{"input": "\tpublic synchronized void initComponentActivity(Body body) {\n\t\tif (!init) {\n\t\t\tthis.logger = LoggerFactory.getLogger(this.getClass());\n\t\t\tlogger.info(\"Initialising {} component.\", this.getClass().getSimpleName());\n\t\t\teleGenerator = new EleGeneratorForConstructQuery();\n\t\t\ttry {\n\t\t\t\tString address = Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.endpoint\");\n\t\t\t\tsoapServer = Endpoint.publish(address, this);\n\t\t\t\tlogger.info(\"QueryDispatch SOAP service started at {}.\", address);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch SOAP Service\", e);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\trestServer = new PlayPlatformservicesRest(this);\n\t \tlogger.info(String.format(\"QueryDispatch REST service started at %s with WADL remotely available at \"\n\t \t\t\t+ \"%sapplication.wadl\\n\", PlayPlatformservicesRest.BASE_URI, Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.rest\")));\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch REST Service\", e);\n\t\t\t}\n\t\t\tthis.init = true;\n\t\t}\n\t}\n", "output": "\tpublic synchronized void initComponentActivity(Body body) {\n\t\tif (!init) {\n\t\t\tthis.logger = LoggerFactory.getLogger(this.getClass());\n\t\t\tlogger.info(\"Initialising {} component.\", this.getClass().getSimpleName());\n\t\t\teleGenerator = new EleGeneratorForConstructQuery();\n\t\t\ttry {\n\t\t\t\tString address = Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.endpoint\");\n\t\t\t\tsoapServer = Endpoint.publish(address, this);\n\t\t\t\tlogger.info(\"QueryDispatch SOAP service started at {}.\", address);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch SOAP Service\", e);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\trestServer = new PlayPlatformservicesRest(this);\n\t \tlogger.info(String.format(\"QueryDispatch REST service started at %s with WADL remotely available at \"\n\t \t\t\t+ \"%s/application.wadl\\n\", PlayPlatformservicesRest.BASE_URI, Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.rest\")));\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch REST Service\", e);\n\t\t\t}\n\t\t\tthis.init = true;\n\t\t}\n\t}\n"} {"input": " public void testEncodeDecode() {\n byte[] bytes = new byte[256];\n new Random(1L).nextBytes(bytes);\n final String encodedBytes = HexDecoder.encode(bytes);\n assertEquals(\n \"Bad encoded data\",\n \"73d51abbd89cb8196f0efb6892f94d68fccc2c35f0b84609e5f12c55dd85aba8d5d9bef76808f3b572e5900112b81927ba5bb5f67e1bda28b4049bf0e4aed78db15d7bf2fc0c34e9a99de4ef3bc2b17c8137ad659878f9e93df1f658367aca286452474b9ef3765e24e9a88173724dddfb04b01dcceb0c8aead641c58dad569581baeea87c10d40a47902028e61cfdc243d9d16008aabc9fb77cc723a56017e14f1ce8b1698341734a6823ce02043e016b544901214a2ddab82fec85c0b9fe0549c475be5b887bb4b8995b24fb5c6846f88b527b4f9d4c1391f1678b23ba4f9c9cd7bc93eb5776f4f03675344864294661c5949faf17b130fcf6482f971a5500\",\n encodedBytes);\n final byte[] decodedBytes = HexDecoder.decode(encodedBytes);\n assertTrue(\"Bad decoded bytes\", Arrays.equals(bytes, decodedBytes));\n }\n", "output": " public void testEncodeDecode() {\n byte[] bytes = new byte[256];\n new Random(1L).nextBytes(bytes);\n final String encodedBytes = HexDecoder.encode(bytes);\n assertEquals(\n \"Bad encoded data\",\n \"73D51ABBD89CB8196F0EFB6892F94D68FCCC2C35F0B84609E5F12C55DD85ABA8D5D9BEF76808F3B572E5900112B81927BA5BB5F67E1BDA28B4049BF0E4AED78DB15D7BF2FC0C34E9A99DE4EF3BC2B17C8137AD659878F9E93DF1F658367ACA286452474B9EF3765E24E9A88173724DDDFB04B01DCCEB0C8AEAD641C58DAD569581BAEEA87C10D40A47902028E61CFDC243D9D16008AABC9FB77CC723A56017E14F1CE8B1698341734A6823CE02043E016B544901214A2DDAB82FEC85C0B9FE0549C475BE5B887BB4B8995B24FB5C6846F88B527B4F9D4C1391F1678B23BA4F9C9CD7BC93EB5776F4F03675344864294661C5949FAF17B130FCF6482F971A5500\",\n encodedBytes);\n final byte[] decodedBytes = HexDecoder.decode(encodedBytes);\n assertTrue(\"Bad decoded bytes\", Arrays.equals(bytes, decodedBytes));\n }\n"} {"input": " public String getGeoSearchSql(final Object domainKey) {\n final String sql = \"\"\n + \"SELECT DISTINCT i.class_id , \"\n + \" i.object_id, \"\n + \" s.stringrep \"\n + \"FROM geom g, \"\n + \" cs_attr_object_derived i \"\n + \" LEFT OUTER JOIN cs_stringrepcache s \"\n + \" ON ( \"\n + \" s.class_id =i.class_id \"\n + \" AND s.object_id=i.object_id \"\n + \" ) \"\n + \"WHERE i.attr_class_id = \"\n + \" ( SELECT cs_class.id \"\n + \" FROM cs_class \"\n + \" WHERE cs_class.table_name::text = 'GEOM'::text \"\n + \" ) \"\n + \"AND i.attr_object_id = g.id \"\n + \"AND i.class_id IN \"\n + \"AND geo_field && GeometryFromText('SRID=;') \"\n + \"AND \"\n + \"ORDER BY 1,2,3\";\n final String sqlAlt = \"\"\n + \"\\nWITH recursive derived_index(ocid,oid,acid,aid,depth) AS \"\n + \"\\n( SELECT class_id, \"\n + \"\\n object_id, \"\n + \"\\n class_id , \"\n + \"\\n object_id, \"\n + \"\\n 0 \"\n + \"\\nFROM geosuche2 \"\n + \"\\nWHERE class_id IN( WITH recursive derived_child(father,child,depth) AS \"\n + \"\\n ( SELECT father, \"\n + \"\\n father , \"\n + \"\\n 0 \"\n + \"\\n FROM cs_class_hierarchy \"\n + \"\\n WHERE father IN \"\n + \"\\n \"\n + \"\\n UNION ALL \"\n + \"\\n \"\n + \"\\n SELECT ch.father, \"\n + \"\\n ch.child , \"\n + \"\\n dc.depth+1 \"\n + \"\\n FROM derived_child dc, \"\n + \"\\n cs_class_hierarchy ch \"\n + \"\\n WHERE ch.father=dc.child \"\n + \"\\n ) \"\n + \"\\n SELECT DISTINCT child \"\n + \"\\n FROM derived_child LIMIT 100 ) \"\n + \"\\nAND geo_field && GeometryFromText('SRID=;') \"\n + \"\\nAND intersects(geo_field,GeometryFromText('SRID=;')) \"\n + \"\\n \"\n + \"\\nUNION ALL \"\n + \"\\n \"\n + \"\\nSELECT aam.class_id , \"\n + \"\\n aam.object_id , \"\n + \"\\n aam.attr_class_id , \"\n + \"\\n aam.attr_object_id, \"\n + \"\\n di.depth+1 \"\n + \"\\nFROM cs_attr_object aam, \"\n + \"\\n derived_index di \"\n + \"\\nWHERE aam.attr_class_id =di.ocid \"\n + \"\\nAND aam.attr_object_id=di.oid \"\n + \"\\n) \"\n + \"\\nSELECT DISTINCT ocid, \"\n + \"\\n oid , \"\n + \"\\n stringrep \"\n + \"\\nFROM derived_index \"\n + \"\\n LEFT OUTER JOIN cs_stringrepcache \"\n + \"\\n ON ( \"\n + \"\\n ocid=class_id \"\n + \"\\n AND oid =object_id \"\n + \"\\n ) \"\n + \"\\nWHERE ocid IN LIMIT 10000000 \";\n final String intersectsStatement;\n if (searchGeometry.getSRID() == 4326) {\n intersectsStatement =\n \"intersects(geo_field,GeometryFromText('SRID=;'))\";\n } else {\n if ((searchGeometry instanceof Polygon) || (searchGeometry instanceof MultiPolygon)) { \n intersectsStatement =\n \"intersects(st_buffer(geo_field, 0.000001),st_buffer(GeometryFromText('SRID=;'), 0.000001))\";\n } else { \n intersectsStatement =\n \"intersects(st_buffer(geo_field, 0.000001),GeometryFromText('SRID=;'), 0.000001)\";\n }\n }\n final String cidsSearchGeometryWKT = searchGeometry.toText();\n final String sridString = Integer.toString(searchGeometry.getSRID());\n final String classesInStatement = getClassesInSnippetsPerDomain().get((String)domainKey);\n if ((cidsSearchGeometryWKT == null) || (cidsSearchGeometryWKT.trim().length() == 0)\n || (sridString == null)\n || (sridString.trim().length() == 0)) {\n getLog().error(\n \"Search geometry or srid is not given. Can't perform a search without those information.\");\n return null;\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"cidsClassesInStatement=\" + classesInStatement);\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"cidsSearchGeometryWKT=\" + cidsSearchGeometryWKT);\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"cidsSearchGeometrySRID=\" + sridString);\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"intersectsStatement=\" + intersectsStatement);\n }\n if ((classesInStatement == null) || (classesInStatement.trim().length() == 0)) {\n getLog().warn(\"There are no search classes defined for domain '\" + domainKey\n + \"'. This domain will be skipped.\");\n return null;\n }\n return sql.replaceAll(\"\", intersectsStatement)\n .replaceAll(\"\", classesInStatement)\n .replaceAll(\"\", cidsSearchGeometryWKT)\n .replaceAll(\"\", sridString);\n }\n", "output": " public String getGeoSearchSql(final Object domainKey) {\n final String sql = \"\"\n + \"SELECT DISTINCT i.class_id , \"\n + \" i.object_id, \"\n + \" s.stringrep \"\n + \"FROM geom g, \"\n + \" cs_attr_object_derived i \"\n + \" LEFT OUTER JOIN cs_stringrepcache s \"\n + \" ON ( \"\n + \" s.class_id =i.class_id \"\n + \" AND s.object_id=i.object_id \"\n + \" ) \"\n + \"WHERE i.attr_class_id = \"\n + \" ( SELECT cs_class.id \"\n + \" FROM cs_class \"\n + \" WHERE cs_class.table_name::text = 'GEOM'::text \"\n + \" ) \"\n + \"AND i.attr_object_id = g.id \"\n + \"AND i.class_id IN \"\n + \"AND geo_field && GeometryFromText('SRID=;') \"\n + \"AND \"\n + \"ORDER BY 1,2,3\";\n final String sqlAlt = \"\"\n + \"\\nWITH recursive derived_index(ocid,oid,acid,aid,depth) AS \"\n + \"\\n( SELECT class_id, \"\n + \"\\n object_id, \"\n + \"\\n class_id , \"\n + \"\\n object_id, \"\n + \"\\n 0 \"\n + \"\\nFROM geosuche2 \"\n + \"\\nWHERE class_id IN( WITH recursive derived_child(father,child,depth) AS \"\n + \"\\n ( SELECT father, \"\n + \"\\n father , \"\n + \"\\n 0 \"\n + \"\\n FROM cs_class_hierarchy \"\n + \"\\n WHERE father IN \"\n + \"\\n \"\n + \"\\n UNION ALL \"\n + \"\\n \"\n + \"\\n SELECT ch.father, \"\n + \"\\n ch.child , \"\n + \"\\n dc.depth+1 \"\n + \"\\n FROM derived_child dc, \"\n + \"\\n cs_class_hierarchy ch \"\n + \"\\n WHERE ch.father=dc.child \"\n + \"\\n ) \"\n + \"\\n SELECT DISTINCT child \"\n + \"\\n FROM derived_child LIMIT 100 ) \"\n + \"\\nAND geo_field && GeometryFromText('SRID=;') \"\n + \"\\nAND intersects(geo_field,GeometryFromText('SRID=;')) \"\n + \"\\n \"\n + \"\\nUNION ALL \"\n + \"\\n \"\n + \"\\nSELECT aam.class_id , \"\n + \"\\n aam.object_id , \"\n + \"\\n aam.attr_class_id , \"\n + \"\\n aam.attr_object_id, \"\n + \"\\n di.depth+1 \"\n + \"\\nFROM cs_attr_object aam, \"\n + \"\\n derived_index di \"\n + \"\\nWHERE aam.attr_class_id =di.ocid \"\n + \"\\nAND aam.attr_object_id=di.oid \"\n + \"\\n) \"\n + \"\\nSELECT DISTINCT ocid, \"\n + \"\\n oid , \"\n + \"\\n stringrep \"\n + \"\\nFROM derived_index \"\n + \"\\n LEFT OUTER JOIN cs_stringrepcache \"\n + \"\\n ON ( \"\n + \"\\n ocid=class_id \"\n + \"\\n AND oid =object_id \"\n + \"\\n ) \"\n + \"\\nWHERE ocid IN LIMIT 10000000 \";\n final String intersectsStatement;\n if (searchGeometry.getSRID() == 4326) {\n intersectsStatement =\n \"intersects(geo_field,GeometryFromText('SRID=;'))\";\n } else {\n if ((searchGeometry instanceof Polygon) || (searchGeometry instanceof MultiPolygon)) { \n intersectsStatement =\n \"intersects(st_buffer(geo_field, 0.000001),st_buffer(GeometryFromText('SRID=;'), 0.000001))\";\n } else { \n intersectsStatement =\n \"intersects(st_buffer(geo_field, 0.000001),GeometryFromText('SRID=;'))\";\n }\n }\n final String cidsSearchGeometryWKT = searchGeometry.toText();\n final String sridString = Integer.toString(searchGeometry.getSRID());\n final String classesInStatement = getClassesInSnippetsPerDomain().get((String)domainKey);\n if ((cidsSearchGeometryWKT == null) || (cidsSearchGeometryWKT.trim().length() == 0)\n || (sridString == null)\n || (sridString.trim().length() == 0)) {\n getLog().error(\n \"Search geometry or srid is not given. Can't perform a search without those information.\");\n return null;\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"cidsClassesInStatement=\" + classesInStatement);\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"cidsSearchGeometryWKT=\" + cidsSearchGeometryWKT);\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"cidsSearchGeometrySRID=\" + sridString);\n }\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"intersectsStatement=\" + intersectsStatement);\n }\n if ((classesInStatement == null) || (classesInStatement.trim().length() == 0)) {\n getLog().warn(\"There are no search classes defined for domain '\" + domainKey\n + \"'. This domain will be skipped.\");\n return null;\n }\n return sql.replaceAll(\"\", intersectsStatement)\n .replaceAll(\"\", classesInStatement)\n .replaceAll(\"\", cidsSearchGeometryWKT)\n .replaceAll(\"\", sridString);\n }\n"} {"input": " private Image labelImage(BufferedImage image, String label) {\n if (label != null) {\n Graphics2D g2 = image.createGraphics();\n String[] words = label.split(\" \");\n String longest = \"\";\n for (int i = 0; i < words.length; i++) {\n if (words[i].length() > longest.length()) {\n longest = words[i];\n }\n }\n int rowGap = 3;\n int x;\n int y = rowGap;\n int iw = image.getWidth();\n int ih = image.getHeight();\n int fontSize = 10;\n Font font = new Font(\"SansSerif\", Font.BOLD, fontSize);\n FontMetrics metrics = g2.getFontMetrics(font);\n while (!(metrics.getStringBounds(longest, g2).getWidth() < iw - 2) &&\n fontSize > 5) {\n fontSize--;\n font = new Font(\"SansSerif\", Font.BOLD, fontSize);\n metrics = g2.getFontMetrics(font);\n }\n g2.setFont(font);\n g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,\n RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);\n g2.setColor(Color.DARK_GRAY);\n Rectangle2D maxBounds = metrics.getMaxCharBounds(g2);\n int wh = (int) maxBounds.getHeight();\n for (int i = 0; i < words.length; i++) {\n Rectangle2D stringBounds = metrics.getStringBounds(words[i], g2);\n x = (int) (iw / 2 - stringBounds.getWidth() / 2);\n g2.drawString(words[i], x, y + wh);\n y += wh + rowGap;\n }\n g2.dispose();\n }\n return image;\n }\n", "output": " private Image labelImage(BufferedImage image, String label) {\n if (label != null) {\n Graphics2D g2 = image.createGraphics();\n String[] words = label.split(\" \");\n String longest = \"\";\n for (int i = 0; i < words.length; i++) {\n if (words[i].length() > longest.length()) {\n longest = words[i];\n }\n }\n int rowGap = 3;\n int x;\n int y = rowGap;\n int iw = image.getWidth();\n int ih = image.getHeight();\n int fontSize = 10;\n Font font = new Font(\"SansSerif\", Font.BOLD, fontSize);\n FontMetrics metrics = g2.getFontMetrics(font);\n while (!(metrics.getStringBounds(longest, g2).getWidth() < iw - 2) &&\n fontSize > 5) {\n fontSize--;\n font = new Font(\"SansSerif\", Font.BOLD, fontSize);\n metrics = g2.getFontMetrics(font);\n }\n g2.setFont(font);\n g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,\n RenderingHints.VALUE_TEXT_ANTIALIAS_ON);\n g2.setColor(Color.DARK_GRAY);\n Rectangle2D maxBounds = metrics.getMaxCharBounds(g2);\n int wh = (int) maxBounds.getHeight();\n for (int i = 0; i < words.length; i++) {\n Rectangle2D stringBounds = metrics.getStringBounds(words[i], g2);\n x = (int) (iw / 2 - stringBounds.getWidth() / 2);\n g2.drawString(words[i], x, y + wh);\n y += wh + rowGap;\n }\n g2.dispose();\n }\n return image;\n }\n"} {"input": "\tpublic void everySecondCheck() {\n\t\tif (schedulerTaskID != -1) {\n\t\t\tConfig.removeBorder(plugin.startPosition.getWorld().getName());\n\t\t\tschedulerTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tswitch (gameStatus) {\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((preGameCountdown - currentLoop) + \" seconds until game starts.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((preGameCountdown - currentLoop % 3600 == 0 || preGameCountdown - currentLoop == 60 || preGameCountdown - currentLoop % 60 == 0 || (preGameCountdown - currentLoop <= 10 && preGameCountdown - currentLoop > 0) || preGameCountdown - currentLoop == 15 || preGameCountdown - currentLoop == 30) && preGameCountdown - currentLoop != 0) {\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(String.format(plugin.strings.get(\"starttimeleft\"), (((preGameCountdown - currentLoop) % 3600) == 0) ? ((preGameCountdown - currentLoop) / 60) + \" hour\" + ((((preGameCountdown - currentLoop) / 60) == 1) ? \"s\" : \"\") : ((preGameCountdown - currentLoop) % 60 == 0 ? (preGameCountdown - currentLoop) / 60 + \" minute\" + (((preGameCountdown - currentLoop) / 60) == 1 ? \"\" : \"s\") : (preGameCountdown - currentLoop) + \" second\" + ((preGameCountdown - currentLoop != 1) ? \"s\" : \"\"))));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= preGameCountdown) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Attempting to start...\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (plugin.serverwide.livingPlayers.size() <= minPlayersToStart) { \n\t\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(plugin.strings.get(\"startnotenoughplayers\"));\n\t\t\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\t\t\tScheduledTasks.gameStatus = 2;\n\t\t\t\t\t\t\t\t\tplugin.scheduler.startGame();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((gameInvincibleCountdown - currentLoop) + \" seconds until invincibility ends.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= gameInvincibleCountdown) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Invincibility has ended.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(plugin.strings.get(\"invincibilityend\"));\n\t\t\t\t\t\t\t\tgameStatus = 3;\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((gameOvertimeCountdown - currentLoop) + \" seconds until overtime starts.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((currentLoop - gameOvertimeCountdown) % 60 == 0 || (((currentLoop - gameOvertimeCountdown) / 60) <= 60 && ((((currentLoop - gameOvertimeCountdown) / 60) == 30 || ((currentLoop - gameOvertimeCountdown) / 60) == 15 || (((currentLoop - gameOvertimeCountdown) / 60) <= 10 && !(((currentLoop - gameOvertimeCountdown) / 60) == 0)))))) {\n\t\t\t\t\t\t\t\tif (!((currentLoop - gameOvertimeCountdown) == 0)) {\n\t\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers( (gameOvertimeCountdown-currentLoop ) % 60 == 0 ? (gameOvertimeCountdown-currentLoop) / 60 + \" minutes until overtime starts\" : (gameOvertimeCountdown-currentLoop) / 60 +\" minutes and \" + (gameOvertimeCountdown-currentLoop) % 60 + \" seconds until overtime starts.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= gameOvertimeCountdown) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Overtime has started.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(plugin.strings.get(\"overtimestart\"));\n\t\t\t\t\t\t\t\tfor (Player p : plugin.getServer().getOnlinePlayers()) {\n\t\t\t\t\t\t\t\t\tif (plugin.serverwide.getArcher(p).isReady) {\n\t\t\t\t\t\t\t\t\t\tp.teleport(plugin.startPosition);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tConfig.setBorder(plugin.startPosition.getWorld().getName(), overtimeWorldRadius, plugin.startPosition.getBlockX(), plugin.startPosition.getBlockZ(), true); \n\t\t\t\t\t\t\t\tgameStatus = 4;\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\tint alivePlayers = 0;\n\t\t\t\t\t\t\tfor (Player p : plugin.getServer().getOnlinePlayers()) {\n\t\t\t\t\t\t\t\tif (Archer.getByName(p.getName()).isAlive()) {\n\t\t\t\t\t\t\t\t\talivePlayers++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (alivePlayers <= 1) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Game has ended.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.scheduler.endGame();\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 5:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((shutdownTimer - currentLoop) + \" seconds until server reboots.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop % 5 == 0) {\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(ChatColor.GREEN + \"\" + plugin.winner + \" is the winner!\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= shutdownTimer) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Kicking all players, then shutting down.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfor (Player p : plugin.getServer().getOnlinePlayers()) {\n\t\t\t\t\t\t\t\t\tp.kickPlayer(plugin.strings.get(\"serverclosekick\"));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.getServer().shutdown();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, 20L, 20L);\n\t\t\tif (plugin.debug) {\n\t\t\t\tplugin.log.info(\"Task ID is \" + schedulerTaskID);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin.log.severe(\"Scheduler task start was attempted, but scheduler task already running!\");\n\t\t}\n\t}\n", "output": "\tpublic void everySecondCheck() {\n\t\tif (schedulerTaskID != -1) {\n\t\t\tConfig.removeBorder(plugin.startPosition.getWorld().getName());\n\t\t\tschedulerTaskID = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tswitch (gameStatus) {\n\t\t\t\t\t\tcase 1:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((preGameCountdown - currentLoop) + \" seconds until game starts.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((preGameCountdown - currentLoop % 3600 == 0 || preGameCountdown - currentLoop == 60 || preGameCountdown - currentLoop % 60 == 0 || (preGameCountdown - currentLoop <= 10 && preGameCountdown - currentLoop > 0) || preGameCountdown - currentLoop == 15 || preGameCountdown - currentLoop == 30) && preGameCountdown - currentLoop != 0) {\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(String.format(plugin.strings.get(\"starttimeleft\"), (((preGameCountdown - currentLoop) % 3600) == 0) ? ((preGameCountdown - currentLoop) / 60) + \" hour\" + ((((preGameCountdown - currentLoop) / 60) == 1) ? \"s\" : \"\") : ((preGameCountdown - currentLoop) % 60 == 0 ? (preGameCountdown - currentLoop) / 60 + \" minute\" + (((preGameCountdown - currentLoop) / 60) == 1 ? \"\" : \"s\") : (preGameCountdown - currentLoop) + \" second\" + ((preGameCountdown - currentLoop != 1) ? \"s\" : \"\"))));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= preGameCountdown) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Attempting to start...\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (plugin.serverwide.livingPlayers.size() <= minPlayersToStart) { \n\t\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(plugin.strings.get(\"startnotenoughplayers\"));\n\t\t\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\t\t\tScheduledTasks.gameStatus = 2;\n\t\t\t\t\t\t\t\t\tplugin.scheduler.startGame();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((gameInvincibleCountdown - currentLoop) + \" seconds until invincibility ends.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= gameInvincibleCountdown) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Invincibility has ended.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(plugin.strings.get(\"invincibilityend\"));\n\t\t\t\t\t\t\t\tgameStatus = 3;\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((gameOvertimeCountdown - currentLoop) + \" seconds until overtime starts.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((currentLoop - gameOvertimeCountdown) % 60 == 0 || (((currentLoop - gameOvertimeCountdown) / 60) <= 60 && ((((currentLoop - gameOvertimeCountdown) / 60) == 30 || ((currentLoop - gameOvertimeCountdown) / 60) == 15 || (((currentLoop - gameOvertimeCountdown) / 60) <= 10 && !(((currentLoop - gameOvertimeCountdown) / 60) == 0)))))) {\n\t\t\t\t\t\t\t\tif (!((currentLoop - gameOvertimeCountdown) == 0)) {\n\t\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers( (gameOvertimeCountdown-currentLoop ) % 60 == 0 ? (gameOvertimeCountdown-currentLoop) / 60 + \" minutes until overtime starts\" : (gameOvertimeCountdown-currentLoop) / 60 +\" minutes and \" + (gameOvertimeCountdown-currentLoop) % 60 + \" seconds until overtime starts.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= gameOvertimeCountdown) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Overtime has started.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(plugin.strings.get(\"overtimestart\"));\n\t\t\t\t\t\t\t\tfor (Player p : plugin.getServer().getOnlinePlayers()) {\n\t\t\t\t\t\t\t\t\tif (plugin.serverwide.getArcher(p).isReady) {\n\t\t\t\t\t\t\t\t\t\tp.teleport(plugin.startPosition);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tConfig.setBorder(plugin.startPosition.getWorld().getName(), overtimeWorldRadius, plugin.startPosition.getBlockX(), plugin.startPosition.getBlockZ(), true); \n\t\t\t\t\t\t\t\tgameStatus = 4;\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\tint alivePlayers = 0;\n\t\t\t\t\t\t\tfor (Player p : plugin.getServer().getOnlinePlayers()) {\n\t\t\t\t\t\t\t\tif (Archer.getByName(p.getName()).isAlive()) {\n\t\t\t\t\t\t\t\t\talivePlayers++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (alivePlayers <= 1) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Game has ended.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.scheduler.endGame();\n\t\t\t\t\t\t\t\tcurrentLoop = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 5:\n\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\tplugin.log.info((shutdownTimer - currentLoop) + \" seconds until server reboots.\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop % 5 == 0) {\n\t\t\t\t\t\t\t\tplugin.serverwide.sendMessageToAllPlayers(ChatColor.GREEN + \"\" + plugin.serverwide.winner + \" is the winner!\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (currentLoop >= shutdownTimer) {\n\t\t\t\t\t\t\t\tif (plugin.debug) {\n\t\t\t\t\t\t\t\t\tplugin.log.info(\"Kicking all players, then shutting down.\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfor (Player p : plugin.getServer().getOnlinePlayers()) {\n\t\t\t\t\t\t\t\t\tp.kickPlayer(plugin.strings.get(\"serverclosekick\"));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tplugin.getServer().shutdown();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentLoop++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, 20L, 20L);\n\t\t\tif (plugin.debug) {\n\t\t\t\tplugin.log.info(\"Task ID is \" + schedulerTaskID);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin.log.severe(\"Scheduler task start was attempted, but scheduler task already running!\");\n\t\t}\n\t}\n"} {"input": " public static T templateFor( Class clazz )\n {\n NullArgumentException.validateNotNull( \"Template class\", clazz );\n if( clazz.isInterface() )\n {\n return clazz.cast( Proxy.newProxyInstance( clazz.getClassLoader(),\n new Class[] { clazz },\n new TemplateHandler( null, null, null ) ) );\n }\n else\n {\n try\n {\n T mixin = clazz.newInstance();\n for( Field field : clazz.getFields() )\n {\n if( field.getAnnotation( State.class ) != null )\n {\n if( field.getType().equals( Property.class ) )\n {\n field.set( mixin,\n Proxy.newProxyInstance( field.getType().getClassLoader(),\n new Class[]{ field.getType() },\n new PropertyReferenceHandler<>( new PropertyFunction( null, null, null, field ) ) ) );\n }\n else if( field.getType().equals( Association.class ) )\n {\n field.set( mixin,\n Proxy.newProxyInstance( field.getType().getClassLoader(),\n new Class[]{ field.getType() },\n new AssociationReferenceHandler<>( new AssociationFunction( null, null, field ) ) ) );\n }\n else if( field.getType().equals( Property.class ) )\n {\n field.set( mixin,\n Proxy.newProxyInstance( field.getType().getClassLoader(),\n new Class[]{ field.getType() },\n new ManyAssociationReferenceHandler<>( new ManyAssociationFunction( null, null, field ) ) ) );\n }\n }\n }\n return mixin;\n }\n catch( IllegalAccessException | IllegalArgumentException | InstantiationException | SecurityException e )\n {\n throw new IllegalArgumentException( \"Cannot use class as template\", e );\n }\n }\n }\n", "output": " public static T templateFor( Class clazz )\n {\n NullArgumentException.validateNotNull( \"Template class\", clazz );\n if( clazz.isInterface() )\n {\n return clazz.cast( Proxy.newProxyInstance( clazz.getClassLoader(),\n new Class[] { clazz },\n new TemplateHandler( null, null, null ) ) );\n }\n else\n {\n try\n {\n T mixin = clazz.newInstance();\n for( Field field : clazz.getFields() )\n {\n if( field.getAnnotation( State.class ) != null )\n {\n if( field.getType().equals( Property.class ) )\n {\n field.set( mixin,\n Proxy.newProxyInstance( field.getType().getClassLoader(),\n new Class[]{ field.getType() },\n new PropertyReferenceHandler<>( new PropertyFunction( null, null, null, field ) ) ) );\n }\n else if( field.getType().equals( Association.class ) )\n {\n field.set( mixin,\n Proxy.newProxyInstance( field.getType().getClassLoader(),\n new Class[]{ field.getType() },\n new AssociationReferenceHandler<>( new AssociationFunction( null, null, field ) ) ) );\n }\n else if( field.getType().equals( ManyAssociation.class ) )\n {\n field.set( mixin,\n Proxy.newProxyInstance( field.getType().getClassLoader(),\n new Class[]{ field.getType() },\n new ManyAssociationReferenceHandler<>( new ManyAssociationFunction( null, null, field ) ) ) );\n }\n }\n }\n return mixin;\n }\n catch( IllegalAccessException | IllegalArgumentException | InstantiationException | SecurityException e )\n {\n throw new IllegalArgumentException( \"Cannot use class as template\", e );\n }\n }\n }\n"} {"input": " void sendHtmlMailReport(ITestContext testContext) {\n String buildNumber = System.getProperty(\"sgtest.buildNumber\");\n String suiteName = System.getProperty(\"sgtest.suiteName\");\n List mailRecipients = null;\n if(buildNumber == null)\n return;\n Properties props = new Properties();\n InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(\"framework/report/mailreporter.properties\");\n try {\n props.load(in);\n in.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n MailReporterProperties mailProperties = new MailReporterProperties(props);\n String link = null;\n if (suiteName.contains(\"webui\")) {\n \tlink = \"\"+buildNumber+\" \";\n }\n else {\n \tlink = \"\"+buildNumber+\" \";\n }\n StringBuilder sb = new StringBuilder();\n sb.append(\"\").append(\"\\n\");\n sb.append(\"

SGTtest Results




\").append(\"\\n\");\n sb.append(\"

Suite Name: \" + testContext.getSuite().getName() + \"


\").append(\"\\n\");\n sb.append(\"

Start Date: \" + testContext.getStartDate() + \"


\").append(\"\\n\");\n sb.append(\"

End Date: \" + testContext.getEndDate() + \"


\").append(\"\\n\");\n sb.append(\"

Skipped Configurations: \" + testContext.getSkippedConfigurations().size() + \"


\").append(\"\\n\");\n sb.append(\"

Skipped Tests: \" + testContext.getSkippedTests().size() + \"


\").append(\"\\n\");\n sb.append(\"

Failed Tests: \" + testContext.getFailedTests().size() + \"


\").append(\"\\n\");\n sb.append(\"

Passed Tests: \" + testContext.getPassedTests().size() + \"


\").append(\"\\n\");\n sb.append(\"

Full Suite Report: \" + link + \"


\").append(\"\\n\");\n sb.append(\"\");\n try {\n \tmailRecipients = mailProperties.getRecipients();\n \tif (suiteName.contains(\"webui\")) mailRecipients = mailProperties.getWebUIRecipients();\n \tif (suiteName.equals(\"ServiceGrid\")) mailRecipients = mailProperties.getSGRecipients();\n \tif (suiteName.equals(\"WAN\")) mailRecipients = mailProperties.getWanRecipients();\n \tif (suiteName.equals(\"SECURITY\")) mailRecipients = mailProperties.getSecurityRecipients();\n \tif (suiteName.equals(\"CLOUDIFY\")) mailRecipients = mailProperties.getCloudifyRecipients();\n \tif (suiteName.equals(\"ESM\")) mailRecipients = mailProperties.getESMRecipients();\n SimpleMail.send(mailProperties.getMailHost(), mailProperties.getUsername(), mailProperties.getPassword(),\n \"SGTest Suite \" + testContext.getSuite().getName() + \" results\", sb.toString(), mailRecipients);\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n", "output": " void sendHtmlMailReport(ITestContext testContext) {\n String buildNumber = System.getProperty(\"sgtest.buildNumber\");\n String suiteName = System.getProperty(\"sgtest.suiteName\");\n List mailRecipients = null;\n if(buildNumber == null)\n return;\n Properties props = new Properties();\n InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(\"framework/report/mailreporter.properties\");\n try {\n props.load(in);\n in.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n MailReporterProperties mailProperties = new MailReporterProperties(props);\n String link = null;\n if (suiteName.contains(\"webui\")) {\n \tlink = \"\"+buildNumber+\" \";\n }\n else {\n \tlink = \"\"+buildNumber+\" \";\n }\n StringBuilder sb = new StringBuilder();\n sb.append(\"\").append(\"\\n\");\n sb.append(\"

SGTtest Results




\").append(\"\\n\");\n sb.append(\"

Suite Name: \" + testContext.getSuite().getName() + \"


\").append(\"\\n\");\n sb.append(\"

Start Date: \" + testContext.getStartDate() + \"


\").append(\"\\n\");\n sb.append(\"

End Date: \" + testContext.getEndDate() + \"


\").append(\"\\n\");\n sb.append(\"

Skipped Configurations: \" + testContext.getSkippedConfigurations().size() + \"


\").append(\"\\n\");\n sb.append(\"

Skipped Tests: \" + testContext.getSkippedTests().size() + \"


\").append(\"\\n\");\n sb.append(\"

Failed Tests: \" + testContext.getFailedTests().size() + \"


\").append(\"\\n\");\n sb.append(\"

Passed Tests: \" + testContext.getPassedTests().size() + \"


\").append(\"\\n\");\n sb.append(\"

Full Suite Report: \" + link + \"


\").append(\"\\n\");\n sb.append(\"\");\n try {\n \tmailRecipients = mailProperties.getRecipients();\n \tif (suiteName.contains(\"webui\")) mailRecipients = mailProperties.getWebUIRecipients();\n \tif (suiteName.equals(\"ServiceGrid\")) mailRecipients = mailProperties.getSGRecipients();\n \tif (suiteName.equals(\"WAN\")) mailRecipients = mailProperties.getWanRecipients();\n \tif (suiteName.equals(\"SECURITY\")) mailRecipients = mailProperties.getSecurityRecipients();\n \tif (suiteName.equals(\"CLOUDIFY\")) mailRecipients = mailProperties.getCloudifyRecipients();\n \tif (suiteName.equals(\"ESM\")) mailRecipients = mailProperties.getESMRecipients();\n SimpleMail.send(mailProperties.getMailHost(), mailProperties.getUsername(), mailProperties.getPassword(),\n \"SGTest Suite \" + testContext.getSuite().getName() + \" results\", sb.toString(), mailRecipients);\n } catch (Exception e) {\n e.printStackTrace();\n }\n }\n"} {"input": " protected void doCopyToCimi(final CimiContext context, final Credentials dataService, final CimiCredentials dataCimi) {\n this.fill(context, dataService, dataCimi);\n if (true == context.mustBeExpanded(dataCimi)) {\n dataCimi.setUserName(dataService.getUserName());\n if (true == context.isConvertedWriteOnly()) {\n dataCimi.setKey(dataService.getPublicKey());\n dataCimi.setPassword(dataService.getPassword());\n }\n }\n }\n", "output": " protected void doCopyToCimi(final CimiContext context, final Credentials dataService, final CimiCredentials dataCimi) {\n this.fill(context, dataService, dataCimi);\n if (true == context.mustBeExpanded(dataCimi)) {\n dataCimi.setUserName(dataService.getUserName());\n dataCimi.setKey(dataService.getPublicKey());\n if (true == context.isConvertedWriteOnly()) {\n dataCimi.setPassword(dataService.getPassword());\n }\n }\n }\n"} {"input": "\t\tprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\t\tif( request.getSession().getAttribute(\"adherent\") == null ) {\n\t\t\tresponse.sendRedirect(request.getContextPath() + \"/Login\");\n\t\t\treturn;\n\t\t}\n\t\tArticlePersistence service = PersistenceServiceProvider.getService(ArticlePersistence.class);\n\t\tif( articleAjoute(request) ) {\n\t\t\tint id = Integer.parseInt( request.getParameter(\"article\") );\n\t\t\tArticle article = service.load(id);\n\t\t\tif ( article == null ) {\n\t\t\t\tresponse.sendError(HttpServletResponse.SC_NOT_FOUND, \"La page entr\ufffde n'est pas valide \");\n return;\n\t\t\t}\n else {\n HttpSession session = request.getSession();\n ArrayList
articles = (ArrayList
) session.getAttribute(\"orderInProcess\");\n if( articles == null ) {\n articles = new ArrayList<>();\n }\n articles.add(article);\n request.setAttribute(\"added\", id);\n }\n\t\t}\n\t\tList
articles = service.loadAll();\n\t\tRequestDispatcher rd;\n\t\trequest.setAttribute(\"articles\", articles);\n\t\trd = context.getRequestDispatcher(\"/jsp/Articles.jsp\");\n\t\trd.include(request, response);\n\t}\n", "output": "\t\tprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\t\tif( request.getSession().getAttribute(\"adherent\") == null ) {\n\t\t\tresponse.sendRedirect(request.getContextPath() + \"/Login\");\n\t\t\treturn;\n\t\t}\n\t\tArticlePersistence service = PersistenceServiceProvider.getService(ArticlePersistence.class);\n\t\tif( articleAjoute(request) ) {\n\t\t\tint id = Integer.parseInt( request.getParameter(\"article\") );\n\t\t\tArticle article = service.load(id);\n\t\t\tif ( article == null ) {\n\t\t\t\tresponse.sendError(HttpServletResponse.SC_NOT_FOUND, \"La page entr\u00e9e n'est pas valide \");\n return;\n\t\t\t}\n else {\n HttpSession session = request.getSession();\n ArrayList
articles = (ArrayList
) session.getAttribute(\"orderInProcess\");\n if( articles == null ) {\n articles = new ArrayList<>();\n session.setAttribute(\"orderInProcess\",articles);\n }\n articles.add(article);\n request.setAttribute(\"added\", id);\n }\n\t\t}\n\t\tList
articles = service.loadAll();\n\t\tRequestDispatcher rd;\n\t\trequest.setAttribute(\"articles\", articles);\n\t\trd = context.getRequestDispatcher(\"/jsp/Articles.jsp\");\n\t\trd.include(request, response);\n\t}\n"} {"input": " private void initComponents() {\n userPasswordPanel = new javax.swing.JPanel();\n upServerLabel = new javax.swing.JLabel();\n upPasswordLabel = new javax.swing.JLabel();\n upUsernameLabel = new javax.swing.JLabel();\n upServerField = new javax.swing.JTextField();\n upPasswordField = new javax.swing.JPasswordField();\n upUsernameField = new javax.swing.JTextField();\n webPanel = new javax.swing.JPanel();\n webServerLabel = new javax.swing.JLabel();\n webServerField = new javax.swing.JTextField();\n jLabel1 = new javax.swing.JLabel();\n gradientPanel1 = new org.jdesktop.wonderland.client.jme.login.GradientPanel();\n worldNameLabel = new javax.swing.JLabel();\n gradientPanel2 = new org.jdesktop.wonderland.client.jme.login.GradientPanel();\n loginSpecificPanel = new javax.swing.JPanel();\n tagLineLabel = new javax.swing.JLabel();\n buttonPanel = new javax.swing.JPanel();\n cancelButton = new javax.swing.JButton();\n loginButton = new javax.swing.JButton();\n getRootPane().setDefaultButton(loginButton);\n statusLabel = new javax.swing.JLabel();\n advancedButton = new javax.swing.JButton();\n userPasswordPanel.setOpaque(false);\n upServerLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(\"org/jdesktop/wonderland/client/jme/login/Bundle\"); \n upServerLabel.setText(bundle.getString(\"WonderlandLoginDialog.upServerLabel.text\")); \n upPasswordLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n upPasswordLabel.setText(bundle.getString(\"WonderlandLoginDialog.upPasswordLabel.text\")); \n upUsernameLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n upUsernameLabel.setText(bundle.getString(\"WonderlandLoginDialog.upUsernameLabel.text\")); \n upServerField.setEditable(false);\n upPasswordField.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n upPasswordField.setMinimumSize(new java.awt.Dimension(98, 22));\n upUsernameField.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n upUsernameField.setMinimumSize(new java.awt.Dimension(98, 22));\n org.jdesktop.layout.GroupLayout userPasswordPanelLayout = new org.jdesktop.layout.GroupLayout(userPasswordPanel);\n userPasswordPanel.setLayout(userPasswordPanelLayout);\n userPasswordPanelLayout.setHorizontalGroup(\n userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(userPasswordPanelLayout.createSequentialGroup()\n .add(26, 26, 26)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)\n .add(upPasswordLabel)\n .add(upUsernameLabel)\n .add(upServerLabel))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)\n .add(upUsernameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .add(upPasswordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .add(upServerField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE))\n .addContainerGap())\n );\n userPasswordPanelLayout.setVerticalGroup(\n userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, userPasswordPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(upUsernameLabel)\n .add(upUsernameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(upPasswordLabel)\n .add(upPasswordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(upServerField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(upServerLabel))\n .add(20, 20, 20))\n );\n webPanel.setOpaque(false);\n webPanel.setPreferredSize(new java.awt.Dimension(402, 140));\n webServerLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n webServerLabel.setText(bundle.getString(\"WonderlandLoginDialog.webServerLabel.text\")); \n webServerField.setEditable(false);\n webServerField.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n webServerField.setMinimumSize(new java.awt.Dimension(98, 22));\n jLabel1.setText(bundle.getString(\"WonderlandLoginDialog.jLabel1.text\")); \n org.jdesktop.layout.GroupLayout webPanelLayout = new org.jdesktop.layout.GroupLayout(webPanel);\n webPanel.setLayout(webPanelLayout);\n webPanelLayout.setHorizontalGroup(\n webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(webPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(webPanelLayout.createSequentialGroup()\n .add(webServerLabel)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(webServerField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))\n .add(jLabel1))\n .addContainerGap())\n );\n webPanelLayout.setVerticalGroup(\n webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, webPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(jLabel1)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 56, Short.MAX_VALUE)\n .add(webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(webServerLabel)\n .add(webServerField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addContainerGap())\n );\n setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\n setResizable(false);\n gradientPanel1.setGradientEndColor(new java.awt.Color(163, 183, 255));\n gradientPanel1.setGradientStartColor(new java.awt.Color(0, 51, 255));\n gradientPanel1.setMinimumSize(new java.awt.Dimension(0, 82));\n worldNameLabel.setFont(new java.awt.Font(\"Arial\", 1, 36));\n worldNameLabel.setForeground(new java.awt.Color(255, 255, 255));\n worldNameLabel.setText(bundle.getString(\"WonderlandLoginDialog.worldNameLabel.text\")); \n org.jdesktop.layout.GroupLayout gradientPanel1Layout = new org.jdesktop.layout.GroupLayout(gradientPanel1);\n gradientPanel1.setLayout(gradientPanel1Layout);\n gradientPanel1Layout.setHorizontalGroup(\n gradientPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(gradientPanel1Layout.createSequentialGroup()\n .addContainerGap()\n .add(worldNameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 372, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addContainerGap(66, Short.MAX_VALUE))\n );\n gradientPanel1Layout.setVerticalGroup(\n gradientPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(gradientPanel1Layout.createSequentialGroup()\n .addContainerGap()\n .add(worldNameLabel)\n .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n );\n gradientPanel2.setGradientEndColor(new java.awt.Color(217, 225, 255));\n gradientPanel2.setGradientStartColor(new java.awt.Color(163, 183, 255));\n gradientPanel2.setLayout(new java.awt.BorderLayout());\n loginSpecificPanel.setOpaque(false);\n loginSpecificPanel.setLayout(new java.awt.BorderLayout());\n gradientPanel2.add(loginSpecificPanel, java.awt.BorderLayout.CENTER);\n tagLineLabel.setFont(new java.awt.Font(\"Arial\", 1, 18));\n tagLineLabel.setForeground(new java.awt.Color(255, 255, 255));\n tagLineLabel.setText(bundle.getString(\"WonderlandLoginDialog.tagLineLabel.text\")); \n tagLineLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);\n tagLineLabel.setAlignmentY(0.0F);\n tagLineLabel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));\n tagLineLabel.setFocusable(false);\n gradientPanel2.add(tagLineLabel, java.awt.BorderLayout.NORTH);\n buttonPanel.setOpaque(false);\n buttonPanel.setPreferredSize(new java.awt.Dimension(453, 65));\n cancelButton.setBackground(new java.awt.Color(255, 255, 255));\n cancelButton.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n cancelButton.setText(bundle.getString(\"WonderlandLoginDialog.cancelButton.text\")); \n cancelButton.setAlignmentX(0.5F);\n cancelButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n cancelButtonActionPerformed(evt);\n }\n });\n loginButton.setBackground(new java.awt.Color(255, 255, 255));\n loginButton.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n loginButton.setText(bundle.getString(\"WonderlandLoginDialog.loginButton.text\")); \n loginButton.setAlignmentX(0.5F);\n loginButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n loginButtonActionPerformed(evt);\n }\n });\n statusLabel.setFont(new java.awt.Font(\"Arial\", 1, 12));\n statusLabel.setForeground(new java.awt.Color(45, 45, 45));\n statusLabel.setText(bundle.getString(\"WonderlandLoginDialog.statusLabel.text\")); \n advancedButton.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n advancedButton.setText(bundle.getString(\"WonderlandLoginDialog.advancedButton.text\")); \n advancedButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n advancedButtonActionPerformed(evt);\n }\n });\n org.jdesktop.layout.GroupLayout buttonPanelLayout = new org.jdesktop.layout.GroupLayout(buttonPanel);\n buttonPanel.setLayout(buttonPanelLayout);\n buttonPanelLayout.setHorizontalGroup(\n buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(buttonPanelLayout.createSequentialGroup()\n .add(buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(buttonPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(statusLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 308, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(10, 10, 10))\n .add(org.jdesktop.layout.GroupLayout.TRAILING, buttonPanelLayout.createSequentialGroup()\n .addContainerGap(110, Short.MAX_VALUE)\n .add(cancelButton)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(loginButton)\n .add(40, 40, 40)))\n .add(advancedButton)\n .addContainerGap())\n );\n buttonPanelLayout.linkSize(new java.awt.Component[] {cancelButton, loginButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n buttonPanelLayout.setVerticalGroup(\n buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(buttonPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(statusLabel)\n .add(advancedButton))\n .addContainerGap(24, Short.MAX_VALUE))\n .add(org.jdesktop.layout.GroupLayout.TRAILING, buttonPanelLayout.createSequentialGroup()\n .addContainerGap(24, Short.MAX_VALUE)\n .add(buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(loginButton)\n .add(cancelButton))\n .addContainerGap())\n );\n gradientPanel2.add(buttonPanel, java.awt.BorderLayout.PAGE_END);\n org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());\n getContentPane().setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(gradientPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)\n .add(gradientPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n );\n layout.setVerticalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .add(gradientPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(4, 4, 4)\n .add(gradientPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))\n );\n pack();\n }\n", "output": " private void initComponents() {\n userPasswordPanel = new javax.swing.JPanel();\n upServerLabel = new javax.swing.JLabel();\n upPasswordLabel = new javax.swing.JLabel();\n upUsernameLabel = new javax.swing.JLabel();\n upServerField = new javax.swing.JTextField();\n upPasswordField = new javax.swing.JPasswordField();\n upUsernameField = new javax.swing.JTextField();\n webPanel = new javax.swing.JPanel();\n webServerLabel = new javax.swing.JLabel();\n webServerField = new javax.swing.JTextField();\n jLabel1 = new javax.swing.JLabel();\n gradientPanel1 = new org.jdesktop.wonderland.client.jme.login.GradientPanel();\n worldNameLabel = new javax.swing.JLabel();\n gradientPanel2 = new org.jdesktop.wonderland.client.jme.login.GradientPanel();\n loginSpecificPanel = new javax.swing.JPanel();\n tagLineLabel = new javax.swing.JLabel();\n buttonPanel = new javax.swing.JPanel();\n cancelButton = new javax.swing.JButton();\n loginButton = new javax.swing.JButton();\n getRootPane().setDefaultButton(loginButton);\n statusLabel = new javax.swing.JLabel();\n advancedButton = new javax.swing.JButton();\n userPasswordPanel.setOpaque(false);\n upServerLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(\"org/jdesktop/wonderland/client/jme/login/Bundle\"); \n upServerLabel.setText(bundle.getString(\"WonderlandLoginDialog.upServerLabel.text\")); \n upPasswordLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n upPasswordLabel.setText(bundle.getString(\"WonderlandLoginDialog.upPasswordLabel.text\")); \n upUsernameLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n upUsernameLabel.setText(bundle.getString(\"WonderlandLoginDialog.upUsernameLabel.text\")); \n upServerField.setEditable(false);\n upPasswordField.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n upPasswordField.setMinimumSize(new java.awt.Dimension(98, 22));\n upUsernameField.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n upUsernameField.setMinimumSize(new java.awt.Dimension(98, 22));\n org.jdesktop.layout.GroupLayout userPasswordPanelLayout = new org.jdesktop.layout.GroupLayout(userPasswordPanel);\n userPasswordPanel.setLayout(userPasswordPanelLayout);\n userPasswordPanelLayout.setHorizontalGroup(\n userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(userPasswordPanelLayout.createSequentialGroup()\n .add(26, 26, 26)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)\n .add(upPasswordLabel)\n .add(upUsernameLabel)\n .add(upServerLabel))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)\n .add(upUsernameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .add(upPasswordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .add(upServerField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE))\n .addContainerGap())\n );\n userPasswordPanelLayout.setVerticalGroup(\n userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, userPasswordPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(upUsernameLabel)\n .add(upUsernameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(upPasswordLabel)\n .add(upPasswordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(userPasswordPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(upServerField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(upServerLabel))\n .add(20, 20, 20))\n );\n webPanel.setOpaque(false);\n webPanel.setPreferredSize(new java.awt.Dimension(402, 140));\n webServerLabel.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n webServerLabel.setText(bundle.getString(\"WonderlandLoginDialog.webServerLabel.text\")); \n webServerField.setEditable(false);\n webServerField.setFont(new java.awt.Font(\"Dialog\", 0, 13));\n webServerField.setMinimumSize(new java.awt.Dimension(98, 22));\n jLabel1.setText(bundle.getString(\"WonderlandLoginDialog.jLabel1.text\")); \n org.jdesktop.layout.GroupLayout webPanelLayout = new org.jdesktop.layout.GroupLayout(webPanel);\n webPanel.setLayout(webPanelLayout);\n webPanelLayout.setHorizontalGroup(\n webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(webPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(webPanelLayout.createSequentialGroup()\n .add(webServerLabel)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(webServerField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE))\n .add(jLabel1))\n .addContainerGap())\n );\n webPanelLayout.setVerticalGroup(\n webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, webPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(jLabel1)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 56, Short.MAX_VALUE)\n .add(webPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(webServerLabel)\n .add(webServerField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addContainerGap())\n );\n setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\n setResizable(false);\n gradientPanel1.setGradientEndColor(new java.awt.Color(163, 183, 255));\n gradientPanel1.setGradientStartColor(new java.awt.Color(0, 51, 255));\n gradientPanel1.setMinimumSize(new java.awt.Dimension(0, 82));\n worldNameLabel.setFont(new java.awt.Font(\"Arial\", 1, 36)); \n worldNameLabel.setForeground(new java.awt.Color(255, 255, 255));\n worldNameLabel.setText(bundle.getString(\"WonderlandLoginDialog.worldNameLabel.text\")); \n org.jdesktop.layout.GroupLayout gradientPanel1Layout = new org.jdesktop.layout.GroupLayout(gradientPanel1);\n gradientPanel1.setLayout(gradientPanel1Layout);\n gradientPanel1Layout.setHorizontalGroup(\n gradientPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(gradientPanel1Layout.createSequentialGroup()\n .addContainerGap()\n .add(worldNameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 372, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addContainerGap(72, Short.MAX_VALUE))\n );\n gradientPanel1Layout.setVerticalGroup(\n gradientPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(gradientPanel1Layout.createSequentialGroup()\n .addContainerGap()\n .add(worldNameLabel)\n .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n );\n gradientPanel2.setGradientEndColor(new java.awt.Color(217, 225, 255));\n gradientPanel2.setGradientStartColor(new java.awt.Color(163, 183, 255));\n gradientPanel2.setLayout(new java.awt.BorderLayout());\n loginSpecificPanel.setOpaque(false);\n loginSpecificPanel.setLayout(new java.awt.BorderLayout());\n gradientPanel2.add(loginSpecificPanel, java.awt.BorderLayout.CENTER);\n tagLineLabel.setFont(new java.awt.Font(\"Arial\", 1, 18));\n tagLineLabel.setForeground(new java.awt.Color(255, 255, 255));\n tagLineLabel.setText(bundle.getString(\"WonderlandLoginDialog.tagLineLabel.text\")); \n tagLineLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);\n tagLineLabel.setAlignmentY(0.0F);\n tagLineLabel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));\n tagLineLabel.setFocusable(false);\n gradientPanel2.add(tagLineLabel, java.awt.BorderLayout.NORTH);\n buttonPanel.setOpaque(false);\n buttonPanel.setPreferredSize(new java.awt.Dimension(453, 65));\n cancelButton.setBackground(new java.awt.Color(255, 255, 255));\n cancelButton.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n cancelButton.setText(bundle.getString(\"WonderlandLoginDialog.cancelButton.text\")); \n cancelButton.setAlignmentX(0.5F);\n cancelButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n cancelButtonActionPerformed(evt);\n }\n });\n loginButton.setBackground(new java.awt.Color(255, 255, 255));\n loginButton.setFont(new java.awt.Font(\"Dialog\", 1, 13));\n loginButton.setText(bundle.getString(\"WonderlandLoginDialog.loginButton.text\")); \n loginButton.setAlignmentX(0.5F);\n loginButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n loginButtonActionPerformed(evt);\n }\n });\n statusLabel.setFont(new java.awt.Font(\"Arial\", 1, 12)); \n statusLabel.setForeground(new java.awt.Color(45, 45, 45));\n statusLabel.setText(bundle.getString(\"WonderlandLoginDialog.statusLabel.text\")); \n advancedButton.setFont(new java.awt.Font(\"Dialog\", 0, 13)); \n advancedButton.setText(bundle.getString(\"WonderlandLoginDialog.advancedButton.text\")); \n advancedButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n advancedButtonActionPerformed(evt);\n }\n });\n org.jdesktop.layout.GroupLayout buttonPanelLayout = new org.jdesktop.layout.GroupLayout(buttonPanel);\n buttonPanel.setLayout(buttonPanelLayout);\n buttonPanelLayout.setHorizontalGroup(\n buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(buttonPanelLayout.createSequentialGroup()\n .add(buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(buttonPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(statusLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 308, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(10, 10, 10))\n .add(org.jdesktop.layout.GroupLayout.TRAILING, buttonPanelLayout.createSequentialGroup()\n .addContainerGap(103, Short.MAX_VALUE)\n .add(cancelButton)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(loginButton)\n .add(40, 40, 40)))\n .add(advancedButton)\n .addContainerGap())\n );\n buttonPanelLayout.linkSize(new java.awt.Component[] {cancelButton, loginButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n buttonPanelLayout.setVerticalGroup(\n buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(buttonPanelLayout.createSequentialGroup()\n .addContainerGap()\n .add(buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(statusLabel)\n .add(advancedButton))\n .addContainerGap(30, Short.MAX_VALUE))\n .add(org.jdesktop.layout.GroupLayout.TRAILING, buttonPanelLayout.createSequentialGroup()\n .addContainerGap(30, Short.MAX_VALUE)\n .add(buttonPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(loginButton)\n .add(cancelButton))\n .addContainerGap())\n );\n gradientPanel2.add(buttonPanel, java.awt.BorderLayout.PAGE_END);\n org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());\n getContentPane().setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(gradientPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)\n .add(gradientPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n );\n layout.setVerticalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .add(gradientPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(4, 4, 4)\n .add(gradientPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))\n );\n pack();\n }\n"} {"input": " public boolean execute(Menu menu, Player player, String[] args, String command, ItemStack menuItem, Iterator commands, Player targetPlayer, Block targetBlock) {\n if (args.length != 5) {\n player.sendMessage(\"Error in menu script line (expected /TakeChest [x] [y] [z] [slot1,fromSlot-toSlot...] [amount]): \" + command);\n return false;\n }\n int x, y, z;\n try {\n x = Integer.parseInt(args[0]);\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for x): \" + args[0]);\n return false;\n }\n try {\n y = Integer.parseInt(args[1]);\n if (y < 0 || y > 255) {\n player.sendMessage(\"Error in menu script line (expected y between 0 and 255): \" + args[2]);\n return false;\n }\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for y): \" + args[1]);\n return false;\n }\n try {\n z = Integer.parseInt(args[2]);\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for z): \" + args[2]);\n return false;\n }\n List slots;\n try {\n slots = ValidationUtils.getSlotRange(args[3]);\n } catch (IllegalArgumentException ex) {\n player.sendMessage(\"Error in menu script line \" + ex.getLocalizedMessage());\n return false;\n }\n int amount;\n try {\n amount = Integer.parseInt(args[4]);\n if (amount < 1) {\n player.sendMessage(\"Error in menu script line (expected amount of at least 1): \" + args[4]);\n return false;\n }\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for amount): \" + args[4]);\n return false;\n }\n Block block = player.getWorld().getBlockAt(x, y, z);\n if (block.getState() instanceof InventoryHolder) {\n InventoryHolder chest = (InventoryHolder) block.getState();\n Inventory inv = chest.getInventory();\n InventoryReport chestData;\n try {\n chestData = InventoryReport.getReport(inv, slots);\n } catch (IllegalArgumentException ex) {\n player.sendMessage(ex.getLocalizedMessage());\n return false;\n }\n if (chestData.getCount() <= amount) {\n player.sendMessage(\"There are not enough \" + chestData.toString() + \" in stock\");\n return false;\n }\n int count = 0;\n PlayerInventory to = player.getInventory();\n List toDrop = new ArrayList<>();\n for (Map.Entry entry : chestData.getItems().entrySet()) {\n int slot = entry.getKey();\n ItemStack item = entry.getValue();\n count += item.getAmount();\n if (count < amount) {\n inv.clear(slot);\n toDrop.addAll(to.addItem(item).values());\n } else {\n int remaining = count - amount;\n if (remaining > 0) {\n ItemStack split = item.clone();\n split.setAmount(item.getAmount() - remaining);\n item.setAmount(remaining);\n toDrop.addAll(to.addItem(split).values());\n } else {\n inv.clear(slot);\n toDrop.addAll(to.addItem(item).values());\n }\n break;\n }\n }\n if (!toDrop.isEmpty()) {\n World world = player.getWorld();\n Location loc = player.getLocation();\n for (ItemStack drop : toDrop) {\n world.dropItem(loc, drop);\n }\n }\n player.updateInventory();\n for (HumanEntity viewer : chest.getInventory().getViewers()) {\n if (viewer instanceof Player) {\n ((Player) viewer).updateInventory();\n }\n }\n return true;\n } else {\n player.sendMessage(\"Error in menu script line (expected chest at \" + x + \",\" + y + \",\" + z + \"): \" + block.getType().name());\n return false;\n }\n }\n", "output": " public boolean execute(Menu menu, Player player, String[] args, String command, ItemStack menuItem, Iterator commands, Player targetPlayer, Block targetBlock) {\n if (args.length != 5) {\n player.sendMessage(\"Error in menu script line (expected /TakeChest [x] [y] [z] [slot1,fromSlot-toSlot...] [amount]): \" + command);\n return false;\n }\n int x, y, z;\n try {\n x = Integer.parseInt(args[0]);\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for x): \" + args[0]);\n return false;\n }\n try {\n y = Integer.parseInt(args[1]);\n if (y < 0 || y > 255) {\n player.sendMessage(\"Error in menu script line (expected y between 0 and 255): \" + args[2]);\n return false;\n }\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for y): \" + args[1]);\n return false;\n }\n try {\n z = Integer.parseInt(args[2]);\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for z): \" + args[2]);\n return false;\n }\n List slots;\n try {\n slots = ValidationUtils.getSlotRange(args[3]);\n } catch (IllegalArgumentException ex) {\n player.sendMessage(\"Error in menu script line \" + ex.getLocalizedMessage());\n return false;\n }\n int amount;\n try {\n amount = Integer.parseInt(args[4]);\n if (amount < 1) {\n player.sendMessage(\"Error in menu script line (expected amount of at least 1): \" + args[4]);\n return false;\n }\n } catch (NumberFormatException ex) {\n player.sendMessage(\"Error in menu script line (expected whole number for amount): \" + args[4]);\n return false;\n }\n Block block = player.getWorld().getBlockAt(x, y, z);\n if (block.getState() instanceof InventoryHolder) {\n InventoryHolder chest = (InventoryHolder) block.getState();\n Inventory inv = chest.getInventory();\n InventoryReport chestData;\n try {\n chestData = InventoryReport.getReport(inv, slots);\n } catch (IllegalArgumentException ex) {\n player.sendMessage(ex.getLocalizedMessage());\n return false;\n }\n if (!chestData.hasType()) {\n player.sendMessage(\"This item is no longer being stocked\");\n return false;\n }\n if (chestData.getCount() <= amount) {\n player.sendMessage(\"There are not enough \" + chestData.toString() + \" in stock\");\n return false;\n }\n int count = 0;\n PlayerInventory to = player.getInventory();\n List toDrop = new ArrayList<>();\n for (Map.Entry entry : chestData.getItems().entrySet()) {\n int slot = entry.getKey();\n ItemStack item = entry.getValue();\n count += item.getAmount();\n if (count < amount) {\n inv.clear(slot);\n toDrop.addAll(to.addItem(item).values());\n } else {\n int remaining = count - amount;\n if (remaining > 0) {\n ItemStack split = item.clone();\n split.setAmount(item.getAmount() - remaining);\n item.setAmount(remaining);\n toDrop.addAll(to.addItem(split).values());\n } else {\n inv.clear(slot);\n toDrop.addAll(to.addItem(item).values());\n }\n break;\n }\n }\n if (!toDrop.isEmpty()) {\n World world = player.getWorld();\n Location loc = player.getLocation();\n for (ItemStack drop : toDrop) {\n world.dropItem(loc, drop);\n }\n }\n player.updateInventory();\n for (HumanEntity viewer : chest.getInventory().getViewers()) {\n if (viewer instanceof Player) {\n ((Player) viewer).updateInventory();\n }\n }\n return true;\n } else {\n player.sendMessage(\"Error in menu script line (expected chest at \" + x + \",\" + y + \",\" + z + \"): \" + block.getType().name());\n return false;\n }\n }\n"} {"input": " public void testDescribeLayerVersion111() throws Exception {\n String layer = MockData.FORESTS.getPrefix() + \":\" + MockData.FORESTS.getLocalPart();\n String request = \"wms?service=wms&version=1.1.1&request=DescribeLayer&layers=\" + layer;\n Document dom = getAsDOM(request);\n assertEquals(\"1.1.1\", dom.getDocumentElement().getAttributes().getNamedItem(\"version\").getNodeValue());\n }\n", "output": " public void testDescribeLayerVersion111() throws Exception {\n String layer = MockData.FORESTS.getPrefix() + \":\" + MockData.FORESTS.getLocalPart();\n String request = \"wms?service=wms&version=1.1.1&request=DescribeLayer&layers=\" + layer;\n Document dom = getAsDOM(request, true);\n assertEquals(\"1.1.1\", dom.getDocumentElement().getAttributes().getNamedItem(\"version\").getNodeValue());\n }\n"} {"input": "\tprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\t\tboolean ret = false; \n\t\tboolean res = true;\n\t\tHttpSession session = request.getSession(false);\n\t\tString actionUrl = \"\";\n\t\tList errorMsgs = new ArrayList();\t\t\n\t\tMember user = new Member();\n\t\tString imagePath = getServletContext().getRealPath(\"image\"); \n\t\tint size = 2 * 1024 * 1024; \n\t\tMultipartRequest multi = new MultipartRequest(request, imagePath, size, \"utf-8\", new DefaultFileRenamePolicy());\t\n\t\trequest.setCharacterEncoding(\"utf-8\");\n\t\tString userid = multi.getParameter(\"userid\");\n\t\tString userpwd = multi.getParameter(\"pwd\");\n\t\t\tSystem.out.println(\"userid:\" + userid + \" / userpwd : \"+ userpwd);\n\t\tString pwd_confirm \t= multi.getParameter(\"pwd_confirm\");\n\t\tString lastname \t= multi.getParameter(\"lastname\");\n\t\tString firstname \t= multi.getParameter(\"firstname\");\n\t\tString nickname \t= multi.getParameter(\"nickname\");\n\t\tString email \t\t= multi.getParameter(\"email\");\n\t\tString gender \t\t= multi.getParameter(\"gender\");\n\t\tString website\t\t= multi.getParameter(\"website\");\n\t\tString introduce \t= multi.getParameter(\"introduce\");\n\t\tString info \t\t= multi.getParameter(\"info\");\n\t\tif(isRegisterMode(multi) == state.signup || isRegisterMode(multi) == state.update) {\n\t\t\tif (userpwd.length() < 6 || userpwd == null ) {\n\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\ub294 6\uc790 \uc774\uc0c1 \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t} \n\t\t\tif (!userpwd.equals(pwd_confirm)) {\n\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\uac00 \uc77c\uce58\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\");\n\t\t\t\tres = false;\n\t\t\t} \n\t\t\tif (userid == null || userid.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"ID\ub97c \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (lastname == null || lastname.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\uc131\uc744 \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (firstname == null || firstname.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\uc774\ub984\uc744 \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (nickname == null || nickname.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\ubcc4\uba85\uc744 \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (gender == null || !(gender.equals(\"M\") || gender.equals(\"F\") )) {\n\t\t\t\terrorMsgs.add(\"\uc131\ubcc4\uc5d0 \uc801\ud569\ud558\uc9c0 \uc54a\uc740 \uac12\uc774 \uc785\ub825\ub418\uc5c8\uc2b5\ub2c8\ub2e4.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (info == null || !(info.equals(\"Y\") || info.equals(\"N\") )) {\n\t\t\t\terrorMsgs.add(\"\uc815\ubcf4 \uacf5\uac1c\uc5ec\ubd80\ub97c \uc120\ud0dd\ud574\uc8fc\uc138\uc694\");\n\t\t\t\tres = false;\n\t\t\t}\n\t\t} else if(isRegisterMode(multi) == state.login) {\n\t\t\tif (userid == null || userid.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"ID\ub97c \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\n\t\t\tif (userpwd == null || userpwd.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\ub97c \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tif(res && (isRegisterMode(multi) == state.signup || isRegisterMode(multi) == state.update)) {\n\t\t\t\tuser.setUserid(userid);\n\t\t\t\tuser.setPwd(userpwd);\n\t\t\t\tuser.setRegisterdate(new Timestamp(System.currentTimeMillis()));\n\t\t\t\tuser.setLastname(lastname);\n\t\t\t\tuser.setFirstname(firstname);\n\t\t\t\tuser.setNickname(nickname);\n\t\t\t\tuser.setEmail(email);\n\t\t\t\tuser.setGender(gender);\n\t\t\t\tuser.setIntroduce(introduce);\n\t\t\t\tuser.setWebsite(website);\n\t\t\t\tuser.setInfo(info);\n\t\t\t\tret = SignUpManager.SignUp(multi, response, user, imagePath, isRegisterMode(multi).toString()); \n\t\t\t\tif (user.getProfilephoto() == null) {\n\t\t\t\t\terrorMsgs.add(\"\uc0ac\uc9c4 \uc5c5\ub85c\ub4dc\uc5d0 \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud558\uc5ec \uc0ac\uc9c4\uc774 \uc5c5\ub85c\ub4dc \ub418\uc9c0 \uc54a\uc558\uc2b5\ub2c8\ub2e4\");\n\t\t\t\t}\n\t\t\t\tif(ret) {\n\t\t\t\t\tSystem.out.println(\"\ud68c\uc6d0\uac00\uc785\uc774\ub098 \uc218\uc815 \uc798\ub428\");\n\t\t\t\t\tactionUrl = \"main.jsp\";\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(\"\ud68c\uc6d0\uac00\uc785\uc774\ub098 \uc218\uc815 \uc798\uc548\ub428\");\n\t\t\t\t\tactionUrl = \"signup.jsp\";\n\t\t\t\t}\n\t\t\t} else if(res && (isRegisterMode(multi) == state.login)) {\n\t\t\t\tuser = MemberDAO.findById(userid);\n\t\t\t\tif(user != null) {\n\t\t\t\t\tif( user.getUserid().equals(userid) && user.getPwd().equals(userpwd) ) {\n\t\t\t\t\t\tsession.setAttribute(\"userid\", user.getUserid());\n\t\t\t\t\t session.setAttribute(\"usernickname\", user.getNickname());\n\t\t\t\t\t session.setAttribute(\"profilephoto\", user.getProfilephoto());\n\t\t\t\t\t System.out.println(\"\ub85c\uadf8\uc778\uc131\uacf5!\" + user.getUserid() + \"\ub2d8\uc774 \ub85c\uadf8\uc778\ud558\uc168\uc2b5\ub2c8\ub2e4.\");\n\t\t\t\t\t\tactionUrl = \"main.jsp\";\n\t\t\t\t\t\tret = true;\n\t\t\t\t\t} else if(user.getPwd() != userpwd) {\n\t\t\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\uac00 \uc77c\uce58\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ub2e4\uc2dc \ud655\uc778\ud574\uc8fc\uc138\uc694\");\n\t\t\t\t\t\tactionUrl = \"login.jsp\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terrorMsgs.add(\"\uc5c6\ub294 \uc544\uc774\ub514\uc785\ub2c8\ub2e4. \ub2e4\uc2dc \ud655\uc778\ud574\uc8fc\uc138\uc694\");\n\t\t\t\t\tactionUrl = \"login.jsp\";\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tactionUrl = \"error.jsp\";\n\t\t\t}\n\t\t} catch (SQLException | NamingException e) {\n\t\t\tSystem.out.println(e.getMessage());\n\t\t\terrorMsgs.add(\"\uc54c \uc218 \uc5c6\ub294 \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud558\uc600\uc2b5\ub2c8\ub2e4. \ub2e4\uc2dc \uc2dc\ub3c4\ud574\uc8fc\uc138\uc694\");\n\t\t\tsession.invalidate();\n\t\t\tactionUrl = \"error.jsp\";\n\t\t}\n\t\tif(actionUrl.equals(\"main.jsp\")) {\n\t\t\tresponse.sendRedirect(\"\");\n\t\t} else {\t\t\n\t\t\trequest.setAttribute(\"errorMsgs\", errorMsgs);\n\t\t\tRequestDispatcher dispatcher = request.getRequestDispatcher(actionUrl);\n\t\t\tdispatcher.forward(request, response);\n\t\t}\n\t}\n", "output": "\tprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n\t\tboolean ret = false; \n\t\tboolean res = true;\n\t\tHttpSession session = request.getSession(false);\n\t\tString actionUrl = \"\";\n\t\tList errorMsgs = new ArrayList();\t\t\n\t\tMember user = new Member();\n\t\tString imagePath = getServletContext().getRealPath(\"image\"); \n\t\tint size = 2 * 1024 * 1024; \n\t\tMultipartRequest multi = new MultipartRequest(request, imagePath, size, \"utf-8\", new DefaultFileRenamePolicy());\t\n\t\trequest.setCharacterEncoding(\"utf-8\");\n\t\tString userid = multi.getParameter(\"userid\");\n\t\tString userpwd = multi.getParameter(\"pwd\");\n\t\t\tSystem.out.println(\"userid:\" + userid + \" / userpwd : \"+ userpwd);\n\t\tString pwd_confirm \t= multi.getParameter(\"pwd_confirm\");\n\t\tString lastname \t= multi.getParameter(\"lastname\");\n\t\tString firstname \t= multi.getParameter(\"firstname\");\n\t\tString nickname \t= multi.getParameter(\"nickname\");\n\t\tString email \t\t= multi.getParameter(\"email\");\n\t\tString gender \t\t= multi.getParameter(\"gender\");\n\t\tString website\t\t= multi.getParameter(\"website\");\n\t\tString introduce \t= multi.getParameter(\"introduce\");\n\t\tString info \t\t= multi.getParameter(\"info\");\n\t\tif(isRegisterMode(multi) == state.signup || isRegisterMode(multi) == state.update) {\n\t\t\tif (userpwd.length() < 6 || userpwd == null ) {\n\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\ub294 6\uc790 \uc774\uc0c1 \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t} \n\t\t\tif (!userpwd.equals(pwd_confirm)) {\n\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\uac00 \uc77c\uce58\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\");\n\t\t\t\tres = false;\n\t\t\t} \n\t\t\tif (userid == null || userid.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"ID\ub97c \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (lastname == null || lastname.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\uc131\uc744 \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (firstname == null || firstname.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\uc774\ub984\uc744 \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (nickname == null || nickname.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\ubcc4\uba85\uc744 \ubc18\ub4dc\uc2dc \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (gender == null || !(gender.equals(\"M\") || gender.equals(\"F\") )) {\n\t\t\t\terrorMsgs.add(\"\uc131\ubcc4\uc5d0 \uc801\ud569\ud558\uc9c0 \uc54a\uc740 \uac12\uc774 \uc785\ub825\ub418\uc5c8\uc2b5\ub2c8\ub2e4.\");\n\t\t\t\tres = false;\n\t\t\t}\t\t\t\n\t\t\tif (info == null || !(info.equals(\"Y\") || info.equals(\"N\") )) {\n\t\t\t\terrorMsgs.add(\"\uc815\ubcf4 \uacf5\uac1c\uc5ec\ubd80\ub97c \uc120\ud0dd\ud574\uc8fc\uc138\uc694\");\n\t\t\t\tres = false;\n\t\t\t}\n\t\t} else if(isRegisterMode(multi) == state.login) {\n\t\t\tif (userid == null || userid.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"ID\ub97c \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\n\t\t\tif (userpwd == null || userpwd.trim().length() == 0) {\n\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\ub97c \uc785\ub825\ud574\uc8fc\uc138\uc694.\");\n\t\t\t\tres = false;\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tif(res && (isRegisterMode(multi) == state.signup || isRegisterMode(multi) == state.update)) {\n\t\t\t\tuser.setUserid(userid);\n\t\t\t\tuser.setPwd(userpwd);\n\t\t\t\tuser.setRegisterdate(new Timestamp(System.currentTimeMillis()));\n\t\t\t\tuser.setLastname(lastname);\n\t\t\t\tuser.setFirstname(firstname);\n\t\t\t\tuser.setNickname(nickname);\n\t\t\t\tuser.setEmail(email);\n\t\t\t\tuser.setGender(gender);\n\t\t\t\tuser.setIntroduce(introduce);\n\t\t\t\tuser.setWebsite(website);\n\t\t\t\tuser.setInfo(info);\n\t\t\t\tret = SignUpManager.SignUp(multi, response, user, imagePath, isRegisterMode(multi).toString()); \n\t\t\t\tif (user.getProfilephoto() == null) {\n\t\t\t\t\terrorMsgs.add(\"\uc774 \uba54\uc138\uc9c0\ub294 \uc0ac\uc9c4 \uc5c5\ub85c\ub4dc\ub97c \ud558\uc9c0 \uc54a\uc558\uac70\ub098 \uc0ac\uc9c4 \uc5c5\ub85c\ub4dc\uc2dc \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud588\uc744\ub54c \ubcf4\uc774\ub294 \uba54\uc138\uc9c0\uc785\ub2c8\ub2e4\");\n\t\t\t\t\tSystem.out.println(\"\uc774 \uba54\uc138\uc9c0\ub294 \uc0ac\uc9c4 \uc5c5\ub85c\ub4dc\ub97c \ud558\uc9c0 \uc54a\uc558\uac70\ub098 \uc0ac\uc9c4 \uc5c5\ub85c\ub4dc\uc2dc \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud588\uc744\ub54c \ubcf4\uc774\ub294 \uba54\uc138\uc9c0\uc785\ub2c8\ub2e4\" );\n\t\t\t\t}\n\t\t\t\tif(ret) {\n\t\t\t\t\tSystem.out.println(\"\ud68c\uc6d0\uac00\uc785\uc774\ub098 \uc218\uc815 \uc798\ub428\");\n\t\t\t\t\tactionUrl = \"main.jsp\";\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(\"\ud68c\uc6d0\uac00\uc785\uc774\ub098 \uc218\uc815 \uc798\uc548\ub428\");\n\t\t\t\t\tactionUrl = \"error.jsp\";\n\t\t\t\t}\n\t\t\t} else if(res && (isRegisterMode(multi) == state.login)) {\n\t\t\t\tuser = MemberDAO.findById(userid);\n\t\t\t\tif(user != null) {\n\t\t\t\t\tif( user.getUserid().equals(userid) && user.getPwd().equals(userpwd) ) {\n\t\t\t\t\t\tsession.setAttribute(\"userid\", user.getUserid());\n\t\t\t\t\t session.setAttribute(\"usernickname\", user.getNickname());\n\t\t\t\t\t session.setAttribute(\"profilephoto\", user.getProfilephoto());\n\t\t\t\t\t System.out.println(\"\ub85c\uadf8\uc778\uc131\uacf5!\" + user.getUserid() + \"\ub2d8\uc774 \ub85c\uadf8\uc778\ud558\uc168\uc2b5\ub2c8\ub2e4.\");\n\t\t\t\t\t\tactionUrl = \"main.jsp\";\n\t\t\t\t\t\tret = true;\n\t\t\t\t\t} else if(user.getPwd() != userpwd) {\n\t\t\t\t\t\terrorMsgs.add(\"\ube44\ubc00\ubc88\ud638\uac00 \uc77c\uce58\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \ub2e4\uc2dc \ud655\uc778\ud574\uc8fc\uc138\uc694\");\n\t\t\t\t\t\tactionUrl = \"login.jsp\";\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terrorMsgs.add(\"\uc5c6\ub294 \uc544\uc774\ub514\uc785\ub2c8\ub2e4. \ub2e4\uc2dc \ud655\uc778\ud574\uc8fc\uc138\uc694\");\n\t\t\t\t\tactionUrl = \"login.jsp\";\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tactionUrl = \"error.jsp\";\n\t\t\t}\n\t\t} catch (SQLException | NamingException e) {\n\t\t\tSystem.out.println(e.getMessage());\n\t\t\terrorMsgs.add(\"\uc54c \uc218 \uc5c6\ub294 \ubb38\uc81c\uac00 \ubc1c\uc0dd\ud558\uc600\uc2b5\ub2c8\ub2e4. \ub2e4\uc2dc \uc2dc\ub3c4\ud574\uc8fc\uc138\uc694\");\n\t\t\tsession.invalidate();\n\t\t\tactionUrl = \"error.jsp\";\n\t\t}\n\t\tif(actionUrl.equals(\"main.jsp\")) {\n\t\t\tresponse.sendRedirect(\"\");\n\t\t} else {\t\t\n\t\t\trequest.setAttribute(\"errorMsgs\", errorMsgs);\n\t\t\tRequestDispatcher dispatcher = request.getRequestDispatcher(actionUrl);\n\t\t\tdispatcher.forward(request, response);\n\t\t}\n\t}\n"} {"input": " private void initPopup() {\n mParent = LayoutInflater.from(getContext()).inflate(R.layout.switcher_popup,\n (ViewGroup) getParent());\n LinearLayout content = (LinearLayout) mParent.findViewById(R.id.content);\n mPopup = content;\n mPopup.setVisibility(View.INVISIBLE);\n mNeedsAnimationSetup = true;\n for (int i = mDrawIds.length - 1; i >= 0; i--) {\n RotateImageView item = new RotateImageView(getContext());\n item.setImageResource(mDrawIds[i]);\n item.setBackgroundResource(R.drawable.bg_pressed);\n final int index = i;\n item.setOnClickListener(new OnClickListener() {\n @Override\n public void onClick(View v) {\n onCameraSelected(index);\n }\n });\n switch (mDrawIds[i]) {\n case R.drawable.ic_switch_camera:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_camera));\n break;\n case R.drawable.ic_switch_video:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_video));\n break;\n case R.drawable.ic_switch_pan:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_panorama));\n break;\n case com.android.gallery3d.R.drawable.ic_menu_photosphere:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_lightcycle));\n break;\n default:\n break;\n }\n content.addView(item, new LinearLayout.LayoutParams(mItemSize, mItemSize));\n }\n }\n", "output": " private void initPopup() {\n mParent = LayoutInflater.from(getContext()).inflate(R.layout.switcher_popup,\n (ViewGroup) getParent());\n LinearLayout content = (LinearLayout) mParent.findViewById(R.id.content);\n mPopup = content;\n mPopup.setVisibility(View.INVISIBLE);\n mNeedsAnimationSetup = true;\n for (int i = mDrawIds.length - 1; i >= 0; i--) {\n RotateImageView item = new RotateImageView(getContext());\n item.setImageResource(mDrawIds[i]);\n item.setBackgroundResource(R.drawable.bg_pressed);\n final int index = i;\n item.setOnClickListener(new OnClickListener() {\n @Override\n public void onClick(View v) {\n onCameraSelected(index);\n }\n });\n switch (mDrawIds[i]) {\n case R.drawable.ic_switch_camera:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_camera));\n break;\n case R.drawable.ic_switch_video:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_video));\n break;\n case R.drawable.ic_switch_pan:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_panorama));\n break;\n case com.android.gallery3d.R.drawable.ic_menu_photosphere:\n item.setContentDescription(getContext().getResources().getString(\n R.string.accessibility_switch_to_photosphere));\n break;\n default:\n break;\n }\n content.addView(item, new LinearLayout.LayoutParams(mItemSize, mItemSize));\n }\n }\n"} {"input": " protected void checkExtraRules(final SQueriableLog log) {\n if (log.getActionStatus() != SQueriableLog.STATUS_FAIL && log.getNumericIndex(COMMENT_INDEX) == 0L) {\n throw new MissingMandatoryFieldsException(\"Some mandatoryFildes are missing: \" + \"comment Id\");\n }\n }\n", "output": " protected void checkExtraRules(final SQueriableLog log) {\n if (log.getActionStatus() != SQueriableLog.STATUS_FAIL && log.getNumericIndex(COMMENT_INDEX) == 0L) {\n throw new MissingMandatoryFieldsException(\"Some mandatory fields are missing: \" + \"comment Id\");\n }\n }\n"} {"input": " public void init() {\n logger = LoggerFactory.getLogger(getClass());\n logger.debug(\"initializing bean \" + getClass().getName());\n attributes = Attributes.getBehaviorAttributes(ToggleControl.class, getClass());\n attributes.setAttribute(\"forPanel\", \"panel1\");\n attributes.setAttribute(\"targetItem\", \"item1\");\n attributes.remove(\"disableDefault\");\n attributes.remove(\"event\"); \n }\n", "output": " public void init() {\n logger = LoggerFactory.getLogger(getClass());\n logger.debug(\"initializing bean \" + getClass().getName());\n attributes = Attributes.getBehaviorAttributes(ToggleControl.class, getClass());\n attributes.setAttribute(\"targetPanel\", \"panel1\");\n attributes.setAttribute(\"targetItem\", \"item1\");\n attributes.remove(\"disableDefault\");\n attributes.remove(\"event\"); \n }\n"} {"input": "\tpublic static boolean onOptionsItemSelected(MenuItem item, Context context) {\n\t\tswitch (item.getItemId()) {\n\t\tcase R.id.menu_log_in_out:\n\t\t\tSessionHandler sh = SessionHandler.getInstance(context);\n\t\t\tif(sh.hasSession()){\n\t\t\t\tsh.logOut();\n\t\t\t} else {\n\t\t\t\tcontext.startActivity(new Intent(context, LogInActivity.class));\n\t\t\t}\n\t\t\treturn true;\n\t\tcase R.id.menu_options:\n\t\t\tToast.makeText(context, \"Not implemented\", Toast.LENGTH_SHORT);\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t\t}\n\t}\n", "output": "\tpublic static boolean onOptionsItemSelected(MenuItem item, Context context) {\n\t\tswitch (item.getItemId()) {\n\t\tcase R.id.menu_log_in_out:\n\t\t\tSessionHandler sh = SessionHandler.getInstance(context);\n\t\t\tif(sh.hasSession()){\n\t\t\t\tsh.logOut();\n\t\t\t} else {\n\t\t\t\tcontext.startActivity(new Intent(context, LogInActivity.class));\n\t\t\t}\n\t\t\treturn true;\n\t\tcase R.id.menu_options:\n\t\t\tToast.makeText(context, \"Not implemented\", Toast.LENGTH_SHORT).show();\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t\t}\n\t}\n"} {"input": " protected static void initialize(Object mystcraft) {\n if (mystcraft == null) {\n Objects.log.log(Level.SEVERE, \"Mystcraft is not installed or not found! This mod requires mystcraft to function!\");\n return;\n }\n try {\n hideTechnicalBlocks();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed hiding technical blocks from NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed hiding technical blocks from NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addDecayTypes();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding different kinds of decay to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding different kinds of decay to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addCreativeNotebook(mystcraft);\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding a creative notebook to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding a creative notebook to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addPages();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding symbol pages to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding symbol pages to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addLinkPanels();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding link panels to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding link panels to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addItemRanges();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding item ranges to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding item ranges to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n getMethodsAndFields();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting methods and fields\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting methods and fields, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n PluginNEIMystcraft.guiInkMixerClass = (Class) Class.forName(\"com.xcompwiz.mystcraft.client.GuiInkMixer\");\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting GUI classes\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting GUI classes, you don't need to report this as I'll probably already know about this\", ex);\n }\n }\n", "output": " protected static void initialize(Object mystcraft) {\n if (mystcraft == null) {\n Objects.log.log(Level.SEVERE, \"Mystcraft is not installed or not found! This mod requires mystcraft to function!\");\n return;\n }\n try {\n hideTechnicalBlocks();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed hiding technical blocks from NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed hiding technical blocks from NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addDecayTypes();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding different kinds of decay to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding different kinds of decay to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addCreativeNotebook(mystcraft);\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding a creative notebook to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding a creative notebook to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addPages();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding symbol pages to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding symbol pages to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addLinkPanels();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding link panels to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding link panels to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n addItemRanges();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding item ranges to NEI\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed adding item ranges to NEI, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n getMethodsAndFields();\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting methods and fields\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting methods and fields, you don't need to report this as I'll probably already know about this\", ex);\n }\n try {\n PluginNEIMystcraft.guiInkMixerClass = (Class) Class.forName(\"com.xcompwiz.mystcraft.client.gui.GuiInkMixer\");\n }\n catch (Exception ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting GUI classes\", ex);\n }\n catch (Error ex) {\n Objects.log.log(Level.SEVERE, \"Failed getting GUI classes, you don't need to report this as I'll probably already know about this\", ex);\n }\n }\n"} {"input": " private InferredPath traverseEdge(\n EdgeTransitionDistributions edgeTransDist,\n final MultivariateGaussian belief, PathEdge startEdge,\n StandardRoadTrackingFilter movementFilter) {\n rng.setSeed(this.localSeed);\n PathEdge currentEdge = startEdge;\n PathEdge previousEdge = null;\n final MultivariateGaussian newBelief = belief.clone();\n final List currentPath = Lists.newArrayList();\n double distTraveled = 0d;\n Double totalDistToTravel = null;\n while (totalDistToTravel == null ||\n Math.abs(totalDistToTravel) > Math.abs(distTraveled)) {\n final List transferEdges = Lists.newArrayList();\n if (currentEdge.getInferredEdge() == InferredEdge\n .getEmptyEdge()) {\n final Vector projLocation =\n StandardRoadTrackingFilter.getOg().times(\n newBelief.getMean());\n for (final StreetEdge edge : this.inferredGraph\n .getNearbyEdges(projLocation,\n movementFilter.getObservationErrorAbsRadius())) {\n transferEdges.add(this.inferredGraph.getInferredEdge(edge));\n }\n } else {\n if (totalDistToTravel == null) {\n transferEdges.add(startEdge.getInferredEdge());\n } else {\n if (newBelief.getMean().getElement(0) < 0d) {\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getIncomingTransferableEdges());\n } else if (newBelief.getMean().getElement(0) > 0d) {\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getOutgoingTransferableEdges());\n } else {\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getIncomingTransferableEdges());\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getOutgoingTransferableEdges());\n }\n transferEdges.remove(currentEdge.getInferredEdge());\n }\n }\n final InferredEdge sampledEdge =\n edgeTransDist.sample(rng, transferEdges,\n currentEdge == null ? startEdge.getInferredEdge()\n : currentEdge.getInferredEdge());\n if (sampledEdge == InferredEdge.getEmptyEdge()) {\n if (totalDistToTravel == null) {\n movementFilter.predict(newBelief,\n PathEdge.getEmptyPathEdge(), startEdge);\n } else {\n StandardRoadTrackingFilter.convertToGroundBelief(newBelief,\n currentEdge, true);\n }\n currentEdge = PathEdge.getEmptyPathEdge();\n currentPath.add(PathEdge.getEmptyPathEdge());\n break;\n }\n double direction =\n newBelief.getMean().getElement(0) >= 0d ? 1d : -1d;\n final PathEdge sampledPathEdge =\n PathEdge.getEdge(sampledEdge, previousEdge == null\n || previousEdge.isEmptyEdge() ? 0d : direction\n * previousEdge.getInferredEdge().getLength()\n + previousEdge.getDistToStartOfEdge());\n if (sampledPathEdge == null) {\n newBelief.getMean().setElement(0,\n direction * currentEdge.getInferredEdge().getLength());\n newBelief.getMean().setElement(1, 0d);\n break;\n }\n if (totalDistToTravel == null) {\n final PathEdge initialEdge =\n startEdge.isEmptyEdge() ? sampledPathEdge : startEdge;\n currentEdge = initialEdge;\n if (newBelief.getInputDimensionality() == 4) {\n StandardRoadTrackingFilter.convertToRoadBelief(newBelief,\n InferredPath.getInferredPath(initialEdge));\n }\n double previousLocation = newBelief.getMean().getElement(0);\n movementFilter.predict(newBelief, initialEdge, initialEdge);\n final Vector transStateSample =\n StandardRoadTrackingFilter.sampleMovementBelief(rng,\n newBelief.getMean(), movementFilter);\n newBelief.setMean(transStateSample);\n totalDistToTravel =\n newBelief.getMean().getElement(0) - previousLocation;\n double newLocation = newBelief.getMean().getElement(0);\n final double L = initialEdge.getInferredEdge().getLength();\n if (newLocation < 0d && previousLocation > 0d) {\n previousLocation = -L + previousLocation;\n newLocation = previousLocation + totalDistToTravel;\n newBelief.getMean().setElement(0, newLocation);\n } else if (newLocation >= 0d && previousLocation < 0d) {\n previousLocation = L + previousLocation;\n newLocation = previousLocation + totalDistToTravel;\n newBelief.getMean().setElement(0, newLocation);\n }\n direction = totalDistToTravel >= 0d ? 1d : -1d;\n if (L < Math.abs(newLocation)) {\n final double r = L - Math.abs(previousLocation);\n distTraveled += r * direction;\n } else {\n distTraveled += totalDistToTravel;\n }\n } else {\n distTraveled +=\n direction * sampledPathEdge.getInferredEdge().getLength();\n currentEdge = sampledPathEdge;\n }\n previousEdge = currentEdge;\n currentPath.add(currentEdge);\n }\n if(!Iterables.getLast(currentPath).isEmptyEdge() && \n !Iterables.getLast(currentPath).isOnEdge(newBelief.getMean().getElement(0))) {\n Iterables.getLast(currentPath).isOnEdge(newBelief.getMean().getElement(0));\n }\n assert (Iterables.getLast(currentPath).isEmptyEdge() || Iterables\n .getLast(currentPath).isOnEdge(\n newBelief.getMean().getElement(0)));\n belief.setMean(newBelief.getMean());\n belief.setCovariance(newBelief.getCovariance());\n return InferredPath.getInferredPath(currentPath,\n (totalDistToTravel != null && totalDistToTravel < 0d) ? true\n : false);\n }\n", "output": " private InferredPath traverseEdge(\n EdgeTransitionDistributions edgeTransDist,\n final MultivariateGaussian belief, PathEdge startEdge,\n StandardRoadTrackingFilter movementFilter) {\n rng.setSeed(this.localSeed);\n PathEdge currentEdge = startEdge;\n PathEdge previousEdge = null;\n final MultivariateGaussian newBelief = belief.clone();\n final List currentPath = Lists.newArrayList();\n double distTraveled = 0d;\n Double totalDistToTravel = null;\n while (totalDistToTravel == null ||\n Math.abs(totalDistToTravel) > Math.abs(distTraveled)) {\n final List transferEdges = Lists.newArrayList();\n if (currentEdge.getInferredEdge() == InferredEdge\n .getEmptyEdge()) {\n final Vector projLocation =\n StandardRoadTrackingFilter.getOg().times(\n newBelief.getMean());\n for (final StreetEdge edge : this.inferredGraph\n .getNearbyEdges(projLocation,\n movementFilter.getObservationErrorAbsRadius())) {\n transferEdges.add(this.inferredGraph.getInferredEdge(edge));\n }\n } else {\n if (totalDistToTravel == null) {\n transferEdges.add(startEdge.getInferredEdge());\n } else {\n if (newBelief.getMean().getElement(0) < 0d) {\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getIncomingTransferableEdges());\n } else if (newBelief.getMean().getElement(0) > 0d) {\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getOutgoingTransferableEdges());\n } else {\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getIncomingTransferableEdges());\n transferEdges.addAll(currentEdge.getInferredEdge()\n .getOutgoingTransferableEdges());\n }\n transferEdges.remove(currentEdge.getInferredEdge());\n }\n }\n final InferredEdge sampledEdge =\n edgeTransDist.sample(rng, transferEdges,\n currentEdge == null ? startEdge.getInferredEdge()\n : currentEdge.getInferredEdge());\n if (sampledEdge == InferredEdge.getEmptyEdge()) {\n if (totalDistToTravel == null) {\n movementFilter.predict(newBelief,\n PathEdge.getEmptyPathEdge(), startEdge);\n } else {\n StandardRoadTrackingFilter.convertToGroundBelief(newBelief,\n currentEdge, true);\n }\n currentEdge = PathEdge.getEmptyPathEdge();\n currentPath.add(PathEdge.getEmptyPathEdge());\n break;\n }\n double direction =\n newBelief.getMean().getElement(0) >= 0d ? 1d : -1d;\n final PathEdge sampledPathEdge =\n PathEdge.getEdge(sampledEdge, previousEdge == null\n || previousEdge.isEmptyEdge() ? 0d : direction\n * previousEdge.getInferredEdge().getLength()\n + previousEdge.getDistToStartOfEdge(), direction < 0d);\n if (sampledPathEdge == null) {\n newBelief.getMean().setElement(0,\n direction * currentEdge.getInferredEdge().getLength());\n newBelief.getMean().setElement(1, 0d);\n break;\n }\n if (totalDistToTravel == null) {\n final PathEdge initialEdge =\n startEdge.isEmptyEdge() ? sampledPathEdge : startEdge;\n currentEdge = initialEdge;\n if (newBelief.getInputDimensionality() == 4) {\n StandardRoadTrackingFilter.convertToRoadBelief(newBelief,\n InferredPath.getInferredPath(initialEdge));\n }\n double previousLocation = newBelief.getMean().getElement(0);\n movementFilter.predict(newBelief, initialEdge, initialEdge);\n final Vector transStateSample =\n StandardRoadTrackingFilter.sampleMovementBelief(rng,\n newBelief.getMean(), movementFilter);\n newBelief.setMean(transStateSample);\n totalDistToTravel =\n newBelief.getMean().getElement(0) - previousLocation;\n double newLocation = newBelief.getMean().getElement(0);\n final double L = initialEdge.getInferredEdge().getLength();\n if (newLocation < 0d && previousLocation > 0d) {\n previousLocation = -L + previousLocation;\n newLocation = previousLocation + totalDistToTravel;\n newBelief.getMean().setElement(0, newLocation);\n } else if (newLocation >= 0d && previousLocation < 0d) {\n previousLocation = L + previousLocation;\n newLocation = previousLocation + totalDistToTravel;\n newBelief.getMean().setElement(0, newLocation);\n }\n direction = totalDistToTravel >= 0d ? 1d : -1d;\n if (L < Math.abs(newLocation)) {\n final double r = L - Math.abs(previousLocation);\n distTraveled += r * direction;\n } else {\n distTraveled += totalDistToTravel;\n }\n } else {\n distTraveled +=\n direction * sampledPathEdge.getInferredEdge().getLength();\n currentEdge = sampledPathEdge;\n }\n previousEdge = currentEdge;\n currentPath.add(currentEdge);\n }\n assert (Iterables.getLast(currentPath).isEmptyEdge() || Iterables\n .getLast(currentPath).isOnEdge(\n newBelief.getMean().getElement(0)));\n belief.setMean(newBelief.getMean());\n belief.setCovariance(newBelief.getCovariance());\n return InferredPath.getInferredPath(currentPath,\n (totalDistToTravel != null && totalDistToTravel < 0d) ? true\n : false);\n }\n"} {"input": " public Set getUnusedImports() {\n Set unused = new HashSet();\n for(Declared declared : declaredImports) {\n if (declared.importName.endsWith(\".*\")) {\n int imprtLen = declared.importName.length() - 1;\n String target = declared.importName.substring(0, imprtLen);\n boolean found = false;\n for(String imprt : usedImports) {\n if (imprt.length() > imprtLen) {\n if (imprt.indexOf(\".\", imprtLen + 1) > -1) continue;\n if (imprt.substring(0, imprtLen).equals(target)) {\n found = true;\n break;\n }\n }\n }\n if (!found) {\n unused.add(declared);\n }\n } else {\n if (!usedImports.contains(declared.importName)) {\n unused.add(declared);\n }\n }\n }\n return unused;\n }\n", "output": " public Set getUnusedImports() {\n Set unused = new HashSet();\n for(Declared declared : declaredImports) {\n if (declared.importName.endsWith(\".*\")) {\n int imprtLen = declared.importName.length() - 2;\n String target = declared.importName.substring(0, imprtLen);\n boolean found = false;\n for(String imprt : usedImports) {\n if (imprt.length() > imprtLen) {\n if (imprt.indexOf(\".\", imprtLen + 2) > -1) continue;\n if (imprt.substring(0, imprtLen).equals(target)) {\n found = true;\n break;\n }\n } else {\n if (imprt.length() == imprtLen && target.equals(imprt)) {\n found = true;\n break;\n }\n }\n }\n if (!found) {\n unused.add(declared);\n }\n } else {\n if (!usedImports.contains(declared.importName)) {\n unused.add(declared);\n }\n }\n }\n return unused;\n }\n"} {"input": "\tpublic ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)\n {\n if (!par2World.isRemote)\n {\n if(par1ItemStack.getItemDamage() == 2)\n \tTFC_Core.getPlayerFoodStats(par3EntityPlayer).restoreWater(par3EntityPlayer, 8000);\n if (par1ItemStack.getItemDamage() > 1)\n {\n \tif(par2World.rand.nextInt(25) == 0)\n \t\tpar1ItemStack = null;\n \telse\n \t{\n \t\tpar1ItemStack.setItemDamage(1);\n \t}\n }\n }\n return par1ItemStack;\n }\n", "output": "\tpublic ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)\n {\n if (!par2World.isRemote)\n {\n if(par1ItemStack.getItemDamage() == 2)\n \tTFC_Core.getPlayerFoodStats(par3EntityPlayer).restoreWater(par3EntityPlayer, 8000);\n if (par1ItemStack.getItemDamage() > 1)\n {\n \tif(par2World.rand.nextInt(25) == 0)\n \t\tpar1ItemStack.stackSize--;\n \telse\n \t{\n \t\tpar1ItemStack.setItemDamage(1);\n \t}\n }\n }\n return par1ItemStack;\n }\n"} {"input": "\tpublic void process(MApplication application, EModelService modelService) {\n\t\tMCommand command = null;\n\t\tfor (MCommand cmd : application.getCommands()) {\n\t\t\tif (E4_TOOLING_LIVEMODEL.equals(cmd.getElementId())) {\n\t\t\t\tcommand = cmd;\n\t\t\t}\n\t\t}\n\t\tif (command == null) {\n\t\t\tcommand = modelService.createModelElement(MCommand.class);\n\t\t\tcommand.setElementId(E4_TOOLING_LIVEMODEL);\n\t\t\tcommand.setCommandName(\"Show running app model\");\n\t\t\tcommand.setDescription(\"Show the running application model\");\n\t\t\tapplication.getCommands().add(command);\n\t\t}\n\t\tMHandler handler = null;\n\t\tfor (MHandler hdl : application.getHandlers()) {\n\t\t\tif (E4_TOOLING_LIVEMODEL_HANDLER.equals(hdl.getElementId())) {\n\t\t\t\thandler = hdl;\n\t\t\t}\n\t\t}\n\t\tif (handler == null) {\n\t\t\thandler = modelService.createModelElement(MHandler.class);\n\t\t\thandler.setElementId(E4_TOOLING_LIVEMODEL_HANDLER);\n\t\t\thandler.setContributionURI(\"bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.OpenLiveDialogHandler\");\n\t\t\tapplication.getHandlers().add(handler);\n\t\t}\n\t\thandler.setCommand(command);\n\t\tMKeyBinding binding = null;\n\t\tif (application.getBindingTables().size() <= 0) {\n\t\t\tMBindingContext bc = null;\n\t\t\tfinal List bindingContexts = application\n\t\t\t\t\t.getBindingContexts();\n\t\t\tif (bindingContexts.size() == 0) {\n\t\t\t\tbc = modelService.createModelElement(MBindingContext.class);\n\t\t\t\tbc.setElementId(\"org.eclipse.ui.contexts.window\");\n\t\t\t} else {\n\t\t\t\tfor (MBindingContext aBindingContext : bindingContexts) {\n\t\t\t\t\tbc = aBindingContext;\n\t\t\t\t\tif (\"org.eclipse.ui.contexts.dialogAndWindow\"\n\t\t\t\t\t\t\t.equals(aBindingContext.getElementId())) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tMBindingTable bt = modelService\n\t\t\t\t\t.createModelElement(MBindingTable.class);\n\t\t\tbt.setElementId(\"e4.tooling.livemodel.bindingTable\");\n\t\t\tbt.setBindingContext(bc);\n\t\t\tapplication.getBindingTables().add(bt);\n\t\t}\n\t\tList keyBindings = modelService.findElements(application,\n\t\t\t\t\"e4.tooling.livemodel.binding\", MKeyBinding.class, null);\n\t\tif (keyBindings.size() == 0) {\n\t\t\tbinding = modelService.createModelElement(MKeyBinding.class);\n\t\t\tbinding.setElementId(\"e4.tooling.livemodel.binding\");\n\t\t\tbinding.setKeySequence(\"M2+M3+F9\");\n\t\t\tif (application.getBindingTables().size() > 0) {\n\t\t\t\tapplication.getBindingTables().get(0).getBindings()\n\t\t\t\t\t\t.add(binding);\n\t\t\t}\n\t\t} else {\n\t\t\tbinding = keyBindings.get(0);\n\t\t}\n\t\tbinding.setCommand(command);\n\t\tMPartDescriptor descriptor = null;\n\t\tList descriptors = modelService.findElements(\n\t\t\t\tapplication, \"org.eclipse.e4.tools.emf.liveeditor.view\",\n\t\t\t\tMPartDescriptor.class, null);\n\t\tif (descriptors.size() == 0) {\n\t\t\tdescriptor = modelService.createModelElement(MPartDescriptor.class);\n\t\t\tdescriptor.setCategory(\"org.eclipse.e4.secondaryDataStack\");\n\t\t\tdescriptor.setElementId(\"org.eclipse.e4.tools.emf.liveeditor.view\");\n\t\t\tdescriptor.getTags().add(\"View\");\n\t\t\tdescriptor.getTags().add(\"categoryTag:General\");\n\t\t\tdescriptor.setLabel(\"Live Application Model\");\n\t\t\tdescriptor\n\t\t\t\t\t.setContributionURI(\"bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.LivePartDelegator\");\n\t\t\tdescriptor\n\t\t\t\t\t.setContributorURI(\"bundleclass://org.eclipse.e4.tools.emf.liveeditor\");\n\t\t\tdescriptor\n\t\t\t\t\t.setIconURI(\"platform:/plugin/org.eclipse.e4.tools.emf.liveeditor/icons/full/obj16/application_lightning.png\");\n\t\t\tapplication.getDescriptors().add(descriptor);\n\t\t}\n\t}\n", "output": "\tpublic void process(MApplication application, EModelService modelService) {\n\t\tMCommand command = null;\n\t\tfor (MCommand cmd : application.getCommands()) {\n\t\t\tif (E4_TOOLING_LIVEMODEL.equals(cmd.getElementId())) {\n\t\t\t\tcommand = cmd;\n\t\t\t}\n\t\t}\n\t\tif (command == null) {\n\t\t\tcommand = modelService.createModelElement(MCommand.class);\n\t\t\tcommand.setElementId(E4_TOOLING_LIVEMODEL);\n\t\t\tcommand.setCommandName(\"Show Live Application Model\");\n\t\t\tcommand.setDescription(\"Show the running application model\");\n\t\t\tapplication.getCommands().add(command);\n\t\t}\n\t\tMHandler handler = null;\n\t\tfor (MHandler hdl : application.getHandlers()) {\n\t\t\tif (E4_TOOLING_LIVEMODEL_HANDLER.equals(hdl.getElementId())) {\n\t\t\t\thandler = hdl;\n\t\t\t}\n\t\t}\n\t\tif (handler == null) {\n\t\t\thandler = modelService.createModelElement(MHandler.class);\n\t\t\thandler.setElementId(E4_TOOLING_LIVEMODEL_HANDLER);\n\t\t\thandler.setContributionURI(\"bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.OpenLiveDialogHandler\");\n\t\t\tapplication.getHandlers().add(handler);\n\t\t}\n\t\thandler.setCommand(command);\n\t\tMKeyBinding binding = null;\n\t\tif (application.getBindingTables().size() <= 0) {\n\t\t\tMBindingContext bc = null;\n\t\t\tfinal List bindingContexts = application\n\t\t\t\t\t.getBindingContexts();\n\t\t\tif (bindingContexts.size() == 0) {\n\t\t\t\tbc = modelService.createModelElement(MBindingContext.class);\n\t\t\t\tbc.setElementId(\"org.eclipse.ui.contexts.window\");\n\t\t\t} else {\n\t\t\t\tfor (MBindingContext aBindingContext : bindingContexts) {\n\t\t\t\t\tbc = aBindingContext;\n\t\t\t\t\tif (\"org.eclipse.ui.contexts.dialogAndWindow\"\n\t\t\t\t\t\t\t.equals(aBindingContext.getElementId())) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tMBindingTable bt = modelService\n\t\t\t\t\t.createModelElement(MBindingTable.class);\n\t\t\tbt.setElementId(\"e4.tooling.livemodel.bindingTable\");\n\t\t\tbt.setBindingContext(bc);\n\t\t\tapplication.getBindingTables().add(bt);\n\t\t}\n\t\tList keyBindings = modelService.findElements(application,\n\t\t\t\t\"e4.tooling.livemodel.binding\", MKeyBinding.class, null);\n\t\tif (keyBindings.size() == 0) {\n\t\t\tbinding = modelService.createModelElement(MKeyBinding.class);\n\t\t\tbinding.setElementId(\"e4.tooling.livemodel.binding\");\n\t\t\tbinding.setKeySequence(\"M2+M3+F9\");\n\t\t\tif (application.getBindingTables().size() > 0) {\n\t\t\t\tapplication.getBindingTables().get(0).getBindings()\n\t\t\t\t\t\t.add(binding);\n\t\t\t}\n\t\t} else {\n\t\t\tbinding = keyBindings.get(0);\n\t\t}\n\t\tbinding.setCommand(command);\n\t\tMPartDescriptor descriptor = null;\n\t\tList descriptors = modelService.findElements(\n\t\t\t\tapplication, \"org.eclipse.e4.tools.emf.liveeditor.view\",\n\t\t\t\tMPartDescriptor.class, null);\n\t\tif (descriptors.size() == 0) {\n\t\t\tdescriptor = modelService.createModelElement(MPartDescriptor.class);\n\t\t\tdescriptor.setCategory(\"org.eclipse.e4.secondaryDataStack\");\n\t\t\tdescriptor.setElementId(\"org.eclipse.e4.tools.emf.liveeditor.view\");\n\t\t\tdescriptor.getTags().add(\"View\");\n\t\t\tdescriptor.getTags().add(\"categoryTag:General\");\n\t\t\tdescriptor.setLabel(\"Live Application Model\");\n\t\t\tdescriptor\n\t\t\t\t\t.setContributionURI(\"bundleclass://org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.LivePartDelegator\");\n\t\t\tdescriptor\n\t\t\t\t\t.setContributorURI(\"bundleclass://org.eclipse.e4.tools.emf.liveeditor\");\n\t\t\tdescriptor\n\t\t\t\t\t.setIconURI(\"platform:/plugin/org.eclipse.e4.tools.emf.liveeditor/icons/full/obj16/application_lightning.png\");\n\t\t\tapplication.getDescriptors().add(descriptor);\n\t\t}\n\t}\n"} {"input": "\tpublic void onPlayerMove(PlayerMoveEvent event)\n\t{\n\t\tPlayer player = event.getPlayer();\n\t\tVector vector = player.getVelocity();\n\t\tBlock blockTo = event.getTo().getBlock();\n\t\tRegion regionTo = RegionManager.getRegion(event.getTo());\n\t\tRegion regionFrom = RegionManager.getRegion(event.getFrom());\n\t\tPortalManager.checkPlayerMove(player, regionFrom, regionTo);\n\t\tif (blockTo.getType() == Material.SUGAR_CANE_BLOCK && regionTo.getBoolean(RegionSetting.ENABLE_GRILLS))\n\t\t{\n\t\t\tfor (Grill grill: GrillManager.grills)\n\t\t\t{\n\t\t\t\tif (grill.getInside().contains(blockTo))\n\t\t\t\t{\n\t\t\t\t\tGrillManager.emancipate(player);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (player.isInsideVehicle()) return;\n\t\tif (!Permission.teleport(player)) return;\n\t\tdouble addX = 0.0;\n\t\tdouble addY = 0.0;\n\t\tdouble addZ = 0.0;\n\t\tif (Math.abs(vector.getX()) > 1)\n\t\t{\n\t\t\taddX += 3.0;\n\t\t\taddY += 2.0;\n\t\t\taddZ += 2.0;\n\t\t}\n\t\tif (Math.abs(vector.getZ()) > 1)\n\t\t{\n\t\t\taddX += 2.0;\n\t\t\taddY += 2.0;\n\t\t\taddZ += 3.0;\n\t\t}\n\t\tif (Math.abs(vector.getY()) > 1)\n\t\t{\n\t\t\taddX += 2.0;\n\t\t\taddY += 3.0;\n\t\t\taddZ += 2.0;\n\t\t}\n\t\tPortal portal = null;\n\t\tfor (Portal p : PortalManager.portals)\n\t\t{\n\t\t\tfor (Block b : p.getInside())\n\t\t\t{\n\t\t\t\tif (offsetequals(b.getLocation().getX(), blockTo.getX(),addX) && offsetequals(b.getLocation().getZ(), blockTo.getZ(), addZ) && offsetequals(b.getLocation().getY(), blockTo.getY(),addY))\n\t\t\t\t{\n\t\t\t\t\tportal = p;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\t \n\t\t}\n\t\tif (portal != null)\n\t\t{\n\t\t\tif (!portal.isOpen() || portal.isDisabled()) return;\n\t\t\tUser owner = portal.getOwner();\n\t\t\tLocation teleport;\n\t\t\tPortal destination;\n\t\t\tif (portal.isOrange())\n\t\t\t\tdestination = owner.getBluePortal();\n\t\t\telse\n\t\t\t\tdestination = owner.getOrangePortal();\n\t\t\tteleport = destination.getTeleportLocation().clone();\n\t\t\tfloat yaw = 0;\n\t\t\tfloat pitch = 0;\n\t\t\tDouble momentum = 0.0;\n\t\t\tswitch(portal.getTeleportFace())\n\t {\n\t \tcase NORTH:\n\t \tcase SOUTH:\n\t \t\tmomentum = vector.getX();\n\t \t\tbreak;\n\t \tcase EAST:\n\t \tcase WEST:\n\t \t\tmomentum = vector.getZ();\n\t \t\tbreak;\n\t \tcase UP:\n\t \tcase DOWN:\n\t \t\tmomentum = vector.getY();\n\t \t\tbreak;\n\t }\n\t\t\tmomentum = Math.abs(momentum);\n\t\t\tmomentum = momentum * regionTo.getDouble(RegionSetting.VELOCITY_MULTIPLIER);\n\t\t\tVector outvector = player.getVelocity().zero();\n\t\t\tswitch(destination.getTeleportFace())\n\t {\n\t \tcase NORTH:\n\t \t\tyaw = 270;\n\t \t\toutvector = outvector.setX(momentum);\n\t \t\tbreak;\n\t \tcase EAST:\n\t \t\tyaw = 0;\n\t \t\toutvector = outvector.setZ(momentum);\n\t \t\tbreak;\n\t \tcase SOUTH:\n\t \t\tyaw = 90;\n\t \t\toutvector = outvector.setX(-momentum);\n\t \t\tbreak;\n\t \tcase WEST:\n\t \t\tyaw = 180;\n\t \t\toutvector = outvector.setZ(-momentum);\n\t \t\tbreak;\n\t \tcase UP:\n\t \t\tpitch = 90;\n\t \t\toutvector = outvector.setY(momentum);\n\t \t\tbreak;\n\t \tcase DOWN:\n\t \t\tpitch = -90;\n\t \t\toutvector = outvector.setY(-momentum);\n\t \t\tbreak;\n\t }\n\t\t\tplayer.setFallDistance(0);\t\n\t\t\tplayer.setVelocity(player.getVelocity().zero());\n\t\t\tteleport.setPitch(pitch);\n\t\t\tteleport.setYaw(yaw);\n\t\t\tevent.setTo(teleport);\n\t\t\tplayer.teleport(teleport);\n\t\t\tplayer.setVelocity(outvector);\n\t\t\tdestination.setDisabled(true);\n\t\t\tplugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new EnablePortal(destination), 10L);\n\t\t}\n\t}\n", "output": "\tpublic void onPlayerMove(PlayerMoveEvent event)\n\t{\n\t\tPlayer player = event.getPlayer();\n\t\tVector vector = player.getVelocity();\n\t\tBlock blockTo = event.getTo().getBlock();\n\t\tRegion regionTo = RegionManager.getRegion(event.getTo());\n\t\tRegion regionFrom = RegionManager.getRegion(event.getFrom());\n\t\tPortalManager.checkPlayerMove(player, regionFrom, regionTo);\n\t\tif (blockTo.getType() == Material.SUGAR_CANE_BLOCK && regionTo.getBoolean(RegionSetting.ENABLE_GRILLS))\n\t\t{\n\t\t\tfor (Grill grill: GrillManager.grills)\n\t\t\t{\n\t\t\t\tif (grill.getInside().contains(blockTo))\n\t\t\t\t{\n\t\t\t\t\tGrillManager.emancipate(player);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (player.isInsideVehicle()) return;\n\t\tif (!Permission.teleport(player)) return;\n\t\tdouble addX = 0.0;\n\t\tdouble addY = 0.0;\n\t\tdouble addZ = 0.0;\n\t\tif (Math.abs(vector.getX()) > 1)\n\t\t{\n\t\t\taddX += 3.0;\n\t\t\taddY += 2.0;\n\t\t\taddZ += 2.0;\n\t\t}\n\t\tif (Math.abs(vector.getZ()) > 1)\n\t\t{\n\t\t\taddX += 2.0;\n\t\t\taddY += 2.0;\n\t\t\taddZ += 3.0;\n\t\t}\n\t\tif (Math.abs(vector.getY()) > 1)\n\t\t{\n\t\t\taddX += 2.0;\n\t\t\taddY += 3.0;\n\t\t\taddZ += 2.0;\n\t\t}\n\t\tPortal portal = null;\n\t\tfor (Portal p : PortalManager.portals)\n\t\t{\n\t\t\tfor (Block b : p.getInside())\n\t\t\t{\n\t\t\t\tif (offsetequals(b.getLocation().getX(), blockTo.getX(),addX) && offsetequals(b.getLocation().getZ(), blockTo.getZ(), addZ) && offsetequals(b.getLocation().getY(), blockTo.getY(),addY))\n\t\t\t\t{\n\t\t\t\t\tportal = p;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\t \n\t\t}\n\t\tif (portal != null)\n\t\t{\n\t\t\tif (!portal.isOpen() || portal.isDisabled()) return;\n\t\t\tif (Math.abs(vector.getY()) > 1 && !portal.isVertical()) return;\n\t\t\tUser owner = portal.getOwner();\n\t\t\tLocation teleport;\n\t\t\tPortal destination;\n\t\t\tif (portal.isOrange())\n\t\t\t\tdestination = owner.getBluePortal();\n\t\t\telse\n\t\t\t\tdestination = owner.getOrangePortal();\n\t\t\tteleport = destination.getTeleportLocation().clone();\n\t\t\tfloat yaw = 0;\n\t\t\tfloat pitch = 0;\n\t\t\tDouble momentum = 0.0;\n\t\t\tswitch(portal.getTeleportFace())\n\t {\n\t \tcase NORTH:\n\t \tcase SOUTH:\n\t \t\tmomentum = vector.getX();\n\t \t\tbreak;\n\t \tcase EAST:\n\t \tcase WEST:\n\t \t\tmomentum = vector.getZ();\n\t \t\tbreak;\n\t \tcase UP:\n\t \tcase DOWN:\n\t \t\tmomentum = vector.getY();\n\t \t\tbreak;\n\t }\n\t\t\tmomentum = Math.abs(momentum);\n\t\t\tmomentum = momentum * regionTo.getDouble(RegionSetting.VELOCITY_MULTIPLIER);\n\t\t\tVector outvector = player.getVelocity().zero();\n\t\t\tswitch(destination.getTeleportFace())\n\t {\n\t \tcase NORTH:\n\t \t\tyaw = 270;\n\t \t\toutvector = outvector.setX(momentum);\n\t \t\tbreak;\n\t \tcase EAST:\n\t \t\tyaw = 0;\n\t \t\toutvector = outvector.setZ(momentum);\n\t \t\tbreak;\n\t \tcase SOUTH:\n\t \t\tyaw = 90;\n\t \t\toutvector = outvector.setX(-momentum);\n\t \t\tbreak;\n\t \tcase WEST:\n\t \t\tyaw = 180;\n\t \t\toutvector = outvector.setZ(-momentum);\n\t \t\tbreak;\n\t \tcase UP:\n\t \t\tpitch = 90;\n\t \t\toutvector = outvector.setY(momentum);\n\t \t\tbreak;\n\t \tcase DOWN:\n\t \t\tpitch = -90;\n\t \t\toutvector = outvector.setY(-momentum);\n\t \t\tbreak;\n\t }\n\t\t\tplayer.setFallDistance(0);\t\n\t\t\tplayer.setVelocity(player.getVelocity().zero());\n\t\t\tteleport.setPitch(pitch);\n\t\t\tteleport.setYaw(yaw);\n\t\t\tevent.setTo(teleport);\n\t\t\tplayer.teleport(teleport);\n\t\t\tplayer.setVelocity(outvector);\n\t\t\tdestination.setDisabled(true);\n\t\t\tplugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new EnablePortal(destination), 10L);\n\t\t}\n\t}\n"} {"input": " public void loadPartOk() throws IOException {\n final Part part = new Part( sections1File ) ;\n final Tree partTree = part.getTree();\n Assert.assertNotNull( partTree ) ;\n final Tree expected = tree( PART, \n tree( SECTION,\n tree( IDENTIFIER, tree( WORD, \"Section1nlp\" ) ),\n tree( PARAGRAPH_PLAIN, tree( WORD, \"p00\" ), tree( WORD, \"w001\" ) )\n ),\n tree( SECTION,\n tree( TITLE, tree( WORD, \"section1\" ), tree( WORD, \"w11\" ) ),\n tree( PARAGRAPH_PLAIN,\n tree( WORD, \"p10\" ),\n tree( WORD, \"w101\" ),\n tree( WORD, \"w102\" )\n )\n )\n ) ;\n TreeHelper.assertEquals( expected, partTree ) ;\n Assert.assertFalse( part.getProblems().iterator().hasNext() ) ;\n }\n", "output": " public void loadPartOk() throws IOException {\n final Part part = new Part( sections1File ) ;\n final Tree partTree = part.getTree();\n Assert.assertNotNull( partTree ) ;\n final Tree expected = tree( PART, \n tree( SECTION, tree( IDENTIFIER, tree( WORD, \"Section1nlp\" ) ) ),\n tree( PARAGRAPH_PLAIN, tree( WORD, \"p00\" ), tree( WORD, \"w001\" ) ),\n tree( SECTION, tree( TITLE, tree( WORD, \"section1\" ), tree( WORD, \"w11\" ) ) ),\n tree( PARAGRAPH_PLAIN, tree( WORD, \"p10\" ), tree( WORD, \"w101\" ), tree( WORD, \"w102\" ) )\n ) ;\n TreeHelper.assertEquals( expected, partTree ) ;\n Assert.assertFalse( part.getProblems().iterator().hasNext() ) ;\n }\n"} {"input": "\tpublic synchronized RoutingEntry getBestEntry(HRMID pDestination, int pDesiredMaxDelay, int pDesiredMinDataRate)\n\t{\n\t\tRoutingEntry tResult = null;\n\t\tRoutingEntry tBestResultHopCount = null;\n\t\tRoutingEntry tBestResultQoS = null;\n\t\tboolean DEBUG = HRMConfig.DebugOutput.GUI_SHOW_ROUTING;\n\t\tLogging.log(this, \"### Searching for best routing table entry towards: \" + pDestination +\", desired max. delay=\" + pDesiredMaxDelay + \", desired min. data rate=\" + pDesiredMinDataRate);\n\t\tif(size() > 0){\n\t\t\tfor(RoutingEntry tEntry : this){\n\t\t\t\tif(pDestination.isCluster(tEntry.getDest())){\n\t\t\t\t\tif(tBestResultHopCount != null){\n\t\t\t\t\t\tif( \n\t\t\t\t\t\t (tBestResultHopCount.getHopCount() > tEntry.getHopCount()) || \n\t\t\t\t\t\t (\n\t\t\t\t\t\t\t (tBestResultHopCount.getHopCount() == tEntry.getHopCount()) && \n\t\t\t\t\t\t\t ( \n\t\t\t\t\t\t (tBestResultHopCount.getMaxAvailableDataRate() < tEntry.getMaxAvailableDataRate()) ||\n\t\t\t\t\t\t\t\t ( \n\t\t\t\t\t\t\t\t (tBestResultHopCount.getMaxAvailableDataRate() == tEntry.getMaxAvailableDataRate()) && (tBestResultHopCount.getMinDelay() > tEntry.getMinDelay()) \n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t ) \n\t\t\t\t\t\t ) \n\t\t\t\t\t\t ){\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..found better (BE) entry: \" + tEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttBestResultHopCount = tEntry.clone();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..found uninteresting (BE) entry: \" + tEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\tLogging.log(this, \" ..found first matching (BE) entry: \" + tEntry);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttBestResultHopCount = tEntry.clone();\n\t\t\t\t\t}\n\t\t\t\t\tif (((pDesiredMaxDelay > 0) && (pDesiredMaxDelay >= tEntry.getMinDelay()) || (pDesiredMaxDelay <= 0)) && \n\t\t\t\t\t ((pDesiredMinDataRate > 0) && (pDesiredMinDataRate <= tEntry.getMaxAvailableDataRate())) || (pDesiredMinDataRate <= 0)){\n\t\t\t\t\t\tif(tBestResultQoS != null){\t\t\t\t\t\t\n\t\t\t\t\t\t\tif(\n\t\t\t\t\t\t\t ( (pDesiredMinDataRate > 0) &&\n\t\t\t\t\t\t\t ( (tBestResultQoS.getMaxAvailableDataRate() < tEntry.getMaxAvailableDataRate()) ||\n\t\t\t\t\t\t\t ( (tBestResultQoS.getMaxAvailableDataRate() == tEntry.getMaxAvailableDataRate()) && (pDesiredMaxDelay <= 0) && (tBestResultQoS.getHopCount() > tEntry.getHopCount()) ) ) ) ||\n\t\t\t\t\t\t\t ( (pDesiredMaxDelay > 0) && ( (pDesiredMinDataRate <= 0) || (tBestResultQoS.getMaxAvailableDataRate() == tEntry.getMaxAvailableDataRate()) ) && \t \n\t\t\t\t\t\t\t ( (tBestResultQoS.getMinDelay() > tEntry.getMinDelay()) ||\n\t\t\t\t\t\t\t ( (tBestResultQoS.getMinDelay() == tEntry.getMinDelay()) && (tBestResultQoS.getHopCount() > tEntry.getHopCount()) ) ) )\n\t\t\t\t\t\t\t ){\n\t\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\t\tLogging.log(this, \" ..found better (QoS) entry: \" + tEntry);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttBestResultQoS = tEntry.clone();\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\t\tLogging.log(this, \" ..found uninteresting (QoS) entry: \" + tEntry);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..found first matching (QoS) entry: \" + tEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttBestResultQoS = tEntry.clone();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..ignoring entry: \" + tEntry);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttResult = tBestResultHopCount;\n\t\t\tif((pDesiredMinDataRate > 0) || (pDesiredMaxDelay > 0)) {\n\t\t\t\tif(tBestResultQoS != null){\n\t\t\t\t\ttResult = tBestResultQoS;\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}else{\n\t\t\tif (DEBUG){\n\t\t\t\tLogging.log(this, \" ..found empty routing table\");\n\t\t\t}\n\t\t}\n\t\tLogging.log(this, \"### BEST ROUTE is: \" + tResult);\n\t\treturn tResult;\n\t}\n", "output": "\tpublic synchronized RoutingEntry getBestEntry(HRMID pDestination, int pDesiredMaxDelay, int pDesiredMinDataRate)\n\t{\n\t\tRoutingEntry tResult = null;\n\t\tRoutingEntry tBestResultHopCount = null;\n\t\tRoutingEntry tBestResultQoS = null;\n\t\tboolean DEBUG = HRMConfig.DebugOutput.GUI_SHOW_ROUTING;\n\t\tif (DEBUG){\n\t\t\tLogging.log(this, \"### Searching for best routing table entry towards: \" + pDestination +\", desired max. delay=\" + pDesiredMaxDelay + \", desired min. data rate=\" + pDesiredMinDataRate);\n\t\t}\n\t\tif(size() > 0){\n\t\t\tfor(RoutingEntry tEntry : this){\n\t\t\t\tif(pDestination.isCluster(tEntry.getDest())){\n\t\t\t\t\tif(tBestResultHopCount != null){\n\t\t\t\t\t\tif( \n\t\t\t\t\t\t (tBestResultHopCount.getHopCount() > tEntry.getHopCount()) || \n\t\t\t\t\t\t (\n\t\t\t\t\t\t\t (tBestResultHopCount.getHopCount() == tEntry.getHopCount()) && \n\t\t\t\t\t\t\t ( \n\t\t\t\t\t\t (tBestResultHopCount.getMaxAvailableDataRate() < tEntry.getMaxAvailableDataRate()) ||\n\t\t\t\t\t\t\t\t ( \n\t\t\t\t\t\t\t\t (tBestResultHopCount.getMaxAvailableDataRate() == tEntry.getMaxAvailableDataRate()) && (tBestResultHopCount.getMinDelay() > tEntry.getMinDelay()) \n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t ) \n\t\t\t\t\t\t ) \n\t\t\t\t\t\t ){\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..found better (BE) entry: \" + tEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttBestResultHopCount = tEntry.clone();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..found uninteresting (BE) entry: \" + tEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\tLogging.log(this, \" ..found first matching (BE) entry: \" + tEntry);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttBestResultHopCount = tEntry.clone();\n\t\t\t\t\t}\n\t\t\t\t\tif (((pDesiredMaxDelay > 0) && (pDesiredMaxDelay >= tEntry.getMinDelay()) || (pDesiredMaxDelay <= 0)) && \n\t\t\t\t\t ((pDesiredMinDataRate > 0) && (pDesiredMinDataRate <= tEntry.getMaxAvailableDataRate())) || (pDesiredMinDataRate <= 0)){\n\t\t\t\t\t\tif(tBestResultQoS != null){\t\t\t\t\t\t\n\t\t\t\t\t\t\tif(\n\t\t\t\t\t\t\t ( (pDesiredMinDataRate > 0) &&\n\t\t\t\t\t\t\t ( (tBestResultQoS.getMaxAvailableDataRate() < tEntry.getMaxAvailableDataRate()) ||\n\t\t\t\t\t\t\t ( (tBestResultQoS.getMaxAvailableDataRate() == tEntry.getMaxAvailableDataRate()) && (pDesiredMaxDelay <= 0) && (tBestResultQoS.getHopCount() > tEntry.getHopCount()) ) ) ) ||\n\t\t\t\t\t\t\t ( (pDesiredMaxDelay > 0) && ( (pDesiredMinDataRate <= 0) || (tBestResultQoS.getMaxAvailableDataRate() == tEntry.getMaxAvailableDataRate()) ) && \t \n\t\t\t\t\t\t\t ( (tBestResultQoS.getMinDelay() > tEntry.getMinDelay()) ||\n\t\t\t\t\t\t\t ( (tBestResultQoS.getMinDelay() == tEntry.getMinDelay()) && (tBestResultQoS.getHopCount() > tEntry.getHopCount()) ) ) )\n\t\t\t\t\t\t\t ){\n\t\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\t\tLogging.log(this, \" ..found better (QoS) entry: \" + tEntry);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttBestResultQoS = tEntry.clone();\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\t\tLogging.log(this, \" ..found uninteresting (QoS) entry: \" + tEntry);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..found first matching (QoS) entry: \" + tEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttBestResultQoS = tEntry.clone();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..ignoring entry: \" + tEntry);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttResult = tBestResultHopCount;\n\t\t\tif((pDesiredMinDataRate > 0) || (pDesiredMaxDelay > 0)) {\n\t\t\t\tif(tBestResultQoS != null){\n\t\t\t\t\ttResult = tBestResultQoS;\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}else{\n\t\t\tif (DEBUG){\n\t\t\t\tLogging.log(this, \" ..found empty routing table\");\n\t\t\t}\n\t\t}\n\t\tif (DEBUG){\n\t\t\tLogging.log(this, \"### BEST ROUTE is: \" + tResult);\n\t\t}\n\t\treturn tResult;\n\t}\n"} {"input": "\tprivate void fillData()\n\t{\n\t\tString[] from = new String[] { HomeworkTable.COLUMN_NAME, HomeworkTable.COLUMN_DATE, HomeworkTable.COLUMN_DESCRIPTION };\n\t\tint[] to = new int[] { R.id.hwName, R.id.date, R.id.descrption };\n\t\tgetLoaderManager().initLoader( 0, null, this );\n\t\tthis.adapter = new SimpleCursorAdapter( this, R.layout.list_row, null, from, to, 0 ){\n\t\t\t@Override\n\t\t public View getView(int position, View convertView, ViewGroup parent) {\n\t\t\t\t View v = super.getView(position, convertView, parent);\n\t\t\t if (position %2 ==1) {\n\t\t\t v.setBackgroundColor(Color.argb(TRIM_MEMORY_MODERATE, 100, 100, 100));\n\t\t\t } else {\n\t\t\t v.setBackgroundColor(Color.argb(TRIM_MEMORY_MODERATE, 170, 170, 170)); \n\t\t\t }\n\t\t\t return v;\n\t\t\t}\n\t\t};;\n\t\tsetListAdapter( this.adapter );\n\t}\n", "output": "\tprivate void fillData()\n\t{\n\t\tString[] from = new String[] { HomeworkTable.COLUMN_NAME, HomeworkTable.COLUMN_DATE, HomeworkTable.COLUMN_DESCRIPTION };\n\t\tint[] to = new int[] { R.id.hwName, R.id.date, R.id.descrption };\n\t\tgetLoaderManager().initLoader( 0, null, this );\n\t\tthis.adapter = new SimpleCursorAdapter( this, R.layout.home_list_row, null, from, to, 0 ){\n\t\t\t@Override\n\t\t public View getView(int position, View convertView, ViewGroup parent) {\n\t\t\t\t View v = super.getView(position, convertView, parent);\n\t\t\t if (position %2 ==1) {\n\t\t\t v.setBackgroundColor(Color.argb(TRIM_MEMORY_MODERATE, 100, 100, 100));\n\t\t\t } else {\n\t\t\t v.setBackgroundColor(Color.argb(TRIM_MEMORY_MODERATE, 170, 170, 170)); \n\t\t\t }\n\t\t\t return v;\n\t\t\t}\n\t\t};;\n\t\tsetListAdapter( this.adapter );\n\t}\n"} {"input": " public BufferedImage openImage(int no)\n throws FormatException, IOException\n {\n FormatTools.assertId(currentId, true, 1);\n if (no < 0 || no >= getImageCount()) {\n throw new FormatException(\"Invalid image number: \" + no);\n }\n if (noImageJ) throw new FormatException(NO_IJ);\n try {\n Location file = new Location(currentId);\n r.setVar(\"dir\", file.getParent() + System.getProperty(\"file.separator\"));\n r.setVar(\"name\", file.getName());\n synchronized (ImageJReader.class) {\n try {\n r.exec(\"state = Opener.getOpenUsingPlugins()\");\n r.exec(\"Opener.setOpenUsingPlugins(false)\");\n }\n catch (ReflectException exc) {\n }\n r.exec(\"image = opener.openImage(dir, name)\");\n try {\n r.exec(\"Opener.setOpenUsingPlugins(state)\");\n }\n catch (ReflectException exc) {\n }\n }\n r.exec(\"size = image.getStackSize()\");\n Image img = (Image) r.exec(\"image.getImage()\");\n BufferedImage b = ImageTools.makeBuffered(img);\n return b;\n }\n catch (ReflectException exc) {\n throw new FormatException(exc);\n }\n }\n", "output": " public BufferedImage openImage(int no)\n throws FormatException, IOException\n {\n FormatTools.assertId(currentId, true, 1);\n if (no < 0 || no >= getImageCount()) {\n throw new FormatException(\"Invalid image number: \" + no);\n }\n if (noImageJ) throw new FormatException(NO_IJ);\n try {\n Location file = new Location(currentId).getAbsoluteFile();\n r.setVar(\"dir\", file.getParent() + System.getProperty(\"file.separator\"));\n r.setVar(\"name\", file.getName());\n synchronized (ImageJReader.class) {\n try {\n r.exec(\"state = Opener.getOpenUsingPlugins()\");\n r.exec(\"Opener.setOpenUsingPlugins(false)\");\n }\n catch (ReflectException exc) {\n }\n r.exec(\"image = opener.openImage(dir, name)\");\n try {\n r.exec(\"Opener.setOpenUsingPlugins(state)\");\n }\n catch (ReflectException exc) {\n }\n }\n if (r.getVar(\"image\") == null) {\n throw new FormatException(\"ImageJ cannot read this image\");\n }\n r.exec(\"size = image.getStackSize()\");\n Image img = (Image) r.exec(\"image.getImage()\");\n BufferedImage b = ImageTools.makeBuffered(img);\n return b;\n }\n catch (ReflectException exc) {\n throw new FormatException(exc);\n }\n }\n"} {"input": "\tprivate Integer[] getRows( String line, int indent ) {\n\t\tfinal FontMetrics METRICS = getFontMetrics(getFont());\n\t\tfinal int WIDTH = getWidth() - 2*PAD;\n\t\tfinal int indentsize = indent*METRICS.stringWidth(\" \")*indent;\n\t\tList rows = new util.LinkedList();\n\t\tint row = 0;\n\t\tint remaining = WIDTH;\n\t\tif ( METRICS.stringWidth(\" \")*indent > WIDTH )\n\t\t\treturn new Integer[0];\n\t\tStringTokenizer st = new StringTokenizer(line, \" \",true); \n\t\twhile (st.hasMoreTokens()) {\n\t\t\tString tok = st.nextToken();\n\t\t\tint width = METRICS.stringWidth(tok);\n\t\t\tif ( width <= remaining ) {\n\t\t\t\trow += tok.length();\n\t\t\t\tremaining -= width;\n\t\t\t} else if ( width > WIDTH-indentsize ) {\n\t\t\t\tfor (int i = 0; i < tok.length(); ++i) {\n\t\t\t\t\tchar chr = tok.charAt(i);\n\t\t\t\t\twidth = METRICS.charWidth(chr);\n\t\t\t\t\tif ( width <= remaining ) {\n\t\t\t\t\t\tremaining -= width;\n\t\t\t\t\t\trow += 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\trows.add(row);\n\t\t\t\t\t\trow = 1;\n\t\t\t\t\t\tremaining = WIDTH - indentsize - width;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trows.add(row);\n\t\t\t\trow = tok.length();\n\t\t\t\tremaining = WIDTH - indentsize - width;\n\t\t\t}\n\t\t}\n\t\tif (row != 0)\n\t\t\trows.add(row);\n\t\treturn rows.toArray(new Integer[rows.size()]);\n\t}\n", "output": "\tprivate Integer[] getRows( String line, int indent ) {\n\t\tfinal FontMetrics METRICS = getFontMetrics(getFont());\n\t\tfinal int WIDTH = getWidth() - 2*PAD;\n\t\tfinal int indentsize = METRICS.stringWidth(\" \")*indent;\n\t\tList rows = new util.LinkedList();\n\t\tint row = 0;\n\t\tint remaining = WIDTH;\n\t\tif ( METRICS.stringWidth(\" \")*indent > WIDTH )\n\t\t\treturn new Integer[0];\n\t\tStringTokenizer st = new StringTokenizer(line, \" \",true); \n\t\twhile (st.hasMoreTokens()) {\n\t\t\tString tok = st.nextToken();\n\t\t\tint width = METRICS.stringWidth(tok);\n\t\t\tif ( width <= remaining ) {\n\t\t\t\trow += tok.length();\n\t\t\t\tremaining -= width;\n\t\t\t} else if ( width > WIDTH-indentsize ) {\n\t\t\t\tfor (int i = 0; i < tok.length(); ++i) {\n\t\t\t\t\tchar chr = tok.charAt(i);\n\t\t\t\t\twidth = METRICS.charWidth(chr);\n\t\t\t\t\tif ( width <= remaining ) {\n\t\t\t\t\t\tremaining -= width;\n\t\t\t\t\t\trow += 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\trows.add(row);\n\t\t\t\t\t\trow = 1;\n\t\t\t\t\t\tremaining = WIDTH - indentsize - width;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trows.add(row);\n\t\t\t\trow = tok.length();\n\t\t\t\tremaining = WIDTH - indentsize - width;\n\t\t\t}\n\t\t}\n\t\tif (row != 0)\n\t\t\trows.add(row);\n\t\treturn rows.toArray(new Integer[rows.size()]);\n\t}\n"} {"input": "\tprivate void handleUploadVideo(HttpServletRequest request,\n\t\t\tHttpServletResponse response, HttpSession session)\n\t\t\tthrows IOException {\n\t\tPrintWriter out = response.getWriter();\n\t\tout.println(\"Uploading file...\");\n\t\tresponse.setContentType(\"text/plain\");\n\t\tDiskFileItemFactory fileItemFactory = new DiskFileItemFactory();\n\t\tfileItemFactory.setSizeThreshold(1 * 1024 * 1024); \n\t\tfileItemFactory.setRepository(tempDir);\n\t\tServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);\n\t\tFile file = null;\n\t\ttry {\n\t\t\tList items = uploadHandler.parseRequest(request);\n\t\t\tIterator itr = items.iterator();\n\t\t\tFileItem videoNameItem = null;\n\t\t\tFileItem fileItem = null;\n\t\t\twhile (itr.hasNext()) {\n\t\t\t\tFileItem item = (FileItem) itr.next();\n\t\t\t\tif (item.isFormField()\n\t\t\t\t\t\t&& item.getFieldName().equals(\"new-video-name\")) { \n\t\t\t\t\tlog.info(\"Form Name = \\\"\" + item.getFieldName()\n\t\t\t\t\t\t\t+ \"\\\", Value = \\\"\" + item.getString() + \"\\\"\");\n\t\t\t\t\tvideoNameItem = item;\n\t\t\t\t} else {\n\t\t\t\t\tlog.info(\"Field Name = \\\"\" + item.getFieldName()\n\t\t\t\t\t\t\t+ \"\\\", File Name = \\\"\" + item.getName()\n\t\t\t\t\t\t\t+ \"\\\", Content type = \\\"\"\n\t\t\t\t\t\t\t+ item.getContentType() \n\t\t\t\t\t\t\t+ \"\\\", File Size (bytes) = \\\"\" + item.getSize()\n\t\t\t\t\t\t\t+ \"\\\"\");\n\t\t\t\t\tfileItem = item;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (videoNameItem == null) {\n\t\t\t\tlog.severe(\"Video name field not found in video upload form\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (fileItem == null) {\n\t\t\t\tlog.severe(\"File field not found in video upload form\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFileItem i = fileItem;\n\t\t\tfile = new File(destinationDir, fileItem.getName()); \n\t\t\tfileItem.write(file); \n\t\t\tint projectId = getProjectIdFromSessionAttributes(session);\n\t\t\tString videoName = videoNameItem.getString();\n\t\t\tif (Security.isSafeVideoName(videoName)\n\t\t\t\t\t&& Security.isSafeVideo(i)\n\t\t\t\t\t&& Security.isUniqueVideoName(videoName, projectId)\n\t\t\t\t\t&& Security.videoFits(DatabaseApi.getNumberOfVideos(projectId))) {\n\t\t\t\tString videoUrl = S3Api.uploadFile(file);\n\t\t\t\tif (videoUrl != null) {\n\t\t\t\t\tDatabaseApi.addVideo(new Video(videoName,\n\t\t\t\t\t\t\tvideoUrl, \"/olive/images/bbb480.jpg\", projectId,\n\t\t\t\t\t\t\t-1, -1, false)); \n\t\t\t\t\tout.println(\"File uploaded. Please close this window and refresh the editor page.\");\n\t\t\t\t\tout.println();\n\t\t\t\t} else {\n\t\t\t\t\tout.println(\"Upload Failed. Error uploading video to the cloud.\");\n\t\t\t\t\tlog.warning(\"Upload Failed. Error uploading video to the cloud.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (!Security.isSafeVideoName(videoName)) {\n\t\t\t\tout.println(\"Upload Failed. Video name may consist of a-z, 0-9; and must begin with a letter.\");\n\t\t\t\tlog.warning(\"Upload Failed. Video name may consist of a-z, 0-9; and must begin with a letter.\");\n\t\t\t\treturn;\n\t\t\t} else if (!Security.isUniqueVideoName(videoName, projectId)) {\n\t\t\t\tout.println(\"Upload Failed. Video name already exists.\");\n\t\t\t\tlog.warning(\"Upload Failed. Video name already exists.\");\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tout.println(\"Upload Failed. Video type is invalid or maximum number of videos reached.\");\n\t\t\t\tlog.warning(\"Upload Failed. Video type is invalid or maximum number of videos reached.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (FileUploadException e) {\n\t\t\tlog.severe(\"Error encountered while parsing the request in the upload handler\");\n\t\t\tout.println(\"Upload failed.\");\n\t\t\te.printStackTrace();\n\t\t} catch (InvalidFileSizeException e) {\n\t\t\tlog.severe(\"Invalid file size\");\n\t\t\tout.println(\"Upload failed (invalid file size)\");\n\t\t\te.printStackTrace();\n\t\t} catch (Exception e) {\n\t\t\tlog.severe(\"Unknown error encountered while uploading file\");\n\t\t\tout.println(\"Upload failed (unknown reason).\");\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\tif (out != null) {\n\t\t\t\tout.close();\n\t\t\t}\n\t\t\tif (file != null) {\n\t\t\t\tfile.delete();\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void handleUploadVideo(HttpServletRequest request,\n\t\t\tHttpServletResponse response, HttpSession session)\n\t\t\tthrows IOException {\n\t\tPrintWriter out = response.getWriter();\n\t\tout.println(\"Uploading file...\");\n\t\tresponse.setContentType(\"text/plain\");\n\t\tDiskFileItemFactory fileItemFactory = new DiskFileItemFactory();\n\t\tfileItemFactory.setSizeThreshold(1 * 1024 * 1024); \n\t\tfileItemFactory.setRepository(tempDir);\n\t\tServletFileUpload uploadHandler = new ServletFileUpload(fileItemFactory);\n\t\tFile file = null;\n\t\ttry {\n\t\t\tList items = uploadHandler.parseRequest(request);\n\t\t\tIterator itr = items.iterator();\n\t\t\tFileItem videoNameItem = null;\n\t\t\tFileItem fileItem = null;\n\t\t\twhile (itr.hasNext()) {\n\t\t\t\tFileItem item = (FileItem) itr.next();\n\t\t\t\tif (item.isFormField()\n\t\t\t\t\t\t&& item.getFieldName().equals(\"new-video-name\")) { \n\t\t\t\t\tlog.info(\"Form Name = \\\"\" + item.getFieldName()\n\t\t\t\t\t\t\t+ \"\\\", Value = \\\"\" + item.getString() + \"\\\"\");\n\t\t\t\t\tvideoNameItem = item;\n\t\t\t\t} else {\n\t\t\t\t\tlog.info(\"Field Name = \\\"\" + item.getFieldName()\n\t\t\t\t\t\t\t+ \"\\\", File Name = \\\"\" + item.getName()\n\t\t\t\t\t\t\t+ \"\\\", Content type = \\\"\"\n\t\t\t\t\t\t\t+ item.getContentType() \n\t\t\t\t\t\t\t+ \"\\\", File Size (bytes) = \\\"\" + item.getSize()\n\t\t\t\t\t\t\t+ \"\\\"\");\n\t\t\t\t\tfileItem = item;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (videoNameItem == null) {\n\t\t\t\tlog.severe(\"Video name field not found in video upload form\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (fileItem == null) {\n\t\t\t\tlog.severe(\"File field not found in video upload form\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFileItem i = fileItem;\n\t\t\tfile = new File(destinationDir, fileItem.getName()); \n\t\t\tfileItem.write(file); \n\t\t\tint projectId = getProjectIdFromSessionAttributes(session);\n\t\t\tString videoName = videoNameItem.getString();\n\t\t\tif (Security.isSafeVideoName(videoName)\n\t\t\t\t\t&& Security.isSafeVideo(i)\n\t\t\t\t\t&& Security.isUniqueVideoName(videoName, projectId)\n\t\t\t\t\t&& Security.videoFits(DatabaseApi.getNumberOfVideos(projectId))) {\n\t\t\t\tString videoUrl = S3Api.uploadFile(file);\n\t\t\t\tif (videoUrl != null) {\n\t\t\t\t\tDatabaseApi.addVideo(new Video(videoName,\n\t\t\t\t\t\t\tvideoUrl, \"/olive/images/bbb480.jpg\", projectId,\n\t\t\t\t\t\t\t-1, -1, false)); \n\t\t\t\t\tout.println(\"File uploaded. Please close this window and refresh the editor page.\");\n\t\t\t\t\tout.println();\n\t\t\t\t\tresponse.sendRedirect(\"editor.jsp\");\t\n\t\t\t\t} else {\n\t\t\t\t\tout.println(\"Upload Failed. Error uploading video to the cloud.\");\n\t\t\t\t\tlog.warning(\"Upload Failed. Error uploading video to the cloud.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (!Security.isSafeVideoName(videoName)) {\n\t\t\t\tout.println(\"Upload Failed. Video name may consist of a-z, 0-9; and must begin with a letter.\");\n\t\t\t\tlog.warning(\"Upload Failed. Video name may consist of a-z, 0-9; and must begin with a letter.\");\n\t\t\t\treturn;\n\t\t\t} else if (!Security.isUniqueVideoName(videoName, projectId)) {\n\t\t\t\tout.println(\"Upload Failed. Video name already exists.\");\n\t\t\t\tlog.warning(\"Upload Failed. Video name already exists.\");\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tout.println(\"Upload Failed. Video type is invalid or maximum number of videos reached.\");\n\t\t\t\tlog.warning(\"Upload Failed. Video type is invalid or maximum number of videos reached.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (FileUploadException e) {\n\t\t\tlog.severe(\"Error encountered while parsing the request in the upload handler\");\n\t\t\tout.println(\"Upload failed.\");\n\t\t\te.printStackTrace();\n\t\t} catch (InvalidFileSizeException e) {\n\t\t\tlog.severe(\"Invalid file size\");\n\t\t\tout.println(\"Upload failed (invalid file size)\");\n\t\t\te.printStackTrace();\n\t\t} catch (Exception e) {\n\t\t\tlog.severe(\"Unknown error encountered while uploading file\");\n\t\t\tout.println(\"Upload failed (unknown reason).\");\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\tif (out != null) {\n\t\t\t\tout.close();\n\t\t\t}\n\t\t\tif (file != null) {\n\t\t\t\tfile.delete();\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " protected void append(ILoggingEvent event)\n {\n Throwable throwable = null;\n IThrowableProxy throwableProxy = event.getThrowableProxy();\n if (throwableProxy instanceof ThrowableProxy) {\n throwable = ((ThrowableProxy) throwableProxy).getThrowable();\n }\n try {\n LogLevel logLevel = LogLevel.valueOf(event.getLevel().toString());\n LogEvent logevent = new LogEvent(logLevel, event.getMessage(), event.getArgumentArray(), throwable);\n getObservationManager().notify(logevent, event.getLoggerName(), null);\n } catch (IllegalArgumentException e) {\n this.logger.debug(\"Unsupported log level {0}\", event.getLevel());\n } catch (ComponentLookupException e) {\n this.logger.error(\"Can't find any implementation of org.xwiki.observation.ObservationManager\", e);\n }\n }\n", "output": " protected void append(ILoggingEvent event)\n {\n Throwable throwable = null;\n IThrowableProxy throwableProxy = event.getThrowableProxy();\n if (throwableProxy instanceof ThrowableProxy) {\n throwable = ((ThrowableProxy) throwableProxy).getThrowable();\n }\n try {\n LogLevel logLevel = LogLevel.valueOf(event.getLevel().toString());\n LogEvent logevent = new LogEvent(logLevel, event.getMessage(), event.getArgumentArray(), throwable);\n getObservationManager().notify(logevent, event.getLoggerName(), null);\n } catch (IllegalArgumentException e) {\n this.logger.debug(\"Unsupported log level {0}\", event.getLevel());\n } catch (ComponentLookupException e) {\n this.logger.error(\"Can't find any implementation of [\" + ObservationManager.class.getName() + \"]\", e);\n }\n }\n"} {"input": "\tpublic final void updateEntity() {\n\t\tif(checkTileEntity(_initialInit)) {\n\t\t\tstillNeedReplace = true;\n\t\t\treturn;\n\t\t} else {\n\t\t\tif(stillNeedReplace) {\n\t\t\t\tstillNeedReplace = false;\n\t\t\t\tworldObj.notifyBlockChange(getX(), getY(), getZ(), worldObj.getBlockId(getX(), getY(), getZ()));\n\t\t\t\tfor(Pair3 item : _sendQueue) {\n\t\t\t\t\titem.getValue1().getEntityPassiveItem().setWorld(worldObj);\n\t\t\t\t}\n\t\t\t\tgetRouter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif(repeatFor > 0) {\n\t\t\tif(delayTo < System.currentTimeMillis()) {\n\t\t\t\tdelayTo = System.currentTimeMillis() + 200;\n\t\t\t\trepeatFor--;\n\t\t\t\tworldObj.markBlockForUpdate(this.getX(), this.getY(), this.getZ());\n\t\t\t}\n\t\t}\n\t\twhile(this._inTransitToMe.peek()!=null && this._inTransitToMe.peek().getTickToTimeOut()<=0){\n\t\t\tif (LogisticsPipes.DEBUG) {\n\t\t\t\tfinal IRoutedItem p=_inTransitToMe.poll();\n\t\t\t\tLogisticsPipes.log.info(\"Timed Out: \"+p.getIDStack().getItem().getFriendlyName());\n\t\t\t}\n\t\t}\n\t\tgetRouter().update(worldObj.getWorldTime() % Configs.LOGISTICS_DETECTION_FREQUENCY == _delayOffset || _initialInit);\n\t\tgetUpgradeManager().securityTick();\n\t\tsuper.updateEntity();\n\t\tignoreDisableUpdateEntity();\n\t\t_initialInit = false;\n\t\tif (!_sendQueue.isEmpty()){\n\t\t\tif(getItemSendMode() == ItemSendMode.Normal || !SimpleServiceLocator.buildCraftProxy.checkMaxItems()) {\n\t\t\t\tPair3 itemToSend = _sendQueue.getFirst();\n\t\t\t\tsendRoutedItem(itemToSend.getValue1(), itemToSend.getValue2());\n\t\t\t\t_sendQueue.removeFirst();\n\t\t\t\tif(SimpleServiceLocator.buildCraftProxy.checkMaxItems()) {\n\t\t\t\t\tfor(int i=0;i < 16 && !_sendQueue.isEmpty() && _sendQueue.getFirst().getValue3() == ItemSendMode.Fast;i++) {\n\t\t\t\t\t\tif (!_sendQueue.isEmpty()){\n\t\t\t\t\t\t\titemToSend = _sendQueue.getFirst();\n\t\t\t\t\t\t\tsendRoutedItem(itemToSend.getValue1(), itemToSend.getValue2());\n\t\t\t\t\t\t\t_sendQueue.removeFirst();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsendQueueChanged(false);\n\t\t\t} else if(getItemSendMode() == ItemSendMode.Fast) {\n\t\t\t\tfor(int i=0;i < 16;i++) {\n\t\t\t\t\tif (!_sendQueue.isEmpty()){\n\t\t\t\t\t\tPair3 itemToSend = _sendQueue.getFirst();\n\t\t\t\t\t\tsendRoutedItem(itemToSend.getValue1(), itemToSend.getValue2());\n\t\t\t\t\t\t_sendQueue.removeFirst();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsendQueueChanged(false);\n\t\t\t} else if(getItemSendMode() == null) {\n\t\t\t\tthrow new UnsupportedOperationException(\"getItemSendMode() can't return null. \"+this.getClass().getName());\n\t\t\t} else {\n\t\t\t\tthrow new UnsupportedOperationException(\"getItemSendMode() returned unhandled value. \" + getItemSendMode().name() + \" in \"+this.getClass().getName());\n\t\t\t}\n\t\t}\n\t\tif(MainProxy.isClient(worldObj)) return;\n\t\tcheckTexturePowered();\n\t\tif (!isEnabled()) return;\n\t\tenabledUpdateEntity();\n\t\tif (getLogisticsModule() == null) return;\n\t\tgetLogisticsModule().tick();\n\t}\t\n", "output": "\tpublic final void updateEntity() {\n\t\tif(checkTileEntity(_initialInit)) {\n\t\t\tstillNeedReplace = true;\n\t\t\treturn;\n\t\t} else {\n\t\t\tif(stillNeedReplace) {\n\t\t\t\tstillNeedReplace = false;\n\t\t\t\tworldObj.notifyBlockChange(getX(), getY(), getZ(), worldObj.getBlockId(getX(), getY(), getZ()));\n\t\t\t\tfor(Pair3 item : _sendQueue) {\n\t\t\t\t\titem.getValue1().getEntityPassiveItem().setWorld(worldObj);\n\t\t\t\t}\n\t\t\t\tgetRouter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif(repeatFor > 0) {\n\t\t\tif(delayTo < System.currentTimeMillis()) {\n\t\t\t\tdelayTo = System.currentTimeMillis() + 200;\n\t\t\t\trepeatFor--;\n\t\t\t\tworldObj.markBlockForUpdate(this.getX(), this.getY(), this.getZ());\n\t\t\t}\n\t\t}\n\t\twhile(this._inTransitToMe.peek()!=null && this._inTransitToMe.peek().getTickToTimeOut()<=0){\n\t\t\tfinal IRoutedItem p=_inTransitToMe.poll();\n\t\t\tif (LogisticsPipes.DEBUG) {\n\t\t\t\t\tLogisticsPipes.log.info(\"Timed Out: \"+p.getIDStack().getItem().getFriendlyName());\n\t\t\t}\n\t\t}\n\t\tgetRouter().update(worldObj.getWorldTime() % Configs.LOGISTICS_DETECTION_FREQUENCY == _delayOffset || _initialInit);\n\t\tgetUpgradeManager().securityTick();\n\t\tsuper.updateEntity();\n\t\tignoreDisableUpdateEntity();\n\t\t_initialInit = false;\n\t\tif (!_sendQueue.isEmpty()){\n\t\t\tif(getItemSendMode() == ItemSendMode.Normal || !SimpleServiceLocator.buildCraftProxy.checkMaxItems()) {\n\t\t\t\tPair3 itemToSend = _sendQueue.getFirst();\n\t\t\t\tsendRoutedItem(itemToSend.getValue1(), itemToSend.getValue2());\n\t\t\t\t_sendQueue.removeFirst();\n\t\t\t\tif(SimpleServiceLocator.buildCraftProxy.checkMaxItems()) {\n\t\t\t\t\tfor(int i=0;i < 16 && !_sendQueue.isEmpty() && _sendQueue.getFirst().getValue3() == ItemSendMode.Fast;i++) {\n\t\t\t\t\t\tif (!_sendQueue.isEmpty()){\n\t\t\t\t\t\t\titemToSend = _sendQueue.getFirst();\n\t\t\t\t\t\t\tsendRoutedItem(itemToSend.getValue1(), itemToSend.getValue2());\n\t\t\t\t\t\t\t_sendQueue.removeFirst();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsendQueueChanged(false);\n\t\t\t} else if(getItemSendMode() == ItemSendMode.Fast) {\n\t\t\t\tfor(int i=0;i < 16;i++) {\n\t\t\t\t\tif (!_sendQueue.isEmpty()){\n\t\t\t\t\t\tPair3 itemToSend = _sendQueue.getFirst();\n\t\t\t\t\t\tsendRoutedItem(itemToSend.getValue1(), itemToSend.getValue2());\n\t\t\t\t\t\t_sendQueue.removeFirst();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsendQueueChanged(false);\n\t\t\t} else if(getItemSendMode() == null) {\n\t\t\t\tthrow new UnsupportedOperationException(\"getItemSendMode() can't return null. \"+this.getClass().getName());\n\t\t\t} else {\n\t\t\t\tthrow new UnsupportedOperationException(\"getItemSendMode() returned unhandled value. \" + getItemSendMode().name() + \" in \"+this.getClass().getName());\n\t\t\t}\n\t\t}\n\t\tif(MainProxy.isClient(worldObj)) return;\n\t\tcheckTexturePowered();\n\t\tif (!isEnabled()) return;\n\t\tenabledUpdateEntity();\n\t\tif (getLogisticsModule() == null) return;\n\t\tgetLogisticsModule().tick();\n\t}\t\n"} {"input": " public Changeset getChangeset(Repository repository, String revision)\n throws RepositoryException, IOException, NotSupportedFeatuerException\n {\n AssertUtil.assertIsNotNull(repository);\n ChangesetViewer viewer = repositoryManager.getChangesetViewer(repository);\n if (viewer == null)\n {\n throw new NotSupportedFeatuerException(\n \"ChangesetViewer is not supported for type \".concat(\n repository.getType()));\n }\n Changeset changeset = null;\n ChangesetViewerCacheKey key =\n new ChangesetViewerCacheKey(repository.getId(), -1, -1);\n ChangesetPagingResult result = cache.get(key);\n if (result == null)\n {\n changeset = viewer.getChangeset(revision);\n if (changeset != null)\n {\n callPreProcessors(changeset);\n callPreProcessorFactories(repository, changeset);\n result = new ChangesetPagingResult(1, Arrays.asList(changeset));\n cache.put(key, result);\n }\n else\n {\n throw new RepositoryException(\"could not find changeset\");\n }\n }\n else\n {\n if (logger.isDebugEnabled())\n {\n logger.debug(\"fetch changesetviewer result from cache\");\n }\n changeset = result.getChangesets().get(0);\n }\n return changeset;\n }\n", "output": " public Changeset getChangeset(Repository repository, String revision)\n throws RepositoryException, IOException, NotSupportedFeatuerException\n {\n AssertUtil.assertIsNotNull(repository);\n ChangesetViewer viewer = repositoryManager.getChangesetViewer(repository);\n if (viewer == null)\n {\n throw new NotSupportedFeatuerException(\n \"ChangesetViewer is not supported for type \".concat(\n repository.getType()));\n }\n Changeset changeset = null;\n ChangesetViewerCacheKey key =\n new ChangesetViewerCacheKey(repository.getId(), null, revision, -1, -1);\n ChangesetPagingResult result = cache.get(key);\n if (result == null)\n {\n changeset = viewer.getChangeset(revision);\n if (changeset != null)\n {\n callPreProcessors(changeset);\n callPreProcessorFactories(repository, changeset);\n result = new ChangesetPagingResult(1, Arrays.asList(changeset));\n cache.put(key, result);\n }\n else\n {\n throw new RepositoryException(\"could not find changeset\");\n }\n }\n else\n {\n if (logger.isDebugEnabled())\n {\n logger.debug(\"fetch changesetviewer result from cache\");\n }\n changeset = result.getChangesets().get(0);\n }\n return changeset;\n }\n"} {"input": " private static SpacingBuilder createSpacingBuilder(CommonCodeStyleSettings settings) {\n TokenSet rules = TokenSet.create(ERL_RULE, ERL_RECORD_DEFINITION, ERL_INCLUDE, ERL_MACROS_DEFINITION, ERL_ATTRIBUTE);\n TokenSet keywords = TokenSet.create(\n ERL_AFTER, ERL_WHEN, ERL_BEGIN, ERL_END, ERL_OF, ERL_CASE, ERL_QUERY, ERL_CATCH, ERL_IF, ERL_RECEIVE,\n ERL_TRY, ERL_DIV, ERL_REM, ERL_OR, ERL_XOR, ERL_BOR, ERL_BXOR, ERL_BSL, ERL_BSR, ERL_AND, ERL_BAND);\n return new SpacingBuilder(settings.getRootSettings())\n .before(ERL_COMMA).spaceIf(settings.SPACE_BEFORE_COMMA)\n .after(ERL_COMMA).spaceIf(settings.SPACE_AFTER_COMMA)\n .around(ERL_OP_EQ).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .around(ERL_OP_LT_MINUS).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .around(ERL_OP_EXL).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .after(ERL_ARROW).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .before(ERL_CLAUSE_BODY).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .around(ERL_OP_PLUS).spaceIf(settings.SPACE_AROUND_ADDITIVE_OPERATORS)\n .around(ERL_OP_PLUS_PLUS).spaceIf(settings.SPACE_AROUND_ADDITIVE_OPERATORS)\n .aroundInside(ERL_OP_MINUS, ERL_ADDITIVE_EXPRESSION).spaceIf(settings.SPACE_AROUND_ADDITIVE_OPERATORS)\n .aroundInside(ERL_OP_AR_DIV, ERL_MULTIPLICATIVE_EXPRESSION).spaceIf(settings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)\n .around(ERL_OP_AR_MUL).spaceIf(settings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)\n .around(ERL_OP_EQ_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_DIV_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_EQ_DIV_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_EQ_COL_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_LT).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OP_EQ_LT).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OP_GT).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OP_GT_EQ).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OR_OR).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OR).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .after(ERL_BRACKET_LEFT).none()\n .before(ERL_BRACKET_RIGHT).none()\n .after(ERL_CURLY_LEFT).none()\n .before(ERL_CURLY_RIGHT).none()\n .after(ERL_BIN_START).none()\n .before(ERL_BIN_END).none()\n .before(ERL_ARGUMENT_DEFINITION_LIST).none()\n .before(ERL_ARGUMENT_LIST).none()\n .withinPair(ERL_PAR_LEFT, ERL_PAR_RIGHT).spaceIf(settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES)\n .withinPair(ERL_BRACKET_LEFT, ERL_BRACKET_RIGHT).spaceIf(true)\n .withinPair(ERL_CURLY_LEFT, ERL_CURLY_RIGHT).spaceIf(true)\n .withinPair(ERL_BIN_START, ERL_BIN_END).spaceIf(true)\n .beforeInside(rules, ERL_PAR_LEFT).none()\n .around(keywords).spaces(1)\n .before(ERL_FUN_TYPE_SIGS_BRACES).none()\n .between(ERL_SPEC_FUN, ERL_TYPE_SIG).none()\n .aroundInside(ERL_OP_AR_DIV, ERL_SPEC_FUN).none()\n .beforeInside(ERL_PAR_LEFT, ERL_EXPORT).none()\n .beforeInside(ERL_PAR_LEFT, ERL_EXPORT_TYPE_ATTRIBUTE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_INCLUDE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_RECORD_DEFINITION).none()\n .beforeInside(ERL_PAR_LEFT, ERL_MODULE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_MACROS_DEFINITION).none()\n .beforeInside(ERL_PAR_LEFT, ERL_BEHAVIOUR).none()\n .beforeInside(ERL_TYPED_ATTR_VAL, ERL_ATOM_ATTRIBUTE).spaces(1)\n .afterInside(ERL_Q_ATOM, ERL_ATOM_ATTRIBUTE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_SPECIFICATION).none()\n .beforeInside(ERL_FUN_TYPE_SIGS, ERL_SPECIFICATION).spaces(1)\n .beforeInside(ERL_PAR_LEFT, ERL_CALLBACK_SPEC).none()\n .beforeInside(ERL_FUN_TYPE_SIGS, ERL_CALLBACK_SPEC).spaces(1)\n .aroundInside(ERL_OP_AR_DIV, ERL_FUN_TYPE_SIGS).none()\n .aroundInside(ERL_OP_AR_DIV, ERL_EXPORT_FUNCTION).none()\n .aroundInside(ERL_OP_AR_DIV, ERL_EXPORT_TYPE).none()\n .aroundInside(ERL_COLON_COLON, ERL_FUN_TYPE_SIGS).spaces(1)\n .betweenInside(ERL_COLON_COLON, ERL_TYPE_SIG, ERL_FUN_TYPE_SIGS).spaces(1)\n .between(ERL_FUN_TYPE_ARGUMENTS, ERL_TOP_TYPE_CLAUSE).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .betweenInside(ERL_Q_ATOM, ERL_PAR_LEFT, ERL_TYPE).none()\n .before(ERL_CLAUSE_GUARD).spaces(1)\n .before(ERL_FUN_TYPE_SIGS).spaces(1)\n .around(ERL_FUN_TYPE).spaces(1)\n .around(ERL_TYPE_SIG).spaces(1)\n .beforeInside(ERL_PAR_LEFT, ERL_FUN_TYPE).spaces(1)\n .afterInside(ERL_PAR_RIGHT, ERL_FUN_TYPE).spaces(1)\n .aroundInside(ERL_COLON, ERL_GLOBAL_FUNCTION_CALL_EXPRESSION).none()\n .around(ERL_COLON_COLON).spaces(1)\n .aroundInside(ERL_DOT, ERL_RECORD_FIELD).none()\n .before(ERL_RECORD_FIELD).none()\n .aroundInside(ERL_RADIX, ERL_RECORD_EXPRESSION).none()\n .before(ERL_DOT).none()\n .around(ERL_QMARK).none()\n .before(ERL_RECORD_TUPLE).none()\n .after(ERL_FUN).none()\n .before(ERL_END).spaces(1)\n ;\n }\n", "output": " private static SpacingBuilder createSpacingBuilder(CommonCodeStyleSettings settings) {\n TokenSet rules = TokenSet.create(ERL_RULE, ERL_RECORD_DEFINITION, ERL_INCLUDE, ERL_MACROS_DEFINITION, ERL_ATTRIBUTE);\n TokenSet keywords = TokenSet.create(\n ERL_AFTER, ERL_WHEN, ERL_BEGIN, ERL_END, ERL_OF, ERL_CASE, ERL_QUERY, ERL_CATCH, ERL_IF, ERL_RECEIVE,\n ERL_TRY, ERL_DIV, ERL_REM, ERL_OR, ERL_XOR, ERL_BOR, ERL_BXOR, ERL_BSL, ERL_BSR, ERL_AND, ERL_BAND);\n return new SpacingBuilder(settings.getRootSettings())\n .before(ERL_COMMA).spaceIf(settings.SPACE_BEFORE_COMMA)\n .after(ERL_COMMA).spaceIf(settings.SPACE_AFTER_COMMA)\n .around(ERL_OP_EQ).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .around(ERL_OP_LT_MINUS).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .around(ERL_OP_EXL).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .after(ERL_ARROW).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .before(ERL_CLAUSE_BODY).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .around(ERL_OP_PLUS).spaceIf(settings.SPACE_AROUND_ADDITIVE_OPERATORS)\n .around(ERL_OP_PLUS_PLUS).spaceIf(settings.SPACE_AROUND_ADDITIVE_OPERATORS)\n .aroundInside(ERL_OP_MINUS, ERL_ADDITIVE_EXPRESSION).spaceIf(settings.SPACE_AROUND_ADDITIVE_OPERATORS)\n .aroundInside(ERL_OP_AR_DIV, ERL_MULTIPLICATIVE_EXPRESSION).spaceIf(settings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)\n .around(ERL_OP_AR_MUL).spaceIf(settings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS)\n .around(ERL_OP_EQ_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_DIV_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_EQ_DIV_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_EQ_COL_EQ).spaceIf(settings.SPACE_AROUND_EQUALITY_OPERATORS)\n .around(ERL_OP_LT).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OP_EQ_LT).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OP_GT).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OP_GT_EQ).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OR_OR).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .around(ERL_OR).spaceIf(settings.SPACE_AROUND_LOGICAL_OPERATORS)\n .after(ERL_BRACKET_LEFT).none()\n .before(ERL_BRACKET_RIGHT).none()\n .after(ERL_CURLY_LEFT).none()\n .before(ERL_CURLY_RIGHT).none()\n .after(ERL_BIN_START).none()\n .before(ERL_BIN_END).none()\n .before(ERL_ARGUMENT_DEFINITION_LIST).none()\n .before(ERL_ARGUMENT_LIST).none()\n .withinPair(ERL_PAR_LEFT, ERL_PAR_RIGHT).spaceIf(settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES)\n .withinPair(ERL_BRACKET_LEFT, ERL_BRACKET_RIGHT).spaceIf(true)\n .withinPair(ERL_CURLY_LEFT, ERL_CURLY_RIGHT).spaceIf(true)\n .withinPair(ERL_BIN_START, ERL_BIN_END).spaceIf(true)\n .beforeInside(rules, ERL_PAR_LEFT).none()\n .around(keywords).spaces(1)\n .before(ERL_FUN_TYPE_SIGS_BRACES).none()\n .between(ERL_SPEC_FUN, ERL_TYPE_SIG).none()\n .aroundInside(ERL_OP_AR_DIV, ERL_SPEC_FUN).none()\n .beforeInside(ERL_PAR_LEFT, ERL_EXPORT).none()\n .beforeInside(ERL_PAR_LEFT, ERL_EXPORT_TYPE_ATTRIBUTE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_INCLUDE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_RECORD_DEFINITION).none()\n .beforeInside(ERL_PAR_LEFT, ERL_MODULE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_MACROS_DEFINITION).none()\n .beforeInside(ERL_PAR_LEFT, ERL_BEHAVIOUR).none()\n .beforeInside(ERL_TYPED_ATTR_VAL, ERL_ATOM_ATTRIBUTE).spaces(1)\n .afterInside(ERL_Q_ATOM, ERL_ATOM_ATTRIBUTE).none()\n .beforeInside(ERL_PAR_LEFT, ERL_SPECIFICATION).none()\n .beforeInside(ERL_FUN_TYPE_SIGS, ERL_SPECIFICATION).spaces(1)\n .beforeInside(ERL_PAR_LEFT, ERL_CALLBACK_SPEC).none()\n .beforeInside(ERL_FUN_TYPE_SIGS, ERL_CALLBACK_SPEC).spaces(1)\n .aroundInside(ERL_OP_AR_DIV, ERL_FUN_TYPE_SIGS).none()\n .aroundInside(ERL_OP_AR_DIV, ERL_EXPORT_FUNCTION).none()\n .aroundInside(ERL_OP_AR_DIV, ERL_EXPORT_TYPE).none()\n .aroundInside(ERL_COLON_COLON, ERL_FUN_TYPE_SIGS).spaces(1)\n .betweenInside(ERL_COLON_COLON, ERL_TYPE_SIG, ERL_FUN_TYPE_SIGS).spaces(1)\n .between(ERL_FUN_TYPE_ARGUMENTS, ERL_TOP_TYPE_CLAUSE).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)\n .betweenInside(ERL_Q_ATOM, ERL_PAR_LEFT, ERL_TYPE).none()\n .before(ERL_CLAUSE_GUARD).spaces(1)\n .before(ERL_FUN_TYPE_SIGS).spaces(1)\n .around(ERL_FUN_TYPE).spaces(1)\n .around(ERL_TYPE_SIG).spaces(1)\n .beforeInside(ERL_PAR_LEFT, ERL_FUN_TYPE).spaces(1)\n .afterInside(ERL_PAR_RIGHT, ERL_FUN_TYPE).spaces(1)\n .aroundInside(ERL_COLON, ERL_GLOBAL_FUNCTION_CALL_EXPRESSION).none()\n .around(ERL_COLON_COLON).spaces(1)\n .aroundInside(ERL_DOT, ERL_RECORD_FIELD).none()\n .before(ERL_RECORD_FIELD).none()\n .aroundInside(ERL_RADIX, ERL_RECORD_EXPRESSION).none()\n .before(ERL_DOT).none()\n .around(ERL_QMARK).none()\n .before(ERL_RECORD_TUPLE).none()\n .between(ERL_FUN, ERL_MODULE_REF).spaces(1)\n .between(ERL_FUN, ERL_FUNCTION_WITH_ARITY).spaces(1)\n .after(ERL_FUN).none()\n .before(ERL_END).spaces(1)\n ;\n }\n"} {"input": " public void onSurfaceCreated(final SurfaceHolder holder) {\n if (_debug) Log.d(TAG, \"start onSurfaceCreated() [\" + this + \"]\");\n super.onSurfaceCreated(holder);\n Runnable surfaceCreatedCommand = new Runnable() {\n @Override\n public void run() {\n doSurfaceCreated();\n }\n protected void doSurfaceCreated() {\n if (mInitialized) {\n if (_debug) Log.d(TAG, \"already Initialized(surfaceCreatedCommand)\");\n return;\n }\n boolean ret;\n int counter = 0;\n int specCounter = 0;\n while(true) {\n if (_debug) Log.d(TAG, \"start EGLContext.getEGL()\");\n exitEgl();\n egl10 = (EGL10) EGLContext.getEGL();\n if (_debug) Log.d(TAG, \"end EGLContext.getEGL()\");\n if (_debug) Log.d(TAG, \"start eglGetDisplay\");\n eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);\n if (_debug) Log.d(TAG, \"end eglGetDisplay\");\n if (eglDisplay == null || EGL10.EGL_NO_DISPLAY.equals(eglDisplay)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n if (_debug) Log.d(TAG, \"eglGetDisplay\u304cEGL_NO_DISPLAY [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG, \"egl10.eglCreateContext\u304cEGL_NO_DISPLAY\");\n throw new RuntimeException(\"OpenGL Error(EGL_NO_DISPLAY) \"\n + errStr + \": \"\n );\n } \n if (_debug) Log.d(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n {\n egl10.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);\n }\n int[] version = new int[2];\n if (! egl10.eglInitialize(eglDisplay, version)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n if (_debug) Log.d(TAG, \"egl10.eglInitialize\u304cfalse [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG,\"egl10.eglInitialize\u304cfalse\");\n throw new RuntimeException(\"OpenGL Error(eglInitialize) \"\n + errStr + \": \"\n );\n }\n if (_debug) Log.d(TAG,\"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n EGLConfig[] configs = new EGLConfig[1];\n int[] numConfig = new int[1];\n egl10.eglChooseConfig(eglDisplay, configSpec[specCounter++], configs, 1, numConfig);\n if (numConfig[0] == 0) {\n if (_debug) Log.d(TAG, \"numConfig[0]=\" + numConfig[0] + \"\");\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \" eglChooseConfig numConfig == 0 \";\n errStr += \" numConfig:[\" + numConfig[0] + \"]\";\n errStr += \" specCounter:[\" + (specCounter - 1) + \"]\";\n exitEgl();\n Log.e(TAG,\"eglChooseConfig\u5931\u6557:\"\n + \"numConfig:[\" + numConfig[0] + \"]\"\n + errStr);\n if (++counter >= AtlantisService.RETRY_COUNT) {\n throw new RuntimeException(\"OpenGL Error \"\n + errStr + \" :\"\n );\n }\n }\n EGLConfig config = configs[0];\n eglContext = egl10.eglCreateContext(eglDisplay, config, EGL10.EGL_NO_CONTEXT, null); \n if (eglContext == null || EGL10.EGL_NO_CONTEXT.equals(eglContext)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \"egl10.eglCreateContext == EGL_NO_CONTEXT \";\n errStr += \"specCounter:[\" + (specCounter - 1) + \"]\";\n if (_debug) Log.d(TAG, \"egl10.eglCreateContext == EGL_NO_CONTEXT [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG, \"egl10.eglCreateContext\u304cEGL_NO_CONTEXT\");\n throw new RuntimeException(\"OpenGL Error(EGL_NO_CONTEXT) \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.d(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n if (_debug) Log.d(TAG, \"eglCreateContext done.\");\n eglSurface = egl10.eglCreateWindowSurface(eglDisplay, config, holder, null);\n if (eglSurface == null || EGL10.EGL_NO_SURFACE.equals(eglSurface)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \"egl10.eglCreateWindowSurface == EGL_NO_SURFACE \";\n errStr += \"specCounter:[\" + (specCounter - 1) + \"]\";\n if (_debug) Log.d(TAG, \"egl10.eglCreateWindowSurface == EGL_NO_SURFACE [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG, \"egl10.eglCreateWindowSurface\u304cEGL_NO_SURFACE\");\n throw new RuntimeException(\"OpenGL Error(EGL_NO_SURFACE) \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.e(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n if (_debug) Log.d(TAG, \"eglCreateWindowSurface done.\");\n if (! egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \"egl10.eglMakeCurrent == false \";\n errStr += \"specCounter:[\" + (specCounter - 1) + \"]\";\n if (_debug) Log.d(TAG, \"egl10.eglMakeCurrent == false [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG,\"egl10.eglMakeCurrent\u304cfalse\");\n throw new RuntimeException(\"OpenGL Error(eglMakeCurrent) \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.d(TAG,\"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n if (_debug) Log.d(TAG, \"eglMakeCurrent done.\");\n if (_debug) Log.d(TAG, \"now create gl10 object\");\n gl10 = new MatrixTrackingGL((GL10) (eglContext.getGL()));\n glRenderer = GLRenderer.getInstance(getApplicationContext());\n synchronized (glRenderer) {\n glRenderer.onSurfaceCreated(gl10, config, getApplicationContext());\n }\n if (_debug) Log.d(TAG, \"EGL initalize done.\");\n mInitialized = true;\n if (drawCommand == null) {\n drawCommand = new Runnable() {\n public void run() {\n doDrawCommand();\n }\n protected void doDrawCommand() {\n if (mInitialized && glRenderer != null && gl10 != null) {\n synchronized (glRenderer) {\n long nowTime = System.nanoTime();\n if (nowTime - glRenderer.prevTick < BASE_TICK) {\n try {\n TimeUnit.NANOSECONDS.sleep(BASE_TICK - (nowTime - glRenderer.prevTick));\n } catch (InterruptedException e) {\n }\n }\n glRenderer.onDrawFrame(gl10);\n glRenderer.prevTick = nowTime;\n }\n egl10.eglSwapBuffers(eglDisplay, eglSurface);\n if (!getExecutor().isShutdown() && isVisible() && egl10.eglGetError() != EGL11.EGL_CONTEXT_LOST) {\n doExecute(drawCommand);\n }\n }\n }\n };\n doExecute(drawCommand);\n }\n break;\n }\n }\n };\n doExecute(surfaceCreatedCommand);\n if (_debug) Log.d(TAG, \"end onSurfaceCreated() [\" + this + \"]\");\n }\n", "output": " public void onSurfaceCreated(final SurfaceHolder holder) {\n if (_debug) Log.d(TAG, \"start onSurfaceCreated() [\" + this + \"]\");\n super.onSurfaceCreated(holder);\n Runnable surfaceCreatedCommand = new Runnable() {\n @Override\n public void run() {\n doSurfaceCreated();\n }\n protected void doSurfaceCreated() {\n if (mInitialized) {\n if (_debug) Log.d(TAG, \"already Initialized(surfaceCreatedCommand)\");\n return;\n }\n boolean ret;\n int counter = 0;\n int specCounter = 0;\n while(true) {\n if (_debug) Log.d(TAG, \"start EGLContext.getEGL()\");\n exitEgl();\n egl10 = (EGL10) EGLContext.getEGL();\n if (_debug) Log.d(TAG, \"end EGLContext.getEGL()\");\n if (_debug) Log.d(TAG, \"start eglGetDisplay\");\n eglDisplay = egl10.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);\n if (_debug) Log.d(TAG, \"end eglGetDisplay\");\n if (eglDisplay == null || EGL10.EGL_NO_DISPLAY.equals(eglDisplay)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n if (_debug) Log.d(TAG, \"eglGetDisplay\u304cEGL_NO_DISPLAY [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG, \"egl10.eglCreateContext\u304cEGL_NO_DISPLAY\");\n throw new RuntimeException(\"OpenGL Error(EGL_NO_DISPLAY) \"\n + errStr + \": \"\n );\n } \n if (_debug) Log.d(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n {\n egl10.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);\n }\n int[] version = new int[2];\n if (! egl10.eglInitialize(eglDisplay, version)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n if (_debug) Log.d(TAG, \"egl10.eglInitialize\u304cfalse [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG,\"egl10.eglInitialize\u304cfalse\");\n throw new RuntimeException(\"OpenGL Error(eglInitialize) \"\n + errStr + \": \"\n );\n }\n if (_debug) Log.d(TAG,\"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n EGLConfig[] configs = new EGLConfig[1];\n int[] numConfig = new int[1];\n egl10.eglChooseConfig(eglDisplay, configSpec[specCounter++], configs, 1, numConfig);\n if (numConfig[0] == 0) {\n if (_debug) Log.d(TAG, \"numConfig[0]=\" + numConfig[0] + \"\");\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \" eglChooseConfig numConfig == 0 \";\n errStr += \" numConfig:[\" + numConfig[0] + \"]\";\n errStr += \" specCounter:[\" + (specCounter - 1) + \"]\";\n exitEgl();\n Log.e(TAG,\"eglChooseConfig\u5931\u6557:\"\n + \"numConfig:[\" + numConfig[0] + \"]\"\n + errStr);\n if (++counter >= AtlantisService.RETRY_COUNT) {\n throw new RuntimeException(\"OpenGL Error \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.d(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n EGLConfig config = configs[0];\n eglContext = egl10.eglCreateContext(eglDisplay, config, EGL10.EGL_NO_CONTEXT, null); \n if (eglContext == null || EGL10.EGL_NO_CONTEXT.equals(eglContext)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \"egl10.eglCreateContext == EGL_NO_CONTEXT \";\n errStr += \"specCounter:[\" + (specCounter - 1) + \"]\";\n if (_debug) Log.d(TAG, \"egl10.eglCreateContext == EGL_NO_CONTEXT [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG, \"egl10.eglCreateContext\u304cEGL_NO_CONTEXT\");\n throw new RuntimeException(\"OpenGL Error(EGL_NO_CONTEXT) \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.d(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n if (_debug) Log.d(TAG, \"eglCreateContext done.\");\n eglSurface = egl10.eglCreateWindowSurface(eglDisplay, config, holder, null);\n if (eglSurface == null || EGL10.EGL_NO_SURFACE.equals(eglSurface)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \"egl10.eglCreateWindowSurface == EGL_NO_SURFACE \";\n errStr += \"specCounter:[\" + (specCounter - 1) + \"]\";\n if (_debug) Log.d(TAG, \"egl10.eglCreateWindowSurface == EGL_NO_SURFACE [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG, \"egl10.eglCreateWindowSurface\u304cEGL_NO_SURFACE\");\n throw new RuntimeException(\"OpenGL Error(EGL_NO_SURFACE) \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.e(TAG, \"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n if (_debug) Log.d(TAG, \"eglCreateWindowSurface done.\");\n if (! egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {\n String errStr = AtlantisService.getErrorString(egl10.eglGetError());\n errStr += \"egl10.eglMakeCurrent == false \";\n errStr += \"specCounter:[\" + (specCounter - 1) + \"]\";\n if (_debug) Log.d(TAG, \"egl10.eglMakeCurrent == false [\" + errStr + \"]\");\n exitEgl();\n if (++counter >= AtlantisService.RETRY_COUNT) {\n Log.e(TAG,\"egl10.eglMakeCurrent\u304cfalse\");\n throw new RuntimeException(\"OpenGL Error(eglMakeCurrent) \"\n + errStr + \" :\"\n );\n }\n if (_debug) Log.d(TAG,\"RETRY\");\n System.gc();\n waitNano();\n continue;\n }\n if (_debug) Log.d(TAG, \"eglMakeCurrent done.\");\n if (_debug) Log.d(TAG, \"now create gl10 object\");\n gl10 = new MatrixTrackingGL((GL10) (eglContext.getGL()));\n glRenderer = GLRenderer.getInstance(getApplicationContext());\n synchronized (glRenderer) {\n glRenderer.onSurfaceCreated(gl10, config, getApplicationContext());\n }\n if (_debug) Log.d(TAG, \"EGL initalize done.\");\n mInitialized = true;\n if (drawCommand == null) {\n drawCommand = new Runnable() {\n public void run() {\n doDrawCommand();\n }\n protected void doDrawCommand() {\n if (mInitialized && glRenderer != null && gl10 != null) {\n synchronized (glRenderer) {\n long nowTime = System.nanoTime();\n if (nowTime - glRenderer.prevTick < BASE_TICK) {\n try {\n TimeUnit.NANOSECONDS.sleep(BASE_TICK - (nowTime - glRenderer.prevTick));\n } catch (InterruptedException e) {\n }\n }\n glRenderer.onDrawFrame(gl10);\n glRenderer.prevTick = nowTime;\n }\n egl10.eglSwapBuffers(eglDisplay, eglSurface);\n if (!getExecutor().isShutdown() && isVisible() && egl10.eglGetError() != EGL11.EGL_CONTEXT_LOST) {\n doExecute(drawCommand);\n }\n }\n }\n };\n doExecute(drawCommand);\n }\n break;\n }\n }\n };\n doExecute(surfaceCreatedCommand);\n if (_debug) Log.d(TAG, \"end onSurfaceCreated() [\" + this + \"]\");\n }\n"} {"input": "\tpublic void execute() throws Throwable\n\t{\n\t\tOlioPerson loggedPerson = this.getUtility().getPerson(this.getSessionState().getLoggedPersonId());\n\t\tif (!this.getUtility().isRegisteredPerson(loggedPerson))\n\t\t{\n\t\t\tthis.getLogger().severe(\"Login required for adding an event\");\n\t\t\tthis.setFailed(true);\n\t\t\treturn;\n\t\t}\n\t\tStringBuilder response = null;\n\t\tresponse = this.getHttpTransport().fetchUrl(this.getGenerator().getAddEventURL());\n\t\tthis.trace(this.getGenerator().getAddEventURL());\n\t\tif (!this.getGenerator().checkHttpResponse(response.toString()))\n\t\t{\n\t\t\tthis.getLogger().severe(\"Problems in performing request to URL: \" + this.getGenerator().getAddEventURL() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"). Server response: \" + response);\n\t\t\tthrow new IOException(\"Problems in performing request to URL: \" + this.getGenerator().getAddEventURL() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \")\");\n\t\t}\n\t\tthis.loadStatics(this.getGenerator().getAddEventStatics());\n\t\tthis.trace(this.getGenerator().getAddEventStatics());\n\t\tString token = null;\n\t\tswitch (this.getConfiguration().getIncarnation())\n\t\t{\n\t\t\tcase OlioConfiguration.JAVA_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.PHP_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.RAILS_INCARNATION:\n\t\t\t\ttoken = this.parseAuthToken(response.toString());\n\t\t\t\tif ( token == null )\n\t\t\t\t{\n\t\t\t\t\tthrow new Exception( \"Authentication token could not be parsed\" );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tOlioSocialEvent event = this.getUtility().newSocialEvent();\n\t\tevent.submitterUserName = loggedPerson.userName;\n\t\tHttpPost reqPost = new HttpPost(this.getGenerator().getAddEventResultURL());\n\t\tMultipartEntity entity = new MultipartEntity();\n\t\tthis.populateEntity(entity, event);\n\t\tswitch (this.getConfiguration().getIncarnation())\n\t\t{\n\t\t\tcase OlioConfiguration.JAVA_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.PHP_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.RAILS_INCARNATION:\n\t\t\t\tentity.addPart(\"authenticity_token\", new StringBody(token));\n\t\t\t\tbreak;\n\t\t}\n\t\treqPost.setEntity(entity);\n\t\tresponse = this.getHttpTransport().fetch(reqPost);\n\t\tthis.trace(this.getGenerator().getAddEventResultURL());\n\t\tif (!this.getGenerator().checkHttpResponse(response.toString()))\n\t\t{\n\t\t\tthis.getLogger().severe(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"). Server response: \" + response);\n\t\t\tthrow new IOException(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \")\");\n\t\t}\n\t\tint index = response.toString().toLowerCase().indexOf(\"success\");\n\t\tif (index == -1)\n\t\t{\n\t\t\tthis.getLogger().severe(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"): Could not find success message in result body. Server response: \" + response);\n\t\t\tthrow new IOException(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"): Could not find success message in result body\");\n\t\t}\n\t\tthis.getSessionState().setLastResponse(response.toString());\n\t\tthis.setFailed(false);\n\t}\n", "output": "\tpublic void execute() throws Throwable\n\t{\n\t\tOlioPerson loggedPerson = this.getUtility().getPerson(this.getSessionState().getLoggedPersonId());\n\t\tif (!this.getUtility().isRegisteredPerson(loggedPerson))\n\t\t{\n\t\t\tthis.getLogger().severe(\"Login required for adding an event\");\n\t\t\tthis.setFailed(true);\n\t\t\treturn;\n\t\t}\n\t\tStringBuilder response = null;\n\t\tresponse = this.getHttpTransport().fetchUrl(this.getGenerator().getAddEventURL());\n\t\tthis.trace(this.getGenerator().getAddEventURL());\n\t\tif (!this.getGenerator().checkHttpResponse(response.toString()))\n\t\t{\n\t\t\tthis.getLogger().severe(\"Problems in performing request to URL: \" + this.getGenerator().getAddEventURL() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"). Server response: \" + response);\n\t\t\tthrow new IOException(\"Problems in performing request to URL: \" + this.getGenerator().getAddEventURL() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \")\");\n\t\t}\n\t\tthis.loadStatics(this.getGenerator().getAddEventStatics());\n\t\tthis.trace(this.getGenerator().getAddEventStatics());\n\t\tString token = null;\n\t\tswitch (this.getConfiguration().getIncarnation())\n\t\t{\n\t\t\tcase OlioConfiguration.JAVA_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.PHP_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.RAILS_INCARNATION:\n\t\t\t\ttoken = this.parseAuthToken(response.toString());\n\t\t\t\tif ( token == null )\n\t\t\t\t{\n\t\t\t\t\tthrow new Exception( \"Authentication token could not be parsed\" );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tOlioSocialEvent event = this.getUtility().newSocialEvent();\n\t\tevent.submitterUserName = loggedPerson.userName;\n\t\tHttpPost reqPost = new HttpPost(this.getGenerator().getAddEventResultURL());\n\t\tMultipartEntity entity = new MultipartEntity();\n\t\tthis.populateEntity(entity, event);\n\t\tswitch (this.getConfiguration().getIncarnation())\n\t\t{\n\t\t\tcase OlioConfiguration.JAVA_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.PHP_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.RAILS_INCARNATION:\n\t\t\t\tentity.addPart(\"authenticity_token\", new StringBody(token));\n\t\t\t\tbreak;\n\t\t}\n\t\treqPost.setEntity(entity);\n\t\tresponse = this.getHttpTransport().fetch(reqPost);\n\t\tthis.trace(this.getGenerator().getAddEventResultURL());\n\t\tif (!this.getGenerator().checkHttpResponse(response.toString()))\n\t\t{\n\t\t\tthis.getLogger().severe(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"). Server response: \" + response);\n\t\t\tthrow new IOException(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \")\");\n\t\t}\n\t\tswitch (this.getConfiguration().getIncarnation())\n\t\t{\n\t\t\tcase OlioConfiguration.JAVA_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.PHP_INCARNATION:\n\t\t\t\tbreak;\n\t\t\tcase OlioConfiguration.RAILS_INCARNATION:\n\t\t\t\tint index = response.toString().toLowerCase().indexOf(\"event was successfully created.\");\n\t\t\t\tif (index == -1)\n\t\t\t\t{\n\t\t\t\t\tthis.getLogger().severe(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"): Could not find success message in result body. Server response: \" + response);\n\t\t\t\t\tthrow new IOException(\"Problems in performing request to URL: \" + reqPost.getURI() + \" (HTTP status code: \" + this.getHttpTransport().getStatusCode() + \"): Could not find success message in result body\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t\tthis.getSessionState().setLastResponse(response.toString());\n\t\tthis.setFailed(false);\n\t}\n"} {"input": "\tpublic void addPrimitiveDerivedSetOrGet(Type.Kind derivedTypeKind,\n\t String derived,\n\t String index,\n\t Kind primitiveType,\n\t String primitive,\n\t boolean set) throws BackendException {\n\t\tList indices = new LinkedList();\n\t\twhile(references.containsKey(derived)) {\n\t\t\tMap.Entry> reference = references.get(derived);\n\t\t\tindices.addAll(reference.getValue());\n\t\t\tderived = reference.getKey();\n\t\t}\n\t\tswitch(derivedTypeKind) {\n\t\t\tcase ARRAY:\n\t\t\t\tindices.add(index);\n\t\t\t\tbreak;\n\t\t\tcase STRUCT:\n\t\t\t\tDerivedType type = derivedTypes.get(derived);\n\t\t\t\tif(type instanceof LLVMBackendArrayType) {\n\t\t\t\t\ttype = (DerivedType) ((LLVMBackendArrayType) type).getStorageType();\n\t\t\t\t}\n\t\t\t\tif(type instanceof LLVMBackendStructType) {\n\t\t\t\t\tList members = ((LLVMBackendStructType) type).getMembers();\n\t\t\t\t\tfor(Member m: members) {\n\t\t\t\t\t\tif(m.getName().equals(index)) {\n\t\t\t\t\t\t\tindices.add(String.valueOf(members.indexOf(m)));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new BackendException(\"Unexpected final derived type: \" + type.getClass().getName());\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new BackendException(\"Unexpected derived type: \" + derivedTypeKind.toString());\n\t\t}\n\t\tStringBuffer indexList = new StringBuffer();\n\t\tfor(String i: indices) {\n\t\t\tindexList.append(\", \");\n\t\t\tindexList.append(Module.getIRType(Type.Kind.LONG));\n\t\t\tindexList.append(\" \");\n\t\t\tindexList.append(cdl(i, Type.Kind.LONG));\n\t\t}\n\t\tString primitiveIRType = Module.getIRType(primitiveType);\n\t\tDerivedType derivedType = derivedTypes.get(derived);\n\t\tString derivedIRType = \"\";\n\t\tif(derivedType instanceof LLVMBackendArrayType) {\n\t\t\tLLVMBackendArrayType derivedArType = (LLVMBackendArrayType) derivedType;\n\t\t\tderivedIRType = Module.getIRAType(derivedArType.getStorageType(), derivedArType.getDimensions());\n\t\t\tfor(int idx = 0;\n\t\t\t idx < derivedArType.getDimensions().size();\n\t\t\t\tidx++)\n\t\t\t{\n\t\t\t\tString dim = \"\"+derivedArType.getDimensions().get(idx);\n\t\t\t\tString elem= cdl(indices.get(idx),Type.Kind.LONG);\n\t\t\t\tgen(\"call void @aoob1(i64 \" + elem + \", i64 \" + dim + \")\");\n\t\t\t}\n\t\t}\n\t\telse if(derivedType instanceof LLVMBackendStructType) {\n\t\t\tLLVMBackendStructType derivedStType = (LLVMBackendStructType) derivedType;\n\t\t\tderivedIRType = Module.getIRSType(derivedStType.getMembers());\n\t\t}\n\t\telse {\n\t\t\tthrow new BackendException(\"Unexpected derived type: \" + derivedType.getClass().getName());\n\t\t}\n\t\tif(set) {\n\t\t\tString derivedUseIdentifier1 = getUseIdentifierForVariable(derived);\n\t\t\tString derivedUseIdentifier2 = getUseIdentifierForVariable(derived);\n\t\t\tString derivedIdentifier = \"%\" + derived;\n\t\t\tprimitive = cdl(primitive, primitiveType);\n\t\t\tgen(derivedUseIdentifier1 + \" = getelementptr \" + derivedIRType + \"* \" + derivedIdentifier + \", i64 0\"\n\t\t\t\t+ indexList);\n\t\t\tgen(\"store \" + primitiveIRType + \" \" + primitive + \", \" + primitiveIRType + \"* \" + derivedUseIdentifier1);\n\t\t}\n\t\telse {\n\t\t\tString primitiveUseIdentifier = getUseIdentifierForVariable(primitive);\n\t\t\tString primitiveIdentifier = \"%\" + primitive;\n\t\t\tString derivedUseIdentifier = getUseIdentifierForVariable(derived);\n\t\t\tString derivedIdentifier = \"%\" + derived;\n\t\t\tgen(derivedUseIdentifier + \" = getelementptr \" + derivedIRType + \"* \" + derivedIdentifier + \", i64 0\"\n\t\t\t\t+ indexList);\n\t\t\tgen(primitiveUseIdentifier + \" = load \" + primitiveIRType + \"* \" + derivedUseIdentifier);\n\t\t\tgen(\"store \" + primitiveIRType + \" \" + primitiveUseIdentifier + \", \" + primitiveIRType + \"* \" + primitiveIdentifier);\n\t\t}\n\t}\n", "output": "\tpublic void addPrimitiveDerivedSetOrGet(Type.Kind derivedTypeKind,\n\t String derived,\n\t String index,\n\t Kind primitiveType,\n\t String primitive,\n\t boolean set) throws BackendException {\n\t\tList indices = new LinkedList();\n\t\twhile(references.containsKey(derived)) {\n\t\t\tMap.Entry> reference = references.get(derived);\n\t\t\tindices.addAll(reference.getValue());\n\t\t\tderived = reference.getKey();\n\t\t}\n\t\tswitch(derivedTypeKind) {\n\t\t\tcase ARRAY:\n\t\t\t\tindices.add(index);\n\t\t\t\tbreak;\n\t\t\tcase STRUCT:\n\t\t\t\tDerivedType type = derivedTypes.get(derived);\n\t\t\t\tif(type instanceof LLVMBackendArrayType) {\n\t\t\t\t\ttype = (DerivedType) ((LLVMBackendArrayType) type).getStorageType();\n\t\t\t\t}\n\t\t\t\tif(type instanceof LLVMBackendStructType) {\n\t\t\t\t\tList members = ((LLVMBackendStructType) type).getMembers();\n\t\t\t\t\tfor(Member m: members) {\n\t\t\t\t\t\tif(m.getName().equals(index)) {\n\t\t\t\t\t\t\tindices.add(\"#\" + String.valueOf(members.indexOf(m)));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new BackendException(\"Unexpected final derived type: \" + type.getClass().getName());\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new BackendException(\"Unexpected derived type: \" + derivedTypeKind.toString());\n\t\t}\n\t\tStringBuffer indexList = new StringBuffer();\n\t\tfor(String i: indices) {\n\t\t\tindexList.append(\", \");\n\t\t\tindexList.append(Module.getIRType(Type.Kind.LONG));\n\t\t\tindexList.append(\" \");\n\t\t\tindexList.append(cdl(i, Type.Kind.LONG));\n\t\t}\n\t\tString primitiveIRType = Module.getIRType(primitiveType);\n\t\tDerivedType derivedType = derivedTypes.get(derived);\n\t\tString derivedIRType = \"\";\n\t\tif(derivedType instanceof LLVMBackendArrayType) {\n\t\t\tLLVMBackendArrayType derivedArType = (LLVMBackendArrayType) derivedType;\n\t\t\tderivedIRType = Module.getIRAType(derivedArType.getStorageType(), derivedArType.getDimensions());\n\t\t\tfor(int idx = 0;\n\t\t\t idx < derivedArType.getDimensions().size();\n\t\t\t\tidx++)\n\t\t\t{\n\t\t\t\tString dim = \"\"+derivedArType.getDimensions().get(idx);\n\t\t\t\tString elem= cdl(indices.get(idx),Type.Kind.LONG);\n\t\t\t\tgen(\"call void @aoob1(i64 \" + elem + \", i64 \" + dim + \")\");\n\t\t\t}\n\t\t}\n\t\telse if(derivedType instanceof LLVMBackendStructType) {\n\t\t\tLLVMBackendStructType derivedStType = (LLVMBackendStructType) derivedType;\n\t\t\tderivedIRType = Module.getIRSType(derivedStType.getMembers());\n\t\t}\n\t\telse {\n\t\t\tthrow new BackendException(\"Unexpected derived type: \" + derivedType.getClass().getName());\n\t\t}\n\t\tif(set) {\n\t\t\tString derivedUseIdentifier1 = getUseIdentifierForVariable(derived);\n\t\t\tString derivedUseIdentifier2 = getUseIdentifierForVariable(derived);\n\t\t\tString derivedIdentifier = \"%\" + derived;\n\t\t\tprimitive = cdl(primitive, primitiveType);\n\t\t\tgen(derivedUseIdentifier1 + \" = getelementptr \" + derivedIRType + \"* \" + derivedIdentifier + \", i64 0\"\n\t\t\t\t+ indexList);\n\t\t\tgen(\"store \" + primitiveIRType + \" \" + primitive + \", \" + primitiveIRType + \"* \" + derivedUseIdentifier1);\n\t\t}\n\t\telse {\n\t\t\tString primitiveUseIdentifier = getUseIdentifierForVariable(primitive);\n\t\t\tString primitiveIdentifier = \"%\" + primitive;\n\t\t\tString derivedUseIdentifier = getUseIdentifierForVariable(derived);\n\t\t\tString derivedIdentifier = \"%\" + derived;\n\t\t\tgen(derivedUseIdentifier + \" = getelementptr \" + derivedIRType + \"* \" + derivedIdentifier + \", i64 0\"\n\t\t\t\t+ indexList);\n\t\t\tgen(primitiveUseIdentifier + \" = load \" + primitiveIRType + \"* \" + derivedUseIdentifier);\n\t\t\tgen(\"store \" + primitiveIRType + \" \" + primitiveUseIdentifier + \", \" + primitiveIRType + \"* \" + primitiveIdentifier);\n\t\t}\n\t}\n"} {"input": " private static void proceedExternalStoragePath() {\n String mExternalStoragePathName = Environment.getExternalStorageDirectory()\n .getAbsolutePath();\n if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {\n if (Build.VERSION.SDK_INT >= 18) {\n if (mExternalStoragePathName.endsWith(\"/emulated/0\")\n || mExternalStoragePathName.endsWith(\"/emulated/0/\")) {\n mExternalStoragePathName = mExternalStoragePathName.replace(\"/emulated/0\",\n \"/emulated/legacy\");\n }\n }\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n } else {\n boolean isPathFromSdkWorking = false;\n boolean isPathFromLegacyWorking = false;\n String externalPath;\n externalPath = mExternalStoragePathName.endsWith(\"/\") ? mExternalStoragePathName\n : mExternalStoragePathName + \"/\";\n externalPath = externalPath + \"v4a_test_file\";\n Log.i(\"ViPER4Android\", \"Now checking for external storage writable, file = \"\n + externalPath);\n if (checkWritable(externalPath)) {\n isPathFromSdkWorking = true;\n }\n externalPath = mExternalStoragePathName.endsWith(\"/\") ? mExternalStoragePathName\n : mExternalStoragePathName + \"/\";\n if (externalPath.endsWith(\"/emulated/0/\")) {\n externalPath = externalPath.replace(\"/emulated/0/\", \"/emulated/legacy/\");\n externalPath = externalPath + \"v4a_test_file\";\n Log.i(\"ViPER4Android\", \"Now checking for external storage writable, file = \" + externalPath);\n if (checkWritable(externalPath)) {\n isPathFromLegacyWorking = true;\n }\n }\n if (isPathFromLegacyWorking) {\n mExternalStoragePathName = mExternalStoragePathName.replace(\"/emulated/0\",\n \"/emulated/legacy\");\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sEnvironmentInitialized + \"Profile/\";\n Log.i(\"ViPER4Android\", \"External storage path = \" + sExternalStoragePath);\n Log.i(\"ViPER4Android\", \"ViPER4Android root path = \" + sV4aRoot);\n Log.i(\"ViPER4Android\", \"ViPER4Android kernel path = \" + sV4aKernelPath);\n Log.i(\"ViPER4Android\", \"ViPER4Android profile path = \" + sV4aProfilePath);\n return;\n }\n if (isPathFromSdkWorking) {\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n Log.i(\"ViPER4Android\", \"External storage path = \" + sExternalStoragePath);\n Log.i(\"ViPER4Android\", \"ViPER4Android root path = \" + sV4aRoot);\n Log.i(\"ViPER4Android\", \"ViPER4Android kernel path = \" + sV4aKernelPath);\n Log.i(\"ViPER4Android\", \"ViPER4Android profile path = \" + sV4aProfilePath);\n return;\n }\n Log.i(\"ViPER4Android\", \"Really terrible thing, external storage detection failed. V4A may malfunction\");\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n }\n }\n", "output": " private static void proceedExternalStoragePath() {\n String mExternalStoragePathName = Environment.getExternalStorageDirectory()\n .getAbsolutePath();\n if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {\n if (Build.VERSION.SDK_INT >= 18) {\n if (mExternalStoragePathName.endsWith(\"/emulated/0\")\n || mExternalStoragePathName.endsWith(\"/emulated/0/\")) {\n mExternalStoragePathName = mExternalStoragePathName.replace(\"/emulated/0\",\n \"/emulated/legacy\");\n }\n }\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n } else {\n boolean isPathFromSdkWorking = false;\n boolean isPathFromLegacyWorking = false;\n String externalPath;\n externalPath = mExternalStoragePathName.endsWith(\"/\") ? mExternalStoragePathName\n : mExternalStoragePathName + \"/\";\n externalPath = externalPath + \"v4a_test_file\";\n Log.i(\"ViPER4Android\", \"Now checking for external storage writable, file = \"\n + externalPath);\n if (checkWritable(externalPath)) {\n isPathFromSdkWorking = true;\n }\n externalPath = mExternalStoragePathName.endsWith(\"/\") ? mExternalStoragePathName\n : mExternalStoragePathName + \"/\";\n if (externalPath.endsWith(\"/emulated/0/\")) {\n externalPath = externalPath.replace(\"/emulated/0/\", \"/emulated/legacy/\");\n externalPath = externalPath + \"v4a_test_file\";\n Log.i(\"ViPER4Android\", \"Now checking for external storage writable, file = \" + externalPath);\n if (checkWritable(externalPath)) {\n isPathFromLegacyWorking = true;\n }\n }\n if (isPathFromLegacyWorking) {\n mExternalStoragePathName = mExternalStoragePathName.replace(\"/emulated/0\",\n \"/emulated/legacy\");\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n Log.i(\"ViPER4Android\", \"External storage path = \" + sExternalStoragePath);\n Log.i(\"ViPER4Android\", \"ViPER4Android root path = \" + sV4aRoot);\n Log.i(\"ViPER4Android\", \"ViPER4Android kernel path = \" + sV4aKernelPath);\n Log.i(\"ViPER4Android\", \"ViPER4Android profile path = \" + sV4aProfilePath);\n return;\n }\n if (isPathFromSdkWorking) {\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n Log.i(\"ViPER4Android\", \"External storage path = \" + sExternalStoragePath);\n Log.i(\"ViPER4Android\", \"ViPER4Android root path = \" + sV4aRoot);\n Log.i(\"ViPER4Android\", \"ViPER4Android kernel path = \" + sV4aKernelPath);\n Log.i(\"ViPER4Android\", \"ViPER4Android profile path = \" + sV4aProfilePath);\n return;\n }\n Log.i(\"ViPER4Android\", \"Really terrible thing, external storage detection failed. V4A may malfunction\");\n sExternalStoragePath = mExternalStoragePathName.endsWith(\"/\")\n ? mExternalStoragePathName : mExternalStoragePathName + \"/\";\n sV4aRoot = sExternalStoragePath + \"ViPER4Android/\";\n sV4aKernelPath = sV4aRoot + \"Kernel/\";\n sV4aProfilePath = sV4aRoot + \"Profile/\";\n }\n }\n"} {"input": "\tpublic boolean canRun(Transmittable trns) {\n\t\tif (!trns.isPrivmsg())\n\t\t\treturn false;\n\t\tString msg = trns.asPrivmsg().getMessage();\n\t\tMatcher matcher = COMMAND_PATTERN.matcher(msg);\n\t\tif (matcher.matches()) {\n\t\t\tint count = matcher.groupCount();\n\t\t\tString command = matcher.group(3);\n\t\t\tif (matcher.group(4) == null || matcher.group(4).isEmpty()) {\n\t\t\t\treturn matcher.group(2).matches(getName());\n\t\t\t} else {\n System.out.println(command);\n System.out.println(matcher.group(4));\n\t\t\t\treturn command.matches(getName()) && matcher.group(4).matches(getParameterRegex());\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean canRun(Transmittable trns) {\n\t\tif (!trns.isPrivmsg())\n\t\t\treturn false;\n\t\tString msg = trns.asPrivmsg().getMessage();\n\t\tMatcher matcher = COMMAND_PATTERN.matcher(msg);\n\t\tif (matcher.matches()) {\n\t\t\tint count = matcher.groupCount();\n\t\t\tif (matcher.group(4) == null || matcher.group(4).isEmpty()) {\n\t\t\t\treturn matcher.group(2).matches(getName());\n\t\t\t} else {\n return matcher.group(4).matches(getName()) && matcher.group(5).matches(getParameterRegex());\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": "\tpublic IRegion getDamageRegion(ITypedRegion partition, final DocumentEvent e, boolean documentPartitioningChanged) {\n\t\tif (documentPartitioningChanged)\n\t\t\treturn partition;\n\t\tIRegion result = getDocument().readOnly(new UnitOfWork(){\n\t\t\tprivate final int offset = e.getOffset();\n\t\t\tprivate final int endOffset = offset + e.getLength();\n\t\t\tpublic IRegion exec(XtextResource resource) throws Exception {\n\t\t\t\tAbstractNode node = resource.getParseResult().getRootNode();\n\t\t\t\tAbstractNode start = null;\n\t\t\t\tAbstractNode end = null;\n\t\t\t\twhile(node != null && start == null) {\n\t\t\t\t\tif (node instanceof CompositeNode) {\n\t\t\t\t\t\tfor(AbstractNode child: ((CompositeNode) node).getChildren()) {\n\t\t\t\t\t\t\tif (child.getTotalOffset() <= offset && child.getTotalOffset() + child.getTotalLength() >= offset) {\n\t\t\t\t\t\t\t\tnode = child;\n\t\t\t\t\t\t\t\tif (node instanceof LeafNode || node.getTotalOffset() == offset)\n\t\t\t\t\t\t\t\t\tstart = node;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new IllegalStateException(\"node is not in expected range but is not a composite.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnode = start;\n\t\t\t\twhile(node != null && end == null) {\n\t\t\t\t\tif (node.getTotalLength() + node.getTotalOffset() >= endOffset) {\n\t\t\t\t\t\twhile(end == null) {\n\t\t\t\t\t\t\tif (node instanceof CompositeNode) {\n\t\t\t\t\t\t\t\tfor(int i = ((CompositeNode) node).getChildren().size() - 1; i >= 0; i--) {\n\t\t\t\t\t\t\t\t\tAbstractNode child = ((CompositeNode) node).getChildren().get(i);\n\t\t\t\t\t\t\t\t\tif (child.getTotalOffset() + child.getTotalLength() >= endOffset && child.getTotalOffset() <= endOffset) {\n\t\t\t\t\t\t\t\t\t\tnode = child;\n\t\t\t\t\t\t\t\t\t\tif (node instanceof LeafNode || node.getTotalOffset() + node.getTotalLength() == endOffset)\n\t\t\t\t\t\t\t\t\t\t\tend = node;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tend = node;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode = node.getParent();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint startOffset = start != null ? start.getTotalOffset() : offset;\n\t\t\t\tint endOffset = end != null ? end.getTotalOffset() + end.getTotalLength() : this.endOffset;\n\t\t\t\tRange range = new Range(startOffset, endOffset);\n\t\t\t\trange.mergeAllErrors(resource.getParseResult().getRootNode());\n\t\t\t\treturn new Region(range.getFromOffset(), range.getToOffset() - range.getFromOffset() + e.getText().length() - e.getLength());\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n", "output": "\tpublic IRegion getDamageRegion(ITypedRegion partition, final DocumentEvent e, boolean documentPartitioningChanged) {\n\t\tif (documentPartitioningChanged)\n\t\t\treturn partition;\n\t\tIRegion result = getDocument().readOnly(new UnitOfWork(){\n\t\t\tprivate final int offset = e.getOffset();\n\t\t\tprivate final int endOffset = offset + e.getLength();\n\t\t\tpublic IRegion exec(XtextResource resource) throws Exception {\n\t\t\t\tAbstractNode node = resource.getParseResult().getRootNode();\n\t\t\t\tAbstractNode start = null;\n\t\t\t\tAbstractNode end = null;\n\t\t\t\twhile(node != null && start == null) {\n\t\t\t\t\tif (node instanceof CompositeNode) {\n\t\t\t\t\t\tif (((CompositeNode) node).getChildren().isEmpty())\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tfor(AbstractNode child: ((CompositeNode) node).getChildren()) {\n\t\t\t\t\t\t\tif (child.getTotalOffset() <= offset && child.getTotalOffset() + child.getTotalLength() >= offset) {\n\t\t\t\t\t\t\t\tnode = child;\n\t\t\t\t\t\t\t\tif (node instanceof LeafNode || node.getTotalOffset() == offset)\n\t\t\t\t\t\t\t\t\tstart = node;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new IllegalStateException(\"node is not in expected range but is not a composite.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnode = start;\n\t\t\t\twhile(node != null && end == null) {\n\t\t\t\t\tif (node.getTotalLength() + node.getTotalOffset() >= endOffset) {\n\t\t\t\t\t\twhile(end == null) {\n\t\t\t\t\t\t\tif (node instanceof CompositeNode) {\n\t\t\t\t\t\t\t\tfor(int i = ((CompositeNode) node).getChildren().size() - 1; i >= 0; i--) {\n\t\t\t\t\t\t\t\t\tAbstractNode child = ((CompositeNode) node).getChildren().get(i);\n\t\t\t\t\t\t\t\t\tif (child.getTotalOffset() + child.getTotalLength() >= endOffset && child.getTotalOffset() <= endOffset) {\n\t\t\t\t\t\t\t\t\t\tnode = child;\n\t\t\t\t\t\t\t\t\t\tif (node instanceof LeafNode || node.getTotalOffset() + node.getTotalLength() == endOffset)\n\t\t\t\t\t\t\t\t\t\t\tend = node;\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tend = node;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode = node.getParent();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint startOffset = start != null ? start.getTotalOffset() : offset;\n\t\t\t\tint endOffset = end != null ? end.getTotalOffset() + end.getTotalLength() : this.endOffset;\n\t\t\t\tRange range = new Range(startOffset, endOffset);\n\t\t\t\trange.mergeAllErrors(resource.getParseResult().getRootNode());\n\t\t\t\treturn new Region(range.getFromOffset(), range.getToOffset() - range.getFromOffset() + e.getText().length() - e.getLength());\n\t\t\t}\n\t\t});\n\t\treturn result;\n\t}\n"} {"input": " public void runTest(String test, boolean registerInfo) throws IOException, URISyntaxException {\n String dexFilePath = String.format(\"%s%sclasses.dex\", test, File.separatorChar);\n DexFile dexFile = DexFileFactory.loadDexFile(findResource(dexFilePath), 15);\n baksmaliOptions options = new baksmaliOptions();\n if (registerInfo) {\n options.registerInfo = baksmaliOptions.ALL | baksmaliOptions.FULLMERGE;\n options.classPath = new ClassPath();\n }\n for (ClassDef classDef: dexFile.getClasses()) {\n StringWriter stringWriter = new StringWriter();\n IndentingWriter writer = new IndentingWriter(stringWriter);\n ClassDefinition classDefinition = new ClassDefinition(options, classDef);\n classDefinition.writeTo(writer);\n writer.close();\n String className = classDef.getType();\n String smaliPath = String.format(\"%s%s%s.smali\", test, File.separatorChar,\n className.substring(1, className.length() - 1));\n String smaliContents = readResource(smaliPath);\n Assert.assertEquals(smaliContents.replace(\"\\r\\n\", \"\\n\"), stringWriter.toString().replace(\"\\r\\n\", \"\\n\"));\n }\n }\n", "output": " public void runTest(String test, boolean registerInfo) throws IOException, URISyntaxException {\n String dexFilePath = String.format(\"%s%sclasses.dex\", test, File.separatorChar);\n DexFile dexFile = DexFileFactory.loadDexFile(findResource(dexFilePath), 15);\n baksmaliOptions options = new baksmaliOptions();\n if (registerInfo) {\n options.registerInfo = baksmaliOptions.ALL | baksmaliOptions.FULLMERGE;\n options.classPath = new ClassPath();\n }\n for (ClassDef classDef: dexFile.getClasses()) {\n StringWriter stringWriter = new StringWriter();\n IndentingWriter writer = new IndentingWriter(stringWriter);\n ClassDefinition classDefinition = new ClassDefinition(options, classDef);\n classDefinition.writeTo(writer);\n writer.close();\n String className = classDef.getType();\n String smaliPath = String.format(\"%s%s%s.smali\", test, File.separatorChar,\n className.substring(1, className.length() - 1));\n String smaliContents = readResource(smaliPath);\n Assert.assertEquals(smaliContents.replace(\"\\r\", \"\").replace(\"\\n\", System.lineSeparator()),\n stringWriter.toString().replace(\"\\r\", \"\").replace(\"\\n\", System.lineSeparator()));\n }\n }\n"} {"input": "\tpublic void onEnable() {\n\t\ttry {\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Initalizing...\");\n\t\t\tserver = getServer();\n\t\t\tPluginManager pm = server.getPluginManager();\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Loading config and ban handler...\");\n\t\t\tlong oldtime = System.currentTimeMillis();\n\t\t\tGlobalConf.conf = getConfig();\n\t\t\tGlobalConf.loadConfig();\n\t\t\tHashMap data = new HashMap(15);\n\t\t\tdata.put(\"username\", GlobalConf.Sql.user);\n\t\t\tdata.put(\"password\", GlobalConf.Sql.pass);\n\t\t\tdata.put(\"host\", GlobalConf.Sql.host);\n\t\t\tdata.put(\"port\", GlobalConf.Sql.port);\n\t\t\tdata.put(\"prefix\", GlobalConf.Sql.prefix);\n\t\t\tdata.put(\"db\", GlobalConf.Sql.db);\n\t\t\ttry {\n\t\t\t\tClass rawClass = Class.forName(GlobalConf.Advanced.pkg+\".\"+GlobalConf.banHandlerConf+GlobalConf.Advanced.suffix);\n\t\t\t\tif (rawClass.isAssignableFrom(BanHandler.class)) {\n\t\t\t\t\tClass[] arguments = {Map.class};\n\t\t\t\t\tbanHandler = (BanHandler) rawClass.getDeclaredMethod(\"onEnable\", arguments).invoke(null, data);\n\t\t\t\t} else {\n\t\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Wierd ban handler given in config file! Aborting operation.\");\n\t\t\t\t\tonFatal();\n\t\t\t\t}\n\t\t\t} catch (ClassNotFoundException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Non-existant ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (SecurityException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Somehow, a SecurityException occurred. Plugin conflict? Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (NoSuchMethodException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (IllegalAccessException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (InvocationTargetException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (NullPointerException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (ClassCastException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t}\n\t\t\tlong newtime = System.currentTimeMillis();\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Done. Took \"+(newtime-oldtime)+\" ms.\");\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Registering events...\");\n\t\t\toldtime = System.currentTimeMillis();\n\t\t\tpm.registerEvents(new EventListener(), this);\n\t\t\tnewtime = System.currentTimeMillis();\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Done. Took \"+(newtime-oldtime)+\" ms.\");\n\t\t}\n\t\tcatch (RuntimeException e) {\n\t\t\tsetEnabled(false);\n\t\t}\n\t}\n", "output": "\tpublic void onEnable() {\n\t\ttry {\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Initalizing...\");\n\t\t\tserver = getServer();\n\t\t\tPluginManager pm = server.getPluginManager();\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Loading config and ban handler...\");\n\t\t\tlong oldtime = System.currentTimeMillis();\n\t\t\tGlobalConf.conf = getConfig();\n\t\t\tGlobalConf.loadConfig();\n\t\t\tHashMap data = new HashMap(15);\n\t\t\tdata.put(\"username\", GlobalConf.Sql.user);\n\t\t\tdata.put(\"password\", GlobalConf.Sql.pass);\n\t\t\tdata.put(\"host\", GlobalConf.Sql.host);\n\t\t\tdata.put(\"port\", GlobalConf.Sql.port);\n\t\t\tdata.put(\"prefix\", GlobalConf.Sql.prefix);\n\t\t\tdata.put(\"db\", GlobalConf.Sql.db);\n\t\t\tdata.put(\"yaml\", GlobalConf.Yaml.file);\n\t\t\tdata.put(\"json\", GlobalConf.Json.file);\n\t\t\tdata.put(\"apiKey\", GlobalConf.MCBans.apiKey);\n\t\t\ttry {\n\t\t\t\tClass rawClass = Class.forName(GlobalConf.Advanced.pkg+\".\"+GlobalConf.banHandlerConf+GlobalConf.Advanced.suffix);\n\t\t\t\tif (rawClass.isAssignableFrom(BanHandler.class)) {\n\t\t\t\t\tClass[] arguments = {Map.class};\n\t\t\t\t\tbanHandler = (BanHandler) rawClass.getDeclaredMethod(\"onEnable\", arguments).invoke(null, data);\n\t\t\t\t} else {\n\t\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Wierd ban handler given in config file! Aborting operation.\");\n\t\t\t\t\tonFatal();\n\t\t\t\t}\n\t\t\t} catch (ClassNotFoundException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Non-existant ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (SecurityException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Somehow, a SecurityException occurred. Plugin conflict? Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (NoSuchMethodException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (IllegalAccessException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (InvocationTargetException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (NullPointerException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t} catch (ClassCastException e) {\n\t\t\t\tLOG.severe(GlobalConf.logPrefix+\"Bad ban handler given in config file! Aborting operation.\");\n\t\t\t\tonFatal();\n\t\t\t}\n\t\t\tlong newtime = System.currentTimeMillis();\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Done. Took \"+(newtime-oldtime)+\" ms.\");\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Registering events...\");\n\t\t\toldtime = System.currentTimeMillis();\n\t\t\tpm.registerEvents(new EventListener(), this);\n\t\t\tnewtime = System.currentTimeMillis();\n\t\t\tSystem.out.println(GlobalConf.logPrefix+\"Done. Took \"+(newtime-oldtime)+\" ms.\");\n\t\t}\n\t\tcatch (RuntimeException e) {\n\t\t\tsetEnabled(false);\n\t\t}\n\t}\n"} {"input": " public static GLConfig fromgl(GL gl, GLContext ctx, GLCapabilitiesImmutable caps) {\n\tGLConfig c = new GLConfig();\n\ttry {\n\t c.glmajver = glgeti(gl, GL2.GL_MAJOR_VERSION);\n\t c.glminver = glgeti(gl, GL2.GL_MINOR_VERSION);\n\t} catch(GLException e) {\n\t c.glmajver = 1;\n\t c.glminver = 0;\n\t}\n\tc.maxlights = glgeti(gl, GL2.GL_MAX_LIGHTS);\n\tc.exts = Arrays.asList(gl.glGetString(GL.GL_EXTENSIONS).split(\" \"));\n\tc.caps = caps;\n\tc.pref = GLSettings.defconf(c);\n\tString slv = glconds(gl, GL2.GL_SHADING_LANGUAGE_VERSION);\n\tif(slv != null) {\n\t Matcher m = slvp.matcher(slv);\n\t if(m.find()) {\n\t\ttry {\n\t\t int major = Integer.parseInt(m.group(1));\n\t\t int minor = Integer.parseInt(m.group(2));\n\t\t if((major > 0) || (major < 256) || (minor >= 0) || (minor < 256))\n\t\t\tc.glslver = (major << 8) | minor;\n\t\t} catch(NumberFormatException e) {\n\t\t}\n\t }\n\t}\n\treturn(c);\n }\n", "output": " public static GLConfig fromgl(GL gl, GLContext ctx, GLCapabilitiesImmutable caps) {\n\tGLConfig c = new GLConfig();\n\ttry {\n\t c.glmajver = glgeti(gl, GL2.GL_MAJOR_VERSION);\n\t c.glminver = glgeti(gl, GL2.GL_MINOR_VERSION);\n\t} catch(GOut.GLException e) {\n\t c.glmajver = 1;\n\t c.glminver = 0;\n\t}\n\tc.maxlights = glgeti(gl, GL2.GL_MAX_LIGHTS);\n\tc.exts = Arrays.asList(gl.glGetString(GL.GL_EXTENSIONS).split(\" \"));\n\tc.caps = caps;\n\tc.pref = GLSettings.defconf(c);\n\tString slv = glconds(gl, GL2.GL_SHADING_LANGUAGE_VERSION);\n\tif(slv != null) {\n\t Matcher m = slvp.matcher(slv);\n\t if(m.find()) {\n\t\ttry {\n\t\t int major = Integer.parseInt(m.group(1));\n\t\t int minor = Integer.parseInt(m.group(2));\n\t\t if((major > 0) || (major < 256) || (minor >= 0) || (minor < 256))\n\t\t\tc.glslver = (major << 8) | minor;\n\t\t} catch(NumberFormatException e) {\n\t\t}\n\t }\n\t}\n\treturn(c);\n }\n"} {"input": " protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n \tString action = request.getParameter(\"Action\");\n \tString name = request.getParameter(\"User\");\n \tString pass = request.getParameter(\"Pass\");\n \tSystem.out.println(action);\n \tServletContext sc = request.getServletContext();\n\t\tAccountManager am = (AccountManager) sc.getAttribute(\"accounts\");\n \tif (action.equals(\"Create\")) {\n \t\tAccount acct = am.createAccount(name, pass);\n \t\tif (acct == null) {\n \t\t\trequest.getRequestDispatcher(\"/NameTaken.jsp\").forward(request, response);\n \t\t} else {\n \t\t\tsc.setAttribute(\"user\", name);\n \t\t\tAccount curracct = (Account) request.getSession().getAttribute(\"account\");\n \t\t\tcurracct = acct;\n \t\t\trequest.getRequestDispatcher(\"/UserHome.jsp\").forward(request, response);\n \t\t}\n \t} else if (action.equals(\"Delete\")) {\n \t\tam.deleteAccount(name);\n \t\trequest.getRequestDispatcher(\"/GuestHome.jsp\").forward(request, response);\n \t} else if (action.equals(\"Logout\")) {\n \t\tam.logoutAccount((Account) request.getSession().getAttribute(\"account\"));\n \t\trequest.getSession().setAttribute(\"account\", null);\n \t\trequest.getRequestDispatcher(\"/GuestHome.jsp\").forward(request, response);\n \t}\n }\n", "output": " protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {\n \tString action = request.getParameter(\"Action\");\n \tString name = request.getParameter(\"User\");\n \tString pass = request.getParameter(\"Pass\");\n \tSystem.out.println(action);\n \tServletContext sc = request.getServletContext();\n\t\tAccountManager am = (AccountManager) sc.getAttribute(\"accounts\");\n \tif (action.equals(\"Create\")) {\n \t\tAccount acct = am.createAccount(name, pass);\n \t\tif (acct == null) {\n \t\t\trequest.getSession().setAttribute(\"user\", name);\n \t\t\trequest.getRequestDispatcher(\"/NameTaken.jsp\").forward(request, response);\n \t\t} else {\n \t\t\trequest.getSession().setAttribute(\"user\", name);\n \t\t\trequest.getSession().setAttribute(\"account\", acct);\n \t\t\trequest.getRequestDispatcher(\"/UserHome.jsp\").forward(request, response);\n \t\t}\n \t} else if (action.equals(\"Delete\")) {\n \t\tam.deleteAccount(name);\n \t\trequest.getRequestDispatcher(\"/GuestHome.jsp\").forward(request, response);\n \t} else if (action.equals(\"Logout\")) {\n \t\tam.logoutAccount((Account) request.getSession().getAttribute(\"account\"));\n \t\trequest.getSession().setAttribute(\"account\", null);\n \t\trequest.getRequestDispatcher(\"/GuestHome.jsp\").forward(request, response);\n \t}\n }\n"} {"input": " public int vote(Authentication authentication,\n Object object,\n ConfigAttributeDefinition config) {\n if (! (authentication instanceof UsernamePasswordAuthenticationToken)) {\n return ACCESS_ABSTAIN;\n }\n CosmoUserDetails details =\n (CosmoUserDetails) authentication.getPrincipal();\n String username = details.getUser().getUsername();\n FilterInvocation fi = (FilterInvocation) object;\n String path = findResourcePath(fi);\n return path.startsWith(username) ? ACCESS_GRANTED : ACCESS_DENIED;\n }\n", "output": " public int vote(Authentication authentication,\n Object object,\n ConfigAttributeDefinition config) {\n if (! (authentication instanceof UsernamePasswordAuthenticationToken)) {\n return ACCESS_ABSTAIN;\n }\n CosmoUserDetails details =\n (CosmoUserDetails) authentication.getPrincipal();\n String username = details.getUser().getUsername();\n FilterInvocation fi = (FilterInvocation) object;\n String path = findResourcePath(fi);\n if (path == null) {\n return ACCESS_DENIED;\n }\n return path.startsWith(username) ? ACCESS_GRANTED : ACCESS_DENIED;\n }\n"} {"input": "\tpublic void setLookups() {\n\t\tdiseaseType = new ArrayList();\n\t\tgeneTypeColl = new ArrayList();\n\t\tdiseaseType.add( new LabelValueBean( \"Astrocytic\", \"astro\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Oligodendroglial\", \"oligo\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Ependymal cell\", \"Ependymal cell\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Mixed gliomas\", \"Mixed gliomas\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Neuroepithelial\", \"Neuroepithelial\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Choroid Plexus\", \"Choroid Plexus\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Neuronal and mixed neuronal-glial\", \"neuronal-glial\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Pineal Parenchyma\", \"Pineal Parenchyma\" ));\n\t\tdiseaseType.add( new LabelValueBean( \"Embryonal\", \"Embryonal\" ));\n\t\tdiseaseType.add( new LabelValueBean( \"Glioblastoma\", \"Glioblastoma\" ));\n\t\tgeneTypeColl.add( new LabelValueBean( \"All Genes\", \"allgenes\" ) );\n\t\tgeneTypeColl.add( new LabelValueBean( \"Name/Symbol\", \"genesymbol\" ) );\n\t\tgeneTypeColl.add( new LabelValueBean( \"Locus Link Id\", \"genelocus\" ) );\n\t\tgeneTypeColl.add( new LabelValueBean( \"GenBank AccNo.\", \"genbankno\" ) );\n\t}\n", "output": "\tpublic void setLookups() {\n\t\tdiseaseType = new ArrayList();\n\t\tgeneTypeColl = new ArrayList();\n\t\tdiseaseType.add( new LabelValueBean( \"Astrocytic\", \"ASTROCYTOMA\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Oligodendroglial\", \"OLIG\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Mixed gliomas\", \"MIXED\" ) );\n\t\tdiseaseType.add( new LabelValueBean( \"Glioblastoma\", \"GBM\" ));\n\t\tgeneTypeColl.add( new LabelValueBean( \"Name/Symbol\", \"genesymbol\" ) );\n\t\tgeneTypeColl.add( new LabelValueBean( \"Locus Link Id\", \"genelocus\" ) );\n\t\tgeneTypeColl.add( new LabelValueBean( \"GenBank AccNo.\", \"genbankno\" ) );\n\t}\n"} {"input": " public void visitNode(AstNode astNode) {\n if (astNode.getFirstChild(FlexGrammar.VARIABLE_DEF_KIND).getFirstChild(FlexKeyword.CONST) != null) {\n for (AstNode variableBindingNode : astNode.getFirstChild(FlexGrammar.VARIABLE_BINDING_LIST).getChildren(FlexGrammar.VARIABLE_BINDING)) {\n AstNode identifierNode = variableBindingNode\n .getFirstChild(FlexGrammar.TYPED_IDENTIFIER)\n .getFirstChild(FlexGrammar.IDENTIFIER);\n if (!identifierNode.getTokenValue().matches(format)) {\n getContext().createLineViolation(this, \"Rename this constant name to match the regular expression {0}\",\n identifierNode, format);\n }\n }\n }\n }\n", "output": " public void visitNode(AstNode astNode) {\n if (astNode.getFirstChild(FlexGrammar.VARIABLE_DEF_KIND).getFirstChild(FlexKeyword.CONST) != null) {\n for (AstNode variableBindingNode : astNode.getFirstChild(FlexGrammar.VARIABLE_BINDING_LIST).getChildren(FlexGrammar.VARIABLE_BINDING)) {\n AstNode identifierNode = variableBindingNode\n .getFirstChild(FlexGrammar.TYPED_IDENTIFIER)\n .getFirstChild(FlexGrammar.IDENTIFIER);\n if (!identifierNode.getTokenValue().matches(format)) {\n getContext().createLineViolation(this, \"Rename this constant ''{0}'' to match the regular expression {1}\",\n identifierNode, identifierNode.getTokenValue(), format);\n }\n }\n }\n }\n"} {"input": " private void makeItem() throws CollectException {\n\ttry {\n\t long timeout = session.getTimeout(IBaseSession.Timeout.M);\n\t String tempDir = session.getTempDir();\n\t StringBuffer sb = new StringBuffer(tempDir);\n\t if (!tempDir.endsWith(session.getFilesystem().getDelimiter())) {\n\t\tsb.append(session.getFilesystem().getDelimiter());\n\t }\n\t sb.append(\"secpol.inf\");\n\t String secpol = sb.toString();\n\t String cmd = \"secedit.exe /export /areas SECURITYPOLICY /cfg \" + secpol;\n\t SafeCLI.ExecData data = SafeCLI.execData(cmd, null, session, timeout);\n\t int code = data.getExitCode();\n\t switch(code) {\n\t case 0: \n\t\tIFile file = null;\n\t\ttry {\n\t\t file = session.getFilesystem().getFile(secpol, IFile.Flags.READWRITE);\n\t\t IniFile config = new IniFile(file.getInputStream(), StringTools.UTF16LE);\n\t\t items = new Vector();\n\t\t PasswordpolicyItem item = Factories.sc.windows.createPasswordpolicyItem();\n\t\t IProperty prop = config.getSection(\"System Access\");\n\t\t for (String key : prop) {\n\t\t\tif (\"MaximumPasswordAge\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setMaxPasswdAge(type);\n\t\t\t} else if (\"MinimumPasswordAge\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setMinPasswdAge(type);\n\t\t\t} else if (\"MinimumPasswordLength\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setMinPasswdLen(type);\n\t\t\t} else if (\"PasswordHistorySize\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setPasswordHistLen(type);\n\t\t\t} else if (\"ClearTextPassword\".equals(key)) {\n\t\t\t EntityItemBoolType type = Factories.sc.core.createEntityItemBoolType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.BOOLEAN.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setReversibleEncryption(type);\n\t\t\t} else if (\"PasswordComplexity\".equals(key)) {\n\t\t\t EntityItemBoolType type = Factories.sc.core.createEntityItemBoolType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.BOOLEAN.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setReversibleEncryption(type);\n\t\t\t}\n\t\t }\n\t\t items.add(item);\n\t\t} catch (NoSuchElementException e) {\n\t\t error = new CollectException(e.getMessage(), FlagEnumeration.NOT_APPLICABLE);\n\t\t throw error;\n\t\t} catch (IOException e) {\n\t\t session.getLogger().warn(JOVALMsg.ERROR_IO, secpol, e.getMessage());\n\t\t} finally {\n\t\t if (file != null) {\n\t\t\tfile.delete();\n\t\t }\n\t\t}\n\t\tbreak;\n\t default:\n\t\tString output = new String(data.getData());\n\t\tString msg = JOVALMsg.getMessage(JOVALMsg.ERROR_WIN_SECEDIT_CODE, Integer.toString(code), output);\n\t\tthrow new Exception(msg);\n\t }\n\t} catch (CollectException e) {\n\t throw e;\n\t} catch (Exception e) {\n\t session.getLogger().warn(JOVALMsg.getMessage(JOVALMsg.ERROR_EXCEPTION), e);\n\t error = new CollectException(e.getMessage(), FlagEnumeration.ERROR);\n\t throw error;\n\t}\n }\n", "output": " private void makeItem() throws CollectException {\n\ttry {\n\t long timeout = session.getTimeout(IBaseSession.Timeout.M);\n\t String tempDir = session.getTempDir();\n\t StringBuffer sb = new StringBuffer(tempDir);\n\t if (!tempDir.endsWith(session.getFilesystem().getDelimiter())) {\n\t\tsb.append(session.getFilesystem().getDelimiter());\n\t }\n\t sb.append(\"secpol.inf\");\n\t String secpol = sb.toString();\n\t String cmd = \"secedit.exe /export /areas SECURITYPOLICY /cfg \" + secpol;\n\t SafeCLI.ExecData data = SafeCLI.execData(cmd, null, session, timeout);\n\t int code = data.getExitCode();\n\t switch(code) {\n\t case 0: \n\t\tIFile file = null;\n\t\ttry {\n\t\t file = session.getFilesystem().getFile(secpol, IFile.Flags.READWRITE);\n\t\t IniFile config = new IniFile(file.getInputStream(), StringTools.UTF16LE);\n\t\t items = new Vector();\n\t\t PasswordpolicyItem item = Factories.sc.windows.createPasswordpolicyItem();\n\t\t IProperty prop = config.getSection(\"System Access\");\n\t\t for (String key : prop) {\n\t\t\tif (\"MaximumPasswordAge\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t long days = Long.parseLong(prop.getProperty(key));\n\t\t\t long secs = days * 86400;\n\t\t\t type.setValue(Long.toString(secs));\n\t\t\t item.setMaxPasswdAge(type);\n\t\t\t} else if (\"MinimumPasswordAge\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t long days = Long.parseLong(prop.getProperty(key));\n\t\t\t long secs = days * 86400;\n\t\t\t type.setValue(Long.toString(secs));\n\t\t\t item.setMinPasswdAge(type);\n\t\t\t} else if (\"MinimumPasswordLength\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setMinPasswdLen(type);\n\t\t\t} else if (\"PasswordHistorySize\".equals(key)) {\n\t\t\t EntityItemIntType type = Factories.sc.core.createEntityItemIntType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.INT.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setPasswordHistLen(type);\n\t\t\t} else if (\"ClearTextPassword\".equals(key)) {\n\t\t\t EntityItemBoolType type = Factories.sc.core.createEntityItemBoolType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.BOOLEAN.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setReversibleEncryption(type);\n\t\t\t} else if (\"PasswordComplexity\".equals(key)) {\n\t\t\t EntityItemBoolType type = Factories.sc.core.createEntityItemBoolType();\n\t\t\t type.setDatatype(SimpleDatatypeEnumeration.BOOLEAN.value());\n\t\t\t type.setValue(prop.getProperty(key));\n\t\t\t item.setReversibleEncryption(type);\n\t\t\t}\n\t\t }\n\t\t items.add(item);\n\t\t} catch (NoSuchElementException e) {\n\t\t error = new CollectException(e.getMessage(), FlagEnumeration.NOT_APPLICABLE);\n\t\t throw error;\n\t\t} catch (IOException e) {\n\t\t session.getLogger().warn(JOVALMsg.ERROR_IO, secpol, e.getMessage());\n\t\t} finally {\n\t\t if (file != null) {\n\t\t\tfile.delete();\n\t\t }\n\t\t}\n\t\tbreak;\n\t default:\n\t\tString output = new String(data.getData());\n\t\tString msg = JOVALMsg.getMessage(JOVALMsg.ERROR_WIN_SECEDIT_CODE, Integer.toString(code), output);\n\t\tthrow new Exception(msg);\n\t }\n\t} catch (CollectException e) {\n\t throw e;\n\t} catch (Exception e) {\n\t session.getLogger().warn(JOVALMsg.getMessage(JOVALMsg.ERROR_EXCEPTION), e);\n\t error = new CollectException(e.getMessage(), FlagEnumeration.ERROR);\n\t throw error;\n\t}\n }\n"} {"input": "\tprotected void zipSubmissions(Assignment2 assignment,\n\t\t\tList submissionsWithHistory, OutputStream outputStream,\n\t\t\tStringBuilder exceptionMessage)\n\t{\n\t\tString assignmentTitle = assignment.getTitle();\n\t\tString contextId = externalLogic.getCurrentContextId();\n\t\tString currUserId = externalLogic.getCurrentUserId();\n\t\tList viewableStudents = permissionLogic.getViewableStudentsForUserForItem(currUserId, assignment);\n\t\tMap userIdUserMap = externalLogic.getUserIdUserMap(viewableStudents);\n\t\tString formatWithTime = bundle.getString(\"assignment2.assignment_grade_assignment.downloadall.filename_date_format_with_time\");\n\t\tString formatNoTime = bundle.getString(\"assignment2.assignment_grade_assignment.downloadall.filename_date_format\");\n\t\tDateFormat df_withTime = new SimpleDateFormat(formatWithTime, bundle.getLocale());\n\t\tDateFormat df_noTime = new SimpleDateFormat(formatNoTime, bundle.getLocale());\n\t\tif (!assignment.isGraded() && (submissionsWithHistory == null || submissionsWithHistory.isEmpty())) {\n\t\t if (log.isDebugEnabled()) log.debug(\"Nothing to download!!\");\n\t\t} else {\n\t\t try\n\t\t {\n\t\t ZipOutputStream out = new ZipOutputStream(outputStream);\n\t\t String root = Validator.escapeZipEntry(assignmentTitle) + Entity.SEPARATOR;\n\t\t if (submissionsWithHistory != null && !submissionsWithHistory.isEmpty())\n\t\t {\n\t\t List submissionFolderNames = new ArrayList();\n\t\t for (AssignmentSubmission s : submissionsWithHistory)\n\t\t {\n\t\t if (s.getSubmissionHistorySet() != null && !s.getSubmissionHistorySet().isEmpty()) {\n\t\t User submitterUser = userIdUserMap.get(s.getUserId());\n\t\t if (submitterUser != null) {\n\t\t String submissionFolder = submitterUser.getSortName();\n\t\t if (submissionFolderNames.contains(submissionFolder)) {\n\t\t submissionFolder = getUniqueFolderName(submissionFolder, submissionFolderNames);\n\t\t }\n\t\t submissionFolderNames.add(submissionFolder);\n\t\t Set versionHistory = s.getSubmissionHistorySet();\n\t\t if (versionHistory != null && !versionHistory.isEmpty()) {\n\t\t List versionFolderNames = new ArrayList(); \n\t\t for (AssignmentSubmissionVersion version : versionHistory) {\n\t\t if (version.getSubmittedDate() != null) {\n\t\t String versionFolder = root + submissionFolder + Entity.SEPARATOR \n\t\t + df_withTime.format(version.getSubmittedDate());\n\t\t if (versionFolderNames.contains(versionFolder)) {\n\t\t versionFolder = getUniqueFolderName(versionFolder, versionFolderNames);\n\t\t }\n\t\t versionFolderNames.add(versionFolder);\n\t\t ZipEntry versionFolderEntry = new ZipEntry(\n\t\t versionFolder);\n\t\t out.putNextEntry(versionFolderEntry);\n\t\t out.flush();\n\t\t out.closeEntry();\n\t\t if (version.getSubmittedText() != null && version.getSubmittedText().trim().length() > 0)\n\t\t {\n\t\t ZipEntry textEntry = new ZipEntry(versionFolder + Entity.SEPARATOR \n\t\t + bundle.getString(\"assignment2.assignment_grade_assignment.downloadall.filename_submitted_text\")\n\t\t + \".txt\");\n\t\t out.putNextEntry(textEntry);\n\t\t byte[] text = version.getSubmittedText().getBytes();\n\t\t out.write(text);\n\t\t textEntry.setSize(text.length);\n\t\t out.closeEntry();\n\t\t }\n\t\t if (version.getSubmissionAttachSet() != null && !version.getSubmissionAttachSet().isEmpty()) {\n\t\t zipAttachments(out, root + submissionFolder,\n\t\t versionFolder, version.getSubmissionAttachSet());\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t if (assignment.isGraded() && assignment.getGradableObjectId() != null) {\n\t\t StringBuilder gradesBuilder = new StringBuilder();\n\t\t gradesBuilder.append(\n\t\t bundle.getFormattedMessage(\"assignment2.assignment_grade-assignment.downloadall.header\",\n\t\t new Object[] {assignmentTitle}))\n\t\t .append(\"\\n\");\n\t\t List gradableStudents = permissionLogic.getGradableStudentsForUserForItem(currUserId, assignment);\n\t\t if (gradableStudents != null && !gradableStudents.isEmpty()) {\n\t\t Map userIdGradeMap = gradebookLogic.getGradeInformationForStudents(gradableStudents, assignment.getContextId(), assignment.getGradableObjectId());\n\t\t for (String studentId : gradableStudents) {\n\t\t User student = userIdUserMap.get(studentId);\n\t\t if (student != null) {\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(student.getDisplayId());\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(student.getSortName());\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t GradeInformation gradeInfo = userIdGradeMap.get(studentId);\n\t\t if (gradeInfo != null) {\n\t\t String gradebookGrade = \"\";\n\t\t String gradebookComment = \"\";\n\t\t if (gradeInfo.getGradebookGrade() != null) {\n\t\t gradebookGrade = gradeInfo.getGradebookGrade();\n\t\t }\n\t\t if (gradeInfo.getGradebookComment() != null) {\n\t\t gradebookComment = gradeInfo.getGradebookComment();\n\t\t }\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(gradebookGrade);\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(gradebookComment);\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t } else {\n\t\t gradesBuilder.append(\",,\");\n\t\t }\n\t\t gradesBuilder.append(\"\\n\");\n\t\t }\n\t\t }\n\t\t ZipEntry gradesCSVEntry = new ZipEntry(root + assignmentTitle + \"-\" + contextId + \"_\" + df_noTime.format(new Date()) + \".csv\");\n\t\t out.putNextEntry(gradesCSVEntry);\n\t\t byte[] grades = gradesBuilder.toString().getBytes();\n\t\t out.write(grades);\n\t\t gradesCSVEntry.setSize(grades.length);\n\t\t out.closeEntry();\n\t\t }\n\t\t }\n\t\t out.finish();\n\t\t out.flush();\n\t\t out.close();\n\t\t }\n\t\t catch (IOException e)\n\t\t {\n\t\t exceptionMessage.append(\"Cannot establish the IO to create zip file. \");\n\t\t log\n\t\t .debug(this\n\t\t + \": getSubmissionsZip--IOException unable to create the zip file for assignment \"\n\t\t + assignmentTitle);\n\t\t }\n\t\t}\n\t}\n", "output": "\tprotected void zipSubmissions(Assignment2 assignment,\n\t\t\tList submissionsWithHistory, OutputStream outputStream,\n\t\t\tStringBuilder exceptionMessage)\n\t{\n\t\tString assignmentTitle = assignment.getTitle();\n\t\tString contextId = externalLogic.getCurrentContextId();\n\t\tString currUserId = externalLogic.getCurrentUserId();\n\t\tList viewableStudents = permissionLogic.getViewableStudentsForUserForItem(currUserId, assignment);\n\t\tMap userIdUserMap = externalLogic.getUserIdUserMap(viewableStudents);\n\t\tString formatWithTime = bundle.getString(\"assignment2.assignment_grade_assignment.downloadall.filename_date_format_with_time\");\n\t\tString formatNoTime = bundle.getString(\"assignment2.assignment_grade_assignment.downloadall.filename_date_format\");\n\t\tDateFormat df_withTime = new SimpleDateFormat(formatWithTime, bundle.getLocale());\n\t\tDateFormat df_noTime = new SimpleDateFormat(formatNoTime, bundle.getLocale());\n\t\tif (!assignment.isGraded() && (submissionsWithHistory == null || submissionsWithHistory.isEmpty())) {\n\t\t if (log.isDebugEnabled()) log.debug(\"Nothing to download!!\");\n\t\t} else {\n\t\t try\n\t\t {\n\t\t ZipOutputStream out = new ZipOutputStream(outputStream);\n\t\t String root = Validator.escapeZipEntry(assignmentTitle) + Entity.SEPARATOR;\n\t\t if (submissionsWithHistory != null && !submissionsWithHistory.isEmpty())\n\t\t {\n\t\t List submissionFolderNames = new ArrayList();\n\t\t for (AssignmentSubmission s : submissionsWithHistory)\n\t\t {\n\t\t if (s.getSubmissionHistorySet() != null && !s.getSubmissionHistorySet().isEmpty()) {\n\t\t User submitterUser = userIdUserMap.get(s.getUserId());\n\t\t if (submitterUser != null) {\n\t\t String submissionFolder = submitterUser.getSortName();\n\t\t if (submissionFolderNames.contains(submissionFolder)) {\n\t\t submissionFolder = getUniqueFolderName(submissionFolder, submissionFolderNames);\n\t\t }\n\t\t submissionFolderNames.add(submissionFolder);\n\t\t Set versionHistory = s.getSubmissionHistorySet();\n\t\t if (versionHistory != null && !versionHistory.isEmpty()) {\n\t\t List versionFolderNames = new ArrayList(); \n\t\t for (AssignmentSubmissionVersion version : versionHistory) {\n\t\t if (version.getSubmittedDate() != null) {\n\t\t String versionFolder = root + submissionFolder + Entity.SEPARATOR \n\t\t + df_withTime.format(version.getSubmittedDate());\n\t\t if (versionFolderNames.contains(versionFolder)) {\n\t\t versionFolder = getUniqueFolderName(versionFolder, versionFolderNames);\n\t\t }\n\t\t versionFolderNames.add(versionFolder);\n\t\t ZipEntry versionFolderEntry = new ZipEntry(\n\t\t versionFolder + Entity.SEPARATOR);\n\t\t out.putNextEntry(versionFolderEntry);\n\t\t out.closeEntry();\n\t\t if (version.getSubmittedText() != null && version.getSubmittedText().trim().length() > 0)\n\t\t {\n\t\t String submittedTextFileName = bundle.getString(\"assignment2.assignment_grade_assignment.downloadall.filename_submitted_text\") + \".txt\";\n\t\t ZipEntry textEntry = new ZipEntry(versionFolder + Entity.SEPARATOR \n\t\t + submittedTextFileName);\n\t\t out.putNextEntry(textEntry);\n\t\t byte[] text = version.getSubmittedText().getBytes();\n\t\t out.write(text);\n\t\t textEntry.setSize(text.length);\n\t\t out.closeEntry();\n\t\t }\n\t\t if (version.getSubmissionAttachSet() != null && !version.getSubmissionAttachSet().isEmpty()) {\n\t\t zipAttachments(out, root + submissionFolder,\n\t\t versionFolder, version.getSubmissionAttachSet());\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t }\n\t\t if (assignment.isGraded() && assignment.getGradableObjectId() != null) {\n\t\t StringBuilder gradesBuilder = new StringBuilder();\n\t\t gradesBuilder.append(\n\t\t bundle.getFormattedMessage(\"assignment2.assignment_grade-assignment.downloadall.header\",\n\t\t new Object[] {assignmentTitle}))\n\t\t .append(\"\\n\");\n\t\t List gradableStudents = permissionLogic.getGradableStudentsForUserForItem(currUserId, assignment);\n\t\t if (gradableStudents != null && !gradableStudents.isEmpty()) {\n\t\t Map userIdGradeMap = gradebookLogic.getGradeInformationForStudents(gradableStudents, assignment.getContextId(), assignment.getGradableObjectId());\n\t\t for (String studentId : gradableStudents) {\n\t\t User student = userIdUserMap.get(studentId);\n\t\t if (student != null) {\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(student.getDisplayId());\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(student.getSortName());\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t GradeInformation gradeInfo = userIdGradeMap.get(studentId);\n\t\t if (gradeInfo != null) {\n\t\t String gradebookGrade = \"\";\n\t\t String gradebookComment = \"\";\n\t\t if (gradeInfo.getGradebookGrade() != null) {\n\t\t gradebookGrade = gradeInfo.getGradebookGrade();\n\t\t }\n\t\t if (gradeInfo.getGradebookComment() != null) {\n\t\t gradebookComment = gradeInfo.getGradebookComment();\n\t\t }\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(gradebookGrade);\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(gradebookComment);\n\t\t gradesBuilder.append(\"\\\"\");\n\t\t gradesBuilder.append(\",\");\n\t\t } else {\n\t\t gradesBuilder.append(\",,\");\n\t\t }\n\t\t gradesBuilder.append(\"\\n\");\n\t\t }\n\t\t }\n\t\t ZipEntry gradesCSVEntry = new ZipEntry(root + assignmentTitle + \"-\" + contextId + \"_\" + df_noTime.format(new Date()) + \".csv\");\n\t\t out.putNextEntry(gradesCSVEntry);\n\t\t byte[] grades = gradesBuilder.toString().getBytes();\n\t\t out.write(grades);\n\t\t gradesCSVEntry.setSize(grades.length);\n\t\t out.closeEntry();\n\t\t }\n\t\t }\n\t\t out.finish();\n\t\t out.flush();\n\t\t out.close();\n\t\t }\n\t\t catch (IOException e)\n\t\t {\n\t\t exceptionMessage.append(\"Cannot establish the IO to create zip file. \");\n\t\t log\n\t\t .debug(this\n\t\t + \": getSubmissionsZip--IOException unable to create the zip file for assignment \"\n\t\t + assignmentTitle);\n\t\t }\n\t\t}\n\t}\n"} {"input": " public void populate(MetropolisGenerator generator,Chunk chunk) {\n ClipboardProviderWorldEdit clips = generator.getClipboardProvider();\n grid = generator.getGridProvider().getGrid(chunkX,chunkZ);\n GridRandom random = grid.getRandom();\n ContextProvider context = generator.getContextProvider();\n if(random.getChance(60)){\n List schems = clips.getFit(chunkSizeX,chunkSizeZ, findRoad(),context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ) + \"going over to fallback\");\n schems = clips.getFit(chunkSizeX,chunkSizeZ, Direction.NORTH,context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ));\n }\n }\n }\n if((chunkSizeX<=2)&&(chunkSizeZ<=2)){ \n List schems = clips.getFit(chunkSizeX,chunkSizeZ, findRoad(),context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ) + \"going over to fallback\");\n schems = clips.getFit(chunkSizeX,chunkSizeZ, Direction.NORTH,context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n parcel = new EmptyParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ);\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ));\n }\n }\n return; \n }\n if(chunkSizeX>chunkSizeZ){\n int cut = random.getRandomInt(1,chunkSizeX-1);\n partitionX(grid,cut);\n }else {\n int cut = random.getRandomInt(1,chunkSizeZ-1);\n partitionZ(grid,cut);\n }\n partition1.populate(generator,chunk);\n partition2.populate(generator,chunk);\n }\n private Direction findRoad(){\n for(int i=0;i schems = clips.getFit(chunkSizeX,chunkSizeZ, findRoad(),context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ) + \"going over to fallback\");\n schems = clips.getFit(chunkSizeX,chunkSizeZ, Direction.NORTH,context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ));\n }\n }\n }\n if((chunkSizeX<=2)&&(chunkSizeZ<=2)){ \n List schems = clips.getFit(chunkSizeX,chunkSizeZ, findRoad(),context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ) + \"going over to fallback\");\n schems = clips.getFit(chunkSizeX,chunkSizeZ, Direction.NORTH,context.getContext(chunkX,chunkZ)); \n if(schems!=null&&schems.size()>0){\n generator.reportDebug(\"Found \"+schems.size()+\" schematics for this spot, placing one\");\n parcel = new ClipboardParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ,schems.get(random.getRandomInt(schems.size())),context.getContext(chunkX,chunkZ));\n parcel.populate(generator,chunk);\n return;\n }else {\n parcel = new EmptyParcel(grid,chunkX,chunkZ,chunkSizeX,chunkSizeZ);\n generator.reportDebug(\"No schems found for size \"+chunkSizeX+\"x\"+chunkSizeZ + \" , context=\" + context.getContext(chunkX,chunkZ));\n }\n }\n return; \n }\n if(chunkSizeX>chunkSizeZ){\n int cut = random.getRandomInt(1,chunkSizeX-1);\n partitionX(grid,cut);\n }else {\n int cut = random.getRandomInt(1,chunkSizeZ-1);\n partitionZ(grid,cut);\n }\n partition1.populate(generator,chunk);\n partition2.populate(generator,chunk);\n }\n private Direction findRoad(){\n for(int i=0;i 0) {\n DataXceiverServer dxcs =\n (DataXceiverServer) dn.dataXceiverServer.getRunnable();\n LOG.info(\"Updating balance throttler bandwidth from \"\n + dxcs.balanceThrottler.getBandwidth() + \" bytes/s \"\n + \"to: \" + bandwidth + \" bytes/s.\");\n dxcs.balanceThrottler.setBandwidth(bandwidth);\n }\n break;\n default:\n LOG.warn(\"Unknown DatanodeCommand action: \" + cmd.getAction());\n }\n return true;\n }\n", "output": " private boolean processCommandFromActive(DatanodeCommand cmd,\n BPServiceActor actor) throws IOException {\n if (cmd == null)\n return true;\n final BlockCommand bcmd = \n cmd instanceof BlockCommand? (BlockCommand)cmd: null;\n switch(cmd.getAction()) {\n case DatanodeProtocol.DNA_TRANSFER:\n dn.transferBlocks(bcmd.getBlockPoolId(), bcmd.getBlocks(), bcmd.getTargets());\n dn.metrics.incrBlocksReplicated(bcmd.getBlocks().length);\n break;\n case DatanodeProtocol.DNA_INVALIDATE:\n Block toDelete[] = bcmd.getBlocks();\n try {\n if (dn.blockScanner != null) {\n dn.blockScanner.deleteBlocks(bcmd.getBlockPoolId(), toDelete);\n }\n dn.getFSDataset().invalidate(bcmd.getBlockPoolId(), toDelete);\n } catch(IOException e) {\n throw e;\n }\n dn.metrics.incrBlocksRemoved(toDelete.length);\n break;\n case DatanodeProtocol.DNA_SHUTDOWN:\n throw new UnsupportedOperationException(\"Received unimplemented DNA_SHUTDOWN\");\n case DatanodeProtocol.DNA_REGISTER:\n LOG.info(\"DatanodeCommand action: DNA_REGISTER\");\n actor.reRegister();\n break;\n case DatanodeProtocol.DNA_FINALIZE:\n String bp = ((FinalizeCommand) cmd).getBlockPoolId(); \n assert getBlockPoolId().equals(bp) :\n \"BP \" + getBlockPoolId() + \" received DNA_FINALIZE \" +\n \"for other block pool \" + bp;\n dn.finalizeUpgradeForPool(bp);\n break;\n case DatanodeProtocol.DNA_RECOVERBLOCK:\n String who = \"NameNode at \" + actor.getNNSocketAddress();\n dn.recoverBlocks(who, ((BlockRecoveryCommand)cmd).getRecoveringBlocks());\n break;\n case DatanodeProtocol.DNA_ACCESSKEYUPDATE:\n LOG.info(\"DatanodeCommand action: DNA_ACCESSKEYUPDATE\");\n if (dn.isBlockTokenEnabled) {\n dn.blockPoolTokenSecretManager.addKeys(\n getBlockPoolId(), \n ((KeyUpdateCommand) cmd).getExportedKeys());\n }\n break;\n case DatanodeProtocol.DNA_BALANCERBANDWIDTHUPDATE:\n LOG.info(\"DatanodeCommand action: DNA_BALANCERBANDWIDTHUPDATE\");\n long bandwidth =\n ((BalancerBandwidthCommand) cmd).getBalancerBandwidthValue();\n if (bandwidth > 0) {\n DataXceiverServer dxcs =\n (DataXceiverServer) dn.dataXceiverServer.getRunnable();\n LOG.info(\"Updating balance throttler bandwidth from \"\n + dxcs.balanceThrottler.getBandwidth() + \" bytes/s \"\n + \"to: \" + bandwidth + \" bytes/s.\");\n dxcs.balanceThrottler.setBandwidth(bandwidth);\n }\n break;\n default:\n LOG.warn(\"Unknown DatanodeCommand action: \" + cmd.getAction());\n }\n return true;\n }\n"} {"input": "\tpublic ProvisioningPlan getProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) {\n\t\tSubMonitor sub = SubMonitor.convert(monitor, ExpandWork);\n\t\tsub.setTaskName(Messages.Director_Task_Resolving_Dependencies);\n\t\ttry {\n\t\t\tIProfile profile = profileChangeRequest.getProfile();\n\t\t\tObject[] updatedPlan = updatePlannerInfo(profileChangeRequest);\n\t\t\tURI[] metadataRepositories = (context != null) ? context.getMetadataRepositories() : null;\n\t\t\tDictionary newSelectionContext = createSelectionContext(profileChangeRequest.getProfileProperties());\n\t\t\tList extraIUs = new ArrayList(Arrays.asList(profileChangeRequest.getAddedInstallableUnits()));\n\t\t\textraIUs.addAll(Arrays.asList(profileChangeRequest.getRemovedInstallableUnits()));\n\t\t\tif (context == null || context.getProperty(INCLUDE_PROFILE_IUS) == null || context.getProperty(INCLUDE_PROFILE_IUS).equalsIgnoreCase(Boolean.TRUE.toString()))\n\t\t\t\textraIUs.addAll(profile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection());\n\t\t\tIInstallableUnit[] availableIUs = gatherAvailableInstallableUnits((IInstallableUnit[]) extraIUs.toArray(new IInstallableUnit[extraIUs.size()]), metadataRepositories, context, sub.newChild(ExpandWork / 4));\n\t\t\tSlicer slicer = new Slicer(new QueryableArray(availableIUs), newSelectionContext);\n\t\t\tIQueryable slice = slicer.slice(new IInstallableUnit[] {(IInstallableUnit) updatedPlan[0]}, sub.newChild(ExpandWork / 4));\n\t\t\tif (slice == null)\n\t\t\t\treturn new ProvisioningPlan(slicer.getStatus());\n\t\t\tProjector projector = new Projector(slice, newSelectionContext);\n\t\t\tprojector.encode((IInstallableUnit) updatedPlan[0], (IInstallableUnit[]) updatedPlan[1], profileChangeRequest.getAddedInstallableUnits(), sub.newChild(ExpandWork / 4));\n\t\t\tIStatus s = projector.invokeSolver(sub.newChild(ExpandWork / 4));\n\t\t\tif (s.getSeverity() == IStatus.CANCEL)\n\t\t\t\treturn new ProvisioningPlan(s);\n\t\t\tif (s.getSeverity() == IStatus.ERROR) {\n\t\t\t\tsub.setTaskName(Messages.Planner_NoSolution);\n\t\t\t\tif (!(context.getProperty(EXPLANATION) == null || Boolean.TRUE.toString().equalsIgnoreCase(context.getProperty(EXPLANATION))))\n\t\t\t\t\treturn new ProvisioningPlan(s);\n\t\t\t\tboolean newExplanation = Boolean.getBoolean(\"p2.new.explanation\"); \n\t\t\t\tLogHelper.log(s);\n\t\t\t\tif (!newExplanation) {\n\t\t\t\t\tIStatus oldResolverStatus = new NewDependencyExpander(new IInstallableUnit[] {(IInstallableUnit) updatedPlan[0]}, null, availableIUs, newSelectionContext, false).expand(sub.newChild(ExpandWork / 4));\n\t\t\t\t\tif (!oldResolverStatus.isOK())\n\t\t\t\t\t\ts = oldResolverStatus;\n\t\t\t\t\treturn new ProvisioningPlan(oldResolverStatus, new Operand[0], buildDetailedErrors(profileChangeRequest), new RequestStatus(null, RequestStatus.REMOVED, IStatus.ERROR, null));\n\t\t\t\t}\n\t\t\t\tSet explanation = projector.getExplanation();\n\t\t\t\tIStatus explanationStatus = new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, explanation.toString(), null);\n\t\t\t\treturn new ProvisioningPlan(explanationStatus, new Operand[0], buildDetailedErrors(profileChangeRequest), new RequestStatus(null, RequestStatus.REMOVED, IStatus.ERROR, explanation));\n\t\t\t}\n\t\t\tif (Tracing.DEBUG && s.getSeverity() != IStatus.OK)\n\t\t\t\tLogHelper.log(s);\n\t\t\ts = Status.OK_STATUS;\n\t\t\tCollection newState = projector.extractSolution();\n\t\t\tnewState.remove(updatedPlan[0]);\n\t\t\tResolutionHelper newStateHelper = new ResolutionHelper(newSelectionContext, null);\n\t\t\tnewState = newStateHelper.attachCUs(newState);\n\t\t\tResolutionHelper oldStateHelper = new ResolutionHelper(createSelectionContext(profile.getProperties()), null);\n\t\t\tCollection oldState = oldStateHelper.attachCUs(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection());\n\t\t\treturn generateProvisioningPlan(s, oldState, newState, profileChangeRequest);\n\t\t} catch (OperationCanceledException e) {\n\t\t\treturn new ProvisioningPlan(Status.CANCEL_STATUS);\n\t\t} finally {\n\t\t\tsub.done();\n\t\t}\n\t}\n", "output": "\tpublic ProvisioningPlan getProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) {\n\t\tSubMonitor sub = SubMonitor.convert(monitor, ExpandWork);\n\t\tsub.setTaskName(Messages.Director_Task_Resolving_Dependencies);\n\t\ttry {\n\t\t\tIProfile profile = profileChangeRequest.getProfile();\n\t\t\tObject[] updatedPlan = updatePlannerInfo(profileChangeRequest);\n\t\t\tURI[] metadataRepositories = (context != null) ? context.getMetadataRepositories() : null;\n\t\t\tDictionary newSelectionContext = createSelectionContext(profileChangeRequest.getProfileProperties());\n\t\t\tList extraIUs = new ArrayList(Arrays.asList(profileChangeRequest.getAddedInstallableUnits()));\n\t\t\textraIUs.addAll(Arrays.asList(profileChangeRequest.getRemovedInstallableUnits()));\n\t\t\tif (context == null || context.getProperty(INCLUDE_PROFILE_IUS) == null || context.getProperty(INCLUDE_PROFILE_IUS).equalsIgnoreCase(Boolean.TRUE.toString()))\n\t\t\t\textraIUs.addAll(profile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection());\n\t\t\tIInstallableUnit[] availableIUs = gatherAvailableInstallableUnits((IInstallableUnit[]) extraIUs.toArray(new IInstallableUnit[extraIUs.size()]), metadataRepositories, context, sub.newChild(ExpandWork / 4));\n\t\t\tSlicer slicer = new Slicer(new QueryableArray(availableIUs), newSelectionContext);\n\t\t\tIQueryable slice = slicer.slice(new IInstallableUnit[] {(IInstallableUnit) updatedPlan[0]}, sub.newChild(ExpandWork / 4));\n\t\t\tif (slice == null)\n\t\t\t\treturn new ProvisioningPlan(slicer.getStatus());\n\t\t\tProjector projector = new Projector(slice, newSelectionContext);\n\t\t\tprojector.encode((IInstallableUnit) updatedPlan[0], (IInstallableUnit[]) updatedPlan[1], profileChangeRequest.getAddedInstallableUnits(), sub.newChild(ExpandWork / 4));\n\t\t\tIStatus s = projector.invokeSolver(sub.newChild(ExpandWork / 4));\n\t\t\tif (s.getSeverity() == IStatus.CANCEL)\n\t\t\t\treturn new ProvisioningPlan(s);\n\t\t\tif (s.getSeverity() == IStatus.ERROR) {\n\t\t\t\tsub.setTaskName(Messages.Planner_NoSolution);\n\t\t\t\tLogHelper.log(s);\n\t\t\t\tif (context != null && !(context.getProperty(EXPLANATION) == null || Boolean.TRUE.toString().equalsIgnoreCase(context.getProperty(EXPLANATION))))\n\t\t\t\t\treturn new ProvisioningPlan(s);\n\t\t\t\tboolean newExplanation = Boolean.getBoolean(\"p2.new.explanation\"); \n\t\t\t\tif (!newExplanation) {\n\t\t\t\t\tIStatus oldResolverStatus = new NewDependencyExpander(new IInstallableUnit[] {(IInstallableUnit) updatedPlan[0]}, null, availableIUs, newSelectionContext, false).expand(sub.newChild(ExpandWork / 4));\n\t\t\t\t\tif (!oldResolverStatus.isOK())\n\t\t\t\t\t\ts = oldResolverStatus;\n\t\t\t\t\treturn new ProvisioningPlan(oldResolverStatus, new Operand[0], buildDetailedErrors(profileChangeRequest), new RequestStatus(null, RequestStatus.REMOVED, IStatus.ERROR, null));\n\t\t\t\t}\n\t\t\t\tSet explanation = projector.getExplanation();\n\t\t\t\tIStatus explanationStatus = new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, explanation.toString(), null);\n\t\t\t\treturn new ProvisioningPlan(explanationStatus, new Operand[0], buildDetailedErrors(profileChangeRequest), new RequestStatus(null, RequestStatus.REMOVED, IStatus.ERROR, explanation));\n\t\t\t}\n\t\t\tif (Tracing.DEBUG && s.getSeverity() != IStatus.OK)\n\t\t\t\tLogHelper.log(s);\n\t\t\ts = Status.OK_STATUS;\n\t\t\tCollection newState = projector.extractSolution();\n\t\t\tnewState.remove(updatedPlan[0]);\n\t\t\tResolutionHelper newStateHelper = new ResolutionHelper(newSelectionContext, null);\n\t\t\tnewState = newStateHelper.attachCUs(newState);\n\t\t\tResolutionHelper oldStateHelper = new ResolutionHelper(createSelectionContext(profile.getProperties()), null);\n\t\t\tCollection oldState = oldStateHelper.attachCUs(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection());\n\t\t\treturn generateProvisioningPlan(s, oldState, newState, profileChangeRequest);\n\t\t} catch (OperationCanceledException e) {\n\t\t\treturn new ProvisioningPlan(Status.CANCEL_STATUS);\n\t\t} finally {\n\t\t\tsub.done();\n\t\t}\n\t}\n"} {"input": "\tpublic A requireAncestorTag(Class tagClass) {\n\t\tTagStack ts = getTagStack();\n\t\tif (ts.size()>1) {\n\t\t\tfor (int i=ts.size()-2;i>=0;--i) {\n\t\t\t\tPolygraphTag tag=ts.get(i);\n\t\t\t\tif (!tagClass.isInstance(tag)) {\n\t\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\t\tA tag2 = (A)tag;\n\t\t\t\t\treturn tag2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow new PolygraphTemplateException(String.format(\"Ancestor tag of type %s expected but not found.\",tagClass.getName()));\n\t}\n", "output": "\tpublic A requireAncestorTag(Class tagClass) {\n\t\tTagStack ts = getTagStack();\n\t\tif (ts.size()>1) {\n\t\t\tfor (int i=ts.size()-2;i>=0;--i) {\n\t\t\t\tPolygraphTag tag=ts.get(i);\n\t\t\t\tif (tagClass.isInstance(tag)) {\n\t\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\t\tA tag2 = (A)tag;\n\t\t\t\t\treturn tag2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow new PolygraphTemplateException(String.format(\"Ancestor tag of type %s expected but not found.\",tagClass.getName()));\n\t}\n"} {"input": "\tprivate void handleKeyInput() {\n\t\tif(isKeyPressed(KeyConfig.openMenu, KeyConfig.IDX_OPENSETTINGS)) {\n\t\t\tif(Minecraft.getMinecraft().currentScreen == null) {\n\t\t\t\tMinecraft.getMinecraft().displayGuiScreen(new GuiSettings());\n\t\t\t}\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.toggleRecording, KeyConfig.IDX_TOGGLERECORDING)) {\n\t\t\tEntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;\n\t\t\tEiraPlayerInfo playerInfo = EiraIRC.instance.getNetHandler().getPlayerInfo(player.username);\n\t\t\tplayerInfo.isRecording = !playerInfo.isRecording;\n\t\t\tPacket packet = new PacketRecLiveState(player.username, playerInfo.isRecording, playerInfo.isLive).createPacket();\n\t\t\tif(packet != null) {\n\t\t\t\tplayer.sendQueue.addToSendQueue(packet);\n\t\t\t}\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.toggleLive, KeyConfig.IDX_TOGGLELIVE)) {\n\t\t\tEntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;\n\t\t\tEiraPlayerInfo playerInfo = EiraIRC.instance.getNetHandler().getPlayerInfo(player.username);\n\t\t\tplayerInfo.isLive = !playerInfo.isLive;\n\t\t\tPacket packet = new PacketRecLiveState(player.username, playerInfo.isRecording, playerInfo.isLive).createPacket();\n\t\t\tif(packet != null) {\n\t\t\t\tplayer.sendQueue.addToSendQueue(packet);\n\t\t\t}\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.screenshotShare, KeyConfig.IDX_SCREENSHOTSHARE)) {\n\t\t\tif(Minecraft.getMinecraft().currentScreen instanceof GuiKeybinds) {\n\t\t\t\tScreenshot screenshot = ScreenshotManager.getInstance().takeScreenshot();\n\t\t\t\tScreenshotManager.getInstance().uploadScreenshot(screenshot);\n\t\t\t\tScreenshotManager.getInstance().shareScreenshot(screenshot);\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void handleKeyInput() {\n\t\tif(Minecraft.getMinecraft().currentScreen instanceof GuiKeybinds) {\n\t\t\treturn;\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.openMenu, KeyConfig.IDX_OPENSETTINGS)) {\n\t\t\tif(Minecraft.getMinecraft().currentScreen == null) {\n\t\t\t\tMinecraft.getMinecraft().displayGuiScreen(new GuiSettings());\n\t\t\t}\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.toggleRecording, KeyConfig.IDX_TOGGLERECORDING)) {\n\t\t\tEntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;\n\t\t\tEiraPlayerInfo playerInfo = EiraIRC.instance.getNetHandler().getPlayerInfo(player.username);\n\t\t\tplayerInfo.isRecording = !playerInfo.isRecording;\n\t\t\tPacket packet = new PacketRecLiveState(player.username, playerInfo.isRecording, playerInfo.isLive).createPacket();\n\t\t\tif(packet != null) {\n\t\t\t\tplayer.sendQueue.addToSendQueue(packet);\n\t\t\t}\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.toggleLive, KeyConfig.IDX_TOGGLELIVE)) {\n\t\t\tEntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;\n\t\t\tEiraPlayerInfo playerInfo = EiraIRC.instance.getNetHandler().getPlayerInfo(player.username);\n\t\t\tplayerInfo.isLive = !playerInfo.isLive;\n\t\t\tPacket packet = new PacketRecLiveState(player.username, playerInfo.isRecording, playerInfo.isLive).createPacket();\n\t\t\tif(packet != null) {\n\t\t\t\tplayer.sendQueue.addToSendQueue(packet);\n\t\t\t}\n\t\t}\n\t\tif(isKeyPressed(KeyConfig.screenshotShare, KeyConfig.IDX_SCREENSHOTSHARE)) {\n\t\t\tScreenshot screenshot = ScreenshotManager.getInstance().takeScreenshot();\n\t\t\tScreenshotManager.getInstance().uploadScreenshot(screenshot);\n\t\t\tScreenshotManager.getInstance().shareScreenshot(screenshot);\n\t\t}\n\t}\n"} {"input": " public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {\n final String opString = Printer.OPCODES[opcode];\n final String decompiledOwnerFullClassName = DeclarationWorker.decompileFullClassName(owner);\n final String ownerClassName = decompileClassNameWithOuterClasses(owner);\n List arguments = getInvocationArguments(desc);\n String returnType = getInvocationReturnType(desc);\n final boolean hasVoidReturnType = hasVoidReturnType(desc);\n String invocationName = name;\n boolean isStaticInvocation = false;\n if (opString.contains(\"INVOKEVIRTUAL\") || opString.contains(\"INVOKEINTERFACE\")) {\n if (!name.equals(\"\")) {\n appendInstanceInvocation(name, hasVoidReturnType ? \"\" : returnType, arguments, myBodyStack.pop());\n return;\n }\n }\n if (opString.contains(\"INVOKESPECIAL\")) {\n if (name.equals(\"\")) {\n final Expression lambdaFunction = tryVisitLambdaFunction(owner);\n if (lambdaFunction != null) {\n myBodyStack.pop();\n myBodyStack.pop();\n myBodyStack.push(lambdaFunction);\n return;\n }\n myDecompiledMethod.addImport(decompiledOwnerFullClassName);\n invocationName = ownerClassName;\n returnType = invocationName + \" \";\n } else if (!myDecompiledOwnerFullClassName.equals(decompiledOwnerFullClassName)) {\n invocationName = \"super<\" + ownerClassName + \">.\" + name;\n }\n }\n if (opString.contains(\"INVOKESTATIC\")) {\n myDecompiledMethod.addImport(decompiledOwnerFullClassName);\n if (!ownerClassName.equals(\"KotlinPackage\")) {\n if (!decompiledOwnerFullClassName.contains(\".src.\")) {\n invocationName = ownerClassName + \".\" + name;\n } else {\n invocationName = name;\n }\n } else {\n appendInstanceInvocation(name, hasVoidReturnType ? \"\" : returnType, arguments, arguments.remove(0));\n return;\n }\n isStaticInvocation = true;\n if (name.equals(\"checkParameterIsNotNull\")) {\n ((KotlinVariable) arguments.get(0)).setIsNotNull(true);\n return;\n }\n }\n appendInvocationOrConstructor(isStaticInvocation, name, invocationName, hasVoidReturnType ? \"\" : returnType, arguments, decompiledOwnerFullClassName);\n }\n", "output": " public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc) {\n final String opString = Printer.OPCODES[opcode];\n final String decompiledOwnerFullClassName = DeclarationWorker.decompileFullClassName(owner);\n final String ownerClassName = decompileClassNameWithOuterClasses(owner);\n List arguments = getInvocationArguments(desc);\n String returnType = getInvocationReturnType(desc);\n final boolean hasVoidReturnType = hasVoidReturnType(desc);\n String invocationName = name;\n boolean isStaticInvocation = false;\n if (opString.contains(\"INVOKEVIRTUAL\") || opString.contains(\"INVOKEINTERFACE\")) {\n if (!name.equals(\"\")) {\n appendInstanceInvocation(name, hasVoidReturnType ? \"\" : returnType, arguments, myBodyStack.pop());\n return;\n }\n }\n if (opString.contains(\"INVOKESPECIAL\")) {\n if (name.equals(\"\")) {\n final Expression lambdaFunction = tryVisitLambdaFunction(owner);\n if (lambdaFunction != null) {\n myBodyStack.pop();\n myBodyStack.pop();\n myBodyStack.push(lambdaFunction);\n return;\n }\n myDecompiledMethod.addImport(decompiledOwnerFullClassName);\n invocationName = ownerClassName;\n returnType = invocationName + \" \";\n } else if (!myDecompiledOwnerFullClassName.equals(decompiledOwnerFullClassName)) {\n invocationName = \"super<\" + ownerClassName + \">.\" + name;\n }\n }\n if (opString.contains(\"INVOKESTATIC\")) {\n myDecompiledMethod.addImport(decompiledOwnerFullClassName);\n if (!ownerClassName.equals(\"KotlinPackage\") && !ownerClassName.equals(myDecompiledMethod.getDecompiledClass().getName())) {\n if (!decompiledOwnerFullClassName.contains(\".src.\")) {\n if (ownerClassName.contains(\"..\")) {\n invocationName = \"super<\" + ownerClassName.substring(0, ownerClassName.indexOf(\"..\")) + \">.\" + name;\n appendInstanceInvocation(invocationName, hasVoidReturnType ? \"\" : returnType, arguments, arguments.remove(0));\n return;\n } else {\n invocationName = ownerClassName + \".\" + name;\n }\n } else {\n invocationName = name;\n }\n } else {\n appendInstanceInvocation(name, hasVoidReturnType ? \"\" : returnType, arguments, arguments.remove(0));\n return;\n }\n isStaticInvocation = true;\n if (name.equals(\"checkParameterIsNotNull\")) {\n ((KotlinVariable) arguments.get(0)).setIsNotNull(true);\n return;\n }\n }\n appendInvocationOrConstructor(isStaticInvocation, name, invocationName, hasVoidReturnType ? \"\" : returnType, arguments, decompiledOwnerFullClassName);\n }\n"} {"input": "\tpublic boolean isCategoryNameValidForCategory(Long categoryId,\n\t\t\tString categoryName) {\n\t\tCategory category = repo.findByCategoryName(categoryName);\n\t\tif (category == null)\n\t\t\treturn true;\n\t\tif (category.getCategoryId() != categoryId)\n\t\t\treturn false;\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean isCategoryNameValidForCategory(Long categoryId,\n\t\t\tString categoryName) {\n\t\tCategory category = repo.findByCategoryName(categoryName);\n\t\tif (category == null)\n\t\t\treturn true;\n\t\tif (category.getCategoryId().equals(categoryId))\n\t\t\treturn true;\n\t\treturn false;\n\t}\n"} {"input": "\tpublic Pair getMidiNumsWithTicks(int[] midiNums,int clipRate){\n\t\tlong TICKS_PER_OCCURRENCE = bpm*ppq/(6*10*1000*clipRate);\n\t\tArrayList newMidiNums = new ArrayList();\n\t\tArrayList ticksPerMidiNum = new ArrayList();\n\t\tint lastNum = midiNums[0];\n\t\tint dur = 1;\n\t\tfor(int m: midiNums){\n\t\t\tif(m != lastNum){\n\t\t\t\tnewMidiNums.add(m);\n\t\t\t\tticksPerMidiNum.add(dur*TICKS_PER_OCCURRENCE);\n\t\t\t\tlastNum = m;\n\t\t\t\tdur = 1;\n\t\t\t}else{\n\t\t\t\tdur++;\n\t\t\t}\n\t\t}\n\t\tInteger[] outMidiNums= new Integer[0];\n\t\toutMidiNums = newMidiNums.toArray(outMidiNums);\n\t\tLong[] outTicksPer = new Long[0];\n\t\toutTicksPer = ticksPerMidiNum.toArray(outTicksPer);\n\t\treturn new Pair(outMidiNums,outTicksPer);\n\t}\n", "output": "\tpublic Pair getMidiNumsWithTicks(int[] midiNums,int clipRate){\n\t\tlong TICKS_PER_OCCURRENCE = bpm*ppq/(60*clipRate);\n\t\tArrayList newMidiNums = new ArrayList();\n\t\tArrayList ticksPerMidiNum = new ArrayList();\n\t\tint lastNum = midiNums[0];\n\t\tint dur = 1;\n\t\tfor(int m: midiNums){\n\t\t\tif(m != lastNum){\n\t\t\t\tnewMidiNums.add(m);\n\t\t\t\tticksPerMidiNum.add(dur*TICKS_PER_OCCURRENCE);\n\t\t\t\tlastNum = m;\n\t\t\t\tdur = 1;\n\t\t\t}else{\n\t\t\t\tdur++;\n\t\t\t}\n\t\t}\n\t\tInteger[] outMidiNums= new Integer[0];\n\t\toutMidiNums = newMidiNums.toArray(outMidiNums);\n\t\tLong[] outTicksPer = new Long[0];\n\t\toutTicksPer = ticksPerMidiNum.toArray(outTicksPer);\n\t\treturn new Pair(outMidiNums,outTicksPer);\n\t}\n"} {"input": " public String getPostHeadContribution(Map ctx) {\n String version = getVersionFromJarFile(\"/META-INF/maven/org.sonatype.nexus.plugins/nexus-rrb-plugin/pom.properties\");\n return \"\";\n }\n", "output": " public String getPostHeadContribution(Map ctx) {\n String version = getVersionFromJarFile(\"/META-INF/maven/org.sonatype.nexus.plugins/nexus-rrb-plugin/pom.properties\");\n return \"\";\n }\n"} {"input": " public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n Player player = null;\n if (sender instanceof Player) {\n player = (Player) sender;\n }\n if (cmd.getName().equalsIgnoreCase(\"tardistravel\")) {\n if (player == null) {\n sender.sendMessage(plugin.pluginName + ChatColor.RED + \" This command can only be run by a player\");\n return true;\n }\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (args.length < 1) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n QueryFactory qf = new QueryFactory(plugin);\n TARDISTimeTravel tt = new TARDISTimeTravel(plugin);\n HashMap where = new HashMap();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS before using this command!\");\n return true;\n }\n int id = rs.getTardis_id();\n if (!rs.isHandbrake_on()) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"You cannot set a destination while the TARDIS is travelling!\");\n return true;\n }\n HashMap wheret = new HashMap();\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not inside the TARDIS. You need to be to run this command!\");\n return true;\n }\n int tardis_id = rst.getTardis_id();\n if (tardis_id != id) {\n sender.sendMessage(plugin.pluginName + \"You can only run this command if you are the Timelord of \" + ChatColor.LIGHT_PURPLE + \"this\" + ChatColor.RESET + \" TARDIS!\");\n return true;\n }\n int level = rs.getArtron_level();\n int travel = plugin.getArtronConfig().getInt(\"travel\");\n if (level < travel) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to make this trip!\");\n return true;\n }\n TARDISConstants.COMPASS d = rs.getDirection();\n String home = rs.getHome();\n String back = rs.getFast_return();\n String current = rs.getCurrent();\n HashMap tid = new HashMap();\n HashMap set = new HashMap();\n tid.put(\"tardis_id\", id);\n if (player.hasPermission(\"tardis.exile\") && plugin.getConfig().getBoolean(\"exile\")) {\n String permArea = plugin.ta.getExileArea(player);\n player.sendMessage(plugin.pluginName + ChatColor.RED + \" Notice:\" + ChatColor.RESET + \" Your travel has been restricted to the [\" + permArea + \"] area!\");\n Location l = plugin.ta.getNextSpot(permArea);\n if (l == null) {\n player.sendMessage(plugin.pluginName + \"All available parking spots are taken in this area!\");\n return true;\n }\n String save_loc = l.getWorld().getName() + \":\" + l.getBlockX() + \":\" + l.getBlockY() + \":\" + l.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n player.sendMessage(plugin.pluginName + \"Your TARDIS was approved for parking in [\" + permArea + \"]!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n if (args.length == 1) {\n if (args[0].equalsIgnoreCase(\"home\") || args[0].equalsIgnoreCase(\"back\")) {\n String which;\n if (args[0].equalsIgnoreCase(\"home\")) {\n set.put(\"save\", home);\n which = \"Home\";\n } else {\n set.put(\"save\", back);\n which = \"Fast Return\";\n }\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + which + \" location loaded succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n if (player.hasPermission(\"tardis.timetravel.player\")) {\n TARDISRescue to_player = new TARDISRescue(plugin);\n return to_player.rescue(player, args[0], id, tt, d, false);\n } else {\n player.sendMessage(plugin.pluginName + \"You do not have permission to time travel to a player!\");\n return true;\n }\n }\n }\n if (args.length == 2 && args[0].equalsIgnoreCase(\"biome\")) {\n if (!player.hasPermission(\"tardis.timetravel.biome\")) {\n player.sendMessage(plugin.pluginName + \"You do not have permission to time travel to a biome!\");\n return true;\n }\n String upper = args[1].toUpperCase(Locale.ENGLISH);\n if (upper.equals(\"LIST\")) {\n StringBuilder buf = new StringBuilder();\n for (String bi : BIOME_SUBS) {\n buf.append(bi).append(\", \");\n }\n String b = buf.toString().substring(0, buf.length() - 2);\n sender.sendMessage(plugin.pluginName + \"Biomes: \" + b);\n return true;\n } else {\n try {\n Biome biome = Biome.valueOf(upper);\n sender.sendMessage(plugin.pluginName + \"Searching for biome, this may take some time!\");\n String[] cw = current.split(\":\");\n Location nsob = searchBiome(player, biome, cw[0]);\n if (nsob == null) {\n sender.sendMessage(plugin.pluginName + \"Could not find biome!\");\n return true;\n } else {\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, nsob, true)) {\n return true;\n }\n World bw = nsob.getWorld();\n bw.getChunkAt(nsob).load();\n bw.getChunkAt(nsob).load(true);\n while (!bw.getChunkAt(nsob).isLoaded()) {\n bw.getChunkAt(nsob).load();\n }\n int[] start_loc = tt.getStartLocation(nsob, d);\n int tmp_y = nsob.getBlockY();\n for (int up = 0; up < 10; up++) {\n int count = tt.safeLocation(start_loc[0], tmp_y + up, start_loc[2], start_loc[1], start_loc[3], nsob.getWorld(), d);\n if (count == 0) {\n nsob.setY(tmp_y + up);\n break;\n }\n }\n String save_loc = nsob.getWorld().getName() + \":\" + nsob.getBlockX() + \":\" + nsob.getBlockY() + \":\" + nsob.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The biome was set succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n }\n } catch (IllegalArgumentException iae) {\n sender.sendMessage(plugin.pluginName + \"Biome type not valid!\");\n return true;\n }\n return true;\n }\n }\n if (args.length == 2 && args[0].equalsIgnoreCase(\"dest\")) {\n HashMap whered = new HashMap();\n whered.put(\"dest_name\", args[1]);\n whered.put(\"tardis_id\", id);\n ResultSetDestinations rsd = new ResultSetDestinations(plugin, whered, false);\n if (!rsd.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"Could not find a destination with that name! try using \" + ChatColor.GREEN + \"/TARDIS list saves\" + ChatColor.RESET + \" first.\");\n return true;\n }\n String save_loc = rsd.getWorld() + \":\" + rsd.getX() + \":\" + rsd.getY() + \":\" + rsd.getZ();\n World w = plugin.getServer().getWorld(rsd.getWorld());\n if (w != null) {\n Location save_dest = new Location(w, rsd.getX(), rsd.getY(), rsd.getZ());\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, save_dest, true)) {\n return true;\n }\n if (!plugin.ta.areaCheckInExisting(save_dest)) {\n HashMap wheres = new HashMap();\n wheres.put(\"save\", save_loc);\n ResultSetTardis rsz = new ResultSetTardis(plugin, wheres, \"\", true);\n if (rsz.resultSet()) {\n ArrayList> data = rsz.getData();\n if (data.size() > 0) {\n sender.sendMessage(plugin.pluginName + \"A TARDIS already occupies this parking spot! Try using the \" + ChatColor.AQUA + \"/tardistravel area [name]\" + ChatColor.RESET + \" command instead.\");\n return true;\n }\n }\n }\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The specified location was set succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + \"Could not get the world for this save!\");\n return true;\n }\n }\n if (args.length == 2 && args[0].equalsIgnoreCase(\"area\")) {\n HashMap wherea = new HashMap();\n wherea.put(\"area_name\", args[1]);\n ResultSetAreas rsa = new ResultSetAreas(plugin, wherea, false);\n if (!rsa.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"Could not find an area with that name! try using \" + ChatColor.GREEN + \"/tardis list areas\" + ChatColor.RESET + \" first.\");\n return true;\n }\n if (!player.hasPermission(\"tardis.area.\" + args[1]) || !player.isPermissionSet(\"tardis.area.\" + args[1])) {\n sender.sendMessage(plugin.pluginName + \"You do not have permission [tardis.area.\" + args[1] + \"] to send the TARDIS to this location!\");\n return true;\n }\n Location l = plugin.ta.getNextSpot(rsa.getArea_name());\n if (l == null) {\n sender.sendMessage(plugin.pluginName + \"All available parking spots are taken in this area!\");\n return true;\n }\n String save_loc = l.getWorld().getName() + \":\" + l.getBlockX() + \":\" + l.getBlockY() + \":\" + l.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"Your TARDIS was approved for parking in [\" + args[1] + \"]!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n }\n if (args.length > 2 && args.length < 4) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments for co-ordinates travel!\");\n return false;\n }\n if (args.length >= 4 && player.hasPermission(\"tardis.timetravel.location\")) {\n String w_str = args[0];\n if (w_str.contains(\"'\")) {\n w_str = getQuotedString(args);\n }\n int x, y, z;\n World w = plugin.getServer().getWorld(w_str);\n if (w == null) {\n sender.sendMessage(plugin.pluginName + \"Cannot find the specified world! Make sure you typed it correctly.\");\n return true;\n }\n if (!plugin.getConfig().getBoolean(\"worlds.\" + w.getName())) {\n sender.sendMessage(plugin.pluginName + \"The server does not allow time travel to this world!\");\n return true;\n }\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && args[0].equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server does not allow time travel to this world!\");\n return true;\n }\n x = plugin.utils.parseNum(args[args.length - 3]);\n y = plugin.utils.parseNum(args[args.length - 2]);\n z = plugin.utils.parseNum(args[args.length - 1]);\n Block block = w.getBlockAt(x, y, z);\n Location location = block.getLocation();\n if (!plugin.ta.areaCheckInExisting(location)) {\n sender.sendMessage(plugin.pluginName + \"The location is in a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, location, true)) {\n return true;\n }\n int[] start_loc = tt.getStartLocation(location, d);\n int count = tt.safeLocation(start_loc[0], location.getBlockY(), start_loc[2], start_loc[1], start_loc[3], w, d);\n if (count > 0) {\n sender.sendMessage(plugin.pluginName + \"The specified location would not be safe! Please try another.\");\n return true;\n } else {\n String save_loc = location.getWorld().getName() + \":\" + location.getBlockX() + \":\" + location.getBlockY() + \":\" + location.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The specified location was saved succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + \"You do not have permission to use co-ordinates time travel!\");\n return true;\n }\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n return false;\n }\n", "output": " public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n Player player = null;\n if (sender instanceof Player) {\n player = (Player) sender;\n }\n if (cmd.getName().equalsIgnoreCase(\"tardistravel\")) {\n if (player == null) {\n sender.sendMessage(plugin.pluginName + ChatColor.RED + \" This command can only be run by a player\");\n return true;\n }\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (args.length < 1) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n QueryFactory qf = new QueryFactory(plugin);\n TARDISTimeTravel tt = new TARDISTimeTravel(plugin);\n HashMap where = new HashMap();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS before using this command!\");\n return true;\n }\n int id = rs.getTardis_id();\n if (!rs.isHandbrake_on()) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"You cannot set a destination while the TARDIS is travelling!\");\n return true;\n }\n HashMap wheret = new HashMap();\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not inside the TARDIS. You need to be to run this command!\");\n return true;\n }\n int tardis_id = rst.getTardis_id();\n if (tardis_id != id) {\n sender.sendMessage(plugin.pluginName + \"You can only run this command if you are the Timelord of \" + ChatColor.LIGHT_PURPLE + \"this\" + ChatColor.RESET + \" TARDIS!\");\n return true;\n }\n int level = rs.getArtron_level();\n int travel = plugin.getArtronConfig().getInt(\"travel\");\n if (level < travel) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to make this trip!\");\n return true;\n }\n TARDISConstants.COMPASS d = rs.getDirection();\n String home = rs.getHome();\n String back = rs.getFast_return();\n String current = rs.getCurrent();\n HashMap tid = new HashMap();\n HashMap set = new HashMap();\n tid.put(\"tardis_id\", id);\n if (player.hasPermission(\"tardis.exile\") && plugin.getConfig().getBoolean(\"exile\")) {\n String permArea = plugin.ta.getExileArea(player);\n player.sendMessage(plugin.pluginName + ChatColor.RED + \" Notice:\" + ChatColor.RESET + \" Your travel has been restricted to the [\" + permArea + \"] area!\");\n Location l = plugin.ta.getNextSpot(permArea);\n if (l == null) {\n player.sendMessage(plugin.pluginName + \"All available parking spots are taken in this area!\");\n return true;\n }\n String save_loc = l.getWorld().getName() + \":\" + l.getBlockX() + \":\" + l.getBlockY() + \":\" + l.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n player.sendMessage(plugin.pluginName + \"Your TARDIS was approved for parking in [\" + permArea + \"]!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n if (args.length == 1) {\n if (args[0].equalsIgnoreCase(\"home\") || args[0].equalsIgnoreCase(\"back\")) {\n String which;\n if (args[0].equalsIgnoreCase(\"home\")) {\n set.put(\"save\", home);\n which = \"Home\";\n } else {\n set.put(\"save\", back);\n which = \"Fast Return\";\n }\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + which + \" location loaded succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n if (player.hasPermission(\"tardis.timetravel.player\")) {\n if (player.getName().equalsIgnoreCase(args[0])) {\n player.sendMessage(plugin.pluginName + \"You cannot travel to yourself!\");\n return true;\n }\n TARDISRescue to_player = new TARDISRescue(plugin);\n return to_player.rescue(player, args[0], id, tt, d, false);\n } else {\n player.sendMessage(plugin.pluginName + \"You do not have permission to time travel to a player!\");\n return true;\n }\n }\n }\n if (args.length == 2 && args[0].equalsIgnoreCase(\"biome\")) {\n if (!player.hasPermission(\"tardis.timetravel.biome\")) {\n player.sendMessage(plugin.pluginName + \"You do not have permission to time travel to a biome!\");\n return true;\n }\n String upper = args[1].toUpperCase(Locale.ENGLISH);\n if (upper.equals(\"LIST\")) {\n StringBuilder buf = new StringBuilder();\n for (String bi : BIOME_SUBS) {\n buf.append(bi).append(\", \");\n }\n String b = buf.toString().substring(0, buf.length() - 2);\n sender.sendMessage(plugin.pluginName + \"Biomes: \" + b);\n return true;\n } else {\n try {\n Biome biome = Biome.valueOf(upper);\n sender.sendMessage(plugin.pluginName + \"Searching for biome, this may take some time!\");\n String[] cw = current.split(\":\");\n Location nsob = searchBiome(player, biome, cw[0]);\n if (nsob == null) {\n sender.sendMessage(plugin.pluginName + \"Could not find biome!\");\n return true;\n } else {\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, nsob, true)) {\n return true;\n }\n World bw = nsob.getWorld();\n bw.getChunkAt(nsob).load();\n bw.getChunkAt(nsob).load(true);\n while (!bw.getChunkAt(nsob).isLoaded()) {\n bw.getChunkAt(nsob).load();\n }\n int[] start_loc = tt.getStartLocation(nsob, d);\n int tmp_y = nsob.getBlockY();\n for (int up = 0; up < 10; up++) {\n int count = tt.safeLocation(start_loc[0], tmp_y + up, start_loc[2], start_loc[1], start_loc[3], nsob.getWorld(), d);\n if (count == 0) {\n nsob.setY(tmp_y + up);\n break;\n }\n }\n String save_loc = nsob.getWorld().getName() + \":\" + nsob.getBlockX() + \":\" + nsob.getBlockY() + \":\" + nsob.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The biome was set succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n }\n } catch (IllegalArgumentException iae) {\n sender.sendMessage(plugin.pluginName + \"Biome type not valid!\");\n return true;\n }\n return true;\n }\n }\n if (args.length == 2 && args[0].equalsIgnoreCase(\"dest\")) {\n HashMap whered = new HashMap();\n whered.put(\"dest_name\", args[1]);\n whered.put(\"tardis_id\", id);\n ResultSetDestinations rsd = new ResultSetDestinations(plugin, whered, false);\n if (!rsd.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"Could not find a destination with that name! try using \" + ChatColor.GREEN + \"/TARDIS list saves\" + ChatColor.RESET + \" first.\");\n return true;\n }\n String save_loc = rsd.getWorld() + \":\" + rsd.getX() + \":\" + rsd.getY() + \":\" + rsd.getZ();\n World w = plugin.getServer().getWorld(rsd.getWorld());\n if (w != null) {\n Location save_dest = new Location(w, rsd.getX(), rsd.getY(), rsd.getZ());\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, save_dest, true)) {\n return true;\n }\n if (!plugin.ta.areaCheckInExisting(save_dest)) {\n HashMap wheres = new HashMap();\n wheres.put(\"save\", save_loc);\n ResultSetTardis rsz = new ResultSetTardis(plugin, wheres, \"\", true);\n if (rsz.resultSet()) {\n ArrayList> data = rsz.getData();\n if (data.size() > 0) {\n sender.sendMessage(plugin.pluginName + \"A TARDIS already occupies this parking spot! Try using the \" + ChatColor.AQUA + \"/tardistravel area [name]\" + ChatColor.RESET + \" command instead.\");\n return true;\n }\n }\n }\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The specified location was set succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + \"Could not get the world for this save!\");\n return true;\n }\n }\n if (args.length == 2 && args[0].equalsIgnoreCase(\"area\")) {\n HashMap wherea = new HashMap();\n wherea.put(\"area_name\", args[1]);\n ResultSetAreas rsa = new ResultSetAreas(plugin, wherea, false);\n if (!rsa.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"Could not find an area with that name! try using \" + ChatColor.GREEN + \"/tardis list areas\" + ChatColor.RESET + \" first.\");\n return true;\n }\n if (!player.hasPermission(\"tardis.area.\" + args[1]) || !player.isPermissionSet(\"tardis.area.\" + args[1])) {\n sender.sendMessage(plugin.pluginName + \"You do not have permission [tardis.area.\" + args[1] + \"] to send the TARDIS to this location!\");\n return true;\n }\n Location l = plugin.ta.getNextSpot(rsa.getArea_name());\n if (l == null) {\n sender.sendMessage(plugin.pluginName + \"All available parking spots are taken in this area!\");\n return true;\n }\n String save_loc = l.getWorld().getName() + \":\" + l.getBlockX() + \":\" + l.getBlockY() + \":\" + l.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"Your TARDIS was approved for parking in [\" + args[1] + \"]!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n }\n if (args.length > 2 && args.length < 4) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments for co-ordinates travel!\");\n return false;\n }\n if (args.length >= 4 && player.hasPermission(\"tardis.timetravel.location\")) {\n String w_str = args[0];\n if (w_str.contains(\"'\")) {\n w_str = getQuotedString(args);\n }\n int x, y, z;\n World w = plugin.getServer().getWorld(w_str);\n if (w == null) {\n sender.sendMessage(plugin.pluginName + \"Cannot find the specified world! Make sure you typed it correctly.\");\n return true;\n }\n if (!plugin.getConfig().getBoolean(\"worlds.\" + w.getName())) {\n sender.sendMessage(plugin.pluginName + \"The server does not allow time travel to this world!\");\n return true;\n }\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && args[0].equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server does not allow time travel to this world!\");\n return true;\n }\n x = plugin.utils.parseNum(args[args.length - 3]);\n y = plugin.utils.parseNum(args[args.length - 2]);\n z = plugin.utils.parseNum(args[args.length - 1]);\n Block block = w.getBlockAt(x, y, z);\n Location location = block.getLocation();\n if (!plugin.ta.areaCheckInExisting(location)) {\n sender.sendMessage(plugin.pluginName + \"The location is in a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, location, true)) {\n return true;\n }\n int[] start_loc = tt.getStartLocation(location, d);\n int count = tt.safeLocation(start_loc[0], location.getBlockY(), start_loc[2], start_loc[1], start_loc[3], w, d);\n if (count > 0) {\n sender.sendMessage(plugin.pluginName + \"The specified location would not be safe! Please try another.\");\n return true;\n } else {\n String save_loc = location.getWorld().getName() + \":\" + location.getBlockX() + \":\" + location.getBlockY() + \":\" + location.getBlockZ();\n set.put(\"save\", save_loc);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The specified location was saved succesfully. Please release the handbrake!\");\n plugin.tardisHasDestination.put(id, travel);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + \"You do not have permission to use co-ordinates time travel!\");\n return true;\n }\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n return false;\n }\n"} {"input": " public String getLink(Resource resource, boolean absolute)\n throws FilesException\n {\n HttpContext httpContext = HttpContext.getHttpContext(context);\n if(!(resource instanceof FileResource))\n {\n throw new FilesException(\"Resource is not the instance of cms.files.file class\");\n }\n FileResource file = (FileResource)resource;\n RootDirectoryResource rootDirectory = null;\n for(Resource parent = file.getParent(); parent != null; parent = parent.getParent())\n {\n if(parent instanceof RootDirectoryResource)\n {\n rootDirectory = ((RootDirectoryResource)parent);\n break;\n }\n }\n if(rootDirectory.getExternal())\n {\n String path = \"\";\n for(Resource parent = file; parent != null; parent = parent.getParent())\n {\n if(parent instanceof RootDirectoryResource)\n {\n break;\n }\n else\n {\n try\n {\n path = \"/\"+URLEncoder.encode(parent.getName(), \"UTF-8\")+path;\n }\n catch(UnsupportedEncodingException e)\n {\n throw new FilesException(\"really should not happen\", e);\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n if(absolute)\n {\n if(!httpContext.getRequest().isSecure())\n {\n sb.append(\"http://\");\n sb.append(httpContext.getRequest().getServerName());\n if(httpContext.getRequest().getServerPort() != 80)\n {\n sb.append(\":\");\n sb.append(httpContext.getRequest().getServerPort());\n } \n }\n else\n {\n sb.append(\"https://\");\n sb.append(httpContext.getRequest().getServerName());\n if(httpContext.getRequest().getServerPort() != 443)\n {\n sb.append(\":\");\n sb.append(httpContext.getRequest().getServerPort());\n } \n }\n }\n sb.append(httpContext.getRequest().getContextPath());\n sb.append(\"/files/\");\n sb.append(rootDirectory.getParent().getParent().getName());\n sb.append(\"/\");\n sb.append(rootDirectory.getName());\n sb.append(path);\n return sb.toString();\n }\n else\n {\n TemplatingContext tContext = (TemplatingContext)\n context.getAttribute(TemplatingContext.class);\n LinkTool link = (LinkTool)tContext.get(\"link\");\n if(absolute)\n {\n link = link.absolute();\n }\n link = link.view(\"files.Download\").pathInfoSuffix(file.getName()).set(\n \"file_id\", file.getIdString());\n if(absolute)\n {\n link = link.absolute();\n }\n return link.toString();\n }\n }\n", "output": " public String getLink(Resource resource, boolean absolute)\n throws FilesException\n {\n HttpContext httpContext = HttpContext.getHttpContext(context);\n if(!(resource instanceof FileResource))\n {\n throw new FilesException(\"Resource is not the instance of cms.files.file class\");\n }\n FileResource file = (FileResource)resource;\n RootDirectoryResource rootDirectory = null;\n for(Resource parent = file.getParent(); parent != null; parent = parent.getParent())\n {\n if(parent instanceof RootDirectoryResource)\n {\n rootDirectory = ((RootDirectoryResource)parent);\n break;\n }\n }\n if(rootDirectory.getExternal())\n {\n String path = \"\";\n for(Resource parent = file; parent != null; parent = parent.getParent())\n {\n if(parent instanceof RootDirectoryResource)\n {\n break;\n }\n else\n {\n try\n {\n path = \"/\"+URLEncoder.encode(parent.getName(), \"UTF-8\")+path;\n path = path.replace(\"+\", \"%20\");\n }\n catch(UnsupportedEncodingException e)\n {\n throw new FilesException(\"really should not happen\", e);\n }\n }\n }\n StringBuilder sb = new StringBuilder();\n if(absolute)\n {\n if(!httpContext.getRequest().isSecure())\n {\n sb.append(\"http://\");\n sb.append(httpContext.getRequest().getServerName());\n if(httpContext.getRequest().getServerPort() != 80)\n {\n sb.append(\":\");\n sb.append(httpContext.getRequest().getServerPort());\n } \n }\n else\n {\n sb.append(\"https://\");\n sb.append(httpContext.getRequest().getServerName());\n if(httpContext.getRequest().getServerPort() != 443)\n {\n sb.append(\":\");\n sb.append(httpContext.getRequest().getServerPort());\n } \n }\n }\n sb.append(httpContext.getRequest().getContextPath());\n sb.append(\"/files/\");\n sb.append(rootDirectory.getParent().getParent().getName());\n sb.append(\"/\");\n sb.append(rootDirectory.getName());\n sb.append(path);\n return sb.toString();\n }\n else\n {\n TemplatingContext tContext = (TemplatingContext)\n context.getAttribute(TemplatingContext.class);\n LinkTool link = (LinkTool)tContext.get(\"link\");\n if(absolute)\n {\n link = link.absolute();\n }\n link = link.view(\"files.Download\").pathInfoSuffix(file.getName()).set(\n \"file_id\", file.getIdString());\n if(absolute)\n {\n link = link.absolute();\n }\n return link.toString();\n }\n }\n"} {"input": " public void marshal( AssemblyInfo assemblyInfo, MavenProject mavenProject, OutputStream outputStream )\n throws AssemblyInfoException, IOException\n {\n String src = mavenProject.getBuild().getDirectory() + \"/build-sources\";\n StringBuffer sb = new StringBuffer();\n sb.append( \"using System.Reflection;\\r\\n\" )\n .append( \"using System.Runtime.CompilerServices;\\r\\n\" )\n .append( createEntry( \"Description\", assemblyInfo.getDescription() ) )\n .append( createEntry( \"Title\", assemblyInfo.getTitle() ) )\n .append( createEntry( \"Company\", assemblyInfo.getCompany() ) )\n .append( createEntry( \"Product\", assemblyInfo.getProduct() ) )\n .append( createEntry( \"Copyright\", assemblyInfo.getCopyright().replace( \"\\\"\", \"\\\\\" ) ) )\n .append( createEntry( \"Trademark\", assemblyInfo.getTrademark() ) )\n .append( createEntry( \"Culture\", assemblyInfo.getCulture() ) )\n .append( createEntry( \"Version\", assemblyInfo.getVersion() ) )\n .append( createEntry( \"InformationalVersion\", assemblyInfo.getInformationalVersion() ) )\n .append( createEntry( \"Configuration\", assemblyInfo.getConfiguration() ) );\n if ( assemblyInfo.getKeyName() != null )\n {\n sb.append( createEntry( \"KeyName\", assemblyInfo.getKeyName() ) );\n }\n if ( assemblyInfo.getKeyFile() != null )\n {\n sb.append( createEntry( \"KeyFile\", assemblyInfo.getKeyFile().getAbsolutePath().replace( \"\\\\\", \"\\\\\\\\\" ) ) );\n }\n boolean wroteCustomStringAttribute = false;\n for(Entry e: assemblyInfo.getCustomStringAttributes().entrySet()) {\n if(StringUtils.isEmpty(e.getValue()))\n continue;\n sb.append(createCustomStringEntry(e.getKey(), e.getValue()));\n wroteCustomStringAttribute = true;\n }\n if(wroteCustomStringAttribute) {\n final String customClass = \"\\n\" + \n \"[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)]\\n\" + \n \"class CustomStringAttribute : System.Attribute {\\n\" + \n \" public CustomStringAttribute(string name, string value) {\\n\" + \n \" }\\n\" + \n \"}\\n\"; \n sb.append(customClass);\n }\n FileOutputStream man = null;\n try\n {\n String groupIdAsDir = mavenProject.getGroupId().replace( \".\", File.separator );\n File file = new File( src + \"/META-INF/\" + groupIdAsDir );\n file.mkdirs();\n man = new FileOutputStream(\n src + \"/META-INF/\" + groupIdAsDir + File.separator + \"AssemblyInfo.\" + plugin.getExtension() );\n man.write( sb.toString().getBytes() );\n }\n catch ( IOException e )\n {\n throw new AssemblyInfoException( \"NPANDAY-022-000: Failed to generate AssemblyInfo\" );\n }\n finally\n {\n if ( man != null )\n {\n man.close();\n }\n }\n }\n", "output": " public void marshal( AssemblyInfo assemblyInfo, MavenProject mavenProject, OutputStream outputStream )\n throws AssemblyInfoException, IOException\n {\n String src = mavenProject.getBuild().getDirectory() + \"/build-sources\";\n StringBuffer sb = new StringBuffer();\n sb.append( \"using System.Reflection;\\r\\n\" )\n .append( \"using System.Runtime.CompilerServices;\\r\\n\" )\n .append( createEntry( \"Description\", assemblyInfo.getDescription() ) )\n .append( createEntry( \"Title\", assemblyInfo.getTitle() ) )\n .append( createEntry( \"Company\", assemblyInfo.getCompany() ) )\n .append( createEntry( \"Product\", assemblyInfo.getProduct() ) )\n .append( createEntry( \"Copyright\", assemblyInfo.getCopyright().replace( \"\\\"\", \"\\\\\" ) ) )\n .append( createEntry( \"Trademark\", assemblyInfo.getTrademark() ) )\n .append( createEntry( \"Culture\", assemblyInfo.getCulture() ) )\n .append( createEntry( \"Version\", assemblyInfo.getVersion() ) )\n .append( createEntry( \"InformationalVersion\", assemblyInfo.getInformationalVersion() ) )\n .append( createEntry( \"Configuration\", assemblyInfo.getConfiguration() ) );\n if ( assemblyInfo.getKeyName() != null )\n {\n sb.append( createEntry( \"KeyName\", assemblyInfo.getKeyName() ) );\n }\n if ( assemblyInfo.getKeyFile() != null )\n {\n sb.append( createEntry( \"KeyFile\", assemblyInfo.getKeyFile().getAbsolutePath().replace( \"\\\\\", \"\\\\\\\\\" ) ) );\n }\n boolean wroteCustomStringAttribute = false;\n for(Entry e: assemblyInfo.getCustomStringAttributes().entrySet()) {\n if(StringUtils.isEmpty(e.getValue()))\n continue;\n sb.append(createCustomStringEntry(e.getKey(), e.getValue()));\n wroteCustomStringAttribute = true;\n }\n if(wroteCustomStringAttribute) {\n final String customClass = \"\\n\" + \n \"[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)]\\n\" + \n \"class CustomStringAttribute : System.Attribute {\\n\" + \n \" public CustomStringAttribute(string name, string value) {\\n\" + \n \" }\\n\" + \n \"}\\n\"; \n sb.append(customClass);\n }\n FileOutputStream man = null;\n try\n {\n String groupIdAsDir = mavenProject.getGroupId().replace( \".\", File.separator );\n File file = new File( src + \"/META-INF/\" + groupIdAsDir );\n file.mkdirs();\n man = new FileOutputStream(\n src + \"/META-INF/\" + groupIdAsDir + File.separator + \"AssemblyInfo.\" + plugin.getExtension() );\n man.write( sb.toString().getBytes() );\n }\n catch ( IOException e )\n {\n throw new AssemblyInfoException( \"NPANDAY-022-000: Failed to generate AssemblyInfo\", e );\n }\n finally\n {\n if ( man != null )\n {\n man.close();\n }\n }\n }\n"} {"input": " public void run() {\n try {\n while (!Thread.interrupted()) {\n try {\n if (serversocket == null || serversocket.isClosed()) {\n if (LOG.isInfoEnabled()) {\n LOG.info(\"Listening on port \" + port);\n }\n serversocket = new ServerSocket(port);\n serversocket.setReuseAddress(true);\n }\n LOG.debug(\"Waiting for incoming HTTP connection\");\n Socket socket = this.serversocket.accept();\n if (LOG.isDebugEnabled()) {\n LOG.debug(\"Incoming HTTP connection from \" +\n socket.getRemoteSocketAddress());\n }\n AxisHttpConnection conn = new AxisHttpConnectionImpl(socket, this.params);\n this.connmanager.process(conn);\n } catch (Throwable ex) {\n if (Thread.interrupted()) {\n break;\n }\n if (!failureHandler.failed(this, ex)) {\n break;\n }\n }\n }\n } finally {\n destroy();\n }\n }\n", "output": " public void run() {\n try {\n while (!Thread.interrupted()) {\n try {\n if (serversocket == null || serversocket.isClosed()) {\n if (LOG.isInfoEnabled()) {\n LOG.info(\"Listening on port \" + port);\n }\n serversocket = new ServerSocket(port);\n serversocket.setReuseAddress(true);\n }\n LOG.debug(\"Waiting for incoming HTTP connection\");\n Socket socket = this.serversocket.accept();\n if (LOG.isDebugEnabled()) {\n LOG.debug(\"Incoming HTTP connection from \" +\n socket.getRemoteSocketAddress());\n }\n AxisHttpConnection conn = new AxisHttpConnectionImpl(socket, this.params);\n this.connmanager.process(conn);\n } catch(java.io.InterruptedIOException ie) {\n break; \n } catch (Throwable ex) {\n if (Thread.interrupted()) {\n break;\n }\n if (!failureHandler.failed(this, ex)) {\n break;\n }\n }\n }\n } finally {\n destroy();\n }\n }\n"} {"input": "\tpublic IntermediateDefinition(ListDefinition parentListDefinition,\n\t\t\tListDefinition nestedListDefinition) {\n\t\tsetParentEditorDefinition(parentListDefinition);\n\t\tthis.nestedListDefinition = nestedListDefinition;\n\t\tnestedListDefinition.setParentEditorDefinition(this);\n\t}\n", "output": "\tpublic IntermediateDefinition(ListDefinition parentListDefinition,\n\t\t\tListDefinition nestedListDefinition) {\n\t\tsetParentEditorDefinition(parentListDefinition);\n\t\tthis.nestedListDefinition = nestedListDefinition;\n\t\tnestedListDefinition.setParentEditorDefinition(this);\n\t\tsetEditorRepository(parentListDefinition.getEditorRepository());\n\t}\n"} {"input": " public String extractTweet(String html) {\n Preconditions.checkNotNull(html);\n Matcher matcher = TWEET_PATTERN.matcher(html);\n if (!matcher.find()) {\n return null;\n }\n String tweet = matcher.group(1);\n matcher = URL_PATTERN.matcher(tweet);\n StringBuffer rawsb = new StringBuffer();\n while (matcher.find()) {\n HashMap urls = new HashMap();\n urls.put(matcher.group(1), matcher.group(2));\n urls.put(matcher.group(3), matcher.group(4));\n String deu = urls.containsKey(\"data-expanded-url\") ? urls.get(\"data-expanded-url\") : \"\";\n String href = urls.containsKey(\"href\") ? urls.get(\"href\") : \"\";\n if (!deu.equals(\"\"))\n matcher.appendReplacement(rawsb, deu);\n else if (!href.equals(\"\"))\n matcher.appendReplacement(rawsb, href);\n else\n matcher.appendReplacement(rawsb, \"$0\"); \n }\n matcher.appendTail(rawsb);\n tweet = rawsb.toString();\n tweet = tweet.replaceAll(\"<(.|\\n)*?>\", \"\").replaceAll(\"[\\n\\r]\", \"\").replaceAll(\"[\\t]\", \" \").trim();\n tweet = StringEscapeUtils.unescapeHtml(tweet);\n return tweet;\n }\n", "output": " public String extractTweet(String html) {\n Preconditions.checkNotNull(html);\n Matcher matcher = TWEET_PATTERN.matcher(html);\n if (!matcher.find()) {\n return null;\n }\n String tweet = matcher.group(1);\n matcher = URL_PATTERN.matcher(tweet);\n StringBuffer rawsb = new StringBuffer();\n while (matcher.find()) {\n HashMap urls = new HashMap();\n urls.put(matcher.group(1), matcher.group(2));\n urls.put(matcher.group(3), matcher.group(4));\n String deu = urls.containsKey(\"data-expanded-url\") ? urls.get(\"data-expanded-url\") : \"\";\n String href = urls.containsKey(\"href\") ? urls.get(\"href\") : \"\";\n if (!deu.equals(\"\"))\n matcher.appendReplacement(rawsb, deu.replaceAll(\"\\\\$\", \"\\\\\\\\\\\\$\"));\n else if (!href.equals(\"\"))\n matcher.appendReplacement(rawsb, href.replaceAll(\"\\\\$\", \"\\\\\\\\\\\\$\"));\n else\n matcher.appendReplacement(rawsb, \"$0\"); \n }\n matcher.appendTail(rawsb);\n tweet = rawsb.toString();\n tweet = tweet.replaceAll(\"<(.|\\n)*?>\", \"\").replaceAll(\"[\\n\\r]\", \"\").replaceAll(\"[\\t]\", \" \").trim();\n tweet = StringEscapeUtils.unescapeHtml(tweet);\n return tweet;\n }\n"} {"input": "\tprotected void doGet(HttpServletRequest httpRequest, HttpServletResponse response) throws IOException {\n\t\tlog.debug(\"Handling Get request: \" + httpRequest.getRequestURI());\n\t\ttry {\n\t\t\tMap params = initSession(httpRequest);\n\t\t\tif (params.get(\"service\") != null && params.get(\"service\").equals(\"wps\")) {\n\t\t\t\tString version = params.get(\"version\");\n\t\t\t\tif (version != null && !version.equals(\"1.0.0\")) {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Only WPS version 1.0.0 is supported.\",\n\t\t\t\t\t\t\tWpsErrorCode.VersionNegotiationFailed, null, null);\n\t\t\t\t}\n\t\t\t\tString request = params.get(\"request\");\n\t\t\t\tif (request == null) {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Parameter request is missing.\",\n\t\t\t\t\t\t\tWpsErrorCode.MissingParameterValue, null, \"request\");\n\t\t\t\t}\n\t\t\t\telse if (request.toLowerCase().equals(\"getcapabilities\")) {\n\t\t\t\t\tgetCapabilities(httpRequest, response);\n\t\t\t\t}\n\t\t\t\telse if (request.toLowerCase().equals(\"describeprocess\")) {\n\t\t\t\t\tdescribeProcess(response);\n\t\t\t\t}\n\t\t\t\telse if (httpRequest.getMethod().toLowerCase().equals(\"post\") && \n\t\t\t\t\t\t\trequest.toLowerCase().contains(\"execute\")) {\n\t\t\t\t\texecute(params, response, httpRequest);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Parameter request is invalid: \" + request,\n\t\t\t\t\t\t\tWpsErrorCode.InvalidParameterValue, null, \"request\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\"Parameter service is missing.\",\n\t\t\t\t\t\tWpsErrorCode.MissingParameterValue, null, \"service\");\n\t\t\t}\n\t\t} catch (WpsException e) {\n\t\t\tWpsUtil.printError(e, null, response);\n\t\t}\n\t}\n", "output": "\tprotected void doGet(HttpServletRequest httpRequest, HttpServletResponse response) throws IOException {\n\t\tlog.debug(\"Handling Get request: \" + httpRequest.getRequestURI());\n\t\ttry {\n\t\t\tMap params = initSession(httpRequest);\n\t\t\tif (params.get(\"service\") != null && params.get(\"service\").equals(\"wps\")) {\n\t\t\t\tString version = params.get(\"version\");\n\t\t\t\tif (version != null && !version.equals(\"1.0.0\")) {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Only WPS version 1.0.0 is supported.\",\n\t\t\t\t\t\t\tWpsErrorCode.VersionNegotiationFailed, null, null);\n\t\t\t\t}\n\t\t\t\tString request = params.get(\"request\");\n\t\t\t\tif (request == null) {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Parameter request is missing.\",\n\t\t\t\t\t\t\tWpsErrorCode.MissingParameterValue, null, \"request\");\n\t\t\t\t}\n\t\t\t\telse if (request.toLowerCase().equals(\"getcapabilities\")) {\n\t\t\t\t\tgetCapabilities(httpRequest, response);\n\t\t\t\t}\n\t\t\t\telse if (request.toLowerCase().equals(\"describeprocess\")) {\n\t\t\t\t\tdescribeProcess(response);\n\t\t\t\t}\n\t\t\t\telse if (request.toLowerCase().contains(\"execute\")) {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Execute operation only supported with POST method.\" + request,\n\t\t\t\t\t\t\tWpsErrorCode.InvalidParameterValue, null, \"request\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\t\"Parameter request is invalid: \" + request,\n\t\t\t\t\t\t\tWpsErrorCode.InvalidParameterValue, null, \"request\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new WpsException(\n\t\t\t\t\t\t\"Parameter service is missing.\",\n\t\t\t\t\t\tWpsErrorCode.MissingParameterValue, null, \"service\");\n\t\t\t}\n\t\t} catch (WpsException e) {\n\t\t\tWpsUtil.printError(e, null, response);\n\t\t}\n\t}\n"} {"input": " private void removeClientFromCache(ChannelPipeline pipeline) {\n final RegionClient client = pipeline.get(RegionClient.class);\n final SocketAddress remote = pipeline.getChannel().getRemoteAddress();\n if (remote == null) {\n if (client == rootregion) {\n rootregion = null;\n String hostport = null;\n synchronized(this) {\n final Iterator> it =\n ip2client.entrySet().iterator();\n while (it.hasNext()) {\n final Map.Entry e = it.next();\n if (e.getValue() == client) {\n hostport = e.getKey();\n it.remove();\n break;\n }\n }\n }\n LOG.warn(\"Couldn't connect to the -ROOT- region @ \" + hostport);\n }\n return;\n }\n pipeline = null; \n String hostport = null;\n if (remote instanceof InetSocketAddress) {\n final InetSocketAddress sock = (InetSocketAddress) remote;\n final InetAddress addr = sock.getAddress();\n if (addr == null) {\n LOG.error(\"Unresolved IP for \" + remote\n + \". This shouldn't happen.\");\n return;\n } else {\n hostport = addr.getHostAddress() + ':' + sock.getPort();\n }\n } else {\n LOG.error(\"Found a non-InetSocketAddress remote: \" + remote\n + \". This shouldn't happen.\");\n return;\n }\n RegionClient old;\n if (client != null) {\n final ArrayList regions = client2regions.remove(client);\n if (regions != null) {\n for (final RegionInfo region : regions) {\n final byte[] table = region.table();\n final byte[] stop_key = region.stopKey();\n final Map.Entry entry =\n (stop_key.length == 0\n ? regions_cache.floorEntry(createRegionSearchKey(table, stop_key))\n : regions_cache.lowerEntry(createRegionSearchKey(table, stop_key)));\n if (entry != null && entry.getValue() == region) {\n regions_cache.remove(entry.getKey());\n LOG.debug(\"Removed from regions cache: {}\", region);\n }\n final RegionClient oldclient = region2client.remove(region);\n if (client == oldclient) {\n LOG.debug(\"Association removed: {} -> {}\", region, client);\n } else if (oldclient != null) { \n LOG.warn(\"When handling disconnection of \" + client\n + \" and removing \" + region + \" from region2client\"\n + \", it was found that \" + oldclient + \" was in fact\"\n + \" serving this region\");\n }\n }\n }\n }\n synchronized (ip2client) {\n old = ip2client.remove(hostport);\n }\n LOG.debug(\"Removed from IP cache: {} -> {}\", hostport, client);\n if (old == null) {\n LOG.warn(\"When expiring \" + client + \" from the client cache (host:port=\"\n + hostport + \"), it was found that there was no entry\"\n + \" corresponding to \" + remote + \". This shouldn't happen.\");\n }\n if (client == rootregion) {\n LOG.info(\"Lost connection with the -ROOT- region\");\n rootregion = null;\n }\n }\n", "output": " private void removeClientFromCache(ChannelPipeline pipeline) {\n final RegionClient client = pipeline.get(RegionClient.class);\n final SocketAddress remote = pipeline.getChannel().getRemoteAddress();\n if (remote == null) {\n if (client == rootregion) {\n rootregion = null;\n String hostport = null;\n synchronized (ip2client) {\n final Iterator> it =\n ip2client.entrySet().iterator();\n while (it.hasNext()) {\n final Map.Entry e = it.next();\n if (e.getValue() == client) {\n hostport = e.getKey();\n it.remove();\n break;\n }\n }\n }\n LOG.warn(\"Couldn't connect to the -ROOT- region @ \" + hostport);\n }\n return;\n }\n pipeline = null; \n String hostport = null;\n if (remote instanceof InetSocketAddress) {\n final InetSocketAddress sock = (InetSocketAddress) remote;\n final InetAddress addr = sock.getAddress();\n if (addr == null) {\n LOG.error(\"Unresolved IP for \" + remote\n + \". This shouldn't happen.\");\n return;\n } else {\n hostport = addr.getHostAddress() + ':' + sock.getPort();\n }\n } else {\n LOG.error(\"Found a non-InetSocketAddress remote: \" + remote\n + \". This shouldn't happen.\");\n return;\n }\n RegionClient old;\n if (client != null) {\n final ArrayList regions = client2regions.remove(client);\n if (regions != null) {\n for (final RegionInfo region : regions) {\n final byte[] table = region.table();\n final byte[] stop_key = region.stopKey();\n final Map.Entry entry =\n (stop_key.length == 0\n ? regions_cache.floorEntry(createRegionSearchKey(table, stop_key))\n : regions_cache.lowerEntry(createRegionSearchKey(table, stop_key)));\n if (entry != null && entry.getValue() == region) {\n regions_cache.remove(entry.getKey());\n LOG.debug(\"Removed from regions cache: {}\", region);\n }\n final RegionClient oldclient = region2client.remove(region);\n if (client == oldclient) {\n LOG.debug(\"Association removed: {} -> {}\", region, client);\n } else if (oldclient != null) { \n LOG.warn(\"When handling disconnection of \" + client\n + \" and removing \" + region + \" from region2client\"\n + \", it was found that \" + oldclient + \" was in fact\"\n + \" serving this region\");\n }\n }\n }\n }\n synchronized (ip2client) {\n old = ip2client.remove(hostport);\n }\n LOG.debug(\"Removed from IP cache: {} -> {}\", hostport, client);\n if (old == null) {\n LOG.warn(\"When expiring \" + client + \" from the client cache (host:port=\"\n + hostport + \"), it was found that there was no entry\"\n + \" corresponding to \" + remote + \". This shouldn't happen.\");\n }\n if (client == rootregion) {\n LOG.info(\"Lost connection with the -ROOT- region\");\n rootregion = null;\n }\n }\n"} {"input": " public CopyOnWriteList unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {\n List items = new ArrayList();\n while (reader.hasMoreChildren()) {\n reader.moveDown();\n try {\n Object item = readItem(reader, context, items);\n items.add(item);\n } catch (CannotResolveClassException e) {\n LOGGER.log(WARNING,\"Failed to resolve class\",e);\n } catch (LinkageError e) {\n LOGGER.log(WARNING,\"Failed to resolve class\",e);\n }\n reader.moveUp();\n }\n return new CopyOnWriteList(items,true);\n }\n", "output": " public CopyOnWriteList unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {\n List items = new ArrayList();\n while (reader.hasMoreChildren()) {\n reader.moveDown();\n try {\n Object item = readItem(reader, context, items);\n items.add(item);\n } catch (CannotResolveClassException e) {\n LOGGER.log(WARNING,\"Failed to resolve class\",e);\n RobustReflectionConverter.addErrorInContext(context, e);\n } catch (LinkageError e) {\n LOGGER.log(WARNING,\"Failed to resolve class\",e);\n RobustReflectionConverter.addErrorInContext(context, e);\n }\n reader.moveUp();\n }\n return new CopyOnWriteList(items,true);\n }\n"} {"input": " private void calculateColumnEncodings() {\n assert (_bases != null);\n assert _scale != null;\n assert (_min != null);\n assert _ncolumns == _colTypes.length:\"ncols=\" + _ncolumns + \", colTypes.length=\" + _colTypes.length;\n for(int i = 0; i < _ncolumns; ++i){\n if( (_colTypes[i]==ICOL || _colTypes[i]==DCOL || _colTypes[i]==FCOL ) &&\n (double)_invalidValues[i]/_numRows > 1 ) {\n _enums[i] = null;\n _max[i] = _min[i] = 0;\n _scale[i] = 0;\n _bases[i] = 0;\n _colTypes[i] = STRINGCOL;\n continue;\n }\n if(_colTypes[i] == UCOL && _enums[i].size() == 1)\n _colTypes[i] = ECOL;\n switch(_colTypes[i]){\n case UCOL: \n _colTypes[i] = BYTE;\n break;\n case ECOL: \n if(_enums[i] == null || _enums[i].isKilled()){\n _max[i] = 0;\n _min[i] = 0;\n _colTypes[i] = STRINGCOL;\n } else {\n _max[i] = _colDomains[i].length-1;\n _min[i] = 0;\n if(_max[i] < 256)_colTypes[i] = BYTE;\n else if(_max[i] < 65536)_colTypes[i] = SHORT;\n else _colTypes[i] = INT;\n }\n break;\n case ICOL: \n if (_max[i] - _min[i] < 255) {\n _colTypes[i] = BYTE;\n _bases[i] = (int)_min[i];\n } else if ((_max[i] - _min[i]) < 65535) {\n _colTypes[i] = SHORT;\n _bases[i] = (int)_min[i];\n } else if (_max[i] - _min[i] < (1L << 32) &&\n _min[i] > Integer.MIN_VALUE && _max[i] < Integer.MAX_VALUE) {\n _colTypes[i] = INT;\n _bases[i] = (int)_min[i];\n } else\n _colTypes[i] = LONG;\n break;\n case FCOL:\n case DCOL:\n if(_scale[i] >= -4 && (_max[i] <= powers10i[powers10i.length-1]) && (_min[i] >= -powers10i[powers10i.length-1])){\n double s = pow10(-_scale[i]);\n double range = s*(_max[i]-_min[i]);\n double base = s*_min[i];\n if(range < 256){\n if(fitsIntoInt(base)) { \n _colTypes[i] = DBYTE;\n _bases[i] = (int)base;\n break;\n }\n } else if(range < 65535){\n if(fitsIntoInt(base)){\n _colTypes[i] = DSHORT;\n _bases[i] = (int)(base);\n break;\n }\n }\n }\n _scale[i] = 0;\n _bases[i] = 0;\n _colTypes[i] = (_colTypes[i] == FCOL)?FLOAT:DOUBLE;\n break;\n case TCOL: \n _scale[i] = -1;\n _bases[i] = 0;\n _colTypes[i] = LONG;\n break;\n default: throw H2O.unimpl();\n }\n }\n _invalidValues = null;\n }\n", "output": " private void calculateColumnEncodings() {\n assert (_bases != null);\n assert _scale != null;\n assert (_min != null);\n assert _ncolumns == _colTypes.length:\"ncols=\" + _ncolumns + \", colTypes.length=\" + _colTypes.length;\n for(int i = 0; i < _ncolumns; ++i){\n if( (_colTypes[i]==ICOL || _colTypes[i]==DCOL || _colTypes[i]==FCOL ) &&\n (double)_invalidValues[i]/_numRows > 1 ) {\n _enums[i] = null;\n _max[i] = _min[i] = 0;\n _scale[i] = 0;\n _bases[i] = 0;\n _colTypes[i] = STRINGCOL;\n continue;\n }\n if(_colTypes[i] == UCOL && _enums[i] != null && _enums[i].size() == 1)\n _colTypes[i] = ECOL;\n switch(_colTypes[i]){\n case UCOL: \n _colTypes[i] = BYTE;\n break;\n case ECOL: \n if(_enums[i] == null || _enums[i].isKilled()){\n _max[i] = 0;\n _min[i] = 0;\n _colTypes[i] = STRINGCOL;\n } else {\n _max[i] = _colDomains[i].length-1;\n _min[i] = 0;\n if(_max[i] < 256)_colTypes[i] = BYTE;\n else if(_max[i] < 65536)_colTypes[i] = SHORT;\n else _colTypes[i] = INT;\n }\n break;\n case ICOL: \n if (_max[i] - _min[i] < 255) {\n _colTypes[i] = BYTE;\n _bases[i] = (int)_min[i];\n } else if ((_max[i] - _min[i]) < 65535) {\n _colTypes[i] = SHORT;\n _bases[i] = (int)_min[i];\n } else if (_max[i] - _min[i] < (1L << 32) &&\n _min[i] > Integer.MIN_VALUE && _max[i] < Integer.MAX_VALUE) {\n _colTypes[i] = INT;\n _bases[i] = (int)_min[i];\n } else\n _colTypes[i] = LONG;\n break;\n case FCOL:\n case DCOL:\n if(_scale[i] >= -4 && (_max[i] <= powers10i[powers10i.length-1]) && (_min[i] >= -powers10i[powers10i.length-1])){\n double s = pow10(-_scale[i]);\n double range = s*(_max[i]-_min[i]);\n double base = s*_min[i];\n if(range < 256){\n if(fitsIntoInt(base)) { \n _colTypes[i] = DBYTE;\n _bases[i] = (int)base;\n break;\n }\n } else if(range < 65535){\n if(fitsIntoInt(base)){\n _colTypes[i] = DSHORT;\n _bases[i] = (int)(base);\n break;\n }\n }\n }\n _scale[i] = 0;\n _bases[i] = 0;\n _colTypes[i] = (_colTypes[i] == FCOL)?FLOAT:DOUBLE;\n break;\n case TCOL: \n _scale[i] = -1;\n _bases[i] = 0;\n _colTypes[i] = LONG;\n break;\n default: throw H2O.unimpl();\n }\n }\n _invalidValues = null;\n }\n"} {"input": " private void visitExpression(Node node, int contextFlags)\n {\n int type = node.getType();\n Node child = node.getFirstChild();\n int savedStackDepth = stackDepth;\n switch (type) {\n case Token.FUNCTION:\n {\n int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP);\n FunctionNode fn = scriptOrFn.getFunctionNode(fnIndex);\n if (fn.getFunctionType() != FunctionNode.FUNCTION_EXPRESSION) {\n throw Kit.codeBug();\n }\n addIndexOp(Icode_CLOSURE_EXPR, fnIndex);\n stackChange(1);\n }\n break;\n case Token.LOCAL_LOAD:\n {\n int localIndex = getLocalBlockRef(node);\n addIndexOp(Token.LOCAL_LOAD, localIndex);\n stackChange(1);\n }\n break;\n case Token.COMMA:\n {\n Node lastChild = node.getLastChild();\n while (child != lastChild) {\n visitExpression(child, 0);\n addIcode(Icode_POP);\n stackChange(-1);\n child = child.getNext();\n }\n visitExpression(child, contextFlags & ECF_TAIL);\n }\n break;\n case Token.USE_STACK:\n stackChange(1);\n break;\n case Token.REF_CALL:\n case Token.CALL:\n case Token.NEW:\n {\n if (type == Token.NEW) {\n visitExpression(child, 0);\n } else {\n generateCallFunAndThis(child);\n }\n int argCount = 0;\n while ((child = child.getNext()) != null) {\n visitExpression(child, 0);\n ++argCount;\n }\n int callType = node.getIntProp(Node.SPECIALCALL_PROP,\n Node.NON_SPECIALCALL);\n if (callType != Node.NON_SPECIALCALL) {\n addIndexOp(Icode_CALLSPECIAL, argCount);\n addUint8(callType);\n addUint8(type == Token.NEW ? 1 : 0);\n addUint16(lineNumber & 0xFFFF);\n } else {\n if (type == Token.CALL && (contextFlags & ECF_TAIL) != 0 &&\n !compilerEnv.isGenerateDebugInfo() && !itsInTryFlag)\n {\n type = Icode_TAIL_CALL;\n }\n addIndexOp(type, argCount);\n }\n if (type == Token.NEW) {\n stackChange(-argCount);\n } else {\n stackChange(-1 - argCount);\n }\n if (argCount > itsData.itsMaxCalleeArgs) {\n itsData.itsMaxCalleeArgs = argCount;\n }\n }\n break;\n case Token.AND:\n case Token.OR:\n {\n visitExpression(child, 0);\n addIcode(Icode_DUP);\n stackChange(1);\n int afterSecondJumpStart = iCodeTop;\n int jump = (type == Token.AND) ? Token.IFNE : Token.IFEQ;\n addGotoOp(jump);\n stackChange(-1);\n addIcode(Icode_POP);\n stackChange(-1);\n child = child.getNext();\n visitExpression(child, contextFlags & ECF_TAIL);\n resolveForwardGoto(afterSecondJumpStart);\n }\n break;\n case Token.HOOK:\n {\n Node ifThen = child.getNext();\n Node ifElse = ifThen.getNext();\n visitExpression(child, 0);\n int elseJumpStart = iCodeTop;\n addGotoOp(Token.IFNE);\n stackChange(-1);\n visitExpression(ifThen, contextFlags & ECF_TAIL);\n int afterElseJumpStart = iCodeTop;\n addGotoOp(Token.GOTO);\n resolveForwardGoto(elseJumpStart);\n stackDepth = savedStackDepth;\n visitExpression(ifElse, contextFlags & ECF_TAIL);\n resolveForwardGoto(afterElseJumpStart);\n }\n break;\n case Token.GETPROP:\n case Token.GETPROPNOWARN:\n visitExpression(child, 0);\n child = child.getNext();\n addStringOp(type, child.getString());\n break;\n case Token.DELPROP:\n boolean isName = child.getType() == Token.BINDNAME;\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n if (isName) {\n addIcode(Icode_DELNAME);\n } else {\n addToken(Token.DELPROP);\n }\n stackChange(-1);\n break;\n case Token.GETELEM:\n case Token.BITAND:\n case Token.BITOR:\n case Token.BITXOR:\n case Token.LSH:\n case Token.RSH:\n case Token.URSH:\n case Token.ADD:\n case Token.SUB:\n case Token.MOD:\n case Token.DIV:\n case Token.MUL:\n case Token.EQ:\n case Token.NE:\n case Token.SHEQ:\n case Token.SHNE:\n case Token.IN:\n case Token.INSTANCEOF:\n case Token.LE:\n case Token.LT:\n case Token.GE:\n case Token.GT:\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n addToken(type);\n stackChange(-1);\n break;\n case Token.POS:\n case Token.NEG:\n case Token.NOT:\n case Token.BITNOT:\n case Token.TYPEOF:\n case Token.VOID:\n visitExpression(child, 0);\n if (type == Token.VOID) {\n addIcode(Icode_POP);\n addIcode(Icode_UNDEF);\n } else {\n addToken(type);\n }\n break;\n case Token.GET_REF:\n case Token.DEL_REF:\n visitExpression(child, 0);\n addToken(type);\n break;\n case Token.SETPROP:\n case Token.SETPROP_OP:\n {\n visitExpression(child, 0);\n child = child.getNext();\n String property = child.getString();\n child = child.getNext();\n if (type == Token.SETPROP_OP) {\n addIcode(Icode_DUP);\n stackChange(1);\n addStringOp(Token.GETPROP, property);\n stackChange(-1);\n }\n visitExpression(child, 0);\n addStringOp(Token.SETPROP, property);\n stackChange(-1);\n }\n break;\n case Token.SETELEM:\n case Token.SETELEM_OP:\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n child = child.getNext();\n if (type == Token.SETELEM_OP) {\n addIcode(Icode_DUP2);\n stackChange(2);\n addToken(Token.GETELEM);\n stackChange(-1);\n stackChange(-1);\n }\n visitExpression(child, 0);\n addToken(Token.SETELEM);\n stackChange(-2);\n break;\n case Token.SET_REF:\n case Token.SET_REF_OP:\n visitExpression(child, 0);\n child = child.getNext();\n if (type == Token.SET_REF_OP) {\n addIcode(Icode_DUP);\n stackChange(1);\n addToken(Token.GET_REF);\n stackChange(-1);\n }\n visitExpression(child, 0);\n addToken(Token.SET_REF);\n stackChange(-1);\n break;\n case Token.STRICT_SETNAME:\n case Token.SETNAME:\n {\n String name = child.getString();\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n addStringOp(type, name);\n stackChange(-1);\n }\n break;\n case Token.SETCONST:\n {\n String name = child.getString();\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n addStringOp(Icode_SETCONST, name);\n stackChange(-1);\n }\n break;\n case Token.TYPEOFNAME:\n {\n int index = -1;\n if (itsInFunctionFlag && !itsData.itsNeedsActivation)\n index = scriptOrFn.getIndexForNameNode(node);\n if (index == -1) {\n addStringOp(Icode_TYPEOFNAME, node.getString());\n stackChange(1);\n } else {\n addVarOp(Token.GETVAR, index);\n stackChange(1);\n addToken(Token.TYPEOF);\n }\n }\n break;\n case Token.BINDNAME:\n case Token.NAME:\n case Token.STRING:\n addStringOp(type, node.getString());\n stackChange(1);\n break;\n case Token.INC:\n case Token.DEC:\n visitIncDec(node, child);\n break;\n case Token.NUMBER:\n {\n double num = node.getDouble();\n int inum = (int)num;\n if (inum == num) {\n if (inum == 0) {\n addIcode(Icode_ZERO);\n if (1.0 / num < 0.0) {\n addToken(Token.NEG);\n }\n } else if (inum == 1) {\n addIcode(Icode_ONE);\n } else if ((short)inum == inum) {\n addIcode(Icode_SHORTNUMBER);\n addUint16(inum & 0xFFFF);\n } else {\n addIcode(Icode_INTNUMBER);\n addInt(inum);\n }\n } else {\n int index = getDoubleIndex(num);\n addIndexOp(Token.NUMBER, index);\n }\n stackChange(1);\n }\n break;\n case Token.GETVAR:\n {\n if (itsData.itsNeedsActivation) Kit.codeBug();\n int index = scriptOrFn.getIndexForNameNode(node);\n addVarOp(Token.GETVAR, index);\n stackChange(1);\n }\n break;\n case Token.SETVAR:\n {\n if (itsData.itsNeedsActivation) Kit.codeBug();\n int index = scriptOrFn.getIndexForNameNode(child);\n child = child.getNext();\n visitExpression(child, 0);\n addVarOp(Token.SETVAR, index);\n }\n break;\n case Token.SETCONSTVAR:\n {\n if (itsData.itsNeedsActivation) Kit.codeBug();\n int index = scriptOrFn.getIndexForNameNode(child);\n child = child.getNext();\n visitExpression(child, 0);\n addVarOp(Token.SETCONSTVAR, index);\n }\n break;\n case Token.NULL:\n case Token.THIS:\n case Token.THISFN:\n case Token.FALSE:\n case Token.TRUE:\n addToken(type);\n stackChange(1);\n break;\n case Token.ENUM_NEXT:\n case Token.ENUM_ID:\n addIndexOp(type, getLocalBlockRef(node));\n stackChange(1);\n break;\n case Token.REGEXP:\n {\n int index = node.getExistingIntProp(Node.REGEXP_PROP);\n addIndexOp(Token.REGEXP, index);\n stackChange(1);\n }\n break;\n case Token.ARRAYLIT:\n case Token.OBJECTLIT:\n visitLiteral(node, child);\n break;\n case Token.ARRAYCOMP:\n visitArrayComprehension(node, child, child.getNext());\n break;\n case Token.REF_SPECIAL:\n visitExpression(child, 0);\n addStringOp(type, (String)node.getProp(Node.NAME_PROP));\n break;\n case Token.REF_MEMBER:\n case Token.REF_NS_MEMBER:\n case Token.REF_NAME:\n case Token.REF_NS_NAME:\n {\n int memberTypeFlags = node.getIntProp(Node.MEMBER_TYPE_PROP, 0);\n int childCount = 0;\n do {\n visitExpression(child, 0);\n ++childCount;\n child = child.getNext();\n } while (child != null);\n addIndexOp(type, memberTypeFlags);\n stackChange(1 - childCount);\n }\n break;\n case Token.DOTQUERY:\n {\n int queryPC;\n updateLineNumber(node);\n visitExpression(child, 0);\n addIcode(Icode_ENTERDQ);\n stackChange(-1);\n queryPC = iCodeTop;\n visitExpression(child.getNext(), 0);\n addBackwardGoto(Icode_LEAVEDQ, queryPC);\n }\n break;\n case Token.DEFAULTNAMESPACE :\n case Token.ESCXMLATTR :\n case Token.ESCXMLTEXT :\n visitExpression(child, 0);\n addToken(type);\n break;\n case Token.YIELD:\n if (child != null) {\n visitExpression(child, 0);\n } else {\n addIcode(Icode_UNDEF);\n stackChange(1);\n }\n addToken(Token.YIELD);\n addUint16(node.getLineno() & 0xFFFF);\n break;\n case Token.WITHEXPR: {\n Node enterWith = node.getFirstChild();\n Node with = enterWith.getNext();\n visitExpression(enterWith.getFirstChild(), 0);\n addToken(Token.ENTERWITH);\n stackChange(-1);\n visitExpression(with.getFirstChild(), 0);\n addToken(Token.LEAVEWITH);\n break;\n }\n default:\n throw badTree(node);\n }\n if (savedStackDepth + 1 != stackDepth) {\n Kit.codeBug();\n }\n }\n", "output": " private void visitExpression(Node node, int contextFlags)\n {\n int type = node.getType();\n Node child = node.getFirstChild();\n int savedStackDepth = stackDepth;\n switch (type) {\n case Token.FUNCTION:\n {\n int fnIndex = node.getExistingIntProp(Node.FUNCTION_PROP);\n FunctionNode fn = scriptOrFn.getFunctionNode(fnIndex);\n if (fn.getFunctionType() != FunctionNode.FUNCTION_EXPRESSION) {\n throw Kit.codeBug();\n }\n addIndexOp(Icode_CLOSURE_EXPR, fnIndex);\n stackChange(1);\n }\n break;\n case Token.LOCAL_LOAD:\n {\n int localIndex = getLocalBlockRef(node);\n addIndexOp(Token.LOCAL_LOAD, localIndex);\n stackChange(1);\n }\n break;\n case Token.COMMA:\n {\n Node lastChild = node.getLastChild();\n while (child != lastChild) {\n visitExpression(child, 0);\n addIcode(Icode_POP);\n stackChange(-1);\n child = child.getNext();\n }\n visitExpression(child, contextFlags & ECF_TAIL);\n }\n break;\n case Token.USE_STACK:\n stackChange(1);\n break;\n case Token.REF_CALL:\n case Token.CALL:\n case Token.NEW:\n {\n if (type == Token.NEW) {\n visitExpression(child, 0);\n } else {\n generateCallFunAndThis(child);\n }\n int argCount = 0;\n while ((child = child.getNext()) != null) {\n visitExpression(child, 0);\n ++argCount;\n }\n int callType = node.getIntProp(Node.SPECIALCALL_PROP,\n Node.NON_SPECIALCALL);\n if (type != Token.REF_CALL && callType != Node.NON_SPECIALCALL) {\n addIndexOp(Icode_CALLSPECIAL, argCount);\n addUint8(callType);\n addUint8(type == Token.NEW ? 1 : 0);\n addUint16(lineNumber & 0xFFFF);\n } else {\n if (type == Token.CALL && (contextFlags & ECF_TAIL) != 0 &&\n !compilerEnv.isGenerateDebugInfo() && !itsInTryFlag)\n {\n type = Icode_TAIL_CALL;\n }\n addIndexOp(type, argCount);\n }\n if (type == Token.NEW) {\n stackChange(-argCount);\n } else {\n stackChange(-1 - argCount);\n }\n if (argCount > itsData.itsMaxCalleeArgs) {\n itsData.itsMaxCalleeArgs = argCount;\n }\n }\n break;\n case Token.AND:\n case Token.OR:\n {\n visitExpression(child, 0);\n addIcode(Icode_DUP);\n stackChange(1);\n int afterSecondJumpStart = iCodeTop;\n int jump = (type == Token.AND) ? Token.IFNE : Token.IFEQ;\n addGotoOp(jump);\n stackChange(-1);\n addIcode(Icode_POP);\n stackChange(-1);\n child = child.getNext();\n visitExpression(child, contextFlags & ECF_TAIL);\n resolveForwardGoto(afterSecondJumpStart);\n }\n break;\n case Token.HOOK:\n {\n Node ifThen = child.getNext();\n Node ifElse = ifThen.getNext();\n visitExpression(child, 0);\n int elseJumpStart = iCodeTop;\n addGotoOp(Token.IFNE);\n stackChange(-1);\n visitExpression(ifThen, contextFlags & ECF_TAIL);\n int afterElseJumpStart = iCodeTop;\n addGotoOp(Token.GOTO);\n resolveForwardGoto(elseJumpStart);\n stackDepth = savedStackDepth;\n visitExpression(ifElse, contextFlags & ECF_TAIL);\n resolveForwardGoto(afterElseJumpStart);\n }\n break;\n case Token.GETPROP:\n case Token.GETPROPNOWARN:\n visitExpression(child, 0);\n child = child.getNext();\n addStringOp(type, child.getString());\n break;\n case Token.DELPROP:\n boolean isName = child.getType() == Token.BINDNAME;\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n if (isName) {\n addIcode(Icode_DELNAME);\n } else {\n addToken(Token.DELPROP);\n }\n stackChange(-1);\n break;\n case Token.GETELEM:\n case Token.BITAND:\n case Token.BITOR:\n case Token.BITXOR:\n case Token.LSH:\n case Token.RSH:\n case Token.URSH:\n case Token.ADD:\n case Token.SUB:\n case Token.MOD:\n case Token.DIV:\n case Token.MUL:\n case Token.EQ:\n case Token.NE:\n case Token.SHEQ:\n case Token.SHNE:\n case Token.IN:\n case Token.INSTANCEOF:\n case Token.LE:\n case Token.LT:\n case Token.GE:\n case Token.GT:\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n addToken(type);\n stackChange(-1);\n break;\n case Token.POS:\n case Token.NEG:\n case Token.NOT:\n case Token.BITNOT:\n case Token.TYPEOF:\n case Token.VOID:\n visitExpression(child, 0);\n if (type == Token.VOID) {\n addIcode(Icode_POP);\n addIcode(Icode_UNDEF);\n } else {\n addToken(type);\n }\n break;\n case Token.GET_REF:\n case Token.DEL_REF:\n visitExpression(child, 0);\n addToken(type);\n break;\n case Token.SETPROP:\n case Token.SETPROP_OP:\n {\n visitExpression(child, 0);\n child = child.getNext();\n String property = child.getString();\n child = child.getNext();\n if (type == Token.SETPROP_OP) {\n addIcode(Icode_DUP);\n stackChange(1);\n addStringOp(Token.GETPROP, property);\n stackChange(-1);\n }\n visitExpression(child, 0);\n addStringOp(Token.SETPROP, property);\n stackChange(-1);\n }\n break;\n case Token.SETELEM:\n case Token.SETELEM_OP:\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n child = child.getNext();\n if (type == Token.SETELEM_OP) {\n addIcode(Icode_DUP2);\n stackChange(2);\n addToken(Token.GETELEM);\n stackChange(-1);\n stackChange(-1);\n }\n visitExpression(child, 0);\n addToken(Token.SETELEM);\n stackChange(-2);\n break;\n case Token.SET_REF:\n case Token.SET_REF_OP:\n visitExpression(child, 0);\n child = child.getNext();\n if (type == Token.SET_REF_OP) {\n addIcode(Icode_DUP);\n stackChange(1);\n addToken(Token.GET_REF);\n stackChange(-1);\n }\n visitExpression(child, 0);\n addToken(Token.SET_REF);\n stackChange(-1);\n break;\n case Token.STRICT_SETNAME:\n case Token.SETNAME:\n {\n String name = child.getString();\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n addStringOp(type, name);\n stackChange(-1);\n }\n break;\n case Token.SETCONST:\n {\n String name = child.getString();\n visitExpression(child, 0);\n child = child.getNext();\n visitExpression(child, 0);\n addStringOp(Icode_SETCONST, name);\n stackChange(-1);\n }\n break;\n case Token.TYPEOFNAME:\n {\n int index = -1;\n if (itsInFunctionFlag && !itsData.itsNeedsActivation)\n index = scriptOrFn.getIndexForNameNode(node);\n if (index == -1) {\n addStringOp(Icode_TYPEOFNAME, node.getString());\n stackChange(1);\n } else {\n addVarOp(Token.GETVAR, index);\n stackChange(1);\n addToken(Token.TYPEOF);\n }\n }\n break;\n case Token.BINDNAME:\n case Token.NAME:\n case Token.STRING:\n addStringOp(type, node.getString());\n stackChange(1);\n break;\n case Token.INC:\n case Token.DEC:\n visitIncDec(node, child);\n break;\n case Token.NUMBER:\n {\n double num = node.getDouble();\n int inum = (int)num;\n if (inum == num) {\n if (inum == 0) {\n addIcode(Icode_ZERO);\n if (1.0 / num < 0.0) {\n addToken(Token.NEG);\n }\n } else if (inum == 1) {\n addIcode(Icode_ONE);\n } else if ((short)inum == inum) {\n addIcode(Icode_SHORTNUMBER);\n addUint16(inum & 0xFFFF);\n } else {\n addIcode(Icode_INTNUMBER);\n addInt(inum);\n }\n } else {\n int index = getDoubleIndex(num);\n addIndexOp(Token.NUMBER, index);\n }\n stackChange(1);\n }\n break;\n case Token.GETVAR:\n {\n if (itsData.itsNeedsActivation) Kit.codeBug();\n int index = scriptOrFn.getIndexForNameNode(node);\n addVarOp(Token.GETVAR, index);\n stackChange(1);\n }\n break;\n case Token.SETVAR:\n {\n if (itsData.itsNeedsActivation) Kit.codeBug();\n int index = scriptOrFn.getIndexForNameNode(child);\n child = child.getNext();\n visitExpression(child, 0);\n addVarOp(Token.SETVAR, index);\n }\n break;\n case Token.SETCONSTVAR:\n {\n if (itsData.itsNeedsActivation) Kit.codeBug();\n int index = scriptOrFn.getIndexForNameNode(child);\n child = child.getNext();\n visitExpression(child, 0);\n addVarOp(Token.SETCONSTVAR, index);\n }\n break;\n case Token.NULL:\n case Token.THIS:\n case Token.THISFN:\n case Token.FALSE:\n case Token.TRUE:\n addToken(type);\n stackChange(1);\n break;\n case Token.ENUM_NEXT:\n case Token.ENUM_ID:\n addIndexOp(type, getLocalBlockRef(node));\n stackChange(1);\n break;\n case Token.REGEXP:\n {\n int index = node.getExistingIntProp(Node.REGEXP_PROP);\n addIndexOp(Token.REGEXP, index);\n stackChange(1);\n }\n break;\n case Token.ARRAYLIT:\n case Token.OBJECTLIT:\n visitLiteral(node, child);\n break;\n case Token.ARRAYCOMP:\n visitArrayComprehension(node, child, child.getNext());\n break;\n case Token.REF_SPECIAL:\n visitExpression(child, 0);\n addStringOp(type, (String)node.getProp(Node.NAME_PROP));\n break;\n case Token.REF_MEMBER:\n case Token.REF_NS_MEMBER:\n case Token.REF_NAME:\n case Token.REF_NS_NAME:\n {\n int memberTypeFlags = node.getIntProp(Node.MEMBER_TYPE_PROP, 0);\n int childCount = 0;\n do {\n visitExpression(child, 0);\n ++childCount;\n child = child.getNext();\n } while (child != null);\n addIndexOp(type, memberTypeFlags);\n stackChange(1 - childCount);\n }\n break;\n case Token.DOTQUERY:\n {\n int queryPC;\n updateLineNumber(node);\n visitExpression(child, 0);\n addIcode(Icode_ENTERDQ);\n stackChange(-1);\n queryPC = iCodeTop;\n visitExpression(child.getNext(), 0);\n addBackwardGoto(Icode_LEAVEDQ, queryPC);\n }\n break;\n case Token.DEFAULTNAMESPACE :\n case Token.ESCXMLATTR :\n case Token.ESCXMLTEXT :\n visitExpression(child, 0);\n addToken(type);\n break;\n case Token.YIELD:\n if (child != null) {\n visitExpression(child, 0);\n } else {\n addIcode(Icode_UNDEF);\n stackChange(1);\n }\n addToken(Token.YIELD);\n addUint16(node.getLineno() & 0xFFFF);\n break;\n case Token.WITHEXPR: {\n Node enterWith = node.getFirstChild();\n Node with = enterWith.getNext();\n visitExpression(enterWith.getFirstChild(), 0);\n addToken(Token.ENTERWITH);\n stackChange(-1);\n visitExpression(with.getFirstChild(), 0);\n addToken(Token.LEAVEWITH);\n break;\n }\n default:\n throw badTree(node);\n }\n if (savedStackDepth + 1 != stackDepth) {\n Kit.codeBug();\n }\n }\n"} {"input": " public void onAttachedToWindow() {\n super.onAttachedToWindow();\n setContentView(R.layout.main);\n lightsOut(); \n final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);\n final String url = prefs.getString(\"url\", \"file:///android_asset/default.html\");\n final boolean interactive = prefs.getBoolean(\"interactive\", false);\n Log.v(\"WebViewDream\", String.format(\"loading %s in %s mode\",\n url, interactive ? \"interactive\" : \"noninteractive\"));\n setInteractive(interactive);\n WebView webview = (WebView) findViewById(R.id.webview);\n webview.setWebViewClient(new LinkLauncher());\n WebSettings webSettings = webview.getSettings();\n webSettings.setJavaScriptEnabled(true);\n webview.loadUrl(url);\n }\n", "output": " public void onAttachedToWindow() {\n super.onAttachedToWindow();\n setContentView(R.layout.main);\n setFullscreen(true);\n final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);\n final String url = prefs.getString(\"url\", \"file:///android_asset/default.html\");\n final boolean interactive = prefs.getBoolean(\"interactive\", false);\n Log.v(\"WebViewDream\", String.format(\"loading %s in %s mode\",\n url, interactive ? \"interactive\" : \"noninteractive\"));\n setInteractive(interactive);\n WebView webview = (WebView) findViewById(R.id.webview);\n webview.setWebViewClient(new LinkLauncher());\n WebSettings webSettings = webview.getSettings();\n webSettings.setJavaScriptEnabled(true);\n webview.loadUrl(url);\n }\n"} {"input": " protected void execute() {\n if (TrackingCamera.targetGoal == null){ \n leftShootingMotors.setSetpoint(1000); \n rightShootingMotors.setSetpoint(1000); \n System.out.println(\"No target set\"); \n return;\n }\n tgtHght = TrackingCamera.targetGoal.boundingRectHeight; \n tgtHghtFt = 1.5; \n vertFOV = tgtHghtFt / tgtHght * ttlHght; \n vertVA = 47*pi/180; \n horVA = 47*pi/180; \n tgtWdth = TrackingCamera.targetGoal.boundingRectWidth; \n tgtWdthFt = 2.0; \n horFOV = tgtWdthFt / tgtWdth * ttlWdth; \n leftRight = Math.abs(TrackingCamera.targetGoal.center_mass_x - (ttlHght/2)); \n upDown = Math.abs(TrackingCamera.targetGoal.center_mass_y - (ttlWdth/2)); \n wdth1Px = (ttlHght/2) - leftRight; \n hght1Px = (ttlWdth/2) - upDown; \n horThet1 = horVA * wdth1Px/ttlWdth; \n vertThet1 = vertVA * hght1Px/ttlHght; \n TrackingCamera.d1 = (hght1Px) / Math.tan(vertThet1); \n TrackingCamera.d2 = (wdth1Px) / Math.tan(horThet1); \n TrackingCamera.distanceToTarget = (TrackingCamera.d1 + TrackingCamera.d2) / 2; \n if (TrackingCamera.distanceToTarget > 60 || TrackingCamera.distanceToTarget <= 0)\n TrackingCamera.distanceToTarget = 60;\n d = TrackingCamera.distanceToTarget; \n TrackingCamera.launchSpeed = 60 * (d / Math.sqrt((11 / 6 - d) / -16.1) / (2 / 3 * pi)); \n leftShootingMotors.setSetpoint(TrackingCamera.launchSpeed); \n rightShootingMotors.setSetpoint(TrackingCamera.launchSpeed); \n System.out.println();\n System.out.println(\"D1: \"+TrackingCamera.d1);\n System.out.println(\"D2: \"+TrackingCamera.d2);\n System.out.println(\"D: \"+d);\n System.out.println(\"Camera Launch Speed: \"+TrackingCamera.launchSpeed);\n System.out.println();\n }\n", "output": " protected void execute() {\n if (TrackingCamera.targetGoal == null){ \n leftShootingMotors.setSetpoint(1000); \n rightShootingMotors.setSetpoint(1000); \n System.out.println(\"No target set\"); \n return;\n }\n tgtHght = TrackingCamera.targetGoal.boundingRectHeight; \n tgtHghtFt = 1.5; \n vertFOV = tgtHghtFt / tgtHght * ttlHght; \n vertVA = 47*pi/180; \n horVA = 47*pi/180; \n tgtWdth = TrackingCamera.targetGoal.boundingRectWidth; \n tgtWdthFt = 2.0; \n horFOV = tgtWdthFt / tgtWdth * ttlWdth; \n leftRight = Math.abs(TrackingCamera.targetGoal.center_mass_x - (ttlHght/2)); \n upDown = Math.abs(TrackingCamera.targetGoal.center_mass_y - (ttlWdth/2)); \n wdth1Px = (ttlWdth/2) - leftRight; \n hght1Px = (ttlHght/2) - upDown; \n horThet1 = horVA * wdth1Px/ttlWdth; \n vertThet1 = vertVA * hght1Px/ttlHght; \n TrackingCamera.d1 = (hght1Px) / Math.tan(vertThet1); \n TrackingCamera.d2 = (wdth1Px) / Math.tan(horThet1); \n TrackingCamera.distanceToTarget = (TrackingCamera.d1 + TrackingCamera.d2) / 2; \n if (TrackingCamera.distanceToTarget > 60 || TrackingCamera.distanceToTarget <= 0)\n TrackingCamera.distanceToTarget = 60;\n d = TrackingCamera.distanceToTarget; \n TrackingCamera.launchSpeed = 60 * (d / Math.sqrt((11 / 6 - d) / -16.1) / (2 / 3 * pi)); \n leftShootingMotors.setSetpoint(TrackingCamera.launchSpeed); \n rightShootingMotors.setSetpoint(TrackingCamera.launchSpeed); \n System.out.println();\n System.out.println(\"D1: \"+TrackingCamera.d1);\n System.out.println(\"D2: \"+TrackingCamera.d2);\n System.out.println(\"D: \"+d);\n System.out.println(\"Camera Launch Speed: \"+TrackingCamera.launchSpeed);\n System.out.println();\n }\n"} {"input": " protected AbstractHttpClient http() {\n if(null == http) {\n final HttpParams params = new BasicHttpParams();\n HttpProtocolParams.setVersion(params, org.apache.http.HttpVersion.HTTP_1_1);\n HttpProtocolParams.setContentCharset(params, getEncoding());\n HttpProtocolParams.setUserAgent(params, getUserAgent());\n AuthParams.setCredentialCharset(params, \"ISO-8859-1\");\n HttpConnectionParams.setTcpNoDelay(params, true);\n HttpConnectionParams.setSoTimeout(params, timeout());\n HttpConnectionParams.setSocketBufferSize(params, 8192);\n HttpClientParams.setRedirecting(params, true);\n HttpClientParams.setAuthenticating(params, true);\n SchemeRegistry registry = new SchemeRegistry();\n if(host.getProtocol().isSecure()) {\n org.apache.http.conn.ssl.SSLSocketFactory factory = new SSLSocketFactory(\n new CustomTrustSSLProtocolSocketFactory(this.getTrustManager()).getSSLContext());\n factory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);\n registry.register(\n new Scheme(host.getProtocol().getScheme(), factory, host.getPort()));\n }\n else {\n registry.register(\n new Scheme(host.getProtocol().getScheme(), PlainSocketFactory.getSocketFactory(), host.getPort()));\n }\n if(\"https\".equals(this.getHost().getProtocol().getScheme())) {\n if(Preferences.instance().getBoolean(\"connection.proxy.enable\")) {\n final Proxy proxy = ProxyFactory.instance();\n if(proxy.isHTTPSProxyEnabled(host)) {\n ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPSProxyHost(), proxy.getHTTPSProxyPort()));\n }\n }\n }\n else if(\"http\".equals(this.getHost().getProtocol().getScheme())) {\n if(Preferences.instance().getBoolean(\"connection.proxy.enable\")) {\n final Proxy proxy = ProxyFactory.instance();\n if(proxy.isHTTPProxyEnabled(host)) {\n ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPProxyHost(), proxy.getHTTPProxyPort()));\n }\n }\n }\n ClientConnectionManager manager = new SingleClientConnManager(params, registry);\n http = new DefaultHttpClient(manager, params);\n this.configure(http);\n }\n return http;\n }\n", "output": " protected AbstractHttpClient http() {\n if(null == http) {\n final HttpParams params = new BasicHttpParams();\n HttpProtocolParams.setVersion(params, org.apache.http.HttpVersion.HTTP_1_1);\n HttpProtocolParams.setContentCharset(params, getEncoding());\n HttpProtocolParams.setUserAgent(params, getUserAgent());\n AuthParams.setCredentialCharset(params, \"ISO-8859-1\");\n HttpConnectionParams.setTcpNoDelay(params, true);\n HttpConnectionParams.setSoTimeout(params, timeout());\n HttpConnectionParams.setSocketBufferSize(params, 8192);\n HttpClientParams.setRedirecting(params, true);\n HttpClientParams.setAuthenticating(params, true);\n SchemeRegistry registry = new SchemeRegistry();\n registry.register(new Scheme(\"http\", PlainSocketFactory.getSocketFactory(), host.getPort()));\n if(\"https\".equals(this.getHost().getProtocol().getScheme())) {\n org.apache.http.conn.ssl.SSLSocketFactory factory = new SSLSocketFactory(\n new CustomTrustSSLProtocolSocketFactory(this.getTrustManager()).getSSLContext());\n factory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);\n registry.register(new Scheme(host.getProtocol().getScheme(), factory, host.getPort()));\n }\n if(Preferences.instance().getBoolean(\"connection.proxy.enable\")) {\n final Proxy proxy = ProxyFactory.instance();\n if(\"https\".equals(this.getHost().getProtocol().getScheme())) {\n if(proxy.isHTTPSProxyEnabled(host)) {\n ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPSProxyHost(), proxy.getHTTPSProxyPort()));\n }\n }\n if(\"http\".equals(this.getHost().getProtocol().getScheme())) {\n if(proxy.isHTTPProxyEnabled(host)) {\n ConnRouteParams.setDefaultProxy(params, new HttpHost(proxy.getHTTPProxyHost(), proxy.getHTTPProxyPort()));\n }\n }\n }\n ClientConnectionManager manager = new SingleClientConnManager(params, registry);\n http = new DefaultHttpClient(manager, params);\n this.configure(http);\n }\n return http;\n }\n"} {"input": " protected IStatus run(IProgressMonitor monitor) {\n instances.remove(project.getFullPath().toPortableString());\n try {\n Project model = Workspace.getProject(project.getLocation().toFile());\n Collection< ? extends Builder> builders = model.getSubBuilders();\n Map> allExports = new HashMap>();\n Set allContained = new HashSet();\n for (Builder builder : builders) {\n try {\n builder.build();\n Packages exports = builder.getExports();\n if (exports != null) {\n for (Entry export : exports.entrySet()) {\n Version version;\n String versionStr = export.getValue().get(Constants.VERSION_ATTRIBUTE);\n try {\n version = Version.parseVersion(versionStr);\n String pkgName = Processor.removeDuplicateMarker(export.getKey().getFQN());\n SortedSet versions = allExports.get(pkgName);\n if (versions == null) {\n versions = new TreeSet();\n allExports.put(pkgName, versions);\n }\n versions.add(version);\n } catch (IllegalArgumentException e) {\n }\n }\n }\n Packages contained = builder.getContained();\n for (PackageRef pkgRef : contained.keySet()) {\n String pkgName = Processor.removeDuplicateMarker(pkgRef.getFQN());\n allContained.add(pkgName);\n }\n } catch (Exception e) {\n logger.logWarning(MessageFormat.format(\"Unable to process exported packages for builder of {0}.\", builder.getPropertiesFile()), e);\n }\n }\n Central.setProjectPackageModel(project, allExports, allContained);\n Display display = PlatformUI.getWorkbench().getDisplay();\n SWTConcurrencyUtil.execForDisplay(display, true, new Runnable() {\n public void run() {\n PlatformUI.getWorkbench().getDecoratorManager().update(\"bndtools.packageDecorator\");\n }\n });\n } catch (Exception e) {\n logger.logWarning(\"Error persisting package model for project: \" + project.getName(), e);\n }\n return Status.OK_STATUS;\n }\n", "output": " protected IStatus run(IProgressMonitor monitor) {\n instances.remove(project.getFullPath().toPortableString());\n try {\n Project model = Workspace.getProject(project.getLocation().toFile());\n if (model == null) {\n return Status.OK_STATUS;\n }\n Collection< ? extends Builder> builders = model.getSubBuilders();\n Map> allExports = new HashMap>();\n Set allContained = new HashSet();\n for (Builder builder : builders) {\n try {\n builder.build();\n Packages exports = builder.getExports();\n if (exports != null) {\n for (Entry export : exports.entrySet()) {\n Version version;\n String versionStr = export.getValue().get(Constants.VERSION_ATTRIBUTE);\n try {\n version = Version.parseVersion(versionStr);\n String pkgName = Processor.removeDuplicateMarker(export.getKey().getFQN());\n SortedSet versions = allExports.get(pkgName);\n if (versions == null) {\n versions = new TreeSet();\n allExports.put(pkgName, versions);\n }\n versions.add(version);\n } catch (IllegalArgumentException e) {\n }\n }\n }\n Packages contained = builder.getContained();\n for (PackageRef pkgRef : contained.keySet()) {\n String pkgName = Processor.removeDuplicateMarker(pkgRef.getFQN());\n allContained.add(pkgName);\n }\n } catch (Exception e) {\n logger.logWarning(MessageFormat.format(\"Unable to process exported packages for builder of {0}.\", builder.getPropertiesFile()), e);\n }\n }\n Central.setProjectPackageModel(project, allExports, allContained);\n Display display = PlatformUI.getWorkbench().getDisplay();\n SWTConcurrencyUtil.execForDisplay(display, true, new Runnable() {\n public void run() {\n PlatformUI.getWorkbench().getDecoratorManager().update(\"bndtools.packageDecorator\");\n }\n });\n } catch (Exception e) {\n logger.logWarning(\"Error persisting package model for project: \" + project.getName(), e);\n }\n return Status.OK_STATUS;\n }\n"} {"input": "\tpublic void onCreate(Activity activity, Bundle savedInstanceState) {\n\t\tPackageManager manager = activity.getBaseContext().getPackageManager();\n\t\tString[] keys = {\"tapJoyAppID\", \"tapJoySecretKey\"};\n\t\ttry {\n\t\t\tBundle meta = manager.getApplicationInfo(activity.getApplicationContext().getPackageName(),\n\t\t\t\t\tPackageManager.GET_META_DATA).metaData;\n\t\t\tfor (String k : keys) {\n\t\t\t\tif (meta.containsKey(k)) {\n\t\t\t\t\tmanifestKeyMap.put(k, meta.get(k).toString());\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tlogger.log(\"Exception while loading manifest keys:\", e);\n\t\t}\n\t\tString tapJoyAppID = manifestKeyMap.get(\"tapJoyAppID\");\n\t\tString tapJoySecretKey = manifestKeyMap.get(\"tapJoySecretKey\");\n\t\tlogger.log(\"{tapjoy} Installing TapJoy for appID:\", tapJoyAppID);\n\t\tTapjoyLog.enableLogging(true);\n\t\tTapjoyConnect.requestTapjoyConnect(_ctx, tapJoyAppID, tapJoySecretKey);\n\t}\n", "output": "\tpublic void onCreate(Activity activity, Bundle savedInstanceState) {\n\t\tPackageManager manager = activity.getBaseContext().getPackageManager();\n\t\tString[] keys = {\"tapjoyAppID\", \"tapjoySecretKey\"};\n\t\ttry {\n\t\t\tBundle meta = manager.getApplicationInfo(activity.getApplicationContext().getPackageName(),\n\t\t\t\t\tPackageManager.GET_META_DATA).metaData;\n\t\t\tfor (String k : keys) {\n\t\t\t\tif (meta.containsKey(k)) {\n\t\t\t\t\tmanifestKeyMap.put(k, meta.get(k).toString());\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tlogger.log(\"Exception while loading manifest keys:\", e);\n\t\t}\n\t\tString tapJoyAppID = manifestKeyMap.get(\"tapjoyAppID\");\n\t\tString tapJoySecretKey = manifestKeyMap.get(\"tapjoySecretKey\");\n\t\tlogger.log(\"{tapjoy} Installing for appID:\", tapJoyAppID);\n\t\tTapjoyLog.enableLogging(true);\n\t\tTapjoyConnect.requestTapjoyConnect(_ctx, tapJoyAppID, tapJoySecretKey);\n\t}\n"} {"input": " public void setLocale(Locale locale)\n {\n Locale oldLocale = this.locale;\n this.locale = locale;\n firePropertyChange(\"locale\", locale, oldLocale);\n }\n", "output": " public void setLocale(Locale locale)\n {\n Locale oldLocale = this.locale;\n this.locale = locale;\n firePropertyChange(\"locale\", oldLocale, locale);\n }\n"} {"input": "\tpublic static void main(String[] args) {\n\t\ttry {\t\t\t\n\t\t\ttry {\n\t\t\t\tCORE_LOCATION = CredentialLoader.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"resources/irma_configuration/\").toURI();\n\t\t\t} catch (URISyntaxException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\tthrow new RuntimeException(e.toString());\n\t\t\t}\n\t\t\tCard card = getCardFromDb(args[0]);\n\t\t\tRandom rand = new Random();\n\t\t\tbyte[] credentialPin = new byte[4];\n\t\t\tfor(int i = 0; i < 4; i++) {\n\t\t\t\tcredentialPin[i] = (byte) (rand.nextInt(10) + 0x30);\n\t\t\t}\n\t\t\tbyte[] cardPin = new byte[6];\n\t\t\tfor(int i = 0; i < 6; i++) {\n\t\t\t\tcardPin[i] = (byte) (rand.nextInt(10) + 0x30);\n\t\t\t}\n\t\t\tSystem.out.println(\"CORE_LOCATION: \" + CORE_LOCATION);\n\t\t\tCredentialInformation.setCoreLocation(CORE_LOCATION);\n\t\t\tDescriptionStore.setCoreLocation(CORE_LOCATION);\n\t\t\tAttributes attributes = new Attributes();\n\t\t\tattributes.add(\"userID\", card.getUserID().getBytes());\n\t\t\tattributes.add(\"securityHash\", hash(card.getUserID(), Integer.toString(card.getCardId())));\n\t\t\tIssueCredentialInformation ici = new IssueCredentialInformation(\"Surfnet\", \"root\");\n\t\t\tIdemixIssueSpecification spec = ici.getIdemixIssueSpecification();\n\t\t\tIdemixPrivateKey isk = ici.getIdemixPrivateKey();\n\t\t\tCardTerminal terminal = TerminalFactory.getDefault().terminals().list().get(0);\n\t\t\tIdemixService is = new IdemixService(new TerminalCardService(terminal));\n\t\t\tIdemixCredentials ic = new IdemixCredentials(is);\n\t\t\tic.connect();\n\t\t\tis.sendPin(TestSetup.DEFAULT_CRED_PIN);\n\t\t\tic.issue(spec, isk, attributes, null);\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(Exception e) {\n\t\t\tSystem.err.println(\"Exception in Credential Loader: \" + e.toString());\n\t\t\te.printStackTrace();\n\t\t\tSystem.exit(1);\n\t\t}\n\t}\n", "output": "\tpublic static void main(String[] args) {\n\t\ttry {\t\t\t\n\t\t\tCORE_LOCATION= new File(System\n\t\t\t\t\t.getProperty(\"user.dir\")).toURI()\n\t\t\t\t\t.resolve(\"irma_configuration/\");\n\t\t\tCard card = getCardFromDb(args[0]);\n\t\t\tRandom rand = new Random();\n\t\t\tbyte[] credentialPin = new byte[4];\n\t\t\tfor(int i = 0; i < 4; i++) {\n\t\t\t\tcredentialPin[i] = (byte) (rand.nextInt(10) + 0x30);\n\t\t\t}\n\t\t\tbyte[] cardPin = new byte[6];\n\t\t\tfor(int i = 0; i < 6; i++) {\n\t\t\t\tcardPin[i] = (byte) (rand.nextInt(10) + 0x30);\n\t\t\t}\n\t\t\tSystem.out.println(\"CORE_LOCATION: \" + CORE_LOCATION);\n\t\t\tCredentialInformation.setCoreLocation(CORE_LOCATION);\n\t\t\tDescriptionStore.setCoreLocation(CORE_LOCATION);\n\t\t\tAttributes attributes = new Attributes();\n\t\t\tattributes.add(\"userID\", card.getUserID().getBytes());\n\t\t\tattributes.add(\"securityHash\", hash(card.getUserID(), Integer.toString(card.getCardId())));\n\t\t\tIssueCredentialInformation ici = new IssueCredentialInformation(\"Surfnet\", \"root\");\n\t\t\tIdemixIssueSpecification spec = ici.getIdemixIssueSpecification();\n\t\t\tIdemixPrivateKey isk = ici.getIdemixPrivateKey();\n\t\t\tCardTerminal terminal = TerminalFactory.getDefault().terminals().list().get(0);\n\t\t\tIdemixService is = new IdemixService(new TerminalCardService(terminal));\n\t\t\tIdemixCredentials ic = new IdemixCredentials(is);\n\t\t\tic.connect();\n\t\t\tis.sendPin(TestSetup.DEFAULT_CRED_PIN);\n\t\t\tic.issue(spec, isk, attributes, null);\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(Exception e) {\n\t\t\tSystem.err.println(\"Exception in Credential Loader: \" + e.toString());\n\t\t\te.printStackTrace();\n\t\t\tSystem.exit(1);\n\t\t}\n\t}\n"} {"input": " private void updateColony(Colony colony) {\n final Specification spec = getSpecification();\n final GoodsType foodType = spec.getPrimaryFoodType();\n final UnitType colonistType\n = spec.getUnitType(\"model.unit.freeColonist\");\n final ImageLibrary lib = getCanvas().getImageLibrary();\n final String cac = colony.getId();\n List exploreTiles = new ArrayList();\n List clearTiles = new ArrayList();\n List plowTiles = new ArrayList();\n List roadTiles = new ArrayList();\n colony.getColonyTileTodo(exploreTiles, clearTiles, plowTiles,\n roadTiles);\n boolean plowMe = plowTiles.size() > 0\n && plowTiles.get(0) == colony.getTile();\n int newFood = colony.getAdjustedNetProductionOf(foodType);\n boolean famine = newFood < 0\n && colony.getGoodsCount(foodType) / -newFood <= 3;\n int newColonist = (newFood == 0) ? 0\n : (newFood < 0) ? colony.getGoodsCount(foodType) / newFood - 1\n : (Settlement.FOOD_PER_COLONIST - colony.getGoodsCount(foodType))\n / newFood + 1;\n int pop = colony.getUnitCount();\n int grow, bonus = colony.getProductionBonus();\n if (bonus < 0) {\n int i;\n for (i = 1; i < pop; i++) {\n if (colony.governmentChange(pop - i) == 1) break;\n }\n grow = -i;\n } else {\n int i;\n for (i = 1; i < pop; i++) {\n if (colony.governmentChange(pop + i) == -1) break;\n }\n grow = i - 1;\n }\n JButton b = colourButton(cac, colony.getName(), null,\n (bonus <= -2) ? cAlarm\n : (bonus == -1) ? cWarn\n : (bonus == 0) ? cPlain\n : (bonus == 1) ? cExport\n : cGood,\n null);\n if (famine) {\n b.setFont(b.getFont().deriveFont(Font.BOLD));\n }\n reportPanel.add(b, \"newline\");\n if (exploreTiles.size() > 0) {\n b = colourButton(cac, Integer.toString(exploreTiles.size()),\n null, cAlarm,\n stpl(\"report.colony.exploring.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", exploreTiles.size()));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (plowTiles.size() > 0) {\n b = colourButton(cac, Integer.toString(plowTiles.size()),\n null, cAlarm,\n stpl(\"report.colony.plowing.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", plowTiles.size()));\n if (plowMe) {\n b.setFont(b.getFont().deriveFont(Font.BOLD));\n }\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (roadTiles.size() > 0) {\n b = colourButton(cac, Integer.toString(roadTiles.size()),\n null, cAlarm,\n stpl(\"report.colony.roadBuilding.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", roadTiles.size()));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n final int adjustment = colony.getWarehouseCapacity()\n / GoodsContainer.CARGO_SIZE;\n for (GoodsType g : goodsTypes) {\n int p = colony.getAdjustedNetProductionOf(g);\n ExportData exportData = colony.getExportData(g);\n int low = exportData.getLowLevel() * adjustment;\n int high = exportData.getHighLevel() * adjustment;\n int amount = colony.getGoodsCount(g);\n Color c;\n StringTemplate tip;\n if (p < 0) {\n if (amount < low) {\n int turns = amount / p + 1;\n c = cAlarm;\n tip = stpl(\"report.colony.production.low.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%turns%\", turns);\n } else {\n c = cWarn;\n tip = stpl(\"report.colony.production.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p);\n }\n } else if (p == 0) {\n if (colony.getProductionOf(g) == 0) {\n c = null;\n tip = null;\n } else {\n c = cPlain;\n tip = stpl(\"report.colony.production.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p);\n }\n } else if (exportData.isExported()) {\n c = cExport;\n tip = stpl(\"report.colony.production.export.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%export%\", exportData.getExportLevel());\n } else if (g != foodType\n && amount + p > colony.getWarehouseCapacity()) {\n c = cAlarm;\n int waste = amount + p - colony.getWarehouseCapacity();\n tip = stpl(\"report.colony.production.waste.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%waste%\", waste);\n } else if (g != foodType && amount > high) {\n int turns = (colony.getWarehouseCapacity() - amount) / p;\n c = cWarn;\n tip = stpl(\"report.colony.production.high.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%turns%\", turns);\n } else {\n c = cGood;\n tip = stpl(\"report.colony.production.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p);\n }\n if (c == null) reportPanel.add(new JLabel(\"\"));\n else {\n b = colourButton(cac, Integer.toString(p), null, c, tip);\n reportPanel.add(b);\n }\n }\n HashMap improve\n = new HashMap();\n HashMap want\n = new HashMap();\n List teachers = new ArrayList();\n List notWorking = new ArrayList();\n for (Unit u : colony.getTile().getUnitList()) {\n if (u.getState() != UnitState.FORTIFIED\n && u.getState() != UnitState.SENTRY) {\n notWorking.add(u);\n }\n }\n for (WorkLocation wl : colony.getWorkLocations()) {\n if (wl instanceof ColonyTile) {\n if (!((ColonyTile) wl).canBeWorked()) continue;\n } else if (wl instanceof Building) {\n if (((Building) wl).canTeach()) {\n teachers.addAll(wl.getUnitList());\n continue;\n }\n }\n UnitType expert;\n GoodsType work;\n boolean needsWorker = wl.getUnitCount() < wl.getUnitCapacity();\n int delta;\n for (Unit u : wl.getUnitList()) {\n if (u.getTeacher() != null) {\n continue; \n } else if ((work = u.getWorkType()) == null) {\n notWorking.add(u);\n needsWorker = true;\n } else if ((expert = spec.getExpertForProducing(work)) != null\n && expert != u.getType()\n && (delta = wl.getPotentialProduction(expert, work)\n - wl.getPotentialProduction(u.getType(), work)) > 0\n && wantGoods(wl, work, u, expert)) {\n addSuggestion(improve, u.getType(), expert,\n work, delta);\n }\n }\n if (needsWorker\n && (work = bestProduction(wl, colonistType)) != null\n && (expert = spec.getExpertForProducing(work)) != null\n && (delta = wl.getPotentialProduction(expert, work)) > 0\n && wantGoods(wl, work, null, expert)) {\n addSuggestion(want, null, expert, work, delta);\n }\n }\n List couldWork = new ArrayList();\n for (Unit u : notWorking) {\n GoodsType t = u.getWorkType();\n WorkLocation wl = (u.getLocation() instanceof Building\n || u.getLocation() instanceof ColonyTile)\n ? (WorkLocation) u.getLocation()\n : null;\n GoodsType w = bestProduction(wl, colonistType);\n if (w == null || w != t) couldWork.add(u.getType());\n }\n if (newColonist > 0) {\n b = colourButton(cac, Integer.toString(newColonist),\n null, cGood,\n stpl(\"report.colony.arriving.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%unit%\", colonistType.getNameKey())\n .addAmount(\"%turns%\", newColonist));\n reportPanel.add(b);\n } else if (newColonist < 0) {\n b = colourButton(cac, Integer.toString(-newColonist),\n null, (newColonist >= -3) ? cAlarm : cWarn,\n stpl(\"report.colony.starving.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%turns%\", -newColonist));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n BuildableType build = colony.getCurrentlyBuilding();\n int fields = 1 + teachers.size();\n String layout = (fields > 1) ? \"split \" + fields : null;\n String qac = BUILDQUEUE + colony.getId();\n if (build == null) {\n b = colourButton(qac, Messages.message(\"nothing\"),\n null, cAlarm,\n stpl(\"report.colony.making.noconstruction.description\")\n .addName(\"%colony%\", colony.getName()));\n b.setFont(b.getFont().deriveFont(Font.BOLD));\n } else {\n int turns = colony.getTurnsToComplete(build);\n String name = Messages.message(build.getNameKey());\n if (turns == FreeColObject.UNDEFINED) {\n b = colourButton(qac, name, null, cAlarm,\n stpl(\"report.colony.making.noconstruction.description\")\n .addName(\"%colony%\", colony.getName()));\n } else if (turns >= 0) {\n turns++;\n name += \" \" + Integer.toString(turns);\n b = colourButton(qac, name, null, cGood,\n stpl(\"report.colony.making.constructing.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%buildable%\", build.getNameKey())\n .addAmount(\"%turns%\", turns));;\n } else if (turns < 0) {\n turns = -turns;\n name += \" \" + Integer.toString(turns);\n b = colourButton(qac, name, null, cAlarm,\n stpl(\"report.colony.making.block.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%buildable%\", build.getNameKey())\n .addAmount(\"%turns%\", turns));\n }\n }\n reportPanel.add(b, layout);\n layout = null;\n Collections.sort(teachers, teacherComparator);\n for (Unit u : teachers) {\n int left = u.getNeededTurnsOfTraining()\n - u.getTurnsOfTraining();\n JLabel teach;\n if (left <= 0) {\n b = colourButton(cac, Integer.toString(0),\n lib.getUnitImageIcon(u.getType(), Role.DEFAULT,\n true, 0.333), cAlarm,\n stpl(\"report.colony.making.noteach.description\")\n .addName(\"%colony%\", colony.getName())\n .addStringTemplate(\"%teacher%\", u.getLabel()));\n } else {\n b = colourButton(cac, Integer.toString(left),\n lib.getUnitImageIcon(u.getType(), Role.DEFAULT,\n true, 0.333), Color.BLACK,\n stpl(\"report.colony.making.educating.description\")\n .addName(\"%colony%\", colony.getName())\n .addStringTemplate(\"%teacher%\", u.getLabel())\n .addAmount(\"%turns%\", left));\n }\n reportPanel.add(b);\n }\n if (fields <= 0) reportPanel.add(new JLabel(\"\"));\n if (!improve.isEmpty()) {\n addUnits(improve, couldWork, colony, grow);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (grow < 0) {\n b = colourButton(cac, Integer.toString(-grow), null, cAlarm,\n stpl(\"report.colony.shrinking.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", -grow));\n reportPanel.add(b);\n } else if (grow > 0) {\n b = colourButton(cac, Integer.toString(grow), null, cGood,\n stpl(\"report.colony.growing.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", grow));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (!want.isEmpty()) {\n grow = Math.min(grow, colony.getNetProductionOf(foodType)\n / Settlement.FOOD_PER_COLONIST);\n addUnits(want, couldWork, colony, grow);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n }\n", "output": " private void updateColony(Colony colony) {\n final Specification spec = getSpecification();\n final GoodsType foodType = spec.getPrimaryFoodType();\n final UnitType colonistType\n = spec.getUnitType(\"model.unit.freeColonist\");\n final ImageLibrary lib = getCanvas().getImageLibrary();\n final String cac = colony.getId();\n List exploreTiles = new ArrayList();\n List clearTiles = new ArrayList();\n List plowTiles = new ArrayList();\n List roadTiles = new ArrayList();\n colony.getColonyTileTodo(exploreTiles, clearTiles, plowTiles,\n roadTiles);\n boolean plowMe = plowTiles.size() > 0\n && plowTiles.get(0) == colony.getTile();\n int newFood = colony.getAdjustedNetProductionOf(foodType);\n boolean famine = newFood < 0\n && colony.getGoodsCount(foodType) / -newFood <= 3;\n int newColonist = (newFood == 0) ? 0\n : (newFood < 0) ? colony.getGoodsCount(foodType) / newFood - 1\n : (Settlement.FOOD_PER_COLONIST - colony.getGoodsCount(foodType))\n / newFood + 1;\n int pop = colony.getUnitCount();\n int grow, bonus = colony.getProductionBonus();\n if (bonus < 0) {\n int i;\n for (i = 1; i < pop; i++) {\n if (colony.governmentChange(pop - i) == 1) break;\n }\n grow = -i;\n } else {\n int i;\n for (i = 1; i < pop; i++) {\n if (colony.governmentChange(pop + i) == -1) break;\n }\n grow = i - 1;\n }\n JButton b = colourButton(cac, colony.getName(), null,\n (bonus <= -2) ? cAlarm\n : (bonus == -1) ? cWarn\n : (bonus == 0) ? cPlain\n : (bonus == 1) ? cExport\n : cGood,\n null);\n if (famine) {\n b.setFont(b.getFont().deriveFont(Font.BOLD));\n }\n reportPanel.add(b, \"newline\");\n if (exploreTiles.size() > 0) {\n b = colourButton(cac, Integer.toString(exploreTiles.size()),\n null, cAlarm,\n stpl(\"report.colony.exploring.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", exploreTiles.size()));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (plowTiles.size() > 0) {\n b = colourButton(cac, Integer.toString(plowTiles.size()),\n null, cAlarm,\n stpl(\"report.colony.plowing.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", plowTiles.size()));\n if (plowMe) {\n b.setFont(b.getFont().deriveFont(Font.BOLD));\n }\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (roadTiles.size() > 0) {\n b = colourButton(cac, Integer.toString(roadTiles.size()),\n null, cAlarm,\n stpl(\"report.colony.roadBuilding.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", roadTiles.size()));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n final int adjustment = colony.getWarehouseCapacity()\n / GoodsContainer.CARGO_SIZE;\n for (GoodsType g : goodsTypes) {\n int p = colony.getAdjustedNetProductionOf(g);\n ExportData exportData = colony.getExportData(g);\n int low = exportData.getLowLevel() * adjustment;\n int high = exportData.getHighLevel() * adjustment;\n int amount = colony.getGoodsCount(g);\n Color c;\n StringTemplate tip;\n if (p < 0) {\n if (amount < low) {\n int turns = -amount / p + 1;\n c = cAlarm;\n tip = stpl(\"report.colony.production.low.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%turns%\", turns);\n } else {\n c = cWarn;\n tip = stpl(\"report.colony.production.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p);\n }\n } else if (p == 0) {\n if (colony.getProductionOf(g) == 0) {\n c = null;\n tip = null;\n } else {\n c = cPlain;\n tip = stpl(\"report.colony.production.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p);\n }\n } else if (exportData.isExported()) {\n c = cExport;\n tip = stpl(\"report.colony.production.export.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%export%\", exportData.getExportLevel());\n } else if (g != foodType\n && amount + p > colony.getWarehouseCapacity()) {\n c = cAlarm;\n int waste = amount + p - colony.getWarehouseCapacity();\n tip = stpl(\"report.colony.production.waste.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%waste%\", waste);\n } else if (g != foodType && amount > high) {\n int turns = (colony.getWarehouseCapacity() - amount) / p;\n c = cWarn;\n tip = stpl(\"report.colony.production.high.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p)\n .addAmount(\"%turns%\", turns);\n } else {\n c = cGood;\n tip = stpl(\"report.colony.production.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%goods%\", g.getNameKey())\n .addAmount(\"%amount%\", p);\n }\n if (c == null) reportPanel.add(new JLabel(\"\"));\n else {\n b = colourButton(cac, Integer.toString(p), null, c, tip);\n reportPanel.add(b);\n }\n }\n HashMap improve\n = new HashMap();\n HashMap want\n = new HashMap();\n List teachers = new ArrayList();\n List notWorking = new ArrayList();\n for (Unit u : colony.getTile().getUnitList()) {\n if (u.getState() != UnitState.FORTIFIED\n && u.getState() != UnitState.SENTRY) {\n notWorking.add(u);\n }\n }\n for (WorkLocation wl : colony.getWorkLocations()) {\n if (wl instanceof ColonyTile) {\n if (!((ColonyTile) wl).canBeWorked()) continue;\n } else if (wl instanceof Building) {\n if (((Building) wl).canTeach()) {\n teachers.addAll(wl.getUnitList());\n continue;\n }\n }\n UnitType expert;\n GoodsType work;\n boolean needsWorker = wl.getUnitCount() < wl.getUnitCapacity();\n int delta;\n for (Unit u : wl.getUnitList()) {\n if (u.getTeacher() != null) {\n continue; \n } else if ((work = u.getWorkType()) == null) {\n notWorking.add(u);\n needsWorker = true;\n } else if ((expert = spec.getExpertForProducing(work)) != null\n && expert != u.getType()\n && (delta = wl.getPotentialProduction(expert, work)\n - wl.getPotentialProduction(u.getType(), work)) > 0\n && wantGoods(wl, work, u, expert)) {\n addSuggestion(improve, u.getType(), expert,\n work, delta);\n }\n }\n if (needsWorker\n && (work = bestProduction(wl, colonistType)) != null\n && (expert = spec.getExpertForProducing(work)) != null\n && (delta = wl.getPotentialProduction(expert, work)) > 0\n && wantGoods(wl, work, null, expert)) {\n addSuggestion(want, null, expert, work, delta);\n }\n }\n List couldWork = new ArrayList();\n for (Unit u : notWorking) {\n GoodsType t = u.getWorkType();\n WorkLocation wl = (u.getLocation() instanceof Building\n || u.getLocation() instanceof ColonyTile)\n ? (WorkLocation) u.getLocation()\n : null;\n GoodsType w = bestProduction(wl, colonistType);\n if (w == null || w != t) couldWork.add(u.getType());\n }\n if (newColonist > 0) {\n b = colourButton(cac, Integer.toString(newColonist),\n null, cGood,\n stpl(\"report.colony.arriving.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%unit%\", colonistType.getNameKey())\n .addAmount(\"%turns%\", newColonist));\n reportPanel.add(b);\n } else if (newColonist < 0) {\n b = colourButton(cac, Integer.toString(-newColonist),\n null, (newColonist >= -3) ? cAlarm : cWarn,\n stpl(\"report.colony.starving.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%turns%\", -newColonist));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n BuildableType build = colony.getCurrentlyBuilding();\n int fields = 1 + teachers.size();\n String layout = (fields > 1) ? \"split \" + fields : null;\n String qac = BUILDQUEUE + colony.getId();\n if (build == null) {\n b = colourButton(qac, Messages.message(\"nothing\"),\n null, cAlarm,\n stpl(\"report.colony.making.noconstruction.description\")\n .addName(\"%colony%\", colony.getName()));\n b.setFont(b.getFont().deriveFont(Font.BOLD));\n } else {\n int turns = colony.getTurnsToComplete(build);\n String name = Messages.message(build.getNameKey());\n if (turns == FreeColObject.UNDEFINED) {\n b = colourButton(qac, name, null, cAlarm,\n stpl(\"report.colony.making.noconstruction.description\")\n .addName(\"%colony%\", colony.getName()));\n } else if (turns >= 0) {\n turns++;\n name += \" \" + Integer.toString(turns);\n b = colourButton(qac, name, null, cGood,\n stpl(\"report.colony.making.constructing.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%buildable%\", build.getNameKey())\n .addAmount(\"%turns%\", turns));;\n } else if (turns < 0) {\n turns = -turns;\n name += \" \" + Integer.toString(turns);\n b = colourButton(qac, name, null, cAlarm,\n stpl(\"report.colony.making.block.description\")\n .addName(\"%colony%\", colony.getName())\n .add(\"%buildable%\", build.getNameKey())\n .addAmount(\"%turns%\", turns));\n }\n }\n reportPanel.add(b, layout);\n layout = null;\n Collections.sort(teachers, teacherComparator);\n for (Unit u : teachers) {\n int left = u.getNeededTurnsOfTraining()\n - u.getTurnsOfTraining();\n JLabel teach;\n if (left <= 0) {\n b = colourButton(cac, Integer.toString(0),\n lib.getUnitImageIcon(u.getType(), Role.DEFAULT,\n true, 0.333), cAlarm,\n stpl(\"report.colony.making.noteach.description\")\n .addName(\"%colony%\", colony.getName())\n .addStringTemplate(\"%teacher%\", u.getLabel()));\n } else {\n b = colourButton(cac, Integer.toString(left),\n lib.getUnitImageIcon(u.getType(), Role.DEFAULT,\n true, 0.333), Color.BLACK,\n stpl(\"report.colony.making.educating.description\")\n .addName(\"%colony%\", colony.getName())\n .addStringTemplate(\"%teacher%\", u.getLabel())\n .addAmount(\"%turns%\", left));\n }\n reportPanel.add(b);\n }\n if (fields <= 0) reportPanel.add(new JLabel(\"\"));\n if (!improve.isEmpty()) {\n addUnits(improve, couldWork, colony, grow);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (grow < 0) {\n b = colourButton(cac, Integer.toString(-grow), null, cAlarm,\n stpl(\"report.colony.shrinking.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", -grow));\n reportPanel.add(b);\n } else if (grow > 0) {\n b = colourButton(cac, Integer.toString(grow), null, cGood,\n stpl(\"report.colony.growing.description\")\n .addName(\"%colony%\", colony.getName())\n .addAmount(\"%amount%\", grow));\n reportPanel.add(b);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n if (!want.isEmpty()) {\n grow = Math.min(grow, colony.getNetProductionOf(foodType)\n / Settlement.FOOD_PER_COLONIST);\n addUnits(want, couldWork, colony, grow);\n } else {\n reportPanel.add(new JLabel(\"\"));\n }\n }\n"} {"input": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tLog.v(\"cr3\", \"creating OptionsDialog\");\n\t\tCoolReader.dumpHeapAllocation();\n\t\tLog.v(\"cr3\", \"calling gc\");\n\t\tSystem.gc();\n\t\tCoolReader.dumpHeapAllocation();\n\t\tLog.v(\"cr3\", \"creating options dialog\");\n\t\tsetTitle(null);\n setCancelable(true);\n setCanceledOnTouchOutside(true);\n mInflater = LayoutInflater.from(getContext());\n mTabs = (TabHost)mInflater.inflate(R.layout.options, null);\n\t\tmTabs.setup();\n\t\tmOptionsStyles = new OptionsListView(getContext());\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_font_face), ReaderView.PROP_FONT_FACE).add(mFontFaces).setDefaultValue(mFontFaces[0]).setIconId(R.drawable.cr3_option_font_face));\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_font_size), ReaderView.PROP_FONT_SIZE).add(mFontSizes).setDefaultValue(\"24\").setIconId(R.drawable.cr3_option_font_size));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_embolden), ReaderView.PROP_FONT_WEIGHT_EMBOLDEN).setDefaultValue(\"0\").setIconId(R.drawable.cr3_option_text_bold));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_embolden), ReaderView.PROP_FONT_WEIGHT_EMBOLDEN).setDefaultValue(\"0\").setIconId(R.drawable.cr3_option_text_bold));\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_font_antialias), ReaderView.PROP_FONT_ANTIALIASING).add(mAntialias, mAntialiasTitles).setDefaultValue(\"2\"));\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_interline_space), ReaderView.PROP_INTERLINE_SPACE).addPercents(mInterlineSpaces).setDefaultValue(\"100\"));\n\t\tmOptionsStyles.add(new NightModeOption(this, getString(R.string.options_inverse_view), ReaderView.PROP_NIGHT_MODE));\n\t\tmOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_text), ReaderView.PROP_FONT_COLOR, 0x000000));\n\t\tmOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_background), ReaderView.PROP_BACKGROUND_COLOR, 0xFFFFFF));\n\t\tmOptionsStyles.add(new TextureOptions(this, getString(R.string.options_background_texture)));\n\t\tmBacklightLevelsTitles[0] = getString(R.string.options_app_backlight_screen_default);\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_app_backlight_screen), ReaderView.PROP_APP_SCREEN_BACKLIGHT).add(mBacklightLevels, mBacklightLevelsTitles).setDefaultValue(\"-1\"));\n\t\tmOptionsStyles.add(new HyphenationOptions(this, getString(R.string.options_hyphenation_dictionary)));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_style_floating_punctuation), ReaderView.PROP_FLOATING_PUNCTUATION).setDefaultValue(\"1\"));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_kerning), ReaderView.PROP_FONT_KERNING_ENABLED).setDefaultValue(\"0\"));\n\t\tmOptionsPage = new OptionsListView(getContext());\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_view_mode), ReaderView.PROP_PAGE_VIEW_MODE).add(mViewModes, mViewModeTitles).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add( new StatusBarOption(this, getString(R.string.options_page_titlebar)));\n\t\tmOptionsPage.add(new BoolOption(this, getString(R.string.options_page_footnotes), ReaderView.PROP_FOOTNOTES).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_orientation), ReaderView.PROP_APP_SCREEN_ORIENTATION).add(mOrientations, mOrientationsTitles).setDefaultValue(\"0\").setIconId(android.R.drawable.ic_menu_always_landscape_portrait));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_landscape_pages), ReaderView.PROP_LANDSCAPE_PAGES).add(mLandscapePages, mLandscapePagesTitles).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_animation), ReaderView.PROP_PAGE_ANIMATION).add(mAnimation, mAnimationTitles).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_left), ReaderView.PROP_PAGE_MARGIN_LEFT).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_right), ReaderView.PROP_PAGE_MARGIN_RIGHT).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_top), ReaderView.PROP_PAGE_MARGIN_TOP).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_bottom), ReaderView.PROP_PAGE_MARGIN_BOTTOM).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsApplication = new OptionsListView(getContext());\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_fullscreen), ReaderView.PROP_APP_FULLSCREEN));\n\t\tmOptionsApplication.add(new DictOptions(this, getString(R.string.options_app_dictionary)));\n\t\tmOptionsApplication.add(new TapZoneOption(this, getString(R.string.options_app_tapzones_normal), ReaderView.PROP_APP_TAP_ZONE_ACTIONS_TAP));\n\t\tmOptionsApplication.add(new KeyMapOption(this, getString(R.string.options_app_key_actions)));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_show_cover_pages), ReaderView.PROP_APP_SHOW_COVERPAGES));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_controls_enable_volume_keys), ReaderView.PROP_CONTROLS_ENABLE_VOLUME_KEYS).setDefaultValue(\"1\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_double_tap_selection), ReaderView.PROP_APP_DOUBLE_TAP_SELECTION).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_tapzone_hilite), ReaderView.PROP_APP_TAP_ZONE_HILIGHT).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_trackball_disable), ReaderView.PROP_APP_TRACKBALL_DISABLED).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_scan_book_props), ReaderView.PROP_APP_BOOK_PROPERTY_SCAN_ENABLED).setDefaultValue(\"1\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_backlight_lock_enabled), ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new ListOption(this, getString(R.string.options_controls_flick_brightness), ReaderView.PROP_APP_FLICK_BACKLIGHT_CONTROL).add(mFlickBrightness, mFlickBrightnessTitles).setDefaultValue(\"1\"));\n\t\tmOptionsStyles.refresh();\n\t\tmOptionsPage.refresh();\n\t\tmOptionsApplication.refresh();\n\t\tTabHost.TabSpec tsStyles = mTabs.newTabSpec(\"Styles\");\n\t\ttsStyles.setIndicator(\"\", \n\t\t\t\tgetContext().getResources().getDrawable(android.R.drawable.ic_menu_view)); \n\t\ttsStyles.setContent(this);\n\t\tmTabs.addTab(tsStyles);\n\t\tTabHost.TabSpec tsPage = mTabs.newTabSpec(\"Page\");\n\t\ttsPage.setIndicator(\"\", getContext().getResources().getDrawable(android.R.drawable.ic_menu_crop)); \n\t\ttsPage.setContent(this);\n\t\tmTabs.addTab(tsPage);\n\t\tTabHost.TabSpec tsApp = mTabs.newTabSpec(\"App\");\n\t\ttsApp.setIndicator(\"\", \n\t\t\t\tgetContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));\n\t\ttsApp.setContent(this);\n\t\tmTabs.addTab(tsApp);\n\t\tTabHost.TabSpec tsControls = mTabs.newTabSpec(\"Controls\");\n\t\ttsControls.setIndicator(getContext().getResources().getString(R.string.tab_options_controls), getContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));\n\t\ttsControls.setContent(this);\n\t\tsetView(mTabs);\n\t\tmOldProperties = new Properties(mProperties);\n\t\tsetOnCancelListener(new OnCancelListener() {\n\t\t\tpublic void onCancel(DialogInterface dialog) {\n\t\t\t\taskApply();\n\t\t\t}\n\t\t});\n\t\tsuper.onCreate(savedInstanceState);\n\t\tLog.v(\"cr3\", \"OptionsDialog is created\");\n\t}\n", "output": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tLog.v(\"cr3\", \"creating OptionsDialog\");\n\t\tCoolReader.dumpHeapAllocation();\n\t\tLog.v(\"cr3\", \"calling gc\");\n\t\tSystem.gc();\n\t\tCoolReader.dumpHeapAllocation();\n\t\tLog.v(\"cr3\", \"creating options dialog\");\n\t\tsetTitle(null);\n setCancelable(true);\n setCanceledOnTouchOutside(true);\n mInflater = LayoutInflater.from(getContext());\n mTabs = (TabHost)mInflater.inflate(R.layout.options, null);\n\t\tmTabs.setup();\n\t\tmOptionsStyles = new OptionsListView(getContext());\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_font_face), ReaderView.PROP_FONT_FACE).add(mFontFaces).setDefaultValue(mFontFaces[0]).setIconId(R.drawable.cr3_option_font_face));\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_font_size), ReaderView.PROP_FONT_SIZE).add(mFontSizes).setDefaultValue(\"24\").setIconId(R.drawable.cr3_option_font_size));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_embolden), ReaderView.PROP_FONT_WEIGHT_EMBOLDEN).setDefaultValue(\"0\").setIconId(R.drawable.cr3_option_text_bold));\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_font_antialias), ReaderView.PROP_FONT_ANTIALIASING).add(mAntialias, mAntialiasTitles).setDefaultValue(\"2\"));\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_interline_space), ReaderView.PROP_INTERLINE_SPACE).addPercents(mInterlineSpaces).setDefaultValue(\"100\"));\n\t\tmOptionsStyles.add(new NightModeOption(this, getString(R.string.options_inverse_view), ReaderView.PROP_NIGHT_MODE));\n\t\tmOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_text), ReaderView.PROP_FONT_COLOR, 0x000000));\n\t\tmOptionsStyles.add(new ColorOption(this, getString(R.string.options_color_background), ReaderView.PROP_BACKGROUND_COLOR, 0xFFFFFF));\n\t\tmOptionsStyles.add(new TextureOptions(this, getString(R.string.options_background_texture)));\n\t\tmBacklightLevelsTitles[0] = getString(R.string.options_app_backlight_screen_default);\n\t\tmOptionsStyles.add(new ListOption(this, getString(R.string.options_app_backlight_screen), ReaderView.PROP_APP_SCREEN_BACKLIGHT).add(mBacklightLevels, mBacklightLevelsTitles).setDefaultValue(\"-1\"));\n\t\tmOptionsStyles.add(new HyphenationOptions(this, getString(R.string.options_hyphenation_dictionary)));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_style_floating_punctuation), ReaderView.PROP_FLOATING_PUNCTUATION).setDefaultValue(\"1\"));\n\t\tmOptionsStyles.add(new BoolOption(this, getString(R.string.options_font_kerning), ReaderView.PROP_FONT_KERNING_ENABLED).setDefaultValue(\"0\"));\n\t\tmOptionsPage = new OptionsListView(getContext());\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_view_mode), ReaderView.PROP_PAGE_VIEW_MODE).add(mViewModes, mViewModeTitles).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add( new StatusBarOption(this, getString(R.string.options_page_titlebar)));\n\t\tmOptionsPage.add(new BoolOption(this, getString(R.string.options_page_footnotes), ReaderView.PROP_FOOTNOTES).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_orientation), ReaderView.PROP_APP_SCREEN_ORIENTATION).add(mOrientations, mOrientationsTitles).setDefaultValue(\"0\").setIconId(android.R.drawable.ic_menu_always_landscape_portrait));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_landscape_pages), ReaderView.PROP_LANDSCAPE_PAGES).add(mLandscapePages, mLandscapePagesTitles).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_animation), ReaderView.PROP_PAGE_ANIMATION).add(mAnimation, mAnimationTitles).setDefaultValue(\"1\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_left), ReaderView.PROP_PAGE_MARGIN_LEFT).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_right), ReaderView.PROP_PAGE_MARGIN_RIGHT).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_top), ReaderView.PROP_PAGE_MARGIN_TOP).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsPage.add(new ListOption(this, getString(R.string.options_page_margin_bottom), ReaderView.PROP_PAGE_MARGIN_BOTTOM).add(mMargins).setDefaultValue(\"5\"));\n\t\tmOptionsApplication = new OptionsListView(getContext());\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_fullscreen), ReaderView.PROP_APP_FULLSCREEN));\n\t\tmOptionsApplication.add(new DictOptions(this, getString(R.string.options_app_dictionary)));\n\t\tmOptionsApplication.add(new TapZoneOption(this, getString(R.string.options_app_tapzones_normal), ReaderView.PROP_APP_TAP_ZONE_ACTIONS_TAP));\n\t\tmOptionsApplication.add(new KeyMapOption(this, getString(R.string.options_app_key_actions)));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_show_cover_pages), ReaderView.PROP_APP_SHOW_COVERPAGES));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_controls_enable_volume_keys), ReaderView.PROP_CONTROLS_ENABLE_VOLUME_KEYS).setDefaultValue(\"1\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_double_tap_selection), ReaderView.PROP_APP_DOUBLE_TAP_SELECTION).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_tapzone_hilite), ReaderView.PROP_APP_TAP_ZONE_HILIGHT).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_trackball_disable), ReaderView.PROP_APP_TRACKBALL_DISABLED).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_scan_book_props), ReaderView.PROP_APP_BOOK_PROPERTY_SCAN_ENABLED).setDefaultValue(\"1\"));\n\t\tmOptionsApplication.add(new BoolOption(this, getString(R.string.options_app_backlight_lock_enabled), ReaderView.PROP_APP_SCREEN_BACKLIGHT_LOCK).setDefaultValue(\"0\"));\n\t\tmOptionsApplication.add(new ListOption(this, getString(R.string.options_controls_flick_brightness), ReaderView.PROP_APP_FLICK_BACKLIGHT_CONTROL).add(mFlickBrightness, mFlickBrightnessTitles).setDefaultValue(\"1\"));\n\t\tmOptionsStyles.refresh();\n\t\tmOptionsPage.refresh();\n\t\tmOptionsApplication.refresh();\n\t\tTabHost.TabSpec tsStyles = mTabs.newTabSpec(\"Styles\");\n\t\ttsStyles.setIndicator(\"\", \n\t\t\t\tgetContext().getResources().getDrawable(android.R.drawable.ic_menu_view)); \n\t\ttsStyles.setContent(this);\n\t\tmTabs.addTab(tsStyles);\n\t\tTabHost.TabSpec tsPage = mTabs.newTabSpec(\"Page\");\n\t\ttsPage.setIndicator(\"\", getContext().getResources().getDrawable(android.R.drawable.ic_menu_crop)); \n\t\ttsPage.setContent(this);\n\t\tmTabs.addTab(tsPage);\n\t\tTabHost.TabSpec tsApp = mTabs.newTabSpec(\"App\");\n\t\ttsApp.setIndicator(\"\", \n\t\t\t\tgetContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));\n\t\ttsApp.setContent(this);\n\t\tmTabs.addTab(tsApp);\n\t\tTabHost.TabSpec tsControls = mTabs.newTabSpec(\"Controls\");\n\t\ttsControls.setIndicator(getContext().getResources().getString(R.string.tab_options_controls), getContext().getResources().getDrawable(android.R.drawable.ic_menu_manage));\n\t\ttsControls.setContent(this);\n\t\tsetView(mTabs);\n\t\tmOldProperties = new Properties(mProperties);\n\t\tsetOnCancelListener(new OnCancelListener() {\n\t\t\tpublic void onCancel(DialogInterface dialog) {\n\t\t\t\taskApply();\n\t\t\t}\n\t\t});\n\t\tsuper.onCreate(savedInstanceState);\n\t\tLog.v(\"cr3\", \"OptionsDialog is created\");\n\t}\n"} {"input": "\tpublic void before(Method method, Object[] args, Object target) throws Throwable {\n\t\tString methodName = method.getName();\n\t\tif (methodName.startsWith(\"save\") || methodName.startsWith(\"create\")) {\n\t\t\tif (args == null || args.length == 0)\n\t\t\t\treturn;\n\t\t\tObject mainArgument = args[0];\n\t\t\tif (mainArgument == null)\n\t\t\t\treturn;\n\t\t\tReflect reflect = new Reflect(OpenmrsObject.class);\n\t\t\tif (reflect.isSuperClass(mainArgument)) {\n\t\t\t\tString other = null;\n\t\t\t\tif (args.length > 1)\n\t\t\t\t\tother = (String) args[1];\n\t\t\t\trecursivelyHandle(SaveHandler.class, (OpenmrsObject) mainArgument, other);\n\t\t\t}\n\t\t\telse if (Reflect.isCollection(mainArgument) && isOpenmrsObjectCollection(mainArgument)) {\n\t\t\t\tString other = null;\n\t\t\t\tif (args.length > 1)\n\t\t\t\t\tother = (String) args[1];\n\t\t\t\tCollection openmrsObjects = (Collection) mainArgument;\n\t\t\t\tfor (OpenmrsObject object : openmrsObjects) {\n\t\t\t\t\trecursivelyHandle(SaveHandler.class, object, other);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (methodName.startsWith(\"void\")) {\n\t\t\tVoidable voidable = (Voidable) args[0];\n\t\t\tString voidReason = (String) args[1];\n\t\t\trecursivelyHandle(VoidHandler.class, voidable, voidReason);\n\t\t} else if (methodName.startsWith(\"unvoid\")) {\n\t\t\tVoidable voidable = (Voidable) args[0];\n\t\t\tDate originalDateVoided = voidable.getDateVoided();\n\t\t\trecursivelyHandle(UnvoidHandler.class, voidable, Context.getAuthenticatedUser(), originalDateVoided, null, null);\n\t\t} else if (methodName.startsWith(\"retire\")) {\n\t\t\tRetireable retirable = (Retireable) args[0];\n\t\t\tString retireReason = (String) args[1];\n\t\t\trecursivelyHandle(RetireHandler.class, retirable, retireReason);\n\t\t} else if (methodName.startsWith(\"unretire\")) {\n\t\t\tRetireable retirable = (Retireable) args[0];\n\t\t\tDate originalDateRetired = retirable.getDateRetired();\n\t\t\trecursivelyHandle(UnretireHandler.class, retirable, Context.getAuthenticatedUser(), originalDateRetired, null,\n\t\t\t null);\n\t\t}\n\t}\n", "output": "\tpublic void before(Method method, Object[] args, Object target) throws Throwable {\n\t\tString methodName = method.getName();\n\t\tif (methodName.startsWith(\"save\") || methodName.startsWith(\"create\")) {\n\t\t\tif (args == null || args.length == 0)\n\t\t\t\treturn;\n\t\t\tObject mainArgument = args[0];\n\t\t\tif (mainArgument == null)\n\t\t\t\treturn;\n\t\t\tReflect reflect = new Reflect(OpenmrsObject.class);\n\t\t\tif (reflect.isSuperClass(mainArgument)) {\n\t\t\t\tString other = null;\n\t\t\t\tif (args.length > 1 && args[1] instanceof String)\n\t\t\t\t\tother = (String) args[1];\n\t\t\t\trecursivelyHandle(SaveHandler.class, (OpenmrsObject) mainArgument, other);\n\t\t\t}\n\t\t\telse if (Reflect.isCollection(mainArgument) && isOpenmrsObjectCollection(mainArgument)) {\n\t\t\t\tString other = null;\n\t\t\t\tif (args.length > 1)\n\t\t\t\t\tother = (String) args[1];\n\t\t\t\tCollection openmrsObjects = (Collection) mainArgument;\n\t\t\t\tfor (OpenmrsObject object : openmrsObjects) {\n\t\t\t\t\trecursivelyHandle(SaveHandler.class, object, other);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (methodName.startsWith(\"void\")) {\n\t\t\tVoidable voidable = (Voidable) args[0];\n\t\t\tString voidReason = (String) args[1];\n\t\t\trecursivelyHandle(VoidHandler.class, voidable, voidReason);\n\t\t} else if (methodName.startsWith(\"unvoid\")) {\n\t\t\tVoidable voidable = (Voidable) args[0];\n\t\t\tDate originalDateVoided = voidable.getDateVoided();\n\t\t\trecursivelyHandle(UnvoidHandler.class, voidable, Context.getAuthenticatedUser(), originalDateVoided, null, null);\n\t\t} else if (methodName.startsWith(\"retire\")) {\n\t\t\tRetireable retirable = (Retireable) args[0];\n\t\t\tString retireReason = (String) args[1];\n\t\t\trecursivelyHandle(RetireHandler.class, retirable, retireReason);\n\t\t} else if (methodName.startsWith(\"unretire\")) {\n\t\t\tRetireable retirable = (Retireable) args[0];\n\t\t\tDate originalDateRetired = retirable.getDateRetired();\n\t\t\trecursivelyHandle(UnretireHandler.class, retirable, Context.getAuthenticatedUser(), originalDateRetired, null,\n\t\t\t null);\n\t\t}\n\t}\n"} {"input": "\tpublic void characters(char ch[], int start, int length) throws SAXException {\n\t\tif (!parsingLoansOrRequests) {\n\t\t\tif (circulationStatusReached) {\n\t\t\t\tcurrentAlephItem.setCirculationStatus(new String(ch, start, length));\n\t\t\t\tcirculationStatusReached = false;\n\t\t\t} else if (holdQueueLengthReached) {\n\t\t\t\tcurrentAlephItem.setHoldQueueLength(Integer.parseInt(new String(ch, start, length)));\n\t\t\t\tholdQueueLengthReached = false;\n\t\t\t} else if (itemDesrciptionReached) {\n\t\t\t\tcurrentAlephItem.setDescription(new String(ch, start, length));\n\t\t\t\titemDesrciptionReached = false;\n\t\t\t} else if (docNoReached) {\n\t\t\t\tcurrentAlephItem.setDocNumber(new String(ch, start, length));\n\t\t\t\tdocNoReached = false;\n\t\t\t} else if (itemSequenceReached) {\n\t\t\t\tcurrentAlephItem.setItemSeqNumber(new String(ch, start, length));\n\t\t\t\titemSequenceReached = false;\n\t\t\t} else if (locationReached) {\n\t\t\t\tcurrentAlephItem.setLocation(new String(ch, start, length));\n\t\t\t\tlocationReached = false;\n\t\t\t} else if (openDateReached) {\n\t\t\t\tcurrentAlephItem.setPublicationDate(new String(ch, start, length));\n\t\t\t\topenDateReached = false;\n\t\t\t} else if (callNoReached) {\n\t\t\t\tcurrentAlephItem.setCallNumber(new String(ch, start, length));\n\t\t\t\tcallNoReached = false;\n\t\t\t} else if (secondCallNoTypeReached) {\n\t\t\t\tsecondCallNoType = new String(ch, start, length);\n\t\t\t\tsecondCallNoTypeReached = false;\n\t\t\t} else if (secondCallNoReached) {\n\t\t\t\tif (secondCallNoType != null && !secondCallNoType.equalsIgnoreCase(\"9\"))\n\t\t\t\t\tcurrentAlephItem.setCallNumber(new String(ch, start, length));\n\t\t\t\telse if (secondCallNoType == null)\n\t\t\t\t\tcurrentAlephItem.setCallNumber(new String(ch, start, length));\n\t\t\t\tsecondCallNoReached = false;\n\t\t\t} else if (copyNoReached) {\n\t\t\t\tcurrentAlephItem.setCopyNumber(new String(ch, start, length));\n\t\t\t\tcopyNoReached = false;\n\t\t\t} else if (barcodeReached) {\n\t\t\t\tcurrentAlephItem.setBarcode(new String(ch, start, length));\n\t\t\t\tbarcodeReached = false;\n\t\t\t} else if (materialReached) {\n\t\t\t\tcurrentAlephItem.setMediumType(new String(ch, start, length));\n\t\t\t\tmaterialReached = false;\n\t\t\t} else if (agencyReached) {\n\t\t\t\tcurrentAlephItem.setAgency(new String(ch, start, length));\n\t\t\t\tagencyReached = false;\n\t\t\t} else if (collectionReached) {\n\t\t\t\tcurrentAlephItem.setCollection(new String(ch, start, length));\n\t\t\t\tcollectionReached = false;\n\t\t\t} else if (bibDescriptionDesired) {\n\t\t\t\tif (authorReached) {\n\t\t\t\t\tcurrentAlephItem.setAuthor(new String(ch, start, length));\n\t\t\t\t\tauthorReached = false;\n\t\t\t\t} else if (isbnReached) {\n\t\t\t\t\tcurrentAlephItem.setIsbn(new String(ch, start, length));\n\t\t\t\t\tisbnReached = false;\n\t\t\t\t} else if (titleReached) {\n\t\t\t\t\tcurrentAlephItem.setTitle(new String(ch, start, length));\n\t\t\t\t\ttitleReached = false;\n\t\t\t\t} else if (publisherReached) {\n\t\t\t\t\tcurrentAlephItem.setPublisher(new String(ch, start, length));\n\t\t\t\t\tpublisherReached = false;\n\t\t\t\t} else if (bibIdReached) {\n\t\t\t\t\tcurrentAlephItem.setBibId(new String(ch, start, length));\n\t\t\t\t\tbibIdReached = false;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (materialReached) {\n\t\t\t\tString mediumTypeParsed = new String(ch, start, length);\n\t\t\t\tMediumType mediumType = AlephUtil.detectMediumType(mediumTypeParsed);\n\t\t\t\tbibliographicDescription.setMediumType(mediumType);\n\t\t\t\tmaterialReached = false;\n\t\t\t} else if (authorReached) {\n\t\t\t\tbibliographicDescription.setAuthor(new String(ch, start, length));\n\t\t\t\tauthorReached = false;\n\t\t\t} else if (isbnReached) {\n\t\t\t\tbibliographicDescription.setBibliographicLevel(null);\n\t\t\t\tisbnReached = false;\n\t\t\t} else if (titleReached) {\n\t\t\t\tbibliographicDescription.setTitle(new String(ch, start, length));\n\t\t\t\ttitleReached = false;\n\t\t\t} else if (publisherReached) {\n\t\t\t\tbibliographicDescription.setPublisher(new String(ch, start, length));\n\t\t\t\tpublisherReached = false;\n\t\t\t} else if (bibIdReached) {\n\t\t\t\tString parsedBibId = new String(ch, start, length);\n\t\t\t\tdocNumber = parsedBibId;\n\t\t\t\tList bibliographicItemIds = new ArrayList();\n\t\t\t\tBibliographicItemId bibId = new BibliographicItemId();\n\t\t\t\tbibId.setBibliographicItemIdentifier(parsedBibId);\n\t\t\t\tbibId.setBibliographicItemIdentifierCode(Version1BibliographicItemIdentifierCode.URI);\n\t\t\t\tbibliographicItemIds.add(bibId);\n\t\t\t\tbibliographicDescription.setBibliographicItemIds(bibliographicItemIds);\n\t\t\t\tbibIdReached = false;\n\t\t\t} else if (itemSequenceReached) {\n\t\t\t\titemSequence = new String(ch, start, length);\n\t\t\t\titemSequenceReached = false;\n\t\t\t} else if (loansHandling) {\n\t\t\t\tif (dueDateReached) {\n\t\t\t\t\tString dateDueParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar dateDue = AlephUtil.parseGregorianCalendarFromAlephDate(dateDueParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateDue(dateDue);\n\t\t\t\t\tdueDateReached = false;\n\t\t\t\t} else if (loanDateReached) {\n\t\t\t\t\tString loanDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar loanDate = AlephUtil.parseGregorianCalendarFromAlephDate(loanDateParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(loanDate);\n\t\t\t\t\tloanDateReached = false;\n\t\t\t\t}\n\t\t\t} else if (holdRequestsHandling) {\n\t\t\t\tif (datePlacedReached) {\n\t\t\t\t\tString datePlacedParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar datePlaced = AlephUtil.parseGregorianCalendarFromAlephDate(datePlacedParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(datePlaced);\n\t\t\t\t\tdatePlacedReached = false;\n\t\t\t\t} else if (hourPlacedReached) {\n\t\t\t\t\tString hourPlacedParsed = new String(ch, start, length);\n\t\t\t\t\tif (!hourPlacedParsed.equalsIgnoreCase(\"00000000\")) {\n\t\t\t\t\t\tGregorianCalendar datePlaced = currentRequestedItem.getDatePlaced();\n\t\t\t\t\t\tGregorianCalendar hourPlaced = new GregorianCalendar(localTimeZone);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\thourPlaced.setTime(AlephConstants.ALEPH_HOUR_FORMATTER.parse(hourPlacedParsed));\n\t\t\t\t\t\t} catch (ParseException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdatePlaced.add(Calendar.HOUR_OF_DAY, hourPlaced.get(Calendar.HOUR_OF_DAY) - 1);\n\t\t\t\t\t\tdatePlaced.add(Calendar.MINUTE, hourPlaced.get(Calendar.MINUTE));\n\t\t\t\t\t\tcurrentRequestedItem.setDatePlaced(datePlaced);\n\t\t\t\t\t}\n\t\t\t\t\thourPlacedReached = false;\n\t\t\t\t} else if (earliestDateNeededReached) {\n\t\t\t\t\tString earliestDateNeededParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar earliestDateNeeded = AlephUtil.parseGregorianCalendarFromAlephDate(earliestDateNeededParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(earliestDateNeeded);\n\t\t\t\t\tearliestDateNeededReached = false;\n\t\t\t\t} else if (needBeforeDateReached) {\n\t\t\t\t\tString needBeforeDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar needBeforeDate = AlephUtil.parseGregorianCalendarFromAlephDate(needBeforeDateParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(needBeforeDate);\n\t\t\t\t\tneedBeforeDateReached = false;\n\t\t\t\t} else if (holdQueueLengthReached) {\n\t\t\t\t\tcurrentRequestedItem.setHoldQueueLength(new BigDecimal(new String(ch, start, length)));\n\t\t\t\t\tholdQueueLengthReached = false;\n\t\t\t\t} else if (pickupLocationReached) {\n\t\t\t\t\tPickupLocation pickupLocation = new PickupLocation(new String(ch, start, length));\n\t\t\t\t\tcurrentRequestedItem.setPickupLocation(pickupLocation);\n\t\t\t\t\tpickupLocationReached = false;\n\t\t\t\t} else if (pickupExpiryDateReached) {\n\t\t\t\t\tString pickupExpiryDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar pickupExpiryDate = AlephUtil.parseGregorianCalendarFromAlephDate(pickupExpiryDateParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(pickupExpiryDate);\n\t\t\t\t\tpickupExpiryDateReached = false;\n\t\t\t\t} else if (reminderLevelReached) {\n\t\t\t\t\tcurrentRequestedItem.setReminderLevel(new BigDecimal(new String(ch, start, length)));\n\t\t\t\t\treminderLevelReached = false;\n\t\t\t\t} else if (requestIdReached) {\n\t\t\t\t\tRequestId requestId = new RequestId();\n\t\t\t\t\trequestId.setRequestIdentifierValue(new String(ch, start, length));\n\t\t\t\t\tcurrentRequestedItem.setRequestId(requestId);\n\t\t\t\t\trequestIdReached = false;\n\t\t\t\t} else if (requestTypeReached) {\n\t\t\t\t\tRequestType requestType = null;\n\t\t\t\t\tString parsedValue = new String(ch, start, length);\n\t\t\t\t\tif (parsedValue == \"30\") \n\t\t\t\t\t\trequestType = Version1RequestType.LOAN;\n\t\t\t\t\telse\n\t\t\t\t\t\trequestType = Version1RequestType.ESTIMATE; \n\t\t\t\t\tcurrentRequestedItem.setRequestType(requestType);\n\t\t\t\t\trequestTypeReached = false;\n\t\t\t\t} else if (pickupDateReached) {\n\t\t\t\t\tString pickupDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar pickupDate = AlephUtil.parseGregorianCalendarFromAlephDate(pickupDateParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(pickupDate);\n\t\t\t\t\tpickupDateReached = false;\n\t\t\t\t} else if (statusReached) {\n\t\t\t\t\tString parsedStatus = new String(ch, start, length);\n\t\t\t\t\tRequestStatusType requestStatusType;\n\t\t\t\t\tif (parsedStatus == \"S\")\n\t\t\t\t\t\trequestStatusType = Version1RequestStatusType.AVAILABLE_FOR_PICKUP;\n\t\t\t\t\telse\n\t\t\t\t\t\trequestStatusType = Version1RequestStatusType.IN_PROCESS;\n\t\t\t\t\tcurrentRequestedItem.setRequestStatusType(requestStatusType);\n\t\t\t\t\tstatusReached = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void characters(char ch[], int start, int length) throws SAXException {\n\t\tif (!parsingLoansOrRequests) {\n\t\t\tif (circulationStatusReached) {\n\t\t\t\tcurrentAlephItem.setCirculationStatus(new String(ch, start, length));\n\t\t\t\tcirculationStatusReached = false;\n\t\t\t} else if (holdQueueLengthReached) {\n\t\t\t\tcurrentAlephItem.setHoldQueueLength(Integer.parseInt(new String(ch, start, length)));\n\t\t\t\tholdQueueLengthReached = false;\n\t\t\t} else if (itemDesrciptionReached) {\n\t\t\t\tcurrentAlephItem.setDescription(new String(ch, start, length));\n\t\t\t\titemDesrciptionReached = false;\n\t\t\t} else if (docNoReached) {\n\t\t\t\tcurrentAlephItem.setDocNumber(new String(ch, start, length));\n\t\t\t\tdocNoReached = false;\n\t\t\t} else if (itemSequenceReached) {\n\t\t\t\tcurrentAlephItem.setItemSeqNumber(new String(ch, start, length));\n\t\t\t\titemSequenceReached = false;\n\t\t\t} else if (locationReached) {\n\t\t\t\tcurrentAlephItem.setLocation(new String(ch, start, length));\n\t\t\t\tlocationReached = false;\n\t\t\t} else if (openDateReached) {\n\t\t\t\tcurrentAlephItem.setPublicationDate(new String(ch, start, length));\n\t\t\t\topenDateReached = false;\n\t\t\t} else if (callNoReached) {\n\t\t\t\tcurrentAlephItem.setCallNumber(new String(ch, start, length));\n\t\t\t\tcallNoReached = false;\n\t\t\t} else if (secondCallNoTypeReached) {\n\t\t\t\tsecondCallNoType = new String(ch, start, length);\n\t\t\t\tsecondCallNoTypeReached = false;\n\t\t\t} else if (secondCallNoReached) {\n\t\t\t\tif (secondCallNoType != null && !secondCallNoType.equalsIgnoreCase(\"9\"))\n\t\t\t\t\tcurrentAlephItem.setCallNumber(new String(ch, start, length));\n\t\t\t\telse if (secondCallNoType == null)\n\t\t\t\t\tcurrentAlephItem.setCallNumber(new String(ch, start, length));\n\t\t\t\tsecondCallNoReached = false;\n\t\t\t} else if (copyNoReached) {\n\t\t\t\tcurrentAlephItem.setCopyNumber(new String(ch, start, length));\n\t\t\t\tcopyNoReached = false;\n\t\t\t} else if (barcodeReached) {\n\t\t\t\tcurrentAlephItem.setBarcode(new String(ch, start, length));\n\t\t\t\tbarcodeReached = false;\n\t\t\t} else if (materialReached) {\n\t\t\t\tcurrentAlephItem.setMediumType(new String(ch, start, length));\n\t\t\t\tmaterialReached = false;\n\t\t\t} else if (agencyReached) {\n\t\t\t\tcurrentAlephItem.setAgency(new String(ch, start, length));\n\t\t\t\tagencyReached = false;\n\t\t\t} else if (collectionReached) {\n\t\t\t\tcurrentAlephItem.setCollection(new String(ch, start, length));\n\t\t\t\tcollectionReached = false;\n\t\t\t} else if (bibDescriptionDesired) {\n\t\t\t\tif (authorReached) {\n\t\t\t\t\tcurrentAlephItem.setAuthor(new String(ch, start, length));\n\t\t\t\t\tauthorReached = false;\n\t\t\t\t} else if (isbnReached) {\n\t\t\t\t\tcurrentAlephItem.setIsbn(new String(ch, start, length));\n\t\t\t\t\tisbnReached = false;\n\t\t\t\t} else if (titleReached) {\n\t\t\t\t\tcurrentAlephItem.setTitle(new String(ch, start, length));\n\t\t\t\t\ttitleReached = false;\n\t\t\t\t} else if (publisherReached) {\n\t\t\t\t\tcurrentAlephItem.setPublisher(new String(ch, start, length));\n\t\t\t\t\tpublisherReached = false;\n\t\t\t\t} else if (bibIdReached) {\n\t\t\t\t\tcurrentAlephItem.setBibId(new String(ch, start, length));\n\t\t\t\t\tbibIdReached = false;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (materialReached) {\n\t\t\t\tString mediumTypeParsed = new String(ch, start, length);\n\t\t\t\tMediumType mediumType = AlephUtil.detectMediumType(mediumTypeParsed);\n\t\t\t\tbibliographicDescription.setMediumType(mediumType);\n\t\t\t\tmaterialReached = false;\n\t\t\t} else if (authorReached) {\n\t\t\t\tbibliographicDescription.setAuthor(new String(ch, start, length));\n\t\t\t\tauthorReached = false;\n\t\t\t} else if (isbnReached) {\n\t\t\t\tbibliographicDescription.setBibliographicLevel(null);\n\t\t\t\tisbnReached = false;\n\t\t\t} else if (titleReached) {\n\t\t\t\tbibliographicDescription.setTitle(new String(ch, start, length));\n\t\t\t\ttitleReached = false;\n\t\t\t} else if (publisherReached) {\n\t\t\t\tbibliographicDescription.setPublisher(new String(ch, start, length));\n\t\t\t\tpublisherReached = false;\n\t\t\t} else if (bibIdReached) {\n\t\t\t\tString parsedBibId = new String(ch, start, length);\n\t\t\t\tdocNumber = parsedBibId;\n\t\t\t\tList bibliographicItemIds = new ArrayList();\n\t\t\t\tBibliographicItemId bibId = new BibliographicItemId();\n\t\t\t\tbibId.setBibliographicItemIdentifier(parsedBibId);\n\t\t\t\tbibId.setBibliographicItemIdentifierCode(Version1BibliographicItemIdentifierCode.URI);\n\t\t\t\tbibliographicItemIds.add(bibId);\n\t\t\t\tbibliographicDescription.setBibliographicItemIds(bibliographicItemIds);\n\t\t\t\tbibIdReached = false;\n\t\t\t} else if (itemSequenceReached) {\n\t\t\t\titemSequence = new String(ch, start, length);\n\t\t\t\titemSequenceReached = false;\n\t\t\t} else if (loansHandling) {\n\t\t\t\tif (dueDateReached) {\n\t\t\t\t\tString dateDueParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar dateDue = AlephUtil.parseGregorianCalendarFromAlephDate(dateDueParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateDue(dateDue);\n\t\t\t\t\tdueDateReached = false;\n\t\t\t\t} else if (loanDateReached) {\n\t\t\t\t\tString loanDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar loanDate = AlephUtil.parseGregorianCalendarFromAlephDate(loanDateParsed);\n\t\t\t\t\tcurrentLoanedItem.setDateCheckedOut(loanDate);\n\t\t\t\t\tloanDateReached = false;\n\t\t\t\t}\n\t\t\t} else if (holdRequestsHandling) {\n\t\t\t\tif (datePlacedReached) {\n\t\t\t\t\tString datePlacedParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar datePlaced = AlephUtil.parseGregorianCalendarFromAlephDate(datePlacedParsed);\n\t\t\t\t\tcurrentRequestedItem.setDatePlaced(datePlaced);\n\t\t\t\t\tdatePlacedReached = false;\n\t\t\t\t} else if (hourPlacedReached) {\n\t\t\t\t\tString hourPlacedParsed = new String(ch, start, length);\n\t\t\t\t\tif (!hourPlacedParsed.equalsIgnoreCase(\"00000000\")) {\n\t\t\t\t\t\tGregorianCalendar datePlaced = currentRequestedItem.getDatePlaced();\n\t\t\t\t\t\tGregorianCalendar hourPlaced = new GregorianCalendar(localTimeZone);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\thourPlaced.setTime(AlephConstants.ALEPH_HOUR_FORMATTER.parse(hourPlacedParsed));\n\t\t\t\t\t\t} catch (ParseException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdatePlaced.add(Calendar.HOUR_OF_DAY, hourPlaced.get(Calendar.HOUR_OF_DAY) - 1);\n\t\t\t\t\t\tdatePlaced.add(Calendar.MINUTE, hourPlaced.get(Calendar.MINUTE));\n\t\t\t\t\t\tcurrentRequestedItem.setDatePlaced(datePlaced);\n\t\t\t\t\t}\n\t\t\t\t\thourPlacedReached = false;\n\t\t\t\t} else if (earliestDateNeededReached) {\n\t\t\t\t\tString earliestDateNeededParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar earliestDateNeeded = AlephUtil.parseGregorianCalendarFromAlephDate(earliestDateNeededParsed);\n\t\t\t\t\tcurrentRequestedItem.setEarliestDateNeeded(earliestDateNeeded);\n\t\t\t\t\tearliestDateNeededReached = false;\n\t\t\t\t} else if (needBeforeDateReached) {\n\t\t\t\t\tString needBeforeDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar needBeforeDate = AlephUtil.parseGregorianCalendarFromAlephDate(needBeforeDateParsed);\n\t\t\t\t\tcurrentRequestedItem.setNeedBeforeDate(needBeforeDate);\n\t\t\t\t\tneedBeforeDateReached = false;\n\t\t\t\t} else if (holdQueueLengthReached) {\n\t\t\t\t\tcurrentRequestedItem.setHoldQueueLength(new BigDecimal(new String(ch, start, length)));\n\t\t\t\t\tholdQueueLengthReached = false;\n\t\t\t\t} else if (pickupLocationReached) {\n\t\t\t\t\tPickupLocation pickupLocation = new PickupLocation(new String(ch, start, length));\n\t\t\t\t\tcurrentRequestedItem.setPickupLocation(pickupLocation);\n\t\t\t\t\tpickupLocationReached = false;\n\t\t\t\t} else if (pickupExpiryDateReached) {\n\t\t\t\t\tString pickupExpiryDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar pickupExpiryDate = AlephUtil.parseGregorianCalendarFromAlephDate(pickupExpiryDateParsed);\n\t\t\t\t\tcurrentRequestedItem.setPickupExpiryDate(pickupExpiryDate);\n\t\t\t\t\tpickupExpiryDateReached = false;\n\t\t\t\t} else if (reminderLevelReached) {\n\t\t\t\t\tcurrentRequestedItem.setReminderLevel(new BigDecimal(new String(ch, start, length)));\n\t\t\t\t\treminderLevelReached = false;\n\t\t\t\t} else if (requestIdReached) {\n\t\t\t\t\tRequestId requestId = new RequestId();\n\t\t\t\t\trequestId.setRequestIdentifierValue(new String(ch, start, length));\n\t\t\t\t\tcurrentRequestedItem.setRequestId(requestId);\n\t\t\t\t\trequestIdReached = false;\n\t\t\t\t} else if (requestTypeReached) {\n\t\t\t\t\tRequestType requestType = null;\n\t\t\t\t\tString parsedValue = new String(ch, start, length);\n\t\t\t\t\tif (parsedValue == \"30\") \n\t\t\t\t\t\trequestType = Version1RequestType.LOAN;\n\t\t\t\t\telse\n\t\t\t\t\t\trequestType = Version1RequestType.ESTIMATE; \n\t\t\t\t\tcurrentRequestedItem.setRequestType(requestType);\n\t\t\t\t\trequestTypeReached = false;\n\t\t\t\t} else if (pickupDateReached) {\n\t\t\t\t\tString pickupDateParsed = new String(ch, start, length);\n\t\t\t\t\tGregorianCalendar pickupDate = AlephUtil.parseGregorianCalendarFromAlephDate(pickupDateParsed);\n\t\t\t\t\tcurrentRequestedItem.setPickupDate(pickupDate);\n\t\t\t\t\tpickupDateReached = false;\n\t\t\t\t} else if (statusReached) {\n\t\t\t\t\tString parsedStatus = new String(ch, start, length);\n\t\t\t\t\tRequestStatusType requestStatusType;\n\t\t\t\t\tif (parsedStatus == \"S\")\n\t\t\t\t\t\trequestStatusType = Version1RequestStatusType.AVAILABLE_FOR_PICKUP;\n\t\t\t\t\telse\n\t\t\t\t\t\trequestStatusType = Version1RequestStatusType.IN_PROCESS;\n\t\t\t\t\tcurrentRequestedItem.setRequestStatusType(requestStatusType);\n\t\t\t\t\tstatusReached = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic synchronized void executeMojo() throws MojoExecutionException {\n\t\tif (\"pom\".equalsIgnoreCase(this.mavenProject.getPackaging())) { \n\t\t\tString key = ArtifactUtils.key(this.mavenProject.getGroupId(), this.mavenProject.getArtifactId(), this.mavenProject.getVersion());\n\t\t\tinfo(\"Ignoring project \", \n\t\t\t\t\tkey, \" because it is a source-less project.\"); \n\t\t\treturn;\n\t\t}\n\t\tFile classesDirectory = new File(getOutputDirectory(), CLASSES_DIR);\n\t\tFile metainfDirectory = new File(classesDirectory, METAINF_DIR);\n\t\tFile licenseDirectory = new File(metainfDirectory, LICENSE_DIR);\n\t\tlicenseDirectory.mkdirs();\n\t\tSet coreInstalled = new HashSet();\n\t\tLicense lic;\n\t\tURL resource;\n\t\tString filename;\n\t\tFile licFile;\n\t\tMap includedLicenses = new HashMap();\n\t\tPattern re1 = Pattern.compile(\"^([^:]+):(.+):(.+)$\"); \n\t\tPattern re2 = Pattern.compile(\"^([^:]+):(.+)$\"); \n\t\tif (this.thirdPartyLicenses != null) {\n\t\t\tfor (String tpl : this.thirdPartyLicenses) {\n\t\t\t\tMatcher matcher = re1.matcher(tpl);\n\t\t\t\tif (matcher.matches()) {\n\t\t\t\t\tString l = matcher.group(1);\n\t\t\t\t\tString f = matcher.group(2);\n\t\t\t\t\tlic = License.parse(l, null);\n\t\t\t\t\tif (lic != null) {\n\t\t\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\t\t\tsb.append(this.name);\n\t\t\t\t\t\tsb.append(\"_\"); \n\t\t\t\t\t\tString b = f.replaceAll(\"[/\\\\:]\", \".\"); \n\t\t\t\t\t\tb = b.replaceAll(\"^\\\\.\", \"\"); \n\t\t\t\t\t\tsb.append(b);\n\t\t\t\t\t\tincludedLicenses.put(sb.toString(), lic);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tmatcher = re2.matcher(tpl);\n\t\t\t\t\tif (matcher.matches()) {\n\t\t\t\t\t\tString l = matcher.group(1);\n\t\t\t\t\t\tString g = matcher.group(2);\n\t\t\t\t\t\tString a = matcher.group(3);\n\t\t\t\t\t\tlic = License.parse(l, null);\n\t\t\t\t\t\tif (lic != null) {\n\t\t\t\t\t\t\tString depName = \"mvndep_\"+g+\"_\"+a; \n\t\t\t\t\t\t\tincludedLicenses.put(depName, lic);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tfor (String license : this.licenses) {\n\t\t\t\tlic = License.parse(license, License.GPLv3);\n\t\t\t\tif (!coreInstalled.contains(lic)) {\n\t\t\t\t\tresource = lic.getFullTextResource();\n\t\t\t\t\tif (resource != null) {\n\t\t\t\t\t\tfilename = LICENSE_FILENAME_PATTERN.replaceAll(\"%s\", this.name); \n\t\t\t\t\t\tfilename = filename.replaceAll(\"%l\", lic.name()); \n\t\t\t\t\t\tinfo(\"Installing license: \", \n\t\t\t\t\t\t\t\tlic.getLicenseName(), \", into \", \n\t\t\t\t\t\t\t\tfilename);\n\t\t\t\t\t\tlicFile = new File(licenseDirectory, filename);\n\t\t\t\t\t\tfileCopy(resource, licFile);\n\t\t\t\t\t\tcoreInstalled.add(lic);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new MojoExecutionException(\"Unable to find the full text of the license: \" + lic.getLicenseName()); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (Entry licenseMap : includedLicenses.entrySet()) {\n\t\t\t\tlic = licenseMap.getValue();\n\t\t\t\tresource = lic.getFullTextResource();\n\t\t\t\tif (resource != null) {\n\t\t\t\t\tfilename = LICENSE_FILENAME_PATTERN.replaceAll(\"%s\", licenseMap.getKey()); \n\t\t\t\t\tfilename = filename.replaceAll(\"%l\", lic.name()); \n\t\t\t\t\tinfo(\"Installing included source code license: \", \n\t\t\t\t\t\t\tlic.getLicenseName(), \", into \", \n\t\t\t\t\t\t\tfilename);\n\t\t\t\t\tlicFile = new File(licenseDirectory, filename);\n\t\t\t\t\tfileCopy(resource, licFile);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new MojoExecutionException(\"Unable to find the full text of the license: \" + lic.getLicenseName()); \n\t\t\t\t}\n\t\t\t}\n\t\t\tfilename = NOTICE_FILENAME_PATTERN.replaceAll(\"%s\", this.name); \n\t\t\tinfo(\"Installing license notice: \", \n\t\t\t\t\tfilename);\n\t\t\tStringBuilder addParts = new StringBuilder();\n\t\t\tfor (Entry licenseMap : includedLicenses.entrySet()) {\n\t\t\t\tlic = licenseMap.getValue();\n\t\t\t\tif (lic != null) {\n\t\t\t\t\tString s = getLString(InstallLicenseMojo.class, \"NOTICE_SENTENCE\", \n\t\t\t\t\t\t\tlic.getLicenseName(), licenseMap.getKey());\n\t\t\t\t\taddParts.append(s);\n\t\t\t\t}\n\t\t\t}\n\t\t\tStringBuilder fullLicenseText = new StringBuilder();\n\t\t\tint n = 0;\n\t\t\tfor (License l : coreInstalled) {\n\t\t\t\tif (n > 0) {\n\t\t\t\t\tif (n == coreInstalled.size() - 1) {\n\t\t\t\t\t\tfullLicenseText.append(getLString(InstallLicenseMojo.class, \"AND\")); \n\t\t\t\t\t} else {\n\t\t\t\t\t\tfullLicenseText.append(getLString(InstallLicenseMojo.class, \"COMMA\")); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfullLicenseText.append(l.getLicenseName());\n\t\t\t\t++n;\n\t\t\t}\n\t\t\tString noticeText = getLString(InstallLicenseMojo.class, \"NOTICE_TEXT\", \n\t\t\t\t\tthis.name, this.copyrightDates, this.copyrighters, fullLicenseText.toString(), addParts.toString());\n\t\t\tFile noticeFile = new File(metainfDirectory, filename);\n\t\t\tFileWriter fileWriter = new FileWriter(noticeFile);\n\t\t\ttry {\n\t\t\t\tfileWriter.write(noticeText);\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tfileWriter.close();\n\t\t\t}\n\t\t\tfilename = AUTHOR_FILENAME_PATTERN.replaceAll(\"%s\", this.name); \n\t\t\tinfo(\"Installing authors: \", \n\t\t\t\t\tfilename);\n\t\t\tStringBuilder authorsText = new StringBuilder();\n\t\t\tif (this.projectURL != null) {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"AUTHOR_INTRO\", this.projectURL.toExternalForm())); \n\t\t\t} else {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"AUTHOR_INTRO\", \"\")); \n\t\t\t}\n\t\t\tauthorsText.append(\"\\n\\n\"); \n\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"DEVELOPER_TITLE\", this.name)); \n\t\t\tauthorsText.append(\"\\n\\n\"); \n\t\t\tfor (Developer developer : this.mavenProject.getDevelopers()) {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"DEVELOPER\", \n\t\t\t\t\t\tdeveloper.getName(), developer.getEmail()));\n\t\t\t\tauthorsText.append(\"\\n\"); \n\t\t\t}\n\t\t\tauthorsText.append(\"\\n\\n\\n\"); \n\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"CONTRIBUTOR_TITLE\", this.name)); \n\t\t\tauthorsText.append(\"\\n\\n\"); \n\t\t\tfor (Contributor contributor : this.mavenProject.getContributors()) {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"DEVELOPER\", \n\t\t\t\t\t\tcontributor.getName(), contributor.getEmail()));\n\t\t\t\tauthorsText.append(\"\\n\"); \n\t\t\t}\n\t\t\tFile authorFile = new File(metainfDirectory, filename);\n\t\t\tfileWriter = new FileWriter(authorFile);\n\t\t\ttry {\n\t\t\t\tfileWriter.write(authorsText.toString());\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tfileWriter.close();\n\t\t\t}\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n", "output": "\tpublic synchronized void executeMojo() throws MojoExecutionException {\n\t\tif (\"pom\".equalsIgnoreCase(this.mavenProject.getPackaging())) { \n\t\t\tString key = ArtifactUtils.key(this.mavenProject.getGroupId(), this.mavenProject.getArtifactId(), this.mavenProject.getVersion());\n\t\t\tinfo(\"Ignoring project \", \n\t\t\t\t\tkey, \" because it is a source-less project.\"); \n\t\t\treturn;\n\t\t}\n\t\tFile classesDirectory = new File(getOutputDirectory(), CLASSES_DIR);\n\t\tFile metainfDirectory = new File(classesDirectory, METAINF_DIR);\n\t\tFile licenseDirectory = new File(metainfDirectory, LICENSE_DIR);\n\t\tlicenseDirectory.mkdirs();\n\t\tSet coreInstalled = new HashSet();\n\t\tLicense lic;\n\t\tURL resource;\n\t\tString filename;\n\t\tFile licFile;\n\t\tMap includedLicenses = new HashMap();\n\t\tPattern re1 = Pattern.compile(\"^([^:]+):(.+):(.+)$\"); \n\t\tPattern re2 = Pattern.compile(\"^([^:]+):(.+)$\"); \n\t\tif (this.thirdPartyLicenses != null) {\n\t\t\tfor (String tpl : this.thirdPartyLicenses) {\n\t\t\t\tMatcher matcher = re1.matcher(tpl);\n\t\t\t\tif (matcher.matches()) {\n\t\t\t\t\tString l = matcher.group(1);\n\t\t\t\t\tString g = matcher.group(2);\n\t\t\t\t\tString a = matcher.group(3);\n\t\t\t\t\tlic = License.parse(l, null);\n\t\t\t\t\tif (lic != null) {\n\t\t\t\t\t\tString depName = \"mvndep_\"+g+\"_\"+a; \n\t\t\t\t\t\tincludedLicenses.put(depName, lic);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tmatcher = re2.matcher(tpl);\n\t\t\t\t\tif (matcher.matches()) {\n\t\t\t\t\t\tString l = matcher.group(1);\n\t\t\t\t\t\tString f = matcher.group(2);\n\t\t\t\t\t\tlic = License.parse(l, null);\n\t\t\t\t\t\tif (lic != null) {\n\t\t\t\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\t\t\t\tsb.append(this.name);\n\t\t\t\t\t\t\tsb.append(\"_\"); \n\t\t\t\t\t\t\tString b = f.replaceAll(\"[/\\\\:]\", \".\"); \n\t\t\t\t\t\t\tb = b.replaceAll(\"^\\\\.\", \"\"); \n\t\t\t\t\t\t\tsb.append(b);\n\t\t\t\t\t\t\tincludedLicenses.put(sb.toString(), lic);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttry {\n\t\t\tfor (String license : this.licenses) {\n\t\t\t\tlic = License.parse(license, License.GPLv3);\n\t\t\t\tif (!coreInstalled.contains(lic)) {\n\t\t\t\t\tresource = lic.getFullTextResource();\n\t\t\t\t\tif (resource != null) {\n\t\t\t\t\t\tfilename = LICENSE_FILENAME_PATTERN.replaceAll(\"%s\", this.name); \n\t\t\t\t\t\tfilename = filename.replaceAll(\"%l\", lic.name()); \n\t\t\t\t\t\tinfo(\"Installing license: \", \n\t\t\t\t\t\t\t\tlic.getLicenseName(), \", into \", \n\t\t\t\t\t\t\t\tfilename);\n\t\t\t\t\t\tlicFile = new File(licenseDirectory, filename);\n\t\t\t\t\t\tfileCopy(resource, licFile);\n\t\t\t\t\t\tcoreInstalled.add(lic);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new MojoExecutionException(\"Unable to find the full text of the license: \" + lic.getLicenseName()); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (Entry licenseMap : includedLicenses.entrySet()) {\n\t\t\t\tlic = licenseMap.getValue();\n\t\t\t\tresource = lic.getFullTextResource();\n\t\t\t\tif (resource != null) {\n\t\t\t\t\tfilename = LICENSE_FILENAME_PATTERN.replaceAll(\"%s\", licenseMap.getKey()); \n\t\t\t\t\tfilename = filename.replaceAll(\"%l\", lic.name()); \n\t\t\t\t\tinfo(\"Installing included source code license: \", \n\t\t\t\t\t\t\tlic.getLicenseName(), \", into \", \n\t\t\t\t\t\t\tfilename);\n\t\t\t\t\tlicFile = new File(licenseDirectory, filename);\n\t\t\t\t\tfileCopy(resource, licFile);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new MojoExecutionException(\"Unable to find the full text of the license: \" + lic.getLicenseName()); \n\t\t\t\t}\n\t\t\t}\n\t\t\tfilename = NOTICE_FILENAME_PATTERN.replaceAll(\"%s\", this.name); \n\t\t\tinfo(\"Installing license notice: \", \n\t\t\t\t\tfilename);\n\t\t\tStringBuilder addParts = new StringBuilder();\n\t\t\tfor (Entry licenseMap : includedLicenses.entrySet()) {\n\t\t\t\tlic = licenseMap.getValue();\n\t\t\t\tif (lic != null) {\n\t\t\t\t\tString s = getLString(InstallLicenseMojo.class, \"NOTICE_SENTENCE\", \n\t\t\t\t\t\t\tlic.getLicenseName(), licenseMap.getKey());\n\t\t\t\t\taddParts.append(s);\n\t\t\t\t}\n\t\t\t}\n\t\t\tStringBuilder fullLicenseText = new StringBuilder();\n\t\t\tint n = 0;\n\t\t\tfor (License l : coreInstalled) {\n\t\t\t\tif (n > 0) {\n\t\t\t\t\tif (n == coreInstalled.size() - 1) {\n\t\t\t\t\t\tfullLicenseText.append(getLString(InstallLicenseMojo.class, \"AND\")); \n\t\t\t\t\t} else {\n\t\t\t\t\t\tfullLicenseText.append(getLString(InstallLicenseMojo.class, \"COMMA\")); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfullLicenseText.append(l.getLicenseName());\n\t\t\t\t++n;\n\t\t\t}\n\t\t\tString noticeText = getLString(InstallLicenseMojo.class, \"NOTICE_TEXT\", \n\t\t\t\t\tthis.name, this.copyrightDates, this.copyrighters, fullLicenseText.toString(), addParts.toString());\n\t\t\tFile noticeFile = new File(metainfDirectory, filename);\n\t\t\tFileWriter fileWriter = new FileWriter(noticeFile);\n\t\t\ttry {\n\t\t\t\tfileWriter.write(noticeText);\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tfileWriter.close();\n\t\t\t}\n\t\t\tfilename = AUTHOR_FILENAME_PATTERN.replaceAll(\"%s\", this.name); \n\t\t\tinfo(\"Installing authors: \", \n\t\t\t\t\tfilename);\n\t\t\tStringBuilder authorsText = new StringBuilder();\n\t\t\tif (this.projectURL != null) {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"AUTHOR_INTRO\", this.projectURL.toExternalForm())); \n\t\t\t} else {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"AUTHOR_INTRO\", \"\")); \n\t\t\t}\n\t\t\tauthorsText.append(\"\\n\\n\"); \n\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"DEVELOPER_TITLE\", this.name)); \n\t\t\tauthorsText.append(\"\\n\\n\"); \n\t\t\tfor (Developer developer : this.mavenProject.getDevelopers()) {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"DEVELOPER\", \n\t\t\t\t\t\tdeveloper.getName(), developer.getEmail()));\n\t\t\t\tauthorsText.append(\"\\n\"); \n\t\t\t}\n\t\t\tauthorsText.append(\"\\n\\n\\n\"); \n\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"CONTRIBUTOR_TITLE\", this.name)); \n\t\t\tauthorsText.append(\"\\n\\n\"); \n\t\t\tfor (Contributor contributor : this.mavenProject.getContributors()) {\n\t\t\t\tauthorsText.append(getLString(InstallLicenseMojo.class, \"DEVELOPER\", \n\t\t\t\t\t\tcontributor.getName(), contributor.getEmail()));\n\t\t\t\tauthorsText.append(\"\\n\"); \n\t\t\t}\n\t\t\tFile authorFile = new File(metainfDirectory, filename);\n\t\t\tfileWriter = new FileWriter(authorFile);\n\t\t\ttry {\n\t\t\t\tfileWriter.write(authorsText.toString());\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tfileWriter.close();\n\t\t\t}\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n"} {"input": " public boolean readRichSequence(BufferedReader reader,\n SymbolTokenization symParser,\n RichSeqIOListener rlistener,\n Namespace ns)\n throws IllegalSymbolException, IOException, ParseException {\n tax = null;\n organism = null;\n accession = null;\n boolean hasAnotherSequence = true;\n rlistener.startSequence();\n if (ns==null) ns=RichObjectFactory.getDefaultNamespace();\n rlistener.setNamespace(ns);\n String sectionKey = null;\n int xrefCount = 0;\n do {\n List section = this.readSection(reader);\n sectionKey = ((String[])section.get(0))[0];\n if(sectionKey == null){\n String message = ParseException.newMessage(this.getClass(), accession, \"No section key\", \"Not set\", sectionToString(section));\n throw new ParseException(message);\n }\n if (sectionKey.equals(LOCUS_TAG)) {\n String loc = ((String[])section.get(0))[1];\n Matcher m = lp.matcher(loc);\n Matcher mPre87 = lpPre87.matcher(loc);\n if (m.matches()) {\n rlistener.setName(m.group(1));\n rlistener.setAccession(m.group(1));\n rlistener.setVersion(Integer.parseInt(m.group(2)));\n rlistener.setCircular(m.group(3).equals(\"circular\"));\n rlistener.addSequenceProperty(Terms.getMolTypeTerm(),m.group(4));\n rlistener.addSequenceProperty(Terms.getDataClassTerm(),m.group(5));\n rlistener.setDivision(m.group(6));\n } else if (mPre87.matches()) {\n rlistener.setName(mPre87.group(1));\n if (mPre87.group(3)!=null) {\n rlistener.addSequenceProperty(Terms.getGenomicTerm(),null);\n }\n rlistener.addSequenceProperty(Terms.getMolTypeTerm(),mPre87.group(4));\n rlistener.setDivision(mPre87.group(5));\n String circular = mPre87.group(2);\n if (circular!=null) rlistener.setCircular(true);\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"Not Set\",\"Bad ID line found\", sectionToString(section));\n throw new ParseException(message);\n }\n } else if (sectionKey.equals(DEFINITION_TAG)) {\n rlistener.setDescription(((String[])section.get(0))[1]);\n } else if (sectionKey.equals(SOURCE_TAG)) {\n for (int i = 1; i < section.size(); i++) {\n sectionKey = ((String[])section.get(i))[0];\n if (sectionKey.equals(ORGANELLE_TAG)) {\n rlistener.addSequenceProperty(Terms.getOrganelleTerm(), ((String[])section.get(i))[1].trim());\n break; \n }\n }\n } else if (sectionKey.equals(DATE_TAG)) {\n String chunk = ((String[])section.get(0))[1].trim();\n Matcher dm = dp.matcher(chunk);\n if (dm.matches()) {\n String date = dm.group(1);\n String rel = dm.group(3);\n String type = dm.group(4);\n if (type.equals(\"Created\")) {\n rlistener.addSequenceProperty(Terms.getDateCreatedTerm(), date);\n rlistener.addSequenceProperty(Terms.getRelCreatedTerm(), rel);\n } else if (type.equals(\"Last updated, Version \")) {\n rlistener.addSequenceProperty(Terms.getDateUpdatedTerm(), date);\n rlistener.addSequenceProperty(Terms.getRelUpdatedTerm(), rel);\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad date type found\",sectionToString(section));\n throw new ParseException(message);\n }\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad date line found\",sectionToString(section));\n throw new ParseException(message);\n }\n } else if (sectionKey.equals(ACCESSION_TAG)) {\n String[] accs = ((String[])section.get(0))[1].split(\";\");\n accession = accs[0].trim();\n rlistener.setAccession(accession);\n for (int i = 1; i < accs.length; i++) {\n rlistener.addSequenceProperty(Terms.getAdditionalAccessionTerm(),accs[i].trim());\n }\n } else if (sectionKey.equals(VERSION_TAG)) {\n String ver = ((String[])section.get(0))[1];\n Matcher m = vp.matcher(ver);\n if (m.matches()) {\n String verAcc = m.group(1);\n if (!accession.equals(verAcc)) {\n rlistener.addSequenceProperty(Terms.getAdditionalAccessionTerm(),accession);\n accession = verAcc;\n rlistener.setAccession(accession);\n }\n rlistener.setVersion(Integer.parseInt(m.group(2)));\n } else {\n rlistener.addSequenceProperty(Terms.getVersionLineTerm(),ver);\n }\n } else if (sectionKey.equals(KEYWORDS_TAG)) {\n String val = ((String[])section.get(0))[1];\n val = val.substring(0,val.length()-1); \n String[] kws = val.split(\";\");\n for (int i = 0; i < kws.length; i++) {\n rlistener.addSequenceProperty(Terms.getKeywordTerm(), kws[i].trim());\n }\n } else if (sectionKey.equals(DATABASE_XREF_TAG)) {\n String val = ((String[])section.get(0))[1];\n val = val.substring(0,val.length()-1); \n String[] parts = val.split(\";\");\n CrossRef crossRef = (CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{parts[0].trim(),parts[1].trim(), new Integer(0)});\n for (int j = 2; j < parts.length; j++) {\n Note note = new SimpleNote(Terms.getAdditionalAccessionTerm(),parts[j].trim(),j-1);\n try {\n ((RichAnnotation)crossRef.getAnnotation()).addNote(note);\n } catch (ChangeVetoException ce) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Could not annotate identifier terms\",sectionToString(section));\n ParseException pe = new ParseException(message);\n pe.initCause(ce);\n throw pe;\n }\n }\n RankedCrossRef rcrossRef = new SimpleRankedCrossRef(crossRef, ++xrefCount);\n rlistener.setRankedCrossRef(rcrossRef);\n } else if (sectionKey.equals(REFERENCE_TAG) && !this.getElideReferences()) {\n String refrank = ((String[])section.get(0))[1];\n int ref_rank = Integer.parseInt(refrank.substring(1,refrank.length()-1));\n int ref_start = -999;\n int ref_end = -999;\n String consortium = null;\n String authors = null;\n String title = null;\n String locator = null;\n String pubmed = null;\n String medline = null;\n String doi = null;\n String remark = null;\n for (int i = 1; i < section.size(); i++) {\n String key = ((String[])section.get(i))[0];\n String val = ((String[])section.get(i))[1];\n if (key.equals(AUTHORS_TAG)) {\n if (val.endsWith(\";\")) val = val.substring(0,val.length()-1); \n authors = val;\n }\n if (key.equals(CONSORTIUM_TAG)) {\n if (val.endsWith(\";\")) val = val.substring(0,val.length()-1); \n consortium = val;\n }\n if (key.equals(TITLE_TAG)) {\n if (val.length()>1) {\n if (val.endsWith(\";\")) val = val.substring(0,val.length()-1); \n if (val.endsWith(\"\\\"\")) val = val.substring(1,val.length()-1); \n title = val.replace('\\n',' '); \n } else title=null; \n }\n if (key.equals(LOCATOR_TAG)) {\n if (val.endsWith(\".\")) val = val.substring(0,val.length()-1); \n locator = val;\n }\n if (key.equals(REFERENCE_XREF_TAG)) {\n String[] refs = val.split(\"\\\\.(\\\\s+|$)\");\n for (int j = 0 ; j < refs.length; j++) {\n if (refs[j].trim().length()==0) continue;\n String[] parts = refs[j].split(\";\");\n String db = parts[0];\n String ref = parts[1];\n if (db.equalsIgnoreCase(Terms.PUBMED_KEY)) pubmed = ref;\n else if (db.equalsIgnoreCase(Terms.MEDLINE_KEY)) medline = ref;\n else if (db.equalsIgnoreCase(Terms.DOI_KEY)) doi = ref;\n }\n }\n if (key.equals(REMARK_TAG)) remark = val.replace('\\n',' '); \n if (key.equals(REFERENCE_POSITION_TAG)) {\n Matcher m = rpp.matcher(val);\n if (m.matches()) {\n ref_start = Integer.parseInt(m.group(1));\n if(m.group(2) != null)\n ref_end = Integer.parseInt(m.group(3));\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad reference line found\",sectionToString(section));\n throw new ParseException(message);\n }\n }\n }\n try {\n List authSet = DocRefAuthor.Tools.parseAuthorString(authors);\n if (consortium!=null) authSet.add(new SimpleDocRefAuthor(consortium, true, false));\n DocRef dr = (DocRef)RichObjectFactory.getObject(SimpleDocRef.class,new Object[]{authSet,locator,title});\n if (medline!=null) dr.setCrossref((CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{Terms.MEDLINE_KEY, medline, new Integer(0)}));\n else if (pubmed!=null) dr.setCrossref((CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{Terms.PUBMED_KEY, pubmed, new Integer(0)}));\n else if (doi!=null) dr.setCrossref((CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{Terms.DOI_KEY, doi, new Integer(0)}));\n if (!this.getElideComments()) dr.setRemark(remark);\n RankedDocRef rdr = new SimpleRankedDocRef(dr,\n (ref_start != -999 ? new Integer(ref_start) : null),\n (ref_end != -999 ? new Integer(ref_end) : null),\n ref_rank);\n rlistener.setRankedDocRef(rdr);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(e, message);\n }\n } else if (sectionKey.equals(COMMENT_TAG) && !this.getElideComments()) {\n rlistener.setComment(((String[])section.get(0))[1]);\n } else if (sectionKey.equals(FEATURE_TAG) && !this.getElideFeatures()) {\n boolean seenAFeature = false;\n for (int i = 1 ; i < section.size(); i++) {\n String key = ((String[])section.get(i))[0];\n String val = ((String[])section.get(i))[1];\n if (key.startsWith(\"/\")) {\n key = key.substring(1); \n val = val.replaceAll(\"\\\\s*[\\\\n\\\\r]+\\\\s*\",\" \").trim();\n if (val.startsWith(\"\\\"\")) val = val.substring(1,val.length()-1); \n if (key.equalsIgnoreCase(\"db_xref\")) {\n Matcher m = dbxp.matcher(val);\n if (m.matches()) {\n String dbname = m.group(1);\n String raccession = m.group(2);\n if (dbname.equalsIgnoreCase(\"taxon\")) {\n tax = (NCBITaxon)RichObjectFactory.getObject(SimpleNCBITaxon.class, new Object[]{Integer.valueOf(raccession)});\n rlistener.setTaxon(tax);\n try {\n if (organism!=null) tax.addName(NCBITaxon.SCIENTIFIC,organism);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(e, message);\n }\n } else {\n try {\n CrossRef cr = (CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{dbname, raccession, new Integer(0)});\n RankedCrossRef rcr = new SimpleRankedCrossRef(cr, 0);\n rlistener.getCurrentFeature().addRankedCrossRef(rcr);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(e, message);\n }\n }\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad dbxref found\",sectionToString(section));\n throw new ParseException(message);\n }\n } else if (key.equalsIgnoreCase(\"organism\")) {\n try {\n organism = val;\n if (tax!=null) tax.addName(NCBITaxon.SCIENTIFIC,organism);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(message);\n }\n } else {\n if (key.equalsIgnoreCase(\"translation\")) {\n val = val.replaceAll(\"\\\\s+\",\"\");\n }\n rlistener.addFeatureProperty(RichObjectFactory.getDefaultOntology().getOrCreateTerm(key),val);\n }\n } else {\n if (seenAFeature) rlistener.endFeature();\n RichFeature.Template templ = new RichFeature.Template();\n templ.annotation = new SimpleRichAnnotation();\n templ.sourceTerm = Terms.getEMBLTerm();\n templ.typeTerm = RichObjectFactory.getDefaultOntology().getOrCreateTerm(key);\n templ.featureRelationshipSet = new TreeSet();\n templ.rankedCrossRefs = new TreeSet();\n String tidyLocStr = val.replaceAll(\"\\\\s+\",\"\");\n templ.location = GenbankLocationParser.parseLocation(ns, accession, tidyLocStr);\n rlistener.startFeature(templ);\n seenAFeature = true;\n }\n }\n if (seenAFeature) rlistener.endFeature();\n } else if (sectionKey.equals(START_SEQUENCE_TAG) && !this.getElideSymbols()) {\n StringBuffer seq = new StringBuffer();\n for (int i = 0 ; i < section.size(); i++) seq.append(((String[])section.get(i))[1]);\n try {\n SymbolList sl = new SimpleSymbolList(symParser,\n seq.toString().replaceAll(\"\\\\s+\",\"\").replaceAll(\"[\\\\.|~]\",\"-\"));\n rlistener.addSymbols(symParser.getAlphabet(),\n (Symbol[])(sl.toList().toArray(new Symbol[0])),\n 0, sl.length());\n } catch (Exception e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad sequence\",sectionToString(section));\n throw new ParseException(e, message);\n }\n }\n } while (!sectionKey.equals(END_SEQUENCE_TAG));\n while (true) {\n reader.mark(1);\n int c = reader.read();\n if (c == -1) {\n hasAnotherSequence = false;\n break;\n }\n if (Character.isWhitespace((char) c)) {\n continue;\n }\n reader.reset();\n break;\n }\n rlistener.endSequence();\n return hasAnotherSequence;\n }\n", "output": " public boolean readRichSequence(BufferedReader reader,\n SymbolTokenization symParser,\n RichSeqIOListener rlistener,\n Namespace ns)\n throws IllegalSymbolException, IOException, ParseException {\n tax = null;\n organism = null;\n accession = null;\n boolean hasAnotherSequence = true;\n rlistener.startSequence();\n if (ns==null) ns=RichObjectFactory.getDefaultNamespace();\n rlistener.setNamespace(ns);\n String sectionKey = null;\n int xrefCount = 0;\n do {\n List section = this.readSection(reader);\n sectionKey = ((String[])section.get(0))[0];\n if(sectionKey == null){\n String message = ParseException.newMessage(this.getClass(), accession, \"No section key\", \"Not set\", sectionToString(section));\n throw new ParseException(message);\n }\n if (sectionKey.equals(LOCUS_TAG)) {\n String loc = ((String[])section.get(0))[1];\n Matcher m = lp.matcher(loc);\n Matcher mPre87 = lpPre87.matcher(loc);\n if (m.matches()) {\n rlistener.setName(m.group(1));\n rlistener.setAccession(m.group(1));\n rlistener.setVersion(Integer.parseInt(m.group(2)));\n rlistener.setCircular(m.group(3).equals(\"circular\"));\n rlistener.addSequenceProperty(Terms.getMolTypeTerm(),m.group(4));\n rlistener.addSequenceProperty(Terms.getDataClassTerm(),m.group(5));\n rlistener.setDivision(m.group(6));\n } else if (mPre87.matches()) {\n rlistener.setName(mPre87.group(1));\n if (mPre87.group(3)!=null) {\n rlistener.addSequenceProperty(Terms.getGenomicTerm(),null);\n }\n rlistener.addSequenceProperty(Terms.getMolTypeTerm(),mPre87.group(4));\n rlistener.setDivision(mPre87.group(5));\n String circular = mPre87.group(2);\n if (circular!=null) rlistener.setCircular(true);\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"Not Set\",\"Bad ID line found\", sectionToString(section));\n throw new ParseException(message);\n }\n } else if (sectionKey.equals(DEFINITION_TAG)) {\n rlistener.setDescription(((String[])section.get(0))[1]);\n } else if (sectionKey.equals(SOURCE_TAG)) {\n for (int i = 1; i < section.size(); i++) {\n sectionKey = ((String[])section.get(i))[0];\n if (sectionKey.equals(ORGANELLE_TAG)) {\n rlistener.addSequenceProperty(Terms.getOrganelleTerm(), ((String[])section.get(i))[1].trim());\n break; \n }\n }\n } else if (sectionKey.equals(DATE_TAG)) {\n String chunk = ((String[])section.get(0))[1].trim();\n Matcher dm = dp.matcher(chunk);\n if (dm.matches()) {\n String date = dm.group(1);\n String rel = dm.group(3);\n String type = dm.group(4);\n if (type.equals(\"Created\")) {\n rlistener.addSequenceProperty(Terms.getDateCreatedTerm(), date);\n rlistener.addSequenceProperty(Terms.getRelCreatedTerm(), rel);\n } else if (type.equals(\"Last updated, Version \")) {\n rlistener.addSequenceProperty(Terms.getDateUpdatedTerm(), date);\n rlistener.addSequenceProperty(Terms.getRelUpdatedTerm(), rel);\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad date type found\",sectionToString(section));\n throw new ParseException(message);\n }\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad date line found\",sectionToString(section));\n throw new ParseException(message);\n }\n } else if (sectionKey.equals(ACCESSION_TAG)) {\n String[] accs = ((String[])section.get(0))[1].split(\";\");\n accession = accs[0].trim();\n rlistener.setAccession(accession);\n for (int i = 1; i < accs.length; i++) {\n rlistener.addSequenceProperty(Terms.getAdditionalAccessionTerm(),accs[i].trim());\n }\n } else if (sectionKey.equals(VERSION_TAG)) {\n String ver = ((String[])section.get(0))[1];\n Matcher m = vp.matcher(ver);\n if (m.matches()) {\n String verAcc = m.group(1);\n if (!accession.equals(verAcc)) {\n rlistener.addSequenceProperty(Terms.getAdditionalAccessionTerm(),accession);\n accession = verAcc;\n rlistener.setAccession(accession);\n }\n rlistener.setVersion(Integer.parseInt(m.group(2)));\n } else {\n rlistener.addSequenceProperty(Terms.getVersionLineTerm(),ver);\n }\n } else if (sectionKey.equals(KEYWORDS_TAG)) {\n String val = ((String[])section.get(0))[1];\n val = val.substring(0,val.length()-1); \n String[] kws = val.split(\";\");\n for (int i = 0; i < kws.length; i++) {\n rlistener.addSequenceProperty(Terms.getKeywordTerm(), kws[i].trim());\n }\n } else if (sectionKey.equals(DATABASE_XREF_TAG)) {\n String val = ((String[])section.get(0))[1];\n val = val.substring(0,val.length()-1); \n String[] parts = val.split(\";\");\n CrossRef crossRef = (CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{parts[0].trim(),parts[1].trim(), new Integer(0)});\n for (int j = 2; j < parts.length; j++) {\n Note note = new SimpleNote(Terms.getAdditionalAccessionTerm(),parts[j].trim(),j-1);\n try {\n ((RichAnnotation)crossRef.getAnnotation()).addNote(note);\n } catch (ChangeVetoException ce) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Could not annotate identifier terms\",sectionToString(section));\n ParseException pe = new ParseException(message);\n pe.initCause(ce);\n throw pe;\n }\n }\n RankedCrossRef rcrossRef = new SimpleRankedCrossRef(crossRef, ++xrefCount);\n rlistener.setRankedCrossRef(rcrossRef);\n } else if (sectionKey.equals(REFERENCE_TAG) && !this.getElideReferences()) {\n String refrank = ((String[])section.get(0))[1];\n int ref_rank = Integer.parseInt(refrank.substring(1,refrank.length()-1));\n int ref_start = -999;\n int ref_end = -999;\n String consortium = null;\n String authors = null;\n String title = null;\n String locator = null;\n String pubmed = null;\n String medline = null;\n String doi = null;\n String remark = null;\n for (int i = 1; i < section.size(); i++) {\n String key = ((String[])section.get(i))[0];\n String val = ((String[])section.get(i))[1];\n if (key.equals(AUTHORS_TAG)) {\n if (val.endsWith(\";\")) val = val.substring(0,val.length()-1); \n authors = val;\n }\n if (key.equals(CONSORTIUM_TAG)) {\n if (val.endsWith(\";\")) val = val.substring(0,val.length()-1); \n consortium = val;\n }\n if (key.equals(TITLE_TAG)) {\n if (val.length()>1) {\n if (val.endsWith(\";\")) val = val.substring(0,val.length()-1); \n if (val.endsWith(\"\\\"\")) val = val.substring(1,val.length()-1); \n title = val.replace('\\n',' '); \n } else title=null; \n }\n if (key.equals(LOCATOR_TAG)) {\n if (val.endsWith(\".\")) val = val.substring(0,val.length()-1); \n locator = val;\n }\n if (key.equals(REFERENCE_XREF_TAG)) {\n String[] refs = val.split(\"\\\\.(\\\\s+|$)\");\n for (int j = 0 ; j < refs.length; j++) {\n if (refs[j].trim().length()==0) continue;\n String[] parts = refs[j].split(\";\");\n String db = parts[0];\n String ref = parts[1].trim();\n if (db.equalsIgnoreCase(Terms.PUBMED_KEY)) pubmed = ref;\n else if (db.equalsIgnoreCase(Terms.MEDLINE_KEY)) medline = ref;\n else if (db.equalsIgnoreCase(Terms.DOI_KEY)) doi = ref;\n }\n }\n if (key.equals(REMARK_TAG)) remark = val.replace('\\n',' '); \n if (key.equals(REFERENCE_POSITION_TAG)) {\n Matcher m = rpp.matcher(val);\n if (m.matches()) {\n ref_start = Integer.parseInt(m.group(1));\n if(m.group(2) != null)\n ref_end = Integer.parseInt(m.group(3));\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad reference line found\",sectionToString(section));\n throw new ParseException(message);\n }\n }\n }\n try {\n List authSet = DocRefAuthor.Tools.parseAuthorString(authors);\n if (consortium!=null) authSet.add(new SimpleDocRefAuthor(consortium, true, false));\n DocRef dr = (DocRef)RichObjectFactory.getObject(SimpleDocRef.class,new Object[]{authSet,locator,title});\n if (medline!=null) dr.setCrossref((CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{Terms.MEDLINE_KEY, medline, new Integer(0)}));\n else if (pubmed!=null) dr.setCrossref((CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{Terms.PUBMED_KEY, pubmed, new Integer(0)}));\n else if (doi!=null) dr.setCrossref((CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{Terms.DOI_KEY, doi, new Integer(0)}));\n if (!this.getElideComments()) dr.setRemark(remark);\n RankedDocRef rdr = new SimpleRankedDocRef(dr,\n (ref_start != -999 ? new Integer(ref_start) : null),\n (ref_end != -999 ? new Integer(ref_end) : null),\n ref_rank);\n rlistener.setRankedDocRef(rdr);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(e, message);\n }\n } else if (sectionKey.equals(COMMENT_TAG) && !this.getElideComments()) {\n rlistener.setComment(((String[])section.get(0))[1]);\n } else if (sectionKey.equals(FEATURE_TAG) && !this.getElideFeatures()) {\n boolean seenAFeature = false;\n for (int i = 1 ; i < section.size(); i++) {\n String key = ((String[])section.get(i))[0];\n String val = ((String[])section.get(i))[1];\n if (key.startsWith(\"/\")) {\n key = key.substring(1); \n val = val.replaceAll(\"\\\\s*[\\\\n\\\\r]+\\\\s*\",\" \").trim();\n if (val.startsWith(\"\\\"\")) val = val.substring(1,val.length()-1); \n if (key.equalsIgnoreCase(\"db_xref\")) {\n Matcher m = dbxp.matcher(val);\n if (m.matches()) {\n String dbname = m.group(1);\n String raccession = m.group(2);\n if (dbname.equalsIgnoreCase(\"taxon\")) {\n tax = (NCBITaxon)RichObjectFactory.getObject(SimpleNCBITaxon.class, new Object[]{Integer.valueOf(raccession)});\n rlistener.setTaxon(tax);\n try {\n if (organism!=null) tax.addName(NCBITaxon.SCIENTIFIC,organism);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(e, message);\n }\n } else {\n try {\n CrossRef cr = (CrossRef)RichObjectFactory.getObject(SimpleCrossRef.class,new Object[]{dbname, raccession, new Integer(0)});\n RankedCrossRef rcr = new SimpleRankedCrossRef(cr, 0);\n rlistener.getCurrentFeature().addRankedCrossRef(rcr);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(e, message);\n }\n }\n } else {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad dbxref found\",sectionToString(section));\n throw new ParseException(message);\n }\n } else if (key.equalsIgnoreCase(\"organism\")) {\n try {\n organism = val;\n if (tax!=null) tax.addName(NCBITaxon.SCIENTIFIC,organism);\n } catch (ChangeVetoException e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"\",sectionToString(section));\n throw new ParseException(message);\n }\n } else {\n if (key.equalsIgnoreCase(\"translation\")) {\n val = val.replaceAll(\"\\\\s+\",\"\");\n }\n rlistener.addFeatureProperty(RichObjectFactory.getDefaultOntology().getOrCreateTerm(key),val);\n }\n } else {\n if (seenAFeature) rlistener.endFeature();\n RichFeature.Template templ = new RichFeature.Template();\n templ.annotation = new SimpleRichAnnotation();\n templ.sourceTerm = Terms.getEMBLTerm();\n templ.typeTerm = RichObjectFactory.getDefaultOntology().getOrCreateTerm(key);\n templ.featureRelationshipSet = new TreeSet();\n templ.rankedCrossRefs = new TreeSet();\n String tidyLocStr = val.replaceAll(\"\\\\s+\",\"\");\n templ.location = GenbankLocationParser.parseLocation(ns, accession, tidyLocStr);\n rlistener.startFeature(templ);\n seenAFeature = true;\n }\n }\n if (seenAFeature) rlistener.endFeature();\n } else if (sectionKey.equals(START_SEQUENCE_TAG) && !this.getElideSymbols()) {\n StringBuffer seq = new StringBuffer();\n for (int i = 0 ; i < section.size(); i++) seq.append(((String[])section.get(i))[1]);\n try {\n SymbolList sl = new SimpleSymbolList(symParser,\n seq.toString().replaceAll(\"\\\\s+\",\"\").replaceAll(\"[\\\\.|~]\",\"-\"));\n rlistener.addSymbols(symParser.getAlphabet(),\n (Symbol[])(sl.toList().toArray(new Symbol[0])),\n 0, sl.length());\n } catch (Exception e) {\n String message = ParseException.newMessage(this.getClass(),accession,\"not set\", \"Bad sequence\",sectionToString(section));\n throw new ParseException(e, message);\n }\n }\n } while (!sectionKey.equals(END_SEQUENCE_TAG));\n while (true) {\n reader.mark(1);\n int c = reader.read();\n if (c == -1) {\n hasAnotherSequence = false;\n break;\n }\n if (Character.isWhitespace((char) c)) {\n continue;\n }\n reader.reset();\n break;\n }\n rlistener.endSequence();\n return hasAnotherSequence;\n }\n"} {"input": " public void init() {\n\t\ttry {\n\t\t\tRFX_FOLDER = new File(getRfxFolderPath()); \n\t\t\tBIN_FOLDER = new File(getBinFolderPath());\n\t\t\tDESKTOP_FOLDER = new File(getDesktopFolderPath());\n\t\t\tDOCUMENT_BASE = getDocumentBase();\n\t\t\tCODE_BASE = getCodeBase();\n\t\t\tPOST_URL = getParameter(\"post_url\");\n\t\t\tAPI_KEY = getParameter(\"api_key\");\n\t\t\tHEADLESS = !getParameter(\"headless\").isEmpty() && getParameter(\"headless\").equals(\"true\"); \n\t\t\tGRAPHICS_CONFIG = getGraphicsConfiguration();\n\t\t\tGraphicsDevice myScreen = GRAPHICS_CONFIG.getDevice();\n\t\t\tGraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();\n\t\t\tGraphicsDevice[] allScreens = env.getScreenDevices();\n\t\t\tint myScreenIndex = -1;\n\t\t\tfor (int i = 0; i < allScreens.length; i++) {\n\t\t\t if (allScreens[i].equals(myScreen))\n\t\t\t {\n\t\t\t myScreenIndex = i;\n\t\t\t break;\n\t\t\t }\n\t\t\t}\n\t\t\tSystem.out.println(\"Applet window is on screen\" + myScreenIndex);\n\t\t\tSystem.out.println(getAppletInfo());\t\t\t \n\t\t\tif( RFX_FOLDER.exists() && !RFX_FOLDER.isDirectory() && !RFX_FOLDER.delete() )\n\t\t throw new IOException(\"Could not delete file for folder: \" + RFX_FOLDER.getAbsolutePath());\n\t\t\tif( !RFX_FOLDER.exists() && !RFX_FOLDER.mkdir() )\n\t\t throw new IOException(\"Could not create folder: \" + RFX_FOLDER.getAbsolutePath());\n\t\t\tSystem.out.println(\"Have access to folder: \"+RFX_FOLDER.getAbsolutePath()+File.separator);\n SwingUtilities.invokeAndWait(new Runnable() {\n public void run() {\n \tif(IS_MAC)\n \t\tcontroller = new MacController();\n \telse if(IS_LINUX)\n \t\tcontroller = new LinuxController();\n \telse if(IS_WINDOWS)\n \t\tcontroller = new WindowsController();\n \telse \n \t\tSystem.err.println(\"Want to launch controller but don't which operating system this is.\");\n }\n });\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n \tif(controller != null)\n \t\tcontroller.setupExtensions();\n }\n });\n\t\t} catch (IOException e1) {\n\t\t\tSystem.err.println(\"Could not create temporary folder!\");\n\t\t\te1.printStackTrace();\n\t\t}\tcatch (Exception e) {\n System.err.println(\"Could not create GUI!\");\n e.printStackTrace();\n }\n }\n", "output": " public void init() {\n\t\ttry {\n\t\t\tRFX_FOLDER = new File(getRfxFolderPath()); \n\t\t\tBIN_FOLDER = new File(getBinFolderPath());\n\t\t\tDESKTOP_FOLDER = new File(getDesktopFolderPath());\n\t\t\tDOCUMENT_BASE = getDocumentBase();\n\t\t\tCODE_BASE = getCodeBase();\n\t\t\tPOST_URL = getParameter(\"post_url\");\n\t\t\tAPI_KEY = getParameter(\"api_key\");\n\t\t\tif(getParameter(\"headless\") != null)\n\t\t\t\tHEADLESS = !getParameter(\"headless\").isEmpty() && getParameter(\"headless\").equals(\"true\"); \n\t\t\tGRAPHICS_CONFIG = getGraphicsConfiguration();\n\t\t\tGraphicsDevice myScreen = GRAPHICS_CONFIG.getDevice();\n\t\t\tGraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();\n\t\t\tGraphicsDevice[] allScreens = env.getScreenDevices();\n\t\t\tint myScreenIndex = -1;\n\t\t\tfor (int i = 0; i < allScreens.length; i++) {\n\t\t\t if (allScreens[i].equals(myScreen))\n\t\t\t {\n\t\t\t myScreenIndex = i;\n\t\t\t break;\n\t\t\t }\n\t\t\t}\n\t\t\tSystem.out.println(\"Applet window is on screen\" + myScreenIndex);\n\t\t\tSystem.out.println(getAppletInfo());\t\t\t \n\t\t\tif( RFX_FOLDER.exists() && !RFX_FOLDER.isDirectory() && !RFX_FOLDER.delete() )\n\t\t throw new IOException(\"Could not delete file for folder: \" + RFX_FOLDER.getAbsolutePath());\n\t\t\tif( !RFX_FOLDER.exists() && !RFX_FOLDER.mkdir() )\n\t\t throw new IOException(\"Could not create folder: \" + RFX_FOLDER.getAbsolutePath());\n\t\t\tSystem.out.println(\"Have access to folder: \"+RFX_FOLDER.getAbsolutePath()+File.separator);\n SwingUtilities.invokeAndWait(new Runnable() {\n public void run() {\n \tif(IS_MAC)\n \t\tcontroller = new MacController();\n \telse if(IS_LINUX)\n \t\tcontroller = new LinuxController();\n \telse if(IS_WINDOWS)\n \t\tcontroller = new WindowsController();\n \telse \n \t\tSystem.err.println(\"Want to launch controller but don't which operating system this is.\");\n }\n });\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n \tif(controller != null)\n \t\tcontroller.setupExtensions();\n }\n });\n\t\t} catch (IOException e1) {\n\t\t\tSystem.err.println(\"Could not create temporary folder!\");\n\t\t\te1.printStackTrace();\n\t\t}\tcatch (Exception e) {\n System.err.println(\"Could not create GUI!\");\n e.printStackTrace();\n }\n }\n"} {"input": " public int run(String[] args) throws Exception {\n Options options = new Options();\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"output path\").create(OUTPUT));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"input\").create(INPUT));\n options.addOption(OptionBuilder.withArgName(\"string\")\n .hasArg().withDescription(\"e language\").create(eLangOption));\n options.addOption(OptionBuilder.withArgName(\"string\")\n .hasArg().withDescription(\"f language\").create(fLangOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e stop words\").create(eStopWordsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f stop words\").create(fStopWordsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e tokens\").create(eTokensOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f tokens\").create(fTokensOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e vocab src\").create(eVocabSrcOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f vocab src\").create(fVocabSrcOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e vocab tgt\").create(eVocabTgtOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f vocab tgt\").create(fVocabTgtOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e2f prob table\").create(e2fProbsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f2e prob table\").create(f2eProbsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"output path\").create(OUTPUT));\n options.addOption(OptionBuilder.withArgName(\"integer\")\n .hasArg().withDescription(\"n samples\").create(nSamplesOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"sampled documents\").create(sampleDocsOption));\n CommandLine cmdline;\n CommandLineParser parser = new GnuParser();\n try {\n cmdline = parser.parse(options, args);\n } catch (ParseException exp) {\n System.err.println(\"Error parsing command line: \" + exp.getMessage());\n return -1;\n }\n if (!cmdline.hasOption(OUTPUT) || !cmdline.hasOption(INPUT)\n || !cmdline.hasOption(nSamplesOption)\n || !cmdline.hasOption(eVocabSrcOption) || !cmdline.hasOption(fVocabSrcOption) \n || !cmdline.hasOption(eVocabTgtOption) || !cmdline.hasOption(fVocabTgtOption)\n || !cmdline.hasOption(e2fProbsOption) || !cmdline.hasOption(f2eProbsOption)\n || !cmdline.hasOption(eLangOption) || !cmdline.hasOption(fLangOption) \n || !cmdline.hasOption(eStopWordsOption) || !cmdline.hasOption(fStopWordsOption) \n || !cmdline.hasOption(eTokensOption) || !cmdline.hasOption(fTokensOption)\n || !cmdline.hasOption(nSamplesOption) || !cmdline.hasOption(sampleDocsOption)\n ) {\n HelpFormatter formatter = new HelpFormatter();\n formatter.setWidth(120);\n formatter.printHelp(this.getClass().getName(), options);\n ToolRunner.printGenericCommandUsage(System.out);\n return -1;\n }\n String inputPath = cmdline.getOptionValue(INPUT);\n String outputPath = cmdline.getOptionValue(OUTPUT);\n String eLang = cmdline.getOptionValue(eLangOption);\n String fLang = cmdline.getOptionValue(fLangOption);\n String eTokensPath = cmdline.getOptionValue(eTokensOption);\n String fTokensPath = cmdline.getOptionValue(fTokensOption);\n String eStopWordsPath = cmdline.getOptionValue(eStopWordsOption);\n String fStopWordsPath = cmdline.getOptionValue(fStopWordsOption);\n String eVocabSrcPath = cmdline.getOptionValue(eVocabSrcOption);\n String fVocabSrcPath = cmdline.getOptionValue(fVocabSrcOption);\n String eVocabTgtPath = cmdline.getOptionValue(eVocabTgtOption);\n String fVocabTgtPath = cmdline.getOptionValue(fVocabTgtOption);\n String e2fProbsPath = cmdline.getOptionValue(e2fProbsOption);\n String f2eProbsPath = cmdline.getOptionValue(f2eProbsOption);\n int nSamples = Integer.parseInt(cmdline.getOptionValue(nSamplesOption));\n String sampleDocsFile = cmdline.getOptionValue(sampleDocsOption);\n LOG.info(\"Tool name: \" + this.getClass().getName());\n LOG.info(\" - nput file: \" + inputPath);\n LOG.info(\" - output file: \" + outputPath);\n JobConf conf = new JobConf(getConf(), BruteForcePwsim.class);\n conf.setJobName(String.format(\"BruteForcePwsim[%s: %s]\", OUTPUT, outputPath));\n conf.setLong(\"rseed\", 1123456);\n conf.setInt(\"nSamples\", nSamples);\n conf.set(\"eLang\", eLang);\n conf.set(\"fLang\", fLang);\n conf.set(\"eTokensFile\", eTokensPath);\n conf.set(\"fTokensFile\", fTokensPath);\n conf.set(\"eStopWordsFile\", eStopWordsPath);\n conf.set(\"fStopWordsFile\", fStopWordsPath);\n conf.set(\"eVocabSrcFile\", eVocabSrcPath);\n conf.set(\"eVocabTgtFile\", eVocabTgtPath);\n conf.set(\"fVocabSrcFile\", fVocabSrcPath);\n conf.set(\"fVocabTgtFile\", fVocabTgtPath);\n conf.set(\"probTablef2eFile\", f2eProbsPath);\n conf.set(\"probTablee2fFile\", e2fProbsPath);\n conf.set(\"sampleDocs\", sampleDocsFile);\n conf.setNumMapTasks(20);\n conf.setNumReduceTasks(0);\n FileInputFormat.setInputPaths(conf, new Path(inputPath));\n FileOutputFormat.setOutputPath(conf, new Path(outputPath));\n conf.setMapperClass(SignatureMapper.class);\n conf.setInputFormat(SequenceFileInputFormat.class);\n conf.setOutputFormat(SequenceFileOutputFormat.class);\n conf.set(\"mapred.job.map.memory.mb\", \"2048\");\n conf.set(\"mapred.map.child.java.opts\", \"-Xmx2048m\");\n conf.set(\"mapred.job.reduce.memory.mb\", \"8000\");\n conf.set(\"mapred.reduce.child.java.opts\", \"-Xmx8000m\");\n conf.setMapOutputKeyClass(PairOfLongInt.class);\n conf.setMapOutputValueClass(ArrayListOfDoubles.class);\n Path outputDir = new Path(outputPath);\n FileSystem.get(conf).delete(outputDir, true);\n JobClient.runJob(conf);\n return 0;\n }\n", "output": " public int run(String[] args) throws Exception {\n Options options = new Options();\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"output path\").create(OUTPUT));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"input\").create(INPUT));\n options.addOption(OptionBuilder.withArgName(\"string\")\n .hasArg().withDescription(\"e language\").create(eLangOption));\n options.addOption(OptionBuilder.withArgName(\"string\")\n .hasArg().withDescription(\"f language\").create(fLangOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e stop words\").create(eStopWordsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f stop words\").create(fStopWordsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e tokens\").create(eTokensOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f tokens\").create(fTokensOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e vocab src\").create(eVocabSrcOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f vocab src\").create(fVocabSrcOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e vocab tgt\").create(eVocabTgtOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f vocab tgt\").create(fVocabTgtOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"e2f prob table\").create(e2fProbsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"f2e prob table\").create(f2eProbsOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"output path\").create(OUTPUT));\n options.addOption(OptionBuilder.withArgName(\"integer\")\n .hasArg().withDescription(\"n samples\").create(nSamplesOption));\n options.addOption(OptionBuilder.withArgName(\"path\")\n .hasArg().withDescription(\"sampled documents\").create(sampleDocsOption));\n CommandLine cmdline;\n CommandLineParser parser = new GnuParser();\n try {\n cmdline = parser.parse(options, args);\n } catch (ParseException exp) {\n System.err.println(\"Error parsing command line: \" + exp.getMessage());\n return -1;\n }\n if (!cmdline.hasOption(OUTPUT) || !cmdline.hasOption(INPUT)\n || !cmdline.hasOption(nSamplesOption)\n || !cmdline.hasOption(eVocabSrcOption) || !cmdline.hasOption(fVocabSrcOption) \n || !cmdline.hasOption(eVocabTgtOption) || !cmdline.hasOption(fVocabTgtOption)\n || !cmdline.hasOption(e2fProbsOption) || !cmdline.hasOption(f2eProbsOption)\n || !cmdline.hasOption(eLangOption) || !cmdline.hasOption(fLangOption) \n || !cmdline.hasOption(eStopWordsOption) || !cmdline.hasOption(fStopWordsOption) \n || !cmdline.hasOption(eTokensOption) || !cmdline.hasOption(fTokensOption)\n || !cmdline.hasOption(nSamplesOption) || !cmdline.hasOption(sampleDocsOption)\n ) {\n HelpFormatter formatter = new HelpFormatter();\n formatter.setWidth(120);\n formatter.printHelp(this.getClass().getName(), options);\n ToolRunner.printGenericCommandUsage(System.out);\n return -1;\n }\n String inputPath = cmdline.getOptionValue(INPUT);\n String outputPath = cmdline.getOptionValue(OUTPUT);\n String eLang = cmdline.getOptionValue(eLangOption);\n String fLang = cmdline.getOptionValue(fLangOption);\n String eTokensPath = cmdline.getOptionValue(eTokensOption);\n String fTokensPath = cmdline.getOptionValue(fTokensOption);\n String eStopWordsPath = cmdline.getOptionValue(eStopWordsOption);\n String fStopWordsPath = cmdline.getOptionValue(fStopWordsOption);\n String eVocabSrcPath = cmdline.getOptionValue(eVocabSrcOption);\n String fVocabSrcPath = cmdline.getOptionValue(fVocabSrcOption);\n String eVocabTgtPath = cmdline.getOptionValue(eVocabTgtOption);\n String fVocabTgtPath = cmdline.getOptionValue(fVocabTgtOption);\n String e2fProbsPath = cmdline.getOptionValue(e2fProbsOption);\n String f2eProbsPath = cmdline.getOptionValue(f2eProbsOption);\n int nSamples = Integer.parseInt(cmdline.getOptionValue(nSamplesOption));\n String sampleDocsFile = cmdline.getOptionValue(sampleDocsOption);\n LOG.info(\"Tool name: \" + this.getClass().getName());\n LOG.info(\" - nput file: \" + inputPath);\n LOG.info(\" - output file: \" + outputPath);\n JobConf conf = new JobConf(getConf(), BruteForcePwsim.class);\n conf.setJobName(String.format(\"BruteForcePwsim[%s: %s]\", OUTPUT, outputPath));\n conf.setLong(\"rseed\", 1123456);\n conf.setInt(\"nSamples\", nSamples);\n conf.set(\"eLang\", eLang);\n conf.set(\"fLang\", fLang);\n conf.set(\"eTokensFile\", eTokensPath);\n conf.set(\"fTokensFile\", fTokensPath);\n conf.set(\"eStopWordsFile\", eStopWordsPath);\n conf.set(\"fStopWordsFile\", fStopWordsPath);\n conf.set(\"eVocabSrcFile\", eVocabSrcPath);\n conf.set(\"eVocabTgtFile\", eVocabTgtPath);\n conf.set(\"fVocabSrcFile\", fVocabSrcPath);\n conf.set(\"fVocabTgtFile\", fVocabTgtPath);\n conf.set(\"probTablef2eFile\", f2eProbsPath);\n conf.set(\"probTablee2fFile\", e2fProbsPath);\n conf.set(\"sampleDocs\", sampleDocsFile);\n conf.setNumMapTasks(20);\n conf.setNumReduceTasks(0);\n FileInputFormat.setInputPaths(conf, new Path(inputPath));\n FileOutputFormat.setOutputPath(conf, new Path(outputPath));\n conf.setMapperClass(SignatureMapper.class);\n conf.setInputFormat(SequenceFileInputFormat.class);\n conf.setOutputFormat(SequenceFileOutputFormat.class);\n conf.set(\"mapred.job.map.memory.mb\", \"2048\");\n conf.set(\"mapred.map.child.java.opts\", \"-Xmx2048m\");\n conf.set(\"mapred.job.reduce.memory.mb\", \"8000\");\n conf.set(\"mapred.reduce.child.java.opts\", \"-Xmx8000m\");\n conf.setOutputKeyClass(PairOfLongInt.class);\n conf.setOutputValueClass(ArrayListOfDoubles.class);\n Path outputDir = new Path(outputPath);\n FileSystem.get(conf).delete(outputDir, true);\n JobClient.runJob(conf);\n return 0;\n }\n"} {"input": "\tpublic void initializeContent() {\t\n\t\tBoolean useUserHomeFolder = (Boolean) this.getAttributes().get(\"useUserHomeFolder\");\n\t\tif (useUserHomeFolder != null && useUserHomeFolder.booleanValue()) {\n\t\t\trootFolder = super.getIWSlideSession().getUserHomeFolder();\n\t\t}\n\t\tString startFolder = (String) this.getAttributes().get(\"startFolder\");\n\t\tif (rootFolder == null) {\n\t\t\trootFolder = (String) this.getAttributes().get(\"rootFolder\");\n\t\t}\n\t\tWFBlock listBlock = new WFBlock();\n\t\tWFTitlebar tb = new WFTitlebar();\n\t\ttb.setValueRefTitle(true);\n\t\ttb.setTitleText(\"WebDAVListBean.webDAVPath\");\t\t\n\t\tlistBlock.setToolbarEmbeddedInTitlebar(true);\n\t\tlistBlock.setTitlebar(tb);\n\t\tlistBlock.setToolbar(getToolbar());\n\t\tWebDAVList list = new WebDAVList();\n\t\tlist.setId(getId()+\"_list\");\n\t\tlist.setRendered(renderWebDAVList);\n\t\tlist.setStartFolder(startFolder);\n\t\tlistBlock.add(list);\n\t\tWFBlock detailsBlock = new WFBlock();\n\t\tWFTitlebar detailsBar = new WFTitlebar();\n\t\tdetailsBar.setTitleText(getBundle().getLocalizedText(\"document_details\"));\n\t\tdetailsBlock.setTitlebar(detailsBar);\n\t\tdetailsBlock.setToolbar(getToolbar());\n\t\tWebDAVFileDetails details = new WebDAVFileDetails();\n\t\tdetails.setRendered(renderWebDAVFileDetails);\n\t\tdetails.setId(getId()+\"_details\");\n\t\tdetailsBlock.add(details);\n\t\tWFBlock previewBlock = new WFBlock();\n\t\tWFTitlebar previewBar = new WFTitlebar();\n\t\tpreviewBar.setTitleText(getBundle().getLocalizedText(\"document_details\"));\n\t\tpreviewBlock.setTitlebar(previewBar);\n\t\tpreviewBlock.setToolbar(getToolbar());\n\t\tWebDAVFileDetails details2 = new WebDAVFileDetails();\n\t\tdetails2.setRendered(renderWebDAVFilePreview);\n\t\tdetails2.setId(getId()+\"_details\");\n\t\tdetails2.setDetailed(false);\n\t\tWebDAVFilePreview preview = new WebDAVFilePreview();\n\t\tpreview.setRendered(renderWebDAVFilePreview);\n\t\tpreview.setId(getId()+\"_preview\");\n\t\tpreviewBlock.add(details2);\n\t\tWFBlock folderBlock = new WFBlock();\n\t\tWFTitlebar folderBar = new WFTitlebar();\n\t\tfolderBar.setTitleText(getBundle().getLocalizedText(\"create_a_folder\"));\n\t\tfolderBlock.setTitlebar(folderBar);\n\t\tfolderBlock.setToolbar(new WFToolbar());\n\t\tWebDAVFolderCreation folder = new WebDAVFolderCreation();\n\t\tfolder.setRendered(renderWebDAVNewFolder);\n\t\tfolder.setId(getId()+\"_folder\");\n\t\tfolderBlock.add(folder);\n\t\tWFBlock uploadBlock = new WFBlock();\n\t\tWFTitlebar uploadBar = new WFTitlebar();\n\t\tuploadBar.setTitleText(getBundle().getLocalizedText(\"upload\"));\n\t\tuploadBlock.setTitlebar(uploadBar);\n\t\tuploadBlock.setToolbar(new WFToolbar());\n\t\tWebDAVUpload upload = new WebDAVUpload();\n\t\tupload.setId(getId()+\"_upload\");\n\t\tuploadBlock.add(upload);\n\t\tWFBlock deleteBlock = new WFBlock();\n\t\tWFTitlebar deleteBar = new WFTitlebar();\n\t\tdeleteBar.setTitleText(getBundle().getLocalizedText(\"delete\"));\n\t\tdeleteBlock.setTitlebar(deleteBar);\n\t\tdeleteBlock.setToolbar(new WFToolbar());\n\t\tWebDAVDocumentDeleter deleter = new WebDAVDocumentDeleter();\n\t\tdeleter.setRendered(renderWebDAVDeleter);\n\t\tdeleter.setId(getId()+\"_deleter\");\n\t\tdeleteBlock.add(deleter);\n\t\tgetFacets().put(LIST, listBlock);\n\t\tgetFacets().put(FILE_DETAILS, detailsBlock);\n\t\tgetFacets().put(FILE_DETAILS_LESS, previewBlock);\n\t\tgetFacets().put(PREVIEW, preview);\n\t\tgetFacets().put(NEW_FOLDER, folderBlock);\n\t\tgetFacets().put(UPLOAD, uploadBlock);\n\t\tgetFacets().put(DELETE, deleteBlock);\n\t}\n", "output": "\tpublic void initializeContent() {\t\n\t\tBoolean useUserHomeFolder = (Boolean) this.getAttributes().get(\"useUserHomeFolder\");\n\t\tif (useUserHomeFolder != null && useUserHomeFolder.booleanValue()) {\n\t\t\trootFolder = super.getIWSlideSession().getUserHomeFolder();\n\t\t}\n\t\tString startFolder = (String) this.getAttributes().get(\"startFolder\");\n\t\tif (rootFolder == null) {\n\t\t\trootFolder = (String) this.getAttributes().get(\"rootFolder\");\n\t\t}\n\t\tWFBlock listBlock = new WFBlock();\n\t\tWFTitlebar tb = new WFTitlebar();\n\t\ttb.setValueRefTitle(true);\n\t\ttb.setTitleText(\"WebDAVListBean.webDAVPath\");\t\t\n\t\tlistBlock.setToolbarEmbeddedInTitlebar(true);\n\t\tlistBlock.setTitlebar(tb);\n\t\tlistBlock.setToolbar(getToolbar());\n\t\tWebDAVList list = new WebDAVList();\n\t\tlist.setId(getId()+\"_list\");\n\t\tlist.setRendered(renderWebDAVList);\n\t\tlist.setStartFolder(startFolder);\n\t\tlist.setRootFolder(rootFolder);\n\t\tlistBlock.add(list);\n\t\tWFBlock detailsBlock = new WFBlock();\n\t\tWFTitlebar detailsBar = new WFTitlebar();\n\t\tdetailsBar.setTitleText(getBundle().getLocalizedText(\"document_details\"));\n\t\tdetailsBlock.setTitlebar(detailsBar);\n\t\tdetailsBlock.setToolbar(getToolbar());\n\t\tWebDAVFileDetails details = new WebDAVFileDetails();\n\t\tdetails.setRendered(renderWebDAVFileDetails);\n\t\tdetails.setId(getId()+\"_details\");\n\t\tdetailsBlock.add(details);\n\t\tWFBlock previewBlock = new WFBlock();\n\t\tWFTitlebar previewBar = new WFTitlebar();\n\t\tpreviewBar.setTitleText(getBundle().getLocalizedText(\"document_details\"));\n\t\tpreviewBlock.setTitlebar(previewBar);\n\t\tpreviewBlock.setToolbar(getToolbar());\n\t\tWebDAVFileDetails details2 = new WebDAVFileDetails();\n\t\tdetails2.setRendered(renderWebDAVFilePreview);\n\t\tdetails2.setId(getId()+\"_details\");\n\t\tdetails2.setDetailed(false);\n\t\tWebDAVFilePreview preview = new WebDAVFilePreview();\n\t\tpreview.setRendered(renderWebDAVFilePreview);\n\t\tpreview.setId(getId()+\"_preview\");\n\t\tpreviewBlock.add(details2);\n\t\tWFBlock folderBlock = new WFBlock();\n\t\tWFTitlebar folderBar = new WFTitlebar();\n\t\tfolderBar.setTitleText(getBundle().getLocalizedText(\"create_a_folder\"));\n\t\tfolderBlock.setTitlebar(folderBar);\n\t\tfolderBlock.setToolbar(new WFToolbar());\n\t\tWebDAVFolderCreation folder = new WebDAVFolderCreation();\n\t\tfolder.setRendered(renderWebDAVNewFolder);\n\t\tfolder.setId(getId()+\"_folder\");\n\t\tfolderBlock.add(folder);\n\t\tWFBlock uploadBlock = new WFBlock();\n\t\tWFTitlebar uploadBar = new WFTitlebar();\n\t\tuploadBar.setTitleText(getBundle().getLocalizedText(\"upload\"));\n\t\tuploadBlock.setTitlebar(uploadBar);\n\t\tuploadBlock.setToolbar(new WFToolbar());\n\t\tWebDAVUpload upload = new WebDAVUpload();\n\t\tupload.setId(getId()+\"_upload\");\n\t\tuploadBlock.add(upload);\n\t\tWFBlock deleteBlock = new WFBlock();\n\t\tWFTitlebar deleteBar = new WFTitlebar();\n\t\tdeleteBar.setTitleText(getBundle().getLocalizedText(\"delete\"));\n\t\tdeleteBlock.setTitlebar(deleteBar);\n\t\tdeleteBlock.setToolbar(new WFToolbar());\n\t\tWebDAVDocumentDeleter deleter = new WebDAVDocumentDeleter();\n\t\tdeleter.setRendered(renderWebDAVDeleter);\n\t\tdeleter.setId(getId()+\"_deleter\");\n\t\tdeleteBlock.add(deleter);\n\t\tgetFacets().put(LIST, listBlock);\n\t\tgetFacets().put(FILE_DETAILS, detailsBlock);\n\t\tgetFacets().put(FILE_DETAILS_LESS, previewBlock);\n\t\tgetFacets().put(PREVIEW, preview);\n\t\tgetFacets().put(NEW_FOLDER, folderBlock);\n\t\tgetFacets().put(UPLOAD, uploadBlock);\n\t\tgetFacets().put(DELETE, deleteBlock);\n\t}\n"} {"input": "\tpublic static Task parse_json(JsonObject el, AccountMirakel account) {\n\t\tTask t = null;\n\t\tJsonElement id = el.get(\"id\");\n\t\tif (id != null) {\n\t\t\tt = Task.get(id.getAsLong());\n\t\t} else {\n\t\t\tid = el.get(\"uuid\");\n\t\t\tif (id != null) {\n\t\t\t\tt = Task.getByUUID(id.getAsString());\n\t\t\t}\n\t\t}\n\t\tif (t == null) {\n\t\t\tt = new Task();\n\t\t}\n\t\tSet> entries = el.entrySet();\n\t\tfor (Entry entry : entries) {\n\t\t\tString key = entry.getKey();\n\t\t\tJsonElement val = entry.getValue();\n\t\t\tif (key == null || key.equals(\"id\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (key.equals(\"uuid\")) {\n\t\t\t\tt.setUUID(val.getAsString());\n\t\t\t} else if (key.equals(\"name\") || key.equals(\"description\")) {\n\t\t\t\tt.setName(val.getAsString());\n\t\t\t} else if (key.equals(\"content\")) {\n\t\t\t\tString content = val.getAsString();\n\t\t\t\tif (content == null) {\n\t\t\t\t\tcontent = \"\";\n\t\t\t\t}\n\t\t\t\tt.setContent(content);\n\t\t\t} else if (key.equals(\"priority\")) {\n\t\t\t\tString prioString = val.getAsString().trim();\n\t\t\t\tif (prioString.equals(\"L\") && t.getPriority() != -1) {\n\t\t\t\t\tt.setPriority(-2);\n\t\t\t\t} else if (prioString.equals(\"M\")) {\n\t\t\t\t\tt.setPriority(1);\n\t\t\t\t} else if (prioString.equals(\"H\")) {\n\t\t\t\t\tt.setPriority(2);\n\t\t\t\t} else if (!prioString.equals(\"L\")) {\n\t\t\t\t\tt.setPriority(val.getAsInt());\n\t\t\t\t}\n\t\t\t} else if(key.equals(\"progress\")) {\n\t\t\t\tint progress=(int) val.getAsDouble();\n\t\t\t\tt.setProgress(progress);\n\t\t\t} else if (key.equals(\"list_id\")) {\n\t\t\t\tListMirakel list = ListMirakel.getList(val.getAsInt());\n\t\t\t\tif (list == null) {\n\t\t\t\t\tlist = SpecialList.firstSpecial().getDefaultList();\n\t\t\t\t}\n\t\t\t\tt.setList(list, true);\n\t\t\t} else if (key.equals(\"project\")) {\n\t\t\t\tListMirakel list = ListMirakel.findByName(val.getAsString(),\n\t\t\t\t\t\taccount);\n\t\t\t\tif (list == null\n\t\t\t\t\t\t|| list.getAccount().getId() != account.getId()) {\n\t\t\t\t\tlist = ListMirakel.newList(val.getAsString(),\n\t\t\t\t\t\t\tListMirakel.SORT_BY_OPT, account);\n\t\t\t\t}\n\t\t\t\tt.setList(list, true);\n\t\t\t} else if (key.equals(\"created_at\")) {\n\t\t\t\tt.setCreatedAt(val.getAsString().replace(\":\", \"\"));\n\t\t\t} else if (key.equals(\"updated_at\")) {\n\t\t\t\tt.setUpdatedAt(val.getAsString().replace(\":\", \"\"));\n\t\t\t} else if (key.equals(\"entry\")) {\n\t\t\t\tt.setCreatedAt(parseDate(val.getAsString(),\n\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat)));\n\t\t\t} else if (key.equals(\"modification\")||key.equals(\"modified\")) {\n\t\t\t\tt.setUpdatedAt(parseDate(val.getAsString(),\n\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat)));\n\t\t\t} else if (key.equals(\"done\")) {\n\t\t\t\tt.setDone(val.getAsBoolean());\n\t\t\t} else if (key.equals(\"status\")) {\n\t\t\t\tString status = val.getAsString();\n\t\t\t\tif (status.equals(\"pending\")) {\n\t\t\t\t\tt.setDone(false);\n\t\t\t\t} else if (status.equals(\"deleted\")) {\n\t\t\t\t\tt.setSyncState(SYNC_STATE.DELETE);\n\t\t\t\t} else {\n\t\t\t\t\tt.setDone(true);\n\t\t\t\t}\n\t\t\t\tt.addAdditionalEntry(key, \"\\\"\" + val.getAsString() + \"\\\"\");\n\t\t\t} else if (key.equals(\"due\")) {\n\t\t\t\tCalendar due = parseDate(val.getAsString(), \"yyyy-MM-dd\");\n\t\t\t\tif (due == null) {\n\t\t\t\t\tdue = parseDate(val.getAsString(),\n\t\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat));\n\t\t\t\t\tif (due != null) {\n\t\t\t\t\t\tdue.setTimeInMillis(due.getTimeInMillis()\n\t\t\t\t\t\t\t\t+ TimeZone.getDefault().getRawOffset());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tt.setDue(due);\n\t\t\t} else if (key.equals(\"reminder\")) {\n\t\t\t\tCalendar reminder = parseDate(val.getAsString(), \"yyyy-MM-dd\");\n\t\t\t\tif (reminder == null) {\n\t\t\t\t\treminder = parseDate(val.getAsString(),\n\t\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat));\n\t\t\t\t}\n\t\t\t\tt.setReminder(reminder);\n\t\t\t} else if (key.equals(\"annotations\")) {\n\t\t\t\tString content = \"\";\n\t\t\t\ttry {\n\t\t\t\t\tJsonArray annotations = val.getAsJsonArray();\n\t\t\t\t\tboolean first = true;\n\t\t\t\t\tfor (JsonElement a : annotations) {\n\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\tfirst = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontent += \"\\n\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontent += a.getAsJsonObject().get(\"description\")\n\t\t\t\t\t\t\t\t.getAsString();\n\t\t\t\t\t}\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tLog.e(TAG, \"cannot parse json\");\n\t\t\t\t}\n\t\t\t\tt.setContent(content);\n\t\t\t} else if (key.equals(\"content\")) {\n\t\t\t\tt.setContent(val.getAsString());\n\t\t\t} else if (key.equals(\"sync_state\")) {\n\t\t\t\tt.setSyncState(SYNC_STATE.parseInt(val.getAsInt()));\n\t\t\t} else if (key.equals(\"depends\")) {\n\t\t\t\tt.setDependencies(val.getAsString().split(\",\"));\n\t\t\t} else {\n\t\t\t\tif (val.isJsonPrimitive()) {\n\t\t\t\t\tJsonPrimitive p = (JsonPrimitive) val;\n\t\t\t\t\tif (p.isBoolean()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, val.getAsBoolean() + \"\");\n\t\t\t\t\t} else if (p.isNumber()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, val.getAsInt() + \"\");\n\t\t\t\t\t} else if (p.isJsonNull()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, \"null\");\n\t\t\t\t\t} else if (p.isString()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, \"\\\"\" + val.getAsString()\n\t\t\t\t\t\t\t\t+ \"\\\"\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t\t}\n\t\t\t\t} else if (val.isJsonArray()) {\n\t\t\t\t\tJsonArray a = (JsonArray) val;\n\t\t\t\t\tString s = \"[\";\n\t\t\t\t\tboolean first = true;\n\t\t\t\t\tfor (JsonElement e : a) {\n\t\t\t\t\t\tif (e.isJsonPrimitive()) {\n\t\t\t\t\t\t\tJsonPrimitive p = (JsonPrimitive) e;\n\t\t\t\t\t\t\tString add;\n\t\t\t\t\t\t\tif (p.isBoolean()) {\n\t\t\t\t\t\t\t\tadd = p.getAsBoolean() + \"\";\n\t\t\t\t\t\t\t} else if (p.isNumber()) {\n\t\t\t\t\t\t\t\tadd = p.getAsInt() + \"\";\n\t\t\t\t\t\t\t} else if (p.isString()) {\n\t\t\t\t\t\t\t\tadd = \"\\\"\" + p.getAsString() + \"\\\"\";\n\t\t\t\t\t\t\t} else if (p.isJsonNull()) {\n\t\t\t\t\t\t\t\tadd = \"null\";\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ts += (first ? \"\" : \",\") + add;\n\t\t\t\t\t\t\tfirst = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tt.addAdditionalEntry(key, s + \"]\");\n\t\t\t\t} else {\n\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn t;\n\t}\n", "output": "\tpublic static Task parse_json(JsonObject el, AccountMirakel account) {\n\t\tTask t = null;\n\t\tJsonElement id = el.get(\"id\");\n\t\tif (id != null) {\n\t\t\tt = Task.get(id.getAsLong());\n\t\t} else {\n\t\t\tid = el.get(\"uuid\");\n\t\t\tif (id != null) {\n\t\t\t\tt = Task.getByUUID(id.getAsString());\n\t\t\t}\n\t\t}\n\t\tif (t == null) {\n\t\t\tt = new Task();\n\t\t}\n\t\tSet> entries = el.entrySet();\n\t\tfor (Entry entry : entries) {\n\t\t\tString key = entry.getKey();\n\t\t\tJsonElement val = entry.getValue();\n\t\t\tif (key == null || key.equals(\"id\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (key.equals(\"uuid\")) {\n\t\t\t\tt.setUUID(val.getAsString());\n\t\t\t} else if (key.equals(\"name\") || key.equals(\"description\")) {\n\t\t\t\tt.setName(val.getAsString());\n\t\t\t} else if (key.equals(\"content\")) {\n\t\t\t\tString content = val.getAsString();\n\t\t\t\tif (content == null) {\n\t\t\t\t\tcontent = \"\";\n\t\t\t\t}\n\t\t\t\tt.setContent(content);\n\t\t\t} else if (key.equals(\"priority\")) {\n\t\t\t\tString prioString = val.getAsString().trim();\n\t\t\t\tif (prioString.equals(\"L\") && t.getPriority() != -1) {\n\t\t\t\t\tt.setPriority(-2);\n\t\t\t\t} else if (prioString.equals(\"M\")) {\n\t\t\t\t\tt.setPriority(1);\n\t\t\t\t} else if (prioString.equals(\"H\")) {\n\t\t\t\t\tt.setPriority(2);\n\t\t\t\t} else if (!prioString.equals(\"L\")) {\n\t\t\t\t\tt.setPriority(val.getAsInt());\n\t\t\t\t}\n\t\t\t} else if(key.equals(\"progress\")) {\n\t\t\t\tint progress=(int) val.getAsDouble();\n\t\t\t\tt.setProgress(progress);\n\t\t\t} else if (key.equals(\"list_id\")) {\n\t\t\t\tListMirakel list = ListMirakel.getList(val.getAsInt());\n\t\t\t\tif (list == null) {\n\t\t\t\t\tlist = SpecialList.firstSpecial().getDefaultList();\n\t\t\t\t}\n\t\t\t\tt.setList(list, true);\n\t\t\t} else if (key.equals(\"project\")) {\n\t\t\t\tListMirakel list = ListMirakel.findByName(val.getAsString(),\n\t\t\t\t\t\taccount);\n\t\t\t\tif (list == null\n\t\t\t\t\t\t|| list.getAccount().getId() != account.getId()) {\n\t\t\t\t\tlist = ListMirakel.newList(val.getAsString(),\n\t\t\t\t\t\t\tListMirakel.SORT_BY_OPT, account);\n\t\t\t\t}\n\t\t\t\tt.setList(list, true);\n\t\t\t} else if (key.equals(\"created_at\")) {\n\t\t\t\tt.setCreatedAt(val.getAsString().replace(\":\", \"\"));\n\t\t\t} else if (key.equals(\"updated_at\")) {\n\t\t\t\tt.setUpdatedAt(val.getAsString().replace(\":\", \"\"));\n\t\t\t} else if (key.equals(\"entry\")) {\n\t\t\t\tt.setCreatedAt(parseDate(val.getAsString(),\n\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat)));\n\t\t\t} else if (key.equals(\"modification\")) {\n\t\t\t\tt.setUpdatedAt(parseDate(val.getAsString(),\n\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat)));\n\t\t\t} else if (key.equals(\"modified\")) {\n\t\t\t\tCalendar modification = new GregorianCalendar();\n\t\t\t\tmodification\n\t\t\t\t\t\t.setTimeInMillis(Long.parseLong(val.getAsString()) * 1000);\n\t\t\t\tt.setUpdatedAt(modification);\n\t\t\t} else if (key.equals(\"done\")) {\n\t\t\t\tt.setDone(val.getAsBoolean());\n\t\t\t} else if (key.equals(\"status\")) {\n\t\t\t\tString status = val.getAsString();\n\t\t\t\tif (status.equals(\"pending\")) {\n\t\t\t\t\tt.setDone(false);\n\t\t\t\t} else if (status.equals(\"deleted\")) {\n\t\t\t\t\tt.setSyncState(SYNC_STATE.DELETE);\n\t\t\t\t} else {\n\t\t\t\t\tt.setDone(true);\n\t\t\t\t}\n\t\t\t\tt.addAdditionalEntry(key, \"\\\"\" + val.getAsString() + \"\\\"\");\n\t\t\t} else if (key.equals(\"due\")) {\n\t\t\t\tCalendar due = parseDate(val.getAsString(), \"yyyy-MM-dd\");\n\t\t\t\tif (due == null) {\n\t\t\t\t\tdue = parseDate(val.getAsString(),\n\t\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat));\n\t\t\t\t\tif (due != null) {\n\t\t\t\t\t\tdue.setTimeInMillis(due.getTimeInMillis()\n\t\t\t\t\t\t\t\t+ TimeZone.getDefault().getRawOffset());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tt.setDue(due);\n\t\t\t} else if (key.equals(\"reminder\")) {\n\t\t\t\tCalendar reminder = parseDate(val.getAsString(), \"yyyy-MM-dd\");\n\t\t\t\tif (reminder == null) {\n\t\t\t\t\treminder = parseDate(val.getAsString(),\n\t\t\t\t\t\t\tcontext.getString(R.string.TWDateFormat));\n\t\t\t\t}\n\t\t\t\tt.setReminder(reminder);\n\t\t\t} else if (key.equals(\"annotations\")) {\n\t\t\t\tString content = \"\";\n\t\t\t\ttry {\n\t\t\t\t\tJsonArray annotations = val.getAsJsonArray();\n\t\t\t\t\tboolean first = true;\n\t\t\t\t\tfor (JsonElement a : annotations) {\n\t\t\t\t\t\tif (first) {\n\t\t\t\t\t\t\tfirst = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcontent += \"\\n\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontent += a.getAsJsonObject().get(\"description\")\n\t\t\t\t\t\t\t\t.getAsString();\n\t\t\t\t\t}\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tLog.e(TAG, \"cannot parse json\");\n\t\t\t\t}\n\t\t\t\tt.setContent(content);\n\t\t\t} else if (key.equals(\"content\")) {\n\t\t\t\tt.setContent(val.getAsString());\n\t\t\t} else if (key.equals(\"sync_state\")) {\n\t\t\t\tt.setSyncState(SYNC_STATE.parseInt(val.getAsInt()));\n\t\t\t} else if (key.equals(\"depends\")) {\n\t\t\t\tt.setDependencies(val.getAsString().split(\",\"));\n\t\t\t} else {\n\t\t\t\tif (val.isJsonPrimitive()) {\n\t\t\t\t\tJsonPrimitive p = (JsonPrimitive) val;\n\t\t\t\t\tif (p.isBoolean()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, val.getAsBoolean() + \"\");\n\t\t\t\t\t} else if (p.isNumber()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, val.getAsInt() + \"\");\n\t\t\t\t\t} else if (p.isJsonNull()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, \"null\");\n\t\t\t\t\t} else if (p.isString()) {\n\t\t\t\t\t\tt.addAdditionalEntry(key, \"\\\"\" + val.getAsString()\n\t\t\t\t\t\t\t\t+ \"\\\"\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t\t}\n\t\t\t\t} else if (val.isJsonArray()) {\n\t\t\t\t\tJsonArray a = (JsonArray) val;\n\t\t\t\t\tString s = \"[\";\n\t\t\t\t\tboolean first = true;\n\t\t\t\t\tfor (JsonElement e : a) {\n\t\t\t\t\t\tif (e.isJsonPrimitive()) {\n\t\t\t\t\t\t\tJsonPrimitive p = (JsonPrimitive) e;\n\t\t\t\t\t\t\tString add;\n\t\t\t\t\t\t\tif (p.isBoolean()) {\n\t\t\t\t\t\t\t\tadd = p.getAsBoolean() + \"\";\n\t\t\t\t\t\t\t} else if (p.isNumber()) {\n\t\t\t\t\t\t\t\tadd = p.getAsInt() + \"\";\n\t\t\t\t\t\t\t} else if (p.isString()) {\n\t\t\t\t\t\t\t\tadd = \"\\\"\" + p.getAsString() + \"\\\"\";\n\t\t\t\t\t\t\t} else if (p.isJsonNull()) {\n\t\t\t\t\t\t\t\tadd = \"null\";\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ts += (first ? \"\" : \",\") + add;\n\t\t\t\t\t\t\tfirst = false;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tt.addAdditionalEntry(key, s + \"]\");\n\t\t\t\t} else {\n\t\t\t\t\tLog.w(TAG, \"unkown json-type\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn t;\n\t}\n"} {"input": "\tpublic void sync() throws IOException {\n\t\tint blocks = 0;\n\t\tfor (DirectoryEntry dir : entries.values()) {\n\t\t\tDirent ent = (Dirent) dir;\n\t\t\tlog.debug(\"ent size\", ent.getSize());\n\t\t\tint n = ent.numberHeaderBlocks();\n\t\t\tblocks += n;\n\t\t}\n\t\tlong dirPosition = chan.position();\n\t\tint blockSize = headerBlockManager.getBlockSize();\n\t\tint forHeader = (blocks + DirectoryEntry.SLOTS_PER_ENTRY - 1)/DirectoryEntry.SLOTS_PER_ENTRY;\n\t\tlog.debug(\"header blocks needed\", forHeader);\n\t\tchan.position(dirPosition + (long) forHeader * Dirent.ENTRY_SIZE);\n\t\tfor (DirectoryEntry dir : entries.values()) {\n\t\t\tDirent ent = (Dirent) dir;\n\t\t\tif (!ent.isSpecial()) {\n\t\t\t\tlog.debug(\"wrting \", dir.getFullName(), \" at \", chan.position());\n\t\t\t\tlog.debug(\"ent size\", ent.getSize());\n\t\t\t\tent.sync(chan);\n\t\t\t}\n\t\t}\n\t\tlong end = (long) blockSize * headerBlockManager.getMaxBlock();\n\t\tByteBuffer buf = ByteBuffer.allocate((int) (end - chan.position()));\n\t\tfor (int i = 0; i < buf.capacity(); i++)\n\t\t\tbuf.put((byte) 0);\n\t\tbuf.flip();\n\t\tchan.write(buf);\n\t\tchan.position(dirPosition);\n\t\tDirent ent = (Dirent) entries.values().iterator().next();\n\t\tlog.debug(\"ent header size\", ent.getSize());\n\t\tent.sync(chan);\n\t}\n", "output": "\tpublic void sync() throws IOException {\n\t\tint blocks = 0;\n\t\tfor (DirectoryEntry dir : entries.values()) {\n\t\t\tDirent ent = (Dirent) dir;\n\t\t\tlog.debug(\"ent size\", ent.getSize());\n\t\t\tint n = ent.numberHeaderBlocks();\n\t\t\tblocks += n;\n\t\t}\n\t\tlong dirPosition = chan.position();\n\t\tint blockSize = headerBlockManager.getBlockSize();\n\t\tint forHeader = (blocks + Dirent.ENTRY_SIZE - 1)/Dirent.ENTRY_SIZE;\n\t\tlog.debug(\"header blocks needed\", forHeader);\n\t\tassert forHeader == 1;\n\t\tchan.position(dirPosition + (long) forHeader * Dirent.ENTRY_SIZE);\n\t\tfor (DirectoryEntry dir : entries.values()) {\n\t\t\tDirent ent = (Dirent) dir;\n\t\t\tif (!ent.isSpecial()) {\n\t\t\t\tlog.debug(\"wrting \", dir.getFullName(), \" at \", chan.position());\n\t\t\t\tlog.debug(\"ent size\", ent.getSize());\n\t\t\t\tent.sync(chan);\n\t\t\t}\n\t\t}\n\t\tlong end = (long) blockSize * headerBlockManager.getMaxBlock();\n\t\tByteBuffer buf = ByteBuffer.allocate((int) (end - chan.position()));\n\t\tfor (int i = 0; i < buf.capacity(); i++)\n\t\t\tbuf.put((byte) 0);\n\t\tbuf.flip();\n\t\tchan.write(buf);\n\t\tchan.position(dirPosition);\n\t\tDirent ent = (Dirent) entries.values().iterator().next();\n\t\tlog.debug(\"ent header size\", ent.getSize());\n\t\tent.sync(chan);\n\t}\n"} {"input": "\tpublic final boolean performFinish() {\n\t\tfinal AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(\n\t\t\t\tthis.repository.getKind());\n\t\tfinal String taskId = getTaskId();\n\t\ttry {\n\t\t\tgetContainer().run(true, false, new IRunnableWithProgress() {\n\t\t\t\tpublic void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {\n\t\t\t\t\tmonitor.beginTask(\"Retrieving task...\", IProgressMonitor.UNKNOWN);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tnewTask = connector.createTaskFromExistingKey(repository, taskId, null);\n\t\t\t\t\t\tif (newTask instanceof AbstractRepositoryTask) {\n\t\t\t\t\t\t\tTasksUiPlugin.getSynchronizationManager().synchronize(connector, (AbstractRepositoryTask)newTask, true, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tthrow new InvocationTargetException(e);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tmonitor.done();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (InvocationTargetException e) {\n\t\t\tString message = e.getCause() != null ? e.getCause().getMessage() : \"None provided\";\n\t\t\tMessageDialog.openWarning(this.getShell(), \"Add Existing Task Failed\",\n\t\t\t\t\t\"Unable to retrieve existing task from repository, error was: \\n\\n\" + message);\n\t\t} catch (InterruptedException e) {\n\t\t\treturn true;\n\t\t}\n\t\tif (newTask != null && TaskListView.getFromActivePerspective() != null) {\n\t\t\tObject selectedObject = ((IStructuredSelection) TaskListView.getFromActivePerspective().getViewer()\n\t\t\t\t\t.getSelection()).getFirstElement();\n\t\t\tif (selectedObject instanceof TaskCategory) {\n\t\t\t\tTasksUiPlugin.getTaskListManager().getTaskList().moveToContainer(((TaskCategory) selectedObject),\n\t\t\t\t\t\tnewTask);\n\t\t\t} else {\n\t\t\t\tTasksUiPlugin.getTaskListManager().getTaskList().moveToRoot(newTask);\n\t\t\t}\n\t\t\tif (TaskListView.getFromActivePerspective() != null) {\n\t\t\t\tTaskListView.getFromActivePerspective().getViewer().setSelection(new StructuredSelection(newTask));\n\t\t\t}\n\t\t\tTaskUiUtil.openEditor(newTask, false);\n\t\t} else {\n\t\t\tMessageDialog.openWarning(this.getShell(), \"Add Existing Task Failed\",\n\t\t\t\t\t\"Unable to retrieve task from repository.\");\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic final boolean performFinish() {\n\t\tfinal AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(\n\t\t\t\tthis.repository.getKind());\n\t\tfinal String taskId = getTaskId();\n\t\ttry {\n\t\t\tgetContainer().run(true, false, new IRunnableWithProgress() {\n\t\t\t\tpublic void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {\n\t\t\t\t\tmonitor.beginTask(\"Retrieving task...\", IProgressMonitor.UNKNOWN);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tnewTask = connector.createTaskFromExistingKey(repository, taskId, null);\n\t\t\t\t\t\tif (newTask instanceof AbstractRepositoryTask) {\n\t\t\t\t\t\t\tTasksUiPlugin.getSynchronizationManager().synchronize(connector, (AbstractRepositoryTask)newTask, true, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tthrow new InvocationTargetException(e);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tmonitor.done();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (InvocationTargetException e) {\n\t\t\tString message = e.getCause() != null ? e.getCause().getMessage() : \"None provided\";\n\t\t\tMessageDialog.openWarning(this.getShell(), \"Add Existing Task Failed\",\n\t\t\t\t\t\"Unable to retrieve existing task from repository, error was: \\n\\n\" + message);\n\t\t\treturn false;\n\t\t} catch (InterruptedException e) {\n\t\t\treturn true;\n\t\t}\n\t\tif (newTask != null && TaskListView.getFromActivePerspective() != null) {\n\t\t\tObject selectedObject = ((IStructuredSelection) TaskListView.getFromActivePerspective().getViewer()\n\t\t\t\t\t.getSelection()).getFirstElement();\n\t\t\tif (selectedObject instanceof TaskCategory) {\n\t\t\t\tTasksUiPlugin.getTaskListManager().getTaskList().moveToContainer(((TaskCategory) selectedObject),\n\t\t\t\t\t\tnewTask);\n\t\t\t} else {\n\t\t\t\tTasksUiPlugin.getTaskListManager().getTaskList().moveToRoot(newTask);\n\t\t\t}\n\t\t\tif (TaskListView.getFromActivePerspective() != null) {\n\t\t\t\tTaskListView.getFromActivePerspective().getViewer().setSelection(new StructuredSelection(newTask));\n\t\t\t}\n\t\t\tTaskUiUtil.openEditor(newTask, false);\n\t\t} else {\n\t\t\tMessageDialog.openWarning(this.getShell(), \"Add Existing Task Failed\",\n\t\t\t\t\t\"Unable to retrieve task from repository.\");\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": "\tprotected void processCommand(Command c) {\n\t\tMap response = null, read = null;\n\t\tlong start;\n\t\tlong maxwait = 10000;\n\t\ttry {\n\t\t\temptyRead();\n\t\t\tresponse = (Map)connection.execute(\"session.meterpreter_write\", new Object[] { session, Base64.encode(c.text) });\n\t\t\tif (c.text.startsWith(\"cd \"))\n\t\t\t\treturn;\n\t\t\tif (c.text.startsWith(\"rm \"))\n\t\t\t\treturn;\n\t\t\tif (c.text.equals(\"shell\\n\") || c.text.equals(\"exit\\n\"))\n\t\t\t\treturn;\n\t\t\tread = readResponse();\n\t\t\tstart = System.currentTimeMillis();\n\t\t\twhile (\"\".equals(read.get(\"data\")) || read.get(\"data\").toString().startsWith(\"[-] Error running command read\")) {\n\t\t\t\tif ((System.currentTimeMillis() - start) > maxwait) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tThread.sleep(100);\n\t\t\t\tread = readResponse();\n\t\t\t}\n\t\t\tfireEvent(c, read);\n\t\t\tThread.sleep(50);\n\t\t\tread = readResponse();\n\t\t\twhile (!\"\".equals(read.get(\"data\"))) {\n\t\t\t\tfireEvent(c, read);\n\t\t\t\tread = readResponse();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tSystem.err.println(session + \" -> \" + c.text + \" ( \" + response + \")\");\n\t\t\tex.printStackTrace();\n\t\t}\n\t}\n", "output": "\tprotected void processCommand(Command c) {\n\t\tMap response = null, read = null;\n\t\tlong start;\n\t\tlong maxwait = 12000;\n\t\ttry {\n\t\t\temptyRead();\n\t\t\tresponse = (Map)connection.execute(\"session.meterpreter_write\", new Object[] { session, Base64.encode(c.text) });\n\t\t\tif (c.text.startsWith(\"cd \"))\n\t\t\t\treturn;\n\t\t\tif (c.text.startsWith(\"rm \"))\n\t\t\t\treturn;\n\t\t\tif (c.text.equals(\"shell\\n\") || c.text.equals(\"exit\\n\"))\n\t\t\t\treturn;\n\t\t\tread = readResponse();\n\t\t\tstart = System.currentTimeMillis();\n\t\t\twhile (\"\".equals(read.get(\"data\")) || read.get(\"data\").toString().startsWith(\"[-] Error running command read\")) {\n\t\t\t\tif ((System.currentTimeMillis() - start) > maxwait) {\n\t\t\t\t\tSystem.err.println(\"(\" + session + \") - '\" + c.text + \"' - timed out\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tThread.sleep(100);\n\t\t\t\tread = readResponse();\n\t\t\t}\n\t\t\tfireEvent(c, read);\n\t\t\tThread.sleep(50);\n\t\t\tread = readResponse();\n\t\t\twhile (!\"\".equals(read.get(\"data\"))) {\n\t\t\t\tfireEvent(c, read);\n\t\t\t\tread = readResponse();\n\t\t\t}\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tSystem.err.println(session + \" -> \" + c.text + \" ( \" + response + \")\");\n\t\t\tex.printStackTrace();\n\t\t}\n\t}\n"} {"input": " public static String byteArrayToHex(byte[] array, int length, long arrayOffset) {\n if (array == null) {\n return \"\";\n } \n else {\n StringBuilder outputStringBuilder = new StringBuilder();\n for (int curOffset = 0; curOffset < length; curOffset += 16) {\n int lineLen = 16;\n if (length - curOffset < 16) {\n lineLen = length - curOffset;\n }\n outputStringBuilder.append(String.format(\"0x%08x: \", arrayOffset + curOffset));\n for (int i = 0; i < 16; i++) {\n if (i < lineLen) { \n int v = array[curOffset + i] & 0xFF;\n outputStringBuilder.append(hexArray[v >>> 4]);\n outputStringBuilder.append(hexArray[v & 0x0F]);\n }\n else {\n outputStringBuilder.append(\" \");\n }\n if (true) {\n outputStringBuilder.append(\" \");\n if (i % 4 == 3) {\n outputStringBuilder.append(\" \");\n }\n if (i == 7) {\n outputStringBuilder.append(\" \");\n }\n }\n else {\n if (i % 2 == 1) {\n outputStringBuilder.append(\" \");\n }\n }\n }\n outputStringBuilder.append(\" \");\n String ascii = new String(array, curOffset, lineLen); \n for (int i = 0; i < 16; i++) {\n char c = ' ';\n if (i < lineLen) {\n c = ascii.charAt(i);\n int dec = (int) c;\n if (dec < 32 || dec > 126) {\n c = '.';\n }\n }\n outputStringBuilder.append(c); \n }\n outputStringBuilder.append(\"\\n\");\n }\n return outputStringBuilder.toString();\n }\n }\n", "output": " public static String byteArrayToHex(byte[] array, int length, long arrayOffset) {\n if (array == null) {\n return \"\";\n } \n else {\n StringBuilder outputStringBuilder = new StringBuilder();\n for (int curOffset = 0; curOffset < length; curOffset += 16) {\n int lineLen = 16;\n if (length - curOffset < 16) {\n lineLen = length - curOffset;\n }\n outputStringBuilder.append(String.format(\"0x%08x: \", arrayOffset + curOffset));\n for (int i = 0; i < 16; i++) {\n if (i < lineLen) { \n int v = array[curOffset + i] & 0xFF;\n outputStringBuilder.append(hexArray[v >>> 4]);\n outputStringBuilder.append(hexArray[v & 0x0F]);\n }\n else {\n outputStringBuilder.append(\" \");\n }\n if (true) {\n outputStringBuilder.append(\" \");\n if (i % 4 == 3) {\n outputStringBuilder.append(\" \");\n }\n if (i == 7) {\n outputStringBuilder.append(\" \");\n }\n }\n else {\n if (i % 2 == 1) {\n outputStringBuilder.append(\" \");\n }\n }\n }\n outputStringBuilder.append(\" \");\n String ascii = new String(array, curOffset, lineLen, java.nio.charset.StandardCharsets.US_ASCII); \n for (int i = 0; i < 16; i++) {\n char c = ' ';\n if (i < ascii.length()) {\n c = ascii.charAt(i);\n int dec = (int) c;\n if (dec < 32 || dec > 126) {\n c = '.';\n }\n }\n outputStringBuilder.append(c); \n }\n outputStringBuilder.append(\"\\n\");\n }\n return outputStringBuilder.toString();\n }\n }\n"} {"input": " public void testSensorOperations() {\n final SensorManager mSensorManager =\n (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);\n List sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);\n assertNotNull(sensors);\n Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);\n assertEquals(Sensor.TYPE_ACCELEROMETER, sensor.getType());\n assertSensorValues(sensor);\n sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);\n assertEquals(Sensor.TYPE_MAGNETIC_FIELD, sensor.getType());\n assertSensorValues(sensor);\n sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);\n assertEquals(Sensor.TYPE_ORIENTATION, sensor.getType());\n assertSensorValues(sensor);\n sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_TEMPERATURE);\n assertEquals(Sensor.TYPE_TEMPERATURE, sensor.getType());\n assertSensorValues(sensor);\n }\n", "output": " public void testSensorOperations() {\n final SensorManager mSensorManager =\n (SensorManager) getContext().getSystemService(Context.SENSOR_SERVICE);\n List sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);\n assertNotNull(sensors);\n Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);\n assertEquals(Sensor.TYPE_ACCELEROMETER, sensor.getType());\n assertSensorValues(sensor);\n sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);\n assertEquals(Sensor.TYPE_MAGNETIC_FIELD, sensor.getType());\n assertSensorValues(sensor);\n sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);\n assertEquals(Sensor.TYPE_ORIENTATION, sensor.getType());\n assertSensorValues(sensor);\n sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_TEMPERATURE);\n if (sensor != null) {\n assertEquals(Sensor.TYPE_TEMPERATURE, sensor.getType());\n assertSensorValues(sensor);\n }\n }\n"} {"input": "\tpublic void execute(Map p) {\n\t\tthis.destination = MathUtil.getPuntDesti(this.laser.position.toPoint(), this.destination, 2000f);\n\t\tthis.laser.lastParringJedi = jedi;\n\t\tthis.laser.jumps--;\n\t\tsuper.execute(p);\n\t\tjedi.forceStopMovement();\n\t\tjedi.animateParryLaser(this.destination.clone());\n\t}\n", "output": "\tpublic void execute(Map p) {\n\t\tthis.destination = MathUtil.getPuntDesti(this.laser.position.toPoint(), this.destination, 2000f);\n\t\tthis.laser.lastParringJedi = jedi;\n\t\tthis.laser.jumps--;\n\t\tsuper.execute(p);\n\t\tjedi.forceStopMovement();\n\t\tjedi.animateParryLaser(this.laser.position.toPoint());\n\t}\n"} {"input": "\tpublic static ArrayList parseForumThreads(TagNode aResponse) throws Exception {\n\t\tlong startTime = System.currentTimeMillis();\n ArrayList result = new ArrayList();\n TagNode[] threads = aResponse.getElementsByAttValue(\"class\", \"thread\", true, true);\n\t\tfor(TagNode node : threads){\n AwfulThread thread = new AwfulThread();\n try {\n String threadId = node.getAttributeByName(\"id\");\n thread.setThreadId(threadId.replaceAll(\"thread\", \"\"));\n } catch (NullPointerException e) {\n e.printStackTrace();\n continue;\n }\n \tTagNode[] tarThread = node.getElementsByAttValue(\"class\", \"thread_title\", true, true);\n \tTagNode[] tarUser = node.getElementsByAttValue(\"class\", \"author\", true, true);\n Object[] nodeList;\n if (tarThread.length > 0) {\n thread.setTitle(((TagNode) tarThread[0]).getText().toString().trim());\n }\n TagNode[] tarSticky = node.getElementsByAttValue(\"class\", \"title title_sticky\", true, true);\n if (tarSticky.length > 0) {\n thread.setSticky(true);\n } else {\n thread.setSticky(false);\n }\n TagNode[] tarIcon = node.getElementsByAttValue(\"class\", \"icon\", true, true);\n if (tarIcon.length > 0 && tarIcon[0].getChildTags().length >0) {\n thread.setIcon(tarIcon[0].getChildTags()[0].getAttributeByName(\"src\"));\n }\n if (tarUser.length > 0) {\n thread.setAuthor(tarUser[0].getText().toString().trim());\n }\n TagNode[] tarCount = node.getElementsByAttValue(\"class\", \"count\", true, true);\n if (tarCount.length > 0 && tarCount[0].getChildTags().length >0) {\n thread.setUnreadCount(Integer.parseInt(\n \t\ttarCount[0].getChildTags()[0].getText().toString().trim()));\n } else {\n \tTagNode[] tarXCount = node.getElementsByAttValue(\"class\", \"x\", true, true);\n\t\t\t\t\tif (tarXCount.length > 0) {\n\t\t\t\t\t\tthread.setUnreadCount(0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthread.setUnreadCount(-1);\n\t\t\t\t\t} \n }\n result.add(thread);\n }\n Log.e(\"AwfulThread\", \"Process Time: \"+(System.currentTimeMillis()-startTime));\n return result;\n }\n", "output": "\tpublic static ArrayList parseForumThreads(TagNode aResponse) throws Exception {\n\t\tlong startTime = System.currentTimeMillis();\n ArrayList result = new ArrayList();\n TagNode[] threads = aResponse.getElementsByAttValue(\"id\", \"forum\", true, true);\n TagNode[] tbody = threads[0].getElementsByName(\"tbody\", false);\n\t\tfor(TagNode node : tbody[0].getChildTags()){\n AwfulThread thread = new AwfulThread();\n try {\n String threadId = node.getAttributeByName(\"id\");\n thread.setThreadId(threadId.replaceAll(\"thread\", \"\"));\n } catch (NullPointerException e) {\n e.printStackTrace();\n continue;\n }\n \tTagNode[] tarThread = node.getElementsByAttValue(\"class\", \"thread_title\", true, true);\n \tTagNode[] tarUser = node.getElementsByAttValue(\"class\", \"author\", true, true);\n Object[] nodeList;\n if (tarThread.length > 0) {\n thread.setTitle(((TagNode) tarThread[0]).getText().toString().trim());\n }\n TagNode[] tarSticky = node.getElementsByAttValue(\"class\", \"title title_sticky\", true, true);\n if (tarSticky.length > 0) {\n thread.setSticky(true);\n } else {\n thread.setSticky(false);\n }\n TagNode[] tarIcon = node.getElementsByAttValue(\"class\", \"icon\", true, true);\n if (tarIcon.length > 0 && tarIcon[0].getChildTags().length >0) {\n thread.setIcon(tarIcon[0].getChildTags()[0].getAttributeByName(\"src\"));\n }\n if (tarUser.length > 0) {\n thread.setAuthor(tarUser[0].getText().toString().trim());\n }\n TagNode[] tarCount = node.getElementsByAttValue(\"class\", \"count\", true, true);\n if (tarCount.length > 0 && tarCount[0].getChildTags().length >0) {\n thread.setUnreadCount(Integer.parseInt(\n \t\ttarCount[0].getChildTags()[0].getText().toString().trim()));\n } else {\n \tTagNode[] tarXCount = node.getElementsByAttValue(\"class\", \"x\", true, true);\n\t\t\t\t\tif (tarXCount.length > 0) {\n\t\t\t\t\t\tthread.setUnreadCount(0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthread.setUnreadCount(-1);\n\t\t\t\t\t} \n }\n result.add(thread);\n }\n Log.e(\"AwfulThread\", \"Process Time: \"+(System.currentTimeMillis()-startTime));\n return result;\n }\n"} {"input": "\tpublic boolean sendPluginMessage(Player player, String message){\n\t\tif(player == null || message == null){\n\t\t\treturn false;\n\t\t}\n\t\tif(!player.getListeningPluginChannels().contains(\"SimpleNotice\")){\n\t\t\treturn false;\n\t\t}\n\t\ttry{\n\t\t\tplayer.sendPluginMessage(AntiShare.getInstance(), \"SimpleNotice\", message.getBytes(\"UTF-8\"));\n\t\t\treturn true;\n\t\t}catch(Exception e){\n\t\t\tAntiShare.getInstance().getMessenger().log(\"AntiShare encountered and error. Please report this to turt2live.\", Level.SEVERE, LogType.ERROR);\n\t\t\tAntiShare.getInstance().getMessenger().log(\"Please see \" + ErrorLog.print(e) + \" for the full error.\", Level.SEVERE, LogType.ERROR);\n\t\t\treturn false;\n\t\t}\n\t}\n", "output": "\tpublic boolean sendPluginMessage(Player player, String message){\n\t\tif(player == null || message == null){\n\t\t\treturn false;\n\t\t}\n\t\tif(!player.getListeningPluginChannels().contains(\"SimpleNotice\")){\n\t\t\treturn false;\n\t\t}\n\t\ttry{\n\t\t\tplayer.sendPluginMessage(AntiShare.getInstance(), \"SimpleNotice\", message.getBytes());\n\t\t\treturn true;\n\t\t}catch(Exception e){\n\t\t\tAntiShare.getInstance().getMessenger().log(\"AntiShare encountered and error. Please report this to turt2live.\", Level.SEVERE, LogType.ERROR);\n\t\t\tAntiShare.getInstance().getMessenger().log(\"Please see \" + ErrorLog.print(e) + \" for the full error.\", Level.SEVERE, LogType.ERROR);\n\t\t\treturn false;\n\t\t}\n\t}\n"} {"input": "\tpublic View(Window window, boolean offscreen, boolean isSharedUniverse)\n\t{\t\t\n\t\tsuper(getPreferredConfiguration(window), offscreen);\n\t\tif(offscreen)\n\t\t{\n\t\t\tgetScreen3D().setPhysicalScreenWidth(0.0254/90.0 * 1600);\n\t\t\tgetScreen3D().setPhysicalScreenHeight(0.0254/90.0 * 1200); \n\t\t}\n\t\tif(isSharedUniverse)\n\t\t{\n\t\t\tif(sharedUniverse==null)\n\t\t\t{\n\t\t\t\tsharedUniverse=new SimpleUniverse(this);\n\t\t\t\tuniverse=View.sharedUniverse;\n\t\t\t\tviewingPlatform=universe.getViewingPlatform();\t\t\t\n\t\t\t\tuniverse.addBranchGraph(\n\t\t\t\t\tcreateLights(new BoundingSphere(new Point3d(),Double.MAX_VALUE)));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tuniverse=View.sharedUniverse;\n\t\t\t\tviewingPlatform=createViewingPlatform();\n\t\t\t\tsharedUniverse.getLocale().addBranchGraph(viewingPlatform);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tuniverse=new SimpleUniverse(this);\n\t\t\tviewingPlatform=universe.getViewingPlatform();\t\t\t\n\t\t\tuniverse.addBranchGraph(createLights(new BoundingSphere(new Point3d(),Double.MAX_VALUE)));\n\t\t}\n\t\torbit.setCapability(Node.ALLOW_BOUNDS_WRITE);\n\t\tviewingPlatform.setViewPlatformBehavior(orbit);\t\t\n\t\toriginAxisSwitch.setCapability(Switch.ALLOW_SWITCH_READ);\n\t\toriginAxisSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);\n\t\tfixedAxisSwitch.setCapability(Switch.ALLOW_SWITCH_READ);\n\t\tfixedAxisSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);\n\t\tfixedAxisTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);\n\t\tcreateAxis(originAxisTransformGroup);\n\t\toriginAxisSwitch.addChild(originAxisTransformGroup);\t\t\t\n\t\tViewSpecificGroup vsp=new ViewSpecificGroup();\t\t\t\t\n\t\tvsp.addView(getView());\t\t\n\t\tvsp.addChild(originAxisSwitch);\n\t\taxisBranchGroup.addChild(vsp);\n\t\tuniverse.addBranchGraph(axisBranchGroup);\n\t\tcreateClipBranchGroup();\n\t\tcreateWidgetsBranchGroup();\n\t\tcreateUnClipWidgetsBranchGroup();\n\t\tfinal TransformGroup tg=new TransformGroup();\n\t\ttg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);\n\t\ttg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);\n\t\tTransform3D t3d=new Transform3D();\n\t\tt3d.set(new Vector3d(-4, -4, -40));\n\t\tcreateAxis(fixedAxisTransformGroup);\t\t\n\t\ttg.setTransform(t3d);\n\t\ttg.addChild(fixedAxisTransformGroup);\n\t\tfixedAxisSwitch.addChild(tg);\n\t\tPlatformGeometry pg=new PlatformGeometry();\n\t\tvsp=new ViewSpecificGroup();\n\t\tvsp.addView(getView());\n\t\tvsp.addChild(fixedAxisSwitch);\n\t\tpg.addChild(vsp);\t\t\n\t\taxisBehavior=new AxisBehavior(fixedAxisTransformGroup,\n\t\t\tviewingPlatform.getViewPlatformTransform());\n\t\tpg.addChild(axisBehavior);\n\t\tviewingPlatform.setPlatformGeometry(pg);\n\t\taddComponentListener(new ComponentAdapter()\n\t\t{\n\t\t\tprivate Transform3D myT3d=new Transform3D();\n\t\t\tpublic void componentResized(ComponentEvent e)\n\t\t\t{\n\t\t\t\ttg.getTransform(myT3d);\n\t\t\t\tmyT3d.set(new Vector3d(-4, -4*((float)getHeight())/getWidth(), -40));\n\t\t\t\ttg.setTransform(myT3d);\n\t\t\t}\n\t\t});\n\t\tgetView().setFieldOfView(Math.PI/12);\n\t\tgetView().setFrontClipPolicy(javax.media.j3d.View.PHYSICAL_EYE);\n\t\tgetView().setBackClipPolicy(javax.media.j3d.View.PHYSICAL_EYE);\n\t\tzoomTo(0,0,0,1.0f);\t\n\t\taddKeyListener(new PAKeyListener());\n }\t\n", "output": "\tpublic View(Window window, boolean offscreen, boolean isSharedUniverse)\n\t{\t\t\n\t\tsuper(getPreferredConfiguration(window), offscreen);\n\t\tif(offscreen)\n\t\t{\n\t\t\tgetScreen3D().setPhysicalScreenWidth(0.0254/90.0 * 1600);\n\t\t\tgetScreen3D().setPhysicalScreenHeight(0.0254/90.0 * 1200); \n\t\t}\n\t\tif(isSharedUniverse)\n\t\t{\n\t\t\tif(sharedUniverse==null)\n\t\t\t{\n\t\t\t\tsharedUniverse=new SimpleUniverse(this);\n\t\t\t\tuniverse=View.sharedUniverse;\n\t\t\t\tviewingPlatform=universe.getViewingPlatform();\t\t\t\n\t\t\t\tuniverse.addBranchGraph(\n\t\t\t\t\tcreateLights(new BoundingSphere(new Point3d(),Double.MAX_VALUE)));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tuniverse=View.sharedUniverse;\n\t\t\t\tviewingPlatform=createViewingPlatform();\n\t\t\t\tsharedUniverse.getLocale().addBranchGraph(viewingPlatform);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tuniverse=new SimpleUniverse(this);\n\t\t\tviewingPlatform=universe.getViewingPlatform();\t\t\t\n\t\t\tuniverse.addBranchGraph(createLights(new BoundingSphere(new Point3d(),Double.MAX_VALUE)));\n\t\t}\n\t\torbit.setCapability(Node.ALLOW_BOUNDS_WRITE);\n\t\tviewingPlatform.setViewPlatformBehavior(orbit);\t\t\n\t\toriginAxisSwitch.setCapability(Switch.ALLOW_SWITCH_READ);\n\t\toriginAxisSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);\n\t\tfixedAxisSwitch.setCapability(Switch.ALLOW_SWITCH_READ);\n\t\tfixedAxisSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);\n\t\tfixedAxisTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);\n\t\tcreateAxis(originAxisTransformGroup);\n\t\toriginAxisSwitch.addChild(originAxisTransformGroup);\t\t\t\n\t\tViewSpecificGroup vsp=new ViewSpecificGroup();\t\t\t\t\n\t\tvsp.addView(getView());\t\t\n\t\tvsp.addChild(originAxisSwitch);\n\t\taxisBranchGroup.addChild(vsp);\n\t\tuniverse.addBranchGraph(axisBranchGroup);\n\t\tcreateClipBranchGroup();\n\t\tcreateWidgetsBranchGroup();\n\t\tcreateUnClipWidgetsBranchGroup();\n\t\tfinal TransformGroup tg=new TransformGroup();\n\t\ttg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);\n\t\ttg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);\n\t\tTransform3D t3d=new Transform3D();\n\t\tt3d.set(new Vector3d(-4, -4, -40));\n\t\tcreateAxis(fixedAxisTransformGroup);\t\t\n\t\ttg.setTransform(t3d);\n\t\ttg.addChild(fixedAxisTransformGroup);\n\t\tfixedAxisSwitch.addChild(tg);\n\t\tPlatformGeometry pg=new PlatformGeometry();\n\t\tvsp=new ViewSpecificGroup();\n\t\tvsp.addView(getView());\n\t\tvsp.addChild(fixedAxisSwitch);\n\t\tpg.addChild(vsp);\t\t\n\t\taxisBehavior=new AxisBehavior(fixedAxisTransformGroup,\n\t\t\tviewingPlatform.getViewPlatformTransform());\n\t\tpg.addChild(axisBehavior);\n\t\tviewingPlatform.setPlatformGeometry(pg);\n\t\taddComponentListener(new ComponentAdapter()\n\t\t{\n\t\t\tprivate Transform3D myT3d=new Transform3D();\n\t\t\tpublic void componentResized(ComponentEvent e)\n\t\t\t{\n\t\t\t\tif(getWidth()!=0)\n\t\t\t\t{\n\t\t\t\t\ttg.getTransform(myT3d);\n\t\t\t\t\tmyT3d.set(new Vector3d(-4, -4*((float)getHeight())/getWidth(), -40));\n\t\t\t\t\ttg.setTransform(myT3d);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tgetView().setFieldOfView(Math.PI/12);\n\t\tgetView().setFrontClipPolicy(javax.media.j3d.View.PHYSICAL_EYE);\n\t\tgetView().setBackClipPolicy(javax.media.j3d.View.PHYSICAL_EYE);\n\t\tzoomTo(0,0,0,1.0f);\t\n\t\taddKeyListener(new PAKeyListener());\n }\t\n"} {"input": "\tpublic double getV(int index, State qj) {\n\t\tassert(index >= 1);\n\t\tassert(index-1 < outputSencence.size()); \n\t\tdouble cachedValue = checkCache(index, qj); \n\t\tif (cachedValue != -1)\n\t\t\treturn cachedValue;\n\t\tif (index == 1) {\n\t\t\tdouble probability;\n\t\t\tprobability = stateCollection.startState().nextStateProbability(qj);\n\t\t\tprobability *= qj.wordEmittingProbability(new Word(outputSencence.get(0)));\n\t\t\taddToCache(index, qj, probability);\n\t\t\treturn probability;\t\t\t\n\t\t}\n\t\tdouble max = 0;\n\t\tfor (State qi : stateCollection.states.values()) {\n\t\t\tdouble value;\n\t\t\tvalue = getV(index - 1, qj);\n\t\t\tvalue *= qi.nextStateProbability(qj);\n\t\t\tvalue *= qj.wordEmittingProbability(new Word(outputSencence.get(index - 1)));\n\t\t\tif (value > max) {\n\t\t\t\tmax = value;\n\t\t\t}\n\t\t}\n\t\taddToCache(index, qj, max);\n\t\treturn max;\n\t}\n", "output": "\tpublic double getAlpha(int index, State qj) {\n\t\tassert(index >= 1);\n\t\tassert(index-1 < outputSencence.size()); \n\t\tdouble cachedValue = checkCache(index, qj); \n\t\tif (cachedValue != -1)\n\t\t\treturn cachedValue;\n\t\tif (index == 1) {\n\t\t\tdouble probability;\n\t\t\tprobability = stateCollection.startState().nextStateProbability(qj);\n\t\t\tprobability *= qj.wordEmittingProbability(new Word(outputSencence.get(0)));\n\t\t\taddToCache(index, qj, probability);\n\t\t\treturn probability;\t\t\t\n\t\t}\n\t\tdouble sum = 0;\n\t\tfor (State qi : stateCollection.states.values()) {\n\t\t\tdouble value;\n\t\t\tvalue = getAlpha(index - 1, qj);\n\t\t\tvalue *= qi.nextStateProbability(qj);\n\t\t\tvalue *= qj.wordEmittingProbability(new Word(outputSencence.get(index - 1)));\n\t\t\tsum += value;\n\t\t}\n\t\taddToCache(index, qj, sum);\n\t\treturn sum;\n\t}\n"} {"input": "\tprivate void calculateRotationalAxis(Matrix rotation, Atom translation,\n\t\t\tdouble c) {\n\t\tdouble sum=0;\n\t\tdouble[] rotAx = new double[3];\n\t\tfor(int i=0;i<3;i++) {\n\t\t\trotAx[i] = Math.sqrt(rotation.get(i, i)-c);\n\t\t\tsum+=rotAx[i]*rotAx[i];\n\t\t}\n\t\tfor(int i=0;i<3;i++) {\n\t\t\trotAx[i] /= Math.sqrt(sum);\n\t\t}\n\t\tdouble d0 = rotation.get(2,1)-rotation.get(1,2); \n\t\tdouble d1 = rotation.get(0,2)-rotation.get(2,0); \n\t\tdouble d2 = rotation.get(1,0)-rotation.get(0,1); \n\t\tdouble s12 = rotation.get(2,1)+rotation.get(1,2); \n\t\tdouble s02 = rotation.get(0,2)+rotation.get(2,0); \n\t\tdouble s01 = rotation.get(1,0)+rotation.get(0,1); \n\t\tif( Math.abs(d0) < Math.abs(d1) ) {\n\t\t\tif( Math.abs(d1) < Math.abs(d2) ) { \n\t\t\t\tif(d2>=0){ \n\t\t\t\t\tif( s02 < 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 < 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t} else { \n\t\t\t\t\trotAx[2] = -rotAx[2];\n\t\t\t\t\tif( s02 >= 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 >= 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t}\n\t\t\t} else { \n\t\t\t\tif(d1>=0) {\n\t\t\t\t\tif( s01 < 0) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 < 0) rotAx[2] = -rotAx[2];\n\t\t\t\t} else { \n\t\t\t\t\trotAx[1] = -rotAx[1];\n\t\t\t\t\tif( s01 >= 0) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 >= 0) rotAx[2] = -rotAx[2];\n\t\t\t\t}\n\t\t\t}\n\t\t} else { \n\t\t\tif(d0>=0) { \n\t\t\t\tif( s01 < 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\tif( s02 < 0 ) rotAx[2] = -rotAx[2];\n\t\t\t} else { \n\t\t\t\trotAx[0] = -rotAx[0];\n\t\t\t\tif( s01 >= 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\tif( s02 >= 0 ) rotAx[2] = -rotAx[2];\n\t\t\t}\n\t\t}\n\t\trotationAxis = new AtomImpl();\n\t\trotationAxis.setCoords(rotAx);\n\t\tdouble dotProduct = Calc.skalarProduct(rotationAxis, translation);\n\t\tscrewTranslation = Calc.scale(rotationAxis, dotProduct);\n\t\totherTranslation = Calc.subtract(translation, screwTranslation);\n\t\tAtom hypot = Calc.vectorProduct(otherTranslation,rotationAxis);\n\t\tCalc.scaleEquals(hypot,.5/Math.tan(theta/2.0));\n\t\trotationPos = Calc.scaleAdd(.5,otherTranslation, hypot);\n\t}\n", "output": "\tprivate void calculateRotationalAxis(Matrix rotation, Atom translation,\n\t\t\tdouble c) {\n\t\tdouble sum=0;\n\t\tdouble[] rotAx = new double[3];\n\t\tfor(int i=0;i<3;i++) {\n\t\t\trotAx[i] = Math.sqrt(rotation.get(i, i)-c);\n\t\t\tsum+=rotAx[i]*rotAx[i];\n\t\t}\n\t\tfor(int i=0;i<3;i++) {\n\t\t\trotAx[i] /= Math.sqrt(sum);\n\t\t}\n\t\tdouble d0 = rotation.get(2,1)-rotation.get(1,2); \n\t\tdouble d1 = rotation.get(0,2)-rotation.get(2,0); \n\t\tdouble d2 = rotation.get(1,0)-rotation.get(0,1); \n\t\tdouble s12 = rotation.get(2,1)+rotation.get(1,2); \n\t\tdouble s02 = rotation.get(0,2)+rotation.get(2,0); \n\t\tdouble s01 = rotation.get(1,0)+rotation.get(0,1); \n\t\tif( Math.abs(d0) < Math.abs(d1) ) { \n\t\t\tif( Math.abs(d1) < Math.abs(d2) ) { \n\t\t\t\tif(d2>=0){ \n\t\t\t\t\tif( s02 < 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 < 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t} else { \n\t\t\t\t\trotAx[2] = -rotAx[2];\n\t\t\t\t\tif( s02 >= 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 >= 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t}\n\t\t\t} else { \n\t\t\t\tif(d1>=0) {\n\t\t\t\t\tif( s01 < 0) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 < 0) rotAx[2] = -rotAx[2];\n\t\t\t\t} else { \n\t\t\t\t\trotAx[1] = -rotAx[1];\n\t\t\t\t\tif( s01 >= 0) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 >= 0) rotAx[2] = -rotAx[2];\n\t\t\t\t}\n\t\t\t}\n\t\t} else { \n\t\t\tif( Math.abs(d0) < Math.abs(d2) ) { \n\t\t\t\tif(d2>=0){ \n\t\t\t\t\tif( s02 < 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 < 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t} else { \n\t\t\t\t\trotAx[2] = -rotAx[2];\n\t\t\t\t\tif( s02 >= 0 ) rotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s12 >= 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t}\n\t\t\t} else { \n\t\t\t\tif(d0>=0) { \n\t\t\t\t\tif( s01 < 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t\tif( s02 < 0 ) rotAx[2] = -rotAx[2];\n\t\t\t\t} else { \n\t\t\t\t\trotAx[0] = -rotAx[0];\n\t\t\t\t\tif( s01 >= 0 ) rotAx[1] = -rotAx[1];\n\t\t\t\t\tif( s02 >= 0 ) rotAx[2] = -rotAx[2];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\trotationAxis = new AtomImpl();\n\t\trotationAxis.setCoords(rotAx);\n\t\tdouble dotProduct = Calc.skalarProduct(rotationAxis, translation);\n\t\tscrewTranslation = Calc.scale(rotationAxis, dotProduct);\n\t\totherTranslation = Calc.subtract(translation, screwTranslation);\n\t\tAtom hypot = Calc.vectorProduct(otherTranslation,rotationAxis);\n\t\tCalc.scaleEquals(hypot,.5/Math.tan(theta/2.0));\n\t\trotationPos = Calc.scaleAdd(.5,otherTranslation, hypot);\n\t}\n"} {"input": " public void copySubstractingFieldFromLowerInstance(final DataDefinition technologyOperationComponentDD,\n final Entity technologyOperationComponent) {\n Entity operation = technologyOperationComponent.getBelongsToField(OPERATION);\n technologyOperationComponent.setField(IS_SUBCONTRACTING, operation.getBooleanField(IS_SUBCONTRACTING));\n }\n", "output": " public void copySubstractingFieldFromLowerInstance(final DataDefinition technologyOperationComponentDD,\n final Entity technologyOperationComponent) {\n Entity operation = technologyOperationComponent.getBelongsToField(OPERATION);\n if (operation != null) {\n technologyOperationComponent.setField(IS_SUBCONTRACTING, operation.getBooleanField(IS_SUBCONTRACTING));\n }\n }\n"} {"input": "\tprotected void initUniforms()\n\t{\n\t\tthis.addUniform(\"tColor\", new Uniform(Uniform.TYPE.T ));\n\t\tthis.addUniform(\"tDepth\", new Uniform(Uniform.TYPE.T ));\n\t\tthis.addUniform(\"focus\", new Uniform(Uniform.TYPE.F, 1.0));\n\t\tthis.addUniform(\"aspect\", new Uniform(Uniform.TYPE.F, 1.0));\n\t\tthis.addUniform(\"aperture\", new Uniform(Uniform.TYPE.F, 0.025));\n\t\tthis.addUniform(\"maxblur\", new Uniform(Uniform.TYPE.I, true));\n\t}\n", "output": "\tprotected void initUniforms()\n\t{\n\t\tthis.addUniform(\"tColor\", new Uniform(Uniform.TYPE.T ));\n\t\tthis.addUniform(\"tDepth\", new Uniform(Uniform.TYPE.T ));\n\t\tthis.addUniform(\"focus\", new Uniform(Uniform.TYPE.F, 1.0));\n\t\tthis.addUniform(\"aspect\", new Uniform(Uniform.TYPE.F, 1.0));\n\t\tthis.addUniform(\"aperture\", new Uniform(Uniform.TYPE.F, 0.025));\n\t\tthis.addUniform(\"maxblur\", new Uniform(Uniform.TYPE.F, 1.0));\n\t}\n"} {"input": " protected final void add_triangle_with_clip(int a, int b, int c) {\n boolean aClipped = false;\n boolean bClipped = false;\n int clippedCount = 0;\n cameraNear = -8;\n if (vertices[a][VZ] > cameraNear) {\n aClipped = true;\n clippedCount++;\n }\n if (vertices[b][VZ] > cameraNear) {\n bClipped = true;\n clippedCount++;\n }\n if (vertices[c][VZ] > cameraNear) {\n clippedCount++;\n }\n if (clippedCount == 0) {\n add_triangle_no_clip(a, b, c);\n return;\n }\n else if (clippedCount == 3) {\n return;\n }\n else if (clippedCount == 2) {\n int ca, cb, cc, cd, ce;\n if (!aClipped) {\n ca = a;\n cb = b;\n cc = c;\n }\n else if (!bClipped) {\n ca = b;\n cb = a;\n cc = c;\n }\n else { \n ca = c;\n cb = b;\n cc = a;\n }\n cd = interpolate_clip_vertex(ca, cb);\n ce = interpolate_clip_vertex(ca, cc);\n add_triangle_no_clip(ca, cd, ce);\n return;\n }\n else { \n int ca, cb, cc, cd, ce;\n if (aClipped) {\n ca = c;\n cb = b;\n cc = a;\n }\n else if (bClipped) {\n ca = a;\n cb = c;\n cc = b;\n }\n else { \n ca = a;\n cb = b;\n cc = c;\n }\n cd = interpolate_clip_vertex(ca, cc);\n ce = interpolate_clip_vertex(cb, cc);\n add_triangle_no_clip(ca, cd, cb);\n add_triangle_no_clip(cb, cd, ce);\n return;\n }\n }\n private final int interpolate_clip_vertex(int a, int b) {\n float[] va;\n float[] vb;\n if (vertices[a][VZ] < vertices[b][VZ]) {\n va = vertices[b];\n vb = vertices[a];\n }\n else {\n va = vertices[a];\n vb = vertices[b];\n }\n float az = va[VZ];\n float bz = vb[VZ];\n float dz = az - bz;\n if (dz == 0) {\n return a;\n }\n float pa = (cameraNear - bz) / dz;\n float pb = 1 - pa;\n vertex(pa * va[MX] + pb * vb[MX],\n pa * va[MY] + pb * vb[MY],\n pa * va[MZ] + pb * vb[MZ]);\n int irv = vertexCount - 1;\n vertex_end_including_clip_verts++;\n float[] rv = vertices[irv];\n rv[X] = pa * va[X] + pb * vb[X];\n rv[Y] = pa * va[Y] + pb * vb[Y];\n rv[Z] = pa * va[Z] + pb * vb[Z];\n rv[VX] = pa * va[VX] + pb * vb[VX];\n rv[VY] = pa * va[VY] + pb * vb[VY];\n rv[VZ] = pa * va[VZ] + pb * vb[VZ];\n rv[VW] = pa * va[VW] + pb * vb[VW];\n rv[R] = pa * va[R] + pb * vb[R];\n rv[G] = pa * va[G] + pb * vb[G];\n rv[B] = pa * va[B] + pb * vb[B];\n rv[A] = pa * va[A] + pb * vb[A];\n rv[U] = pa * va[U] + pb * vb[U];\n rv[V] = pa * va[V] + pb * vb[V];\n rv[SR] = pa * va[SR] + pb * vb[SR];\n rv[SG] = pa * va[SG] + pb * vb[SG];\n rv[SB] = pa * va[SB] + pb * vb[SB];\n rv[SA] = pa * va[SA] + pb * vb[SA];\n rv[NX] = pa * va[NX] + pb * vb[NX];\n rv[NY] = pa * va[NY] + pb * vb[NY];\n rv[NZ] = pa * va[NZ] + pb * vb[NZ];\n rv[SW] = pa * va[SW] + pb * vb[SW];\n rv[AR] = pa * va[AR] + pb * vb[AR];\n rv[AG] = pa * va[AG] + pb * vb[AG];\n rv[AB] = pa * va[AB] + pb * vb[AB];\n rv[SPR] = pa * va[SPR] + pb * vb[SPR];\n rv[SPG] = pa * va[SPG] + pb * vb[SPG];\n rv[SPB] = pa * va[SPB] + pb * vb[SPB];\n rv[SPA] = pa * va[SPA] + pb * vb[SPA];\n rv[ER] = pa * va[ER] + pb * vb[ER];\n rv[EG] = pa * va[EG] + pb * vb[EG];\n rv[EB] = pa * va[EB] + pb * vb[EB];\n rv[SHINE] = pa * va[SHINE] + pb * vb[SHINE];\n rv[BEEN_LIT] = 0;\n return irv;\n }\n protected final void add_triangle_no_clip(int a, int b, int c) {\n if (triangleCount == triangles.length) {\n int temp[][] = new int[triangleCount<<1][TRIANGLE_FIELD_COUNT];\n System.arraycopy(triangles, 0, temp, 0, triangleCount);\n triangles = temp;\n float ftemp[][][] = new float[triangleCount<<1][3][TRIANGLE_COLOR_COUNT];\n System.arraycopy(triangleColors, 0, ftemp, 0, triangleCount);\n triangleColors = ftemp;\n }\n triangles[triangleCount][VERTEX1] = a;\n triangles[triangleCount][VERTEX2] = b;\n triangles[triangleCount][VERTEX3] = c;\n if (textureImage == null) {\n triangles[triangleCount][TEXTURE_INDEX] = -1;\n } else {\n triangles[triangleCount][TEXTURE_INDEX] = texture_index;\n }\n triangles[triangleCount][INDEX] = shape_index;\n triangleCount++;\n }\n protected void depth_sort_triangles() {\n depth_sort_triangles_internal(0, triangleCount-1);\n }\n protected void depth_sort_triangles_internal(int i, int j) {\n int pivotIndex = (i+j)/2;\n depth_sort_triangles_swap(pivotIndex, j);\n int k = depth_sort_triangles_partition(i-1, j);\n depth_sort_triangles_swap(k, j);\n if ((k-i) > 1) depth_sort_triangles_internal(i, k-1);\n if ((j-k) > 1) depth_sort_triangles_internal(k+1, j);\n }\n protected int depth_sort_triangles_partition(int left, int right) {\n int pivot = right;\n do {\n while (depth_sort_triangles_compare(++left, pivot) < 0) { }\n while ((right != 0) &&\n (depth_sort_triangles_compare(--right, pivot) > 0)) { }\n depth_sort_triangles_swap(left, right);\n } while (left < right);\n depth_sort_triangles_swap(left, right);\n return left;\n }\n protected void depth_sort_triangles_swap(int a, int b) {\n int tempi[] = triangles[a];\n triangles[a] = triangles[b];\n triangles[b] = tempi;\n float tempf[][] = triangleColors[a];\n triangleColors[a] = triangleColors[b];\n triangleColors[b] = tempf;\n }\n protected float depth_sort_triangles_compare(int a, int b) {\n if (Float.isNaN(vertices[triangles[a][VERTEX1]][Z]) ||\n Float.isNaN(vertices[triangles[a][VERTEX2]][Z]) || \n Float.isNaN(vertices[triangles[a][VERTEX3]][Z]) || \n Float.isNaN(vertices[triangles[b][VERTEX1]][Z]) || \n Float.isNaN(vertices[triangles[b][VERTEX2]][Z]) || \n Float.isNaN(vertices[triangles[b][VERTEX3]][Z])) {\n throw new RuntimeException(\"nan triangle\");\n }\n return\n (vertices[triangles[b][VERTEX1]][Z] +\n vertices[triangles[b][VERTEX2]][Z] +\n vertices[triangles[b][VERTEX3]][Z]) -\n (vertices[triangles[a][VERTEX1]][Z] +\n vertices[triangles[a][VERTEX2]][Z] +\n vertices[triangles[a][VERTEX3]][Z]);\n }\n protected void render_triangles() {\n if (raw != null) {\n raw.colorMode(RGB, 1);\n raw.noStroke();\n raw.beginShape(TRIANGLES);\n }\n for (int i = 0; i < triangleCount; i ++) {\n float a[] = vertices[triangles[i][VERTEX1]];\n float b[] = vertices[triangles[i][VERTEX2]];\n float c[] = vertices[triangles[i][VERTEX3]];\n int tex = triangles[i][TEXTURE_INDEX];\n int index = triangles[i][INDEX];\n triangle.reset();\n float ar = min(1, triangleColors[i][0][TRI_DIFFUSE_R] +\n triangleColors[i][0][TRI_SPECULAR_R]);\n float ag = min(1, triangleColors[i][0][TRI_DIFFUSE_G] +\n triangleColors[i][0][TRI_SPECULAR_G]);\n float ab = min(1, triangleColors[i][0][TRI_DIFFUSE_B] +\n triangleColors[i][0][TRI_SPECULAR_B]);\n float br = min(1, triangleColors[i][1][TRI_DIFFUSE_R] +\n triangleColors[i][1][TRI_SPECULAR_R]);\n float bg = min(1, triangleColors[i][1][TRI_DIFFUSE_G] +\n triangleColors[i][1][TRI_SPECULAR_G]);\n float bb = min(1, triangleColors[i][1][TRI_DIFFUSE_B] +\n triangleColors[i][1][TRI_SPECULAR_B]);\n float cr = min(1, triangleColors[i][2][TRI_DIFFUSE_R] +\n triangleColors[i][2][TRI_SPECULAR_R]);\n float cg = min(1, triangleColors[i][2][TRI_DIFFUSE_G] +\n triangleColors[i][2][TRI_SPECULAR_G]);\n float cb = min(1, triangleColors[i][2][TRI_DIFFUSE_B] +\n triangleColors[i][2][TRI_SPECULAR_B]);\n if (tex > -1 && textures[tex] != null) {\n triangle.setTexture(textures[tex]);\n triangle.setUV(a[U], a[V], b[U], b[V], c[U], c[V]);\n }\n triangle.setIntensities(ar, ag, ab, a[A],\n br, bg, bb, b[A],\n cr, cg, cb, c[A]);\n triangle.setVertices(a[X], a[Y], a[Z],\n b[X], b[Y], b[Z],\n c[X], c[Y], c[Z]);\n triangle.setIndex(index);\n triangle.render();\n if (raw != null) {\n if (raw instanceof PGraphics3D) {\n if ((a[VW] != 0) && (b[VW] != 0) && (c[VW] != 0)) {\n raw.fill(ar, ag, ab, a[A]);\n raw.vertex(a[VX] / a[VW], a[VY] / a[VW], a[VZ] / a[VW]);\n raw.fill(br, bg, bb, b[A]);\n raw.vertex(b[VX] / b[VW], b[VY] / b[VW], b[VZ] / b[VW]);\n raw.fill(cr, cg, cb, c[A]);\n raw.vertex(c[VX] / c[VW], c[VY] / c[VW], c[VZ] / c[VW]);\n }\n } else {\n raw.fill(ar, ag, ab, a[A]);\n raw.vertex(a[X], a[Y]);\n raw.fill(br, bg, bb, b[A]);\n raw.vertex(b[X], b[Y]);\n raw.fill(cr, cg, cb, c[A]);\n raw.vertex(c[X], c[Y]);\n }\n }\n }\n if (raw != null) {\n raw.endShape();\n }\n }\n protected void depth_sort_lines() {\n }\n protected void render_lines() {\n if (raw != null) {\n raw.colorMode(RGB, 1);\n raw.noFill();\n raw.beginShape(LINES);\n }\n for (int i = 0; i < lineCount; i ++) {\n float a[] = vertices[lines[i][VERTEX1]];\n float b[] = vertices[lines[i][VERTEX2]];\n int index = lines[i][INDEX];\n line.reset();\n line.setIntensities(a[SR], a[SG], a[SB], a[SA],\n b[SR], b[SG], b[SB], b[SA]);\n line.setVertices(a[X], a[Y], a[Z],\n b[X], b[Y], b[Z]);\n if (raw != null) {\n if (raw instanceof PGraphics3D) {\n if ((a[VW] != 0) && (b[VW] != 0)) {\n raw.stroke(a[SR], a[SG], a[SB], a[SA]);\n raw.vertex(a[VX] / a[VW], a[VY] / a[VW], a[VZ] / a[VW]);\n raw.stroke(b[SR], b[SG], b[SB], b[SA]);\n raw.vertex(b[VX] / b[VW], b[VY] / b[VW], b[VZ] / b[VW]);\n }\n } else {\n raw.stroke(a[SR], a[SG], a[SB], a[SA]);\n raw.vertex(a[X], a[Y]);\n raw.stroke(b[SR], b[SG], b[SB], b[SA]);\n raw.vertex(b[X], b[Y]);\n }\n }\n line.setIndex(index);\n line.draw();\n }\n if (raw != null) {\n raw.endShape();\n }\n }\n private void triangulate_polygon() {\n int d1 = MX;\n int d2 = MY;\n float area = 0;\n for (int p = vertex_end - 1, q = vertex_start; q < vertex_end; p = q++) {\n area += (vertices[q][d1] * vertices[p][d2] -\n vertices[p][d1] * vertices[q][d2]);\n }\n if (area == 0) {\n boolean foundValidX = false;\n boolean foundValidY = false;\n for (int i = vertex_start; i < vertex_end; i++) {\n if (vertices[i][MX] != 0) foundValidX = true;\n if (vertices[i][MY] != 0) foundValidY = true;\n }\n if (foundValidX && !foundValidY) {\n d2 = MZ;\n } else if (!foundValidX && foundValidY) {\n d1 = MY;\n d2 = MZ;\n } else {\n return;\n }\n for (int p = vertex_end - 1, q = vertex_start; q < vertex_end; p = q++) {\n area += (vertices[q][d1] * vertices[p][d2] -\n vertices[p][d1] * vertices[q][d2]);\n }\n }\n float vfirst[] = vertices[vertex_start];\n float vlast[] = vertices[vertex_end-1];\n if ((abs(vfirst[MX] - vlast[MX]) < EPSILON) &&\n (abs(vfirst[MY] - vlast[MY]) < EPSILON) &&\n (abs(vfirst[MZ] - vlast[MZ]) < EPSILON)) {\n vertex_end--;\n }\n int j = 0;\n if (area > 0) {\n for (int i = vertex_start; i < vertex_end; i++) {\n j = i - vertex_start;\n vertex_order[j] = i;\n }\n } else {\n for (int i = vertex_start; i < vertex_end; i++) {\n j = i - vertex_start;\n vertex_order[j] = (vertex_end - 1) - j;\n }\n }\n int vc = vertex_end - vertex_start;\n int count = 2*vc; \n for (int m = 0, v = vc - 1; vc > 2; ) {\n boolean snip = true;\n if (0 >= (count--)) {\n break; \n }\n int u = v ; if (vc <= u) u = 0; \n v = u + 1; if (vc <= v) v = 0; \n int w = v + 1; if (vc <= w) w = 0; \n float Ax = -vertices[vertex_order[u]][d1];\n float Ay = vertices[vertex_order[u]][d2];\n float Bx = -vertices[vertex_order[v]][d1];\n float By = vertices[vertex_order[v]][d2];\n float Cx = -vertices[vertex_order[w]][d1];\n float Cy = vertices[vertex_order[w]][d2];\n if (EPSILON > (((Bx-Ax) * (Cy-Ay)) - ((By-Ay) * (Cx-Ax)))) {\n continue;\n }\n for (int p = 0; p < vc; p++) {\n if( (p == u) || (p == v) || (p == w) ) {\n continue;\n }\n float Px = -vertices[vertex_order[p]][d1];\n float Py = vertices[vertex_order[p]][d2];\n float ax = Cx - Bx; float ay = Cy - By;\n float bx = Ax - Cx; float by = Ay - Cy;\n float cx = Bx - Ax; float cy = By - Ay;\n float apx = Px - Ax; float apy = Py - Ay;\n float bpx = Px - Bx; float bpy = Py - By;\n float cpx = Px - Cx; float cpy = Py - Cy;\n float aCROSSbp = ax * bpy - ay * bpx;\n float cCROSSap = cx * apy - cy * apx;\n float bCROSScp = bx * cpy - by * cpx;\n if ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)) {\n snip = false;\n }\n }\n if (snip) {\n add_triangle(vertex_order[u], vertex_order[v], vertex_order[w]);\n m++;\n for (int s = v, t = v + 1; t < vc; s++, t++) {\n vertex_order[s] = vertex_order[t];\n }\n vc--;\n count = 2 * vc;\n }\n }\n }\n private void toWorldNormal(float nx, float ny, float nz, float[] out) {\n out[0] =\n modelviewInv.m00*nx + modelviewInv.m10*ny +\n modelviewInv.m20*nz + modelviewInv.m30;\n out[1] =\n modelviewInv.m01*nx + modelviewInv.m11*ny +\n modelviewInv.m21*nz + modelviewInv.m31;\n out[2] =\n modelviewInv.m02*nx + modelviewInv.m12*ny +\n modelviewInv.m22*nz + modelviewInv.m32;\n out[3] =\n modelviewInv.m03*nx + modelviewInv.m13*ny +\n modelviewInv.m23*nz + modelviewInv.m33;\n if (out[3] != 0 && out[3] != ONE) {\n out[0] /= out[3]; out[1] /= out[3]; out[2] /= out[3];\n }\n out[3] = 1;\n float nlen = mag(out[0], out[1], out[2]); \n if (nlen != 0 && nlen != ONE) {\n out[0] /= nlen; out[1] /= nlen; out[2] /= nlen;\n }\n }\n private void calc_lighting_contribution(int vIndex,\n float[] contribution) {\n calc_lighting_contribution(vIndex, contribution, false);\n }\n private void calc_lighting_contribution(int vIndex,\n float[] contribution,\n boolean normalIsWorld) {\n float[] v = vertices[vIndex];\n float sr = v[SPR];\n float sg = v[SPG];\n float sb = v[SPB];\n float wx = v[VX];\n float wy = v[VY];\n float wz = v[VZ];\n float shine = v[SHINE];\n float nx;\n float ny;\n float nz;\n if (!normalIsWorld) {\n toWorldNormal(v[NX], v[NY], v[NZ], worldNormal);\n nx = worldNormal[X];\n ny = worldNormal[Y];\n nz = worldNormal[Z];\n }\n else {\n nx = v[NX];\n ny = v[NY];\n nz = v[NZ];\n }\n float dir = dot(nx, ny, nz, -wx, -wy, -wz);\n if (dir < 0) {\n nx = -nx;\n ny = -ny;\n nz = -nz;\n }\n contribution[LIGHT_AMBIENT_R] = 0;\n contribution[LIGHT_AMBIENT_G] = 0;\n contribution[LIGHT_AMBIENT_B] = 0;\n contribution[LIGHT_DIFFUSE_R] = 0;\n contribution[LIGHT_DIFFUSE_G] = 0;\n contribution[LIGHT_DIFFUSE_B] = 0;\n contribution[LIGHT_SPECULAR_R] = 0;\n contribution[LIGHT_SPECULAR_G] = 0;\n contribution[LIGHT_SPECULAR_B] = 0;\n for (int i = 0; i < lightCount; i++) {\n float denom = lightFalloffConstant[i];\n float spotTerm = 1;\n if (lightType[i] == AMBIENT) {\n if (lightFalloffQuadratic[i] != 0 || lightFalloffLinear[i] != 0) {\n float distSq = mag(lightPosition[i][0] - wx,\n lightPosition[i][1] - wy,\n lightPosition[i][2] - wz);\n denom +=\n lightFalloffQuadratic[i] * distSq +\n lightFalloffLinear[i] * (float) sqrt(distSq);\n }\n if (denom == 0) denom = 1;\n contribution[LIGHT_AMBIENT_R] += lightDiffuse[i][0] / denom;\n contribution[LIGHT_AMBIENT_G] += lightDiffuse[i][1] / denom;\n contribution[LIGHT_AMBIENT_B] += lightDiffuse[i][2] / denom;\n } else {\n float lix, liy, liz;\n float lightDir_dot_li = 0;\n float n_dot_li = 0;\n if (lightType[i] == DIRECTIONAL) {\n lix = -lightNormal[i][0];\n liy = -lightNormal[i][1];\n liz = -lightNormal[i][2];\n denom = 1;\n n_dot_li = (nx * lix + ny * liy + nz * liz);\n if (n_dot_li <= 0) {\n continue;\n }\n } else { \n lix = lightPosition[i][0] - wx;\n liy = lightPosition[i][1] - wy;\n liz = lightPosition[i][2] - wz;\n float distSq = mag(lix, liy, liz);\n if (distSq != 0) {\n lix /= distSq;\n liy /= distSq;\n liz /= distSq;\n }\n n_dot_li = (nx * lix + ny * liy + nz * liz);\n if (n_dot_li <= 0) {\n continue;\n }\n if (lightType[i] == SPOT) { \n lightDir_dot_li =\n -(lightNormal[i][0] * lix +\n lightNormal[i][1] * liy +\n lightNormal[i][2] * liz);\n if (lightDir_dot_li <= lightSpotAngleCos[i]) {\n continue;\n }\n spotTerm = pow(lightDir_dot_li, lightSpotConcentration[i]);\n }\n if (lightFalloffQuadratic[i] != 0 || lightFalloffLinear[i] != 0) {\n denom +=\n lightFalloffQuadratic[i] * distSq +\n lightFalloffLinear[i] * (float) sqrt(distSq);\n }\n }\n if (denom == 0)\n denom = 1;\n float mul = n_dot_li * spotTerm / denom;\n contribution[LIGHT_DIFFUSE_R] += lightDiffuse[i][0] * mul;\n contribution[LIGHT_DIFFUSE_G] += lightDiffuse[i][1] * mul;\n contribution[LIGHT_DIFFUSE_B] += lightDiffuse[i][2] * mul;\n if ((sr > 0 || sg > 0 || sb > 0) &&\n (lightSpecular[i][0] > 0 ||\n lightSpecular[i][1] > 0 ||\n lightSpecular[i][2] > 0)) {\n float vmag = mag(wx, wy, wz);\n if (vmag != 0) {\n wx /= vmag;\n wy /= vmag;\n wz /= vmag;\n }\n float sx = lix - wx;\n float sy = liy - wy;\n float sz = liz - wz;\n vmag = mag(sx, sy, sz);\n if (vmag != 0) {\n sx /= vmag;\n sy /= vmag;\n sz /= vmag;\n }\n float s_dot_n = (sx * nx + sy * ny + sz * nz);\n if (s_dot_n > 0) {\n s_dot_n = pow(s_dot_n, shine);\n mul = s_dot_n * spotTerm / denom;\n contribution[LIGHT_SPECULAR_R] += lightSpecular[i][0] * mul;\n contribution[LIGHT_SPECULAR_G] += lightSpecular[i][1] * mul;\n contribution[LIGHT_SPECULAR_B] += lightSpecular[i][2] * mul;\n }\n }\n }\n }\n return;\n }\n private void apply_lighting_contribution(int vIndex, float[] contribution) {\n float[] v = vertices[vIndex];\n v[R] = min(1, v[ER] + v[AR] * contribution[LIGHT_AMBIENT_R] +\n v[DR] * contribution[LIGHT_DIFFUSE_R]);\n v[G] = min(1, v[EG] + v[AG] * contribution[LIGHT_AMBIENT_G] +\n v[DG] * contribution[LIGHT_DIFFUSE_G]);\n v[B] = min(1, v[EB] + v[AB] * contribution[LIGHT_AMBIENT_R] +\n v[DB] * contribution[LIGHT_DIFFUSE_B]);\n v[A] = min(1, v[DA]);\n v[SPR] = min(1, v[SPR] * contribution[LIGHT_SPECULAR_R]);\n v[SPG] = min(1, v[SPG] * contribution[LIGHT_SPECULAR_G]);\n v[SPB] = min(1, v[SPB] * contribution[LIGHT_SPECULAR_B]);\n v[SPA] = min(1, v[SPA]);\n v[BEEN_LIT] = 1;\n }\n private void light_vertex_always(int vIndex, float[] contribution) {\n calc_lighting_contribution(vIndex, contribution);\n apply_lighting_contribution(vIndex, contribution);\n }\n private void light_vertex_if_not_already_lit(int vIndex,\n float[] contribution) {\n if (vertices[vIndex][BEEN_LIT] == 0) {\n light_vertex_always(vIndex, contribution);\n }\n }\n private void copy_prelit_vertex_color_to_triangle(int triIndex, int vIndex,\n int colorIndex) {\n float[] triColor = triangleColors[triIndex][colorIndex];\n float[] v = vertices[vIndex];\n triColor[TRI_DIFFUSE_R] = v[R];\n triColor[TRI_DIFFUSE_G] = v[G];\n triColor[TRI_DIFFUSE_B] = v[B];\n triColor[TRI_DIFFUSE_A] = v[A];\n triColor[TRI_SPECULAR_R] = v[SPR];\n triColor[TRI_SPECULAR_G] = v[SPG];\n triColor[TRI_SPECULAR_B] = v[SPB];\n triColor[TRI_SPECULAR_A] = v[SPA];\n }\n private void copy_vertex_color_to_triangle(int triIndex,\n int vIndex, int colorIndex,\n float[] lightContribution) {\n float[] triColor = triangleColors[triIndex][colorIndex];\n float[] v = vertices[vIndex];\n triColor[TRI_DIFFUSE_R] =\n min(1, v[ER] + v[AR] * lightContribution[LIGHT_AMBIENT_R] +\n v[DR] * lightContribution[LIGHT_DIFFUSE_R]);\n triColor[TRI_DIFFUSE_G] =\n min(1, v[EG] + v[AG] * lightContribution[LIGHT_AMBIENT_G] +\n v[DG] * lightContribution[LIGHT_DIFFUSE_G]);\n triColor[TRI_DIFFUSE_B] =\n min(1, v[EB] + v[AB] * lightContribution[LIGHT_AMBIENT_B] +\n v[DB] * lightContribution[LIGHT_DIFFUSE_B]);\n triColor[TRI_DIFFUSE_A] = min(1, v[DA]);\n triColor[TRI_SPECULAR_R] =\n min(1, v[SPR] * lightContribution[LIGHT_SPECULAR_R]);\n triColor[TRI_SPECULAR_G] =\n min(1, v[SPG] * lightContribution[LIGHT_SPECULAR_G]);\n triColor[TRI_SPECULAR_B] =\n min(1, v[SPB] * lightContribution[LIGHT_SPECULAR_B]);\n triColor[TRI_SPECULAR_A] = min(1, v[SPA]);\n }\n private void light_triangle(int triIndex, float[] lightContribution) {\n int vIndex = triangles[triIndex][VERTEX1];\n copy_vertex_color_to_triangle(triIndex, vIndex, 0, lightContribution);\n vIndex = triangles[triIndex][VERTEX2];\n copy_vertex_color_to_triangle(triIndex, vIndex, 1, lightContribution);\n vIndex = triangles[triIndex][VERTEX3];\n copy_vertex_color_to_triangle(triIndex, vIndex, 2, lightContribution);\n }\n private void crossProduct(float[] u, float[] v, float[] out) {\n out[0] = u[1]*v[2] - u[2]*v[1];\n out[1] = u[2]*v[0] - u[0]*v[2];\n out[2] = u[0]*v[1] - u[1]*v[0];\n }\n private void light_triangle(int triIndex) {\n int vIndex;\n if (normalMode == MANUAL_VERTEX_NORMAL) {\n vIndex = triangles[triIndex][VERTEX1];\n light_vertex_if_not_already_lit(vIndex, tempLightingContribution);\n copy_prelit_vertex_color_to_triangle(triIndex, vIndex, 0);\n vIndex = triangles[triIndex][VERTEX2];\n light_vertex_if_not_already_lit(vIndex, tempLightingContribution);\n copy_prelit_vertex_color_to_triangle(triIndex, vIndex, 1);\n vIndex = triangles[triIndex][VERTEX3];\n light_vertex_if_not_already_lit(vIndex, tempLightingContribution);\n copy_prelit_vertex_color_to_triangle(triIndex, vIndex, 2);\n }\n else if (!lightingDependsOnVertexPosition) {\n vIndex = triangles[triIndex][VERTEX1];\n int vIndex2 = triangles[triIndex][VERTEX2];\n int vIndex3 = triangles[triIndex][VERTEX3];\n dv1[0] = vertices[vIndex2][VX] - vertices[vIndex][VX];\n dv1[1] = vertices[vIndex2][VY] - vertices[vIndex][VY];\n dv1[2] = vertices[vIndex2][VZ] - vertices[vIndex][VZ];\n dv2[0] = vertices[vIndex3][VX] - vertices[vIndex][VX];\n dv2[1] = vertices[vIndex3][VY] - vertices[vIndex][VY];\n dv2[2] = vertices[vIndex3][VZ] - vertices[vIndex][VZ];\n crossProduct(dv1, dv2, norm);\n float nMag = mag(norm[X], norm[Y], norm[Z]);\n if (nMag != 0 && nMag != ONE) {\n norm[X] /= nMag; norm[Y] /= nMag; norm[Z] /= nMag;\n }\n vertices[vIndex][NX] = norm[X];\n vertices[vIndex][NY] = norm[Y];\n vertices[vIndex][NZ] = norm[Z];\n calc_lighting_contribution(vIndex, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex, 0,\n tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex2, 1,\n tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex3, 2,\n tempLightingContribution);\n }\n else {\n if (normalMode == MANUAL_SHAPE_NORMAL) {\n vIndex = triangles[triIndex][VERTEX1];\n vertices[vIndex][NX] = vertices[vertex_start][NX];\n vertices[vIndex][NY] = vertices[vertex_start][NY];\n vertices[vIndex][NZ] = vertices[vertex_start][NZ];\n calc_lighting_contribution(vIndex, tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex, 0,\n tempLightingContribution);\n vIndex = triangles[triIndex][VERTEX2];\n vertices[vIndex][NX] = vertices[vertex_start][NX];\n vertices[vIndex][NY] = vertices[vertex_start][NY];\n vertices[vIndex][NZ] = vertices[vertex_start][NZ];\n calc_lighting_contribution(vIndex, tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex, 1,\n tempLightingContribution);\n vIndex = triangles[triIndex][VERTEX3];\n vertices[vIndex][NX] = vertices[vertex_start][NX];\n vertices[vIndex][NY] = vertices[vertex_start][NY];\n vertices[vIndex][NZ] = vertices[vertex_start][NZ];\n calc_lighting_contribution(vIndex, tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex, 2,\n tempLightingContribution);\n }\n else {\n vIndex = triangles[triIndex][VERTEX1];\n int vIndex2 = triangles[triIndex][VERTEX2];\n int vIndex3 = triangles[triIndex][VERTEX3];\n dv1[0] = vertices[vIndex2][VX] - vertices[vIndex][VX];\n dv1[1] = vertices[vIndex2][VY] - vertices[vIndex][VY];\n dv1[2] = vertices[vIndex2][VZ] - vertices[vIndex][VZ];\n dv2[0] = vertices[vIndex3][VX] - vertices[vIndex][VX];\n dv2[1] = vertices[vIndex3][VY] - vertices[vIndex][VY];\n dv2[2] = vertices[vIndex3][VZ] - vertices[vIndex][VZ];\n crossProduct(dv1, dv2, norm);\n float nMag = mag(norm[X], norm[Y], norm[Z]);\n if (nMag != 0 && nMag != ONE) {\n norm[X] /= nMag; norm[Y] /= nMag; norm[Z] /= nMag;\n }\n vertices[vIndex][NX] = norm[X];\n vertices[vIndex][NY] = norm[Y];\n vertices[vIndex][NZ] = norm[Z];\n calc_lighting_contribution(vIndex, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex, 0,\n tempLightingContribution);\n vertices[vIndex2][NX] = norm[X];\n vertices[vIndex2][NY] = norm[Y];\n vertices[vIndex2][NZ] = norm[Z];\n calc_lighting_contribution(vIndex2, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex2, 1,\n tempLightingContribution);\n vertices[vIndex3][NX] = norm[X];\n vertices[vIndex3][NY] = norm[Y];\n vertices[vIndex3][NZ] = norm[Z];\n calc_lighting_contribution(vIndex3, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex3, 2,\n tempLightingContribution);\n }\n }\n }\n protected void handle_lighting() {\n if (!lightingDependsOnVertexPosition && normalMode == MANUAL_SHAPE_NORMAL) {\n calc_lighting_contribution(vertex_start, tempLightingContribution);\n for (int tri = 0; tri < triangleCount; tri++) {\n light_triangle(tri, tempLightingContribution);\n }\n }\n else {\n for (int tri = 0; tri < triangleCount; tri++) {\n light_triangle(tri);\n }\n }\n }\n protected void handle_no_lighting() {\n int vIndex;\n for (int tri = 0; tri < triangleCount; tri++) {\n vIndex = triangles[tri][VERTEX1];\n copy_prelit_vertex_color_to_triangle(tri, vIndex, 0);\n vIndex = triangles[tri][VERTEX2];\n copy_prelit_vertex_color_to_triangle(tri, vIndex, 1);\n vIndex = triangles[tri][VERTEX3];\n copy_prelit_vertex_color_to_triangle(tri, vIndex, 2);\n }\n }\n public void point(float x, float y) {\n point(x, y, 0);\n }\n public void point(float x, float y, float z) {\n beginShape(LINES);\n vertex(x, y, z);\n vertex(x + EPSILON, y + EPSILON, z);\n endShape();\n }\n public void triangle(float x1, float y1, float x2, float y2,\n float x3, float y3) {\n beginShape(TRIANGLES);\n normal(0, 0, 1);\n vertex(x1, y1);\n vertex(x2, y2);\n vertex(x3, y3);\n endShape();\n }\n public void quad(float x1, float y1, float x2, float y2,\n float x3, float y3, float x4, float y4) {\n beginShape(QUADS);\n normal(0, 0, 1);\n vertex(x1, y1);\n vertex(x2, y2);\n vertex(x3, y3);\n vertex(x4, y4);\n endShape();\n }\n public void box(float size) {\n box(size, size, size);\n }\n public void box(float w, float h, float d) {\n float x1 = -w/2f; float x2 = w/2f;\n float y1 = -h/2f; float y2 = h/2f;\n float z1 = -d/2f; float z2 = d/2f;\n if (triangle != null) { \n triangle.setCulling(true);\n }\n beginShape(QUADS);\n normal(0, 0, 1);\n vertex(x1, y1, z1);\n vertex(x2, y1, z1);\n vertex(x2, y2, z1);\n vertex(x1, y2, z1);\n normal(1, 0, 0);\n vertex(x2, y1, z1);\n vertex(x2, y1, z2);\n vertex(x2, y2, z2);\n vertex(x2, y2, z1);\n normal(0, 0, -1);\n vertex(x2, y1, z2);\n vertex(x1, y1, z2);\n vertex(x1, y2, z2);\n vertex(x2, y2, z2);\n normal(-1, 0, 0);\n vertex(x1, y1, z2);\n vertex(x1, y1, z1);\n vertex(x1, y2, z1);\n vertex(x1, y2, z2);\n normal(0, 1, 0);\n vertex(x1, y1, z2);\n vertex(x2, y1, z2);\n vertex(x2, y1, z1);\n vertex(x1, y1, z1);\n normal(0, -1, 0);\n vertex(x1, y2, z1);\n vertex(x2, y2, z1);\n vertex(x2, y2, z2);\n vertex(x1, y2, z2);\n endShape();\n if (triangle != null) { \n triangle.setCulling(false);\n }\n }\n public void sphereDetail(int res) {\n if (res < 3) res = 3; \n if (res == sphereDetail) return;\n float delta = (float)SINCOS_LENGTH/res;\n float[] cx = new float[res];\n float[] cz = new float[res];\n for (int i = 0; i < res; i++) {\n cx[i] = cosLUT[(int) (i*delta) % SINCOS_LENGTH];\n cz[i] = sinLUT[(int) (i*delta) % SINCOS_LENGTH];\n }\n int vertCount = res * (res-1) + 2;\n int currVert = 0;\n sphereX = new float[vertCount];\n sphereY = new float[vertCount];\n sphereZ = new float[vertCount];\n float angle_step = (SINCOS_LENGTH*0.5f)/res;\n float angle = angle_step;\n for (int i = 1; i < res; i++) {\n float curradius = sinLUT[(int) angle % SINCOS_LENGTH];\n float currY = -cosLUT[(int) angle % SINCOS_LENGTH];\n for (int j = 0; j < res; j++) {\n sphereX[currVert] = cx[j] * curradius;\n sphereY[currVert] = currY;\n sphereZ[currVert++] = cz[j] * curradius;\n }\n angle += angle_step;\n }\n sphereDetail = res;\n }\n public void sphere(float r) {\n float x = 0; \n float y = 0;\n float z = 0;\n if (sphereDetail == 0) {\n sphereDetail(30);\n }\n int v1,v11,v2;\n pushMatrix();\n if (x!=0f && y!=0f && z!=0f) translate(x,y,z);\n scale(r);\n if (triangle != null) { \n triangle.setCulling(true);\n }\n beginShape(TRIANGLE_STRIP);\n for (int i = 0; i < sphereDetail; i++) {\n normal(0, -1, 0);\n vertex(0, -1, 0);\n normal(sphereX[i], sphereY[i], sphereZ[i]);\n vertex(sphereX[i], sphereY[i], sphereZ[i]);\n }\n vertex(0, -1, 0);\n normal(sphereX[0], sphereY[0], sphereZ[0]);\n vertex(sphereX[0], sphereY[0], sphereZ[0]);\n endShape();\n int voff = 0;\n for(int i = 2; i < sphereDetail; i++) {\n v1=v11=voff;\n voff += sphereDetail;\n v2=voff;\n beginShape(TRIANGLE_STRIP);\n for (int j = 0; j < sphereDetail; j++) {\n normal(sphereX[v1], sphereY[v1], sphereZ[v1]);\n vertex(sphereX[v1], sphereY[v1], sphereZ[v1++]);\n normal(sphereX[v2], sphereY[v2], sphereZ[v2]);\n vertex(sphereX[v2], sphereY[v2], sphereZ[v2++]);\n }\n v1=v11;\n v2=voff;\n normal(sphereX[v1], sphereY[v1], sphereZ[v1]);\n vertex(sphereX[v1], sphereY[v1], sphereZ[v1]);\n normal(sphereX[v2], sphereY[v2], sphereZ[v2]);\n vertex(sphereX[v2], sphereY[v2], sphereZ[v2]);\n endShape();\n }\n beginShape(TRIANGLE_STRIP);\n for (int i = 0; i < sphereDetail; i++) {\n v2 = voff + i;\n normal(sphereX[v2], sphereY[v2], sphereZ[v2]);\n vertex(sphereX[v2], sphereY[v2], sphereZ[v2]);\n normal(0, 1, 0);\n vertex(0, 1, 0);\n }\n normal(sphereX[voff], sphereY[voff], sphereZ[voff]);\n vertex(sphereX[voff], sphereY[voff], sphereZ[voff]);\n normal(0, 1, 0);\n vertex(0, 1, 0);\n endShape();\n popMatrix();\n if (triangle != null) { \n triangle.setCulling(false);\n }\n }\n public void translate(float tx, float ty) {\n translate(tx, ty, 0);\n }\n public void translate(float tx, float ty, float tz) {\n forwardTransform.translate(tx, ty, tz);\n reverseTransform.invTranslate(tx, ty, tz);\n }\n public void rotate(float angle) {\n rotateZ(angle);\n }\n public void rotateX(float angle) {\n forwardTransform.rotateX(angle);\n reverseTransform.invRotateX(angle);\n }\n public void rotateY(float angle) {\n forwardTransform.rotateY(angle);\n reverseTransform.invRotateY(angle);\n }\n public void rotateZ(float angle) {\n forwardTransform.rotateZ(angle);\n reverseTransform.invRotateZ(angle);\n }\n public void rotate(float angle, float v0, float v1, float v2) {\n forwardTransform.rotate(angle, v0, v1, v2);\n reverseTransform.invRotate(angle, v0, v1, v2);\n }\n public void scale(float s) {\n scale(s, s, s);\n }\n public void scale(float sx, float sy) {\n scale(sx, sy, 1);\n }\n public void scale(float x, float y, float z) {\n forwardTransform.scale(x, y, z);\n reverseTransform.invScale(x, y, z);\n }\n public void pushMatrix() {\n if (!modelview.push()) {\n throw new RuntimeException(\"Too many calls to pushMatrix()\");\n }\n modelviewInv.push();\n }\n public void popMatrix() {\n if (!modelview.pop()) {\n throw new RuntimeException(\"Too many calls to popMatrix() \" +\n \"(and not enough to pushMatrix)\");\n }\n modelviewInv.pop();\n }\n public void resetMatrix() {\n forwardTransform.reset();\n reverseTransform.reset();\n }\n public void applyMatrix(float n00, float n01, float n02,\n float n10, float n11, float n12) {\n throw new RuntimeException(\"Use applyMatrix() with a 4x4 matrix \" +\n \"when using OPENGL or P3D\");\n }\n public void applyMatrix(float n00, float n01, float n02, float n03,\n float n10, float n11, float n12, float n13,\n float n20, float n21, float n22, float n23,\n float n30, float n31, float n32, float n33) {\n forwardTransform.apply(n00, n01, n02, n03,\n n10, n11, n12, n13,\n n20, n21, n22, n23,\n n30, n31, n32, n33);\n reverseTransform.invApply(n00, n01, n02, n03,\n n10, n11, n12, n13,\n n20, n21, n22, n23,\n n30, n31, n32, n33);\n }\n public void loadMatrix() {\n m00 = modelview.m00;\n m01 = modelview.m01;\n m02 = modelview.m02;\n m03 = modelview.m03;\n m10 = modelview.m10;\n m11 = modelview.m11;\n m12 = modelview.m12;\n m13 = modelview.m13;\n m20 = modelview.m20;\n m21 = modelview.m21;\n m22 = modelview.m22;\n m23 = modelview.m23;\n m30 = modelview.m30;\n m31 = modelview.m31;\n m32 = modelview.m32;\n m33 = modelview.m33;\n }\n public void printMatrix() {\n modelview.print();\n }\n public void beginCamera() {\n if (manipulatingCamera) {\n throw new RuntimeException(\"beginCamera() cannot be called again \" +\n \"before endCamera()\");\n } else {\n manipulatingCamera = true;\n forwardTransform = cameraInv;\n reverseTransform = camera;\n }\n }\n public void endCamera() {\n if (!manipulatingCamera) {\n throw new RuntimeException(\"Cannot call endCamera() \" +\n \"without first calling beginCamera()\");\n }\n modelview.set(camera);\n modelviewInv.set(cameraInv);\n forwardTransform = modelview;\n reverseTransform = modelviewInv;\n manipulatingCamera = false;\n }\n public void camera() {\n camera(cameraX, cameraY, cameraZ,\n cameraX, cameraY, 0,\n 0, 1, 0);\n }\n public void camera(float eyeX, float eyeY, float eyeZ,\n float centerX, float centerY, float centerZ,\n float upX, float upY, float upZ) {\n float z0 = eyeX - centerX;\n float z1 = eyeY - centerY;\n float z2 = eyeZ - centerZ;\n float mag = sqrt(z0*z0 + z1*z1 + z2*z2);\n if (mag != 0) {\n z0 /= mag;\n z1 /= mag;\n z2 /= mag;\n }\n float y0 = upX;\n float y1 = upY;\n float y2 = upZ;\n float x0 = y1*z2 - y2*z1;\n float x1 = -y0*z2 + y2*z0;\n float x2 = y0*z1 - y1*z0;\n y0 = z1*x2 - z2*x1;\n y1 = -z0*x2 + z2*x0;\n y2 = z0*x1 - z1*x0;\n mag = sqrt(x0*x0 + x1*x1 + x2*x2);\n if (mag != 0) {\n x0 /= mag;\n x1 /= mag;\n x2 /= mag;\n }\n mag = sqrt(y0*y0 + y1*y1 + y2*y2);\n if (mag != 0) {\n y0 /= mag;\n y1 /= mag;\n y2 /= mag;\n }\n camera.set(x0, x1, x2, 0,\n y0, y1, y2, 0,\n z0, z1, z2, 0,\n 0, 0, 0, 1);\n camera.translate(-eyeX, -eyeY, -eyeZ);\n cameraInv.reset();\n cameraInv.invApply(x0, x1, x2, 0,\n y0, y1, y2, 0,\n z0, z1, z2, 0,\n 0, 0, 0, 1);\n cameraInv.invTranslate(-eyeX, -eyeY, -eyeZ);\n modelview.set(camera);\n modelviewInv.set(cameraInv);\n }\n public void printCamera() {\n camera.print();\n }\n public void ortho() {\n ortho(0, width, 0, height, -10, 10);\n }\n public void ortho(float left, float right,\n float bottom, float top,\n float near, float far) {\n float x = 2.0f / (right - left);\n float y = 2.0f / (top - bottom);\n float z = -2.0f / (far - near);\n float tx = -(right + left) / (right - left);\n float ty = -(top + bottom) / (top - bottom);\n float tz = -(far + near) / (far - near);\n projection.set(x, 0, 0, tx,\n 0, y, 0, ty,\n 0, 0, z, tz,\n 0, 0, 0, 1);\n }\n public void perspective() {\n perspective(cameraFOV, cameraAspect, cameraNear, cameraFar);\n }\n public void perspective(float fov, float aspect, float zNear, float zFar) {\n float ymax = zNear * tan(fov / 2.0f);\n float ymin = -ymax;\n float xmin = ymin * aspect;\n float xmax = ymax * aspect;\n frustum(xmin, xmax, ymin, ymax, zNear, zFar);\n }\n public void frustum(float left, float right, float bottom,\n float top, float znear, float zfar) {\n projection.set((2*znear)/(right-left), 0, (right+left)/(right-left), 0,\n 0, (2*znear)/(top-bottom), (top+bottom)/(top-bottom), 0,\n 0, 0, -(zfar+znear)/(zfar-znear),-(2*zfar*znear)/(zfar-znear),\n 0, 0, -1, 0);\n }\n public void printProjection() {\n projection.print();\n }\n public float screenX(float x, float y) {\n return screenX(x, y, 0);\n }\n public float screenY(float x, float y) {\n return screenY(x, y, 0);\n }\n public float screenX(float x, float y, float z) {\n float ax =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n float ay =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n float az =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n float aw =\n modelview.m30*x + modelview.m31*y + modelview.m32*z + modelview.m33;\n float ox =\n projection.m00*ax + projection.m01*ay +\n projection.m02*az + projection.m03*aw;\n float ow =\n projection.m30*ax + projection.m31*ay +\n projection.m32*az + projection.m33*aw;\n if (ow != 0) ox /= ow;\n return width * (1 + ox) / 2.0f;\n }\n public float screenY(float x, float y, float z) {\n float ax =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n float ay =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n float az =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n float aw =\n modelview.m30*x + modelview.m31*y + modelview.m32*z + modelview.m33;\n float oy =\n projection.m10*ax + projection.m11*ay +\n projection.m12*az + projection.m13*aw;\n float ow =\n projection.m30*ax + projection.m31*ay +\n projection.m32*az + projection.m33*aw;\n if (ow != 0) oy /= ow;\n return height * (1 + oy) / 2.0f;\n }\n public float screenZ(float x, float y, float z) {\n float ax =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n float ay =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n float az =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n float aw =\n modelview.m30*x + modelview.m31*y + modelview.m32*z + modelview.m33;\n float oz =\n projection.m20*ax + projection.m21*ay +\n projection.m22*az + projection.m23*aw;\n float ow =\n projection.m30*ax + projection.m31*ay +\n projection.m32*az + projection.m33*aw;\n if (ow != 0) oz /= ow;\n return (oz + 1) / 2.0f;\n }\n public float modelX(float x, float y, float z) {\n float ax =\n cameraInv.m00*x + cameraInv.m01*y + cameraInv.m02*z + cameraInv.m03;\n float ay =\n cameraInv.m10*x + cameraInv.m11*y + cameraInv.m12*z + cameraInv.m13;\n float az =\n cameraInv.m20*x + cameraInv.m21*y + cameraInv.m22*z + cameraInv.m23;\n float aw =\n cameraInv.m30*x + cameraInv.m31*y + cameraInv.m32*z + cameraInv.m33;\n float ox =\n modelview.m00*ax + modelview.m01*ay +\n modelview.m02*az + modelview.m03*aw;\n float ow =\n modelview.m30*ax + modelview.m31*ay +\n modelview.m32*az + modelview.m33*aw;\n return (ow != 0) ? ox / ow : ox;\n }\n public float modelY(float x, float y, float z) {\n float ax =\n cameraInv.m00*x + cameraInv.m01*y + cameraInv.m02*z + cameraInv.m03;\n float ay =\n cameraInv.m10*x + cameraInv.m11*y + cameraInv.m12*z + cameraInv.m13;\n float az =\n cameraInv.m20*x + cameraInv.m21*y + cameraInv.m22*z + cameraInv.m23;\n float aw =\n cameraInv.m30*x + cameraInv.m31*y + cameraInv.m32*z + cameraInv.m33;\n float oy =\n modelview.m10*ax + modelview.m11*ay +\n modelview.m12*az + modelview.m13*aw;\n float ow =\n modelview.m30*ax + modelview.m31*ay +\n modelview.m32*az + modelview.m33*aw;\n return (ow != 0) ? oy / ow : oy;\n }\n public float modelZ(float x, float y, float z) {\n float ax =\n cameraInv.m00*x + cameraInv.m01*y + cameraInv.m02*z + cameraInv.m03;\n float ay =\n cameraInv.m10*x + cameraInv.m11*y + cameraInv.m12*z + cameraInv.m13;\n float az =\n cameraInv.m20*x + cameraInv.m21*y + cameraInv.m22*z + cameraInv.m23;\n float aw =\n cameraInv.m30*x + cameraInv.m31*y + cameraInv.m32*z + cameraInv.m33;\n float oz =\n modelview.m20*ax + modelview.m21*ay +\n modelview.m22*az + modelview.m23*aw;\n float ow =\n modelview.m30*ax + modelview.m31*ay +\n modelview.m32*az + modelview.m33*aw;\n return (ow != 0) ? oz / ow : oz;\n }\n public void strokeJoin(int join) {\n String msg = \"strokeJoin() not available with P3D\";\n throw new RuntimeException(msg);\n }\n public void strokeCap(int cap) {\n String msg = \"strokeCap() not available with P3D\";\n throw new RuntimeException(msg);\n }\n protected void fillFromCalc() {\n super.fillFromCalc();\n ambientFromCalc();\n }\n public void ambient(int rgb) {\n if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { \n ambient((float) rgb);\n } else {\n colorCalcARGB(rgb, colorModeA);\n ambientFromCalc();\n }\n }\n public void ambient(float gray) {\n colorCalc(gray);\n ambientFromCalc();\n }\n public void ambient(float x, float y, float z) {\n colorCalc(x, y, z);\n ambientFromCalc();\n }\n protected void ambientFromCalc() {\n ambientR = calcR;\n ambientG = calcG;\n ambientB = calcB;\n }\n public void specular(int rgb) {\n if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { \n specular((float) rgb);\n } else {\n colorCalcARGB(rgb, colorModeA);\n specularFromCalc();\n }\n }\n public void specular(float gray) {\n colorCalc(gray);\n specularFromCalc();\n }\n public void specular(float gray, float alpha) {\n colorCalc(gray, alpha);\n specularFromCalc();\n }\n public void specular(float x, float y, float z) {\n colorCalc(x, y, z);\n specularFromCalc();\n }\n public void specular(float x, float y, float z, float a) {\n colorCalc(x, y, z, a);\n specularFromCalc();\n }\n protected void specularFromCalc() {\n specularR = calcR;\n specularG = calcG;\n specularB = calcB;\n specularA = calcA;\n }\n public void shininess(float shine) {\n shininess = shine;\n }\n public void emissive(int rgb) {\n if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { \n emissive((float) rgb);\n } else {\n colorCalcARGB(rgb, colorModeA);\n emissiveFromCalc();\n }\n }\n public void emissive(float gray) {\n colorCalc(gray);\n emissiveFromCalc();\n }\n public void emissive(float x, float y, float z) {\n colorCalc(x, y, z);\n emissiveFromCalc();\n }\n protected void emissiveFromCalc() {\n emissiveR = calcR;\n emissiveG = calcG;\n emissiveB = calcB;\n }\n public void lights() {\n int colorModeSaved = colorMode;\n colorMode = RGB;\n lightFalloff(1, 0, 0);\n lightSpecular(0, 0, 0);\n ambientLight(colorModeX * 0.5f,\n colorModeY * 0.5f,\n colorModeZ * 0.5f);\n directionalLight(colorModeX * 0.5f,\n colorModeY * 0.5f,\n colorModeZ * 0.5f,\n 0, 0, -1);\n colorMode = colorModeSaved;\n lightingDependsOnVertexPosition = false;\n }\n public void ambientLight(float r, float g, float b) {\n ambientLight(r, g, b, 0, 0, 0);\n }\n public void ambientLight(float r, float g, float b,\n float x, float y, float z) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = AMBIENT;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightPosition(lightCount, x, y, z);\n lightCount++;\n }\n public void directionalLight(float r, float g, float b,\n float nx, float ny, float nz) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = DIRECTIONAL;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightSpecular[lightCount][0] = currentLightSpecular[0];\n lightSpecular[lightCount][1] = currentLightSpecular[1];\n lightSpecular[lightCount][2] = currentLightSpecular[2];\n lightDirection(lightCount, nx, ny, nz);\n lightCount++;\n }\n public void pointLight(float r, float g, float b,\n float x, float y, float z) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = POINT;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightSpecular[lightCount][0] = currentLightSpecular[0];\n lightSpecular[lightCount][1] = currentLightSpecular[1];\n lightSpecular[lightCount][2] = currentLightSpecular[2];\n lightPosition(lightCount, x, y, z);\n lightCount++;\n lightingDependsOnVertexPosition = true;\n }\n public void spotLight(float r, float g, float b,\n float x, float y, float z,\n float nx, float ny, float nz,\n float angle, float concentration) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = SPOT;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightSpecular[lightCount][0] = currentLightSpecular[0];\n lightSpecular[lightCount][1] = currentLightSpecular[1];\n lightSpecular[lightCount][2] = currentLightSpecular[2];\n lightPosition(lightCount, x, y, z);\n lightDirection(lightCount, nx, ny, nz);\n lightSpotAngle[lightCount] = angle;\n lightSpotAngleCos[lightCount] = max(0, cos(angle));\n lightSpotConcentration[lightCount] = concentration;\n lightCount++;\n lightingDependsOnVertexPosition = true;\n }\n public void lightFalloff(float constant, float linear, float quadratic) {\n currentLightFalloffConstant = constant;\n currentLightFalloffLinear = linear;\n currentLightFalloffQuadratic = quadratic;\n lightingDependsOnVertexPosition = true;\n }\n public void lightSpecular(float x, float y, float z) {\n colorCalc(x, y, z);\n currentLightSpecular[0] = calcR;\n currentLightSpecular[1] = calcG;\n currentLightSpecular[2] = calcB;\n lightingDependsOnVertexPosition = true;\n }\n protected void lightPosition(int num, float x, float y, float z) {\n lightPosition[num][0] =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n lightPosition[num][1] =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n lightPosition[num][2] =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n }\n protected void lightDirection(int num, float x, float y, float z) {\n lightNormal[num][0] =\n modelviewInv.m00*x + modelviewInv.m10*y +\n modelviewInv.m20*z + modelviewInv.m30;\n lightNormal[num][1] =\n modelviewInv.m01*x + modelviewInv.m11*y +\n modelviewInv.m21*z + modelviewInv.m31;\n lightNormal[num][2] =\n modelviewInv.m02*x + modelviewInv.m12*y +\n modelviewInv.m22*z + modelviewInv.m32;\n float n = mag(lightNormal[num]);\n if (n == 0 || n == 1) return;\n lightNormal[num][0] /= n;\n lightNormal[num][1] /= n;\n lightNormal[num][2] /= n;\n }\n public void background(PImage image) {\n super.background(image);\n for (int i = 0; i < pixelCount; i++) {\n zbuffer[i] = Float.MAX_VALUE;\n }\n }\n protected void clear() {\n for (int i = 0; i < pixelCount; i++) {\n pixels[i] = backgroundColor;\n zbuffer[i] = Float.MAX_VALUE;\n }\n }\n public void smooth() {\n String msg = \"smooth() not available with P3D\";\n throw new RuntimeException(msg);\n }\n public void noSmooth() {\n String msg = \"noSmooth() not available with P3D\";\n throw new RuntimeException(msg);\n }\n private final float mag(float a, float b, float c) {\n return (float)Math.sqrt(a*a + b*b + c*c);\n }\n private final float mag(float abc[]) {\n return (float)Math.sqrt(abc[0]*abc[0] + abc[1]*abc[1] + abc[2]*abc[2]);\n }\n private final float min(float a, float b) {\n return (a < b) ? a : b;\n }\n private final float max(float a, float b) {\n return (a > b) ? a : b;\n }\n private final float pow(float a, float b) {\n return (float)Math.pow(a, b);\n }\n private final float abs(float a) {\n return (a < 0) ? -a : a;\n }\n private final float cos(float angle) {\n return (float)Math.cos(angle);\n }\n private final float tan(float angle) {\n return (float)Math.tan(angle);\n }\n private float dot(float ax, float ay, float az,\n float bx, float by, float bz) {\n return ax * bx + ay * by + az * bz;\n }\n}\n", "output": " protected final void add_triangle_with_clip(int a, int b, int c) {\n boolean aClipped = false;\n boolean bClipped = false;\n int clippedCount = 0;\n cameraNear = -8;\n if (vertices[a][VZ] > cameraNear) {\n aClipped = true;\n clippedCount++;\n }\n if (vertices[b][VZ] > cameraNear) {\n bClipped = true;\n clippedCount++;\n }\n if (vertices[c][VZ] > cameraNear) {\n clippedCount++;\n }\n if (clippedCount == 0) {\n add_triangle_no_clip(a, b, c);\n return;\n }\n else if (clippedCount == 3) {\n return;\n }\n else if (clippedCount == 2) {\n int ca, cb, cc, cd, ce;\n if (!aClipped) {\n ca = a;\n cb = b;\n cc = c;\n }\n else if (!bClipped) {\n ca = b;\n cb = a;\n cc = c;\n }\n else { \n ca = c;\n cb = b;\n cc = a;\n }\n cd = interpolate_clip_vertex(ca, cb);\n ce = interpolate_clip_vertex(ca, cc);\n add_triangle_no_clip(ca, cd, ce);\n return;\n }\n else { \n int ca, cb, cc, cd, ce;\n if (aClipped) {\n ca = c;\n cb = b;\n cc = a;\n }\n else if (bClipped) {\n ca = a;\n cb = c;\n cc = b;\n }\n else { \n ca = a;\n cb = b;\n cc = c;\n }\n cd = interpolate_clip_vertex(ca, cc);\n ce = interpolate_clip_vertex(cb, cc);\n add_triangle_no_clip(ca, cd, cb);\n add_triangle_no_clip(cb, cd, ce);\n return;\n }\n }\n private final int interpolate_clip_vertex(int a, int b) {\n float[] va;\n float[] vb;\n if (vertices[a][VZ] < vertices[b][VZ]) {\n va = vertices[b];\n vb = vertices[a];\n }\n else {\n va = vertices[a];\n vb = vertices[b];\n }\n float az = va[VZ];\n float bz = vb[VZ];\n float dz = az - bz;\n if (dz == 0) {\n return a;\n }\n float pa = (cameraNear - bz) / dz;\n float pb = 1 - pa;\n vertex(pa * va[MX] + pb * vb[MX],\n pa * va[MY] + pb * vb[MY],\n pa * va[MZ] + pb * vb[MZ]);\n int irv = vertexCount - 1;\n vertex_end_including_clip_verts++;\n float[] rv = vertices[irv];\n rv[X] = pa * va[X] + pb * vb[X];\n rv[Y] = pa * va[Y] + pb * vb[Y];\n rv[Z] = pa * va[Z] + pb * vb[Z];\n rv[VX] = pa * va[VX] + pb * vb[VX];\n rv[VY] = pa * va[VY] + pb * vb[VY];\n rv[VZ] = pa * va[VZ] + pb * vb[VZ];\n rv[VW] = pa * va[VW] + pb * vb[VW];\n rv[R] = pa * va[R] + pb * vb[R];\n rv[G] = pa * va[G] + pb * vb[G];\n rv[B] = pa * va[B] + pb * vb[B];\n rv[A] = pa * va[A] + pb * vb[A];\n rv[U] = pa * va[U] + pb * vb[U];\n rv[V] = pa * va[V] + pb * vb[V];\n rv[SR] = pa * va[SR] + pb * vb[SR];\n rv[SG] = pa * va[SG] + pb * vb[SG];\n rv[SB] = pa * va[SB] + pb * vb[SB];\n rv[SA] = pa * va[SA] + pb * vb[SA];\n rv[NX] = pa * va[NX] + pb * vb[NX];\n rv[NY] = pa * va[NY] + pb * vb[NY];\n rv[NZ] = pa * va[NZ] + pb * vb[NZ];\n rv[SW] = pa * va[SW] + pb * vb[SW];\n rv[AR] = pa * va[AR] + pb * vb[AR];\n rv[AG] = pa * va[AG] + pb * vb[AG];\n rv[AB] = pa * va[AB] + pb * vb[AB];\n rv[SPR] = pa * va[SPR] + pb * vb[SPR];\n rv[SPG] = pa * va[SPG] + pb * vb[SPG];\n rv[SPB] = pa * va[SPB] + pb * vb[SPB];\n rv[SPA] = pa * va[SPA] + pb * vb[SPA];\n rv[ER] = pa * va[ER] + pb * vb[ER];\n rv[EG] = pa * va[EG] + pb * vb[EG];\n rv[EB] = pa * va[EB] + pb * vb[EB];\n rv[SHINE] = pa * va[SHINE] + pb * vb[SHINE];\n rv[BEEN_LIT] = 0;\n return irv;\n }\n protected final void add_triangle_no_clip(int a, int b, int c) {\n if (triangleCount == triangles.length) {\n int temp[][] = new int[triangleCount<<1][TRIANGLE_FIELD_COUNT];\n System.arraycopy(triangles, 0, temp, 0, triangleCount);\n triangles = temp;\n float ftemp[][][] = new float[triangleCount<<1][3][TRIANGLE_COLOR_COUNT];\n System.arraycopy(triangleColors, 0, ftemp, 0, triangleCount);\n triangleColors = ftemp;\n }\n triangles[triangleCount][VERTEX1] = a;\n triangles[triangleCount][VERTEX2] = b;\n triangles[triangleCount][VERTEX3] = c;\n if (textureImage == null) {\n triangles[triangleCount][TEXTURE_INDEX] = -1;\n } else {\n triangles[triangleCount][TEXTURE_INDEX] = texture_index;\n }\n triangles[triangleCount][INDEX] = shape_index;\n triangleCount++;\n }\n protected void depth_sort_triangles() {\n depth_sort_triangles_internal(0, triangleCount-1);\n }\n protected void depth_sort_triangles_internal(int i, int j) {\n int pivotIndex = (i+j)/2;\n depth_sort_triangles_swap(pivotIndex, j);\n int k = depth_sort_triangles_partition(i-1, j);\n depth_sort_triangles_swap(k, j);\n if ((k-i) > 1) depth_sort_triangles_internal(i, k-1);\n if ((j-k) > 1) depth_sort_triangles_internal(k+1, j);\n }\n protected int depth_sort_triangles_partition(int left, int right) {\n int pivot = right;\n do {\n while (depth_sort_triangles_compare(++left, pivot) < 0) { }\n while ((right != 0) &&\n (depth_sort_triangles_compare(--right, pivot) > 0)) { }\n depth_sort_triangles_swap(left, right);\n } while (left < right);\n depth_sort_triangles_swap(left, right);\n return left;\n }\n protected void depth_sort_triangles_swap(int a, int b) {\n int tempi[] = triangles[a];\n triangles[a] = triangles[b];\n triangles[b] = tempi;\n float tempf[][] = triangleColors[a];\n triangleColors[a] = triangleColors[b];\n triangleColors[b] = tempf;\n }\n protected float depth_sort_triangles_compare(int a, int b) {\n if (Float.isNaN(vertices[triangles[a][VERTEX1]][Z]) ||\n Float.isNaN(vertices[triangles[a][VERTEX2]][Z]) ||\n Float.isNaN(vertices[triangles[a][VERTEX3]][Z]) ||\n Float.isNaN(vertices[triangles[b][VERTEX1]][Z]) ||\n Float.isNaN(vertices[triangles[b][VERTEX2]][Z]) ||\n Float.isNaN(vertices[triangles[b][VERTEX3]][Z])) {\n throw new RuntimeException(\"nan triangle\");\n }\n return\n (vertices[triangles[b][VERTEX1]][Z] +\n vertices[triangles[b][VERTEX2]][Z] +\n vertices[triangles[b][VERTEX3]][Z]) -\n (vertices[triangles[a][VERTEX1]][Z] +\n vertices[triangles[a][VERTEX2]][Z] +\n vertices[triangles[a][VERTEX3]][Z]);\n }\n protected void render_triangles() {\n if (raw != null) {\n raw.colorMode(RGB, 1);\n raw.noStroke();\n raw.beginShape(TRIANGLES);\n }\n for (int i = 0; i < triangleCount; i ++) {\n float a[] = vertices[triangles[i][VERTEX1]];\n float b[] = vertices[triangles[i][VERTEX2]];\n float c[] = vertices[triangles[i][VERTEX3]];\n int tex = triangles[i][TEXTURE_INDEX];\n int index = triangles[i][INDEX];\n triangle.reset();\n float ar = min(1, triangleColors[i][0][TRI_DIFFUSE_R] +\n triangleColors[i][0][TRI_SPECULAR_R]);\n float ag = min(1, triangleColors[i][0][TRI_DIFFUSE_G] +\n triangleColors[i][0][TRI_SPECULAR_G]);\n float ab = min(1, triangleColors[i][0][TRI_DIFFUSE_B] +\n triangleColors[i][0][TRI_SPECULAR_B]);\n float br = min(1, triangleColors[i][1][TRI_DIFFUSE_R] +\n triangleColors[i][1][TRI_SPECULAR_R]);\n float bg = min(1, triangleColors[i][1][TRI_DIFFUSE_G] +\n triangleColors[i][1][TRI_SPECULAR_G]);\n float bb = min(1, triangleColors[i][1][TRI_DIFFUSE_B] +\n triangleColors[i][1][TRI_SPECULAR_B]);\n float cr = min(1, triangleColors[i][2][TRI_DIFFUSE_R] +\n triangleColors[i][2][TRI_SPECULAR_R]);\n float cg = min(1, triangleColors[i][2][TRI_DIFFUSE_G] +\n triangleColors[i][2][TRI_SPECULAR_G]);\n float cb = min(1, triangleColors[i][2][TRI_DIFFUSE_B] +\n triangleColors[i][2][TRI_SPECULAR_B]);\n if (tex > -1 && textures[tex] != null) {\n triangle.setTexture(textures[tex]);\n triangle.setUV(a[U], a[V], b[U], b[V], c[U], c[V]);\n }\n triangle.setIntensities(ar, ag, ab, a[A],\n br, bg, bb, b[A],\n cr, cg, cb, c[A]);\n triangle.setVertices(a[X], a[Y], a[Z],\n b[X], b[Y], b[Z],\n c[X], c[Y], c[Z]);\n triangle.setIndex(index);\n triangle.render();\n if (raw != null) {\n if (raw instanceof PGraphics3D) {\n if ((a[VW] != 0) && (b[VW] != 0) && (c[VW] != 0)) {\n raw.fill(ar, ag, ab, a[A]);\n raw.vertex(a[VX] / a[VW], a[VY] / a[VW], a[VZ] / a[VW]);\n raw.fill(br, bg, bb, b[A]);\n raw.vertex(b[VX] / b[VW], b[VY] / b[VW], b[VZ] / b[VW]);\n raw.fill(cr, cg, cb, c[A]);\n raw.vertex(c[VX] / c[VW], c[VY] / c[VW], c[VZ] / c[VW]);\n }\n } else {\n raw.fill(ar, ag, ab, a[A]);\n raw.vertex(a[X], a[Y]);\n raw.fill(br, bg, bb, b[A]);\n raw.vertex(b[X], b[Y]);\n raw.fill(cr, cg, cb, c[A]);\n raw.vertex(c[X], c[Y]);\n }\n }\n }\n if (raw != null) {\n raw.endShape();\n }\n }\n protected void depth_sort_lines() {\n }\n protected void render_lines() {\n if (raw != null) {\n raw.colorMode(RGB, 1);\n raw.noFill();\n raw.beginShape(LINES);\n }\n for (int i = 0; i < lineCount; i ++) {\n float a[] = vertices[lines[i][VERTEX1]];\n float b[] = vertices[lines[i][VERTEX2]];\n int index = lines[i][INDEX];\n line.reset();\n line.setIntensities(a[SR], a[SG], a[SB], a[SA],\n b[SR], b[SG], b[SB], b[SA]);\n line.setVertices(a[X], a[Y], a[Z],\n b[X], b[Y], b[Z]);\n if (raw != null) {\n if (raw instanceof PGraphics3D) {\n if ((a[VW] != 0) && (b[VW] != 0)) {\n raw.stroke(a[SR], a[SG], a[SB], a[SA]);\n raw.vertex(a[VX] / a[VW], a[VY] / a[VW], a[VZ] / a[VW]);\n raw.stroke(b[SR], b[SG], b[SB], b[SA]);\n raw.vertex(b[VX] / b[VW], b[VY] / b[VW], b[VZ] / b[VW]);\n }\n } else {\n raw.stroke(a[SR], a[SG], a[SB], a[SA]);\n raw.vertex(a[X], a[Y]);\n raw.stroke(b[SR], b[SG], b[SB], b[SA]);\n raw.vertex(b[X], b[Y]);\n }\n }\n line.setIndex(index);\n line.draw();\n }\n if (raw != null) {\n raw.endShape();\n }\n }\n private void triangulate_polygon() {\n int d1 = MX;\n int d2 = MY;\n float area = 0;\n for (int p = vertex_end - 1, q = vertex_start; q < vertex_end; p = q++) {\n area += (vertices[q][d1] * vertices[p][d2] -\n vertices[p][d1] * vertices[q][d2]);\n }\n if (area == 0) {\n boolean foundValidX = false;\n boolean foundValidY = false;\n for (int i = vertex_start; i < vertex_end; i++) {\n if (vertices[i][MX] != 0) foundValidX = true;\n if (vertices[i][MY] != 0) foundValidY = true;\n }\n if (foundValidX && !foundValidY) {\n d2 = MZ;\n } else if (!foundValidX && foundValidY) {\n d1 = MY;\n d2 = MZ;\n } else {\n return;\n }\n for (int p = vertex_end - 1, q = vertex_start; q < vertex_end; p = q++) {\n area += (vertices[q][d1] * vertices[p][d2] -\n vertices[p][d1] * vertices[q][d2]);\n }\n }\n float vfirst[] = vertices[vertex_start];\n float vlast[] = vertices[vertex_end-1];\n if ((abs(vfirst[MX] - vlast[MX]) < EPSILON) &&\n (abs(vfirst[MY] - vlast[MY]) < EPSILON) &&\n (abs(vfirst[MZ] - vlast[MZ]) < EPSILON)) {\n vertex_end--;\n }\n int j = 0;\n if (area > 0) {\n for (int i = vertex_start; i < vertex_end; i++) {\n j = i - vertex_start;\n vertex_order[j] = i;\n }\n } else {\n for (int i = vertex_start; i < vertex_end; i++) {\n j = i - vertex_start;\n vertex_order[j] = (vertex_end - 1) - j;\n }\n }\n int vc = vertex_end - vertex_start;\n int count = 2*vc; \n for (int m = 0, v = vc - 1; vc > 2; ) {\n boolean snip = true;\n if (0 >= (count--)) {\n break; \n }\n int u = v ; if (vc <= u) u = 0; \n v = u + 1; if (vc <= v) v = 0; \n int w = v + 1; if (vc <= w) w = 0; \n float Ax = -vertices[vertex_order[u]][d1];\n float Ay = vertices[vertex_order[u]][d2];\n float Bx = -vertices[vertex_order[v]][d1];\n float By = vertices[vertex_order[v]][d2];\n float Cx = -vertices[vertex_order[w]][d1];\n float Cy = vertices[vertex_order[w]][d2];\n if (EPSILON > (((Bx-Ax) * (Cy-Ay)) - ((By-Ay) * (Cx-Ax)))) {\n continue;\n }\n for (int p = 0; p < vc; p++) {\n if( (p == u) || (p == v) || (p == w) ) {\n continue;\n }\n float Px = -vertices[vertex_order[p]][d1];\n float Py = vertices[vertex_order[p]][d2];\n float ax = Cx - Bx; float ay = Cy - By;\n float bx = Ax - Cx; float by = Ay - Cy;\n float cx = Bx - Ax; float cy = By - Ay;\n float apx = Px - Ax; float apy = Py - Ay;\n float bpx = Px - Bx; float bpy = Py - By;\n float cpx = Px - Cx; float cpy = Py - Cy;\n float aCROSSbp = ax * bpy - ay * bpx;\n float cCROSSap = cx * apy - cy * apx;\n float bCROSScp = bx * cpy - by * cpx;\n if ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)) {\n snip = false;\n }\n }\n if (snip) {\n add_triangle(vertex_order[u], vertex_order[v], vertex_order[w]);\n m++;\n for (int s = v, t = v + 1; t < vc; s++, t++) {\n vertex_order[s] = vertex_order[t];\n }\n vc--;\n count = 2 * vc;\n }\n }\n }\n private void toWorldNormal(float nx, float ny, float nz, float[] out) {\n out[0] =\n modelviewInv.m00*nx + modelviewInv.m10*ny +\n modelviewInv.m20*nz + modelviewInv.m30;\n out[1] =\n modelviewInv.m01*nx + modelviewInv.m11*ny +\n modelviewInv.m21*nz + modelviewInv.m31;\n out[2] =\n modelviewInv.m02*nx + modelviewInv.m12*ny +\n modelviewInv.m22*nz + modelviewInv.m32;\n out[3] =\n modelviewInv.m03*nx + modelviewInv.m13*ny +\n modelviewInv.m23*nz + modelviewInv.m33;\n if (out[3] != 0 && out[3] != ONE) {\n out[0] /= out[3]; out[1] /= out[3]; out[2] /= out[3];\n }\n out[3] = 1;\n float nlen = mag(out[0], out[1], out[2]); \n if (nlen != 0 && nlen != ONE) {\n out[0] /= nlen; out[1] /= nlen; out[2] /= nlen;\n }\n }\n private void calc_lighting_contribution(int vIndex,\n float[] contribution) {\n calc_lighting_contribution(vIndex, contribution, false);\n }\n private void calc_lighting_contribution(int vIndex,\n float[] contribution,\n boolean normalIsWorld) {\n float[] v = vertices[vIndex];\n float sr = v[SPR];\n float sg = v[SPG];\n float sb = v[SPB];\n float wx = v[VX];\n float wy = v[VY];\n float wz = v[VZ];\n float shine = v[SHINE];\n float nx;\n float ny;\n float nz;\n if (!normalIsWorld) {\n toWorldNormal(v[NX], v[NY], v[NZ], worldNormal);\n nx = worldNormal[X];\n ny = worldNormal[Y];\n nz = worldNormal[Z];\n }\n else {\n nx = v[NX];\n ny = v[NY];\n nz = v[NZ];\n }\n float dir = dot(nx, ny, nz, -wx, -wy, -wz);\n if (dir < 0) {\n nx = -nx;\n ny = -ny;\n nz = -nz;\n }\n contribution[LIGHT_AMBIENT_R] = 0;\n contribution[LIGHT_AMBIENT_G] = 0;\n contribution[LIGHT_AMBIENT_B] = 0;\n contribution[LIGHT_DIFFUSE_R] = 0;\n contribution[LIGHT_DIFFUSE_G] = 0;\n contribution[LIGHT_DIFFUSE_B] = 0;\n contribution[LIGHT_SPECULAR_R] = 0;\n contribution[LIGHT_SPECULAR_G] = 0;\n contribution[LIGHT_SPECULAR_B] = 0;\n for (int i = 0; i < lightCount; i++) {\n float denom = lightFalloffConstant[i];\n float spotTerm = 1;\n if (lightType[i] == AMBIENT) {\n if (lightFalloffQuadratic[i] != 0 || lightFalloffLinear[i] != 0) {\n float distSq = mag(lightPosition[i][0] - wx,\n lightPosition[i][1] - wy,\n lightPosition[i][2] - wz);\n denom +=\n lightFalloffQuadratic[i] * distSq +\n lightFalloffLinear[i] * (float) sqrt(distSq);\n }\n if (denom == 0) denom = 1;\n contribution[LIGHT_AMBIENT_R] += lightDiffuse[i][0] / denom;\n contribution[LIGHT_AMBIENT_G] += lightDiffuse[i][1] / denom;\n contribution[LIGHT_AMBIENT_B] += lightDiffuse[i][2] / denom;\n } else {\n float lix, liy, liz;\n float lightDir_dot_li = 0;\n float n_dot_li = 0;\n if (lightType[i] == DIRECTIONAL) {\n lix = -lightNormal[i][0];\n liy = -lightNormal[i][1];\n liz = -lightNormal[i][2];\n denom = 1;\n n_dot_li = (nx * lix + ny * liy + nz * liz);\n if (n_dot_li <= 0) {\n continue;\n }\n } else { \n lix = lightPosition[i][0] - wx;\n liy = lightPosition[i][1] - wy;\n liz = lightPosition[i][2] - wz;\n float distSq = mag(lix, liy, liz);\n if (distSq != 0) {\n lix /= distSq;\n liy /= distSq;\n liz /= distSq;\n }\n n_dot_li = (nx * lix + ny * liy + nz * liz);\n if (n_dot_li <= 0) {\n continue;\n }\n if (lightType[i] == SPOT) { \n lightDir_dot_li =\n -(lightNormal[i][0] * lix +\n lightNormal[i][1] * liy +\n lightNormal[i][2] * liz);\n if (lightDir_dot_li <= lightSpotAngleCos[i]) {\n continue;\n }\n spotTerm = pow(lightDir_dot_li, lightSpotConcentration[i]);\n }\n if (lightFalloffQuadratic[i] != 0 || lightFalloffLinear[i] != 0) {\n denom +=\n lightFalloffQuadratic[i] * distSq +\n lightFalloffLinear[i] * (float) sqrt(distSq);\n }\n }\n if (denom == 0)\n denom = 1;\n float mul = n_dot_li * spotTerm / denom;\n contribution[LIGHT_DIFFUSE_R] += lightDiffuse[i][0] * mul;\n contribution[LIGHT_DIFFUSE_G] += lightDiffuse[i][1] * mul;\n contribution[LIGHT_DIFFUSE_B] += lightDiffuse[i][2] * mul;\n if ((sr > 0 || sg > 0 || sb > 0) &&\n (lightSpecular[i][0] > 0 ||\n lightSpecular[i][1] > 0 ||\n lightSpecular[i][2] > 0)) {\n float vmag = mag(wx, wy, wz);\n if (vmag != 0) {\n wx /= vmag;\n wy /= vmag;\n wz /= vmag;\n }\n float sx = lix - wx;\n float sy = liy - wy;\n float sz = liz - wz;\n vmag = mag(sx, sy, sz);\n if (vmag != 0) {\n sx /= vmag;\n sy /= vmag;\n sz /= vmag;\n }\n float s_dot_n = (sx * nx + sy * ny + sz * nz);\n if (s_dot_n > 0) {\n s_dot_n = pow(s_dot_n, shine);\n mul = s_dot_n * spotTerm / denom;\n contribution[LIGHT_SPECULAR_R] += lightSpecular[i][0] * mul;\n contribution[LIGHT_SPECULAR_G] += lightSpecular[i][1] * mul;\n contribution[LIGHT_SPECULAR_B] += lightSpecular[i][2] * mul;\n }\n }\n }\n }\n return;\n }\n private void apply_lighting_contribution(int vIndex, float[] contribution) {\n float[] v = vertices[vIndex];\n v[R] = min(1, v[ER] + v[AR] * contribution[LIGHT_AMBIENT_R] +\n v[DR] * contribution[LIGHT_DIFFUSE_R]);\n v[G] = min(1, v[EG] + v[AG] * contribution[LIGHT_AMBIENT_G] +\n v[DG] * contribution[LIGHT_DIFFUSE_G]);\n v[B] = min(1, v[EB] + v[AB] * contribution[LIGHT_AMBIENT_B] +\n v[DB] * contribution[LIGHT_DIFFUSE_B]);\n v[A] = min(1, v[DA]);\n v[SPR] = min(1, v[SPR] * contribution[LIGHT_SPECULAR_R]);\n v[SPG] = min(1, v[SPG] * contribution[LIGHT_SPECULAR_G]);\n v[SPB] = min(1, v[SPB] * contribution[LIGHT_SPECULAR_B]);\n v[SPA] = min(1, v[SPA]);\n v[BEEN_LIT] = 1;\n }\n private void light_vertex_always(int vIndex, float[] contribution) {\n calc_lighting_contribution(vIndex, contribution);\n apply_lighting_contribution(vIndex, contribution);\n }\n private void light_vertex_if_not_already_lit(int vIndex,\n float[] contribution) {\n if (vertices[vIndex][BEEN_LIT] == 0) {\n light_vertex_always(vIndex, contribution);\n }\n }\n private void copy_prelit_vertex_color_to_triangle(int triIndex, int vIndex,\n int colorIndex) {\n float[] triColor = triangleColors[triIndex][colorIndex];\n float[] v = vertices[vIndex];\n triColor[TRI_DIFFUSE_R] = v[R];\n triColor[TRI_DIFFUSE_G] = v[G];\n triColor[TRI_DIFFUSE_B] = v[B];\n triColor[TRI_DIFFUSE_A] = v[A];\n triColor[TRI_SPECULAR_R] = v[SPR];\n triColor[TRI_SPECULAR_G] = v[SPG];\n triColor[TRI_SPECULAR_B] = v[SPB];\n triColor[TRI_SPECULAR_A] = v[SPA];\n }\n private void copy_vertex_color_to_triangle(int triIndex,\n int vIndex, int colorIndex,\n float[] lightContribution) {\n float[] triColor = triangleColors[triIndex][colorIndex];\n float[] v = vertices[vIndex];\n triColor[TRI_DIFFUSE_R] =\n min(1, v[ER] + v[AR] * lightContribution[LIGHT_AMBIENT_R] +\n v[DR] * lightContribution[LIGHT_DIFFUSE_R]);\n triColor[TRI_DIFFUSE_G] =\n min(1, v[EG] + v[AG] * lightContribution[LIGHT_AMBIENT_G] +\n v[DG] * lightContribution[LIGHT_DIFFUSE_G]);\n triColor[TRI_DIFFUSE_B] =\n min(1, v[EB] + v[AB] * lightContribution[LIGHT_AMBIENT_B] +\n v[DB] * lightContribution[LIGHT_DIFFUSE_B]);\n triColor[TRI_DIFFUSE_A] = min(1, v[DA]);\n triColor[TRI_SPECULAR_R] =\n min(1, v[SPR] * lightContribution[LIGHT_SPECULAR_R]);\n triColor[TRI_SPECULAR_G] =\n min(1, v[SPG] * lightContribution[LIGHT_SPECULAR_G]);\n triColor[TRI_SPECULAR_B] =\n min(1, v[SPB] * lightContribution[LIGHT_SPECULAR_B]);\n triColor[TRI_SPECULAR_A] = min(1, v[SPA]);\n }\n private void light_triangle(int triIndex, float[] lightContribution) {\n int vIndex = triangles[triIndex][VERTEX1];\n copy_vertex_color_to_triangle(triIndex, vIndex, 0, lightContribution);\n vIndex = triangles[triIndex][VERTEX2];\n copy_vertex_color_to_triangle(triIndex, vIndex, 1, lightContribution);\n vIndex = triangles[triIndex][VERTEX3];\n copy_vertex_color_to_triangle(triIndex, vIndex, 2, lightContribution);\n }\n private void crossProduct(float[] u, float[] v, float[] out) {\n out[0] = u[1]*v[2] - u[2]*v[1];\n out[1] = u[2]*v[0] - u[0]*v[2];\n out[2] = u[0]*v[1] - u[1]*v[0];\n }\n private void light_triangle(int triIndex) {\n int vIndex;\n if (normalMode == MANUAL_VERTEX_NORMAL) {\n vIndex = triangles[triIndex][VERTEX1];\n light_vertex_if_not_already_lit(vIndex, tempLightingContribution);\n copy_prelit_vertex_color_to_triangle(triIndex, vIndex, 0);\n vIndex = triangles[triIndex][VERTEX2];\n light_vertex_if_not_already_lit(vIndex, tempLightingContribution);\n copy_prelit_vertex_color_to_triangle(triIndex, vIndex, 1);\n vIndex = triangles[triIndex][VERTEX3];\n light_vertex_if_not_already_lit(vIndex, tempLightingContribution);\n copy_prelit_vertex_color_to_triangle(triIndex, vIndex, 2);\n }\n else if (!lightingDependsOnVertexPosition) {\n vIndex = triangles[triIndex][VERTEX1];\n int vIndex2 = triangles[triIndex][VERTEX2];\n int vIndex3 = triangles[triIndex][VERTEX3];\n dv1[0] = vertices[vIndex2][VX] - vertices[vIndex][VX];\n dv1[1] = vertices[vIndex2][VY] - vertices[vIndex][VY];\n dv1[2] = vertices[vIndex2][VZ] - vertices[vIndex][VZ];\n dv2[0] = vertices[vIndex3][VX] - vertices[vIndex][VX];\n dv2[1] = vertices[vIndex3][VY] - vertices[vIndex][VY];\n dv2[2] = vertices[vIndex3][VZ] - vertices[vIndex][VZ];\n crossProduct(dv1, dv2, norm);\n float nMag = mag(norm[X], norm[Y], norm[Z]);\n if (nMag != 0 && nMag != ONE) {\n norm[X] /= nMag; norm[Y] /= nMag; norm[Z] /= nMag;\n }\n vertices[vIndex][NX] = norm[X];\n vertices[vIndex][NY] = norm[Y];\n vertices[vIndex][NZ] = norm[Z];\n calc_lighting_contribution(vIndex, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex, 0,\n tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex2, 1,\n tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex3, 2,\n tempLightingContribution);\n }\n else {\n if (normalMode == MANUAL_SHAPE_NORMAL) {\n vIndex = triangles[triIndex][VERTEX1];\n vertices[vIndex][NX] = vertices[vertex_start][NX];\n vertices[vIndex][NY] = vertices[vertex_start][NY];\n vertices[vIndex][NZ] = vertices[vertex_start][NZ];\n calc_lighting_contribution(vIndex, tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex, 0,\n tempLightingContribution);\n vIndex = triangles[triIndex][VERTEX2];\n vertices[vIndex][NX] = vertices[vertex_start][NX];\n vertices[vIndex][NY] = vertices[vertex_start][NY];\n vertices[vIndex][NZ] = vertices[vertex_start][NZ];\n calc_lighting_contribution(vIndex, tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex, 1,\n tempLightingContribution);\n vIndex = triangles[triIndex][VERTEX3];\n vertices[vIndex][NX] = vertices[vertex_start][NX];\n vertices[vIndex][NY] = vertices[vertex_start][NY];\n vertices[vIndex][NZ] = vertices[vertex_start][NZ];\n calc_lighting_contribution(vIndex, tempLightingContribution);\n copy_vertex_color_to_triangle(triIndex, vIndex, 2,\n tempLightingContribution);\n }\n else {\n vIndex = triangles[triIndex][VERTEX1];\n int vIndex2 = triangles[triIndex][VERTEX2];\n int vIndex3 = triangles[triIndex][VERTEX3];\n dv1[0] = vertices[vIndex2][VX] - vertices[vIndex][VX];\n dv1[1] = vertices[vIndex2][VY] - vertices[vIndex][VY];\n dv1[2] = vertices[vIndex2][VZ] - vertices[vIndex][VZ];\n dv2[0] = vertices[vIndex3][VX] - vertices[vIndex][VX];\n dv2[1] = vertices[vIndex3][VY] - vertices[vIndex][VY];\n dv2[2] = vertices[vIndex3][VZ] - vertices[vIndex][VZ];\n crossProduct(dv1, dv2, norm);\n float nMag = mag(norm[X], norm[Y], norm[Z]);\n if (nMag != 0 && nMag != ONE) {\n norm[X] /= nMag; norm[Y] /= nMag; norm[Z] /= nMag;\n }\n vertices[vIndex][NX] = norm[X];\n vertices[vIndex][NY] = norm[Y];\n vertices[vIndex][NZ] = norm[Z];\n calc_lighting_contribution(vIndex, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex, 0,\n tempLightingContribution);\n vertices[vIndex2][NX] = norm[X];\n vertices[vIndex2][NY] = norm[Y];\n vertices[vIndex2][NZ] = norm[Z];\n calc_lighting_contribution(vIndex2, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex2, 1,\n tempLightingContribution);\n vertices[vIndex3][NX] = norm[X];\n vertices[vIndex3][NY] = norm[Y];\n vertices[vIndex3][NZ] = norm[Z];\n calc_lighting_contribution(vIndex3, tempLightingContribution, true);\n copy_vertex_color_to_triangle(triIndex, vIndex3, 2,\n tempLightingContribution);\n }\n }\n }\n protected void handle_lighting() {\n if (!lightingDependsOnVertexPosition && normalMode == MANUAL_SHAPE_NORMAL) {\n calc_lighting_contribution(vertex_start, tempLightingContribution);\n for (int tri = 0; tri < triangleCount; tri++) {\n light_triangle(tri, tempLightingContribution);\n }\n }\n else {\n for (int tri = 0; tri < triangleCount; tri++) {\n light_triangle(tri);\n }\n }\n }\n protected void handle_no_lighting() {\n int vIndex;\n for (int tri = 0; tri < triangleCount; tri++) {\n vIndex = triangles[tri][VERTEX1];\n copy_prelit_vertex_color_to_triangle(tri, vIndex, 0);\n vIndex = triangles[tri][VERTEX2];\n copy_prelit_vertex_color_to_triangle(tri, vIndex, 1);\n vIndex = triangles[tri][VERTEX3];\n copy_prelit_vertex_color_to_triangle(tri, vIndex, 2);\n }\n }\n public void point(float x, float y) {\n point(x, y, 0);\n }\n public void point(float x, float y, float z) {\n beginShape(LINES);\n vertex(x, y, z);\n vertex(x + EPSILON, y + EPSILON, z);\n endShape();\n }\n public void triangle(float x1, float y1, float x2, float y2,\n float x3, float y3) {\n beginShape(TRIANGLES);\n normal(0, 0, 1);\n vertex(x1, y1);\n vertex(x2, y2);\n vertex(x3, y3);\n endShape();\n }\n public void quad(float x1, float y1, float x2, float y2,\n float x3, float y3, float x4, float y4) {\n beginShape(QUADS);\n normal(0, 0, 1);\n vertex(x1, y1);\n vertex(x2, y2);\n vertex(x3, y3);\n vertex(x4, y4);\n endShape();\n }\n public void box(float size) {\n box(size, size, size);\n }\n public void box(float w, float h, float d) {\n float x1 = -w/2f; float x2 = w/2f;\n float y1 = -h/2f; float y2 = h/2f;\n float z1 = -d/2f; float z2 = d/2f;\n if (triangle != null) { \n triangle.setCulling(true);\n }\n beginShape(QUADS);\n normal(0, 0, 1);\n vertex(x1, y1, z1);\n vertex(x2, y1, z1);\n vertex(x2, y2, z1);\n vertex(x1, y2, z1);\n normal(1, 0, 0);\n vertex(x2, y1, z1);\n vertex(x2, y1, z2);\n vertex(x2, y2, z2);\n vertex(x2, y2, z1);\n normal(0, 0, -1);\n vertex(x2, y1, z2);\n vertex(x1, y1, z2);\n vertex(x1, y2, z2);\n vertex(x2, y2, z2);\n normal(-1, 0, 0);\n vertex(x1, y1, z2);\n vertex(x1, y1, z1);\n vertex(x1, y2, z1);\n vertex(x1, y2, z2);\n normal(0, 1, 0);\n vertex(x1, y1, z2);\n vertex(x2, y1, z2);\n vertex(x2, y1, z1);\n vertex(x1, y1, z1);\n normal(0, -1, 0);\n vertex(x1, y2, z1);\n vertex(x2, y2, z1);\n vertex(x2, y2, z2);\n vertex(x1, y2, z2);\n endShape();\n if (triangle != null) { \n triangle.setCulling(false);\n }\n }\n public void sphereDetail(int res) {\n if (res < 3) res = 3; \n if (res == sphereDetail) return;\n float delta = (float)SINCOS_LENGTH/res;\n float[] cx = new float[res];\n float[] cz = new float[res];\n for (int i = 0; i < res; i++) {\n cx[i] = cosLUT[(int) (i*delta) % SINCOS_LENGTH];\n cz[i] = sinLUT[(int) (i*delta) % SINCOS_LENGTH];\n }\n int vertCount = res * (res-1) + 2;\n int currVert = 0;\n sphereX = new float[vertCount];\n sphereY = new float[vertCount];\n sphereZ = new float[vertCount];\n float angle_step = (SINCOS_LENGTH*0.5f)/res;\n float angle = angle_step;\n for (int i = 1; i < res; i++) {\n float curradius = sinLUT[(int) angle % SINCOS_LENGTH];\n float currY = -cosLUT[(int) angle % SINCOS_LENGTH];\n for (int j = 0; j < res; j++) {\n sphereX[currVert] = cx[j] * curradius;\n sphereY[currVert] = currY;\n sphereZ[currVert++] = cz[j] * curradius;\n }\n angle += angle_step;\n }\n sphereDetail = res;\n }\n public void sphere(float r) {\n float x = 0; \n float y = 0;\n float z = 0;\n if (sphereDetail == 0) {\n sphereDetail(30);\n }\n int v1,v11,v2;\n pushMatrix();\n if (x!=0f && y!=0f && z!=0f) translate(x,y,z);\n scale(r);\n if (triangle != null) { \n triangle.setCulling(true);\n }\n beginShape(TRIANGLE_STRIP);\n for (int i = 0; i < sphereDetail; i++) {\n normal(0, -1, 0);\n vertex(0, -1, 0);\n normal(sphereX[i], sphereY[i], sphereZ[i]);\n vertex(sphereX[i], sphereY[i], sphereZ[i]);\n }\n vertex(0, -1, 0);\n normal(sphereX[0], sphereY[0], sphereZ[0]);\n vertex(sphereX[0], sphereY[0], sphereZ[0]);\n endShape();\n int voff = 0;\n for(int i = 2; i < sphereDetail; i++) {\n v1=v11=voff;\n voff += sphereDetail;\n v2=voff;\n beginShape(TRIANGLE_STRIP);\n for (int j = 0; j < sphereDetail; j++) {\n normal(sphereX[v1], sphereY[v1], sphereZ[v1]);\n vertex(sphereX[v1], sphereY[v1], sphereZ[v1++]);\n normal(sphereX[v2], sphereY[v2], sphereZ[v2]);\n vertex(sphereX[v2], sphereY[v2], sphereZ[v2++]);\n }\n v1=v11;\n v2=voff;\n normal(sphereX[v1], sphereY[v1], sphereZ[v1]);\n vertex(sphereX[v1], sphereY[v1], sphereZ[v1]);\n normal(sphereX[v2], sphereY[v2], sphereZ[v2]);\n vertex(sphereX[v2], sphereY[v2], sphereZ[v2]);\n endShape();\n }\n beginShape(TRIANGLE_STRIP);\n for (int i = 0; i < sphereDetail; i++) {\n v2 = voff + i;\n normal(sphereX[v2], sphereY[v2], sphereZ[v2]);\n vertex(sphereX[v2], sphereY[v2], sphereZ[v2]);\n normal(0, 1, 0);\n vertex(0, 1, 0);\n }\n normal(sphereX[voff], sphereY[voff], sphereZ[voff]);\n vertex(sphereX[voff], sphereY[voff], sphereZ[voff]);\n normal(0, 1, 0);\n vertex(0, 1, 0);\n endShape();\n popMatrix();\n if (triangle != null) { \n triangle.setCulling(false);\n }\n }\n public void translate(float tx, float ty) {\n translate(tx, ty, 0);\n }\n public void translate(float tx, float ty, float tz) {\n forwardTransform.translate(tx, ty, tz);\n reverseTransform.invTranslate(tx, ty, tz);\n }\n public void rotate(float angle) {\n rotateZ(angle);\n }\n public void rotateX(float angle) {\n forwardTransform.rotateX(angle);\n reverseTransform.invRotateX(angle);\n }\n public void rotateY(float angle) {\n forwardTransform.rotateY(angle);\n reverseTransform.invRotateY(angle);\n }\n public void rotateZ(float angle) {\n forwardTransform.rotateZ(angle);\n reverseTransform.invRotateZ(angle);\n }\n public void rotate(float angle, float v0, float v1, float v2) {\n forwardTransform.rotate(angle, v0, v1, v2);\n reverseTransform.invRotate(angle, v0, v1, v2);\n }\n public void scale(float s) {\n scale(s, s, s);\n }\n public void scale(float sx, float sy) {\n scale(sx, sy, 1);\n }\n public void scale(float x, float y, float z) {\n forwardTransform.scale(x, y, z);\n reverseTransform.invScale(x, y, z);\n }\n public void pushMatrix() {\n if (!modelview.push()) {\n throw new RuntimeException(\"Too many calls to pushMatrix()\");\n }\n modelviewInv.push();\n }\n public void popMatrix() {\n if (!modelview.pop()) {\n throw new RuntimeException(\"Too many calls to popMatrix() \" +\n \"(and not enough to pushMatrix)\");\n }\n modelviewInv.pop();\n }\n public void resetMatrix() {\n forwardTransform.reset();\n reverseTransform.reset();\n }\n public void applyMatrix(float n00, float n01, float n02,\n float n10, float n11, float n12) {\n throw new RuntimeException(\"Use applyMatrix() with a 4x4 matrix \" +\n \"when using OPENGL or P3D\");\n }\n public void applyMatrix(float n00, float n01, float n02, float n03,\n float n10, float n11, float n12, float n13,\n float n20, float n21, float n22, float n23,\n float n30, float n31, float n32, float n33) {\n forwardTransform.apply(n00, n01, n02, n03,\n n10, n11, n12, n13,\n n20, n21, n22, n23,\n n30, n31, n32, n33);\n reverseTransform.invApply(n00, n01, n02, n03,\n n10, n11, n12, n13,\n n20, n21, n22, n23,\n n30, n31, n32, n33);\n }\n public void loadMatrix() {\n m00 = modelview.m00;\n m01 = modelview.m01;\n m02 = modelview.m02;\n m03 = modelview.m03;\n m10 = modelview.m10;\n m11 = modelview.m11;\n m12 = modelview.m12;\n m13 = modelview.m13;\n m20 = modelview.m20;\n m21 = modelview.m21;\n m22 = modelview.m22;\n m23 = modelview.m23;\n m30 = modelview.m30;\n m31 = modelview.m31;\n m32 = modelview.m32;\n m33 = modelview.m33;\n }\n public void printMatrix() {\n modelview.print();\n }\n public void beginCamera() {\n if (manipulatingCamera) {\n throw new RuntimeException(\"beginCamera() cannot be called again \" +\n \"before endCamera()\");\n } else {\n manipulatingCamera = true;\n forwardTransform = cameraInv;\n reverseTransform = camera;\n }\n }\n public void endCamera() {\n if (!manipulatingCamera) {\n throw new RuntimeException(\"Cannot call endCamera() \" +\n \"without first calling beginCamera()\");\n }\n modelview.set(camera);\n modelviewInv.set(cameraInv);\n forwardTransform = modelview;\n reverseTransform = modelviewInv;\n manipulatingCamera = false;\n }\n public void camera() {\n camera(cameraX, cameraY, cameraZ,\n cameraX, cameraY, 0,\n 0, 1, 0);\n }\n public void camera(float eyeX, float eyeY, float eyeZ,\n float centerX, float centerY, float centerZ,\n float upX, float upY, float upZ) {\n float z0 = eyeX - centerX;\n float z1 = eyeY - centerY;\n float z2 = eyeZ - centerZ;\n float mag = sqrt(z0*z0 + z1*z1 + z2*z2);\n if (mag != 0) {\n z0 /= mag;\n z1 /= mag;\n z2 /= mag;\n }\n float y0 = upX;\n float y1 = upY;\n float y2 = upZ;\n float x0 = y1*z2 - y2*z1;\n float x1 = -y0*z2 + y2*z0;\n float x2 = y0*z1 - y1*z0;\n y0 = z1*x2 - z2*x1;\n y1 = -z0*x2 + z2*x0;\n y2 = z0*x1 - z1*x0;\n mag = sqrt(x0*x0 + x1*x1 + x2*x2);\n if (mag != 0) {\n x0 /= mag;\n x1 /= mag;\n x2 /= mag;\n }\n mag = sqrt(y0*y0 + y1*y1 + y2*y2);\n if (mag != 0) {\n y0 /= mag;\n y1 /= mag;\n y2 /= mag;\n }\n camera.set(x0, x1, x2, 0,\n y0, y1, y2, 0,\n z0, z1, z2, 0,\n 0, 0, 0, 1);\n camera.translate(-eyeX, -eyeY, -eyeZ);\n cameraInv.reset();\n cameraInv.invApply(x0, x1, x2, 0,\n y0, y1, y2, 0,\n z0, z1, z2, 0,\n 0, 0, 0, 1);\n cameraInv.invTranslate(-eyeX, -eyeY, -eyeZ);\n modelview.set(camera);\n modelviewInv.set(cameraInv);\n }\n public void printCamera() {\n camera.print();\n }\n public void ortho() {\n ortho(0, width, 0, height, -10, 10);\n }\n public void ortho(float left, float right,\n float bottom, float top,\n float near, float far) {\n float x = 2.0f / (right - left);\n float y = 2.0f / (top - bottom);\n float z = -2.0f / (far - near);\n float tx = -(right + left) / (right - left);\n float ty = -(top + bottom) / (top - bottom);\n float tz = -(far + near) / (far - near);\n projection.set(x, 0, 0, tx,\n 0, y, 0, ty,\n 0, 0, z, tz,\n 0, 0, 0, 1);\n }\n public void perspective() {\n perspective(cameraFOV, cameraAspect, cameraNear, cameraFar);\n }\n public void perspective(float fov, float aspect, float zNear, float zFar) {\n float ymax = zNear * tan(fov / 2.0f);\n float ymin = -ymax;\n float xmin = ymin * aspect;\n float xmax = ymax * aspect;\n frustum(xmin, xmax, ymin, ymax, zNear, zFar);\n }\n public void frustum(float left, float right, float bottom,\n float top, float znear, float zfar) {\n projection.set((2*znear)/(right-left), 0, (right+left)/(right-left), 0,\n 0, (2*znear)/(top-bottom), (top+bottom)/(top-bottom), 0,\n 0, 0, -(zfar+znear)/(zfar-znear),-(2*zfar*znear)/(zfar-znear),\n 0, 0, -1, 0);\n }\n public void printProjection() {\n projection.print();\n }\n public float screenX(float x, float y) {\n return screenX(x, y, 0);\n }\n public float screenY(float x, float y) {\n return screenY(x, y, 0);\n }\n public float screenX(float x, float y, float z) {\n float ax =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n float ay =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n float az =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n float aw =\n modelview.m30*x + modelview.m31*y + modelview.m32*z + modelview.m33;\n float ox =\n projection.m00*ax + projection.m01*ay +\n projection.m02*az + projection.m03*aw;\n float ow =\n projection.m30*ax + projection.m31*ay +\n projection.m32*az + projection.m33*aw;\n if (ow != 0) ox /= ow;\n return width * (1 + ox) / 2.0f;\n }\n public float screenY(float x, float y, float z) {\n float ax =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n float ay =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n float az =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n float aw =\n modelview.m30*x + modelview.m31*y + modelview.m32*z + modelview.m33;\n float oy =\n projection.m10*ax + projection.m11*ay +\n projection.m12*az + projection.m13*aw;\n float ow =\n projection.m30*ax + projection.m31*ay +\n projection.m32*az + projection.m33*aw;\n if (ow != 0) oy /= ow;\n return height * (1 + oy) / 2.0f;\n }\n public float screenZ(float x, float y, float z) {\n float ax =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n float ay =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n float az =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n float aw =\n modelview.m30*x + modelview.m31*y + modelview.m32*z + modelview.m33;\n float oz =\n projection.m20*ax + projection.m21*ay +\n projection.m22*az + projection.m23*aw;\n float ow =\n projection.m30*ax + projection.m31*ay +\n projection.m32*az + projection.m33*aw;\n if (ow != 0) oz /= ow;\n return (oz + 1) / 2.0f;\n }\n public float modelX(float x, float y, float z) {\n float ax =\n cameraInv.m00*x + cameraInv.m01*y + cameraInv.m02*z + cameraInv.m03;\n float ay =\n cameraInv.m10*x + cameraInv.m11*y + cameraInv.m12*z + cameraInv.m13;\n float az =\n cameraInv.m20*x + cameraInv.m21*y + cameraInv.m22*z + cameraInv.m23;\n float aw =\n cameraInv.m30*x + cameraInv.m31*y + cameraInv.m32*z + cameraInv.m33;\n float ox =\n modelview.m00*ax + modelview.m01*ay +\n modelview.m02*az + modelview.m03*aw;\n float ow =\n modelview.m30*ax + modelview.m31*ay +\n modelview.m32*az + modelview.m33*aw;\n return (ow != 0) ? ox / ow : ox;\n }\n public float modelY(float x, float y, float z) {\n float ax =\n cameraInv.m00*x + cameraInv.m01*y + cameraInv.m02*z + cameraInv.m03;\n float ay =\n cameraInv.m10*x + cameraInv.m11*y + cameraInv.m12*z + cameraInv.m13;\n float az =\n cameraInv.m20*x + cameraInv.m21*y + cameraInv.m22*z + cameraInv.m23;\n float aw =\n cameraInv.m30*x + cameraInv.m31*y + cameraInv.m32*z + cameraInv.m33;\n float oy =\n modelview.m10*ax + modelview.m11*ay +\n modelview.m12*az + modelview.m13*aw;\n float ow =\n modelview.m30*ax + modelview.m31*ay +\n modelview.m32*az + modelview.m33*aw;\n return (ow != 0) ? oy / ow : oy;\n }\n public float modelZ(float x, float y, float z) {\n float ax =\n cameraInv.m00*x + cameraInv.m01*y + cameraInv.m02*z + cameraInv.m03;\n float ay =\n cameraInv.m10*x + cameraInv.m11*y + cameraInv.m12*z + cameraInv.m13;\n float az =\n cameraInv.m20*x + cameraInv.m21*y + cameraInv.m22*z + cameraInv.m23;\n float aw =\n cameraInv.m30*x + cameraInv.m31*y + cameraInv.m32*z + cameraInv.m33;\n float oz =\n modelview.m20*ax + modelview.m21*ay +\n modelview.m22*az + modelview.m23*aw;\n float ow =\n modelview.m30*ax + modelview.m31*ay +\n modelview.m32*az + modelview.m33*aw;\n return (ow != 0) ? oz / ow : oz;\n }\n public void strokeJoin(int join) {\n String msg = \"strokeJoin() not available with P3D\";\n throw new RuntimeException(msg);\n }\n public void strokeCap(int cap) {\n String msg = \"strokeCap() not available with P3D\";\n throw new RuntimeException(msg);\n }\n protected void fillFromCalc() {\n super.fillFromCalc();\n ambientFromCalc();\n }\n public void ambient(int rgb) {\n if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { \n ambient((float) rgb);\n } else {\n colorCalcARGB(rgb, colorModeA);\n ambientFromCalc();\n }\n }\n public void ambient(float gray) {\n colorCalc(gray);\n ambientFromCalc();\n }\n public void ambient(float x, float y, float z) {\n colorCalc(x, y, z);\n ambientFromCalc();\n }\n protected void ambientFromCalc() {\n ambientR = calcR;\n ambientG = calcG;\n ambientB = calcB;\n }\n public void specular(int rgb) {\n if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { \n specular((float) rgb);\n } else {\n colorCalcARGB(rgb, colorModeA);\n specularFromCalc();\n }\n }\n public void specular(float gray) {\n colorCalc(gray);\n specularFromCalc();\n }\n public void specular(float gray, float alpha) {\n colorCalc(gray, alpha);\n specularFromCalc();\n }\n public void specular(float x, float y, float z) {\n colorCalc(x, y, z);\n specularFromCalc();\n }\n public void specular(float x, float y, float z, float a) {\n colorCalc(x, y, z, a);\n specularFromCalc();\n }\n protected void specularFromCalc() {\n specularR = calcR;\n specularG = calcG;\n specularB = calcB;\n specularA = calcA;\n }\n public void shininess(float shine) {\n shininess = shine;\n }\n public void emissive(int rgb) {\n if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { \n emissive((float) rgb);\n } else {\n colorCalcARGB(rgb, colorModeA);\n emissiveFromCalc();\n }\n }\n public void emissive(float gray) {\n colorCalc(gray);\n emissiveFromCalc();\n }\n public void emissive(float x, float y, float z) {\n colorCalc(x, y, z);\n emissiveFromCalc();\n }\n protected void emissiveFromCalc() {\n emissiveR = calcR;\n emissiveG = calcG;\n emissiveB = calcB;\n }\n public void lights() {\n int colorModeSaved = colorMode;\n colorMode = RGB;\n lightFalloff(1, 0, 0);\n lightSpecular(0, 0, 0);\n ambientLight(colorModeX * 0.5f,\n colorModeY * 0.5f,\n colorModeZ * 0.5f);\n directionalLight(colorModeX * 0.5f,\n colorModeY * 0.5f,\n colorModeZ * 0.5f,\n 0, 0, -1);\n colorMode = colorModeSaved;\n lightingDependsOnVertexPosition = false;\n }\n public void ambientLight(float r, float g, float b) {\n ambientLight(r, g, b, 0, 0, 0);\n }\n public void ambientLight(float r, float g, float b,\n float x, float y, float z) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = AMBIENT;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightPosition(lightCount, x, y, z);\n lightCount++;\n }\n public void directionalLight(float r, float g, float b,\n float nx, float ny, float nz) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = DIRECTIONAL;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightSpecular[lightCount][0] = currentLightSpecular[0];\n lightSpecular[lightCount][1] = currentLightSpecular[1];\n lightSpecular[lightCount][2] = currentLightSpecular[2];\n lightDirection(lightCount, nx, ny, nz);\n lightCount++;\n }\n public void pointLight(float r, float g, float b,\n float x, float y, float z) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = POINT;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightSpecular[lightCount][0] = currentLightSpecular[0];\n lightSpecular[lightCount][1] = currentLightSpecular[1];\n lightSpecular[lightCount][2] = currentLightSpecular[2];\n lightPosition(lightCount, x, y, z);\n lightCount++;\n lightingDependsOnVertexPosition = true;\n }\n public void spotLight(float r, float g, float b,\n float x, float y, float z,\n float nx, float ny, float nz,\n float angle, float concentration) {\n if (lightCount == MAX_LIGHTS) {\n throw new RuntimeException(\"can only create \" + MAX_LIGHTS + \" lights\");\n }\n colorCalc(r, g, b);\n lightDiffuse[lightCount][0] = calcR;\n lightDiffuse[lightCount][1] = calcG;\n lightDiffuse[lightCount][2] = calcB;\n lightType[lightCount] = SPOT;\n lightFalloffConstant[lightCount] = currentLightFalloffConstant;\n lightFalloffLinear[lightCount] = currentLightFalloffLinear;\n lightFalloffQuadratic[lightCount] = currentLightFalloffQuadratic;\n lightSpecular[lightCount][0] = currentLightSpecular[0];\n lightSpecular[lightCount][1] = currentLightSpecular[1];\n lightSpecular[lightCount][2] = currentLightSpecular[2];\n lightPosition(lightCount, x, y, z);\n lightDirection(lightCount, nx, ny, nz);\n lightSpotAngle[lightCount] = angle;\n lightSpotAngleCos[lightCount] = max(0, cos(angle));\n lightSpotConcentration[lightCount] = concentration;\n lightCount++;\n lightingDependsOnVertexPosition = true;\n }\n public void lightFalloff(float constant, float linear, float quadratic) {\n currentLightFalloffConstant = constant;\n currentLightFalloffLinear = linear;\n currentLightFalloffQuadratic = quadratic;\n lightingDependsOnVertexPosition = true;\n }\n public void lightSpecular(float x, float y, float z) {\n colorCalc(x, y, z);\n currentLightSpecular[0] = calcR;\n currentLightSpecular[1] = calcG;\n currentLightSpecular[2] = calcB;\n lightingDependsOnVertexPosition = true;\n }\n protected void lightPosition(int num, float x, float y, float z) {\n lightPosition[num][0] =\n modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03;\n lightPosition[num][1] =\n modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13;\n lightPosition[num][2] =\n modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23;\n }\n protected void lightDirection(int num, float x, float y, float z) {\n lightNormal[num][0] =\n modelviewInv.m00*x + modelviewInv.m10*y +\n modelviewInv.m20*z + modelviewInv.m30;\n lightNormal[num][1] =\n modelviewInv.m01*x + modelviewInv.m11*y +\n modelviewInv.m21*z + modelviewInv.m31;\n lightNormal[num][2] =\n modelviewInv.m02*x + modelviewInv.m12*y +\n modelviewInv.m22*z + modelviewInv.m32;\n float n = mag(lightNormal[num]);\n if (n == 0 || n == 1) return;\n lightNormal[num][0] /= n;\n lightNormal[num][1] /= n;\n lightNormal[num][2] /= n;\n }\n public void background(PImage image) {\n super.background(image);\n for (int i = 0; i < pixelCount; i++) {\n zbuffer[i] = Float.MAX_VALUE;\n }\n }\n protected void clear() {\n for (int i = 0; i < pixelCount; i++) {\n pixels[i] = backgroundColor;\n zbuffer[i] = Float.MAX_VALUE;\n }\n }\n public void smooth() {\n String msg = \"smooth() not available with P3D\";\n throw new RuntimeException(msg);\n }\n public void noSmooth() {\n String msg = \"noSmooth() not available with P3D\";\n throw new RuntimeException(msg);\n }\n private final float mag(float a, float b, float c) {\n return (float)Math.sqrt(a*a + b*b + c*c);\n }\n private final float mag(float abc[]) {\n return (float)Math.sqrt(abc[0]*abc[0] + abc[1]*abc[1] + abc[2]*abc[2]);\n }\n private final float min(float a, float b) {\n return (a < b) ? a : b;\n }\n private final float max(float a, float b) {\n return (a > b) ? a : b;\n }\n private final float pow(float a, float b) {\n return (float)Math.pow(a, b);\n }\n private final float abs(float a) {\n return (a < 0) ? -a : a;\n }\n private final float cos(float angle) {\n return (float)Math.cos(angle);\n }\n private final float tan(float angle) {\n return (float)Math.tan(angle);\n }\n private float dot(float ax, float ay, float az,\n float bx, float by, float bz) {\n return ax * bx + ay * by + az * bz;\n }\n}\n"} {"input": "\tpublic void onResume(){\n\t\tsuper.onResume();\n\t\tif(isMyself()){\n\t\t\ttry{\t\t\n\t\t\t\tint id = bookmark.getId();\n\t\t\t\tbookmark = BookmarkManager.GetById(id, base);\n\t\t\t\tDate d = new Date(bookmark.getTime());\n\t\t\t\tmTitle.setText(Boolean.toString(bookmark.getSynced()));\n\t\t\t\tmUrl.setText(bookmark.getUrl());\n\t\t\t\tmNotes.setText(bookmark.getNotes());\n\t\t\t\tmTime.setText(d.toString());\n\t\t\t\tmUsername.setText(bookmark.getAccount());\n\t\t\t\tif(!bookmark.getShared()) {\n\t\t\t\t\tmIcon.setImageResource(R.drawable.padlock);\n\t\t\t\t} else if(bookmark.getToRead()) {\n\t\t\t\t\tmIcon.setImageResource(R.drawable.book_open);\n\t\t\t\t}\n \t\tSpannableStringBuilder tagBuilder = new SpannableStringBuilder();\n \t\tfor(Tag t : bookmark.getTags()) {\n \t\t\taddTag(tagBuilder, t, tagOnClickListener);\n \t\t}\n \t\tmTags.setText(tagBuilder);\n \t\tmTags.setMovementMethod(LinkMovementMethod.getInstance());\n\t\t\t}\n\t\t\tcatch(ContentNotFoundException e){}\n\t\t} else {\n\t\t\tDate d = new Date(bookmark.getTime());\n\t\t\tif(!bookmark.getDescription().equals(\"null\"))\n\t\t\t\tmTitle.setText(bookmark.getDescription());\n\t\t\tmUrl.setText(bookmark.getUrl());\n\t\t\tif(!bookmark.getNotes().equals(\"null\"))\n\t\t\t\t\tmNotes.setText(bookmark.getNotes());\n\t\t\tmTime.setText(d.toString());\n \t\tSpannableStringBuilder tagBuilder = new SpannableStringBuilder();\n \t\tfor(Tag t : bookmark.getTags()) {\n \t\t\taddTag(tagBuilder, t, userTagOnClickListener);\n \t\t}\n \t\tmTags.setText(tagBuilder);\n \t\tmTags.setMovementMethod(LinkMovementMethod.getInstance());\n\t\t\tSpannableStringBuilder builder = new SpannableStringBuilder();\n\t\t\tint start = builder.length();\n\t\t\tbuilder.append(bookmark.getAccount());\n\t\t\tint end = builder.length();\n\t\t\tAccountSpan span = new AccountSpan(bookmark.getAccount());\n\t\t\tspan.setOnAccountClickListener(accountOnClickListener);\n\t\t\tbuilder.setSpan(span, start, end, 0);\n\t\t\tmUsername.setText(builder);\n\t\t\tmUsername.setMovementMethod(LinkMovementMethod.getInstance());\n\t\t}\n\t}\n", "output": "\tpublic void onResume(){\n\t\tsuper.onResume();\n\t\tif(isMyself()){\n\t\t\ttry{\t\t\n\t\t\t\tint id = bookmark.getId();\n\t\t\t\tbookmark = BookmarkManager.GetById(id, base);\n\t\t\t\tDate d = new Date(bookmark.getTime());\n\t\t\t\tmTitle.setText(bookmark.getDescription());\n\t\t\t\tmUrl.setText(bookmark.getUrl());\n\t\t\t\tmNotes.setText(bookmark.getNotes());\n\t\t\t\tmTime.setText(d.toString());\n\t\t\t\tmUsername.setText(bookmark.getAccount());\n\t\t\t\tif(!bookmark.getShared()) {\n\t\t\t\t\tmIcon.setImageResource(R.drawable.padlock);\n\t\t\t\t} else if(bookmark.getToRead()) {\n\t\t\t\t\tmIcon.setImageResource(R.drawable.book_open);\n\t\t\t\t}\n \t\tSpannableStringBuilder tagBuilder = new SpannableStringBuilder();\n \t\tfor(Tag t : bookmark.getTags()) {\n \t\t\taddTag(tagBuilder, t, tagOnClickListener);\n \t\t}\n \t\tmTags.setText(tagBuilder);\n \t\tmTags.setMovementMethod(LinkMovementMethod.getInstance());\n\t\t\t}\n\t\t\tcatch(ContentNotFoundException e){}\n\t\t} else {\n\t\t\tDate d = new Date(bookmark.getTime());\n\t\t\tif(!bookmark.getDescription().equals(\"null\"))\n\t\t\t\tmTitle.setText(bookmark.getDescription());\n\t\t\tmUrl.setText(bookmark.getUrl());\n\t\t\tif(!bookmark.getNotes().equals(\"null\"))\n\t\t\t\t\tmNotes.setText(bookmark.getNotes());\n\t\t\tmTime.setText(d.toString());\n \t\tSpannableStringBuilder tagBuilder = new SpannableStringBuilder();\n \t\tfor(Tag t : bookmark.getTags()) {\n \t\t\taddTag(tagBuilder, t, userTagOnClickListener);\n \t\t}\n \t\tmTags.setText(tagBuilder);\n \t\tmTags.setMovementMethod(LinkMovementMethod.getInstance());\n\t\t\tSpannableStringBuilder builder = new SpannableStringBuilder();\n\t\t\tint start = builder.length();\n\t\t\tbuilder.append(bookmark.getAccount());\n\t\t\tint end = builder.length();\n\t\t\tAccountSpan span = new AccountSpan(bookmark.getAccount());\n\t\t\tspan.setOnAccountClickListener(accountOnClickListener);\n\t\t\tbuilder.setSpan(span, start, end, 0);\n\t\t\tmUsername.setText(builder);\n\t\t\tmUsername.setMovementMethod(LinkMovementMethod.getInstance());\n\t\t}\n\t}\n"} {"input": "\tprivate void writeSampleFile(Writer sampleWriter) throws IOException\n\t{\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"ID_1\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"ID_2\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"missing\");\n\t\tList colNames = new ArrayList();\n\t\tList dataTypes = new ArrayList();\n\t\tfor (SampleAnnotation annotation : genotypeData.getSampleAnnotations())\n\t\t{\n\t\t\tif (annotation.getSampleAnnotationType() == SampleAnnotationType.COVARIATE)\n\t\t\t{\n\t\t\t\tswitch (annotation.getType())\n\t\t\t\t{\n\t\t\t\t\tcase INTEGER:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"D\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FLOAT:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"C\");\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tLOG.warn(\"Unsupported covariate datatype [\" + annotation.getType() + \"]\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (annotation.getSampleAnnotationType() == SampleAnnotationType.PHENOTYPE)\n\t\t\t{\n\t\t\t\tswitch (annotation.getType())\n\t\t\t\t{\n\t\t\t\t\tcase BOOLEAN:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"B\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FLOAT:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"P\");\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tLOG.warn(\"Unsupported phenotype datatype [\" + annotation.getType() + \"]\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLOG.warn(\"'OTHER' sample annotation type not supported by impute2\");\n\t\t\t}\n\t\t}\n\t\tfor (String colName : colNames)\n\t\t{\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(colName);\n\t\t}\n\t\tsb.append(LINE_ENDING);\n\t\tsb.append(\"0\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"0\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"0\");\n\t\tfor (String dataType : dataTypes)\n\t\t{\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(dataType);\n\t\t}\n\t\tsb.append(LINE_ENDING);\n\t\tsampleWriter.write(sb.toString());\n\t\tfor (Sample sample : genotypeData.getSamples())\n\t\t{\n\t\t\tsb = new StringBuilder();\n\t\t\tsb.append(sample.getFamilyId() == null ? \"NA\" : sample.getFamilyId());\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(sample.getId() == null ? \"NA\" : sample.getId());\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(getValue(\"missing\", sample, \"0\"));\n\t\t\tfor (String colName : colNames)\n\t\t\t{\n\t\t\t\tsb.append(SEPARATOR);\n\t\t\t\tsb.append(getValue(colName, sample, \"NA\"));\n\t\t\t}\n\t\t\tsb.append(LINE_ENDING);\n\t\t\tsampleWriter.write(sb.toString());\n\t\t}\n\t}\n", "output": "\tprivate void writeSampleFile(Writer sampleWriter) throws IOException\n\t{\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"ID_1\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"ID_2\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"missing\");\n\t\tList colNames = new ArrayList();\n\t\tList dataTypes = new ArrayList();\n\t\tfor (SampleAnnotation annotation : genotypeData.getSampleAnnotations())\n\t\t{\n\t\t\tif (annotation.getSampleAnnotationType() == SampleAnnotationType.COVARIATE)\n\t\t\t{\n\t\t\t\tswitch (annotation.getType())\n\t\t\t\t{\n\t\t\t\t\tcase INTEGER:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"D\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FLOAT:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"C\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tLOG.warn(\"Unsupported covariate datatype [\" + annotation.getType() + \"]\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (annotation.getSampleAnnotationType() == SampleAnnotationType.PHENOTYPE)\n\t\t\t{\n\t\t\t\tswitch (annotation.getType())\n\t\t\t\t{\n\t\t\t\t\tcase BOOLEAN:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"B\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase FLOAT:\n\t\t\t\t\t\tcolNames.add(annotation.getId());\n\t\t\t\t\t\tdataTypes.add(\"P\");\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tLOG.warn(\"Unsupported phenotype datatype [\" + annotation.getType() + \"]\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLOG.warn(\"'OTHER' sample annotation type not supported by impute2\");\n\t\t\t}\n\t\t}\n\t\tfor (String colName : colNames)\n\t\t{\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(colName);\n\t\t}\n\t\tsb.append(LINE_ENDING);\n\t\tsb.append(\"0\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"0\");\n\t\tsb.append(SEPARATOR);\n\t\tsb.append(\"0\");\n\t\tfor (String dataType : dataTypes)\n\t\t{\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(dataType);\n\t\t}\n\t\tsb.append(LINE_ENDING);\n\t\tsampleWriter.write(sb.toString());\n\t\tfor (Sample sample : genotypeData.getSamples())\n\t\t{\n\t\t\tsb = new StringBuilder();\n\t\t\tsb.append(sample.getFamilyId() == null ? \"NA\" : sample.getFamilyId());\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(sample.getId() == null ? \"NA\" : sample.getId());\n\t\t\tsb.append(SEPARATOR);\n\t\t\tsb.append(getValue(\"missing\", sample, \"0\"));\n\t\t\tfor (String colName : colNames)\n\t\t\t{\n\t\t\t\tsb.append(SEPARATOR);\n\t\t\t\tsb.append(getValue(colName, sample, \"NA\"));\n\t\t\t}\n\t\t\tsb.append(LINE_ENDING);\n\t\t\tsampleWriter.write(sb.toString());\n\t\t}\n\t}\n"} {"input": " public void parse(final Builder builder) throws IOException {\n builder.startDoc(token(filename));\n final Stack stack = new Stack();\n stack.push(new NodeIterator(root));\n while(!stack.empty()) {\n final NodeIterator ni = stack.peek();\n if(ni.more()) {\n final Node n = ni.curr();\n if(n instanceof Element) {\n stack.push(new NodeIterator(n));\n final NamedNodeMap at = n.getAttributes();\n final int as = at.getLength();\n atts.reset();\n for(int a = 0; a < as; a++) {\n atts.add(token(at.item(a).getNodeName()),\n token(at.item(a).getNodeValue()));\n }\n builder.startElem(token(n.getNodeName()), atts);\n } else if(n instanceof Text) {\n builder.text(new TokenBuilder(n.getNodeValue()));\n } else if(n instanceof Comment) {\n builder.comment(new TokenBuilder(n.getNodeValue()));\n } else if(n instanceof ProcessingInstruction) {\n builder.pi(new TokenBuilder(n.getNodeName() + ' ' +\n n.getNodeValue()));\n builder.text(new TokenBuilder(n.getNodeValue()));\n }\n nodes++;\n } else {\n stack.pop();\n if(stack.empty()) break;\n builder.endElem(token(stack.peek().curr().getNodeName()));\n }\n }\n builder.endDoc();\n }\n", "output": " public void parse(final Builder builder) throws IOException {\n builder.startDoc(token(filename));\n final Stack stack = new Stack();\n stack.push(new NodeIterator(root));\n while(!stack.empty()) {\n final NodeIterator ni = stack.peek();\n if(ni.more()) {\n final Node n = ni.curr();\n if(n instanceof Element) {\n stack.push(new NodeIterator(n));\n final NamedNodeMap at = n.getAttributes();\n final int as = at.getLength();\n atts.reset();\n for(int a = 0; a < as; a++) {\n final byte[] att = token(at.item(a).getNodeName());\n if (eq(att, XMLNS)) {\n builder.startNS(EMPTY, token(at.item(a).getNodeValue()));\n } else if (eq(att, XMLNSC)) {\n builder.startNS(substring(att, 6), \n token(at.item(a).getNodeValue()));\n } else {\n atts.add(att, token(at.item(a).getNodeValue()));\n }\n }\n builder.startElem(token(n.getNodeName()), atts);\n } else if(n instanceof Text) {\n builder.text(new TokenBuilder(n.getNodeValue()));\n } else if(n instanceof Comment) {\n builder.comment(new TokenBuilder(n.getNodeValue()));\n } else if(n instanceof ProcessingInstruction) {\n builder.pi(new TokenBuilder(n.getNodeName() + ' ' +\n n.getNodeValue()));\n builder.text(new TokenBuilder(n.getNodeValue()));\n }\n nodes++;\n } else {\n stack.pop();\n if(stack.empty()) break;\n builder.endElem(token(stack.peek().curr().getNodeName()));\n }\n }\n builder.endDoc();\n }\n"} {"input": " public void generateAndCompile() throws Exception\n {\n File componentDir = new File(\"src/test/resources/com/seitenbau/micgwaf/page\");\n File generatedSourcesDir = new File(\"target/generated-sources\");\n File generatedExtensionsDir = new File(\"target/generated-extension-sources\");\n File compileRootDir = new File(\"target/manually-compiled-classes\");\n FileUtils.deleteDirectory(generatedSourcesDir);\n FileUtils.deleteDirectory(generatedExtensionsDir);\n FileUtils.deleteDirectory(compileRootDir);\n Generator generator = new Generator();\n generator.generateComponent(\n componentDir, \n generatedSourcesDir, \n generatedExtensionsDir,\n \"com.seitenbau.micgwaf.test.generated\");\n compileRootDir.mkdirs();\n JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();\n compiler.run(null, null, null, \n \"-g\", \n \"-d\", compileRootDir.getAbsolutePath(),\n \"-sourcepath\", generatedSourcesDir.getAbsolutePath() + \";\" + generatedExtensionsDir.getAbsolutePath(),\n generatedExtensionsDir.getAbsolutePath() + \"/com/seitenbau/micgwaf/test/generated/root/RootExtension.java\");\n }\n", "output": " public void generateAndCompile() throws Exception\n {\n File componentDir = new File(\"src/test/resources/com/seitenbau/micgwaf/page\");\n File generatedSourcesDir = new File(\"target/generated-sources\");\n File generatedExtensionsDir = new File(\"target/generated-extension-sources\");\n File compileRootDir = new File(\"target/manually-compiled-classes\");\n FileUtils.deleteDirectory(generatedSourcesDir);\n FileUtils.deleteDirectory(generatedExtensionsDir);\n FileUtils.deleteDirectory(compileRootDir);\n Generator generator = new Generator();\n generator.generateComponent(\n componentDir, \n generatedSourcesDir, \n generatedExtensionsDir,\n \"com.seitenbau.micgwaf.test.generated\");\n compileRootDir.mkdirs();\n JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();\n compiler.run(null, null, null, \n \"-g\", \n \"-d\", compileRootDir.getAbsolutePath(),\n \"-verbose\",\n \"-sourcepath\", generatedSourcesDir.getAbsolutePath() + \";\" + generatedExtensionsDir.getAbsolutePath(),\n generatedExtensionsDir.getAbsolutePath() + \"/com/seitenbau/micgwaf/test/generated/root/RootExtension.java\");\n }\n"} {"input": " public void run() {\n Thread thisThread = Thread.currentThread();\n ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);\n while (curThread == thisThread) {\n List part = collectionHandler.getNextPart(this);\n for (WebURL url : part) {\n executor.submit(new PageProcessingTask(new Page(url), collectionHandler));\n }\n try {\n executor.shutdown();\n executor.awaitTermination(20, TimeUnit.MINUTES);\n } catch (InterruptedException e) {\n stop();\n e.printStackTrace();\n }\n }\n }\n", "output": " public void run() {\n Thread thisThread = Thread.currentThread();\n while (curThread == thisThread) {\n List part = collectionHandler.getNextPart(this);\n ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);\n for (WebURL url : part) {\n executor.submit(new PageProcessingTask(new Page(url), collectionHandler));\n }\n try {\n executor.shutdown();\n executor.awaitTermination(20, TimeUnit.MINUTES);\n } catch (InterruptedException e) {\n stop();\n e.printStackTrace();\n }\n }\n }\n"} {"input": " public Parser getParser(final MyInfo myInfo, final IrcAddress address) {\n final ServerInfo info = new ServerInfo(address.getServer(), address.getPort(6667),\n address.getPassword());\n info.setSSL(address.isSSL());\n if (\"irc\".equals(address.getProtocol())) {\n return new IRCParser(myInfo, info);\n } else if (\"irc-test\".equals(address.getProtocol())) {\n try {\n return (Parser) Class.forName(\"com.dmdirc.harness.parser.TestParser\")\n .getConstructor(MyInfo.class, ServerInfo.class)\n .newInstance(myInfo, info);\n } catch (Exception ex) {\n Logger.userError(ErrorLevel.UNKNOWN, \"Unable to create parser\", ex);\n }\n }\n return null;\n }\n", "output": " public Parser getParser(final MyInfo myInfo, final IrcAddress address) {\n final ServerInfo info = new ServerInfo(address.getServer(), address.getPort(6667),\n address.getPassword());\n info.setSSL(address.isSSL());\n if (\"irc-test\".equals(address.getProtocol())) {\n try {\n return (Parser) Class.forName(\"com.dmdirc.harness.parser.TestParser\")\n .getConstructor(MyInfo.class, ServerInfo.class)\n .newInstance(myInfo, info);\n } catch (Exception ex) {\n Logger.userError(ErrorLevel.UNKNOWN, \"Unable to create parser\", ex);\n }\n }\n return new IRCParser(myInfo, info);\n }\n"} {"input": " protected MultipleGradientPaintContext(MultipleGradientPaint mgp,\n ColorModel cm,\n Rectangle deviceBounds,\n Rectangle2D userBounds,\n AffineTransform t,\n RenderingHints hints,\n float[] fractions,\n Color[] colors, \n CycleMethod cycleMethod,\n ColorSpaceType colorSpace) \n { \n if (deviceBounds == null) {\n throw new NullPointerException(\"Device bounds cannot be null\");\n }\n if (userBounds == null) {\n throw new NullPointerException(\"User bounds cannot be null\");\n }\n if (t == null) {\n throw new NullPointerException(\"Transform cannot be null\");\n }\n if (hints == null) {\n throw new NullPointerException(\"RenderingHints cannot be null\");\n }\n AffineTransform tInv;\n try {\n tInv = t.createInverse();\n } catch (NoninvertibleTransformException e) {\n tInv = new AffineTransform();\n }\n double m[] = new double[6];\n tInv.getMatrix(m);\n a00 = (float)m[0];\n a10 = (float)m[1];\n a01 = (float)m[2];\n a11 = (float)m[3];\n a02 = (float)m[4];\n a12 = (float)m[5];\n this.cycleMethod = cycleMethod;\n this.colorSpace = colorSpace;\n this.fractions = fractions;\n int[] gradient =\n (mgp.gradient != null) ? mgp.gradient.get() : null;\n int[][] gradients =\n (mgp.gradients != null) ? mgp.gradients.get() : null;\n if (gradient == null && gradients == null) {\n calculateLookupData(colors);\n mgp.model = this.model;\n mgp.normalizedIntervals = this.normalizedIntervals;\n mgp.isSimpleLookup = this.isSimpleLookup;\n if (isSimpleLookup) {\n mgp.fastGradientArraySize = this.fastGradientArraySize;\n mgp.gradient = new SoftReference(this.gradient);\n } else {\n mgp.gradients = new SoftReference(this.gradients);\n }\n } else {\n this.model = mgp.model;\n this.normalizedIntervals = mgp.normalizedIntervals;\n this.isSimpleLookup = mgp.isSimpleLookup;\n this.gradient = gradient;\n this.fastGradientArraySize = mgp.fastGradientArraySize;\n this.gradients = gradients;\n }\n }\n", "output": " protected MultipleGradientPaintContext(MultipleGradientPaint mgp,\n ColorModel cm,\n Rectangle deviceBounds,\n Rectangle2D userBounds,\n AffineTransform t,\n RenderingHints hints,\n float[] fractions,\n Color[] colors, \n CycleMethod cycleMethod,\n ColorSpaceType colorSpace) \n { \n if (deviceBounds == null) {\n throw new NullPointerException(\"Device bounds cannot be null\");\n }\n if (userBounds == null) {\n throw new NullPointerException(\"User bounds cannot be null\");\n }\n if (t == null) {\n throw new NullPointerException(\"Transform cannot be null\");\n }\n if (hints == null) {\n }\n AffineTransform tInv;\n try {\n tInv = t.createInverse();\n } catch (NoninvertibleTransformException e) {\n tInv = new AffineTransform();\n }\n double m[] = new double[6];\n tInv.getMatrix(m);\n a00 = (float)m[0];\n a10 = (float)m[1];\n a01 = (float)m[2];\n a11 = (float)m[3];\n a02 = (float)m[4];\n a12 = (float)m[5];\n this.cycleMethod = cycleMethod;\n this.colorSpace = colorSpace;\n this.fractions = fractions;\n int[] gradient =\n (mgp.gradient != null) ? mgp.gradient.get() : null;\n int[][] gradients =\n (mgp.gradients != null) ? mgp.gradients.get() : null;\n if (gradient == null && gradients == null) {\n calculateLookupData(colors);\n mgp.model = this.model;\n mgp.normalizedIntervals = this.normalizedIntervals;\n mgp.isSimpleLookup = this.isSimpleLookup;\n if (isSimpleLookup) {\n mgp.fastGradientArraySize = this.fastGradientArraySize;\n mgp.gradient = new SoftReference(this.gradient);\n } else {\n mgp.gradients = new SoftReference(this.gradients);\n }\n } else {\n this.model = mgp.model;\n this.normalizedIntervals = mgp.normalizedIntervals;\n this.isSimpleLookup = mgp.isSimpleLookup;\n this.gradient = gradient;\n this.fastGradientArraySize = mgp.fastGradientArraySize;\n this.gradients = gradients;\n }\n }\n"} {"input": "\tprivate static IResource getResourceForElement(Object element) {\n\t\tif (element instanceof DiffChangeSet) {\n\t\t\tIResource[] resources = ((DiffChangeSet) element).getResources();\n\t\t\tif (resources.length > 0) {\n\t\t\t\treturn resources[0];\n\t\t\t}\n\t\t} \n\t\tif (element instanceof SynchronizeModelElement) {\n\t\t\tSynchronizeModelElement modelElement = (SynchronizeModelElement) element;\n\t\t\tIResource resource = modelElement.getResource();\n\t\t\tif (resource != null) {\n\t\t\t\treturn resource;\n\t\t\t} else {\n\t\t\t\tIDiffElement[] elements = modelElement.getChildren();\n\t\t\t\tif (elements.length > 0) {\n\t\t\t\t\tif (elements[0] instanceof SynchronizeModelElement) {\n\t\t\t\t\t\treturn ((SynchronizeModelElement) elements[0]).getResource();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} \n\t\tif (element instanceof IAdaptable) {\n\t\t\tIAdaptable adaptable = (IAdaptable) element;\n\t\t\tIResourceVariant resourceVariant = (IResourceVariant) adaptable.getAdapter(IResourceVariant.class);\n\t\t\tif (resourceVariant != null && resourceVariant instanceof RemoteResource) {\n\t\t\t\tRemoteResource remoteResource = (RemoteResource) resourceVariant;\n\t\t\t\tString path = remoteResource.getRepositoryRelativePath();\n\t\t\t\tfor (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {\n\t\t\t\t\tif (project.isAccessible()) {\n\t\t\t\t\t\tICVSResource cvsResource = CVSWorkspaceRoot.getCVSFolderFor(project);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (cvsResource != null && path.startsWith(cvsResource.getRepositoryRelativePath())) {\n\t\t\t\t\t\t\t\treturn project;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (CVSException ex) {\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tprivate static IResource getResourceForElement(Object element) {\n\t\tif (element instanceof DiffChangeSet) {\n\t\t\tIResource[] resources = ((DiffChangeSet) element).getResources();\n\t\t\tif (resources.length > 0) {\n\t\t\t\treturn resources[0];\n\t\t\t}\n\t\t} \n\t\tif (element instanceof SynchronizeModelElement) {\n\t\t\tSynchronizeModelElement modelElement = (SynchronizeModelElement) element;\n\t\t\tIResource resource = modelElement.getResource();\n\t\t\tif (resource != null) {\n\t\t\t\treturn resource;\n\t\t\t} else {\n\t\t\t\tIDiffElement[] elements = modelElement.getChildren();\n\t\t\t\tif (elements.length > 0) {\n\t\t\t\t\tif (elements[0] instanceof SynchronizeModelElement) {\n\t\t\t\t\t\treturn ((SynchronizeModelElement) elements[0]).getResource();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} \n\t\tif (element instanceof IAdaptable) {\n\t\t\tIAdaptable adaptable = (IAdaptable) element;\n\t\t\tIResourceVariant resourceVariant = (IResourceVariant) adaptable.getAdapter(IResourceVariant.class);\n\t\t\tif (resourceVariant != null && resourceVariant instanceof RemoteResource) {\n\t\t\t\tRemoteResource remoteResource = (RemoteResource) resourceVariant;\n\t\t\t\tString path = remoteResource.getRepositoryRelativePath();\n\t\t\t\tif (path != null) {\n\t\t\t\t\tfor (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {\n\t\t\t\t\t\tif (project.isAccessible()) {\n\t\t\t\t\t\t\tICVSResource cvsResource = CVSWorkspaceRoot.getCVSFolderFor(project);\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (cvsResource != null && path.startsWith(cvsResource.getRepositoryRelativePath())) {\n\t\t\t\t\t\t\t\t\treturn project;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (CVSException ex) {\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": " public Response loadData(int action, int startIndex, Map filteredColumns, ArrayList currentSortedColumns, ArrayList currentSortedVersusColumns, Class valueObjectType, Map otherGridParams) {\n ReportesGridFrame frame = (ReportesGridFrame) gridFrame;\n Session s = null;\n try {\n filteredColumns.put(\n \"mostarEnListado\",\n new FilterWhereClause[]{\n new FilterWhereClause(\"mostarEnListado\", \"=\", true),\n null\n });\n String sql = \"FROM \" + claseModeloFullPath + \" C \";\n boolean sw = false;\n if (frame.getCategoria() != null) {\n sql += \" WHERE C.categoria='\" + frame.getCategoria() + \"' \";\n sw = true;\n }\n if (frame.getTipo() != -1) {\n if (sw) {\n sql += \" AND \";\n } else {\n sql += \" WHERE \";\n }\n sql += \" C.tipo=\" + frame.getTipo() + \" \";\n }\n SessionFactory sf = HibernateUtil.getSessionFactory();\n s = sf.openSession();\n Response res = HibernateUtils.getAllFromQuery(\n filteredColumns,\n currentSortedColumns,\n currentSortedVersusColumns,\n valueObjectType,\n sql,\n new Object[0],\n new Type[0],\n \"C\",\n sf,\n s);\n return res;\n } catch (Exception ex) {\n LoggerUtil.error(this.getClass(), \"loadData\", ex);\n return new ErrorResponse(ex.getMessage());\n } finally {\n if (s != null) {\n s.close();\n }\n }\n }\n", "output": " public Response loadData(int action, int startIndex, Map filteredColumns, ArrayList currentSortedColumns, ArrayList currentSortedVersusColumns, Class valueObjectType, Map otherGridParams) {\n ReportesGridFrame frame = (ReportesGridFrame) gridFrame;\n Session s = null;\n try {\n String sql = \"FROM \" + claseModeloFullPath + \" C \";\n boolean sw = false;\n if (frame.getCategoria() != null) {\n sql += \" WHERE C.categoria='\" + frame.getCategoria() + \"' \";\n sw = true;\n }\n if (frame.getTipo() != -1) {\n if (sw) {\n sql += \" AND \";\n } else {\n sql += \" WHERE \";\n }\n sql += \" C.tipo=\" + frame.getTipo() + \" \";\n }\n SessionFactory sf = HibernateUtil.getSessionFactory();\n s = sf.openSession();\n Response res = HibernateUtils.getAllFromQuery(\n filteredColumns,\n currentSortedColumns,\n currentSortedVersusColumns,\n valueObjectType,\n sql,\n new Object[0],\n new Type[0],\n \"C\",\n sf,\n s);\n return res;\n } catch (Exception ex) {\n LoggerUtil.error(this.getClass(), \"loadData\", ex);\n return new ErrorResponse(ex.getMessage());\n } finally {\n if (s != null) {\n s.close();\n }\n }\n }\n"} {"input": "\tprivate Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) {\n\t\tCTabFolder folder = new CTabFolder(parent, SWT.BOTTOM);\n\t\tCTabItem item = new CTabItem(folder, SWT.NONE);\n\t\titem.setText(Messages.ModelTooling_Common_TabDefault);\n\t\tparent = createScrollableContainer(folder);\n\t\titem.setControl(parent.getParent());\n\t\tif (getEditor().isShowXMIId() || getEditor().isLiveModel()) {\n\t\t\tControlFactory.createXMIId(parent, this);\n\t\t}\n\t\tIWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);\n\t\t{\n\t\t\tLabel l = new Label(parent, SWT.NONE);\n\t\t\tl.setText(Messages.CoreExpressionEditor_ExpressionId);\n\t\t\tl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));\n\t\t\tfinal Text t = new Text(parent, SWT.BORDER);\n\t\t\tTextPasteHandler.createFor(t);\n\t\t\tGridData gd = new GridData(GridData.FILL_HORIZONTAL);\n\t\t\tt.setLayoutData(gd);\n\t\t\tcontext.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.CORE_EXPRESSION__CORE_EXPRESSION_ID).observeDetail(getMaster()));\n\t\t\tif (getEditor().getExtensionLookup() == null) {\n\t\t\t\tgd.horizontalSpan = 2;\n\t\t\t} else {\n\t\t\t\tButton b = new Button(parent, SWT.PUSH | SWT.FLAT);\n\t\t\t\tb.setText(Messages.ModelTooling_Common_FindEllipsis);\n\t\t\t\tb.addSelectionListener(new SelectionAdapter() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\t\tExpressionIdDialog dialog = new ExpressionIdDialog(t.getShell(), getEditor().getExtensionLookup(), (MCoreExpression) getMaster().getValue(), getEditingDomain(), getEditor().isLiveModel(), Messages);\n\t\t\t\t\t\tdialog.open();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\titem = new CTabItem(folder, SWT.NONE);\n\t\titem.setText(Messages.ModelTooling_Common_TabSupplementary);\n\t\tparent = createScrollableContainer(folder);\n\t\titem.setControl(parent.getParent());\n\t\tControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT);\n\t\tControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT);\n\t\tfolder.setSelection(0);\n\t\treturn folder;\n\t}\n", "output": "\tprivate Composite createForm(Composite parent, EMFDataBindingContext context, WritableValue master) {\n\t\tCTabFolder folder = new CTabFolder(parent, SWT.BOTTOM);\n\t\tCTabItem item = new CTabItem(folder, SWT.NONE);\n\t\titem.setText(Messages.ModelTooling_Common_TabDefault);\n\t\tparent = createScrollableContainer(folder);\n\t\titem.setControl(parent.getParent());\n\t\tif (getEditor().isShowXMIId() || getEditor().isLiveModel()) {\n\t\t\tControlFactory.createXMIId(parent, this);\n\t\t}\n\t\tIWidgetValueProperty textProp = WidgetProperties.text(SWT.Modify);\n\t\t{\n\t\t\tLabel l = new Label(parent, SWT.NONE);\n\t\t\tl.setText(Messages.CoreExpressionEditor_ExpressionId);\n\t\t\tl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));\n\t\t\tfinal Text t = new Text(parent, SWT.BORDER);\n\t\t\tTextPasteHandler.createFor(t);\n\t\t\tGridData gd = new GridData(GridData.FILL_HORIZONTAL);\n\t\t\tt.setLayoutData(gd);\n\t\t\tcontext.bindValue(textProp.observeDelayed(200, t), EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.CORE_EXPRESSION__CORE_EXPRESSION_ID).observeDetail(getMaster()));\n\t\t\tif (getEditor().getExtensionLookup() == null) {\n\t\t\t\tgd.horizontalSpan = 2;\n\t\t\t} else {\n\t\t\t\tButton b = new Button(parent, SWT.PUSH | SWT.FLAT);\n\t\t\t\tb.setText(Messages.ModelTooling_Common_FindEllipsis);\n\t\t\t\tb.setImage(createImage(ResourceProvider.IMG_Obj16_zoom));\n\t\t\t\tb.addSelectionListener(new SelectionAdapter() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\t\tExpressionIdDialog dialog = new ExpressionIdDialog(t.getShell(), getEditor().getExtensionLookup(), (MCoreExpression) getMaster().getValue(), getEditingDomain(), getEditor().isLiveModel(), Messages);\n\t\t\t\t\t\tdialog.open();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\titem = new CTabItem(folder, SWT.NONE);\n\t\titem.setText(Messages.ModelTooling_Common_TabSupplementary);\n\t\tparent = createScrollableContainer(folder);\n\t\titem.setControl(parent.getParent());\n\t\tControlFactory.createStringListWidget(parent, Messages, this, Messages.CategoryEditor_Tags, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__TAGS, VERTICAL_LIST_WIDGET_INDENT);\n\t\tControlFactory.createMapProperties(parent, Messages, this, Messages.ModelTooling_Contribution_PersistedState, ApplicationPackageImpl.Literals.APPLICATION_ELEMENT__PERSISTED_STATE, VERTICAL_LIST_WIDGET_INDENT);\n\t\tfolder.setSelection(0);\n\t\treturn folder;\n\t}\n"} {"input": "\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\ttry {\n\t\t\tWebUtil.init();\n\t\t\tWebClientLog.setLoggingEnabled(DEBUG_HTTPCLIENT);\n\t\t\tinitializePreferences(getPreferenceStore());\n\t\t\tCommonFonts.BOLD.toString();\n\t\t\tFile dataDir = new File(getDataDirectory());\n\t\t\tdataDir.mkdirs();\n\t\t\texternalizationManager = new ExternalizationManager(getDataDirectory());\n\t\t\trepositoryManager = new TaskRepositoryManager();\n\t\t\tIExternalizationParticipant repositoryParticipant = new RepositoryExternalizationParticipant(\n\t\t\t\t\texternalizationManager, repositoryManager);\n\t\t\texternalizationManager.addParticipant(repositoryParticipant);\n\t\t\ttaskList = new TaskList();\n\t\t\trepositoryModel = new RepositoryModel(taskList, repositoryManager);\n\t\t\ttaskListExternalizer = new TaskListExternalizer(repositoryModel, repositoryManager);\n\t\t\tTaskListElementImporter taskListImporter = new TaskListElementImporter(repositoryManager, repositoryModel);\n\t\t\ttaskListSaveParticipant = new TaskListExternalizationParticipant(repositoryModel, taskList,\n\t\t\t\t\ttaskListExternalizer, externalizationManager, repositoryManager);\n\t\t\texternalizationManager.addParticipant(taskListSaveParticipant);\n\t\t\ttaskList.addChangeListener(taskListSaveParticipant);\n\t\t\ttaskActivityManager = new TaskActivityManager(repositoryManager, taskList);\n\t\t\ttaskActivityManager.addActivationListener(taskListSaveParticipant);\n\t\t\ttaskListManager = new TaskListManager(taskList, taskListSaveParticipant, taskListImporter);\n\t\t\tupdateTaskActivityManager();\n\t\t\tproxyServiceReference = context.getServiceReference(IProxyService.class.getName());\n\t\t\tif (proxyServiceReference != null) {\n\t\t\t\tIProxyService proxyService = (IProxyService) context.getService(proxyServiceReference);\n\t\t\t\tif (proxyService != null) {\n\t\t\t\t\tproxyChangeListener = new IProxyChangeListener() {\n\t\t\t\t\t\tpublic void proxyInfoChanged(IProxyChangeEvent event) {\n\t\t\t\t\t\t\tList repos = repositoryManager.getAllRepositories();\n\t\t\t\t\t\t\tfor (TaskRepository repo : repos) {\n\t\t\t\t\t\t\t\tif (repo.isDefaultProxyEnabled()) {\n\t\t\t\t\t\t\t\t\trepositoryManager.notifyRepositorySettingsChanged(repo);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tproxyService.addProxyChangeListener(proxyChangeListener);\n\t\t\t\t}\n\t\t\t}\n\t\t\trepositoryTemplateManager = new RepositoryTemplateManager();\n\t\t\tTasksUiExtensionReader.initStartupExtensions(taskListExternalizer, taskListImporter);\n\t\t\tFile root = new File(this.getDataDirectory() + '/' + FOLDER_OFFLINE);\n\t\t\tOfflineFileStorage storage = new OfflineFileStorage(root);\n\t\t\tOfflineCachingStorage cachedStorage = new OfflineCachingStorage(storage);\n\t\t\ttaskDataStorageManager = new TaskDataStorageManager(repositoryManager, cachedStorage);\n\t\t\ttaskDataStorageManager.start();\n\t\t\tTaskDataStore taskDataStore = new TaskDataStore(repositoryManager);\n\t\t\ttaskDataManager = new TaskDataManager(taskDataStorageManager, taskDataStore, repositoryManager,\n\t\t\t\t\ttaskListManager.getTaskList(), taskActivityManager);\n\t\t\ttaskDataManager.setDataPath(getDataDirectory());\n\t\t\tfor (AbstractRepositoryConnector connector : repositoryManager.getRepositoryConnectors()) {\n\t\t\t\tif (connector instanceof AbstractLegacyRepositoryConnector) {\n\t\t\t\t\t((AbstractLegacyRepositoryConnector) connector).init(taskDataManager);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttaskJobFactory = new TaskJobFactory(taskListManager.getTaskList(), taskDataManager, repositoryManager,\n\t\t\t\t\trepositoryModel);\n\t\t\ttaskActivityManager.addActivationListener(CONTEXT_TASK_ACTIVATION_LISTENER);\n\t\t\ttaskActivityMonitor = new TaskActivityMonitor(taskActivityManager, ContextCorePlugin.getContextManager());\n\t\t\ttaskActivityMonitor.start();\n\t\t\tsaveParticipant = new ISaveParticipant() {\n\t\t\t\tpublic void doneSaving(ISaveContext context) {\n\t\t\t\t}\n\t\t\t\tpublic void prepareToSave(ISaveContext context) throws CoreException {\n\t\t\t\t}\n\t\t\t\tpublic void rollback(ISaveContext context) {\n\t\t\t\t}\n\t\t\t\tpublic void saving(ISaveContext context) throws CoreException {\n\t\t\t\t\tif (context.getKind() == ISaveContext.FULL_SAVE) {\n\t\t\t\t\t\texternalizationManager.stop();\n\t\t\t\t\t\ttaskDataStorageManager.stop();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tResourcesPlugin.getWorkspace().addSaveParticipant(this, saveParticipant);\n\t\t\tActivityExternalizationParticipant ACTIVITY_EXTERNALIZTAION_PARTICIPANT = new ActivityExternalizationParticipant(\n\t\t\t\t\texternalizationManager);\n\t\t\texternalizationManager.addParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);\n\t\t\ttaskActivityManager.addActivityListener(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);\n\t\t\ttaskActivityMonitor.setExternalizationParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);\n\t\t\tloadDataSources();\n\t\t\tnew TasksUiInitializationJob().schedule();\n\t\t} catch (Exception e) {\n\t\t\tStatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, \"Task list initialization failed\", e));\n\t\t}\n\t}\n", "output": "\tpublic void start(BundleContext context) throws Exception {\n\t\tsuper.start(context);\n\t\ttry {\n\t\t\tWebUtil.init();\n\t\t\tWebClientLog.setLoggingEnabled(DEBUG_HTTPCLIENT);\n\t\t\tinitializePreferences(getPreferenceStore());\n\t\t\tif (CommonFonts.BOLD == null) {\n\t\t\t}\n\t\t\tFile dataDir = new File(getDataDirectory());\n\t\t\tdataDir.mkdirs();\n\t\t\texternalizationManager = new ExternalizationManager(getDataDirectory());\n\t\t\trepositoryManager = new TaskRepositoryManager();\n\t\t\tIExternalizationParticipant repositoryParticipant = new RepositoryExternalizationParticipant(\n\t\t\t\t\texternalizationManager, repositoryManager);\n\t\t\texternalizationManager.addParticipant(repositoryParticipant);\n\t\t\ttaskList = new TaskList();\n\t\t\trepositoryModel = new RepositoryModel(taskList, repositoryManager);\n\t\t\ttaskListExternalizer = new TaskListExternalizer(repositoryModel, repositoryManager);\n\t\t\tTaskListElementImporter taskListImporter = new TaskListElementImporter(repositoryManager, repositoryModel);\n\t\t\ttaskListSaveParticipant = new TaskListExternalizationParticipant(repositoryModel, taskList,\n\t\t\t\t\ttaskListExternalizer, externalizationManager, repositoryManager);\n\t\t\texternalizationManager.addParticipant(taskListSaveParticipant);\n\t\t\ttaskList.addChangeListener(taskListSaveParticipant);\n\t\t\ttaskActivityManager = new TaskActivityManager(repositoryManager, taskList);\n\t\t\ttaskActivityManager.addActivationListener(taskListSaveParticipant);\n\t\t\ttaskListManager = new TaskListManager(taskList, taskListSaveParticipant, taskListImporter);\n\t\t\tupdateTaskActivityManager();\n\t\t\tproxyServiceReference = context.getServiceReference(IProxyService.class.getName());\n\t\t\tif (proxyServiceReference != null) {\n\t\t\t\tIProxyService proxyService = (IProxyService) context.getService(proxyServiceReference);\n\t\t\t\tif (proxyService != null) {\n\t\t\t\t\tproxyChangeListener = new IProxyChangeListener() {\n\t\t\t\t\t\tpublic void proxyInfoChanged(IProxyChangeEvent event) {\n\t\t\t\t\t\t\tList repos = repositoryManager.getAllRepositories();\n\t\t\t\t\t\t\tfor (TaskRepository repo : repos) {\n\t\t\t\t\t\t\t\tif (repo.isDefaultProxyEnabled()) {\n\t\t\t\t\t\t\t\t\trepositoryManager.notifyRepositorySettingsChanged(repo);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tproxyService.addProxyChangeListener(proxyChangeListener);\n\t\t\t\t}\n\t\t\t}\n\t\t\trepositoryTemplateManager = new RepositoryTemplateManager();\n\t\t\tTasksUiExtensionReader.initStartupExtensions(taskListExternalizer, taskListImporter);\n\t\t\tFile root = new File(this.getDataDirectory() + '/' + FOLDER_OFFLINE);\n\t\t\tOfflineFileStorage storage = new OfflineFileStorage(root);\n\t\t\tOfflineCachingStorage cachedStorage = new OfflineCachingStorage(storage);\n\t\t\ttaskDataStorageManager = new TaskDataStorageManager(repositoryManager, cachedStorage);\n\t\t\ttaskDataStorageManager.start();\n\t\t\tTaskDataStore taskDataStore = new TaskDataStore(repositoryManager);\n\t\t\ttaskDataManager = new TaskDataManager(taskDataStorageManager, taskDataStore, repositoryManager,\n\t\t\t\t\ttaskListManager.getTaskList(), taskActivityManager);\n\t\t\ttaskDataManager.setDataPath(getDataDirectory());\n\t\t\tfor (AbstractRepositoryConnector connector : repositoryManager.getRepositoryConnectors()) {\n\t\t\t\tif (connector instanceof AbstractLegacyRepositoryConnector) {\n\t\t\t\t\t((AbstractLegacyRepositoryConnector) connector).init(taskDataManager);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttaskJobFactory = new TaskJobFactory(taskListManager.getTaskList(), taskDataManager, repositoryManager,\n\t\t\t\t\trepositoryModel);\n\t\t\ttaskActivityManager.addActivationListener(CONTEXT_TASK_ACTIVATION_LISTENER);\n\t\t\ttaskActivityMonitor = new TaskActivityMonitor(taskActivityManager, ContextCorePlugin.getContextManager());\n\t\t\ttaskActivityMonitor.start();\n\t\t\tsaveParticipant = new ISaveParticipant() {\n\t\t\t\tpublic void doneSaving(ISaveContext context) {\n\t\t\t\t}\n\t\t\t\tpublic void prepareToSave(ISaveContext context) throws CoreException {\n\t\t\t\t}\n\t\t\t\tpublic void rollback(ISaveContext context) {\n\t\t\t\t}\n\t\t\t\tpublic void saving(ISaveContext context) throws CoreException {\n\t\t\t\t\tif (context.getKind() == ISaveContext.FULL_SAVE) {\n\t\t\t\t\t\texternalizationManager.stop();\n\t\t\t\t\t\ttaskDataStorageManager.stop();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tResourcesPlugin.getWorkspace().addSaveParticipant(this, saveParticipant);\n\t\t\tActivityExternalizationParticipant ACTIVITY_EXTERNALIZTAION_PARTICIPANT = new ActivityExternalizationParticipant(\n\t\t\t\t\texternalizationManager);\n\t\t\texternalizationManager.addParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);\n\t\t\ttaskActivityManager.addActivityListener(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);\n\t\t\ttaskActivityMonitor.setExternalizationParticipant(ACTIVITY_EXTERNALIZTAION_PARTICIPANT);\n\t\t\tloadDataSources();\n\t\t\tnew TasksUiInitializationJob().schedule();\n\t\t} catch (Exception e) {\n\t\t\tStatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, \"Task list initialization failed\", e));\n\t\t}\n\t}\n"} {"input": " public static void main(String[] args) {\n\tif (args.length != 1) {\n\t System.err.println(\"need filename argument\");\n\t System.exit(1);\n\t}\n\ttry {\n\t JEditorPane editor = new JEditorPane();\n\t JavaEditorKit kit = new JavaEditorKit();\n\t editor.setEditorKitForContentType(\"text/java\", kit);\n\t editor.setContentType(\"text/java\");\n\t editor.setBackground(Color.white);\n\t editor.setFont(new Font(\"Courier\", 0, 12));\n\t editor.setEditable(true);\n\t JavaContext styles = kit.getStylePreferences();\n\t Style s;\n\t s = styles.getStyleForScanValue(Token.COMMENT.getScanValue());\n\t StyleConstants.setForeground(s, new Color(102, 153, 153));\n\t s = styles.getStyleForScanValue(Token.STRINGVAL.getScanValue());\n\t StyleConstants.setForeground(s, new Color(102, 153, 102));\n\t Color keyword = new Color(102, 102, 255);\n\t for (int code = 70; code <= 130; code++) {\n\t\ts = styles.getStyleForScanValue(code);\n\t\tif (s != null) {\n\t\t StyleConstants.setForeground(s, keyword);\n\t\t}\n\t }\n File file = new File(args[0]);\n editor.read(new FileReader(file), file);\n JScrollPane scroller = new JScrollPane();\n JViewport vp = scroller.getViewport();\n vp.setBackingStoreEnabled(true);\n vp.add(editor);\n\t JFrame f = new JFrame(\"JavaEditorKit: \" + args[0]);\n\t f.getContentPane().setLayout(new BorderLayout());\n\t f.getContentPane().add(\"Center\", scroller);\n\t f.pack();\n\t f.setSize(600, 600);\n\t f.setVisible(true);\n\t} catch (Throwable e) {\n\t e.printStackTrace();\n\t System.exit(1);\n\t}\n }\n", "output": " public static void main(String[] args) {\n\tif (args.length != 1) {\n\t System.err.println(\"need filename argument\"); \n\t System.exit(1);\n\t}\n\ttry {\n\t JEditorPane editor = new JEditorPane();\n\t JavaEditorKit kit = new JavaEditorKit();\n\t editor.setEditorKitForContentType(\"text/java\", kit); \n\t editor.setContentType(\"text/java\"); \n\t editor.setBackground(Color.white);\n\t editor.setFont(new Font(\"Courier\", 0, 12)); \n\t editor.setEditable(true);\n\t JavaContext styles = kit.getStylePreferences();\n\t Style s;\n\t s = styles.getStyleForScanValue(Token.COMMENT.getScanValue());\n\t StyleConstants.setForeground(s, new Color(102, 153, 153));\n\t s = styles.getStyleForScanValue(Token.STRINGVAL.getScanValue());\n\t StyleConstants.setForeground(s, new Color(102, 153, 102));\n\t Color keyword = new Color(102, 102, 255);\n\t for (int code = 70; code <= 130; code++) {\n\t\ts = styles.getStyleForScanValue(code);\n\t\tif (s != null) {\n\t\t StyleConstants.setForeground(s, keyword);\n\t\t}\n\t }\n File file = new File(args[0]);\n editor.read(new FileReader(file), file);\n JScrollPane scroller = new JScrollPane();\n JViewport vp = scroller.getViewport();\n vp.setBackingStoreEnabled(true);\n vp.add(editor);\n\t JFrame f = new JFrame(org.openide.util.NbBundle.getMessage(JavaKitTest.class, \"JavaKitTest.main(String[]).f.title\", args[0])); \n\t f.getContentPane().setLayout(new BorderLayout());\n\t f.getContentPane().add(\"Center\", scroller); \n\t f.pack();\n\t f.setSize(600, 600);\n\t f.setVisible(true);\n\t} catch (Throwable e) {\n\t e.printStackTrace();\n\t System.exit(1);\n\t}\n }\n"} {"input": " public void onPlayerInteract(PlayerInteractEvent event) {\n if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK) {\n return;\n }\n if (event.getPlayer().getItemInHand().getType().equals(Material.BONE)) {\n if (!UtilPermissions.playerCanUseCommand(event.getPlayer(), \"castaway.admin\")) {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"You are not allowed to do this!\");\n event.setCancelled(true);\n return;\n }\n event.setCancelled(true);\n event.setUseInteractedBlock(Event.Result.DENY);\n event.setUseItemInHand(Event.Result.DENY);\n Player player = event.getPlayer();\n boolean isLeftClick = (event.getAction() == Action.LEFT_CLICK_BLOCK);\n if (player.isSneaking()) {\n Dungeon dungeon = CastAwayCore.gameManager.getDungeonByName(\"test\");\n if (dungeon != null) {\n if (isLeftClick && event.getClickedBlock().getType().equals(Material.STONE_PLATE)) {\n AbstractBlock actionBlock = new DungeonStartBlock(new BlockVector(event.getClickedBlock()), dungeon);\n if (CastAwayCore.databaseManager.addActionBlock(actionBlock)) {\n CastAwayCore.databaseManager.addActionBlock(actionBlock);\n CastAwayCore.gameManager.addBlock(actionBlock.getVector(), actionBlock);\n PlayerUtils.sendSuccess(event.getPlayer(), CastAwayCore.NAME, \"Start block added for '\" + dungeon.getDungeonName() + \"'.\");\n } else {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"Error creating block in database!\");\n }\n } else if (!isLeftClick && event.getClickedBlock().getType().equals(Material.STONE_BUTTON)) {\n AbstractBlock actionBlock = new DungeonEndBlock(new BlockVector(event.getClickedBlock()), dungeon);\n if (CastAwayCore.databaseManager.addActionBlock(actionBlock)) {\n CastAwayCore.gameManager.addBlock(actionBlock.getVector(), actionBlock);\n PlayerUtils.sendSuccess(event.getPlayer(), CastAwayCore.NAME, \"End block added for '\" + dungeon.getDungeonName() + \"'.\");\n } else {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"Error creating block in database!\");\n }\n }\n }\n } else {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"Dungeon 'test' not found!\");\n }\n }\n }\n", "output": " public void onPlayerInteract(PlayerInteractEvent event) {\n if (event.getAction() != Action.LEFT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_BLOCK) {\n return;\n }\n if (event.getPlayer().getItemInHand().getType().equals(Material.BONE)) {\n if (!UtilPermissions.playerCanUseCommand(event.getPlayer(), \"castaway.admin\")) {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"You are not allowed to do this!\");\n event.setCancelled(true);\n return;\n }\n event.setCancelled(true);\n event.setUseInteractedBlock(Event.Result.DENY);\n event.setUseItemInHand(Event.Result.DENY);\n Player player = event.getPlayer();\n boolean isLeftClick = (event.getAction() == Action.LEFT_CLICK_BLOCK);\n if (player.isSneaking()) {\n Dungeon dungeon = CastAwayCore.gameManager.getDungeonByName(\"test\");\n if (dungeon != null) {\n if (isLeftClick && event.getClickedBlock().getType().equals(Material.STONE_PLATE)) {\n AbstractBlock actionBlock = new DungeonStartBlock(new BlockVector(event.getClickedBlock()), dungeon);\n if (CastAwayCore.databaseManager.addActionBlock(actionBlock)) {\n CastAwayCore.databaseManager.addActionBlock(actionBlock);\n CastAwayCore.gameManager.addBlock(actionBlock.getVector(), actionBlock);\n PlayerUtils.sendSuccess(event.getPlayer(), CastAwayCore.NAME, \"Start block added for '\" + dungeon.getDungeonName() + \"'.\");\n } else {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"Error creating block in database!\");\n }\n } else if (!isLeftClick && event.getClickedBlock().getType().equals(Material.STONE_BUTTON)) {\n AbstractBlock actionBlock = new DungeonEndBlock(new BlockVector(event.getClickedBlock()), dungeon);\n if (CastAwayCore.databaseManager.addActionBlock(actionBlock)) {\n CastAwayCore.gameManager.addBlock(actionBlock.getVector(), actionBlock);\n PlayerUtils.sendSuccess(event.getPlayer(), CastAwayCore.NAME, \"End block added for '\" + dungeon.getDungeonName() + \"'.\");\n } else {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"Error creating block in database!\");\n }\n }\n } else {\n PlayerUtils.sendError(event.getPlayer(), CastAwayCore.NAME, \"Dungeon 'test' not found!\");\n }\n }\n }\n }\n"} {"input": " public Object ac_rep_ls_$_0_99(final Args args) throws Exception\n {\n if (args.argc() > 0) {\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < args.argc(); i++) {\n PnfsId pnfsid = new PnfsId(args.argv(i));\n sb.append(_repository.getEntry(pnfsid));\n sb.append(\"\\n\");\n }\n return sb.toString();\n }\n final DelayedReply reply = new DelayedReply();\n Thread task = new Thread() {\n void reply(Object o)\n throws InterruptedException\n {\n try {\n reply.send(o);\n } catch (NoRouteToCellException e) {\n _log.error(\"Failed to send reply for 'rep ls': \" + e);\n }\n }\n public void run()\n {\n try {\n try {\n reply(list());\n } catch (CacheException e) {\n reply(e);\n } catch (RuntimeException e) {\n reply(e);\n }\n } catch (InterruptedException e) {\n _log.warn(\"Interrupted while listing: \" + e);\n }\n }\n private Object list()\n throws CacheException, InterruptedException\n {\n StringBuilder sb = new StringBuilder();\n String stat = args.getOpt(\"s\");\n if (stat != null) {\n long dev = 1;\n dev = (stat.indexOf(\"k\") > -1) ||\n (stat.indexOf(\"K\") > -1) ? 1024L : dev;\n dev = (stat.indexOf(\"m\") > -1) ||\n (stat.indexOf(\"M\") > -1) ? (1024L*1024L) : dev;\n dev = (stat.indexOf(\"g\") > -1) ||\n (stat.indexOf(\"G\") > -1) ? (1024L*1024L*1024L) : dev;\n dev = (stat.indexOf(\"t\") > -1) ||\n (stat.indexOf(\"T\") > -1) ? (1024L*1024L*1024L*1024L) : dev;\n Map map = new HashMap();\n long removable = 0L;\n for (PnfsId id: _repository) {\n try {\n CacheEntry entry = _repository.getEntry(id);\n StorageInfo info = entry.getStorageInfo();\n if (info == null) continue;\n String sc = info.getStorageClass()\n + \"@\" + info.getHsm();\n long[] counter = map.get(sc);\n if (counter == null)\n map.put(sc, counter = new long[8]);\n boolean sticky = entry.isSticky();\n boolean precious =\n (entry.getState() == EntryState.PRECIOUS);\n long entrySize = entry.getReplicaSize();\n counter[0] += entrySize;\n counter[1]++;\n if (precious) {\n counter[2] += entrySize;\n counter[3]++;\n }\n if (sticky) {\n counter[4] += entrySize;\n counter[5]++;\n }\n if (!precious && !sticky) {\n counter[6] += entrySize;\n removable += entrySize;\n counter[7]++;\n }\n } catch (FileNotInCacheException e) {\n }\n }\n if (args.getOpt(\"sum\") != null) {\n long[] counter = new long[10];\n map.put(\"total\", counter);\n SpaceRecord record = _repository.getSpaceRecord();\n counter[0] = record.getTotalSpace();\n counter[1] = record.getFreeSpace();\n counter[2] = removable;\n }\n Iterator e2 = map.keySet().iterator();\n if (args.getOpt(\"binary\") != null) {\n Object [] result = new Object[map.size()];\n for (int i = 0; e2.hasNext(); i++) {\n Object[] ex = new Object[2];\n ex[0] = e2.next();\n ex[1] = map.get(ex[0]);\n result[i] = ex;\n }\n return result;\n }\n while (e2.hasNext()) {\n String sc = e2.next();\n long[] counter = map.get(sc);\n sb.append(Formats.field(sc,24,Formats.LEFT)).\n append(\" \").\n append(Formats.field(\"\"+counter[0]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[1],8,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[2]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[3],8,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[4]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[5],8,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[6]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[7],8,Formats.RIGHT)).\n append(\"\\n\");\n }\n } else {\n String format = args.getOpt(\"l\");\n format = format == null ? \"\" : format;\n boolean notcached = format.indexOf(\"nc\") > -1;\n boolean precious = format.indexOf('p') > -1;\n boolean locked = format.indexOf('l') > -1;\n boolean sticky = format.indexOf('s') > -1;\n boolean used = format.indexOf('u') > -1;\n boolean broken = format.indexOf('e') > -1;\n for (PnfsId id: _repository) {\n try {\n CacheEntry entry = _repository.getEntry(id);\n EntryState state = entry.getState();\n if (format.length() == 0 ||\n (notcached && state != EntryState.CACHED) ||\n (precious && state == EntryState.PRECIOUS) ||\n (sticky && entry.isSticky()) ||\n (broken && state == EntryState.BROKEN) ||\n (used && entry.getLinkCount() > 0)) {\n sb.append(entry).append('\\n');\n }\n } catch (FileNotInCacheException e) {\n }\n }\n }\n return sb.toString();\n }\n };\n task.start();\n return reply;\n }\n", "output": " public Object ac_rep_ls_$_0_99(final Args args) throws Exception\n {\n if (args.argc() > 0) {\n StringBuilder sb = new StringBuilder();\n for (int i = 0; i < args.argc(); i++) {\n PnfsId pnfsid = new PnfsId(args.argv(i));\n sb.append(_repository.getEntry(pnfsid));\n sb.append(\"\\n\");\n }\n return sb.toString();\n }\n final DelayedReply reply = new DelayedReply();\n Thread task = new Thread() {\n void reply(Object o)\n throws InterruptedException\n {\n try {\n reply.send(o);\n } catch (NoRouteToCellException e) {\n _log.error(\"Failed to send reply for 'rep ls': \" + e);\n }\n }\n public void run()\n {\n try {\n try {\n reply(list());\n } catch (CacheException e) {\n reply(e);\n } catch (RuntimeException e) {\n reply(e);\n }\n } catch (InterruptedException e) {\n _log.warn(\"Interrupted while listing: \" + e);\n }\n }\n private Object list()\n throws CacheException, InterruptedException\n {\n StringBuilder sb = new StringBuilder();\n String stat = args.getOpt(\"s\");\n if (stat != null) {\n long dev = 1;\n dev = (stat.indexOf(\"k\") > -1) ||\n (stat.indexOf(\"K\") > -1) ? 1024L : dev;\n dev = (stat.indexOf(\"m\") > -1) ||\n (stat.indexOf(\"M\") > -1) ? (1024L*1024L) : dev;\n dev = (stat.indexOf(\"g\") > -1) ||\n (stat.indexOf(\"G\") > -1) ? (1024L*1024L*1024L) : dev;\n dev = (stat.indexOf(\"t\") > -1) ||\n (stat.indexOf(\"T\") > -1) ? (1024L*1024L*1024L*1024L) : dev;\n Map map = new HashMap();\n long removable = 0L;\n for (PnfsId id: _repository) {\n try {\n CacheEntry entry = _repository.getEntry(id);\n StorageInfo info = entry.getStorageInfo();\n if (info == null) continue;\n String sc = info.getStorageClass()\n + \"@\" + info.getHsm();\n long[] counter = map.get(sc);\n if (counter == null)\n map.put(sc, counter = new long[8]);\n boolean sticky = entry.isSticky();\n boolean precious =\n (entry.getState() == EntryState.PRECIOUS);\n long entrySize = entry.getReplicaSize();\n counter[0] += entrySize;\n counter[1]++;\n if (precious) {\n counter[2] += entrySize;\n counter[3]++;\n }\n if (sticky) {\n counter[4] += entrySize;\n counter[5]++;\n }\n if (!precious && !sticky) {\n counter[6] += entrySize;\n removable += entrySize;\n counter[7]++;\n }\n } catch (FileNotInCacheException e) {\n }\n }\n if (args.getOpt(\"sum\") != null) {\n long[] counter = new long[10];\n map.put(\"total\", counter);\n SpaceRecord record = _repository.getSpaceRecord();\n counter[0] = record.getTotalSpace();\n counter[1] = record.getFreeSpace();\n counter[2] = removable;\n }\n Iterator e2 = map.keySet().iterator();\n if (args.getOpt(\"binary\") != null) {\n Object [] result = new Object[map.size()];\n for (int i = 0; e2.hasNext(); i++) {\n Object[] ex = new Object[2];\n ex[0] = e2.next();\n ex[1] = map.get(ex[0]);\n result[i] = ex;\n }\n return result;\n }\n while (e2.hasNext()) {\n String sc = e2.next();\n long[] counter = map.get(sc);\n sb.append(Formats.field(sc,24,Formats.LEFT)).\n append(\" \").\n append(Formats.field(\"\"+counter[0]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[1],8,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[2]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[3],8,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[4]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[5],8,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[6]/dev,10,Formats.RIGHT)).\n append(\" \").\n append(Formats.field(\"\"+counter[7],8,Formats.RIGHT)).\n append(\"\\n\");\n }\n } else {\n String format = args.getOpt(\"l\");\n format = format == null ? \"\" : format;\n boolean notcached = format.indexOf(\"nc\") > -1;\n boolean precious = format.indexOf('p') > -1;\n boolean locked = format.indexOf('l') > -1;\n boolean sticky = format.indexOf('s') > -1;\n boolean used = format.indexOf('u') > -1;\n boolean broken = format.indexOf('e') > -1;\n boolean cached = format.indexOf('c') > -1;\n for (PnfsId id: _repository) {\n try {\n CacheEntry entry = _repository.getEntry(id);\n EntryState state = entry.getState();\n if (format.length() == 0 ||\n (notcached && state != EntryState.CACHED) ||\n (precious && state == EntryState.PRECIOUS) ||\n (sticky && entry.isSticky()) ||\n (broken && state == EntryState.BROKEN) ||\n (cached && state == EntryState.CACHED) ||\n (used && entry.getLinkCount() > 0)) {\n sb.append(entry).append('\\n');\n }\n } catch (FileNotInCacheException e) {\n }\n }\n }\n return sb.toString();\n }\n };\n task.start();\n return reply;\n }\n"} {"input": " public boolean wearingSet(final LivingEntity entity)\n {\n ItemStack his = entity.getEquipment().getHelmet();\n ItemStack cis = entity.getEquipment().getChestplate();\n ItemStack lis = entity.getEquipment().getLeggings();\n ItemStack bis = entity.getEquipment().getBoots();\n if ((his == null) || (cis == null) || (lis == null) || (bis == null))\n return false;\n Set sis = new HashSet();\n sis.add(cis);\n sis.add(lis);\n sis.add(bis);\n ItemMeta meta = his.getItemMeta();\n String[] ss = ChatColor.stripColor(meta.getDisplayName()).split(\" \");\n String potentialSet = ss[0];\n for (ItemStack is : sis)\n {\n ItemMeta ism = is.getItemMeta();\n String[] splits = ChatColor.stripColor(ism.getDisplayName()).split(\" \");\n if (!splits[0].equalsIgnoreCase(potentialSet))\n return false;\n }\n return true;\n }\n", "output": " public boolean wearingSet(final LivingEntity entity)\n {\n ItemStack his = entity.getEquipment().getHelmet();\n ItemStack cis = entity.getEquipment().getChestplate();\n ItemStack lis = entity.getEquipment().getLeggings();\n ItemStack bis = entity.getEquipment().getBoots();\n if ((his == null) || (cis == null) || (lis == null) || (bis == null))\n return false;\n Set sis = new HashSet();\n sis.add(cis);\n sis.add(lis);\n sis.add(bis);\n ItemMeta meta = his.getItemMeta();\n String[] ss = ChatColor.stripColor(meta.getDisplayName()).split(\" \");\n String potentialSet = ss[0];\n for (ItemStack is : sis)\n {\n ItemMeta ism = is.getItemMeta();\n if(ism.getDisplayName()!=null){\n \tString[] splits = ChatColor.stripColor(ism.getDisplayName()).split(\" \");\n \tif (!splits[0].equalsIgnoreCase(potentialSet))\n \t\treturn false;\n }\n }\n return true;\n }\n"} {"input": " public void run() {\n Vector currentInvokeItems;\n synchronized(invokeLock) {\n currentInvokeItems = invokeItems;\n invokeItems = new Vector();\n }\n int size = currentInvokeItems.size();\n for(int i=0; i= 19) {\n\t\t\t\t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\t\t\t\t\t\t\tsetAdditionalInstanceField(window, PROP_FULLSCREEN, Boolean.TRUE);\n\t\t\t\t\t\t\tView decorView = window.getDecorView();\n\t\t\t\t\t\t\tdecorView.setSystemUiVisibility(\n\t\t\t\t\t\t\t\t\tView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION\n\t\t\t\t\t\t\t\t\t| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION\n\t\t\t\t\t\t\t\t\t| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (XposedMod.prefs.getBoolean(packageName + Common.PREF_NO_TITLE, false))\n\t\t\t\t\t\twindow.requestFeature(Window.FEATURE_NO_TITLE);\n\t\t\t\t\tif (XposedMod.prefs.getBoolean(packageName + Common.PREF_ALLOW_ON_LOCKSCREEN, false))\n\t\t \t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |\n\t\t \t\t\t\t WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |\n\t\t \t\t\t\t WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);\n\t\t\t\t\tif (XposedMod.prefs.getBoolean(packageName + Common.PREF_SCREEN_ON, false)) {\n\t\t\t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);\n\t\t\t\t\t\tsetAdditionalInstanceField(window, PROP_KEEP_SCREEN_ON, Boolean.TRUE);\n\t\t\t\t\t}\n\t\t\t\t\tint orientation = XposedMod.prefs.getInt(packageName + Common.PREF_ORIENTATION, XposedMod.prefs.getInt(Common.PREF_DEFAULT + Common.PREF_ORIENTATION, 0));\n\t\t\t\t\tif (orientation > 0 && orientation < Common.orientationCodes.length && context instanceof Activity) {\n\t\t\t\t\t\t((Activity) context).setRequestedOrientation(Common.orientationCodes[orientation]);\n\t\t\t\t\t\tsetAdditionalInstanceField(context, PROP_ORIENTATION, orientation);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Throwable e) {\n\t\t\tXposedBridge.log(e);\n\t\t}\n\t\ttry {\n\t\t\tfindAndHookMethod(Window.class, \"setFlags\", int.class, int.class,\n\t\t\t\t\tnew XC_MethodHook() {\n\t\t\t\t@Override\n\t\t\t\tprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {\n\t\t\t\t\tint flags = (Integer) param.args[0];\n\t\t\t\t\tint mask = (Integer) param.args[1];\n\t\t\t\t\tif ((mask & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) {\n\t\t\t\t\t\tBoolean fullscreen = (Boolean) getAdditionalInstanceField(param.thisObject, PROP_FULLSCREEN);\n\t\t\t\t\t\tif (fullscreen != null) {\n\t\t\t\t\t\t\tif (fullscreen.booleanValue()) {\n\t\t\t\t\t\t\t\tflags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tflags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparam.args[0] = flags;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ((mask & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0) {\n\t\t\t\t\t\tBoolean keepScreenOn = (Boolean) getAdditionalInstanceField(param.thisObject, PROP_KEEP_SCREEN_ON);\n\t\t\t\t\t\tif (keepScreenOn != null) {\n\t\t\t\t\t\t\tif (keepScreenOn.booleanValue()) {\n\t\t\t\t\t\t\t\tflags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparam.args[0] = flags;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Throwable e) {\n\t\t\tXposedBridge.log(e);\n\t\t}\n\t\ttry {\n\t\t\tfindAndHookMethod(Activity.class, \"setRequestedOrientation\", int.class, new XC_MethodHook() {\n\t\t\t\t@Override\n\t\t\t\tprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {\n\t\t\t\t\tInteger orientation = (Integer) getAdditionalInstanceField(param.thisObject, PROP_ORIENTATION);\n\t\t\t\t\tif (orientation != null)\n\t\t\t\t\t\tparam.args[0] = orientation;\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Throwable e) {\n\t\t\tXposedBridge.log(e);\n\t\t}\n\t\ttry {\n\t\t\tMethod mthRealStartActivityLocked;\n\t\t\tif (Build.VERSION.SDK_INT <= 18) {\n\t\t\t\ttry {\n\t\t\t\t\tmthRealStartActivityLocked = findMethodExact(\"com.android.server.am.ActivityStack\", null, \"realStartActivityLocked\",\n\t\t\t\t\t\t\t\"com.android.server.am.ActivityRecord\", \"com.android.server.am.ProcessRecord\",\n\t\t\t\t\t\t\tboolean.class, boolean.class, boolean.class);\n\t\t\t\t} catch (NoSuchMethodError t) {\n\t\t\t\t\tmthRealStartActivityLocked = findMethodExact(\"com.android.server.am.ActivityStack\", null, \"realStartActivityLocked\",\n\t\t\t\t\t\t\t\"com.android.server.am.ActivityRecord\", \"com.android.server.am.ProcessRecord\",\n\t\t\t\t\t\t\tboolean.class, boolean.class);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmthRealStartActivityLocked = findMethodExact(\"com.android.server.am.ActivityStackSupervisor\", null, \"realStartActivityLocked\",\n\t\t\t\t\t\t\"com.android.server.am.ActivityRecord\", \"com.android.server.am.ProcessRecord\",\n\t\t\t\t\t\tboolean.class, boolean.class);\n\t\t\t}\n\t\t\thookMethod(mthRealStartActivityLocked, new XC_MethodHook() {\n\t \t\t@Override\n\t \t\tprotected void afterHookedMethod(MethodHookParam param) throws Throwable {\n\t \t\t\tString pkgName = (String) getObjectField(param.args[0], \"packageName\");\n\t \t\t\tif (!XposedMod.isActive(pkgName, Common.PREF_RESIDENT))\n\t \t\t\t\treturn;\n\t\t\t\t\tint adj = -12;\n\t\t\t\t\tObject proc = getObjectField(param.args[0], \"app\");\n\t\t\t\t\tif (proc != null) {\n\t\t\t\t\t\tsetIntField(proc, \"maxAdj\", adj);\n\t\t\t\t\t\tif (Build.VERSION.SDK_INT <= 18)\n\t\t\t\t\t\t\tsetIntField(proc, \"hiddenAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"curRawAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"setRawAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"curAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"setAdj\", adj);\n\t\t\t\t\t}\n\t \t\t}\n\t \t});\n\t } catch (Throwable e) {\n\t XposedBridge.log(e);\n\t }\n }\n", "output": "\tpublic static void hookActivitySettings() {\n\t\ttry {\n\t\t\tfindAndHookMethod(\"com.android.internal.policy.impl.PhoneWindow\", null, \"generateLayout\",\n\t\t\t\t\t\"com.android.internal.policy.impl.PhoneWindow.DecorView\", new XC_MethodHook() {\n\t\t\t\t@SuppressLint(\"InlinedApi\")\n\t\t\t\tprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {\n\t\t\t\t\tWindow window = (Window) param.thisObject;\n\t\t\t\t\tContext context = window.getContext();\n\t\t\t\t\tString packageName = context.getPackageName();\n\t\t\t\t\tif (!XposedMod.isActive(packageName))\n\t\t\t\t\t\treturn;\n\t\t\t\t\tint fullscreen;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tfullscreen = XposedMod.prefs.getInt(packageName + Common.PREF_FULLSCREEN,\n\t\t\t\t\t\t\t\tCommon.FULLSCREEN_DEFAULT);\n\t\t\t\t\t} catch (ClassCastException ex) {\n\t\t\t\t\t\tfullscreen = XposedMod.prefs.getBoolean(packageName + Common.PREF_FULLSCREEN, false)\n\t\t\t\t\t\t\t\t? Common.FULLSCREEN_FORCE : Common.FULLSCREEN_DEFAULT;\n\t\t\t\t\t}\n\t\t\t\t\tif (fullscreen == Common.FULLSCREEN_FORCE) {\n\t\t\t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\t\t\t\t\t\tsetAdditionalInstanceField(window, PROP_FULLSCREEN, Boolean.TRUE);\n\t\t\t\t\t} else if (fullscreen == Common.FULLSCREEN_PREVENT) {\n\t\t\t\t\t\twindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\t\t\t\t\t\tsetAdditionalInstanceField(window, PROP_FULLSCREEN, Boolean.FALSE);\n\t\t\t\t\t} else if (fullscreen == Common.FULLSCREEN_IMMERSIVE) {\n\t\t\t\t\t\tif (Build.VERSION.SDK_INT >= 19) {\n\t\t\t\t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);\n\t\t\t\t\t\t\tsetAdditionalInstanceField(window, PROP_FULLSCREEN, Boolean.TRUE);\n\t\t\t\t\t\t\tView decorView = window.getDecorView();\n\t\t\t\t\t\t\tdecorView.setSystemUiVisibility(\n\t\t\t\t\t\t\t\t\tView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION\n\t\t\t\t\t\t\t\t\t| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION\n\t\t\t\t\t\t\t\t\t| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (XposedMod.prefs.getBoolean(packageName + Common.PREF_NO_TITLE, false))\n\t\t\t\t\t\twindow.requestFeature(Window.FEATURE_NO_TITLE);\n\t\t\t\t\tif (XposedMod.prefs.getBoolean(packageName + Common.PREF_ALLOW_ON_LOCKSCREEN, false))\n\t\t \t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |\n\t\t \t\t\t\t WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |\n\t\t \t\t\t\t WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);\n\t\t\t\t\tif (XposedMod.prefs.getBoolean(packageName + Common.PREF_SCREEN_ON, false)) {\n\t\t\t\t\t\twindow.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);\n\t\t\t\t\t\tsetAdditionalInstanceField(window, PROP_KEEP_SCREEN_ON, Boolean.TRUE);\n\t\t\t\t\t}\n\t\t\t\t\tint orientation = XposedMod.prefs.getInt(packageName + Common.PREF_ORIENTATION, XposedMod.prefs.getInt(Common.PREF_DEFAULT + Common.PREF_ORIENTATION, 0));\n\t\t\t\t\tif (orientation > 0 && orientation < Common.orientationCodes.length && context instanceof Activity) {\n\t\t\t\t\t\t((Activity) context).setRequestedOrientation(Common.orientationCodes[orientation]);\n\t\t\t\t\t\tsetAdditionalInstanceField(context, PROP_ORIENTATION, orientation);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Throwable e) {\n\t\t\tXposedBridge.log(e);\n\t\t}\n\t\ttry {\n\t\t\tfindAndHookMethod(Window.class, \"setFlags\", int.class, int.class,\n\t\t\t\t\tnew XC_MethodHook() {\n\t\t\t\t@Override\n\t\t\t\tprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {\n\t\t\t\t\tint flags = (Integer) param.args[0];\n\t\t\t\t\tint mask = (Integer) param.args[1];\n\t\t\t\t\tif ((mask & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) {\n\t\t\t\t\t\tBoolean fullscreen = (Boolean) getAdditionalInstanceField(param.thisObject, PROP_FULLSCREEN);\n\t\t\t\t\t\tif (fullscreen != null) {\n\t\t\t\t\t\t\tif (fullscreen.booleanValue()) {\n\t\t\t\t\t\t\t\tflags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tflags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparam.args[0] = flags;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ((mask & WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) != 0) {\n\t\t\t\t\t\tBoolean keepScreenOn = (Boolean) getAdditionalInstanceField(param.thisObject, PROP_KEEP_SCREEN_ON);\n\t\t\t\t\t\tif (keepScreenOn != null) {\n\t\t\t\t\t\t\tif (keepScreenOn.booleanValue()) {\n\t\t\t\t\t\t\t\tflags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparam.args[0] = flags;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Throwable e) {\n\t\t\tXposedBridge.log(e);\n\t\t}\n\t\ttry {\n\t\t\tfindAndHookMethod(Activity.class, \"setRequestedOrientation\", int.class, new XC_MethodHook() {\n\t\t\t\t@Override\n\t\t\t\tprotected void beforeHookedMethod(MethodHookParam param) throws Throwable {\n\t\t\t\t\tInteger orientation = (Integer) getAdditionalInstanceField(param.thisObject, PROP_ORIENTATION);\n\t\t\t\t\tif (orientation != null)\n\t\t\t\t\t\tparam.args[0] = Common.orientationCodes[orientation];\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (Throwable e) {\n\t\t\tXposedBridge.log(e);\n\t\t}\n\t\ttry {\n\t\t\tMethod mthRealStartActivityLocked;\n\t\t\tif (Build.VERSION.SDK_INT <= 18) {\n\t\t\t\ttry {\n\t\t\t\t\tmthRealStartActivityLocked = findMethodExact(\"com.android.server.am.ActivityStack\", null, \"realStartActivityLocked\",\n\t\t\t\t\t\t\t\"com.android.server.am.ActivityRecord\", \"com.android.server.am.ProcessRecord\",\n\t\t\t\t\t\t\tboolean.class, boolean.class, boolean.class);\n\t\t\t\t} catch (NoSuchMethodError t) {\n\t\t\t\t\tmthRealStartActivityLocked = findMethodExact(\"com.android.server.am.ActivityStack\", null, \"realStartActivityLocked\",\n\t\t\t\t\t\t\t\"com.android.server.am.ActivityRecord\", \"com.android.server.am.ProcessRecord\",\n\t\t\t\t\t\t\tboolean.class, boolean.class);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmthRealStartActivityLocked = findMethodExact(\"com.android.server.am.ActivityStackSupervisor\", null, \"realStartActivityLocked\",\n\t\t\t\t\t\t\"com.android.server.am.ActivityRecord\", \"com.android.server.am.ProcessRecord\",\n\t\t\t\t\t\tboolean.class, boolean.class);\n\t\t\t}\n\t\t\thookMethod(mthRealStartActivityLocked, new XC_MethodHook() {\n\t \t\t@Override\n\t \t\tprotected void afterHookedMethod(MethodHookParam param) throws Throwable {\n\t \t\t\tString pkgName = (String) getObjectField(param.args[0], \"packageName\");\n\t \t\t\tif (!XposedMod.isActive(pkgName, Common.PREF_RESIDENT))\n\t \t\t\t\treturn;\n\t\t\t\t\tint adj = -12;\n\t\t\t\t\tObject proc = getObjectField(param.args[0], \"app\");\n\t\t\t\t\tif (proc != null) {\n\t\t\t\t\t\tsetIntField(proc, \"maxAdj\", adj);\n\t\t\t\t\t\tif (Build.VERSION.SDK_INT <= 18)\n\t\t\t\t\t\t\tsetIntField(proc, \"hiddenAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"curRawAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"setRawAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"curAdj\", adj);\n\t\t\t\t\t\tsetIntField(proc, \"setAdj\", adj);\n\t\t\t\t\t}\n\t \t\t}\n\t \t});\n\t } catch (Throwable e) {\n\t XposedBridge.log(e);\n\t }\n }\n"} {"input": " public void run() {\n while (mActive) {\n synchronized (this) {\n if (!mDirty && mActive) {\n updateLoading(false);\n Utils.waitWithoutInterrupt(this);\n continue;\n }\n }\n mDirty = false;\n UpdateInfo info = executeAndWait(new GetUpdateInfo());\n updateLoading(true);\n long version = mSource.reload();\n if (info.version != version) {\n info.reloadContent = true;\n info.size = mSource.getMediaItemCount();\n }\n if (!info.reloadContent) continue;\n info.items = mSource.getMediaItem(\n info.contentStart, info.contentEnd);\n int index = MediaSet.INDEX_NOT_FOUND;\n if (mFocusHintPath != null) {\n index = findIndexOfPathInCache(info, mFocusHintPath);\n mFocusHintPath = null;\n }\n if (index == MediaSet.INDEX_NOT_FOUND) {\n MediaItem item = findCurrentMediaItem(info);\n if (item != null && item.getPath() == info.target) {\n index = info.indexHint;\n } else {\n index = findIndexOfTarget(info);\n }\n }\n if (index == MediaSet.INDEX_NOT_FOUND) {\n index = info.indexHint;\n int focusHintDirection = mFocusHintDirection;\n if (index == (mCameraIndex + 1)) {\n focusHintDirection = FOCUS_HINT_NEXT;\n }\n if (focusHintDirection == FOCUS_HINT_PREVIOUS\n && index > 0) {\n index--;\n }\n }\n if (mSize > 0) {\n if (index >= mSize) index = mSize - 1;\n }\n info.indexHint = index;\n executeAndWait(new UpdateContent(info));\n }\n }\n", "output": " public void run() {\n while (mActive) {\n synchronized (this) {\n if (!mDirty && mActive) {\n updateLoading(false);\n Utils.waitWithoutInterrupt(this);\n continue;\n }\n }\n mDirty = false;\n UpdateInfo info = executeAndWait(new GetUpdateInfo());\n updateLoading(true);\n long version = mSource.reload();\n if (info.version != version) {\n info.reloadContent = true;\n info.size = mSource.getMediaItemCount();\n int start = Utils.clamp(info.indexHint - DATA_CACHE_SIZE / 2,\n 0, Math.max(0, info.size - DATA_CACHE_SIZE));\n info.contentStart = start;\n info.contentEnd = Math.min(info.size, start + DATA_CACHE_SIZE);\n }\n if (!info.reloadContent) continue;\n info.items = mSource.getMediaItem(\n info.contentStart, info.contentEnd);\n int index = MediaSet.INDEX_NOT_FOUND;\n if (mFocusHintPath != null) {\n index = findIndexOfPathInCache(info, mFocusHintPath);\n mFocusHintPath = null;\n }\n if (index == MediaSet.INDEX_NOT_FOUND) {\n MediaItem item = findCurrentMediaItem(info);\n if (item != null && item.getPath() == info.target) {\n index = info.indexHint;\n } else {\n index = findIndexOfTarget(info);\n }\n }\n if (index == MediaSet.INDEX_NOT_FOUND) {\n index = info.indexHint;\n int focusHintDirection = mFocusHintDirection;\n if (index == (mCameraIndex + 1)) {\n focusHintDirection = FOCUS_HINT_NEXT;\n }\n if (focusHintDirection == FOCUS_HINT_PREVIOUS\n && index > 0) {\n index--;\n }\n }\n if (info.size > 0) {\n if (index >= info.size) index = info.size - 1;\n }\n info.indexHint = index;\n executeAndWait(new UpdateContent(info));\n }\n }\n"} {"input": " protected void performAction(final Node[] nodes) {\n final Map map = new HashMap();\n for (final Node node : nodes) {\n final Set users = node.getCookie(RMUserCookie.class).getRMUsers();\n final RegistryProject project = node.getCookie(RegistryProjectCookie.class).getProject();\n for (final RMUser user : users) {\n map.put(user, project);\n }\n }\n final String message = JOptionPane.showInputDialog(\n WindowManager.getDefault().getMainWindow(),\n NbBundle.getMessage(\n SendMessageAction.class,\n \"SendMessageAction.performAction(Node[]).message\",\n map.size()));\n if ((message != null) && (message.trim().isEmpty())) {\n for (final Entry entry : map.entrySet()) {\n final RegistryProject project = entry.getValue();\n final RMUser user = entry.getKey();\n try {\n project.getMessageForwarder()\n .sendMessage(\n user.getQualifiedName(),\n user.getIpAddress(),\n message,\n org.openide.util.NbBundle.getMessage(\n SendMessageAction.class,\n \"SendMessageAction.performAction(Node[]).messageFromAdmin\")); \n } catch (final RemoteException ex) {\n LOG.error(\"could not send message\", ex); \n } catch (final UnableToSendMessageException ex) {\n LOG.error(\"could not send message\", ex); \n }\n }\n }\n }\n", "output": " protected void performAction(final Node[] nodes) {\n final Map map = new HashMap();\n for (final Node node : nodes) {\n final Set users = node.getCookie(RMUserCookie.class).getRMUsers();\n final RegistryProject project = node.getCookie(RegistryProjectCookie.class).getProject();\n for (final RMUser user : users) {\n map.put(user, project);\n }\n }\n final String message = JOptionPane.showInputDialog(\n WindowManager.getDefault().getMainWindow(),\n NbBundle.getMessage(\n SendMessageAction.class,\n \"SendMessageAction.performAction(Node[]).message\",\n map.size()));\n if ((message != null) && (!message.trim().isEmpty())) {\n for (final Entry entry : map.entrySet()) {\n final RegistryProject project = entry.getValue();\n final RMUser user = entry.getKey();\n try {\n project.getMessageForwarder()\n .sendMessage(\n user.getQualifiedName(),\n user.getIpAddress(),\n message,\n org.openide.util.NbBundle.getMessage(\n SendMessageAction.class,\n \"SendMessageAction.performAction(Node[]).messageFromAdmin\")); \n } catch (final RemoteException ex) {\n LOG.error(\"could not send message\", ex); \n } catch (final UnableToSendMessageException ex) {\n LOG.error(\"could not send message\", ex); \n }\n }\n }\n }\n"} {"input": " public static IntervalCategoryDataset createDataset(final ProjectSchedule input) {\n final ProjectSchedule solution = GanttPanel.CLONER.cloneSolution(input);\n final TaskSeriesCollection collection = new TaskSeriesCollection();\n for (final Project p : solution.getProblem().getProjects()) {\n final TaskSeries series = new TaskSeries(\"P\" + p.getId());\n for (final Job j : p.getJobs()) {\n if (j.isSink() || j.isSource()) {\n continue;\n }\n final Allocation a = solution.getAllocation(j);\n if (!a.isInitialized()) {\n continue;\n }\n series.add(new Task(\"J\" + j.getId(), new SimpleTimePeriod(GanttPanel.date(a.getStartDate()),\n GanttPanel.date(a.getDueDate()))));\n }\n collection.add(series);\n }\n return collection;\n }\n", "output": " public static IntervalCategoryDataset createDataset(final ProjectSchedule input) {\n final ProjectSchedule solution = GanttPanel.CLONER.cloneSolution(input);\n final TaskSeriesCollection collection = new TaskSeriesCollection();\n for (final Project p : solution.getProblem().getProjects()) {\n final TaskSeries series = new TaskSeries(\"P\" + p.getId());\n for (final Job j : p.getJobs()) {\n if (j.isSink() || j.isSource()) {\n continue;\n }\n final Allocation a = solution.getAllocation(j);\n if (!a.isInitialized()) {\n continue;\n }\n series.add(new Task(\"J\" + j.getId(), new SimpleTimePeriod(GanttPanel.date(a.getStartDate()),\n GanttPanel.date(a.getDueDate() + 1))));\n }\n collection.add(series);\n }\n return collection;\n }\n"} {"input": " public void addToCache(String k, Class type, List ret) {\n if (k == null) {\n return;\n }\n if (ret != null && !k.endsWith(\"idlist\")) {\n Hashtable, Hashtable> idCacheClone = cloneIdCache();\n for (T record : ret) {\n if (idCacheClone.get(type) == null) {\n idCacheClone.put(type, new Hashtable());\n }\n idCacheClone.get(type).put(annotationHelper.getId(record), record);\n }\n setIdCache(idCacheClone);\n }\n CacheElement e = new CacheElement(ret);\n e.setLru(System.currentTimeMillis());\n Hashtable, Hashtable> cl = (Hashtable, Hashtable>) cache.clone();\n if (cl.get(type) == null) {\n cl.put(type, new Hashtable());\n }\n cl.get(type).put(k, e);\n cache = cl;\n }\n", "output": " public void addToCache(String k, Class type, List ret) {\n if (k == null) {\n return;\n }\n if (!k.endsWith(\"idlist\")) {\n Hashtable, Hashtable> idCacheClone = cloneIdCache();\n for (T record : ret) {\n if (idCacheClone.get(type) == null) {\n idCacheClone.put(type, new Hashtable());\n }\n idCacheClone.get(type).put(annotationHelper.getId(record), record);\n }\n setIdCache(idCacheClone);\n }\n CacheElement e = new CacheElement(ret);\n e.setLru(System.currentTimeMillis());\n Hashtable, Hashtable> cl = (Hashtable, Hashtable>) cache.clone();\n if (cl.get(type) == null) {\n cl.put(type, new Hashtable());\n }\n cl.get(type).put(k, e);\n cache = cl;\n }\n"} {"input": " void run() {\n printer.print(WELCOME);\n Question question = new Question(test1);\n question.addAnswer(ANSWER1A, 3);\n question.addAnswer(ANSWER1B, 5);\n question.addAnswer(ANSWER1C, 10);\n printer.print(question.toString());\n String answer = reado.get();\n int response = question.score(answer);\n printer.print(\"You got a \" + response + \"out of 10!\");\n }\n", "output": " void run() {\n printer.print(WELCOME);\n Question question = new Question(test1);\n question.addAnswer(ANSWER1A, 3);\n question.addAnswer(ANSWER1B, 5);\n question.addAnswer(ANSWER1C, 10);\n printer.print(question.toString());\n String answer = reado.get();\n int response = question.score(answer);\n printer.print(\"You got a \" + response + \" out of 10!\");\n }\n"} {"input": " public void startRelation(long statusId)\n {\n TweetModel start = TweetUtils.getOrCreateStatusModel(statusId);\n if (start == null)\n {\n Notificator.alert(\"\u30c4\u30a4\u30fc\u30c8\u306e\u53d6\u5f97\u306b\u5931\u6557\u3057\u307e\u3057\u305f\");\n return;\n }\n talkList.addToTop(start);\n long inReplyTo = start.getInReplyToStatusId();\n while (inReplyTo > 0)\n {\n TweetModel older = TweetUtils.getOrCreateStatusModel(inReplyTo);\n talkList.addToBottom(older);\n inReplyTo = older.getInReplyToStatusId();\n }\n inReplyTo = start.statusId;\n while (true)\n {\n long before = inReplyTo;\n for (TweetModel newer : TweetCache.getList())\n {\n if (newer.getInReplyToStatusId() == inReplyTo)\n {\n talkList.addToTop(newer);\n inReplyTo = newer.statusId;\n break;\n }\n }\n if (before == inReplyTo)\n {\n break;\n }\n }\n updateChasingId(((TweetModel) talkList.getStatus(0)).statusId);\n StatusListManager.getAdapter(talkList).forceNotifyAdapter();\n }\n", "output": " public void startRelation(long statusId)\n {\n TweetModel start = TweetUtils.getOrCreateStatusModel(statusId);\n if (start == null)\n {\n Notificator.alert(\"\u30c4\u30a4\u30fc\u30c8\u306e\u53d6\u5f97\u306b\u5931\u6557\u3057\u307e\u3057\u305f\");\n return;\n }\n talkList.addToTop(start);\n long inReplyTo = start.getInReplyToStatusId();\n while (inReplyTo > 0)\n {\n TweetModel older = TweetUtils.getOrCreateStatusModel(inReplyTo);\n if (older == null)\n {\n Notificator.alert(\"\u30c4\u30a4\u30fc\u30c8\u306e\u53d6\u5f97\u306b\u5931\u6557\u3057\u307e\u3057\u305f\");\n break;\n }\n talkList.addToBottom(older);\n inReplyTo = older.getInReplyToStatusId();\n }\n inReplyTo = start.statusId;\n while (true)\n {\n long before = inReplyTo;\n for (TweetModel newer : TweetCache.getList())\n {\n if (newer.getInReplyToStatusId() == inReplyTo)\n {\n talkList.addToTop(newer);\n inReplyTo = newer.statusId;\n break;\n }\n }\n if (before == inReplyTo)\n {\n break;\n }\n }\n updateChasingId(((TweetModel) talkList.getStatus(0)).statusId);\n StatusListManager.getAdapter(talkList).forceNotifyAdapter();\n }\n"} {"input": "\tpublic void execute() {\n\t\tRule first = _firstRule;\n\t\tRule second = _secondRule;\n\t\t_aggInfo = new TggAggInfo(_trafo);\n\t\t_aggInfo.extendDueToTGG(layoutSystem);\n\t\tList critPairList = _aggInfo.getConflictOverlappings(first, second);\n\t\tif (critPairList != null && !critPairList.isEmpty()) {\n\t\t\tfor (CriticalPair critPair : critPairList) {\n\t\t\tList mappingsOverToR1 = critPair.getMappingsOverlappingToRule1();\n\t\t\tList mappingsOverToR2 = critPair.getMappingsOverlappingToRule2();\n\t\t\tList mappingsR1ToR2 = critPair.getMappingsRule1ToRule2();\n\t\t\tGraph over = critPair.getOverlapping();\n\t\t\tCritPair newCrit = TGGFactory.eINSTANCE.createCritPair();\n\t\t\t\tnewCrit.setName(\"CP\"+(critPairList.indexOf(critPair)+1));\n\t\t\tnewCrit.setOverlapping(over);\n\t\t\tnewCrit.setRule1(critPair.getRule1());\n\t\t\tnewCrit.setRule2(critPair.getRule2());\n\t\t\tnewCrit.getMappingsOverToRule1().addAll(mappingsOverToR1);\n\t\t\tnewCrit.getMappingsOverToRule2().addAll(mappingsOverToR2);\n\t\t\tnewCrit.getMappingsRule1ToRule2().addAll(mappingsR1ToR2);\n\t\t\tlayoutSystem.getCritPairs().add(newCrit);\n\t\t\t_trafo.getInstances().add(over);\n\t\t\t\tchangeToTGGGraph(over);\n\t\t\t\tmarkCriticalObjects(over, _aggInfo.getCriticalObjects().get(critPair));\n\t\t\t\tSystem.out.println(\"Adding CritPair \"+newCrit.getName()+\" for \"+_firstRule.getName()+\" with \"+_secondRule.getName()+\" finished.\");\n\t\t}\n\t\t} else {\n\t\t}\n\t\tsuper.execute();\n\t}\n", "output": "\tpublic void execute() {\n\t\tRule first = RuleUtil.copyRule(_firstRule);\n\t\tRule second = RuleUtil.copyRule(_secondRule);\n\t\t_aggInfo = new TggAggInfo(_trafo);\n\t\t_aggInfo.extendDueToTGG(layoutSystem);\n\t\tList critPairList = _aggInfo.getConflictOverlappings(first, second);\n\t\tif (critPairList != null && !critPairList.isEmpty()) {\n\t\t\tfor (CriticalPair critPair : critPairList) {\n\t\t\tList mappingsOverToR1 = critPair.getMappingsOverlappingToRule1();\n\t\t\tList mappingsOverToR2 = critPair.getMappingsOverlappingToRule2();\n\t\t\tList mappingsR1ToR2 = critPair.getMappingsRule1ToRule2();\n\t\t\tGraph over = critPair.getOverlapping();\n\t\t\tCritPair newCrit = TGGFactory.eINSTANCE.createCritPair();\n\t\t\t\tnewCrit.setName(\"CP\"+(critPairList.indexOf(critPair)+1));\n\t\t\tnewCrit.setOverlapping(over);\n\t\t\tnewCrit.setRule1(critPair.getRule1());\n\t\t\tnewCrit.setRule2(critPair.getRule2());\n\t\t\tnewCrit.getMappingsOverToRule1().addAll(mappingsOverToR1);\n\t\t\tnewCrit.getMappingsOverToRule2().addAll(mappingsOverToR2);\n\t\t\tnewCrit.getMappingsRule1ToRule2().addAll(mappingsR1ToR2);\n\t\t\tlayoutSystem.getCritPairs().add(newCrit);\n\t\t\t_trafo.getInstances().add(over);\n\t\t\t\tchangeToTGGGraph(over);\n\t\t\t\tmarkCriticalObjects(over, _aggInfo.getCriticalObjects().get(critPair));\n\t\t\t\tSystem.out.println(\"Adding CritPair \"+newCrit.getName()+\" for \"+_firstRule.getName()+\" with \"+_secondRule.getName()+\" finished.\");\n\t\t}\n\t\t} else {\n\t\t\tDeleteRuleCommand c1 = new DeleteRuleCommand(first);\n\t\t\tDeleteRuleCommand c2 = new DeleteRuleCommand(second);\n\t\t\tc1.execute();\n\t\t\tc2.execute();\n\t\t}\n\t\tsuper.execute();\n\t}\n"} {"input": " public Raw(Server server) {\n this.server = server;\n frame = new ServerFrame();\n MainFrame.getMainFrame().addChild(frame);\n server.AddDataIn(new IRCParser.IDataIn() {\n public void onDataIn(IRCParser tParser, String sData) {\n Raw.this.frame.addLine(\"<<< \"+sData);\n }\n });\n server.AddDataOut(new IRCParser.IDataOut() {\n public void onDataOut(IRCParser tparser, String sData) {\n Raw.this.frame.addLine(\">>> \"+sData);\n }\n });\n }\n", "output": " public Raw(Server server) {\n this.server = server;\n frame = new ServerFrame();\n MainFrame.getMainFrame().addChild(frame);\n server.AddDataIn(new IRCParser.IDataIn() {\n public void onDataIn(IRCParser tParser, String sData) {\n Raw.this.frame.addLine(\"<<< \"+sData);\n }\n });\n server.AddDataOut(new IRCParser.IDataOut() {\n public void onDataOut(IRCParser tparser, String sData, boolean fromParser) {\n Raw.this.frame.addLine(\">>> \"+sData);\n }\n });\n }\n"} {"input": "\tprivate DSMicroarraySet parseFile(File file)\n\t\tthrows InputFileFormatException, InterruptedIOException {\n\t\tif (!checkFormat(file)) {\n\t\t\tlog\n\t\t\t\t\t.info(\"SOFTFileFormat::getMArraySet - \"\n\t\t\t\t\t\t\t+ \"Attempting to open a file that does not comply with the \"\n\t\t\t\t\t\t\t+ \"GEO SOFT file format.\");\n\t\t\tthrow new InputFileFormatException(errorMessage);\n\t\t}\n\t\tCSMicroarraySet maSet = new CSMicroarraySet();\n\t\tList arrayNames = new ArrayList();\n\t\tint possibleMarkers = 0;\n\t\tBufferedReader in = null;\n\t\tfinal int extSeperater = '.';\n\t\tString fileName = file.getName();\n\t\tint dotIndex = fileName.lastIndexOf(extSeperater);\n\t\tif (dotIndex != -1) {\n\t\t\tfileName = fileName.substring(0, dotIndex);\n\t\t}\n\t\tmaSet.setLabel(fileName);\n\t\tList markers = new ArrayList();\n\t\ttry {\n\t\t\tin = new BufferedReader(new FileReader(file));\n\t\t\tif(in != null){\n\t\t\t\ttry {\n\t\t\t\t\tint m = 0;\n\t\t\t\t\tString header = in.readLine();\n\t\t\t\t\twhile (header != null) {\n\t\t\t\t\t\tif (header.startsWith(commentSign1) || header.startsWith(commentSign2)) {\n\t\t\t\t\t\t\tif(!header.equalsIgnoreCase(\"!dataset_table_begin\") && !header.equalsIgnoreCase(\"!dataset_table_end\")) {\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tString[] tokens = null;\n\t\t\t\t\t\tif(!header.startsWith(commentSign1) && !header.startsWith(commentSign2) && !header.startsWith(commentSign3)){\n\t\t\t\t\t\t\tif(header.subSequence(0, 6).equals(\"ID_REF\")){\n\t\t\t\t\t\t\t\ttokens = header.split(\"\\t\");\n\t\t\t\t\t\t\t\tfor(int n = 2; n arrayNames = new ArrayList();\n\t\tint possibleMarkers = 0;\n\t\tBufferedReader in = null;\n\t\tString fileName = file.getName();\n\t\tmaSet.setLabel(fileName);\n\t\tList markers = new ArrayList();\n\t\ttry {\n\t\t\tin = new BufferedReader(new FileReader(file));\n\t\t\tif(in != null){\n\t\t\t\ttry {\n\t\t\t\t\tint m = 0;\n\t\t\t\t\tString header = in.readLine();\n\t\t\t\t\twhile (header != null) {\n\t\t\t\t\t\tif (header.startsWith(commentSign1) || header.startsWith(commentSign2)) {\n\t\t\t\t\t\t\tif(!header.equalsIgnoreCase(\"!dataset_table_begin\") && !header.equalsIgnoreCase(\"!dataset_table_end\")) {\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tString[] tokens = null;\n\t\t\t\t\t\tif(!header.startsWith(commentSign1) && !header.startsWith(commentSign2) && !header.startsWith(commentSign3)){\n\t\t\t\t\t\t\tif(header.subSequence(0, 6).equals(\"ID_REF\")){\n\t\t\t\t\t\t\t\ttokens = header.split(\"\\t\");\n\t\t\t\t\t\t\t\tfor(int n = 2; n 3)\");\n\t\t\t\tExpression incrementAge = new Expression(\n\t\t\t\t\t\t\"setField('age', this.age+1)\");\n\t\t\t\tExpression incrementNeighbors = new Expression(\n\t\t\t\t\t\t\"setField('neighbors', this.neighbors+1)\");\n\t\t\t\tExpression die = new Expression(\n\t\t\t\t\t\t\"clonePrototype(this.x, this.y, 'deadBeing')\");\n\t\t\t\tExpression resetNeighbors = new Expression(\n\t\t\t\t\t\t\"setField('neighbors', 0)\");\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"updateAge\", 1, isAlive,\n\t\t\t\t\t\tincrementAge));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"resetNeighbors\", 2, new Expression(\n\t\t\t\t\t\t\"true\"), resetNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh1\", 3, neigh1,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh2\", 4, neigh2,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh3\", 5, neigh3,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh4\", 6, neigh4,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh5\", 7, neigh5,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh6\", 8, neigh6,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh7\", 9, neigh7,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh8\", 10, neigh8,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"die\", 11, dieCond, die));\n\t\t\t\tPrototype.addPrototype(aliveBeing);\n\t\t\t\treturn aliveBeing;\n\t}\n", "output": "\tprivate static Prototype initAliveBeing(Prototype aliveBeing){\n\t\t\t\ttry {\n\t\t\t\t\taliveBeing.addField(\"alive\", 1 + \"\"); \n\t\t\t\t\taliveBeing.addField(\"age\", 1 + \"\");\n\t\t\t\t\taliveBeing.addField(\"neighbors\", 0 + \"\");\n\t\t\t\t} catch (ElementAlreadyContainedException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tExpression isAlive = new Expression(\"this.alive == 1\");\n\t\t\t\tExpression neigh1 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt( this.x - 1 , this.y - 1 , 'alive' ) == 1\");\n\t\t\t\tExpression neigh2 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x, this.y-1, 'alive') == 1\");\n\t\t\t\tExpression neigh3 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x+1, this.y-1, 'alive') == 1\");\n\t\t\t\tExpression neigh4 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x-1, this.y, 'alive') == 1\");\n\t\t\t\tExpression neigh5 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x+1, this.y, 'alive') == 1\");\n\t\t\t\tExpression neigh6 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x-1, this.y+1, 'alive') == 1\");\n\t\t\t\tExpression neigh7 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x, this.y+1, 'alive') == 1\");\n\t\t\t\tExpression neigh8 = new Expression(\n\t\t\t\t\t\t\"getFieldOfAgentAt(this.x+1, this.y+1, 'alive') == 1\");\n\t\t\t\tExpression dieCond = new Expression(\n\t\t\t\t\t\t\"(this.alive == 1) && (this.neighbors < 2 || this.neighbors > 3)\");\n\t\t\t\tExpression incrementAge = new Expression(\n\t\t\t\t\t\t\"setField('age', this.age+1)\");\n\t\t\t\tExpression incrementNeighbors = new Expression(\n\t\t\t\t\t\t\"setField('neighbors', this.neighbors+1)\");\n\t\t\t\tExpression die = new Expression(\n\t\t\t\t\t\t\"clonePrototype(this.x, this.y, 'deadBeing')\");\n\t\t\t\tExpression resetNeighbors = new Expression(\n\t\t\t\t\t\t\"setField('neighbors', 0)\");\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"updateAge\", 1, isAlive,\n\t\t\t\t\t\tincrementAge));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"resetNeighbors\", 2, new Expression(\n\t\t\t\t\t\t\"true\"), resetNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh1\", 3, neigh1,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh2\", 4, neigh2,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh3\", 5, neigh3,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh4\", 6, neigh4,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh5\", 7, neigh5,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh6\", 8, neigh6,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh7\", 9, neigh7,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"checkNeigh8\", 10, neigh8,\n\t\t\t\t\t\tincrementNeighbors));\n\t\t\t\taliveBeing.addTrigger(new Trigger(\"die\", 11, dieCond, die));\n\t\t\t\tPrototype.addPrototype(aliveBeing);\n\t\t\t\treturn aliveBeing;\n\t}\n"} {"input": "\tpublic boolean OpenDatabase() {\n\t\ttry {\n\t\t\tClass.forName(\"org.sqlite.JDBC\");\n\t\t\tConn = DriverManager.getConnection(\"jdbc:sqlite:plugins/\" + plugin.getName() + \"/\" + DBFilename);\n\t\t\tIsConnected = true;\n\t\t\tif (TableExists(Conn, \"birthdaygift\")) {\n\t\t\t\tif (!ColumnExists(Conn, \"birthdaygift\", \"lastAnnouncedDate\")) {\n\t\t\t\t\tplugin.Warn(\"Old table format detected!\");\n\t\t\t\t\tplugin.Log(\"Creating backup of existing database...\");\n\t\t\t\t\tPath src = Paths.get(\"plugins/\" + plugin.getName() + \"/\" + DBFilename);\n\t\t\t\t\tPath dst = Paths.get(\"plugins/\" + plugin.getName() + \"/backup.db\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFiles.copy(src, dst, new CopyOption[] { REPLACE_EXISTING });\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tplugin.Warn(\"Unable to create database backup! Refusing to continue!!\");\n\t\t\t\t\t\tConn.close();\n\t\t\t\t\t\tIsConnected = false;\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tplugin.Log(\"Updating database table...\");\n\t\t\t\t\tint result = ExecuteUpdate(\"ALTER TABLE birthdaygift ADD COLUMN `lastAnnouncedDate` DATE\");\n\t\t\t\t\tplugin.Debug(\"SQL Result: \" + result);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tplugin.Log(\"Database table does not exist, creating one.\");\n\t\t\t\tExecuteUpdate(\"CREATE TABLE IF NOT EXISTS birthdaygift (\" +\n\t\t\t\t\t\t\"`player` varchar(250) NOT NULL PRIMARY KEY, \" +\n\t\t\t\t\t\t\"`birthdayDate` DATE,\" +\n\t\t\t\t\t\t\"`lastGiftDate` DATE,\" +\n\t\t\t\t\t\t\"`lastAnnouncedDate` DATE)\");\n\t\t\t}\n\t\t\tIsConnected = true;\n\t\t\treturn false;\n\t\t} catch (SQLException e) {\n\t\t\tplugin.Warn(\"Unable to open database!\");\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean OpenDatabase() {\n\t\ttry {\n\t\t\tClass.forName(\"org.sqlite.JDBC\");\n\t\t\tConn = DriverManager.getConnection(\"jdbc:sqlite:plugins/\" + plugin.getName() + \"/\" + DBFilename);\n\t\t\tIsConnected = true;\n\t\t\tif (TableExists(Conn, \"birthdaygift\")) {\n\t\t\t\tif (!ColumnExists(Conn, \"birthdaygift\", \"lastAnnouncedDate\")) {\n\t\t\t\t\tplugin.Warn(\"Old table format detected!\");\n\t\t\t\t\tplugin.Log(\"Creating backup of existing database...\");\n\t\t\t\t\tPath src = Paths.get(\"plugins/\" + plugin.getName() + \"/\" + DBFilename);\n\t\t\t\t\tPath dst = Paths.get(\"plugins/\" + plugin.getName() + \"/backup.db\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFiles.copy(src, dst, new CopyOption[] { REPLACE_EXISTING });\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tplugin.Warn(\"Unable to create database backup! Refusing to continue!!\");\n\t\t\t\t\t\tConn.close();\n\t\t\t\t\t\tIsConnected = false;\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tplugin.Log(\"Updating database table...\");\n\t\t\t\t\tint result = ExecuteUpdate(\"ALTER TABLE birthdaygift ADD COLUMN `lastAnnouncedDate` DATE\");\n\t\t\t\t\tplugin.Debug(\"SQL Result: \" + result);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tplugin.Log(\"Database table does not exist, creating one.\");\n\t\t\t\tExecuteUpdate(\"CREATE TABLE IF NOT EXISTS birthdaygift (\" +\n\t\t\t\t\t\t\"`player` varchar(250) NOT NULL PRIMARY KEY, \" +\n\t\t\t\t\t\t\"`birthdayDate` DATE,\" +\n\t\t\t\t\t\t\"`lastGiftDate` DATE,\" +\n\t\t\t\t\t\t\"`lastAnnouncedDate` DATE)\");\n\t\t\t}\n\t\t\tIsConnected = true;\n\t\t\treturn false;\n\t\t} catch (SQLException e) {\n\t\t\tplugin.Warn(\"Unable to open database!\");\n\t\t\te.printStackTrace();\n\t\t\treturn false;\n\t\t} catch (ClassNotFoundException e) {\n\t\t\tplugin.Warn(\"Unable to find a suitable SQLite driver!\");\n\t\t\te.printStackTrace();\n\t\t\treturn false;\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": "\tprivate Object docreate(Configuration config) throws Exception {\n\t\tensureSecurityManager();\n\t\tObject proxy = null;\n\t\tHTTPDStatus.httpdWarning(getCodebase());\n\t\tString defaultDir = null;\n\t\tString fs = File.separator;\n\t\tString sorcerHome = SorcerEnv.getHomeDir().getPath();\n\t\tif (sorcerHome == null) {\n\t\t\tlogger.info(\"'sorcer.home' not defined, no default platformDir\");\n\t\t} else {\n\t\t\tdefaultDir = sorcerHome+fs+\"configs\"+fs+\"platform\"+fs+\"sorcer\";\n\t\t}\n\t\tCommonClassLoader commonCL = CommonClassLoader.getInstance();\n if (!platformLoaded) {\n loadPlatform(config, defaultDir, commonCL);\n platformLoaded = true;\n }\n Thread currentThread = Thread.currentThread();\n\t\tClassLoader currentClassLoader = currentThread.getContextClassLoader();\n\t\tClassAnnotator annotator = null;\n if (getCodebase() != null) {\n annotator = new ClassAnnotator(ClassLoaderUtil\n .getCodebaseURLs(getCodebase()), new Properties());\n }\n\t\tServiceClassLoader jsbCL = new ServiceClassLoader(ServiceClassLoader\n\t\t\t\t.getURIs(ClassLoaderUtil.getClasspathURLs(getClasspath())),\n\t\t\t\tannotator, commonCL);\n\t\tif (logger.isLoggable(Level.FINE))\n\t\t\tClassLoaderUtil.displayClassLoaderTree(jsbCL);\n\t\tnew ClassPathVerifier().verifyClassPaths(jsbCL);\n\t\tcurrentThread.setContextClassLoader(jsbCL);\n\t\tProxyPreparer servicePreparer = (ProxyPreparer) Config.getNonNullEntry(\n\t\t\t\tconfig, COMPONENT, \"servicePreparer\", ProxyPreparer.class,\n\t\t\t\tnew BasicProxyPreparer());\n\t\tsynchronized (SorcerServiceDescriptor.class) {\n\t\t\tif (globalPolicy == null) {\n\t\t\t\tinitialGlobalPolicy = Policy.getPolicy();\n\t\t\t\tglobalPolicy = new AggregatePolicyProvider(initialGlobalPolicy);\n\t\t\t\tPolicy.setPolicy(globalPolicy);\n\t\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\t\tlogger.log(Level.FINEST, \"Global policy set: {0}\",\n\t\t\t\t\t\t\tglobalPolicy);\n\t\t\t}\n\t\t\tDynamicPolicyProvider service_policy = new DynamicPolicyProvider(\n\t\t\t\t\tnew PolicyFileProvider(getPolicy()));\n\t\t\tLoaderSplitPolicyProvider splitServicePolicy = new LoaderSplitPolicyProvider(\n\t\t\t\t\tjsbCL, service_policy, new DynamicPolicyProvider(\n\t\t\t\t\t\t\tinitialGlobalPolicy));\n\t\t\tsplitServicePolicy.grant(SorcerServiceDescriptor.class, null,\n\t\t\t\t\tnew Permission[] { new AllPermission() });\n\t\t\tglobalPolicy.setPolicy(jsbCL, splitServicePolicy);\n\t\t}\n\t\tObject impl;\n\t\ttry {\n\t\t\tClass implClass;\n\t\t\timplClass = Class.forName(getImplClassName(), false, jsbCL);\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger.finest(\"Attempting to get implementation constructor\");\n\t\t\tConstructor constructor = implClass\n\t\t\t\t\t.getDeclaredConstructor(actTypes);\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger\n\t\t\t\t\t\t.log(Level.FINEST,\n\t\t\t\t\t\t\t\t\"Obtained implementation constructor: \",\n\t\t\t\t\t\t\t\tconstructor);\n\t\t\tconstructor.setAccessible(true);\n\t\t\timpl = constructor.newInstance(getServerConfigArgs(), lifeCycle);\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger.log(Level.FINEST,\n\t\t\t\t\t\t\"Obtained implementation instance: {0}\", impl);\n\t\t\tif (impl instanceof ServiceProxyAccessor) {\n\t\t\t\tproxy = ((ServiceProxyAccessor) impl).getServiceProxy();\n\t\t\t} else if (impl instanceof ProxyAccessor) {\n\t\t\t\tproxy = ((ProxyAccessor) impl).getProxy();\n\t\t\t} else {\n\t\t\t\tproxy = null; \n\t\t\t}\n\t\t\tif (proxy != null) {\n\t\t\t\tproxy = servicePreparer.prepareProxy(proxy);\n\t\t\t}\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger.log(Level.FINEST, \"Proxy = {0}\", proxy);\n proxy = (new MarshalledObject(proxy)).get();\n currentThread.setContextClassLoader(currentClassLoader);\n } finally {\n\t\t\tcurrentThread.setContextClassLoader(currentClassLoader);\n\t\t}\n\t\treturn (new Created(impl, proxy));\n\t}\n", "output": "\tprivate Object docreate(Configuration config) throws Exception {\n\t\tensureSecurityManager();\n\t\tObject proxy = null;\n {\n String codebase = getCodebase();\n if (codebase != null && codebase.startsWith(\"http\"))\n HTTPDStatus.httpdWarning(codebase);\n }\n\t\tString defaultDir = null;\n\t\tString fs = File.separator;\n\t\tString sorcerHome = SorcerEnv.getHomeDir().getPath();\n\t\tif (sorcerHome == null) {\n\t\t\tlogger.info(\"'sorcer.home' not defined, no default platformDir\");\n\t\t} else {\n\t\t\tdefaultDir = sorcerHome+fs+\"configs\"+fs+\"platform\"+fs+\"sorcer\";\n\t\t}\n\t\tCommonClassLoader commonCL = CommonClassLoader.getInstance();\n if (!platformLoaded) {\n loadPlatform(config, defaultDir, commonCL);\n platformLoaded = true;\n }\n Thread currentThread = Thread.currentThread();\n\t\tClassLoader currentClassLoader = currentThread.getContextClassLoader();\n\t\tClassAnnotator annotator = null;\n if (getCodebase() != null) {\n annotator = new ClassAnnotator(ClassLoaderUtil\n .getCodebaseURLs(getCodebase()), new Properties());\n }\n\t\tServiceClassLoader jsbCL = new ServiceClassLoader(ServiceClassLoader\n\t\t\t\t.getURIs(ClassLoaderUtil.getClasspathURLs(getClasspath())),\n\t\t\t\tannotator, commonCL);\n\t\tif (logger.isLoggable(Level.FINE))\n\t\t\tClassLoaderUtil.displayClassLoaderTree(jsbCL);\n\t\tnew ClassPathVerifier().verifyClassPaths(jsbCL);\n\t\tcurrentThread.setContextClassLoader(jsbCL);\n\t\tProxyPreparer servicePreparer = (ProxyPreparer) Config.getNonNullEntry(\n\t\t\t\tconfig, COMPONENT, \"servicePreparer\", ProxyPreparer.class,\n\t\t\t\tnew BasicProxyPreparer());\n\t\tsynchronized (SorcerServiceDescriptor.class) {\n\t\t\tif (globalPolicy == null) {\n\t\t\t\tinitialGlobalPolicy = Policy.getPolicy();\n\t\t\t\tglobalPolicy = new AggregatePolicyProvider(initialGlobalPolicy);\n\t\t\t\tPolicy.setPolicy(globalPolicy);\n\t\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\t\tlogger.log(Level.FINEST, \"Global policy set: {0}\",\n\t\t\t\t\t\t\tglobalPolicy);\n\t\t\t}\n\t\t\tDynamicPolicyProvider service_policy = new DynamicPolicyProvider(\n\t\t\t\t\tnew PolicyFileProvider(getPolicy()));\n\t\t\tLoaderSplitPolicyProvider splitServicePolicy = new LoaderSplitPolicyProvider(\n\t\t\t\t\tjsbCL, service_policy, new DynamicPolicyProvider(\n\t\t\t\t\t\t\tinitialGlobalPolicy));\n\t\t\tsplitServicePolicy.grant(SorcerServiceDescriptor.class, null,\n\t\t\t\t\tnew Permission[] { new AllPermission() });\n\t\t\tglobalPolicy.setPolicy(jsbCL, splitServicePolicy);\n\t\t}\n\t\tObject impl;\n\t\ttry {\n\t\t\tClass implClass;\n\t\t\timplClass = Class.forName(getImplClassName(), false, jsbCL);\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger.finest(\"Attempting to get implementation constructor\");\n\t\t\tConstructor constructor = implClass\n\t\t\t\t\t.getDeclaredConstructor(actTypes);\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger\n\t\t\t\t\t\t.log(Level.FINEST,\n\t\t\t\t\t\t\t\t\"Obtained implementation constructor: \",\n\t\t\t\t\t\t\t\tconstructor);\n\t\t\tconstructor.setAccessible(true);\n\t\t\timpl = constructor.newInstance(getServerConfigArgs(), lifeCycle);\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger.log(Level.FINEST,\n\t\t\t\t\t\t\"Obtained implementation instance: {0}\", impl);\n\t\t\tif (impl instanceof ServiceProxyAccessor) {\n\t\t\t\tproxy = ((ServiceProxyAccessor) impl).getServiceProxy();\n\t\t\t} else if (impl instanceof ProxyAccessor) {\n\t\t\t\tproxy = ((ProxyAccessor) impl).getProxy();\n\t\t\t} else {\n\t\t\t\tproxy = null; \n\t\t\t}\n\t\t\tif (proxy != null) {\n\t\t\t\tproxy = servicePreparer.prepareProxy(proxy);\n\t\t\t}\n\t\t\tif (logger.isLoggable(Level.FINEST))\n\t\t\t\tlogger.log(Level.FINEST, \"Proxy = {0}\", proxy);\n proxy = (new MarshalledObject(proxy)).get();\n currentThread.setContextClassLoader(currentClassLoader);\n } finally {\n\t\t\tcurrentThread.setContextClassLoader(currentClassLoader);\n\t\t}\n\t\treturn (new Created(impl, proxy));\n\t}\n"} {"input": " public Command movePieces(Map map, Point p) {\n PieceIterator it = DragBuffer.getBuffer().getIterator();\n if (!it.hasMoreElements()) {\n return null;\n }\n Point offset = null;\n Command comm = new NullCommand();\n BoundsTracker tracker = new BoundsTracker();\n HashMap> mergeTargets =\n new HashMap>();\n while (it.hasMoreElements()) {\n dragging = it.nextPiece();\n tracker.addPiece(dragging);\n GamePiece[] draggedPieces;\n if (dragging instanceof Stack) {\n int size = ((Stack) dragging).getPieceCount();\n draggedPieces = new GamePiece[size];\n for (int i = 0; i < size; i++) {\n draggedPieces[i] = ((Stack) dragging).getPieceAt(i);\n }\n }\n else {\n draggedPieces = new GamePiece[]{dragging};\n }\n for (int i = 0; i < draggedPieces.length; i++) {\n KeyBuffer.getBuffer().add(draggedPieces[i]);\n }\n if (offset != null) {\n p = new Point(dragging.getPosition().x + offset.x, dragging.getPosition().y + offset.y);\n }\n List mergeCandidates = mergeTargets.get(p);\n GamePiece mergeWith = null;\n if (mergeCandidates != null) {\n for (int i = 0, n = mergeCandidates.size(); i < n; ++i) {\n GamePiece candidate = mergeCandidates.get(i);\n if (map.getPieceCollection().canMerge(candidate, dragging)) {\n mergeWith = candidate;\n mergeCandidates.set(i, dragging);\n break;\n }\n }\n }\n if (mergeWith == null) {\n mergeWith = map.findAnyPiece(p, dropTargetSelector);\n if (mergeWith == null && !Boolean.TRUE.equals(dragging.getProperty(Properties.IGNORE_GRID))) {\n p = map.snapTo(p);\n }\n if (offset == null) {\n offset = new Point(p.x - dragging.getPosition().x,\n p.y - dragging.getPosition().y);\n }\n if (mergeWith != null && map.getStackMetrics().isStackingEnabled()) {\n mergeCandidates = new ArrayList();\n mergeCandidates.add(mergeWith);\n mergeTargets.put(p, mergeCandidates);\n }\n }\n if (mergeWith == null) {\n comm = comm.append(movedPiece(dragging, p));\n comm = comm.append(map.placeAt(dragging, p));\n if (!(dragging instanceof Stack) && !Boolean.TRUE.equals(dragging.getProperty(Properties.NO_STACK))) {\n Stack parent = map.getStackMetrics().createStack(dragging);\n if (parent != null) {\n comm = comm.append(map.placeAt(parent, p));\n }\n }\n }\n else {\n comm = comm.append(movedPiece(dragging, mergeWith.getPosition()));\n comm = comm.append(map.getStackMetrics().merge(mergeWith, dragging));\n }\n if (map.getMoveKey() != null) {\n applyKeyAfterMove(draggedPieces, comm, map.getMoveKey());\n }\n tracker.addPiece(dragging);\n }\n if (GlobalOptions.getInstance().autoReportEnabled()) {\n Command report = createMovementReporter(comm).getReportCommand();\n report.execute();\n comm = comm.append(report);\n }\n tracker.repaint();\n return comm;\n }\n", "output": " public Command movePieces(Map map, Point p) {\n PieceIterator it = DragBuffer.getBuffer().getIterator();\n if (!it.hasMoreElements()) {\n return null;\n }\n Point offset = null;\n Command comm = new NullCommand();\n BoundsTracker tracker = new BoundsTracker();\n HashMap> mergeTargets =\n new HashMap>();\n while (it.hasMoreElements()) {\n dragging = it.nextPiece();\n tracker.addPiece(dragging);\n GamePiece[] draggedPieces;\n if (dragging instanceof Stack) {\n int size = ((Stack) dragging).getPieceCount();\n draggedPieces = new GamePiece[size];\n for (int i = 0; i < size; i++) {\n draggedPieces[i] = ((Stack) dragging).getPieceAt(i);\n }\n }\n else {\n draggedPieces = new GamePiece[]{dragging};\n }\n for (int i = 0; i < draggedPieces.length; i++) {\n KeyBuffer.getBuffer().add(draggedPieces[i]);\n }\n if (offset != null) {\n p = new Point(dragging.getPosition().x + offset.x, dragging.getPosition().y + offset.y);\n }\n List mergeCandidates = mergeTargets.get(p);\n GamePiece mergeWith = null;\n if (mergeCandidates != null) {\n for (int i = 0, n = mergeCandidates.size(); i < n; ++i) {\n GamePiece candidate = mergeCandidates.get(i);\n if (map.getPieceCollection().canMerge(candidate, dragging)) {\n mergeWith = candidate;\n mergeCandidates.set(i, dragging);\n break;\n }\n }\n }\n if (mergeWith == null) {\n mergeWith = map.findAnyPiece(p, dropTargetSelector);\n if (mergeWith == null && !Boolean.TRUE.equals(dragging.getProperty(Properties.IGNORE_GRID))) {\n p = map.snapTo(p);\n }\n if (offset == null) {\n offset = new Point(p.x - dragging.getPosition().x,\n p.y - dragging.getPosition().y);\n }\n if (mergeWith != null && map.getStackMetrics().isStackingEnabled()) {\n mergeCandidates = new ArrayList();\n mergeCandidates.add(dragging);\n mergeCandidates.add(mergeWith);\n mergeTargets.put(p, mergeCandidates);\n }\n }\n if (mergeWith == null) {\n comm = comm.append(movedPiece(dragging, p));\n comm = comm.append(map.placeAt(dragging, p));\n if (!(dragging instanceof Stack) && !Boolean.TRUE.equals(dragging.getProperty(Properties.NO_STACK))) {\n Stack parent = map.getStackMetrics().createStack(dragging);\n if (parent != null) {\n comm = comm.append(map.placeAt(parent, p));\n }\n }\n }\n else {\n comm = comm.append(movedPiece(dragging, mergeWith.getPosition()));\n comm = comm.append(map.getStackMetrics().merge(mergeWith, dragging));\n }\n if (map.getMoveKey() != null) {\n applyKeyAfterMove(draggedPieces, comm, map.getMoveKey());\n }\n tracker.addPiece(dragging);\n }\n if (GlobalOptions.getInstance().autoReportEnabled()) {\n Command report = createMovementReporter(comm).getReportCommand();\n report.execute();\n comm = comm.append(report);\n }\n tracker.repaint();\n return comm;\n }\n"} {"input": " LibraryProperties(Composite parent) {\n mMatchIcon = AdtPlugin.getImageDescriptor(\"/icons/match.png\").createImage(); \n mErrorIcon = AdtPlugin.getImageDescriptor(\"/icons/error.png\").createImage(); \n mTop = new Composite(parent, SWT.NONE);\n mTop.setLayout(new GridLayout(2, false));\n mTop.setLayoutData(new GridData(GridData.FILL_BOTH));\n mTop.setFont(parent.getFont());\n mTop.addDisposeListener(new DisposeListener() {\n public void widgetDisposed(DisposeEvent e) {\n mMatchIcon.dispose();\n mErrorIcon.dispose();\n }\n });\n mTable = new Table(mTop, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);\n mTable.setLayoutData(new GridData(GridData.FILL_BOTH));\n mTable.setHeaderVisible(true);\n mTable.setLinesVisible(false);\n mTable.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n resetEnabled();\n }\n });\n final TableColumn column0 = new TableColumn(mTable, SWT.NONE);\n column0.setText(\"Reference\");\n final TableColumn column1 = new TableColumn(mTable, SWT.NONE);\n column1.setText(\"Project\");\n Composite buttons = new Composite(mTop, SWT.NONE);\n buttons.setLayout(new GridLayout());\n buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL));\n mProjectChooser = new ProjectChooserHelper(parent.getShell(), mFilter);\n mAddButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mAddButton.setText(\"Add...\");\n mAddButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n IJavaProject javaProject = mProjectChooser.chooseJavaProject(null);\n if (javaProject != null) {\n IProject iProject = javaProject.getProject();\n IPath relativePath = Sdk.makeRelativeTo(\n iProject.getLocation(), mState.getProject().getLocation());\n addItem(relativePath.toString(), iProject, -1);\n resetEnabled();\n mMustSave = true;\n }\n }\n });\n mRemoveButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mRemoveButton.setText(\"Remove\");\n mRemoveButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n TableItem selection = mTable.getSelection()[0];\n ItemData data = (ItemData) selection.getData();\n mItemDataList.remove(data);\n mTable.remove(mTable.getSelectionIndex());\n resetEnabled();\n }\n });\n Label l = new Label(buttons, SWT.SEPARATOR | SWT.HORIZONTAL);\n l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mUpButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mUpButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mUpButton.setText(\"Up\");\n mUpButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n int index = mTable.getSelectionIndex();\n ItemData data = mItemDataList.remove(index);\n mTable.remove(index);\n addItem(data.relativePath, data.project, index - 1);\n mTable.select(index - 1);\n resetEnabled();\n }\n });\n mDownButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mDownButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mDownButton.setText(\"Down\");\n mDownButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n int index = mTable.getSelectionIndex();\n ItemData data = mItemDataList.remove(index);\n mTable.remove(index);\n addItem(data.relativePath, data.project, index + 1);\n mTable.select(index + 1);\n resetEnabled();\n }\n });\n adjustColumnsWidth(mTable, column0, column1);\n }\n", "output": " LibraryProperties(Composite parent) {\n mMatchIcon = AdtPlugin.getImageDescriptor(\"/icons/match.png\").createImage(); \n mErrorIcon = AdtPlugin.getImageDescriptor(\"/icons/error.png\").createImage(); \n mTop = new Composite(parent, SWT.NONE);\n mTop.setLayout(new GridLayout(2, false));\n mTop.setLayoutData(new GridData(GridData.FILL_BOTH));\n mTop.setFont(parent.getFont());\n mTop.addDisposeListener(new DisposeListener() {\n public void widgetDisposed(DisposeEvent e) {\n mMatchIcon.dispose();\n mErrorIcon.dispose();\n }\n });\n mTable = new Table(mTop, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);\n mTable.setLayoutData(new GridData(GridData.FILL_BOTH));\n mTable.setHeaderVisible(true);\n mTable.setLinesVisible(false);\n mTable.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n resetEnabled();\n }\n });\n final TableColumn column0 = new TableColumn(mTable, SWT.NONE);\n column0.setText(\"Reference\");\n final TableColumn column1 = new TableColumn(mTable, SWT.NONE);\n column1.setText(\"Project\");\n Composite buttons = new Composite(mTop, SWT.NONE);\n buttons.setLayout(new GridLayout());\n buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL));\n mProjectChooser = new ProjectChooserHelper(parent.getShell(), mFilter);\n mAddButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mAddButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mAddButton.setText(\"Add...\");\n mAddButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n IJavaProject javaProject = mProjectChooser.chooseJavaProject(null);\n if (javaProject != null) {\n IProject iProject = javaProject.getProject();\n IPath relativePath = Sdk.makeRelativeTo(\n iProject.getLocation(), mState.getProject().getLocation());\n addItem(relativePath.toString(), iProject, -1);\n resetEnabled();\n mMustSave = true;\n }\n }\n });\n mRemoveButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mRemoveButton.setText(\"Remove\");\n mRemoveButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n TableItem selection = mTable.getSelection()[0];\n ItemData data = (ItemData) selection.getData();\n mItemDataList.remove(data);\n mTable.remove(mTable.getSelectionIndex());\n resetEnabled();\n mMustSave = true;\n }\n });\n Label l = new Label(buttons, SWT.SEPARATOR | SWT.HORIZONTAL);\n l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mUpButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mUpButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mUpButton.setText(\"Up\");\n mUpButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n int index = mTable.getSelectionIndex();\n ItemData data = mItemDataList.remove(index);\n mTable.remove(index);\n addItem(data.relativePath, data.project, index - 1);\n mTable.select(index - 1);\n resetEnabled();\n mMustSave = true;\n }\n });\n mDownButton = new Button(buttons, SWT.PUSH | SWT.FLAT);\n mDownButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n mDownButton.setText(\"Down\");\n mDownButton.addSelectionListener(new SelectionAdapter() {\n @Override\n public void widgetSelected(SelectionEvent e) {\n int index = mTable.getSelectionIndex();\n ItemData data = mItemDataList.remove(index);\n mTable.remove(index);\n addItem(data.relativePath, data.project, index + 1);\n mTable.select(index + 1);\n resetEnabled();\n mMustSave = true;\n }\n });\n adjustColumnsWidth(mTable, column0, column1);\n }\n"} {"input": "\tpublic Collection getContactGroups(Context context,\n\t\t\tlong directoryId) {\n\t\tfinal String starredContacts = context.getString(R.string.starredContacts);\n\t\tfinal String myContacts = context.getString(R.string.myContacts);\n\t\tComparator comparator = new Comparator() {\n\t\t\t@Override\n\t\t\tpublic int compare(ContactGroup g1, ContactGroup g2) {\n\t\t\t\tif (myContacts.equalsIgnoreCase(g1.getTitle())) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (myContacts.equalsIgnoreCase(g2.getTitle())) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (starredContacts.equalsIgnoreCase(g1.getTitle())\n\t\t\t\t\t\t|| STARRED_CONTACTS_ENG.equalsIgnoreCase(g1.getTitle())) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (starredContacts.equalsIgnoreCase(g2.getTitle())\n\t\t\t\t\t\t|| STARRED_CONTACTS_ENG.equalsIgnoreCase(g2.getTitle())) {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\treturn g1.getTitle().compareTo(g2.getTitle());\n\t\t\t}\n\t\t};\n\t\tfinal Collection groups = new TreeSet(\n\t\t\t\tcomparator);\n\t\tUri uri = ContactsContract.Groups.CONTENT_URI;\n\t\tString[] projection = new String[] { ContactsContract.Groups._ID,\n\t\t\t\tContactsContract.Groups.ACCOUNT_NAME,\n\t\t\t\tContactsContract.Groups.ACCOUNT_TYPE,\n\t\t\t\tContactsContract.Groups.TITLE, };\n\t\tString selection = null;\n\t\tString[] selectionArgs = null;\n\t\tString sortOrder = ContactsContract.Groups.TITLE\n\t\t\t\t+ \" COLLATE LOCALIZED ASC\"; \n\t\tCursorLoader loader = new CursorLoader(context, uri, projection,\n\t\t\t\tselection, selectionArgs, sortOrder);\n\t\tCursor cursor = null;\n\t\tboolean foundStarredGroup = false;\n\t\tboolean foundMyContacts = false;\n\t\ttry {\n\t\t\tloader.startLoading();\n\t\t\tcursor = loader.loadInBackground();\n\t\t\tif (cursor == null) {\n\t\t\t\treturn groups;\n\t\t\t}\n\t\t\tcursor.moveToFirst();\n\t\t\twhile (cursor.isAfterLast() == false) {\n\t\t\t\tlong groupId = cursor.getLong(0);\n\t\t\t\tString accountName = cursor.getString(1);\n\t\t\t\tString accountType = cursor.getString(2);\n\t\t\t\tString title = cursor.getString(3);\n\t\t\t\tif (title == null || title.equalsIgnoreCase(myContacts)) { \n\t\t\t\t\tif (foundMyContacts) {\n\t\t\t\t\t\tcursor.moveToNext();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tfoundMyContacts = true;\n\t\t\t\t\tgroupId = ContactsWidgetConfigurationActivity.CONTACT_MY_CONTACTS_GROUP_ID;\n\t\t\t\t} else if (title.equalsIgnoreCase(starredContacts)\n\t\t\t\t\t\t|| STARRED_CONTACTS_ENG.equalsIgnoreCase(title)) {\n\t\t\t\t\tfoundStarredGroup = true;\n\t\t\t\t\tgroupId = ContactsWidgetConfigurationActivity.CONTACT_STARRED_GROUP_ID;\n\t\t\t\t}\n\t\t\t\tContactGroup group = new ContactGroup(groupId, accountName,\n\t\t\t\t\t\taccountType, title);\n\t\t\t\tgroups.add(group);\n\t\t\t\tcursor.moveToNext();\n\t\t\t}\n\t\t} finally {\n\t\t\tloader.stopLoading();\n\t\t\tif (cursor != null) {\n\t\t\t\tcursor.close();\n\t\t\t}\n\t\t}\n\t\tif (!foundStarredGroup) {\n\t\t\tContactGroup group = new ContactGroup(\n\t\t\t\t\tContactsWidgetConfigurationActivity.CONTACT_STARRED_GROUP_ID, starredContacts,\n\t\t\t\t\tnull, starredContacts);\n\t\t\tgroups.add(group);\n\t\t}\n\t\tif (!foundMyContacts) {\n\t\t\tContactGroup group = new ContactGroup(\n\t\t\t\t\tContactsWidgetConfigurationActivity.CONTACT_MY_CONTACTS_GROUP_ID, myContacts,\n\t\t\t\t\tnull, myContacts);\n\t\t\tgroups.add(group);\n\t\t}\n\t\treturn groups;\n\t}\n", "output": "\tpublic Collection getContactGroups(Context context,\n\t\t\tlong directoryId) {\n\t\tfinal String starredContacts = context.getString(R.string.starredContacts);\n\t\tfinal String myContacts = context.getString(R.string.myContacts);\n\t\tComparator comparator = new Comparator() {\n\t\t\t@Override\n\t\t\tpublic int compare(ContactGroup g1, ContactGroup g2) {\n\t\t\t\tif (myContacts.equalsIgnoreCase(g1.getTitle())) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (myContacts.equalsIgnoreCase(g2.getTitle())) {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (starredContacts.equalsIgnoreCase(g1.getTitle())\n\t\t\t\t\t\t|| STARRED_CONTACTS_ENG.equalsIgnoreCase(g1.getTitle())) {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (starredContacts.equalsIgnoreCase(g2.getTitle())\n\t\t\t\t\t\t|| STARRED_CONTACTS_ENG.equalsIgnoreCase(g2.getTitle())) {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\treturn g1.getTitle().compareTo(g2.getTitle());\n\t\t\t}\n\t\t};\n\t\tfinal Collection groups = new TreeSet(\n\t\t\t\tcomparator);\n\t\tUri uri = ContactsContract.Groups.CONTENT_URI;\n\t\tString[] projection = new String[] { ContactsContract.Groups._ID,\n\t\t\t\tContactsContract.Groups.ACCOUNT_NAME,\n\t\t\t\tContactsContract.Groups.ACCOUNT_TYPE,\n\t\t\t\tContactsContract.Groups.TITLE, };\n\t\tString selection = null;\n\t\tString[] selectionArgs = null;\n\t\tString sortOrder = ContactsContract.Groups.TITLE\n\t\t\t\t+ \" COLLATE LOCALIZED ASC\"; \n\t\tCursorLoader loader = new CursorLoader(context, uri, projection,\n\t\t\t\tselection, selectionArgs, sortOrder);\n\t\tCursor cursor = null;\n\t\tboolean foundStarredGroup = false;\n\t\tboolean foundMyContacts = false;\n\t\ttry {\n\t\t\tloader.startLoading();\n\t\t\tcursor = loader.loadInBackground();\n\t\t\tif (cursor == null) {\n\t\t\t\treturn groups;\n\t\t\t}\n\t\t\tcursor.moveToFirst();\n\t\t\twhile (cursor.isAfterLast() == false) {\n\t\t\t\tlong groupId = cursor.getLong(0);\n\t\t\t\tString accountName = cursor.getString(1);\n\t\t\t\tString accountType = cursor.getString(2);\n\t\t\t\tString title = cursor.getString(3);\n\t\t\t\tif (title == null || title.equalsIgnoreCase(myContacts)) { \n\t\t\t\t\tif (foundMyContacts) {\n\t\t\t\t\t\tcursor.moveToNext();\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tfoundMyContacts = true;\n\t\t\t\t\tgroupId = ContactsWidgetConfigurationActivity.CONTACT_MY_CONTACTS_GROUP_ID;\n\t\t\t\t\ttitle = myContacts;\n\t\t\t\t} else if (title.equalsIgnoreCase(starredContacts)\n\t\t\t\t\t\t|| STARRED_CONTACTS_ENG.equalsIgnoreCase(title)) {\n\t\t\t\t\tfoundStarredGroup = true;\n\t\t\t\t\tgroupId = ContactsWidgetConfigurationActivity.CONTACT_STARRED_GROUP_ID;\n\t\t\t\t}\n\t\t\t\tContactGroup group = new ContactGroup(groupId, accountName,\n\t\t\t\t\t\taccountType, title);\n\t\t\t\tgroups.add(group);\n\t\t\t\tcursor.moveToNext();\n\t\t\t}\n\t\t} finally {\n\t\t\tloader.stopLoading();\n\t\t\tif (cursor != null) {\n\t\t\t\tcursor.close();\n\t\t\t}\n\t\t}\n\t\tif (!foundStarredGroup) {\n\t\t\tContactGroup group = new ContactGroup(\n\t\t\t\t\tContactsWidgetConfigurationActivity.CONTACT_STARRED_GROUP_ID, starredContacts,\n\t\t\t\t\tnull, starredContacts);\n\t\t\tgroups.add(group);\n\t\t}\n\t\tif (!foundMyContacts) {\n\t\t\tContactGroup group = new ContactGroup(\n\t\t\t\t\tContactsWidgetConfigurationActivity.CONTACT_MY_CONTACTS_GROUP_ID, myContacts,\n\t\t\t\t\tnull, myContacts);\n\t\t\tgroups.add(group);\n\t\t}\n\t\treturn groups;\n\t}\n"} {"input": " void display(final List result) {\n all.clear();\n final FlexCellFormatter fmt = table.getFlexCellFormatter();\n table.setText(0, 0, PatchUtil.C.patchHeaderPatchSet());\n fmt.setStyleName(0, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(1, 0, PatchUtil.C.patchHeaderOld());\n fmt.setStyleName(1, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(2, 0, PatchUtil.C.patchHeaderNew());\n fmt.setStyleName(2, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(3, 0, Util.C.patchTableColumnComments());\n fmt.setStyleName(3, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(0, 1, PatchUtil.C.patchBase());\n fmt.setStyleName(0, 1, Gerrit.RESOURCES.css().dataCell());\n fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topMostCell());\n fmt.setStyleName(1, 1, Gerrit.RESOURCES.css().dataCell());\n fmt.setStyleName(2, 1, Gerrit.RESOURCES.css().dataCell());\n fmt.setStyleName(3, 1, Gerrit.RESOURCES.css().dataCell());\n installRadio(1, 1, null, screen.idSideA, 0);\n int col=2;\n for (final Patch k : result) {\n final PatchSet.Id psId = k.getKey().getParentKey();\n table.setText(0, col, String.valueOf(psId.get()));\n fmt.setStyleName(0, col, Gerrit.RESOURCES.css().patchHistoryTablePatchSetHeader());\n fmt.addStyleName(0, col, Gerrit.RESOURCES.css().dataCell());\n fmt.addStyleName(0, col, Gerrit.RESOURCES.css().topMostCell());\n installRadio(1, col, psId, screen.idSideA, 0);\n installRadio(2, col, psId, screen.idSideB, 1);\n fmt.setStyleName(3, col, Gerrit.RESOURCES.css().dataCell());\n if (k.getCommentCount() > 0) {\n table.setText(3, col, k.getCommentCount());\n }\n col++;\n }\n }\n", "output": " void display(final List result) {\n all.clear();\n final FlexCellFormatter fmt = table.getFlexCellFormatter();\n table.setText(0, 0, PatchUtil.C.patchHeaderPatchSet());\n fmt.setStyleName(0, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(1, 0, PatchUtil.C.patchHeaderOld());\n fmt.setStyleName(1, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(2, 0, PatchUtil.C.patchHeaderNew());\n fmt.setStyleName(2, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(3, 0, Util.C.patchTableColumnComments());\n fmt.setStyleName(3, 0, Gerrit.RESOURCES.css().dataHeader());\n table.setText(0, 1, PatchUtil.C.patchBase());\n fmt.setStyleName(0, 1, Gerrit.RESOURCES.css().dataCell());\n fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topMostCell());\n fmt.setStyleName(1, 1, Gerrit.RESOURCES.css().dataCell());\n fmt.setStyleName(2, 1, Gerrit.RESOURCES.css().dataCell());\n fmt.setStyleName(3, 1, Gerrit.RESOURCES.css().dataCell());\n installRadio(1, 1, null, screen.idSideA, 0);\n int col=2;\n for (final Patch k : result) {\n final PatchSet.Id psId = k.getKey().getParentKey();\n table.setText(0, col, String.valueOf(psId.get()));\n fmt.setStyleName(0, col, Gerrit.RESOURCES.css().patchHistoryTablePatchSetHeader());\n fmt.addStyleName(0, col, Gerrit.RESOURCES.css().dataCell());\n fmt.addStyleName(0, col, Gerrit.RESOURCES.css().topMostCell());\n installRadio(1, col, psId, screen.idSideA, 0);\n installRadio(2, col, psId, screen.idSideB, 1);\n fmt.setStyleName(3, col, Gerrit.RESOURCES.css().dataCell());\n if (k.getCommentCount() > 0) {\n table.setText(3, col, Integer.toString(k.getCommentCount()));\n }\n col++;\n }\n }\n"} {"input": "\tprivate Constructor getFirstMatchingConstructor(Object object) throws NoSuchMethodException {\n\t\tConstructor[] constructors = clazz.getDeclaredConstructors();\n\t\tConstructor constructor = null;\n\t\tfor (int i = 0; i < constructors.length; i++) {\n\t\t\tClass[] parameterTypes = constructors[i].getParameterTypes();\n\t\t\tif (parameterTypes.length == 1 && (object == null || parameterTypes[i].isInstance(object))) {\n\t\t\t\tconstructor = constructors[i];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (constructor == null) {\n\t\t\tif (object == null) {\n\t\t\t\tthrow new NoSuchMethodException(\"No constructor found that can take a single argument\");\n\t\t\t} else {\n\t\t\t\tthrow new NoSuchMethodException(\"No constructor found that can take a single argument of type \" + object.getClass());\n\t\t\t}\n\t\t}\n\t\treturn constructor;\n\t}\n", "output": "\tprivate Constructor getFirstMatchingConstructor(Object object) throws NoSuchMethodException {\n\t\tConstructor[] constructors = clazz.getDeclaredConstructors();\n\t\tConstructor constructor = null;\n\t\tfor (int i = 0; i < constructors.length; i++) {\n\t\t\tClass[] parameterTypes = constructors[i].getParameterTypes();\n\t\t\tif (parameterTypes.length == 1 && (object == null || parameterTypes[0].isInstance(object))) {\n\t\t\t\tconstructor = constructors[i];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (constructor == null) {\n\t\t\tif (object == null) {\n\t\t\t\tthrow new NoSuchMethodException(\"No constructor found that can take a single argument\");\n\t\t\t} else {\n\t\t\t\tthrow new NoSuchMethodException(\"No constructor found that can take a single argument of type \" + object.getClass());\n\t\t\t}\n\t\t}\n\t\treturn constructor;\n\t}\n"} {"input": " public static RuntimeDelegate getInstance() {\n if (delegate != null) {\n return delegate;\n }\n synchronized (RuntimeDelegate.class) {\n if (delegate != null) {\n return delegate;\n }\n ClassLoader classLoader = Thread.currentThread().getContextClassLoader();\n try {\n Object service = ProviderLocator.getService(RuntimeDelegate.class.getName(), RuntimeDelegate.class, classLoader);\n if (service != null) {\n delegate = (RuntimeDelegate)service;\n return delegate;\n }\n } catch (Exception ex) {\n } catch (Error ex) {\n }\n String className = null;\n try {\n className = ProviderLocator.lookupByJREPropertyFile(\"lib\" + File.separator + \"jaxrpc.properties\", RuntimeDelegate.class.getName());\n if (className != null) {\n Class delegateClass = ProviderLocator.loadClass(className,\n RuntimeDelegate.class, classLoader);\n delegate = (RuntimeDelegate)delegateClass.newInstance();\n return delegate;\n }\n } catch (IOException e) {\n } catch (ClassNotFoundException e) {\n } catch (InstantiationException e) {\n } catch (IllegalAccessException e) {\n }\n try {\n className = System.getProperty(\"javax.ws.rs.ext.RuntimeDelegate\");\n } catch (SecurityException e) {\n }\n if (className == null || \"\".equals(className)) {\n className = \"org.apache.wink.common.internal.runtime.RuntimeDelegateImpl\";\n }\n try {\n Class delegateClass = ProviderLocator.loadClass(className,\n RuntimeDelegate.class, classLoader);\n delegate = (RuntimeDelegate)delegateClass.newInstance();\n return delegate;\n } catch (ClassNotFoundException e1) {\n } catch (SecurityException e) {\n } catch (InstantiationException e) {\n } catch (IllegalAccessException e) {\n }\n return delegate;\n }\n }\n", "output": " public static RuntimeDelegate getInstance() {\n if (delegate != null) {\n return delegate;\n }\n synchronized (RuntimeDelegate.class) {\n if (delegate != null) {\n return delegate;\n }\n ClassLoader classLoader = Thread.currentThread().getContextClassLoader();\n try {\n Object service = ProviderLocator.getService(RuntimeDelegate.class.getName(), RuntimeDelegate.class, classLoader);\n if (service != null) {\n delegate = (RuntimeDelegate)service;\n return delegate;\n }\n } catch (Exception ex) {\n } catch (Error ex) {\n }\n String className = null;\n try {\n className = ProviderLocator.lookupByJREPropertyFile(\"lib\" + File.separator + \"jaxrpc.properties\", RuntimeDelegate.class.getName());\n if (className != null) {\n Class delegateClass = ProviderLocator.loadClass(className,\n RuntimeDelegate.class, classLoader);\n delegate = (RuntimeDelegate)delegateClass.newInstance();\n return delegate;\n }\n } catch (IOException e) {\n } catch (ClassNotFoundException e) {\n } catch (InstantiationException e) {\n } catch (IllegalAccessException e) {\n }\n try {\n className = System.getProperty(\"javax.ws.rs.ext.RuntimeDelegate\");\n } catch (SecurityException e) {\n }\n if (className == null || \"\".equals(className)) {\n className = \"org.apache.wink.common.internal.runtime.RuntimeDelegateImpl\";\n }\n try {\n Class delegateClass = ProviderLocator.loadClass(className,\n RuntimeDelegate.class, classLoader);\n delegate = (RuntimeDelegate)delegateClass.newInstance();\n return delegate;\n } catch (ClassNotFoundException e1) {\n } catch (SecurityException e) {\n } catch (InstantiationException e) {\n } catch (IllegalAccessException e) {\n }\n throw new RuntimeException(\"Unable to create jax-rs RuntimeDelegate\");\n }\n }\n"} {"input": "\tpublic static boolean checkUsername(String username) {\n\t\tusername = username.toLowerCase();\n\t\tboolean hasallowedchars = false;\n\t\tfor (String e : evil)\n\t\t\tif (username.contains(e)) return false;\n\t\tfor (String a : alpha)\n\t\t\tif (username.contains(a) && !hasallowedchars) hasallowedchars = true;\n\t\tConfiguration.log(\"So, username \" + username + \" was \" + Boolean.toString(hasallowedchars));\n\t\treturn hasallowedchars;\n\t}\n", "output": "\tpublic static boolean checkUsername(String username) {\n\t\tusername = username.toLowerCase();\n\t\tboolean hasallowedchars = false;\n\t\tif (username.trim().length() == 0) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (String e : evil)\n\t\t\tif (username.contains(e)) return false;\n\t\tfor (String a : alpha)\n\t\t\tif (username.contains(a) && !hasallowedchars) hasallowedchars = true;\n\t\tConfiguration.log(\"So, username \" + username + \" was \" + Boolean.toString(hasallowedchars));\n\t\treturn hasallowedchars;\n\t}\n"} {"input": "\tpublic static String getServerLocation() {\n\t\tif (!initialized) {\n\t\t\ttry {\n\t\t\t\tinitialize();\n\t\t\t\tensureBundleStarted(EQUINOX_HTTP_JETTY);\n\t\t\t\tensureBundleStarted(EQUINOX_HTTP_REGISTRY);\n\t\t\t\torg.eclipse.orion.server.authentication.Activator.getDefault();\n\t\t\t\tActivator.getDefault();\n\t\t\t\tConfiguratorActivator.getDefault();\n\t\t\t\twebapp = new WebApplication();\n\t\t\t\twebapp.start(null);\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn \"http://\" + serverHost + ':' + String.valueOf(serverPort);\n\t}\n", "output": "\tpublic static String getServerLocation() {\n\t\tif (!initialized) {\n\t\t\ttry {\n\t\t\t\tensureBundleStarted(EQUINOX_HTTP_JETTY);\n\t\t\t\tensureBundleStarted(EQUINOX_HTTP_REGISTRY);\n\t\t\t\torg.eclipse.orion.server.authentication.Activator.getDefault();\n\t\t\t\tActivator.getDefault();\n\t\t\t\tConfiguratorActivator.getDefault();\n\t\t\t\twebapp = new WebApplication();\n\t\t\t\twebapp.start(null);\n\t\t\t\tinitialize();\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn \"http://\" + serverHost + ':' + String.valueOf(serverPort);\n\t}\n"} {"input": " public void subsetFile(String infile, String outfile, Set columns,\n String delimiter) {\n try {\n Scanner scanner = new Scanner(new File(infile));\n dbgLog.fine(\"outfile=\"+outfile);\n BufferedWriter out = new BufferedWriter(new FileWriter(outfile));\n scanner.useDelimiter(\"\\\\n\");\n while (scanner.hasNext()) {\n String[] line = (scanner.next()).split(delimiter);\n if ((line.length <= 1) && (line[0].equals(\"\"))) {\n break;\n }\n List ln = new ArrayList();\n for (Integer i : columns) {\n ln.add(line[i]);\n }\n dbgLog.fine(StringUtils.join(ln,\"\\t\"));\n out.write(StringUtils.join(ln,\"\\t\")+\"\\n\");\n ln=null;\n }\n scanner.close();\n out.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n", "output": " public void subsetFile(String infile, String outfile, Set columns,\n String delimiter) {\n try {\n Scanner scanner = new Scanner(new File(infile));\n dbgLog.fine(\"outfile=\"+outfile);\n BufferedWriter out = new BufferedWriter(new FileWriter(outfile));\n scanner.useDelimiter(\"\\\\n\");\n while (scanner.hasNext()) {\n String[] line = (scanner.next()).split(delimiter,-1);\n List ln = new ArrayList();\n for (Integer i : columns) {\n ln.add(line[i]);\n }\n dbgLog.fine(StringUtils.join(ln,\"\\t\"));\n out.write(StringUtils.join(ln,\"\\t\")+\"\\n\");\n ln=null;\n }\n scanner.close();\n out.close();\n } catch (FileNotFoundException e) {\n e.printStackTrace();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n"} {"input": "\tpublic SensorData toSensorData(String jsonString)\n\t{\n\t\tJSONObject jsonData = super.parseData(jsonString);\n\t\tif (jsonData != null)\n\t\t{\n\t\t\tlong senseStartTimestamp = super.parseTimeStamp(jsonData);\n\t\t\tSensorConfig sensorConfig = super.getGenericConfig(jsonData);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tJSONArray xs = (JSONArray) jsonData.get(X_AXIS);\n\t\t\t\tJSONArray ys = (JSONArray) jsonData.get(Y_AXIS);\n\t\t\t\tJSONArray zs = (JSONArray) jsonData.get(Z_AXIS);\n\t\t\t\tArrayList sensorReadings = new ArrayList();\n\t\t\t\tfor (int i=0; i sensorReadingTimestamps = new ArrayList();\n\t\t\t\tfor (int i=0; i sensorReadings = new ArrayList();\n\t\t\t\tfor (int i=0; i sensorReadingTimestamps = new ArrayList();\n\t\t\t\tfor (int i=0; i getInitParameterNames() {\n Vector v = new Vector();\n v.add(\"a String\");\n return v.elements();\n }\n", "output": " public Enumeration getInitParameterNames() {\n Vector v = new Vector();\n v.add(ServletRequest.getInputString());\n return v.elements();\n }\n"} {"input": "\tpublic PageResponse process(Request request) {\n\t\tTwitter twitter = new TwitterFactory().getInstance();\n\t\tString q = \"dartford\";\n\t\tif (request.params().named(\"q\") != null) {\n\t\t\tq = request.params().named(\"q\").value;\n\t\t}\n\t\tQuery query = new Query(q);\n\t\tquery.setPage(1);\n\t\tQueryResult result = null;\n\t\tStringBuilder sb = new StringBuilder();\n\t\ttry {\n\t\t\tresult = twitter.search(query);\n\t\t\tsb.append(\"
Searching for \").append(q).append(\"
\");\n\t\t\tsb.append(\"
results\");\n\t\t\tsb.append((\"page \" + result.getPage()));\n\t\t\tfor (Tweet tweet : result.getTweets()) {\n\t\t\t\tsb.append(\"\\n\");\n\t\t\t\tsb.append(tweet.getCreatedAt() + \" - \" + tweet.getFromUser() + \":\" + tweet.getText() + \":\"\n\t\t\t\t\t\t+ tweet.getLocation());\n\t\t\t}\n\t\t\tsb.append(\"
\");\n\t\t} catch (TwitterException e) {\n\t\t\tsb.append(e.getMessage());\n\t\t}\n\t\treturn PageResponseFactory.text(sb.toString());\n\t}\n", "output": "\tpublic PageResponse process(Request request) {\n\t\tTwitter twitter = new TwitterFactory().getInstance();\n\t\tString q = \"dartford\";\n\t\tif (request.params().named(\"q\") != null) {\n\t\t\tq = request.params().named(\"q\").value;\n\t\t}\n\t\tQuery query = new Query(q);\n\t\tquery.setPage(1);\n\t\tQueryResult result = null;\n\t\tStringBuilder sb = new StringBuilder();\n\t\ttry {\n\t\t\tresult = twitter.search(query);\n\t\t\tsb.append(\"
Searching for \").append(q).append(\"
\");\n\t\t\tsb.append(\"
results\");\n\t\t\tsb.append((\"page \" + result.getPage()));\n\t\t\tfor (Object t : result.getTweets()) {\n\t\t\t\tTweet tweet = (Tweet)t;\n\t\t\t\tsb.append(\"\\n\");\n\t\t\t\tsb.append(tweet.getCreatedAt() + \" - \" + tweet.getFromUser() + \":\" + tweet.getText() + \":\"\n\t\t\t\t\t\t+ tweet.getLocation());\n\t\t\t}\n\t\t\tsb.append(\"
\");\n\t\t} catch (TwitterException e) {\n\t\t\tsb.append(e.getMessage());\n\t\t}\n\t\treturn PageResponseFactory.text(sb.toString());\n\t}\n"} {"input": " public boolean execute(Map parameters)\n throws ProcessExecutionException, IllegalArgumentException,\n InterruptedException {\n int exitValue = 0;\n AccessionParameter accession = new AccessionParameter();\n accession.setAccession(parameters.get(accessionParameter));\n String reportsDir =\n accession.getFile().getParentFile().getAbsolutePath() + File.separator +\n \"reports\";\n File reportsDirFile = new File(reportsDir);\n if (!reportsDirFile.exists()) {\n reportsDirFile.mkdirs();\n }\n String fileName = reportsDir + File.separator + accession.getAccession() +\n \"_AtlasEligibilityCheck\" +\n \"_\" + new SimpleDateFormat(\"yyyy-MM-dd_HH:mm:ss\").format(new Date()) +\n \".report\";\n try {\n log = new BufferedWriter(new FileWriter(fileName));\n log.write(\"Atlas Eligibility Check: START\\n\");\n }\n catch (IOException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Can't create report file '\" + fileName + \"'\");\n String[] errors = new String[1];\n errors[0] = \"Can't create report file '\" + fileName + \"'\";\n pex.setProcessOutput(errors);\n throw pex;\n }\n MAGETABParser parser = new MAGETABParser();\n try {\n MAGETABInvestigation investigation =\n parser.parse(accession.getFile().getAbsoluteFile());\n boolean isAtlasType = false;\n String restrictedExptType = \"\";\n if (investigation.IDF.getComments().containsKey(\"AEExperimentType\")) {\n for (String exptType : investigation.IDF.getComments()\n .get(\"AEExperimentType\")) {\n for (String AtlasType : controlledVocabularyDAO\n .getAtlasExperimentTypes()) {\n if (exptType.equals(AtlasType)) {\n isAtlasType = true;\n }\n else {\n restrictedExptType = exptType;\n }\n }\n }\n }\n else {\n for (String exptType : investigation.IDF.experimentalDesign) {\n for (String AtlasType : controlledVocabularyDAO\n .getAtlasExperimentTypes()) {\n if (exptType.equals(AtlasType)) {\n isAtlasType = true;\n }\n }\n }\n }\n if (!isAtlasType)\n {\n exitValue = 1;\n log.write(\n \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\\n\");\n System.out.println(\n \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\");\n String[] errors = new String[1];\n errors[0] = \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n else {\n if (investigation.SDRF.getNumberOfChannels() > 1) {\n exitValue = 1;\n log.write(\n \"Two-channel experiment is not accepted by Atlas\\n\");\n System.out.println(\n \"Two-channel experiment is not accepted by Atlas\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Two-channel experiment is not accepted by Atlas\");\n String[] errors = new String[1];\n errors[0] = \"Two-channel experiment is not accepted by Atlas\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n Collection hybridizationNodes =\n investigation.SDRF.getNodes(HybridizationNode.class);\n Collection rawDataNodes =\n investigation.SDRF.getNodes(ArrayDataNode.class);\n Collection processedDataNodes =\n investigation.SDRF.getNodes(DerivedArrayDataNode.class);\n Collection processedDataMatrixNodes =\n investigation.SDRF.getNodes(DerivedArrayDataMatrixNode.class);\n int factorValues = 0;\n for (HybridizationNode hybNode : hybridizationNodes)\n {\n if (hybNode.factorValues.size() > 0) {\n factorValues++;\n }\n ArrayDesignAccessions.clear();\n for (ArrayDesignAttribute arrayDesign : hybNode.arrayDesigns) {\n if (!ArrayDesignAccessions\n .contains(arrayDesign.getAttributeValue())) {\n ArrayDesignAccessions.add(arrayDesign.getAttributeValue());\n }\n }\n }\n if (factorValues == 0) {\n exitValue = 1;\n log.write(\n \"Experiment does not have Factor Values\\n\");\n System.out.println(\n \"Experiment does not have Factor Values\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Experiment does not have Factor Values\");\n String[] errors = new String[1];\n errors[0] = \"Experiment does not have Factor Values\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n boolean factorTypesFromCV = true;\n List missedFactorType = new ArrayList();\n for (String factorType : investigation.IDF.experimentalFactorType) {\n if (!controlledVocabularyDAO\n .getAtlasFactorTypes().contains(factorType)) {\n factorTypesFromCV = false;\n missedFactorType.add(factorType);\n }\n }\n if (!factorTypesFromCV) {\n exitValue = 1;\n log.write(\n \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType + \"\\n\");\n System.out.println(\n \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType);\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType);\n String[] errors = new String[1];\n errors[0] = \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType;\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n for (String arrayDesign : ArrayDesignAccessions) {\n ArrayDesignExistenceChecking arrayDesignExistenceChecking =\n new ArrayDesignExistenceChecking();\n String arrayCheckResult =\n arrayDesignExistenceChecking.execute(arrayDesign);\n if (arrayCheckResult.equals(\"empty\") ||\n arrayCheckResult.equals(\"no\")) {\n exitValue = 1;\n log.write(\"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\\n\");\n System.out.println(\"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\");\n String[] errors = new String[1];\n errors[0] = \"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n else {\n Collection hybridizationSubNodes =\n new ArrayList();\n Collection rawDataSubNodes = new ArrayList();\n Collection processedDataSubNodes = new ArrayList();\n Collection processedDataMatrixSubNodes =\n new ArrayList();\n if (ArrayDesignAccessions.size() > 1) {\n for (HybridizationNode hybNode : hybridizationNodes) {\n ArrayDesignAttribute attribute = new ArrayDesignAttribute();\n attribute.setAttributeValue(arrayDesign);\n if (hybNode.arrayDesigns.contains(attribute)) {\n hybridizationSubNodes.add(hybNode);\n getNodes(hybNode, ArrayDataNode.class, rawDataSubNodes);\n getNodes(hybNode, DerivedArrayDataNode.class,\n processedDataSubNodes);\n getNodes(hybNode, DerivedArrayDataMatrixNode.class,\n processedDataMatrixSubNodes);\n }\n }\n }\n else {\n hybridizationSubNodes = hybridizationNodes;\n for (ArrayDataNode node : rawDataNodes) {\n rawDataSubNodes.add(node);\n }\n for (DerivedArrayDataNode node : processedDataNodes) {\n processedDataSubNodes.add(node);\n }\n for (DerivedArrayDataMatrixNode node : processedDataMatrixNodes) {\n processedDataMatrixSubNodes.add(node);\n }\n }\n if (arrayCheckResult.equals(\"affy\") &&\n hybridizationSubNodes.size() != rawDataSubNodes.size())\n {\n exitValue = 1;\n log.write(\n \"Affymetrix experiment without raw data files\\n\");\n System.out.println(\n \"Affymetrix experiment without raw data files\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Affymetrix experiment without raw data files\");\n String[] errors = new String[1];\n errors[0] = \"Affymetrix experiment without raw data files\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n else\n if (processedDataSubNodes.size() == 0 &&\n processedDataMatrixSubNodes.size() == 0) {\n exitValue = 1;\n log.write(\n \"Non-Affymetrix experiment without processed data files\\n\");\n System.out.println(\n \"Non-Affymetrix experiment without processed data files\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Non-Affymetrix experiment without processed data files\");\n String[] errors = new String[1];\n errors[0] = \"Non-Affymetrix experiment without processed data files\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n }\n }\n }\n }\n catch (ParseException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n catch (IOException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n catch (RuntimeException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n finally {\n try {\n if (exitValue == 0) {\n log.write(\"Experiment \\\"\" +\n accession.getAccession() +\n \"\\\" is eligible for Atlas\\n\");\n }\n else {\n log.write(\"Experiment \\\"\" +\n accession.getAccession() +\n \"\\\" is NOT eligible for Atlas\\n\");\n }\n log.write(\"Atlas Eligibility Check: FINISHED\");\n log.write(\n \"Eligibility checks for Gene Expression Atlas version 2.0.9.3: \\n\" +\n \"1. Experiment has raw data for Affymetrix platforms or normalized data for all other platforms;\\n\" +\n \"2. Array design(s) used in experiment are loaded into Atlas;\\n\" +\n \"3. Type of experiment is from the list: \\n\" +\n \"transcription profiling by array,\\n\" +\n \"methylation profiling by array,\\n\" +\n \"tiling path by array,\\n\" +\n \"comparative genomic hybridization by array,\\n\" +\n \"microRNA profiling by array,\\n\" +\n \"RNAi profiling by array,\\n\" +\n \"ChIP-chip by array;\\n\" +\n \"4. Experiments is not two-channel;\\n\" +\n \"5. Experiment has factor values;\\n\" +\n \"6. Factor types are from controlled vocabulary.\");\n log.close();\n }\n catch (IOException e) {\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n }\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\"Something wrong in the code \");\n if (exitValue == 0) {\n return true;\n }\n else {\n String[] errors = new String[1];\n errors[0] = \"Something wrong in the code \";\n pex.setProcessOutput(errors);\n throw pex;\n }\n }\n", "output": " public boolean execute(Map parameters)\n throws ProcessExecutionException, IllegalArgumentException,\n InterruptedException {\n int exitValue = 0;\n AccessionParameter accession = new AccessionParameter();\n accession.setAccession(parameters.get(accessionParameter));\n String reportsDir =\n accession.getFile().getParentFile().getAbsolutePath() + File.separator +\n \"reports\";\n File reportsDirFile = new File(reportsDir);\n if (!reportsDirFile.exists()) {\n reportsDirFile.mkdirs();\n }\n String fileName = reportsDir + File.separator + accession.getAccession() +\n \"_AtlasEligibilityCheck\" +\n \"_\" + new SimpleDateFormat(\"yyyy-MM-dd_HH:mm:ss\").format(new Date()) +\n \".report\";\n try {\n log = new BufferedWriter(new FileWriter(fileName));\n log.write(\"Atlas Eligibility Check: START\\n\");\n }\n catch (IOException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Can't create report file '\" + fileName + \"'\");\n String[] errors = new String[1];\n errors[0] = \"Can't create report file '\" + fileName + \"'\";\n pex.setProcessOutput(errors);\n throw pex;\n }\n MAGETABParser parser = new MAGETABParser();\n try {\n MAGETABInvestigation investigation =\n parser.parse(accession.getFile().getAbsoluteFile());\n boolean isAtlasType = false;\n String restrictedExptType = \"\";\n if (investigation.IDF.getComments().containsKey(\"AEExperimentType\")) {\n for (String exptType : investigation.IDF.getComments()\n .get(\"AEExperimentType\")) {\n for (String AtlasType : controlledVocabularyDAO\n .getAtlasExperimentTypes()) {\n if (exptType.equals(AtlasType)) {\n isAtlasType = true;\n }\n else {\n restrictedExptType = exptType;\n }\n }\n }\n }\n else {\n for (String exptType : investigation.IDF.experimentalDesign) {\n for (String AtlasType : controlledVocabularyDAO\n .getAtlasExperimentTypes()) {\n if (exptType.equals(AtlasType)) {\n isAtlasType = true;\n }\n }\n }\n }\n if (!isAtlasType)\n {\n exitValue = 1;\n log.write(\n \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\\n\");\n System.out.println(\n \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\");\n String[] errors = new String[1];\n errors[0] = \"'Experiment Type' \" + restrictedExptType + \" is not accepted by Atlas\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n else {\n if (investigation.SDRF.getNumberOfChannels() > 1) {\n exitValue = 1;\n log.write(\n \"Two-channel experiment is not accepted by Atlas\\n\");\n System.out.println(\n \"Two-channel experiment is not accepted by Atlas\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Two-channel experiment is not accepted by Atlas\");\n String[] errors = new String[1];\n errors[0] = \"Two-channel experiment is not accepted by Atlas\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n Collection hybridizationNodes =\n investigation.SDRF.getNodes(HybridizationNode.class);\n Collection rawDataNodes =\n investigation.SDRF.getNodes(ArrayDataNode.class);\n Collection processedDataNodes =\n investigation.SDRF.getNodes(DerivedArrayDataNode.class);\n Collection processedDataMatrixNodes =\n investigation.SDRF.getNodes(DerivedArrayDataMatrixNode.class);\n int factorValues = 0;\n for (HybridizationNode hybNode : hybridizationNodes)\n {\n if (hybNode.factorValues.size() > 0) {\n factorValues++;\n }\n ArrayDesignAccessions.clear();\n for (ArrayDesignAttribute arrayDesign : hybNode.arrayDesigns) {\n if (!ArrayDesignAccessions\n .contains(arrayDesign.getAttributeValue())) {\n ArrayDesignAccessions.add(arrayDesign.getAttributeValue());\n }\n }\n }\n if (factorValues == 0) {\n exitValue = 1;\n log.write(\n \"Experiment does not have Factor Values\\n\");\n System.out.println(\n \"Experiment does not have Factor Values\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Experiment does not have Factor Values\");\n String[] errors = new String[1];\n errors[0] = \"Experiment does not have Factor Values\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n boolean factorTypesFromCV = true;\n List missedFactorType = new ArrayList();\n for (String factorType : investigation.IDF.experimentalFactorType) {\n if (!controlledVocabularyDAO\n .getAtlasFactorTypes().contains(factorType)) {\n factorTypesFromCV = false;\n missedFactorType.add(factorType);\n }\n }\n if (!factorTypesFromCV) {\n exitValue = 1;\n log.write(\n \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType + \"\\n\");\n System.out.println(\n \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType);\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType);\n String[] errors = new String[1];\n errors[0] = \"Experiment have Factor Types that are not in controlled vocabulary:\" +\n missedFactorType;\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n for (String arrayDesign : ArrayDesignAccessions) {\n ArrayDesignExistenceChecking arrayDesignExistenceChecking =\n new ArrayDesignExistenceChecking();\n String arrayCheckResult =\n arrayDesignExistenceChecking.execute(arrayDesign);\n if (arrayCheckResult.equals(\"empty\") ||\n arrayCheckResult.equals(\"no\")) {\n exitValue = 1;\n log.write(\"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\\n\");\n System.out.println(\"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\");\n String[] errors = new String[1];\n errors[0] = \"Array design '\" +\n arrayDesign +\n \"' used in experiment is not in Atlas\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n else {\n Collection hybridizationSubNodes =\n new ArrayList();\n Collection rawDataSubNodes = new ArrayList();\n Collection processedDataSubNodes = new ArrayList();\n Collection processedDataMatrixSubNodes =\n new ArrayList();\n if (ArrayDesignAccessions.size() > 1) {\n for (HybridizationNode hybNode : hybridizationNodes) {\n ArrayDesignAttribute attribute = new ArrayDesignAttribute();\n attribute.setAttributeValue(arrayDesign);\n if (hybNode.arrayDesigns.contains(attribute)) {\n hybridizationSubNodes.add(hybNode);\n getNodes(hybNode, ArrayDataNode.class, rawDataSubNodes);\n getNodes(hybNode, DerivedArrayDataNode.class,\n processedDataSubNodes);\n getNodes(hybNode, DerivedArrayDataMatrixNode.class,\n processedDataMatrixSubNodes);\n }\n }\n }\n else {\n hybridizationSubNodes = hybridizationNodes;\n for (ArrayDataNode node : rawDataNodes) {\n rawDataSubNodes.add(node);\n }\n for (DerivedArrayDataNode node : processedDataNodes) {\n processedDataSubNodes.add(node);\n }\n for (DerivedArrayDataMatrixNode node : processedDataMatrixNodes) {\n processedDataMatrixSubNodes.add(node);\n }\n }\n if (arrayCheckResult.equals(\"affy\") &&\n hybridizationSubNodes.size() != rawDataSubNodes.size())\n {\n exitValue = 1;\n log.write(\n \"Affymetrix experiment without raw data files\\n\");\n System.out.println(\n \"Affymetrix experiment without raw data files\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Affymetrix experiment without raw data files\");\n String[] errors = new String[1];\n errors[0] = \"Affymetrix experiment without raw data files\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n else\n if (!arrayCheckResult.equals(\"affy\") && processedDataSubNodes.size() == 0 &&\n processedDataMatrixSubNodes.size() == 0) {\n exitValue = 1;\n log.write(\n \"Non-Affymetrix experiment without processed data files\\n\");\n System.out.println(\n \"Non-Affymetrix experiment without processed data files\");\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n \"Non-Affymetrix experiment without processed data files\");\n String[] errors = new String[1];\n errors[0] = \"Non-Affymetrix experiment without processed data files\";\n pex.setExceptionCausesAbort();\n pex.setProcessOutput(errors);\n throw pex;\n }\n }\n }\n }\n }\n catch (ParseException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n catch (IOException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n catch (RuntimeException e) {\n exitValue = 1;\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n finally {\n try {\n if (exitValue == 0) {\n log.write(\"Experiment \\\"\" +\n accession.getAccession() +\n \"\\\" is eligible for Atlas\\n\");\n }\n else {\n log.write(\"Experiment \\\"\" +\n accession.getAccession() +\n \"\\\" is NOT eligible for Atlas\\n\");\n }\n log.write(\"Atlas Eligibility Check: FINISHED\\n\");\n log.write(\n \"Eligibility checks for Gene Expression Atlas version 2.0.9.3: \\n\" +\n \"1. Experiment has raw data for Affymetrix platforms or normalized data for all other platforms;\\n\" +\n \"2. Array design(s) used in experiment are loaded into Atlas;\\n\" +\n \"3. Type of experiment is from the list: \\n\" +\n \"transcription profiling by array,\\n\" +\n \"methylation profiling by array,\\n\" +\n \"tiling path by array,\\n\" +\n \"comparative genomic hybridization by array,\\n\" +\n \"microRNA profiling by array,\\n\" +\n \"RNAi profiling by array,\\n\" +\n \"ChIP-chip by array;\\n\" +\n \"4. Experiments is not two-channel;\\n\" +\n \"5. Experiment has factor values;\\n\" +\n \"6. Factor types are from controlled vocabulary.\");\n log.close();\n }\n catch (IOException e) {\n e.printStackTrace();\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\n e.getMessage());\n String[] errors = new String[1];\n errors[0] = e.getMessage();\n pex.setProcessOutput(errors);\n throw pex;\n }\n }\n ProcessExecutionException pex = new ProcessExecutionException(exitValue,\"Something wrong in the code \");\n if (exitValue == 0) {\n return true;\n }\n else {\n String[] errors = new String[1];\n errors[0] = \"Something wrong in the code \";\n pex.setProcessOutput(errors);\n throw pex;\n }\n }\n"} {"input": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_activity_details);\n\t\tIntent intent = getIntent();\n\t\tString from = intent.getStringExtra(C.DETAILS_FROM);\n\t\tButton continueButton = (Button) findViewById(R.id.details_continue_button);\n\t\tif (null == from){\n\t\t\tcontinueButton.setVisibility(View.GONE);\n\t\t}\n\t\telse{\n\t\t\tcontinueButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tmanageProject();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tlong activityId = intent.getLongExtra(\"activityId\", -1);\n\t\tUserActivitiesTableHelper helper = new UserActivitiesTableHelper(this);\n\t\tCursor activity = helper.getUserActivity(activityId);\n\t\tif (activity.moveToFirst()){\n\t\t\tTextView type = (TextView) findViewById(R.id.details_type);\n\t\t\ttype.setText(activity.getString(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_ACTIVITY)));\n\t\t\tTextView durationTextView = (TextView) findViewById(R.id.details__duration);\n\t\t\tlong duration = activity.getLong(activity.getColumnIndex(UserActivitiesTableHelper.COLUMN_DURATION));\n\t\t\tString durationStr = String.format(\" %02d:%02d'%d\\\"\", \n\t\t\t\t\tTimeUnit.MILLISECONDS.toHours(duration),\n\t\t\t\t TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)),\n\t\t\t\t TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.HOURS.toSeconds(TimeUnit.MILLISECONDS.toHours(duration)) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))\n\t\t\t);\n\t\t\tdurationTextView.setText(durationStr);\n\t\t\tTextView dateTextView = (TextView) findViewById(R.id.details_date);\n\t\t\tlong datetime = activity.getLong(activity.getColumnIndex(UserActivitiesTableHelper.COLUMN_DATETIME));\n\t\t\tDate date = new Date(datetime);\n\t\t\tDateFormat formatter = new SimpleDateFormat(\" MM/dd/yyyy 'at' HH:mm\");\n\t\t\tString dateFormatted = formatter.format(date);\n\t\t\tdateTextView.setText(dateFormatted);\n\t\t\tint[] base = {\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W1)),\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W2)),\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W3)),\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W4))\t\t\t\t\n\t\t\t};\n\t\t\tSharedPreferences prefs = getSharedPreferences(C.PREF, MODE_PRIVATE);\n\t\t\tint weight = prefs.getInt(C.P_WEIGHT, 0);\n\t\t\tint calories = CaloriesHelper.getCalories(weight, base, duration);\n\t\t\tTextView caloriesTextView = (TextView) findViewById(R.id.details_calories);\n\t\t\tcaloriesTextView.setText(String.valueOf(calories));\n\t\t}\n\t}\n", "output": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_activity_details);\n\t\tIntent intent = getIntent();\n\t\tString from = intent.getStringExtra(C.DETAILS_FROM);\n\t\tButton continueButton = (Button) findViewById(R.id.details_continue_button);\n\t\tif (null == from){\n\t\t\tcontinueButton.setVisibility(View.GONE);\n\t\t}\n\t\telse{\n\t\t\tcontinueButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tmanageProject();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tlong activityId = intent.getLongExtra(\"activityId\", -1);\n\t\tUserActivitiesTableHelper helper = new UserActivitiesTableHelper(this);\n\t\tCursor activity = helper.getUserActivity(activityId);\n\t\tif (activity.moveToFirst()){\n\t\t\tTextView type = (TextView) findViewById(R.id.details_type);\n\t\t\ttype.setText(activity.getString(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_ACTIVITY)));\n\t\t\tTextView durationTextView = (TextView) findViewById(R.id.details__duration);\n\t\t\tlong duration = activity.getLong(activity.getColumnIndex(UserActivitiesTableHelper.COLUMN_DURATION));\n\t\t\tString durationStr = String.format(\" %02d:%02d'%d\\\"\", \n\t\t\t\t\tTimeUnit.MILLISECONDS.toHours(duration),\n\t\t\t\t TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)),\n\t\t\t\t TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.HOURS.toSeconds(TimeUnit.MILLISECONDS.toHours(duration)) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration))\n\t\t\t);\n\t\t\tdurationTextView.setText(durationStr);\n\t\t\tTextView dateTextView = (TextView) findViewById(R.id.details_date);\n\t\t\tlong datetime = activity.getLong(activity.getColumnIndex(UserActivitiesTableHelper.COLUMN_DATETIME));\n\t\t\tDate date = new Date(datetime);\n\t\t\tDateFormat formatter = new SimpleDateFormat(\" MM/dd/yyyy 'at' HH:mm\");\n\t\t\tString dateFormatted = formatter.format(date);\n\t\t\tdateTextView.setText(dateFormatted);\n\t\t\tint[] base = {\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W1)),\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W2)),\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W3)),\n\t\t\t\t\tactivity.getInt(activity.getColumnIndex(ActivitiesTableHelper.COLUMN_W4))\t\t\t\t\n\t\t\t};\n\t\t\tSharedPreferences prefs = getSharedPreferences(C.PREF, MODE_PRIVATE);\n\t\t\tint weight = prefs.getInt(C.P_WEIGHT, 50);\n\t\t\tint calories = CaloriesHelper.getCalories(weight, base, duration);\n\t\t\tTextView caloriesTextView = (TextView) findViewById(R.id.details_calories);\n\t\t\tcaloriesTextView.setText(String.valueOf(calories));\n\t\t}\n\t}\n"} {"input": "\tprivate String convert_hyp_2_string(int sent_id, DerivationState cur, ArrayList l_models, String str_hyp_numeric, \n\t\t\tboolean extract_nbest_tree, boolean add_combined_score, double[] model_cost){\n\t\tString[] tem = str_hyp_numeric.split(\"\\\\s+\");\n\t\tStringBuffer str_hyp =new StringBuffer();\n\t\tif(sent_id>=0){\n\t\t\tstr_hyp.append(sent_id);\n\t\t\tstr_hyp.append(\" ||| \");\n\t\t}\n\t\tfor(int t=0; t 1e-2) {\n\t\t\t\t\tSystem.out.println(\"In nbest extraction, Cost does not match; cur.cost: \" + cur.cost + \"; temsum: \" +tem_sum);\n\t\t\t\t\tfor (int k = 0; k < model_cost.length; k++) {\n\t\t\t\t\t\tSystem.out.println(\"model weight: \" + l_models.get(k).getWeight() + \"; cost: \" +model_cost[k]);\n\t\t\t\t\t}\n\t\t\t\t\tSystem.exit(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(add_combined_score==true)\t\t\t\n\t\t\tstr_hyp.append(String.format(\" ||| %.3f\",-cur.cost));\n\t\tSystem.err.println(str_hyp.toString());\n\t\treturn str_hyp.toString();\n\t}\n", "output": "\tprivate String convert_hyp_2_string(int sent_id, DerivationState cur, ArrayList l_models, String str_hyp_numeric, \n\t\t\tboolean extract_nbest_tree, boolean add_combined_score, double[] model_cost){\n\t\tString[] tem = str_hyp_numeric.split(\"\\\\s+\");\n\t\tStringBuffer str_hyp =new StringBuffer();\n\t\tif(sent_id>=0){\n\t\t\tstr_hyp.append(sent_id);\n\t\t\tstr_hyp.append(\" ||| \");\n\t\t}\n\t\tfor(int t=0; t 1e-2) {\n\t\t\t\t\tSystem.out.println(\"In nbest extraction, Cost does not match; cur.cost: \" + cur.cost + \"; temsum: \" +tem_sum);\n\t\t\t\t\tfor (int k = 0; k < model_cost.length; k++) {\n\t\t\t\t\t\tSystem.out.println(\"model weight: \" + l_models.get(k).getWeight() + \"; cost: \" +model_cost[k]);\n\t\t\t\t\t}\n\t\t\t\t\tSystem.exit(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(add_combined_score==true)\t\t\t\n\t\t\tstr_hyp.append(String.format(\" ||| %.3f\",-cur.cost));\n\t\treturn str_hyp.toString();\n\t}\n"} {"input": " public static void sendSelfDisguise(final Player player) {\n try {\n if (!player.isValid()) {\n return;\n }\n Object world = ReflectionManager.getWorld(player.getWorld());\n Object tracker = world.getClass().getField(\"tracker\").get(world);\n Object trackedEntities = tracker.getClass().getField(\"trackedEntities\").get(tracker);\n Object entityTrackerEntry = trackedEntities.getClass().getMethod(\"get\", int.class)\n .invoke(trackedEntities, player.getEntityId());\n if (entityTrackerEntry == null) {\n Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {\n public void run() {\n sendSelfDisguise(player);\n }\n });\n return;\n }\n ((HashSet) entityTrackerEntry.getClass().getField(\"trackedPlayers\").get(entityTrackerEntry)).add(ReflectionManager\n .getNmsEntity(player));\n ProtocolManager manager = ProtocolLibrary.getProtocolManager();\n manager.sendServerPacket(player, manager.createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)\n .createPacket(player));\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),\n WrappedDataWatcher.getEntityWatcher(player), true).createPacket(player.getEntityId(),\n WrappedDataWatcher.getEntityWatcher(player), true));\n boolean isMoving = false;\n try {\n Field field = ReflectionManager.getNmsClass(\"EntityTrackerEntry\").getDeclaredField(\"isMoving\");\n field.setAccessible(true);\n isMoving = field.getBoolean(entityTrackerEntry);\n } catch (Exception ex) {\n ex.printStackTrace();\n }\n if (isMoving) {\n Vector velocity = player.getVelocity();\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_VELOCITY, player.getEntityId(),\n velocity.getX(), velocity.getY(), velocity.getZ()).createPacket(player.getEntityId(),\n velocity.getX(), velocity.getY(), velocity.getZ()));\n }\n if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {\n manager.sendServerPacket(player,\n manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())\n .createPacket(0, player, player.getVehicle()));\n } else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {\n manager.sendServerPacket(player,\n manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)\n .createPacket(0, player.getPassenger(), player));\n }\n for (int i = 0; i < 5; i++) {\n ItemStack item;\n if (i == 0) {\n item = player.getItemInHand();\n } else {\n item = player.getInventory().getArmorContents()[i - 1];\n }\n if (item != null && item.getType() != Material.AIR) {\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EQUIPMENT, player.getEntityId(), i,\n item).createPacket(player.getEntityId(), i, item));\n }\n }\n Location loc = player.getLocation();\n if (player.isSleeping()) {\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.BED, player, loc.getBlockX(), loc.getBlockY(),\n loc.getBlockZ()).createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));\n }\n Iterator iterator = player.getActivePotionEffects().iterator();\n while (iterator.hasNext()) {\n PotionEffect potionEffect = (PotionEffect) iterator.next();\n manager.sendServerPacket(player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect)\n .createPacket(player.getEntityId(), potionEffect));\n }\n } catch (Exception ex) {\n ex.printStackTrace();\n }\n }\n", "output": " public static void sendSelfDisguise(final Player player) {\n try {\n if (!player.isValid()) {\n return;\n }\n Object world = ReflectionManager.getWorld(player.getWorld());\n Object tracker = world.getClass().getField(\"tracker\").get(world);\n Object trackedEntities = tracker.getClass().getField(\"trackedEntities\").get(tracker);\n Object entityTrackerEntry = trackedEntities.getClass().getMethod(\"get\", int.class)\n .invoke(trackedEntities, player.getEntityId());\n if (entityTrackerEntry == null) {\n Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {\n public void run() {\n sendSelfDisguise(player);\n }\n });\n return;\n }\n int fakeId = selfDisguisesIds.get(player.getEntityId());\n ((HashSet) entityTrackerEntry.getClass().getField(\"trackedPlayers\").get(entityTrackerEntry)).add(ReflectionManager\n .getNmsEntity(player));\n ProtocolManager manager = ProtocolLibrary.getProtocolManager();\n manager.sendServerPacket(player, manager.createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)\n .createPacket(player));\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, fakeId,\n WrappedDataWatcher.getEntityWatcher(player), true).createPacket(fakeId,\n WrappedDataWatcher.getEntityWatcher(player), true));\n boolean isMoving = false;\n try {\n Field field = ReflectionManager.getNmsClass(\"EntityTrackerEntry\").getDeclaredField(\"isMoving\");\n field.setAccessible(true);\n isMoving = field.getBoolean(entityTrackerEntry);\n } catch (Exception ex) {\n ex.printStackTrace();\n }\n if (isMoving) {\n Vector velocity = player.getVelocity();\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_VELOCITY, fakeId, velocity.getX(),\n velocity.getY(), velocity.getZ()).createPacket(fakeId, velocity.getX(), velocity.getY(),\n velocity.getZ()));\n }\n if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {\n manager.sendServerPacket(player,\n manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())\n .createPacket(0, player, player.getVehicle()));\n } else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {\n manager.sendServerPacket(player,\n manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)\n .createPacket(0, player.getPassenger(), player));\n }\n for (int i = 0; i < 5; i++) {\n ItemStack item;\n if (i == 0) {\n item = player.getItemInHand();\n } else {\n item = player.getInventory().getArmorContents()[i - 1];\n }\n if (item != null && item.getType() != Material.AIR) {\n manager.sendServerPacket(player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EQUIPMENT, fakeId, i, item)\n .createPacket(fakeId, i, item));\n }\n }\n Location loc = player.getLocation();\n if (player.isSleeping()) {\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.BED, player, loc.getBlockX(), loc.getBlockY(),\n loc.getBlockZ()).createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));\n }\n Iterator iterator = player.getActivePotionEffects().iterator();\n while (iterator.hasNext()) {\n PotionEffect potionEffect = (PotionEffect) iterator.next();\n manager.sendServerPacket(\n player,\n manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, fakeId, potionEffect).createPacket(\n fakeId, potionEffect));\n }\n } catch (Exception ex) {\n ex.printStackTrace();\n }\n }\n"} {"input": " public KDTreeCell(Integer dimensions, Integer depth,\n ArrayList> points) throws KDTreeCellException {\n if (dimensions <= 0)\n throw new KDTreeCellWrongCreationArgumentException();\n if (depth < 0)\n throw new KDTreeCellWrongCreationArgumentException();\n if (points.size() != dimensions)\n throw new KDTreeCellWrongCreationArgumentException();\n this.dimensions = dimensions;\n this.splitDimension = depth % dimensions;\n this.depth = depth;\n if (points != null) {\n if (points.get(0).size() > 2) {\n ArrayList> leftPoints = new ArrayList>();\n ArrayList> rightPoints = new ArrayList>();\n ArrayList master = points.get(this.splitDimension);\n Integer medianID = master.size()/2;\n while (medianID >= 0 &&\n master.get(medianID)[this.splitDimension] == master.get(medianID-1)[this.splitDimension] )\n medianID--;\n Float[] median = master.get(medianID);\n this.point = new Float[this.dimensions];\n this.point = Arrays.copyOf(median, median.length);\n master.remove(median);\n for (int i = 0; i < this.dimensions; i++) {\n ArrayList left = new ArrayList();\n ArrayList right = new ArrayList();\n if (i == this.splitDimension) {\n left.addAll(master.subList(0, medianID));\n right.addAll(master.subList(medianID, master.size()));\n } else {\n ArrayList slave = points.get(i);\n for (Iterator it = slave.iterator(); it.hasNext();) {\n Float[] v = it.next();\n Integer j = -1;\n Float[] foundMedian = null;\n while (++j < this.dimensions) {\n if (v[j] != median[j]) continue;\n else if (j == this.dimensions-1)\n foundMedian = v;\n }\n if (foundMedian != null) {\n it.remove();\n continue;\n } else if (v[this.splitDimension] < median[this.splitDimension])\n left.add(v);\n else right.add(v);\n }\n }\n leftPoints.add(left);\n rightPoints.add(right);\n }\n this.children = new KDTreeCell[2];\n this.children[0] = new KDTreeCell(dimensions, depth+1, leftPoints);\n this.children[1] = new KDTreeCell(dimensions, depth+1, rightPoints);\n } else switch (points.get(0).size()) {\n case 2:\n ArrayList> leftPoints = new ArrayList>();\n ArrayList> rightPoints = new ArrayList>();\n for (int i = 0; i < this.dimensions; i++) {\n ArrayList temp = new ArrayList();\n temp.add(points.get(0).get(0));\n leftPoints.add(temp);\n rightPoints.add(temp);\n }\n this.children = new KDTreeCell[2];\n this.children[0] = new KDTreeCell(dimensions, depth+1, leftPoints);\n this.children[1] = new KDTreeCell(dimensions, depth+1, rightPoints);\n break;\n case 1:\n this.point = new Float[this.dimensions];\n Float[] leafPoint = points.get(0).get(0);\n this.point = Arrays.copyOf(leafPoint, leafPoint.length);\n this.children = null;\n break;\n case 0:\n this.children = null;\n this.point = null;\n break;\n }\n } else {\n this.children = null;\n this.point = null;\n }\n }\n", "output": " public KDTreeCell(Integer dimensions, Integer depth,\n ArrayList> points) throws KDTreeCellException {\n if (dimensions <= 0)\n throw new KDTreeCellWrongCreationArgumentException();\n if (depth < 0)\n throw new KDTreeCellWrongCreationArgumentException();\n if (points.size() != dimensions)\n throw new KDTreeCellWrongCreationArgumentException();\n this.dimensions = dimensions;\n this.splitDimension = depth % dimensions;\n this.depth = depth;\n if (points != null) {\n if (points.get(0).size() > 2) {\n ArrayList> leftPoints = new ArrayList>();\n ArrayList> rightPoints = new ArrayList>();\n ArrayList master = points.get(this.splitDimension);\n Integer medianID = master.size()/2;\n while (medianID > 0) {\n if (master.get(medianID-1)[this.splitDimension] >= master.get(medianID)[this.splitDimension]) medianID--;\n else break;\n }\n Float[] median = master.get(medianID);\n this.point = new Float[this.dimensions];\n this.point = Arrays.copyOf(median, median.length);\n master.remove(median);\n for (int i = 0; i < this.dimensions; i++) {\n ArrayList left = new ArrayList();\n ArrayList right = new ArrayList();\n if (i == this.splitDimension) {\n left.addAll(master.subList(0, medianID));\n right.addAll(master.subList(medianID, master.size()));\n } else {\n ArrayList slave = points.get(i);\n for (Iterator it = slave.iterator(); it.hasNext();) {\n Float[] v = it.next();\n Integer j = -1;\n Float[] foundMedian = null;\n while (++j < this.dimensions) {\n if (v[j] != median[j]) continue;\n if (j == this.dimensions-1)\n foundMedian = v;\n }\n if (foundMedian != null) {\n it.remove();\n continue;\n } else if (v[this.splitDimension] < median[this.splitDimension])\n left.add(v);\n else right.add(v);\n }\n }\n leftPoints.add(left);\n rightPoints.add(right);\n }\n this.children = new KDTreeCell[2];\n this.children[0] = new KDTreeCell(dimensions, depth+1, leftPoints);\n this.children[1] = new KDTreeCell(dimensions, depth+1, rightPoints);\n } else switch (points.get(0).size()) {\n case 2:\n ArrayList> leftPoints = new ArrayList>();\n ArrayList> rightPoints = new ArrayList>();\n for (int i = 0; i < this.dimensions; i++) {\n ArrayList temp = new ArrayList();\n temp.add(points.get(0).get(0));\n leftPoints.add(temp);\n rightPoints.add(temp);\n }\n this.children = new KDTreeCell[2];\n this.children[0] = new KDTreeCell(dimensions, depth+1, leftPoints);\n this.children[1] = new KDTreeCell(dimensions, depth+1, rightPoints);\n break;\n case 1:\n Float[] leafPoint = points.get(0).get(0);\n this.point = Arrays.copyOf(leafPoint, leafPoint.length);\n this.children = null;\n break;\n case 0:\n this.children = null;\n this.point = null;\n break;\n }\n } else {\n this.children = null;\n this.point = null;\n }\n }\n"} {"input": "\t\tvoid amqp() throws Throwable {\n\t\t\tfinal PushQueue dev_queue = Push.queue(\"push.p12\", \"pusubi\", false,\n\t\t\t\t\t1);\n\t\t\tdev_queue.start();\n\t\t\tfinal PushQueue prod_queue = Push.queue(\"pushprod.p12\", \"pusubi\",\n\t\t\t\t\ttrue, 1);\n\t\t\tprod_queue.start();\n\t\t\tfor (;;) {\n\t\t\t\tConnectionFactory connectionFactory = new ConnectionFactory();\n\t\t\t\tconnectionFactory.setHost(\"bumblebee.musubi.us\");\n\t\t\t\tconnectionFactory.setConnectionTimeout(30 * 1000);\n\t\t\t\tconnectionFactory.setRequestedHeartbeat(30);\n\t\t\t\tConnection connection = connectionFactory.newConnection();\n\t\t\t\tmIncomingChannel = connection.createChannel();\n\t\t\t\tmConsumer = new DefaultConsumer(mIncomingChannel) {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void handleDelivery(final String consumerTag,\n\t\t\t\t\t\t\tfinal Envelope envelope,\n\t\t\t\t\t\t\tfinal BasicProperties properties, final byte[] body)\n\t\t\t\t\t\t\tthrows IOException {\n\t\t\t\t\t\tHashSet threadDevices = new HashSet();\n\t\t\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\t\t\tString identity = mConsumers.get(consumerTag);\n\t\t\t\t\t\t\tif (identity == null)\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\tHashSet devices = mNotifiers.get(identity);\n\t\t\t\t\t\t\tif (devices == null)\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\tthreadDevices.addAll(devices);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tMessage m = null;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tm = mMapper.readValue(body, Message.class);\n\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\tnew RuntimeException(\n\t\t\t\t\t\t\t\t\t\"Failed to parse BSON of outer message\", e)\n\t\t\t\t\t\t\t\t\t.printStackTrace();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (m.l)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tString sender_exchange;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tsender_exchange = encodeAMQPname(\"ibeidentity-\",\n\t\t\t\t\t\t\t\t\tnew IBHashedIdentity(m.s.i).at(0).identity_);\n\t\t\t\t\t\t} catch (CorruptIdentity e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tDate now = new Date();\n\t\t\t\t\t\tfor (String device : threadDevices) {\n\t\t\t\t\t\t\tListener l;\n\t\t\t\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\t\t\t\tl = mListeners.get(device);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (l.identityExchanges.contains(sender_exchange))\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tint new_value = 0;\n\t\t\t\t\t\t\tint amqp = 0;\n\t\t\t\t\t\t\tint local = 0;\n\t\t\t\t\t\t\tDate last;\n\t\t\t\t\t\t\tsynchronized (mCounts) {\n\t\t\t\t\t\t\t\tBadgeData bd = mCounts.get(device);\n\t\t\t\t\t\t\t\tif (bd == null) {\n\t\t\t\t\t\t\t\t\tbd = new BadgeData();\n\t\t\t\t\t\t\t\t\tmCounts.put(device, bd);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbd.amqp++;\n\t\t\t\t\t\t\t\tamqp = bd.amqp;\n\t\t\t\t\t\t\t\tlocal = bd.local;\n\t\t\t\t\t\t\t\tnew_value = bd.amqp + bd.local;\n\t\t\t\t\t\t\t\tlast = bd.last;\n\t\t\t\t\t\t\t\tif (bd.last == null) {\n\t\t\t\t\t\t\t\t\tbd.last = now;\n\t\t\t\t\t\t\t\t} else if (bd.last != null\n\t\t\t\t\t\t\t\t\t\t&& now.getTime() - bd.last.getTime() > 3 * 60 * 1000) {\n\t\t\t\t\t\t\t\t\tbd.last = now;\n\t\t\t\t\t\t\t\t\tlast = null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (l.platform.equals(\"android\")) {\n\t\t\t\t\t\t\t\tcom.google.android.gcm.server.Message message = new com.google.android.gcm.server.Message.Builder()\n\t\t\t\t\t\t\t\t\t\t.addData(\"amqp\", Integer.toString(amqp))\n\t\t\t\t\t\t\t\t\t\t.build();\n\t\t\t\t\t\t\t\tmGooglePushes.add(Pair.of(message, device));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tboolean production = l.production != null\n\t\t\t\t\t\t\t\t\t\t\t&& l.production != false;\n\t\t\t\t\t\t\t\t\tPushNotificationPayload payload = PushNotificationPayload\n\t\t\t\t\t\t\t\t\t\t\t.complex();\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tif (last == null) {\n\t\t\t\t\t\t\t\t\t\t\tpayload.addAlert(\"New message\");\n\t\t\t\t\t\t\t\t\t\t\tpayload.addSound(\"default\");\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tpayload.addBadge(new_value);\n\t\t\t\t\t\t\t\t\t\tpayload.addCustomDictionary(\"local\",\n\t\t\t\t\t\t\t\t\t\t\t\tlocal);\n\t\t\t\t\t\t\t\t\t\tpayload.addCustomDictionary(\"amqp\",\n\t\t\t\t\t\t\t\t\t\t\t\tamqp);\n\t\t\t\t\t\t\t\t\t} catch (JSONException e) {\n\t\t\t\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\t\t\t\tSystem.exit(1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (!production)\n\t\t\t\t\t\t\t\t\t\tdev_queue.add(payload, device);\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tprod_queue.add(payload, device);\n\t\t\t\t\t\t\t\t} catch (InvalidDeviceTokenFormatException e) {\n\t\t\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tSystem.out.println(\"doing registrations\");\n\t\t\t\tSet notifiers = new HashSet();\n\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\tnotifiers.addAll(mNotifiers.keySet());\n\t\t\t\t}\n\t\t\t\tfor (String identity : notifiers) {\n\t\t\t\t\tDeclareOk x = mIncomingChannel.queueDeclare();\n\t\t\t\t\tSystem.out.println(\"listening \" + identity);\n\t\t\t\t\tmIncomingChannel.exchangeDeclare(identity, \"fanout\", true);\n\t\t\t\t\tmIncomingChannel.queueBind(x.getQueue(), identity, \"\");\n\t\t\t\t\tString consumerTag = mIncomingChannel.basicConsume(\n\t\t\t\t\t\t\tx.getQueue(), true, mConsumer);\n\t\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\t\tmQueues.put(identity, x.getQueue());\n\t\t\t\t\t\tmConsumers.put(consumerTag, identity);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tSystem.out.println(\"done registrations\");\n\t\t\t\tlong last = new Date().getTime();\n\t\t\t\tfor (;;) {\n\t\t\t\t\tRunnable job = mJobs.poll(60, TimeUnit.SECONDS);\n\t\t\t\t\tlong current = new Date().getTime();\n\t\t\t\t\tif (current - last > 60 * 1000) {\n\t\t\t\t\t\tPushedNotifications ps = dev_queue\n\t\t\t\t\t\t\t\t.getPushedNotifications();\n\t\t\t\t\t\tfor (PushedNotification p : ps) {\n\t\t\t\t\t\t\tif (p.isSuccessful())\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tString invalidToken = p.getDevice().getToken();\n\t\t\t\t\t\t\tSystem.err.println(\"unregistering invalid token \"\n\t\t\t\t\t\t\t\t\t+ invalidToken);\n\t\t\t\t\t\t\tunregister(invalidToken);\n\t\t\t\t\t\t\tException theProblem = p.getException();\n\t\t\t\t\t\t\ttheProblem.printStackTrace();\n\t\t\t\t\t\t\tResponsePacket theErrorResponse = p.getResponse();\n\t\t\t\t\t\t\tif (theErrorResponse != null) {\n\t\t\t\t\t\t\t\tSystem.out.println(theErrorResponse\n\t\t\t\t\t\t\t\t\t\t.getMessage());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlast = new Date().getTime();\n\t\t\t\t\t\tList inactiveDevices = Push.feedback(\n\t\t\t\t\t\t\t\t\"push.p12\", \"pusubi\", false);\n\t\t\t\t\t\tfor (Device d : inactiveDevices) {\n\t\t\t\t\t\t\tString invalidToken = d.getToken();\n\t\t\t\t\t\t\tSystem.err\n\t\t\t\t\t\t\t\t\t.println(\"unregistering feedback failed token token \"\n\t\t\t\t\t\t\t\t\t\t\t+ invalidToken);\n\t\t\t\t\t\t\tunregister(invalidToken);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (job == null)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tjob.run();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n", "output": "\t\tvoid amqp() throws Throwable {\n\t\t\tfinal PushQueue dev_queue = Push.queue(\"push.p12\", \"pusubi\", false,\n\t\t\t\t\t1);\n\t\t\tdev_queue.start();\n\t\t\tfinal PushQueue prod_queue = Push.queue(\"pushprod.p12\", \"pusubi\",\n\t\t\t\t\ttrue, 1);\n\t\t\tprod_queue.start();\n\t\t\tfor (;;) {\n\t\t\t\tConnectionFactory connectionFactory = new ConnectionFactory();\n\t\t\t\tconnectionFactory.setHost(\"bumblebee.musubi.us\");\n\t\t\t\tconnectionFactory.setConnectionTimeout(30 * 1000);\n\t\t\t\tconnectionFactory.setRequestedHeartbeat(30);\n\t\t\t\tConnection connection = connectionFactory.newConnection();\n\t\t\t\tmIncomingChannel = connection.createChannel();\n\t\t\t\tmConsumer = new DefaultConsumer(mIncomingChannel) {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void handleDelivery(final String consumerTag,\n\t\t\t\t\t\t\tfinal Envelope envelope,\n\t\t\t\t\t\t\tfinal BasicProperties properties, final byte[] body)\n\t\t\t\t\t\t\tthrows IOException {\n\t\t\t\t\t\tHashSet threadDevices = new HashSet();\n\t\t\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\t\t\tString identity = mConsumers.get(consumerTag);\n\t\t\t\t\t\t\tif (identity == null)\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\tHashSet devices = mNotifiers.get(identity);\n\t\t\t\t\t\t\tif (devices == null)\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\tthreadDevices.addAll(devices);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tMessage m = null;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tm = mMapper.readValue(body, Message.class);\n\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\tnew RuntimeException(\n\t\t\t\t\t\t\t\t\t\"Failed to parse BSON of outer message\", e)\n\t\t\t\t\t\t\t\t\t.printStackTrace();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (m.l)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tString sender_exchange;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tsender_exchange = encodeAMQPname(\"ibeidentity-\",\n\t\t\t\t\t\t\t\t\tnew IBHashedIdentity(m.s.i).at(0).identity_);\n\t\t\t\t\t\t} catch (CorruptIdentity e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tDate now = new Date();\n\t\t\t\t\t\tfor (String device : threadDevices) {\n\t\t\t\t\t\t\tListener l;\n\t\t\t\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\t\t\t\tl = mListeners.get(device);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (l.identityExchanges.contains(sender_exchange))\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tint new_value = 0;\n\t\t\t\t\t\t\tint amqp = 0;\n\t\t\t\t\t\t\tint local = 0;\n\t\t\t\t\t\t\tDate last;\n\t\t\t\t\t\t\tsynchronized (mCounts) {\n\t\t\t\t\t\t\t\tBadgeData bd = mCounts.get(device);\n\t\t\t\t\t\t\t\tif (bd == null) {\n\t\t\t\t\t\t\t\t\tbd = new BadgeData();\n\t\t\t\t\t\t\t\t\tmCounts.put(device, bd);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbd.amqp++;\n\t\t\t\t\t\t\t\tamqp = bd.amqp;\n\t\t\t\t\t\t\t\tlocal = bd.local;\n\t\t\t\t\t\t\t\tnew_value = bd.amqp + bd.local;\n\t\t\t\t\t\t\t\tlast = bd.last;\n\t\t\t\t\t\t\t\tif (bd.last == null) {\n\t\t\t\t\t\t\t\t\tbd.last = now;\n\t\t\t\t\t\t\t\t} else if (bd.last != null\n\t\t\t\t\t\t\t\t\t\t&& now.getTime() - bd.last.getTime() > 3 * 60 * 1000) {\n\t\t\t\t\t\t\t\t\tbd.last = now;\n\t\t\t\t\t\t\t\t\tlast = null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (l.platform != null && l.platform.equals(\"android\")) {\n\t\t\t\t\t\t\t\tcom.google.android.gcm.server.Message message = new com.google.android.gcm.server.Message.Builder()\n\t\t\t\t\t\t\t\t\t\t.addData(\"amqp\", Integer.toString(amqp))\n\t\t\t\t\t\t\t\t\t\t.build();\n\t\t\t\t\t\t\t\tmGooglePushes.add(Pair.of(message, device));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tboolean production = l.production != null\n\t\t\t\t\t\t\t\t\t\t\t&& l.production != false;\n\t\t\t\t\t\t\t\t\tPushNotificationPayload payload = PushNotificationPayload\n\t\t\t\t\t\t\t\t\t\t\t.complex();\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tif (last == null) {\n\t\t\t\t\t\t\t\t\t\t\tpayload.addAlert(\"New message\");\n\t\t\t\t\t\t\t\t\t\t\tpayload.addSound(\"default\");\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tpayload.addBadge(new_value);\n\t\t\t\t\t\t\t\t\t\tpayload.addCustomDictionary(\"local\",\n\t\t\t\t\t\t\t\t\t\t\t\tlocal);\n\t\t\t\t\t\t\t\t\t\tpayload.addCustomDictionary(\"amqp\",\n\t\t\t\t\t\t\t\t\t\t\t\tamqp);\n\t\t\t\t\t\t\t\t\t} catch (JSONException e) {\n\t\t\t\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\t\t\t\tSystem.exit(1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (!production)\n\t\t\t\t\t\t\t\t\t\tdev_queue.add(payload, device);\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tprod_queue.add(payload, device);\n\t\t\t\t\t\t\t\t} catch (InvalidDeviceTokenFormatException e) {\n\t\t\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tSystem.out.println(\"doing registrations\");\n\t\t\t\tSet notifiers = new HashSet();\n\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\tnotifiers.addAll(mNotifiers.keySet());\n\t\t\t\t}\n\t\t\t\tfor (String identity : notifiers) {\n\t\t\t\t\tDeclareOk x = mIncomingChannel.queueDeclare();\n\t\t\t\t\tSystem.out.println(\"listening \" + identity);\n\t\t\t\t\tmIncomingChannel.exchangeDeclare(identity, \"fanout\", true);\n\t\t\t\t\tmIncomingChannel.queueBind(x.getQueue(), identity, \"\");\n\t\t\t\t\tString consumerTag = mIncomingChannel.basicConsume(\n\t\t\t\t\t\t\tx.getQueue(), true, mConsumer);\n\t\t\t\t\tsynchronized (mNotifiers) {\n\t\t\t\t\t\tmQueues.put(identity, x.getQueue());\n\t\t\t\t\t\tmConsumers.put(consumerTag, identity);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tSystem.out.println(\"done registrations\");\n\t\t\t\tlong last = new Date().getTime();\n\t\t\t\tfor (;;) {\n\t\t\t\t\tRunnable job = mJobs.poll(60, TimeUnit.SECONDS);\n\t\t\t\t\tlong current = new Date().getTime();\n\t\t\t\t\tif (current - last > 60 * 1000) {\n\t\t\t\t\t\tPushedNotifications ps = dev_queue\n\t\t\t\t\t\t\t\t.getPushedNotifications();\n\t\t\t\t\t\tfor (PushedNotification p : ps) {\n\t\t\t\t\t\t\tif (p.isSuccessful())\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tString invalidToken = p.getDevice().getToken();\n\t\t\t\t\t\t\tSystem.err.println(\"unregistering invalid token \"\n\t\t\t\t\t\t\t\t\t+ invalidToken);\n\t\t\t\t\t\t\tunregister(invalidToken);\n\t\t\t\t\t\t\tException theProblem = p.getException();\n\t\t\t\t\t\t\ttheProblem.printStackTrace();\n\t\t\t\t\t\t\tResponsePacket theErrorResponse = p.getResponse();\n\t\t\t\t\t\t\tif (theErrorResponse != null) {\n\t\t\t\t\t\t\t\tSystem.out.println(theErrorResponse\n\t\t\t\t\t\t\t\t\t\t.getMessage());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlast = new Date().getTime();\n\t\t\t\t\t\tList inactiveDevices = Push.feedback(\n\t\t\t\t\t\t\t\t\"push.p12\", \"pusubi\", false);\n\t\t\t\t\t\tfor (Device d : inactiveDevices) {\n\t\t\t\t\t\t\tString invalidToken = d.getToken();\n\t\t\t\t\t\t\tSystem.err\n\t\t\t\t\t\t\t\t\t.println(\"unregistering feedback failed token token \"\n\t\t\t\t\t\t\t\t\t\t\t+ invalidToken);\n\t\t\t\t\t\t\tunregister(invalidToken);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (job == null)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tjob.run();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n"} {"input": "\tpublic Change createChange(IProgressMonitor pm) throws CoreException {\n\t\tif (fMethodName == null)\n\t\t\treturn null;\n\t\tpm.beginTask(\"\", 2); \n\t\ttry {\n\t\t\tChangeRecorder cr = new ChangeRecorder(fRoot);\n\t\t\tNode[] nodes = fAnalyzer.getSelectedNodes();\n\t\t\tboolean isExpr = fAnalyzer.isExpressionSelected();\n\t\t\tMap renamings = new HashMap();\n\t\t\tfor (ParameterInfo parameter : fParameterInfos)\n\t\t\t\tif (parameter.isRenamed())\n\t\t\t\t\trenamings.put(parameter.getOldName(),parameter.getNewName());\n\t\t\tfor (Node node : nodes) {\n\t\t\t\tList oldNames = VariableLookup.findReferences(node, renamings.keySet());\n\t\t\t\tfor (Identifier ref : oldNames) {\n\t\t\t\t\tref.setName(renamings.get(ref.getName()));\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tCallExpression invocation= DomFactory.eINSTANCE.createCallExpression();\n\t\t\t{\n\t\t\t\tVariableReference ref = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\tIdentifier id = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\tid.setName(fMethodName);\n\t\t\t\tref.setVariable(id);\n\t\t\t\tinvocation.setApplicant(ref);\n\t\t\t}\n\t\t\tfor (ParameterInfo parameter : fParameterInfos) {\n\t\t\t\tIdentifier name = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\tname.setName(parameter.getOldName());\n\t\t\t\tVariableReference local = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\tlocal.setVariable(name);\n\t\t\t\tinvocation.getArguments().add(local);\n\t\t\t}\n\t\t\tif (isExpr) {\n\t\t\t\tEReference ref = nodes[0].eContainmentFeature();\n\t\t\t\tif (ref.isMany()) {\n\t\t\t\t\tEList exprList = (EList)nodes[0].eContainer().eGet(ref);\n\t\t\t\t\texprList.set(exprList.lastIndexOf(nodes[0]), (Expression)invocation);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[0].eContainer().eSet(ref, invocation);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tNode call;\n\t\t\t\tint returnKind= fAnalyzer.getReturnKind();\n\t\t\t\tswitch (returnKind) {\n\t\t\t\tcase ExtractMethodAnalyzer.ACCESS_TO_LOCAL:\n\t\t\t\t\tVariableBinding binding= fAnalyzer.getReturnLocal();\n\t\t\t\t\tif (binding != null) {\n\t\t\t\t\t\tcall = createDeclaration(binding, invocation);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tBinaryExpression assignment= DomFactory.eINSTANCE.createBinaryExpression();\n\t\t\t\t\t\tassignment.setOperation(BinaryOperator.ASSIGN);\n\t\t\t\t\t\tVariableReference retVar = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\t\t\tIdentifier id = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\t\t\tid.setName(fAnalyzer.getReturnValue().getName());\n\t\t\t\t\t\tretVar.setVariable(id);\n\t\t\t\t\t\tassignment.setLeft(retVar);\n\t\t\t\t\t\tassignment.setRight(invocation);\n\t\t\t\t\t\tcall = assignment;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ExtractMethodAnalyzer.RETURN_STATEMENT_VALUE:\n\t\t\t\t\tReturnStatement rs=DomFactory.eINSTANCE.createReturnStatement();\n\t\t\t\t\trs.setExpression(invocation);\n\t\t\t\t\tcall = rs;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tcall = invocation;\n\t\t\t\t}\n\t\t\t\tif (call instanceof Expression) {\n\t\t\t\t\tExpressionStatement stmt = DomFactory.eINSTANCE.createExpressionStatement();\n\t\t\t\t\tstmt.setExpression((Expression)call);\n\t\t\t\t\tcall = stmt;\n\t\t\t\t}\n\t\t\t\tList callNodes= new ArrayList(2);\n\t\t\t\tcallNodes.add((Statement)call);\n\t\t\t\tif (returnKind == ExtractMethodAnalyzer.RETURN_STATEMENT_VOID && !fAnalyzer.isLastStatementSelected()) {\n\t\t\t\t\tcallNodes.add(DomFactory.eINSTANCE.createReturnStatement());\n\t\t\t\t}\n\t\t\t\tfor (VariableBinding local : fAnalyzer.getCallerLocals())\n\t\t\t\t\tcallNodes.add(createDeclaration(local, null));\n\t\t\t\tEReference ref = nodes[0].eContainmentFeature();\n\t\t\t\tif (ref.isMany()) {\n\t\t\t\t\tEList list = (EList)nodes[0].eContainer().eGet(ref);\n\t\t\t\t\tint index = list.lastIndexOf(nodes[0]);\n\t\t\t\t\tfor(int i=nodes.length-1;i>=0;i--)\n\t\t\t\t\t\tlist.remove(index+i);\n\t\t\t\t\tlist.addAll(index, callNodes);\n\t\t\t\t} else if (callNodes.size() == 1) {\n\t\t\t\t\tnodes[0].eContainer().eSet(ref, callNodes.get(0));\n\t\t\t\t} else {\n\t\t\t\t\tBlockStatement block = DomFactory.eINSTANCE.createBlockStatement();\n\t\t\t\t\tblock.getStatements().addAll(callNodes);\n\t\t\t\t\tnodes[0].eContainer().eSet(ref, block);\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tFunctionExpression mm = createNewMethodDeclaration();\n\t\t\tList statements = mm.getBody().getStatements();\n\t\t\tVariableBinding[] methodLocals= fAnalyzer.getMethodLocals();\n\t\t\tfor (int i= 0; i < methodLocals.length; i++) {\n\t\t\t\tif (methodLocals[i] != null)\n\t\t\t\t\tstatements.add(createDeclaration(methodLocals[i],null));\n\t\t\t}\n\t\t\tif (isExpr) {\n\t\t\t\tReturnStatement rs = DomFactory.eINSTANCE.createReturnStatement();\n\t\t\t\trs.setExpression((Expression)nodes[0]);\n\t\t\t\tstatements.add(rs);\n\t\t\t} else {\n\t\t\t\tfor(Node node : nodes) \n\t\t\t\t\tstatements.add((Statement)node);\n\t\t\t\tVariableBinding returnValue= fAnalyzer.getReturnValue();\n\t\t\t\tif (returnValue != null) {\n\t\t\t\t\tReturnStatement rs = DomFactory.eINSTANCE.createReturnStatement();\n\t\t\t\t\tVariableReference ret = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\t\tIdentifier rid = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\t\tString name = returnValue.getName();\n\t\t\t\t\tif (renamings.containsKey(name))\n\t\t\t\t\t\tname = renamings.get(name);\n\t\t\t\t\trid.setName(name);\n\t\t\t\t\tret.setVariable(rid);\n\t\t\t\t\trs.setExpression(ret);\n\t\t\t\t\tstatements.add(rs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tExpressionStatement stmt = DomFactory.eINSTANCE.createExpressionStatement();\n\t\t\tstmt.setExpression(mm);\n\t\t\tNode enclosing = fDestination;\n\t\t\tEReference ref = enclosing.eContainmentFeature();\n\t\t\tassert ref.isMany();\n\t\t\tEList list = (EList)enclosing.eContainer().eGet(ref);\n\t\t\tlist.add(list.lastIndexOf(enclosing),stmt);\n\t\t\tChangeDescription cd = cr.endRecording();\n\t\t\tRewriteAnalyzer ra = new RewriteAnalyzer(cd, fSource);\n\t\t\tSourceModuleChange result= new SourceModuleChange(RefactoringCoreMessages.ExtractMethodRefactoring_change_name, fCUnit);\n\t\t\tra.rewrite(fRoot);\n\t\t\tresult.setSaveMode(TextFileChange.KEEP_SAVE_STATE);\n\t\t\tresult.setDescriptor(new RefactoringChangeDescriptor(getRefactoringDescriptor()));\n\t\t\tresult.setEdit(ra.getEdit());\n\t\t\tcd.apply();\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tpm.done();\n\t\t}\n\t}\n", "output": "\tpublic Change createChange(IProgressMonitor pm) throws CoreException {\n\t\tif (fMethodName == null)\n\t\t\treturn null;\n\t\tpm.beginTask(\"\", 2); \n\t\ttry {\n\t\t\tChangeRecorder cr = new ChangeRecorder(fRoot);\n\t\t\tNode[] nodes = fAnalyzer.getSelectedNodes();\n\t\t\tboolean isExpr = fAnalyzer.isExpressionSelected();\n\t\t\tMap renamings = new HashMap();\n\t\t\tfor (ParameterInfo parameter : fParameterInfos)\n\t\t\t\tif (parameter.isRenamed())\n\t\t\t\t\trenamings.put(parameter.getOldName(),parameter.getNewName());\n\t\t\tfor (Node node : nodes) {\n\t\t\t\tList oldNames = VariableLookup.findReferences(node, renamings.keySet());\n\t\t\t\tfor (Identifier ref : oldNames) {\n\t\t\t\t\tref.setName(renamings.get(ref.getName()));\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tCallExpression invocation= DomFactory.eINSTANCE.createCallExpression();\n\t\t\t{\n\t\t\t\tVariableReference ref = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\tIdentifier id = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\tid.setName(fMethodName);\n\t\t\t\tref.setVariable(id);\n\t\t\t\tinvocation.setApplicant(ref);\n\t\t\t}\n\t\t\tfor (ParameterInfo parameter : fParameterInfos) {\n\t\t\t\tIdentifier name = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\tname.setName(parameter.getOldName());\n\t\t\t\tVariableReference local = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\tlocal.setVariable(name);\n\t\t\t\tinvocation.getArguments().add(local);\n\t\t\t}\n\t\t\tif (isExpr) {\n\t\t\t\tEReference ref = nodes[0].eContainmentFeature();\n\t\t\t\tif (ref.isMany()) {\n\t\t\t\t\tEList exprList = (EList)nodes[0].eContainer().eGet(ref);\n\t\t\t\t\texprList.set(exprList.lastIndexOf(nodes[0]), (Expression)invocation);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[0].eContainer().eSet(ref, invocation);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tNode call;\n\t\t\t\tint returnKind= fAnalyzer.getReturnKind();\n\t\t\t\tswitch (returnKind) {\n\t\t\t\tcase ExtractMethodAnalyzer.ACCESS_TO_LOCAL:\n\t\t\t\t\tVariableBinding binding= fAnalyzer.getReturnLocal();\n\t\t\t\t\tif (binding != null) {\n\t\t\t\t\t\tcall = createDeclaration(binding, invocation);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tBinaryExpression assignment= DomFactory.eINSTANCE.createBinaryExpression();\n\t\t\t\t\t\tassignment.setOperation(BinaryOperator.ASSIGN);\n\t\t\t\t\t\tVariableReference retVar = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\t\t\tIdentifier id = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\t\t\tid.setName(fAnalyzer.getReturnValue().getName());\n\t\t\t\t\t\tretVar.setVariable(id);\n\t\t\t\t\t\tassignment.setLeft(retVar);\n\t\t\t\t\t\tassignment.setRight(invocation);\n\t\t\t\t\t\tcall = assignment;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase ExtractMethodAnalyzer.RETURN_STATEMENT_VALUE:\n\t\t\t\t\tReturnStatement rs=DomFactory.eINSTANCE.createReturnStatement();\n\t\t\t\t\trs.setExpression(invocation);\n\t\t\t\t\tcall = rs;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tcall = invocation;\n\t\t\t\t}\n\t\t\t\tif (call instanceof Expression) {\n\t\t\t\t\tExpressionStatement stmt = DomFactory.eINSTANCE.createExpressionStatement();\n\t\t\t\t\tstmt.setExpression((Expression)call);\n\t\t\t\t\tcall = stmt;\n\t\t\t\t}\n\t\t\t\tList callNodes= new ArrayList(2);\n\t\t\t\tcallNodes.add((Statement)call);\n\t\t\t\tif (returnKind == ExtractMethodAnalyzer.RETURN_STATEMENT_VOID && !fAnalyzer.isLastStatementSelected()) {\n\t\t\t\t\tcallNodes.add(DomFactory.eINSTANCE.createReturnStatement());\n\t\t\t\t}\n\t\t\t\tfor (VariableBinding local : fAnalyzer.getCallerLocals())\n\t\t\t\t\tcallNodes.add(createDeclaration(local, null));\n\t\t\t\tEReference ref = nodes[0].eContainmentFeature();\n\t\t\t\tif (ref.isMany()) {\n\t\t\t\t\tEList list = (EList)nodes[0].eContainer().eGet(ref);\n\t\t\t\t\tint index = list.lastIndexOf(nodes[0]);\n\t\t\t\t\tfor(int i=nodes.length-1;i>=0;i--)\n\t\t\t\t\t\tlist.remove(index+i);\n\t\t\t\t\tlist.addAll(index, callNodes);\n\t\t\t\t} else if (callNodes.size() == 1) {\n\t\t\t\t\tnodes[0].eContainer().eSet(ref, callNodes.get(0));\n\t\t\t\t} else {\n\t\t\t\t\tBlockStatement block = DomFactory.eINSTANCE.createBlockStatement();\n\t\t\t\t\tblock.getStatements().addAll(callNodes);\n\t\t\t\t\tnodes[0].eContainer().eSet(ref, block);\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\tFunctionExpression mm = createNewMethodDeclaration();\n\t\t\tList statements = mm.getBody().getStatements();\n\t\t\tVariableBinding[] methodLocals= fAnalyzer.getMethodLocals();\n\t\t\tfor (int i= 0; i < methodLocals.length; i++) {\n\t\t\t\tif (methodLocals[i] != null)\n\t\t\t\t\tstatements.add(createDeclaration(methodLocals[i],null));\n\t\t\t}\n\t\t\tif (isExpr) {\n\t\t\t\tReturnStatement rs = DomFactory.eINSTANCE.createReturnStatement();\n\t\t\t\trs.setExpression((Expression)nodes[0]);\n\t\t\t\tstatements.add(rs);\n\t\t\t} else {\n\t\t\t\tfor(Node node : nodes) \n\t\t\t\t\tstatements.add((Statement)node);\n\t\t\t\tVariableBinding returnValue= fAnalyzer.getReturnValue();\n\t\t\t\tif (returnValue != null) {\n\t\t\t\t\tReturnStatement rs = DomFactory.eINSTANCE.createReturnStatement();\n\t\t\t\t\tVariableReference ret = DomFactory.eINSTANCE.createVariableReference();\n\t\t\t\t\tIdentifier rid = DomFactory.eINSTANCE.createIdentifier();\n\t\t\t\t\tString name = returnValue.getName();\n\t\t\t\t\tif (renamings.containsKey(name))\n\t\t\t\t\t\tname = renamings.get(name);\n\t\t\t\t\trid.setName(name);\n\t\t\t\t\tret.setVariable(rid);\n\t\t\t\t\trs.setExpression(ret);\n\t\t\t\t\tstatements.add(rs);\n\t\t\t\t}\n\t\t\t}\n\t\t\tExpressionStatement stmt = DomFactory.eINSTANCE.createExpressionStatement();\n\t\t\tstmt.setExpression(mm);\n\t\t\tNode enclosing = fDestination;\n\t\t\tEReference ref = enclosing.eContainmentFeature();\n\t\t\tassert ref.isMany();\n\t\t\tEList list = (EList)enclosing.eContainer().eGet(ref);\n\t\t\tlist.add(list.lastIndexOf(enclosing)+1,stmt);\n\t\t\tChangeDescription cd = cr.endRecording();\n\t\t\tRewriteAnalyzer ra = new RewriteAnalyzer(cd, fSource);\n\t\t\tSourceModuleChange result= new SourceModuleChange(RefactoringCoreMessages.ExtractMethodRefactoring_change_name, fCUnit);\n\t\t\tra.rewrite(fRoot);\n\t\t\tresult.setSaveMode(TextFileChange.KEEP_SAVE_STATE);\n\t\t\tresult.setDescriptor(new RefactoringChangeDescriptor(getRefactoringDescriptor()));\n\t\t\tresult.setEdit(ra.getEdit());\n\t\t\tcd.apply();\n\t\t\treturn result;\n\t\t} finally {\n\t\t\tpm.done();\n\t\t}\n\t}\n"} {"input": " public static void main(String args[]) throws InterruptedException {\n if (args.length != 1) {\n System.err.println(\"Usage: java TestPingers hostname\");\n System.exit(2);\n }\n ClientInfo this_client = new ClientInfo(ClientInfo.m_cookie_name+\"={user=bobafett;uuid=fatalapouet};path=/;expires=eventually\");\n if (this_client.getNickname() == null)\n this_client.setNickname(\"bobafett\");\n InetAddress my_local_addr = this_client.getAddress();\n InetAddress my_global_addr = null;\n try {\n my_global_addr = this_client.getExternalAddress();\n }\n catch (RuntimeException e) {\n System.err.println(\"Warning: could not get external address.\");\n }\n InetAddress target = null;\n try {\n target = InetAddress.getByName(args[0]);\n }\n catch (UnknownHostException e) {\n System.err.println(\"Error: could not get address for host '\" + args[0] + \"'.\");\n System.exit(1);\n }\n if (target != null) {\n System.out.println(\"\\nStarting pings...\");\n TcpPinger this_tcp_pinger = new TcpPinger(this_client);\n IcmpPinger this_pinger = new IcmpPinger(this_client);\n TraceRouter this_router = new TraceRouter(this_client);\n String text_local_addr = my_local_addr.toString().split(\"/\")[1];\n String text_global_addr;\n if (my_global_addr != null)\n text_global_addr = my_global_addr.toString().split(\"/\")[1];\n else\n text_global_addr = \"\";\n this_pinger.ping(target);\n System.out.println(text_local_addr + \" \" +\n text_global_addr + \" \" +\n this_pinger.getLastPings());\n this_router.trace(target);\n System.out.println(text_local_addr + \" \" +\n text_global_addr + \" \" +\n this_router.getLastTrace());\n this_tcp_pinger.ping(target,50);\n System.out.println(text_local_addr + \" \" +\n text_global_addr + \" \" +\n this_tcp_pinger.getLastPings());\n }\n System.out.println(this_client.getPreferences());\n }\n", "output": " public static void main(String args[]) throws InterruptedException {\n if (args.length != 1) {\n System.err.println(\"Usage: java TestPingers hostname\");\n System.exit(2);\n }\n ClientInfo this_client = new ClientInfo(ClientInfo.m_cookie_name+\"={user=bobafett;uuid=fatalapouet};path=/;expires=eventually\");\n if (this_client.getNickname() == null)\n this_client.setNickname(\"bobafett\");\n InetAddress my_local_addr = this_client.getAddress();\n InetAddress my_global_addr = null;\n try {\n my_global_addr = this_client.getExternalAddress();\n }\n catch (RuntimeException e) {\n System.err.println(\"Warning: could not get external address.\");\n }\n InetAddress target = null;\n try {\n target = InetAddress.getByName(args[0]);\n }\n catch (UnknownHostException e) {\n System.err.println(\"Error: could not get address for host '\" + args[0] + \"'.\");\n System.exit(1);\n }\n if (target != null) {\n System.out.println(\"\\nStarting pings...\");\n TcpPinger this_tcp_pinger = new TcpPinger(this_client);\n IcmpPinger this_pinger = new IcmpPinger(this_client);\n TraceRouter this_router = new TraceRouter(this_client);\n String text_local_addr = my_local_addr.toString().split(\"/\")[1];\n String text_global_addr;\n if (my_global_addr != null)\n text_global_addr = my_global_addr.toString().split(\"/\")[1];\n else\n text_global_addr = \"\";\n this_pinger.probe(target);\n System.out.println(text_local_addr + \" \" +\n text_global_addr + \" \" +\n this_pinger.getLastProbe());\n this_router.probe(target);\n System.out.println(text_local_addr + \" \" +\n text_global_addr + \" \" +\n this_router.getLastProbe());\n this_tcp_pinger.probe(target,50);\n System.out.println(text_local_addr + \" \" +\n text_global_addr + \" \" +\n this_tcp_pinger.getLastProbe());\n }\n System.out.println(this_client.getPreferences());\n }\n"} {"input": "\tpublic IProofObligationList caseAExplicitFunctionDefinition(\n\t\t\tAExplicitFunctionDefinition node, IPOContextStack question)\n\t\t\tthrows AnalysisException\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (node.getBody() instanceof ANotYetSpecifiedExp)\n\t\t\t{\n\t\t\t\treturn new ProofObligationList();\n\t\t\t}\n\t\t\tIProofObligationList obligations = new ProofObligationList();\n\t\t\tLexNameList pids = new LexNameList();\n\t\t\tAFunctionType ftype = (AFunctionType) node.getType();\n\t\t\tboolean alwaysMatches = true;\n\t\t\tfor (List params : node.getParamPatternList())\n\t\t\t{\n\t\t\t\talwaysMatches = params.isEmpty() && alwaysMatches;\n\t\t\t}\n\t\t\tif (alwaysMatches)\n\t\t\t{\n\t\t\t} else\n\t\t\t{\n\t\t\t\talwaysMatches = false;\n\t\t\t\tPatternAlwaysMatchesVisitor amVisitor = new PatternAlwaysMatchesVisitor();\n\t\t\t\tfor (List patterns : node.getParamPatternList())\n\t\t\t\t\tfor (PPattern p : patterns)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (PDefinition def : p.getDefinitions())\n\t\t\t\t\t\t\tpids.add(def.getName());\n\t\t\t\t\t\talwaysMatches = alwaysMatches && p.apply(amVisitor);\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tif (pids.hasDuplicates() || !alwaysMatches)\n\t\t\t{\n\t\t\t\tobligations.add(new ParameterPatternObligation(node, question));\n\t\t\t}\n\t\t\tPExp precondition = node.getPrecondition();\n\t\t\tif (precondition != null)\n\t\t\t{\n\t\t\t\tquestion.push(new POFunctionDefinitionContext(node, false));\n\t\t\t\tobligations.addAll(precondition.apply(rootVisitor, question));\n\t\t\t\tquestion.pop();\n\t\t\t}\n\t\t\tPExp postcondition = node.getPostcondition();\n\t\t\tif (postcondition != null)\n\t\t\t{\n\t\t\t\tquestion.push(new POFunctionDefinitionContext(node, false));\n\t\t\t\tobligations.add(new FuncPostConditionObligation(node, question));\n\t\t\t\tquestion.push(new POFunctionResultContext(node));\n\t\t\t\tobligations.addAll(postcondition.apply(rootVisitor, question));\n\t\t\t\tquestion.pop();\n\t\t\t\tquestion.pop();\n\t\t\t}\n\t\t\tquestion.push(new POFunctionDefinitionContext(node, true));\n\t\t\tPExp body = node.getBody();\n\t\t\tint sizeBefore = question.size();\n\t\t\tobligations.addAll(body.apply(rootVisitor, question));\n\t\t\tassert sizeBefore <= question.size();\n\t\t\tif (node.getIsUndefined()\n\t\t\t\t\t|| !TypeComparator.isSubType(node.getActualResult(), node.getExpectedResult()))\n\t\t\t{\n\t\t\t\tSubTypeObligation sto = SubTypeObligation.newInstance(node, node.getExpectedResult(), node.getActualResult(), question);\n\t\t\t\tif (sto != null)\n\t\t\t\t{\n\t\t\t\t\tobligations.add(sto);\n\t\t\t\t}\n\t\t\t}\n\t\t\tquestion.pop();\n\t\t\treturn obligations;\n\t\t} catch (Exception e)\n\t\t{\n\t\t\tthrow new POException(node, e.getMessage());\n\t\t}\n\t}\n", "output": "\tpublic IProofObligationList caseAExplicitFunctionDefinition(\n\t\t\tAExplicitFunctionDefinition node, IPOContextStack question)\n\t\t\tthrows AnalysisException\n\t{\n\t\ttry\n\t\t{\n\t\t\tif (node.getBody() instanceof ANotYetSpecifiedExp)\n\t\t\t{\n\t\t\t\treturn new ProofObligationList();\n\t\t\t}\n\t\t\tIProofObligationList obligations = new ProofObligationList();\n\t\t\tLexNameList pids = new LexNameList();\n\t\t\tAFunctionType ftype = (AFunctionType) node.getType();\n\t\t\tboolean alwaysMatches = true;\n\t\t\tfor (List params : node.getParamPatternList())\n\t\t\t{\n\t\t\t\talwaysMatches = params.isEmpty() && alwaysMatches;\n\t\t\t}\n\t\t\tif (alwaysMatches)\n\t\t\t{\n\t\t\t} else\n\t\t\t{\n\t\t\t\talwaysMatches = true;\n\t\t\t\tPatternAlwaysMatchesVisitor amVisitor = new PatternAlwaysMatchesVisitor();\n\t\t\t\tfor (List patterns : node.getParamPatternList())\n\t\t\t\t\tfor (PPattern p : patterns)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (PDefinition def : p.getDefinitions())\n\t\t\t\t\t\t\tpids.add(def.getName());\n\t\t\t\t\t\talwaysMatches = alwaysMatches && p.apply(amVisitor);\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tif (pids.hasDuplicates() || !alwaysMatches)\n\t\t\t{\n\t\t\t\tobligations.add(new ParameterPatternObligation(node, question));\n\t\t\t}\n\t\t\tPExp precondition = node.getPrecondition();\n\t\t\tif (precondition != null)\n\t\t\t{\n\t\t\t\tquestion.push(new POFunctionDefinitionContext(node, false));\n\t\t\t\tobligations.addAll(precondition.apply(rootVisitor, question));\n\t\t\t\tquestion.pop();\n\t\t\t}\n\t\t\tPExp postcondition = node.getPostcondition();\n\t\t\tif (postcondition != null)\n\t\t\t{\n\t\t\t\tquestion.push(new POFunctionDefinitionContext(node, false));\n\t\t\t\tobligations.add(new FuncPostConditionObligation(node, question));\n\t\t\t\tquestion.push(new POFunctionResultContext(node));\n\t\t\t\tobligations.addAll(postcondition.apply(rootVisitor, question));\n\t\t\t\tquestion.pop();\n\t\t\t\tquestion.pop();\n\t\t\t}\n\t\t\tquestion.push(new POFunctionDefinitionContext(node, true));\n\t\t\tPExp body = node.getBody();\n\t\t\tint sizeBefore = question.size();\n\t\t\tobligations.addAll(body.apply(rootVisitor, question));\n\t\t\tassert sizeBefore <= question.size();\n\t\t\tif (node.getIsUndefined()\n\t\t\t\t\t|| !TypeComparator.isSubType(node.getActualResult(), node.getExpectedResult()))\n\t\t\t{\n\t\t\t\tSubTypeObligation sto = SubTypeObligation.newInstance(node, node.getExpectedResult(), node.getActualResult(), question);\n\t\t\t\tif (sto != null)\n\t\t\t\t{\n\t\t\t\t\tobligations.add(sto);\n\t\t\t\t}\n\t\t\t}\n\t\t\tquestion.pop();\n\t\t\treturn obligations;\n\t\t} catch (Exception e)\n\t\t{\n\t\t\tthrow new POException(node, e.getMessage());\n\t\t}\n\t}\n"} {"input": "\tpublic static boolean parse(byte[] buffer, HarleyData hd) {\n\t\tbyte[] in;\n\t\tint x;\n\t\tint y;\n\t\tin = bytes_to_hex(buffer);\n\t\tif (crc(in) != (byte)0xc4) {\n\t\t\thd.setBadCRC(buffer);\n\t\t\treturn false;\n\t\t}\n\t\tx = y = 0;\n\t\tif (in.length >= 4)\n\t\t\tx = ((in[0] << 24) & 0xff000000) |\n\t\t\t ((in[1] << 16) & 0x00ff0000) |\n\t\t\t ((in[2] << 8) & 0x0000ff00) |\n\t\t\t (in[3] & 0x000000ff);\n\t\tif (in.length >= 6)\n\t\t\ty = ((in[4] << 8) & 0x0000ff00) |\n\t\t\t (in[5] & 0x000000ff);\n\t\tif (x == 0x281b1002)\n\t\t\thd.setRPM(y);\n\t\telse if (x == 0x48291002)\n\t\t\thd.setSpeed(y);\n\t\telse if (x == 0xa8491010)\n\t\t\thd.setEngineTemp((int)in[4] & 0xff);\n\t\telse if (x == 0xa83b1003) {\n\t\t\tif (in[4] != 0) {\n\t\t\t\tint gear = 0;\n\t\t\t\twhile ((in[4] >>= 1) != 0)\n\t\t\t\t\tgear++;\n\t\t\t\thd.setGear(gear);\n\t\t\t} else\n\t\t\t\thd.setGear(-1);\n\t\t} else if ((x == 0x48da4039) && ((in[4] & 0xfc) == 0))\n\t\t\thd.setTurnSignals(in[4] & 0x03);\n\t\telse if ((x & 0xffffff7f) == 0xa8691006) {\n\t\t\todolast = y - odolast;\n\t\t\tif (odolast < 0)\t\n\t\t\t\todolast += 65536;\n\t\t\todoaccum += odolast;\n\t\t\todolast = y;\n\t\t\thd.setOdometer(odoaccum);\n\t\t} else if ((x & 0xffffff7f) == 0xa883100a) {\n\t\t\tfuellast = y - fuellast;\n\t\t\tif (fuellast < 0)\t\n\t\t\t\tfuellast += 65536;\n\t\t\tfuelaccum += fuellast;\n\t\t\tfuellast = y;\n\t\t\thd.setFuel(fuelaccum);\n\t\t} else if ((x == 0xa8836112) && ((in[4] & 0xd0) == 0xd0))\n\t\t\thd.setFuelGauge(in[4] & 0x0f);\n\t\telse if ((x & 0xffffff5d) == 0x483b4000) {\n\t\t\tif ((in[3] & 0x20) == 0x20)\n\t\t\t\thd.setNeutral(false);\n\t\t\telse if ((in[3] & 0xa0) == 0xa0)\n\t\t\t\thd.setNeutral(true);\n\t\t\thd.setClutch((in[3] & 0x80) != 0);\n\t\t} else if ((x & 0xffffff7f) == 0x68881003) {\n\t\t\tif ((in[3] & 0x80) != 0)\n\t\t\t\thd.setCheckEngine(true);\n\t\t\telse\n\t\t\t\thd.setCheckEngine(false);\n\t\t} else if (x == 0x0c10f13c) {\n\t\t} else if (x == 0x0cf1107c) {\n\t\t\tswitch (in[4]) {\n\t\t\tcase 0x01:\n\t\t\t\tSystem.arraycopy(in, 5, ecmPN, 0, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x02:\n\t\t\t\tSystem.arraycopy(in, 5, ecmPN, 6, 6);\n\t\t\t\thd.setECMPN(new String(ecmPN).trim());\n\t\t\t\tbreak;\n\t\t\tcase 0x03:\n\t\t\t\tSystem.arraycopy(in, 5, ecmCalID, 0, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x04:\n\t\t\t\tSystem.arraycopy(in, 5, ecmCalID, 6, 6);\n\t\t\t\thd.setECMCalID(new String(ecmCalID).trim());\n\t\t\t\tbreak;\n\t\t\tcase 0x0b:\n\t\t\t\thd.setECMSWLevel((int)in[5] & 0xff);\n\t\t\t\tbreak;\n\t\t\tcase 0x0f:\n\t\t\t\tSystem.arraycopy(in, 5, vin, 0, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x10:\n\t\t\t\tSystem.arraycopy(in, 5, vin, 6, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x11:\n\t\t\t\tSystem.arraycopy(in, 5, vin, 12, 5);\n\t\t\t\thd.setVIN(new String(vin).trim());\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\thd.setUnknown(buffer);\n\t\t\t}\n\t\t} else if (x == 0x6cfef119)\n\t\t\tif (D) Log.d(TAG, \"DTC start\");\n\t\telse if ((x & 0xffff0fff) == 0x6cf10059) {\n\t\t\tint dtc = (((int)in[4] & 0xff) << 8) | ((int)in[5] & 0xff);\n\t\t\tif (in[2] == 0x10) {\n\t\t\t\tif (D) Log.d(TAG, \"historic DTC: 0x\" + Integer.toString(dtc, 16));\n\t\t\t\thd.addHistoricDTC(dtc);\n\t\t\t} else if (in[2] == 0x40) {\n\t\t\t\tif (D) Log.d(TAG, \"current DTC: 0x\" + Integer.toString(dtc, 16));\n\t\t\t\thd.addCurrentDTC(dtc);\n\t\t\t} else\n\t\t\t\thd.setUnknown(buffer);\n\t\t} else if (x == 0x6c10f114)\n\t\t\tif (D) Log.d(TAG, \"DTC clear\");\n\t\telse\n\t\t\thd.setUnknown(buffer);\n\t\treturn true;\n\t}\n", "output": "\tpublic static boolean parse(byte[] buffer, HarleyData hd) {\n\t\tbyte[] in;\n\t\tint x;\n\t\tint y;\n\t\tin = bytes_to_hex(buffer);\n\t\thd.setRaw(buffer);\n\t\tif (crc(in) != (byte)0xc4) {\n\t\t\thd.setBadCRC(buffer);\n\t\t\treturn false;\n\t\t}\n\t\tx = y = 0;\n\t\tif (in.length >= 4)\n\t\t\tx = ((in[0] << 24) & 0xff000000) |\n\t\t\t ((in[1] << 16) & 0x00ff0000) |\n\t\t\t ((in[2] << 8) & 0x0000ff00) |\n\t\t\t (in[3] & 0x000000ff);\n\t\tif (in.length >= 6)\n\t\t\ty = ((in[4] << 8) & 0x0000ff00) |\n\t\t\t (in[5] & 0x000000ff);\n\t\tif (x == 0x281b1002)\n\t\t\thd.setRPM(y);\n\t\telse if (x == 0x48291002)\n\t\t\thd.setSpeed(y);\n\t\telse if (x == 0xa8491010)\n\t\t\thd.setEngineTemp((int)in[4] & 0xff);\n\t\telse if (x == 0xa83b1003) {\n\t\t\tif (in[4] != 0) {\n\t\t\t\tint gear = 0;\n\t\t\t\twhile ((in[4] >>= 1) != 0)\n\t\t\t\t\tgear++;\n\t\t\t\thd.setGear(gear);\n\t\t\t} else\n\t\t\t\thd.setGear(-1);\n\t\t} else if ((x == 0x48da4039) && ((in[4] & 0xfc) == 0))\n\t\t\thd.setTurnSignals(in[4] & 0x03);\n\t\telse if ((x & 0xffffff7f) == 0xa8691006) {\n\t\t\todolast = y - odolast;\n\t\t\tif (odolast < 0)\t\n\t\t\t\todolast += 65536;\n\t\t\todoaccum += odolast;\n\t\t\todolast = y;\n\t\t\thd.setOdometer(odoaccum);\n\t\t} else if ((x & 0xffffff7f) == 0xa883100a) {\n\t\t\tfuellast = y - fuellast;\n\t\t\tif (fuellast < 0)\t\n\t\t\t\tfuellast += 65536;\n\t\t\tfuelaccum += fuellast;\n\t\t\tfuellast = y;\n\t\t\thd.setFuel(fuelaccum);\n\t\t} else if ((x == 0xa8836112) && ((in[4] & 0xd0) == 0xd0))\n\t\t\thd.setFuelGauge(in[4] & 0x0f);\n\t\telse if ((x & 0xffffff5d) == 0x483b4000) {\n\t\t\tif ((in[3] & 0x20) == 0x20)\n\t\t\t\thd.setNeutral(false);\n\t\t\telse if ((in[3] & 0xa0) == 0xa0)\n\t\t\t\thd.setNeutral(true);\n\t\t\thd.setClutch((in[3] & 0x80) != 0);\n\t\t} else if ((x & 0xffffff7f) == 0x68881003) {\n\t\t\tif ((in[3] & 0x80) != 0)\n\t\t\t\thd.setCheckEngine(true);\n\t\t\telse\n\t\t\t\thd.setCheckEngine(false);\n\t\t} else if (x == 0x0c10f13c) {\n\t\t} else if (x == 0x0cf1107c) {\n\t\t\tswitch (in[4]) {\n\t\t\tcase 0x01:\n\t\t\t\tSystem.arraycopy(in, 5, ecmPN, 0, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x02:\n\t\t\t\tSystem.arraycopy(in, 5, ecmPN, 6, 6);\n\t\t\t\thd.setECMPN(new String(ecmPN).trim());\n\t\t\t\tbreak;\n\t\t\tcase 0x03:\n\t\t\t\tSystem.arraycopy(in, 5, ecmCalID, 0, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x04:\n\t\t\t\tSystem.arraycopy(in, 5, ecmCalID, 6, 6);\n\t\t\t\thd.setECMCalID(new String(ecmCalID).trim());\n\t\t\t\tbreak;\n\t\t\tcase 0x0b:\n\t\t\t\thd.setECMSWLevel((int)in[5] & 0xff);\n\t\t\t\tbreak;\n\t\t\tcase 0x0f:\n\t\t\t\tSystem.arraycopy(in, 5, vin, 0, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x10:\n\t\t\t\tSystem.arraycopy(in, 5, vin, 6, 6);\n\t\t\t\tbreak;\n\t\t\tcase 0x11:\n\t\t\t\tSystem.arraycopy(in, 5, vin, 12, 5);\n\t\t\t\thd.setVIN(new String(vin).trim());\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\thd.setUnknown(buffer);\n\t\t\t}\n\t\t} else if (x == 0x6cfef119) {\n\t\t\tif (D) Log.d(TAG, \"DTC start\");\n\t\t} else if ((x & 0xffff0fff) == 0x6cf10059) {\n\t\t\tint dtc = (((int)in[4] & 0xff) << 8) | ((int)in[5] & 0xff);\n\t\t\tif (in[2] == 0x10) {\n\t\t\t\tif (D) Log.d(TAG, \"historic DTC: 0x\" + Integer.toString(dtc, 16));\n\t\t\t\thd.addHistoricDTC(dtc);\n\t\t\t} else if (in[2] == 0x40) {\n\t\t\t\tif (D) Log.d(TAG, \"current DTC: 0x\" + Integer.toString(dtc, 16));\n\t\t\t\thd.addCurrentDTC(dtc);\n\t\t\t} else\n\t\t\t\thd.setUnknown(buffer);\n\t\t} else if (x == 0x6c10f114)\n\t\t\tif (D) Log.d(TAG, \"DTC clear\");\n\t\telse\n\t\t\thd.setUnknown(buffer);\n\t\treturn true;\n\t}\n"} {"input": " private Resource findMatchingConfiguredResource(List resources,\n FolderConfiguration referenceConfig) {\n ArrayList matchingResources = new ArrayList();\n for (int i = 0 ; i < resources.size(); i++) {\n Resource res = resources.get(i);\n if (res.getConfiguration().isMatchFor(referenceConfig)) {\n matchingResources.add(res);\n }\n }\n if (matchingResources.size() == 1) {\n return matchingResources.get(0);\n } else if (matchingResources.size() == 0) {\n return null;\n }\n final int count = FolderConfiguration.getQualifierCount();\n for (int q = 0 ; q < count ; q++) {\n ResourceQualifier referenceQualifier = referenceConfig.getQualifier(q);\n boolean found = false;\n ResourceQualifier bestMatch = null; \n for (Resource res : matchingResources) {\n ResourceQualifier qualifier = res.getConfiguration().getQualifier(q);\n if (qualifier != null) {\n found = true;\n if (referenceQualifier != null) {\n if (qualifier.isBetterMatchThan(bestMatch, referenceQualifier)) {\n bestMatch = qualifier;\n }\n }\n }\n }\n if (found) {\n for (int i = 0 ; i < matchingResources.size(); ) {\n Resource res = matchingResources.get(i);\n ResourceQualifier qualifier = res.getConfiguration().getQualifier(q);\n if (qualifier == null) {\n matchingResources.remove(res);\n } else if (referenceQualifier != null && bestMatch != null &&\n bestMatch.equals(qualifier) == false) {\n matchingResources.remove(res);\n } else {\n i++;\n }\n }\n if (matchingResources.size() < 2) {\n break;\n }\n }\n }\n if (matchingResources.size() == 0) {\n return null;\n }\n return matchingResources.get(1);\n }\n", "output": " private Resource findMatchingConfiguredResource(List resources,\n FolderConfiguration referenceConfig) {\n ArrayList matchingResources = new ArrayList();\n for (int i = 0 ; i < resources.size(); i++) {\n Resource res = resources.get(i);\n if (res.getConfiguration().isMatchFor(referenceConfig)) {\n matchingResources.add(res);\n }\n }\n if (matchingResources.size() == 1) {\n return matchingResources.get(0);\n } else if (matchingResources.size() == 0) {\n return null;\n }\n final int count = FolderConfiguration.getQualifierCount();\n for (int q = 0 ; q < count ; q++) {\n ResourceQualifier referenceQualifier = referenceConfig.getQualifier(q);\n boolean found = false;\n ResourceQualifier bestMatch = null; \n for (Resource res : matchingResources) {\n ResourceQualifier qualifier = res.getConfiguration().getQualifier(q);\n if (qualifier != null) {\n found = true;\n if (referenceQualifier != null) {\n if (qualifier.isBetterMatchThan(bestMatch, referenceQualifier)) {\n bestMatch = qualifier;\n }\n }\n }\n }\n if (found) {\n for (int i = 0 ; i < matchingResources.size(); ) {\n Resource res = matchingResources.get(i);\n ResourceQualifier qualifier = res.getConfiguration().getQualifier(q);\n if (qualifier == null) {\n matchingResources.remove(res);\n } else if (referenceQualifier != null && bestMatch != null &&\n bestMatch.equals(qualifier) == false) {\n matchingResources.remove(res);\n } else {\n i++;\n }\n }\n if (matchingResources.size() < 2) {\n break;\n }\n }\n }\n if (matchingResources.size() == 0) {\n return null;\n }\n return matchingResources.get(0);\n }\n"} {"input": "\tpublic ServiceInterface create(String interfaceUrl, String username,\n\t\t\tchar[] password, String myProxyServer, String myProxyPort,\n\t\t\tObject[] otherOptions) throws ServiceInterfaceException {\n\t\ttry {\n\t\t\tfinal QName serviceName = new QName(\"http://api.grisu\",\n\t\t\t\t\t\"GrisuService\");\n\t\t\tfinal QName portName = new QName(\"http://api.grisu\",\n\t\t\t\t\t\"ServiceInterfacePort\");\n\t\t\tService s;\n\t\t\ttry {\n\t\t\t\ts = Service.create(\n\t\t\t\t\t\tnew URL(interfaceUrl.replace(\"soap/GrisuService\",\n\t\t\t\t\t\t\t\t\"api.wsdl\")), serviceName);\n\t\t\t} catch (final MalformedURLException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t\tfinal MTOMFeature mtom = new MTOMFeature();\n\t\t\ttry {\n\t\t\t\ts.getPort(portName, ServiceInterface.class, mtom);\n\t\t\t} catch (final Error e) {\n\t\t\t\tthrow new ServiceInterfaceException(\n\t\t\t\t\t\t\"Sorry, could not login. Most likely your client version is incompatible with the server.\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"Please download the latest version from:\\n\\nhttp://code.ceres.auckland.ac.nz/stable-downloads\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"If you have the latest version and are still experiencing this problem please contact\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"eresearch-admin@list.auckland.ac.nz\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"with a description of the issue.\\n\\nUnderlying cause: \"\n\t\t\t\t\t\t\t\t+ e.getLocalizedMessage());\n\t\t\t}\n\t\t\tfinal ServiceInterface service = s.getPort(portName,\n\t\t\t\t\tServiceInterface.class);\n\t\t\tfinal BindingProvider bp = (javax.xml.ws.BindingProvider) service;\n\t\t\tbp.getRequestContext().put(\n\t\t\t\t\tjavax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY,\n\t\t\t\t\tinterfaceUrl);\n\t\t\tbp.getRequestContext().put(\n\t\t\t\t\tJAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);\n\t\t\tbp.getRequestContext()\n\t\t\t.put(\"com.sun.xml.internal.ws.transport.http.client.streaming.chunk.size\",\n\t\t\t\t\tnew Integer(4096));\n\t\t\tbp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,\n\t\t\t\t\tusername);\n\t\t\tbp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,\n\t\t\t\t\tnew String(password));\n\t\t\tbp.getRequestContext().put(\n\t\t\t\t\tBindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);\n\t\t\tfinal SOAPBinding binding = (SOAPBinding) bp.getBinding();\n\t\t\tbinding.setMTOMEnabled(true);\n\t\t\tString clientstring = LoginManager.getClientName()\n\t\t\t\t\t+ \" \"\n\t\t\t\t\t+ LoginManager.getClientVersion()\n\t\t\t\t\t+ \" / \"\n\t\t\t\t\t+ \"frontend \"\n\t\t\t\t\t+ grisu.jcommons.utils.Version\n\t\t\t\t\t.get(\"grisu-client\");\n\t\t\tMap map = Maps.newHashMap();\n\t\t\tmap.put(\"X-login-host\", myProxyServer);\n\t\t\tmap.put(\"X-login-port\", myProxyPort);\n\t\t\tmap.put(\"X-grisu-client\", Collections.singletonList(clientstring));\n\t\t\tString session_id = LoginManager.USER_SESSION;\n\t\t\tif (StringUtils.isNotBlank(session_id)) {\n\t\t\t\tmap.put(\"X-client-session-id\",\n\t\t\t\t\t\tCollections.singletonList(session_id));\n\t\t\t}\n\t\t\tbp.getRequestContext()\n\t\t\t.put(MessageContext.HTTP_REQUEST_HEADERS, map);\n\t\t\tCommandLogHandler authnHandler = new CommandLogHandler(bp);\n\t\t\tList hc = binding.getHandlerChain();\n\t\t\thc.add(authnHandler);\n\t\t\tbinding.setHandlerChain(hc);\n\t\t\treturn service;\n\t\t} catch (final Exception e) {\n\t\t\tthrow new ServiceInterfaceException(\n\t\t\t\t\t\"Could not create JaxwsServiceInterface: \"\n\t\t\t\t\t\t\t+ e.getLocalizedMessage(), e);\n\t\t}\n\t}\n", "output": "\tpublic ServiceInterface create(String interfaceUrl, String username,\n\t\t\tchar[] password, String myProxyServer, String myProxyPort,\n\t\t\tObject[] otherOptions) throws ServiceInterfaceException {\n\t\ttry {\n\t\t\tfinal QName serviceName = new QName(\"http://api.grisu\",\n\t\t\t\t\t\"GrisuService\");\n\t\t\tfinal QName portName = new QName(\"http://api.grisu\",\n\t\t\t\t\t\"ServiceInterfacePort\");\n\t\t\tService s;\n\t\t\ttry {\n\t\t\t\ts = Service.create(\n\t\t\t\t\t\tnew URL(interfaceUrl.replace(\"soap/GrisuService\",\n\t\t\t\t\t\t\t\t\"api.wsdl\")), serviceName);\n\t\t\t} catch (final MalformedURLException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t\tfinal MTOMFeature mtom = new MTOMFeature();\n\t\t\ttry {\n\t\t\t\ts.getPort(portName, ServiceInterface.class, mtom);\n\t\t\t} catch (final Error e) {\n\t\t\t\tthrow new ServiceInterfaceException(\n\t\t\t\t\t\t\"Sorry, could not login. Most likely your client version is incompatible with the server.\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"Please download the latest version from:\\n\\nhttp://code.ceres.auckland.ac.nz/stable-downloads\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"If you have the latest version and are still experiencing this problem please contact\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"eresearch-admin@list.auckland.ac.nz\\n\\n\"\n\t\t\t\t\t\t\t\t+ \"with a description of the issue.\\n\\nUnderlying cause: \"\n\t\t\t\t\t\t\t\t+ e.getLocalizedMessage());\n\t\t\t}\n\t\t\tfinal ServiceInterface service = s.getPort(portName,\n\t\t\t\t\tServiceInterface.class);\n\t\t\tfinal BindingProvider bp = (javax.xml.ws.BindingProvider) service;\n\t\t\tbp.getRequestContext().put(\n\t\t\t\t\tjavax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY,\n\t\t\t\t\tinterfaceUrl);\n\t\t\tbp.getRequestContext().put(\n\t\t\t\t\tJAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);\n\t\t\tbp.getRequestContext()\n\t\t\t.put(\"com.sun.xml.internal.ws.transport.http.client.streaming.chunk.size\",\n\t\t\t\t\tnew Integer(4096));\n\t\t\tbp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,\n\t\t\t\t\tusername);\n\t\t\tbp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,\n\t\t\t\t\tnew String(password));\n\t\t\tbp.getRequestContext().put(\n\t\t\t\t\tBindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);\n\t\t\tfinal SOAPBinding binding = (SOAPBinding) bp.getBinding();\n\t\t\tbinding.setMTOMEnabled(true);\n\t\t\tString clientstring = LoginManager.getClientName()\n\t\t\t\t\t+ \" \"\n\t\t\t\t\t+ LoginManager.getClientVersion()\n\t\t\t\t\t+ \" / \"\n\t\t\t\t\t+ \"frontend \"\n\t\t\t\t\t+ grisu.jcommons.utils.Version\n\t\t\t\t\t.get(\"grisu-client\");\n\t\t\tMap map = Maps.newHashMap();\n\t\t\tmap.put(\"X-login-host\", Collections.singletonList(myProxyServer));\n\t\t\tmap.put(\"X-login-port\", Collections.singletonList(myProxyPort));\n\t\t\tmap.put(\"X-grisu-client\", Collections.singletonList(clientstring));\n\t\t\tString session_id = LoginManager.USER_SESSION;\n\t\t\tif (StringUtils.isNotBlank(session_id)) {\n\t\t\t\tmap.put(\"X-client-session-id\",\n\t\t\t\t\t\tCollections.singletonList(session_id));\n\t\t\t}\n\t\t\tbp.getRequestContext()\n\t\t\t.put(MessageContext.HTTP_REQUEST_HEADERS, map);\n\t\t\tCommandLogHandler authnHandler = new CommandLogHandler(bp);\n\t\t\tList hc = binding.getHandlerChain();\n\t\t\thc.add(authnHandler);\n\t\t\tbinding.setHandlerChain(hc);\n\t\t\treturn service;\n\t\t} catch (final Exception e) {\n\t\t\tthrow new ServiceInterfaceException(\n\t\t\t\t\t\"Could not create JaxwsServiceInterface: \"\n\t\t\t\t\t\t\t+ e.getLocalizedMessage(), e);\n\t\t}\n\t}\n"} {"input": " public static void main(String[] arg) throws Exception {\n int port = arg.length > 1 ? Integer.parseInt(arg[1]) : 8080;\n Server server = new Server(port);\n ServletHandler servletHandler = new ServletHandler();\n servletHandler.addServletWithMapping(GameServlet.class, \"/chat/*\");\n ResourceHandler resourceHandler = new ResourceHandler();\n resourceHandler.setResourceBase(\"./dune-client/resources/\");\n DefaultHandler defaultHandler = new DefaultHandler();\n HandlerList handlers = new HandlerList();\n handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, defaultHandler});\n server.setHandler(handlers);\n server.start();\n server.join();\n }\n", "output": " public static void main(String[] arg) throws Exception {\n int port = arg.length > 1 ? Integer.parseInt(arg[1]) : 8080;\n Server server = new Server(port);\n ServletHandler servletHandler = new ServletHandler();\n servletHandler.addServletWithMapping(GameServlet.class, \"/chat/*\");\n ResourceHandler resourceHandler = new ResourceHandler();\n resourceHandler.setResourceBase(\"dune-client/resources/\");\n DefaultHandler defaultHandler = new DefaultHandler();\n HandlerList handlers = new HandlerList();\n handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, defaultHandler});\n server.setHandler(handlers);\n server.start();\n server.join();\n }\n"} {"input": " public static void shop(SignChangeEvent event) {\n Inventory chest = ChestFinder.findChest(event.getBlock());\n Block chestBlock = ChestFinder.findChestBlock(event.getBlock());\n if(chest == null) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_NoChest);\n event.getBlock().breakNaturally();\n return;\n }\n String[] lines = event.getLines();\n Integer amount;\n try {\n amount = Integer.parseInt(lines[1]);\n } catch(NumberFormatException e) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_InvalidAmount);\n event.getBlock().breakNaturally();\n return;\n }\n Matcher matcher = pattern.matcher(lines[2]);\n Float buy = 0.0F, sell = 0.0F;\n if(matcher.find()) {\n try {\n buy = Float.parseFloat(matcher.group(1));\n sell = Float.parseFloat(matcher.group(2));\n } catch(NumberFormatException e) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_InvalidBuySell);\n event.getBlock().breakNaturally();\n return;\n }\n } else {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_NoValidBuySellLine);\n event.getBlock().breakNaturally();\n return;\n }\n Boolean hasItem = false;\n ListIterator itemStackListIterator = chest.iterator();\n while(itemStackListIterator.hasNext()) {\n ItemStack itemStack = itemStackListIterator.next();\n if(itemStack == null) continue;\n hasItem = true;\n break;\n }\n if(!hasItem) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_ChestIsEmpty);\n event.getBlock().breakNaturally();\n return;\n }\n com.geNAZt.RegionShop.Database.Model.Chest.store(event.getPlayer(), event.getBlock(), chestBlock, event.getPlayer().getWorld());\n com.geNAZt.RegionShop.Database.Table.Chest chest1 = com.geNAZt.RegionShop.Database.Model.Chest.get(chestBlock, event.getPlayer().getWorld(), false);\n itemStackListIterator = chest.iterator();\n Integer firstID = null;\n Byte firstData = null;\n Integer itemAmount = 0;\n ItemStack firstItemStack = null;\n while(itemStackListIterator.hasNext()) {\n ItemStack itemStack = itemStackListIterator.next();\n if(itemStack == null) continue;\n if(firstID == null) {\n firstID = itemStack.getTypeId();\n firstData = itemStack.getData().getData();\n firstItemStack = itemStack;\n if(Add.add(itemStack, event.getPlayer(), chest1, sell, buy, amount) == -1) {\n event.getBlock().breakNaturally();\n return;\n }\n itemAmount += itemStack.getAmount();\n continue;\n }\n if(itemStack.getTypeId() == firstID && itemStack.getData().getData() == firstData) {\n itemAmount += itemStack.getAmount();\n }\n }\n Items item = chest1.getItemStorage().getItems().iterator().next();\n item.setCurrentAmount(itemAmount);\n Database.getServer().update(item);\n item.getItemStorage().setItemAmount(itemAmount);\n Database.getServer().update(item.getItemStorage());\n ItemStack itemStack = firstItemStack.clone();\n itemStack.setAmount(1);\n org.bukkit.entity.Item droppedItem = event.getPlayer().getWorld().dropItem(new Location(event.getPlayer().getWorld(), (double) chest1.getChestX() + 0.5, (double)chest1.getChestY() + 1.2, (double)chest1.getChestZ() + 0.5), itemStack);\n droppedItem.setVelocity(new Vector(0, 0.1, 0));\n NMS.safeGuard(droppedItem);\n String itemName = ItemName.getDataName(firstItemStack) + firstItemStack.getType().toString();\n if (firstItemStack.getItemMeta().hasDisplayName()) {\n itemName = \"(\" + firstItemStack.getItemMeta().getDisplayName() + \")\";\n }\n for(Integer line = 0; line < 4; line++) {\n event.setLine(line, ConfigManager.language.Sign_Shop_SignText.get(line).\n replace(\"%player\", event.getPlayer().getName()).\n replace(\"%itemname\", ItemName.nicer(itemName)).\n replace(\"%amount\", amount.toString()).\n replace(\"%sell\", sell.toString()).\n replace(\"%buy\", buy.toString()));\n }\n }\n", "output": " public static void shop(SignChangeEvent event) {\n Inventory chest = ChestFinder.findChest(event.getBlock());\n Block chestBlock = ChestFinder.findChestBlock(event.getBlock());\n if(chest == null) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_NoChest);\n event.getBlock().breakNaturally();\n return;\n }\n String[] lines = event.getLines();\n Integer amount;\n try {\n amount = Integer.parseInt(lines[1]);\n } catch(NumberFormatException e) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_InvalidAmount);\n event.getBlock().breakNaturally();\n return;\n }\n Matcher matcher = pattern.matcher(lines[2]);\n Float buy = 0.0F, sell = 0.0F;\n if(matcher.find()) {\n try {\n sell = Float.parseFloat(matcher.group(1));\n buy = Float.parseFloat(matcher.group(2));\n } catch(NumberFormatException e) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_InvalidBuySell);\n event.getBlock().breakNaturally();\n return;\n }\n } else {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_NoValidBuySellLine);\n event.getBlock().breakNaturally();\n return;\n }\n Boolean hasItem = false;\n ListIterator itemStackListIterator = chest.iterator();\n while(itemStackListIterator.hasNext()) {\n ItemStack itemStack = itemStackListIterator.next();\n if(itemStack == null) continue;\n hasItem = true;\n break;\n }\n if(!hasItem) {\n event.getPlayer().sendMessage(ConfigManager.main.Chat_prefix + ConfigManager.language.Sign_Shop_ChestIsEmpty);\n event.getBlock().breakNaturally();\n return;\n }\n com.geNAZt.RegionShop.Database.Model.Chest.store(event.getPlayer(), event.getBlock(), chestBlock, event.getPlayer().getWorld());\n com.geNAZt.RegionShop.Database.Table.Chest chest1 = com.geNAZt.RegionShop.Database.Model.Chest.get(chestBlock, event.getPlayer().getWorld(), false);\n itemStackListIterator = chest.iterator();\n Integer firstID = null;\n Byte firstData = null;\n Integer itemAmount = 0;\n ItemStack firstItemStack = null;\n while(itemStackListIterator.hasNext()) {\n ItemStack itemStack = itemStackListIterator.next();\n if(itemStack == null) continue;\n if(firstID == null) {\n firstID = itemStack.getTypeId();\n firstData = itemStack.getData().getData();\n firstItemStack = itemStack;\n if(Add.add(itemStack, event.getPlayer(), chest1, sell, buy, amount) == -1) {\n event.getBlock().breakNaturally();\n return;\n }\n itemAmount += itemStack.getAmount();\n continue;\n }\n if(itemStack.getTypeId() == firstID && itemStack.getData().getData() == firstData) {\n itemAmount += itemStack.getAmount();\n }\n }\n Items item = chest1.getItemStorage().getItems().iterator().next();\n item.setCurrentAmount(itemAmount);\n Database.getServer().update(item);\n item.getItemStorage().setItemAmount(itemAmount);\n Database.getServer().update(item.getItemStorage());\n ItemStack itemStack = firstItemStack.clone();\n itemStack.setAmount(1);\n org.bukkit.entity.Item droppedItem = event.getPlayer().getWorld().dropItem(new Location(event.getPlayer().getWorld(), (double) chest1.getChestX() + 0.5, (double)chest1.getChestY() + 1.2, (double)chest1.getChestZ() + 0.5), itemStack);\n droppedItem.setVelocity(new Vector(0, 0.1, 0));\n NMS.safeGuard(droppedItem);\n String itemName = ItemName.getDataName(firstItemStack) + firstItemStack.getType().toString();\n if (firstItemStack.getItemMeta().hasDisplayName()) {\n itemName = \"(\" + firstItemStack.getItemMeta().getDisplayName() + \")\";\n }\n for(Integer line = 0; line < 4; line++) {\n event.setLine(line, ConfigManager.language.Sign_Shop_SignText.get(line).\n replace(\"%player\", event.getPlayer().getName()).\n replace(\"%itemname\", ItemName.nicer(itemName)).\n replace(\"%amount\", amount.toString()).\n replace(\"%sell\", sell.toString()).\n replace(\"%buy\", buy.toString()));\n }\n }\n"} {"input": " public double distance(EventSet es1, EventSet es2) {\n\t\tEventHistogram h1 = new EventHistogram();\n\t\tEventHistogram h2 = new EventHistogram();\n\t\tSet s = new HashSet();\n\t\tList> l1 = new ArrayList>();\n\t\tList> l2 = new ArrayList>();\n\t\tHashMap hm1 = new HashMap();\n\t\tHashMap hm2 = new HashMap();\n\t\tdouble oldfreq = Double.POSITIVE_INFINITY;\n\t\tdouble correlation = 0.0;\n\t\tfor (int i = 0; i < es1.size(); i++) {\n\t\t\th1.add(es1.eventAt(i));\n\t\t\ts.add(es1.eventAt(i));\n\t\t}\n\t\tfor (int i = 0; i < es2.size(); i++) {\n\t\t\th2.add(es2.eventAt(i));\n\t\t\ts.add(es2.eventAt(i));\n\t\t}\n\t\tfor (Event e: h1) {\n\t\t\tl1.add(new Pair(e,h1.getRelativeFrequency(e),2) );\n\t\t}\n\t\tfor (Event e: h2) {\n\t\t\tl2.add(new Pair(e,h2.getRelativeFrequency(e),2) );\n\t\t}\n\t\tCollections.sort(l1);\n\t\tCollections.reverse(l1);\n\t\tCollections.sort(l2);\n\t\tCollections.reverse(l2);\n\t\tint rank = 0;\n\t\tint count = 0;\n\t\tfor (Pair p : l1) {\n\t\t\tEvent e = (Event) (p.getFirst());\n\t\t\tdouble f = (Double) (p.getSecond());\n\t\t\tcount++;\n\t\t\tif (f != oldfreq) {\n\t\t\t\trank = count;\n\t\t\t\toldfreq = f;\n\t\t\t}\n\t\t\thm1.put(e,rank);\n\t\t}\n\t\trank = 0;\n\t\tcount = 0;\n\t\tfor (Pair p : l2) {\n\t\t\tEvent e = (Event) (p.getFirst());\n\t\t\tdouble f = (Double) (p.getSecond());\n\t\t\tcount++;\n\t\t\tif (f != oldfreq) {\n\t\t\t\trank = count;\n\t\t\t\toldfreq = f;\n\t\t\t}\n\t\t\thm2.put(e,rank);\n\t\t}\n\t\tInteger x1, x2, y1, y2;\n\t\tfor (Event e1 : s) {\n\t\t\tfor (Event e2: s) {\n\t\t\t\tif (e1.equals(e2)) continue;\n\t\t\t\tx1 = hm1.get(e1);\n\t\t\t\tif (x1 == null) x1 = hm1.size()+1;\n\t\t\t\tx2 = hm2.get(e1);\n\t\t\t\tif (x2 == null) x2 = hm2.size()+1;\n\t\t\t\ty1 = hm1.get(e2);\n\t\t\t\tif (y1 == null) y1 = hm1.size()+1;\n\t\t\t\ty2 = hm2.get(e2);\n\t\t\t\tif (y2 == null) y2 = hm2.size()+1;\n\t\t\t\tcorrelation += (sgn(x1.compareTo(y1)) * sgn(x2.compareTo(y2)));\n\t\t\t\tSystem.out.println(correlation);\n\t\t\t}\n\t\t}\n\t\tcorrelation /= (hm1.size() * (hm2.size()-1));\n\t\treturn 1.0 - correlation;\n }\n", "output": " public double distance(EventSet es1, EventSet es2) {\n\t\tEventHistogram h1 = new EventHistogram();\n\t\tEventHistogram h2 = new EventHistogram();\n\t\tSet s = new HashSet();\n\t\tList> l1 = new ArrayList>();\n\t\tList> l2 = new ArrayList>();\n\t\tHashMap hm1 = new HashMap();\n\t\tHashMap hm2 = new HashMap();\n\t\tdouble oldfreq = Double.POSITIVE_INFINITY;\n\t\tdouble correlation = 0.0;\n\t\tfor (int i = 0; i < es1.size(); i++) {\n\t\t\th1.add(es1.eventAt(i));\n\t\t\ts.add(es1.eventAt(i));\n\t\t}\n\t\tfor (int i = 0; i < es2.size(); i++) {\n\t\t\th2.add(es2.eventAt(i));\n\t\t\ts.add(es2.eventAt(i));\n\t\t}\n\t\tfor (Event e: h1) {\n\t\t\tl1.add(new Pair(e,h1.getRelativeFrequency(e),2) );\n\t\t}\n\t\tfor (Event e: h2) {\n\t\t\tl2.add(new Pair(e,h2.getRelativeFrequency(e),2) );\n\t\t}\n\t\tCollections.sort(l1);\n\t\tCollections.reverse(l1);\n\t\tCollections.sort(l2);\n\t\tCollections.reverse(l2);\n\t\tint rank = 0;\n\t\tint count = 0;\n\t\tfor (Pair p : l1) {\n\t\t\tEvent e = (Event) (p.getFirst());\n\t\t\tdouble f = (Double) (p.getSecond());\n\t\t\tcount++;\n\t\t\tif (f != oldfreq) {\n\t\t\t\trank = count;\n\t\t\t\toldfreq = f;\n\t\t\t}\n\t\t\thm1.put(e,rank);\n\t\t}\n\t\trank = 0;\n\t\tcount = 0;\n\t\tfor (Pair p : l2) {\n\t\t\tEvent e = (Event) (p.getFirst());\n\t\t\tdouble f = (Double) (p.getSecond());\n\t\t\tcount++;\n\t\t\tif (f != oldfreq) {\n\t\t\t\trank = count;\n\t\t\t\toldfreq = f;\n\t\t\t}\n\t\t\thm2.put(e,rank);\n\t\t}\n\t\tInteger x1, x2, y1, y2;\n\t\tSet s2 = new HashSet(s);\n\t\tfor (Event e1 : s) {\n\t\t\ts2.remove(e1);\n\t\t\tfor (Event e2: s2) {\n\t\t\t\tif (e1.equals(e2)) continue;\n\t\t\t\tx1 = hm1.get(e1);\n\t\t\t\tif (x1 == null) x1 = hm1.size()+1;\n\t\t\t\tx2 = hm2.get(e1);\n\t\t\t\tif (x2 == null) x2 = hm2.size()+1;\n\t\t\t\ty1 = hm1.get(e2);\n\t\t\t\tif (y1 == null) y1 = hm1.size()+1;\n\t\t\t\ty2 = hm2.get(e2);\n\t\t\t\tif (y2 == null) y2 = hm2.size()+1;\n\t\t\t\tcorrelation += (sgn(x1.compareTo(y1)) * sgn(x2.compareTo(y2)));\n\t\t\t}\n\t\t}\n\t\tcorrelation /= (hm1.size() * (hm2.size()-1));\n\t\treturn 1.0 - correlation;\n }\n"} {"input": " public void onMessage(Message message) {\n DSBIngestMessage ingestMessage = null;\n StudyVersion sv = null;\n List successfulFiles = new ArrayList();\n List problemFiles = new ArrayList();\n try { \n ObjectMessage om = (ObjectMessage) message;\n ingestMessage = (DSBIngestMessage) om.getObject();\n sv = studyService.getStudyVersionById( ingestMessage.getStudyVersionId() );\n String detail = \"Ingest processing for \" +ingestMessage.getFileBeans().size() + \" file(s).\";\n Iterator iter = ingestMessage.getFileBeans().iterator();\n while (iter.hasNext()) {\n StudyFileEditBean fileBean = (StudyFileEditBean) iter.next();\n try {\n if (fileBean.getStudyFile() instanceof NetworkDataFile ) {\n Context ctx = new InitialContext();\n networkDataService = (NetworkDataServiceLocal) ctx.lookup(\"java:comp/env/networkData\");\n networkDataService.ingest(fileBean);\n successfulFiles.add(fileBean);\n } else {\n parseXML( new DSBWrapper().ingest(fileBean) , fileBean.getFileMetadata() );\n successfulFiles.add(fileBean);\n }\n } catch (Exception ex) {\n ex.printStackTrace();\n problemFiles.add(fileBean);\n }\n }\n if (!successfulFiles.isEmpty()) {\n studyFileService.addIngestedFiles(ingestMessage.getStudyId(), ingestMessage.getVersionNote(), successfulFiles, ingestMessage.getIngestUserId());\n }\n if ( ingestMessage.sendInfoMessage() || ( problemFiles.size() >= 0 && ingestMessage.sendErrorMessage() ) ) {\n mailService.sendIngestCompletedNotification(ingestMessage.getIngestEmail(), sv, successfulFiles, problemFiles);\n }\n } catch (JMSException ex) {\n ex.printStackTrace(); \n } catch (Exception ex) { \n ex.printStackTrace();\n if (ingestMessage.sendErrorMessage()) {\n mailService.sendIngestCompletedNotification(ingestMessage.getIngestEmail(), sv, null, ingestMessage.getFileBeans());\n }\n } finally {\n try {\n studyService.removeStudyLock( ingestMessage.getStudyId() );\n } catch (Exception ex) {\n ex.printStackTrace(); \n }\n }\n }\n", "output": " public void onMessage(Message message) {\n DSBIngestMessage ingestMessage = null;\n StudyVersion sv = null;\n List successfulFiles = new ArrayList();\n List problemFiles = new ArrayList();\n try { \n ObjectMessage om = (ObjectMessage) message;\n ingestMessage = (DSBIngestMessage) om.getObject();\n String detail = \"Ingest processing for \" +ingestMessage.getFileBeans().size() + \" file(s).\";\n Iterator iter = ingestMessage.getFileBeans().iterator();\n while (iter.hasNext()) {\n StudyFileEditBean fileBean = (StudyFileEditBean) iter.next();\n try {\n if (fileBean.getStudyFile() instanceof NetworkDataFile ) {\n Context ctx = new InitialContext();\n networkDataService = (NetworkDataServiceLocal) ctx.lookup(\"java:comp/env/networkData\");\n networkDataService.ingest(fileBean);\n successfulFiles.add(fileBean);\n } else {\n parseXML( new DSBWrapper().ingest(fileBean) , fileBean.getFileMetadata() );\n successfulFiles.add(fileBean);\n }\n } catch (Exception ex) {\n ex.printStackTrace();\n problemFiles.add(fileBean);\n }\n }\n if (!successfulFiles.isEmpty()) {\n studyFileService.addIngestedFiles(ingestMessage.getStudyId(), ingestMessage.getVersionNote(), successfulFiles, ingestMessage.getIngestUserId());\n }\n if ( ingestMessage.sendInfoMessage() || ( problemFiles.size() >= 0 && ingestMessage.sendErrorMessage() ) ) {\n mailService.sendIngestCompletedNotification(ingestMessage, successfulFiles, problemFiles);\n }\n } catch (JMSException ex) {\n ex.printStackTrace(); \n } catch (Exception ex) { \n ex.printStackTrace();\n if (ingestMessage.sendErrorMessage()) {\n mailService.sendIngestCompletedNotification(ingestMessage, null, ingestMessage.getFileBeans());\n }\n } finally {\n try {\n studyService.removeStudyLock( ingestMessage.getStudyId() );\n } catch (Exception ex) {\n ex.printStackTrace(); \n }\n }\n }\n"} {"input": "\tpublic static void main(String[] args) {\n\t\t HostConfiguration hostConfig = new HostConfiguration(); \n\t HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();\n\t HttpConnectionManagerParams params = new HttpConnectionManagerParams();\n\t int maxHostConnections = 20;\n\t params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);\n\t connectionManager.setParams(params); \n\t HttpClient client = new HttpClient(connectionManager);\n\t Credentials creds = new UsernamePasswordCredentials(\"admin\", \"admin\");\n\t client.getState().setCredentials(AuthScope.ANY, creds);\n\t client.setHostConfiguration(hostConfig);\n\t String select = \n \t\t\"\" + \n\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\"\"+ \n\t\t\t\"\";\n\t String from = \n\t\t \"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\t\"infinity\"+\n\t\t\t\t\"\"+\n\t\t\t\"\";\n\t String lessDay = get_custom_time_string(0, 0, 0);\n\t String greaterDay = get_custom_time_string(23, 59, 59);\n\t String where = \n\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\" + greaterDay + \"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\"\" + lessDay + \"\"+\n\t\t\t\t\"\"+\n\t\t\t\"\";\n\t String orderby = \n\t \t \"\"+\n\t\t\t\t\"\"+ \n\t\t\t\t\t\"\"+\n\t\t\t\t\t\t\"\"+ \n\t\t\t\t\t\"\"+ \n\t\t\t\t\t\"\"+ \n\t\t\t\t\"\"+\n\t\t\t\"\";\n String limit = \n \"\"+\n \"20\"+\n \"\";\n\t String query = select + from + where + orderby + limit;\n\t SearchMethod searchMethod=null;\n\t\ttry {\n\t\t\t searchMethod = new SearchMethod(\"http://localhost:8089/files?start=20\",query,\"D:basicsearch\");\n\t\t\t client.executeMethod(searchMethod);\n\t\t\t Namespace edoNamespace = Namespace.getNamespace(\"http://ns.everydo.com/basic\");\n\t\t if (searchMethod.getStatusCode() != 207){\n\t\t\t\t System.out.println(\"\ufffd\ufffd\ufffd\ufffd\u05b4\ufffd\ufffd\u02a7\ufffd\u0723\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u01e3\ufffd\" + searchMethod.getStatusCode());\n\t\t\t\t return;\n \t\t\t }\n\t\t\t MultiStatusResponse[] responses = null;\n\t\t\t try{\n\t\t\t\t MultiStatus resp = searchMethod.getResponseBodyAsMultiStatus();\n\t\t\t\t responses = resp.getResponses();\n\t\t\t } catch (DavException e){\n\t\t\t\t System.out.println(e.getMessage());\n\t\t\t }\n\t\t\t for (int i=0; i\" + \n\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\"\"+ \n\t\t\t\"\";\n\t String from = \n\t\t \"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\t\"/\"+\n\t\t\t\t\t\"infinity\"+\n\t\t\t\t\"\"+\n\t\t\t\"\";\n\t String lessDay = get_custom_time_string(0, 0, 0);\n\t String greaterDay = get_custom_time_string(23, 59, 59);\n\t String where = \n\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\t\"\" + greaterDay + \"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\t\"\"+\n\t\t\t\t\"\"+\n\t\t\t\t\"\" + lessDay + \"\"+\n\t\t\t\t\"\"+\n\t\t\t\"\";\n\t String orderby = \n\t \t \"\"+\n\t\t\t\t\"\"+ \n\t\t\t\t\t\"\"+\n\t\t\t\t\t\t\"\"+ \n\t\t\t\t\t\"\"+ \n\t\t\t\t\t\"\"+ \n\t\t\t\t\"\"+\n\t\t\t\"\";\n String limit = \n \"\"+\n \"20\"+\n \"\";\n\t String query = select + from + where + orderby + limit;\n\t SearchMethod searchMethod=null;\n\t\ttry {\n\t\t\t searchMethod = new SearchMethod(\"http://localhost:8089/files?start=20\",query,\"D:basicsearch\");\n\t\t\t client.executeMethod(searchMethod);\n\t\t\t Namespace edoNamespace = Namespace.getNamespace(\"http://ns.everydo.com/basic\");\n\t\t if (searchMethod.getStatusCode() != 207){\n\t\t\t\t System.out.println(\"\ufffd\ufffd\ufffd\ufffd\u05b4\ufffd\ufffd\u02a7\ufffd\u0723\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u01e3\ufffd\" + searchMethod.getStatusCode());\n\t\t\t\t return;\n \t\t\t }\n\t\t\t MultiStatusResponse[] responses = null;\n\t\t\t try{\n\t\t\t\t MultiStatus resp = searchMethod.getResponseBodyAsMultiStatus();\n\t\t\t\t responses = resp.getResponses();\n\t\t\t } catch (DavException e){\n\t\t\t\t System.out.println(e.getMessage());\n\t\t\t }\n\t\t\t for (int i=0; i extensionToFactoryMap = resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap();\n\t\tfinal DiResourceFactoryImpl diResourceFactoryImpl = new DiResourceFactoryImpl();\n\t\textensionToFactoryMap.put(\"bpmn\", diResourceFactoryImpl);\n\t\tURL bpmnResource = FileLocator.toFileURL(BPMNImportExportTest.class.getResource(bpmnFileName));\n\t\tResource resource1 = resourceSet1.createResource(URI.createFileURI(bpmnResource.getFile()));\n\t\tresource1.load(Collections.emptyMap());\n\t\tResource resource2 = resourceSet1.createResource(URI.createFileURI(bpmnFileExported.getAbsolutePath()));\n\t\tresource2.load(Collections.emptyMap());\n\t\tDocumentRoot model1 = (DocumentRoot) resource1.getContents().get(0);\n\t\tDocumentRoot model2 = (DocumentRoot) resource2.getContents().get(0);\n\t\tint nbProcess1 = 0;\n\t\tSet processNames = new HashSet();\n\t\tList activityNames = new ArrayList();\n\t\tint nbActivity1 = 0;\n\t\tint nbBoundaryEvent1 = 0;\n\t\tint nbTsignal1 = 0;\n\t\tint nbEvents1 = 0;\n\t\tint nbTextannotation1 = 0;\n\t\tint nbMessageFlow1 = 0;\n\t\tint nbProcessItemeDefinition1 = 0;\n\t\tint nbDataObject1 = 0;\n\t\tint nbProperty1 = 0;\n\t\tfor(TRootElement rootElement : model1.getDefinitions().getRootElement()){\n\t\t\tif(rootElement instanceof TProcess){\n\t\t\t\tnbProcess1++;\n\t\t\t\tfinal String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();\n\t\t\t\tprocessNames.add(processName);\n\t\t\t\tfor(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){\n\t\t\t\t\tif(tArtifact instanceof TTextAnnotation){\n\t\t\t\t\t\tnbTextannotation1++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){\n\t\t\t\t\tif(tFlowElement instanceof TActivity){ \t\n\t\t\t\t\t\tnbActivity1++;\n\t\t\t\t\t\tString name = getFlowElementName((TActivity) tFlowElement);\n\t\t\t\t\t\tactivityNames.add(name);\n\t\t\t\t\t\tif(tFlowElement instanceof TSubProcess){\n\t\t\t\t\t\t\tif(((TSubProcess) tFlowElement).isTriggeredByEvent()){\n\t\t\t\t\t\t\t\tnbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement) ;\n\t\t\t\t\t\t\t\tnbActivity1--;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnbProcess1++;\n\t\t\t\t\t\t\t\tnbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSystem.out.println(\"activity count for model 1 \"+ nbActivity1 + tFlowElement.getId() +\" ### \"+ tFlowElement.getName());\n\t\t\t\t\t\tnbProperty1 += ((TActivity) tFlowElement).getProperty().size();\n\t\t\t\t\t} else if(tFlowElement instanceof TDataObject){\n\t\t\t\t\t\tnbDataObject1++;\n\t\t\t\t\t} else if(tFlowElement instanceof TIntermediateThrowEvent){\n\t\t\t\t\t\tif((((TThrowEvent) tFlowElement).getEventDefinition() == null\n\t\t\t\t\t\t\t\t|| ((TThrowEvent) tFlowElement).getEventDefinition().isEmpty())\n\t\t\t\t\t\t\t\t&& (((TThrowEvent) tFlowElement).getEventDefinitionRef() == null\n\t\t\t\t\t\t\t\t|| ((TThrowEvent) tFlowElement).getEventDefinitionRef().isEmpty())){\n\t\t\t\t\t\t\tnbActivity1++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if(rootElement instanceof TBoundaryEvent){\n\t\t\t\tnbBoundaryEvent1++;\n\t\t\t} else if(rootElement instanceof TSignal){\n\t\t\t\tnbTsignal1++;\n\t\t\t} else if(rootElement instanceof TEvent){\n\t\t\t\tnbEvents1++;\n\t\t\t} else if(rootElement instanceof TCollaboration){\n\t\t\t\tnbMessageFlow1+=((TCollaboration) rootElement).getMessageFlow().size();\n\t\t\t} else if(rootElement instanceof TItemDefinition){\n\t\t\t\tnbProcessItemeDefinition1++;\n\t\t\t}\n\t\t}\n\t\tint nbProcess2 = 0;\n\t\tint nbBoundaryEvent2 = 0;\n\t\tint nbActivity2 = 0;\n\t\tint nbTsignal2 = 0;\n\t\tint nbEvents2 = 0;\n\t\tint nbTextannotation2 = 0;\n\t\tint nbMessageFlow2 =0;\n\t\tint nbProcessItemeDefinition2 = 0;\n\t\tint nbDataObject2 = 0;\n\t\tint nbProperty2 = 0;\n\t\tfor(TRootElement rootElement : model2.getDefinitions().getRootElement()){\n\t\t\tif(rootElement instanceof TProcess){\n\t\t\t\tnbProcess2++;\n\t\t\t\tfinal String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();\n\t\t\t\tif(!processNames.remove(processName)){\n\t\t\t\t\tSystem.out.println(processName+ \" has appeared\");\n\t\t\t\t}\n\t\t\t\tfor(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){\n\t\t\t\t\tif(tArtifact instanceof TTextAnnotation){\n\t\t\t\t\t\tnbTextannotation2++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){\n\t\t\t\t\tif(tFlowElement instanceof TActivity){\n\t\t\t\t\t\tnbActivity2++;\n\t\t\t\t\t\tString name = getFlowElementName((TActivity) tFlowElement);\n\t\t\t\t\t\tif(!activityNames.remove(name)){\n\t\t\t\t\t\t\tSystem.out.println(\"The activity : \"+name +\" is missing \");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tFlowElement instanceof TSubProcess){\n\t\t\t\t\t\t\tnbActivity2 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);\n\t\t\t\t\t\t\tif(((TSubProcess) tFlowElement).isTriggeredByEvent()){\n\t\t\t\t\t\t\t\tnbActivity2--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSystem.out.println(\"activity count for model 2 \"+ nbActivity2 + tFlowElement.getId() +\" ### \"+ tFlowElement.getName());\n\t\t\t\t\t\tnbProperty2 += ((TActivity) tFlowElement).getProperty().size();\n\t\t\t\t\t} else if(tFlowElement instanceof TDataObject){\n\t\t\t\t\t\tnbDataObject2++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if(rootElement instanceof TBoundaryEvent){\n\t\t\t\tnbBoundaryEvent2++;\n\t\t\t} else if(rootElement instanceof TSignal){\n\t\t\t\tnbTsignal2++;\n\t\t\t} else if(rootElement instanceof TEvent){\n\t\t\t\tnbEvents2++;\n\t\t\t} else if(rootElement instanceof TCollaboration){\n\t\t\t\tnbMessageFlow2 = ((TCollaboration) rootElement).getMessageFlow().size();\n\t\t\t} else if(rootElement instanceof TItemDefinition){\n\t\t\t\tnbProcessItemeDefinition2++;\n\t\t\t}\n\t\t}\n\t\tCollection ids = new HashSet();\n\t\tCollection duplicatedIds = new HashSet();\n\t\tCollection noIds = new HashSet();\n\t\tfor (Iterator iterator = model2.eAllContents(); iterator.hasNext();) {\n\t\t\tEObject object = iterator.next();\n\t\t\tif(object instanceof TBaseElement){\n\t\t\t\tString id = ((TBaseElement) object).getId();\n\t\t\t\tif(id == null){\n\t\t\t\t\tnoIds.add(object);\n\t\t\t\t}\n\t\t\t\tif(ids.contains(id)){\n\t\t\t\t\tduplicatedIds.add(id);\n\t\t\t\t}\n\t\t\t\tids.add(id);\n\t\t\t}\n\t\t}\n\t\tif(!activityNames.isEmpty()){\n\t\t\tSystem.out.println(\"Some activity have disappeared for diagram:\" + bpmnFileName);\n\t\t\tfor (String activityName : activityNames) {\n\t\t\t\tSystem.out.println(activityName+\"\\n\");\n\t\t\t}\n\t\t}\n\t\tassertEquals(\"We don't find the same number of process\", nbProcess1, nbProcess2);\n\t\tassertTrue(\"There are missing processes:\"+processNames.toString(), processNames.isEmpty());\n\t\tassertEquals(\"We don't find the same number of boundaries event\", nbBoundaryEvent1, nbBoundaryEvent2);\n\t\tif(checkActivities){\n\t\t\tassertEquals(\"We don't find the same number of activities\", nbActivity1, nbActivity2);\n\t\t}\n\t\tassertEquals(\"We don't find the same number of TSignal defined\", nbTsignal1, nbTsignal2);\n\t\tif(checkEvents){\n\t\t\tassertEquals(\"We don't find the same number of TEvent defined\", nbEvents1, nbEvents2);\n\t\t}\n\t\tif(checkMessageFlow){\n\t\t\tassertEquals(\"We don't find the same number of TMessageFlow defined\", nbMessageFlow1, nbMessageFlow2);\n\t\t}\n\t\tassertTrue(\"There are null ids: \"+noIds, noIds.isEmpty());\n\t\tassertTrue(\"There are duplicated ids: \"+duplicatedIds, duplicatedIds.isEmpty());\n\t\tassertEquals(\"Some data were lost\", nbDataObject1, nbDataObject2);\n\t\tassertEquals(\"Some property (transient data) were lost\", nbProperty1, nbProperty2);\n\t}\n", "output": "\tprotected void checkSemantic(final String bpmnFileName,\n\t\t\tboolean checkActivities, boolean checkEvents,\n\t\t\tboolean checkMessageFlow, MainProcess mainProcess)\n\t\t\t\t\tthrows IOException {\n\t\tfinal Diagram diagramFor = ModelHelper.getDiagramFor(mainProcess,null);\n\t\tDiagramEditPart dep;\n\t\ttry{\n\t\t\tdep = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagramFor, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());\n\t\t} catch(Exception ex){\n\t\t\tdep = OffscreenEditPartFactory.getInstance().createDiagramEditPart(diagramFor, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());\n\t\t}\n\t\tMainProcessEditPart mped = (MainProcessEditPart) dep;\n\t\tIBonitaModelExporter exporter = new BonitaModelExporterImpl(mped) ;\n\t\tFile bpmnFileExported = File.createTempFile(\"withAllExported\", \".bpmn\");\n\t\tfinal boolean transformed = new BonitaToBPMN().transform(exporter, bpmnFileExported, new NullProgressMonitor());\n\t\tassertTrue(\"Error during export\", transformed);\n\t\tResourceSet resourceSet1 = new ResourceSetImpl();\n\t\tfinal Map extensionToFactoryMap = resourceSet1.getResourceFactoryRegistry().getExtensionToFactoryMap();\n\t\tfinal DiResourceFactoryImpl diResourceFactoryImpl = new DiResourceFactoryImpl();\n\t\textensionToFactoryMap.put(\"bpmn\", diResourceFactoryImpl);\n\t\tURL bpmnResource = FileLocator.toFileURL(BPMNImportExportTest.class.getResource(bpmnFileName));\n\t\tResource resource1 = resourceSet1.createResource(URI.createFileURI(new File(bpmnResource.getFile()).getAbsolutePath()));\n\t\tresource1.load(Collections.emptyMap());\n\t\tResource resource2 = resourceSet1.createResource(URI.createFileURI(bpmnFileExported.getAbsolutePath()));\n\t\tresource2.load(Collections.emptyMap());\n\t\tDocumentRoot model1 = (DocumentRoot) resource1.getContents().get(0);\n\t\tDocumentRoot model2 = (DocumentRoot) resource2.getContents().get(0);\n\t\tint nbProcess1 = 0;\n\t\tSet processNames = new HashSet();\n\t\tList activityNames = new ArrayList();\n\t\tint nbActivity1 = 0;\n\t\tint nbBoundaryEvent1 = 0;\n\t\tint nbTsignal1 = 0;\n\t\tint nbEvents1 = 0;\n\t\tint nbTextannotation1 = 0;\n\t\tint nbMessageFlow1 = 0;\n\t\tint nbProcessItemeDefinition1 = 0;\n\t\tint nbDataObject1 = 0;\n\t\tint nbProperty1 = 0;\n\t\tfor(TRootElement rootElement : model1.getDefinitions().getRootElement()){\n\t\t\tif(rootElement instanceof TProcess){\n\t\t\t\tnbProcess1++;\n\t\t\t\tfinal String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();\n\t\t\t\tprocessNames.add(processName);\n\t\t\t\tfor(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){\n\t\t\t\t\tif(tArtifact instanceof TTextAnnotation){\n\t\t\t\t\t\tnbTextannotation1++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){\n\t\t\t\t\tif(tFlowElement instanceof TActivity){ \t\n\t\t\t\t\t\tnbActivity1++;\n\t\t\t\t\t\tString name = getFlowElementName((TActivity) tFlowElement);\n\t\t\t\t\t\tactivityNames.add(name);\n\t\t\t\t\t\tif(tFlowElement instanceof TSubProcess){\n\t\t\t\t\t\t\tif(((TSubProcess) tFlowElement).isTriggeredByEvent()){\n\t\t\t\t\t\t\t\tnbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement) ;\n\t\t\t\t\t\t\t\tnbActivity1--;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnbProcess1++;\n\t\t\t\t\t\t\t\tnbActivity1 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSystem.out.println(\"activity count for model 1 \"+ nbActivity1 + tFlowElement.getId() +\" ### \"+ tFlowElement.getName());\n\t\t\t\t\t\tnbProperty1 += ((TActivity) tFlowElement).getProperty().size();\n\t\t\t\t\t} else if(tFlowElement instanceof TDataObject){\n\t\t\t\t\t\tnbDataObject1++;\n\t\t\t\t\t} else if(tFlowElement instanceof TIntermediateThrowEvent){\n\t\t\t\t\t\tif((((TThrowEvent) tFlowElement).getEventDefinition() == null\n\t\t\t\t\t\t\t\t|| ((TThrowEvent) tFlowElement).getEventDefinition().isEmpty())\n\t\t\t\t\t\t\t\t&& (((TThrowEvent) tFlowElement).getEventDefinitionRef() == null\n\t\t\t\t\t\t\t\t|| ((TThrowEvent) tFlowElement).getEventDefinitionRef().isEmpty())){\n\t\t\t\t\t\t\tnbActivity1++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if(rootElement instanceof TBoundaryEvent){\n\t\t\t\tnbBoundaryEvent1++;\n\t\t\t} else if(rootElement instanceof TSignal){\n\t\t\t\tnbTsignal1++;\n\t\t\t} else if(rootElement instanceof TEvent){\n\t\t\t\tnbEvents1++;\n\t\t\t} else if(rootElement instanceof TCollaboration){\n\t\t\t\tnbMessageFlow1+=((TCollaboration) rootElement).getMessageFlow().size();\n\t\t\t} else if(rootElement instanceof TItemDefinition){\n\t\t\t\tnbProcessItemeDefinition1++;\n\t\t\t}\n\t\t}\n\t\tint nbProcess2 = 0;\n\t\tint nbBoundaryEvent2 = 0;\n\t\tint nbActivity2 = 0;\n\t\tint nbTsignal2 = 0;\n\t\tint nbEvents2 = 0;\n\t\tint nbTextannotation2 = 0;\n\t\tint nbMessageFlow2 =0;\n\t\tint nbProcessItemeDefinition2 = 0;\n\t\tint nbDataObject2 = 0;\n\t\tint nbProperty2 = 0;\n\t\tfor(TRootElement rootElement : model2.getDefinitions().getRootElement()){\n\t\t\tif(rootElement instanceof TProcess){\n\t\t\t\tnbProcess2++;\n\t\t\t\tfinal String processName = ((TProcess) rootElement).getName() != null ? ((TProcess) rootElement).getName() : ((TProcess) rootElement).getId();\n\t\t\t\tif(!processNames.remove(processName)){\n\t\t\t\t\tSystem.out.println(processName+ \" has appeared\");\n\t\t\t\t}\n\t\t\t\tfor(TArtifact tArtifact :((TProcess) rootElement).getArtifact()){\n\t\t\t\t\tif(tArtifact instanceof TTextAnnotation){\n\t\t\t\t\t\tnbTextannotation2++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(TFlowElement tFlowElement : ((TProcess) rootElement).getFlowElement()){\n\t\t\t\t\tif(tFlowElement instanceof TActivity){\n\t\t\t\t\t\tnbActivity2++;\n\t\t\t\t\t\tString name = getFlowElementName((TActivity) tFlowElement);\n\t\t\t\t\t\tif(!activityNames.remove(name)){\n\t\t\t\t\t\t\tSystem.out.println(\"The activity : \"+name +\" is missing \");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tFlowElement instanceof TSubProcess){\n\t\t\t\t\t\t\tnbActivity2 += findNbActivitiesInSubProc((TSubProcess)tFlowElement);\n\t\t\t\t\t\t\tif(((TSubProcess) tFlowElement).isTriggeredByEvent()){\n\t\t\t\t\t\t\t\tnbActivity2--;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSystem.out.println(\"activity count for model 2 \"+ nbActivity2 + tFlowElement.getId() +\" ### \"+ tFlowElement.getName());\n\t\t\t\t\t\tnbProperty2 += ((TActivity) tFlowElement).getProperty().size();\n\t\t\t\t\t} else if(tFlowElement instanceof TDataObject){\n\t\t\t\t\t\tnbDataObject2++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if(rootElement instanceof TBoundaryEvent){\n\t\t\t\tnbBoundaryEvent2++;\n\t\t\t} else if(rootElement instanceof TSignal){\n\t\t\t\tnbTsignal2++;\n\t\t\t} else if(rootElement instanceof TEvent){\n\t\t\t\tnbEvents2++;\n\t\t\t} else if(rootElement instanceof TCollaboration){\n\t\t\t\tnbMessageFlow2 = ((TCollaboration) rootElement).getMessageFlow().size();\n\t\t\t} else if(rootElement instanceof TItemDefinition){\n\t\t\t\tnbProcessItemeDefinition2++;\n\t\t\t}\n\t\t}\n\t\tCollection ids = new HashSet();\n\t\tCollection duplicatedIds = new HashSet();\n\t\tCollection noIds = new HashSet();\n\t\tfor (Iterator iterator = model2.eAllContents(); iterator.hasNext();) {\n\t\t\tEObject object = iterator.next();\n\t\t\tif(object instanceof TBaseElement){\n\t\t\t\tString id = ((TBaseElement) object).getId();\n\t\t\t\tif(id == null){\n\t\t\t\t\tnoIds.add(object);\n\t\t\t\t}\n\t\t\t\tif(ids.contains(id)){\n\t\t\t\t\tduplicatedIds.add(id);\n\t\t\t\t}\n\t\t\t\tids.add(id);\n\t\t\t}\n\t\t}\n\t\tif(!activityNames.isEmpty()){\n\t\t\tSystem.out.println(\"Some activity have disappeared for diagram:\" + bpmnFileName);\n\t\t\tfor (String activityName : activityNames) {\n\t\t\t\tSystem.out.println(activityName+\"\\n\");\n\t\t\t}\n\t\t}\n\t\tassertEquals(\"We don't find the same number of process\", nbProcess1, nbProcess2);\n\t\tassertTrue(\"There are missing processes:\"+processNames.toString(), processNames.isEmpty());\n\t\tassertEquals(\"We don't find the same number of boundaries event\", nbBoundaryEvent1, nbBoundaryEvent2);\n\t\tif(checkActivities){\n\t\t\tassertEquals(\"We don't find the same number of activities\", nbActivity1, nbActivity2);\n\t\t}\n\t\tassertEquals(\"We don't find the same number of TSignal defined\", nbTsignal1, nbTsignal2);\n\t\tif(checkEvents){\n\t\t\tassertEquals(\"We don't find the same number of TEvent defined\", nbEvents1, nbEvents2);\n\t\t}\n\t\tif(checkMessageFlow){\n\t\t\tassertEquals(\"We don't find the same number of TMessageFlow defined\", nbMessageFlow1, nbMessageFlow2);\n\t\t}\n\t\tassertTrue(\"There are null ids: \"+noIds, noIds.isEmpty());\n\t\tassertTrue(\"There are duplicated ids: \"+duplicatedIds, duplicatedIds.isEmpty());\n\t\tassertEquals(\"Some data were lost\", nbDataObject1, nbDataObject2);\n\t\tassertEquals(\"Some property (transient data) were lost\", nbProperty1, nbProperty2);\n\t}\n"} {"input": " public static void coerceNamespaceAwarePropertyValues(AbstractBeanDefinition bd, Element element, PropertyDescriptor[] descriptors, int i) {\n PropertyDescriptor descriptor = descriptors[i];\n if (descriptor.getPropertyType().isAssignableFrom(QName.class)) {\n String name = descriptor.getName();\n MutablePropertyValues propertyValues = bd.getPropertyValues();\n PropertyValue propertyValue = propertyValues.getPropertyValue(name);\n if (propertyValue != null) {\n Object value = propertyValue.getValue();\n if (value instanceof String) {\n propertyValues.removePropertyValue(propertyValue);\n propertyValues.addPropertyValue(name, createQName(element, (String) value));\n }\n }\n } else if (descriptor.getPropertyType().isAssignableFrom(QName[].class)) {\n String name = descriptor.getName();\n MutablePropertyValues propertyValues = bd.getPropertyValues();\n PropertyValue propertyValue = propertyValues.getPropertyValue(name);\n if (propertyValue != null) {\n Object value = propertyValue.getValue();\n if (value instanceof List) {\n List values = (List) value;\n List newValues = new ManagedList();\n for (Iterator iter = values.iterator(); iter.hasNext();) {\n Object v = iter.next();\n if (v instanceof String) {\n newValues.add(createQName(element, (String) v));\n } else {\n newValues.add(v);\n }\n }\n propertyValues.removePropertyValue(propertyValue);\n propertyValues.addPropertyValue(name, newValues);\n }\n }\n }\n }\n", "output": " public static void coerceNamespaceAwarePropertyValues(AbstractBeanDefinition bd, Element element, PropertyDescriptor[] descriptors, int i) {\n PropertyDescriptor descriptor = descriptors[i];\n if (descriptor.getPropertyType() == null) {\n return;\n }\n if (descriptor.getPropertyType().isAssignableFrom(QName.class)) {\n String name = descriptor.getName();\n MutablePropertyValues propertyValues = bd.getPropertyValues();\n PropertyValue propertyValue = propertyValues.getPropertyValue(name);\n if (propertyValue != null) {\n Object value = propertyValue.getValue();\n if (value instanceof String) {\n propertyValues.removePropertyValue(propertyValue);\n propertyValues.addPropertyValue(name, createQName(element, (String) value));\n }\n }\n } else if (descriptor.getPropertyType().isAssignableFrom(QName[].class)) {\n String name = descriptor.getName();\n MutablePropertyValues propertyValues = bd.getPropertyValues();\n PropertyValue propertyValue = propertyValues.getPropertyValue(name);\n if (propertyValue != null) {\n Object value = propertyValue.getValue();\n if (value instanceof List) {\n List values = (List) value;\n List newValues = new ManagedList();\n for (Iterator iter = values.iterator(); iter.hasNext();) {\n Object v = iter.next();\n if (v instanceof String) {\n newValues.add(createQName(element, (String) v));\n } else {\n newValues.add(v);\n }\n }\n propertyValues.removePropertyValue(propertyValue);\n propertyValues.addPropertyValue(name, newValues);\n }\n }\n }\n }\n"} {"input": " public Configuration getUserConfiguration() throws ConfigurationException\n {\n if (userConfiguration == null)\n {\n String property = System.getProperty(USER_CONFIG_PATH);\n File userConfigurationFile;\n if (property == null || property.isEmpty())\n {\n userConfigurationFile = new File(OperatingSystemUtils.getUserForgeDir(), \"config.xml\");\n }\n else\n {\n userConfigurationFile = new File(property);\n }\n if (!userConfigurationFile.exists() || userConfigurationFile.length() == 0L)\n {\n userConfigurationFile.mkdirs();\n try (FileWriter fw = new FileWriter(userConfigurationFile))\n {\n fw.write(\"\");\n }\n catch (IOException e)\n {\n throw new ConfigurationException(\"Error while create user configuration\", e);\n }\n }\n userConfiguration = getConfiguration(userConfigurationFile);\n }\n return userConfiguration;\n }\n", "output": " public Configuration getUserConfiguration() throws ConfigurationException\n {\n if (userConfiguration == null)\n {\n String property = System.getProperty(USER_CONFIG_PATH);\n File userConfigurationFile;\n if (property == null || property.isEmpty())\n {\n userConfigurationFile = new File(OperatingSystemUtils.getUserForgeDir(), \"config.xml\");\n }\n else\n {\n userConfigurationFile = new File(property);\n }\n if (!userConfigurationFile.exists() || userConfigurationFile.length() == 0L)\n {\n File parentFile = userConfigurationFile.getParentFile();\n if (parentFile != null)\n {\n parentFile.mkdirs();\n }\n try (FileWriter fw = new FileWriter(userConfigurationFile))\n {\n fw.write(\"\");\n }\n catch (IOException e)\n {\n throw new ConfigurationException(\"Error while create user configuration\", e);\n }\n }\n userConfiguration = getConfiguration(userConfigurationFile);\n }\n return userConfiguration;\n }\n"} {"input": " public static void main(final String[] args) throws IOException, ParseException {\n final Option baseDirOpt = new Option(\"b\", \"base-dir\", true, \"Base directory for test search\");\n final Option includeOpt = new Option(\"i\", \"include\", true,\n \"Comma-separated list of Ant-style paths to the tests to run\");\n final Option excludeOpt = new Option(\"e\", \"exclude\", true,\n \"Comma-separated list of Ant-style paths to the tests to exclude from run\");\n final Option outputDirOpt = new Option(\"o\", \"output-dir\", true, \"The output directory for coverage reports\");\n final Option outputInstrumentedFilesOpt = new Option(\"f\", \"output-instrumented-files\", false,\n \"Whether to output instrumented files (default is false)\");\n final Option noInstrumentPatternOpt = new Option(\"n\", \"no-instrument-pattern\", true,\n \"Regular expression patterns to match classes to exclude from instrumentation\");\n noInstrumentPatternOpt.setArgs(Option.UNLIMITED_VALUES);\n final Option sourcesToPreloadOpt = new Option(\"p\", \"preload-sources\", true,\n \"Comma-separated list of Ant-style paths to files to preload\");\n final Option sourcesToPreloadEncodingOpt = new Option(null, \"preload-sources-encoding\", true,\n \"Encoding to use when preloading sources\");\n final Option threadCountOpt = new Option(\"t\", \"thread-count\", true,\n \"The maximum number of threads to use (defaults to the number of cores)\");\n final Option outputStrategyOpt = new Option(\"s\", \"output-strategy\", true,\n \"Coverage report output strategy. One of \" + Arrays.toString(OutputStrategy.values()));\n final Option includeInlineScriptsOpt = new Option(\"d\", \"include-inline-scripts\", false,\n \"Whether to include inline scripts into instrumentation by default (default is false)\");\n final Option backgroundJavaScriptTimeoutOpt = new Option(\"j\", \"background-javascript-timeout\", true,\n \"How long to wait for background JavaScript to finish running (in milliseconds, default is 5 minutes)\");\n final Option browserVersionOpt = new Option(\"v\", \"browser-version\", true,\n \"Determines the browser and version profile that HtmlUnit will simulate\");\n final Option reportFormatsOpt = new Option(null, \"report-formats\", true,\n \"A comma-separated list of formats of the reports to be generated. Valid values are: HTML, RAW, CSV\");\n final Option helpOpt = new Option(\"h\", \"help\", false, \"Print this message\");\n final Options options = new Options();\n options.addOption(baseDirOpt);\n options.addOption(includeOpt);\n options.addOption(excludeOpt);\n options.addOption(outputDirOpt);\n options.addOption(outputInstrumentedFilesOpt);\n options.addOption(noInstrumentPatternOpt);\n options.addOption(threadCountOpt);\n options.addOption(outputStrategyOpt);\n options.addOption(includeInlineScriptsOpt);\n options.addOption(helpOpt);\n options.addOption(sourcesToPreloadOpt);\n options.addOption(sourcesToPreloadEncodingOpt);\n options.addOption(backgroundJavaScriptTimeoutOpt);\n options.addOption(browserVersionOpt);\n options.addOption(reportFormatsOpt);\n try {\n CommandLineParser parser = new GnuParser();\n CommandLine line = parser.parse(options, args, false);\n baseDirOpt.setRequired(true);\n includeOpt.setRequired(true);\n outputDirOpt.setRequired(true);\n options.addOption(baseDirOpt);\n options.addOption(includeOpt);\n options.addOption(outputDirOpt);\n if (line.hasOption(helpOpt.getOpt())) {\n printHelpAndExit(options);\n }\n parser = new GnuParser();\n line = parser.parse(options, args);\n final File baseDir = new File(line.getOptionValue(baseDirOpt.getOpt()));\n final String includes = line.getOptionValue(includeOpt.getOpt());\n final String excludes = line.getOptionValue(excludeOpt.getOpt());\n final File outputDir = new File(line.getOptionValue(outputDirOpt.getOpt()));\n final CoverageGenerator gen = new CoverageGenerator(baseDir, includes, excludes, outputDir);\n if (line.hasOption(outputInstrumentedFilesOpt.getOpt())) {\n gen.setOutputInstrumentedFiles(true);\n }\n gen.setNoInstrumentPatterns(line.getOptionValues(noInstrumentPatternOpt.getOpt()));\n gen.setSourcesToPreload(line.getOptionValue(sourcesToPreloadOpt.getOpt()));\n gen.setOutputStrategy(line.getOptionValue(outputStrategyOpt.getOpt()));\n final String threadCount = line.getOptionValue(threadCountOpt.getOpt());\n if (threadCount != null) {\n try {\n gen.setThreadCount(Integer.parseInt(threadCount));\n } catch (final Exception e) {\n System.err.println(\"Invalid thread count\");\n printHelpAndExit(options);\n }\n }\n if (line.hasOption(includeInlineScriptsOpt.getOpt())) {\n gen.setIncludeInlineScripts(true);\n }\n final String backgroundJavaScriptTimeout = line.getOptionValue(backgroundJavaScriptTimeoutOpt.getOpt());\n if (backgroundJavaScriptTimeout != null) {\n try {\n gen.setBackgroundJavaScriptTimeout(Long.valueOf(backgroundJavaScriptTimeout));\n } catch (final Exception e) {\n System.err.println(\"Invalid timeout\");\n printHelpAndExit(options);\n }\n }\n gen.setBrowserVersion(line.getOptionValue(browserVersionOpt.getOpt()));\n gen.setReportFormats(line.getOptionValue(reportFormatsOpt.getOpt()));\n gen.run();\n } catch (final MissingOptionException e) {\n System.err.println(e.getMessage());\n printHelpAndExit(options);\n } catch (final UnrecognizedOptionException e) {\n System.err.println(e.getMessage());\n printHelpAndExit(options);\n } catch (final ParseException e) {\n System.err.println(e.getMessage());\n System.exit(1);\n }\n }\n", "output": " public static void main(final String[] args) throws IOException, ParseException {\n final Option baseDirOpt = new Option(\"b\", \"base-dir\", true, \"Base directory for test search\");\n final Option includeOpt = new Option(\"i\", \"include\", true,\n \"Comma-separated list of Ant-style paths to the tests to run\");\n final Option excludeOpt = new Option(\"e\", \"exclude\", true,\n \"Comma-separated list of Ant-style paths to the tests to exclude from run\");\n final Option outputDirOpt = new Option(\"o\", \"output-dir\", true, \"The output directory for coverage reports\");\n final Option outputInstrumentedFilesOpt = new Option(\"f\", \"output-instrumented-files\", false,\n \"Whether to output instrumented files (default is false)\");\n final Option noInstrumentPatternOpt = new Option(\"n\", \"no-instrument-pattern\", true,\n \"Regular expression patterns to match classes to exclude from instrumentation\");\n noInstrumentPatternOpt.setArgs(Option.UNLIMITED_VALUES);\n final Option sourcesToPreloadOpt = new Option(\"p\", \"preload-sources\", true,\n \"Comma-separated list of Ant-style paths to files to preload\");\n final Option sourcesToPreloadEncodingOpt = new Option(null, \"preload-sources-encoding\", true,\n \"Encoding to use when preloading sources\");\n final Option threadCountOpt = new Option(\"t\", \"thread-count\", true,\n \"The maximum number of threads to use (defaults to the number of cores)\");\n final Option outputStrategyOpt = new Option(\"s\", \"output-strategy\", true,\n \"Coverage report output strategy. One of \" + Arrays.toString(OutputStrategy.values()));\n final Option includeInlineScriptsOpt = new Option(\"d\", \"include-inline-scripts\", false,\n \"Whether to include inline scripts into instrumentation by default (default is false)\");\n final Option backgroundJavaScriptTimeoutOpt = new Option(\"j\", \"background-javascript-timeout\", true,\n \"How long to wait for background JavaScript to finish running (in milliseconds, default is 5 minutes)\");\n final Option browserVersionOpt = new Option(\"v\", \"browser-version\", true,\n \"Determines the browser and version profile that HtmlUnit will simulate\");\n final Option reportFormatsOpt = new Option(null, \"report-formats\", true,\n \"A comma-separated list of formats of the reports to be generated. Valid values are: HTML, RAW, CSV\");\n final Option helpOpt = new Option(\"h\", \"help\", false, \"Print this message\");\n final Options options = new Options();\n options.addOption(baseDirOpt);\n options.addOption(includeOpt);\n options.addOption(excludeOpt);\n options.addOption(outputDirOpt);\n options.addOption(outputInstrumentedFilesOpt);\n options.addOption(noInstrumentPatternOpt);\n options.addOption(threadCountOpt);\n options.addOption(outputStrategyOpt);\n options.addOption(includeInlineScriptsOpt);\n options.addOption(helpOpt);\n options.addOption(sourcesToPreloadOpt);\n options.addOption(sourcesToPreloadEncodingOpt);\n options.addOption(backgroundJavaScriptTimeoutOpt);\n options.addOption(browserVersionOpt);\n options.addOption(reportFormatsOpt);\n try {\n CommandLineParser parser = new GnuParser();\n CommandLine line = parser.parse(options, args, false);\n baseDirOpt.setRequired(true);\n includeOpt.setRequired(true);\n outputDirOpt.setRequired(true);\n options.addOption(baseDirOpt);\n options.addOption(includeOpt);\n options.addOption(outputDirOpt);\n if (line.hasOption(helpOpt.getLongOpt())) {\n printHelpAndExit(options);\n }\n parser = new GnuParser();\n line = parser.parse(options, args);\n final File baseDir = new File(line.getOptionValue(baseDirOpt.getLongOpt()));\n final String includes = line.getOptionValue(includeOpt.getLongOpt());\n final String excludes = line.getOptionValue(excludeOpt.getLongOpt());\n final File outputDir = new File(line.getOptionValue(outputDirOpt.getLongOpt()));\n final CoverageGenerator gen = new CoverageGenerator(baseDir, includes, excludes, outputDir);\n if (line.hasOption(outputInstrumentedFilesOpt.getLongOpt())) {\n gen.setOutputInstrumentedFiles(true);\n }\n gen.setNoInstrumentPatterns(line.getOptionValues(noInstrumentPatternOpt.getLongOpt()));\n gen.setSourcesToPreload(line.getOptionValue(sourcesToPreloadOpt.getLongOpt()));\n gen.setOutputStrategy(line.getOptionValue(outputStrategyOpt.getLongOpt()));\n final String threadCount = line.getOptionValue(threadCountOpt.getLongOpt());\n if (threadCount != null) {\n try {\n gen.setThreadCount(Integer.parseInt(threadCount));\n } catch (final Exception e) {\n System.err.println(\"Invalid thread count\");\n printHelpAndExit(options);\n }\n }\n if (line.hasOption(includeInlineScriptsOpt.getLongOpt())) {\n gen.setIncludeInlineScripts(true);\n }\n final String backgroundJavaScriptTimeout = line.getOptionValue(backgroundJavaScriptTimeoutOpt.getLongOpt());\n if (backgroundJavaScriptTimeout != null) {\n try {\n gen.setBackgroundJavaScriptTimeout(Long.valueOf(backgroundJavaScriptTimeout));\n } catch (final Exception e) {\n System.err.println(\"Invalid timeout\");\n printHelpAndExit(options);\n }\n }\n gen.setBrowserVersion(line.getOptionValue(browserVersionOpt.getLongOpt()));\n gen.setReportFormats(line.getOptionValue(reportFormatsOpt.getLongOpt()));\n gen.run();\n } catch (final MissingOptionException e) {\n System.err.println(e.getMessage());\n printHelpAndExit(options);\n } catch (final UnrecognizedOptionException e) {\n System.err.println(e.getMessage());\n printHelpAndExit(options);\n } catch (final ParseException e) {\n System.err.println(e.getMessage());\n System.exit(1);\n }\n }\n"} {"input": " public void onSensorChanged(SensorEvent arg) {\n double leftPower, rightPower;\n double accel = (arg.values[2]/50.) * 100;\n double orient = (arg.values[1]/50.) * 50;\n leftPower = accel;\n rightPower = accel;\n if(arg.values[1] > 0)\n {\n leftPower += orient;\n }\n else\n {\n rightPower -= orient;\n }\n if(leftPower > 100) leftPower = 100;\n if(leftPower < -100) leftPower = -100;\n if(rightPower > 100) rightPower = 100;\n if(rightPower < -100) rightPower = -100;\n this.tv.setText(String.format(\"%.2f %.2f %.2f\\n%3.0f %3.0f\\n%3.0f %3.0f\", arg.values[0], arg.values[1], arg.values[2], accel, orient, leftPower, rightPower));\n }\n", "output": " public void onSensorChanged(SensorEvent arg) {\n double leftPower, rightPower;\n double accel = (arg.values[2]/50.) * 100;\n double orient = (arg.values[1]/50.) * 50;\n leftPower = accel;\n rightPower = accel;\n if(arg.values[1] > 0)\n {\n leftPower -= orient;\n }\n else\n {\n rightPower += orient;\n }\n if(leftPower > 100) leftPower = 100;\n if(leftPower < -100) leftPower = -100;\n if(rightPower > 100) rightPower = 100;\n if(rightPower < -100) rightPower = -100;\n this.tv.setText(String.format(\"%.2f %.2f %.2f\\n%3.0f %3.0f\\n%3.0f %3.0f\", arg.values[0], arg.values[1], arg.values[2], accel, orient, leftPower, rightPower));\n }\n"} {"input": " public static void printLabelings(Classifier classifier, File vectorfile, String outputFilename) throws IOException {\n CsvIterator reader =\n new CsvIterator(new FileReader(vectorfile),\n \"(.+)\\\\t(.+)\\\\t(.*)\",\n 3, 2, 1);\n Iterator instances =\n classifier.getInstancePipe().newIteratorFrom(reader);\n CsvIterator reader2 = \n new CsvIterator(new FileReader(vectorfile),\n \"(.+)\\\\t(.+)\\\\t(.*)\",\n 3, 2, 1);\n PrintStream output = new PrintStream(new FileOutputStream(outputFilename));\n while (instances.hasNext()) {\n \tInstance reader2Instance = reader2.next();\n \tInstance instance = (Instance) instances.next();\n Labeling labeling = classifier.classify(instance).getLabeling();\n output.print(instance.getName() + \"\\t\");\n Object trueLabel = reader2Instance.getTarget();\n if(trueLabel!=null)\n \toutput.print(trueLabel.toString() + \"\\t\");\n for (int rank = 0; rank < labeling.numLocations(); rank++){\n output.print(labeling.getLabelAtRank(rank) + \":\" +\n labeling.getValueAtRank(rank) + \" \");\n }\n output.println();\n }\n }\n", "output": " public static void printLabelings(Classifier classifier, File vectorfile, String outputFilename) throws IOException {\n CsvIterator reader =\n new CsvIterator(new FileReader(vectorfile),\n \"(.+)\\\\t(.*)\\\\t(.*)\",\n 3, 2, 1);\n Iterator instances =\n classifier.getInstancePipe().newIteratorFrom(reader);\n CsvIterator reader2 = \n new CsvIterator(new FileReader(vectorfile),\n \"(.+)\\\\t(.*)\\\\t(.*)\",\n 3, 2, 1);\n PrintStream output = new PrintStream(new FileOutputStream(outputFilename));\n while (instances.hasNext()) {\n \tInstance reader2Instance = reader2.next();\n \tInstance instance = (Instance) instances.next();\n Labeling labeling = classifier.classify(instance).getLabeling();\n output.print(instance.getName() + \"\\t\");\n Object trueLabel = reader2Instance.getTarget();\n if(trueLabel!=null)\n \toutput.print(trueLabel.toString() + \"\\t\");\n for (int rank = 0; rank < labeling.numLocations(); rank++){\n output.print(labeling.getLabelAtRank(rank) + \":\" +\n labeling.getValueAtRank(rank) + \" \");\n }\n output.println();\n }\n }\n"} {"input": " protected void run() throws Exception {\n DBService dbs = core.getDBService();\n if (!dbs.isDBSessionActive()) {\n dbs.startDBSession();\n }\n sp = dbs.attachObjectToDBSession(sp);\n HashMap properties = new HashMap();\n properties.put(\"project\", sp);\n List assosRules = dbs.findObjectsByProperties(InvocationRule.class,\n properties);\n if ((assosRules != null) && (assosRules.size() > 0)) {\n for (Object nextDAO : assosRules) {\n InvocationRule.deleteInvocationRule(dbs, \n core.getMetricActivator(), (InvocationRule) nextDAO);\n }\n }\n List ps = (List) dbs.doHQL(\"from Plugin\"); \n for (Plugin p : ps ) {\n AlitheiaPlugin ap = core.getPluginAdmin().getPlugin(core.getPluginAdmin().getPluginInfo(p.getHashcode()));\n ap.cleanup(sp);\n }\n boolean success = true;\n ClusterNodeProject cnp = ClusterNodeProject.getProjectAssignment(sp);\n if (cnp != null) {\n success &= dbs.deleteRecord(cnp);\n }\n List confParams = StoredProjectConfig.fromProject(sp);\n if (!confParams.isEmpty()) {\n \tsuccess &= dbs.deleteRecords(confParams);\n }\n success &= dbs.deleteRecord(sp);\n if (success) {\n dbs.commitDBSession();\n } else {\n dbs.rollbackDBSession();\n }\n }\n", "output": " protected void run() throws Exception {\n DBService dbs = core.getDBService();\n if (!dbs.isDBSessionActive()) {\n dbs.startDBSession();\n }\n sp = dbs.attachObjectToDBSession(sp);\n HashMap properties = new HashMap();\n properties.put(\"project\", sp);\n List assosRules = dbs.findObjectsByProperties(InvocationRule.class,\n properties);\n if ((assosRules != null) && (assosRules.size() > 0)) {\n for (Object nextDAO : assosRules) {\n InvocationRule.deleteInvocationRule(dbs, \n core.getMetricActivator(), (InvocationRule) nextDAO);\n }\n }\n List ps = (List) dbs.doHQL(\"from Plugin\"); \n for (Plugin p : ps ) {\n AlitheiaPlugin ap = core.getPluginAdmin().getPlugin(core.getPluginAdmin().getPluginInfo(p.getHashcode()));\n ap.cleanup(sp);\n }\n boolean success = true;\n List confParams = StoredProjectConfig.fromProject(sp);\n if (!confParams.isEmpty()) {\n \tsuccess &= dbs.deleteRecords(confParams);\n }\n success &= dbs.deleteRecord(sp);\n if (success) {\n dbs.commitDBSession();\n } else {\n dbs.rollbackDBSession();\n }\n }\n"} {"input": " protected int run() throws Exception {\n Team targetTeam = validateTeam(team, create, stderr);\n Hudson h = Hudson.getInstance();\n TeamManager teamManager = h.getTeamManager();\n if (team != null && targetTeam == null) {\n return -1;\n }\n String qualifiedJobName = targetTeam == null\n ? getNewJobName(name)\n : teamManager.getRawTeamQualifiedJobName(targetTeam, name);\n TopLevelItem item = h.getItem(qualifiedJobName);\n if (item == null && !create) {\n stderr.println(\"Job '\" + qualifiedJobName + \"' does not exist and create is set to false\");\n return -1;\n } else if (item != null && create) {\n stderr.println(\"Job '\" + qualifiedJobName + \"' already exists and create is set to true\");\n return -1;\n }\n if (item == null) {\n name = name.trim();\n if (!isGoodName(name, stderr)) {\n return -1;\n }\n h.checkPermission(Item.CREATE);\n h.createProjectFromXML(name, team, stdin);\n } else {\n XmlFile oldConfigXml = null;\n Object oldItem = null;\n try {\n h.checkPermission(Job.CONFIGURE);\n File rootDirOfJob = teamManager.getRootFolderForJob(item.getName());\n oldConfigXml = Items.getConfigFile(rootDirOfJob);\n oldItem = oldConfigXml.read();\n File configXml = oldConfigXml.getFile();\n IOUtils.copy(stdin, configXml);\n h.reloadProjectFromDisk(configXml.getParentFile());\n } catch (IOException e) {\n if (oldConfigXml != null && oldItem != null) {\n oldConfigXml.write(oldItem);\n }\n throw e;\n }\n }\n return 0;\n }\n", "output": " protected int run() throws Exception {\n Team targetTeam = validateTeam(team, create, stderr);\n Hudson h = Hudson.getInstance();\n TeamManager teamManager = h.getTeamManager();\n if (team != null && targetTeam == null) {\n return -1;\n }\n String qualifiedJobName = !create ? name :\n (targetTeam == null\n ? getNewJobName(name)\n : teamManager.getRawTeamQualifiedJobName(targetTeam, name));\n TopLevelItem item = h.getItem(qualifiedJobName);\n if (item == null && !create) {\n stderr.println(\"Job '\" + qualifiedJobName + \"' does not exist and create is set to false\");\n return -1;\n } else if (item != null && create) {\n stderr.println(\"Job '\" + qualifiedJobName + \"' already exists and create is set to true\");\n return -1;\n }\n if (item == null) {\n name = name.trim();\n if (!isGoodName(name, stderr)) {\n return -1;\n }\n h.checkPermission(Item.CREATE);\n h.createProjectFromXML(name, team, stdin);\n } else {\n XmlFile oldConfigXml = null;\n Object oldItem = null;\n try {\n item.checkPermission(Job.CONFIGURE);\n File rootDirOfJob = teamManager.getRootFolderForJob(item.getName());\n oldConfigXml = Items.getConfigFile(rootDirOfJob);\n oldItem = oldConfigXml.read();\n File configXml = oldConfigXml.getFile();\n IOUtils.copy(stdin, configXml);\n h.reloadProjectFromDisk(configXml.getParentFile());\n } catch (IOException e) {\n if (oldConfigXml != null && oldItem != null) {\n oldConfigXml.write(oldItem);\n }\n throw e;\n }\n }\n return 0;\n }\n"} {"input": "\tpublic List findAllDevs() {\n\t\tList alldevs = new ArrayList();\n\t\tStringBuilder errbuf = new StringBuilder();\n\t\tList devs = new ArrayList();\n\t\tint r = Pcap.findAllDevs(alldevs, errbuf);\n\t\tif (r == Pcap.NOT_OK || alldevs.isEmpty()) {\n\t\t\tSystem.err.printf(\"Cannot read list of devices, error is %s\\n\",\n\t\t\t\t\terrbuf.toString());\n\t\t\treturn null;\n\t\t}\n\t\tint index = 0;\n\t\tfor (PcapIf device : alldevs)\n\t\t\tdevs.add(new DevInfo(index, device.getName(), device.getDescription()));\n\t\treturn devs;\n\t}\n", "output": "\tpublic List findAllDevs() {\n\t\tList alldevs = new ArrayList();\n\t\tStringBuilder errbuf = new StringBuilder();\n\t\tList devs = new ArrayList();\n\t\tint r = Pcap.findAllDevs(alldevs, errbuf);\n\t\tif (r == Pcap.NOT_OK || alldevs.isEmpty()) {\n\t\t\tSystem.err.printf(\"Cannot read list of devices, error is %s\\n\",\n\t\t\t\t\terrbuf.toString());\n\t\t\treturn null;\n\t\t}\n\t\tint index = 0;\n\t\tfor (PcapIf device : alldevs)\n\t\t\tdevs.add(new DevInfo(index++, device.getName(), device.getDescription()));\n\t\treturn devs;\n\t}\n"} {"input": "\tpublic void SchritteKopieren(Prozess prozessVorlage, Prozess prozessKopie) {\n\t\tHashSet mySchritte = new HashSet();\n\t\tfor (Schritt step : prozessVorlage.getSchritteList()) {\n\t\t\tSchritt stepneu = new Schritt();\n\t\t\tstepneu.setTypAutomatisch(step.isTypAutomatisch());\n\t\t\tstepneu.setScriptname1(step.getScriptname1());\n\t\t\tstepneu.setScriptname2(step.getScriptname2());\n\t\t\tstepneu.setScriptname3(step.getScriptname3());\n\t\t\tstepneu.setScriptname4(step.getScriptname4());\n\t\t\tstepneu.setScriptname5(step.getScriptname5());\n\t\t\tstepneu.setTypAutomatischScriptpfad(step.getTypAutomatischScriptpfad());\n\t\t\tstepneu.setTypAutomatischScriptpfad2(step.getTypAutomatischScriptpfad2());\n\t\t\tstepneu.setTypAutomatischScriptpfad3(step.getTypAutomatischScriptpfad3());\n\t\t\tstepneu.setTypAutomatischScriptpfad4(step.getTypAutomatischScriptpfad4());\n\t\t\tstepneu.setTypAutomatischScriptpfad5(step.getTypAutomatischScriptpfad5());\n\t\t\tstepneu.setBatchStep(step.getBatchStep());\n\t\t\tstepneu.setTypScriptStep(step.getTypScriptStep());\n\t\t\tstepneu.setTypBeimAnnehmenAbschliessen(step.isTypBeimAnnehmenAbschliessen());\n\t\t\tstepneu.setTypBeimAnnehmenModul(step.isTypBeimAnnehmenModul());\n\t\t\tstepneu.setTypBeimAnnehmenModulUndAbschliessen(step.isTypBeimAnnehmenModulUndAbschliessen());\n\t\t\tstepneu.setTypExportDMS(step.isTypExportDMS());\n\t\t\tstepneu.setTypExportRus(step.isTypExportRus());\n\t\t\tstepneu.setTypImagesLesen(step.isTypImagesLesen());\n\t\t\tstepneu.setTypImagesSchreiben(step.isTypImagesSchreiben());\n\t\t\tstepneu.setTypImportFileUpload(step.isTypImportFileUpload());\n\t\t\tstepneu.setTypMetadaten(step.isTypMetadaten());\n\t\t\tstepneu.setPrioritaet(step.getPrioritaet());\n\t\t\tstepneu.setBearbeitungsstatusEnum(step.getBearbeitungsstatusEnum());\n\t\t\tstepneu.setReihenfolge(step.getReihenfolge());\n\t\t\tstepneu.setTitel(step.getTitel());\n\t\t\tstepneu.setHomeverzeichnisNutzen(step.getHomeverzeichnisNutzen());\n\t\t\tstepneu.setProzess(prozessKopie);\n\t\t\tstepneu.setStepPlugin(step.getStepPlugin());\n\t\t\tstepneu.setValidationPlugin(step.getValidationPlugin());\n\t\t\tstepneu.setTypBeimAbschliessenVerifizieren(step.isTypBeimAbschliessenVerifizieren());\n\t\t\tHashSet myEigenschaften = new HashSet();\n\t\t\tfor (Schritteigenschaft eig : step.getEigenschaftenList()) {\n\t\t\t\tSchritteigenschaft eigneu = new Schritteigenschaft();\n\t\t\t\teigneu.setIstObligatorisch(eig.isIstObligatorisch());\n\t\t\t\teigneu.setType(eig.getType());\n\t\t\t\teigneu.setTitel(eig.getTitel());\n\t\t\t\teigneu.setWert(eig.getWert());\n\t\t\t\teigneu.setSchritt(stepneu);\n\t\t\t\tmyEigenschaften.add(eigneu);\n\t\t\t}\n\t\t\tstepneu.setEigenschaften(myEigenschaften);\n\t\t\tHashSet myBenutzer = new HashSet();\n\t\t\tfor (Benutzer benneu : step.getBenutzer()) {\n\t\t\t\tmyBenutzer.add(benneu);\n\t\t\t}\n\t\t\tstepneu.setBenutzer(myBenutzer);\n\t\t\tHashSet myBenutzergruppen = new HashSet();\n\t\t\tfor (Benutzergruppe grupneu : step.getBenutzergruppen()) {\n\t\t\t\tmyBenutzergruppen.add(grupneu);\n\t\t\t}\n\t\t\tstepneu.setBenutzergruppen(myBenutzergruppen);\n\t\t\tmySchritte.add(stepneu);\n\t\t}\n\t\tprozessKopie.setSchritte(mySchritte);\n\t}\n", "output": "\tpublic void SchritteKopieren(Prozess prozessVorlage, Prozess prozessKopie) {\n\t\tHashSet mySchritte = new HashSet();\n\t\tfor (Schritt step : prozessVorlage.getSchritteList()) {\n\t\t\tSchritt stepneu = new Schritt();\n\t\t\tstepneu.setTypAutomatisch(step.isTypAutomatisch());\n\t\t\tstepneu.setScriptname1(step.getScriptname1());\n\t\t\tstepneu.setScriptname2(step.getScriptname2());\n\t\t\tstepneu.setScriptname3(step.getScriptname3());\n\t\t\tstepneu.setScriptname4(step.getScriptname4());\n\t\t\tstepneu.setScriptname5(step.getScriptname5());\n\t\t\tstepneu.setTypAutomatischScriptpfad(step.getTypAutomatischScriptpfad());\n\t\t\tstepneu.setTypAutomatischScriptpfad2(step.getTypAutomatischScriptpfad2());\n\t\t\tstepneu.setTypAutomatischScriptpfad3(step.getTypAutomatischScriptpfad3());\n\t\t\tstepneu.setTypAutomatischScriptpfad4(step.getTypAutomatischScriptpfad4());\n\t\t\tstepneu.setTypAutomatischScriptpfad5(step.getTypAutomatischScriptpfad5());\n\t\t\tstepneu.setBatchStep(step.getBatchStep());\n\t\t\tstepneu.setTypScriptStep(step.getTypScriptStep());\n\t\t\tstepneu.setTypBeimAnnehmenAbschliessen(step.isTypBeimAnnehmenAbschliessen());\n\t\t\tstepneu.setTypBeimAnnehmenModul(step.isTypBeimAnnehmenModul());\n\t\t\tstepneu.setTypBeimAnnehmenModulUndAbschliessen(step.isTypBeimAnnehmenModulUndAbschliessen());\n\t\t\tstepneu.setTypModulName(step.getTypModulName());\n\t\t\tstepneu.setTypExportDMS(step.isTypExportDMS());\n\t\t\tstepneu.setTypExportRus(step.isTypExportRus());\n\t\t\tstepneu.setTypImagesLesen(step.isTypImagesLesen());\n\t\t\tstepneu.setTypImagesSchreiben(step.isTypImagesSchreiben());\n\t\t\tstepneu.setTypImportFileUpload(step.isTypImportFileUpload());\n\t\t\tstepneu.setTypMetadaten(step.isTypMetadaten());\n\t\t\tstepneu.setPrioritaet(step.getPrioritaet());\n\t\t\tstepneu.setBearbeitungsstatusEnum(step.getBearbeitungsstatusEnum());\n\t\t\tstepneu.setReihenfolge(step.getReihenfolge());\n\t\t\tstepneu.setTitel(step.getTitel());\n\t\t\tstepneu.setHomeverzeichnisNutzen(step.getHomeverzeichnisNutzen());\n\t\t\tstepneu.setProzess(prozessKopie);\n\t\t\tstepneu.setStepPlugin(step.getStepPlugin());\n\t\t\tstepneu.setValidationPlugin(step.getValidationPlugin());\n\t\t\tstepneu.setTypBeimAbschliessenVerifizieren(step.isTypBeimAbschliessenVerifizieren());\n\t\t\tHashSet myEigenschaften = new HashSet();\n\t\t\tfor (Schritteigenschaft eig : step.getEigenschaftenList()) {\n\t\t\t\tSchritteigenschaft eigneu = new Schritteigenschaft();\n\t\t\t\teigneu.setIstObligatorisch(eig.isIstObligatorisch());\n\t\t\t\teigneu.setType(eig.getType());\n\t\t\t\teigneu.setTitel(eig.getTitel());\n\t\t\t\teigneu.setWert(eig.getWert());\n\t\t\t\teigneu.setSchritt(stepneu);\n\t\t\t\tmyEigenschaften.add(eigneu);\n\t\t\t}\n\t\t\tstepneu.setEigenschaften(myEigenschaften);\n\t\t\tHashSet myBenutzer = new HashSet();\n\t\t\tfor (Benutzer benneu : step.getBenutzer()) {\n\t\t\t\tmyBenutzer.add(benneu);\n\t\t\t}\n\t\t\tstepneu.setBenutzer(myBenutzer);\n\t\t\tHashSet myBenutzergruppen = new HashSet();\n\t\t\tfor (Benutzergruppe grupneu : step.getBenutzergruppen()) {\n\t\t\t\tmyBenutzergruppen.add(grupneu);\n\t\t\t}\n\t\t\tstepneu.setBenutzergruppen(myBenutzergruppen);\n\t\t\tmySchritte.add(stepneu);\n\t\t}\n\t\tprozessKopie.setSchritte(mySchritte);\n\t}\n"} {"input": "\tpublic SampleProvider() {\n\t\tsuper(AUTHORITY, DB_VERSION);\n\t\tfinal DBHelper messageHelper = new GenericDBHelper(Message.class,\n\t\t\t\tMessage.CONTENT_URI);\n\t\taddDirAndItemUri(messageHelper, Message.PATH);\n\t}\n", "output": "\tpublic SampleProvider() {\n\t\tsuper(AUTHORITY, DB_VERSION);\n\t\tfinal DBHelper messageHelper = new GenericDBHelper(Message.class);\n\t\taddDirAndItemUri(messageHelper, Message.PATH);\n\t}\n"} {"input": "\tprivate void print(Method method, Object[] args) {\n if (shouldPrint()) {\n \tif (\"prepareStmt\".equals(method.getName())) {\n \t\tprint(\"prepareStmt: \" + args[0]);\n if (((String)args[0]).indexOf(\"ODE_SCOPE\") > 0) {\n for (StackTraceElement traceElement : Thread.currentThread().getStackTrace()) {\n print(traceElement.toString());\n }\n }\n \t} else if (\"prepareCall\".equals(method.getName())) {\n \t\tprint(\"prepareCall: \" + args[0]);\n \t} else if (\"close\".equals(method.getName())) {\n \t\tprint(\"close()\");\n \t} else if (\"commit\".equals(method.getName())) {\n \t\tprint(\"commit()\");\n \t} else if (\"rollback\".equals(method.getName())) {\n \t\tprint(\"rollback()\");\n \t} else if (\"setTransactionIsolation\".equals(method.getName())) {\n \t\tprint(\"Set isolation level to \" + args[0]);\n \t} \n \t else if (method.getName().startsWith(\"execute\")) {\n \t\tprint(method.getName() + \", \" + getParams());\n \t} else if (\"clearParameters\".equals(method.getName())) {\n \t\t_paramsByIdx.clear();\n \t\t_paramsByName.clear();\n \t} else if (\"setNull\".equals(method.getName())) {\n \t\tif (String.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByName.put((String)args[0], null);\n \t\t} else if (Integer.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByIdx.put((Integer)args[0], null);\n \t\t}\n \t} else if (PARAMSTYPES.contains(method.getName())){\n \t\tif (String.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByName.put((String)args[0], args[1]);\n \t\t} else if (Integer.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByIdx.put((Integer)args[0], args[1]);\n \t\t}\n \t}\n }\n\t}\n", "output": "\tprivate void print(Method method, Object[] args) {\n if (shouldPrint()) {\n \tif (\"prepareStatement\".equals(method.getName())) {\n \t\tprint(\"prepareStmt: \" + args[0]);\n if (((String)args[0]).indexOf(\"ODE_SCOPE\") > 0) {\n for (StackTraceElement traceElement : Thread.currentThread().getStackTrace()) {\n print(traceElement.toString());\n }\n }\n \t} else if (\"prepareCall\".equals(method.getName())) {\n \t\tprint(\"prepareCall: \" + args[0]);\n \t} else if (\"close\".equals(method.getName())) {\n \t\tprint(\"close()\");\n \t} else if (\"commit\".equals(method.getName())) {\n \t\tprint(\"commit()\");\n \t} else if (\"rollback\".equals(method.getName())) {\n \t\tprint(\"rollback()\");\n \t} else if (\"setTransactionIsolation\".equals(method.getName())) {\n \t\tprint(\"Set isolation level to \" + args[0]);\n \t} \n \t else if (method.getName().startsWith(\"execute\")) {\n \t\tprint(method.getName() + \", \" + getParams());\n \t} else if (\"clearParameters\".equals(method.getName())) {\n \t\t_paramsByIdx.clear();\n \t\t_paramsByName.clear();\n \t} else if (\"setNull\".equals(method.getName())) {\n \t\tif (String.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByName.put((String)args[0], null);\n \t\t} else if (Integer.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByIdx.put((Integer)args[0], null);\n \t\t}\n \t} else if (PARAMSTYPES.contains(method.getName())){\n \t\tif (String.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByName.put((String)args[0], args[1]);\n \t\t} else if (Integer.class.isAssignableFrom(args[0].getClass())) {\n \t\t\t_paramsByIdx.put((Integer)args[0], args[1]);\n \t\t}\n \t}\n }\n\t}\n"} {"input": " private void droid6() throws FileNotFoundException, IOException, CommandExecutionException {\n BinarySignatureIdentification bin = new BinarySignatureIdentification(file, sigFile);\n List resultList = bin.getResultList();\n List extResultList = bin.getExtResultList();\n if(resultList.size() == 1){\n IdentificationResult result = resultList.get(0);\n System.out.println(\"droidMatch: true\");\n System.out.println(\"droidPuid: \" + result.getPuid());\n System.out.println(\"droidMimeType: \" + result.getMimeType());\n System.out.println(\"droidMethod: binary signature\" );\n if(result.getName() != null)\n System.out.println(\"droidFileName: \" + result.getName());\n if(result.getVersion() != null)\n System.out.println(\"droidFileVersion: \" + result.getVersion());\n }\n if(resultList.isEmpty()){\n if(extResultList.isEmpty()){\n System.out.println(\"droidMatch: false\");\n }\n else{\n System.out.println(\"droidMatch: true\");\n System.out.println(\"droidPuid: \" + extResultList.get(0).getPuid());\n System.out.println(\"droidMimeType: \" + extResultList.get(0).getMimeType());\n System.out.println(\"droidMethod: extension\" );\n }\n }\n }\n", "output": " private void droid6() throws FileNotFoundException, IOException, CommandExecutionException {\n BinarySignatureIdentification bin = new BinarySignatureIdentification(file, sigFile);\n List resultList = bin.getResultList();\n List extResultList = bin.getExtResultList();\n if(resultList.size() == 1){\n IdentificationResult result = resultList.get(0);\n System.out.println(\"droidMatch: true\");\n System.out.println(\"droidPuid: \" + result.getPuid());\n if(result.getMimeType() != null)\n System.out.println(\"droidMimeType: \" + result.getMimeType());\n if(result.getName() != null)\n System.out.println(\"droidFileName: \" + result.getName());\n if(result.getVersion() != null)\n System.out.println(\"droidFileVersion: \" + result.getVersion());\n System.out.println(\"droidIdentificationMethod: binary signature\" );\n }\n if(resultList.isEmpty()){\n if(extResultList.isEmpty()){\n System.out.println(\"droidMatch: false\");\n }\n else{\n IdentificationResult result = extResultList.get(0);\n System.out.println(\"droidMatch: true\");\n System.out.println(\"droidPuid: \" + result.getPuid());\n if(result.getMimeType() != null)\n System.out.println(\"droidMimeType: \" + result.getMimeType());\n if(result.getName() != null)\n System.out.println(\"droidFileName: \" + result.getName());\n if(result.getVersion() != null)\n System.out.println(\"droidFileVersion: \" + result.getVersion());\n System.out.println(\"droidIdentificationMethod: extension\" );\n }\n }\n }\n"} {"input": "\tprotected int[] sortModifierKeys(final int modifierKeys) {\n\t\tfinal IKeyLookup lookup = KeyLookupFactory.getDefault();\n\t\tfinal String platform = SWT.getPlatform();\n\t\tfinal int[] sortedKeys = new int[4];\n\t\tint index = 0;\n\t\tif (\"win32\".equals(platform) || \"wpf\".equals(platform)) { \n\t\t\tif ((modifierKeys & lookup.getCtrl()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCtrl();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getAlt()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getAlt();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getShift()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getShift();\n\t\t\t}\n\t\t} else if (\"gtk\".equals(platform) || \"motif\".equals(platform)) { \n\t\t\tif ((modifierKeys & lookup.getShift()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getShift();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getCtrl()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCtrl();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getAlt()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getAlt();\n\t\t\t}\n\t\t} else if (\"carbon\".equals(platform)) { \n\t\t\tif ((modifierKeys & lookup.getShift()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getShift();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getCtrl()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCtrl();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getAlt()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getAlt();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getCommand()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCommand();\n\t\t\t}\n\t\t}\n\t\treturn sortedKeys;\n\t}\n", "output": "\tprotected int[] sortModifierKeys(final int modifierKeys) {\n\t\tfinal IKeyLookup lookup = KeyLookupFactory.getDefault();\n\t\tfinal String platform = SWT.getPlatform();\n\t\tfinal int[] sortedKeys = new int[4];\n\t\tint index = 0;\n\t\tif (\"win32\".equals(platform) || \"wpf\".equals(platform)) { \n\t\t\tif ((modifierKeys & lookup.getCtrl()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCtrl();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getAlt()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getAlt();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getShift()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getShift();\n\t\t\t}\n\t\t} else if (\"gtk\".equals(platform) || \"motif\".equals(platform)) { \n\t\t\tif ((modifierKeys & lookup.getShift()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getShift();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getCtrl()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCtrl();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getAlt()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getAlt();\n\t\t\t}\n\t\t} else if (\"carbon\".equals(SWT.getPlatform()) || \"cocoa\".equals(SWT.getPlatform())) { \n\t\t\tif ((modifierKeys & lookup.getShift()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getShift();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getCtrl()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCtrl();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getAlt()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getAlt();\n\t\t\t}\n\t\t\tif ((modifierKeys & lookup.getCommand()) != 0) {\n\t\t\t\tsortedKeys[index++] = lookup.getCommand();\n\t\t\t}\n\t\t}\n\t\treturn sortedKeys;\n\t}\n"} {"input": " public Result onError( Http.RequestHeader requestHeader, Throwable throwable )\n {\n logger.error( String.format( \"experienced error {}\", Utils.requestToString( requestHeader ) ), throwable );\n Results.Status status = JavaResults.InternalServerError();\n SimpleResult result;\n if ( throwable.getCause() != null && throwable.getCause() instanceof ExceptionResponse ){ \n ExceptionResponseDetails res = ( ( ExceptionResponse) throwable.getCause() ).getResponseDetails();\n Tuple2 ac = new Tuple2( res.getHeaderKey(), res.toJson());\n ArrayList> list = new ArrayList>();\n list.add(ac);\n scala.collection.immutable.List> headers =\n JavaConversions.asBuffer( list ).toList();\n status.header().headers().$plus( ac );\n result = status.withHeaders( headers );\n }else{\n return null;\n }\n final SimpleResult finalResult = result;\n return new Result() {\n @Override\n public play.api.mvc.Result getWrappedResult()\n {\n return finalResult;\n }\n };\n }\n", "output": " public Result onError( Http.RequestHeader requestHeader, Throwable throwable )\n {\n logger.error( String.format( \"experienced error {}\", Utils.requestToString( requestHeader ) ), throwable );\n Results.Status status = JavaResults.InternalServerError();\n SimpleResult result;\n if ( throwable.getCause() != null && throwable.getCause() instanceof ExceptionResponse ){ \n ExceptionResponseDetails res = ( ( ExceptionResponse) throwable.getCause() ).getResponseDetails();\n Tuple2 ac = new Tuple2( res.getHeaderKey(), res.toJson());\n ArrayList> list = new ArrayList>();\n list.add(ac);\n scala.collection.immutable.List> headers =\n JavaConversions.asScalaBuffer( list ).toList();\n status.header().headers().$plus( ac );\n result = status.withHeaders( headers );\n }else{\n return null;\n }\n final SimpleResult finalResult = result;\n return new Result() {\n @Override\n public play.api.mvc.Result getWrappedResult()\n {\n return finalResult;\n }\n };\n }\n"} {"input": " public void monitorWeather() throws Exception {\n\tint errorCount = 0;\n try {\n getStation().test();\n } catch (IOException ex) {\n LOGGER.error(ex);\n }\n while (true) {\n try {\n for (int i = 0; i < 15; i++) {\n getStation().readCurrentConditions();\n }\n if (isCheckArchive()) {\n getStation().readArchiveMemory();\n }\n } catch (Exception e) {\n LOGGER.error(\"exception - waiting 5s\", e);\n try {\n Thread.sleep(5000);\n boolean ok = getStation().test();\n LOGGER.warn(\"station test:\" + (ok ? \"ok\" : \"not ok\"));\n } catch (Exception e1) {\n if (errorCount++ > MAX_ERRORS) {\n System.exit(1);\n }\n LOGGER.error(e1);\n throw e1;\n }\n }\n }\n }\n", "output": " public void monitorWeather() throws Exception {\n\tint errorCount = 0;\n try {\n getStation().test();\n } catch (IOException ex) {\n LOGGER.error(ex);\n }\n while (true) {\n try {\n for (int i = 0; i < 15; i++) {\n getStation().readCurrentConditions();\n }\n if (isCheckArchive()) {\n getStation().readArchiveMemory();\n }\n } catch (Exception e) {\n LOGGER.error(\"exception - waiting 5s\", e);\n try {\n if (errorCount++ > MAX_ERRORS) {\n System.exit(1);\n }\n Thread.sleep(5000);\n boolean ok = getStation().test();\n LOGGER.warn(\"station test:\" + (ok ? \"ok\" : \"not ok\"));\n } catch (Exception e1) {\n LOGGER.error(e1);\n throw e1;\n }\n }\n }\n }\n"} {"input": "\tprivate void setUpRecognizerGui(final SpeechRecognizer sr, final Intent intentRecognizer) {\n\t\tfinal AudioCue audioCue;\n\t\tif (mPrefs.getBoolean(getString(R.string.keyAudioCues), mRes.getBoolean(R.bool.defaultAudioCues))) {\n\t\t\taudioCue = new AudioCue(this);\n\t\t} else {\n\t\t\taudioCue = null;\n\t\t}\n\t\tsr.setRecognitionListener(new RecognitionListener() {\n\t\t\t@Override\n\t\t\tpublic void onBeginningOfSpeech() {\n\t\t\t\tmState = State.LISTENING;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onBufferReceived(byte[] buffer) {\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onEndOfSpeech() {\n\t\t\t\tmState = State.TRANSCRIBING;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t\tif (audioCue != null) {\n\t\t\t\t\taudioCue.playStopSound();\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onError(int error) {\n\t\t\t\tmState = State.ERROR;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t\tif (audioCue != null) {\n\t\t\t\t\taudioCue.playErrorSound();\n\t\t\t\t}\n\t\t\t\tswitch (error) {\n\t\t\t\tcase SpeechRecognizer.ERROR_AUDIO:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultAudioError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_CLIENT:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultClientError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_NETWORK:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNetworkError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_NETWORK_TIMEOUT:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNetworkError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_SERVER:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultServerError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_RECOGNIZER_BUSY:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultServerError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_NO_MATCH:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNoMatch);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_SPEECH_TIMEOUT:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNoMatch);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onEvent(int eventType, Bundle params) {\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onPartialResults(Bundle partialResults) {\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onReadyForSpeech(Bundle params) {\n\t\t\t\tmState = State.RECORDING;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onResults(Bundle results) {\n\t\t\t\tmState = State.INIT;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t\tonSuccess(intentRecognizer.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE), results);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onRmsChanged(float rmsdB) {\n\t\t\t\tmButtonMicrophone.setVolumeLevel(rmsdB);\n\t\t\t}\n\t\t});\n\t\tmButtonMicrophone.setOnTouchListener(new View.OnTouchListener() {\n\t\t\t@Override\n\t\t\tpublic boolean onTouch(View v, MotionEvent event) {\n\t\t\t\tif (event.getAction() == MotionEvent.ACTION_DOWN) {\n\t\t\t\t\tvibrate();\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tmButtonMicrophone.setOnClickListener(new View.OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (mState == State.INIT || mState == State.ERROR) {\n\t\t\t\t\tmTts.stop();\n\t\t\t\t\tif (audioCue != null) {\n\t\t\t\t\t\taudioCue.playStartSoundAndSleep();\n\t\t\t\t\t}\n\t\t\t\t\tsr.startListening(intentRecognizer);\n\t\t\t\t}\n\t\t\t\telse if (mState == State.RECORDING) {\n\t\t\t\t}\n\t\t\t\telse if (mState == State.TRANSCRIBING) {\n\t\t\t\t}\n\t\t\t\telse if (mState == State.LISTENING) {\n\t\t\t\t\tsr.stopListening();\n\t\t\t\t} else {\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tLinearLayout llMicrophone = (LinearLayout) findViewById(R.id.llMicrophone);\n\t\tllMicrophone.setVisibility(View.VISIBLE);\n\t\tllMicrophone.setEnabled(true);\n\t}\n", "output": "\tprivate void setUpRecognizerGui(final SpeechRecognizer sr, final Intent intentRecognizer) {\n\t\tfinal AudioCue audioCue;\n\t\tif (mPrefs.getBoolean(getString(R.string.keyAudioCues), mRes.getBoolean(R.bool.defaultAudioCues))) {\n\t\t\taudioCue = new AudioCue(this);\n\t\t} else {\n\t\t\taudioCue = null;\n\t\t}\n\t\tsr.setRecognitionListener(new RecognitionListener() {\n\t\t\t@Override\n\t\t\tpublic void onBeginningOfSpeech() {\n\t\t\t\tmState = State.LISTENING;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onBufferReceived(byte[] buffer) {\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onEndOfSpeech() {\n\t\t\t\tmState = State.TRANSCRIBING;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t\tif (audioCue != null) {\n\t\t\t\t\taudioCue.playStopSound();\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onError(int error) {\n\t\t\t\tmState = State.ERROR;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t\tif (audioCue != null) {\n\t\t\t\t\taudioCue.playErrorSound();\n\t\t\t\t}\n\t\t\t\tswitch (error) {\n\t\t\t\tcase SpeechRecognizer.ERROR_AUDIO:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultAudioError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_CLIENT:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultClientError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_NETWORK:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNetworkError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_NETWORK_TIMEOUT:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNetworkError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_SERVER:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultServerError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_RECOGNIZER_BUSY:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultServerError);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_NO_MATCH:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNoMatch);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_SPEECH_TIMEOUT:\n\t\t\t\t\tshowErrorDialog(R.string.errorResultNoMatch);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onEvent(int eventType, Bundle params) {\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onPartialResults(Bundle partialResults) {\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onReadyForSpeech(Bundle params) {\n\t\t\t\tmState = State.RECORDING;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onResults(Bundle results) {\n\t\t\t\tmState = State.INIT;\n\t\t\t\tmButtonMicrophone.setState(mState);\n\t\t\t\tonSuccess(intentRecognizer.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE), results);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onRmsChanged(float rmsdB) {\n\t\t\t\tmButtonMicrophone.setVolumeLevel(rmsdB);\n\t\t\t}\n\t\t});\n\t\tmButtonMicrophone.setOnTouchListener(new View.OnTouchListener() {\n\t\t\t@Override\n\t\t\tpublic boolean onTouch(View v, MotionEvent event) {\n\t\t\t\tif (event.getAction() == MotionEvent.ACTION_DOWN) {\n\t\t\t\t\tvibrate();\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tmButtonMicrophone.setOnClickListener(new View.OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (mState == State.INIT || mState == State.ERROR) {\n\t\t\t\t\tif (mTts != null) {\n\t\t\t\t\t\tmTts.stop();\n\t\t\t\t\t}\n\t\t\t\t\tif (audioCue != null) {\n\t\t\t\t\t\taudioCue.playStartSoundAndSleep();\n\t\t\t\t\t}\n\t\t\t\t\tsr.startListening(intentRecognizer);\n\t\t\t\t}\n\t\t\t\telse if (mState == State.RECORDING) {\n\t\t\t\t}\n\t\t\t\telse if (mState == State.TRANSCRIBING) {\n\t\t\t\t}\n\t\t\t\telse if (mState == State.LISTENING) {\n\t\t\t\t\tsr.stopListening();\n\t\t\t\t} else {\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tLinearLayout llMicrophone = (LinearLayout) findViewById(R.id.llMicrophone);\n\t\tllMicrophone.setVisibility(View.VISIBLE);\n\t\tllMicrophone.setEnabled(true);\n\t}\n"} {"input": "\tprivate void registerScannedPorts(int PortType)\n\t{\n\t\tString[] CandidateDeviceNames;\n\t\tif (debug)\n\t\t\tSystem.out.println(\"scanning device directory \"+deviceDirectory+\" for ports of type \"+PortType);\n\t\tif(osName.toLowerCase().indexOf(\"windows\") != -1 )\n\t\t{\n\t\t\tString[] temp = { \"COM1\", \"COM2\",\"COM3\",\"COM4\" };\n\t\t\tCandidateDeviceNames=temp;\n\t\t}\n\t\telse if ( osName.equals(\"Solaris\") || osName.equals(\"SunOS\"))\n\t\t{\n\t\t\tString term[] = new String[2];\n\t\t\tint l = 0;\n\t\t\tFile dev = null;\n\t\t\tdev = new File( \"/dev/term\" );\n\t\t\tif( dev.list().length > 0 );\n\t\t\t\tterm[l++] = new String( \"term/\" );\n\t\t\tdev = new File( \"/dev/cua0\" );\n\t\t\tif( dev.list().length > 0 );\n\t\t\t\tterm[l++] = new String( \"cua/\" );\n\t\t\tString[] temp = new String[l];\n\t\t\tfor(l--;l >= 0;l--)\n\t\t\t\ttemp[l] = term[l];\n\t\t\tCandidateDeviceNames=temp;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tFile dev = new File( deviceDirectory );\n\t\t\tString[] temp = dev.list();\n\t\t\tCandidateDeviceNames=temp;\n\t\t}\n\t\tif (CandidateDeviceNames==null)\n\t\t{\n\t\t\tif (debug)\n\t\t\t\tSystem.out.println(\"RXTXCommDriver:registerScannedPorts() no Device files to check \");\n\t\t\treturn;\n\t\t}\n\t\tString CandidatePortPrefixes[] = {};\n\t\tswitch (PortType) {\n\t\t\tcase CommPortIdentifier.PORT_SERIAL:\n\t\t\t\tif (debug)\n\t\t\t\t\tSystem.out.println(\"scanning for serial ports for os \"+osName);\n\t\t\t\tif(osName.equals(\"Linux\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\"ttyS\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"Linux-all-ports\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\"comx\", \n\t\t\t\t\t\"holter\", \n\t\t\t\t\t\"modem\", \n\t\t\t\t\t\"ttyircomm\", \n\t\t\t\t\t\"ttycosa0c\", \n\t\t\t\t\t\"ttycosa1c\", \n\t\t\t\t\t\"ttyC\", \n\t\t\t\t\t\"ttyCH\",\n\t\t\t\t\t\"ttyD\", \n\t\t\t\t\t\"ttyE\", \n\t\t\t\t\t\"ttyF\", \n\t\t\t\t\t\"ttyH\", \n\t\t\t\t\t\"ttyI\", \n\t\t\t\t\t\"ttyL\", \n\t\t\t\t\t\"ttyM\", \n\t\t\t\t\t\"ttyMX\",\n\t\t\t\t\t\"ttyP\", \n\t\t\t\t\t\"ttyR\", \n\t\t\t\t\t\"ttyS\", \n\t\t\t\t\t\"ttySI\",\n\t\t\t\t\t\"ttySR\",\n\t\t\t\t\t\"ttyT\", \n\t\t\t\t\t\"ttyUSB\",\n\t\t\t\t\t\"ttyV\", \n\t\t\t\t\t\"ttyW\", \n\t\t\t\t\t\"ttyX\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"Irix\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"ttyc\", \n\t\t\t\t\t\t\"ttyd\", \n\t\t\t\t\t\t\"ttyf\", \n\t\t\t\t\t\t\"ttym\", \n\t\t\t\t\t\t\"ttyq\", \n\t\t\t\t\t\t\"tty4d\",\n\t\t\t\t\t\t\"tty4f\",\n\t\t\t\t\t\t\"midi\", \n\t\t\t\t\t\t\"us\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"FreeBSD\")) \n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"cuaa\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"NetBSD\")) \n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty0\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if ( osName.equals(\"Solaris\")\n\t\t\t\t\t\t|| osName.equals(\"SunOS\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"term/\",\n\t\t\t\t\t\t\"cua/\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"HP-UX\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty0p\",\n\t\t\t\t\t\t\"tty1p\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"UnixWare\") ||\n\t\t\t\t\t\tosName.equals(\"OpenUNIX\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty00s\", \n\t\t\t\t\t\t\"tty01s\",\n\t\t\t\t\t\t\"tty02s\",\n\t\t\t\t\t\t\"tty03s\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\telse if\t(osName.equals(\"OpenServer\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty1A\", \n\t\t\t\t\t\t\"tty2A\",\n\t\t\t\t\t\t\"tty3A\",\n\t\t\t\t\t\t\"tty4A\",\n\t\t\t\t\t\t\"tty5A\",\n\t\t\t\t\t\t\"tty6A\",\n\t\t\t\t\t\t\"tty7A\",\n\t\t\t\t\t\t\"tty8A\",\n\t\t\t\t\t\t\"tty9A\",\n\t\t\t\t\t\t\"tty10A\",\n\t\t\t\t\t\t\"tty11A\",\n\t\t\t\t\t\t\"tty12A\",\n\t\t\t\t\t\t\"tty13A\",\n\t\t\t\t\t\t\"tty14A\",\n\t\t\t\t\t\t\"tty15A\",\n\t\t\t\t\t\t\"tty16A\",\n\t\t\t\t\t\t\"ttyu1A\", \n\t\t\t\t\t\t\"ttyu2A\",\n\t\t\t\t\t\t\"ttyu3A\",\n\t\t\t\t\t\t\"ttyu4A\",\n\t\t\t\t\t\t\"ttyu5A\",\n\t\t\t\t\t\t\"ttyu6A\",\n\t\t\t\t\t\t\"ttyu7A\",\n\t\t\t\t\t\t\"ttyu8A\",\n\t\t\t\t\t\t\"ttyu9A\",\n\t\t\t\t\t\t\"ttyu10A\",\n\t\t\t\t\t\t\"ttyu11A\",\n\t\t\t\t\t\t\"ttyu12A\",\n\t\t\t\t\t\t\"ttyu13A\",\n\t\t\t\t\t\t\"ttyu14A\",\n\t\t\t\t\t\t\"ttyu15A\",\n\t\t\t\t\t\t\"ttyu16A\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if (osName.equals(\"Compaq's Digital UNIX\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty0\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"BeOS\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"serial\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"Mac OS X\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"cu.KeyUSA28X191.\",\n\t\t\t\t\t\t\"tty.KeyUSA28X191.\",\n\t\t\t\t\t\t\"cu.KeyUSA28X181.\",\n\t\t\t\t\t\t\"tty.KeyUSA28X181.\",\n\t\t\t\t\t\t\"cu.KeyUSA19181.\",\n\t\t\t\t\t\t\"tty.KeyUSA19181.\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.toLowerCase().indexOf(\"windows\") != -1 )\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"COM\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (debug)\n\t\t\t\t\t\tSystem.out.println(\"No valid prefixes for serial ports have been entered for \"+osName + \" in RXTXCommDriver.java. This may just be a typo in the method registerScanPorts().\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CommPortIdentifier.PORT_PARALLEL:\n\t\t\t\tif (debug)\n\t\t\t\t\tSystem.out.println(\"scanning for parallel ports for os \"+osName);\n\t\t\t\tif(osName.equals(\"Linux\")\n\t\t\t\t)\n\t\t\t\t{\n\t\t\t\t\tString[] temp={\n\t\t\t\t\t\t\"lp\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"FreeBSD\"))\n\t\t\t\t{\n\t\t\t\t\tString[] temp={\n\t\t\t\t\t\t\"lpt\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=temp;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tString [] temp={};\n\t\t\t\t\tCandidatePortPrefixes=temp;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (debug)\n\t\t\t\t\tSystem.out.println(\"Unknown PortType \"+PortType+\" passed to RXTXCommDriver.registerScannedPorts()\");\n\t\t}\n\t\tregisterValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType);\n\t}\n", "output": "\tprivate void registerScannedPorts(int PortType)\n\t{\n\t\tString[] CandidateDeviceNames;\n\t\tif (debug)\n\t\t\tSystem.out.println(\"scanning device directory \"+deviceDirectory+\" for ports of type \"+PortType);\n\t\tif(osName.toLowerCase().indexOf(\"windows\") != -1 )\n\t\t{\n\t\t\tString[] temp = { \"COM1\", \"COM2\",\"COM3\",\"COM4\" };\n\t\t\tCandidateDeviceNames=temp;\n\t\t}\n\t\telse if ( osName.equals(\"Solaris\") || osName.equals(\"SunOS\"))\n\t\t{\n\t\t\tString term[] = new String[2];\n\t\t\tint l = 0;\n\t\t\tFile dev = null;\n\t\t\tdev = new File( \"/dev/term\" );\n\t\t\tif( dev.list().length > 0 );\n\t\t\t\tterm[l++] = new String( \"term/\" );\n\t\t\tdev = new File( \"/dev/cua0\" );\n\t\t\tif( dev.list().length > 0 );\n\t\t\t\tterm[l++] = new String( \"cua/\" );\n\t\t\tString[] temp = new String[l];\n\t\t\tfor(l--;l >= 0;l--)\n\t\t\t\ttemp[l] = term[l];\n\t\t\tCandidateDeviceNames=temp;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tFile dev = new File( deviceDirectory );\n\t\t\tString[] temp = dev.list();\n\t\t\tCandidateDeviceNames=temp;\n\t\t}\n\t\tif (CandidateDeviceNames==null)\n\t\t{\n\t\t\tif (debug)\n\t\t\t\tSystem.out.println(\"RXTXCommDriver:registerScannedPorts() no Device files to check \");\n\t\t\treturn;\n\t\t}\n\t\tString CandidatePortPrefixes[] = {};\n\t\tswitch (PortType) {\n\t\t\tcase CommPortIdentifier.PORT_SERIAL:\n\t\t\t\tif (debug)\n\t\t\t\t\tSystem.out.println(\"scanning for serial ports for os \"+osName);\n\t\t\t\tif(osName.equals(\"Linux\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\"ttyS\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"Linux-all-ports\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\"comx\", \n\t\t\t\t\t\"holter\", \n\t\t\t\t\t\"modem\", \n\t\t\t\t\t\"ttyircomm\", \n\t\t\t\t\t\"ttycosa0c\", \n\t\t\t\t\t\"ttycosa1c\", \n\t\t\t\t\t\"ttyC\", \n\t\t\t\t\t\"ttyCH\",\n\t\t\t\t\t\"ttyD\", \n\t\t\t\t\t\"ttyE\", \n\t\t\t\t\t\"ttyF\", \n\t\t\t\t\t\"ttyH\", \n\t\t\t\t\t\"ttyI\", \n\t\t\t\t\t\"ttyL\", \n\t\t\t\t\t\"ttyM\", \n\t\t\t\t\t\"ttyMX\",\n\t\t\t\t\t\"ttyP\", \n\t\t\t\t\t\"ttyR\", \n\t\t\t\t\t\"ttyS\", \n\t\t\t\t\t\"ttySI\",\n\t\t\t\t\t\"ttySR\",\n\t\t\t\t\t\"ttyT\", \n\t\t\t\t\t\"ttyUSB\",\n\t\t\t\t\t\"ttyV\", \n\t\t\t\t\t\"ttyW\", \n\t\t\t\t\t\"ttyX\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"Irix\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"ttyc\", \n\t\t\t\t\t\t\"ttyd\", \n\t\t\t\t\t\t\"ttyf\", \n\t\t\t\t\t\t\"ttym\", \n\t\t\t\t\t\t\"ttyq\", \n\t\t\t\t\t\t\"tty4d\",\n\t\t\t\t\t\t\"tty4f\",\n\t\t\t\t\t\t\"midi\", \n\t\t\t\t\t\t\"us\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"FreeBSD\")) \n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"cuaa\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"NetBSD\")) \n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty0\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if ( osName.equals(\"Solaris\")\n\t\t\t\t\t\t|| osName.equals(\"SunOS\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"term/\",\n\t\t\t\t\t\t\"cua/\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"HP-UX\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty0p\",\n\t\t\t\t\t\t\"tty1p\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"UnixWare\") ||\n\t\t\t\t\t\tosName.equals(\"OpenUNIX\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty00s\", \n\t\t\t\t\t\t\"tty01s\",\n\t\t\t\t\t\t\"tty02s\",\n\t\t\t\t\t\t\"tty03s\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\telse if\t(osName.equals(\"OpenServer\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty1A\", \n\t\t\t\t\t\t\"tty2A\",\n\t\t\t\t\t\t\"tty3A\",\n\t\t\t\t\t\t\"tty4A\",\n\t\t\t\t\t\t\"tty5A\",\n\t\t\t\t\t\t\"tty6A\",\n\t\t\t\t\t\t\"tty7A\",\n\t\t\t\t\t\t\"tty8A\",\n\t\t\t\t\t\t\"tty9A\",\n\t\t\t\t\t\t\"tty10A\",\n\t\t\t\t\t\t\"tty11A\",\n\t\t\t\t\t\t\"tty12A\",\n\t\t\t\t\t\t\"tty13A\",\n\t\t\t\t\t\t\"tty14A\",\n\t\t\t\t\t\t\"tty15A\",\n\t\t\t\t\t\t\"tty16A\",\n\t\t\t\t\t\t\"ttyu1A\", \n\t\t\t\t\t\t\"ttyu2A\",\n\t\t\t\t\t\t\"ttyu3A\",\n\t\t\t\t\t\t\"ttyu4A\",\n\t\t\t\t\t\t\"ttyu5A\",\n\t\t\t\t\t\t\"ttyu6A\",\n\t\t\t\t\t\t\"ttyu7A\",\n\t\t\t\t\t\t\"ttyu8A\",\n\t\t\t\t\t\t\"ttyu9A\",\n\t\t\t\t\t\t\"ttyu10A\",\n\t\t\t\t\t\t\"ttyu11A\",\n\t\t\t\t\t\t\"ttyu12A\",\n\t\t\t\t\t\t\"ttyu13A\",\n\t\t\t\t\t\t\"ttyu14A\",\n\t\t\t\t\t\t\"ttyu15A\",\n\t\t\t\t\t\t\"ttyu16A\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if (osName.equals(\"Compaq's Digital UNIX\") || osName.equals(\"OSF1\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"tty0\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"BeOS\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"serial\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"Mac OS X\"))\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"cu.KeyUSA28X191.\",\n\t\t\t\t\t\t\"tty.KeyUSA28X191.\",\n\t\t\t\t\t\t\"cu.KeyUSA28X181.\",\n\t\t\t\t\t\t\"tty.KeyUSA28X181.\",\n\t\t\t\t\t\t\"cu.KeyUSA19181.\",\n\t\t\t\t\t\t\"tty.KeyUSA19181.\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.toLowerCase().indexOf(\"windows\") != -1 )\n\t\t\t\t{\n\t\t\t\t\tString[] Temp = {\n\t\t\t\t\t\t\"COM\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=Temp;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (debug)\n\t\t\t\t\t\tSystem.out.println(\"No valid prefixes for serial ports have been entered for \"+osName + \" in RXTXCommDriver.java. This may just be a typo in the method registerScanPorts().\");\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase CommPortIdentifier.PORT_PARALLEL:\n\t\t\t\tif (debug)\n\t\t\t\t\tSystem.out.println(\"scanning for parallel ports for os \"+osName);\n\t\t\t\tif(osName.equals(\"Linux\")\n\t\t\t\t)\n\t\t\t\t{\n\t\t\t\t\tString[] temp={\n\t\t\t\t\t\t\"lp\" \n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=temp;\n\t\t\t\t}\n\t\t\t\telse if(osName.equals(\"FreeBSD\"))\n\t\t\t\t{\n\t\t\t\t\tString[] temp={\n\t\t\t\t\t\t\"lpt\"\n\t\t\t\t\t};\n\t\t\t\t\tCandidatePortPrefixes=temp;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tString [] temp={};\n\t\t\t\t\tCandidatePortPrefixes=temp;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (debug)\n\t\t\t\t\tSystem.out.println(\"Unknown PortType \"+PortType+\" passed to RXTXCommDriver.registerScannedPorts()\");\n\t\t}\n\t\tregisterValidPorts(CandidateDeviceNames, CandidatePortPrefixes, PortType);\n\t}\n"} {"input": " private UrlMappingInfo createUrlMappingInfo(String uri, Matcher m) {\n Map params = new HashMap();\n Errors errors = new MapBindingResult(params, \"urlMapping\");\n String lastGroup = null;\n for (int i = 0; i < m.groupCount(); i++) {\n lastGroup = m.group(i+1);\n if(constraints.length > i) {\n ConstrainedProperty cp = constraints[i];\n cp.validate(this,lastGroup, errors);\n if(errors.hasErrors()) return null;\n else {\n params.put(cp.getPropertyName(), lastGroup);\n }\n }\n }\n if(lastGroup!= null) {\n String remainingUri = uri.substring(uri.lastIndexOf(lastGroup)+lastGroup.length());\n if(remainingUri.length() > 0) {\n if(remainingUri.startsWith(SLASH))remainingUri = remainingUri.substring(1);\n String[] tokens = remainingUri.split(SLASH);\n for (int i = 0; i < tokens.length; i=i+2) {\n String token = tokens[i];\n if((i+1) < tokens.length) {\n params.put(token, tokens[i+1]);\n }\n }\n }\n }\n for (Iterator i = this.parameterValues.keySet().iterator(); i.hasNext();) {\n Object key = i.next();\n params.put(key, this.parameterValues.get(key)); \n }\n if(controllerName == null) {\n this.controllerName = createRuntimeConstraintEvaluator(GrailsControllerClass.CONTROLLER, this.constraints);\n }\n if(actionName == null) {\n this.actionName = createRuntimeConstraintEvaluator(GrailsControllerClass.ACTION, this.constraints);\n }\n if(viewName == null) {\n this.viewName = createRuntimeConstraintEvaluator(GrailsControllerClass.VIEW, this.constraints);\n }\n if (viewName != null && this.controllerName == null) {\n return new DefaultUrlMappingInfo(viewName, params,this.urlData);\n }\n else {\n return new DefaultUrlMappingInfo(this.controllerName, this.actionName,getViewName(), params,this.urlData);\n }\n }\n", "output": " private UrlMappingInfo createUrlMappingInfo(String uri, Matcher m) {\n Map params = new HashMap();\n Errors errors = new MapBindingResult(params, \"urlMapping\");\n String lastGroup = null;\n for (int i = 0; i < m.groupCount(); i++) {\n lastGroup = m.group(i+1);\n int j = lastGroup.indexOf('?');\n if(j >-1) {\n lastGroup = lastGroup.substring(0,j);\n }\n if(constraints.length > i) {\n ConstrainedProperty cp = constraints[i];\n cp.validate(this,lastGroup, errors);\n if(errors.hasErrors()) return null;\n else {\n params.put(cp.getPropertyName(), lastGroup);\n }\n }\n }\n if(lastGroup!= null) {\n String remainingUri = uri.substring(uri.lastIndexOf(lastGroup)+lastGroup.length());\n if(remainingUri.length() > 0) {\n if(remainingUri.startsWith(SLASH))remainingUri = remainingUri.substring(1);\n String[] tokens = remainingUri.split(SLASH);\n for (int i = 0; i < tokens.length; i=i+2) {\n String token = tokens[i];\n if((i+1) < tokens.length) {\n params.put(token, tokens[i+1]);\n }\n }\n }\n }\n for (Iterator i = this.parameterValues.keySet().iterator(); i.hasNext();) {\n Object key = i.next();\n params.put(key, this.parameterValues.get(key)); \n }\n if(controllerName == null) {\n this.controllerName = createRuntimeConstraintEvaluator(GrailsControllerClass.CONTROLLER, this.constraints);\n }\n if(actionName == null) {\n this.actionName = createRuntimeConstraintEvaluator(GrailsControllerClass.ACTION, this.constraints);\n }\n if(viewName == null) {\n this.viewName = createRuntimeConstraintEvaluator(GrailsControllerClass.VIEW, this.constraints);\n }\n if (viewName != null && this.controllerName == null) {\n return new DefaultUrlMappingInfo(viewName, params,this.urlData);\n }\n else {\n return new DefaultUrlMappingInfo(this.controllerName, this.actionName,getViewName(), params,this.urlData);\n }\n }\n"} {"input": " public void execute() {\n if (this.outputFile == null) {\n throw new BuildException(\"outputFile attribute must be set\");\n }\n Compiler.setLoggingLevel(Level.OFF);\n CompilerOptions options = createCompilerOptions();\n Compiler compiler = createCompiler(options);\n JSSourceFile[] externs = findExternFiles();\n JSSourceFile[] sources = findSourceFiles();\n log(\"Compiling \" + sources.length + \" file(s) with \" +\n externs.length + \" extern(s)\");\n Result result = compiler.compile(externs, sources, options);\n if (result.success) {\n writeResult(compiler.toSource());\n }\n }\n", "output": " public void execute() {\n if (this.outputFile == null) {\n throw new BuildException(\"outputFile attribute must be set\");\n }\n Compiler.setLoggingLevel(Level.OFF);\n CompilerOptions options = createCompilerOptions();\n Compiler compiler = createCompiler(options);\n JSSourceFile[] externs = findExternFiles();\n JSSourceFile[] sources = findSourceFiles();\n log(\"Compiling \" + sources.length + \" file(s) with \" +\n externs.length + \" extern(s)\");\n Result result = compiler.compile(externs, sources, options);\n if (result.success) {\n writeResult(compiler.toSource());\n } else {\n throw new BuildException(\"Compilation failed.\");\n }\n }\n"} {"input": " public boolean processImpression(User user, Query query, Auction auction) {\n fireQueryIssued(query);\n boolean converted = false;\n boolean clicking = true;\n double continuationProbability = 0.0;\n int queryIndex = userClickModel.queryIndex(query);\n if (queryIndex < 0) {\n log.warning(String.format(\"Query: %s does not have a click model.\",\n query));\n } else {\n continuationProbability = userClickModel\n .getContinuationProbability(queryIndex);\n }\n Ranking ranking = auction.getRanking();\n Pricing pricing = auction.getPricing();\n for (int i = 0; i < ranking.size(); i++) {\n AdLink ad = ranking.get(i);\n boolean isPromoted = ranking.isPromoted(i);\n fireAdViewed(query, ad, i + 1, isPromoted);\n if (clicking) {\n AdvertiserInfo info = advertiserInfo.get(ad.getAdvertiser());\n double promotionEffect = ranking.isPromoted(i) ? slotInfo\n .getPromotedSlotBonus() : 0.0;\n double clickProbability = calculateClickProbability(user, ad.getAd(), info.getTargetEffect(),\n promotionEffect, findAdvertiserEffect(query, ad, userClickModel));\n if (random.nextDouble() <= clickProbability) {\n fireAdClicked(query, ad, i + 1, pricing.getPrice(ad));\n double conversionProbability = calculateConversionProbability( user, query, info,\n recentConversionsTracker.getRecentConversions(ad.getAdvertiser()));\n if(user.isTransacting()){\n if (random.nextDouble() <= conversionProbability) {\n double salesProfit = catalog.getSalesProfit(user\n .getProduct());\n fireAdConverted(query, ad, i + 1, modifySalesProfitForManufacturerSpecialty(user,\n info.getManufacturerSpecialty(), info.getManufacturerBonus(), salesProfit));\n converted = true;\n clicking = false;\n }\n }\n }\n }\n if (random.nextDouble() > continuationProbability) {\n clicking = false;\n }\n }\n return converted;\n }\n", "output": " public boolean processImpression(User user, Query query, Auction auction) {\n fireQueryIssued(query);\n boolean converted = false;\n boolean clicking = true;\n double continuationProbability = 0.0;\n int queryIndex = userClickModel.queryIndex(query);\n if (queryIndex < 0) {\n log.warning(String.format(\"Query: %s does not have a click model.\",\n query));\n } else {\n continuationProbability = userClickModel\n .getContinuationProbability(queryIndex);\n }\n Ranking ranking = auction.getRanking();\n Pricing pricing = auction.getPricing();\n for (int i = 0; i < ranking.size(); i++) {\n AdLink ad = ranking.get(i);\n boolean isPromoted = ranking.isPromoted(i);\n fireAdViewed(query, ad, i + 1, isPromoted);\n if (clicking) {\n AdvertiserInfo info = advertiserInfo.get(ad.getAdvertiser());\n double promotionEffect = ranking.isPromoted(i) ? slotInfo\n .getPromotedSlotBonus() : 0.0;\n double clickProbability = calculateClickProbability(user, ad.getAd(), info.getTargetEffect(),\n promotionEffect, findAdvertiserEffect(query, ad, userClickModel));\n if (random.nextDouble() <= clickProbability) {\n fireAdClicked(query, ad, i + 1, pricing.getPrice(ad));\n double conversionProbability = calculateConversionProbability( user, query, info,\n recentConversionsTracker.getRecentConversions(ad.getAdvertiser()));\n if (random.nextDouble() <= conversionProbability) {\n double salesProfit = catalog.getSalesProfit(user\n .getProduct());\n fireAdConverted(query, ad, i + 1, modifySalesProfitForManufacturerSpecialty(user,\n info.getManufacturerSpecialty(), info.getManufacturerBonus(), salesProfit));\n converted = true;\n clicking = false;\n }\n }\n }\n if (random.nextDouble() > continuationProbability) {\n clicking = false;\n }\n }\n return converted;\n }\n"} {"input": " private static DB getDB() {\n Mongo mongoClient;\n try {\n mongoClient = new Mongo(\"mongodb-rankitapp.jelastic.dogado.eu\", 27017);\n } catch (UnknownHostException e) {\n throw new RuntimeException(e);\n }\n final DB pingpong = mongoClient.getDB(\"pingpong\");\n final boolean auth = pingpong.authenticate(\"admin\", \"XIyqkxSMgQ\".toCharArray());\n if (!auth) {\n throw new RuntimeException(\"Mongo authentication failed!\");\n }\n return pingpong;\n }\n", "output": " private static DB getDB() {\n Mongo mongoClient;\n try {\n mongoClient = new Mongo(\"mongodb-rankitapp.jelastic.dogado.eu\", 27017);\n } catch (UnknownHostException e) {\n throw new RuntimeException(e);\n }\n final DB pingpong = mongoClient.getDB(\"pingpong\");\n final boolean auth = pingpong.authenticate(\"admin\", \"XIyqkxSMgQ\".toCharArray());\n if (!auth) {\n return pingpong;\n }\n return pingpong;\n }\n"} {"input": "\tpublic void performGWAS(Transformation transformation, TYPE analysis) {\n\t\tfinal RunGWASAction gwasAction = new RunGWASAction(transformation.getPhenotype(),transformation.getDataset(), transformation.getName(), analysis, gwasResultReader);\n\t\tdispatch.execute(gwasAction, new GWASCallback(getEventBus()) {\n\t\t\t@Override\n\t\t\tpublic void onFailure(Throwable caught) {\n\t\t\t\tProgressBarEvent.fire(getEventBus(),gwasAction.getUrl(),true);\n\t\t\t\tgetView().showNotification(\"\", \"Error\", \"GWAS analysis failed\");\n\t\t\t\tsuper.onFailure(caught);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onSuccess(RunGWASActionResult result) {\n\t\t\t\tif (result.result.getStatus() == BackendResult.STATUS.OK) {\n\t\t\t\t\tgoogleAnalytics.trackEvent(\"GWAS\", \"successful\");\n\t\t\t\t\tRunGWASFinishedEvent.fire(TransformationListPresenter.this, result.Chromosome, result.Position, result.Phenotypes, result.Phenotype, result.Dataset,result.Transformation, result.ResultName);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgoogleAnalytics.trackEvent(\"GWAS\", \"failed\");\n\t\t\t\t\tgetView().showNotification(\"\", \"Error\", \"GWAS analysis failed\");\n\t\t\t\t\tDisplayNotificationEvent.fireError(TransformationListPresenter.this, \"Backend-Error\", result.result.getStatustext());\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tProgressBarEvent.fire(getEventBus(),gwasAction.getUrl());\n\t}\n", "output": "\tpublic void performGWAS(Transformation transformation, TYPE analysis) {\n\t\tfinal RunGWASAction gwasAction = new RunGWASAction(transformation.getPhenotype(),transformation.getDataset(), transformation.getName(), analysis, gwasResultReader);\n\t\tdispatch.execute(gwasAction, new GWASCallback(getEventBus()) {\n\t\t\t@Override\n\t\t\tpublic void onFailure(Throwable caught) {\n\t\t\t\tProgressBarEvent.fire(getEventBus(),gwasAction.getUrl(),true);\n\t\t\t\tgetView().showNotification(\"\", \"Error\", \"GWAS analysis failed\");\n\t\t\t\tsuper.onFailure(caught);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void onSuccess(RunGWASActionResult result) {\n\t\t\t\tif (result.result.getStatus() == BackendResult.STATUS.OK) {\n\t\t\t\t\tgoogleAnalytics.trackEvent(\"GWAS\", \"successful\");\n\t\t\t\t\tRunGWASFinishedEvent.fire(TransformationListPresenter.this, result.Chromosome, result.Position, result.Phenotypes, result.Phenotype, result.Dataset,result.Transformation, result.ResultName);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgoogleAnalytics.trackEvent(\"GWAS\", \"failed\");\n\t\t\t\t\tProgressBarEvent.fire(getEventBus(),gwasAction.getUrl(),true);\n\t\t\t\t\tgetView().showNotification(\"\", \"Error\", \"GWAS analysis failed\");\n\t\t\t\t\tDisplayNotificationEvent.fireError(TransformationListPresenter.this, \"Backend-Error\", result.result.getStatustext());\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tProgressBarEvent.fire(getEventBus(),gwasAction.getUrl());\n\t}\n"} {"input": " public void doJob() throws Exception {\n if(Play.configuration.getProperty(\"mailbox.username\") == null || Play.configuration.getProperty(\"mailbox.password\") == null) {\n Logger.error(\"Please configure mailbox credentials in conf/credentials.conf\");\n return;\n }\n Properties props = new Properties();\n props.setProperty(\"mail.imap.socketFactory.class\", \"javax.net.ssl.SSLSocketFactory\");\n props.setProperty(\"mail.imap.socketFactory.port\", \"993\");\n Session session = Session.getDefaultInstance(props);\n Store store = session.getStore(\"imap\");\n store.connect(\"imap.gmail.com\", Play.configuration.getProperty(\"mailbox.username\"), Play.configuration.getProperty(\"mailbox.password\"));\n Folder folder = store.getFolder(\"jobs\");\n folder.open(Folder.READ_WRITE);\n SearchTerm unstarred = new FlagTerm(new Flags(Flags.Flag.FLAGGED), false);\n Message[] messages = folder.search(unstarred);\n for (Message message : messages) {\n String contentString = \"\";\n List attachments = new ArrayList();\n if (message.getContent() instanceof String) {\n contentString = (String) message.getContent();\n } else if (message.getContent() instanceof Multipart) {\n Multipart mp = (Multipart) message.getContent();\n for (int j = 0; j < mp.getCount(); j++) {\n Part part = mp.getBodyPart(j);\n String disposition = part.getDisposition();\n if (disposition == null\n || ((disposition != null) && (disposition.equalsIgnoreCase(Part.ATTACHMENT) || disposition\n .equalsIgnoreCase(Part.INLINE)))) {\n MimeBodyPart mbp = (MimeBodyPart) part;\n if (mbp.isMimeType(\"text/plain\")) {\n contentString += (String) mbp.getContent();\n } else {\n attachments.add(saveAttachment(part));\n }\n }\n }\n }\n String name = ((InternetAddress) message.getFrom()[0]).getPersonal();\n String email = ((InternetAddress) message.getFrom()[0]).getAddress();\n String to = ((InternetAddress) message.getAllRecipients()[0]).getAddress();\n if(\"jobs@zenexity.com\".equals(to)) {\n JobApplication application = new JobApplication(name, email, contentString, attachments);\n application.create();\n for(Attachment attachment : attachments) {\n attachment.jobApplication = application;\n attachment.create();\n }\n Mails.applied(application);\n } else {\n Pattern regexp = Pattern.compile(\"^jobs[+][^@]{5}-([0-9]+)@.*$\");\n Matcher matcher = regexp.matcher(to);\n if(matcher.matches()) {\n Long id = Long.parseLong(matcher.group(1));\n JobApplication application = JobApplication.findById(id);\n if(application == null) {\n Logger.warn(\"Job application not found %s, for %s\", id, to);\n } else {\n application.addMessage(name, email, contentString);\n application.save();\n }\n } else {\n Logger.warn(\"Unknow address --> %s\", to);\n }\n }\n if (Play.mode == Play.Mode.PROD) {\n message.setFlag(Flag.FLAGGED, true);\n }\n }\n folder.close(false);\n store.close();\n }\n", "output": " public void doJob() throws Exception {\n if(Play.configuration.getProperty(\"mailbox.username\") == null || Play.configuration.getProperty(\"mailbox.password\") == null) {\n Logger.error(\"Please configure mailbox credentials in conf/credentials.conf\");\n return;\n }\n Properties props = new Properties();\n props.setProperty(\"mail.imap.socketFactory.class\", \"javax.net.ssl.SSLSocketFactory\");\n props.setProperty(\"mail.imap.socketFactory.port\", \"993\");\n Session session = Session.getDefaultInstance(props);\n Store store = session.getStore(\"imap\");\n store.connect(\"imap.gmail.com\", Play.configuration.getProperty(\"mailbox.username\"), Play.configuration.getProperty(\"mailbox.password\"));\n Folder folder = store.getFolder(\"jobs\");\n folder.open(Folder.READ_WRITE);\n SearchTerm unstarred = new FlagTerm(new Flags(Flags.Flag.FLAGGED), false);\n Message[] messages = folder.search(unstarred);\n for (Message message : messages) {\n String contentString = \"\";\n List attachments = new ArrayList();\n if (message.getContent() instanceof String) {\n contentString = (String) message.getContent();\n } else if (message.getContent() instanceof Multipart) {\n Multipart mp = (Multipart) message.getContent();\n for (int j = 0; j < mp.getCount(); j++) {\n Part part = mp.getBodyPart(j);\n String disposition = part.getDisposition();\n if (disposition == null\n || ((disposition != null) && (disposition.equalsIgnoreCase(Part.ATTACHMENT) || disposition\n .equalsIgnoreCase(Part.INLINE)))) {\n MimeBodyPart mbp = (MimeBodyPart) part;\n if (mbp.isMimeType(\"text/plain\")) {\n contentString += (String) mbp.getContent();\n } else {\n attachments.add(saveAttachment(part));\n }\n }\n }\n }\n String name = ((InternetAddress) message.getFrom()[0]).getPersonal();\n String email = ((InternetAddress) message.getFrom()[0]).getAddress();\n String to = ((InternetAddress) message.getAllRecipients()[0]).getAddress();\n if(\"jobs@zenexity.com\".equals(to)) {\n JobApplication application = new JobApplication(name, email, contentString, attachments);\n application.create();\n for(Attachment attachment : attachments) {\n attachment.jobApplication = application;\n attachment.create();\n }\n Mails.applied(application);\n } else {\n Pattern regexp = Pattern.compile(\"^jobs[+][^@]{5}-([0-9]+)@.*$\");\n Matcher matcher = regexp.matcher(to);\n if(matcher.matches()) {\n Long id = Long.parseLong(matcher.group(1));\n JobApplication application = JobApplication.findById(id);\n if(application == null) {\n Logger.warn(\"Job application not found %s, for %s\", id, to);\n } else {\n application.addMessage(name, email, contentString);\n application.save();\n }\n } else {\n Logger.warn(\"Unknow address --> %s\", to);\n }\n }\n if (Play.mode == Play.Mode.PROD || true) {\n message.setFlag(Flag.FLAGGED, true);\n }\n }\n folder.close(false);\n store.close();\n }\n"} {"input": "\tpublic boolean createTexturePart(String texturePartID, String textureID,\n\t\t\tRectangle rectangle) {\n\t\tTexture texture = TextureManager.getInstance().get(textureID);\n\t\tRectangle scaledRectangle = rectangle.scaleAll(new Vector2f(texture\n\t\t\t\t.getWidth(), texture.getHeight()));\n\t\tTexturePart part = new TexturePart(texture, scaledRectangle);\n\t\treturn put(texturePartID, part);\n\t}\n", "output": "\tpublic boolean createTexturePart(String texturePartID, String textureID,\n\t\t\tRectangle rectangle) {\n\t\tTexture texture = TextureManager.getInstance().get(textureID);\n\t\tfloat width = (float) texture.getWidth();\n\t\tfloat height = (float) texture.getHeight();\n\t\tVector2f scale = new Vector2f(1 / width, 1 / height);\n\t\tRectangle scaledRectangle = rectangle.scaleAll(scale);\n\t\tTexturePart part = new TexturePart(texture, scaledRectangle);\n\t\treturn put(texturePartID, part);\n\t}\n"} {"input": "\tprivate static void parse(String in2) {\n\t\tString[] result = in.split(\" \", 2);\n\t\tswitch (result[0]) {\n\t\tcase \"about\":\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"Echode version 0.3\\nMade by Erik Konijn and Marks Polakovs\");\n\t\t\tbreak;\n\t\tcase \"kill\":\n\t\t\tSystem.out.println(\"Echode shut down succesfully.\");\n\t\t\tSystem.exit(0);\n\t\t\tbreak;\n\t\tcase \"help\":\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"List of commands:\\n\"\n\t\t\t\t\t\t\t+ \"about ----------------------------------- Gives some info about ECHODE\\n\"\n\t\t\t\t\t\t\t+ \"help ---------------------------------------------- Lists all commands\\n\"\n\t\t\t\t\t\t\t+ \"kill ---------------------------------------- Quits the ECHODE console\\n\"\n\t\t\t\t\t\t\t+ \"version ------------------------ Outputs current Echode version number\\n\"\n\t\t\t\t\t\t\t+ \"time ---------------------------------- Outputs time\");\n\t\t\tbreak;\n\t\tcase \"version\":\n\t\t\tSystem.out.println(\"0.3\");\n\t\t\tbreak;\n\t\tcase \"time\":\n\t\t\ttry {\n\t\t\t\tswitch (result[1]) {\n\t\t\t\tcase \"all\":\n\t\t\t\t\tString alltime = new SimpleDateFormat(\n\t\t\t\t\t\t\t\"yyyy-MM-dd HH:mm:ss\").format(Calendar\n\t\t\t\t\t\t\t.getInstance().getTime());\n\t\t\t\t\tSystem.out.println(alltime);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"date\":\n\t\t\t\t\tString datetime = new SimpleDateFormat(\n\t\t\t\t\t\t\t\"yyyy-MM-dd\").format(Calendar\n\t\t\t\t\t\t\t.getInstance().getTime());\n\t\t\t\t\tSystem.out.println(datetime);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"digital\":\n\t\t\t\t\tString digitaltime = new SimpleDateFormat(\n\t\t\t\t\t\t\t\"HH:mm:ss\").format(Calendar\n\t\t\t\t\t\t\t.getInstance().getTime());\n\t\t\t\t\tSystem.out.println(digitaltime);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tSystem.out.println(\"Usage: 'time '\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\tSystem.out.println(\"Usage: 'time '\");\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tSystem.out.println(\"Not implemented yet.\");\n\t\t\tbreak;\n\t\t}\n\t}\n", "output": "\tprivate static void parse(String in2) {\n\t\tString[] result = in.split(\" \", 2);\n\t\tswitch (result[0]) {\n\t\tcase \"about\":\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"Echode version 0.3\\nMade by Erik Konijn and Marks Polakovs\");\n\t\t\tbreak;\n\t\tcase \"kill\":\n\t\t\tSystem.out.println(\"Echode shut down succesfully.\");\n\t\t\tSystem.exit(0);\n\t\t\tbreak;\n\t\tcase \"help\":\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"List of commands:\\n\"\n\t\t\t\t\t\t\t+ \"about ----------------------------------- Gives some info about ECHODE\\n\"\n\t\t\t\t\t\t\t+ \"help ---------------------------------------------- Lists all commands\\n\"\n\t\t\t\t\t\t\t+ \"kill ---------------------------------------- Quits the ECHODE console\\n\"\n\t\t\t\t\t\t\t+ \"version ------------------------ Outputs current Echode version number\\n\"\n\t\t\t\t\t\t\t+ \"time --------------------------------- Outputs time\\n\");\n\t\t\tbreak;\n\t\tcase \"version\":\n\t\t\tSystem.out.println(\"0.3\");\n\t\t\tbreak;\n\t\tcase \"time\":\n\t\t\ttry {\n\t\t\t\tswitch (result[1]) {\n\t\t\t\tcase \"all\":\n\t\t\t\t\tString alltime = new SimpleDateFormat(\n\t\t\t\t\t\t\t\"yyyy-MM-dd HH:mm:ss\").format(Calendar\n\t\t\t\t\t\t\t.getInstance().getTime());\n\t\t\t\t\tSystem.out.println(alltime);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"date\":\n\t\t\t\t\tString datetime = new SimpleDateFormat(\n\t\t\t\t\t\t\t\"yyyy-MM-dd\").format(Calendar\n\t\t\t\t\t\t\t.getInstance().getTime());\n\t\t\t\t\tSystem.out.println(datetime);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"digital\":\n\t\t\t\t\tString digitaltime = new SimpleDateFormat(\n\t\t\t\t\t\t\t\"HH:mm:ss\").format(Calendar\n\t\t\t\t\t\t\t.getInstance().getTime());\n\t\t\t\t\tSystem.out.println(digitaltime);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tSystem.out.println(\"Usage: 'time '\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\tSystem.out.println(\"Usage: 'time '\");\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tSystem.out.println(\"Not implemented yet.\");\n\t\t\tbreak;\n\t\t}\n\t}\n"} {"input": " public void Draw()\n {\n Paint pa = new Paint();\n RMR.c.save();\n {\n int mapW = this.width * 32;\n int mapH = this.height * 32;\n Player p = this.p0;\n double mapRotation = Math.toDegrees(Math.asin(Math.abs(p.posY - p.prevPosY) / Math.sqrt(Math.pow(p.posX - p.prevPosX, 2) + Math.pow(p.posY - p.prevPosY, 2))));\n if ((p.posX - p.prevPosX) >= 0)\n {\n if ((p.posY - p.prevPosY) >= 0)\n {\n mapRotation = 180 - mapRotation;\n }\n else\n {\n mapRotation = 180 + mapRotation;\n }\n }\n else\n {\n if ((p.posY - p.prevPosY) < 0)\n {\n mapRotation = 360 - mapRotation;\n }\n }\n RMR.c.scale(((float) RMR.sw.getWidth() / (float) mapH), ((float) RMR.sw.getWidth() / (float) mapH));\n Rect src = new Rect();\n Rect dst = new Rect();\n float \u03b1 = 0.9f;\n RMR.c.save();\n {\n RMR.c.translate(RMR.mapSideLength * 32 / 2, RMR.mapSideLength * 32 / 2);\n double delta = prevFilteredCompass + Math.toDegrees(RMR.compass.orientationData[0]);\n Log.d(\"compass\", delta + \" \" + prevFilteredCompass + \" \" + (Math.abs(delta) > 180));\n delta = (delta > 180) ? (delta - 360) : ((delta < -180) ? (delta + 360) : delta);\n prevFilteredCompass = (float) (\u03b1 * delta - Math.toDegrees(RMR.compass.orientationData[0]));\n if (this.corner1fixed && this.corner2fixed)\n {\n RMR.c.rotate((!Double.isNaN(mapRotation) ? (float) mapRotation : 0) + prevFilteredCompass, 0, 0);\n }\n RMR.c.translate(-this.p0.posY, -this.p0.posX);\n pa.setColor(Color.DKGRAY);\n RMR.c.save();\n {\n RMR.c.drawLine(0, 0, 32 * this.width, 0, pa);\n RMR.c.drawLine(0, 0, 0, 32 * this.height, pa);\n RMR.c.drawLine(32 * this.width, 32 * this.height, 32 * this.width, 0, pa);\n RMR.c.drawLine(32 * this.width, 32 * this.height, 0, 32 * this.height, pa);\n }\n RMR.c.restore();\n pa = new Paint();\n RMR.c.save();\n {\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.tile_0_iterator++;\n if(RMGR.tile_0_iterator == RMGR.TILE_0.length) RMGR.tile_0_iterator = 0;\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.tile_1_iterator++;\n if(RMGR.tile_1_iterator == RMGR.TILE_1.length) RMGR.tile_1_iterator = 0;\n for (int i = 0; i < this.height; i++)\n {\n for (int j = 0; j < this.width; j++)\n {\n switch (this.tiles[j][i])\n {\n default:\n continue;\n case 1:\n RMR.c.save();\n {\n int it = RMGR.tile_0_iterator + i + j;\n it %= RMGR.TILE_0.length;\n RMR.c.translate(i * 32, j * 32);\n src.set(0, 0, RMGR.TILE_0[it].getWidth(), RMGR.TILE_0[it].getHeight());\n dst.set(0, 0, 32, 32);\n pa.setColor(Color.WHITE);\n RMR.c.drawBitmap(RMGR.TILE_0[it], src, dst, pa);\n }\n RMR.c.restore();\n break;\n case 2:\n RMR.c.save();\n {\n int it = RMGR.tile_1_iterator + i + j;\n it %= RMGR.TILE_1.length;\n RMR.c.translate(i * 32, j * 32);\n src.set(0, 0, RMGR.TILE_1[it].getWidth(), RMGR.TILE_1[it].getHeight());\n dst.set(0, 0, 32, 32);\n pa.setColor(Color.WHITE);\n RMR.c.drawBitmap(RMGR.TILE_1[it], src, dst, pa);\n }\n RMR.c.restore();\n break;\n }\n }\n }\n }\n RMR.c.restore();\n RMR.c.save();\n {\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.pickup_0_iterator++;\n if(RMGR.pickup_0_iterator == RMGR.PICKUP_0.length) RMGR.pickup_0_iterator = 0;\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.pickup_1_iterator++;\n if(RMGR.pickup_1_iterator == RMGR.PICKUP_1.length) RMGR.pickup_1_iterator = 0;\n for (int i = 0; i < this.pickups.size(); i++)\n {\n RMR.c.save();\n {\n RMR.c.translate(this.pickups.get(i)[1] * 32, this.pickups.get(i)[0] * 32);\n pa.setAlpha((int) Math.floor(100 / ((float)this.pickups.get(i)[3] / ((float)this.pickups.get(i)[2] != 0 ? (float)this.pickups.get(i)[2] : 1))));\n switch (this.pickups.get(i)[4])\n {\n default:\n case 1:\n int it = (RMGR.pickup_0_iterator + this.pickups.get(i)[0] + this.pickups.get(i)[1]);\n it %= RMGR.PICKUP_0.length;\n src.set(0, 0, RMGR.PICKUP_0[it].getWidth(), RMGR.PICKUP_0[it].getHeight());\n dst.set(4, 4, 28, 28);\n RMR.c.drawBitmap(RMGR.PICKUP_0[it], src, dst, pa);\n break;\n case 2:\n int it1 = (RMGR.pickup_1_iterator + this.pickups.get(i)[0] + this.pickups.get(i)[1]);\n it1 %= RMGR.PICKUP_1.length;\n src.set(0, 0, RMGR.PICKUP_1[it1].getWidth(), RMGR.PICKUP_1[it1].getHeight());\n dst.set(4, 4, 28, 28);\n RMR.c.drawBitmap(RMGR.PICKUP_1[it1], src, dst, pa);\n break;\n }\n }\n RMR.c.restore();\n }\n }\n RMR.c.restore();\n pa = new Paint();\n if (this.state == MapState.Suspended)\n {\n RMR.c.save();\n {\n pa.setColor(Color.BLACK);\n pa.setAlpha(80);\n RMR.c.drawRect(0, 0, RMR.mapSideLength * 32, this.suspendTile.x * 32, pa);\n RMR.c.drawRect((this.suspendTile.y + 1) * 32, this.suspendTile.x * 32, RMR.mapSideLength * 32, (this.suspendTile.x + 1) * 32, pa);\n RMR.c.drawRect(0, this.suspendTile.x * 32, this.suspendTile.y * 32, (this.suspendTile.x + 1) * 32, pa);\n RMR.c.drawRect(0, (this.suspendTile.x + 1) * 32, RMR.mapSideLength * 32, RMR.mapSideLength * 32, pa);\n pa.setColor(Color.YELLOW);\n pa.setAlpha((int) Math.floor((Math.sin(System.currentTimeMillis() / 100) + 2) * 30));\n RMR.c.drawRect(this.suspendTile.y * 32, this.suspendTile.x * 32, (this.suspendTile.y + 1) * 32, (this.suspendTile.x + 1) * 32, pa);\n }\n RMR.c.restore();\n }\n RMR.c.save();\n {\n pa.setColor(Color.WHITE);\n RMR.c.translate(p1.posY, p1.posX);\n src.set(0, 0, RMGR.CHAR_0.getWidth(), RMGR.CHAR_0.getHeight());\n dst.set(-12, -12, 12, 12);\n RMR.c.drawBitmap(RMGR.CHAR_0, src, dst, pa);\n }\n RMR.c.restore();\n }\n RMR.c.restore();\n RMR.c.save();\n {\n pa.setColor(Color.WHITE);\n RMR.c.translate(RMR.mapSideLength * 32 / 2, RMR.mapSideLength * 32 / 2);\n src.set(0, 0, RMGR.CHAR_0.getWidth(), RMGR.CHAR_0.getHeight());\n dst.set(-12, -12, 12, 12);\n RMR.c.drawBitmap(RMGR.CHAR_0, src, dst, pa);\n }\n RMR.c.restore();\n }\n RMR.c.restore();\n }\n", "output": " public void Draw()\n {\n Paint pa = new Paint();\n RMR.c.save();\n {\n int mapW = this.width * 32;\n int mapH = this.height * 32;\n Player p = this.p0;\n double mapRotation = Math.toDegrees(Math.asin(Math.abs(p.posY - p.prevPosY) / Math.sqrt(Math.pow(p.posX - p.prevPosX, 2) + Math.pow(p.posY - p.prevPosY, 2))));\n if ((p.posX - p.prevPosX) >= 0)\n {\n if ((p.posY - p.prevPosY) >= 0)\n {\n mapRotation = 180 - mapRotation;\n }\n else\n {\n mapRotation = 180 + mapRotation;\n }\n }\n else\n {\n if ((p.posY - p.prevPosY) < 0)\n {\n mapRotation = 360 - mapRotation;\n }\n }\n RMR.c.scale(((float) RMR.sw.getWidth() / (float) mapH), ((float) RMR.sw.getWidth() / (float) mapH));\n Rect src = new Rect();\n Rect dst = new Rect();\n float \u03b1 = 0.9f;\n RMR.c.save();\n {\n RMR.c.translate(RMR.mapSideLength * 32 / 2, RMR.mapSideLength * 32 / 2);\n double delta = prevFilteredCompass + Math.toDegrees(RMR.compass.orientationData[0]);\n Log.d(\"compass\", delta + \" \" + prevFilteredCompass + \" \" + (Math.abs(delta) > 180));\n delta = (delta > 180) ? (delta - 360) : ((delta < -180) ? (delta + 360) : delta);\n prevFilteredCompass = (float) (\u03b1 * delta - Math.toDegrees(RMR.compass.orientationData[0]));\n if (this.corner1fixed && this.corner2fixed)\n {\n RMR.c.rotate(prevFilteredCompass, 0, 0);\n }\n RMR.c.translate(-this.p0.posY, -this.p0.posX);\n pa.setColor(Color.DKGRAY);\n RMR.c.save();\n {\n RMR.c.drawLine(0, 0, 32 * this.width, 0, pa);\n RMR.c.drawLine(0, 0, 0, 32 * this.height, pa);\n RMR.c.drawLine(32 * this.width, 32 * this.height, 32 * this.width, 0, pa);\n RMR.c.drawLine(32 * this.width, 32 * this.height, 0, 32 * this.height, pa);\n }\n RMR.c.restore();\n pa = new Paint();\n RMR.c.save();\n {\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.tile_0_iterator++;\n if(RMGR.tile_0_iterator == RMGR.TILE_0.length) RMGR.tile_0_iterator = 0;\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.tile_1_iterator++;\n if(RMGR.tile_1_iterator == RMGR.TILE_1.length) RMGR.tile_1_iterator = 0;\n for (int i = 0; i < this.height; i++)\n {\n for (int j = 0; j < this.width; j++)\n {\n switch (this.tiles[j][i])\n {\n default:\n continue;\n case 1:\n RMR.c.save();\n {\n int it = RMGR.tile_0_iterator + i + j;\n it %= RMGR.TILE_0.length;\n RMR.c.translate(i * 32, j * 32);\n src.set(0, 0, RMGR.TILE_0[it].getWidth(), RMGR.TILE_0[it].getHeight());\n dst.set(0, 0, 32, 32);\n pa.setColor(Color.WHITE);\n RMR.c.drawBitmap(RMGR.TILE_0[it], src, dst, pa);\n }\n RMR.c.restore();\n break;\n case 2:\n RMR.c.save();\n {\n int it = RMGR.tile_1_iterator + i + j;\n it %= RMGR.TILE_1.length;\n RMR.c.translate(i * 32, j * 32);\n src.set(0, 0, RMGR.TILE_1[it].getWidth(), RMGR.TILE_1[it].getHeight());\n dst.set(0, 0, 32, 32);\n pa.setColor(Color.WHITE);\n RMR.c.drawBitmap(RMGR.TILE_1[it], src, dst, pa);\n }\n RMR.c.restore();\n break;\n }\n }\n }\n }\n RMR.c.restore();\n RMR.c.save();\n {\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.pickup_0_iterator++;\n if(RMGR.pickup_0_iterator == RMGR.PICKUP_0.length) RMGR.pickup_0_iterator = 0;\n if((System.currentTimeMillis() / 30) % 2 == 0) RMGR.pickup_1_iterator++;\n if(RMGR.pickup_1_iterator == RMGR.PICKUP_1.length) RMGR.pickup_1_iterator = 0;\n for (int i = 0; i < this.pickups.size(); i++)\n {\n RMR.c.save();\n {\n RMR.c.translate(this.pickups.get(i)[1] * 32, this.pickups.get(i)[0] * 32);\n pa.setAlpha((int) Math.floor(100 / ((float)this.pickups.get(i)[3] / ((float)this.pickups.get(i)[2] != 0 ? (float)this.pickups.get(i)[2] : 1))));\n switch (this.pickups.get(i)[4])\n {\n default:\n case 1:\n int it = (RMGR.pickup_0_iterator + this.pickups.get(i)[0] + this.pickups.get(i)[1]);\n it %= RMGR.PICKUP_0.length;\n src.set(0, 0, RMGR.PICKUP_0[it].getWidth(), RMGR.PICKUP_0[it].getHeight());\n dst.set(4, 4, 28, 28);\n RMR.c.drawBitmap(RMGR.PICKUP_0[it], src, dst, pa);\n break;\n case 2:\n int it1 = (RMGR.pickup_1_iterator + this.pickups.get(i)[0] + this.pickups.get(i)[1]);\n it1 %= RMGR.PICKUP_1.length;\n src.set(0, 0, RMGR.PICKUP_1[it1].getWidth(), RMGR.PICKUP_1[it1].getHeight());\n dst.set(4, 4, 28, 28);\n RMR.c.drawBitmap(RMGR.PICKUP_1[it1], src, dst, pa);\n break;\n }\n }\n RMR.c.restore();\n }\n }\n RMR.c.restore();\n pa = new Paint();\n if (this.state == MapState.Suspended)\n {\n RMR.c.save();\n {\n pa.setColor(Color.BLACK);\n pa.setAlpha(80);\n RMR.c.drawRect(0, 0, RMR.mapSideLength * 32, this.suspendTile.x * 32, pa);\n RMR.c.drawRect((this.suspendTile.y + 1) * 32, this.suspendTile.x * 32, RMR.mapSideLength * 32, (this.suspendTile.x + 1) * 32, pa);\n RMR.c.drawRect(0, this.suspendTile.x * 32, this.suspendTile.y * 32, (this.suspendTile.x + 1) * 32, pa);\n RMR.c.drawRect(0, (this.suspendTile.x + 1) * 32, RMR.mapSideLength * 32, RMR.mapSideLength * 32, pa);\n pa.setColor(Color.YELLOW);\n pa.setAlpha((int) Math.floor((Math.sin(System.currentTimeMillis() / 100) + 2) * 30));\n RMR.c.drawRect(this.suspendTile.y * 32, this.suspendTile.x * 32, (this.suspendTile.y + 1) * 32, (this.suspendTile.x + 1) * 32, pa);\n }\n RMR.c.restore();\n }\n RMR.c.save();\n {\n pa.setColor(Color.WHITE);\n RMR.c.translate(p1.posY, p1.posX);\n src.set(0, 0, RMGR.CHAR_0.getWidth(), RMGR.CHAR_0.getHeight());\n dst.set(-12, -12, 12, 12);\n RMR.c.drawBitmap(RMGR.CHAR_0, src, dst, pa);\n }\n RMR.c.restore();\n }\n RMR.c.restore();\n RMR.c.save();\n {\n pa.setColor(Color.WHITE);\n RMR.c.translate(RMR.mapSideLength * 32 / 2, RMR.mapSideLength * 32 / 2);\n src.set(0, 0, RMGR.CHAR_0.getWidth(), RMGR.CHAR_0.getHeight());\n dst.set(-12, -12, 12, 12);\n RMR.c.drawBitmap(RMGR.CHAR_0, src, dst, pa);\n }\n RMR.c.restore();\n }\n RMR.c.restore();\n }\n"} {"input": "\tpublic void onReceive(Context context, Intent intent) {\n\t\tmContext = context;\n\t\tmContentResolver = context.getContentResolver();\n\t\tmPreferences = context.getSharedPreferences(\"preferences\",\n\t\t\t\tContext.MODE_PRIVATE);\n\t\tboolean firstTime = mPreferences.getBoolean(\"firstTime\", true);\n\t\tif (firstTime) {\n\t\t\tSharedPreferences.Editor editor = mPreferences.edit();\n\t\t\teditor.putBoolean(\"firstTime\", false);\n\t\t\teditor.commit();\n\t\t\tnew CreateDatabase().execute();\n\t\t} else\n\t\t\tnew ScanForPackages().execute();\n\t}\n", "output": "\tpublic void onReceive(Context context, Intent intent) {\n\t\tmContext = context;\n\t\tmContentResolver = context.getContentResolver();\n\t\tmPreferences = context.getSharedPreferences(\"preferences\",\n\t\t\t\tContext.MODE_PRIVATE);\n\t\tboolean firstTime = mPreferences.getBoolean(\"firstTime\", true);\n\t\tif (firstTime) {\n\t\t\tSharedPreferences.Editor editor = mPreferences.edit();\n\t\t\teditor.putBoolean(\"firstTime\", false);\n\t\t\teditor.commit();\n\t\t\ttry {\n\t\t\t\tnew CreateDatabase().execute();\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tnew ScanForPackages().execute();\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " private void updateChildrens(Vector3f cam) {\n TerrainQuad q1 = cache.get(cam.add(quadIndex[5]));\n TerrainQuad q2 = cache.get(cam.add(quadIndex[6]));\n TerrainQuad q3 = cache.get(cam.add(quadIndex[9]));\n TerrainQuad q4 = cache.get(cam.add(quadIndex[10]));\n int dx = 0;\n int dy = 0;\n if (currentCell != null) {\n dx = (int) (cam.x - currentCell.x);\n dy = (int) (cam.z - currentCell.z);\n }\n int kxm = 0;\n int kxM = 4;\n int kym = 0;\n int kyM = 4;\n if (dx == -1) {\n kxM = 3;\n } else if (dx == 1) {\n kxm = 1;\n }\n if (dy == -1) {\n kyM = 3;\n } else if (dy == 1) {\n kym = 1;\n }\n for (int i = kym; i < kyM; i++) {\n for (int j = kxm; j < kxM; j++) {\n cache.get(cam.add(quadIndex[i * 4 + j]));\n }\n }\n if (q1 == null || q2 == null || q3 == null || q4 == null) {\n try {\n executor.submit(new UpdateQuadCache(cam, true)).get();\n q1 = cache.get(cam.add(quadIndex[5]));\n q2 = cache.get(cam.add(quadIndex[6]));\n q3 = cache.get(cam.add(quadIndex[9]));\n q4 = cache.get(cam.add(quadIndex[10]));\n } catch (InterruptedException ex) {\n Logger.getLogger(TerrainGrid.class.getName()).log(Level.SEVERE, null, ex);\n return;\n } catch (ExecutionException ex) {\n Logger.getLogger(TerrainGrid.class.getName()).log(Level.SEVERE, null, ex);\n return;\n }\n }\n executor.execute(new UpdateQuadCache(cam));\n RigidBodyControl control = getControl(RigidBodyControl.class);\n PhysicsSpace space = null;\n if (control != null) {\n space = control.getPhysicsSpace();\n space.remove(this);\n this.removeControl(control);\n }\n this.removeQuad(1);\n this.removeQuad(2);\n this.removeQuad(3);\n this.removeQuad(4);\n attachQuadAt(q1, 1);\n attachQuadAt(q2, 2);\n attachQuadAt(q3, 3);\n attachQuadAt(q4, 4);\n this.currentCell = cam;\n this.setLocalTranslation(cam.mult(this.getLocalScale().mult(this.quadSize)));\n this.updateModelBound();\n if (control != null) {\n int collisionGroupsCollideWith = control.getCollideWithGroups();\n int collisionGroups = control.getCollisionGroup();\n control = new RigidBodyControl(new HeightfieldCollisionShape(getHeightMap(), getLocalScale()), 0);\n control.setCollideWithGroups(collisionGroupsCollideWith);\n control.setCollisionGroup(collisionGroups);\n this.addControl(control);\n space.add(this);\n }\n }\n", "output": " private void updateChildrens(Vector3f cam) {\n TerrainQuad q1 = cache.get(cam.add(quadIndex[5]));\n TerrainQuad q2 = cache.get(cam.add(quadIndex[6]));\n TerrainQuad q3 = cache.get(cam.add(quadIndex[9]));\n TerrainQuad q4 = cache.get(cam.add(quadIndex[10]));\n int dx = 0;\n int dy = 0;\n if (currentCell != null) {\n dx = (int) (cam.x - currentCell.x);\n dy = (int) (cam.z - currentCell.z);\n }\n int kxm = 0;\n int kxM = 4;\n int kym = 0;\n int kyM = 4;\n if (dx == -1) {\n kxM = 3;\n } else if (dx == 1) {\n kxm = 1;\n }\n if (dy == -1) {\n kyM = 3;\n } else if (dy == 1) {\n kym = 1;\n }\n for (int i = kym; i < kyM; i++) {\n for (int j = kxm; j < kxM; j++) {\n cache.get(cam.add(quadIndex[i * 4 + j]));\n }\n }\n if (q1 == null || q2 == null || q3 == null || q4 == null) {\n try {\n executor.submit(new UpdateQuadCache(cam, true)).get();\n q1 = cache.get(cam.add(quadIndex[5]));\n q2 = cache.get(cam.add(quadIndex[6]));\n q3 = cache.get(cam.add(quadIndex[9]));\n q4 = cache.get(cam.add(quadIndex[10]));\n } catch (InterruptedException ex) {\n Logger.getLogger(TerrainGrid.class.getName()).log(Level.SEVERE, null, ex);\n return;\n } catch (ExecutionException ex) {\n Logger.getLogger(TerrainGrid.class.getName()).log(Level.SEVERE, null, ex);\n return;\n }\n }\n executor.execute(new UpdateQuadCache(cam));\n RigidBodyControl control = getControl(RigidBodyControl.class);\n PhysicsSpace space = null;\n if (control != null) {\n space = control.getPhysicsSpace();\n space.remove(this);\n this.removeControl(control);\n }\n this.removeQuad(1);\n this.removeQuad(2);\n this.removeQuad(3);\n this.removeQuad(4);\n attachQuadAt(q1, 1);\n attachQuadAt(q2, 2);\n attachQuadAt(q3, 3);\n attachQuadAt(q4, 4);\n this.currentCell = cam;\n this.setLocalTranslation(cam.mult(this.getLocalScale().mult(this.quadSize-1)));\n this.updateModelBound();\n if (control != null) {\n int collisionGroupsCollideWith = control.getCollideWithGroups();\n int collisionGroups = control.getCollisionGroup();\n control = new RigidBodyControl(new HeightfieldCollisionShape(getHeightMap(), getLocalScale()), 0);\n control.setCollideWithGroups(collisionGroupsCollideWith);\n control.setCollisionGroup(collisionGroups);\n this.addControl(control);\n space.add(this);\n }\n }\n"} {"input": "\tpublic void write(Writer writer) throws IOException {\n\t\twriter.write('{');\n\t\tfor (Entry entry : values.entrySet()) {\n\t\t\twriter.write(JsonUtils.format(entry.getKey()));\n\t\t\twriter.write(':');\n\t\t\twriter.write(JsonUtils.format(entry.getValue()));\n\t\t}\n\t\twriter.write('}');\n\t}\n", "output": "\tpublic void write(Writer writer) throws IOException {\n\t\twriter.write('{');\n\t\tboolean first = true;\n\t\tfor (Entry entry : values.entrySet()) {\n\t\t\tif (first) {\n\t\t\t\tfirst = false;\n\t\t\t} else {\n\t\t\t\twriter.write(',');\n\t\t\t}\n\t\t\twriter.write(JsonUtils.format(entry.getKey()));\n\t\t\twriter.write(':');\n\t\t\twriter.write(JsonUtils.format(entry.getValue()));\n\t\t}\n\t\twriter.write('}');\n\t}\n"} {"input": "\tpublic static void SetSpawnTick(Player p,String spawntick) {\n\t\tif(IsInteger(spawntick)) {\n\t\t\tBlock b = p.getTargetBlock(null, 200);\n\t\t\tif(b.getTypeId() == 52) {\n\t\t\t\tif(IsEMASpawner(b.getLocation())) {\n\t\t\t\t\tSpawnerCache sc = getSpawner(b.getLocation());\n\t\t\t\t\tsc.TimerTick = Integer.parseInt(spawntick);\n\t\t\t\t\tsc.TimerEnabled = true;\n\t\t\t\t\tint TimerTickActual = sc.TimerTick * 20;\n\t\t\t\t\tif(!SpawnerCacheTimers.get(sc).equals(null)) SpawnerCacheTimers.get(sc).cancel();\n\t\t\t\t\tSpawnerCacheTimers.put(sc, new MonsterSpawnTimer(sc).runTaskTimer(Bukkit.getPluginManager().getPlugin(\"EasyMobArmory\"), TimerTickActual, TimerTickActual));\n\t\t\t\t\tSaveSpawnerCache(sc);\n\t\t\t\t\tString LocString = Spawners.LocString(sc.getLocation());\n\t\t\t\t\tSpawners.addtolist(\"Spawners.Running.List\", LocString);\n\t\t\t\t\tMessenger.playermessage(\"The spawner at \" + LocString + \" had it's TimerTick set to \" + spawntick + \".\", p);\n\t\t\t\t\tMessenger.info(\"The spawner at \" + LocString + \" had it's TimerTick set to \" + spawntick + \" by \" + p.getName() + \".\");\n\t\t\t\t}else{\n\t\t\t\t\tMessenger.playermessage(\"The block is a Spawner, but not a EMA-Spawner.\", p);\n\t\t\t\t\tMessenger.playermessage(\"Select the block with a bone and with EMA enabled and add some EMA eggs to make it an EMA spawner.\", p);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tMessenger.playermessage(\"Please look at a EMA-Spawner before typing this command.\", p);\n\t\t\t}\n\t\t}else{\n\t\t\tMessenger.playermessage(\"The second argument must be an integer.\", p);\n\t\t}\n\t}\n", "output": "\tpublic static void SetSpawnTick(Player p,String spawntick) {\n\t\tif(IsInteger(spawntick)) {\n\t\t\tBlock b = p.getTargetBlock(null, 200);\n\t\t\tif(b.getTypeId() == 52) {\n\t\t\t\tif(IsEMASpawner(b.getLocation())) {\n\t\t\t\t\tSpawnerCache sc = getSpawner(b.getLocation());\n\t\t\t\t\tsc.TimerTick = Integer.parseInt(spawntick);\n\t\t\t\t\tsc.TimerEnabled = true;\n\t\t\t\t\tint TimerTickActual = sc.TimerTick * 20;\n\t\t\t\t\tif(SpawnerCacheTimers.get(sc) == null) SpawnerCacheTimers.get(sc).cancel();\n\t\t\t\t\tSpawnerCacheTimers.put(sc, new MonsterSpawnTimer(sc).runTaskTimer(Bukkit.getPluginManager().getPlugin(\"EasyMobArmory\"), TimerTickActual, TimerTickActual));\n\t\t\t\t\tSaveSpawnerCache(sc);\n\t\t\t\t\tString LocString = Spawners.LocString(sc.getLocation());\n\t\t\t\t\tSpawners.addtolist(\"Spawners.Running.List\", LocString);\n\t\t\t\t\tMessenger.playermessage(\"The spawner at \" + LocString + \" had it's TimerTick set to \" + spawntick + \".\", p);\n\t\t\t\t\tMessenger.info(\"The spawner at \" + LocString + \" had it's TimerTick set to \" + spawntick + \" by \" + p.getName() + \".\");\n\t\t\t\t}else{\n\t\t\t\t\tMessenger.playermessage(\"The block is a Spawner, but not a EMA-Spawner.\", p);\n\t\t\t\t\tMessenger.playermessage(\"Select the block with a bone and with EMA enabled and add some EMA eggs to make it an EMA spawner.\", p);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tMessenger.playermessage(\"Please look at a EMA-Spawner before typing this command.\", p);\n\t\t\t}\n\t\t}else{\n\t\t\tMessenger.playermessage(\"The second argument must be an integer.\", p);\n\t\t}\n\t}\n"} {"input": " protected final int performOperation(final SyncResult syncResult) {\n int redirectCount = 0;\n do {\n final EasResponse response;\n try {\n if (registerClientCert()) {\n response = mConnection.executeHttpUriRequest(makeRequest(), getTimeout());\n } else {\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n return RESULT_CLIENT_CERTIFICATE_REQUIRED;\n }\n } catch (final IOException e) {\n switch (mConnection.getStoppedReason()) {\n case EasServerConnection.STOPPED_REASON_ABORT:\n return RESULT_ABORT;\n case EasServerConnection.STOPPED_REASON_RESTART:\n return RESULT_RESTART;\n default:\n break;\n }\n LogUtils.e(LOG_TAG, e, \"Exception while sending request\");\n if (syncResult != null) {\n ++syncResult.stats.numIoExceptions;\n }\n return RESULT_REQUEST_FAILURE;\n } catch (final IllegalStateException e) {\n LogUtils.e(LOG_TAG, e, \"Exception while sending request\");\n if (syncResult != null) {\n syncResult.databaseError = true;\n }\n return RESULT_OTHER_FAILURE;\n }\n try {\n final int result;\n if (response.isSuccess()) {\n try {\n result = handleResponse(response, syncResult);\n if (result >= 0) {\n return result;\n }\n } catch (final IOException e) {\n LogUtils.e(LOG_TAG, e, \"Exception while handling response\");\n if (syncResult != null) {\n ++syncResult.stats.numParseExceptions;\n }\n return RESULT_OTHER_FAILURE;\n }\n } else {\n result = RESULT_OTHER_FAILURE;\n }\n if (result == RESULT_FORBIDDEN || (response.isForbidden() && handleForbidden())) {\n LogUtils.e(LOG_TAG, \"Forbidden response\");\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n return RESULT_FORBIDDEN;\n }\n if (result == RESULT_PROVISIONING_ERROR || response.isProvisionError()) {\n if (handleProvisionError(syncResult, mAccountId)) {\n continue;\n }\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n return RESULT_PROVISIONING_ERROR;\n }\n if (response.isAuthError()) {\n LogUtils.e(LOG_TAG, \"Authentication error\");\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n if (response.isMissingCertificate()) {\n return RESULT_CLIENT_CERTIFICATE_REQUIRED;\n }\n return RESULT_AUTHENTICATION_ERROR;\n }\n if (response.isRedirectError()) {\n ++redirectCount;\n mConnection.redirectHostAuth(response.getRedirectAddress());\n } else {\n LogUtils.e(LOG_TAG, \"Generic error\");\n if (syncResult != null) {\n ++syncResult.stats.numIoExceptions;\n }\n return RESULT_OTHER_FAILURE;\n }\n } finally {\n response.close();\n }\n } while (redirectCount < MAX_REDIRECTS);\n LogUtils.e(LOG_TAG, \"Too many redirects\");\n if (syncResult != null) {\n syncResult.tooManyRetries = true;\n }\n return RESULT_TOO_MANY_REDIRECTS;\n }\n", "output": " protected final int performOperation(final SyncResult syncResult) {\n int redirectCount = 0;\n do {\n final EasResponse response;\n try {\n if (registerClientCert()) {\n response = mConnection.executeHttpUriRequest(makeRequest(), getTimeout());\n } else {\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n return RESULT_CLIENT_CERTIFICATE_REQUIRED;\n }\n } catch (final IOException e) {\n switch (mConnection.getStoppedReason()) {\n case EasServerConnection.STOPPED_REASON_ABORT:\n return RESULT_ABORT;\n case EasServerConnection.STOPPED_REASON_RESTART:\n return RESULT_RESTART;\n default:\n break;\n }\n LogUtils.e(LOG_TAG, e, \"Exception while sending request\");\n if (syncResult != null) {\n ++syncResult.stats.numIoExceptions;\n }\n return RESULT_REQUEST_FAILURE;\n } catch (final IllegalStateException e) {\n LogUtils.e(LOG_TAG, e, \"Exception while sending request\");\n if (syncResult != null) {\n syncResult.databaseError = true;\n }\n return RESULT_OTHER_FAILURE;\n }\n try {\n final int result;\n if (response.isSuccess()) {\n try {\n result = handleResponse(response, syncResult);\n if (result >= 0) {\n return result;\n }\n } catch (final IOException e) {\n LogUtils.e(LOG_TAG, e, \"Exception while handling response\");\n if (syncResult != null) {\n ++syncResult.stats.numParseExceptions;\n }\n return RESULT_OTHER_FAILURE;\n }\n } else {\n result = RESULT_OTHER_FAILURE;\n }\n if (result == RESULT_FORBIDDEN || (response.isForbidden() && handleForbidden())) {\n LogUtils.e(LOG_TAG, \"Forbidden response\");\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n return RESULT_FORBIDDEN;\n }\n if (result == RESULT_PROVISIONING_ERROR || response.isProvisionError()) {\n if (handleProvisionError(syncResult, mAccountId)) {\n continue;\n }\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n return RESULT_PROVISIONING_ERROR;\n }\n if (response.isAuthError()) {\n LogUtils.e(LOG_TAG, \"Authentication error\");\n if (syncResult != null) {\n ++syncResult.stats.numAuthExceptions;\n }\n if (response.isMissingCertificate()) {\n return RESULT_CLIENT_CERTIFICATE_REQUIRED;\n }\n return RESULT_AUTHENTICATION_ERROR;\n }\n if (response.isRedirectError()) {\n ++redirectCount;\n mConnection.redirectHostAuth(response.getRedirectAddress());\n } else {\n LogUtils.e(LOG_TAG, \"Generic error: \" + response.getStatus());\n if (syncResult != null) {\n ++syncResult.stats.numIoExceptions;\n }\n return RESULT_OTHER_FAILURE;\n }\n } finally {\n response.close();\n }\n } while (redirectCount < MAX_REDIRECTS);\n LogUtils.e(LOG_TAG, \"Too many redirects\");\n if (syncResult != null) {\n syncResult.tooManyRetries = true;\n }\n return RESULT_TOO_MANY_REDIRECTS;\n }\n"} {"input": " protected void printStats() {\n int size;\n synchronized (this) {\n size = victims.size() + 1;\n }\n StatsMessage me = createStats();\n totalStats.add(me);\n java.text.NumberFormat nf = java.text.NumberFormat.getInstance();\n java.text.NumberFormat pf = java.text.NumberFormat.getInstance();\n pf.setMaximumFractionDigits(3);\n pf.setMinimumFractionDigits(3);\n pf.setGroupingUsed(false);\n out.println(\"-------------------------------SATIN STATISTICS------\"\n + \"--------------------------\");\n if (SPAWN_STATS) {\n out.println(\"SATIN: SPAWN: \" + nf.format(totalStats.spawns)\n + \" spawns, \" + nf.format(totalStats.jobsExecuted)\n + \" executed, \" + nf.format(totalStats.syncs) + \" syncs\");\n if (ABORTS) {\n out.println(\"SATIN: ABORT: \"\n + nf.format(totalStats.aborts) + \" aborts, \"\n + nf.format(totalStats.abortMessages) + \" abort msgs, \"\n + nf.format(totalStats.abortedJobs) + \" aborted jobs\");\n }\n }\n if (TUPLE_STATS) {\n out.println(\"SATIN: TUPLE_SPACE: \"\n + nf.format(totalStats.tupleMsgs) + \" bcasts, \"\n + nf.format(totalStats.tupleBytes) + \" bytes\");\n }\n if (POLL_FREQ != 0 && POLL_TIMING) {\n out.println(\"SATIN: POLL: poll count = \"\n + nf.format(totalStats.pollCount));\n }\n if (IDLE_TIMING) {\n out.println(\"SATIN: IDLE: idle count = \"\n + nf.format(totalStats.idleCount));\n }\n if (STEAL_STATS) {\n out.println(\"SATIN: STEAL: \"\n + nf.format(totalStats.stealAttempts)\n + \" attempts, \"\n + nf.format(totalStats.stealSuccess)\n + \" successes (\"\n + pf.format(perStats((double) totalStats.stealSuccess,\n totalStats.stealAttempts) * 100.0)\n + \" %)\");\n\t if(totalStats.asyncStealAttempts != 0) {\n\t\tout.println(\"SATIN: ASYNCSTEAL: \"\n\t\t\t + nf.format(totalStats.asyncStealAttempts)\n\t\t\t + \" attempts, \"\n\t\t\t + nf.format(totalStats.asyncStealSuccess)\n\t\t\t + \" successes (\"\n\t\t\t + pf.format(perStats((double) totalStats.asyncStealSuccess,\n\t\t\t\t\t totalStats.asyncStealAttempts) * 100.0)\n\t\t\t + \" %)\");\n\t }\n out.println(\"SATIN: MESSAGES: intra \"\n + nf.format(totalStats.intraClusterMessages) + \" msgs, \"\n + nf.format(totalStats.intraClusterBytes)\n + \" bytes; inter \"\n + nf.format(totalStats.interClusterMessages) + \" msgs, \"\n + nf.format(totalStats.interClusterBytes) + \" bytes\");\n }\n if (FAULT_TOLERANCE && GRT_STATS) {\n out.println(\"SATIN: GLOBAL_RESULT_TABLE: result updates \"\n + nf.format(totalStats.tableResultUpdates)\n + \",update messages \"\n + nf.format(totalStats.tableUpdateMessages)\n + \", lock updates \"\n + nf.format(totalStats.tableLockUpdates) + \",lookups \"\n + nf.format(totalStats.tableLookups) + \",successful \"\n + nf.format(totalStats.tableSuccessfulLookups) + \",remote \"\n + nf.format(totalStats.tableRemoteLookups));\n }\n if (FAULT_TOLERANCE && FT_STATS) {\n out.println(\"SATIN: FAULT_TOLERANCE: killed orphans \"\n + nf.format(totalStats.killedOrphans));\n out.println(\"SATIN: FAULT_TOLERANCE: restarted jobs \"\n + nf.format(totalStats.restartedJobs));\n }\n\tif (SHARED_OBJECTS && SO_STATS) {\n out.println(\"SATIN: SHARED_OBJECTS: nr invocations \"\n\t\t\t+ nf.format(totalStats.soInvocations)\n\t\t\t+ \", bytes \"\n\t\t\t+ nf.format(totalStats.soInvocationsBytes)\n\t\t\t+\", object transfers \" \n\t\t\t+ nf.format(totalStats.soTransfers)\n\t\t\t+ \", bytes \"\n\t\t\t+ nf.format(totalStats.soTransfersBytes));\n\t}\n out.println(\"-------------------------------SATIN TOTAL TIMES\"\n + \"-------------------------------\");\n if (STEAL_TIMING) {\n out.println(\"SATIN: STEAL_TIME: total \"\n + Timer.format(totalStats.stealTime)\n + \" time/req \"\n + Timer.format(perStats(totalStats.stealTime,\n totalStats.stealAttempts)));\n out.println(\"SATIN: HANDLE_STEAL_TIME: total \"\n + Timer.format(totalStats.handleStealTime)\n + \" time/handle \"\n + Timer.format(perStats(totalStats.handleStealTime,\n totalStats.stealAttempts)));\n out.println(\"SATIN: INV SERIALIZATION_TIME: total \"\n + Timer.format(totalStats.invocationRecordWriteTime)\n + \" time/write \"\n + Timer.format(perStats(totalStats.invocationRecordWriteTime,\n totalStats.stealSuccess)));\n out.println(\"SATIN: INV DESERIALIZATION_TIME: total \"\n + Timer.format(totalStats.invocationRecordReadTime)\n + \" time/read \"\n + Timer.format(perStats(totalStats.invocationRecordReadTime,\n totalStats.stealSuccess)));\n out.println(\"SATIN: RET SERIALIZATION_TIME: total \"\n + Timer.format(totalStats.returnRecordWriteTime)\n + \" time/write \"\n + Timer.format(perStats(totalStats.returnRecordWriteTime,\n totalStats.returnRecordWriteCount)));\n out.println(\"SATIN: RET DESERIALIZATION_TIME: total \"\n + Timer.format(totalStats.returnRecordReadTime)\n + \" time/read \"\n + Timer.format(perStats(totalStats.returnRecordReadTime,\n totalStats.returnRecordReadCount)));\n }\n if (ABORT_TIMING) {\n out.println(\"SATIN: ABORT_TIME: total \"\n + Timer.format(totalStats.abortTime) + \" time/abort \"\n + Timer.format(perStats(totalStats.abortTime, totalStats.aborts)));\n }\n if (TUPLE_TIMING) {\n out.println(\"SATIN: TUPLE_SPACE_BCAST_TIME: total \"\n + Timer.format(totalStats.tupleTime) + \" time/bcast \"\n + Timer.format(perStats(totalStats.tupleTime,\n totalStats.tupleMsgs)));\n out.println(\"SATIN: TUPLE_SPACE_WAIT_TIME: total \"\n + Timer.format(totalStats.tupleWaitTime)\n + \" time/bcast \"\n + Timer.format(perStats(totalStats.tupleWaitTime,\n totalStats.tupleWaitCount)));\n }\n if (POLL_FREQ != 0 && POLL_TIMING) {\n out.println(\"SATIN: POLL_TIME: total \"\n + Timer.format(totalStats.pollTime) + \" time/poll \"\n + Timer.format(perStats(totalStats.pollTime, totalStats.pollCount)));\n }\n if (IDLE_TIMING) {\n out.println(\"SATIN: IDLE_TIME: total \"\n + Timer.format(totalStats.idleTime) + \" time/idle \"\n + Timer.format(perStats(totalStats.idleTime, totalStats.idleCount)));\n }\n if (FAULT_TOLERANCE && GRT_TIMING) {\n out.println(\"SATIN: GRT_UPDATE_TIME: total \"\n + Timer.format(totalStats.tableUpdateTime)\n + \" time/update \"\n + Timer.format(perStats(totalStats.tableUpdateTime,\n (totalStats.tableResultUpdates\n + totalStats.tableLockUpdates))));\n out.println(\"SATIN: GRT_LOOKUP_TIME: total \"\n + Timer.format(totalStats.tableLookupTime)\n + \" time/lookup \"\n + Timer.format(perStats(totalStats.tableLookupTime,\n totalStats.tableLookups)));\n out.println(\"SATIN: GRT_HANDLE_UPDATE_TIME: total \"\n + Timer.format(totalStats.tableHandleUpdateTime)\n + \" time/handle \"\n + Timer.format(perStats(totalStats.tableHandleUpdateTime,\n totalStats.tableResultUpdates * (size - 1))));\n out.println(\"SATIN: GRT_HANDLE_LOOKUP_TIME: total \"\n + Timer.format(totalStats.tableHandleLookupTime)\n + \" time/handle \"\n + Timer.format(perStats(totalStats.tableHandleLookupTime,\n totalStats.tableRemoteLookups)));\n out.println(\"SATIN: GRT_SERIALIZATION_TIME: total \"\n + Timer.format(totalStats.tableSerializationTime));\n out.println(\"SATIN: GRT_DESERIALIZATION_TIME: total \"\n + Timer.format(totalStats.tableDeserializationTime));\n out.println(\"SATIN: GRT_CHECK_TIME: total \"\n + Timer.format(totalStats.tableCheckTime)\n + \" time/check \"\n + Timer.format(perStats(totalStats.tableCheckTime,\n totalStats.tableLookups)));\n }\n if (FAULT_TOLERANCE && CRASH_TIMING) {\n out.println(\"SATIN: CRASH_HANDLING_TIME: total \"\n + Timer.format(totalStats.crashHandlingTime));\n }\n if (FAULT_TOLERANCE && ADD_REPLICA_TIMING) {\n out.println(\"SATIN: ADD_REPLICA_TIME: total \"\n + Timer.format(totalStats.addReplicaTime));\n }\n\tif (SHARED_OBJECTS && SO_TIMING) {\n\t out.println(\"SATIN: BROADCAST_SO_INVOCATIONS: total \"\n\t\t\t+ Timer.format(totalStats.broadcastSOInvocationsTime)\n\t\t\t+ \" time/inv \"\n\t\t\t+ Timer.format(perStats(totalStats.broadcastSOInvocationsTime,\n\t\t\t\t\t\ttotalStats.soInvocations)));\n\t out.println(\"SATIN: HANDLE_SO_INVOCATIONS: total \"\n\t\t\t+ Timer.format(totalStats.handleSOInvocationsTime)\n\t\t\t+ \" time/inv \"\n\t\t\t+ Timer.format(perStats(totalStats.handleSOInvocationsTime,\n\t\t\t\t totalStats.soInvocations * (size - 1))));\n\t out.println(\"SATIN: SO_TRANSFERS: total \"\n\t\t\t+ Timer.format(totalStats.soTransferTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.soTransferTime,\n\t\t\t\t totalStats.soTransfers)));\n\t out.println(\"SATIN: HANDLE_SO_TRANSFERS: total \"\n\t\t\t+ Timer.format(totalStats.handleSOTransferTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.handleSOTransferTime,\n\t\t\t\t totalStats.soTransfers))); \n\t out.println(\"SATIN: SO_SERIALIZATION: total \"\n\t\t\t+ Timer.format(totalStats.soSerializationTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.soSerializationTime,\n\t\t\t\t totalStats.soTransfers)));\n\t out.println(\"SATIN: SO_DESERIALIZATION: total \"\n\t\t\t+ Timer.format(totalStats.soDeserializationTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.soDeserializationTime,\n\t\t\t\t totalStats.soTransfers))); \n\t}\n out.println(\"-------------------------------SATIN RUN TIME \"\n + \"BREAKDOWN------------------------\");\n out.println(\"SATIN: TOTAL_RUN_TIME: \"\n + Timer.format(totalTimer.totalTimeVal()));\n double lbTime = (totalStats.stealTime + totalStats.handleStealTime\n - totalStats.invocationRecordReadTime\n - totalStats.invocationRecordWriteTime) / size;\n if (lbTime < 0.0) {\n lbTime = 0.0;\n }\n double lbPerc = lbTime / totalTimer.totalTimeVal() * 100.0;\n double serTime = (totalStats.invocationRecordWriteTime\n + totalStats.invocationRecordReadTime\n + totalStats.returnRecordWriteTime\n + totalStats.returnRecordReadTime) / size;\n double serPerc = serTime / totalTimer.totalTimeVal() * 100.0;\n double abortTime = totalStats.abortTime / size;\n double abortPerc = abortTime / totalTimer.totalTimeVal() * 100.0;\n double tupleTime = totalStats.tupleTime / size;\n double tuplePerc = tupleTime / totalTimer.totalTimeVal() * 100.0;\n\tdouble handleTupleTime = totalStats.handleTupleTime / size;\n\tdouble handleTuplePerc = handleTupleTime / totalTimer.totalTimeVal() * 100.0;\n double tupleWaitTime = totalStats.tupleWaitTime / size;\n double tupleWaitPerc = tupleWaitTime / totalTimer.totalTimeVal()\n * 100.0;\n double pollTime = totalStats.pollTime / size;\n double pollPerc = pollTime / totalTimer.totalTimeVal() * 100.0;\n double tableUpdateTime = totalStats.tableUpdateTime / size;\n double tableUpdatePerc = tableUpdateTime / totalTimer.totalTimeVal()\n * 100.0;\n double tableLookupTime = totalStats.tableLookupTime / size;\n double tableLookupPerc = tableLookupTime / totalTimer.totalTimeVal()\n * 100.0;\n double tableHandleUpdateTime = totalStats.tableHandleUpdateTime / size;\n double tableHandleUpdatePerc = tableHandleUpdateTime\n / totalTimer.totalTimeVal() * 100.0;\n double tableHandleLookupTime = totalStats.tableHandleLookupTime / size;\n double tableHandleLookupPerc = tableHandleLookupTime\n / totalTimer.totalTimeVal() * 100.0;\n double tableSerializationTime = totalStats.tableSerializationTime\n / size;\n double tableSerializationPerc = tableSerializationTime\n / totalTimer.totalTimeVal() * 100;\n double tableDeserializationTime = totalStats.tableDeserializationTime\n / size;\n double tableDeserializationPerc = tableDeserializationTime\n / totalTimer.totalTimeVal() * 100;\n double crashHandlingTime = totalStats.crashHandlingTime / size;\n double crashHandlingPerc = crashHandlingTime\n / totalTimer.totalTimeVal() * 100.0;\n double addReplicaTime = totalStats.addReplicaTime / size;\n double addReplicaPerc = addReplicaTime / totalTimer.totalTimeVal()\n * 100.0;\n\tdouble broadcastSOInvocationsTime = \n\t totalStats.broadcastSOInvocationsTime / size;\n\tdouble broadcastSOInvocationsPerc = broadcastSOInvocationsTime\n\t / totalTimer.totalTimeVal() * 100;\n\tdouble handleSOInvocationsTime = totalStats.handleSOInvocationsTime \n\t / size;\n\tdouble handleSOInvocationsPerc = handleSOInvocationsTime\n\t / totalTimer.totalTimeVal() * 100;\n\tdouble soTransferTime = totalStats.soTransferTime / size;\n\tdouble soTransferPerc = soTransferTime / totalTimer.totalTimeVal() * 100;\n\tdouble handleSOTransferTime = totalStats.handleSOTransferTime / size;\n\tdouble handleSOTransferPerc = handleSOTransferTime \n\t / totalTimer.totalTimeVal() * 100; \n\tdouble soSerializationTime = totalStats.soSerializationTime / size;\n\tdouble soSerializationPerc = soSerializationTime\n\t / totalTimer.totalTimeVal() * 100;\n\tdouble soDeserializationTime = totalStats.soDeserializationTime / size;\n\tdouble soDeserializationPerc = soDeserializationTime\n\t / totalTimer.totalTimeVal() * 100;\n double totalOverhead = abortTime + tupleTime + handleTupleTime + tupleWaitTime\n\t + pollTime + tableUpdateTime + tableLookupTime\n\t + tableHandleUpdateTime + tableHandleLookupTime\n\t + handleSOInvocationsTime + broadcastSOInvocationsTime\n\t + soTransferTime + handleSOTransferTime \n\t + (totalStats.stealTime + totalStats.handleStealTime\n\t + totalStats.returnRecordReadTime\n\t + totalStats.returnRecordWriteTime) / size;\n double totalPerc = totalOverhead / totalTimer.totalTimeVal() * 100.0;\n double appTime = totalTimer.totalTimeVal() - totalOverhead;\n if (appTime < 0.0) {\n appTime = 0.0;\n }\n double appPerc = appTime / totalTimer.totalTimeVal() * 100.0;\n if (STEAL_TIMING) {\n out.println(\"SATIN: LOAD_BALANCING_TIME: avg. per machine \"\n + Timer.format(lbTime) + \" (\" + (lbPerc < 10 ? \" \" : \"\")\n + pf.format(lbPerc) + \" %)\");\n out.println(\"SATIN: (DE)SERIALIZATION_TIME: avg. per machine \"\n + Timer.format(serTime) + \" (\" + (serPerc < 10 ? \" \" : \"\")\n + pf.format(serPerc) + \" %)\");\n }\n if (ABORT_TIMING) {\n out.println(\"SATIN: ABORT_TIME: avg. per machine \"\n + Timer.format(abortTime) + \" (\"\n + (abortPerc < 10 ? \" \" : \"\") + pf.format(abortPerc)\n + \" %)\");\n }\n if (TUPLE_TIMING) {\n out.println(\"SATIN: TUPLE_SPACE_BCAST_TIME: avg. per machine \"\n + Timer.format(tupleTime) + \" (\"\n + (tuplePerc < 10 ? \" \" : \"\") + pf.format(tuplePerc)\n + \" %)\");\n out.println(\"SATIN: TUPLE_SPACE_HANDLE_TIME: avg. per machine \"\n + Timer.format(handleTupleTime) + \" (\"\n + (handleTuplePerc < 10 ? \" \" : \"\") + pf.format(handleTuplePerc)\n + \" %)\");\n out.println(\"SATIN: TUPLE_SPACE_WAIT_TIME: avg. per machine \"\n + Timer.format(tupleWaitTime) + \" (\"\n + (tupleWaitPerc < 10 ? \" \" : \"\")\n + pf.format(tupleWaitPerc) + \" %)\");\n }\n if (POLL_FREQ != 0 && POLL_TIMING) {\n out.println(\"SATIN: POLL_TIME: avg. per machine \"\n + Timer.format(pollTime) + \" (\"\n + (pollPerc < 10 ? \" \" : \"\") + pf.format(pollPerc) + \" %)\");\n }\n if (FAULT_TOLERANCE && GRT_TIMING) {\n out.println(\"SATIN: GRT_UPDATE_TIME: avg. per machine \"\n + Timer.format(tableUpdateTime) + \" (\"\n + pf.format(tableUpdatePerc) + \" %)\");\n out.println(\"SATIN: GRT_LOOKUP_TIME: avg. per machine \"\n + Timer.format(tableLookupTime) + \" (\"\n + pf.format(tableLookupPerc) + \" %)\");\n out.println(\"SATIN: GRT_HANDLE_UPDATE_TIME: avg. per machine \"\n + Timer.format(tableHandleUpdateTime) + \" (\"\n + pf.format(tableHandleUpdatePerc) + \" %)\");\n out.println(\"SATIN: GRT_HANDLE_LOOKUP_TIME: avg. per machine \"\n + Timer.format(tableHandleLookupTime) + \" (\"\n + pf.format(tableHandleLookupPerc) + \" %)\");\n out.println(\"SATIN: GRT_SERIALIZATION_TIME: avg. per machine \"\n + Timer.format(tableSerializationTime) + \" (\"\n + pf.format(tableSerializationPerc) + \" %)\");\n out.println(\"SATIN: GRT_DESERIALIZATION_TIME: avg. per machine \"\n + Timer.format(tableDeserializationTime) + \" (\"\n + pf.format(tableDeserializationPerc) + \" %)\");\n }\n if (FAULT_TOLERANCE && CRASH_TIMING) {\n out.println(\"SATIN: CRASH_HANDLING_TIME: avg. per machine \"\n + Timer.format(crashHandlingTime) + \" (\"\n + pf.format(crashHandlingPerc) + \" %)\");\n }\n if (FAULT_TOLERANCE && ADD_REPLICA_TIMING) {\n out.println(\"SATIN: ADD_REPLICA_TIME: avg. per machine \"\n + Timer.format(addReplicaTime) + \" (\"\n + pf.format(addReplicaPerc) + \" %)\");\n }\n\tif (SHARED_OBJECTS && SO_TIMING) {\n out.println(\"SATIN: BROADCAST_SO_INVOCATIONS: avg. per machine \"\n + Timer.format(broadcastSOInvocationsTime) + \" (\"\n + pf.format(broadcastSOInvocationsPerc) + \" %)\");\n out.println(\"SATIN: HANDLE_SO_INVOCATIONS: avg. per machine \"\n + Timer.format(handleSOInvocationsTime) + \" (\"\n + pf.format(handleSOInvocationsPerc) + \" %)\");\n out.println(\"SATIN: SO_TRANSFERS: avg. per machine \"\n + Timer.format(soTransferTime) + \" (\"\n + pf.format(soTransferPerc) + \" %)\");\n out.println(\"SATIN: HANDLE_SO_TRANSFERS: avg. per machine \"\n + Timer.format(handleSOTransferTime) + \" (\"\n + pf.format(handleSOTransferPerc) + \" %)\");\n out.println(\"SATIN: SO_SERIALIZATION: avg. per machine \"\n + Timer.format(soSerializationTime) + \" (\"\n + pf.format(soSerializationPerc) + \" %)\");\n out.println(\"SATIN: SO_DESERIALIZATION: avg. per machine \"\n + Timer.format(soDeserializationTime) + \" (\"\n + pf.format(soDeserializationPerc) + \" %)\");\n\t}\n out.println(\"\\nSATIN: TOTAL_PARALLEL_OVERHEAD: avg. per machine \"\n + Timer.format(totalOverhead) + \" (\"\n + (totalPerc < 10 ? \" \" : \"\") + pf.format(totalPerc) + \" %)\");\n out.println(\"SATIN: USEFUL_APP_TIME: avg. per machine \"\n + Timer.format(appTime) + \" (\" + (appPerc < 10 ? \" \" : \"\")\n + pf.format(appPerc) + \" %)\");\n }\n", "output": " protected void printStats() {\n int size;\n synchronized (this) {\n size = victims.size() + 1;\n }\n StatsMessage me = createStats();\n totalStats.add(me);\n java.text.NumberFormat nf = java.text.NumberFormat.getInstance();\n java.text.NumberFormat pf = java.text.NumberFormat.getInstance();\n pf.setMaximumFractionDigits(3);\n pf.setMinimumFractionDigits(3);\n pf.setGroupingUsed(false);\n out.println(\"-------------------------------SATIN STATISTICS------\"\n + \"--------------------------\");\n if (SPAWN_STATS) {\n out.println(\"SATIN: SPAWN: \" + nf.format(totalStats.spawns)\n + \" spawns, \" + nf.format(totalStats.jobsExecuted)\n + \" executed, \" + nf.format(totalStats.syncs) + \" syncs\");\n if (ABORTS) {\n out.println(\"SATIN: ABORT: \"\n + nf.format(totalStats.aborts) + \" aborts, \"\n + nf.format(totalStats.abortMessages) + \" abort msgs, \"\n + nf.format(totalStats.abortedJobs) + \" aborted jobs\");\n }\n }\n if (TUPLE_STATS) {\n out.println(\"SATIN: TUPLE_SPACE: \"\n + nf.format(totalStats.tupleMsgs) + \" bcasts, \"\n + nf.format(totalStats.tupleBytes) + \" bytes\");\n }\n if (POLL_FREQ != 0 && POLL_TIMING) {\n out.println(\"SATIN: POLL: poll count = \"\n + nf.format(totalStats.pollCount));\n }\n if (IDLE_TIMING) {\n out.println(\"SATIN: IDLE: idle count = \"\n + nf.format(totalStats.idleCount));\n }\n if (STEAL_STATS) {\n out.println(\"SATIN: STEAL: \"\n + nf.format(totalStats.stealAttempts)\n + \" attempts, \"\n + nf.format(totalStats.stealSuccess)\n + \" successes (\"\n + pf.format(perStats((double) totalStats.stealSuccess,\n totalStats.stealAttempts) * 100.0)\n + \" %)\");\n\t if(totalStats.asyncStealAttempts != 0) {\n\t\tout.println(\"SATIN: ASYNCSTEAL: \"\n\t\t\t + nf.format(totalStats.asyncStealAttempts)\n\t\t\t + \" attempts, \"\n\t\t\t + nf.format(totalStats.asyncStealSuccess)\n\t\t\t + \" successes (\"\n\t\t\t + pf.format(perStats((double) totalStats.asyncStealSuccess,\n\t\t\t\t\t totalStats.asyncStealAttempts) * 100.0)\n\t\t\t + \" %)\");\n\t }\n out.println(\"SATIN: MESSAGES: intra \"\n + nf.format(totalStats.intraClusterMessages) + \" msgs, \"\n + nf.format(totalStats.intraClusterBytes)\n + \" bytes; inter \"\n + nf.format(totalStats.interClusterMessages) + \" msgs, \"\n + nf.format(totalStats.interClusterBytes) + \" bytes\");\n }\n if (FAULT_TOLERANCE && GRT_STATS) {\n out.println(\"SATIN: GLOBAL_RESULT_TABLE: result updates \"\n + nf.format(totalStats.tableResultUpdates)\n + \",update messages \"\n + nf.format(totalStats.tableUpdateMessages)\n + \", lock updates \"\n + nf.format(totalStats.tableLockUpdates) + \",lookups \"\n + nf.format(totalStats.tableLookups) + \",successful \"\n + nf.format(totalStats.tableSuccessfulLookups) + \",remote \"\n + nf.format(totalStats.tableRemoteLookups));\n }\n if (FAULT_TOLERANCE && FT_STATS) {\n out.println(\"SATIN: FAULT_TOLERANCE: killed orphans \"\n + nf.format(totalStats.killedOrphans));\n out.println(\"SATIN: FAULT_TOLERANCE: restarted jobs \"\n + nf.format(totalStats.restartedJobs));\n }\n\tif (SHARED_OBJECTS && SO_STATS) {\n out.println(\"SATIN: SHARED_OBJECTS: nr invocations \"\n\t\t\t+ nf.format(totalStats.soInvocations)\n\t\t\t+ \", bytes \"\n\t\t\t+ nf.format(totalStats.soInvocationsBytes)\n\t\t\t+\", object transfers \" \n\t\t\t+ nf.format(totalStats.soTransfers)\n\t\t\t+ \", bytes \"\n\t\t\t+ nf.format(totalStats.soTransfersBytes));\n\t}\n out.println(\"-------------------------------SATIN TOTAL TIMES\"\n + \"-------------------------------\");\n if (STEAL_TIMING) {\n out.println(\"SATIN: STEAL_TIME: total \"\n + Timer.format(totalStats.stealTime)\n + \" time/req \"\n + Timer.format(perStats(totalStats.stealTime,\n totalStats.stealAttempts)));\n out.println(\"SATIN: HANDLE_STEAL_TIME: total \"\n + Timer.format(totalStats.handleStealTime)\n + \" time/handle \"\n + Timer.format(perStats(totalStats.handleStealTime,\n totalStats.stealAttempts)));\n out.println(\"SATIN: INV SERIALIZATION_TIME: total \"\n + Timer.format(totalStats.invocationRecordWriteTime)\n + \" time/write \"\n + Timer.format(perStats(totalStats.invocationRecordWriteTime,\n totalStats.stealSuccess)));\n out.println(\"SATIN: INV DESERIALIZATION_TIME: total \"\n + Timer.format(totalStats.invocationRecordReadTime)\n + \" time/read \"\n + Timer.format(perStats(totalStats.invocationRecordReadTime,\n totalStats.stealSuccess)));\n out.println(\"SATIN: RET SERIALIZATION_TIME: total \"\n + Timer.format(totalStats.returnRecordWriteTime)\n + \" time/write \"\n + Timer.format(perStats(totalStats.returnRecordWriteTime,\n totalStats.returnRecordWriteCount)));\n out.println(\"SATIN: RET DESERIALIZATION_TIME: total \"\n + Timer.format(totalStats.returnRecordReadTime)\n + \" time/read \"\n + Timer.format(perStats(totalStats.returnRecordReadTime,\n totalStats.returnRecordReadCount)));\n }\n if (ABORT_TIMING) {\n out.println(\"SATIN: ABORT_TIME: total \"\n + Timer.format(totalStats.abortTime) + \" time/abort \"\n + Timer.format(perStats(totalStats.abortTime, totalStats.aborts)));\n }\n if (TUPLE_TIMING) {\n out.println(\"SATIN: TUPLE_SPACE_BCAST_TIME: total \"\n + Timer.format(totalStats.tupleTime) + \" time/bcast \"\n + Timer.format(perStats(totalStats.tupleTime,\n totalStats.tupleMsgs)));\n out.println(\"SATIN: TUPLE_SPACE_WAIT_TIME: total \"\n + Timer.format(totalStats.tupleWaitTime)\n + \" time/bcast \"\n + Timer.format(perStats(totalStats.tupleWaitTime,\n totalStats.tupleWaitCount)));\n }\n if (POLL_FREQ != 0 && POLL_TIMING) {\n out.println(\"SATIN: POLL_TIME: total \"\n + Timer.format(totalStats.pollTime) + \" time/poll \"\n + Timer.format(perStats(totalStats.pollTime, totalStats.pollCount)));\n }\n if (IDLE_TIMING) {\n out.println(\"SATIN: IDLE_TIME: total \"\n + Timer.format(totalStats.idleTime) + \" time/idle \"\n + Timer.format(perStats(totalStats.idleTime, totalStats.idleCount)));\n }\n if (FAULT_TOLERANCE && GRT_TIMING) {\n out.println(\"SATIN: GRT_UPDATE_TIME: total \"\n + Timer.format(totalStats.tableUpdateTime)\n + \" time/update \"\n + Timer.format(perStats(totalStats.tableUpdateTime,\n (totalStats.tableResultUpdates\n + totalStats.tableLockUpdates))));\n out.println(\"SATIN: GRT_LOOKUP_TIME: total \"\n + Timer.format(totalStats.tableLookupTime)\n + \" time/lookup \"\n + Timer.format(perStats(totalStats.tableLookupTime,\n totalStats.tableLookups)));\n out.println(\"SATIN: GRT_HANDLE_UPDATE_TIME: total \"\n + Timer.format(totalStats.tableHandleUpdateTime)\n + \" time/handle \"\n + Timer.format(perStats(totalStats.tableHandleUpdateTime,\n totalStats.tableResultUpdates * (size - 1))));\n out.println(\"SATIN: GRT_HANDLE_LOOKUP_TIME: total \"\n + Timer.format(totalStats.tableHandleLookupTime)\n + \" time/handle \"\n + Timer.format(perStats(totalStats.tableHandleLookupTime,\n totalStats.tableRemoteLookups)));\n out.println(\"SATIN: GRT_SERIALIZATION_TIME: total \"\n + Timer.format(totalStats.tableSerializationTime));\n out.println(\"SATIN: GRT_DESERIALIZATION_TIME: total \"\n + Timer.format(totalStats.tableDeserializationTime));\n out.println(\"SATIN: GRT_CHECK_TIME: total \"\n + Timer.format(totalStats.tableCheckTime)\n + \" time/check \"\n + Timer.format(perStats(totalStats.tableCheckTime,\n totalStats.tableLookups)));\n }\n if (FAULT_TOLERANCE && CRASH_TIMING) {\n out.println(\"SATIN: CRASH_HANDLING_TIME: total \"\n + Timer.format(totalStats.crashHandlingTime));\n }\n if (FAULT_TOLERANCE && ADD_REPLICA_TIMING) {\n out.println(\"SATIN: ADD_REPLICA_TIME: total \"\n + Timer.format(totalStats.addReplicaTime));\n }\n\tif (SHARED_OBJECTS && SO_TIMING) {\n\t out.println(\"SATIN: BROADCAST_SO_INVOCATIONS: total \"\n\t\t\t+ Timer.format(totalStats.broadcastSOInvocationsTime)\n\t\t\t+ \" time/inv \"\n\t\t\t+ Timer.format(perStats(totalStats.broadcastSOInvocationsTime,\n\t\t\t\t\t\ttotalStats.soInvocations)));\n\t out.println(\"SATIN: HANDLE_SO_INVOCATIONS: total \"\n\t\t\t+ Timer.format(totalStats.handleSOInvocationsTime)\n\t\t\t+ \" time/inv \"\n\t\t\t+ Timer.format(perStats(totalStats.handleSOInvocationsTime,\n\t\t\t\t totalStats.soInvocations * (size - 1))));\n\t out.println(\"SATIN: SO_TRANSFERS: total \"\n\t\t\t+ Timer.format(totalStats.soTransferTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.soTransferTime,\n\t\t\t\t totalStats.soTransfers)));\n\t out.println(\"SATIN: HANDLE_SO_TRANSFERS: total \"\n\t\t\t+ Timer.format(totalStats.handleSOTransferTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.handleSOTransferTime,\n\t\t\t\t totalStats.soTransfers))); \n\t out.println(\"SATIN: SO_SERIALIZATION: total \"\n\t\t\t+ Timer.format(totalStats.soSerializationTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.soSerializationTime,\n\t\t\t\t totalStats.soTransfers)));\n\t out.println(\"SATIN: SO_DESERIALIZATION: total \"\n\t\t\t+ Timer.format(totalStats.soDeserializationTime)\n\t\t\t+ \" time/transf \"\n\t\t\t+ Timer.format(perStats(totalStats.soDeserializationTime,\n\t\t\t\t totalStats.soTransfers))); \n\t}\n out.println(\"-------------------------------SATIN RUN TIME \"\n + \"BREAKDOWN------------------------\");\n out.println(\"SATIN: TOTAL_RUN_TIME: \"\n + Timer.format(totalTimer.totalTimeVal()));\n double lbTime = (totalStats.stealTime + totalStats.handleStealTime\n - totalStats.invocationRecordReadTime\n - totalStats.invocationRecordWriteTime) / size;\n if (lbTime < 0.0) {\n lbTime = 0.0;\n }\n double lbPerc = lbTime / totalTimer.totalTimeVal() * 100.0;\n double serTime = (totalStats.invocationRecordWriteTime\n + totalStats.invocationRecordReadTime\n + totalStats.returnRecordWriteTime\n + totalStats.returnRecordReadTime) / size;\n double serPerc = serTime / totalTimer.totalTimeVal() * 100.0;\n double abortTime = totalStats.abortTime / size;\n double abortPerc = abortTime / totalTimer.totalTimeVal() * 100.0;\n double tupleTime = totalStats.tupleTime / size;\n double tuplePerc = tupleTime / totalTimer.totalTimeVal() * 100.0;\n\tdouble handleTupleTime = totalStats.handleTupleTime / size;\n\tdouble handleTuplePerc = handleTupleTime / totalTimer.totalTimeVal() * 100.0;\n double tupleWaitTime = totalStats.tupleWaitTime / size;\n double tupleWaitPerc = tupleWaitTime / totalTimer.totalTimeVal()\n * 100.0;\n double pollTime = totalStats.pollTime / size;\n double pollPerc = pollTime / totalTimer.totalTimeVal() * 100.0;\n double tableUpdateTime = totalStats.tableUpdateTime / size;\n double tableUpdatePerc = tableUpdateTime / totalTimer.totalTimeVal()\n * 100.0;\n double tableLookupTime = totalStats.tableLookupTime / size;\n double tableLookupPerc = tableLookupTime / totalTimer.totalTimeVal()\n * 100.0;\n double tableHandleUpdateTime = totalStats.tableHandleUpdateTime / size;\n double tableHandleUpdatePerc = tableHandleUpdateTime\n / totalTimer.totalTimeVal() * 100.0;\n double tableHandleLookupTime = totalStats.tableHandleLookupTime / size;\n double tableHandleLookupPerc = tableHandleLookupTime\n / totalTimer.totalTimeVal() * 100.0;\n double tableSerializationTime = totalStats.tableSerializationTime\n / size;\n double tableSerializationPerc = tableSerializationTime\n / totalTimer.totalTimeVal() * 100;\n double tableDeserializationTime = totalStats.tableDeserializationTime\n / size;\n double tableDeserializationPerc = tableDeserializationTime\n / totalTimer.totalTimeVal() * 100;\n double crashHandlingTime = totalStats.crashHandlingTime / size;\n double crashHandlingPerc = crashHandlingTime\n / totalTimer.totalTimeVal() * 100.0;\n double addReplicaTime = totalStats.addReplicaTime / size;\n double addReplicaPerc = addReplicaTime / totalTimer.totalTimeVal()\n * 100.0;\n\tdouble broadcastSOInvocationsTime = \n\t totalStats.broadcastSOInvocationsTime / size;\n\tdouble broadcastSOInvocationsPerc = broadcastSOInvocationsTime\n\t / totalTimer.totalTimeVal() * 100;\n\tdouble handleSOInvocationsTime = totalStats.handleSOInvocationsTime \n\t / size;\n\tdouble handleSOInvocationsPerc = handleSOInvocationsTime\n\t / totalTimer.totalTimeVal() * 100;\n\tdouble soTransferTime = totalStats.soTransferTime / size;\n\tdouble soTransferPerc = soTransferTime / totalTimer.totalTimeVal() * 100;\n\tdouble handleSOTransferTime = totalStats.handleSOTransferTime / size;\n\tdouble handleSOTransferPerc = handleSOTransferTime \n\t / totalTimer.totalTimeVal() * 100; \n\tdouble soSerializationTime = totalStats.soSerializationTime / size;\n\tdouble soSerializationPerc = soSerializationTime\n\t / totalTimer.totalTimeVal() * 100;\n\tdouble soDeserializationTime = totalStats.soDeserializationTime / size;\n\tdouble soDeserializationPerc = soDeserializationTime\n\t / totalTimer.totalTimeVal() * 100;\n double totalOverhead = abortTime + tupleTime + handleTupleTime + tupleWaitTime\n\t + pollTime + tableUpdateTime + tableLookupTime\n\t + tableHandleUpdateTime + tableHandleLookupTime\n\t + handleSOInvocationsTime + broadcastSOInvocationsTime\n\t + soTransferTime + handleSOTransferTime \n\t + (totalStats.stealTime + totalStats.handleStealTime\n\t + totalStats.returnRecordReadTime\n\t + totalStats.returnRecordWriteTime) / size;\n double totalPerc = totalOverhead / totalTimer.totalTimeVal() * 100.0;\n double appTime = totalTimer.totalTimeVal() - totalOverhead;\n if (appTime < 0.0) {\n appTime = 0.0;\n }\n double appPerc = appTime / totalTimer.totalTimeVal() * 100.0;\n if (STEAL_TIMING) {\n out.println(\"SATIN: LOAD_BALANCING_TIME: avg. per machine \"\n + Timer.format(lbTime) + \" (\" + (lbPerc < 10 ? \" \" : \"\")\n + pf.format(lbPerc) + \" %)\");\n out.println(\"SATIN: (DE)SERIALIZATION_TIME: avg. per machine \"\n + Timer.format(serTime) + \" (\" + (serPerc < 10 ? \" \" : \"\")\n + pf.format(serPerc) + \" %)\");\n }\n if (ABORT_TIMING) {\n out.println(\"SATIN: ABORT_TIME: avg. per machine \"\n + Timer.format(abortTime) + \" (\"\n + (abortPerc < 10 ? \" \" : \"\") + pf.format(abortPerc)\n + \" %)\");\n }\n if (TUPLE_TIMING) {\n out.println(\"SATIN: TUPLE_SPACE_BCAST_TIME: avg. per machine \"\n + Timer.format(tupleTime) + \" (\"\n + (tuplePerc < 10 ? \" \" : \"\") + pf.format(tuplePerc)\n + \" %)\");\n out.println(\"SATIN: TUPLE_SPACE_HANDLE_TIME: avg. per machine \"\n + Timer.format(handleTupleTime) + \" (\"\n + (handleTuplePerc < 10 ? \" \" : \"\") + pf.format(handleTuplePerc)\n + \" %)\");\n out.println(\"SATIN: TUPLE_SPACE_WAIT_TIME: avg. per machine \"\n + Timer.format(tupleWaitTime) + \" (\"\n + (tupleWaitPerc < 10 ? \" \" : \"\")\n + pf.format(tupleWaitPerc) + \" %)\");\n }\n if (POLL_FREQ != 0 && POLL_TIMING) {\n out.println(\"SATIN: POLL_TIME: avg. per machine \"\n + Timer.format(pollTime) + \" (\"\n + (pollPerc < 10 ? \" \" : \"\") + pf.format(pollPerc) + \" %)\");\n }\n if (FAULT_TOLERANCE && GRT_TIMING) {\n out.println(\"SATIN: GRT_UPDATE_TIME: avg. per machine \"\n + Timer.format(tableUpdateTime) + \" (\"\n + pf.format(tableUpdatePerc) + \" %)\");\n out.println(\"SATIN: GRT_LOOKUP_TIME: avg. per machine \"\n + Timer.format(tableLookupTime) + \" (\"\n + pf.format(tableLookupPerc) + \" %)\");\n out.println(\"SATIN: GRT_HANDLE_UPDATE_TIME: avg. per machine \"\n + Timer.format(tableHandleUpdateTime) + \" (\"\n + pf.format(tableHandleUpdatePerc) + \" %)\");\n out.println(\"SATIN: GRT_HANDLE_LOOKUP_TIME: avg. per machine \"\n + Timer.format(tableHandleLookupTime) + \" (\"\n + pf.format(tableHandleLookupPerc) + \" %)\");\n out.println(\"SATIN: GRT_SERIALIZATION_TIME: avg. per machine \"\n + Timer.format(tableSerializationTime) + \" (\"\n + pf.format(tableSerializationPerc) + \" %)\");\n out.println(\"SATIN: GRT_DESERIALIZATION_TIME: avg. per machine \"\n + Timer.format(tableDeserializationTime) + \" (\"\n + pf.format(tableDeserializationPerc) + \" %)\");\n }\n if (FAULT_TOLERANCE && CRASH_TIMING) {\n out.println(\"SATIN: CRASH_HANDLING_TIME: avg. per machine \"\n + Timer.format(crashHandlingTime) + \" (\"\n + pf.format(crashHandlingPerc) + \" %)\");\n }\n if (FAULT_TOLERANCE && ADD_REPLICA_TIMING) {\n out.println(\"SATIN: ADD_REPLICA_TIME: avg. per machine \"\n + Timer.format(addReplicaTime) + \" (\"\n + pf.format(addReplicaPerc) + \" %)\");\n }\n\tif (SHARED_OBJECTS && SO_TIMING) {\n out.println(\"SATIN: BROADCAST_SO_INVOCATIONS: avg. per machine \"\n + Timer.format(broadcastSOInvocationsTime) + \" (\"\n + pf.format(broadcastSOInvocationsPerc) + \" %)\");\n out.println(\"SATIN: HANDLE_SO_INVOCATIONS: avg. per machine \"\n + Timer.format(handleSOInvocationsTime) + \" (\"\n + pf.format(handleSOInvocationsPerc) + \" %)\");\n out.println(\"SATIN: SO_TRANSFERS: avg. per machine \"\n + Timer.format(soTransferTime) + \" (\"\n + pf.format(soTransferPerc) + \" %)\");\n out.println(\"SATIN: HANDLE_SO_TRANSFERS: avg. per machine \"\n + Timer.format(handleSOTransferTime) + \" (\"\n + pf.format(handleSOTransferPerc) + \" %)\");\n out.println(\"SATIN: SO_SERIALIZATION: avg. per machine \"\n + Timer.format(soSerializationTime) + \" (\"\n + pf.format(soSerializationPerc) + \" %)\");\n out.println(\"SATIN: SO_DESERIALIZATION: avg. per machine \"\n + Timer.format(soDeserializationTime) + \" (\"\n + pf.format(soDeserializationPerc) + \" %)\");\n\t}\n out.println(\"\\nSATIN: TOTAL_PARALLEL_OVERHEAD: avg. per machine \"\n + Timer.format(totalOverhead) + \" (\"\n + (totalPerc < 10 ? \" \" : \"\") + pf.format(totalPerc) + \" %)\");\n out.println(\"SATIN: USEFUL_APP_TIME: avg. per machine \"\n + Timer.format(appTime) + \" (\" + (appPerc < 10 ? \" \" : \"\")\n + pf.format(appPerc) + \" %)\");\n }\n"} {"input": "\tpublic void run() {\n\t\tfinal TInt21TripleObjectHashMap worldRegistry = this.worldRegistry.get(world);\n\t\tif (worldRegistry == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (pastTime == 0) {\n\t\t\tpastTime = System.currentTimeMillis() / 1000;\n\t\t}\n\t\tfinal long localTime = System.currentTimeMillis() / 1000;\n\t\tfinal long delta = localTime - pastTime;\n\t\tpastTime = localTime;\n\t\tworldRegistry.getInternalMap().forEachEntry(new TLongObjectProcedure() {\n\t\t\t@Override\n\t\t\tpublic boolean execute(long l, Object o) {\n\t\t\t\tfinal Sprout sprout = (Sprout) o;\n\t\t\t\tif (sprout.isFullyGrown()) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tfinal Stage current = sprout.getCurrentStage();\n\t\t\t\tif (current == null) {\n\t\t\t\t\t((SimpleSprout) sprout).grow((int) delta);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (RANDOM.nextInt(current.getGrowthChance() - 1 + 1) + 1 != current.getGrowthChance()) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t((SimpleSprout) sprout).grow((int) delta);\n\t\t\t\tfinal int x = Int21TripleHashed.key1(l);\n\t\t\t\tfinal int y = Int21TripleHashed.key2(l);\n\t\t\t\tfinal int z = Int21TripleHashed.key3(l);\n\t\t\t\tfinal Block block = Bukkit.getWorld(world).getBlockAt(x, y, z);\n\t\t\t\tif (!block.getChunk().isLoaded()) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tfinal CustomBlock customBlock = MaterialData.getCustomBlock(current.getName());\n\t\t\t\tif (customBlock == null) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t((SpoutBlock) block).setCustomBlock(customBlock);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t}\n", "output": "\tpublic void run() {\n\t\tfinal TInt21TripleObjectHashMap worldRegistry = this.worldRegistry.get(world);\n\t\tif (worldRegistry == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (pastTime == 0) {\n\t\t\tpastTime = System.currentTimeMillis() / 1000;\n\t\t}\n\t\tfinal long localTime = System.currentTimeMillis() / 1000;\n\t\tfinal long delta = localTime - pastTime;\n\t\tpastTime = localTime;\n\t\tworldRegistry.getInternalMap().forEachEntry(new TLongObjectProcedure() {\n\t\t\t@Override\n\t\t\tpublic boolean execute(long l, Object o) {\n\t\t\t\tfinal Sprout sprout = (Sprout) o;\n\t\t\t\tfinal Stage current = sprout.getCurrentStage();\n\t\t\t\tif (current == null) {\n\t\t\t\t\t((SimpleSprout) sprout).grow((int) delta);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (RANDOM.nextInt(current.getGrowthChance() - 1 + 1) + 1 != current.getGrowthChance()) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t((SimpleSprout) sprout).grow((int) delta);\n\t\t\t\tfinal int x = Int21TripleHashed.key1(l);\n\t\t\t\tfinal int y = Int21TripleHashed.key2(l);\n\t\t\t\tfinal int z = Int21TripleHashed.key3(l);\n\t\t\t\tfinal Block block = Bukkit.getWorld(world).getBlockAt(x, y, z);\n\t\t\t\tif (!block.getChunk().isLoaded()) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tfinal CustomBlock customBlock = MaterialData.getCustomBlock(current.getName());\n\t\t\t\tif (customBlock == null) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t((SpoutBlock) block).setCustomBlock(customBlock);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t}\n"} {"input": " public void setHeaders(Map headers) {\n String h = headers.get(\"host\");\n if (h != null) {\n int idx = h.indexOf(':');\n if (idx != -1) {\n this.serverName = h.substring(0, idx);\n serverPort = Integer.valueOf(h.substring(idx + 1));\n } else {\n this.serverName = h;\n }\n }\n String ct = headers.get(CONTENT_TYPE);\n if (ct != null) {\n int idx = ct.indexOf(\";\");\n if (idx != -1) {\n int cidx = ct.indexOf(CHARSET, idx);\n if (cidx != -1) {\n contentType = ct.substring(0, idx);\n charset = ct.substring(cidx + CHARSET.length());\n } else {\n contentType = ct;\n }\n } else {\n contentType = ct;\n }\n }\n String con = headers.get(CONNECTION);\n if (con != null) {\n con = con.toLowerCase();\n }\n isKeepAlive = (version == HTTP_1_1 && !\"close\".equals(con)) || \"keep-alive\".equals(con);\n isWebSocket = \"websocket\".equalsIgnoreCase(headers.get(\"upgrade\"));\n this.headers = headers;\n }\n", "output": " public void setHeaders(Map headers) {\n String h = headers.get(\"host\");\n if (h != null) {\n int idx = h.lastIndexOf(':');\n if (idx != -1) {\n this.serverName = h.substring(0, idx);\n serverPort = Integer.valueOf(h.substring(idx + 1));\n } else {\n this.serverName = h;\n }\n }\n String ct = headers.get(CONTENT_TYPE);\n if (ct != null) {\n int idx = ct.indexOf(\";\");\n if (idx != -1) {\n int cidx = ct.indexOf(CHARSET, idx);\n if (cidx != -1) {\n contentType = ct.substring(0, idx);\n charset = ct.substring(cidx + CHARSET.length());\n } else {\n contentType = ct;\n }\n } else {\n contentType = ct;\n }\n }\n String con = headers.get(CONNECTION);\n if (con != null) {\n con = con.toLowerCase();\n }\n isKeepAlive = (version == HTTP_1_1 && !\"close\".equals(con)) || \"keep-alive\".equals(con);\n isWebSocket = \"websocket\".equalsIgnoreCase(headers.get(\"upgrade\"));\n this.headers = headers;\n }\n"} {"input": " public List parseMovies(String areaId) {\n final MovieInfo movieInfo = new MovieInfo();\n final MovieTrailer movieTrailer = new MovieTrailer();\n final List movies = new ArrayList();\n RootElement root = new RootElement(EVENTS);\n Element event = root.getChild(EVENT);\n Element images = event.getChild(IMAGES);\n Element videos = event.getChild(VIDEOS);\n Element eventVideo = videos.getChild(EVENT_VIDEO);\n event.setEndElementListener(new EndElementListener() {\n @Override\n public void end() {\n movies.add(movieInfo.copy());\n }\n });\n eventVideo.setEndElementListener(new EndElementListener() {\n @Override\n public void end() {\n movieInfo.addMovieTrailer(movieTrailer.copy());\n }\n });\n event.getChild(ID).setEndTextElementListener(new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventId(body);\n }\n });\n event.getChild(TITLE).setEndTextElementListener(new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setTitle(body);\n }\n });\n event.getChild(ORIGINAL_TITLE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setOriginalTitle(body);\n }\n });\n event.getChild(PRODUCTION_YEAR).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setProductionYear(body);\n }\n });\n event.getChild(LENGTH_IN_MINUTES).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setLenghtInMinutes(body);\n }\n });\n event.getChild(DATE_LOCAL_RELEASE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setDtLocalRelease(body);\n }\n });\n event.getChild(RATING_LABEL).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setRatingLabel(body);\n }\n });\n event.getChild(LOGAL_DISTRIBUTOR_NAME).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setLocalDistributorName(body);\n }\n });\n event.getChild(GLOBAL_DISTRIBUTOR_NAME).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setGlobalDistributorName(body);\n }\n });\n event.getChild(GENRES).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setGenres(body);\n }\n });\n event.getChild(SYNOPSIS).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setSynopsis(body);\n }\n });\n images.getChild(EVENT_SMALL_IMAGE_PORTRAIT).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventSmallImagePortrait(body);\n }\n });\n images.getChild(EVENT_LARGE_IMAGE_PORTRAIT).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventLargeImagePortrait(body);\n }\n });\n images.getChild(EVENT_SMALL_IMAGE_LANDSCAPE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventSmallImageLandscape(body);\n }\n });\n images.getChild(EVENT_LARGE_IMAGE_LANDSCAPE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventLargeImageLandscape(body);\n }\n });\n eventVideo.getChild(TITLE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setTitle(body);\n }\n });\n eventVideo.getChild(LOCATION).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setLocation(body);\n }\n });\n eventVideo.getChild(THUMBNAIL_LOCATION).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setThumbnailLocation(body);\n }\n });\n eventVideo.getChild(MEDIA_RESOURCE_FORMAT).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setMediaResourceFormat(body);\n }\n });\n eventVideo.getChild(MEDIA_RESOURCE_SUB_TYPE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setMediaResourceSubType(body);\n }\n });\n try {\n StringBuffer urlStringBuffer = new StringBuffer(BASE_FINN_FINO_URL);\n urlStringBuffer.append(EVENTS);\n if (areaId != null) {\n urlStringBuffer.append(\"?\");\n urlStringBuffer.append(PARAM_AREA);\n urlStringBuffer.append(\"=\");\n urlStringBuffer.append(areaId); \n }\n URL url = new URL(urlStringBuffer.toString());\n Xml.parse(this.getInputStream(url), Xml.Encoding.UTF_8, root.getContentHandler());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n return movies;\n }\n", "output": " public List parseMovies(String areaId) {\n final MovieInfo movieInfo = new MovieInfo();\n final MovieTrailer movieTrailer = new MovieTrailer();\n final List movies = new ArrayList();\n RootElement root = new RootElement(EVENTS);\n Element event = root.getChild(EVENT);\n Element images = event.getChild(IMAGES);\n Element videos = event.getChild(VIDEOS);\n Element eventVideo = videos.getChild(EVENT_VIDEO);\n event.setEndElementListener(new EndElementListener() {\n @Override\n public void end() {\n movies.add(movieInfo.copy());\n }\n });\n eventVideo.setEndElementListener(new EndElementListener() {\n @Override\n public void end() {\n movieInfo.addMovieTrailer(movieTrailer.copy());\n }\n });\n event.getChild(ID).setEndTextElementListener(new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventId(body);\n }\n });\n event.getChild(TITLE).setEndTextElementListener(new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setTitle(body);\n }\n });\n event.getChild(ORIGINAL_TITLE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setOriginalTitle(body);\n }\n });\n event.getChild(PRODUCTION_YEAR).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setProductionYear(body);\n }\n });\n event.getChild(LENGTH_IN_MINUTES).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setLenghtInMinutes(body);\n }\n });\n event.getChild(DATE_LOCAL_RELEASE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setDtLocalRelease(body);\n }\n });\n event.getChild(RATING_LABEL).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setRatingLabel(body);\n }\n });\n event.getChild(LOGAL_DISTRIBUTOR_NAME).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setLocalDistributorName(body);\n }\n });\n event.getChild(GLOBAL_DISTRIBUTOR_NAME).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setGlobalDistributorName(body);\n }\n });\n event.getChild(GENRES).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setGenres(body);\n }\n });\n event.getChild(SYNOPSIS).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setSynopsis(body);\n }\n });\n images.getChild(EVENT_SMALL_IMAGE_PORTRAIT).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventSmallImagePortrait(body);\n }\n });\n images.getChild(EVENT_LARGE_IMAGE_PORTRAIT).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventLargeImagePortrait(body);\n }\n });\n images.getChild(EVENT_SMALL_IMAGE_LANDSCAPE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventSmallImageLandscape(body);\n }\n });\n images.getChild(EVENT_LARGE_IMAGE_LANDSCAPE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieInfo.setEventLargeImageLandscape(body);\n }\n });\n eventVideo.getChild(TITLE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setTitle(body);\n }\n });\n eventVideo.getChild(LOCATION).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setLocation(body);\n }\n });\n eventVideo.getChild(THUMBNAIL_LOCATION).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setThumbnailLocation(body);\n }\n });\n eventVideo.getChild(MEDIA_RESOURCE_FORMAT).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setMediaResourceFormat(body);\n }\n });\n eventVideo.getChild(MEDIA_RESOURCE_SUB_TYPE).setEndTextElementListener(\n new EndTextElementListener() {\n @Override\n public void end(String body) {\n movieTrailer.setMediaResourceSubType(body);\n }\n });\n try {\n StringBuffer urlStringBuffer = new StringBuffer(BASE_FINN_FINO_URL);\n urlStringBuffer.append(EVENTS);\n if (areaId != null) {\n urlStringBuffer.append(\"?\");\n urlStringBuffer.append(PARAM_AREA);\n urlStringBuffer.append(\"=\");\n urlStringBuffer.append(areaId); \n }\n URL url = new URL(urlStringBuffer.toString());\n Xml.parse(this.getInputStream(url), Xml.Encoding.UTF_8, root.getContentHandler());\n } catch (Exception e) {\n throw new RuntimeException(e);\n }\n return movies;\n }\n"} {"input": "\tpublic Result decode(IoBuffer in, Charset charset) {\n\t\tlog.trace(\"IoBuffer remaining bytes: {}, current position: {}\",\n\t\t\t\tin.remaining(), in.position());\n\t\tif (in.remaining() >= ProtocolLengths.HEAD) {\n\t\t\tboolean sessionKeyDecoded = false;\n\t\t\tlong cmdBodySize = 0;\n\t\t\tint start = in.position();\n\t\t\tlog.trace(\"Parsing message header ({} bytes)..\",\n\t\t\t\t\tProtocolLengths.HEAD);\n\t\t\tPackageHeadCodec headCodec = new PackageHeadCodec();\n\t\t\tHeadMessage header = headCodec.decode(in);\t\n\t\t\tlog.trace(\"- message header: {}\", header);\n\t\t\tlog.trace(\"- IoBuffer remaining (for body): {}\", in.remaining());\n\t\t\tcmdBodySize = header.getMessageSize() - ProtocolLengths.HEAD; \n\t\t\tif ((header.getFlags() & HeadMessage.FLAG_SESSION_ID) != 0) {\n\t\t\t\tlog.debug(\"flag FLAG_SESSION_ID is set in header\");\n\t\t\t\tlog.debug(\"in.remaining() = {}\", in.remaining());\n\t\t\t\tif (in.remaining() >= 4) {\n\t\t\t\t\tshort sessionKeyVersion = in.getUnsigned();\n\t\t\t\t\tin.getUnsigned();\n\t\t\t\t\tint sessionKeyLength = in.getUnsignedShort();\n\t\t\t\t\tlog.debug(\"sessionKeyVersion={}\", sessionKeyVersion);\n\t\t\t\t\tlog.debug(\"sessionKeyLength={}\", sessionKeyLength);\n\t\t\t\t\tcmdBodySize -= (sessionKeyLength + 4);\n\t\t\t\t\tif (sessionKeyVersion == 0 && sessionKeyLength == 0) {\n\t\t\t\t\t\tlog.debug(\"version 0 session key detected, client can process session ID!\");\n\t\t\t\t\t} else if (in.remaining() < sessionKeyLength) {\n\t\t\t\t\t\tlong owe = header.getMessageSize()\n\t\t\t\t\t\t\t\t- ProtocolLengths.HEAD - 4 - in.remaining();\n\t\t\t\t\t\tin.position(start);\t\n\t\t\t\t\t\treturn new Result(true, owe, header, null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlog.debug(\n\t\t\t\t\t\t\t\t\t\"decoding session key (version: {}, key length: {})\",\n\t\t\t\t\t\t\t\t\tsessionKeyVersion, sessionKeyLength);\n\t\t\t\t\t\t\tin.position(start + 3);\n\t\t\t\t\t\t\tISessionKey sessionKey = sessionKeyCodec.decode(in);\n\t\t\t\t\t\t\theader.setSessionKey(sessionKey);\n\t\t\t\t\t\t\tlog.debug(\"session key decoded: {}\", sessionKey);\n\t\t\t\t\t\t\tsessionKeyDecoded = true;\n\t\t\t\t\t\t} catch (CodecException e) {\n\t\t\t\t\t\t\tlog.warn(\n\t\t\t\t\t\t\t\t\t\"error when decoding session key (version: {}, key length: {})\",\n\t\t\t\t\t\t\t\t\tnew Object[] { sessionKeyVersion,\n\t\t\t\t\t\t\t\t\t\t\tsessionKeyLength }, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlong owe = header.getMessageSize()\n\t\t\t\t\t\t\t- ProtocolLengths.HEAD - in.remaining();\n\t\t\t\t\tin.position(start);\t\n\t\t\t\t\treturn new Result(true, owe, header, null);\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog.debug(\"before parsing body: cmdBodySize={}, in.remaining={}\", cmdBodySize, in.remaining());\n\t\t\tif (in.remaining() < cmdBodySize) {\n\t\t\t\tlong owe = cmdBodySize - in.remaining();\n\t\t\t\tlog.trace(\"More bytes are required to parse the complete message (still need {} bytes)\",\n\t\t\t\t\t\towe);\n\t\t\t\tin.position(start);\t\n\t\t\t\treturn new Result(true, owe, header, null);\n\t\t\t}\n\t\t\tint calculatedChecksum = 0;\n\t\t\t{\n\t\t\t\tin.position(start);\n\t\t\t\tbyte[] byteTmp = new byte[(int)header.getMessageSize()];\t\n\t\t\t\tin.get(byteTmp);\n\t\t\t\tTools.putUnsignedShort(byteTmp, 0, 10);\n\t\t\t\tcalculatedChecksum = Tools.checkSum(byteTmp, byteTmp.length);\n\t\t\t}\n\t\t\tif (calculatedChecksum != header.getChecksum()) {\n\t\t\t\tErrorBodyMessage bodyMessage = new ErrorBodyMessage();\n\t\t\t\tbodyMessage.setErrorCode(CmdConstant.ERROR_CHECKSUM_CODE);\n\t\t\t\tMessage message = new Message(header, bodyMessage);\n\t\t\t\tlog.trace(\n\t\t\t\t\t\t\"Received message has invalid checksum (calc: 0x{}, actual: 0x{})\",\n\t\t\t\t\t\tInteger.toHexString(calculatedChecksum),\n\t\t\t\t\t\tInteger.toHexString(header.getChecksum()));\n\t\t\t\treturn new Result(false, 0, header, message);\n\t\t\t}\n\t\t\tin.position(start + ProtocolLengths.HEAD);\n\t\t\tICommand bodyMessage = null;\n\t\t\ttry {\n\t\t\t\tbodyMessage = this.decodeMessageBody(in, charset, header);\n\t\t\t\tMessage message = new Message(header, bodyMessage);\n\t\t\t\treturn new Result(false, 0, header, message);\n\t\t\t} catch (Throwable e) {\n\t\t\t\tlog.trace(\"Unexpected error when decoding message\", e);\n\t\t\t\tErrorBodyMessage errorBodyMessage = new ErrorBodyMessage();\n\t\t\t\terrorBodyMessage.setErrorCode(CmdConstant.ERROR_MESSAGE_CODE);\n\t\t\t\tMessage message = new Message(header, errorBodyMessage);\n\t\t\t\treturn new Result(false, 0, header, message);\n\t\t\t}\n\t\t} else {\n\t\t\tlong owe = ProtocolLengths.HEAD - in.remaining();\n\t\t\tlog.trace(\"More bytes are required to parse the header message (still need {} bytes)\",\n\t\t\t\t\towe);\n\t\t\treturn new Result(true, owe, null, null);\n\t\t}\n\t}\n", "output": "\tpublic Result decode(IoBuffer in, Charset charset) {\n\t\tlog.trace(\"IoBuffer remaining bytes: {}, current position: {}\",\n\t\t\t\tin.remaining(), in.position());\n\t\tif (in.remaining() >= ProtocolLengths.HEAD) {\n\t\t\tboolean sessionKeyDecoded = false;\n\t\t\tlong cmdBodySize = 0;\n\t\t\tint start = in.position();\n\t\t\tlog.trace(\"Parsing message header ({} bytes)..\",\n\t\t\t\t\tProtocolLengths.HEAD);\n\t\t\tPackageHeadCodec headCodec = new PackageHeadCodec();\n\t\t\tHeadMessage header = headCodec.decode(in);\t\n\t\t\tlog.trace(\"- message header: {}\", header);\n\t\t\tlog.trace(\"- IoBuffer remaining (for body): {}\", in.remaining());\n\t\t\tcmdBodySize = header.getMessageSize() - ProtocolLengths.HEAD; \n\t\t\tif ((header.getFlags() & HeadMessage.FLAG_SESSION_ID) != 0) {\n\t\t\t\tlog.debug(\"flag FLAG_SESSION_ID is set in header\");\n\t\t\t\tlog.debug(\"in.remaining() = {}\", in.remaining());\n\t\t\t\tif (in.remaining() >= 4) {\n\t\t\t\t\tshort sessionKeyVersion = in.getUnsigned();\n\t\t\t\t\tin.getUnsigned();\n\t\t\t\t\tint sessionKeyLength = in.getUnsignedShort();\n\t\t\t\t\tlog.debug(\"sessionKeyVersion={}\", sessionKeyVersion);\n\t\t\t\t\tlog.debug(\"sessionKeyLength={}\", sessionKeyLength);\n\t\t\t\t\tcmdBodySize -= (sessionKeyLength + 4);\n\t\t\t\t\tif (sessionKeyVersion == 0 && sessionKeyLength == 0) {\n\t\t\t\t\t\tlog.debug(\"version 0 session key detected, client can process session ID!\");\n\t\t\t\t\t} else if (in.remaining() < sessionKeyLength) {\n\t\t\t\t\t\tlong owe = header.getMessageSize()\n\t\t\t\t\t\t\t\t- ProtocolLengths.HEAD - 4 - in.remaining();\n\t\t\t\t\t\tin.position(start);\t\n\t\t\t\t\t\treturn new Result(true, owe, header, null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlog.debug(\n\t\t\t\t\t\t\t\t\t\"decoding session key (version: {}, key length: {})\",\n\t\t\t\t\t\t\t\t\tsessionKeyVersion, sessionKeyLength);\n\t\t\t\t\t\t\tin.position(start + 3);\n\t\t\t\t\t\t\tISessionKey sessionKey = sessionKeyCodec.decode(in);\n\t\t\t\t\t\t\theader.setSessionKey(sessionKey);\n\t\t\t\t\t\t\tlog.debug(\"session key decoded: {}\", sessionKey);\n\t\t\t\t\t\t\tsessionKeyDecoded = true;\n\t\t\t\t\t\t} catch (CodecException e) {\n\t\t\t\t\t\t\tlog.warn(\n\t\t\t\t\t\t\t\t\t\"error when decoding session key (version: {}, key length: {})\",\n\t\t\t\t\t\t\t\t\tnew Object[] { sessionKeyVersion,\n\t\t\t\t\t\t\t\t\t\t\tsessionKeyLength }, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlong owe = header.getMessageSize()\n\t\t\t\t\t\t\t- ProtocolLengths.HEAD - in.remaining();\n\t\t\t\t\tin.position(start);\t\n\t\t\t\t\treturn new Result(true, owe, header, null);\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog.debug(\"before parsing body: cmdBodySize={}, in.remaining={}\", cmdBodySize, in.remaining());\n\t\t\tif (in.remaining() < cmdBodySize) {\n\t\t\t\tlong owe = cmdBodySize - in.remaining();\n\t\t\t\tlog.trace(\"More bytes are required to parse the complete message (still need {} bytes)\",\n\t\t\t\t\t\towe);\n\t\t\t\tin.position(start);\t\n\t\t\t\treturn new Result(true, owe, header, null);\n\t\t\t}\n\t\t\tint calculatedChecksum = 0;\n\t\t\t{\n\t\t\t\tin.position(start);\n\t\t\t\tbyte[] byteTmp = new byte[(int)header.getMessageSize()];\t\n\t\t\t\tin.get(byteTmp);\n\t\t\t\tTools.putUnsignedShort(byteTmp, 0, 10);\n\t\t\t\tcalculatedChecksum = Tools.checkSum(byteTmp, byteTmp.length);\n\t\t\t}\n\t\t\tif (calculatedChecksum != header.getChecksum()) {\n\t\t\t\tErrorBodyMessage bodyMessage = new ErrorBodyMessage();\n\t\t\t\tbodyMessage.setErrorCode(CmdConstant.ERROR_CHECKSUM_CODE);\n\t\t\t\tMessage message = new Message(header, bodyMessage);\n\t\t\t\tlog.trace(\n\t\t\t\t\t\t\"Received message has invalid checksum (calc: 0x{}, actual: 0x{})\",\n\t\t\t\t\t\tInteger.toHexString(calculatedChecksum),\n\t\t\t\t\t\tInteger.toHexString(header.getChecksum()));\n\t\t\t\treturn new Result(false, 0, header, message);\n\t\t\t}\n\t\t\tin.position(start\n\t\t\t\t\t+ ((int) header.getMessageSize() - (int) cmdBodySize));\n\t\t\tICommand bodyMessage = null;\n\t\t\ttry {\n\t\t\t\tbodyMessage = this.decodeMessageBody(in, charset, header);\n\t\t\t\tMessage message = new Message(header, bodyMessage);\n\t\t\t\treturn new Result(false, 0, header, message);\n\t\t\t} catch (Throwable e) {\n\t\t\t\tlog.trace(\"Unexpected error when decoding message\", e);\n\t\t\t\tErrorBodyMessage errorBodyMessage = new ErrorBodyMessage();\n\t\t\t\terrorBodyMessage.setErrorCode(CmdConstant.ERROR_MESSAGE_CODE);\n\t\t\t\tMessage message = new Message(header, errorBodyMessage);\n\t\t\t\treturn new Result(false, 0, header, message);\n\t\t\t}\n\t\t} else {\n\t\t\tlong owe = ProtocolLengths.HEAD - in.remaining();\n\t\t\tlog.trace(\"More bytes are required to parse the header message (still need {} bytes)\",\n\t\t\t\t\towe);\n\t\t\treturn new Result(true, owe, null, null);\n\t\t}\n\t}\n"} {"input": " public void pageBeginRender(PageEvent event) {\n if (getUser() == null) { \n setUser(new User());\n }\n if (getUsers() == null) {\n setUsers(new ArrayList());\n } \n if (isFirstRender()) {\n setFirstRender(false);\n } else {\n search(event.getRequestCycle());\n }\n }\n", "output": " public void pageBeginRender(PageEvent event) {\n if (getUser() == null) { \n setUser(new User());\n }\n if (getUsers() == null) {\n setUsers(new ArrayList());\n } \n if (isFirstRender()) {\n getUsers().clear(); \n setFirstRender(false);\n } else {\n search(event.getRequestCycle());\n }\n }\n"} {"input": "\tpublic void onPlayerCommandPreprocess(\n\t\t\tfinal PlayerCommandPreprocessEvent event) {\n\t\tString command = event.getMessage();\n\t\tif (command.startsWith(\"/toggledownfall\")) {\n\t\t\tevent.setCancelled(true);\n\t\t\tif (!event.getPlayer().hasPermission(\"essentials.weather\")) {\n\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\tChatColor.RED + \"You don't have permission.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.getPlayer().getWorld().hasStorm()) {\n\t\t\t\tevent.getPlayer().getWorld().setStorm(false);\n\t\t\t} else {\n\t\t\t\tevent.getPlayer().getWorld().setStorm(true);\n\t\t\t}\n\t\t}\n\t\tif (command.startsWith(\"/time set\")) {\n\t\t\tevent.setCancelled(true);\n\t\t\tif (!event.getPlayer().hasPermission(\"essentials.time.set\")) {\n\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\tChatColor.RED + \"You don't have permission.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint ticks;\n\t\t\ttry {\n\t\t\t\tticks = Integer.parseInt(command.split(\" \")[2]);\n\t\t\t\tevent.getPlayer().getWorld().setTime(ticks);\n\t\t\t} catch (Exception e) {\n\t\t\t\tevent.getPlayer().sendMessage(e.toString());\n\t\t\t}\n\t\t}\n\t\tif (command.startsWith(\"/give\")) {\n\t\t\tif (event.getPlayer().hasPermission(\"essentials.give\"))\n\t\t\t\treturn;\n\t\t\tevent.setCancelled(true);\n\t\t\tif (!event.getPlayer().hasPermission(\"essentials.item\")) {\n\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\tChatColor.RED + \"You don't have permission.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tString player = command.split(\" \")[1];\n\t\t\t\tif (Config.config.getBoolean(\"debug\")) System.out.println(\"'\"+player+\"'\");\n\t\t\t\tint item = Integer.parseInt(command.split(\" \")[2]);\n\t\t\t\tint amount = Integer.parseInt(command.split(\" \")[3]);\n\t\t\t\tshort data = Short.parseShort(command.split(\" \")[4]);\n\t\t\t\tif (event.getPlayer().getName().toLowerCase() != player.toLowerCase()) {\n\t\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\t\tChatColor.RED\n\t\t\t\t\t\t\t\t\t+ \"You may only give items to yourself\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.getPlayer().getInventory()\n\t\t\t\t\t\t.addItem(new ItemStack(item, amount, data));\n\t\t\t} catch (Exception e) {\n\t\t\t\tevent.getPlayer().sendMessage(e.toString());\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void onPlayerCommandPreprocess(\n\t\t\tfinal PlayerCommandPreprocessEvent event) {\n\t\tString command = event.getMessage();\n\t\tif (command.startsWith(\"/toggledownfall\")) {\n\t\t\tevent.setCancelled(true);\n\t\t\tif (!event.getPlayer().hasPermission(\"essentials.weather\")) {\n\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\tChatColor.RED + \"You don't have permission.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.getPlayer().getWorld().hasStorm()) {\n\t\t\t\tevent.getPlayer().getWorld().setStorm(false);\n\t\t\t} else {\n\t\t\t\tevent.getPlayer().getWorld().setStorm(true);\n\t\t\t}\n\t\t}\n\t\tif (command.startsWith(\"/time set\")) {\n\t\t\tevent.setCancelled(true);\n\t\t\tif (!event.getPlayer().hasPermission(\"essentials.time.set\")) {\n\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\tChatColor.RED + \"You don't have permission.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint ticks;\n\t\t\ttry {\n\t\t\t\tticks = Integer.parseInt(command.split(\" \")[2]);\n\t\t\t\tevent.getPlayer().getWorld().setTime(ticks);\n\t\t\t} catch (Exception e) {\n\t\t\t\tevent.getPlayer().sendMessage(e.toString());\n\t\t\t}\n\t\t}\n\t\tif (command.startsWith(\"/give\")) {\n\t\t\tif (event.getPlayer().hasPermission(\"essentials.give\"))\n\t\t\t\treturn;\n\t\t\tevent.setCancelled(true);\n\t\t\tif (!event.getPlayer().hasPermission(\"essentials.item\")) {\n\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\tChatColor.RED + \"You don't have permission.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tPlayer player = Bukkit.getPlayer(command.split(\" \")[1]);\n\t\t\t\tint item = Integer.parseInt(command.split(\" \")[2]);\n\t\t\t\tint amount = Integer.parseInt(command.split(\" \")[3]);\n\t\t\t\tshort data = Short.parseShort(command.split(\" \")[4]);\n\t\t\t\tif (event.getPlayer() != player) {\n\t\t\t\t\tevent.getPlayer().sendMessage(\n\t\t\t\t\t\t\tChatColor.RED\n\t\t\t\t\t\t\t\t\t+ \"You may only give items to yourself\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.getPlayer().getInventory()\n\t\t\t\t\t\t.addItem(new ItemStack(item, amount, data));\n\t\t\t} catch (Exception e) {\n\t\t\t\tevent.getPlayer().sendMessage(e.toString());\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public void runJob() {\n SessionConfig cfg = _runner.getConfig();\n if ( (cfg == null) || (cfg.getDestination() == null) ) {\n if (_log.shouldLog(Log.ERROR))\n _log.error(\"No session config on runner \" + _runner);\n return;\n }\n if (_log.shouldLog(Log.INFO))\n _log.info(\"Requesting lease set for destination \" + cfg.getDestination().calculateHash().toBase64());\n ClientTunnelSettings settings = new ClientTunnelSettings();\n Properties props = new Properties();\n props.putAll(_runner.getConfig().getOptions());\n settings.readFromProperties(props);\n getContext().tunnelManager().buildTunnels(_runner.getConfig().getDestination(), settings);\n }\n", "output": " public void runJob() {\n SessionConfig cfg = _runner.getConfig();\n if ( (cfg == null) || (cfg.getDestination() == null) ) {\n if (_log.shouldLog(Log.ERROR))\n _log.error(\"No session config on runner \" + _runner);\n return;\n }\n if (_log.shouldLog(Log.INFO))\n _log.info(\"Requesting lease set for destination \" + cfg.getDestination().calculateHash().toBase64());\n ClientTunnelSettings settings = new ClientTunnelSettings();\n Properties props = new Properties();\n props.putAll(cfg.getOptions());\n settings.readFromProperties(props);\n getContext().tunnelManager().buildTunnels(cfg.getDestination(), settings);\n }\n"} {"input": "\tpublic void test_AllPathPermutationsGeneratior() throws StopConditionException, InterruptedException {\n\t\tlogger.info(\"TEST: test_AllPathPermutationsGeneration\");\n\t\tlogger.info(\"=======================================================================\");\n\t\tGraphML gml = new GraphML();\n\t\tgml.load(\"graphml/permutations/simple.graphml\");\n\t\tFiniteStateMachine FSM = new FiniteStateMachine();\n\t\tFSM.setModel(gml.getModel());\n\t\tFSM.setWeighted(false);\n\t\tPathGenerator pathGenerator = new AllPathPermutationsGenerator(new TestCaseLength(42));\n\t\tpathGenerator.setMachine(FSM);\n\t\twhile (pathGenerator.hasNext()) {\n\t\t\tString[] stepPair = pathGenerator.getNext();\n\t\t\tint stats[] = FSM.getStatistics();\n\t\t\tint ec = 100 * stats[1] / stats[0];\n\t\t\tlogger.debug(\"call( \" + stepPair[0] + \" ) then verify( \" + stepPair[1] + \" ) --> Edge coverage @ \" + ec + \"%\");\n\t\t}\n\t\tassertEquals(3, ((AllPathPermutationsGenerator) pathGenerator).getDepth());\n\t\tlogger.debug(\"==============================\");\n\t}\n", "output": "\tpublic void test_AllPathPermutationsGeneratior() throws StopConditionException, InterruptedException {\n\t\tlogger.info(\"TEST: test_AllPathPermutationsGeneration\");\n\t\tlogger.info(\"=======================================================================\");\n\t\tGraphML gml = new GraphML();\n\t\tgml.load(\"graphml/permutations/simple.graphml\");\n\t\tFiniteStateMachine FSM = new FiniteStateMachine();\n\t\tFSM.setModel(gml.getModel());\n\t\tFSM.setWeighted(false);\n\t\tPathGenerator pathGenerator = new AllPathPermutationsGenerator(new TestCaseLength(42));\n\t\tpathGenerator.setMachine(FSM);\n\t\twhile (pathGenerator.hasNext()) {\n\t\t\tString[] stepPair = pathGenerator.getNext();\n\t\t\tint stats[] = FSM.getStatistics();\n\t\t\tint ec = 100 * stats[1] / stats[0];\n\t\t\tlogger.debug(\"call( \" + stepPair[0] + \" ) then verify( \" + stepPair[1] + \" ) --> Edge coverage @ \" + ec + \"%\");\n\t\t}\n\t\tassertEquals(2, ((AllPathPermutationsGenerator) pathGenerator).getDepth());\n\t\tlogger.debug(\"==============================\");\n\t}\n"} {"input": " CarRaceGUI(CarRaceImpl i,String carClass) {\n super(\"CarRace\");\n PropertiesControl pc = new PropertiesControl(\"UTF-8\");\n messages = ResourceBundle.getBundle(\"Messages\",pc);\n System.out.println(\"i18n: test=\"+i18n(\"test\"));\n impl = i;\n ide = new SimpleIDE(this);\n this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n this.setLayout(new BorderLayout());\n VBox baseBox = new VBox();\n this.add(baseBox,BorderLayout.CENTER);\n HBox controlBox = new HBox();\n baseBox.myAdd(controlBox,0);\n HBox classNameBox = new HBox();\n classNameBox.setBorder(new TitledBorder(i18n(\"main.carClassname\")));\n controlBox.myAdd(classNameBox,1);\n carClassTF = new JTextField(carClass,20);\n classNameBox.myAdd(carClassTF,1);\n HBox loadFromBox = new HBox();\n loadFromBox.setBorder(new TitledBorder(i18n(\"main.loadFrom\")));\n controlBox.myAdd(loadFromBox,0);\n loadFromL = new JLabel(\"loadFrom???\");\n loadFromBox.myAdd(loadFromL,0);\n changeCPB = new JButton(i18n(\"main.change\"));\n changeCPB.addActionListener(this);\n loadFromBox.myAdd(changeCPB,0);\n VBox controlBox1 = new VBox();\n controlBox.myAdd(controlBox1,0);\n confB = new JButton(i18n(\"main.settings\"));\n confB.addActionListener(this);\n controlBox1.myAdd(confB,0);\n ideB = new JButton(i18n(\"main.programming\"));\n ideB.addActionListener(this);\n controlBox1.myAdd(ideB,0);\n VBox controlBox2 = new VBox();\n controlBox.myAdd(controlBox2,0);\n HBox generalInfoBox = new HBox();\n controlBox2.myAdd(generalInfoBox,0);\n fastForwardCB = new JCheckBox(i18n(\"main.fastForward\"));\n fastForwardCB.addActionListener(this);\n generalInfoBox.myAdd(fastForwardCB,0);\n generalInfoL = new JLabel(i18n(\"main.time\"));\n generalInfoBox.myAdd(generalInfoL,1);\n HBox mainButtonsBox = new HBox();\n controlBox2.myAdd(mainButtonsBox,0);\n startB = new JButton(i18n(\"main.start\"));\n startB.addActionListener(this);\n mainButtonsBox.myAdd(startB,1);\n pauseB = new JButton(i18n(\"main.pause\"));\n pauseB.addActionListener(this);\n mainButtonsBox.myAdd(pauseB,1);\n stopB = new JButton(i18n(\"main.stop\"));\n stopB.addActionListener(this);\n mainButtonsBox.myAdd(stopB,1);\n HBox displayBox = new HBox();\n baseBox.myAdd(displayBox,1);\n mainCanvas = A3Canvas.createA3Canvas(400,400);\n mainCanvas.setCameraLocImmediately(0.0,150.0,0.0);\n mainCanvas.setCameraLookAtPointImmediately(-50.0,0.0,1.0);\n a3csController = new A3CSController(150.0);\n mainCanvas.setA3Controller(a3csController);\n displayBox.myAdd(mainCanvas,1);\n VBox subBox = new VBox();\n displayBox.myAdd(subBox,1);\n HBox carBox = new HBox();\n subBox.myAdd(carBox,1);\n carCanvas = A3SubCanvas.createA3SubCanvas(200,200);\n carBox.myAdd(carCanvas,1);\n stdOutTA = new JTextArea(10,40);\n stdOutTA.setEditable(false);\n JScrollPane sp = new JScrollPane(stdOutTA);\n sp.setMinimumSize(new Dimension(100,100));\n baseBox.myAdd(sp,0);\n out = new JTextAreaOutputStream(stdOutTA,System.out);\n PrintStream ps = new PrintStream(out,true);\n System.setOut(ps);\n System.setErr(ps);\n updateLoadFrom();\n }\n", "output": " CarRaceGUI(CarRaceImpl i,String carClass) {\n super(\"CarRace\");\n PropertiesControl pc = new PropertiesControl(\"UTF-8\");\n messages = ResourceBundle.getBundle(\"Messages\",pc);\n System.out.println(\"i18n: test=\"+i18n(\"test\"));\n impl = i;\n ide = new SimpleIDE(this);\n this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n this.setLayout(new BorderLayout());\n VBox baseBox = new VBox();\n this.add(baseBox,BorderLayout.CENTER);\n HBox controlBox = new HBox();\n baseBox.myAdd(controlBox,0);\n HBox classNameBox = new HBox();\n classNameBox.setBorder(new TitledBorder(i18n(\"main.carClassname\")));\n controlBox.myAdd(classNameBox,1);\n carClassTF = new JTextField(carClass,20);\n classNameBox.myAdd(carClassTF,1);\n HBox loadFromBox = new HBox();\n loadFromBox.setBorder(new TitledBorder(i18n(\"main.loadFrom\")));\n controlBox.myAdd(loadFromBox,0);\n loadFromL = new JLabel(\"loadFrom???\");\n loadFromBox.myAdd(loadFromL,0);\n changeCPB = new JButton(i18n(\"main.change\"));\n changeCPB.addActionListener(this);\n loadFromBox.myAdd(changeCPB,0);\n VBox controlBox1 = new VBox();\n controlBox.myAdd(controlBox1,0);\n confB = new JButton(i18n(\"main.settings\"));\n confB.addActionListener(this);\n controlBox1.myAdd(confB,0);\n ideB = new JButton(i18n(\"main.programming\"));\n ideB.addActionListener(this);\n controlBox1.myAdd(ideB,0);\n VBox controlBox2 = new VBox();\n controlBox.myAdd(controlBox2,0);\n HBox generalInfoBox = new HBox();\n controlBox2.myAdd(generalInfoBox,0);\n fastForwardCB = new JCheckBox(i18n(\"main.fastForward\"));\n fastForwardCB.addActionListener(this);\n generalInfoBox.myAdd(fastForwardCB,0);\n generalInfoL = new JLabel(i18n(\"main.time\"));\n generalInfoBox.myAdd(generalInfoL,1);\n HBox mainButtonsBox = new HBox();\n controlBox2.myAdd(mainButtonsBox,0);\n startB = new JButton(i18n(\"main.start\"));\n startB.addActionListener(this);\n mainButtonsBox.myAdd(startB,1);\n pauseB = new JButton(i18n(\"main.pause\"));\n pauseB.addActionListener(this);\n mainButtonsBox.myAdd(pauseB,1);\n stopB = new JButton(i18n(\"main.stop\"));\n stopB.addActionListener(this);\n mainButtonsBox.myAdd(stopB,1);\n JSplitPane displayAndStdOutSP = new JSplitPane(JSplitPane.VERTICAL_SPLIT);\n baseBox.myAdd(displayAndStdOutSP,1);\n JSplitPane displaySP = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);\n displayAndStdOutSP.setTopComponent(displaySP);\n mainCanvas = A3Canvas.createA3Canvas(400,400);\n mainCanvas.setPreferredSize(new Dimension(400,400));\n mainCanvas.setMinimumSize(new Dimension(40,40));\n mainCanvas.setCameraLocImmediately(0.0,150.0,0.0);\n mainCanvas.setCameraLookAtPointImmediately(-50.0,0.0,1.0);\n a3csController = new A3CSController(150.0);\n mainCanvas.setA3Controller(a3csController);\n displaySP.setLeftComponent(mainCanvas);\n VBox subBox = new VBox();\n displaySP.setRightComponent(subBox);\n HBox carBox = new HBox();\n subBox.myAdd(carBox,1);\n carCanvas = A3SubCanvas.createA3SubCanvas(200,200);\n carCanvas.setPreferredSize(new Dimension(200,200));\n carCanvas.setMinimumSize(new Dimension(20,20));\n carBox.myAdd(carCanvas,1);\n stdOutTA = new JTextArea(10,40);\n stdOutTA.setEditable(false);\n JScrollPane sp = new JScrollPane(stdOutTA);\n sp.setPreferredSize(new Dimension(100,100));\n sp.setMinimumSize(new Dimension(10,10));\n displayAndStdOutSP.setBottomComponent(sp);\n out = new JTextAreaOutputStream(stdOutTA,System.out);\n PrintStream ps = new PrintStream(out,true);\n System.setOut(ps);\n System.setErr(ps);\n updateLoadFrom();\n }\n"} {"input": "\tpublic void hit(Input in) {\n\t\tboolean hoverDone = false;\n\t\tboolean downDone = false;\n\t\tboolean clickDone = false;\n\t\tfor (int i = list.size() - 1; i >= 0; i--) {\n\t\t\tPair h = list.get(i);\n\t\t\tif (!hoverDone && h.b.ofType(Hook.Type.HOVER) && h.a.contains(in.cursor())) {\n\t\t\t\thoverDone = true;\n\t\t\t\th.b.run(in, h.a.relative(in.cursor()), Hook.Type.HOVER);\n\t\t\t}\n\t\t\tif (!downDone && h.b.ofType(Hook.Type.values()[in.clickButton()]) && h.a.contains(in.mouseDown())) {\n\t\t\t\tdownDone = true;\n\t\t\t\th.b.run(in, h.a.relative(in.mouseDown()), Hook.Type.values()[in.clickButton()]);\n\t\t\t}\n\t\t\tif (!clickDone && (in.clickButton() + 3) < Hook.Type.values().length && h.b.ofType(Hook.Type.values()[in.clickButton() + 3]) && h.a.contains(in.clicked())) {\n\t\t\t\tclickDone = true;\n\t\t\t\th.b.run(in, h.a.relative(in.clicked()), Hook.Type.values()[in.clickButton() + 3]);\n\t\t\t}\n\t\t\tif (clickDone && downDone && hoverDone) { list.clear(); return; }\n\t\t}\n\t\tlist.clear();\n\t}\n", "output": "\tpublic void hit(Input in) {\n\t\tboolean hoverDone = false;\n\t\tboolean downDone = false;\n\t\tboolean clickDone = false;\n\t\tfor (int i = list.size() - 1; i >= 0; i--) {\n\t\t\tPair h = list.get(i);\n\t\t\tif (!hoverDone && h.b.ofType(Hook.Type.HOVER) && h.a.contains(in.cursor())) {\n\t\t\t\thoverDone = true;\n\t\t\t\th.b.run(in, h.a.relative(in.cursor()), Hook.Type.HOVER);\n\t\t\t}\n\t\t\tif (!downDone && h.a.contains(in.mouseDown())) {\n\t\t\t\tdownDone = true;\n\t\t\t\th.b.run(in, h.a.relative(in.mouseDown()), Hook.Type.values()[in.clickButton()]);\n\t\t\t}\n\t\t\tif (!clickDone && (in.clickButton() + 3) < Hook.Type.values().length && h.b.ofType(Hook.Type.values()[in.clickButton() + 3]) && h.a.contains(in.clicked())) {\n\t\t\t\tclickDone = true;\n\t\t\t\th.b.run(in, h.a.relative(in.clicked()), Hook.Type.values()[in.clickButton() + 3]);\n\t\t\t}\n\t\t\tif (clickDone && downDone && hoverDone) { list.clear(); return; }\n\t\t}\n\t\tlist.clear();\n\t}\n"} {"input": "\tpublic void addComponentsToPane() {\n\t\tContainer pane = getContentPane();\n\t\tpane.setLayout(new GridBagLayout());\n\t\tGridBagConstraints c;\n\t\tJToolBar toolBar = new JToolBar(\"Toolbar\");\n\t\ttoolBar.setBackground(new Color(128, 128, 128));\n\t\ttoolBar.setFloatable(false);\n\t\ttoolBar.setRollover(true);\n\t\ttoolBar.setMargin(new Insets(8, 16, 8, 8));\n\t\ttoolBar.setBorder(new EmptyBorder(new Insets(8, 16, 8, 8)));\n\t\tstatus_label = new JLabel(status_red);\n\t\tstatus_label.setPreferredSize(new Dimension(24, 64));\n\t\ttoolBar.add(status_label);\n\t\tstatus_timer = new Timer(750, new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tif (status == Status.YELLOW) {\n\t\t\t\t\tif (status_label.getIcon() == status_yellow) {\n\t\t\t\t\t\tstatus_label.setIcon(status_off);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatus_label.setIcon(status_yellow);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tstatus_timer.start();\n\t\ttoolBar.addSeparator(new Dimension(16, 0));\n\t\tstart_button = new JButton(start_active_icon);\n\t\tinitButton(start_button);\n\t\ttoolBar.add(start_button);\n\t\tstart_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tstart_button.setIcon(start_icon);\n\t\t\t\tstop_button.setIcon(stop_active_icon);\n\t\t\t\tapp.startServer();\n\t\t\t}\n\t\t});\n\t\ttoolBar.addSeparator(new Dimension(8, 0));\n\t\tstop_button = new JButton(stop_icon);\n\t\tinitButton(stop_button);\n\t\ttoolBar.add(stop_button);\n\t\tstop_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tstart_button.setIcon(start_active_icon);\n\t\t\t\tstop_button.setIcon(stop_icon);\n\t\t\t\tapp.stopServer();\n\t\t\t}\n\t\t});\n\t\ttoolBar.addSeparator(new Dimension(8, 0));\n\t\tlog_viewer_button = new JButton(log_viewer_icon);\n\t\tinitButton(log_viewer_button);\n\t\ttoolBar.add(log_viewer_button);\n\t\tlog_viewer_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tapp.showLogView();\n\t\t\t}\n\t\t});\n\t\ttoolBar.addSeparator(new Dimension(8, 0));\n\t\tusergrid_admin_button = new JButton(usergrid_admin_icon);\n\t\tinitButton(usergrid_admin_button);\n\t\ttoolBar.add(usergrid_admin_button);\n\t\tusergrid_admin_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tif (app.serverIsStarted() && (status == Status.GREEN)) {\n\t\t\t\t\tstoreAdminUrls();\n\t\t\t\t\tstoreAdminEmail();\n\t\t\t\t\ttry {\n\t\t\t\t\t\tDesktop.getDesktop().browse(getAdminURI());\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tJOptionPane\n\t\t\t\t\t\t\t.showMessageDialog(\n\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\"Server must be started before opening Admin Console.\\n\"\n\t\t\t\t\t\t\t\t\t\t\t+ \"Please start server and wait for the status to turn green.\",\n\t\t\t\t\t\t\t\t\t\"Warning\", JOptionPane.WARNING_MESSAGE);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tc = new GridBagConstraints();\n\t\tc.anchor = GridBagConstraints.CENTER;\n\t\tc.weightx = 0.0;\n\t\tc.fill = GridBagConstraints.HORIZONTAL;\n\t\tc.gridwidth = 2;\n\t\tadd(toolBar, c);\n\t\tstart_database_checkbox = new JCheckBox(\"Start Database With Server*\");\n\t\tc = new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 8, 16), 0, 0);\n\t\tstart_database_checkbox.setSelected(app.isStartDatabaseWithServer());\n\t\tstart_database_checkbox.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(start_database_checkbox, c);\n\t\tstart_database_checkbox.addChangeListener(new ChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void stateChanged(ChangeEvent change) {\n\t\t\t\tapp.setStartDatabaseWithServer(start_database_checkbox\n\t\t\t\t\t\t.isSelected());\n\t\t\t}\n\t\t});\n\t\tinit_database_checkbox = new JCheckBox(\"Initialize Database on Start*\");\n\t\tc = new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 8, 16), 0, 0);\n\t\tinit_database_checkbox.setSelected(app.isInitializeDatabaseOnStart());\n\t\tinit_database_checkbox.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(init_database_checkbox, c);\n\t\tinit_database_checkbox.addChangeListener(new ChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void stateChanged(ChangeEvent change) {\n\t\t\t\tapp.setInitializeDatabaseOnStart(init_database_checkbox\n\t\t\t\t\t\t.isSelected());\n\t\t\t}\n\t\t});\n\t\tJLabel label = new JLabel(\"Console URL:\");\n\t\tc = new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 24, 8, 0), 0, 0);\n\t\tlabel.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(label, c);\n\t\tString[] urls = app.getUrlsFromPreferences();\n\t\turlList = new JComboBox(urls);\n\t\turlList.setEditable(true);\n\t\tc = new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(\n\t\t\t\t\t\t16, 0, 8, 16), 0, 0);\n\t\turlList.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\turlList.setPrototypeDisplayValue(\"XXXXXXXXXXXXXXXXXXXX\");\n\t\tComboBoxEditor editor = urlList.getEditor();\n\t\tJTextField textField = (JTextField) editor.getEditorComponent();\n\t\ttextField.setColumns(20);\n\t\tsetPreferredWidth(textField, 350);\n\t\tsetMaxWidth(textField, 350);\n\t\tsetPreferredWidth(urlList, 350);\n\t\tsetMaxWidth(urlList, 350);\n\t\tpane.add(urlList, c);\n\t\tauto_login_checkbox = new JCheckBox(\"Auto-login as:\");\n\t\tc = new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 8, 0), 0, 0);\n\t\tauto_login_checkbox.setSelected(app.isAutoLogin());\n\t\tauto_login_checkbox.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(auto_login_checkbox, c);\n\t\tauto_login_checkbox.addChangeListener(new ChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void stateChanged(ChangeEvent change) {\n\t\t\t\tapp.setAutoLogin(auto_login_checkbox.isSelected());\n\t\t\t}\n\t\t});\n\t\tauto_login_email = new JTextField(app.getAdminUserEmail());\n\t\tc = new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 0, 8, 16), 0, 0);\n\t\tauto_login_email.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(auto_login_email, c);\n\t\tlabel = new JLabel(\n\t\t\t\t\"* Database can only be started or initialized once per app launch\");\n\t\tc = new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 16, 0), 0, 0);\n\t\tlabel.setForeground(Color.RED);\n\t\tlabel.setFont(new Font(\"Arial\", Font.BOLD, 12));\n\t\tpane.add(label, c);\n\t\tList icons = new ArrayList(4);\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_16.png\")).getImage());\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_32.png\")).getImage());\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_64.png\")).getImage());\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_256.png\")).getImage());\n\t\tsetIconImages(icons);\n\t}\n", "output": "\tpublic void addComponentsToPane() {\n\t\tContainer pane = getContentPane();\n\t\tpane.setLayout(new GridBagLayout());\n\t\tGridBagConstraints c;\n\t\tJToolBar toolBar = new JToolBar(\"Toolbar\");\n\t\ttoolBar.setBackground(new Color(128, 128, 128));\n\t\ttoolBar.setFloatable(false);\n\t\ttoolBar.setRollover(true);\n\t\ttoolBar.setMargin(new Insets(8, 16, 8, 8));\n\t\ttoolBar.setBorder(new EmptyBorder(new Insets(8, 16, 8, 8)));\n\t\tstatus_label = new JLabel(status_red);\n\t\tstatus_label.setPreferredSize(new Dimension(24, 64));\n\t\ttoolBar.add(status_label);\n\t\tstatus_timer = new Timer(750, new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tif (status == Status.YELLOW) {\n\t\t\t\t\tif (status_label.getIcon() == status_yellow) {\n\t\t\t\t\t\tstatus_label.setIcon(status_off);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatus_label.setIcon(status_yellow);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tstatus_timer.start();\n\t\ttoolBar.addSeparator(new Dimension(16, 0));\n\t\tstart_button = new JButton(start_active_icon);\n\t\tinitButton(start_button);\n\t\ttoolBar.add(start_button);\n\t\tstart_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tstart_button.setIcon(start_icon);\n\t\t\t\tstop_button.setIcon(stop_active_icon);\n\t\t\t\tapp.startServer();\n\t\t\t}\n\t\t});\n\t\ttoolBar.addSeparator(new Dimension(8, 0));\n\t\tstop_button = new JButton(stop_icon);\n\t\tinitButton(stop_button);\n\t\ttoolBar.add(stop_button);\n\t\tstop_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tstart_button.setIcon(start_active_icon);\n\t\t\t\tstop_button.setIcon(stop_icon);\n\t\t\t\tapp.stopServer();\n\t\t\t}\n\t\t});\n\t\ttoolBar.addSeparator(new Dimension(8, 0));\n\t\tlog_viewer_button = new JButton(log_viewer_icon);\n\t\tinitButton(log_viewer_button);\n\t\ttoolBar.add(log_viewer_button);\n\t\tlog_viewer_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tapp.showLogView();\n\t\t\t}\n\t\t});\n\t\ttoolBar.addSeparator(new Dimension(8, 0));\n\t\tusergrid_admin_button = new JButton(usergrid_admin_icon);\n\t\tinitButton(usergrid_admin_button);\n\t\ttoolBar.add(usergrid_admin_button);\n\t\tusergrid_admin_button.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent event) {\n\t\t\t\tif (app.serverIsStarted() && (status == Status.GREEN)) {\n\t\t\t\t\tstoreAdminUrls();\n\t\t\t\t\tstoreAdminEmail();\n String adminUri = null;\n\t\t\t\t\ttry {\n adminUri = getAdminURI().toString();\n\t\t\t\t\t\tDesktop.getDesktop().browse(getAdminURI());\n\t\t\t\t\t} catch (Exception e) {\n System.out.println(\"There was a problem opening default browser for this system: \");\n e.printStackTrace();\n System.out.println(\"You can access the URI directly here: \" + adminUri);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tJOptionPane\n\t\t\t\t\t\t\t.showMessageDialog(\n\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\"Server must be started before opening Admin Console.\\n\"\n\t\t\t\t\t\t\t\t\t\t\t+ \"Please start server and wait for the status to turn green.\",\n\t\t\t\t\t\t\t\t\t\"Warning\", JOptionPane.WARNING_MESSAGE);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tc = new GridBagConstraints();\n\t\tc.anchor = GridBagConstraints.CENTER;\n\t\tc.weightx = 0.0;\n\t\tc.fill = GridBagConstraints.HORIZONTAL;\n\t\tc.gridwidth = 2;\n\t\tadd(toolBar, c);\n\t\tstart_database_checkbox = new JCheckBox(\"Start Database With Server*\");\n\t\tc = new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 8, 16), 0, 0);\n\t\tstart_database_checkbox.setSelected(app.isStartDatabaseWithServer());\n\t\tstart_database_checkbox.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(start_database_checkbox, c);\n\t\tstart_database_checkbox.addChangeListener(new ChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void stateChanged(ChangeEvent change) {\n\t\t\t\tapp.setStartDatabaseWithServer(start_database_checkbox\n\t\t\t\t\t\t.isSelected());\n\t\t\t}\n\t\t});\n\t\tinit_database_checkbox = new JCheckBox(\"Initialize Database on Start*\");\n\t\tc = new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 8, 16), 0, 0);\n\t\tinit_database_checkbox.setSelected(app.isInitializeDatabaseOnStart());\n\t\tinit_database_checkbox.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(init_database_checkbox, c);\n\t\tinit_database_checkbox.addChangeListener(new ChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void stateChanged(ChangeEvent change) {\n\t\t\t\tapp.setInitializeDatabaseOnStart(init_database_checkbox\n\t\t\t\t\t\t.isSelected());\n\t\t\t}\n\t\t});\n\t\tJLabel label = new JLabel(\"Console URL:\");\n\t\tc = new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 24, 8, 0), 0, 0);\n\t\tlabel.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(label, c);\n\t\tString[] urls = app.getUrlsFromPreferences();\n\t\turlList = new JComboBox(urls);\n\t\turlList.setEditable(true);\n\t\tc = new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(\n\t\t\t\t\t\t16, 0, 8, 16), 0, 0);\n\t\turlList.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\turlList.setPrototypeDisplayValue(\"XXXXXXXXXXXXXXXXXXXX\");\n\t\tComboBoxEditor editor = urlList.getEditor();\n\t\tJTextField textField = (JTextField) editor.getEditorComponent();\n\t\ttextField.setColumns(20);\n\t\tsetPreferredWidth(textField, 350);\n\t\tsetMaxWidth(textField, 350);\n\t\tsetPreferredWidth(urlList, 350);\n\t\tsetMaxWidth(urlList, 350);\n\t\tpane.add(urlList, c);\n\t\tauto_login_checkbox = new JCheckBox(\"Auto-login as:\");\n\t\tc = new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 8, 0), 0, 0);\n\t\tauto_login_checkbox.setSelected(app.isAutoLogin());\n\t\tauto_login_checkbox.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(auto_login_checkbox, c);\n\t\tauto_login_checkbox.addChangeListener(new ChangeListener() {\n\t\t\t@Override\n\t\t\tpublic void stateChanged(ChangeEvent change) {\n\t\t\t\tapp.setAutoLogin(auto_login_checkbox.isSelected());\n\t\t\t}\n\t\t});\n\t\tauto_login_email = new JTextField(app.getAdminUserEmail());\n\t\tc = new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 0, 8, 16), 0, 0);\n\t\tauto_login_email.setFont(new Font(\"Arial\", Font.BOLD, 18));\n\t\tpane.add(auto_login_email, c);\n\t\tlabel = new JLabel(\n\t\t\t\t\"* Database can only be started or initialized once per app launch\");\n\t\tc = new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0,\n\t\t\t\tGridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,\n\t\t\t\tnew Insets(16, 16, 16, 0), 0, 0);\n\t\tlabel.setForeground(Color.RED);\n\t\tlabel.setFont(new Font(\"Arial\", Font.BOLD, 12));\n\t\tpane.add(label, c);\n\t\tList icons = new ArrayList(4);\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_16.png\")).getImage());\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_32.png\")).getImage());\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_64.png\")).getImage());\n\t\ticons.add(new ImageIcon(getClass().getClassLoader().getResource(\n\t\t\t\t\"org/usergrid/launcher/icon_256.png\")).getImage());\n\t\tsetIconImages(icons);\n\t}\n"} {"input": "\tpublic boolean onCommand(CommandSender sender, Command cmd, String label, String args[]){\n\t\tif(cmd.getName().equalsIgnoreCase(\"icu\")){\n\t\t\tif(sender instanceof Player){\n\t\t\t\tif(args.length == 0 || args.length > 2){\n\t\t\t\t\tsender.sendMessage(ChatColor.YELLOW+\"==========[ iControlU Help v1.5.6]==========\");\n\t\t\t\t\tsender.sendMessage(ChatColor.BLUE+\"/icu control \"+ChatColor.GREEN+\" Enter Control Mode with .\");\n\t\t\t\t\tsender.sendMessage(ChatColor.BLUE+\"/icu stop\"+ChatColor.GREEN+\" Exit Control Mode.\");\n\t\t\t\t\tsender.sendMessage(ChatColor.YELLOW+\" ========== \");\n\t\t\t\t\tsender.sendMessage(ChatColor.DARK_PURPLE+\"Created by FireBreath15\");\n\t\t\t\t\tsender.sendMessage(ChatColor.YELLOW+\"==========[ iControlU Help v1.5.6]==========\");\n\t\t\t\t}\n\t\t\t\tif(args.length == 2){\n\t\t\t\t\tif(args[0].equalsIgnoreCase(\"control\")){\n\t\t\t\t\t\tif(sender.hasPermission(\"icu.control\")){\n\t\t\t\t\t\t\tString name = sender.getName();\n\t\t\t\t\t\t\tif(!(this.getConfig().contains(\"controllers.\"+name))){\n\t\t\t\t\t\t\t\tif(this.getServer().getPlayer(args[1]) != null){\n\t\t\t\t\t\t\t\tPlayer victim = this.getServer().getPlayer(args[1]);\n\t\t\t\t\t\t\t\tif(!(victim.hasPermission(\"icu.exempt\"))){\n\t\t\t\t\t\t\t\t\tPlayer s = (Player)sender;\n\t\t\t\t\t\t\t\t\tvictim.hidePlayer(s);\n\t\t\t\t\t\t\t\t\ts.teleport(victim);\n\t\t\t\t\t\t\t\t\ts.hidePlayer(victim);\n\t\t\t\t\t\t\t\t\tPlayer[] ps = this.getServer().getOnlinePlayers();\n\t\t\t\t\t\t\t\t\tint pon = ps.length;\n\t\t\t\t\t\t\t\t\tfor(int i=0; i 2){\n\t\t\t\t\tsender.sendMessage(ChatColor.YELLOW+\"==========[ iControlU Help v1.5.7]==========\");\n\t\t\t\t\tsender.sendMessage(ChatColor.BLUE+\"/icu control \"+ChatColor.GREEN+\" Enter Control Mode with .\");\n\t\t\t\t\tsender.sendMessage(ChatColor.BLUE+\"/icu stop\"+ChatColor.GREEN+\" Exit Control Mode.\");\n\t\t\t\t\tsender.sendMessage(ChatColor.YELLOW+\" ========== \");\n\t\t\t\t\tsender.sendMessage(ChatColor.DARK_PURPLE+\"Created by FireBreath15\");\n\t\t\t\t\tsender.sendMessage(ChatColor.YELLOW+\"==========[ iControlU Help v1.5.7]==========\");\n\t\t\t\t}\n\t\t\t\tif(args.length == 2){\n\t\t\t\t\tif(args[0].equalsIgnoreCase(\"control\")){\n\t\t\t\t\t\tif(sender.hasPermission(\"icu.control\")){\n\t\t\t\t\t\t\tString name = sender.getName();\n\t\t\t\t\t\t\tif(!(this.getConfig().contains(\"controllers.\"+name))){\n\t\t\t\t\t\t\t\tif(this.getServer().getPlayer(args[1]) != null){\n\t\t\t\t\t\t\t\tPlayer victim = this.getServer().getPlayer(args[1]);\n\t\t\t\t\t\t\t\tif(!(victim.hasPermission(\"icu.exempt\"))){\n\t\t\t\t\t\t\t\t\tPlayer s = (Player)sender;\n\t\t\t\t\t\t\t\t\tvictim.hidePlayer(s);\n\t\t\t\t\t\t\t\t\ts.teleport(victim);\n\t\t\t\t\t\t\t\t\ts.hidePlayer(victim);\n\t\t\t\t\t\t\t\t\tPlayer[] ps = this.getServer().getOnlinePlayers();\n\t\t\t\t\t\t\t\t\tint pon = ps.length;\n\t\t\t\t\t\t\t\t\tfor(int i=0; i 0)) {\n\t\t\tcmd.add(\"-branch\", \"brtype:\" + branch);\n\t\t}\n\t\tcmd.add(\"-nco\");\n\t\tFilePath viewPath = getRootViewPath(launcher).child(viewName);\n\t\tfor (String path : viewPaths) { \n\t\t\tcmd.add(path.replace(\"\\\\n\",\"\"));\n\t\t}\n\t\tReader returnReader = null;\n\t\tByteArrayOutputStream baos = new ByteArrayOutputStream();\n\t\tif (launcher.run(cmd.toCommandArray(), null, baos, viewPath)) {\n\t\t\treturnReader = new InputStreamReader(new ByteArrayInputStream(baos\n\t\t\t\t\t.toByteArray()));\n\t\t}\n\t\tbaos.close();\n\t\treturn returnReader;\n\t}\n", "output": "\tpublic Reader lshistory(String format, Date lastBuildDate, String viewName,\n\t\t\tString branch, String[] viewPaths) throws IOException,\n\t\t\tInterruptedException {\n\t\tSimpleDateFormat formatter = new SimpleDateFormat(\"d-MMM.HH:mm:ss\");\n\t\tArgumentListBuilder cmd = new ArgumentListBuilder();\n\t\tcmd.add(\"lshistory\");\n\t\tcmd.add(\"-r\");\n\t\tcmd.add(\"-since\", formatter.format(lastBuildDate).toLowerCase());\n\t\tcmd.add(\"-fmt\", format);\n\t\tif ((branch != null) && (branch.length() > 0)) {\n\t\t\tcmd.add(\"-branch\", \"brtype:\" + branch);\n\t\t}\n\t\tcmd.add(\"-nco\");\n\t\tFilePath viewPath = getRootViewPath(launcher).child(viewName);\n\t\tfor (String path : viewPaths) { \n\t\t\tcmd.add(path.replace(\"\\n\",\"\"));\n\t\t}\n\t\tReader returnReader = null;\n\t\tByteArrayOutputStream baos = new ByteArrayOutputStream();\n\t\tif (launcher.run(cmd.toCommandArray(), null, baos, viewPath)) {\n\t\t\treturnReader = new InputStreamReader(new ByteArrayInputStream(baos\n\t\t\t\t\t.toByteArray()));\n\t\t}\n\t\tbaos.close();\n\t\treturn returnReader;\n\t}\n"} {"input": " public static boolean checkScript(String type, String script, String player, String password,\n String email, String ipAddress) throws SQLException {\n boolean caseSensitive = false;\n if (Util.databaseManager.getDatabaseType().equalsIgnoreCase(\"ebean\")) {\n EBean eBeanClass = EBean.checkPlayer(player, true);\n if (type.equalsIgnoreCase(\"checkuser\")) {\n if (eBeanClass.getRegistered().equalsIgnoreCase(\"true\")) {\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"checkpassword\")) {\n String storedPassword = eBeanClass.getPassword();\n if (Encryption.SHA512(password).equals(storedPassword)) {\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"adduser\")) {\n Custom.adduser(player, email, password, ipAddress);\n eBeanClass.setEmail(email);\n eBeanClass.setPassword(Encryption.SHA512(password));\n eBeanClass.setRegistered(\"true\");\n eBeanClass.setIp(ipAddress);\n } else if (type.equalsIgnoreCase(\"numusers\")) {\n int amount = EBean.getUsers();\n logging.Info(amount + \" user registrations in database\");\n }\n } else if (Config.database_ison) {\n String usertable = null, usernamefield = null, passwordfield = null, saltfield = \"\";\n boolean bans = false;\n PreparedStatement ps = null;\n int number = 0;\n if (Config.custom_enabled) {\n if (type.equalsIgnoreCase(\"checkuser\")) {\n String check = MySQL.getfromtable(Config.custom_table, \"*\", Config.custom_userfield, player);\n if (check != \"fail\") {\n Config.hasForumBoard = true;\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (Custom.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.custom_table, \"`\" + Config.custom_passfield + \"`\", \"\" + Config.custom_userfield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Custom.check_hash(password, hash)) {\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"syncpassword\")) {\n String hash = MySQL.getfromtable(Config.custom_table, \"`\" + Config.custom_passfield + \"`\", \"\" + Config.custom_userfield + \"\", player);\n EBean.checkPassword(player, hash);\n return true;\n } else if (type.equalsIgnoreCase(\"adduser\")) {\n Custom.adduser(player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n } else if (type.equalsIgnoreCase(\"numusers\")) {\n ps = (PreparedStatement) MySQL.mysql.prepareStatement(\"SELECT COUNT(*) as `countit` FROM `\" + Config.custom_table + \"`\");\n ResultSet rs = ps.executeQuery();\n if (rs.next()) {\n logging.Info(rs.getInt(\"countit\") + \" user registrations in database\");\n }\n }\n } else if (script.equalsIgnoreCase(PhpBB.Name) || script.equalsIgnoreCase(PhpBB.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(PhpBB.VersionRange)) {\n usernamefield = \"username_clean\";\n passwordfield = \"user_password\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && PhpBB.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player.toLowerCase());\n EBean.checkPassword(player, hash);\n if (PhpBB.check_hash(password, hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(PhpBB.VersionRange2)) {\n usernamefield = \"username_clean\"; \n passwordfield = \"user_password\";\n Config.hasForumBoard = true;\n bans = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && PhpBB.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player.toLowerCase());\n EBean.checkPassword(player, hash);\n if (PhpBB.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n PhpBB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(SMF.Name) || script.equalsIgnoreCase(SMF.ShortName)) {\n usertable = \"members\";\n if (checkVersionInRange(SMF.VersionRange)) {\n usernamefield = \"memberName\";\n passwordfield = \"passwd\";\n saltfield = \"passwordSalt\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n bans = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && SMF.check_hash(SMF.hash(1, player, password), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (SMF.check_hash(SMF.hash(1, player, password), hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(SMF.VersionRange2) || checkVersionInRange(\"2.0-2.0\")\n || checkVersionInRange(\"2.0.0-2.0.0\")) {\n usernamefield = \"member_name\";\n passwordfield = \"passwd\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n bans = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && SMF.check_hash(SMF.hash(2, player, password), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (SMF.check_hash(SMF.hash(2, player, password), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n SMF.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(MyBB.Name) || script.equalsIgnoreCase(MyBB.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(MyBB.VersionRange)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n bans = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && MyBB.check_hash(MyBB.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (MyBB.check_hash(MyBB.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n MyBB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(VBulletin.Name) || script.equalsIgnoreCase(VBulletin.ShortName)) {\n usertable = \"user\";\n if (checkVersionInRange(VBulletin.VersionRange)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n bans = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(VBulletin.VersionRange2)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n bans = true;\n number = 2;\n caseSensitive = true;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n VBulletin.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(Drupal.Name) || script.equalsIgnoreCase(Drupal.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(Drupal.VersionRange)) {\n usernamefield = \"name\";\n passwordfield = \"pass\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Encryption.md5(password).equals(storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Encryption.md5(password).equals(hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(Drupal.VersionRange2)) {\n usernamefield = \"name\";\n passwordfield = \"pass\";\n Config.hasForumBoard = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && storedPassword.equals(Drupal.user_check_password(password, storedPassword))) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (hash.equals(Drupal.user_check_password(password, hash))) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n Drupal.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(Joomla.Name) || script.equalsIgnoreCase(Joomla.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(Joomla.VersionRange)) {\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Joomla.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Joomla.check_hash(password, hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(Joomla.VersionRange2)) {\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Joomla.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Joomla.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n Joomla.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(Vanilla.Name) || script.equalsIgnoreCase(Vanilla.ShortName)) {\n if (checkVersionInRange(Vanilla.VersionRange)) {\n usertable = \"User\";\n usernamefield = \"Name\";\n passwordfield = \"Password\";\n caseSensitive = true;\n if (Vanilla.check() == 2) {\n usertable = usertable.toLowerCase();\n }\n Config.hasForumBoard = true;\n number = Vanilla.check();\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Vanilla.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Vanilla.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n String emailcheck = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`\" + usernamefield + \"`\", \"Email\", email);\n if (emailcheck.equalsIgnoreCase(\"fail\")) {\n Vanilla.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n return false;\n }\n } else if (script.equalsIgnoreCase(PunBB.Name) || script.equalsIgnoreCase(PunBB.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(PunBB.VersionRange)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && PunBB.check_hash(PunBB.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (PunBB.check_hash(PunBB.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n PunBB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(XenForo.Name) || script.equalsIgnoreCase(XenForo.ShortName)) {\n usertable = \"user\";\n if (checkVersionInRange(XenForo.VersionRange)) {\n String userid = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`user_id`\", \"username\", player);\n usernamefield = \"username\";\n passwordfield = \"password\";\n caseSensitive = true;\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n Blob hash = MySQL.getfromtableBlob(Config.script_tableprefix + \"user_authenticate\", \"`data`\", \"user_id\", userid);\n if (hash != null) {\n int offset = -1;\n int chunkSize = 1024;\n long blobLength = hash.length();\n if (chunkSize > blobLength) {\n chunkSize = (int) blobLength;\n }\n char buffer[] = new char[chunkSize];\n StringBuilder stringBuffer = new StringBuilder();\n Reader reader = new InputStreamReader(hash.getBinaryStream());\n try {\n while ((offset = reader.read(buffer)) != -1) {\n stringBuffer.append(buffer, 0, offset);\n }\n } catch (IOException e) {\n logging.StackTrace(e.getStackTrace(), Thread.currentThread().getStackTrace()[1].getMethodName(), Thread.currentThread().getStackTrace()[1].getLineNumber(), Thread.currentThread().getStackTrace()[1].getClassName(), Thread.currentThread().getStackTrace()[1].getFileName());\n }\n String cache = stringBuffer.toString();\n String thehash = forumCacheValue(cache, \"hash\");\n String thesalt = forumCacheValue(cache, \"salt\");\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n String storedSalt = eBeanClass.getSalt();\n if (storedPassword != null && storedSalt != null && XenForo.check_hash(XenForo.hash(1, storedSalt, password), storedPassword)) {\n return true;\n }\n EBean.checkSalt(player, thesalt);\n EBean.checkPassword(player, thehash);\n if (XenForo.check_hash(XenForo.hash(1, thesalt, password), thehash)) {\n return true;\n }\n } else {\n return false;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n XenForo.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncpassword\") && !Config.custom_enabled) {\n String userid = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`user_id`\", \"username\", player);\n Blob hash = MySQL.getfromtableBlob(Config.script_tableprefix + \"user_authenticate\", \"`data`\", \"user_id\", userid);\n int offset = -1;\n int chunkSize = 1024;\n long blobLength = hash.length();\n if (chunkSize > blobLength) {\n chunkSize = (int) blobLength;\n }\n char buffer[] = new char[chunkSize];\n StringBuilder stringBuffer = new StringBuilder();\n Reader reader = new InputStreamReader(hash.getBinaryStream());\n try {\n while ((offset = reader.read(buffer)) != -1) {\n stringBuffer.append(buffer, 0, offset);\n }\n } catch (IOException e) {\n logging.StackTrace(e.getStackTrace(), Thread.currentThread().getStackTrace()[1].getMethodName(), Thread.currentThread().getStackTrace()[1].getLineNumber(), Thread.currentThread().getStackTrace()[1].getClassName(), Thread.currentThread().getStackTrace()[1].getFileName());\n }\n String cache = stringBuffer.toString();\n String thehash = forumCacheValue(cache, \"hash\");\n EBean.checkPassword(player, thehash);\n return true;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncsalt\") && !Config.custom_enabled && saltfield != null && saltfield != \"\") {\n String userid = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`user_id`\", \"username\", player);\n Blob hash = MySQL.getfromtableBlob(Config.script_tableprefix + \"user_authenticate\", \"`data`\", \"user_id\", userid);\n int offset = -1;\n int chunkSize = 1024;\n long blobLength = hash.length();\n if (chunkSize > blobLength) {\n chunkSize = (int) blobLength;\n }\n char buffer[] = new char[chunkSize];\n StringBuilder stringBuffer = new StringBuilder();\n Reader reader = new InputStreamReader(hash.getBinaryStream());\n try {\n while ((offset = reader.read(buffer)) != -1) {\n stringBuffer.append(buffer, 0, offset);\n }\n } catch (IOException e) {\n logging.StackTrace(e.getStackTrace(),\n Thread.currentThread().getStackTrace()[1].getMethodName(),\n Thread.currentThread().getStackTrace()[1].getLineNumber(),\n Thread.currentThread().getStackTrace()[1].getClassName(),\n Thread.currentThread().getStackTrace()[1].getFileName());\n }\n String cache = stringBuffer.toString();\n String thesalt = forumCacheValue(cache, \"salt\");\n EBean.checkSalt(player, thesalt);\n return true;\n }\n } else if (script.equalsIgnoreCase(BBPress.Name) || script.equalsIgnoreCase(BBPress.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(BBPress.VersionRange)) {\n usernamefield = \"user_login\";\n passwordfield = \"user_pass\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && BBPress.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (BBPress.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n BBPress.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(DLE.Name) || script.equalsIgnoreCase(DLE.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(DLE.VersionRange)) {\n usernamefield = \"name\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && DLE.check_hash(DLE.hash(password), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (DLE.check_hash(DLE.hash(password), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n DLE.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(IPB.Name) || script.equalsIgnoreCase(IPB.ShortName)) {\n usertable = \"members\";\n if (checkVersionInRange(IPB.VersionRange)) {\n saltfield = \"members_pass_salt\";\n usernamefield = \"members_l_username\";\n passwordfield = \"members_pass_hash\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && IPB.check_hash(IPB.hash(\"find\", player, password.toLowerCase(), null), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player.toLowerCase());\n EBean.checkPassword(player, hash);\n if (IPB.check_hash(IPB.hash(\"find\", player.toLowerCase(), password, null), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n IPB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(WordPress.Name) || script.equalsIgnoreCase(WordPress.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(WordPress.VersionRange)) {\n usernamefield = \"user_login\";\n passwordfield = \"user_pass\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && WordPress.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (WordPress.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n WordPress.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } \n if (!Config.hasForumBoard) {\n if (!Config.custom_enabled) {\n String tempVers = Config.script_version;\n Config.script_version = scriptVersion();\n logging.Info(System.getProperty(\"line.separator\")\n + \"|-----------------------------------------------------------------------------|\" + System.getProperty(\"line.separator\")\n + \"|--------------------------------AUTHDB WARNING-------------------------------|\" + System.getProperty(\"line.separator\")\n + \"|-----------------------------------------------------------------------------|\" + System.getProperty(\"line.separator\")\n + \"| COULD NOT FIND A COMPATIBLE SCRIPT VERSION! |\" + System.getProperty(\"line.separator\")\n + \"| PLEASE CHECK YOUR SCRIPT VERSION AND TRY AGAIN. PLUGIN MAY OR MAY NOT WORK. |\" + System.getProperty(\"line.separator\")\n + \"| YOUR SCRIPT VERSION FOR \" + Config.script_name + \" HAS BEEN SET FROM \" + tempVers + \" TO \" + Config.script_version + \" |\" + System.getProperty(\"line.separator\")\n + \"| FOR A LIST OF SCRIPT VERSIONS, |\" + System.getProperty(\"line.separator\")\n + \"| CHECK: http://wiki.bukkit.org/AuthDB#Scripts_Supported |\" + System.getProperty(\"line.separator\")\n + \"|-----------------------------------------------------------------------------|\");\n }\n }\n if (!caseSensitive && player != null) {\n player = player.toLowerCase();\n }\n if (Config.hasForumBoard && type.equalsIgnoreCase(\"checkuser\") && !Config.custom_enabled) {\n String check = MySQL.getfromtable(Config.script_tableprefix + usertable, \"*\", usernamefield, player);\n if (check != \"fail\") { return true; }\n return false;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"numusers\") && !Config.custom_enabled) {\n if (script.equalsIgnoreCase(PhpBB.Name) || script.equalsIgnoreCase(PhpBB.ShortName)) {\n ps = (PreparedStatement) MySQL.mysql.prepareStatement(\"SELECT COUNT(*) as `countit` FROM `\"\n + Config.script_tableprefix + usertable + \"` WHERE `group_id` !=6\");\n } else {\n ps = (PreparedStatement) MySQL.mysql.prepareStatement(\"SELECT COUNT(*) as `countit` FROM `\"\n + Config.script_tableprefix + usertable + \"`\");\n }\n ResultSet rs = ps.executeQuery();\n if (rs.next()) { logging.Info(rs.getInt(\"countit\") + \" user registrations in database\"); }\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncpassword\") && !Config.custom_enabled) {\n String hash = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`\" + passwordfield + \"`\", usernamefield, player);\n EBean.checkPassword(player, hash);\n return true;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncsalt\") && !Config.custom_enabled && saltfield != null && saltfield != \"\") {\n String salt = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`\" + saltfield + \"`\", usernamefield, player);\n EBean.checkSalt(player, salt);\n return true;\n }\n }\n", "output": " public static boolean checkScript(String type, String script, String player, String password,\n String email, String ipAddress) throws SQLException {\n boolean caseSensitive = false;\n if (Util.databaseManager.getDatabaseType().equalsIgnoreCase(\"ebean\")) {\n EBean eBeanClass = EBean.checkPlayer(player, true);\n if (type.equalsIgnoreCase(\"checkuser\")) {\n if (eBeanClass.getRegistered().equalsIgnoreCase(\"true\")) {\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"checkpassword\")) {\n String storedPassword = eBeanClass.getPassword();\n if (Encryption.SHA512(password).equals(storedPassword)) {\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"adduser\")) {\n Custom.adduser(player, email, password, ipAddress);\n eBeanClass.setEmail(email);\n eBeanClass.setPassword(Encryption.SHA512(password));\n eBeanClass.setRegistered(\"true\");\n eBeanClass.setIp(ipAddress);\n } else if (type.equalsIgnoreCase(\"numusers\")) {\n int amount = EBean.getUsers();\n logging.Info(amount + \" user registrations in database\");\n }\n } else if (Config.database_ison) {\n String usertable = null, usernamefield = null, passwordfield = null, saltfield = \"\";\n boolean bans = false;\n PreparedStatement ps = null;\n int number = 0;\n if (Config.custom_enabled) {\n if (type.equalsIgnoreCase(\"checkuser\")) {\n String check = MySQL.getfromtable(Config.custom_table, \"*\", Config.custom_userfield, player);\n if (check != \"fail\") {\n Config.hasForumBoard = true;\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (Custom.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.custom_table, \"`\" + Config.custom_passfield + \"`\", \"\" + Config.custom_userfield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Custom.check_hash(password, hash)) {\n return true;\n }\n return false;\n } else if (type.equalsIgnoreCase(\"syncpassword\")) {\n String hash = MySQL.getfromtable(Config.custom_table, \"`\" + Config.custom_passfield + \"`\", \"\" + Config.custom_userfield + \"\", player);\n EBean.checkPassword(player, hash);\n return true;\n } else if (type.equalsIgnoreCase(\"adduser\")) {\n Custom.adduser(player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n } else if (type.equalsIgnoreCase(\"numusers\")) {\n ps = (PreparedStatement) MySQL.mysql.prepareStatement(\"SELECT COUNT(*) as `countit` FROM `\" + Config.custom_table + \"`\");\n ResultSet rs = ps.executeQuery();\n if (rs.next()) {\n logging.Info(rs.getInt(\"countit\") + \" user registrations in database\");\n }\n }\n } else if (script.equalsIgnoreCase(PhpBB.Name) || script.equalsIgnoreCase(PhpBB.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(PhpBB.VersionRange)) {\n usernamefield = \"username_clean\";\n passwordfield = \"user_password\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && PhpBB.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player.toLowerCase());\n EBean.checkPassword(player, hash);\n if (PhpBB.check_hash(password, hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(PhpBB.VersionRange2)) {\n usernamefield = \"username_clean\"; \n passwordfield = \"user_password\";\n Config.hasForumBoard = true;\n bans = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && PhpBB.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player.toLowerCase());\n EBean.checkPassword(player, hash);\n if (PhpBB.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n PhpBB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(SMF.Name) || script.equalsIgnoreCase(SMF.ShortName)) {\n usertable = \"members\";\n if (checkVersionInRange(SMF.VersionRange)) {\n usernamefield = \"memberName\";\n passwordfield = \"passwd\";\n saltfield = \"passwordSalt\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n bans = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && SMF.check_hash(SMF.hash(1, player, password), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (SMF.check_hash(SMF.hash(1, player, password), hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(SMF.VersionRange2) || checkVersionInRange(\"2.0-2.0\")\n || checkVersionInRange(\"2.0.0-2.0.0\")) {\n usernamefield = \"member_name\";\n passwordfield = \"passwd\";\n saltfield = \"password_salt\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n bans = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && SMF.check_hash(SMF.hash(2, player, password), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (SMF.check_hash(SMF.hash(2, player, password), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n SMF.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(MyBB.Name) || script.equalsIgnoreCase(MyBB.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(MyBB.VersionRange)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n bans = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && MyBB.check_hash(MyBB.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (MyBB.check_hash(MyBB.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n MyBB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(VBulletin.Name) || script.equalsIgnoreCase(VBulletin.ShortName)) {\n usertable = \"user\";\n if (checkVersionInRange(VBulletin.VersionRange)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n bans = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(VBulletin.VersionRange2)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n bans = true;\n number = 2;\n caseSensitive = true;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (VBulletin.check_hash(VBulletin.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n VBulletin.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(Drupal.Name) || script.equalsIgnoreCase(Drupal.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(Drupal.VersionRange)) {\n usernamefield = \"name\";\n passwordfield = \"pass\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Encryption.md5(password).equals(storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Encryption.md5(password).equals(hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(Drupal.VersionRange2)) {\n usernamefield = \"name\";\n passwordfield = \"pass\";\n Config.hasForumBoard = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && storedPassword.equals(Drupal.user_check_password(password, storedPassword))) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (hash.equals(Drupal.user_check_password(password, hash))) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n Drupal.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(Joomla.Name) || script.equalsIgnoreCase(Joomla.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(Joomla.VersionRange)) {\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Joomla.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Joomla.check_hash(password, hash)) {\n return true;\n }\n }\n } else if (checkVersionInRange(Joomla.VersionRange2)) {\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 2;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Joomla.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Joomla.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n Joomla.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(Vanilla.Name) || script.equalsIgnoreCase(Vanilla.ShortName)) {\n if (checkVersionInRange(Vanilla.VersionRange)) {\n usertable = \"User\";\n usernamefield = \"Name\";\n passwordfield = \"Password\";\n caseSensitive = true;\n if (Vanilla.check() == 2) {\n usertable = usertable.toLowerCase();\n }\n Config.hasForumBoard = true;\n number = Vanilla.check();\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && Vanilla.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (Vanilla.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n String emailcheck = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`\" + usernamefield + \"`\", \"Email\", email);\n if (emailcheck.equalsIgnoreCase(\"fail\")) {\n Vanilla.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n return false;\n }\n } else if (script.equalsIgnoreCase(PunBB.Name) || script.equalsIgnoreCase(PunBB.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(PunBB.VersionRange)) {\n saltfield = \"salt\";\n usernamefield = \"username\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && PunBB.check_hash(PunBB.hash(\"find\", player, password, \"\"), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (PunBB.check_hash(PunBB.hash(\"find\", player, password, \"\"), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n PunBB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(XenForo.Name) || script.equalsIgnoreCase(XenForo.ShortName)) {\n usertable = \"user\";\n if (checkVersionInRange(XenForo.VersionRange)) {\n String userid = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`user_id`\", \"username\", player);\n usernamefield = \"username\";\n passwordfield = \"password\";\n caseSensitive = true;\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n Blob hash = MySQL.getfromtableBlob(Config.script_tableprefix + \"user_authenticate\", \"`data`\", \"user_id\", userid);\n if (hash != null) {\n int offset = -1;\n int chunkSize = 1024;\n long blobLength = hash.length();\n if (chunkSize > blobLength) {\n chunkSize = (int) blobLength;\n }\n char buffer[] = new char[chunkSize];\n StringBuilder stringBuffer = new StringBuilder();\n Reader reader = new InputStreamReader(hash.getBinaryStream());\n try {\n while ((offset = reader.read(buffer)) != -1) {\n stringBuffer.append(buffer, 0, offset);\n }\n } catch (IOException e) {\n logging.StackTrace(e.getStackTrace(), Thread.currentThread().getStackTrace()[1].getMethodName(), Thread.currentThread().getStackTrace()[1].getLineNumber(), Thread.currentThread().getStackTrace()[1].getClassName(), Thread.currentThread().getStackTrace()[1].getFileName());\n }\n String cache = stringBuffer.toString();\n String thehash = forumCacheValue(cache, \"hash\");\n String thesalt = forumCacheValue(cache, \"salt\");\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n String storedSalt = eBeanClass.getSalt();\n if (storedPassword != null && storedSalt != null && XenForo.check_hash(XenForo.hash(1, storedSalt, password), storedPassword)) {\n return true;\n }\n EBean.checkSalt(player, thesalt);\n EBean.checkPassword(player, thehash);\n if (XenForo.check_hash(XenForo.hash(1, thesalt, password), thehash)) {\n return true;\n }\n } else {\n return false;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n XenForo.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncpassword\") && !Config.custom_enabled) {\n String userid = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`user_id`\", \"username\", player);\n Blob hash = MySQL.getfromtableBlob(Config.script_tableprefix + \"user_authenticate\", \"`data`\", \"user_id\", userid);\n int offset = -1;\n int chunkSize = 1024;\n long blobLength = hash.length();\n if (chunkSize > blobLength) {\n chunkSize = (int) blobLength;\n }\n char buffer[] = new char[chunkSize];\n StringBuilder stringBuffer = new StringBuilder();\n Reader reader = new InputStreamReader(hash.getBinaryStream());\n try {\n while ((offset = reader.read(buffer)) != -1) {\n stringBuffer.append(buffer, 0, offset);\n }\n } catch (IOException e) {\n logging.StackTrace(e.getStackTrace(), Thread.currentThread().getStackTrace()[1].getMethodName(), Thread.currentThread().getStackTrace()[1].getLineNumber(), Thread.currentThread().getStackTrace()[1].getClassName(), Thread.currentThread().getStackTrace()[1].getFileName());\n }\n String cache = stringBuffer.toString();\n String thehash = forumCacheValue(cache, \"hash\");\n EBean.checkPassword(player, thehash);\n return true;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncsalt\") && !Config.custom_enabled && saltfield != null && saltfield != \"\") {\n String userid = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`user_id`\", \"username\", player);\n Blob hash = MySQL.getfromtableBlob(Config.script_tableprefix + \"user_authenticate\", \"`data`\", \"user_id\", userid);\n int offset = -1;\n int chunkSize = 1024;\n long blobLength = hash.length();\n if (chunkSize > blobLength) {\n chunkSize = (int) blobLength;\n }\n char buffer[] = new char[chunkSize];\n StringBuilder stringBuffer = new StringBuilder();\n Reader reader = new InputStreamReader(hash.getBinaryStream());\n try {\n while ((offset = reader.read(buffer)) != -1) {\n stringBuffer.append(buffer, 0, offset);\n }\n } catch (IOException e) {\n logging.StackTrace(e.getStackTrace(),\n Thread.currentThread().getStackTrace()[1].getMethodName(),\n Thread.currentThread().getStackTrace()[1].getLineNumber(),\n Thread.currentThread().getStackTrace()[1].getClassName(),\n Thread.currentThread().getStackTrace()[1].getFileName());\n }\n String cache = stringBuffer.toString();\n String thesalt = forumCacheValue(cache, \"salt\");\n EBean.checkSalt(player, thesalt);\n return true;\n }\n } else if (script.equalsIgnoreCase(BBPress.Name) || script.equalsIgnoreCase(BBPress.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(BBPress.VersionRange)) {\n usernamefield = \"user_login\";\n passwordfield = \"user_pass\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && BBPress.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (BBPress.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n BBPress.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(DLE.Name) || script.equalsIgnoreCase(DLE.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(DLE.VersionRange)) {\n usernamefield = \"name\";\n passwordfield = \"password\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && DLE.check_hash(DLE.hash(password), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\",\n \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (DLE.check_hash(DLE.hash(password), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n DLE.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(IPB.Name) || script.equalsIgnoreCase(IPB.ShortName)) {\n usertable = \"members\";\n if (checkVersionInRange(IPB.VersionRange)) {\n usernamefield = \"members_l_username\";\n passwordfield = \"members_pass_hash\";\n saltfield = \"members_pass_salt\";\n Config.hasForumBoard = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && IPB.check_hash(IPB.hash(\"find\", player, password.toLowerCase(), null), storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player.toLowerCase());\n EBean.checkPassword(player, hash);\n if (IPB.check_hash(IPB.hash(\"find\", player.toLowerCase(), password, null), hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n IPB.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } else if (script.equalsIgnoreCase(WordPress.Name) || script.equalsIgnoreCase(WordPress.ShortName)) {\n usertable = \"users\";\n if (checkVersionInRange(WordPress.VersionRange)) {\n usernamefield = \"user_login\";\n passwordfield = \"user_pass\";\n Config.hasForumBoard = true;\n caseSensitive = true;\n number = 1;\n if (type.equalsIgnoreCase(\"checkpassword\")) {\n EBean eBeanClass = EBean.find(player);\n String storedPassword = eBeanClass.getPassword();\n if (storedPassword != null && WordPress.check_hash(password, storedPassword)) {\n return true;\n }\n String hash = MySQL.getfromtable(Config.script_tableprefix + \"\" + usertable + \"\", \"`\" + passwordfield + \"`\", \"\" + usernamefield + \"\", player);\n EBean.checkPassword(player, hash);\n if (WordPress.check_hash(password, hash)) {\n return true;\n }\n }\n }\n if (type.equalsIgnoreCase(\"adduser\")) {\n WordPress.adduser(number, player, email, password, ipAddress);\n EBean.sync(player);\n return true;\n }\n } \n if (!Config.hasForumBoard) {\n if (!Config.custom_enabled) {\n String tempVers = Config.script_version;\n Config.script_version = scriptVersion();\n logging.Info(System.getProperty(\"line.separator\")\n + \"|-----------------------------------------------------------------------------|\" + System.getProperty(\"line.separator\")\n + \"|--------------------------------AUTHDB WARNING-------------------------------|\" + System.getProperty(\"line.separator\")\n + \"|-----------------------------------------------------------------------------|\" + System.getProperty(\"line.separator\")\n + \"| COULD NOT FIND A COMPATIBLE SCRIPT VERSION! |\" + System.getProperty(\"line.separator\")\n + \"| PLEASE CHECK YOUR SCRIPT VERSION AND TRY AGAIN. PLUGIN MAY OR MAY NOT WORK. |\" + System.getProperty(\"line.separator\")\n + \"| YOUR SCRIPT VERSION FOR \" + Config.script_name + \" HAS BEEN SET FROM \" + tempVers + \" TO \" + Config.script_version + \" |\" + System.getProperty(\"line.separator\")\n + \"| FOR A LIST OF SCRIPT VERSIONS, |\" + System.getProperty(\"line.separator\")\n + \"| CHECK: http://wiki.bukkit.org/AuthDB#Scripts_Supported |\" + System.getProperty(\"line.separator\")\n + \"|-----------------------------------------------------------------------------|\");\n }\n }\n if (!caseSensitive && player != null) {\n player = player.toLowerCase();\n }\n if (Config.hasForumBoard && type.equalsIgnoreCase(\"checkuser\") && !Config.custom_enabled) {\n String check = MySQL.getfromtable(Config.script_tableprefix + usertable, \"*\", usernamefield, player);\n if (check != \"fail\") { return true; }\n return false;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"numusers\") && !Config.custom_enabled) {\n if (script.equalsIgnoreCase(PhpBB.Name) || script.equalsIgnoreCase(PhpBB.ShortName)) {\n ps = (PreparedStatement) MySQL.mysql.prepareStatement(\"SELECT COUNT(*) as `countit` FROM `\"\n + Config.script_tableprefix + usertable + \"` WHERE `group_id` !=6\");\n } else {\n ps = (PreparedStatement) MySQL.mysql.prepareStatement(\"SELECT COUNT(*) as `countit` FROM `\"\n + Config.script_tableprefix + usertable + \"`\");\n }\n ResultSet rs = ps.executeQuery();\n if (rs.next()) { logging.Info(rs.getInt(\"countit\") + \" user registrations in database\"); }\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncpassword\") && !Config.custom_enabled) {\n String hash = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`\" + passwordfield + \"`\", usernamefield, player);\n EBean.checkPassword(player, hash);\n return true;\n } else if (Config.hasForumBoard && type.equalsIgnoreCase(\"syncsalt\") && !Config.custom_enabled && saltfield != null && saltfield != \"\") {\n String salt = MySQL.getfromtable(Config.script_tableprefix + usertable, \"`\" + saltfield + \"`\", usernamefield, player);\n EBean.checkSalt(player, salt);\n return true;\n }\n }\n"} {"input": "\tpublic static String mol2AdjList (String inchi, String filePath) {\n FileReader in = null;\n\t\ttry {\n\t\t\tin = new FileReader(filePath);\n\t\t} catch (FileNotFoundException e) {\n\t\t\tString err = \"Error reading .mol file: \" + e.toString();\n\t\t\tSystem.out.println(err);\n\t\t}\n\t\tBufferedReader reader = new BufferedReader(in);\n\t\tString line = ChemParser.readMeaningfulLine(reader, true);\n\t\twhile (!line.toUpperCase().endsWith(\"V2000\")) {\n\t\t\tline = ChemParser.readMeaningfulLine(reader, true);\n\t\t}\n\t\tString molFile = \"\";\n\t\twhile (line != null) {\n\t\t\tmolFile += line + \"\\r\";\n\t\t\tline = ChemParser.readMeaningfulLine(reader, true);\n\t\t}\n\t\tString[] molFileLines = molFile.split(\"[\\r]\",0);\n\t\tint numOfLines = molFileLines.length;\n\t\tStringTokenizer st = new StringTokenizer(molFileLines[numOfLines-1]);\n\t\tif (st.nextToken().equals(\"$$$$\")) --numOfLines;\n\t\tst = new StringTokenizer(molFileLines[0]);\n\t\tint numOfAtoms = Integer.parseInt(st.nextToken());\n\t\tint numOfBonds = Integer.parseInt(st.nextToken());\n\t\tint numOfAtomLists = Integer.parseInt(st.nextToken());\n\t\tString obsoleteString1 = st.nextToken();\n\t\tString chiralFlag = st.nextToken();\n\t\tint stextEntries = Integer.parseInt(st.nextToken());\n\t\tString obsoleteString2 = st.nextToken();\n\t\tString obsoleteString3 = st.nextToken();\n\t\tString obsoleteString4 = st.nextToken();\n\t\tString obsoleteString5 = st.nextToken();\n\t\tint numOfMLines = Integer.parseInt(st.nextToken());\n\t\tString[] adjListElement = new String[numOfAtoms];\n\t\tString[] adjListRadical = new String[numOfAtoms];\n\t\tString[] adjListConnectivity = new String[numOfAtoms];\n\t\tfor (int i=0; i> scan(ClassLoader classLoader, String dataFolder) {\n\t\tfinal ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(classLoader);\n\t\tfinal List locationPatterns = ImmutableList.of(\"classpath*:org/**/*.\" + suppliedClassSimpleName + \".xmi\",\n\t\t\t\t\"classpath*:com/**/*.\" + suppliedClassSimpleName + \".xmi\",\n\t\t\t\t\"classpath*:id/**/*.\" + suppliedClassSimpleName +\".xmi\",\n\t\t\t\t\"file:\" + dataFolder + \"/common/*.\" + suppliedClassSimpleName +\".xmi\");\n\t\tlog.trace(\"Scanning {} for {}\", classLoader, locationPatterns);\n\t\ttry {\n\t\t\tfinal List allResources = new ArrayList<>();\n\t\t\tfor (String locationPattern : locationPatterns) {\n\t\t\t\tfinal Resource[] resources = resolver.getResources(locationPattern);\n\t\t\t\tallResources.addAll(ImmutableList.copyOf(resources));\n\t\t\t}\n\t\t\tlog.info(\"Scanned {} returned {} resources: {}\",\n\t\t\t\t\tlocationPatterns, allResources.size(), allResources);\n\t\t\tfinal List xmiUrls = ImmutableList.copyOf(Lists.transform(\n\t\t\t\t\tallResources, new Function() {\n\t\t\t\t@Override @Nullable\n\t\t\t\tpublic URL apply(@Nullable Resource input) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn input.getURL();\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tthrow new CommonsException(\"Cannot get URL for \" + input, e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}));\n\t\t\tfinal Map>> managedSuppliers = new HashMap<>();\n\t\t\tfor (URL xmiUrl : xmiUrls) {\n\t\t\t\tfinal List> objs = Preconditions.checkNotNull(extractSuppliers(ImmutableList.of(xmiUrl)),\n\t\t\t\t\t\t\"extractSuppliers from %s returned null\", xmiUrl);\n\t\t\t\tmanagedSuppliers.put(xmiUrl.toString(), objs);\n\t\t\t}\n\t\t\tfinal List> scannedSuppliers = ImmutableList.copyOf(Iterables.concat(managedSuppliers.values()));\n\t\t\treturn scannedSuppliers;\n\t\t} catch (IOException e) {\n\t\t\tthrow new CommonsException(e, \"Cannot scan %s for %s\",\n\t\t\t\t\tclassLoader, locationPatterns);\n\t\t}\n\t}\n", "output": "\tpublic List> scan(ClassLoader classLoader, String dataFolder) {\n\t\tfinal ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(classLoader);\n\t\tfinal List locationPatterns = ImmutableList.of(\"classpath*:org/**/*.\" + suppliedClassSimpleName + \".xmi\",\n\t\t\t\t\"classpath*:com/**/*.\" + suppliedClassSimpleName + \".xmi\",\n\t\t\t\t\"classpath*:id/**/*.\" + suppliedClassSimpleName +\".xmi\",\n\t\t\t\t\"file:\" + dataFolder + \"/common/*.\" + suppliedClassSimpleName +\".xmi\");\n\t\tlog.trace(\"Scanning {} for {}\", classLoader, locationPatterns);\n\t\ttry {\n\t\t\tfinal List allResources = new ArrayList<>();\n\t\t\tfor (String locationPattern : locationPatterns) {\n\t\t\t\tfinal Resource[] resources = resolver.getResources(locationPattern);\n\t\t\t\tallResources.addAll(ImmutableList.copyOf(resources));\n\t\t\t}\n\t\t\tlog.info(\"Scanned {} returned {} resources: {}\",\n\t\t\t\t\tlocationPatterns, allResources.size(), allResources);\n\t\t\tfinal List xmiUrls = ImmutableList.copyOf(Lists.transform(\n\t\t\t\t\tallResources, new Function() {\n\t\t\t\t@Override @Nullable\n\t\t\t\tpublic URL apply(@Nullable Resource input) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn input.getURL();\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tthrow new CommonsException(\"Cannot get URL for \" + input, e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}));\n\t\t\tfinal Map>> managedSuppliers = new HashMap<>();\n\t\t\tfor (URL xmiUrl : xmiUrls) {\n\t\t\t\tfinal List> objs = Preconditions.checkNotNull(extractSuppliers(ImmutableList.of(xmiUrl)),\n\t\t\t\t\t\t\"extractSuppliers from '%s' returned null\", xmiUrl);\n\t\t\t\tmanagedSuppliers.put(xmiUrl.toString(), objs);\n\t\t\t}\n\t\t\tfinal List> scannedSuppliers = ImmutableList.copyOf(Iterables.concat(managedSuppliers.values()));\n\t\t\treturn scannedSuppliers;\n\t\t} catch (IOException e) {\n\t\t\tthrow new CommonsException(e, \"Cannot scan %s for %s\",\n\t\t\t\t\tclassLoader, locationPatterns);\n\t\t}\n\t}\n"} {"input": "\tpublic void testXMLInjectedPointHyperlinkDetector() throws Exception {\n\t\tArrayList regionList = new ArrayList();\n\t\tregionList.add(new TestRegion(2166, 15, new TestHyperlink[]{\n\t\t\t\tnew TestHyperlink(InjectedPointHyperlink.class, CDIExtensionsMessages.CDI_INJECTED_POINT_HYPERLINK_OPEN_INJECT_BEAN+ \" MyBean6.myType6\")\n\t\t}));\n\t\tCDIHyperlinkTestUtil.checkRegions(project, FILENAME, regionList, new XMLInjectedPointHyperlinkDetector());\n\t}\n", "output": "\tpublic void testXMLInjectedPointHyperlinkDetector() throws Exception {\n\t\tArrayList regionList = new ArrayList();\n\t\tregionList.add(new TestRegion(\"= 2 && getToken(-2).getType() == Token.DOT ||\n getToken(0).getType() == Token.OBJECTLIT) {\n result.append(symbol);\n } else {\n identifier = getIdentifier(symbol, currentScope);\n if (identifier != null) {\n if (identifier.getMungedValue() != null) {\n result.append(identifier.getMungedValue());\n } else {\n result.append(symbol);\n }\n if (currentScope != globalScope && identifier.getRefcount() == 0) {\n warn(\"The symbol \" + symbol + \" is declared but is apparently never used.\\nThis code can probably be written in a more compact way.\", true);\n }\n } else {\n result.append(symbol);\n }\n }\n break;\n case Token.REGEXP:\n case Token.NUMBER:\n case Token.STRING:\n result.append(symbol);\n break;\n case Token.ADD:\n case Token.SUB:\n result.append((String) literals.get(new Integer(token.getType())));\n if (offset < length) {\n token = getToken(0);\n if (token.getType() == Token.INC ||\n token.getType() == Token.DEC ||\n token.getType() == Token.ADD ||\n token.getType() == Token.DEC) {\n result.append(' ');\n } else if (token.getType() == Token.POS && getToken(-1).getType() == Token.ADD ||\n token.getType() == Token.NEG && getToken(-1).getType() == Token.SUB) {\n result.append(' ');\n }\n }\n break;\n case Token.FUNCTION:\n if (lastToken.getType() != Token.GET && lastToken.getType() != Token.SET) {\n result.append(\"function\");\n }\n token = consumeToken();\n if (token.getType() == Token.NAME) {\n result.append(' ');\n symbol = token.getValue();\n identifier = getIdentifier(symbol, currentScope);\n assert identifier != null;\n if (identifier.getMungedValue() != null) {\n result.append(identifier.getMungedValue());\n } else {\n result.append(symbol);\n }\n if (currentScope != globalScope && identifier.getRefcount() == 0) {\n warn(\"The symbol \" + symbol + \" is declared but is apparently never used.\\nThis code can probably be written in a more compact way.\", true);\n }\n token = consumeToken();\n }\n assert token.getType() == Token.LP;\n result.append('(');\n currentScope = (ScriptOrFnScope) indexedScopes.get(new Integer(offset));\n enterScope(currentScope);\n while ((token = consumeToken()).getType() != Token.RP) {\n assert token.getType() == Token.NAME || token.getType() == Token.COMMA;\n if (token.getType() == Token.NAME) {\n symbol = token.getValue();\n identifier = getIdentifier(symbol, currentScope);\n assert identifier != null;\n if (identifier.getMungedValue() != null) {\n result.append(identifier.getMungedValue());\n } else {\n result.append(symbol);\n }\n } else if (token.getType() == Token.COMMA) {\n result.append(',');\n }\n }\n result.append(')');\n token = consumeToken();\n assert token.getType() == Token.LC;\n result.append('{');\n braceNesting++;\n token = getToken(0);\n if (token.getType() == Token.STRING &&\n getToken(1).getType() == Token.SEMI) {\n consumeToken();\n consumeToken();\n }\n break;\n case Token.RETURN:\n case Token.TYPEOF:\n result.append(literals.get(new Integer(token.getType())));\n if (offset < length) {\n token = getToken(0);\n if (token.getType() != Token.LP &&\n token.getType() != Token.LB &&\n token.getType() != Token.LC &&\n token.getType() != Token.STRING &&\n token.getType() != Token.REGEXP &&\n token.getType() != Token.SEMI) {\n result.append(' ');\n }\n }\n break;\n case Token.CASE:\n case Token.THROW:\n result.append(literals.get(new Integer(token.getType())));\n if (offset < length && getToken(0).getType() != Token.STRING) {\n result.append(' ');\n }\n break;\n case Token.BREAK:\n case Token.CONTINUE:\n result.append(literals.get(new Integer(token.getType())));\n if (offset < length && getToken(0).getType() != Token.SEMI) {\n result.append(' ');\n }\n break;\n case Token.LC:\n result.append('{');\n braceNesting++;\n break;\n case Token.RC:\n result.append('}');\n braceNesting--;\n assert braceNesting >= currentScope.getBraceNesting();\n if (braceNesting == currentScope.getBraceNesting()) {\n leaveCurrentScope();\n }\n break;\n case Token.SEMI:\n if (preserveAllSemiColons || offset < length && getToken(0).getType() != Token.RC) {\n result.append(';');\n }\n if (linebreakpos >= 0 && result.length() - linestartpos > linebreakpos) {\n result.append('\\n');\n linestartpos = result.length();\n }\n break;\n case Token.CONDCOMMENT:\n case Token.KEEPCOMMENT:\n if (result.length() > 0 && result.charAt(result.length() - 1) != '\\n') {\n result.append(\"\\n\");\n }\n result.append(\"/*\");\n result.append(symbol);\n result.append(\"*/\\n\");\n break;\n default:\n String literal = (String) literals.get(new Integer(token.getType()));\n if (literal != null) {\n result.append(literal);\n } else {\n warn(\"This symbol cannot be printed: \" + symbol, true);\n }\n break;\n }\n }\n if (!preserveAllSemiColons &&\n result.length() > 0 &&\n getToken(-1).getType() != Token.CONDCOMMENT &&\n getToken(-1).getType() != Token.KEEPCOMMENT) {\n if (result.charAt(result.length() - 1) == '\\n') {\n result.setCharAt(result.length() - 1, ';');\n } else {\n result.append(';');\n }\n }\n return result;\n }\n", "output": " private StringBuffer printSymbolTree(int linebreakpos, boolean preserveAllSemiColons)\n throws IOException {\n offset = 0;\n braceNesting = 0;\n scopes.clear();\n String symbol;\n JavaScriptToken token;\n JavaScriptToken lastToken = getToken(0);\n ScriptOrFnScope currentScope;\n JavaScriptIdentifier identifier;\n int length = tokens.size();\n StringBuffer result = new StringBuffer();\n int linestartpos = 0;\n enterScope(globalScope);\n while (offset < length) {\n token = consumeToken();\n symbol = token.getValue();\n currentScope = getCurrentScope();\n switch (token.getType()) {\n case Token.GET:\n case Token.SET:\n lastToken = token;\n case Token.NAME:\n if (offset >= 2 && getToken(-2).getType() == Token.DOT ||\n getToken(0).getType() == Token.OBJECTLIT) {\n result.append(symbol);\n } else {\n identifier = getIdentifier(symbol, currentScope);\n if (identifier != null) {\n if (identifier.getMungedValue() != null) {\n result.append(identifier.getMungedValue());\n } else {\n result.append(symbol);\n }\n if (currentScope != globalScope && identifier.getRefcount() == 0) {\n warn(\"The symbol \" + symbol + \" is declared but is apparently never used.\\nThis code can probably be written in a more compact way.\", true);\n }\n } else {\n result.append(symbol);\n }\n }\n break;\n case Token.REGEXP:\n case Token.NUMBER:\n case Token.STRING:\n result.append(symbol);\n break;\n case Token.ADD:\n case Token.SUB:\n result.append((String) literals.get(new Integer(token.getType())));\n if (offset < length) {\n token = getToken(0);\n if (token.getType() == Token.INC ||\n token.getType() == Token.DEC ||\n token.getType() == Token.ADD ||\n token.getType() == Token.DEC) {\n result.append(' ');\n } else if (token.getType() == Token.POS && getToken(-1).getType() == Token.ADD ||\n token.getType() == Token.NEG && getToken(-1).getType() == Token.SUB) {\n result.append(' ');\n }\n }\n break;\n case Token.FUNCTION:\n if (lastToken.getType() != Token.GET && lastToken.getType() != Token.SET) {\n result.append(\"function\");\n }\n lastToken = token;\n token = consumeToken();\n if (token.getType() == Token.NAME) {\n result.append(' ');\n symbol = token.getValue();\n identifier = getIdentifier(symbol, currentScope);\n assert identifier != null;\n if (identifier.getMungedValue() != null) {\n result.append(identifier.getMungedValue());\n } else {\n result.append(symbol);\n }\n if (currentScope != globalScope && identifier.getRefcount() == 0) {\n warn(\"The symbol \" + symbol + \" is declared but is apparently never used.\\nThis code can probably be written in a more compact way.\", true);\n }\n token = consumeToken();\n }\n assert token.getType() == Token.LP;\n result.append('(');\n currentScope = (ScriptOrFnScope) indexedScopes.get(new Integer(offset));\n enterScope(currentScope);\n while ((token = consumeToken()).getType() != Token.RP) {\n assert token.getType() == Token.NAME || token.getType() == Token.COMMA;\n if (token.getType() == Token.NAME) {\n symbol = token.getValue();\n identifier = getIdentifier(symbol, currentScope);\n assert identifier != null;\n if (identifier.getMungedValue() != null) {\n result.append(identifier.getMungedValue());\n } else {\n result.append(symbol);\n }\n } else if (token.getType() == Token.COMMA) {\n result.append(',');\n }\n }\n result.append(')');\n token = consumeToken();\n assert token.getType() == Token.LC;\n result.append('{');\n braceNesting++;\n token = getToken(0);\n if (token.getType() == Token.STRING &&\n getToken(1).getType() == Token.SEMI) {\n consumeToken();\n consumeToken();\n }\n break;\n case Token.RETURN:\n case Token.TYPEOF:\n result.append(literals.get(new Integer(token.getType())));\n if (offset < length) {\n token = getToken(0);\n if (token.getType() != Token.LP &&\n token.getType() != Token.LB &&\n token.getType() != Token.LC &&\n token.getType() != Token.STRING &&\n token.getType() != Token.REGEXP &&\n token.getType() != Token.SEMI) {\n result.append(' ');\n }\n }\n break;\n case Token.CASE:\n case Token.THROW:\n result.append(literals.get(new Integer(token.getType())));\n if (offset < length && getToken(0).getType() != Token.STRING) {\n result.append(' ');\n }\n break;\n case Token.BREAK:\n case Token.CONTINUE:\n result.append(literals.get(new Integer(token.getType())));\n if (offset < length && getToken(0).getType() != Token.SEMI) {\n result.append(' ');\n }\n break;\n case Token.LC:\n result.append('{');\n braceNesting++;\n break;\n case Token.RC:\n result.append('}');\n braceNesting--;\n assert braceNesting >= currentScope.getBraceNesting();\n if (braceNesting == currentScope.getBraceNesting()) {\n leaveCurrentScope();\n }\n break;\n case Token.SEMI:\n if (preserveAllSemiColons || offset < length && getToken(0).getType() != Token.RC) {\n result.append(';');\n }\n if (linebreakpos >= 0 && result.length() - linestartpos > linebreakpos) {\n result.append('\\n');\n linestartpos = result.length();\n }\n break;\n case Token.CONDCOMMENT:\n case Token.KEEPCOMMENT:\n if (result.length() > 0 && result.charAt(result.length() - 1) != '\\n') {\n result.append(\"\\n\");\n }\n result.append(\"/*\");\n result.append(symbol);\n result.append(\"*/\\n\");\n break;\n default:\n String literal = (String) literals.get(new Integer(token.getType()));\n if (literal != null) {\n result.append(literal);\n } else {\n warn(\"This symbol cannot be printed: \" + symbol, true);\n }\n break;\n }\n }\n if (!preserveAllSemiColons &&\n result.length() > 0 &&\n getToken(-1).getType() != Token.CONDCOMMENT &&\n getToken(-1).getType() != Token.KEEPCOMMENT) {\n if (result.charAt(result.length() - 1) == '\\n') {\n result.setCharAt(result.length() - 1, ';');\n } else {\n result.append(';');\n }\n }\n return result;\n }\n"} {"input": " public static void handle(final LoginEvent event) {\n Main.instance.getProxy().getScheduler().schedule(Main.instance, new Runnable() {\n @Override\n public void run() {\n final ProxiedPlayer target = Main.instance.getProxy().getPlayer(event.getConnection().getName());\n boolean registered = AuthProvider.isRegistered(target.getName());\n target.sendMessage(ChatColor.GREEN + \"Welkom \" + ((registered) ? \"terug \" : \"\") + \"in de Banjoserver, \" + target.getName() + \"!\");\n target.sendMessage(ChatColor.GRAY + \"Gebruik \" + ((registered) ? ChatColor.WHITE + \"/login [wachtwoord]\" + ChatColor.GRAY + \" om in te loggen.\" : ChatColor.WHITE + \"/register [wachtwoord]\" + ChatColor.GRAY + \" om te registreren.\"));\n target.sendMessage(\" \");\n Main.instance.getProxy().getScheduler().schedule(Main.instance, new Runnable() {\n @Override\n public void run() {\n if(!AuthProvider.isAuthenticated(target)) {\n target.disconnect(\"Om overbelasting van onze servers te voorkomen moet je binnen 30 seconden inloggen.\");\n }\n }\n }, 29, TimeUnit.SECONDS);\n }\n }, 1, TimeUnit.SECONDS);\n }\n", "output": " public static void handle(final LoginEvent event) {\n Main.instance.getProxy().getScheduler().schedule(Main.instance, new Runnable() {\n @Override\n public void run() {\n final ProxiedPlayer target = Main.instance.getProxy().getPlayer(event.getConnection().getName());\n boolean registered = AuthProvider.isRegistered(target.getName());\n target.sendMessage(ChatColor.GREEN + \"Welkom \" + ((registered) ? \"terug \" : \"\") + \"in de Banjoserver, \" + target.getName() + \"!\");\n target.sendMessage(ChatColor.GRAY + \"Gebruik \" + ((registered) ? ChatColor.WHITE + \"/login [wachtwoord]\" + ChatColor.GRAY + \" om in te loggen.\" : ChatColor.WHITE + \"/register [wachtwoord]\" + ChatColor.GRAY + \" om te registreren.\"));\n target.sendMessage(\" \");\n Main.instance.getProxy().getScheduler().schedule(Main.instance, new Runnable() {\n @Override\n public void run() {\n if(target == null) return; \n if(!AuthProvider.isAuthenticated(target)) {\n target.disconnect(\"Om overbelasting van onze servers te voorkomen moet je binnen 30 seconden inloggen.\");\n }\n }\n }, 29, TimeUnit.SECONDS);\n }\n }, 1, TimeUnit.SECONDS);\n }\n"} {"input": " protected void onOK() {\n final boolean checkInvalids = (Boolean) _paramWarnOnErrors.getValue();\n final boolean noDataValueUsed = (Boolean) _paramNoDataValueUsed.getValue();\n final float noDataValue = (Float) _paramNoDataValue.getValue();\n _targetBand.setImageInfo(null);\n _targetBand.setGeophysicalNoDataValue(noDataValue);\n _targetBand.setNoDataValueUsed(noDataValueUsed);\n if (getCreateVirtualBand()) {\n final VirtualBand virtualBand = (VirtualBand) _targetBand;\n virtualBand.setExpression(_paramExpression.getValueAsText());\n virtualBand.setCheckInvalids(checkInvalids);\n } else {\n if (!_targetBand.hasRasterData()) {\n final int rasterSize = _targetBand.getRasterWidth() * _targetBand.getRasterHeight();\n final int type = _targetBand.getDataType();\n final int requiredMemory = rasterSize * ProductData.getElemSize(type);\n final long freeMemory = Runtime.getRuntime().freeMemory();\n final float megabyte = 1024.0f * 1024.0f;\n if (freeMemory <= requiredMemory) {\n String message = \"Can not create the new band.\\n\" +\n String.format(\"\\tFree memory : %f.1 MB\\n\", freeMemory / megabyte) +\n String.format(\"\\tRequired memory: %f.1 MB\\n\\n\", requiredMemory / megabyte) +\n \"The amount of required memory is equal or greater than the available memory.\";\n _visatApp.showErrorDialog(message); \n BandArithmetikDialog.super.onOK();\n return;\n } else if (requiredMemory * 2 > freeMemory) {\n String message = \"Creating the new band will cause the system to reach the memory limit.\\n\" +\n \"Ths can cause the system to slow down.\\n\" +\n String.format(\"\\tFree memory : %f MB\\n\", freeMemory / megabyte) +\n String.format(\"\\tRequired memory: %f MB\\n\\n\", requiredMemory / megabyte) +\n \"Do you want to create the image anyhow?\";\n final int answer = _visatApp.showQuestionDialog(message, null);\n if (answer != JOptionPane.YES_OPTION) {\n BandArithmetikDialog.super.onOK();\n return;\n }\n }\n }\n }\n if (!_targetProduct.containsBand(_targetBand.getName())) {\n _targetProduct.addBand(_targetBand);\n }\n final String expression = _paramExpression.getValueAsText();\n _targetBand.setSynthetic(true);\n SwingWorker swingWorker = new SwingWorker() {\n final ProgressMonitor pm = new DialogProgressMonitor(getJDialog(), \"Band Arithmetic\",\n Dialog.ModalityType.APPLICATION_MODAL);\n String _errorMessage;\n int _numInvalids;\n @Override\n protected Object doInBackground() throws Exception {\n _errorMessage = null;\n try {\n if (!getCreateVirtualBand()) {\n _numInvalids = _targetBand.computeBand(expression,\n getCompatibleProducts(),\n checkInvalids,\n noDataValueUsed,\n noDataValue,\n pm);\n _targetBand.fireProductNodeDataChanged();\n }\n } catch (IOException e) {\n Debug.trace(e);\n _errorMessage = \"The band could not be created.\\nAn I/O error occurred:\\n\" + e.getMessage(); \n } catch (ParseException e) {\n Debug.trace(e);\n _errorMessage = \"The band could not be created.\\nAn expression parse error occurred:\\n\" + e.getMessage(); \n } catch (EvalException e) {\n Debug.trace(e);\n _errorMessage = \"The band could not be created.\\nAn expression evaluation error occured:\\n\" + e.getMessage();\n } finally {\n }\n return null;\n }\n @Override\n public void done() {\n boolean ok = true;\n if (_errorMessage != null) {\n showErrorDialog(_errorMessage);\n ok = false;\n } else if (pm.isCanceled()) {\n showErrorDialog(\"Band arithmetic has been canceled.\");\n ok = false;\n } else if (_numInvalids > 0 && checkInvalids) {\n int numPixelsTotal = _targetBand.getRasterWidth() * _targetBand.getRasterHeight();\n int percentage = MathUtils.floorInt(100.0 * _numInvalids / numPixelsTotal);\n if (percentage == 0) {\n percentage = 1;\n }\n String message = _numInvalids + \" of \" + numPixelsTotal + \" pixels (< \" + percentage + \"%) are invalid due to arithmetic exceptions.\\n\"; \n if (noDataValueUsed) {\n message += \"These pixels have been set to \" + noDataValue + \".\\n\\n\"; \n } else {\n message += \"These pixels have been set to NaN (IEEE 754).\\n\\n\"; \n }\n message += \"Do you still want to use the suspicious computed data?\\n\" \n + \"If you select \\\"No\\\", all computed data will be lost.\"; \n int status = showQuestionDialog(\"Invalid Pixel Warning\", message);\n if (status != JOptionPane.YES_OPTION) {\n ok = false;\n }\n }\n finalOnOk(ok);\n }\n };\n swingWorker.execute();\n }\n", "output": " protected void onOK() {\n final boolean checkInvalids = (Boolean) _paramWarnOnErrors.getValue();\n final boolean noDataValueUsed = (Boolean) _paramNoDataValueUsed.getValue();\n final float noDataValue = (Float) _paramNoDataValue.getValue();\n _targetBand.setImageInfo(null);\n _targetBand.setGeophysicalNoDataValue(noDataValue);\n _targetBand.setNoDataValueUsed(noDataValueUsed);\n if (getCreateVirtualBand()) {\n final VirtualBand virtualBand = (VirtualBand) _targetBand;\n virtualBand.setExpression(_paramExpression.getValueAsText());\n virtualBand.setCheckInvalids(checkInvalids);\n } else {\n if (!_targetBand.hasRasterData()) {\n final int rasterSize = _targetBand.getRasterWidth() * _targetBand.getRasterHeight();\n final int type = _targetBand.getDataType();\n final int requiredMemory = rasterSize * ProductData.getElemSize(type);\n final long freeMemory = Runtime.getRuntime().freeMemory();\n final float megabyte = 1024.0f * 1024.0f;\n if (freeMemory <= requiredMemory) {\n String message = \"Can not create the new band.\\n\" +\n \"The amount of required memory is equal or greater than the available memory.\\n\\n\" +\n String.format(\"\\tFree memory : %f.1 MB\\n\", freeMemory / megabyte) +\n String.format(\"\\tRequired memory: %f.1 MB\", requiredMemory / megabyte);\n _visatApp.showErrorDialog(message); \n BandArithmetikDialog.super.onOK();\n return;\n } else if (requiredMemory * 2 > freeMemory) {\n String message = \"Creating the new band will cause the system to reach its memory limit.\\n\" +\n \"This can cause the system to slow down.\\n\" +\n String.format(\"\\tFree memory : %f MB\\n\", freeMemory / megabyte) +\n String.format(\"\\tRequired memory: %f MB\\n\\n\", requiredMemory / megabyte) +\n \"Do you really want to create the image?\";\n final int answer = _visatApp.showQuestionDialog(message, null);\n if (answer != JOptionPane.YES_OPTION) {\n BandArithmetikDialog.super.onOK();\n return;\n }\n }\n }\n }\n if (!_targetProduct.containsBand(_targetBand.getName())) {\n _targetProduct.addBand(_targetBand);\n }\n final String expression = _paramExpression.getValueAsText();\n _targetBand.setSynthetic(true);\n SwingWorker swingWorker = new SwingWorker() {\n final ProgressMonitor pm = new DialogProgressMonitor(getJDialog(), \"Band Arithmetic\",\n Dialog.ModalityType.APPLICATION_MODAL);\n String _errorMessage;\n int _numInvalids;\n @Override\n protected Object doInBackground() throws Exception {\n _errorMessage = null;\n try {\n if (!getCreateVirtualBand()) {\n _numInvalids = _targetBand.computeBand(expression,\n getCompatibleProducts(),\n checkInvalids,\n noDataValueUsed,\n noDataValue,\n pm);\n _targetBand.fireProductNodeDataChanged();\n }\n } catch (IOException e) {\n Debug.trace(e);\n _errorMessage = \"The band could not be created.\\nAn I/O error occurred:\\n\" + e.getMessage(); \n } catch (ParseException e) {\n Debug.trace(e);\n _errorMessage = \"The band could not be created.\\nAn expression parse error occurred:\\n\" + e.getMessage(); \n } catch (EvalException e) {\n Debug.trace(e);\n _errorMessage = \"The band could not be created.\\nAn expression evaluation error occured:\\n\" + e.getMessage();\n } finally {\n }\n return null;\n }\n @Override\n public void done() {\n boolean ok = true;\n if (_errorMessage != null) {\n showErrorDialog(_errorMessage);\n ok = false;\n } else if (pm.isCanceled()) {\n showErrorDialog(\"Band arithmetic has been canceled.\");\n ok = false;\n } else if (_numInvalids > 0 && checkInvalids) {\n int numPixelsTotal = _targetBand.getRasterWidth() * _targetBand.getRasterHeight();\n int percentage = MathUtils.floorInt(100.0 * _numInvalids / numPixelsTotal);\n if (percentage == 0) {\n percentage = 1;\n }\n String message = _numInvalids + \" of \" + numPixelsTotal + \" pixels (< \" + percentage + \"%) are invalid due to arithmetic exceptions.\\n\"; \n if (noDataValueUsed) {\n message += \"These pixels have been set to \" + noDataValue + \".\\n\\n\"; \n } else {\n message += \"These pixels have been set to NaN (IEEE 754).\\n\\n\"; \n }\n message += \"Do you still want to use the suspicious computed data?\\n\" \n + \"If you select \\\"No\\\", all computed data will be lost.\"; \n int status = showQuestionDialog(\"Invalid Pixel Warning\", message);\n if (status != JOptionPane.YES_OPTION) {\n ok = false;\n }\n }\n finalOnOk(ok);\n }\n };\n swingWorker.execute();\n }\n"} {"input": "\tpublic DocEdit(PrintWriter outputStream, String documentName, String user, String content, String collaboratorNames, int versionID){\n\t\tsuper(documentName);\n\t\tthis.version = versionID;\n\t\tthis.cursorPosition = 0;\n\t\tout = outputStream;\n\t\tthis.docName = documentName;\n\t\tthis.userName = user;\n\t\tthis.docContent = content;\n\t\tthis.collaboratorNames = collaboratorNames;\n\t\twelcomeLabel = new JLabel(\"Welcome \" + userName + \"!\");\n\t\texitButton = new JButton(\"Exit Doc\");\n\t\tcollabLabel = new JLabel(\"Collaborators: \");\n\t\tcollaborators = new JLabel(collaboratorNames);\n\t\tmessageLabel = new JLabel(\"Messages will appear here.\");\n\t\tlatexButton = new JButton(\"Latex View\");\n\t\tlatexDisplay = new MyPanel();\n\t\tcloseLatexButton = new JButton(\"<\");\n\t\tcloseLatexButton.setVisible(false);\n\t\tlatexDisplay.setVisible(false);\n\t\ttextArea = new JTextArea();\n\t\tscrollText = new JScrollPane(textArea);\n\t\tscrollText.setMinimumSize(new Dimension(700, 700));\n\t\ttextArea.setText(docContent);\n\t\ttextArea.setCaretPosition(cursorPosition);\n\t\ttextDocument = textArea.getDocument();\n\t\tsetDefaultCloseOperation(EXIT_ON_CLOSE);\n\t\tGroupLayout layout = new GroupLayout(getContentPane());\n\t\tgetContentPane().setLayout(layout);\n\t\tlayout.setAutoCreateGaps(true);\n\t\tlayout.setAutoCreateContainerGaps(true);\n\t\tGroupLayout.ParallelGroup hGroup = layout.createParallelGroup();\n\t\thGroup.addGroup(\n\t\t\t\tlayout.createParallelGroup()\n\t\t\t\t\t.addGroup(layout.createSequentialGroup()\n\t\t\t\t\t\t\t.addComponent(collabLabel)\n\t\t\t\t\t\t\t.addComponent(collaborators)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t.addComponent(welcomeLabel)\n\t\t\t\t\t.addComponent(messageLabel)\n\t\t\t\t\t);\n\t\thGroup.addGroup(\n\t\t\t\tlayout.createParallelGroup(GroupLayout.Alignment.TRAILING)\n\t\t\t\t\t.addComponent(exitButton)\n\t\t\t\t\t.addGroup(layout.createSequentialGroup()\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t.addComponent(scrollText)\n\t\t\t\t\t\t\t.addComponent(latexDisplay)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t.addGroup(layout.createSequentialGroup()\n\t\t\t\t\t\t\t.addComponent(closeLatexButton)\n\t\t\t\t\t\t\t.addComponent(latexButton)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\tlayout.setHorizontalGroup(hGroup);\n\t\tGroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup(GroupLayout.Alignment.CENTER)\n\t\t\t\t\t\t.addComponent(welcomeLabel)\n\t\t\t\t\t\t.addComponent(exitButton)\n\t\t\t\t\t);\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup()\n\t\t\t\t\t\t.addComponent(collabLabel)\n\t\t\t\t\t\t.addComponent(collaborators)\n\t\t\t\t\t);\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup()\n\t\t\t\t\t\t.addComponent(scrollText)\n\t\t\t\t\t\t.addComponent(latexDisplay)\n\t\t\t\t\t);\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup(GroupLayout.Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(messageLabel)\n\t\t\t\t\t\t.addComponent(closeLatexButton)\n\t\t\t\t\t\t.addComponent(latexButton)\n\t\t\t\t\t);\n\t\tlayout.setVerticalGroup(vGroup);\n\t\tlatexButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e){\n\t\t\t\tif (latexDisplay.isVisible()){\n\t\t\t\t\tString content = textArea.getText();\n\t\t\t\t\tif (Latex.isLatex(content)){\n\t\t\t\t\t\tTeXIcon icon = Latex.getLatex(content);\n\t\t\t\t\t\tBufferedImage b = new BufferedImage(icon.getIconWidth(),\n\t\t\t\t\t\t\t\ticon.getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR);\n\t\t\t\t\t\ticon.paintIcon(new JLabel(), b.getGraphics(), 0, 0);\n\t\t\t\t\t\tb.getGraphics().drawImage(b, 0, 0, null);\n\t\t\t\t\t\tlatexDisplay.updateImage(b);\n\t\t\t\t\t\tlatexDisplay.repaint();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tlatexDisplay.setVisible(true);\n\t\t\t\t\tint height = scrollText.getHeight();\n\t\t\t\t\tint width = scrollText.getWidth();\n\t\t\t\t\tlatexDisplay.setMinimumSize(new Dimension(width/2, height));\n\t\t\t\t\tscrollText.setMinimumSize(new Dimension(width/2, height));\n\t\t\t\t\tlatexButton.setText(\"Render\");\n\t\t\t\t\tcloseLatexButton.setVisible(true);\n\t\t\t\t\tpackFrame();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tcloseLatexButton.addActionListener(new ActionListener(){\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e){\t\t\t\t\n\t\t\t\tlatexDisplay.setVisible(false);\n\t\t\t\tcloseLatexButton.setVisible(false);\n\t\t\t\tlatexButton.setText(\"Latex View\");\n\t\t\t}\t\n\t\t});\n\t\texitButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e){\n\t\t\t\texitDocument();\t\n\t\t\t}\n\t\t});\t\t\n\t\tdocumentListener = new DocumentListener() {\n\t\t\t@Override\n\t\t\tpublic void changedUpdate(DocumentEvent e) {\n\t\t\t\tSystem.out.println(\"CHANGED!\");\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void insertUpdate(DocumentEvent e) {\n\t\t\t\ttry {\n\t\t\t\t\tint position = e.getOffset();\n\t\t\t\t\tint length = e.getLength();\n\t\t\t\t\tString change = textDocument.getText(position, length);\n\t\t\t\t\tif (change.equals(\"\\n\")) {\n\t\t\t\t\t\tout.println(\"CHANGE|\" + userName + \"|\" + docName + \"|\" + position + \"|\" + \"\\t\" + \"|\" + length + \"|\" + version);\n\t\t\t\t\t} else if (! change.equals(\"\")){\n\t\t\t\t\t\tout.println(\"CHANGE|\" + userName + \"|\" + docName + \"|\" + position + \"|\" + change + \"|\" + length + \"|\" + version);\n\t\t\t\t\t}\n\t\t\t\t} catch (BadLocationException e1) {\n\t\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void removeUpdate(DocumentEvent e) {\n\t\t\t\tint position = e.getOffset();\n\t\t\t\tint length = e.getLength();\n\t\t\t\tout.println(\"CHANGE|\" + userName + \"|\" + docName + \"|\" + position + \"|\" + length + \"|\" + version);\n\t\t\t}\n\t\t};\n\t\tthis.addListener();\n\t\tthis.pack();\n\t}\n", "output": "\tpublic DocEdit(PrintWriter outputStream, String documentName, String user, String content, String collaboratorNames, int versionID){\n\t\tsuper(documentName);\n\t\tthis.version = versionID;\n\t\tthis.cursorPosition = 0;\n\t\tout = outputStream;\n\t\tthis.docName = documentName;\n\t\tthis.userName = user;\n\t\tthis.docContent = content;\n\t\tthis.collaboratorNames = collaboratorNames;\n\t\twelcomeLabel = new JLabel(\"Welcome \" + userName + \"!\");\n\t\texitButton = new JButton(\"Exit Doc\");\n\t\tcollabLabel = new JLabel(\"Collaborators: \");\n\t\tcollaborators = new JLabel(collaboratorNames);\n\t\tmessageLabel = new JLabel(\"Messages will appear here.\");\n\t\tlatexButton = new JButton(\"Latex View\");\n\t\tlatexDisplay = new MyPanel();\n\t\tcloseLatexButton = new JButton(\"<\");\n\t\tcloseLatexButton.setVisible(false);\n\t\tlatexDisplay.setVisible(false);\n\t\ttextArea = new JTextArea();\n\t\tscrollText = new JScrollPane(textArea);\n\t\tscrollText.setMinimumSize(new Dimension(700, 700));\n\t\ttextArea.setText(docContent);\n\t\ttextArea.setCaretPosition(cursorPosition);\n\t\ttextDocument = textArea.getDocument();\n\t\tsetDefaultCloseOperation(EXIT_ON_CLOSE);\n\t\tGroupLayout layout = new GroupLayout(getContentPane());\n\t\tgetContentPane().setLayout(layout);\n\t\tlayout.setAutoCreateGaps(true);\n\t\tlayout.setAutoCreateContainerGaps(true);\n\t\tGroupLayout.ParallelGroup hGroup = layout.createParallelGroup();\n\t\thGroup.addGroup(\n\t\t\t\tlayout.createParallelGroup()\n\t\t\t\t\t.addGroup(layout.createSequentialGroup()\n\t\t\t\t\t\t\t.addComponent(collabLabel)\n\t\t\t\t\t\t\t.addComponent(collaborators)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t.addComponent(welcomeLabel)\n\t\t\t\t\t.addComponent(messageLabel)\n\t\t\t\t\t);\n\t\thGroup.addGroup(\n\t\t\t\tlayout.createParallelGroup(GroupLayout.Alignment.TRAILING)\n\t\t\t\t\t.addComponent(exitButton)\n\t\t\t\t\t.addGroup(layout.createSequentialGroup()\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t.addComponent(scrollText)\n\t\t\t\t\t\t\t.addComponent(latexDisplay)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t.addGroup(layout.createSequentialGroup()\n\t\t\t\t\t\t\t.addComponent(closeLatexButton)\n\t\t\t\t\t\t\t.addComponent(latexButton)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\tlayout.setHorizontalGroup(hGroup);\n\t\tGroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup(GroupLayout.Alignment.CENTER)\n\t\t\t\t\t\t.addComponent(welcomeLabel)\n\t\t\t\t\t\t.addComponent(exitButton)\n\t\t\t\t\t);\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup()\n\t\t\t\t\t\t.addComponent(collabLabel)\n\t\t\t\t\t\t.addComponent(collaborators)\n\t\t\t\t\t);\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup()\n\t\t\t\t\t\t.addComponent(scrollText)\n\t\t\t\t\t\t.addComponent(latexDisplay)\n\t\t\t\t\t);\n\t\tvGroup.addGroup(\n\t\t\t\t\tlayout.createParallelGroup(GroupLayout.Alignment.BASELINE)\n\t\t\t\t\t\t.addComponent(messageLabel)\n\t\t\t\t\t\t.addComponent(closeLatexButton)\n\t\t\t\t\t\t.addComponent(latexButton)\n\t\t\t\t\t);\n\t\tlayout.setVerticalGroup(vGroup);\n\t\tlatexButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e){\n\t\t\t\tif (latexDisplay.isVisible()){\n\t\t\t\t\tString content = textArea.getText();\n\t\t\t\t\tif (Latex.isLatex(content)){\n\t\t\t\t\t\tTeXIcon icon = Latex.getLatex(content);\n\t\t\t\t\t\tBufferedImage b = new BufferedImage(icon.getIconWidth(),\n\t\t\t\t\t\t\t\ticon.getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR);\n\t\t\t\t\t\ticon.paintIcon(new JLabel(), b.getGraphics(), 0, 0);\n\t\t\t\t\t\tb.getGraphics().drawImage(b, 0, 0, null);\n\t\t\t\t\t\tlatexDisplay.updateImage(b);\n\t\t\t\t\t\tlatexDisplay.repaint();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tlatexDisplay.setVisible(true);\n\t\t\t\t\tint height = scrollText.getHeight();\n\t\t\t\t\tint width = scrollText.getWidth();\n\t\t\t\t\tlatexDisplay.setMinimumSize(new Dimension(width/2, height));\n\t\t\t\t\tscrollText.setMinimumSize(new Dimension(width/2, height));\n\t\t\t\t\tlatexButton.setText(\"Render\");\n\t\t\t\t\tcloseLatexButton.setVisible(true);\n\t\t\t\t\tpackFrame();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tcloseLatexButton.addActionListener(new ActionListener(){\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e){\t\t\t\t\n\t\t\t\tlatexDisplay.setVisible(false);\n\t\t\t\tcloseLatexButton.setVisible(false);\n\t\t\t\tlatexButton.setText(\"Latex View\");\n\t\t\t}\t\n\t\t});\n\t\texitButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e){\n\t\t\t\texitDocument();\t\n\t\t\t}\n\t\t});\t\t\n\t\tdocumentListener = new DocumentListener() {\n\t\t\t@Override\n\t\t\tpublic void changedUpdate(DocumentEvent e) {\n\t\t\t\tSystem.out.println(\"CHANGED!\");\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void insertUpdate(DocumentEvent e) {\n\t\t\t\ttry {\n\t\t\t\t\tint position = e.getOffset();\n\t\t\t\t\tint length = e.getLength();\n\t\t\t\t\tcursorPosition = position + length;\n\t\t\t\t\tString change = textDocument.getText(position, length);\n\t\t\t\t\tif (change.equals(\"\\n\")) {\n\t\t\t\t\t\tout.println(\"CHANGE|\" + userName + \"|\" + docName + \"|\" + position + \"|\" + \"\\t\" + \"|\" + length + \"|\" + version);\n\t\t\t\t\t} else if (! change.equals(\"\")){\n\t\t\t\t\t\tout.println(\"CHANGE|\" + userName + \"|\" + docName + \"|\" + position + \"|\" + change + \"|\" + length + \"|\" + version);\n\t\t\t\t\t}\n\t\t\t\t} catch (BadLocationException e1) {\n\t\t\t\t\tthrow new UnsupportedOperationException();\n\t\t\t\t}\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void removeUpdate(DocumentEvent e) {\n\t\t\t\tint position = e.getOffset();\n\t\t\t\tint length = e.getLength();\n\t\t\t\tcursorPosition = length;\n\t\t\t\tout.println(\"CHANGE|\" + userName + \"|\" + docName + \"|\" + position + \"|\" + length + \"|\" + version);\n\t\t\t}\n\t\t};\n\t\tthis.addListener();\n\t\tthis.pack();\n\t}\n"} {"input": " public void pickSuggestionManually(int index, CharSequence suggestion) {\n SuggestedWords suggestions = mCandidateView.getSuggestions();\n mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,\n mSettingsValues.mWordSeparators);\n final boolean recorrecting = TextEntryState.isRecorrecting();\n InputConnection ic = getCurrentInputConnection();\n if (ic != null) {\n ic.beginBatchEdit();\n }\n if (mApplicationSpecifiedCompletionOn && mApplicationSpecifiedCompletions != null\n && index >= 0 && index < mApplicationSpecifiedCompletions.length) {\n CompletionInfo ci = mApplicationSpecifiedCompletions[index];\n if (ic != null) {\n ic.commitCompletion(ci);\n }\n mCommittedLength = suggestion.length();\n if (mCandidateView != null) {\n mCandidateView.clear();\n }\n mKeyboardSwitcher.updateShiftState();\n if (ic != null) {\n ic.endBatchEdit();\n }\n return;\n }\n if (suggestion.length() == 1 && (mSettingsValues.isWordSeparator(suggestion.charAt(0))\n || mSettingsValues.isSuggestedPunctuation(suggestion.charAt(0)))) {\n LatinImeLogger.logOnManualSuggestion(\n \"\", suggestion.toString(), index, suggestions.mWords);\n final char primaryCode = suggestion.charAt(0);\n final int toLeft = (ic == null) ? 0 : ic.getTextBeforeCursor(1, 0).charAt(0);\n final boolean oldMagicSpace = mJustAddedMagicSpace;\n if (Keyboard.CODE_SPACE == toLeft) mJustAddedMagicSpace = true;\n onCodeInput(primaryCode, new int[] { primaryCode },\n KeyboardActionListener.NOT_A_TOUCH_COORDINATE,\n KeyboardActionListener.NOT_A_TOUCH_COORDINATE);\n mJustAddedMagicSpace = oldMagicSpace;\n if (ic != null) {\n ic.endBatchEdit();\n }\n return;\n }\n if (!mHasUncommittedTypedChars) {\n mWord.reset();\n }\n mJustAccepted = true;\n pickSuggestion(suggestion);\n if (index == 0) {\n addToAutoAndUserBigramDictionaries(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);\n } else {\n addToOnlyBigramDictionary(suggestion, 1);\n }\n LatinImeLogger.logOnManualSuggestion(mComposing.toString(), suggestion.toString(),\n index, suggestions.mWords);\n TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);\n if (mShouldInsertMagicSpace && !recorrecting) {\n sendMagicSpace();\n }\n final boolean showingAddToDictionaryHint = index == 0 && mSuggest != null\n && (!mHasDictionary\n || !AutoCorrection.isValidWord(\n mSuggest.getUnigramDictionaries(), suggestion, true));\n if (!recorrecting) {\n TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,\n WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);\n mHandler.postUpdateSuggestions();\n } else if (!showingAddToDictionaryHint) {\n clearSuggestions();\n mHandler.postUpdateOldSuggestions();\n }\n if (showingAddToDictionaryHint) {\n mCandidateView.showAddToDictionaryHint(suggestion);\n }\n if (ic != null) {\n ic.endBatchEdit();\n }\n }\n", "output": " public void pickSuggestionManually(int index, CharSequence suggestion) {\n SuggestedWords suggestions = mCandidateView.getSuggestions();\n mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,\n mSettingsValues.mWordSeparators);\n final boolean recorrecting = TextEntryState.isRecorrecting();\n InputConnection ic = getCurrentInputConnection();\n if (ic != null) {\n ic.beginBatchEdit();\n }\n if (mApplicationSpecifiedCompletionOn && mApplicationSpecifiedCompletions != null\n && index >= 0 && index < mApplicationSpecifiedCompletions.length) {\n CompletionInfo ci = mApplicationSpecifiedCompletions[index];\n if (ic != null) {\n ic.commitCompletion(ci);\n }\n mCommittedLength = suggestion.length();\n if (mCandidateView != null) {\n mCandidateView.clear();\n }\n mKeyboardSwitcher.updateShiftState();\n if (ic != null) {\n ic.endBatchEdit();\n }\n return;\n }\n if (suggestion.length() == 1 && (mSettingsValues.isWordSeparator(suggestion.charAt(0))\n || mSettingsValues.isSuggestedPunctuation(suggestion.charAt(0)))) {\n LatinImeLogger.logOnManualSuggestion(\n \"\", suggestion.toString(), index, suggestions.mWords);\n final char primaryCode = suggestion.charAt(0);\n final int toLeft = (ic == null) ? 0 : ic.getTextBeforeCursor(1, 0).charAt(0);\n final boolean oldMagicSpace = mJustAddedMagicSpace;\n if (Keyboard.CODE_SPACE == toLeft) mJustAddedMagicSpace = true;\n onCodeInput(primaryCode, new int[] { primaryCode },\n KeyboardActionListener.NOT_A_TOUCH_COORDINATE,\n KeyboardActionListener.NOT_A_TOUCH_COORDINATE);\n mJustAddedMagicSpace = oldMagicSpace;\n if (ic != null) {\n ic.endBatchEdit();\n }\n return;\n }\n if (!mHasUncommittedTypedChars) {\n mWord.reset();\n }\n mJustAccepted = true;\n pickSuggestion(suggestion);\n if (index == 0) {\n addToAutoAndUserBigramDictionaries(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);\n } else {\n addToOnlyBigramDictionary(suggestion, 1);\n }\n LatinImeLogger.logOnManualSuggestion(mComposing.toString(), suggestion.toString(),\n index, suggestions.mWords);\n TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);\n if (mShouldInsertMagicSpace && !recorrecting) {\n sendMagicSpace();\n }\n final boolean showingAddToDictionaryHint = index == 0 && mSuggest != null\n && (!mHasDictionary\n || !AutoCorrection.isValidWord(\n mSuggest.getUnigramDictionaries(), suggestion, true));\n if (!recorrecting) {\n TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,\n WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);\n }\n if (!showingAddToDictionaryHint) {\n clearSuggestions();\n mHandler.postUpdateOldSuggestions();\n }\n if (showingAddToDictionaryHint) {\n mCandidateView.showAddToDictionaryHint(suggestion);\n }\n if (ic != null) {\n ic.endBatchEdit();\n }\n }\n"} {"input": " public static void main(String[] args) {\n\tSystem.out.print(\"afck Copyright (C) 2013 Chandler Paul\\n\" +\n\t\t\t \"This program comes with ABSOLUTELY NO WARRANTY and is distributed under the terms\"\t+\n\t\t\t \"of the LGPL license. For more information, please see the file LICENSE at the root\" \t+\n\t\t\t \"of the source code, or go to http://www.gnu.org/licenses.lgpl.html\\n\");\n if (args.length > 0) {\n File brokenAliceWorld = new File(args[0]);\n File tmpDir;\n String worldName;\n Random generator = new Random();\n if (!brokenAliceWorld.exists()) {\n System.err.printf(\"Path specified is not valid! Exiting...\\n\");\n System.exit(-1);\n }\n worldName = brokenAliceWorld.getPath();\n tmpDir = new File(System.getProperty(\"java.io.tmpdir\") + \"/afck-\" +\n Integer.toString(Math.abs(generator.nextInt())));\n tmpDir.mkdirs();\n try {\n ZipFile brokenAliceWorldZip = new ZipFile(brokenAliceWorld);\n Enumeration aliceZipEntries = brokenAliceWorldZip.entries();\n System.out.print(\"Extracting world...\");\n while (aliceZipEntries.hasMoreElements()) {\n ZipEntry entry = (ZipEntry) aliceZipEntries.nextElement();\n String currentEntry = entry.getName();\n File destFile = new File(tmpDir, currentEntry);\n File destinationParent = destFile.getParentFile();\n destinationParent.mkdirs();\n if (!entry.isDirectory()) {\n BufferedInputStream inputStream = new BufferedInputStream(brokenAliceWorldZip.getInputStream(entry));\n int currentByte;\n byte data[] = new byte[BUFFER_SIZE]; \n FileOutputStream outputStream = new FileOutputStream(destFile);\n BufferedOutputStream dest = new BufferedOutputStream(outputStream, BUFFER_SIZE);\n while ((currentByte = inputStream.read(data, 0, BUFFER_SIZE)) != -1)\n dest.write(data, 0, currentByte);\n dest.flush();\n dest.close();\n outputStream.close();\n inputStream.close();\n }\n }\n }\n catch (ZipException e) {\n System.err.printf(\"Fatal zip file exception! %s\\n\" +\n \"Exiting...\\n\",\n e.getMessage());\n System.exit(-1);\n }\n catch (IOException e) {\n System.err.printf(\"Fatal I/O Exception: %s\\n\" +\n \"Exiting...\\n\",\n e.getMessage());\n System.exit(-1);\n }\n System.out.print(\" done!\\n\");\n try {\n DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();\n DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();\n for (File file : getAllElementData(tmpDir)) {\n Document elementData = docBuilder.parse(file);\n Element rootElement = elementData.getDocumentElement();\n NodeList propertyList;\n NodeList itemList;\n int componentResponsesIndex = 0;\n boolean indexVariableMarkedCorrectly = false;\n if (!rootElement.getAttribute(\"class\").equals(\n \"edu.cmu.cs.stage3.alice.core.response.LoopNInOrder\"))\n continue;\n propertyList = rootElement.getElementsByTagName(\"property\");\n for (int i = 0; i < propertyList.getLength(); i++) {\n if (((Element) propertyList.item(i)).getAttribute(\"name\").equals(\n \"componentResponses\")) {\n componentResponsesIndex = i;\n break;\n }\n }\n itemList = ((Element) propertyList.item(componentResponsesIndex)).getElementsByTagName(\"item\");\n for (int i = 0; i < itemList.getLength(); i++) {\n Node item = itemList.item(i);\n if (((Element) item).getAttribute(\"criterionClass\").equals(\n \"edu.cmu.cs.stage3.alice.core.criterion.InternalReferenceKeyedCriterion\") &&\n\t\t\t\t((Element) item).getTextContext().equals(file.getAbsolutePath().replaceFirst(tmpDir.getAbsolutePath() + \"(/|\\\\\\\\)(.*(/|\\\\\\\\))elementData\\\\.xml\", \"$2\").replaceAll(\"/|\\\\\\\\\", \".\") + \"index\")) {\n indexVariableMarkedCorrectly = true;\n break;\n }\n }\n if (indexVariableMarkedCorrectly)\n continue;\n System.out.println(\"Found one!\");\n }\n }\n catch (ParserConfigurationException e) {\n System.err.println(e.getMessage());\n System.exit(-1);\n }\n catch (SAXException e) {\n System.err.println(e.getMessage());\n System.exit(-1);\n }\n catch (IOException e) {\n System.err.println(e.getMessage());\n System.exit(-1);\n }\n tmpDir.delete();\n }\n }\n", "output": " public static void main(String[] args) {\n System.out.print(\"afck Copyright (C) 2013 Chandler Paul\\n\" +\n \"This program comes with ABSOLUTELY NO WARRANTY and is distributed under the terms\" +\n \"of the LGPL license. For more information, please see the file LICENSE at the root\" +\n \"of the source code, or go to http://www.gnu.org/licenses.lgpl.html\\n\");\n if (args.length > 0) {\n File brokenAliceWorld = new File(args[0]);\n File tmpDir;\n String worldName;\n Random generator = new Random();\n if (!brokenAliceWorld.exists()) {\n System.err.printf(\"Path specified is not valid! Exiting...\\n\");\n System.exit(-1);\n }\n worldName = brokenAliceWorld.getPath();\n tmpDir = new File(System.getProperty(\"java.io.tmpdir\") + \"/afck-\" +\n Integer.toString(Math.abs(generator.nextInt())));\n tmpDir.mkdirs();\n try {\n ZipFile brokenAliceWorldZip = new ZipFile(brokenAliceWorld);\n Enumeration aliceZipEntries = brokenAliceWorldZip.entries();\n System.out.print(\"Extracting world...\");\n while (aliceZipEntries.hasMoreElements()) {\n ZipEntry entry = (ZipEntry) aliceZipEntries.nextElement();\n String currentEntry = entry.getName();\n File destFile = new File(tmpDir, currentEntry);\n File destinationParent = destFile.getParentFile();\n destinationParent.mkdirs();\n if (!entry.isDirectory()) {\n BufferedInputStream inputStream = new BufferedInputStream(brokenAliceWorldZip.getInputStream(entry));\n int currentByte;\n byte data[] = new byte[BUFFER_SIZE]; \n FileOutputStream outputStream = new FileOutputStream(destFile);\n BufferedOutputStream dest = new BufferedOutputStream(outputStream, BUFFER_SIZE);\n while ((currentByte = inputStream.read(data, 0, BUFFER_SIZE)) != -1)\n dest.write(data, 0, currentByte);\n dest.flush();\n dest.close();\n outputStream.close();\n inputStream.close();\n }\n }\n }\n catch (ZipException e) {\n System.err.printf(\"Fatal zip file exception! %s\\n\" +\n \"Exiting...\\n\",\n e.getMessage());\n System.exit(-1);\n }\n catch (IOException e) {\n System.err.printf(\"Fatal I/O Exception: %s\\n\" +\n \"Exiting...\\n\",\n e.getMessage());\n System.exit(-1);\n }\n System.out.print(\" done!\\n\");\n try {\n DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();\n DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();\n for (File file : getAllElementData(tmpDir)) {\n Document elementData = docBuilder.parse(file);\n Element rootElement = elementData.getDocumentElement();\n NodeList propertyList;\n NodeList itemList;\n int componentResponsesIndex = 0;\n boolean indexVariableMarkedCorrectly = false;\n if (!rootElement.getAttribute(\"class\").equals(\n \"edu.cmu.cs.stage3.alice.core.response.LoopNInOrder\"))\n continue;\n propertyList = rootElement.getElementsByTagName(\"property\");\n for (int i = 0; i < propertyList.getLength(); i++) {\n if (((Element) propertyList.item(i)).getAttribute(\"name\").equals(\n \"componentResponses\")) {\n componentResponsesIndex = i;\n break;\n }\n }\n itemList = ((Element) propertyList.item(componentResponsesIndex)).getElementsByTagName(\"item\");\n for (int i = 0; i < itemList.getLength(); i++) {\n Node item = itemList.item(i);\n String indexString = file.getAbsolutePath().replaceFirst(\n tmpDir.getAbsolutePath() + \"(/|\\\\\\\\)(.*(/|\\\\\\\\))elementData\\\\.xml\", \"$2\").\n replaceAll(\"/|\\\\\\\\\", \".\") + \"index\";\n if (((Element) item).getAttribute(\"criterionClass\").equals(\n \"edu.cmu.cs.stage3.alice.core.criterion.InternalReferenceKeyedCriterion\") &&\n item.getFirstChild().getNodeValue().equals(indexString)) {\n indexVariableMarkedCorrectly = true;\n break;\n }\n }\n if (indexVariableMarkedCorrectly)\n continue;\n System.out.println(\"Found one!\");\n }\n }\n catch (ParserConfigurationException e) {\n System.err.println(e.getMessage());\n System.exit(-1);\n }\n catch (SAXException e) {\n System.err.println(e.getMessage());\n System.exit(-1);\n }\n catch (IOException e) {\n System.err.println(e.getMessage());\n System.exit(-1);\n }\n tmpDir.delete();\n }\n }\n"} {"input": " public void execute(EObject element, TransactionType request, Map featureStores,\n TransactionResponseType response, TransactionListener listener)\n throws WFSTransactionException {\n LOGGER.finer(\"Transasction Insert:\" + element);\n InsertElementType insert = (InsertElementType) element;\n long inserted = response.getTransactionSummary().getTotalInserted().longValue();\n try {\n HashMap schema2features = new HashMap();\n for (Iterator f = insert.getFeature().iterator(); f.hasNext();) {\n SimpleFeature feature = (SimpleFeature) f.next();\n SimpleFeatureType schema = feature.getFeatureType();\n FeatureCollection collection = (FeatureCollection) schema2features.get(schema);\n if (collection == null) {\n collection = new DefaultFeatureCollection(null, schema);\n schema2features.put(schema, collection);\n }\n collection.add(feature);\n }\n HashMap schema2fids = new HashMap();\n for (Iterator c = schema2features.values().iterator(); c.hasNext();) {\n FeatureCollection collection = (FeatureCollection) c.next();\n SimpleFeatureType schema = collection.getSchema();\n final QName elementName = new QName(schema.getName().getNamespaceURI(), schema.getTypeName());\n FeatureStore store = (FeatureStore) featureStores.get(elementName);\n if (store == null) {\n throw new WFSException(\"Could not locate FeatureStore for '\" + elementName\n + \"'\");\n }\n if (collection != null) {\n if(wfs.getCiteConformanceHacks()) {\n checkFeatureCoordinatesRange(collection);\n }\n final GeometryDescriptor defaultGeometry = store.getSchema().getDefaultGeometry();\n if(defaultGeometry != null) {\n CoordinateReferenceSystem target = defaultGeometry.getCRS();\n if (target != null) {\n collection = new ReprojectingFeatureCollection(collection, target);\n }\n }\n LOGGER.finer(\"Use featureValidation to check contents of insert\");\n List fids = (List) schema2fids.get(schema.getTypeName());\n if (fids == null) {\n fids = new LinkedList();\n schema2fids.put(schema.getTypeName(), fids);\n }\n listener.dataStoreChange(new TransactionEvent(TransactionEventType.PRE_INSERT,\n elementName, collection));\n fids.addAll(store.addFeatures(collection));\n }\n }\n InsertedFeatureType insertedFeature = null;\n for (Iterator f = insert.getFeature().iterator(); f.hasNext();) {\n SimpleFeature feature = (SimpleFeature) f.next();\n SimpleFeatureType schema = feature.getFeatureType();\n LinkedList fids = (LinkedList) schema2fids.get(schema.getTypeName());\n String fid = (String) fids.removeFirst();\n insertedFeature = WfsFactory.eINSTANCE.createInsertedFeatureType();\n insertedFeature.setHandle(insert.getHandle());\n insertedFeature.getFeatureId().add(filterFactory.featureId(fid));\n response.getInsertResults().getFeature().add(insertedFeature);\n }\n inserted += insert.getFeature().size();\n } catch (Exception e) {\n String msg = \"Error perfomring insert\";\n throw new WFSTransactionException(msg, e, insert.getHandle());\n }\n response.getTransactionSummary().setTotalInserted(BigInteger.valueOf(inserted));\n }\n", "output": " public void execute(EObject element, TransactionType request, Map featureStores,\n TransactionResponseType response, TransactionListener listener)\n throws WFSTransactionException {\n LOGGER.finer(\"Transasction Insert:\" + element);\n InsertElementType insert = (InsertElementType) element;\n long inserted = response.getTransactionSummary().getTotalInserted().longValue();\n try {\n HashMap schema2features = new HashMap();\n for (Iterator f = insert.getFeature().iterator(); f.hasNext();) {\n SimpleFeature feature = (SimpleFeature) f.next();\n SimpleFeatureType schema = feature.getFeatureType();\n FeatureCollection collection = (FeatureCollection) schema2features.get(schema);\n if (collection == null) {\n collection = new DefaultFeatureCollection(null, schema);\n schema2features.put(schema, collection);\n }\n collection.add(feature);\n }\n HashMap schema2fids = new HashMap();\n for (Iterator c = schema2features.values().iterator(); c.hasNext();) {\n FeatureCollection collection = (FeatureCollection) c.next();\n SimpleFeatureType schema = collection.getSchema();\n final QName elementName = new QName(schema.getName().getNamespaceURI(), schema.getTypeName());\n FeatureStore store = (FeatureStore) featureStores.get(elementName);\n if (store == null) {\n throw new WFSException(\"Could not locate FeatureStore for '\" + elementName\n + \"'\");\n }\n if (collection != null) {\n if(wfs.getCiteConformanceHacks()) {\n checkFeatureCoordinatesRange(collection);\n }\n final GeometryDescriptor defaultGeometry = store.getSchema().getDefaultGeometry();\n if(defaultGeometry != null) {\n CoordinateReferenceSystem target = defaultGeometry.getCRS();\n if (target != null) {\n collection = new ReprojectingFeatureCollection(collection, target);\n }\n }\n LOGGER.finer(\"Use featureValidation to check contents of insert\");\n List fids = (List) schema2fids.get(schema.getTypeName());\n if (fids == null) {\n fids = new LinkedList();\n schema2fids.put(schema.getTypeName(), fids);\n }\n listener.dataStoreChange(new TransactionEvent(TransactionEventType.PRE_INSERT,\n elementName, collection));\n fids.addAll(store.addFeatures(collection));\n }\n }\n InsertedFeatureType insertedFeature = null;\n for (Iterator f = insert.getFeature().iterator(); f.hasNext();) {\n SimpleFeature feature = (SimpleFeature) f.next();\n SimpleFeatureType schema = feature.getFeatureType();\n LinkedList fids = (LinkedList) schema2fids.get(schema.getTypeName());\n String fid = (String) fids.removeFirst();\n insertedFeature = WfsFactory.eINSTANCE.createInsertedFeatureType();\n insertedFeature.setHandle(insert.getHandle());\n insertedFeature.getFeatureId().add(filterFactory.featureId(fid));\n response.getInsertResults().getFeature().add(insertedFeature);\n }\n inserted += insert.getFeature().size();\n } catch (Exception e) {\n String msg = \"Error performing insert\";\n throw new WFSTransactionException(msg, e, insert.getHandle());\n }\n response.getTransactionSummary().setTotalInserted(BigInteger.valueOf(inserted));\n }\n"} {"input": " public void init(FMLInitializationEvent event) {\n mopBukket = new BlockMopBukket(900, Material.grass, mopBukket_Tex).setUnlocalizedName(\"mopBukket_UN\");\n mopBukket.setStepSound(Block.soundMetalFootstep);\n mop = (new ItemMop(901, mop_Tex)).setUnlocalizedName(\"Mop\").setCreativeTab(hygienicTab);\n food = (new ItemModFood(902, 18, true, modFood_Tex)).setUnlocalizedName(\"My Food\");\n apple = (new ItemModApple(903, 18, false, modFood_Tex)).setUnlocalizedName(\"My Apple\").setPotionEffect(\"potion.blindness\");\n glassBow = (new GlassBow(904, modBow_Tex)).setUnlocalizedName(\"Glass Bow\");\n GameRegistry.registerBlock(mopBukket, \"mopBukket_UN\");\n LanguageRegistry.addName(mopBukket, \"Mop Bukket\");\n LanguageRegistry.addName(mop, \"Mop\"); \n LanguageRegistry.addName(food, \"My Food\"); \n LanguageRegistry.addName(apple, \"My Apple\"); \n LanguageRegistry.addName(glassBow, \"Glass Bow\"); \n GameRegistry.addRecipe(new ItemStack(mopBukket, 1), new Object[] {\" \",\" X \",\"X X\", Character.valueOf('X'), Item.ingotIron});\n GameRegistry.addRecipe(new ItemStack(mop, 4), new Object[] {\"XXX\",\"XXX\",\"XXX\", Character.valueOf('X'), mopBukket});\n GameRegistry.addRecipe(new ItemStack(food, 4), new Object[] {\" \",\" X \",\" X \", Character.valueOf('X'), Item.ingotIron});\n GameRegistry.addRecipe(new ItemStack(apple, 4), new Object[] {\" X \",\" X \",\" X \", Character.valueOf('X'), Item.ingotIron});\n GameRegistry.addRecipe(new ItemStack(glassBow, 1), new Object[] {\" XS\",\"X S\",\" XS\", Character.valueOf('X'), Block.glass, Character.valueOf('S'), Item.silk});\n }\n", "output": " public void init(FMLInitializationEvent event) {\n mopBukket = new BlockMopBukket(900, Material.grass, mopBukket_Tex).setUnlocalizedName(\"mopBukket_UN\");\n mopBukket.setStepSound(Block.soundMetalFootstep);\n mop = (new ItemMop(901, mop_Tex)).setUnlocalizedName(\"Mop\").setCreativeTab(hygienicTab);\n food = (new ItemModFood(902, 18, true, modFood_Tex)).setUnlocalizedName(\"My Food\");\n apple = (new ItemModApple(903, 18, false, modFood_Tex)).setUnlocalizedName(\"My Apple\").setPotionEffect(\"potion.blindness\");\n glassBow = (new GlassBow(904, modBow_Tex)).setUnlocalizedName(\"Glass Bow\");\n GameRegistry.registerBlock(mopBukket, \"mopBukket_UN\");\n LanguageRegistry.addName(mopBukket, \"Mop Bukket\");\n LanguageRegistry.addName(mop, \"Mop\"); \n LanguageRegistry.addName(food, \"My Food\"); \n LanguageRegistry.addName(apple, \"My Apple\"); \n LanguageRegistry.addName(glassBow, \"Glass Bow\"); \n LanguageRegistry.instance().addStringLocalization(\"itemGroup.Hygienic\", \"en_US\", \"Hygienic\");\n GameRegistry.addRecipe(new ItemStack(mopBukket, 1), new Object[] {\" \",\" X \",\"X X\", Character.valueOf('X'), Item.ingotIron});\n GameRegistry.addRecipe(new ItemStack(mop, 4), new Object[] {\"XXX\",\"XXX\",\"XXX\", Character.valueOf('X'), mopBukket});\n GameRegistry.addRecipe(new ItemStack(food, 4), new Object[] {\" \",\" X \",\" X \", Character.valueOf('X'), Item.ingotIron});\n GameRegistry.addRecipe(new ItemStack(apple, 4), new Object[] {\" X \",\" X \",\" X \", Character.valueOf('X'), Item.ingotIron});\n GameRegistry.addRecipe(new ItemStack(glassBow, 1), new Object[] {\" XS\",\"X S\",\" XS\", Character.valueOf('X'), Block.glass, Character.valueOf('S'), Item.silk});\n }\n"} {"input": " public ImportStatementInfo resolve(final TargetClassInfo usingClass,\n final CallableUnitInfo usingMethod, final ClassInfoManager classInfoManager,\n final FieldInfoManager fieldInfoManager, final MethodInfoManager methodInfoManager) {\n MetricsToolSecurityManager.getInstance().checkAccess();\n if (null == classInfoManager) {\n throw new NullPointerException();\n }\n if (this.alreadyResolved()) {\n return this.getResolved();\n }\n final int fromLine = this.getFromLine();\n final int fromColumn = this.getFromColumn();\n final int toLine = this.getToLine();\n final int toColumn = this.getToColumn();\n final SortedSet accessibleClasses = new TreeSet();\n if (this.isAllClasses()) {\n final String[] namespace = this.getNamespace();\n final Collection specifiedClasses = classInfoManager\n .getClassInfos(namespace);\n accessibleClasses.addAll(specifiedClasses);\n } else {\n final String[] importName = this.getImportName();\n ClassInfo specifiedClass = classInfoManager.getClassInfo(importName);\n if (null == specifiedClass) {\n specifiedClass = new ExternalClassInfo(importName);\n }\n }\n this.resolvedInfo = new ImportStatementInfo(fromLine, fromColumn, toLine, toColumn,\n accessibleClasses);\n return this.resolvedInfo;\n }\n", "output": " public ImportStatementInfo resolve(final TargetClassInfo usingClass,\n final CallableUnitInfo usingMethod, final ClassInfoManager classInfoManager,\n final FieldInfoManager fieldInfoManager, final MethodInfoManager methodInfoManager) {\n MetricsToolSecurityManager.getInstance().checkAccess();\n if (null == classInfoManager) {\n throw new NullPointerException();\n }\n if (this.alreadyResolved()) {\n return this.getResolved();\n }\n final int fromLine = this.getFromLine();\n final int fromColumn = this.getFromColumn();\n final int toLine = this.getToLine();\n final int toColumn = this.getToColumn();\n final SortedSet accessibleClasses = new TreeSet();\n if (this.isAllClasses()) {\n final String[] namespace = this.getNamespace();\n final Collection specifiedClasses = classInfoManager\n .getClassInfos(namespace);\n accessibleClasses.addAll(specifiedClasses);\n } else {\n final String[] importName = this.getImportName();\n ClassInfo specifiedClass = classInfoManager.getClassInfo(importName);\n if (null == specifiedClass) {\n specifiedClass = new ExternalClassInfo(importName);\n accessibleClasses.add(specifiedClass);\n }\n }\n this.resolvedInfo = new ImportStatementInfo(fromLine, fromColumn, toLine, toColumn,\n accessibleClasses);\n return this.resolvedInfo;\n }\n"} {"input": "\tpublic static IResultMetaData retrieveResultMetaData(\n\t\t\tDataSetHandle dataSetHandle ) throws BirtException\n\t{\n\t\tList resultSetList = null;\n\t\tif ( dataSetHandle instanceof OdaDataSetHandle )\n\t\t{\n\t\t\tPropertyHandle handle = dataSetHandle.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP );\n\t\t\tif ( handle.isLocal( ) )\n\t\t\t\tresultSetList = handle.getListValue( );\n\t\t}\n\t\telse if ( dataSetHandle instanceof ScriptDataSetHandle )\n\t\t{\n\t\t\tPropertyHandle handle = dataSetHandle.getPropertyHandle( DataSetHandle.RESULT_SET_HINTS_PROP );\n\t\t\tif ( handle.isLocal( ) )\n\t\t\t\tresultSetList = handle.getListValue( );\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\tList computedList = (List) dataSetHandle.getProperty( OdaDataSetHandle.COMPUTED_COLUMNS_PROP );\n\t\tList columnMeta = new ArrayList( );\n\t\tResultSetColumnDefinition columnDef;\n\t\tint count = 0;\n\t\tif ( resultSetList != null && !resultSetList.isEmpty( ) )\n\t\t{\n\t\t\tResultSetColumn resultSetColumn;\n\t\t\tHashSet orgColumnNameSet = new HashSet( );\n\t\t\tHashSet uniqueColumnNameSet = new HashSet( );\n\t\t\tfor ( int n = 0; n < resultSetList.size( ); n++ )\n\t\t\t{\n\t\t\t\torgColumnNameSet.add( ( (ResultSetColumn) resultSetList.get( n ) ).getColumnName( ) );\n\t\t\t}\n\t\t\tfor ( int i = 0; i < resultSetList.size( ); i++ )\n\t\t\t{\n\t\t\t\tresultSetColumn = (ResultSetColumn) resultSetList.get( i );\n\t\t\t\tString columnName = resultSetColumn.getColumnName( );\n\t\t\t\tString uniqueColumnName = getUniqueName( orgColumnNameSet,\n\t\t\t\t\t\tuniqueColumnNameSet,\n\t\t\t\t\t\tcolumnName,\n\t\t\t\t\t\ti );\n\t\t\t\tuniqueColumnNameSet.add( uniqueColumnName );\n\t\t\t\tif ( !uniqueColumnName.equals( columnName ) )\n\t\t\t\t{\n\t\t\t\t\tupdateModelColumn( dataSetHandle, uniqueColumnName, i + 1 );\n\t\t\t\t}\n\t\t\t\tcolumnDef = new ResultSetColumnDefinition( uniqueColumnName );\n\t\t\t\tcolumnDef.setDataTypeName( resultSetColumn.getDataType( ) );\n\t\t\t\tcolumnDef.setDataType( DataAdapterUtil.adaptModelDataType( resultSetColumn.getDataType( ) ) );\n\t\t\t\tif ( resultSetColumn.getPosition( ) != null )\n\t\t\t\t\tcolumnDef.setColumnPosition( resultSetColumn.getPosition( )\n\t\t\t\t\t\t\t.intValue( ) );\n\t\t\t\tif ( resultSetColumn.getNativeDataType( ) != null )\n\t\t\t\t\tcolumnDef.setNativeDataType( resultSetColumn.getNativeDataType( )\n\t\t\t\t\t\t\t.intValue( ) );\n\t\t\t\tif ( findColumnHint( dataSetHandle, uniqueColumnName ) != null )\n\t\t\t\t{\n\t\t\t\t\tColumnHintHandle columnHint = findColumnHint( dataSetHandle,\n\t\t\t\t\t\t\tuniqueColumnName );\n\t\t\t\t\tcolumnDef.setAlias( columnHint.getAlias( ) );\n\t\t\t\t\tcolumnDef.setLableName( columnHint.getDisplayName( ) );\n\t\t\t\t}\n\t\t\t\tcolumnDef.setComputedColumn( false );\n\t\t\t\tcolumnMeta.add( columnDef );\n\t\t\t}\n\t\t\tcount += resultSetList.size( );\n\t\t\tif ( computedList != null )\n\t\t\t{\n\t\t\t\tfor ( int n = 0; n < computedList.size( ); n++ )\n\t\t\t\t{\n\t\t\t\t\torgColumnNameSet.add( ( (ComputedColumn) computedList.get( n ) ).getName( ) );\n\t\t\t\t}\n\t\t\t\tComputedColumn computedColumn;\n\t\t\t\tfor ( int i = 0; i < computedList.size( ); i++ )\n\t\t\t\t{\n\t\t\t\t\tcomputedColumn = (ComputedColumn) computedList.get( i );\n\t\t\t\t\tString columnName = computedColumn.getName( );\n\t\t\t\t\tString uniqueColumnName = getUniqueName( orgColumnNameSet,\n\t\t\t\t\t\t\tuniqueColumnNameSet,\n\t\t\t\t\t\t\tcolumnName,\n\t\t\t\t\t\t\ti + count );\n\t\t\t\t\tuniqueColumnNameSet.add( uniqueColumnName );\n\t\t\t\t\tif ( !uniqueColumnName.equals( columnName ) )\n\t\t\t\t\t{\n\t\t\t\t\t\tupdateComputedColumn( dataSetHandle, uniqueColumnName, columnName );\n\t\t\t\t\t}\n\t\t\t\t\tcolumnDef = new ResultSetColumnDefinition( uniqueColumnName );\n\t\t\t\t\tcolumnDef.setDataTypeName( computedColumn.getDataType( ) );\n\t\t\t\t\tcolumnDef.setDataType( org.eclipse.birt.report.data.adapter.api.DataAdapterUtil.adaptModelDataType( computedColumn.getDataType( ) ) );\n\t\t\t\t\tif ( findColumnHint( dataSetHandle, uniqueColumnName ) != null )\n\t\t\t\t\t{\n\t\t\t\t\t\tColumnHintHandle columnHint = findColumnHint( dataSetHandle,\n\t\t\t\t\t\t\t\tuniqueColumnName );\n\t\t\t\t\t\tcolumnDef.setAlias( columnHint.getAlias( ) );\n\t\t\t\t\t\tcolumnDef.setLableName( columnHint.getDisplayName( ) );\n\t\t\t\t\t}\n\t\t\t\t\tcolumnDef.setComputedColumn( true );\n\t\t\t\t\tcolumnMeta.add( columnDef );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new ResultMetaData2( columnMeta );\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tpublic static IResultMetaData retrieveResultMetaData(\n\t\t\tDataSetHandle dataSetHandle ) throws BirtException\n\t{\n\t\tList resultSetList = null;\n\t\tif ( dataSetHandle instanceof OdaDataSetHandle )\n\t\t{\n\t\t\tPropertyHandle handle = dataSetHandle.getPropertyHandle( OdaDataSetHandle.RESULT_SET_PROP );\n\t\t\tresultSetList = handle.getListValue( );\n\t\t}\n\t\telse if ( dataSetHandle instanceof ScriptDataSetHandle )\n\t\t{\n\t\t\tPropertyHandle handle = dataSetHandle.getPropertyHandle( DataSetHandle.RESULT_SET_HINTS_PROP );\n\t\t\tresultSetList = handle.getListValue( );\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn null;\n\t\t}\n\t\tList computedList = (List) dataSetHandle.getProperty( OdaDataSetHandle.COMPUTED_COLUMNS_PROP );\n\t\tList columnMeta = new ArrayList( );\n\t\tResultSetColumnDefinition columnDef;\n\t\tint count = 0;\n\t\tif ( resultSetList != null && !resultSetList.isEmpty( ) )\n\t\t{\n\t\t\tResultSetColumn resultSetColumn;\n\t\t\tHashSet orgColumnNameSet = new HashSet( );\n\t\t\tHashSet uniqueColumnNameSet = new HashSet( );\n\t\t\tfor ( int n = 0; n < resultSetList.size( ); n++ )\n\t\t\t{\n\t\t\t\torgColumnNameSet.add( ( (ResultSetColumn) resultSetList.get( n ) ).getColumnName( ) );\n\t\t\t}\n\t\t\tfor ( int i = 0; i < resultSetList.size( ); i++ )\n\t\t\t{\n\t\t\t\tresultSetColumn = (ResultSetColumn) resultSetList.get( i );\n\t\t\t\tString columnName = resultSetColumn.getColumnName( );\n\t\t\t\tString uniqueColumnName = getUniqueName( orgColumnNameSet,\n\t\t\t\t\t\tuniqueColumnNameSet,\n\t\t\t\t\t\tcolumnName,\n\t\t\t\t\t\ti );\n\t\t\t\tuniqueColumnNameSet.add( uniqueColumnName );\n\t\t\t\tif ( !uniqueColumnName.equals( columnName ) )\n\t\t\t\t{\n\t\t\t\t\tupdateModelColumn( dataSetHandle, uniqueColumnName, i + 1 );\n\t\t\t\t}\n\t\t\t\tcolumnDef = new ResultSetColumnDefinition( uniqueColumnName );\n\t\t\t\tcolumnDef.setDataTypeName( resultSetColumn.getDataType( ) );\n\t\t\t\tcolumnDef.setDataType( DataAdapterUtil.adaptModelDataType( resultSetColumn.getDataType( ) ) );\n\t\t\t\tif ( resultSetColumn.getPosition( ) != null )\n\t\t\t\t\tcolumnDef.setColumnPosition( resultSetColumn.getPosition( )\n\t\t\t\t\t\t\t.intValue( ) );\n\t\t\t\tif ( resultSetColumn.getNativeDataType( ) != null )\n\t\t\t\t\tcolumnDef.setNativeDataType( resultSetColumn.getNativeDataType( )\n\t\t\t\t\t\t\t.intValue( ) );\n\t\t\t\tif ( findColumnHint( dataSetHandle, uniqueColumnName ) != null )\n\t\t\t\t{\n\t\t\t\t\tColumnHintHandle columnHint = findColumnHint( dataSetHandle,\n\t\t\t\t\t\t\tuniqueColumnName );\n\t\t\t\t\tcolumnDef.setAlias( columnHint.getAlias( ) );\n\t\t\t\t\tcolumnDef.setLableName( columnHint.getDisplayName( ) );\n\t\t\t\t}\n\t\t\t\tcolumnDef.setComputedColumn( false );\n\t\t\t\tcolumnMeta.add( columnDef );\n\t\t\t}\n\t\t\tcount += resultSetList.size( );\n\t\t\tif ( computedList != null )\n\t\t\t{\n\t\t\t\tfor ( int n = 0; n < computedList.size( ); n++ )\n\t\t\t\t{\n\t\t\t\t\torgColumnNameSet.add( ( (ComputedColumn) computedList.get( n ) ).getName( ) );\n\t\t\t\t}\n\t\t\t\tComputedColumn computedColumn;\n\t\t\t\tfor ( int i = 0; i < computedList.size( ); i++ )\n\t\t\t\t{\n\t\t\t\t\tcomputedColumn = (ComputedColumn) computedList.get( i );\n\t\t\t\t\tString columnName = computedColumn.getName( );\n\t\t\t\t\tString uniqueColumnName = getUniqueName( orgColumnNameSet,\n\t\t\t\t\t\t\tuniqueColumnNameSet,\n\t\t\t\t\t\t\tcolumnName,\n\t\t\t\t\t\t\ti + count );\n\t\t\t\t\tuniqueColumnNameSet.add( uniqueColumnName );\n\t\t\t\t\tif ( !uniqueColumnName.equals( columnName ) )\n\t\t\t\t\t{\n\t\t\t\t\t\tupdateComputedColumn( dataSetHandle, uniqueColumnName, columnName );\n\t\t\t\t\t}\n\t\t\t\t\tcolumnDef = new ResultSetColumnDefinition( uniqueColumnName );\n\t\t\t\t\tcolumnDef.setDataTypeName( computedColumn.getDataType( ) );\n\t\t\t\t\tcolumnDef.setDataType( org.eclipse.birt.report.data.adapter.api.DataAdapterUtil.adaptModelDataType( computedColumn.getDataType( ) ) );\n\t\t\t\t\tif ( findColumnHint( dataSetHandle, uniqueColumnName ) != null )\n\t\t\t\t\t{\n\t\t\t\t\t\tColumnHintHandle columnHint = findColumnHint( dataSetHandle,\n\t\t\t\t\t\t\t\tuniqueColumnName );\n\t\t\t\t\t\tcolumnDef.setAlias( columnHint.getAlias( ) );\n\t\t\t\t\t\tcolumnDef.setLableName( columnHint.getDisplayName( ) );\n\t\t\t\t\t}\n\t\t\t\t\tcolumnDef.setComputedColumn( true );\n\t\t\t\t\tcolumnMeta.add( columnDef );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn new ResultMetaData2( columnMeta );\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": " public void doFilter(final ServletRequest request, final ServletResponse response,\n final FilterChain chain) throws IOException, ServletException {\n if ( interval < 0 ) {\n return;\n }\n final HttpServletRequest httpServletRequest = (HttpServletRequest)request;\n final HttpServletResponse httpServletResponse = (HttpServletResponse)response;\n Long lastUpdate = (Long)httpServletRequest.getSession(false).getAttribute(SESSION_KEEP_ALIVE_ATTRIBUTE_KEY);\n if(lastUpdate != null)\n {\n long delta = System.currentTimeMillis() - lastUpdate.longValue();\n if(delta >= interval) {\n final CrossContextRestApiInvoker rest = new SimpleCrossContextRestApiInvoker();\n HttpServletGetRequestWrapper wrap = new HttpServletGetRequestWrapper(httpServletRequest);\n final Map params = new HashMap();\n final RestResponse rr = rest.invoke(wrap, httpServletResponse, \"/ssp-platform/api/session.json\", params);\n httpServletRequest.getSession(false).setAttribute(SESSION_KEEP_ALIVE_ATTRIBUTE_KEY,System.currentTimeMillis());\n }\n } else {\n httpServletRequest.getSession(false).setAttribute(SESSION_KEEP_ALIVE_ATTRIBUTE_KEY,System.currentTimeMillis());\n }\n chain.doFilter(request, response);\n }\n", "output": " public void doFilter(final ServletRequest request, final ServletResponse response,\n final FilterChain chain) throws IOException, ServletException {\n if ( interval < 0 ) {\n chain.doFilter(request, response);\n return;\n }\n final HttpServletRequest httpServletRequest = (HttpServletRequest)request;\n final HttpServletResponse httpServletResponse = (HttpServletResponse)response;\n Long lastUpdate = (Long)httpServletRequest.getSession(false).getAttribute(SESSION_KEEP_ALIVE_ATTRIBUTE_KEY);\n if(lastUpdate != null)\n {\n long delta = System.currentTimeMillis() - lastUpdate.longValue();\n if(delta >= interval) {\n final CrossContextRestApiInvoker rest = new SimpleCrossContextRestApiInvoker();\n HttpServletGetRequestWrapper wrap = new HttpServletGetRequestWrapper(httpServletRequest);\n final Map params = new HashMap();\n final RestResponse rr = rest.invoke(wrap, httpServletResponse, \"/ssp-platform/api/session.json\", params);\n httpServletRequest.getSession(false).setAttribute(SESSION_KEEP_ALIVE_ATTRIBUTE_KEY,System.currentTimeMillis());\n }\n } else {\n httpServletRequest.getSession(false).setAttribute(SESSION_KEEP_ALIVE_ATTRIBUTE_KEY,System.currentTimeMillis());\n }\n chain.doFilter(request, response);\n }\n"} {"input": "\tprivate Message prepareForSending(BrokerMessage brkMessage, String messageSource)\n\t{\n\t\ttry\n\t\t{\n\t\t\tfinal Message message = new Message();\n\t\t\tif (StringUtils.isNotBlank(brkMessage.messageId))\n\t\t\t\tmessage.setMessageId(brkMessage.messageId);\n\t\t\tif (StringUtils.isNotBlank(brkMessage.correlationId))\n\t\t\t\tmessage.setCorrelationId(brkMessage.correlationId);\n\t\t\tif (StringUtils.isNotBlank(brkMessage.destinationName))\n\t\t\t\tmessage.setDestination(brkMessage.destinationName);\n\t\t\tif (StringUtils.isNotBlank(brkMessage.timestamp))\n\t\t\t{\n\t\t\t\tmessage.setTimestamp(DateUtil.parseISODate(brkMessage.timestamp).getTime());\n\t\t\t}\n\t\t\tif (StringUtils.isNotBlank(brkMessage.expiration))\n\t\t\t{\n\t\t\t\tmessage.setExpiration(DateUtil.parseISODate(brkMessage.expiration).getTime());\n\t\t\t}\n\t\t\tmessage.setContent(brkMessage.textPayload);\n\t\t\tmessage.setSourceApp(messageSource);\n\t\t\tif (log.isDebugEnabled())\n\t\t\t{\n\t\t\t\tlog.debug(\"Received message: {}\", message.getMessageId());\n\t\t\t}\n\t\t\treturn message;\n\t\t}\n\t\tcatch (Throwable e)\n\t\t{\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n", "output": "\tprivate Message prepareForSending(BrokerMessage brkMessage, String messageSource)\n\t{\n\t\ttry\n\t\t{\n\t\t\tfinal Message message = new Message();\n\t\t\tif (StringUtils.isNotBlank(brkMessage.messageId))\n\t\t\t\tmessage.setMessageId(brkMessage.messageId);\n\t\t\tif (StringUtils.isNotBlank(brkMessage.correlationId))\n\t\t\t\tmessage.setCorrelationId(brkMessage.correlationId);\n\t\t\tif (StringUtils.isNotBlank(brkMessage.destinationName))\n\t\t\t\tmessage.setDestination(brkMessage.destinationName);\n\t\t\tif (StringUtils.isNotBlank(brkMessage.timestamp))\n\t\t\t{\n\t\t\t\tmessage.setTimestamp(DateUtil.parseISODate(brkMessage.timestamp).getTime());\n\t\t\t}\n\t\t\tif (StringUtils.isNotBlank(brkMessage.expiration))\n\t\t\t{\n\t\t\t\tmessage.setExpiration(DateUtil.parseISODate(brkMessage.expiration).getTime());\n\t\t\t}\n\t\t\tmessage.setContent(brkMessage.textPayload);\n\t\t\tmessage.setSourceApp(messageSource);\n\t\t\tmessage.setPriority(brkMessage.priority);\n\t\t\tif (log.isDebugEnabled())\n\t\t\t{\n\t\t\t\tlog.debug(\"Received message: {}\", message.getMessageId());\n\t\t\t}\n\t\t\treturn message;\n\t\t}\n\t\tcatch (Throwable e)\n\t\t{\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n"} {"input": " public Rating(Surfer surfer, UserInfo userInfo){\n this.surfer = surfer;\n this.userInfos.add(userInfo);\n this.rating = 0;\n this.ratingCount = 0;\n }\n", "output": " public Rating(Surfer surfer, UserInfo userInfo){\n this.surfer = surfer;\n this.rating = 0;\n this.ratingCount = 0;\n }\n"} {"input": "\tprivate static Point getPointerLocation(final Component component) {\n\t\ttry {\n\t\t\tfinal Class MouseInfo_class = Class.forName(\"java.awt.MouseInfo\");\n\t\t\tfinal Method getPointerInfo_method = MouseInfo_class.getMethod(\"getPointerInfo\", null);\n\t\t\tfinal Class PointerInfo_class = Class.forName(\"java.awt.PointerInfo\");\n\t\t\tfinal Method getDevice_method = PointerInfo_class.getMethod(\"getDevice\", null);\n\t\t\tfinal Method getLocation_method = PointerInfo_class.getMethod(\"getLocation\", null);\n\t\t\treturn (Point)AccessController.doPrivileged(new PrivilegedExceptionAction() {\n\t\t\t\tpublic final Object run() throws Exception {\n\t\t\t\t\tObject pointer_info = getPointerInfo_method.invoke(null, null);\n\t\t\t\t\tGraphicsDevice device = (GraphicsDevice)getDevice_method.invoke(pointer_info, null);\n\t\t\t\t\tif (device == component.getGraphicsConfiguration().getDevice()) {\n\t\t\t\t\t\treturn (Point)getLocation_method.invoke(pointer_info, null);\n\t\t\t\t\t} else\n\t\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (PrivilegedActionException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e.getCause());\n\t\t} catch (NoSuchMethodException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e);\n\t\t} catch (IllegalAccessException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e);\n\t\t} catch (ClassNotFoundException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e);\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tprivate static Point getPointerLocation(final Component component) {\n\t\ttry {\n\t\t\tfinal Class MouseInfo_class = Class.forName(\"java.awt.MouseInfo\");\n\t\t\tfinal Method getPointerInfo_method = MouseInfo_class.getMethod(\"getPointerInfo\", null);\n\t\t\tfinal Class PointerInfo_class = Class.forName(\"java.awt.PointerInfo\");\n\t\t\tfinal Method getDevice_method = PointerInfo_class.getMethod(\"getDevice\", null);\n\t\t\tfinal Method getLocation_method = PointerInfo_class.getMethod(\"getLocation\", null);\n\t\t\treturn (Point)AccessController.doPrivileged(new PrivilegedExceptionAction() {\n\t\t\t\tpublic final Object run() throws Exception {\n\t\t\t\t\tObject pointer_info = getPointerInfo_method.invoke(null, null);\n\t\t\t\t\tGraphicsDevice device = (GraphicsDevice)getDevice_method.invoke(pointer_info, null);\n\t\t\t\t\tif (device == component.getGraphicsConfiguration().getDevice()) {\n\t\t\t\t\t\treturn (Point)getLocation_method.invoke(pointer_info, null);\n\t\t\t\t\t} else\n\t\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (PrivilegedActionException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e.getCause());\n\t\t} catch (NoSuchMethodException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e);\n\t\t} catch (ClassNotFoundException e) {\n\t\t\tLWJGLUtil.log(\"Failed to query pointer location: \" + e);\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": "\tpublic void updateMissingPlacements() {\n\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: Beginning updating applications...\");\n\t\tSystem.out.println(\"-------------------------------------------------------------------\");\n\t\ttry {\n\t\t\tCollection applications = getChildCareApplicationHome().findApplicationsWithoutPlacing();\n\t\t\tint size = applications.size();\n\t\t\tint counter = 1;\n\t\t\tIterator iter = applications.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tChildCareApplication application = (ChildCareApplication) iter.next();\n\t\t\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: Updating application \" + counter + \" of \" + size + \" (ID=\" + application.getPrimaryKey() + \")\");\n\t\t\t\tIWTimestamp fromDate = new IWTimestamp(application.getFromDate());\n\t\t\t\tTimestamp endDate = null;\n\t\t\t\tif (application.getRejectionDate() != null)\n\t\t\t\t\tendDate = new IWTimestamp(application.getRejectionDate()).getTimestamp();\n\t\t\t\ttry {\n\t\t\t\t\tCollection contracts = getChildCareContractHome().findByApplication(((Integer)application.getPrimaryKey()).intValue());\n\t\t\t\t\tSchoolClass group = null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tgroup = getSchoolBusiness().getSchoolClassHome().findOneBySchool(application.getProviderId());\n\t\t\t\t\t}\n\t\t\t\t\tcatch (FinderException fe) {\n\t\t\t\t\t\tSystem.out.println(\"Found no group for provider = \" + application.getProviderId());\n\t\t\t\t\t\tgroup = null;\n\t\t\t\t\t}\n\t\t\t\t\tif (group != null) {\n\t\t\t\t\t\tSchoolClassMember member = getSchoolBusiness().storeSchoolClassMember(application.getChildId(), ((Integer) group.getPrimaryKey()).intValue(), fromDate.getTimestamp(), endDate, -1, null);\n\t\t\t\t\t\tIterator iterator = contracts.iterator();\n\t\t\t\t\t\twhile (iterator.hasNext()) {\n\t\t\t\t\t\t\tChildCareContract contract = (ChildCareContract) iterator.next();\n\t\t\t\t\t\t\tcontract.setSchoolClassMember(member);\n\t\t\t\t\t\t\tcontract.store();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (FinderException fe) {\n\t\t\t\t\tfe.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (RemoteException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tcatch (FinderException e) {\n\t\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: No applications found with missing placements.\");\n\t\t}\n\t\tSystem.out.println(\"-------------------------------------------------------------------\");\n\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: Done updating applications........\");\n\t}\n", "output": "\tpublic void updateMissingPlacements() {\n\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: Beginning updating applications...\");\n\t\tSystem.out.println(\"-------------------------------------------------------------------\");\n\t\ttry {\n\t\t\tCollection applications = getChildCareApplicationHome().findApplicationsWithoutPlacing();\n\t\t\tint size = applications.size();\n\t\t\tint counter = 1;\n\t\t\tIterator iter = applications.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tChildCareApplication application = (ChildCareApplication) iter.next();\n\t\t\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: Updating application \" + counter + \" of \" + size + \" (ID=\" + application.getPrimaryKey() + \")\");\n\t\t\t\tIWTimestamp fromDate = new IWTimestamp(application.getFromDate());\n\t\t\t\tTimestamp endDate = null;\n\t\t\t\tif (application.getRejectionDate() != null)\n\t\t\t\t\tendDate = new IWTimestamp(application.getRejectionDate()).getTimestamp();\n\t\t\t\ttry {\n\t\t\t\t\tCollection contracts = getChildCareContractHome().findByApplication(((Integer)application.getPrimaryKey()).intValue());\n\t\t\t\t\tSchoolClass group = null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tgroup = getSchoolBusiness().getSchoolClassHome().findOneBySchool(application.getProviderId());\n\t\t\t\t\t}\n\t\t\t\t\tcatch (FinderException fe) {\n\t\t\t\t\t\tSystem.out.println(\"Found no group for provider = \" + application.getProviderId());\n\t\t\t\t\t\tgroup = null;\n\t\t\t\t\t}\n\t\t\t\t\tif (group != null) {\n\t\t\t\t\t\tSchoolClassMember member = getSchoolBusiness().storeSchoolClassMember(application.getChildId(), ((Integer) group.getPrimaryKey()).intValue(), -1, group.getSchoolTypeId(), fromDate.getTimestamp(), endDate, -1, null);\n\t\t\t\t\t\tIterator iterator = contracts.iterator();\n\t\t\t\t\t\twhile (iterator.hasNext()) {\n\t\t\t\t\t\t\tChildCareContract contract = (ChildCareContract) iterator.next();\n\t\t\t\t\t\t\tcontract.setSchoolClassMember(member);\n\t\t\t\t\t\t\tcontract.store();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch (FinderException fe) {\n\t\t\t\t\tfe.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (RemoteException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tcatch (FinderException e) {\n\t\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: No applications found with missing placements.\");\n\t\t}\n\t\tSystem.out.println(\"-------------------------------------------------------------------\");\n\t\tSystem.out.println(\"[ContractSchoolPlacementUpdate]: Done updating applications........\");\n\t}\n"} {"input": " public void encodeBegin(FacesContext context, UIComponent component)\n throws IOException\n {\n ResponseWriter out = context.getResponseWriter();\n String id = component.getId();\n String accesskey;\n String charset;\n String coords;\n String dir;\n boolean disabled;\n String hreflang;\n String lang;\n String onblur;\n String onclick;\n String ondblclick;\n String onfocus;\n String onkeydown;\n String onkeypress;\n String onkeyup;\n String onmousedown;\n String onmousemove;\n String onmouseout;\n String onmouseover;\n String onmouseup;\n String rel;\n String rev;\n String shape;\n String style;\n String styleClass;\n String tabindex;\n String target;\n String title;\n String type;\n Object value;\n if (component instanceof HtmlCommandLink) {\n HtmlCommandLink htmlCommandLink = (HtmlCommandLink) component;\n accesskey = htmlCommandLink.getAccesskey();\n charset = htmlCommandLink.getCharset();\n coords = htmlCommandLink.getCoords();\n dir = htmlCommandLink.getDir();\n disabled = htmlCommandLink.isDisabled();\n hreflang = htmlCommandLink.getHreflang();\n lang = htmlCommandLink.getLang();\n onblur = htmlCommandLink.getOnblur();\n onclick = htmlCommandLink.getOnclick();\n ondblclick = htmlCommandLink.getOndblclick();\n onfocus = htmlCommandLink.getOnfocus();\n onkeydown = htmlCommandLink.getOnkeydown();\n onkeypress = htmlCommandLink.getOnkeypress();\n onkeyup = htmlCommandLink.getOnkeyup();\n onmousedown = htmlCommandLink.getOnmousedown();\n onmousemove = htmlCommandLink.getOnmousemove();\n onmouseout = htmlCommandLink.getOnmouseout();\n onmouseover = htmlCommandLink.getOnmouseover();\n onmouseup = htmlCommandLink.getOnmouseup();\n rel = htmlCommandLink.getRel();\n rev = htmlCommandLink.getRev();\n shape = htmlCommandLink.getShape();\n style = htmlCommandLink.getStyle();\n styleClass = htmlCommandLink.getStyleClass();\n tabindex = htmlCommandLink.getTabindex();\n title = htmlCommandLink.getTitle();\n type = htmlCommandLink.getType();\n target = htmlCommandLink.getTarget();\n value = htmlCommandLink.getValue();\n }\n else {\n Map attrMap = component.getAttributes();\n accesskey = (String) attrMap.get(\"accesskey\");\n charset = (String) attrMap.get(\"charset\");\n coords = (String) attrMap.get(\"coords\");\n dir = (String) attrMap.get(\"dir\");\n disabled = (Boolean) attrMap.get(\"disabled\");\n hreflang = (String) attrMap.get(\"hreflang\");\n lang = (String) attrMap.get(\"lang\");\n onblur = (String) attrMap.get(\"onblur\");\n onclick = (String) attrMap.get(\"onclick\");\n ondblclick = (String) attrMap.get(\"ondblclick\");\n onfocus = (String) attrMap.get(\"onfocus\");\n onkeydown = (String) attrMap.get(\"onkeydown\");\n onkeypress = (String) attrMap.get(\"onkeypress\");\n onkeyup = (String) attrMap.get(\"onkeyup\");\n onmousedown = (String) attrMap.get(\"onmousedown\");\n onmousemove = (String) attrMap.get(\"onmousemove\");\n onmouseout = (String) attrMap.get(\"onmouseout\");\n onmouseover = (String) attrMap.get(\"onmouseover\");\n onmouseup = (String) attrMap.get(\"onmouseup\");\n rel = (String) attrMap.get(\"rel\");\n rev = (String) attrMap.get(\"rev\");\n shape = (String) attrMap.get(\"shape\");\n style = (String) attrMap.get(\"style\");\n styleClass = (String) attrMap.get(\"styleClass\");\n tabindex = (String) attrMap.get(\"tabindex\");\n title = (String) attrMap.get(\"title\");\n type = (String) attrMap.get(\"type\");\n target = (String)attrMap.get(\"target\");\n value = attrMap.get(\"value\");\n }\n String clientId = component.getClientId(context);\n String formClientId = getFormId(context, component);\n String hiddenFieldName = clientId + \":link\";\n if (disabled) {\n out.startElement(\"span\", component);\n if (target != null)\n\tout.writeAttribute(\"target\", target, \"target\");\n }\n else {\n out.startElement(\"a\", component);\n out.writeAttribute(\"href\", \"#\", \"href\");\n }\n if (id != null && ! id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX))\n out.writeAttribute(\"id\", component.getClientId(context), \"id\");\n if (accesskey != null)\n out.writeAttribute(\"accesskey\", accesskey, \"accesskey\");\n if (charset != null)\n out.writeAttribute(\"charset\", charset, \"charset\");\n if (coords != null)\n out.writeAttribute(\"coords\", coords, \"coords\");\n if (dir != null)\n out.writeAttribute(\"dir\", dir, \"dir\");\n if (hreflang != null)\n out.writeAttribute(\"hreflang\", hreflang, \"hreflang\");\n if (lang != null)\n out.writeAttribute(\"lang\", lang, \"lang\");\n if (onblur != null)\n out.writeAttribute(\"onblur\", onblur, \"onblur\");\n if (disabled) {\n }\n else {\n HtmlFormRenderer.addCommandLinkHiddenField(context,\n formClientId,\n hiddenFieldName);\n StringBuilder clickJs = new StringBuilder();\n clickJs.append(\"document.forms['\");\n clickJs.append(formClientId);\n clickJs.append(\"']['\");\n clickJs.append(hiddenFieldName);\n clickJs.append(\"'].value='\");\n clickJs.append(clientId);\n clickJs.append(\"';\");\n final int childCount = component.getChildCount();\n if (childCount > 0 && !disabled) {\n\tList children = component.getChildren();\n\tfor (int i = 0; i < childCount; i++) {\n\t UIComponent child = children.get(i);\n\t if (child instanceof UIParameter) {\n\t UIParameter param = (UIParameter) child;\n\t String enc = out.getCharacterEncoding();\n\t clickJs.append(\"document.forms['\");\n\t clickJs.append(formClientId);\n\t clickJs.append(\"']['\");\n\t String name = param.getName();\n\t String encodedName = URLEncoder.encode(name, enc);\n\t HtmlFormRenderer.addCommandLinkParam(context, formClientId, name);\n\t clickJs.append(encodedName);\n\t clickJs.append(\"'].value='\");\n\t String val = toString(context, param, param.getValue());\n\t String encodedVal = URLEncoder.encode(val, enc);\n\t clickJs.append(encodedVal);\n\t clickJs.append(\"';\");\n\t }\n\t}\n }\n if (target != null) {\n\tclickJs.append(\"document.forms['\");\n\tclickJs.append(formClientId);\n\tclickJs.append(\"'].target='\");\n\tclickJs.append(target);\n\tclickJs.append(\"';\");\n }\n clickJs.append(\"document.forms['\");\n clickJs.append(formClientId);\n clickJs.append(\"'].submit();\");\n clickJs.append(\"return false;\");\n if (onclick != null) {\n\tString code = (\"var a = function(){\" + onclick + \"};\"\n\t\t + \"var b = function() {\" + clickJs + \"};\"\n\t\t + \"return a() && b();\");\n\tout.writeAttribute(\"onclick\", code, \"onclick\");\n }\n else\n\tout.writeAttribute(\"onclick\", clickJs.toString(), \"onclick\");\n }\n if (ondblclick != null)\n out.writeAttribute(\"ondblclick\", ondblclick, \"ondblclick\");\n if (onfocus != null)\n out.writeAttribute(\"onfocus\", onfocus, \"onfocus\");\n if (onkeydown != null)\n out.writeAttribute(\"onkeydown\", onkeydown, \"onkeydown\");\n if (onkeypress != null)\n out.writeAttribute(\"onkeypress\", onkeypress, \"onkeypress\");\n if (onkeyup != null)\n out.writeAttribute(\"onkeyup\", onkeyup, \"onkeyup\");\n if (onmousedown != null)\n out.writeAttribute(\"onmousedown\", onmousedown, \"onmousedown\");\n if (onmousemove != null)\n out.writeAttribute(\"onmousemove\", onmousemove, \"onmousemove\");\n if (onmouseout != null)\n out.writeAttribute(\"onmouseout\", onmouseout, \"onmouseout\");\n if (onmouseover != null)\n out.writeAttribute(\"onmouseover\", onmouseover, \"onmouseover\");\n if (onmouseup != null)\n out.writeAttribute(\"onmouseup\", onmouseup, \"onmouseup\");\n if (rel != null)\n out.writeAttribute(\"rel\", rel, \"rel\");\n if (rev != null)\n out.writeAttribute(\"rev\", rev, \"rev\");\n if (shape != null)\n out.writeAttribute(\"shape\", shape, \"shape\");\n if (style != null)\n out.writeAttribute(\"style\", style, \"style\");\n if (styleClass != null)\n out.writeAttribute(\"class\", styleClass, \"class\");\n if (tabindex != null)\n out.writeAttribute(\"tabindex\", tabindex, \"tabindex\");\n if (title != null)\n out.writeAttribute(\"title\", title, \"title\");\n if (type != null)\n out.writeAttribute(\"type\", type, \"type\");\n if (value != null)\n out.writeText(toString(context, component, value), \"value\");\n final int childCount = component.getChildCount();\n if (childCount > 0) {\n List children = component.getChildren();\n for (int i = 0; i < childCount; i++) {\n\tUIComponent child = children.get(i);\n\tif (child instanceof UIParameter) {\n\t}\n\telse if (child.isRendered()) {\n\t child.encodeBegin(context);\n\t child.encodeChildren(context);\n\t child.encodeEnd(context);\n\t}\n }\n }\n if (disabled)\n out.endElement(\"span\");\n else\n out.endElement(\"a\");\n }\n", "output": " public void encodeBegin(FacesContext context, UIComponent component)\n throws IOException\n {\n ResponseWriter out = context.getResponseWriter();\n String id = component.getId();\n String accesskey;\n String charset;\n String coords;\n String dir;\n boolean disabled;\n String hreflang;\n String lang;\n String onblur;\n String onclick;\n String ondblclick;\n String onfocus;\n String onkeydown;\n String onkeypress;\n String onkeyup;\n String onmousedown;\n String onmousemove;\n String onmouseout;\n String onmouseover;\n String onmouseup;\n String rel;\n String rev;\n String shape;\n String style;\n String styleClass;\n String tabindex;\n String target;\n String title;\n String type;\n Object value;\n if (component instanceof HtmlCommandLink) {\n HtmlCommandLink htmlCommandLink = (HtmlCommandLink) component;\n accesskey = htmlCommandLink.getAccesskey();\n charset = htmlCommandLink.getCharset();\n coords = htmlCommandLink.getCoords();\n dir = htmlCommandLink.getDir();\n disabled = htmlCommandLink.isDisabled();\n hreflang = htmlCommandLink.getHreflang();\n lang = htmlCommandLink.getLang();\n onblur = htmlCommandLink.getOnblur();\n onclick = htmlCommandLink.getOnclick();\n ondblclick = htmlCommandLink.getOndblclick();\n onfocus = htmlCommandLink.getOnfocus();\n onkeydown = htmlCommandLink.getOnkeydown();\n onkeypress = htmlCommandLink.getOnkeypress();\n onkeyup = htmlCommandLink.getOnkeyup();\n onmousedown = htmlCommandLink.getOnmousedown();\n onmousemove = htmlCommandLink.getOnmousemove();\n onmouseout = htmlCommandLink.getOnmouseout();\n onmouseover = htmlCommandLink.getOnmouseover();\n onmouseup = htmlCommandLink.getOnmouseup();\n rel = htmlCommandLink.getRel();\n rev = htmlCommandLink.getRev();\n shape = htmlCommandLink.getShape();\n style = htmlCommandLink.getStyle();\n styleClass = htmlCommandLink.getStyleClass();\n tabindex = htmlCommandLink.getTabindex();\n title = htmlCommandLink.getTitle();\n type = htmlCommandLink.getType();\n target = htmlCommandLink.getTarget();\n value = htmlCommandLink.getValue();\n }\n else {\n Map attrMap = component.getAttributes();\n accesskey = (String) attrMap.get(\"accesskey\");\n charset = (String) attrMap.get(\"charset\");\n coords = (String) attrMap.get(\"coords\");\n dir = (String) attrMap.get(\"dir\");\n disabled = (Boolean) attrMap.get(\"disabled\");\n hreflang = (String) attrMap.get(\"hreflang\");\n lang = (String) attrMap.get(\"lang\");\n onblur = (String) attrMap.get(\"onblur\");\n onclick = (String) attrMap.get(\"onclick\");\n ondblclick = (String) attrMap.get(\"ondblclick\");\n onfocus = (String) attrMap.get(\"onfocus\");\n onkeydown = (String) attrMap.get(\"onkeydown\");\n onkeypress = (String) attrMap.get(\"onkeypress\");\n onkeyup = (String) attrMap.get(\"onkeyup\");\n onmousedown = (String) attrMap.get(\"onmousedown\");\n onmousemove = (String) attrMap.get(\"onmousemove\");\n onmouseout = (String) attrMap.get(\"onmouseout\");\n onmouseover = (String) attrMap.get(\"onmouseover\");\n onmouseup = (String) attrMap.get(\"onmouseup\");\n rel = (String) attrMap.get(\"rel\");\n rev = (String) attrMap.get(\"rev\");\n shape = (String) attrMap.get(\"shape\");\n style = (String) attrMap.get(\"style\");\n styleClass = (String) attrMap.get(\"styleClass\");\n tabindex = (String) attrMap.get(\"tabindex\");\n title = (String) attrMap.get(\"title\");\n type = (String) attrMap.get(\"type\");\n target = (String)attrMap.get(\"target\");\n value = attrMap.get(\"value\");\n }\n String clientId = component.getClientId(context);\n String formClientId = getFormId(context, component);\n String hiddenFieldName = clientId + \":link\";\n if (disabled) {\n out.startElement(\"span\", component);\n if (target != null)\n\tout.writeAttribute(\"target\", target, \"target\");\n }\n else {\n out.startElement(\"a\", component);\n out.writeAttribute(\"href\", \"#\", \"href\");\n }\n if (id != null && ! id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX))\n out.writeAttribute(\"id\", component.getClientId(context), \"id\");\n if (accesskey != null)\n out.writeAttribute(\"accesskey\", accesskey, \"accesskey\");\n if (charset != null)\n out.writeAttribute(\"charset\", charset, \"charset\");\n if (coords != null)\n out.writeAttribute(\"coords\", coords, \"coords\");\n if (dir != null)\n out.writeAttribute(\"dir\", dir, \"dir\");\n if (hreflang != null)\n out.writeAttribute(\"hreflang\", hreflang, \"hreflang\");\n if (lang != null)\n out.writeAttribute(\"lang\", lang, \"lang\");\n if (onblur != null)\n out.writeAttribute(\"onblur\", onblur, \"onblur\");\n if (disabled) {\n }\n else {\n HtmlFormRenderer.addCommandLinkHiddenField(context,\n formClientId,\n hiddenFieldName);\n StringBuilder clickJs = new StringBuilder();\n clickJs.append(\"document.forms['\");\n clickJs.append(formClientId);\n clickJs.append(\"']['\");\n clickJs.append(hiddenFieldName);\n clickJs.append(\"'].value='\");\n clickJs.append(clientId);\n clickJs.append(\"';\");\n final int childCount = component.getChildCount();\n if (childCount > 0 && !disabled) {\n\tList children = component.getChildren();\n\tfor (int i = 0; i < childCount; i++) {\n\t UIComponent child = children.get(i);\n\t if (child instanceof UIParameter) {\n\t UIParameter param = (UIParameter) child;\n\t String enc = out.getCharacterEncoding();\n\t clickJs.append(\"document.forms['\");\n\t clickJs.append(formClientId);\n\t clickJs.append(\"']['\");\n\t String name = param.getName();\n\t String encodedName = URLEncoder.encode(name, enc);\n\t HtmlFormRenderer.addCommandLinkParam(context, formClientId, encodedName);\n\t clickJs.append(encodedName);\n\t clickJs.append(\"'].value='\");\n\t String val = toString(context, param, param.getValue());\n\t String encodedVal = URLEncoder.encode(val, enc);\n\t clickJs.append(encodedVal);\n\t clickJs.append(\"';\");\n\t }\n\t}\n }\n if (target != null) {\n\tclickJs.append(\"document.forms['\");\n\tclickJs.append(formClientId);\n\tclickJs.append(\"'].target='\");\n\tclickJs.append(target);\n\tclickJs.append(\"';\");\n }\n clickJs.append(\"document.forms['\");\n clickJs.append(formClientId);\n clickJs.append(\"'].submit();\");\n clickJs.append(\"return false;\");\n if (onclick != null) {\n\tString code = (\"var a = function(){\" + onclick + \"};\"\n\t\t + \"var b = function() {\" + clickJs + \"};\"\n\t\t + \"return a() && b();\");\n\tout.writeAttribute(\"onclick\", code, \"onclick\");\n }\n else\n\tout.writeAttribute(\"onclick\", clickJs.toString(), \"onclick\");\n }\n if (ondblclick != null)\n out.writeAttribute(\"ondblclick\", ondblclick, \"ondblclick\");\n if (onfocus != null)\n out.writeAttribute(\"onfocus\", onfocus, \"onfocus\");\n if (onkeydown != null)\n out.writeAttribute(\"onkeydown\", onkeydown, \"onkeydown\");\n if (onkeypress != null)\n out.writeAttribute(\"onkeypress\", onkeypress, \"onkeypress\");\n if (onkeyup != null)\n out.writeAttribute(\"onkeyup\", onkeyup, \"onkeyup\");\n if (onmousedown != null)\n out.writeAttribute(\"onmousedown\", onmousedown, \"onmousedown\");\n if (onmousemove != null)\n out.writeAttribute(\"onmousemove\", onmousemove, \"onmousemove\");\n if (onmouseout != null)\n out.writeAttribute(\"onmouseout\", onmouseout, \"onmouseout\");\n if (onmouseover != null)\n out.writeAttribute(\"onmouseover\", onmouseover, \"onmouseover\");\n if (onmouseup != null)\n out.writeAttribute(\"onmouseup\", onmouseup, \"onmouseup\");\n if (rel != null)\n out.writeAttribute(\"rel\", rel, \"rel\");\n if (rev != null)\n out.writeAttribute(\"rev\", rev, \"rev\");\n if (shape != null)\n out.writeAttribute(\"shape\", shape, \"shape\");\n if (style != null)\n out.writeAttribute(\"style\", style, \"style\");\n if (styleClass != null)\n out.writeAttribute(\"class\", styleClass, \"class\");\n if (tabindex != null)\n out.writeAttribute(\"tabindex\", tabindex, \"tabindex\");\n if (title != null)\n out.writeAttribute(\"title\", title, \"title\");\n if (type != null)\n out.writeAttribute(\"type\", type, \"type\");\n if (value != null)\n out.writeText(toString(context, component, value), \"value\");\n final int childCount = component.getChildCount();\n if (childCount > 0) {\n List children = component.getChildren();\n for (int i = 0; i < childCount; i++) {\n\tUIComponent child = children.get(i);\n\tif (child instanceof UIParameter) {\n\t}\n\telse if (child.isRendered()) {\n\t child.encodeBegin(context);\n\t child.encodeChildren(context);\n\t child.encodeEnd(context);\n\t}\n }\n }\n if (disabled)\n out.endElement(\"span\");\n else\n out.endElement(\"a\");\n }\n"} {"input": "\tpublic void start() throws Exception {\n\t\tlogger = LoggerFactory.getLogger(Main.class);\n\t\tfinal String PROACTIVE_PNP_PORT = DcepConstants.getProperties().getProperty(\"dcep.proactive.pnp.port\");\n\t\tfinal String PROACTIVE_HTTP_PORT = DcepConstants.getProperties().getProperty(\"dcep.proactive.http.port\");\n\t\tfinal String PROACTIVE_RMI_PORT = DcepConstants.getProperties().getProperty(\"dcep.proactive.rmi.port\");\n\t\tlogger.debug(\"Setting system property 'proactive.pnp.port' to: \" + PROACTIVE_PNP_PORT);\n\t\tSystem.getProperties().setProperty(\"proactive.pnp.port\", PROACTIVE_PNP_PORT);\n\t\tlogger.debug(\"Setting system property 'proactive.http.port' to: \" + PROACTIVE_HTTP_PORT);\n\t\tSystem.getProperties().setProperty(\"proactive.http.port\", PROACTIVE_HTTP_PORT);\n\t\tlogger.debug(\"Setting system property 'proactive.rmi.port' to: \" + PROACTIVE_RMI_PORT);\n\t\tSystem.getProperties().setProperty(\"proactive.rmi.port\", PROACTIVE_RMI_PORT);\n\t\tCentralPAPropertyRepository.JAVA_SECURITY_POLICY\n\t\t\t\t.setValue(propertiesFile);\n\t\tCentralPAPropertyRepository.GCM_PROVIDER\n\t\t\t\t.setValue(\"org.objectweb.proactive.core.component.Fractive\");\n\t\tFactory factory = FactoryFactory.getFactory();\n\t\tHashMap context = new HashMap();\n\t\troot = (Component) factory.newComponent(\"PlayPlatform\", context);\n\t\tGCM.getGCMLifeCycleController(root).startFc();\n\t\tboolean init = false;\n\t\twhile (!init) {\n\t\t\tboolean overallInitStatus = true;\n\t\t\tfor (Component subcomponent : GCM.getContentController(root)\n\t\t\t\t\t.getFcSubComponents()) {\n\t\t\t\toverallInitStatus = overallInitStatus\n\t\t\t\t\t\t&& GCM.getGCMLifeCycleController(subcomponent)\n\t\t\t\t\t\t\t\t.getFcState()\n\t\t\t\t\t\t\t\t.equals(LifeCycleController.STARTED);\n\t\t\t}\n\t\t\tif (overallInitStatus == true) {\n\t\t\t\tinit = true;\n\t\t\t} else {\n\t\t\t\tlogger.info(\"Wait for all subcomponents to be started...\");\n\t\t\t}\n\t\t\tThread.sleep(500);\n\t\t}\n\t\tQueryDispatchApi queryDispatchApi = ((eu.play_project.play_platformservices.api.QueryDispatchApi) root\n\t\t\t\t.getFcInterface(\"QueryDispatchApi\"));\n\t\tfor (String queryFileName : DcepConstants.getProperties()\n\t\t\t\t.getProperty(\"dcep.startup.registerqueries\").split(\",\")) {\n\t\t\tqueryFileName = queryFileName.trim();\n\t\t\ttry {\n\t\t\t\tString queryString = IOUtils.toString(Main.class\n\t\t\t\t\t\t.getClassLoader().getResourceAsStream(queryFileName));\n\t\t\t\tlogger.info(queryString);\n\t\t\t\tqueryDispatchApi.registerQuery(queryFileName, queryString);\n\t\t\t} catch (QueryDispatchException e) {\n\t\t\t\tlogger.warn(\"Error registering query {} on startup: {}\",\n\t\t\t\t\t\tqueryFileName, e.getMessage());\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void start() throws Exception {\n\t\tlogger = LoggerFactory.getLogger(Main.class);\n\t\tfinal String PROACTIVE_PNP_PORT = DcepConstants.getProperties().getProperty(\"dcep.proactive.pnp.port\");\n\t\tfinal String PROACTIVE_HTTP_PORT = DcepConstants.getProperties().getProperty(\"dcep.proactive.http.port\");\n\t\tfinal String PROACTIVE_RMI_PORT = DcepConstants.getProperties().getProperty(\"dcep.proactive.rmi.port\");\n\t\tlogger.debug(\"Setting system property 'proactive.pnp.port' to: \" + PROACTIVE_PNP_PORT);\n\t\tSystem.getProperties().setProperty(\"proactive.pnp.port\", PROACTIVE_PNP_PORT);\n\t\tlogger.debug(\"Setting system property 'proactive.http.port' to: \" + PROACTIVE_HTTP_PORT);\n\t\tSystem.getProperties().setProperty(\"proactive.http.port\", PROACTIVE_HTTP_PORT);\n\t\tlogger.debug(\"Setting system property 'proactive.rmi.port' to: \" + PROACTIVE_RMI_PORT);\n\t\tSystem.getProperties().setProperty(\"proactive.rmi.port\", PROACTIVE_RMI_PORT);\n\t\tCentralPAPropertyRepository.JAVA_SECURITY_POLICY\n\t\t\t\t.setValue(propertiesFile);\n\t\tCentralPAPropertyRepository.GCM_PROVIDER\n\t\t\t\t.setValue(\"org.objectweb.proactive.core.component.Fractive\");\n\t\tFactory factory = FactoryFactory.getFactory();\n\t\tHashMap context = new HashMap();\n\t\troot = (Component) factory.newComponent(\"PlayPlatform\", context);\n\t\tGCM.getGCMLifeCycleController(root).startFc();\n\t\tboolean init = false;\n\t\twhile (!init) {\n\t\t\tboolean overallInitStatus = true;\n\t\t\tfor (Component subcomponent : GCM.getContentController(root)\n\t\t\t\t\t.getFcSubComponents()) {\n\t\t\t\toverallInitStatus = overallInitStatus\n\t\t\t\t\t\t&& GCM.getGCMLifeCycleController(subcomponent)\n\t\t\t\t\t\t\t\t.getFcState()\n\t\t\t\t\t\t\t\t.equals(LifeCycleController.STARTED);\n\t\t\t}\n\t\t\tif (overallInitStatus == true) {\n\t\t\t\tinit = true;\n\t\t\t} else {\n\t\t\t\tlogger.info(\"Wait for all subcomponents to be started...\");\n\t\t\t}\n\t\t\tThread.sleep(500);\n\t\t}\n\t\tQueryDispatchApi queryDispatchApi = ((eu.play_project.play_platformservices.api.QueryDispatchApi) root\n\t\t\t\t.getFcInterface(\"QueryDispatchApi\"));\n\t\tfor (String queryFileName : DcepConstants.getProperties()\n\t\t\t\t.getProperty(\"dcep.startup.registerqueries\").split(\",\")) {\n\t\t\tqueryFileName = queryFileName.trim();\n\t\t\tif (!queryFileName.isEmpty()) {\n\t\t\t\ttry {\n\t\t\t\t\tString queryString = IOUtils.toString(Main.class\n\t\t\t\t\t\t\t.getClassLoader().getResourceAsStream(queryFileName));\n\t\t\t\t\tlogger.info(queryString);\n\t\t\t\t\tqueryDispatchApi.registerQuery(queryFileName, queryString);\n\t\t\t\t} catch (QueryDispatchException e) {\n\t\t\t\t\tlogger.warn(\"Error registering query {} on startup: {}\",\n\t\t\t\t\t\t\tqueryFileName, e.getMessage());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public TaskStatus run(final TaskToolbox toolbox) throws Exception\n {\n if (this.plumber != null) {\n throw new IllegalStateException(\"WTF?!? run with non-null plumber??!\");\n }\n for (final TaskLock taskLock : toolbox.getTaskActionClient().submit(new LockListAction())) {\n toolbox.getTaskActionClient().submit(new LockReleaseAction(taskLock.getInterval()));\n }\n boolean normalExit = true;\n final Period intermediatePersistPeriod = fireDepartmentConfig.getIntermediatePersistPeriod();\n final Firehose firehose = firehoseFactory.connect();\n final RealtimePlumberSchool realtimePlumberSchool = new RealtimePlumberSchool(\n windowPeriod,\n new File(toolbox.getTaskWorkDir(), \"persist\"),\n segmentGranularity\n );\n final SegmentPublisher segmentPublisher = new TaskActionSegmentPublisher(this, toolbox);\n final DataSegmentAnnouncer lockingSegmentAnnouncer = new DataSegmentAnnouncer()\n {\n @Override\n public void announceSegment(final DataSegment segment) throws IOException\n {\n toolbox.getTaskActionClient().submit(new LockAcquireAction(segment.getInterval()));\n toolbox.getSegmentAnnouncer().announceSegment(segment);\n }\n @Override\n public void unannounceSegment(final DataSegment segment) throws IOException\n {\n try {\n toolbox.getSegmentAnnouncer().unannounceSegment(segment);\n }\n finally {\n toolbox.getTaskActionClient().submit(new LockReleaseAction(segment.getInterval()));\n }\n }\n @Override\n public void announceSegments(Iterable segments) throws IOException\n {\n for (DataSegment segment : segments) {\n toolbox.getTaskActionClient().submit(new LockAcquireAction(segment.getInterval()));\n }\n toolbox.getSegmentAnnouncer().announceSegments(segments);\n }\n @Override\n public void unannounceSegments(Iterable segments) throws IOException\n {\n try {\n toolbox.getSegmentAnnouncer().unannounceSegments(segments);\n }\n finally {\n for (DataSegment segment : segments) {\n toolbox.getTaskActionClient().submit(new LockReleaseAction(segment.getInterval()));\n }\n }\n }\n };\n final VersioningPolicy versioningPolicy = new VersioningPolicy()\n {\n @Override\n public String getVersion(final Interval interval)\n {\n try {\n final TaskLock myLock = toolbox.getTaskActionClient()\n .submit(new LockAcquireAction(interval));\n return myLock.getVersion();\n }\n catch (IOException e) {\n throw Throwables.propagate(e);\n }\n }\n };\n realtimePlumberSchool.setDataSegmentPusher(toolbox.getSegmentPusher());\n realtimePlumberSchool.setConglomerate(toolbox.getQueryRunnerFactoryConglomerate());\n realtimePlumberSchool.setVersioningPolicy(versioningPolicy);\n realtimePlumberSchool.setSegmentAnnouncer(lockingSegmentAnnouncer);\n realtimePlumberSchool.setSegmentPublisher(segmentPublisher);\n realtimePlumberSchool.setServerView(toolbox.getNewSegmentServerView());\n realtimePlumberSchool.setServiceEmitter(toolbox.getEmitter());\n if (this.rejectionPolicyFactory != null) {\n realtimePlumberSchool.setRejectionPolicyFactory(new NoopRejectionPolicyFactory());\n }\n final FireDepartment fireDepartment = new FireDepartment(schema, fireDepartmentConfig, null, null);\n final RealtimeMetricsMonitor metricsMonitor = new RealtimeMetricsMonitor(ImmutableList.of(fireDepartment));\n this.queryRunnerFactoryConglomerate = toolbox.getQueryRunnerFactoryConglomerate();\n this.plumber = realtimePlumberSchool.findPlumber(schema, fireDepartment.getMetrics());\n try {\n plumber.startJob();\n toolbox.getMonitorScheduler().addMonitor(metricsMonitor);\n long nextFlush = new DateTime().plus(intermediatePersistPeriod).getMillis();\n while (firehose.hasMore()) {\n final InputRow inputRow;\n try {\n inputRow = firehose.nextRow();\n if (inputRow == null) {\n continue;\n }\n final Sink sink = plumber.getSink(inputRow.getTimestampFromEpoch());\n if (sink == null) {\n fireDepartment.getMetrics().incrementThrownAway();\n log.debug(\"Throwing away event[%s]\", inputRow);\n if (System.currentTimeMillis() > nextFlush) {\n plumber.persist(firehose.commit());\n nextFlush = new DateTime().plus(intermediatePersistPeriod).getMillis();\n }\n continue;\n }\n if (sink.isEmpty()) {\n log.info(\"Task %s: New sink: %s\", getId(), sink);\n }\n int currCount = sink.add(inputRow);\n fireDepartment.getMetrics().incrementProcessed();\n if (currCount >= fireDepartmentConfig.getMaxRowsInMemory() || System.currentTimeMillis() > nextFlush) {\n plumber.persist(firehose.commit());\n nextFlush = new DateTime().plus(intermediatePersistPeriod).getMillis();\n }\n }\n catch (FormattedException e) {\n log.warn(e, \"unparseable line\");\n fireDepartment.getMetrics().incrementUnparseable();\n }\n }\n }\n catch (Exception e) {\n log.makeAlert(e, \"Exception aborted realtime processing[%s]\", schema.getDataSource())\n .emit();\n normalExit = false;\n throw Throwables.propagate(e);\n }\n finally {\n if (normalExit) {\n try {\n plumber.persist(firehose.commit());\n plumber.finishJob();\n }\n catch (Exception e) {\n log.makeAlert(e, \"Failed to finish realtime task\").emit();\n }\n finally {\n Closeables.closeQuietly(firehose);\n toolbox.getMonitorScheduler().removeMonitor(metricsMonitor);\n }\n }\n }\n return TaskStatus.success(getId());\n }\n", "output": " public TaskStatus run(final TaskToolbox toolbox) throws Exception\n {\n if (this.plumber != null) {\n throw new IllegalStateException(\"WTF?!? run with non-null plumber??!\");\n }\n for (final TaskLock taskLock : toolbox.getTaskActionClient().submit(new LockListAction())) {\n toolbox.getTaskActionClient().submit(new LockReleaseAction(taskLock.getInterval()));\n }\n boolean normalExit = true;\n final Period intermediatePersistPeriod = fireDepartmentConfig.getIntermediatePersistPeriod();\n final Firehose firehose = firehoseFactory.connect();\n final RealtimePlumberSchool realtimePlumberSchool = new RealtimePlumberSchool(\n windowPeriod,\n new File(toolbox.getTaskWorkDir(), \"persist\"),\n segmentGranularity\n );\n final SegmentPublisher segmentPublisher = new TaskActionSegmentPublisher(this, toolbox);\n final DataSegmentAnnouncer lockingSegmentAnnouncer = new DataSegmentAnnouncer()\n {\n @Override\n public void announceSegment(final DataSegment segment) throws IOException\n {\n toolbox.getTaskActionClient().submit(new LockAcquireAction(segment.getInterval()));\n toolbox.getSegmentAnnouncer().announceSegment(segment);\n }\n @Override\n public void unannounceSegment(final DataSegment segment) throws IOException\n {\n try {\n toolbox.getSegmentAnnouncer().unannounceSegment(segment);\n }\n finally {\n toolbox.getTaskActionClient().submit(new LockReleaseAction(segment.getInterval()));\n }\n }\n @Override\n public void announceSegments(Iterable segments) throws IOException\n {\n for (DataSegment segment : segments) {\n toolbox.getTaskActionClient().submit(new LockAcquireAction(segment.getInterval()));\n }\n toolbox.getSegmentAnnouncer().announceSegments(segments);\n }\n @Override\n public void unannounceSegments(Iterable segments) throws IOException\n {\n try {\n toolbox.getSegmentAnnouncer().unannounceSegments(segments);\n }\n finally {\n for (DataSegment segment : segments) {\n toolbox.getTaskActionClient().submit(new LockReleaseAction(segment.getInterval()));\n }\n }\n }\n };\n final VersioningPolicy versioningPolicy = new VersioningPolicy()\n {\n @Override\n public String getVersion(final Interval interval)\n {\n try {\n final TaskLock myLock = toolbox.getTaskActionClient()\n .submit(new LockAcquireAction(interval));\n return myLock.getVersion();\n }\n catch (IOException e) {\n throw Throwables.propagate(e);\n }\n }\n };\n realtimePlumberSchool.setDataSegmentPusher(toolbox.getSegmentPusher());\n realtimePlumberSchool.setConglomerate(toolbox.getQueryRunnerFactoryConglomerate());\n realtimePlumberSchool.setVersioningPolicy(versioningPolicy);\n realtimePlumberSchool.setSegmentAnnouncer(lockingSegmentAnnouncer);\n realtimePlumberSchool.setSegmentPublisher(segmentPublisher);\n realtimePlumberSchool.setServerView(toolbox.getNewSegmentServerView());\n realtimePlumberSchool.setServiceEmitter(toolbox.getEmitter());\n if (this.rejectionPolicyFactory != null) {\n realtimePlumberSchool.setRejectionPolicyFactory(rejectionPolicyFactory);\n }\n final FireDepartment fireDepartment = new FireDepartment(schema, fireDepartmentConfig, null, null);\n final RealtimeMetricsMonitor metricsMonitor = new RealtimeMetricsMonitor(ImmutableList.of(fireDepartment));\n this.queryRunnerFactoryConglomerate = toolbox.getQueryRunnerFactoryConglomerate();\n this.plumber = realtimePlumberSchool.findPlumber(schema, fireDepartment.getMetrics());\n try {\n plumber.startJob();\n toolbox.getMonitorScheduler().addMonitor(metricsMonitor);\n long nextFlush = new DateTime().plus(intermediatePersistPeriod).getMillis();\n while (firehose.hasMore()) {\n final InputRow inputRow;\n try {\n inputRow = firehose.nextRow();\n if (inputRow == null) {\n continue;\n }\n final Sink sink = plumber.getSink(inputRow.getTimestampFromEpoch());\n if (sink == null) {\n fireDepartment.getMetrics().incrementThrownAway();\n log.debug(\"Throwing away event[%s]\", inputRow);\n if (System.currentTimeMillis() > nextFlush) {\n plumber.persist(firehose.commit());\n nextFlush = new DateTime().plus(intermediatePersistPeriod).getMillis();\n }\n continue;\n }\n if (sink.isEmpty()) {\n log.info(\"Task %s: New sink: %s\", getId(), sink);\n }\n int currCount = sink.add(inputRow);\n fireDepartment.getMetrics().incrementProcessed();\n if (currCount >= fireDepartmentConfig.getMaxRowsInMemory() || System.currentTimeMillis() > nextFlush) {\n plumber.persist(firehose.commit());\n nextFlush = new DateTime().plus(intermediatePersistPeriod).getMillis();\n }\n }\n catch (FormattedException e) {\n log.warn(e, \"unparseable line\");\n fireDepartment.getMetrics().incrementUnparseable();\n }\n }\n }\n catch (Exception e) {\n log.makeAlert(e, \"Exception aborted realtime processing[%s]\", schema.getDataSource())\n .emit();\n normalExit = false;\n throw Throwables.propagate(e);\n }\n finally {\n if (normalExit) {\n try {\n plumber.persist(firehose.commit());\n plumber.finishJob();\n }\n catch (Exception e) {\n log.makeAlert(e, \"Failed to finish realtime task\").emit();\n }\n finally {\n Closeables.closeQuietly(firehose);\n toolbox.getMonitorScheduler().removeMonitor(metricsMonitor);\n }\n }\n }\n return TaskStatus.success(getId());\n }\n"} {"input": " public int doStartTag() throws JspException {\n boolean beanNotPresent = getPageContext().findAttribute(binding) == null;\n try {\n final Configuration config = StripesFilter.getConfiguration();\n final ActionResolver resolver = StripesFilter.getConfiguration().getActionResolver();\n final HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();\n final HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();\n Resolution resolution = null;\n ExecutionContext ctx = new ExecutionContext();\n if (beanNotPresent) {\n ActionBeanContext tempContext =\n config.getActionBeanContextFactory().getContextInstance(request, response);\n tempContext.setServletContext(getPageContext().getServletContext());\n ctx.setLifecycleStage(LifecycleStage.ActionBeanResolution);\n ctx.setActionBeanContext(tempContext);\n ctx.setInterceptors(config.getInterceptors(LifecycleStage.ActionBeanResolution));\n resolution = ctx.wrap( new Interceptor() {\n public Resolution intercept(ExecutionContext ec) throws Exception {\n ActionBean bean = resolver.getActionBean(ec.getActionBeanContext(), binding);\n ec.setActionBean(bean);\n return null;\n }\n });\n }\n if (resolution == null && event != null && (beanNotPresent || this.alwaysExecuteEvent)) {\n ctx.setLifecycleStage(LifecycleStage.HandlerResolution);\n ctx.setInterceptors(config.getInterceptors(LifecycleStage.HandlerResolution));\n resolution = ctx.wrap( new Interceptor() {\n public Resolution intercept(ExecutionContext ec) throws Exception {\n ec.setHandler(resolver.getHandler(ec.getActionBean().getClass(), event));\n ec.getActionBeanContext().setEventName(event);\n return null;\n }\n });\n }\n try {\n DispatcherHelper.setPageContext(getPageContext());\n if (resolution == null && (beanNotPresent || this.validate == true)) {\n resolution = DispatcherHelper.doBindingAndValidation(ctx, this.validate);\n }\n if (resolution == null && this.validate == true) {\n String temp = config.getBootstrapPropertyResolver().getProperty(\n DispatcherServlet.RUN_CUSTOM_VALIDATION_WHEN_ERRORS);\n boolean validateWhenErrors = temp != null && Boolean.valueOf(temp);\n resolution = DispatcherHelper.doCustomValidation(ctx, validateWhenErrors);\n }\n }\n finally {\n DispatcherHelper.setPageContext(null);\n }\n if (resolution == null && this.validate == true) {\n resolution = DispatcherHelper.handleValidationErrors(ctx);\n }\n if (resolution == null && event != null && (beanNotPresent || this.alwaysExecuteEvent)) {\n resolution = DispatcherHelper.invokeEventHandler(ctx);\n }\n DispatcherHelper.fillInValidationErrors(ctx); \n if (resolution != null && this.executeResolution) {\n DispatcherHelper.executeResolution(ctx, resolution);\n }\n if (getVar() != null) {\n pageContext.setAttribute(getVar(), ctx.getActionBean());\n }\n return SKIP_BODY;\n }\n catch(Exception e) {\n throw new StripesJspException(\"Unabled to prepare ActionBean for JSP Usage\",e);\n }\n }\n", "output": " public int doStartTag() throws JspException {\n ActionBean actionBean = (ActionBean) getPageContext().findAttribute(binding);\n boolean beanNotPresent = actionBean == null;\n try {\n final Configuration config = StripesFilter.getConfiguration();\n final ActionResolver resolver = StripesFilter.getConfiguration().getActionResolver();\n final HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();\n final HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();\n Resolution resolution = null;\n ExecutionContext ctx = new ExecutionContext();\n if (beanNotPresent) {\n ActionBeanContext tempContext =\n config.getActionBeanContextFactory().getContextInstance(request, response);\n tempContext.setServletContext(getPageContext().getServletContext());\n ctx.setLifecycleStage(LifecycleStage.ActionBeanResolution);\n ctx.setActionBeanContext(tempContext);\n ctx.setInterceptors(config.getInterceptors(LifecycleStage.ActionBeanResolution));\n resolution = ctx.wrap( new Interceptor() {\n public Resolution intercept(ExecutionContext ec) throws Exception {\n ActionBean bean = resolver.getActionBean(ec.getActionBeanContext(), binding);\n ec.setActionBean(bean);\n return null;\n }\n });\n }\n else {\n ctx.setActionBean(actionBean);\n ctx.setActionBeanContext(actionBean.getContext());\n }\n if (resolution == null && event != null && (beanNotPresent || this.alwaysExecuteEvent)) {\n ctx.setLifecycleStage(LifecycleStage.HandlerResolution);\n ctx.setInterceptors(config.getInterceptors(LifecycleStage.HandlerResolution));\n resolution = ctx.wrap( new Interceptor() {\n public Resolution intercept(ExecutionContext ec) throws Exception {\n ec.setHandler(resolver.getHandler(ec.getActionBean().getClass(), event));\n ec.getActionBeanContext().setEventName(event);\n return null;\n }\n });\n }\n try {\n DispatcherHelper.setPageContext(getPageContext());\n if (resolution == null && (beanNotPresent || this.validate == true)) {\n resolution = DispatcherHelper.doBindingAndValidation(ctx, this.validate);\n }\n if (resolution == null && this.validate == true) {\n String temp = config.getBootstrapPropertyResolver().getProperty(\n DispatcherServlet.RUN_CUSTOM_VALIDATION_WHEN_ERRORS);\n boolean validateWhenErrors = temp != null && Boolean.valueOf(temp);\n resolution = DispatcherHelper.doCustomValidation(ctx, validateWhenErrors);\n }\n }\n finally {\n DispatcherHelper.setPageContext(null);\n }\n if (resolution == null && this.validate == true) {\n resolution = DispatcherHelper.handleValidationErrors(ctx);\n }\n if (resolution == null && event != null && (beanNotPresent || this.alwaysExecuteEvent)) {\n resolution = DispatcherHelper.invokeEventHandler(ctx);\n }\n DispatcherHelper.fillInValidationErrors(ctx); \n if (resolution != null && this.executeResolution) {\n DispatcherHelper.executeResolution(ctx, resolution);\n }\n if (getVar() != null) {\n pageContext.setAttribute(getVar(), ctx.getActionBean());\n }\n return SKIP_BODY;\n }\n catch(Exception e) {\n throw new StripesJspException(\"Unabled to prepare ActionBean for JSP Usage\",e);\n }\n }\n"} {"input": "\tprivate void parseClassification(BufferedReader buffer) throws IOException {\n\t\tString line = null;\n\t\tint counter = 0;\n\t\twhile ((line = buffer.readLine ()) != null) {\n\t\t\tif ( line.startsWith(\"#\"))\n\t\t\t\tcontinue;\n\t\t\tString[] spl = line.split(\"\\t\");\n\t\t\tif ( spl.length != 6){\n\t\t\t\tSystem.err.println(\"Can't parse line \" + line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcounter++;\n\t\t\tString scopId = spl[0];\n\t\t\tString pdbId = spl[1];\n\t\t\tString range = spl[2];\n\t\t\tString classificationId = spl[3];\n\t\t\tInteger sunid = Integer.parseInt(spl[4]);\n\t\t\tString tree = spl[5];\n\t\t\tScopDomain d = new ScopDomain();\n\t\t\td.setScopId(scopId);\n\t\t\td.setPdbId(pdbId);\n\t\t\td.setRanges(extractRanges(range));\n\t\t\td.setClassificationId(classificationId);\n\t\t\td.setSunid(sunid);\n\t\t\tString[] treeSplit = tree.split(\",\");\n\t\t\tif ( treeSplit.length != 7 ) {\n\t\t\t\tSystem.err.println(\"can't process: \" + tree );\n\t\t\t}\n\t\t\tint classId =Integer.parseInt(treeSplit[0].substring(3));\n\t\t\tint foldId = Integer.parseInt(treeSplit[1].substring(3));\n\t\t\tint superfamilyId = Integer.parseInt(treeSplit[2].substring(3));\n\t\t\tint familyId = Integer.parseInt(treeSplit[3].substring(3));\t\t\t\t\t\t\n\t\t\tint domainId = Integer.parseInt(treeSplit[4].substring(3));\n\t\t\tint speciesId = Integer.parseInt(treeSplit[5].substring(3));\n\t\t\tint px = Integer.parseInt(treeSplit[6].substring(3));\n\t\t\td.setClassId(classId);\n\t\t\td.setFoldId(foldId);\n\t\t\td.setSuperfamilyId(superfamilyId);\n\t\t\td.setFamilyId(familyId);\n\t\t\td.setDomainId(domainId);\n\t\t\td.setSpeciesId(speciesId);\n\t\t\td.setPx(px);\n\t\t\tList domainList;\n\t\t\tif ( domainMap.containsKey(pdbId)){\n\t\t\t\tdomainList = domainMap.get(pdbId);\n\t\t\t} else {\n\t\t\t\tdomainList = new ArrayList();\n\t\t\t\tdomainMap.put(pdbId,domainList);\n\t\t\t}\n\t\t\tdomainList.add(d);\n\t\t\tif ( sunid == 47763)\n\t\t\t\tSystem.out.println(\"FOUND DOMAIN!!!! \" + sunid + \" \" + d);\n\t\t}\n\t\tSystem.out.println(\"parsed \"+ counter + \" scop sunid domains.\");\n\t}\n", "output": "\tprivate void parseClassification(BufferedReader buffer) throws IOException {\n\t\tString line = null;\n\t\tint counter = 0;\n\t\twhile ((line = buffer.readLine ()) != null) {\n\t\t\tif ( line.startsWith(\"#\"))\n\t\t\t\tcontinue;\n\t\t\tString[] spl = line.split(\"\\t\");\n\t\t\tif ( spl.length != 6){\n\t\t\t\tSystem.err.println(\"Can't parse line \" + line);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcounter++;\n\t\t\tString scopId = spl[0];\n\t\t\tString pdbId = spl[1];\n\t\t\tString range = spl[2];\n\t\t\tString classificationId = spl[3];\n\t\t\tInteger sunid = Integer.parseInt(spl[4]);\n\t\t\tString tree = spl[5];\n\t\t\tScopDomain d = new ScopDomain();\n\t\t\td.setScopId(scopId);\n\t\t\td.setPdbId(pdbId);\n\t\t\td.setRanges(extractRanges(range));\n\t\t\td.setClassificationId(classificationId);\n\t\t\td.setSunid(sunid);\n\t\t\tString[] treeSplit = tree.split(\",\");\n\t\t\tif ( treeSplit.length != 7 ) {\n\t\t\t\tSystem.err.println(\"can't process: \" + line );\n\t\t\t}\n\t\t\tint classId =Integer.parseInt(treeSplit[0].substring(3));\n\t\t\tint foldId = Integer.parseInt(treeSplit[1].substring(3));\n\t\t\tint superfamilyId = Integer.parseInt(treeSplit[2].substring(3));\n\t\t\tint familyId = Integer.parseInt(treeSplit[3].substring(3));\t\t\t\t\t\t\n\t\t\tint domainId = Integer.parseInt(treeSplit[4].substring(3));\n\t\t\tint speciesId = Integer.parseInt(treeSplit[5].substring(3));\n\t\t\tint px = Integer.parseInt(treeSplit[6].substring(3));\n\t\t\td.setClassId(classId);\n\t\t\td.setFoldId(foldId);\n\t\t\td.setSuperfamilyId(superfamilyId);\n\t\t\td.setFamilyId(familyId);\n\t\t\td.setDomainId(domainId);\n\t\t\td.setSpeciesId(speciesId);\n\t\t\td.setPx(px);\n\t\t\tList domainList;\n\t\t\tif ( domainMap.containsKey(pdbId)){\n\t\t\t\tdomainList = domainMap.get(pdbId);\n\t\t\t} else {\n\t\t\t\tdomainList = new ArrayList();\n\t\t\t\tdomainMap.put(pdbId,domainList);\n\t\t\t}\n\t\t\tdomainList.add(d);\n\t\t\tif ( sunid == 47763)\n\t\t\t\tSystem.out.println(\"FOUND DOMAIN!!!! \" + sunid + \" \" + d);\n\t\t}\n\t\tSystem.out.println(\"parsed \"+ counter + \" scop sunid domains.\");\n\t}\n"} {"input": "\tpublic void generateMail(List list, String lableTemplateName, String mailingTemplateName) {\n\t\tsetTemplateName(mailingTemplateName);\n\t\tsetLabelTemplateName(lableTemplateName);\n\t\tPerson p = list.get(0);\n\t\tSite s = p.getSite();\n\t\tsetSite(s);\n\t\tArrayList ids = new ArrayList();\n\t\tfor (Person person : list) {\n\t\t\tids.add(person.getId());\n\t\t\tCommunicationHistory ch = new CommunicationHistory();\n\t\t\tch.setPerson(person);\n\t\t\tch.setSystemGenerated(true);\n\t\t\tch.setComments(\"Generated mailing using template named \" + getTemplateName());\n\t\t\tch.setEntryType(\"Email\");\n\t\t\tch.setRecordDate(new Date());\n\t\t\tch.setCustomFieldValue(\"template\", getTemplateName());\n\t\t\tcommunicationHistoryService.maintainCommunicationHistory(ch);\n\t\t}\n\t\tMap params = getReportParameters();\n\t\tparams.clear();\n\t\tparams.put(\"Ids\", ids);\n\t\tthis.labelMap.clear();\n\t\tthis.labelMap.put(\"Ids\", ids);\n\t\tFile tempLabelFile = runLabels();\n\t\tFile tempFile = runReport();\n\t\tResourceDescriptor labelRD = new ResourceDescriptor();\n\t\tResourceDescriptor reportRD = new ResourceDescriptor();\n\t\tDate date = new Date();\n\t\tDateFormat dateFormat = new SimpleDateFormat(\"yyyyMMddHHmmss\");\n\t\ttry {\n\t\t\tlabelRD.setName(getLabelTemplateName() + dateFormat.format(date));\n\t\t\tlabelRD.setLabel(labelRD.getName());\n\t\t\tlabelRD.setDescription(labelRD.getName());\n\t\t\tlabelRD.setParentFolder(\"/Reports/\" + getSite().getName() + \"/Content_files\");\n\t\t\tlabelRD.setUriString(labelRD.getParentFolder() + \"/\" + labelRD.getName());\n\t\t\tlabelRD.setWsType(labelRD.TYPE_CONTENT_RESOURCE);\n\t\t\tlabelRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);\n\t\t\tlabelRD.setIsNew(true);\n\t\t\tlabelRD.setHasData(true);\n\t\t\t{\n\t\t\t\tRequestAttachment[] attachments;\n\t\t\t\tFileDataSource fileDataSource = new FileDataSource(tempLabelFile);\n\t\t\t\tRequestAttachment attachment = new RequestAttachment(fileDataSource);\n\t\t\t\tattachment.setContentID(labelRD.getName());\n\t\t\t\tattachments = new RequestAttachment[]{attachment};\n\t\t\tjserver.getWSClient().putResource(labelRD, attachments);\n\t\t\t}\n\t\t\treportRD.setName(getTemplateName() + dateFormat.format(date));\n\t\t\treportRD.setLabel(reportRD.getName());\n\t\t\treportRD.setDescription(reportRD.getName());\n\t\t\treportRD.setParentFolder(\"/Reports/\" + getSite().getName() + \"/Content_files\");\n\t\t\treportRD.setUriString(reportRD.getParentFolder() + \"/\" + reportRD.getName());\n\t\t\treportRD.setWsType(reportRD.TYPE_CONTENT_RESOURCE);\n\t\t\treportRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);\n\t\t\treportRD.setIsNew(true);\n\t\t\treportRD.setHasData(true);\n\t\t\t{\n\t\t\t\tRequestAttachment[] attachments;\n\t\t\t\tFileDataSource fileDataSource = new FileDataSource(tempFile);\n\t\t\t\tRequestAttachment attachment = new RequestAttachment(fileDataSource);\n\t\t\t\tattachment.setContentID(reportRD.getName());\n\t\t\t\tattachments = new RequestAttachment[]{attachment};\n\t\t\t\tjserver.getWSClient().putResource(reportRD, attachments);\n\t\t\t}\n\t\t\ttempLabelFile.delete();\n\t\t\ttempFile.delete();\n\t\t} catch (Exception ex) {\n\t\t\tlogger.error(ex.getMessage());\n\t\t}\n\t}\n", "output": "\tpublic void generateMail(List list, String lableTemplateName, String mailingTemplateName) {\n\t\tsetTemplateName(mailingTemplateName);\n\t\tsetLabelTemplateName(lableTemplateName);\n\t\tPerson p = list.get(0);\n\t\tSite s = p.getSite();\n\t\tsetSite(s);\n\t\tArrayList ids = new ArrayList();\n\t\tfor (Person person : list) {\n\t\t\tids.add(person.getId());\n\t\t\tCommunicationHistory ch = new CommunicationHistory();\n\t\t\tch.setPerson(person);\n\t\t\tch.setSystemGenerated(true);\n\t\t\tch.setComments(\"Generated mailing using template named \" + getTemplateName());\n\t\t\tch.setEntryType(\"Mail\");\n\t\t\tch.setRecordDate(new Date());\n\t\t\tch.setCustomFieldValue(\"template\", getTemplateName());\n\t\t\tcommunicationHistoryService.maintainCommunicationHistory(ch);\n\t\t}\n\t\tMap params = getReportParameters();\n\t\tparams.clear();\n\t\tparams.put(\"Ids\", ids);\n\t\tthis.labelMap.clear();\n\t\tthis.labelMap.put(\"Ids\", ids);\n\t\tFile tempLabelFile = runLabels();\n\t\tFile tempFile = runReport();\n\t\tResourceDescriptor labelRD = new ResourceDescriptor();\n\t\tResourceDescriptor reportRD = new ResourceDescriptor();\n\t\tDate date = new Date();\n\t\tDateFormat dateFormat = new SimpleDateFormat(\"yyyyMMddHHmmss\");\n\t\ttry {\n\t\t\tlabelRD.setName(getLabelTemplateName() + dateFormat.format(date));\n\t\t\tlabelRD.setLabel(labelRD.getName());\n\t\t\tlabelRD.setDescription(labelRD.getName());\n\t\t\tlabelRD.setParentFolder(\"/Reports/\" + getSite().getName() + \"/Content_files\");\n\t\t\tlabelRD.setUriString(labelRD.getParentFolder() + \"/\" + labelRD.getName());\n\t\t\tlabelRD.setWsType(labelRD.TYPE_CONTENT_RESOURCE);\n\t\t\tlabelRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);\n\t\t\tlabelRD.setIsNew(true);\n\t\t\tlabelRD.setHasData(true);\n\t\t\t{\n\t\t\t\tRequestAttachment[] attachments;\n\t\t\t\tFileDataSource fileDataSource = new FileDataSource(tempLabelFile);\n\t\t\t\tRequestAttachment attachment = new RequestAttachment(fileDataSource);\n\t\t\t\tattachment.setContentID(labelRD.getName());\n\t\t\t\tattachments = new RequestAttachment[]{attachment};\n\t\t\tjserver.getWSClient().putResource(labelRD, attachments);\n\t\t\t}\n\t\t\treportRD.setName(getTemplateName() + dateFormat.format(date));\n\t\t\treportRD.setLabel(reportRD.getName());\n\t\t\treportRD.setDescription(reportRD.getName());\n\t\t\treportRD.setParentFolder(\"/Reports/\" + getSite().getName() + \"/Content_files\");\n\t\t\treportRD.setUriString(reportRD.getParentFolder() + \"/\" + reportRD.getName());\n\t\t\treportRD.setWsType(reportRD.TYPE_CONTENT_RESOURCE);\n\t\t\treportRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);\n\t\t\treportRD.setIsNew(true);\n\t\t\treportRD.setHasData(true);\n\t\t\t{\n\t\t\t\tRequestAttachment[] attachments;\n\t\t\t\tFileDataSource fileDataSource = new FileDataSource(tempFile);\n\t\t\t\tRequestAttachment attachment = new RequestAttachment(fileDataSource);\n\t\t\t\tattachment.setContentID(reportRD.getName());\n\t\t\t\tattachments = new RequestAttachment[]{attachment};\n\t\t\t\tjserver.getWSClient().putResource(reportRD, attachments);\n\t\t\t}\n\t\t\ttempLabelFile.delete();\n\t\t\ttempFile.delete();\n\t\t} catch (Exception ex) {\n\t\t\tlogger.error(ex.getMessage());\n\t\t}\n\t}\n"} {"input": " public boolean isValidMention(String[] text, int startIndex, int endIndex) {\n int noBrands = 0;\n for(int i=startIndex; i<=endIndex; i++) {\n if(brandnames.contains(text[i]))\n noBrands++;\n }\n if(noBrands>1)\n return false;\n if(startIndex==endIndex && noBrands==1)\n return false;\n return false;\n }\n", "output": " public boolean isValidMention(String[] text, int startIndex, int endIndex) {\n int noBrands = 0;\n for(int i=startIndex; i<=endIndex; i++) {\n if(brandnames.contains(text[i]))\n noBrands++;\n }\n if(noBrands>1)\n return false;\n if(startIndex==endIndex && noBrands==1)\n return false;\n return true;\n }\n"} {"input": "\tpublic AppControllerImpl(@CotrixBus EventBus cotrixBus, CotrixWebPresenter cotrixWebPresenter) {\n\t\tthis.cotrixBus = cotrixBus;\n\t\tthis.cotrixWebPresenter = cotrixWebPresenter;\n\t\tbind();\n\t\tinitMenu();\n\t\tinitUserBar();\n\t\tHome home = new Home();\n\t\taddModule(home);\n\t\tCotrixImportAppGinInjector importInjector = CotrixImportAppGinInjector.INSTANCE;\n\t\taddModule(importInjector.getController());\n\t\tCotrixManagerAppGinInjector managerInjector = CotrixManagerAppGinInjector.INSTANCE;\n\t\taddModule(managerInjector.getController());\n\t\tshowModule(CotrixModule.HOME);\n\t}\n", "output": "\tpublic AppControllerImpl(@CotrixBus EventBus cotrixBus, CotrixWebPresenter cotrixWebPresenter) {\n\t\tthis.cotrixBus = cotrixBus;\n\t\tthis.cotrixWebPresenter = cotrixWebPresenter;\n\t\tbind();\n\t\tinitMenu();\n\t\tinitUserBar();\n\t\tHome home = new Home();\n\t\taddModule(home);\n\t\tCotrixImportAppGinInjector importInjector = CotrixImportAppGinInjector.INSTANCE;\n\t\taddModule(importInjector.getController());\n\t\tCotrixManagerAppGinInjector managerInjector = CotrixManagerAppGinInjector.INSTANCE;\n\t\taddModule(managerInjector.getController());\n\t\tshowModule(CotrixModule.MANAGE);\n\t}\n"} {"input": "\tpublic String[] getCoverUrl(String artist, String album, String path, String filename) throws Exception {\n\t\tString musicPath = settings.getString(\"musicPath\", \"music/\");\n\t\tFILENAMES[0] = settings.getString(\"coverFileName\", null);\n\t\tif (musicPath != null) {\n\t\t\tfinal String serverName = app.oMPDAsyncHelper.getConnectionSettings().sServer;\n\t\t\tString url;\n\t\t\tfinal List urls = new ArrayList();\n\t\t\tboolean secondFilenamePlaceholder = false;\n\t\t\tfor (String lfilename : FILENAMES) {\n\t\t\t\tif (lfilename == null || (lfilename.startsWith(\"%\") && !lfilename.equals(PLACEHOLDER_FILENAME)))\n\t\t\t\t\tcontinue;\n\t\t\t\tif (lfilename.equals(PLACEHOLDER_FILENAME)) {\n\t\t\t\t\tfinal int dotIndex = filename.lastIndexOf('.');\n\t\t\t\t\tif (dotIndex == -1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tlfilename = filename.substring(0, dotIndex) + (secondFilenamePlaceholder ? \".png\" : \".jpg\");\n\t\t\t\t\tsecondFilenamePlaceholder = true;\n\t\t\t\t}\n\t\t\t\turl = String.format(URL, new Object[] { musicPath, path.replaceAll(\" \", \"%20\"), lfilename });\n\t\t\t\turl = musicPath.toLowerCase().startsWith(URL_PREFIX) ? url : (URL_PREFIX + serverName + \"/\" + url);\n\t\t\t\tif (!urls.contains(url))\n\t\t\t\t\turls.add(url);\n\t\t\t}\n\t\t\treturn (String[]) urls.toArray();\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n", "output": "\tpublic String[] getCoverUrl(String artist, String album, String path, String filename) throws Exception {\n\t\tString musicPath = settings.getString(\"musicPath\", \"music/\");\n\t\tFILENAMES[0] = settings.getString(\"coverFileName\", null);\n\t\tif (musicPath != null) {\n\t\t\tfinal String serverName = app.oMPDAsyncHelper.getConnectionSettings().sServer;\n\t\t\tString url;\n\t\t\tfinal List urls = new ArrayList();\n\t\t\tboolean secondFilenamePlaceholder = false;\n\t\t\tfor (String lfilename : FILENAMES) {\n\t\t\t\tif (lfilename == null || (lfilename.startsWith(\"%\") && !lfilename.equals(PLACEHOLDER_FILENAME)))\n\t\t\t\t\tcontinue;\n\t\t\t\tif (lfilename.equals(PLACEHOLDER_FILENAME)) {\n\t\t\t\t\tfinal int dotIndex = filename.lastIndexOf('.');\n\t\t\t\t\tif (dotIndex == -1)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tlfilename = filename.substring(0, dotIndex) + (secondFilenamePlaceholder ? \".png\" : \".jpg\");\n\t\t\t\t\tsecondFilenamePlaceholder = true;\n\t\t\t\t}\n\t\t\t\turl = String.format(URL, new Object[] { musicPath, path.replaceAll(\" \", \"%20\"), lfilename });\n\t\t\t\turl = musicPath.toLowerCase().startsWith(URL_PREFIX) ? url : (URL_PREFIX + serverName + \"/\" + url);\n\t\t\t\tif (!urls.contains(url))\n\t\t\t\t\turls.add(url);\n\t\t\t}\n\t\t\treturn urls.toArray(new String[urls.size()]);\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n"} {"input": " public DataTypeDeclNode(ParameterListNode pl) {\n \tthis.pl=pl;\n } \n", "output": "\tpublic DataTypeDeclNode(ParameterListNode pl) {\n\t\tthis.pl=pl;\n\t} \n"} {"input": " private RomDetail( ConfigSection section, String computedMd5 )\n {\n if( sConfigFile == null )\n throw new IllegalStateException(\n \"RomDetail#initializeDatabase must be called before any other RomDetail method\" );\n String _md5 = null;\n String _crc = null;\n String _goodName = null;\n String _baseName = null;\n String _artUrl = null;\n String _saveType = null;\n int _status = 0;\n int _players = 0;\n boolean _rumble = false;\n if( section != null )\n {\n _md5 = section.name.equals( computedMd5 ) ? computedMd5 : null;\n _crc = section.get( \"CRC\" );\n if( \"00000000 00000000\".equals( _crc ) )\n _goodName = \"\";\n else\n _goodName = section.get( \"GoodName\" );\n _baseName = _goodName == null ? null : _goodName.split( \" \\\\(\" )[0].trim();\n _artUrl = _baseName == null ? null : String.format( URL_TEMPLATE,\n _baseName.replace( ' ', '_' ).replace( \"'\", \"\" ) );\n String refMd5 = section.get( \"RefMD5\" );\n if( !TextUtils.isEmpty( refMd5 ) )\n section = sConfigFile.get( refMd5 );\n if( section != null )\n {\n _saveType = section.get( \"SaveType\" );\n String statusString = section.get( \"Status\" );\n String playersString = section.get( \"Players\" );\n _status = TextUtils.isEmpty( statusString ) ? 0 : Integer.parseInt( statusString );\n _players = TextUtils.isEmpty( playersString ) ? 0 : Integer.parseInt( playersString );\n _rumble = \"Yes\".equals( section.get( \"Rumble\" ) );\n }\n }\n md5 = _md5;\n goodName = _md5 == null ? null : _goodName;\n baseName = _baseName;\n artUrl = _artUrl;\n crc = _crc;\n saveType = _saveType;\n status = _status;\n players = _players;\n rumble = _rumble;\n }\n", "output": " private RomDetail( ConfigSection section, String computedMd5 )\n {\n if( sConfigFile == null )\n throw new IllegalStateException(\n \"RomDetail#initializeDatabase must be called before any other RomDetail method\" );\n String _md5 = null;\n String _crc = null;\n String _goodName = null;\n String _baseName = null;\n String _artUrl = null;\n String _saveType = null;\n int _status = 0;\n int _players = 0;\n boolean _rumble = false;\n if( section != null )\n {\n _md5 = section.name.equals( computedMd5 ) ? computedMd5 : null;\n _crc = section.get( \"CRC\" );\n if( \"00000000 00000000\".equals( _crc ) )\n _goodName = \"\";\n else\n _goodName = section.get( \"GoodName\" );\n _baseName = _goodName == null ? null : _goodName.split( \" \\\\(\" )[0].trim();\n _artUrl = _baseName == null ? null : String.format( URL_TEMPLATE,\n _baseName.replace( ' ', '_' ).replace( \"'\", \"\" ).replace( '-', '_' ) );\n String refMd5 = section.get( \"RefMD5\" );\n if( !TextUtils.isEmpty( refMd5 ) )\n section = sConfigFile.get( refMd5 );\n if( section != null )\n {\n _saveType = section.get( \"SaveType\" );\n String statusString = section.get( \"Status\" );\n String playersString = section.get( \"Players\" );\n _status = TextUtils.isEmpty( statusString ) ? 0 : Integer.parseInt( statusString );\n _players = TextUtils.isEmpty( playersString ) ? 0 : Integer.parseInt( playersString );\n _rumble = \"Yes\".equals( section.get( \"Rumble\" ) );\n }\n }\n md5 = _md5;\n goodName = _md5 == null ? null : _goodName;\n baseName = _baseName;\n artUrl = _artUrl;\n crc = _crc;\n saveType = _saveType;\n status = _status;\n players = _players;\n rumble = _rumble;\n }\n"} {"input": " public void onEnable() {\n this.core = (MultiverseCore) getServer().getPluginManager().getPlugin(\"Multiverse-Core\");\n if (this.core == null) {\n log.info(logPrefix + \"Multiverse-Core not found, will keep looking.\");\n getServer().getPluginManager().disablePlugin(this);\n return;\n }\n if (this.core.getProtocolVersion() < requiresProtocol) {\n log.severe(logPrefix + \"Your Multiverse-Core is OUT OF DATE\");\n log.severe(logPrefix + \"This version of SignPortals requires Protocol Level: \" + requiresProtocol);\n log.severe(logPrefix + \"Your of Core Protocol Level is: \" + this.core.getProtocolVersion());\n log.severe(logPrefix + \"Grab an updated copy at: \");\n log.severe(logPrefix + \"http://bukkit.onarandombox.com/?dir=multiverse-core\");\n getServer().getPluginManager().disablePlugin(this);\n return;\n }\n debugLog = new DebugLog(\"Multiverse-NetherPortals\", getDataFolder() + File.separator + \"debug.log\");\n this.core.incrementPluginCount();\n this.pluginListener = new MVNPPluginListener(this);\n this.playerListener = new MVNPPlayerListener(this);\n this.entityListener = new MVNPEntityListener(this);\n this.customListener = new MVNPConfigReloadListener(this);\n this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, this.pluginListener, Priority.Normal, this);\n this.getServer().getPluginManager().registerEvent(Type.PLAYER_PORTAL, this.playerListener, Priority.Normal, this);\n this.getServer().getPluginManager().registerEvent(Type.CUSTOM_EVENT, this.customListener, Priority.Normal, this);\n this.getServer().getPluginManager().registerEvent(Type.ENTITY_PORTAL_ENTER, this.entityListener, Priority.Monitor, this);\n log.info(logPrefix + \"- Version \" + this.getDescription().getVersion() + \" Enabled - By \" + getAuthors());\n loadConfig();\n this.registerCommands();\n }\n", "output": " public void onEnable() {\n this.core = (MultiverseCore) getServer().getPluginManager().getPlugin(\"Multiverse-Core\");\n if (this.core == null) {\n log.info(logPrefix + \"Multiverse-Core not found, will keep looking.\");\n getServer().getPluginManager().disablePlugin(this);\n return;\n }\n if (this.core.getProtocolVersion() < requiresProtocol) {\n log.severe(logPrefix + \"Your Multiverse-Core is OUT OF DATE\");\n log.severe(logPrefix + \"This version of NetherPortals requires Protocol Level: \" + requiresProtocol);\n log.severe(logPrefix + \"Your of Core Protocol Level is: \" + this.core.getProtocolVersion());\n log.severe(logPrefix + \"Grab an updated copy at: \");\n log.severe(logPrefix + \"http://bukkit.onarandombox.com/?dir=multiverse-core\");\n getServer().getPluginManager().disablePlugin(this);\n return;\n }\n debugLog = new DebugLog(\"Multiverse-NetherPortals\", getDataFolder() + File.separator + \"debug.log\");\n this.core.incrementPluginCount();\n this.pluginListener = new MVNPPluginListener(this);\n this.playerListener = new MVNPPlayerListener(this);\n this.entityListener = new MVNPEntityListener(this);\n this.customListener = new MVNPConfigReloadListener(this);\n this.getServer().getPluginManager().registerEvent(Type.PLUGIN_ENABLE, this.pluginListener, Priority.Normal, this);\n this.getServer().getPluginManager().registerEvent(Type.PLAYER_PORTAL, this.playerListener, Priority.Normal, this);\n this.getServer().getPluginManager().registerEvent(Type.CUSTOM_EVENT, this.customListener, Priority.Normal, this);\n this.getServer().getPluginManager().registerEvent(Type.ENTITY_PORTAL_ENTER, this.entityListener, Priority.Monitor, this);\n log.info(logPrefix + \"- Version \" + this.getDescription().getVersion() + \" Enabled - By \" + getAuthors());\n loadConfig();\n this.registerCommands();\n }\n"} {"input": " private static boolean checkControlFlow(Statement statement, Set initializedVariables) throws ConceptualException\n {\n if (statement instanceof AssignStatement)\n {\n AssignStatement assign = (AssignStatement) statement;\n checkUninitializedVariables(assign.getExpression(), initializedVariables);\n initializedVariables.add(assign.getResolvedVariable());\n return false;\n }\n else if (statement instanceof Block)\n {\n boolean returned = false;\n for (Statement s : ((Block) statement).getStatements())\n {\n if (returned)\n {\n throw new ConceptualException(\"Unreachable code\", s.getLexicalPhrase());\n }\n returned = checkControlFlow(s, initializedVariables);\n }\n return returned;\n }\n else if (statement instanceof IfStatement)\n {\n IfStatement ifStatement = (IfStatement) statement;\n checkUninitializedVariables(ifStatement.getExpression(), initializedVariables);\n Statement thenClause = ifStatement.getThenClause();\n Statement elseClause = ifStatement.getElseClause();\n if (elseClause == null)\n {\n Set thenClauseVariables = new HashSet(initializedVariables);\n checkControlFlow(thenClause, thenClauseVariables);\n return false;\n }\n Set thenClauseVariables = new HashSet(initializedVariables);\n Set elseClauseVariables = new HashSet(initializedVariables);\n boolean returned = checkControlFlow(thenClause, thenClauseVariables) & checkControlFlow(elseClause, elseClauseVariables);\n for (Variable var : thenClauseVariables)\n {\n if (elseClauseVariables.contains(var))\n {\n initializedVariables.add(var);\n }\n }\n return returned;\n }\n else if (statement instanceof ReturnStatement)\n {\n checkUninitializedVariables(((ReturnStatement) statement).getExpression(), initializedVariables);\n return true;\n }\n else if (statement instanceof VariableDefinition)\n {\n VariableDefinition definition = (VariableDefinition) statement;\n if (definition.getExpression() != null)\n {\n checkUninitializedVariables(definition.getExpression(), initializedVariables);\n initializedVariables.add(definition.getVariable());\n }\n return false;\n }\n else if (statement instanceof WhileStatement)\n {\n WhileStatement whileStatement = (WhileStatement) statement;\n checkUninitializedVariables(whileStatement.getExpression(), initializedVariables);\n Set loopVariables = new HashSet(initializedVariables);\n return checkControlFlow(whileStatement.getStatement(), loopVariables);\n }\n throw new ConceptualException(\"Internal control flow checking error: Unknown statement type\", statement.getLexicalPhrase());\n }\n", "output": " private static boolean checkControlFlow(Statement statement, Set initializedVariables) throws ConceptualException\n {\n if (statement instanceof AssignStatement)\n {\n AssignStatement assign = (AssignStatement) statement;\n checkUninitializedVariables(assign.getExpression(), initializedVariables);\n initializedVariables.add(assign.getResolvedVariable());\n return false;\n }\n else if (statement instanceof Block)\n {\n boolean returned = false;\n for (Statement s : ((Block) statement).getStatements())\n {\n if (returned)\n {\n throw new ConceptualException(\"Unreachable code\", s.getLexicalPhrase());\n }\n returned = checkControlFlow(s, initializedVariables);\n }\n return returned;\n }\n else if (statement instanceof IfStatement)\n {\n IfStatement ifStatement = (IfStatement) statement;\n checkUninitializedVariables(ifStatement.getExpression(), initializedVariables);\n Statement thenClause = ifStatement.getThenClause();\n Statement elseClause = ifStatement.getElseClause();\n if (elseClause == null)\n {\n Set thenClauseVariables = new HashSet(initializedVariables);\n checkControlFlow(thenClause, thenClauseVariables);\n return false;\n }\n Set thenClauseVariables = new HashSet(initializedVariables);\n Set elseClauseVariables = new HashSet(initializedVariables);\n boolean thenReturned = checkControlFlow(thenClause, thenClauseVariables);\n boolean elseReturned = checkControlFlow(elseClause, elseClauseVariables);\n if (!thenReturned && !elseReturned)\n {\n for (Variable var : thenClauseVariables)\n {\n if (elseClauseVariables.contains(var))\n {\n initializedVariables.add(var);\n }\n }\n }\n else if (!thenReturned && elseReturned)\n {\n initializedVariables.addAll(thenClauseVariables);\n }\n else if (thenReturned && !elseReturned)\n {\n initializedVariables.addAll(elseClauseVariables);\n }\n return thenReturned && elseReturned;\n }\n else if (statement instanceof ReturnStatement)\n {\n checkUninitializedVariables(((ReturnStatement) statement).getExpression(), initializedVariables);\n return true;\n }\n else if (statement instanceof VariableDefinition)\n {\n VariableDefinition definition = (VariableDefinition) statement;\n if (definition.getExpression() != null)\n {\n checkUninitializedVariables(definition.getExpression(), initializedVariables);\n initializedVariables.add(definition.getVariable());\n }\n return false;\n }\n else if (statement instanceof WhileStatement)\n {\n WhileStatement whileStatement = (WhileStatement) statement;\n checkUninitializedVariables(whileStatement.getExpression(), initializedVariables);\n Set loopVariables = new HashSet(initializedVariables);\n return checkControlFlow(whileStatement.getStatement(), loopVariables);\n }\n throw new ConceptualException(\"Internal control flow checking error: Unknown statement type\", statement.getLexicalPhrase());\n }\n"} {"input": "\tpublic Object executeProgram(String main, IValue[] args) {\n\t\tfor (Function f : functionStore) {\n\t\t\tf.finalize(functionMap, constructorMap, listing);\n\t\t}\n\t\tFunction init_function = functionStore.get(functionMap.get(\"#module_init\"));\n\t\tif (init_function == null) {\n\t\t\tthrow new RuntimeException(\"PANIC: Code for #module_init not found\");\n\t\t}\n\t\tif (init_function.nformals != 0) {\n\t\t\tthrow new RuntimeException(\"PANIC: \" + \"function \\\"#module_init\\\" should have one argument\");\n\t\t}\n\t\tFunction main_function = functionStore.get(functionMap.get(\"main\"));\n\t\tif (main_function == null) {\n\t\t\tthrow new RuntimeException(\"PANIC: No function \\\"main\\\" found\");\n\t\t}\n\t\tif (main_function.nformals != 1) {\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: function \\\"main\\\" should have one argument\");\n\t\t}\n\t\tFrame cf = new Frame(0, null, init_function.maxstack, init_function);\n\t\tFrame root = cf; \n\t\tObject[] stack = cf.stack;\n\t\tstack[0] = args; \n\t\tint[] instructions = init_function.codeblock.getInstructions();\n\t\tint pc = 0;\n\t\tint sp = init_function.nlocals;\n\t\tStack activeCoroutines = new Stack<>();\n\t\tFrame ccf = null; \n\t\ttry {\n\t\t\tNEXT_INSTRUCTION: while (true) {\n\t\t\t\tif(pc < 0 || pc >= instructions.length){\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: \" + main + \" illegal pc: \" + pc);\n\t\t\t\t}\n\t\t\t\tint op = instructions[pc++];\n\t\t\t\tif (debug) {\n\t\t\t\t\tint startpc = pc - 1;\n\t\t\t\t\tfor (int i = 0; i < sp; i++) {\n\t\t\t\t\t\tstdout.println(\"\\t\" + i + \": \" + stack[i]);\n\t\t\t\t\t}\n\t\t\t\t\tstdout.println(cf.function.name + \"[\" + startpc + \"] \" + cf.function.codeblock.toString(startpc));\n\t\t\t\t}\n\t\t\t\tswitch (op) {\n\t\t\t\tcase Opcode.OP_LOADCON:\n\t\t\t\t\tstack[sp++] = cf.function.constantStore[instructions[pc++]];\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOADTTYPE:\n\t\t\t\t\tstack[sp++] = cf.function.typeConstantStore[instructions[pc++]];\n\t\t\t\tcase Opcode.OP_LOADFUN:\n\t\t\t\t\tstack[sp++] = new FunctionInstance(functionStore.get(instructions[pc++]), root);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOAD_NESTED_FUN: { \n\t\t\t\t\tFunction fun = functionStore.get(instructions[pc++]);\n\t\t\t\t\tint scope = instructions[pc++];\n\t\t\t\t\tfor (Frame env = cf; env != null; env = env.previousCallFrame) {\n\t\t\t\t\t\tif (env.scopeId == scope) {\n\t\t\t\t\t\t\tstack[sp++] = new FunctionInstance(fun, env);\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: LOAD_NESTED_FUNCTION cannot find matching scope: \" + scope);\t\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_LOADCONSTR:\n\t\t\t\t\tType constructor = constructorStore.get(instructions[pc++]);\n\t\t\t\tcase Opcode.OP_LOADLOC:\n\t\t\t\tcase Opcode.OP_LOADLOC_AS_REF:\n\t\t\t\t\tstack[sp++] = (op == Opcode.OP_LOADLOC) ? stack[instructions[pc++]] \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: new Reference(stack, instructions[pc++]);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOADLOCREF: {\n\t\t\t\t\tReference ref = (Reference) stack[instructions[pc++]];\n\t\t\t\t\tstack[sp++] = ref.stack[ref.pos];\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_LOADVAR:\n\t\t\t\tcase Opcode.OP_LOADVAR_AS_REF: {\n\t\t\t\t\tint s = instructions[pc++];\n\t\t\t\t\tint pos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tstack[sp++] = (op == Opcode.OP_LOADVAR) ? fr.stack[pos] \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: new Reference(fr.stack, pos);\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: load var cannot find matching scope: \" + s);\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_LOADVARREF: {\n\t\t\t\t\tint s = instructions[pc++];\n\t\t\t\t\tint pos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tReference ref = (Reference) fr.stack[pos];\n\t\t\t\t\t\t\tstack[sp++] = ref.stack[ref.pos];\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: load var cannot find matching scope: \" + s);\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_STORELOC: {\n\t\t\t\t\tstack[instructions[pc++]] = stack[sp - 1]; \n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_STORELOCREF:\n\t\t\t\t\tReference ref = (Reference) stack[instructions[pc++]];\n\t\t\t\t\tref.stack[ref.pos] = stack[sp - 1]; \n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_STOREVAR:\n\t\t\t\t\tint s = instructions[pc++];\n\t\t\t\t\tint pos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tfr.stack[pos] = stack[sp - 1];\t\t\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: load var cannot find matching scope: \" + s);\n\t\t\t\tcase Opcode.OP_STOREVARREF:\n\t\t\t\t\ts = instructions[pc++];\n\t\t\t\t\tpos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tref = (Reference) fr.stack[pos];\n\t\t\t\t\t\t\tref.stack[ref.pos] = stack[sp - 1];\t\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: load var cannot find matching scope: \" + s);\n\t\t\t\tcase Opcode.OP_JMP:\n\t\t\t\t\tpc = instructions[pc];\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_JMPTRUE:\n\t\t\t\t\tif (stack[sp - 1].equals(TRUE)) {\n\t\t\t\t\t\tpc = instructions[pc];\n\t\t\t\t\t} else\n\t\t\t\t\t\tpc++;\n\t\t\t\t\tsp--;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_JMPFALSE:\n\t\t\t\t\tif (stack[sp - 1].equals(FALSE)) {\n\t\t\t\t\t\tpc = instructions[pc];\n\t\t\t\t\t} else\n\t\t\t\t\t\tpc++;\n\t\t\t\t\tsp--;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_POP:\n\t\t\t\t\tsp--;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LABEL:\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: label instruction at runtime\");\n\t\t\t\tcase Opcode.OP_CALLCONSTR:\n\t\t\t\t\tconstructor = constructorStore.get(instructions[pc++]);\n\t\t\t\t\tint arity = constructor.getArity();\n\t\t\t\t\targs = new IValue[arity]; \n\t\t\t\t\tfor(int i = 0; i < arity; i++) {\n\t\t\t\t\t\targs[arity - 1 - i] = (IValue) stack[--sp];\n\t\t\t\t\t}\n\t\t\t\t\tstack[sp++] = vf.constructor(constructor, args);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_CALLDYN:\t\t\t\t\n\t\t\t\tcase Opcode.OP_CALL:\t\t\t\n\t\t\t\t\tif(op == Opcode.OP_CALLDYN && stack[sp - 1] instanceof Type) {\n\t\t\t\t\t\tType constr = (Type) stack[--sp];\n\t\t\t\t\t\tarity = constr.getArity();\n\t\t\t\t\t\targs = new IValue[arity]; \n\t\t\t\t\t\tfor(int i = arity - 1; i >=0; i--) {\n\t\t\t\t\t\t\targs[i] = (IValue) stack[sp - arity + i];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsp = sp - arity;\n\t\t\t\t\t\tstack[sp++] = vf.constructor(constr, args);\n\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t}\n\t\t\t\t\tFunction fun = null;\n\t\t\t\t\tFrame previousScope = null;\n\t\t\t\t\tif(op == Opcode.OP_CALLDYN && stack[sp - 1] instanceof FunctionInstance){\n\t\t\t\t\t\tFunctionInstance fun_instance = (FunctionInstance) stack[--sp];\n\t\t\t\t\t\tfun = fun_instance.function;\n\t\t\t\t\t\tpreviousScope = fun_instance.env;\n\t\t\t\t\t} else if(op == Opcode.OP_CALL) {\n\t\t\t\t\t\tfun = functionStore.get(instructions[pc++]);\n\t\t\t\t\t\tpreviousScope = cf;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new RuntimeException(\"PANIC: unexpected argument type when CALLDYN is executed\");\n\t\t\t\t\t}\n\t\t\t\t\tinstructions = fun.codeblock.getInstructions();\n\t\t\t\t\tFrame nextFrame = new Frame(fun.scope, cf, previousScope, fun.maxstack, fun);\n\t\t\t\t\tfor (int i = fun.nformals - 1; i >= 0; i--) {\n\t\t\t\t\t\tnextFrame.stack[i] = stack[sp - fun.nformals + i];\n\t\t\t\t\t}\n\t\t\t\t\tcf.pc = pc;\n\t\t\t\t\tcf.sp = sp - fun.nformals;\n\t\t\t\t\tcf = nextFrame;\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = fun.nlocals;\n\t\t\t\t\tpc = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_RETURN0:\n\t\t\t\tcase Opcode.OP_RETURN1:\n\t\t\t\t\tObject rval = null;\n\t\t\t\t\tboolean returns = op == Opcode.OP_RETURN1; \n\t\t\t\t\tif(returns) \n\t\t\t\t\t\trval = stack[sp - 1];\n\t\t\t\t\tif(cf == ccf) {\n\t\t\t\t\t\tactiveCoroutines.pop();\n\t\t\t\t\t\tccf = activeCoroutines.isEmpty() ? null : activeCoroutines.peek().start;\n\t\t\t\t\t}\n\t\t\t\t\tcf = cf.previousCallFrame;\n\t\t\t\t\tif(cf == null) {\n\t\t\t\t\t\tif(returns)\n\t\t\t\t\t\t\treturn rval;\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\treturn vf.string(\"None\");\n\t\t\t\t\t}\n\t\t\t\t\tinstructions = cf.function.codeblock.getInstructions();\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = cf.sp;\n\t\t\t\t\tpc = cf.pc;\n\t\t\t\t\tif(returns)\n\t\t\t\t\t\tstack[sp++] = rval;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_HALT:\n\t\t\t\t\tif (debug) {\n\t\t\t\t\t\tstdout.println(\"Program halted:\");\n\t\t\t\t\t\tfor (int i = 0; i < sp; i++) {\n\t\t\t\t\t\t\tstdout.println(i + \": \" + stack[i]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn stack[sp - 1];\n\t\t\t\tcase Opcode.OP_PRINTLN:\n\t\t\t\t\tstdout.println(((IString) stack[sp - 1]).getValue());\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_CALLPRIM:\n\t\t\t\t\tPrimitive prim = Primitive.fromInteger(instructions[pc++]);\n\t\t\t\t\tsp = prim.invoke(stack, sp);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_INIT:\n\t\t\t\t\tObject src = stack[--sp];\n\t\t\t\t\tCoroutine coroutine;\n\t\t\t\t\tif(src instanceof Coroutine){\n\t\t\t\t\t\tcoroutine = (Coroutine) src; \n\t\t\t\t\t\tfun = coroutine.frame.function;\n\t\t\t\t\t} else if(src instanceof FunctionInstance) {\n\t\t\t\t\t\tFunctionInstance fun_instance = (FunctionInstance) src;\n\t\t\t\t\t\tfun = fun_instance.function;\n\t\t\t\t\t\tFrame frame = new Frame(fun.scope, null, fun_instance.env, fun.maxstack, fun);\n\t\t\t\t\t\tcoroutine = new Coroutine(frame);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new RuntimeException(\"PANIC: unexpected argument type when INIT is executed.\");\n\t\t\t\t\t}\n\t\t\t\t\tfor (int i = fun.nformals - 1; i >= 0; i--) {\n\t\t\t\t\t\tcoroutine.frame.stack[i] = stack[sp - fun.nformals + i];\n\t\t\t\t\t}\n\t\t\t\t\tcoroutine.frame.sp = fun.nlocals;\n\t\t\t\t\tcoroutine.suspend(coroutine.frame);\n\t\t\t\t\tsp = sp - fun.nformals;\t\t\t\t\t\t\t\n\t\t\t\t\tstack[sp++] = coroutine;\t\t\t\t\t\t\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_CREATE:\n\t\t\t\tcase Opcode.OP_CREATEDYN:\n\t\t\t\t\tif(op == Opcode.OP_CREATE){\n\t\t\t\t\t\tfun = functionStore.get(instructions[pc++]);\n\t\t\t\t\t\tpreviousScope = null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsrc = stack[--sp];\n\t\t\t\t\t\tif(src instanceof FunctionInstance) {\n\t\t\t\t\t\t\tFunctionInstance fun_instance = (FunctionInstance) src;\n\t\t\t\t\t\t\tfun = fun_instance.function;\n\t\t\t\t\t\t\tpreviousScope = fun_instance.env;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new RuntimeException(\"PANIC: unexpected argument type when CREATEDYN is executed.\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tFrame frame = new Frame(fun.scope, null, previousScope, fun.maxstack, fun);\n\t\t\t\t\tcoroutine = new Coroutine(frame);\n\t\t\t\t\tstack[sp++] = coroutine;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_NEXT0:\n\t\t\t\tcase Opcode.OP_NEXT1:\n\t\t\t\t\tcoroutine = (Coroutine) stack[--sp];\n\t\t\t\t\tactiveCoroutines.push(coroutine);\n\t\t\t\t\tccf = coroutine.start;\n\t\t\t\t\tcoroutine.next(cf);\n\t\t\t\t\tfun = coroutine.frame.function;\n\t\t\t\t\tinstructions = coroutine.frame.function.codeblock.getInstructions();\n\t\t\t\t\tcoroutine.frame.stack[coroutine.frame.sp++] = \t\t\n\t\t\t\t\t\t\t(op == Opcode.OP_NEXT1) ? stack[--sp] : null;\n\t\t\t\t\tcf.pc = pc;\n\t\t\t\t\tcf.sp = sp;\n\t\t\t\t\tcf = coroutine.frame;\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = cf.sp;\n\t\t\t\t\tpc = cf.pc;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_YIELD0:\t\n\t\t\t\tcase Opcode.OP_YIELD1:\n\t\t\t\t\tcoroutine = activeCoroutines.pop();\n\t\t\t\t\tccf = activeCoroutines.isEmpty() ? null : activeCoroutines.peek().start;\n\t\t\t\t\tFrame prev = coroutine.start.previousCallFrame;\n\t\t\t\t\trval = (op == Opcode.OP_YIELD1) ? stack[--sp] : null;\n\t\t\t\t\tcf.pc = pc;\n\t\t\t\t\tcf.sp = sp;\n\t\t\t\t\tcoroutine.suspend(cf);\n\t\t\t\t\tcf = prev;\n\t\t\t\t\tif(op == Opcode.OP_YIELD1 && cf == null)\n\t\t\t\t\t\treturn rval;\n\t\t\t\t\tinstructions = cf.function.codeblock.getInstructions();\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = cf.sp;\n\t\t\t\t\tpc = cf.pc;\n\t\t\t\t\tstack[sp++] = rval;\t \n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_HASNEXT:\n\t\t\t\t\tcoroutine = (Coroutine) stack[--sp];\n\t\t\t\t\tstack[sp++] = coroutine.hasNext() ? TRUE : FALSE;\n\t\t\t\t\tcontinue;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: RVM main loop -- cannot decode instruction\");\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tstdout.println(\"PANIC: exception caused by invoking a primitive or illegal instruction sequence\");\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn FALSE;\n\t}\n", "output": "\tpublic Object executeProgram(String main, IValue[] args) {\n\t\tfor (Function f : functionStore) {\n\t\t\tf.finalize(functionMap, constructorMap, listing);\n\t\t}\n\t\tFunction init_function = functionStore.get(functionMap.get(\"#module_init\"));\n\t\tif (init_function == null) {\n\t\t\tthrow new RuntimeException(\"PANIC: Code for #module_init not found\");\n\t\t}\n\t\tif (init_function.nformals != 0) {\n\t\t\tthrow new RuntimeException(\"PANIC: \" + \"function \\\"#module_init\\\" should have one argument\");\n\t\t}\n\t\tFunction main_function = functionStore.get(functionMap.get(\"main\"));\n\t\tif (main_function == null) {\n\t\t\tthrow new RuntimeException(\"PANIC: No function \\\"main\\\" found\");\n\t\t}\n\t\tif (main_function.nformals != 1) {\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: function \\\"main\\\" should have one argument\");\n\t\t}\n\t\tFrame cf = new Frame(0, null, init_function.maxstack, init_function);\n\t\tFrame root = cf; \n\t\tObject[] stack = cf.stack;\n\t\tstack[0] = args; \n\t\tint[] instructions = init_function.codeblock.getInstructions();\n\t\tint pc = 0;\n\t\tint sp = init_function.nlocals;\n\t\tStack activeCoroutines = new Stack<>();\n\t\tFrame ccf = null; \n\t\ttry {\n\t\t\tNEXT_INSTRUCTION: while (true) {\n\t\t\t\tif(pc < 0 || pc >= instructions.length){\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: \" + main + \" illegal pc: \" + pc);\n\t\t\t\t}\n\t\t\t\tint op = instructions[pc++];\n\t\t\t\tif (debug) {\n\t\t\t\t\tint startpc = pc - 1;\n\t\t\t\t\tfor (int i = 0; i < sp; i++) {\n\t\t\t\t\t\tstdout.println(\"\\t\" + i + \": \" + stack[i]);\n\t\t\t\t\t}\n\t\t\t\t\tstdout.println(cf.function.name + \"[\" + startpc + \"] \" + cf.function.codeblock.toString(startpc));\n\t\t\t\t}\n\t\t\t\tswitch (op) {\n\t\t\t\tcase Opcode.OP_LOADCON:\n\t\t\t\t\tstack[sp++] = cf.function.constantStore[instructions[pc++]];\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOADTTYPE:\n\t\t\t\t\tstack[sp++] = cf.function.typeConstantStore[instructions[pc++]];\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOADFUN:\n\t\t\t\t\tstack[sp++] = new FunctionInstance(functionStore.get(instructions[pc++]), root);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOAD_NESTED_FUN: { \n\t\t\t\t\tFunction fun = functionStore.get(instructions[pc++]);\n\t\t\t\t\tint scope = instructions[pc++];\n\t\t\t\t\tfor (Frame env = cf; env != null; env = env.previousCallFrame) {\n\t\t\t\t\t\tif (env.scopeId == scope) {\n\t\t\t\t\t\t\tstack[sp++] = new FunctionInstance(fun, env);\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: LOAD_NESTED_FUNCTION cannot find matching scope: \" + scope);\t\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_LOADCONSTR:\n\t\t\t\t\tType constructor = constructorStore.get(instructions[pc++]);\n\t\t\t\tcase Opcode.OP_LOADLOC:\n\t\t\t\tcase Opcode.OP_LOADLOC_AS_REF:\n\t\t\t\t\tstack[sp++] = (op == Opcode.OP_LOADLOC) ? stack[instructions[pc++]] \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: new Reference(stack, instructions[pc++]);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LOADLOCREF: {\n\t\t\t\t\tReference ref = (Reference) stack[instructions[pc++]];\n\t\t\t\t\tstack[sp++] = ref.stack[ref.pos];\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_LOADVAR:\n\t\t\t\tcase Opcode.OP_LOADVAR_AS_REF: {\n\t\t\t\t\tint s = instructions[pc++];\n\t\t\t\t\tint pos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tstack[sp++] = (op == Opcode.OP_LOADVAR) ? fr.stack[pos] \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: new Reference(fr.stack, pos);\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: LOADVAR cannot find matching scope: \" + s);\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_LOADVARREF: {\n\t\t\t\t\tint s = instructions[pc++];\n\t\t\t\t\tint pos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tReference ref = (Reference) fr.stack[pos];\n\t\t\t\t\t\t\tstack[sp++] = ref.stack[ref.pos];\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: LOADVARREF cannot find matching scope: \" + s);\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_STORELOC: {\n\t\t\t\t\tstack[instructions[pc++]] = stack[sp - 1]; \n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase Opcode.OP_STORELOCREF:\n\t\t\t\t\tReference ref = (Reference) stack[instructions[pc++]];\n\t\t\t\t\tref.stack[ref.pos] = stack[sp - 1]; \n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_STOREVAR:\n\t\t\t\t\tint s = instructions[pc++];\n\t\t\t\t\tint pos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tfr.stack[pos] = stack[sp - 1];\t\t\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: STOREVAR cannot find matching scope: \" + s);\n\t\t\t\tcase Opcode.OP_STOREVARREF:\n\t\t\t\t\ts = instructions[pc++];\n\t\t\t\t\tpos = instructions[pc++];\n\t\t\t\t\tfor (Frame fr = cf; fr != null; fr = fr.previousScope) {\n\t\t\t\t\t\tif (fr.scopeId == s) {\n\t\t\t\t\t\t\tref = (Reference) fr.stack[pos];\n\t\t\t\t\t\t\tref.stack[ref.pos] = stack[sp - 1];\t\n\t\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: STOREVARREF cannot find matching scope: \" + s);\n\t\t\t\tcase Opcode.OP_JMP:\n\t\t\t\t\tpc = instructions[pc];\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_JMPTRUE:\n\t\t\t\t\tif (stack[sp - 1].equals(TRUE)) {\n\t\t\t\t\t\tpc = instructions[pc];\n\t\t\t\t\t} else\n\t\t\t\t\t\tpc++;\n\t\t\t\t\tsp--;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_JMPFALSE:\n\t\t\t\t\tif (stack[sp - 1].equals(FALSE)) {\n\t\t\t\t\t\tpc = instructions[pc];\n\t\t\t\t\t} else\n\t\t\t\t\t\tpc++;\n\t\t\t\t\tsp--;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_POP:\n\t\t\t\t\tsp--;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_LABEL:\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: label instruction at runtime\");\n\t\t\t\tcase Opcode.OP_CALLCONSTR:\n\t\t\t\t\tconstructor = constructorStore.get(instructions[pc++]);\n\t\t\t\t\tint arity = constructor.getArity();\n\t\t\t\t\targs = new IValue[arity]; \n\t\t\t\t\tfor(int i = 0; i < arity; i++) {\n\t\t\t\t\t\targs[arity - 1 - i] = (IValue) stack[--sp];\n\t\t\t\t\t}\n\t\t\t\t\tstack[sp++] = vf.constructor(constructor, args);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_CALLDYN:\t\t\t\t\n\t\t\t\tcase Opcode.OP_CALL:\t\t\t\n\t\t\t\t\tif(op == Opcode.OP_CALLDYN && stack[sp - 1] instanceof Type) {\n\t\t\t\t\t\tType constr = (Type) stack[--sp];\n\t\t\t\t\t\tarity = constr.getArity();\n\t\t\t\t\t\targs = new IValue[arity]; \n\t\t\t\t\t\tfor(int i = arity - 1; i >=0; i--) {\n\t\t\t\t\t\t\targs[i] = (IValue) stack[sp - arity + i];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsp = sp - arity;\n\t\t\t\t\t\tstack[sp++] = vf.constructor(constr, args);\n\t\t\t\t\t\tcontinue NEXT_INSTRUCTION;\n\t\t\t\t\t}\n\t\t\t\t\tFunction fun = null;\n\t\t\t\t\tFrame previousScope = null;\n\t\t\t\t\tif(op == Opcode.OP_CALLDYN && stack[sp - 1] instanceof FunctionInstance){\n\t\t\t\t\t\tFunctionInstance fun_instance = (FunctionInstance) stack[--sp];\n\t\t\t\t\t\tfun = fun_instance.function;\n\t\t\t\t\t\tpreviousScope = fun_instance.env;\n\t\t\t\t\t} else if(op == Opcode.OP_CALL) {\n\t\t\t\t\t\tfun = functionStore.get(instructions[pc++]);\n\t\t\t\t\t\tpreviousScope = cf;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new RuntimeException(\"PANIC: unexpected argument type when CALLDYN is executed\");\n\t\t\t\t\t}\n\t\t\t\t\tinstructions = fun.codeblock.getInstructions();\n\t\t\t\t\tFrame nextFrame = new Frame(fun.scope, cf, previousScope, fun.maxstack, fun);\n\t\t\t\t\tfor (int i = fun.nformals - 1; i >= 0; i--) {\n\t\t\t\t\t\tnextFrame.stack[i] = stack[sp - fun.nformals + i];\n\t\t\t\t\t}\n\t\t\t\t\tcf.pc = pc;\n\t\t\t\t\tcf.sp = sp - fun.nformals;\n\t\t\t\t\tcf = nextFrame;\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = fun.nlocals;\n\t\t\t\t\tpc = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_RETURN0:\n\t\t\t\tcase Opcode.OP_RETURN1:\n\t\t\t\t\tObject rval = null;\n\t\t\t\t\tboolean returns = op == Opcode.OP_RETURN1; \n\t\t\t\t\tif(returns) \n\t\t\t\t\t\trval = stack[sp - 1];\n\t\t\t\t\tif(cf == ccf) {\n\t\t\t\t\t\tactiveCoroutines.pop();\n\t\t\t\t\t\tccf = activeCoroutines.isEmpty() ? null : activeCoroutines.peek().start;\n\t\t\t\t\t}\n\t\t\t\t\tcf = cf.previousCallFrame;\n\t\t\t\t\tif(cf == null) {\n\t\t\t\t\t\tif(returns)\n\t\t\t\t\t\t\treturn rval;\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\treturn vf.string(\"None\");\n\t\t\t\t\t}\n\t\t\t\t\tinstructions = cf.function.codeblock.getInstructions();\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = cf.sp;\n\t\t\t\t\tpc = cf.pc;\n\t\t\t\t\tif(returns)\n\t\t\t\t\t\tstack[sp++] = rval;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_HALT:\n\t\t\t\t\tif (debug) {\n\t\t\t\t\t\tstdout.println(\"Program halted:\");\n\t\t\t\t\t\tfor (int i = 0; i < sp; i++) {\n\t\t\t\t\t\t\tstdout.println(i + \": \" + stack[i]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn stack[sp - 1];\n\t\t\t\tcase Opcode.OP_PRINTLN:\n\t\t\t\t\tstdout.println(((IString) stack[sp - 1]).getValue());\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_CALLPRIM:\n\t\t\t\t\tPrimitive prim = Primitive.fromInteger(instructions[pc++]);\n\t\t\t\t\tsp = prim.invoke(stack, sp);\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_INIT:\n\t\t\t\t\tObject src = stack[--sp];\n\t\t\t\t\tCoroutine coroutine;\n\t\t\t\t\tif(src instanceof Coroutine){\n\t\t\t\t\t\tcoroutine = (Coroutine) src; \n\t\t\t\t\t\tfun = coroutine.frame.function;\n\t\t\t\t\t} else if(src instanceof FunctionInstance) {\n\t\t\t\t\t\tFunctionInstance fun_instance = (FunctionInstance) src;\n\t\t\t\t\t\tfun = fun_instance.function;\n\t\t\t\t\t\tFrame frame = new Frame(fun.scope, null, fun_instance.env, fun.maxstack, fun);\n\t\t\t\t\t\tcoroutine = new Coroutine(frame);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new RuntimeException(\"PANIC: unexpected argument type when INIT is executed.\");\n\t\t\t\t\t}\n\t\t\t\t\tfor (int i = fun.nformals - 1; i >= 0; i--) {\n\t\t\t\t\t\tcoroutine.frame.stack[i] = stack[sp - fun.nformals + i];\n\t\t\t\t\t}\n\t\t\t\t\tcoroutine.frame.sp = fun.nlocals;\n\t\t\t\t\tcoroutine.suspend(coroutine.frame);\n\t\t\t\t\tsp = sp - fun.nformals;\t\t\t\t\t\t\t\n\t\t\t\t\tstack[sp++] = coroutine;\t\t\t\t\t\t\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_CREATE:\n\t\t\t\tcase Opcode.OP_CREATEDYN:\n\t\t\t\t\tif(op == Opcode.OP_CREATE){\n\t\t\t\t\t\tfun = functionStore.get(instructions[pc++]);\n\t\t\t\t\t\tpreviousScope = null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsrc = stack[--sp];\n\t\t\t\t\t\tif(src instanceof FunctionInstance) {\n\t\t\t\t\t\t\tFunctionInstance fun_instance = (FunctionInstance) src;\n\t\t\t\t\t\t\tfun = fun_instance.function;\n\t\t\t\t\t\t\tpreviousScope = fun_instance.env;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new RuntimeException(\"PANIC: unexpected argument type when CREATEDYN is executed.\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tFrame frame = new Frame(fun.scope, null, previousScope, fun.maxstack, fun);\n\t\t\t\t\tcoroutine = new Coroutine(frame);\n\t\t\t\t\tstack[sp++] = coroutine;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_NEXT0:\n\t\t\t\tcase Opcode.OP_NEXT1:\n\t\t\t\t\tcoroutine = (Coroutine) stack[--sp];\n\t\t\t\t\tactiveCoroutines.push(coroutine);\n\t\t\t\t\tccf = coroutine.start;\n\t\t\t\t\tcoroutine.next(cf);\n\t\t\t\t\tfun = coroutine.frame.function;\n\t\t\t\t\tinstructions = coroutine.frame.function.codeblock.getInstructions();\n\t\t\t\t\tcoroutine.frame.stack[coroutine.frame.sp++] = \t\t\n\t\t\t\t\t\t\t(op == Opcode.OP_NEXT1) ? stack[--sp] : null;\n\t\t\t\t\tcf.pc = pc;\n\t\t\t\t\tcf.sp = sp;\n\t\t\t\t\tcf = coroutine.frame;\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = cf.sp;\n\t\t\t\t\tpc = cf.pc;\n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_YIELD0:\t\n\t\t\t\tcase Opcode.OP_YIELD1:\n\t\t\t\t\tcoroutine = activeCoroutines.pop();\n\t\t\t\t\tccf = activeCoroutines.isEmpty() ? null : activeCoroutines.peek().start;\n\t\t\t\t\tFrame prev = coroutine.start.previousCallFrame;\n\t\t\t\t\trval = (op == Opcode.OP_YIELD1) ? stack[--sp] : null;\n\t\t\t\t\tcf.pc = pc;\n\t\t\t\t\tcf.sp = sp;\n\t\t\t\t\tcoroutine.suspend(cf);\n\t\t\t\t\tcf = prev;\n\t\t\t\t\tif(op == Opcode.OP_YIELD1 && cf == null)\n\t\t\t\t\t\treturn rval;\n\t\t\t\t\tinstructions = cf.function.codeblock.getInstructions();\n\t\t\t\t\tstack = cf.stack;\n\t\t\t\t\tsp = cf.sp;\n\t\t\t\t\tpc = cf.pc;\n\t\t\t\t\tstack[sp++] = rval;\t \n\t\t\t\t\tcontinue;\n\t\t\t\tcase Opcode.OP_HASNEXT:\n\t\t\t\t\tcoroutine = (Coroutine) stack[--sp];\n\t\t\t\t\tstack[sp++] = coroutine.hasNext() ? TRUE : FALSE;\n\t\t\t\t\tcontinue;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new RuntimeException(\"PANIC: RVM main loop -- cannot decode instruction\");\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tstdout.println(\"PANIC: exception caused by invoking a primitive or illegal instruction sequence: \" + e);\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn FALSE;\n\t}\n"} {"input": " public void run() {\n while (running_.get()) {\n MotionEvent[] motionEvents = inputBroker_.takeBundle();\n long now = System.currentTimeMillis();\n float elapsed = (float) ((now - lastTime_) / 1000.0);\n gameState_ = physicsSimulator_.run(elapsed, gameState_, motionEvents);\n renderer_.render(gameState_);\n }\n }\n", "output": " public void run() {\n while (running_.get()) {\n MotionEvent[] motionEvents = inputBroker_.takeBundle();\n long now = System.currentTimeMillis();\n float elapsed = (float) ((now - lastTime_) / 1000.0);\n lastTime_ = now;\n gameState_ = physicsSimulator_.run(elapsed, gameState_, motionEvents);\n renderer_.render(gameState_);\n }\n }\n"} {"input": "\tprivate DefaultProperties() {\n\t\ttry {\n\t\t\tprop.load(new FileInputStream(\"resources/default.properties\"));\n\t\t} catch (FileNotFoundException e1) {\n\t\t\tAssert.fail(\"Unable to load file due to error :\" + e1.toString());\n\t\t} catch (IOException e1) {\n\t\t\tAssert.fail(\"Unable to load file due to error :\" + e1.toString());\n\t\t}\n\t}\n", "output": "\tprivate DefaultProperties() {\n\t\ttry {\n\t\t\tprop.load(new FileInputStream(\"../default.properties\"));\n\t\t} catch (FileNotFoundException e1) {\n\t\t\tAssert.fail(\"Unable to load file due to error :\" + e1.toString());\n\t\t} catch (IOException e1) {\n\t\t\tAssert.fail(\"Unable to load file due to error :\" + e1.toString());\n\t\t}\n\t}\n"} {"input": "\tpublic void onMessage(Message inMessage) throws Exception {\n\t\tif (!inMessage.isPrivMsg()) {\n\t\t\tString channel = inMessage.getChannel();\n\t\t\tString message = inMessage.getMessage();\n\t\t\tif (message.charAt(message.length() - 1) == ' ')\n\t\t\t\tmessage = message.substring(0, message.length() - 1);\n\t\t\tIRC irc = IRC.getInstance();\n\t\t\tMatcher r = Pattern.compile(\n\t\t\t\t\t\"^([\\\\w\\\\d]*)(?:[\\\\s])?([+|-])(?:[+|-|=])?(?:[\\\\s]([\\\\d]*))?\",\n\t\t\t\t\tPattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(\n\t\t\t\t\tmessage);\n\t\t\tif (r.find()) {\n\t\t\t\tString item = r.group(1);\n\t\t\t\tString type = r.group(2);\n\t\t\t\tString ammount = r.group(3);\n\t\t\t\tif (!inMessage.getUser().equalsIgnoreCase(item))\n\t\t\t\t{\n\t\t\t\t\tint iAmmount = 0;\n\t\t\t\t\tif (type.equals(\"+\") && r.group(3) == null) {\n\t\t\t\t\t\tiAmmount = 1;\n\t\t\t\t\t} else if (type.equals(\"-\") && r.group(3) == null) {\n\t\t\t\t\t\tiAmmount = -1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttype = type.trim();\n\t\t\t\t\t\tammount = ammount.trim();\n\t\t\t\t\t\tif (type.equals(\"+\"))\n\t\t\t\t\t\t\tiAmmount = Integer.valueOf(ammount);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tiAmmount = Integer.valueOf(type + ammount);\n\t\t\t\t\t}\n\t\t\t\t\tif (iAmmount > 100 || iAmmount < -100) {\n\t\t\t\t\t\tirc.sendPrivmsg(channel,\n\t\t\t\t\t\t\t\t\"You cant do that its to much rep...\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tReputation tempRep = repList_.getRep(item);\n\t\t\t\t\t\ttempRep.modRep(iAmmount);\n\t\t\t\t\t\tirc.sendPrivmsg(channel, item + \": Rep = \"\n\t\t\t\t\t\t\t\t+ tempRep.getRep() + \"!\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (message.matches(RegexFormatter.format(\"rep\",RegexFormatter.REG_NICK))) {\n\t\t\t\tString[] t = message.split(\" \");\n\t\t\t\tif (t.length > 0 || t[1] != null)\n\t\t\t\t\tirc.sendPrivmsg(channel, t[1] + \": Rep = \"\n\t\t\t\t\t\t\t+ repList_.getRep(t[1]).getRep() + \"!\");\n\t\t\t}\n\t\t\tJSON.save(cfgFile_, repList_);\n\t\t}\n\t}\n", "output": "\tpublic void onMessage(Message inMessage) throws Exception {\n\t\tif (!inMessage.isPrivMsg()) {\n\t\t\tString channel = inMessage.getChannel();\n\t\t\tString message = inMessage.getMessage();\n\t\t\tif (message.charAt(message.length() - 1) == ' ')\n\t\t\t\tmessage = message.substring(0, message.length() - 1);\n\t\t\tIRC irc = IRC.getInstance();\n\t\t\tMatcher r = Pattern.compile(\n\t\t\t\t\t\"^([\\\\w\\\\d]*)(?:[\\\\s])?([+|-])(?:[+|-|=])?(?:[\\\\s]([\\\\d]*))?\\\\r\",\n\t\t\t\t\tPattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(\n\t\t\t\t\tmessage);\n\t\t\tif (r.find()) {\n\t\t\t\tString item = r.group(1);\n\t\t\t\tString type = r.group(2);\n\t\t\t\tString ammount = r.group(3);\n\t\t\t\tif (!inMessage.getUser().equalsIgnoreCase(item))\n\t\t\t\t{\n\t\t\t\t\tint iAmmount = 0;\n\t\t\t\t\tif (type.equals(\"+\") && r.group(3) == null) {\n\t\t\t\t\t\tiAmmount = 1;\n\t\t\t\t\t} else if (type.equals(\"-\") && r.group(3) == null) {\n\t\t\t\t\t\tiAmmount = -1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttype = type.trim();\n\t\t\t\t\t\tammount = ammount.trim();\n\t\t\t\t\t\tif (type.equals(\"+\"))\n\t\t\t\t\t\t\tiAmmount = Integer.valueOf(ammount);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tiAmmount = Integer.valueOf(type + ammount);\n\t\t\t\t\t}\n\t\t\t\t\tif (iAmmount > 100 || iAmmount < -100) {\n\t\t\t\t\t\tirc.sendPrivmsg(channel,\n\t\t\t\t\t\t\t\t\"You cant do that its to much rep...\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tReputation tempRep = repList_.getRep(item);\n\t\t\t\t\t\ttempRep.modRep(iAmmount);\n\t\t\t\t\t\tirc.sendPrivmsg(channel, item + \": Rep = \"\n\t\t\t\t\t\t\t\t+ tempRep.getRep() + \"!\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (message.matches(RegexFormatter.format(\"rep\",RegexFormatter.REG_NICK))) {\n\t\t\t\tString[] t = message.split(\" \");\n\t\t\t\tif (t.length > 0 || t[1] != null)\n\t\t\t\t\tirc.sendPrivmsg(channel, t[1] + \": Rep = \"\n\t\t\t\t\t\t\t+ repList_.getRep(t[1]).getRep() + \"!\");\n\t\t\t}\n\t\t\tJSON.save(cfgFile_, repList_);\n\t\t}\n\t}\n"} {"input": "\tprivate void build() {\n\t\tfinal BooksDatabase db = BooksDatabase.Instance();\n\t\tfinal FileInfoSet fileInfos = new FileInfoSet();\n\t\tfinal Map savedBooksByFileId = db.loadBooks(fileInfos, true);\n\t\tfinal Map savedBooksByBookId = new HashMap();\n\t\tfor (Book b : savedBooksByFileId.values()) {\n\t\t\tsavedBooksByBookId.put(b.getId(), b);\n\t\t}\n\t\tfor (long id : db.loadRecentBookIds()) {\n\t\t\tBook book = savedBooksByBookId.get(id);\n\t\t\tif (book == null) {\n\t\t\t\tbook = Book.getById(id);\n\t\t\t}\n\t\t\tif (book != null) {\n\t\t\t\tnew BookTree(getFirstLevelTree(ROOT_RECENT), book, true);\n\t\t\t}\n\t\t}\n\t\tfor (long id : db.loadFavoritesIds()) {\n\t\t\tBook book = savedBooksByBookId.get(id);\n\t\t\tif (book == null) {\n\t\t\t\tbook = Book.getById(id);\n\t\t\t}\n\t\t\tif (book != null) {\n\t\t\t\tgetFirstLevelTree(ROOT_FAVORITES).getBookSubTree(book, true);\n\t\t\t}\n\t\t}\n\t\tfireModelChangedEvent();\n\t\tif (savedBooksByFileId.size() > 10) {\n\t\t\tfinal HashSet letterSet = new HashSet();\n\t\t\tfor (Book book : savedBooksByFileId.values()) {\n\t\t\t\tfinal String letter = TitleTree.firstTitleLetter(book);\n\t\t\t\tif (letter != null) {\n\t\t\t\t\tletterSet.add(letter);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmyDoGroupTitlesByFirstLetter = savedBooksByFileId.values().size() > letterSet.size() * 5 / 4;\n\t\t}\n\t\tfinal Set orphanedBooks = new HashSet();\n\t\tfor (Book book : savedBooksByFileId.values()) {\n\t\t\tsynchronized (this) {\n\t\t\t\tif (book.File.exists()) {\n\t\t\t\t\tboolean doAdd = true;\n\t\t\t\t\tfinal ZLPhysicalFile file = book.File.getPhysicalFile();\n\t\t\t\t\tif (file == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!fileInfos.check(file, true)) {\n\t\t\t\t\t\tif (book.readMetaInfo()) {\n\t\t\t\t\t\t\tbook.save();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdoAdd = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfile.setCached(false);\n\t\t\t\t\t}\n\t\t\t\t\tif (doAdd) {\n\t\t\t\t\t\taddBookToLibrary(book);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmyRootTree.removeBook(book);\n\t\t\t\t\torphanedBooks.add(book);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfireModelChangedEvent();\n\t\t}\n\t\tdb.setExistingFlag(orphanedBooks, false);\n\t\tfinal Map orphanedBooksByFileId = db.loadBooks(fileInfos, false);\n\t\tfinal Set newBooks = new HashSet();\n\t\tfinal List physicalFilesList = collectPhysicalFiles();\n\t\tfor (ZLPhysicalFile file : physicalFilesList) {\n\t\t\tcollectBooks(\n\t\t\t\tfile, fileInfos,\n\t\t\t\tsavedBooksByFileId, orphanedBooksByFileId,\n\t\t\t\tnewBooks,\n\t\t\t\t!fileInfos.check(file, true)\n\t\t\t);\n\t\t\tfile.setCached(false);\n\t\t}\n\t\tfinal ZLFile helpFile = getHelpFile();\n\t\tBook helpBook = savedBooksByFileId.get(fileInfos.getId(helpFile));\n\t\tif (helpBook == null) {\n\t\t\thelpBook = new Book(helpFile);\n\t\t\thelpBook.readMetaInfo();\n\t\t}\n\t\taddBookToLibrary(helpBook);\n\t\tfireModelChangedEvent();\n\t\tfileInfos.save();\n\t\tdb.executeAsATransaction(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tfor (Book book : newBooks) {\n\t\t\t\t\tbook.save();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tdb.setExistingFlag(newBooks, true);\n\t}\n", "output": "\tprivate void build() {\n\t\tfinal BooksDatabase db = BooksDatabase.Instance();\n\t\tfinal FileInfoSet fileInfos = new FileInfoSet();\n\t\tfinal Map savedBooksByFileId = db.loadBooks(fileInfos, true);\n\t\tfinal Map savedBooksByBookId = new HashMap();\n\t\tfor (Book b : savedBooksByFileId.values()) {\n\t\t\tsavedBooksByBookId.put(b.getId(), b);\n\t\t}\n\t\tfor (long id : db.loadRecentBookIds()) {\n\t\t\tBook book = savedBooksByBookId.get(id);\n\t\t\tif (book == null) {\n\t\t\t\tbook = Book.getById(id);\n\t\t\t\tif (book != null && !book.File.exists()) {\n\t\t\t\t\tbook = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (book != null) {\n\t\t\t\tnew BookTree(getFirstLevelTree(ROOT_RECENT), book, true);\n\t\t\t}\n\t\t}\n\t\tfor (long id : db.loadFavoritesIds()) {\n\t\t\tBook book = savedBooksByBookId.get(id);\n\t\t\tif (book == null) {\n\t\t\t\tbook = Book.getById(id);\n\t\t\t\tif (book != null && !book.File.exists()) {\n\t\t\t\t\tbook = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (book != null) {\n\t\t\t\tgetFirstLevelTree(ROOT_FAVORITES).getBookSubTree(book, true);\n\t\t\t}\n\t\t}\n\t\tfireModelChangedEvent();\n\t\tif (savedBooksByFileId.size() > 10) {\n\t\t\tfinal HashSet letterSet = new HashSet();\n\t\t\tfor (Book book : savedBooksByFileId.values()) {\n\t\t\t\tfinal String letter = TitleTree.firstTitleLetter(book);\n\t\t\t\tif (letter != null) {\n\t\t\t\t\tletterSet.add(letter);\n\t\t\t\t}\n\t\t\t}\n\t\t\tmyDoGroupTitlesByFirstLetter = savedBooksByFileId.values().size() > letterSet.size() * 5 / 4;\n\t\t}\n\t\tfinal Set orphanedBooks = new HashSet();\n\t\tfor (Book book : savedBooksByFileId.values()) {\n\t\t\tsynchronized (this) {\n\t\t\t\tif (book.File.exists()) {\n\t\t\t\t\tboolean doAdd = true;\n\t\t\t\t\tfinal ZLPhysicalFile file = book.File.getPhysicalFile();\n\t\t\t\t\tif (file == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (!fileInfos.check(file, true)) {\n\t\t\t\t\t\tif (book.readMetaInfo()) {\n\t\t\t\t\t\t\tbook.save();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdoAdd = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfile.setCached(false);\n\t\t\t\t\t}\n\t\t\t\t\tif (doAdd) {\n\t\t\t\t\t\taddBookToLibrary(book);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tmyRootTree.removeBook(book);\n\t\t\t\t\torphanedBooks.add(book);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfireModelChangedEvent();\n\t\t}\n\t\tdb.setExistingFlag(orphanedBooks, false);\n\t\tfinal Map orphanedBooksByFileId = db.loadBooks(fileInfos, false);\n\t\tfinal Set newBooks = new HashSet();\n\t\tfinal List physicalFilesList = collectPhysicalFiles();\n\t\tfor (ZLPhysicalFile file : physicalFilesList) {\n\t\t\tcollectBooks(\n\t\t\t\tfile, fileInfos,\n\t\t\t\tsavedBooksByFileId, orphanedBooksByFileId,\n\t\t\t\tnewBooks,\n\t\t\t\t!fileInfos.check(file, true)\n\t\t\t);\n\t\t\tfile.setCached(false);\n\t\t}\n\t\tfinal ZLFile helpFile = getHelpFile();\n\t\tBook helpBook = savedBooksByFileId.get(fileInfos.getId(helpFile));\n\t\tif (helpBook == null) {\n\t\t\thelpBook = new Book(helpFile);\n\t\t\thelpBook.readMetaInfo();\n\t\t}\n\t\taddBookToLibrary(helpBook);\n\t\tfireModelChangedEvent();\n\t\tfileInfos.save();\n\t\tdb.executeAsATransaction(new Runnable() {\n\t\t\tpublic void run() {\n\t\t\t\tfor (Book book : newBooks) {\n\t\t\t\t\tbook.save();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tdb.setExistingFlag(newBooks, true);\n\t}\n"} {"input": "\tpublic String encode() {\n\t\tif (name != null && value != null && !isFlagParameter) {\n\t\t\tif (GenericObject.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObject gv = (GenericObject) value;\n\t\t\t\treturn name + separator + quotes + gv.encode() + quotes;\n\t\t\t} else if (GenericObjectList.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObjectList gvlist = (GenericObjectList) value;\n\t\t\t\treturn name + separator + gvlist.encode();\n\t\t\t} else if ( value.toString().equals(\"\")) {\n\t\t\t\tif (name.toString().equals(gov.nist.javax.sip.header.ParameterNames.OPAQUE))\n\t\t\t\t\treturn name + separator + quotes + quotes;\n\t\t\t\telse\n\t\t\t\t\treturn name;\n\t\t\t} else \n\t\t\t\treturn name + separator + quotes + value.toString() + quotes;\n\t\t} else if (name == null && value != null) {\n\t\t\tif (GenericObject.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObject gv = (GenericObject) value;\n\t\t\t\treturn gv.encode();\n\t\t\t} else if (GenericObjectList.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObjectList gvlist = (GenericObjectList) value;\n\t\t\t\treturn gvlist.encode();\n\t\t\t}\n\t\t\treturn quotes + value.toString() + quotes;\n\t\t} else if (name != null && (value == null || isFlagParameter)) {\n\t\t\treturn name;\n\t\t} else\n\t\t\treturn \"\";\n\t}\n", "output": "\tpublic String encode() {\n\t\tif (name != null && value != null && !isFlagParameter) {\n\t\t\tif (GenericObject.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObject gv = (GenericObject) value;\n\t\t\t\treturn name + separator + quotes + gv.encode() + quotes;\n\t\t\t} else if (GenericObjectList.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObjectList gvlist = (GenericObjectList) value;\n\t\t\t\treturn name + separator + gvlist.encode();\n\t\t\t} else if ( value.toString().equals(\"\")) {\n\t\t\t\tif ( this.isQuotedString ) {\n\t\t\t\t\treturn name + separator + quotes + quotes;\n\t\t\t\t} else \n\t\t\t\t\treturn name;\n\t\t\t} else \n\t\t\t\treturn name + separator + quotes + value.toString() + quotes;\n\t\t} else if (name == null && value != null) {\n\t\t\tif (GenericObject.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObject gv = (GenericObject) value;\n\t\t\t\treturn gv.encode();\n\t\t\t} else if (GenericObjectList.isMySubclass(value.getClass())) {\n\t\t\t\tGenericObjectList gvlist = (GenericObjectList) value;\n\t\t\t\treturn gvlist.encode();\n\t\t\t}\n\t\t\treturn quotes + value.toString() + quotes;\n\t\t} else if (name != null && (value == null || isFlagParameter)) {\n\t\t\treturn name;\n\t\t} else\n\t\t\treturn \"\";\n\t}\n"} {"input": "\tpublic QSync(File qsyncfile)\n\t{\n\t\tDocument qsyncDoc =null;\n\t\ttry\n\t\t{\n\t\t\tqsyncDoc = DocumentBuilderFactory.newInstance()\n\t\t\t\t\t.newDocumentBuilder()\n\t\t\t\t\t.parse(qsyncfile);\n\t\t}\n\t\tcatch(ParserConfigurationException ex) { System.err.println(\"QSync: error creating XML configuration\"); }\n\t\tcatch(SAXException ex) { System.err.println(\"Error reading document (\"+qsyncfile.getName()+\"): \"+ex.getMessage()); }\n\t\tcatch(IOException ex) { System.err.println(\"IOException reading document (\"+qsyncfile.getName()+\")\"); }\t\n\t\tif(qsyncDoc==null) System.exit(-1); \n\t\tmPwd = qsyncfile.getAbsoluteFile().getParentFile();\n\t\ttry\n\t\t{\n\t\t\tNodeList includeExtList = qsyncDoc.getElementsByTagName(\"ClInclude\");\n\t\t\tif(includeExtList.getLength() == 0) throw new XMLParseException(\"element not found\");\n\t\t\tif(includeExtList.getLength() >1) throw new XMLParseException(\"multiple elements\");\n\t\t\tElement includes = (Element) qsyncDoc.adoptNode(includeExtList.item(0));\n\t\t\tmIncludes = includes.getAttribute(\"ext\");\n\t\t\tif(mIncludes.length()==0 || !mIncludes.matches(\"^[a-zA-Z0-9]*(,[a-zA-Z0-9]*)*$\"))\n\t\t\t\tthrow new XMLParseException(\"src attribute of is not valid\");\n\t\t\tNodeList compileExtList = qsyncDoc.getElementsByTagName(\"ClCompile\");\n\t\t\tif(compileExtList.getLength() == 0) throw new XMLParseException(\"element not found\");\n\t\t\tif(compileExtList.getLength() >1) throw new XMLParseException(\"multiple elements\");\n\t\t\tElement compiles = (Element) qsyncDoc.adoptNode(compileExtList.item(0));\n\t\t\tmCompiles = compiles.getAttribute(\"ext\");\n\t\t\tif(mCompiles.length()==0 || !mCompiles.matches(\"^[a-zA-Z0-9]*(,[a-zA-Z0-9]*)*$\"))\n\t\t\t\tthrow new XMLParseException(\"src attribute of is not valid\");\n\t\t\tmProjects = new ArrayList();\n\t\t\tNodeList vcxprojList = qsyncDoc.getElementsByTagName(\"vcxproj\");\n\t\t\tif(vcxprojList.getLength() == 0) throw new XMLParseException(\"no elements found\");\n\t\t\tfor(int i=vcxprojList.getLength()-1; i>=0; --i)\n\t\t\t{\n\t\t\t\tNode projNode = vcxprojList.item(i);\n\t\t\t\tElement projElem = (Element) qsyncDoc.adoptNode(projNode);\n\t\t\t\tString projFile = projElem.getAttribute(\"proj\");\n\t\t\t\tif(projFile.length()==0 || !projFile.matches(\".*vcxproj$\"))\n\t\t\t\t\tthrow new XMLParseException(\"proj attribute of is not valid (must be *.vcxproj)\");\n\t\t\t\tprojFile = Helpers.resolvePath(mPwd.getAbsolutePath(), projFile);\n\t\t\t\tQSyncVcxproj proj = new QSyncVcxproj(projFile, projFile + \".filters\");\n\t\t\t\tNodeList importList = projNode.getChildNodes();\n\t\t\t\tif(importList.getLength() == 0) throw new XMLParseException(\"no element defined for \" + projFile);\n\t\t\t\tfor(int j= importList.getLength()-1; j>=0; --j)\n\t\t\t\t{\n\t\t\t\t\tNode importNode = importList.item(j);\n\t\t\t\t\tif(!importNode.getNodeName().equals(\"import\")) continue;\n\t\t\t\t\tString toFilter = importNode.getAttributes().getNamedItem(\"tofilter\").getNodeValue();\n\t\t\t\t\ttoFilter = Helpers.fixSlashes(toFilter);\n\t\t\t\t\ttoFilter = Helpers.stripSlashes(toFilter);\n\t\t\t\t\tif(toFilter.length()==0 || !toFilter.matches(\"[a-zA-Z0-9 ]*(\\\\\\\\[a-zA-Z0-9 ]*)*\"))\n\t\t\t\t\t\tthrow new XMLParseException(\"tofilter attribute of is not valid\");\n\t\t\t\t\tQSyncImport imp = new QSyncImport(toFilter);\n\t\t\t\t\tNodeList importIncludesList = importNode.getChildNodes();\n\t\t\t\t\tif(importIncludesList.getLength()==0)\n\t\t\t\t\t\tthrow new XMLParseException(\" is empty (with tofilter=\"+toFilter+\")\");\n\t\t\t\t\tboolean src=false, inc=false;\n\t\t\t\t\tfor(int n=importIncludesList.getLength()-1; n>=0; --n)\n\t\t\t\t\t{\n\t\t\t\t\t\tNode includeNode = importIncludesList.item(n);\n\t\t\t\t\t\tif(!includeNode.getNodeName().equals(\"include\")\n\t\t\t\t\t\t\t\t && !includeNode.getNodeName().equals(\"src\")\n\t\t\t\t\t\t\t\t && !includeNode.getNodeName().equals(\"misc\"))\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif(includeNode.getNodeName().equals(\"include\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tNode attrNode;\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"accept\"))!=null )\n\t\t\t\t\t\t\t\timp.setRegexpInclude(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"exclude\"))!=null )\n\t\t\t\t\t\t\t\timp.setExcludeInc(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif(inc) throw new XMLParseException(\" has multiple elements\");\n\t\t\t\t\t\t\tif(includeNode.getFirstChild()==null) throw new XMLParseException(\" element is empty.\"); \n\t\t\t\t\t\t\tinc = true;\n\t\t\t\t\t\t\tString includePath = includeNode.getFirstChild().getNodeValue();\n\t\t\t\t\t\t\tincludePath = Helpers.resolvePath(mPwd.getAbsolutePath(), includePath);\n\t\t\t\t\t\t\timp.setInclude(includePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(includeNode.getNodeName().equals(\"src\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tNode attrNode;\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"regexp\"))!=null)\n\t\t\t\t\t\t\t\timp.setRegexpSrc(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"exclude\"))!=null )\n\t\t\t\t\t\t\t\timp.setExcludeSrc(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif(src) throw new XMLParseException(\" has multiple elements\");\n\t\t\t\t\t\t\tif(includeNode.getFirstChild()==null) throw new XMLParseException(\" element is empty\");\n\t\t\t\t\t\t\tsrc = true;\n\t\t\t\t\t\t\tString srcPath = includeNode.getFirstChild().getNodeValue();\n\t\t\t\t\t\t\tsrcPath = Helpers.resolvePath(mPwd.getAbsolutePath(), srcPath);\n\t\t\t\t\t\t\timp.setSrc(srcPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(includeNode.getNodeName().equals(\"misc\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(includeNode.getFirstChild()==null) throw new XMLParseException(\" element is empty\");\n\t\t\t\t\t\t\tString miscPath = includeNode.getFirstChild().getNodeValue();\n\t\t\t\t\t\t\tmiscPath = Helpers.resolvePath(mPwd.getAbsolutePath(), miscPath);\n\t\t\t\t\t\t\timp.addMisc(miscPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow new XMLParseException(\" has invalid element: \" + includeNode.getNodeName());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tproj.addImport(imp);\n\t\t\t\t}\n\t\t\t\tmProjects.add(proj);\n\t\t\t}\n\t\t}\n\t\tcatch(XMLParseException ex) { System.err.println(\"XMLParseExcepiton: \" + ex.getMessage()); System.exit(-1); }\n\t}\n", "output": "\tpublic QSync(File qsyncfile)\n\t{\n\t\tDocument qsyncDoc =null;\n\t\ttry\n\t\t{\n\t\t\tqsyncDoc = DocumentBuilderFactory.newInstance()\n\t\t\t\t\t.newDocumentBuilder()\n\t\t\t\t\t.parse(qsyncfile);\n\t\t}\n\t\tcatch(ParserConfigurationException ex) { System.err.println(\"QSync: error creating XML configuration\"); }\n\t\tcatch(SAXException ex) { System.err.println(\"Error reading document (\"+qsyncfile.getName()+\"): \"+ex.getMessage()); }\n\t\tcatch(IOException ex) { System.err.println(\"IOException reading document (\"+qsyncfile.getName()+\")\"); }\t\n\t\tif(qsyncDoc==null) System.exit(-1); \n\t\tmPwd = qsyncfile.getAbsoluteFile().getParentFile();\n\t\ttry\n\t\t{\n\t\t\tNodeList includeExtList = qsyncDoc.getElementsByTagName(\"ClInclude\");\n\t\t\tif(includeExtList.getLength() == 0) throw new XMLParseException(\"element not found\");\n\t\t\tif(includeExtList.getLength() >1) throw new XMLParseException(\"multiple elements\");\n\t\t\tElement includes = (Element) qsyncDoc.adoptNode(includeExtList.item(0));\n\t\t\tmIncludes = includes.getAttribute(\"ext\");\n\t\t\tif(mIncludes.length()==0 || !mIncludes.matches(\"^[a-zA-Z0-9]*(,[a-zA-Z0-9]*)*$\"))\n\t\t\t\tthrow new XMLParseException(\"src attribute of is not valid\");\n\t\t\tNodeList compileExtList = qsyncDoc.getElementsByTagName(\"ClCompile\");\n\t\t\tif(compileExtList.getLength() == 0) throw new XMLParseException(\"element not found\");\n\t\t\tif(compileExtList.getLength() >1) throw new XMLParseException(\"multiple elements\");\n\t\t\tElement compiles = (Element) qsyncDoc.adoptNode(compileExtList.item(0));\n\t\t\tmCompiles = compiles.getAttribute(\"ext\");\n\t\t\tif(mCompiles.length()==0 || !mCompiles.matches(\"^[a-zA-Z0-9]*(,[a-zA-Z0-9]*)*$\"))\n\t\t\t\tthrow new XMLParseException(\"src attribute of is not valid\");\n\t\t\tmProjects = new ArrayList();\n\t\t\tNodeList vcxprojList = qsyncDoc.getElementsByTagName(\"vcxproj\");\n\t\t\tif(vcxprojList.getLength() == 0) throw new XMLParseException(\"no elements found\");\n\t\t\tfor(int i=vcxprojList.getLength()-1; i>=0; --i)\n\t\t\t{\n\t\t\t\tNode projNode = vcxprojList.item(i);\n\t\t\t\tElement projElem = (Element) qsyncDoc.adoptNode(projNode);\n\t\t\t\tString projFile = projElem.getAttribute(\"proj\");\n\t\t\t\tif(projFile.length()==0 || !projFile.matches(\".*vcxproj$\"))\n\t\t\t\t\tthrow new XMLParseException(\"proj attribute of is not valid (must be *.vcxproj)\");\n\t\t\t\tprojFile = Helpers.resolvePath(mPwd.getAbsolutePath(), projFile);\n\t\t\t\tQSyncVcxproj proj = new QSyncVcxproj(projFile, projFile + \".filters\");\n\t\t\t\tNodeList importList = projNode.getChildNodes();\n\t\t\t\tif(importList.getLength() == 0) throw new XMLParseException(\"no element defined for \" + projFile);\n\t\t\t\tfor(int j= importList.getLength()-1; j>=0; --j)\n\t\t\t\t{\n\t\t\t\t\tNode importNode = importList.item(j);\n\t\t\t\t\tif(!importNode.getNodeName().equals(\"import\")) continue;\n\t\t\t\t\tString toFilter = importNode.getAttributes().getNamedItem(\"tofilter\").getNodeValue();\n\t\t\t\t\ttoFilter = Helpers.fixSlashes(toFilter);\n\t\t\t\t\ttoFilter = Helpers.stripSlashes(toFilter);\n\t\t\t\t\tif(toFilter.length()==0 || !toFilter.matches(\"[a-zA-Z0-9 ]*(\\\\\\\\[a-zA-Z0-9 ]*)*\"))\n\t\t\t\t\t\tthrow new XMLParseException(\"tofilter attribute of is not valid\");\n\t\t\t\t\tQSyncImport imp = new QSyncImport(toFilter);\n\t\t\t\t\tNodeList importIncludesList = importNode.getChildNodes();\n\t\t\t\t\tif(importIncludesList.getLength()==0)\n\t\t\t\t\t\tthrow new XMLParseException(\" is empty (with tofilter=\"+toFilter+\")\");\n\t\t\t\t\tboolean src=false, inc=false;\n\t\t\t\t\tfor(int n=importIncludesList.getLength()-1; n>=0; --n)\n\t\t\t\t\t{\n\t\t\t\t\t\tNode includeNode = importIncludesList.item(n);\n\t\t\t\t\t\tif(!includeNode.getNodeName().equals(\"include\")\n\t\t\t\t\t\t\t\t && !includeNode.getNodeName().equals(\"src\")\n\t\t\t\t\t\t\t\t && !includeNode.getNodeName().equals(\"misc\"))\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif(includeNode.getNodeName().equals(\"include\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tNode attrNode;\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"accept\"))!=null )\n\t\t\t\t\t\t\t\timp.setRegexpInclude(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"exclude\"))!=null )\n\t\t\t\t\t\t\t\timp.setExcludeInc(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif(inc) throw new XMLParseException(\" has multiple elements\");\n\t\t\t\t\t\t\tif(includeNode.getFirstChild()==null) throw new XMLParseException(\" element is empty.\"); \n\t\t\t\t\t\t\tinc = true;\n\t\t\t\t\t\t\tString includePath = includeNode.getFirstChild().getNodeValue().trim();\n\t\t\t\t\t\t\tincludePath = Helpers.resolvePath(mPwd.getAbsolutePath(), includePath);\n\t\t\t\t\t\t\timp.setInclude(includePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(includeNode.getNodeName().equals(\"src\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tNode attrNode;\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"regexp\"))!=null)\n\t\t\t\t\t\t\t\timp.setRegexpSrc(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif( (attrNode=includeNode.getAttributes().getNamedItem(\"exclude\"))!=null )\n\t\t\t\t\t\t\t\timp.setExcludeSrc(attrNode.getNodeValue());\n\t\t\t\t\t\t\tif(src) throw new XMLParseException(\" has multiple elements\");\n\t\t\t\t\t\t\tif(includeNode.getFirstChild()==null) throw new XMLParseException(\" element is empty\");\n\t\t\t\t\t\t\tsrc = true;\n\t\t\t\t\t\t\tString srcPath = includeNode.getFirstChild().getNodeValue().trim();\n\t\t\t\t\t\t\tsrcPath = Helpers.resolvePath(mPwd.getAbsolutePath(), srcPath);\n\t\t\t\t\t\t\timp.setSrc(srcPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if(includeNode.getNodeName().equals(\"misc\"))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(includeNode.getFirstChild()==null) throw new XMLParseException(\" element is empty\");\n\t\t\t\t\t\t\tString miscPath = includeNode.getFirstChild().getNodeValue();\n\t\t\t\t\t\t\tmiscPath = Helpers.resolvePath(mPwd.getAbsolutePath(), miscPath);\n\t\t\t\t\t\t\timp.addMisc(miscPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthrow new XMLParseException(\" has invalid element: \" + includeNode.getNodeName());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tproj.addImport(imp);\n\t\t\t\t}\n\t\t\t\tmProjects.add(proj);\n\t\t\t}\n\t\t}\n\t\tcatch(XMLParseException ex) { System.err.println(\"XMLParseExcepiton: \" + ex.getMessage()); System.exit(-1); }\n\t}\n"} {"input": "\tpublic List validate(String source, final URI path, final IValidationManager manager)\n\t{\n\t\tList items = new ArrayList();\n\t\tCompatVersion version = CompatVersion.RUBY1_8;\n\t\tIPath projectPath = null;\n\t\tIPath workingDir = null;\n\t\tif (path != null && \"file\".equals(path.getScheme())) \n\t\t{\n\t\t\tFile file = new File(path);\n\t\t\tworkingDir = Path.fromOSString(file.getParent());\n\t\t}\n\t\tif (workingDir != null)\n\t\t{\n\t\t\tIContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(workingDir);\n\t\t\tif (container != null)\n\t\t\t{\n\t\t\t\tIProject project = container.getProject();\n\t\t\t\tif (project != null)\n\t\t\t\t{\n\t\t\t\t\tprojectPath = project.getLocation();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tIPath ruby = RubyLaunchingPlugin.rubyExecutablePath(projectPath);\n\t\tString rubyVersion = ProcessUtil.outputForCommand(\n\t\t\t\truby == null ? \"ruby\" : ruby.toOSString(), workingDir, ShellExecutable.getEnvironment(), \"-v\"); \n\t\tif (rubyVersion != null && rubyVersion.startsWith(\"ruby 1.9\")) \n\t\t{\n\t\t\tversion = CompatVersion.RUBY1_9;\n\t\t}\n\t\tParserConfiguration config = new ParserConfiguration(1, version);\n\t\tRubyParser parser;\n\t\tif (version == CompatVersion.RUBY1_9)\n\t\t{\n\t\t\tParserSupport19 support = new ParserSupport19();\n\t\t\tsupport.setConfiguration(config);\n\t\t\tparser = new Ruby19Parser(support);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tParserSupport support = new ParserSupport();\n\t\t\tsupport.setConfiguration(config);\n\t\t\tparser = new Ruby18Parser(support);\n\t\t}\n\t\tIRubyWarnings warnings = new IRubyWarnings()\n\t\t{\n\t\t\tpublic void warn(ID id, SourcePosition position, String message, Object... data)\n\t\t\t{\n\t\t\t\tint length = position.getEndOffset() - position.getStartOffset() + 1;\n\t\t\t\tmanager.addWarning(message, position.getStartLine(), 0, length, path);\n\t\t\t}\n\t\t\tpublic void warn(ID id, String fileName, int lineNumber, String message, Object... data)\n\t\t\t{\n\t\t\t\tmanager.addWarning(message, lineNumber, 0, 1, path);\n\t\t\t}\n\t\t\tpublic boolean isVerbose()\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tpublic void warn(ID id, String message, Object... data)\n\t\t\t{\n\t\t\t\tmanager.addWarning(message, 1, 0, 1, path);\n\t\t\t}\n\t\t\tpublic void warning(ID id, String message, Object... data)\n\t\t\t{\n\t\t\t\twarn(id, message, data);\n\t\t\t}\n\t\t\tpublic void warning(ID id, SourcePosition position, String message, Object... data)\n\t\t\t{\n\t\t\t\twarn(id, position, message, data);\n\t\t\t}\n\t\t\tpublic void warning(ID id, String fileName, int lineNumber, String message, Object... data)\n\t\t\t{\n\t\t\t\twarn(id, fileName, lineNumber, message, data);\n\t\t\t}\n\t\t};\n\t\tparser.setWarnings(warnings);\n\t\tLexerSource lexerSource = LexerSource.getSource(path.getPath(), new StringReader(source), config);\n\t\ttry\n\t\t{\n\t\t\tparser.parse(config, lexerSource);\n\t\t}\n\t\tcatch (SyntaxException e)\n\t\t{\n\t\t\tint start = e.getPosition().getStartOffset();\n\t\t\tint end = e.getPosition().getEndOffset();\n\t\t\tint lineNumber = e.getPosition().getStartLine();\n\t\t\tint charLineOffset = 0;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tint lineOffset = new Document(source).getLineOffset(lineNumber - 1);\n\t\t\t\tcharLineOffset = start - lineOffset;\n\t\t\t}\n\t\t\tcatch (BadLocationException ble)\n\t\t\t{\n\t\t\t}\n\t\t\tmanager.addError(e.getMessage(), lineNumber, charLineOffset, end - start + 1, path);\n\t\t}\n\t\treturn items;\n\t}\n", "output": "\tpublic List validate(String source, final URI path, final IValidationManager manager)\n\t{\n\t\tList items = new ArrayList();\n\t\tCompatVersion version = CompatVersion.RUBY1_8;\n\t\tIPath projectPath = null;\n\t\tIPath workingDir = null;\n\t\tif (path != null && \"file\".equals(path.getScheme())) \n\t\t{\n\t\t\tFile file = new File(path);\n\t\t\tworkingDir = Path.fromOSString(file.getParent());\n\t\t}\n\t\tif (workingDir != null)\n\t\t{\n\t\t\tIContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(workingDir);\n\t\t\tif (container != null)\n\t\t\t{\n\t\t\t\tIProject project = container.getProject();\n\t\t\t\tif (project != null)\n\t\t\t\t{\n\t\t\t\t\tprojectPath = project.getLocation();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tIPath ruby = RubyLaunchingPlugin.rubyExecutablePath(projectPath);\n\t\tString rubyVersion = ProcessUtil.outputForCommand(\n\t\t\t\truby == null ? \"ruby\" : ruby.toOSString(), workingDir, ShellExecutable.getEnvironment(), \"-v\"); \n\t\tif (rubyVersion != null && rubyVersion.startsWith(\"ruby 1.9\")) \n\t\t{\n\t\t\tversion = CompatVersion.RUBY1_9;\n\t\t}\n\t\tParserConfiguration config = new ParserConfiguration(1, version);\n\t\tRubyParser parser;\n\t\tif (version == CompatVersion.RUBY1_9)\n\t\t{\n\t\t\tParserSupport19 support = new ParserSupport19();\n\t\t\tsupport.setConfiguration(config);\n\t\t\tparser = new Ruby19Parser(support);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tParserSupport support = new ParserSupport();\n\t\t\tsupport.setConfiguration(config);\n\t\t\tparser = new Ruby18Parser(support);\n\t\t}\n\t\tIRubyWarnings warnings = new IRubyWarnings()\n\t\t{\n\t\t\tpublic void warn(ID id, SourcePosition position, String message, Object... data)\n\t\t\t{\n\t\t\t\tint length = position.getEndOffset() - position.getStartOffset() + 1;\n\t\t\t\tmanager.addWarning(message, position.getStartLine(), 0, length, path);\n\t\t\t}\n\t\t\tpublic void warn(ID id, String fileName, int lineNumber, String message, Object... data)\n\t\t\t{\n\t\t\t\tmanager.addWarning(message, lineNumber, 0, 1, path);\n\t\t\t}\n\t\t\tpublic boolean isVerbose()\n\t\t\t{\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tpublic void warn(ID id, String message, Object... data)\n\t\t\t{\n\t\t\t\tmanager.addWarning(message, 1, 0, 1, path);\n\t\t\t}\n\t\t\tpublic void warning(ID id, String message, Object... data)\n\t\t\t{\n\t\t\t\twarn(id, message, data);\n\t\t\t}\n\t\t\tpublic void warning(ID id, SourcePosition position, String message, Object... data)\n\t\t\t{\n\t\t\t\twarn(id, position, message, data);\n\t\t\t}\n\t\t\tpublic void warning(ID id, String fileName, int lineNumber, String message, Object... data)\n\t\t\t{\n\t\t\t\twarn(id, fileName, lineNumber, message, data);\n\t\t\t}\n\t\t};\n\t\tparser.setWarnings(warnings);\n\t\tLexerSource lexerSource = LexerSource.getSource(path.getPath(), new StringReader(source), config);\n\t\ttry\n\t\t{\n\t\t\tparser.parse(config, lexerSource);\n\t\t}\n\t\tcatch (SyntaxException e)\n\t\t{\n\t\t\tint start = e.getPosition().getStartOffset();\n\t\t\tint end = e.getPosition().getEndOffset();\n\t\t\tint lineNumber = e.getPosition().getStartLine();\n\t\t\tint charLineOffset = 0;\n\t\t\ttry\n\t\t\t{\n\t\t\t\tint lineOffset = new Document(source).getLineOffset(lineNumber - 1);\n\t\t\t\tcharLineOffset = start - lineOffset;\n\t\t\t}\n\t\t\tcatch (BadLocationException ble)\n\t\t\t{\n\t\t\t}\n\t\t\titems.add(manager.addError(e.getMessage(), lineNumber, charLineOffset, end - start + 1, path));\n\t\t}\n\t\treturn items;\n\t}\n"} {"input": " private void initMetadata(String xml) throws FormatException, IOException {\n LIFHandler handler = new LIFHandler();\n xml = \"\" + xml + \n \"\";\n for (int i=0; i\");\n while (st.hasMoreTokens()) {\n String token = st.nextToken();\n elements.add(token.substring(1));\n }\n String token = (String) elements.get(0);\n String key = token.substring(0, token.indexOf(\"\\\"\"));\n String value = token.substring(token.indexOf(\"\\\"\") + 1, token.length()-1);\n addMeta(key, value);\n int ndx = 1;\n int numDatasets = 0;\n Vector widths = new Vector();\n Vector heights = new Vector();\n Vector zs = new Vector();\n Vector ts = new Vector();\n Vector channels = new Vector();\n Vector bps = new Vector();\n Vector extraDims = new Vector();\n String prefix = \"\";\n while (ndx < elements.size()) {\n token = (String) elements.get(ndx);\n if (token.startsWith(\"ScannerSettingRecord\")) {\n if (token.indexOf(\"csScanMode\") != -1) {\n int index = token.indexOf(\"Variant\") + 7;\n String ordering = token.substring(index + 2,\n token.indexOf(\"\\\"\", index + 3));\n ordering = ordering.toLowerCase();\n if (ordering.indexOf(\"x\") == -1 || ordering.indexOf(\"y\") == -1 ||\n ordering.indexOf(\"xy\") == -1)\n {\n int xPos = ordering.indexOf(\"x\");\n int yPos = ordering.indexOf(\"y\");\n int zPos = ordering.indexOf(\"z\");\n int tPos = ordering.indexOf(\"t\");\n if (xPos < 0) xPos = 0;\n if (yPos < 0) yPos = 1;\n if (zPos < 0) zPos = 2;\n if (tPos < 0) tPos = 3;\n int x = ((Integer) widths.get(widths.size() - 1)).intValue();\n int y = ((Integer) heights.get(widths.size() - 1)).intValue();\n int z = ((Integer) zs.get(widths.size() - 1)).intValue();\n int t = ((Integer) ts.get(widths.size() - 1)).intValue();\n int[] dimensions = {x, y, z, t};\n x = dimensions[xPos];\n y = dimensions[yPos];\n z = dimensions[zPos];\n t = dimensions[tPos];\n widths.setElementAt(new Integer(x), widths.size() - 1);\n heights.setElementAt(new Integer(y), heights.size() - 1);\n zs.setElementAt(new Integer(z), zs.size() - 1);\n ts.setElementAt(new Integer(t), ts.size() - 1);\n }\n }\n else if (token.indexOf(\"dblVoxel\") != -1) {\n int index = token.indexOf(\"Variant\") + 7;\n String size = token.substring(index + 2,\n token.indexOf(\"\\\"\", index + 3));\n float cal = Float.parseFloat(size) * 1000000;\n if (token.indexOf(\"X\") != -1) xcal.add(new Float(cal));\n else if (token.indexOf(\"Y\") != -1) ycal.add(new Float(cal));\n else if (token.indexOf(\"Z\") != -1) zcal.add(new Float(cal));\n }\n }\n else if (token.startsWith(\"Element Name\")) {\n seriesNames.add(token.substring(token.indexOf(\"=\") + 2,\n token.length() - 1));\n numDatasets++;\n int numChannels = 0;\n int extras = 1;\n while (token.indexOf(\"/ImageDescription\") == -1) {\n if (token.indexOf(\"=\") != -1) {\n if (token.startsWith(\"Element Name\")) {\n seriesNames.setElementAt(token.substring(token.indexOf(\"=\") + 2,\n token.length() - 1), seriesNames.size() - 1);\n prefix = (String) seriesNames.get(seriesNames.size() - 1);\n }\n Hashtable tmp = new Hashtable();\n while (token.length() > 2) {\n key = token.substring(0, token.indexOf(\"\\\"\") - 1);\n value = token.substring(token.indexOf(\"\\\"\") + 1,\n token.indexOf(\"\\\"\", token.indexOf(\"\\\"\") + 1));\n token = token.substring(key.length() + value.length() + 3);\n key = key.trim();\n value = value.trim();\n tmp.put(key, value);\n }\n if (tmp.get(\"ChannelDescription DataType\") != null) {\n numChannels++;\n if (numChannels == 1) {\n bps.add(new Integer((String) tmp.get(\"Resolution\")));\n String sMin = (String) tmp.get(\"Min\");\n String sMax = (String) tmp.get(\"Max\");\n if (sMin != null && sMax != null) {\n double min = Double.parseDouble(sMin);\n double max = Double.parseDouble(sMax);\n channelMins.add(new Integer((int) min));\n channelMaxs.add(new Integer((int) max));\n }\n }\n }\n else if (tmp.get(\"DimensionDescription DimID\") != null) {\n int w = Integer.parseInt((String) tmp.get(\"NumberOfElements\"));\n int id = Integer.parseInt((String)\n tmp.get(\"DimensionDescription DimID\"));\n switch (id) {\n case 1:\n widths.add(new Integer(w));\n break;\n case 2:\n heights.add(new Integer(w));\n break;\n case 3:\n zs.add(new Integer(w));\n break;\n case 4:\n ts.add(new Integer(w));\n break;\n default:\n extras *= w;\n }\n }\n }\n ndx++;\n if (elements != null && ndx < elements.size()) {\n token = (String) elements.get(ndx);\n }\n else break;\n }\n extraDims.add(new Integer(extras));\n if (numChannels == 0) numChannels++;\n channels.add(new Integer(numChannels));\n if (widths.size() < numDatasets && heights.size() < numDatasets) {\n numDatasets--;\n }\n else {\n if (widths.size() < numDatasets) widths.add(new Integer(1));\n if (heights.size() < numDatasets) heights.add(new Integer(1));\n if (zs.size() < numDatasets) zs.add(new Integer(1));\n if (ts.size() < numDatasets) ts.add(new Integer(1));\n if (bps.size() < numDatasets) bps.add(new Integer(8));\n }\n }\n ndx++;\n }\n numDatasets = widths.size();\n bitsPerPixel = new int[numDatasets];\n extraDimensions = new int[numDatasets];\n status(\"Populating metadata\");\n MetadataStore store = getMetadataStore();\n core = new CoreMetadata(numDatasets);\n Arrays.fill(core.orderCertain, true);\n validBits = new int[numDatasets][];\n for (int i=0; i core.sizeT[i]) ? \"XYCZT\" : \"XYCTZ\";\n bitsPerPixel[i] = ((Integer) bps.get(i)).intValue();\n extraDimensions[i] = ((Integer) extraDims.get(i)).intValue();\n if (extraDimensions[i] > 1) {\n if (core.sizeZ[i] == 1) core.sizeZ[i] = extraDimensions[i];\n else core.sizeT[i] *= extraDimensions[i];\n extraDimensions[i] = 1;\n }\n core.littleEndian[i] = true;\n core.rgb[i] = core.sizeC[i] > 1 && core.sizeC[i] < 4;\n core.interleaved[i] = true;\n core.imageCount[i] = core.sizeZ[i] * core.sizeT[i];\n if (!core.rgb[i]) core.imageCount[i] *= core.sizeC[i];\n validBits[i] = new int[core.sizeC[i] != 2 ? core.sizeC[i] : 3];\n for (int j=0; j 1), new Boolean(core.sizeC[i] > 1),\n new Boolean(core.sizeC[i] > 2), new Boolean(isRGB()), null,\n null, null, null, null, ii, null, null, null, null, null);\n Enumeration keys = metadata.keys();\n while (keys.hasMoreElements()) {\n String k = (String) keys.nextElement();\n boolean use = true; \n for (int j=0; j\" + xml + \n \"\";\n for (int i=0; i\");\n while (st.hasMoreTokens()) {\n String token = st.nextToken();\n elements.add(token.substring(1));\n }\n String token = (String) elements.get(0);\n String key = token.substring(0, token.indexOf(\"\\\"\"));\n String value = token.substring(token.indexOf(\"\\\"\") + 1, token.length()-1);\n addMeta(key, value);\n int ndx = 1;\n int numDatasets = 0;\n Vector widths = new Vector();\n Vector heights = new Vector();\n Vector zs = new Vector();\n Vector ts = new Vector();\n Vector channels = new Vector();\n Vector bps = new Vector();\n Vector extraDims = new Vector();\n String prefix = \"\";\n while (ndx < elements.size()) {\n token = (String) elements.get(ndx);\n if (token.startsWith(\"ScannerSettingRecord\")) {\n if (token.indexOf(\"csScanMode\") != -1) {\n int index = token.indexOf(\"Variant\") + 7;\n String ordering = token.substring(index + 2,\n token.indexOf(\"\\\"\", index + 3));\n ordering = ordering.toLowerCase();\n if (ordering.indexOf(\"x\") == -1 || ordering.indexOf(\"y\") == -1 ||\n ordering.indexOf(\"xy\") == -1)\n {\n int xPos = ordering.indexOf(\"x\");\n int yPos = ordering.indexOf(\"y\");\n int zPos = ordering.indexOf(\"z\");\n int tPos = ordering.indexOf(\"t\");\n if (xPos < 0) xPos = 0;\n if (yPos < 0) yPos = 1;\n if (zPos < 0) zPos = 2;\n if (tPos < 0) tPos = 3;\n int x = ((Integer) widths.get(widths.size() - 1)).intValue();\n int y = ((Integer) heights.get(widths.size() - 1)).intValue();\n int z = ((Integer) zs.get(widths.size() - 1)).intValue();\n int t = ((Integer) ts.get(widths.size() - 1)).intValue();\n int[] dimensions = {x, y, z, t};\n x = dimensions[xPos];\n y = dimensions[yPos];\n z = dimensions[zPos];\n t = dimensions[tPos];\n widths.setElementAt(new Integer(x), widths.size() - 1);\n heights.setElementAt(new Integer(y), heights.size() - 1);\n zs.setElementAt(new Integer(z), zs.size() - 1);\n ts.setElementAt(new Integer(t), ts.size() - 1);\n }\n }\n else if (token.indexOf(\"dblVoxel\") != -1) {\n int index = token.indexOf(\"Variant\") + 7;\n String size = token.substring(index + 2,\n token.indexOf(\"\\\"\", index + 3));\n float cal = Float.parseFloat(size) * 1000000;\n if (token.indexOf(\"X\") != -1) xcal.add(new Float(cal));\n else if (token.indexOf(\"Y\") != -1) ycal.add(new Float(cal));\n else if (token.indexOf(\"Z\") != -1) zcal.add(new Float(cal));\n }\n }\n else if (token.startsWith(\"Element Name\")) {\n seriesNames.add(token.substring(token.indexOf(\"=\") + 2,\n token.length() - 1));\n numDatasets++;\n int numChannels = 0;\n int extras = 1;\n while (token.indexOf(\"/ImageDescription\") == -1) {\n if (token.indexOf(\"=\") != -1) {\n if (token.startsWith(\"Element Name\")) {\n seriesNames.setElementAt(token.substring(token.indexOf(\"=\") + 2,\n token.length() - 1), seriesNames.size() - 1);\n prefix = (String) seriesNames.get(seriesNames.size() - 1);\n }\n Hashtable tmp = new Hashtable();\n while (token.length() > 2) {\n key = token.substring(0, token.indexOf(\"\\\"\") - 1);\n value = token.substring(token.indexOf(\"\\\"\") + 1,\n token.indexOf(\"\\\"\", token.indexOf(\"\\\"\") + 1));\n token = token.substring(key.length() + value.length() + 3);\n key = key.trim();\n value = value.trim();\n tmp.put(key, value);\n }\n if (tmp.get(\"ChannelDescription DataType\") != null) {\n numChannels++;\n if (numChannels == 1) {\n bps.add(new Integer((String) tmp.get(\"Resolution\")));\n String sMin = (String) tmp.get(\"Min\");\n String sMax = (String) tmp.get(\"Max\");\n if (sMin != null && sMax != null) {\n double min = Double.parseDouble(sMin);\n double max = Double.parseDouble(sMax);\n channelMins.add(new Integer((int) min));\n channelMaxs.add(new Integer((int) max));\n }\n }\n }\n else if (tmp.get(\"DimensionDescription DimID\") != null) {\n int w = Integer.parseInt((String) tmp.get(\"NumberOfElements\"));\n int id = Integer.parseInt((String)\n tmp.get(\"DimensionDescription DimID\"));\n switch (id) {\n case 1:\n widths.add(new Integer(w));\n break;\n case 2:\n heights.add(new Integer(w));\n break;\n case 3:\n zs.add(new Integer(w));\n break;\n case 4:\n ts.add(new Integer(w));\n break;\n default:\n extras *= w;\n }\n }\n }\n ndx++;\n if (elements != null && ndx < elements.size()) {\n token = (String) elements.get(ndx);\n }\n else break;\n }\n extraDims.add(new Integer(extras));\n if (numChannels == 0) numChannels++;\n channels.add(new Integer(numChannels));\n if (widths.size() < numDatasets && heights.size() < numDatasets) {\n numDatasets--;\n }\n else {\n if (widths.size() < numDatasets) widths.add(new Integer(1));\n if (heights.size() < numDatasets) heights.add(new Integer(1));\n if (zs.size() < numDatasets) zs.add(new Integer(1));\n if (ts.size() < numDatasets) ts.add(new Integer(1));\n if (bps.size() < numDatasets) bps.add(new Integer(8));\n }\n }\n ndx++;\n }\n numDatasets = widths.size();\n bitsPerPixel = new int[numDatasets];\n extraDimensions = new int[numDatasets];\n status(\"Populating metadata\");\n MetadataStore store = getMetadataStore();\n core = new CoreMetadata(numDatasets);\n Arrays.fill(core.orderCertain, true);\n validBits = new int[numDatasets][];\n for (int i=0; i core.sizeT[i]) ? \"XYCZT\" : \"XYCTZ\";\n bitsPerPixel[i] = ((Integer) bps.get(i)).intValue();\n extraDimensions[i] = ((Integer) extraDims.get(i)).intValue();\n if (extraDimensions[i] > 1) {\n if (core.sizeZ[i] == 1) core.sizeZ[i] = extraDimensions[i];\n else core.sizeT[i] *= extraDimensions[i];\n extraDimensions[i] = 1;\n }\n core.littleEndian[i] = true;\n core.rgb[i] = core.sizeC[i] > 1 && core.sizeC[i] < 4;\n core.interleaved[i] = true;\n core.imageCount[i] = core.sizeZ[i] * core.sizeT[i];\n if (!core.rgb[i]) core.imageCount[i] *= core.sizeC[i];\n validBits[i] = new int[core.sizeC[i] != 2 ? core.sizeC[i] : 3];\n for (int j=0; j 1), new Boolean(core.sizeC[i] > 1),\n new Boolean(core.sizeC[i] > 2), new Boolean(isRGB()), null,\n null, null, null, null, ii, null, null, null, null, null);\n Enumeration keys = metadata.keys();\n while (keys.hasMoreElements()) {\n String k = (String) keys.nextElement();\n boolean use = true; \n for (int j=0; j 0 ){\n file = ((IASTFileLocation) locs[0]).getFileName();\n offset = locs[0].getNodeOffset();\n } else {\n file = \"\"; \n offset = 0;\n }\n Object[] args = new Object[] { msg, file, new Integer(offset) }; \n message = ParserMessages.getFormattedString(AST_PROBLEM_PATTERN, args);\n return message;\n }\n", "output": " public String getMessage() {\n if (message != null)\n return message;\n String msg = (String) errorMessages.get(new Integer(id));\n if (msg == null)\n msg = \"\"; \n if (arg != null) {\n msg = MessageFormat.format(msg, new Object[] { new String(arg) });\n }\n IASTNodeLocation [] locs = getNodeLocations();\n String file = null;\n int offset = 0;\n if( locs != null && locs.length == 1 && locs[0] instanceof IASTFileLocation ){\n file = ((IASTFileLocation) locs[0]).getFileName();\n offset = locs[0].getNodeOffset();\n } else {\n IASTFileLocation f = getTranslationUnit().flattenLocationsToFile(locs);\n if( f == null )\n {\n file = \"\"; \n offset = 0;\n }\n else\n {\n file = f.getFileName();\n offset = f.getNodeOffset();\n }\n }\n Object[] args = new Object[] { msg, file, new Integer(offset) }; \n message = ParserMessages.getFormattedString(AST_PROBLEM_PATTERN, args);\n return message;\n }\n"} {"input": "\tprivate void nextInts() {\n\t\tswitch (operation) {\n\t\tcase 0:\n\t\t\toperand1 = random.nextInt(99) + 1;\n\t\t\toperand2 = random.nextInt(99) + 1;\n\t\t\tresult = operand1 + operand2;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\toperand1 = random.nextInt(99) + 1;\n\t\t\toperand2 = random.nextInt(99) + 1;\n\t\t\tresult = operand1 - operand2;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\toperand1 = random.nextInt(8) + 2;\n\t\t\toperand2 = random.nextInt(8) + 2;\n\t\t\tresult = operand1 * operand2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tresult = random.nextInt(8) + 2;\n\t\t\toperand2 = random.nextInt(8) + 2;\n\t\t\toperand1 = result * operand2;\n\t\t\tbreak;\t\n\t\tdefault:\n\t\t\tthrow new IllegalArgumentException(\"This should not happen\");\n\t\t}\n\t}\n", "output": "\tprivate void nextInts() {\n\t\tswitch (operation) {\n\t\tcase 0:\n\t\t\toperand1 = random.nextInt(99) + 1;\n\t\t\toperand2 = random.nextInt(99) + 1;\n\t\t\tresult = operand1 + operand2;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\toperand1 = random.nextInt(99) + 1;\n\t\t\toperand2 = random.nextInt(99) + 1;\n\t\t\tresult = operand1 - operand2;\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\toperand1 = random.nextInt(8) + 2;\n\t\t\toperand2 = random.nextInt(8) + 2;\n\t\t\tresult = operand1 * operand2;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tresult = random.nextInt(8) + 2;\n\t\t\toperand2 = random.nextInt(8) + 2;\n\t\t\toperand1 = result / operand2;\n\t\t\tbreak;\t\n\t\tdefault:\n\t\t\tthrow new IllegalArgumentException(\"This should not happen\");\n\t\t}\n\t}\n"} {"input": " private String parseString(Source source)\n {\n if (source.next()!='\"')\n throw new IllegalStateException();\n boolean escape=false;\n StringBuffer b=null;\n final char[] scratch=source.scratchBuffer();\n if (scratch!=null)\n {\n int i=0;\n while (source.hasNext())\n {\n if(i>=scratch.length)\n {\n b=new StringBuffer(scratch.length*2);\n b.append(scratch,0,i);\n break;\n }\n char c=source.next();\n if (escape)\n {\n escape=false;\n switch (c)\n {\n case '\"':\n scratch[i++]='\"';\n break;\n case '\\\\':\n scratch[i++]='\\\\';\n break;\n case '/':\n scratch[i++]='/';\n break;\n case 'b':\n scratch[i++]='\\b';\n break;\n case 'f':\n scratch[i++]='\\f';\n break;\n case 'n':\n scratch[i++]='\\n';\n break;\n case 'r':\n scratch[i++]='\\r';\n break;\n case 't':\n scratch[i++]='\\t';\n break;\n case 'u':\n char uc=(char)((TypeUtil.convertHexDigit((byte)source.next())<<12)+\n (TypeUtil.convertHexDigit((byte)source.next())<<8)+\n (TypeUtil.convertHexDigit((byte)source.next())<<4)+\n (TypeUtil.convertHexDigit((byte)source.next())));\n scratch[i++]=uc;\n break;\n default:\n scratch[i++]=c;\n }\n }\n else if (c=='\\\\')\n {\n escape=true;\n continue;\n }\n else if (c=='\\\"')\n {\n return toString(scratch,0,i);\n }\n else\n scratch[i++]=c;\n }\n if (b==null)\n return toString(scratch,0,i);\n }\n else\n b=new StringBuffer(getStringBufferSize());\n synchronized (b)\n {\n while (source.hasNext())\n {\n char c=source.next();\n if (escape)\n {\n escape=false;\n switch (c)\n {\n case 'n':\n b.append('\\n');\n break;\n case 'r':\n b.append('\\r');\n break;\n case 't':\n b.append('\\t');\n break;\n case 'f':\n b.append('\\f');\n break;\n case 'b':\n b.append('\\b');\n break;\n case 'u':\n b.append((char)((TypeUtil.convertHexDigit((byte)source.next())<<24)+(TypeUtil.convertHexDigit((byte)source.next())<<16)\n +(TypeUtil.convertHexDigit((byte)source.next())<<8)+(TypeUtil.convertHexDigit((byte)source.next()))));\n break;\n default:\n b.append(c);\n }\n }\n else if (c=='\\\\')\n {\n escape=true;\n continue;\n }\n else if (c=='\\\"')\n break;\n else\n b.append(c);\n }\n return b.toString();\n }\n }\n", "output": " private String parseString(Source source)\n {\n if (source.next()!='\"')\n throw new IllegalStateException();\n boolean escape=false;\n StringBuffer b=null;\n final char[] scratch=source.scratchBuffer();\n if (scratch!=null)\n {\n int i=0;\n while (source.hasNext())\n {\n if(i>=scratch.length)\n {\n b=new StringBuffer(scratch.length*2);\n b.append(scratch,0,i);\n break;\n }\n char c=source.next();\n if (escape)\n {\n escape=false;\n switch (c)\n {\n case '\"':\n scratch[i++]='\"';\n break;\n case '\\\\':\n scratch[i++]='\\\\';\n break;\n case '/':\n scratch[i++]='/';\n break;\n case 'b':\n scratch[i++]='\\b';\n break;\n case 'f':\n scratch[i++]='\\f';\n break;\n case 'n':\n scratch[i++]='\\n';\n break;\n case 'r':\n scratch[i++]='\\r';\n break;\n case 't':\n scratch[i++]='\\t';\n break;\n case 'u':\n char uc=(char)((TypeUtil.convertHexDigit((byte)source.next())<<12)+\n (TypeUtil.convertHexDigit((byte)source.next())<<8)+\n (TypeUtil.convertHexDigit((byte)source.next())<<4)+\n (TypeUtil.convertHexDigit((byte)source.next())));\n scratch[i++]=uc;\n break;\n default:\n scratch[i++]=c;\n }\n }\n else if (c=='\\\\')\n {\n escape=true;\n continue;\n }\n else if (c=='\\\"')\n {\n return toString(scratch,0,i);\n }\n else\n scratch[i++]=c;\n }\n if (b==null)\n return toString(scratch,0,i);\n }\n else\n b=new StringBuffer(getStringBufferSize());\n synchronized (b)\n {\n while (source.hasNext())\n {\n char c=source.next();\n if (escape)\n {\n escape=false;\n switch (c)\n {\n case '\"':\n b.append('\"');\n break;\n case '\\\\':\n b.append('\\\\');\n break;\n case '/':\n b.append('/');\n break;\n case 'b':\n b.append('\\b');\n break;\n case 'f':\n b.append('\\f');\n break;\n case 'n':\n b.append('\\n');\n break;\n case 'r':\n b.append('\\r');\n break;\n case 't':\n b.append('\\t');\n break;\n case 'u':\n char uc=(char)((TypeUtil.convertHexDigit((byte)source.next())<<12)+\n (TypeUtil.convertHexDigit((byte)source.next())<<8)+\n (TypeUtil.convertHexDigit((byte)source.next())<<4)+\n (TypeUtil.convertHexDigit((byte)source.next())));\n b.append(uc);\n break;\n default:\n b.append(c);\n }\n }\n else if (c=='\\\\')\n {\n escape=true;\n continue;\n }\n else if (c=='\\\"')\n break;\n else\n b.append(c);\n }\n return b.toString();\n }\n }\n"} {"input": " public String getStudentId(final long id)\n {\n Cursor c = null;\n try\n {\n c = getDatabase().query(\n Signature.TABLE_NAME,\n new String[] { Signature.STUDENT_ID },\n Signature._ID + \"=?\",\n new String[] { Long.toString(id) },\n null ,\n null ,\n null );\n if (c != null && c.moveToFirst())\n {\n return c.getString(0);\n } \n return null;\n } \n finally\n {\n if (c != null)\n {\n c.close();\n } \n } \n } \n", "output": " public String getStudentId(final long id)\n {\n Cursor c = null;\n try\n {\n c = getDatabase().query(\n Signature.TABLE_NAME,\n new String[] { Signature.STUDENT_ID },\n Signature._ID + \"=?\",\n new String[] { Long.toString(id) },\n null ,\n null ,\n null );\n if (c != null && c.moveToFirst())\n {\n return c.getString(0);\n } \n Log.e(TAG, \"Failed to get student ID for \" + id);\n return null;\n } \n finally\n {\n if (c != null)\n {\n c.close();\n } \n } \n } \n"} {"input": "\tpublic static Test suite() {\n\t\tTestSuite suite = new TestSuite(AllTests.class.getName());\n\t\tsuite.addTest(Bug_126104.suite());\n\t\tsuite.addTest(Bug_127562.suite());\n\t\tsuite.addTest(Bug_25457.suite());\n\t\tsuite.addTest(Bug_26294.suite());\n\t\tsuite.addTest(Bug_27271.suite());\n\t\tsuite.addTest(Bug_28981.suite());\n\t\tsuite.addTest(Bug_29116.suite());\n\t\tsuite.addTest(Bug_29671.suite());\n\t\tsuite.addTest(Bug_29851.suite());\n\t\tsuite.addTest(Bug_32076.suite());\n\t\tsuite.addTest(Bug_44106.suite());\n\t\tsuite.addTest(Bug_6708.suite());\n\t\tsuite.addTest(Bug_98740.suite());\n\t\tsuite.addTest(IFileTest.suite());\n\t\tsuite.addTest(IFolderTest.suite());\n\t\tsuite.addTest(IProjectTest.suite());\n\t\tsuite.addTest(IResourceTest.suite());\n\t\tsuite.addTest(IWorkspaceTest.suite());\n\t\tsuite.addTest(LocalStoreRegressionTests.suite());\n\t\tsuite.addTest(NLTest.suite());\n\t\tsuite.addTest(PR_1GEAB3C_Test.suite());\n\t\tsuite.addTest(PR_1GH2B0N_Test.suite());\n\t\tsuite.addTest(PR_1GHOM0N_Test.suite());\n\t\treturn suite;\n\t}\n", "output": "\tpublic static Test suite() {\n\t\tTestSuite suite = new TestSuite(AllTests.class.getName());\n\t\tsuite.addTest(Bug_126104.suite());\n\t\tsuite.addTest(Bug_127562.suite());\n\t\tsuite.addTest(Bug_132510.suite());\n\t\tsuite.addTest(Bug_25457.suite());\n\t\tsuite.addTest(Bug_26294.suite());\n\t\tsuite.addTest(Bug_27271.suite());\n\t\tsuite.addTest(Bug_28981.suite());\n\t\tsuite.addTest(Bug_29116.suite());\n\t\tsuite.addTest(Bug_29671.suite());\n\t\tsuite.addTest(Bug_29851.suite());\n\t\tsuite.addTest(Bug_32076.suite());\n\t\tsuite.addTest(Bug_44106.suite());\n\t\tsuite.addTest(Bug_6708.suite());\n\t\tsuite.addTest(Bug_98740.suite());\n\t\tsuite.addTest(IFileTest.suite());\n\t\tsuite.addTest(IFolderTest.suite());\n\t\tsuite.addTest(IProjectTest.suite());\n\t\tsuite.addTest(IResourceTest.suite());\n\t\tsuite.addTest(IWorkspaceTest.suite());\n\t\tsuite.addTest(LocalStoreRegressionTests.suite());\n\t\tsuite.addTest(NLTest.suite());\n\t\tsuite.addTest(PR_1GEAB3C_Test.suite());\n\t\tsuite.addTest(PR_1GH2B0N_Test.suite());\n\t\tsuite.addTest(PR_1GHOM0N_Test.suite());\n\t\treturn suite;\n\t}\n"} {"input": " public String getHoverHelpAt(IParseController parseController, ISourceViewer srcViewer, int offset)\n {\n IPrsStream ps= parseController.getParser().getParseStream();\n IToken token= ps.getTokenAtCharacter(offset);\n if (token == null) return null;\n Object ast = parseController.getCurrentAst();\n if (ast == null) return null;\n IASTNodeLocator nodeLocator= parseController.getNodeLocator();\n Object node = nodeLocator.findNode(ast, offset);\n if (node == null)\n return null;\n if (node instanceof IASTNodeToken\t\n \t\t|| node instanceof ASTNodeToken)\n {\n \tint tokenKind = ((IASTNodeToken) node).getLeftIToken().getKind();\n \tswitch (tokenKind) {\n \tcase PrefspecsLexer.TK_TABS:\n \t\treturn(\"In this section list each of the four tabs: 'default', 'configuration', 'instance', and 'project',\t\" +\n \t\t\t\t\"and, for eack, indicate whether it is 'in' or 'out' of the preference page and assign tab-wide attributes, \" +\n \t\t\t\t\"'iseditable' and/or 'isremovable', as appropriate\");\n \tcase PrefspecsLexer.TK_FIELDS:\n \t\treturn(\"In this section list the fields that will appear on the generated preferences page (each field will appear\" +\n \t\t\t\t\"on each included tab). To list a field, give its type and name, and optionally set any properties specific \" +\n \t\t\t\t\"to that field (applicable properties depend on field type). The name of each field should be unique.\");\n \tcase PrefspecsLexer.TK_CUSTOM:\n \t\treturn(\"In this section provide property values that apply to specific fields on specific tabs. \" +\n \t\t\t\t\"Designate fields by 'tab-name' 'field-name'; \" +\n \t\t\t\t\"applicable properties depend on field type. \" +\n \t\t\t\t\"Field names should have been introduced in the 'fields' section. \" +\n \t\t\t\t\"Specific fields (specific tab-field combinations) may appear multiple times \" +\n \t\t\t\t\"with any subset of applicable properties (later assignments override earlier ones).\");\n \tcase PrefspecsLexer.TK_CONDITIONALS:\n \t\treturn(\"In this section list fields of any type whose enabled state depends on the state of another field of boolean type.\" +\n \t\t\t\t\"E.g., 'nameOfDependentField with nameOfBooleanField' or 'nameOfDependentField against nameOfBooleanField'\");\n \tcase PrefspecsLexer.TK_DEFAULT:\n \t\treturn(\"Designates the 'default' level preferences tab\");\n \tcase PrefspecsLexer.TK_CONFIGURATION:\n \t\treturn(\"Designates the 'configuration' level preferences tab\");\n \tcase PrefspecsLexer.TK_INSTANCE:\n \t\treturn(\"Designates the 'instance' level preferences tab\");\n \tcase PrefspecsLexer.TK_PROJECT:\n \t\treturn(\"Designates the 'project' level preferences tab\");\n \tcase PrefspecsLexer.TK_BOOLEAN:\n \t\treturn(\"Designates the 'boolean' (checkbox) field type\");\n \tcase PrefspecsLexer.TK_COMBO:\n \t\treturn(\"Designates the 'combo' (combo box) field type\");\n \tcase PrefspecsLexer.TK_DIRLIST:\n \t\treturn(\"Designates the 'dirlist' (directory list) field type\");\n \tcase PrefspecsLexer.TK_FILE:\n \t\treturn(\"Designates the 'file' (file name) field type\");\n \tcase PrefspecsLexer.TK_INT:\n \t\treturn(\"Designates the 'int' field type\");\n \tcase PrefspecsLexer.TK_RADIO:\n \t\treturn(\"Designates the 'radio' (radio buttons) field type\");\n \tcase PrefspecsLexer.TK_STRING:\n \t\treturn(\"Designates the 'string' field type\");\n \tcase PrefspecsLexer.TK_EMPTYALLOWED:\n \t\treturn(\"'emptyallowed' indicates whether the field has, and is allowed to take on, \" +\n \t\t\t\t\"an 'empty' value; this attribute takes a boolean value; if 'true' then a value \" +\n \t\t\t\t\"of the field type must be provided (to serve as the 'empty' value); \" +\n \t\t\t\t\"if 'false', then no other argument is needed\");\n \tcase PrefspecsLexer.TK_HASSPECIAL:\n \t\treturn(\"'hasspecial' requires a value of the type of the field that \" +\n \t\t\t\t\"will serve as a distinguished value; omit if no such value\");\n \tcase PrefspecsLexer.TK_ISEDITABLE:\n \t\treturn(\"'iseditable' takes a boolean value: 'true' indicates that the field \" +\n \t\t\t\t\"can be edited (normal case); false indicates that it cannot (field is 'read only')\");\n \tcase PrefspecsLexer.TK_ISREMOVABLE:\n \t\treturn(\"'isremovable' takes a boolean value: 'true' indicates that the value \" +\n \t\t\t\t\"can be removed from this field an inherited from a higher level; \" +\n \t\t\t\t\"'false' means that the field must always have a local value (not inherited\");\n \tcase PrefspecsLexer.TK_RANGE:\n \t\treturn(\"'range' sets a range for numeric field types in the form 'lowVal .. highVal'\");\n \tcase PrefspecsLexer.TK_AGAINST:\n \t\treturn(\"'against' means that the preceding field (of any type) is enabled if and only if \" +\n \t\t\t\t\"the following field (of boolean type) is set to 'false'\");\n \tcase PrefspecsLexer.TK_WITH:\n \t\treturn(\"'with' means that the preceding field (of any type) is enabled if and only if \" +\n \t\t\t\t\"the following field (of boolean type) is set to 'true'\");\n \tcase PrefspecsLexer.TK_STRING_LITERAL:\n \t\treturn(\"String literal\");\n \tcase PrefspecsLexer.TK_IDENTIFIER:\n \t\tint tokenNumber = ((IASTNodeToken) node).getLeftIToken().getTokenIndex();\n \t\tif (tokenNumber == 2)\n \t\t\treturn \"Preference-page identifier\";\n \t\telse\n \t\t\treturn \"Preference-field identifier\";\n \tcase PrefspecsLexer.TK_SINGLE_LINE_COMMENT:\n \t\treturn \"Comment (no effect on pagegeneration)\";\n \tcase PrefspecsLexer.TK_IN:\n \t\treturn(\"'in' means that the associated tab will be included in the generated preferences page\");\n \tcase PrefspecsLexer.TK_OUT:\n \t\treturn(\"'out' means that the associated tab will not be included in the generated preferences page\");\n \tcase PrefspecsLexer.TK_TRUE:\n \t\treturn(\"The opposite of false.\");\n \tcase PrefspecsLexer.TK_FALSE:\n \t\treturn(\"The opposite of true.\");\n \tcase PrefspecsLexer.TK_PAGE:\n \t\treturn \"This designates the beginning of a preference-page specification\";\n \tcase PrefspecsLexer.TK_LEFTBRACE:\n \tcase PrefspecsLexer.TK_RIGHTBRACE:\n \t\tASTNode grandParentNode = (ASTNode) ((ASTNode)node).getParent().getParent();\n \t\tif (grandParentNode == null) {\n \t\t\tif (tokenKind == PrefspecsLexer.TK_LEFTBRACE)\n \t\t\t\treturn \"This is the beginning of the body of the specification\";\n \t\t\telse\n \t\t\t\treturn \"This is the end of the body of the specification\";\n \t\t}\n \t\tString parentTypeName = grandParentNode.getClass().getName();\n \t\tif (parentTypeName.endsWith(\"tabSpecs\")) {\n \t\t\treturn(\"Specify tab properties within braces; these properties by default apply to \" +\n \t\t\t\t\t\"all fields in the tab. There are two optional properties: \" +\n \t\t\t\t\t\"'iseditable' (boolean) indicates whether fields in the tab are editable; \" +\n \t\t\t\t\t\"'isremovable' (boolean) indicates whether values stored in fields on the tab \" +\n \t\t\t\t\t\"can be removed (triggering inheritance). When both are used 'iseditable' \" +\n \t\t\t\t\t\"must appear first. Each should be followed by a ';'.\");\n \t\t} else if (parentTypeName.endsWith(\"fieldSpecs\")) {\n \t\t\tASTNode specNode = getFieldSpecNode((ASTNode) node);\n \t\t\tif (specNode != null) {\n \t\t\t\tif (specNode.getClass().toString().endsWith(\"booleanFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a boolean field: three optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (boolean), 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"comboFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a combo-box field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"dirListFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a directory-list field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"fileFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a file-name field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"intFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for an integer field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'range' (lowval .. highval), \" +\n \t\t\t\t\t\t\"'hasspecial' (int), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"radioFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a radio-button field: three optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (int), \" +\n\t\t\t\t\t\t\t\t\t\"and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"stringFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a string\tfield: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t}\t\n \t\t\t\treturn(\"Unrecognized field-spec type; no hover help available\");\n \t\t\t} else {\n \t\t\t\treturn(\"No field spec found; no hover help possible\");\n \t\t\t}\n \t\t} else {\n \t\t\treturn(\"This is some kind of crazy AST node!\");\n \t\t}\n \tdefault:\t\t\t\t \n\t\t ASTNode def = null; \n\t\t if (def != null)\n\t\t return getSubstring(parseController, def.getLeftIToken().getStartOffset(), def.getRightIToken().getEndOffset());\n\t\t else\n\t\t \treturn \"Abandon hope\";\n \t}\n }\n return getSubstring(parseController, token);\n }\n", "output": " public String getHoverHelpAt(IParseController parseController, ISourceViewer srcViewer, int offset)\n {\n IPrsStream ps= parseController.getParser().getParseStream();\n IToken token= ps.getTokenAtCharacter(offset);\n if (token == null) return null;\n Object ast = parseController.getCurrentAst();\n if (ast == null) return null;\n IASTNodeLocator nodeLocator= parseController.getNodeLocator();\n Object node = nodeLocator.findNode(ast, offset);\n if (node == null)\n return null;\n if (node instanceof IASTNodeToken\t\n \t\t|| node instanceof ASTNodeToken)\n {\n \tint tokenKind = ((IASTNodeToken) node).getLeftIToken().getKind();\n \tswitch (tokenKind) {\n \tcase PrefspecsLexer.TK_TABS:\n \t\treturn(\"In this section list each of the four tabs: 'default', 'configuration', 'instance', and 'project',\t\" +\n \t\t\t\t\"and, for eack, indicate whether it is 'in' or 'out' of the preference page and assign tab-wide attributes, \" +\n \t\t\t\t\"'iseditable' and/or 'isremovable', as appropriate\");\n \tcase PrefspecsLexer.TK_FIELDS:\n \t\treturn(\"In this section list the fields that will appear on the generated preferences page (each field will appear\" +\n \t\t\t\t\"on each included tab). To list a field, give its type and name, and optionally set any properties specific \" +\n \t\t\t\t\"to that field (applicable properties depend on field type). The name of each field should be unique.\");\n \tcase PrefspecsLexer.TK_CUSTOM:\n \t\treturn(\"In this section provide property values that apply to specific fields on specific tabs. \" +\n \t\t\t\t\"Designate fields by 'tab-name' 'field-name'; \" +\n \t\t\t\t\"applicable properties depend on field type. \" +\n \t\t\t\t\"Field names should have been introduced in the 'fields' section. \" +\n \t\t\t\t\"Specific fields (specific tab-field combinations) may appear multiple times \" +\n \t\t\t\t\"with any subset of applicable properties (later assignments override earlier ones).\");\n \tcase PrefspecsLexer.TK_CONDITIONALS:\n \t\treturn(\"In this section list fields of any type whose enabled state depends on the state of another field of boolean type.\" +\n \t\t\t\t\"E.g., 'nameOfDependentField with nameOfBooleanField' or 'nameOfDependentField against nameOfBooleanField'\");\n \tcase PrefspecsLexer.TK_DEFAULT:\n \t\treturn(\"Designates the 'default' level preferences tab\");\n \tcase PrefspecsLexer.TK_CONFIGURATION:\n \t\treturn(\"Designates the 'configuration' level preferences tab\");\n \tcase PrefspecsLexer.TK_INSTANCE:\n \t\treturn(\"Designates the 'instance' level preferences tab\");\n \tcase PrefspecsLexer.TK_PROJECT:\n \t\treturn(\"Designates the 'project' level preferences tab\");\n \tcase PrefspecsLexer.TK_BOOLEAN:\n \t\treturn(\"Designates the 'boolean' (checkbox) field type\");\n \tcase PrefspecsLexer.TK_COMBO:\n \t\treturn(\"Designates the 'combo' (combo box) field type\");\n \tcase PrefspecsLexer.TK_DIRLIST:\n \t\treturn(\"Designates the 'dirlist' (directory list) field type\");\n \tcase PrefspecsLexer.TK_FILE:\n \t\treturn(\"Designates the 'file' (file name) field type\");\n \tcase PrefspecsLexer.TK_INT:\n \t\treturn(\"Designates the 'int' field type\");\n \tcase PrefspecsLexer.TK_RADIO:\n \t\treturn(\"Designates the 'radio' (radio buttons) field type\");\n \tcase PrefspecsLexer.TK_STRING:\n \t\treturn(\"Designates the 'string' field type\");\n \tcase PrefspecsLexer.TK_EMPTYALLOWED:\n \t\treturn(\"'emptyallowed' indicates whether the field has, and is allowed to take on, \" +\n \t\t\t\t\"an 'empty' value; this attribute takes a boolean value; if 'true' then a value \" +\n \t\t\t\t\"of the field type must be provided (to serve as the 'empty' value); \" +\n \t\t\t\t\"if 'false', then no other argument is needed\");\n \tcase PrefspecsLexer.TK_HASSPECIAL:\n \t\treturn(\"'hasspecial' requires a value of the type of the field that \" +\n \t\t\t\t\"will serve as a distinguished value; omit if no such value\");\n \tcase PrefspecsLexer.TK_ISEDITABLE:\n \t\treturn(\"'iseditable' takes a boolean value: 'true' indicates that the field \" +\n \t\t\t\t\"can be edited (normal case); false indicates that it cannot (field is 'read only')\");\n \tcase PrefspecsLexer.TK_ISREMOVABLE:\n \t\treturn(\"'isremovable' takes a boolean value: 'true' indicates that the value \" +\n \t\t\t\t\"can be removed from this field an inherited from a higher level; \" +\n \t\t\t\t\"'false' means that the field must always have a local value (not inherited\");\n \tcase PrefspecsLexer.TK_RANGE:\n \t\treturn(\"'range' sets a range for numeric field types in the form 'lowVal .. highVal'\");\n \tcase PrefspecsLexer.TK_AGAINST:\n \t\treturn(\"'against' means that the preceding field (of any type) is enabled if and only if \" +\n \t\t\t\t\"the following field (of boolean type) is set to 'false'\");\n \tcase PrefspecsLexer.TK_WITH:\n \t\treturn(\"'with' means that the preceding field (of any type) is enabled if and only if \" +\n \t\t\t\t\"the following field (of boolean type) is set to 'true'\");\n \tcase PrefspecsLexer.TK_STRING_LITERAL:\n \t\treturn(\"String literal\");\n \tcase PrefspecsLexer.TK_IDENTIFIER:\n \t\tint tokenNumber = ((IASTNodeToken) node).getLeftIToken().getTokenIndex();\n \t\tif (tokenNumber == 2)\n \t\t\treturn \"Preference-page identifier\";\n \t\telse\n \t\t\treturn \"Preference-field identifier\";\n \tcase PrefspecsLexer.TK_SINGLE_LINE_COMMENT:\n \t\treturn \"Comment (no effect on pagegeneration)\";\n \tcase PrefspecsLexer.TK_IN:\n \t\treturn(\"'in' means that the associated tab will be included in the generated preferences page\");\n \tcase PrefspecsLexer.TK_OUT:\n \t\treturn(\"'out' means that the associated tab will not be included in the generated preferences page\");\n \tcase PrefspecsLexer.TK_TRUE:\n \t\treturn(\"The opposite of false.\");\n \tcase PrefspecsLexer.TK_FALSE:\n \t\treturn(\"The opposite of true.\");\n \tcase PrefspecsLexer.TK_PAGE:\n \t\treturn \"This designates the beginning of a preference-page specification\";\n \tcase PrefspecsLexer.TK_LEFTBRACE:\n \tcase PrefspecsLexer.TK_RIGHTBRACE:\n \t\tASTNode grandParentNode = (ASTNode) ((ASTNode)node).getParent().getParent();\n \t\tif (grandParentNode == null) {\n \t\t\tif (tokenKind == PrefspecsLexer.TK_LEFTBRACE)\n \t\t\t\treturn \"This is the beginning of the body of the specification\";\n \t\t\telse\n \t\t\t\treturn \"This is the end of the body of the specification\";\n \t\t}\n \t\tString parentTypeName = grandParentNode.getClass().getName();\n \t\tif (parentTypeName.endsWith(\"tabSpecs\")) {\n \t\t\treturn(\"Specify tab properties within braces; these properties by default apply to \" +\n \t\t\t\t\t\"all fields in the tab. There are two optional properties: \" +\n \t\t\t\t\t\"'iseditable' (boolean) indicates whether fields in the tab are editable; \" +\n \t\t\t\t\t\"'isremovable' (boolean) indicates whether values stored in fields on the tab \" +\n \t\t\t\t\t\"can be removed (triggering inheritance). When both are used 'iseditable' \" +\n \t\t\t\t\t\"must appear first. Each should be followed by a ';'.\");\n \t\t} else if (parentTypeName.endsWith(\"fieldSpecs\")) {\n \t\t\tASTNode specNode = getFieldSpecNode((ASTNode) node);\n \t\t\tif (specNode != null) {\n \t\t\t\tif (specNode.getClass().toString().endsWith(\"booleanFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a boolean field: three optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (boolean), 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"comboFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a combo-box field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"dirListFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a directory-list field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"fileFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a file-name field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"intFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for an integer field: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'range' (lowval .. highval), \" +\n \t\t\t\t\t\t\"'hasspecial' (int), and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"radioFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a radio-button field: three optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (int), \" +\n\t\t\t\t\t\t\t\t\t\"and 'isremovable' (boolean).\");\n \t\t\t\t} else if (specNode.getClass().toString().endsWith(\"stringFieldSpec\")) {\n \t\t\t\treturn(\"Specify attributes for a string\tfield: four optional, semicolon-separated attributes, \" +\n \t\t\t\t\t\t\"in this order, if used: 'iseditable' (boolean), 'hasspecial' (string), \" +\n \t\t\t\t\t\t\t\t\"'emptyallowed' (boolean--plus a string if 'true'), and 'isremovable' (boolean).\");\n \t\t\t\t}\t\n \t\t\t\treturn(\"Unrecognized field-spec type; no hover help available\");\n \t\t\t} else {\n \t\t\t\treturn(\"No field spec found; no hover help possible\");\n \t\t\t}\n \t\t} else {\n \t\t\treturn null;\n \t\t}\n \tdefault:\t\t\t\t \n\t\t ASTNode def = null; \n\t\t if (def != null)\n\t\t return getSubstring(parseController, def.getLeftIToken().getStartOffset(), def.getRightIToken().getEndOffset());\n\t\t else\n\t\t \treturn \"No help available\";\n \t}\n }\n return getSubstring(parseController, token);\n }\n"} {"input": " public void test_handle_implies_call_to_authenticationSchemeHandler_when_authentication_succeed() throws Exception {\n MockRequestAdapter request = new MockRequestAdapter(new MockRequest());\n MockResponseAdapter response = new MockResponseAdapter(new MockResponse());\n AuthenticationSchemeHandler authenticationSchemeHandler = mock(AuthenticationSchemeHandler.class);\n Collection> callbackClasses = Lists.newArrayList();\n callbackClasses.add(NameCallback.class);\n when(authenticationSchemeHandler.getCallbackTypes()).thenReturn(callbackClasses);\n Collection> authenticationSchemeHandlers = new ArrayList>();\n authenticationSchemeHandlers.add(authenticationSchemeHandler);\n MockCallbackHandler mockCallbackHandler = new MockCallbackHandler(new MockRequestAdapter(new MockRequest()), new MockResponseAdapter(new MockResponse()), authenticationSchemeHandlers\n );\n List callbackList = new ArrayList();\n NameCallback nameCallback = new NameCallback(DUMMY_PROMPT);\n callbackList.add(nameCallback);\n Callback[] callbacks = callbackList.toArray(new Callback[callbackList.size()]);\n mockCallbackHandler.handle(callbacks);\n Subject subject = new Subject();\n mockCallbackHandler.authenticationSucceed(subject);\n verify(authenticationSchemeHandler).authenticationSucceed(subject, request, response);\n }\n", "output": " public void test_handle_implies_call_to_authenticationSchemeHandler_when_authentication_succeed() throws Exception {\n MockRequestAdapter request = new MockRequestAdapter(new MockRequest());\n MockResponseAdapter response = new MockResponseAdapter(new MockResponse());\n AuthenticationSchemeHandler authenticationSchemeHandler = mock(AuthenticationSchemeHandler.class);\n Collection> callbackClasses = Lists.newArrayList();\n callbackClasses.add(NameCallback.class);\n when(authenticationSchemeHandler.getCallbackTypes()).thenReturn(callbackClasses);\n Collection> authenticationSchemeHandlers = new ArrayList>();\n authenticationSchemeHandlers.add(authenticationSchemeHandler);\n MockCallbackHandler mockCallbackHandler = new MockCallbackHandler(request, response, authenticationSchemeHandlers\n );\n List callbackList = new ArrayList();\n NameCallback nameCallback = new NameCallback(DUMMY_PROMPT);\n callbackList.add(nameCallback);\n Callback[] callbacks = callbackList.toArray(new Callback[callbackList.size()]);\n mockCallbackHandler.handle(callbacks);\n Subject subject = new Subject();\n mockCallbackHandler.authenticationSucceed(subject);\n verify(authenticationSchemeHandler).authenticationSucceed(subject, request, response);\n }\n"} {"input": "\tpublic void populate(Chunk chunk, Random random) {\n\t\tnoise.setSeed((int) chunk.getWorld().getSeed());\n\t\tint x = chunk.getX() * 16;\n\t\tint y = chunk.getY() * 16;\n\t\tint z = chunk.getZ() * 16;\n\t\tPoint pt = new Point(chunk.getWorld(), x + random.nextInt(16), y + random.nextInt(16), z + random.nextInt(16));\n\t\tfor (int dx = x; dx < x + 16; dx++) {\n\t\t\tfor (int dz = z; dz < z + 16; dz++) {\n\t\t\t\tfor (int dy = y; dy < y + 16; dy++) {\n\t\t\t\t\tif (Math.sqrt(Math.pow(dx - pt.getX(), 2) + Math.pow(dy - pt.getY(), 2) + Math.pow(dz - pt.getZ(), 2)) > 6) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (noise.GetValue(dx / 5.0 + 0.005, dy / 5.0 + 0.005, dz / 5.0 + 0.005) > 0 && chunk.getBlockMaterial(dx, dy, dz) == VanillaMaterials.STONE) {\n\t\t\t\t\t\tchunk.getBlock(dx, dy, dz).setMaterial(VanillaMaterials.AIR).update(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void populate(Chunk chunk, Random random) {\n\t\tnoise.setSeed((int) chunk.getWorld().getSeed());\n\t\tint x = chunk.getX() * 16;\n\t\tint y = chunk.getY() * 16;\n\t\tint z = chunk.getZ() * 16;\n\t\tPoint pt = new Point(chunk.getWorld(), x + random.nextInt(16), y + random.nextInt(16), z + random.nextInt(16));\n\t\tfor (int dx = x; dx < x + 16; dx++) {\n\t\t\tfor (int dz = z; dz < z + 16; dz++) {\n\t\t\t\tfor (int dy = y; dy < y + 16; dy++) {\n\t\t\t\t\tif (Math.sqrt(Math.pow(dx - pt.getX(), 2) + Math.pow(dy - pt.getY(), 2) + Math.pow(dz - pt.getZ(), 2)) > 6) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (noise.GetValue(dx / 5.0 + 0.005, dy / 5.0 + 0.005, dz / 5.0 + 0.005) > 0 && chunk.getBlockMaterial(dx, dy, dz) == VanillaMaterials.STONE) {\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public int getKeyIndexAndNearbyCodes(int x, int y, final int[] allCodes) {\n final List keys = getKeys();\n final int touchX = getTouchX(x);\n final int touchY = getTouchY(y);\n initializeNearbyKeys();\n int primaryIndex = NOT_A_KEY;\n for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) {\n final Key key = keys.get(index);\n final boolean isInside = mKeyboard.isInside(key, touchX, touchY);\n final int distance = key.squaredDistanceToEdge(touchX, touchY);\n if (isInside || (mProximityCorrectOn && distance < mProximityThresholdSquare)) {\n final int insertedPosition = sortNearbyKeys(index, distance);\n if (insertedPosition == 0 && isInside)\n primaryIndex = index;\n }\n }\n if (allCodes != null && allCodes.length > 0) {\n getNearbyKeyCodes(allCodes);\n if (DEBUG) {\n Log.d(TAG, \"x=\" + x + \" y=\" + y\n + \" primary=\"\n + (primaryIndex == NOT_A_KEY ? \"none\" : keys.get(primaryIndex).mCode)\n + \" codes=\" + Arrays.toString(allCodes));\n }\n }\n return primaryIndex;\n }\n", "output": " public int getKeyIndexAndNearbyCodes(int x, int y, final int[] allCodes) {\n final List keys = getKeys();\n final int touchX = getTouchX(x);\n final int touchY = getTouchY(y);\n initializeNearbyKeys();\n int primaryIndex = NOT_A_KEY;\n for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) {\n final Key key = keys.get(index);\n final boolean isInside = mKeyboard.isInside(key, touchX, touchY);\n final int distance = key.squaredDistanceToEdge(touchX, touchY);\n if (isInside || (mProximityCorrectOn && distance < mProximityThresholdSquare)) {\n final int insertedPosition = sortNearbyKeys(index, distance);\n if (insertedPosition == 0)\n primaryIndex = index;\n }\n }\n if (allCodes != null && allCodes.length > 0) {\n getNearbyKeyCodes(allCodes);\n if (DEBUG) {\n Log.d(TAG, \"x=\" + x + \" y=\" + y\n + \" primary=\"\n + (primaryIndex == NOT_A_KEY ? \"none\" : keys.get(primaryIndex).mCode)\n + \" codes=\" + Arrays.toString(allCodes));\n }\n }\n return primaryIndex;\n }\n"} {"input": "\tfinal public void run( final String args )\n\t{\n\t\tif ( IJ.versionLessThan( \"1.41n\" ) ) return;\n\t\tfinal ImagePlus imp = WindowManager.getCurrentImage();\n\t\tif ( imp == null ) { System.err.println( \"There are no images open\" ); return; }\n\t\tGenericDialog gd = new GenericDialog( \"Generate optic flow\" );\n\t\tgd.addNumericField( \"sigma :\", sigma, 2, 6, \"px\" );\n\t\tgd.addNumericField( \"maximal_distance :\", maxDistance, 0, 6, \"px\" );\n\t\tgd.addCheckbox( \"show_color_map\", showColors );\n\t\tgd.showDialog();\n\t\tif (gd.wasCanceled()) return;\n\t\tsigma = ( float )gd.getNextNumber();\n\t\tmaxDistance = ( byte )gd.getNextNumber();\n\t\tshowColors = gd.getNextBoolean();\n\t\tif ( showColors )\n\t\t{\n\t\t\tColorProcessor ipColor = new ColorProcessor( imp.getWidth(), imp.getHeight() );\n\t\t\tcolorCircle( ipColor );\n\t\t\tImagePlus impColor = new ImagePlus( \"Color\", ipColor );\n\t\t\timpColor.show();\n\t\t}\n\t\tImageStack seq = imp.getStack();\n\t\tImageStack seqOpticFlow = new ImageStack( seq.getWidth(), seq.getHeight() );\n\t\tFloatProcessor ip1;\n\t\tFloatProcessor ip2 = ( FloatProcessor )seq.getProcessor( 1 ).convertToFloat();\n\t\tImagePlus impOpticFlow = null;\n\t\tfor ( int i = 1; i < seq.getSize(); ++i )\n\t\t{\n\t\t\tip1 = ip2;\n\t\t\tip2 = ( FloatProcessor )seq.getProcessor( i + 1 ).convertToFloat();\n\t\t\tIJ.log( \"Processing slice \" + i );\n\t\t\tseqOpticFlow.addSlice( \"\" + i, createOpticFlow( ip1, ip2 ) );\n\t\t\tif ( seqOpticFlow.getSize() == 1 )\n\t\t\t{\n\t\t\t\timpOpticFlow = new ImagePlus( imp.getTitle() + \" optic flow\", seqOpticFlow );\n\t\t\t\timpOpticFlow.show();\n\t\t\t}\n\t\t\telse\n\t\t\t\timpOpticFlow.setStack( null, seqOpticFlow );\n\t\t\tIJ.showProgress( i, seq.getSize() );\n\t\t\timpOpticFlow.setSlice( i );\n\t\t\timp.setSlice( i + 1 );\n\t\t}\n\t}\n", "output": "\tfinal public void run( final String args )\n\t{\n\t\tif ( IJ.versionLessThan( \"1.41n\" ) ) return;\n\t\tfinal ImagePlus imp = WindowManager.getCurrentImage();\n\t\tif ( imp == null ) { IJ.error( \"There are no images open\" ); return; }\n\t\tGenericDialog gd = new GenericDialog( \"Generate optic flow\" );\n\t\tgd.addNumericField( \"sigma :\", sigma, 2, 6, \"px\" );\n\t\tgd.addNumericField( \"maximal_distance :\", maxDistance, 0, 6, \"px\" );\n\t\tgd.addCheckbox( \"show_color_map\", showColors );\n\t\tgd.showDialog();\n\t\tif (gd.wasCanceled()) return;\n\t\tsigma = ( float )gd.getNextNumber();\n\t\tmaxDistance = ( byte )gd.getNextNumber();\n\t\tshowColors = gd.getNextBoolean();\n\t\tif ( showColors )\n\t\t{\n\t\t\tColorProcessor ipColor = new ColorProcessor( imp.getWidth(), imp.getHeight() );\n\t\t\tcolorCircle( ipColor );\n\t\t\tImagePlus impColor = new ImagePlus( \"Color\", ipColor );\n\t\t\timpColor.show();\n\t\t}\n\t\tImageStack seq = imp.getStack();\n\t\tImageStack seqOpticFlow = new ImageStack( seq.getWidth(), seq.getHeight() );\n\t\tFloatProcessor ip1;\n\t\tFloatProcessor ip2 = ( FloatProcessor )seq.getProcessor( 1 ).convertToFloat();\n\t\tImagePlus impOpticFlow = null;\n\t\tfor ( int i = 1; i < seq.getSize(); ++i )\n\t\t{\n\t\t\tip1 = ip2;\n\t\t\tip2 = ( FloatProcessor )seq.getProcessor( i + 1 ).convertToFloat();\n\t\t\tIJ.log( \"Processing slice \" + i );\n\t\t\tseqOpticFlow.addSlice( \"\" + i, createOpticFlow( ip1, ip2 ) );\n\t\t\tif ( seqOpticFlow.getSize() == 1 )\n\t\t\t{\n\t\t\t\timpOpticFlow = new ImagePlus( imp.getTitle() + \" optic flow\", seqOpticFlow );\n\t\t\t\timpOpticFlow.show();\n\t\t\t}\n\t\t\telse\n\t\t\t\timpOpticFlow.setStack( null, seqOpticFlow );\n\t\t\tIJ.showProgress( i, seq.getSize() );\n\t\t\timpOpticFlow.setSlice( i );\n\t\t\timp.setSlice( i + 1 );\n\t\t}\n\t}\n"} {"input": "\tpublic void setContent(String content)\n\t{\n\t\tthis.content= content.replaceAll(\"[\\\\x00-\\\\x08\\\\x0b\\\\x0c\\\\x0e-\\\\x1f\\\\ud800-\\\\udfff\\\\uffff\\\\ufffe]\", \"\");\n\t\tif (this.content == null) this.content = \"\";\n\t}\n", "output": "\tpublic void setContent(String content)\n\t{\n\t\tif (this.content == null) this.content = \"\";\n\t\tthis.content= content.replaceAll(\"[\\\\x00-\\\\x08\\\\x0b\\\\x0c\\\\x0e-\\\\x1f\\\\ud800-\\\\udfff\\\\uffff\\\\ufffe]\", \"\");\n\t}\n"} {"input": " public void performAction() {\n\tFLyrVect lyr = null;\n\tMapControl mapCtrl = view.getMapControl();\n\ttry {\n\t mapCtrl.getMapContext().beginAtomicEvent();\n\t lyr = wizard.createLayer(mapCtrl.getProjection());\n\t} catch (Exception e) {\n\t NotificationManager.showMessageError(e.getLocalizedMessage(), e);\n\t return;\n\t}\n\tif (lyr == null) {\n\t return;\n\t}\n\tlyr.setVisible(true);\n\tmapCtrl.getMapContext().getLayers().addLayer(lyr);\n\tmapCtrl.getMapContext().endAtomicEvent();\n\tlyr.addLayerListener(CADExtension.getEditionManager());\n\tlyr.setActive(true);\n\ttry {\n\t lyr.setEditing(true);\n\t VectorialEditableAdapter vea = (VectorialEditableAdapter) lyr\n\t\t .getSource();\n\t vea.getRules().clear();\n\t if (vea.getShapeType() == FShape.POLYGON) {\n\t\tIRule rulePol = new RulePolygon();\n\t\tvea.getRules().add(rulePol);\n\t }\n\t StartEditing.startCommandsApplicable(view, lyr);\n\t vea.getCommandRecord().addCommandListener(mapCtrl);\n\t view.showConsole();\n\t oldAction.performAction();\n\t} catch (ReadDriverException e) {\n\t NotificationManager.addError(e);\n\t} catch (StartEditionLayerException e) {\n\t NotificationManager.addError(e);\n\t}\n }\n", "output": " public void performAction() {\n\tFLyrVect lyr = null;\n\tMapControl mapCtrl = view.getMapControl();\n\ttry {\n\t mapCtrl.getMapContext().beginAtomicEvent();\n\t lyr = wizard.createLayer(mapCtrl.getProjection());\n\t} catch (Exception e) {\n\t Throwable cause = e.getCause();\n\t if (cause != null) {\n\t\tNotificationManager.showMessageError(\n\t\t\tcause.getLocalizedMessage(), e);\n\t } else {\n\t\tNotificationManager\n\t\t\t.showMessageError(e.getLocalizedMessage(), e);\n\t }\n\t return;\n\t}\n\tif (lyr == null) {\n\t return;\n\t}\n\tlyr.setVisible(true);\n\tmapCtrl.getMapContext().getLayers().addLayer(lyr);\n\tmapCtrl.getMapContext().endAtomicEvent();\n\tlyr.addLayerListener(CADExtension.getEditionManager());\n\tlyr.setActive(true);\n\ttry {\n\t lyr.setEditing(true);\n\t VectorialEditableAdapter vea = (VectorialEditableAdapter) lyr\n\t\t .getSource();\n\t vea.getRules().clear();\n\t if (vea.getShapeType() == FShape.POLYGON) {\n\t\tIRule rulePol = new RulePolygon();\n\t\tvea.getRules().add(rulePol);\n\t }\n\t StartEditing.startCommandsApplicable(view, lyr);\n\t vea.getCommandRecord().addCommandListener(mapCtrl);\n\t view.showConsole();\n\t oldAction.performAction();\n\t} catch (ReadDriverException e) {\n\t NotificationManager.addError(e);\n\t} catch (StartEditionLayerException e) {\n\t NotificationManager.addError(e);\n\t}\n }\n"} {"input": " public void testBuildReader()\n throws Exception\n {\n PluginDescriptor pd = build( \"/plugin.xml\" );\n assertEquals( \"org.apache.maven.plugins\", pd.getGroupId() );\n assertEquals( \"maven-jar-plugin\", pd.getArtifactId() );\n assertEquals( \"2.3-SNAPSHOT\", pd.getVersion() );\n assertEquals( \"jar\", pd.getGoalPrefix() );\n assertEquals( \"plugin-description\", pd.getDescription() );\n assertEquals( false, pd.isIsolatedRealm() );\n assertEquals( true, pd.isInheritedByDefault() );\n assertEquals( 2, pd.getMojos().size() );\n assertEquals( 1, pd.getDependencies().size() );\n MojoDescriptor md = pd.getMojos().get( 0 );\n assertEquals( \"jar\", md.getGoal() );\n assertEquals( \"mojo-description\", md.getDescription() );\n assertEquals( \"runtime\", md.getDependencyResolutionRequired() );\n assertEquals( \"test\", md.getDependencyCollectionRequired() );\n assertEquals( false, md.isAggregator() );\n assertEquals( false, md.isDirectInvocationOnly() );\n assertEquals( true, md.isInheritedByDefault() );\n assertEquals( false, md.isOnlineRequired() );\n assertEquals( true, md.isProjectRequired() );\n assertEquals( false, md.isThreadSafe() );\n assertEquals( \"package\", md.getPhase() );\n assertEquals( \"org.apache.maven.plugin.jar.JarMojo\", md.getImplementation() );\n assertEquals( \"antrun\", md.getComponentConfigurator() );\n assertEquals( \"java\", md.getLanguage() );\n assertEquals( \"per-lookup\", md.getInstantiationStrategy() );\n assertEquals( \"some-goal\", md.getExecuteGoal() );\n assertEquals( \"generate-sources\", md.getExecutePhase() );\n assertEquals( \"cobertura\", md.getExecuteLifecycle() );\n assertEquals( \"2.2\", md.getSince() );\n assertEquals( \"deprecated-mojo\", md.getDeprecated() );\n assertEquals( 1, md.getRequirements().size() );\n assertEquals( 1, md.getParameters().size() );\n assertNotNull( md.getMojoConfiguration() );\n assertEquals( 1, md.getMojoConfiguration().getChildCount() );\n PlexusConfiguration pc = md.getMojoConfiguration().getChild( 0 );\n assertEquals( \"${jar.finalName}\", pc.getValue() );\n assertEquals( \"${project.build.finalName}\", pc.getAttribute( \"default-value\" ) );\n assertEquals( \"java.lang.String\", pc.getAttribute( \"implementation\" ) );\n Parameter mp = md.getParameters().get( 0 );\n assertEquals( \"finalName\", mp.getName() );\n assertEquals( \"jarName\", mp.getAlias() );\n assertEquals( \"java.lang.String\", mp.getType() );\n assertEquals( true, mp.isEditable() );\n assertEquals( false, mp.isRequired() );\n assertEquals( \"parameter-description\", mp.getDescription() );\n assertEquals( \"deprecated-parameter\", mp.getDeprecated() );\n assertEquals( \"${jar.finalName}\", mp.getExpression() );\n assertEquals( \"${project.build.finalName}\", mp.getDefaultValue() );\n ComponentRequirement cr = md.getRequirements().get( 0 );\n assertEquals( \"org.codehaus.plexus.archiver.Archiver\", cr.getRole() );\n assertEquals( \"jar\", cr.getRoleHint() );\n assertEquals( \"jarArchiver\", cr.getFieldName() );\n ComponentDependency cd = pd.getDependencies().get( 0 );\n assertEquals( \"org.apache.maven\", cd.getGroupId() );\n assertEquals( \"maven-plugin-api\", cd.getArtifactId() );\n assertEquals( \"2.0.6\", cd.getVersion() );\n assertEquals( \"jar\", cd.getType() );\n md = pd.getMojos().get( 1 );\n assertEquals( \"war\", md.getGoal() );\n assertEquals( null, md.getDependencyResolutionRequired() );\n assertEquals( null, md.getDependencyCollectionRequired() );\n assertEquals( true, md.isThreadSafe() );\n }\n", "output": " public void testBuildReader()\n throws Exception\n {\n PluginDescriptor pd = build( \"/plugin.xml\" );\n assertEquals( \"org.apache.maven.plugins\", pd.getGroupId() );\n assertEquals( \"maven-jar-plugin\", pd.getArtifactId() );\n assertEquals( \"2.3-SNAPSHOT\", pd.getVersion() );\n assertEquals( \"jar\", pd.getGoalPrefix() );\n assertEquals( \"plugin-description\", pd.getDescription() );\n assertEquals( false, pd.isIsolatedRealm() );\n assertEquals( true, pd.isInheritedByDefault() );\n assertEquals( 2, pd.getMojos().size() );\n assertEquals( 1, pd.getDependencies().size() );\n MojoDescriptor md = pd.getMojos().get( 0 );\n assertEquals( \"jar\", md.getGoal() );\n assertEquals( \"mojo-description\", md.getDescription() );\n assertEquals( \"runtime\", md.getDependencyResolutionRequired() );\n assertEquals( \"test\", md.getDependencyCollectionRequired() );\n assertEquals( false, md.isAggregator() );\n assertEquals( false, md.isDirectInvocationOnly() );\n assertEquals( true, md.isInheritedByDefault() );\n assertEquals( false, md.isOnlineRequired() );\n assertEquals( true, md.isProjectRequired() );\n assertEquals( false, md.isThreadSafe() );\n assertEquals( \"package\", md.getPhase() );\n assertEquals( \"org.apache.maven.plugin.jar.JarMojo\", md.getImplementation() );\n assertEquals( \"antrun\", md.getComponentConfigurator() );\n assertEquals( \"java\", md.getLanguage() );\n assertEquals( \"per-lookup\", md.getInstantiationStrategy() );\n assertEquals( \"some-goal\", md.getExecuteGoal() );\n assertEquals( \"generate-sources\", md.getExecutePhase() );\n assertEquals( \"cobertura\", md.getExecuteLifecycle() );\n assertEquals( \"2.2\", md.getSince() );\n assertEquals( \"deprecated-mojo\", md.getDeprecated() );\n assertEquals( 1, md.getRequirements().size() );\n assertEquals( 1, md.getParameters().size() );\n assertNotNull( md.getMojoConfiguration() );\n assertEquals( 1, md.getMojoConfiguration().getChildCount() );\n PlexusConfiguration pc = md.getMojoConfiguration().getChild( 0 );\n assertEquals( \"${jar.finalName}\", pc.getValue() );\n assertEquals( \"${project.build.finalName}\", pc.getAttribute( \"default-value\" ) );\n Parameter mp = md.getParameters().get( 0 );\n assertEquals( \"finalName\", mp.getName() );\n assertEquals( \"jarName\", mp.getAlias() );\n assertEquals( \"java.lang.String\", mp.getType() );\n assertEquals( \"java.lang.String\", mp.getImplementation() );\n assertEquals( true, mp.isEditable() );\n assertEquals( false, mp.isRequired() );\n assertEquals( \"parameter-description\", mp.getDescription() );\n assertEquals( \"deprecated-parameter\", mp.getDeprecated() );\n assertEquals( \"${jar.finalName}\", mp.getExpression() );\n assertEquals( \"${project.build.finalName}\", mp.getDefaultValue() );\n ComponentRequirement cr = md.getRequirements().get( 0 );\n assertEquals( \"org.codehaus.plexus.archiver.Archiver\", cr.getRole() );\n assertEquals( \"jar\", cr.getRoleHint() );\n assertEquals( \"jarArchiver\", cr.getFieldName() );\n ComponentDependency cd = pd.getDependencies().get( 0 );\n assertEquals( \"org.apache.maven\", cd.getGroupId() );\n assertEquals( \"maven-plugin-api\", cd.getArtifactId() );\n assertEquals( \"2.0.6\", cd.getVersion() );\n assertEquals( \"jar\", cd.getType() );\n md = pd.getMojos().get( 1 );\n assertEquals( \"war\", md.getGoal() );\n assertEquals( null, md.getDependencyResolutionRequired() );\n assertEquals( null, md.getDependencyCollectionRequired() );\n assertEquals( true, md.isThreadSafe() );\n }\n"} {"input": "\tprivate boolean insertIntoTable(String className, Product product) {\n\t\ttry {\n\t\t\tint originalCount = getRecordCount(className);\n\t\t\tClass c = product.getClass();\n\t\t\tField[] fields = c.getFields();\n\t\t\tfields = sortFields(fields);\n\t\t\tString sql = \"INSERT INTO \" + className + \"(\";\n\t\t\tfor (int i = 0; i < fields.length; i++) {\n\t\t\t\tsql += fields[i].getName();\n\t\t\t\tif (i < fields.length-1) {\n\t\t\t\t\tsql += \",\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tsql += \") values (\";\n\t\t\tfor (int i = 0; i < fields.length; i++) {\n\t\t\t\tsql += \"?\";\n\t\t\t\tif (i < fields.length-1) {\n\t\t\t\t\tsql += \",\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tsql += \");\";\n\t\t\tPreparedStatement preparedStatement = conn.prepareStatement(sql);\n\t\t\tpreparedStatement.setInt(1, 1);\n\t\t\tfor (int i = 0; i < fields.length; i++) {\t\n\t\t\t\tObject obj = fields[i].get(product);\n\t\t\t\tString data = \"\";\n\t\t\t\tif (obj != null) {\n\t\t\t\t\tdata = fields[i].get(product).toString();\n\t\t\t\t}\n\t\t\t\tsetPreparedStatementValues(preparedStatement, fields[i], i+1, product);\t\n\t\t\t}\n\t\t\tpreparedStatement.addBatch();\n\t\t\tpreparedStatement.executeBatch();\n\t\t\tif (getRecordCount(className) == originalCount+1) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tSystem.err.println(\"Error on database insert\");\n\t\t\te.printStackTrace();\n\t\t\treturn false;\n\t\t}\n\t}\n", "output": "\tprivate boolean insertIntoTable(String className, Product product) {\n\t\ttry {\n\t\t\tint originalCount = getRecordCount(className);\n\t\t\tClass c = product.getClass();\n\t\t\tField[] fields = c.getFields();\n\t\t\tfields = sortFields(fields);\n\t\t\tString sql = \"INSERT INTO \" + className + \"(\";\n\t\t\tfor (int i = 0; i < fields.length; i++) {\n\t\t\t\tsql += fields[i].getName();\n\t\t\t\tif (i < fields.length-1) {\n\t\t\t\t\tsql += \",\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tsql += \") values (\";\n\t\t\tfor (int i = 0; i < fields.length; i++) {\n\t\t\t\tsql += \"?\";\n\t\t\t\tif (i < fields.length-1) {\n\t\t\t\t\tsql += \",\";\n\t\t\t\t}\n\t\t\t}\n\t\t\tsql += \");\";\n\t\t\tPreparedStatement preparedStatement = conn.prepareStatement(sql);\n\t\t\tpreparedStatement.setInt(1, 1);\n\t\t\tfor (int i = 0; i < fields.length; i++) {\t\n\t\t\t\tObject obj = fields[i].get(product);\n\t\t\t\tString data = \"\";\n\t\t\t\tif (obj != null) {\n\t\t\t\t\tdata = fields[i].get(product).toString();\n\t\t\t\t\tsetPreparedStatementValues(preparedStatement, fields[i], i+1, product);\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tpreparedStatement.addBatch();\n\t\t\tpreparedStatement.executeBatch();\n\t\t\tif (getRecordCount(className) == originalCount+1) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tSystem.err.println(\"Error on database insert\");\n\t\t\te.printStackTrace();\n\t\t\treturn false;\n\t\t}\n\t}\n"} {"input": "\tprivate MoCMOS()\n\t{\n\t\tsuper(\"mocmos\");\n\t\tsetTechShortName(\"MOSIS CMOS\");\n\t\tsetTechDesc(\"MOSIS CMOS\");\n\t\tsetFactoryScale(200, true);\t\t\t\n\t\tsetNoNegatedArcs();\n\t\tsetStaticTechnology();\n\t\tsetFactoryTransparentLayers(new Color []\n\t\t{\n\t\t\tnew Color( 96,209,255), \n\t\t\tnew Color(255,155,192), \n\t\t\tnew Color(107,226, 96), \n\t\t\tnew Color(224, 95,255), \n\t\t\tnew Color(247,251, 20) \n\t\t});\n setFactoryResolution(0.01); \n foundries.add(new Foundry(Foundry.MOSIS_FOUNDRY, DRCTemplate.MOSIS));\n foundries.add(new Foundry(\"TSMC\", DRCTemplate.TSMC));\n setFactorySelecedFound(Foundry.MOSIS_FOUNDRY); \n Layer[] metalLayers = new Layer[6]; \n\t\tmetalLayers[0] = Layer.newInstance(this, \"Metal-1\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_1, 96,209,255, 0.8,true,\n\t\t\tnew int[] { 0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000}));\n\t\tmetalLayers[1] = Layer.newInstance(this, \"Metal-2\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_4, 224,95,255, 0.7,true,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tmetalLayers[2] = Layer.newInstance(this, \"Metal-3\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_5, 247,251,20, 0.6,true,\n\t\t\tnew int[] { 0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000}));\n\t\tmetalLayers[3] = Layer.newInstance(this, \"Metal-4\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 150,150,255, 0.5,true,\n\t\t\tnew int[] { 0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000}));\n\t\tmetalLayers[4] = Layer.newInstance(this, \"Metal-5\",\n\t\t\tnew EGraphics(EGraphics.OUTLINEPAT, EGraphics.OUTLINEPAT, 0, 255,190,6, 0.4,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444}));\n\t\tmetalLayers[5] = Layer.newInstance(this, \"Metal-6\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 0,255,255, 0.3,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111}));\n\t\tpoly1_lay = Layer.newInstance(this, \"Polysilicon-1\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 255,155,192, 0.5,true,\n\t\t\tnew int[] { 0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555}));\n\t\tLayer poly2_lay = Layer.newInstance(this, \"Polysilicon-2\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,190,6, 1.0,true,\n\t\t\tnew int[] { 0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888}));\n Layer[] activeLayers = new Layer[2];\n\t\tactiveLayers[P_TYPE] = Layer.newInstance(this, \"P-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 0.5,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tactiveLayers[N_TYPE] = Layer.newInstance(this, \"N-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 0.5,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n Layer[] selectLayers = new Layer[2];\n\t\tselectLayers[P_TYPE] = Layer.newInstance(this, \"P-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 0.2,false,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tselectLayers[N_TYPE] = Layer.newInstance(this, \"N-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 0.2,false,\n\t\t\tnew int[] { 0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000}));\n Layer[] wellLayers = new Layer[2];\n\t\twellLayers[P_TYPE] = Layer.newInstance(this, \"P-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 0.2,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404}));\n\t\twellLayers[N_TYPE] = Layer.newInstance(this, \"N-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 0.2,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer polyCutLayer = Layer.newInstance(this, \"Poly-Cut\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 100,100,100, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer activeCut_lay = Layer.newInstance(this, \"Active-Cut\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 100,100,100, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via1_lay = Layer.newInstance(this, \"Via1\", \n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via2_lay = Layer.newInstance(this, \"Via2\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via3_lay = Layer.newInstance(this, \"Via3\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via4_lay = Layer.newInstance(this, \"Via4\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via5_lay = Layer.newInstance(this, \"Via5\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer passivation_lay = Layer.newInstance(this, \"Passivation\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 100,100,100, 1.0,true,\n\t\t\tnew int[] { 0x1C1C, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x3636, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x1C1C, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1C1C, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x3636, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x1C1C, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000}));\n\t\ttransistorPoly_lay = Layer.newInstance(this, \"Transistor-Poly\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 255,155,192, 0.5,true,\n\t\t\tnew int[] { 0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555}));\n\t\tLayer polyCap_lay = Layer.newInstance(this, \"Poly-Cap\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 0,0,0, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer pActiveWell_lay = Layer.newInstance(this, \"P-Active-Well\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 1.0,false,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tLayer silicideBlock_lay = Layer.newInstance(this, \"Silicide-Block\",\n new EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 192,255,255, 0.5,true,\n new int[] { 0x1010, \n 0x2828, \n 0x4444, \n 0x8282, \n 0x0101, \n 0x0000, \n 0x0000, \n 0x0000, \n 0x1010, \n 0x2828, \n 0x4444, \n 0x8282, \n 0x0101, \n 0x0000, \n 0x0000, \n 0x0000}));\n\t\tLayer thickActive_lay = Layer.newInstance(this, \"Thick-Active\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 0,0,0, 1.0,false,\n\t\t\tnew int[] { 0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020}));\n\t\tLayer pseudoMetal1_lay = Layer.newInstance(this, \"Pseudo-Metal-1\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_1, 96,209,255, 0.8,true,\n\t\t\tnew int[] { 0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer pseudoMetal2_lay = Layer.newInstance(this, \"Pseudo-Metal-2\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_4, 224,95,255, 0.7,true,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tLayer pseudoMetal3_lay = Layer.newInstance(this, \"Pseudo-Metal-3\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_5, 247,251,20, 0.6,true,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tLayer pseudoMetal4_lay = Layer.newInstance(this, \"Pseudo-Metal-4\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 150,150,255, 0.5,true,\n\t\t\tnew int[] { 0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer pseudoMetal5_lay = Layer.newInstance(this, \"Pseudo-Metal-5\",\n\t\t\tnew EGraphics(EGraphics.OUTLINEPAT, EGraphics.OUTLINEPAT, 0, 255,190,6, 0.4,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444}));\n\t\tLayer pseudoMetal6_lay = Layer.newInstance(this, \"Pseudo-Metal-6\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 0,255,255, 0.3,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111}));\n\t\tLayer pseudoPoly1_lay = Layer.newInstance(this, \"Pseudo-Polysilicon\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 255,155,192, 1.0,true,\n\t\t\tnew int[] { 0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555}));\n\t\tLayer pseudoPoly2_lay = Layer.newInstance(this, \"Pseudo-Electrode\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,190,6, 1.0,true,\n\t\t\tnew int[] { 0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888}));\n\t\tLayer pseudoPActive_lay = Layer.newInstance(this, \"Pseudo-P-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 1.0,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tLayer pseudoNActive_lay = Layer.newInstance(this, \"Pseudo-N-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 1.0,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tLayer pseudoPSelect_lay = Layer.newInstance(this, \"Pseudo-P-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 1.0,false,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tLayer pseudoNSelect_lay = Layer.newInstance(this, \"Pseudo-N-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 1.0,false,\n\t\t\tnew int[] { 0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer pseudoPWell_lay = Layer.newInstance(this, \"Pseudo-P-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 1.0,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404}));\n\t\tLayer pseudoNWell_lay = Layer.newInstance(this, \"Pseudo-N-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 1.0,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer padFrame_lay = Layer.newInstance(this, \"Pad-Frame\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, 0, 255,0,0, 1.0,false,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tmetalLayers[0].setFunction(Layer.Function.METAL1);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[1].setFunction(Layer.Function.METAL2);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[2].setFunction(Layer.Function.METAL3);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[3].setFunction(Layer.Function.METAL4);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[4].setFunction(Layer.Function.METAL5);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[5].setFunction(Layer.Function.METAL6);\t\t\t\t\t\t\t\t\t\n\t\tpoly1_lay.setFunction(Layer.Function.POLY1);\t\t\t\t\t\t\t\t\t\n\t\tpoly2_lay.setFunction(Layer.Function.POLY2);\t\t\t\t\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFunction(Layer.Function.DIFFP);\t\t\t\t\t\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFunction(Layer.Function.DIFFN);\t\t\t\t\t\t\t\t\t\n\t\tselectLayers[P_TYPE].setFunction(Layer.Function.IMPLANTP);\t\t\t\t\t\t\t\t\n\t\tselectLayers[N_TYPE].setFunction(Layer.Function.IMPLANTN);\t\t\t\t\t\t\t\t\n\t\twellLayers[P_TYPE].setFunction(Layer.Function.WELLP);\t\t\t\t\t\t\t\t\t\n\t\twellLayers[N_TYPE].setFunction(Layer.Function.WELLN);\t\t\t\t\t\t\t\t\t\n\t\tpolyCutLayer.setFunction(Layer.Function.CONTACT1, Layer.Function.CONPOLY);\t\t\n\t\tactiveCut_lay.setFunction(Layer.Function.CONTACT1, Layer.Function.CONDIFF);\t\t\n\t\tvia1_lay.setFunction(Layer.Function.CONTACT2, Layer.Function.CONMETAL);\t\t\t\n\t\tvia2_lay.setFunction(Layer.Function.CONTACT3, Layer.Function.CONMETAL);\t\t\t\n\t\tvia3_lay.setFunction(Layer.Function.CONTACT4, Layer.Function.CONMETAL);\t\t\t\n\t\tvia4_lay.setFunction(Layer.Function.CONTACT5, Layer.Function.CONMETAL);\t\t\t\n\t\tvia5_lay.setFunction(Layer.Function.CONTACT6, Layer.Function.CONMETAL);\t\t\t\n\t\tpassivation_lay.setFunction(Layer.Function.OVERGLASS);\t\t\t\t\t\t\t\n\t\ttransistorPoly_lay.setFunction(Layer.Function.GATE);\t\t\t\t\t\t\t\n\t\tpolyCap_lay.setFunction(Layer.Function.CAP);\t\t\t\t\t\t\t\t\t\n\t\tpActiveWell_lay.setFunction(Layer.Function.DIFFP);\t\t\t\t\t\t\t\t\n\t\tsilicideBlock_lay.setFunction(Layer.Function.ART);\t\t\t\t\t\t\t\t\n\t\tthickActive_lay.setFunction(Layer.Function.DIFF, Layer.Function.THICK);\t\t\t\n\t\tpseudoMetal1_lay.setFunction(Layer.Function.METAL1, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal2_lay.setFunction(Layer.Function.METAL2, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal3_lay.setFunction(Layer.Function.METAL3, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal4_lay.setFunction(Layer.Function.METAL4, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal5_lay.setFunction(Layer.Function.METAL5, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal6_lay.setFunction(Layer.Function.METAL6, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPoly1_lay.setFunction(Layer.Function.POLY1, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPoly2_lay.setFunction(Layer.Function.POLY2, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPActive_lay.setFunction(Layer.Function.DIFFP, Layer.Function.PSEUDO);\t\t\n\t\tpseudoNActive_lay.setFunction(Layer.Function.DIFFN, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPSelect_lay.setFunction(Layer.Function.IMPLANTP, Layer.Function.PSEUDO);\t\n\t\tpseudoNSelect_lay.setFunction(Layer.Function.IMPLANTN, Layer.Function.PSEUDO);\t\n\t\tpseudoPWell_lay.setFunction(Layer.Function.WELLP, Layer.Function.PSEUDO);\t\t\n\t\tpseudoNWell_lay.setFunction(Layer.Function.WELLN, Layer.Function.PSEUDO);\t\t\n\t\tpadFrame_lay.setFunction(Layer.Function.ART);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[0].setFactoryCIFLayer(\"CMF\");\t\t\t\t\n\t\tmetalLayers[1].setFactoryCIFLayer(\"CMS\");\t\t\t\t\n\t\tmetalLayers[2].setFactoryCIFLayer(\"CMT\");\t\t\t\t\n\t\tmetalLayers[3].setFactoryCIFLayer(\"CMQ\");\t\t\t\t\n\t\tmetalLayers[4].setFactoryCIFLayer(\"CMP\");\t\t\t\t\n\t\tmetalLayers[5].setFactoryCIFLayer(\"CM6\");\t\t\t\t\n\t\tpoly1_lay.setFactoryCIFLayer(\"CPG\");\t\t\t\t\n\t\tpoly2_lay.setFactoryCIFLayer(\"CEL\");\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFactoryCIFLayer(\"CAA\");\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactoryCIFLayer(\"CAA\");\t\t\t\t\n\t\tselectLayers[P_TYPE].setFactoryCIFLayer(\"CSP\");\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactoryCIFLayer(\"CSN\");\t\t\t\t\n\t\twellLayers[P_TYPE].setFactoryCIFLayer(\"CWP\");\t\t\t\t\n\t\twellLayers[N_TYPE].setFactoryCIFLayer(\"CWN\");\t\t\t\t\n\t\tpolyCutLayer.setFactoryCIFLayer(\"CCC\");\t\t\t\t\n\t\tactiveCut_lay.setFactoryCIFLayer(\"CCC\");\t\t\t\n\t\tvia1_lay.setFactoryCIFLayer(\"CVA\");\t\t\t\t\t\n\t\tvia2_lay.setFactoryCIFLayer(\"CVS\");\t\t\t\t\t\n\t\tvia3_lay.setFactoryCIFLayer(\"CVT\");\t\t\t\t\t\n\t\tvia4_lay.setFactoryCIFLayer(\"CVQ\");\t\t\t\t\t\n\t\tvia5_lay.setFactoryCIFLayer(\"CV5\");\t\t\t\t\t\n\t\tpassivation_lay.setFactoryCIFLayer(\"COG\");\t\t\t\n\t\ttransistorPoly_lay.setFactoryCIFLayer(\"CPG\");\t\t\n\t\tpolyCap_lay.setFactoryCIFLayer(\"CPC\");\t\t\t\t\n\t\tpActiveWell_lay.setFactoryCIFLayer(\"CAA\");\t\t\t\n\t\tsilicideBlock_lay.setFactoryCIFLayer(\"CSB\");\t\t\n\t\tthickActive_lay.setFactoryCIFLayer(\"CTA\");\t\t\t\n\t\tpseudoMetal1_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal2_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal3_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal4_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal5_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal6_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoPoly1_lay.setFactoryCIFLayer(\"\");\t\t\t\t\n\t\tpseudoPoly2_lay.setFactoryCIFLayer(\"\");\t\t\t\t\n\t\tpseudoPActive_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoNActive_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoPSelect_lay.setFactoryCIFLayer(\"CSP\");\t\t\n\t\tpseudoNSelect_lay.setFactoryCIFLayer(\"CSN\");\t\t\n\t\tpseudoPWell_lay.setFactoryCIFLayer(\"CWP\");\t\t\t\n\t\tpseudoNWell_lay.setFactoryCIFLayer(\"CWN\");\t\t\t\n\t\tpadFrame_lay.setFactoryCIFLayer(\"XP\");\t\t\t\t\n\t\tmetalLayers[0].setFactoryGDSLayer(\"49, 80p, 80t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[0].setFactoryGDSLayer(\"16\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[1].setFactoryGDSLayer(\"51, 82p, 82t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[1].setFactoryGDSLayer(\"18\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[2].setFactoryGDSLayer(\"62, 93p, 93t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[2].setFactoryGDSLayer(\"28\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[3].setFactoryGDSLayer(\"31, 63p, 63t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[3].setFactoryGDSLayer(\"31\", Foundry.TSMC_FOUNDRY);\n\t\tmetalLayers[4].setFactoryGDSLayer(\"33, 64p, 64t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[4].setFactoryGDSLayer(\"33\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[5].setFactoryGDSLayer(\"37, 68p, 68t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[5].setFactoryGDSLayer(\"38\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tpoly1_lay.setFactoryGDSLayer(\"46\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n poly1_lay.setFactoryGDSLayer(\"13\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\ttransistorPoly_lay.setFactoryGDSLayer(\"46\", Foundry.MOSIS_FOUNDRY);\t\t\n transistorPoly_lay.setFactoryGDSLayer(\"13\", Foundry.TSMC_FOUNDRY);\t\t\n\t\tpoly2_lay.setFactoryGDSLayer(\"56\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFactoryGDSLayer(\"43\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n activeLayers[P_TYPE].setFactoryGDSLayer(\"3\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactoryGDSLayer(\"43\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n activeLayers[N_TYPE].setFactoryGDSLayer(\"3\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tpActiveWell_lay.setFactoryGDSLayer(\"43\", Foundry.MOSIS_FOUNDRY);\t\t\t\n pActiveWell_lay.setFactoryGDSLayer(\"3\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tselectLayers[P_TYPE].setFactoryGDSLayer(\"44\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n selectLayers[P_TYPE].setFactoryGDSLayer(\"7\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactoryGDSLayer(\"45\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n selectLayers[N_TYPE].setFactoryGDSLayer(\"8\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\twellLayers[P_TYPE].setFactoryGDSLayer(\"41\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n wellLayers[P_TYPE].setFactoryGDSLayer(\"41\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\twellLayers[N_TYPE].setFactoryGDSLayer(\"42\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n wellLayers[N_TYPE].setFactoryGDSLayer(\"2\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tpolyCutLayer.setFactoryGDSLayer(\"25\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n polyCutLayer.setFactoryGDSLayer(\"15\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tactiveCut_lay.setFactoryGDSLayer(\"25\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tactiveCut_lay.setFactoryGDSLayer(\"15\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tvia1_lay.setFactoryGDSLayer(\"50\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via1_lay.setFactoryGDSLayer(\"17\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia2_lay.setFactoryGDSLayer(\"61\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via2_lay.setFactoryGDSLayer(\"27\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia3_lay.setFactoryGDSLayer(\"30\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via3_lay.setFactoryGDSLayer(\"29\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia4_lay.setFactoryGDSLayer(\"32\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via4_lay.setFactoryGDSLayer(\"32\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia5_lay.setFactoryGDSLayer(\"36\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via5_lay.setFactoryGDSLayer(\"39\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tpassivation_lay.setFactoryGDSLayer(\"52\", Foundry.MOSIS_FOUNDRY);\t\t\t\n passivation_lay.setFactoryGDSLayer(\"19\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tpolyCap_lay.setFactoryGDSLayer(\"28\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n polyCap_lay.setFactoryGDSLayer(\"28\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tsilicideBlock_lay.setFactoryGDSLayer(\"29\", Foundry.MOSIS_FOUNDRY);\t\t\t\n silicideBlock_lay.setFactoryGDSLayer(\"34\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tthickActive_lay.setFactoryGDSLayer(\"60\", Foundry.MOSIS_FOUNDRY);\t\t\t\n thickActive_lay.setFactoryGDSLayer(\"4\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tpseudoMetal1_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal2_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal3_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal4_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal5_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal6_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoPoly1_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpseudoPoly2_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpseudoPActive_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoNActive_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoPSelect_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoNSelect_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoPWell_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpseudoNWell_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpadFrame_lay.setFactoryGDSLayer(\"26\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n padFrame_lay.setFactoryGDSLayer(\"26\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[0].setFactorySkillLayer(\"metal1\");\t\t\t\n\t\tmetalLayers[1].setFactorySkillLayer(\"metal2\");\t\t\t\n\t\tmetalLayers[2].setFactorySkillLayer(\"metal3\");\t\t\t\n\t\tmetalLayers[3].setFactorySkillLayer(\"metal4\");\t\t\t\n\t\tmetalLayers[4].setFactorySkillLayer(\"metal5\");\t\t\t\n\t\tmetalLayers[5].setFactorySkillLayer(\"metal6\");\t\t\t\n\t\tpoly1_lay.setFactorySkillLayer(\"poly\");\t\t\t\t\n\t\tpoly2_lay.setFactorySkillLayer(\"\");\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFactorySkillLayer(\"aa\");\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactorySkillLayer(\"aa\");\t\t\t\t\n\t\tselectLayers[P_TYPE].setFactorySkillLayer(\"pplus\");\t\t\t\n\t\tselectLayers[N_TYPE].setFactorySkillLayer(\"nplus\");\t\t\t\n\t\twellLayers[P_TYPE].setFactorySkillLayer(\"pwell\");\t\t\t\n\t\twellLayers[N_TYPE].setFactorySkillLayer(\"nwell\");\t\t\t\n\t\tpolyCutLayer.setFactorySkillLayer(\"pcont\");\t\t\t\n\t\tactiveCut_lay.setFactorySkillLayer(\"acont\");\t\t\n\t\tvia1_lay.setFactorySkillLayer(\"via\");\t\t\t\t\n\t\tvia2_lay.setFactorySkillLayer(\"via2\");\t\t\t\t\n\t\tvia3_lay.setFactorySkillLayer(\"via3\");\t\t\t\t\n\t\tvia4_lay.setFactorySkillLayer(\"via4\");\t\t\t\t\n\t\tvia5_lay.setFactorySkillLayer(\"via5\");\t\t\t\t\n\t\tpassivation_lay.setFactorySkillLayer(\"glasscut\");\t\n\t\ttransistorPoly_lay.setFactorySkillLayer(\"poly\");\t\n\t\tpolyCap_lay.setFactorySkillLayer(\"\");\t\t\t\t\n\t\tpActiveWell_lay.setFactorySkillLayer(\"aa\");\t\t\t\n\t\tsilicideBlock_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tthickActive_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal1_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal2_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal3_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal4_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal5_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal6_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPoly1_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPoly2_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPActive_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoNActive_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPSelect_lay.setFactorySkillLayer(\"pplus\");\t\n\t\tpseudoNSelect_lay.setFactorySkillLayer(\"nplus\");\t\n\t\tpseudoPWell_lay.setFactorySkillLayer(\"pwell\");\t\t\n\t\tpseudoNWell_lay.setFactorySkillLayer(\"nwell\");\t\t\n\t\tpadFrame_lay.setFactorySkillLayer(\"\");\t\t\t\t\n\t\tdouble BULK_LAYER = 10;\n\t\tdouble DIFF_LAYER = 1; \n\t\tdouble ILD_LAYER = 3.5; \n\t\tdouble IMD_LAYER = 5.65; \n\t\tdouble METAL_LAYER = 2.65; \n\t\tactiveLayers[P_TYPE].setFactory3DInfo(0.85, BULK_LAYER + 2*DIFF_LAYER);\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactory3DInfo(0.8, BULK_LAYER + 2*DIFF_LAYER);\t\t\t\t\n\t\tselectLayers[P_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER + DIFF_LAYER);\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER + DIFF_LAYER);\t\t\t\t\n\t\twellLayers[P_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER);\t\t\t\t\t\n\t\twellLayers[N_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER);\t\t\t\t\t\n pActiveWell_lay.setFactory3DInfo(0.85, BULK_LAYER + 2*DIFF_LAYER);\t\t\t\n thickActive_lay.setFactory3DInfo(0.5, BULK_LAYER + 0.5);\t\t\t\n\t\tmetalLayers[0].setFactory3DInfo(METAL_LAYER, ILD_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\t\t\n\t\tmetalLayers[1].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[0].getDistance());\t\t\t\t\t\n\t\tvia1_lay.setFactory3DInfo(metalLayers[1].getDistance()-metalLayers[0].getDepth(), metalLayers[0].getDepth());\t\t\t\t\t\n\t\tmetalLayers[2].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[1].getDistance());\t\t\t\t\t\n\t\tvia2_lay.setFactory3DInfo(metalLayers[2].getDistance()-metalLayers[1].getDepth(), metalLayers[1].getDepth());\t\t\t\t\t\n\t\tmetalLayers[3].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[2].getDistance());\t\t\t\t\t\n via3_lay.setFactory3DInfo(metalLayers[3].getDistance()-metalLayers[2].getDepth(), metalLayers[2].getDepth());\t\t\t\t\t\n\t\tmetalLayers[4].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[3].getDistance());\t\t\t\t\t\n\t\tvia4_lay.setFactory3DInfo(metalLayers[4].getDistance()-metalLayers[3].getDepth(), metalLayers[3].getDepth());\t\t\t\t\t\n\t\tmetalLayers[5].setFactory3DInfo(4.95, IMD_LAYER + metalLayers[4].getDistance());\t\t\t\t\t\n via5_lay.setFactory3DInfo(metalLayers[5].getDistance()-metalLayers[4].getDepth(), metalLayers[4].getDepth());\t\t\t\t\t\n\t\tdouble PASS_LAYER = 5; \n\t\tdouble PO_LAYER = 1; \n\t\tdouble FOX_LAYER = 1.75; \n\t\tdouble TOX_LAYER = 0; \n\t\tpseudoMetal1_lay.setFactory3DInfo(0, metalLayers[0].getDistance());\t\t\t\n\t\tpseudoMetal2_lay.setFactory3DInfo(0, metalLayers[1].getDistance());\t\t\t\n\t\tpseudoMetal3_lay.setFactory3DInfo(0, metalLayers[2].getDistance());\t\t\t\n\t\tpseudoMetal4_lay.setFactory3DInfo(0, metalLayers[3].getDistance());\t\t\t\n\t\tpseudoMetal5_lay.setFactory3DInfo(0, metalLayers[4].getDistance());\t\t\t\n\t\tpseudoMetal6_lay.setFactory3DInfo(0, metalLayers[5].getDistance());\t\t\t\n\t\tpoly1_lay.setFactory3DInfo(PO_LAYER, FOX_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\t\t\n\t\ttransistorPoly_lay.setFactory3DInfo(PO_LAYER, TOX_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\n poly2_lay.setFactory3DInfo(PO_LAYER, transistorPoly_lay.getDepth());\t\t\t\t\t\n\t\tpolyCap_lay.setFactory3DInfo(PO_LAYER, FOX_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\t\n\t\tpolyCutLayer.setFactory3DInfo(metalLayers[0].getDistance()-poly1_lay.getDepth(), poly1_lay.getDepth());\t\t\t\t\n\t\tactiveCut_lay.setFactory3DInfo(metalLayers[0].getDistance()-activeLayers[N_TYPE].getDepth(), activeLayers[N_TYPE].getDepth());\t\t\t\t\n\t\tpassivation_lay.setFactory3DInfo(PASS_LAYER, metalLayers[5].getDepth());\t\t\t\n\t\tsilicideBlock_lay.setFactory3DInfo(0, BULK_LAYER);\t\t\t\n\t\tpadFrame_lay.setFactory3DInfo(0, passivation_lay.getDepth());\t\t\t\t\n\t\tpseudoPoly1_lay.setFactory3DInfo(0, poly1_lay.getDistance());\t\t\t\n\t\tpseudoPoly2_lay.setFactory3DInfo(0, poly2_lay.getDistance());\t\t\t\n\t\tpseudoPActive_lay.setFactory3DInfo(0, activeLayers[P_TYPE].getDistance());\t\t\t\n\t\tpseudoNActive_lay.setFactory3DInfo(0, activeLayers[N_TYPE].getDistance());\t\t\t\n\t\tpseudoPSelect_lay.setFactory3DInfo(0, selectLayers[P_TYPE].getDistance());\t\t\t\n\t\tpseudoNSelect_lay.setFactory3DInfo(0, selectLayers[N_TYPE].getDistance());\t\t\t\n\t\tpseudoPWell_lay.setFactory3DInfo(0, wellLayers[P_TYPE].getDistance());\t\t\t\t\n\t\tpseudoNWell_lay.setFactory3DInfo(0, wellLayers[N_TYPE].getDistance());\t\t\t\t\n\t\tmetalLayers[0].setFactoryParasitics(0.06, 0.07, 0);\t\t\t\n\t\tmetalLayers[1].setFactoryParasitics(0.06, 0.04, 0);\t\t\t\n\t\tmetalLayers[2].setFactoryParasitics(0.06, 0.04, 0);\t\t\t\n\t\tmetalLayers[3].setFactoryParasitics(0.03, 0.04, 0);\t\t\t\n\t\tmetalLayers[4].setFactoryParasitics(0.03, 0.04, 0);\t\t\t\n\t\tmetalLayers[5].setFactoryParasitics(0.03, 0.04, 0);\t\t\t\n\t\tpoly1_lay.setFactoryParasitics(2.5, 0.09, 0);\t\t\t\n\t\tpoly2_lay.setFactoryParasitics(50.0, 1.0, 0);\t\t\t\n\t\tactiveLayers[P_TYPE].setFactoryParasitics(2.5, 0.9, 0);\t\t\t\n\t\tactiveLayers[N_TYPE].setFactoryParasitics(3.0, 0.9, 0);\t\t\t\n\t\tselectLayers[P_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\twellLayers[P_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\twellLayers[N_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tpolyCutLayer.setFactoryParasitics(2.2, 0, 0);\t\t\t\n\t\tactiveCut_lay.setFactoryParasitics(2.5, 0, 0);\t\t\t\n\t\tvia1_lay.setFactoryParasitics(1.0, 0, 0);\t\t\t\t\n\t\tvia2_lay.setFactoryParasitics(0.9, 0, 0);\t\t\t\t\n\t\tvia3_lay.setFactoryParasitics(0.8, 0, 0);\t\t\t\t\n\t\tvia4_lay.setFactoryParasitics(0.8, 0, 0);\t\t\t\t\n\t\tvia5_lay.setFactoryParasitics(0.8, 0, 0);\t\t\t\t\n\t\tpassivation_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\ttransistorPoly_lay.setFactoryParasitics(2.5, 0.09, 0);\t\n\t\tpolyCap_lay.setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tpActiveWell_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tsilicideBlock_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tthickActive_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal1_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal2_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal3_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal4_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal5_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal6_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoPoly1_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoPoly2_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoPActive_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoNActive_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoPSelect_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoNSelect_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoPWell_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoNWell_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpadFrame_lay.setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tsetFactoryParasitics(50, 0.04);\n\t\tString [] headerLevel1 =\n\t\t{\n\t\t\t\"*CMOS/BULK-NWELL (PRELIMINARY PARAMETERS)\",\n\t\t\t\".OPTIONS NOMOD DEFL=3UM DEFW=3UM DEFAD=70P DEFAS=70P LIMPTS=1000\",\n\t\t\t\"+ITL5=0 RELTOL=0.01 ABSTOL=500PA VNTOL=500UV LVLTIM=2\",\n\t\t\t\"+LVLCOD=1\",\n\t\t\t\".MODEL N NMOS LEVEL=1\",\n\t\t\t\"+KP=60E-6 VTO=0.7 GAMMA=0.3 LAMBDA=0.05 PHI=0.6\",\n\t\t\t\"+LD=0.4E-6 TOX=40E-9 CGSO=2.0E-10 CGDO=2.0E-10 CJ=.2MF/M^2\",\n\t\t\t\".MODEL P PMOS LEVEL=1\",\n\t\t\t\"+KP=20E-6 VTO=0.7 GAMMA=0.4 LAMBDA=0.05 PHI=0.6\",\n\t\t\t\"+LD=0.6E-6 TOX=40E-9 CGSO=3.0E-10 CGDO=3.0E-10 CJ=.2MF/M^2\",\n\t\t\t\".MODEL DIFFCAP D CJO=.2MF/M^2\"\n\t\t};\n\t\tsetSpiceHeaderLevel1(headerLevel1);\n\t\tString [] headerLevel2 =\n\t\t{\n\t\t\t\"* MOSIS 3u CMOS PARAMS\",\n\t\t\t\".OPTIONS NOMOD DEFL=2UM DEFW=6UM DEFAD=100P DEFAS=100P\",\n\t\t\t\"+LIMPTS=1000 ITL5=0 ABSTOL=500PA VNTOL=500UV\",\n\t\t\t\"* Note that ITL5=0 sets ITL5 to infinity\",\n\t\t\t\".MODEL N NMOS LEVEL=2 LD=0.3943U TOX=502E-10\",\n\t\t\t\"+NSUB=1.22416E+16 VTO=0.756 KP=4.224E-05 GAMMA=0.9241\",\n\t\t\t\"+PHI=0.6 UO=623.661 UEXP=8.328627E-02 UCRIT=54015.0\",\n\t\t\t\"+DELTA=5.218409E-03 VMAX=50072.2 XJ=0.4U LAMBDA=2.975321E-02\",\n\t\t\t\"+NFS=4.909947E+12 NEFF=1.001E-02 NSS=0.0 TPG=1.0\",\n\t\t\t\"+RSH=20.37 CGDO=3.1E-10 CGSO=3.1E-10\",\n\t\t\t\"+CJ=3.205E-04 MJ=0.4579 CJSW=4.62E-10 MJSW=0.2955 PB=0.7\",\n\t\t\t\".MODEL P PMOS LEVEL=2 LD=0.2875U TOX=502E-10\",\n\t\t\t\"+NSUB=1.715148E+15 VTO=-0.7045 KP=1.686E-05 GAMMA=0.3459\",\n\t\t\t\"+PHI=0.6 UO=248.933 UEXP=1.02652 UCRIT=182055.0\",\n\t\t\t\"+DELTA=1.0E-06 VMAX=100000.0 XJ=0.4U LAMBDA=1.25919E-02\",\n\t\t\t\"+NFS=1.0E+12 NEFF=1.001E-02 NSS=0.0 TPG=-1.0\",\n\t\t\t\"+RSH=79.10 CGDO=2.89E-10 CGSO=2.89E-10\",\n\t\t\t\"+CJ=1.319E-04 MJ=0.4125 CJSW=3.421E-10 MJSW=0.198 PB=0.66\",\n\t\t\t\".TEMP 25.0\"\n\t\t};\n\t\tsetSpiceHeaderLevel2(headerLevel2);\n\t\tmetalArcs[0] = ArcProto.newInstance(this, \"Metal-1\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[0], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[0].setFunction(ArcProto.Function.METAL1);\n\t\tmetalArcs[0].setFactoryFixedAngle(true);\n\t\tmetalArcs[0].setWipable();\n\t\tmetalArcs[0].setFactoryAngleIncrement(90);\n\t\tmetalArcs[1] = ArcProto.newInstance(this, \"Metal-2\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[1], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[1].setFunction(ArcProto.Function.METAL2);\n\t\tmetalArcs[1].setFactoryFixedAngle(true);\n\t\tmetalArcs[1].setWipable();\n\t\tmetalArcs[1].setFactoryAngleIncrement(90);\n\t\tmetalArcs[2] = ArcProto.newInstance(this, \"Metal-3\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[2], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[2].setFunction(ArcProto.Function.METAL3);\n\t\tmetalArcs[2].setFactoryFixedAngle(true);\n\t\tmetalArcs[2].setWipable();\n\t\tmetalArcs[2].setFactoryAngleIncrement(90);\n\t\tmetalArcs[3] = ArcProto.newInstance(this, \"Metal-4\", 6.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[3], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[3].setFunction(ArcProto.Function.METAL4);\n\t\tmetalArcs[3].setFactoryFixedAngle(true);\n\t\tmetalArcs[3].setWipable();\n\t\tmetalArcs[3].setFactoryAngleIncrement(90);\n\t\tmetalArcs[4] = ArcProto.newInstance(this, \"Metal-5\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[4], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[4].setFunction(ArcProto.Function.METAL5);\n\t\tmetalArcs[4].setFactoryFixedAngle(true);\n\t\tmetalArcs[4].setWipable();\n\t\tmetalArcs[4].setFactoryAngleIncrement(90);\n\t\tmetalArcs[5] = ArcProto.newInstance(this, \"Metal-6\", 4.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[5], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[5].setFunction(ArcProto.Function.METAL6);\n\t\tmetalArcs[5].setFactoryFixedAngle(true);\n\t\tmetalArcs[5].setWipable();\n\t\tmetalArcs[5].setFactoryAngleIncrement(90);\n\t\tpoly1_arc = ArcProto.newInstance(this, \"Polysilicon-1\", 2.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(poly1_lay, 0, Poly.Type.FILLED)\n\t\t});\n\t\tpoly1_arc.setFunction(ArcProto.Function.POLY1);\n\t\tpoly1_arc.setFactoryFixedAngle(true);\n\t\tpoly1_arc.setWipable();\n\t\tpoly1_arc.setFactoryAngleIncrement(90);\n\t\tpoly2_arc = ArcProto.newInstance(this, \"Polysilicon-2\", 7.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(poly2_lay, 0, Poly.Type.FILLED)\n\t\t});\n\t\tpoly2_arc.setFunction(ArcProto.Function.POLY2);\n\t\tpoly2_arc.setFactoryFixedAngle(true);\n\t\tpoly2_arc.setWipable();\n\t\tpoly2_arc.setFactoryAngleIncrement(90);\n\t\tpoly2_arc.setNotUsed();\n\t\tactiveArcs[P_TYPE] = ArcProto.newInstance(this, \"P-Active\", 15.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(activeLayers[P_TYPE], 12, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(selectLayers[P_TYPE], 8, Poly.Type.FILLED)\n\t\t});\n\t\tactiveArcs[P_TYPE].setFunction(ArcProto.Function.DIFFP);\n\t\tactiveArcs[P_TYPE].setFactoryFixedAngle(true);\n\t\tactiveArcs[P_TYPE].setWipable();\n\t\tactiveArcs[P_TYPE].setFactoryAngleIncrement(90);\n\t\tactiveArcs[P_TYPE].setWidthOffset(12.0);\n\t\tactiveArcs[N_TYPE] = ArcProto.newInstance(this, \"N-Active\", 15.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(activeLayers[N_TYPE], 12, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(selectLayers[N_TYPE], 8, Poly.Type.FILLED)\n\t\t});\n\t\tactiveArcs[N_TYPE].setFunction(ArcProto.Function.DIFFN);\n\t\tactiveArcs[N_TYPE].setFactoryFixedAngle(true);\n\t\tactiveArcs[N_TYPE].setWipable();\n\t\tactiveArcs[N_TYPE].setFactoryAngleIncrement(90);\n\t\tactiveArcs[N_TYPE].setWidthOffset(12.0);\n\t\tactive_arc = ArcProto.newInstance(this, \"Active\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(activeLayers[P_TYPE], 0, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED)\n\t\t});\n\t\tactive_arc.setFunction(ArcProto.Function.DIFF);\n\t\tactive_arc.setFactoryFixedAngle(true);\n\t\tactive_arc.setWipable();\n\t\tactive_arc.setFactoryAngleIncrement(90);\n\t\tactive_arc.setNotUsed();\n\t\tmetalPinNodes[0] = PrimitiveNode.newInstance(\"Metal-1-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal1_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[0].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[0], new ArcProto[] {metalArcs[0]}, \"metal-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[0].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[0].setArcsWipe();\n\t\tmetalPinNodes[0].setArcsShrink();\n\t\tmetalPinNodes[1] = PrimitiveNode.newInstance(\"Metal-2-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal2_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[1].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[1], new ArcProto[] {metalArcs[1]}, \"metal-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[1].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[1].setArcsWipe();\n\t\tmetalPinNodes[1].setArcsShrink();\n\t\tmetalPinNodes[2] = PrimitiveNode.newInstance(\"Metal-3-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal3_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[2].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[2], new ArcProto[] {metalArcs[2]}, \"metal-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[2].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[2].setArcsWipe();\n\t\tmetalPinNodes[2].setArcsShrink();\n\t\tmetalPinNodes[3] = PrimitiveNode.newInstance(\"Metal-4-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal4_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[3].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[3], new ArcProto[] {metalArcs[3]}, \"metal-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[3].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[3].setArcsWipe();\n\t\tmetalPinNodes[3].setArcsShrink();\n\t\tmetalPinNodes[4] = PrimitiveNode.newInstance(\"Metal-5-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal5_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[4].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[4], new ArcProto[] {metalArcs[4]}, \"metal-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[4].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[4].setArcsWipe();\n\t\tmetalPinNodes[4].setArcsShrink();\n\t\tmetalPinNodes[4].setNotUsed();\n\t\tmetalPinNodes[5] = PrimitiveNode.newInstance(\"Metal-6-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal6_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[5].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[5], new ArcProto[] {metalArcs[5]}, \"metal-6\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[5].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[5].setArcsWipe();\n\t\tmetalPinNodes[5].setArcsShrink();\n\t\tmetalPinNodes[5].setNotUsed();\n\t\tpoly1Pin_node = PrimitiveNode.newInstance(\"Polysilicon-1-Pin\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPoly1_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly1Pin_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly1Pin_node, new ArcProto[] {poly1_arc}, \"polysilicon-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1), EdgeV.fromBottom(1), EdgeH.fromRight(1), EdgeV.fromTop(1))\n\t\t\t});\n\t\tpoly1Pin_node.setFunction(PrimitiveNode.Function.PIN);\n\t\tpoly1Pin_node.setArcsWipe();\n\t\tpoly1Pin_node.setArcsShrink();\n\t\tpoly2Pin_node = PrimitiveNode.newInstance(\"Polysilicon-2-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPoly2_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly2Pin_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly2Pin_node, new ArcProto[] {poly2_arc}, \"polysilicon-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tpoly2Pin_node.setFunction(PrimitiveNode.Function.PIN);\n\t\tpoly2Pin_node.setArcsWipe();\n\t\tpoly2Pin_node.setArcsShrink();\n\t\tpoly2Pin_node.setNotUsed();\n\t\tactivePinNodes[P_TYPE] = PrimitiveNode.newInstance(\"P-Active-Pin\", this, 15.0, 15.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(pseudoNWell_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(pseudoPSelect_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4))\n\t\t\t});\n\t\tactivePinNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activePinNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE]}, \"p-active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromBottom(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7.5))\n\t\t\t});\n\t\tactivePinNodes[P_TYPE].setFunction(PrimitiveNode.Function.PIN);\n\t\tactivePinNodes[P_TYPE].setArcsWipe();\n\t\tactivePinNodes[P_TYPE].setArcsShrink();\n\t\tactivePinNodes[N_TYPE] = PrimitiveNode.newInstance(\"N-Active-Pin\", this, 15.0, 15.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoNActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(pseudoPWell_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(pseudoNSelect_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4))\n\t\t\t});\n\t\tactivePinNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activePinNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE]}, \"n-active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromBottom(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7.5))\n\t\t\t});\n\t\tactivePinNodes[N_TYPE].setFunction(PrimitiveNode.Function.PIN);\n\t\tactivePinNodes[N_TYPE].setArcsWipe();\n\t\tactivePinNodes[N_TYPE].setArcsShrink();\n\t\tactivePin_node = PrimitiveNode.newInstance(\"Active-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(pseudoNActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tactivePin_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activePin_node, new ArcProto[] {active_arc, activeArcs[P_TYPE], activeArcs[N_TYPE]}, \"active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tactivePin_node.setFunction(PrimitiveNode.Function.PIN);\n\t\tactivePin_node.setArcsWipe();\n\t\tactivePin_node.setArcsShrink();\n activePin_node.setNotUsed();\n\t\tmetalActiveContactNodes[P_TYPE] = PrimitiveNode.newInstance(\"Metal-1-P-Active-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX,Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalActiveContactNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalActiveContactNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE], metalArcs[0]}, \"metal-1-p-act\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalActiveContactNodes[P_TYPE].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalActiveContactNodes[P_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalActiveContactNodes[P_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalActiveContactNodes[P_TYPE].setMinSize(17, 17, \"6.2, 7.3\");\n\t\tmetalActiveContactNodes[N_TYPE] = PrimitiveNode.newInstance(\"Metal-1-N-Active-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalActiveContactNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalActiveContactNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE], metalArcs[0]}, \"metal-1-n-act\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalActiveContactNodes[N_TYPE].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalActiveContactNodes[N_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalActiveContactNodes[N_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalActiveContactNodes[N_TYPE].setMinSize(17, 17, \"6.2, 7.3\");\n\t\tmetal1Poly1Contact_node = PrimitiveNode.newInstance(\"Metal-1-Polysilicon-1-Con\", this, 5.0, 5.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(0.5)),\n\t\t\t\tnew Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5))\n\t\t\t});\n\t\tmetal1Poly1Contact_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Poly1Contact_node, new ArcProto[] {poly1_arc, metalArcs[0]}, \"metal-1-polysilicon-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2), EdgeV.fromBottom(2), EdgeH.fromRight(2), EdgeV.fromTop(2))\n\t\t\t});\n\t\tmetal1Poly1Contact_node.setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetal1Poly1Contact_node.setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetal1Poly1Contact_node.setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetal1Poly1Contact_node.setMinSize(5, 5, \"5.2, 7.3\");\n\t\tmetal1Poly2Contact_node = PrimitiveNode.newInstance(\"Metal-1-Polysilicon-2-Con\", this, 10.0, 10.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(3)),\n\t\t\t\tnew Technology.NodeLayer(poly2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4))\n\t\t\t});\n\t\tmetal1Poly2Contact_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Poly2Contact_node, new ArcProto[] {poly2_arc, metalArcs[0]}, \"metal-1-polysilicon-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(4.5), EdgeV.fromBottom(4.5), EdgeH.fromRight(4.5), EdgeV.fromTop(4.5))\n\t\t\t});\n\t\tmetal1Poly2Contact_node.setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetal1Poly2Contact_node.setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetal1Poly2Contact_node.setSpecialValues(new double [] {2, 2, 4, 4, 3, 3});\n\t\tmetal1Poly2Contact_node.setNotUsed();\n\t\tmetal1Poly2Contact_node.setMinSize(10, 10, \"?\");\n\t\tmetal1Poly12Contact_node = PrimitiveNode.newInstance(\"Metal-1-Polysilicon-1-2-Con\", this, 15.0, 15.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(5.5)),\n\t\t\t\tnew Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(5)),\n\t\t\t\tnew Technology.NodeLayer(poly2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5))\n\t\t\t});\n\t\tmetal1Poly12Contact_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Poly12Contact_node, new ArcProto[] {poly1_arc, poly2_arc, metalArcs[0]}, \"metal-1-polysilicon-1-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(7), EdgeV.fromBottom(7), EdgeH.fromRight(7), EdgeV.fromTop(7))\n\t\t\t});\n\t\tmetal1Poly12Contact_node.setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetal1Poly12Contact_node.setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetal1Poly12Contact_node.setSpecialValues(new double [] {2, 2, 6.5, 6.5, 3, 3});\n\t\tmetal1Poly12Contact_node.setNotUsed();\n\t\tmetal1Poly12Contact_node.setMinSize(15, 15, \"?\");\n String[] stdNames = {\"p\", \"n\"};\n for (int i = 0; i < 2; i++)\n {\n transistorPolyLayers[i] = new Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(4), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromRight(4), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorPolyLLayers[i] = new Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(4), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorPolyRLayers[i] = new Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromRight(4), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorPolyCLayers[i] = new Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorActiveLayers[i] = new Technology.NodeLayer(activeLayers[i], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(7)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(7))}, 4, 4, 0, 0);\n transistorActiveTLayers[i] = new Technology.NodeLayer(activeLayers[i], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(10)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(7))}, 4, 4, 0, 0);\n transistorActiveBLayers[i] = new Technology.NodeLayer(activeLayers[i], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(7)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(10))}, 4, 4, 0, 0);\n transistorWellLayers[i] = new Technology.NodeLayer(wellLayers[(i+1)%transistorNodes.length], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.makeLeftEdge(), EdgeV.fromBottom(1)),\n new Technology.TechPoint(EdgeH.makeRightEdge(), EdgeV.fromTop(1))}, 10, 10, 6, 6);\n transistorSelectLayers[i] = new Technology.NodeLayer(selectLayers[i], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(4), EdgeV.fromBottom(5)),\n new Technology.TechPoint(EdgeH.fromRight(4), EdgeV.fromTop(5))}, 6, 6, 2, 2);\n transistorNodes[i] = PrimitiveNode.newInstance(stdNames[i].toUpperCase()+\"-Transistor\", this, 15.0, 22.0, new SizeOffset(6, 6, 10, 10),\n new Technology.NodeLayer [] {transistorActiveLayers[i], transistorPolyLayers[i], transistorWellLayers[i], transistorSelectLayers[i]});\n transistorNodes[i].setElectricalLayers(new Technology.NodeLayer [] {transistorActiveTLayers[i], transistorActiveBLayers[i],\n transistorPolyCLayers[i], transistorPolyLLayers[i], transistorPolyRLayers[i], transistorWellLayers[i], transistorSelectLayers[i]});\n transistorNodes[i].addPrimitivePorts(new PrimitivePort []\n {\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {poly1_arc}, stdNames[i]+\"-trans-poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(4), EdgeV.fromBottom(11), EdgeH.fromLeft(4), EdgeV.fromTop(11)),\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {activeArcs[i]}, stdNames[i]+\"-trans-diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(7.5), EdgeV.fromTop(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7)),\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {poly1_arc}, stdNames[i]+\"-trans-poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n EdgeH.fromRight(4), EdgeV.fromBottom(11), EdgeH.fromRight(4), EdgeV.fromTop(11)),\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {activeArcs[i]}, stdNames[i]+\"-trans-diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(7.5), EdgeV.fromBottom(7), EdgeH.fromRight(7.5), EdgeV.fromBottom(7.5))\n });\n transistorNodes[i].setFunction((i==P_TYPE) ? PrimitiveNode.Function.TRAPMOS : PrimitiveNode.Function.TRANMOS);\n transistorNodes[i].setHoldsOutline();\n transistorNodes[i].setCanShrink();\n transistorNodes[i].setSpecialType(PrimitiveNode.SERPTRANS);\n transistorNodes[i].setSpecialValues(new double [] {7, 1.5, 2.5, 2, 1, 2});\n transistorNodes[i].setMinSize(15, 22, \"2.1, 3.1\");\n }\n\t\tString[] thickNames = {\"Thick-P\", \"Thick-N\"};\n\t\tTechnology.NodeLayer[] thickActiveLayers = new Technology.NodeLayer[] {transistorActiveLayers[P_TYPE], transistorActiveLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickPolyLayers = new Technology.NodeLayer[] {transistorPolyLayers[P_TYPE], transistorPolyLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickWellLayers = new Technology.NodeLayer[] {transistorWellLayers[P_TYPE], transistorWellLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickSelectLayers = new Technology.NodeLayer[] {transistorSelectLayers[P_TYPE], transistorSelectLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickActiveTLayers = new Technology.NodeLayer[] {transistorActiveTLayers[P_TYPE], transistorActiveTLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickActiveBLayers = new Technology.NodeLayer[] {transistorActiveBLayers[P_TYPE], transistorActiveBLayers[N_TYPE]};\n Technology.NodeLayer[] thickPolyCLayers = new Technology.NodeLayer[] {transistorPolyCLayers[P_TYPE], transistorPolyCLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickPolyLLayers = new Technology.NodeLayer[] {transistorPolyLLayers[P_TYPE], transistorPolyLLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickPolyRLayers = new Technology.NodeLayer[] {transistorPolyRLayers[P_TYPE], transistorPolyRLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickLayers = new Technology.NodeLayer[2];\n\t\tfor (int i = 0; i < thickLayers.length; i++)\n\t\t{\n\t\t\tthickLayers[i] = new Technology.NodeLayer(thickActive_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\tnew Technology.TechPoint(EdgeH.makeLeftEdge(), EdgeV.fromBottom(1)),\n\t\t\tnew Technology.TechPoint(EdgeH.makeRightEdge(), EdgeV.fromTop(1))}, 10, 10, 6, 6);\n\t\t}\n\t\tfor (int i = 0; i < thickTransistorNodes.length; i++)\n\t\t{\n\t\t\tthickTransistorNodes[i] = PrimitiveNode.newInstance(thickNames[i] + \"-Transistor\", this, 15.0, 22.0, new SizeOffset(6, 6, 10, 10),\n\t\t\t\tnew Technology.NodeLayer [] {thickActiveLayers[i], thickPolyLayers[i], thickWellLayers[i], thickSelectLayers[i], thickLayers[i]});\n\t\t\tthickTransistorNodes[i].setElectricalLayers(new Technology.NodeLayer [] {thickActiveTLayers[i], thickActiveBLayers[i],\n\t\t\t\tthickPolyCLayers[i], thickPolyLLayers[i], thickPolyRLayers[i], thickWellLayers[i], thickSelectLayers[i], thickLayers[i]});\n\t\t\tthickTransistorNodes[i].addPrimitivePorts(new PrimitivePort []\n\t\t\t\t{\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {poly1_arc}, \"poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromLeft(4), EdgeV.fromBottom(11), EdgeH.fromLeft(4), EdgeV.fromTop(11)),\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {activeArcs[i]}, \"diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromTop(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7)),\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {poly1_arc}, \"poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromRight(4), EdgeV.fromBottom(11), EdgeH.fromRight(4), EdgeV.fromTop(11)),\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {activeArcs[i]}, \"diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromBottom(7), EdgeH.fromRight(7.5), EdgeV.fromBottom(7.5))\n\t\t\t\t});\n\t\t\tthickTransistorNodes[i].setFunction((i==P_TYPE) ? PrimitiveNode.Function.TRAPMOS : PrimitiveNode.Function.TRANMOS);\n\t\t\tthickTransistorNodes[i].setHoldsOutline();\n\t\t\tthickTransistorNodes[i].setCanShrink();\n\t\t\tthickTransistorNodes[i].setSpecialType(PrimitiveNode.SERPTRANS);\n\t\t\tthickTransistorNodes[i].setSpecialValues(new double [] {7, 1.5, 2.5, 2, 1, 2});\n\t\t\tthickTransistorNodes[i].setMinSize(15, 22, \"2.1, 3.1\");\n\t\t\tthickTransistorNodes[i].setSpecialNode(); \n\t\t}\n\t\tscalableTransistorNodes[P_TYPE] = PrimitiveNode.newInstance(\"P-Transistor-Scalable\", this, 17.0, 26.0, new SizeOffset(7, 7, 12, 12),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(6)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(11))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromTop(6.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromTop(10.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(11)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(6))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromBottom(10.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromBottom(6.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7), EdgeV.fromBottom(9)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(7), EdgeV.fromTop(9))}),\n\t\t\t\tnew Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(5), EdgeV.fromBottom(12)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(5), EdgeV.fromTop(12))}),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromBottom(9.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromBottom(7.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromTop(7.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromTop(9.5))})\n\t\t\t});\n\t\tscalableTransistorNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {poly1_arc}, \"p-trans-sca-poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(-3.5), EdgeV.makeCenter(), EdgeH.fromCenter(-3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE], metalArcs[0]}, \"p-trans-sca-diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(4.5), EdgeH.makeCenter(), EdgeV.fromCenter(4.5)),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {poly1_arc}, \"p-trans-sca-poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(3.5), EdgeV.makeCenter(), EdgeH.fromCenter(3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE], metalArcs[0]}, \"p-trans-sca-diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(-4.5), EdgeH.makeCenter(), EdgeV.fromCenter(-4.5))\n\t\t\t});\n\t\tscalableTransistorNodes[P_TYPE].setFunction(PrimitiveNode.Function.TRAPMOS);\n\t\tscalableTransistorNodes[P_TYPE].setCanShrink();\n\t\tscalableTransistorNodes[P_TYPE].setMinSize(17, 26, \"2.1, 3.1\");\n\t\tscalableTransistorNodes[N_TYPE] = PrimitiveNode.newInstance(\"N-Transistor-Scalable\", this, 17.0, 26.0, new SizeOffset(7, 7, 12, 12),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(6)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(11))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromTop(6.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromTop(10.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(11)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(6))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromBottom(10.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromBottom(6.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7), EdgeV.fromBottom(9)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(7), EdgeV.fromTop(9))}),\n\t\t\t\tnew Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(5), EdgeV.fromBottom(12)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(5), EdgeV.fromTop(12))}),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromBottom(9.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromBottom(7.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromTop(7.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromTop(9.5))})\n\t\t\t});\n\t\tscalableTransistorNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {poly1_arc}, \"n-trans-sca-poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(-3.5), EdgeV.makeCenter(), EdgeH.fromCenter(-3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE], metalArcs[0]}, \"n-trans-sca-diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(4.5), EdgeH.makeCenter(), EdgeV.fromCenter(4.5)),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {poly1_arc}, \"n-trans-sca-poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(3.5), EdgeV.makeCenter(), EdgeH.fromCenter(3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE], metalArcs[0]}, \"n-trans-sca-diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(-4.5), EdgeH.makeCenter(), EdgeV.fromCenter(-4.5))\n\t\t\t});\n\t\tscalableTransistorNodes[N_TYPE].setFunction(PrimitiveNode.Function.TRANMOS);\n\t\tscalableTransistorNodes[N_TYPE].setCanShrink();\n\t\tscalableTransistorNodes[N_TYPE].setMinSize(17, 26, \"2.1, 3.1\");\n\t\tmetalContactNodes[0] = PrimitiveNode.newInstance(\"Metal-1-Metal-2-Con\", this, 5.0, 5.0, new SizeOffset(0.5, 0.5, 0.5, 0.5),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(0.5)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[1], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(0.5)),\n\t\t\t\tnew Technology.NodeLayer(via1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5))\n\t\t\t});\n\t\tmetalContactNodes[0].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[0], new ArcProto[] {metalArcs[0], metalArcs[1]}, \"metal-1-metal-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalContactNodes[0].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[0].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[0].setSpecialValues(new double [] {2, 2, 1, 1, 3, 3});\n\t\tmetalContactNodes[0].setMinSize(5, 5, \"8.3, 9.3\");\n\t\tmetalContactNodes[1] = PrimitiveNode.newInstance(\"Metal-2-Metal-3-Con\", this, 6.0, 6.0, new SizeOffset(1, 1, 1, 1),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[1], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[2], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(via2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(2))\n\t\t\t});\n\t\tmetalContactNodes[1].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[1], new ArcProto[] {metalArcs[1], metalArcs[2]}, \"metal-2-metal-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[1].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[1].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[1].setSpecialValues(new double [] {2, 2, 1, 1, 3, 3});\n\t\tmetalContactNodes[1].setMinSize(6, 6, \"14.3, 15.3\");\n\t\tmetalContactNodes[2] = PrimitiveNode.newInstance(\"Metal-3-Metal-4-Con\", this, 6.0, 6.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[2], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[3], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(via3_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(2))\n\t\t\t});\n\t\tmetalContactNodes[2].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[2], new ArcProto[] {metalArcs[2], metalArcs[3]}, \"metal-3-metal-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[2].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[2].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[2].setSpecialValues(new double [] {2, 2, 2, 2, 3, 3});\n\t\tmetalContactNodes[2].setMinSize(6, 6, \"21.3, 22.3\");\n\t\tmetalContactNodes[3] = PrimitiveNode.newInstance(\"Metal-4-Metal-5-Con\", this, 7.0, 7.0, new SizeOffset(1.5, 1.5, 1.5, 1.5),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[3], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[4], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5)),\n\t\t\t\tnew Technology.NodeLayer(via4_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(2.5))\n\t\t\t});\n\t\tmetalContactNodes[3].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[3], new ArcProto[] {metalArcs[3], metalArcs[4]}, \"metal-4-metal-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[3].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[3].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[3].setSpecialValues(new double [] {2, 2, 1, 1, 3, 3});\n\t\tmetalContactNodes[3].setNotUsed();\n\t\tmetalContactNodes[3].setMinSize(7, 7, \"25.3, 26.3\");\n\t\tmetalContactNodes[4] = PrimitiveNode.newInstance(\"Metal-5-Metal-6-Con\", this, 8.0, 8.0, new SizeOffset(1, 1, 1, 1),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[4], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[5], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(via5_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(3))\n\t\t\t});\n\t\tmetalContactNodes[4].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[4], new ArcProto[] {metalArcs[4], metalArcs[5]}, \"metal-5-metal-6\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[4].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[4].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[4].setSpecialValues(new double [] {3, 3, 2, 2, 4, 4});\n\t\tmetalContactNodes[4].setNotUsed();\n\t\tmetalContactNodes[4].setMinSize(8, 8, \"29.3, 30.3\");\n\t\tmetalWellContactNodes[P_TYPE] = PrimitiveNode.newInstance(\"Metal-1-P-Well-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(pActiveWell_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalWellContactNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalWellContactNodes[P_TYPE], new ArcProto[] {metalArcs[0], active_arc}, \"metal-1-well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalWellContactNodes[P_TYPE].setFunction(PrimitiveNode.Function.WELL);\n\t\tmetalWellContactNodes[P_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalWellContactNodes[P_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalWellContactNodes[P_TYPE].setMinSize(17, 17, \"4.2, 6.2, 7.3\");\n\t\tmetalWellContactNodes[N_TYPE] = PrimitiveNode.newInstance(\"Metal-1-N-Well-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalWellContactNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalWellContactNodes[N_TYPE], new ArcProto[] {metalArcs[0], active_arc}, \"metal-1-substrate\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalWellContactNodes[N_TYPE].setFunction(PrimitiveNode.Function.SUBSTRATE);\n\t\tmetalWellContactNodes[N_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalWellContactNodes[N_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalWellContactNodes[N_TYPE].setMinSize(17, 17, \"4.2, 6.2, 7.3\");\n double polySelectOffX = 1.8; \n double polyCutSize = 2.2; \n double resistorViaOff = 1.0; \n double resistorConW = polyCutSize + 2*resistorViaOff ;\n double resistorConH = resistorConW ;\n double resistorOffX = resistorConW + polySelectOffX + 1.2 ;\n double resistorW = 20 + 2*resistorOffX;\n double resistorOffY = 2.2 ;\n double resistorH = 2*resistorOffY + resistorConH;\n double resistorM1Off = resistorViaOff - 0.6; \n double resistorM1W = resistorConW-2*resistorM1Off;\n double resistorM1OffX = resistorM1Off + polySelectOffX;\n double resistorM1OffY = resistorM1Off + resistorOffY;\n double resistorV1OffX = resistorViaOff + polySelectOffX;\n double resistorV1OffY = resistorOffY + (resistorConH-polyCutSize)/2;\n rpoResistorNodes = new PrimitiveNode[2];\n for (int i = 0; i < rpoResistorNodes.length; i++)\n {\n rpoResistorNodes[i] = PrimitiveNode.newInstance(stdNames[i]+\"-Poly-RPO-Resistor\", this, resistorW, resistorH,\n new SizeOffset(resistorOffX, resistorOffX, resistorOffY, resistorOffY),\n\t\t\t\tnew Technology.NodeLayer []\n\t\t\t\t{\n new Technology.NodeLayer(poly1_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(polySelectOffX), EdgeV.fromBottom(resistorOffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(polySelectOffX), EdgeV.fromTop(resistorOffY))}),\n new Technology.NodeLayer(silicideBlock_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorOffX), EdgeV.makeBottomEdge()),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorOffX), EdgeV.makeTopEdge())}),\n new Technology.NodeLayer(selectLayers[i], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.makeLeftEdge(), EdgeV.fromBottom(0.2)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.makeRightEdge(), EdgeV.fromTop(0.2))}),\n new Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorM1OffX), EdgeV.fromBottom(resistorM1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorM1OffX+resistorM1W), EdgeV.fromTop(resistorM1OffY))}),\n new Technology.NodeLayer(polyCutLayer, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorV1OffX+polyCutSize), EdgeV.fromBottom(resistorV1OffY+polyCutSize))}),\n new Technology.NodeLayer(metalLayers[0], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorM1OffX+resistorM1W), EdgeV.fromBottom(resistorM1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorM1OffX), EdgeV.fromTop(resistorM1OffY))}),\n new Technology.NodeLayer(polyCutLayer, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorV1OffX+polyCutSize), EdgeV.fromBottom(resistorV1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY+polyCutSize))})\n\t\t\t\t});\n rpoResistorNodes[i].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, rpoResistorNodes[i], new ArcProto[] {poly1_arc, metalArcs[0]}, \"left-rpo\", 0,180, 0, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY), EdgeH.fromLeft(resistorV1OffX+polyCutSize), EdgeV.fromTop(resistorV1OffY)),\n PrimitivePort.newInstance(this, rpoResistorNodes[i], new ArcProto[] {poly1_arc, metalArcs[0]}, \"right-rpo\", 0,180, 1, PortCharacteristic.UNKNOWN,\n EdgeH.fromRight(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY), EdgeH.fromRight(resistorV1OffX+polyCutSize), EdgeV.fromTop(resistorV1OffY))\n\t\t\t});\n rpoResistorNodes[i].setFunction(PrimitiveNode.Function.PRESIST);\n\t\t\trpoResistorNodes[i].setHoldsOutline();\n\t\t\trpoResistorNodes[i].setSpecialType(PrimitiveNode.POLYGONAL);\n }\n\t\tmetal1Node_node = PrimitiveNode.newInstance(\"Metal-1-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal1Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Node_node, new ArcProto[] {metalArcs[0]}, \"metal-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal1Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal1Node_node.setHoldsOutline();\n\t\tmetal1Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal2Node_node = PrimitiveNode.newInstance(\"Metal-2-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[1], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal2Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal2Node_node, new ArcProto[] {metalArcs[1]}, \"metal-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal2Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal2Node_node.setHoldsOutline();\n\t\tmetal2Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal3Node_node = PrimitiveNode.newInstance(\"Metal-3-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[2], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal3Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal3Node_node, new ArcProto[] {metalArcs[2]}, \"metal-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal3Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal3Node_node.setHoldsOutline();\n\t\tmetal3Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal4Node_node = PrimitiveNode.newInstance(\"Metal-4-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[3], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal4Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal4Node_node, new ArcProto[] {metalArcs[3]}, \"metal-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal4Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal4Node_node.setHoldsOutline();\n\t\tmetal4Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal5Node_node = PrimitiveNode.newInstance(\"Metal-5-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[4], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal5Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal5Node_node, new ArcProto[] {metalArcs[4]}, \"metal-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal5Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal5Node_node.setHoldsOutline();\n\t\tmetal5Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal5Node_node.setNotUsed();\n\t\tmetal6Node_node = PrimitiveNode.newInstance(\"Metal-6-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[5], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal6Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal6Node_node, new ArcProto[] {metalArcs[5]}, \"metal-6\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal6Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal6Node_node.setHoldsOutline();\n\t\tmetal6Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal6Node_node.setNotUsed();\n\t\tpoly1Node_node = PrimitiveNode.newInstance(\"Polysilicon-1-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly1Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly1Node_node, new ArcProto[] {poly1_arc}, \"polysilicon-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1), EdgeV.fromBottom(1), EdgeH.fromRight(1), EdgeV.fromTop(1))\n\t\t\t});\n\t\tpoly1Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpoly1Node_node.setHoldsOutline();\n\t\tpoly1Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpoly2Node_node = PrimitiveNode.newInstance(\"Polysilicon-2-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(poly2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly2Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly2Node_node, new ArcProto[] {poly2_arc}, \"polysilicon-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tpoly2Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpoly2Node_node.setHoldsOutline();\n\t\tpoly2Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpoly2Node_node.setNotUsed();\n\t\tpActiveNode_node = PrimitiveNode.newInstance(\"P-Active-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpActiveNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pActiveNode_node, new ArcProto[] {active_arc, activeArcs[P_TYPE], activeArcs[N_TYPE]}, \"active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tpActiveNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpActiveNode_node.setHoldsOutline();\n\t\tpActiveNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tnActiveNode_node = PrimitiveNode.newInstance(\"N-Active-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tnActiveNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, nActiveNode_node, new ArcProto[] {active_arc, activeArcs[P_TYPE], activeArcs[N_TYPE]}, \"active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tnActiveNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tnActiveNode_node.setHoldsOutline();\n\t\tnActiveNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpSelectNode_node = PrimitiveNode.newInstance(\"P-Select-Node\", this, 4.0, 4.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpSelectNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pSelectNode_node, new ArcProto[0], \"select\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpSelectNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpSelectNode_node.setHoldsOutline();\n\t\tpSelectNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tnSelectNode_node = PrimitiveNode.newInstance(\"N-Select-Node\", this, 4.0, 4.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tnSelectNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, nSelectNode_node, new ArcProto[0], \"select\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tnSelectNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tnSelectNode_node.setHoldsOutline();\n\t\tnSelectNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpolyCutNode_node = PrimitiveNode.newInstance(\"Poly-Cut-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpolyCutNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, polyCutNode_node, new ArcProto[0], \"polycut\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpolyCutNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpolyCutNode_node.setHoldsOutline();\n\t\tpolyCutNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tactiveCutNode_node = PrimitiveNode.newInstance(\"Active-Cut-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tactiveCutNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activeCutNode_node, new ArcProto[0], \"activecut\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tactiveCutNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tactiveCutNode_node.setHoldsOutline();\n\t\tactiveCutNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia1Node_node = PrimitiveNode.newInstance(\"Via-1-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia1Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via1Node_node, new ArcProto[0], \"via-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia1Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia1Node_node.setHoldsOutline();\n\t\tvia1Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia2Node_node = PrimitiveNode.newInstance(\"Via-2-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia2Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via2Node_node, new ArcProto[0], \"via-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia2Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia2Node_node.setHoldsOutline();\n\t\tvia2Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia3Node_node = PrimitiveNode.newInstance(\"Via-3-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via3_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia3Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via3Node_node, new ArcProto[0], \"via-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia3Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia3Node_node.setHoldsOutline();\n\t\tvia3Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia4Node_node = PrimitiveNode.newInstance(\"Via-4-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via4_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia4Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via4Node_node, new ArcProto[0], \"via-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia4Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia4Node_node.setHoldsOutline();\n\t\tvia4Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia4Node_node.setNotUsed();\n\t\tvia5Node_node = PrimitiveNode.newInstance(\"Via-5-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via5_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia5Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via5Node_node, new ArcProto[0], \"via-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia5Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia5Node_node.setHoldsOutline();\n\t\tvia5Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia5Node_node.setNotUsed();\n\t\tpWellNode_node = PrimitiveNode.newInstance(\"P-Well-Node\", this, 12.0, 12.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpWellNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pWellNode_node, new ArcProto[] {activeArcs[P_TYPE]}, \"well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(3), EdgeV.fromBottom(3), EdgeH.fromRight(3), EdgeV.fromTop(3))\n\t\t\t});\n\t\tpWellNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpWellNode_node.setHoldsOutline();\n\t\tpWellNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tnWellNode_node = PrimitiveNode.newInstance(\"N-Well-Node\", this, 12.0, 12.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tnWellNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, nWellNode_node, new ArcProto[] {activeArcs[P_TYPE]}, \"well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(3), EdgeV.fromBottom(3), EdgeH.fromRight(3), EdgeV.fromTop(3))\n\t\t\t});\n\t\tnWellNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tnWellNode_node.setHoldsOutline();\n\t\tnWellNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpassivationNode_node = PrimitiveNode.newInstance(\"Passivation-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(passivation_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpassivationNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, passivationNode_node, new ArcProto[0], \"passivation\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpassivationNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpassivationNode_node.setHoldsOutline();\n\t\tpassivationNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpadFrameNode_node = PrimitiveNode.newInstance(\"Pad-Frame-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(padFrame_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpadFrameNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, padFrameNode_node, new ArcProto[0], \"pad-frame\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpadFrameNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpadFrameNode_node.setHoldsOutline();\n\t\tpadFrameNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpolyCapNode_node = PrimitiveNode.newInstance(\"Poly-Cap-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(polyCap_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpolyCapNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, polyCapNode_node, new ArcProto[0], \"poly-cap\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpolyCapNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpolyCapNode_node.setHoldsOutline();\n\t\tpolyCapNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpActiveWellNode_node = PrimitiveNode.newInstance(\"P-Active-Well-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pActiveWell_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpActiveWellNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pActiveWellNode_node, new ArcProto[0], \"p-active-well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpActiveWellNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpActiveWellNode_node.setHoldsOutline();\n\t\tpActiveWellNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpolyTransistorNode_node = PrimitiveNode.newInstance(\"Transistor-Poly-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpolyTransistorNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, polyTransistorNode_node, new ArcProto[] {poly1_arc}, \"trans-poly-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1), EdgeV.fromBottom(1), EdgeH.fromRight(1), EdgeV.fromTop(1))\n\t\t\t});\n\t\tpolyTransistorNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpolyTransistorNode_node.setHoldsOutline();\n\t\tpolyTransistorNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tsilicideBlockNode_node = PrimitiveNode.newInstance(\"Silicide-Block-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(silicideBlock_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tsilicideBlockNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, silicideBlockNode_node, new ArcProto[] {poly1_arc}, \"silicide-block\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tsilicideBlockNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tsilicideBlockNode_node.setHoldsOutline();\n\t\tsilicideBlockNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tthickActiveNode_node = PrimitiveNode.newInstance(\"Thick-Active-Node\", this, 4.0, 4.0, null, \n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(thickActive_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tthickActiveNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, thickActiveNode_node, new ArcProto[] {poly1_arc}, \"thick-active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tthickActiveNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tthickActiveNode_node.setHoldsOutline();\n\t\tthickActiveNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetalLayers[0].setPureLayerNode(metal1Node_node);\t\t\t\t\t\n\t\tmetalLayers[1].setPureLayerNode(metal2Node_node);\t\t\t\t\t\n\t\tmetalLayers[2].setPureLayerNode(metal3Node_node);\t\t\t\t\t\n\t\tmetalLayers[3].setPureLayerNode(metal4Node_node);\t\t\t\t\t\n\t\tmetalLayers[4].setPureLayerNode(metal5Node_node);\t\t\t\t\t\n\t\tmetalLayers[5].setPureLayerNode(metal6Node_node);\t\t\t\t\t\n\t\tpoly1_lay.setPureLayerNode(poly1Node_node);\t\t\t\t\t\t\n\t\tpoly2_lay.setPureLayerNode(poly2Node_node);\t\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setPureLayerNode(pActiveNode_node);\t\t\t\t\t\n\t\tactiveLayers[N_TYPE].setPureLayerNode(nActiveNode_node);\t\t\t\t\t\n\t\tselectLayers[P_TYPE].setPureLayerNode(pSelectNode_node);\t\t\t\t\t\n\t\tselectLayers[N_TYPE].setPureLayerNode(nSelectNode_node);\t\t\t\t\t\n\t\twellLayers[P_TYPE].setPureLayerNode(pWellNode_node);\t\t\t\t\t\t\n\t\twellLayers[N_TYPE].setPureLayerNode(nWellNode_node);\t\t\t\t\t\t\n\t\tpolyCutLayer.setPureLayerNode(polyCutNode_node);\t\t\t\t\t\n\t\tactiveCut_lay.setPureLayerNode(activeCutNode_node);\t\t\t\t\n\t\tvia1_lay.setPureLayerNode(via1Node_node);\t\t\t\t\t\t\n\t\tvia2_lay.setPureLayerNode(via2Node_node);\t\t\t\t\t\t\n\t\tvia3_lay.setPureLayerNode(via3Node_node);\t\t\t\t\t\t\n\t\tvia4_lay.setPureLayerNode(via4Node_node);\t\t\t\t\t\t\n\t\tvia5_lay.setPureLayerNode(via5Node_node);\t\t\t\t\t\t\n\t\tpassivation_lay.setPureLayerNode(passivationNode_node);\t\t\t\n\t\ttransistorPoly_lay.setPureLayerNode(polyTransistorNode_node);\t\n\t\tpolyCap_lay.setPureLayerNode(polyCapNode_node);\t\t\t\t\t\n\t\tpActiveWell_lay.setPureLayerNode(pActiveWellNode_node);\t\t\t\n\t\tsilicideBlock_lay.setPureLayerNode(silicideBlockNode_node);\t\t\n\t\tthickActive_lay.setPureLayerNode(thickActiveNode_node);\t\t\t\n\t\tpadFrame_lay.setPureLayerNode(padFrameNode_node);\t\t\t\t\n int maxY = metalArcs.length + activeArcs.length + 1 + 1 + 1 + 1 ;\n nodeGroups = new Object[maxY][3];\n int count = 0;\n String[] shortNames = {\"p\", \"n\"};\n List tmp;\n for (int i = 0; i < transistorNodes.length; i++)\n {\n tmp = new ArrayList(2);\n String tmpVar = shortNames[i]+\"Mos\";\n tmp.add(makeNodeInst(transistorNodes[i], transistorNodes[i].getFunction(), 0, true, tmpVar, 9));\n tmp.add(makeNodeInst(thickTransistorNodes[i], thickTransistorNodes[i].getFunction(), 0, true, tmpVar, 9));\n tmp.add(makeNodeInst(scalableTransistorNodes[i], scalableTransistorNodes[i].getFunction(), 0, true, tmpVar, 9)); \n nodeGroups[count][i+1] = tmp;\n }\n count++;\n for (int i = 0; i < metalWellContactNodes.length; i++)\n {\n String tmpVar = shortNames[i]+\"Well\";\n nodeGroups[count][i+1] = makeNodeInst(metalWellContactNodes[i], metalWellContactNodes[i].getFunction(),\n 0, true, tmpVar, 5.5);\n }\n for (int i = 0; i < rpoResistorNodes.length; i++)\n {\n String tmpVar = shortNames[i]+\"R\";\n tmp = new ArrayList(1);\n tmp.add(makeNodeInst(rpoResistorNodes[i], rpoResistorNodes[i].getFunction(), 0, true, tmpVar, 10));\n nodeGroups[i][0] = tmp;\n }\n for (int i = 0; i < activeArcs.length; i++)\n {\n nodeGroups[++count][0] = activeArcs[i];\n nodeGroups[count][1] = activePinNodes[i];\n String tmpVar = shortNames[i]+\"Act\";\n nodeGroups[count][2] = makeNodeInst(metalActiveContactNodes[i], metalActiveContactNodes[i].getFunction(),\n 0, true, tmpVar, 5.55);\n }\n nodeGroups[++count][0] = poly1_arc;\n nodeGroups[count][1] = poly1Pin_node;\n nodeGroups[count][2] = metal1Poly1Contact_node;\n for (int i = 0; i < metalArcs.length; i++)\n {\n nodeGroups[++count][0] = metalArcs[i];\n nodeGroups[count][1] = metalPinNodes[i];\n nodeGroups[count][2] = (i < metalArcs.length - 1) ? metalContactNodes[i] : null;\n }\n nodeGroups[++count][0] = \"Pure\";\n nodeGroups[count][1] = \"Misc.\";\n nodeGroups[count][2] = \"Cell\";\n\t}\n", "output": "\tprivate MoCMOS()\n\t{\n\t\tsuper(\"mocmos\");\n\t\tsetTechShortName(\"MOSIS CMOS\");\n\t\tsetTechDesc(\"MOSIS CMOS\");\n\t\tsetFactoryScale(200, true);\t\t\t\n\t\tsetNoNegatedArcs();\n\t\tsetStaticTechnology();\n\t\tsetFactoryTransparentLayers(new Color []\n\t\t{\n\t\t\tnew Color( 96,209,255), \n\t\t\tnew Color(255,155,192), \n\t\t\tnew Color(107,226, 96), \n\t\t\tnew Color(224, 95,255), \n\t\t\tnew Color(247,251, 20) \n\t\t});\n setFactoryResolution(0.01); \n foundries.add(new Foundry(Foundry.MOSIS_FOUNDRY, DRCTemplate.MOSIS));\n foundries.add(new Foundry(\"TSMC\", DRCTemplate.TSMC));\n setFactorySelecedFound(Foundry.MOSIS_FOUNDRY); \n Layer[] metalLayers = new Layer[6]; \n\t\tmetalLayers[0] = Layer.newInstance(this, \"Metal-1\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_1, 96,209,255, 0.8,true,\n\t\t\tnew int[] { 0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000}));\n\t\tmetalLayers[1] = Layer.newInstance(this, \"Metal-2\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_4, 224,95,255, 0.7,true,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tmetalLayers[2] = Layer.newInstance(this, \"Metal-3\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_5, 247,251,20, 0.6,true,\n\t\t\tnew int[] { 0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000}));\n\t\tmetalLayers[3] = Layer.newInstance(this, \"Metal-4\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 150,150,255, 0.5,true,\n\t\t\tnew int[] { 0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000}));\n\t\tmetalLayers[4] = Layer.newInstance(this, \"Metal-5\",\n\t\t\tnew EGraphics(EGraphics.OUTLINEPAT, EGraphics.OUTLINEPAT, 0, 255,190,6, 0.4,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444}));\n\t\tmetalLayers[5] = Layer.newInstance(this, \"Metal-6\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 0,255,255, 0.3,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111}));\n\t\tpoly1_lay = Layer.newInstance(this, \"Polysilicon-1\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 255,155,192, 0.5,true,\n\t\t\tnew int[] { 0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555}));\n\t\tLayer poly2_lay = Layer.newInstance(this, \"Polysilicon-2\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,190,6, 1.0,true,\n\t\t\tnew int[] { 0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888}));\n Layer[] activeLayers = new Layer[2];\n\t\tactiveLayers[P_TYPE] = Layer.newInstance(this, \"P-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 0.5,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tactiveLayers[N_TYPE] = Layer.newInstance(this, \"N-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 0.5,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n Layer[] selectLayers = new Layer[2];\n\t\tselectLayers[P_TYPE] = Layer.newInstance(this, \"P-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 0.2,false,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tselectLayers[N_TYPE] = Layer.newInstance(this, \"N-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 0.2,false,\n\t\t\tnew int[] { 0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000}));\n Layer[] wellLayers = new Layer[2];\n\t\twellLayers[P_TYPE] = Layer.newInstance(this, \"P-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 0.2,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404}));\n\t\twellLayers[N_TYPE] = Layer.newInstance(this, \"N-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 0.2,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer polyCutLayer = Layer.newInstance(this, \"Poly-Cut\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 100,100,100, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer activeCut_lay = Layer.newInstance(this, \"Active-Cut\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 100,100,100, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via1_lay = Layer.newInstance(this, \"Via1\", \n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via2_lay = Layer.newInstance(this, \"Via2\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via3_lay = Layer.newInstance(this, \"Via3\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via4_lay = Layer.newInstance(this, \"Via4\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer via5_lay = Layer.newInstance(this, \"Via5\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 180,180,180, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer passivation_lay = Layer.newInstance(this, \"Passivation\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 100,100,100, 1.0,true,\n\t\t\tnew int[] { 0x1C1C, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x3636, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x1C1C, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1C1C, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x3636, \n\t\t\t\t\t\t0x3E3E, \n\t\t\t\t\t\t0x1C1C, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0000}));\n\t\ttransistorPoly_lay = Layer.newInstance(this, \"Transistor-Poly\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 255,155,192, 0.5,true,\n\t\t\tnew int[] { 0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555}));\n\t\tLayer polyCap_lay = Layer.newInstance(this, \"Poly-Cap\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.SOLID, 0, 0,0,0, 1.0,true,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tLayer pActiveWell_lay = Layer.newInstance(this, \"P-Active-Well\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 1.0,false,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tLayer silicideBlock_lay = Layer.newInstance(this, \"Silicide-Block\",\n new EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 192,255,255, 0.5,true,\n new int[] { 0x1010, \n 0x2828, \n 0x4444, \n 0x8282, \n 0x0101, \n 0x0000, \n 0x0000, \n 0x0000, \n 0x1010, \n 0x2828, \n 0x4444, \n 0x8282, \n 0x0101, \n 0x0000, \n 0x0000, \n 0x0000}));\n\t\tLayer thickActive_lay = Layer.newInstance(this, \"Thick-Active\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 0,0,0, 1.0,false,\n\t\t\tnew int[] { 0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020}));\n\t\tLayer pseudoMetal1_lay = Layer.newInstance(this, \"Pseudo-Metal-1\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_1, 96,209,255, 0.8,true,\n\t\t\tnew int[] { 0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer pseudoMetal2_lay = Layer.newInstance(this, \"Pseudo-Metal-2\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_4, 224,95,255, 0.7,true,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tLayer pseudoMetal3_lay = Layer.newInstance(this, \"Pseudo-Metal-3\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_5, 247,251,20, 0.6,true,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tLayer pseudoMetal4_lay = Layer.newInstance(this, \"Pseudo-Metal-4\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 150,150,255, 0.5,true,\n\t\t\tnew int[] { 0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer pseudoMetal5_lay = Layer.newInstance(this, \"Pseudo-Metal-5\",\n\t\t\tnew EGraphics(EGraphics.OUTLINEPAT, EGraphics.OUTLINEPAT, 0, 255,190,6, 0.4,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x4444}));\n\t\tLayer pseudoMetal6_lay = Layer.newInstance(this, \"Pseudo-Metal-6\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 0,255,255, 0.3,true,\n\t\t\tnew int[] { 0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0x4444, \n\t\t\t\t\t\t0x2222, \n\t\t\t\t\t\t0x1111}));\n\t\tLayer pseudoPoly1_lay = Layer.newInstance(this, \"Pseudo-Polysilicon\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_2, 255,155,192, 1.0,true,\n\t\t\tnew int[] { 0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0xFFFF, \n\t\t\t\t\t\t0x1111, \n\t\t\t\t\t\t0x5555}));\n\t\tLayer pseudoPoly2_lay = Layer.newInstance(this, \"Pseudo-Electrode\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,190,6, 1.0,true,\n\t\t\tnew int[] { 0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xAFAF, \n\t\t\t\t\t\t0x8888, \n\t\t\t\t\t\t0xFAFA, \n\t\t\t\t\t\t0x8888}));\n\t\tLayer pseudoPActive_lay = Layer.newInstance(this, \"Pseudo-P-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 1.0,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tLayer pseudoNActive_lay = Layer.newInstance(this, \"Pseudo-N-Active\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, EGraphics.TRANSPARENT_3, 107,226,96, 1.0,true,\n\t\t\tnew int[] { 0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x4848, \n\t\t\t\t\t\t0x0303, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x3030, \n\t\t\t\t\t\t0x8484, \n\t\t\t\t\t\t0x3030}));\n\t\tLayer pseudoPSelect_lay = Layer.newInstance(this, \"Pseudo-P-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 1.0,false,\n\t\t\tnew int[] { 0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0808}));\n\t\tLayer pseudoNSelect_lay = Layer.newInstance(this, \"Pseudo-N-Select\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 255,255,0, 1.0,false,\n\t\t\tnew int[] { 0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer pseudoPWell_lay = Layer.newInstance(this, \"Pseudo-P-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 1.0,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0101, \n\t\t\t\t\t\t0x8080, \n\t\t\t\t\t\t0x4040, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x1010, \n\t\t\t\t\t\t0x0808, \n\t\t\t\t\t\t0x0404}));\n\t\tLayer pseudoNWell_lay = Layer.newInstance(this, \"Pseudo-N-Well\",\n\t\t\tnew EGraphics(EGraphics.PATTERNED, EGraphics.PATTERNED, 0, 139,99,46, 1.0,false,\n\t\t\tnew int[] { 0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x0202, \n\t\t\t\t\t\t0x0000, \n\t\t\t\t\t\t0x2020, \n\t\t\t\t\t\t0x0000}));\n\t\tLayer padFrame_lay = Layer.newInstance(this, \"Pad-Frame\",\n\t\t\tnew EGraphics(EGraphics.SOLID, EGraphics.PATTERNED, 0, 255,0,0, 1.0,false,\n\t\t\tnew int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}));\n\t\tmetalLayers[0].setFunction(Layer.Function.METAL1);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[1].setFunction(Layer.Function.METAL2);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[2].setFunction(Layer.Function.METAL3);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[3].setFunction(Layer.Function.METAL4);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[4].setFunction(Layer.Function.METAL5);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[5].setFunction(Layer.Function.METAL6);\t\t\t\t\t\t\t\t\t\n\t\tpoly1_lay.setFunction(Layer.Function.POLY1);\t\t\t\t\t\t\t\t\t\n\t\tpoly2_lay.setFunction(Layer.Function.POLY2);\t\t\t\t\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFunction(Layer.Function.DIFFP);\t\t\t\t\t\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFunction(Layer.Function.DIFFN);\t\t\t\t\t\t\t\t\t\n\t\tselectLayers[P_TYPE].setFunction(Layer.Function.IMPLANTP);\t\t\t\t\t\t\t\t\n\t\tselectLayers[N_TYPE].setFunction(Layer.Function.IMPLANTN);\t\t\t\t\t\t\t\t\n\t\twellLayers[P_TYPE].setFunction(Layer.Function.WELLP);\t\t\t\t\t\t\t\t\t\n\t\twellLayers[N_TYPE].setFunction(Layer.Function.WELLN);\t\t\t\t\t\t\t\t\t\n\t\tpolyCutLayer.setFunction(Layer.Function.CONTACT1, Layer.Function.CONPOLY);\t\t\n\t\tactiveCut_lay.setFunction(Layer.Function.CONTACT1, Layer.Function.CONDIFF);\t\t\n\t\tvia1_lay.setFunction(Layer.Function.CONTACT2, Layer.Function.CONMETAL);\t\t\t\n\t\tvia2_lay.setFunction(Layer.Function.CONTACT3, Layer.Function.CONMETAL);\t\t\t\n\t\tvia3_lay.setFunction(Layer.Function.CONTACT4, Layer.Function.CONMETAL);\t\t\t\n\t\tvia4_lay.setFunction(Layer.Function.CONTACT5, Layer.Function.CONMETAL);\t\t\t\n\t\tvia5_lay.setFunction(Layer.Function.CONTACT6, Layer.Function.CONMETAL);\t\t\t\n\t\tpassivation_lay.setFunction(Layer.Function.OVERGLASS);\t\t\t\t\t\t\t\n\t\ttransistorPoly_lay.setFunction(Layer.Function.GATE);\t\t\t\t\t\t\t\n\t\tpolyCap_lay.setFunction(Layer.Function.CAP);\t\t\t\t\t\t\t\t\t\n\t\tpActiveWell_lay.setFunction(Layer.Function.DIFFP);\t\t\t\t\t\t\t\t\n\t\tsilicideBlock_lay.setFunction(Layer.Function.ART);\t\t\t\t\t\t\t\t\n\t\tthickActive_lay.setFunction(Layer.Function.DIFF, Layer.Function.THICK);\t\t\t\n\t\tpseudoMetal1_lay.setFunction(Layer.Function.METAL1, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal2_lay.setFunction(Layer.Function.METAL2, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal3_lay.setFunction(Layer.Function.METAL3, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal4_lay.setFunction(Layer.Function.METAL4, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal5_lay.setFunction(Layer.Function.METAL5, Layer.Function.PSEUDO);\t\t\n\t\tpseudoMetal6_lay.setFunction(Layer.Function.METAL6, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPoly1_lay.setFunction(Layer.Function.POLY1, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPoly2_lay.setFunction(Layer.Function.POLY2, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPActive_lay.setFunction(Layer.Function.DIFFP, Layer.Function.PSEUDO);\t\t\n\t\tpseudoNActive_lay.setFunction(Layer.Function.DIFFN, Layer.Function.PSEUDO);\t\t\n\t\tpseudoPSelect_lay.setFunction(Layer.Function.IMPLANTP, Layer.Function.PSEUDO);\t\n\t\tpseudoNSelect_lay.setFunction(Layer.Function.IMPLANTN, Layer.Function.PSEUDO);\t\n\t\tpseudoPWell_lay.setFunction(Layer.Function.WELLP, Layer.Function.PSEUDO);\t\t\n\t\tpseudoNWell_lay.setFunction(Layer.Function.WELLN, Layer.Function.PSEUDO);\t\t\n\t\tpadFrame_lay.setFunction(Layer.Function.ART);\t\t\t\t\t\t\t\t\t\n\t\tmetalLayers[0].setFactoryCIFLayer(\"CMF\");\t\t\t\t\n\t\tmetalLayers[1].setFactoryCIFLayer(\"CMS\");\t\t\t\t\n\t\tmetalLayers[2].setFactoryCIFLayer(\"CMT\");\t\t\t\t\n\t\tmetalLayers[3].setFactoryCIFLayer(\"CMQ\");\t\t\t\t\n\t\tmetalLayers[4].setFactoryCIFLayer(\"CMP\");\t\t\t\t\n\t\tmetalLayers[5].setFactoryCIFLayer(\"CM6\");\t\t\t\t\n\t\tpoly1_lay.setFactoryCIFLayer(\"CPG\");\t\t\t\t\n\t\tpoly2_lay.setFactoryCIFLayer(\"CEL\");\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFactoryCIFLayer(\"CAA\");\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactoryCIFLayer(\"CAA\");\t\t\t\t\n\t\tselectLayers[P_TYPE].setFactoryCIFLayer(\"CSP\");\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactoryCIFLayer(\"CSN\");\t\t\t\t\n\t\twellLayers[P_TYPE].setFactoryCIFLayer(\"CWP\");\t\t\t\t\n\t\twellLayers[N_TYPE].setFactoryCIFLayer(\"CWN\");\t\t\t\t\n\t\tpolyCutLayer.setFactoryCIFLayer(\"CCC\");\t\t\t\t\n\t\tactiveCut_lay.setFactoryCIFLayer(\"CCC\");\t\t\t\n\t\tvia1_lay.setFactoryCIFLayer(\"CVA\");\t\t\t\t\t\n\t\tvia2_lay.setFactoryCIFLayer(\"CVS\");\t\t\t\t\t\n\t\tvia3_lay.setFactoryCIFLayer(\"CVT\");\t\t\t\t\t\n\t\tvia4_lay.setFactoryCIFLayer(\"CVQ\");\t\t\t\t\t\n\t\tvia5_lay.setFactoryCIFLayer(\"CV5\");\t\t\t\t\t\n\t\tpassivation_lay.setFactoryCIFLayer(\"COG\");\t\t\t\n\t\ttransistorPoly_lay.setFactoryCIFLayer(\"CPG\");\t\t\n\t\tpolyCap_lay.setFactoryCIFLayer(\"CPC\");\t\t\t\t\n\t\tpActiveWell_lay.setFactoryCIFLayer(\"CAA\");\t\t\t\n\t\tsilicideBlock_lay.setFactoryCIFLayer(\"CSB\");\t\t\n\t\tthickActive_lay.setFactoryCIFLayer(\"CTA\");\t\t\t\n\t\tpseudoMetal1_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal2_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal3_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal4_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal5_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoMetal6_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoPoly1_lay.setFactoryCIFLayer(\"\");\t\t\t\t\n\t\tpseudoPoly2_lay.setFactoryCIFLayer(\"\");\t\t\t\t\n\t\tpseudoPActive_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoNActive_lay.setFactoryCIFLayer(\"\");\t\t\t\n\t\tpseudoPSelect_lay.setFactoryCIFLayer(\"CSP\");\t\t\n\t\tpseudoNSelect_lay.setFactoryCIFLayer(\"CSN\");\t\t\n\t\tpseudoPWell_lay.setFactoryCIFLayer(\"CWP\");\t\t\t\n\t\tpseudoNWell_lay.setFactoryCIFLayer(\"CWN\");\t\t\t\n\t\tpadFrame_lay.setFactoryCIFLayer(\"XP\");\t\t\t\t\n\t\tmetalLayers[0].setFactoryGDSLayer(\"49, 80p, 80t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[0].setFactoryGDSLayer(\"16\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[1].setFactoryGDSLayer(\"51, 82p, 82t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[1].setFactoryGDSLayer(\"18\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[2].setFactoryGDSLayer(\"62, 93p, 93t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[2].setFactoryGDSLayer(\"28\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[3].setFactoryGDSLayer(\"31, 63p, 63t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[3].setFactoryGDSLayer(\"31\", Foundry.TSMC_FOUNDRY);\n\t\tmetalLayers[4].setFactoryGDSLayer(\"33, 64p, 64t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[4].setFactoryGDSLayer(\"33\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[5].setFactoryGDSLayer(\"37, 68p, 68t\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n metalLayers[5].setFactoryGDSLayer(\"38\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tpoly1_lay.setFactoryGDSLayer(\"46\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n poly1_lay.setFactoryGDSLayer(\"13\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\ttransistorPoly_lay.setFactoryGDSLayer(\"46\", Foundry.MOSIS_FOUNDRY);\t\t\n transistorPoly_lay.setFactoryGDSLayer(\"13\", Foundry.TSMC_FOUNDRY);\t\t\n\t\tpoly2_lay.setFactoryGDSLayer(\"56\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFactoryGDSLayer(\"43\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n activeLayers[P_TYPE].setFactoryGDSLayer(\"3\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactoryGDSLayer(\"43\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n activeLayers[N_TYPE].setFactoryGDSLayer(\"3\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tpActiveWell_lay.setFactoryGDSLayer(\"43\", Foundry.MOSIS_FOUNDRY);\t\t\t\n pActiveWell_lay.setFactoryGDSLayer(\"3\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tselectLayers[P_TYPE].setFactoryGDSLayer(\"44\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n selectLayers[P_TYPE].setFactoryGDSLayer(\"7\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactoryGDSLayer(\"45\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n selectLayers[N_TYPE].setFactoryGDSLayer(\"8\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\twellLayers[P_TYPE].setFactoryGDSLayer(\"41\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n wellLayers[P_TYPE].setFactoryGDSLayer(\"41\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\twellLayers[N_TYPE].setFactoryGDSLayer(\"42\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n wellLayers[N_TYPE].setFactoryGDSLayer(\"2\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tpolyCutLayer.setFactoryGDSLayer(\"25\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n polyCutLayer.setFactoryGDSLayer(\"15\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tactiveCut_lay.setFactoryGDSLayer(\"25\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tactiveCut_lay.setFactoryGDSLayer(\"15\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tvia1_lay.setFactoryGDSLayer(\"50\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via1_lay.setFactoryGDSLayer(\"17\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia2_lay.setFactoryGDSLayer(\"61\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via2_lay.setFactoryGDSLayer(\"27\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia3_lay.setFactoryGDSLayer(\"30\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via3_lay.setFactoryGDSLayer(\"29\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia4_lay.setFactoryGDSLayer(\"32\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via4_lay.setFactoryGDSLayer(\"32\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tvia5_lay.setFactoryGDSLayer(\"36\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\t\n via5_lay.setFactoryGDSLayer(\"39\", Foundry.TSMC_FOUNDRY);\t\t\t\t\t\n\t\tpassivation_lay.setFactoryGDSLayer(\"52\", Foundry.MOSIS_FOUNDRY);\t\t\t\n passivation_lay.setFactoryGDSLayer(\"19\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tpolyCap_lay.setFactoryGDSLayer(\"28\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n polyCap_lay.setFactoryGDSLayer(\"28\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tsilicideBlock_lay.setFactoryGDSLayer(\"29\", Foundry.MOSIS_FOUNDRY);\t\t\t\n silicideBlock_lay.setFactoryGDSLayer(\"34\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tthickActive_lay.setFactoryGDSLayer(\"60\", Foundry.MOSIS_FOUNDRY);\t\t\t\n thickActive_lay.setFactoryGDSLayer(\"4\", Foundry.TSMC_FOUNDRY);\t\t\t\n\t\tpseudoMetal1_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal2_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal3_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal4_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal5_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoMetal6_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoPoly1_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpseudoPoly2_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpseudoPActive_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoNActive_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoPSelect_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoNSelect_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\n\t\tpseudoPWell_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpseudoNWell_lay.setFactoryGDSLayer(\"\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n\t\tpadFrame_lay.setFactoryGDSLayer(\"26\", Foundry.MOSIS_FOUNDRY);\t\t\t\t\n padFrame_lay.setFactoryGDSLayer(\"26\", Foundry.TSMC_FOUNDRY);\t\t\t\t\n\t\tmetalLayers[0].setFactorySkillLayer(\"metal1\");\t\t\t\n\t\tmetalLayers[1].setFactorySkillLayer(\"metal2\");\t\t\t\n\t\tmetalLayers[2].setFactorySkillLayer(\"metal3\");\t\t\t\n\t\tmetalLayers[3].setFactorySkillLayer(\"metal4\");\t\t\t\n\t\tmetalLayers[4].setFactorySkillLayer(\"metal5\");\t\t\t\n\t\tmetalLayers[5].setFactorySkillLayer(\"metal6\");\t\t\t\n\t\tpoly1_lay.setFactorySkillLayer(\"poly\");\t\t\t\t\n\t\tpoly2_lay.setFactorySkillLayer(\"\");\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setFactorySkillLayer(\"aa\");\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactorySkillLayer(\"aa\");\t\t\t\t\n\t\tselectLayers[P_TYPE].setFactorySkillLayer(\"pplus\");\t\t\t\n\t\tselectLayers[N_TYPE].setFactorySkillLayer(\"nplus\");\t\t\t\n\t\twellLayers[P_TYPE].setFactorySkillLayer(\"pwell\");\t\t\t\n\t\twellLayers[N_TYPE].setFactorySkillLayer(\"nwell\");\t\t\t\n\t\tpolyCutLayer.setFactorySkillLayer(\"pcont\");\t\t\t\n\t\tactiveCut_lay.setFactorySkillLayer(\"acont\");\t\t\n\t\tvia1_lay.setFactorySkillLayer(\"via\");\t\t\t\t\n\t\tvia2_lay.setFactorySkillLayer(\"via2\");\t\t\t\t\n\t\tvia3_lay.setFactorySkillLayer(\"via3\");\t\t\t\t\n\t\tvia4_lay.setFactorySkillLayer(\"via4\");\t\t\t\t\n\t\tvia5_lay.setFactorySkillLayer(\"via5\");\t\t\t\t\n\t\tpassivation_lay.setFactorySkillLayer(\"glasscut\");\t\n\t\ttransistorPoly_lay.setFactorySkillLayer(\"poly\");\t\n\t\tpolyCap_lay.setFactorySkillLayer(\"\");\t\t\t\t\n\t\tpActiveWell_lay.setFactorySkillLayer(\"aa\");\t\t\t\n\t\tsilicideBlock_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tthickActive_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal1_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal2_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal3_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal4_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal5_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoMetal6_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPoly1_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPoly2_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPActive_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoNActive_lay.setFactorySkillLayer(\"\");\t\t\t\n\t\tpseudoPSelect_lay.setFactorySkillLayer(\"pplus\");\t\n\t\tpseudoNSelect_lay.setFactorySkillLayer(\"nplus\");\t\n\t\tpseudoPWell_lay.setFactorySkillLayer(\"pwell\");\t\t\n\t\tpseudoNWell_lay.setFactorySkillLayer(\"nwell\");\t\t\n\t\tpadFrame_lay.setFactorySkillLayer(\"\");\t\t\t\t\n\t\tdouble BULK_LAYER = 10;\n\t\tdouble DIFF_LAYER = 1; \n\t\tdouble ILD_LAYER = 3.5; \n\t\tdouble IMD_LAYER = 5.65; \n\t\tdouble METAL_LAYER = 2.65; \n\t\tactiveLayers[P_TYPE].setFactory3DInfo(0.85, BULK_LAYER + 2*DIFF_LAYER);\t\t\t\t\n\t\tactiveLayers[N_TYPE].setFactory3DInfo(0.8, BULK_LAYER + 2*DIFF_LAYER);\t\t\t\t\n\t\tselectLayers[P_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER + DIFF_LAYER);\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER + DIFF_LAYER);\t\t\t\t\n\t\twellLayers[P_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER);\t\t\t\t\t\n\t\twellLayers[N_TYPE].setFactory3DInfo(DIFF_LAYER, BULK_LAYER);\t\t\t\t\t\n pActiveWell_lay.setFactory3DInfo(0.85, BULK_LAYER + 2*DIFF_LAYER);\t\t\t\n thickActive_lay.setFactory3DInfo(0.5, BULK_LAYER + 0.5);\t\t\t\n\t\tmetalLayers[0].setFactory3DInfo(METAL_LAYER, ILD_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\t\t\n\t\tmetalLayers[1].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[0].getDistance());\t\t\t\t\t\n\t\tvia1_lay.setFactory3DInfo(metalLayers[1].getDistance()-metalLayers[0].getDepth(), metalLayers[0].getDepth());\t\t\t\t\t\n\t\tmetalLayers[2].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[1].getDistance());\t\t\t\t\t\n\t\tvia2_lay.setFactory3DInfo(metalLayers[2].getDistance()-metalLayers[1].getDepth(), metalLayers[1].getDepth());\t\t\t\t\t\n\t\tmetalLayers[3].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[2].getDistance());\t\t\t\t\t\n via3_lay.setFactory3DInfo(metalLayers[3].getDistance()-metalLayers[2].getDepth(), metalLayers[2].getDepth());\t\t\t\t\t\n\t\tmetalLayers[4].setFactory3DInfo(METAL_LAYER, IMD_LAYER + metalLayers[3].getDistance());\t\t\t\t\t\n\t\tvia4_lay.setFactory3DInfo(metalLayers[4].getDistance()-metalLayers[3].getDepth(), metalLayers[3].getDepth());\t\t\t\t\t\n\t\tmetalLayers[5].setFactory3DInfo(4.95, IMD_LAYER + metalLayers[4].getDistance());\t\t\t\t\t\n via5_lay.setFactory3DInfo(metalLayers[5].getDistance()-metalLayers[4].getDepth(), metalLayers[4].getDepth());\t\t\t\t\t\n\t\tdouble PASS_LAYER = 5; \n\t\tdouble PO_LAYER = 1; \n\t\tdouble FOX_LAYER = 1.75; \n\t\tdouble TOX_LAYER = 0; \n\t\tpseudoMetal1_lay.setFactory3DInfo(0, metalLayers[0].getDistance());\t\t\t\n\t\tpseudoMetal2_lay.setFactory3DInfo(0, metalLayers[1].getDistance());\t\t\t\n\t\tpseudoMetal3_lay.setFactory3DInfo(0, metalLayers[2].getDistance());\t\t\t\n\t\tpseudoMetal4_lay.setFactory3DInfo(0, metalLayers[3].getDistance());\t\t\t\n\t\tpseudoMetal5_lay.setFactory3DInfo(0, metalLayers[4].getDistance());\t\t\t\n\t\tpseudoMetal6_lay.setFactory3DInfo(0, metalLayers[5].getDistance());\t\t\t\n\t\tpoly1_lay.setFactory3DInfo(PO_LAYER, FOX_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\t\t\n\t\ttransistorPoly_lay.setFactory3DInfo(PO_LAYER, TOX_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\n poly2_lay.setFactory3DInfo(PO_LAYER, transistorPoly_lay.getDepth());\t\t\t\t\t\n\t\tpolyCap_lay.setFactory3DInfo(PO_LAYER, FOX_LAYER + activeLayers[P_TYPE].getDepth());\t\t\t\t\n\t\tpolyCutLayer.setFactory3DInfo(metalLayers[0].getDistance()-poly1_lay.getDepth(), poly1_lay.getDepth());\t\t\t\t\n\t\tactiveCut_lay.setFactory3DInfo(metalLayers[0].getDistance()-activeLayers[N_TYPE].getDepth(), activeLayers[N_TYPE].getDepth());\t\t\t\t\n\t\tpassivation_lay.setFactory3DInfo(PASS_LAYER, metalLayers[5].getDepth());\t\t\t\n\t\tsilicideBlock_lay.setFactory3DInfo(0, BULK_LAYER);\t\t\t\n\t\tpadFrame_lay.setFactory3DInfo(0, passivation_lay.getDepth());\t\t\t\t\n\t\tpseudoPoly1_lay.setFactory3DInfo(0, poly1_lay.getDistance());\t\t\t\n\t\tpseudoPoly2_lay.setFactory3DInfo(0, poly2_lay.getDistance());\t\t\t\n\t\tpseudoPActive_lay.setFactory3DInfo(0, activeLayers[P_TYPE].getDistance());\t\t\t\n\t\tpseudoNActive_lay.setFactory3DInfo(0, activeLayers[N_TYPE].getDistance());\t\t\t\n\t\tpseudoPSelect_lay.setFactory3DInfo(0, selectLayers[P_TYPE].getDistance());\t\t\t\n\t\tpseudoNSelect_lay.setFactory3DInfo(0, selectLayers[N_TYPE].getDistance());\t\t\t\n\t\tpseudoPWell_lay.setFactory3DInfo(0, wellLayers[P_TYPE].getDistance());\t\t\t\t\n\t\tpseudoNWell_lay.setFactory3DInfo(0, wellLayers[N_TYPE].getDistance());\t\t\t\t\n\t\tmetalLayers[0].setFactoryParasitics(0.078, 0.1209, 0.1104);\t\t\t\n\t\tmetalLayers[1].setFactoryParasitics(0.078, 0.0843, 0.0974);\t\t\t\n\t\tmetalLayers[2].setFactoryParasitics(0.078, 0.0843, 0.0974);\t\t\t\n\t\tmetalLayers[3].setFactoryParasitics(0.078, 0.0843, 0.0974);\t\t\t\n\t\tmetalLayers[4].setFactoryParasitics(0.078, 0.0843, 0.0974);\t\t\t\n\t\tmetalLayers[5].setFactoryParasitics(0.036, 0.0423, 0.1273);\t\t\t\n\t\tpoly1_lay.setFactoryParasitics(6.2, 0.1467, 0.0608);\t\t\t\n\t\tpoly2_lay.setFactoryParasitics(50.0, 1.0, 0);\t\t\t\n\t\tactiveLayers[P_TYPE].setFactoryParasitics(2.5, 0.9, 0);\t\t\t\n\t\tactiveLayers[N_TYPE].setFactoryParasitics(3.0, 0.9, 0);\t\t\t\n\t\tselectLayers[P_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tselectLayers[N_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\twellLayers[P_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\twellLayers[N_TYPE].setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tpolyCutLayer.setFactoryParasitics(2.2, 0, 0);\t\t\t\n\t\tactiveCut_lay.setFactoryParasitics(2.5, 0, 0);\t\t\t\n\t\tvia1_lay.setFactoryParasitics(1.0, 0, 0);\t\t\t\t\n\t\tvia2_lay.setFactoryParasitics(0.9, 0, 0);\t\t\t\t\n\t\tvia3_lay.setFactoryParasitics(0.8, 0, 0);\t\t\t\t\n\t\tvia4_lay.setFactoryParasitics(0.8, 0, 0);\t\t\t\t\n\t\tvia5_lay.setFactoryParasitics(0.8, 0, 0);\t\t\t\t\n\t\tpassivation_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\ttransistorPoly_lay.setFactoryParasitics(2.5, 0.09, 0);\t\n\t\tpolyCap_lay.setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tpActiveWell_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tsilicideBlock_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tthickActive_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal1_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal2_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal3_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal4_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal5_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoMetal6_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoPoly1_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoPoly2_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoPActive_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoNActive_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoPSelect_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoNSelect_lay.setFactoryParasitics(0, 0, 0);\t\t\n\t\tpseudoPWell_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpseudoNWell_lay.setFactoryParasitics(0, 0, 0);\t\t\t\n\t\tpadFrame_lay.setFactoryParasitics(0, 0, 0);\t\t\t\t\n\t\tsetFactoryParasitics(4, 0.1);\n\t\tString [] headerLevel1 =\n\t\t{\n\t\t\t\"*CMOS/BULK-NWELL (PRELIMINARY PARAMETERS)\",\n\t\t\t\".OPTIONS NOMOD DEFL=3UM DEFW=3UM DEFAD=70P DEFAS=70P LIMPTS=1000\",\n\t\t\t\"+ITL5=0 RELTOL=0.01 ABSTOL=500PA VNTOL=500UV LVLTIM=2\",\n\t\t\t\"+LVLCOD=1\",\n\t\t\t\".MODEL N NMOS LEVEL=1\",\n\t\t\t\"+KP=60E-6 VTO=0.7 GAMMA=0.3 LAMBDA=0.05 PHI=0.6\",\n\t\t\t\"+LD=0.4E-6 TOX=40E-9 CGSO=2.0E-10 CGDO=2.0E-10 CJ=.2MF/M^2\",\n\t\t\t\".MODEL P PMOS LEVEL=1\",\n\t\t\t\"+KP=20E-6 VTO=0.7 GAMMA=0.4 LAMBDA=0.05 PHI=0.6\",\n\t\t\t\"+LD=0.6E-6 TOX=40E-9 CGSO=3.0E-10 CGDO=3.0E-10 CJ=.2MF/M^2\",\n\t\t\t\".MODEL DIFFCAP D CJO=.2MF/M^2\"\n\t\t};\n\t\tsetSpiceHeaderLevel1(headerLevel1);\n\t\tString [] headerLevel2 =\n\t\t{\n\t\t\t\"* MOSIS 3u CMOS PARAMS\",\n\t\t\t\".OPTIONS NOMOD DEFL=2UM DEFW=6UM DEFAD=100P DEFAS=100P\",\n\t\t\t\"+LIMPTS=1000 ITL5=0 ABSTOL=500PA VNTOL=500UV\",\n\t\t\t\"* Note that ITL5=0 sets ITL5 to infinity\",\n\t\t\t\".MODEL N NMOS LEVEL=2 LD=0.3943U TOX=502E-10\",\n\t\t\t\"+NSUB=1.22416E+16 VTO=0.756 KP=4.224E-05 GAMMA=0.9241\",\n\t\t\t\"+PHI=0.6 UO=623.661 UEXP=8.328627E-02 UCRIT=54015.0\",\n\t\t\t\"+DELTA=5.218409E-03 VMAX=50072.2 XJ=0.4U LAMBDA=2.975321E-02\",\n\t\t\t\"+NFS=4.909947E+12 NEFF=1.001E-02 NSS=0.0 TPG=1.0\",\n\t\t\t\"+RSH=20.37 CGDO=3.1E-10 CGSO=3.1E-10\",\n\t\t\t\"+CJ=3.205E-04 MJ=0.4579 CJSW=4.62E-10 MJSW=0.2955 PB=0.7\",\n\t\t\t\".MODEL P PMOS LEVEL=2 LD=0.2875U TOX=502E-10\",\n\t\t\t\"+NSUB=1.715148E+15 VTO=-0.7045 KP=1.686E-05 GAMMA=0.3459\",\n\t\t\t\"+PHI=0.6 UO=248.933 UEXP=1.02652 UCRIT=182055.0\",\n\t\t\t\"+DELTA=1.0E-06 VMAX=100000.0 XJ=0.4U LAMBDA=1.25919E-02\",\n\t\t\t\"+NFS=1.0E+12 NEFF=1.001E-02 NSS=0.0 TPG=-1.0\",\n\t\t\t\"+RSH=79.10 CGDO=2.89E-10 CGSO=2.89E-10\",\n\t\t\t\"+CJ=1.319E-04 MJ=0.4125 CJSW=3.421E-10 MJSW=0.198 PB=0.66\",\n\t\t\t\".TEMP 25.0\"\n\t\t};\n\t\tsetSpiceHeaderLevel2(headerLevel2);\n\t\tmetalArcs[0] = ArcProto.newInstance(this, \"Metal-1\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[0], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[0].setFunction(ArcProto.Function.METAL1);\n\t\tmetalArcs[0].setFactoryFixedAngle(true);\n\t\tmetalArcs[0].setWipable();\n\t\tmetalArcs[0].setFactoryAngleIncrement(90);\n\t\tmetalArcs[1] = ArcProto.newInstance(this, \"Metal-2\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[1], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[1].setFunction(ArcProto.Function.METAL2);\n\t\tmetalArcs[1].setFactoryFixedAngle(true);\n\t\tmetalArcs[1].setWipable();\n\t\tmetalArcs[1].setFactoryAngleIncrement(90);\n\t\tmetalArcs[2] = ArcProto.newInstance(this, \"Metal-3\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[2], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[2].setFunction(ArcProto.Function.METAL3);\n\t\tmetalArcs[2].setFactoryFixedAngle(true);\n\t\tmetalArcs[2].setWipable();\n\t\tmetalArcs[2].setFactoryAngleIncrement(90);\n\t\tmetalArcs[3] = ArcProto.newInstance(this, \"Metal-4\", 6.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[3], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[3].setFunction(ArcProto.Function.METAL4);\n\t\tmetalArcs[3].setFactoryFixedAngle(true);\n\t\tmetalArcs[3].setWipable();\n\t\tmetalArcs[3].setFactoryAngleIncrement(90);\n\t\tmetalArcs[4] = ArcProto.newInstance(this, \"Metal-5\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[4], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[4].setFunction(ArcProto.Function.METAL5);\n\t\tmetalArcs[4].setFactoryFixedAngle(true);\n\t\tmetalArcs[4].setWipable();\n\t\tmetalArcs[4].setFactoryAngleIncrement(90);\n\t\tmetalArcs[5] = ArcProto.newInstance(this, \"Metal-6\", 4.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(metalLayers[5], 0, Poly.Type.FILLED)\n\t\t});\n\t\tmetalArcs[5].setFunction(ArcProto.Function.METAL6);\n\t\tmetalArcs[5].setFactoryFixedAngle(true);\n\t\tmetalArcs[5].setWipable();\n\t\tmetalArcs[5].setFactoryAngleIncrement(90);\n\t\tpoly1_arc = ArcProto.newInstance(this, \"Polysilicon-1\", 2.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(poly1_lay, 0, Poly.Type.FILLED)\n\t\t});\n\t\tpoly1_arc.setFunction(ArcProto.Function.POLY1);\n\t\tpoly1_arc.setFactoryFixedAngle(true);\n\t\tpoly1_arc.setWipable();\n\t\tpoly1_arc.setFactoryAngleIncrement(90);\n\t\tpoly2_arc = ArcProto.newInstance(this, \"Polysilicon-2\", 7.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(poly2_lay, 0, Poly.Type.FILLED)\n\t\t});\n\t\tpoly2_arc.setFunction(ArcProto.Function.POLY2);\n\t\tpoly2_arc.setFactoryFixedAngle(true);\n\t\tpoly2_arc.setWipable();\n\t\tpoly2_arc.setFactoryAngleIncrement(90);\n\t\tpoly2_arc.setNotUsed();\n\t\tactiveArcs[P_TYPE] = ArcProto.newInstance(this, \"P-Active\", 15.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(activeLayers[P_TYPE], 12, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(selectLayers[P_TYPE], 8, Poly.Type.FILLED)\n\t\t});\n\t\tactiveArcs[P_TYPE].setFunction(ArcProto.Function.DIFFP);\n\t\tactiveArcs[P_TYPE].setFactoryFixedAngle(true);\n\t\tactiveArcs[P_TYPE].setWipable();\n\t\tactiveArcs[P_TYPE].setFactoryAngleIncrement(90);\n\t\tactiveArcs[P_TYPE].setWidthOffset(12.0);\n\t\tactiveArcs[N_TYPE] = ArcProto.newInstance(this, \"N-Active\", 15.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(activeLayers[N_TYPE], 12, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(selectLayers[N_TYPE], 8, Poly.Type.FILLED)\n\t\t});\n\t\tactiveArcs[N_TYPE].setFunction(ArcProto.Function.DIFFN);\n\t\tactiveArcs[N_TYPE].setFactoryFixedAngle(true);\n\t\tactiveArcs[N_TYPE].setWipable();\n\t\tactiveArcs[N_TYPE].setFactoryAngleIncrement(90);\n\t\tactiveArcs[N_TYPE].setWidthOffset(12.0);\n\t\tactive_arc = ArcProto.newInstance(this, \"Active\", 3.0, new Technology.ArcLayer []\n\t\t{\n\t\t\tnew Technology.ArcLayer(activeLayers[P_TYPE], 0, Poly.Type.FILLED),\n\t\t\tnew Technology.ArcLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED)\n\t\t});\n\t\tactive_arc.setFunction(ArcProto.Function.DIFF);\n\t\tactive_arc.setFactoryFixedAngle(true);\n\t\tactive_arc.setWipable();\n\t\tactive_arc.setFactoryAngleIncrement(90);\n\t\tactive_arc.setNotUsed();\n\t\tmetalPinNodes[0] = PrimitiveNode.newInstance(\"Metal-1-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal1_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[0].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[0], new ArcProto[] {metalArcs[0]}, \"metal-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[0].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[0].setArcsWipe();\n\t\tmetalPinNodes[0].setArcsShrink();\n\t\tmetalPinNodes[1] = PrimitiveNode.newInstance(\"Metal-2-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal2_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[1].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[1], new ArcProto[] {metalArcs[1]}, \"metal-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[1].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[1].setArcsWipe();\n\t\tmetalPinNodes[1].setArcsShrink();\n\t\tmetalPinNodes[2] = PrimitiveNode.newInstance(\"Metal-3-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal3_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[2].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[2], new ArcProto[] {metalArcs[2]}, \"metal-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[2].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[2].setArcsWipe();\n\t\tmetalPinNodes[2].setArcsShrink();\n\t\tmetalPinNodes[3] = PrimitiveNode.newInstance(\"Metal-4-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal4_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[3].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[3], new ArcProto[] {metalArcs[3]}, \"metal-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[3].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[3].setArcsWipe();\n\t\tmetalPinNodes[3].setArcsShrink();\n\t\tmetalPinNodes[4] = PrimitiveNode.newInstance(\"Metal-5-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal5_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[4].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[4], new ArcProto[] {metalArcs[4]}, \"metal-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[4].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[4].setArcsWipe();\n\t\tmetalPinNodes[4].setArcsShrink();\n\t\tmetalPinNodes[4].setNotUsed();\n\t\tmetalPinNodes[5] = PrimitiveNode.newInstance(\"Metal-6-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoMetal6_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetalPinNodes[5].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalPinNodes[5], new ArcProto[] {metalArcs[5]}, \"metal-6\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalPinNodes[5].setFunction(PrimitiveNode.Function.PIN);\n\t\tmetalPinNodes[5].setArcsWipe();\n\t\tmetalPinNodes[5].setArcsShrink();\n\t\tmetalPinNodes[5].setNotUsed();\n\t\tpoly1Pin_node = PrimitiveNode.newInstance(\"Polysilicon-1-Pin\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPoly1_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly1Pin_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly1Pin_node, new ArcProto[] {poly1_arc}, \"polysilicon-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1), EdgeV.fromBottom(1), EdgeH.fromRight(1), EdgeV.fromTop(1))\n\t\t\t});\n\t\tpoly1Pin_node.setFunction(PrimitiveNode.Function.PIN);\n\t\tpoly1Pin_node.setArcsWipe();\n\t\tpoly1Pin_node.setArcsShrink();\n\t\tpoly2Pin_node = PrimitiveNode.newInstance(\"Polysilicon-2-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPoly2_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly2Pin_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly2Pin_node, new ArcProto[] {poly2_arc}, \"polysilicon-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tpoly2Pin_node.setFunction(PrimitiveNode.Function.PIN);\n\t\tpoly2Pin_node.setArcsWipe();\n\t\tpoly2Pin_node.setArcsShrink();\n\t\tpoly2Pin_node.setNotUsed();\n\t\tactivePinNodes[P_TYPE] = PrimitiveNode.newInstance(\"P-Active-Pin\", this, 15.0, 15.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(pseudoNWell_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(pseudoPSelect_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4))\n\t\t\t});\n\t\tactivePinNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activePinNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE]}, \"p-active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromBottom(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7.5))\n\t\t\t});\n\t\tactivePinNodes[P_TYPE].setFunction(PrimitiveNode.Function.PIN);\n\t\tactivePinNodes[P_TYPE].setArcsWipe();\n\t\tactivePinNodes[P_TYPE].setArcsShrink();\n\t\tactivePinNodes[N_TYPE] = PrimitiveNode.newInstance(\"N-Active-Pin\", this, 15.0, 15.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoNActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(pseudoPWell_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(pseudoNSelect_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4))\n\t\t\t});\n\t\tactivePinNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activePinNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE]}, \"n-active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromBottom(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7.5))\n\t\t\t});\n\t\tactivePinNodes[N_TYPE].setFunction(PrimitiveNode.Function.PIN);\n\t\tactivePinNodes[N_TYPE].setArcsWipe();\n\t\tactivePinNodes[N_TYPE].setArcsShrink();\n\t\tactivePin_node = PrimitiveNode.newInstance(\"Active-Pin\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pseudoPActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(pseudoNActive_lay, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tactivePin_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activePin_node, new ArcProto[] {active_arc, activeArcs[P_TYPE], activeArcs[N_TYPE]}, \"active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tactivePin_node.setFunction(PrimitiveNode.Function.PIN);\n\t\tactivePin_node.setArcsWipe();\n\t\tactivePin_node.setArcsShrink();\n activePin_node.setNotUsed();\n\t\tmetalActiveContactNodes[P_TYPE] = PrimitiveNode.newInstance(\"Metal-1-P-Active-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX,Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalActiveContactNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalActiveContactNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE], metalArcs[0]}, \"metal-1-p-act\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalActiveContactNodes[P_TYPE].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalActiveContactNodes[P_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalActiveContactNodes[P_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalActiveContactNodes[P_TYPE].setMinSize(17, 17, \"6.2, 7.3\");\n\t\tmetalActiveContactNodes[N_TYPE] = PrimitiveNode.newInstance(\"Metal-1-N-Active-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalActiveContactNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalActiveContactNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE], metalArcs[0]}, \"metal-1-n-act\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalActiveContactNodes[N_TYPE].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalActiveContactNodes[N_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalActiveContactNodes[N_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalActiveContactNodes[N_TYPE].setMinSize(17, 17, \"6.2, 7.3\");\n\t\tmetal1Poly1Contact_node = PrimitiveNode.newInstance(\"Metal-1-Polysilicon-1-Con\", this, 5.0, 5.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(0.5)),\n\t\t\t\tnew Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5))\n\t\t\t});\n\t\tmetal1Poly1Contact_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Poly1Contact_node, new ArcProto[] {poly1_arc, metalArcs[0]}, \"metal-1-polysilicon-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2), EdgeV.fromBottom(2), EdgeH.fromRight(2), EdgeV.fromTop(2))\n\t\t\t});\n\t\tmetal1Poly1Contact_node.setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetal1Poly1Contact_node.setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetal1Poly1Contact_node.setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetal1Poly1Contact_node.setMinSize(5, 5, \"5.2, 7.3\");\n\t\tmetal1Poly2Contact_node = PrimitiveNode.newInstance(\"Metal-1-Polysilicon-2-Con\", this, 10.0, 10.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(3)),\n\t\t\t\tnew Technology.NodeLayer(poly2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4))\n\t\t\t});\n\t\tmetal1Poly2Contact_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Poly2Contact_node, new ArcProto[] {poly2_arc, metalArcs[0]}, \"metal-1-polysilicon-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(4.5), EdgeV.fromBottom(4.5), EdgeH.fromRight(4.5), EdgeV.fromTop(4.5))\n\t\t\t});\n\t\tmetal1Poly2Contact_node.setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetal1Poly2Contact_node.setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetal1Poly2Contact_node.setSpecialValues(new double [] {2, 2, 4, 4, 3, 3});\n\t\tmetal1Poly2Contact_node.setNotUsed();\n\t\tmetal1Poly2Contact_node.setMinSize(10, 10, \"?\");\n\t\tmetal1Poly12Contact_node = PrimitiveNode.newInstance(\"Metal-1-Polysilicon-1-2-Con\", this, 15.0, 15.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(5.5)),\n\t\t\t\tnew Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(5)),\n\t\t\t\tnew Technology.NodeLayer(poly2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5))\n\t\t\t});\n\t\tmetal1Poly12Contact_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Poly12Contact_node, new ArcProto[] {poly1_arc, poly2_arc, metalArcs[0]}, \"metal-1-polysilicon-1-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(7), EdgeV.fromBottom(7), EdgeH.fromRight(7), EdgeV.fromTop(7))\n\t\t\t});\n\t\tmetal1Poly12Contact_node.setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetal1Poly12Contact_node.setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetal1Poly12Contact_node.setSpecialValues(new double [] {2, 2, 6.5, 6.5, 3, 3});\n\t\tmetal1Poly12Contact_node.setNotUsed();\n\t\tmetal1Poly12Contact_node.setMinSize(15, 15, \"?\");\n String[] stdNames = {\"p\", \"n\"};\n for (int i = 0; i < 2; i++)\n {\n transistorPolyLayers[i] = new Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(4), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromRight(4), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorPolyLLayers[i] = new Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(4), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorPolyRLayers[i] = new Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromRight(4), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorPolyCLayers[i] = new Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(10)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(10))}, 1, 1, 2, 2);\n transistorActiveLayers[i] = new Technology.NodeLayer(activeLayers[i], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(7)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(7))}, 4, 4, 0, 0);\n transistorActiveTLayers[i] = new Technology.NodeLayer(activeLayers[i], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(10)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(7))}, 4, 4, 0, 0);\n transistorActiveBLayers[i] = new Technology.NodeLayer(activeLayers[i], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(7)),\n new Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(10))}, 4, 4, 0, 0);\n transistorWellLayers[i] = new Technology.NodeLayer(wellLayers[(i+1)%transistorNodes.length], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.makeLeftEdge(), EdgeV.fromBottom(1)),\n new Technology.TechPoint(EdgeH.makeRightEdge(), EdgeV.fromTop(1))}, 10, 10, 6, 6);\n transistorSelectLayers[i] = new Technology.NodeLayer(selectLayers[i], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n new Technology.TechPoint(EdgeH.fromLeft(4), EdgeV.fromBottom(5)),\n new Technology.TechPoint(EdgeH.fromRight(4), EdgeV.fromTop(5))}, 6, 6, 2, 2);\n transistorNodes[i] = PrimitiveNode.newInstance(stdNames[i].toUpperCase()+\"-Transistor\", this, 15.0, 22.0, new SizeOffset(6, 6, 10, 10),\n new Technology.NodeLayer [] {transistorActiveLayers[i], transistorPolyLayers[i], transistorWellLayers[i], transistorSelectLayers[i]});\n transistorNodes[i].setElectricalLayers(new Technology.NodeLayer [] {transistorActiveTLayers[i], transistorActiveBLayers[i],\n transistorPolyCLayers[i], transistorPolyLLayers[i], transistorPolyRLayers[i], transistorWellLayers[i], transistorSelectLayers[i]});\n transistorNodes[i].addPrimitivePorts(new PrimitivePort []\n {\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {poly1_arc}, stdNames[i]+\"-trans-poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(4), EdgeV.fromBottom(11), EdgeH.fromLeft(4), EdgeV.fromTop(11)),\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {activeArcs[i]}, stdNames[i]+\"-trans-diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(7.5), EdgeV.fromTop(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7)),\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {poly1_arc}, stdNames[i]+\"-trans-poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n EdgeH.fromRight(4), EdgeV.fromBottom(11), EdgeH.fromRight(4), EdgeV.fromTop(11)),\n PrimitivePort.newInstance(this, transistorNodes[i], new ArcProto[] {activeArcs[i]}, stdNames[i]+\"-trans-diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(7.5), EdgeV.fromBottom(7), EdgeH.fromRight(7.5), EdgeV.fromBottom(7.5))\n });\n transistorNodes[i].setFunction((i==P_TYPE) ? PrimitiveNode.Function.TRAPMOS : PrimitiveNode.Function.TRANMOS);\n transistorNodes[i].setHoldsOutline();\n transistorNodes[i].setCanShrink();\n transistorNodes[i].setSpecialType(PrimitiveNode.SERPTRANS);\n transistorNodes[i].setSpecialValues(new double [] {7, 1.5, 2.5, 2, 1, 2});\n transistorNodes[i].setMinSize(15, 22, \"2.1, 3.1\");\n }\n\t\tString[] thickNames = {\"Thick-P\", \"Thick-N\"};\n\t\tTechnology.NodeLayer[] thickActiveLayers = new Technology.NodeLayer[] {transistorActiveLayers[P_TYPE], transistorActiveLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickPolyLayers = new Technology.NodeLayer[] {transistorPolyLayers[P_TYPE], transistorPolyLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickWellLayers = new Technology.NodeLayer[] {transistorWellLayers[P_TYPE], transistorWellLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickSelectLayers = new Technology.NodeLayer[] {transistorSelectLayers[P_TYPE], transistorSelectLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickActiveTLayers = new Technology.NodeLayer[] {transistorActiveTLayers[P_TYPE], transistorActiveTLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickActiveBLayers = new Technology.NodeLayer[] {transistorActiveBLayers[P_TYPE], transistorActiveBLayers[N_TYPE]};\n Technology.NodeLayer[] thickPolyCLayers = new Technology.NodeLayer[] {transistorPolyCLayers[P_TYPE], transistorPolyCLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickPolyLLayers = new Technology.NodeLayer[] {transistorPolyLLayers[P_TYPE], transistorPolyLLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickPolyRLayers = new Technology.NodeLayer[] {transistorPolyRLayers[P_TYPE], transistorPolyRLayers[N_TYPE]};\n\t\tTechnology.NodeLayer[] thickLayers = new Technology.NodeLayer[2];\n\t\tfor (int i = 0; i < thickLayers.length; i++)\n\t\t{\n\t\t\tthickLayers[i] = new Technology.NodeLayer(thickActive_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\tnew Technology.TechPoint(EdgeH.makeLeftEdge(), EdgeV.fromBottom(1)),\n\t\t\tnew Technology.TechPoint(EdgeH.makeRightEdge(), EdgeV.fromTop(1))}, 10, 10, 6, 6);\n\t\t}\n\t\tfor (int i = 0; i < thickTransistorNodes.length; i++)\n\t\t{\n\t\t\tthickTransistorNodes[i] = PrimitiveNode.newInstance(thickNames[i] + \"-Transistor\", this, 15.0, 22.0, new SizeOffset(6, 6, 10, 10),\n\t\t\t\tnew Technology.NodeLayer [] {thickActiveLayers[i], thickPolyLayers[i], thickWellLayers[i], thickSelectLayers[i], thickLayers[i]});\n\t\t\tthickTransistorNodes[i].setElectricalLayers(new Technology.NodeLayer [] {thickActiveTLayers[i], thickActiveBLayers[i],\n\t\t\t\tthickPolyCLayers[i], thickPolyLLayers[i], thickPolyRLayers[i], thickWellLayers[i], thickSelectLayers[i], thickLayers[i]});\n\t\t\tthickTransistorNodes[i].addPrimitivePorts(new PrimitivePort []\n\t\t\t\t{\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {poly1_arc}, \"poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromLeft(4), EdgeV.fromBottom(11), EdgeH.fromLeft(4), EdgeV.fromTop(11)),\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {activeArcs[i]}, \"diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromTop(7.5), EdgeH.fromRight(7.5), EdgeV.fromTop(7)),\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {poly1_arc}, \"poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromRight(4), EdgeV.fromBottom(11), EdgeH.fromRight(4), EdgeV.fromTop(11)),\n\t\t\t\t\tPrimitivePort.newInstance(this, thickTransistorNodes[i], new ArcProto[] {activeArcs[i]}, \"diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n\t\t\t\t\t\tEdgeH.fromLeft(7.5), EdgeV.fromBottom(7), EdgeH.fromRight(7.5), EdgeV.fromBottom(7.5))\n\t\t\t\t});\n\t\t\tthickTransistorNodes[i].setFunction((i==P_TYPE) ? PrimitiveNode.Function.TRAPMOS : PrimitiveNode.Function.TRANMOS);\n\t\t\tthickTransistorNodes[i].setHoldsOutline();\n\t\t\tthickTransistorNodes[i].setCanShrink();\n\t\t\tthickTransistorNodes[i].setSpecialType(PrimitiveNode.SERPTRANS);\n\t\t\tthickTransistorNodes[i].setSpecialValues(new double [] {7, 1.5, 2.5, 2, 1, 2});\n\t\t\tthickTransistorNodes[i].setMinSize(15, 22, \"2.1, 3.1\");\n\t\t\tthickTransistorNodes[i].setSpecialNode(); \n\t\t}\n\t\tscalableTransistorNodes[P_TYPE] = PrimitiveNode.newInstance(\"P-Transistor-Scalable\", this, 17.0, 26.0, new SizeOffset(7, 7, 12, 12),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(6)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(11))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromTop(6.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromTop(10.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(11)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(6))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromBottom(10.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromBottom(6.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7), EdgeV.fromBottom(9)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(7), EdgeV.fromTop(9))}),\n\t\t\t\tnew Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(5), EdgeV.fromBottom(12)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(5), EdgeV.fromTop(12))}),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromBottom(9.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromBottom(7.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromTop(7.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromTop(9.5))})\n\t\t\t});\n\t\tscalableTransistorNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {poly1_arc}, \"p-trans-sca-poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(-3.5), EdgeV.makeCenter(), EdgeH.fromCenter(-3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE], metalArcs[0]}, \"p-trans-sca-diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(4.5), EdgeH.makeCenter(), EdgeV.fromCenter(4.5)),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {poly1_arc}, \"p-trans-sca-poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(3.5), EdgeV.makeCenter(), EdgeH.fromCenter(3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[P_TYPE], new ArcProto[] {activeArcs[P_TYPE], metalArcs[0]}, \"p-trans-sca-diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(-4.5), EdgeH.makeCenter(), EdgeV.fromCenter(-4.5))\n\t\t\t});\n\t\tscalableTransistorNodes[P_TYPE].setFunction(PrimitiveNode.Function.TRAPMOS);\n\t\tscalableTransistorNodes[P_TYPE].setCanShrink();\n\t\tscalableTransistorNodes[P_TYPE].setMinSize(17, 26, \"2.1, 3.1\");\n\t\tscalableTransistorNodes[N_TYPE] = PrimitiveNode.newInstance(\"N-Transistor-Scalable\", this, 17.0, 26.0, new SizeOffset(7, 7, 12, 12),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromTop(6)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromTop(11))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromTop(6.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromTop(10.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6), EdgeV.fromBottom(11)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6), EdgeV.fromBottom(6))}),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 3, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(6.5), EdgeV.fromBottom(10.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(6.5), EdgeV.fromBottom(6.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7), EdgeV.fromBottom(9)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(7), EdgeV.fromTop(9))}),\n\t\t\t\tnew Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(5), EdgeV.fromBottom(12)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(5), EdgeV.fromTop(12))}),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromBottom(9.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromBottom(7.5))}),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(7.5), EdgeV.fromTop(7.5)),\n\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(9.5), EdgeV.fromTop(9.5))})\n\t\t\t});\n\t\tscalableTransistorNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {poly1_arc}, \"n-trans-sca-poly-left\", 180,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(-3.5), EdgeV.makeCenter(), EdgeH.fromCenter(-3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE], metalArcs[0]}, \"n-trans-sca-diff-top\", 90,90, 1, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(4.5), EdgeH.makeCenter(), EdgeV.fromCenter(4.5)),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {poly1_arc}, \"n-trans-sca-poly-right\", 0,90, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromCenter(3.5), EdgeV.makeCenter(), EdgeH.fromCenter(3.5), EdgeV.makeCenter()),\n\t\t\t\tPrimitivePort.newInstance(this, scalableTransistorNodes[N_TYPE], new ArcProto[] {activeArcs[N_TYPE], metalArcs[0]}, \"n-trans-sca-diff-bottom\", 270,90, 2, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeCenter(), EdgeV.fromCenter(-4.5), EdgeH.makeCenter(), EdgeV.fromCenter(-4.5))\n\t\t\t});\n\t\tscalableTransistorNodes[N_TYPE].setFunction(PrimitiveNode.Function.TRANMOS);\n\t\tscalableTransistorNodes[N_TYPE].setCanShrink();\n\t\tscalableTransistorNodes[N_TYPE].setMinSize(17, 26, \"2.1, 3.1\");\n\t\tmetalContactNodes[0] = PrimitiveNode.newInstance(\"Metal-1-Metal-2-Con\", this, 5.0, 5.0, new SizeOffset(0.5, 0.5, 0.5, 0.5),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(0.5)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[1], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(0.5)),\n\t\t\t\tnew Technology.NodeLayer(via1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5))\n\t\t\t});\n\t\tmetalContactNodes[0].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[0], new ArcProto[] {metalArcs[0], metalArcs[1]}, \"metal-1-metal-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetalContactNodes[0].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[0].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[0].setSpecialValues(new double [] {2, 2, 1, 1, 3, 3});\n\t\tmetalContactNodes[0].setMinSize(5, 5, \"8.3, 9.3\");\n\t\tmetalContactNodes[1] = PrimitiveNode.newInstance(\"Metal-2-Metal-3-Con\", this, 6.0, 6.0, new SizeOffset(1, 1, 1, 1),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[1], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[2], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(via2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(2))\n\t\t\t});\n\t\tmetalContactNodes[1].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[1], new ArcProto[] {metalArcs[1], metalArcs[2]}, \"metal-2-metal-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[1].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[1].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[1].setSpecialValues(new double [] {2, 2, 1, 1, 3, 3});\n\t\tmetalContactNodes[1].setMinSize(6, 6, \"14.3, 15.3\");\n\t\tmetalContactNodes[2] = PrimitiveNode.newInstance(\"Metal-3-Metal-4-Con\", this, 6.0, 6.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[2], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[3], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(via3_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(2))\n\t\t\t});\n\t\tmetalContactNodes[2].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[2], new ArcProto[] {metalArcs[2], metalArcs[3]}, \"metal-3-metal-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[2].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[2].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[2].setSpecialValues(new double [] {2, 2, 2, 2, 3, 3});\n\t\tmetalContactNodes[2].setMinSize(6, 6, \"21.3, 22.3\");\n\t\tmetalContactNodes[3] = PrimitiveNode.newInstance(\"Metal-4-Metal-5-Con\", this, 7.0, 7.0, new SizeOffset(1.5, 1.5, 1.5, 1.5),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[3], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[4], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1.5)),\n\t\t\t\tnew Technology.NodeLayer(via4_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(2.5))\n\t\t\t});\n\t\tmetalContactNodes[3].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[3], new ArcProto[] {metalArcs[3], metalArcs[4]}, \"metal-4-metal-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[3].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[3].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[3].setSpecialValues(new double [] {2, 2, 1, 1, 3, 3});\n\t\tmetalContactNodes[3].setNotUsed();\n\t\tmetalContactNodes[3].setMinSize(7, 7, \"25.3, 26.3\");\n\t\tmetalContactNodes[4] = PrimitiveNode.newInstance(\"Metal-5-Metal-6-Con\", this, 8.0, 8.0, new SizeOffset(1, 1, 1, 1),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[4], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(metalLayers[5], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(1)),\n\t\t\t\tnew Technology.NodeLayer(via5_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(3))\n\t\t\t});\n\t\tmetalContactNodes[4].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalContactNodes[4], new ArcProto[] {metalArcs[4], metalArcs[5]}, \"metal-5-metal-6\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(2.5), EdgeV.fromBottom(2.5), EdgeH.fromRight(2.5), EdgeV.fromTop(2.5))\n\t\t\t});\n\t\tmetalContactNodes[4].setFunction(PrimitiveNode.Function.CONTACT);\n\t\tmetalContactNodes[4].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalContactNodes[4].setSpecialValues(new double [] {3, 3, 2, 2, 4, 4});\n\t\tmetalContactNodes[4].setNotUsed();\n\t\tmetalContactNodes[4].setMinSize(8, 8, \"29.3, 30.3\");\n\t\tmetalWellContactNodes[P_TYPE] = PrimitiveNode.newInstance(\"Metal-1-P-Well-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(pActiveWell_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalWellContactNodes[P_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalWellContactNodes[P_TYPE], new ArcProto[] {metalArcs[0], active_arc}, \"metal-1-well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalWellContactNodes[P_TYPE].setFunction(PrimitiveNode.Function.WELL);\n\t\tmetalWellContactNodes[P_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalWellContactNodes[P_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalWellContactNodes[P_TYPE].setMinSize(17, 17, \"4.2, 6.2, 7.3\");\n\t\tmetalWellContactNodes[N_TYPE] = PrimitiveNode.newInstance(\"Metal-1-N-Well-Con\", this, 17.0, 17.0, new SizeOffset(6, 6, 6, 6),\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6.5)),\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(6)),\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox()),\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(4)),\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeIndented(7.5))\n\t\t\t});\n\t\tmetalWellContactNodes[N_TYPE].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metalWellContactNodes[N_TYPE], new ArcProto[] {metalArcs[0], active_arc}, \"metal-1-substrate\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(8), EdgeV.fromBottom(8), EdgeH.fromRight(8), EdgeV.fromTop(8))\n\t\t\t});\n\t\tmetalWellContactNodes[N_TYPE].setFunction(PrimitiveNode.Function.SUBSTRATE);\n\t\tmetalWellContactNodes[N_TYPE].setSpecialType(PrimitiveNode.MULTICUT);\n\t\tmetalWellContactNodes[N_TYPE].setSpecialValues(new double [] {2, 2, 1.5, 1.5, 3, 3});\n\t\tmetalWellContactNodes[N_TYPE].setMinSize(17, 17, \"4.2, 6.2, 7.3\");\n double polySelectOffX = 1.8; \n double polyCutSize = 2.2; \n double resistorViaOff = 1.0; \n double resistorConW = polyCutSize + 2*resistorViaOff ;\n double resistorConH = resistorConW ;\n double resistorOffX = resistorConW + polySelectOffX + 1.2 ;\n double resistorW = 20 + 2*resistorOffX;\n double resistorOffY = 2.2 ;\n double resistorH = 2*resistorOffY + resistorConH;\n double resistorM1Off = resistorViaOff - 0.6; \n double resistorM1W = resistorConW-2*resistorM1Off;\n double resistorM1OffX = resistorM1Off + polySelectOffX;\n double resistorM1OffY = resistorM1Off + resistorOffY;\n double resistorV1OffX = resistorViaOff + polySelectOffX;\n double resistorV1OffY = resistorOffY + (resistorConH-polyCutSize)/2;\n rpoResistorNodes = new PrimitiveNode[2];\n for (int i = 0; i < rpoResistorNodes.length; i++)\n {\n rpoResistorNodes[i] = PrimitiveNode.newInstance(stdNames[i]+\"-Poly-RPO-Resistor\", this, resistorW, resistorH,\n new SizeOffset(resistorOffX, resistorOffX, resistorOffY, resistorOffY),\n\t\t\t\tnew Technology.NodeLayer []\n\t\t\t\t{\n new Technology.NodeLayer(poly1_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(polySelectOffX), EdgeV.fromBottom(resistorOffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(polySelectOffX), EdgeV.fromTop(resistorOffY))}),\n new Technology.NodeLayer(silicideBlock_lay, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorOffX), EdgeV.makeBottomEdge()),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorOffX), EdgeV.makeTopEdge())}),\n new Technology.NodeLayer(selectLayers[i], -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.makeLeftEdge(), EdgeV.fromBottom(0.2)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.makeRightEdge(), EdgeV.fromTop(0.2))}),\n new Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorM1OffX), EdgeV.fromBottom(resistorM1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorM1OffX+resistorM1W), EdgeV.fromTop(resistorM1OffY))}),\n new Technology.NodeLayer(polyCutLayer, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromLeft(resistorV1OffX+polyCutSize), EdgeV.fromBottom(resistorV1OffY+polyCutSize))}),\n new Technology.NodeLayer(metalLayers[0], 1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorM1OffX+resistorM1W), EdgeV.fromBottom(resistorM1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorM1OffX), EdgeV.fromTop(resistorM1OffY))}),\n new Technology.NodeLayer(polyCutLayer, -1, Poly.Type.FILLED, Technology.NodeLayer.BOX, new Technology.TechPoint [] {\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorV1OffX+polyCutSize), EdgeV.fromBottom(resistorV1OffY)),\n\t\t\t\t\t\tnew Technology.TechPoint(EdgeH.fromRight(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY+polyCutSize))})\n\t\t\t\t});\n rpoResistorNodes[i].addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, rpoResistorNodes[i], new ArcProto[] {poly1_arc, metalArcs[0]}, \"left-rpo\", 0,180, 0, PortCharacteristic.UNKNOWN,\n EdgeH.fromLeft(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY), EdgeH.fromLeft(resistorV1OffX+polyCutSize), EdgeV.fromTop(resistorV1OffY)),\n PrimitivePort.newInstance(this, rpoResistorNodes[i], new ArcProto[] {poly1_arc, metalArcs[0]}, \"right-rpo\", 0,180, 1, PortCharacteristic.UNKNOWN,\n EdgeH.fromRight(resistorV1OffX), EdgeV.fromBottom(resistorV1OffY), EdgeH.fromRight(resistorV1OffX+polyCutSize), EdgeV.fromTop(resistorV1OffY))\n\t\t\t});\n rpoResistorNodes[i].setFunction(PrimitiveNode.Function.PRESIST);\n\t\t\trpoResistorNodes[i].setHoldsOutline();\n\t\t\trpoResistorNodes[i].setSpecialType(PrimitiveNode.POLYGONAL);\n }\n\t\tmetal1Node_node = PrimitiveNode.newInstance(\"Metal-1-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[0], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal1Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal1Node_node, new ArcProto[] {metalArcs[0]}, \"metal-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal1Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal1Node_node.setHoldsOutline();\n\t\tmetal1Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal2Node_node = PrimitiveNode.newInstance(\"Metal-2-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[1], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal2Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal2Node_node, new ArcProto[] {metalArcs[1]}, \"metal-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal2Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal2Node_node.setHoldsOutline();\n\t\tmetal2Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal3Node_node = PrimitiveNode.newInstance(\"Metal-3-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[2], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal3Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal3Node_node, new ArcProto[] {metalArcs[2]}, \"metal-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal3Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal3Node_node.setHoldsOutline();\n\t\tmetal3Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal4Node_node = PrimitiveNode.newInstance(\"Metal-4-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[3], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal4Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal4Node_node, new ArcProto[] {metalArcs[3]}, \"metal-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal4Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal4Node_node.setHoldsOutline();\n\t\tmetal4Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal5Node_node = PrimitiveNode.newInstance(\"Metal-5-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[4], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal5Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal5Node_node, new ArcProto[] {metalArcs[4]}, \"metal-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal5Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal5Node_node.setHoldsOutline();\n\t\tmetal5Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal5Node_node.setNotUsed();\n\t\tmetal6Node_node = PrimitiveNode.newInstance(\"Metal-6-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(metalLayers[5], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tmetal6Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, metal6Node_node, new ArcProto[] {metalArcs[5]}, \"metal-6\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tmetal6Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tmetal6Node_node.setHoldsOutline();\n\t\tmetal6Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetal6Node_node.setNotUsed();\n\t\tpoly1Node_node = PrimitiveNode.newInstance(\"Polysilicon-1-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(poly1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly1Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly1Node_node, new ArcProto[] {poly1_arc}, \"polysilicon-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1), EdgeV.fromBottom(1), EdgeH.fromRight(1), EdgeV.fromTop(1))\n\t\t\t});\n\t\tpoly1Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpoly1Node_node.setHoldsOutline();\n\t\tpoly1Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpoly2Node_node = PrimitiveNode.newInstance(\"Polysilicon-2-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(poly2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpoly2Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, poly2Node_node, new ArcProto[] {poly2_arc}, \"polysilicon-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tpoly2Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpoly2Node_node.setHoldsOutline();\n\t\tpoly2Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpoly2Node_node.setNotUsed();\n\t\tpActiveNode_node = PrimitiveNode.newInstance(\"P-Active-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpActiveNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pActiveNode_node, new ArcProto[] {active_arc, activeArcs[P_TYPE], activeArcs[N_TYPE]}, \"active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tpActiveNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpActiveNode_node.setHoldsOutline();\n\t\tpActiveNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tnActiveNode_node = PrimitiveNode.newInstance(\"N-Active-Node\", this, 3.0, 3.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tnActiveNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, nActiveNode_node, new ArcProto[] {active_arc, activeArcs[P_TYPE], activeArcs[N_TYPE]}, \"active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1.5), EdgeV.fromBottom(1.5), EdgeH.fromRight(1.5), EdgeV.fromTop(1.5))\n\t\t\t});\n\t\tnActiveNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tnActiveNode_node.setHoldsOutline();\n\t\tnActiveNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpSelectNode_node = PrimitiveNode.newInstance(\"P-Select-Node\", this, 4.0, 4.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(selectLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpSelectNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pSelectNode_node, new ArcProto[0], \"select\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpSelectNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpSelectNode_node.setHoldsOutline();\n\t\tpSelectNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tnSelectNode_node = PrimitiveNode.newInstance(\"N-Select-Node\", this, 4.0, 4.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(selectLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tnSelectNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, nSelectNode_node, new ArcProto[0], \"select\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tnSelectNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tnSelectNode_node.setHoldsOutline();\n\t\tnSelectNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpolyCutNode_node = PrimitiveNode.newInstance(\"Poly-Cut-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(polyCutLayer, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpolyCutNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, polyCutNode_node, new ArcProto[0], \"polycut\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpolyCutNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpolyCutNode_node.setHoldsOutline();\n\t\tpolyCutNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tactiveCutNode_node = PrimitiveNode.newInstance(\"Active-Cut-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(activeCut_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tactiveCutNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, activeCutNode_node, new ArcProto[0], \"activecut\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tactiveCutNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tactiveCutNode_node.setHoldsOutline();\n\t\tactiveCutNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia1Node_node = PrimitiveNode.newInstance(\"Via-1-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via1_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia1Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via1Node_node, new ArcProto[0], \"via-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia1Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia1Node_node.setHoldsOutline();\n\t\tvia1Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia2Node_node = PrimitiveNode.newInstance(\"Via-2-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via2_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia2Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via2Node_node, new ArcProto[0], \"via-2\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia2Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia2Node_node.setHoldsOutline();\n\t\tvia2Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia3Node_node = PrimitiveNode.newInstance(\"Via-3-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via3_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia3Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via3Node_node, new ArcProto[0], \"via-3\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia3Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia3Node_node.setHoldsOutline();\n\t\tvia3Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia4Node_node = PrimitiveNode.newInstance(\"Via-4-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via4_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia4Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via4Node_node, new ArcProto[0], \"via-4\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia4Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia4Node_node.setHoldsOutline();\n\t\tvia4Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia4Node_node.setNotUsed();\n\t\tvia5Node_node = PrimitiveNode.newInstance(\"Via-5-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(via5_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tvia5Node_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, via5Node_node, new ArcProto[0], \"via-5\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tvia5Node_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tvia5Node_node.setHoldsOutline();\n\t\tvia5Node_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tvia5Node_node.setNotUsed();\n\t\tpWellNode_node = PrimitiveNode.newInstance(\"P-Well-Node\", this, 12.0, 12.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(wellLayers[P_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpWellNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pWellNode_node, new ArcProto[] {activeArcs[P_TYPE]}, \"well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(3), EdgeV.fromBottom(3), EdgeH.fromRight(3), EdgeV.fromTop(3))\n\t\t\t});\n\t\tpWellNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpWellNode_node.setHoldsOutline();\n\t\tpWellNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tnWellNode_node = PrimitiveNode.newInstance(\"N-Well-Node\", this, 12.0, 12.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(wellLayers[N_TYPE], 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tnWellNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, nWellNode_node, new ArcProto[] {activeArcs[P_TYPE]}, \"well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(3), EdgeV.fromBottom(3), EdgeH.fromRight(3), EdgeV.fromTop(3))\n\t\t\t});\n\t\tnWellNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tnWellNode_node.setHoldsOutline();\n\t\tnWellNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpassivationNode_node = PrimitiveNode.newInstance(\"Passivation-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(passivation_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpassivationNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, passivationNode_node, new ArcProto[0], \"passivation\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpassivationNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpassivationNode_node.setHoldsOutline();\n\t\tpassivationNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpadFrameNode_node = PrimitiveNode.newInstance(\"Pad-Frame-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(padFrame_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpadFrameNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, padFrameNode_node, new ArcProto[0], \"pad-frame\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpadFrameNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpadFrameNode_node.setHoldsOutline();\n\t\tpadFrameNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpolyCapNode_node = PrimitiveNode.newInstance(\"Poly-Cap-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(polyCap_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpolyCapNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, polyCapNode_node, new ArcProto[0], \"poly-cap\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpolyCapNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpolyCapNode_node.setHoldsOutline();\n\t\tpolyCapNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpActiveWellNode_node = PrimitiveNode.newInstance(\"P-Active-Well-Node\", this, 8.0, 8.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(pActiveWell_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpActiveWellNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, pActiveWellNode_node, new ArcProto[0], \"p-active-well\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tpActiveWellNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpActiveWellNode_node.setHoldsOutline();\n\t\tpActiveWellNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tpolyTransistorNode_node = PrimitiveNode.newInstance(\"Transistor-Poly-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(transistorPoly_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tpolyTransistorNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, polyTransistorNode_node, new ArcProto[] {poly1_arc}, \"trans-poly-1\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.fromLeft(1), EdgeV.fromBottom(1), EdgeH.fromRight(1), EdgeV.fromTop(1))\n\t\t\t});\n\t\tpolyTransistorNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tpolyTransistorNode_node.setHoldsOutline();\n\t\tpolyTransistorNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tsilicideBlockNode_node = PrimitiveNode.newInstance(\"Silicide-Block-Node\", this, 2.0, 2.0, null,\n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(silicideBlock_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tsilicideBlockNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, silicideBlockNode_node, new ArcProto[] {poly1_arc}, \"silicide-block\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tsilicideBlockNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tsilicideBlockNode_node.setHoldsOutline();\n\t\tsilicideBlockNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tthickActiveNode_node = PrimitiveNode.newInstance(\"Thick-Active-Node\", this, 4.0, 4.0, null, \n\t\t\tnew Technology.NodeLayer []\n\t\t\t{\n\t\t\t\tnew Technology.NodeLayer(thickActive_lay, 0, Poly.Type.FILLED, Technology.NodeLayer.BOX, Technology.TechPoint.makeFullBox())\n\t\t\t});\n\t\tthickActiveNode_node.addPrimitivePorts(new PrimitivePort []\n\t\t\t{\n\t\t\t\tPrimitivePort.newInstance(this, thickActiveNode_node, new ArcProto[] {poly1_arc}, \"thick-active\", 0,180, 0, PortCharacteristic.UNKNOWN,\n\t\t\t\t\tEdgeH.makeLeftEdge(), EdgeV.makeBottomEdge(), EdgeH.makeRightEdge(), EdgeV.makeTopEdge())\n\t\t\t});\n\t\tthickActiveNode_node.setFunction(PrimitiveNode.Function.NODE);\n\t\tthickActiveNode_node.setHoldsOutline();\n\t\tthickActiveNode_node.setSpecialType(PrimitiveNode.POLYGONAL);\n\t\tmetalLayers[0].setPureLayerNode(metal1Node_node);\t\t\t\t\t\n\t\tmetalLayers[1].setPureLayerNode(metal2Node_node);\t\t\t\t\t\n\t\tmetalLayers[2].setPureLayerNode(metal3Node_node);\t\t\t\t\t\n\t\tmetalLayers[3].setPureLayerNode(metal4Node_node);\t\t\t\t\t\n\t\tmetalLayers[4].setPureLayerNode(metal5Node_node);\t\t\t\t\t\n\t\tmetalLayers[5].setPureLayerNode(metal6Node_node);\t\t\t\t\t\n\t\tpoly1_lay.setPureLayerNode(poly1Node_node);\t\t\t\t\t\t\n\t\tpoly2_lay.setPureLayerNode(poly2Node_node);\t\t\t\t\t\t\n\t\tactiveLayers[P_TYPE].setPureLayerNode(pActiveNode_node);\t\t\t\t\t\n\t\tactiveLayers[N_TYPE].setPureLayerNode(nActiveNode_node);\t\t\t\t\t\n\t\tselectLayers[P_TYPE].setPureLayerNode(pSelectNode_node);\t\t\t\t\t\n\t\tselectLayers[N_TYPE].setPureLayerNode(nSelectNode_node);\t\t\t\t\t\n\t\twellLayers[P_TYPE].setPureLayerNode(pWellNode_node);\t\t\t\t\t\t\n\t\twellLayers[N_TYPE].setPureLayerNode(nWellNode_node);\t\t\t\t\t\t\n\t\tpolyCutLayer.setPureLayerNode(polyCutNode_node);\t\t\t\t\t\n\t\tactiveCut_lay.setPureLayerNode(activeCutNode_node);\t\t\t\t\n\t\tvia1_lay.setPureLayerNode(via1Node_node);\t\t\t\t\t\t\n\t\tvia2_lay.setPureLayerNode(via2Node_node);\t\t\t\t\t\t\n\t\tvia3_lay.setPureLayerNode(via3Node_node);\t\t\t\t\t\t\n\t\tvia4_lay.setPureLayerNode(via4Node_node);\t\t\t\t\t\t\n\t\tvia5_lay.setPureLayerNode(via5Node_node);\t\t\t\t\t\t\n\t\tpassivation_lay.setPureLayerNode(passivationNode_node);\t\t\t\n\t\ttransistorPoly_lay.setPureLayerNode(polyTransistorNode_node);\t\n\t\tpolyCap_lay.setPureLayerNode(polyCapNode_node);\t\t\t\t\t\n\t\tpActiveWell_lay.setPureLayerNode(pActiveWellNode_node);\t\t\t\n\t\tsilicideBlock_lay.setPureLayerNode(silicideBlockNode_node);\t\t\n\t\tthickActive_lay.setPureLayerNode(thickActiveNode_node);\t\t\t\n\t\tpadFrame_lay.setPureLayerNode(padFrameNode_node);\t\t\t\t\n int maxY = metalArcs.length + activeArcs.length + 1 + 1 + 1 + 1 ;\n nodeGroups = new Object[maxY][3];\n int count = 0;\n String[] shortNames = {\"p\", \"n\"};\n List tmp;\n for (int i = 0; i < transistorNodes.length; i++)\n {\n tmp = new ArrayList(2);\n String tmpVar = shortNames[i]+\"Mos\";\n tmp.add(makeNodeInst(transistorNodes[i], transistorNodes[i].getFunction(), 0, true, tmpVar, 9));\n tmp.add(makeNodeInst(thickTransistorNodes[i], thickTransistorNodes[i].getFunction(), 0, true, tmpVar, 9));\n tmp.add(makeNodeInst(scalableTransistorNodes[i], scalableTransistorNodes[i].getFunction(), 0, true, tmpVar, 9)); \n nodeGroups[count][i+1] = tmp;\n }\n count++;\n for (int i = 0; i < metalWellContactNodes.length; i++)\n {\n String tmpVar = shortNames[i]+\"Well\";\n nodeGroups[count][i+1] = makeNodeInst(metalWellContactNodes[i], metalWellContactNodes[i].getFunction(),\n 0, true, tmpVar, 5.5);\n }\n for (int i = 0; i < rpoResistorNodes.length; i++)\n {\n String tmpVar = shortNames[i]+\"R\";\n tmp = new ArrayList(1);\n tmp.add(makeNodeInst(rpoResistorNodes[i], rpoResistorNodes[i].getFunction(), 0, true, tmpVar, 10));\n nodeGroups[i][0] = tmp;\n }\n for (int i = 0; i < activeArcs.length; i++)\n {\n nodeGroups[++count][0] = activeArcs[i];\n nodeGroups[count][1] = activePinNodes[i];\n String tmpVar = shortNames[i]+\"Act\";\n nodeGroups[count][2] = makeNodeInst(metalActiveContactNodes[i], metalActiveContactNodes[i].getFunction(),\n 0, true, tmpVar, 5.55);\n }\n nodeGroups[++count][0] = poly1_arc;\n nodeGroups[count][1] = poly1Pin_node;\n nodeGroups[count][2] = metal1Poly1Contact_node;\n for (int i = 0; i < metalArcs.length; i++)\n {\n nodeGroups[++count][0] = metalArcs[i];\n nodeGroups[count][1] = metalPinNodes[i];\n nodeGroups[count][2] = (i < metalArcs.length - 1) ? metalContactNodes[i] : null;\n }\n nodeGroups[++count][0] = \"Pure\";\n nodeGroups[count][1] = \"Misc.\";\n nodeGroups[count][2] = \"Cell\";\n\t}\n"} {"input": "\t\tpublic int compare(Storable o1, Storable o2) {\n\t\t\tif(o1.isNotForStorage()) {\n\t\t\t\treturn o1.equals(o2) ? 0 : 1;\n\t\t\t}\n\t\t\telse if(o2.isNotForStorage()) {\n\t\t\t\treturn o1.equals(o2) ? 0 : -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn -1 * Longs.compare(o1.getTimestamp(), o2.getTimestamp());\n\t\t\t}\n\t\t}\n", "output": "\t\tpublic int compare(Storable o1, Storable o2) {\n\t\t\tif(o1.isNotForStorage() && o2.isNotForStorage()) {\n\t\t\t\treturn o1.equals(o2) ? 0 : 0;\n\t\t\t}\n\t\t\tif(o1.isNotForStorage()) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\telse if(o2.isNotForStorage()) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn -1 * Longs.compare(o1.getTimestamp(), o2.getTimestamp());\n\t\t\t}\n\t\t}\n"} {"input": " public static String normalize(String pidString) \n throws MalformedPIDException {\n if (pidString == null) {\n throw new MalformedPIDException(\"PID is null.\");\n }\n if (pidString.length() > MAX_LENGTH) {\n throw new MalformedPIDException(\"PID length exceeds \" \n + MAX_LENGTH + \".\");\n }\n StringBuffer out = new StringBuffer();\n boolean inObjectID = false;\n for (int i = 0; i < pidString.length(); i++) {\n char c = pidString.charAt(i);\n if (!inObjectID) {\n if (c == ':') {\n out.append(':');\n inObjectID = true;\n } else if (c == '%') {\n if (pidString.length() >= i + 3) {\n i++;\n if (pidString.charAt(i) == '3') {\n i++;\n c = pidString.charAt(i);\n if ( c == 'a' || c == 'A' ) {\n out.append(\":\");\n inObjectID = true;\n } else {\n throw new MalformedPIDException(\"Error in PID after first '%': expected '3a' or '3A', but saw '3\" + c + \"'.\");\n }\n } else {\n throw new MalformedPIDException(\"Error in PID after first '%': expected '3a' or '3A', but saw '\" + pidString.substring(i, i+2) + \"'.\");\n }\n } else {\n throw new MalformedPIDException(\"Error in PID after first '%': expected '3a' or '3A', but saw '\" + pidString.substring(i+1) + \"'.\");\n }\n } else if (isAlphaNum(c) || c == '-' || c == '.') {\n out.append(c);\n } else {\n throw new MalformedPIDException(\"PID namespace-id cannot contain '\" + c + \"' character.\");\n }\n } else if (isAlphaNum(c) || c == '-' || c == '.' || c == '~' || c == '_' ) {\n out.append(c);\n } else if (c == '%') {\n if (pidString.length() >= i + 3) {\n char h1 = getNormalizedHexChar(pidString.charAt(++i));\n char h2 = getNormalizedHexChar(pidString.charAt(++i));\n out.append(\"%\" + h1 + h2);\n } else {\n throw new MalformedPIDException(\"PID object-id ended early: need at least 2 chars after '%'.\");\n }\n } else {\n throw new MalformedPIDException(\"PID object-id cannot contain '\" + c + \"' character.\");\n }\n }\n if (!inObjectID) throw new MalformedPIDException(\"PID delimiter (:) is missing.\");\n String outString = out.toString();\n if (outString.startsWith(\":\")) throw new MalformedPIDException(\"PID namespace-id cannot be empty.\");\n if (outString.length() < 3) throw new MalformedPIDException(\"PID object-id cannot be empty.\");\n return out.toString();\n }\n", "output": " public static String normalize(String pidString) \n throws MalformedPIDException {\n if (pidString == null) {\n throw new MalformedPIDException(\"PID is null.\");\n }\n if (pidString.length() > MAX_LENGTH) {\n throw new MalformedPIDException(\"PID length exceeds \" \n + MAX_LENGTH + \".\");\n }\n StringBuffer out = new StringBuffer();\n boolean inObjectID = false;\n for (int i = 0; i < pidString.length(); i++) {\n char c = pidString.charAt(i);\n if (!inObjectID) {\n if (c == ':') {\n out.append(':');\n inObjectID = true;\n } else if (c == '%') {\n if (pidString.length() >= i + 3) {\n i++;\n if (pidString.charAt(i) == '3') {\n i++;\n c = pidString.charAt(i);\n if ( c == 'a' || c == 'A' ) {\n out.append(\":\");\n inObjectID = true;\n } else {\n throw new MalformedPIDException(\"Error in PID after first '%': expected '3a' or '3A', but saw '3\" + c + \"'.\");\n }\n } else {\n throw new MalformedPIDException(\"Error in PID after first '%': expected '3a' or '3A', but saw '\" + pidString.substring(i, i+2) + \"'.\");\n }\n } else {\n throw new MalformedPIDException(\"Error in PID after first '%': expected '3a' or '3A', but saw '\" + pidString.substring(i+1) + \"'.\");\n }\n } else if (isAlphaNum(c) || c == '-' || c == '.') {\n out.append(c);\n } else {\n throw new MalformedPIDException(\"PID namespace-id cannot contain '\" + c + \"' character.\");\n }\n } else if (isAlphaNum(c) || c == '-' || c == '.' || c == '~' || c == '_' ) {\n out.append(c);\n } else if (c == '%') {\n if (pidString.length() >= i + 3) {\n char h1 = getNormalizedHexChar(pidString.charAt(++i));\n char h2 = getNormalizedHexChar(pidString.charAt(++i));\n out.append(\"%\" + h1 + h2);\n } else {\n throw new MalformedPIDException(\"PID object-id ended early: need at least 2 chars after '%'.\");\n }\n } else {\n throw new MalformedPIDException(\"PID object-id cannot contain '\" + c + \"' character.\");\n }\n }\n if (!inObjectID) throw new MalformedPIDException(\"PID delimiter (:) is missing.\");\n String outString = out.toString();\n if (outString.startsWith(\":\")) throw new MalformedPIDException(\"PID namespace-id cannot be empty.\");\n if (outString.length() < 3) throw new MalformedPIDException(\"PID object-id cannot be empty.\");\n return outString;\n }\n"} {"input": " public void process(Event event) throws PluggableTaskException {\n PluggableTaskBL ptbl = new PluggableTaskBL(getExternalSavingPluginId());\n IExternalCreditCardStorage externalCCStorage = ptbl.instantiateTask();\n if (event instanceof NewCreditCardEvent) {\n LOG.debug(\"Processing NewCreditCardEvent ...\");\n NewCreditCardEvent ev = (NewCreditCardEvent) event;\n if (!ev.getCreditCard().getBaseUsers().isEmpty()) {\n String gateWayKey = externalCCStorage.storeCreditCard(null, ev.getCreditCard(), null);\n updateCreditCard(ev.getCreditCard(), gateWayKey);\n } else {\n LOG.debug(\"Credit card is not associated with a user (card for payment) - can't save through gateway.\");\n }\n } else if (event instanceof NewContactEvent) {\n LOG.debug(\"Processing NewContactEvent ...\");\n NewContactEvent ev = (NewContactEvent) event;\n ContactDTO contact = ev.getContactDto();\n int thisRecordContactType = contact.getContactMap().getContactType().getId();\n LOG.debug(\"Contact type: \" + thisRecordContactType + \", plug-in expects: \" + getContactType());\n if (getContactType() == thisRecordContactType) {\n UserBL userBl = new UserBL(contact.getUserId());\n CreditCardDTO creditCard = userBl.getCreditCard();\n if (creditCard != null) {\n String gateWayKey = externalCCStorage.storeCreditCard(contact, creditCard, null);\n updateCreditCard(creditCard, gateWayKey);\n } else {\n LOG.warn(\"Cannot determine credit card for storage, invoking external store with contact only\");\n String gateWayKey = externalCCStorage.storeCreditCard(contact, null, null);\n updateCreditCard(creditCard, gateWayKey);\n }\n }\n } else {\n throw new PluggableTaskException(\"Cant not process event \" + event);\n }\n }\n", "output": " public void process(Event event) throws PluggableTaskException {\n PluggableTaskBL ptbl = new PluggableTaskBL(getExternalSavingPluginId());\n IExternalCreditCardStorage externalCCStorage = ptbl.instantiateTask();\n if (event instanceof NewCreditCardEvent) {\n LOG.debug(\"Processing NewCreditCardEvent ...\");\n NewCreditCardEvent ev = (NewCreditCardEvent) event;\n if (!ev.getCreditCard().getBaseUsers().isEmpty()) {\n String gateWayKey = externalCCStorage.storeCreditCard(null, ev.getCreditCard(), null);\n updateCreditCard(ev.getCreditCard(), gateWayKey);\n } else {\n LOG.debug(\"Credit card is not associated with a user (card for payment) - can't save through gateway.\");\n }\n } else if (event instanceof NewContactEvent) {\n LOG.debug(\"Processing NewContactEvent ...\");\n NewContactEvent ev = (NewContactEvent) event;\n ContactDTO contact = ev.getContactDto();\n int thisRecordContactType = contact.getContactMap().getContactType().getId();\n LOG.debug(\"Contact type: \" + thisRecordContactType + \", plug-in expects: \" + getContactType());\n if (getContactType() == thisRecordContactType) {\n UserBL userBl = new UserBL(contact.getUserId());\n CreditCardDTO creditCard = userBl.getCreditCard();\n if (creditCard != null) {\n String gateWayKey = externalCCStorage.storeCreditCard(contact, creditCard, null);\n updateCreditCard(creditCard, gateWayKey);\n } else {\n LOG.warn(\"Cannot determine credit card for storage, invoking external store with contact only\");\n }\n }\n } else {\n throw new PluggableTaskException(\"Cant not process event \" + event);\n }\n }\n"} {"input": " public static final ServiceLocator instance()\n {\n \tif (context == null)\n \t{\n \t\tcontext = new org.springframework.context.annotation.AnnotationConfigApplicationContext();\n \t\t((org.springframework.context.annotation.AnnotationConfigApplicationContext) context).scan(\"org.molgenis\");\n \t\t((org.springframework.context.annotation.AnnotationConfigApplicationContext) context).refresh();\n \t}\n return instance;\n }\n", "output": " public static final ServiceLocator instance()\n {\n \tif (context == null)\n \t{\n \t\tcontext = new org.springframework.context.support.ClassPathXmlApplicationContext();\n \t}\n return instance;\n }\n"} {"input": " public void runPermissionEvent(PermissionEvent event) {\n User user = event.getUser();\n RalexBot.log(\"Updating perms for \" + user.getNick());\n String ver = user.isVerified();\n RalexBot.log(\"Is verified: \" + ver);\n if (ver == null || ver.isEmpty()) {\n return;\n }\n Map> existing = user.getPermissions();\n for (String key : existing.keySet()) {\n for (Permission perm : existing.get(key)) {\n user.removePermission(key, perm.getName());\n }\n }\n List list = permFile.getStringList(ver);\n for (String line : list) {\n String chan = line.split(\"\\\\|\")[0];\n String perm = line.split(\"\\\\|\")[1];\n if (chan.isEmpty()) {\n chan = null;\n }\n user.addPermission(chan, perm);\n }\n }\n", "output": " public void runPermissionEvent(PermissionEvent event) {\n User user = event.getUser();\n String ver = user.isVerified();\n if (ver == null || ver.isEmpty()) {\n return;\n }\n Map> existing = user.getPermissions();\n for (String key : existing.keySet().toArray(new String[0])) {\n for (Permission perm : existing.get(key).toArray(new Permission[0])) {\n user.removePermission(key, perm.getName());\n }\n }\n List list = permFile.getStringList(ver);\n for (String line : list) {\n String chan = line.split(\"\\\\|\")[0];\n String perm = line.split(\"\\\\|\")[1];\n if (chan.isEmpty()) {\n chan = null;\n }\n user.addPermission(chan, perm);\n }\n }\n"} {"input": " private boolean getInfo(String searchString) {\n try {\n String urlString = _searchUrl + filterTitle(searchString);\n URL url = new URL(urlString);\n URLConnection urlConn = url.openConnection();\n if (!(urlConn.getContent() instanceof InputStream))\n return false;\n String data = \"\";\n BufferedReader in = null;\n String line;\n try {\n\t\t\t\tin = new BufferedReader(new InputStreamReader(urlConn\n\t\t\t\t\t\t.getInputStream()));\n\t\t\t\twhile ((line = in.readLine()) != null) {\n\t\t\t\t\tdata += line + \"\\n\";\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (in != null) {\n\t\t\t\t\tin.close();\n\t\t\t\t}\n\t\t\t}\n if (data.indexOf(\"No Matches.\") > 0)\n return false;\n if (data.indexOf(\"IMDb name and title search\") >= 0 ||\n data.indexOf(\"<a href=\\\"/title/tt\") >= 0) {\n int start = data.indexOf(\"/title/tt\");\n if (start > 0) {\n int end = data.indexOf(\"/\",start + \"/title/tt\".length());\n _url = data.substring(start,end);\n if (_url.indexOf(\"http://\") < 0)\n _url = _baseUrl + _url;\n }\n if (_url == null) \n return false;\n } else {\n _url = urlString;\n }\n url = new URL(_url);\n urlConn = url.openConnection();\n if (!(urlConn.getContent() instanceof InputStream))\n return false;\n try {\n\t\t\t\tin = new BufferedReader(new InputStreamReader(urlConn\n\t\t\t\t\t\t.getInputStream()));\n\t\t\t\twhile ((line = in.readLine()) != null)\n\t\t\t\t\tdata = data + line + \"\\n\";\n\t\t\t} finally {\n\t\t\t\tin.close();\n\t\t\t}\n _title = parseData(data, \"<h1><strong class=\\\"title\\\">\", \"<small>\");\n _genre = parseData(data, \"<b class=\\\"ch\\\">Genre:</b>\", \"<br><br>\");\n _genre = _genre.replaceAll(\"\\\\(more\\\\)\", \"\").trim();\n _plot = parseData(data, \"<b class=\\\"ch\\\">Plot Outline:</b>\", \"<a href=\\\"\");\n _rating = parseData(data, \"<b class=\\\"ch\\\">User Rating:</b>\", \"</b>\");\n _rating = _rating.equals(\"N/A\") || _rating.indexOf(\"/\") < 0 ? \"N/A\" \n : _rating.substring(0,_rating.indexOf(\"/\"));\n _votes = parseData(data, \"<b class=\\\"ch\\\">User Rating:</b>\", \"<br><br>\");\n _votes = _votes.indexOf(\"(\") < 0 || _votes.indexOf(\"votes\") < 0 ? \"N/A\" \n : _votes.substring(_votes.indexOf(\"(\")+1, _votes.indexOf(\"votes\")).trim();\n _year = parseData(data, \"<a href=\\\"/Sections/Years/\", \"</a>\");\n if (_year.length() >= 6)\n \t _year = _year.substring(6);\n } catch (MalformedURLException e) {\n e.printStackTrace();\n return false;\n } catch (IOException e) {\n e.printStackTrace();\n return false;\n }\n return true;\n }\n", "output": " private boolean getInfo(String searchString) {\n try {\n String urlString = _searchUrl + filterTitle(searchString);\n URL url = new URL(urlString);\n URLConnection urlConn = url.openConnection();\n if (!(urlConn.getContent() instanceof InputStream))\n return false;\n String data = \"\";\n BufferedReader in = null;\n String line;\n try {\n\t\t\t\tin = new BufferedReader(new InputStreamReader(urlConn\n\t\t\t\t\t\t.getInputStream()));\n\t\t\t\twhile ((line = in.readLine()) != null) {\n\t\t\t\t\tdata += line + \"\\n\";\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (in != null) {\n\t\t\t\t\tin.close();\n\t\t\t\t}\n\t\t\t}\n if (data.indexOf(\"<b>No Matches.</b>\") > 0)\n return false;\n if (data.indexOf(\"<title>IMDb name and title search\") >= 0 ||\n data.indexOf(\"<a href=\\\"/title/tt\") >= 0) {\n int start = data.indexOf(\"/title/tt\");\n if (start > 0) {\n int end = data.indexOf(\"/\",start + \"/title/tt\".length());\n _url = data.substring(start,end);\n if (_url.indexOf(\"http://\") < 0)\n _url = _baseUrl + _url;\n }\n if (_url == null) \n return false;\n } else {\n _url = urlString;\n }\n url = new URL(_url);\n urlConn = url.openConnection();\n if (!(urlConn.getContent() instanceof InputStream))\n return false;\n try {\n\t\t\t\tin = new BufferedReader(new InputStreamReader(urlConn\n\t\t\t\t\t\t.getInputStream()));\n\t\t\t\twhile ((line = in.readLine()) != null)\n\t\t\t\t\tdata = data + line + \"\\n\";\n\t\t\t} finally {\n\t\t\t\tin.close();\n\t\t\t}\n _title = parseData(data, \"<strong class=\\\"title\\\">\", \"<small>\");\n _genre = parseData(data, \"<b class=\\\"ch\\\">Genre:</b>\", \"<br><br>\");\n _genre = _genre.replaceAll(\"\\\\(more\\\\)\", \"\").trim();\n _plot = parseData(data, \"<b class=\\\"ch\\\">Plot Outline:</b>\", \"<a href=\\\"\");\n _rating = parseData(data, \"<b class=\\\"ch\\\">User Rating:</b>\", \"</b>\");\n _rating = _rating.equals(\"N/A\") || _rating.indexOf(\"/\") < 0 ? \"N/A\" \n : _rating.substring(0,_rating.indexOf(\"/\"));\n _votes = parseData(data, \"<b class=\\\"ch\\\">User Rating:</b>\", \"<br><br>\");\n _votes = _votes.indexOf(\"(\") < 0 || _votes.indexOf(\"votes\") < 0 ? \"N/A\" \n : _votes.substring(_votes.indexOf(\"(\")+1, _votes.indexOf(\"votes\")).trim();\n _year = parseData(data, \"<a href=\\\"/Sections/Years/\", \"</a>\");\n if (_year.length() >= 6)\n \t _year = _year.substring(6);\n } catch (MalformedURLException e) {\n e.printStackTrace();\n return false;\n } catch (IOException e) {\n e.printStackTrace();\n return false;\n }\n return true;\n }\n"} {"input": " private void parseInput(File inputFile) throws IOException {\n CSVReader reader = null;\n Map<String, Set<String>> groupMap = new HashMap<String, Set<String>>();\n Map<String, Set<Publication>> publicationMap = new HashMap<String, Set<Publication>>();\n Map<String, SampleData> stMap = new HashMap<String, SampleData>();\n int linecount;\n String [] nextLine;\n try {\n reader = new CSVReader(new FileReader(inputFile), \"\\t\".charAt(0));\n linecount = 0;\n while ((nextLine = reader.readNext()) != null) {\n linecount += 1;\n if (this.headers == null || linecount == 0){\n this.headers = new ArrayList<String>();\n for (String header : nextLine){\n if (header.startsWith(\"V_\")){\n header = header.substring(2);\n }\n log.info(\"Found header : \"+header);\n headers.add(header);\n }\n this.doiindex = this.headers.indexOf(\"DOI\");\n if (this.doiindex < 0){\n throw new IOException(\"Headers does not contain DOI\");\n }\n this.pubmedindex = this.headers.indexOf(\"PUBMED_ID\");\n if (this.pubmedindex < 0){\n throw new IOException(\"Headers does not contain PUBMED_ID\");\n }\n this.projheaderindex = this.headers.indexOf(\"PROJECT_ACC\");\n this.pubheaderindex = this.headers.indexOf(\"ENA_PUBID\");\n if (this.pubheaderindex < 0){\n throw new IOException(\"Headers does not contain ENA_PUBID\");\n }\n this.collectedbyindex = this.headers.indexOf(\"COLLECTED_BY\");\n if (this.collectedbyindex < 0){\n throw new IOException(\"Headers does not contain COLLECTED_BY\");\n }\n this.identifiedbyindex = this.headers.indexOf(\"IDENTIFIED_BY\");\n if (this.identifiedbyindex < 0){\n throw new IOException(\"Headers does not contain IDENTIFIED_BY\");\n }\n this.taxidindex = this.headers.indexOf(\"TAX_ID\");\n if (this.taxidindex < 0){\n throw new IOException(\"Headers does not contain TAX_ID\");\n }\n } else {\n if (nextLine.length > headers.size()){\n log.warn(\"Line longer than headers \"+linecount);\n }\n String accession = nextLine[0].trim();\n log.debug(\"First processing \"+accession);\n for (String id : getGroupIdentifiers(nextLine)){\n if(!groupMap.containsKey(id)){\n groupMap.put(id, new HashSet<String>());\n }\n groupMap.get(id).add(accession);\n }\n publicationMap.put(accession, getPublications(nextLine));\n log.info(accession+\" \"+getPublications(nextLine).size());\n }\n }\n reader.close();\n } finally {\n try {\n if (reader != null){\n reader.close();\n }\n } catch (IOException e){\n }\n }\n try {\n reader = new CSVReader(new FileReader(inputFile), \"\\t\".charAt(0));\n linecount = 0;\n while ((nextLine = reader.readNext()) != null) {\n linecount += 1;\n if (this.headers == null || linecount == 0){\n } else {\n if (nextLine.length > this.headers.size()){\n log.warn(\"Line longer than headers \"+linecount);\n }\n String accession = nextLine[0].trim();\n log.debug(\"Second processing \"+accession);\n for (String id : getGroupIdentifiers(nextLine)){\n if (!groupMap.containsKey(id)){\n continue;\n }\n if(!stMap.containsKey(id)){\n stMap.put(id, new SampleData());\n }\n SampleData st = stMap.get(id);\n SampleNode s = lineToSample(nextLine, st);\n if (s.getNodeName() == null){\n log.error(\"Unable to add node with null name\");\n continue;\n }\n try {\n if (s.getNodeName() == null){\n log.error(\"Unable to add node with null name\");\n } else if (st.scd.getNode(s.getNodeName(), SampleNode.class) != null) {\n log.error(\"Unable to add duplicate node with name \"+s.getNodeName());\n } else if (s.getAttributes().size() <= 1){\n log.warn(\"Refusing to add sample \"+s.getNodeName()+\" without attributes\");\n } else {\n st.scd.addNode(s);\n }\n } catch (ParseException e) {\n log.error(\"Unable to add node \"+s.getNodeName(), e);\n } \n if (!groupMap.containsKey(id)){\n log.error(\"Problem locating publication ID \"+id+\" in publication maping\");\n continue;\n }\n if (!groupMap.get(id).contains(s.getNodeName())){\n log.error(\"Problem removing sample \"+s.getNodeName()+\" from publication maping\");\n continue;\n }\n if (publicationMap.containsKey(accession)){\n st.msi.publications.addAll(publicationMap.get(accession));\n log.debug(accession+\" \"+publicationMap.get(accession).size());\n log.debug(accession+\" \"+st.msi.publications.size());\n }\n groupMap.get(id).remove(s.getNodeName());\n if (groupMap.get(id).size() == 0){\n st.msi.submissionIdentifier = prefix+\"-\"+id;\n if (wgs){\n String speciesName = null;\n for (SampleNode sn : st.scd.getNodes(SampleNode.class)){\n for (SCDNodeAttribute a : sn.getAttributes()){\n if (OrganismAttribute.class.isInstance(a)){\n OrganismAttribute oa = (OrganismAttribute) a;\n speciesName = a.getAttributeValue();\n }\n }\n }\n if (speciesName == null){\n log.warn(\"Unable to determine species name\");\n } else {\n st.msi.submissionTitle = \"Whole Genome Shotgun sequencing of \"+speciesName;\n }\n } else if (tsa){\n String speciesName = null;\n for (SampleNode sn : st.scd.getNodes(SampleNode.class)){\n for (SCDNodeAttribute a : sn.getAttributes()){\n if (OrganismAttribute.class.isInstance(a)){\n OrganismAttribute oa = (OrganismAttribute) a;\n speciesName = a.getAttributeValue();\n }\n }\n }\n if (speciesName == null){\n log.warn(\"Unable to determine species name\");\n } else {\n st.msi.submissionTitle = \"Transcriptome Shotgun sequencing of \"+speciesName;\n }\n } else if (bar){\n st.msi.submissionTitle = st.msi.submissionIdentifier;\n }\n log.debug(\"No. of publications = \"+st.msi.publications.size());\n log.debug(\"Empty? \"+st.msi.publications.isEmpty());\n File outputSubDir = new File(outputFile, st.msi.submissionIdentifier);\n File sampletabPre = new File(outputSubDir, \"sampletab.pre.txt\");\n outputSubDir.mkdirs();\n log.info(\"Writing \"+sampletabPre);\n SampleTabWriter sampletabwriter = null;\n try {\n sampletabwriter = new SampleTabWriter(new BufferedWriter(new FileWriter(sampletabPre)));\n sampletabwriter.write(st);\n } catch (IOException e) {\n log.error(\"Unable to write to \"+sampletabPre, e);\n } finally {\n if (sampletabwriter != null){\n try {\n sampletabwriter.close();\n } catch (IOException e) {\n }\n }\n }\n groupMap.remove(id);\n stMap.remove(id);\n }\n }\n }\n }\n reader.close();\n } finally {\n try {\n if (reader != null){\n reader.close();\n }\n } catch (IOException e){\n }\n }\n }\n", "output": " private void parseInput(File inputFile) throws IOException {\n CSVReader reader = null;\n Map<String, Set<String>> groupMap = new HashMap<String, Set<String>>();\n Map<String, Set<Publication>> publicationMap = new HashMap<String, Set<Publication>>();\n Map<String, SampleData> stMap = new HashMap<String, SampleData>();\n int linecount;\n String [] nextLine;\n try {\n reader = new CSVReader(new FileReader(inputFile), \"\\t\".charAt(0));\n linecount = 0;\n while ((nextLine = reader.readNext()) != null) {\n linecount += 1;\n if (this.headers == null || linecount == 0){\n this.headers = new ArrayList<String>();\n for (String header : nextLine){\n if (header.startsWith(\"V_\")){\n header = header.substring(2);\n }\n log.info(\"Found header : \"+header);\n headers.add(header);\n }\n this.doiindex = this.headers.indexOf(\"DOI\");\n if (this.doiindex < 0){\n throw new IOException(\"Headers does not contain DOI\");\n }\n this.pubmedindex = this.headers.indexOf(\"PUBMED_ID\");\n if (this.pubmedindex < 0){\n throw new IOException(\"Headers does not contain PUBMED_ID\");\n }\n this.projheaderindex = this.headers.indexOf(\"PROJECT_ACC\");\n this.pubheaderindex = this.headers.indexOf(\"ENA_PUBID\");\n if (this.pubheaderindex < 0){\n throw new IOException(\"Headers does not contain ENA_PUBID\");\n }\n this.collectedbyindex = this.headers.indexOf(\"COLLECTED_BY\");\n if (this.collectedbyindex < 0){\n throw new IOException(\"Headers does not contain COLLECTED_BY\");\n }\n this.identifiedbyindex = this.headers.indexOf(\"IDENTIFIED_BY\");\n if (this.identifiedbyindex < 0){\n throw new IOException(\"Headers does not contain IDENTIFIED_BY\");\n }\n this.taxidindex = this.headers.indexOf(\"TAX_ID\");\n if (this.taxidindex < 0){\n throw new IOException(\"Headers does not contain TAX_ID\");\n }\n } else {\n if (nextLine.length > headers.size()){\n log.warn(\"Line longer than headers \"+linecount);\n }\n String accession = nextLine[0].trim();\n log.debug(\"First processing \"+accession);\n for (String id : getGroupIdentifiers(nextLine)){\n if(!groupMap.containsKey(id)){\n groupMap.put(id, new HashSet<String>());\n }\n groupMap.get(id).add(accession);\n }\n publicationMap.put(accession, getPublications(nextLine));\n log.info(accession+\" \"+getPublications(nextLine).size());\n }\n }\n reader.close();\n } finally {\n try {\n if (reader != null){\n reader.close();\n }\n } catch (IOException e){\n }\n }\n try {\n reader = new CSVReader(new FileReader(inputFile), \"\\t\".charAt(0));\n linecount = 0;\n while ((nextLine = reader.readNext()) != null) {\n linecount += 1;\n if (this.headers == null || linecount == 0){\n } else {\n if (nextLine.length > this.headers.size()){\n log.warn(\"Line longer than headers \"+linecount);\n }\n String accession = nextLine[0].trim();\n log.debug(\"Second processing \"+accession);\n for (String id : getGroupIdentifiers(nextLine)){\n if (!groupMap.containsKey(id)){\n continue;\n }\n if(!stMap.containsKey(id)){\n stMap.put(id, new SampleData());\n }\n SampleData st = stMap.get(id);\n SampleNode s = lineToSample(nextLine, st);\n if (s.getNodeName() == null){\n log.error(\"Unable to add node with null name\");\n continue;\n }\n try {\n if (s.getNodeName() == null){\n log.error(\"Unable to add node with null name\");\n } else if (st.scd.getNode(s.getNodeName(), SampleNode.class) != null) {\n log.error(\"Unable to add duplicate node with name \"+s.getNodeName());\n } else if (s.getAttributes().size() <= 1){\n log.warn(\"Refusing to add sample \"+s.getNodeName()+\" without attributes\");\n } else {\n st.scd.addNode(s);\n }\n } catch (ParseException e) {\n log.error(\"Unable to add node \"+s.getNodeName(), e);\n } \n if (!groupMap.containsKey(id)){\n log.error(\"Problem locating publication ID \"+id+\" in publication maping\");\n continue;\n }\n if (!groupMap.get(id).contains(s.getNodeName())){\n log.error(\"Problem removing sample \"+s.getNodeName()+\" from publication maping\");\n continue;\n }\n if (publicationMap.containsKey(accession)){\n st.msi.publications.addAll(publicationMap.get(accession));\n log.debug(accession+\" \"+publicationMap.get(accession).size());\n log.debug(accession+\" \"+st.msi.publications.size());\n }\n groupMap.get(id).remove(s.getNodeName());\n if (groupMap.get(id).size() == 0){\n st.msi.submissionIdentifier = prefix+\"-\"+id;\n st.msi.submissionIdentifier = st.msi.submissionIdentifier.replace(\" \", \"-\");\n st.msi.submissionIdentifier = st.msi.submissionIdentifier.replace(\"&\", \"and\");\n if (wgs){\n String speciesName = null;\n for (SampleNode sn : st.scd.getNodes(SampleNode.class)){\n for (SCDNodeAttribute a : sn.getAttributes()){\n if (OrganismAttribute.class.isInstance(a)){\n OrganismAttribute oa = (OrganismAttribute) a;\n speciesName = a.getAttributeValue();\n }\n }\n }\n if (speciesName == null){\n log.warn(\"Unable to determine species name\");\n } else {\n st.msi.submissionTitle = \"Whole Genome Shotgun sequencing of \"+speciesName;\n }\n } else if (tsa){\n String speciesName = null;\n for (SampleNode sn : st.scd.getNodes(SampleNode.class)){\n for (SCDNodeAttribute a : sn.getAttributes()){\n if (OrganismAttribute.class.isInstance(a)){\n OrganismAttribute oa = (OrganismAttribute) a;\n speciesName = a.getAttributeValue();\n }\n }\n }\n if (speciesName == null){\n log.warn(\"Unable to determine species name\");\n } else {\n st.msi.submissionTitle = \"Transcriptome Shotgun sequencing of \"+speciesName;\n }\n } else if (bar){\n st.msi.submissionTitle = st.msi.submissionIdentifier;\n }\n log.debug(\"No. of publications = \"+st.msi.publications.size());\n log.debug(\"Empty? \"+st.msi.publications.isEmpty());\n File outputSubDir = new File(outputFile, st.msi.submissionIdentifier);\n File sampletabPre = new File(outputSubDir, \"sampletab.pre.txt\");\n outputSubDir.mkdirs();\n log.info(\"Writing \"+sampletabPre);\n SampleTabWriter sampletabwriter = null;\n try {\n sampletabwriter = new SampleTabWriter(new BufferedWriter(new FileWriter(sampletabPre)));\n sampletabwriter.write(st);\n } catch (IOException e) {\n log.error(\"Unable to write to \"+sampletabPre, e);\n } finally {\n if (sampletabwriter != null){\n try {\n sampletabwriter.close();\n } catch (IOException e) {\n }\n }\n }\n groupMap.remove(id);\n stMap.remove(id);\n }\n }\n }\n }\n reader.close();\n } finally {\n try {\n if (reader != null){\n reader.close();\n }\n } catch (IOException e){\n }\n }\n }\n"} {"input": " public void handleEvent(Event e) {\n Player p;\n if (e.getStringValue().equals(getPlayerName())) {\n p = currentPlayer;\n } else {\n p = players.get(e.getSender());\n }\n if (p != null) {\n System.out.printf(\"Handling event from %s %n\", p.getName());\n }\n switch (e.getType()) {\n case RUN_RIGHT: {\n p.accelerateX(Physics.RUN_SPEED);\n } break;\n case RUN_LEFT: {\n p.accelerateX(-Physics.RUN_SPEED);\n } break;\n case JUMP: {\n if (p.isCanJump()) {\n p.accelerateY(Physics.JUMP_SPEED);\n p.setCanJump(false);\n }\n } break;\n case SHOOT: {\n String[] pos = e.getStringValue().split(\" \");\n int sx = Integer.parseInt(pos[0]);\n int sy = Integer.parseInt(pos[1]);\n countShoot(currentPlayer.getPosition(), new Point(sx, sy));\n if (hitedPlayer != null) {\n Event event = new GameEvent(EventType.INCREMENT_HP, e.getSender(),\n hitedPlayer.getName() + \" -\" + HIT_DECREMENT_HP_VALUE);\n for (EventHandler h : handlers) {\n h.handleEvent(event);\n }\n hitedPlayer = null;\n handleEvent(event);\n }\n } break;\n case INCREMENT_HP: {\n String[] values = e.getStringValue().split(\" \");\n int leftHP = players.get(values[0]).changeHP(Integer.parseInt(values[1]));\n if (leftHP <= 0) {\n GameEvent event = new GameEvent(EventType.KILLED, e.getSender(), values[0]);\n for (EventHandler h : handlers) {\n h.handleEvent(event);\n }\n handleEvent(event);\n }\n } break;\n case KILLED: {\n System.out.printf(\"%s: %s killed %s%n\", playerName, e.getSender(), e.getStringValue());\n rate.incScore(players.get(e.getSender()), 1);\n rate.incScore(players.get(e.getStringValue()), -1);\n GameEvent event = new GameEvent(EventType.REBORN,\n e.getSender(), e.getStringValue());\n for (EventHandler h : handlers) {\n h.handleEvent(event);\n }\n handleEvent(event);\n } break;\n case REBORN: {\n spawn(players.get(e.getStringValue()));\n } break;\n case JOIN_NEW_PLAYER: {\n String[] playerInfo = e.getStringValue().split(\" \");\n int x = Integer.parseInt(playerInfo[0]);\n int y = Integer.parseInt(playerInfo[1]);\n Player newPlayer = new Player(x, y);\n newPlayer.setName(e.getSender());\n players.put(newPlayer.getName(), newPlayer);\n rate.addPlayer(newPlayer);\n } break;\n case MOVE_PLAYER: {\n if (p != currentPlayer && p != null) {\n String[] pos = e.getStringValue().split(\" \");\n int x = Integer.parseInt(pos[0]);\n int y = Integer.parseInt(pos[1]);\n p.setX(x);\n p.setY(y);\n }\n } break;\n }\n }\n", "output": " public void handleEvent(Event e) {\n Player p;\n if (e.getStringValue().equals(getPlayerName())) {\n p = currentPlayer;\n } else {\n p = players.get(e.getSender());\n }\n if (p != null) {\n System.out.printf(\"Handling event from %s %n\", p.getName());\n }\n switch (e.getType()) {\n case RUN_RIGHT: {\n if (p != null) {\n p.accelerateX(Physics.RUN_SPEED);\n }\n } break;\n case RUN_LEFT: {\n if (p != null) {\n p.accelerateX(-Physics.RUN_SPEED);\n }\n } break;\n case JUMP: {\n if (p != null) {\n if (p.isCanJump()) {\n p.accelerateY(Physics.JUMP_SPEED);\n p.setCanJump(false);\n }\n }\n } break;\n case SHOOT: {\n String[] pos = e.getStringValue().split(\" \");\n int sx = Integer.parseInt(pos[0]);\n int sy = Integer.parseInt(pos[1]);\n countShoot(currentPlayer.getPosition(), new Point(sx, sy));\n if (hitedPlayer != null) {\n Event event = new GameEvent(EventType.INCREMENT_HP, e.getSender(),\n hitedPlayer.getName() + \" -\" + HIT_DECREMENT_HP_VALUE);\n for (EventHandler h : handlers) {\n h.handleEvent(event);\n }\n hitedPlayer = null;\n handleEvent(event);\n }\n } break;\n case INCREMENT_HP: {\n String[] values = e.getStringValue().split(\" \");\n int leftHP = players.get(values[0]).changeHP(Integer.parseInt(values[1]));\n if (leftHP <= 0) {\n GameEvent event = new GameEvent(EventType.KILLED, e.getSender(), values[0]);\n for (EventHandler h : handlers) {\n h.handleEvent(event);\n }\n handleEvent(event);\n }\n } break;\n case KILLED: {\n System.out.printf(\"%s: %s killed %s%n\", playerName, e.getSender(), e.getStringValue());\n rate.incScore(players.get(e.getSender()), 1);\n rate.incScore(players.get(e.getStringValue()), -1);\n GameEvent event = new GameEvent(EventType.REBORN,\n e.getSender(), e.getStringValue());\n for (EventHandler h : handlers) {\n h.handleEvent(event);\n }\n handleEvent(event);\n } break;\n case REBORN: {\n spawn(players.get(e.getStringValue()));\n } break;\n case JOIN_NEW_PLAYER: {\n String[] playerInfo = e.getStringValue().split(\" \");\n int x = Integer.parseInt(playerInfo[0]);\n int y = Integer.parseInt(playerInfo[1]);\n Player newPlayer = new Player(x, y);\n newPlayer.setName(e.getSender());\n players.put(newPlayer.getName(), newPlayer);\n rate.addPlayer(newPlayer);\n } break;\n case MOVE_PLAYER: {\n if (p != currentPlayer && p != null) {\n String[] pos = e.getStringValue().split(\" \");\n int x = Integer.parseInt(pos[0]);\n int y = Integer.parseInt(pos[1]);\n p.setX(x);\n p.setY(y);\n }\n } break;\n }\n }\n"} {"input": "\tpublic void draw(int x, int y){\n\t\tif (covered==true){\n\t\t\tRenderer.Tile_Break.draw(x*size, y*size);\n\t\t\tRenderer.print(x*size, y*size, \"\"+art, 0.5f);\n\t\t} else {\n\t\t\tRenderer.Tile_Empty.draw(x*size, y*size); \n\t\t\tswitch(art)\n\t\t\t{\n\t\t\t\tcase 1: Renderer.Tile_Health.draw(x*size, y*size); break; \n\t\t\t\tcase 2: Renderer.Tile_addbomb.draw(x*size, y*size); break; \n\t\t\t\tcase 3: Renderer.Tile_kick.draw(x*size, y*size); break; \n\t\t\t\tcase 4: \n\t\t\t\tcase 5: Renderer.Tile_confuse.draw(x*size, y*size); break;\n\t\t\t\tcase 6: Renderer.Tile_teleport.draw(x*size, y*size); break;\n\t\t\t\tcase 7: Renderer.Tile_speed.draw(x*size, y*size); break;\n\t\t\t\tcase 8: Renderer.Tile_slow.draw(x*size, y*size); break;\n\t\t\t\tcase 9: \n\t\t\t\tcase 10: \n\t\t\t\tcase 11: \n\t\t\t\tcase 12: \n\t\t\t\tcase 13: \n\t\t\t}\n\t\t}\n", "output": "\tpublic void draw(int x, int y){\n\t\tif (covered==true){\n\t\t\tRenderer.Tile_Break.draw(x*size, y*size);\n\t\t\tRenderer.print(x*size, y*size, \"\"+art, 0.5f);\n\t\t} else {\n\t\t\tRenderer.Tile_Empty.draw(x*size, y*size); \n\t\t\tswitch(art)\n\t\t\t{\n\t\t\t\tcase 1: Renderer.Tile_Health.draw(x*size, y*size); break; \n\t\t\t\tcase 2: Renderer.Tile_addbomb.draw(x*size, y*size); break; \n\t\t\t\tcase 3: Renderer.Tile_kick.draw(x*size, y*size); break; \n\t\t\t\tcase 4: break;\n\t\t\t\tcase 5: Renderer.Tile_slow.draw(x*size, y*size); break;\n\t\t\t\tcase 6: Renderer.Tile_teleport.draw(x*size, y*size); break;\n\t\t\t\tcase 7: Renderer.Tile_speed.draw(x*size, y*size); break;\n\t\t\t\tcase 8: Renderer.Tile_confuse.draw(x*size, y*size); break;\n\t\t\t\tcase 9: \n\t\t\t\tcase 10: \n\t\t\t}\n\t\t}\n"} {"input": "\tpublic Object adapt(Object o) {\n\t\tSearchResult result = new SearchResult();\n\t\tif(!(o instanceof String)) {\n\t\t\tthrow new IllegalArgumentException(\"Argument is not a String\");\n\t\t}\n\t\tString line = (String) o;\n\t\tString[] tokens = line.split(\" \");\n\t\tif (tokens.length != 9) {\n\t\t\treturn null;\n\t\t}\n\t\tString url = tokens[0];\n\t\tString captureDate = tokens[1];\n\t\tString origHost = tokens[2];\n\t\tString mimeType = tokens[3];\n\t\tString httpResponseCode = tokens[4];\n\t\tString md5Fragment = tokens[5];\n\t\tString redirectUrl = tokens[6];\n\t\tlong compressedOffset = Long.parseLong(tokens[7]);\n\t\tString arcFileName = tokens[8];\n\t\tString origUrl = url;\n\t\ttry {\n\t\t\tUURI uri = UURIFactory.getInstance(WaybackConstants.HTTP_URL_PREFIX +\n\t\t\t\t\turl);\n\t\t\torigUrl = origHost + uri.getEscapedPathQuery();\n\t\t} catch (URIException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tresult.put(WaybackConstants.RESULT_URL, origUrl);\n\t\tresult.put(WaybackConstants.RESULT_URL_KEY, url);\n\t\tresult.put(WaybackConstants.RESULT_CAPTURE_DATE, captureDate);\n\t\tresult.put(WaybackConstants.RESULT_ORIG_HOST, origHost);\n\t\tresult.put(WaybackConstants.RESULT_MIME_TYPE, mimeType);\n\t\tresult.put(WaybackConstants.RESULT_HTTP_CODE, httpResponseCode);\n\t\tresult.put(WaybackConstants.RESULT_MD5_DIGEST, md5Fragment);\n\t\tresult.put(WaybackConstants.RESULT_REDIRECT_URL, redirectUrl);\n\t\tresult.put(WaybackConstants.RESULT_OFFSET, String.valueOf(compressedOffset));\n\t\tresult.put(WaybackConstants.RESULT_ARC_FILE, arcFileName);\n\t\treturn result;\n\t}\n", "output": "\tpublic Object adapt(Object o) {\n\t\tSearchResult result = new SearchResult();\n\t\tif(!(o instanceof String)) {\n\t\t\tthrow new IllegalArgumentException(\"Argument is not a String\");\n\t\t}\n\t\tString line = (String) o;\n\t\tString[] tokens = line.split(\" \");\n\t\tif (tokens.length != 9) {\n\t\t\treturn null;\n\t\t}\n\t\tString url = tokens[0];\n\t\tString captureDate = tokens[1];\n\t\tString origHost = tokens[2];\n\t\tString mimeType = tokens[3];\n\t\tString httpResponseCode = tokens[4];\n\t\tString md5Fragment = tokens[5];\n\t\tString redirectUrl = tokens[6];\n\t\tlong compressedOffset = Long.parseLong(tokens[7]);\n\t\tString arcFileName = tokens[8];\n\t\tString origUrl = url;\n\t\tif(!url.startsWith(WaybackConstants.DNS_URL_PREFIX)) {\n\t\t\ttry {\n\t\t\t\tUURI uri = UURIFactory.getInstance(\n\t\t\t\t\t\tWaybackConstants.HTTP_URL_PREFIX + url);\n\t\t\t\torigUrl = origHost + uri.getEscapedPathQuery();\n\t\t\t} catch (URIException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tresult.put(WaybackConstants.RESULT_URL, origUrl);\n\t\tresult.put(WaybackConstants.RESULT_URL_KEY, url);\n\t\tresult.put(WaybackConstants.RESULT_CAPTURE_DATE, captureDate);\n\t\tresult.put(WaybackConstants.RESULT_ORIG_HOST, origHost);\n\t\tresult.put(WaybackConstants.RESULT_MIME_TYPE, mimeType);\n\t\tresult.put(WaybackConstants.RESULT_HTTP_CODE, httpResponseCode);\n\t\tresult.put(WaybackConstants.RESULT_MD5_DIGEST, md5Fragment);\n\t\tresult.put(WaybackConstants.RESULT_REDIRECT_URL, redirectUrl);\n\t\tresult.put(WaybackConstants.RESULT_OFFSET, String.valueOf(compressedOffset));\n\t\tresult.put(WaybackConstants.RESULT_ARC_FILE, arcFileName);\n\t\treturn result;\n\t}\n"} {"input": "\tpublic void execute(AwRequest awRequest) {\n\t\ttry {\n\t\t\tgetDao().execute(awRequest);\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tList<MobilityQueryResult> results = (List<MobilityQueryResult>) awRequest.getResultList();\n\t\t\tList<MobilityQueryResult> chunkedResults = new ArrayList<MobilityQueryResult>();\n\t\t\tChunkedMobilityQueryResult currentChunkedResult = new ChunkedMobilityQueryResult();\n\t\t\tint count = 0, still = 0, walk = 0, run = 0, bike = 0, drive = 0;\n\t\t\tString startTimestamp = null;\n\t\t\tfor(int i = 0; i < results.size(); i++) { \n\t\t\t\tMobilityQueryResult result = results.get(i);\n\t\t\t\tif(0 == count) {\n\t\t\t\t\tstartTimestamp = result.getTimestamp();\n\t\t\t\t}\n\t\t\t\tcount++;\n\t\t\t\tcurrentChunkedResult.setLocation(result.getLocation());\n\t\t\t\tcurrentChunkedResult.setLocationStatus(result.getLocationStatus());\n\t\t\t\tcurrentChunkedResult.setTimestamp(result.getTimestamp());\n\t\t\t\tcurrentChunkedResult.setTimezone(result.getTimezone());\n\t\t\t\tif(\"still\".equals(result.getValue())) {\n\t\t\t\t\tstill++;\n\t\t\t\t} else if(\"walk\".equals(result.getValue())) {\n\t\t\t\t\twalk++;\n\t\t\t\t} else if(\"run\".equals(result.getValue())) {\n\t\t\t\t\trun++;\n\t\t\t\t} else if(\"bike\".equals(result.getValue())) {\n\t\t\t\t\tbike++;\n\t\t\t\t} else if(\"drive\".equals(result.getValue())) {\n\t\t\t\t\tdrive++;\n\t\t\t\t} else {\n\t\t\t\t\t_logger.warn(\"unknown mobility mode found: \" + result.getValue());\n\t\t\t\t}\n\t\t\t\tif(10 == count || (i == (results.size() - 1)) ) {\n\t\t\t\t\tJSONObject o = new JSONObject();\n\t\t\t\t\ttry {\n\t\t\t\t\t\to.put(\"still\", still);\n\t\t\t\t\t\to.put(\"walk\", walk);\n\t\t\t\t\t\to.put(\"run\", run);\n\t\t\t\t\t\to.put(\"bike\", bike);\n\t\t\t\t\t\to.put(\"drive\", drive);\n\t\t\t\t\t} catch (JSONException jsone) { \n\t\t\t\t\t\t_logger.warn(jsone);\n\t\t\t\t\t}\n\t\t\t\t\tcurrentChunkedResult.setValue(o);\n\t\t\t\t\tcurrentChunkedResult.setDuration(calcDuration(startTimestamp, currentChunkedResult.getTimestamp()));\n\t\t\t\t\tchunkedResults.add(currentChunkedResult);\n\t\t\t\t\tcount = 0; still = 0; walk = 0; run = 0; bike = 0; drive = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tresults.clear();\n\t\t\tawRequest.setResultList(chunkedResults);\n\t\t} catch (DataAccessException dae) {\n\t\t\tthrow new ServiceException(dae);\n\t\t}\n\t}\n", "output": "\tpublic void execute(AwRequest awRequest) {\n\t\ttry {\n\t\t\tgetDao().execute(awRequest);\n\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\tList<MobilityQueryResult> results = (List<MobilityQueryResult>) awRequest.getResultList();\n\t\t\tList<MobilityQueryResult> chunkedResults = new ArrayList<MobilityQueryResult>();\n\t\t\tChunkedMobilityQueryResult currentChunkedResult = new ChunkedMobilityQueryResult();\n\t\t\tint count = 0, still = 0, walk = 0, run = 0, bike = 0, drive = 0;\n\t\t\tString startTimestamp = null;\n\t\t\tfor(int i = 0; i < results.size(); i++) { \n\t\t\t\tMobilityQueryResult result = results.get(i);\n\t\t\t\tif(0 == count) {\n\t\t\t\t\tstartTimestamp = result.getTimestamp();\n\t\t\t\t}\n\t\t\t\tcount++;\n\t\t\t\tcurrentChunkedResult.setLocation(result.getLocation());\n\t\t\t\tcurrentChunkedResult.setLocationStatus(result.getLocationStatus());\n\t\t\t\tcurrentChunkedResult.setTimestamp(result.getTimestamp());\n\t\t\t\tcurrentChunkedResult.setTimezone(result.getTimezone());\n\t\t\t\tif(\"still\".equals(result.getValue())) {\n\t\t\t\t\tstill++;\n\t\t\t\t} else if(\"walk\".equals(result.getValue())) {\n\t\t\t\t\twalk++;\n\t\t\t\t} else if(\"run\".equals(result.getValue())) {\n\t\t\t\t\trun++;\n\t\t\t\t} else if(\"bike\".equals(result.getValue())) {\n\t\t\t\t\tbike++;\n\t\t\t\t} else if(\"drive\".equals(result.getValue())) {\n\t\t\t\t\tdrive++;\n\t\t\t\t} else {\n\t\t\t\t\t_logger.warn(\"unknown mobility mode found: \" + result.getValue());\n\t\t\t\t}\n\t\t\t\tif(10 == count || (i == (results.size() - 1)) ) {\n\t\t\t\t\tJSONObject o = new JSONObject();\n\t\t\t\t\ttry {\n\t\t\t\t\t\to.put(\"still\", still);\n\t\t\t\t\t\to.put(\"walk\", walk);\n\t\t\t\t\t\to.put(\"run\", run);\n\t\t\t\t\t\to.put(\"bike\", bike);\n\t\t\t\t\t\to.put(\"drive\", drive);\n\t\t\t\t\t} catch (JSONException jsone) { \n\t\t\t\t\t\t_logger.warn(jsone);\n\t\t\t\t\t}\n\t\t\t\t\tcurrentChunkedResult.setValue(o);\n\t\t\t\t\tcurrentChunkedResult.setDuration(calcDuration(startTimestamp, currentChunkedResult.getTimestamp()));\n\t\t\t\t\tchunkedResults.add(currentChunkedResult);\n\t\t\t\t\tcount = 0; still = 0; walk = 0; run = 0; bike = 0; drive = 0;\n\t\t\t\t\tcurrentChunkedResult = new ChunkedMobilityQueryResult();\n\t\t\t\t}\n\t\t\t}\n\t\t\tresults.clear();\n\t\t\tawRequest.setResultList(chunkedResults);\n\t\t} catch (DataAccessException dae) {\n\t\t\tthrow new ServiceException(dae);\n\t\t}\n\t}\n"} {"input": "public static void\nmain(String argv[]) throws IOException {\n\tString server;\n\tint arg;\n\tMessage query, response;\n\tRecord rec;\n\tRecord opt = null;\n\tResolver res = null;\n\tboolean printQuery = false;\n\tif (argv.length < 1) {\n\t\tusage();\n\t}\n\ttry {\n\t\targ = 0;\n\t\tif (argv[arg].startsWith(\"@\")) {\n\t\t\tserver = argv[arg++].substring(1);\n\t\t\tres = new SimpleResolver(server);\n\t\t}\n\t\telse\n\t\t\tres = new ExtendedResolver();\n\t\tString nameString = argv[arg++];\n\t\tif (nameString.equals(\"-x\")) {\n\t\t\tname = new Name(dns.inaddrString(argv[arg++]));\n\t\t\ttype = Type.PTR;\n\t\t\t_class = DClass.IN;\n\t\t}\n\t\telse {\n\t\t\tname = new Name(nameString);\n\t\t\ttype = Type.value(argv[arg]);\n\t\t\tif (type < 0)\n\t\t\t\ttype = Type.A;\n\t\t\telse\n\t\t\t\targ++;\n\t\t\t_class = DClass.value(argv[arg]);\n\t\t\tif (_class < 0)\n\t\t\t\t_class = DClass.IN;\n\t\t\telse\n\t\t\t\targ++;\n\t\t}\n\t\twhile (argv[arg].startsWith(\"-\") && argv[arg].length() > 1) {\n\t\t\tswitch (argv[arg].charAt(1)) {\n\t\t\t case 'p':\n\t\t\t\tString portStr;\n\t\t\t\tint port;\n\t\t\t\tif (argv[arg].length() > 2)\n\t\t\t\t\tportStr = argv[arg].substring(2);\n\t\t\t\telse\n\t\t\t\t\tportStr = argv[++arg];\n\t\t\t\tport = Integer.parseInt(portStr);\n\t\t\t\tif (port < 0 || port > 65536) {\n\t\t\t\t\tSystem.out.println(\"Invalid port\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tres.setPort(port);\n\t\t\t\tbreak;\n\t\t\t case 'k':\n\t\t\t\tString key;\n\t\t\t\tif (argv[arg].length() > 2)\n\t\t\t\t\tkey = argv[arg].substring(2);\n\t\t\t\telse\n\t\t\t\t\tkey = argv[++arg];\n\t\t\t\tint index = key.indexOf('/');\n\t\t\t\tif (index < 0)\n\t\t\t\t\tres.setTSIGKey(key);\n\t\t\t\telse\n\t\t\t\t\tres.setTSIGKey(key.substring(0, index),\n\t\t\t\t\t\t key.substring(index+1));\n\t\t\t\tbreak;\n\t\t\t case 't':\n\t\t\t\tres.setTCP(true);\n\t\t\t\tbreak;\n\t\t\t case 'i':\n\t\t\t\tres.setIgnoreTruncation(true);\n\t\t\t\tbreak;\n\t\t\t case 'e':\n\t\t\t\tString ednsStr;\n\t\t\t\tint edns;\n\t\t\t\tif (argv[arg].length() > 2)\n\t\t\t\t\tednsStr = argv[arg].substring(2);\n\t\t\t\telse\n\t\t\t\t\tednsStr = argv[++arg];\n\t\t\t\tedns = Integer.parseInt(ednsStr);\n\t\t\t\tif (edns < 0 || edns > 1) {\n\t\t\t\t\tSystem.out.println(\"Unsupported \" +\n\t\t\t\t\t\t\t \"EDNS level: \" +\n\t\t\t\t\t\t\t edns);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tres.setEDNS(edns);\n\t\t\t\tbreak;\n\t\t\t case 'd':\n\t\t\t \topt = new OPTRecord((short)1280, (byte)0,\n\t\t\t\t\t\t (byte)0, Flags.DO);\n\t\t\t\tbreak;\n\t\t\t case 'q':\n\t\t\t \tprintQuery = true;\n\t\t\t\tbreak;\n\t\t\t default:\n\t\t\t\tSystem.out.print(\"Invalid option\");\n\t\t\t\tSystem.out.println(argv[arg]);\n\t\t\t}\n\t\t\targ++;\n\t\t}\n\t}\n\tcatch (ArrayIndexOutOfBoundsException e) {\n\t\tif (name == null)\n\t\t\tusage();\n\t}\n\trec = Record.newRecord(name, type, _class);\n\tquery = Message.newQuery(rec);\n\tif (opt != null)\n\t\tquery.addRecord(opt, Section.ADDITIONAL);\n\tif (printQuery)\n\t\tSystem.out.println(query);\n\tresponse = res.send(query);\n\tif (type == Type.AXFR)\n\t\tdoAXFR(response);\n\telse\n\t\tdoQuery(response);\n}\n", "output": "public static void\nmain(String argv[]) throws IOException {\n\tString server;\n\tint arg;\n\tMessage query, response;\n\tRecord rec;\n\tRecord opt = null;\n\tResolver res = null;\n\tboolean printQuery = false;\n\tif (argv.length < 1) {\n\t\tusage();\n\t}\n\ttry {\n\t\targ = 0;\n\t\tif (argv[arg].startsWith(\"@\")) {\n\t\t\tserver = argv[arg++].substring(1);\n\t\t\tres = new SimpleResolver(server);\n\t\t}\n\t\telse\n\t\t\tres = new ExtendedResolver();\n\t\tString nameString = argv[arg++];\n\t\tif (nameString.equals(\"-x\")) {\n\t\t\tname = new Name(dns.inaddrString(argv[arg++]));\n\t\t\ttype = Type.PTR;\n\t\t\t_class = DClass.IN;\n\t\t}\n\t\telse {\n\t\t\tname = new Name(nameString);\n\t\t\ttype = Type.value(argv[arg]);\n\t\t\tif (type < 0)\n\t\t\t\ttype = Type.A;\n\t\t\telse\n\t\t\t\targ++;\n\t\t\t_class = DClass.value(argv[arg]);\n\t\t\tif (_class < 0)\n\t\t\t\t_class = DClass.IN;\n\t\t\telse\n\t\t\t\targ++;\n\t\t}\n\t\twhile (argv[arg].startsWith(\"-\") && argv[arg].length() > 1) {\n\t\t\tswitch (argv[arg].charAt(1)) {\n\t\t\t case 'p':\n\t\t\t\tString portStr;\n\t\t\t\tint port;\n\t\t\t\tif (argv[arg].length() > 2)\n\t\t\t\t\tportStr = argv[arg].substring(2);\n\t\t\t\telse\n\t\t\t\t\tportStr = argv[++arg];\n\t\t\t\tport = Integer.parseInt(portStr);\n\t\t\t\tif (port < 0 || port > 65536) {\n\t\t\t\t\tSystem.out.println(\"Invalid port\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tres.setPort(port);\n\t\t\t\tbreak;\n\t\t\t case 'k':\n\t\t\t\tString key;\n\t\t\t\tif (argv[arg].length() > 2)\n\t\t\t\t\tkey = argv[arg].substring(2);\n\t\t\t\telse\n\t\t\t\t\tkey = argv[++arg];\n\t\t\t\tint index = key.indexOf('/');\n\t\t\t\tif (index < 0)\n\t\t\t\t\tres.setTSIGKey(key);\n\t\t\t\telse\n\t\t\t\t\tres.setTSIGKey(key.substring(0, index),\n\t\t\t\t\t\t key.substring(index+1));\n\t\t\t\tbreak;\n\t\t\t case 't':\n\t\t\t\tres.setTCP(true);\n\t\t\t\tbreak;\n\t\t\t case 'i':\n\t\t\t\tres.setIgnoreTruncation(true);\n\t\t\t\tbreak;\n\t\t\t case 'e':\n\t\t\t\tString ednsStr;\n\t\t\t\tint edns;\n\t\t\t\tif (argv[arg].length() > 2)\n\t\t\t\t\tednsStr = argv[arg].substring(2);\n\t\t\t\telse\n\t\t\t\t\tednsStr = argv[++arg];\n\t\t\t\tedns = Integer.parseInt(ednsStr);\n\t\t\t\tif (edns < 0 || edns > 1) {\n\t\t\t\t\tSystem.out.println(\"Unsupported \" +\n\t\t\t\t\t\t\t \"EDNS level: \" +\n\t\t\t\t\t\t\t edns);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tres.setEDNS(edns);\n\t\t\t\tbreak;\n\t\t\t case 'd':\n\t\t\t \topt = new OPTRecord((short)1280, (byte)0,\n\t\t\t\t\t\t (byte)0, Flags.DO);\n\t\t\t\tbreak;\n\t\t\t case 'q':\n\t\t\t \tprintQuery = true;\n\t\t\t\tbreak;\n\t\t\t default:\n\t\t\t\tSystem.out.print(\"Invalid option: \");\n\t\t\t\tSystem.out.println(argv[arg]);\n\t\t\t}\n\t\t\targ++;\n\t\t}\n\t}\n\tcatch (ArrayIndexOutOfBoundsException e) {\n\t\tif (name == null)\n\t\t\tusage();\n\t}\n\trec = Record.newRecord(name, type, _class);\n\tquery = Message.newQuery(rec);\n\tif (opt != null)\n\t\tquery.addRecord(opt, Section.ADDITIONAL);\n\tif (printQuery)\n\t\tSystem.out.println(query);\n\tresponse = res.send(query);\n\tif (type == Type.AXFR)\n\t\tdoAXFR(response);\n\telse\n\t\tdoQuery(response);\n}\n"} {"input": " protected void reloadConfigFile() throws NicoLiveAlertException {\n File configFile = new File(getDataFolder(), \"config.yml\");\n if ( !configFile.exists() ) {\n Utility.copyFileFromJar(getFile(), configFile, \"config_ja.yml\", false);\n }\n reloadConfig();\n FileConfiguration config = getConfig();\n community = config.getStringList(\"community\");\n if ( community == null ) {\n community = new ArrayList<String>();\n }\n user = config.getStringList(\"user\");\n if ( user == null ) {\n user = new ArrayList<String>();\n }\n Object communityNicknames_temp = config.get(\"communityNicknames\");\n if ( communityNicknames_temp != null ) {\n communityNicknames = (MemorySection)communityNicknames_temp;\n }\n Object userNicknames_temp = config.get(\"userNicknames\");\n if ( userNicknames_temp != null ) {\n userNicknames = (MemorySection)userNicknames_temp;\n }\n messageTemplate = Utility.replaceColorCode(\n config.getString(\"messageTemplate\", \"&c\u30cb\u30b3\u751f [$com]\u3067[$title]\u304c\u958b\u59cb\u3057\u307e\u3057\u305f\uff01&r\") );\n messageTemplate2 = Utility.replaceColorCode(\n config.getString(\"messageTemplate2\", \"\") );\n messageTemplate3 = Utility.replaceColorCode(\n config.getString(\"messageTemplate3\", \"\") );\n messageTemplate4 = Utility.replaceColorCode(\n config.getString(\"messageTemplate4\", \"\") );\n messageTemplate5 = Utility.replaceColorCode(\n config.getString(\"messageTemplate5\", \"\") );\n messageTemplateURL = config.getString(\"messageTemplateURL\", \n \"{\\\"text\\\":\\\"\uff1e\u653e\u9001\u30da\u30fc\u30b8\u306f\u3053\u3061\u3089\uff01\uff1c\\\",\"\n + \"\\\"color\\\":\\\"red\\\",\\\"underlined\\\":\\\"true\\\",\\\"clickEvent\\\":{\"\n + \"\\\"action\\\":\\\"open_url\\\",\\\"value\\\":\\\"$url\\\"}}\");\n titleKeywords = config.getStringList(\"titleKeywords\");\n if ( titleKeywords == null ) {\n titleKeywords = new ArrayList<String>();\n }\n }\n", "output": " protected void reloadConfigFile() throws NicoLiveAlertException {\n File configFile = new File(getDataFolder(), \"config.yml\");\n if ( !configFile.exists() ) {\n Utility.copyFileFromJar(getFile(), configFile, \"config_ja.yml\", false);\n }\n reloadConfig();\n FileConfiguration config = getConfig();\n community = config.getStringList(\"community\");\n if ( community == null ) {\n community = new ArrayList<String>();\n }\n user = config.getStringList(\"user\");\n if ( user == null ) {\n user = new ArrayList<String>();\n }\n Object communityNicknames_temp = config.get(\"communityNicknames\");\n if ( communityNicknames_temp != null ) {\n communityNicknames = (MemorySection)communityNicknames_temp;\n }\n Object userNicknames_temp = config.get(\"userNicknames\");\n if ( userNicknames_temp != null ) {\n userNicknames = (MemorySection)userNicknames_temp;\n }\n messageTemplate = Utility.replaceColorCode(\n config.getString(\"messageTemplate\", \"&c\u30cb\u30b3\u751f\u304c\u958b\u59cb\u3057\u307e\u3057\u305f\uff01\") );\n messageTemplate2 = Utility.replaceColorCode(\n config.getString(\"messageTemplate2\", \"&b\u30b3\u30df\u30e5\u30cb\u30c6\u30a3\uff1a$com\") );\n messageTemplate3 = Utility.replaceColorCode(\n config.getString(\"messageTemplate3\", \"&b\u653e\u9001\u8005\uff1a$user\") );\n messageTemplate4 = Utility.replaceColorCode(\n config.getString(\"messageTemplate4\", \"&b$title\") );\n messageTemplate5 = Utility.replaceColorCode(\n config.getString(\"messageTemplate5\", \"\") );\n messageTemplateURL = config.getString(\"messageTemplateURL\", \n \"{\\\"text\\\":\\\"\uff1e\u653e\u9001\u30da\u30fc\u30b8\u306f\u3053\u3061\u3089\uff01\uff1c\\\",\"\n + \"\\\"color\\\":\\\"red\\\",\\\"underlined\\\":\\\"true\\\",\\\"clickEvent\\\":{\"\n + \"\\\"action\\\":\\\"open_url\\\",\\\"value\\\":\\\"$url\\\"}}\");\n titleKeywords = config.getStringList(\"titleKeywords\");\n if ( titleKeywords == null ) {\n titleKeywords = new ArrayList<String>();\n }\n }\n"} {"input": "\tpublic String defaultSInvariantType(SInvariantType node,\n\t\t\tPrettyPrinterEnv question) throws AnalysisException\n\t{\n\t\tILexNameToken name = null;\n\t\tswitch(node.kindSInvariantType())\n\t\t{\n\t\t\tcase ANamedInvariantType.kindSInvariantType:\n\t\t\t\tname = ((ANamedInvariantType)node).getName();\n\t\t\t\tbreak;\n\t\t\tcase ARecordInvariantType.kindSInvariantType:\n\t\t\t\tname = ((ARecordInvariantType)node).getName();\n\t\t\t\tbreak;\n\t\t}\n\t\tif(name !=null)\n\t\t{\n\t\t\tif(name.getModule()!=null && !name.getModule().equals(question.getClassName()))\n\t\t\t{\n\t\t\t\treturn name.module+\"`\"+name.getFullName();\n\t\t\t}\n\t\t\treturn name.getFullName();\n\t\t}\n\t\treturn \"unresolved\";\n\t}\n", "output": "\tpublic String defaultSInvariantType(SInvariantType node,\n\t\t\tPrettyPrinterEnv question) throws AnalysisException\n\t{\n\t\tILexNameToken name = null;\n\t\tswitch(node.kindSInvariantType())\n\t\t{\n\t\t\tcase ANamedInvariantType.kindSInvariantType:\n\t\t\t\tname = ((ANamedInvariantType)node).getName();\n\t\t\t\tbreak;\n\t\t\tcase ARecordInvariantType.kindSInvariantType:\n\t\t\t\tname = ((ARecordInvariantType)node).getName();\n\t\t\t\tbreak;\n\t\t}\n\t\tif(name !=null)\n\t\t{\n\t\t\tif(name.getModule()!=null && !name.getModule().equals(question.getClassName()))\n\t\t\t{\n\t\t\t\treturn name.getModule()+\"`\"+name.getFullName();\n\t\t\t}\n\t\t\treturn name.getFullName();\n\t\t}\n\t\treturn \"unresolved\";\n\t}\n"} {"input": "\tpublic void startTickRun(int stage, long delta) throws InterruptedException {\n\t\tswitch (stage) {\n\t\t\tcase 0: {\n\t\t\t\tif(!spawnQueue.isEmpty()) {\n\t\t\t\t\tSpoutEntity e;\n\t\t\t\t\twhile ((e = (SpoutEntity)spawnQueue.poll()) != null) {\n\t\t\t\t\t\tthis.allocate(e);\n\t\t\t\t\t\tEntitySpawnEvent event = new EntitySpawnEvent(e, e.getPoint());\n\t\t\t\t\t\tSpout.getGame().getEventManager().callEvent(event);\n\t\t\t\t\t\tif (event.isCancelled()) {\n\t\t\t\t\t\t\tthis.deallocate((SpoutEntity) e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!removeQueue.isEmpty()) {\n\t\t\t\t\tSpoutEntity e;\n\t\t\t\t\twhile ((e = (SpoutEntity)removeQueue.poll()) != null) {\n\t\t\t\t\t\tthis.deallocate(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfloat dt = delta / 1000.f;\n\t\t\t\tfor (SpoutEntity ent : entityManager) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tent.onTick(dt);\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tSpout.getGame().getLogger().severe(\"Unhandled exception during tick for \" + ent.toString());\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tWorld world = getWorld();\n\t\t\t\tint[] updates;\n\t\t\t\tsynchronized (queuedPhysicsUpdates) {\n\t\t\t\t\tupdates = queuedPhysicsUpdates.toArray();\n\t\t\t\t\tqueuedPhysicsUpdates.clear();\n\t\t\t\t}\n\t\t\t\tfor (int key : updates) {\n\t\t\t\t\tint x = TByteTripleHashSet.key1(key);\n\t\t\t\t\tint y = TByteTripleHashSet.key2(key);\n\t\t\t\t\tint z = TByteTripleHashSet.key3(key);\n\t\t\t\t\tChunk chunk = chunks[x >> Chunk.CHUNK_SIZE_BITS][y >> Chunk.CHUNK_SIZE_BITS][z >> Chunk.CHUNK_SIZE_BITS].get();\n\t\t\t\t\tif (chunk != null) {\n\t\t\t\t\t\tBlockMaterial material = chunk.getBlockMaterial(x, y, z);\n\t\t\t\t\t\tif (material.hasPhysics()) {\n\t\t\t\t\t\t\tmaterial.onUpdate(world, x + (this.x << blockShifts), y + (this.y << blockShifts), z + (this.z << blockShifts));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int i = 0; i < LIGHT_PER_TICK; i++) {\n\t\t\t\t\tSpoutChunk toLight = lightingQueue.poll();\n\t\t\t\t\tif (toLight == null) break;\n\t\t\t\t\tif (toLight.isLoaded()) {\n\t\t\t\t\t\ttoLight.processQueuedLighting();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int i = 0; i < POPULATE_PER_TICK; i++) {\n\t\t\t\t\tChunk toPopulate = populationQueue.poll();\n\t\t\t\t\tif (toPopulate == null) break;\n\t\t\t\t\tif (toPopulate.isLoaded()) {\n\t\t\t\t\t\ttoPopulate.populate();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tChunk toUnload = unloadQueue.poll();\n\t\t\t\tif (toUnload != null) {\n\t\t\t\t\ttoUnload.unload(true);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 1: {\n\t\t\t\tfor (SpoutEntity ent : entityManager) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tent.resolve();\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tSpout.getGame().getLogger().severe(\"Unhandled exception during tick resolution for \" + ent.toString());\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new IllegalStateException(\"Number of states exceeded limit for SpoutRegion\");\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void startTickRun(int stage, long delta) throws InterruptedException {\n\t\tswitch (stage) {\n\t\t\tcase 0: {\n\t\t\t\tif(!spawnQueue.isEmpty()) {\n\t\t\t\t\tSpoutEntity e;\n\t\t\t\t\twhile ((e = (SpoutEntity)spawnQueue.poll()) != null) {\n\t\t\t\t\t\tthis.allocate(e);\n\t\t\t\t\t\tEntitySpawnEvent event = new EntitySpawnEvent(e, e.getPosition());\n\t\t\t\t\t\tSpout.getGame().getEventManager().callEvent(event);\n\t\t\t\t\t\tif (event.isCancelled()) {\n\t\t\t\t\t\t\tthis.deallocate((SpoutEntity) e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!removeQueue.isEmpty()) {\n\t\t\t\t\tSpoutEntity e;\n\t\t\t\t\twhile ((e = (SpoutEntity)removeQueue.poll()) != null) {\n\t\t\t\t\t\tthis.deallocate(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfloat dt = delta / 1000.f;\n\t\t\t\tfor (SpoutEntity ent : entityManager) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tent.onTick(dt);\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tSpout.getGame().getLogger().severe(\"Unhandled exception during tick for \" + ent.toString());\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tWorld world = getWorld();\n\t\t\t\tint[] updates;\n\t\t\t\tsynchronized (queuedPhysicsUpdates) {\n\t\t\t\t\tupdates = queuedPhysicsUpdates.toArray();\n\t\t\t\t\tqueuedPhysicsUpdates.clear();\n\t\t\t\t}\n\t\t\t\tfor (int key : updates) {\n\t\t\t\t\tint x = TByteTripleHashSet.key1(key);\n\t\t\t\t\tint y = TByteTripleHashSet.key2(key);\n\t\t\t\t\tint z = TByteTripleHashSet.key3(key);\n\t\t\t\t\tChunk chunk = chunks[x >> Chunk.CHUNK_SIZE_BITS][y >> Chunk.CHUNK_SIZE_BITS][z >> Chunk.CHUNK_SIZE_BITS].get();\n\t\t\t\t\tif (chunk != null) {\n\t\t\t\t\t\tBlockMaterial material = chunk.getBlockMaterial(x, y, z);\n\t\t\t\t\t\tif (material.hasPhysics()) {\n\t\t\t\t\t\t\tmaterial.onUpdate(world, x + (this.x << blockShifts), y + (this.y << blockShifts), z + (this.z << blockShifts));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int i = 0; i < LIGHT_PER_TICK; i++) {\n\t\t\t\t\tSpoutChunk toLight = lightingQueue.poll();\n\t\t\t\t\tif (toLight == null) break;\n\t\t\t\t\tif (toLight.isLoaded()) {\n\t\t\t\t\t\ttoLight.processQueuedLighting();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int i = 0; i < POPULATE_PER_TICK; i++) {\n\t\t\t\t\tChunk toPopulate = populationQueue.poll();\n\t\t\t\t\tif (toPopulate == null) break;\n\t\t\t\t\tif (toPopulate.isLoaded()) {\n\t\t\t\t\t\ttoPopulate.populate();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tChunk toUnload = unloadQueue.poll();\n\t\t\t\tif (toUnload != null) {\n\t\t\t\t\ttoUnload.unload(true);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 1: {\n\t\t\t\tfor (SpoutEntity ent : entityManager) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tent.resolve();\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tSpout.getGame().getLogger().severe(\"Unhandled exception during tick resolution for \" + ent.toString());\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new IllegalStateException(\"Number of states exceeded limit for SpoutRegion\");\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic static MessageToMediationService valueOf(String json) {\n\t\ttry {\n\t\t\tJSONObject o = new JSONObject(json);\n\t\t\tString webapp =o.getString(\"webappname\");\n\t\t\tString entityTesto =o.getString(\"entityTesto\");\n\t\t\tint entityId =o.getInt(\"entityId\");\n\t\t\tMessageToMediationService messageToMediationService = new MessageToMediationService(webapp,entityId,entityTesto);\n\t\t\tmessageToMediationService.setMediationApproved(o.getBoolean(\"mediationApproved\"));\n\t\t\tmessageToMediationService.setParseApproved(o.getBoolean(\"parseApproved\"));\n\t\t\tmessageToMediationService.setTimestamp(o.getLong(\"timestamp\"));\n\t\t\tmessageToMediationService.setNote(o.getString(\"note\"));\n\t\t\treturn messageToMediationService;\n\t\t} catch (JSONException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n", "output": "\tpublic static MessageToMediationService valueOf(String json) {\n\t\ttry {\n\t\t\tJSONObject o = new JSONObject(json);\n\t\t\tString webapp =o.getString(\"webappname\");\n\t\t\tString entityTesto =o.getString(\"entityTesto\");\n\t\t\tint entityId =o.getInt(\"entityId\");\n\t\t\tMessageToMediationService messageToMediationService = new MessageToMediationService(webapp,entityId,entityTesto);\n\t\t\tmessageToMediationService.setMediationApproved(o.getBoolean(\"mediationApproved\"));\n\t\t\tmessageToMediationService.setParseApproved(o.getBoolean(\"parseApproved\"));\n\t\t\tmessageToMediationService.setTimestamp(o.getLong(\"timestamp\"));\n\t\t\tif(o.has(\"note\"))\n\t\t\tmessageToMediationService.setNote(o.getString(\"note\"));\n\t\t\treturn messageToMediationService;\n\t\t} catch (JSONException e) {\n\t\t\treturn null;\n\t\t}\n\t}\n"} {"input": "\tpublic static boolean checkImpl(String methodPrefix, Class<?>... parameters) {\n\t\tif (parameters[0] == null) {\n\t\t\tSystem.err.println(\"Error: CheckImpl() first class parameter was null.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(Zone.class.isAssignableFrom(parameters[0]))) {\n\t\t\tSystem.err\n\t\t\t\t\t.println(\"Error: CheckImpl() first class parameter (\"\n\t\t\t\t\t\t\t+ parameters[0]\n\t\t\t\t\t\t\t+ \") was not Zone or a subclass, please give the current Zone class (using this.getClass()) as the first class parameter.\");\n\t\t\treturn false;\n\t\t}\n\t\tMethod impl = null;\n\t\ttry {\n\t\t\tClass<?>[] firstRemoved = new Class<?>[parameters.length - 1];\n\t\t\tSystem.arraycopy(parameters, 1, firstRemoved, 0, parameters.length - 1);\n\t\t\tif (Zone.class.getDeclaredMethod(methodPrefix + \"Impl\", firstRemoved) != null) {\n\t\t\t\ttry {\n\t\t\t\t\timpl = parameters[0].getDeclaredMethod(methodPrefix + \"Impl\", firstRemoved);\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {}\n\t\t\t\tif (impl == null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\timpl = parameters[0].getDeclaredMethod(methodPrefix + \"Impl\", parameters);\n\t\t\t\t\t\tif (impl != null) {\n\t\t\t\t\t\t\tSystem.err\n\t\t\t\t\t\t\t\t\t.println(methodPrefix\n\t\t\t\t\t\t\t\t\t\t\t+ \"Impl() in the class \"\n\t\t\t\t\t\t\t\t\t\t\t+ parameters[0].getName()\n\t\t\t\t\t\t\t\t\t\t\t+ \" should not have Zone as a parameter, please remove it to override \"\n\t\t\t\t\t\t\t\t\t\t\t+ methodPrefix + \"Impl() correctly.\");\n\t\t\t\t\t\t\timpl = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {}\n\t\tif (impl == null && parameters[0].getSuperclass() != null\n\t\t\t\t&& parameters[0].getSuperclass() != Zone.class && parameters[0] != Zone.class) {\n\t\t\tClass<?> superClass = parameters[0].getSuperclass();\n\t\t\tClass<?>[] firstSupered = new Class<?>[parameters.length];\n\t\t\tSystem.arraycopy(parameters, 0, firstSupered, 0, parameters.length);\n\t\t\tfirstSupered[0] = superClass;\n\t\t\tif (checkImpl(methodPrefix, firstSupered)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (impl == null) {\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\treturn true;\n\t\t}\n\t}\n", "output": "\tpublic static boolean checkImpl(String methodPrefix, Class<?>... parameters) {\n\t\tif (parameters[0] == null) {\n\t\t\tSystem.err.println(\"Error: CheckImpl() first class parameter was null.\");\n\t\t\treturn false;\n\t\t}\n\t\tif (!(Zone.class.isAssignableFrom(parameters[0]))) {\n\t\t\tSystem.err\n\t\t\t\t\t.println(\"Error: CheckImpl() first class parameter (\"\n\t\t\t\t\t\t\t+ parameters[0]\n\t\t\t\t\t\t\t+ \") was not Zone or a subclass, please give the current Zone class (using this.getClass()) as the first class parameter.\");\n\t\t\treturn false;\n\t\t}\n\t\tMethod impl = null;\n\t\ttry {\n\t\t\tClass<?>[] firstRemoved = new Class<?>[parameters.length - 1];\n\t\t\tSystem.arraycopy(parameters, 1, firstRemoved, 0, parameters.length - 1);\n\t\t\tif (parameters[0].getSuperclass().getDeclaredMethod(methodPrefix + \"Impl\", firstRemoved) != null) {\n\t\t\t\ttry {\n\t\t\t\t\timpl = parameters[0].getDeclaredMethod(methodPrefix + \"Impl\", firstRemoved);\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {}\n\t\t\t\tif (impl == null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\timpl = parameters[0].getDeclaredMethod(methodPrefix + \"Impl\", parameters);\n\t\t\t\t\t\tif (impl != null) {\n\t\t\t\t\t\t\tSystem.err\n\t\t\t\t\t\t\t\t\t.println(methodPrefix\n\t\t\t\t\t\t\t\t\t\t\t+ \"Impl() in the class \"\n\t\t\t\t\t\t\t\t\t\t\t+ parameters[0].getName()\n\t\t\t\t\t\t\t\t\t\t\t+ \" should not have Zone as a parameter, please remove it to override \"\n\t\t\t\t\t\t\t\t\t\t\t+ methodPrefix + \"Impl() correctly.\");\n\t\t\t\t\t\t\timpl = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (Exception e) {}\n\t\tif (impl == null && parameters[0].getSuperclass() != null\n\t\t\t\t&& parameters[0].getSuperclass() != Zone.class && parameters[0] != Zone.class) {\n\t\t\tClass<?> superClass = parameters[0].getSuperclass();\n\t\t\tClass<?>[] firstSupered = new Class<?>[parameters.length];\n\t\t\tSystem.arraycopy(parameters, 0, firstSupered, 0, parameters.length);\n\t\t\tfirstSupered[0] = superClass;\n\t\t\tif (checkImpl(methodPrefix, firstSupered)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (impl == null) {\n\t\t\treturn false;\n\t\t}\n\t\telse {\n\t\t\treturn true;\n\t\t}\n\t}\n"} {"input": "\tprotected void searchNext1(final int c1) {\n\t\tswitch(c1) { \n\t\tcase SourceParseInput.EOF:\n\t\t\tfFoundNum--;\n\t\t\tcreateFix(RTerminal.EOF);\n\t\t\treturn;\n\t\tcase '\\r':\n\t\t\tif (fInput.get(2) == '\\n') {\n\t\t\t\tfFoundNum++;\n\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(2));\n\t\t\t\tcreateLinebreakToken(\"\\r\\n\"); \n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(1));\n\t\t\tcreateLinebreakToken(\"\\r\"); \n\t\t\treturn;\n\t\tcase '\\n':\n\t\tcase '\\f':\n\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(1));\n\t\t\tcreateLinebreakToken(\"\\n\"); \n\t\t\treturn;\n\t\tcase ' ':\n\t\tcase '\\t':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase ' ':\n\t\t\t\tcase '\\t':\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tdefault:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateWhitespaceToken();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '!':\n\t\t\tif (fInput.get(2) == '=') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_NE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.NOT);\n\t\t\treturn;\n\t\tcase '\\\"':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '\\\\':\n\t\t\t\t\tif (fInput.get(++fFoundNum) == SourceParseInput.EOF) {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\\"':\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_D, STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\r':\n\t\t\t\t\tif (fInput.get(++fFoundNum) != '\\n') {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\n':\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_D, STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '#':\n\t\t\tfinal RTerminal type;\n\t\t\tif (fInput.get(2) == '\\'') {\n\t\t\t\ttype = RTerminal.ROXYGEN_COMMENT;\n\t\t\t\tfFoundNum++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttype = RTerminal.COMMENT;\n\t\t\t}\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\tcase '\\r':\n\t\t\t\tcase '\\n':\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateCommentToken(type);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '$':\n\t\t\tcreateFix(RTerminal.SUB_NAMED_PART);\n\t\t\treturn;\n\t\tcase '%':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '%':\n\t\t\t\t\tcreateSpecialToken(STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\n':\n\t\t\t\tcase '\\r':\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateSpecialToken(STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '&':\n\t\t\tif (fInput.get(2) == '&') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.AND_D);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.AND);\n\t\t\treturn;\n\t\tcase '\\'':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '\\\\':\n\t\t\t\t\tif (fInput.get(++fFoundNum) == SourceParseInput.EOF) {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\'':\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_S, STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\r':\n\t\t\t\t\tif (fInput.get(++fFoundNum) != '\\n') {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\n':\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_S, STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '(':\n\t\t\tcreateFix(RTerminal.GROUP_OPEN);\n\t\t\treturn;\n\t\tcase ')':\n\t\t\tcreateFix(RTerminal.GROUP_CLOSE);\n\t\t\treturn;\n\t\tcase '*':\n\t\t\tcreateFix(RTerminal.MULT);\n\t\t\treturn;\n\t\tcase '+':\n\t\t\tcreateFix(RTerminal.PLUS);\n\t\t\treturn;\n\t\tcase ',':\n\t\t\tcreateFix(RTerminal.COMMA);\n\t\t\treturn;\n\t\tcase '-':\n\t\t\tif (fInput.get(2) == '>') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tif (fInput.get(3) == '>') {\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tcreateFix(RTerminal.ARROW_RIGHT_D);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcreateFix(RTerminal.ARROW_RIGHT_S);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.MINUS);\n\t\t\treturn;\n\t\tcase '.':\n\t\t\tswitch (fInput.get(2)) {\n\t\t\tcase '0':\n\t\t\tcase '1':\n\t\t\tcase '2':\n\t\t\tcase '3':\n\t\t\tcase '4':\n\t\t\tcase '5':\n\t\t\tcase '6':\n\t\t\tcase '7':\n\t\t\tcase '8':\n\t\t\tcase '9':\n\t\t\t\tfFoundNum++;\n\t\t\t\tconsumeNumberInFloat();\n\t\t\t\treturn;\n\t\t\tdefault:\n\t\t\t\tscanIdentifier();\n\t\t\t\tcreateSymbolToken();\n\t\t\t\treturn;\n\t\t\t}\n\t\tcase '/':\n\t\t\tcreateFix(RTerminal.DIV);\n\t\t\treturn;\n\t\tcase '0':\n\t\t\tif (fInput.get(2) == 'x') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tconsumeNumberInHex();\n\t\t\t\treturn;\n\t\t\t}\n\t\tcase '1':\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '4':\n\t\tcase '5':\n\t\tcase '6':\n\t\tcase '7':\n\t\tcase '8':\n\t\tcase '9':\n\t\t\tconsumeNumberInDec();\n\t\t\treturn;\n\t\tcase ':':\n\t\t\tif (fInput.get(2) == ':') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tif (fInput.get(3) == ':') {\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tcreateFix(RTerminal.NS_GET_INT);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcreateFix(RTerminal.NS_GET);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.SEQ);\n\t\t\treturn;\n\t\tcase ';':\n\t\t\tcreateFix(RTerminal.SEMI);\n\t\t\treturn;\n\t\tcase '<':\n\t\t\tswitch (fInput.get(2)) {\n\t\t\tcase '=':\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_LE);\n\t\t\t\treturn;\n\t\t\tcase '-':\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.ARROW_LEFT_S);\n\t\t\t\treturn;\n\t\t\tcase '<':\n\t\t\t\tif (fInput.get(3) == '-') {\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tcreateFix(RTerminal.ARROW_LEFT_D);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tcreateFix(RTerminal.REL_LT);\n\t\t\t\treturn;\n\t\t\t}\n\t\tcase '=':\n\t\t\tif (fInput.get(2) == '=') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_EQ);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.EQUAL);\n\t\t\treturn;\n\t\tcase '>':\n\t\t\tif (fInput.get(2) == '=') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_GE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.REL_LT);\n\t\t\treturn;\n\t\tcase '?':\n\t\t\tcreateFix(RTerminal.QUESTIONMARK);\n\t\t\treturn;\n\t\tcase '@':\n\t\t\tcreateFix(RTerminal.SUB_NAMED_SLOT);\n\t\t\treturn;\n\t\tcase '[':\n\t\t\tif (fInput.get(2) == '[') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.SUB_INDEXED_D_OPEN);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.SUB_INDEXED_S_OPEN);\n\t\t\treturn;\n\t\tcase ']':\n\t\t\tcreateFix(RTerminal.SUB_INDEXED_CLOSE);\n\t\t\treturn;\n\t\tcase '^':\n\t\t\tcreateFix(RTerminal.POWER);\n\t\t\treturn;\n\t\tcase 'A':\n\t\tcase 'B':\n\t\tcase 'C':\n\t\tcase 'D':\n\t\tcase 'E':\n\t\tcase 'G':\n\t\tcase 'H':\n\t\tcase 'J':\n\t\tcase 'K':\n\t\tcase 'L':\n\t\tcase 'M':\n\t\tcase 'O':\n\t\tcase 'P':\n\t\tcase 'Q':\n\t\tcase 'R':\n\t\tcase 'S':\n\t\tcase 'U':\n\t\tcase 'V':\n\t\tcase 'W':\n\t\tcase 'X':\n\t\tcase 'Y':\n\t\tcase 'Z':\n\t\tcase 'a':\n\t\tcase 'c':\n\t\tcase 'd':\n\t\tcase 'g':\n\t\tcase 'h':\n\t\tcase 'j':\n\t\tcase 'k':\n\t\tcase 'l':\n\t\tcase 'm':\n\t\tcase 'o':\n\t\tcase 'p':\n\t\tcase 'q':\n\t\tcase 's':\n\t\tcase 't':\n\t\tcase 'u':\n\t\tcase 'v':\n\t\tcase 'x':\n\t\tcase 'y':\n\t\tcase 'z':\n\t\t\tscanIdentifier();\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'F':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 5\n\t\t\t\t\t&& fInput.subequals(2, C1_FALSE)) {\n\t\t\t\tcreateFix(RTerminal.FALSE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'I':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 3\n\t\t\t\t\t&& fInput.subequals(2, 'n', 'f')) {\n\t\t\t\tcreateFix(RTerminal.INF);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'N':\n\t\t\tscanIdentifier();\n\t\t\tswitch(fFoundNum) {\n\t\t\tcase 2:\n\t\t\t\tif (fInput.get(2) == 'A') {\n\t\t\t\t\tcreateFix(RTerminal.NA);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tif (fInput.subequals(2, 'a', 'N')) {\n\t\t\t\t\tcreateFix(RTerminal.NAN);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\tif (fInput.subequals(2, 'U', 'L', 'L')) {\n\t\t\t\t\tcreateFix(RTerminal.NULL);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 7:\n\t\t\t\tif (fInput.subequals(2, C1_NA_real_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_REAL);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 11:\n\t\t\t\tif (fInput.subequals(2, C1_NA_integer_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_INT);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (fInput.subequals(2, C1_NA_complex_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_CPLX);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 13:\n\t\t\t\tif (fInput.subequals(2, C1_NA_character_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_CHAR);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'T':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 4\n\t\t\t\t\t&& fInput.subequals(2, 'R', 'U', 'E')) {\n\t\t\t\tcreateFix(RTerminal.TRUE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'b':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 5\n\t\t\t\t\t&& fInput.subequals(2, C1_break)) {\n\t\t\t\tcreateFix(RTerminal.BREAK);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'i':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 2) {\n\t\t\t\tif (fInput.get(2) == 'f') {\n\t\t\t\t\tcreateFix(RTerminal.IF);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (fInput.get(2) == 'n') {\n\t\t\t\t\tcreateFix(RTerminal.IN);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'e':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 4\n\t\t\t\t\t&& fInput.subequals(2, 'l', 's', 'e')) {\n\t\t\t\tcreateFix(RTerminal.ELSE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'n':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 4\n\t\t\t\t\t&& fInput.subequals(2, 'e', 'x', 't')) {\n\t\t\t\tcreateFix(RTerminal.NEXT);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'f':\n\t\t\tscanIdentifier();\n\t\t\tswitch (fFoundNum) {\n\t\t\tcase 3:\n\t\t\t\tif (fInput.subequals(2, 'o', 'r')) {\n\t\t\t\t\tcreateFix(RTerminal.FOR);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 8:\n\t\t\t\tif (fInput.subequals(2, C1_function)) {\n\t\t\t\t\tcreateFix(RTerminal.FUNCTION);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'r':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 6\n\t\t\t\t\t&& fInput.subequals(2, C1_repeat)) {\n\t\t\t\tcreateFix(RTerminal.REPEAT);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'w':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 5\n\t\t\t\t\t&& fInput.subequals(2, C1_while)) {\n\t\t\t\tcreateFix(RTerminal.WHILE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase '{':\n\t\t\tcreateFix(RTerminal.BLOCK_OPEN);\n\t\t\treturn;\n\t\tcase '|':\n\t\t\tif (fInput.get(2) == '|') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.OR_D);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.OR);\n\t\t\treturn;\n\t\tcase '}':\n\t\t\tcreateFix(RTerminal.BLOCK_CLOSE);\n\t\t\treturn;\n\t\tcase '~':\n\t\t\tcreateFix(RTerminal.TILDE);\n\t\t\treturn;\n\t\tcase '`':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '\\\\':\n\t\t\t\t\tif (fInput.get(++fFoundNum) == SourceParseInput.EOF) {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '`':\n\t\t\t\t\tcreateQuotedSymbolToken(RTerminal.SYMBOL_G, STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\r':\n\t\t\t\t\tif (fInput.get(++fFoundNum) != '\\n') {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\n':\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateQuotedSymbolToken(RTerminal.SYMBOL_G, STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase 0x000:\n\t\tcase 0x001:\n\t\tcase 0x002:\n\t\tcase 0x003:\n\t\tcase 0x004:\n\t\tcase 0x005:\n\t\tcase 0x006:\n\t\tcase 0x007:\n\t\tcase 0x008:\n\t\tcase 0x00B:\n\t\tcase 0x00E:\n\t\tcase 0x00F:\n\t\tcase 0x010:\n\t\tcase 0x011:\n\t\tcase 0x012:\n\t\tcase 0x013:\n\t\tcase 0x014:\n\t\tcase 0x015:\n\t\tcase 0x016:\n\t\tcase 0x017:\n\t\tcase 0x018:\n\t\tcase 0x019:\n\t\tcase 0x01A:\n\t\tcase 0x01B:\n\t\tcase 0x01C:\n\t\tcase 0x01D:\n\t\tcase 0x01E:\n\t\tcase 0x01F:\n\t\tcase 0x07F:\n\t\tcase 0x080:\n\t\tcase 0x081:\n\t\tcase 0x082:\n\t\tcase 0x083:\n\t\tcase 0x084:\n\t\tcase 0x085:\n\t\tcase 0x086:\n\t\tcase 0x087:\n\t\tcase 0x088:\n\t\tcase 0x089:\n\t\tcase 0x08A:\n\t\tcase 0x08B:\n\t\tcase 0x08C:\n\t\tcase 0x08D:\n\t\tcase 0x08E:\n\t\tcase 0x08F:\n\t\tcase 0x090:\n\t\tcase 0x091:\n\t\tcase 0x092:\n\t\tcase 0x093:\n\t\tcase 0x094:\n\t\tcase 0x095:\n\t\tcase 0x096:\n\t\tcase 0x097:\n\t\tcase 0x098:\n\t\tcase 0x099:\n\t\tcase 0x09A:\n\t\tcase 0x09B:\n\t\tcase 0x09C:\n\t\tcase 0x09D:\n\t\tcase 0x09E:\n\t\tcase 0x09F:\n\t\tcase 0x0A0:\n\t\tcase 0x0A1:\n\t\tcase 0x0A2:\n\t\tcase 0x0A3:\n\t\tcase 0x0A4:\n\t\tcase 0x0A5:\n\t\tcase 0x0A6:\n\t\tcase 0x0A7:\n\t\tcase 0x0A8:\n\t\tcase 0x0A9:\n\t\tcase 0x0AA:\n\t\tcase 0x0AB:\n\t\tcase 0x0AC:\n\t\tcase 0x0AD:\n\t\tcase 0x0AE:\n\t\tcase 0x0AF:\n\t\tcase 0x0B0:\n\t\tcase 0x0B1:\n\t\tcase 0x0B2:\n\t\tcase 0x0B3:\n\t\tcase 0x0B4:\n\t\tcase 0x0B5:\n\t\tcase 0x0B6:\n\t\tcase 0x0B7:\n\t\tcase 0x0B8:\n\t\tcase 0x0B9:\n\t\tcase 0x0BA:\n\t\tcase 0x0BB:\n\t\tcase 0x0BC:\n\t\tcase 0x0BD:\n\t\tcase 0x0BE:\n\t\tcase 0x0BF:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (Character.isLetterOrDigit(c1)) {\n\t\t\t\tscanIdentifier();\n\t\t\t\tcreateSymbolToken();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tconsumeUnknown();\n\t}\n", "output": "\tprotected void searchNext1(final int c1) {\n\t\tswitch(c1) { \n\t\tcase SourceParseInput.EOF:\n\t\t\tfFoundNum--;\n\t\t\tcreateFix(RTerminal.EOF);\n\t\t\treturn;\n\t\tcase '\\r':\n\t\t\tif (fInput.get(2) == '\\n') {\n\t\t\t\tfFoundNum++;\n\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(2));\n\t\t\t\tcreateLinebreakToken(\"\\r\\n\"); \n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(1));\n\t\t\tcreateLinebreakToken(\"\\r\"); \n\t\t\treturn;\n\t\tcase '\\n':\n\t\tcase '\\f':\n\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(1));\n\t\t\tcreateLinebreakToken(\"\\n\"); \n\t\t\treturn;\n\t\tcase ' ':\n\t\tcase '\\t':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase ' ':\n\t\t\t\tcase '\\t':\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tdefault:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateWhitespaceToken();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '!':\n\t\t\tif (fInput.get(2) == '=') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_NE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.NOT);\n\t\t\treturn;\n\t\tcase '\\\"':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '\\\\':\n\t\t\t\t\tif (fInput.get(++fFoundNum) == SourceParseInput.EOF) {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\\"':\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_D, STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\r':\n\t\t\t\t\tif (fInput.get(++fFoundNum) != '\\n') {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\n':\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_D, STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '#':\n\t\t\tfinal RTerminal type;\n\t\t\tif (fInput.get(2) == '\\'') {\n\t\t\t\ttype = RTerminal.ROXYGEN_COMMENT;\n\t\t\t\tfFoundNum++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttype = RTerminal.COMMENT;\n\t\t\t}\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\tcase '\\r':\n\t\t\t\tcase '\\n':\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateCommentToken(type);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '$':\n\t\t\tcreateFix(RTerminal.SUB_NAMED_PART);\n\t\t\treturn;\n\t\tcase '%':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '%':\n\t\t\t\t\tcreateSpecialToken(STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\n':\n\t\t\t\tcase '\\r':\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateSpecialToken(STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '&':\n\t\t\tif (fInput.get(2) == '&') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.AND_D);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.AND);\n\t\t\treturn;\n\t\tcase '\\'':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '\\\\':\n\t\t\t\t\tif (fInput.get(++fFoundNum) == SourceParseInput.EOF) {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\'':\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_S, STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\r':\n\t\t\t\t\tif (fInput.get(++fFoundNum) != '\\n') {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\n':\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateStringToken(RTerminal.STRING_S, STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase '(':\n\t\t\tcreateFix(RTerminal.GROUP_OPEN);\n\t\t\treturn;\n\t\tcase ')':\n\t\t\tcreateFix(RTerminal.GROUP_CLOSE);\n\t\t\treturn;\n\t\tcase '*':\n\t\t\tcreateFix(RTerminal.MULT);\n\t\t\treturn;\n\t\tcase '+':\n\t\t\tcreateFix(RTerminal.PLUS);\n\t\t\treturn;\n\t\tcase ',':\n\t\t\tcreateFix(RTerminal.COMMA);\n\t\t\treturn;\n\t\tcase '-':\n\t\t\tif (fInput.get(2) == '>') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tif (fInput.get(3) == '>') {\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tcreateFix(RTerminal.ARROW_RIGHT_D);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcreateFix(RTerminal.ARROW_RIGHT_S);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.MINUS);\n\t\t\treturn;\n\t\tcase '.':\n\t\t\tswitch (fInput.get(2)) {\n\t\t\tcase '0':\n\t\t\tcase '1':\n\t\t\tcase '2':\n\t\t\tcase '3':\n\t\t\tcase '4':\n\t\t\tcase '5':\n\t\t\tcase '6':\n\t\t\tcase '7':\n\t\t\tcase '8':\n\t\t\tcase '9':\n\t\t\t\tfFoundNum++;\n\t\t\t\tconsumeNumberInFloat();\n\t\t\t\treturn;\n\t\t\tdefault:\n\t\t\t\tscanIdentifier();\n\t\t\t\tcreateSymbolToken();\n\t\t\t\treturn;\n\t\t\t}\n\t\tcase '/':\n\t\t\tcreateFix(RTerminal.DIV);\n\t\t\treturn;\n\t\tcase '0':\n\t\t\tif (fInput.get(2) == 'x') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tconsumeNumberInHex();\n\t\t\t\treturn;\n\t\t\t}\n\t\tcase '1':\n\t\tcase '2':\n\t\tcase '3':\n\t\tcase '4':\n\t\tcase '5':\n\t\tcase '6':\n\t\tcase '7':\n\t\tcase '8':\n\t\tcase '9':\n\t\t\tconsumeNumberInDec();\n\t\t\treturn;\n\t\tcase ':':\n\t\t\tif (fInput.get(2) == ':') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tif (fInput.get(3) == ':') {\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tcreateFix(RTerminal.NS_GET_INT);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcreateFix(RTerminal.NS_GET);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.SEQ);\n\t\t\treturn;\n\t\tcase ';':\n\t\t\tcreateFix(RTerminal.SEMI);\n\t\t\treturn;\n\t\tcase '<':\n\t\t\tswitch (fInput.get(2)) {\n\t\t\tcase '=':\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_LE);\n\t\t\t\treturn;\n\t\t\tcase '-':\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.ARROW_LEFT_S);\n\t\t\t\treturn;\n\t\t\tcase '<':\n\t\t\t\tif (fInput.get(3) == '-') {\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tfFoundNum++;\n\t\t\t\t\tcreateFix(RTerminal.ARROW_LEFT_D);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tcreateFix(RTerminal.REL_LT);\n\t\t\t\treturn;\n\t\t\t}\n\t\tcase '=':\n\t\t\tif (fInput.get(2) == '=') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_EQ);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.EQUAL);\n\t\t\treturn;\n\t\tcase '>':\n\t\t\tif (fInput.get(2) == '=') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.REL_GE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.REL_LT);\n\t\t\treturn;\n\t\tcase '?':\n\t\t\tcreateFix(RTerminal.QUESTIONMARK);\n\t\t\treturn;\n\t\tcase '@':\n\t\t\tcreateFix(RTerminal.SUB_NAMED_SLOT);\n\t\t\treturn;\n\t\tcase '[':\n\t\t\tif (fInput.get(2) == '[') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.SUB_INDEXED_D_OPEN);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.SUB_INDEXED_S_OPEN);\n\t\t\treturn;\n\t\tcase ']':\n\t\t\tcreateFix(RTerminal.SUB_INDEXED_CLOSE);\n\t\t\treturn;\n\t\tcase '^':\n\t\t\tcreateFix(RTerminal.POWER);\n\t\t\treturn;\n\t\tcase 'A':\n\t\tcase 'B':\n\t\tcase 'C':\n\t\tcase 'D':\n\t\tcase 'E':\n\t\tcase 'G':\n\t\tcase 'H':\n\t\tcase 'J':\n\t\tcase 'K':\n\t\tcase 'L':\n\t\tcase 'M':\n\t\tcase 'O':\n\t\tcase 'P':\n\t\tcase 'Q':\n\t\tcase 'R':\n\t\tcase 'S':\n\t\tcase 'U':\n\t\tcase 'V':\n\t\tcase 'W':\n\t\tcase 'X':\n\t\tcase 'Y':\n\t\tcase 'Z':\n\t\tcase 'a':\n\t\tcase 'c':\n\t\tcase 'd':\n\t\tcase 'g':\n\t\tcase 'h':\n\t\tcase 'j':\n\t\tcase 'k':\n\t\tcase 'l':\n\t\tcase 'm':\n\t\tcase 'o':\n\t\tcase 'p':\n\t\tcase 'q':\n\t\tcase 's':\n\t\tcase 't':\n\t\tcase 'u':\n\t\tcase 'v':\n\t\tcase 'x':\n\t\tcase 'y':\n\t\tcase 'z':\n\t\t\tscanIdentifier();\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'F':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 5\n\t\t\t\t\t&& fInput.subequals(2, C1_FALSE)) {\n\t\t\t\tcreateFix(RTerminal.FALSE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'I':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 3\n\t\t\t\t\t&& fInput.subequals(2, 'n', 'f')) {\n\t\t\t\tcreateFix(RTerminal.INF);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'N':\n\t\t\tscanIdentifier();\n\t\t\tswitch(fFoundNum) {\n\t\t\tcase 2:\n\t\t\t\tif (fInput.get(2) == 'A') {\n\t\t\t\t\tcreateFix(RTerminal.NA);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tif (fInput.subequals(2, 'a', 'N')) {\n\t\t\t\t\tcreateFix(RTerminal.NAN);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\tif (fInput.subequals(2, 'U', 'L', 'L')) {\n\t\t\t\t\tcreateFix(RTerminal.NULL);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 8:\n\t\t\t\tif (fInput.subequals(2, C1_NA_real_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_REAL);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 11:\n\t\t\t\tif (fInput.subequals(2, C1_NA_integer_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_INT);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (fInput.subequals(2, C1_NA_complex_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_CPLX);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 13:\n\t\t\t\tif (fInput.subequals(2, C1_NA_character_)) {\n\t\t\t\t\tcreateFix(RTerminal.NA_CHAR);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'T':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 4\n\t\t\t\t\t&& fInput.subequals(2, 'R', 'U', 'E')) {\n\t\t\t\tcreateFix(RTerminal.TRUE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'b':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 5\n\t\t\t\t\t&& fInput.subequals(2, C1_break)) {\n\t\t\t\tcreateFix(RTerminal.BREAK);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'i':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 2) {\n\t\t\t\tif (fInput.get(2) == 'f') {\n\t\t\t\t\tcreateFix(RTerminal.IF);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (fInput.get(2) == 'n') {\n\t\t\t\t\tcreateFix(RTerminal.IN);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'e':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 4\n\t\t\t\t\t&& fInput.subequals(2, 'l', 's', 'e')) {\n\t\t\t\tcreateFix(RTerminal.ELSE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'n':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 4\n\t\t\t\t\t&& fInput.subequals(2, 'e', 'x', 't')) {\n\t\t\t\tcreateFix(RTerminal.NEXT);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'f':\n\t\t\tscanIdentifier();\n\t\t\tswitch (fFoundNum) {\n\t\t\tcase 3:\n\t\t\t\tif (fInput.subequals(2, 'o', 'r')) {\n\t\t\t\t\tcreateFix(RTerminal.FOR);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 8:\n\t\t\t\tif (fInput.subequals(2, C1_function)) {\n\t\t\t\t\tcreateFix(RTerminal.FUNCTION);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'r':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 6\n\t\t\t\t\t&& fInput.subequals(2, C1_repeat)) {\n\t\t\t\tcreateFix(RTerminal.REPEAT);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase 'w':\n\t\t\tscanIdentifier();\n\t\t\tif (fFoundNum == 5\n\t\t\t\t\t&& fInput.subequals(2, C1_while)) {\n\t\t\t\tcreateFix(RTerminal.WHILE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateSymbolToken();\n\t\t\treturn;\n\t\tcase '{':\n\t\t\tcreateFix(RTerminal.BLOCK_OPEN);\n\t\t\treturn;\n\t\tcase '|':\n\t\t\tif (fInput.get(2) == '|') {\n\t\t\t\tfFoundNum++;\n\t\t\t\tcreateFix(RTerminal.OR_D);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcreateFix(RTerminal.OR);\n\t\t\treturn;\n\t\tcase '}':\n\t\t\tcreateFix(RTerminal.BLOCK_CLOSE);\n\t\t\treturn;\n\t\tcase '~':\n\t\t\tcreateFix(RTerminal.TILDE);\n\t\t\treturn;\n\t\tcase '`':\n\t\t\tLOOP: while (true) {\n\t\t\t\tswitch (fInput.get(++fFoundNum)) {\n\t\t\t\tcase '\\\\':\n\t\t\t\t\tif (fInput.get(++fFoundNum) == SourceParseInput.EOF) {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '`':\n\t\t\t\t\tcreateQuotedSymbolToken(RTerminal.SYMBOL_G, STATUS_OK);\n\t\t\t\t\treturn;\n\t\t\t\tcase '\\r':\n\t\t\t\t\tif (fInput.get(++fFoundNum) != '\\n') {\n\t\t\t\t\t\tfFoundNum--;\n\t\t\t\t\t}\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase '\\n':\n\t\t\t\t\thandleNewLine(fInput.getIndex()+fInput.getLength(fFoundNum));\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\tcase SourceParseInput.EOF:\n\t\t\t\t\tfFoundNum--;\n\t\t\t\t\tcreateQuotedSymbolToken(RTerminal.SYMBOL_G, STATUS2_SYNTAX_TOKEN_NOT_CLOSED);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tcontinue LOOP;\n\t\t\t\t}\n\t\t\t}\n\t\tcase 0x000:\n\t\tcase 0x001:\n\t\tcase 0x002:\n\t\tcase 0x003:\n\t\tcase 0x004:\n\t\tcase 0x005:\n\t\tcase 0x006:\n\t\tcase 0x007:\n\t\tcase 0x008:\n\t\tcase 0x00B:\n\t\tcase 0x00E:\n\t\tcase 0x00F:\n\t\tcase 0x010:\n\t\tcase 0x011:\n\t\tcase 0x012:\n\t\tcase 0x013:\n\t\tcase 0x014:\n\t\tcase 0x015:\n\t\tcase 0x016:\n\t\tcase 0x017:\n\t\tcase 0x018:\n\t\tcase 0x019:\n\t\tcase 0x01A:\n\t\tcase 0x01B:\n\t\tcase 0x01C:\n\t\tcase 0x01D:\n\t\tcase 0x01E:\n\t\tcase 0x01F:\n\t\tcase 0x07F:\n\t\tcase 0x080:\n\t\tcase 0x081:\n\t\tcase 0x082:\n\t\tcase 0x083:\n\t\tcase 0x084:\n\t\tcase 0x085:\n\t\tcase 0x086:\n\t\tcase 0x087:\n\t\tcase 0x088:\n\t\tcase 0x089:\n\t\tcase 0x08A:\n\t\tcase 0x08B:\n\t\tcase 0x08C:\n\t\tcase 0x08D:\n\t\tcase 0x08E:\n\t\tcase 0x08F:\n\t\tcase 0x090:\n\t\tcase 0x091:\n\t\tcase 0x092:\n\t\tcase 0x093:\n\t\tcase 0x094:\n\t\tcase 0x095:\n\t\tcase 0x096:\n\t\tcase 0x097:\n\t\tcase 0x098:\n\t\tcase 0x099:\n\t\tcase 0x09A:\n\t\tcase 0x09B:\n\t\tcase 0x09C:\n\t\tcase 0x09D:\n\t\tcase 0x09E:\n\t\tcase 0x09F:\n\t\tcase 0x0A0:\n\t\tcase 0x0A1:\n\t\tcase 0x0A2:\n\t\tcase 0x0A3:\n\t\tcase 0x0A4:\n\t\tcase 0x0A5:\n\t\tcase 0x0A6:\n\t\tcase 0x0A7:\n\t\tcase 0x0A8:\n\t\tcase 0x0A9:\n\t\tcase 0x0AA:\n\t\tcase 0x0AB:\n\t\tcase 0x0AC:\n\t\tcase 0x0AD:\n\t\tcase 0x0AE:\n\t\tcase 0x0AF:\n\t\tcase 0x0B0:\n\t\tcase 0x0B1:\n\t\tcase 0x0B2:\n\t\tcase 0x0B3:\n\t\tcase 0x0B4:\n\t\tcase 0x0B5:\n\t\tcase 0x0B6:\n\t\tcase 0x0B7:\n\t\tcase 0x0B8:\n\t\tcase 0x0B9:\n\t\tcase 0x0BA:\n\t\tcase 0x0BB:\n\t\tcase 0x0BC:\n\t\tcase 0x0BD:\n\t\tcase 0x0BE:\n\t\tcase 0x0BF:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (Character.isLetterOrDigit(c1)) {\n\t\t\t\tscanIdentifier();\n\t\t\t\tcreateSymbolToken();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tconsumeUnknown();\n\t}\n"} {"input": "\tprivate boolean Save()\n\t{\n\t\tif(this._location == null)\n\t\t\tthis._location = new FrontendLocation();\n\t\tthis._location.Name = this.GetName();\n\t\tthis._location.Address = this.GetAddress();\n\t\tthis._location.Port = this.GetPort();\n\t\tAlertDialog.Builder builder = new AlertDialog.Builder(this);\n\t\tbuilder.setTitle(R.string.error_input_str);\n\t\tbuilder.setNeutralButton(R.string.ok_str, new DialogInterface.OnClickListener(){\n\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t}});\n\t\tif(this._location.Name == null)\n\t\t{\n\t\t\tbuilder.setMessage(R.string.error_invalid_name_str);\n\t\t\tbuilder.show();\n\t\t}\n\t\telse if(this._location.Address == null)\n\t\t{\n\t\t\tbuilder.setMessage(R.string.error_invalid_address_str);\n\t\t\tbuilder.show();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(this._location.Port <= 0)\n\t\t\t\tthis._location.Port = MythCom.DEFAULT_MYTH_PORT;\n\t\t\tLocationDbAdapter adapter = new LocationDbAdapter(this);\n\t\t\tadapter.open();\n\t\t\tif(this._location.ID == -1)\n\t\t\t{\n\t\t\t\tthis._location.ID = (int) adapter.createFrontendLocation(this._location.Name, this._location.Address, this._location.Port);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn adapter.updateFrontendLocation(this._location.ID, this._location.Name, this._location.Address, this._location.Port);\n\t\t\t}\n\t\t\tadapter.close();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tprivate boolean Save()\n\t{\n\t\tif(this._location == null)\n\t\t\tthis._location = new FrontendLocation();\n\t\tthis._location.Name = this.GetName();\n\t\tthis._location.Address = this.GetAddress();\n\t\tthis._location.Port = this.GetPort();\n\t\tAlertDialog.Builder builder = new AlertDialog.Builder(this);\n\t\tbuilder.setTitle(R.string.error_input_str);\n\t\tbuilder.setNeutralButton(R.string.ok_str, new DialogInterface.OnClickListener(){\n\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t}});\n\t\tif(this._location.Name.trim().equals(\"\"))\n\t\t{\n\t\t\tbuilder.setMessage(R.string.error_invalid_name_str);\n\t\t\tbuilder.show();\n\t\t}\n\t\telse if(this._location.Address.trim().equals(\"\"))\n\t\t{\n\t\t\tbuilder.setMessage(R.string.error_invalid_address_str);\n\t\t\tbuilder.show();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(this._location.Port <= 0)\n\t\t\t\tthis._location.Port = MythCom.DEFAULT_MYTH_PORT;\n\t\t\tLocationDbAdapter adapter = new LocationDbAdapter(this);\n\t\t\tadapter.open();\n\t\t\tif(this._location.ID == -1)\n\t\t\t{\n\t\t\t\tthis._location.ID = (int) adapter.createFrontendLocation(this._location.Name, this._location.Address, this._location.Port);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn adapter.updateFrontendLocation(this._location.ID, this._location.Name, this._location.Address, this._location.Port);\n\t\t\t}\n\t\t\tadapter.close();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": "\tprivate void postAbsenceInfo(HttpServletRequest req,\n\t\t\tHttpServletResponse resp) throws ServletException, IOException {\n\t\tDataTrain train = DataTrain.depart();\n\t\tAbsenceManager ac = train.absences();\n\t\tDateTimeZone zone = train.appData().get().getTimeZone();\n\t\tboolean validForm = true;\n\t\tList<String> errors = new LinkedList<String>();\n\t\tif (!ValidationUtil.isPost(req)) {\n\t\t\tvalidForm = false;\n\t\t} else {\n\t\t\tString absid = req.getParameter(\"absenceid\");\n\t\t\tif (req.getParameter(\"delete\") != null) {\n\t\t\t\tdeleteAbsence(absid, ac, req, resp);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlong aid;\n\t\t\tAbsence toUpdate = null;\n\t\t\tif (absid != null) {\n\t\t\t\tString type = req.getParameter(\"Type\");\n\t\t\t\tString status = req.getParameter(\"Status\");\n\t\t\t\tString eventid = req.getParameter(\"eventid\");\n\t\t\t\tEvent event = null;\n\t\t\t\ttry {\n\t\t\t\t\tlong eid = Long.parseLong(eventid);\n\t\t\t\t\tevent = train.events().get(eid);\n\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\terrors.add(\"No event to add. Can't create absence.\");\n\t\t\t\t}\n\t\t\t\tif (absid.equals(\"new\")) {\n\t\t\t\t\tString sid = req.getParameter(\"studentid\");\n\t\t\t\t\tUser student = train.users().get(sid);\n\t\t\t\t\tAbsence.Type atype = Absence.Type.valueOf(type);\n\t\t\t\t\tif (student != null) {\n\t\t\t\t\t\tDateTime time = Util.parseDateTime(\n\t\t\t\t\t\t\t\treq.getParameter(\"date\") + \" \"\n\t\t\t\t\t\t\t\t\t\t+ req.getParameter(\"time\"), train\n\t\t\t\t\t\t\t\t\t\t.appData().get().getTimeZone());\n\t\t\t\t\t\tswitch (atype) {\n\t\t\t\t\t\tcase Absence:\n\t\t\t\t\t\t\ttoUpdate = ac.createOrUpdateAbsence(student, event);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Tardy:\n\t\t\t\t\t\t\ttoUpdate = ac.createOrUpdateTardy(student, time);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EarlyCheckOut:\n\t\t\t\t\t\t\ttoUpdate = ac.createOrUpdateEarlyCheckout(student,\n\t\t\t\t\t\t\t\t\ttime);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\taid = Long.parseLong(absid);\n\t\t\t\t\ttoUpdate = ac.get(aid);\n\t\t\t\t}\n\t\t\t\tif (toUpdate != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tLocalTime d = Util.parseTimeOnly(\n\t\t\t\t\t\t\t\treq.getParameter(\"time\"), train.appData().get()\n\t\t\t\t\t\t\t\t\t\t.getTimeZone());\n\t\t\t\t\t\tswitch (toUpdate.getType()) {\n\t\t\t\t\t\tcase EarlyCheckOut:\n\t\t\t\t\t\t\ttoUpdate.setCheckout(d.toDateTime(toUpdate\n\t\t\t\t\t\t\t\t\t.getCheckout(zone).toDateMidnight()));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Tardy:\n\t\t\t\t\t\t\ttoUpdate.setCheckin(d.toDateTime(toUpdate\n\t\t\t\t\t\t\t\t\t.getCheckin(zone).toDateMidnight()));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new IllegalStateException();\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoUpdate.setType(Absence.Type.valueOf(type));\n\t\t\t\t\t\ttoUpdate.setStatus(Absence.Status.valueOf(status));\n\t\t\t\t\t} catch (ValidationExceptions e) {\n\t\t\t\t\t\tvalidForm = false;\n\t\t\t\t\t\terrors.add(\"Invalid Input: The input DateTime was invalid.\");\n\t\t\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\t\t\tvalidForm = false;\n\t\t\t\t\t\terrors.add(\"Invalid Input: The input DateTime is invalid.\");\n\t\t\t\t\t} catch (IllegalStateException e) {\n\t\t\t\t\t\tvalidForm = false;\n\t\t\t\t\t\terrors.add(\"Invalid Input: Cannot set time for absence\");\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvalidForm = false;\n\t\t\t\t\terrors.add(\"Could not find the Absence to update\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvalidForm = false;\n\t\t\t\terrors.add(\"Could not find the Absence to update\");\n\t\t\t}\n\t\t\tif (validForm) {\n\t\t\t\tac.updateAbsence(toUpdate);\n\t\t\t\tviewAbsence(req, resp, errors, \"Successfully updated absence\");\n\t\t\t} else {\n\t\t\t\tviewAbsence(req, resp, errors, \"\");\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void postAbsenceInfo(HttpServletRequest req,\n\t\t\tHttpServletResponse resp) throws ServletException, IOException {\n\t\tDataTrain train = DataTrain.depart();\n\t\tAbsenceManager ac = train.absences();\n\t\tDateTimeZone zone = train.appData().get().getTimeZone();\n\t\tboolean validForm = true;\n\t\tList<String> errors = new LinkedList<String>();\n\t\tif (!ValidationUtil.isPost(req)) {\n\t\t\tvalidForm = false;\n\t\t} else {\n\t\t\tString absid = req.getParameter(\"absenceid\");\n\t\t\tif (req.getParameter(\"delete\") != null) {\n\t\t\t\tdeleteAbsence(absid, ac, req, resp);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlong aid;\n\t\t\tAbsence toUpdate = null;\n\t\t\tif (absid != null) {\n\t\t\t\tString type = req.getParameter(\"Type\");\n\t\t\t\tString status = req.getParameter(\"Status\");\n\t\t\t\tString eventid = req.getParameter(\"eventid\");\n\t\t\t\tEvent event = null;\n\t\t\t\ttry {\n\t\t\t\t\tlong eid = Long.parseLong(eventid);\n\t\t\t\t\tevent = train.events().get(eid);\n\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\terrors.add(\"No event to add. Can't create absence.\");\n\t\t\t\t}\n\t\t\t\tif (absid.equals(\"new\")) {\n\t\t\t\t\tString sid = req.getParameter(\"studentid\");\n\t\t\t\t\tUser student = train.users().get(sid);\n\t\t\t\t\tAbsence.Type atype = Absence.Type.valueOf(type);\n\t\t\t\t\tif (student != null) {\n\t\t\t\t\t\tDateTime time = Util.parseDateTime(\n\t\t\t\t\t\t\t\treq.getParameter(\"date\") + \" \"\n\t\t\t\t\t\t\t\t\t\t+ req.getParameter(\"time\"), train\n\t\t\t\t\t\t\t\t\t\t.appData().get().getTimeZone());\n\t\t\t\t\t\tswitch (atype) {\n\t\t\t\t\t\tcase Absence:\n\t\t\t\t\t\t\ttoUpdate = ac.createOrUpdateAbsence(student, event);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Tardy:\n\t\t\t\t\t\t\ttoUpdate = ac.createOrUpdateTardy(student, time);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase EarlyCheckOut:\n\t\t\t\t\t\t\ttoUpdate = ac.createOrUpdateEarlyCheckout(student,\n\t\t\t\t\t\t\t\t\ttime);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\taid = Long.parseLong(absid);\n\t\t\t\t\ttoUpdate = ac.get(aid);\n\t\t\t\t}\n\t\t\t\tif (toUpdate != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tString time = req.getParameter(\"time\");\n\t\t\t\t\t\tLocalTime d = null;\n\t\t\t\t\t\tif (time != null && !time.equals(\"\")) {\n\t\t\t\t\t\t\td = Util.parseTimeOnly(time, train.appData().get()\n\t\t\t\t\t\t\t\t\t.getTimeZone());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (d == null\n\t\t\t\t\t\t\t\t&& toUpdate.getType() != Absence.Type.Absence) {\n\t\t\t\t\t\t\tthrow new IllegalArgumentException();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tswitch (toUpdate.getType()) {\n\t\t\t\t\t\tcase EarlyCheckOut:\n\t\t\t\t\t\t\ttoUpdate.setCheckout(d.toDateTime(toUpdate\n\t\t\t\t\t\t\t\t\t.getCheckout(zone).toDateMidnight()));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Tardy:\n\t\t\t\t\t\t\ttoUpdate.setCheckin(d.toDateTime(toUpdate\n\t\t\t\t\t\t\t\t\t.getCheckin(zone).toDateMidnight()));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Absence:\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tthrow new IllegalStateException();\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttoUpdate.setType(Absence.Type.valueOf(type));\n\t\t\t\t\t\ttoUpdate.setStatus(Absence.Status.valueOf(status));\n\t\t\t\t\t} catch (ValidationExceptions e) {\n\t\t\t\t\t\tvalidForm = false;\n\t\t\t\t\t\terrors.add(\"Invalid Input: The input DateTime was invalid.\");\n\t\t\t\t\t} catch (IllegalArgumentException e) {\n\t\t\t\t\t\tvalidForm = false;\n\t\t\t\t\t\terrors.add(\"Invalid Input: The input DateTime is invalid.\");\n\t\t\t\t\t} catch (IllegalStateException e) {\n\t\t\t\t\t\tvalidForm = false;\n\t\t\t\t\t\terrors.add(\"Invalid Input: Cannot set time for absence\");\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvalidForm = false;\n\t\t\t\t\terrors.add(\"Could not find the Absence to update\");\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvalidForm = false;\n\t\t\t\terrors.add(\"Could not find the Absence to update\");\n\t\t\t}\n\t\t\tif (validForm) {\n\t\t\t\tac.updateAbsence(toUpdate);\n\t\t\t\tviewAbsence(req, resp, errors, \"Successfully updated absence\");\n\t\t\t} else {\n\t\t\t\tviewAbsence(req, resp, errors, \"\");\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic static Result register(){\n\t\tForm<Register> registerForm = form(Register.class).bindFromRequest();\n\t\tPattern pattern = Pattern.compile(\"[^a-z ]\", Pattern.CASE_INSENSITIVE);\n\t\tMatcher matcher = pattern.matcher(registerForm.get().name);\n\t\tList<Link> breadcrumbs = new ArrayList<Link>();\n\t\tbreadcrumbs.add(new Link(\"Home\", \"/\"));\n\t\tbreadcrumbs.add(new Link(\"Sign Up\", \"/signup\"));\n\t\tif(!registerForm.get().email.isEmpty()){\n\t\t\tif(Ebean.find(UserModel.class).where().eq(\n\t\t\t\t\t\"email\",registerForm.get().email).findUnique() != null){\n\t\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"register.same_email\")));\n\t\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, registerForm));\n\t\t\t}\n\t\t}\n\t\tif(registerForm.hasErrors()){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.text\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, form(Register.class).bindFromRequest()));\n\t\t}\n\t\tif(matcher.find()){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.invalid_symbols\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, form(Register.class).bindFromRequest()));\n\t\t}\n\t\tpattern = Pattern.compile(\"[^a-z._+@0-9!#$%&'*+-/=?^_`{|}~]\");\n\t\tmatcher = pattern.matcher(registerForm.get().email);\n\t\tif(matcher.find()){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.invalid_email\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, form(Register.class).bindFromRequest()));\n\t\t}\n\t\ttry{\n\t\t\tnew SimpleDateFormat(\"yyyy/mm/dd\").parse(registerForm.get().bday);\n\t\t}catch(Exception e){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.invalid_date\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, form(Register.class).bindFromRequest()));\n\t\t}\n\t\tString bebrasID = null;\n\t\ttry {\n\t\t\tbebrasID = AuthenticationManager.getInstance().createUser(registerForm);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn ok(registerLandingPage.render(EMessages.get(\"info.success\"), new ArrayList<Link>(), bebrasID));\n\t}\n", "output": "\tpublic static Result register(){\n\t\tForm<Register> registerForm = form(Register.class).bindFromRequest();\n\t\tPattern pattern = Pattern.compile(\"[^a-z ]\", Pattern.CASE_INSENSITIVE);\n\t\tMatcher matcher = pattern.matcher(registerForm.get().name);\n\t\tList<Link> breadcrumbs = new ArrayList<Link>();\n\t\tbreadcrumbs.add(new Link(\"Home\", \"/\"));\n\t\tbreadcrumbs.add(new Link(\"Sign Up\", \"/signup\"));\n\t\tif(!registerForm.get().email.isEmpty()){\n\t\t\tif(Ebean.find(UserModel.class).where().eq(\n\t\t\t\t\t\"email\",registerForm.get().email).findUnique() != null){\n\t\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"register.same_email\")));\n\t\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, registerForm));\n\t\t\t}\n\t\t}\n\t\tif(registerForm.hasErrors()){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.text\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, registerForm));\n\t\t}\n\t\tif(matcher.find()){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.invalid_symbols\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, registerForm));\n\t\t}\n\t\tpattern = Pattern.compile(\"[^a-z._+@0-9!#$%&'*+-/=?^_`{|}~]\");\n\t\tmatcher = pattern.matcher(registerForm.get().email);\n\t\tif(matcher.find()){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.invalid_email\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, registerForm));\n\t\t}\n\t\ttry{\n\t\t\tnew SimpleDateFormat(\"yyyy/mm/dd\").parse(registerForm.get().bday);\n\t\t}catch(Exception e){\n\t\t\tflash(\"error\", EMessages.get(EMessages.get(\"error.invalid_date\")));\n\t\t\treturn badRequest(register.render((EMessages.get(\"register.title\")), breadcrumbs, registerForm));\n\t\t}\n\t\tString bebrasID = null;\n\t\ttry {\n\t\t\tbebrasID = AuthenticationManager.getInstance().createUser(registerForm);\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn ok(registerLandingPage.render(EMessages.get(\"info.success\"), new ArrayList<Link>(), bebrasID));\n\t}\n"} {"input": " public void fillCurrentUserSubjectList(Subject[] subjects) {\n UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();\n Person person = personDAO.findByUsername(userDetails.getUsername());\n LOGGER.debug(\"User: \" + person.getUsername() + \" [\" + person.getIndeks() + \"] submitted subjects: \" +\n Arrays.asList(subjects));\n final List<Subject> toRemove = new ArrayList<>();\n final List<Subject> personSubjects = person.getSubjects();\n for (Subject s : personSubjects) {\n boolean contained = false;\n for (Subject s2 : subjects) {\n if (s2.equals(s)) {\n contained = true;\n break;\n }\n }\n if (!contained) {\n toRemove.add(s);\n }\n }\n LOGGER.debug(\"To remove list computed: \" + toRemove);\n for (Subject s : toRemove) {\n s = getByPK(s.getSubjectID());\n final List<Term> termsBySubject = termDAO.getTermsBySubject(s);\n LOGGER.debug(\"Terms of subject: \" + s + \" retrieved\");\n for (Term t : termsBySubject) {\n final StudentPointsPerTerm byPersonAndTerm = pointsDAO.getByPersonAndTerm(person, t);\n if (byPersonAndTerm != null) {\n pointsDAO.remove(byPersonAndTerm);\n LOGGER.debug(\"Points of term: \" + t + \" removed\");\n }\n }\n s.getPersons().remove(person);\n LOGGER.debug(\"Person removed from subject\");\n }\n personSubjects.removeAll(toRemove);\n LOGGER.debug(\"Unnecessary subjects removed\");\n for (Subject subject : subjects) {\n subject.addPerson(person);\n person.addSubject(subject);\n LOGGER.debug(\"add new subject to student: \" + subject);\n }\n em.merge(person);\n LOGGER.debug(\"Person updated\");\n }\n", "output": " public void fillCurrentUserSubjectList(Subject[] subjects) {\n UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();\n Person person = personDAO.findByUsername(userDetails.getUsername());\n LOGGER.debug(\"User: \" + person.getUsername() + \" [\" + person.getIndeks() + \"] submitted subjects: \" +\n Arrays.asList(subjects));\n final List<Subject> toRemove = new ArrayList<>();\n final List<Subject> personSubjects = person.getSubjects();\n for (Subject s : personSubjects) {\n boolean contained = false;\n for (Subject s2 : subjects) {\n if (s2.equals(s)) {\n contained = true;\n break;\n }\n }\n if (!contained) {\n toRemove.add(s);\n }\n }\n LOGGER.debug(\"To remove list computed: \" + toRemove);\n for (Subject s : toRemove) {\n s = getByPK(s.getSubjectID());\n final List<Term> termsBySubject = termDAO.getTermsBySubject(s);\n LOGGER.debug(\"Terms of subject: \" + s + \" retrieved\");\n for (Term t : termsBySubject) {\n final StudentPointsPerTerm byPersonAndTerm = pointsDAO.getByPersonAndTerm(person, t);\n if (byPersonAndTerm != null) {\n pointsDAO.remove(byPersonAndTerm);\n LOGGER.debug(\"Points of term: \" + t + \" removed\");\n }\n }\n s.getPersons().remove(person);\n LOGGER.debug(\"Person removed from subject\");\n }\n personSubjects.removeAll(toRemove);\n LOGGER.debug(\"Unnecessary subjects removed\");\n for (Subject subject : subjects) {\n subject = getByPK(subject.getSubjectID());\n subject.addPerson(person);\n person.addSubject(subject);\n LOGGER.debug(\"add new subject to student: \" + subject);\n }\n em.merge(person);\n LOGGER.debug(\"Person updated\");\n }\n"} {"input": " protected final void addAnnotationsBuilder() {\n \tDescriptor descriptor = AnnotationsControllerManager.INSTANCE.getDescriptor(ProjectUtilities.getProject(model.getStringProperty(PROJECT_NAME)));\n \tif (descriptor!=null) \n \t\treturn;\n try {\n IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATE_EMITTER);\n String builderID = configurationElements[0].getNamespace() + \".\" + configurationElements[0].getAttribute(BUILDER_ID); \n IProject project = ProjectUtilities.getProject(model.getProperty(PROJECT_NAME));\n IProjectDescription description = project.getDescription();\n ICommand[] commands = description.getBuildSpec();\n boolean found = false;\n for (int i = 0; i < commands.length; ++i) {\n if (commands[i].getBuilderName().equals(builderID)) {\n found = true;\n break;\n }\n }\n if (!found) {\n ICommand command = description.newCommand();\n command.setBuilderName(builderID);\n ICommand[] newCommands = new ICommand[commands.length + 1];\n System.arraycopy(commands, 0, newCommands, 0, commands.length);\n newCommands[commands.length] = command;\n IProjectDescription desc = project.getDescription();\n desc.setBuildSpec(newCommands);\n project.setDescription(desc, null);\n }\n } catch (Exception e) {\n }\n }\n", "output": " protected final void addAnnotationsBuilder() {\n \tDescriptor descriptor = AnnotationsControllerManager.INSTANCE.getDescriptor(ProjectUtilities.getProject(model.getStringProperty(PROJECT_NAME)));\n \tif (descriptor!=null) \n \t\treturn;\n try {\n IConfigurationElement[] configurationElements = Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATE_EMITTER);\n String builderID = configurationElements[0].getNamespace() + \".\" + configurationElements[0].getAttribute(BUILDER_ID); \n IProject project = ProjectUtilities.getProject(model.getProperty(PROJECT_NAME));\n if(project != null && project.isAccessible()) {\n IProjectDescription description = project.getDescription();\n ICommand[] commands = description.getBuildSpec();\n boolean found = false;\n for (int i = 0; i < commands.length; ++i) {\n if (commands[i].getBuilderName().equals(builderID)) {\n found = true;\n break;\n }\n }\n if (!found) {\n ICommand command = description.newCommand();\n command.setBuilderName(builderID);\n ICommand[] newCommands = new ICommand[commands.length + 1];\n System.arraycopy(commands, 0, newCommands, 0, commands.length);\n newCommands[commands.length] = command;\n IProjectDescription desc = project.getDescription();\n desc.setBuildSpec(newCommands);\n project.setDescription(desc, null);\n }\n }\n } catch (Exception e) {\n }\n }\n"} {"input": " public final SixteenSegment build() {\n final SixteenSegment CONTROL = new SixteenSegment();\n for (String key : properties.keySet()) {\n if(\"prefWidth\".equals(key)) {\n CONTROL.setPrefWidth(((DoubleProperty) properties.get(key)).get());\n } else if(\"prefHeight\".equals(key)) {\n CONTROL.setPrefHeight(((DoubleProperty) properties.get(key)).get());\n } else if(\"minWidth\".equals(key)) {\n CONTROL.setMinWidth(((DoubleProperty) properties.get(key)).get());\n } else if(\"minHeight\".equals(key)) {\n CONTROL.setMinHeight(((DoubleProperty) properties.get(key)).get());\n } else if(\"maxWidth\".equals(key)) {\n CONTROL.setMaxWidth(((DoubleProperty) properties.get(key)).get());\n } else if(\"maxHeight\".equals(key)) {\n CONTROL.setMaxHeight(((DoubleProperty) properties.get(key)).get());\n } else if(\"scaleX\".equals(key)) {\n CONTROL.setScaleX(((DoubleProperty) properties.get(key)).get());\n } else if(\"scaleY\".equals(key)) {\n CONTROL.setScaleY(((DoubleProperty) properties.get(key)).get());\n } else if (\"layoutX\".equals(key)) {\n CONTROL.setLayoutX(((DoubleProperty) properties.get(key)).get());\n } else if (\"layoutY\".equals(key)) {\n CONTROL.setLayoutY(((DoubleProperty) properties.get(key)).get());\n } else if (\"translateX\".equals(key)) {\n CONTROL.setTranslateX(((DoubleProperty) properties.get(key)).get());\n } else if (\"translateY\".equals(key)) {\n CONTROL.setTranslateY(((DoubleProperty) properties.get(key)).get());\n } else if (\"styleClass\".equals(key)) {\n CONTROL.getStyleClass().setAll(\"seven-segment\", ((StringProperty) properties.get(key)).get());\n } else if (\"segmentStyle\".equals(key)) {\n CONTROL.setSegmentStyle(((ObjectProperty<SixteenSegment.SegmentStyle>) properties.get(key)).get());\n } else if (\"characterString\".equals(key)) {\n CONTROL.setCharacter(((StringProperty) properties.get(key)).get());\n } else if (\"characterChar\".equals(key)) {\n CONTROL.setCharacter(((ObjectProperty<Character>) properties.get(key)).get());\n } else if (\"characterInt\".equals(key)) {\n CONTROL.setCharacter(((IntegerProperty) properties.get(key)).get());\n } else if (\"dotOn\".equals(key)) {\n CONTROL.setDotOn(((BooleanProperty) properties.get(key)).get());\n }\n }\n return CONTROL;\n }\n", "output": " public final SixteenSegment build() {\n final SixteenSegment CONTROL = new SixteenSegment();\n for (String key : properties.keySet()) {\n if(\"prefWidth\".equals(key)) {\n CONTROL.setPrefWidth(((DoubleProperty) properties.get(key)).get());\n } else if(\"prefHeight\".equals(key)) {\n CONTROL.setPrefHeight(((DoubleProperty) properties.get(key)).get());\n } else if(\"minWidth\".equals(key)) {\n CONTROL.setMinWidth(((DoubleProperty) properties.get(key)).get());\n } else if(\"minHeight\".equals(key)) {\n CONTROL.setMinHeight(((DoubleProperty) properties.get(key)).get());\n } else if(\"maxWidth\".equals(key)) {\n CONTROL.setMaxWidth(((DoubleProperty) properties.get(key)).get());\n } else if(\"maxHeight\".equals(key)) {\n CONTROL.setMaxHeight(((DoubleProperty) properties.get(key)).get());\n } else if(\"scaleX\".equals(key)) {\n CONTROL.setScaleX(((DoubleProperty) properties.get(key)).get());\n } else if(\"scaleY\".equals(key)) {\n CONTROL.setScaleY(((DoubleProperty) properties.get(key)).get());\n } else if (\"layoutX\".equals(key)) {\n CONTROL.setLayoutX(((DoubleProperty) properties.get(key)).get());\n } else if (\"layoutY\".equals(key)) {\n CONTROL.setLayoutY(((DoubleProperty) properties.get(key)).get());\n } else if (\"translateX\".equals(key)) {\n CONTROL.setTranslateX(((DoubleProperty) properties.get(key)).get());\n } else if (\"translateY\".equals(key)) {\n CONTROL.setTranslateY(((DoubleProperty) properties.get(key)).get());\n } else if (\"styleClass\".equals(key)) {\n CONTROL.getStyleClass().setAll(\"sixteen-segment\", ((StringProperty) properties.get(key)).get());\n } else if (\"segmentStyle\".equals(key)) {\n CONTROL.setSegmentStyle(((ObjectProperty<SixteenSegment.SegmentStyle>) properties.get(key)).get());\n } else if (\"characterString\".equals(key)) {\n CONTROL.setCharacter(((StringProperty) properties.get(key)).get());\n } else if (\"characterChar\".equals(key)) {\n CONTROL.setCharacter(((ObjectProperty<Character>) properties.get(key)).get());\n } else if (\"characterInt\".equals(key)) {\n CONTROL.setCharacter(((IntegerProperty) properties.get(key)).get());\n } else if (\"dotOn\".equals(key)) {\n CONTROL.setDotOn(((BooleanProperty) properties.get(key)).get());\n }\n }\n return CONTROL;\n }\n"} {"input": " public static void populate(Object bean, String prefix, String suffix,\n HttpServletRequest request)\n throws ServletException {\n HashMap properties = new HashMap();\n Enumeration names = null;\n Map multipartParameters = null;\n String contentType = request.getContentType();\n String method = request.getMethod();\n boolean isMultipart = false;\n if (bean instanceof ActionForm) {\n ((ActionForm) bean).setMultipartRequestHandler(null);\n }\n MultipartRequestHandler multipartHandler = null;\n if ((contentType != null)\n && (contentType.startsWith(\"multipart/form-data\"))\n && (method.equalsIgnoreCase(\"POST\"))) {\n ActionServletWrapper servlet;\n if (bean instanceof ActionForm) {\n servlet = ((ActionForm) bean).getServletWrapper();\n } else {\n throw new ServletException(\"bean that's supposed to be \"\n + \"populated from a multipart request is not of type \"\n + \"\\\"org.apache.struts.action.ActionForm\\\", but type \"\n + \"\\\"\" + bean.getClass().getName() + \"\\\"\");\n }\n multipartHandler = getMultipartHandler(request);\n if (multipartHandler != null) {\n isMultipart = true;\n servlet.setServletFor(multipartHandler);\n multipartHandler.setMapping((ActionMapping) request\n .getAttribute(Globals.MAPPING_KEY));\n multipartHandler.handleRequest(request);\n Boolean maxLengthExceeded =\n (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);\n if ((maxLengthExceeded != null)\n && (maxLengthExceeded.booleanValue())) {\n return;\n }\n multipartParameters =\n getAllParametersForMultipartRequest(request,\n multipartHandler);\n names = Collections.enumeration(multipartParameters.keySet());\n }\n }\n if (!isMultipart) {\n names = request.getParameterNames();\n }\n while (names.hasMoreElements()) {\n String name = (String) names.nextElement();\n String stripped = name;\n if (prefix != null) {\n if (!stripped.startsWith(prefix)) {\n continue;\n }\n stripped = stripped.substring(prefix.length());\n }\n if (suffix != null) {\n if (!stripped.endsWith(suffix)) {\n continue;\n }\n stripped =\n stripped.substring(0, stripped.length() - suffix.length());\n }\n Object parameterValue = null;\n if (isMultipart) {\n parameterValue = multipartParameters.get(name);\n } else {\n parameterValue = request.getParameterValues(name);\n }\n if (!(stripped.startsWith(\"org.apache.struts.\"))) {\n properties.put(stripped, parameterValue);\n }\n }\n try {\n BeanUtils.populate(bean, properties);\n } catch (Exception e) {\n throw new ServletException(\"BeanUtils.populate\", e);\n } finally {\n if (multipartHandler != null) {\n ((ActionForm) bean).setMultipartRequestHandler(multipartHandler);\n }\n }\n }\n", "output": " public static void populate(Object bean, String prefix, String suffix,\n HttpServletRequest request)\n throws ServletException {\n HashMap properties = new HashMap();\n Enumeration names = null;\n Map multipartParameters = null;\n String contentType = request.getContentType();\n String method = request.getMethod();\n boolean isMultipart = false;\n if (bean instanceof ActionForm) {\n ((ActionForm) bean).setMultipartRequestHandler(null);\n }\n MultipartRequestHandler multipartHandler = null;\n if ((contentType != null)\n && (contentType.startsWith(\"multipart/form-data\"))\n && (method.equalsIgnoreCase(\"POST\"))) {\n ActionServletWrapper servlet;\n if (bean instanceof ActionForm) {\n servlet = ((ActionForm) bean).getServletWrapper();\n } else {\n throw new ServletException(\"bean that's supposed to be \"\n + \"populated from a multipart request is not of type \"\n + \"\\\"org.apache.struts.action.ActionForm\\\", but type \"\n + \"\\\"\" + bean.getClass().getName() + \"\\\"\");\n }\n multipartHandler = getMultipartHandler(request);\n if (multipartHandler != null) {\n isMultipart = true;\n servlet.setServletFor(multipartHandler);\n multipartHandler.setMapping((ActionMapping) request\n .getAttribute(Globals.MAPPING_KEY));\n multipartHandler.handleRequest(request);\n Boolean maxLengthExceeded =\n (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);\n if ((maxLengthExceeded != null)\n && (maxLengthExceeded.booleanValue())) {\n ((ActionForm) bean).setMultipartRequestHandler(multipartHandler);\n return;\n }\n multipartParameters =\n getAllParametersForMultipartRequest(request,\n multipartHandler);\n names = Collections.enumeration(multipartParameters.keySet());\n }\n }\n if (!isMultipart) {\n names = request.getParameterNames();\n }\n while (names.hasMoreElements()) {\n String name = (String) names.nextElement();\n String stripped = name;\n if (prefix != null) {\n if (!stripped.startsWith(prefix)) {\n continue;\n }\n stripped = stripped.substring(prefix.length());\n }\n if (suffix != null) {\n if (!stripped.endsWith(suffix)) {\n continue;\n }\n stripped =\n stripped.substring(0, stripped.length() - suffix.length());\n }\n Object parameterValue = null;\n if (isMultipart) {\n parameterValue = multipartParameters.get(name);\n } else {\n parameterValue = request.getParameterValues(name);\n }\n if (!(stripped.startsWith(\"org.apache.struts.\"))) {\n properties.put(stripped, parameterValue);\n }\n }\n try {\n BeanUtils.populate(bean, properties);\n } catch (Exception e) {\n throw new ServletException(\"BeanUtils.populate\", e);\n } finally {\n if (multipartHandler != null) {\n ((ActionForm) bean).setMultipartRequestHandler(multipartHandler);\n }\n }\n }\n"} {"input": " private String getIPFrom_chinaz(final String hostName)\n {\n String ipAddress = null;\n String url = UrlManager.URL_CHINAZ_IP + \"?IP=\" + hostName;\n NetDataGetter getter;\n try \n {\n getter = new NetDataGetter(url);\n String html = getter.getStringData();\n Pattern resultPattern = Pattern.compile(\"\u67e5\u8be2\u7ed3\u679c\\\\[1\\\\](.+)</\");\n Matcher resultMatcher = resultPattern.matcher(html);\n if (resultMatcher.find())\n {\n String result = resultMatcher.group();\n Pattern ipPattern = Pattern.compile(\"((25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)\\\\.){3}(25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|[1-9])\");\n Matcher ipMatcher = ipPattern.matcher(result);\n if (ipMatcher.find()) \n {\n ipAddress = ipMatcher.group();\n }\n }\n }\n catch (MalformedURLException e) \n {\n e.printStackTrace();\n }\n if (!Utility.isIPAddress(ipAddress))\n return null;\n return ipAddress;\n }\n", "output": " private String getIPFrom_chinaz(final String hostName)\n {\n String ipAddress = null;\n String url = UrlManager.URL_CHINAZ_IP + \"?IP=\" + hostName;\n NetDataGetter getter;\n try \n {\n getter = new NetDataGetter(url);\n String html = getter.getStringData();\n if (html == null)\n return null;\n Pattern resultPattern = Pattern.compile(\"\u67e5\u8be2\u7ed3\u679c\\\\[1\\\\](.+)</\");\n Matcher resultMatcher = resultPattern.matcher(html);\n if (resultMatcher.find())\n {\n String result = resultMatcher.group();\n Pattern ipPattern = Pattern.compile(\"((25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|\\\\d)\\\\.){3}(25[0-5]|2[0-4]\\\\d|1\\\\d\\\\d|[1-9]\\\\d|[1-9])\");\n Matcher ipMatcher = ipPattern.matcher(result);\n if (ipMatcher.find()) \n {\n ipAddress = ipMatcher.group();\n }\n }\n }\n catch (MalformedURLException e) \n {\n e.printStackTrace();\n }\n if (!Utility.isIPAddress(ipAddress))\n return null;\n return ipAddress;\n }\n"} {"input": "\tpublic void testExtractingEpisodes() throws Exception {\n\t\tList<Episode> episodes = new C4EpisodesExtractor(new NullAdapterLog()).includeBroadcasts().includeOnDemands().extract(fourOdFeed.build());\n\t\tEpisode firstEpisode = (Episode) Iterables.get(episodes, 0);\n\t\tassertThat(firstEpisode.getCanonicalUri(), is(\"http://www.channel4.com/programmes/ramsays-kitchen-nightmares/episode-guide/series-1/episode-1\"));\n\t\tassertThat(firstEpisode.getAliases(), is((Set<String>) ImmutableSet.of(\"http://www.channel4.com/programmes/ramsays-kitchen-nightmares/4od#2922045\", \"tag:www.channel4.com,2009:/programmes/ramsays-kitchen-nightmares/4od%232922045\")));\n\t\tassertThat(firstEpisode.getCurie(), is(\"c4:ramsays-kitchen-nightmares-series-1-episode-1\"));\n\t\tassertThat(firstEpisode.getTitle(), is(\"Series 1 Episode 1\"));\n\t\tassertThat(firstEpisode.getPublisher(), is(Publisher.C4));\n\t\tassertThat(firstEpisode.getSeriesNumber(), is(1));\n\t\tassertThat(firstEpisode.getEpisodeNumber(), is(1));\n\t\tassertThat(firstEpisode.getDescription(), startsWith(\"Gordon Ramsay visits Bonapartes in Silsden, West Yorkshire.\"));\n\t\tassertThat(firstEpisode.getThumbnail(), is(\"http://www.channel4.com/assets/programmes/images/ramsays-kitchen-nightmares/series-1/ramsays-kitchen-nightmares-s1-20090617160732_200x113.jpg\"));\n\t\tassertThat(firstEpisode.getImage(), is(\"http://www.channel4.com/assets/programmes/images/ramsays-kitchen-nightmares/series-1/ramsays-kitchen-nightmares-s1-20090617160732_625x352.jpg\"));\n\t\tassertThat(firstEpisode.getLastUpdated(), is(new DateTime(\"2010-04-27T09:49:40.803Z\", DateTimeZones.UTC)));\n\t\tVersion firstEpisodeVersion = Iterables.get(firstEpisode.getVersions(), 0);\n\t\tassertThat(firstEpisodeVersion.getDuration(), is((48 * 60) + 55));\n\t\tassertThat(firstEpisodeVersion.getRating(), is(\"http://ref.atlasapi.org/ratings/simple/adult\"));\n\t\tassertThat(firstEpisodeVersion.getRatingText(), is(\"Strong language throughout\"));\n\t\tassertThat(firstEpisodeVersion.getBroadcasts(), is(Collections.<Broadcast>emptySet()));\n\t\tEncoding firstEpsiodeEncoding = Iterables.get(firstEpisodeVersion.getManifestedAs(), 0); \n\t\tLocation firstEpsiodeLocation = Iterables.get(firstEpsiodeEncoding.getAvailableAt(), 0); \n\t\tassertThat(firstEpsiodeLocation.getUri(), is(\"http://www.channel4.com/programmes/ramsays-kitchen-nightmares/4od#2922045\"));\n\t\tassertThat(firstEpsiodeLocation.getAliases(), is((Set<String>) ImmutableSet.of(\"tag:www.channel4.com,2009:/programmes/ramsays-kitchen-nightmares/4od%232922045\")));\n\t\tassertThat(firstEpsiodeLocation.getTransportType(), is(TransportType.LINK));\n\t\tPolicy firstEpisodePolicy = firstEpsiodeLocation.getPolicy();\n\t\tassertThat(firstEpisodePolicy.getAvailabilityStart(), is(new LocalDate(2009, 07, 01).toDateTimeAtStartOfDay()));\n\t\tassertThat(firstEpisodePolicy.getAvailabilityEnd(), is(new LocalDate(2010, 12, 31).plusDays(1).toDateTimeAtStartOfDay()));\n\t\tassertThat(firstEpisodePolicy.getAvailableCountries(), is((Set<Country>) Sets.newHashSet(Countries.GB, Countries.IE)));\n\t\tEpisode episodeWithABroadcast = (Episode) Iterables.get(episodes, 4);\n\t\tVersion episodeWithABroadcastVersion = Iterables.get(episodeWithABroadcast.getVersions(), 0);\n\t\tBroadcast episodeWithABroadcastBroadcast = Iterables.get(episodeWithABroadcastVersion.getBroadcasts(), 0);\n\t\tassertThat(episodeWithABroadcastBroadcast.getTransmissionTime(), is(new DateTime(\"2009-06-10T23:05:00.000Z\")));\n\t\tassertThat(episodeWithABroadcastBroadcast.getBroadcastOn(), is(\"http://www.channel4.com/more4\"));\n\t}\n", "output": "\tpublic void testExtractingEpisodes() throws Exception {\n\t\tList<Episode> episodes = new C4EpisodesExtractor(new NullAdapterLog()).includeBroadcasts().includeOnDemands().extract(fourOdFeed.build());\n\t\tEpisode firstEpisode = (Episode) Iterables.get(episodes, 0);\n\t\tassertThat(firstEpisode.getCanonicalUri(), is(\"http://www.channel4.com/programmes/ramsays-kitchen-nightmares/episode-guide/series-1/episode-1\"));\n\t\tassertThat(firstEpisode.getAliases(), is((Set<String>) ImmutableSet.of(\"http://www.channel4.com/programmes/ramsays-kitchen-nightmares/4od#2922045\")));\n\t\tassertThat(firstEpisode.getCurie(), is(\"c4:ramsays-kitchen-nightmares-series-1-episode-1\"));\n\t\tassertThat(firstEpisode.getTitle(), is(\"Series 1 Episode 1\"));\n\t\tassertThat(firstEpisode.getPublisher(), is(Publisher.C4));\n\t\tassertThat(firstEpisode.getSeriesNumber(), is(1));\n\t\tassertThat(firstEpisode.getEpisodeNumber(), is(1));\n\t\tassertThat(firstEpisode.getDescription(), startsWith(\"Gordon Ramsay visits Bonapartes in Silsden, West Yorkshire.\"));\n\t\tassertThat(firstEpisode.getThumbnail(), is(\"http://www.channel4.com/assets/programmes/images/ramsays-kitchen-nightmares/series-1/ramsays-kitchen-nightmares-s1-20090617160732_200x113.jpg\"));\n\t\tassertThat(firstEpisode.getImage(), is(\"http://www.channel4.com/assets/programmes/images/ramsays-kitchen-nightmares/series-1/ramsays-kitchen-nightmares-s1-20090617160732_625x352.jpg\"));\n\t\tassertThat(firstEpisode.getLastUpdated(), is(new DateTime(\"2010-04-27T09:49:40.803Z\", DateTimeZones.UTC)));\n\t\tVersion firstEpisodeVersion = Iterables.get(firstEpisode.getVersions(), 0);\n\t\tassertThat(firstEpisodeVersion.getDuration(), is((48 * 60) + 55));\n\t\tassertThat(firstEpisodeVersion.getRating(), is(\"http://ref.atlasapi.org/ratings/simple/adult\"));\n\t\tassertThat(firstEpisodeVersion.getRatingText(), is(\"Strong language throughout\"));\n\t\tassertThat(firstEpisodeVersion.getBroadcasts(), is(Collections.<Broadcast>emptySet()));\n\t\tEncoding firstEpsiodeEncoding = Iterables.get(firstEpisodeVersion.getManifestedAs(), 0); \n\t\tLocation firstEpsiodeLocation = Iterables.get(firstEpsiodeEncoding.getAvailableAt(), 0); \n\t\tassertThat(firstEpsiodeLocation.getUri(), is(\"http://www.channel4.com/programmes/ramsays-kitchen-nightmares/4od#2922045\"));\n\t\tassertThat(firstEpsiodeLocation.getAliases(), is((Set<String>) ImmutableSet.of(\"tag:www.channel4.com,2009:/programmes/ramsays-kitchen-nightmares/4od%232922045\")));\n\t\tassertThat(firstEpsiodeLocation.getTransportType(), is(TransportType.LINK));\n\t\tPolicy firstEpisodePolicy = firstEpsiodeLocation.getPolicy();\n\t\tassertThat(firstEpisodePolicy.getAvailabilityStart(), is(new LocalDate(2009, 07, 01).toDateTimeAtStartOfDay()));\n\t\tassertThat(firstEpisodePolicy.getAvailabilityEnd(), is(new LocalDate(2010, 12, 31).plusDays(1).toDateTimeAtStartOfDay()));\n\t\tassertThat(firstEpisodePolicy.getAvailableCountries(), is((Set<Country>) Sets.newHashSet(Countries.GB, Countries.IE)));\n\t\tEpisode episodeWithABroadcast = (Episode) Iterables.get(episodes, 4);\n\t\tVersion episodeWithABroadcastVersion = Iterables.get(episodeWithABroadcast.getVersions(), 0);\n\t\tBroadcast episodeWithABroadcastBroadcast = Iterables.get(episodeWithABroadcastVersion.getBroadcasts(), 0);\n\t\tassertThat(episodeWithABroadcastBroadcast.getTransmissionTime(), is(new DateTime(\"2009-06-10T23:05:00.000Z\")));\n\t\tassertThat(episodeWithABroadcastBroadcast.getBroadcastOn(), is(\"http://www.channel4.com/more4\"));\n\t}\n"} {"input": " public TimestampSpec(\n @JsonProperty(\"column\") String timestampColumn,\n @JsonProperty(\"format\") String format\n )\n {\n this.timestampColumn = timestampColumn.toLowerCase();\n this.timestampFormat = format == null ? defaultFormat : format;\n this.timestampConverter = ParserUtils.createTimestampParser(timestampFormat);\n }\n", "output": " public TimestampSpec(\n @JsonProperty(\"column\") String timestampColumn,\n @JsonProperty(\"format\") String format\n )\n {\n this.timestampColumn = timestampColumn.toLowerCase();\n this.timestampFormat = format == null ? defaultFormat : format.toLowerCase();\n this.timestampConverter = ParserUtils.createTimestampParser(timestampFormat);\n }\n"} {"input": "\tpublic boolean reloadSettings() {\n\t\tfinal Set<String> oldForceEnableLater = new LinkedHashSet<String>();\n\t\toldForceEnableLater.addAll(settings.forceEnableLater);\n\t\tFile file = new File(getDataFolder() , \"cncp.yml\");\n\t\tCompatConfig cfg = new NewConfig(file);\n\t\tcfg.load();\n\t\tif (Settings.addDefaults(cfg)) cfg.save();\n\t\tsettings.fromConfig(cfg);\n\t\thookPlayerClass.setClassNames(settings.exemptPlayerClassNames);\n\t\thookPlayerClass.setExemptAll(settings.exemptAllPlayerClassNames);\n\t\thookPlayerClass.setPlayerClassName(settings.playerClassName);\n\t\tServer server = getServer();\n\t\tLogger logger = server.getLogger();\n\t\tfor (String plgName : settings.loadPlugins){\n\t\t\ttry{\n\t\t\t\tif (CompatNoCheatPlus.enablePlugin(plgName)){\n\t\t\t\t\tSystem.out.println(\"[cncp] Ensured that the following plugin is enabled: \" + plgName);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Throwable t){\n\t\t\t\tlogger.severe(\"[cncp] Failed to enable the plugin: \" + plgName);\n\t\t\t\tlogger.severe(Utils.toString(t));\n\t\t\t}\n\t\t}\n\t\tBukkitScheduler sched = server.getScheduler();\n\t\tfor (String plgName : settings.forceEnableLater){\n\t\t\tif (!oldForceEnableLater.remove(plgName)) oldForceEnableLater.add(plgName);\n\t\t}\n\t\tif (!oldForceEnableLater.isEmpty()){\n\t\t\tSystem.out.println(\"[cncp] Schedule task to re-enable plugins later...\");\n\t\t\tsched.scheduleSyncDelayedTask(this, new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tfor (String plgName : oldForceEnableLater){\n\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\tif (disablePlugin(plgName)){\n\t\t\t\t\t\t\t\tif (enablePlugin(plgName)) System.out.println(\"[cncp] Re-enabled plugin: \" + plgName);\n\t\t\t\t\t\t\t\telse System.out.println(\"[cncp] Could not re-enable plugin: \"+plgName);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\tSystem.out.println(\"[cncp] Could not disable plugin (already disabled?): \"+plgName);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch(Throwable t){\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}); \n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean reloadSettings() {\n\t\tfinal Set<String> oldForceEnableLater = new LinkedHashSet<String>();\n\t\toldForceEnableLater.addAll(settings.forceEnableLater);\n\t\tFile file = new File(getDataFolder() , \"cncp.yml\");\n\t\tCompatConfig cfg = new NewConfig(file);\n\t\tcfg.load();\n\t\tif (Settings.addDefaults(cfg)) cfg.save();\n\t\tsettings.fromConfig(cfg);\n\t\thookPlayerClass.setClassNames(settings.exemptPlayerClassNames);\n\t\thookPlayerClass.setExemptAll(settings.exemptAllPlayerClassNames);\n\t\thookPlayerClass.setPlayerClassName(settings.playerClassName);\n\t\thookPlayerClass.setCheckSuperClass(settings.exemptSuperClass);\n\t\tServer server = getServer();\n\t\tLogger logger = server.getLogger();\n\t\tfor (String plgName : settings.loadPlugins){\n\t\t\ttry{\n\t\t\t\tif (CompatNoCheatPlus.enablePlugin(plgName)){\n\t\t\t\t\tSystem.out.println(\"[cncp] Ensured that the following plugin is enabled: \" + plgName);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Throwable t){\n\t\t\t\tlogger.severe(\"[cncp] Failed to enable the plugin: \" + plgName);\n\t\t\t\tlogger.severe(Utils.toString(t));\n\t\t\t}\n\t\t}\n\t\tBukkitScheduler sched = server.getScheduler();\n\t\tfor (String plgName : settings.forceEnableLater){\n\t\t\tif (!oldForceEnableLater.remove(plgName)) oldForceEnableLater.add(plgName);\n\t\t}\n\t\tif (!oldForceEnableLater.isEmpty()){\n\t\t\tSystem.out.println(\"[cncp] Schedule task to re-enable plugins later...\");\n\t\t\tsched.scheduleSyncDelayedTask(this, new Runnable() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tfor (String plgName : oldForceEnableLater){\n\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\tif (disablePlugin(plgName)){\n\t\t\t\t\t\t\t\tif (enablePlugin(plgName)) System.out.println(\"[cncp] Re-enabled plugin: \" + plgName);\n\t\t\t\t\t\t\t\telse System.out.println(\"[cncp] Could not re-enable plugin: \"+plgName);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\tSystem.out.println(\"[cncp] Could not disable plugin (already disabled?): \"+plgName);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch(Throwable t){\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}); \n\t\t}\n\t\treturn true;\n\t}\n"} {"input": " public void testLoggerConfig() throws Exception {\n Logger logger = Logger.getLogger(\"foo.bar.zot\");\n HtmlPage page = new WebClient().goTo(\"log/all\");\n HtmlForm form = page.getFormByName(\"configLogger\");\n form.getInputByName(\"name\").setValueAttribute(\"foo.bar.zot\");\n form.getSelectByName(\"level\").getOptionByValue(\"finest\").setSelected(true);\n submit(form);\n assertEquals(logger.getLevel(), Level.FINEST);\n }\n", "output": " public void testLoggerConfig() throws Exception {\n Logger logger = Logger.getLogger(\"foo.bar.zot\");\n HtmlPage page = new WebClient().goTo(\"log/levels\");\n HtmlForm form = page.getFormByName(\"configLogger\");\n form.getInputByName(\"name\").setValueAttribute(\"foo.bar.zot\");\n form.getSelectByName(\"level\").getOptionByValue(\"finest\").setSelected(true);\n submit(form);\n assertEquals(logger.getLevel(), Level.FINEST);\n }\n"} {"input": " public String searchSchema(final SearchConditions searchConditions) {\n String union = \" union all \";\n String clientExactMatchSql = \" (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo \"\n + \" , c.office_id as parentId, o.name as parentName \"\n + \" from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :search or c.display_name like :search or c.external_id like :search)) \";\n String clientMatchSql = \" (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo \"\n + \" , c.office_id as parentId, o.name as parentName \"\n + \" from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :partialSearch and c.account_no not like :search) or \"\n + \"(c.display_name like :partialSearch and c.display_name not like :search) or \"\n + \"(c.external_id like :partialSearch and c.external_id not like :search))\";\n String loanExactMatchSql = \" (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo \"\n + \" , c.id as parentId, c.display_name as parentName \"\n + \" from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and l.account_no like :search) \";\n String loanMatchSql = \" (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo \"\n + \" , c.id as parentId, c.display_name as parentName \"\n + \" from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and l.account_no like :partialSearch and l.account_no not like :search) \";\n String clientIdentifierExactMatchSql = \" (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, \"\n + \" null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName \"\n + \" from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id \"\n + \" where o.hierarchy like :hierarchy and ci.document_key like :search) \";\n String clientIdentifierMatchSql = \" (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, \"\n + \" null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName \"\n + \" from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id \"\n + \" where o.hierarchy like :hierarchy and ci.document_key like :partialSearch and ci.document_key not like :search) \";\n String groupExactMatchSql = \" (select 'GROUP' as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, NULL as entityAccountNo \"\n + \" , g.office_id as parentId, o.name as parentName \"\n + \" from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and g.display_name like :search) \";\n String groupMatchSql = \" (select 'GROUP' as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, NULL as entityAccountNo \"\n + \" , g.office_id as parentId, o.name as parentName \"\n + \" from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and g.display_name like :partialSearch and g.display_name not like :search) \";\n StringBuffer sql = new StringBuffer();\n if (searchConditions.isClientSearch()) {\n sql.append(clientExactMatchSql).append(union);\n }\n if (searchConditions.isLoanSeach()) {\n sql.append(loanExactMatchSql).append(union);\n }\n if(searchConditions.isClientIdentifierSearch()){\n sql.append(clientIdentifierExactMatchSql).append(union);\n }\n if (searchConditions.isGroupSearch()) {\n sql.append(groupExactMatchSql).append(union);\n }\n if (searchConditions.isClientSearch()) {\n sql.append(clientMatchSql).append(union);\n }\n if (searchConditions.isLoanSeach()) {\n sql.append(loanMatchSql).append(union);\n }\n if(searchConditions.isClientIdentifierSearch()){\n sql.append(clientIdentifierMatchSql).append(union);\n }\n if (searchConditions.isGroupSearch()) {\n sql.append(groupMatchSql).append(union);\n }\n sql.replace(sql.lastIndexOf(union), sql.length(), \"\");\n return sql.toString();\n }\n", "output": " public String searchSchema(final SearchConditions searchConditions) {\n String union = \" union all \";\n String clientExactMatchSql = \" (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo \"\n + \" , c.office_id as parentId, o.name as parentName \"\n + \" from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :search or c.display_name like :search or c.external_id like :search)) \";\n String clientMatchSql = \" (select 'CLIENT' as entityType, c.id as entityId, c.display_name as entityName, c.external_id as entityExternalId, c.account_no as entityAccountNo \"\n + \" , c.office_id as parentId, o.name as parentName \"\n + \" from m_client c join m_office o on o.id = c.office_id where o.hierarchy like :hierarchy and (c.account_no like :partialSearch and c.account_no not like :search) or \"\n + \"(c.display_name like :partialSearch and c.display_name not like :search) or \"\n + \"(c.external_id like :partialSearch and c.external_id not like :search))\";\n String loanExactMatchSql = \" (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo \"\n + \" , c.id as parentId, c.display_name as parentName \"\n + \" from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and l.account_no like :search) \";\n String loanMatchSql = \" (select 'LOAN' as entityType, l.id as entityId, pl.name as entityName, l.external_id as entityExternalId, l.account_no as entityAccountNo \"\n + \" , c.id as parentId, c.display_name as parentName \"\n + \" from m_loan l join m_client c on l.client_id = c.id join m_office o on o.id = c.office_id join m_product_loan pl on pl.id=l.product_id where o.hierarchy like :hierarchy and l.account_no like :partialSearch and l.account_no not like :search) \";\n String clientIdentifierExactMatchSql = \" (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, \"\n + \" null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName \"\n + \" from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id \"\n + \" where o.hierarchy like :hierarchy and ci.document_key like :search) \";\n String clientIdentifierMatchSql = \" (select 'CLIENTIDENTIFIER' as entityType, ci.id as entityId, ci.document_key as entityName, \"\n + \" null as entityExternalId, null as entityAccountNo, c.id as parentId, c.display_name as parentName \"\n + \" from m_client_identifier ci join m_client c on ci.client_id=c.id join m_office o on o.id = c.office_id \"\n + \" where o.hierarchy like :hierarchy and ci.document_key like :partialSearch and ci.document_key not like :search) \";\n String groupExactMatchSql = \" (select IF(g.level_id=1,'CENTER','GROUP') as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, NULL as entityAccountNo \"\n + \" , g.office_id as parentId, o.name as parentName \"\n + \" from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and g.display_name like :search) \";\n String groupMatchSql = \" (select IF(g.level_id=1,'CENTER','GROUP') as entityType, g.id as entityId, g.display_name as entityName, g.external_id as entityExternalId, NULL as entityAccountNo \"\n + \" , g.office_id as parentId, o.name as parentName \"\n + \" from m_group g join m_office o on o.id = g.office_id where o.hierarchy like :hierarchy and g.display_name like :partialSearch and g.display_name not like :search) \";\n StringBuffer sql = new StringBuffer();\n if (searchConditions.isClientSearch()) {\n sql.append(clientExactMatchSql).append(union);\n }\n if (searchConditions.isLoanSeach()) {\n sql.append(loanExactMatchSql).append(union);\n }\n if(searchConditions.isClientIdentifierSearch()){\n sql.append(clientIdentifierExactMatchSql).append(union);\n }\n if (searchConditions.isGroupSearch()) {\n sql.append(groupExactMatchSql).append(union);\n }\n if (searchConditions.isClientSearch()) {\n sql.append(clientMatchSql).append(union);\n }\n if (searchConditions.isLoanSeach()) {\n sql.append(loanMatchSql).append(union);\n }\n if(searchConditions.isClientIdentifierSearch()){\n sql.append(clientIdentifierMatchSql).append(union);\n }\n if (searchConditions.isGroupSearch()) {\n sql.append(groupMatchSql).append(union);\n }\n sql.replace(sql.lastIndexOf(union), sql.length(), \"\");\n return sql.toString();\n }\n"} {"input": " public void execute(Request req) throws ServiceException {\n GetMapRequest request = (GetMapRequest) req;\n final String outputFormat = request.getFormat();\n this.delegate = getDelegate(outputFormat, wms);\n\t\tfinal MapLayerInfo[] layers = request.getLayers();\n\t\tfinal Style[] styles = (Style[]) request.getStyles().toArray(\n\t\t\t\tnew Style[] {});\n\t\tfinal Filter[] filters = (request.getFilters() != null ? (Filter[]) request.getFilters().toArray(\n\t\t\t\tnew Filter[] {}) : null); \n map = new WMSMapContext(request);\n\t\tfinal Envelope env = request.getBbox();\n\t\tif (env.isNull() || (env.getWidth() <= 0) || (env.getHeight() <= 0)) {\n\t\t\tthrow new WmsException(new StringBuffer(\n\t\t\t\t\t\"The request bounding box has zero area: \").append(env)\n\t\t\t\t\t.toString());\n\t\t}\n\t\tfinal CoordinateReferenceSystem mapcrs = request.getCrs();\n\t\tif (mapcrs != null)\n\t\t\tmap.setAreaOfInterest(env, mapcrs);\n\t\telse\n\t\t\tmap.setAreaOfInterest(env, DefaultGeographicCRS.WGS84);\n\t\tmap.setMapWidth(request.getWidth());\n\t\tmap.setMapHeight(request.getHeight());\n\t\tmap.setBgColor(request.getBgColor());\n\t\tmap.setTransparent(request.isTransparent());\n\t\tif (request.getWidth() <= 0 || request.getHeight() <= 0\n\t\t\t\t|| map.getAreaOfInterest().getLength(0) <= 0\n\t\t\t\t|| map.getAreaOfInterest().getLength(1) <= 0) {\n\t\t\tif (LOGGER.isLoggable(Level.FINE))\n\t\t\t\tLOGGER\n\t\t\t\t\t\t.fine(\"We are not going to render anything because either the are is null ar the dimensions are not positive.\");\n\t\t\treturn;\n\t\t}\n\t\tif (LOGGER.isLoggable(Level.FINE)) {\n\t\t\tLOGGER.fine(\"setting up map\");\n\t\t}\n\t\ttry { \n\t\t\tMapLayer layer;\n\t\t\tboolean cachingPossible = request.getHttpServletRequest()\n\t\t\t\t\t.getMethod().equals(\"GET\");\n\t\t\tint maxAge = Integer.MAX_VALUE;\n\t\t\tFeatureSource source;\n\t\t\tAbstractGridCoverage2DReader reader;\n\t\t\tStyle style;\n\t\t\tFilter definitionFilter, optionalFilter;\n\t\t\tQuery definitionQuery;\n\t\t\tint nma;\n\t\t\tfinal int length = layers.length;\n\t\t\tfor (int i = 0; i < length; i++) {\n\t\t\t\tstyle = styles[i];\n\t\t\t\ttry {\n\t\t\t\t\toptionalFilter = filters[i];\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\toptionalFilter = null;\n\t\t\t\t}\n\t\t\t\tif (layers[i].getType() == MapLayerInfo.TYPE_VECTOR) {\n\t\t\t\t\tif (cachingPossible) {\n\t\t\t\t\t\tif (layers[i].getFeature().isCachingEnabled()) {\n\t\t\t\t\t\t\tnma = Integer.parseInt(layers[i].getFeature()\n\t\t\t\t\t\t\t\t\t.getCacheMaxAge());\n\t\t\t\t\t\t\tif (nma < maxAge)\n\t\t\t\t\t\t\t\tmaxAge = nma;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcachingPossible = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsource = layers[i].getFeature().getFeatureSource();\n\t\t\t\t\t\tif (layers[i].getBoundingBox() instanceof ReferencedEnvelope) {\n\t\t\t\t\t\t\tfinal ReferencedEnvelope bbox = (ReferencedEnvelope) layers[i].getBoundingBox();\n\t\t\t\t\t\t\tif(CRS.equalsIgnoreMetadata(bbox.getCoordinateReferenceSystem(), mapcrs)) {\n\t\t\t\t\t\t\t\tif (!layers[i].getBoundingBox().intersects(env)) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tReferencedEnvelope prjEnv = new ReferencedEnvelope(env, mapcrs).transform(bbox.getCoordinateReferenceSystem(), true);\n\t\t\t\t\t\t\t\tif (!layers[i].getBoundingBox().intersects(prjEnv)) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (IOException exp) {\n\t\t\t\t\t\tif (LOGGER.isLoggable(Level.SEVERE)) {\n\t\t\t\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\t\t\t\"Getting feature source: \").append(\n\t\t\t\t\t\t\t\t\texp.getMessage()).toString(), exp);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new WmsException(null, new StringBuffer(\n\t\t\t\t\t\t\t\t\"Internal error : \").append(exp.getMessage())\n\t\t\t\t\t\t\t\t.toString());\n\t\t\t\t\t} catch (FactoryException exp) {\n\t\t\t\t\t\tif (LOGGER.isLoggable(Level.SEVERE)) {\n\t\t\t\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\t\t\t\"Getting feature source: \").append(\n\t\t\t\t\t\t\t\t\texp.getMessage()).toString(), exp);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new WmsException(null, new StringBuffer(\n\t\t\t\t\t\t\t\t\"Internal error : \").append(exp.getMessage())\n\t\t\t\t\t\t\t\t.toString());\n\t\t\t\t\t}\n\t\t\t\t\tlayer = new DefaultMapLayer(source, style);\n\t\t\t\t\tlayer.setTitle(layers[i].getName());\n\t\t\t\t\tdefinitionFilter = layers[i].getFeature().getDefinitionQuery();\n\t\t\t\t\tif (definitionFilter != null) {\n\t\t\t\t\t\tdefinitionQuery = new DefaultQuery(source.getSchema()\n\t\t\t\t\t\t\t\t.getTypeName(), definitionFilter);\n\t\t\t\t\t\tlayer.setQuery(definitionQuery);\n\t\t\t\t\t} else if (optionalFilter != null) {\n\t\t\t\t\t\tdefinitionQuery = new DefaultQuery(source.getSchema().getTypeName(), optionalFilter);\n\t\t\t\t\t\tlayer.setQuery(definitionQuery);\n\t\t\t\t\t}\n\t\t\t\t\tmap.addLayer(layer);\n\t\t\t\t} else if (layers[i].getType() == MapLayerInfo.TYPE_RASTER) {\n\t\t\t\t\treader = (AbstractGridCoverage2DReader) layers[i]\n\t\t\t\t\t\t\t.getCoverage().getReader();\n\t\t\t\t\tif (reader != null) {\n\t\t\t\t\t\tfinal ParameterValueGroup params = reader.getFormat().getReadParameters();\n\t\t\t\t\t\tlayer = new DefaultMapLayer(DataUtilities.wrapGcReader(reader, CoverageUtils.getParameters(params, layers[i].getCoverage().getParameters())), style); \n\t\t\t\t\t\tlayer.setTitle(layers[i].getName());\n\t\t\t\t\t\tlayer.setQuery(Query.ALL);\n\t\t\t\t\t\tmap.addLayer(layer);\n\t\t\t\t\t} else\n\t\t\t\t\t\tthrow new WmsException(\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\tnew StringBuffer(\n\t\t\t\t\t\t\t\t\t\t\"Internal error : unable to get reader for this coverage layer \")\n\t\t\t\t\t\t\t\t\t\t.append(layers[i].toString())\n\t\t\t\t\t\t\t\t\t\t.toString());\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.delegate.produceMap(map);\n\t\t\tif (cachingPossible)\n\t\t\t\tresponseHeaders.put(\"Cache-Control: max-age\", maxAge + \"s\");\n\t\t\tString contentDisposition = this.delegate.getContentDisposition();\n\t if (contentDisposition != null) {\n\t \tthis.headerContentDisposition = contentDisposition;\n\t }\n\t\t} catch (ClassCastException e) {\n\t\t\tif (LOGGER.isLoggable(Level.WARNING)) {\n\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\"Getting feature source: \").append(e.getMessage())\n\t\t\t\t\t\t.toString(), e);\n\t\t\t}\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (TransformException e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (FactoryConfigurationError e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (SchemaException e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (IllegalAttributeException e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} finally {\n\t\t\ttry {\n\t\t\t} catch (Exception e) \n\t\t\t{\n\t\t\t\tif (LOGGER.isLoggable(Level.SEVERE)) {\n\t\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\t\"Getting feature source: \").append(e.getMessage())\n\t\t\t\t\t\t\t.toString(), e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": " public void execute(Request req) throws ServiceException {\n GetMapRequest request = (GetMapRequest) req;\n final String outputFormat = request.getFormat();\n this.delegate = getDelegate(outputFormat, wms);\n\t\tfinal MapLayerInfo[] layers = request.getLayers();\n\t\tfinal Style[] styles = (Style[]) request.getStyles().toArray(\n\t\t\t\tnew Style[] {});\n\t\tfinal Filter[] filters = (request.getFilters() != null ? (Filter[]) request.getFilters().toArray(\n\t\t\t\tnew Filter[] {}) : null); \n map = new WMSMapContext(request);\n\t\tfinal Envelope env = request.getBbox();\n\t\tif (env.isNull() || (env.getWidth() <= 0) || (env.getHeight() <= 0)) {\n\t\t\tthrow new WmsException(new StringBuffer(\n\t\t\t\t\t\"The request bounding box has zero area: \").append(env)\n\t\t\t\t\t.toString());\n\t\t}\n\t\tfinal CoordinateReferenceSystem mapcrs = request.getCrs();\n\t\tif (mapcrs != null)\n\t\t\tmap.setAreaOfInterest(env, mapcrs);\n\t\telse\n\t\t\tmap.setAreaOfInterest(env, DefaultGeographicCRS.WGS84);\n\t\tmap.setMapWidth(request.getWidth());\n\t\tmap.setMapHeight(request.getHeight());\n\t\tmap.setBgColor(request.getBgColor());\n\t\tmap.setTransparent(request.isTransparent());\n\t\tif (request.getWidth() <= 0 || request.getHeight() <= 0\n\t\t\t\t|| map.getAreaOfInterest().getLength(0) <= 0\n\t\t\t\t|| map.getAreaOfInterest().getLength(1) <= 0) {\n\t\t\tif (LOGGER.isLoggable(Level.FINE))\n\t\t\t\tLOGGER\n\t\t\t\t\t\t.fine(\"We are not going to render anything because either the are is null ar the dimensions are not positive.\");\n\t\t\treturn;\n\t\t}\n\t\tif (LOGGER.isLoggable(Level.FINE)) {\n\t\t\tLOGGER.fine(\"setting up map\");\n\t\t}\n\t\ttry { \n\t\t\tMapLayer layer;\n\t\t\tboolean cachingPossible = request.getHttpServletRequest()\n\t\t\t\t\t.getMethod().equals(\"GET\");\n\t\t\tint maxAge = Integer.MAX_VALUE;\n\t\t\tFeatureSource source;\n\t\t\tAbstractGridCoverage2DReader reader;\n\t\t\tStyle style;\n\t\t\tFilter definitionFilter, optionalFilter;\n\t\t\tQuery definitionQuery;\n\t\t\tint nma;\n\t\t\tfinal int length = layers.length;\n\t\t\tfor (int i = 0; i < length; i++) {\n\t\t\t\tstyle = styles[i];\n\t\t\t\ttry {\n\t\t\t\t\toptionalFilter = filters[i];\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\toptionalFilter = null;\n\t\t\t\t}\n\t\t\t\tif (layers[i].getType() == MapLayerInfo.TYPE_VECTOR) {\n\t\t\t\t\tif (cachingPossible) {\n\t\t\t\t\t\tif (layers[i].getFeature().isCachingEnabled()) {\n\t\t\t\t\t\t\tnma = Integer.parseInt(layers[i].getFeature()\n\t\t\t\t\t\t\t\t\t.getCacheMaxAge());\n\t\t\t\t\t\t\tif (nma < maxAge)\n\t\t\t\t\t\t\t\tmaxAge = nma;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcachingPossible = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsource = layers[i].getFeature().getFeatureSource();\n\t\t\t\t\t} catch (IOException exp) {\n\t\t\t\t\t\tif (LOGGER.isLoggable(Level.SEVERE)) {\n\t\t\t\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\t\t\t\"Getting feature source: \").append(\n\t\t\t\t\t\t\t\t\texp.getMessage()).toString(), exp);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new WmsException(null, new StringBuffer(\n\t\t\t\t\t\t\t\t\"Internal error : \").append(exp.getMessage())\n\t\t\t\t\t\t\t\t.toString());\n }\n\t\t\t\t\tlayer = new DefaultMapLayer(source, style);\n\t\t\t\t\tlayer.setTitle(layers[i].getName());\n\t\t\t\t\tdefinitionFilter = layers[i].getFeature().getDefinitionQuery();\n\t\t\t\t\tif (definitionFilter != null) {\n\t\t\t\t\t\tdefinitionQuery = new DefaultQuery(source.getSchema()\n\t\t\t\t\t\t\t\t.getTypeName(), definitionFilter);\n\t\t\t\t\t\tlayer.setQuery(definitionQuery);\n\t\t\t\t\t} else if (optionalFilter != null) {\n\t\t\t\t\t\tdefinitionQuery = new DefaultQuery(source.getSchema().getTypeName(), optionalFilter);\n\t\t\t\t\t\tlayer.setQuery(definitionQuery);\n\t\t\t\t\t}\n\t\t\t\t\tmap.addLayer(layer);\n\t\t\t\t} else if (layers[i].getType() == MapLayerInfo.TYPE_RASTER) {\n\t\t\t\t\treader = (AbstractGridCoverage2DReader) layers[i]\n\t\t\t\t\t\t\t.getCoverage().getReader();\n\t\t\t\t\tif (reader != null) {\n\t\t\t\t\t\tfinal ParameterValueGroup params = reader.getFormat().getReadParameters();\n\t\t\t\t\t\tlayer = new DefaultMapLayer(DataUtilities.wrapGcReader(reader, CoverageUtils.getParameters(params, layers[i].getCoverage().getParameters())), style); \n\t\t\t\t\t\tlayer.setTitle(layers[i].getName());\n\t\t\t\t\t\tlayer.setQuery(Query.ALL);\n\t\t\t\t\t\tmap.addLayer(layer);\n\t\t\t\t\t} else\n\t\t\t\t\t\tthrow new WmsException(\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\tnew StringBuffer(\n\t\t\t\t\t\t\t\t\t\t\"Internal error : unable to get reader for this coverage layer \")\n\t\t\t\t\t\t\t\t\t\t.append(layers[i].toString())\n\t\t\t\t\t\t\t\t\t\t.toString());\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.delegate.produceMap(map);\n\t\t\tif (cachingPossible)\n\t\t\t\tresponseHeaders.put(\"Cache-Control: max-age\", maxAge + \"s\");\n\t\t\tString contentDisposition = this.delegate.getContentDisposition();\n\t if (contentDisposition != null) {\n\t \tthis.headerContentDisposition = contentDisposition;\n\t }\n\t\t} catch (ClassCastException e) {\n\t\t\tif (LOGGER.isLoggable(Level.WARNING)) {\n\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\"Getting feature source: \").append(e.getMessage())\n\t\t\t\t\t\t.toString(), e);\n\t\t\t}\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (TransformException e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (FactoryConfigurationError e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (SchemaException e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} catch (IllegalAttributeException e) {\n\t\t\tthrow new WmsException(e, new StringBuffer(\"Internal error : \")\n\t\t\t\t\t.append(e.getMessage()).toString(), \"\");\n\t\t} finally {\n\t\t\ttry {\n\t\t\t} catch (Exception e) \n\t\t\t{\n\t\t\t\tif (LOGGER.isLoggable(Level.SEVERE)) {\n\t\t\t\t\tLOGGER.log(Level.SEVERE, new StringBuffer(\n\t\t\t\t\t\t\t\"Getting feature source: \").append(e.getMessage())\n\t\t\t\t\t\t\t.toString(), e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public static FixedData[] parse( RDFReader rdr ) throws Exception\n {\n java.util.List< FixedData > work = new ArrayList< FixedData >();\n java.util.List< Short > temp = new ArrayList< Short >();\n String line;\n int address = -1;\n int value = -1;\n while ( true )\n {\n line = rdr.readLine();\n if ( ( line == null ) || ( line.length() == 0 ) )\n break;\n StringTokenizer st = new StringTokenizer( line, \",; \\t\" );\n String token = st.nextToken();\n while ( true )\n {\n if ( token.charAt( 0 ) == '=' ) \n {\n token = token.substring( 1 );\n if ( address != -1 ) \n {\n short[] b = new short[ temp.size() ];\n int i = 0;\n for ( Short val : temp )\n {\n b[ i++ ] = val.shortValue();\n }\n work.add( new FixedData( address, b ) );\n temp.clear();\n }\n address = value;\n value = -1;\n if ( token.length() != 0 )\n continue;\n }\n else\n {\n int equal = token.indexOf( '=' );\n String saved = token;\n if ( equal != -1 )\n {\n token = token.substring( 0, equal );\n }\n if ( value != -1 )\n {\n temp.add( new Short( ( short )value ) );\n }\n value = RDFReader.parseNumber( token );\n if ( equal != -1 )\n {\n token = saved.substring( equal );\n continue;\n }\n }\n if ( !st.hasMoreTokens() )\n break;\n token = st.nextToken();\n }\n }\n temp.add( new Short( ( short )value ) );\n short[] b = new short[ temp.size() ];\n int j = 0;\n for ( Short by : temp )\n {\n b[ j++ ] = by.shortValue();\n }\n work.add( new FixedData( address, b ) );\n return work.toArray( new FixedData[ work.size() ] );\n }\n", "output": " public static FixedData[] parse( RDFReader rdr ) throws Exception\n {\n java.util.List< FixedData > work = new ArrayList< FixedData >();\n java.util.List< Short > temp = new ArrayList< Short >();\n String line;\n int address = -1;\n int value = -1;\n while ( true )\n {\n line = rdr.readLine();\n if ( ( line == null ) || ( line.length() == 0 ) )\n break;\n StringTokenizer st = new StringTokenizer( line, \",; \\t\" );\n String token = st.nextToken();\n while ( true )\n {\n if ( token.charAt( 0 ) == '=' ) \n {\n token = token.substring( 1 );\n if ( address != -1 ) \n {\n short[] b = new short[ temp.size() ];\n int i = 0;\n for ( Short val : temp )\n {\n b[ i++ ] = val.shortValue();\n }\n work.add( new FixedData( address, b ) );\n temp.clear();\n }\n address = value;\n value = -1;\n if ( token.length() != 0 )\n continue;\n }\n else\n {\n int equal = token.indexOf( '=' );\n String saved = token;\n if ( equal != -1 )\n {\n token = token.substring( 0, equal );\n }\n if ( value != -1 )\n {\n temp.add( new Short( ( short )value ) );\n }\n value = RDFReader.parseNumber( token );\n if ( equal != -1 )\n {\n token = saved.substring( equal );\n continue;\n }\n }\n if ( !st.hasMoreTokens() )\n break;\n token = st.nextToken();\n }\n }\n temp.add( new Short( ( short )value ) );\n short[] b = new short[ temp.size() ];\n int j = 0;\n for ( Short by : temp )\n {\n b[ j++ ] = by.shortValue();\n }\n if ( address != -1 )\n {\n work.add( new FixedData( address, b ) );\n }\n return work.toArray( new FixedData[ work.size() ] );\n }\n"} {"input": " public Config buildArchive(OS os, Arch arch, TargetType targetType) throws MojoExecutionException, MojoFailureException {\n getLog().info(\"Building RoboVM app for: \" + os + \" (\" + arch + \")\");\n Config.Builder builder = new Config.Builder();\n File robovmSrcDir = new File(project.getBasedir(), \"src/main/robovm\");\n if (propertiesFile != null) {\n if (!propertiesFile.exists()) {\n throw new MojoExecutionException(\"Invalid 'propertiesFile' specified for RoboVM compile: \" + propertiesFile);\n }\n try {\n getLog().debug(\"Including properties file in RoboVM compiler config: \" + propertiesFile.getAbsolutePath());\n builder.addProperties(propertiesFile);\n } catch (IOException e) {\n throw new MojoExecutionException(\"Failed to add properties file to RoboVM config: \" + propertiesFile);\n }\n } else {\n File file = new File(robovmSrcDir, \"Info.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default properties file: \" + file.getAbsolutePath());\n builder.iosInfoPList(file);\n }\n }\n if (configFile != null) {\n if (!configFile.exists()) {\n throw new MojoExecutionException(\"Invalid 'configFile' specified for RoboVM compile: \" + configFile);\n }\n try {\n getLog().debug(\"Loading config file for RoboVM compiler: \" + configFile.getAbsolutePath());\n builder.read(configFile);\n } catch (Exception e) {\n throw new MojoExecutionException(\"Failed to read RoboVM config file: \" + configFile);\n }\n } else {\n File file = new File(robovmSrcDir, \"config.xml\");\n if (file.exists()) {\n getLog().debug(\"Using default config file: \" + file.getAbsolutePath());\n builder.iosInfoPList(file);\n }\n }\n File osDir = new File(installDir, os.name());\n File archiveDir = new File(new File(osDir, arch.name()), \"\");\n builder.home(new Config.Home(unpackRoboVMDist()))\n .logger(getRoboVMLogger())\n .mainClass(mainClass)\n .executableName(executableName)\n .tmpDir(archiveDir)\n .targetType(targetType)\n .skipInstall(true)\n .os(os)\n .arch(arch);\n if (forceLinkClasses != null) {\n for (String pattern : forceLinkClasses) {\n getLog().debug(\"Including class pattern for linking: \" + pattern);\n builder.addForceLinkClass(pattern);\n }\n }\n if (frameworks != null) {\n for (String framework : frameworks) {\n getLog().debug(\"Including framework: \" + framework);\n builder.addFramework(framework);\n }\n }\n if (libs != null) {\n for (String lib : libs) {\n getLog().debug(\"Including lib: \" + lib);\n builder.addLib(lib);\n }\n }\n if (iosSdkVersion != null) {\n getLog().debug(\"Using explicit iOS SDK version: \" + iosSdkVersion);\n builder.iosSdkVersion(iosSdkVersion);\n }\n if (iosSignIdentity != null) {\n getLog().debug(\"Using explicit iOS Signing identity: \" + iosSignIdentity);\n builder.iosSignIdentity(iosSignIdentity);\n }\n if (iosInfoPList != null) {\n if (!iosInfoPList.exists()) {\n throw new MojoExecutionException(\"Invalid 'iosInfoPList' specified for RoboVM compile: \" + iosInfoPList);\n }\n getLog().debug(\"Using Info.plist input file: \" + iosInfoPList.getAbsolutePath());\n builder.iosInfoPList(iosInfoPList);\n } else {\n File file = new File(robovmSrcDir, \"Info.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default Info.plist input file: \" + file.getAbsolutePath());\n builder.iosInfoPList(file);\n }\n }\n if (iosEntitlementsPList != null) {\n if (!iosEntitlementsPList.exists()) {\n throw new MojoExecutionException(\"Invalid 'iosEntitlementsPList' specified for RoboVM compile: \" + iosEntitlementsPList);\n }\n getLog().debug(\"Using Entitlements.plist input file: \" + iosEntitlementsPList.getAbsolutePath());\n builder.iosEntitlementsPList(iosEntitlementsPList);\n } else {\n File file = new File(robovmSrcDir, \"Entitlements.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default Entitlements.plist input file: \" + file.getAbsolutePath());\n builder.iosEntitlementsPList(file);\n }\n }\n if (iosResourceRulesPList != null) {\n if (!iosResourceRulesPList.exists()) {\n throw new MojoExecutionException(\"Invalid 'iosResourceRulesPList' specified for RoboVM compile: \" + iosResourceRulesPList);\n }\n getLog().debug(\"Using ResourceRules.plist input file: \" + iosResourceRulesPList.getAbsolutePath());\n builder.iosResourceRulesPList(iosResourceRulesPList);\n } else {\n File file = new File(robovmSrcDir, \"ResourceRules.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default ResourceRules.plist input file: \" + file.getAbsolutePath());\n builder.iosResourceRulesPList(file);\n }\n }\n if (resources != null) {\n for (File resource : resources) {\n if (!resource.exists()) {\n throw new MojoExecutionException(\"Invalid 'resource' directory specified for RoboVM compile: \" + resource);\n }\n getLog().debug(\"Including resource directory: \" + resource.getAbsolutePath());\n builder.addResource(resource);\n }\n } else {\n File resource = new File(robovmSrcDir, \"resources\");\n if (resource.exists()) {\n getLog().debug(\"Using default resource directory: \" + resource.getAbsolutePath());\n builder.addResource(resource);\n }\n }\n builder.clearClasspathEntries();\n if (includeJFX) {\n getLog().info(\"Including JavaFX Runtime in build\");\n File jfxJar = resolveJavaFXRuntimeArtifact();\n getLog().debug(\"JavaFX runtime JAR found at: \" + jfxJar);\n builder.addClasspathEntry(jfxJar);\n File iosNativesBaseDir = unpackJavaFXNativeIOSArtifact();\n builder.addLib(new File(iosNativesBaseDir, \"libdecora-sse-armv7.a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libglass-armv7.a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libjavafx-font-armv7.a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libjavafx-iio-armv7.a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libprism-common-armv7.a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libprism-es2-armv7.a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libprism-sw-armv7.a\").getAbsolutePath());\n builder.addForceLinkClass(\"com.sun.javafx.tk.quantum.QuantumToolkit\");\n builder.addForceLinkClass(\"com.sun.prism.es2.ES2Pipeline\");\n builder.addForceLinkClass(\"com.sun.prism.es2.IOSGLFactory\");\n builder.addForceLinkClass(\"com.sun.glass.ui.ios.**.*\");\n builder.addForceLinkClass(\"javafx.scene.CssStyleHelper\");\n builder.addForceLinkClass(\"com.sun.prism.shader.**.*\");\n builder.addForceLinkClass(\"com.sun.scenario.effect.impl.es2.ES2ShaderSource\");\n builder.addForceLinkClass(\"sun.util.logging.PlatformLogger\");\n builder.addFramework(\"UIKit\");\n builder.addFramework(\"OpenGLES\");\n builder.addFramework(\"QuartzCore\");\n builder.addFramework(\"CoreGraphics\");\n builder.addFramework(\"CoreText\");\n builder.addFramework(\"ImageIO\");\n builder.addFramework(\"MobileCoreServices\");\n }\n try {\n for (Object object : project.getRuntimeClasspathElements()) {\n String path = (String) object;\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"Including classpath element for RoboVM app: \" + path);\n }\n builder.addClasspathEntry(new File(path));\n }\n } catch (DependencyResolutionRequiredException e) {\n throw new MojoExecutionException(\"Error resolving application classpath for RoboVM build\", e);\n }\n try {\n Config config = builder.build();\n AppCompiler compiler = new AppCompiler(config);\n compiler.compile();\n return config;\n } catch (IOException e) {\n throw new MojoExecutionException(\"Error building RoboVM executable for app\", e);\n }\n }\n", "output": " public Config buildArchive(OS os, Arch arch, TargetType targetType) throws MojoExecutionException, MojoFailureException {\n getLog().info(\"Building RoboVM app for: \" + os + \" (\" + arch + \")\");\n Config.Builder builder = new Config.Builder();\n File robovmSrcDir = new File(project.getBasedir(), \"src/main/robovm\");\n if (propertiesFile != null) {\n if (!propertiesFile.exists()) {\n throw new MojoExecutionException(\"Invalid 'propertiesFile' specified for RoboVM compile: \" + propertiesFile);\n }\n try {\n getLog().debug(\"Including properties file in RoboVM compiler config: \" + propertiesFile.getAbsolutePath());\n builder.addProperties(propertiesFile);\n } catch (IOException e) {\n throw new MojoExecutionException(\"Failed to add properties file to RoboVM config: \" + propertiesFile);\n }\n } else {\n File file = new File(robovmSrcDir, \"Info.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default properties file: \" + file.getAbsolutePath());\n builder.iosInfoPList(file);\n }\n }\n if (configFile != null) {\n if (!configFile.exists()) {\n throw new MojoExecutionException(\"Invalid 'configFile' specified for RoboVM compile: \" + configFile);\n }\n try {\n getLog().debug(\"Loading config file for RoboVM compiler: \" + configFile.getAbsolutePath());\n builder.read(configFile);\n } catch (Exception e) {\n throw new MojoExecutionException(\"Failed to read RoboVM config file: \" + configFile);\n }\n } else {\n File file = new File(robovmSrcDir, \"config.xml\");\n if (file.exists()) {\n getLog().debug(\"Using default config file: \" + file.getAbsolutePath());\n builder.iosInfoPList(file);\n }\n }\n File osDir = new File(installDir, os.name());\n File archiveDir = new File(new File(osDir, arch.name()), \"\");\n builder.home(new Config.Home(unpackRoboVMDist()))\n .logger(getRoboVMLogger())\n .mainClass(mainClass)\n .executableName(executableName)\n .tmpDir(archiveDir)\n .targetType(targetType)\n .skipInstall(true)\n .os(os)\n .arch(arch);\n if (forceLinkClasses != null) {\n for (String pattern : forceLinkClasses) {\n getLog().debug(\"Including class pattern for linking: \" + pattern);\n builder.addForceLinkClass(pattern);\n }\n }\n if (frameworks != null) {\n for (String framework : frameworks) {\n getLog().debug(\"Including framework: \" + framework);\n builder.addFramework(framework);\n }\n }\n if (libs != null) {\n for (String lib : libs) {\n getLog().debug(\"Including lib: \" + lib);\n builder.addLib(lib);\n }\n }\n if (iosSdkVersion != null) {\n getLog().debug(\"Using explicit iOS SDK version: \" + iosSdkVersion);\n builder.iosSdkVersion(iosSdkVersion);\n }\n if (iosSignIdentity != null) {\n getLog().debug(\"Using explicit iOS Signing identity: \" + iosSignIdentity);\n builder.iosSignIdentity(iosSignIdentity);\n }\n if (iosInfoPList != null) {\n if (!iosInfoPList.exists()) {\n throw new MojoExecutionException(\"Invalid 'iosInfoPList' specified for RoboVM compile: \" + iosInfoPList);\n }\n getLog().debug(\"Using Info.plist input file: \" + iosInfoPList.getAbsolutePath());\n builder.iosInfoPList(iosInfoPList);\n } else {\n File file = new File(robovmSrcDir, \"Info.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default Info.plist input file: \" + file.getAbsolutePath());\n builder.iosInfoPList(file);\n }\n }\n if (iosEntitlementsPList != null) {\n if (!iosEntitlementsPList.exists()) {\n throw new MojoExecutionException(\"Invalid 'iosEntitlementsPList' specified for RoboVM compile: \" + iosEntitlementsPList);\n }\n getLog().debug(\"Using Entitlements.plist input file: \" + iosEntitlementsPList.getAbsolutePath());\n builder.iosEntitlementsPList(iosEntitlementsPList);\n } else {\n File file = new File(robovmSrcDir, \"Entitlements.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default Entitlements.plist input file: \" + file.getAbsolutePath());\n builder.iosEntitlementsPList(file);\n }\n }\n if (iosResourceRulesPList != null) {\n if (!iosResourceRulesPList.exists()) {\n throw new MojoExecutionException(\"Invalid 'iosResourceRulesPList' specified for RoboVM compile: \" + iosResourceRulesPList);\n }\n getLog().debug(\"Using ResourceRules.plist input file: \" + iosResourceRulesPList.getAbsolutePath());\n builder.iosResourceRulesPList(iosResourceRulesPList);\n } else {\n File file = new File(robovmSrcDir, \"ResourceRules.plist\");\n if (file.exists()) {\n getLog().debug(\"Using default ResourceRules.plist input file: \" + file.getAbsolutePath());\n builder.iosResourceRulesPList(file);\n }\n }\n if (resources != null) {\n for (File resource : resources) {\n if (!resource.exists()) {\n throw new MojoExecutionException(\"Invalid 'resource' directory specified for RoboVM compile: \" + resource);\n }\n getLog().debug(\"Including resource directory: \" + resource.getAbsolutePath());\n builder.addResource(resource);\n }\n } else {\n File resource = new File(robovmSrcDir, \"resources\");\n if (resource.exists()) {\n getLog().debug(\"Using default resource directory: \" + resource.getAbsolutePath());\n builder.addResource(resource);\n }\n }\n builder.clearClasspathEntries();\n if (includeJFX) {\n getLog().info(\"Including JavaFX Runtime in build\");\n File jfxJar = resolveJavaFXRuntimeArtifact();\n getLog().debug(\"JavaFX runtime JAR found at: \" + jfxJar);\n builder.addClasspathEntry(jfxJar);\n File iosNativesBaseDir = unpackJavaFXNativeIOSArtifact();\n builder.addLib(new File(iosNativesBaseDir, \"libglass-\" + arch.getClangName() + \".a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libjavafx-font-\" + arch.getClangName() + \".a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libjavafx-iio-\" + arch.getClangName() + \".a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libprism-common-\" + arch.getClangName() + \".a\").getAbsolutePath());\n builder.addLib(new File(iosNativesBaseDir, \"libprism-es2-\" + arch.getClangName() + \".a\").getAbsolutePath());\n builder.addForceLinkClass(\"com.sun.javafx.tk.quantum.QuantumToolkit\");\n builder.addForceLinkClass(\"com.sun.prism.es2.ES2Pipeline\");\n builder.addForceLinkClass(\"com.sun.prism.es2.IOSGLFactory\");\n builder.addForceLinkClass(\"com.sun.glass.ui.ios.**.*\");\n builder.addForceLinkClass(\"javafx.scene.CssStyleHelper\");\n builder.addForceLinkClass(\"com.sun.prism.shader.**.*\");\n builder.addForceLinkClass(\"com.sun.scenario.effect.impl.es2.ES2ShaderSource\");\n builder.addForceLinkClass(\"com.sun.javafx.font.coretext.CTFactory\");\n builder.addForceLinkClass(\"sun.util.logging.PlatformLogger\");\n builder.addFramework(\"UIKit\");\n builder.addFramework(\"OpenGLES\");\n builder.addFramework(\"QuartzCore\");\n builder.addFramework(\"CoreGraphics\");\n builder.addFramework(\"CoreText\");\n builder.addFramework(\"ImageIO\");\n builder.addFramework(\"MobileCoreServices\");\n }\n try {\n for (Object object : project.getRuntimeClasspathElements()) {\n String path = (String) object;\n if (getLog().isDebugEnabled()) {\n getLog().debug(\"Including classpath element for RoboVM app: \" + path);\n }\n builder.addClasspathEntry(new File(path));\n }\n } catch (DependencyResolutionRequiredException e) {\n throw new MojoExecutionException(\"Error resolving application classpath for RoboVM build\", e);\n }\n try {\n Config config = builder.build();\n AppCompiler compiler = new AppCompiler(config);\n compiler.compile();\n return config;\n } catch (IOException e) {\n throw new MojoExecutionException(\"Error building RoboVM executable for app\", e);\n }\n }\n"} {"input": "\tpublic void check(ArrayList remarks, StepMeta stepMeta, Row prev, String input[], String output[], Row info)\n\t{\n\t\tCheckResult cr;\n\t\tif (useDatabase)\n\t\t{\n\t\t\tDatabase db = new Database(database);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tdb.connect();\n\t\t\t\tValue last = db.checkSequence(sequenceName);\n\t\t\t\tif (last!=null)\n\t\t\t\t{\n\t\t\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_OK, \"Sequence is at value \"+last, stepMeta);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, \"Last value of sequence couldn't be found\", stepMeta);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(KettleException e)\n\t\t\t{\n\t\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, \"Unable to connect to database to verify sequence because of an error: \"+Const.CR+e.getMessage(), stepMeta);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tdb.disconnect();\n\t\t\t}\n\t\t\tremarks.add(cr);\n\t\t}\n\t\tif (input.length>0)\n\t\t{\n\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_OK, \"Step is receiving info from other steps.\", stepMeta);\n\t\t\tremarks.add(cr);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, \"No input received from other steps!\", stepMeta);\n\t\t\tremarks.add(cr);\n\t\t}\n\t}\n", "output": "\tpublic void check(ArrayList remarks, StepMeta stepMeta, Row prev, String input[], String output[], Row info)\n\t{\n\t\tCheckResult cr;\n\t\tif (useDatabase)\n\t\t{\n\t\t\tDatabase db = new Database(database);\n\t\t\ttry\n\t\t\t{\n\t\t\t\tdb.connect();\n\t\t\t\tif (db.checkSequenceExists(sequenceName))\n\t\t\t\t{\n\t\t\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_OK, \"Sequence exits.\", stepMeta);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, \"The sequence [\"+sequenceName+\"] couldn't be found\", stepMeta);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch(KettleException e)\n\t\t\t{\n\t\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, \"Unable to connect to database to verify sequence because of an error: \"+Const.CR+e.getMessage(), stepMeta);\n\t\t\t}\n\t\t\tfinally\n\t\t\t{\n\t\t\t\tdb.disconnect();\n\t\t\t}\n\t\t\tremarks.add(cr);\n\t\t}\n\t\tif (input.length>0)\n\t\t{\n\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_OK, \"Step is receiving info from other steps.\", stepMeta);\n\t\t\tremarks.add(cr);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcr = new CheckResult(CheckResult.TYPE_RESULT_ERROR, \"No input received from other steps!\", stepMeta);\n\t\t\tremarks.add(cr);\n\t\t}\n\t}\n"} {"input": "\tpublic String onSubmit(HttpServletRequest request, AppointmentBlock appointmentBlock, BindingResult result,\n\t @RequestParam(value = \"timeSlotLength\", required = false) String timeSlotLength,\n\t @RequestParam(value = \"emptyTypes\", required = false) String emptyTypes) throws Exception {\n\t\tHttpSession httpSession = request.getSession();\n\t\tif (Context.isAuthenticated()) {\n\t\t\tif (emptyTypes.equals(\"yes\")) {\n\t\t\t\tappointmentBlock.setTypes(null);\n\t\t\t}\n\t\t\tAppointmentService appointmentService = Context.getService(AppointmentService.class);\n\t\t\tif (request.getParameter(\"save\") != null) {\n\t\t\t\tnew AppointmentBlockValidator().validate(appointmentBlock, result);\n\t\t\t\tif (result.hasErrors()) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\tif (appointmentBlock.getStartDate().before(Calendar.getInstance().getTime())) {\n\t\t\t\t\t\tresult.rejectValue(\"startDate\", \"appointment.AppointmentBlock.error.dateCannotBeInThePast\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tif (!appointmentBlock.getStartDate().before(appointmentBlock.getEndDate())) {\n\t\t\t\t\t\tresult.rejectValue(\"endDate\", \"appointment.AppointmentBlock.error.InvalidDateInterval\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tif (timeSlotLength.isEmpty() || Integer.parseInt(timeSlotLength) <= 0) {\n\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t \"appointment.AppointmentBlock.error.selectTimeSlot\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tlong appointmentBlocklengthInMinutes = (appointmentBlock.getEndDate().getTime() - appointmentBlock\n\t\t\t\t\t .getStartDate().getTime()) / 60000;\n\t\t\t\t\tif (!timeSlotLength.isEmpty() && (Integer.parseInt(timeSlotLength) > appointmentBlocklengthInMinutes)) {\n\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t \"appointment.AppointmentBlock.error.maximalTimeSlot\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tList<TimeSlot> currentTimeSlots = null;\n\t\t\t\t\tif (appointmentBlock.getCreator() != null) {\n\t\t\t\t\t\tboolean canBeUpdated = true;\n\t\t\t\t\t\tcurrentTimeSlots = appointmentService.getTimeSlotsInAppointmentBlock(appointmentBlock);\n\t\t\t\t\t\tfor (TimeSlot timeSlot : currentTimeSlots) {\n\t\t\t\t\t\t\tif (appointmentService.getAppointmentsInTimeSlot(timeSlot).size() > 0) {\n\t\t\t\t\t\t\t\tcanBeUpdated = false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!canBeUpdated) {\n\t\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t\t \"appointment.AppointmentBlock.error.appointmentsExist\");\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (appointmentService.getOverlappingAppointmentBlocks(appointmentBlock).size() > 0) { \n\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t \"appointment.AppointmentBlock.error.appointmentBlockOverlap\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tappointmentService.saveAppointmentBlock(appointmentBlock);\n\t\t\t\t\tInteger slotLength = Integer.parseInt(timeSlotLength);\n\t\t\t\t\tint howManyTimeSlotsToCreate = (int) (appointmentBlocklengthInMinutes / slotLength);\n\t\t\t\t\tif (currentTimeSlots == null) {\n\t\t\t\t\t\tcurrentTimeSlots = appointmentService.getTimeSlotsInAppointmentBlock(appointmentBlock);\n\t\t\t\t\t}\n\t\t\t\t\tif (currentTimeSlots.size() != howManyTimeSlotsToCreate) { \n\t\t\t\t\t\tfor (TimeSlot timeSlot : currentTimeSlots) {\n\t\t\t\t\t\t\tappointmentService.purgeTimeSlot(timeSlot);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tDate startDate = appointmentBlock.getStartDate();\n\t\t\t\t\t\tDate endDate = null;\n\t\t\t\t\t\tCalendar cal;\n\t\t\t\t\t\tfor (int i = 0; i < howManyTimeSlotsToCreate; i++) {\n\t\t\t\t\t\t\tcal = Context.getDateTimeFormat().getCalendar();\n\t\t\t\t\t\t\tcal.setTime(startDate);\n\t\t\t\t\t\t\tcal.add(Calendar.MINUTE, slotLength); \n\t\t\t\t\t\t\tendDate = cal.getTime();\n\t\t\t\t\t\t\tTimeSlot timeSlot = new TimeSlot(appointmentBlock, startDate, endDate);\n\t\t\t\t\t\t\tstartDate = endDate;\n\t\t\t\t\t\t\tappointmentService.saveTimeSlot(timeSlot);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (startDate.before(appointmentBlock.getEndDate())) {\n\t\t\t\t\t\t\tTimeSlot timeSlot = new TimeSlot(appointmentBlock, startDate, appointmentBlock.getEndDate());\n\t\t\t\t\t\t\tappointmentService.saveTimeSlot(timeSlot);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, \"appointment.AppointmentBlock.saved\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (request.getParameter(\"unvoid\") != null) {\n\t\t\t\tappointmentService.unvoidAppointmentBlock(appointmentBlock);\n\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, \"appointment.AppointmentBlock.unvoidedSuccessfully\");\n\t\t\t}\n\t\t}\n\t\treturn \"redirect:appointmentBlockList.list\";\n\t}\n", "output": "\tpublic String onSubmit(HttpServletRequest request, AppointmentBlock appointmentBlock, BindingResult result,\n\t @RequestParam(value = \"timeSlotLength\", required = false) String timeSlotLength,\n\t @RequestParam(value = \"emptyTypes\", required = false) String emptyTypes) throws Exception {\n\t\tHttpSession httpSession = request.getSession();\n\t\tif (Context.isAuthenticated()) {\n\t\t\tif (emptyTypes.equals(\"yes\")) {\n\t\t\t\tappointmentBlock.setTypes(null);\n\t\t\t}\n\t\t\tAppointmentService appointmentService = Context.getService(AppointmentService.class);\n\t\t\tif (request.getParameter(\"save\") != null) {\n\t\t\t\tnew AppointmentBlockValidator().validate(appointmentBlock, result);\n\t\t\t\tif (result.hasErrors()) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else {\n\t\t\t\t\tif (appointmentBlock.getStartDate().before(Calendar.getInstance().getTime())) {\n\t\t\t\t\t\tresult.rejectValue(\"startDate\", \"appointment.AppointmentBlock.error.dateCannotBeInThePast\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tif (!appointmentBlock.getStartDate().before(appointmentBlock.getEndDate())) {\n\t\t\t\t\t\tresult.rejectValue(\"endDate\", \"appointment.AppointmentBlock.error.InvalidDateInterval\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tif (timeSlotLength.isEmpty() || Integer.parseInt(timeSlotLength) <= 0) {\n\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t \"appointment.AppointmentBlock.error.selectTimeSlot\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tlong appointmentBlocklengthInMinutes = (appointmentBlock.getEndDate().getTime() - appointmentBlock\n\t\t\t\t\t .getStartDate().getTime()) / 60000;\n\t\t\t\t\tif (!timeSlotLength.isEmpty() && (Integer.parseInt(timeSlotLength) > appointmentBlocklengthInMinutes)) {\n\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t \"appointment.AppointmentBlock.error.maximalTimeSlot\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tList<TimeSlot> currentTimeSlots = null;\n\t\t\t\t\tif (appointmentBlock.getCreator() != null) {\n\t\t\t\t\t\tboolean canBeUpdated = true;\n\t\t\t\t\t\tcurrentTimeSlots = appointmentService.getTimeSlotsInAppointmentBlock(appointmentBlock);\n\t\t\t\t\t\tfor (TimeSlot timeSlot : currentTimeSlots) {\n\t\t\t\t\t\t\tif (appointmentService.getAppointmentsInTimeSlot(timeSlot).size() > 0) {\n\t\t\t\t\t\t\t\tcanBeUpdated = false;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!canBeUpdated) {\n\t\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t\t \"appointment.AppointmentBlock.error.appointmentsExist\");\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (appointmentService.getOverlappingAppointmentBlocks(appointmentBlock).size() > 0) { \n\t\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR,\n\t\t\t\t\t\t \"appointment.AppointmentBlock.error.appointmentBlockOverlap\");\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tappointmentService.saveAppointmentBlock(appointmentBlock);\n\t\t\t\t\tInteger slotLength = Integer.parseInt(timeSlotLength);\n\t\t\t\t\tint howManyTimeSlotsToCreate = (int) (appointmentBlocklengthInMinutes / slotLength);\n\t\t\t\t\tif (currentTimeSlots == null) {\n\t\t\t\t\t\tcurrentTimeSlots = appointmentService.getTimeSlotsInAppointmentBlock(appointmentBlock);\n\t\t\t\t\t}\n\t\t\t\t\tif (currentTimeSlots.size() != howManyTimeSlotsToCreate) { \n\t\t\t\t\t\tfor (TimeSlot timeSlot : currentTimeSlots) {\n\t\t\t\t\t\t\tappointmentService.purgeTimeSlot(timeSlot);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tDate startDate = appointmentBlock.getStartDate();\n\t\t\t\t\t\tDate endDate = null;\n\t\t\t\t\t\tCalendar cal;\n\t\t\t\t\t\tfor (int i = 0; i < howManyTimeSlotsToCreate - 1; i++) {\n\t\t\t\t\t\t\tcal = Context.getDateTimeFormat().getCalendar();\n\t\t\t\t\t\t\tcal.setTime(startDate);\n\t\t\t\t\t\t\tcal.add(Calendar.MINUTE, slotLength); \n\t\t\t\t\t\t\tendDate = cal.getTime();\n\t\t\t\t\t\t\tTimeSlot timeSlot = new TimeSlot(appointmentBlock, startDate, endDate);\n\t\t\t\t\t\t\tstartDate = endDate;\n\t\t\t\t\t\t\tappointmentService.saveTimeSlot(timeSlot);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTimeSlot timeSlot = new TimeSlot(appointmentBlock, startDate, appointmentBlock.getEndDate());\n\t\t\t\t\t\tappointmentService.saveTimeSlot(timeSlot);\n\t\t\t\t\t}\n\t\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, \"appointment.AppointmentBlock.saved\");\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (request.getParameter(\"unvoid\") != null) {\n\t\t\t\tappointmentService.unvoidAppointmentBlock(appointmentBlock);\n\t\t\t\thttpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, \"appointment.AppointmentBlock.unvoidedSuccessfully\");\n\t\t\t}\n\t\t}\n\t\treturn \"redirect:appointmentBlockList.list\";\n\t}\n"} {"input": " protected Key createKeyFromXml(Resources res, Row parent, int x, int y, \n XmlResourceParser parser) {\n Key key = super.createKeyFromXml(res, parent, x, y, parser);\n if (key.codes[0] == 10) \n {\n mEnterKey = key;\n }\n else if ((key.codes[0] == Keyboard.KEYCODE_MODE_CHANGE) ||\n \t\t (key.codes[0] == AnyKeyboard.KEYCODE_LANG_CHANGE))\n {\n \tif (SoftKeyboard.mChangeKeysMode.equals(\"2\"))\n \t{\n \t\tkey.label = \"\";\n \t\tkey.height = 0;\n \t\tkey.width = 0;\n \t}\n }\n else\n {\n \tif (isAlphabetKey(key))\n \t{\n \t\tkey.label = \"\"+((char)key.codes[0]); \n \t}\n }\n Log.v(\"AnySoftKeyboard\", \"Key '\"+key.codes[0]+\"' will have - width: \"+key.width+\", height:\"+key.height+\", text: '\"+key.label+\"'.\");\n return key;\n }\n", "output": " protected Key createKeyFromXml(Resources res, Row parent, int x, int y, \n XmlResourceParser parser) {\n Key key = super.createKeyFromXml(res, parent, x, y, parser);\n if (key.codes[0] == 10) \n {\n mEnterKey = key;\n }\n else if ((key.codes[0] == Keyboard.KEYCODE_MODE_CHANGE) ||\n \t\t (key.codes[0] == AnyKeyboard.KEYCODE_LANG_CHANGE))\n {\n \tif (SoftKeyboard.mChangeKeysMode.equals(\"2\"))\n \t{\n \t\tkey.label = null;\n \t\tkey.height = 0;\n \t\tkey.width = 0;\n \t}\n }\n else\n {\n \tif (isAlphabetKey(key))\n \t{\n \t\tkey.label = \"\"+((char)key.codes[0]); \n \t}\n }\n Log.v(\"AnySoftKeyboard\", \"Key '\"+key.codes[0]+\"' will have - width: \"+key.width+\", height:\"+key.height+\", text: '\"+key.label+\"'.\");\n return key;\n }\n"} {"input": "\tpublic void testIs() throws Exception {\n\t\tDateFilter filter;\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014, 11, 03), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014, 11, 04), null, attributeDefinition);\n\t\tdoMatch(filter, false);\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014,11,03,0,0,0), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tcreateFixture(new GregorianCalendar(2014, 11, 03, 13, 14, 15));\t\t\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014,11,03), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014,11,03,20,0,0), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tGregorianCalendar fixtureDate = new GregorianCalendar(2014, 11, 3, 23, 0, 0);\n\t\tfixtureDate.setTimeZone(TimeZone.getTimeZone(\"GMT\"));\n\t\tGregorianCalendar filterDate = new GregorianCalendar(TimeZone.getTimeZone(\"GMT-9\"));\n\t\tfilterDate.set(2014, 11, 4, 8, 0, 0);\n\t\tSystem.out.println((filterDate.getTimeInMillis() - fixtureDate.getTimeInMillis()) / 1000 / 60 / 60);\n\t\tcreateFixture(fixtureDate);\t\t\n\t\tfilter = new DateFilter(IFilter.Operator.IS, filterDate, null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t}\n", "output": "\tpublic void testIs() throws Exception {\n\t\tDateFilter filter;\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014, 11, 03), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014, 11, 04), null, attributeDefinition);\n\t\tdoMatch(filter, false);\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014,11,03,0,0,0), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tcreateFixture(new GregorianCalendar(2014, 11, 03, 13, 14, 15));\t\t\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014,11,03), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tfilter = new DateFilter(IFilter.Operator.IS, new GregorianCalendar(2014,11,03,20,0,0), null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t\tGregorianCalendar fixtureDate = new GregorianCalendar(2014, 11, 3, 23, 0, 0);\n\t\tfixtureDate.setTimeZone(TimeZone.getTimeZone(\"GMT\"));\n\t\tGregorianCalendar filterDate = new GregorianCalendar(TimeZone.getTimeZone(\"GMT+9\"));\n\t\tfilterDate.set(2014, 11, 4, 8, 0, 0);\n\t\tSystem.out.println((filterDate.getTimeInMillis() - fixtureDate.getTimeInMillis()) / 1000 / 60 / 60);\n\t\tcreateFixture(fixtureDate);\t\t\n\t\tfilter = new DateFilter(IFilter.Operator.IS, filterDate, null, attributeDefinition);\n\t\tdoMatch(filter, true);\n\t}\n"} {"input": " public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\n id = uidl.getId();\n boolean firstPaint = connection == null;\n connection = client;\n String newTheme = uidl.getStringAttribute(\"theme\");\n if (theme != null && !newTheme.equals(theme)) {\n reloadHostPage();\n } else {\n theme = newTheme;\n }\n if (uidl.hasAttribute(\"style\")) {\n addStyleName(uidl.getStringAttribute(\"style\"));\n }\n if (uidl.hasAttribute(\"name\")) {\n client.setWindowName(uidl.getStringAttribute(\"name\"));\n }\n com.google.gwt.user.client.Window.setTitle(uidl\n .getStringAttribute(\"caption\"));\n int childIndex = 0;\n boolean isClosed = false; \n while (childIndex < uidl.getChildCount()\n && \"open\".equals(uidl.getChildUIDL(childIndex).getTag())) {\n final UIDL open = uidl.getChildUIDL(childIndex);\n final String url = open.getStringAttribute(\"src\");\n final String target = open.getStringAttribute(\"name\");\n if (target == null) {\n isClosed = true;\n onWindowClosed();\n goTo(url);\n } else {\n Window.open(url, target != null ? target : null, \"\");\n }\n childIndex++;\n }\n if (isClosed) {\n return;\n }\n UIDL childUidl = uidl.getChildUIDL(childIndex);\n final Paintable lo = client.getPaintable(childUidl);\n if (layout != null) {\n if (layout != lo) {\n client.unregisterPaintable(layout);\n setWidget((Widget) lo);\n layout = lo;\n }\n } else {\n setWidget((Widget) lo);\n layout = lo;\n }\n layout.updateFromUIDL(childUidl, client);\n final HashSet removedSubWindows = new HashSet(subWindows);\n while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {\n if (\"window\".equals(childUidl.getTag())) {\n final Paintable w = client.getPaintable(childUidl);\n if (subWindows.contains(w)) {\n removedSubWindows.remove(w);\n } else {\n subWindows.add(w);\n }\n w.updateFromUIDL(childUidl, client);\n } else if (\"actions\".equals(childUidl.getTag())) {\n if (actionHandler == null) {\n actionHandler = new ShortcutActionHandler(id, client);\n }\n actionHandler.updateActionMap(childUidl);\n } else if (childUidl.getTag().equals(\"notifications\")) {\n for (final Iterator it = childUidl.getChildIterator(); it\n .hasNext();) {\n final UIDL notification = (UIDL) it.next();\n String html = \"\";\n if (notification.hasAttribute(\"icon\")) {\n final String parsedUri = client\n .translateToolkitUri(notification\n .getStringAttribute(\"icon\"));\n html += \"<IMG src=\\\"\" + parsedUri + \"\\\" />\";\n }\n if (notification.hasAttribute(\"caption\")) {\n html += \"<H1>\"\n + notification.getStringAttribute(\"caption\")\n + \"</H1>\";\n }\n if (notification.hasAttribute(\"message\")) {\n html += \"<p>\"\n + notification.getStringAttribute(\"message\")\n + \"</p>\";\n }\n final String style = notification.hasAttribute(\"style\") ? notification\n .getStringAttribute(\"style\")\n : null;\n final int position = notification\n .getIntAttribute(\"position\");\n final int delay = notification.getIntAttribute(\"delay\");\n new INotification(delay).show(html, position, style);\n }\n }\n }\n for (final Iterator rem = removedSubWindows.iterator(); rem.hasNext();) {\n final IWindow w = (IWindow) rem.next();\n client.unregisterPaintable(w);\n subWindows.remove(w);\n w.hide();\n }\n if (uidl.hasAttribute(\"focused\")) {\n final String focusPid = uidl.getStringAttribute(\"focused\");\n DeferredCommand.addCommand(new Command() {\n public void execute() {\n final Paintable toBeFocused = connection\n .getPaintable(focusPid);\n if (toBeFocused instanceof HasFocus) {\n final HasFocus toBeFocusedWidget = (HasFocus) toBeFocused;\n toBeFocusedWidget.setFocus(true);\n } else if (toBeFocused instanceof Focusable) {\n ((Focusable) toBeFocused).focus();\n } else {\n ApplicationConnection.getConsole().log(\n \"Could not focus component\");\n }\n }\n });\n }\n if (firstPaint) {\n Window.addWindowCloseListener(this);\n Window.addWindowResizeListener(this);\n }\n onWindowResized(Window.getClientWidth(), Window.getClientHeight());\n }\n", "output": " public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\n id = uidl.getId();\n boolean firstPaint = connection == null;\n connection = client;\n String newTheme = uidl.getStringAttribute(\"theme\");\n if (theme != null && !newTheme.equals(theme)) {\n reloadHostPage();\n } else {\n theme = newTheme;\n }\n if (uidl.hasAttribute(\"style\")) {\n addStyleName(uidl.getStringAttribute(\"style\"));\n }\n if (uidl.hasAttribute(\"name\")) {\n client.setWindowName(uidl.getStringAttribute(\"name\"));\n }\n com.google.gwt.user.client.Window.setTitle(uidl\n .getStringAttribute(\"caption\"));\n int childIndex = 0;\n boolean isClosed = false; \n while (childIndex < uidl.getChildCount()\n && \"open\".equals(uidl.getChildUIDL(childIndex).getTag())) {\n final UIDL open = uidl.getChildUIDL(childIndex);\n final String url = open.getStringAttribute(\"src\");\n final String target = open.getStringAttribute(\"name\");\n if (target == null) {\n isClosed = true;\n onWindowClosed();\n goTo(url);\n } else {\n Window.open(url, target != null ? target : null, \"\");\n }\n childIndex++;\n }\n if (isClosed) {\n return;\n }\n UIDL childUidl = uidl.getChildUIDL(childIndex);\n final Paintable lo = client.getPaintable(childUidl);\n if (layout != null) {\n if (layout != lo) {\n client.unregisterPaintable(layout);\n setWidget((Widget) lo);\n layout = lo;\n }\n } else {\n setWidget((Widget) lo);\n layout = lo;\n }\n layout.updateFromUIDL(childUidl, client);\n final HashSet removedSubWindows = new HashSet(subWindows);\n while ((childUidl = uidl.getChildUIDL(childIndex++)) != null) {\n if (\"window\".equals(childUidl.getTag())) {\n final Paintable w = client.getPaintable(childUidl);\n if (subWindows.contains(w)) {\n removedSubWindows.remove(w);\n } else {\n subWindows.add(w);\n }\n w.updateFromUIDL(childUidl, client);\n } else if (\"actions\".equals(childUidl.getTag())) {\n if (actionHandler == null) {\n actionHandler = new ShortcutActionHandler(id, client);\n }\n actionHandler.updateActionMap(childUidl);\n } else if (childUidl.getTag().equals(\"notifications\")) {\n for (final Iterator it = childUidl.getChildIterator(); it\n .hasNext();) {\n final UIDL notification = (UIDL) it.next();\n String html = \"\";\n if (notification.hasAttribute(\"icon\")) {\n final String parsedUri = client\n .translateToolkitUri(notification\n .getStringAttribute(\"icon\"));\n html += \"<IMG src=\\\"\" + parsedUri + \"\\\" />\";\n }\n if (notification.hasAttribute(\"caption\")) {\n html += \"<H1>\"\n + notification.getStringAttribute(\"caption\")\n + \"</H1>\";\n }\n if (notification.hasAttribute(\"message\")) {\n html += \"<p>\"\n + notification.getStringAttribute(\"message\")\n + \"</p>\";\n }\n final String style = notification.hasAttribute(\"style\") ? notification\n .getStringAttribute(\"style\")\n : null;\n final int position = notification\n .getIntAttribute(\"position\");\n final int delay = notification.getIntAttribute(\"delay\");\n new INotification(delay).show(html, position, style);\n }\n }\n }\n for (final Iterator rem = removedSubWindows.iterator(); rem.hasNext();) {\n final IWindow w = (IWindow) rem.next();\n client.unregisterPaintable(w);\n subWindows.remove(w);\n w.hide();\n }\n if (uidl.hasAttribute(\"focused\")) {\n final String focusPid = uidl.getStringAttribute(\"focused\");\n DeferredCommand.addCommand(new Command() {\n public void execute() {\n final Paintable toBeFocused = connection\n .getPaintable(focusPid);\n if (toBeFocused instanceof HasFocus) {\n final HasFocus toBeFocusedWidget = (HasFocus) toBeFocused;\n toBeFocusedWidget.setFocus(true);\n } else if (toBeFocused instanceof Focusable) {\n ((Focusable) toBeFocused).focus();\n } else {\n ApplicationConnection.getConsole().log(\n \"Could not focus component\");\n }\n }\n });\n }\n if (firstPaint) {\n Window.addWindowCloseListener(this);\n Window.addWindowResizeListener(this);\n }\n onWindowResized(Window.getClientWidth(), Window.getClientHeight());\n if (BrowserInfo.get().isSafari()) {\n Util.runWebkitOverflowAutoFix(getElement());\n }\n }\n"} {"input": "\tpublic void setGLState(GL2 gl, int light) {\n\t\tif (enabled) {\n\t\t\tgl.glEnable(GL2.GL_LIGHT0 + light);\n\t\t}\n\t\telse\n\t\t\tgl.glDisable(GL2.GL_LIGHT0 + light);\n\t\tgl.glLightfv(light, GL2.GL_AMBIENT,\n\t\t\t\tambientColor.getComponents(null), 0);\n\t\tgl.glLightfv(light, GL2.GL_DIFFUSE,\n\t\t\t\tdiffuseColor.getComponents(null), 0);\n\t\tgl.glLightfv(light, GL2.GL_SPECULAR,\n\t\t\t\tspecularColor.getComponents(null), 0);\n\t}\n", "output": "\tpublic void setGLState(GL2 gl, int light) {\n\t\tif (enabled) {\n\t\t\tgl.glEnable(light);\n\t\t}\n\t\telse\n\t\t\tgl.glDisable(light);\n\t\tgl.glLightfv(light, GL2.GL_AMBIENT,\n\t\t\t\tambientColor.getComponents(null), 0);\n\t\tgl.glLightfv(light, GL2.GL_DIFFUSE,\n\t\t\t\tdiffuseColor.getComponents(null), 0);\n\t\tgl.glLightfv(light, GL2.GL_SPECULAR,\n\t\t\t\tspecularColor.getComponents(null), 0);\n\t}\n"} {"input": "\tprotected TaskManager createTaskManagerImpl(String taskId, Map<String, String> taskArgs, Map<String, String> pipeArgs) {\n\t\tString fileName;\n\t\tFile file;\n\t\tEntityReporter task;\n\t\tfileName = getStringArgument(taskId, taskArgs, ARG_FILE_NAME, DEFAULT_FILE_NAME);\n\t\tfile = new File(fileName);\n\t\ttask = new EntityReporter(file);\n\t\treturn new SinkManager(taskId, task, pipeArgs);\n\t}\n", "output": "\tprotected TaskManager createTaskManagerImpl(String taskId, Map<String, String> taskArgs, Map<String, String> pipeArgs) {\n\t\tString fileName;\n\t\tFile file;\n\t\tIntegrityReporter task;\n\t\tfileName = getStringArgument(taskId, taskArgs, ARG_FILE_NAME, DEFAULT_FILE_NAME);\n\t\tfile = new File(fileName);\n\t\ttask = new IntegrityReporter(file);\n\t\treturn new SinkManager(taskId, task, pipeArgs);\n\t}\n"} {"input": " public void service(HttpServletRequest request, HttpServletResponse response)\n throws ServletException, IOException {\n if (getTarget() != null) {\n ServletCall servletCall = new ServletCall(getLogger(), request\n .getLocalAddr(), request.getLocalPort(), request, response);\n HttpRequest httpRequest = toRequest(servletCall);\n HttpResponse httpResponse = new HttpResponse(servletCall,\n httpRequest);\n if (this.baseRef == null) {\n String baseUri = request.getContextPath()\n + request.getServletPath();\n int baseIndex = request.getRequestURI().indexOf(baseUri);\n if (baseIndex != -1) {\n this.baseRef = new Reference(request.getRequestURI()\n .substring(0, baseIndex + baseUri.length()));\n }\n }\n httpRequest.getResourceRef().setBaseRef(this.baseRef);\n getTarget().handle(httpRequest, httpResponse);\n commit(httpResponse);\n } else {\n getLogger().warning(\"Unable to find the Restlet target\");\n }\n }\n", "output": " public void service(HttpServletRequest request, HttpServletResponse response)\n throws ServletException, IOException {\n if (getTarget() != null) {\n ServletCall servletCall = new ServletCall(getLogger(), request\n .getLocalAddr(), request.getLocalPort(), request, response);\n HttpRequest httpRequest = toRequest(servletCall);\n HttpResponse httpResponse = new HttpResponse(servletCall,\n httpRequest);\n if (this.baseRef == null) {\n String basePath = request.getContextPath()\n + request.getServletPath();\n String baseUri = request.getRequestURL().toString();\n int baseIndex = baseUri.indexOf(basePath);\n if (baseIndex != -1) {\n this.baseRef = new Reference(baseUri.substring(0, baseIndex\n + basePath.length()));\n }\n }\n httpRequest.getResourceRef().setBaseRef(this.baseRef);\n getTarget().handle(httpRequest, httpResponse);\n commit(httpResponse);\n } else {\n getLogger().warning(\"Unable to find the Restlet target\");\n }\n }\n"} {"input": " public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]) {\n String player = sender.getName();\n String target = \"\";\n try {\n target = args[0];\n } catch (ArrayIndexOutOfBoundsException e) {\n }\n if ((cmd.getName().equalsIgnoreCase(\"greport\")) && (args.length == 1)) {\n if (!sender.hasPermission(\"ireport.greport\") && !sender.isOp()) {\n sender.sendMessage(ChatColor.RED + \"You don't have permission to perform this command\");\n return true;\n }\n String already = (String) getConfig().get(\"reports.griefing.\" + player);\n sender.sendMessage(ChatColor.BLUE + \"You successfully reported \" + ChatColor.RED + target);\n getConfig().set(\"reports.griefing.\" + player, Rlocation.getxyz(this, args[0]) + \"; \" + target);\n saveConfig();\n for (Player p : sender.getServer().getOnlinePlayers()) {\n if (p.isOp() || p.hasPermission(\"iReport.seereport\")) {\n p.sendMessage(ChatColor.RED + player + \" has reported \" + target + \" for griefing\");\n }\n }\n return true;\n }\n if ((cmd.getName().equalsIgnoreCase(\"hreport\")) && (args.length == 2)) {\n if (!sender.hasPermission(\"ireport.hreport\")) {\n sender.sendMessage(ChatColor.RED + \"You don't have permission to perform this command\");\n return true;\n }\n String already = (String) getConfig().get(\"reports.hacking.\" + player);\n getConfig().set(\"reports.hacking.\" + player, new StringBuilder(\"type: \").append(args[1]).toString() + \"; \" + target);\n sender.sendMessage(ChatColor.BLUE + \"You successfully reported \" + ChatColor.RED + target);\n saveConfig();\n for (Player p : sender.getServer().getOnlinePlayers()) {\n if (p.isOp() || p.hasPermission(\"iReport.seereport\")) {\n p.sendMessage(ChatColor.RED + player + \" has reported \" + target + \" for hacking \" + args[1]);\n }\n }\n return true;\n }\n if ((cmd.getName().equalsIgnoreCase(\"sreport\")) && (args.length == 1)) {\n if (!sender.hasPermission(\"ireport.sreport\")) {\n sender.sendMessage(ChatColor.RED + \"You don't have permission to perform this command\");\n return true;\n }\n String already = (String) getConfig().get(\"reports.swearing.\" + player);\n getConfig().set(\"reports.swearing.\" + player, \"; \" + target);\n sender.sendMessage(ChatColor.BLUE + \"You don't have permission to perform this command\" + ChatColor.RED + target);\n saveConfig();\n for (Player p : sender.getServer().getOnlinePlayers()) {\n if (p.isOp() || p.hasPermission(\"iReport.seereport\")) {\n p.sendMessage(ChatColor.RED + player + \" has reported \" + target + \" for swearing\");\n }\n }\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(\"ireport\")) {\n sender.sendMessage(ChatColor.YELLOW + \"==============================\");\n sender.sendMessage(ChatColor.GREEN + \"/greport - Report a griefer\");\n sender.sendMessage(ChatColor.GREEN + \"/hreport - Report a hacker\");\n sender.sendMessage(ChatColor.GREEN + \"/sreport - Report a swearer\");\n sender.sendMessage(ChatColor.GREEN + \"/ireport - Show this help menu\");\n sender.sendMessage(ChatColor.YELLOW + \"==============================\");\n sender.sendMessage(ChatColor.MAGIC + \"Created by tudse145 & heni123321\");\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(\"reports\")) {\n try {\n Scanner sc = new Scanner(new File(\"plugins/iReport/\", \"config.yml\"));\n while (sc.hasNext()) {\n sender.sendMessage(sc.nextLine());\n }\n sc.close();\n } catch (FileNotFoundException e) {\n }\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(\"reports\")) {\n return true;\n }\n return false;\n }\n", "output": " public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]) {\n String player = sender.getName();\n String target = \"\";\n try {\n target = args[0];\n } catch (ArrayIndexOutOfBoundsException e) {\n }\n if ((cmd.getName().equalsIgnoreCase(\"greport\")) && (args.length == 1)) {\n if (!sender.hasPermission(\"ireport.greport\") && !sender.isOp()) {\n sender.sendMessage(ChatColor.RED + \"You don't have permission to perform this command\");\n return true;\n }\n String already = (String) getConfig().get(\"reports.griefing.\" + player);\n sender.sendMessage(ChatColor.BLUE + \"You successfully reported \" + ChatColor.RED + target);\n getConfig().set(\"reports.griefing.\" + player, Rlocation.getxyz(this, args[0]) + \"; \" + target);\n saveConfig();\n for (Player p : sender.getServer().getOnlinePlayers()) {\n if (p.isOp() || p.hasPermission(\"iReport.seereport\")) {\n p.sendMessage(ChatColor.RED + player + \" has reported \" + target + \" for griefing\");\n }\n }\n return true;\n }\n if ((cmd.getName().equalsIgnoreCase(\"hreport\")) && (args.length == 2)) {\n if (!sender.hasPermission(\"ireport.hreport\")) {\n sender.sendMessage(ChatColor.RED + \"You don't have permission to perform this command\");\n return true;\n }\n String already = (String) getConfig().get(\"reports.hacking.\" + player);\n getConfig().set(\"reports.hacking.\" + player, new StringBuilder(\"type: \").append(args[1]).toString() + \"; \" + target);\n sender.sendMessage(ChatColor.BLUE + \"You successfully reported \" + ChatColor.RED + target);\n saveConfig();\n for (Player p : sender.getServer().getOnlinePlayers()) {\n if (p.isOp() || p.hasPermission(\"iReport.seereport\")) {\n p.sendMessage(ChatColor.RED + player + \" has reported \" + target + \" for hacking \" + args[1]);\n }\n }\n return true;\n }\n if ((cmd.getName().equalsIgnoreCase(\"sreport\")) && (args.length == 1)) {\n if (!sender.hasPermission(\"ireport.sreport\")) {\n sender.sendMessage(ChatColor.RED + \"You don't have permission to perform this command\");\n return true;\n }\n String already = (String) getConfig().get(\"reports.swearing.\" + player);\n getConfig().set(\"reports.swearing.\" + player, \"; \" + target);\n sender.sendMessage(ChatColor.BLUE + \"You successfully reported\" + ChatColor.RED + target);\n saveConfig();\n for (Player p : sender.getServer().getOnlinePlayers()) {\n if (p.isOp() || p.hasPermission(\"iReport.seereport\")) {\n p.sendMessage(ChatColor.RED + player + \" has reported \" + target + \" for swearing\");\n }\n }\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(\"ireport\")) {\n sender.sendMessage(ChatColor.YELLOW + \"==============================\");\n sender.sendMessage(ChatColor.GREEN + \"/greport - Report a griefer\");\n sender.sendMessage(ChatColor.GREEN + \"/hreport - Report a hacker\");\n sender.sendMessage(ChatColor.GREEN + \"/sreport - Report a swearer\");\n sender.sendMessage(ChatColor.GREEN + \"/ireport - Show this help menu\");\n sender.sendMessage(ChatColor.YELLOW + \"==============================\");\n sender.sendMessage(ChatColor.MAGIC + \"Created by tudse145 & heni123321\");\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(\"reports\")) {\n try {\n Scanner sc = new Scanner(new File(\"plugins/iReport/\", \"config.yml\"));\n while (sc.hasNext()) {\n sender.sendMessage(sc.nextLine());\n }\n sc.close();\n } catch (FileNotFoundException e) {\n }\n return true;\n }\n if (cmd.getName().equalsIgnoreCase(\"reports\")) {\n return true;\n }\n return false;\n }\n"} {"input": "\tprotected IGenPackageFinderResult findGenPackage(ConcreteSyntax syntax, String nsURI, final ResourceSet rs, URI genModelURI) {\n\t\tResource genModelResource = null;\n\t\ttry {\n\t\t\tgenModelResource = rs.getResource(genModelURI, true);\n\t\t} catch (Exception e) {}\n\t\tEList<EObject> contents = null; \n\t\tif (genModelResource != null) {\n\t\t\tcontents = genModelResource.getContents();\t\n\t\t}\n\t\tif (contents != null && contents.size() > 0) {\n\t\t\tGenModel genModel = (GenModel) contents.get(0);\n\t\t\tFile ecoreFile = null;\n\t\t\tif (Platform.isRunning()) {\n\t\t\t\tboolean reloadEnabled = OptionManager.INSTANCE.getBooleanOptionValue(syntax, ICodeGenOptions.RELOAD_GENERATOR_MODEL);\n\t\t\t\tif (reloadEnabled) {\n\t\t\t\t\tgenModel = reloadGeneratorModel(genModel);\n\t\t\t\t}\n\t\t\t\tList<GenFeature> allGenFeatures = genModel.getAllGenFeatures();\n\t\t\t\tfor (GenFeature genFeature : allGenFeatures) {\n\t\t\t\t\tfinal Resource resource = genFeature.getEcoreFeature().eResource();\n\t\t\t\t\tif (resource == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tURI uri = resource.getURI();\n\t\t\t\t\tif (uri == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tIResource ecoreMember = ResourcesPlugin.getWorkspace().getRoot().findMember(uri.toPlatformString(true));\n\t\t\t\t\tecoreFile = ecoreMember.getLocation().toFile();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tMap<String, GenPackage> packages = MetamodelManager.getGenPackages(genModel);\n\t\t\tfor (String uri : packages.keySet()) {\n\t\t\t\tif (uri == null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (uri.equals(nsURI)) {\n\t\t\t\t\treturn new GenPackageInFileResult(packages.get(nsURI), ecoreFile);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tprotected IGenPackageFinderResult findGenPackage(ConcreteSyntax syntax, String nsURI, final ResourceSet rs, URI genModelURI) {\n\t\tResource genModelResource = null;\n\t\ttry {\n\t\t\tgenModelResource = rs.getResource(genModelURI, true);\n\t\t} catch (Exception e) {}\n\t\tEList<EObject> contents = null; \n\t\tif (genModelResource != null) {\n\t\t\tcontents = genModelResource.getContents();\t\n\t\t}\n\t\tif (contents != null && contents.size() > 0) {\n\t\t\tGenModel genModel = (GenModel) contents.get(0);\n\t\t\tFile ecoreFile = null;\n\t\t\tif (Platform.isRunning()) {\n\t\t\t\tboolean reloadEnabled = OptionManager.INSTANCE.getBooleanOptionValue(syntax, ICodeGenOptions.RELOAD_GENERATOR_MODEL);\n\t\t\t\tif (reloadEnabled) {\n\t\t\t\t\tgenModel = reloadGeneratorModel(genModel);\n\t\t\t\t}\n\t\t\t\tList<GenFeature> allGenFeatures = genModel.getAllGenFeatures();\n\t\t\t\tfor (GenFeature genFeature : allGenFeatures) {\n\t\t\t\t\tfinal Resource resource = genFeature.getEcoreFeature().eResource();\n\t\t\t\t\tif (resource == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tURI uri = resource.getURI();\n\t\t\t\t\tif (uri == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tIResource ecoreMember = ResourcesPlugin.getWorkspace().getRoot().findMember(uri.toPlatformString(true));\n\t\t\t\t\tif (ecoreMember != null) {\n\t\t\t\t\t\tecoreFile = ecoreMember.getLocation().toFile();\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tMap<String, GenPackage> packages = MetamodelManager.getGenPackages(genModel);\n\t\t\tfor (String uri : packages.keySet()) {\n\t\t\t\tif (uri == null) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (uri.equals(nsURI)) {\n\t\t\t\t\treturn new GenPackageInFileResult(packages.get(nsURI), ecoreFile);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": "\tpublic ArrayList<Observation> parse(String line)\n\t{\n\t\tArrayList<Observation> observations = new ArrayList<Observation>();\n\t\tString[] obs = line.split(\",\");\n\t\ttry\n\t\t{\n\t\t\tString date = obs[0];\n\t\t\tString time = obs[1];\n\t\t\tString avgX = (obs[5].equals(\"\") ? \"0\" : obs[5]);\n\t\t\tString avgY = (obs[8].equals(\"\") ? \"0\" : obs[8]);\n\t\t\tString avgZ = (obs[11].equals(\"\") ? \"0\" : obs[11]);\n\t\t\tString hum = (obs[12].equals(\"\") ? \"0\" : obs[12]);\n\t\t\tString temp = (obs[13].equals(\"\") ? \"0\" : obs[13]);\n\t\t\tString lat = (obs[14].equals(\"\") ? \"0\" : obs[14]);\n\t\t\tString lon = (obs[15].equals(\"\") ? \"0\" : obs[15]);\n\t\t\tString alt = (obs[16].equals(\"\") ? \"0\" : obs[16]);\n\t\t\tString speed = (obs[17].equals(\"\") ? \"0\" : obs[17]);\n\t\t\tString sat = (obs[18].equals(\"\") ? \"0\" : obs[18]);\n\t\t\tString prec = (obs[19].equals(\"\") ? \"0\" : obs[19]);\n\t\t\tString event = (obs[20].equals(\"\") ? \"0\" : obs[20]);\n\t\t\ttime = date.trim() + \" \" + time.trim();\n\t\t\tif(!time.equals(\" \") && (count == 2) && !time.contains(\"VALUE\"))\n\t\t\t{\n\t\t\t\tobservations.add(new AccelerometerObservation(ObservationType.ACCELERATION, \"X\", time, avgX, event));\n\t\t\t\tobservations.add(new AccelerometerObservation(ObservationType.ACCELERATION, \"Y\", time, avgY, event));\n\t\t\t\tobservations.add(new AccelerometerObservation(ObservationType.ACCELERATION, \"Z\", time, avgZ, event));\n\t\t\t\tobservations.add(new Observation(ObservationType.HUMIDITY, time, hum, event));\n\t\t\t\tobservations.add(new Observation(ObservationType.TEMPERATURE, time, temp, event));\n\t\t\t\tobservations.add(new GPSObservation(ObservationType.GPS, time, lat, lon, sat, prec, event));\n\t\t\t\tobservations.add(new AltitudeObservation(ObservationType.ALTITUDE, time, alt, sat, event));\n\t\t\t\tobservations.add(new SpeedObservation(ObservationType.SPEED, time, speed, event));\n\t\t\t\tcount = 0;\n\t\t\t} else\n\t\t\t\tcount++;\n\t\t}\n\t\tcatch(ArrayIndexOutOfBoundsException aex)\n\t\t{\n\t\t}\n\t\tcatch(Exception ex)\n\t\t{\n\t\t\tex.printStackTrace();\n\t\t}\n\t\treturn observations;\n\t}\n", "output": "\tpublic ArrayList<Observation> parse(String line)\n\t{\n\t\tArrayList<Observation> observations = new ArrayList<Observation>();\n\t\tString[] obs = line.split(\",\");\n\t\ttry\n\t\t{\n\t\t\tString date = obs[0];\n\t\t\tString time = obs[1];\n\t\t\tString avgX = (obs[5].equals(\"\") ? \"0\" : obs[5]);\n\t\t\tString avgY = (obs[8].equals(\"\") ? \"0\" : obs[8]);\n\t\t\tString avgZ = (obs[11].equals(\"\") ? \"0\" : obs[11]);\n\t\t\tString hum = (obs[12].equals(\"\") ? \"0\" : obs[12]);\n\t\t\tString temp = (obs[13].equals(\"\") ? \"0\" : obs[13]);\n\t\t\tString lat = (obs[14].equals(\"\") ? \"0\" : obs[14]);\n\t\t\tString lon = (obs[15].equals(\"\") ? \"0\" : obs[15]);\n\t\t\tString alt = (obs[16].equals(\"\") ? \"0\" : obs[16]);\n\t\t\tString speed = (obs[17].equals(\"\") ? \"0\" : obs[17]);\n\t\t\tString sat = (obs[18].equals(\"\") ? \"0\" : obs[18]);\n\t\t\tString prec = (obs[19].equals(\"\") ? \"0\" : obs[19]);\n\t\t\tString event = (obs[20].equals(\"\") ? \"0\" : obs[20]);\n\t\t\ttime = date.trim() + \" \" + time.trim();\n\t\t\tif(count == 4)\n\t\t\t{\n\t\t\t\tif(!time.equals(\" \") && !time.contains(\"#VALUE\"))\n\t\t\t\t{\n\t\t\t\t\tobservations.add(new AccelerometerObservation(ObservationType.ACCELERATION, \"X\", time, avgX, event));\n\t\t\t\t\tobservations.add(new AccelerometerObservation(ObservationType.ACCELERATION, \"Y\", time, avgY, event));\n\t\t\t\t\tobservations.add(new AccelerometerObservation(ObservationType.ACCELERATION, \"Z\", time, avgZ, event));\n\t\t\t\t\tobservations.add(new Observation(ObservationType.HUMIDITY, time, hum, event));\n\t\t\t\t\tobservations.add(new Observation(ObservationType.TEMPERATURE, time, temp, event));\n\t\t\t\t\tobservations.add(new GPSObservation(ObservationType.GPS, time, lat, lon, sat, prec, event));\n\t\t\t\t\tobservations.add(new AltitudeObservation(ObservationType.ALTITUDE, time, alt, sat, event));\n\t\t\t\t\tobservations.add(new SpeedObservation(ObservationType.SPEED, time, speed, event));\n\t\t\t\t}\n\t\t\t\tcount = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t\tcount++;\n\t\t}\n\t\tcatch(ArrayIndexOutOfBoundsException aex)\n\t\t{\n\t\t}\n\t\tcatch(Exception ex)\n\t\t{\n\t\t\tex.printStackTrace();\n\t\t}\n\t\treturn observations;\n\t}\n"} {"input": " private void parseCommandLineArguments(String[] args)\n {\n\ttry\n\t{\n\t Options options = new Options();\n\t options.addOption(new Option(\"h\",\"help\",false,\"Shows this help\"));\n\t options.addOption(new Option(\"U\",\"nfsp\",true,\"Path to directory with UCSC files.\"));\n\t options.addOption(new Option(\"S\",\"serialize\",false,\"Serialize\"));\n\t options.addOption(new Option(\"D\",\"deserialize\",true,\"Path to serialized file with UCSC data\"));\n\t options.addOption(new Option(\"V\",\"vcf\",true,\"Path to VCF file\"));\n\t options.addOption(new Option(\"J\",\"janno\",false,\"Output Jannovar format\"));\n\t options.addOption(new Option(null,\"download-ucsc\",false,\"Download UCSC KnownGene data\"));\n\t options.addOption(new Option(null,\"ftp-proxy\",true,\"FTP Proxy\"));\n\t options.addOption(new Option(null,\"ftp-proxy-port\",true,\"FTP Proxy Port\"));\n\t Parser parser = new GnuParser();\n\t CommandLine cmd = parser.parse(options,args);\n\t if (cmd.hasOption(\"h\") || cmd.hasOption(\"H\") || args.length==0)\n\t {\n\t\tHelpFormatter formatter = new HelpFormatter();\n\t\tformatter.printHelp(\"java -jar Jannovar.jar [-options]\", options);\n\t\tusage();\n\t\tSystem.exit(0);\n\t }\n\t if (cmd.hasOption(\"J\")) {\n\t\tthis.jannovarFormat = true; \n\t } else {\n\t\tthis.jannovarFormat = false;\n\t }\n\t if (cmd.hasOption(\"download-ucsc\")) {\n\t\tthis.downloadUCSC = true;\n\t\tthis.performSerialization = true;\n\t } else {\n\t\tthis.downloadUCSC = false;\n\t }\n\t if (cmd.hasOption('S')) {\n\t\tthis.performSerialization = true;\n\t }\n\t if (cmd.hasOption(\"proxy\")) {\n\t\tthis.proxy = cmd.getOptionValue(\"proxy\");\n\t } \n\t if (cmd.hasOption(\"proxy-port\")) {\n\t\tthis.proxyPort = cmd.getOptionValue(\"proxy-port\");\n\t\t}\n\t if (cmd.hasOption(\"U\")) {\n\t\tthis.ucscDirPath = getRequiredOptionValue(cmd,'U');\n\t }\n\t if (cmd.hasOption('D')) {\n\t\tthis.serializedFile = cmd.getOptionValue('D');\n\t }\n\t if (cmd.hasOption(\"V\"))\n\t\tthis.VCFfilePath = cmd.getOptionValue(\"V\");\n\t} catch (ParseException pe)\n\t{\n\t System.err.println(\"Error parsing command line options\");\n\t System.err.println(pe.getMessage());\n\t System.exit(1);\n\t}\n }\n", "output": " private void parseCommandLineArguments(String[] args)\n {\n\ttry\n\t{\n\t Options options = new Options();\n\t options.addOption(new Option(\"h\",\"help\",false,\"Shows this help\"));\n\t options.addOption(new Option(\"U\",\"nfsp\",true,\"Path to directory with UCSC files.\"));\n\t options.addOption(new Option(\"S\",\"serialize\",false,\"Serialize\"));\n\t options.addOption(new Option(\"D\",\"deserialize\",true,\"Path to serialized file with UCSC data\"));\n\t options.addOption(new Option(\"V\",\"vcf\",true,\"Path to VCF file\"));\n\t options.addOption(new Option(\"J\",\"janno\",false,\"Output Jannovar format\"));\n\t options.addOption(new Option(null,\"download-ucsc\",false,\"Download UCSC KnownGene data\"));\n\t options.addOption(new Option(null,\"proxy\",true,\"FTP Proxy\"));\n\t options.addOption(new Option(null,\"proxy-port\",true,\"FTP Proxy Port\"));\n\t Parser parser = new GnuParser();\n\t CommandLine cmd = parser.parse(options,args);\n\t if (cmd.hasOption(\"h\") || cmd.hasOption(\"H\") || args.length==0)\n\t {\n\t\tHelpFormatter formatter = new HelpFormatter();\n\t\tformatter.printHelp(\"java -jar Jannovar.jar [-options]\", options);\n\t\tusage();\n\t\tSystem.exit(0);\n\t }\n\t if (cmd.hasOption(\"J\")) {\n\t\tthis.jannovarFormat = true; \n\t } else {\n\t\tthis.jannovarFormat = false;\n\t }\n\t if (cmd.hasOption(\"download-ucsc\")) {\n\t\tthis.downloadUCSC = true;\n\t\tthis.performSerialization = true;\n\t } else {\n\t\tthis.downloadUCSC = false;\n\t }\n\t if (cmd.hasOption('S')) {\n\t\tthis.performSerialization = true;\n\t }\n\t if (cmd.hasOption(\"proxy\")) {\n\t\tthis.proxy = cmd.getOptionValue(\"proxy\");\n\t } \n\t if (cmd.hasOption(\"proxy-port\")) {\n\t\tthis.proxyPort = cmd.getOptionValue(\"proxy-port\");\n\t\t}\n\t if (cmd.hasOption(\"U\")) {\n\t\tthis.ucscDirPath = getRequiredOptionValue(cmd,'U');\n\t }\n\t if (cmd.hasOption('D')) {\n\t\tthis.serializedFile = cmd.getOptionValue('D');\n\t }\n\t if (cmd.hasOption(\"V\"))\n\t\tthis.VCFfilePath = cmd.getOptionValue(\"V\");\n\t} catch (ParseException pe)\n\t{\n\t System.err.println(\"Error parsing command line options\");\n\t System.err.println(pe.getMessage());\n\t System.exit(1);\n\t}\n }\n"} {"input": "\tpublic void draw(Graphics2D g, int windowWidth, int windowHeight)\n\t{\n\t\tif (map == null)\n\t\t\treturn;\n\t\tg.setColor(RADAR_BACKGROUND_COLOR);\n\t\tg.fill(getFixedBounds(windowWidth, windowHeight));\n\t\tg.setColor(RADAR_COLOR);\n\t\tfinal int offsetX = getFixedX(windowWidth), offsetY = getFixedY(windowHeight); \n\t\tfor (int x=0; x < map.getWidth(); x++)\n\t\t\tfor (int y=0; y < map.getHeight(); y++)\n\t\t\t{\n\t\t\t\tif (map.isWall(x, y))\n\t\t\t\t\tg.fillRect(Math.round(scale * x) + offsetX,\n\t\t\t\t\t Math.round(scale * y) + offsetY,\n\t\t\t\t\t Math.round(scale),\n\t\t\t\t\t Math.round(scale));\n\t\t\t}\n\t\tfinal LocalPlayer localPlayer = engine.getLocalPlayer();\n\t\tfinal int localID = localPlayer.getPlayerID();\n\t\tfloat time;\n\t\tint px, py;\n\t\tfor (Player p : engine.playerList)\n\t\t{\n\t\t\tif (p.getPlayerID() == localID || p.equals(localPlayer))\n\t\t\t{\n\t\t\t\tg.setColor(Color.green);\n\t\t\t}\n\t\t\telse if (p.getTeam() != TEAM_A && p.getTeam() != TEAM_B)\n\t\t\t{\n\t\t\t\ttime = p.getTimeSinceLastSound();\n\t\t\t\tif (time > BLIP_TIME)\n\t\t\t\t\tcontinue;\n\t\t\t\tg.setColor(GuiUtils.modulateColor(TEAMLESS_COLOR, 1 - (float)time/BLIP_TIME));\n\t\t\t}\n\t\t\telse if (p.getTeam() == localPlayer.getTeam())\n\t\t\t{\n\t\t\t\tg.setColor(Color.blue);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttime = p.getTimeSinceLastSound();\n\t\t\t\tif (time > BLIP_TIME)\n\t\t\t\t\tcontinue;\n\t\t\t\tg.setColor(GuiUtils.modulateColor(Color.red, 1 - (float)time/BLIP_TIME));\n\t\t\t}\n\t\t\tpx = Math.round(p.getPosition().getX() * scale) + offsetX;\n\t\t\tpy = Math.round(p.getPosition().getY() * scale) + offsetY;\n\t\t\tpx = Math.min(x + width, Math.max(x, px));\n\t\t\tpy = Math.min(y + height, Math.max(y, py));\n\t\t\tg.fillRect(px - 1, py - 1, 3, 3);\n\t\t} \n\t\tif (showName)\n\t\t{\n\t\t\tString name = map.getName();\n\t\t\tRectangle2D bounds = g.getFontMetrics().getStringBounds(name, g);\n\t\t\tint xpos = x, ypos = y + height;\n\t\t\tif (x < 0)\n\t\t\t\txpos = (int)Math.round(windowWidth - bounds.getWidth() + x - width - bounds.getX());\n\t\t\tif (y < 0)\n\t\t\t\typos = (int)Math.round(windowHeight - bounds.getHeight() + y - height - bounds.getY());\n\t\t\tg.setColor(Color.yellow);\n\t\t\tg.drawString(name, xpos, ypos);\n\t\t}\n\t} \n", "output": "\tpublic void draw(Graphics2D g, int windowWidth, int windowHeight)\n\t{\n\t\tif (map == null)\n\t\t\treturn;\n\t\tg.setColor(RADAR_BACKGROUND_COLOR);\n\t\tg.fill(getFixedBounds(windowWidth, windowHeight));\n\t\tg.setColor(RADAR_COLOR);\n\t\tfinal int offsetX = getFixedX(windowWidth), offsetY = getFixedY(windowHeight); \n\t\tfor (int x=0; x < map.getWidth(); x++)\n\t\t\tfor (int y=0; y < map.getHeight(); y++)\n\t\t\t{\n\t\t\t\tif (map.isWall(x, y))\n\t\t\t\t\tg.fillRect(Math.round(scale * x) + offsetX,\n\t\t\t\t\t Math.round(scale * y) + offsetY,\n\t\t\t\t\t Math.round(scale),\n\t\t\t\t\t Math.round(scale));\n\t\t\t}\n\t\tfinal LocalPlayer localPlayer = engine.getLocalPlayer();\n\t\tfinal int localID = localPlayer.getPlayerID();\n\t\tfloat time;\n\t\tint px, py;\n\t\tfor (Player p : engine.playerList)\n\t\t{\n\t\t\tif (p.getPlayerID() == localID || p.equals(localPlayer))\n\t\t\t{\n\t\t\t\tg.setColor(Color.green);\n\t\t\t}\n\t\t\telse if (p.getTeam() != TEAM_A && p.getTeam() != TEAM_B)\n\t\t\t{\n\t\t\t\ttime = p.getTimeSinceLastSound();\n\t\t\t\tif (time > BLIP_TIME)\n\t\t\t\t\tcontinue;\n\t\t\t\tg.setColor(GuiUtils.modulateColor(TEAMLESS_COLOR, 1 - (float)time/BLIP_TIME));\n\t\t\t}\n\t\t\telse if (p.getTeam() == localPlayer.getTeam())\n\t\t\t{\n\t\t\t\tg.setColor(Color.blue);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttime = p.getTimeSinceLastSound();\n\t\t\t\tif (time > BLIP_TIME)\n\t\t\t\t\tcontinue;\n\t\t\t\tg.setColor(GuiUtils.modulateColor(Color.red, 1 - (float)time/BLIP_TIME));\n\t\t\t}\n\t\t\tpx = Math.round(p.getPosition().getX() * scale) + offsetX;\n\t\t\tpy = Math.round(p.getPosition().getY() * scale) + offsetY;\n\t\t\tpx = Math.min(getFixedX(windowWidth) + width, Math.max(getFixedX(windowWidth), px));\n\t\t\tpy = Math.min(getFixedY(windowHeight) + height, Math.max(getFixedY(windowHeight), py));\n\t\t\tg.fillRect(px - 1, py - 1, 3, 3);\n\t\t} \n\t\tif (showName)\n\t\t{\n\t\t\tString name = map.getName();\n\t\t\tRectangle2D bounds = g.getFontMetrics().getStringBounds(name, g);\n\t\t\tint xpos = x, ypos = y + height;\n\t\t\tif (x < 0)\n\t\t\t\txpos = (int)Math.round(windowWidth - bounds.getWidth() + x - width - bounds.getX());\n\t\t\tif (y < 0)\n\t\t\t\typos = (int)Math.round(windowHeight - bounds.getHeight() + y - height - bounds.getY());\n\t\t\tg.setColor(Color.yellow);\n\t\t\tg.drawString(name, xpos, ypos);\n\t\t}\n\t} \n"} {"input": " public CompositeSequence(Class<T> clazz, Sequence<? extends T>... sequences) {\n super(clazz);\n this.sequences = sequences.clone();\n this.startPositions = new int[sequences.length];\n int size = 0;\n int depth = 0;\n for (int i = 0, offset = 0; i < sequences.length; i++) {\n if (!sequences[i].getElementType().isAssignableFrom(clazz))\n throw new ClassCastException();\n startPositions[i] = offset;\n size += sequences[i].size();\n offset += sequences[i].size();\n depth = Math.max(depth, sequences[i].getDepth());\n }\n this.size = size;\n this.depth = depth + 1;\n }\n", "output": " public CompositeSequence(Class<T> clazz, Sequence<? extends T>... sequences) {\n super(clazz);\n this.sequences = sequences.clone();\n this.startPositions = new int[sequences.length];\n int size = 0;\n int depth = 0;\n for (int i = 0, offset = 0; i < sequences.length; i++) {\n Class eClass = sequences[i].getElementType();\n if (!clazz.isAssignableFrom(eClass))\n throw new ClassCastException(\"cannot cast \"+eClass.getName()\n +\" segment to \"+clazz.getName()+\" sequence\");\n startPositions[i] = offset;\n size += sequences[i].size();\n offset += sequences[i].size();\n depth = Math.max(depth, sequences[i].getDepth());\n }\n this.size = size;\n this.depth = depth + 1;\n }\n"} {"input": "\tprotected ToolBar createToolBar() {\n\t\tif (this.toolBar != null) {\n\t\t\tthis.toolBar.clear();\n\t\t\tthis.toolBar.destroy(GLContext.getCurrentGL().getGL2());\n\t\t}\n\t\tToolBar toolBar = new ToolBar(\"ToolBarRow\", brick);\n\t\ttoolBar.setPixelSizeY(0);\n\t\tElementLayout spacingLayoutX = new ElementLayout(\"spacingLayoutX\");\n\t\tspacingLayoutX.setPixelSizeX(SPACING_PIXELS);\n\t\tspacingLayoutX.setRatioSizeY(0);\n\t\ttoolBar.append(spacingLayoutX);\n\t\tfor (ElementLayout element : toolBarElements) {\n\t\t\ttoolBar.append(element);\n\t\t}\n\t\tElementLayout greedyXLayout = new ElementLayout(\"greedy\");\n\t\tgreedyXLayout.setGrabX(true);\n\t\tgreedyXLayout.setRatioSizeY(0);\n\t\ttoolBar.append(greedyXLayout);\n\t\tif (showClusterButton) {\n\t\t\tButton clusterButton = new Button(EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(), brick.getID(),\n\t\t\t\t\tEIconTextures.CLUSTER_ICON);\n\t\t\tElementLayout clusterButtonLayout = new ElementLayout(\"clusterButton\");\n\t\t\tclusterButtonLayout.setPixelSizeX(BUTTON_WIDTH_PIXELS);\n\t\t\tclusterButtonLayout.setPixelSizeY(BUTTON_HEIGHT_PIXELS);\n\t\t\tclusterButtonLayout\n\t\t\t\t\t.setRenderer(new ButtonRenderer.Builder(brick.getStratomex(), clusterButton)\n\t\t\t\t\t\t\t.textureManager(brick.getTextureManager()).zCoordinate(DefaultBrickLayoutTemplate.BUTTON_Z)\n\t\t\t\t\t\t\t.build());\n\t\t\ttoolBar.append(clusterButtonLayout);\n\t\t\ttoolBar.append(spacingLayoutX);\n\t\t\tbrick.getStratomex().removeAllIDPickingListeners(EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(),\n\t\t\t\t\tbrick.getID());\n\t\t\tbrick.getStratomex().addIDPickingListener(new APickingListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void clicked(Pick pick) {\n\t\t\t\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\tClusterConfiguration clusterConfiguration = new ClusterConfiguration();\n\t\t\t\t\t\t\tTablePerspective oldTablePerspective = brick.getBrickColumn().getTablePerspective();\n\t\t\t\t\t\t\tclusterConfiguration.setSourceDimensionPerspective(oldTablePerspective\n\t\t\t\t\t\t\t\t\t.getDimensionPerspective());\n\t\t\t\t\t\t\tclusterConfiguration.setSourceRecordPerspective(oldTablePerspective.getRecordPerspective());\n\t\t\t\t\t\t\tATableBasedDataDomain dataDomain = oldTablePerspective.getDataDomain();\n\t\t\t\t\t\t\tPerspective newRecordPerspective = new Perspective(dataDomain, dataDomain.getRecordIDType());\n\t\t\t\t\t\t\tnewRecordPerspective.setVirtualArray(oldTablePerspective.getRecordPerspective()\n\t\t\t\t\t\t\t\t\t.getVirtualArray());\n\t\t\t\t\t\t\tclusterConfiguration.setOptionalTargetRecordPerspective(newRecordPerspective);\n\t\t\t\t\t\t\tClusterDialog dialog = new ClusterDialog(new Shell(), brick.getDataDomain(),\n\t\t\t\t\t\t\t\t\tclusterConfiguration);\n\t\t\t\t\t\t\tif (dialog.open() == Window.OK) {\n\t\t\t\t\t\t\t\tdataDomain.getTable().registerRecordPerspective(newRecordPerspective);\n\t\t\t\t\t\t\t\tTablePerspective newTablePerspective = dataDomain.getTablePerspective(\n\t\t\t\t\t\t\t\t\t\tnewRecordPerspective.getPerspectiveID(), oldTablePerspective\n\t\t\t\t\t\t\t\t\t\t\t\t.getDimensionPerspective().getPerspectiveID());\n\t\t\t\t\t\t\t\tReplaceTablePerspectiveEvent rEvent = new ReplaceTablePerspectiveEvent(brick\n\t\t\t\t\t\t\t\t\t\t.getBrickColumn().getStratomexView().getID(), newTablePerspective,\n\t\t\t\t\t\t\t\t\t\toldTablePerspective);\n\t\t\t\t\t\t\t\tGeneralManager.get().getEventPublisher().triggerEvent(rEvent);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}, EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(), brick.getID());\n\t\t}\n\t\tbrick.getStratomex().addIDPickingTooltipListener(\"Cluster\", EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(),\n\t\t\t\tbrick.getID());\n\t\tButton removeColumnButton = new Button(EPickingType.REMOVE_COLUMN_BUTTON.name(), brick.getID(),\n\t\t\t\tEIconTextures.REMOVE);\n\t\tElementLayout removeColumnButtonLayout = new ElementLayout(\"removeColumnButton\");\n\t\tremoveColumnButtonLayout.setPixelSizeX(BUTTON_WIDTH_PIXELS);\n\t\tremoveColumnButtonLayout.setPixelSizeY(BUTTON_HEIGHT_PIXELS);\n\t\tremoveColumnButtonLayout.setRenderer(new ButtonRenderer.Builder(brick.getStratomex(), removeColumnButton)\n\t\t\t\t.textureManager(brick.getTextureManager()).zCoordinate(DefaultBrickLayoutTemplate.BUTTON_Z).build());\n\t\ttoolBar.append(removeColumnButtonLayout);\n\t\ttoolBar.append(spacingLayoutX);\n\t\tbrick.getStratomex().removeAllIDPickingListeners(EPickingType.REMOVE_COLUMN_BUTTON.name(), brick.getID());\n\t\tbrick.getStratomex().addIDPickingListener(new APickingListener() {\n\t\t\t@Override\n\t\t\tpublic void clicked(Pick pick) {\n\t\t\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tRemoveTablePerspectiveEvent event = new RemoveTablePerspectiveEvent(brick.getBrickColumn()\n\t\t\t\t\t\t\t\t.getTablePerspective(), brick.getStratomex());\n\t\t\t\t\t\tevent.setSender(this);\n\t\t\t\t\t\tGeneralManager.get().getEventPublisher().triggerEvent(event);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}, EPickingType.REMOVE_COLUMN_BUTTON.name(), brick.getID());\n\t\tbrick.getStratomex().addIDPickingTooltipListener(\"Remove column\", EPickingType.REMOVE_COLUMN_BUTTON.name(),\n\t\t\t\tbrick.getID());\n\t\treturn toolBar;\n\t}\n", "output": "\tprotected ToolBar createToolBar() {\n\t\tif (this.toolBar != null) {\n\t\t\tthis.toolBar.clear();\n\t\t\tthis.toolBar.destroy(GLContext.getCurrentGL().getGL2());\n\t\t}\n\t\tToolBar toolBar = new ToolBar(\"ToolBarRow\", brick);\n\t\ttoolBar.setPixelSizeY(0);\n\t\tElementLayout spacingLayoutX = new ElementLayout(\"spacingLayoutX\");\n\t\tspacingLayoutX.setPixelSizeX(SPACING_PIXELS);\n\t\tspacingLayoutX.setRatioSizeY(0);\n\t\ttoolBar.append(spacingLayoutX);\n\t\tfor (ElementLayout element : toolBarElements) {\n\t\t\ttoolBar.append(element);\n\t\t}\n\t\tElementLayout greedyXLayout = new ElementLayout(\"greedy\");\n\t\tgreedyXLayout.setGrabX(true);\n\t\tgreedyXLayout.setRatioSizeY(0);\n\t\ttoolBar.append(greedyXLayout);\n\t\tif (showClusterButton) {\n\t\t\tButton clusterButton = new Button(EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(), brick.getID(),\n\t\t\t\t\tEIconTextures.CLUSTER_ICON);\n\t\t\tElementLayout clusterButtonLayout = new ElementLayout(\"clusterButton\");\n\t\t\tclusterButtonLayout.setPixelSizeX(BUTTON_WIDTH_PIXELS);\n\t\t\tclusterButtonLayout.setPixelSizeY(BUTTON_HEIGHT_PIXELS);\n\t\t\tclusterButtonLayout\n\t\t\t\t\t.setRenderer(new ButtonRenderer.Builder(brick.getStratomex(), clusterButton)\n\t\t\t\t\t\t\t.textureManager(brick.getTextureManager()).zCoordinate(DefaultBrickLayoutTemplate.BUTTON_Z)\n\t\t\t\t\t\t\t.build());\n\t\t\ttoolBar.append(clusterButtonLayout);\n\t\t\ttoolBar.append(spacingLayoutX);\n\t\t\tbrick.getStratomex().removeAllIDPickingListeners(EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(),\n\t\t\t\t\tbrick.getID());\n\t\t\tbrick.getStratomex().addIDPickingListener(new APickingListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void clicked(Pick pick) {\n\t\t\t\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\tClusterConfiguration clusterConfiguration = new ClusterConfiguration();\n\t\t\t\t\t\t\tTablePerspective oldTablePerspective = brick.getBrickColumn().getTablePerspective();\n\t\t\t\t\t\t\tclusterConfiguration.setSourceDimensionPerspective(oldTablePerspective\n\t\t\t\t\t\t\t\t\t.getDimensionPerspective());\n\t\t\t\t\t\t\tclusterConfiguration.setSourceRecordPerspective(oldTablePerspective.getRecordPerspective());\n\t\t\t\t\t\t\tATableBasedDataDomain dataDomain = oldTablePerspective.getDataDomain();\n\t\t\t\t\t\t\tPerspective newRecordPerspective = new Perspective(dataDomain, dataDomain.getRecordIDType());\n\t\t\t\t\t\t\tnewRecordPerspective.setLabel(\"Currently clustering...\", false);\n\t\t\t\t\t\t\tnewRecordPerspective.setVirtualArray(oldTablePerspective.getRecordPerspective()\n\t\t\t\t\t\t\t\t\t.getVirtualArray());\n\t\t\t\t\t\t\tclusterConfiguration.setOptionalTargetRecordPerspective(newRecordPerspective);\n\t\t\t\t\t\t\tClusterDialog dialog = new ClusterDialog(new Shell(), brick.getDataDomain(),\n\t\t\t\t\t\t\t\t\tclusterConfiguration);\n\t\t\t\t\t\t\tif (dialog.open() == Window.OK) {\n\t\t\t\t\t\t\t\tdataDomain.getTable().registerRecordPerspective(newRecordPerspective);\n\t\t\t\t\t\t\t\tTablePerspective newTablePerspective = dataDomain.getTablePerspective(\n\t\t\t\t\t\t\t\t\t\tnewRecordPerspective.getPerspectiveID(), oldTablePerspective\n\t\t\t\t\t\t\t\t\t\t\t\t.getDimensionPerspective().getPerspectiveID());\n\t\t\t\t\t\t\t\tReplaceTablePerspectiveEvent rEvent = new ReplaceTablePerspectiveEvent(brick\n\t\t\t\t\t\t\t\t\t\t.getBrickColumn().getStratomexView().getID(), newTablePerspective,\n\t\t\t\t\t\t\t\t\t\toldTablePerspective);\n\t\t\t\t\t\t\t\tGeneralManager.get().getEventPublisher().triggerEvent(rEvent);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}, EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(), brick.getID());\n\t\t}\n\t\tbrick.getStratomex().addIDPickingTooltipListener(\"Cluster\", EPickingType.DIMENSION_GROUP_CLUSTER_BUTTON.name(),\n\t\t\t\tbrick.getID());\n\t\tButton removeColumnButton = new Button(EPickingType.REMOVE_COLUMN_BUTTON.name(), brick.getID(),\n\t\t\t\tEIconTextures.REMOVE);\n\t\tElementLayout removeColumnButtonLayout = new ElementLayout(\"removeColumnButton\");\n\t\tremoveColumnButtonLayout.setPixelSizeX(BUTTON_WIDTH_PIXELS);\n\t\tremoveColumnButtonLayout.setPixelSizeY(BUTTON_HEIGHT_PIXELS);\n\t\tremoveColumnButtonLayout.setRenderer(new ButtonRenderer.Builder(brick.getStratomex(), removeColumnButton)\n\t\t\t\t.textureManager(brick.getTextureManager()).zCoordinate(DefaultBrickLayoutTemplate.BUTTON_Z).build());\n\t\ttoolBar.append(removeColumnButtonLayout);\n\t\ttoolBar.append(spacingLayoutX);\n\t\tbrick.getStratomex().removeAllIDPickingListeners(EPickingType.REMOVE_COLUMN_BUTTON.name(), brick.getID());\n\t\tbrick.getStratomex().addIDPickingListener(new APickingListener() {\n\t\t\t@Override\n\t\t\tpublic void clicked(Pick pick) {\n\t\t\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tRemoveTablePerspectiveEvent event = new RemoveTablePerspectiveEvent(brick.getBrickColumn()\n\t\t\t\t\t\t\t\t.getTablePerspective(), brick.getStratomex());\n\t\t\t\t\t\tevent.setSender(this);\n\t\t\t\t\t\tGeneralManager.get().getEventPublisher().triggerEvent(event);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}, EPickingType.REMOVE_COLUMN_BUTTON.name(), brick.getID());\n\t\tbrick.getStratomex().addIDPickingTooltipListener(\"Remove column\", EPickingType.REMOVE_COLUMN_BUTTON.name(),\n\t\t\t\tbrick.getID());\n\t\treturn toolBar;\n\t}\n"} {"input": "\tpublic TreePage(PageParameters params) {\n\t\tsuper(params);\n\t\tfinal String path = WicketUtils.getPath(params);\n\t\tRepository r = getRepository();\n\t\tRevCommit commit = getCommit();\n\t\tList<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);\n\t\tadd(new BookmarkablePageLink<Void>(\"historyLink\", HistoryPage.class,\n\t\t\t\tWicketUtils.newPathParameter(repositoryName, objectId, path)));\n\t\tadd(new BookmarkablePageLink<Void>(\"headLink\", TreePage.class,\n\t\t\t\tWicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));\n\t\tadd(new CompressedDownloadsPanel(\"compressedLinks\", getRequest()\n\t\t\t\t.getRelativePathPrefixToContextRoot(), repositoryName, objectId, path));\n\t\tadd(new CommitHeaderPanel(\"commitHeader\", repositoryName, commit));\n\t\tadd(new PathBreadcrumbsPanel(\"breadcrumbs\", repositoryName, path, objectId));\n\t\tif (path != null && path.trim().length() > 0) {\n\t\t\tString parentPath = null;\n\t\t\tif (path.lastIndexOf('/') > -1) {\n\t\t\t\tparentPath = path.substring(0, path.lastIndexOf('/'));\n\t\t\t}\n\t\t\tPathModel model = new PathModel(\"..\", parentPath, 0, FileMode.TREE.getBits(), null, objectId);\n\t\t\tmodel.isParentPath = true;\n\t\t\tpaths.add(0, model);\n\t\t}\n\t\tfinal ByteFormat byteFormat = new ByteFormat();\n\t\tfinal String baseUrl = WicketUtils.getGitblitURL(getRequest());\n\t\tListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);\n\t\tDataView<PathModel> pathsView = new DataView<PathModel>(\"changedPath\", pathsDp) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\tint counter;\n\t\t\tpublic void populateItem(final Item<PathModel> item) {\n\t\t\t\tPathModel entry = item.getModelObject();\n\t\t\t\titem.add(new Label(\"pathPermissions\", JGitUtils.getPermissionsFromMode(entry.mode)));\n\t\t\t\tif (entry.isParentPath) {\n\t\t\t\t\titem.add(WicketUtils.newBlankImage(\"pathIcon\"));\n\t\t\t\t\titem.add(new Label(\"pathSize\", \"\"));\n\t\t\t\t\titem.add(new LinkPanel(\"pathName\", null, entry.name, TreePage.class,\n\t\t\t\t\t\t\tWicketUtils\n\t\t\t\t\t\t\t\t\t.newPathParameter(repositoryName, entry.commitId, entry.path)));\n\t\t\t\t\titem.add(new Label(\"pathLinks\", \"\"));\n\t\t\t\t} else {\n\t\t\t\t\tif (entry.isTree()) {\n\t\t\t\t\t\titem.add(WicketUtils.newImage(\"pathIcon\", \"folder_16x16.png\"));\n\t\t\t\t\t\titem.add(new Label(\"pathSize\", \"\"));\n\t\t\t\t\t\titem.add(new LinkPanel(\"pathName\", \"list\", entry.name, TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tentry.path)));\n\t\t\t\t\t\tFragment links = new Fragment(\"pathLinks\", \"treeLinks\", this);\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"tree\", TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tentry.path)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"history\", HistoryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tentry.path)));\t\t\t\t\t\t\n\t\t\t\t\t\tlinks.add(new CompressedDownloadsPanel(\"compressedLinks\", baseUrl,\n\t\t\t\t\t\t\t\trepositoryName, objectId, entry.path));\n\t\t\t\t\t\titem.add(links);\n\t\t\t\t\t} else if (entry.isSubmodule()) {\n\t\t\t\t\t\tString submoduleId = entry.objectId;\t\t\t\t\t\t\n\t\t\t\t\t\tString submodulePath;\n\t\t\t\t\t\tboolean hasSubmodule = false;\n\t\t\t\t\t\tSubmoduleModel submodule = getSubmodule(entry.path);\n\t\t\t\t\t\tsubmodulePath = submodule.gitblitPath;\n\t\t\t\t\t\thasSubmodule = submodule.hasSubmodule;\n\t\t\t\t\t\titem.add(WicketUtils.newImage(\"pathIcon\", \"git-orange-16x16.png\"));\n\t\t\t\t\t\titem.add(new Label(\"pathSize\", \"\"));\n\t\t\t\t\t\titem.add(new LinkPanel(\"pathName\", \"list\", entry.name + \" @ \" + \n\t\t\t\t\t\t\t\tgetShortObjectId(submoduleId), TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(submodulePath, submoduleId, \"\")).setEnabled(hasSubmodule));\n\t\t\t\t\t\tFragment links = new Fragment(\"pathLinks\", \"submoduleLinks\", this);\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"view\", SummaryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"tree\", TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(submodulePath, submoduleId,\n\t\t\t\t\t\t\t\t\t\t\"\")).setEnabled(hasSubmodule));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"history\", HistoryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(submodulePath, submoduleId,\n\t\t\t\t\t\t\t\t\t\t\"\")).setEnabled(hasSubmodule));\n\t\t\t\t\t\tlinks.add(new CompressedDownloadsPanel(\"compressedLinks\", baseUrl,\n\t\t\t\t\t\t\t\tsubmodulePath, submoduleId, \"\").setEnabled(hasSubmodule));\n\t\t\t\t\t\titem.add(links);\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\tString displayPath = entry.path;\n\t\t\t\t\t\tString path = entry.path;\n\t\t\t\t\t\tif (entry.isSymlink()) {\n\t\t\t\t\t\t\tpath = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);\n\t\t\t\t\t\t\tdisplayPath = entry.path + \" -> \" + path;\n\t\t\t\t\t\t}\n\t\t\t\t\t\titem.add(WicketUtils.getFileImage(\"pathIcon\", entry.name));\n\t\t\t\t\t\titem.add(new Label(\"pathSize\", byteFormat.format(entry.size)));\n\t\t\t\t\t\titem.add(new LinkPanel(\"pathName\", \"list\", displayPath, BlobPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\tFragment links = new Fragment(\"pathLinks\", \"blobLinks\", this);\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"view\", BlobPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"raw\", RawPage.class, WicketUtils\n\t\t\t\t\t\t\t\t.newPathParameter(repositoryName, entry.commitId, path)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"blame\", BlamePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"history\", HistoryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\titem.add(links);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tWicketUtils.setAlternatingBackground(item, counter);\n\t\t\t\tcounter++;\n\t\t\t}\n\t\t};\n\t\tadd(pathsView);\n\t}\n", "output": "\tpublic TreePage(PageParameters params) {\n\t\tsuper(params);\n\t\tfinal String path = WicketUtils.getPath(params);\n\t\tRepository r = getRepository();\n\t\tRevCommit commit = getCommit();\n\t\tList<PathModel> paths = JGitUtils.getFilesInPath(r, path, commit);\n\t\tadd(new BookmarkablePageLink<Void>(\"historyLink\", HistoryPage.class,\n\t\t\t\tWicketUtils.newPathParameter(repositoryName, objectId, path)));\n\t\tadd(new BookmarkablePageLink<Void>(\"headLink\", TreePage.class,\n\t\t\t\tWicketUtils.newPathParameter(repositoryName, Constants.HEAD, path)));\n\t\tadd(new CompressedDownloadsPanel(\"compressedLinks\", getRequest()\n\t\t\t\t.getRelativePathPrefixToContextRoot(), repositoryName, objectId, path));\n\t\tadd(new CommitHeaderPanel(\"commitHeader\", repositoryName, commit));\n\t\tadd(new PathBreadcrumbsPanel(\"breadcrumbs\", repositoryName, path, objectId));\n\t\tif (path != null && path.trim().length() > 0) {\n\t\t\tString parentPath = null;\n\t\t\tif (path.lastIndexOf('/') > -1) {\n\t\t\t\tparentPath = path.substring(0, path.lastIndexOf('/'));\n\t\t\t}\n\t\t\tPathModel model = new PathModel(\"..\", parentPath, 0, FileMode.TREE.getBits(), null, objectId);\n\t\t\tmodel.isParentPath = true;\n\t\t\tpaths.add(0, model);\n\t\t}\n\t\tfinal ByteFormat byteFormat = new ByteFormat();\n\t\tfinal String baseUrl = WicketUtils.getGitblitURL(getRequest());\n\t\tListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);\n\t\tDataView<PathModel> pathsView = new DataView<PathModel>(\"changedPath\", pathsDp) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\tint counter;\n\t\t\tpublic void populateItem(final Item<PathModel> item) {\n\t\t\t\tPathModel entry = item.getModelObject();\n\t\t\t\titem.add(new Label(\"pathPermissions\", JGitUtils.getPermissionsFromMode(entry.mode)));\n\t\t\t\tif (entry.isParentPath) {\n\t\t\t\t\titem.add(WicketUtils.newBlankImage(\"pathIcon\"));\n\t\t\t\t\titem.add(new Label(\"pathSize\", \"\"));\n\t\t\t\t\titem.add(new LinkPanel(\"pathName\", null, entry.name, TreePage.class,\n\t\t\t\t\t\t\tWicketUtils\n\t\t\t\t\t\t\t\t\t.newPathParameter(repositoryName, entry.commitId, entry.path)));\n\t\t\t\t\titem.add(new Label(\"pathLinks\", \"\"));\n\t\t\t\t} else {\n\t\t\t\t\tif (entry.isTree()) {\n\t\t\t\t\t\titem.add(WicketUtils.newImage(\"pathIcon\", \"folder_16x16.png\"));\n\t\t\t\t\t\titem.add(new Label(\"pathSize\", \"\"));\n\t\t\t\t\t\titem.add(new LinkPanel(\"pathName\", \"list\", entry.name, TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tentry.path)));\n\t\t\t\t\t\tFragment links = new Fragment(\"pathLinks\", \"treeLinks\", this);\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"tree\", TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tentry.path)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"history\", HistoryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tentry.path)));\t\t\t\t\t\t\n\t\t\t\t\t\tlinks.add(new CompressedDownloadsPanel(\"compressedLinks\", baseUrl,\n\t\t\t\t\t\t\t\trepositoryName, objectId, entry.path));\n\t\t\t\t\t\titem.add(links);\n\t\t\t\t\t} else if (entry.isSubmodule()) {\n\t\t\t\t\t\tString submoduleId = entry.objectId;\t\t\t\t\t\t\n\t\t\t\t\t\tString submodulePath;\n\t\t\t\t\t\tboolean hasSubmodule = false;\n\t\t\t\t\t\tSubmoduleModel submodule = getSubmodule(entry.path);\n\t\t\t\t\t\tsubmodulePath = submodule.gitblitPath;\n\t\t\t\t\t\thasSubmodule = submodule.hasSubmodule;\n\t\t\t\t\t\titem.add(WicketUtils.newImage(\"pathIcon\", \"git-orange-16x16.png\"));\n\t\t\t\t\t\titem.add(new Label(\"pathSize\", \"\"));\n\t\t\t\t\t\titem.add(new LinkPanel(\"pathName\", \"list\", entry.name + \" @ \" + \n\t\t\t\t\t\t\t\tgetShortObjectId(submoduleId), TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(submodulePath, submoduleId, \"\")).setEnabled(hasSubmodule));\n\t\t\t\t\t\tFragment links = new Fragment(\"pathLinks\", \"submoduleLinks\", this);\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"view\", SummaryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newRepositoryParameter(submodulePath)).setEnabled(hasSubmodule));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"tree\", TreePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(submodulePath, submoduleId,\n\t\t\t\t\t\t\t\t\t\t\"\")).setEnabled(hasSubmodule));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"history\", HistoryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(submodulePath, submoduleId,\n\t\t\t\t\t\t\t\t\t\t\"\")).setEnabled(hasSubmodule));\n\t\t\t\t\t\tlinks.add(new CompressedDownloadsPanel(\"compressedLinks\", baseUrl,\n\t\t\t\t\t\t\t\tsubmodulePath, submoduleId, \"\").setEnabled(hasSubmodule));\n\t\t\t\t\t\titem.add(links);\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\tString displayPath = entry.name;\n\t\t\t\t\t\tString path = entry.path;\n\t\t\t\t\t\tif (entry.isSymlink()) {\n\t\t\t\t\t\t\tpath = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);\n\t\t\t\t\t\t\tdisplayPath = entry.name + \" -> \" + path;\n\t\t\t\t\t\t}\n\t\t\t\t\t\titem.add(WicketUtils.getFileImage(\"pathIcon\", entry.name));\n\t\t\t\t\t\titem.add(new Label(\"pathSize\", byteFormat.format(entry.size)));\n\t\t\t\t\t\titem.add(new LinkPanel(\"pathName\", \"list\", displayPath, BlobPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\tFragment links = new Fragment(\"pathLinks\", \"blobLinks\", this);\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"view\", BlobPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"raw\", RawPage.class, WicketUtils\n\t\t\t\t\t\t\t\t.newPathParameter(repositoryName, entry.commitId, path)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"blame\", BlamePage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\tlinks.add(new BookmarkablePageLink<Void>(\"history\", HistoryPage.class,\n\t\t\t\t\t\t\t\tWicketUtils.newPathParameter(repositoryName, entry.commitId,\n\t\t\t\t\t\t\t\t\t\tpath)));\n\t\t\t\t\t\titem.add(links);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tWicketUtils.setAlternatingBackground(item, counter);\n\t\t\t\tcounter++;\n\t\t\t}\n\t\t};\n\t\tadd(pathsView);\n\t}\n"} {"input": " private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { \n User user = null;\n String action = request.getParameter(\"Action\");\n long ts1 = System.currentTimeMillis();\n try {\n valueAccumulator.initializeAllCounters();\n \trequestInit();\n response.setContentType(\"text/xml\");\n if (!isValidAction(action)) {\n throw new CMBException(CMBErrorCodes.InvalidAction, action + \" is not a valid action\");\n }\n if (isAuthenticationRequired(action)) {\n user = authModule.authenticateByRequest(request);\n } else {\n user = null;\n }\n long ts3 = System.currentTimeMillis();\n valueAccumulator.addToCounter(AccumulatorName.CMBControllerPreHandleAction, (ts3 - ts1));\n boolean actionPerformed = handleAction(action, user, request, response);\n response.setStatus(200);\n long ts2 = System.currentTimeMillis();\n if (action != null && action.equals(\"ReceiveMessage\") && !actionPerformed && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {\n } else if (action != null && action.equals(\"GetQueueUrl\") && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {\n } else {\n\t logger.info(\n\t \t\t\"event=handleRequest status=success client_ip=\" + request.getRemoteAddr() + \" action=\" + action + \" responseTimeMS=\" + (ts2-ts1) + \n\t (request.getParameter(\"TopicArn\") != null ? \" topic_arn=\" + request.getParameter(\"TopicArn\") : \"\") +\n\t (request.getParameter(\"SubscriptionArn\") != null ? \" subscription_arn=\" + request.getParameter(\"SubscriptionArn\") : \"\") +\n\t (request.getParameter(\"Label\") != null ? \" label=\" + request.getParameter(\"Label\") : \"\") +\n\t (request.getParameter(\"NextToken\") != null ? \" next_token=\" + request.getParameter(\"NextToken\") : \"\") +\n\t (request.getParameter(\"Name\") != null ? \" name=\" + request.getParameter(\"Name\") : \"\") +\n\t (request.getParameter(\"Token\") != null ? \" token=\" + request.getParameter(\"Token\") : \"\") +\n\t (request.getParameter(\"Endpoint\") != null ? \" endpoint=\" + request.getParameter(\"Endpoint\") : \"\") +\n\t (request.getParameter(\"Protocol\") != null ? \" protocol=\" + request.getParameter(\"Protocol\") : \"\") +\n\t (request.getParameter(\"ReceiptHandle\") != null ? \" receipt_handle=\" + request.getParameter(\"ReceiptHandle\") : \"\") +\n\t (request.getParameter(\"VisibilityTimeout\") != null ? \" visibility_timeout=\" + request.getParameter(\"VisibilityTimeout\") : \"\") +\n\t (request.getParameter(\"QueueName\") != null ? \" queue_name=\" + request.getParameter(\"QueueName\") : \"\") +\n\t (request.getParameter(\"QueueNamePrefix\") != null ? \" queue_name_prefix=\" + request.getParameter(\"QueueNamePrefix\") : \"\") +\n\t (request.getParameter(\"DelaySeconds\") != null ? \" delay_seconds=\" + request.getParameter(\"DelaySeconds\") : \"\") +\n\t ((this instanceof CQSControllerServlet) ? (\" queue_url=\" + request.getRequestURL().toString()) : \"\") +\n\t \t\t\" CassandraTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + \n\t \" CassandraReadNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + \n\t \" CassandraWriteNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +\n\t ((this instanceof CNSControllerServlet) ? (\" CNSCQSTimeMS=\" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : \"\") +\n\t ((this instanceof CQSControllerServlet) ? (\" RedisTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : \"\") +\n\t (user != null ? \" user_name=\" + user.getUserName() : \"\")\n\t ); \n }\n } catch (Exception ex) {\n \tlong ts2 = System.currentTimeMillis();\n logger.error(\n \t\t\"event=handleRequest status=failed client_ip=\" + request.getRemoteAddr() + \" action=\" + action + \" responseTimeMS=\" + (ts2-ts1) + \n (request.getParameter(\"TopicArn\") != null ? \" topic_arn=\" + request.getParameter(\"TopicArn\") : \"\") +\n (request.getParameter(\"SubscriptionArn\") != null ? \" subscription_arn=\" + request.getParameter(\"SubscriptionArn\") : \"\") +\n (request.getParameter(\"Label\") != null ? \" label=\" + request.getParameter(\"Label\") : \"\") +\n (request.getParameter(\"NextToken\") != null ? \" next_token=\" + request.getParameter(\"NextToken\") : \"\") +\n (request.getParameter(\"Name\") != null ? \" name=\" + request.getParameter(\"Name\") : \"\") +\n (request.getParameter(\"Token\") != null ? \" token=\" + request.getParameter(\"Token\") : \"\") +\n (request.getParameter(\"Endpoint\") != null ? \" endpoint=\" + request.getParameter(\"Endpoint\") : \"\") +\n (request.getParameter(\"Protocol\") != null ? \" protocol=\" + request.getParameter(\"Protocol\") : \"\") +\n (request.getParameter(\"ReceiptHandle\") != null ? \" receipt_handle=\" + request.getParameter(\"ReceiptHandle\") : \"\") +\n (request.getParameter(\"VisibilityTimeout\") != null ? \" visibility_timeout=\" + request.getParameter(\"VisibilityTimeout\") : \"\") +\n (request.getParameter(\"QueueName\") != null ? \" queue_name=\" + request.getParameter(\"QueueName\") : \"\") +\n (request.getParameter(\"QueueNamePrefix\") != null ? \" queue_name_prefix=\" + request.getParameter(\"QueueNamePrefix\") : \"\") +\n (request.getParameter(\"DelaySeconds\") != null ? \" delay_seconds=\" + request.getParameter(\"DelaySeconds\") : \"\") +\n ((this instanceof CQSControllerServlet) ? (\" queue_url=\" + request.getRequestURL().toString()) : \"\") +\n \t\t\" CassandraTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + \n \" CassandraReadNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + \n \" CassandraWriteNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +\n ((this instanceof CNSControllerServlet) ? (\" CNSCQSTimeMS=\" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : \"\") +\n ((this instanceof CQSControllerServlet) ? (\" RedisTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : \"\") +\n (user != null ? \" user_name=\" + user.getUserName() : \"\"), ex\n ); \n int httpCode = CMBErrorCodes.InternalError.getHttpCode();\n String code = CMBErrorCodes.InternalError.getCMBCode();\n String message = \"There is an internal problem with CMB\";\n if (ex instanceof CMBException) {\n httpCode = ((CMBException) ex).getHttpCode();\n code = ((CMBException) ex).getCMBCode();\n message = ex.getMessage();\n }\n String errXml = createErrorResponse(code, message);\n response.setStatus(httpCode);\n response.getWriter().println(errXml);\n } finally {\n valueAccumulator.deleteAllCounters();\n }\n }\n", "output": " private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { \n User user = null;\n String action = request.getParameter(\"Action\");\n long ts1 = System.currentTimeMillis();\n try {\n valueAccumulator.initializeAllCounters();\n \trequestInit();\n response.setContentType(\"text/xml\");\n if (!isValidAction(action)) {\n throw new CMBException(CMBErrorCodes.InvalidAction, action + \" is not a valid action\");\n }\n if (isAuthenticationRequired(action)) {\n user = authModule.authenticateByRequest(request);\n } else {\n user = null;\n }\n long ts3 = System.currentTimeMillis();\n valueAccumulator.addToCounter(AccumulatorName.CMBControllerPreHandleAction, (ts3 - ts1));\n boolean actionPerformed = handleAction(action, user, request, response);\n response.setStatus(200);\n long ts2 = System.currentTimeMillis();\n if (action != null && action.equals(\"ReceiveMessage\") && !actionPerformed && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {\n } else if (action != null && action.equals(\"GetQueueUrl\") && user != null && user.getUserName().equals(CMBProperties.getInstance().getCnsUserName())) {\n } else {\n\t logger.info(\n\t \t\t\"event=handleRequest status=success client_ip=\" + request.getRemoteAddr() + \" action=\" + action + \" responseTimeMS=\" + (ts2-ts1) + \n\t (request.getParameter(\"TopicArn\") != null ? \" topic_arn=\" + request.getParameter(\"TopicArn\") : \"\") +\n\t (request.getParameter(\"SubscriptionArn\") != null ? \" subscription_arn=\" + request.getParameter(\"SubscriptionArn\") : \"\") +\n\t (request.getParameter(\"Label\") != null ? \" label=\" + request.getParameter(\"Label\") : \"\") +\n\t (request.getParameter(\"NextToken\") != null ? \" next_token=\" + request.getParameter(\"NextToken\") : \"\") +\n\t (request.getParameter(\"Name\") != null ? \" name=\" + request.getParameter(\"Name\") : \"\") +\n\t (request.getParameter(\"Token\") != null ? \" token=\" + request.getParameter(\"Token\") : \"\") +\n\t (request.getParameter(\"Endpoint\") != null ? \" endpoint=\" + request.getParameter(\"Endpoint\") : \"\") +\n\t (request.getParameter(\"Protocol\") != null ? \" protocol=\" + request.getParameter(\"Protocol\") : \"\") +\n\t (request.getParameter(\"ReceiptHandle\") != null ? \" receipt_handle=\" + request.getParameter(\"ReceiptHandle\") : \"\") +\n\t (request.getParameter(\"VisibilityTimeout\") != null ? \" visibility_timeout=\" + request.getParameter(\"VisibilityTimeout\") : \"\") +\n\t (request.getParameter(\"QueueName\") != null ? \" queue_name=\" + request.getParameter(\"QueueName\") : \"\") +\n\t (request.getParameter(\"QueueNamePrefix\") != null ? \" queue_name_prefix=\" + request.getParameter(\"QueueNamePrefix\") : \"\") +\n\t (request.getParameter(\"DelaySeconds\") != null ? \" delay_seconds=\" + request.getParameter(\"DelaySeconds\") : \"\") +\n\t ((this instanceof CQSControllerServlet) ? (\" queue_url=\" + request.getRequestURL()) : \"\") +\n\t \t\t\" CassandraTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + \n\t \" CassandraReadNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + \n\t \" CassandraWriteNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +\n\t ((this instanceof CNSControllerServlet) ? (\" CNSCQSTimeMS=\" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : \"\") +\n\t ((this instanceof CQSControllerServlet) ? (\" RedisTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : \"\") +\n\t (user != null ? \" user_name=\" + user.getUserName() : \"\")\n\t ); \n }\n } catch (Exception ex) {\n \tlong ts2 = System.currentTimeMillis();\n logger.error(\n \t\t\"event=handleRequest status=failed client_ip=\" + request.getRemoteAddr() + \" action=\" + action + \" responseTimeMS=\" + (ts2-ts1) + \n (request.getParameter(\"TopicArn\") != null ? \" topic_arn=\" + request.getParameter(\"TopicArn\") : \"\") +\n (request.getParameter(\"SubscriptionArn\") != null ? \" subscription_arn=\" + request.getParameter(\"SubscriptionArn\") : \"\") +\n (request.getParameter(\"Label\") != null ? \" label=\" + request.getParameter(\"Label\") : \"\") +\n (request.getParameter(\"NextToken\") != null ? \" next_token=\" + request.getParameter(\"NextToken\") : \"\") +\n (request.getParameter(\"Name\") != null ? \" name=\" + request.getParameter(\"Name\") : \"\") +\n (request.getParameter(\"Token\") != null ? \" token=\" + request.getParameter(\"Token\") : \"\") +\n (request.getParameter(\"Endpoint\") != null ? \" endpoint=\" + request.getParameter(\"Endpoint\") : \"\") +\n (request.getParameter(\"Protocol\") != null ? \" protocol=\" + request.getParameter(\"Protocol\") : \"\") +\n (request.getParameter(\"ReceiptHandle\") != null ? \" receipt_handle=\" + request.getParameter(\"ReceiptHandle\") : \"\") +\n (request.getParameter(\"VisibilityTimeout\") != null ? \" visibility_timeout=\" + request.getParameter(\"VisibilityTimeout\") : \"\") +\n (request.getParameter(\"QueueName\") != null ? \" queue_name=\" + request.getParameter(\"QueueName\") : \"\") +\n (request.getParameter(\"QueueNamePrefix\") != null ? \" queue_name_prefix=\" + request.getParameter(\"QueueNamePrefix\") : \"\") +\n (request.getParameter(\"DelaySeconds\") != null ? \" delay_seconds=\" + request.getParameter(\"DelaySeconds\") : \"\") +\n ((this instanceof CQSControllerServlet) ? (\" queue_url=\" + request.getRequestURL()) : \"\") +\n \t\t\" CassandraTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.CassandraTime) + \n \" CassandraReadNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraRead) + \n \" CassandraWriteNum=\" + valueAccumulator.getCounter(AccumulatorName.CassandraWrite) +\n ((this instanceof CNSControllerServlet) ? (\" CNSCQSTimeMS=\" + CMBControllerServlet.valueAccumulator.getCounter(AccumulatorName.CNSCQSTime)) : \"\") +\n ((this instanceof CQSControllerServlet) ? (\" RedisTimeMS=\" + valueAccumulator.getCounter(AccumulatorName.RedisTime)) : \"\") +\n (user != null ? \" user_name=\" + user.getUserName() : \"\"), ex\n ); \n int httpCode = CMBErrorCodes.InternalError.getHttpCode();\n String code = CMBErrorCodes.InternalError.getCMBCode();\n String message = \"There is an internal problem with CMB\";\n if (ex instanceof CMBException) {\n httpCode = ((CMBException) ex).getHttpCode();\n code = ((CMBException) ex).getCMBCode();\n message = ex.getMessage();\n }\n String errXml = createErrorResponse(code, message);\n response.setStatus(httpCode);\n response.getWriter().println(errXml);\n } finally {\n valueAccumulator.deleteAllCounters();\n }\n }\n"} {"input": "\tpublic static Set findApplicable(HttpServletRequest request, boolean instructorPrefOnly, boolean examPref) throws Exception {\n \tUser user = Web.getUser(request.getSession());\n \tSession session = Session.getCurrentAcadSession(user);\n \tTimetableManager mgr = TimetableManager.getManager(user);\n \tif (user.isAdmin()) return findAll(instructorPrefOnly, examPref);\n \tTreeSet ret = new TreeSet();\n \tfor (Iterator i=findAll(instructorPrefOnly,examPref).iterator();i.hasNext();) {\n \t\tDistributionType dt = (DistributionType)i.next();\n \t\tSet depts = dt.getDepartments(session.getUniqueId());\n \t\tif (depts.isEmpty()) {\n \t\t\tret.add(dt);\n \t\t} else {\n \t\t\tboolean contains = false;\n \t\t\tfor (Iterator j=mgr.getDepartments().iterator();!contains && j.hasNext();) {\n \t\t\t\tDepartment d = (Department)j.next();\n \t\t\t\tif (depts.contains(d)) contains = true; \n \t\t\t}\n \t\t\tif (contains)\n \t\t\t\tret.add(dt);\n \t\t}\n \t}\n \treturn ret;\n }\n", "output": "\tpublic static Set findApplicable(HttpServletRequest request, boolean instructorPrefOnly, boolean examPref) throws Exception {\n \tUser user = Web.getUser(request.getSession());\n \tSession session = Session.getCurrentAcadSession(user);\n \tTimetableManager mgr = TimetableManager.getManager(user);\n \tif (user.isAdmin()) return findAll(instructorPrefOnly, examPref);\n \tTreeSet ret = new TreeSet();\n \tfor (Iterator i=findAll(instructorPrefOnly,examPref).iterator();i.hasNext();) {\n \t\tDistributionType dt = (DistributionType)i.next();\n \t\tSet depts = dt.getDepartments(session==null?null:session.getUniqueId());\n \t\tif (depts.isEmpty()) {\n \t\t\tret.add(dt);\n \t\t} else {\n \t\t\tboolean contains = false;\n \t\t\tfor (Iterator j=mgr.getDepartments().iterator();!contains && j.hasNext();) {\n \t\t\t\tDepartment d = (Department)j.next();\n \t\t\t\tif (depts.contains(d)) contains = true; \n \t\t\t}\n \t\t\tif (contains)\n \t\t\t\tret.add(dt);\n \t\t}\n \t}\n \treturn ret;\n }\n"} {"input": " public List<Path> generate() throws IOException {\n List<Path> paths = new ArrayList<>();\n Map<String, List<Tick>> demomap = new LinkedHashMap<>();\n Map<String, String> peeknext = new LinkedHashMap<>();\n String previous = null;\n for (Tick tick : ticklist) {\n List<Tick> ticks;\n if (!demomap.containsKey(tick.getDemoname())) {\n ticks = new ArrayList<>();\n demomap.put(tick.getDemoname(), ticks);\n } else {\n ticks = demomap.get(tick.getDemoname());\n }\n ticks.add(tick);\n if (previous != null) {\n if (!peeknext.containsKey(previous) && !previous.equals(tick.getDemoname())) {\n peeknext.put(previous, tick.getDemoname());\n }\n }\n previous = tick.getDemoname();\n }\n for (Entry<String, List<Tick>> e : demomap.entrySet()) {\n String demo = e.getKey();\n log.finer(\"creating vdm for demo: \" + demo);\n List<String> lines = new ArrayList<>();\n lines.add(\"demoactions\\n{\");\n int count = 1;\n int previousEndTick = 0;\n for (Tick tick : e.getValue()) {\n lines.add(segment(count++, \"SkipAhead\", \"skip\",\n \"starttick \\\"\" + (previousEndTick + 1) + \"\\\"\",\n \"skiptotick \\\"\" + (tick.getStart() - 1) + \"\\\"\"));\n lines.add(segment(count++, \"PlayCommands\", \"startrec\",\n \"commands \\\"startrecording\\\"\"));\n lines.add(segment(count++, \"PlayCommands\", \"stoprec\",\n \"starttick \\\"\" + tick.getEnd() + \"\\\"\",\n \"commands \\\"stoprecording\\\"\"));\n previousEndTick = tick.getEnd();\n }\n String nextdemo = peeknext.get(demo);\n if (nextdemo != null) {\n lines.add(segment(count++, \"PlayCommands\", \"nextdem\",\n \"starttick \\\"\" + (previousEndTick + 1) + \"\\\"\",\n \"commands \\\"playdemo \" + nextdemo + \"\\\"\"));\n } else {\n lines.add(segment(count++, \"PlayCommands\", \"stopdem\",\n \"starttick \\\"\" + (previousEndTick + 1) + \"\\\"\",\n \"commands \\\"stopdemo\\\"\"));\n }\n lines.add(\"}\\n\");\n Path added = Files.write(\n tfpath.resolve(demo.substring(0, demo.indexOf(\".dem\")) + \".vdm\"), lines,\n Charset.defaultCharset());\n paths.add(added);\n log.fine(\"VDM file written to \" + added);\n }\n return paths;\n }\n", "output": " public List<Path> generate() throws IOException {\n List<Path> paths = new ArrayList<>();\n Map<String, List<Tick>> demomap = new LinkedHashMap<>();\n Map<String, String> peeknext = new LinkedHashMap<>();\n String previous = null;\n for (Tick tick : ticklist) {\n List<Tick> ticks;\n if (!demomap.containsKey(tick.getDemoname())) {\n ticks = new ArrayList<>();\n demomap.put(tick.getDemoname(), ticks);\n } else {\n ticks = demomap.get(tick.getDemoname());\n }\n ticks.add(tick);\n if (previous != null) {\n if (!peeknext.containsKey(previous) && !previous.equals(tick.getDemoname())) {\n peeknext.put(previous, tick.getDemoname());\n }\n }\n previous = tick.getDemoname();\n }\n for (Entry<String, List<Tick>> e : demomap.entrySet()) {\n String demo = e.getKey();\n log.finer(\"creating vdm for demo: \" + demo);\n List<String> lines = new ArrayList<>();\n lines.add(\"demoactions\\n{\");\n int count = 1;\n int previousEndTick = 0;\n for (Tick tick : e.getValue()) {\n lines.add(segment(count++, \"SkipAhead\", \"skip\",\n \"starttick \\\"\" + (previousEndTick + 1) + \"\\\"\",\n \"skiptotick \\\"\" + (tick.getStart() - 1) + \"\\\"\"));\n lines.add(segment(count++, \"PlayCommands\", \"startrec\",\n \"starttick \\\"\" + tick.getStart() + \"\\\"\",\n \"commands \\\"startrecording\\\"\"));\n lines.add(segment(count++, \"PlayCommands\", \"stoprec\",\n \"starttick \\\"\" + tick.getEnd() + \"\\\"\",\n \"commands \\\"stoprecording\\\"\"));\n previousEndTick = tick.getEnd();\n }\n String nextdemo = peeknext.get(demo);\n if (nextdemo != null) {\n lines.add(segment(count++, \"PlayCommands\", \"nextdem\",\n \"starttick \\\"\" + (previousEndTick + 1) + \"\\\"\",\n \"commands \\\"playdemo \" + nextdemo + \"\\\"\"));\n } else {\n lines.add(segment(count++, \"PlayCommands\", \"stopdem\",\n \"starttick \\\"\" + (previousEndTick + 1) + \"\\\"\",\n \"commands \\\"stopdemo\\\"\"));\n }\n lines.add(\"}\\n\");\n Path added = Files.write(\n tfpath.resolve(demo.substring(0, demo.indexOf(\".dem\")) + \".vdm\"), lines,\n Charset.defaultCharset());\n paths.add(added);\n log.fine(\"VDM file written to \" + added);\n }\n return paths;\n }\n"} {"input": "\tpublic static ProjectData getGlobalProjectData()\n\t{\n\t\tif (globalProjectData != null)\n\t\t\treturn globalProjectData;\n\t\tFile dataFile = CoverageDataFileHandler.getDefaultDataFile();\n\t\tif (dataFile.isFile())\n\t\t{\n\t\t\tglobalProjectData = CoverageDataFileHandler\n\t\t\t\t\t.loadCoverageData(dataFile);\n\t\t}\n\t\tif (globalProjectData == null)\n\t\t{\n\t\t\tSystem.out.println(\"Cobertura: Coverage data file \"\n\t\t\t\t\t\t\t+ dataFile.getAbsolutePath()\n\t\t\t\t\t\t\t+ \" either does not exist or is not readable. Creating a new data file.\");\n\t\t\tglobalProjectData = new ProjectData();\n\t\t\tsaveTimer = new SaveTimer();\n\t\t\tRuntime.getRuntime().addShutdownHook(new Thread(saveTimer));\n\t\t}\n\t\treturn globalProjectData;\n\t}\n", "output": "\tpublic static ProjectData getGlobalProjectData()\n\t{\n\t\tif (globalProjectData != null)\n\t\t\treturn globalProjectData;\n\t\tFile dataFile = CoverageDataFileHandler.getDefaultDataFile();\n\t\tif (dataFile.isFile())\n\t\t{\n\t\t\tglobalProjectData = CoverageDataFileHandler\n\t\t\t\t\t.loadCoverageData(dataFile);\n\t\t}\n\t\tif (globalProjectData == null)\n\t\t{\n\t\t\tSystem.out.println(\"Cobertura: Coverage data file \"\n\t\t\t\t\t\t\t+ dataFile.getAbsolutePath()\n\t\t\t\t\t\t\t+ \" either does not exist or is not readable. Creating a new data file.\");\n\t\t\tglobalProjectData = new ProjectData();\n\t\t}\n\t\tsaveTimer = new SaveTimer();\n\t\tRuntime.getRuntime().addShutdownHook(new Thread(saveTimer));\n\t\treturn globalProjectData;\n\t}\n"} {"input": "\tpublic static void main(String[] args) {\n\t\tSystem.out.println(\"prueba trabajo 1\");\n\t}\n", "output": "\tpublic static void main(String[] args) {\n\t\tSystem.out.println(\"prueba trabajo 1qwdqwdqwd\");\n\t}\n"} {"input": " protected void initField(com.redhat.ceylon.compiler.typechecker.model.Declaration decl, java.lang.Class<?> javaClass, java.lang.Class<?> getterReturnType, Object instance) {\n if(decl instanceof JavaBeanValue){\n String setterName = ((JavaBeanValue) decl).getSetterName();\n try {\n Method m = javaClass.getMethod(setterName, getterReturnType);\n setter = MethodHandles.lookup().unreflect(m);\n setter = setter.bindTo(instance);\n setter = setter.asType(MethodType.methodType(void.class, getterReturnType));\n setter = MethodHandleUtil.unboxArguments(setter, 0, 1, new java.lang.Class[]{getterReturnType});\n } catch (NoSuchMethodException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (SecurityException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (IllegalAccessException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n }\n }else if(decl instanceof LazyValue){\n String setterName = Naming.getSetterName(decl);\n try {\n Method m = javaClass.getMethod(setterName, getterReturnType);\n setter = MethodHandles.lookup().unreflect(m);\n setter = setter.asType(MethodType.methodType(void.class, getterReturnType));\n setter = MethodHandleUtil.unboxArguments(setter, 0, 0, new java.lang.Class[]{getterReturnType});\n } catch (NoSuchMethodException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (SecurityException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (IllegalAccessException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n }\n }else\n throw new RuntimeException(\"Unsupported attribute type: \"+decl);\n }\n", "output": " protected void initField(com.redhat.ceylon.compiler.typechecker.model.Declaration decl, java.lang.Class<?> javaClass, java.lang.Class<?> getterReturnType, Object instance) {\n if(decl instanceof JavaBeanValue){\n String setterName = ((JavaBeanValue) decl).getSetterName();\n try {\n Method m = javaClass.getMethod(setterName, getterReturnType);\n setter = MethodHandles.lookup().unreflect(m);\n setter = setter.bindTo(instance);\n setter = setter.asType(MethodType.methodType(void.class, getterReturnType));\n setter = MethodHandleUtil.unboxArguments(setter, 0, 0, new java.lang.Class[]{getterReturnType});\n } catch (NoSuchMethodException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (SecurityException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (IllegalAccessException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n }\n }else if(decl instanceof LazyValue){\n String setterName = Naming.getSetterName(decl);\n try {\n Method m = javaClass.getMethod(setterName, getterReturnType);\n setter = MethodHandles.lookup().unreflect(m);\n setter = setter.asType(MethodType.methodType(void.class, getterReturnType));\n setter = MethodHandleUtil.unboxArguments(setter, 0, 0, new java.lang.Class[]{getterReturnType});\n } catch (NoSuchMethodException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (SecurityException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n } catch (IllegalAccessException e) {\n throw new RuntimeException(\"Failed to find setter method \"+setterName+\" for: \"+decl, e);\n }\n }else\n throw new RuntimeException(\"Unsupported attribute type: \"+decl);\n }\n"} {"input": " protected static JPanel customFileChooser(final JDialog dlg, final JFileChooser chooser, final Action action) {\n\tInsets insets = null;\n\tif (chooser.getBorder() instanceof EmptyBorder)\n\t insets = ((EmptyBorder)chooser.getBorder()).getBorderInsets();\n\tchooser.setControlButtonsAreShown(false);\n\tchooser.setApproveButtonText((String)action.getValue(Action.NAME));\n\tJPanel panel = new JPanel();\n\tpanel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));\n\tpanel.add(chooser);\n\tJPanel contentpane = new JPanel();\n\tcontentpane.setLayout(new BoxLayout(contentpane, BoxLayout.Y_AXIS));\n\tif (insets!=null) contentpane.setBorder(BorderFactory.createEmptyBorder(0, insets.left, 0, insets.right));\n\tpanel.add(contentpane);\n\tJPanel btns = new JPanel();\n\tif (insets!=null) btns.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));\n\tbtns.add(Box.createHorizontalGlue());\n\tbtns.setLayout(new BoxLayout(btns, BoxLayout.X_AXIS));\n\tfinal JButton activate = new JButton(new AbstractAction((String)action.getValue(Action.NAME)) {\n\t public void actionPerformed(ActionEvent e) {\n\t\tchooser.approveSelection();\n\t }\n\t});\n\tbtns.add(activate);\n\tfinal JButton cancel = new JButton(new AbstractAction(\"Cancel\") {\n\t public void actionPerformed(ActionEvent e) {\n\t\tchooser.cancelSelection();\n\t }\n\t});\n\tbtns.add(cancel);\n\tpanel.add(btns);\n\tdlg.getContentPane().add(panel);\n\tdlg.getRootPane().setDefaultButton(activate);\n\tdlg.setModal(true);\n\tchooser.addActionListener(new ActionListener() {\n\t public void actionPerformed(ActionEvent e) {\n\t\tif (JFileChooser.APPROVE_SELECTION.equals(e.getActionCommand())) {\n\t\t if (chooser.getUI() instanceof BasicFileChooserUI) {\n\t\t BasicFileChooserUI ui = (BasicFileChooserUI)chooser.getUI();\n\t\t chooser.setSelectedFile(new File(ui.getFileName()));\n\t\t }\n\t\t action.actionPerformed(e);\n\t\t}\n\t\tdlg.removeAll();\n\t\tdlg.dispose();\n\t }\n\t});\n\treturn contentpane;\n }\n", "output": " protected static JPanel customFileChooser(final JDialog dlg, final JFileChooser chooser, final Action action) {\n\tInsets insets = null;\n\tif (chooser.getBorder() instanceof EmptyBorder)\n\t insets = ((EmptyBorder)chooser.getBorder()).getBorderInsets();\n\tchooser.setControlButtonsAreShown(false);\n\tchooser.setApproveButtonText((String)action.getValue(Action.NAME));\n\tJPanel panel = new JPanel();\n\tpanel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));\n\tpanel.add(chooser);\n\tJPanel contentpane = new JPanel();\n\tcontentpane.setLayout(new BoxLayout(contentpane, BoxLayout.Y_AXIS));\n\tif (insets!=null) contentpane.setBorder(BorderFactory.createEmptyBorder(0, insets.left, 0, insets.right));\n\tpanel.add(contentpane);\n\tJPanel btns = new JPanel();\n\tif (insets!=null) btns.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));\n\tbtns.add(Box.createHorizontalGlue());\n\tbtns.setLayout(new BoxLayout(btns, BoxLayout.X_AXIS));\n\tfinal JButton activate = new JButton(new AbstractAction((String)action.getValue(Action.NAME)) {\n\t public void actionPerformed(ActionEvent e) {\n\t\tchooser.approveSelection();\n\t }\n\t});\n\tbtns.add(activate);\n\tfinal JButton cancel = new JButton(new AbstractAction(\"Cancel\") {\n\t public void actionPerformed(ActionEvent e) {\n\t\tchooser.cancelSelection();\n\t }\n\t});\n\tbtns.add(cancel);\n\tpanel.add(btns);\n\tdlg.getContentPane().add(panel);\n\tdlg.getRootPane().setDefaultButton(activate);\n\tdlg.setModal(true);\n\tchooser.addActionListener(new ActionListener() {\n\t public void actionPerformed(ActionEvent e) {\n\t\tif (JFileChooser.APPROVE_SELECTION.equals(e.getActionCommand())) {\n\t\t if (chooser.getUI() instanceof BasicFileChooserUI) {\n\t\t BasicFileChooserUI ui = (BasicFileChooserUI)chooser.getUI();\n\t\t File f = new File(chooser.getCurrentDirectory(), ui.getFileName());\n\t\t chooser.setSelectedFile(f);\n\t\t }\n\t\t action.actionPerformed(e);\n\t\t}\n\t\tdlg.removeAll();\n\t\tdlg.dispose();\n\t }\n\t});\n\treturn contentpane;\n }\n"} {"input": "\tpublic void handle(Willie bot, Channel channel, User sender, String[] args){\n\t\tif(args.length <= 0){\n\t\t\tchannel.sendMessage(\"(\" + sender.getNick() + \") Usage: !utime <time>[s|ms] [timezone]\");\n\t\t}else{\n\t\t\tString time = args[0];\n\t\t\tString timezone = \"GMT\";\n\t\t\tif(args.length > 1){\n\t\t\t\ttimezone = args[1];\n\t\t\t}\n\t\t\tlong realTime = System.currentTimeMillis();\n\t\t\tString lowerTime = time.toLowerCase();\n\t\t\tlong multiplier = 1000;\n\t\t\tif(lowerTime.endsWith(\"ms\")){\n\t\t\t\ttime = time.substring(0, time.length() - 2);\n\t\t\t\tmultiplier = 1;\n\t\t\t}else if(lowerTime.endsWith(\"s\")){\n\t\t\t\ttime = time.substring(0, time.length() - 1);\n\t\t\t}\n\t\t\tif(!time.equalsIgnoreCase(\"now\")){\n\t\t\t\ttry{\n\t\t\t\t\trealTime = Long.parseLong(time);\n\t\t\t\t}catch(NumberFormatException e){\n\t\t\t\t\tchannel.sendMessage(\"(\" + sender.getNick() + \") [Invalid time format] Usage: !utime <time>[s|ms] [timezone]\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\trealTime = realTime * multiplier;\n\t\t\tDate d = new Date(realTime);\n\t\t\tString formatted = new String();\n\t\t\tDateFormat dateFormat = DateFormat.getDateTimeInstance();\n\t\t\tTimeZone tz = TimeZone.getTimeZone(timezone);\n\t\t\tdateFormat.setTimeZone(tz);\n\t\t\tformatted = dateFormat.format(d) + \" \" + tz.getDisplayName();\n\t\t\tchannel.sendMessage(\"(\" + sender.getNick() + \") \" + formatted);\n\t\t}\n\t}\n", "output": "\tpublic void handle(Willie bot, Channel channel, User sender, String[] args){\n\t\tif(args.length <= 0){\n\t\t\tchannel.sendMessage(\"(\" + sender.getNick() + \") Usage: !utime <time>[s|ms] [timezone]\");\n\t\t}else{\n\t\t\tString time = args[0];\n\t\t\tString timezone = \"GMT\";\n\t\t\tif(args.length > 1){\n\t\t\t\ttimezone = args[1];\n\t\t\t}\n\t\t\tlong realTime = System.currentTimeMillis();\n\t\t\tString lowerTime = time.toLowerCase();\n\t\t\tlong multiplier = 1000;\n\t\t\tif(lowerTime.endsWith(\"ms\")){\n\t\t\t\ttime = time.substring(0, time.length() - 2);\n\t\t\t\tmultiplier = 1;\n\t\t\t}else if(lowerTime.endsWith(\"s\")){\n\t\t\t\ttime = time.substring(0, time.length() - 1);\n\t\t\t}\n\t\t\tif(!time.equalsIgnoreCase(\"now\")){\n\t\t\t\ttry{\n\t\t\t\t\trealTime = Long.parseLong(time);\n\t\t\t\t\tmultiplier = 1;\n\t\t\t\t}catch(NumberFormatException e){\n\t\t\t\t\tchannel.sendMessage(\"(\" + sender.getNick() + \") [Invalid time format] Usage: !utime <time>[s|ms] [timezone]\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\trealTime = realTime * multiplier;\n\t\t\tDate d = new Date(realTime);\n\t\t\tString formatted = new String();\n\t\t\tDateFormat dateFormat = DateFormat.getDateTimeInstance();\n\t\t\tTimeZone tz = TimeZone.getTimeZone(timezone);\n\t\t\tdateFormat.setTimeZone(tz);\n\t\t\tformatted = dateFormat.format(d) + \" \" + tz.getDisplayName();\n\t\t\tchannel.sendMessage(\"(\" + sender.getNick() + \") \" + formatted);\n\t\t}\n\t}\n"} {"input": "\tpublic void test() {\n\t\tFileFinder2 finder = new FileFinder2();\n\t\tArrayList<File> files = finder.getAllFiles(new File(\"C:/z/pleiades/workspace/S3ParallelUploader/testdirs/a\"));\n\t\tassertThat(files.size() , is(1));\n\t}\n", "output": "\tpublic void test() {\n\t\tArrayList<File> files = FileFinder.find(\"C:/z/pleiades/workspace/S3ParallelUploader/testdirs/a\");\n\t\tassertThat(files.size() , is(2));\n\t}\n"} {"input": " public ID3v24Tag(AbstractTag mp3tag)\n {\n logger.info(\"Creating tag from a tag of a different version\");\n if (mp3tag != null)\n {\n if ((mp3tag instanceof ID3v24Tag == true))\n {\n throw new UnsupportedOperationException(\"Copy Constructor not called. Please type cast the argument\");\n }\n else if (mp3tag instanceof AbstractID3v2Tag)\n {\n copyPrimitives((AbstractID3v2Tag) mp3tag);\n copyFrames((AbstractID3v2Tag) mp3tag);\n }\n else if (mp3tag instanceof ID3v1Tag)\n {\n ID3v1Tag id3tag = (ID3v1Tag) mp3tag;\n ID3v24Frame newFrame;\n AbstractID3v2FrameBody newBody;\n if (id3tag.title.length() > 0)\n {\n newBody = new FrameBodyTIT2((byte) 0, id3tag.title);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_TITLE);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.artist.length() > 0)\n {\n newBody = new FrameBodyTPE1((byte) 0, id3tag.artist);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_ARTIST);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.album.length() > 0)\n {\n newBody = new FrameBodyTALB((byte) 0, id3tag.album);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_ALBUM);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.year.length() > 0)\n {\n newBody = new FrameBodyTDRC((byte) 0, id3tag.year);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_YEAR);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.comment.length() > 0)\n {\n newBody = new FrameBodyCOMM((byte) 0, \"ENG\", \"\", id3tag.comment);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_COMMENT);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.genre >= 0)\n {\n String genre = \"(\" + Byte.toString(id3tag.genre) + \") \" +\n GenreTypes.getInstanceOf().getValueForId(id3tag.genre);\n newBody = new FrameBodyTCON((byte) 0, genre);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_GENRE);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (mp3tag instanceof ID3v11Tag)\n {\n ID3v11Tag id3tag2 = (ID3v11Tag) mp3tag;\n if (id3tag2.track > 0)\n {\n newBody = new FrameBodyTRCK((byte) 0, Byte.toString(id3tag2.track));\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_TRACK);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n }\n }\n else if (mp3tag instanceof AbstractLyrics3)\n {\n Lyrics3v2 lyric;\n if (mp3tag instanceof Lyrics3v2)\n {\n lyric = new Lyrics3v2((Lyrics3v2) mp3tag);\n }\n else\n {\n lyric = new Lyrics3v2(mp3tag);\n }\n Iterator iterator = lyric.iterator();\n Lyrics3v2Field field;\n ID3v24Frame newFrame;\n while (iterator.hasNext())\n {\n try\n {\n field = (Lyrics3v2Field) iterator.next();\n newFrame = new ID3v24Frame(field);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n catch (InvalidTagException ex)\n {\n logger.warning(\"Unable to convert Lyrics3 to v24 Frame:Frame Identifier\");\n }\n }\n }\n }\n }\n", "output": " public ID3v24Tag(AbstractTag mp3tag)\n {\n logger.info(\"Creating tag from a tag of a different version\");\n if (mp3tag != null)\n {\n if ((mp3tag instanceof ID3v24Tag == true))\n {\n throw new UnsupportedOperationException(\"Copy Constructor not called. Please type cast the argument\");\n }\n else if (mp3tag instanceof AbstractID3v2Tag)\n {\n copyPrimitives((AbstractID3v2Tag) mp3tag);\n copyFrames((AbstractID3v2Tag) mp3tag);\n }\n else if (mp3tag instanceof ID3v1Tag)\n {\n ID3v1Tag id3tag = (ID3v1Tag) mp3tag;\n ID3v24Frame newFrame;\n AbstractID3v2FrameBody newBody;\n if (id3tag.title.length() > 0)\n {\n newBody = new FrameBodyTIT2((byte) 0, id3tag.title);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_TITLE);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.artist.length() > 0)\n {\n newBody = new FrameBodyTPE1((byte) 0, id3tag.artist);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_ARTIST);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.album.length() > 0)\n {\n newBody = new FrameBodyTALB((byte) 0, id3tag.album);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_ALBUM);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.year.length() > 0)\n {\n newBody = new FrameBodyTDRC((byte) 0, id3tag.year);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_YEAR);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (id3tag.comment.length() > 0)\n {\n newBody = new FrameBodyCOMM((byte) 0, \"ENG\", \"\", id3tag.comment);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_COMMENT);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if ((id3tag.genre & 0xff) >= 0)\n {\n String genre = \"(\" + Byte.toString(id3tag.genre) + \") \" +\n GenreTypes.getInstanceOf().getValueForId(id3tag.genre);\n newBody = new FrameBodyTCON((byte) 0, genre);\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_GENRE);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n if (mp3tag instanceof ID3v11Tag)\n {\n ID3v11Tag id3tag2 = (ID3v11Tag) mp3tag;\n if (id3tag2.track > 0)\n {\n newBody = new FrameBodyTRCK((byte) 0, Byte.toString(id3tag2.track));\n newFrame = new ID3v24Frame(ID3v24Frames.FRAME_ID_TRACK);\n newFrame.setBody(newBody);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n }\n }\n else if (mp3tag instanceof AbstractLyrics3)\n {\n Lyrics3v2 lyric;\n if (mp3tag instanceof Lyrics3v2)\n {\n lyric = new Lyrics3v2((Lyrics3v2) mp3tag);\n }\n else\n {\n lyric = new Lyrics3v2(mp3tag);\n }\n Iterator iterator = lyric.iterator();\n Lyrics3v2Field field;\n ID3v24Frame newFrame;\n while (iterator.hasNext())\n {\n try\n {\n field = (Lyrics3v2Field) iterator.next();\n newFrame = new ID3v24Frame(field);\n frameMap.put(newFrame.getIdentifier(), newFrame);\n }\n catch (InvalidTagException ex)\n {\n logger.warning(\"Unable to convert Lyrics3 to v24 Frame:Frame Identifier\");\n }\n }\n }\n }\n }\n"} {"input": "\tpublic void createEdge(List<Point2D> edgePoints) {\n\t\tif (edgePoints == null || edgePoints.size() < 2)\n\t\t\treturn;\n\t\tMap<Point2D, IDataGraphNode> pointsOnBoundingBoxes = new HashMap<Point2D, IDataGraphNode>();\n\t\tfor (int i = 1; i < edgePoints.size(); i++) {\n\t\t\tPoint2D point1 = edgePoints.get(i - 1);\n\t\t\tPoint2D point2 = edgePoints.get(i);\n\t\t\tfor (IDataGraphNode node : dataGraph.getNodes()) {\n\t\t\t\tRectangle2D box = node.getBoundingBox();\n\t\t\t\tint code1 = box.outcode(point1);\n\t\t\t\tint code2 = box.outcode(point2);\n\t\t\t\tboolean isPoint1OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t.get(point1) == node);\n\t\t\t\tboolean isPoint2OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t.get(point2) == node);\n\t\t\t\tif (((code1 & code2) != 0)\n\t\t\t\t\t\t|| (code1 == 0 && !isPoint1OnBoundingBox)\n\t\t\t\t\t\t|| (code2 == 0 && !isPoint2OnBoundingBox)\n\t\t\t\t\t\t|| (isPoint1OnBoundingBox && isPoint2OnBoundingBox)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tPoint2D intersection1 = (isPoint1OnBoundingBox) ? (point1)\n\t\t\t\t\t\t: (calcIntersectionPoint(point1, point2, box, code1));\n\t\t\t\tPoint2D intersection2 = (isPoint2OnBoundingBox) ? (point2)\n\t\t\t\t\t\t: (calcIntersectionPoint(point2, point1, box, code2));\n\t\t\t\tif (intersection1 != null && intersection2 != null) {\n\t\t\t\t\tif (intersection1.getX() == intersection2.getX()\n\t\t\t\t\t\t\t&& intersection1.getY() == intersection2.getY()) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tPoint2D[] corners = new Point2D[4];\n\t\t\t\t\tcorners[0] = new Point2D.Double(box.getMinX(),\n\t\t\t\t\t\t\tbox.getMinY());\n\t\t\t\t\tcorners[1] = new Point2D.Double(box.getMaxX(),\n\t\t\t\t\t\t\tbox.getMinY());\n\t\t\t\t\tcorners[2] = new Point2D.Double(box.getMaxX(),\n\t\t\t\t\t\t\tbox.getMaxY());\n\t\t\t\t\tcorners[3] = new Point2D.Double(box.getMinX(),\n\t\t\t\t\t\t\tbox.getMaxY());\n\t\t\t\t\tdouble minDistance = Double.MAX_VALUE;\n\t\t\t\t\tPoint2D bendPoint = null;\n\t\t\t\t\tfor (int j = 0; j < 4; j++) {\n\t\t\t\t\t\tif ((corners[j].getX() == point1.getX()\n\t\t\t\t\t\t\t\t&& corners[j].getY() == point1.getY() && isPoint1OnBoundingBox)\n\t\t\t\t\t\t\t\t|| (corners[j].getX() == point2.getX() && corners[j]\n\t\t\t\t\t\t\t\t\t\t.getY() == point2.getY())\n\t\t\t\t\t\t\t\t&& isPoint2OnBoundingBox) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdouble currentSummedDistance = intersection1\n\t\t\t\t\t\t\t\t.distanceSq(corners[j])\n\t\t\t\t\t\t\t\t+ intersection2.distanceSq(corners[j]);\n\t\t\t\t\t\tif (currentSummedDistance < minDistance) {\n\t\t\t\t\t\t\tminDistance = currentSummedDistance;\n\t\t\t\t\t\t\tbendPoint = corners[j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (bendPoint == null) {\n\t\t\t\t\t\tSystem.out.println(\"null\");\n\t\t\t\t\t}\n\t\t\t\t\tboolean isPointAlreadyAdded = false;\n\t\t\t\t\tfor (Point2D point : edgePoints) {\n\t\t\t\t\t\tif (point.getX() == bendPoint.getX()\n\t\t\t\t\t\t\t\t&& point.getY() == bendPoint.getY()) {\n\t\t\t\t\t\t\tisPointAlreadyAdded = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (isPointAlreadyAdded) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tedgePoints.add(i, bendPoint);\n\t\t\t\t\tpointsOnBoundingBoxes.put(bendPoint, node);\n\t\t\t\t\ti--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int step = edgePoints.size() - 2; step >= 2; step--) {\n\t\t\tfor (int i = 0; i + step < edgePoints.size(); i++) {\n\t\t\t\tPoint2D point1 = edgePoints.get(i);\n\t\t\t\tPoint2D point2 = edgePoints.get(i + step);\n\t\t\t\tboolean hasIntersection = false;\n\t\t\t\tfor (IDataGraphNode node : dataGraph.getNodes()) {\n\t\t\t\t\tRectangle2D box = node.getBoundingBox();\n\t\t\t\t\tint code1 = box.outcode(point1);\n\t\t\t\t\tint code2 = box.outcode(point2);\n\t\t\t\t\tboolean isPoint1OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t\t.get(point1) == node);\n\t\t\t\t\tboolean isPoint2OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t\t.get(point2) == node);\n\t\t\t\t\tif ((code1 & code2) != 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif ((code1 == 0 && !isPoint1OnBoundingBox)\n\t\t\t\t\t\t\t|| (code2 == 0 && !isPoint2OnBoundingBox)\n\t\t\t\t\t\t\t|| (isPoint1OnBoundingBox && isPoint2OnBoundingBox)) {\n\t\t\t\t\t\thasIntersection = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tPoint2D intersection1 = (isPoint1OnBoundingBox) ? (point1)\n\t\t\t\t\t\t\t: (calcIntersectionPoint(point1, point2, box, code1));\n\t\t\t\t\tPoint2D intersection2 = (isPoint2OnBoundingBox) ? (point2)\n\t\t\t\t\t\t\t: (calcIntersectionPoint(point2, point1, box, code2));\n\t\t\t\t\tif (intersection1 == null || intersection2 == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (intersection1.distance(intersection2) < 0.000001\n\t\t\t\t\t\t\t&& (isPoint1OnBoundingBox || isPoint2OnBoundingBox)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\thasIntersection = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!hasIntersection) {\n\t\t\t\t\tfor (int j = i + 1; j < i + step; j++) {\n\t\t\t\t\t\tedgePoints.remove(i + 1);\n\t\t\t\t\t}\n\t\t\t\t\tstep = edgePoints.size() - 2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void createEdge(List<Point2D> edgePoints) {\n\t\tif (edgePoints == null || edgePoints.size() < 2)\n\t\t\treturn;\n\t\tMap<Point2D, IDataGraphNode> pointsOnBoundingBoxes = new HashMap<Point2D, IDataGraphNode>();\n\t\tfor (int i = 1; i < edgePoints.size(); i++) {\n\t\t\tPoint2D point1 = edgePoints.get(i - 1);\n\t\t\tPoint2D point2 = edgePoints.get(i);\n\t\t\tfor (IDataGraphNode node : dataGraph.getNodes()) {\n\t\t\t\tRectangle2D box = node.getBoundingBox();\n\t\t\t\tint code1 = box.outcode(point1);\n\t\t\t\tint code2 = box.outcode(point2);\n\t\t\t\tboolean isPoint1OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t.get(point1) == node);\n\t\t\t\tboolean isPoint2OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t.get(point2) == node);\n\t\t\t\tif (((code1 & code2) != 0)\n\t\t\t\t\t\t|| (code1 == 0 && !isPoint1OnBoundingBox)\n\t\t\t\t\t\t|| (code2 == 0 && !isPoint2OnBoundingBox)\n\t\t\t\t\t\t|| (isPoint1OnBoundingBox && isPoint2OnBoundingBox)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tPoint2D intersection1 = (isPoint1OnBoundingBox) ? (point1)\n\t\t\t\t\t\t: (calcIntersectionPoint(point1, point2, box, code1));\n\t\t\t\tPoint2D intersection2 = (isPoint2OnBoundingBox) ? (point2)\n\t\t\t\t\t\t: (calcIntersectionPoint(point2, point1, box, code2));\n\t\t\t\tif (intersection1 != null && intersection2 != null) {\n\t\t\t\t\tif (intersection1.getX() <= intersection2.getX() + 0.0000001\n\t\t\t\t\t\t\t&& intersection1.getX() >= intersection2.getX() - 0.0000001\n\t\t\t\t\t\t\t&& intersection1.getY() <= intersection2.getY() + 0.0000001\n\t\t\t\t\t\t\t&& intersection1.getY() >= intersection2.getY() - 0.0000001) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tPoint2D[] corners = new Point2D[4];\n\t\t\t\t\tcorners[0] = new Point2D.Double(box.getMinX(),\n\t\t\t\t\t\t\tbox.getMinY());\n\t\t\t\t\tcorners[1] = new Point2D.Double(box.getMaxX(),\n\t\t\t\t\t\t\tbox.getMinY());\n\t\t\t\t\tcorners[2] = new Point2D.Double(box.getMaxX(),\n\t\t\t\t\t\t\tbox.getMaxY());\n\t\t\t\t\tcorners[3] = new Point2D.Double(box.getMinX(),\n\t\t\t\t\t\t\tbox.getMaxY());\n\t\t\t\t\tdouble minDistance = Double.MAX_VALUE;\n\t\t\t\t\tPoint2D bendPoint = null;\n\t\t\t\t\tfor (int j = 0; j < 4; j++) {\n\t\t\t\t\t\tif ((corners[j].getX() == point1.getX()\n\t\t\t\t\t\t\t\t&& corners[j].getY() == point1.getY() && isPoint1OnBoundingBox)\n\t\t\t\t\t\t\t\t|| (corners[j].getX() == point2.getX() && corners[j]\n\t\t\t\t\t\t\t\t\t\t.getY() == point2.getY())\n\t\t\t\t\t\t\t\t&& isPoint2OnBoundingBox) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdouble currentSummedDistance = intersection1\n\t\t\t\t\t\t\t\t.distanceSq(corners[j])\n\t\t\t\t\t\t\t\t+ intersection2.distanceSq(corners[j]);\n\t\t\t\t\t\tif (currentSummedDistance < minDistance) {\n\t\t\t\t\t\t\tminDistance = currentSummedDistance;\n\t\t\t\t\t\t\tbendPoint = corners[j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (bendPoint == null) {\n\t\t\t\t\t\tSystem.out.println(\"null\");\n\t\t\t\t\t}\n\t\t\t\t\tboolean isPointAlreadyAdded = false;\n\t\t\t\t\tfor (Point2D point : edgePoints) {\n\t\t\t\t\t\tif (point.getX() == bendPoint.getX()\n\t\t\t\t\t\t\t\t&& point.getY() == bendPoint.getY()) {\n\t\t\t\t\t\t\tisPointAlreadyAdded = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (isPointAlreadyAdded) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tedgePoints.add(i, bendPoint);\n\t\t\t\t\tpointsOnBoundingBoxes.put(bendPoint, node);\n\t\t\t\t\ti--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int step = edgePoints.size() - 2; step >= 2; step--) {\n\t\t\tfor (int i = 0; i + step < edgePoints.size(); i++) {\n\t\t\t\tPoint2D point1 = edgePoints.get(i);\n\t\t\t\tPoint2D point2 = edgePoints.get(i + step);\n\t\t\t\tboolean hasIntersection = false;\n\t\t\t\tfor (IDataGraphNode node : dataGraph.getNodes()) {\n\t\t\t\t\tRectangle2D box = node.getBoundingBox();\n\t\t\t\t\tint code1 = box.outcode(point1);\n\t\t\t\t\tint code2 = box.outcode(point2);\n\t\t\t\t\tboolean isPoint1OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t\t.get(point1) == node);\n\t\t\t\t\tboolean isPoint2OnBoundingBox = (pointsOnBoundingBoxes\n\t\t\t\t\t\t\t.get(point2) == node);\n\t\t\t\t\tif ((code1 & code2) != 0) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif ((code1 == 0 && !isPoint1OnBoundingBox\n\t\t\t\t\t\t\t&& edgePoints.indexOf(point1) != 0 && edgePoints\n\t\t\t\t\t\t\t.indexOf(point1) != edgePoints.size() - 1)\n\t\t\t\t\t\t\t|| (code2 == 0 && !isPoint2OnBoundingBox\n\t\t\t\t\t\t\t\t\t&& edgePoints.indexOf(point2) != 0 && edgePoints\n\t\t\t\t\t\t\t\t\t.indexOf(point2) != edgePoints.size() - 1)\n\t\t\t\t\t\t\t|| (isPoint1OnBoundingBox && isPoint2OnBoundingBox)) {\n\t\t\t\t\t\thasIntersection = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tPoint2D intersection1 = (isPoint1OnBoundingBox) ? (point1)\n\t\t\t\t\t\t\t: (calcIntersectionPoint(point1, point2, box, code1));\n\t\t\t\t\tPoint2D intersection2 = (isPoint2OnBoundingBox) ? (point2)\n\t\t\t\t\t\t\t: (calcIntersectionPoint(point2, point1, box, code2));\n\t\t\t\t\tif (intersection1 == null || intersection2 == null) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (intersection1.distance(intersection2) < 0.000001\n\t\t\t\t\t\t\t&& (isPoint1OnBoundingBox || isPoint2OnBoundingBox)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\thasIntersection = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!hasIntersection) {\n\t\t\t\t\tfor (int j = i + 1; j < i + step; j++) {\n\t\t\t\t\t\tedgePoints.remove(i + 1);\n\t\t\t\t\t}\n\t\t\t\t\tstep = edgePoints.size() - 2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic void handlePrintProduktBatch(HttpServletRequest request, HttpServletResponse response, IFunctionality funktionalitetsLaget) throws ServletException, IOException, DALException {\n\t\tint produktBatchId, receptId, oprId = 0, raavareId, status, raavareBatchId = 0;\n\t\tString udskrevet, receptNavn, raavareNavn, startDato, slutDato;\n\t\tdouble tara = 0, netto = 0, taraSum = 0, nettoSum = 0;\n\t\tproduktBatchId = Integer.parseInt(request.getParameter(\"pbId\"));\n\t\tProduktBatchDTO pbDTO = funktionalitetsLaget.getProduktBatchDAO().getProduktBatch(produktBatchId);\n\t\treceptId = pbDTO.getReceptId();\n\t\tReceptDTO receptDTO = funktionalitetsLaget.getReceptDAO().getRecept(receptId);\n\t\treceptNavn = receptDTO.getReceptNavn();\n\t\tList<ReceptKompDTO> receptKompList = funktionalitetsLaget.getReceptKompDAO().getReceptKompList(receptId);\n\t\tstatus = pbDTO.getStatus();\n\t\tstartDato = pbDTO.getStartDato();\n\t\tslutDato = pbDTO.getSlutDato();\n\t\tCalendar d = Calendar.getInstance();\n\t\tDecimalFormat df = new DecimalFormat(\"00\");\n\t\tudskrevet = d.get(Calendar.YEAR) + \"-\"\n\t\t+ df.format(d.get(Calendar.MONTH) + 1) + \"-\"\n\t\t+ df.format(d.get(Calendar.DATE)) + \" \"\n\t\t+ df.format(d.get(Calendar.HOUR_OF_DAY)) + \":\"\n\t\t+ df.format(d.get(Calendar.MINUTE)) + \":\"\n\t\t+ df.format(d.get(Calendar.SECOND));\n\t\ttry {\n\t Document document = new Document();\n\t ByteArrayOutputStream baos = new ByteArrayOutputStream();\n\t PdfWriter.getInstance(document, baos);\n\t document.open();\n\t Chunk SEPERATOR = new Chunk(\n\t new LineSeparator(0.5f, 95, BaseColor.BLUE, Element.ALIGN_CENTER, 3.5f));\n\t Chunk DOTTED = new Chunk(\n\t new DottedLineSeparator());\n\t document.add(new Paragraph(\"Udskrevet \"+udskrevet));\n\t document.add(new Paragraph(\"Produkt Batch nr. \"+produktBatchId));\n\t document.add(new Paragraph(\"Recept nr. \"+receptId));\n\t document.add(new Paragraph(\"Recept navn: \"+receptNavn));\n\t document.add(SEPERATOR);\n\t for (ReceptKompDTO receptKomp: receptKompList) {\n\t \tRaavareDTO raavare = funktionalitetsLaget.getRaavareDAO().getRaavare(receptKomp.getRaavareId());\n\t \traavareId = receptKomp.getRaavareId();\n\t \traavareNavn = raavare.getRaavareNavn();\n\t \tList<ProduktBatchKompDTO> produktBatchKompList = funktionalitetsLaget.getProduktBatchKompDAO().getProduktBatchKompList(produktBatchId);\n\t\t document.add(new Paragraph(\"R\u00e5vare nr. \"+raavareId));\n\t\t document.add(new Paragraph(\"R\u00e5vare navn: \"+raavareNavn));\n\t\t document.add(DOTTED);\n\t\t PdfPTable table = new PdfPTable(6);\n\t\t table.getDefaultCell().setBorder(0);\n\t\t table.addCell(\"Nominel Netto\");\n\t\t table.addCell(\"Tolerance\");\n\t\t table.addCell(\"Tara\");\n\t\t table.addCell(\"Netto\");\n\t\t table.addCell(\"Batch\");\n\t\t table.addCell(\"Operat\u00f8r\");\n\t\t for (ProduktBatchKompDTO produktBatchKomp: produktBatchKompList) {\n\t\t \tint rbId = produktBatchKomp.getRbId();\n\t\t \tRaavareBatchDTO tjekRaavareBatch = funktionalitetsLaget.getRaavareBatchDAO().getRaavareBatch(rbId);\n\t\t \tif (raavareId == tjekRaavareBatch.getRaavareId()) {\n\t\t \t\ttara = produktBatchKomp.getTara();\n\t\t \t\ttaraSum += tara;\n\t\t \t\tnetto = produktBatchKomp.getNetto();\n\t\t \t\tnettoSum += netto;\n\t\t \t\traavareBatchId = tjekRaavareBatch.getRbId();\n\t\t \t\toprId = produktBatchKomp.getOprId();\n\t\t\t\t table.addCell(\"\"+receptKomp.getNomNetto());\n\t\t\t\t table.addCell(\"\"+receptKomp.getTolerance());\n\t\t \t\ttable.addCell(\"\"+tara);\n\t\t \t\ttable.addCell(\"\"+netto);\n\t\t \t\ttable.addCell(\"\"+raavareBatchId);\n\t\t \t\ttable.addCell(\"\"+oprId);\n\t\t \t}\n\t\t }\n\t\t if (tara == 0) {\n\t\t \ttable.addCell(\"\");\n\t\t \ttable.addCell(\"\");\n\t\t \ttable.addCell(\"\");\n\t\t \ttable.addCell(\"\");\n\t\t }\n\t\t document.add(table);\n\t\t document.add(SEPERATOR);\n\t }\n\t document.add(new Paragraph(\"Sum Tara: \"+((taraSum != 0)?taraSum:\"\")));\n\t document.add(new Paragraph(\"Sum Netto: \"+((nettoSum != 0)?nettoSum:\"\")));\n\t document.add(new Paragraph(\"\\n\\n\"));\n\t document.add(new Paragraph(\"Produktion Status: \"+statusToString(status)));\n\t document.add(new Paragraph(\"Produktion Startet: \"+startDato));\n\t document.add(new Paragraph(\"Produktion Slut: \"+slutDato));\n\t document.close();\n\t response.setHeader(\"Expires\", \"0\");\n\t response.setHeader(\"Cache-Control\",\n\t \"must-revalidate, post-check=0, pre-check=0\");\n\t response.setHeader(\"Pragma\", \"public\");\n\t response.setHeader(\"Content-Disposition\", \"attachment; filename=\\\"ProduktBatch\"+produktBatchId+\".pdf\\\"\");\n\t response.setContentType(\"application/pdf\");\n\t response.setContentLength(baos.size());\n\t OutputStream os = response.getOutputStream();\n\t baos.writeTo(os);\n\t os.flush();\n\t os.close();\n\t\t}\n\t\tcatch(DocumentException e) {\n\t\t\te.printStackTrace();\n\t\t\tSystem.out.println(\"fanget\");\n\t\t}\n\t}\n", "output": "\tpublic void handlePrintProduktBatch(HttpServletRequest request, HttpServletResponse response, IFunctionality funktionalitetsLaget) throws ServletException, IOException, DALException {\n\t\tint produktBatchId, receptId, oprId = 0, raavareId, status, raavareBatchId = 0;\n\t\tString udskrevet, receptNavn, raavareNavn, startDato, slutDato;\n\t\tdouble tara = 0, netto = 0, taraSum = 0, nettoSum = 0;\n\t\tproduktBatchId = Integer.parseInt(request.getParameter(\"pbId\"));\n\t\tProduktBatchDTO pbDTO = funktionalitetsLaget.getProduktBatchDAO().getProduktBatch(produktBatchId);\n\t\treceptId = pbDTO.getReceptId();\n\t\tReceptDTO receptDTO = funktionalitetsLaget.getReceptDAO().getRecept(receptId);\n\t\treceptNavn = receptDTO.getReceptNavn();\n\t\tList<ReceptKompDTO> receptKompList = funktionalitetsLaget.getReceptKompDAO().getReceptKompList(receptId);\n\t\tstatus = pbDTO.getStatus();\n\t\tstartDato = pbDTO.getStartDato();\n\t\tslutDato = pbDTO.getSlutDato();\n\t\tCalendar d = Calendar.getInstance();\n\t\tDecimalFormat df = new DecimalFormat(\"00\");\n\t\tudskrevet = d.get(Calendar.YEAR) + \"-\"\n\t\t+ df.format(d.get(Calendar.MONTH) + 1) + \"-\"\n\t\t+ df.format(d.get(Calendar.DATE)) + \" \"\n\t\t+ df.format(d.get(Calendar.HOUR_OF_DAY)) + \":\"\n\t\t+ df.format(d.get(Calendar.MINUTE)) + \":\"\n\t\t+ df.format(d.get(Calendar.SECOND));\n\t\ttry {\n\t Document document = new Document();\n\t ByteArrayOutputStream baos = new ByteArrayOutputStream();\n\t PdfWriter.getInstance(document, baos);\n\t document.open();\n\t Chunk SEPERATOR = new Chunk(\n\t new LineSeparator(0.5f, 95, BaseColor.BLUE, Element.ALIGN_CENTER, 3.5f));\n\t Chunk DOTTED = new Chunk(\n\t new DottedLineSeparator());\n\t document.add(new Paragraph(\"Udskrevet \"+udskrevet));\n\t document.add(new Paragraph(\"Produkt Batch nr. \"+produktBatchId));\n\t document.add(new Paragraph(\"Recept nr. \"+receptId));\n\t document.add(new Paragraph(\"Recept navn: \"+receptNavn));\n\t document.add(SEPERATOR);\n\t for (ReceptKompDTO receptKomp: receptKompList) {\n\t \tRaavareDTO raavare = funktionalitetsLaget.getRaavareDAO().getRaavare(receptKomp.getRaavareId());\n\t \traavareId = receptKomp.getRaavareId();\n\t \traavareNavn = raavare.getRaavareNavn();\n\t \tList<ProduktBatchKompDTO> produktBatchKompList = funktionalitetsLaget.getProduktBatchKompDAO().getProduktBatchKompList(produktBatchId);\n\t\t document.add(new Paragraph(\"R\u00e5vare nr. \"+raavareId));\n\t\t document.add(new Paragraph(\"R\u00e5vare navn: \"+raavareNavn));\n\t\t document.add(DOTTED);\n\t\t PdfPTable table = new PdfPTable(6);\n\t\t table.getDefaultCell().setBorder(0);\n\t\t table.addCell(\"Nominel Netto\");\n\t\t table.addCell(\"Tolerance\");\n\t\t table.addCell(\"Tara\");\n\t\t table.addCell(\"Netto\");\n\t\t table.addCell(\"Batch\");\n\t\t table.addCell(\"Operat\u00f8r\");\n\t\t for (ProduktBatchKompDTO produktBatchKomp: produktBatchKompList) {\n\t\t \tint rbId = produktBatchKomp.getRbId();\n\t\t \tRaavareBatchDTO tjekRaavareBatch = funktionalitetsLaget.getRaavareBatchDAO().getRaavareBatch(rbId);\n\t\t \tif (raavareId == tjekRaavareBatch.getRaavareId()) {\n\t\t \t\ttara = produktBatchKomp.getTara();\n\t\t \t\ttaraSum += tara;\n\t\t \t\tnetto = produktBatchKomp.getNetto();\n\t\t \t\tnettoSum += netto;\n\t\t \t\traavareBatchId = tjekRaavareBatch.getRbId();\n\t\t \t\toprId = produktBatchKomp.getOprId();\n\t\t\t\t table.addCell(\"\"+receptKomp.getNomNetto());\n\t\t\t\t table.addCell(\"\"+receptKomp.getTolerance() + \" %\");\n\t\t \t\ttable.addCell(\"\"+tara);\n\t\t \t\ttable.addCell(\"\"+netto);\n\t\t \t\ttable.addCell(\"\"+raavareBatchId);\n\t\t \t\ttable.addCell(\"\"+oprId);\n\t\t \t}\n\t\t }\n\t\t if (tara == 0 && netto == 0) {\n\t\t \ttable.addCell(\"\"+receptKomp.getNomNetto());\n\t\t \ttable.addCell(\"\"+receptKomp.getTolerance()+\" %\");\n\t\t \ttable.addCell(\"\");\n\t\t \ttable.addCell(\"\");\n\t\t \ttable.addCell(\"\");\n\t\t \ttable.addCell(\"\");\n\t\t }\n\t\t document.add(table);\n\t\t document.add(SEPERATOR);\n\t }\n\t document.add(new Paragraph(\"Sum Tara: \"+((taraSum != 0)?taraSum:\"\")));\n\t document.add(new Paragraph(\"Sum Netto: \"+((nettoSum != 0)?nettoSum:\"\")));\n\t document.add(new Paragraph(\"\\n\\n\"));\n\t document.add(new Paragraph(\"Produktion Status: \"+statusToString(status)));\n\t document.add(new Paragraph(\"Produktion Startet: \"+startDato));\n\t document.add(new Paragraph(\"Produktion Slut: \"+slutDato));\n\t document.close();\n\t response.setHeader(\"Expires\", \"0\");\n\t response.setHeader(\"Cache-Control\",\n\t \"must-revalidate, post-check=0, pre-check=0\");\n\t response.setHeader(\"Pragma\", \"public\");\n\t response.setHeader(\"Content-Disposition\", \"attachment; filename=\\\"ProduktBatch\"+produktBatchId+\".pdf\\\"\");\n\t response.setContentType(\"application/pdf\");\n\t response.setContentLength(baos.size());\n\t OutputStream os = response.getOutputStream();\n\t baos.writeTo(os);\n\t os.flush();\n\t os.close();\n\t\t}\n\t\tcatch(DocumentException e) {\n\t\t\te.printStackTrace();\n\t\t\tSystem.out.println(\"fanget\");\n\t\t}\n\t}\n"} {"input": "\tpublic void handleMsg(Bais msg) {\n\t\tbyte i = msg.readByte();\n\t\tCommand c = Command.values()[i];\n\t\tLog.d(TAG, \"Received: \" + c);\n\t\tswitch (c) {\n\t\tcase ChannelPlayers:\n\t\tcase JoinChannel: \n\t\tcase LeaveChannel:{\n\t\t\tChannel ch = channels.get(msg.readInt());\n\t\t\tif(ch != null)\n\t\t\t\tch.handleChannelMsg(c, msg);\n\t\t\telse\n\t\t\t\tLog.e(TAG, \"Received message for nonexistent channel\");\n\t\t\tbreak;\n\t\t} case VersionControl: {\n\t\t\tProtocolVersion serverVersion = new ProtocolVersion(msg);\n\t\t\tif (serverVersion.compareTo(version) > 0) {\n\t\t\t\tLog.d(TAG, \"Server has newer protocol version than we expect\");\n\t\t\t} else if (serverVersion.compareTo(version) < 0) {\n\t\t\t\tLog.d(TAG, \"PO Android uses newer protocol than Server\");\n\t\t\t}\n\t\t\tserverSupportsZipCompression = msg.readBool();\n\t\t\tProtocolVersion lastVersionWithoutFeatures = new ProtocolVersion(msg);\n\t\t\tProtocolVersion lastVersionWithoutCompatBreak = new ProtocolVersion(msg);\n\t\t\tProtocolVersion lastVersionWithoutMajorCompatBreak = new ProtocolVersion(msg);\n\t\t\tif (serverVersion.compareTo(version) > 0) {\n\t\t\t\tif (lastVersionWithoutFeatures.compareTo(version) > 0) {\n\t\t\t\t\tToast.makeText(this, R.string.new_server_features_warning, Toast.LENGTH_SHORT).show();\n\t\t\t\t} else if (lastVersionWithoutCompatBreak.compareTo(version) > 0) {\n\t\t\t\t\tToast.makeText(this, R.string.minor_compat_break_warning, Toast.LENGTH_SHORT).show();\n\t\t\t\t} else if (lastVersionWithoutMajorCompatBreak.compareTo(version) > 0) {\n\t\t\t\t\tToast.makeText(this, R.string.major_compat_break_warning, Toast.LENGTH_LONG).show();\n\t\t\t\t}\n\t\t\t}\n\t\t\tserverName = msg.readString();\n\t\t\tif (chatActivity != null) {\n\t\t\t\tchatActivity.updateTitle();\n\t\t\t}\n\t\t\tbreak;\n\t\t} case Register: {\n\t\t\tbreak;\n\t\t} case Login: {\n\t\t\tBais flags = msg.readFlags();\n\t\t\tBoolean hasReconnPass = flags.readBool();\n\t\t\tif (hasReconnPass) {\n\t\t\t\treconnectSecret = msg.readQByteArray();\n\t\t\t}\n\t\t\tmePlayer = new PlayerInfo(msg);\n\t\t\tmyid = mePlayer.id;\n\t\t\tint numTiers = msg.readInt();\n\t\t\tfor (int j = 0; j < numTiers; j++) {\n\t\t\t\tmsg.readString();\n\t\t\t}\n\t\t\tplayers.put(mePlayer.id, mePlayer);\n\t\t\tbreak;\n\t\t} case TierSelection: {\n\t\t\tmsg.readInt(); \n\t\t\tTier prevTier = new Tier(msg.readByte(), msg.readString());\n\t\t\tprevTier.parentTier = superTier;\n\t\t\tsuperTier.subTiers.add(prevTier);\n\t\t\twhile(msg.available() != 0) { \n\t\t\t\tTier t = new Tier(msg.readByte(), msg.readString());\n\t\t\t\tif(t.level == prevTier.level) { \n\t\t\t\t\tprevTier.parentTier.addSubTier(t);\n\t\t\t\t\tt.parentTier = prevTier.parentTier;\n\t\t\t\t}\n\t\t\t\telse if(t.level < prevTier.level) { \n\t\t\t\t\twhile(t.level < prevTier.level)\n\t\t\t\t\t\tprevTier = prevTier.parentTier;\n\t\t\t\t\tprevTier.parentTier.addSubTier(t);\n\t\t\t\t\tt.parentTier = prevTier.parentTier;\n\t\t\t\t}\n\t\t\t\telse if(t.level > prevTier.level) { \n\t\t\t\t\tprevTier.addSubTier(t);\n\t\t\t\t\tt.parentTier = prevTier;\n\t\t\t\t}\n\t\t\t\tprevTier = t;\n\t\t\t}\n\t\t\tbreak;\n\t\t} case ChannelsList: {\n\t\t\tint numChannels = msg.readInt();\n\t\t\tfor(int j = 0; j < numChannels; j++) {\n\t\t\t\tint chanId = msg.readInt();\n\t\t\t\tChannel ch = new Channel(chanId, msg.readString(), this);\n\t\t\t\tchannels.put(chanId, ch);\n\t\t\t}\n\t\t\tLog.d(TAG, channels.toString());\n\t\t\tbreak;\n\t\t} case PlayersList: {\n\t\t\twhile (msg.available() != 0) { \n\t\t\t\tPlayerInfo p = new PlayerInfo(msg);\n\t\t\t\tPlayerInfo oldPlayer = players.get(p.id);\n\t\t\t\tplayers.put(p.id, p);\n\t\t\t\tif (oldPlayer != null && chatActivity != null) {\n\t\t\t\t\tchatActivity.updatePlayer(p, oldPlayer);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t} case SendMessage: {\n\t\t\tBais netFlags = msg.readFlags();\n\t\t\tboolean hasChannel = netFlags.readBool();\n\t\t\tboolean hasId = netFlags.readBool();\n\t\t\tBais dataFlags = msg.readFlags();\n\t\t\tboolean isHtml = dataFlags.readBool();\n\t\t\tChannel chan = hasChannel ? channels.get(msg.readInt()) : null;\n\t\t\tPlayerInfo player = hasId ? players.get(msg.readInt()) : null;\n\t\t\tCharSequence message = msg.readString();\n\t\t\tif (hasId) {\n\t\t\t\tCharSequence color = (player == null ? \"orange\" : player.color.toHexString());\n\t\t\t\tCharSequence name = player.nick();\n\t\t\t\tif (isHtml) {\n\t\t\t\t\tmessage = Html.fromHtml(\"<font color='\" + color + \"'><b>\" + name + \n\t\t\t\t\t\t\t\": </b></font>\" + message);\n\t\t\t\t} else {\n\t\t\t\t\tmessage = Html.fromHtml(\"<font color='\" + color + \"'><b>\" + name +\n\t\t\t\t\t\t\t\": </b></font>\" + StringUtilities.escapeHtml((String)message));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmessage = isHtml ? Html.fromHtml((String)message) : message;\n\t\t\t}\n\t\t\tif (!hasChannel) {\n\t\t\t\tif (chatActivity != null && message.toString().contains(\"Wrong password for this name.\")) \n\t\t\t\t\tchatActivity.makeToast(message.toString(), \"long\");\n\t\t\t\telse {\n\t\t\t\t\tIterator<Channel> it = joinedChannels.iterator();\n\t\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\t\tit.next().writeToHist(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (chan == null) {\n\t\t\t\t\tLog.e(TAG, \"Received message for nonexistent channel\");\n\t\t\t\t} else {\n\t\t\t\t\tchan.writeToHist(message);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase BattleList: {\n\t\t\tmsg.readInt(); \n\t\t\tint numBattles = msg.readInt();\n\t\t\tfor (; numBattles > 0; numBattles--) {\n\t\t\t\tint battleId = msg.readInt();\n\t\t\t\tint player1 = msg.readInt();\n\t\t\t\tint player2 = msg.readInt();\n\t\t\t\taddBattle(battleId, new BattleDesc(player1, player2));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase ChannelBattle: {\n\t\t\tmsg.readInt(); \n\t\t\tint battleId = msg.readInt();\n\t\t\tint player1 = msg.readInt();\n\t\t\tint player2 = msg.readInt();\n\t\t\taddBattle(battleId, new BattleDesc(player1, player2));\n\t\t}\n\t\t case Logout: {\n\t\t\tint playerID = msg.readInt();\n\t\t\tremovePlayer(playerID);\n\t\t\tbreak;\n\t\t} case BattleFinished: {\n\t\t\tint battleID = msg.readInt();\n\t\t\tbyte battleDesc = msg.readByte();\n\t\t\tmsg.readByte(); \n\t\t\tint id1 = msg.readInt();\n\t\t\tint id2 = msg.readInt();\n\t\t\tLog.i(TAG, \"bID \" + battleID + \" battleDesc \" + battleDesc + \" id1 \" + id1 + \" id2 \" + id2);\n\t\t\tString[] outcome = new String[]{\" won by forfeit against \", \" won against \", \" tied with \"};\n\t\t\tif (battle != null && battle.bID == battleID || spectatedBattles.containsKey(battleID)) {\n\t\t\t\tif (battle.bID == battleID) {\n\t\t\t\t}\n\t\t\t\tif (battleDesc < 2) {\n\t\t\t\t\tjoinedChannels.peek().writeToHist(Html.fromHtml(\"<b><i>\" + \n\t\t\t\t\t\t\tStringUtilities.escapeHtml(playerName(id1)) + outcome[battleDesc] + \n\t\t\t\t\t\t\tStringUtilities.escapeHtml(playerName(id2)) + \".</b></i>\"));\n\t\t\t\t}\n\t\t\t\tif (battleDesc == 0 || battleDesc == 3) {\n\t\t\t\t\tcloseBattle(battleID);\n\t\t\t\t}\n\t\t\t}\n\t\t\tremoveBattle(battleID);\n\t\t\tbreak;\n\t\t} case SendPM: {\n\t\t\tint playerID = msg.readInt();\n\t\t\tpmedPlayers.add(playerID);\n\t\t\tString pm = new String(\"This user is running the Pokemon Online Android client and cannot respond to private messages.\");\n\t\t\tBaos bb = new Baos();\n\t\t\tbb.putInt(playerID);\n\t\t\tbb.putString(pm);\n\t\t\tsocket.sendMessage(bb, Command.SendPM);\n\t\t\tbreak;\n\t\t} case BattleMessage: {\n\t\t\tmsg.readInt(); \n\t\t\tmsg.readInt(); \n\t\t\tif (battle != null)\n\t\t\t\tbattle.receiveCommand(msg);\n\t\t\tbreak;\n\t\t} case EngageBattle: {\n\t\t\tint battleId = msg.readInt();\n\t\t\tBais flags = msg.readFlags();\n\t\t\tbyte mode = msg.readByte();\n\t\t\tint p1 = msg.readInt();\n\t\t\tint p2 = msg.readInt();\n\t\t\taddBattle(battleId, new BattleDesc(p1, p2, mode));\n\t\t\tif(flags.readBool()) { \n\t\t\t\tBattleConf conf = new BattleConf(msg);\n\t\t\t\tbattle = new Battle(conf, msg, players.get(conf.id(0)),\n\t\t\t\t\t\tplayers.get(conf.id(1)), mePlayer.id, battleId, this);\n\t\t\t\tjoinedChannels.peek().writeToHist(\"Battle between \" + playerName(p1) + \n\t\t\t\t\t\t\" and \" + playerName(p2) + \" started!\");\n\t\t\t\tIntent in;\n\t\t\t\tin = new Intent(this, BattleActivity.class);\n\t\t\t\tin.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t\t\t\tstartActivity(in);\n\t\t\t\tfindingBattle = false;\n\t\t\t}\n\t\t\tbreak;\n\t\t} \n\t\tcase SpectateBattle: {\n\t\t\tBais flags = msg.readFlags();\n\t\t\tint battleId = msg.readInt();\n\t\t\tif (flags.readBool()) {\n\t\t\t\tif (spectatedBattles.contains(battleId)) {\n\t\t\t\t\tLog.e(TAG, \"Already watching battle \" + battleId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t BattleConf conf = new BattleConf(msg);\n\t SpectatingBattle battle = new SpectatingBattle(conf, players.get(conf.id(0)), players.get(conf.id(1)), battleId, this);\n\t spectatedBattles.put(battleId, battle);\n\t Intent intent = new Intent(this, BattleActivity.class);\n\t intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t intent.putExtra(\"battleId\", battleId);\n\t startActivity(intent);\n\t } else {\n\t SpectatingBattle battle = spectatedBattles.remove(battleId);\n\t if (battle != null && battle.activity != null) {\n\t \tbattle.activity.end();\n\t }\n\t }\n\t\t\tbreak;\n\t\t}\n\t\tcase SpectateBattleMessage: {\n\t\t\tint battleId = msg.readInt(); \n\t\t\tmsg.readInt(); \n\t\t\tif (spectatedBattles.containsKey(battleId)) {\n\t\t\t\tspectatedBattles.get(battleId).receiveCommand(msg);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase AskForPass: {\n\t\t\tsalt = msg.readString();\n\t\t\tif (salt.length() < 6) { \n\t\t\t\tSystem.out.println(\"Protocol Error: The server requires insecure authentication\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\taskedForPass = true;\n\t\t\tif (chatActivity != null && (chatActivity.hasWindowFocus() || chatActivity.progressDialog.isShowing())) {\n\t\t\t\tchatActivity.notifyAskForPass();\n\t\t\t}\n\t\t\tbreak;\n\t\t} case AddChannel: {\n\t\t\taddChannel(msg.readString(),msg.readInt());\n\t\t\tbreak;\n\t\t} case RemoveChannel: {\n\t\t\tint chanId = msg.readInt();\n\t\t\tif (chatActivity != null)\n\t\t\t\tchatActivity.removeChannel(channels.get(chanId));\n\t\t\tchannels.remove(chanId);\n\t\t\tbreak;\n\t\t} case ChanNameChange: {\n\t\t\tint chanId = msg.readInt();\n\t\t\tif (chatActivity != null)\n\t\t\t\tchatActivity.removeChannel(channels.get(chanId));\n\t\t\tchannels.remove(chanId);\n\t\t\tchannels.put(chanId, new Channel(chanId, msg.readString(), this));\n\t\t\tbreak;\n\t\t} default: {\n\t\t\tSystem.out.println(\"Unimplented message\");\n\t\t}\n\t\t}\n", "output": "\tpublic void handleMsg(Bais msg) {\n\t\tbyte i = msg.readByte();\n\t\tCommand c = Command.values()[i];\n\t\tLog.d(TAG, \"Received: \" + c);\n\t\tswitch (c) {\n\t\tcase ChannelPlayers:\n\t\tcase JoinChannel: \n\t\tcase LeaveChannel:{\n\t\t\tChannel ch = channels.get(msg.readInt());\n\t\t\tif(ch != null)\n\t\t\t\tch.handleChannelMsg(c, msg);\n\t\t\telse\n\t\t\t\tLog.e(TAG, \"Received message for nonexistent channel\");\n\t\t\tbreak;\n\t\t} case VersionControl: {\n\t\t\tProtocolVersion serverVersion = new ProtocolVersion(msg);\n\t\t\tif (serverVersion.compareTo(version) > 0) {\n\t\t\t\tLog.d(TAG, \"Server has newer protocol version than we expect\");\n\t\t\t} else if (serverVersion.compareTo(version) < 0) {\n\t\t\t\tLog.d(TAG, \"PO Android uses newer protocol than Server\");\n\t\t\t}\n\t\t\tserverSupportsZipCompression = msg.readBool();\n\t\t\tProtocolVersion lastVersionWithoutFeatures = new ProtocolVersion(msg);\n\t\t\tProtocolVersion lastVersionWithoutCompatBreak = new ProtocolVersion(msg);\n\t\t\tProtocolVersion lastVersionWithoutMajorCompatBreak = new ProtocolVersion(msg);\n\t\t\tif (serverVersion.compareTo(version) > 0) {\n\t\t\t\tif (lastVersionWithoutFeatures.compareTo(version) > 0) {\n\t\t\t\t\tToast.makeText(this, R.string.new_server_features_warning, Toast.LENGTH_SHORT).show();\n\t\t\t\t} else if (lastVersionWithoutCompatBreak.compareTo(version) > 0) {\n\t\t\t\t\tToast.makeText(this, R.string.minor_compat_break_warning, Toast.LENGTH_SHORT).show();\n\t\t\t\t} else if (lastVersionWithoutMajorCompatBreak.compareTo(version) > 0) {\n\t\t\t\t\tToast.makeText(this, R.string.major_compat_break_warning, Toast.LENGTH_LONG).show();\n\t\t\t\t}\n\t\t\t}\n\t\t\tserverName = msg.readString();\n\t\t\tif (chatActivity != null) {\n\t\t\t\tchatActivity.updateTitle();\n\t\t\t}\n\t\t\tbreak;\n\t\t} case Register: {\n\t\t\tbreak;\n\t\t} case Login: {\n\t\t\tBais flags = msg.readFlags();\n\t\t\tBoolean hasReconnPass = flags.readBool();\n\t\t\tif (hasReconnPass) {\n\t\t\t\treconnectSecret = msg.readQByteArray();\n\t\t\t}\n\t\t\tmePlayer = new PlayerInfo(msg);\n\t\t\tmyid = mePlayer.id;\n\t\t\tint numTiers = msg.readInt();\n\t\t\tfor (int j = 0; j < numTiers; j++) {\n\t\t\t\tmsg.readString();\n\t\t\t}\n\t\t\tplayers.put(mePlayer.id, mePlayer);\n\t\t\tbreak;\n\t\t} case TierSelection: {\n\t\t\tmsg.readInt(); \n\t\t\tTier prevTier = new Tier(msg.readByte(), msg.readString());\n\t\t\tprevTier.parentTier = superTier;\n\t\t\tsuperTier.subTiers.add(prevTier);\n\t\t\twhile(msg.available() != 0) { \n\t\t\t\tTier t = new Tier(msg.readByte(), msg.readString());\n\t\t\t\tif(t.level == prevTier.level) { \n\t\t\t\t\tprevTier.parentTier.addSubTier(t);\n\t\t\t\t\tt.parentTier = prevTier.parentTier;\n\t\t\t\t}\n\t\t\t\telse if(t.level < prevTier.level) { \n\t\t\t\t\twhile(t.level < prevTier.level)\n\t\t\t\t\t\tprevTier = prevTier.parentTier;\n\t\t\t\t\tprevTier.parentTier.addSubTier(t);\n\t\t\t\t\tt.parentTier = prevTier.parentTier;\n\t\t\t\t}\n\t\t\t\telse if(t.level > prevTier.level) { \n\t\t\t\t\tprevTier.addSubTier(t);\n\t\t\t\t\tt.parentTier = prevTier;\n\t\t\t\t}\n\t\t\t\tprevTier = t;\n\t\t\t}\n\t\t\tbreak;\n\t\t} case ChannelsList: {\n\t\t\tint numChannels = msg.readInt();\n\t\t\tfor(int j = 0; j < numChannels; j++) {\n\t\t\t\tint chanId = msg.readInt();\n\t\t\t\tChannel ch = new Channel(chanId, msg.readString(), this);\n\t\t\t\tchannels.put(chanId, ch);\n\t\t\t}\n\t\t\tLog.d(TAG, channels.toString());\n\t\t\tbreak;\n\t\t} case PlayersList: {\n\t\t\twhile (msg.available() != 0) { \n\t\t\t\tPlayerInfo p = new PlayerInfo(msg);\n\t\t\t\tPlayerInfo oldPlayer = players.get(p.id);\n\t\t\t\tplayers.put(p.id, p);\n\t\t\t\tif (oldPlayer != null && chatActivity != null) {\n\t\t\t\t\tchatActivity.updatePlayer(p, oldPlayer);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t} case SendMessage: {\n\t\t\tBais netFlags = msg.readFlags();\n\t\t\tboolean hasChannel = netFlags.readBool();\n\t\t\tboolean hasId = netFlags.readBool();\n\t\t\tBais dataFlags = msg.readFlags();\n\t\t\tboolean isHtml = dataFlags.readBool();\n\t\t\tChannel chan = hasChannel ? channels.get(msg.readInt()) : null;\n\t\t\tPlayerInfo player = hasId ? players.get(msg.readInt()) : null;\n\t\t\tCharSequence message = msg.readString();\n\t\t\tif (hasId) {\n\t\t\t\tCharSequence color = (player == null ? \"orange\" : player.color.toHexString());\n\t\t\t\tCharSequence name = player.nick();\n\t\t\t\tif (isHtml) {\n\t\t\t\t\tmessage = Html.fromHtml(\"<font color='\" + color + \"'><b>\" + name + \n\t\t\t\t\t\t\t\": </b></font>\" + message);\n\t\t\t\t} else {\n\t\t\t\t\tmessage = Html.fromHtml(\"<font color='\" + color + \"'><b>\" + name +\n\t\t\t\t\t\t\t\": </b></font>\" + StringUtilities.escapeHtml((String)message));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tmessage = isHtml ? Html.fromHtml((String)message) : message;\n\t\t\t}\n\t\t\tif (!hasChannel) {\n\t\t\t\tif (chatActivity != null && message.toString().contains(\"Wrong password for this name.\")) \n\t\t\t\t\tchatActivity.makeToast(message.toString(), \"long\");\n\t\t\t\telse {\n\t\t\t\t\tIterator<Channel> it = joinedChannels.iterator();\n\t\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\t\tit.next().writeToHist(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (chan == null) {\n\t\t\t\t\tLog.e(TAG, \"Received message for nonexistent channel\");\n\t\t\t\t} else {\n\t\t\t\t\tchan.writeToHist(message);\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase BattleList: {\n\t\t\tmsg.readInt(); \n\t\t\tint numBattles = msg.readInt();\n\t\t\tfor (; numBattles > 0; numBattles--) {\n\t\t\t\tint battleId = msg.readInt();\n\t\t\t\tint player1 = msg.readInt();\n\t\t\t\tint player2 = msg.readInt();\n\t\t\t\taddBattle(battleId, new BattleDesc(player1, player2));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase ChannelBattle: {\n\t\t\tmsg.readInt(); \n\t\t\tint battleId = msg.readInt();\n\t\t\tint player1 = msg.readInt();\n\t\t\tint player2 = msg.readInt();\n\t\t\taddBattle(battleId, new BattleDesc(player1, player2));\n\t\t}\n\t\t case Logout: {\n\t\t\tint playerID = msg.readInt();\n\t\t\tremovePlayer(playerID);\n\t\t\tbreak;\n\t\t} case BattleFinished: {\n\t\t\tint battleID = msg.readInt();\n\t\t\tbyte battleDesc = msg.readByte();\n\t\t\tmsg.readByte(); \n\t\t\tint id1 = msg.readInt();\n\t\t\tint id2 = msg.readInt();\n\t\t\tLog.i(TAG, \"bID \" + battleID + \" battleDesc \" + battleDesc + \" id1 \" + id1 + \" id2 \" + id2);\n\t\t\tString[] outcome = new String[]{\" won by forfeit against \", \" won against \", \" tied with \"};\n\t\t\tif (battle != null && battle.bID == battleID || spectatedBattles.containsKey(battleID)) {\n\t\t\t\tif (battle != null && battle.bID == battleID) {\n\t\t\t\t}\n\t\t\t\tif (battleDesc < 2) {\n\t\t\t\t\tjoinedChannels.peek().writeToHist(Html.fromHtml(\"<b><i>\" + \n\t\t\t\t\t\t\tStringUtilities.escapeHtml(playerName(id1)) + outcome[battleDesc] + \n\t\t\t\t\t\t\tStringUtilities.escapeHtml(playerName(id2)) + \".</b></i>\"));\n\t\t\t\t}\n\t\t\t\tif (battleDesc == 0 || battleDesc == 3) {\n\t\t\t\t\tcloseBattle(battleID);\n\t\t\t\t}\n\t\t\t}\n\t\t\tremoveBattle(battleID);\n\t\t\tbreak;\n\t\t} case SendPM: {\n\t\t\tint playerID = msg.readInt();\n\t\t\tpmedPlayers.add(playerID);\n\t\t\tString pm = new String(\"This user is running the Pokemon Online Android client and cannot respond to private messages.\");\n\t\t\tBaos bb = new Baos();\n\t\t\tbb.putInt(playerID);\n\t\t\tbb.putString(pm);\n\t\t\tsocket.sendMessage(bb, Command.SendPM);\n\t\t\tbreak;\n\t\t} case BattleMessage: {\n\t\t\tmsg.readInt(); \n\t\t\tmsg.readInt(); \n\t\t\tif (battle != null)\n\t\t\t\tbattle.receiveCommand(msg);\n\t\t\tbreak;\n\t\t} case EngageBattle: {\n\t\t\tint battleId = msg.readInt();\n\t\t\tBais flags = msg.readFlags();\n\t\t\tbyte mode = msg.readByte();\n\t\t\tint p1 = msg.readInt();\n\t\t\tint p2 = msg.readInt();\n\t\t\taddBattle(battleId, new BattleDesc(p1, p2, mode));\n\t\t\tif(flags.readBool()) { \n\t\t\t\tBattleConf conf = new BattleConf(msg);\n\t\t\t\tbattle = new Battle(conf, msg, players.get(conf.id(0)),\n\t\t\t\t\t\tplayers.get(conf.id(1)), mePlayer.id, battleId, this);\n\t\t\t\tjoinedChannels.peek().writeToHist(\"Battle between \" + playerName(p1) + \n\t\t\t\t\t\t\" and \" + playerName(p2) + \" started!\");\n\t\t\t\tIntent in;\n\t\t\t\tin = new Intent(this, BattleActivity.class);\n\t\t\t\tin.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t\t\t\tstartActivity(in);\n\t\t\t\tfindingBattle = false;\n\t\t\t}\n\t\t\tbreak;\n\t\t} \n\t\tcase SpectateBattle: {\n\t\t\tBais flags = msg.readFlags();\n\t\t\tint battleId = msg.readInt();\n\t\t\tif (flags.readBool()) {\n\t\t\t\tif (spectatedBattles.contains(battleId)) {\n\t\t\t\t\tLog.e(TAG, \"Already watching battle \" + battleId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t BattleConf conf = new BattleConf(msg);\n\t SpectatingBattle battle = new SpectatingBattle(conf, players.get(conf.id(0)), players.get(conf.id(1)), battleId, this);\n\t spectatedBattles.put(battleId, battle);\n\t Intent intent = new Intent(this, BattleActivity.class);\n\t intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\n\t intent.putExtra(\"battleId\", battleId);\n\t startActivity(intent);\n\t } else {\n\t SpectatingBattle battle = spectatedBattles.remove(battleId);\n\t if (battle != null && battle.activity != null) {\n\t \tbattle.activity.end();\n\t }\n\t }\n\t\t\tbreak;\n\t\t}\n\t\tcase SpectateBattleMessage: {\n\t\t\tint battleId = msg.readInt(); \n\t\t\tmsg.readInt(); \n\t\t\tif (spectatedBattles.containsKey(battleId)) {\n\t\t\t\tspectatedBattles.get(battleId).receiveCommand(msg);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase AskForPass: {\n\t\t\tsalt = msg.readString();\n\t\t\tif (salt.length() < 6) { \n\t\t\t\tSystem.out.println(\"Protocol Error: The server requires insecure authentication\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\taskedForPass = true;\n\t\t\tif (chatActivity != null && (chatActivity.hasWindowFocus() || chatActivity.progressDialog.isShowing())) {\n\t\t\t\tchatActivity.notifyAskForPass();\n\t\t\t}\n\t\t\tbreak;\n\t\t} case AddChannel: {\n\t\t\taddChannel(msg.readString(),msg.readInt());\n\t\t\tbreak;\n\t\t} case RemoveChannel: {\n\t\t\tint chanId = msg.readInt();\n\t\t\tif (chatActivity != null)\n\t\t\t\tchatActivity.removeChannel(channels.get(chanId));\n\t\t\tchannels.remove(chanId);\n\t\t\tbreak;\n\t\t} case ChanNameChange: {\n\t\t\tint chanId = msg.readInt();\n\t\t\tif (chatActivity != null)\n\t\t\t\tchatActivity.removeChannel(channels.get(chanId));\n\t\t\tchannels.remove(chanId);\n\t\t\tchannels.put(chanId, new Channel(chanId, msg.readString(), this));\n\t\t\tbreak;\n\t\t} default: {\n\t\t\tSystem.out.println(\"Unimplented message\");\n\t\t}\n\t\t}\n"} {"input": "\tprotected boolean isPlayerProtected(String playername)\n\t{\n\t\tif (System.currentTimeMillis() - playerprotecttime.get(playername) > config.protecttime)\n\t\t{\n\t\t\tunprotectPlayer(playername);\n\t\t}\n\t\tPlayer player = Bukkit.getPlayerExact(playername);\n\t\ttry {\n\t\t\tList<String> aregions = WGBukkit.getRegionManager(player.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(player.getLocation()));\n\t\t\tfor (String region : aregions)\n\t\t\t{\n\t\t\t\tif (config.disabledegions.contains(region))\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {}\n\t\treturn playerprotecttime.containsKey(playername);\n\t}\n", "output": "\tprotected boolean isPlayerProtected(String playername)\n\t{\n\t\tif (playerprotecttime.containsKey(playername) && System.currentTimeMillis() - playerprotecttime.get(playername) > config.protecttime)\n\t\t{\n\t\t\tunprotectPlayer(playername);\n\t\t}\n\t\tPlayer player = Bukkit.getPlayerExact(playername);\n\t\ttry {\n\t\t\tList<String> aregions = WGBukkit.getRegionManager(player.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(player.getLocation()));\n\t\t\tfor (String region : aregions)\n\t\t\t{\n\t\t\t\tif (config.disabledegions.contains(region))\n\t\t\t\t{\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {}\n\t\treturn playerprotecttime.containsKey(playername);\n\t}\n"} {"input": " public void startElement(final String uri, final String localName, final String qName, final Attributes atts) throws SAXException {\n switch (this.stage) {\n case 0:\n if (qName.equals(\"div\") && \"content_box post_content_box story_content_box\".equals(atts.getValue(\"class\"))) {\n this.startStory();\n this.getCurrentBuilder().id(Integer.parseInt(atts.getValue(\"id\").substring(6)));\n this.stage = 1;\n }\n break;\n case 1:\n String src = atts.getValue(\"src\");\n this.author = User.builder();\n if (src != null && !src.equals(\"//www.fimfiction-static.net/images/avatars/none_64.png\")) {\n try {\n this.author.profileImageUrl(new URL(\"http:\" + src));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n }\n this.stage = 2;\n break;\n case 2:\n if (qName.equals(\"div\") && \"right\".equals(atts.getValue(\"class\"))) {\n this.stage = 3;\n }\n break;\n case 3:\n this.stage = \"track_container\".equals(atts.getValue(\"class\")) ? 4 : 6;\n break;\n case 4:\n if (qName.equals(\"a\")) {\n this.favorited = atts.getValue(\"class\").contains(\"favourite_button_selected\");\n this.stage = 5;\n }\n break;\n case 5:\n if (qName.equals(\"input\")) {\n final boolean email = atts.getValue(\"checked\") != null;\n this.getCurrentBuilder().favorited(this.favorited ? email ? FavoriteState.FAVORITED_EMAIL : FavoriteState.FAVORITED : FavoriteState.NOT_FAVORITED);\n this.stage = 6;\n }\n break;\n case 6:\n if (qName.equals(\"a\")) {\n final String onClick = atts.getValue(\"onclick\");\n if (onClick != null && onClick.startsWith(\"Ra\")) {\n this.getCurrentBuilder().ratingToken(onClick.substring(onClick.indexOf('\\'') + 1, onClick.lastIndexOf('\\'')));\n }\n this.stage = 7;\n }\n break;\n case 8:\n if (qName.equals(\"a\")) {\n this.stage = 9;\n }\n break;\n case 10:\n if (qName.equals(\"b\")) {\n this.stage = 300;\n }\n break;\n case 301:\n if (qName.equals(\"span\")) {\n final String title = atts.getValue(\"title\");\n if (title != null) {\n this.getCurrentBuilder().totalViewCount(toIntLiberal(title));\n this.stage = 11;\n }\n }\n break;\n case 12:\n if (qName.equals(\"a\")) {\n this.getCurrentBuilder().readLater(atts.getValue(\"class\").contains(\"read_it_later_selected\"));\n }\n this.stage = 14;\n break;\n case 14:\n if (qName.equals(\"a\")) {\n try {\n this.getCurrentBuilder().url(new URL(\"http://www.fimfiction.net\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.title = new StringBuilder();\n this.stage = 15;\n }\n break;\n case 16:\n if (qName.equals(\"a\")) {\n this.authorName = new StringBuilder();\n this.stage = 17;\n }\n break;\n case 18:\n if (qName.equals(\"img\") && atts.getValue(\"src\").equals(\"//www.fimfiction-static.net/images/icons/views.png\")) {\n this.stage = 19;\n }\n break;\n case 20:\n if (qName.equals(\"div\") && \"description\".equals(atts.getValue(\"class\"))) {\n this.stage = 21;\n }\n break;\n case 21:\n this.stage = \"story_image\".equals(atts.getValue(\"class\")) ? 22 : 25;\n break;\n case 22:\n try {\n this.getCurrentBuilder().imageUrl(new URL(\"http:\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.stage = 23;\n break;\n case 23:\n try {\n this.getCurrentBuilder().thumbnailUrl(new URL(\"http:\" + atts.getValue(\"src\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.stage = 24;\n break;\n case 24:\n if (qName.equals(\"a\")) {\n this.stage = 25;\n } else {\n if (this.categories != null) {\n this.getCurrentBuilder().categories(Collections.unmodifiableSet(this.categories));\n this.categories = null;\n }\n this.description = new StringBuilder();\n this.stage = 26;\n }\n break;\n case 27:\n this.description.append('<');\n this.description.append(qName);\n for (int i = 0; i < atts.getLength(); i++) {\n this.description.append(' ');\n this.description.append(atts.getQName(i));\n this.description.append(\"=\\\"\");\n this.description.append(atts.getValue(i).replace(\"\\\"\", \"\\\\\\\"\"));\n this.description.append('\"');\n }\n this.description.append('>');\n break;\n case 28:\n if (qName.equals(\"ul\")) {\n this.chapters = new ArrayList<Chapter>();\n this.stage = 29;\n }\n break;\n case 29:\n if (qName.equals(\"div\")) {\n final String clazz = atts.getValue(\"class\");\n if (clazz != null && clazz.contains(\"chapter_container\")) {\n if (!clazz.contains(\"chapter_expander\")) {\n this.stage = 100;\n }\n }\n }\n if (qName.equals(\"li\") && \"save_ordering\".equals(atts.getValue(\"class\"))) {\n this.getCurrentBuilder().chapters(Collections.unmodifiableList(this.chapters));\n this.getCurrentBuilder().chapterCount(this.chapters.size());\n this.chapters = null;\n this.stage = 38;\n }\n break;\n case 100:\n this.stage = 101;\n break;\n case 101:\n this.stage = 30;\n break;\n case 30:\n this.chapter = Chapter.builder();\n if (qName.equals(\"img\")) {\n this.chapter.unread(\"//www.fimfiction-static.net/images/icons/new.png\".equals(atts.getValue(\"src\")));\n this.stage = 31;\n } else if (qName.equals(\"a\")) {\n try {\n this.chapter.url(new URL(\"http://www.fimfiction.net\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.chapterTitle = new StringBuilder();\n this.stage = 32;\n }\n break;\n case 31:\n if (qName.equals(\"a\")) {\n try {\n this.chapter.url(new URL(\"http://www.fimfiction.net\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.chapterTitle = new StringBuilder();\n this.stage = 32;\n }\n break;\n case 35:\n this.stage = 36;\n break;\n case 37:\n if (qName.equals(\"a\")) {\n this.chapter.id(toIntLiberal(atts.getValue(\"href\")));\n this.chapters.add(this.chapter.build());\n this.chapter = null;\n this.stage = 29;\n }\n break;\n case 203:\n if (qName.equals(\"div\")) {\n this.stage = 204;\n }\n break;\n case 205:\n if (qName.equals(\"br\")) {\n this.stage = 39;\n }\n break;\n case 39:\n if (qName.equals(\"span\")) {\n this.stage = 40;\n }\n break;\n case 41:\n if (qName.equals(\"br\")) {\n this.stage = 42;\n }\n if (qName.equals(\"a\")) {\n this.stage = 43;\n }\n break;\n case 42:\n if (qName.equals(\"span\")) {\n this.stage = 43;\n }\n break;\n case 43:\n case 44:\n if (qName.equals(\"img\")) {\n src = atts.getValue(\"src\");\n final int i = src.lastIndexOf('.');\n if (i > 46) {\n final String id = src.substring(46, i);\n for (final Character character : Character.values()) {\n if (id.equals(getImageId(character))) {\n this.characters.add(character);\n break;\n }\n }\n }\n }\n if (qName.equals(\"i\")) {\n this.getCurrentBuilder().characters(Collections.unmodifiableSet(this.characters));\n this.characters = null;\n this.endStory();\n this.stage = 0;\n }\n ;\n break;\n }\n }\n", "output": " public void startElement(final String uri, final String localName, final String qName, final Attributes atts) throws SAXException {\n switch (this.stage) {\n case 0:\n if (qName.equals(\"div\") && \"content_box post_content_box story_content_box\".equals(atts.getValue(\"class\"))) {\n this.startStory();\n this.getCurrentBuilder().id(Integer.parseInt(atts.getValue(\"id\").substring(6)));\n this.stage = 1;\n }\n break;\n case 1:\n String src = atts.getValue(\"src\");\n this.author = User.builder();\n if (src != null && !src.equals(\"//www.fimfiction-static.net/images/avatars/none_64.png\")) {\n try {\n this.author.profileImageUrl(new URL(\"http:\" + src));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n }\n this.stage = 2;\n break;\n case 2:\n if (qName.equals(\"div\") && \"right\".equals(atts.getValue(\"class\"))) {\n this.stage = 3;\n }\n break;\n case 3:\n this.stage = \"track_container\".equals(atts.getValue(\"class\")) ? 4 : 6;\n break;\n case 4:\n if (qName.equals(\"a\")) {\n this.favorited = atts.getValue(\"class\").contains(\"favourite_button_selected\");\n this.stage = 5;\n }\n break;\n case 5:\n if (qName.equals(\"input\")) {\n final boolean email = atts.getValue(\"checked\") != null;\n this.getCurrentBuilder().favorited(this.favorited ? email ? FavoriteState.FAVORITED_EMAIL : FavoriteState.FAVORITED : FavoriteState.NOT_FAVORITED);\n this.stage = 6;\n }\n break;\n case 6:\n if (qName.equals(\"a\")) {\n final String onClick = atts.getValue(\"onclick\");\n if (onClick != null && onClick.startsWith(\"Ra\")) {\n this.getCurrentBuilder().ratingToken(onClick.substring(onClick.indexOf('\\'') + 1, onClick.lastIndexOf('\\'')));\n }\n this.stage = 7;\n }\n break;\n case 8:\n if (qName.equals(\"a\")) {\n this.stage = 9;\n }\n break;\n case 10:\n if (qName.equals(\"b\")) {\n this.stage = 300;\n }\n break;\n case 301:\n if (qName.equals(\"span\")) {\n final String title = atts.getValue(\"title\");\n if (title != null) {\n this.getCurrentBuilder().totalViewCount(toIntLiberal(title));\n this.stage = 11;\n }\n }\n break;\n case 12:\n if (qName.equals(\"a\")) {\n this.getCurrentBuilder().readLater(atts.getValue(\"class\").contains(\"read_it_later_selected\"));\n }\n this.stage = 14;\n break;\n case 14:\n if (qName.equals(\"a\")) {\n try {\n this.getCurrentBuilder().url(new URL(\"http://www.fimfiction.net\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.title = new StringBuilder();\n this.stage = 15;\n }\n break;\n case 16:\n if (qName.equals(\"a\")) {\n this.authorName = new StringBuilder();\n this.stage = 17;\n }\n break;\n case 18:\n if (qName.equals(\"img\") && atts.getValue(\"src\").equals(\"//www.fimfiction-static.net/images/icons/views.png\")) {\n this.stage = 19;\n }\n break;\n case 20:\n if (qName.equals(\"div\") && \"description\".equals(atts.getValue(\"class\"))) {\n this.stage = 21;\n }\n break;\n case 21:\n this.stage = \"story_image\".equals(atts.getValue(\"class\")) ? 22 : 25;\n break;\n case 22:\n try {\n this.getCurrentBuilder().imageUrl(new URL(\"http:\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.stage = 23;\n break;\n case 23:\n try {\n this.getCurrentBuilder().thumbnailUrl(new URL(\"http:\" + atts.getValue(\"src\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.stage = 24;\n break;\n case 24:\n if (qName.equals(\"a\")) {\n this.stage = 25;\n } else {\n if (this.categories != null) {\n this.getCurrentBuilder().categories(Collections.unmodifiableSet(this.categories));\n this.categories = null;\n }\n this.description = new StringBuilder();\n this.stage = 26;\n }\n break;\n case 27:\n this.description.append('<');\n this.description.append(qName);\n for (int i = 0; i < atts.getLength(); i++) {\n this.description.append(' ');\n this.description.append(atts.getQName(i));\n this.description.append(\"=\\\"\");\n this.description.append(atts.getValue(i).replace(\"\\\"\", \"\\\\\\\"\"));\n this.description.append('\"');\n }\n this.description.append('>');\n break;\n case 28:\n if (qName.equals(\"ul\")) {\n this.chapters = new ArrayList<Chapter>();\n this.stage = 29;\n }\n break;\n case 29:\n if (qName.equals(\"div\")) {\n final String clazz = atts.getValue(\"class\");\n if (clazz != null && clazz.contains(\"chapter_container\")) {\n if (!clazz.contains(\"chapter_expander\")) {\n this.stage = 100;\n }\n }\n }\n if (qName.equals(\"li\") && \"save_ordering\".equals(atts.getValue(\"class\"))) {\n this.getCurrentBuilder().chapters(Collections.unmodifiableList(this.chapters));\n this.getCurrentBuilder().chapterCount(this.chapters.size());\n this.chapters = null;\n this.stage = 38;\n }\n break;\n case 100:\n this.stage = 101;\n break;\n case 101:\n this.stage = 30;\n break;\n case 30:\n this.chapter = Chapter.builder();\n if (qName.equals(\"i\")) {\n this.chapter.unread(atts.getValue(\"class\").length() == 17);\n this.stage = 31;\n } else if (qName.equals(\"a\")) {\n try {\n this.chapter.url(new URL(\"http://www.fimfiction.net\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.chapterTitle = new StringBuilder();\n this.stage = 32;\n }\n break;\n case 31:\n if (qName.equals(\"a\")) {\n try {\n this.chapter.url(new URL(\"http://www.fimfiction.net\" + atts.getValue(\"href\")));\n } catch (final MalformedURLException e) {\n throw new SAXException(e);\n }\n this.chapterTitle = new StringBuilder();\n this.stage = 32;\n }\n break;\n case 35:\n this.stage = 36;\n break;\n case 37:\n if (qName.equals(\"a\")) {\n this.chapter.id(toIntLiberal(atts.getValue(\"href\")));\n this.chapters.add(this.chapter.build());\n this.chapter = null;\n this.stage = 29;\n }\n break;\n case 203:\n if (qName.equals(\"div\")) {\n this.stage = 204;\n }\n break;\n case 205:\n if (qName.equals(\"br\")) {\n this.stage = 39;\n }\n break;\n case 39:\n if (qName.equals(\"span\")) {\n this.stage = 40;\n }\n break;\n case 41:\n if (qName.equals(\"br\")) {\n this.stage = 42;\n }\n if (qName.equals(\"a\")) {\n this.stage = 43;\n }\n break;\n case 42:\n if (qName.equals(\"span\")) {\n this.stage = 43;\n }\n break;\n case 43:\n case 44:\n if (qName.equals(\"img\")) {\n src = atts.getValue(\"src\");\n final int i = src.lastIndexOf('.');\n if (i > 46) {\n final String id = src.substring(46, i);\n for (final Character character : Character.values()) {\n if (id.equals(getImageId(character))) {\n this.characters.add(character);\n break;\n }\n }\n }\n }\n if (qName.equals(\"i\")) {\n this.getCurrentBuilder().characters(Collections.unmodifiableSet(this.characters));\n this.characters = null;\n this.endStory();\n this.stage = 0;\n }\n ;\n break;\n }\n }\n"} {"input": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.main);\n layoutCover();\n final Button button = (Button)findViewById(R.id.button_identify);\n button.setOnClickListener(new View.OnClickListener() {\n public void onClick(View view) {\n button.setText(\"\");\n ImageView img = (ImageView)findViewById(R.id.mic_animation);\n img.setBackgroundResource(R.drawable.microphone_animation);\n AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();\n frameAnimation.start();\n img.setVisibility(View.VISIBLE);\n Intent intent = new Intent(FingerprintShowActivity.this, CardsActivity.class);\n intent.putExtra(\"imdb\", \"http://www.imdb.com/title/tt1777828/\");\n startActivity(intent);\n }\n });\n", "output": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.main);\n layoutCover();\n final Button button = (Button)findViewById(R.id.button_identify);\n button.setOnClickListener(new View.OnClickListener() {\n public void onClick(View view) {\n button.setText(\"\");\n ImageView img = (ImageView)findViewById(R.id.mic_animation);\n img.setBackgroundResource(R.drawable.microphone_animation);\n AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();\n frameAnimation.start();\n img.setVisibility(View.VISIBLE);\n fingerprinter = new FingerprintListener(FingerprintShowActivity.this);\n }\n });\n"} {"input": "\tpublic void initEstrategiaElaborada() {\n\t\tVector<EstacionesCompare> estAuxSobrantes = new Vector<EstacionesCompare>();\n\t\tVector<EstacionesCompare> estAuxDemanda = new Vector<EstacionesCompare>();\n\t\tfor (int i = 0; i < estaciones.getNumStations(); i++) {\n\t\t\tint notMove = estaciones.getStationDoNotMove(i);\n\t\t\tint faltan = estaciones.getDemandNextHour(i) - estaciones.getStationNextState(i);\n\t\t\tif (notMove > 0) {\n\t\t\t\tif (notMove > 30)\n\t\t\t\t\tnotMove = 30;\n\t\t\t\tEstacionesCompare aux = new EstacionesCompare(i, notMove);\n\t\t\t\testAuxSobrantes.add(aux);\n\t\t\t}\n\t\t\tif (faltan > 0) {\n\t\t\t\tEstacionesCompare aux2 = new EstacionesCompare(i, faltan);\n\t\t\t\testAuxDemanda.add(aux2);\n\t\t\t}\n\t\t}\n\t\tordena(estAuxSobrantes);\n\t\tordena(estAuxDemanda);\n\t\tSystem.out.println(\"Do not move: \");\n\t\tfor (int i = 0; i < estAuxSobrantes.size(); i++)\n\t\t\tSystem.out.print(estAuxSobrantes.elementAt(i).getSobrantes() + \", \");\n\t\tSystem.out.println(\"Faltan: \");\n\t\tfor (int i = 0; i < estAuxDemanda.size(); i++)\n\t\t\tSystem.out.print(estAuxDemanda.elementAt(i).getSobrantes() + \", \");\n\t\tSystem.out.println(\"Furgonetas: \" + numFurgonetas);\n\t\tfor (int i = 0; (i < numFurgonetas) && (estAuxSobrantes.size() > 0) && (estAuxDemanda.size() > 0); i++) {\n\t\t\tSystem.out.print(\"1 \");\n\t\t\tTransporte trans = new Transporte();\n\t\t\tEstacionesCompare estDem0 = estAuxDemanda.elementAt(0);\n\t\t\tEstacionesCompare estSob0 = estAuxSobrantes.elementAt(0);\n\t\t\ttrans.setOrigen(estSob0.getOrigen());\n\t\t\ttrans.setParadaUno(estDem0.getOrigen());\n\t\t\tint diferencia = estDem0.getSobrantes() - estSob0.getSobrantes();\n\t\t\tif (diferencia > 0) {\n\t\t\t\ttrans.setBcParadaUno(estSob0.getSobrantes());\n\t\t\t\ttrans.setBcOrigen(estSob0.getSobrantes());\n\t\t\t\testDem0.setSobrantes(estDem0.getSobrantes() - estSob0.getSobrantes());\n\t\t\t\tif ((estAuxDemanda.size() > 1) && (estDem0.getSobrantes() < estAuxDemanda.elementAt(1).getSobrantes()))\n\t\t\t\t\tordena(estAuxDemanda);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttrans.setBcParadaUno(estDem0.getSobrantes());\n\t\t\t\testAuxDemanda.remove(0);\n\t\t\t\tif (estAuxDemanda.size() > 0) {\n\t\t\t\t\tEstacionesCompare estDem1 = estAuxDemanda.elementAt(0);\n\t\t\t\t\ttrans.setParadaDos(estDem1.getOrigen());\n\t\t\t\t\tif (estDem1.getSobrantes() + trans.getBcParadaUno() <= 30) {\n\t\t\t\t\t\ttrans.setBcParadaDos(estDem1.getSobrantes());\n\t\t\t\t\t\testAuxDemanda.remove(0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttrans.setBcParadaDos(30 - trans.getBcParadaUno());\n\t\t\t\t\t\testDem1.setSobrantes(estDem1.getSobrantes() - trans.getBcParadaDos());\n\t\t\t\t\t\tif ((estAuxDemanda.size() > 1) && (estDem1.getSobrantes() < estAuxDemanda.elementAt(1).getSobrantes()))\n\t\t\t\t\t\t\tordena(estAuxDemanda);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttrans.setBcOrigen(trans.getBcParadaUno() + trans.getBcParadaDos());\n\t\t\t}\n\t\t\testAuxSobrantes.remove(0);\n\t\t\ttransportes.add(trans);\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tprintTransportes();\n\t}\n", "output": "\tpublic void initEstrategiaElaborada() {\n\t\tVector<EstacionesCompare> estAuxSobrantes = new Vector<EstacionesCompare>();\n\t\tVector<EstacionesCompare> estAuxDemanda = new Vector<EstacionesCompare>();\n\t\tfor (int i = 0; i < estaciones.getNumStations(); i++) {\n\t\t\tint notMove = estaciones.getStationDoNotMove(i);\n\t\t\tint faltan = estaciones.getDemandNextHour(i) - estaciones.getStationNextState(i);\n\t\t\tif (notMove > 0) {\n\t\t\t\tif (notMove > 30)\n\t\t\t\t\tnotMove = 30;\n\t\t\t\tEstacionesCompare aux = new EstacionesCompare(i, notMove);\n\t\t\t\testAuxSobrantes.add(aux);\n\t\t\t}\n\t\t\tif (faltan > 0) {\n\t\t\t\tEstacionesCompare aux2 = new EstacionesCompare(i, faltan);\n\t\t\t\testAuxDemanda.add(aux2);\n\t\t\t}\n\t\t}\n\t\tordena(estAuxSobrantes);\n\t\tordena(estAuxDemanda);\n\t\tSystem.out.println(\"Do not move: \");\n\t\tfor (int i = 0; i < estAuxSobrantes.size(); i++)\n\t\t\tSystem.out.print(estAuxSobrantes.elementAt(i).getSobrantes() + \", \");\n\t\tSystem.out.println(\"Faltan: \");\n\t\tfor (int i = 0; i < estAuxDemanda.size(); i++)\n\t\t\tSystem.out.print(estAuxDemanda.elementAt(i).getSobrantes() + \", \");\n\t\tSystem.out.println(\"Furgonetas: \" + numFurgonetas);\n\t\tfor (int i = 0; (i < numFurgonetas) && (estAuxSobrantes.size() > 0) && (estAuxDemanda.size() > 0); i++) {\n\t\t\tSystem.out.print(\"1 \");\n\t\t\tTransporte trans = new Transporte();\n\t\t\tEstacionesCompare estDem0 = estAuxDemanda.elementAt(0);\n\t\t\tEstacionesCompare estSob0 = estAuxSobrantes.elementAt(0);\n\t\t\ttrans.setOrigen(estSob0.getOrigen());\n\t\t\ttrans.setParadaUno(estDem0.getOrigen());\n\t\t\tint diferencia = estDem0.getSobrantes() - estSob0.getSobrantes();\n\t\t\tif (diferencia > 0) {\n\t\t\t\ttrans.setBcParadaUno(estSob0.getSobrantes());\n\t\t\t\ttrans.setBcOrigen(estSob0.getSobrantes());\n\t\t\t\testDem0.setSobrantes(estDem0.getSobrantes() - estSob0.getSobrantes());\n\t\t\t\tif ((estAuxDemanda.size() > 1) && (estDem0.getSobrantes() < estAuxDemanda.elementAt(1).getSobrantes()))\n\t\t\t\t\tordena(estAuxDemanda);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttrans.setBcParadaUno(estDem0.getSobrantes());\n\t\t\t\testAuxDemanda.remove(0);\n\t\t\t\testSob0.setSobrantes(estSob0.getSobrantes() - trans.getBcParadaUno());\n\t\t\t\tif (estAuxDemanda.size() > 0) {\n\t\t\t\t\tEstacionesCompare estDem1 = estAuxDemanda.elementAt(0);\n\t\t\t\t\ttrans.setParadaDos(estDem1.getOrigen());\n\t\t\t\t\tif (estDem1.getSobrantes() > estSob0.getSobrantes()) {\n\t\t\t\t\t\ttrans.setBcParadaDos(estSob0.getSobrantes());\n\t\t\t\t\t\testDem1.setSobrantes(estDem1.getSobrantes() - trans.getBcParadaDos());\n\t\t\t\t\t\tif ((estAuxDemanda.size() > 1) && (estDem1.getSobrantes() < estAuxDemanda.elementAt(1).getSobrantes()))\n\t\t\t\t\t\t\tordena(estAuxDemanda);\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttrans.setBcParadaDos(estDem1.getSobrantes());\n\t\t\t\t\t\testAuxDemanda.remove(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttrans.setBcOrigen(trans.getBcParadaUno() + trans.getBcParadaDos());\n\t\t\t}\n\t\t\testAuxSobrantes.remove(0);\n\t\t\ttransportes.add(trans);\n\t\t}\n\t\tSystem.out.println(\"\");\n\t\tprintTransportes();\n\t}\n"} {"input": " protected void dispatchDraw(Canvas canvas) {\n if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {\n scrollChanged(getFirstVisiblePosition());\n }\n boolean drawStickiedHeader = mStickiedHeader != null\n && mAreHeadersSticky\n && mStickiedHeader.getVisibility() == View.VISIBLE;\n int headerHeight = getHeaderHeight();\n int top = mHeaderBottomPosition - headerHeight;\n if (drawStickiedHeader && mMaskStickyHeaderRegion) {\n mClippingRect.left = getPaddingLeft();\n mClippingRect.right = getWidth() - getPaddingRight();\n mClippingRect.top = mHeaderBottomPosition;\n mClippingRect.bottom = getHeight();\n canvas.save();\n canvas.clipRect(mClippingRect);\n }\n super.dispatchDraw(canvas);\n List<Integer> headerPositions = new ArrayList<Integer>();\n int vi = 0;\n for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition();) {\n long id = getItemIdAtPosition(i);\n if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {\n headerPositions.add(vi);\n }\n i += mNumMeasuredColumns;\n vi += mNumMeasuredColumns;\n }\n for (int i = 0; i < headerPositions.size(); i++) {\n ReferenceView frame = (ReferenceView)getChildAt(headerPositions\n .get(i));\n View header;\n try {\n header = (View)frame.getTag();\n } catch (Exception e) {\n return;\n }\n boolean headerIsStickied = ((HeaderFillerView)frame.getChildAt(0))\n .getHeaderId() == mCurrentHeaderId\n && frame.getTop() <= 0\n && mAreHeadersSticky;\n if (header.getVisibility() != View.VISIBLE || headerIsStickied) {\n continue;\n }\n int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),\n MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());\n int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,\n MeasureSpec.UNSPECIFIED);\n header.measure(widthMeasureSpec, heightMeasureSpec);\n header.layout(getLeft() + getPaddingLeft(), 0, getRight()\n - getPaddingRight(), frame.getHeight());\n mClippingRect.left = getPaddingLeft();\n mClippingRect.right = getWidth() - getPaddingRight();\n mClippingRect.bottom = frame.getBottom();\n mClippingRect.top = frame.getTop();\n canvas.save();\n canvas.clipRect(mClippingRect);\n canvas.translate(getPaddingLeft(), frame.getTop());\n header.draw(canvas);\n canvas.restore();\n }\n if (drawStickiedHeader && mMaskStickyHeaderRegion) {\n canvas.restore();\n } else if (!drawStickiedHeader) {\n return;\n }\n if (mStickiedHeader.getWidth() != getWidth() - getPaddingLeft()\n - getPaddingRight()) {\n int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),\n MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());\n int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,\n MeasureSpec.UNSPECIFIED);\n mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);\n mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()\n - getPaddingRight(), mStickiedHeader.getHeight());\n }\n mClippingRect.left = getPaddingLeft();\n mClippingRect.right = getWidth() - getPaddingRight();\n mClippingRect.bottom = top + headerHeight;\n if (mClippingToPadding) {\n mClippingRect.top = getPaddingTop();\n } else {\n mClippingRect.top = 0;\n }\n canvas.save();\n canvas.clipRect(mClippingRect);\n canvas.translate(getPaddingLeft(), top);\n canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(),\n (int)(0xff * (float)mHeaderBottomPosition / headerHeight),\n Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);\n mStickiedHeader.draw(canvas);\n canvas.restore();\n canvas.restore();\n }\n", "output": " protected void dispatchDraw(Canvas canvas) {\n if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {\n scrollChanged(getFirstVisiblePosition());\n }\n boolean drawStickiedHeader = mStickiedHeader != null\n && mAreHeadersSticky\n && mStickiedHeader.getVisibility() == View.VISIBLE;\n int headerHeight = getHeaderHeight();\n int top = mHeaderBottomPosition - headerHeight;\n if (drawStickiedHeader && mMaskStickyHeaderRegion) {\n mClippingRect.left = getPaddingLeft();\n mClippingRect.right = getWidth() - getPaddingRight();\n mClippingRect.top = mHeaderBottomPosition;\n mClippingRect.bottom = getHeight();\n canvas.save();\n canvas.clipRect(mClippingRect);\n }\n super.dispatchDraw(canvas);\n List<Integer> headerPositions = new ArrayList<Integer>();\n int vi = 0;\n for (int i = getFirstVisiblePosition(); i <= getLastVisiblePosition();) {\n long id = getItemIdAtPosition(i);\n if (id == StickyGridHeadersBaseAdapterWrapper.ID_HEADER) {\n headerPositions.add(vi);\n }\n i += mNumMeasuredColumns;\n vi += mNumMeasuredColumns;\n }\n for (int i = 0; i < headerPositions.size(); i++) {\n ReferenceView frame = (ReferenceView)getChildAt(headerPositions\n .get(i));\n View header;\n try {\n header = (View)frame.getTag();\n } catch (Exception e) {\n return;\n }\n boolean headerIsStickied = ((HeaderFillerView)frame.getChildAt(0))\n .getHeaderId() == mCurrentHeaderId\n && frame.getTop() < 0\n && mAreHeadersSticky;\n if (header.getVisibility() != View.VISIBLE || headerIsStickied) {\n continue;\n }\n int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),\n MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());\n int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,\n MeasureSpec.UNSPECIFIED);\n header.measure(widthMeasureSpec, heightMeasureSpec);\n header.layout(getLeft() + getPaddingLeft(), 0, getRight()\n - getPaddingRight(), frame.getHeight());\n mClippingRect.left = getPaddingLeft();\n mClippingRect.right = getWidth() - getPaddingRight();\n mClippingRect.bottom = frame.getBottom();\n mClippingRect.top = frame.getTop();\n canvas.save();\n canvas.clipRect(mClippingRect);\n canvas.translate(getPaddingLeft(), frame.getTop());\n header.draw(canvas);\n canvas.restore();\n }\n if (drawStickiedHeader && mMaskStickyHeaderRegion) {\n canvas.restore();\n } else if (!drawStickiedHeader) {\n return;\n }\n if (mStickiedHeader.getWidth() != getWidth() - getPaddingLeft()\n - getPaddingRight()) {\n int widthMeasureSpec = MeasureSpec.makeMeasureSpec(getWidth(),\n MeasureSpec.EXACTLY - getPaddingLeft() - getPaddingRight());\n int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0,\n MeasureSpec.UNSPECIFIED);\n mStickiedHeader.measure(widthMeasureSpec, heightMeasureSpec);\n mStickiedHeader.layout(getLeft() + getPaddingLeft(), 0, getRight()\n - getPaddingRight(), mStickiedHeader.getHeight());\n }\n mClippingRect.left = getPaddingLeft();\n mClippingRect.right = getWidth() - getPaddingRight();\n mClippingRect.bottom = top + headerHeight;\n if (mClippingToPadding) {\n mClippingRect.top = getPaddingTop();\n } else {\n mClippingRect.top = 0;\n }\n canvas.save();\n canvas.clipRect(mClippingRect);\n canvas.translate(getPaddingLeft(), top);\n canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(),\n (int)(0xff * (float)mHeaderBottomPosition / headerHeight),\n Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);\n mStickiedHeader.draw(canvas);\n canvas.restore();\n canvas.restore();\n }\n"} {"input": "\tpublic Element exec(Element params, ServiceContext context) throws Exception\n\t{\n\t\tGeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);\n\t\tSearchManager searchMan = gc.getSearchmanager();\n\t\tElement elData = SearchDefaults.getDefaultSearch(context, params);\n\t\tString sRemote = elData.getChildText(Geonet.SearchResult.REMOTE);\n\t\tboolean remote = sRemote != null && sRemote.equals(Geonet.Text.ON);\n\t\tUserSession session = context.getUserSession();\n\t\tMetaSearcher searcher;\n\t\tcontext.info(\"Creating searchers\");\n\t\tif (remote)\t \n\t\t\tsearcher = searchMan.newSearcher(SearchManager.Z3950, Geonet.File.SEARCH_Z3950_CLIENT);\n\t\telse \n\t\t\tsearcher = searchMan.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);\n\t\ttry {\n\t\t\tString summaryOnly = Util.getParam(params, Geonet.SearchResult.SUMMARY_ONLY, \"0\");\n\t\t\tString sBuildSummary = params.getChildText(Geonet.SearchResult.BUILD_SUMMARY);\n\t\t\tif (sBuildSummary != null && sBuildSummary.equals(\"false\") && !\"0\".equals(summaryOnly))\n\t\t\t\telData.getChild(Geonet.SearchResult.BUILD_SUMMARY).setText(\"true\");\n\t\t\tsearcher.search(context, elData, _config);\n\t\t\tsession.setProperty(Geonet.Session.SEARCH_REQUEST, elData);\n\t\t\tif (!\"0\".equals(summaryOnly)) {\n\t\t\t\treturn searcher.getSummary();\n\t\t\t} else {\n\t\t\t\telData.addContent(new Element(Geonet.SearchResult.FAST).setText(\"true\"));\n\t\t\t\telData.addContent(new Element(\"from\").setText(\"1\"));\n\t\t\t\telData.addContent(new Element(\"to\").setText(searcher.getSize() +\"\"));\n\t\t\t\tElement result = searcher.present(context, elData, _config);\n\t\t\t\tSelectionManager.updateMDResult(context.getUserSession(), result);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t} finally {\n\t\t\tsearcher.close();\n\t\t}\n\t}\n", "output": "\tpublic Element exec(Element params, ServiceContext context) throws Exception\n\t{\n\t\tGeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);\n\t\tSearchManager searchMan = gc.getSearchmanager();\n\t\tElement elData = SearchDefaults.getDefaultSearch(context, params);\n\t\tString sRemote = elData.getChildText(Geonet.SearchResult.REMOTE);\n\t\tboolean remote = sRemote != null && sRemote.equals(Geonet.Text.ON);\n\t\tUserSession session = context.getUserSession();\n\t\tMetaSearcher searcher;\n\t\tcontext.info(\"Creating searchers\");\n\t\tif (remote)\t \n\t\t\tsearcher = searchMan.newSearcher(SearchManager.Z3950, Geonet.File.SEARCH_Z3950_CLIENT);\n\t\telse \n\t\t\tsearcher = searchMan.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);\n\t\ttry {\n\t\t\tString summaryOnly = Util.getParam(params, Geonet.SearchResult.SUMMARY_ONLY, \"0\");\n\t\t\tString sBuildSummary = params.getChildText(Geonet.SearchResult.BUILD_SUMMARY);\n\t\t\tif (sBuildSummary != null && sBuildSummary.equals(\"false\") && !\"0\".equals(summaryOnly))\n\t\t\t\telData.getChild(Geonet.SearchResult.BUILD_SUMMARY).setText(\"true\");\n\t\t\tsession.setProperty(Geonet.Session.SEARCH_REQUEST, elData.clone());\n\t\t\tsearcher.search(context, elData, _config);\n\t\t\tif (!\"0\".equals(summaryOnly)) {\n\t\t\t\treturn searcher.getSummary();\n\t\t\t} else {\n\t\t\t\telData.addContent(new Element(Geonet.SearchResult.FAST).setText(\"true\"));\n\t\t\t\telData.addContent(new Element(\"from\").setText(\"1\"));\n\t\t\t\telData.addContent(new Element(\"to\").setText(searcher.getSize() +\"\"));\n\t\t\t\tElement result = searcher.present(context, elData, _config);\n\t\t\t\tSelectionManager.updateMDResult(context.getUserSession(), result);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t} finally {\n\t\t\tsearcher.close();\n\t\t}\n\t}\n"} {"input": "\tprivate void saveCSV(File folderToSaveIn, File databaseFile) throws Exception {\n\t\tConnection c = null;\n\t\tStatement statement = null;\n\t\tFile fileNameToSaveAs = new File(folderToSaveIn, databaseFile.getName() + \".csv\");\n\t\tBufferedWriter w = null;\n\t\tboolean success = false;\n\t\ttry {\n\t\t\tw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileNameToSaveAs), \"UTF-8\"));\n\t\t\tc = getConnection(databaseFile.getAbsolutePath());\n\t\t\tstatement = c.createStatement();\n\t\t\tstatement\n\t\t\t\t\t.execute(\"select datetime(ZCREATIONDATE + 978307200 ,'unixepoch', 'localtime') as CreationDate, datetime(ZMODIFICATIONDATE + 978307200 ,'unixepoch', 'localtime') as ModificationDate, ZTITLE as Title, (ZCONTENT) as Content,ZNOTE.Z_PK as Z_PK, ZCREATIONDATE, ZMODIFICATIONDATE from ZNOTE, ZNOTEBODY where ZNOTE.ZBODY = ZNOTEBODY.Z_PK order by ZMODIFICATIONDATE\");\n\t\t\tResultSet rs = statement.getResultSet();\n\t\t\tString headerLine = createCsvLine(\"Z_PK\", \"ZCREATIONDATE\", \"ZMODIFICATIONDATE\", \"CreationDate\",\"ModificationDate\",\"Title\",\"Content\");\n\t\t\tw.write(headerLine);\n\t\t\twhile (rs.next()) {\n\t\t\t\tString bodyLine = createCsvLine(rs.getString(\"CreationDate\"),rs.getString(\"ModificationDate\"),rs.getString(\"Title\"),\"<html><body>\" + rs.getString(\"Content\") + \"</body></html>\", rs.getString(\"Z_PK\"), rs.getString(\"ZCREATIONDATE\"), rs.getString(\"ZMODIFICATIONDATE\"));\n\t\t\t\tw.write(bodyLine);\n\t\t\t}\n\t\t\tsuccess = true;\n\t\t} catch (SQLException e) {\n\t\t\tthrow e;\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif (statement != null) {\n\t\t\t\t\tstatement.close();\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (c != null) {\n\t\t\t\t\tc.close();\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (w != null) {\n\t\t\t\t\tw.flush();\n\t\t\t\t\tw.close();\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t\tif (!success) {\n\t\t\t\tfileNameToSaveAs.delete();\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void saveCSV(File folderToSaveIn, File databaseFile) throws Exception {\n\t\tConnection c = null;\n\t\tStatement statement = null;\n\t\tFile fileNameToSaveAs = new File(folderToSaveIn, databaseFile.getName() + \".csv\");\n\t\tBufferedWriter w = null;\n\t\tboolean success = false;\n\t\ttry {\n\t\t\tw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileNameToSaveAs), \"UTF-8\"));\n\t\t\tc = getConnection(databaseFile.getAbsolutePath());\n\t\t\tstatement = c.createStatement();\n\t\t\tstatement\n\t\t\t\t\t.execute(\"select datetime(ZCREATIONDATE + 978307200 ,'unixepoch', 'localtime') as CreationDate, datetime(ZMODIFICATIONDATE + 978307200 ,'unixepoch', 'localtime') as ModificationDate, ZTITLE as Title, (ZCONTENT) as Content,ZNOTE.Z_PK as Z_PK, ZCREATIONDATE, ZMODIFICATIONDATE from ZNOTE, ZNOTEBODY where ZNOTE.ZBODY = ZNOTEBODY.Z_PK order by ZMODIFICATIONDATE\");\n\t\t\tResultSet rs = statement.getResultSet();\n\t\t\tString headerLine = createCsvLine( \"CreationDate\",\"ModificationDate\",\"Title\",\"Content\", \"Z_PK\", \"ZCREATIONDATE\",\"ZMODIFICATIONDATE\");\n\t\t\tw.write(headerLine);\n\t\t\twhile (rs.next()) {\n\t\t\t\tString bodyLine = createCsvLine(rs.getString(\"CreationDate\"),rs.getString(\"ModificationDate\"),rs.getString(\"Title\"),\"<html><body>\" + rs.getString(\"Content\") + \"</body></html>\", rs.getString(\"Z_PK\"), rs.getString(\"ZCREATIONDATE\"), rs.getString(\"ZMODIFICATIONDATE\"));\n\t\t\t\tw.write(bodyLine);\n\t\t\t}\n\t\t\tsuccess = true;\n\t\t} catch (SQLException e) {\n\t\t\tthrow e;\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tif (statement != null) {\n\t\t\t\t\tstatement.close();\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (c != null) {\n\t\t\t\t\tc.close();\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (w != null) {\n\t\t\t\t\tw.flush();\n\t\t\t\t\tw.close();\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t\tif (!success) {\n\t\t\t\tfileNameToSaveAs.delete();\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public MachineImageView() {\n this.setSizeFull();\n VerticalLayout verticalLayout = new VerticalLayout();\n verticalLayout.setSizeFull();\n HorizontalLayout actionButtonHeader = new HorizontalLayout();\n actionButtonHeader.setMargin(true);\n actionButtonHeader.setSpacing(true);\n actionButtonHeader.setWidth(\"100%\");\n actionButtonHeader.setHeight(\"50px\");\n this.registerMachineImageButton = new Button(\"Register Image...\");\n this.registerMachineImageButton.setIcon(new ThemeResource(\"img/add.png\"));\n this.registerMachineImageButton.addClickListener(new ClickListener() {\n @Override\n public void buttonClick(final ClickEvent event) {\n if (MachineImageView.this.machineImageRegisterWizard.init(MachineImageView.this)) {\n UI.getCurrent().addWindow(MachineImageView.this.machineImageRegisterWizard);\n }\n }\n });\n actionButtonHeader.addComponent(this.registerMachineImageButton);\n this.deleteMachineImageButton = new Button(\"Delete\");\n this.deleteMachineImageButton.setIcon(new ThemeResource(\"img/delete.png\"));\n this.deleteMachineImageButton.setEnabled(false);\n this.deleteMachineImageButton.addClickListener(new ClickListener() {\n @Override\n public void buttonClick(final ClickEvent event) {\n final Set<?> selectedImageIds = (Set<?>) MachineImageView.this.machineImageTable.getValue();\n String name = MachineImageView.this.images.getItem(selectedImageIds.iterator().next()).getBean().getName();\n ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialogWithOption(\"Delete Image\",\n \"Are you sure you want to delete image \" + name + \" ?\", \"delete image on provider\",\n new ConfirmDialog.ConfirmationDialogCallback() {\n @Override\n public void response(final boolean ok, final boolean deleteOnProvider) {\n if (ok) {\n for (Object id : selectedImageIds) {\n try {\n if (deleteOnProvider) {\n MachineImageView.this.machineImageManager.deleteMachineImage(id.toString());\n } else {\n MachineImageView.this.machineImageManager.unregisterMachineImage(id.toString());\n }\n } catch (CloudProviderException e) {\n Util.diplayErrorMessageBox(\"Image delete failure\", e);\n }\n }\n MachineImageView.this.valueChange(null);\n }\n }\n });\n MachineImageView.this.getUI().addWindow(confirmDialog);\n }\n });\n actionButtonHeader.addComponent(this.deleteMachineImageButton);\n Label spacer = new Label();\n spacer.setWidth(\"100%\");\n actionButtonHeader.addComponent(spacer);\n actionButtonHeader.setExpandRatio(spacer, 1.0f);\n Button button = new Button(\"Refresh\", new ClickListener() {\n @Override\n public void buttonClick(final ClickEvent event) {\n MachineImageView.this.refresh();\n }\n });\n button.setIcon(new ThemeResource(\"img/refresh.png\"));\n actionButtonHeader.addComponent(button);\n verticalLayout.addComponent(actionButtonHeader);\n verticalLayout.addComponent(this.machineImageTable = this.createMachineImageTable());\n verticalLayout.setExpandRatio(this.machineImageTable, 1.0f);\n this.setFirstComponent(verticalLayout);\n this.setSecondComponent(this.detailView = new MachineImageDetailView(this));\n this.setSplitPosition(60.0f);\n }\n", "output": " public MachineImageView() {\n this.setSizeFull();\n VerticalLayout verticalLayout = new VerticalLayout();\n verticalLayout.setSizeFull();\n HorizontalLayout actionButtonHeader = new HorizontalLayout();\n actionButtonHeader.setMargin(true);\n actionButtonHeader.setSpacing(true);\n actionButtonHeader.setWidth(\"100%\");\n actionButtonHeader.setHeight(\"50px\");\n this.registerMachineImageButton = new Button(\"Register Image...\");\n this.registerMachineImageButton.setIcon(new ThemeResource(\"img/add.png\"));\n this.registerMachineImageButton.addClickListener(new ClickListener() {\n @Override\n public void buttonClick(final ClickEvent event) {\n if (MachineImageView.this.machineImageRegisterWizard.init(MachineImageView.this)) {\n UI.getCurrent().addWindow(MachineImageView.this.machineImageRegisterWizard);\n }\n }\n });\n actionButtonHeader.addComponent(this.registerMachineImageButton);\n this.deleteMachineImageButton = new Button(\"Delete\");\n this.deleteMachineImageButton.setIcon(new ThemeResource(\"img/delete.png\"));\n this.deleteMachineImageButton.setEnabled(false);\n this.deleteMachineImageButton.addClickListener(new ClickListener() {\n @Override\n public void buttonClick(final ClickEvent event) {\n final Set<?> selectedImageIds = (Set<?>) MachineImageView.this.machineImageTable.getValue();\n StringBuilder sb = new StringBuilder();\n sb.append(\"Are you sure you want to delete \");\n if (selectedImageIds.size() == 1) {\n Object id = selectedImageIds.iterator().next();\n sb.append(\"image \" + MachineImageView.this.images.getItem(id).getBean().getName() + \" ?\");\n } else {\n sb.append(\" these \" + selectedImageIds.size() + \" images ?\");\n }\n String name = MachineImageView.this.images.getItem(selectedImageIds.iterator().next()).getBean().getName();\n ConfirmDialog confirmDialog = ConfirmDialog.newConfirmDialogWithOption(\"Delete Image\", sb.toString(),\n \"delete image on provider\", new ConfirmDialog.ConfirmationDialogCallback() {\n @Override\n public void response(final boolean ok, final boolean deleteOnProvider) {\n if (ok) {\n for (Object id : selectedImageIds) {\n try {\n if (deleteOnProvider) {\n MachineImageView.this.machineImageManager.deleteMachineImage(id.toString());\n } else {\n MachineImageView.this.machineImageManager.unregisterMachineImage(id.toString());\n }\n } catch (CloudProviderException e) {\n Util.diplayErrorMessageBox(\"Image delete failure\", e);\n }\n }\n MachineImageView.this.valueChange(null);\n }\n }\n });\n MachineImageView.this.getUI().addWindow(confirmDialog);\n }\n });\n actionButtonHeader.addComponent(this.deleteMachineImageButton);\n Label spacer = new Label();\n spacer.setWidth(\"100%\");\n actionButtonHeader.addComponent(spacer);\n actionButtonHeader.setExpandRatio(spacer, 1.0f);\n Button button = new Button(\"Refresh\", new ClickListener() {\n @Override\n public void buttonClick(final ClickEvent event) {\n MachineImageView.this.refresh();\n }\n });\n button.setIcon(new ThemeResource(\"img/refresh.png\"));\n actionButtonHeader.addComponent(button);\n verticalLayout.addComponent(actionButtonHeader);\n verticalLayout.addComponent(this.machineImageTable = this.createMachineImageTable());\n verticalLayout.setExpandRatio(this.machineImageTable, 1.0f);\n this.setFirstComponent(verticalLayout);\n this.setSecondComponent(this.detailView = new MachineImageDetailView(this));\n this.setSplitPosition(60.0f);\n }\n"} {"input": "\tpublic static void initDefaultColors() {\n\t\tfor (int i = 0; i < blockColors.length; i++) {\n\t\t\tblockColors[i] = null;\n\t\t}\n\t\tsetDefaultColor(0, 0, 0);\n\t\tsetDefaultColor(1, 0, -9934744);\n\t\tsetDefaultColor(2, 0, -12096451);\n\t\tsetDefaultColor(3, 0, -8825542);\n\t\tsetDefaultColor(4, 0, -6974059);\n\t\tsetDefaultColor(5, 0, -4417438);\n\t\tsetDefaultColor(6, 0, 1816358162);\n\t\tsetDefaultColor(6, 1, 1412577569);\n\t\tsetDefaultColor(6, 2, 1819645267);\n\t\tsetDefaultColor(7, 0, -13421773);\n\t\tsetDefaultColor(8, 0, -1960157441);\n\t\tsetDefaultColor(9, 0, -1960157441);\n\t\tsetDefaultColor(10, 0, -2530028);\n\t\tsetDefaultColor(11, 0, -2530028);\n\t\tsetDefaultColor(12, 0, -2238560);\n\t\tsetDefaultColor(13, 0, -7766146);\n\t\tsetDefaultColor(14, 0, -7304324);\n\t\tsetDefaultColor(15, 0, -7830913);\n\t\tsetDefaultColor(16, 0, -9145485);\n\t\tsetDefaultColor(17, 0, -10006222);\n\t\tsetDefaultColor(17, 1, -13358823);\n\t\tsetDefaultColor(17, 2, -3620193);\n\t\tsetDefaultColor(18, 0, -1708107227);\n\t\tsetDefaultColor(18, 1, -1522906074);\n\t\tsetDefaultColor(18, 2, -1707912909);\n\t\tsetDefaultColor(18, 3, -1707912909);\n\t\tsetDefaultColor(18, 4, -1708107227);\n\t\tsetDefaultColor(18, 5, -1522906074);\n\t\tsetDefaultColor(18, 6, -1707912909);\n\t\tsetDefaultColor(18, 7, -1707912909);\n\t\tsetDefaultColor(19, 0, -1710770);\n\t\tsetDefaultColor(20, 0, 1090519039);\n\t\tsetDefaultColor(21, 0, -9998201);\n\t\tsetDefaultColor(22, 0, -14858330);\n\t\tsetDefaultColor(23, 0, -10987432);\n\t\tsetDefaultColor(24, 0, -2370913);\n\t\tsetDefaultColor(25, 0, -10206158);\n\t\tsetDefaultColor(26, 0, -6339259);\n\t\tsetDefaultColor(26, 1, -6339259);\n\t\tsetDefaultColor(26, 2, -6339259);\n\t\tsetDefaultColor(26, 3, -6339259);\n\t\tsetDefaultColor(26, 4, -6339259);\n\t\tsetDefaultColor(26, 5, -6339259);\n\t\tsetDefaultColor(26, 6, -6339259);\n\t\tsetDefaultColor(26, 7, -6339259);\n\t\tsetDefaultColor(26, 8, -6397599);\n\t\tsetDefaultColor(26, 9, -6397599);\n\t\tsetDefaultColor(26, 10, -6397599);\n\t\tsetDefaultColor(26, 11, -6397599);\n\t\tsetDefaultColor(26, 12, -6397599);\n\t\tsetDefaultColor(26, 13, -6397599);\n\t\tsetDefaultColor(26, 14, -6397599);\n\t\tsetDefaultColor(26, 15, -6397599);\n\t\tsetDefaultColor(27, 0, -528457632);\n\t\tsetDefaultColor(27, 1, -528457632);\n\t\tsetDefaultColor(27, 2, -528457632);\n\t\tsetDefaultColor(27, 3, -528457632);\n\t\tsetDefaultColor(27, 4, -528457632);\n\t\tsetDefaultColor(27, 5, -528457632);\n\t\tsetDefaultColor(27, 6, -528457632);\n\t\tsetDefaultColor(27, 7, -528457632);\n\t\tsetDefaultColor(27, 8, -523214752);\n\t\tsetDefaultColor(27, 9, -523214752);\n\t\tsetDefaultColor(27, 10, -523214752);\n\t\tsetDefaultColor(27, 11, -523214752);\n\t\tsetDefaultColor(27, 12, -523214752);\n\t\tsetDefaultColor(27, 13, -523214752);\n\t\tsetDefaultColor(27, 14, -523214752);\n\t\tsetDefaultColor(27, 15, -523214752);\n\t\tsetDefaultColor(28, 0, -8952744);\n\t\tsetDefaultColor(29, 0, -9605779);\n\t\tsetDefaultColor(29, 1, -7499421);\n\t\tsetDefaultColor(29, 2, -9804194);\n\t\tsetDefaultColor(29, 3, -9804194);\n\t\tsetDefaultColor(29, 4, -9804194);\n\t\tsetDefaultColor(29, 5, -9804194);\n\t\tsetDefaultColor(29, 8, -9605779);\n\t\tsetDefaultColor(29, 9, -7499421);\n\t\tsetDefaultColor(29, 10, -9804194);\n\t\tsetDefaultColor(29, 11, -9804194);\n\t\tsetDefaultColor(29, 12, -9804194);\n\t\tsetDefaultColor(29, 13, -9804194);\n\t\tsetDefaultColor(30, 0, 1775884761);\n\t\tsetDefaultColor(31, 0, 1383747097);\n\t\tsetDefaultColor(31, 1, -1571782606);\n\t\tsetDefaultColor(31, 2, 1330675762);\n\t\tsetDefaultColor(32, 0, 1383747097);\n\t\tsetDefaultColor(33, 0, -9605779);\n\t\tsetDefaultColor(33, 1, -6717094);\n\t\tsetDefaultColor(33, 2, -9804194);\n\t\tsetDefaultColor(33, 3, -9804194);\n\t\tsetDefaultColor(33, 4, -9804194);\n\t\tsetDefaultColor(33, 5, -9804194);\n\t\tsetDefaultColor(33, 8, -9605779);\n\t\tsetDefaultColor(33, 9, -6717094);\n\t\tsetDefaultColor(33, 10, -9804194);\n\t\tsetDefaultColor(33, 11, -9804194);\n\t\tsetDefaultColor(33, 12, -9804194);\n\t\tsetDefaultColor(33, 13, -9804194);\n\t\tsetDefaultColor(34, 0, -6717094);\n\t\tsetDefaultColor(34, 1, -6717094);\n\t\tsetDefaultColor(34, 2, -2137423526);\n\t\tsetDefaultColor(34, 3, -2137423526);\n\t\tsetDefaultColor(34, 4, -2137423526);\n\t\tsetDefaultColor(34, 5, -2137423526);\n\t\tsetDefaultColor(34, 8, -6717094);\n\t\tsetDefaultColor(34, 9, -7499421);\n\t\tsetDefaultColor(34, 10, -2137423526);\n\t\tsetDefaultColor(34, 11, -2137423526);\n\t\tsetDefaultColor(34, 12, -2137423526);\n\t\tsetDefaultColor(34, 13, -2137423526);\n\t\tsetDefaultColor(35, 0, -2236963);\n\t\tsetDefaultColor(35, 1, -1475018);\n\t\tsetDefaultColor(35, 2, -4370744);\n\t\tsetDefaultColor(35, 3, -9991469);\n\t\tsetDefaultColor(35, 4, -4082660);\n\t\tsetDefaultColor(35, 5, -12928209);\n\t\tsetDefaultColor(35, 6, -2588006);\n\t\tsetDefaultColor(35, 7, -12434878);\n\t\tsetDefaultColor(35, 8, -6445916);\n\t\tsetDefaultColor(35, 9, -14191468);\n\t\tsetDefaultColor(35, 10, -8374846);\n\t\tsetDefaultColor(35, 11, -14273895);\n\t\tsetDefaultColor(35, 12, -11193573);\n\t\tsetDefaultColor(35, 13, -13153256);\n\t\tsetDefaultColor(35, 14, -6083544);\n\t\tsetDefaultColor(35, 15, -15067369);\n\t\tsetDefaultColor(37, 0, -1057883902);\n\t\tsetDefaultColor(38, 0, -1057552625);\n\t\tsetDefaultColor(39, 0, -1064211115);\n\t\tsetDefaultColor(40, 0, -1063643364);\n\t\tsetDefaultColor(41, 0, -66723);\n\t\tsetDefaultColor(42, 0, -1447447);\n\t\tsetDefaultColor(43, 0, -5723992);\n\t\tsetDefaultColor(43, 1, -1712721);\n\t\tsetDefaultColor(43, 2, -7046838);\n\t\tsetDefaultColor(43, 3, -8224126);\n\t\tsetDefaultColor(43, 4, -6591135);\n\t\tsetDefaultColor(43, 5, -8750470);\n\t\tsetDefaultColor(44, 0, -5723992);\n\t\tsetDefaultColor(44, 1, -1712721);\n\t\tsetDefaultColor(44, 2, -7046838);\n\t\tsetDefaultColor(44, 3, -8224126);\n\t\tsetDefaultColor(44, 4, -6591135);\n\t\tsetDefaultColor(44, 5, -8750470);\n\t\tsetDefaultColor(45, 0, -6591135);\n\t\tsetDefaultColor(46, 0, -2407398);\n\t\tsetDefaultColor(47, 0, -4943782);\n\t\tsetDefaultColor(48, 0, -14727393);\n\t\tsetDefaultColor(49, 0, -15527395);\n\t\tsetDefaultColor(50, 0, 1627379712);\n\t\tsetDefaultColor(51, 0, -4171263);\n\t\tsetDefaultColor(52, 0, -14262393);\n\t\tsetDefaultColor(53, 0, -4417438);\n\t\tsetDefaultColor(54, 0, -7378659);\n\t\tsetDefaultColor(55, 0, 1827466476);\n\t\tsetDefaultColor(56, 0, -8287089);\n\t\tsetDefaultColor(57, 0, -10428192);\n\t\tsetDefaultColor(58, 0, -8038091);\n\t\tsetDefaultColor(59, 0, 302029071);\n\t\tsetDefaultColor(59, 1, 957524751);\n\t\tsetDefaultColor(59, 2, 1444710667);\n\t\tsetDefaultColor(59, 3, -1708815608);\n\t\tsetDefaultColor(59, 4, -835813369);\n\t\tsetDefaultColor(59, 5, -532579833);\n\t\tsetDefaultColor(59, 6, -531663353);\n\t\tsetDefaultColor(59, 7, -531208953);\n\t\tsetDefaultColor(60, 0, -9221331);\n\t\tsetDefaultColor(60, 1, -9550295);\n\t\tsetDefaultColor(60, 2, -9879003);\n\t\tsetDefaultColor(60, 3, -10207967);\n\t\tsetDefaultColor(60, 4, -10536675);\n\t\tsetDefaultColor(60, 5, -10865383);\n\t\tsetDefaultColor(60, 6, -11194347);\n\t\tsetDefaultColor(60, 7, -11523055);\n\t\tsetDefaultColor(60, 8, -11786226);\n\t\tsetDefaultColor(61, 0, -9145228);\n\t\tsetDefaultColor(62, 0, -8355712);\n\t\tsetDefaultColor(63, 0, -1598779307);\n\t\tsetDefaultColor(64, 0, -1064934094);\n\t\tsetDefaultColor(65, 0, -2139595212);\n\t\tsetDefaultColor(66, 0, -8951211);\n\t\tsetDefaultColor(67, 0, -6381922);\n\t\tsetDefaultColor(68, 0, -1598779307);\n\t\tsetDefaultColor(69, 0, -1603709901);\n\t\tsetDefaultColor(70, 0, -7368817);\n\t\tsetDefaultColor(71, 0, -1061043775);\n\t\tsetDefaultColor(72, 0, -4417438);\n\t\tsetDefaultColor(73, 0, -6981535);\n\t\tsetDefaultColor(74, 0, -6981535);\n\t\tsetDefaultColor(75, 0, -2141709038);\n\t\tsetDefaultColor(76, 0, -2136923117);\n\t\tsetDefaultColor(77, 0, -2139851660);\n\t\tsetDefaultColor(78, 0, -1314833);\n\t\tsetDefaultColor(79, 0, -1619219203);\n\t\tsetDefaultColor(80, 0, -986896);\n\t\tsetDefaultColor(81, 0, -15695840);\n\t\tsetDefaultColor(82, 0, -6380624);\n\t\tsetDefaultColor(83, 0, -7094428);\n\t\tsetDefaultColor(84, 0, -9811658);\n\t\tsetDefaultColor(85, 0, -4417438);\n\t\tsetDefaultColor(86, 0, -4229867);\n\t\tsetDefaultColor(87, 0, -9751501);\n\t\tsetDefaultColor(88, 0, -11255757);\n\t\tsetDefaultColor(89, 0, -4157626);\n\t\tsetDefaultColor(90, 0, -9231226);\n\t\tsetDefaultColor(91, 0, -3893474);\n\t\tsetDefaultColor(92, 0, -1848115);\n\t\tsetDefaultColor(93, 0, -6843501);\n\t\tsetDefaultColor(94, 0, -4156525);\n\t\tsetDefaultColor(95, 0, -7378659);\n\t\tsetDefaultColor(96, 0, -8495827);\n\t\tsetDefaultColor(96, 1, -8495827);\n\t\tsetDefaultColor(96, 2, -8495827);\n\t\tsetDefaultColor(96, 3, -8495827);\n\t\tsetDefaultColor(96, 4, 545152301);\n\t\tsetDefaultColor(96, 5, 545152301);\n\t\tsetDefaultColor(96, 6, 545152301);\n\t\tsetDefaultColor(96, 7, 545152301);\n\t\tsetDefaultColor(97, 0, -9934744);\n\t\tsetDefaultColor(97, 1, -6974059);\n\t\tsetDefaultColor(97, 2, -8750470);\n\t\tsetDefaultColor(98, 0, -8750470);\n\t\tsetDefaultColor(98, 1, -9275542);\n\t\tsetDefaultColor(98, 2, -9013642);\n\t\tsetDefaultColor(99, 0, -3495048);\n\t\tsetDefaultColor(99, 1, -7509421);\n\t\tsetDefaultColor(99, 2, -7509421);\n\t\tsetDefaultColor(99, 3, -7509421);\n\t\tsetDefaultColor(99, 4, -7509421);\n\t\tsetDefaultColor(99, 5, -7509421);\n\t\tsetDefaultColor(99, 6, -7509421);\n\t\tsetDefaultColor(99, 7, -7509421);\n\t\tsetDefaultColor(99, 8, -7509421);\n\t\tsetDefaultColor(99, 9, -7509421);\n\t\tsetDefaultColor(99, 10, -3495048);\n\t\tsetDefaultColor(100, 0, -3495048);\n\t\tsetDefaultColor(100, 1, -4840156);\n\t\tsetDefaultColor(100, 2, -4840156);\n\t\tsetDefaultColor(100, 3, -4840156);\n\t\tsetDefaultColor(100, 4, -4840156);\n\t\tsetDefaultColor(100, 5, -4840156);\n\t\tsetDefaultColor(100, 6, -4840156);\n\t\tsetDefaultColor(100, 7, -4840156);\n\t\tsetDefaultColor(100, 8, -4840156);\n\t\tsetDefaultColor(100, 9, -4840156);\n\t\tsetDefaultColor(100, 10, -3495048);\n\t\tsetDefaultColor(101, 0, -2140312470);\n\t\tsetDefaultColor(102, 0, 1627389951);\n\t\tsetDefaultColor(103, 0, -6842076);\n\t\tsetDefaultColor(104, 0, 1073780992);\n\t\tsetDefaultColor(104, 1, 1209242626);\n\t\tsetDefaultColor(104, 2, 1344704516);\n\t\tsetDefaultColor(104, 3, 1480166151);\n\t\tsetDefaultColor(104, 4, 1615693321);\n\t\tsetDefaultColor(104, 5, 1751154956);\n\t\tsetDefaultColor(104, 6, 1886616590);\n\t\tsetDefaultColor(104, 7, 2022144016);\n\t\tsetDefaultColor(105, 0, 1073780992);\n\t\tsetDefaultColor(105, 1, 1209242626);\n\t\tsetDefaultColor(105, 2, 1344704516);\n\t\tsetDefaultColor(105, 3, 1480166151);\n\t\tsetDefaultColor(105, 4, 1615693321);\n\t\tsetDefaultColor(105, 5, 1751154956);\n\t\tsetDefaultColor(105, 6, 1886616590);\n\t\tsetDefaultColor(105, 7, 2022144016);\n\t\tsetDefaultColor(106, 0, -2145432054);\n\t\tsetDefaultColor(107, 0, -1061382046);\n\t\tsetDefaultColor(108, 0, -6591135);\n\t\tsetDefaultColor(109, 0, -8750470);\n\t\tsetDefaultColor(110, 0, 0xAB8790, 0xFF);\n\t\tsetDefaultColor(111, 0, 0x158003, 0xFF);\n\t\tsetDefaultColor(112, 0, 0x40002F, 0xFF);\n\t\tsetDefaultColor(113, 0, 0x40002F, 0xFF);\n\t\tsetDefaultColor(114, 0, 0x40002F, 0xFF);\n\t\tsetDefaultColor(115, 0, 0xA30321, 0xFF);\n\t\tsetDefaultColor(116, 0, 0xF0DDE0, 0xFF);\n\t\tsetDefaultColor(117, 0, -9934744);\n\t\tsetDefaultColor(118, 0, -9934744);\n\t\tsetDefaultColor(119, 0, 0x000000, 0xFF);\n\t\tsetDefaultColor(120, 0, 0x376319, 0xFF);\n\t\tsetDefaultColor(121, 0, 0xE4E8B5, 0xFF);\n\t\tsetDefaultColor(122, 0, 0x24031E, 0xFF);\n\t\tsetDefaultColor(123, 0, 0x784C10, 0xFF);\n\t\tsetDefaultColor(124, 0, 0xE3DE54, 0xFF);\n\t}\n", "output": "\tpublic static void initDefaultColors() {\n\t\tfor (int i = 0; i < blockColors.length; i++) {\n\t\t\tblockColors[i] = null;\n\t\t}\n\t\tsetDefaultColor(0, 0, 0);\n\t\tsetDefaultColor(1, 0, -9934744);\n\t\tsetDefaultColor(2, 0, -12096451);\n\t\tsetDefaultColor(3, 0, -8825542);\n\t\tsetDefaultColor(4, 0, -6974059);\n\t\tsetDefaultColor(5, 0, -4417438);\n\t\tsetDefaultColor(6, 0, 1816358162);\n\t\tsetDefaultColor(6, 1, 1412577569);\n\t\tsetDefaultColor(6, 2, 1819645267);\n\t\tsetDefaultColor(7, 0, -13421773);\n\t\tsetDefaultColor(8, 0, -1960157441);\n\t\tsetDefaultColor(9, 0, -1960157441);\n\t\tsetDefaultColor(10, 0, -2530028);\n\t\tsetDefaultColor(11, 0, -2530028);\n\t\tsetDefaultColor(12, 0, -2238560);\n\t\tsetDefaultColor(13, 0, -7766146);\n\t\tsetDefaultColor(14, 0, -7304324);\n\t\tsetDefaultColor(15, 0, -7830913);\n\t\tsetDefaultColor(16, 0, -9145485);\n\t\tsetDefaultColor(17, 0, -10006222);\n\t\tsetDefaultColor(17, 1, -13358823);\n\t\tsetDefaultColor(17, 2, -3620193);\n\t\tsetDefaultColor(18, 0, -1708107227);\n\t\tsetDefaultColor(18, 1, -1522906074);\n\t\tsetDefaultColor(18, 2, -1707912909);\n\t\tsetDefaultColor(18, 3, -1707912909);\n\t\tsetDefaultColor(18, 4, -1708107227);\n\t\tsetDefaultColor(18, 5, -1522906074);\n\t\tsetDefaultColor(18, 6, -1707912909);\n\t\tsetDefaultColor(18, 7, -1707912909);\n\t\tsetDefaultColor(19, 0, -1710770);\n\t\tsetDefaultColor(20, 0, 1090519039);\n\t\tsetDefaultColor(21, 0, -9998201);\n\t\tsetDefaultColor(22, 0, -14858330);\n\t\tsetDefaultColor(23, 0, -10987432);\n\t\tsetDefaultColor(24, 0, -2370913);\n\t\tsetDefaultColor(25, 0, -10206158);\n\t\tsetDefaultColor(26, 0, -6339259);\n\t\tsetDefaultColor(26, 1, -6339259);\n\t\tsetDefaultColor(26, 2, -6339259);\n\t\tsetDefaultColor(26, 3, -6339259);\n\t\tsetDefaultColor(26, 4, -6339259);\n\t\tsetDefaultColor(26, 5, -6339259);\n\t\tsetDefaultColor(26, 6, -6339259);\n\t\tsetDefaultColor(26, 7, -6339259);\n\t\tsetDefaultColor(26, 8, -6397599);\n\t\tsetDefaultColor(26, 9, -6397599);\n\t\tsetDefaultColor(26, 10, -6397599);\n\t\tsetDefaultColor(26, 11, -6397599);\n\t\tsetDefaultColor(26, 12, -6397599);\n\t\tsetDefaultColor(26, 13, -6397599);\n\t\tsetDefaultColor(26, 14, -6397599);\n\t\tsetDefaultColor(26, 15, -6397599);\n\t\tsetDefaultColor(27, 0, -528457632);\n\t\tsetDefaultColor(27, 1, -528457632);\n\t\tsetDefaultColor(27, 2, -528457632);\n\t\tsetDefaultColor(27, 3, -528457632);\n\t\tsetDefaultColor(27, 4, -528457632);\n\t\tsetDefaultColor(27, 5, -528457632);\n\t\tsetDefaultColor(27, 6, -528457632);\n\t\tsetDefaultColor(27, 7, -528457632);\n\t\tsetDefaultColor(27, 8, -523214752);\n\t\tsetDefaultColor(27, 9, -523214752);\n\t\tsetDefaultColor(27, 10, -523214752);\n\t\tsetDefaultColor(27, 11, -523214752);\n\t\tsetDefaultColor(27, 12, -523214752);\n\t\tsetDefaultColor(27, 13, -523214752);\n\t\tsetDefaultColor(27, 14, -523214752);\n\t\tsetDefaultColor(27, 15, -523214752);\n\t\tsetDefaultColor(28, 0, -8952744);\n\t\tsetDefaultColor(29, 0, -9605779);\n\t\tsetDefaultColor(29, 1, -7499421);\n\t\tsetDefaultColor(29, 2, -9804194);\n\t\tsetDefaultColor(29, 3, -9804194);\n\t\tsetDefaultColor(29, 4, -9804194);\n\t\tsetDefaultColor(29, 5, -9804194);\n\t\tsetDefaultColor(29, 8, -9605779);\n\t\tsetDefaultColor(29, 9, -7499421);\n\t\tsetDefaultColor(29, 10, -9804194);\n\t\tsetDefaultColor(29, 11, -9804194);\n\t\tsetDefaultColor(29, 12, -9804194);\n\t\tsetDefaultColor(29, 13, -9804194);\n\t\tsetDefaultColor(30, 0, 1775884761);\n\t\tsetDefaultColor(31, 0, 1383747097);\n\t\tsetDefaultColor(31, 1, -1571782606);\n\t\tsetDefaultColor(31, 2, 1330675762);\n\t\tsetDefaultColor(32, 0, 1383747097);\n\t\tsetDefaultColor(33, 0, -9605779);\n\t\tsetDefaultColor(33, 1, -6717094);\n\t\tsetDefaultColor(33, 2, -9804194);\n\t\tsetDefaultColor(33, 3, -9804194);\n\t\tsetDefaultColor(33, 4, -9804194);\n\t\tsetDefaultColor(33, 5, -9804194);\n\t\tsetDefaultColor(33, 8, -9605779);\n\t\tsetDefaultColor(33, 9, -6717094);\n\t\tsetDefaultColor(33, 10, -9804194);\n\t\tsetDefaultColor(33, 11, -9804194);\n\t\tsetDefaultColor(33, 12, -9804194);\n\t\tsetDefaultColor(33, 13, -9804194);\n\t\tsetDefaultColor(34, 0, -6717094);\n\t\tsetDefaultColor(34, 1, -6717094);\n\t\tsetDefaultColor(34, 2, -2137423526);\n\t\tsetDefaultColor(34, 3, -2137423526);\n\t\tsetDefaultColor(34, 4, -2137423526);\n\t\tsetDefaultColor(34, 5, -2137423526);\n\t\tsetDefaultColor(34, 8, -6717094);\n\t\tsetDefaultColor(34, 9, -7499421);\n\t\tsetDefaultColor(34, 10, -2137423526);\n\t\tsetDefaultColor(34, 11, -2137423526);\n\t\tsetDefaultColor(34, 12, -2137423526);\n\t\tsetDefaultColor(34, 13, -2137423526);\n\t\tsetDefaultColor(35, 0, -2236963);\n\t\tsetDefaultColor(35, 1, -1475018);\n\t\tsetDefaultColor(35, 2, -4370744);\n\t\tsetDefaultColor(35, 3, -9991469);\n\t\tsetDefaultColor(35, 4, -4082660);\n\t\tsetDefaultColor(35, 5, -12928209);\n\t\tsetDefaultColor(35, 6, -2588006);\n\t\tsetDefaultColor(35, 7, -12434878);\n\t\tsetDefaultColor(35, 8, -6445916);\n\t\tsetDefaultColor(35, 9, -14191468);\n\t\tsetDefaultColor(35, 10, -8374846);\n\t\tsetDefaultColor(35, 11, -14273895);\n\t\tsetDefaultColor(35, 12, -11193573);\n\t\tsetDefaultColor(35, 13, -13153256);\n\t\tsetDefaultColor(35, 14, -6083544);\n\t\tsetDefaultColor(35, 15, -15067369);\n\t\tsetDefaultColor(37, 0, -1057883902);\n\t\tsetDefaultColor(38, 0, -1057552625);\n\t\tsetDefaultColor(39, 0, -1064211115);\n\t\tsetDefaultColor(40, 0, -1063643364);\n\t\tsetDefaultColor(41, 0, -66723);\n\t\tsetDefaultColor(42, 0, -1447447);\n\t\tsetDefaultColor(43, 0, -5723992);\n\t\tsetDefaultColor(43, 1, -1712721);\n\t\tsetDefaultColor(43, 2, -7046838);\n\t\tsetDefaultColor(43, 3, -8224126);\n\t\tsetDefaultColor(43, 4, -6591135);\n\t\tsetDefaultColor(43, 5, -8750470);\n\t\tsetDefaultColor(44, 0, -5723992);\n\t\tsetDefaultColor(44, 1, -1712721);\n\t\tsetDefaultColor(44, 2, -7046838);\n\t\tsetDefaultColor(44, 3, -8224126);\n\t\tsetDefaultColor(44, 4, -6591135);\n\t\tsetDefaultColor(44, 5, -8750470);\n\t\tsetDefaultColor(45, 0, -6591135);\n\t\tsetDefaultColor(46, 0, -2407398);\n\t\tsetDefaultColor(47, 0, -4943782);\n\t\tsetDefaultColor(48, 0, -14727393);\n\t\tsetDefaultColor(49, 0, -15527395);\n\t\tsetDefaultColor(50, 0, 1627379712);\n\t\tsetDefaultColor(51, 0, -4171263);\n\t\tsetDefaultColor(52, 0, -14262393);\n\t\tsetDefaultColor(53, 0, -4417438);\n\t\tsetDefaultColor(54, 0, -7378659);\n\t\tsetDefaultColor(55, 0, 1827466476);\n\t\tsetDefaultColor(56, 0, -8287089);\n\t\tsetDefaultColor(57, 0, -10428192);\n\t\tsetDefaultColor(58, 0, -8038091);\n\t\tsetDefaultColor(59, 0, 302029071);\n\t\tsetDefaultColor(59, 1, 957524751);\n\t\tsetDefaultColor(59, 2, 1444710667);\n\t\tsetDefaultColor(59, 3, -1708815608);\n\t\tsetDefaultColor(59, 4, -835813369);\n\t\tsetDefaultColor(59, 5, -532579833);\n\t\tsetDefaultColor(59, 6, -531663353);\n\t\tsetDefaultColor(59, 7, -531208953);\n\t\tsetDefaultColor(60, 0, -9221331);\n\t\tsetDefaultColor(60, 1, -9550295);\n\t\tsetDefaultColor(60, 2, -9879003);\n\t\tsetDefaultColor(60, 3, -10207967);\n\t\tsetDefaultColor(60, 4, -10536675);\n\t\tsetDefaultColor(60, 5, -10865383);\n\t\tsetDefaultColor(60, 6, -11194347);\n\t\tsetDefaultColor(60, 7, -11523055);\n\t\tsetDefaultColor(60, 8, -11786226);\n\t\tsetDefaultColor(61, 0, -9145228);\n\t\tsetDefaultColor(62, 0, -8355712);\n\t\tsetDefaultColor(63, 0, -1598779307);\n\t\tsetDefaultColor(64, 0, -1064934094);\n\t\tsetDefaultColor(65, 0, -2139595212);\n\t\tsetDefaultColor(66, 0, -8951211);\n\t\tsetDefaultColor(67, 0, -6381922);\n\t\tsetDefaultColor(68, 0, -1598779307);\n\t\tsetDefaultColor(69, 0, -1603709901);\n\t\tsetDefaultColor(70, 0, -7368817);\n\t\tsetDefaultColor(71, 0, -1061043775);\n\t\tsetDefaultColor(72, 0, -4417438);\n\t\tsetDefaultColor(73, 0, -6981535);\n\t\tsetDefaultColor(74, 0, -6981535);\n\t\tsetDefaultColor(75, 0, -2141709038);\n\t\tsetDefaultColor(76, 0, -2136923117);\n\t\tsetDefaultColor(77, 0, -2139851660);\n\t\tsetDefaultColor(78, 0, -1314833);\n\t\tsetDefaultColor(79, 0, -1619219203);\n\t\tsetDefaultColor(80, 0, -986896);\n\t\tsetDefaultColor(81, 0, -15695840);\n\t\tsetDefaultColor(82, 0, -6380624);\n\t\tsetDefaultColor(83, 0, -7094428);\n\t\tsetDefaultColor(84, 0, -9811658);\n\t\tsetDefaultColor(85, 0, -4417438);\n\t\tsetDefaultColor(86, 0, -4229867);\n\t\tsetDefaultColor(87, 0, -9751501);\n\t\tsetDefaultColor(88, 0, -11255757);\n\t\tsetDefaultColor(89, 0, -4157626);\n\t\tsetDefaultColor(90, 0, -9231226);\n\t\tsetDefaultColor(91, 0, -3893474);\n\t\tsetDefaultColor(92, 0, -1848115);\n\t\tsetDefaultColor(93, 0, -6843501);\n\t\tsetDefaultColor(94, 0, -4156525);\n\t\tsetDefaultColor(95, 0, -7378659);\n\t\tsetDefaultColor(96, 0, -8495827);\n\t\tsetDefaultColor(96, 1, -8495827);\n\t\tsetDefaultColor(96, 2, -8495827);\n\t\tsetDefaultColor(96, 3, -8495827);\n\t\tsetDefaultColor(96, 4, 545152301);\n\t\tsetDefaultColor(96, 5, 545152301);\n\t\tsetDefaultColor(96, 6, 545152301);\n\t\tsetDefaultColor(96, 7, 545152301);\n\t\tsetDefaultColor(97, 0, -9934744);\n\t\tsetDefaultColor(97, 1, -6974059);\n\t\tsetDefaultColor(97, 2, -8750470);\n\t\tsetDefaultColor(98, 0, -8750470);\n\t\tsetDefaultColor(98, 1, -9275542);\n\t\tsetDefaultColor(98, 2, -9013642);\n\t\tsetDefaultColor(99, 0, -3495048);\n\t\tsetDefaultColor(99, 1, -7509421);\n\t\tsetDefaultColor(99, 2, -7509421);\n\t\tsetDefaultColor(99, 3, -7509421);\n\t\tsetDefaultColor(99, 4, -7509421);\n\t\tsetDefaultColor(99, 5, -7509421);\n\t\tsetDefaultColor(99, 6, -7509421);\n\t\tsetDefaultColor(99, 7, -7509421);\n\t\tsetDefaultColor(99, 8, -7509421);\n\t\tsetDefaultColor(99, 9, -7509421);\n\t\tsetDefaultColor(99, 10, -3495048);\n\t\tsetDefaultColor(100, 0, -3495048);\n\t\tsetDefaultColor(100, 1, -4840156);\n\t\tsetDefaultColor(100, 2, -4840156);\n\t\tsetDefaultColor(100, 3, -4840156);\n\t\tsetDefaultColor(100, 4, -4840156);\n\t\tsetDefaultColor(100, 5, -4840156);\n\t\tsetDefaultColor(100, 6, -4840156);\n\t\tsetDefaultColor(100, 7, -4840156);\n\t\tsetDefaultColor(100, 8, -4840156);\n\t\tsetDefaultColor(100, 9, -4840156);\n\t\tsetDefaultColor(100, 10, -3495048);\n\t\tsetDefaultColor(101, 0, -2140312470);\n\t\tsetDefaultColor(102, 0, 1627389951);\n\t\tsetDefaultColor(103, 0, -6842076);\n\t\tsetDefaultColor(104, 0, 1073780992);\n\t\tsetDefaultColor(104, 1, 1209242626);\n\t\tsetDefaultColor(104, 2, 1344704516);\n\t\tsetDefaultColor(104, 3, 1480166151);\n\t\tsetDefaultColor(104, 4, 1615693321);\n\t\tsetDefaultColor(104, 5, 1751154956);\n\t\tsetDefaultColor(104, 6, 1886616590);\n\t\tsetDefaultColor(104, 7, 2022144016);\n\t\tsetDefaultColor(105, 0, 1073780992);\n\t\tsetDefaultColor(105, 1, 1209242626);\n\t\tsetDefaultColor(105, 2, 1344704516);\n\t\tsetDefaultColor(105, 3, 1480166151);\n\t\tsetDefaultColor(105, 4, 1615693321);\n\t\tsetDefaultColor(105, 5, 1751154956);\n\t\tsetDefaultColor(105, 6, 1886616590);\n\t\tsetDefaultColor(105, 7, 2022144016);\n\t\tsetDefaultColor(106, 0, -2145432054);\n\t\tsetDefaultColor(107, 0, -1061382046);\n\t\tsetDefaultColor(108, 0, -6591135);\n\t\tsetDefaultColor(109, 0, -8750470);\n\t\tsetDefaultColor(110, 0, 0xAB8790, 0xFF);\n\t\tsetDefaultColor(111, 0, 0x158003, 0xFF);\n\t\tsetDefaultColor(112, 0, 0x40002F, 0xFF);\n\t\tsetDefaultColor(113, 0, 0x40002F, 0xFF);\n\t\tsetDefaultColor(114, 0, 0x40002F, 0xFF);\n\t\tsetDefaultColor(115, 0, 0xA30321, 0xFF);\n\t\tsetDefaultColor(116, 0, 0xF0DDE0, 0xFF);\n\t\tsetDefaultColor(117, 0, -9934744);\n\t\tsetDefaultColor(118, 0, -9934744);\n\t\tsetDefaultColor(119, 0, 0x000000, 0xFF);\n\t\tsetDefaultColor(120, 0, 0x376319, 0xFF);\n\t\tsetDefaultColor(121, 0, 0xE4E8B5, 0xFF);\n\t\tsetDefaultColor(122, 0, 0x24031E, 0xFF);\n\t\tsetDefaultColor(123, 0, 0x784C10, 0xFF);\n\t\tsetDefaultColor(124, 0, 0xE3DE54, 0xFF);\n\t\tsetDefaultColor(125, 0, 0x9F824B);\n\t\tsetDefaultColor(126, 0, 0x9F824B);\n\t\tsetDefaultColor(127, 0, 0xAE6616);\n\t\tsetDefaultColor(128, 0, 0xCBC594);\n\t\tsetDefaultColor(129, 0, 0x46A56A);\n\t\tsetDefaultColor(130, 0, 0x283A3C);\n\t\tsetDefaultColor(131, 0, 0xAC8B54);\n\t\tsetDefaultColor(132, 0, 0xD5D5D5);\n\t\tsetDefaultColor(133, 0, 0x4CD473);\n\t\tsetDefaultColor(134, 0, 0x6E512C);\n\t\tsetDefaultColor(135, 0, 0xC4B87B);\n\t\tsetDefaultColor(136, 0, 0x986C46);\n\t\tsetDefaultColor(137, 0, 0xAD9D8F);\n\t\tsetDefaultColor(138, 0, 0x64A6A2);\n\t\tsetDefaultColor(139, 0, 0x929292);\n\t\tsetDefaultColor(140, 0, 0x3A2017);\n\t\tsetDefaultColor(141, 0, 0xC28600);\n\t\tsetDefaultColor(142, 0, 0x9C931D);\n\t\tsetDefaultColor(143, 0, 0xA4864F);\n\t}\n"} {"input": " public MatrixData data (@PathVariable (\"id\") String id,\n @RequestParam (value = \"startRow\", required = false) Integer startRow,\n @RequestParam (value = \"endRow\", required = false) Integer endRow,\n @RequestParam (value = \"startColumn\", required = false) Integer startColumn,\n @RequestParam (value = \"endColumn\", required = false) Integer endColumn) throws HeatmapNotFoundException {\n return (startRow == null || endRow == null || startColumn == null || endColumn == null)\n ? heatmaps.get (id)\n .getData (0,\n MAX_VALUE,\n 0,\n MAX_VALUE)\n : heatmaps.get (id)\n .getData (startRow,\n endRow,\n startColumn,\n endColumn);\n }\n", "output": " public MatrixData data (@PathVariable (\"id\") String id,\n @RequestParam (value = \"startRow\", required = false) Integer startRow,\n @RequestParam (value = \"endRow\", required = false) Integer endRow,\n @RequestParam (value = \"startColumn\", required = false) Integer startColumn,\n @RequestParam (value = \"endColumn\", required = false) Integer endColumn) throws HeatmapNotFoundException {\n if (log.isDebugEnabled ())\n log.debug (\"Serving request for data for heatmap \"\n + id + \" starting row \" + startRow + \" ending row \" + endRow + \" startingColumn \" + startColumn\n + \" ending column \" + endColumn);\n return (startRow == null || endRow == null || startColumn == null || endColumn == null)\n ? heatmaps.get (id)\n .getData (0,\n MAX_VALUE,\n 0,\n MAX_VALUE)\n : heatmaps.get (id)\n .getData (startRow,\n endRow,\n startColumn,\n endColumn);\n }\n"} {"input": "\tprotected List<PluginApi.ActionInfo> implementedActions(Context context) {\n\t\treturn Collections.<PluginApi.ActionInfo>singletonList(new PluginApi.MenuActionInfo(\n\t\t\tUri.parse(\"http://data.fbreader.org/plugin/tts/speak\"),\n\t\t\tcontext.getText(R.string.speak_menu_item).toString()\n\t\t));\n\t}\n", "output": "\tprotected List<PluginApi.ActionInfo> implementedActions(Context context) {\n\t\treturn Collections.<PluginApi.ActionInfo>singletonList(new PluginApi.MenuActionInfo(\n\t\t\tUri.parse(\"http://data.fbreader.org/plugin/tts/speak\"),\n\t\t\tcontext.getText(R.string.speak_menu_item).toString(),\n\t\t\tInteger.MAX_VALUE\n\t\t));\n\t}\n"} {"input": " public List<SampleAcquisition> findMatchingSamples(AbstractAnnotationCriterion criterion, Study study) {\n if (!criterion.getEntityType().equals(EntityTypeEnum.SAMPLE)) {\n return null;\n } else {\n Criteria sampleAcquisitionCrit = getHibernateTemplate().\n getSessionFactory().\n getCurrentSession().\n createCriteria(SampleAcquisition.class);\n Criteria valuesCrit = sampleAcquisitionCrit.createCriteria(\"annotationCollection\");\n valuesCrit.add(AbstractAnnotationCriterionHandler.create(criterion).translate());\n return sampleAcquisitionCrit.list();\n }\n }\n", "output": " public List<SampleAcquisition> findMatchingSamples(AbstractAnnotationCriterion criterion, Study study) {\n if (!criterion.getEntityType().equals(EntityTypeEnum.SAMPLE.getValue())) {\n return null;\n } else {\n Criteria sampleAcquisitionCrit = getHibernateTemplate().\n getSessionFactory().\n getCurrentSession().\n createCriteria(SampleAcquisition.class);\n Criteria valuesCrit = sampleAcquisitionCrit.createCriteria(\"annotationCollection\");\n valuesCrit.add(AbstractAnnotationCriterionHandler.create(criterion).translate());\n return sampleAcquisitionCrit.list();\n }\n }\n"} {"input": "\tpublic boolean onCommand(CommandSender sender, Command cmnd, String arg2,\n\t\t\tString[] arg3) {\n\t\tif (sender instanceof ConsoleCommandSender) {\n\t\t\tMinePermit.log.info(\"[MinePermit] Sorry, commands cant be sent from console yet.\");\n\t\t\treturn true;\n\t\t}\n\t\tPlayer p = (Player) sender;\n\t\tif (arg3.length == 0) {\n\t\t\treturn false;\n\t\t} else if (arg3[0].equalsIgnoreCase(\"view\")) {\n\t\t\tMiner m = MinerManager.getMiner(p);\n\t\t\tint id;\n\t\t\ttry {\n\t\t\t\tid = Integer.parseInt(arg3[1]);\n\t\t\t} catch (Exception e) {\n\t\t\t\tString s = \"\";\n\t\t\t\tMap<Integer, Long> tmp = m.getPermits();\n\t\t\t\tif(tmp.isEmpty()){\n\t\t\t\t\tp.sendMessage(ChatColor.YELLOW + \"You don't own any permits!\");\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tfor (int y = 0; y < tmp.size(); y++) {\n\t\t\t\t\tint n = (Integer) tmp.keySet().toArray()[y];\n\t\t\t\t\tp.sendMessage(ChatColor.DARK_GREEN + \"\" + n + \": \" + m.getRemainingTime(n) + \" minutes.\");\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!m.hasPermit(id)) {\n\t\t\t\tp.sendMessage(ChatColor.DARK_RED\n\t\t\t\t\t\t+ \"You do not own a permit for \" + id);\n\t\t\t} else {\n\t\t\t\tp.sendMessage(ChatColor.DARK_GREEN + \"You have \"\n\t\t\t\t\t\t+ m.getRemainingTime(id) + \" minutes left.\");\n\t\t\t}\n\t\t\treturn true;\n\t\t} else if (arg3[0].equalsIgnoreCase(\"cost\")) {\n\t\t\tint id;\n\t\t\ttry {\n\t\t\t\tid = Integer.parseInt(arg3[1]);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!Config.isPermitRequired(id)) {\n\t\t\t\tp.sendMessage(ChatColor.GRAY\n\t\t\t\t\t\t+ \"A permit is not required for this item.\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tp.sendMessage(ChatColor.AQUA + \"The cost for this item is \"\n\t\t\t\t\t+ Config.getCost(id) + \" dolars\");\n\t\t\treturn true;\n\t\t} else if (arg3[0].equalsIgnoreCase(\"buy\")) {\n\t\t\tint id;\n\t\t\ttry {\n\t\t\t\tid = Integer.parseInt(arg3[1]);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!Config.isPermitRequired(id)) {\n\t\t\t\tp.sendMessage(ChatColor.GRAY\n\t\t\t\t\t\t+ \"A permit is not required for this item.\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif(MinerManager.getMiner(p).hasPermit(id)){\n\t\t\t\tp.sendMessage(ChatColor.AQUA + \"You already have a permit for this!\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!p.getInventory().contains(Config.currencyBlockID, Config.getCost(id))) {\n\t\t\t\tp.sendMessage(ChatColor.DARK_RED\n\t\t\t\t\t\t+ \"You dont have enough money!\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tint cost = Config.getCost(id);\n\t\t\twhile (cost > 0) {\n\t\t\t\tItemStack x = p.getInventory().getItem(\n\t\t\t\t\t\tp.getInventory().first(Config.currencyBlockID));\n\t\t\t\tif (x.getAmount() < cost) {\n\t\t\t\t\tcost -= x.getAmount();\n\t\t\t\t\tx.setAmount(0);\n\t\t\t\t} else {\n\t\t\t\t\tx.setAmount(x.getAmount() - cost);\n\t\t\t\t\tcost = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tMinerManager.getMiner(p).addPermit(id, Config.permitDuration);\n\t\t\tp.sendMessage(ChatColor.DARK_GREEN + \"Permit purchased!\");\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean onCommand(CommandSender sender, Command cmnd, String arg2,\n\t\t\tString[] arg3) {\n\t\tif (sender instanceof ConsoleCommandSender) {\n\t\t\tMinePermit.log.info(\"[MinePermit] Sorry, commands cant be sent from console yet.\");\n\t\t\treturn true;\n\t\t}\n\t\tPlayer p = (Player) sender;\n\t\tif (arg3.length == 0) {\n\t\t\treturn false;\n\t\t} else if (arg3[0].equalsIgnoreCase(\"view\")) {\n\t\t\tMiner m = MinerManager.getMiner(p);\n\t\t\tint id;\n\t\t\ttry {\n\t\t\t\tid = Integer.parseInt(arg3[1]);\n\t\t\t} catch (Exception e) {\n\t\t\t\tString s = \"\";\n\t\t\t\tMap<Integer, Long> tmp = m.getPermits();\n\t\t\t\tif(tmp.isEmpty()){\n\t\t\t\t\tp.sendMessage(ChatColor.YELLOW + \"You don't own any permits!\");\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tfor (int y = 0; y < tmp.size(); y++) {\n\t\t\t\t\tint n = (Integer) tmp.keySet().toArray()[y];\n\t\t\t\t\tp.sendMessage(ChatColor.DARK_GREEN + \"\" + n + \": \" + m.getRemainingTime(n) + \" minutes.\");\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!m.hasPermit(id)) {\n\t\t\t\tp.sendMessage(ChatColor.DARK_RED\n\t\t\t\t\t\t+ \"You do not own a permit for \" + id);\n\t\t\t} else {\n\t\t\t\tp.sendMessage(ChatColor.DARK_GREEN + \"You have \"\n\t\t\t\t\t\t+ m.getRemainingTime(id) + \" minutes left.\");\n\t\t\t}\n\t\t\treturn true;\n\t\t} else if (arg3[0].equalsIgnoreCase(\"cost\")) {\n\t\t\tint id;\n\t\t\ttry {\n\t\t\t\tid = Integer.parseInt(arg3[1]);\n\t\t\t} catch (ArrayIndexOutOfBoundsException e1){\n\t\t\t\treturn false;\n\t\t\t} catch (NumberFormatException e2) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!Config.isPermitRequired(id)) {\n\t\t\t\tp.sendMessage(ChatColor.GRAY\n\t\t\t\t\t\t+ \"A permit is not required for this item.\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tp.sendMessage(ChatColor.AQUA + \"The cost for this item is \"\n\t\t\t\t\t+ Config.getCost(id) + \" dolars\");\n\t\t\treturn true;\n\t\t} else if (arg3[0].equalsIgnoreCase(\"buy\")) {\n\t\t\tint id;\n\t\t\ttry {\n\t\t\t\tid = Integer.parseInt(arg3[1]);\n\t\t\t} catch (ArrayIndexOutOfBoundsException e1){\n\t\t\t\treturn false;\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (!Config.isPermitRequired(id)) {\n\t\t\t\tp.sendMessage(ChatColor.GRAY\n\t\t\t\t\t\t+ \"A permit is not required for this item.\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif(MinerManager.getMiner(p).hasPermit(id)){\n\t\t\t\tp.sendMessage(ChatColor.AQUA + \"You already have a permit for this!\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!p.getInventory().contains(Config.currencyBlockID, Config.getCost(id))) {\n\t\t\t\tp.sendMessage(ChatColor.DARK_RED\n\t\t\t\t\t\t+ \"You dont have enough money!\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tint cost = Config.getCost(id);\n\t\t\twhile (cost > 0) {\n\t\t\t\tItemStack x = p.getInventory().getItem(\n\t\t\t\t\t\tp.getInventory().first(Config.currencyBlockID));\n\t\t\t\tif (x.getAmount() < cost) {\n\t\t\t\t\tcost -= x.getAmount();\n\t\t\t\t\tx.setAmount(0);\n\t\t\t\t} else {\n\t\t\t\t\tx.setAmount(x.getAmount() - cost);\n\t\t\t\t\tcost = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tMinerManager.getMiner(p).addPermit(id, Config.permitDuration);\n\t\t\tp.sendMessage(ChatColor.DARK_GREEN + \"Permit purchased!\");\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": "\tpublic final void performJobUnit(final JobUnitContext context) {\n\t\tfinal BasicNetwork network = (BasicNetwork) context.getJobUnit();\n\t\tBufferedMLDataSet buffer = null;\n\t\tMLDataSet useTraining = this.training;\n\t\tif (this.training instanceof BufferedMLDataSet) {\n\t\t\tbuffer = (BufferedMLDataSet) this.training;\n\t\t\tuseTraining = buffer.openAdditional();\n\t\t}\n\t\tdouble error = Double.POSITIVE_INFINITY;\n\t\tfor (int z = 0; z < this.weightTries; z++) {\n\t\t\tnetwork.reset();\n\t\t\tfinal Propagation train = new ResilientPropagation(network,\n\t\t\t\t\tuseTraining);\n\t\t\tfinal StopTrainingStrategy strat = new StopTrainingStrategy(0.001,\n\t\t\t\t\t5);\n\t\t\ttrain.addStrategy(strat);\n\t\t\ttrain.setNumThreads(1); \n\t\t\tfor (int i = 0; (i < this.iterations) && !getShouldStop()\n\t\t\t\t\t&& !strat.shouldStop(); i++) {\n\t\t\t\ttrain.iteration();\n\t\t\t}\n\t\t\terror = Math.min(error, train.getError());\n\t\t}\n\t\tif (buffer != null) {\n\t\t\tbuffer.close();\n\t\t}\n\t\tif (!getShouldStop()) {\n\t\t\tthis.high = Math.max(this.high, error);\n\t\t\tthis.low = Math.min(this.low, error);\n\t\t\tif (this.hidden1Size > 0) {\n\t\t\t\tint networkHidden1Count;\n\t\t\t\tint networkHidden2Count;\n\t\t\t\tif (network.getLayerCount() > 3) {\n\t\t\t\t\tnetworkHidden2Count = network.getLayerNeuronCount(1);\n\t\t\t\t\tnetworkHidden1Count = network.getLayerNeuronCount(2);\n\t\t\t\t} else {\n\t\t\t\t\tnetworkHidden2Count = 0;\n\t\t\t\t\tnetworkHidden1Count = network.getLayerNeuronCount(1);\n\t\t\t\t}\n\t\t\t\tint row, col;\n\t\t\t\tif (this.hidden2Size == 0) {\n\t\t\t\t\trow = networkHidden1Count - this.hidden.get(0).getMin();\n\t\t\t\t\tcol = 0;\n\t\t\t\t} else {\n\t\t\t\t\trow = networkHidden1Count - this.hidden.get(0).getMin();\n\t\t\t\t\tcol = networkHidden2Count - this.hidden.get(1).getMin();\n\t\t\t\t}\n\t\t\t\tif ((row < 0) || (col < 0)) {\n\t\t\t\t\tSystem.out.println(\"STOP\");\n\t\t\t\t}\n\t\t\t\tthis.results[row][col] = error;\n\t\t\t}\n\t\t\tthis.currentTry++;\n\t\t\tupdateBest(network, error);\n\t\t\treportStatus(\n\t\t\t\t\tcontext,\n\t\t\t\t\t\"Current: \"\n\t\t\t\t\t\t\t+ PruneIncremental.networkToString(network)\n\t\t\t\t\t\t\t+ \"; Best: \"\n\t\t\t\t\t\t\t+ PruneIncremental\n\t\t\t\t\t\t\t\t\t.networkToString(this.bestNetwork));\n\t\t}\n\t}\n", "output": "\tpublic final void performJobUnit(final JobUnitContext context) {\n\t\tfinal BasicNetwork network = (BasicNetwork) context.getJobUnit();\n\t\tBufferedMLDataSet buffer = null;\n\t\tMLDataSet useTraining = this.training;\n\t\tif (this.training instanceof BufferedMLDataSet) {\n\t\t\tbuffer = (BufferedMLDataSet) this.training;\n\t\t\tuseTraining = buffer.openAdditional();\n\t\t}\n\t\tdouble error = Double.POSITIVE_INFINITY;\n\t\tfor (int z = 0; z < this.weightTries; z++) {\n\t\t\tnetwork.reset();\n\t\t\tfinal Propagation train = new ResilientPropagation(network,\n\t\t\t\t\tuseTraining);\n\t\t\tfinal StopTrainingStrategy strat = new StopTrainingStrategy(0.001,\n\t\t\t\t\t5);\n\t\t\ttrain.addStrategy(strat);\n\t\t\ttrain.setNumThreads(1); \n\t\t\tfor (int i = 0; (i < this.iterations) && !getShouldStop()\n\t\t\t\t\t&& !strat.shouldStop(); i++) {\n\t\t\t\ttrain.iteration();\n\t\t\t}\n\t\t\terror = Math.min(error, train.getError());\n\t\t}\n\t\tif (buffer != null) {\n\t\t\tbuffer.close();\n\t\t}\n\t\tif (!getShouldStop()) {\n\t\t\tthis.high = Math.max(this.high, error);\n\t\t\tthis.low = Math.min(this.low, error);\n\t\t\tif (this.hidden1Size > 0) {\n\t\t\t\tint networkHidden1Count;\n\t\t\t\tint networkHidden2Count;\n\t\t\t\tif (network.getLayerCount() > 3) {\n\t\t\t\t\tnetworkHidden2Count = network.getLayerNeuronCount(2);\n\t\t\t\t\tnetworkHidden1Count = network.getLayerNeuronCount(1);\n\t\t\t\t} else {\n\t\t\t\t\tnetworkHidden2Count = 0;\n\t\t\t\t\tnetworkHidden1Count = network.getLayerNeuronCount(1);\n\t\t\t\t}\n\t\t\t\tint row, col;\n\t\t\t\tif (this.hidden2Size == 0) {\n\t\t\t\t\trow = networkHidden1Count - this.hidden.get(0).getMin();\n\t\t\t\t\tcol = 0;\n\t\t\t\t} else {\n\t\t\t\t\trow = networkHidden1Count - this.hidden.get(0).getMin();\n\t\t\t\t\tcol = networkHidden2Count - this.hidden.get(1).getMin();\n\t\t\t\t}\n\t\t\t\tif ((row < 0) || (col < 0)) {\n\t\t\t\t\tSystem.out.println(\"STOP\");\n\t\t\t\t}\n\t\t\t\tthis.results[row][col] = error;\n\t\t\t}\n\t\t\tthis.currentTry++;\n\t\t\tupdateBest(network, error);\n\t\t\treportStatus(\n\t\t\t\t\tcontext,\n\t\t\t\t\t\"Current: \"\n\t\t\t\t\t\t\t+ PruneIncremental.networkToString(network)\n\t\t\t\t\t\t\t+ \"; Best: \"\n\t\t\t\t\t\t\t+ PruneIncremental\n\t\t\t\t\t\t\t\t\t.networkToString(this.bestNetwork));\n\t\t}\n\t}\n"} {"input": " public String showPart() {\n String part = request.getParameter(\"part\");\n String result = \"plain_text\";\n String content = \"\";\n if (\"code\".equals(part)) {\n content = snippet.getCode();\n result = \"code_part\";\n } else if (\"example\".equals(part)) {\n content = snippet.getExample();\n }\n request.setAttribute(\"content\", content);\n return result;\n }\n", "output": " public String showPart() {\n String part = request.getParameter(\"part\");\n String result = \"plain_text\";\n String content = \"\";\n if (snippet != null) {\n if (\"code\".equals(part)) {\n content = snippet.getCode();\n result = \"code_part\";\n } else if (\"example\".equals(part)) {\n content = snippet.getExample();\n }\n } else {\n content = \"Snippet Not Found!\";\n }\n request.setAttribute(\"content\", content);\n return result;\n }\n"} {"input": "\tprotected void createData(LeafNode.DataProvider dataProvider)\n\t{\n\t\tdata = new vtkPolyData();\n\t\tdata.SetPoints(Utils.createPoints(dataProvider.getNodes()));\n\t\tvtkCellArray cells = Utils.createCells(dataProvider.getNbrOfVertices(),\n\t\t\tdataProvider.getVertices());\n\t\tdata.SetVerts(cells);\t\t\n\t\tcells=Utils.createCells(dataProvider.getNbrOfLines(), dataProvider.getLines());\n\t\tdata.SetLines(cells);\n\t\tcells=Utils.createCells(dataProvider.getNbrOfPolys(), dataProvider.getPolys());\n\t\tdata.SetPolys(cells);\n\t\tif(LOGGER.isLoggable(Level.FINEST))\n\t\t{\n\t\t\tLOGGER.finest(\"Number of points : \" + data.GetPoints().GetNumberOfPoints());\n\t\t\tLOGGER.finest(\"Number of vertices : \" + data.GetVerts().GetNumberOfCells());\n\t\t\tLOGGER.finest(\"Number of lines : \" + data.GetLines().GetNumberOfCells());\n\t\t\tLOGGER.finest(\"Number of polys : \" + data.GetPolys().GetNumberOfCells());\n\t\t\tLOGGER.finest(\"vertex coherance : \" + Utils.isMeshCoherent(dataProvider.getNodes(), dataProvider.getVertices()));\n\t\t\tLOGGER.finest(\"line coherance : \" + Utils.isMeshCoherent(dataProvider.getNodes(), dataProvider.getLines()));\n\t\t\tLOGGER.finest(\"polys coherance : \" + Utils.isMeshCoherent(dataProvider.getNodes(), dataProvider.getPolys()));\n\t\t}\n\t\tif(dataProvider.getNormals() == null)\n\t\t\treturn;\n\t\tvtkPolyDataNormals algoNormals = new vtkPolyDataNormals();\n\t\talgoNormals.SetInput(data);\n\t\talgoNormals.SplittingOff();\n\t\talgoNormals.FlipNormalsOff();\n\t\talgoNormals.AutoOrientNormalsOff();\n\t\talgoNormals.ComputePointNormalsOn();\n\t\talgoNormals.Update();\n\t\tdata = algoNormals.GetOutput();\n\t\tvtkPointData pointData = data.GetPointData();\n\t\tvtkFloatArray computedNormals = (vtkFloatArray) pointData.GetNormals();\t\t\n\t\tfloat[] javaComputedNormals = computedNormals.GetJavaArray();\n\t\tfloat[] javaNormals = dataProvider.getNormals();\n\t\tfor(int i = 0 ; i < javaComputedNormals.length / 3 ; i += 3)\n\t\t{\n\t\t\tif(javaNormals[i] == 0. && javaNormals[i + 1] == 0. && javaNormals[i + 2] == 0.)\n\t\t\t{\n\t\t\t\tjavaNormals[i] = javaComputedNormals[i];\n\t\t\t\tjavaNormals[i + 1] = javaComputedNormals[i + 1];\n\t\t\t\tjavaNormals[i + 2] = javaComputedNormals[i + 2];\n\t\t\t}\n\t\t}\n\t\tvtkFloatArray normals = new vtkFloatArray();\n\t\tnormals.SetNumberOfComponents(3);\n\t\tnormals.SetJavaArray(javaNormals);\n\t\tpointData.SetNormals(normals);\n\t}\n", "output": "\tprotected void createData(LeafNode.DataProvider dataProvider)\n\t{\n\t\tdata = new vtkPolyData();\n\t\tdata.SetPoints(Utils.createPoints(dataProvider.getNodes()));\n\t\tvtkCellArray cells = Utils.createCells(dataProvider.getNbrOfVertices(),\n\t\t\tdataProvider.getVertices());\n\t\tdata.SetVerts(cells);\t\t\n\t\tcells=Utils.createCells(dataProvider.getNbrOfLines(), dataProvider.getLines());\n\t\tdata.SetLines(cells);\n\t\tcells=Utils.createCells(dataProvider.getNbrOfPolys(), dataProvider.getPolys());\n\t\tdata.SetPolys(cells);\n\t\tif(LOGGER.isLoggable(Level.FINEST))\n\t\t{\n\t\t\tLOGGER.finest(\"Number of points : \" + data.GetPoints().GetNumberOfPoints());\n\t\t\tLOGGER.finest(\"Number of vertices : \" + data.GetVerts().GetNumberOfCells());\n\t\t\tLOGGER.finest(\"Number of lines : \" + data.GetLines().GetNumberOfCells());\n\t\t\tLOGGER.finest(\"Number of polys : \" + data.GetPolys().GetNumberOfCells());\n\t\t\tLOGGER.finest(\"vertex coherance : \" + Utils.isMeshCoherent(dataProvider.getNodes(), dataProvider.getVertices()));\n\t\t\tLOGGER.finest(\"line coherance : \" + Utils.isMeshCoherent(dataProvider.getNodes(), dataProvider.getLines()));\n\t\t\tLOGGER.finest(\"polys coherance : \" + Utils.isMeshCoherent(dataProvider.getNodes(), dataProvider.getPolys()));\n\t\t}\n\t\tif(dataProvider.getNormals() == null)\n\t\t\treturn;\n\t\tvtkPolyDataNormals algoNormals = new vtkPolyDataNormals();\n\t\talgoNormals.SetInput(data);\n\t\talgoNormals.SplittingOff();\n\t\talgoNormals.FlipNormalsOff();\n\t\talgoNormals.AutoOrientNormalsOff();\n\t\talgoNormals.ComputePointNormalsOn();\n\t\talgoNormals.Update();\n\t\tdata = algoNormals.GetOutput();\n\t\tvtkPointData pointData = data.GetPointData();\n\t\tvtkFloatArray computedNormals = (vtkFloatArray) pointData.GetNormals();\t\t\n\t\tfloat[] javaComputedNormals = computedNormals.GetJavaArray();\n\t\tfloat[] javaNormals = dataProvider.getNormals();\n\t\tfor(int i = 0 ; i < javaComputedNormals.length ; i+= 3)\n\t\t{\n\t\t\tif(javaNormals[i] == 0. && javaNormals[i + 1] == 0. && javaNormals[i + 2] == 0.)\n\t\t\t{\n\t\t\t\tjavaNormals[i] = javaComputedNormals[i];\n\t\t\t\tjavaNormals[i + 1] = javaComputedNormals[i + 1];\n\t\t\t\tjavaNormals[i + 2] = javaComputedNormals[i + 2];\n\t\t\t}\n\t\t}\n\t\tvtkFloatArray normals = new vtkFloatArray();\n\t\tnormals.SetNumberOfComponents(3);\n\t\tnormals.SetJavaArray(javaNormals);\n\t\tpointData.SetNormals(normals);\n\t}\n"} {"input": "\tpublic void create() {\n\t\tsuper.create();\n\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tGridData gridData = new GridData();\n\t\t\t\tgridData.grabExcessHorizontalSpace = true;\n\t\t\t\tgridData.widthHint = 400;\n\t\t\t\tgridData.heightHint = 50;\n\t\t\t\tComposite infoComposite = new Composite(parentComposite, SWT.NULL);\n\t\t\t\tinfoComposite.setLayoutData(gridData);\n\t\t\t\tinfoComposite.setLayout(new FillLayout(SWT.VERTICAL));\n\t\t\t\tfinal Slider pValueSlider = new Slider(infoComposite, SWT.HORIZONTAL);\n\t\t\t\tfinal Label pValueLabel = new Label(infoComposite, SWT.NULL);\n\t\t\t\tpValueLabel.setText(\"p-Value: \" + Float.toString(pValue));\n\t\t\t\tpValueSlider.setMinimum(0);\n\t\t\t\tpValueSlider.setMaximum((int) (histogram.getMax() * 10000));\n\t\t\t\tSystem.out.println(\"Largest: \" +histogram.getMax());\n\t\t\t\tpValueSlider.setIncrement(1);\n\t\t\t\tpValueSlider.setPageIncrement(5);\n\t\t\t\tpValueSlider.setSelection((int) (pValue * 10000));\n\t\t\t\tpValueSlider.addMouseListener(new MouseAdapter() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void mouseUp(MouseEvent e) {\n\t\t\t\t\t\tpValue = (float) pValueSlider.getSelection() / 10000.00f;\n\t\t\t\t\t\tSystem.out.println(pValue);\n\t\t\t\t\t\tpValueLabel.setText(\"p-Value: \" + Float.toString(pValue));\n\t\t\t\t\t\tparentComposite.pack();\n\t\t\t\t\t\tparentComposite.layout();\n\t\t\t\t\t\tcreateVADelta();\n\t\t\t\t\t\tfilter.updateFilterManager();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tComposite histoComposite = new Composite(parentComposite, SWT.NULL);\n\t\t\t\thistoComposite.setLayout(new FillLayout(SWT.VERTICAL));\n\t\t\t\tgridData.heightHint = 300;\n\t\t\t\tgridData.grabExcessVerticalSpace = true;\n\t\t\t\thistoComposite.setLayoutData(gridData);\n\t\t\t\tRcpGLHistogramView histogramView = new RcpGLHistogramView();\n\t\t\t\thistogramView.setDataDomain(DataDomainManager.get().getDataDomain(\n\t\t\t\t\t\t\"org.caleydo.datadomain.genetic\"));\n\t\t\t\thistogramView.createDefaultSerializedView();\n\t\t\t\thistogramView.createPartControl(histoComposite);\n\t\t\t\t((GLHistogram) (histogramView.getGLView())).setHistogram(histogram);\n\t\t\t\tGeneralManager.get().getViewGLCanvasManager()\n\t\t\t\t\t\t.registerGLCanvasToAnimator(histogramView.getGLCanvas());\n\t\t\t\tMonitor primary = parentComposite.getDisplay().getPrimaryMonitor();\n\t\t\t\tRectangle bounds = primary.getBounds();\n\t\t\t\tRectangle rect = parentComposite.getBounds();\n\t\t\t\tint x = bounds.x + (bounds.width - rect.width) / 2;\n\t\t\t\tint y = bounds.y + (bounds.height - rect.height) / 2;\n\t\t\t\tparentComposite.setLocation(x, y);\n\t\t\t\t((Shell) parentComposite).open();\n\t\t\t}\n\t\t});\n\t}\n", "output": "\tpublic void create() {\n\t\tsuper.create();\n\t\tDisplay.getDefault().asyncExec(new Runnable() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tGridData gridData = new GridData();\n\t\t\t\tgridData.grabExcessHorizontalSpace = true;\n\t\t\t\tgridData.widthHint = 400;\n\t\t\t\tgridData.heightHint = 50;\n\t\t\t\tComposite infoComposite = new Composite(parentComposite, SWT.NULL);\n\t\t\t\tinfoComposite.setLayoutData(gridData);\n\t\t\t\tinfoComposite.setLayout(new FillLayout(SWT.VERTICAL));\n\t\t\t\tfinal Slider pValueSlider = new Slider(infoComposite, SWT.HORIZONTAL);\n\t\t\t\tfinal Label pValueLabel = new Label(infoComposite, SWT.NULL);\n\t\t\t\tpValue = histogram.getMax();\n\t\t\t\tpValueLabel.setText(\"p-Value: \" + Float.toString(pValue));\n\t\t\t\tpValueSlider.setMinimum(0);\n\t\t\t\tpValueSlider.setMaximum((int) (histogram.getMax() * 10000));\n\t\t\t\tpValueSlider.setIncrement(1);\n\t\t\t\tpValueSlider.setPageIncrement(5);\n\t\t\t\tpValueSlider.setSelection((int) (pValue * 10000));\n\t\t\t\tpValueSlider.addMouseListener(new MouseAdapter() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void mouseUp(MouseEvent e) {\n\t\t\t\t\t\tpValue = (float) pValueSlider.getSelection() / 10000.00f;\n\t\t\t\t\t\tSystem.out.println(pValue);\n\t\t\t\t\t\tpValueLabel.setText(\"p-Value: \" + Float.toString(pValue));\n\t\t\t\t\t\tparentComposite.pack();\n\t\t\t\t\t\tparentComposite.layout();\n\t\t\t\t\t\tcreateVADelta();\n\t\t\t\t\t\tfilter.updateFilterManager();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tComposite histoComposite = new Composite(parentComposite, SWT.NULL);\n\t\t\t\thistoComposite.setLayout(new FillLayout(SWT.VERTICAL));\n\t\t\t\tgridData.heightHint = 300;\n\t\t\t\tgridData.grabExcessVerticalSpace = true;\n\t\t\t\thistoComposite.setLayoutData(gridData);\n\t\t\t\tRcpGLHistogramView histogramView = new RcpGLHistogramView();\n\t\t\t\thistogramView.setDataDomain(DataDomainManager.get().getDataDomain(\n\t\t\t\t\t\t\"org.caleydo.datadomain.genetic\"));\n\t\t\t\thistogramView.createDefaultSerializedView();\n\t\t\t\thistogramView.createPartControl(histoComposite);\n\t\t\t\t((GLHistogram) (histogramView.getGLView())).setHistogram(histogram);\n\t\t\t\tGeneralManager.get().getViewGLCanvasManager()\n\t\t\t\t\t\t.registerGLCanvasToAnimator(histogramView.getGLCanvas());\n\t\t\t\tMonitor primary = parentComposite.getDisplay().getPrimaryMonitor();\n\t\t\t\tRectangle bounds = primary.getBounds();\n\t\t\t\tRectangle rect = parentComposite.getBounds();\n\t\t\t\tint x = bounds.x + (bounds.width - rect.width) / 2;\n\t\t\t\tint y = bounds.y + (bounds.height - rect.height) / 2;\n\t\t\t\tparentComposite.setLocation(x, y);\n\t\t\t\t((Shell) parentComposite).open();\n\t\t\t}\n\t\t});\n\t}\n"} {"input": " AbstractCallPeer<?, ?> createOutgoingCall(\n CallJabberImpl call,\n String calleeAddress,\n Iterable<PacketExtension> sessionInitiateExtensions)\n throws OperationFailedException\n {\n if (logger.isInfoEnabled())\n logger.info(\"creating outgoing call...\");\n if (protocolProvider.getConnection() == null || call == null)\n {\n throw new OperationFailedException(\n \"Failed to create OutgoingJingleSession.\"\n + \" We don't have a valid XMPPConnection.\",\n OperationFailedException.INTERNAL_ERROR);\n }\n boolean isGoogle = protocolProvider.isGmailOrGoogleAppsAccount();\n boolean isGoogleVoice = false;\n if(isGoogle)\n {\n if(!calleeAddress.contains(\"@\"))\n {\n calleeAddress += \"@\" + GOOGLE_VOICE_DOMAIN;\n isGoogleVoice = true;\n }\n else if(calleeAddress.endsWith(GOOGLE_VOICE_DOMAIN))\n {\n isGoogleVoice = true;\n }\n }\n if(calleeAddress.indexOf('@') == -1)\n {\n String serviceName = null;\n String phoneSuffix =\n (String)getProtocolProvider().getAccountID().getAccountProperty(\n \"OVERRIDE_PHONE_SUFFIX\");\n if(phoneSuffix == null || phoneSuffix.length() == 0)\n {\n serviceName = \"@\" + StringUtils.parseServer(\n getProtocolProvider().getAccountID().getUserID());\n }\n else\n {\n serviceName = \"@\" + phoneSuffix;\n }\n calleeAddress += serviceName;\n }\n AccountID accountID = getProtocolProvider().getAccountID();\n String bypassDomain = accountID.getAccountPropertyString(\n \"TELEPHONY_BYPASS_GTALK_CAPS\");\n boolean alwaysCallGtalk = ((bypassDomain != null) &&\n bypassDomain.equals(calleeAddress.substring(\n calleeAddress.indexOf('@') + 1))) || isGoogleVoice;\n String fullCalleeURI = null;\n DiscoverInfo di = null;\n int bestPriority = -1;\n if(!getProtocolProvider().getConnection().getRoster().contains(\n calleeAddress) && !alwaysCallGtalk)\n {\n throw new OperationFailedException(\n calleeAddress + \" does not belong to our contact list\",\n OperationFailedException.NOT_FOUND);\n }\n Iterator<Presence> it =\n getProtocolProvider().getConnection().getRoster().getPresences(\n calleeAddress);\n String calleeURI = null;\n boolean isGingle = false;\n String gingleURI = null;\n while(it.hasNext())\n {\n Presence presence = it.next();\n int priority = (presence.getPriority() == Integer.MIN_VALUE) ? 0 :\n presence.getPriority();\n calleeURI = presence.getFrom();\n DiscoverInfo discoverInfo = null;\n try\n {\n discoverInfo =\n protocolProvider.getDiscoveryManager().\n discoverInfo(calleeURI);\n }\n catch (XMPPException ex)\n {\n logger.warn(\"could not retrieve info for \" + fullCalleeURI, ex);\n }\n boolean hasGtalkCaps =\n getProtocolProvider().isExtFeatureListSupported(\n calleeURI, ProtocolProviderServiceJabberImpl.\n CAPS_GTALK_WEB_VOICE);\n if (discoverInfo != null && discoverInfo.containsFeature(\n ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE))\n {\n if(priority > bestPriority)\n {\n bestPriority = priority;\n di = discoverInfo;\n fullCalleeURI = calleeURI;\n isGingle = false;\n }\n }\n else\n {\n if(!protocolProvider.isGTalkTesting() && !alwaysCallGtalk)\n {\n continue;\n }\n if(hasGtalkCaps || alwaysCallGtalk)\n {\n if(priority > bestPriority)\n {\n bestPriority = priority;\n isGingle = true;\n gingleURI = calleeURI;\n }\n }\n }\n }\n if(isGingle)\n {\n if(logger.isInfoEnabled())\n {\n logger.info(gingleURI + \": Google Talk dialect supported\");\n }\n fullCalleeURI = gingleURI;\n }\n else if(di != null)\n {\n if (logger.isInfoEnabled())\n logger.info(fullCalleeURI + \": jingle supported \");\n }\n else\n {\n if (logger.isInfoEnabled())\n logger.info(calleeURI +\n \": jingle and Google Talk not supported ?\");\n throw new OperationFailedException(\n \"Failed to create OutgoingJingleSession.\\n\"\n + calleeURI + \" does not support jingle or Google Talk\",\n OperationFailedException.INTERNAL_ERROR);\n }\n if(logger.isInfoEnabled())\n {\n logger.info(\"Choose one is: \" + fullCalleeURI + \" \" + bestPriority);\n }\n AbstractCallPeer<?, ?> peer = null;\n try\n {\n if(isGingle)\n {\n logger.info(\"initiate Gingle call\");\n CallGTalkImpl callGTalk = new CallGTalkImpl(this);\n MediaUseCase useCase = call.getMediaUseCase();\n boolean isVideo = call.isLocalVideoAllowed(useCase);\n callGTalk.setLocalVideoAllowed(isVideo, useCase);\n peer = callGTalk.initiateGTalkSession(fullCalleeURI,\n sessionInitiateExtensions);\n }\n else if(di != null)\n {\n peer\n = call.initiateSession(\n fullCalleeURI,\n di,\n sessionInitiateExtensions);\n }\n }\n catch(Throwable t)\n {\n if (t instanceof ThreadDeath)\n throw (ThreadDeath) t;\n throw new OperationFailedException(\n \"Failed to create a call\",\n OperationFailedException.INTERNAL_ERROR,\n t);\n }\n return peer;\n }\n", "output": " AbstractCallPeer<?, ?> createOutgoingCall(\n CallJabberImpl call,\n String calleeAddress,\n Iterable<PacketExtension> sessionInitiateExtensions)\n throws OperationFailedException\n {\n if (logger.isInfoEnabled())\n logger.info(\"creating outgoing call...\");\n if (protocolProvider.getConnection() == null || call == null)\n {\n throw new OperationFailedException(\n \"Failed to create OutgoingJingleSession.\"\n + \" We don't have a valid XMPPConnection.\",\n OperationFailedException.INTERNAL_ERROR);\n }\n boolean isGoogle = protocolProvider.isGmailOrGoogleAppsAccount();\n boolean isGoogleVoice = false;\n if(isGoogle)\n {\n if(!calleeAddress.contains(\"@\"))\n {\n calleeAddress += \"@\" + GOOGLE_VOICE_DOMAIN;\n isGoogleVoice = true;\n }\n else if(calleeAddress.endsWith(GOOGLE_VOICE_DOMAIN))\n {\n isGoogleVoice = true;\n }\n }\n if(calleeAddress.indexOf('@') == -1)\n {\n String serviceName = null;\n String phoneSuffix =\n (String)getProtocolProvider().getAccountID().getAccountProperty(\n \"OVERRIDE_PHONE_SUFFIX\");\n if(phoneSuffix == null || phoneSuffix.length() == 0)\n {\n serviceName = \"@\" + StringUtils.parseServer(\n getProtocolProvider().getAccountID().getUserID());\n }\n else\n {\n serviceName = \"@\" + phoneSuffix;\n }\n calleeAddress += serviceName;\n }\n AccountID accountID = getProtocolProvider().getAccountID();\n String bypassDomain = accountID.getAccountPropertyString(\n \"TELEPHONY_BYPASS_GTALK_CAPS\");\n boolean alwaysCallGtalk = ((bypassDomain != null) &&\n bypassDomain.equals(calleeAddress.substring(\n calleeAddress.indexOf('@') + 1))) || isGoogleVoice;\n String fullCalleeURI = null;\n DiscoverInfo di = null;\n int bestPriority = -1;\n if(!getProtocolProvider().getConnection().getRoster().contains(\n StringUtils.parseBareAddress(calleeAddress)) && !alwaysCallGtalk)\n {\n throw new OperationFailedException(\n calleeAddress + \" does not belong to our contact list\",\n OperationFailedException.NOT_FOUND);\n }\n Iterator<Presence> it =\n getProtocolProvider().getConnection().getRoster().getPresences(\n calleeAddress);\n String calleeURI = null;\n boolean isGingle = false;\n String gingleURI = null;\n while(it.hasNext())\n {\n Presence presence = it.next();\n int priority = (presence.getPriority() == Integer.MIN_VALUE) ? 0 :\n presence.getPriority();\n calleeURI = presence.getFrom();\n DiscoverInfo discoverInfo = null;\n try\n {\n discoverInfo =\n protocolProvider.getDiscoveryManager().\n discoverInfo(calleeURI);\n }\n catch (XMPPException ex)\n {\n logger.warn(\"could not retrieve info for \" + fullCalleeURI, ex);\n }\n boolean hasGtalkCaps =\n getProtocolProvider().isExtFeatureListSupported(\n calleeURI, ProtocolProviderServiceJabberImpl.\n CAPS_GTALK_WEB_VOICE);\n if (discoverInfo != null && discoverInfo.containsFeature(\n ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE))\n {\n if(priority > bestPriority)\n {\n bestPriority = priority;\n di = discoverInfo;\n fullCalleeURI = calleeURI;\n isGingle = false;\n }\n }\n else\n {\n if(!protocolProvider.isGTalkTesting() && !alwaysCallGtalk)\n {\n continue;\n }\n if(hasGtalkCaps || alwaysCallGtalk)\n {\n if(priority > bestPriority)\n {\n bestPriority = priority;\n isGingle = true;\n gingleURI = calleeURI;\n }\n }\n }\n }\n if(isGingle)\n {\n if(logger.isInfoEnabled())\n {\n logger.info(gingleURI + \": Google Talk dialect supported\");\n }\n fullCalleeURI = gingleURI;\n }\n else if(di != null)\n {\n if (logger.isInfoEnabled())\n logger.info(fullCalleeURI + \": jingle supported \");\n }\n else\n {\n if (logger.isInfoEnabled())\n logger.info(calleeURI +\n \": jingle and Google Talk not supported ?\");\n throw new OperationFailedException(\n \"Failed to create OutgoingJingleSession.\\n\"\n + calleeURI + \" does not support jingle or Google Talk\",\n OperationFailedException.INTERNAL_ERROR);\n }\n if(logger.isInfoEnabled())\n {\n logger.info(\"Choose one is: \" + fullCalleeURI + \" \" + bestPriority);\n }\n AbstractCallPeer<?, ?> peer = null;\n try\n {\n if(isGingle)\n {\n logger.info(\"initiate Gingle call\");\n CallGTalkImpl callGTalk = new CallGTalkImpl(this);\n MediaUseCase useCase = call.getMediaUseCase();\n boolean isVideo = call.isLocalVideoAllowed(useCase);\n callGTalk.setLocalVideoAllowed(isVideo, useCase);\n peer = callGTalk.initiateGTalkSession(fullCalleeURI,\n sessionInitiateExtensions);\n }\n else if(di != null)\n {\n peer\n = call.initiateSession(\n fullCalleeURI,\n di,\n sessionInitiateExtensions);\n }\n }\n catch(Throwable t)\n {\n if (t instanceof ThreadDeath)\n throw (ThreadDeath) t;\n throw new OperationFailedException(\n \"Failed to create a call\",\n OperationFailedException.INTERNAL_ERROR,\n t);\n }\n return peer;\n }\n"} {"input": " public void defaultConfiguration() {\n assertProcess(\"Simple text\", \"Simple text\");\n assertProcess(\"&\", \"&\");\n assertProcess(\"'\", \"'\");\n assertProcess(\"<\", \"<\");\n assertProcess(\">\", \">\");\n assertProcess(\""\", \"\\\"\");\n assertProcess(\"<br/>\", \"\\r\\n\");\n assertProcess(\"<br/>\", \"\\n\\r\");\n assertProcess(\"<br/>\", \"\\r\");\n assertProcess(\"<br/>\", \"\\n\");\n assertProcess(\"\\\\\", \"\\\\\\\\\");\n assertProcess(\"[\", \"\\\\[\");\n assertProcess(\"]\", \"\\\\]\");\n assertProcess(\"<span style=\\\"font-weight:bold;\\\">test</span>\", \"[b]test[/b]\");\n assertProcess(\"<span style=\\\"text-decoration:underline;\\\">test</span>\", \"[u]test[/u]\");\n assertProcess(\"<span style=\\\"text-decoration:line-through;\\\">test</span>\", \"[s]test[/s]\");\n assertProcess(\"<span style=\\\"font-style:italic;\\\">test</span>\", \"[i]test[/i]\");\n assertProcess(\"<img src=\\\"http://kefir-bb.sourceforge.net/ava.jpg\\\"/>\", \"[img]http://kefir-bb.sourceforge.net/ava.jpg[/img]\");\n assertProcess(\"<img src=\\\"/ava.jpg\\\"/>\", \"[img]/ava.jpg[/img]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">KefirBB</a>\", \"[url=http://kefir-bb.sourceforge.net]KefirBB[/url]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">http://kefir-bb.sourceforge.net</a>\", \"[url]http://kefir-bb.sourceforge.net[/url]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">KefirBB</a>\", \"[url=kefir-bb.sourceforge.net]KefirBB[/url]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">kefir-bb.sourceforge.net</a>\", \"[url]kefir-bb.sourceforge.net[/url]\");\n assertProcess(\"<a href=\\\"https://securedsite.org\\\">Secured</a>\", \"[url=https://securedsite.org]Secured[/url]\");\n assertProcess(\"<a href=\\\"https://securedsite.org\\\">https://securedsite.org</a>\", \"[url]https://securedsite.org[/url]\");\n assertProcess(\"<a href=\\\"mailto:kefir@perm.ru\\\">Mail to Kefir</a>\", \"[url=mailto:kefir@perm.ru]Mail to Kefir[/url]\");\n assertProcess(\"<a href=\\\"mailto:kefir@perm.ru\\\">mailto:kefir@perm.ru</a>\", \"[url]mailto:kefir@perm.ru[/url]\");\n assertProcess(\"<a href=\\\"/test.xml\\\">Test</a>\", \"[url=/test.xml]Test[/url]\");\n assertProcess(\"<a href=\\\"/test.xml\\\">/test.xml</a>\", \"[url]/test.xml[/url]\");\n assertProcess(\"<a href=\\\"./test.xml\\\">Test</a>\", \"[url=./test.xml]Test[/url]\");\n assertProcess(\"<a href=\\\"./test.xml\\\">./test.xml</a>\", \"[url]./test.xml[/url]\");\n assertProcess(\"<a href=\\\"../test.xml\\\">Test</a>\", \"[url=../test.xml]Test[/url]\");\n assertProcess(\"<a href=\\\"../test.xml\\\">../test.xml</a>\", \"[url]../test.xml[/url]\");\n assertProcess(\"<a href=\\\"http://javascript:alert('Kefir is stupid!');\\\">javascript:alert('Kefir is stupid!');</a>\", \"[url]javascript:alert('Kefir is stupid!');[/url]\");\n assertProcess(\"<span style=\\\"color:red;\\\">Red text</span>\", \"[color=red]Red text[/color]\");\n assertProcess(\"<span style=\\\"font-size:14px;\\\">Test</span>\", \"[size=14px]Test[/size]\");\n assertProcess(\"<blockquote>Quoted text</blockquote>\", \"[quote]Quoted text[/quote]\");\n assertProcess(\"«Test»\", \"[aquote]Test[/aquote]\");\n assertProcess(\"\", \"[*Comment*]\");\n assertProcess(\"©\", \"[symbol=copy/]\");\n }\n", "output": " public void defaultConfiguration() {\n assertProcess(\"Simple text\", \"Simple text\");\n assertProcess(\"&\", \"&\");\n assertProcess(\"'\", \"'\");\n assertProcess(\"<\", \"<\");\n assertProcess(\">\", \">\");\n assertProcess(\""\", \"\\\"\");\n assertProcess(\"<br/>\", \"\\r\\n\");\n assertProcess(\"<br/>\", \"\\n\\r\");\n assertProcess(\"<br/>\", \"\\r\");\n assertProcess(\"<br/>\", \"\\n\");\n assertProcess(\"\\\\\", \"\\\\\\\\\");\n assertProcess(\"[\", \"\\\\[\");\n assertProcess(\"]\", \"\\\\]\");\n assertProcess(\"<span style=\\\"font-weight:bold;\\\">test</span>\", \"[B]test[/b]\");\n assertProcess(\"<span style=\\\"text-decoration:underline;\\\">test</span>\", \"[u]test[/u]\");\n assertProcess(\"<span style=\\\"text-decoration:line-through;\\\">test</span>\", \"[s]test[/s]\");\n assertProcess(\"<span style=\\\"font-style:italic;\\\">test</span>\", \"[i]test[/i]\");\n assertProcess(\"<img src=\\\"http://kefir-bb.sourceforge.net/ava.jpg\\\"/>\", \"[img]http://kefir-bb.sourceforge.net/ava.jpg[/img]\");\n assertProcess(\"<img src=\\\"/ava.jpg\\\"/>\", \"[img]/ava.jpg[/img]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">KefirBB</a>\", \"[url=http://kefir-bb.sourceforge.net]KefirBB[/url]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">http://kefir-bb.sourceforge.net</a>\", \"[url]http://kefir-bb.sourceforge.net[/url]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">KefirBB</a>\", \"[url=kefir-bb.sourceforge.net]KefirBB[/url]\");\n assertProcess(\"<a href=\\\"http://kefir-bb.sourceforge.net\\\">kefir-bb.sourceforge.net</a>\", \"[url]kefir-bb.sourceforge.net[/url]\");\n assertProcess(\"<a href=\\\"https://securedsite.org\\\">Secured</a>\", \"[url=https://securedsite.org]Secured[/url]\");\n assertProcess(\"<a href=\\\"https://securedsite.org\\\">https://securedsite.org</a>\", \"[url]https://securedsite.org[/url]\");\n assertProcess(\"<a href=\\\"mailto:kefir@perm.ru\\\">Mail to Kefir</a>\", \"[url=mailto:kefir@perm.ru]Mail to Kefir[/url]\");\n assertProcess(\"<a href=\\\"mailto:kefir@perm.ru\\\">mailto:kefir@perm.ru</a>\", \"[url]mailto:kefir@perm.ru[/url]\");\n assertProcess(\"<a href=\\\"/test.xml\\\">Test</a>\", \"[url=/test.xml]Test[/url]\");\n assertProcess(\"<a href=\\\"/test.xml\\\">/test.xml</a>\", \"[url]/test.xml[/url]\");\n assertProcess(\"<a href=\\\"./test.xml\\\">Test</a>\", \"[url=./test.xml]Test[/url]\");\n assertProcess(\"<a href=\\\"./test.xml\\\">./test.xml</a>\", \"[url]./test.xml[/url]\");\n assertProcess(\"<a href=\\\"../test.xml\\\">Test</a>\", \"[url=../test.xml]Test[/url]\");\n assertProcess(\"<a href=\\\"../test.xml\\\">../test.xml</a>\", \"[url]../test.xml[/url]\");\n assertProcess(\"<a href=\\\"http://javascript:alert('Kefir is stupid!');\\\">javascript:alert('Kefir is stupid!');</a>\", \"[url]javascript:alert('Kefir is stupid!');[/url]\");\n assertProcess(\"<span style=\\\"color:red;\\\">Red text</span>\", \"[color=red]Red text[/color]\");\n assertProcess(\"<span style=\\\"font-size:14px;\\\">Test</span>\", \"[size=14px]Test[/size]\");\n assertProcess(\"<blockquote>Quoted text</blockquote>\", \"[quote]Quoted text[/quote]\");\n assertProcess(\"«Test»\", \"[aquote]Test[/aquote]\");\n assertProcess(\"\", \"[*Comment*]\");\n assertProcess(\"©\", \"[symbol=copy/]\");\n }\n"} {"input": " private void processPartiallyTagged(Context context) throws IOException, InterruptedException {\n \tstateIndexes.clear();\n \tfor (int i = 0; i < items.length; ++i) {\n \t\tif (ArrayUtils.contains(states, items[i])) {\n \t\t\tstateIndexes.add(i);\n \t\t}\n \t}\n \t\toutKey.initialize();\n \t\toutKey.add(INITIAL_STATE, items[stateIndexes.get(0)], items[stateIndexes.get(0)]);\n \t\toutVal.set(1);\n \t\tcontext.write(outKey, outVal);\n \tint leftBound = 0;\n \tint rightBound = 0;\n \tint leftWindow = 0;\n \tint rightWindow = 0;\n \tfor (int i = 0; i < stateIndexes.size(); ++i ) {\n \t\tif (i > 0) {\n \t\t\tleftWindow = stateIndexes.get(i) - stateIndexes.get(i-1) / 2;\n \t\t\tleftBound =stateIndexes.get(i) - leftWindow; \n \t\t} else {\n \t\t\tleftBound = -1;\n \t\t}\n \t\tif (i < stateIndexes.size() -1) {\n \t\t\trightWindow = stateIndexes.get(i+1) - stateIndexes.get(i) / 2; \n \t\t\trightBound = stateIndexes.get(i) + rightWindow;\n \t\t} else {\n \t\t\trightBound = -1;\n \t\t}\n \t\tif (leftBound == -1 && rightBound != -1) {\n \t\t\tleftBound =stateIndexes.get(i) - rightWindow; \n \t\t\tif (leftBound < 0) {\n \t\t\t\tleftBound = 0;\n \t\t\t}\n \t\t} else if (rightBound == -1 && leftBound != -1) {\n \t\t\trightBound =stateIndexes.get(i) + leftWindow; \n \t\t\tif (rightBound >= items.length) {\n \t\t\t\trightBound = items.length-1;\n \t\t\t}\n \t\t}\n \t\tString state = items[stateIndexes.get(i)];\n \t\tfor (int j = stateIndexes.get(i)-1, k=0; j >= leftBound; --j,++k ) {\n \t\t\tString obs = items[j];\n \t\toutKey.initialize();\n \t\toutKey.add(STATE_OBS, state, obs);\n \t\toutVal.set(windowFunction[k]);\n \t\tcontext.write(outKey, outVal);\n \t\t}\n \t\tfor (int j = stateIndexes.get(i)+1, k=0; j <= rightBound; ++j,++k ) {\n \t\t\tString obs = items[j];\n \t\toutKey.initialize();\n \t\toutKey.add(STATE_OBS, state, obs);\n \t\toutVal.set(windowFunction[k]);\n \t\tcontext.write(outKey, outVal);\n \t\t}\n \t}\n \tfor (int i = 0; i < stateIndexes.size() -1; ++i) {\n \t\toutKey.initialize();\n \t\toutKey.add(STATE_TRANS, items[stateIndexes.get(i)], items[stateIndexes.get(i+1)]);\n \t\toutVal.set(1);\n \t\tcontext.write(outKey, outVal);\n \t}\n }\t\n", "output": " private void processPartiallyTagged(Context context) throws IOException, InterruptedException {\n \tstateIndexes.clear();\n \tfor (int i = 0; i < items.length; ++i) {\n \t\tif (ArrayUtils.contains(states, items[i])) {\n \t\t\tstateIndexes.add(i);\n \t\t}\n \t}\n \t\toutKey.initialize();\n \t\toutKey.add(INITIAL_STATE, items[stateIndexes.get(0)], items[stateIndexes.get(0)]);\n \t\toutVal.set(1);\n \t\tcontext.write(outKey, outVal);\n \tint leftBound = 0;\n \tint rightBound = 0;\n \tint leftWindow = 0;\n \tint rightWindow = 0;\n \tfor (int i = 0; i < stateIndexes.size(); ++i ) {\n \t\tif (i > 0) {\n \t\t\tleftWindow = stateIndexes.get(i) - stateIndexes.get(i-1) / 2;\n \t\t\tleftBound =stateIndexes.get(i) - leftWindow; \n \t\t} else {\n \t\t\tleftBound = -1;\n \t\t}\n \t\tif (i < stateIndexes.size() -1) {\n \t\t\trightWindow = stateIndexes.get(i+1) - stateIndexes.get(i) / 2; \n \t\t\trightBound = stateIndexes.get(i) + rightWindow;\n \t\t} else {\n \t\t\trightBound = -1;\n \t\t}\n \t\tif (leftBound == -1 && rightBound != -1) {\n \t\t\tleftBound =stateIndexes.get(i) - rightWindow; \n \t\t\tif (leftBound < 0) {\n \t\t\t\tleftBound = 0;\n \t\t\t}\n \t\t} else if (rightBound == -1 && leftBound != -1) {\n \t\t\trightBound =stateIndexes.get(i) + leftWindow; \n \t\t\tif (rightBound >= items.length) {\n \t\t\t\trightBound = items.length-1;\n \t\t\t}\n \t\t} else if (leftBound == -1 && rightBound == -1) {\n \t\t\tleftBound =stateIndexes.get(i) / 2;\n \t\t\trightBound = stateIndexes.get(i) + (items.length - 1 - stateIndexes.get(i)) / 2;\n \t\t}\n \t\tString state = items[stateIndexes.get(i)];\n \t\tfor (int j = stateIndexes.get(i)-1, k=0; j >= leftBound; --j,++k ) {\n \t\t\tString obs = items[j];\n \t\toutKey.initialize();\n \t\toutKey.add(STATE_OBS, state, obs);\n \t\tint val = k < windowFunction.length ? windowFunction[k] : windowFunction[ windowFunction.length -1]; \n \t\toutVal.set(val);\n \t\tcontext.write(outKey, outVal);\n \t\t}\n \t\tfor (int j = stateIndexes.get(i)+1, k=0; j <= rightBound; ++j,++k ) {\n \t\t\tString obs = items[j];\n \t\toutKey.initialize();\n \t\toutKey.add(STATE_OBS, state, obs);\n \t\tint val = k < windowFunction.length ? windowFunction[k] : windowFunction[ windowFunction.length -1]; \n \t\toutVal.set(val);\n \t\tcontext.write(outKey, outVal);\n \t\t}\n \t}\n \tfor (int i = 0; i < stateIndexes.size() -1; ++i) {\n \t\toutKey.initialize();\n \t\toutKey.add(STATE_TRANS, items[stateIndexes.get(i)], items[stateIndexes.get(i+1)]);\n \t\toutVal.set(1);\n \t\tcontext.write(outKey, outVal);\n \t}\n }\t\n"} {"input": " public void testExchangeCZKUSD() throws Exception {\n Currency usd = new Currency(\"USD\");\n Currency czk = new Currency(\"CZK\");\n Calculator c = createCZKtoUSD();\n CurrencyValue result = c.convert(new CurrencyValue(usd, 5.0), czk);\n assertEquals(result.getValue(), 85.0);\n assertEquals(result.getCurrency(), czk);\n result = c.convert(new CurrencyValue(usd, 8.0), czk);\n assertEquals(result.getValue(), 136);\n assertEquals(result.getCurrency(), czk);\n result = c.convert(new CurrencyValue(czk, 1003.0), usd);\n assertEquals(result.getValue(), 59);\n assertEquals(result.getCurrency(), usd);\n }\n", "output": " public void testExchangeCZKUSD() throws Exception {\n Currency usd = new Currency(\"USD\");\n Currency czk = new Currency(\"CZK\");\n Calculator c = createCZKtoUSD();\n CurrencyValue result = c.convert(new CurrencyValue(usd, 5.0), czk);\n assertEquals(result.getValue(), 85.0);\n assertEquals(result.getCurrency(), czk);\n result = c.convert(new CurrencyValue(usd, 8.0), czk);\n assertEquals(result.getValue(), 136.0);\n assertEquals(result.getCurrency(), czk);\n result = c.convert(new CurrencyValue(czk, 1003.0), usd);\n assertEquals(result.getValue(), 59.0);\n assertEquals(result.getCurrency(), usd);\n }\n"} {"input": "\tprivate void selectAttribute() { \n\t\tif(attribute == null || attribute.length() == 0) return;\n\t\tXAttribute a = object.getModelEntity().getAttribute(attribute);\n\t\tif(isESB(a)) {\n\t\t\tfindESBAttrPosition(a);\n\t\t}\n\t\tString xml = (a == null) ? null : a.getXMLName();\n\t\tif(xml == null || xml.length() == 0) return;\n\t\tif(xml.indexOf(\".\") < 0) { \n\t\t\tString s = text.substring(startPosition, endPosition);\n\t\t\tint i1 = findAttrPosition(s, xml);\n\t\t\tif(selectAttributeName) {\n\t\t\t\tif(i1 < 0) return;\n\t\t\t\tstartPosition = startPosition + i1;\n\t\t\t\tendPosition = startPosition + xml.length();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint i2 = (i1 < 0) ? -1 : s.indexOf('\"', i1 + 1);\n\t\t\tint i3 = (i2 < 0) ? -1 : s.indexOf('\"', i2 + 1);\n\t\t\tif(i3 > 0) {\n\t\t\t\tendPosition = startPosition + i3;\t\t\t\t\t\t\n\t\t\t\tstartPosition = startPosition + i2 + 1;\n\t\t\t}\n\t\t} else {\n\t\t\txml = xml.substring(0, xml.indexOf('.'));\n\t\t\tint e1 = text.indexOf(\"</\" + getTagXMLName(object) + \">\", startPosition); \n\t\t\tString s = e1 < 0 ? \"\" : text.substring(startPosition, e1); \n\t\t\tif(xml.length() == 0) {\n\t\t\t\tint i1 = s.indexOf(\">\"); \n\t\t\t\tendPosition = startPosition + i1 + 1;\n\t\t\t\tstartPosition = startPosition + e1;\n\t\t\t} else if(s.length() > 0) {\n\t\t\t\tint i1a = s.indexOf(\"<\" + xml + \">\"); \n\t\t\t\tint i1b = s.indexOf(\"<\" + xml + \"/>\"); \n\t\t\t\tint i2 = (i1a < 0) ? -1 : s.indexOf(\"</\", i1a); \n\t\t\t\tif(i1a >= 0 && i2 >= 0) {\n\t\t\t\t\tendPosition = startPosition + i2;\n\t\t\t\t\tstartPosition = startPosition + i1a + 2 + xml.length();\n\t\t\t\t} else if(i1b >= 0) {\n\t\t\t\t\tendPosition = startPosition + i1b + 3 + xml.length();\n\t\t\t\t\tstartPosition = startPosition + i1b;\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\t\t\t\n\t}\n", "output": "\tprivate void selectAttribute() { \n\t\tif(attribute == null || attribute.length() == 0) return;\n\t\tXAttribute a = object.getModelEntity().getAttribute(attribute);\n\t\tif(isESB(a)) {\n\t\t\tfindESBAttrPosition(a);\n\t\t}\n\t\tString xml = (a == null) ? null : a.getXMLName();\n\t\tif(xml == null || xml.length() == 0) return;\n\t\tif(xml.indexOf(\".\") < 0) { \n\t\t\tString s = text.substring(startPosition, endPosition);\n\t\t\tint i1 = findAttrPosition(s, xml);\n\t\t\tif(selectAttributeName) {\n\t\t\t\tif(i1 < 0) return;\n\t\t\t\tstartPosition = startPosition + i1;\n\t\t\t\tendPosition = startPosition + xml.length();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint i2 = (i1 < 0) ? -1 : s.indexOf('\"', i1 + 1);\n\t\t\tint i3 = (i2 < 0) ? -1 : s.indexOf('\"', i2 + 1);\n\t\t\tif(i3 > 0) {\n\t\t\t\tendPosition = startPosition + i3;\t\t\t\t\t\t\n\t\t\t\tstartPosition = startPosition + i2 + 1;\n\t\t\t}\n\t\t} else {\n\t\t\txml = xml.substring(0, xml.lastIndexOf('.')); \n\t\t\tif(xml.indexOf('.') >= 0) {\n\t\t\t\txml = xml.substring(xml.lastIndexOf('.') + 1); \n\t\t\t}\n\t\t\tint e1 = text.indexOf(\"</\" + getTagXMLName(object) + \">\", startPosition); \n\t\t\tString s = e1 < 0 ? \"\" : text.substring(startPosition, e1); \n\t\t\tif(xml.length() == 0) {\n\t\t\t\tint i1 = s.indexOf(\">\"); \n\t\t\t\tendPosition = startPosition + i1 + 1;\n\t\t\t\tstartPosition = startPosition + e1;\n\t\t\t} else if(s.length() > 0) {\n\t\t\t\tint i1a = s.indexOf(\"<\" + xml + \">\"); \n\t\t\t\tint i1b = s.indexOf(\"<\" + xml + \"/>\"); \n\t\t\t\tint i2 = (i1a < 0) ? -1 : s.indexOf(\"</\", i1a); \n\t\t\t\tif(i1a >= 0 && i2 >= 0) {\n\t\t\t\t\tendPosition = startPosition + i2;\n\t\t\t\t\tstartPosition = startPosition + i1a + 2 + xml.length();\n\t\t\t\t} else if(i1b >= 0) {\n\t\t\t\t\tendPosition = startPosition + i1b + 3 + xml.length();\n\t\t\t\t\tstartPosition = startPosition + i1b;\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\t\t\t\n\t}\n"} {"input": " public RuleViolation(Rule rule, RuleContext ctx, SimpleNode node, String specificMsg) {\n this.rule = rule;\n this.filename = ctx.getSourceCodeFilename();\n this.description = specificMsg;\n if (node != null) {\n\t if (node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class) == null) {\n\t className = \"\";\n\t } else {\n\t className = node.getScope().getEnclosingClassScope().getClassName() == null ? \"\" : node.getScope().getEnclosingClassScope().getClassName();\n\t }\n\t String qualifiedName = null;\n\t List<ASTClassOrInterfaceDeclaration> parents = node.getParentsOfType(ASTClassOrInterfaceDeclaration.class);\n\t for ( ASTClassOrInterfaceDeclaration parent : parents )\n\t {\n\t \tif (qualifiedName == null) {\n\t \t\tqualifiedName = parent.getScope().getEnclosingClassScope().getClassName();\n\t } else {\n\t \tqualifiedName = qualifiedName + \"$\" + parent.getScope().getEnclosingClassScope().getClassName();\n\t }\n\t }\n\t if ( ! \"net.sourceforge.pmd.symboltable.SourceFileScope\".equals(node.getScope().getClass().getName() ) ) {\n\t \tclassName = node.getScope().getEnclosingClassScope().getClassName() == null ? \"\" : qualifiedName;\n\t }\n\t setVariableNameIfExists(node);\n\t methodName = node.getFirstParentOfType(ASTMethodDeclaration.class) == null ? \"\" : node.getScope().getEnclosingMethodScope().getName();\n\t packageName = node.getScope().getEnclosingSourceFileScope().getPackageName() == null ? \"\" : node.getScope().getEnclosingSourceFileScope().getPackageName();\n\t beginLine = node.getBeginLine();\n\t endLine = node.getEndLine();\n\t beginColumn = node.getBeginColumn();\n\t endColumn = node.getEndColumn();\n\t List<SimpleNode> parentTypes = new ArrayList<SimpleNode>(node.getParentsOfType(ASTTypeDeclaration.class));\n\t if (node instanceof ASTTypeDeclaration) {\n\t parentTypes.add(node);\n\t }\n\t parentTypes.addAll(node.getParentsOfType(ASTClassOrInterfaceBodyDeclaration.class));\n\t if (node instanceof ASTClassOrInterfaceBodyDeclaration) {\n\t parentTypes.add(node);\n\t }\n\t parentTypes.addAll(node.getParentsOfType(ASTFormalParameter.class));\n\t if (node instanceof ASTFormalParameter) {\n\t parentTypes.add(node);\n\t }\n\t parentTypes.addAll(node.getParentsOfType(ASTLocalVariableDeclaration.class));\n\t if (node instanceof ASTLocalVariableDeclaration) {\n\t parentTypes.add(node);\n\t }\n\t for (SimpleNode parentType : parentTypes) {\n\t CanSuppressWarnings t = (CanSuppressWarnings) parentType;\n\t if (t.hasSuppressWarningsAnnotationFor(getRule())) {\n\t isSuppressed = true;\n\t }\n\t }\n } else {\n \tclassName = \"\";\n \tmethodName = \"\";\n \tpackageName = \"\";\n \tfilename = \"\";\n }\n }\n", "output": " public RuleViolation(Rule rule, RuleContext ctx, SimpleNode node, String specificMsg) {\n this.rule = rule;\n this.filename = ctx.getSourceCodeFilename();\n this.description = specificMsg;\n if (node != null) {\n\t if (node.getFirstParentOfType(ASTClassOrInterfaceDeclaration.class) == null) {\n\t className = \"\";\n\t } else {\n\t className = node.getScope().getEnclosingClassScope().getClassName() == null ? \"\" : node.getScope().getEnclosingClassScope().getClassName();\n\t }\n\t String qualifiedName = null;\n\t List<ASTClassOrInterfaceDeclaration> parents = node.getParentsOfType(ASTClassOrInterfaceDeclaration.class);\n\t for ( ASTClassOrInterfaceDeclaration parent : parents )\n\t {\n\t \tif (qualifiedName == null) {\n\t \t\tqualifiedName = parent.getScope().getEnclosingClassScope().getClassName();\n\t } else {\n\t \tqualifiedName = parent.getScope().getEnclosingClassScope().getClassName() + \"$\" + qualifiedName;\n\t }\n\t }\n\t if ( ! \"net.sourceforge.pmd.symboltable.SourceFileScope\".equals(node.getScope().getClass().getName() ) ) {\n\t \tclassName = node.getScope().getEnclosingClassScope().getClassName() == null ? \"\" : qualifiedName;\n\t }\n\t setVariableNameIfExists(node);\n\t methodName = node.getFirstParentOfType(ASTMethodDeclaration.class) == null ? \"\" : node.getScope().getEnclosingMethodScope().getName();\n\t packageName = node.getScope().getEnclosingSourceFileScope().getPackageName() == null ? \"\" : node.getScope().getEnclosingSourceFileScope().getPackageName();\n\t beginLine = node.getBeginLine();\n\t endLine = node.getEndLine();\n\t beginColumn = node.getBeginColumn();\n\t endColumn = node.getEndColumn();\n\t List<SimpleNode> parentTypes = new ArrayList<SimpleNode>(node.getParentsOfType(ASTTypeDeclaration.class));\n\t if (node instanceof ASTTypeDeclaration) {\n\t parentTypes.add(node);\n\t }\n\t parentTypes.addAll(node.getParentsOfType(ASTClassOrInterfaceBodyDeclaration.class));\n\t if (node instanceof ASTClassOrInterfaceBodyDeclaration) {\n\t parentTypes.add(node);\n\t }\n\t parentTypes.addAll(node.getParentsOfType(ASTFormalParameter.class));\n\t if (node instanceof ASTFormalParameter) {\n\t parentTypes.add(node);\n\t }\n\t parentTypes.addAll(node.getParentsOfType(ASTLocalVariableDeclaration.class));\n\t if (node instanceof ASTLocalVariableDeclaration) {\n\t parentTypes.add(node);\n\t }\n\t for (SimpleNode parentType : parentTypes) {\n\t CanSuppressWarnings t = (CanSuppressWarnings) parentType;\n\t if (t.hasSuppressWarningsAnnotationFor(getRule())) {\n\t isSuppressed = true;\n\t }\n\t }\n } else {\n \tclassName = \"\";\n \tmethodName = \"\";\n \tpackageName = \"\";\n \tfilename = \"\";\n }\n }\n"} {"input": " protected void initFile(String id) throws FormatException, IOException {\n super.initFile(id);\n in = new RandomAccessInputStream(id);\n core[0].littleEndian = false;\n if (!in.readString(4).equals(\"8BPS\")) {\n throw new FormatException(\"Not a valid Photoshop file.\");\n }\n addGlobalMeta(\"Version\", in.readShort());\n in.skipBytes(6); \n core[0].sizeC = in.readShort();\n core[0].sizeY = in.readInt();\n core[0].sizeX = in.readInt();\n int bits = in.readShort();\n addGlobalMeta(\"Bits per pixel\", bits);\n core[0].pixelType = FormatTools.pixelTypeFromBytes(bits / 8, false, false);\n int colorMode = in.readShort();\n String modeString = null;\n switch (colorMode) {\n case 0:\n modeString = \"monochrome\";\n break;\n case 1:\n modeString = \"gray-scale\";\n break;\n case 2:\n modeString = \"palette color\";\n break;\n case 3:\n modeString = \"RGB\";\n break;\n case 4:\n modeString = \"CMYK\";\n break;\n case 6:\n modeString = \"Duotone\";\n break;\n case 7:\n modeString = \"Multichannel color\";\n break;\n case 8:\n modeString = \"Duotone\";\n break;\n case 9:\n modeString = \"LAB color\";\n break;\n }\n addGlobalMeta(\"Color mode\", modeString);\n int modeDataLength = in.readInt();\n long fp = in.getFilePointer();\n if (modeDataLength != 0) {\n if (colorMode == 2) {\n lut = new byte[3][256];\n for (int i=0; i<lut.length; i++) {\n in.read(lut[i]);\n }\n }\n in.seek(fp + modeDataLength);\n }\n in.skipBytes(4);\n while (in.readString(4).equals(\"8BIM\")) {\n int tag = in.readShort();\n int read = 1;\n while (in.read() != 0) read++;\n if (read % 2 == 1) in.skipBytes(1);\n int size = in.readInt();\n if (size % 2 == 1) size++;\n in.skipBytes(size);\n }\n in.seek(in.getFilePointer() - 4);\n int blockLen = in.readInt();\n if (blockLen == 0) {\n offset = in.getFilePointer();\n }\n else {\n int layerLen = in.readInt();\n int layerCount = in.readShort();\n if (layerCount < 0) {\n throw new FormatException(\"Vector data is not supported.\");\n }\n int[] w = new int[layerCount];\n int[] h = new int[layerCount];\n int[] c = new int[layerCount];\n for (int i=0; i<layerCount; i++) {\n int top = in.readInt();\n int left = in.readInt();\n int bottom = in.readInt();\n int right = in.readInt();\n w[i] = right - left;\n h[i] = bottom - top;\n c[i] = in.readShort();\n in.skipBytes(c[i] * 6 + 12);\n int len = in.readInt();\n if (len % 2 == 1) len++;\n in.skipBytes(len);\n }\n for (int i=0; i<layerCount; i++) {\n int[] lens = new int[h[i]];\n for (int cc=0; cc<c[i]; cc++) {\n boolean compressed = in.readShort() == 1;\n if (!compressed) in.skipBytes(w[i] * h[i]);\n else {\n for (int y=0; y<h[i]; y++) {\n lens[y] = in.readShort();\n }\n for (int y=0; y<h[i]; y++) {\n in.skipBytes(lens[y]);\n }\n }\n }\n }\n while (in.read() != '8');\n in.skipBytes(7);\n int len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n String s = in.readString(4);\n while (s.equals(\"8BIM\")) {\n in.skipBytes(4);\n len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n s = in.readString(4);\n }\n offset = in.getFilePointer() - 4;\n }\n core[0].sizeZ = 1;\n core[0].sizeT = 1;\n core[0].rgb = modeString.equals(\"RGB\");\n core[0].imageCount = getSizeC() / (isRGB() ? 3 : 1);\n core[0].indexed = modeString.equals(\"palette color\");\n core[0].falseColor = false;\n core[0].dimensionOrder = \"XYCZT\";\n core[0].interleaved = false;\n core[0].metadataComplete = true;\n MetadataStore store = makeFilterMetadata();\n MetadataTools.populatePixels(store, this);\n MetadataTools.setDefaultCreationDate(store, id, 0);\n }\n", "output": " protected void initFile(String id) throws FormatException, IOException {\n super.initFile(id);\n in = new RandomAccessInputStream(id);\n core[0].littleEndian = false;\n if (!in.readString(4).equals(\"8BPS\")) {\n throw new FormatException(\"Not a valid Photoshop file.\");\n }\n addGlobalMeta(\"Version\", in.readShort());\n in.skipBytes(6); \n core[0].sizeC = in.readShort();\n core[0].sizeY = in.readInt();\n core[0].sizeX = in.readInt();\n int bits = in.readShort();\n addGlobalMeta(\"Bits per pixel\", bits);\n core[0].pixelType = FormatTools.pixelTypeFromBytes(bits / 8, false, false);\n int colorMode = in.readShort();\n String modeString = null;\n switch (colorMode) {\n case 0:\n modeString = \"monochrome\";\n break;\n case 1:\n modeString = \"gray-scale\";\n break;\n case 2:\n modeString = \"palette color\";\n break;\n case 3:\n modeString = \"RGB\";\n break;\n case 4:\n modeString = \"CMYK\";\n break;\n case 6:\n modeString = \"Duotone\";\n break;\n case 7:\n modeString = \"Multichannel color\";\n break;\n case 8:\n modeString = \"Duotone\";\n break;\n case 9:\n modeString = \"LAB color\";\n break;\n }\n addGlobalMeta(\"Color mode\", modeString);\n int modeDataLength = in.readInt();\n long fp = in.getFilePointer();\n if (modeDataLength != 0) {\n if (colorMode == 2) {\n lut = new byte[3][256];\n for (int i=0; i<lut.length; i++) {\n in.read(lut[i]);\n }\n }\n in.seek(fp + modeDataLength);\n }\n in.skipBytes(4);\n while (in.readString(4).equals(\"8BIM\")) {\n int tag = in.readShort();\n int read = 1;\n while (in.read() != 0) read++;\n if (read % 2 == 1) in.skipBytes(1);\n int size = in.readInt();\n if (size % 2 == 1) size++;\n in.skipBytes(size);\n }\n in.seek(in.getFilePointer() - 4);\n int blockLen = in.readInt();\n if (blockLen == 0) {\n offset = in.getFilePointer();\n }\n else {\n int layerLen = in.readInt();\n int layerCount = in.readShort();\n if (layerCount < 0) {\n throw new FormatException(\"Vector data is not supported.\");\n }\n int[] w = new int[layerCount];\n int[] h = new int[layerCount];\n int[] c = new int[layerCount];\n for (int i=0; i<layerCount; i++) {\n int top = in.readInt();\n int left = in.readInt();\n int bottom = in.readInt();\n int right = in.readInt();\n w[i] = right - left;\n h[i] = bottom - top;\n c[i] = in.readShort();\n in.skipBytes(c[i] * 6 + 12);\n int len = in.readInt();\n if (len % 2 == 1) len++;\n in.skipBytes(len);\n }\n for (int i=0; i<layerCount; i++) {\n int[] lens = new int[h[i]];\n for (int cc=0; cc<c[i]; cc++) {\n boolean compressed = in.readShort() == 1;\n if (!compressed) in.skipBytes(w[i] * h[i]);\n else {\n for (int y=0; y<h[i]; y++) {\n lens[y] = in.readShort();\n }\n for (int y=0; y<h[i]; y++) {\n in.skipBytes(lens[y]);\n }\n }\n }\n }\n if (layerCount > 0) {\n while (in.read() != '8');\n in.skipBytes(7);\n }\n int len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n String s = in.readString(4);\n while (s.equals(\"8BIM\")) {\n in.skipBytes(4);\n len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n s = in.readString(4);\n }\n offset = in.getFilePointer() - 4;\n }\n core[0].sizeZ = 1;\n core[0].sizeT = 1;\n core[0].rgb = modeString.equals(\"RGB\");\n core[0].imageCount = getSizeC() / (isRGB() ? 3 : 1);\n core[0].indexed = modeString.equals(\"palette color\");\n core[0].falseColor = false;\n core[0].dimensionOrder = \"XYCZT\";\n core[0].interleaved = false;\n core[0].metadataComplete = true;\n MetadataStore store = makeFilterMetadata();\n MetadataTools.populatePixels(store, this);\n MetadataTools.setDefaultCreationDate(store, id, 0);\n }\n"} {"input": " private void doSaveProfile(HttpServletRequest request, HttpServletResponse response)\n throws ServletException, IOException {\n User currentUser = (User) request.getAttribute(\"user\");\n Profile profile = Profile.findForUser(currentUser);\n if(profile == null) {\n profile = new Profile();\n Key key = KeyFactory.createKey(Profile.class.getSimpleName(), currentUser.getEmail());\n profile.setKey(key);\n }\n profile.setAboutMe(request.getParameter(\"profile.aboutMe\"));\n profile.setUsername(request.getParameter(\"profile.username\"));\n profile.setPets(request.getParameterValues(\"profile.pet\"));\n profile.setGender(request.getParameter(\"profile.gender\"));\n profile.setMaritalStatus(request.getParameter(\"profile.maritalStatus\"));\n PersistenceManager pm = PMF.get().getPersistenceManager();\n try {\n pm.makePersistent(profile); \n } finally {\n pm.close();\n }\n response.sendRedirect(\"/profile/mine\");\n }\n", "output": " private void doSaveProfile(HttpServletRequest request, HttpServletResponse response)\n throws ServletException, IOException {\n User currentUser = (User) request.getAttribute(\"user\");\n Profile profile = Profile.findForUser(currentUser);\n if(profile == null) {\n profile = new Profile();\n Key key = KeyFactory.createKey(Profile.class.getSimpleName(), currentUser.getUserId());\n profile.setKey(key);\n }\n profile.setAboutMe(request.getParameter(\"profile.aboutMe\"));\n profile.setUsername(request.getParameter(\"profile.username\"));\n profile.setPets(request.getParameterValues(\"profile.pet\"));\n profile.setGender(request.getParameter(\"profile.gender\"));\n profile.setMaritalStatus(request.getParameter(\"profile.maritalStatus\"));\n PersistenceManager pm = PMF.get().getPersistenceManager();\n try {\n pm.makePersistent(profile); \n } finally {\n pm.close();\n }\n response.sendRedirect(\"/profile/mine\");\n }\n"} {"input": "\t\tpublic Collection<Namespace> elements(Language language) {\n\t\t\tCollection<Namespace> result = new ArrayList<Namespace>();\n\t\t\ttry {\n\t\t\t\tfor(String fqn: _namespaces) {\n\t\t\t\t result.add(namespace(fqn, language));\n\t\t\t\t}\n\t\t\t} catch (LookupException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n", "output": "\t\tpublic Collection<Namespace> elements(Language language) {\n\t\t\tCollection<Namespace> result = new ArrayList<Namespace>();\n\t\t\ttry {\n\t\t\t\tfor(String fqn: _namespaces) {\n\t\t\t\t Util.addNonNull(namespace(fqn, language),result);\n\t\t\t\t}\n\t\t\t} catch (LookupException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n"} {"input": "\tpublic void start()\n\t{\n\t\tGroupManager gm = this.world.getManager(GroupManager.class);\n\t\tTagManager tm = this.world.getManager(TagManager.class);\n\t\tfor (int i = 0; i < data.enemyData.size; i++)\n\t\t{\n\t\t\tSpawnSet s = data.enemyData.get(i);\n\t\t\tfor (int j = 0; j < s.spawns.size; j++)\n\t\t\t{\n\t\t\t\tSpawn enemy = s.spawns.get(j);\n\t\t\t\tEntity e = this.world.createEntity();\n\t\t\t\te = s.atlas.createEnemy(enemy.name, e);\n\t\t\t\tPosition p = (Position)e.getComponent(Position.CType);\n\t\t\t\tp.location.x = enemy.pos.x;\n\t\t\t\tp.location.y = enemy.pos.y;\n\t\t\t\tthis.world.addEntity(e);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < data.background.stack.size; i++)\n\t\t{\n\t\t\tEntity layer = this.world.createEntity();\n\t\t\tFieldData f = data.background.stack.get(i);\n\t\t\tTexture t = Engine.assets.get(f.image, Texture.class);\n\t\t\tSprite s = new Sprite(t);\n\t\t\tif (f instanceof LayerData)\n\t\t\t{\n\t\t\t\tLayerData d = (LayerData)data.background.stack.get(i);\n\t\t\t\tt.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);\n\t\t\t\ts.setSize(FOV[2], FOV[3]);\n\t\t\t\tlayer.addComponent(new Position(), Position.CType);\n\t\t\t\tlayer.addComponent(new Scrollable(0, d.rate, Math.max(FOV[2]/(float)t.getWidth(), 1.0f), Math.max(FOV[3]/(float)t.getHeight(), 1.0f)), Scrollable.CType);\n\t\t\t}\n\t\t\telse if (f instanceof StaticData)\n\t\t\t{\n\t\t\t\tStaticData d = (StaticData)data.background.stack.get(i);\n\t\t\t\tlayer.addComponent(new Position(d.x, d.y), Position.CType);\n\t\t\t\tlayer.addComponent(new Angle(0), Angle.CType);\n\t\t\t\tlayer.addComponent(new Rotation(d.dps), Rotation.CType);\n\t\t\t}\n\t\t\tlayer.addComponent(new Renderable(s), Renderable.CType);\n\t\t\tgm.add(layer, \"Field\");\n\t\t\tthis.world.addEntity(layer);\n\t\t}\n\t\tTexture t = Engine.assets.get(DataDir.Ui+\"banners.png\", Texture.class);\n\t\tt.setWrap(TextureWrap.Repeat, TextureWrap.ClampToEdge);\n\t\tSpriteSheet bannerTex = new SpriteSheet(t, 1, 3);\n\t\tfor (int i = 0; i < 3; i++)\n\t\t{\n\t\t\tEntity e = this.world.createEntity();\n\t\t\tTextureRegion r = bannerTex.getFrame(i);\n\t\t\tSprite s = new Sprite(r);\n\t\t\ts.setSize(FOV[3], 12);\n\t\t\ts.setRotation(90);\n\t\t\ts.setOrigin(0, 0);\n\t\t\te.addComponent(new Position(0, 0, 12, 0));\n\t\t\te.addComponent(new Scrollable(.35f, 0f, FOV[3]/bannerTex.getFrameWidth(), 1f, r));\n\t\t\te.addComponent(new Renderable(s));\n\t\t\tgm.add(e, \"Banner\");\n\t\t\tgm.add(e, \"Banner\"+(char)(i+65));\n\t\t\te.addToWorld();\n\t\t\te = this.world.createEntity();\n\t\t\ts = new Sprite(r);\n\t\t\ts.setSize(FOV[3], 12);\n\t\t\ts.setRotation(-90);\n\t\t\ts.setOrigin(0, 0);\n\t\t\ts.flip(false, true);\n\t\t\te.addComponent(new Position(FOV[2], 0, -12, FOV[3]));\n\t\t\te.addComponent(new Scrollable(-.35f, 0f, 220f/bannerTex.getFrameWidth(), 1f, r));\n\t\t\te.addComponent(new Renderable(s));\n\t\t\tgm.add(e, \"Banner\");\n\t\t\tgm.add(e, \"Banner\"+(char)(i+65));\n\t\t\te.addToWorld();\n\t\t}\n\t\tthis.world.initialize();\n\t\tEngine.score = 0f;\n\t\tPosition p = (Position)Engine.player.getComponent(Position.CType);\n\t\tp.location.x = FOV[2]/2.0f;\n\t}\n", "output": "\tpublic void start()\n\t{\n\t\tGroupManager gm = this.world.getManager(GroupManager.class);\n\t\tTagManager tm = this.world.getManager(TagManager.class);\n\t\tfor (int i = 0; i < data.enemyData.size; i++)\n\t\t{\n\t\t\tSpawnSet s = data.enemyData.get(i);\n\t\t\tfor (int j = 0; j < s.spawns.size; j++)\n\t\t\t{\n\t\t\t\tSpawn enemy = s.spawns.get(j);\n\t\t\t\tEntity e = this.world.createEntity();\n\t\t\t\te = s.atlas.createEnemy(enemy.name, e);\n\t\t\t\tPosition p = (Position)e.getComponent(Position.CType);\n\t\t\t\tp.location.x = enemy.pos.x;\n\t\t\t\tp.location.y = enemy.pos.y;\n\t\t\t\tthis.world.addEntity(e);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < data.background.stack.size; i++)\n\t\t{\n\t\t\tEntity layer = this.world.createEntity();\n\t\t\tFieldData f = data.background.stack.get(i);\n\t\t\tTexture t = Engine.assets.get(f.image, Texture.class);\n\t\t\tSprite s = new Sprite(t);\n\t\t\tif (f instanceof LayerData)\n\t\t\t{\n\t\t\t\tLayerData d = (LayerData)data.background.stack.get(i);\n\t\t\t\tt.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);\n\t\t\t\ts.setSize(Math.max(t.getWidth(), FOV[2]), Math.max(t.getHeight(),FOV[3]));\n\t\t\t\tlayer.addComponent(new Position(), Position.CType);\n\t\t\t\tlayer.addComponent(new Scrollable(0, d.rate, Math.max(FOV[2]/(float)t.getWidth(), 1.0f), Math.max(FOV[3]/(float)t.getHeight(), 1.0f)), Scrollable.CType);\n\t\t\t}\n\t\t\telse if (f instanceof StaticData)\n\t\t\t{\n\t\t\t\tStaticData d = (StaticData)data.background.stack.get(i);\n\t\t\t\tlayer.addComponent(new Position(d.x, d.y), Position.CType);\n\t\t\t\tlayer.addComponent(new Angle(0), Angle.CType);\n\t\t\t\tlayer.addComponent(new Rotation(d.dps), Rotation.CType);\n\t\t\t}\n\t\t\tlayer.addComponent(new Renderable(s), Renderable.CType);\n\t\t\tgm.add(layer, \"Field\");\n\t\t\tthis.world.addEntity(layer);\n\t\t}\n\t\tTexture t = Engine.assets.get(DataDir.Ui+\"banners.png\", Texture.class);\n\t\tt.setWrap(TextureWrap.Repeat, TextureWrap.ClampToEdge);\n\t\tSpriteSheet bannerTex = new SpriteSheet(t, 1, 3);\n\t\tfor (int i = 0; i < 3; i++)\n\t\t{\n\t\t\tEntity e = this.world.createEntity();\n\t\t\tTextureRegion r = bannerTex.getFrame(i);\n\t\t\tSprite s = new Sprite(r);\n\t\t\ts.setSize(FOV[3], 12);\n\t\t\ts.setRotation(90);\n\t\t\ts.setOrigin(0, 0);\n\t\t\te.addComponent(new Position(0, 0, 12, 0));\n\t\t\te.addComponent(new Scrollable(.35f, 0f, FOV[3]/bannerTex.getFrameWidth(), 1f, r));\n\t\t\te.addComponent(new Renderable(s));\n\t\t\tgm.add(e, \"Banner\");\n\t\t\tgm.add(e, \"Banner\"+(char)(i+65));\n\t\t\te.addToWorld();\n\t\t\te = this.world.createEntity();\n\t\t\ts = new Sprite(r);\n\t\t\ts.setSize(FOV[3], 12);\n\t\t\ts.setRotation(-90);\n\t\t\ts.setOrigin(0, 0);\n\t\t\ts.flip(false, true);\n\t\t\te.addComponent(new Position(FOV[2], 0, -12, FOV[3]));\n\t\t\te.addComponent(new Scrollable(-.35f, 0f, 220f/bannerTex.getFrameWidth(), 1f, r));\n\t\t\te.addComponent(new Renderable(s));\n\t\t\tgm.add(e, \"Banner\");\n\t\t\tgm.add(e, \"Banner\"+(char)(i+65));\n\t\t\te.addToWorld();\n\t\t}\n\t\tthis.world.initialize();\n\t\tEngine.score = 0f;\n\t\tPosition p = (Position)Engine.player.getComponent(Position.CType);\n\t\tp.location.x = FOV[2]/2.0f;\n\t}\n"} {"input": " public void event(final ScopeEvent event)\n {\n switch (event) {\n case ENTER:\n if (value != null) {\n MDC.put(MDC_TRACKING_KEY, value);\n }\n break;\n case LEAVE:\n MDC.remove(MDC_TRACKING_KEY);\n break;\n }\n }\n", "output": " public void event(final ScopeEvent event)\n {\n switch (event) {\n case ENTER:\n if (value != null) {\n MDC.put(MDC_TRACKING_KEY, value);\n }\n break;\n case LEAVE:\n MDC.remove(MDC_TRACKING_KEY);\n break;\n default:\n throw new IllegalStateException(\"Unknown Event: \" + event);\n }\n }\n"} {"input": "\tpublic void createPartControl(final Composite parent) {\n\t\tGridLayout mainLayout = new GridLayout();\n\t\tmainLayout.marginHeight = 0;\n\t\tmainLayout.marginWidth = 0;\n\t\tparent.setLayout(mainLayout);\n\t\tControl filterComposite = createFilterComposite(parent);\n\t\tfilterComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\t\tif (viewer != null && !viewer.getControl().isDisposed()) {\n\t\t\tviewer.getControl().dispose();\n\t\t}\n\t\tComposite resizer = new Composite(parent, SWT.NONE);\n\t\tresizer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));\n\t\tviewer = new TableViewer(resizer, SWT.MULTI);\n\t\tviewer.setUseHashlookup(true);\n\t\tviewer.setContentProvider(new ArrayContentProvider());\n\t\tcreateVehicleIdColumn();\n\t\tcreateDriverNameColumn();\n\t\tviewer.setLabelProvider(labelProvider);\n\t\tviewer.addFilter(viewerFilter);\n\t\tTable table = viewer.getTable();\n\t\tTableColumnLayout tableLayout = new TableColumnLayout();\n\t\ttableLayout.setColumnData(table.getColumn(COL_VEHICLE_ID), new ColumnWeightData(50));\n\t\ttableLayout.setColumnData(table.getColumn(COL_DRIVER_NAME), new ColumnWeightData(50));\n\t\tresizer.setLayout(tableLayout);\n\t\ttable.setHeaderVisible(true);\n\t\taddTableContextMenu(table);\n\t\tgetSite().setSelectionProvider(viewer);\n\t\tif (controlCenter != null)\n\t\t\tviewer.setInput(controlCenter.getVehicles());\n\t\tString message = \"Tue, Mar 24 2009, 7:21 am: \" + \" Vehicle: CA-SAN FRANCISCO-10 reports emergency at 37,7897, -122.3942\";\n\t\tIStatusLineManager statusLineMgr = getViewSite().getActionBars().getStatusLineManager();\n\t\tstatusLineMgr.setMessage(message);\n\t}\n", "output": "\tpublic void createPartControl(final Composite parent) {\n\t\tGridLayout mainLayout = new GridLayout();\n\t\tmainLayout.marginHeight = 0;\n\t\tmainLayout.marginWidth = 0;\n\t\tparent.setLayout(mainLayout);\n\t\tControl filterComposite = createFilterComposite(parent);\n\t\tfilterComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));\n\t\tif (viewer != null && !viewer.getControl().isDisposed()) {\n\t\t\tviewer.getControl().dispose();\n\t\t}\n\t\tComposite resizer = new Composite(parent, SWT.NONE);\n\t\tresizer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));\n\t\tviewer = new TableViewer(resizer, SWT.MULTI);\n\t\tviewer.setUseHashlookup(true);\n\t\tviewer.setContentProvider(new ArrayContentProvider());\n\t\tcreateVehicleIdColumn();\n\t\tcreateDriverNameColumn();\n\t\tviewer.setLabelProvider(labelProvider);\n\t\tviewer.addFilter(viewerFilter);\n\t\tTable table = viewer.getTable();\n\t\tTableColumnLayout tableLayout = new TableColumnLayout();\n\t\ttableLayout.setColumnData(table.getColumn(COL_VEHICLE_ID), new ColumnWeightData(50));\n\t\ttableLayout.setColumnData(table.getColumn(COL_DRIVER_NAME), new ColumnWeightData(50));\n\t\tresizer.setLayout(tableLayout);\n\t\ttable.setHeaderVisible(true);\n\t\taddTableContextMenu(table);\n\t\tgetSite().setSelectionProvider(viewer);\n\t\tif (controlCenter != null)\n\t\t\tviewer.setInput(controlCenter.getVehicles());\n\t\tString message = \"Tue, Oct 27 2009, 7:21 am: \" + \" Vehicle: CA-SAN FRANCISCO-10 reports emergency at 37,7897, -122.3942\";\n\t\tIStatusLineManager statusLineMgr = getViewSite().getActionBars().getStatusLineManager();\n\t\tstatusLineMgr.setMessage(message);\n\t}\n"} {"input": " private long handleInsertException(long originalEventId, ContentValues modValues,\n boolean callerIsSyncAdapter) {\n if (DEBUG_EXCEPTION) {\n Log.i(TAG, \"RE: values: \" + modValues.toString());\n }\n Long originalInstanceTime = modValues.getAsLong(Events.ORIGINAL_INSTANCE_TIME);\n if (originalInstanceTime == null) {\n throw new IllegalArgumentException(\"Exceptions must specify \" +\n Events.ORIGINAL_INSTANCE_TIME);\n }\n checkAllowedInException(modValues.keySet());\n if (!callerIsSyncAdapter) {\n modValues.put(Events.DIRTY, true);\n addMutator(modValues, Events.MUTATORS);\n }\n mDb.beginTransaction();\n Cursor cursor = null;\n try {\n cursor = mDb.query(Tables.EVENTS, null ,\n SQL_WHERE_ID, new String[] { String.valueOf(originalEventId) },\n null , null , null );\n if (cursor.getCount() != 1) {\n Log.e(TAG, \"Original event ID \" + originalEventId + \" lookup failed (count is \" +\n cursor.getCount() + \")\");\n return -1;\n }\n String color_index = modValues.getAsString(Events.EVENT_COLOR_KEY);\n if (!TextUtils.isEmpty(color_index)) {\n int calIdCol = cursor.getColumnIndex(Events.CALENDAR_ID);\n Long calId = cursor.getLong(calIdCol);\n String accountName = null;\n String accountType = null;\n if (calId != null) {\n Account account = getAccount(calId);\n if (account != null) {\n accountName = account.name;\n accountType = account.type;\n }\n }\n verifyColorExists(accountName, accountType, color_index, Colors.TYPE_EVENT);\n }\n cursor.moveToFirst();\n int rruleCol = cursor.getColumnIndex(Events.RRULE);\n if (TextUtils.isEmpty(cursor.getString(rruleCol))) {\n Log.e(TAG, \"Original event has no rrule\");\n return -1;\n }\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: old RRULE is \" + cursor.getString(rruleCol));\n }\n int originalIdCol = cursor.getColumnIndex(Events.ORIGINAL_ID);\n if (!TextUtils.isEmpty(cursor.getString(originalIdCol))) {\n Log.e(TAG, \"Original event is an exception\");\n return -1;\n }\n boolean createSingleException = TextUtils.isEmpty(modValues.getAsString(Events.RRULE));\n ContentValues values = new ContentValues();\n DatabaseUtils.cursorRowToContentValues(cursor, values);\n cursor.close();\n cursor = null;\n boolean createNewEvent = true;\n if (createSingleException) {\n String _id = values.getAsString(Events._ID);\n String _sync_id = values.getAsString(Events._SYNC_ID);\n boolean allDay = values.getAsBoolean(Events.ALL_DAY);\n for (String str : DONT_CLONE_INTO_EXCEPTION) {\n values.remove(str);\n }\n values.putAll(modValues);\n values.put(Events.ORIGINAL_ID, _id);\n values.put(Events.ORIGINAL_SYNC_ID, _sync_id);\n values.put(Events.ORIGINAL_ALL_DAY, allDay);\n if (!values.containsKey(Events.STATUS)) {\n values.put(Events.STATUS, Events.STATUS_TENTATIVE);\n }\n values.remove(Events.RRULE);\n Duration duration = new Duration();\n String durationStr = values.getAsString(Events.DURATION);\n try {\n duration.parse(durationStr);\n } catch (Exception ex) {\n Log.w(TAG, \"Bad duration in recurring event: \" + durationStr, ex);\n return -1;\n }\n long start;\n if (modValues.containsKey(Events.DTSTART)) {\n start = values.getAsLong(Events.DTSTART);\n } else {\n start = values.getAsLong(Events.ORIGINAL_INSTANCE_TIME);\n values.put(Events.DTSTART, start);\n }\n values.put(Events.DTEND, start + duration.getMillis());\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: ORIG_INST_TIME=\" + start +\n \", duration=\" + duration.getMillis() +\n \", generated DTEND=\" + values.getAsLong(Events.DTEND));\n }\n values.remove(Events.DURATION);\n } else {\n boolean canceling = (values.getAsInteger(Events.STATUS) == Events.STATUS_CANCELED);\n if (originalInstanceTime.equals(values.getAsLong(Events.DTSTART))) {\n if (canceling) {\n Log.d(TAG, \"Note: canceling entire event via exception call\");\n }\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: updating full event\");\n }\n if (!validateRecurrenceRule(modValues)) {\n throw new IllegalArgumentException(\"Invalid recurrence rule: \" +\n values.getAsString(Events.RRULE));\n }\n modValues.remove(Events.ORIGINAL_INSTANCE_TIME);\n mDb.update(Tables.EVENTS, modValues, SQL_WHERE_ID,\n new String[] { Long.toString(originalEventId) });\n createNewEvent = false; \n } else {\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: splitting event\");\n }\n ContentValues splitValues = setRecurrenceEnd(values, originalInstanceTime);\n mDb.update(Tables.EVENTS, splitValues, SQL_WHERE_ID,\n new String[] { Long.toString(originalEventId) });\n values.putAll(modValues);\n values.remove(Events.ORIGINAL_INSTANCE_TIME);\n }\n }\n long newEventId;\n if (createNewEvent) {\n values.remove(Events._ID); \n if (callerIsSyncAdapter) {\n scrubEventData(values, null);\n } else {\n validateEventData(values);\n }\n newEventId = mDb.insert(Tables.EVENTS, null, values);\n if (newEventId < 0) {\n Log.w(TAG, \"Unable to add exception to recurring event\");\n Log.w(TAG, \"Values: \" + values);\n return -1;\n }\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: new ID is \" + newEventId);\n }\n mInstancesHelper.updateInstancesLocked(values, newEventId, true, mDb);\n CalendarDatabaseHelper.copyEventRelatedTables(mDb, newEventId, originalEventId);\n if (modValues.containsKey(Events.SELF_ATTENDEE_STATUS)) {\n long calendarId = values.getAsLong(Events.CALENDAR_ID);\n String accountName = getOwner(calendarId);\n if (accountName != null) {\n ContentValues attValues = new ContentValues();\n attValues.put(Attendees.ATTENDEE_STATUS,\n modValues.getAsString(Events.SELF_ATTENDEE_STATUS));\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"Updating attendee status for event=\" + newEventId +\n \" name=\" + accountName + \" to \" +\n attValues.getAsString(Attendees.ATTENDEE_STATUS));\n }\n int count = mDb.update(Tables.ATTENDEES, attValues,\n Attendees.EVENT_ID + \"=? AND \" + Attendees.ATTENDEE_EMAIL + \"=?\",\n new String[] { String.valueOf(newEventId), accountName });\n if (count != 1 && count != 2) {\n Log.e(TAG, \"Attendee status update on event=\" + newEventId\n + \" touched \" + count + \" rows. Expected one or two rows.\");\n if (false) {\n Cursor debugCursor = mDb.query(Tables.ATTENDEES, null,\n Attendees.EVENT_ID + \"=? AND \" +\n Attendees.ATTENDEE_EMAIL + \"=?\",\n new String[] { String.valueOf(newEventId), accountName },\n null, null, null);\n DatabaseUtils.dumpCursor(debugCursor);\n if (debugCursor != null) {\n debugCursor.close();\n }\n }\n throw new RuntimeException(\"Status update WTF\");\n }\n }\n }\n } else {\n mInstancesHelper.updateInstancesLocked(values, originalEventId, false, mDb);\n newEventId = originalEventId;\n }\n mDb.setTransactionSuccessful();\n return newEventId;\n } finally {\n if (cursor != null) {\n cursor.close();\n }\n mDb.endTransaction();\n }\n }\n", "output": " private long handleInsertException(long originalEventId, ContentValues modValues,\n boolean callerIsSyncAdapter) {\n if (DEBUG_EXCEPTION) {\n Log.i(TAG, \"RE: values: \" + modValues.toString());\n }\n Long originalInstanceTime = modValues.getAsLong(Events.ORIGINAL_INSTANCE_TIME);\n if (originalInstanceTime == null) {\n throw new IllegalArgumentException(\"Exceptions must specify \" +\n Events.ORIGINAL_INSTANCE_TIME);\n }\n checkAllowedInException(modValues.keySet());\n if (!callerIsSyncAdapter) {\n modValues.put(Events.DIRTY, true);\n addMutator(modValues, Events.MUTATORS);\n }\n mDb.beginTransaction();\n Cursor cursor = null;\n try {\n cursor = mDb.query(Tables.EVENTS, null ,\n SQL_WHERE_ID, new String[] { String.valueOf(originalEventId) },\n null , null , null );\n if (cursor.getCount() != 1) {\n Log.e(TAG, \"Original event ID \" + originalEventId + \" lookup failed (count is \" +\n cursor.getCount() + \")\");\n return -1;\n }\n String color_index = modValues.getAsString(Events.EVENT_COLOR_KEY);\n if (!TextUtils.isEmpty(color_index)) {\n int calIdCol = cursor.getColumnIndex(Events.CALENDAR_ID);\n Long calId = cursor.getLong(calIdCol);\n String accountName = null;\n String accountType = null;\n if (calId != null) {\n Account account = getAccount(calId);\n if (account != null) {\n accountName = account.name;\n accountType = account.type;\n }\n }\n verifyColorExists(accountName, accountType, color_index, Colors.TYPE_EVENT);\n }\n cursor.moveToFirst();\n int rruleCol = cursor.getColumnIndex(Events.RRULE);\n if (TextUtils.isEmpty(cursor.getString(rruleCol))) {\n Log.e(TAG, \"Original event has no rrule\");\n return -1;\n }\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: old RRULE is \" + cursor.getString(rruleCol));\n }\n int originalIdCol = cursor.getColumnIndex(Events.ORIGINAL_ID);\n if (!TextUtils.isEmpty(cursor.getString(originalIdCol))) {\n Log.e(TAG, \"Original event is an exception\");\n return -1;\n }\n boolean createSingleException = TextUtils.isEmpty(modValues.getAsString(Events.RRULE));\n ContentValues values = new ContentValues();\n DatabaseUtils.cursorRowToContentValues(cursor, values);\n cursor.close();\n cursor = null;\n boolean createNewEvent = true;\n if (createSingleException) {\n String _id = values.getAsString(Events._ID);\n String _sync_id = values.getAsString(Events._SYNC_ID);\n boolean allDay = values.getAsBoolean(Events.ALL_DAY);\n for (String str : DONT_CLONE_INTO_EXCEPTION) {\n values.remove(str);\n }\n values.putAll(modValues);\n values.put(Events.ORIGINAL_ID, _id);\n values.put(Events.ORIGINAL_SYNC_ID, _sync_id);\n values.put(Events.ORIGINAL_ALL_DAY, allDay);\n if (!values.containsKey(Events.STATUS)) {\n values.put(Events.STATUS, Events.STATUS_TENTATIVE);\n }\n values.remove(Events.RRULE);\n values.remove(Events.RDATE);\n values.remove(Events.EXRULE);\n values.remove(Events.EXDATE);\n Duration duration = new Duration();\n String durationStr = values.getAsString(Events.DURATION);\n try {\n duration.parse(durationStr);\n } catch (Exception ex) {\n Log.w(TAG, \"Bad duration in recurring event: \" + durationStr, ex);\n return -1;\n }\n long start;\n if (modValues.containsKey(Events.DTSTART)) {\n start = values.getAsLong(Events.DTSTART);\n } else {\n start = values.getAsLong(Events.ORIGINAL_INSTANCE_TIME);\n values.put(Events.DTSTART, start);\n }\n values.put(Events.DTEND, start + duration.getMillis());\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: ORIG_INST_TIME=\" + start +\n \", duration=\" + duration.getMillis() +\n \", generated DTEND=\" + values.getAsLong(Events.DTEND));\n }\n values.remove(Events.DURATION);\n } else {\n boolean canceling = (values.getAsInteger(Events.STATUS) == Events.STATUS_CANCELED);\n if (originalInstanceTime.equals(values.getAsLong(Events.DTSTART))) {\n if (canceling) {\n Log.d(TAG, \"Note: canceling entire event via exception call\");\n }\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: updating full event\");\n }\n if (!validateRecurrenceRule(modValues)) {\n throw new IllegalArgumentException(\"Invalid recurrence rule: \" +\n values.getAsString(Events.RRULE));\n }\n modValues.remove(Events.ORIGINAL_INSTANCE_TIME);\n mDb.update(Tables.EVENTS, modValues, SQL_WHERE_ID,\n new String[] { Long.toString(originalEventId) });\n createNewEvent = false; \n } else {\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: splitting event\");\n }\n ContentValues splitValues = setRecurrenceEnd(values, originalInstanceTime);\n mDb.update(Tables.EVENTS, splitValues, SQL_WHERE_ID,\n new String[] { Long.toString(originalEventId) });\n values.putAll(modValues);\n values.remove(Events.ORIGINAL_INSTANCE_TIME);\n }\n }\n long newEventId;\n if (createNewEvent) {\n values.remove(Events._ID); \n if (callerIsSyncAdapter) {\n scrubEventData(values, null);\n } else {\n validateEventData(values);\n }\n newEventId = mDb.insert(Tables.EVENTS, null, values);\n if (newEventId < 0) {\n Log.w(TAG, \"Unable to add exception to recurring event\");\n Log.w(TAG, \"Values: \" + values);\n return -1;\n }\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"RE: new ID is \" + newEventId);\n }\n mInstancesHelper.updateInstancesLocked(values, newEventId, true, mDb);\n CalendarDatabaseHelper.copyEventRelatedTables(mDb, newEventId, originalEventId);\n if (modValues.containsKey(Events.SELF_ATTENDEE_STATUS)) {\n long calendarId = values.getAsLong(Events.CALENDAR_ID);\n String accountName = getOwner(calendarId);\n if (accountName != null) {\n ContentValues attValues = new ContentValues();\n attValues.put(Attendees.ATTENDEE_STATUS,\n modValues.getAsString(Events.SELF_ATTENDEE_STATUS));\n if (DEBUG_EXCEPTION) {\n Log.d(TAG, \"Updating attendee status for event=\" + newEventId +\n \" name=\" + accountName + \" to \" +\n attValues.getAsString(Attendees.ATTENDEE_STATUS));\n }\n int count = mDb.update(Tables.ATTENDEES, attValues,\n Attendees.EVENT_ID + \"=? AND \" + Attendees.ATTENDEE_EMAIL + \"=?\",\n new String[] { String.valueOf(newEventId), accountName });\n if (count != 1 && count != 2) {\n Log.e(TAG, \"Attendee status update on event=\" + newEventId\n + \" touched \" + count + \" rows. Expected one or two rows.\");\n if (false) {\n Cursor debugCursor = mDb.query(Tables.ATTENDEES, null,\n Attendees.EVENT_ID + \"=? AND \" +\n Attendees.ATTENDEE_EMAIL + \"=?\",\n new String[] { String.valueOf(newEventId), accountName },\n null, null, null);\n DatabaseUtils.dumpCursor(debugCursor);\n if (debugCursor != null) {\n debugCursor.close();\n }\n }\n throw new RuntimeException(\"Status update WTF\");\n }\n }\n }\n } else {\n mInstancesHelper.updateInstancesLocked(values, originalEventId, false, mDb);\n newEventId = originalEventId;\n }\n mDb.setTransactionSuccessful();\n return newEventId;\n } finally {\n if (cursor != null) {\n cursor.close();\n }\n mDb.endTransaction();\n }\n }\n"} {"input": " static public User getUser(HttpServletRequest request) {\n String accessToken = request.getParameter(\"access_token\");\n if (accessToken == null) {\n return null;\n } else {\n try {\n URL url = new URL(\n \"https://www.googleapis.com/oauth2/v1/tokeninfo\"\n + \"?access_token=\" + accessToken);\n Map<String, String> userData = mapper.readValue(\n new InputStreamReader(url.openStream(), \"UTF-8\"),\n new TypeReference<Map<String, String>>() {\n });\n if (userData.get(\"audience\") == null\n || userData.containsKey(\"error\")\n || !userData.get(\"audience\")\n .equals(Constants.CLIENT_ID)) {\n return null;\n } else {\n String email = userData.get(\"email\"),\n userId = userData.get(\"user_id\");\n User user;\n PersistenceManager pm = PMF.get().getPersistenceManager();\n try {\n user = pm.getObjectById(User.class, email);\n } catch (JDOObjectNotFoundException ex) {\n user = new User(email, userId);\n pm.makePersistent(user);\n } finally {\n pm.close();\n }\n return user;\n }\n } catch (Exception ex) {\n return null;\n }\n }\n }\n", "output": " static public User getUser(HttpServletRequest request) {\n String accessToken = request.getParameter(\"access_token\");\n if (accessToken == null) {\n return null;\n } else {\n try {\n URL url = new URL(\n \"https://www.googleapis.com/oauth2/v1/tokeninfo\"\n + \"?access_token=\" + accessToken);\n Map<String, String> userData = mapper.readValue(\n new InputStreamReader(url.openStream(), \"UTF-8\"),\n new TypeReference<Map<String, String>>() {\n });\n if (userData.get(\"audience\") == null\n || userData.containsKey(\"error\")\n || !userData.get(\"audience\")\n .equals(Constants.CLIENT_ID)) {\n return null;\n } else {\n String email = userData.get(\"email\"),\n userId = userData.get(\"user_id\");\n User user;\n PersistenceManager pm = PMF.get().getPersistenceManager();\n try {\n user = pm.getObjectById(User.class, email);\n } catch (JDOObjectNotFoundException ex) {\n user = new User(userId, email);\n pm.makePersistent(user);\n } finally {\n pm.close();\n }\n return user;\n }\n } catch (Exception ex) {\n return null;\n }\n }\n }\n"} {"input": " public void execute(Event<UIGroupEditMembershipForm> event) throws Exception {\n UIGroupEditMembershipForm uiForm = event.getSource();\n UIApplication uiApp = event.getRequestContext().getUIApplication() ;\n OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);\n User user = service.getUserHandler().findUserByName(uiForm.membership.getUserName()) ;\n MembershipHandler memberShipHandler = service.getMembershipHandler();\n String memberShipType = uiForm.getUIFormSelectBox(MEMBER_SHIP).getValue();\n MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(memberShipType);\n try {\n memberShipHandler.removeMembership(uiForm.membership.getId(), true);\n memberShipHandler.linkMembership(user,uiForm.group,membershipType,true);\n } catch (Exception e) {\n uiApp.addMessage(new ApplicationMessage(\"UIGroupEditMembershipForm.msg.membership-delete\", null)) ;\n }\n UIPopupWindow uiPopup = uiForm.getParent();\n uiPopup.setUIComponent(null);\n uiPopup.setShow(false);\n }\n", "output": " public void execute(Event<UIGroupEditMembershipForm> event) throws Exception {\n UIGroupEditMembershipForm uiForm = event.getSource();\n UIApplication uiApp = event.getRequestContext().getUIApplication() ;\n UIPopupWindow uiPopup = uiForm.getParent();\n OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);\n String userName = uiForm.membership.getUserName();\n Group group = uiForm.group;\n User user = service.getUserHandler().findUserByName(userName) ;\n MembershipHandler memberShipHandler = service.getMembershipHandler();\n String memberShipType = uiForm.getUIFormSelectBox(MEMBER_SHIP).getValue();\n MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(memberShipType);\n Membership membership = memberShipHandler.findMembershipByUserGroupAndType(userName, group.getId(), membershipType.getName());\n if(membership != null){\n uiApp.addMessage(new ApplicationMessage(\"UIGroupEditMembershipForm.msg.membership-exist\", null)) ;\n return ;\n }\n try {\n memberShipHandler.removeMembership(uiForm.membership.getId(), true);\n memberShipHandler.linkMembership(user,group,membershipType,true);\n } catch (Exception e) {\n uiApp.addMessage(new ApplicationMessage(\"UIGroupEditMembershipForm.msg.membership-delete\", null)) ;\n }\n uiPopup.setUIComponent(null);\n uiPopup.setShow(false);\n }\n"} {"input": " public void paintBorder(ICanvas _g, int _x, int _y, int _w, int _h) {\n super.paintBorder(_g, _x, _y, _w, _h);\n if (operable) {\n AColor c = barColor;\n if (alignY > -1 && view.getH() > getH() && !paintYResizing) {\n _g.setColor(barColor);\n XYWH_I r = panY();\n c = barColor;\n _g.paintFlavor(flavor, _x + r.x + r.w, _y + r.y, resize, r.h, c);\n if (scrollingY || paintYScrollbar) {\n c = ViewColor.cThemeAccent;\n _g.paintFlavor(flavor, _x + r.x, _y + r.y, r.w + resize, r.h, c);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.line(_x + r.x + 3, _y + r.y + (r.h / 2) - 2, _x + r.x + r.w + resize - 6, _y + r.y + (r.h / 2) - 2);\n _g.line(_x + r.x + 3, _y + r.y + (r.h / 2), _x + r.x + r.w + resize - 6, _y + r.y + (r.h / 2));\n _g.line(_x + r.x + 3, _y + r.y + (r.h / 2) + 2, _x + r.x + r.w + resize - 6, _y + r.y + (r.h / 2) + 2);\n }\n }\n if (alignX > -1 && view.getW() > getW() && !paintXResizing) {\n _g.setColor(barColor);\n XYWH_I r = panX();\n c = barColor;\n _g.paintFlavor(flavor, _x + r.x, _y + r.y + r.h, r.w, resize, c);\n if (scrollingX || paintXScrollbar) {\n c = ViewColor.cThemeAccent;\n _g.paintFlavor(flavor, _x + r.x, _y + r.y, r.w, r.h + resize, c);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.line(_x + r.x + (r.w / 2) - 2, _y + r.y + 3, _x + r.x + (r.w / 2) - 2, _y + r.y + r.h + resize - 6);\n _g.line(_x + r.x + (r.w / 2), _y + r.y + 3, _x + r.x + (r.w / 2), _y + r.y + r.h + resize - 6);\n _g.line(_x + r.x + (r.w / 2) + 2, _y + r.y + 3, _x + r.x + (r.w / 2) + 2, _y + r.y + r.h + resize - 6);\n }\n }\n if (resizeable) {\n Polygon p = new Polygon();\n p.addPoint(_x + _w - resize, _y + _h - resize);\n p.addPoint(_x + _w - resize, _y + _h - scrollBarSize);\n p.addPoint(_x + _w, _y + _h - scrollBarSize);\n p.addPoint(_x + _w, _y + _h);\n p.addPoint(_x + _w - scrollBarSize, _y + _h);\n p.addPoint(_x + _w - scrollBarSize, _y + _h - resize);\n p.addPoint(_x + _w - resize, _y + _h - resize);\n _g.setColor(ViewColor.cThemeAccent);\n _g.polygon(true, p.xpoints, p.ypoints, p.npoints);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.polygon(false, p.xpoints, p.ypoints, p.npoints);\n }\n XYWH_I rx = resizeX();\n XYWH_I ry = resizeY();\n c = barColor;\n if (paintXResizing) {\n Polygon p = new Polygon();\n p.addPoint(rx.x + (rx.w / 2), rx.y + rx.h - 30);\n p.addPoint(rx.x + (rx.w / 2) - 8, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2) - 1, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2) - 1, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) - 8, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) - 1, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) - 10, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) - 10, rx.y + rx.h);\n p.addPoint(rx.x + (rx.w / 2) + 10, rx.y + rx.h);\n p.addPoint(rx.x + (rx.w / 2) + 10, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) + 1, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) + 8, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) + 1, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) + 1, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2) + 8, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2), rx.y + rx.h - 30);\n _g.setColor(ViewColor.cThemeAccent);\n _g.polygon(true, p.xpoints, p.ypoints, p.npoints);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.polygon(false, p.xpoints, p.ypoints, p.npoints);\n }\n c = barColor;\n if (paintYResizing) {\n Polygon p = new Polygon();\n p.addPoint(ry.x + ry.w - 30, ry.y + (ry.h / 2));\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) - 8);\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) - 1);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) - 1);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) - 8);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) - 1);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) - 10);\n p.addPoint(ry.x + ry.w, ry.y + (ry.h / 2) - 10);\n p.addPoint(ry.x + ry.w, ry.y + (ry.h / 2) + 10);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) + 10);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) + 1);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) + 8);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) + 1);\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) + 1);\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) + 8);\n p.addPoint(ry.x + ry.w - 30, ry.y + (ry.h / 2));\n _g.setColor(ViewColor.cThemeAccent);\n _g.polygon(true, p.xpoints, p.ypoints, p.npoints);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.polygon(false, p.xpoints, p.ypoints, p.npoints);\n }\n }\n }\n public XYWH_I incUp() {\n XYWH_I p = panX();\n return new XYWH_I(p.x, p.y, p.w, p.h / 2);\n }\n public XYWH_I incDown() {\n XYWH_I p = panX();\n return new XYWH_I(p.x, p.y + (p.h / 2), p.w, p.h / 2);\n }\n public XYWH_I incRight() {\n XYWH_I p = panY();\n return new XYWH_I(p.x + (p.w / 2), p.y, p.w / 2, p.h);\n }\n public XYWH_I incLeft() {\n XYWH_I p = panY();\n return new XYWH_I(p.x, p.y, p.w / 2, p.h);\n }\n public XYWH_I resizeY() {\n return new XYWH_I((int) (getW() - resize), 0, resize, getH());\n }\n public XYWH_I resizeX() {\n return new XYWH_I(0, (int) (getH() - resize), getW(), resize);\n }\n public XYWH_I panX() {\n int r = resize;\n if (alignY < 0) {\n r = 0;\n }\n float _w = getW() - r;\n int _x = (int) (alignX * _w);\n int pw = 0;\n if (wSlack != 0) {\n pw = (int) ((_w / (_w + wSlack)) * _w);\n }\n if (pw < scrollBarSize) {\n pw = scrollBarSize;\n }\n return new XYWH_I((int) (_x - (pw * alignX)), (int) (getH() - (scrollBarSize + r)), pw, scrollBarSize);\n }\n public XYWH_I panY() {\n int r = resize;\n if (alignX < 0) {\n r = 0;\n }\n float _h = getH() - r;\n int _y = (int) (alignY * _h);\n int ph = 0;\n if (hSlack != 0) {\n ph = (int) ((_h / (_h + hSlack)) * _h);\n }\n if (ph < scrollBarSize) {\n ph = scrollBarSize;\n }\n return new XYWH_I((int) (getW() - (scrollBarSize + r)), (int) (_y - (ph * alignY)), scrollBarSize, ph);\n }\n @Override\n public void paintBackground(ICanvas _g, int _x, int _y, int _w, int _h) {\n if (maxWBeforePan > -1 && maxWBeforePan > view.getW()) {\n w = view.getW();\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n } else if (maxWBeforePan > -1 && alignX < 0) {\n w = maxWBeforePan;\n alignX = 0;\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n }\n if (maxHBeforePan > -1 && maxHBeforePan > view.getH()) {\n h = view.getH();\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n } else if (maxHBeforePan > -1 && alignY < 0) {\n h = maxHBeforePan;\n alignY = 0;\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n }\n super.paintBackground(_g, _x, _y, _w, _h);\n }\n @Override\n public IView disbatchEvent(IView parent, AViewEvent event) {\n if (isPanEvent(event) || scrollingX || scrollingY || resizingX || resizingY) {\n return this;\n }\n if (event instanceof MouseMoved) {\n XY_I p = ((MouseMoved) event).getPoint();\n if ((alignX > -1 && panX().contains(p)) || (alignY > -1 && panY().contains(p))) {\n if (!mouseIsDown) {\n setPaintingScrollBars(p, isPanEvent(event));\n }\n return this;\n } else if ((p.x > getW() - resize) || (p.y > getH() - resize)) {\n if (!mouseIsDown) {\n setPaintingScrollBars(p, isPanEvent(event));\n }\n return this;\n } else if ((p.x > getW() - scrollBarSize) && (p.y > getH() - scrollBarSize)) {\n if (!mouseIsDown) {\n setPaintingScrollBars(p, isPanEvent(event));\n }\n return this;\n } else {\n paintXScrollbar = false;\n paintYScrollbar = false;\n paintXResizing = false;\n paintYResizing = false;\n return super.disbatchEvent(parent, event);\n }\n } else if (event instanceof MousePressed) {\n XY_I p = ((MousePressed) event).getPoint();\n setModePoint(p, isPanEvent(event));\n if ((alignX > -1 && panX().contains(p)) || (alignY > -1 && panY().contains(p))) {\n setPan(false);\n return this;\n } else if ((p.x > getW() - resize) || (p.y > getH() - resize)) {\n setPan(false);\n return this;\n } else if ((p.x > getW() - scrollBarSize) && (p.y > getH() - scrollBarSize)) {\n setPan(false);\n return this;\n }\n if (scrollingX || scrollingY || resizingX || resizingY) {\n return this;\n } else {\n return super.disbatchEvent(parent, event);\n }\n } else if (event instanceof MouseReleased) {\n XY_I p = ((MouseReleased) event).getPoint();\n setModePoint(p, isPanEvent(event));\n if ((alignX > -1 && panX().contains(p)) || (alignY > -1 && panY().contains(p))) {\n setPan(false);\n return this;\n } else if ((p.x > getW() - resize) || (p.y > getH() - resize)) {\n setPan(false);\n return this;\n }\n if (scrollingX || scrollingY || resizingX || resizingY) {\n return this;\n } else {\n return super.disbatchEvent(parent, event);\n }\n } else if (event instanceof MouseExited) {\n if (!mouseIsDown) {\n XY_I p = ((MouseReleased) event).getPoint();\n setModePoint(p, isPanEvent(event));\n }\n return super.disbatchEvent(parent, event);\n } else {\n return super.disbatchEvent(parent, event);\n }\n }\n boolean isPanEvent(IEvent event) {\n if (event instanceof AInputEvent) {\n boolean isPanEvent = (((AInputEvent) event).isShiftDown() && ((AInputEvent) event).isControlDown());\n if (isPanEvent) {\n return isPanEvent;\n }\n }\n lmp = null;\n return false;\n }\n @Override\n public void mouseWheel(MouseWheel _e) {\n int rotation = _e.getWheelRotation();\n if (_e.isShiftDown()) {\n if (rotation < 0) {\n for (int i = rotation; i < 0; i++) {\n incRightScroll();\n }\n } else {\n for (int i = 0; i < rotation; i++) {\n incLeftScroll();\n }\n }\n } else {\n if (rotation < 0) {\n for (int i = rotation; i < 0; i++) {\n incUpScroll();\n }\n } else {\n for (int i = 0; i < rotation; i++) {\n incDownScroll();\n }\n }\n }\n }\n protected void incUpScroll() {\n float p = getAlignY() - (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 0.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignY() - (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 0.0f));\n }\n }\n }.start();\n }\n protected void incDownScroll() {\n float p = getAlignY() + (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 1.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignY() + (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 1.0f));\n }\n }\n }.start();\n }\n protected void incLeftScroll() {\n float p = getAlignX() - (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 0.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignX() - (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 0.0f));\n }\n }\n }.start();\n }\n protected void incRightScroll() {\n float p = getAlignX() + (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 1.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignX() + (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 1.0f));\n }\n }\n }.start();\n }\n public void setPositionX(float _position) {\n if (_position < 0.0f) {\n _position = 0.0f;\n }\n if (_position > 1.0f) {\n _position = 1.0f;\n }\n setAlignX(_position, this);\n paint();\n }\n public void setPositionY(float _position) {\n if (_position < 0.0f) {\n _position = 0.0f;\n }\n if (_position > 1.0f) {\n _position = 1.0f;\n }\n setAlignY(_position, this);\n paint();\n }\n public float getPositionX() {\n return getAlignX();\n }\n public float getPositionY() {\n return getAlignY();\n }\n public void setPan(boolean _pan) {\n }\n boolean mouseIsDown = false;\n @Override\n public void mouseEntered(MouseEntered _e) {\n DragAndDrop.cDefault.mouseEntered(_e);\n mouseIsDown = false;\n }\n @Override\n public void mouseExited(MouseExited _e) {\n DragAndDrop.cDefault.mouseExited(_e);\n mouseIsDown = false;\n }\n public void setModePoint(XY_I _p, boolean _panXY) {\n if (_panXY) {\n scrollingX = true;\n scrollingY = true;\n } else if (resizeable && (_p.x < getW() && _p.y < getH()) && (_p.x > getW() - scrollBarSize && _p.y > getH() - scrollBarSize)) {\n resizingX = true;\n resizingY = true;\n scrollingX = false;\n scrollingY = false;\n } else if (resizeable && resizeY().contains(_p)) {\n resizingX = true;\n resizingY = false;\n scrollingX = false;\n scrollingY = false;\n } else if (resizeable && resizeX().contains(_p)) {\n resizingX = false;\n resizingY = true;\n scrollingX = false;\n scrollingY = false;\n } else if (panY().contains(_p) || incRight().contains(_p) || incLeft().contains(_p)) {\n resizingX = false;\n resizingY = false;\n scrollingX = false;\n scrollingY = true;\n } else if (panX().contains(_p) || incUp().contains(_p) || incDown().contains(_p)) {\n resizingX = false;\n resizingY = false;\n scrollingX = true;\n scrollingY = false;\n } else {\n resizingX = false;\n resizingY = false;\n scrollingX = false;\n scrollingY = false;\n }\n }\n WH_F mpwh = new WH_F();\n float mpxp = 0f;\n float mpyp = 0f;\n @Override\n public void mousePressed(MousePressed _e) {\n if (_e.getClickCount() > 0) {\n DragAndDrop.cDefault.mousePressed(_e);\n }\n mpwh = new WH_F(getW(), getH());\n mpxp = getPositionX();\n mpyp = getPositionY();\n mouseIsDown = true;\n }\n @Override\n public void mouseReleased(MouseReleased _e) {\n setModePoint(_e.getPoint(), isPanEvent(_e));\n if (incDown().contains(_e.getPoint())) {\n incDownScroll();\n }\n if (incLeft().contains(_e.getPoint())) {\n incLeftScroll();\n }\n if (incRight().contains(_e.getPoint())) {\n incRight();\n }\n if (incUp().contains(_e.getPoint())) {\n incUpScroll();\n }\n mouseIsDown = false;\n drug = false;\n PickupAndDrop.cDefault.event(_e);\n if (_e.getClickCount() > 0) {\n DragAndDrop.cDefault.mouseReleased(_e);\n }\n resizingX = false;\n resizingY = false;\n scrollingX = false;\n scrollingY = false;\n lmp = null;\n }\n public void setPaintingScrollBars(XY_I _p, boolean _pan) {\n if (mouseIsDown) {\n return;\n }\n if (resizeX().contains(_p)) {\n paintXResizing = true;\n paint();\n return;\n } else {\n paintXResizing = false;\n }\n if (resizeY().contains(_p)) {\n paintYResizing = true;\n paint();\n return;\n } else {\n paintYResizing = false;\n }\n if (panY().contains(_p) || _pan) {\n if (paintYScrollbar); else {\n getRootView().setMouseWheelFocus(0, this);\n paintYScrollbar = true;\n paint();\n }\n } else {\n paintYScrollbar = false;\n paint();\n }\n if (panX().contains(_p) || _pan) {\n if (paintXScrollbar); else {\n getRootView().setMouseWheelFocus(0, this);\n paintXScrollbar = true;\n paint();\n }\n } else {\n paintXScrollbar = false;\n paint();\n }\n }\n XY_I lmp = null;\n @Override\n public void mouseMoved(MouseMoved _e) {\n if (mouseIsDown) {\n return;\n }\n XY_I p = _e.getPoint();\n setPaintingScrollBars(p, isPanEvent(_e));\n if (isPanEvent(_e)) {\n if (lmp == null) {\n lmp = _e.getPoint();\n return;\n }\n XY_I mp = _e.getPoint();\n float yrate = (lmp.y - mp.y) / (getH() / 2);\n setPositionY(getPositionY() - yrate);\n float xrate = (lmp.x - mp.x) / (getW() / 2);\n setPositionX(getPositionX() - xrate);\n lmp = mp;\n }\n }\n boolean drug = false;\n @Override\n public void mouseDragged(MouseDragged _e) {\n DragAndDrop.cDefault.mouseDragged(_e);\n if (!operable) {\n return;\n }\n drug = true;\n if (resizeable && (resizingX || resizingY)) {\n if (fixedW == -1 && resizingX) {\n w = mpwh.w + _e.getSumDeltaX();\n }\n if (fixedH == -1 && resizingY) {\n h = mpwh.h + _e.getSumDeltaY();\n }\n layoutInterior();\n parent.layoutInterior();\n parent.paint();\n }\n if (scrollingY) {\n float s = getH() - resize;\n int p = 0;\n if (hSlack != 0) {\n p = (int) ((s / (s + hSlack)) * s);\n }\n double delta = _e.getSumDeltaY() / (s - p);\n setPositionY((float) UDouble.clamp(mpyp + delta, 0, 1));\n }\n if (scrollingX) {\n float s = getW() - resize;\n int p = 0;\n if (wSlack != 0) {\n p = (int) ((s / (s + wSlack)) * s);\n }\n double delta = _e.getSumDeltaX() / (s - p);\n setPositionX((float) UDouble.clamp(mpxp + delta, 0, 1));\n }\n }\n @Override\n public IDropMode accepts(Object value, AInputEvent _e) {\n if (dropCallback == null) {\n return null;\n }\n return (IDropMode) dropCallback.callback(new Object[]{value, _e});\n }\n @Override\n public void dropParcel(final Object value, final IDropMode mode) {\n if (droppedCallback == null) {\n return;\n }\n new Thread() {\n @Override\n public void run() {\n droppedCallback.callback(new Object[]{value, mode});\n }\n }.start();\n }\n}\n", "output": " public void paintBorder(ICanvas _g, int _x, int _y, int _w, int _h) {\n super.paintBorder(_g, _x, _y, _w, _h);\n if (operable) {\n AColor c = barColor;\n if (alignY > -1 && view.getH() > getH() && !paintYResizing) {\n _g.setColor(barColor);\n XYWH_I r = panY();\n c = barColor;\n _g.paintFlavor(flavor, _x + r.x + r.w, _y + r.y, resize, r.h, c);\n if (scrollingY || paintYScrollbar) {\n c = ViewColor.cThemeAccent;\n _g.paintFlavor(flavor, _x + r.x, _y + r.y, r.w + resize, r.h, c);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.line(_x + r.x + 3, _y + r.y + (r.h / 2) - 2, _x + r.x + r.w + resize - 6, _y + r.y + (r.h / 2) - 2);\n _g.line(_x + r.x + 3, _y + r.y + (r.h / 2), _x + r.x + r.w + resize - 6, _y + r.y + (r.h / 2));\n _g.line(_x + r.x + 3, _y + r.y + (r.h / 2) + 2, _x + r.x + r.w + resize - 6, _y + r.y + (r.h / 2) + 2);\n }\n }\n if (alignX > -1 && view.getW() > getW() && !paintXResizing) {\n _g.setColor(barColor);\n XYWH_I r = panX();\n c = barColor;\n _g.paintFlavor(flavor, _x + r.x, _y + r.y + r.h, r.w, resize, c);\n if (scrollingX || paintXScrollbar) {\n c = ViewColor.cThemeAccent;\n _g.paintFlavor(flavor, _x + r.x, _y + r.y, r.w, r.h + resize, c);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.line(_x + r.x + (r.w / 2) - 2, _y + r.y + 3, _x + r.x + (r.w / 2) - 2, _y + r.y + r.h + resize - 6);\n _g.line(_x + r.x + (r.w / 2), _y + r.y + 3, _x + r.x + (r.w / 2), _y + r.y + r.h + resize - 6);\n _g.line(_x + r.x + (r.w / 2) + 2, _y + r.y + 3, _x + r.x + (r.w / 2) + 2, _y + r.y + r.h + resize - 6);\n }\n }\n if (resizeable) {\n Polygon p = new Polygon();\n p.addPoint(_x + _w - resize, _y + _h - resize);\n p.addPoint(_x + _w - resize, _y + _h - scrollBarSize);\n p.addPoint(_x + _w, _y + _h - scrollBarSize);\n p.addPoint(_x + _w, _y + _h);\n p.addPoint(_x + _w - scrollBarSize, _y + _h);\n p.addPoint(_x + _w - scrollBarSize, _y + _h - resize);\n p.addPoint(_x + _w - resize, _y + _h - resize);\n _g.setColor(ViewColor.cThemeAccent);\n _g.polygon(true, p.xpoints, p.ypoints, p.npoints);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.polygon(false, p.xpoints, p.ypoints, p.npoints);\n }\n XYWH_I rx = resizeX();\n XYWH_I ry = resizeY();\n c = barColor;\n if (paintXResizing) {\n Polygon p = new Polygon();\n p.addPoint(rx.x + (rx.w / 2), rx.y + rx.h - 30);\n p.addPoint(rx.x + (rx.w / 2) - 8, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2) - 1, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2) - 1, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) - 8, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) - 1, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) - 10, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) - 10, rx.y + rx.h);\n p.addPoint(rx.x + (rx.w / 2) + 10, rx.y + rx.h);\n p.addPoint(rx.x + (rx.w / 2) + 10, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) + 1, rx.y + rx.h - 4);\n p.addPoint(rx.x + (rx.w / 2) + 8, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) + 1, rx.y + rx.h - 14);\n p.addPoint(rx.x + (rx.w / 2) + 1, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2) + 8, rx.y + rx.h - 20);\n p.addPoint(rx.x + (rx.w / 2), rx.y + rx.h - 30);\n _g.setColor(ViewColor.cThemeAccent);\n _g.polygon(true, p.xpoints, p.ypoints, p.npoints);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.polygon(false, p.xpoints, p.ypoints, p.npoints);\n }\n c = barColor;\n if (paintYResizing) {\n Polygon p = new Polygon();\n p.addPoint(ry.x + ry.w - 30, ry.y + (ry.h / 2));\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) - 8);\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) - 1);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) - 1);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) - 8);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) - 1);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) - 10);\n p.addPoint(ry.x + ry.w, ry.y + (ry.h / 2) - 10);\n p.addPoint(ry.x + ry.w, ry.y + (ry.h / 2) + 10);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) + 10);\n p.addPoint(ry.x + ry.w - 4, ry.y + (ry.h / 2) + 1);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) + 8);\n p.addPoint(ry.x + ry.w - 14, ry.y + (ry.h / 2) + 1);\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) + 1);\n p.addPoint(ry.x + ry.w - 20, ry.y + (ry.h / 2) + 8);\n p.addPoint(ry.x + ry.w - 30, ry.y + (ry.h / 2));\n _g.setColor(ViewColor.cThemeAccent);\n _g.polygon(true, p.xpoints, p.ypoints, p.npoints);\n _g.setColor(ViewColor.cThemeAccent.darker());\n _g.polygon(false, p.xpoints, p.ypoints, p.npoints);\n }\n }\n }\n public XYWH_I incUp() {\n XYWH_I p = panX();\n return new XYWH_I(p.x, p.y, p.w, p.h / 2);\n }\n public XYWH_I incDown() {\n XYWH_I p = panX();\n return new XYWH_I(p.x, p.y + (p.h / 2), p.w, p.h / 2);\n }\n public XYWH_I incRight() {\n XYWH_I p = panY();\n return new XYWH_I(p.x + (p.w / 2), p.y, p.w / 2, p.h);\n }\n public XYWH_I incLeft() {\n XYWH_I p = panY();\n return new XYWH_I(p.x, p.y, p.w / 2, p.h);\n }\n public XYWH_I resizeY() {\n return new XYWH_I((int) (getW() - resize), 0, resize, getH());\n }\n public XYWH_I resizeX() {\n return new XYWH_I(0, (int) (getH() - resize), getW(), resize);\n }\n public XYWH_I panX() {\n int r = resize;\n if (alignY < 0) {\n r = 0;\n }\n float _w = getW() - r;\n int _x = (int) (alignX * _w);\n int pw = 0;\n if (wSlack != 0) {\n pw = (int) ((_w / (_w + wSlack)) * _w);\n }\n if (pw < scrollBarSize) {\n pw = scrollBarSize;\n }\n return new XYWH_I((int) (_x - (pw * alignX)), (int) (getH() - (scrollBarSize + r)), pw, scrollBarSize);\n }\n public XYWH_I panY() {\n int r = resize;\n if (alignX < 0) {\n r = 0;\n }\n float _h = getH() - r;\n int _y = (int) (alignY * _h);\n int ph = 0;\n if (hSlack != 0) {\n ph = (int) ((_h / (_h + hSlack)) * _h);\n }\n if (ph < scrollBarSize) {\n ph = scrollBarSize;\n }\n return new XYWH_I((int) (getW() - (scrollBarSize + r)), (int) (_y - (ph * alignY)), scrollBarSize, ph);\n }\n @Override\n public void paintBackground(ICanvas _g, int _x, int _y, int _w, int _h) {\n if (maxWBeforePan > -1 && maxWBeforePan > view.getW()) {\n w = view.getW();\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n } else if (maxWBeforePan > -1 && alignX < 0) {\n w = maxWBeforePan;\n alignX = 0;\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n }\n if (maxHBeforePan > -1 && maxHBeforePan > view.getH()) {\n h = view.getH();\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n } else if (maxHBeforePan > -1 && alignY < 0) {\n h = maxHBeforePan;\n alignY = 0;\n parent.layoutInterior();\n parent.repair();\n parent.flush();\n }\n super.paintBackground(_g, _x, _y, _w, _h);\n }\n @Override\n public IView disbatchEvent(IView parent, AViewEvent event) {\n if (isPanEvent(event) || scrollingX || scrollingY || resizingX || resizingY) {\n return this;\n }\n if (event instanceof MouseMoved) {\n XY_I p = ((MouseMoved) event).getPoint();\n if ((alignX > -1 && panX().contains(p)) || (alignY > -1 && panY().contains(p))) {\n if (!mouseIsDown) {\n setPaintingScrollBars(p, isPanEvent(event));\n }\n return this;\n } else if ((p.x > getW() - resize) || (p.y > getH() - resize)) {\n if (!mouseIsDown) {\n setPaintingScrollBars(p, isPanEvent(event));\n }\n return this;\n } else if ((p.x > getW() - scrollBarSize) && (p.y > getH() - scrollBarSize)) {\n if (!mouseIsDown) {\n setPaintingScrollBars(p, isPanEvent(event));\n }\n return this;\n } else {\n paintXScrollbar = false;\n paintYScrollbar = false;\n paintXResizing = false;\n paintYResizing = false;\n return super.disbatchEvent(parent, event);\n }\n } else if (event instanceof MousePressed) {\n XY_I p = ((MousePressed) event).getPoint();\n setModePoint(p, isPanEvent(event));\n if ((alignX > -1 && panX().contains(p)) || (alignY > -1 && panY().contains(p))) {\n setPan(false);\n return this;\n } else if ((p.x > getW() - resize) || (p.y > getH() - resize)) {\n setPan(false);\n return this;\n } else if ((p.x > getW() - scrollBarSize) && (p.y > getH() - scrollBarSize)) {\n setPan(false);\n return this;\n }\n if (scrollingX || scrollingY || resizingX || resizingY) {\n return this;\n } else {\n return super.disbatchEvent(parent, event);\n }\n } else if (event instanceof MouseReleased) {\n XY_I p = ((MouseReleased) event).getPoint();\n setModePoint(p, isPanEvent(event));\n if ((alignX > -1 && panX().contains(p)) || (alignY > -1 && panY().contains(p))) {\n setPan(false);\n return this;\n } else if ((p.x > getW() - resize) || (p.y > getH() - resize)) {\n setPan(false);\n return this;\n }\n if (scrollingX || scrollingY || resizingX || resizingY) {\n return this;\n } else {\n return super.disbatchEvent(parent, event);\n }\n } else if (event instanceof MouseExited) {\n if (!mouseIsDown) {\n XY_I p = ((MouseExited) event).getPoint();\n setModePoint(p, isPanEvent(event));\n }\n return super.disbatchEvent(parent, event);\n } else {\n return super.disbatchEvent(parent, event);\n }\n }\n boolean isPanEvent(IEvent event) {\n if (event instanceof AInputEvent) {\n boolean isPanEvent = (((AInputEvent) event).isShiftDown() && ((AInputEvent) event).isControlDown());\n if (isPanEvent) {\n return isPanEvent;\n }\n }\n lmp = null;\n return false;\n }\n @Override\n public void mouseWheel(MouseWheel _e) {\n int rotation = _e.getWheelRotation();\n if (_e.isShiftDown()) {\n if (rotation < 0) {\n for (int i = rotation; i < 0; i++) {\n incRightScroll();\n }\n } else {\n for (int i = 0; i < rotation; i++) {\n incLeftScroll();\n }\n }\n } else {\n if (rotation < 0) {\n for (int i = rotation; i < 0; i++) {\n incUpScroll();\n }\n } else {\n for (int i = 0; i < rotation; i++) {\n incDownScroll();\n }\n }\n }\n }\n protected void incUpScroll() {\n float p = getAlignY() - (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 0.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignY() - (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 0.0f));\n }\n }\n }.start();\n }\n protected void incDownScroll() {\n float p = getAlignY() + (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 1.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignY() + (((float) getH() / 3) / ((float) getContent().getH()));\n setPositionY(UFloat.checkFloat(p, 1.0f));\n }\n }\n }.start();\n }\n protected void incLeftScroll() {\n float p = getAlignX() - (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 0.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignX() - (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 0.0f));\n }\n }\n }.start();\n }\n protected void incRightScroll() {\n float p = getAlignX() + (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 1.0f));\n new Thread() {\n @Override\n public void run() {\n while (mouseIsDown && !drug) {\n try {\n Thread.sleep(600);\n if (!mouseIsDown) {\n break;\n }\n } catch (InterruptedException ex) {\n }\n float p = getAlignX() + (((float) getW() / 3) / ((float) getContent().getW()));\n setPositionX(UFloat.checkFloat(p, 1.0f));\n }\n }\n }.start();\n }\n public void setPositionX(float _position) {\n if (_position < 0.0f) {\n _position = 0.0f;\n }\n if (_position > 1.0f) {\n _position = 1.0f;\n }\n setAlignX(_position, this);\n paint();\n }\n public void setPositionY(float _position) {\n if (_position < 0.0f) {\n _position = 0.0f;\n }\n if (_position > 1.0f) {\n _position = 1.0f;\n }\n setAlignY(_position, this);\n paint();\n }\n public float getPositionX() {\n return getAlignX();\n }\n public float getPositionY() {\n return getAlignY();\n }\n public void setPan(boolean _pan) {\n }\n boolean mouseIsDown = false;\n @Override\n public void mouseEntered(MouseEntered _e) {\n DragAndDrop.cDefault.mouseEntered(_e);\n mouseIsDown = false;\n }\n @Override\n public void mouseExited(MouseExited _e) {\n DragAndDrop.cDefault.mouseExited(_e);\n mouseIsDown = false;\n }\n public void setModePoint(XY_I _p, boolean _panXY) {\n if (_panXY) {\n scrollingX = true;\n scrollingY = true;\n } else if (resizeable && (_p.x < getW() && _p.y < getH()) && (_p.x > getW() - scrollBarSize && _p.y > getH() - scrollBarSize)) {\n resizingX = true;\n resizingY = true;\n scrollingX = false;\n scrollingY = false;\n } else if (resizeable && resizeY().contains(_p)) {\n resizingX = true;\n resizingY = false;\n scrollingX = false;\n scrollingY = false;\n } else if (resizeable && resizeX().contains(_p)) {\n resizingX = false;\n resizingY = true;\n scrollingX = false;\n scrollingY = false;\n } else if (panY().contains(_p) || incRight().contains(_p) || incLeft().contains(_p)) {\n resizingX = false;\n resizingY = false;\n scrollingX = false;\n scrollingY = true;\n } else if (panX().contains(_p) || incUp().contains(_p) || incDown().contains(_p)) {\n resizingX = false;\n resizingY = false;\n scrollingX = true;\n scrollingY = false;\n } else {\n resizingX = false;\n resizingY = false;\n scrollingX = false;\n scrollingY = false;\n }\n }\n WH_F mpwh = new WH_F();\n float mpxp = 0f;\n float mpyp = 0f;\n @Override\n public void mousePressed(MousePressed _e) {\n if (_e.getClickCount() > 0) {\n DragAndDrop.cDefault.mousePressed(_e);\n }\n mpwh = new WH_F(getW(), getH());\n mpxp = getPositionX();\n mpyp = getPositionY();\n mouseIsDown = true;\n }\n @Override\n public void mouseReleased(MouseReleased _e) {\n setModePoint(_e.getPoint(), isPanEvent(_e));\n if (incDown().contains(_e.getPoint())) {\n incDownScroll();\n }\n if (incLeft().contains(_e.getPoint())) {\n incLeftScroll();\n }\n if (incRight().contains(_e.getPoint())) {\n incRight();\n }\n if (incUp().contains(_e.getPoint())) {\n incUpScroll();\n }\n mouseIsDown = false;\n drug = false;\n PickupAndDrop.cDefault.event(_e);\n if (_e.getClickCount() > 0) {\n DragAndDrop.cDefault.mouseReleased(_e);\n }\n resizingX = false;\n resizingY = false;\n scrollingX = false;\n scrollingY = false;\n lmp = null;\n }\n public void setPaintingScrollBars(XY_I _p, boolean _pan) {\n if (mouseIsDown) {\n return;\n }\n if (resizeX().contains(_p)) {\n paintXResizing = true;\n paint();\n return;\n } else {\n paintXResizing = false;\n }\n if (resizeY().contains(_p)) {\n paintYResizing = true;\n paint();\n return;\n } else {\n paintYResizing = false;\n }\n if (panY().contains(_p) || _pan) {\n if (paintYScrollbar); else {\n getRootView().setMouseWheelFocus(0, this);\n paintYScrollbar = true;\n paint();\n }\n } else {\n paintYScrollbar = false;\n paint();\n }\n if (panX().contains(_p) || _pan) {\n if (paintXScrollbar); else {\n getRootView().setMouseWheelFocus(0, this);\n paintXScrollbar = true;\n paint();\n }\n } else {\n paintXScrollbar = false;\n paint();\n }\n }\n XY_I lmp = null;\n @Override\n public void mouseMoved(MouseMoved _e) {\n if (mouseIsDown) {\n return;\n }\n XY_I p = _e.getPoint();\n setPaintingScrollBars(p, isPanEvent(_e));\n if (isPanEvent(_e)) {\n if (lmp == null) {\n lmp = _e.getPoint();\n return;\n }\n XY_I mp = _e.getPoint();\n float yrate = (lmp.y - mp.y) / (getH() / 2);\n setPositionY(getPositionY() - yrate);\n float xrate = (lmp.x - mp.x) / (getW() / 2);\n setPositionX(getPositionX() - xrate);\n lmp = mp;\n }\n }\n boolean drug = false;\n @Override\n public void mouseDragged(MouseDragged _e) {\n DragAndDrop.cDefault.mouseDragged(_e);\n if (!operable) {\n return;\n }\n drug = true;\n if (resizeable && (resizingX || resizingY)) {\n if (fixedW == -1 && resizingX) {\n w = mpwh.w + _e.getSumDeltaX();\n }\n if (fixedH == -1 && resizingY) {\n h = mpwh.h + _e.getSumDeltaY();\n }\n layoutInterior();\n parent.layoutInterior();\n parent.paint();\n }\n if (scrollingY) {\n float s = getH() - resize;\n int p = 0;\n if (hSlack != 0) {\n p = (int) ((s / (s + hSlack)) * s);\n }\n double delta = _e.getSumDeltaY() / (s - p);\n setPositionY((float) UDouble.clamp(mpyp + delta, 0, 1));\n }\n if (scrollingX) {\n float s = getW() - resize;\n int p = 0;\n if (wSlack != 0) {\n p = (int) ((s / (s + wSlack)) * s);\n }\n double delta = _e.getSumDeltaX() / (s - p);\n setPositionX((float) UDouble.clamp(mpxp + delta, 0, 1));\n }\n }\n @Override\n public IDropMode accepts(Object value, AInputEvent _e) {\n if (dropCallback == null) {\n return null;\n }\n return (IDropMode) dropCallback.callback(new Object[]{value, _e});\n }\n @Override\n public void dropParcel(final Object value, final IDropMode mode) {\n if (droppedCallback == null) {\n return;\n }\n new Thread() {\n @Override\n public void run() {\n droppedCallback.callback(new Object[]{value, mode});\n }\n }.start();\n }\n}\n"} {"input": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setTitle(R.string.lockscreen_settings_title_subhead);\n addPreferencesFromResource(R.xml.lockscreen_widgets_settings);\n PreferenceScreen prefSet = getPreferenceScreen();\n mMusicControlPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_MUSIC_CONTROLS);\n mMusicControlPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_MUSIC_CONTROLS, 1) == 1);\n mNowPlayingPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_NOW_PLAYING);\n mNowPlayingPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_NOW_PLAYING, 1) == 1);\n mAlbumArtPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_ALBUM_ART);\n mAlbumArtPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_ALBUM_ART, 1) == 1);\n mLockscreenMusicHeadsetPref = (ListPreference) prefSet\n .findPreference(LOCKSCREEN_MUSIC_CONTROLS_HEADSET);\n int lockscreenMusicHeadsetPref = Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_MUSIC_CONTROLS_HEADSET, 0);\n mLockscreenMusicHeadsetPref.setValue(String.valueOf(lockscreenMusicHeadsetPref));\n mLockscreenMusicHeadsetPref.setOnPreferenceChangeListener(this);\n mAlwaysMusicControlPref = (CheckBoxPreference) prefSet\n .findPreference(LOCKSCREEN_ALWAYS_MUSIC_CONTROLS);\n boolean alwaysMusicControlPref = Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_ALWAYS_MUSIC_CONTROLS, 0) == 1;\n mAlwaysMusicControlPref.setChecked(alwaysMusicControlPref);\n mLockscreenMusicHeadsetPref.setEnabled(!alwaysMusicControlPref);\n mLockscreenWidgetLayout = (ListPreference) prefSet\n .findPreference(LOCKSCREEN_WIDGETS_LAYOUT);\n mLockscreenWidgetLayout.setOnPreferenceChangeListener(this);\n mAlwaysBatteryPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_ALWAYS_BATTERY);\n mAlwaysBatteryPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_ALWAYS_BATTERY, 0) == 1);\n mCalendarsPref = (MultiSelectListPreference) prefSet.findPreference(LOCKSCREEN_CALENDARS);\n mCalendarsPref.setValue(Settings.System.getString(getContentResolver(),\n Settings.System.LOCKSCREEN_CALENDARS));\n mCalendarsPref.setOnPreferenceChangeListener(this);\n CalendarEntries calEntries = CalendarEntries.findCalendars(getContentResolver());\n mCalendarsPref.setEntries(calEntries.getEntries());\n mCalendarsPref.setEntryValues(calEntries.getEntryValues());\n mCalendarRemindersOnlyPref = (CheckBoxPreference) prefSet\n .findPreference(LOCKSCREEN_CALENDAR_REMINDERS_ONLY);\n mCalendarRemindersOnlyPref.setChecked(Settings.System.getInt(getContentResolver(),\n LOCKSCREEN_CALENDAR_REMINDERS_ONLY, 0) == 1);\n mCalendarAlarmLookaheadPref = (ListPreference) prefSet\n .findPreference(LOCKSCREEN_CALENDAR_LOOKAHEAD);\n long calendarAlarmLookaheadPref = Settings.System.getLong(getContentResolver(),\n Settings.System.LOCKSCREEN_CALENDAR_LOOKAHEAD, 10800000);\n mCalendarAlarmLookaheadPref.setValue(String.valueOf(calendarAlarmLookaheadPref));\n mCalendarAlarmLookaheadPref.setOnPreferenceChangeListener(this);\n mCalendarAlarmPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_CALENDAR_ALARM);\n mCalendarAlarmPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_CALENDAR_ALARM, 0) == 1);\n boolean hideAlwaysBatteryPref = mLockscreenWidgetLayout.getEntry().equals(getResources()\n .getStringArray(R.array.pref_lockscreen_widget_layout_entries)[1]);\n mAlwaysBatteryPref.setEnabled(hideAlwaysBatteryPref);\n }\n", "output": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setTitle(R.string.lockscreen_settings_title_subhead);\n addPreferencesFromResource(R.xml.lockscreen_widgets_settings);\n PreferenceScreen prefSet = getPreferenceScreen();\n mMusicControlPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_MUSIC_CONTROLS);\n mMusicControlPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_MUSIC_CONTROLS, 1) == 1);\n mNowPlayingPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_NOW_PLAYING);\n mNowPlayingPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_NOW_PLAYING, 1) == 1);\n mAlbumArtPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_ALBUM_ART);\n mAlbumArtPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_ALBUM_ART, 1) == 1);\n mLockscreenMusicHeadsetPref = (ListPreference) prefSet\n .findPreference(LOCKSCREEN_MUSIC_CONTROLS_HEADSET);\n int lockscreenMusicHeadsetPref = Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_MUSIC_CONTROLS_HEADSET, 0);\n mLockscreenMusicHeadsetPref.setValue(String.valueOf(lockscreenMusicHeadsetPref));\n mLockscreenMusicHeadsetPref.setOnPreferenceChangeListener(this);\n mAlwaysMusicControlPref = (CheckBoxPreference) prefSet\n .findPreference(LOCKSCREEN_ALWAYS_MUSIC_CONTROLS);\n boolean alwaysMusicControlPref = Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_ALWAYS_MUSIC_CONTROLS, 0) == 1;\n mAlwaysMusicControlPref.setChecked(alwaysMusicControlPref);\n mLockscreenMusicHeadsetPref.setEnabled(!alwaysMusicControlPref);\n mLockscreenWidgetLayout = (ListPreference) prefSet\n .findPreference(LOCKSCREEN_WIDGETS_LAYOUT);\n mLockscreenWidgetLayout.setOnPreferenceChangeListener(this);\n mAlwaysBatteryPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_ALWAYS_BATTERY);\n mAlwaysBatteryPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_ALWAYS_BATTERY, 0) == 1);\n mCalendarsPref = (MultiSelectListPreference) prefSet.findPreference(LOCKSCREEN_CALENDARS);\n mCalendarsPref.setValue(Settings.System.getString(getContentResolver(),\n Settings.System.LOCKSCREEN_CALENDARS));\n mCalendarsPref.setOnPreferenceChangeListener(this);\n CalendarEntries calEntries = CalendarEntries.findCalendars(getContentResolver());\n mCalendarsPref.setEntries(calEntries.getEntries());\n mCalendarsPref.setEntryValues(calEntries.getEntryValues());\n mCalendarRemindersOnlyPref = (CheckBoxPreference) prefSet\n .findPreference(LOCKSCREEN_CALENDAR_REMINDERS_ONLY);\n mCalendarRemindersOnlyPref.setChecked(Settings.System.getInt(getContentResolver(),\n LOCKSCREEN_CALENDAR_REMINDERS_ONLY, 0) == 1);\n mCalendarAlarmLookaheadPref = (ListPreference) prefSet\n .findPreference(LOCKSCREEN_CALENDAR_LOOKAHEAD);\n long calendarAlarmLookaheadPref = Settings.System.getLong(getContentResolver(),\n Settings.System.LOCKSCREEN_CALENDAR_LOOKAHEAD, 10800000);\n mCalendarAlarmLookaheadPref.setValue(String.valueOf(calendarAlarmLookaheadPref));\n mCalendarAlarmLookaheadPref.setOnPreferenceChangeListener(this);\n mCalendarAlarmPref = (CheckBoxPreference) prefSet.findPreference(LOCKSCREEN_CALENDAR_ALARM);\n mCalendarAlarmPref.setChecked(Settings.System.getInt(getContentResolver(),\n Settings.System.LOCKSCREEN_CALENDAR_ALARM, 0) == 1);\n boolean enableAlwaysBatteryPref = !mLockscreenWidgetLayout.getEntry().equals(getResources()\n .getStringArray(R.array.pref_lockscreen_widget_layout_entries)[1]);\n mAlwaysBatteryPref.setEnabled(enableAlwaysBatteryPref);\n }\n"} {"input": " public Response createOrUpdateUser(@PathParam(\"U_ID\") String urlSafeUserId, String username)\n throws DigitalLibraryException, ConflictException, ClassNotFoundException, IOException, NamingException,\n SQLException, pl.psnc.dl.wf4ever.dl.NotFoundException {\n String userId = new String(Base64.decodeBase64(urlSafeUserId));\n boolean updated = false;\n UserProfileDAO userProfileDAO = new UserProfileDAO();\n try {\n new URI(userId);\n UserProfile user = userProfileDAO.findByLogin(userId);\n if (user != null && username != null && !(user.getName().equals(username))) {\n updated = true;\n }\n } catch (URISyntaxException e) {\n LOGGER.warn(\"URI \" + userId + \" is not valid\", e);\n }\n String password = UUID.randomUUID().toString().replaceAll(\"-\", \"\").substring(0, 20);\n boolean created = DigitalLibraryFactory.getDigitalLibrary().createOrUpdateUser(userId, password,\n username != null && !username.isEmpty() ? username : userId);\n if (created) {\n return Response.created(uriInfo.getAbsolutePath()).build();\n } else {\n if (updated) {\n UserProfile user = userProfileDAO.findByLogin(userId);\n UpdateUserIndexThread updateThread = new UpdateUserIndexThread(ResearchObject.getAll(builder, user));\n updateThread.run();\n }\n return Response.ok().build();\n }\n }\n", "output": " public Response createOrUpdateUser(@PathParam(\"U_ID\") String urlSafeUserId, String username)\n throws DigitalLibraryException, ConflictException, ClassNotFoundException, IOException, NamingException,\n SQLException, pl.psnc.dl.wf4ever.dl.NotFoundException {\n String userId = new String(Base64.decodeBase64(urlSafeUserId));\n boolean updated = false;\n UserProfileDAO userProfileDAO = new UserProfileDAO();\n try {\n new URI(userId);\n UserProfile user = userProfileDAO.findByLogin(userId);\n if (user != null && username != null && !(user.getName().equals(username))) {\n updated = true;\n }\n } catch (URISyntaxException e) {\n LOGGER.warn(\"URI \" + userId + \" is not valid\", e);\n }\n String password = UUID.randomUUID().toString().replaceAll(\"-\", \"\").substring(0, 20);\n boolean created = DigitalLibraryFactory.getDigitalLibrary().createOrUpdateUser(userId, password,\n username != null && !username.isEmpty() ? username : userId);\n if (created) {\n return Response.created(uriInfo.getAbsolutePath()).build();\n } else {\n if (updated) {\n UserProfile user = userProfileDAO.findByLogin(userId);\n UpdateUserIndexThread updateThread = new UpdateUserIndexThread(ResearchObject.getAll(builder, user));\n updateThread.start();\n }\n return Response.ok().build();\n }\n }\n"} {"input": "\tpublic ObjectClassDefinition getObjectClassDefinition(String id, String localeStr) {\n\t\tfinal Locale locale = (localeStr==null) ? Locale.ENGLISH : new Locale(localeStr);\n\t\tfinal ResourceBundle rb = ResourceBundle.getBundle(\"OSGI-INF/l10n/\" + RuntimeSettings.class.getSimpleName(), locale);\t\t\n\t\tfinal class OptAD implements AttributeDefinition {\n\t\t\tprivate final OptEntry entry;\n\t\t\tprivate final String option;\n\t\t\tpublic OptAD(final OptEntry entry, final String option) {\n\t\t\t\tthis.entry = entry;\n\t\t\t\tthis.option = option;\n\t\t\t}\n\t\t\tpublic String getID() {\n\t\t\t\treturn entry.getPid();\n\t\t\t}\n\t\t\tpublic int getCardinality() {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tpublic String getDescription() {\n\t\t\t\treturn rb.getString(entry.pid + \".desc\");\n\t\t\t}\n\t\t\tpublic String getName() {\n\t\t\t\treturn rb.getString(entry.pid + \".name\");\n\t\t\t}\n\t\t\tpublic String[] getDefaultValue() {\n\t\t\t\treturn new String[] { entry.getValue(option, false).toString() };\n\t\t\t}\n\t\t\tpublic String[] getOptionLabels() {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpublic String[] getOptionValues() {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpublic int getType() {\n\t\t\t\treturn (entry.split) ? STRING : BOOLEAN;\n\t\t\t}\n\t\t\tpublic String validate(String value) {\n\t\t\t\treturn entry.matches(value);\n\t\t\t}\n\t\t}\n\t\treturn new ObjectClassDefinition() {\n\t\t\tpublic AttributeDefinition[] getAttributeDefinitions(int filter) {\n\t\t\t\tfinal List<AttributeDefinition> attribs = new ArrayList<AttributeDefinition>();\n\t\t\t\tfinal List<String> runtimeSettings = readSettings();\n\t\t\t\tfinal HashSet<OptEntry> optEntries = new HashSet<OptEntry>(OPTIONS);\n\t\t\t\tString otherValues = null;\n\t\t\t\tif (runtimeSettings != null) {\n\t\t\t\t\tfinal StringBuilder sb = new StringBuilder();\n\t\t\t\t\touter: for (final String opt : runtimeSettings) {\n\t\t\t\t\t\tfinal Iterator<OptEntry> it = optEntries.iterator();\n\t\t\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\t\t\tfinal OptEntry e = it.next();\n\t\t\t\t\t\t\tif (opt.startsWith(e.fixOpt)) {\n\t\t\t\t\t\t\t\tattribs.add(new OptAD(e, opt));\n\t\t\t\t\t\t\t\tit.remove();\n\t\t\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (sb.length() > 0)\n\t\t\t\t\t\t\tsb.append(OPT_OTHER_SPLIT);\n\t\t\t\t\t\tsb.append(opt);\n\t\t\t\t\t}\n\t\t\t\t\totherValues = sb.toString();\n\t\t\t\t}\n\t\t\t\tfor (final OptEntry e : optEntries)\n\t\t\t\t\tattribs.add(new OptAD(e, null));\n\t\t\t\tif (otherValues != null)\n\t\t\t\t\tattribs.add(new OptAD(CM_OTHER_ENTRY, otherValues));\n\t\t\t\treturn attribs.toArray(new AttributeDefinition[attribs.size()]);\n\t\t\t}\n\t\t\tpublic String getDescription() {\n\t\t\t\ttry {\n\t\t\t\t\treturn MessageFormat.format(\n\t\t\t\t\t\t\trb.getString(\"runtimeSettings.desc\"),\n\t\t\t\t\t\t\tiniFile.getCanonicalFile().toString()\n\t\t\t\t\t);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\treturn rb.getString(\"runtimeSettings.desc\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic String getID() {\n\t\t\t\treturn PID;\n\t\t\t}\n\t\t\tpublic InputStream getIcon(int size) throws IOException {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpublic String getName() {\n\t\t\t\treturn rb.getString(\"runtimeSettings.name\");\n\t\t\t}\n\t\t};\t\t\t\t\n\t}\n", "output": "\tpublic ObjectClassDefinition getObjectClassDefinition(String id, String localeStr) {\n\t\tfinal Locale locale = (localeStr==null) ? Locale.ENGLISH : new Locale(localeStr);\n\t\tfinal ResourceBundle rb = ResourceBundle.getBundle(\"OSGI-INF/l10n/\" + RuntimeSettings.class.getSimpleName(), locale);\t\t\n\t\tfinal class OptAD implements AttributeDefinition {\n\t\t\tprivate final OptEntry entry;\n\t\t\tprivate final String option;\n\t\t\tpublic OptAD(final OptEntry entry, final String option) {\n\t\t\t\tthis.entry = entry;\n\t\t\t\tthis.option = option;\n\t\t\t}\n\t\t\tpublic String getID() {\n\t\t\t\treturn entry.getPid();\n\t\t\t}\n\t\t\tpublic int getCardinality() {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tpublic String getDescription() {\n\t\t\t\treturn rb.getString(entry.pid + \".desc\");\n\t\t\t}\n\t\t\tpublic String getName() {\n\t\t\t\treturn rb.getString(entry.pid + \".name\");\n\t\t\t}\n\t\t\tpublic String[] getDefaultValue() {\n\t\t\t\treturn new String[] { entry.getValue(option, false).toString() };\n\t\t\t}\n\t\t\tpublic String[] getOptionLabels() {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpublic String[] getOptionValues() {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpublic int getType() {\n\t\t\t\treturn (entry.split) ? STRING : BOOLEAN;\n\t\t\t}\n\t\t\tpublic String validate(String value) {\n\t\t\t\treturn entry.matches(value);\n\t\t\t}\n\t\t}\n\t\treturn new ObjectClassDefinition() {\n\t\t\tpublic AttributeDefinition[] getAttributeDefinitions(int filter) {\n\t\t\t\tfinal List<AttributeDefinition> attribs = new ArrayList<AttributeDefinition>();\n\t\t\t\tfinal List<String> runtimeSettings = readSettings();\n\t\t\t\tfinal HashSet<OptEntry> optEntries = new HashSet<OptEntry>(OPTIONS);\n\t\t\t\tString otherValues = \"\";\n\t\t\t\tif (runtimeSettings != null) {\n\t\t\t\t\tfinal StringBuilder sb = new StringBuilder();\n\t\t\t\t\touter: for (final String opt : runtimeSettings) {\n\t\t\t\t\t\tfinal Iterator<OptEntry> it = optEntries.iterator();\n\t\t\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\t\t\tfinal OptEntry e = it.next();\n\t\t\t\t\t\t\tif (opt.startsWith(e.fixOpt)) {\n\t\t\t\t\t\t\t\tattribs.add(new OptAD(e, opt));\n\t\t\t\t\t\t\t\tit.remove();\n\t\t\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (sb.length() > 0)\n\t\t\t\t\t\t\tsb.append(OPT_OTHER_SPLIT);\n\t\t\t\t\t\tsb.append(opt);\n\t\t\t\t\t}\n\t\t\t\t\totherValues = sb.toString();\n\t\t\t\t}\n\t\t\t\tfor (final OptEntry e : optEntries)\n\t\t\t\t\tattribs.add(new OptAD(e, null));\n\t\t\t\tattribs.add(new OptAD(CM_OTHER_ENTRY, otherValues));\n\t\t\t\treturn attribs.toArray(new AttributeDefinition[attribs.size()]);\n\t\t\t}\n\t\t\tpublic String getDescription() {\n\t\t\t\ttry {\n\t\t\t\t\treturn MessageFormat.format(\n\t\t\t\t\t\t\trb.getString(\"runtimeSettings.desc\"),\n\t\t\t\t\t\t\tiniFile.getCanonicalFile().toString()\n\t\t\t\t\t);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\treturn rb.getString(\"runtimeSettings.desc\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic String getID() {\n\t\t\t\treturn PID;\n\t\t\t}\n\t\t\tpublic InputStream getIcon(int size) throws IOException {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tpublic String getName() {\n\t\t\t\treturn rb.getString(\"runtimeSettings.name\");\n\t\t\t}\n\t\t};\t\t\t\t\n\t}\n"} {"input": " protected void onHandleIntent( Intent intent ) {\n String action = intent.getAction();\n if ( action.equals( ACTION_GET_AIRSIGMET ) ) {\n String type = intent.getStringExtra( TYPE );\n if ( type.equals( TYPE_TEXT ) ) {\n String stationId = intent.getStringExtra( STATION_ID );\n double[] box = intent.getDoubleArrayExtra( COORDS_BOX );\n int hours = intent.getIntExtra( HOURS_BEFORE, 3 );\n boolean cacheOnly = intent.getBooleanExtra( CACHE_ONLY, false );\n boolean forceRefresh = intent.getBooleanExtra( FORCE_REFRESH, false );\n File xml = getDataFile( \"AIRSIGMET_\"+stationId+\".xml\" );\n if ( forceRefresh || ( !cacheOnly && !xml.exists() ) ) {\n try {\n String query = String.format( AIRSIGMET_TEXT_QUERY,\n hours, box[ 0 ], box[ 1 ], box[ 2 ], box[ 3 ] );\n fetchFromNoaa( query, xml, true );\n } catch ( Exception e ) {\n UiUtils.showToast( this, \"Unable to fetch AirSigmet: \"+e.getMessage() );\n }\n }\n AirSigmet airSigmet = new AirSigmet();\n if ( xml.exists() ) {\n mParser.parse( xml, airSigmet );\n }\n sendResultIntent( action, stationId, airSigmet );\n } else if ( type.equals( TYPE_IMAGE ) ) {\n boolean hiRes = getResources().getBoolean( R.bool.WxHiResImages );\n String code = intent.getStringExtra( IMAGE_CODE );\n String imageName = String.format(\n hiRes? AIRSIGMET_IMAGE_ZOOM_NAME : AIRSIGMET_IMAGE_NAME, code );\n File imageFile = getDataFile( imageName );\n if ( !imageFile.exists() ) {\n try {\n String path = hiRes? AIRSIGMET_IMAGE_ZOOM_PATH : AIRSIGMET_IMAGE_PATH;\n path += imageName;\n fetchFromNoaa( path, imageFile, false );\n } catch ( Exception e ) {\n UiUtils.showToast( this, \"Unable to fetch AirSigmet image: \"\n +e.getMessage() );\n }\n }\n sendResultIntent( action, code, imageFile );\n }\n }\n }\n", "output": " protected void onHandleIntent( Intent intent ) {\n String action = intent.getAction();\n if ( action.equals( ACTION_GET_AIRSIGMET ) ) {\n String type = intent.getStringExtra( TYPE );\n if ( type.equals( TYPE_TEXT ) ) {\n String stationId = intent.getStringExtra( STATION_ID );\n double[] box = intent.getDoubleArrayExtra( COORDS_BOX );\n int hours = intent.getIntExtra( HOURS_BEFORE, 3 );\n boolean cacheOnly = intent.getBooleanExtra( CACHE_ONLY, false );\n boolean forceRefresh = intent.getBooleanExtra( FORCE_REFRESH, false );\n File xml = getDataFile( \"AIRSIGMET_\"+stationId+\".xml\" );\n if ( forceRefresh || ( !cacheOnly && !xml.exists() ) ) {\n try {\n String query = String.format( AIRSIGMET_TEXT_QUERY,\n hours, box[ 0 ], box[ 1 ], box[ 2 ], box[ 3 ] );\n fetchFromNoaa( query, xml, true );\n } catch ( Exception e ) {\n UiUtils.showToast( this, \"Unable to fetch AirSigmet: \"+e.getMessage() );\n }\n }\n AirSigmet airSigmet = new AirSigmet();\n if ( xml.exists() ) {\n mParser.parse( xml, airSigmet );\n }\n sendResultIntent( action, stationId, airSigmet );\n } else if ( type.equals( TYPE_IMAGE ) ) {\n boolean hiRes = getResources().getBoolean( R.bool.WxHiResImages );\n String code = intent.getStringExtra( IMAGE_CODE );\n String imageName = String.format(\n hiRes? AIRSIGMET_IMAGE_ZOOM_NAME : AIRSIGMET_IMAGE_NAME, code );\n File imageFile = getDataFile( imageName );\n if ( !imageFile.exists() ) {\n try {\n String path = hiRes? AIRSIGMET_IMAGE_ZOOM_PATH : AIRSIGMET_IMAGE_PATH;\n path += imageName;\n fetchFromNoaa( path, null, imageFile, false );\n } catch ( Exception e ) {\n UiUtils.showToast( this, \"Unable to fetch AirSigmet image: \"\n +e.getMessage() );\n }\n }\n sendResultIntent( action, code, imageFile );\n }\n }\n }\n"} {"input": " private void createItemGrid() {\n panel.clear();\n ContentPanel contentPanel = new FullContentPanel();\n contentPanel.setHeading(\"All Items\");\n if (info != null) {\n contentPanel = new PaddedContentPanel();\n contentPanel.setHeading(info.getName());\n itemPanel.setHeading(info.getName());\n }\n contentPanel.setAutoHeight(true);\n contentPanel.setTopComponent(new InlineHelpPanel(repository.getRepositoryConstants().repo_Tip(), 14));\n BeanModelFactory factory = BeanModelLookup.get().getFactory(ItemInfo.class);\n List<BeanModel> model = factory.createModel(items);\n final ListStore<BeanModel> store = new ListStore<BeanModel>();\n store.add(model);\n ToolbarButtonBar toolbar = new ToolbarButtonBar();\n SearchStoreFilterField<BeanModel> filter = new SearchStoreFilterField<BeanModel>() {\n @Override\n protected boolean doSelect(Store<BeanModel> store, BeanModel parent,\n BeanModel record, String property, String filter) {\n String name = record.get(\"name\");\n name = name.toLowerCase();\n String authorName = record.get(\"authorName\");\n authorName = authorName.toLowerCase();\n String type = record.get(\"type\");\n type = type.toLowerCase();\n if (name.indexOf(filter.toLowerCase()) != -1 ||\n authorName.indexOf(filter.toLowerCase()) != -1 ||\n type.indexOf(filter.toLowerCase()) != -1) {\n return true;\n }\n return false;\n }\n };\n filter.bind(store);\n toolbar.add(filter);\n toolbar.add(new FillToolItem());\n selectionModel = new CheckBoxSelectionModel<BeanModel>();\n List<ColumnConfig> columns = new ArrayList<ColumnConfig>();\n columns.add(selectionModel.getColumn());\n ColumnConfig icon = new ColumnConfig(\"type\", \" \", 23);\n icon.setRenderer(new GridCellRenderer() {\n public Object render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {\n if(modelData.get(s).equals(\"Workspace\")) {\n return new Image(Images.ICON_FOLDER);\n }\n return new Image(Images.ICON_TEXT);\n }\n });\n columns.add(icon);\n columns.add(new ColumnConfig(\"name\", \"Name\", 250));\n columns.add(new ColumnConfig(\"authorName\", \"Author\", 200));\n columns.add(new ColumnConfig(\"type\", \"Type\", 200));\n ColumnModel columnModel = new ColumnModel(columns);\n BasicGrid<BeanModel> grid = new BasicGrid<BeanModel>(store, columnModel);\n grid.setSelectionModel(selectionModel);\n grid.addPlugin(selectionModel);\n grid.setAutoExpandColumn(\"type\");\n grid.addListener(Events.CellClick, new Listener<BaseEvent>() {\n public void handleEvent(BaseEvent be) {\n GridEvent ge = (GridEvent) be;\n if (ge.getColIndex() > 0) {\n ItemInfo ii = store.getAt(ge.getRowIndex()).getBean();\n menuPanel.showItem(ii);\n History.newItem(\"item/\" + ii.getId());\n }\n }\n });\n contentPanel.add(toolbar);\n contentPanel.add(grid);\n if (info == null || info.isModifiable()) {\n if (info == null || info.getType().equals(\"Workspace\")) {\n final ToolbarButton newWkspaceBtn = new ToolbarButton(\"New Workspace\");\n newWkspaceBtn.setStyleName(\"toolbar-btn_center\");\n newWkspaceBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n showNewWorkspace();\n }\n });\n newWkspaceBtn.setToolTip(repository.getRepositoryConstants().repo_NewWorkspace());\n toolbar.add(newWkspaceBtn);\n final ToolbarButton newArtifactBtn = new ToolbarButton(\"New Artifact\");\n newArtifactBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n showArtifactUploadForm(true);\n }\n });\n newArtifactBtn.setToolTip(repository.getRepositoryConstants().repo_NewArtifact());\n toolbar.add(newArtifactBtn);\n } else if (info.getType().equals(\"Artifact\")) {\n final ToolbarButton newVersionBtn = new ToolbarButton(\"New Version\");\n newVersionBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n showArtifactUploadForm(false);\n }\n });\n newVersionBtn.setToolTip(repository.getRepositoryConstants().repo_Items_New());\n toolbar.add(newVersionBtn);\n } else {\n String token;\n if (info.getId() != null) {\n token = \"add-item/\" + info.getId();\n } else {\n token = \"add-item/\";\n }\n ToolbarButton newBtn = WidgetHelper.createToolbarHistoryButton(\"New\", token, repository.getRepositoryConstants().repo_Items_New());\n toolbar.add(newBtn);\n }\n }\n final ToolbarButton delBtn = new ToolbarButton(\"Delete\");\n delBtn.setToolTip(repository.getRepositoryConstants().repo_Delete());\n delBtn.setEnabled(false);\n delBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n warnDelete(selectionModel.getSelectedItems());\n }\n });\n if (info == null || info.isDeletable()) {\n toolbar.add(delBtn);\n }\n selectionModel.addSelectionChangedListener(new SelectionChangedListener<BeanModel>() {\n public void selectionChanged(SelectionChangedEvent<BeanModel> se) {\n boolean isSelected = selectionModel.getSelectedItems().size() > 0;\n delBtn.setEnabled(isSelected);\n }\n });\n panel.add(contentPanel);\n }\n", "output": " private void createItemGrid() {\n panel.clear();\n ContentPanel contentPanel = new FullContentPanel();\n contentPanel.setHeading(\"All Items\");\n if (info != null) {\n contentPanel = new PaddedContentPanel();\n contentPanel.setHeading(info.getName());\n itemPanel.setHeading(info.getName());\n }\n contentPanel.setAutoHeight(true);\n contentPanel.setTopComponent(new InlineHelpPanel(repository.getRepositoryConstants().repo_Tip(), 14));\n BeanModelFactory factory = BeanModelLookup.get().getFactory(ItemInfo.class);\n List<BeanModel> model = factory.createModel(items);\n final ListStore<BeanModel> store = new ListStore<BeanModel>();\n store.add(model);\n ToolbarButtonBar toolbar = new ToolbarButtonBar();\n SearchStoreFilterField<BeanModel> filter = new SearchStoreFilterField<BeanModel>() {\n @Override\n protected boolean doSelect(Store<BeanModel> store, BeanModel parent,\n BeanModel record, String property, String filter) {\n String name = record.get(\"name\");\n name = name.toLowerCase();\n String authorName = record.get(\"authorName\");\n authorName = authorName.toLowerCase();\n String type = record.get(\"type\");\n type = type.toLowerCase();\n if (name.indexOf(filter.toLowerCase()) != -1 ||\n authorName.indexOf(filter.toLowerCase()) != -1 ||\n type.indexOf(filter.toLowerCase()) != -1) {\n return true;\n }\n return false;\n }\n };\n filter.bind(store);\n toolbar.add(filter);\n toolbar.add(new FillToolItem());\n selectionModel = new CheckBoxSelectionModel<BeanModel>();\n List<ColumnConfig> columns = new ArrayList<ColumnConfig>();\n columns.add(selectionModel.getColumn());\n ColumnConfig icon = new ColumnConfig(\"type\", \" \", 23);\n icon.setRenderer(new GridCellRenderer() {\n public Object render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {\n Object obj = modelData.get(s);\n if(obj.equals(\"Workspace\")) {\n return new Image(Images.ICON_FOLDER);\n }\n return new Image(Images.ICON_TEXT);\n }\n });\n columns.add(icon);\n columns.add(new ColumnConfig(\"name\", \"Name\", 250));\n columns.add(new ColumnConfig(\"authorName\", \"Author\", 200));\n columns.add(new ColumnConfig(\"type\", \"Type\", 200));\n ColumnModel columnModel = new ColumnModel(columns);\n BasicGrid<BeanModel> grid = new BasicGrid<BeanModel>(store, columnModel);\n grid.setSelectionModel(selectionModel);\n grid.addPlugin(selectionModel);\n grid.setAutoExpandColumn(\"type\");\n grid.addListener(Events.CellClick, new Listener<BaseEvent>() {\n public void handleEvent(BaseEvent be) {\n GridEvent ge = (GridEvent) be;\n if (ge.getColIndex() > 0) {\n ItemInfo ii = store.getAt(ge.getRowIndex()).getBean();\n menuPanel.showItem(ii);\n History.newItem(\"item/\" + ii.getId());\n }\n }\n });\n contentPanel.add(toolbar);\n contentPanel.add(grid);\n if (info == null || info.isModifiable()) {\n if (info == null || info.getType().equals(\"Workspace\")) {\n final ToolbarButton newWkspaceBtn = new ToolbarButton(\"New Workspace\");\n newWkspaceBtn.setStyleName(\"toolbar-btn_center\");\n newWkspaceBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n showNewWorkspace();\n }\n });\n newWkspaceBtn.setToolTip(repository.getRepositoryConstants().repo_NewWorkspace());\n toolbar.add(newWkspaceBtn);\n final ToolbarButton newArtifactBtn = new ToolbarButton(\"New Artifact\");\n newArtifactBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n showArtifactUploadForm(true);\n }\n });\n newArtifactBtn.setToolTip(repository.getRepositoryConstants().repo_NewArtifact());\n toolbar.add(newArtifactBtn);\n } else if (info.getType().equals(\"Artifact\")) {\n final ToolbarButton newVersionBtn = new ToolbarButton(\"New Version\");\n newVersionBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n showArtifactUploadForm(false);\n }\n });\n newVersionBtn.setToolTip(repository.getRepositoryConstants().repo_Items_New());\n toolbar.add(newVersionBtn);\n } else {\n String token;\n if (info.getId() != null) {\n token = \"add-item/\" + info.getId();\n } else {\n token = \"add-item/\";\n }\n ToolbarButton newBtn = WidgetHelper.createToolbarHistoryButton(\"New\", token, repository.getRepositoryConstants().repo_Items_New());\n toolbar.add(newBtn);\n }\n }\n final ToolbarButton delBtn = new ToolbarButton(\"Delete\");\n delBtn.setToolTip(repository.getRepositoryConstants().repo_Delete());\n delBtn.setEnabled(false);\n delBtn.addSelectionListener(new SelectionListener<ToolbarButtonEvent>() {\n @Override\n public void componentSelected(ToolbarButtonEvent ce) {\n warnDelete(selectionModel.getSelectedItems());\n }\n });\n if (info == null || info.isDeletable()) {\n toolbar.add(delBtn);\n }\n selectionModel.addSelectionChangedListener(new SelectionChangedListener<BeanModel>() {\n public void selectionChanged(SelectionChangedEvent<BeanModel> se) {\n boolean isSelected = selectionModel.getSelectedItems().size() > 0;\n delBtn.setEnabled(isSelected);\n }\n });\n panel.add(contentPanel);\n }\n"} {"input": "\tpublic Object run() {\n\t\tDouble ret;\n\t\tDouble arg0, arg1;\n\t\tif (id.equals(\"u-\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 * -1;\n\t\t\tLOGOPP.io.debug(\"unary minus\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"*\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 * arg1;\n\t\t\tLOGOPP.io.debug(\"multiply\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"/\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 == 0.) {\n\t\t\t\tLOGOPP.errorhandler.setRunTime(id, \"devide by zero\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tret = arg0 / arg1;\n\t\t\tLOGOPP.io.debug(\"division\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"^\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = Math.pow(arg0, arg1);\n\t\t\tLOGOPP.io.debug(\"power\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"+\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 + arg1;\n\t\t\tLOGOPP.io.debug(\"plus\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"-\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 - arg1;\n\t\t\tLOGOPP.io.debug(\"minus\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"<\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 < arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"less than\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\">\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 > arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"greater than\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"<=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 <= arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"less than or equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\">=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 >= arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"greater than or equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 == arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"!=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 != arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"not equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"&&\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 == 0 || arg1 == 0)\n\t\t\t\tret = (double) 0;\n\t\t\telse\n\t\t\t\tret = (double) 1;\n\t\t\tLOGOPP.io.debug(\"logical and\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"||\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 > 0 || arg1 > 0)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"logical or\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tLOGOPP.errorhandler.setRunTime(id, \"unrecognised operator\");\n\t\treturn null;\t\t\n\t}\n", "output": "\tpublic Object run() {\n\t\tDouble ret;\n\t\tDouble arg0, arg1;\n\t\tif (id.equals(\"u-\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 * -1;\n\t\t\tLOGOPP.io.debug(\"unary minus\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"*\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 * arg1;\n\t\t\tLOGOPP.io.debug(\"multiply\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"/\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 == 0.) {\n\t\t\t\tLOGOPP.errorhandler.setRunTime(id, \"devide by zero\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tret = arg0 / arg1;\n\t\t\tLOGOPP.io.debug(\"division\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"^\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = Math.pow(arg0, arg1);\n\t\t\tLOGOPP.io.debug(\"power\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"+\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 + arg1;\n\t\t\tLOGOPP.io.debug(\"plus\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"-\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tret = arg0 - arg1;\n\t\t\tLOGOPP.io.debug(\"minus\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"<\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 < arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"less than\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\">\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 > arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"greater than\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"<=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 <= arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"less than or equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\">=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 >= arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"greater than or equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 == arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"!=\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 != arg1)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"not equal to\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"&&\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 == 0 || arg1 == 0)\n\t\t\t\tret = (double) 0;\n\t\t\telse\n\t\t\t\tret = (double) 1;\n\t\t\tLOGOPP.io.debug(\"logical and\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tif (id.equals(\"||\")) {\n\t\t\targ0 = runAndCheck(children[0]);\n\t\t\targ1 = runAndCheck(children[1]);\n\t\t\tif (LOGOPP.errorhandler.error())\n\t\t\t\treturn null;\n\t\t\tif (arg0 != 0 || arg1 != 0)\n\t\t\t\tret = (double) 1;\n\t\t\telse\n\t\t\t\tret = (double) 0;\n\t\t\tLOGOPP.io.debug(\"logical or\");\n\t\t\tLOGOPP.io.debug(ret.toString());\n\t\t\treturn ret;\n\t\t}\n\t\tLOGOPP.errorhandler.setRunTime(id, \"unrecognised operator\");\n\t\treturn null;\t\t\n\t}\n"} {"input": " public void onCreate( Bundle icicle ) {\n super.onCreate(icicle);\n setContentView(R.layout.osmcategorytags);\n Bundle extras = getIntent().getExtras();\n category = extras.getString(Constants.OSM_CATEGORY_KEY);\n final String[] itemsForCategory = OsmTagsManager.getInstance().getItemsForCategory(this, category);\n GridView buttonGridView = (GridView) findViewById(R.id.osmtagsgridview);\n ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.osm_button_layout, itemsForCategory){\n public View getView( final int position, View cView, ViewGroup parent ) {\n View inflate = LayoutInflater.from(OsmCategoryActivity.this).inflate(R.layout.osm_button_layout, parent, false);\n final TextView text = (TextView) inflate.findViewById(R.id.osm_item_text);\n final String tagName = itemsForCategory[position];\n text.setText(tagName.replaceAll(\"\\\\_\", \" \")); \n Drawable icon = OsmImageCache.getInstance(OsmCategoryActivity.this).getImageForTag(tagName, category);\n final ImageButton osmButton = (ImageButton) inflate.findViewById(R.id.osm_item_image);\n osmButton.setImageDrawable(icon);\n osmButton.setOnClickListener(new Button.OnClickListener(){\n public void onClick( View v ) {\n Intent osmCategoryIntent = new Intent(Constants.OSMFORMACTIVITY);\n osmCategoryIntent.putExtra(Constants.OSM_CATEGORY_KEY, category);\n osmCategoryIntent.putExtra(Constants.OSM_TAG_KEY, tagName);\n startActivity(osmCategoryIntent);\n }\n });\n return inflate;\n }\n };\n buttonGridView.setAdapter(arrayAdapter);\n }\n", "output": " public void onCreate( Bundle icicle ) {\n super.onCreate(icicle);\n setContentView(R.layout.osmcategorytags);\n Bundle extras = getIntent().getExtras();\n category = extras.getString(Constants.OSM_CATEGORY_KEY);\n final String[] itemsForCategory = OsmTagsManager.getInstance().getItemsForCategory(this, category);\n GridView buttonGridView = (GridView) findViewById(R.id.osmtagsgridview);\n ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.osm_button_layout, itemsForCategory){\n public View getView( final int position, View cView, ViewGroup parent ) {\n View inflate = LayoutInflater.from(OsmCategoryActivity.this).inflate(R.layout.osm_button_layout, parent, false);\n final TextView text = (TextView) inflate.findViewById(R.id.osm_item_text);\n final String tagName = itemsForCategory[position];\n text.setText(tagName.replaceAll(\"_\", \" \")); \n Drawable icon = OsmImageCache.getInstance(OsmCategoryActivity.this).getImageForTag(tagName, category);\n final ImageButton osmButton = (ImageButton) inflate.findViewById(R.id.osm_item_image);\n osmButton.setImageDrawable(icon);\n osmButton.setOnClickListener(new Button.OnClickListener(){\n public void onClick( View v ) {\n Intent osmCategoryIntent = new Intent(Constants.OSMFORMACTIVITY);\n osmCategoryIntent.putExtra(Constants.OSM_CATEGORY_KEY, category);\n osmCategoryIntent.putExtra(Constants.OSM_TAG_KEY, tagName);\n startActivity(osmCategoryIntent);\n }\n });\n return inflate;\n }\n };\n buttonGridView.setAdapter(arrayAdapter);\n }\n"} {"input": " public void execute(OfficeContext context) throws OfficeException {\n XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));\n XComponent document = null;\n try {\n Map<String,?> loadProperties = getLoadProperties(inputFile);\n document = loader.loadComponentFromURL(toUrl(inputFile), \"_blank\", 0, toUnoProperties(loadProperties));\n XRefreshable refreshable = cast(XRefreshable.class, document);\n if (refreshable != null) {\n refreshable.refresh();\n }\n Map<String,?> storeProperties = getStoreProperties(outputFile, document);\n cast(XStorable.class, document).storeToURL(toUrl(outputFile), toUnoProperties(storeProperties));\n } catch (IOException ioException) {\n throw new OfficeException(\"conversion failed\", ioException);\n } catch (IllegalArgumentException illegalArgumentException) {\n throw new OfficeException(\"conversion failed\", illegalArgumentException);\n } finally {\n try {\n cast(XCloseable.class, document).close(true);\n } catch (CloseVetoException closeVetoException) {\n }\n }\n }\n", "output": " public void execute(OfficeContext context) throws OfficeException {\n XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));\n XComponent document = null;\n try {\n Map<String,?> loadProperties = getLoadProperties(inputFile);\n document = loader.loadComponentFromURL(toUrl(inputFile), \"_blank\", 0, toUnoProperties(loadProperties));\n if (document == null) {\n throw new OfficeException(\"input document could not be loaded: \" + inputFile);\n }\n XRefreshable refreshable = cast(XRefreshable.class, document);\n if (refreshable != null) {\n refreshable.refresh();\n }\n Map<String,?> storeProperties = getStoreProperties(outputFile, document);\n cast(XStorable.class, document).storeToURL(toUrl(outputFile), toUnoProperties(storeProperties));\n } catch (IOException ioException) {\n throw new OfficeException(\"conversion failed\", ioException);\n } catch (IllegalArgumentException illegalArgumentException) {\n throw new OfficeException(\"conversion failed\", illegalArgumentException);\n } finally {\n if (document != null) {\n XCloseable closeable = cast(XCloseable.class, document);\n if (closeable != null) {\n try {\n closeable.close(true);\n } catch (CloseVetoException closeVetoException) {\n }\n } else {\n document.dispose();\n }\n }\n }\n }\n"} {"input": " public BwFreeBusy getFreeBusy(BwCalendar cal,\n String account,\n BwDateTime start,\n BwDateTime end) throws WebdavException {\n try {\n String serviceName = getServiceName(cal.getPath());\n DominoInfo di = serversInfo.get(serviceName);\n if (di == null) {\n throw WebdavIntfException.badRequest();\n }\n DavReq req = new DavReq();\n req.setMethod(\"GET\");\n req.setUrl(di.getUrlPrefix() + \"/\" +\n cal.getOwner().getAccount() + \"?\" +\n \"start-min=\" + makeDateTime(start) + \"&\" +\n \"start-max=\" + makeDateTime(end));\n req.addHeader(\"Accept\",\n \"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\");\n req.addHeader(\"Accept-Language\", \"en-us,en;q=0.7,es;q=0.3\");\n req.addHeader(\"Accept-Encoding\", \"gzip,deflate\");\n req.addHeader(\"Accept-Charset\", \"ISO-8859-1,utf-8;q=0.7,*;q=0.7\");\n DavResp resp = send(req, di);\n String vfb = makeVfb(new InputStreamReader(resp.getContentStream()));\n if (debug) {\n debugMsg(vfb);\n }\n Icalendar ic = trans.fromIcal(null, new StringReader(vfb));\n TreeSet<Period> periods = new TreeSet<Period>();\n Iterator fbit = ic.iterator();\n while (fbit.hasNext()) {\n Object o = fbit.next();\n if (o instanceof BwFreeBusy) {\n BwFreeBusy fb = (BwFreeBusy)o;\n Collection<BwFreeBusyComponent> times = fb.getTimes();\n if (times != null) {\n for (BwFreeBusyComponent fbcomp: times) {\n if (fbcomp.getType() != BwFreeBusyComponent.typeFree) {\n throw WebdavIntfException.serverError();\n }\n for (Period p: fbcomp.getPeriods()) {\n periods.add(p);\n }\n }\n }\n }\n }\n BwFreeBusy fb = new BwFreeBusy();\n fb.setStart(start);\n fb.setEnd(end);\n BwFreeBusyComponent fbcomp = new BwFreeBusyComponent();\n fb.addTime(fbcomp);\n fbcomp.setType(BwFreeBusyComponent.typeBusy);\n DateTime bstart = (DateTime)start.makeDate();\n Iterator pit = periods.iterator();\n while (pit.hasNext()) {\n Period p = (Period)pit.next();\n if (!bstart.equals(p.getStart())) {\n Period busyp = new Period(bstart, p.getStart());\n fbcomp.addPeriod(busyp);\n }\n bstart = p.getEnd();\n }\n DateTime bend = (DateTime)end.makeDate();\n if (!bstart.equals(bend)) {\n Period busyp = new Period(bstart, bend);\n fbcomp.addPeriod(busyp);\n }\n return fb;\n } catch (WebdavIntfException wie) {\n throw wie;\n } catch (Throwable t) {\n throw new WebdavIntfException(t);\n }\n }\n", "output": " public BwFreeBusy getFreeBusy(BwCalendar cal,\n String account,\n BwDateTime start,\n BwDateTime end) throws WebdavException {\n try {\n String serviceName = getServiceName(cal.getPath());\n DominoInfo di = serversInfo.get(serviceName);\n if (di == null) {\n throw WebdavIntfException.badRequest();\n }\n DavReq req = new DavReq();\n req.setMethod(\"GET\");\n req.setUrl(di.getUrlPrefix() + \"/\" +\n cal.getOwner().getAccount() + \"?\" +\n \"start-min=\" + makeDateTime(start) + \"&\" +\n \"start-max=\" + makeDateTime(end));\n req.addHeader(\"Accept\",\n \"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\");\n req.addHeader(\"Accept-Language\", \"en-us,en;q=0.7,es;q=0.3\");\n req.addHeader(\"Accept-Encoding\", \"gzip,deflate\");\n req.addHeader(\"Accept-Charset\", \"ISO-8859-1,utf-8;q=0.7,*;q=0.7\");\n DavResp resp = send(req, di);\n String vfb = makeVfb(new InputStreamReader(resp.getContentStream()));\n if (debug) {\n debugMsg(vfb);\n }\n Icalendar ic = trans.fromIcal(null, new StringReader(vfb));\n TreeSet<Period> periods = new TreeSet<Period>();\n Iterator fbit = ic.iterator();\n while (fbit.hasNext()) {\n Object o = fbit.next();\n if (o instanceof BwFreeBusy) {\n BwFreeBusy fb = (BwFreeBusy)o;\n Collection<BwFreeBusyComponent> times = fb.getTimes();\n if (times != null) {\n for (BwFreeBusyComponent fbcomp: times) {\n if (fbcomp.getType() != BwFreeBusyComponent.typeFree) {\n throw WebdavIntfException.serverError();\n }\n for (Period p: fbcomp.getPeriods()) {\n periods.add(p);\n }\n }\n }\n }\n }\n BwFreeBusy fb = new BwFreeBusy();\n fb.setDtstart(start);\n fb.setDtend(end);\n BwFreeBusyComponent fbcomp = new BwFreeBusyComponent();\n fb.addTime(fbcomp);\n fbcomp.setType(BwFreeBusyComponent.typeBusy);\n DateTime bstart = (DateTime)start.makeDate();\n Iterator pit = periods.iterator();\n while (pit.hasNext()) {\n Period p = (Period)pit.next();\n if (!bstart.equals(p.getStart())) {\n Period busyp = new Period(bstart, p.getStart());\n fbcomp.addPeriod(busyp);\n }\n bstart = p.getEnd();\n }\n DateTime bend = (DateTime)end.makeDate();\n if (!bstart.equals(bend)) {\n Period busyp = new Period(bstart, bend);\n fbcomp.addPeriod(busyp);\n }\n return fb;\n } catch (WebdavIntfException wie) {\n throw wie;\n } catch (Throwable t) {\n throw new WebdavIntfException(t);\n }\n }\n"} {"input": " public static void copyExtendedInfo(ModelItem[] items) {\n if (items == null && items.length == 0) {\n return;\n }\n String keyNotAvailableMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.keyNotAvailableYet\");\n String fileMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.file\")+\" \";\n String keyMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.key\")+\" \";\n String bytesMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.bytes\")+\" \";\n StringBuilder textToCopy = new StringBuilder();\n CopyToClipboardItem item;\n for (ModelItem ditem : items) {\n if( !(ditem instanceof CopyToClipboardItem) ) {\n continue;\n }\n item = (CopyToClipboardItem) ditem;\n String key = item.getKey();\n if (key == null) {\n key = keyNotAvailableMessage;\n } else {\n key = key + item.getFilename(); \n }\n String fs;\n if( item.getFileSize() < 0 ) {\n fs = \"?\";\n } else {\n fs = Long.toString(item.getFileSize());\n }\n textToCopy.append(fileMessage);\n textToCopy.append(item.getFilename()).append(\"\\n\");\n textToCopy.append(keyMessage);\n textToCopy.append(key).append(\"\\n\");\n textToCopy.append(bytesMessage);\n textToCopy.append(fs).append(\"\\n\\n\");\n } \n textToCopy.deleteCharAt(textToCopy.length() - 1);\n StringSelection selection = new StringSelection(textToCopy.toString());\n getClipboard().setContents(selection, dummyClipboardOwner); \n }\n", "output": " public static void copyExtendedInfo(ModelItem[] items) {\n if (items == null && items.length == 0) {\n return;\n }\n String keyNotAvailableMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.keyNotAvailableYet\");\n String fileMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.file\")+\" \";\n String keyMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.key\")+\" \";\n String bytesMessage = Language.getInstance().getString(\"Common.copyToClipBoard.extendedInfo.bytes\")+\" \";\n StringBuilder textToCopy = new StringBuilder();\n CopyToClipboardItem item;\n for (ModelItem ditem : items) {\n if( !(ditem instanceof CopyToClipboardItem) ) {\n continue;\n }\n item = (CopyToClipboardItem) ditem;\n String key = item.getKey();\n if (key == null) {\n key = keyNotAvailableMessage;\n } else {\n key = new StringBuffer().append(key).append(\"/\").append(item.getFilename()).toString();\n }\n String fs;\n if( item.getFileSize() < 0 ) {\n fs = \"?\";\n } else {\n fs = Long.toString(item.getFileSize());\n }\n textToCopy.append(fileMessage);\n textToCopy.append(item.getFilename()).append(\"\\n\");\n textToCopy.append(keyMessage);\n textToCopy.append(key).append(\"\\n\");\n textToCopy.append(bytesMessage);\n textToCopy.append(fs).append(\"\\n\\n\");\n } \n textToCopy.deleteCharAt(textToCopy.length() - 1);\n StringSelection selection = new StringSelection(textToCopy.toString());\n getClipboard().setContents(selection, dummyClipboardOwner); \n }\n"} {"input": "\tpublic void doFilter(ServletRequest request, ServletResponse response,\n\t\t\tFilterChain chain) throws IOException, ServletException {\n\t\tHttpServletRequest req = (HttpServletRequest) request;\n\t\tHttpServletResponse resp = (HttpServletResponse) response;\n\t\tString uri = req.getRequestURI();\n\t\tif (!uri.contains(\"/servlet/admin/media/\")) {\n\t\t\tchain.doFilter(request, response);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tPhotoService photoService = getSpringContext().getBean(\"photoServiceImpl\", PhotoServiceImpl.class);\n\t\t\tString path = uri.substring(uri.indexOf(\"/servlet/admin/media/\") + \"/servlet/admin/media/\".length(), uri.length());\n\t\t\tString scalerType = SimpleServletRequestUtils.getStringParameter(req, \"scalerType\", null);\n\t\t\tint width = SimpleServletRequestUtils.getIntParameter(req, \"width\", 0);\n\t\t\tint hight = SimpleServletRequestUtils.getIntParameter(req, \"hight\", 0);\n\t\t\tbyte[] photoStream = null;\n\t\t\tif (StringUtils.isBlank(scalerType)) {\n\t\t\t\tphotoStream = photoService.getPhoto(path, width, hight);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tPhotoScalerType photoScalerType = PhotoScalerType.valueOf(scalerType);\n\t\t\t\t\tphotoStream = photoService.getPhoto(path, photoScalerType);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tphotoStream = photoService.getPhoto(path, -1, -1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tString suffix = path.substring(path.lastIndexOf(\".\") + 1, path.length());\n\t\t\tresp.setHeader(\"Cache-Control\", \"max-age=3600, must-revalidate\");\n\t\t\tresp.setContentType(\"image/\" + mimeTable.get(suffix.toUpperCase()));\n\t\t\tresp.setCharacterEncoding(\"UTF-8\");\n\t\t\tServletOutputStream out = resp.getOutputStream();\n\t\t\tout.write(photoStream);\n\t\t\tout.close();\n\t\t\treturn;\n\t\t} catch (Exception ex) {\n\t\t\tlogger.error(\"Can not find the media item[\" + uri + \"]\", ex);\n\t\t\tchain.doFilter(request, response);\n\t\t}\n\t}\n", "output": "\tpublic void doFilter(ServletRequest request, ServletResponse response,\n\t\t\tFilterChain chain) throws IOException, ServletException {\n\t\tHttpServletRequest req = (HttpServletRequest) request;\n\t\tHttpServletResponse resp = (HttpServletResponse) response;\n\t\tString uri = req.getRequestURI();\n\t\tif (!uri.contains(\"/servlet/media/\")) {\n\t\t\tchain.doFilter(request, response);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tPhotoService photoService = getSpringContext().getBean(\"photoServiceImpl\", PhotoServiceImpl.class);\n\t\t\tString path = uri.substring(uri.indexOf(\"/servlet/media/\") + \"/servlet/media/\".length(), uri.length());\n\t\t\tString scalerType = SimpleServletRequestUtils.getStringParameter(req, \"scalerType\", null);\n\t\t\tint width = SimpleServletRequestUtils.getIntParameter(req, \"width\", 0);\n\t\t\tint hight = SimpleServletRequestUtils.getIntParameter(req, \"hight\", 0);\n\t\t\tbyte[] photoStream = null;\n\t\t\tif (StringUtils.isBlank(scalerType)) {\n\t\t\t\tphotoStream = photoService.getPhoto(path, width, hight);\n\t\t\t} else {\n\t\t\t\ttry {\n\t\t\t\t\tPhotoScalerType photoScalerType = PhotoScalerType.valueOf(scalerType);\n\t\t\t\t\tphotoStream = photoService.getPhoto(path, photoScalerType);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tphotoStream = photoService.getPhoto(path, -1, -1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tString suffix = path.substring(path.lastIndexOf(\".\") + 1, path.length());\n\t\t\tresp.setHeader(\"Cache-Control\", \"max-age=3600, must-revalidate\");\n\t\t\tresp.setContentType(\"image/\" + mimeTable.get(suffix.toUpperCase()));\n\t\t\tresp.setCharacterEncoding(\"UTF-8\");\n\t\t\tServletOutputStream out = resp.getOutputStream();\n\t\t\tout.write(photoStream);\n\t\t\tout.close();\n\t\t\treturn;\n\t\t} catch (Exception ex) {\n\t\t\tlogger.error(\"Can not find the media item[\" + uri + \"]\", ex);\n\t\t\tchain.doFilter(request, response);\n\t\t}\n\t}\n"} {"input": "\tpublic void create(KindletContext context) {\n\t\tthis.ctx = context;\n\t\tthis.root = ctx.getRootContainer();\n\t\tscreenManager = KRepaintManager.getInstance();\n\t\tget_date();\n\t\tString[] crew_list = load_list(dir.concat(\"config/crew.csv\"));\n\t\tFlight.init(crew_list);\n\t\tfmodel = new FlightModel(filename, save_date);\n\t\ttry {\n\t\t\tFont menu_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,14);\n\t\t\tFont table_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,10);\n\t\t\tFont edit_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,12);\n\t\t\tKMenu menu = new KMenu();\n\t\t\tmenu.add(\"Save\",new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tfmodel.save();\n\t\t\t\t\tKOptionPane.showMessageDialog(root,\"Data Saved\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tmenu.add(\"Sync\",new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tfmodel.save();\n\t\t\t\t\tif(python(\"sync.py\"))\n\t\t\t\t\t\tKOptionPane.showMessageDialog(root,\"Sync Completed\");\n\t\t\t\t\telse KOptionPane.showMessageDialog(root,\"Sync Failed\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tmenu.add(\"Update\",new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tfmodel.save();\n\t\t\t\t\tif(python(\"update.py\"))\n\t\t\t\t\t\tKOptionPane.showMessageDialog(root,\"Update Completed\");\n\t\t\t\t\telse KOptionPane.showMessageDialog(root,\"Update Failed\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tctx.setMenu(menu);\n\t\t\tlogs_day_info = new JLabel(date.concat(\" Flights: \") \n\t\t\t\t\t.concat(Integer.toString(fmodel.getFlightCount())));\n\t\t\tlogs_day_info.setFont(menu_font);\n\t\t\tlogs_day_info.setBorder(new LineBorder(Color.black));\n\t\t\tJPanel log = new JPanel(new BorderLayout()); \n\t\t\tlogs_cells = new JTable(fmodel);\n\t\t\tlogs_cells.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);\n\t\t\tlogs_cells.setRowSelectionAllowed(true);\n\t\t\tlogs_cells.setFont(table_font);\n\t\t\tlogs_cells.setRowHeight(29);\n\t\t\tlogs_cells.getColumnModel().getColumn(0).setPreferredWidth(50); \n\t\t\tlogs_cells.getColumnModel().getColumn(1).setPreferredWidth(306); \n\t\t\tlogs_cells.getColumnModel().getColumn(2).setPreferredWidth(130); \n\t\t\tlogs_cells.getColumnModel().getColumn(3).setPreferredWidth(50); \n\t\t\tlogs_cells.getColumnModel().getColumn(4).setPreferredWidth(50); \n\t\t\tlogs_cells.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_NORTH :\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_WEST :\n\t\t\t\t\t\t\tfmodel.next_page();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_SOUTH :\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_EAST :\n\t\t\t\t\t\t\tfmodel.prev_page();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tPoint p = e.getPoint();\n\t\t\t\t\t\t\tint row = logs_cells.rowAtPoint(p);\n\t\t\t\t\t\t\tint col = logs_cells.columnAtPoint(p);\n\t\t\t\t\t\t\tint flight_num = Integer.parseInt((String)logs_cells.getValueAt(row,0));\n\t\t\t\t\t\t\tflight = (Flight)fmodel.fdata.get(flight_num-1); \n\t\t\t\t\t\t\tflight_backup = flight.toString();\n\t\t\t\t\t\t\tswitch(col) {\n\t\t\t\t\t\t\t\tcase 0 : \n\t\t\t\t\t\t\t\t\tStringBuffer to_del = new StringBuffer();\n\t\t\t\t\t\t\t\t\tto_del.append(Integer.toString(flight_num)).append(\" ?\\n\");\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(flight.name).append('\\n');\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(flight.notes).append('\\n');\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(flight.getAltstr()).append('\\n');\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(new String(flight.work));\n\t\t\t\t\t\t\t\t\tint result = KOptionPane.showConfirmDialog(root,\n\t\t\t\t\t\t\t\t\t\t\t\"Save A copy of flight #\".concat(to_del.toString()),\n\t\t\t\t\t\t\t\t\t\t\t\"Duplication Confirmation\",\n\t\t\t\t\t\t\t\t\t\t\tKOptionPane.CANCEL_SAVE_OPTIONS);\n\t\t\t\t\t\t\t\t\tif(result!=KOptionPane.CANCEL_OPTION) {\n\t\t\t\t\t\t\t\t\t\tfmodel.addFlight((Flight)fmodel.fdata.get(flight_num-1));\n\t\t\t\t\t\t\t\t\t\tscreenManager.repaint(root,false);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tresult = KOptionPane.showConfirmDialog(root,\n\t\t\t\t\t\t\t\t\t\t\t\"**Delete** flight #\".concat(to_del.toString()),\n\t\t\t\t\t\t\t\t\t\t\t\"Deletion Confirmation\",\n\t\t\t\t\t\t\t\t\t\t\tKOptionPane.NO_YES_OPTIONS);\n\t\t\t\t\t\t\t\t\tif(result==KOptionPane.YES_OPTION) {\n\t\t\t\t\t\t\t\t\t\tfmodel.remove(flight_num);\n\t\t\t\t\t\t\t\t\t\tupdate_log();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 1 : \n\t\t\t\t\t\t\t\t\tget_name(false);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 2 : \n\t\t\t\t\t\t\t\tcase 3 : \n\t\t\t\t\t\t\t\tcase 4 : \n\t\t\t\t\t\t\t\t\tget_other(false);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault :\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_GROW :\n\t\t\t\t\t\tcase Gestures.BUTTON_SHRINK :\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP :\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tlogs_cells.getTableHeader().setBorder(new LineBorder(Color.black));\n\t\t\tlog.add(logs_cells.getTableHeader(),BorderLayout.NORTH);\n\t\t\tlog.add(logs_cells,BorderLayout.CENTER);\n\t\t\tJButton tandem = new JButton(\"Add Tandem\"); \n\t\t\ttandem.setFont(menu_font);\n\t\t\ttandem.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tint row = fmodel.fdata.indexOf(flight);\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tint pos = fmodel.fdata.size()-1;\n\t\t\t\t\t\t\twhile(pos>=0) { \n\t\t\t\t\t\t\t\tFlight cur = (Flight)fmodel.fdata.get(pos--);\n\t\t\t\t\t\t\t\tif(cur.solo==false) {\n\t\t\t\t\t\t\t\t\tfmodel.addFlight(new Flight(cur.toString()));\n\t\t\t\t\t\t\t\t\tscreenManager.repaint(root,false);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP : \n\t\t\t\t\t\t\tflight_backup = null;\n\t\t\t\t\t\t\tflight = fmodel.createFlight(false,def_crew);\n\t\t\t\t\t\t\tget_name(false);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tJButton solo = new JButton(\"Add Solo\"); \n\t\t\tsolo.setFont(menu_font);\n\t\t\tsolo.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tint row = fmodel.fdata.indexOf(flight);\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tint pos = fmodel.fdata.size()-1;\n\t\t\t\t\t\t\twhile(pos>=0) { \n\t\t\t\t\t\t\t\tFlight cur = (Flight)fmodel.fdata.get(pos--);\n\t\t\t\t\t\t\t\tif(cur.solo==true) {\n\t\t\t\t\t\t\t\t\tfmodel.addFlight(new Flight(cur.toString()));\n\t\t\t\t\t\t\t\t\tscreenManager.repaint(root,false);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP : \n\t\t\t\t\t\t\tflight_backup = null;\n\t\t\t\t\t\t\tflight = fmodel.createFlight(true,def_crew);\n\t\t\t\t\t\t\tget_name(true);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tJPanel log_buttons = new JPanel(new GridLayout(1,2)); \n\t\t\tlog_buttons.add(tandem);\n\t\t\tlog_buttons.add(solo);\n\t\t\tActionListener name_listener = new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tString name = e.getSource() instanceof JTextField ?\n\t\t\t\t\t\tname_input.getText() : ((JButton)e.getSource()).getText();\n\t\t\t\t\tif( name.equals(\"\") ) return;\n\t\t\t\t\tflight.name = name;\n\t\t\t\t\tif(flight_backup==null) get_other(true); \n\t\t\t\t\telse { \n\t\t\t\t\t\tcard.show(root, \"logs\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tname_input = new JTextField();\n\t\t\tname_input.setFont(edit_font);\n\t\t\tname_input.addActionListener(name_listener);\n\t\t\tname_input.getDocument().addDocumentListener(new DocumentListener() {\n\t\t\t\tpublic void changedUpdate(DocumentEvent e) { textValueChanged(e); }\n\t\t\t\tpublic void insertUpdate(DocumentEvent e) { textValueChanged(e); }\n\t\t\t\tpublic void removeUpdate(DocumentEvent e) { textValueChanged(e); }\n\t\t\t\tpublic void textValueChanged(DocumentEvent e) {\n\t\t\t\t\tProcess match = null;\n\t\t\t\t\tBufferedReader matches = null;\n\t\t\t\t\tif(name_input.getText().equals(\"\")) {\n\t\t\t\t\t\tmod_recent_names();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tString[] cmd = {\"/bin/sh\", dir.concat(\".dropbox/match_\")\n\t\t\t\t\t\t.concat(flight.solo?\"solo\":\"tandem\"),name_input.getText()};\n\t\t\t\t\ttry { \n\t\t\t\t\t\tmatch = Runtime.getRuntime().exec(cmd);\n\t\t\t\t\t\tmatches = new BufferedReader(new InputStreamReader(match.getInputStream()));\n\t\t\t\t\t\tString line; int i=0; Component[] buts = name_buttons.getComponents();\n\t\t\t\t\t\twhile((line=matches.readLine())!=null) {\n\t\t\t\t\t\t\tbuts[i].setEnabled(true);\n\t\t\t\t\t\t\t((JButton)buts[i]).setText(line);\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmatches.close();\n\t\t\t\t\t\twhile(i<buts.length) {\n\t\t\t\t\t\t\tbuts[i++].setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tscreenManager.repaint(name_buttons,false);\n\t\t\t\t\t} \n\t\t\t\t\tcatch(IOException x) { x.printStackTrace();}\n\t\t\t\t}\n\t\t\t});\n\t\t\tOnscreenKeyboardUtil.configure(name_input, OnscreenKeyboardUtil.KEYBOARD_MODE_INIT_CAP_ONCE);\n\t\t\tJButton name_cancel = new JButton(\"Cancel\");\n\t\t\tname_cancel.setFont(edit_font);\n\t\t\tname_cancel.addActionListener(new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tcard.show(root, \"logs\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tJPanel name_head = new JPanel(new BorderLayout());\n\t\t\tname_head.add(name_input, BorderLayout.CENTER);\n\t\t\tname_head.add(name_cancel, BorderLayout.EAST);\n\t\t\tname_buttons = new JPanel(new GridLayout(10,1));\n\t\t\tfor(int i=0;i<10;i++) {\n\t\t\t\tJButton but = new JButton();\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.addActionListener(name_listener);\n\t\t\t\tname_buttons.add(but);\n\t\t\t}\n\t\t\tJLabel name_keyboard_space = new JLabel(\"Keyboard Space\",JLabel.CENTER);\n\t\t\tname_keyboard_space.setPreferredSize(ctx.getOnscreenKeyboardManager().getSize());\n\t\t\tString[] alt_button_text = {\"X\",\"Pat\",\"2500\",\"3500\",\"Mile\",\"10k\"}; \n\t\t\talt_buttons = new JPanel();\n\t\t\tfor(int i=0;i<alt_button_text.length;i++){\n\t\t\t\tJButton but = new JButton(alt_button_text[i]);\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.addActionListener(new ActionListener() {\n\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\tint alt = flight.alt;\n\t\t\t\t\t\talt_buttons.getComponent(alt).setEnabled(true);\n\t\t\t\t\t\tJButton but = (JButton)e.getSource(); \n\t\t\t\t\t\tmod_alt_button(but.getText().charAt(0),false);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\talt_buttons.add(but);\n\t\t\t}\n\t\t\tString[] tandem_list = load_list(dir.concat(\"config/notes.tandem.csv\"));\n\t\t\tString[] solo_list = load_list(dir.concat(\"config/notes.solo.csv\"));\n\t\t\tnotes_tandem = new JPanel(); \n\t\t\tnotes_solo = new JPanel();\n\t\t\tfor(int i=0;i<tandem_list.length;i++) {\n\t\t\t\tJCheckBox but = new JCheckBox(tandem_list[i],false);\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.setPreferredSize(new Dimension(200,50));\n\t\t\t\tnotes_tandem.add(but);\n\t\t\t}\n\t\t\tfor(int i=0;i<solo_list.length;i++) {\n\t\t\t\tJCheckBox but = new JCheckBox(solo_list[i],false);\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.setPreferredSize(new Dimension(200,50));\n\t\t\t\tnotes_solo.add(but);\n\t\t\t}\n\t\t\tcard_notes = new CardLayout();\n\t\t\tnotes = new JPanel();\n\t\t\tnotes.setLayout(card_notes);\n\t\t\tnotes.add(notes_tandem, \"tandem\");\n\t\t\tnotes.add(notes_solo, \"solo\");\n\t\t\twork_tug = new JPanel(new GridLayout(crew_list.length,1));\n\t\t\twork_tug.add(new JLabel(\"Tug\"));\n\t\t\twork_tug.add(new JLabel());\n\t\t\twork_crew = new JPanel(new GridLayout(crew_list.length,1));\n\t\t\twork_crew.add(new JLabel(\"Crew\"));\n\t\t\twork_tandem = new JPanel(new GridLayout(crew_list.length,1));\n\t\t\twork_tandem.add(new JLabel(\"Tan\"));\n\t\t\twork_tandem.add(new JLabel());\n\t\t\tfor(int i=1;i<crew_list.length;i++) {\n\t\t\t\tJButton worker;\n\t\t\t\tString initial = crew_list[i].substring(0,1);\n\t\t\t\tchar def_char = crew_list[i].charAt(2);\n\t\t\t\tif(def_char=='@') { \n\t\t\t\t\tdef_crew[2]=initial.charAt(0);\n\t\t\t\t}\n\t\t\t\telse if(def_char=='*') { \n\t\t\t\t\tdef_crew[0]=initial.charAt(0);\n\t\t\t\t}\n\t\t\t\tint index = crew_list[i].lastIndexOf(\",\");\n\t\t\t\tif(crew_list[i].charAt(index+1)=='1') {\n\t\t\t\t\tworker = new JButton(initial); worker.setFont(edit_font); work_crew.add(worker);\n\t\t\t\t\tworker.addActionListener(new ActionListener() {\n\t\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\twork_crew_but.setEnabled(true);\n\t\t\t\t\t\t\twork_crew_but = (JButton)e.getSource();\n\t\t\t\t\t\t\tflight.work[1] = work_crew_but.getText().charAt(0);\n\t\t\t\t\t\t\twork_crew_but.setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif(crew_list[i].charAt(index-3)=='1') {\n\t\t\t\t\tworker = new JButton(initial); worker.setFont(edit_font); work_tug.add(worker);\n\t\t\t\t\tworker.addActionListener(new ActionListener() {\n\t\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\twork_tug_but.setEnabled(true);\n\t\t\t\t\t\t\twork_tug_but = (JButton)e.getSource();\n\t\t\t\t\t\t\tflight.work[0] = work_tug_but.getText().charAt(0);\n\t\t\t\t\t\t\twork_tug_but.setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif(crew_list[i].charAt(index-1)=='1') {\n\t\t\t\t\tworker = new JButton(initial); worker.setFont(edit_font); work_tandem.add(worker);\n\t\t\t\t\tworker.addActionListener(new ActionListener() {\n\t\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\twork_tandem_but.setEnabled(true);\n\t\t\t\t\t\t\twork_tandem_but = (JButton)e.getSource();\n\t\t\t\t\t\t\tflight.work[2] = work_tandem_but.getText().charAt(0);\n\t\t\t\t\t\t\twork_tandem_but.setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tJPanel work_logs = new JPanel(new FlowLayout(FlowLayout.CENTER,30,0));\n\t\t\twork_logs.add(work_tug);\n\t\t\twork_logs.add(work_crew);\n\t\t\twork_logs.add(work_tandem);\n\t\t\tJPanel other_center = new JPanel(new GridLayout(1,2)); \n\t\t\tother_center.add(notes);\n\t\t\tother_center.add(work_logs);\n\t\t\tJButton other_save = new JButton(\"Save (Hold to Cancel)\"); \n\t\t\tother_save.setFont(menu_font);\n\t\t\tother_save.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tint row = fmodel.fdata.indexOf(flight);\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tif(flight_backup!=null)\n\t\t\t\t\t\t\t\tfmodel.fdata.set(row,new Flight(flight_backup));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP : \n\t\t\t\t\t\t\tStringBuffer new_notes = new StringBuffer();\n\t\t\t\t\t\t\tComponent[] buts = flight.solo ?\n\t\t\t\t\t\t\t\tnotes_solo.getComponents():\n\t\t\t\t\t\t\t\tnotes_tandem.getComponents();\n\t\t\t\t\t\t\tfor(int i=0;i<buts.length;i++) {\n\t\t\t\t\t\t\t\tJCheckBox but = (JCheckBox)buts[i];\n\t\t\t\t\t\t\t\tif(but.isSelected())\n\t\t\t\t\t\t\t\t\tnew_notes.append(but.getText()).append(\"/\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(new_notes.length() > 0)\n\t\t\t\t\t\t\t\tflight.notes = new_notes.deleteCharAt(new_notes.length()-1).toString();\n\t\t\t\t\t\t\tif(flight_backup==null) {\n\t\t\t\t\t\t\t\tfmodel.addFlight(flight);\n\t\t\t\t\t\t\t\tupdate_log();\n\t\t\t\t\t\t\t} else fmodel.update_row(row);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcard.show(root,\"logs\");\n\t\t\t\t\talt_buttons.getComponent(flight.alt).setEnabled(true);\n\t\t\t\t\twork_tug_but.setEnabled(true);\n\t\t\t\t\twork_crew_but.setEnabled(true);\n\t\t\t\t\tif(!flight.solo) work_tandem_but.setEnabled(true);\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tJPanel log_card = new JPanel(new BorderLayout());\n\t\t\tlog_card.add(logs_day_info, BorderLayout.NORTH);\n\t\t\tlog_card.add(log, BorderLayout.CENTER);\n\t\t\tlog_card.add(log_buttons, BorderLayout.SOUTH);\n\t\t\tJPanel name_card = new JPanel(new BorderLayout());\n\t\t\tname_card.add(name_head, BorderLayout.NORTH);\n\t\t\tname_card.add(name_buttons, BorderLayout.CENTER);\n\t\t\tname_card.add(name_keyboard_space, BorderLayout.SOUTH);\n\t\t\tJPanel other_card = new JPanel(new BorderLayout());\n\t\t\tother_card.add(alt_buttons, BorderLayout.NORTH);\n\t\t\tother_card.add(other_center, BorderLayout.CENTER);\n\t\t\tother_card.add(other_save, BorderLayout.SOUTH);\n\t\t\tcard = new CardLayout();\n\t\t\troot.setLayout(card);\n\t\t\troot.add(log_card,\"logs\");\n\t\t\troot.add(name_card,\"name\");\n\t\t\troot.add(other_card,\"other\");\n\t\t} catch (Throwable t) {\n\t\t\tt.printStackTrace();\n\t\t}\n\t}\n", "output": "\tpublic void create(KindletContext context) {\n\t\tthis.ctx = context;\n\t\tthis.root = ctx.getRootContainer();\n\t\tscreenManager = KRepaintManager.getInstance();\n\t\tget_date();\n\t\tString[] crew_list = load_list(dir.concat(\"config/crew.csv\"));\n\t\tFlight.init(crew_list);\n\t\tfmodel = new FlightModel(filename, save_date);\n\t\ttry {\n\t\t\tFont menu_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,14);\n\t\t\tFont table_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,10);\n\t\t\tFont edit_font = ctx.getUIResources().getFont(KFontFamilyName.MONOSPACE,12);\n\t\t\tKMenu menu = new KMenu();\n\t\t\tmenu.add(\"Save\",new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tfmodel.save();\n\t\t\t\t\tKOptionPane.showMessageDialog(root,\"Data Saved\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tmenu.add(\"Sync\",new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tfmodel.save();\n\t\t\t\t\tif(python(\"sync.py\"))\n\t\t\t\t\t\tKOptionPane.showMessageDialog(root,\"Sync Completed\");\n\t\t\t\t\telse KOptionPane.showMessageDialog(root,\"Sync Failed\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tmenu.add(\"Update\",new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tfmodel.save();\n\t\t\t\t\tif(python(\"update.py\"))\n\t\t\t\t\t\tKOptionPane.showMessageDialog(root,\"Update Completed\");\n\t\t\t\t\telse KOptionPane.showMessageDialog(root,\"Update Failed\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tctx.setMenu(menu);\n\t\t\tlogs_day_info = new JLabel(date.concat(\" Flights: \") \n\t\t\t\t\t.concat(Integer.toString(fmodel.getFlightCount())));\n\t\t\tlogs_day_info.setFont(menu_font);\n\t\t\tlogs_day_info.setBorder(new LineBorder(Color.black));\n\t\t\tJPanel log = new JPanel(new BorderLayout()); \n\t\t\tlogs_cells = new JTable(fmodel);\n\t\t\tlogs_cells.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);\n\t\t\tlogs_cells.setRowSelectionAllowed(true);\n\t\t\tlogs_cells.setFont(table_font);\n\t\t\tlogs_cells.setRowHeight(29);\n\t\t\tlogs_cells.getColumnModel().getColumn(0).setPreferredWidth(50); \n\t\t\tlogs_cells.getColumnModel().getColumn(1).setPreferredWidth(306); \n\t\t\tlogs_cells.getColumnModel().getColumn(2).setPreferredWidth(130); \n\t\t\tlogs_cells.getColumnModel().getColumn(3).setPreferredWidth(50); \n\t\t\tlogs_cells.getColumnModel().getColumn(4).setPreferredWidth(50); \n\t\t\tlogs_cells.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_NORTH :\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_WEST :\n\t\t\t\t\t\t\tfmodel.next_page();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_SOUTH :\n\t\t\t\t\t\tcase Gestures.BUTTON_FLICK_EAST :\n\t\t\t\t\t\t\tfmodel.prev_page();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tPoint p = e.getPoint();\n\t\t\t\t\t\t\tint row = logs_cells.rowAtPoint(p);\n\t\t\t\t\t\t\tint col = logs_cells.columnAtPoint(p);\n\t\t\t\t\t\t\tint flight_num = Integer.parseInt((String)logs_cells.getValueAt(row,0));\n\t\t\t\t\t\t\tflight = (Flight)fmodel.fdata.get(flight_num-1); \n\t\t\t\t\t\t\tflight_backup = flight.toString();\n\t\t\t\t\t\t\tswitch(col) {\n\t\t\t\t\t\t\t\tcase 0 : \n\t\t\t\t\t\t\t\t\tStringBuffer to_del = new StringBuffer();\n\t\t\t\t\t\t\t\t\tto_del.append(Integer.toString(flight_num)).append(\" ?\\n\");\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(flight.name).append('\\n');\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(flight.notes).append('\\n');\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(flight.getAltstr()).append('\\n');\n\t\t\t\t\t\t\t\t\tto_del.append(' ').append(new String(flight.work));\n\t\t\t\t\t\t\t\t\tint result = KOptionPane.showConfirmDialog(root,\n\t\t\t\t\t\t\t\t\t\t\t\"Save A copy of flight #\".concat(to_del.toString()),\n\t\t\t\t\t\t\t\t\t\t\t\"Duplication Confirmation\",\n\t\t\t\t\t\t\t\t\t\t\tKOptionPane.CANCEL_SAVE_OPTIONS);\n\t\t\t\t\t\t\t\t\tif(result!=KOptionPane.CANCEL_OPTION) {\n\t\t\t\t\t\t\t\t\t\tfmodel.addFlight((Flight)fmodel.fdata.get(flight_num-1));\n\t\t\t\t\t\t\t\t\t\tscreenManager.repaint(root,false);\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tresult = KOptionPane.showConfirmDialog(root,\n\t\t\t\t\t\t\t\t\t\t\t\"**Delete** flight #\".concat(to_del.toString()),\n\t\t\t\t\t\t\t\t\t\t\t\"Deletion Confirmation\",\n\t\t\t\t\t\t\t\t\t\t\tKOptionPane.NO_YES_OPTIONS);\n\t\t\t\t\t\t\t\t\tif(result==KOptionPane.YES_OPTION) {\n\t\t\t\t\t\t\t\t\t\tfmodel.remove(flight_num);\n\t\t\t\t\t\t\t\t\t\tupdate_log();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 1 : \n\t\t\t\t\t\t\t\t\tget_name(false);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tcase 2 : \n\t\t\t\t\t\t\t\tcase 3 : \n\t\t\t\t\t\t\t\tcase 4 : \n\t\t\t\t\t\t\t\t\tget_other(false);\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\tdefault :\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_GROW :\n\t\t\t\t\t\tcase Gestures.BUTTON_SHRINK :\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP :\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tlogs_cells.getTableHeader().setBorder(new LineBorder(Color.black));\n\t\t\tlog.add(logs_cells.getTableHeader(),BorderLayout.NORTH);\n\t\t\tlog.add(logs_cells,BorderLayout.CENTER);\n\t\t\tJButton tandem = new JButton(\"Add Tandem\"); \n\t\t\ttandem.setFont(menu_font);\n\t\t\ttandem.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tint row = fmodel.fdata.indexOf(flight);\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tint pos = fmodel.fdata.size()-1;\n\t\t\t\t\t\t\twhile(pos>=0) { \n\t\t\t\t\t\t\t\tFlight cur = (Flight)fmodel.fdata.get(pos--);\n\t\t\t\t\t\t\t\tif(cur.solo==false) {\n\t\t\t\t\t\t\t\t\tfmodel.addFlight(new Flight(cur.toString()));\n\t\t\t\t\t\t\t\t\tscreenManager.repaint(root,false);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP : \n\t\t\t\t\t\t\tflight_backup = null;\n\t\t\t\t\t\t\tflight = fmodel.createFlight(false,def_crew);\n\t\t\t\t\t\t\tget_name(false);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tJButton solo = new JButton(\"Add Solo\"); \n\t\t\tsolo.setFont(menu_font);\n\t\t\tsolo.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tint row = fmodel.fdata.indexOf(flight);\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tint pos = fmodel.fdata.size()-1;\n\t\t\t\t\t\t\twhile(pos>=0) { \n\t\t\t\t\t\t\t\tFlight cur = (Flight)fmodel.fdata.get(pos--);\n\t\t\t\t\t\t\t\tif(cur.solo==true) {\n\t\t\t\t\t\t\t\t\tfmodel.addFlight(new Flight(cur.toString()));\n\t\t\t\t\t\t\t\t\tscreenManager.repaint(root,false);\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP : \n\t\t\t\t\t\t\tflight_backup = null;\n\t\t\t\t\t\t\tflight = fmodel.createFlight(true,def_crew);\n\t\t\t\t\t\t\tget_name(true);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tJPanel log_buttons = new JPanel(new GridLayout(1,2)); \n\t\t\tlog_buttons.add(tandem);\n\t\t\tlog_buttons.add(solo);\n\t\t\tActionListener name_listener = new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tString name = e.getSource() instanceof JTextField ?\n\t\t\t\t\t\tname_input.getText() : ((JButton)e.getSource()).getText();\n\t\t\t\t\tif( name.equals(\"\") ) return;\n\t\t\t\t\tflight.name = name;\n\t\t\t\t\tif(flight_backup==null) get_other(true); \n\t\t\t\t\telse { \n\t\t\t\t\t\tcard.show(root, \"logs\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tname_input = new JTextField();\n\t\t\tname_input.setFont(edit_font);\n\t\t\tname_input.addActionListener(name_listener);\n\t\t\tname_input.getDocument().addDocumentListener(new DocumentListener() {\n\t\t\t\tpublic void changedUpdate(DocumentEvent e) { textValueChanged(e); }\n\t\t\t\tpublic void insertUpdate(DocumentEvent e) { textValueChanged(e); }\n\t\t\t\tpublic void removeUpdate(DocumentEvent e) { textValueChanged(e); }\n\t\t\t\tpublic void textValueChanged(DocumentEvent e) {\n\t\t\t\t\tProcess match = null;\n\t\t\t\t\tBufferedReader matches = null;\n\t\t\t\t\tif(name_input.getText().equals(\"\")) {\n\t\t\t\t\t\tmod_recent_names();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tString[] cmd = {\"/bin/sh\", dir.concat(\".dropbox/match_\")\n\t\t\t\t\t\t.concat(flight.solo?\"solo\":\"tandem\"),name_input.getText()};\n\t\t\t\t\ttry { \n\t\t\t\t\t\tmatch = Runtime.getRuntime().exec(cmd);\n\t\t\t\t\t\tmatches = new BufferedReader(new InputStreamReader(match.getInputStream()));\n\t\t\t\t\t\tString line; int i=0; Component[] buts = name_buttons.getComponents();\n\t\t\t\t\t\twhile((line=matches.readLine())!=null) {\n\t\t\t\t\t\t\tbuts[i].setEnabled(true);\n\t\t\t\t\t\t\t((JButton)buts[i]).setText(line);\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmatches.close();\n\t\t\t\t\t\twhile(i<buts.length) {\n\t\t\t\t\t\t\tbuts[i++].setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tscreenManager.repaint(name_buttons,false);\n\t\t\t\t\t} \n\t\t\t\t\tcatch(IOException x) { x.printStackTrace();}\n\t\t\t\t}\n\t\t\t});\n\t\t\tOnscreenKeyboardUtil.configure(name_input, OnscreenKeyboardUtil.KEYBOARD_MODE_INIT_CAP_ONCE);\n\t\t\tJButton name_cancel = new JButton(\"Cancel\");\n\t\t\tname_cancel.setFont(edit_font);\n\t\t\tname_cancel.addActionListener(new ActionListener() {\n\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\tcard.show(root, \"logs\");\n\t\t\t\t}\n\t\t\t});\n\t\t\tJPanel name_head = new JPanel(new BorderLayout());\n\t\t\tname_head.add(name_input, BorderLayout.CENTER);\n\t\t\tname_head.add(name_cancel, BorderLayout.EAST);\n\t\t\tname_buttons = new JPanel(new GridLayout(10,1));\n\t\t\tfor(int i=0;i<10;i++) {\n\t\t\t\tJButton but = new JButton();\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.addActionListener(name_listener);\n\t\t\t\tname_buttons.add(but);\n\t\t\t}\n\t\t\tJLabel name_keyboard_space = new JLabel(\"Keyboard Space\",JLabel.CENTER);\n\t\t\tname_keyboard_space.setPreferredSize(ctx.getOnscreenKeyboardManager().getSize());\n\t\t\tString[] alt_button_text = {\"X\",\"Pat\",\"2500\",\"3500\",\"Mile\",\"10k\"}; \n\t\t\talt_buttons = new JPanel();\n\t\t\tfor(int i=0;i<alt_button_text.length;i++){\n\t\t\t\tJButton but = new JButton(alt_button_text[i]);\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.addActionListener(new ActionListener() {\n\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\tint alt = flight.alt;\n\t\t\t\t\t\talt_buttons.getComponent(alt).setEnabled(true);\n\t\t\t\t\t\tJButton but = (JButton)e.getSource(); \n\t\t\t\t\t\tmod_alt_button(but.getText().charAt(0),false);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\talt_buttons.add(but);\n\t\t\t}\n\t\t\tString[] tandem_list = load_list(dir.concat(\"config/notes.tandem.csv\"));\n\t\t\tString[] solo_list = load_list(dir.concat(\"config/notes.solo.csv\"));\n\t\t\tnotes_tandem = new JPanel(); \n\t\t\tnotes_solo = new JPanel();\n\t\t\tfor(int i=0;i<tandem_list.length;i++) {\n\t\t\t\tJCheckBox but = new JCheckBox(tandem_list[i],false);\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.setPreferredSize(new Dimension(200,50));\n\t\t\t\tnotes_tandem.add(but);\n\t\t\t}\n\t\t\tfor(int i=0;i<solo_list.length;i++) {\n\t\t\t\tJCheckBox but = new JCheckBox(solo_list[i],false);\n\t\t\t\tbut.setFont(edit_font);\n\t\t\t\tbut.setPreferredSize(new Dimension(200,50));\n\t\t\t\tnotes_solo.add(but);\n\t\t\t}\n\t\t\tcard_notes = new CardLayout();\n\t\t\tnotes = new JPanel();\n\t\t\tnotes.setLayout(card_notes);\n\t\t\tnotes.add(notes_tandem, \"tandem\");\n\t\t\tnotes.add(notes_solo, \"solo\");\n\t\t\twork_tug = new JPanel(new GridLayout(crew_list.length,1));\n\t\t\twork_tug.add(new JLabel(\"Tug\"));\n\t\t\twork_tug.add(new JLabel());\n\t\t\twork_crew = new JPanel(new GridLayout(crew_list.length,1));\n\t\t\twork_crew.add(new JLabel(\"Crew\"));\n\t\t\twork_tandem = new JPanel(new GridLayout(crew_list.length,1));\n\t\t\twork_tandem.add(new JLabel(\"Tan\"));\n\t\t\twork_tandem.add(new JLabel());\n\t\t\tfor(int i=1;i<crew_list.length;i++) {\n\t\t\t\tJButton worker;\n\t\t\t\tString initial = crew_list[i].substring(0,1);\n\t\t\t\tchar def_char = crew_list[i].charAt(2);\n\t\t\t\tif(def_char=='@') { \n\t\t\t\t\tdef_crew[2]=initial.charAt(0);\n\t\t\t\t}\n\t\t\t\telse if(def_char=='*') { \n\t\t\t\t\tdef_crew[0]=initial.charAt(0);\n\t\t\t\t}\n\t\t\t\tint index = crew_list[i].lastIndexOf(\",\");\n\t\t\t\tif(crew_list[i].charAt(index+1)=='1') {\n\t\t\t\t\tworker = new JButton(initial); worker.setFont(edit_font); work_crew.add(worker);\n\t\t\t\t\tworker.addActionListener(new ActionListener() {\n\t\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\twork_crew_but.setEnabled(true);\n\t\t\t\t\t\t\twork_crew_but = (JButton)e.getSource();\n\t\t\t\t\t\t\tflight.work[1] = work_crew_but.getText().charAt(0);\n\t\t\t\t\t\t\twork_crew_but.setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif(crew_list[i].charAt(index-3)=='1') {\n\t\t\t\t\tworker = new JButton(initial); worker.setFont(edit_font); work_tug.add(worker);\n\t\t\t\t\tworker.addActionListener(new ActionListener() {\n\t\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\twork_tug_but.setEnabled(true);\n\t\t\t\t\t\t\twork_tug_but = (JButton)e.getSource();\n\t\t\t\t\t\t\tflight.work[0] = work_tug_but.getText().charAt(0);\n\t\t\t\t\t\t\twork_tug_but.setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif(crew_list[i].charAt(index-1)=='1') {\n\t\t\t\t\tworker = new JButton(initial); worker.setFont(edit_font); work_tandem.add(worker);\n\t\t\t\t\tworker.addActionListener(new ActionListener() {\n\t\t\t\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\t\t\t\twork_tandem_but.setEnabled(true);\n\t\t\t\t\t\t\twork_tandem_but = (JButton)e.getSource();\n\t\t\t\t\t\t\tflight.work[2] = work_tandem_but.getText().charAt(0);\n\t\t\t\t\t\t\twork_tandem_but.setEnabled(false);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tJPanel work_logs = new JPanel(new FlowLayout(FlowLayout.CENTER,30,0));\n\t\t\twork_logs.add(work_tug);\n\t\t\twork_logs.add(work_crew);\n\t\t\twork_logs.add(work_tandem);\n\t\t\tJPanel other_center = new JPanel(new GridLayout(1,2)); \n\t\t\tother_center.add(notes);\n\t\t\tother_center.add(work_logs);\n\t\t\tJButton other_save = new JButton(\"Save (Hold to Cancel)\"); \n\t\t\tother_save.setFont(menu_font);\n\t\t\tother_save.addMouseListener(new MouseListener() {\n\t\t\t\tpublic void mouseClicked(MouseEvent e) {\n\t\t\t\t\tint row = fmodel.fdata.indexOf(flight);\n\t\t\t\t\tswitch(e.getButton()) {\n\t\t\t\t\t\tcase Gestures.BUTTON_HOLD : \n\t\t\t\t\t\t\tif(flight_backup!=null)\n\t\t\t\t\t\t\t\tfmodel.fdata.set(row,new Flight(flight_backup));\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase Gestures.BUTTON_TAP : \n\t\t\t\t\t\t\tStringBuffer new_notes = new StringBuffer();\n\t\t\t\t\t\t\tComponent[] buts = flight.solo ?\n\t\t\t\t\t\t\t\tnotes_solo.getComponents():\n\t\t\t\t\t\t\t\tnotes_tandem.getComponents();\n\t\t\t\t\t\t\tfor(int i=0;i<buts.length;i++) {\n\t\t\t\t\t\t\t\tJCheckBox but = (JCheckBox)buts[i];\n\t\t\t\t\t\t\t\tif(but.isSelected())\n\t\t\t\t\t\t\t\t\tnew_notes.append(but.getText()).append(\"/\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(new_notes.length() > 0)\n\t\t\t\t\t\t\t\tflight.notes = new_notes.deleteCharAt(new_notes.length()-1).toString();\n\t\t\t\t\t\t\telse flight.notes = \"\";\n\t\t\t\t\t\t\tif(flight_backup==null) {\n\t\t\t\t\t\t\t\tfmodel.addFlight(flight);\n\t\t\t\t\t\t\t\tupdate_log();\n\t\t\t\t\t\t\t} else fmodel.update_row(row);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcard.show(root,\"logs\");\n\t\t\t\t\talt_buttons.getComponent(flight.alt).setEnabled(true);\n\t\t\t\t\twork_tug_but.setEnabled(true);\n\t\t\t\t\twork_crew_but.setEnabled(true);\n\t\t\t\t\tif(!flight.solo) work_tandem_but.setEnabled(true);\n\t\t\t\t}\n\t\t\t\tpublic void mouseReleased(MouseEvent e) { }\n\t\t\t\tpublic void mousePressed(MouseEvent e) { }\n\t\t\t\tpublic void mouseExited(MouseEvent e) { }\n\t\t\t\tpublic void mouseEntered(MouseEvent e) { }\n\t\t\t});\n\t\t\tJPanel log_card = new JPanel(new BorderLayout());\n\t\t\tlog_card.add(logs_day_info, BorderLayout.NORTH);\n\t\t\tlog_card.add(log, BorderLayout.CENTER);\n\t\t\tlog_card.add(log_buttons, BorderLayout.SOUTH);\n\t\t\tJPanel name_card = new JPanel(new BorderLayout());\n\t\t\tname_card.add(name_head, BorderLayout.NORTH);\n\t\t\tname_card.add(name_buttons, BorderLayout.CENTER);\n\t\t\tname_card.add(name_keyboard_space, BorderLayout.SOUTH);\n\t\t\tJPanel other_card = new JPanel(new BorderLayout());\n\t\t\tother_card.add(alt_buttons, BorderLayout.NORTH);\n\t\t\tother_card.add(other_center, BorderLayout.CENTER);\n\t\t\tother_card.add(other_save, BorderLayout.SOUTH);\n\t\t\tcard = new CardLayout();\n\t\t\troot.setLayout(card);\n\t\t\troot.add(log_card,\"logs\");\n\t\t\troot.add(name_card,\"name\");\n\t\t\troot.add(other_card,\"other\");\n\t\t} catch (Throwable t) {\n\t\t\tt.printStackTrace();\n\t\t}\n\t}\n"} {"input": " public Response all() {\n List<Hotel> hotels = new ArrayList<Hotel>();\n for (HotelProvider provider : providers) {\n hotels.addAll(provider.hotels());\n }\n if (app.isValid()) {\n return Render.view(\"hotel/all.xhtml\", getClass())\n .param(\"hotels\", hotels)\n .param(\"providers\", providers)\n .render();\n } else {\n return Render.view(\"hotel/none.xhtml\", getClass())\n .param(\"hotels\", hotels)\n .param(\"providers\", providers).render();\n }\n }\n", "output": " public Response all() {\n List<Hotel> hotels = new ArrayList<Hotel>();\n for (HotelProvider provider : providers) {\n hotels.addAll(provider.hotels());\n }\n if (app.isValid()) {\n return Render.view(\"hotel/all.xhtml\", getClass())\n .param(\"hotels\", hotels)\n .param(\"providers\", providers)\n .render();\n } else {\n return Render.view(\"hotel/none.xhtml\", getClass())\n .param(\"hotels\", hotels)\n .param(\"providers\", providers)\n .render();\n }\n }\n"} {"input": "\tpublic void unmanage(ProductContainer pc) {\n\t\tif (pc instanceof StorageUnit) {\n\t\t\tStorageUnit storageUnit = (StorageUnit) pc;\n\t\t\trootStorageUnits.remove(storageUnit);\n\t\t\tnameToStorageUnit.remove(storageUnit.getName());\n\t\t} else {\n\t\t\tProductGroup pg = (ProductGroup) pc;\n\t\t\tfor (StorageUnit su : rootStorageUnits) {\n\t\t\t\tif (su.containsProductGroup(pg.getName())) {\n\t\t\t\t\tsu.remove(pg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsetChanged();\n\t\tAction a = new Action(pc, ActionType.DELETE);\n\t\tthis.notifyObservers(a);\n\t}\n", "output": "\tpublic void unmanage(ProductContainer pc) {\n\t\tif (pc instanceof StorageUnit) {\n\t\t\tStorageUnit storageUnit = (StorageUnit) pc;\n\t\t\trootStorageUnits.remove(storageUnit);\n\t\t\tnameToStorageUnit.remove(storageUnit.getName());\n\t\t} else {\n\t\t\tProductGroup pg = (ProductGroup) pc;\n\t\t\tfor (StorageUnit su : rootStorageUnits) {\n\t\t\t\tif (su.containsProductGroup(pg) || su.hasDescendantProductContainer(pg)) {\n\t\t\t\t\tsu.remove(pg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsetChanged();\n\t\tAction a = new Action(pc, ActionType.DELETE);\n\t\tthis.notifyObservers(a);\n\t}\n"} {"input": "\tprotected boolean drawChild(Canvas canvas, View child, long drawingTime) {\n\t\tint saveCount = canvas.save();\n\t\tif(mIconSize==0){\n\t\t\tDrawable[] tmp=((TextView)child).getCompoundDrawables();\n\t\t\tmIconSize=tmp[1].getIntrinsicHeight()+child.getPaddingTop();\n\t\t}\n\t\tif(child.getDrawingCache()==null){\n\t\t\tchild.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_HIGH);\n\t\t\tchild.setDrawingCacheEnabled(true);\n\t\t}\n\t\tBitmap cache=child.getDrawingCache();\n\t\tif(isAnimating){\n\t\t\tpostInvalidate();\n\t\t\tif(cache!=null){\n\t\t\t\tfloat x;\n\t\t\t\tfloat y;\n\t\t\t\tint distH=(child.getLeft()+(child.getWidth()/2))-(getWidth()/2);\n\t\t\t\tint distV=(child.getTop()+(child.getHeight()/2))-(getHeight()/2);\n\t\t\t\tx=child.getLeft()+(distH*(mScaleFactor-1))*(mScaleFactor);\n\t\t\t\ty=child.getTop()+(distV*(mScaleFactor-1))*(mScaleFactor);\n\t\t\t\tfloat width=child.getWidth()*mScaleFactor;\n\t\t\t\tfloat height=(child.getHeight()-(child.getHeight()-mIconSize))*mScaleFactor;\n\t\t\t\tRect r1=new Rect(0, 0, cache.getWidth(), cache.getHeight()-(child.getHeight()-mIconSize));\n\t\t\t\tRect r2=new Rect((int)x, (int)y, (int)x+(int)width, (int)y+(int)height);\n\t\t\t\tif(shouldDrawLabels){\n\t\t\t\t\tRect rl1=new Rect(0,mIconSize,cache.getWidth(),cache.getHeight());\n\t\t\t\t\tRect rl2=new Rect(child.getLeft(),child.getTop()+mIconSize,child.getLeft()+cache.getWidth(),child.getTop()+cache.getHeight());\n\t\t\t\t\tmLabelPaint.setAlpha(mBgAlpha);\n\t\t\t\t\tcanvas.drawBitmap(cache, rl1, rl2, mLabelPaint);\n\t\t\t\t}\n\t\t\t\tcanvas.drawBitmap(cache, r1, r2, mPaint);\n\t\t\t}else{\n\t\t\t\tchild.draw(canvas);\n\t\t\t}\n\t\t}else{\n\t\t\tif(cache!=null){\n\t\t\t\tcanvas.drawBitmap(cache, child.getLeft(), child.getTop(), mPaint);\n\t\t\t}else{\n\t\t\t\tchild.draw(canvas);\n\t\t\t}\n\t\t}\n\t\tcanvas.restoreToCount(saveCount);\n\t\treturn true;\n\t}\n", "output": "\tprotected boolean drawChild(Canvas canvas, View child, long drawingTime) {\n\t\tint saveCount = canvas.save();\n\t\tif(mIconSize==0){\n\t\t\tDrawable[] tmp=((TextView)child).getCompoundDrawables();\n\t\t\tmIconSize=tmp[1].getIntrinsicHeight()+child.getPaddingTop();\n\t\t}\n\t\tif(child.getDrawingCache()==null){\n\t\t\tchild.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_HIGH);\n\t\t\tchild.setDrawingCacheEnabled(true);\n\t\t}\n\t\tBitmap cache=child.getDrawingCache();\n\t\tif(isAnimating){\n\t\t\tpostInvalidate();\n\t\t\tif(cache!=null){\n\t\t\t\tfloat x;\n\t\t\t\tfloat y;\n\t\t\t\tint distH=(child.getLeft()+(child.getWidth()/2))-(getWidth()/2);\n\t\t\t\tint distV=(child.getTop()+(child.getHeight()/2))-(getHeight()/2);\n\t\t\t\tx=child.getLeft()+(distH*(mScaleFactor-1))*(mScaleFactor);\n\t\t\t\ty=child.getTop()+(distV*(mScaleFactor-1))*(mScaleFactor);\n\t\t\t\tfloat width=child.getWidth()*mScaleFactor;\n\t\t\t\tfloat height=(child.getHeight()-(child.getHeight()-mIconSize))*mScaleFactor;\n\t\t\t\tRect r1=new Rect(0, 0, cache.getWidth(), cache.getHeight()-(child.getHeight()-mIconSize));\n\t\t\t\tRect r2=new Rect((int)x, (int)y, (int)x+(int)width, (int)y+(int)height);\n\t\t\t\tif(shouldDrawLabels){\n\t\t\t\t\tRect rl1=new Rect(0,mIconSize,cache.getWidth(),cache.getHeight());\n\t\t\t\t\tRect rl2=new Rect(child.getLeft(),child.getTop()+mIconSize,child.getLeft()+cache.getWidth(),child.getTop()+cache.getHeight());\n\t\t\t\t\tmLabelPaint.setAlpha(mBgAlpha);\n\t\t\t\t\tcanvas.drawBitmap(cache, rl1, rl2, mLabelPaint);\n\t\t\t\t}\n\t\t\t\tcanvas.drawBitmap(cache, r1, r2, mPaint);\n\t\t\t}else{\n\t\t\t\tchild.draw(canvas);\n\t\t\t}\n\t\t}else{\n\t\t\tif(cache!=null){\n\t\t\t\tmPaint.setAlpha(255);\n\t\t\t\tcanvas.drawBitmap(cache, child.getLeft(), child.getTop(), mPaint);\n\t\t\t}else{\n\t\t\t\tchild.draw(canvas);\n\t\t\t}\n\t\t}\n\t\tcanvas.restoreToCount(saveCount);\n\t\treturn true;\n\t}\n"} {"input": "\tpublic void run() {\n\t\tfor(int i =0; i < logNum; i++){\n\t\t\ttry{\n\t\t\t\tif(randomValue.nextInt(100) <= abnormalRandomValue){\n\t\t\t\t\trandomFlag = false;\n\t\t\t\t}else{\n\t\t\t\t\trandomFlag = true;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(this.logProducer.ModelParser(randomFlag, \"random\"));\n\t\t\t\tqueue.put(this.logProducer.ModelParser(false, \"random\"));\n\t\t\t} catch (Exception e){\n\t\t\t\te.printStackTrace();\n\t\t\t} \n\t\t}\n\t}\t\n", "output": "\tpublic void run() {\n\t\tfor(int i =0; i < logNum; i++){\n\t\t\ttry{\n\t\t\t\tif(randomValue.nextInt(100) <= abnormalRandomValue){\n\t\t\t\t\trandomFlag = false;\n\t\t\t\t}else{\n\t\t\t\t\trandomFlag = true;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(this.logProducer.ModelParser(randomFlag, \"random\"));\n\t\t\t} catch (Exception e){\n\t\t\t\te.printStackTrace();\n\t\t\t} \n\t\t}\n\t}\t\n"} {"input": "\tpublic static void setStyle( String name)\n\t{\n\t\tServletManager servletManager = Activator.getServletManager();\n\t\tif( name.equals( \"default\")) {\n\t\t\tservletManager.removeResource( \"/css\");\n\t\t\tservletManager.addResources(\"/css\",\"/resources/templates/layout/css\");\n\t\t\tservletManager.removeResource( \"/js\");\n\t\t\tservletManager.addResources(\"/js\",\"/resources/js\");\n\t\t\tservletManager.removeResource( \"/images\");\n\t\t\tservletManager.addResources(\"/images\", \"/resources/images\");\n\t\t\treturn;\n\t\t}\n\t\tHttpContext httpContextStyle = new HttpContextStyle( name);\n\t\ttry {\n\t\t\tJarFile styleJarFile = new JarFile( name);\n\t\t\tEnumeration<?> jarEntryEnum = styleJarFile.entries();\n\t\t\twhile (jarEntryEnum.hasMoreElements()) {\n\t\t\t\tJarEntry entry = (JarEntry) jarEntryEnum.nextElement();\n\t\t\t\tif (entry.isDirectory()) {\n\t\t\t\t\tString alias = \"/\" + entry.getName().substring( 0, entry.getName().length() - 1);\n\t\t\t\t\tservletManager.removeResource( alias);\n\t\t\t\t\tservletManager.addResources( alias, alias, httpContextStyle);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tlogger.error( \"io: \" + e);\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn;\n\t}\n", "output": "\tpublic static void setStyle( String name)\n\t{\n\t\tServletManager servletManager = Activator.getServletManager();\n\t\tif( name.equals( \"default\")) {\n\t\t\tservletManager.addResources(\"/css\",\"/resources/templates/layout/css\");\n\t\t\tservletManager.addResources(\"/js\",\"/resources/js\");\n\t\t\tservletManager.addResources(\"/images\", \"/resources/images\");\n\t\t\treturn;\n\t\t}\n\t\tHttpContext httpContextStyle = new HttpContextStyle( name);\n\t\ttry {\n\t\t\tJarFile styleJarFile = new JarFile( name);\n\t\t\tEnumeration<?> jarEntryEnum = styleJarFile.entries();\n\t\t\twhile (jarEntryEnum.hasMoreElements()) {\n\t\t\t\tJarEntry entry = (JarEntry) jarEntryEnum.nextElement();\n\t\t\t\tif (entry.isDirectory()) {\n\t\t\t\t\tString alias = \"/\" + entry.getName().substring( 0, entry.getName().length() - 1);\n\t\t\t\t\tservletManager.removeResource( alias);\n\t\t\t\t\tservletManager.addResources( alias, alias, httpContextStyle);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (IOException e) {\n\t\t\tlogger.error( \"io: \" + e);\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn;\n\t}\n"} {"input": " public static void main(String[] args) throws Exception {\n int reps = 10;\n int sets = 100;\n List<Benchmark> benchmarks = Lists.newArrayList();\n benchmarks.add(new Linpack());\n List<Benchmark.Parameterised> pBenchmarks = Lists.newArrayList();\n pBenchmarks.add(new Ddot());\n pBenchmarks.add(new Dgemm());\n for (Benchmark b : benchmarks) {\n File file = new File(getTarget(b) + \".csv\");\n log.info(\"writing to \" + file);\n @Cleanup CSVWriter csv = new CSVWriter(new FileWriter(file));\n for (int i = 0; i < reps; i++) {\n long result = b.benchmark();\n csv.writeNext(new String[]{Long.toString(result)});\n }\n }\n double factor = 6 / 100.0;\n for (Benchmark.Parameterised b : pBenchmarks) {\n File file = new File(getTarget(b) + \".csv\");\n log.info(\"writing to \" + file);\n @Cleanup CSVWriter csv = new CSVWriter(new FileWriter(file));\n for (int i = 0; i < reps; i++) {\n for (int j = sets; j > 0; j--) {\n int size = (int) Math.pow(10, factor * j);\n if (size < 10) continue;\n long result = b.benchmark(size);\n csv.writeNext(new String[]{Long.toString(result)});\n }\n }\n }\n }\n", "output": " public static void main(String[] args) throws Exception {\n int reps = 10;\n int sets = 100;\n List<Benchmark> benchmarks = Lists.newArrayList();\n benchmarks.add(new Linpack());\n List<Benchmark.Parameterised> pBenchmarks = Lists.newArrayList();\n pBenchmarks.add(new Ddot());\n pBenchmarks.add(new Dgemm());\n for (Benchmark b : benchmarks) {\n File file = new File(getTarget(b) + \".csv\");\n log.info(\"writing to \" + file);\n @Cleanup CSVWriter csv = new CSVWriter(new FileWriter(file));\n for (int i = 0; i < reps; i++) {\n long result = b.benchmark();\n csv.writeNext(new String[]{Long.toString(result)});\n }\n }\n double factor = 6 / 100.0;\n for (Benchmark.Parameterised b : pBenchmarks) {\n File file = new File(getTarget(b) + \".csv\");\n log.info(\"writing to \" + file);\n @Cleanup CSVWriter csv = new CSVWriter(new FileWriter(file));\n for (int i = 0; i < reps; i++) {\n for (int j = sets; j > 0; j--) {\n int size = (int) Math.pow(10, factor * j);\n if (size < 10) continue;\n long result = b.benchmark(size);\n csv.writeNext(new String[]{Integer.toString(size), Long.toString(result)});\n }\n }\n }\n }\n"} {"input": "\tprivate final void drawGame() throws Exception {\n\t\tcur_fps++;\n\t\tif (System.currentTimeMillis() - lastFps < 0) {\n\t\t\tlastFps = System.currentTimeMillis();\n\t\t}\n\t\tif (System.currentTimeMillis() - lastFps >= 1000) {\n\t\t\tfps = cur_fps;\n\t\t\tcur_fps = 0;\n\t\t\tlastFps = System.currentTimeMillis();\n\t\t}\n\t\tif (playerAliveTimeout != 0) {\n\t\t\tgameGraphics.fadePixels();\n\t\t\tgameGraphics.drawText(\"Oh dear! You are dead...\", windowWidth / 2,\n\t\t\t\t\twindowHeight / 2, 7, 0xff0000);\n\t\t\tdrawChatMessageTabs();\n\t\t\tdrawOurSpritesOnScreen();\n\t\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t\t\treturn;\n\t\t}\n\t\tif (sleeping) {\n\t\t\tboolean drawEquation = true;\n\t\t\tif (drawEquation && sleepEquation != null) {\n\t\t\t\tgameGraphics.drawImage(aGraphics936, 0, 0,\n\t\t\t\t\t\tfixSleeping(sleepEquation));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (showDrawPointsScreen) {\n\t\t\tshowDPS();\n\t\t\treturn;\n\t\t}\n\t\tif (showCharacterLookScreen) {\n\t\t\tmethod62();\n\t\t\treturn;\n\t\t}\n\t\tif (!engineHandle.playerIsAlive) {\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < 64; i++) {\n\t\t\tgameCamera\n\t\t\t\t\t.removeModel(engineHandle.aModelArrayArray598[lastWildYSubtract][i]);\n\t\t\tif (lastWildYSubtract == 0) {\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray580[1][i]);\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray598[1][i]);\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray580[2][i]);\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray598[2][i]);\n\t\t\t}\n\t\t\tzoomCamera = true;\n\t\t\tif (lastWildYSubtract == 0\n\t\t\t\t\t&& (engineHandle.walkableValue[ourPlayer.currentX / 128][ourPlayer.currentY / 128] & 0x80) == 0) {\n\t\t\t\tif (showRoof) {\n\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray598[lastWildYSubtract][i]);\n\t\t\t\t\tif (lastWildYSubtract == 0) {\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray580[1][i]);\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray598[1][i]);\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray580[2][i]);\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray598[2][i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tzoomCamera = false;\n\t\t\t}\n\t\t}\n\t\tif (modelFireLightningSpellNumber != anInt742) {\n\t\t\tanInt742 = modelFireLightningSpellNumber;\n\t\t\tfor (int j = 0; j < objectCount; j++) {\n\t\t\t\tif (objectType[j] == 97)\n\t\t\t\t\tmethod98(j, \"firea\" + (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 274)\n\t\t\t\t\tmethod98(j, \"fireplacea\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 1031)\n\t\t\t\t\tmethod98(j, \"lightning\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 1036)\n\t\t\t\t\tmethod98(j, \"firespell\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 1147)\n\t\t\t\t\tmethod98(j, \"spellcharge\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t}\n\t\t}\n\t\tif (modelTorchNumber != anInt743) {\n\t\t\tanInt743 = modelTorchNumber;\n\t\t\tfor (int k = 0; k < objectCount; k++) {\n\t\t\t\tif (objectType[k] == 51)\n\t\t\t\t\tmethod98(k, \"torcha\" + (modelTorchNumber + 1));\n\t\t\t\tif (objectType[k] == 143)\n\t\t\t\t\tmethod98(k, \"skulltorcha\" + (modelTorchNumber + 1));\n\t\t\t}\n\t\t}\n\t\tif (modelClawSpellNumber != anInt744) {\n\t\t\tanInt744 = modelClawSpellNumber;\n\t\t\tfor (int l = 0; l < objectCount; l++)\n\t\t\t\tif (objectType[l] == 1142)\n\t\t\t\t\tmethod98(l, \"clawspell\" + (modelClawSpellNumber + 1));\n\t\t}\n\t\tgameCamera.updateFightCount(fightCount);\n\t\tfightCount = 0;\n\t\tfor (int i1 = 0; i1 < playerCount; i1++) {\n\t\t\tMob mob = playerArray[i1];\n\t\t\tif (mob.colourBottomType != 255) {\n\t\t\t\tint k1 = mob.currentX;\n\t\t\t\tint i2 = mob.currentY;\n\t\t\t\tint k2 = -engineHandle.getAveragedElevation(k1, i2);\n\t\t\t\tint l3 = gameCamera.method268(5000 + i1, k1, k2, i2, 145, 220,\n\t\t\t\t\t\ti1 + 10000);\n\t\t\t\tfightCount++;\n\t\t\t\tif (mob == ourPlayer)\n\t\t\t\t\tgameCamera.setOurPlayer(l3);\n\t\t\t\tif (mob.currentSprite == 8)\n\t\t\t\t\tgameCamera.setCombat(l3, -30);\n\t\t\t\tif (mob.currentSprite == 9)\n\t\t\t\t\tgameCamera.setCombat(l3, 30);\n\t\t\t}\n\t\t}\n\t\tfor (int j1 = 0; j1 < playerCount; j1++) {\n\t\t\tMob player = playerArray[j1];\n\t\t\tif (player.anInt176 > 0) {\n\t\t\t\tMob npc = null;\n\t\t\t\tif (player.attackingNpcIndex != -1)\n\t\t\t\t\tnpc = npcRecordArray[player.attackingNpcIndex];\n\t\t\t\telse if (player.attackingMobIndex != -1)\n\t\t\t\t\tnpc = mobArray[player.attackingMobIndex];\n\t\t\t\tif (npc != null) {\n\t\t\t\t\tint px = player.currentX;\n\t\t\t\t\tint py = player.currentY;\n\t\t\t\t\tint pi = -engineHandle.getAveragedElevation(px, py) - 110;\n\t\t\t\t\tint nx = npc.currentX;\n\t\t\t\t\tint ny = npc.currentY;\n\t\t\t\t\tint ni = -engineHandle.getAveragedElevation(nx, ny)\n\t\t\t\t\t\t\t- EntityHandler.getNpcDef(npc.type).getCamera2()\n\t\t\t\t\t\t\t/ 2;\n\t\t\t\t\tint i10 = (px * player.anInt176 + nx\n\t\t\t\t\t\t\t* (attackingInt40 - player.anInt176))\n\t\t\t\t\t\t\t/ attackingInt40;\n\t\t\t\t\tint j10 = (pi * player.anInt176 + ni\n\t\t\t\t\t\t\t* (attackingInt40 - player.anInt176))\n\t\t\t\t\t\t\t/ attackingInt40;\n\t\t\t\t\tint k10 = (py * player.anInt176 + ny\n\t\t\t\t\t\t\t* (attackingInt40 - player.anInt176))\n\t\t\t\t\t\t\t/ attackingInt40;\n\t\t\t\t\tgameCamera.method268(SPRITE_PROJECTILE_START\n\t\t\t\t\t\t\t+ player.attackingCameraInt, i10, j10, k10, 32, 32,\n\t\t\t\t\t\t\t0);\n\t\t\t\t\tfightCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int l1 = 0; l1 < npcCount; l1++) {\n\t\t\tMob npc = npcArray[l1];\n\t\t\tint mobx = npc.currentX;\n\t\t\tint moby = npc.currentY;\n\t\t\tint i7 = -engineHandle.getAveragedElevation(mobx, moby);\n\t\t\tint i9 = gameCamera.method268(20000 + l1, mobx, i7, moby,\n\t\t\t\t\tEntityHandler.getNpcDef(npc.type).getCamera1(),\n\t\t\t\t\tEntityHandler.getNpcDef(npc.type).getCamera2(), l1 + 30000);\n\t\t\tfightCount++;\n\t\t\tif (npc.currentSprite == 8)\n\t\t\t\tgameCamera.setCombat(i9, -30);\n\t\t\tif (npc.currentSprite == 9)\n\t\t\t\tgameCamera.setCombat(i9, 30);\n\t\t}\n\t\tif (LOOT_ENABLED) {\n\t\t\tfor (int j2 = 0; j2 < groundItemCount; j2++) {\n\t\t\t\tint j3 = groundItemX[j2] * magicLoc + 64;\n\t\t\t\tint k4 = groundItemY[j2] * magicLoc + 64;\n\t\t\t\tgameCamera.method268(40000 + groundItemType[j2], j3,\n\t\t\t\t\t\t-engineHandle.getAveragedElevation(j3, k4)\n\t\t\t\t\t\t\t\t- groundItemObjectVar[j2], k4, 96, 64,\n\t\t\t\t\t\tj2 + 20000);\n\t\t\t\tfightCount++;\n\t\t\t}\n\t\t}\n\t\tfor (int k3 = 0; k3 < anInt892; k3++) {\n\t\t\tint l4 = anIntArray944[k3] * magicLoc + 64;\n\t\t\tint j7 = anIntArray757[k3] * magicLoc + 64;\n\t\t\tint j9 = anIntArray782[k3];\n\t\t\tif (j9 == 0) {\n\t\t\t\tgameCamera.method268(50000 + k3, l4,\n\t\t\t\t\t\t-engineHandle.getAveragedElevation(l4, j7), j7, 128,\n\t\t\t\t\t\t256, k3 + 50000);\n\t\t\t\tfightCount++;\n\t\t\t}\n\t\t\tif (j9 == 1) {\n\t\t\t\tgameCamera.method268(50000 + k3, l4,\n\t\t\t\t\t\t-engineHandle.getAveragedElevation(l4, j7), j7, 128,\n\t\t\t\t\t\t64, k3 + 50000);\n\t\t\t\tfightCount++;\n\t\t\t}\n\t\t}\n\t\tgameGraphics.f1Toggle = false;\n\t\tgameGraphics.method211();\n\t\tgameGraphics.f1Toggle = super.keyF1Toggle;\n\t\tif (lastWildYSubtract == 3) {\n\t\t\tint i5 = 40 + (int) (Math.random() * 3D);\n\t\t\tint k7 = 40 + (int) (Math.random() * 7D);\n\t\t\tgameCamera.method304(i5, k7, -50, -10, -50);\n\t\t}\n\t\tanInt699 = 0;\n\t\tmobMessageCount = 0;\n\t\tanInt718 = 0;\n\t\tif (cameraAutoAngleDebug) {\n\t\t\tif (configAutoCameraAngle && !zoomCamera) {\n\t\t\t\tint lastCameraAutoAngle = cameraAutoAngle;\n\t\t\t\tautoRotateCamera();\n\t\t\t\tif (cameraAutoAngle != lastCameraAutoAngle) {\n\t\t\t\t\tlastAutoCameraRotatePlayerX = ourPlayer.currentX;\n\t\t\t\t\tlastAutoCameraRotatePlayerY = ourPlayer.currentY;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (fog) {\n\t\t\t\tgameCamera.zoom1 = 3000 + fogVar;\n\t\t\t\tgameCamera.zoom2 = 3000 + fogVar;\n\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\tgameCamera.zoom4 = 2800 + fogVar;\n\t\t\t} else {\n\t\t\t\tgameCamera.zoom1 = 41000;\n\t\t\t\tgameCamera.zoom2 = 41000;\n\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\tgameCamera.zoom4 = 41000;\n\t\t\t}\n\t\t\tcameraRotation = cameraAutoAngle * 32;\n\t\t\tint k5 = lastAutoCameraRotatePlayerX + screenRotationX;\n\t\t\tint l7 = lastAutoCameraRotatePlayerY + screenRotationY;\n\t\t\tgameCamera.setCamera(k5,\n\t\t\t\t\t-engineHandle.getAveragedElevation(k5, l7), l7,\n\t\t\t\t\tcameraVertical, cameraRotation * 4, 0, 2000);\n\t\t} else {\n\t\t\tif (configAutoCameraAngle && !zoomCamera)\n\t\t\t\tautoRotateCamera();\n\t\t\tif (fog) {\n\t\t\t\tif (!super.keyF1Toggle) {\n\t\t\t\t\tgameCamera.zoom1 = 2400 + fogVar;\n\t\t\t\t\tgameCamera.zoom2 = 2400 + fogVar;\n\t\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\t\tgameCamera.zoom4 = 2300 + fogVar;\n\t\t\t\t} else {\n\t\t\t\t\tgameCamera.zoom1 = 2200;\n\t\t\t\t\tgameCamera.zoom2 = 2200;\n\t\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\t\tgameCamera.zoom4 = 2100;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgameCamera.zoom1 = 41000;\n\t\t\t\tgameCamera.zoom2 = 41000;\n\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\tgameCamera.zoom4 = 41000;\n\t\t\t}\n\t\t\tint l5 = lastAutoCameraRotatePlayerX + screenRotationX;\n\t\t\tint i8 = lastAutoCameraRotatePlayerY + screenRotationY;\n\t\t\tgameCamera.setCamera(l5,\n\t\t\t\t\t-engineHandle.getAveragedElevation(l5, i8), i8,\n\t\t\t\t\tcameraVertical, cameraRotation * 4, 0, cameraHeight * 2);\n\t\t}\n\t\tgameCamera.finishCamera();\n\t\tmethod119();\n\t\tif (actionPictureType > 0)\n\t\t\tgameGraphics.drawPicture(actionPictureX - 8, actionPictureY - 8,\n\t\t\t\t\tSPRITE_MEDIA_START + 14 + (24 - actionPictureType) / 6);\n\t\tif (actionPictureType < 0)\n\t\t\tgameGraphics.drawPicture(actionPictureX - 8, actionPictureY - 8,\n\t\t\t\t\tSPRITE_MEDIA_START + 18 + (24 + actionPictureType) / 6);\n\t\ttry {\n\t\t\tMessageQueue.getQueue().checkProcessMessages();\n\t\t\tint height = 55;\n\t\t\tif (MessageQueue.getQueue().hasMessages()) {\n\t\t\t\tfor (Message m : MessageQueue.getQueue().getList()) {\n\t\t\t\t\tif (m.isBIG)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tgameGraphics.drawString(m.message, 8, height, 1, 0xffff00);\n\t\t\t\t\theight += 12;\n\t\t\t\t}\n\t\t\t\tfor (Message m : MessageQueue.getQueue().getList()) {\n\t\t\t\t\tif (m.isBIG) {\n\t\t\t\t\t\tgameGraphics.drawString(m.message, 120, 100, 7,\n\t\t\t\t\t\t\t\t0xffff00);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tif (systemUpdate != 0) {\n\t\t\tint i6 = systemUpdate / 50;\n\t\t\tint j8 = i6 / 60;\n\t\t\ti6 %= 60;\n\t\t\tif (i6 < 10)\n\t\t\t\tgameGraphics.drawText(\"System update in: \" + j8 + \":0\" + i6,\n\t\t\t\t\t\t256 + xAddition, windowHeight - 7, 1, 0xffff00);\n\t\t\telse\n\t\t\t\tgameGraphics.drawText(\"System update in: \" + j8 + \":\" + i6,\n\t\t\t\t\t\t256 + xAddition, windowHeight - 7, 1, 0xffff00);\n\t\t}\n\t\tif (!notInWilderness) {\n\t\t\tint j6 = 2203 - (getSectionY() + wildY + getAreaY());\n\t\t\tif (getSectionX() + wildX + getAreaX() >= 2640)\n\t\t\t\tj6 = -50;\n\t\t\tif (j6 > 0) {\n\t\t\t\tint k8 = 1 + j6 / 6;\n\t\t\t\tgameGraphics.drawPicture(windowWidth - 50, windowHeight - 56,\n\t\t\t\t\t\tSPRITE_MEDIA_START + 13);\n\t\t\t\tint minx = 12;\n\t\t\t\tint maxx = 91;\n\t\t\t\tint miny = 4;\n\t\t\t\tint maxy = 33;\n\t\t\t\tint ourX = (getSectionX() + getAreaX());\n\t\t\t\tint ourY = (getSectionY() + getAreaY());\n\t\t\t\tif (ourX > minx && ourX < maxx && ourY > miny && ourY < maxy) {\n\t\t\t\t\tgameGraphics.drawText(\"@whi@CTF\", windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 20, 1, 0xffff00);\n\t\t\t\t\tgameGraphics.drawText(\"@red@Red: @whi@\"\n\t\t\t\t\t\t\t+ GameWindowMiddleMan.redPoints\n\t\t\t\t\t\t\t+ \" @blu@Blue: @whi@\"\n\t\t\t\t\t\t\t+ GameWindowMiddleMan.bluePoints, windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 7, 1, 0xffff00);\n\t\t\t\t} else {\n\t\t\t\t\tgameGraphics.drawText(\"Wilderness\", windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 20, 1, 0xffff00);\n\t\t\t\t\tgameGraphics.drawText(\"Level: \" + k8, windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 7, 1, 0xffff00);\n\t\t\t\t}\n\t\t\t\tif (wildernessType == 0)\n\t\t\t\t\twildernessType = 2;\n\t\t\t}\n\t\t\tif (wildernessType == 0 && j6 > -10 && j6 <= 0)\n\t\t\t\twildernessType = 1;\n\t\t}\n\t\tif (messagesTab == 0) {\n\t\t\tfor (int k6 = 0; k6 < messagesArray.length; k6++)\n\t\t\t\tif (messagesTimeout[k6] > 0) {\n\t\t\t\t\tString s = messagesArray[k6];\n\t\t\t\t\tgameGraphics.drawString(s, 7, windowHeight - 18 - k6 * 12,\n\t\t\t\t\t\t\t1, 0xffff00);\n\t\t\t\t}\n\t\t}\n\t\tgameMenu.method171(messagesHandleType2);\n\t\tgameMenu.method171(messagesHandleType5);\n\t\tgameMenu.method171(messagesHandleType6);\n\t\tif (messagesTab == 1)\n\t\t\tgameMenu.method170(messagesHandleType2);\n\t\telse if (messagesTab == 2)\n\t\t\tgameMenu.method170(messagesHandleType5);\n\t\telse if (messagesTab == 3)\n\t\t\tgameMenu.method170(messagesHandleType6);\n\t\tMenu.anInt225 = 2;\n\t\tgameMenu.drawMenu();\n\t\tMenu.anInt225 = 0;\n\t\tgameGraphics.method232(\n\t\t\t\t((GameImage) (gameGraphics)).menuDefaultWidth - 3 - 197, 3,\n\t\t\t\tSPRITE_MEDIA_START, 128);\n\t\tdrawGameWindowsMenus();\n\t\tgameGraphics.drawStringShadows = false;\n\t\tdrawChatMessageTabs();\n\t\tdrawOurSpritesOnScreen();\n\t\tInterfaceHandler.tick();\n\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t}\n\tprivate void drawOurSpritesOnScreen() {\n\t\tif (mouseOverMenu != 7)\n\t\t\tgameGraphics.drawBoxAlpha(\n\t\t\t\t\t((GameImage) (gameGraphics)).menuDefaultWidth - 232, 3, 31,\n\t\t\t\t\t32, GameImage.convertRGBToLong(181, 181, 181), 128);\n\t\tgameGraphics.drawPicture(windowWidth - 240, 2, SPRITE_ITEM_START\n\t\t\t\t+ EntityHandler.getItemDef(167).getSprite());\n\t}\n\tprivate final void drawRightClickMenu() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tfor (int i = 0; i < menuLength; i++) {\n\t\t\t\tint k = menuX + 2;\n\t\t\t\tint i1 = menuY + 27 + i * 15;\n\t\t\t\tif (super.mouseX <= k - 2 || super.mouseY <= i1 - 12\n\t\t\t\t\t\t|| super.mouseY >= i1 + 4\n\t\t\t\t\t\t|| super.mouseX >= (k - 3) + menuWidth)\n\t\t\t\t\tcontinue;\n\t\t\t\tmenuClick(menuIndexes[i]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\tshowRightClickMenu = false;\n\t\t\treturn;\n\t\t}\n\t\tif (super.mouseX < menuX - 10 || super.mouseY < menuY - 10\n\t\t\t\t|| super.mouseX > menuX + menuWidth + 10\n\t\t\t\t|| super.mouseY > menuY + menuHeight + 10) {\n\t\t\tshowRightClickMenu = false;\n\t\t\treturn;\n\t\t}\n\t\tgameGraphics.drawBoxAlpha(menuX, menuY, menuWidth, menuHeight,\n\t\t\t\t0xd0d0d0, 160);\n\t\tgameGraphics.drawString(\"Choose option\", menuX + 2, menuY + 12, 1,\n\t\t\t\t65535);\n\t\tfor (int j = 0; j < menuLength; j++) {\n\t\t\tint l = menuX + 2;\n\t\t\tint j1 = menuY + 27 + j * 15;\n\t\t\tint k1 = 0xffffff;\n\t\t\tif (super.mouseX > l - 2 && super.mouseY > j1 - 12\n\t\t\t\t\t&& super.mouseY < j1 + 4\n\t\t\t\t\t&& super.mouseX < (l - 3) + menuWidth)\n\t\t\t\tk1 = 0xffff00;\n\t\t\tgameGraphics.drawString(menuText1[menuIndexes[j]] + \" \"\n\t\t\t\t\t+ menuText2[menuIndexes[j]], l, j1, 1, k1);\n\t\t}\n\t}\n\tprotected final void resetIntVars() {\n\t\tsystemUpdate = 0;\n\t\tloginScreenNumber = 0;\n\t\tloggedIn = 0;\n\t\tlogoutTimeout = 0;\n\t\tfor (int i = 0; i < questStage.length; i++)\n\t\t\tquestStage[i] = 0;\n\t\tquestPoints = 0;\n\t}\n\tprivate final void drawQuestionMenu() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tfor (int i = 0; i < questionMenuCount; i++) {\n\t\t\t\tif (super.mouseX >= gameGraphics.textWidth(\n\t\t\t\t\t\tquestionMenuAnswer[i], 1)\n\t\t\t\t\t\t|| super.mouseY <= i * 12\n\t\t\t\t\t\t|| super.mouseY >= 12 + i * 12)\n\t\t\t\t\tcontinue;\n\t\t\t\tsuper.streamClass.createPacket(154);\n\t\t\t\tsuper.streamClass.addByte(i);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\tshowQuestionMenu = false;\n\t\t\treturn;\n\t\t}\n\t\tfor (int j = 0; j < questionMenuCount; j++) {\n\t\t\tint k = 65535;\n\t\t\tif (super.mouseX < gameGraphics.textWidth(questionMenuAnswer[j], 1)\n\t\t\t\t\t&& super.mouseY > j * 12 && super.mouseY < 12 + j * 12)\n\t\t\t\tk = 0xff0000;\n\t\t\tgameGraphics\n\t\t\t\t\t.drawString(questionMenuAnswer[j], 6, 12 + j * 12, 1, k);\n\t\t}\n\t}\n\tprivate final void walkToAction(int actionX, int actionY, int actionType) {\n\t\tif (actionType == 0) {\n\t\t\tsendWalkCommand(getSectionX(), getSectionY(), actionX, actionY - 1,\n\t\t\t\t\tactionX, actionY, false, true);\n\t\t\treturn;\n\t\t}\n\t\tif (actionType == 1) {\n\t\t\tsendWalkCommand(getSectionX(), getSectionY(), actionX - 1, actionY,\n\t\t\t\t\tactionX, actionY, false, true);\n\t\t\treturn;\n\t\t} else {\n\t\t\tsendWalkCommand(getSectionX(), getSectionY(), actionX, actionY,\n\t\t\t\t\tactionX, actionY, true, true);\n\t\t\treturn;\n\t\t}\n\t}\n\tprivate final void garbageCollect() {\n\t\ttry {\n\t\t\tif (gameGraphics != null) {\n\t\t\t\tgameGraphics.cleanupSprites();\n\t\t\t\tgameGraphics.imagePixelArray = null;\n\t\t\t\tgameGraphics = null;\n\t\t\t}\n\t\t\tif (gameCamera != null) {\n\t\t\t\tgameCamera.cleanupModels();\n\t\t\t\tgameCamera = null;\n\t\t\t}\n\t\t\tgameDataModels = null;\n\t\t\tobjectModelArray = null;\n\t\t\tdoorModel = null;\n\t\t\tmobArray = null;\n\t\t\tplayerArray = null;\n\t\t\tnpcRecordArray = null;\n\t\t\tnpcArray = null;\n\t\t\tourPlayer = null;\n\t\t\tif (engineHandle != null) {\n\t\t\t\tengineHandle.aModelArray596 = null;\n\t\t\t\tengineHandle.aModelArrayArray580 = null;\n\t\t\t\tengineHandle.aModelArrayArray598 = null;\n\t\t\t\tengineHandle.aModel = null;\n\t\t\t\tengineHandle = null;\n\t\t\t}\n\t\t\tSystem.gc();\n\t\t\treturn;\n\t\t} catch (Exception _ex) {\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected final void loginScreenPrint(String s, String s1) {\n\t\tif (loginScreenNumber == 1)\n\t\t\tmenuNewUser.updateText(anInt900, s + \" \" + s1);\n\t\tif (loginScreenNumber == 2)\n\t\t\tmenuLogin.updateText(loginStatusText, s + \" \" + s1);\n\t\tdrawLoginScreen();\n\t\tresetCurrentTimeArray();\n\t}\n\tprivate final void drawInventoryRightClickMenu() {\n\t\tint i = 2203 - (getSectionY() + wildY + getAreaY());\n\t\tif (getSectionX() + wildX + getAreaX() >= 2640)\n\t\t\ti = -50;\n\t\tint j = -1;\n\t\tfor (int k = 0; k < objectCount; k++)\n\t\t\taBooleanArray827[k] = false;\n\t\tfor (int l = 0; l < doorCount; l++)\n\t\t\taBooleanArray970[l] = false;\n\t\tint i1 = gameCamera.method272();\n\t\tModel models[] = gameCamera.getVisibleModels();\n\t\tint ai[] = gameCamera.method273();\n\t\tfor (int j1 = 0; j1 < i1; j1++) {\n\t\t\tif (menuLength > 200)\n\t\t\t\tbreak;\n\t\t\tint k1 = ai[j1];\n\t\t\tModel model = models[j1];\n\t\t\tif (model.anIntArray258[k1] <= 65535\n\t\t\t\t\t|| model.anIntArray258[k1] >= 0x30d40\n\t\t\t\t\t&& model.anIntArray258[k1] <= 0x493e0)\n\t\t\t\tif (model == gameCamera.aModel_423) {\n\t\t\t\t\tint i2 = model.anIntArray258[k1] % 10000;\n\t\t\t\t\tint l2 = model.anIntArray258[k1] / 10000;\n\t\t\t\t\tif (l2 == 1) {\n\t\t\t\t\t\tString s = \"\";\n\t\t\t\t\t\tint k3 = 0;\n\t\t\t\t\t\tif (ourPlayer.level > 0 && playerArray[i2].level > 0)\n\t\t\t\t\t\t\tk3 = ourPlayer.level - playerArray[i2].level;\n\t\t\t\t\t\tif (k3 < 0)\n\t\t\t\t\t\t\ts = \"@or1@\";\n\t\t\t\t\t\tif (k3 < -3)\n\t\t\t\t\t\t\ts = \"@or2@\";\n\t\t\t\t\t\tif (k3 < -6)\n\t\t\t\t\t\t\ts = \"@or3@\";\n\t\t\t\t\t\tif (k3 < -9)\n\t\t\t\t\t\t\ts = \"@red@\";\n\t\t\t\t\t\tif (k3 > 0)\n\t\t\t\t\t\t\ts = \"@gr1@\";\n\t\t\t\t\t\tif (k3 > 3)\n\t\t\t\t\t\t\ts = \"@gr2@\";\n\t\t\t\t\t\tif (k3 > 6)\n\t\t\t\t\t\t\ts = \"@gr3@\";\n\t\t\t\t\t\tif (k3 > 9)\n\t\t\t\t\t\t\ts = \"@gre@\";\n\t\t\t\t\t\ts = \" \" + s + \"(level-\" + playerArray[i2].level + \")\";\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 1\n\t\t\t\t\t\t\t\t\t|| EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t\t\t.getSpellType() == 2) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@whi@\"\n\t\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 800;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@whi@\"\n\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\tmenuID[menuLength] = 810;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (i > 0\n\t\t\t\t\t\t\t\t\t&& (playerArray[i2].currentY - 64)\n\t\t\t\t\t\t\t\t\t\t\t/ magicLoc + wildY + getAreaY() < 2203) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Attack\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 3 ? \"#adm#\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\t\tif (k3 >= 0 && k3 < 5)\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 805;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 2805;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Duel with\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 2806;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Trade with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 3 ? \"#adm#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\tmenuID[menuLength] = 2810;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Follow\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 3 ? \"#adm#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\tmenuID[menuLength] = 2820;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (l2 == 2) {\n\t\t\t\t\t\tItemDef itemDef = EntityHandler\n\t\t\t\t\t\t\t\t.getItemDef(groundItemType[i2]);\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 3) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\"\n\t\t\t\t\t\t\t\t\t\t+ itemDef.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 200;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = groundItemX[i2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = groundItemY[i2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\" + itemDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 210;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = groundItemX[i2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = groundItemY[i2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Take\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\" + itemDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 220;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = groundItemX[i2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = groundItemY[i2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\"\n\t\t\t\t\t\t\t\t\t+ itemDef.getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\"\n\t\t\t\t\t\t\t\t\t\t\t+ groundItemType[i2] + \":\"\n\t\t\t\t\t\t\t\t\t\t\t+ (groundItemX[i2] + getAreaX())\n\t\t\t\t\t\t\t\t\t\t\t+ \",\"\n\t\t\t\t\t\t\t\t\t\t\t+ (groundItemY[i2] + getAreaY())\n\t\t\t\t\t\t\t\t\t\t\t+ \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3200;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (l2 == 3) {\n\t\t\t\t\t\tString s1 = \"\";\n\t\t\t\t\t\tint l3 = -1;\n\t\t\t\t\t\tNPCDef npcDef = EntityHandler\n\t\t\t\t\t\t\t\t.getNpcDef(npcArray[i2].type);\n\t\t\t\t\t\tif (npcDef.isAttackable()) {\n\t\t\t\t\t\t\tint j4 = (npcDef.getAtt() + npcDef.getDef()\n\t\t\t\t\t\t\t\t\t+ npcDef.getStr() + npcDef.getHits()) / 4;\n\t\t\t\t\t\t\tint k4 = (playerStatBase[0] + playerStatBase[1]\n\t\t\t\t\t\t\t\t\t+ playerStatBase[2] + playerStatBase[3] + 27) / 4;\n\t\t\t\t\t\t\tl3 = k4 - j4;\n\t\t\t\t\t\t\ts1 = \"@yel@\";\n\t\t\t\t\t\t\tif (l3 < 0)\n\t\t\t\t\t\t\t\ts1 = \"@or1@\";\n\t\t\t\t\t\t\tif (l3 < -3)\n\t\t\t\t\t\t\t\ts1 = \"@or2@\";\n\t\t\t\t\t\t\tif (l3 < -6)\n\t\t\t\t\t\t\t\ts1 = \"@or3@\";\n\t\t\t\t\t\t\tif (l3 < -9)\n\t\t\t\t\t\t\t\ts1 = \"@red@\";\n\t\t\t\t\t\t\tif (l3 > 0)\n\t\t\t\t\t\t\t\ts1 = \"@gr1@\";\n\t\t\t\t\t\t\tif (l3 > 3)\n\t\t\t\t\t\t\t\ts1 = \"@gr2@\";\n\t\t\t\t\t\t\tif (l3 > 6)\n\t\t\t\t\t\t\t\ts1 = \"@gr3@\";\n\t\t\t\t\t\t\tif (l3 > 9)\n\t\t\t\t\t\t\t\ts1 = \"@gre@\";\n\t\t\t\t\t\t\ts1 = \" \" + s1 + \"(level-\" + j4 + \")\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 2) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ npcDef.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 700;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\" + npcDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 710;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (npcDef.isAttackable()) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Attack\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ npcDef.getName() + s1;\n\t\t\t\t\t\t\t\tif (l3 >= 0)\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 715;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 2715;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Talk-to\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\" + npcDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 720;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\tif (!npcDef.getCommand().equals(\"\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = npcDef.getCommand();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ npcDef.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 725;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t+ npcDef.getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\"\n\t\t\t\t\t\t\t\t\t\t\t+ npcArray[i2].type + \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3700;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].type;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (model != null && model.anInt257 >= 10000) {\n\t\t\t\t\tint j2 = model.anInt257 - 10000;\n\t\t\t\t\tint i3 = doorType[j2];\n\t\t\t\t\tif (!aBooleanArray970[j2]) {\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 4) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 300;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3).getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 310;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!EntityHandler.getDoorDef(i3).getCommand1()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"WalkTo\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getDoorDef(i3).getCommand1();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 320;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!EntityHandler.getDoorDef(i3).getCommand2()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"Examine\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getDoorDef(i3).getCommand2();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 2300;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3).getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\" + i3\n\t\t\t\t\t\t\t\t\t\t\t+ \":\" + (doorX[j2] + getAreaX())\n\t\t\t\t\t\t\t\t\t\t\t+ \",\" + (doorY[j2] + getAreaY())\n\t\t\t\t\t\t\t\t\t\t\t+ \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3300;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = i3;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taBooleanArray970[j2] = true;\n\t\t\t\t\t}\n\t\t\t\t} else if (model != null && model.anInt257 >= 0) {\n\t\t\t\t\tint k2 = model.anInt257;\n\t\t\t\t\tint j3 = objectType[k2];\n\t\t\t\t\tif (!aBooleanArray827[k2]) {\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 5) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 400;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable2[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3).getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 410;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\tmenuActionVariable2[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!EntityHandler.getObjectDef(j3).getCommand1()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"WalkTo\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getObjectDef(j3).getCommand1();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 420;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!EntityHandler.getObjectDef(j3).getCommand2()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"Examine\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getObjectDef(j3).getCommand2();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 2400;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3).getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\" + j3\n\t\t\t\t\t\t\t\t\t\t\t+ \":\" + (objectX[k2] + getAreaX())\n\t\t\t\t\t\t\t\t\t\t\t+ \",\" + (objectY[k2] + getAreaY())\n\t\t\t\t\t\t\t\t\t\t\t+ \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3400;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = j3;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taBooleanArray827[k2] = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (k1 >= 0)\n\t\t\t\t\t\tk1 = model.anIntArray258[k1] - 0x30d40;\n\t\t\t\t\tif (k1 >= 0)\n\t\t\t\t\t\tj = k1;\n\t\t\t\t}\n\t\t}\n\t\tif (selectedSpell >= 0\n\t\t\t\t&& EntityHandler.getSpellDef(selectedSpell).getSpellType() <= 1) {\n\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t+ EntityHandler.getSpellDef(selectedSpell).getName()\n\t\t\t\t\t+ \" on self\";\n\t\t\tmenuText2[menuLength] = \"\";\n\t\t\tmenuID[menuLength] = 1000;\n\t\t\tmenuActionType[menuLength] = selectedSpell;\n\t\t\tmenuLength++;\n\t\t}\n\t\tif (j != -1) {\n\t\t\tint l1 = j;\n\t\t\tif (selectedSpell >= 0) {\n\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell).getSpellType() == 6) {\n\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getName() + \" on ground\";\n\t\t\t\t\tmenuText2[menuLength] = \"\";\n\t\t\t\t\tmenuID[menuLength] = 900;\n\t\t\t\t\tmenuActionX[menuLength] = engineHandle.selectedX[l1];\n\t\t\t\t\tmenuActionY[menuLength] = engineHandle.selectedY[l1];\n\t\t\t\t\tmenuActionType[menuLength] = selectedSpell;\n\t\t\t\t\tmenuLength++;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (selectedItem < 0) {\n\t\t\t\tmenuText1[menuLength] = \"Walk here\";\n\t\t\t\tmenuText2[menuLength] = \"\";\n\t\t\t\tmenuID[menuLength] = 920;\n\t\t\t\tmenuActionX[menuLength] = engineHandle.selectedX[l1];\n\t\t\t\tmenuActionY[menuLength] = engineHandle.selectedY[l1];\n\t\t\t\tmenuLength++;\n\t\t\t}\n\t\t}\n\t}\n\tprotected final void startGame() {\n\t\tint i = 0;\n\t\tfor (int j = 0; j < 99; j++) {\n\t\t\tint k = j + 1;\n\t\t\tint i1 = (int) ((double) k + 300D * Math.pow(2D, (double) k / 7D));\n\t\t\ti += i1;\n\t\t\texperienceArray[j] = (i & 0xffffffc) / 4;\n\t\t}\n\t\tsuper.yOffset = 0;\n\t\tGameWindowMiddleMan.maxPacketReadCount = 500;\n\t\tif (appletMode) {\n\t\t\tCacheManager.load(\"Loading.rscd\");\n\t\t\tsetLogo(Toolkit.getDefaultToolkit().getImage(\n\t\t\t\t\tConfig.CONF_DIR + File.separator + \"Loading.rscd\"));\n\t\t}\n\t\tloadConfigFilter(); \n\t\tif (lastLoadedNull) {\n\t\t\treturn;\n\t\t}\n\t\taGraphics936 = getGraphics();\n\t\tchangeThreadSleepModifier(50);\n\t\tgameGraphics = new GameImageMiddleMan(windowWidth, windowHeight + 12,\n\t\t\t\t4000, this);\n\t\tgameGraphics._mudclient = this;\n\t\tGameFrame.setClient(mc);\n\t\tGameWindow.setClient(this);\n\t\tgameGraphics.setDimensions(0, 0, windowWidth, windowHeight + 12);\n\t\tMenu.aBoolean220 = false;\n\t\tspellMenu = new Menu(gameGraphics, 5);\n\t\tint l = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tbyte byte0 = 36;\n\t\tspellMenuHandle = spellMenu.method162(l, byte0 + 24, 196, 90, 1, 500,\n\t\t\t\ttrue);\n\t\tfriendsMenu = new Menu(gameGraphics, 5);\n\t\tfriendsMenuHandle = friendsMenu.method162(l, byte0 + 40, 196, 126, 1,\n\t\t\t\t500, true);\n\t\tquestMenu = new Menu(gameGraphics, 5);\n\t\tquestMenuHandle = questMenu.method162(l, byte0 + 40, 196, 235, 1, 500,\n\t\t\t\ttrue);\n\t\tloadMedia(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tloadEntity(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tgameCamera = new Camera(gameGraphics, 15000, 15000, 1000);\n\t\tgameCamera.setCameraSize(windowWidth / 2, windowHeight / 2,\n\t\t\t\twindowWidth / 2, windowHeight / 2, windowWidth, cameraSizeInt);\n\t\tif (fog) {\n\t\t\tgameCamera.zoom1 = 2400 + fogVar;\n\t\t\tgameCamera.zoom2 = 2400 + fogVar;\n\t\t\tgameCamera.zoom3 = 1;\n\t\t\tgameCamera.zoom4 = 2300 + fogVar;\n\t\t} else {\n\t\t\tgameCamera.zoom1 = 41000;\n\t\t\tgameCamera.zoom2 = 41000;\n\t\t\tgameCamera.zoom3 = 1;\n\t\t\tgameCamera.zoom4 = 41000;\n\t\t}\n\t\tgameCamera.method303(-50, -10, -50);\n\t\tengineHandle = new EngineHandle(gameCamera, gameGraphics);\n\t\tloadTextures(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tloadModels(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tloadSounds(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tCacheManager.doneLoading();\n\t\tdrawDownloadProgress(\"Starting game...\", 100, false);\n\t\tdrawGameMenu();\n\t\tmakeLoginMenus();\n\t\tmakeCharacterDesignMenu();\n\t\tmakeDPSMenu();\n\t\tresetLoginVars();\n\t\tmenusLoaded = true;\n\t}\n\tprivate final void loadSprite(int id, String packageName, int amount) {\n\t\tfor (int i = id; i < id + amount; i++) {\n\t\t\tif (!gameGraphics.loadSprite(i, packageName)) {\n\t\t\t\tlastLoadedNull = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tprivate final void loadMedia() {\n\t\tdrawDownloadProgress(\"Unpacking media\", 30, false);\n\t\tloadSprite(SPRITE_MEDIA_START, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 1, \"media\", 6);\n\t\tloadSprite(SPRITE_MEDIA_START + 9, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 10, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 11, \"media\", 3);\n\t\tloadSprite(SPRITE_MEDIA_START + 14, \"media\", 8);\n\t\tloadSprite(SPRITE_MEDIA_START + 22, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 23, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 24, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 25, \"media\", 2);\n\t\tloadSprite(SPRITE_UTIL_START, \"media\", 2);\n\t\tloadSprite(SPRITE_UTIL_START + 2, \"media\", 4);\n\t\tloadSprite(SPRITE_UTIL_START + 6, \"media\", 2);\n\t\tloadSprite(SPRITE_PROJECTILE_START, \"media\", 7);\n\t\tloadSprite(SPRITE_LOGO_START, \"media\", 1);\n\t\tint i = EntityHandler.invPictureCount();\n\t\tfor (int j = 1; i > 0; j++) {\n\t\t\tint k = i;\n\t\t\ti -= 30;\n\t\t\tif (k > 30) {\n\t\t\t\tk = 30;\n\t\t\t}\n\t\t\tloadSprite(SPRITE_ITEM_START + (j - 1) * 30, \"media.object\", k);\n\t\t}\n\t}\n\tprivate final void loadEntity() {\n\t\tdrawDownloadProgress(\"Unpacking entities\", 45, false);\n\t\tint animationNumber = 0;\n\t\tlabel0: for (int animationIndex = 0; animationIndex < EntityHandler\n\t\t\t\t.animationCount(); animationIndex++) {\n\t\t\tString s = EntityHandler.getAnimationDef(animationIndex).getName();\n\t\t\tfor (int nextAnimationIndex = 0; nextAnimationIndex < animationIndex; nextAnimationIndex++) {\n\t\t\t\tif (!EntityHandler.getAnimationDef(nextAnimationIndex)\n\t\t\t\t\t\t.getName().equalsIgnoreCase(s)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tEntityHandler.getAnimationDef(animationIndex).number = EntityHandler\n\t\t\t\t\t\t.getAnimationDef(nextAnimationIndex).getNumber();\n\t\t\t\tcontinue label0;\n\t\t\t}\n\t\t\tloadSprite(animationNumber, \"entity\", 15);\n\t\t\tif (EntityHandler.getAnimationDef(animationIndex).hasA()) {\n\t\t\t\tloadSprite(animationNumber + 15, \"entity\", 3);\n\t\t\t}\n\t\t\tif (EntityHandler.getAnimationDef(animationIndex).hasF()) {\n\t\t\t\tloadSprite(animationNumber + 18, \"entity\", 9);\n\t\t\t}\n\t\t\tEntityHandler.getAnimationDef(animationIndex).number = animationNumber;\n\t\t\tanimationNumber += 27;\n\t\t}\n\t}\n\tprivate final void loadTextures() {\n\t\tdrawDownloadProgress(\"Unpacking textures\", 60, false);\n\t\tgameCamera.method297(EntityHandler.textureCount(), 7, 11);\n\t\tfor (int i = 0; i < EntityHandler.textureCount(); i++) {\n\t\t\tloadSprite(SPRITE_TEXTURE_START + i, \"texture\", 1);\n\t\t\tSprite sprite = ((GameImage) (gameGraphics)).sprites[SPRITE_TEXTURE_START\n\t\t\t\t\t+ i];\n\t\t\tint length = sprite.getWidth() * sprite.getHeight();\n\t\t\tint[] pixels = sprite.getPixels();\n\t\t\tint ai1[] = new int[32768];\n\t\t\tfor (int k = 0; k < length; k++) {\n\t\t\t\tai1[((pixels[k] & 0xf80000) >> 9) + ((pixels[k] & 0xf800) >> 6)\n\t\t\t\t\t\t+ ((pixels[k] & 0xf8) >> 3)]++;\n\t\t\t}\n\t\t\tint[] dictionary = new int[256];\n\t\t\tdictionary[0] = 0xff00ff;\n\t\t\tint[] temp = new int[256];\n\t\t\tfor (int i1 = 0; i1 < ai1.length; i1++) {\n\t\t\t\tint j1 = ai1[i1];\n\t\t\t\tif (j1 > temp[255]) {\n\t\t\t\t\tfor (int k1 = 1; k1 < 256; k1++) {\n\t\t\t\t\t\tif (j1 <= temp[k1]) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int i2 = 255; i2 > k1; i2--) {\n\t\t\t\t\t\t\tdictionary[i2] = dictionary[i2 - 1];\n\t\t\t\t\t\t\ttemp[i2] = temp[i2 - 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdictionary[k1] = ((i1 & 0x7c00) << 9)\n\t\t\t\t\t\t\t\t+ ((i1 & 0x3e0) << 6) + ((i1 & 0x1f) << 3)\n\t\t\t\t\t\t\t\t+ 0x40404;\n\t\t\t\t\t\ttemp[k1] = j1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tai1[i1] = -1;\n\t\t\t}\n\t\t\tbyte[] indices = new byte[length];\n\t\t\tfor (int l1 = 0; l1 < length; l1++) {\n\t\t\t\tint j2 = pixels[l1];\n\t\t\t\tint k2 = ((j2 & 0xf80000) >> 9) + ((j2 & 0xf800) >> 6)\n\t\t\t\t\t\t+ ((j2 & 0xf8) >> 3);\n\t\t\t\tint l2 = ai1[k2];\n\t\t\t\tif (l2 == -1) {\n\t\t\t\t\tint i3 = 0x3b9ac9ff;\n\t\t\t\t\tint j3 = j2 >> 16 & 0xff;\n\t\t\t\t\tint k3 = j2 >> 8 & 0xff;\n\t\t\t\t\tint l3 = j2 & 0xff;\n\t\t\t\t\tfor (int i4 = 0; i4 < 256; i4++) {\n\t\t\t\t\t\tint j4 = dictionary[i4];\n\t\t\t\t\t\tint k4 = j4 >> 16 & 0xff;\n\t\t\t\t\t\tint l4 = j4 >> 8 & 0xff;\n\t\t\t\t\t\tint i5 = j4 & 0xff;\n\t\t\t\t\t\tint j5 = (j3 - k4) * (j3 - k4) + (k3 - l4) * (k3 - l4)\n\t\t\t\t\t\t\t\t+ (l3 - i5) * (l3 - i5);\n\t\t\t\t\t\tif (j5 < i3) {\n\t\t\t\t\t\t\ti3 = j5;\n\t\t\t\t\t\t\tl2 = i4;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tai1[k2] = l2;\n\t\t\t\t}\n\t\t\t\tindices[l1] = (byte) l2;\n\t\t\t}\n\t\t\tgameCamera.method298(i, indices, dictionary,\n\t\t\t\t\tsprite.getSomething1() / 64 - 1);\n\t\t}\n\t}\n\tprivate final void checkMouseStatus() {\n\t\tif (selectedSpell >= 0 || selectedItem >= 0) {\n\t\t\tmenuText1[menuLength] = \"Cancel\";\n\t\t\tmenuText2[menuLength] = \"\";\n\t\t\tmenuID[menuLength] = 4000;\n\t\t\tmenuLength++;\n\t\t}\n\t\tfor (int i = 0; i < menuLength; i++)\n\t\t\tmenuIndexes[i] = i;\n\t\tfor (boolean flag = false; !flag;) {\n\t\t\tflag = true;\n\t\t\tfor (int j = 0; j < menuLength - 1; j++) {\n\t\t\t\tint l = menuIndexes[j];\n\t\t\t\tint j1 = menuIndexes[j + 1];\n\t\t\t\tif (menuID[l] > menuID[j1]) {\n\t\t\t\t\tmenuIndexes[j] = j1;\n\t\t\t\t\tmenuIndexes[j + 1] = l;\n\t\t\t\t\tflag = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (menuLength > 20)\n\t\t\tmenuLength = 20;\n\t\tif (menuLength > 0) {\n\t\t\tint k = -1;\n\t\t\tfor (int i1 = 0; i1 < menuLength; i1++) {\n\t\t\t\tif (menuText2[menuIndexes[i1]] == null\n\t\t\t\t\t\t|| menuText2[menuIndexes[i1]].length() <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tk = i1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tString s = null;\n\t\t\tif ((selectedItem >= 0 || selectedSpell >= 0) && menuLength == 1)\n\t\t\t\ts = \"Choose a target\";\n\t\t\telse if ((selectedItem >= 0 || selectedSpell >= 0)\n\t\t\t\t\t&& menuLength > 1)\n\t\t\t\ts = \"@whi@\" + menuText1[menuIndexes[0]] + \" \"\n\t\t\t\t\t\t+ menuText2[menuIndexes[0]];\n\t\t\telse if (k != -1)\n\t\t\t\ts = menuText2[menuIndexes[k]] + \": @whi@\"\n\t\t\t\t\t\t+ menuText1[menuIndexes[0]];\n\t\t\tif (menuLength == 2 && s != null)\n\t\t\t\ts = s + \"@whi@ / 1 more option\";\n\t\t\tif (menuLength > 2 && s != null)\n\t\t\t\ts = s + \"@whi@ / \" + (menuLength - 1) + \" more options\";\n\t\t\tif (s != null)\n\t\t\t\tgameGraphics.drawString(s, 6, 14, 1, 0xffff00);\n\t\t\tif (!configMouseButtons && mouseButtonClick == 1\n\t\t\t\t\t|| configMouseButtons && mouseButtonClick == 1\n\t\t\t\t\t&& menuLength == 1) {\n\t\t\t\tmenuClick(menuIndexes[0]);\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!configMouseButtons && mouseButtonClick == 2\n\t\t\t\t\t|| configMouseButtons && mouseButtonClick == 1) {\n\t\t\t\tmenuHeight = (menuLength + 1) * 15;\n\t\t\t\tmenuWidth = gameGraphics.textWidth(\"Choose option\", 1) + 5;\n\t\t\t\tfor (int k1 = 0; k1 < menuLength; k1++) {\n\t\t\t\t\tint l1 = gameGraphics.textWidth(menuText1[k1] + \" \"\n\t\t\t\t\t\t\t+ menuText2[k1], 1) + 5;\n\t\t\t\t\tif (l1 > menuWidth)\n\t\t\t\t\t\tmenuWidth = l1;\n\t\t\t\t}\n\t\t\t\tmenuX = super.mouseX - menuWidth / 2;\n\t\t\t\tmenuY = super.mouseY - 7;\n\t\t\t\tshowRightClickMenu = true;\n\t\t\t\tif (menuX < 0)\n\t\t\t\t\tmenuX = 0;\n\t\t\t\tif (menuY < 0)\n\t\t\t\t\tmenuY = 0;\n\t\t\t\tif (menuX + menuWidth > (windowWidth - 10))\n\t\t\t\t\tmenuX = (windowWidth - 10) - menuWidth;\n\t\t\t\tif (menuY + menuHeight > (windowHeight))\n\t\t\t\t\tmenuY = (windowHeight - 10) - menuHeight;\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t}\n\t\t}\n\t}\n\tprotected final void cantLogout() {\n\t\tlogoutTimeout = 0;\n\t\tdisplayMessage(\"@cya@Sorry, you can't logout at the moment\", 3, 0);\n\t}\n\tprivate final void drawFriendsWindow(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tint j = 36;\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 5);\n\t\tchar c = '\\304';\n\t\tchar c1 = '\\266';\n\t\tint l;\n\t\tint k = l = GameImage.convertRGBToLong(160, 160, 160);\n\t\tif (anInt981 == 0)\n\t\t\tk = GameImage.convertRGBToLong(220, 220, 220);\n\t\telse\n\t\t\tl = GameImage.convertRGBToLong(220, 220, 220);\n\t\tint maxWidth = windowWidth - 23;\n\t\tint minWidth = windowWidth - 83;\n\t\tgameGraphics.drawBoxAlpha(i, j, c / 2, 24, k, 128);\n\t\tgameGraphics.drawBoxAlpha(i + c / 2, j, c / 2, 24, l, 128);\n\t\tgameGraphics.drawBoxAlpha(i, j + 24, c, c1 - 24,\n\t\t\t\tGameImage.convertRGBToLong(220, 220, 220), 128);\n\t\tgameGraphics.drawLineX(i, j + 24, c, 0);\n\t\tgameGraphics.drawLineY(i + c / 2, j, 24, 0);\n\t\tgameGraphics.drawLineX(i, (j + c1) - 16, c, 0);\n\t\tgameGraphics.drawText(\"Friends\", i + c / 4, j + 16, 4, 0);\n\t\tgameGraphics.drawText(\"Ignore\", i + c / 4 + c / 2, j + 16, 4, 0);\n\t\tfriendsMenu.resetListTextCount(friendsMenuHandle);\n\t\tif (anInt981 == 0) {\n\t\t\tfor (int i1 = 0; i1 < super.friendsCount; i1++) {\n\t\t\t\tString s;\n\t\t\t\tif (super.friendsListOnlineStatus[i1] == 99)\n\t\t\t\t\ts = \"@gre@\";\n\t\t\t\telse if (super.friendsListOnlineStatus[i1] > 0)\n\t\t\t\t\ts = \"@yel@\";\n\t\t\t\telse\n\t\t\t\t\ts = \"@red@\";\n\t\t\t\tfriendsMenu\n\t\t\t\t\t\t.drawMenuListText(\n\t\t\t\t\t\t\t\tfriendsMenuHandle,\n\t\t\t\t\t\t\t\ti1,\n\t\t\t\t\t\t\t\ts\n\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[i1])\n\t\t\t\t\t\t\t\t\t\t+ \"~\" + (windowWidth - 73) + \"~\"\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@Remove WWWWWWWWWW\");\n\t\t\t}\n\t\t}\n\t\tif (anInt981 == 1) {\n\t\t\tfor (int j1 = 0; j1 < super.ignoreListCount; j1++)\n\t\t\t\tfriendsMenu\n\t\t\t\t\t\t.drawMenuListText(\n\t\t\t\t\t\t\t\tfriendsMenuHandle,\n\t\t\t\t\t\t\t\tj1,\n\t\t\t\t\t\t\t\t\"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.ignoreListLongs[j1])\n\t\t\t\t\t\t\t\t\t\t+ \"~\" + (windowWidth - 73) + \"~\"\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@Remove WWWWWWWWWW\");\n\t\t}\n\t\tfriendsMenu.drawMenu();\n\t\tif (anInt981 == 0) {\n\t\t\tint k1 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\tif (k1 >= 0 && super.mouseX < maxWidth) {\n\t\t\t\tif (super.mouseX > minWidth)\n\t\t\t\t\tgameGraphics\n\t\t\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\t\t\"Click to remove \"\n\t\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1]),\n\t\t\t\t\t\t\t\t\ti + c / 2, j + 35, 1, 0xffffff);\n\t\t\t\telse if (super.friendsListOnlineStatus[k1] == 99)\n\t\t\t\t\tgameGraphics\n\t\t\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\t\t\"Click to message \"\n\t\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1]),\n\t\t\t\t\t\t\t\t\ti + c / 2, j + 35, 1, 0xffffff);\n\t\t\t\telse if (super.friendsListOnlineStatus[k1] > 0)\n\t\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\tDataOperations\n\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1])\n\t\t\t\t\t\t\t\t\t+ \" is on world \"\n\t\t\t\t\t\t\t\t\t+ super.friendsListOnlineStatus[k1], i + c\n\t\t\t\t\t\t\t\t\t/ 2, j + 35, 1, 0xffffff);\n\t\t\t\telse\n\t\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\tDataOperations\n\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1])\n\t\t\t\t\t\t\t\t\t+ \" is offline\", i + c / 2, j + 35, 1,\n\t\t\t\t\t\t\t0xffffff);\n\t\t\t} else\n\t\t\t\tgameGraphics.drawText(\"Click a name to send a message\", i + c\n\t\t\t\t\t\t/ 2, j + 35, 1, 0xffffff);\n\t\t\tint k2;\n\t\t\tif (super.mouseX > i && super.mouseX < i + c\n\t\t\t\t\t&& super.mouseY > (j + c1) - 16 && super.mouseY < j + c1)\n\t\t\t\tk2 = 0xffff00;\n\t\t\telse\n\t\t\t\tk2 = 0xffffff;\n\t\t\tgameGraphics.drawText(\"Click here to add a friend\", i + c / 2,\n\t\t\t\t\t(j + c1) - 3, 1, k2);\n\t\t}\n\t\tif (anInt981 == 1) {\n\t\t\tint l1 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\tif (l1 >= 0 && super.mouseX < maxWidth && super.mouseX > minWidth) {\n\t\t\t\tif (super.mouseX > minWidth)\n\t\t\t\t\tgameGraphics\n\t\t\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\t\t\"Click to remove \"\n\t\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.ignoreListLongs[l1]),\n\t\t\t\t\t\t\t\t\ti + c / 2, j + 35, 1, 0xffffff);\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawText(\"Blocking messages from:\", i + c / 2,\n\t\t\t\t\t\tj + 35, 1, 0xffffff);\n\t\t\t}\n\t\t\tint l2;\n\t\t\tif (super.mouseX > i && super.mouseX < i + c\n\t\t\t\t\t&& super.mouseY > (j + c1) - 16 && super.mouseY < j + c1)\n\t\t\t\tl2 = 0xffff00;\n\t\t\telse\n\t\t\t\tl2 = 0xffffff;\n\t\t\tgameGraphics.drawText(\"Click here to add a name\", i + c / 2,\n\t\t\t\t\t(j + c1) - 3, 1, l2);\n\t\t}\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 182) {\n\t\t\tfriendsMenu.updateActions(i\n\t\t\t\t\t+ (((GameImage) (gameGraphics)).menuDefaultWidth - 199),\n\t\t\t\t\tj + 36, super.lastMouseDownButton, super.mouseDownButton);\n\t\t\tif (j <= 24 && mouseButtonClick == 1)\n\t\t\t\tif (i < 98 && anInt981 == 1) {\n\t\t\t\t\tanInt981 = 0;\n\t\t\t\t\tfriendsMenu.method165(friendsMenuHandle, 0);\n\t\t\t\t} else if (i > 98 && anInt981 == 0) {\n\t\t\t\t\tanInt981 = 1;\n\t\t\t\t\tfriendsMenu.method165(friendsMenuHandle, 0);\n\t\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && anInt981 == 0) {\n\t\t\t\tint i2 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\t\tif (i2 >= 0 && super.mouseX < maxWidth)\n\t\t\t\t\tif (super.mouseX > minWidth)\n\t\t\t\t\t\tremoveFromFriends(super.friendsListLongs[i2]);\n\t\t\t\t\telse if (super.friendsListOnlineStatus[i2] != 0) {\n\t\t\t\t\t\tinputBoxType = 2;\n\t\t\t\t\t\tprivateMessageTarget = super.friendsListLongs[i2];\n\t\t\t\t\t\tsuper.inputMessage = \"\";\n\t\t\t\t\t\tsuper.enteredMessage = \"\";\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && anInt981 == 1) {\n\t\t\t\tint j2 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\t\tif (j2 >= 0 && super.mouseX < maxWidth\n\t\t\t\t\t\t&& super.mouseX > minWidth)\n\t\t\t\t\tremoveFromIgnoreList(super.ignoreListLongs[j2]);\n\t\t\t}\n\t\t\tif (j > 166 && mouseButtonClick == 1 && anInt981 == 0) {\n\t\t\t\tinputBoxType = 1;\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t}\n\t\t\tif (j > 166 && mouseButtonClick == 1 && anInt981 == 1) {\n\t\t\t\tinputBoxType = 3;\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final boolean loadSection(int i, int j) {\n\t\tif (playerAliveTimeout != 0) {\n\t\t\tengineHandle.playerIsAlive = false;\n\t\t\treturn false;\n\t\t}\n\t\tnotInWilderness = false;\n\t\ti += wildX;\n\t\tj += wildY;\n\t\tif (lastWildYSubtract == wildYSubtract && i > anInt789 && i < anInt791\n\t\t\t\t&& j > anInt790 && j < anInt792) {\n\t\t\tengineHandle.playerIsAlive = true;\n\t\t\treturn false;\n\t\t}\n\t\tgameGraphics.drawText(\"Loading... Please wait\", 256 + xAddition,\n\t\t\t\t192 + yAddition, 1, 0xffffff);\n\t\tdrawChatMessageTabs();\n\t\tdrawOurSpritesOnScreen();\n\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t\tint k = getAreaX();\n\t\tint l = getAreaY();\n\t\tint i1 = (i + 24) / 48;\n\t\tint j1 = (j + 24) / 48;\n\t\tlastWildYSubtract = wildYSubtract;\n\t\tsetAreaX(i1 * 48 - 48);\n\t\tsetAreaY(j1 * 48 - 48);\n\t\tanInt789 = i1 * 48 - 32;\n\t\tanInt790 = j1 * 48 - 32;\n\t\tanInt791 = i1 * 48 + 32;\n\t\tanInt792 = j1 * 48 + 32;\n\t\tengineHandle.method401(i, j, lastWildYSubtract);\n\t\tsetAreaX(getAreaX() - wildX);\n\t\tsetAreaY(getAreaY() - wildY);\n\t\tint k1 = getAreaX() - k;\n\t\tint l1 = getAreaY() - l;\n\t\tfor (int i2 = 0; i2 < objectCount; i2++) {\n\t\t\tobjectX[i2] -= k1;\n\t\t\tobjectY[i2] -= l1;\n\t\t\tint j2 = objectX[i2];\n\t\t\tint l2 = objectY[i2];\n\t\t\tint k3 = objectType[i2];\n\t\t\tint m4 = objectID[i2];\n\t\t\tModel model = objectModelArray[i2];\n\t\t\ttry {\n\t\t\t\tint l4 = objectID[i2];\n\t\t\t\tint k5;\n\t\t\t\tint i6;\n\t\t\t\tif (l4 == 0 || l4 == 4) {\n\t\t\t\t\tk5 = EntityHandler.getObjectDef(k3).getWidth();\n\t\t\t\t\ti6 = EntityHandler.getObjectDef(k3).getHeight();\n\t\t\t\t} else {\n\t\t\t\t\ti6 = EntityHandler.getObjectDef(k3).getWidth();\n\t\t\t\t\tk5 = EntityHandler.getObjectDef(k3).getHeight();\n\t\t\t\t}\n\t\t\t\tint j6 = ((j2 + j2 + k5) * magicLoc) / 2;\n\t\t\t\tint k6 = ((l2 + l2 + i6) * magicLoc) / 2;\n\t\t\t\tif (j2 >= 0 && l2 >= 0 && j2 < 96 && l2 < 96) {\n\t\t\t\t\tgameCamera.addModel(model);\n\t\t\t\t\tmodel.method191(j6,\n\t\t\t\t\t\t\t-engineHandle.getAveragedElevation(j6, k6), k6);\n\t\t\t\t\tengineHandle.method412(j2, l2, k3, m4);\n\t\t\t\t\tif (k3 == 74)\n\t\t\t\t\t\tmodel.method190(0, -480, 0);\n\t\t\t\t}\n\t\t\t} catch (RuntimeException runtimeexception) {\n\t\t\t\tSystem.out.println(\"Loc Error: \"\n\t\t\t\t\t\t+ runtimeexception.getMessage());\n\t\t\t\tSystem.out.println(\"i:\" + i2 + \" obj:\" + model);\n\t\t\t\truntimeexception.printStackTrace();\n\t\t\t}\n\t\t}\n\t\tfor (int k2 = 0; k2 < doorCount; k2++) {\n\t\t\tdoorX[k2] -= k1;\n\t\t\tdoorY[k2] -= l1;\n\t\t\tint i3 = doorX[k2];\n\t\t\tint l3 = doorY[k2];\n\t\t\tint j4 = doorType[k2];\n\t\t\tint i5 = doorDirection[k2];\n\t\t\ttry {\n\t\t\t\tengineHandle.method408(i3, l3, i5, j4);\n\t\t\t\tModel model_1 = makeModel(i3, l3, i5, j4, k2);\n\t\t\t\tdoorModel[k2] = model_1;\n\t\t\t} catch (RuntimeException runtimeexception1) {\n\t\t\t\tSystem.out.println(\"Bound Error: \"\n\t\t\t\t\t\t+ runtimeexception1.getMessage());\n\t\t\t\truntimeexception1.printStackTrace();\n\t\t\t}\n\t\t}\n\t\tfor (int j3 = 0; j3 < groundItemCount; j3++) {\n\t\t\tgroundItemX[j3] -= k1;\n\t\t\tgroundItemY[j3] -= l1;\n\t\t}\n\t\tfor (int i4 = 0; i4 < playerCount; i4++) {\n\t\t\tMob mob = playerArray[i4];\n\t\t\tmob.currentX -= k1 * magicLoc;\n\t\t\tmob.currentY -= l1 * magicLoc;\n\t\t\tfor (int j5 = 0; j5 <= mob.waypointCurrent; j5++) {\n\t\t\t\tmob.waypointsX[j5] -= k1 * magicLoc;\n\t\t\t\tmob.waypointsY[j5] -= l1 * magicLoc;\n\t\t\t}\n\t\t}\n\t\tfor (int k4 = 0; k4 < npcCount; k4++) {\n\t\t\tMob mob_1 = npcArray[k4];\n\t\t\tmob_1.currentX -= k1 * magicLoc;\n\t\t\tmob_1.currentY -= l1 * magicLoc;\n\t\t\tfor (int l5 = 0; l5 <= mob_1.waypointCurrent; l5++) {\n\t\t\t\tmob_1.waypointsX[l5] -= k1 * magicLoc;\n\t\t\t\tmob_1.waypointsY[l5] -= l1 * magicLoc;\n\t\t\t}\n\t\t}\n\t\tengineHandle.playerIsAlive = true;\n\t\treturn true;\n\t}\n\tprivate final void drawMagicWindow(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tint j = 36;\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 4);\n\t\tchar c = '\\304';\n\t\tchar c1 = '\\266';\n\t\tint l;\n\t\tint k = l = GameImage.convertRGBToLong(160, 160, 160);\n\t\tif (menuMagicPrayersSelected == 0)\n\t\t\tk = GameImage.convertRGBToLong(220, 220, 220);\n\t\telse\n\t\t\tl = GameImage.convertRGBToLong(220, 220, 220);\n\t\tgameGraphics.drawBoxAlpha(i, j, c / 2, 24, k, 128);\n\t\tgameGraphics.drawBoxAlpha(i + c / 2, j, c / 2, 24, l, 128);\n\t\tgameGraphics.drawBoxAlpha(i, j + 24, c, 90,\n\t\t\t\tGameImage.convertRGBToLong(220, 220, 220), 128);\n\t\tgameGraphics.drawBoxAlpha(i, j + 24 + 90, c, c1 - 90 - 24,\n\t\t\t\tGameImage.convertRGBToLong(160, 160, 160), 128);\n\t\tgameGraphics.drawLineX(i, j + 24, c, 0);\n\t\tgameGraphics.drawLineY(i + c / 2, j, 24, 0);\n\t\tgameGraphics.drawLineX(i, j + 113, c, 0);\n\t\tgameGraphics.drawText(\"Magic\", i + c / 4, j + 16, 4, 0);\n\t\tgameGraphics.drawText(\"Prayers\", i + c / 4 + c / 2, j + 16, 4, 0);\n\t\tif (menuMagicPrayersSelected == 0) {\n\t\t\tspellMenu.resetListTextCount(spellMenuHandle);\n\t\t\tint i1 = 0;\n\t\t\tfor (int spellIndex = 0; spellIndex < EntityHandler.spellCount(); spellIndex++) {\n\t\t\t\tString s = \"@yel@\";\n\t\t\t\tfor (Entry e : EntityHandler.getSpellDef(spellIndex)\n\t\t\t\t\t\t.getRunesRequired()) {\n\t\t\t\t\tif (hasRequiredRunes((Integer) e.getKey(),\n\t\t\t\t\t\t\t(Integer) e.getValue())) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\ts = \"@whi@\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tint spellLevel = playerStatCurrent[6];\n\t\t\t\tif (EntityHandler.getSpellDef(spellIndex).getReqLevel() > spellLevel) {\n\t\t\t\t\ts = \"@bla@\";\n\t\t\t\t}\n\t\t\t\tspellMenu.drawMenuListText(spellMenuHandle, i1++, s + \"Level \"\n\t\t\t\t\t\t+ EntityHandler.getSpellDef(spellIndex).getReqLevel()\n\t\t\t\t\t\t+ \": \"\n\t\t\t\t\t\t+ EntityHandler.getSpellDef(spellIndex).getName());\n\t\t\t}\n\t\t\tspellMenu.drawMenu();\n\t\t\tint selectedSpellIndex = spellMenu\n\t\t\t\t\t.selectedListIndex(spellMenuHandle);\n\t\t\tif (selectedSpellIndex != -1) {\n\t\t\t\tgameGraphics\n\t\t\t\t\t\t.drawString(\n\t\t\t\t\t\t\t\t\"Level \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpellIndex)\n\t\t\t\t\t\t\t\t\t\t\t\t.getReqLevel()\n\t\t\t\t\t\t\t\t\t\t+ \": \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpellIndex).getName(),\n\t\t\t\t\t\t\t\ti + 2, j + 124, 1, 0xffff00);\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getSpellDef(selectedSpellIndex)\n\t\t\t\t\t\t\t\t.getDescription(), i + 2, j + 136, 0, 0xffffff);\n\t\t\t\tint i4 = 0;\n\t\t\t\tfor (Entry<Integer, Integer> e : EntityHandler.getSpellDef(\n\t\t\t\t\t\tselectedSpellIndex).getRunesRequired()) {\n\t\t\t\t\tint runeID = e.getKey();\n\t\t\t\t\tgameGraphics.drawPicture(i + 2 + i4 * 44, j + 150,\n\t\t\t\t\t\t\tSPRITE_ITEM_START\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(runeID)\n\t\t\t\t\t\t\t\t\t\t\t.getSprite());\n\t\t\t\t\tint runeInvCount = inventoryCount(runeID);\n\t\t\t\t\tint runeCount = e.getValue();\n\t\t\t\t\tString s2 = \"@red@\";\n\t\t\t\t\tif (hasRequiredRunes(runeID, runeCount)) {\n\t\t\t\t\t\ts2 = \"@gre@\";\n\t\t\t\t\t}\n\t\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\t\ts2 + runeInvCount + \"/\" + runeCount, i + 2 + i4\n\t\t\t\t\t\t\t\t\t* 44, j + 150, 1, 0xffffff);\n\t\t\t\t\ti4++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawString(\"Point at a spell for a description\",\n\t\t\t\t\t\ti + 2, j + 124, 1, 0);\n\t\t\t}\n\t\t}\n\t\tif (menuMagicPrayersSelected == 1) {\n\t\t\tspellMenu.resetListTextCount(spellMenuHandle);\n\t\t\tint j1 = 0;\n\t\t\tfor (int j2 = 0; j2 < EntityHandler.prayerCount(); j2++) {\n\t\t\t\tString s1 = \"@whi@\";\n\t\t\t\tif (EntityHandler.getPrayerDef(j2).getReqLevel() > playerStatBase[5])\n\t\t\t\t\ts1 = \"@bla@\";\n\t\t\t\tif (prayerOn[j2])\n\t\t\t\t\ts1 = \"@gre@\";\n\t\t\t\tspellMenu.drawMenuListText(spellMenuHandle, j1++, s1 + \"Level \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j2).getReqLevel() + \": \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j2).getName());\n\t\t\t}\n\t\t\tspellMenu.drawMenu();\n\t\t\tint j3 = spellMenu.selectedListIndex(spellMenuHandle);\n\t\t\tif (j3 != -1) {\n\t\t\t\tgameGraphics.drawText(\"Level \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j3).getReqLevel() + \": \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j3).getName(), i + c / 2,\n\t\t\t\t\t\tj + 130, 1, 0xffff00);\n\t\t\t\tif (j3 == 13) {\n\t\t\t\t\tif (playerStatBase[5] > 39) {\n\t\t\t\t\t\tint percent = (int) ((playerStatBase[5] - 40) * 0.6);\n\t\t\t\t\t\tpercent += 60;\n\t\t\t\t\t\tif (percent > 100)\n\t\t\t\t\t\t\tpercent = 100;\n\t\t\t\t\t\tgameGraphics.drawText(percent\n\t\t\t\t\t\t\t\t+ \"% protection from ranged attack\", i + c / 2,\n\t\t\t\t\t\t\t\tj + 145, 0, 0xffffff);\n\t\t\t\t\t} else\n\t\t\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\t\t\"60% protection from ranged attack\", i + c / 2,\n\t\t\t\t\t\t\t\tj + 145, 0, 0xffffff);\n\t\t\t\t} else\n\t\t\t\t\tgameGraphics.drawText(EntityHandler.getPrayerDef(j3)\n\t\t\t\t\t\t\t.getDescription(), i + c / 2, j + 145, 0, 0xffffff);\n\t\t\t\tgameGraphics.drawText(\"Drain rate: \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j3).getDrainRate(), i + c\n\t\t\t\t\t\t/ 2, j + 160, 1, 0);\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawString(\"Point at a prayer for a description\",\n\t\t\t\t\t\ti + 2, j + 124, 1, 0);\n\t\t\t}\n\t\t}\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 182) {\n\t\t\tspellMenu.updateActions(i\n\t\t\t\t\t+ (((GameImage) (gameGraphics)).menuDefaultWidth - 199),\n\t\t\t\t\tj + 36, super.lastMouseDownButton, super.mouseDownButton);\n\t\t\tif (j <= 24 && mouseButtonClick == 1)\n\t\t\t\tif (i < 98 && menuMagicPrayersSelected == 1) {\n\t\t\t\t\tmenuMagicPrayersSelected = 0;\n\t\t\t\t\tprayerMenuIndex = spellMenu.getMenuIndex(spellMenuHandle);\n\t\t\t\t\tspellMenu.method165(spellMenuHandle, magicMenuIndex);\n\t\t\t\t} else if (i > 98 && menuMagicPrayersSelected == 0) {\n\t\t\t\t\tmenuMagicPrayersSelected = 1;\n\t\t\t\t\tmagicMenuIndex = spellMenu.getMenuIndex(spellMenuHandle);\n\t\t\t\t\tspellMenu.method165(spellMenuHandle, prayerMenuIndex);\n\t\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && menuMagicPrayersSelected == 0) {\n\t\t\t\tint k1 = spellMenu.selectedListIndex(spellMenuHandle);\n\t\t\t\tif (k1 != -1) {\n\t\t\t\t\tint k2 = playerStatCurrent[6];\n\t\t\t\t\tif (EntityHandler.getSpellDef(k1).getReqLevel() > k2) {\n\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\"Your magic ability is not high enough for this spell\",\n\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint k3 = 0;\n\t\t\t\t\t\tfor (Entry<Integer, Integer> e : EntityHandler\n\t\t\t\t\t\t\t\t.getSpellDef(k1).getRunesRequired()) {\n\t\t\t\t\t\t\tif (!hasRequiredRunes(e.getKey(), e.getValue())) {\n\t\t\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\t\t\"You don't have all the reagents you need for this spell\",\n\t\t\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\t\t\t\tk3 = -1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tk3++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (k3 == EntityHandler.getSpellDef(k1).getRuneCount()) {\n\t\t\t\t\t\t\tselectedSpell = k1;\n\t\t\t\t\t\t\tselectedItem = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && menuMagicPrayersSelected == 1) {\n\t\t\t\tint l1 = spellMenu.selectedListIndex(spellMenuHandle);\n\t\t\t\tif (l1 != -1) {\n\t\t\t\t\tint l2 = playerStatBase[5];\n\t\t\t\t\tif (EntityHandler.getPrayerDef(l1).getReqLevel() > l2)\n\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\"Your prayer ability is not high enough for this prayer\",\n\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\telse if (playerStatCurrent[5] == 0)\n\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\"You have run out of prayer points. Return to a church to recharge\",\n\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\telse if (prayerOn[l1]) {\n\t\t\t\t\t\tsuper.streamClass.createPacket(248);\n\t\t\t\t\t\tsuper.streamClass.addByte(l1);\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\tprayerOn[l1] = false;\n\t\t\t\t\t\tplaySound(\"prayeroff\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsuper.streamClass.createPacket(56);\n\t\t\t\t\t\tsuper.streamClass.addByte(l1);\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\tprayerOn[l1] = true;\n\t\t\t\t\t\tplaySound(\"prayeron\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprotected final void handleWheelRotate(int units) {\n\t\tif (super.controlDown) {\n\t\t\tif (units > -1) {\n\t\t\t\tif (cameraVertical >= 1000)\n\t\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tif (cameraVertical <= 850)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\tcameraVertical += units * 2;\n\t\t}\n\t}\n\tprotected final void handleMenuKeyDown(int key, char keyChar) {\n\t\tif (!menusLoaded)\n\t\t\treturn;\n\t\tswitch (key) {\n\t\tcase 123: \n\t\t\ttakeScreenshot(true);\n\t\t\tbreak;\n\t\tcase 33: {\n\t\t\tif (cameraHeight < 300) {\n\t\t\t\tcameraHeight += 25;\n\t\t\t} else {\n\t\t\t\tcameraHeight -= 25;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 34: { \n\t\t\tif (cameraHeight > 1500) {\n\t\t\t\tcameraHeight -= 25;\n\t\t\t} else {\n\t\t\t\tcameraHeight += 25;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 36: {\n\t\t\tcameraHeight = 750;\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t\tif (loggedIn == 0) {\n\t\t\tif (loginScreenNumber == 0)\n\t\t\t\tmenuWelcome.keyDown(key, keyChar);\n\t\t\tif (loginScreenNumber == 1)\n\t\t\t\tmenuNewUser.keyDown(key, keyChar);\n\t\t\tif (loginScreenNumber == 2)\n\t\t\t\tmenuLogin.keyDown(key, keyChar);\n\t\t}\n\t\tif (loggedIn == 1) {\n\t\t\tif (showCharacterLookScreen) {\n\t\t\t\tcharacterDesignMenu.keyDown(key, keyChar);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (showDrawPointsScreen) {\n\t\t\t\tdrawPointsScreen.keyDown(key, keyChar);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputBoxType == 0 && showAbuseWindow == 0)\n\t\t\t\tgameMenu.keyDown(key, keyChar);\n\t\t}\n\t}\n\tprivate final void drawShopBox() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tmouseButtonClick = 0;\n\t\t\tint i = super.mouseX - 52 - xAddition;\n\t\t\tint j = super.mouseY - 44 - yAddition;\n\t\t\tif (i >= 0 && j >= 12 && i < 408 && j < 246) {\n\t\t\t\tint k = 0;\n\t\t\t\tfor (int i1 = 0; i1 < 5; i1++) {\n\t\t\t\t\tfor (int i2 = 0; i2 < 8; i2++) {\n\t\t\t\t\t\tint l2 = 7 + i2 * 49;\n\t\t\t\t\t\tint l3 = 28 + i1 * 34;\n\t\t\t\t\t\tif (i > l2 && i < l2 + 49 && j > l3 && j < l3 + 34\n\t\t\t\t\t\t\t\t&& shopItems[k] != -1) {\n\t\t\t\t\t\t\tselectedShopItemIndex = k;\n\t\t\t\t\t\t\tselectedShopItemType = shopItems[k];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (selectedShopItemIndex >= 0) {\n\t\t\t\t\tint j2 = shopItems[selectedShopItemIndex];\n\t\t\t\t\tif (j2 != -1) {\n\t\t\t\t\t\tif (shopItemCount[selectedShopItemIndex] > 0 && i > 298\n\t\t\t\t\t\t\t\t&& j >= 204 && i < 408 && j <= 215) {\n\t\t\t\t\t\t\tint i4 = shopItemsBuyPrice[selectedShopItemIndex];\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(128);\n\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t.add2ByteInt(shopItems[selectedShopItemIndex]);\n\t\t\t\t\t\t\tsuper.streamClass.add4ByteInt(i4);\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (inventoryCount(j2) > 0 && i > 2 && j >= 229\n\t\t\t\t\t\t\t\t&& i < 112 && j <= 240) {\n\t\t\t\t\t\t\tint j4 = shopItemsSellPrice[selectedShopItemIndex];\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(255);\n\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t.add2ByteInt(shopItems[selectedShopItemIndex]);\n\t\t\t\t\t\t\tsuper.streamClass.add4ByteInt(j4);\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.streamClass.createPacket(253);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tshowShop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tint byte0 = 52 + xAddition;\n\t\tint byte1 = 44 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 408, 12, 192);\n\t\tint l = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 12, 408, 17, l, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 29, 8, 170, l, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 399, byte1 + 29, 9, 170, l, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 199, 408, 47, l, 160);\n\t\tgameGraphics.drawString(\"Buying and selling items\", byte0 + 1,\n\t\t\t\tbyte1 + 10, 1, 0xffffff);\n\t\tint j1 = 0xffffff;\n\t\tif (super.mouseX > byte0 + 320 && super.mouseY >= byte1\n\t\t\t\t&& super.mouseX < byte0 + 408 && super.mouseY < byte1 + 12)\n\t\t\tj1 = 0xff0000;\n\t\tgameGraphics.drawBoxTextRight(\"Close window\", byte0 + 406, byte1 + 10,\n\t\t\t\t1, j1);\n\t\tgameGraphics.drawString(\"Shops stock in green\", byte0 + 2, byte1 + 24,\n\t\t\t\t1, 65280);\n\t\tgameGraphics.drawString(\"Number you own in blue\", byte0 + 135,\n\t\t\t\tbyte1 + 24, 1, 65535);\n\t\tgameGraphics.drawString(\"Your money: \" + inventoryCount(10) + \"gp\",\n\t\t\t\tbyte0 + 280, byte1 + 24, 1, 0xffff00);\n\t\tint k2 = 0xd0d0d0;\n\t\tint k3 = 0;\n\t\tfor (int k4 = 0; k4 < 5; k4++) {\n\t\t\tfor (int l4 = 0; l4 < 8; l4++) {\n\t\t\t\tint j5 = byte0 + 7 + l4 * 49;\n\t\t\t\tint i6 = byte1 + 28 + k4 * 34;\n\t\t\t\tif (selectedShopItemIndex == k3)\n\t\t\t\t\tgameGraphics.drawBoxAlpha(j5, i6, 49, 34, 0xff0000, 160);\n\t\t\t\telse\n\t\t\t\t\tgameGraphics.drawBoxAlpha(j5, i6, 49, 34, k2, 160);\n\t\t\t\tgameGraphics.drawBoxEdge(j5, i6, 50, 35, 0);\n\t\t\t\tif (shopItems[k3] != -1) {\n\t\t\t\t\tgameGraphics.spriteClip4(j5, i6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t\t\t+ EntityHandler.getItemDef(shopItems[k3])\n\t\t\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\t\t\tEntityHandler.getItemDef(shopItems[k3])\n\t\t\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\t\t\tgameGraphics.drawString(String.valueOf(shopItemCount[k3]),\n\t\t\t\t\t\t\tj5 + 1, i6 + 10, 1, 65280);\n\t\t\t\t\tgameGraphics.drawBoxTextRight(\n\t\t\t\t\t\t\tString.valueOf(inventoryCount(shopItems[k3])),\n\t\t\t\t\t\t\tj5 + 47, i6 + 10, 1, 65535);\n\t\t\t\t}\n\t\t\t\tk3++;\n\t\t\t}\n\t\t}\n\t\tgameGraphics.drawLineX(byte0 + 5, byte1 + 222, 398, 0);\n\t\tif (selectedShopItemIndex == -1) {\n\t\t\tgameGraphics.drawText(\"Select an object to buy or sell\",\n\t\t\t\t\tbyte0 + 204, byte1 + 214, 3, 0xffff00);\n\t\t\treturn;\n\t\t}\n\t\tint i5 = shopItems[selectedShopItemIndex];\n\t\tif (i5 != -1) {\n\t\t\tif (shopItemCount[selectedShopItemIndex] > 0) {\n\t\t\t\tint j6 = shopItemsBuyPrice[selectedShopItemIndex];\n\t\t\t\tgameGraphics.drawString(\"Buy a new \"\n\t\t\t\t\t\t+ EntityHandler.getItemDef(i5).getName() + \" for \" + j6\n\t\t\t\t\t\t+ \"gp\", byte0 + 2, byte1 + 214, 1, 0xffff00);\n\t\t\t\tint k1 = 0xffffff;\n\t\t\t\tif (super.mouseX > byte0 + 298 && super.mouseY >= byte1 + 204\n\t\t\t\t\t\t&& super.mouseX < byte0 + 408\n\t\t\t\t\t\t&& super.mouseY <= byte1 + 215)\n\t\t\t\t\tk1 = 0xff0000;\n\t\t\t\tgameGraphics.drawBoxTextRight(\"Click here to buy\", byte0 + 405,\n\t\t\t\t\t\tbyte1 + 214, 3, k1);\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\"This item is not currently available to buy\",\n\t\t\t\t\t\tbyte0 + 204, byte1 + 214, 3, 0xffff00);\n\t\t\t}\n\t\t\tif (inventoryCount(i5) > 0) {\n\t\t\t\tint k6 = shopItemsSellPrice[selectedShopItemIndex];\n\t\t\t\tgameGraphics.drawBoxTextRight(\"Sell your \"\n\t\t\t\t\t\t+ EntityHandler.getItemDef(i5).getName() + \" for \" + k6\n\t\t\t\t\t\t+ \"gp\", byte0 + 405, byte1 + 239, 1, 0xffff00);\n\t\t\t\tint l1 = 0xffffff;\n\t\t\t\tif (super.mouseX > byte0 + 2 && super.mouseY >= byte1 + 229\n\t\t\t\t\t\t&& super.mouseX < byte0 + 112\n\t\t\t\t\t\t&& super.mouseY <= byte1 + 240)\n\t\t\t\t\tl1 = 0xff0000;\n\t\t\t\tgameGraphics.drawString(\"Click here to sell\", byte0 + 2,\n\t\t\t\t\t\tbyte1 + 239, 3, l1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgameGraphics.drawText(\"You do not have any of this item to sell\",\n\t\t\t\t\tbyte0 + 204, byte1 + 239, 3, 0xffff00);\n\t\t}\n\t}\n\tprivate final void drawGameMenu() {\n\t\tgameMenu = new Menu(gameGraphics, 10);\n\t\tmessagesHandleType2 = gameMenu.method159(5, windowHeight - 85,\n\t\t\t\twindowWidth - 10, 56, 1, 20, true);\n\t\tchatHandle = gameMenu.method160(7, windowHeight - 10, windowWidth - 14,\n\t\t\t\t14, 1, 80, false, true);\n\t\tmessagesHandleType5 = gameMenu.method159(5, windowHeight - 65,\n\t\t\t\twindowWidth - 10, 56, 1, 20, true);\n\t\tmessagesHandleType6 = gameMenu.method159(5, windowHeight - 65,\n\t\t\t\twindowWidth - 10, 56, 1, 20, true);\n\t\tgameMenu.setFocus(chatHandle);\n\t}\n\tprotected final byte[] load(String filename) {\n\t\tCacheManager.load(filename);\n\t\treturn super.load(Config.CONF_DIR + File.separator + filename);\n\t}\n\tprivate final void drawOurOptionsMenu(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 232;\n\t\tint j = 36;\n\t\tint c = 360;\n\t\tgameGraphics.drawBoxAlpha(i, 36, c, 176,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBox(i, 3, 31, 32,\n\t\t\t\tGameImage.convertRGBToLong(0, 0, 131));\n\t\tint temp = 10;\n\t\tgameGraphics.drawBox(i, 26, 274, temp,\n\t\t\t\tGameImage.convertRGBToLong(0, 0, 131));\n\t\tgameGraphics.drawBox(i, 26 + temp, 274, 1,\n\t\t\t\tGameImage.convertRGBToLong(0, 0, 0));\n\t\tgameGraphics.drawString(\"screen size\", i + 147, 26 + temp, 4, 0xffffff);\n\t\tint k = i + 3;\n\t\tint i1 = j + 15;\n\t\ti1 += 15;\n\t\tif (Resolutions.fs)\n\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\" Fullscreen @gre@On\", k,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\" Fullscreen @red@Off\", k,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\" Screen size @gre@\"\n\t\t\t\t+ reso.getResolution(), k, i1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\" Refresh rate @gre@\"\n\t\t\t\t+ reso.getRefreshRate(), k, i1, 1, 0xffffff);\n\t\ti1 += 30;\n\t\tgameGraphics.drawString(\" Window size will change after you\", k,\n\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics\n\t\t\t\t.drawString(\" restart the client.\", k, i1, 1, 0xffffff);\n\t\ti1 += 30;\n\t\tgameGraphics.drawString(\" Going to fullsreen and back does\", k,\n\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\" not require a client restart.\", k, i1,\n\t\t\t\t1, 0xffffff);\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 265) {\n\t\t\tint l1 = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\t\tbyte byte0 = 36;\n\t\t\tchar c1 = '\\304';\n\t\t\tint l = l1 + 3;\n\t\t\tint j1 = byte0 + 30;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tif (gameFrame == null) {\n\t\t\t\t\tmudclient\n\t\t\t\t\t\t\t.drawPopup(\"You cannot switch to fullscreen from the webclient, sorry!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (Resolutions.fs) {\n\t\t\t\t\tgameFrame.makeRegularScreen();\n\t\t\t\t} else {\n\t\t\t\t\tgameFrame.makeFullScreen();\n\t\t\t\t}\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\treso.findNextResolution();\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"width\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getWidth());\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"height\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getHeight());\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"refreshRate\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getRefreshRate());\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"bitDepth\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getBitDepth());\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tboolean flag1 = false;\n\t\t\tj1 += 35;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tj1 += 20;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1)\n\t\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void drawOptionsMenu(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tint j = 36;\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 6);\n\t\tchar c = '\\304';\n\t\tgameGraphics.drawBoxAlpha(i, 36, c, 65,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBoxAlpha(i, 101, c, 65,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBoxAlpha(i, 166, c, 95,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBoxAlpha(i, 261, c, 52,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tint k = i + 3;\n\t\tint i1 = j + 15;\n\t\tgameGraphics.drawString(\"Game options - click to toggle\", k, i1, 1, 0);\n\t\ti1 += 15;\n\t\tif (configAutoCameraAngle)\n\t\t\tgameGraphics.drawString(\"Camera angle mode - @gre@Auto\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Camera angle mode - @red@Manual\", k, i1,\n\t\t\t\t\t1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (configMouseButtons)\n\t\t\tgameGraphics.drawString(\"Mouse buttons - @red@One\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Mouse buttons - @gre@Two\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tif (configSoundEffects)\n\t\t\tgameGraphics.drawString(\"Sound effects - @red@off\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Sound effects - @gre@on\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics\n\t\t\t\t.drawString(\"Client assists - click to toggle\", k, i1, 1, 0);\n\t\ti1 += 15;\n\t\tif (showRoof)\n\t\t\tgameGraphics\n\t\t\t\t\t.drawString(\"Hide Roofs - @red@off\", k, i1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Hide Roofs - @gre@on\", k, i1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (autoScreenshot)\n\t\t\tgameGraphics.drawString(\"Auto Screenshots - @gre@on\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Auto Screenshots - @red@off\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tif (combatWindow)\n\t\t\tgameGraphics.drawString(\"Fightmode Selector - @gre@on\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Fightmode Selector - @red@off\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tif (fog)\n\t\t\tgameGraphics.drawString(\"Fog of War - @gre@on\", k, i1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics\n\t\t\t\t\t.drawString(\"Fog of War - @red@off\", k, i1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\ti1 += 5;\n\t\tgameGraphics.drawString(\"Privacy settings. Will be applied to\", i + 3,\n\t\t\t\ti1, 1, 0);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\"all people not on your friends list\", i + 3,\n\t\t\t\ti1, 1, 0);\n\t\ti1 += 15;\n\t\tif (super.blockChatMessages == 0)\n\t\t\tgameGraphics.drawString(\"Block chat messages: @red@<off>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block chat messages: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (super.blockPrivateMessages == 0)\n\t\t\tgameGraphics.drawString(\"Block private messages: @red@<off>\",\n\t\t\t\t\ti + 3, i1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block private messages: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (super.blockTradeRequests == 0)\n\t\t\tgameGraphics.drawString(\"Block trade requests: @red@<off>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block trade requests: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (super.blockDuelRequests == 0)\n\t\t\tgameGraphics.drawString(\"Block duel requests: @red@<off>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block duel requests: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\ti1 += 5;\n\t\tgameGraphics.drawString(\"Always logout when you finish\", k, i1, 1, 0);\n\t\ti1 += 15;\n\t\tint k1 = 0xffffff;\n\t\tif (super.mouseX > k && super.mouseX < k + c && super.mouseY > i1 - 12\n\t\t\t\t&& super.mouseY < i1 + 4)\n\t\t\tk1 = 0xffff00;\n\t\tgameGraphics.drawString(\"Click here to logout\", i + 3, i1, 1, k1);\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 265) {\n\t\t\tint l1 = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\t\tbyte byte0 = 36;\n\t\t\tchar c1 = '\\304';\n\t\t\tint l = l1 + 3;\n\t\t\tint j1 = byte0 + 30;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tconfigAutoCameraAngle = !configAutoCameraAngle;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(0);\n\t\t\t\tsuper.streamClass.addByte(configAutoCameraAngle ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tconfigMouseButtons = !configMouseButtons;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(2);\n\t\t\t\tsuper.streamClass.addByte(configMouseButtons ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tconfigSoundEffects = !configSoundEffects;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(3);\n\t\t\t\tsuper.streamClass.addByte(configSoundEffects ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tshowRoof = !showRoof;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(4);\n\t\t\t\tsuper.streamClass.addByte(showRoof ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tautoScreenshot = !autoScreenshot;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(5);\n\t\t\t\tsuper.streamClass.addByte(autoScreenshot ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tcombatWindow = !combatWindow;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(6);\n\t\t\t\tsuper.streamClass.addByte(combatWindow ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tfog = !fog;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tboolean flag1 = false;\n\t\t\tj1 += 35;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockChatMessages = 1 - super.blockChatMessages;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockPrivateMessages = 1 - super.blockPrivateMessages;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockTradeRequests = 1 - super.blockTradeRequests;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockDuelRequests = 1 - super.blockDuelRequests;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (flag1)\n\t\t\t\tsendUpdatedPrivacyInfo(super.blockChatMessages,\n\t\t\t\t\t\tsuper.blockPrivateMessages, super.blockTradeRequests,\n\t\t\t\t\t\tsuper.blockDuelRequests);\n\t\t\tj1 += 20;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1)\n\t\t\t\tlogout();\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void processGame() {\n\t\ttry {\n\t\t\tif (super.keyDownDown) {\n\t\t\t\tcurrentChat++;\n\t\t\t\tif (currentChat >= messages.size()) {\n\t\t\t\t\tcurrentChat = messages.size() - 1;\n\t\t\t\t\tsuper.keyDownDown = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgameMenu.updateText(chatHandle, messages.get(currentChat));\n\t\t\t\tsuper.keyDownDown = false;\n\t\t\t}\n\t\t\tif (super.keyUpDown) {\n\t\t\t\tcurrentChat--;\n\t\t\t\tif (currentChat < 0) {\n\t\t\t\t\tcurrentChat = 0;\n\t\t\t\t\tsuper.keyUpDown = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgameMenu.updateText(chatHandle, messages.get(currentChat));\n\t\t\t\tsuper.keyUpDown = false;\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tif (systemUpdate > 1) {\n\t\t\tsystemUpdate--;\n\t\t}\n\t\tsendPingPacketReadPacketData();\n\t\tif (logoutTimeout > 0) {\n\t\t\tlogoutTimeout--;\n\t\t}\n\t\tif (ourPlayer.currentSprite == 8 || ourPlayer.currentSprite == 9) {\n\t\t\tlastWalkTimeout = 500;\n\t\t}\n\t\tif (lastWalkTimeout > 0) {\n\t\t\tlastWalkTimeout--;\n\t\t}\n\t\tif (showCharacterLookScreen) {\n\t\t\tdrawCharacterLookScreen();\n\t\t\treturn;\n\t\t}\n\t\tif (showDrawPointsScreen) {\n\t\t\tdrawPointsScreen();\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < playerCount; i++) {\n\t\t\tMob mob = playerArray[i];\n\t\t\tint k = (mob.waypointCurrent + 1) % 10;\n\t\t\tif (mob.waypointEndSprite != k) {\n\t\t\t\tint i1 = -1;\n\t\t\t\tint l2 = mob.waypointEndSprite;\n\t\t\t\tint j4;\n\t\t\t\tif (l2 < k)\n\t\t\t\t\tj4 = k - l2;\n\t\t\t\telse\n\t\t\t\t\tj4 = (10 + k) - l2;\n\t\t\t\tint j5 = 4;\n\t\t\t\tif (j4 > 2)\n\t\t\t\t\tj5 = (j4 - 1) * 4;\n\t\t\t\tif (mob.waypointsX[l2] - mob.currentX > magicLoc * 3\n\t\t\t\t\t\t|| mob.waypointsY[l2] - mob.currentY > magicLoc * 3\n\t\t\t\t\t\t|| mob.waypointsX[l2] - mob.currentX < -magicLoc * 3\n\t\t\t\t\t\t|| mob.waypointsY[l2] - mob.currentY < -magicLoc * 3\n\t\t\t\t\t\t|| j4 > 8) {\n\t\t\t\t\tmob.currentX = mob.waypointsX[l2];\n\t\t\t\t\tmob.currentY = mob.waypointsY[l2];\n\t\t\t\t} else {\n\t\t\t\t\tif (mob.currentX < mob.waypointsX[l2]) {\n\t\t\t\t\t\tmob.currentX += j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\ti1 = 2;\n\t\t\t\t\t} else if (mob.currentX > mob.waypointsX[l2]) {\n\t\t\t\t\t\tmob.currentX -= j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\ti1 = 6;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob.currentX - mob.waypointsX[l2] < j5\n\t\t\t\t\t\t\t&& mob.currentX - mob.waypointsX[l2] > -j5)\n\t\t\t\t\t\tmob.currentX = mob.waypointsX[l2];\n\t\t\t\t\tif (mob.currentY < mob.waypointsY[l2]) {\n\t\t\t\t\t\tmob.currentY += j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\tif (i1 == -1)\n\t\t\t\t\t\t\ti1 = 4;\n\t\t\t\t\t\telse if (i1 == 2)\n\t\t\t\t\t\t\ti1 = 3;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti1 = 5;\n\t\t\t\t\t} else if (mob.currentY > mob.waypointsY[l2]) {\n\t\t\t\t\t\tmob.currentY -= j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\tif (i1 == -1)\n\t\t\t\t\t\t\ti1 = 0;\n\t\t\t\t\t\telse if (i1 == 2)\n\t\t\t\t\t\t\ti1 = 1;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti1 = 7;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob.currentY - mob.waypointsY[l2] < j5\n\t\t\t\t\t\t\t&& mob.currentY - mob.waypointsY[l2] > -j5)\n\t\t\t\t\t\tmob.currentY = mob.waypointsY[l2];\n\t\t\t\t}\n\t\t\t\tif (i1 != -1)\n\t\t\t\t\tmob.currentSprite = i1;\n\t\t\t\tif (mob.currentX == mob.waypointsX[l2]\n\t\t\t\t\t\t&& mob.currentY == mob.waypointsY[l2])\n\t\t\t\t\tmob.waypointEndSprite = (l2 + 1) % 10;\n\t\t\t} else {\n\t\t\t\tmob.currentSprite = mob.nextSprite;\n\t\t\t}\n\t\t\tif (mob.lastMessageTimeout > 0)\n\t\t\t\tmob.lastMessageTimeout--;\n\t\t\tif (mob.anInt163 > 0)\n\t\t\t\tmob.anInt163--;\n\t\t\tif (mob.combatTimer > 0)\n\t\t\t\tmob.combatTimer--;\n\t\t\tif (playerAliveTimeout > 0) {\n\t\t\t\tplayerAliveTimeout--;\n\t\t\t\tif (playerAliveTimeout == 0)\n\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\"You have been granted another life. Be more careful this time!\",\n\t\t\t\t\t\t\t3, 0);\n\t\t\t\tif (playerAliveTimeout == 0)\n\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\"You retain your skills. Your objects land where you died\",\n\t\t\t\t\t\t\t3, 0);\n\t\t\t}\n\t\t}\n\t\tfor (int j = 0; j < npcCount; j++) {\n\t\t\tMob mob_1 = npcArray[j];\n\t\t\tif (mob_1 == null) {\n\t\t\t\tSystem.out.println(\"MOB == NULL, npcCount: \" + npcCount\n\t\t\t\t\t\t+ \", j: \" + j);\n\t\t\t\tSystem.exit(1);\n\t\t\t}\n\t\t\tint j1 = (mob_1.waypointCurrent + 1) % 10;\n\t\t\tif (mob_1.waypointEndSprite != j1) {\n\t\t\t\tint i3 = -1;\n\t\t\t\tint k4 = mob_1.waypointEndSprite;\n\t\t\t\tint k5;\n\t\t\t\tif (k4 < j1)\n\t\t\t\t\tk5 = j1 - k4;\n\t\t\t\telse\n\t\t\t\t\tk5 = (10 + j1) - k4;\n\t\t\t\tint l5 = 4;\n\t\t\t\tif (k5 > 2)\n\t\t\t\t\tl5 = (k5 - 1) * 4;\n\t\t\t\tif (mob_1.waypointsX[k4] - mob_1.currentX > magicLoc * 3\n\t\t\t\t\t\t|| mob_1.waypointsY[k4] - mob_1.currentY > magicLoc * 3\n\t\t\t\t\t\t|| mob_1.waypointsX[k4] - mob_1.currentX < -magicLoc * 3\n\t\t\t\t\t\t|| mob_1.waypointsY[k4] - mob_1.currentY < -magicLoc * 3\n\t\t\t\t\t\t|| k5 > 8) {\n\t\t\t\t\tmob_1.currentX = mob_1.waypointsX[k4];\n\t\t\t\t\tmob_1.currentY = mob_1.waypointsY[k4];\n\t\t\t\t} else {\n\t\t\t\t\tif (mob_1.currentX < mob_1.waypointsX[k4]) {\n\t\t\t\t\t\tmob_1.currentX += l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\ti3 = 2;\n\t\t\t\t\t} else if (mob_1.currentX > mob_1.waypointsX[k4]) {\n\t\t\t\t\t\tmob_1.currentX -= l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\ti3 = 6;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob_1.currentX - mob_1.waypointsX[k4] < l5\n\t\t\t\t\t\t\t&& mob_1.currentX - mob_1.waypointsX[k4] > -l5)\n\t\t\t\t\t\tmob_1.currentX = mob_1.waypointsX[k4];\n\t\t\t\t\tif (mob_1.currentY < mob_1.waypointsY[k4]) {\n\t\t\t\t\t\tmob_1.currentY += l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\tif (i3 == -1)\n\t\t\t\t\t\t\ti3 = 4;\n\t\t\t\t\t\telse if (i3 == 2)\n\t\t\t\t\t\t\ti3 = 3;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti3 = 5;\n\t\t\t\t\t} else if (mob_1.currentY > mob_1.waypointsY[k4]) {\n\t\t\t\t\t\tmob_1.currentY -= l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\tif (i3 == -1)\n\t\t\t\t\t\t\ti3 = 0;\n\t\t\t\t\t\telse if (i3 == 2)\n\t\t\t\t\t\t\ti3 = 1;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti3 = 7;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob_1.currentY - mob_1.waypointsY[k4] < l5\n\t\t\t\t\t\t\t&& mob_1.currentY - mob_1.waypointsY[k4] > -l5)\n\t\t\t\t\t\tmob_1.currentY = mob_1.waypointsY[k4];\n\t\t\t\t}\n\t\t\t\tif (i3 != -1)\n\t\t\t\t\tmob_1.currentSprite = i3;\n\t\t\t\tif (mob_1.currentX == mob_1.waypointsX[k4]\n\t\t\t\t\t\t&& mob_1.currentY == mob_1.waypointsY[k4])\n\t\t\t\t\tmob_1.waypointEndSprite = (k4 + 1) % 10;\n\t\t\t} else {\n\t\t\t\tmob_1.currentSprite = mob_1.nextSprite;\n\t\t\t\tif (mob_1.type == 43)\n\t\t\t\t\tmob_1.stepCount++;\n\t\t\t}\n\t\t\tif (mob_1.lastMessageTimeout > 0)\n\t\t\t\tmob_1.lastMessageTimeout--;\n\t\t\tif (mob_1.anInt163 > 0)\n\t\t\t\tmob_1.anInt163--;\n\t\t\tif (mob_1.combatTimer > 0)\n\t\t\t\tmob_1.combatTimer--;\n\t\t}\n\t\tif (mouseOverMenu != 2) {\n\t\t\tif (GameImage.anInt346 > 0)\n\t\t\t\tanInt658++;\n\t\t\tif (GameImage.anInt347 > 0)\n\t\t\t\tanInt658 = 0;\n\t\t\tGameImage.anInt346 = 0;\n\t\t\tGameImage.anInt347 = 0;\n\t\t}\n\t\tfor (int l = 0; l < playerCount; l++) {\n\t\t\tMob mob_2 = playerArray[l];\n\t\t\tif (mob_2.anInt176 > 0)\n\t\t\t\tmob_2.anInt176--;\n\t\t}\n\t\tif (cameraAutoAngleDebug) {\n\t\t\tif (lastAutoCameraRotatePlayerX - ourPlayer.currentX < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerX - ourPlayer.currentX > 500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY > 500) {\n\t\t\t\tlastAutoCameraRotatePlayerX = ourPlayer.currentX;\n\t\t\t\tlastAutoCameraRotatePlayerY = ourPlayer.currentY;\n\t\t\t}\n\t\t} else {\n\t\t\tif (lastAutoCameraRotatePlayerX - ourPlayer.currentX < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerX - ourPlayer.currentX > 500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY > 500) {\n\t\t\t\tlastAutoCameraRotatePlayerX = ourPlayer.currentX;\n\t\t\t\tlastAutoCameraRotatePlayerY = ourPlayer.currentY;\n\t\t\t}\n\t\t\tif (lastAutoCameraRotatePlayerX != ourPlayer.currentX)\n\t\t\t\tlastAutoCameraRotatePlayerX += (ourPlayer.currentX - lastAutoCameraRotatePlayerX)\n\t\t\t\t\t\t/ (16 + (cameraHeight - 500) / 15);\n\t\t\tif (lastAutoCameraRotatePlayerY != ourPlayer.currentY)\n\t\t\t\tlastAutoCameraRotatePlayerY += (ourPlayer.currentY - lastAutoCameraRotatePlayerY)\n\t\t\t\t\t\t/ (16 + (cameraHeight - 500) / 15);\n\t\t\tif (configAutoCameraAngle) {\n\t\t\t\tint k1 = cameraAutoAngle * 32;\n\t\t\t\tint j3 = k1 - cameraRotation;\n\t\t\t\tbyte byte0 = 1;\n\t\t\t\tif (j3 != 0) {\n\t\t\t\t\tcameraRotationBaseAddition++;\n\t\t\t\t\tif (j3 > 128) {\n\t\t\t\t\t\tbyte0 = -1;\n\t\t\t\t\t\tj3 = 256 - j3;\n\t\t\t\t\t} else if (j3 > 0)\n\t\t\t\t\t\tbyte0 = 1;\n\t\t\t\t\telse if (j3 < -128) {\n\t\t\t\t\t\tbyte0 = 1;\n\t\t\t\t\t\tj3 = 256 + j3;\n\t\t\t\t\t} else if (j3 < 0) {\n\t\t\t\t\t\tbyte0 = -1;\n\t\t\t\t\t\tj3 = -j3;\n\t\t\t\t\t}\n\t\t\t\t\tcameraRotation += ((cameraRotationBaseAddition * j3 + 255) / 256)\n\t\t\t\t\t\t\t* byte0;\n\t\t\t\t\tcameraRotation &= 0xff;\n\t\t\t\t} else {\n\t\t\t\t\tcameraRotationBaseAddition = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (anInt658 > 20) {\n\t\t\taBoolean767 = false;\n\t\t\tanInt658 = 0;\n\t\t}\n\t\tif (sleeping) {\n\t\t\tignoreNext = true;\n\t\t\tif (super.enteredText.length() > 0) {\n\t\t\t\tsuper.streamClass.createPacket(200);\n\t\t\t\tsuper.streamClass.addString(super.enteredText);\n\t\t\t\tif (!aBoolean767) {\n\t\t\t\t\tsuper.streamClass.addByte(0);\n\t\t\t\t\taBoolean767 = true;\n\t\t\t\t}\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tgameMenu.updateText(chatHandle, \"\");\n\t\t\t\tsleepMessage = \"Please wait...\";\n\t\t\t} \n\t\t\tif (super.lastMouseDownButton != 0\n\t\t\t\t\t&& super.mouseX >= ((windowWidth / 2) - 100)\n\t\t\t\t\t&& super.mouseX < ((windowWidth / 2) + 100)\n\t\t\t\t\t&& super.mouseY > 280 && super.mouseY < 310) {\n\t\t\t\tsuper.streamClass.createPacket(200);\n\t\t\t\tsuper.streamClass.addString(\"-null-\");\n\t\t\t\tif (!aBoolean767) {\n\t\t\t\t\tsuper.streamClass.addByte(0);\n\t\t\t\t\taBoolean767 = true;\n\t\t\t\t}\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tsleepMessage = \" Please wait...\";\n\t\t\t}\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\t\treturn;\n\t\t}\n\t\tif (super.mouseY > windowHeight - 4) {\n\t\t\tif (super.mouseX > 15 + xAddition && super.mouseX < 96 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1)\n\t\t\t\tmessagesTab = 0;\n\t\t\tif (super.mouseX > 110 + xAddition\n\t\t\t\t\t&& super.mouseX < 194 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tmessagesTab = 1;\n\t\t\t\tgameMenu.anIntArray187[messagesHandleType2] = 0xf423f;\n\t\t\t}\n\t\t\tif (super.mouseX > 215 + xAddition\n\t\t\t\t\t&& super.mouseX < 295 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tmessagesTab = 2;\n\t\t\t\tgameMenu.anIntArray187[messagesHandleType5] = 0xf423f;\n\t\t\t}\n\t\t\tif (super.mouseX > 315 + xAddition\n\t\t\t\t\t&& super.mouseX < 395 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tmessagesTab = 3;\n\t\t\t\tgameMenu.anIntArray187[messagesHandleType6] = 0xf423f;\n\t\t\t}\n\t\t\tif (super.mouseX > 417 + xAddition\n\t\t\t\t\t&& super.mouseX < 497 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tshowAbuseWindow = 1;\n\t\t\t\tabuseSelectedType = 0;\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t}\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\t\tsuper.mouseDownButton = 0;\n\t\t}\n\t\tgameMenu.updateActions(super.mouseX, super.mouseY,\n\t\t\t\tsuper.lastMouseDownButton, super.mouseDownButton);\n\t\tif (messagesTab > 0 && super.mouseX >= 494\n\t\t\t\t&& super.mouseY >= windowHeight - 66)\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\tif (gameMenu.hasActivated(chatHandle)) {\n\t\t\tString s = gameMenu.getText(chatHandle);\n\t\t\tgameMenu.updateText(chatHandle, \"\");\n\t\t\tif (ignoreNext) {\n\t\t\t\tignoreNext = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (s.startsWith(\"::\")) {\n\t\t\t\ts = s.substring(2);\n\t\t\t\tif (!handleCommand(s) && !sleeping && !ignoreNext) {\n\t\t\t\t\tsendChatString(s);\n\t\t\t\t\tif (messages.size() == 0\n\t\t\t\t\t\t\t|| !messages.get(messages.size() - 1)\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"::\" + s)) {\n\t\t\t\t\t\tmessages.add(\"::\" + s);\n\t\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t\t} else if (messages.get(messages.size() - 1)\n\t\t\t\t\t\t\t.equalsIgnoreCase(\"::\" + s)) {\n\t\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (!sleeping && !ignoreNext) {\n\t\t\t\tbyte[] chatMessage = DataConversions.stringToByteArray(s);\n\t\t\t\tsendChatMessage(chatMessage, chatMessage.length);\n\t\t\t\ts = DataConversions.byteToString(chatMessage, 0,\n\t\t\t\t\t\tchatMessage.length).trim();\n\t\t\t\tif (s.toLowerCase().trim().startsWith(\";;\"))\n\t\t\t\t\treturn;\n\t\t\t\tif (messages.size() == 0\n\t\t\t\t\t\t|| !messages.get(messages.size() - 1).equalsIgnoreCase(\n\t\t\t\t\t\t\t\ts)) {\n\t\t\t\t\tmessages.add(s);\n\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t} else if (messages.get(messages.size() - 1)\n\t\t\t\t\t\t.equalsIgnoreCase(s)) {\n\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t}\n\t\t\t\tourPlayer.lastMessageTimeout = 150;\n\t\t\t\tourPlayer.lastMessage = s;\n\t\t\t\tdisplayMessage(ourPlayer.name + \": \" + s, 2, ourPlayer.admin);\n\t\t\t}\n\t\t}\n\t\tif (messagesTab == 0) {\n\t\t\tfor (int l1 = 0; l1 < messagesTimeout.length; l1++)\n\t\t\t\tif (messagesTimeout[l1] > 0)\n\t\t\t\t\tmessagesTimeout[l1]--;\n\t\t}\n\t\tif (playerAliveTimeout != 0)\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\tif (showTradeWindow || showDuelWindow) {\n\t\t\tif (super.mouseDownButton != 0)\n\t\t\t\tmouseDownTime++;\n\t\t\telse\n\t\t\t\tmouseDownTime = 0;\n\t\t\tif (mouseDownTime > 500)\n\t\t\t\titemIncrement += 100000;\n\t\t\telse if (mouseDownTime > 350)\n\t\t\t\titemIncrement += 10000;\n\t\t\telse if (mouseDownTime > 250)\n\t\t\t\titemIncrement += 1000;\n\t\t\telse if (mouseDownTime > 150)\n\t\t\t\titemIncrement += 100;\n\t\t\telse if (mouseDownTime > 100)\n\t\t\t\titemIncrement += 10;\n\t\t\telse if (mouseDownTime > 50)\n\t\t\t\titemIncrement++;\n\t\t\telse if (mouseDownTime > 20 && (mouseDownTime & 5) == 0)\n\t\t\t\titemIncrement++;\n\t\t} else {\n\t\t\tmouseDownTime = 0;\n\t\t\titemIncrement = 0;\n\t\t}\n\t\tif (super.lastMouseDownButton == 1)\n\t\t\tmouseButtonClick = 1;\n\t\telse if (super.lastMouseDownButton == 2)\n\t\t\tmouseButtonClick = 2;\n\t\tgameCamera.updateMouseCoords(super.mouseX, super.mouseY);\n\t\tsuper.lastMouseDownButton = 0;\n\t\tif (configAutoCameraAngle) {\n\t\t\tif (cameraRotationBaseAddition == 0 || cameraAutoAngleDebug) {\n\t\t\t\tif (super.keyLeftDown) {\n\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 1 & 7;\n\t\t\t\t\tsuper.keyLeftDown = false;\n\t\t\t\t\tif (!zoomCamera) {\n\t\t\t\t\t\tif ((cameraAutoAngle & 1) == 0)\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 1 & 7;\n\t\t\t\t\t\tfor (int i2 = 0; i2 < 8; i2++) {\n\t\t\t\t\t\t\tif (enginePlayerVisible(cameraAutoAngle))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 1 & 7;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (super.keyRightDown) {\n\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 7 & 7;\n\t\t\t\t\tsuper.keyRightDown = false;\n\t\t\t\t\tif (!zoomCamera) {\n\t\t\t\t\t\tif ((cameraAutoAngle & 1) == 0)\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 7 & 7;\n\t\t\t\t\t\tfor (int j2 = 0; j2 < 8; j2++) {\n\t\t\t\t\t\t\tif (enginePlayerVisible(cameraAutoAngle))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 7 & 7;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else\n\t\t\ttry {\n\t\t\t\tif (super.keyLeftDown)\n\t\t\t\t\tcameraRotation = cameraRotation + 2 & 0xff;\n\t\t\t\telse if (super.keyRightDown)\n\t\t\t\t\tcameraRotation = cameraRotation - 2 & 0xff;\n\t\t\t\tif (super.home) {\n\t\t\t\t\tcameraHeight = 750;\n\t\t\t\t\tcameraVertical = 920;\n\t\t\t\t\tfogVar = 0;\n\t\t\t\t} else if (super.pageUp) {\n\t\t\t\t\tif (cameraHeight > 400)\n\t\t\t\t\t\tcameraHeight -= 6;\n\t\t\t\t} else if (super.pageDown) {\n\t\t\t\t\tif (cameraHeight < 3000)\n\t\t\t\t\t\tcameraHeight += 6;\n\t\t\t\t}\n\t\t\t\tif (controlDown && fog) {\n\t\t\t\t\tif (minus)\n\t\t\t\t\t\tfogVar += 20;\n\t\t\t\t\telse if (plus)\n\t\t\t\t\t\tfogVar -= 20;\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\tSystem.out.println(\"Camera error: \" + e);\n\t\t\t\tcameraHeight = 750;\n\t\t\t\tcameraVertical = 920;\n\t\t\t\tfogVar = 0;\n\t\t\t}\n\t\tif (actionPictureType > 0)\n\t\t\tactionPictureType--;\n\t\telse if (actionPictureType < 0)\n\t\t\tactionPictureType++;\n\t\tgameCamera.method301(17);\n\t\tmodelUpdatingTimer++;\n\t\tif (modelUpdatingTimer > 5) {\n\t\t\tmodelUpdatingTimer = 0;\n\t\t\tmodelFireLightningSpellNumber = (modelFireLightningSpellNumber + 1) % 3;\n\t\t\tmodelTorchNumber = (modelTorchNumber + 1) % 4;\n\t\t\tmodelClawSpellNumber = (modelClawSpellNumber + 1) % 5;\n\t\t}\n\t\tfor (int k2 = 0; k2 < objectCount; k2++) {\n\t\t\tint l3 = objectX[k2];\n\t\t\tint l4 = objectY[k2];\n\t\t\tif (l3 >= 0 && l4 >= 0 && l3 < 96 && l4 < 96\n\t\t\t\t\t&& objectType[k2] == 74)\n\t\t\t\tobjectModelArray[k2].method188(1, 0, 0);\n\t\t}\n\t\tfor (int i4 = 0; i4 < anInt892; i4++) {\n\t\t\tanIntArray923[i4]++;\n\t\t\tif (anIntArray923[i4] > 50) {\n\t\t\t\tanInt892--;\n\t\t\t\tfor (int i5 = i4; i5 < anInt892; i5++) {\n\t\t\t\t\tanIntArray944[i5] = anIntArray944[i5 + 1];\n\t\t\t\t\tanIntArray757[i5] = anIntArray757[i5 + 1];\n\t\t\t\t\tanIntArray923[i5] = anIntArray923[i5 + 1];\n\t\t\t\t\tanIntArray782[i5] = anIntArray782[i5 + 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic static HashMap<String, File> ctfsounds = new HashMap<String, File>();\n\tprivate final void loadSounds() {\n\t\ttry {\n\t\t\tdrawDownloadProgress(\"Unpacking Sound effects\", 90, false);\n\t\t\tsounds = load(\"sounds1.mem\");\n\t\t\taudioReader = new AudioReader();\n\t\t\treturn;\n\t\t} catch (Throwable throwable) {\n\t\t\tSystem.out.println(\"Unable to init sounds:\" + throwable);\n\t\t}\n\t}\n\tprivate final void drawCombatStyleWindow() {\n\t\tbyte byte0 = 7;\n\t\tbyte byte1 = 15;\n\t\tchar c = '\\257';\n\t\tif (mouseButtonClick != 0) {\n\t\t\tfor (int i = 0; i < 5; i++) {\n\t\t\t\tif (i <= 0 || super.mouseX <= byte0\n\t\t\t\t\t\t|| super.mouseX >= byte0 + c\n\t\t\t\t\t\t|| super.mouseY <= byte1 + i * 20\n\t\t\t\t\t\t|| super.mouseY >= byte1 + i * 20 + 20)\n\t\t\t\t\tcontinue;\n\t\t\t\tcombatStyle = i - 1;\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t\tsuper.streamClass.createPacket(42);\n\t\t\t\tsuper.streamClass.addByte(combatStyle);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor (int j = 0; j < 5; j++) {\n\t\t\tif (j == combatStyle + 1)\n\t\t\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + j * 20, c, 20,\n\t\t\t\t\t\tGameImage.convertRGBToLong(255, 0, 0), 128);\n\t\t\telse\n\t\t\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + j * 20, c, 20,\n\t\t\t\t\t\tGameImage.convertRGBToLong(190, 190, 190), 128);\n\t\t\tgameGraphics.drawLineX(byte0, byte1 + j * 20, c, 0);\n\t\t\tgameGraphics.drawLineX(byte0, byte1 + j * 20 + 20, c, 0);\n\t\t}\n\t\tgameGraphics.drawText(\"Select combat style\", byte0 + c / 2, byte1 + 16,\n\t\t\t\t3, 0xffffff);\n\t\tgameGraphics.drawText(\"Controlled (+1 of each)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 36, 3, 0);\n\t\tgameGraphics.drawText(\"Aggressive (+3 strength)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 56, 3, 0);\n\t\tgameGraphics.drawText(\"Accurate (+3 attack)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 76, 3, 0);\n\t\tgameGraphics.drawText(\"Defensive (+3 defense)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 96, 3, 0);\n\t}\n\tprivate final void drawDuelConfirmWindow() {\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 16, 192);\n\t\tint i = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 16, 468, 246, i, 160);\n\t\tgameGraphics.drawText(\"Please confirm your duel with @yel@\"\n\t\t\t\t+ DataOperations.longToString(duelOpponentNameLong),\n\t\t\t\tbyte0 + 234, byte1 + 12, 1, 0xffffff);\n\t\tgameGraphics.drawText(\"Your stake:\", byte0 + 117, byte1 + 30, 1,\n\t\t\t\t0xffff00);\n\t\tfor (int j = 0; j < duelConfirmMyItemCount; j++) {\n\t\t\tString s = EntityHandler.getItemDef(duelConfirmMyItems[j])\n\t\t\t\t\t.getName();\n\t\t\tif (EntityHandler.getItemDef(duelConfirmMyItems[j]).isStackable())\n\t\t\t\ts = s + \" x \" + method74(duelConfirmMyItemsCount[j]);\n\t\t\tgameGraphics.drawText(s, byte0 + 117, byte1 + 42 + j * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (duelConfirmMyItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 117, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tgameGraphics.drawText(\"Your opponent's stake:\", byte0 + 351,\n\t\t\t\tbyte1 + 30, 1, 0xffff00);\n\t\tfor (int k = 0; k < duelConfirmOpponentItemCount; k++) {\n\t\t\tString s1 = EntityHandler.getItemDef(duelConfirmOpponentItems[k])\n\t\t\t\t\t.getName();\n\t\t\tif (EntityHandler.getItemDef(duelConfirmOpponentItems[k])\n\t\t\t\t\t.isStackable())\n\t\t\t\ts1 = s1 + \" x \" + method74(duelConfirmOpponentItemsCount[k]);\n\t\t\tgameGraphics.drawText(s1, byte0 + 351, byte1 + 42 + k * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (duelConfirmOpponentItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 351, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tif (duelCantRetreat == 0)\n\t\t\tgameGraphics.drawText(\"You can retreat from this duel\",\n\t\t\t\t\tbyte0 + 234, byte1 + 180, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"No retreat is possible!\", byte0 + 234,\n\t\t\t\t\tbyte1 + 180, 1, 0xff0000);\n\t\tif (duelUseMagic == 0)\n\t\t\tgameGraphics.drawText(\"Magic may be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 192, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"Magic cannot be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 192, 1, 0xff0000);\n\t\tif (duelUsePrayer == 0)\n\t\t\tgameGraphics.drawText(\"Prayer may be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 204, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"Prayer cannot be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 204, 1, 0xff0000);\n\t\tif (duelUseWeapons == 0)\n\t\t\tgameGraphics.drawText(\"Weapons may be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 216, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"Weapons cannot be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 216, 1, 0xff0000);\n\t\tgameGraphics.drawText(\n\t\t\t\t\"If you are sure click 'Accept' to begin the duel\",\n\t\t\t\tbyte0 + 234, byte1 + 230, 1, 0xffffff);\n\t\tif (!duelWeAccept) {\n\t\t\tgameGraphics.drawPicture((byte0 + 118) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\t\tgameGraphics.drawPicture((byte0 + 352) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\t} else {\n\t\t\tgameGraphics.drawText(\"Waiting for other player...\", byte0 + 234,\n\t\t\t\t\tbyte1 + 250, 1, 0xffff00);\n\t\t}\n\t\tif (mouseButtonClick == 1) {\n\t\t\tif (super.mouseX < byte0 || super.mouseY < byte1\n\t\t\t\t\t|| super.mouseX > byte0 + 468 || super.mouseY > byte1 + 262) {\n\t\t\t\tshowDuelConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 118) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 118 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\tduelWeAccept = true;\n\t\t\t\tsuper.streamClass.createPacket(87);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 352) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 353 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\tshowDuelConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void updateBankItems() {\n\t\tbankItemCount = newBankItemCount;\n\t\tfor (int i = 0; i < newBankItemCount; i++) {\n\t\t\tbankItems[i] = newBankItems[i];\n\t\t\tbankItemsCount[i] = newBankItemsCount[i];\n\t\t}\n\t\tfor (int j = 0; j < inventoryCount; j++) {\n\t\t\tif (bankItemCount >= bankItemsMax)\n\t\t\t\tbreak;\n\t\t\tint k = getInventoryItems()[j];\n\t\t\tboolean flag = false;\n\t\t\tfor (int l = 0; l < bankItemCount; l++) {\n\t\t\t\tif (bankItems[l] != k)\n\t\t\t\t\tcontinue;\n\t\t\t\tflag = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!flag) {\n\t\t\t\tbankItems[bankItemCount] = k;\n\t\t\t\tbankItemsCount[bankItemCount] = 0;\n\t\t\t\tbankItemCount++;\n\t\t\t}\n\t\t}\n\t}\n\tprivate final void makeDPSMenu() {\n\t\tdrawPointsScreen = new Menu(gameGraphics, 100);\n\t\tfinal Menu dPS = drawPointsScreen;\n\t\tdPS.drawText(256, 10, \"Please select your points\", 4, true);\n\t\tint i = 140;\n\t\tint j = 34;\n\t\ti += 116;\n\t\tj -= 10;\n\t\tbyte byte0 = 54;\n\t\tj += 145;\n\t\tdPS.method157(i - byte0, j, 53, 41);\n\t\tdPS.drawText(i - byte0, j - 8, \"Str\", 1, true);\n\t\tdPS.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tstrDownButton = dPS.makeButton(i - byte0 - 40, j, 20, 20);\n\t\tdPS.method158((i - byte0) + 40, j, SPRITE_UTIL_START + 6);\n\t\tstrUpButton = dPS.makeButton((i - byte0) + 40, j, 20, 20);\n\t\tdPS.method157(i + byte0, j, 53, 41);\n\t\tdPS.drawText(i + byte0, j - 8, \"Atk\", 1, true);\n\t\tdPS.method158((i + byte0) - 40, j, SPRITE_UTIL_START + 7);\n\t\tatkDownButton = dPS.makeButton((i + byte0) - 40, j, 20, 20);\n\t\tdPS.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tatkUpButton = dPS.makeButton(i + byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tdPS.method157(i - byte0, j, 53, 41);\n\t\tdPS.drawText(i - byte0, j - 8, \"Def\", 1, true);\n\t\tdPS.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tdefDownButton = dPS.makeButton(i - byte0 - 40, j, 20, 20);\n\t\tdPS.method158((i - byte0) + 40, j, SPRITE_UTIL_START + 6);\n\t\tdefUpButton = dPS.makeButton((i - byte0) + 40, j, 20, 20);\n\t\tdPS.method157(i + byte0, j, 53, 41);\n\t\tdPS.drawText(i + byte0, j - 8, \"Range\", 1, true);\n\t\tdPS.method158((i + byte0) - 40, j, SPRITE_UTIL_START + 7);\n\t\trangeDownButton = dPS.makeButton((i + byte0) - 40, j, 20, 20);\n\t\tdPS.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\trangeUpButton = dPS.makeButton(i + byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tdPS.method157(i - byte0, j, 53, 41);\n\t\tdPS.drawText(i - byte0, j - 8, \"Magic\", 1, true);\n\t\tdPS.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tmagDownButton = dPS.makeButton(i - byte0 - 40, j, 20, 20);\n\t\tdPS.method158((i - byte0) + 40, j, SPRITE_UTIL_START + 6);\n\t\tmagUpButton = dPS.makeButton((i - byte0) + 40, j, 20, 20);\n\t\tj += 82;\n\t\tj -= 35;\n\t\tdPS.drawBox(i, j, 200, 30);\n\t\tdPS.drawText(i, j, \"Accept\", 4, false);\n\t\tdPSAcceptButton = dPS.makeButton(i, j, 200, 30);\n\t}\n\tprivate final void makeCharacterDesignMenu() {\n\t\tcharacterDesignMenu = new Menu(gameGraphics, 100);\n\t\tcharacterDesignMenu.drawText(256, 10, \"Please design Your Character\",\n\t\t\t\t4, true);\n\t\tint i = 140;\n\t\tint j = 34;\n\t\ti += 116;\n\t\tj -= 10;\n\t\tcharacterDesignMenu.drawText(i - 55, j + 110, \"Front\", 3, true);\n\t\tcharacterDesignMenu.drawText(i, j + 110, \"Side\", 3, true);\n\t\tcharacterDesignMenu.drawText(i + 55, j + 110, \"Back\", 3, true);\n\t\tbyte byte0 = 54;\n\t\tj += 145;\n\t\tcharacterDesignMenu.method157(i - byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i - byte0, j - 8, \"Head\", 1, true);\n\t\tcharacterDesignMenu.drawText(i - byte0, j + 8, \"Type\", 1, true);\n\t\tcharacterDesignMenu.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tcharacterDesignHeadButton1 = characterDesignMenu.makeButton(i - byte0\n\t\t\t\t- 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158((i - byte0) + 40, j,\n\t\t\t\tSPRITE_UTIL_START + 6);\n\t\tcharacterDesignHeadButton2 = characterDesignMenu.makeButton(\n\t\t\t\t(i - byte0) + 40, j, 20, 20);\n\t\tcharacterDesignMenu.method157(i + byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i + byte0, j - 8, \"Hair\", 1, true);\n\t\tcharacterDesignMenu.drawText(i + byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158((i + byte0) - 40, j,\n\t\t\t\tSPRITE_UTIL_START + 7);\n\t\tcharacterDesignHairColourButton1 = characterDesignMenu.makeButton(\n\t\t\t\t(i + byte0) - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tcharacterDesignHairColourButton2 = characterDesignMenu.makeButton(i\n\t\t\t\t+ byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tcharacterDesignMenu.method157(i - byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i - byte0, j, \"Gender\", 1, true);\n\t\tcharacterDesignMenu.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tcharacterDesignGenderButton1 = characterDesignMenu.makeButton(i - byte0\n\t\t\t\t- 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158((i - byte0) + 40, j,\n\t\t\t\tSPRITE_UTIL_START + 6);\n\t\tcharacterDesignGenderButton2 = characterDesignMenu.makeButton(\n\t\t\t\t(i - byte0) + 40, j, 20, 20);\n\t\tcharacterDesignMenu.method157(i + byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i + byte0, j - 8, \"Top\", 1, true);\n\t\tcharacterDesignMenu.drawText(i + byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158((i + byte0) - 40, j,\n\t\t\t\tSPRITE_UTIL_START + 7);\n\t\tcharacterDesignTopColourButton1 = characterDesignMenu.makeButton(\n\t\t\t\t(i + byte0) - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tcharacterDesignTopColourButton2 = characterDesignMenu.makeButton(i\n\t\t\t\t+ byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tcharacterDesignMenu.method157(i - byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i - byte0, j - 8, \"Skin\", 1, true);\n\t\tcharacterDesignMenu.drawText(i - byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tcharacterDesignSkinColourButton1 = characterDesignMenu.makeButton(i\n\t\t\t\t- byte0 - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158((i - byte0) + 40, j,\n\t\t\t\tSPRITE_UTIL_START + 6);\n\t\tcharacterDesignSkinColourButton2 = characterDesignMenu.makeButton(\n\t\t\t\t(i - byte0) + 40, j, 20, 20);\n\t\tcharacterDesignMenu.method157(i + byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i + byte0, j - 8, \"Bottom\", 1, true);\n\t\tcharacterDesignMenu.drawText(i + byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158((i + byte0) - 40, j,\n\t\t\t\tSPRITE_UTIL_START + 7);\n\t\tcharacterDesignBottomColourButton1 = characterDesignMenu.makeButton(\n\t\t\t\t(i + byte0) - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tcharacterDesignBottomColourButton2 = characterDesignMenu.makeButton(i\n\t\t\t\t+ byte0 + 40, j, 20, 20);\n\t\tj += 82;\n\t\tj -= 35;\n\t\tcharacterDesignMenu.drawBox(i, j, 200, 30);\n\t\tcharacterDesignMenu.drawText(i, j, \"Accept\", 4, false);\n\t\tcharacterDesignAcceptButton = characterDesignMenu.makeButton(i, j, 200,\n\t\t\t\t30);\n\t}\n\tprivate final void drawAbuseWindow2() {\n\t\tif (super.enteredText.length() > 0) {\n\t\t\tString s = super.enteredText.trim();\n\t\t\tsuper.inputText = \"\";\n\t\t\tsuper.enteredText = \"\";\n\t\t\tif (s.length() > 0) {\n\t\t\t\tlong l = DataOperations.stringLength12ToLong(s);\n\t\t\t\tsuper.streamClass.createPacket(7);\n\t\t\t\tsuper.streamClass.addTwo4ByteInts(l);\n\t\t\t\tsuper.streamClass.addByte(abuseSelectedType);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tshowAbuseWindow = 0;\n\t\t\treturn;\n\t\t}\n\t\tgameGraphics.drawBox(56 + xAddition, 130 + yAddition, 400, 100, 0);\n\t\tgameGraphics.drawBoxEdge(56 + xAddition, 130 + yAddition, 400, 100,\n\t\t\t\t0xffffff);\n\t\tint i = 160 + yAddition;\n\t\tgameGraphics.drawText(\n\t\t\t\t\"Now type the name of the offending player, and press enter\",\n\t\t\t\t256 + xAddition, i, 1, 0xffff00);\n\t\ti += 18;\n\t\tgameGraphics.drawText(\"Name: \" + super.inputText + \"*\",\n\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\ti = 222 + yAddition;\n\t\tint j = 0xffffff;\n\t\tif (super.mouseX > 196 + xAddition && super.mouseX < 316 + xAddition\n\t\t\t\t&& super.mouseY > i - 13 && super.mouseY < i + 2) {\n\t\t\tj = 0xffff00;\n\t\t\tif (mouseButtonClick == 1) {\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t\tshowAbuseWindow = 0;\n\t\t\t}\n\t\t}\n\t\tgameGraphics.drawText(\"Click here to cancel\", 256 + xAddition, i, 1, j);\n\t\tif (mouseButtonClick == 1\n\t\t\t\t&& (super.mouseX < 56 + xAddition\n\t\t\t\t\t\t|| super.mouseX > 456 + xAddition\n\t\t\t\t\t\t|| super.mouseY < 130 + yAddition || super.mouseY > 230 + yAddition)) {\n\t\t\tmouseButtonClick = 0;\n\t\t\tshowAbuseWindow = 0;\n\t\t}\n\t}\n\tpublic final void displayMessage(String message, int type, int status) {\n\t\tif (type == 2 || type == 4 || type == 6) {\n\t\t\tfor (; message.length() > 5 && message.charAt(0) == '@'\n\t\t\t\t\t&& message.charAt(4) == '@'; message = message.substring(5))\n\t\t\t\t;\n\t\t}\n\t\tif (message.startsWith(\"%\", 0)) {\n\t\t\tmessage = message.substring(1);\n\t\t\tstatus = 4;\n\t\t}\n\t\tif (message.startsWith(\"&\", 0)) {\n\t\t\tmessage = message.substring(1);\n\t\t\tstatus = 33;\n\t\t}\n\t\tmessage = message.replaceAll(\"\\\\#pmd\\\\#\", \"\");\n\t\tmessage = message.replaceAll(\"\\\\#mod\\\\#\", \"\");\n\t\tmessage = message.replaceAll(\"\\\\#adm\\\\#\", \"\");\n\t\tif (type == 2)\n\t\t\tmessage = \"@yel@\" + message;\n\t\tif (type == 3 || type == 4)\n\t\t\tmessage = \"@whi@\" + message;\n\t\tif (type == 6)\n\t\t\tmessage = \"@cya@\" + message;\n\t\tif (status == 1)\n\t\t\tmessage = \"#pmd#\" + message;\n\t\tif (status == 2)\n\t\t\tmessage = \"#mod#\" + message;\n\t\tif (status == 3)\n\t\t\tmessage = \"#adm#\" + message;\n\t\tif (status == 4) {\n\t\t\tmessage = \"#pmd#\" + message;\n\t\t\tMessageQueue.getQueue();\n\t\t\tMessageQueue.addMessage(new Message(message));\n\t\t\tgameMenu.addString(messagesHandleType6, message, false);\n\t\t\treturn;\n\t\t}\n\t\tif (status == 33) {\n\t\t\tMessageQueue.getQueue();\n\t\t\tMessageQueue.addMessage(new Message(message, true));\n\t\t\tgameMenu.addString(messagesHandleType6, message, false);\n\t\t\treturn;\n\t\t}\n\t\tif (messagesTab != 0) {\n\t\t\tif (type == 4 || type == 3)\n\t\t\t\tanInt952 = 200;\n\t\t\tif (type == 2 && messagesTab != 1)\n\t\t\t\tanInt953 = 200;\n\t\t\tif (type == 5 && messagesTab != 2)\n\t\t\t\tanInt954 = 200;\n\t\t\tif (type == 6 && messagesTab != 3)\n\t\t\t\tanInt955 = 200;\n\t\t\tif (type == 3 && messagesTab != 0)\n\t\t\t\tmessagesTab = 0;\n\t\t\tif (type == 6 && messagesTab != 3 && messagesTab != 0)\n\t\t\t\tmessagesTab = 0;\n\t\t}\n\t\tfor (int k = messagesArray.length - 1; k > 0; k--) {\n\t\t\tmessagesArray[k] = messagesArray[k - 1];\n\t\t\tmessagesTimeout[k] = messagesTimeout[k - 1];\n\t\t}\n\t\tmessagesArray[0] = message;\n\t\tmessagesTimeout[0] = 300;\n\t\tif (type == 2)\n\t\t\tif (gameMenu.anIntArray187[messagesHandleType2] == gameMenu.menuListTextCount[messagesHandleType2] - 4)\n\t\t\t\tgameMenu.addString(messagesHandleType2, message, true);\n\t\t\telse\n\t\t\t\tgameMenu.addString(messagesHandleType2, message, false);\n\t\tif (type == 5)\n\t\t\tif (gameMenu.anIntArray187[messagesHandleType5] == gameMenu.menuListTextCount[messagesHandleType5] - 4)\n\t\t\t\tgameMenu.addString(messagesHandleType5, message, true);\n\t\t\telse\n\t\t\t\tgameMenu.addString(messagesHandleType5, message, false);\n\t\tif (type == 6) {\n\t\t\tif (gameMenu.anIntArray187[messagesHandleType6] == gameMenu.menuListTextCount[messagesHandleType6] - 4) {\n\t\t\t\tgameMenu.addString(messagesHandleType6, message, true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgameMenu.addString(messagesHandleType6, message, false);\n\t\t}\n\t}\n\tprotected final void logoutAndStop() {\n\t\tsendLogoutPacket();\n\t\tgarbageCollect();\n\t\tif (audioReader != null) {\n\t\t\taudioReader.stopAudio();\n\t\t}\n\t}\n\tprivate final void method98(int i, String s) {\n\t\tint j = objectX[i];\n\t\tint k = objectY[i];\n\t\tint l = j - ourPlayer.currentX / 128;\n\t\tint i1 = k - ourPlayer.currentY / 128;\n\t\tbyte byte0 = 7;\n\t\tif (j >= 0 && k >= 0 && j < 96 && k < 96 && l > -byte0 && l < byte0\n\t\t\t\t&& i1 > -byte0 && i1 < byte0) {\n\t\t\ttry {\n\t\t\t\tgameCamera.removeModel(objectModelArray[i]);\n\t\t\t\tint j1 = EntityHandler.storeModel(s);\n\t\t\t\tModel model = gameDataModels[j1].method203();\n\t\t\t\tgameCamera.addModel(model);\n\t\t\t\tmodel.method184(true, 48, 48, -50, -10, -50);\n\t\t\t\tmodel.method205(objectModelArray[i]);\n\t\t\t\tmodel.anInt257 = i;\n\t\t\t\tobjectModelArray[i] = model;\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\t}\n\tprotected final void resetVars() {\n\t\tsystemUpdate = 0;\n\t\tcombatStyle = 0;\n\t\tlogoutTimeout = 0;\n\t\tloginScreenNumber = 0;\n\t\tloggedIn = 1;\n\t\tflagged = 0;\n\t\tresetPrivateMessageStrings();\n\t\tgameGraphics.method211();\n\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t\tfor (int i = 0; i < objectCount; i++) {\n\t\t\tgameCamera.removeModel(objectModelArray[i]);\n\t\t\tengineHandle.updateObject(objectX[i], objectY[i], objectType[i],\n\t\t\t\t\tobjectID[i]);\n\t\t}\n\t\tfor (int j = 0; j < doorCount; j++) {\n\t\t\tgameCamera.removeModel(doorModel[j]);\n\t\t\tengineHandle.updateDoor(doorX[j], doorY[j], doorDirection[j],\n\t\t\t\t\tdoorType[j]);\n\t\t}\n\t\tobjectCount = 0;\n\t\tdoorCount = 0;\n\t\tgroundItemCount = 0;\n\t\tplayerCount = 0;\n\t\tfor (int k = 0; k < mobArray.length; k++)\n\t\t\tmobArray[k] = null;\n\t\tfor (int l = 0; l < playerArray.length; l++)\n\t\t\tplayerArray[l] = null;\n\t\tnpcCount = 0;\n\t\tfor (int i1 = 0; i1 < npcRecordArray.length; i1++)\n\t\t\tnpcRecordArray[i1] = null;\n\t\tfor (int j1 = 0; j1 < npcArray.length; j1++)\n\t\t\tnpcArray[j1] = null;\n\t\tfor (int k1 = 0; k1 < prayerOn.length; k1++)\n\t\t\tprayerOn[k1] = false;\n\t\tmouseButtonClick = 0;\n\t\tsuper.lastMouseDownButton = 0;\n\t\tsuper.mouseDownButton = 0;\n\t\tshowShop = false;\n\t\tshowBank = false;\n\t\tsuper.friendsCount = 0;\n\t}\n\tprivate final void drawTradeWindow() {\n\t\tif (mouseButtonClick != 0 && itemIncrement == 0)\n\t\t\titemIncrement = 1;\n\t\tif (itemIncrement > 0) {\n\t\t\tint i = super.mouseX - 22 - xAddition;\n\t\t\tint j = super.mouseY - 36 - yAddition;\n\t\t\tif (i >= 0 && j >= 0 && i < 468 && j < 262) {\n\t\t\t\tif (i > 216 && j > 30 && i < 462 && j < 235) {\n\t\t\t\t\tint k = (i - 217) / 49 + ((j - 31) / 34) * 5;\n\t\t\t\t\tif (k >= 0 && k < inventoryCount) {\n\t\t\t\t\t\tboolean flag = false;\n\t\t\t\t\t\tint l1 = 0;\n\t\t\t\t\t\tint k2 = getInventoryItems()[k];\n\t\t\t\t\t\tfor (int k3 = 0; k3 < tradeMyItemCount; k3++)\n\t\t\t\t\t\t\tif (tradeMyItems[k3] == k2)\n\t\t\t\t\t\t\t\tif (EntityHandler.getItemDef(k2).isStackable()) {\n\t\t\t\t\t\t\t\t\tfor (int i4 = 0; i4 < itemIncrement; i4++) {\n\t\t\t\t\t\t\t\t\t\tif (tradeMyItemsCount[k3] < inventoryItemsCount[k])\n\t\t\t\t\t\t\t\t\t\t\ttradeMyItemsCount[k3]++;\n\t\t\t\t\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tl1++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif (inventoryCount(k2) <= l1)\n\t\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\tif (!flag && tradeMyItemCount < 12) {\n\t\t\t\t\t\t\ttradeMyItems[tradeMyItemCount] = k2;\n\t\t\t\t\t\t\ttradeMyItemsCount[tradeMyItemCount] = 1;\n\t\t\t\t\t\t\ttradeMyItemCount++;\n\t\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (flag) {\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(70);\n\t\t\t\t\t\t\tsuper.streamClass.addByte(tradeMyItemCount);\n\t\t\t\t\t\t\tfor (int j4 = 0; j4 < tradeMyItemCount; j4++) {\n\t\t\t\t\t\t\t\tsuper.streamClass.add2ByteInt(tradeMyItems[j4]);\n\t\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t\t.add4ByteInt(tradeMyItemsCount[j4]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\t\t\t\ttradeWeAccepted = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i > 8 && j > 30 && i < 205 && j < 133) {\n\t\t\t\t\tint l = (i - 9) / 49 + ((j - 31) / 34) * 4;\n\t\t\t\t\tif (l >= 0 && l < tradeMyItemCount) {\n\t\t\t\t\t\tint j1 = tradeMyItems[l];\n\t\t\t\t\t\tfor (int i2 = 0; i2 < itemIncrement; i2++) {\n\t\t\t\t\t\t\tif (EntityHandler.getItemDef(j1).isStackable()\n\t\t\t\t\t\t\t\t\t&& tradeMyItemsCount[l] > 1) {\n\t\t\t\t\t\t\t\ttradeMyItemsCount[l]--;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttradeMyItemCount--;\n\t\t\t\t\t\t\tmouseDownTime = 0;\n\t\t\t\t\t\t\tfor (int l2 = l; l2 < tradeMyItemCount; l2++) {\n\t\t\t\t\t\t\t\ttradeMyItems[l2] = tradeMyItems[l2 + 1];\n\t\t\t\t\t\t\t\ttradeMyItemsCount[l2] = tradeMyItemsCount[l2 + 1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.createPacket(70);\n\t\t\t\t\t\tsuper.streamClass.addByte(tradeMyItemCount);\n\t\t\t\t\t\tfor (int i3 = 0; i3 < tradeMyItemCount; i3++) {\n\t\t\t\t\t\t\tsuper.streamClass.add2ByteInt(tradeMyItems[i3]);\n\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t.add4ByteInt(tradeMyItemsCount[i3]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\t\t\ttradeWeAccepted = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i >= 217 && j >= 238 && i <= 286 && j <= 259) {\n\t\t\t\t\ttradeWeAccepted = true;\n\t\t\t\t\tsuper.streamClass.createPacket(211);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t\tif (i >= 394 && j >= 238 && i < 463 && j < 259) {\n\t\t\t\t\tshowTradeWindow = false;\n\t\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t} else if (mouseButtonClick != 0) {\n\t\t\t\tshowTradeWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\titemIncrement = 0;\n\t\t}\n\t\tif (!showTradeWindow)\n\t\t\treturn;\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 12, 192);\n\t\tint i1 = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 12, 468, 18, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 30, 8, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 205, byte1 + 30, 11, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 462, byte1 + 30, 6, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 133, 197, 22, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 258, 197, 20, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 235, 246, 43, i1, 160);\n\t\tint k1 = 0xd0d0d0;\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 30, 197, 103, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 155, 197, 103, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 30, 246, 205, k1, 160);\n\t\tfor (int j2 = 0; j2 < 4; j2++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 30 + j2 * 34, 197, 0);\n\t\tfor (int j3 = 0; j3 < 4; j3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 155 + j3 * 34, 197, 0);\n\t\tfor (int l3 = 0; l3 < 7; l3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 216, byte1 + 30 + l3 * 34, 246, 0);\n\t\tfor (int k4 = 0; k4 < 6; k4++) {\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics.drawLineY(byte0 + 8 + k4 * 49, byte1 + 30, 103, 0);\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics\n\t\t\t\t\t\t.drawLineY(byte0 + 8 + k4 * 49, byte1 + 155, 103, 0);\n\t\t\tgameGraphics.drawLineY(byte0 + 216 + k4 * 49, byte1 + 30, 205, 0);\n\t\t}\n\t\tgameGraphics.drawString(\"Trading with: \" + tradeOtherPlayerName,\n\t\t\t\tbyte0 + 1, byte1 + 10, 1, 0xffffff);\n\t\tgameGraphics.drawString(\"Your Offer\", byte0 + 9, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Opponent's Offer\", byte0 + 9, byte1 + 152, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Your Inventory\", byte0 + 216, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tif (!tradeWeAccepted)\n\t\t\tgameGraphics.drawPicture(byte0 + 217, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\tgameGraphics.drawPicture(byte0 + 394, byte1 + 238,\n\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\tif (tradeOtherAccepted) {\n\t\t\tgameGraphics.drawText(\"Other player\", byte0 + 341, byte1 + 246, 1,\n\t\t\t\t\t0xffffff);\n\t\t\tgameGraphics.drawText(\"has accepted\", byte0 + 341, byte1 + 256, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (tradeWeAccepted) {\n\t\t\tgameGraphics.drawText(\"Waiting for\", byte0 + 217 + 35, byte1 + 246,\n\t\t\t\t\t1, 0xffffff);\n\t\t\tgameGraphics.drawText(\"other player\", byte0 + 217 + 35,\n\t\t\t\t\tbyte1 + 256, 1, 0xffffff);\n\t\t}\n\t\tfor (int l4 = 0; l4 < inventoryCount; l4++) {\n\t\t\tint i5 = 217 + byte0 + (l4 % 5) * 49;\n\t\t\tint k5 = 31 + byte1 + (l4 / 5) * 34;\n\t\t\tgameGraphics.spriteClip4(i5, k5, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(getInventoryItems()[l4]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(inventoryItemsCount[l4]), i5 + 1,\n\t\t\t\t\t\tk5 + 10, 1, 0xffff00);\n\t\t}\n\t\tfor (int j5 = 0; j5 < tradeMyItemCount; j5++) {\n\t\t\tint l5 = 9 + byte0 + (j5 % 4) * 49;\n\t\t\tint j6 = 31 + byte1 + (j5 / 4) * 34;\n\t\t\tgameGraphics\n\t\t\t\t\t.spriteClip4(l5, j6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeMyItems[j5])\n\t\t\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\t\t\tEntityHandler.getItemDef(tradeMyItems[j5])\n\t\t\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(tradeMyItems[j5]).isStackable())\n\t\t\t\tgameGraphics.drawString(String.valueOf(tradeMyItemsCount[j5]),\n\t\t\t\t\t\tl5 + 1, j6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > l5 && super.mouseX < l5 + 48\n\t\t\t\t\t&& super.mouseY > j6 && super.mouseY < j6 + 32)\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getItemDef(tradeMyItems[j5]).getName()\n\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeMyItems[j5])\n\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t\tfor (int i6 = 0; i6 < tradeOtherItemCount; i6++) {\n\t\t\tint k6 = 9 + byte0 + (i6 % 4) * 49;\n\t\t\tint l6 = 156 + byte1 + (i6 / 4) * 34;\n\t\t\tgameGraphics.spriteClip4(\n\t\t\t\t\tk6,\n\t\t\t\t\tl6,\n\t\t\t\t\t48,\n\t\t\t\t\t32,\n\t\t\t\t\tSPRITE_ITEM_START\n\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeOtherItems[i6])\n\t\t\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(tradeOtherItems[i6])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(tradeOtherItems[i6]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(tradeOtherItemsCount[i6]), k6 + 1,\n\t\t\t\t\t\tl6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > k6 && super.mouseX < k6 + 48\n\t\t\t\t\t&& super.mouseY > l6 && super.mouseY < l6 + 32)\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getItemDef(tradeOtherItems[i6]).getName()\n\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeOtherItems[i6])\n\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t}\n\tprivate final boolean enginePlayerVisible(int i) {\n\t\tint j = ourPlayer.currentX / 128;\n\t\tint k = ourPlayer.currentY / 128;\n\t\tfor (int l = 2; l >= 1; l--) {\n\t\t\tif (i == 1\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k - l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j - l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t- l][k - l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 3\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k + l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j - l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t- l][k + l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 5\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k + l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j + l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t+ l][k + l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 7\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k - l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j + l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t+ l][k - l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 0 && (engineHandle.walkableValue[j][k - l] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t\tif (i == 2 && (engineHandle.walkableValue[j - l][k] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t\tif (i == 4 && (engineHandle.walkableValue[j][k + l] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t\tif (i == 6 && (engineHandle.walkableValue[j + l][k] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\tprivate Mob getLastPlayer(int serverIndex) {\n\t\tfor (int i1 = 0; i1 < lastPlayerCount; i1++) {\n\t\t\tif (lastPlayerArray[i1].serverIndex == serverIndex) {\n\t\t\t\treturn lastPlayerArray[i1];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tprivate Mob getLastNpc(int serverIndex) {\n\t\tfor (int i1 = 0; i1 < lastNpcCount; i1++) {\n\t\t\tif (lastNpcArray[i1].serverIndex == serverIndex) {\n\t\t\t\treturn lastNpcArray[i1];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tprotected final void handleIncomingPacket(int command, int length,\n\t\t\tbyte data[]) {\n\t\ttry {\n\t\t\tif (command == 254) {\n\t\t\t\tint bar = DataOperations.getUnsigned4Bytes(data, 1);\n\t\t\t\tif (bar == -1) {\n\t\t\t\t\tsmithingscreen.isVisible = false;\n\t\t\t\t} else {\n\t\t\t\t\tSmithingScreen.changeItems(smithingscreen, bar);\n\t\t\t\t\tsmithingscreen.isVisible = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (command == 231) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 233) {\n\t\t\t\tquestPoints = DataOperations.getUnsignedByte(data[1]);\n\t\t\t\tint k = DataOperations.getUnsignedByte(data[2]);\n\t\t\t\tint r = 3;\n\t\t\t\tnewQuestNames = new String[k];\n\t\t\t\tquestStage = new byte[k];\n\t\t\t\tfor (int i = 0; i < k; i++) {\n\t\t\t\t\tint uid = DataOperations.getUnsignedByte(data[r]);\n\t\t\t\t\tr++;\n\t\t\t\t\tnewQuestNames[i] = questName[uid];\n\t\t\t\t\tquestStage[i] = (byte) DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[r]);\n\t\t\t\t\tr++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (command == 110) {\n\t\t\t\tint i = 1;\n\t\t\t\tserverStartTime = DataOperations.getUnsigned8Bytes(data, i);\n\t\t\t\ti += 8;\n\t\t\t\tserverLocation = new String(data, i, length - i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 145) {\n\t\t\t\tif (!hasWorldInfo) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tloading = true;\n\t\t\t\tlastPlayerCount = playerCount;\n\t\t\t\tfor (int k = 0; k < lastPlayerCount; k++)\n\t\t\t\t\tlastPlayerArray[k] = playerArray[k];\n\t\t\t\tint currentOffset = 8;\n\t\t\t\tsetSectionX(DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 11));\n\t\t\t\tcurrentOffset += 11;\n\t\t\t\tsetSectionY(DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 13));\n\t\t\t\tcurrentOffset += 13;\n\t\t\t\tint mobSprite = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 4);\n\t\t\t\tcurrentOffset += 4;\n\t\t\t\tboolean sectionLoaded = loadSection(getSectionX(),\n\t\t\t\t\t\tgetSectionY());\n\t\t\t\tsetSectionX(getSectionX() - getAreaX());\n\t\t\t\tsetSectionY(getSectionY() - getAreaY());\n\t\t\t\tint mapEnterX = getSectionX() * magicLoc + 64;\n\t\t\t\tint mapEnterY = getSectionY() * magicLoc + 64;\n\t\t\t\tif (sectionLoaded) {\n\t\t\t\t\tourPlayer.waypointCurrent = 0;\n\t\t\t\t\tourPlayer.waypointEndSprite = 0;\n\t\t\t\t\tourPlayer.currentX = ourPlayer.waypointsX[0] = mapEnterX;\n\t\t\t\t\tourPlayer.currentY = ourPlayer.waypointsY[0] = mapEnterY;\n\t\t\t\t}\n\t\t\t\tplayerCount = 0;\n\t\t\t\tourPlayer = makePlayer(serverIndex, mapEnterX, mapEnterY,\n\t\t\t\t\t\tmobSprite);\n\t\t\t\tint newPlayerCount = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 8);\n\t\t\t\tcurrentOffset += 8;\n\t\t\t\tfor (int currentNewPlayer = 0; currentNewPlayer < newPlayerCount; currentNewPlayer++) {\n\t\t\t\t\tMob lastMob = getLastPlayer(DataOperations\n\t\t\t\t\t\t\t.getIntFromByteArray(data, currentOffset, 16));\n\t\t\t\t\tcurrentOffset += 16;\n\t\t\t\t\tint nextPlayer = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 1); \n\t\t\t\t\tcurrentOffset++;\n\t\t\t\t\tif (nextPlayer != 0) {\n\t\t\t\t\t\tint waypointsLeft = DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\t\tdata, currentOffset, 1); \n\t\t\t\t\t\tcurrentOffset++;\n\t\t\t\t\t\tif (waypointsLeft == 0) {\n\t\t\t\t\t\t\tint currentNextSprite = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, currentOffset, 3); \n\t\t\t\t\t\t\tcurrentOffset += 3;\n\t\t\t\t\t\t\tint currentWaypoint = lastMob.waypointCurrent;\n\t\t\t\t\t\t\tint newWaypointX = lastMob.waypointsX[currentWaypoint];\n\t\t\t\t\t\t\tint newWaypointY = lastMob.waypointsY[currentWaypoint];\n\t\t\t\t\t\t\tif (currentNextSprite == 2\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 1\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 3)\n\t\t\t\t\t\t\t\tnewWaypointX += magicLoc;\n\t\t\t\t\t\t\tif (currentNextSprite == 6\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 5\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 7)\n\t\t\t\t\t\t\t\tnewWaypointX -= magicLoc;\n\t\t\t\t\t\t\tif (currentNextSprite == 4\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 3\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 5)\n\t\t\t\t\t\t\t\tnewWaypointY += magicLoc;\n\t\t\t\t\t\t\tif (currentNextSprite == 0\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 1\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 7)\n\t\t\t\t\t\t\t\tnewWaypointY -= magicLoc;\n\t\t\t\t\t\t\tlastMob.nextSprite = currentNextSprite;\n\t\t\t\t\t\t\tlastMob.waypointCurrent = currentWaypoint = (currentWaypoint + 1) % 10;\n\t\t\t\t\t\t\tlastMob.waypointsX[currentWaypoint] = newWaypointX;\n\t\t\t\t\t\t\tlastMob.waypointsY[currentWaypoint] = newWaypointY;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tint needsNextSprite = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, currentOffset, 4);\n\t\t\t\t\t\t\tcurrentOffset += 4;\n\t\t\t\t\t\t\tif ((needsNextSprite & 0xc) == 12) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlastMob.nextSprite = needsNextSprite;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tplayerArray[playerCount++] = lastMob;\n\t\t\t\t}\n\t\t\t\tint mobCount = 0;\n\t\t\t\twhile (currentOffset + 24 < length * 8) {\n\t\t\t\t\tint mobIndex = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 16);\n\t\t\t\t\tcurrentOffset += 16;\n\t\t\t\t\tint areaMobX = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 5);\n\t\t\t\t\tcurrentOffset += 5;\n\t\t\t\t\tif (areaMobX > 15)\n\t\t\t\t\t\tareaMobX -= 32;\n\t\t\t\t\tint areaMobY = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 5);\n\t\t\t\t\tcurrentOffset += 5;\n\t\t\t\t\tif (areaMobY > 15)\n\t\t\t\t\t\tareaMobY -= 32;\n\t\t\t\t\tint mobArrayMobID = DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\tdata, currentOffset, 4);\n\t\t\t\t\tcurrentOffset += 4;\n\t\t\t\t\tint addIndex = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 1);\n\t\t\t\t\tcurrentOffset++;\n\t\t\t\t\tint mobX = (getSectionX() + areaMobX) * magicLoc + 64;\n\t\t\t\t\tint mobY = (getSectionY() + areaMobY) * magicLoc + 64;\n\t\t\t\t\tmakePlayer(mobIndex, mobX, mobY, mobArrayMobID);\n\t\t\t\t\tif (addIndex == 0)\n\t\t\t\t\t\tmobArrayIndexes[mobCount++] = mobIndex;\n\t\t\t\t}\n\t\t\t\tif (mobCount > 0) {\n\t\t\t\t\tsuper.streamClass.createPacket(83);\n\t\t\t\t\tsuper.streamClass.add2ByteInt(mobCount);\n\t\t\t\t\tfor (int currentMob = 0; currentMob < mobCount; currentMob++) {\n\t\t\t\t\t\tMob dummyMob = mobArray[mobArrayIndexes[currentMob]];\n\t\t\t\t\t\tsuper.streamClass.add2ByteInt(dummyMob.serverIndex);\n\t\t\t\t\t\tsuper.streamClass.add2ByteInt(dummyMob.mobIntUnknown);\n\t\t\t\t\t}\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\tmobCount = 0;\n\t\t\t\t}\n\t\t\t\tloading = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 109) {\n\t\t\t\tif (needsClear) {\n\t\t\t\t\tfor (int i = 0; i < groundItemType.length; i++) {\n\t\t\t\t\t\tgroundItemType[i] = -1;\n\t\t\t\t\t\tgroundItemX[i] = -1;\n\t\t\t\t\t\tgroundItemY[i] = -1;\n\t\t\t\t\t}\n\t\t\t\t\tneedsClear = false;\n\t\t\t\t}\n\t\t\t\tfor (int l = 1; l < length;)\n\t\t\t\t\tif (DataOperations.getUnsignedByte(data[l]) == 255) { \n\t\t\t\t\t\tint newCount = 0;\n\t\t\t\t\t\tint newSectionX = getSectionX() + data[l + 1] >> 3;\n\t\t\t\t\t\tint newSectionY = getSectionY() + data[l + 2] >> 3;\n\t\t\t\t\t\tl += 3;\n\t\t\t\t\t\tfor (int groundItem = 0; groundItem < groundItemCount; groundItem++) {\n\t\t\t\t\t\t\tint newX = (groundItemX[groundItem] >> 3)\n\t\t\t\t\t\t\t\t\t- newSectionX;\n\t\t\t\t\t\t\tint newY = (groundItemY[groundItem] >> 3)\n\t\t\t\t\t\t\t\t\t- newSectionY;\n\t\t\t\t\t\t\tif (newX != 0 || newY != 0) {\n\t\t\t\t\t\t\t\tif (groundItem != newCount) {\n\t\t\t\t\t\t\t\t\tgroundItemX[newCount] = groundItemX[groundItem];\n\t\t\t\t\t\t\t\t\tgroundItemY[newCount] = groundItemY[groundItem];\n\t\t\t\t\t\t\t\t\tgroundItemType[newCount] = groundItemType[groundItem];\n\t\t\t\t\t\t\t\t\tgroundItemObjectVar[newCount] = groundItemObjectVar[groundItem];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tnewCount++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgroundItemCount = newCount;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint i8 = DataOperations.getUnsigned2Bytes(data, l);\n\t\t\t\t\t\tl += 2;\n\t\t\t\t\t\tint k14 = getSectionX() + data[l++];\n\t\t\t\t\t\tint j19 = getSectionY() + data[l++];\n\t\t\t\t\t\tif ((i8 & 0x8000) == 0) { \n\t\t\t\t\t\t\tgroundItemX[groundItemCount] = k14;\n\t\t\t\t\t\t\tgroundItemY[groundItemCount] = j19;\n\t\t\t\t\t\t\tgroundItemType[groundItemCount] = i8;\n\t\t\t\t\t\t\tgroundItemObjectVar[groundItemCount] = 0;\n\t\t\t\t\t\t\tfor (int k23 = 0; k23 < objectCount; k23++) {\n\t\t\t\t\t\t\t\tif (objectX[k23] != k14 || objectY[k23] != j19)\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\tgroundItemObjectVar[groundItemCount] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getObjectDef(objectType[k23])\n\t\t\t\t\t\t\t\t\t\t.getGroundItemVar();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgroundItemCount++;\n\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\ti8 &= 0x7fff;\n\t\t\t\t\t\t\tint l23 = 0;\n\t\t\t\t\t\t\tfor (int k26 = 0; k26 < groundItemCount; k26++) {\n\t\t\t\t\t\t\t\tif (groundItemX[k26] != k14\n\t\t\t\t\t\t\t\t\t\t|| groundItemY[k26] != j19\n\t\t\t\t\t\t\t\t\t\t|| groundItemType[k26] != i8) { \n\t\t\t\t\t\t\t\t\tif (k26 != l23) {\n\t\t\t\t\t\t\t\t\t\tgroundItemX[l23] = groundItemX[k26];\n\t\t\t\t\t\t\t\t\t\tgroundItemY[l23] = groundItemY[k26];\n\t\t\t\t\t\t\t\t\t\tgroundItemType[l23] = groundItemType[k26];\n\t\t\t\t\t\t\t\t\t\tgroundItemObjectVar[l23] = groundItemObjectVar[k26];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tl23++;\n\t\t\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\t\t\ti8 = -123;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgroundItemCount = l23;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 27) {\n\t\t\t\tfor (int i1 = 1; i1 < length;)\n\t\t\t\t\tif (DataOperations.getUnsignedByte(data[i1]) == 255) {\n\t\t\t\t\t\tint j8 = 0;\n\t\t\t\t\t\tint l14 = getSectionX() + data[i1 + 1] >> 3;\n\t\t\t\t\t\tint k19 = getSectionY() + data[i1 + 2] >> 3;\n\t\t\t\t\t\ti1 += 3;\n\t\t\t\t\t\tfor (int i24 = 0; i24 < objectCount; i24++) {\n\t\t\t\t\t\t\tint l26 = (objectX[i24] >> 3) - l14;\n\t\t\t\t\t\t\tint k29 = (objectY[i24] >> 3) - k19;\n\t\t\t\t\t\t\tif (l26 != 0 || k29 != 0) {\n\t\t\t\t\t\t\t\tif (i24 != j8) {\n\t\t\t\t\t\t\t\t\tobjectModelArray[j8] = objectModelArray[i24];\n\t\t\t\t\t\t\t\t\tobjectModelArray[j8].anInt257 = j8;\n\t\t\t\t\t\t\t\t\tobjectX[j8] = objectX[i24];\n\t\t\t\t\t\t\t\t\tobjectY[j8] = objectY[i24];\n\t\t\t\t\t\t\t\t\tobjectType[j8] = objectType[i24];\n\t\t\t\t\t\t\t\t\tobjectID[j8] = objectID[i24];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tj8++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(objectModelArray[i24]);\n\t\t\t\t\t\t\t\tengineHandle.updateObject(objectX[i24],\n\t\t\t\t\t\t\t\t\t\tobjectY[i24], objectType[i24],\n\t\t\t\t\t\t\t\t\t\tobjectID[i24]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tobjectCount = j8;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint k8 = DataOperations.getUnsigned2Bytes(data, i1);\n\t\t\t\t\t\ti1 += 2;\n\t\t\t\t\t\tint i15 = getSectionX() + data[i1++];\n\t\t\t\t\t\tint l19 = getSectionY() + data[i1++];\n\t\t\t\t\t\tint l29 = data[i1++];\n\t\t\t\t\t\tint j24 = 0;\n\t\t\t\t\t\tfor (int i27 = 0; i27 < objectCount; i27++)\n\t\t\t\t\t\t\tif (objectX[i27] != i15 || objectY[i27] != l19\n\t\t\t\t\t\t\t\t\t|| objectID[i27] != l29) {\n\t\t\t\t\t\t\t\tif (i27 != j24) {\n\t\t\t\t\t\t\t\t\tobjectModelArray[j24] = objectModelArray[i27];\n\t\t\t\t\t\t\t\t\tobjectModelArray[j24].anInt257 = j24;\n\t\t\t\t\t\t\t\t\tobjectX[j24] = objectX[i27];\n\t\t\t\t\t\t\t\t\tobjectY[j24] = objectY[i27];\n\t\t\t\t\t\t\t\t\tobjectType[j24] = objectType[i27];\n\t\t\t\t\t\t\t\t\tobjectID[j24] = objectID[i27];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tj24++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(objectModelArray[i27]);\n\t\t\t\t\t\t\t\tengineHandle.updateObject(objectX[i27],\n\t\t\t\t\t\t\t\t\t\tobjectY[i27], objectType[i27],\n\t\t\t\t\t\t\t\t\t\tobjectID[i27]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tobjectCount = j24;\n\t\t\t\t\t\tif (k8 != 60000) {\n\t\t\t\t\t\t\tengineHandle.registerObjectDir(i15, l19, l29);\n\t\t\t\t\t\t\tint i34;\n\t\t\t\t\t\t\tint j37;\n\t\t\t\t\t\t\tif (l29 == 0 || l29 == 4) {\n\t\t\t\t\t\t\t\ti34 = EntityHandler.getObjectDef(k8).getWidth();\n\t\t\t\t\t\t\t\tj37 = EntityHandler.getObjectDef(k8)\n\t\t\t\t\t\t\t\t\t\t.getHeight();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tj37 = EntityHandler.getObjectDef(k8).getWidth();\n\t\t\t\t\t\t\t\ti34 = EntityHandler.getObjectDef(k8)\n\t\t\t\t\t\t\t\t\t\t.getHeight();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tint j40 = ((i15 + i15 + i34) * magicLoc) / 2;\n\t\t\t\t\t\t\tint i42 = ((l19 + l19 + j37) * magicLoc) / 2;\n\t\t\t\t\t\t\tint k43 = EntityHandler.getObjectDef(k8).modelID;\n\t\t\t\t\t\t\tModel model_1 = gameDataModels[k43].method203();\n\t\t\t\t\t\t\tgameCamera.addModel(model_1);\n\t\t\t\t\t\t\tmodel_1.anInt257 = objectCount;\n\t\t\t\t\t\t\tmodel_1.method188(0, l29 * 32, 0);\n\t\t\t\t\t\t\tmodel_1.method190(j40, -engineHandle\n\t\t\t\t\t\t\t\t\t.getAveragedElevation(j40, i42), i42);\n\t\t\t\t\t\t\tmodel_1.method184(true, 48, 48, -50, -10, -50);\n\t\t\t\t\t\t\tengineHandle.method412(i15, l19, k8, l29);\n\t\t\t\t\t\t\tif (k8 == 74)\n\t\t\t\t\t\t\t\tmodel_1.method190(0, -480, 0);\n\t\t\t\t\t\t\tobjectX[objectCount] = i15;\n\t\t\t\t\t\t\tobjectY[objectCount] = l19;\n\t\t\t\t\t\t\tobjectType[objectCount] = k8;\n\t\t\t\t\t\t\tobjectID[objectCount] = l29;\n\t\t\t\t\t\t\tobjectModelArray[objectCount++] = model_1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 114) {\n\t\t\t\tint invOffset = 1;\n\t\t\t\tinventoryCount = data[invOffset++] & 0xff;\n\t\t\t\tfor (int invItem = 0; invItem < inventoryCount; invItem++) {\n\t\t\t\t\tint j15 = DataOperations.getUnsigned2Bytes(data, invOffset);\n\t\t\t\t\tinvOffset += 2;\n\t\t\t\t\tgetInventoryItems()[invItem] = (j15 & 0x7fff);\n\t\t\t\t\twearing[invItem] = j15 / 32768;\n\t\t\t\t\tif (EntityHandler.getItemDef(j15 & 0x7fff).isStackable()) {\n\t\t\t\t\t\tinventoryItemsCount[invItem] = DataOperations.readInt(\n\t\t\t\t\t\t\t\tdata, invOffset);\n\t\t\t\t\t\tinvOffset += 4;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinventoryItemsCount[invItem] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 53) {\n\t\t\t\tint mobCount = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tint mobUpdateOffset = 3;\n\t\t\t\tfor (int currentMob = 0; currentMob < mobCount; currentMob++) {\n\t\t\t\t\tint mobArrayIndex = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\tif (mobArrayIndex < 0 || mobArrayIndex > mobArray.length) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tMob mob = mobArray[mobArrayIndex];\n\t\t\t\t\tif (mob == null) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tbyte mobUpdateType = data[mobUpdateOffset++];\n\t\t\t\t\tif (mobUpdateType == 0) {\n\t\t\t\t\t\tint i30 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.anInt163 = 150;\n\t\t\t\t\t\t\tmob.anInt162 = i30;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 1) { \n\t\t\t\t\t\tbyte byte7 = data[mobUpdateOffset++];\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tString s2 = DataConversions.byteToString(data,\n\t\t\t\t\t\t\t\t\tmobUpdateOffset, byte7);\n\t\t\t\t\t\t\tmob.lastMessageTimeout = 150;\n\t\t\t\t\t\t\tmob.lastMessage = s2;\n\t\t\t\t\t\t\tdisplayMessage(mob.name + \": \" + mob.lastMessage,\n\t\t\t\t\t\t\t\t\t2, mob.admin);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmobUpdateOffset += byte7;\n\t\t\t\t\t} else if (mobUpdateType == 2) { \n\t\t\t\t\t\tint j30 = DataOperations\n\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset++]);\n\t\t\t\t\t\tint hits = DataOperations\n\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset++]);\n\t\t\t\t\t\tint hitsBase = DataOperations\n\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset++]);\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.anInt164 = j30;\n\t\t\t\t\t\t\tmob.hitPointsCurrent = hits;\n\t\t\t\t\t\t\tmob.hitPointsBase = hitsBase;\n\t\t\t\t\t\t\tmob.combatTimer = 200;\n\t\t\t\t\t\t\tif (mob == ourPlayer) {\n\t\t\t\t\t\t\t\tplayerStatCurrent[3] = hits;\n\t\t\t\t\t\t\t\tplayerStatBase[3] = hitsBase;\n\t\t\t\t\t\t\t\tshowWelcomeBox = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 3) { \n\t\t\t\t\t\tint k30 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tint k34 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.attackingCameraInt = k30;\n\t\t\t\t\t\t\tmob.attackingNpcIndex = k34;\n\t\t\t\t\t\t\tmob.attackingMobIndex = -1;\n\t\t\t\t\t\t\tmob.anInt176 = attackingInt40;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 4) { \n\t\t\t\t\t\tint l30 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tint l34 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.attackingCameraInt = l30;\n\t\t\t\t\t\t\tmob.attackingMobIndex = l34;\n\t\t\t\t\t\t\tmob.attackingNpcIndex = -1;\n\t\t\t\t\t\t\tmob.anInt176 = attackingInt40;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 5) { \n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.mobIntUnknown = DataOperations\n\t\t\t\t\t\t\t\t\t.getUnsigned2Bytes(data, mobUpdateOffset);\n\t\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\t\tmob.nameLong = DataOperations.getUnsigned8Bytes(\n\t\t\t\t\t\t\t\t\tdata, mobUpdateOffset);\n\t\t\t\t\t\t\tmobUpdateOffset += 8;\n\t\t\t\t\t\t\tmob.name = DataOperations\n\t\t\t\t\t\t\t\t\t.longToString(mob.nameLong);\n\t\t\t\t\t\t\tint i31 = DataOperations\n\t\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset]);\n\t\t\t\t\t\t\tmobUpdateOffset++;\n\t\t\t\t\t\t\tfor (int i35 = 0; i35 < i31; i35++) {\n\t\t\t\t\t\t\t\tmob.animationCount[i35] = DataOperations\n\t\t\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset]);\n\t\t\t\t\t\t\t\tmobUpdateOffset++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (int l37 = i31; l37 < 12; l37++)\n\t\t\t\t\t\t\t\tmob.animationCount[l37] = 0;\n\t\t\t\t\t\t\tmob.colourHairType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.colourTopType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.colourBottomType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.colourSkinType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.level = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.anInt179 = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.admin = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmobUpdateOffset += 14;\n\t\t\t\t\t\t\tint j31 = DataOperations\n\t\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset]);\n\t\t\t\t\t\t\tmobUpdateOffset += j31 + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 6) { \n\t\t\t\t\t\tbyte byte8 = data[mobUpdateOffset];\n\t\t\t\t\t\tmobUpdateOffset++;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tString s3 = DataConversions.byteToString(data,\n\t\t\t\t\t\t\t\t\tmobUpdateOffset, byte8);\n\t\t\t\t\t\t\tmob.lastMessageTimeout = 150;\n\t\t\t\t\t\t\tmob.lastMessage = s3;\n\t\t\t\t\t\t\tif (mob == ourPlayer)\n\t\t\t\t\t\t\t\tdisplayMessage(mob.name + \": \"\n\t\t\t\t\t\t\t\t\t\t+ mob.lastMessage, 5, mob.admin);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmobUpdateOffset += byte8;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 129) {\n\t\t\t\tcombatStyle = DataOperations.getUnsignedByte(data[1]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 95) {\n\t\t\t\tfor (int l1 = 1; l1 < length;)\n\t\t\t\t\tif (DataOperations.getUnsignedByte(data[l1]) == 255) {\n\t\t\t\t\t\tint j9 = 0;\n\t\t\t\t\t\tint l15 = getSectionX() + data[l1 + 1] >> 3;\n\t\t\t\t\t\tint j20 = getSectionY() + data[l1 + 2] >> 3;\n\t\t\t\t\t\tl1 += 3;\n\t\t\t\t\t\tfor (int currentDoor = 0; currentDoor < doorCount; currentDoor++) {\n\t\t\t\t\t\t\tint j27 = (doorX[currentDoor] >> 3) - l15;\n\t\t\t\t\t\t\tint k31 = (doorY[currentDoor] >> 3) - j20;\n\t\t\t\t\t\t\tif (j27 != 0 || k31 != 0) {\n\t\t\t\t\t\t\t\tif (currentDoor != j9) {\n\t\t\t\t\t\t\t\t\tdoorModel[j9] = doorModel[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorModel[j9].anInt257 = j9 + 10000;\n\t\t\t\t\t\t\t\t\tdoorX[j9] = doorX[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorY[j9] = doorY[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorDirection[j9] = doorDirection[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorType[j9] = doorType[currentDoor];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tj9++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(doorModel[currentDoor]);\n\t\t\t\t\t\t\t\tengineHandle.updateDoor(doorX[currentDoor],\n\t\t\t\t\t\t\t\t\t\tdoorY[currentDoor],\n\t\t\t\t\t\t\t\t\t\tdoorDirection[currentDoor],\n\t\t\t\t\t\t\t\t\t\tdoorType[currentDoor]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdoorCount = j9;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint k9 = DataOperations.getUnsigned2Bytes(data, l1);\n\t\t\t\t\t\tl1 += 2;\n\t\t\t\t\t\tint i16 = getSectionX() + data[l1++];\n\t\t\t\t\t\tint k20 = getSectionY() + data[l1++];\n\t\t\t\t\t\tbyte byte5 = data[l1++];\n\t\t\t\t\t\tint k27 = 0;\n\t\t\t\t\t\tfor (int l31 = 0; l31 < doorCount; l31++)\n\t\t\t\t\t\t\tif (doorX[l31] != i16 || doorY[l31] != k20\n\t\t\t\t\t\t\t\t\t|| doorDirection[l31] != byte5) {\n\t\t\t\t\t\t\t\tif (l31 != k27) {\n\t\t\t\t\t\t\t\t\tdoorModel[k27] = doorModel[l31];\n\t\t\t\t\t\t\t\t\tdoorModel[k27].anInt257 = k27 + 10000;\n\t\t\t\t\t\t\t\t\tdoorX[k27] = doorX[l31];\n\t\t\t\t\t\t\t\t\tdoorY[k27] = doorY[l31];\n\t\t\t\t\t\t\t\t\tdoorDirection[k27] = doorDirection[l31];\n\t\t\t\t\t\t\t\t\tdoorType[k27] = doorType[l31];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tk27++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(doorModel[l31]);\n\t\t\t\t\t\t\t\tengineHandle.updateDoor(doorX[l31], doorY[l31],\n\t\t\t\t\t\t\t\t\t\tdoorDirection[l31], doorType[l31]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tdoorCount = k27;\n\t\t\t\t\t\tif (k9 != 60000) { \n\t\t\t\t\t\t\tengineHandle.method408(i16, k20, byte5, k9);\n\t\t\t\t\t\t\tModel model = makeModel(i16, k20, byte5, k9,\n\t\t\t\t\t\t\t\t\tdoorCount);\n\t\t\t\t\t\t\tdoorModel[doorCount] = model;\n\t\t\t\t\t\t\tdoorX[doorCount] = i16;\n\t\t\t\t\t\t\tdoorY[doorCount] = k20;\n\t\t\t\t\t\t\tdoorType[doorCount] = k9;\n\t\t\t\t\t\t\tdoorDirection[doorCount++] = byte5;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 77) {\n\t\t\t\tlastNpcCount = npcCount;\n\t\t\t\tnpcCount = 0;\n\t\t\t\tfor (int lastNpcIndex = 0; lastNpcIndex < lastNpcCount; lastNpcIndex++)\n\t\t\t\t\tlastNpcArray[lastNpcIndex] = npcArray[lastNpcIndex];\n\t\t\t\tint newNpcOffset = 8;\n\t\t\t\tint newNpcCount = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tnewNpcOffset, 8);\n\t\t\t\tnewNpcOffset += 8;\n\t\t\t\tfor (int newNpcIndex = 0; newNpcIndex < newNpcCount; newNpcIndex++) {\n\t\t\t\t\tMob newNPC = getLastNpc(DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\tdata, newNpcOffset, 16));\n\t\t\t\t\tnewNpcOffset += 16;\n\t\t\t\t\tint npcNeedsUpdate = DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\tdata, newNpcOffset, 1);\n\t\t\t\t\tnewNpcOffset++;\n\t\t\t\t\tif (npcNeedsUpdate != 0) {\n\t\t\t\t\t\tint i32 = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\t\tnewNpcOffset, 1);\n\t\t\t\t\t\tnewNpcOffset++;\n\t\t\t\t\t\tif (i32 == 0) {\n\t\t\t\t\t\t\tint nextSprite = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, newNpcOffset, 3);\n\t\t\t\t\t\t\tnewNpcOffset += 3;\n\t\t\t\t\t\t\tint waypointCurrent = newNPC.waypointCurrent;\n\t\t\t\t\t\t\tint waypointX = newNPC.waypointsX[waypointCurrent];\n\t\t\t\t\t\t\tint waypointY = newNPC.waypointsY[waypointCurrent];\n\t\t\t\t\t\t\tif (nextSprite == 2 || nextSprite == 1\n\t\t\t\t\t\t\t\t\t|| nextSprite == 3)\n\t\t\t\t\t\t\t\twaypointX += magicLoc;\n\t\t\t\t\t\t\tif (nextSprite == 6 || nextSprite == 5\n\t\t\t\t\t\t\t\t\t|| nextSprite == 7)\n\t\t\t\t\t\t\t\twaypointX -= magicLoc;\n\t\t\t\t\t\t\tif (nextSprite == 4 || nextSprite == 3\n\t\t\t\t\t\t\t\t\t|| nextSprite == 5)\n\t\t\t\t\t\t\t\twaypointY += magicLoc;\n\t\t\t\t\t\t\tif (nextSprite == 0 || nextSprite == 1\n\t\t\t\t\t\t\t\t\t|| nextSprite == 7)\n\t\t\t\t\t\t\t\twaypointY -= magicLoc;\n\t\t\t\t\t\t\tnewNPC.nextSprite = nextSprite;\n\t\t\t\t\t\t\tnewNPC.waypointCurrent = waypointCurrent = (waypointCurrent + 1) % 10;\n\t\t\t\t\t\t\tnewNPC.waypointsX[waypointCurrent] = waypointX;\n\t\t\t\t\t\t\tnewNPC.waypointsY[waypointCurrent] = waypointY;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tint nextSpriteOffset = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, newNpcOffset, 4);\n\t\t\t\t\t\t\tnewNpcOffset += 4;\n\t\t\t\t\t\t\tif ((nextSpriteOffset & 0xc) == 12) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnewNPC.nextSprite = nextSpriteOffset;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnpcArray[npcCount++] = newNPC;\n\t\t\t\t}\n\t\t\t\twhile (newNpcOffset + 34 < length * 8) {\n\t\t\t\t\tint serverIndex = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 16);\n\t\t\t\t\tnewNpcOffset += 16;\n\t\t\t\t\tint i28 = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 5);\n\t\t\t\t\tnewNpcOffset += 5;\n\t\t\t\t\tif (i28 > 15)\n\t\t\t\t\t\ti28 -= 32;\n\t\t\t\t\tint j32 = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 5);\n\t\t\t\t\tnewNpcOffset += 5;\n\t\t\t\t\tif (j32 > 15)\n\t\t\t\t\t\tj32 -= 32;\n\t\t\t\t\tint nextSprite = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 4);\n\t\t\t\t\tnewNpcOffset += 4;\n\t\t\t\t\tint x = (getSectionX() + i28) * magicLoc + 64;\n\t\t\t\t\tint y = (getSectionY() + j32) * magicLoc + 64;\n\t\t\t\t\tint type = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 10);\n\t\t\t\t\tnewNpcOffset += 10;\n\t\t\t\t\tif (type >= EntityHandler.npcCount())\n\t\t\t\t\t\ttype = 24;\n\t\t\t\t\taddNPC(serverIndex, x, y, nextSprite, type);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 190) {\n\t\t\t\tint j2 = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tint i10 = 3;\n\t\t\t\tfor (int k16 = 0; k16 < j2; k16++) {\n\t\t\t\t\tint i21 = DataOperations.getUnsigned2Bytes(data, i10);\n\t\t\t\t\ti10 += 2;\n\t\t\t\t\tMob mob_2 = npcRecordArray[i21];\n\t\t\t\t\tint j28 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\ti10++;\n\t\t\t\t\tif (j28 == 1) {\n\t\t\t\t\t\tint k32 = DataOperations.getUnsigned2Bytes(data, i10);\n\t\t\t\t\t\ti10 += 2;\n\t\t\t\t\t\tbyte byte9 = data[i10];\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tif (mob_2 != null) {\n\t\t\t\t\t\t\tString s4 = DataConversions.byteToString(data, i10,\n\t\t\t\t\t\t\t\t\tbyte9);\n\t\t\t\t\t\t\tmob_2.lastMessageTimeout = 150;\n\t\t\t\t\t\t\tmob_2.lastMessage = s4;\n\t\t\t\t\t\t\tif (k32 == ourPlayer.serverIndex)\n\t\t\t\t\t\t\t\tdisplayMessage(\"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getNpcDef(mob_2.type)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName() + \": \"\n\t\t\t\t\t\t\t\t\t\t+ mob_2.lastMessage, 5, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti10 += byte9;\n\t\t\t\t\t} else if (j28 == 2) {\n\t\t\t\t\t\tint l32 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tint i36 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tint k38 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tif (mob_2 != null) {\n\t\t\t\t\t\t\tmob_2.anInt164 = l32;\n\t\t\t\t\t\t\tmob_2.hitPointsCurrent = i36;\n\t\t\t\t\t\t\tmob_2.hitPointsBase = k38;\n\t\t\t\t\t\t\tmob_2.combatTimer = 200;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 223) {\n\t\t\t\tshowQuestionMenu = true;\n\t\t\t\tint newQuestionMenuCount = DataOperations\n\t\t\t\t\t\t.getUnsignedByte(data[1]);\n\t\t\t\tquestionMenuCount = newQuestionMenuCount;\n\t\t\t\tint newQuestionMenuOffset = 2;\n\t\t\t\tfor (int l16 = 0; l16 < newQuestionMenuCount; l16++) {\n\t\t\t\t\tint newQuestionMenuQuestionLength = DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[newQuestionMenuOffset]);\n\t\t\t\t\tnewQuestionMenuOffset++;\n\t\t\t\t\tquestionMenuAnswer[l16] = new String(data,\n\t\t\t\t\t\t\tnewQuestionMenuOffset,\n\t\t\t\t\t\t\tnewQuestionMenuQuestionLength);\n\t\t\t\t\tnewQuestionMenuOffset += newQuestionMenuQuestionLength;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 127) {\n\t\t\t\tshowQuestionMenu = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 131) {\n\t\t\t\tneedsClear = true;\n\t\t\t\tnotInWilderness = true;\n\t\t\t\thasWorldInfo = true;\n\t\t\t\tserverIndex = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\twildX = DataOperations.getUnsigned2Bytes(data, 3);\n\t\t\t\twildY = DataOperations.getUnsigned2Bytes(data, 5);\n\t\t\t\twildYSubtract = DataOperations.getUnsigned2Bytes(data, 7);\n\t\t\t\twildYMultiplier = DataOperations.getUnsigned2Bytes(data, 9);\n\t\t\t\twildY -= wildYSubtract * wildYMultiplier;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 180) {\n\t\t\t\tint l2 = 1;\n\t\t\t\tfor (int k10 = 0; k10 < 18; k10++) {\n\t\t\t\t\tplayerStatCurrent[k10] = DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[l2++]);\n\t\t\t\t}\n\t\t\t\tfor (int i17 = 0; i17 < 18; i17++) {\n\t\t\t\t\tplayerStatBase[i17] = DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[l2++]);\n\t\t\t\t}\n\t\t\t\tfor (int k21 = 0; k21 < 18; k21++) {\n\t\t\t\t\tplayerStatExperience[k21] = DataOperations\n\t\t\t\t\t\t\t.readInt(data, l2);\n\t\t\t\t\tl2 += 4;\n\t\t\t\t}\n\t\t\t\texpGained = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 177) {\n\t\t\t\tint i3 = 1;\n\t\t\t\tfor (int x = 0; x < 6; x++) {\n\t\t\t\t\tequipmentStatus[x] = DataOperations.getSigned2Bytes(data,\n\t\t\t\t\t\t\ti3);\n\t\t\t\t\ti3 += 2;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 165) {\n\t\t\t\tplayerAliveTimeout = 250;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 115) {\n\t\t\t\tint thingLength = (length - 1) / 4;\n\t\t\t\tfor (int currentThing = 0; currentThing < thingLength; currentThing++) {\n\t\t\t\t\tint currentItemSectionX = getSectionX()\n\t\t\t\t\t\t\t+ DataOperations.getSigned2Bytes(data,\n\t\t\t\t\t\t\t\t\t1 + currentThing * 4) >> 3;\n\t\t\t\t\tint currentItemSectionY = getSectionY()\n\t\t\t\t\t\t\t+ DataOperations.getSigned2Bytes(data,\n\t\t\t\t\t\t\t\t\t3 + currentThing * 4) >> 3;\n\t\t\t\t\tint currentCount = 0;\n\t\t\t\t\tfor (int currentItem = 0; currentItem < groundItemCount; currentItem++) {\n\t\t\t\t\t\tint currentItemOffsetX = (groundItemX[currentItem] >> 3)\n\t\t\t\t\t\t\t\t- currentItemSectionX;\n\t\t\t\t\t\tint currentItemOffsetY = (groundItemY[currentItem] >> 3)\n\t\t\t\t\t\t\t\t- currentItemSectionY;\n\t\t\t\t\t\tif (currentItemOffsetX != 0 || currentItemOffsetY != 0) {\n\t\t\t\t\t\t\tif (currentItem != currentCount) {\n\t\t\t\t\t\t\t\tgroundItemX[currentCount] = groundItemX[currentItem];\n\t\t\t\t\t\t\t\tgroundItemY[currentCount] = groundItemY[currentItem];\n\t\t\t\t\t\t\t\tgroundItemType[currentCount] = groundItemType[currentItem];\n\t\t\t\t\t\t\t\tgroundItemObjectVar[currentCount] = groundItemObjectVar[currentItem];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentCount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tgroundItemCount = currentCount;\n\t\t\t\t\tcurrentCount = 0;\n\t\t\t\t\tfor (int j33 = 0; j33 < objectCount; j33++) {\n\t\t\t\t\t\tint k36 = (objectX[j33] >> 3) - currentItemSectionX;\n\t\t\t\t\t\tint l38 = (objectY[j33] >> 3) - currentItemSectionY;\n\t\t\t\t\t\tif (k36 != 0 || l38 != 0) {\n\t\t\t\t\t\t\tif (j33 != currentCount) {\n\t\t\t\t\t\t\t\tobjectModelArray[currentCount] = objectModelArray[j33];\n\t\t\t\t\t\t\t\tobjectModelArray[currentCount].anInt257 = currentCount;\n\t\t\t\t\t\t\t\tobjectX[currentCount] = objectX[j33];\n\t\t\t\t\t\t\t\tobjectY[currentCount] = objectY[j33];\n\t\t\t\t\t\t\t\tobjectType[currentCount] = objectType[j33];\n\t\t\t\t\t\t\t\tobjectID[currentCount] = objectID[j33];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentCount++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgameCamera.removeModel(objectModelArray[j33]);\n\t\t\t\t\t\t\tengineHandle.updateObject(objectX[j33],\n\t\t\t\t\t\t\t\t\tobjectY[j33], objectType[j33],\n\t\t\t\t\t\t\t\t\tobjectID[j33]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tobjectCount = currentCount;\n\t\t\t\t\tcurrentCount = 0;\n\t\t\t\t\tfor (int l36 = 0; l36 < doorCount; l36++) {\n\t\t\t\t\t\tint i39 = (doorX[l36] >> 3) - currentItemSectionX;\n\t\t\t\t\t\tint j41 = (doorY[l36] >> 3) - currentItemSectionY;\n\t\t\t\t\t\tif (i39 != 0 || j41 != 0) {\n\t\t\t\t\t\t\tif (l36 != currentCount) {\n\t\t\t\t\t\t\t\tdoorModel[currentCount] = doorModel[l36];\n\t\t\t\t\t\t\t\tdoorModel[currentCount].anInt257 = currentCount + 10000;\n\t\t\t\t\t\t\t\tdoorX[currentCount] = doorX[l36];\n\t\t\t\t\t\t\t\tdoorY[currentCount] = doorY[l36];\n\t\t\t\t\t\t\t\tdoorDirection[currentCount] = doorDirection[l36];\n\t\t\t\t\t\t\t\tdoorType[currentCount] = doorType[l36];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentCount++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgameCamera.removeModel(doorModel[l36]);\n\t\t\t\t\t\t\tengineHandle.updateDoor(doorX[l36], doorY[l36],\n\t\t\t\t\t\t\t\t\tdoorDirection[l36], doorType[l36]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdoorCount = currentCount;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 230) {\n\t\t\t\tshowDrawPointsScreen = true;\n\t\t\t\tint pkbytes = 1;\n\t\t\t\tpkatk = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkdef = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkstr = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkrange = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkmagic = DataOperations.readInt(data, pkbytes);\n\t\t\t}\n\t\t\tif (command == 207) {\n\t\t\t\tshowCharacterLookScreen = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 4) {\n\t\t\t\tint currentMob = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tif (mobArray[currentMob] != null) \n\t\t\t\t\ttradeOtherPlayerName = mobArray[currentMob].name;\n\t\t\t\tshowTradeWindow = true;\n\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\ttradeWeAccepted = false;\n\t\t\t\ttradeMyItemCount = 0;\n\t\t\t\ttradeOtherItemCount = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 187) {\n\t\t\t\tshowTradeWindow = false;\n\t\t\t\tshowTradeConfirmWindow = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 250) {\n\t\t\t\ttradeOtherItemCount = data[1] & 0xff;\n\t\t\t\tint l3 = 2;\n\t\t\t\tfor (int i11 = 0; i11 < tradeOtherItemCount; i11++) {\n\t\t\t\t\ttradeOtherItems[i11] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, l3);\n\t\t\t\t\tl3 += 2;\n\t\t\t\t\ttradeOtherItemsCount[i11] = DataOperations\n\t\t\t\t\t\t\t.readInt(data, l3);\n\t\t\t\t\tl3 += 4;\n\t\t\t\t}\n\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\ttradeWeAccepted = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 92) {\n\t\t\t\ttradeOtherAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 253) {\n\t\t\t\tshowShop = true;\n\t\t\t\tint i4 = 1;\n\t\t\t\tint j11 = data[i4++] & 0xff;\n\t\t\t\tbyte byte4 = data[i4++];\n\t\t\t\tshopItemSellPriceModifier = data[i4++] & 0xff;\n\t\t\t\tshopItemBuyPriceModifier = data[i4++] & 0xff;\n\t\t\t\tfor (int i22 = 0; i22 < 40; i22++)\n\t\t\t\t\tshopItems[i22] = -1;\n\t\t\t\tfor (int j25 = 0; j25 < j11; j25++) {\n\t\t\t\t\tshopItems[j25] = DataOperations.getUnsigned2Bytes(data, i4);\n\t\t\t\t\ti4 += 2;\n\t\t\t\t\tshopItemCount[j25] = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\ti4);\n\t\t\t\t\ti4 += 2;\n\t\t\t\t\tshopItemsBuyPrice[j25] = DataOperations.getUnsigned4Bytes(\n\t\t\t\t\t\t\tdata, i4);\n\t\t\t\t\ti4 += 4;\n\t\t\t\t\tshopItemsSellPrice[j25] = DataOperations.getUnsigned4Bytes(\n\t\t\t\t\t\t\tdata, i4);\n\t\t\t\t\ti4 += 4;\n\t\t\t\t}\n\t\t\t\tif (byte4 == 1) {\n\t\t\t\t\tint l28 = 39;\n\t\t\t\t\tfor (int k33 = 0; k33 < inventoryCount; k33++) {\n\t\t\t\t\t\tif (l28 < j11)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tboolean flag2 = false;\n\t\t\t\t\t\tfor (int j39 = 0; j39 < 40; j39++) {\n\t\t\t\t\t\t\tif (shopItems[j39] != getInventoryItems()[k33])\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tflag2 = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (getInventoryItems()[k33] == 10)\n\t\t\t\t\t\t\tflag2 = true;\n\t\t\t\t\t\tif (!flag2) {\n\t\t\t\t\t\t\tshopItems[l28] = getInventoryItems()[k33] & 0x7fff;\n\t\t\t\t\t\t\tshopItemsSellPrice[l28] = EntityHandler\n\t\t\t\t\t\t\t\t\t.getItemDef(shopItems[l28]).basePrice\n\t\t\t\t\t\t\t\t\t- (int) (EntityHandler\n\t\t\t\t\t\t\t\t\t\t\t.getItemDef(shopItems[l28]).basePrice / 2.5);\n\t\t\t\t\t\t\tshopItemsSellPrice[l28] = shopItemsSellPrice[l28]\n\t\t\t\t\t\t\t\t\t- (int) (shopItemsSellPrice[l28] * 0.10);\n\t\t\t\t\t\t\tshopItemCount[l28] = 0;\n\t\t\t\t\t\t\tl28--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (selectedShopItemIndex >= 0\n\t\t\t\t\t\t&& selectedShopItemIndex < 40\n\t\t\t\t\t\t&& shopItems[selectedShopItemIndex] != selectedShopItemType) {\n\t\t\t\t\tselectedShopItemIndex = -1;\n\t\t\t\t\tselectedShopItemType = -2;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 220) {\n\t\t\t\tshowShop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 18) {\n\t\t\t\ttradeWeAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 152) {\n\t\t\t\tconfigAutoCameraAngle = DataOperations.getUnsignedByte(data[1]) == 1;\n\t\t\t\tconfigMouseButtons = DataOperations.getUnsignedByte(data[2]) == 1;\n\t\t\t\tconfigSoundEffects = DataOperations.getUnsignedByte(data[3]) == 1;\n\t\t\t\tshowRoof = DataOperations.getUnsignedByte(data[4]) == 1;\n\t\t\t\tautoScreenshot = DataOperations.getUnsignedByte(data[5]) == 1;\n\t\t\t\tcombatWindow = DataOperations.getUnsignedByte(data[6]) == 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 209) {\n\t\t\t\tfor (int currentPrayer = 0; currentPrayer < length - 1; currentPrayer++) {\n\t\t\t\t\tboolean prayerOff = data[currentPrayer + 1] == 1;\n\t\t\t\t\tif (!prayerOn[currentPrayer] && prayerOff)\n\t\t\t\t\t\tplaySound(\"prayeron\");\n\t\t\t\t\tif (prayerOn[currentPrayer] && !prayerOff)\n\t\t\t\t\t\tplaySound(\"prayeroff\");\n\t\t\t\t\tprayerOn[currentPrayer] = prayerOff;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 93) {\n\t\t\t\tshowBank = true;\n\t\t\t\tint l4 = 1;\n\t\t\t\tnewBankItemCount = data[l4++] & 0xff;\n\t\t\t\tbankItemsMax = data[l4++] & 0xff;\n\t\t\t\tfor (int k11 = 0; k11 < newBankItemCount; k11++) {\n\t\t\t\t\tnewBankItems[k11] = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\tl4);\n\t\t\t\t\tl4 += 2;\n\t\t\t\t\tnewBankItemsCount[k11] = DataOperations.getUnsigned4Bytes(\n\t\t\t\t\t\t\tdata, l4);\n\t\t\t\t\tl4 += 4;\n\t\t\t\t}\n\t\t\t\tupdateBankItems();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 171) {\n\t\t\t\tshowBank = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 211) {\n\t\t\t\tint idx = data[1] & 0xFF;\n\t\t\t\tint oldExp = playerStatExperience[idx];\n\t\t\t\tplayerStatExperience[idx] = DataOperations.readInt(data, 2);\n\t\t\t\tif (playerStatExperience[idx] > oldExp) {\n\t\t\t\t\texpGained += (playerStatExperience[idx] - oldExp);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 229) {\n\t\t\t\tint j5 = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tif (mobArray[j5] != null) {\n\t\t\t\t\tduelOpponentName = mobArray[j5].name;\n\t\t\t\t}\n\t\t\t\tshowDuelWindow = true;\n\t\t\t\tduelMyItemCount = 0;\n\t\t\t\tduelOpponentItemCount = 0;\n\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\tduelMyAccepted = false;\n\t\t\t\tduelNoRetreating = false;\n\t\t\t\tduelNoMagic = false;\n\t\t\t\tduelNoPrayer = false;\n\t\t\t\tduelNoWeapons = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 160) {\n\t\t\t\tshowDuelWindow = false;\n\t\t\t\tshowDuelConfirmWindow = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 251) {\n\t\t\t\tshowTradeConfirmWindow = true;\n\t\t\t\ttradeConfirmAccepted = false;\n\t\t\t\tshowTradeWindow = false;\n\t\t\t\tint k5 = 1;\n\t\t\t\ttradeConfirmOtherNameLong = DataOperations.getUnsigned8Bytes(\n\t\t\t\t\t\tdata, k5);\n\t\t\t\tk5 += 8;\n\t\t\t\ttradeConfirmOtherItemCount = data[k5++] & 0xff;\n\t\t\t\tfor (int l11 = 0; l11 < tradeConfirmOtherItemCount; l11++) {\n\t\t\t\t\ttradeConfirmOtherItems[l11] = DataOperations\n\t\t\t\t\t\t\t.getUnsigned2Bytes(data, k5);\n\t\t\t\t\tk5 += 2;\n\t\t\t\t\ttradeConfirmOtherItemsCount[l11] = DataOperations.readInt(\n\t\t\t\t\t\t\tdata, k5);\n\t\t\t\t\tk5 += 4;\n\t\t\t\t}\n\t\t\t\ttradeConfirmItemCount = data[k5++] & 0xff;\n\t\t\t\tfor (int k17 = 0; k17 < tradeConfirmItemCount; k17++) {\n\t\t\t\t\ttradeConfirmItems[k17] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, k5);\n\t\t\t\t\tk5 += 2;\n\t\t\t\t\ttradeConfirmItemsCount[k17] = DataOperations.readInt(data,\n\t\t\t\t\t\t\tk5);\n\t\t\t\t\tk5 += 4;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 63) {\n\t\t\t\tduelOpponentItemCount = data[1] & 0xff;\n\t\t\t\tint l5 = 2;\n\t\t\t\tfor (int i12 = 0; i12 < duelOpponentItemCount; i12++) {\n\t\t\t\t\tduelOpponentItems[i12] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, l5);\n\t\t\t\t\tl5 += 2;\n\t\t\t\t\tduelOpponentItemsCount[i12] = DataOperations.readInt(data,\n\t\t\t\t\t\t\tl5);\n\t\t\t\t\tl5 += 4;\n\t\t\t\t}\n\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\tduelMyAccepted = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 198) {\n\t\t\t\tduelNoRetreating = data[1] == 1;\n\t\t\t\tduelNoMagic = data[2] == 1;\n\t\t\t\tduelNoPrayer = data[3] == 1;\n\t\t\t\tduelNoWeapons = data[4] == 1;\n\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\tduelMyAccepted = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 139) {\n\t\t\t\tint bankDataOffset = 1;\n\t\t\t\tint bankSlot = data[bankDataOffset++] & 0xff;\n\t\t\t\tint bankItemId = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\tbankDataOffset);\n\t\t\t\tbankDataOffset += 2;\n\t\t\t\tint bankItemCount = DataOperations.getUnsigned4Bytes(data,\n\t\t\t\t\t\tbankDataOffset);\n\t\t\t\tbankDataOffset += 4;\n\t\t\t\tif (bankItemCount == 0) {\n\t\t\t\t\tnewBankItemCount--;\n\t\t\t\t\tfor (int currentBankSlot = bankSlot; currentBankSlot < newBankItemCount; currentBankSlot++) {\n\t\t\t\t\t\tnewBankItems[currentBankSlot] = newBankItems[currentBankSlot + 1];\n\t\t\t\t\t\tnewBankItemsCount[currentBankSlot] = newBankItemsCount[currentBankSlot + 1];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnewBankItems[bankSlot] = bankItemId;\n\t\t\t\t\tnewBankItemsCount[bankSlot] = bankItemCount;\n\t\t\t\t\tif (bankSlot >= newBankItemCount)\n\t\t\t\t\t\tnewBankItemCount = bankSlot + 1;\n\t\t\t\t}\n\t\t\t\tupdateBankItems();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 228) {\n\t\t\t\tint j6 = 1;\n\t\t\t\tint k12 = 1;\n\t\t\t\tint i18 = data[j6++] & 0xff;\n\t\t\t\tint k22 = DataOperations.getUnsigned2Bytes(data, j6);\n\t\t\t\tj6 += 2;\n\t\t\t\tif (EntityHandler.getItemDef(k22 & 0x7fff).isStackable()) {\n\t\t\t\t\tk12 = DataOperations.readInt(data, j6);\n\t\t\t\t\tj6 += 4;\n\t\t\t\t}\n\t\t\t\tgetInventoryItems()[i18] = k22 & 0x7fff;\n\t\t\t\twearing[i18] = k22 / 32768;\n\t\t\t\tinventoryItemsCount[i18] = k12;\n\t\t\t\tif (i18 >= inventoryCount)\n\t\t\t\t\tinventoryCount = i18 + 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 191) {\n\t\t\t\tint k6 = data[1] & 0xff;\n\t\t\t\tinventoryCount--;\n\t\t\t\tfor (int l12 = k6; l12 < inventoryCount; l12++) {\n\t\t\t\t\tgetInventoryItems()[l12] = getInventoryItems()[l12 + 1];\n\t\t\t\t\tinventoryItemsCount[l12] = inventoryItemsCount[l12 + 1];\n\t\t\t\t\twearing[l12] = wearing[l12 + 1];\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 208) {\n\t\t\t\tint pointer = 1;\n\t\t\t\tint idx = data[pointer++] & 0xff;\n\t\t\t\tint oldExp = playerStatExperience[idx];\n\t\t\t\tplayerStatCurrent[idx] = DataOperations\n\t\t\t\t\t\t.getUnsignedByte(data[pointer++]);\n\t\t\t\tplayerStatBase[idx] = DataOperations\n\t\t\t\t\t\t.getUnsignedByte(data[pointer++]);\n\t\t\t\tplayerStatExperience[idx] = DataOperations.readInt(data,\n\t\t\t\t\t\tpointer);\n\t\t\t\tpointer += 4;\n\t\t\t\tif (playerStatExperience[idx] > oldExp) {\n\t\t\t\t\texpGained += (playerStatExperience[idx] - oldExp);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 65) {\n\t\t\t\tduelOpponentAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 197) {\n\t\t\t\tduelMyAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 147) {\n\t\t\t\tshowDuelConfirmWindow = true;\n\t\t\t\tduelWeAccept = false;\n\t\t\t\tshowDuelWindow = false;\n\t\t\t\tint i7 = 1;\n\t\t\t\tduelOpponentNameLong = DataOperations.getUnsigned8Bytes(data,\n\t\t\t\t\t\ti7);\n\t\t\t\ti7 += 8;\n\t\t\t\tduelConfirmOpponentItemCount = data[i7++] & 0xff;\n\t\t\t\tfor (int j13 = 0; j13 < duelConfirmOpponentItemCount; j13++) {\n\t\t\t\t\tduelConfirmOpponentItems[j13] = DataOperations\n\t\t\t\t\t\t\t.getUnsigned2Bytes(data, i7);\n\t\t\t\t\ti7 += 2;\n\t\t\t\t\tduelConfirmOpponentItemsCount[j13] = DataOperations\n\t\t\t\t\t\t\t.readInt(data, i7);\n\t\t\t\t\ti7 += 4;\n\t\t\t\t}\n\t\t\t\tduelConfirmMyItemCount = data[i7++] & 0xff;\n\t\t\t\tfor (int j18 = 0; j18 < duelConfirmMyItemCount; j18++) {\n\t\t\t\t\tduelConfirmMyItems[j18] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, i7);\n\t\t\t\t\ti7 += 2;\n\t\t\t\t\tduelConfirmMyItemsCount[j18] = DataOperations.readInt(data,\n\t\t\t\t\t\t\ti7);\n\t\t\t\t\ti7 += 4;\n\t\t\t\t}\n\t\t\t\tduelCantRetreat = data[i7++] & 0xff;\n\t\t\t\tduelUseMagic = data[i7++] & 0xff;\n\t\t\t\tduelUsePrayer = data[i7++] & 0xff;\n\t\t\t\tduelUseWeapons = data[i7++] & 0xff;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 11) {\n\t\t\t\tString s = new String(data, 1, length - 1);\n\t\t\t\tplaySound(s);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 23) {\n\t\t\t\tif (anInt892 < 50) {\n\t\t\t\t\tint j7 = data[1] & 0xff;\n\t\t\t\t\tint k13 = data[2] + getSectionX();\n\t\t\t\t\tint k18 = data[3] + getSectionY();\n\t\t\t\t\tanIntArray782[anInt892] = j7;\n\t\t\t\t\tanIntArray923[anInt892] = 0;\n\t\t\t\t\tanIntArray944[anInt892] = k13;\n\t\t\t\t\tanIntArray757[anInt892] = k18;\n\t\t\t\t\tanInt892++;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 248) {\n\t\t\t\tif (!hasReceivedWelcomeBoxDetails) {\n\t\t\t\t\tlastLoggedInDays = DataOperations\n\t\t\t\t\t\t\t.getUnsigned2Bytes(data, 1);\n\t\t\t\t\tsubscriptionLeftDays = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, 3);\n\t\t\t\t\tlastLoggedInAddress = new String(data, 5, length - 5);\n\t\t\t\t\tshowWelcomeBox = true;\n\t\t\t\t\thasReceivedWelcomeBoxDetails = true;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 148) {\n\t\t\t\tserverMessage = new String(data, 1, length - 1);\n\t\t\t\tshowServerMessageBox = true;\n\t\t\t\tserverMessageBoxTop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 64) {\n\t\t\t\tserverMessage = new String(data, 1, length - 1);\n\t\t\t\tshowServerMessageBox = true;\n\t\t\t\tserverMessageBoxTop = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 126) {\n\t\t\t\tfatigue = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 206) {\n\t\t\t\tif (!sleeping) {\n\t\t\t\t}\n\t\t\t\tsleeping = true;\n\t\t\t\tgameMenu.updateText(chatHandle, \"\");\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tsleepEquation = DataOperations.getImage(data, 1, length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 182) {\n\t\t\t\tint offset = 1;\n\t\t\t\tquestPoints = DataOperations.getUnsigned2Bytes(data, offset);\n\t\t\t\toffset += 2;\n\t\t\t\tfor (int i = 0; i < questName.length; i++)\n\t\t\t\t\tquestStage[i] = data[offset + i];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 224) {\n\t\t\t\tsleeping = false;\n\t\t\t\tsleepMessage = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 225) {\n\t\t\t\tsleepMessage = \"Incorrect - please try again...\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 174) {\n\t\t\t\tDataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 181) {\n\t\t\t\tif (autoScreenshot) {\n\t\t\t\t\ttakeScreenshot(false);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 172) {\n\t\t\t\tsystemUpdate = DataOperations.getUnsigned2Bytes(data, 1) * 32;\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t}\n\t}\n\tprivate String sleepMessage = \"\";\n\tprotected final void lostConnection() {\n\t\tsystemUpdate = 0;\n\t\tif (logoutTimeout != 0) {\n\t\t\tresetIntVars();\n\t\t\treturn;\n\t\t}\n\t\tsuper.lostConnection();\n\t}\n\tprivate final void playSound(String s) {\n\t\tif (audioReader == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (configSoundEffects) {\n\t\t\treturn;\n\t\t}\n\t\taudioReader.loadData(sounds,\n\t\t\t\tDataOperations.method358(s + \".pcm\", sounds),\n\t\t\t\tDataOperations.method359(s + \".pcm\", sounds));\n\t}\n\tprivate final boolean sendWalkCommand(int walkSectionX, int walkSectionY,\n\t\t\tint x1, int y1, int x2, int y2, boolean stepBoolean,\n\t\t\tboolean coordsEqual) {\n\t\tint stepCount = engineHandle.getStepCount(walkSectionX, walkSectionY,\n\t\t\t\tx1, y1, x2, y2, sectionXArray, sectionYArray, stepBoolean);\n\t\tif (stepCount == -1)\n\t\t\tif (coordsEqual) {\n\t\t\t\tstepCount = 1;\n\t\t\t\tsectionXArray[0] = x1;\n\t\t\t\tsectionYArray[0] = y1;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\tstepCount--;\n\t\twalkSectionX = sectionXArray[stepCount];\n\t\twalkSectionY = sectionYArray[stepCount];\n\t\tstepCount--;\n\t\tif (coordsEqual)\n\t\t\tsuper.streamClass.createPacket(246);\n\t\telse\n\t\t\tsuper.streamClass.createPacket(132);\n\t\tsuper.streamClass.add2ByteInt(walkSectionX + getAreaX());\n\t\tsuper.streamClass.add2ByteInt(walkSectionY + getAreaY());\n\t\tif (coordsEqual && stepCount == -1\n\t\t\t\t&& (walkSectionX + getAreaX()) % 5 == 0)\n\t\t\tstepCount = 0;\n\t\tfor (int currentStep = stepCount; currentStep >= 0\n\t\t\t\t&& currentStep > stepCount - 25; currentStep--) {\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionXArray[currentStep] - walkSectionX);\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionYArray[currentStep] - walkSectionY);\n\t\t}\n\t\tsuper.streamClass.formatPacket();\n\t\tactionPictureType = -24;\n\t\tactionPictureX = super.mouseX; \n\t\tactionPictureY = super.mouseY;\n\t\treturn true;\n\t}\n\tprivate final boolean sendWalkCommandIgnoreCoordsEqual(int walkSectionX,\n\t\t\tint walkSectionY, int x1, int y1, int x2, int y2,\n\t\t\tboolean stepBoolean, boolean coordsEqual) {\n\t\tint stepCount = engineHandle.getStepCount(walkSectionX, walkSectionY,\n\t\t\t\tx1, y1, x2, y2, sectionXArray, sectionYArray, stepBoolean);\n\t\tif (stepCount == -1)\n\t\t\treturn false;\n\t\tstepCount--;\n\t\twalkSectionX = sectionXArray[stepCount];\n\t\twalkSectionY = sectionYArray[stepCount];\n\t\tstepCount--;\n\t\tif (coordsEqual)\n\t\t\tsuper.streamClass.createPacket(246);\n\t\telse\n\t\t\tsuper.streamClass.createPacket(132);\n\t\tsuper.streamClass.add2ByteInt(walkSectionX + getAreaX());\n\t\tsuper.streamClass.add2ByteInt(walkSectionY + getAreaY());\n\t\tif (coordsEqual && stepCount == -1\n\t\t\t\t&& (walkSectionX + getAreaX()) % 5 == 0)\n\t\t\tstepCount = 0;\n\t\tfor (int currentStep = stepCount; currentStep >= 0\n\t\t\t\t&& currentStep > stepCount - 25; currentStep--) {\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionXArray[currentStep] - walkSectionX);\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionYArray[currentStep] - walkSectionY);\n\t\t}\n\t\tsuper.streamClass.formatPacket();\n\t\tactionPictureType = -24;\n\t\tactionPictureX = super.mouseX;\n\t\tactionPictureY = super.mouseY;\n\t\treturn true;\n\t}\n\tpublic final Image createImage(int i, int j) {\n\t\tif (GameWindow.gameFrame != null) {\n\t\t\treturn GameWindow.gameFrame.createImage(i, j);\n\t\t}\n\t\treturn super.createImage(i, j);\n\t}\n\tprivate final void drawTradeConfirmWindow() {\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 16, 192);\n\t\tint i = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 16, 468, 246, i, 160);\n\t\tgameGraphics.drawText(\"Please confirm your trade with @yel@\"\n\t\t\t\t+ DataOperations.longToString(tradeConfirmOtherNameLong),\n\t\t\t\tbyte0 + 234, byte1 + 12, 1, 0xffffff);\n\t\tgameGraphics.drawText(\"You are about to give:\", byte0 + 117,\n\t\t\t\tbyte1 + 30, 1, 0xffff00);\n\t\tfor (int j = 0; j < tradeConfirmItemCount; j++) {\n\t\t\tString s = EntityHandler.getItemDef(tradeConfirmItems[j]).getName();\n\t\t\tif (EntityHandler.getItemDef(tradeConfirmItems[j]).isStackable())\n\t\t\t\ts = s + \" x \" + method74(tradeConfirmItemsCount[j]);\n\t\t\tgameGraphics.drawText(s, byte0 + 117, byte1 + 42 + j * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (tradeConfirmItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 117, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tgameGraphics.drawText(\"In return you will receive:\", byte0 + 351,\n\t\t\t\tbyte1 + 30, 1, 0xffff00);\n\t\tfor (int k = 0; k < tradeConfirmOtherItemCount; k++) {\n\t\t\tString s1 = EntityHandler.getItemDef(tradeConfirmOtherItems[k])\n\t\t\t\t\t.getName();\n\t\t\tif (EntityHandler.getItemDef(tradeConfirmOtherItems[k])\n\t\t\t\t\t.isStackable())\n\t\t\t\ts1 = s1 + \" x \" + method74(tradeConfirmOtherItemsCount[k]);\n\t\t\tgameGraphics.drawText(s1, byte0 + 351, byte1 + 42 + k * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (tradeConfirmOtherItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 351, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tgameGraphics.drawText(\"Are you sure you want to do this?\", byte0 + 234,\n\t\t\t\tbyte1 + 200, 4, 65535);\n\t\tgameGraphics.drawText(\n\t\t\t\t\"There is NO WAY to reverse a trade if you change your mind.\",\n\t\t\t\tbyte0 + 234, byte1 + 215, 1, 0xffffff);\n\t\tgameGraphics.drawText(\"Remember that not all players are trustworthy\",\n\t\t\t\tbyte0 + 234, byte1 + 230, 1, 0xffffff);\n\t\tif (!tradeConfirmAccepted) {\n\t\t\tgameGraphics.drawPicture((byte0 + 118) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\t\tgameGraphics.drawPicture((byte0 + 352) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\t} else {\n\t\t\tgameGraphics.drawText(\"Waiting for other player...\", byte0 + 234,\n\t\t\t\t\tbyte1 + 250, 1, 0xffff00);\n\t\t}\n\t\tif (mouseButtonClick == 1) {\n\t\t\tif (super.mouseX < byte0 || super.mouseY < byte1\n\t\t\t\t\t|| super.mouseX > byte0 + 468 || super.mouseY > byte1 + 262) {\n\t\t\t\tshowTradeConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 118) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 118 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\ttradeConfirmAccepted = true;\n\t\t\t\tsuper.streamClass.createPacket(53);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 352) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 353 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\tshowTradeConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void walkToGroundItem(int walkSectionX, int walkSectionY,\n\t\t\tint x, int y, boolean coordsEqual) {\n\t\tif (sendWalkCommandIgnoreCoordsEqual(walkSectionX, walkSectionY, x, y,\n\t\t\t\tx, y, false, coordsEqual)) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tsendWalkCommand(walkSectionX, walkSectionY, x, y, x, y, true,\n\t\t\t\t\tcoordsEqual);\n\t\t\treturn;\n\t\t}\n\t}\n\tprivate final Mob addNPC(int serverIndex, int x, int y, int nextSprite,\n\t\t\tint type) {\n\t\tif (npcRecordArray[serverIndex] == null) {\n\t\t\tnpcRecordArray[serverIndex] = new Mob();\n\t\t\tnpcRecordArray[serverIndex].serverIndex = serverIndex;\n\t\t}\n\t\tMob mob = npcRecordArray[serverIndex];\n\t\tboolean npcAlreadyExists = false;\n\t\tfor (int lastNpcIndex = 0; lastNpcIndex < lastNpcCount; lastNpcIndex++) {\n\t\t\tif (lastNpcArray[lastNpcIndex].serverIndex != serverIndex)\n\t\t\t\tcontinue;\n\t\t\tnpcAlreadyExists = true;\n\t\t\tbreak;\n\t\t}\n\t\tif (npcAlreadyExists) {\n\t\t\tmob.type = type;\n\t\t\tmob.nextSprite = nextSprite;\n\t\t\tint waypointCurrent = mob.waypointCurrent;\n\t\t\tif (x != mob.waypointsX[waypointCurrent]\n\t\t\t\t\t|| y != mob.waypointsY[waypointCurrent]) {\n\t\t\t\tmob.waypointCurrent = waypointCurrent = (waypointCurrent + 1) % 10;\n\t\t\t\tmob.waypointsX[waypointCurrent] = x;\n\t\t\t\tmob.waypointsY[waypointCurrent] = y;\n\t\t\t}\n\t\t} else {\n\t\t\tmob.serverIndex = serverIndex;\n\t\t\tmob.waypointEndSprite = 0;\n\t\t\tmob.waypointCurrent = 0;\n\t\t\tmob.waypointsX[0] = mob.currentX = x;\n\t\t\tmob.waypointsY[0] = mob.currentY = y;\n\t\t\tmob.type = type;\n\t\t\tmob.nextSprite = mob.currentSprite = nextSprite;\n\t\t\tmob.stepCount = 0;\n\t\t}\n\t\tnpcArray[npcCount++] = mob;\n\t\treturn mob;\n\t}\n\tprivate final void drawDuelWindow() {\n\t\tif (mouseButtonClick != 0 && itemIncrement == 0)\n\t\t\titemIncrement = 1;\n\t\tif (itemIncrement > 0) {\n\t\t\tint i = super.mouseX - 22 - xAddition;\n\t\t\tint j = super.mouseY - 36 - yAddition;\n\t\t\tif (i >= 0 && j >= 0 && i < 468 && j < 262) {\n\t\t\t\tif (i > 216 && j > 30 && i < 462 && j < 235) {\n\t\t\t\t\tint k = (i - 217) / 49 + ((j - 31) / 34) * 5;\n\t\t\t\t\tif (k >= 0 && k < inventoryCount) {\n\t\t\t\t\t\tboolean flag1 = false;\n\t\t\t\t\t\tint l1 = 0;\n\t\t\t\t\t\tint k2 = getInventoryItems()[k];\n\t\t\t\t\t\tfor (int k3 = 0; k3 < duelMyItemCount; k3++)\n\t\t\t\t\t\t\tif (duelMyItems[k3] == k2)\n\t\t\t\t\t\t\t\tif (EntityHandler.getItemDef(k2).isStackable()) {\n\t\t\t\t\t\t\t\t\tfor (int i4 = 0; i4 < itemIncrement; i4++) {\n\t\t\t\t\t\t\t\t\t\tif (duelMyItemsCount[k3] < inventoryItemsCount[k])\n\t\t\t\t\t\t\t\t\t\t\tduelMyItemsCount[k3]++;\n\t\t\t\t\t\t\t\t\t\tflag1 = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tl1++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif (inventoryCount(k2) <= l1)\n\t\t\t\t\t\t\tflag1 = true;\n\t\t\t\t\t\tif (!flag1 && duelMyItemCount < 8) {\n\t\t\t\t\t\t\tduelMyItems[duelMyItemCount] = k2;\n\t\t\t\t\t\t\tduelMyItemsCount[duelMyItemCount] = 1;\n\t\t\t\t\t\t\tduelMyItemCount++;\n\t\t\t\t\t\t\tflag1 = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (flag1) {\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(123);\n\t\t\t\t\t\t\tsuper.streamClass.addByte(duelMyItemCount);\n\t\t\t\t\t\t\tfor (int duelItem = 0; duelItem < duelMyItemCount; duelItem++) {\n\t\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t\t.add2ByteInt(duelMyItems[duelItem]);\n\t\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t\t.add4ByteInt(duelMyItemsCount[duelItem]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\t\t\t\tduelMyAccepted = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i > 8 && j > 30 && i < 205 && j < 129) {\n\t\t\t\t\tint l = (i - 9) / 49 + ((j - 31) / 34) * 4;\n\t\t\t\t\tif (l >= 0 && l < duelMyItemCount) {\n\t\t\t\t\t\tint j1 = duelMyItems[l];\n\t\t\t\t\t\tfor (int i2 = 0; i2 < itemIncrement; i2++) {\n\t\t\t\t\t\t\tif (EntityHandler.getItemDef(j1).isStackable()\n\t\t\t\t\t\t\t\t\t&& duelMyItemsCount[l] > 1) {\n\t\t\t\t\t\t\t\tduelMyItemsCount[l]--;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tduelMyItemCount--;\n\t\t\t\t\t\t\tmouseDownTime = 0;\n\t\t\t\t\t\t\tfor (int l2 = l; l2 < duelMyItemCount; l2++) {\n\t\t\t\t\t\t\t\tduelMyItems[l2] = duelMyItems[l2 + 1];\n\t\t\t\t\t\t\t\tduelMyItemsCount[l2] = duelMyItemsCount[l2 + 1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.createPacket(123);\n\t\t\t\t\t\tsuper.streamClass.addByte(duelMyItemCount);\n\t\t\t\t\t\tfor (int i3 = 0; i3 < duelMyItemCount; i3++) {\n\t\t\t\t\t\t\tsuper.streamClass.add2ByteInt(duelMyItems[i3]);\n\t\t\t\t\t\t\tsuper.streamClass.add4ByteInt(duelMyItemsCount[i3]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\t\t\tduelMyAccepted = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tboolean flag = false;\n\t\t\t\tif (i >= 93 && j >= 221 && i <= 104 && j <= 232) {\n\t\t\t\t\tduelNoRetreating = !duelNoRetreating;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (i >= 93 && j >= 240 && i <= 104 && j <= 251) {\n\t\t\t\t\tduelNoMagic = !duelNoMagic;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (i >= 191 && j >= 221 && i <= 202 && j <= 232) {\n\t\t\t\t\tduelNoPrayer = !duelNoPrayer;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (i >= 191 && j >= 240 && i <= 202 && j <= 251) {\n\t\t\t\t\tduelNoWeapons = !duelNoWeapons;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (flag) {\n\t\t\t\t\tsuper.streamClass.createPacket(225);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoRetreating ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoMagic ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoPrayer ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoWeapons ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\t\tduelMyAccepted = false;\n\t\t\t\t}\n\t\t\t\tif (i >= 217 && j >= 238 && i <= 286 && j <= 259) {\n\t\t\t\t\tduelMyAccepted = true;\n\t\t\t\t\tsuper.streamClass.createPacket(252);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t\tif (i >= 394 && j >= 238 && i < 463 && j < 259) {\n\t\t\t\t\tshowDuelWindow = false;\n\t\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t} else if (mouseButtonClick != 0) {\n\t\t\t\tshowDuelWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\titemIncrement = 0;\n\t\t}\n\t\tif (!showDuelWindow)\n\t\t\treturn;\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 12, 0xc90b1d);\n\t\tint i1 = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 12, 468, 18, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 30, 8, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 205, byte1 + 30, 11, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 462, byte1 + 30, 6, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 99, 197, 24, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 192, 197, 23, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 258, 197, 20, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 235, 246, 43, i1, 160);\n\t\tint k1 = 0xd0d0d0;\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 30, 197, 69, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 123, 197, 69, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 215, 197, 43, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 30, 246, 205, k1, 160);\n\t\tfor (int j2 = 0; j2 < 3; j2++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 30 + j2 * 34, 197, 0);\n\t\tfor (int j3 = 0; j3 < 3; j3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 123 + j3 * 34, 197, 0);\n\t\tfor (int l3 = 0; l3 < 7; l3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 216, byte1 + 30 + l3 * 34, 246, 0);\n\t\tfor (int k4 = 0; k4 < 6; k4++) {\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics.drawLineY(byte0 + 8 + k4 * 49, byte1 + 30, 69, 0);\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics.drawLineY(byte0 + 8 + k4 * 49, byte1 + 123, 69, 0);\n\t\t\tgameGraphics.drawLineY(byte0 + 216 + k4 * 49, byte1 + 30, 205, 0);\n\t\t}\n\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 215, 197, 0);\n\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 257, 197, 0);\n\t\tgameGraphics.drawLineY(byte0 + 8, byte1 + 215, 43, 0);\n\t\tgameGraphics.drawLineY(byte0 + 204, byte1 + 215, 43, 0);\n\t\tgameGraphics.drawString(\"Preparing to duel with: \" + duelOpponentName,\n\t\t\t\tbyte0 + 1, byte1 + 10, 1, 0xffffff);\n\t\tgameGraphics.drawString(\"Your Stake\", byte0 + 9, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Opponent's Stake\", byte0 + 9, byte1 + 120, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Duel Options\", byte0 + 9, byte1 + 212, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Your Inventory\", byte0 + 216, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"No retreating\", byte0 + 8 + 1,\n\t\t\t\tbyte1 + 215 + 16, 3, 0xffff00);\n\t\tgameGraphics.drawString(\"No magic\", byte0 + 8 + 1, byte1 + 215 + 35, 3,\n\t\t\t\t0xffff00);\n\t\tgameGraphics.drawString(\"No prayer\", byte0 + 8 + 102, byte1 + 215 + 16,\n\t\t\t\t3, 0xffff00);\n\t\tgameGraphics.drawString(\"No weapons\", byte0 + 8 + 102,\n\t\t\t\tbyte1 + 215 + 35, 3, 0xffff00);\n\t\tgameGraphics.drawBoxEdge(byte0 + 93, byte1 + 215 + 6, 11, 11, 0xffff00);\n\t\tif (duelNoRetreating)\n\t\t\tgameGraphics.drawBox(byte0 + 95, byte1 + 215 + 8, 7, 7, 0xffff00);\n\t\tgameGraphics\n\t\t\t\t.drawBoxEdge(byte0 + 93, byte1 + 215 + 25, 11, 11, 0xffff00);\n\t\tif (duelNoMagic)\n\t\t\tgameGraphics.drawBox(byte0 + 95, byte1 + 215 + 27, 7, 7, 0xffff00);\n\t\tgameGraphics\n\t\t\t\t.drawBoxEdge(byte0 + 191, byte1 + 215 + 6, 11, 11, 0xffff00);\n\t\tif (duelNoPrayer)\n\t\t\tgameGraphics.drawBox(byte0 + 193, byte1 + 215 + 8, 7, 7, 0xffff00);\n\t\tgameGraphics.drawBoxEdge(byte0 + 191, byte1 + 215 + 25, 11, 11,\n\t\t\t\t0xffff00);\n\t\tif (duelNoWeapons)\n\t\t\tgameGraphics.drawBox(byte0 + 193, byte1 + 215 + 27, 7, 7, 0xffff00);\n\t\tif (!duelMyAccepted)\n\t\t\tgameGraphics.drawPicture(byte0 + 217, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\tgameGraphics.drawPicture(byte0 + 394, byte1 + 238,\n\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\tif (duelOpponentAccepted) {\n\t\t\tgameGraphics.drawText(\"Other player\", byte0 + 341, byte1 + 246, 1,\n\t\t\t\t\t0xffffff);\n\t\t\tgameGraphics.drawText(\"has accepted\", byte0 + 341, byte1 + 256, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (duelMyAccepted) {\n\t\t\tgameGraphics.drawText(\"Waiting for\", byte0 + 217 + 35, byte1 + 246,\n\t\t\t\t\t1, 0xffffff);\n\t\t\tgameGraphics.drawText(\"other player\", byte0 + 217 + 35,\n\t\t\t\t\tbyte1 + 256, 1, 0xffffff);\n\t\t}\n\t\tfor (int l4 = 0; l4 < inventoryCount; l4++) {\n\t\t\tint i5 = 217 + byte0 + (l4 % 5) * 49;\n\t\t\tint k5 = 31 + byte1 + (l4 / 5) * 34;\n\t\t\tgameGraphics.spriteClip4(i5, k5, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(getInventoryItems()[l4]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(inventoryItemsCount[l4]), i5 + 1,\n\t\t\t\t\t\tk5 + 10, 1, 0xffff00);\n\t\t}\n\t\tfor (int j5 = 0; j5 < duelMyItemCount; j5++) {\n\t\t\tint l5 = 9 + byte0 + (j5 % 4) * 49;\n\t\t\tint j6 = 31 + byte1 + (j5 / 4) * 34;\n\t\t\tgameGraphics.spriteClip4(l5, j6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(duelMyItems[j5]).getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(duelMyItems[j5]).getPictureMask(),\n\t\t\t\t\t0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(duelMyItems[j5]).isStackable())\n\t\t\t\tgameGraphics.drawString(String.valueOf(duelMyItemsCount[j5]),\n\t\t\t\t\t\tl5 + 1, j6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > l5 && super.mouseX < l5 + 48\n\t\t\t\t\t&& super.mouseY > j6 && super.mouseY < j6 + 32)\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getItemDef(duelMyItems[j5]).getName()\n\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(duelMyItems[j5])\n\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t\tfor (int i6 = 0; i6 < duelOpponentItemCount; i6++) {\n\t\t\tint k6 = 9 + byte0 + (i6 % 4) * 49;\n\t\t\tint l6 = 124 + byte1 + (i6 / 4) * 34;\n\t\t\tgameGraphics.spriteClip4(k6, l6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(duelOpponentItems[i6])\n\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(duelOpponentItems[i6])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(duelOpponentItems[i6]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(duelOpponentItemsCount[i6]), k6 + 1,\n\t\t\t\t\t\tl6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > k6 && super.mouseX < k6 + 48\n\t\t\t\t\t&& super.mouseY > l6 && super.mouseY < l6 + 32)\n\t\t\t\tgameGraphics\n\t\t\t\t\t\t.drawString(\n\t\t\t\t\t\t\t\tEntityHandler.getItemDef(duelOpponentItems[i6])\n\t\t\t\t\t\t\t\t\t\t.getName()\n\t\t\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(\n\t\t\t\t\t\t\t\t\t\t\t\tduelOpponentItems[i6])\n\t\t\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t}\n\tprivate final void drawServerMessageBox() {\n\t\tint c = '\\u0190';\n\t\tint c1 = 'd';\n\t\tif (serverMessageBoxTop) {\n\t\t\tc1 = '\\u01C2';\n\t\t\tc1 = '\\u012C';\n\t\t}\n\t\tgameGraphics.drawBox(256 - c / 2 + xAddition, 167 - c1 / 2 + yAddition,\n\t\t\t\tc, c1, 0);\n\t\tgameGraphics.drawBoxEdge(256 - c / 2 + xAddition, 167 - c1 / 2\n\t\t\t\t+ yAddition, c, c1, 0xffffff);\n\t\tgameGraphics.drawBoxTextColour(serverMessage, 256 + xAddition,\n\t\t\t\t(167 - c1 / 2) + 20 + yAddition, 1, 0xffffff, c - 40);\n\t\tint i = 157 + c1 / 2 + yAddition;\n\t\tint j = 0xffffff;\n\t\tif (super.mouseY > i - 12 && super.mouseY <= i\n\t\t\t\t&& super.mouseX > 106 + xAddition\n\t\t\t\t&& super.mouseX < 406 + xAddition)\n\t\t\tj = 0xff0000;\n\t\tgameGraphics.drawText(\"Click here to close window\", 256 + xAddition, i,\n\t\t\t\t1, j);\n\t\tif (mouseButtonClick == 1) {\n\t\t\tif (j == 0xff0000)\n\t\t\t\tshowServerMessageBox = false;\n\t\t\tif ((super.mouseX < 256 - c / 2 + xAddition || super.mouseX > 256\n\t\t\t\t\t+ c / 2 + xAddition)\n\t\t\t\t\t&& (super.mouseY < 167 - c1 / 2 + yAddition || super.mouseY > 167\n\t\t\t\t\t\t\t+ c1 / 2 + yAddition))\n\t\t\t\tshowServerMessageBox = false;\n\t\t}\n\t\tmouseButtonClick = 0;\n\t}\n\tprivate final void makeLoginMenus() {\n\t\tmenuWelcome = new Menu(gameGraphics, 50);\n\t\tint i = 40 + yAddition;\n\t\tmenuWelcome.drawText(256 + xAddition, 200 + i, \"Click on an option\", 5,\n\t\t\t\ttrue);\n\t\tmenuWelcome.drawBox(156 + xAddition, 240 + i, 120, 35);\n\t\tmenuWelcome.drawBox(356 + xAddition, 240 + i, 120, 35);\n\t\tmenuWelcome.drawText(156 + xAddition, 240 + i, \"New User\", 5, false);\n\t\tmenuWelcome.drawText(356 + xAddition, 240 + i, \"Existing User\", 5,\n\t\t\t\tfalse);\n\t\tloginButtonNewUser = menuWelcome.makeButton(156 + xAddition, 240 + i,\n\t\t\t\t120, 35);\n\t\tloginButtonExistingUser = menuWelcome.makeButton(356 + xAddition,\n\t\t\t\t240 + i, 120, 35);\n\t\tmenuNewUser = new Menu(gameGraphics, 50);\n\t\ti = 230 + yAddition;\n\t\tif (referId == 0) {\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8,\n\t\t\t\t\t\"To create an account please go back to the\", 4, true);\n\t\t\ti += 20;\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"www.3hit.net\", 4,\n\t\t\t\t\ttrue);\n\t\t} else if (referId == 1) {\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"then click account\",\n\t\t\t\t\t4, true);\n\t\t\ti += 20;\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"\", 4, true);\n\t\t} else {\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"\", 4, true);\n\t\t\ti += 20;\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"\", 4, true);\n\t\t}\n\t\ti += 30;\n\t\tmenuNewUser.drawBox(256 + xAddition, i + 17, 150, 34);\n\t\tmenuNewUser.drawText(256 + xAddition, i + 17, \"Ok\", 5, false);\n\t\tnewUserOkButton = menuNewUser.makeButton(256 + xAddition, i + 17, 150,\n\t\t\t\t34);\n\t\tmenuLogin = new Menu(gameGraphics, 50);\n\t\ti = 230 + yAddition;\n\t\tloginStatusText = menuLogin.drawText(256 + xAddition, i - 10,\n\t\t\t\t\"Please enter your username and password\", 4, true);\n\t\ti += 28;\n\t\tmenuLogin.drawBox(140 + xAddition, i, 200, 40);\n\t\tmenuLogin.drawText(140 + xAddition, i - 10, \"Username:\", 4, false);\n\t\tloginUsernameTextBox = menuLogin.makeTextBox(140 + xAddition, i + 10,\n\t\t\t\t200, 40, 4, 12, false, false);\n\t\ti += 47;\n\t\tmenuLogin.drawBox(190 + xAddition, i, 200, 40);\n\t\tmenuLogin.drawText(190 + xAddition, i - 10, \"Password:\", 4, false);\n\t\tloginPasswordTextBox = menuLogin.makeTextBox(190 + xAddition, i + 10,\n\t\t\t\t200, 40, 4, 20, true, false);\n\t\ti -= 55;\n\t\tmenuLogin.drawBox(410 + xAddition, i, 120, 25);\n\t\tmenuLogin.drawText(410 + xAddition, i, \"Play Now\", 4, false);\n\t\tloginOkButton = menuLogin.makeButton(410 + xAddition, i, 120, 25);\n\t\ti += 30;\n\t\tmenuLogin.drawBox(410 + xAddition, i, 120, 25);\n\t\tmenuLogin.drawText(410 + xAddition, i, \"Cancel\", 4, false);\n\t\tloginCancelButton = menuLogin.makeButton(410 + xAddition, i, 120, 25);\n\t\ti += 30;\n\t\tmenuLogin.setFocus(loginUsernameTextBox);\n\t}\n\tprivate final void drawGameWindowsMenus() {\n\t\tif (logoutTimeout != 0)\n\t\t\tdrawLoggingOutBox();\n\t\telse if (showWelcomeBox)\n\t\t\tdrawWelcomeBox();\n\t\telse if (showServerMessageBox)\n\t\t\tdrawServerMessageBox();\n\t\telse if (wildernessType == 1) \n\t\t\tdrawWildernessWarningBox();\n\t\telse if (showBank && lastWalkTimeout == 0)\n\t\t\tdrawBankBox();\n\t\telse if (showShop && lastWalkTimeout == 0)\n\t\t\tdrawShopBox();\n\t\telse if (showTradeConfirmWindow)\n\t\t\tdrawTradeConfirmWindow();\n\t\telse if (showTradeWindow)\n\t\t\tdrawTradeWindow();\n\t\telse if (showDuelConfirmWindow)\n\t\t\tdrawDuelConfirmWindow();\n\t\telse if (showDuelWindow)\n\t\t\tdrawDuelWindow();\n\t\telse if (showAbuseWindow == 1)\n\t\t\tdrawAbuseWindow1();\n\t\telse if (showAbuseWindow == 2)\n\t\t\tdrawAbuseWindow2();\n\t\telse if (inputBoxType != 0) {\n\t\t\tdrawInputBox();\n\t\t} else {\n\t\t\tif (showQuestionMenu)\n\t\t\t\tdrawQuestionMenu();\n\t\t\tif ((ourPlayer.currentSprite == 8 || ourPlayer.currentSprite == 9)\n\t\t\t\t\t|| combatWindow)\n\t\t\t\tdrawCombatStyleWindow();\n\t\t\tcheckMouseOverMenus();\n\t\t\tboolean noMenusShown = !showQuestionMenu && !showRightClickMenu;\n\t\t\tif (noMenusShown)\n\t\t\t\tmenuLength = 0;\n\t\t\tif (mouseOverMenu == 0 && noMenusShown)\n\t\t\t\tdrawInventoryRightClickMenu();\n\t\t\tif (mouseOverMenu == 1)\n\t\t\t\tdrawInventoryMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 2)\n\t\t\t\tdrawMapMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 3)\n\t\t\t\tdrawPlayerInfoMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 4)\n\t\t\t\tdrawMagicWindow(noMenusShown);\n\t\t\tif (mouseOverMenu == 5)\n\t\t\t\tdrawFriendsWindow(noMenusShown);\n\t\t\tif (mouseOverMenu == 6)\n\t\t\t\tdrawOptionsMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 7)\n\t\t\t\tdrawOurOptionsMenu(noMenusShown);\n\t\t\tif (!showRightClickMenu && !showQuestionMenu)\n\t\t\t\tcheckMouseStatus();\n\t\t\tif (showRightClickMenu && !showQuestionMenu)\n\t\t\t\tdrawRightClickMenu();\n\t\t}\n\t\tmouseButtonClick = 0;\n\t}\n\tpublic final void method112(int i, int j, int k, int l, boolean flag) {\n\t\tsendWalkCommand(i, j, k, l, k, l, false, flag);\n\t}\n\tprivate final void drawInputBox() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tmouseButtonClick = 0;\n\t\t\tif (inputBoxType == 1\n\t\t\t\t\t&& (super.mouseX < 106 + xAddition\n\t\t\t\t\t\t\t|| super.mouseY < 145 + yAddition\n\t\t\t\t\t\t\t|| super.mouseX > 406 + xAddition || super.mouseY > 215 + yAddition)) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputBoxType == 2\n\t\t\t\t\t&& (super.mouseX < 6 + xAddition\n\t\t\t\t\t\t\t|| super.mouseY < 145 + yAddition\n\t\t\t\t\t\t\t|| super.mouseX > 506 + xAddition || super.mouseY > 215 + yAddition)) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputBoxType == 3\n\t\t\t\t\t&& (super.mouseX < 106 + xAddition\n\t\t\t\t\t\t\t|| super.mouseY < 145 + yAddition\n\t\t\t\t\t\t\t|| super.mouseX > 406 + xAddition || super.mouseY > 215 + yAddition)) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (super.mouseX > 236 + xAddition\n\t\t\t\t\t&& super.mouseX < 276 + xAddition\n\t\t\t\t\t&& super.mouseY > 193 + yAddition\n\t\t\t\t\t&& super.mouseY < 213 + yAddition) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tint i = 145 + yAddition;\n\t\tif (inputBoxType == 1) {\n\t\t\tgameGraphics.drawBox(106 + xAddition, i, 300, 70, 0);\n\t\t\tgameGraphics.drawBoxEdge(106 + xAddition, i, 300, 70, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(\"Enter name to add to friends list\",\n\t\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(super.inputText + \"*\", 256 + xAddition, i, 4,\n\t\t\t\t\t0xffffff);\n\t\t\tif (super.enteredText.length() > 0) {\n\t\t\t\tString s = super.enteredText.trim();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tinputBoxType = 0;\n\t\t\t\tif (s.length() > 0\n\t\t\t\t\t\t&& DataOperations.stringLength12ToLong(s) != ourPlayer.nameLong)\n\t\t\t\t\taddToFriendsList(s);\n\t\t\t}\n\t\t}\n\t\tif (inputBoxType == 2) {\n\t\t\tgameGraphics.drawBox(6 + xAddition, i, 500, 70, 0);\n\t\t\tgameGraphics.drawBoxEdge(6 + xAddition, i, 500, 70, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics\n\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\"Enter message to send to \"\n\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t.longToString(privateMessageTarget),\n\t\t\t\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(super.inputMessage + \"*\", 256 + xAddition, i,\n\t\t\t\t\t4, 0xffffff);\n\t\t\tif (super.enteredMessage.length() > 0) {\n\t\t\t\tString s1 = super.enteredMessage;\n\t\t\t\tsuper.inputMessage = \"\";\n\t\t\t\tsuper.enteredMessage = \"\";\n\t\t\t\tinputBoxType = 0;\n\t\t\t\tbyte[] message = DataConversions.stringToByteArray(s1);\n\t\t\t\tsendPrivateMessage(privateMessageTarget, message,\n\t\t\t\t\t\tmessage.length);\n\t\t\t\ts1 = DataConversions.byteToString(message, 0, message.length);\n\t\t\t\thandleServerMessage(\"@pri@You tell \"\n\t\t\t\t\t\t+ DataOperations.longToString(privateMessageTarget)\n\t\t\t\t\t\t+ \": \" + s1);\n\t\t\t}\n\t\t}\n\t\tif (inputBoxType == 3) {\n\t\t\tgameGraphics.drawBox(106 + xAddition, i, 300, 70, 0);\n\t\t\tgameGraphics.drawBoxEdge(106 + xAddition, i, 300, 70, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(\"Enter name to add to ignore list\",\n\t\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(super.inputText + \"*\", 256 + xAddition, i, 4,\n\t\t\t\t\t0xffffff);\n\t\t\tif (super.enteredText.length() > 0) {\n\t\t\t\tString s2 = super.enteredText.trim();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tinputBoxType = 0;\n\t\t\t\tif (s2.length() > 0\n\t\t\t\t\t\t&& DataOperations.stringLength12ToLong(s2) != ourPlayer.nameLong)\n\t\t\t\t\taddToIgnoreList(s2);\n\t\t\t}\n\t\t}\n\t\tint j = 0xffffff;\n\t\tif (super.mouseX > 236 + xAddition && super.mouseX < 276 + xAddition\n\t\t\t\t&& super.mouseY > 193 + yAddition\n\t\t\t\t&& super.mouseY < 213 + yAddition)\n\t\t\tj = 0xffff00;\n\t\tgameGraphics.drawText(\"Cancel\", 256 + xAddition, 208 + yAddition, 1, j);\n\t}\n\tprivate final boolean hasRequiredRunes(int i, int j) {\n\t\tif (i == 31 && (method117(197) || method117(615) || method117(682))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (i == 32 && (method117(102) || method117(616) || method117(683))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (i == 33 && (method117(101) || method117(617) || method117(684))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (i == 34 && (method117(103) || method117(618) || method117(685))) {\n\t\t\treturn true;\n\t\t}\n\t\treturn inventoryCount(i) >= j;\n\t}\n\tprivate final void resetPrivateMessageStrings() {\n\t\tsuper.inputMessage = \"\";\n\t\tsuper.enteredMessage = \"\";\n\t}\n\tprivate final boolean method117(int i) {\n\t\tfor (int j = 0; j < inventoryCount; j++)\n\t\t\tif (getInventoryItems()[j] == i && wearing[j] == 1)\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\tprivate final void setPixelsAndAroundColour(int x, int y, int colour) {\n\t\tgameGraphics.setPixelColour(x, y, colour);\n\t\tgameGraphics.setPixelColour(x - 1, y, colour);\n\t\tgameGraphics.setPixelColour(x + 1, y, colour);\n\t\tgameGraphics.setPixelColour(x, y - 1, colour);\n\t\tgameGraphics.setPixelColour(x, y + 1, colour);\n\t}\n\tprivate final void method119() {\n\t\tfor (int i = 0; i < mobMessageCount; i++) {\n\t\t\tint j = gameGraphics.messageFontHeight(1);\n\t\t\tint l = mobMessagesX[i];\n\t\t\tint k1 = mobMessagesY[i];\n\t\t\tint j2 = mobMessagesWidth[i];\n\t\t\tint i3 = mobMessagesHeight[i];\n\t\t\tboolean flag = true;\n\t\t\twhile (flag) {\n\t\t\t\tflag = false;\n\t\t\t\tfor (int i4 = 0; i4 < i; i4++)\n\t\t\t\t\tif (k1 + i3 > mobMessagesY[i4] - j\n\t\t\t\t\t\t\t&& k1 - j < mobMessagesY[i4]\n\t\t\t\t\t\t\t\t\t+ mobMessagesHeight[i4]\n\t\t\t\t\t\t\t&& l - j2 < mobMessagesX[i4] + mobMessagesWidth[i4]\n\t\t\t\t\t\t\t&& l + j2 > mobMessagesX[i4] - mobMessagesWidth[i4]\n\t\t\t\t\t\t\t&& mobMessagesY[i4] - j - i3 < k1) {\n\t\t\t\t\t\tk1 = mobMessagesY[i4] - j - i3;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tmobMessagesY[i] = k1;\n\t\t\tgameGraphics.drawBoxTextColour(mobMessages[i], l, k1, 1, 0xffff00,\n\t\t\t\t\t300);\n\t\t}\n\t\tfor (int k = 0; k < anInt699; k++) {\n\t\t\tint i1 = anIntArray858[k];\n\t\t\tint l1 = anIntArray859[k];\n\t\t\tint k2 = anIntArray705[k];\n\t\t\tint j3 = anIntArray706[k];\n\t\t\tint l3 = (39 * k2) / 100;\n\t\t\tint j4 = (27 * k2) / 100;\n\t\t\tint k4 = l1 - j4;\n\t\t\tgameGraphics.spriteClip2(i1 - l3 / 2, k4, l3, j4,\n\t\t\t\t\tSPRITE_MEDIA_START + 9, 85);\n\t\t\tint l4 = (36 * k2) / 100;\n\t\t\tint i5 = (24 * k2) / 100;\n\t\t\tgameGraphics.spriteClip4(i1 - l4 / 2, (k4 + j4 / 2) - i5 / 2, l4,\n\t\t\t\t\ti5, EntityHandler.getItemDef(j3).getSprite()\n\t\t\t\t\t\t\t+ SPRITE_ITEM_START, EntityHandler.getItemDef(j3)\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t}\n\t\tfor (int j1 = 0; j1 < anInt718; j1++) {\n\t\t\tint i2 = anIntArray786[j1];\n\t\t\tint l2 = anIntArray787[j1];\n\t\t\tint k3 = anIntArray788[j1];\n\t\t\tgameGraphics.drawBoxAlpha(i2 - 15, l2 - 3, k3, 5, 65280, 192);\n\t\t\tgameGraphics.drawBoxAlpha((i2 - 15) + k3, l2 - 3, 30 - k3, 5,\n\t\t\t\t\t0xff0000, 192);\n\t\t}\n\t}\n\tprivate final void drawMapMenu(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tchar c = '\\234';\n\t\tchar c2 = '\\230';\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 2);\n\t\ti += 40;\n\t\tgameGraphics.drawBox(i, 36, c, c2, 0);\n\t\tgameGraphics.setDimensions(i, 36, i + c, 36 + c2);\n\t\tint k = 192 + anInt986;\n\t\tint i1 = cameraRotation + anInt985 & 0xff;\n\t\tint k1 = ((ourPlayer.currentX - 6040) * 3 * k) / 2048;\n\t\tint i3 = ((ourPlayer.currentY - 6040) * 3 * k) / 2048;\n\t\tint k4 = Camera.anIntArray384[1024 - i1 * 4 & 0x3ff];\n\t\tint i5 = Camera.anIntArray384[(1024 - i1 * 4 & 0x3ff) + 1024];\n\t\tint k5 = i3 * k4 + k1 * i5 >> 18;\n\t\ti3 = i3 * i5 - k1 * k4 >> 18;\n\t\tk1 = k5;\n\t\tgameGraphics.method242((i + c / 2) - k1, 36 + c2 / 2 + i3,\n\t\t\t\tSPRITE_MEDIA_START - 1, i1 + 64 & 0xff, k);\n\t\tfor (int i7 = 0; i7 < objectCount; i7++) {\n\t\t\tint l1 = (((objectX[i7] * magicLoc + 64) - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint j3 = (((objectY[i7] * magicLoc + 64) - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint l5 = j3 * k4 + l1 * i5 >> 18;\n\t\t\tj3 = j3 * i5 - l1 * k4 >> 18;\n\t\t\tl1 = l5;\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + l1, (36 + c2 / 2) - j3, 65535);\n\t\t}\n\t\tfor (int j7 = 0; j7 < groundItemCount; j7++) {\n\t\t\tint i2 = (((groundItemX[j7] * magicLoc + 64) - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint k3 = (((groundItemY[j7] * magicLoc + 64) - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint i6 = k3 * k4 + i2 * i5 >> 18;\n\t\t\tk3 = k3 * i5 - i2 * k4 >> 18;\n\t\t\ti2 = i6;\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + i2, (36 + c2 / 2) - k3,\n\t\t\t\t\t0xff0000);\n\t\t}\n\t\tfor (int k7 = 0; k7 < npcCount; k7++) {\n\t\t\tMob mob = npcArray[k7];\n\t\t\tint j2 = ((mob.currentX - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint l3 = ((mob.currentY - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint j6 = l3 * k4 + j2 * i5 >> 18;\n\t\t\tl3 = l3 * i5 - j2 * k4 >> 18;\n\t\t\tj2 = j6;\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + j2, (36 + c2 / 2) - l3,\n\t\t\t\t\t0xffff00);\n\t\t}\n\t\tfor (int l7 = 0; l7 < playerCount; l7++) {\n\t\t\tMob mob_1 = playerArray[l7];\n\t\t\tint k2 = ((mob_1.currentX - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint i4 = ((mob_1.currentY - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint k6 = i4 * k4 + k2 * i5 >> 18;\n\t\t\ti4 = i4 * i5 - k2 * k4 >> 18;\n\t\t\tk2 = k6;\n\t\t\tint j8 = 0xffffff;\n\t\t\tfor (int k8 = 0; k8 < super.friendsCount; k8++) {\n\t\t\t\tif (mob_1.nameLong != super.friendsListLongs[k8]\n\t\t\t\t\t\t|| super.friendsListOnlineStatus[k8] != 99)\n\t\t\t\t\tcontinue;\n\t\t\t\tj8 = 65280;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + k2, (36 + c2 / 2) - i4, j8);\n\t\t}\n\t\tgameGraphics.method212(i + c / 2, 36 + c2 / 2, 2, 0xffffff, 255);\n\t\tgameGraphics.method242(i + 19, 55, SPRITE_MEDIA_START + 24,\n\t\t\t\tcameraRotation + 128 & 0xff, 128);\n\t\tgameGraphics.setDimensions(0, 0, windowWidth, windowHeight + 12);\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tint i8 = super.mouseY - 36;\n\t\tif (i >= 40 && i8 >= 0 && i < 196 && i8 < 152) {\n\t\t\tchar c1 = '\\234';\n\t\t\tchar c3 = '\\230';\n\t\t\tint l = 192 + anInt986;\n\t\t\tint j1 = cameraRotation + anInt985 & 0xff;\n\t\t\tint j = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\t\tj += 40;\n\t\t\tint l2 = ((super.mouseX - (j + c1 / 2)) * 16384) / (3 * l);\n\t\t\tint j4 = ((super.mouseY - (36 + c3 / 2)) * 16384) / (3 * l);\n\t\t\tint l4 = Camera.anIntArray384[1024 - j1 * 4 & 0x3ff];\n\t\t\tint j5 = Camera.anIntArray384[(1024 - j1 * 4 & 0x3ff) + 1024];\n\t\t\tint l6 = j4 * l4 + l2 * j5 >> 15;\n\t\t\tj4 = j4 * j5 - l2 * l4 >> 15;\n\t\t\tl2 = l6;\n\t\t\tl2 += ourPlayer.currentX;\n\t\t\tj4 = ourPlayer.currentY - j4;\n\t\t\tif (mouseButtonClick == 1)\n\t\t\t\tmethod112(getSectionX(), getSectionY(), l2 / 128, j4 / 128,\n\t\t\t\t\t\tfalse);\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tpublic mudclient() {\n\t\tfor (int i = 0; i < questStage.length; i++)\n\t\t\tquestStage[i] = (byte) 0;\n\t\tcombatWindow = false;\n\t\tthreadSleepTime = 10;\n\t\ttry {\n\t\t\tlocalhost = InetAddress.getLocalHost().getHostAddress();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tlocalhost = \"unknown\";\n\t\t}\n\t\tif (config.getProperty(\"width\") == null) {\n\t\t\tConfig.storeConfig(\"width\", \"502\");\n\t\t}\n\t\tif (config.getProperty(\"height\") == null) {\n\t\t\tConfig.storeConfig(\"height\", \"382\");\n\t\t}\n\t\tif (config.getProperty(\"refreshRate\") == null) {\n\t\t\tConfig.storeConfig(\"refreshRate\",\n\t\t\t\t\t\"\" + Resolutions.oldDisplayMode.getRefreshRate());\n\t\t}\n\t\tif (config.getProperty(\"bitDepth\") == null) {\n\t\t\tConfig.storeConfig(\"bitDepth\",\n\t\t\t\t\t\"\" + Resolutions.oldDisplayMode.getBitDepth());\n\t\t}\n\t\twindowWidth = Integer.valueOf(config.getProperty(\"width\"));\n\t\twindowHeight = Integer.valueOf(config.getProperty(\"height\")) - 40;\n\t\tscreenDepth = Integer.valueOf(config.getProperty(\"bitDepth\"));\n\t\tscreenRefreshRate = Integer.valueOf(config.getProperty(\"refreshRate\"));\n\t\tif (windowWidth < defaultWidth || windowHeight < defaultHeight) {\n\t\t\twindowWidth = defaultWidth;\n\t\t\tConfig.storeConfig(\"width\", \"502\");\n\t\t\twindowHeight = defaultHeight;\n\t\t\tConfig.storeConfig(\"height\", \"382\");\n\t\t}\n\t\tif (windowWidth > 532) {\n\t\t\txAddition = (windowWidth - defaultWidth) / 2;\n\t\t\tyAddition = (windowHeight - defaultHeight) / 2;\n\t\t} else {\n\t\t\txAddition = 0;\n\t\t\tyAddition = 0;\n\t\t}\n\t\tstartTime = System.currentTimeMillis();\n\t\tduelMyItems = new int[8];\n\t\tduelMyItemsCount = new int[8];\n\t\tconfigAutoCameraAngle = true;\n\t\tquestionMenuAnswer = new String[10];\n\t\tlastNpcArray = new Mob[500];\n\t\tcurrentUser = \"\";\n\t\tcurrentPass = \"\";\n\t\tmenuText1 = new String[250];\n\t\tduelOpponentAccepted = false;\n\t\tduelMyAccepted = false;\n\t\ttradeConfirmItems = new int[14];\n\t\ttradeConfirmItemsCount = new int[14];\n\t\ttradeConfirmOtherItems = new int[14];\n\t\ttradeConfirmOtherItemsCount = new int[14];\n\t\tserverMessage = \"\";\n\t\tduelOpponentName = \"\";\n\t\tsetInventoryItems(new int[35]);\n\t\tinventoryItemsCount = new int[35];\n\t\twearing = new int[35];\n\t\tmobMessages = new String[50];\n\t\tshowBank = false;\n\t\tdoorModel = new Model[500];\n\t\tmobMessagesX = new int[50];\n\t\tmobMessagesY = new int[50];\n\t\tmobMessagesWidth = new int[50];\n\t\tmobMessagesHeight = new int[50];\n\t\tnpcArray = new Mob[500];\n\t\tequipmentStatus = new int[6];\n\t\tprayerOn = new boolean[50];\n\t\ttradeOtherAccepted = false;\n\t\ttradeWeAccepted = false;\n\t\tmobArray = new Mob[8000];\n\t\tanIntArray705 = new int[50];\n\t\tanIntArray706 = new int[50];\n\t\tlastWildYSubtract = -1;\n\t\tmemoryError = false;\n\t\tbankItemsMax = 48;\n\t\tshowQuestionMenu = false;\n\t\tmagicLoc = 128;\n\t\tcameraAutoAngle = 1;\n\t\tanInt727 = 2;\n\t\tshowServerMessageBox = false;\n\t\thasReceivedWelcomeBoxDetails = false;\n\t\tplayerStatCurrent = new int[18];\n\t\twildYSubtract = -1;\n\t\tanInt742 = -1;\n\t\tanInt743 = -1;\n\t\tanInt744 = -1;\n\t\tsectionXArray = new int[8000];\n\t\tsectionYArray = new int[8000];\n\t\tselectedItem = -1;\n\t\tselectedItemName = \"\";\n\t\tduelOpponentItems = new int[8];\n\t\tduelOpponentItemsCount = new int[8];\n\t\tanIntArray757 = new int[50];\n\t\tmenuID = new int[250];\n\t\tshowCharacterLookScreen = false;\n\t\tshowDrawPointsScreen = false;\n\t\tlastPlayerArray = new Mob[500];\n\t\tappletMode = true;\n\t\tgameDataModels = new Model[1000];\n\t\tconfigMouseButtons = false;\n\t\tduelNoRetreating = false;\n\t\tduelNoMagic = false;\n\t\tduelNoPrayer = false;\n\t\tduelNoWeapons = false;\n\t\tanIntArray782 = new int[50];\n\t\tduelConfirmOpponentItems = new int[8];\n\t\tduelConfirmOpponentItemsCount = new int[8];\n\t\tanIntArray786 = new int[50];\n\t\tanIntArray787 = new int[50];\n\t\tanIntArray788 = new int[50];\n\t\tobjectModelArray = new Model[1500];\n\t\tcameraRotation = 128;\n\t\tshowWelcomeBox = false;\n\t\tcharacterBodyGender = 1;\n\t\tcharacter2Colour = 2;\n\t\tcharacterHairColour = 2;\n\t\tcharacterTopColour = 8;\n\t\tcharacterBottomColour = 14;\n\t\tcharacterHeadGender = 1;\n\t\tselectedBankItem = -1;\n\t\tselectedBankItemType = -2;\n\t\tmenuText2 = new String[250];\n\t\taBooleanArray827 = new boolean[1500];\n\t\tplayerStatBase = new int[18];\n\t\tmenuActionType = new int[250];\n\t\tmenuActionVariable = new int[250];\n\t\tmenuActionVariable2 = new int[250];\n\t\tshopItems = new int[256];\n\t\tshopItemCount = new int[256];\n\t\tshopItemsSellPrice = new int[256];\n\t\tshopItemsBuyPrice = new int[256];\n\t\tanIntArray858 = new int[50];\n\t\tanIntArray859 = new int[50];\n\t\tnewBankItems = new int[256];\n\t\tnewBankItemsCount = new int[256];\n\t\tduelConfirmMyItems = new int[8];\n\t\tduelConfirmMyItemsCount = new int[8];\n\t\tmobArrayIndexes = new int[500];\n\t\tmessagesTimeout = new int[5];\n\t\tobjectX = new int[1500];\n\t\tobjectY = new int[1500];\n\t\tobjectType = new int[1500];\n\t\tobjectID = new int[1500];\n\t\tmenuActionX = new int[250];\n\t\tmenuActionY = new int[250];\n\t\tourPlayer = new Mob();\n\t\tserverIndex = -1;\n\t\tanInt882 = 30;\n\t\tshowTradeConfirmWindow = false;\n\t\ttradeConfirmAccepted = false;\n\t\tplayerArray = new Mob[500];\n\t\tserverMessageBoxTop = false;\n\t\tcameraHeight = 750;\n\t\tbankItems = new int[256];\n\t\tbankItemsCount = new int[256];\n\t\tnotInWilderness = false;\n\t\tselectedSpell = -1;\n\t\tanInt911 = 2;\n\t\ttradeOtherItems = new int[14];\n\t\ttradeOtherItemsCount = new int[14];\n\t\tmenuIndexes = new int[250];\n\t\tzoomCamera = false;\n\t\tplayerStatExperience = new int[18];\n\t\tcameraAutoAngleDebug = false;\n\t\tnpcRecordArray = new Mob[8000];\n\t\tshowDuelWindow = false;\n\t\tanIntArray923 = new int[50];\n\t\tlastLoadedNull = false;\n\t\texperienceArray = new int[99];\n\t\tshowShop = false;\n\t\tmouseClickXArray = new int[8192];\n\t\tmouseClickYArray = new int[8192];\n\t\tshowDuelConfirmWindow = false;\n\t\tduelWeAccept = false;\n\t\tdoorX = new int[500];\n\t\tdoorY = new int[500];\n\t\tconfigSoundEffects = false;\n\t\tshowRightClickMenu = false;\n\t\tattackingInt40 = 40;\n\t\tanIntArray944 = new int[50];\n\t\tdoorDirection = new int[500];\n\t\tdoorType = new int[500];\n\t\tgroundItemX = new int[8000];\n\t\tgroundItemY = new int[8000];\n\t\tgroundItemType = new int[8000];\n\t\tgroundItemObjectVar = new int[8000];\n\t\tselectedShopItemIndex = -1;\n\t\tselectedShopItemType = -2;\n\t\tmessagesArray = new String[5];\n\t\tshowTradeWindow = false;\n\t\taBooleanArray970 = new boolean[500];\n\t\ttradeMyItems = new int[14];\n\t\ttradeMyItemsCount = new int[14];\n\t\tcameraSizeInt = 9;\n\t\ttradeOtherPlayerName = \"\";\n\t\tmc = this;\n\t}\n\tprivate boolean combatWindow;\n\tprivate int lastLoggedInDays;\n\tprivate int subscriptionLeftDays;\n\tprivate int duelMyItemCount;\n\tprivate int duelMyItems[];\n\tprivate int duelMyItemsCount[];\n\tprivate boolean configAutoCameraAngle;\n\tprivate String questionMenuAnswer[];\n\tprivate int anInt658;\n\tprivate Mob lastNpcArray[];\n\tprivate int loginButtonNewUser;\n\tprivate int loginButtonExistingUser;\n\tprivate String currentUser;\n\tprivate String currentPass;\n\tprivate int lastWalkTimeout;\n\tprivate String menuText1[];\n\tprivate boolean duelOpponentAccepted;\n\tprivate boolean duelMyAccepted;\n\tprivate int tradeConfirmItemCount;\n\tprivate int tradeConfirmItems[];\n\tprivate int tradeConfirmItemsCount[];\n\tprivate int tradeConfirmOtherItemCount;\n\tprivate int tradeConfirmOtherItems[];\n\tprivate int tradeConfirmOtherItemsCount[];\n\tstatic String serverMessage;\n\tprivate String duelOpponentName;\n\tprivate int mouseOverBankPageText;\n\tpublic int playerCount;\n\tprivate int lastPlayerCount;\n\tprivate int fightCount;\n\tprivate int inventoryCount;\n\tprivate int inventoryItems[];\n\tprivate int inventoryItemsCount[];\n\tprivate int wearing[];\n\tprivate int mobMessageCount;\n\tString mobMessages[];\n\tprivate boolean showBank;\n\tprivate Model doorModel[];\n\tprivate int mobMessagesX[];\n\tprivate int mobMessagesY[];\n\tprivate int mobMessagesWidth[];\n\tprivate int mobMessagesHeight[];\n\tpublic Mob npcArray[];\n\tprivate int equipmentStatus[];\n\tprivate final int characterTopBottomColours[] = { 0xff0000, 0xff8000,\n\t\t\t0xffe000, 0xa0e000, 57344, 32768, 41088, 45311, 33023, 12528,\n\t\t\t0xe000e0, 0x303030, 0x604000, 0x805000, 0xffffff };\n\tprivate int loginScreenNumber;\n\tprivate int anInt699;\n\tprivate boolean prayerOn[];\n\tprivate boolean tradeOtherAccepted;\n\tprivate boolean tradeWeAccepted;\n\tprivate Mob mobArray[];\n\tprivate int npcCombatModelArray1[] = { 0, 1, 2, 1, 0, 0, 0, 0 };\n\tprivate int anIntArray705[];\n\tprivate int anIntArray706[];\n\tpublic int npcCount;\n\tprivate int lastNpcCount;\n\tprivate int wildX;\n\tprivate int wildY;\n\tprivate int wildYMultiplier;\n\tprivate int lastWildYSubtract;\n\tprivate boolean memoryError;\n\tprivate int bankItemsMax;\n\tprivate int mouseOverMenu;\n\tprivate int walkModel[] = { 0, 1, 2, 1 };\n\tprivate boolean showQuestionMenu;\n\tprivate int anInt718;\n\tpublic int magicLoc;\n\tpublic int loggedIn;\n\tprivate int cameraAutoAngle;\n\tprivate int cameraRotationBaseAddition;\n\tprivate Menu spellMenu;\n\tint spellMenuHandle;\n\tint menuMagicPrayersSelected;\n\tprivate int screenRotationX;\n\tprivate int anInt727;\n\tprivate int showAbuseWindow;\n\tprivate int duelCantRetreat;\n\tprivate int duelUseMagic;\n\tprivate int duelUsePrayer;\n\tprivate int duelUseWeapons;\n\tstatic boolean showServerMessageBox;\n\tprivate boolean hasReceivedWelcomeBoxDetails;\n\tprivate String lastLoggedInAddress;\n\tprivate int loginTimer;\n\tprivate int playerStatCurrent[];\n\tprivate int areaX;\n\tprivate int areaY;\n\tprivate int wildYSubtract;\n\tprivate int anInt742;\n\tprivate int anInt743;\n\tprivate int anInt744;\n\tpublic int sectionXArray[];\n\tpublic int sectionYArray[];\n\tprivate int selectedItem;\n\tString selectedItemName;\n\tprivate int menuX;\n\tprivate int menuY;\n\tprivate int menuWidth;\n\tprivate int menuHeight;\n\tprivate int menuLength;\n\tprivate int duelOpponentItemCount;\n\tprivate int duelOpponentItems[];\n\tprivate int duelOpponentItemsCount[];\n\tprivate int anIntArray757[];\n\tprivate int menuID[];\n\tprivate boolean showCharacterLookScreen;\n\tprivate boolean showDrawPointsScreen;\n\tprivate int newBankItemCount;\n\tprivate int npcCombatModelArray2[] = { 0, 0, 0, 0, 0, 1, 2, 1 };\n\tprivate Mob lastPlayerArray[];\n\tprivate int inputBoxType;\n\tprivate boolean appletMode;\n\tprivate int combatStyle;\n\tprivate Model gameDataModels[];\n\tprivate boolean configMouseButtons;\n\tprivate boolean duelNoRetreating;\n\tprivate boolean duelNoMagic;\n\tprivate boolean duelNoPrayer;\n\tprivate boolean duelNoWeapons;\n\tprivate int anIntArray782[];\n\tprivate int duelConfirmOpponentItemCount;\n\tprivate int duelConfirmOpponentItems[];\n\tprivate int duelConfirmOpponentItemsCount[];\n\tprivate int anIntArray786[];\n\tprivate int anIntArray787[];\n\tprivate int anIntArray788[];\n\tprivate int anInt789;\n\tprivate int anInt790;\n\tprivate int anInt791;\n\tprivate int anInt792;\n\tprivate Menu menuLogin;\n\tprivate final int characterHairColours[] = { 0xffc030, 0xffa040, 0x805030,\n\t\t\t0x604020, 0x303030, 0xff6020, 0xff4000, 0xffffff, 65280, 65535 };\n\tprivate Model objectModelArray[];\n\tprivate Menu menuWelcome;\n\tprivate int systemUpdate;\n\tprivate int cameraRotation;\n\tprivate int logoutTimeout;\n\tprivate Menu gameMenu;\n\tint messagesHandleType2;\n\tint chatHandle;\n\tint messagesHandleType5;\n\tint messagesHandleType6;\n\tint messagesTab;\n\tprivate boolean showWelcomeBox;\n\tprivate int characterHeadType;\n\tprivate int characterBodyGender;\n\tprivate int character2Colour;\n\tprivate int characterHairColour;\n\tprivate int characterTopColour;\n\tprivate int characterBottomColour;\n\tprivate int characterSkinColour;\n\tprivate int characterHeadGender;\n\tprivate int loginStatusText;\n\tprivate int loginUsernameTextBox;\n\tprivate int loginPasswordTextBox;\n\tprivate int loginOkButton;\n\tprivate int loginCancelButton;\n\tprivate int selectedBankItem;\n\tprivate int selectedBankItemType;\n\tprivate String menuText2[];\n\tint anInt826;\n\tprivate boolean aBooleanArray827[];\n\tprivate int playerStatBase[];\n\tprivate int abuseSelectedType;\n\tpublic int actionPictureType;\n\tint actionPictureX;\n\tint actionPictureY;\n\tprivate int menuActionType[];\n\tprivate int menuActionVariable[];\n\tprivate int menuActionVariable2[];\n\tprivate int shopItems[];\n\tprivate int shopItemCount[];\n\tprivate int shopItemsBuyPrice[];\n\tprivate int shopItemsSellPrice[];\n\tprivate byte[] x = new byte[] { 111, 114, 103, 46, 114, 115, 99, 97, 110,\n\t\t\t103, 101, 108, 46, 99, 108, 105, 101, 110, 116, 46, 109, 117, 100,\n\t\t\t99, 108, 105, 101, 110, 116, 46, 99, 104, 101, 99, 107, 77, 111,\n\t\t\t117, 115, 101, 83, 116, 97, 116, 117, 115, 40, 41 };\n\tprivate byte[] y = new byte[] { 111, 114, 103, 46, 114, 115, 99, 97, 110,\n\t\t\t103, 101, 108, 46, 99, 108, 105, 101, 110, 116, 46, 109, 117, 100,\n\t\t\t99, 108, 105, 101, 110, 116, 46, 100, 114, 97, 119, 82, 105, 103,\n\t\t\t104, 116, 67, 108, 105, 99, 107, 77, 101, 110, 117, 40, 41 };\n\tprivate int npcAnimationArray[][] = {\n\t\t\t{ 11, 2, 9, 7, 1, 6, 10, 0, 5, 8, 3, 4 },\n\t\t\t{ 11, 2, 9, 7, 1, 6, 10, 0, 5, 8, 3, 4 },\n\t\t\t{ 11, 3, 2, 9, 7, 1, 6, 10, 0, 5, 8, 4 },\n\t\t\t{ 3, 4, 2, 9, 7, 1, 6, 10, 8, 11, 0, 5 },\n\t\t\t{ 3, 4, 2, 9, 7, 1, 6, 10, 8, 11, 0, 5 },\n\t\t\t{ 4, 3, 2, 9, 7, 1, 6, 10, 8, 11, 0, 5 },\n\t\t\t{ 11, 4, 2, 9, 7, 1, 6, 10, 0, 5, 8, 3 },\n\t\t\t{ 11, 2, 9, 7, 1, 6, 10, 0, 5, 8, 4, 3 } };\n\tprivate int bankItemCount;\n\tprivate int strDownButton;\n\tprivate int atkDownButton;\n\tprivate int defDownButton;\n\tprivate int magDownButton;\n\tprivate int rangeDownButton;\n\tprivate int strUpButton;\n\tprivate int atkUpButton;\n\tprivate int defUpButton;\n\tprivate int magUpButton;\n\tprivate int rangeUpButton;\n\tprivate int dPSAcceptButton;\n\tpublic static final int[] pkexperienceArray = { 83, 174, 276, 388, 512,\n\t\t\t650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,\n\t\t\t3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,\n\t\t\t12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,\n\t\t\t30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983,\n\t\t\t75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872,\n\t\t\t166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804,\n\t\t\t368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627,\n\t\t\t814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581,\n\t\t\t1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373,\n\t\t\t3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831,\n\t\t\t6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606,\n\t\t\t13034431, 14391160 };\n\tprivate int pkmagic, pkrange, pkatk, pkdef, pkstr = 1;\n\tprivate long pkpoints = 0;\n\tprivate int pkmagictext, pkcombattext, pkpointstext, pkrangetext,\n\t\t\tpkatktext, pkdeftext, pkstrtext = 0;\n\tprivate boolean pkreset = true;\n\tprivate int characterDesignHeadButton1;\n\tprivate int characterDesignHeadButton2;\n\tprivate int characterDesignHairColourButton1;\n\tprivate int characterDesignHairColourButton2;\n\tprivate int characterDesignGenderButton1;\n\tprivate int characterDesignGenderButton2;\n\tprivate int characterDesignTopColourButton1;\n\tprivate int characterDesignTopColourButton2;\n\tprivate int characterDesignSkinColourButton1;\n\tprivate int characterDesignSkinColourButton2;\n\tprivate int characterDesignBottomColourButton1;\n\tprivate int characterDesignBottomColourButton2;\n\tprivate int characterDesignAcceptButton;\n\tprivate int anIntArray858[];\n\tprivate int anIntArray859[];\n\tprivate int newBankItems[];\n\tprivate int newBankItemsCount[];\n\tprivate int duelConfirmMyItemCount;\n\tprivate int duelConfirmMyItems[];\n\tprivate int duelConfirmMyItemsCount[];\n\tprivate int mobArrayIndexes[];\n\tprivate Menu menuNewUser;\n\tprivate int messagesTimeout[];\n\tprivate int lastAutoCameraRotatePlayerX;\n\tprivate int lastAutoCameraRotatePlayerY;\n\tprivate int questionMenuCount;\n\tpublic int objectX[];\n\tpublic int objectY[];\n\tpublic int objectType[];\n\tprivate int objectID[];\n\tprivate int menuActionX[];\n\tprivate int menuActionY[];\n\tpublic Mob ourPlayer;\n\tprivate int sectionX;\n\tprivate int sectionY;\n\tint serverIndex;\n\tprivate int anInt882;\n\tprivate int mouseDownTime;\n\tprivate int itemIncrement;\n\tpublic int groundItemCount;\n\tprivate int modelFireLightningSpellNumber;\n\tprivate int modelTorchNumber;\n\tprivate int modelClawSpellNumber;\n\tprivate boolean showTradeConfirmWindow;\n\tprivate boolean tradeConfirmAccepted;\n\tprivate int anInt892;\n\tpublic EngineHandle engineHandle;\n\tpublic Mob playerArray[];\n\tprivate boolean serverMessageBoxTop;\n\tprivate final String equipmentStatusName[] = { \"Armour\", \"WeaponAim\",\n\t\t\t\"WeaponPower\", \"Magic\", \"Prayer\", \"Range\" };\n\tpublic int flagged = 0;\n\tprivate int referId;\n\tprivate int anInt900;\n\tprivate int newUserOkButton;\n\tprivate int mouseButtonClick;\n\tprivate int cameraHeight;\n\tprivate int bankItems[];\n\tprivate int bankItemsCount[];\n\tprivate boolean notInWilderness;\n\tprivate int selectedSpell;\n\tprivate int screenRotationY;\n\tprivate int anInt911;\n\tprivate int tradeOtherItemCount;\n\tprivate int tradeOtherItems[];\n\tprivate int tradeOtherItemsCount[];\n\tprivate int menuIndexes[];\n\tprivate boolean zoomCamera;\n\tprivate AudioReader audioReader;\n\tprivate int playerStatExperience[];\n\tprivate boolean cameraAutoAngleDebug;\n\tprivate Mob npcRecordArray[];\n\tprivate final String skillArray[] = { \"Attack\", \"Defense\", \"Strength\",\n\t\t\t\"Hits\", \"Ranged\", \"Prayer\", \"Magic\", \"Cooking\", \"Woodcut\",\n\t\t\t\"Fletching\", \"Fishing\", \"Firemaking\", \"Crafting\", \"Smithing\",\n\t\t\t\"Mining\", \"Herblaw\", \"Agility\", \"Thieving\" };\n\tprivate boolean showDuelWindow;\n\tprivate int anIntArray923[];\n\tpublic GameImageMiddleMan gameGraphics;\n\tprivate final String skillArrayLong[] = { \"Attack\", \"Defense\", \"Strength\",\n\t\t\t\"Hitpoints\", \"Ranged\", \"Prayer\", \"Magic\", \"Cooking\", \"Woodcutting\",\n\t\t\t\"Fletching\", \"Fishing\", \"Firemaking\", \"Crafting\", \"Smithing\",\n\t\t\t\"Mining\", \"Herblaw\", \"Agility\", \"Thieving\" };\n\tprivate boolean lastLoadedNull;\n\tprivate int experienceArray[];\n\tprivate Camera gameCamera;\n\tprivate boolean showShop;\n\tprivate int mouseClickArrayOffset;\n\tint mouseClickXArray[];\n\tint mouseClickYArray[];\n\tprivate boolean showDuelConfirmWindow;\n\tprivate boolean duelWeAccept;\n\tprivate Graphics aGraphics936;\n\tprivate int doorX[];\n\tprivate int doorY[];\n\tprivate int wildernessType;\n\tprivate boolean configSoundEffects;\n\tprivate boolean showRightClickMenu;\n\tprivate int screenRotationTimer;\n\tprivate int attackingInt40;\n\tprivate int anIntArray944[];\n\tprivate Menu characterDesignMenu;\n\tprivate Menu drawPointsScreen;\n\tprivate int shopItemSellPriceModifier;\n\tprivate int shopItemBuyPriceModifier;\n\tprivate int modelUpdatingTimer;\n\tprivate int doorCount;\n\tprivate int doorDirection[];\n\tprivate int doorType[];\n\tprivate int anInt952;\n\tprivate int anInt953;\n\tprivate int anInt954;\n\tprivate int anInt955;\n\tpublic int groundItemX[];\n\tpublic int groundItemY[];\n\tpublic int groundItemType[];\n\tprivate int groundItemObjectVar[];\n\tprivate int selectedShopItemIndex;\n\tprivate int selectedShopItemType;\n\tprivate String messagesArray[];\n\tprivate long tradeConfirmOtherNameLong;\n\tprivate boolean showTradeWindow;\n\tprivate int playerAliveTimeout;\n\tprivate final int characterSkinColours[] = { 0xecded0, 0xccb366, 0xb38c40,\n\t\t\t0x997326, 0x906020 };\n\tprivate byte sounds[];\n\tprivate boolean aBooleanArray970[];\n\tpublic int objectCount;\n\tprivate int tradeMyItemCount;\n\tprivate int tradeMyItems[];\n\tprivate int tradeMyItemsCount[];\n\tpublic int windowWidth = 512;\n\tpublic int windowHeight = 334;\n\tpublic int screenDepth;\n\tpublic int screenRefreshRate;\n\tint defaultWidth = 512;\n\tint defaultHeight = 334;\n\tpublic int xAddition;\n\tpublic int yAddition;\n\tprivate int cameraSizeInt;\n\tprivate Menu friendsMenu;\n\tint friendsMenuHandle;\n\tint anInt981;\n\tlong privateMessageTarget;\n\tprivate long duelOpponentNameLong;\n\tprivate String tradeOtherPlayerName;\n\tprivate int anInt985;\n\tprivate int anInt986;\n\tprivate boolean aBoolean767;\n\tpublic final static void drawDownloadProgress(String s, int progress,\n\t\t\tboolean download) {\n\t\ttry {\n\t\t\tint j = (appletWidth - 281) / 2;\n\t\t\tint k = (appletHeight - 148) / 2;\n\t\t\tj += 2 + 4;\n\t\t\tk += 122;\n\t\t\tint l = (281 * progress) / 100;\n\t\t\tgetLoadingGraphics().setColor(BAR_COLOUR);\n\t\t\tgetLoadingGraphics().fillRect(j, k, l, 20);\n\t\t\tgetLoadingGraphics().setColor(Color.black);\n\t\t\tgetLoadingGraphics().fillRect(j + l, k, 281 - l, 20);\n\t\t\tgetLoadingGraphics().setColor(Color.WHITE);\n\t\t\tgetLoadingGraphics().drawString(\n\t\t\t\t\t(download ? \"Downloading: \" : \"\") + s + \" \" + progress\n\t\t\t\t\t\t\t+ \"%\", j + (download ? 54 : 54), k + 14);\n\t\t} catch (Exception _ex) {\n\t\t}\n\t}\n\tpublic static File getFile(String filename) {\n\t\tFile file = new File(Config.CONF_DIR + File.separator + filename);\n\t\tif (file.isFile() && file.exists()) {\n\t\t\treturn file;\n\t\t} else\n\t\t\treturn null;\n\t}\n\tpublic void setSectionX(int sectionX) {\n\t\tthis.sectionX = sectionX;\n\t}\n\tpublic int getSectionX() {\n\t\treturn sectionX;\n\t}\n\tpublic void setSectionY(int sectionY) {\n\t\tthis.sectionY = sectionY;\n\t}\n\tpublic int getSectionY() {\n\t\treturn sectionY;\n\t}\n\tpublic void setAreaY(int areaY) {\n\t\tthis.areaY = areaY;\n\t}\n\tpublic int getAreaY() {\n\t\treturn areaY;\n\t}\n\tpublic void setAreaX(int areaX) {\n\t\tthis.areaX = areaX;\n\t}\n\tpublic int getAreaX() {\n\t\treturn areaX;\n\t}\n\tpublic static void drawPopup(String message) {\n\t\tserverMessage = message;\n\t\tshowServerMessageBox = true;\n\t}\n\tpublic void sendSmithingItem(int spriteID) {\n\t\tstreamClass.createPacket(201);\n\t\tstreamClass.add4ByteInt(spriteID);\n\t\tstreamClass.formatPacket();\n\t}\n\tpublic void sendSmithingClose() {\n\t\tstreamClass.createPacket(202);\n\t\tstreamClass.formatPacket();\n\t}\n\tpublic void setInventoryItems(int inventoryItems[]) {\n\t\tthis.inventoryItems = inventoryItems;\n\t}\n\tpublic int[] getInventoryItems() {\n\t\treturn inventoryItems;\n\t}\n}\n", "output": "\tprivate final void drawGame() throws Exception {\n\t\tcur_fps++;\n\t\tif (System.currentTimeMillis() - lastFps < 0) {\n\t\t\tlastFps = System.currentTimeMillis();\n\t\t}\n\t\tif (System.currentTimeMillis() - lastFps >= 1000) {\n\t\t\tfps = cur_fps;\n\t\t\tcur_fps = 0;\n\t\t\tlastFps = System.currentTimeMillis();\n\t\t}\n\t\tif (playerAliveTimeout != 0) {\n\t\t\tgameGraphics.fadePixels();\n\t\t\tgameGraphics.drawText(\"Oh dear! You are dead...\", windowWidth / 2,\n\t\t\t\t\twindowHeight / 2, 7, 0xff0000);\n\t\t\tdrawChatMessageTabs();\n\t\t\tdrawOurSpritesOnScreen();\n\t\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t\t\treturn;\n\t\t}\n\t\tif (sleeping) {\n\t\t\tboolean drawEquation = true;\n\t\t\tif (drawEquation && sleepEquation != null) {\n\t\t\t\tgameGraphics.drawImage(aGraphics936, 0, 0,\n\t\t\t\t\t\tfixSleeping(sleepEquation));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (showDrawPointsScreen) {\n\t\t\tshowDPS();\n\t\t\treturn;\n\t\t}\n\t\tif (showCharacterLookScreen) {\n\t\t\tmethod62();\n\t\t\treturn;\n\t\t}\n\t\tif (!engineHandle.playerIsAlive) {\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < 64; i++) {\n\t\t\tgameCamera\n\t\t\t\t\t.removeModel(engineHandle.aModelArrayArray598[lastWildYSubtract][i]);\n\t\t\tif (lastWildYSubtract == 0) {\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray580[1][i]);\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray598[1][i]);\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray580[2][i]);\n\t\t\t\tgameCamera.removeModel(engineHandle.aModelArrayArray598[2][i]);\n\t\t\t}\n\t\t\tzoomCamera = true;\n\t\t\tif (lastWildYSubtract == 0\n\t\t\t\t\t&& (engineHandle.walkableValue[ourPlayer.currentX / 128][ourPlayer.currentY / 128] & 0x80) == 0) {\n\t\t\t\tif (showRoof) {\n\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray598[lastWildYSubtract][i]);\n\t\t\t\t\tif (lastWildYSubtract == 0) {\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray580[1][i]);\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray598[1][i]);\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray580[2][i]);\n\t\t\t\t\t\tgameCamera\n\t\t\t\t\t\t\t\t.addModel(engineHandle.aModelArrayArray598[2][i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tzoomCamera = false;\n\t\t\t}\n\t\t}\n\t\tif (modelFireLightningSpellNumber != anInt742) {\n\t\t\tanInt742 = modelFireLightningSpellNumber;\n\t\t\tfor (int j = 0; j < objectCount; j++) {\n\t\t\t\tif (objectType[j] == 97)\n\t\t\t\t\tmethod98(j, \"firea\" + (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 274)\n\t\t\t\t\tmethod98(j, \"fireplacea\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 1031)\n\t\t\t\t\tmethod98(j, \"lightning\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 1036)\n\t\t\t\t\tmethod98(j, \"firespell\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t\tif (objectType[j] == 1147)\n\t\t\t\t\tmethod98(j, \"spellcharge\"\n\t\t\t\t\t\t\t+ (modelFireLightningSpellNumber + 1));\n\t\t\t}\n\t\t}\n\t\tif (modelTorchNumber != anInt743) {\n\t\t\tanInt743 = modelTorchNumber;\n\t\t\tfor (int k = 0; k < objectCount; k++) {\n\t\t\t\tif (objectType[k] == 51)\n\t\t\t\t\tmethod98(k, \"torcha\" + (modelTorchNumber + 1));\n\t\t\t\tif (objectType[k] == 143)\n\t\t\t\t\tmethod98(k, \"skulltorcha\" + (modelTorchNumber + 1));\n\t\t\t}\n\t\t}\n\t\tif (modelClawSpellNumber != anInt744) {\n\t\t\tanInt744 = modelClawSpellNumber;\n\t\t\tfor (int l = 0; l < objectCount; l++)\n\t\t\t\tif (objectType[l] == 1142)\n\t\t\t\t\tmethod98(l, \"clawspell\" + (modelClawSpellNumber + 1));\n\t\t}\n\t\tgameCamera.updateFightCount(fightCount);\n\t\tfightCount = 0;\n\t\tfor (int i1 = 0; i1 < playerCount; i1++) {\n\t\t\tMob mob = playerArray[i1];\n\t\t\tif (mob.colourBottomType != 255) {\n\t\t\t\tint k1 = mob.currentX;\n\t\t\t\tint i2 = mob.currentY;\n\t\t\t\tint k2 = -engineHandle.getAveragedElevation(k1, i2);\n\t\t\t\tint l3 = gameCamera.method268(5000 + i1, k1, k2, i2, 145, 220,\n\t\t\t\t\t\ti1 + 10000);\n\t\t\t\tfightCount++;\n\t\t\t\tif (mob == ourPlayer)\n\t\t\t\t\tgameCamera.setOurPlayer(l3);\n\t\t\t\tif (mob.currentSprite == 8)\n\t\t\t\t\tgameCamera.setCombat(l3, -30);\n\t\t\t\tif (mob.currentSprite == 9)\n\t\t\t\t\tgameCamera.setCombat(l3, 30);\n\t\t\t}\n\t\t}\n\t\tfor (int j1 = 0; j1 < playerCount; j1++) {\n\t\t\tMob player = playerArray[j1];\n\t\t\tif (player.anInt176 > 0) {\n\t\t\t\tMob npc = null;\n\t\t\t\tif (player.attackingNpcIndex != -1)\n\t\t\t\t\tnpc = npcRecordArray[player.attackingNpcIndex];\n\t\t\t\telse if (player.attackingMobIndex != -1)\n\t\t\t\t\tnpc = mobArray[player.attackingMobIndex];\n\t\t\t\tif (npc != null) {\n\t\t\t\t\tint px = player.currentX;\n\t\t\t\t\tint py = player.currentY;\n\t\t\t\t\tint pi = -engineHandle.getAveragedElevation(px, py) - 110;\n\t\t\t\t\tint nx = npc.currentX;\n\t\t\t\t\tint ny = npc.currentY;\n\t\t\t\t\tint ni = -engineHandle.getAveragedElevation(nx, ny)\n\t\t\t\t\t\t\t- EntityHandler.getNpcDef(npc.type).getCamera2()\n\t\t\t\t\t\t\t/ 2;\n\t\t\t\t\tint i10 = (px * player.anInt176 + nx\n\t\t\t\t\t\t\t* (attackingInt40 - player.anInt176))\n\t\t\t\t\t\t\t/ attackingInt40;\n\t\t\t\t\tint j10 = (pi * player.anInt176 + ni\n\t\t\t\t\t\t\t* (attackingInt40 - player.anInt176))\n\t\t\t\t\t\t\t/ attackingInt40;\n\t\t\t\t\tint k10 = (py * player.anInt176 + ny\n\t\t\t\t\t\t\t* (attackingInt40 - player.anInt176))\n\t\t\t\t\t\t\t/ attackingInt40;\n\t\t\t\t\tgameCamera.method268(SPRITE_PROJECTILE_START\n\t\t\t\t\t\t\t+ player.attackingCameraInt, i10, j10, k10, 32, 32,\n\t\t\t\t\t\t\t0);\n\t\t\t\t\tfightCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int l1 = 0; l1 < npcCount; l1++) {\n\t\t\tMob npc = npcArray[l1];\n\t\t\tint mobx = npc.currentX;\n\t\t\tint moby = npc.currentY;\n\t\t\tint i7 = -engineHandle.getAveragedElevation(mobx, moby);\n\t\t\tint i9 = gameCamera.method268(20000 + l1, mobx, i7, moby,\n\t\t\t\t\tEntityHandler.getNpcDef(npc.type).getCamera1(),\n\t\t\t\t\tEntityHandler.getNpcDef(npc.type).getCamera2(), l1 + 30000);\n\t\t\tfightCount++;\n\t\t\tif (npc.currentSprite == 8)\n\t\t\t\tgameCamera.setCombat(i9, -30);\n\t\t\tif (npc.currentSprite == 9)\n\t\t\t\tgameCamera.setCombat(i9, 30);\n\t\t}\n\t\tif (LOOT_ENABLED) {\n\t\t\tfor (int j2 = 0; j2 < groundItemCount; j2++) {\n\t\t\t\tint j3 = groundItemX[j2] * magicLoc + 64;\n\t\t\t\tint k4 = groundItemY[j2] * magicLoc + 64;\n\t\t\t\tgameCamera.method268(40000 + groundItemType[j2], j3,\n\t\t\t\t\t\t-engineHandle.getAveragedElevation(j3, k4)\n\t\t\t\t\t\t\t\t- groundItemObjectVar[j2], k4, 96, 64,\n\t\t\t\t\t\tj2 + 20000);\n\t\t\t\tfightCount++;\n\t\t\t}\n\t\t}\n\t\tfor (int k3 = 0; k3 < anInt892; k3++) {\n\t\t\tint l4 = anIntArray944[k3] * magicLoc + 64;\n\t\t\tint j7 = anIntArray757[k3] * magicLoc + 64;\n\t\t\tint j9 = anIntArray782[k3];\n\t\t\tif (j9 == 0) {\n\t\t\t\tgameCamera.method268(50000 + k3, l4,\n\t\t\t\t\t\t-engineHandle.getAveragedElevation(l4, j7), j7, 128,\n\t\t\t\t\t\t256, k3 + 50000);\n\t\t\t\tfightCount++;\n\t\t\t}\n\t\t\tif (j9 == 1) {\n\t\t\t\tgameCamera.method268(50000 + k3, l4,\n\t\t\t\t\t\t-engineHandle.getAveragedElevation(l4, j7), j7, 128,\n\t\t\t\t\t\t64, k3 + 50000);\n\t\t\t\tfightCount++;\n\t\t\t}\n\t\t}\n\t\tgameGraphics.f1Toggle = false;\n\t\tgameGraphics.method211();\n\t\tgameGraphics.f1Toggle = super.keyF1Toggle;\n\t\tif (lastWildYSubtract == 3) {\n\t\t\tint i5 = 40 + (int) (Math.random() * 3D);\n\t\t\tint k7 = 40 + (int) (Math.random() * 7D);\n\t\t\tgameCamera.method304(i5, k7, -50, -10, -50);\n\t\t}\n\t\tanInt699 = 0;\n\t\tmobMessageCount = 0;\n\t\tanInt718 = 0;\n\t\tif (cameraAutoAngleDebug) {\n\t\t\tif (configAutoCameraAngle && !zoomCamera) {\n\t\t\t\tint lastCameraAutoAngle = cameraAutoAngle;\n\t\t\t\tautoRotateCamera();\n\t\t\t\tif (cameraAutoAngle != lastCameraAutoAngle) {\n\t\t\t\t\tlastAutoCameraRotatePlayerX = ourPlayer.currentX;\n\t\t\t\t\tlastAutoCameraRotatePlayerY = ourPlayer.currentY;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (fog) {\n\t\t\t\tgameCamera.zoom1 = 3000 + fogVar;\n\t\t\t\tgameCamera.zoom2 = 3000 + fogVar;\n\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\tgameCamera.zoom4 = 2800 + fogVar;\n\t\t\t} else {\n\t\t\t\tgameCamera.zoom1 = 41000;\n\t\t\t\tgameCamera.zoom2 = 41000;\n\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\tgameCamera.zoom4 = 41000;\n\t\t\t}\n\t\t\tcameraRotation = cameraAutoAngle * 32;\n\t\t\tint k5 = lastAutoCameraRotatePlayerX + screenRotationX;\n\t\t\tint l7 = lastAutoCameraRotatePlayerY + screenRotationY;\n\t\t\tgameCamera.setCamera(k5,\n\t\t\t\t\t-engineHandle.getAveragedElevation(k5, l7), l7,\n\t\t\t\t\tcameraVertical, cameraRotation * 4, 0, 2000);\n\t\t} else {\n\t\t\tif (configAutoCameraAngle && !zoomCamera)\n\t\t\t\tautoRotateCamera();\n\t\t\tif (fog) {\n\t\t\t\tif (!super.keyF1Toggle) {\n\t\t\t\t\tgameCamera.zoom1 = 2400 + fogVar;\n\t\t\t\t\tgameCamera.zoom2 = 2400 + fogVar;\n\t\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\t\tgameCamera.zoom4 = 2300 + fogVar;\n\t\t\t\t} else {\n\t\t\t\t\tgameCamera.zoom1 = 2200;\n\t\t\t\t\tgameCamera.zoom2 = 2200;\n\t\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\t\tgameCamera.zoom4 = 2100;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgameCamera.zoom1 = 41000;\n\t\t\t\tgameCamera.zoom2 = 41000;\n\t\t\t\tgameCamera.zoom3 = 1;\n\t\t\t\tgameCamera.zoom4 = 41000;\n\t\t\t}\n\t\t\tint l5 = lastAutoCameraRotatePlayerX + screenRotationX;\n\t\t\tint i8 = lastAutoCameraRotatePlayerY + screenRotationY;\n\t\t\tgameCamera.setCamera(l5,\n\t\t\t\t\t-engineHandle.getAveragedElevation(l5, i8), i8,\n\t\t\t\t\tcameraVertical, cameraRotation * 4, 0, cameraHeight * 2);\n\t\t}\n\t\tgameCamera.finishCamera();\n\t\tmethod119();\n\t\tif (actionPictureType > 0)\n\t\t\tgameGraphics.drawPicture(actionPictureX - 8, actionPictureY - 8,\n\t\t\t\t\tSPRITE_MEDIA_START + 14 + (24 - actionPictureType) / 6);\n\t\tif (actionPictureType < 0)\n\t\t\tgameGraphics.drawPicture(actionPictureX - 8, actionPictureY - 8,\n\t\t\t\t\tSPRITE_MEDIA_START + 18 + (24 + actionPictureType) / 6);\n\t\ttry {\n\t\t\tMessageQueue.getQueue().checkProcessMessages();\n\t\t\tint height = 55;\n\t\t\tif (MessageQueue.getQueue().hasMessages()) {\n\t\t\t\tfor (Message m : MessageQueue.getQueue().getList()) {\n\t\t\t\t\tif (m.isBIG)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tgameGraphics.drawString(m.message, 8, height, 1, 0xffff00);\n\t\t\t\t\theight += 12;\n\t\t\t\t}\n\t\t\t\tfor (Message m : MessageQueue.getQueue().getList()) {\n\t\t\t\t\tif (m.isBIG) {\n\t\t\t\t\t\tgameGraphics.drawString(m.message, 120, 100, 7,\n\t\t\t\t\t\t\t\t0xffff00);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tif (systemUpdate != 0) {\n\t\t\tint i6 = systemUpdate / 50;\n\t\t\tint j8 = i6 / 60;\n\t\t\ti6 %= 60;\n\t\t\tif (i6 < 10)\n\t\t\t\tgameGraphics.drawText(\"System update in: \" + j8 + \":0\" + i6,\n\t\t\t\t\t\t256 + xAddition, windowHeight - 7, 1, 0xffff00);\n\t\t\telse\n\t\t\t\tgameGraphics.drawText(\"System update in: \" + j8 + \":\" + i6,\n\t\t\t\t\t\t256 + xAddition, windowHeight - 7, 1, 0xffff00);\n\t\t}\n\t\tif (!notInWilderness) {\n\t\t\tint j6 = 2203 - (getSectionY() + wildY + getAreaY());\n\t\t\tif (getSectionX() + wildX + getAreaX() >= 2640)\n\t\t\t\tj6 = -50;\n\t\t\tif (j6 > 0) {\n\t\t\t\tint k8 = 1 + j6 / 6;\n\t\t\t\tgameGraphics.drawPicture(windowWidth - 50, windowHeight - 56,\n\t\t\t\t\t\tSPRITE_MEDIA_START + 13);\n\t\t\t\tint minx = 12;\n\t\t\t\tint maxx = 91;\n\t\t\t\tint miny = 4;\n\t\t\t\tint maxy = 33;\n\t\t\t\tint ourX = (getSectionX() + getAreaX());\n\t\t\t\tint ourY = (getSectionY() + getAreaY());\n\t\t\t\tif (ourX > minx && ourX < maxx && ourY > miny && ourY < maxy) {\n\t\t\t\t\tgameGraphics.drawText(\"@whi@CTF\", windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 20, 1, 0xffff00);\n\t\t\t\t\tgameGraphics.drawText(\"@red@Red: @whi@\"\n\t\t\t\t\t\t\t+ GameWindowMiddleMan.redPoints\n\t\t\t\t\t\t\t+ \" @blu@Blue: @whi@\"\n\t\t\t\t\t\t\t+ GameWindowMiddleMan.bluePoints, windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 7, 1, 0xffff00);\n\t\t\t\t} else {\n\t\t\t\t\tgameGraphics.drawText(\"Wilderness\", windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 20, 1, 0xffff00);\n\t\t\t\t\tgameGraphics.drawText(\"Level: \" + k8, windowWidth - 40,\n\t\t\t\t\t\t\twindowHeight - 7, 1, 0xffff00);\n\t\t\t\t}\n\t\t\t\tif (wildernessType == 0)\n\t\t\t\t\twildernessType = 2;\n\t\t\t}\n\t\t\tif (wildernessType == 0 && j6 > -10 && j6 <= 0)\n\t\t\t\twildernessType = 1;\n\t\t}\n\t\tif (messagesTab == 0) {\n\t\t\tfor (int k6 = 0; k6 < messagesArray.length; k6++)\n\t\t\t\tif (messagesTimeout[k6] > 0) {\n\t\t\t\t\tString s = messagesArray[k6];\n\t\t\t\t\tgameGraphics.drawString(s, 7, windowHeight - 18 - k6 * 12,\n\t\t\t\t\t\t\t1, 0xffff00);\n\t\t\t\t}\n\t\t}\n\t\tgameMenu.method171(messagesHandleType2);\n\t\tgameMenu.method171(messagesHandleType5);\n\t\tgameMenu.method171(messagesHandleType6);\n\t\tif (messagesTab == 1)\n\t\t\tgameMenu.method170(messagesHandleType2);\n\t\telse if (messagesTab == 2)\n\t\t\tgameMenu.method170(messagesHandleType5);\n\t\telse if (messagesTab == 3)\n\t\t\tgameMenu.method170(messagesHandleType6);\n\t\tMenu.anInt225 = 2;\n\t\tgameMenu.drawMenu();\n\t\tMenu.anInt225 = 0;\n\t\tgameGraphics.method232(\n\t\t\t\t((GameImage) (gameGraphics)).menuDefaultWidth - 3 - 197, 3,\n\t\t\t\tSPRITE_MEDIA_START, 128);\n\t\tdrawGameWindowsMenus();\n\t\tgameGraphics.drawStringShadows = false;\n\t\tdrawChatMessageTabs();\n\t\tdrawOurSpritesOnScreen();\n\t\tInterfaceHandler.tick();\n\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t}\n\tprivate void drawOurSpritesOnScreen() {\n\t\tif (mouseOverMenu != 7)\n\t\t\tgameGraphics.drawBoxAlpha(\n\t\t\t\t\t((GameImage) (gameGraphics)).menuDefaultWidth - 232, 3, 31,\n\t\t\t\t\t32, GameImage.convertRGBToLong(181, 181, 181), 128);\n\t\tgameGraphics.drawPicture(windowWidth - 240, 2, SPRITE_ITEM_START\n\t\t\t\t+ EntityHandler.getItemDef(167).getSprite());\n\t}\n\tprivate final void drawRightClickMenu() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tfor (int i = 0; i < menuLength; i++) {\n\t\t\t\tint k = menuX + 2;\n\t\t\t\tint i1 = menuY + 27 + i * 15;\n\t\t\t\tif (super.mouseX <= k - 2 || super.mouseY <= i1 - 12\n\t\t\t\t\t\t|| super.mouseY >= i1 + 4\n\t\t\t\t\t\t|| super.mouseX >= (k - 3) + menuWidth)\n\t\t\t\t\tcontinue;\n\t\t\t\tmenuClick(menuIndexes[i]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\tshowRightClickMenu = false;\n\t\t\treturn;\n\t\t}\n\t\tif (super.mouseX < menuX - 10 || super.mouseY < menuY - 10\n\t\t\t\t|| super.mouseX > menuX + menuWidth + 10\n\t\t\t\t|| super.mouseY > menuY + menuHeight + 10) {\n\t\t\tshowRightClickMenu = false;\n\t\t\treturn;\n\t\t}\n\t\tgameGraphics.drawBoxAlpha(menuX, menuY, menuWidth, menuHeight,\n\t\t\t\t0xd0d0d0, 160);\n\t\tgameGraphics.drawString(\"Choose option\", menuX + 2, menuY + 12, 1,\n\t\t\t\t65535);\n\t\tfor (int j = 0; j < menuLength; j++) {\n\t\t\tint l = menuX + 2;\n\t\t\tint j1 = menuY + 27 + j * 15;\n\t\t\tint k1 = 0xffffff;\n\t\t\tif (super.mouseX > l - 2 && super.mouseY > j1 - 12\n\t\t\t\t\t&& super.mouseY < j1 + 4\n\t\t\t\t\t&& super.mouseX < (l - 3) + menuWidth)\n\t\t\t\tk1 = 0xffff00;\n\t\t\tgameGraphics.drawString(menuText1[menuIndexes[j]] + \" \"\n\t\t\t\t\t+ menuText2[menuIndexes[j]], l, j1, 1, k1);\n\t\t}\n\t}\n\tprotected final void resetIntVars() {\n\t\tsystemUpdate = 0;\n\t\tloginScreenNumber = 0;\n\t\tloggedIn = 0;\n\t\tlogoutTimeout = 0;\n\t\tfor (int i = 0; i < questStage.length; i++)\n\t\t\tquestStage[i] = 0;\n\t\tquestPoints = 0;\n\t}\n\tprivate final void drawQuestionMenu() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tfor (int i = 0; i < questionMenuCount; i++) {\n\t\t\t\tif (super.mouseX >= gameGraphics.textWidth(\n\t\t\t\t\t\tquestionMenuAnswer[i], 1)\n\t\t\t\t\t\t|| super.mouseY <= i * 12\n\t\t\t\t\t\t|| super.mouseY >= 12 + i * 12)\n\t\t\t\t\tcontinue;\n\t\t\t\tsuper.streamClass.createPacket(154);\n\t\t\t\tsuper.streamClass.addByte(i);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\tshowQuestionMenu = false;\n\t\t\treturn;\n\t\t}\n\t\tfor (int j = 0; j < questionMenuCount; j++) {\n\t\t\tint k = 65535;\n\t\t\tif (super.mouseX < gameGraphics.textWidth(questionMenuAnswer[j], 1)\n\t\t\t\t\t&& super.mouseY > j * 12 && super.mouseY < 12 + j * 12)\n\t\t\t\tk = 0xff0000;\n\t\t\tgameGraphics\n\t\t\t\t\t.drawString(questionMenuAnswer[j], 6, 12 + j * 12, 1, k);\n\t\t}\n\t}\n\tprivate final void walkToAction(int actionX, int actionY, int actionType) {\n\t\tif (actionType == 0) {\n\t\t\tsendWalkCommand(getSectionX(), getSectionY(), actionX, actionY - 1,\n\t\t\t\t\tactionX, actionY, false, true);\n\t\t\treturn;\n\t\t}\n\t\tif (actionType == 1) {\n\t\t\tsendWalkCommand(getSectionX(), getSectionY(), actionX - 1, actionY,\n\t\t\t\t\tactionX, actionY, false, true);\n\t\t\treturn;\n\t\t} else {\n\t\t\tsendWalkCommand(getSectionX(), getSectionY(), actionX, actionY,\n\t\t\t\t\tactionX, actionY, true, true);\n\t\t\treturn;\n\t\t}\n\t}\n\tprivate final void garbageCollect() {\n\t\ttry {\n\t\t\tif (gameGraphics != null) {\n\t\t\t\tgameGraphics.cleanupSprites();\n\t\t\t\tgameGraphics.imagePixelArray = null;\n\t\t\t\tgameGraphics = null;\n\t\t\t}\n\t\t\tif (gameCamera != null) {\n\t\t\t\tgameCamera.cleanupModels();\n\t\t\t\tgameCamera = null;\n\t\t\t}\n\t\t\tgameDataModels = null;\n\t\t\tobjectModelArray = null;\n\t\t\tdoorModel = null;\n\t\t\tmobArray = null;\n\t\t\tplayerArray = null;\n\t\t\tnpcRecordArray = null;\n\t\t\tnpcArray = null;\n\t\t\tourPlayer = null;\n\t\t\tif (engineHandle != null) {\n\t\t\t\tengineHandle.aModelArray596 = null;\n\t\t\t\tengineHandle.aModelArrayArray580 = null;\n\t\t\t\tengineHandle.aModelArrayArray598 = null;\n\t\t\t\tengineHandle.aModel = null;\n\t\t\t\tengineHandle = null;\n\t\t\t}\n\t\t\tSystem.gc();\n\t\t\treturn;\n\t\t} catch (Exception _ex) {\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected final void loginScreenPrint(String s, String s1) {\n\t\tif (loginScreenNumber == 1)\n\t\t\tmenuNewUser.updateText(anInt900, s + \" \" + s1);\n\t\tif (loginScreenNumber == 2)\n\t\t\tmenuLogin.updateText(loginStatusText, s + \" \" + s1);\n\t\tdrawLoginScreen();\n\t\tresetCurrentTimeArray();\n\t}\n\tprivate final void drawInventoryRightClickMenu() {\n\t\tint i = 2203 - (getSectionY() + wildY + getAreaY());\n\t\tif (getSectionX() + wildX + getAreaX() >= 2640)\n\t\t\ti = -50;\n\t\tint j = -1;\n\t\tfor (int k = 0; k < objectCount; k++)\n\t\t\taBooleanArray827[k] = false;\n\t\tfor (int l = 0; l < doorCount; l++)\n\t\t\taBooleanArray970[l] = false;\n\t\tint i1 = gameCamera.method272();\n\t\tModel models[] = gameCamera.getVisibleModels();\n\t\tint ai[] = gameCamera.method273();\n\t\tfor (int j1 = 0; j1 < i1; j1++) {\n\t\t\tif (menuLength > 200)\n\t\t\t\tbreak;\n\t\t\tint k1 = ai[j1];\n\t\t\tModel model = models[j1];\n\t\t\tif (model.anIntArray258[k1] <= 65535\n\t\t\t\t\t|| model.anIntArray258[k1] >= 0x30d40\n\t\t\t\t\t&& model.anIntArray258[k1] <= 0x493e0)\n\t\t\t\tif (model == gameCamera.aModel_423) {\n\t\t\t\t\tint i2 = model.anIntArray258[k1] % 10000;\n\t\t\t\t\tint l2 = model.anIntArray258[k1] / 10000;\n\t\t\t\t\tif (l2 == 1) {\n\t\t\t\t\t\tString s = \"\";\n\t\t\t\t\t\tint k3 = 0;\n\t\t\t\t\t\tif (ourPlayer.level > 0 && playerArray[i2].level > 0)\n\t\t\t\t\t\t\tk3 = ourPlayer.level - playerArray[i2].level;\n\t\t\t\t\t\tif (k3 < 0)\n\t\t\t\t\t\t\ts = \"@or1@\";\n\t\t\t\t\t\tif (k3 < -3)\n\t\t\t\t\t\t\ts = \"@or2@\";\n\t\t\t\t\t\tif (k3 < -6)\n\t\t\t\t\t\t\ts = \"@or3@\";\n\t\t\t\t\t\tif (k3 < -9)\n\t\t\t\t\t\t\ts = \"@red@\";\n\t\t\t\t\t\tif (k3 > 0)\n\t\t\t\t\t\t\ts = \"@gr1@\";\n\t\t\t\t\t\tif (k3 > 3)\n\t\t\t\t\t\t\ts = \"@gr2@\";\n\t\t\t\t\t\tif (k3 > 6)\n\t\t\t\t\t\t\ts = \"@gr3@\";\n\t\t\t\t\t\tif (k3 > 9)\n\t\t\t\t\t\t\ts = \"@gre@\";\n\t\t\t\t\t\ts = \" \" + s + \"(level-\" + playerArray[i2].level + \")\";\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 1\n\t\t\t\t\t\t\t\t\t|| EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t\t\t.getSpellType() == 2) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@whi@\"\n\t\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 800;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@whi@\"\n\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\tmenuID[menuLength] = 810;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (i > 0\n\t\t\t\t\t\t\t\t\t&& (playerArray[i2].currentY - 64)\n\t\t\t\t\t\t\t\t\t\t\t/ magicLoc + wildY + getAreaY() < 2203) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Attack\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 3 ? \"#adm#\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\t\tif (k3 >= 0 && k3 < 5)\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 805;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 2805;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Duel with\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = playerArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = playerArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 2806;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Trade with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 3 ? \"#adm#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\tmenuID[menuLength] = 2810;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Follow\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = (playerArray[i2].admin == 1 ? \"#pmd#\"\n\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 2 ? \"#mod#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ (playerArray[i2].admin == 3 ? \"#adm#\"\n\t\t\t\t\t\t\t\t\t\t\t: \"\")\n\t\t\t\t\t\t\t\t\t+ \"@whi@\"\n\t\t\t\t\t\t\t\t\t+ playerArray[i2].name + s;\n\t\t\t\t\t\t\tmenuID[menuLength] = 2820;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = playerArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (l2 == 2) {\n\t\t\t\t\t\tItemDef itemDef = EntityHandler\n\t\t\t\t\t\t\t\t.getItemDef(groundItemType[i2]);\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 3) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\"\n\t\t\t\t\t\t\t\t\t\t+ itemDef.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 200;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = groundItemX[i2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = groundItemY[i2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\" + itemDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 210;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = groundItemX[i2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = groundItemY[i2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Take\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\" + itemDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 220;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = groundItemX[i2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = groundItemY[i2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@lre@\"\n\t\t\t\t\t\t\t\t\t+ itemDef.getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\"\n\t\t\t\t\t\t\t\t\t\t\t+ groundItemType[i2] + \":\"\n\t\t\t\t\t\t\t\t\t\t\t+ (groundItemX[i2] + getAreaX())\n\t\t\t\t\t\t\t\t\t\t\t+ \",\"\n\t\t\t\t\t\t\t\t\t\t\t+ (groundItemY[i2] + getAreaY())\n\t\t\t\t\t\t\t\t\t\t\t+ \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3200;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = groundItemType[i2];\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (l2 == 3) {\n\t\t\t\t\t\tString s1 = \"\";\n\t\t\t\t\t\tint l3 = -1;\n\t\t\t\t\t\tNPCDef npcDef = EntityHandler\n\t\t\t\t\t\t\t\t.getNpcDef(npcArray[i2].type);\n\t\t\t\t\t\tif (npcDef.isAttackable()) {\n\t\t\t\t\t\t\tint j4 = (npcDef.getAtt() + npcDef.getDef()\n\t\t\t\t\t\t\t\t\t+ npcDef.getStr() + npcDef.getHits()) / 4;\n\t\t\t\t\t\t\tint k4 = (playerStatBase[0] + playerStatBase[1]\n\t\t\t\t\t\t\t\t\t+ playerStatBase[2] + playerStatBase[3] + 27) / 4;\n\t\t\t\t\t\t\tl3 = k4 - j4;\n\t\t\t\t\t\t\ts1 = \"@yel@\";\n\t\t\t\t\t\t\tif (l3 < 0)\n\t\t\t\t\t\t\t\ts1 = \"@or1@\";\n\t\t\t\t\t\t\tif (l3 < -3)\n\t\t\t\t\t\t\t\ts1 = \"@or2@\";\n\t\t\t\t\t\t\tif (l3 < -6)\n\t\t\t\t\t\t\t\ts1 = \"@or3@\";\n\t\t\t\t\t\t\tif (l3 < -9)\n\t\t\t\t\t\t\t\ts1 = \"@red@\";\n\t\t\t\t\t\t\tif (l3 > 0)\n\t\t\t\t\t\t\t\ts1 = \"@gr1@\";\n\t\t\t\t\t\t\tif (l3 > 3)\n\t\t\t\t\t\t\t\ts1 = \"@gr2@\";\n\t\t\t\t\t\t\tif (l3 > 6)\n\t\t\t\t\t\t\t\ts1 = \"@gr3@\";\n\t\t\t\t\t\t\tif (l3 > 9)\n\t\t\t\t\t\t\t\ts1 = \"@gre@\";\n\t\t\t\t\t\t\ts1 = \" \" + s1 + \"(level-\" + j4 + \")\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 2) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ npcDef.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 700;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\" + npcDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 710;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (npcDef.isAttackable()) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Attack\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ npcDef.getName() + s1;\n\t\t\t\t\t\t\t\tif (l3 >= 0)\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 715;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tmenuID[menuLength] = 2715;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Talk-to\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\" + npcDef.getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 720;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\tif (!npcDef.getCommand().equals(\"\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = npcDef.getCommand();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ npcDef.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 725;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = npcArray[i2].currentX;\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = npcArray[i2].currentY;\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].serverIndex;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@yel@\"\n\t\t\t\t\t\t\t\t\t+ npcDef.getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\"\n\t\t\t\t\t\t\t\t\t\t\t+ npcArray[i2].type + \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3700;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = npcArray[i2].type;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (model != null && model.anInt257 >= 10000) {\n\t\t\t\t\tint j2 = model.anInt257 - 10000;\n\t\t\t\t\tint i3 = doorType[j2];\n\t\t\t\t\tif (!aBooleanArray970[j2]) {\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 4) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 300;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3).getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 310;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!EntityHandler.getDoorDef(i3).getCommand1()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"WalkTo\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getDoorDef(i3).getCommand1();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 320;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!EntityHandler.getDoorDef(i3).getCommand2()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"Examine\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getDoorDef(i3).getCommand2();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 2300;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = doorX[j2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = doorY[j2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = doorDirection[j2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getDoorDef(i3).getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\" + i3\n\t\t\t\t\t\t\t\t\t\t\t+ \":\" + (doorX[j2] + getAreaX())\n\t\t\t\t\t\t\t\t\t\t\t+ \",\" + (doorY[j2] + getAreaY())\n\t\t\t\t\t\t\t\t\t\t\t+ \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3300;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = i3;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taBooleanArray970[j2] = true;\n\t\t\t\t\t}\n\t\t\t\t} else if (model != null && model.anInt257 >= 0) {\n\t\t\t\t\tint k2 = model.anInt257;\n\t\t\t\t\tint j3 = objectType[k2];\n\t\t\t\t\tif (!aBooleanArray827[k2]) {\n\t\t\t\t\t\tif (selectedSpell >= 0) {\n\t\t\t\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getSpellType() == 5) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpell).getName()\n\t\t\t\t\t\t\t\t\t\t+ \" on\";\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 400;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable2[menuLength] = selectedSpell;\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (selectedItem >= 0) {\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Use \" + selectedItemName\n\t\t\t\t\t\t\t\t\t+ \" with\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3).getName();\n\t\t\t\t\t\t\tmenuID[menuLength] = 410;\n\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\tmenuActionVariable2[menuLength] = selectedItem;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (!EntityHandler.getObjectDef(j3).getCommand1()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"WalkTo\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getObjectDef(j3).getCommand1();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 420;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!EntityHandler.getObjectDef(j3).getCommand2()\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"Examine\")) {\n\t\t\t\t\t\t\t\tmenuText1[menuLength] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getObjectDef(j3).getCommand2();\n\t\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName();\n\t\t\t\t\t\t\t\tmenuID[menuLength] = 2400;\n\t\t\t\t\t\t\t\tmenuActionX[menuLength] = objectX[k2];\n\t\t\t\t\t\t\t\tmenuActionY[menuLength] = objectY[k2];\n\t\t\t\t\t\t\t\tmenuActionType[menuLength] = objectID[k2];\n\t\t\t\t\t\t\t\tmenuActionVariable[menuLength] = objectType[k2];\n\t\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmenuText1[menuLength] = \"Examine\";\n\t\t\t\t\t\t\tmenuText2[menuLength] = \"@cya@\"\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getObjectDef(j3).getName()\n\t\t\t\t\t\t\t\t\t+ (ourPlayer.admin >= 1 ? \" @or1@(\" + j3\n\t\t\t\t\t\t\t\t\t\t\t+ \":\" + (objectX[k2] + getAreaX())\n\t\t\t\t\t\t\t\t\t\t\t+ \",\" + (objectY[k2] + getAreaY())\n\t\t\t\t\t\t\t\t\t\t\t+ \")\" : \"\");\n\t\t\t\t\t\t\tmenuID[menuLength] = 3400;\n\t\t\t\t\t\t\tmenuActionType[menuLength] = j3;\n\t\t\t\t\t\t\tmenuLength++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\taBooleanArray827[k2] = true;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (k1 >= 0)\n\t\t\t\t\t\tk1 = model.anIntArray258[k1] - 0x30d40;\n\t\t\t\t\tif (k1 >= 0)\n\t\t\t\t\t\tj = k1;\n\t\t\t\t}\n\t\t}\n\t\tif (selectedSpell >= 0\n\t\t\t\t&& EntityHandler.getSpellDef(selectedSpell).getSpellType() <= 1) {\n\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t+ EntityHandler.getSpellDef(selectedSpell).getName()\n\t\t\t\t\t+ \" on self\";\n\t\t\tmenuText2[menuLength] = \"\";\n\t\t\tmenuID[menuLength] = 1000;\n\t\t\tmenuActionType[menuLength] = selectedSpell;\n\t\t\tmenuLength++;\n\t\t}\n\t\tif (j != -1) {\n\t\t\tint l1 = j;\n\t\t\tif (selectedSpell >= 0) {\n\t\t\t\tif (EntityHandler.getSpellDef(selectedSpell).getSpellType() == 6) {\n\t\t\t\t\tmenuText1[menuLength] = \"Cast \"\n\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(selectedSpell)\n\t\t\t\t\t\t\t\t\t.getName() + \" on ground\";\n\t\t\t\t\tmenuText2[menuLength] = \"\";\n\t\t\t\t\tmenuID[menuLength] = 900;\n\t\t\t\t\tmenuActionX[menuLength] = engineHandle.selectedX[l1];\n\t\t\t\t\tmenuActionY[menuLength] = engineHandle.selectedY[l1];\n\t\t\t\t\tmenuActionType[menuLength] = selectedSpell;\n\t\t\t\t\tmenuLength++;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (selectedItem < 0) {\n\t\t\t\tmenuText1[menuLength] = \"Walk here\";\n\t\t\t\tmenuText2[menuLength] = \"\";\n\t\t\t\tmenuID[menuLength] = 920;\n\t\t\t\tmenuActionX[menuLength] = engineHandle.selectedX[l1];\n\t\t\t\tmenuActionY[menuLength] = engineHandle.selectedY[l1];\n\t\t\t\tmenuLength++;\n\t\t\t}\n\t\t}\n\t}\n\tprotected final void startGame() {\n\t\tint i = 0;\n\t\tfor (int j = 0; j < 99; j++) {\n\t\t\tint k = j + 1;\n\t\t\tint i1 = (int) ((double) k + 300D * Math.pow(2D, (double) k / 7D));\n\t\t\ti += i1;\n\t\t\texperienceArray[j] = (i & 0xffffffc) / 4;\n\t\t}\n\t\tsuper.yOffset = 0;\n\t\tGameWindowMiddleMan.maxPacketReadCount = 500;\n\t\tif (appletMode) {\n\t\t\tCacheManager.load(\"Loading.rscd\");\n\t\t\tsetLogo(Toolkit.getDefaultToolkit().getImage(\n\t\t\t\t\tConfig.CONF_DIR + File.separator + \"Loading.rscd\"));\n\t\t}\n\t\tloadConfigFilter(); \n\t\tif (lastLoadedNull) {\n\t\t\treturn;\n\t\t}\n\t\taGraphics936 = getGraphics();\n\t\tchangeThreadSleepModifier(50);\n\t\tgameGraphics = new GameImageMiddleMan(windowWidth, windowHeight + 12,\n\t\t\t\t4000, this);\n\t\tgameGraphics._mudclient = this;\n\t\tGameFrame.setClient(mc);\n\t\tGameWindow.setClient(this);\n\t\tgameGraphics.setDimensions(0, 0, windowWidth, windowHeight + 12);\n\t\tMenu.aBoolean220 = false;\n\t\tspellMenu = new Menu(gameGraphics, 5);\n\t\tint l = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tbyte byte0 = 36;\n\t\tspellMenuHandle = spellMenu.method162(l, byte0 + 24, 196, 90, 1, 500,\n\t\t\t\ttrue);\n\t\tfriendsMenu = new Menu(gameGraphics, 5);\n\t\tfriendsMenuHandle = friendsMenu.method162(l, byte0 + 40, 196, 126, 1,\n\t\t\t\t500, true);\n\t\tquestMenu = new Menu(gameGraphics, 5);\n\t\tquestMenuHandle = questMenu.method162(l, byte0 + 40, 196, 235, 1, 500,\n\t\t\t\ttrue);\n\t\tloadMedia(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tloadEntity(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tgameCamera = new Camera(gameGraphics, 15000, 15000, 1000);\n\t\tgameCamera.setCameraSize(windowWidth / 2, windowHeight / 2,\n\t\t\t\twindowWidth / 2, windowHeight / 2, windowWidth, cameraSizeInt);\n\t\tif (fog) {\n\t\t\tgameCamera.zoom1 = 2400 + fogVar;\n\t\t\tgameCamera.zoom2 = 2400 + fogVar;\n\t\t\tgameCamera.zoom3 = 1;\n\t\t\tgameCamera.zoom4 = 2300 + fogVar;\n\t\t} else {\n\t\t\tgameCamera.zoom1 = 41000;\n\t\t\tgameCamera.zoom2 = 41000;\n\t\t\tgameCamera.zoom3 = 1;\n\t\t\tgameCamera.zoom4 = 41000;\n\t\t}\n\t\tgameCamera.method303(-50, -10, -50);\n\t\tengineHandle = new EngineHandle(gameCamera, gameGraphics);\n\t\tloadTextures(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tloadModels(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tloadSounds(); \n\t\tif (lastLoadedNull)\n\t\t\treturn;\n\t\tCacheManager.doneLoading();\n\t\tdrawDownloadProgress(\"Starting game...\", 100, false);\n\t\tdrawGameMenu();\n\t\tmakeLoginMenus();\n\t\tmakeCharacterDesignMenu();\n\t\tmakeDPSMenu();\n\t\tresetLoginVars();\n\t\tmenusLoaded = true;\n\t}\n\tprivate final void loadSprite(int id, String packageName, int amount) {\n\t\tfor (int i = id; i < id + amount; i++) {\n\t\t\tif (!gameGraphics.loadSprite(i, packageName)) {\n\t\t\t\tlastLoadedNull = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tprivate final void loadMedia() {\n\t\tdrawDownloadProgress(\"Unpacking media\", 30, false);\n\t\tloadSprite(SPRITE_MEDIA_START, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 1, \"media\", 6);\n\t\tloadSprite(SPRITE_MEDIA_START + 9, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 10, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 11, \"media\", 3);\n\t\tloadSprite(SPRITE_MEDIA_START + 14, \"media\", 8);\n\t\tloadSprite(SPRITE_MEDIA_START + 22, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 23, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 24, \"media\", 1);\n\t\tloadSprite(SPRITE_MEDIA_START + 25, \"media\", 2);\n\t\tloadSprite(SPRITE_UTIL_START, \"media\", 2);\n\t\tloadSprite(SPRITE_UTIL_START + 2, \"media\", 4);\n\t\tloadSprite(SPRITE_UTIL_START + 6, \"media\", 2);\n\t\tloadSprite(SPRITE_PROJECTILE_START, \"media\", 7);\n\t\tloadSprite(SPRITE_LOGO_START, \"media\", 1);\n\t\tint i = EntityHandler.invPictureCount();\n\t\tfor (int j = 1; i > 0; j++) {\n\t\t\tint k = i;\n\t\t\ti -= 30;\n\t\t\tif (k > 30) {\n\t\t\t\tk = 30;\n\t\t\t}\n\t\t\tloadSprite(SPRITE_ITEM_START + (j - 1) * 30, \"media.object\", k);\n\t\t}\n\t}\n\tprivate final void loadEntity() {\n\t\tdrawDownloadProgress(\"Unpacking entities\", 45, false);\n\t\tint animationNumber = 0;\n\t\tlabel0: for (int animationIndex = 0; animationIndex < EntityHandler\n\t\t\t\t.animationCount(); animationIndex++) {\n\t\t\tString s = EntityHandler.getAnimationDef(animationIndex).getName();\n\t\t\tfor (int nextAnimationIndex = 0; nextAnimationIndex < animationIndex; nextAnimationIndex++) {\n\t\t\t\tif (!EntityHandler.getAnimationDef(nextAnimationIndex)\n\t\t\t\t\t\t.getName().equalsIgnoreCase(s)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tEntityHandler.getAnimationDef(animationIndex).number = EntityHandler\n\t\t\t\t\t\t.getAnimationDef(nextAnimationIndex).getNumber();\n\t\t\t\tcontinue label0;\n\t\t\t}\n\t\t\tloadSprite(animationNumber, \"entity\", 15);\n\t\t\tif (EntityHandler.getAnimationDef(animationIndex).hasA()) {\n\t\t\t\tloadSprite(animationNumber + 15, \"entity\", 3);\n\t\t\t}\n\t\t\tif (EntityHandler.getAnimationDef(animationIndex).hasF()) {\n\t\t\t\tloadSprite(animationNumber + 18, \"entity\", 9);\n\t\t\t}\n\t\t\tEntityHandler.getAnimationDef(animationIndex).number = animationNumber;\n\t\t\tanimationNumber += 27;\n\t\t}\n\t}\n\tprivate final void loadTextures() {\n\t\tdrawDownloadProgress(\"Unpacking textures\", 60, false);\n\t\tgameCamera.method297(EntityHandler.textureCount(), 7, 11);\n\t\tfor (int i = 0; i < EntityHandler.textureCount(); i++) {\n\t\t\tloadSprite(SPRITE_TEXTURE_START + i, \"texture\", 1);\n\t\t\tSprite sprite = ((GameImage) (gameGraphics)).sprites[SPRITE_TEXTURE_START\n\t\t\t\t\t+ i];\n\t\t\tint length = sprite.getWidth() * sprite.getHeight();\n\t\t\tint[] pixels = sprite.getPixels();\n\t\t\tint ai1[] = new int[32768];\n\t\t\tfor (int k = 0; k < length; k++) {\n\t\t\t\tai1[((pixels[k] & 0xf80000) >> 9) + ((pixels[k] & 0xf800) >> 6)\n\t\t\t\t\t\t+ ((pixels[k] & 0xf8) >> 3)]++;\n\t\t\t}\n\t\t\tint[] dictionary = new int[256];\n\t\t\tdictionary[0] = 0xff00ff;\n\t\t\tint[] temp = new int[256];\n\t\t\tfor (int i1 = 0; i1 < ai1.length; i1++) {\n\t\t\t\tint j1 = ai1[i1];\n\t\t\t\tif (j1 > temp[255]) {\n\t\t\t\t\tfor (int k1 = 1; k1 < 256; k1++) {\n\t\t\t\t\t\tif (j1 <= temp[k1]) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int i2 = 255; i2 > k1; i2--) {\n\t\t\t\t\t\t\tdictionary[i2] = dictionary[i2 - 1];\n\t\t\t\t\t\t\ttemp[i2] = temp[i2 - 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdictionary[k1] = ((i1 & 0x7c00) << 9)\n\t\t\t\t\t\t\t\t+ ((i1 & 0x3e0) << 6) + ((i1 & 0x1f) << 3)\n\t\t\t\t\t\t\t\t+ 0x40404;\n\t\t\t\t\t\ttemp[k1] = j1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tai1[i1] = -1;\n\t\t\t}\n\t\t\tbyte[] indices = new byte[length];\n\t\t\tfor (int l1 = 0; l1 < length; l1++) {\n\t\t\t\tint j2 = pixels[l1];\n\t\t\t\tint k2 = ((j2 & 0xf80000) >> 9) + ((j2 & 0xf800) >> 6)\n\t\t\t\t\t\t+ ((j2 & 0xf8) >> 3);\n\t\t\t\tint l2 = ai1[k2];\n\t\t\t\tif (l2 == -1) {\n\t\t\t\t\tint i3 = 0x3b9ac9ff;\n\t\t\t\t\tint j3 = j2 >> 16 & 0xff;\n\t\t\t\t\tint k3 = j2 >> 8 & 0xff;\n\t\t\t\t\tint l3 = j2 & 0xff;\n\t\t\t\t\tfor (int i4 = 0; i4 < 256; i4++) {\n\t\t\t\t\t\tint j4 = dictionary[i4];\n\t\t\t\t\t\tint k4 = j4 >> 16 & 0xff;\n\t\t\t\t\t\tint l4 = j4 >> 8 & 0xff;\n\t\t\t\t\t\tint i5 = j4 & 0xff;\n\t\t\t\t\t\tint j5 = (j3 - k4) * (j3 - k4) + (k3 - l4) * (k3 - l4)\n\t\t\t\t\t\t\t\t+ (l3 - i5) * (l3 - i5);\n\t\t\t\t\t\tif (j5 < i3) {\n\t\t\t\t\t\t\ti3 = j5;\n\t\t\t\t\t\t\tl2 = i4;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tai1[k2] = l2;\n\t\t\t\t}\n\t\t\t\tindices[l1] = (byte) l2;\n\t\t\t}\n\t\t\tgameCamera.method298(i, indices, dictionary,\n\t\t\t\t\tsprite.getSomething1() / 64 - 1);\n\t\t}\n\t}\n\tprivate final void checkMouseStatus() {\n\t\tif (selectedSpell >= 0 || selectedItem >= 0) {\n\t\t\tmenuText1[menuLength] = \"Cancel\";\n\t\t\tmenuText2[menuLength] = \"\";\n\t\t\tmenuID[menuLength] = 4000;\n\t\t\tmenuLength++;\n\t\t}\n\t\tfor (int i = 0; i < menuLength; i++)\n\t\t\tmenuIndexes[i] = i;\n\t\tfor (boolean flag = false; !flag;) {\n\t\t\tflag = true;\n\t\t\tfor (int j = 0; j < menuLength - 1; j++) {\n\t\t\t\tint l = menuIndexes[j];\n\t\t\t\tint j1 = menuIndexes[j + 1];\n\t\t\t\tif (menuID[l] > menuID[j1]) {\n\t\t\t\t\tmenuIndexes[j] = j1;\n\t\t\t\t\tmenuIndexes[j + 1] = l;\n\t\t\t\t\tflag = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (menuLength > 20)\n\t\t\tmenuLength = 20;\n\t\tif (menuLength > 0) {\n\t\t\tint k = -1;\n\t\t\tfor (int i1 = 0; i1 < menuLength; i1++) {\n\t\t\t\tif (menuText2[menuIndexes[i1]] == null\n\t\t\t\t\t\t|| menuText2[menuIndexes[i1]].length() <= 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tk = i1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tString s = null;\n\t\t\tif ((selectedItem >= 0 || selectedSpell >= 0) && menuLength == 1)\n\t\t\t\ts = \"Choose a target\";\n\t\t\telse if ((selectedItem >= 0 || selectedSpell >= 0)\n\t\t\t\t\t&& menuLength > 1)\n\t\t\t\ts = \"@whi@\" + menuText1[menuIndexes[0]] + \" \"\n\t\t\t\t\t\t+ menuText2[menuIndexes[0]];\n\t\t\telse if (k != -1)\n\t\t\t\ts = menuText2[menuIndexes[k]] + \": @whi@\"\n\t\t\t\t\t\t+ menuText1[menuIndexes[0]];\n\t\t\tif (menuLength == 2 && s != null)\n\t\t\t\ts = s + \"@whi@ / 1 more option\";\n\t\t\tif (menuLength > 2 && s != null)\n\t\t\t\ts = s + \"@whi@ / \" + (menuLength - 1) + \" more options\";\n\t\t\tif (s != null)\n\t\t\t\tgameGraphics.drawString(s, 6, 14, 1, 0xffff00);\n\t\t\tif (!configMouseButtons && mouseButtonClick == 1\n\t\t\t\t\t|| configMouseButtons && mouseButtonClick == 1\n\t\t\t\t\t&& menuLength == 1) {\n\t\t\t\tmenuClick(menuIndexes[0]);\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!configMouseButtons && mouseButtonClick == 2\n\t\t\t\t\t|| configMouseButtons && mouseButtonClick == 1) {\n\t\t\t\tmenuHeight = (menuLength + 1) * 15;\n\t\t\t\tmenuWidth = gameGraphics.textWidth(\"Choose option\", 1) + 5;\n\t\t\t\tfor (int k1 = 0; k1 < menuLength; k1++) {\n\t\t\t\t\tint l1 = gameGraphics.textWidth(menuText1[k1] + \" \"\n\t\t\t\t\t\t\t+ menuText2[k1], 1) + 5;\n\t\t\t\t\tif (l1 > menuWidth)\n\t\t\t\t\t\tmenuWidth = l1;\n\t\t\t\t}\n\t\t\t\tmenuX = super.mouseX - menuWidth / 2;\n\t\t\t\tmenuY = super.mouseY - 7;\n\t\t\t\tshowRightClickMenu = true;\n\t\t\t\tif (menuX < 0)\n\t\t\t\t\tmenuX = 0;\n\t\t\t\tif (menuY < 0)\n\t\t\t\t\tmenuY = 0;\n\t\t\t\tif (menuX + menuWidth > (windowWidth - 10))\n\t\t\t\t\tmenuX = (windowWidth - 10) - menuWidth;\n\t\t\t\tif (menuY + menuHeight > (windowHeight))\n\t\t\t\t\tmenuY = (windowHeight - 10) - menuHeight;\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t}\n\t\t}\n\t}\n\tprotected final void cantLogout() {\n\t\tlogoutTimeout = 0;\n\t\tdisplayMessage(\"@cya@Sorry, you can't logout at the moment\", 3, 0);\n\t}\n\tprivate final void drawFriendsWindow(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tint j = 36;\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 5);\n\t\tchar c = '\\304';\n\t\tchar c1 = '\\266';\n\t\tint l;\n\t\tint k = l = GameImage.convertRGBToLong(160, 160, 160);\n\t\tif (anInt981 == 0)\n\t\t\tk = GameImage.convertRGBToLong(220, 220, 220);\n\t\telse\n\t\t\tl = GameImage.convertRGBToLong(220, 220, 220);\n\t\tint maxWidth = windowWidth - 23;\n\t\tint minWidth = windowWidth - 83;\n\t\tgameGraphics.drawBoxAlpha(i, j, c / 2, 24, k, 128);\n\t\tgameGraphics.drawBoxAlpha(i + c / 2, j, c / 2, 24, l, 128);\n\t\tgameGraphics.drawBoxAlpha(i, j + 24, c, c1 - 24,\n\t\t\t\tGameImage.convertRGBToLong(220, 220, 220), 128);\n\t\tgameGraphics.drawLineX(i, j + 24, c, 0);\n\t\tgameGraphics.drawLineY(i + c / 2, j, 24, 0);\n\t\tgameGraphics.drawLineX(i, (j + c1) - 16, c, 0);\n\t\tgameGraphics.drawText(\"Friends\", i + c / 4, j + 16, 4, 0);\n\t\tgameGraphics.drawText(\"Ignore\", i + c / 4 + c / 2, j + 16, 4, 0);\n\t\tfriendsMenu.resetListTextCount(friendsMenuHandle);\n\t\tif (anInt981 == 0) {\n\t\t\tfor (int i1 = 0; i1 < super.friendsCount; i1++) {\n\t\t\t\tString s;\n\t\t\t\tif (super.friendsListOnlineStatus[i1] == 99)\n\t\t\t\t\ts = \"@gre@\";\n\t\t\t\telse if (super.friendsListOnlineStatus[i1] > 0)\n\t\t\t\t\ts = \"@yel@\";\n\t\t\t\telse\n\t\t\t\t\ts = \"@red@\";\n\t\t\t\tfriendsMenu\n\t\t\t\t\t\t.drawMenuListText(\n\t\t\t\t\t\t\t\tfriendsMenuHandle,\n\t\t\t\t\t\t\t\ti1,\n\t\t\t\t\t\t\t\ts\n\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[i1])\n\t\t\t\t\t\t\t\t\t\t+ \"~\" + (windowWidth - 73) + \"~\"\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@Remove WWWWWWWWWW\");\n\t\t\t}\n\t\t}\n\t\tif (anInt981 == 1) {\n\t\t\tfor (int j1 = 0; j1 < super.ignoreListCount; j1++)\n\t\t\t\tfriendsMenu\n\t\t\t\t\t\t.drawMenuListText(\n\t\t\t\t\t\t\t\tfriendsMenuHandle,\n\t\t\t\t\t\t\t\tj1,\n\t\t\t\t\t\t\t\t\"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.ignoreListLongs[j1])\n\t\t\t\t\t\t\t\t\t\t+ \"~\" + (windowWidth - 73) + \"~\"\n\t\t\t\t\t\t\t\t\t\t+ \"@whi@Remove WWWWWWWWWW\");\n\t\t}\n\t\tfriendsMenu.drawMenu();\n\t\tif (anInt981 == 0) {\n\t\t\tint k1 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\tif (k1 >= 0 && super.mouseX < maxWidth) {\n\t\t\t\tif (super.mouseX > minWidth)\n\t\t\t\t\tgameGraphics\n\t\t\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\t\t\"Click to remove \"\n\t\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1]),\n\t\t\t\t\t\t\t\t\ti + c / 2, j + 35, 1, 0xffffff);\n\t\t\t\telse if (super.friendsListOnlineStatus[k1] == 99)\n\t\t\t\t\tgameGraphics\n\t\t\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\t\t\"Click to message \"\n\t\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1]),\n\t\t\t\t\t\t\t\t\ti + c / 2, j + 35, 1, 0xffffff);\n\t\t\t\telse if (super.friendsListOnlineStatus[k1] > 0)\n\t\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\tDataOperations\n\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1])\n\t\t\t\t\t\t\t\t\t+ \" is on world \"\n\t\t\t\t\t\t\t\t\t+ super.friendsListOnlineStatus[k1], i + c\n\t\t\t\t\t\t\t\t\t/ 2, j + 35, 1, 0xffffff);\n\t\t\t\telse\n\t\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\tDataOperations\n\t\t\t\t\t\t\t\t\t.longToString(super.friendsListLongs[k1])\n\t\t\t\t\t\t\t\t\t+ \" is offline\", i + c / 2, j + 35, 1,\n\t\t\t\t\t\t\t0xffffff);\n\t\t\t} else\n\t\t\t\tgameGraphics.drawText(\"Click a name to send a message\", i + c\n\t\t\t\t\t\t/ 2, j + 35, 1, 0xffffff);\n\t\t\tint k2;\n\t\t\tif (super.mouseX > i && super.mouseX < i + c\n\t\t\t\t\t&& super.mouseY > (j + c1) - 16 && super.mouseY < j + c1)\n\t\t\t\tk2 = 0xffff00;\n\t\t\telse\n\t\t\t\tk2 = 0xffffff;\n\t\t\tgameGraphics.drawText(\"Click here to add a friend\", i + c / 2,\n\t\t\t\t\t(j + c1) - 3, 1, k2);\n\t\t}\n\t\tif (anInt981 == 1) {\n\t\t\tint l1 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\tif (l1 >= 0 && super.mouseX < maxWidth && super.mouseX > minWidth) {\n\t\t\t\tif (super.mouseX > minWidth)\n\t\t\t\t\tgameGraphics\n\t\t\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\t\t\"Click to remove \"\n\t\t\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t\t\t.longToString(super.ignoreListLongs[l1]),\n\t\t\t\t\t\t\t\t\ti + c / 2, j + 35, 1, 0xffffff);\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawText(\"Blocking messages from:\", i + c / 2,\n\t\t\t\t\t\tj + 35, 1, 0xffffff);\n\t\t\t}\n\t\t\tint l2;\n\t\t\tif (super.mouseX > i && super.mouseX < i + c\n\t\t\t\t\t&& super.mouseY > (j + c1) - 16 && super.mouseY < j + c1)\n\t\t\t\tl2 = 0xffff00;\n\t\t\telse\n\t\t\t\tl2 = 0xffffff;\n\t\t\tgameGraphics.drawText(\"Click here to add a name\", i + c / 2,\n\t\t\t\t\t(j + c1) - 3, 1, l2);\n\t\t}\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 182) {\n\t\t\tfriendsMenu.updateActions(i\n\t\t\t\t\t+ (((GameImage) (gameGraphics)).menuDefaultWidth - 199),\n\t\t\t\t\tj + 36, super.lastMouseDownButton, super.mouseDownButton);\n\t\t\tif (j <= 24 && mouseButtonClick == 1)\n\t\t\t\tif (i < 98 && anInt981 == 1) {\n\t\t\t\t\tanInt981 = 0;\n\t\t\t\t\tfriendsMenu.method165(friendsMenuHandle, 0);\n\t\t\t\t} else if (i > 98 && anInt981 == 0) {\n\t\t\t\t\tanInt981 = 1;\n\t\t\t\t\tfriendsMenu.method165(friendsMenuHandle, 0);\n\t\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && anInt981 == 0) {\n\t\t\t\tint i2 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\t\tif (i2 >= 0 && super.mouseX < maxWidth)\n\t\t\t\t\tif (super.mouseX > minWidth)\n\t\t\t\t\t\tremoveFromFriends(super.friendsListLongs[i2]);\n\t\t\t\t\telse if (super.friendsListOnlineStatus[i2] != 0) {\n\t\t\t\t\t\tinputBoxType = 2;\n\t\t\t\t\t\tprivateMessageTarget = super.friendsListLongs[i2];\n\t\t\t\t\t\tsuper.inputMessage = \"\";\n\t\t\t\t\t\tsuper.enteredMessage = \"\";\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && anInt981 == 1) {\n\t\t\t\tint j2 = friendsMenu.selectedListIndex(friendsMenuHandle);\n\t\t\t\tif (j2 >= 0 && super.mouseX < maxWidth\n\t\t\t\t\t\t&& super.mouseX > minWidth)\n\t\t\t\t\tremoveFromIgnoreList(super.ignoreListLongs[j2]);\n\t\t\t}\n\t\t\tif (j > 166 && mouseButtonClick == 1 && anInt981 == 0) {\n\t\t\t\tinputBoxType = 1;\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t}\n\t\t\tif (j > 166 && mouseButtonClick == 1 && anInt981 == 1) {\n\t\t\t\tinputBoxType = 3;\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final boolean loadSection(int i, int j) {\n\t\tif (playerAliveTimeout != 0) {\n\t\t\tengineHandle.playerIsAlive = false;\n\t\t\treturn false;\n\t\t}\n\t\tnotInWilderness = false;\n\t\ti += wildX;\n\t\tj += wildY;\n\t\tif (lastWildYSubtract == wildYSubtract && i > anInt789 && i < anInt791\n\t\t\t\t&& j > anInt790 && j < anInt792) {\n\t\t\tengineHandle.playerIsAlive = true;\n\t\t\treturn false;\n\t\t}\n\t\tgameGraphics.drawText(\"Loading... Please wait\", 256 + xAddition,\n\t\t\t\t192 + yAddition, 1, 0xffffff);\n\t\tdrawChatMessageTabs();\n\t\tdrawOurSpritesOnScreen();\n\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t\tint k = getAreaX();\n\t\tint l = getAreaY();\n\t\tint i1 = (i + 24) / 48;\n\t\tint j1 = (j + 24) / 48;\n\t\tlastWildYSubtract = wildYSubtract;\n\t\tsetAreaX(i1 * 48 - 48);\n\t\tsetAreaY(j1 * 48 - 48);\n\t\tanInt789 = i1 * 48 - 32;\n\t\tanInt790 = j1 * 48 - 32;\n\t\tanInt791 = i1 * 48 + 32;\n\t\tanInt792 = j1 * 48 + 32;\n\t\tengineHandle.method401(i, j, lastWildYSubtract);\n\t\tsetAreaX(getAreaX() - wildX);\n\t\tsetAreaY(getAreaY() - wildY);\n\t\tint k1 = getAreaX() - k;\n\t\tint l1 = getAreaY() - l;\n\t\tfor (int i2 = 0; i2 < objectCount; i2++) {\n\t\t\tobjectX[i2] -= k1;\n\t\t\tobjectY[i2] -= l1;\n\t\t\tint j2 = objectX[i2];\n\t\t\tint l2 = objectY[i2];\n\t\t\tint k3 = objectType[i2];\n\t\t\tint m4 = objectID[i2];\n\t\t\tModel model = objectModelArray[i2];\n\t\t\ttry {\n\t\t\t\tint l4 = objectID[i2];\n\t\t\t\tint k5;\n\t\t\t\tint i6;\n\t\t\t\tif (l4 == 0 || l4 == 4) {\n\t\t\t\t\tk5 = EntityHandler.getObjectDef(k3).getWidth();\n\t\t\t\t\ti6 = EntityHandler.getObjectDef(k3).getHeight();\n\t\t\t\t} else {\n\t\t\t\t\ti6 = EntityHandler.getObjectDef(k3).getWidth();\n\t\t\t\t\tk5 = EntityHandler.getObjectDef(k3).getHeight();\n\t\t\t\t}\n\t\t\t\tint j6 = ((j2 + j2 + k5) * magicLoc) / 2;\n\t\t\t\tint k6 = ((l2 + l2 + i6) * magicLoc) / 2;\n\t\t\t\tif (j2 >= 0 && l2 >= 0 && j2 < 96 && l2 < 96) {\n\t\t\t\t\tgameCamera.addModel(model);\n\t\t\t\t\tmodel.method191(j6,\n\t\t\t\t\t\t\t-engineHandle.getAveragedElevation(j6, k6), k6);\n\t\t\t\t\tengineHandle.method412(j2, l2, k3, m4);\n\t\t\t\t\tif (k3 == 74)\n\t\t\t\t\t\tmodel.method190(0, -480, 0);\n\t\t\t\t}\n\t\t\t} catch (RuntimeException runtimeexception) {\n\t\t\t\tSystem.out.println(\"Loc Error: \"\n\t\t\t\t\t\t+ runtimeexception.getMessage());\n\t\t\t\tSystem.out.println(\"i:\" + i2 + \" obj:\" + model);\n\t\t\t\truntimeexception.printStackTrace();\n\t\t\t}\n\t\t}\n\t\tfor (int k2 = 0; k2 < doorCount; k2++) {\n\t\t\tdoorX[k2] -= k1;\n\t\t\tdoorY[k2] -= l1;\n\t\t\tint i3 = doorX[k2];\n\t\t\tint l3 = doorY[k2];\n\t\t\tint j4 = doorType[k2];\n\t\t\tint i5 = doorDirection[k2];\n\t\t\ttry {\n\t\t\t\tengineHandle.method408(i3, l3, i5, j4);\n\t\t\t\tModel model_1 = makeModel(i3, l3, i5, j4, k2);\n\t\t\t\tdoorModel[k2] = model_1;\n\t\t\t} catch (RuntimeException runtimeexception1) {\n\t\t\t\tSystem.out.println(\"Bound Error: \"\n\t\t\t\t\t\t+ runtimeexception1.getMessage());\n\t\t\t\truntimeexception1.printStackTrace();\n\t\t\t}\n\t\t}\n\t\tfor (int j3 = 0; j3 < groundItemCount; j3++) {\n\t\t\tgroundItemX[j3] -= k1;\n\t\t\tgroundItemY[j3] -= l1;\n\t\t}\n\t\tfor (int i4 = 0; i4 < playerCount; i4++) {\n\t\t\tMob mob = playerArray[i4];\n\t\t\tmob.currentX -= k1 * magicLoc;\n\t\t\tmob.currentY -= l1 * magicLoc;\n\t\t\tfor (int j5 = 0; j5 <= mob.waypointCurrent; j5++) {\n\t\t\t\tmob.waypointsX[j5] -= k1 * magicLoc;\n\t\t\t\tmob.waypointsY[j5] -= l1 * magicLoc;\n\t\t\t}\n\t\t}\n\t\tfor (int k4 = 0; k4 < npcCount; k4++) {\n\t\t\tMob mob_1 = npcArray[k4];\n\t\t\tmob_1.currentX -= k1 * magicLoc;\n\t\t\tmob_1.currentY -= l1 * magicLoc;\n\t\t\tfor (int l5 = 0; l5 <= mob_1.waypointCurrent; l5++) {\n\t\t\t\tmob_1.waypointsX[l5] -= k1 * magicLoc;\n\t\t\t\tmob_1.waypointsY[l5] -= l1 * magicLoc;\n\t\t\t}\n\t\t}\n\t\tengineHandle.playerIsAlive = true;\n\t\treturn true;\n\t}\n\tprivate final void drawMagicWindow(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tint j = 36;\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 4);\n\t\tchar c = '\\304';\n\t\tchar c1 = '\\266';\n\t\tint l;\n\t\tint k = l = GameImage.convertRGBToLong(160, 160, 160);\n\t\tif (menuMagicPrayersSelected == 0)\n\t\t\tk = GameImage.convertRGBToLong(220, 220, 220);\n\t\telse\n\t\t\tl = GameImage.convertRGBToLong(220, 220, 220);\n\t\tgameGraphics.drawBoxAlpha(i, j, c / 2, 24, k, 128);\n\t\tgameGraphics.drawBoxAlpha(i + c / 2, j, c / 2, 24, l, 128);\n\t\tgameGraphics.drawBoxAlpha(i, j + 24, c, 90,\n\t\t\t\tGameImage.convertRGBToLong(220, 220, 220), 128);\n\t\tgameGraphics.drawBoxAlpha(i, j + 24 + 90, c, c1 - 90 - 24,\n\t\t\t\tGameImage.convertRGBToLong(160, 160, 160), 128);\n\t\tgameGraphics.drawLineX(i, j + 24, c, 0);\n\t\tgameGraphics.drawLineY(i + c / 2, j, 24, 0);\n\t\tgameGraphics.drawLineX(i, j + 113, c, 0);\n\t\tgameGraphics.drawText(\"Magic\", i + c / 4, j + 16, 4, 0);\n\t\tgameGraphics.drawText(\"Prayers\", i + c / 4 + c / 2, j + 16, 4, 0);\n\t\tif (menuMagicPrayersSelected == 0) {\n\t\t\tspellMenu.resetListTextCount(spellMenuHandle);\n\t\t\tint i1 = 0;\n\t\t\tfor (int spellIndex = 0; spellIndex < EntityHandler.spellCount(); spellIndex++) {\n\t\t\t\tString s = \"@yel@\";\n\t\t\t\tfor (Entry e : EntityHandler.getSpellDef(spellIndex)\n\t\t\t\t\t\t.getRunesRequired()) {\n\t\t\t\t\tif (hasRequiredRunes((Integer) e.getKey(),\n\t\t\t\t\t\t\t(Integer) e.getValue())) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\ts = \"@whi@\";\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tint spellLevel = playerStatCurrent[6];\n\t\t\t\tif (EntityHandler.getSpellDef(spellIndex).getReqLevel() > spellLevel) {\n\t\t\t\t\ts = \"@bla@\";\n\t\t\t\t}\n\t\t\t\tspellMenu.drawMenuListText(spellMenuHandle, i1++, s + \"Level \"\n\t\t\t\t\t\t+ EntityHandler.getSpellDef(spellIndex).getReqLevel()\n\t\t\t\t\t\t+ \": \"\n\t\t\t\t\t\t+ EntityHandler.getSpellDef(spellIndex).getName());\n\t\t\t}\n\t\t\tspellMenu.drawMenu();\n\t\t\tint selectedSpellIndex = spellMenu\n\t\t\t\t\t.selectedListIndex(spellMenuHandle);\n\t\t\tif (selectedSpellIndex != -1) {\n\t\t\t\tgameGraphics\n\t\t\t\t\t\t.drawString(\n\t\t\t\t\t\t\t\t\"Level \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpellIndex)\n\t\t\t\t\t\t\t\t\t\t\t\t.getReqLevel()\n\t\t\t\t\t\t\t\t\t\t+ \": \"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getSpellDef(\n\t\t\t\t\t\t\t\t\t\t\t\tselectedSpellIndex).getName(),\n\t\t\t\t\t\t\t\ti + 2, j + 124, 1, 0xffff00);\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getSpellDef(selectedSpellIndex)\n\t\t\t\t\t\t\t\t.getDescription(), i + 2, j + 136, 0, 0xffffff);\n\t\t\t\tint i4 = 0;\n\t\t\t\tfor (Entry<Integer, Integer> e : EntityHandler.getSpellDef(\n\t\t\t\t\t\tselectedSpellIndex).getRunesRequired()) {\n\t\t\t\t\tint runeID = e.getKey();\n\t\t\t\t\tgameGraphics.drawPicture(i + 2 + i4 * 44, j + 150,\n\t\t\t\t\t\t\tSPRITE_ITEM_START\n\t\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(runeID)\n\t\t\t\t\t\t\t\t\t\t\t.getSprite());\n\t\t\t\t\tint runeInvCount = inventoryCount(runeID);\n\t\t\t\t\tint runeCount = e.getValue();\n\t\t\t\t\tString s2 = \"@red@\";\n\t\t\t\t\tif (hasRequiredRunes(runeID, runeCount)) {\n\t\t\t\t\t\ts2 = \"@gre@\";\n\t\t\t\t\t}\n\t\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\t\ts2 + runeInvCount + \"/\" + runeCount, i + 2 + i4\n\t\t\t\t\t\t\t\t\t* 44, j + 150, 1, 0xffffff);\n\t\t\t\t\ti4++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawString(\"Point at a spell for a description\",\n\t\t\t\t\t\ti + 2, j + 124, 1, 0);\n\t\t\t}\n\t\t}\n\t\tif (menuMagicPrayersSelected == 1) {\n\t\t\tspellMenu.resetListTextCount(spellMenuHandle);\n\t\t\tint j1 = 0;\n\t\t\tfor (int j2 = 0; j2 < EntityHandler.prayerCount(); j2++) {\n\t\t\t\tString s1 = \"@whi@\";\n\t\t\t\tif (EntityHandler.getPrayerDef(j2).getReqLevel() > playerStatBase[5])\n\t\t\t\t\ts1 = \"@bla@\";\n\t\t\t\tif (prayerOn[j2])\n\t\t\t\t\ts1 = \"@gre@\";\n\t\t\t\tspellMenu.drawMenuListText(spellMenuHandle, j1++, s1 + \"Level \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j2).getReqLevel() + \": \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j2).getName());\n\t\t\t}\n\t\t\tspellMenu.drawMenu();\n\t\t\tint j3 = spellMenu.selectedListIndex(spellMenuHandle);\n\t\t\tif (j3 != -1) {\n\t\t\t\tgameGraphics.drawText(\"Level \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j3).getReqLevel() + \": \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j3).getName(), i + c / 2,\n\t\t\t\t\t\tj + 130, 1, 0xffff00);\n\t\t\t\tif (j3 == 13) {\n\t\t\t\t\tif (playerStatBase[5] > 39) {\n\t\t\t\t\t\tint percent = (int) ((playerStatBase[5] - 40) * 0.6);\n\t\t\t\t\t\tpercent += 60;\n\t\t\t\t\t\tif (percent > 100)\n\t\t\t\t\t\t\tpercent = 100;\n\t\t\t\t\t\tgameGraphics.drawText(percent\n\t\t\t\t\t\t\t\t+ \"% protection from ranged attack\", i + c / 2,\n\t\t\t\t\t\t\t\tj + 145, 0, 0xffffff);\n\t\t\t\t\t} else\n\t\t\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\t\t\"60% protection from ranged attack\", i + c / 2,\n\t\t\t\t\t\t\t\tj + 145, 0, 0xffffff);\n\t\t\t\t} else\n\t\t\t\t\tgameGraphics.drawText(EntityHandler.getPrayerDef(j3)\n\t\t\t\t\t\t\t.getDescription(), i + c / 2, j + 145, 0, 0xffffff);\n\t\t\t\tgameGraphics.drawText(\"Drain rate: \"\n\t\t\t\t\t\t+ EntityHandler.getPrayerDef(j3).getDrainRate(), i + c\n\t\t\t\t\t\t/ 2, j + 160, 1, 0);\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawString(\"Point at a prayer for a description\",\n\t\t\t\t\t\ti + 2, j + 124, 1, 0);\n\t\t\t}\n\t\t}\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 182) {\n\t\t\tspellMenu.updateActions(i\n\t\t\t\t\t+ (((GameImage) (gameGraphics)).menuDefaultWidth - 199),\n\t\t\t\t\tj + 36, super.lastMouseDownButton, super.mouseDownButton);\n\t\t\tif (j <= 24 && mouseButtonClick == 1)\n\t\t\t\tif (i < 98 && menuMagicPrayersSelected == 1) {\n\t\t\t\t\tmenuMagicPrayersSelected = 0;\n\t\t\t\t\tprayerMenuIndex = spellMenu.getMenuIndex(spellMenuHandle);\n\t\t\t\t\tspellMenu.method165(spellMenuHandle, magicMenuIndex);\n\t\t\t\t} else if (i > 98 && menuMagicPrayersSelected == 0) {\n\t\t\t\t\tmenuMagicPrayersSelected = 1;\n\t\t\t\t\tmagicMenuIndex = spellMenu.getMenuIndex(spellMenuHandle);\n\t\t\t\t\tspellMenu.method165(spellMenuHandle, prayerMenuIndex);\n\t\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && menuMagicPrayersSelected == 0) {\n\t\t\t\tint k1 = spellMenu.selectedListIndex(spellMenuHandle);\n\t\t\t\tif (k1 != -1) {\n\t\t\t\t\tint k2 = playerStatCurrent[6];\n\t\t\t\t\tif (EntityHandler.getSpellDef(k1).getReqLevel() > k2) {\n\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\"Your magic ability is not high enough for this spell\",\n\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint k3 = 0;\n\t\t\t\t\t\tfor (Entry<Integer, Integer> e : EntityHandler\n\t\t\t\t\t\t\t\t.getSpellDef(k1).getRunesRequired()) {\n\t\t\t\t\t\t\tif (!hasRequiredRunes(e.getKey(), e.getValue())) {\n\t\t\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\t\t\"You don't have all the reagents you need for this spell\",\n\t\t\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\t\t\t\tk3 = -1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tk3++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (k3 == EntityHandler.getSpellDef(k1).getRuneCount()) {\n\t\t\t\t\t\t\tselectedSpell = k1;\n\t\t\t\t\t\t\tselectedItem = -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (mouseButtonClick == 1 && menuMagicPrayersSelected == 1) {\n\t\t\t\tint l1 = spellMenu.selectedListIndex(spellMenuHandle);\n\t\t\t\tif (l1 != -1) {\n\t\t\t\t\tint l2 = playerStatBase[5];\n\t\t\t\t\tif (EntityHandler.getPrayerDef(l1).getReqLevel() > l2)\n\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\"Your prayer ability is not high enough for this prayer\",\n\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\telse if (playerStatCurrent[5] == 0)\n\t\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\t\"You have run out of prayer points. Return to a church to recharge\",\n\t\t\t\t\t\t\t\t3, 0);\n\t\t\t\t\telse if (prayerOn[l1]) {\n\t\t\t\t\t\tsuper.streamClass.createPacket(248);\n\t\t\t\t\t\tsuper.streamClass.addByte(l1);\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\tprayerOn[l1] = false;\n\t\t\t\t\t\tplaySound(\"prayeroff\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsuper.streamClass.createPacket(56);\n\t\t\t\t\t\tsuper.streamClass.addByte(l1);\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\tprayerOn[l1] = true;\n\t\t\t\t\t\tplaySound(\"prayeron\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprotected final void handleWheelRotate(int units) {\n\t\tif (super.controlDown) {\n\t\t\tif (units > -1) {\n\t\t\t\tif (cameraVertical >= 1000)\n\t\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tif (cameraVertical <= 850)\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t\tcameraVertical += units * 2;\n\t\t}\n\t}\n\tprotected final void handleMenuKeyDown(int key, char keyChar) {\n\t\tif (!menusLoaded)\n\t\t\treturn;\n\t\tswitch (key) {\n\t\tcase 123: \n\t\t\ttakeScreenshot(true);\n\t\t\tbreak;\n\t\tcase 33: {\n\t\t\tif (cameraHeight < 300) {\n\t\t\t\tcameraHeight += 25;\n\t\t\t} else {\n\t\t\t\tcameraHeight -= 25;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 34: { \n\t\t\tif (cameraHeight > 1500) {\n\t\t\t\tcameraHeight -= 25;\n\t\t\t} else {\n\t\t\t\tcameraHeight += 25;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase 36: {\n\t\t\tcameraHeight = 750;\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t\tif (loggedIn == 0) {\n\t\t\tif (loginScreenNumber == 0)\n\t\t\t\tmenuWelcome.keyDown(key, keyChar);\n\t\t\tif (loginScreenNumber == 1)\n\t\t\t\tmenuNewUser.keyDown(key, keyChar);\n\t\t\tif (loginScreenNumber == 2)\n\t\t\t\tmenuLogin.keyDown(key, keyChar);\n\t\t}\n\t\tif (loggedIn == 1) {\n\t\t\tif (showCharacterLookScreen) {\n\t\t\t\tcharacterDesignMenu.keyDown(key, keyChar);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (showDrawPointsScreen) {\n\t\t\t\tdrawPointsScreen.keyDown(key, keyChar);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputBoxType == 0 && showAbuseWindow == 0)\n\t\t\t\tgameMenu.keyDown(key, keyChar);\n\t\t}\n\t}\n\tprivate final void drawShopBox() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tmouseButtonClick = 0;\n\t\t\tint i = super.mouseX - 52 - xAddition;\n\t\t\tint j = super.mouseY - 44 - yAddition;\n\t\t\tif (i >= 0 && j >= 12 && i < 408 && j < 246) {\n\t\t\t\tint k = 0;\n\t\t\t\tfor (int i1 = 0; i1 < 5; i1++) {\n\t\t\t\t\tfor (int i2 = 0; i2 < 8; i2++) {\n\t\t\t\t\t\tint l2 = 7 + i2 * 49;\n\t\t\t\t\t\tint l3 = 28 + i1 * 34;\n\t\t\t\t\t\tif (i > l2 && i < l2 + 49 && j > l3 && j < l3 + 34\n\t\t\t\t\t\t\t\t&& shopItems[k] != -1) {\n\t\t\t\t\t\t\tselectedShopItemIndex = k;\n\t\t\t\t\t\t\tselectedShopItemType = shopItems[k];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (selectedShopItemIndex >= 0) {\n\t\t\t\t\tint j2 = shopItems[selectedShopItemIndex];\n\t\t\t\t\tif (j2 != -1) {\n\t\t\t\t\t\tif (shopItemCount[selectedShopItemIndex] > 0 && i > 298\n\t\t\t\t\t\t\t\t&& j >= 204 && i < 408 && j <= 215) {\n\t\t\t\t\t\t\tint i4 = shopItemsBuyPrice[selectedShopItemIndex];\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(128);\n\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t.add2ByteInt(shopItems[selectedShopItemIndex]);\n\t\t\t\t\t\t\tsuper.streamClass.add4ByteInt(i4);\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (inventoryCount(j2) > 0 && i > 2 && j >= 229\n\t\t\t\t\t\t\t\t&& i < 112 && j <= 240) {\n\t\t\t\t\t\t\tint j4 = shopItemsSellPrice[selectedShopItemIndex];\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(255);\n\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t.add2ByteInt(shopItems[selectedShopItemIndex]);\n\t\t\t\t\t\t\tsuper.streamClass.add4ByteInt(j4);\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsuper.streamClass.createPacket(253);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tshowShop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tint byte0 = 52 + xAddition;\n\t\tint byte1 = 44 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 408, 12, 192);\n\t\tint l = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 12, 408, 17, l, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 29, 8, 170, l, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 399, byte1 + 29, 9, 170, l, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 199, 408, 47, l, 160);\n\t\tgameGraphics.drawString(\"Buying and selling items\", byte0 + 1,\n\t\t\t\tbyte1 + 10, 1, 0xffffff);\n\t\tint j1 = 0xffffff;\n\t\tif (super.mouseX > byte0 + 320 && super.mouseY >= byte1\n\t\t\t\t&& super.mouseX < byte0 + 408 && super.mouseY < byte1 + 12)\n\t\t\tj1 = 0xff0000;\n\t\tgameGraphics.drawBoxTextRight(\"Close window\", byte0 + 406, byte1 + 10,\n\t\t\t\t1, j1);\n\t\tgameGraphics.drawString(\"Shops stock in green\", byte0 + 2, byte1 + 24,\n\t\t\t\t1, 65280);\n\t\tgameGraphics.drawString(\"Number you own in blue\", byte0 + 135,\n\t\t\t\tbyte1 + 24, 1, 65535);\n\t\tgameGraphics.drawString(\"Your money: \" + inventoryCount(10) + \"gp\",\n\t\t\t\tbyte0 + 280, byte1 + 24, 1, 0xffff00);\n\t\tint k2 = 0xd0d0d0;\n\t\tint k3 = 0;\n\t\tfor (int k4 = 0; k4 < 5; k4++) {\n\t\t\tfor (int l4 = 0; l4 < 8; l4++) {\n\t\t\t\tint j5 = byte0 + 7 + l4 * 49;\n\t\t\t\tint i6 = byte1 + 28 + k4 * 34;\n\t\t\t\tif (selectedShopItemIndex == k3)\n\t\t\t\t\tgameGraphics.drawBoxAlpha(j5, i6, 49, 34, 0xff0000, 160);\n\t\t\t\telse\n\t\t\t\t\tgameGraphics.drawBoxAlpha(j5, i6, 49, 34, k2, 160);\n\t\t\t\tgameGraphics.drawBoxEdge(j5, i6, 50, 35, 0);\n\t\t\t\tif (shopItems[k3] != -1) {\n\t\t\t\t\tgameGraphics.spriteClip4(j5, i6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t\t\t+ EntityHandler.getItemDef(shopItems[k3])\n\t\t\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\t\t\tEntityHandler.getItemDef(shopItems[k3])\n\t\t\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\t\t\tgameGraphics.drawString(String.valueOf(shopItemCount[k3]),\n\t\t\t\t\t\t\tj5 + 1, i6 + 10, 1, 65280);\n\t\t\t\t\tgameGraphics.drawBoxTextRight(\n\t\t\t\t\t\t\tString.valueOf(inventoryCount(shopItems[k3])),\n\t\t\t\t\t\t\tj5 + 47, i6 + 10, 1, 65535);\n\t\t\t\t}\n\t\t\t\tk3++;\n\t\t\t}\n\t\t}\n\t\tgameGraphics.drawLineX(byte0 + 5, byte1 + 222, 398, 0);\n\t\tif (selectedShopItemIndex == -1) {\n\t\t\tgameGraphics.drawText(\"Select an object to buy or sell\",\n\t\t\t\t\tbyte0 + 204, byte1 + 214, 3, 0xffff00);\n\t\t\treturn;\n\t\t}\n\t\tint i5 = shopItems[selectedShopItemIndex];\n\t\tif (i5 != -1) {\n\t\t\tif (shopItemCount[selectedShopItemIndex] > 0) {\n\t\t\t\tint j6 = shopItemsBuyPrice[selectedShopItemIndex];\n\t\t\t\tgameGraphics.drawString(\"Buy a new \"\n\t\t\t\t\t\t+ EntityHandler.getItemDef(i5).getName() + \" for \" + j6\n\t\t\t\t\t\t+ \"gp\", byte0 + 2, byte1 + 214, 1, 0xffff00);\n\t\t\t\tint k1 = 0xffffff;\n\t\t\t\tif (super.mouseX > byte0 + 298 && super.mouseY >= byte1 + 204\n\t\t\t\t\t\t&& super.mouseX < byte0 + 408\n\t\t\t\t\t\t&& super.mouseY <= byte1 + 215)\n\t\t\t\t\tk1 = 0xff0000;\n\t\t\t\tgameGraphics.drawBoxTextRight(\"Click here to buy\", byte0 + 405,\n\t\t\t\t\t\tbyte1 + 214, 3, k1);\n\t\t\t} else {\n\t\t\t\tgameGraphics.drawText(\n\t\t\t\t\t\t\"This item is not currently available to buy\",\n\t\t\t\t\t\tbyte0 + 204, byte1 + 214, 3, 0xffff00);\n\t\t\t}\n\t\t\tif (inventoryCount(i5) > 0) {\n\t\t\t\tint k6 = shopItemsSellPrice[selectedShopItemIndex];\n\t\t\t\tgameGraphics.drawBoxTextRight(\"Sell your \"\n\t\t\t\t\t\t+ EntityHandler.getItemDef(i5).getName() + \" for \" + k6\n\t\t\t\t\t\t+ \"gp\", byte0 + 405, byte1 + 239, 1, 0xffff00);\n\t\t\t\tint l1 = 0xffffff;\n\t\t\t\tif (super.mouseX > byte0 + 2 && super.mouseY >= byte1 + 229\n\t\t\t\t\t\t&& super.mouseX < byte0 + 112\n\t\t\t\t\t\t&& super.mouseY <= byte1 + 240)\n\t\t\t\t\tl1 = 0xff0000;\n\t\t\t\tgameGraphics.drawString(\"Click here to sell\", byte0 + 2,\n\t\t\t\t\t\tbyte1 + 239, 3, l1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgameGraphics.drawText(\"You do not have any of this item to sell\",\n\t\t\t\t\tbyte0 + 204, byte1 + 239, 3, 0xffff00);\n\t\t}\n\t}\n\tprivate final void drawGameMenu() {\n\t\tgameMenu = new Menu(gameGraphics, 10);\n\t\tmessagesHandleType2 = gameMenu.method159(5, windowHeight - 85,\n\t\t\t\twindowWidth - 10, 56, 1, 20, true);\n\t\tchatHandle = gameMenu.method160(7, windowHeight - 10, windowWidth - 14,\n\t\t\t\t14, 1, 80, false, true);\n\t\tmessagesHandleType5 = gameMenu.method159(5, windowHeight - 65,\n\t\t\t\twindowWidth - 10, 56, 1, 20, true);\n\t\tmessagesHandleType6 = gameMenu.method159(5, windowHeight - 65,\n\t\t\t\twindowWidth - 10, 56, 1, 20, true);\n\t\tgameMenu.setFocus(chatHandle);\n\t}\n\tprotected final byte[] load(String filename) {\n\t\tCacheManager.load(filename);\n\t\treturn super.load(Config.CONF_DIR + File.separator + filename);\n\t}\n\tprivate final void drawOurOptionsMenu(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 232;\n\t\tint j = 36;\n\t\tint c = 360;\n\t\tgameGraphics.drawBoxAlpha(i, 36, c, 176,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBox(i, 3, 31, 32,\n\t\t\t\tGameImage.convertRGBToLong(0, 0, 131));\n\t\tint temp = 10;\n\t\tgameGraphics.drawBox(i, 26, 274, temp,\n\t\t\t\tGameImage.convertRGBToLong(0, 0, 131));\n\t\tgameGraphics.drawBox(i, 26 + temp, 274, 1,\n\t\t\t\tGameImage.convertRGBToLong(0, 0, 0));\n\t\tgameGraphics.drawString(\"screen size\", i + 147, 26 + temp, 4, 0xffffff);\n\t\tint k = i + 3;\n\t\tint i1 = j + 15;\n\t\ti1 += 15;\n\t\tif (Resolutions.fs)\n\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\" Fullscreen @gre@On\", k,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\" Fullscreen @red@Off\", k,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\" Screen size @gre@\"\n\t\t\t\t+ reso.getResolution(), k, i1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\" Refresh rate @gre@\"\n\t\t\t\t+ reso.getRefreshRate(), k, i1, 1, 0xffffff);\n\t\ti1 += 30;\n\t\tgameGraphics.drawString(\" Window size will change after you\", k,\n\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics\n\t\t\t\t.drawString(\" restart the client.\", k, i1, 1, 0xffffff);\n\t\ti1 += 30;\n\t\tgameGraphics.drawString(\" Going to fullsreen and back does\", k,\n\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\" not require a client restart.\", k, i1,\n\t\t\t\t1, 0xffffff);\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 265) {\n\t\t\tint l1 = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\t\tbyte byte0 = 36;\n\t\t\tchar c1 = '\\304';\n\t\t\tint l = l1 + 3;\n\t\t\tint j1 = byte0 + 30;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tif (gameFrame == null) {\n\t\t\t\t\tmudclient\n\t\t\t\t\t\t\t.drawPopup(\"You cannot switch to fullscreen from the webclient, sorry!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (Resolutions.fs) {\n\t\t\t\t\tgameFrame.makeRegularScreen();\n\t\t\t\t} else {\n\t\t\t\t\tgameFrame.makeFullScreen();\n\t\t\t\t}\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\treso.findNextResolution();\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"width\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getWidth());\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"height\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getHeight());\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"refreshRate\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getRefreshRate());\n\t\t\t\tConfig.storeConfig(\n\t\t\t\t\t\t\"bitDepth\",\n\t\t\t\t\t\t\"\"\n\t\t\t\t\t\t\t\t+ Display.displaymodes.get(\n\t\t\t\t\t\t\t\t\t\tResolutions.resolutionSetting)\n\t\t\t\t\t\t\t\t\t\t.getBitDepth());\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tboolean flag1 = false;\n\t\t\tj1 += 35;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tj1 += 20;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1)\n\t\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void drawOptionsMenu(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tint j = 36;\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 6);\n\t\tchar c = '\\304';\n\t\tgameGraphics.drawBoxAlpha(i, 36, c, 65,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBoxAlpha(i, 101, c, 65,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBoxAlpha(i, 166, c, 95,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tgameGraphics.drawBoxAlpha(i, 261, c, 52,\n\t\t\t\tGameImage.convertRGBToLong(181, 181, 181), 160);\n\t\tint k = i + 3;\n\t\tint i1 = j + 15;\n\t\tgameGraphics.drawString(\"Game options - click to toggle\", k, i1, 1, 0);\n\t\ti1 += 15;\n\t\tif (configAutoCameraAngle)\n\t\t\tgameGraphics.drawString(\"Camera angle mode - @gre@Auto\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Camera angle mode - @red@Manual\", k, i1,\n\t\t\t\t\t1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (configMouseButtons)\n\t\t\tgameGraphics.drawString(\"Mouse buttons - @red@One\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Mouse buttons - @gre@Two\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tif (configSoundEffects)\n\t\t\tgameGraphics.drawString(\"Sound effects - @red@off\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Sound effects - @gre@on\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tgameGraphics\n\t\t\t\t.drawString(\"Client assists - click to toggle\", k, i1, 1, 0);\n\t\ti1 += 15;\n\t\tif (showRoof)\n\t\t\tgameGraphics\n\t\t\t\t\t.drawString(\"Hide Roofs - @red@off\", k, i1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Hide Roofs - @gre@on\", k, i1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (autoScreenshot)\n\t\t\tgameGraphics.drawString(\"Auto Screenshots - @gre@on\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Auto Screenshots - @red@off\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tif (combatWindow)\n\t\t\tgameGraphics.drawString(\"Fightmode Selector - @gre@on\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Fightmode Selector - @red@off\", k, i1, 1,\n\t\t\t\t\t0xffffff);\n\t\ti1 += 15;\n\t\tif (fog)\n\t\t\tgameGraphics.drawString(\"Fog of War - @gre@on\", k, i1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics\n\t\t\t\t\t.drawString(\"Fog of War - @red@off\", k, i1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\ti1 += 5;\n\t\tgameGraphics.drawString(\"Privacy settings. Will be applied to\", i + 3,\n\t\t\t\ti1, 1, 0);\n\t\ti1 += 15;\n\t\tgameGraphics.drawString(\"all people not on your friends list\", i + 3,\n\t\t\t\ti1, 1, 0);\n\t\ti1 += 15;\n\t\tif (super.blockChatMessages == 0)\n\t\t\tgameGraphics.drawString(\"Block chat messages: @red@<off>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block chat messages: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (super.blockPrivateMessages == 0)\n\t\t\tgameGraphics.drawString(\"Block private messages: @red@<off>\",\n\t\t\t\t\ti + 3, i1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block private messages: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (super.blockTradeRequests == 0)\n\t\t\tgameGraphics.drawString(\"Block trade requests: @red@<off>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block trade requests: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\tif (super.blockDuelRequests == 0)\n\t\t\tgameGraphics.drawString(\"Block duel requests: @red@<off>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\telse\n\t\t\tgameGraphics.drawString(\"Block duel requests: @gre@<on>\", i + 3,\n\t\t\t\t\ti1, 1, 0xffffff);\n\t\ti1 += 15;\n\t\ti1 += 5;\n\t\tgameGraphics.drawString(\"Always logout when you finish\", k, i1, 1, 0);\n\t\ti1 += 15;\n\t\tint k1 = 0xffffff;\n\t\tif (super.mouseX > k && super.mouseX < k + c && super.mouseY > i1 - 12\n\t\t\t\t&& super.mouseY < i1 + 4)\n\t\t\tk1 = 0xffff00;\n\t\tgameGraphics.drawString(\"Click here to logout\", i + 3, i1, 1, k1);\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tj = super.mouseY - 36;\n\t\tif (i >= 0 && j >= 0 && i < 196 && j < 265) {\n\t\t\tint l1 = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\t\tbyte byte0 = 36;\n\t\t\tchar c1 = '\\304';\n\t\t\tint l = l1 + 3;\n\t\t\tint j1 = byte0 + 30;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tconfigAutoCameraAngle = !configAutoCameraAngle;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(0);\n\t\t\t\tsuper.streamClass.addByte(configAutoCameraAngle ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tconfigMouseButtons = !configMouseButtons;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(2);\n\t\t\t\tsuper.streamClass.addByte(configMouseButtons ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tconfigSoundEffects = !configSoundEffects;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(3);\n\t\t\t\tsuper.streamClass.addByte(configSoundEffects ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tshowRoof = !showRoof;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(4);\n\t\t\t\tsuper.streamClass.addByte(showRoof ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tautoScreenshot = !autoScreenshot;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(5);\n\t\t\t\tsuper.streamClass.addByte(autoScreenshot ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tcombatWindow = !combatWindow;\n\t\t\t\tsuper.streamClass.createPacket(157);\n\t\t\t\tsuper.streamClass.addByte(6);\n\t\t\t\tsuper.streamClass.addByte(combatWindow ? 1 : 0);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tfog = !fog;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tboolean flag1 = false;\n\t\t\tj1 += 35;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockChatMessages = 1 - super.blockChatMessages;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockPrivateMessages = 1 - super.blockPrivateMessages;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockTradeRequests = 1 - super.blockTradeRequests;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1) {\n\t\t\t\tsuper.blockDuelRequests = 1 - super.blockDuelRequests;\n\t\t\t\tflag1 = true;\n\t\t\t}\n\t\t\tj1 += 15;\n\t\t\tif (flag1)\n\t\t\t\tsendUpdatedPrivacyInfo(super.blockChatMessages,\n\t\t\t\t\t\tsuper.blockPrivateMessages, super.blockTradeRequests,\n\t\t\t\t\t\tsuper.blockDuelRequests);\n\t\t\tj1 += 20;\n\t\t\tif (super.mouseX > l && super.mouseX < l + c1\n\t\t\t\t\t&& super.mouseY > j1 - 12 && super.mouseY < j1 + 4\n\t\t\t\t\t&& mouseButtonClick == 1)\n\t\t\t\tlogout();\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void processGame() {\n\t\ttry {\n\t\t\tif (super.keyDownDown) {\n\t\t\t\tcurrentChat++;\n\t\t\t\tif (currentChat >= messages.size()) {\n\t\t\t\t\tcurrentChat = messages.size() - 1;\n\t\t\t\t\tsuper.keyDownDown = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgameMenu.updateText(chatHandle, messages.get(currentChat));\n\t\t\t\tsuper.keyDownDown = false;\n\t\t\t}\n\t\t\tif (super.keyUpDown) {\n\t\t\t\tcurrentChat--;\n\t\t\t\tif (currentChat < 0) {\n\t\t\t\t\tcurrentChat = 0;\n\t\t\t\t\tsuper.keyUpDown = false;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgameMenu.updateText(chatHandle, messages.get(currentChat));\n\t\t\t\tsuper.keyUpDown = false;\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tif (systemUpdate > 1) {\n\t\t\tsystemUpdate--;\n\t\t}\n\t\tsendPingPacketReadPacketData();\n\t\tif (logoutTimeout > 0) {\n\t\t\tlogoutTimeout--;\n\t\t}\n\t\tif (ourPlayer.currentSprite == 8 || ourPlayer.currentSprite == 9) {\n\t\t\tlastWalkTimeout = 500;\n\t\t}\n\t\tif (lastWalkTimeout > 0) {\n\t\t\tlastWalkTimeout--;\n\t\t}\n\t\tif (showCharacterLookScreen) {\n\t\t\tdrawCharacterLookScreen();\n\t\t\treturn;\n\t\t}\n\t\tif (showDrawPointsScreen) {\n\t\t\tdrawPointsScreen();\n\t\t\treturn;\n\t\t}\n\t\tfor (int i = 0; i < playerCount; i++) {\n\t\t\tMob mob = playerArray[i];\n\t\t\tint k = (mob.waypointCurrent + 1) % 10;\n\t\t\tif (mob.waypointEndSprite != k) {\n\t\t\t\tint i1 = -1;\n\t\t\t\tint l2 = mob.waypointEndSprite;\n\t\t\t\tint j4;\n\t\t\t\tif (l2 < k)\n\t\t\t\t\tj4 = k - l2;\n\t\t\t\telse\n\t\t\t\t\tj4 = (10 + k) - l2;\n\t\t\t\tint j5 = 4;\n\t\t\t\tif (j4 > 2)\n\t\t\t\t\tj5 = (j4 - 1) * 4;\n\t\t\t\tif (mob.waypointsX[l2] - mob.currentX > magicLoc * 3\n\t\t\t\t\t\t|| mob.waypointsY[l2] - mob.currentY > magicLoc * 3\n\t\t\t\t\t\t|| mob.waypointsX[l2] - mob.currentX < -magicLoc * 3\n\t\t\t\t\t\t|| mob.waypointsY[l2] - mob.currentY < -magicLoc * 3\n\t\t\t\t\t\t|| j4 > 8) {\n\t\t\t\t\tmob.currentX = mob.waypointsX[l2];\n\t\t\t\t\tmob.currentY = mob.waypointsY[l2];\n\t\t\t\t} else {\n\t\t\t\t\tif (mob.currentX < mob.waypointsX[l2]) {\n\t\t\t\t\t\tmob.currentX += j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\ti1 = 2;\n\t\t\t\t\t} else if (mob.currentX > mob.waypointsX[l2]) {\n\t\t\t\t\t\tmob.currentX -= j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\ti1 = 6;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob.currentX - mob.waypointsX[l2] < j5\n\t\t\t\t\t\t\t&& mob.currentX - mob.waypointsX[l2] > -j5)\n\t\t\t\t\t\tmob.currentX = mob.waypointsX[l2];\n\t\t\t\t\tif (mob.currentY < mob.waypointsY[l2]) {\n\t\t\t\t\t\tmob.currentY += j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\tif (i1 == -1)\n\t\t\t\t\t\t\ti1 = 4;\n\t\t\t\t\t\telse if (i1 == 2)\n\t\t\t\t\t\t\ti1 = 3;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti1 = 5;\n\t\t\t\t\t} else if (mob.currentY > mob.waypointsY[l2]) {\n\t\t\t\t\t\tmob.currentY -= j5;\n\t\t\t\t\t\tmob.stepCount++;\n\t\t\t\t\t\tif (i1 == -1)\n\t\t\t\t\t\t\ti1 = 0;\n\t\t\t\t\t\telse if (i1 == 2)\n\t\t\t\t\t\t\ti1 = 1;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti1 = 7;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob.currentY - mob.waypointsY[l2] < j5\n\t\t\t\t\t\t\t&& mob.currentY - mob.waypointsY[l2] > -j5)\n\t\t\t\t\t\tmob.currentY = mob.waypointsY[l2];\n\t\t\t\t}\n\t\t\t\tif (i1 != -1)\n\t\t\t\t\tmob.currentSprite = i1;\n\t\t\t\tif (mob.currentX == mob.waypointsX[l2]\n\t\t\t\t\t\t&& mob.currentY == mob.waypointsY[l2])\n\t\t\t\t\tmob.waypointEndSprite = (l2 + 1) % 10;\n\t\t\t} else {\n\t\t\t\tmob.currentSprite = mob.nextSprite;\n\t\t\t}\n\t\t\tif (mob.lastMessageTimeout > 0)\n\t\t\t\tmob.lastMessageTimeout--;\n\t\t\tif (mob.anInt163 > 0)\n\t\t\t\tmob.anInt163--;\n\t\t\tif (mob.combatTimer > 0)\n\t\t\t\tmob.combatTimer--;\n\t\t\tif (playerAliveTimeout > 0) {\n\t\t\t\tplayerAliveTimeout--;\n\t\t\t\tif (playerAliveTimeout == 0)\n\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\"You have been granted another life. Be more careful this time!\",\n\t\t\t\t\t\t\t3, 0);\n\t\t\t\tif (playerAliveTimeout == 0)\n\t\t\t\t\tdisplayMessage(\n\t\t\t\t\t\t\t\"You retain your skills. Your objects land where you died\",\n\t\t\t\t\t\t\t3, 0);\n\t\t\t}\n\t\t}\n\t\tfor (int j = 0; j < npcCount; j++) {\n\t\t\tMob mob_1 = npcArray[j];\n\t\t\tif (mob_1 == null) {\n\t\t\t\tSystem.out.println(\"MOB == NULL, npcCount: \" + npcCount\n\t\t\t\t\t\t+ \", j: \" + j);\n\t\t\t\tSystem.exit(1);\n\t\t\t}\n\t\t\tint j1 = (mob_1.waypointCurrent + 1) % 10;\n\t\t\tif (mob_1.waypointEndSprite != j1) {\n\t\t\t\tint i3 = -1;\n\t\t\t\tint k4 = mob_1.waypointEndSprite;\n\t\t\t\tint k5;\n\t\t\t\tif (k4 < j1)\n\t\t\t\t\tk5 = j1 - k4;\n\t\t\t\telse\n\t\t\t\t\tk5 = (10 + j1) - k4;\n\t\t\t\tint l5 = 4;\n\t\t\t\tif (k5 > 2)\n\t\t\t\t\tl5 = (k5 - 1) * 4;\n\t\t\t\tif (mob_1.waypointsX[k4] - mob_1.currentX > magicLoc * 3\n\t\t\t\t\t\t|| mob_1.waypointsY[k4] - mob_1.currentY > magicLoc * 3\n\t\t\t\t\t\t|| mob_1.waypointsX[k4] - mob_1.currentX < -magicLoc * 3\n\t\t\t\t\t\t|| mob_1.waypointsY[k4] - mob_1.currentY < -magicLoc * 3\n\t\t\t\t\t\t|| k5 > 8) {\n\t\t\t\t\tmob_1.currentX = mob_1.waypointsX[k4];\n\t\t\t\t\tmob_1.currentY = mob_1.waypointsY[k4];\n\t\t\t\t} else {\n\t\t\t\t\tif (mob_1.currentX < mob_1.waypointsX[k4]) {\n\t\t\t\t\t\tmob_1.currentX += l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\ti3 = 2;\n\t\t\t\t\t} else if (mob_1.currentX > mob_1.waypointsX[k4]) {\n\t\t\t\t\t\tmob_1.currentX -= l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\ti3 = 6;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob_1.currentX - mob_1.waypointsX[k4] < l5\n\t\t\t\t\t\t\t&& mob_1.currentX - mob_1.waypointsX[k4] > -l5)\n\t\t\t\t\t\tmob_1.currentX = mob_1.waypointsX[k4];\n\t\t\t\t\tif (mob_1.currentY < mob_1.waypointsY[k4]) {\n\t\t\t\t\t\tmob_1.currentY += l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\tif (i3 == -1)\n\t\t\t\t\t\t\ti3 = 4;\n\t\t\t\t\t\telse if (i3 == 2)\n\t\t\t\t\t\t\ti3 = 3;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti3 = 5;\n\t\t\t\t\t} else if (mob_1.currentY > mob_1.waypointsY[k4]) {\n\t\t\t\t\t\tmob_1.currentY -= l5;\n\t\t\t\t\t\tmob_1.stepCount++;\n\t\t\t\t\t\tif (i3 == -1)\n\t\t\t\t\t\t\ti3 = 0;\n\t\t\t\t\t\telse if (i3 == 2)\n\t\t\t\t\t\t\ti3 = 1;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ti3 = 7;\n\t\t\t\t\t}\n\t\t\t\t\tif (mob_1.currentY - mob_1.waypointsY[k4] < l5\n\t\t\t\t\t\t\t&& mob_1.currentY - mob_1.waypointsY[k4] > -l5)\n\t\t\t\t\t\tmob_1.currentY = mob_1.waypointsY[k4];\n\t\t\t\t}\n\t\t\t\tif (i3 != -1)\n\t\t\t\t\tmob_1.currentSprite = i3;\n\t\t\t\tif (mob_1.currentX == mob_1.waypointsX[k4]\n\t\t\t\t\t\t&& mob_1.currentY == mob_1.waypointsY[k4])\n\t\t\t\t\tmob_1.waypointEndSprite = (k4 + 1) % 10;\n\t\t\t} else {\n\t\t\t\tmob_1.currentSprite = mob_1.nextSprite;\n\t\t\t\tif (mob_1.type == 43)\n\t\t\t\t\tmob_1.stepCount++;\n\t\t\t}\n\t\t\tif (mob_1.lastMessageTimeout > 0)\n\t\t\t\tmob_1.lastMessageTimeout--;\n\t\t\tif (mob_1.anInt163 > 0)\n\t\t\t\tmob_1.anInt163--;\n\t\t\tif (mob_1.combatTimer > 0)\n\t\t\t\tmob_1.combatTimer--;\n\t\t}\n\t\tif (mouseOverMenu != 2) {\n\t\t\tif (GameImage.anInt346 > 0)\n\t\t\t\tanInt658++;\n\t\t\tif (GameImage.anInt347 > 0)\n\t\t\t\tanInt658 = 0;\n\t\t\tGameImage.anInt346 = 0;\n\t\t\tGameImage.anInt347 = 0;\n\t\t}\n\t\tfor (int l = 0; l < playerCount; l++) {\n\t\t\tMob mob_2 = playerArray[l];\n\t\t\tif (mob_2.anInt176 > 0)\n\t\t\t\tmob_2.anInt176--;\n\t\t}\n\t\tif (cameraAutoAngleDebug) {\n\t\t\tif (lastAutoCameraRotatePlayerX - ourPlayer.currentX < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerX - ourPlayer.currentX > 500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY > 500) {\n\t\t\t\tlastAutoCameraRotatePlayerX = ourPlayer.currentX;\n\t\t\t\tlastAutoCameraRotatePlayerY = ourPlayer.currentY;\n\t\t\t}\n\t\t} else {\n\t\t\tif (lastAutoCameraRotatePlayerX - ourPlayer.currentX < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerX - ourPlayer.currentX > 500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY < -500\n\t\t\t\t\t|| lastAutoCameraRotatePlayerY - ourPlayer.currentY > 500) {\n\t\t\t\tlastAutoCameraRotatePlayerX = ourPlayer.currentX;\n\t\t\t\tlastAutoCameraRotatePlayerY = ourPlayer.currentY;\n\t\t\t}\n\t\t\tif (lastAutoCameraRotatePlayerX != ourPlayer.currentX)\n\t\t\t\tlastAutoCameraRotatePlayerX += (ourPlayer.currentX - lastAutoCameraRotatePlayerX)\n\t\t\t\t\t\t/ (16 + (cameraHeight - 500) / 15);\n\t\t\tif (lastAutoCameraRotatePlayerY != ourPlayer.currentY)\n\t\t\t\tlastAutoCameraRotatePlayerY += (ourPlayer.currentY - lastAutoCameraRotatePlayerY)\n\t\t\t\t\t\t/ (16 + (cameraHeight - 500) / 15);\n\t\t\tif (configAutoCameraAngle) {\n\t\t\t\tint k1 = cameraAutoAngle * 32;\n\t\t\t\tint j3 = k1 - cameraRotation;\n\t\t\t\tbyte byte0 = 1;\n\t\t\t\tif (j3 != 0) {\n\t\t\t\t\tcameraRotationBaseAddition++;\n\t\t\t\t\tif (j3 > 128) {\n\t\t\t\t\t\tbyte0 = -1;\n\t\t\t\t\t\tj3 = 256 - j3;\n\t\t\t\t\t} else if (j3 > 0)\n\t\t\t\t\t\tbyte0 = 1;\n\t\t\t\t\telse if (j3 < -128) {\n\t\t\t\t\t\tbyte0 = 1;\n\t\t\t\t\t\tj3 = 256 + j3;\n\t\t\t\t\t} else if (j3 < 0) {\n\t\t\t\t\t\tbyte0 = -1;\n\t\t\t\t\t\tj3 = -j3;\n\t\t\t\t\t}\n\t\t\t\t\tcameraRotation += ((cameraRotationBaseAddition * j3 + 255) / 256)\n\t\t\t\t\t\t\t* byte0;\n\t\t\t\t\tcameraRotation &= 0xff;\n\t\t\t\t} else {\n\t\t\t\t\tcameraRotationBaseAddition = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (anInt658 > 20) {\n\t\t\taBoolean767 = false;\n\t\t\tanInt658 = 0;\n\t\t}\n\t\tif (sleeping) {\n\t\t\tignoreNext = true;\n\t\t\tif (super.enteredText.length() > 0) {\n\t\t\t\tsuper.streamClass.createPacket(200);\n\t\t\t\tsuper.streamClass.addString(super.enteredText);\n\t\t\t\tif (!aBoolean767) {\n\t\t\t\t\tsuper.streamClass.addByte(0);\n\t\t\t\t\taBoolean767 = true;\n\t\t\t\t}\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tgameMenu.updateText(chatHandle, \"\");\n\t\t\t\tsleepMessage = \"Please wait...\";\n\t\t\t} \n\t\t\tif (super.lastMouseDownButton != 0\n\t\t\t\t\t&& super.mouseX >= ((windowWidth / 2) - 100)\n\t\t\t\t\t&& super.mouseX < ((windowWidth / 2) + 100)\n\t\t\t\t\t&& super.mouseY > 280 && super.mouseY < 310) {\n\t\t\t\tsuper.streamClass.createPacket(200);\n\t\t\t\tsuper.streamClass.addString(\"-null-\");\n\t\t\t\tif (!aBoolean767) {\n\t\t\t\t\tsuper.streamClass.addByte(0);\n\t\t\t\t\taBoolean767 = true;\n\t\t\t\t}\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tsleepMessage = \" Please wait...\";\n\t\t\t}\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\t\treturn;\n\t\t}\n\t\tif (super.mouseY > windowHeight - 4) {\n\t\t\tif (super.mouseX > 15 + xAddition && super.mouseX < 96 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1)\n\t\t\t\tmessagesTab = 0;\n\t\t\tif (super.mouseX > 110 + xAddition\n\t\t\t\t\t&& super.mouseX < 194 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tmessagesTab = 1;\n\t\t\t\tgameMenu.anIntArray187[messagesHandleType2] = 0xf423f;\n\t\t\t}\n\t\t\tif (super.mouseX > 215 + xAddition\n\t\t\t\t\t&& super.mouseX < 295 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tmessagesTab = 2;\n\t\t\t\tgameMenu.anIntArray187[messagesHandleType5] = 0xf423f;\n\t\t\t}\n\t\t\tif (super.mouseX > 315 + xAddition\n\t\t\t\t\t&& super.mouseX < 395 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tmessagesTab = 3;\n\t\t\t\tgameMenu.anIntArray187[messagesHandleType6] = 0xf423f;\n\t\t\t}\n\t\t\tif (super.mouseX > 417 + xAddition\n\t\t\t\t\t&& super.mouseX < 497 + xAddition\n\t\t\t\t\t&& super.lastMouseDownButton == 1) {\n\t\t\t\tshowAbuseWindow = 1;\n\t\t\t\tabuseSelectedType = 0;\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t}\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\t\tsuper.mouseDownButton = 0;\n\t\t}\n\t\tgameMenu.updateActions(super.mouseX, super.mouseY,\n\t\t\t\tsuper.lastMouseDownButton, super.mouseDownButton);\n\t\tif (messagesTab > 0 && super.mouseX >= 494\n\t\t\t\t&& super.mouseY >= windowHeight - 66)\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\tif (gameMenu.hasActivated(chatHandle)) {\n\t\t\tString s = gameMenu.getText(chatHandle);\n\t\t\tgameMenu.updateText(chatHandle, \"\");\n\t\t\tif (ignoreNext) {\n\t\t\t\tignoreNext = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (s.startsWith(\"::\")) {\n\t\t\t\ts = s.substring(2);\n\t\t\t\tif (!handleCommand(s) && !sleeping && !ignoreNext) {\n\t\t\t\t\tsendChatString(s);\n\t\t\t\t\tif (messages.size() == 0\n\t\t\t\t\t\t\t|| !messages.get(messages.size() - 1)\n\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"::\" + s)) {\n\t\t\t\t\t\tmessages.add(\"::\" + s);\n\t\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t\t} else if (messages.get(messages.size() - 1)\n\t\t\t\t\t\t\t.equalsIgnoreCase(\"::\" + s)) {\n\t\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (!sleeping && !ignoreNext) {\n\t\t\t\tbyte[] chatMessage = DataConversions.stringToByteArray(s);\n\t\t\t\tsendChatMessage(chatMessage, chatMessage.length);\n\t\t\t\ts = DataConversions.byteToString(chatMessage, 0,\n\t\t\t\t\t\tchatMessage.length).trim();\n\t\t\t\tif (s.toLowerCase().trim().startsWith(\";;\"))\n\t\t\t\t\treturn;\n\t\t\t\tif (messages.size() == 0\n\t\t\t\t\t\t|| !messages.get(messages.size() - 1).equalsIgnoreCase(\n\t\t\t\t\t\t\t\ts)) {\n\t\t\t\t\tmessages.add(s);\n\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t} else if (messages.get(messages.size() - 1)\n\t\t\t\t\t\t.equalsIgnoreCase(s)) {\n\t\t\t\t\tcurrentChat = messages.size();\n\t\t\t\t}\n\t\t\t\tourPlayer.lastMessageTimeout = 150;\n\t\t\t\tourPlayer.lastMessage = s;\n\t\t\t\tdisplayMessage(ourPlayer.name + \": \" + s, 2, ourPlayer.admin);\n\t\t\t}\n\t\t}\n\t\tif (messagesTab == 0) {\n\t\t\tfor (int l1 = 0; l1 < messagesTimeout.length; l1++)\n\t\t\t\tif (messagesTimeout[l1] > 0)\n\t\t\t\t\tmessagesTimeout[l1]--;\n\t\t}\n\t\tif (playerAliveTimeout != 0)\n\t\t\tsuper.lastMouseDownButton = 0;\n\t\tif (showTradeWindow || showDuelWindow) {\n\t\t\tif (super.mouseDownButton != 0)\n\t\t\t\tmouseDownTime++;\n\t\t\telse\n\t\t\t\tmouseDownTime = 0;\n\t\t\tif (mouseDownTime > 500)\n\t\t\t\titemIncrement += 100000;\n\t\t\telse if (mouseDownTime > 350)\n\t\t\t\titemIncrement += 10000;\n\t\t\telse if (mouseDownTime > 250)\n\t\t\t\titemIncrement += 1000;\n\t\t\telse if (mouseDownTime > 150)\n\t\t\t\titemIncrement += 100;\n\t\t\telse if (mouseDownTime > 100)\n\t\t\t\titemIncrement += 10;\n\t\t\telse if (mouseDownTime > 50)\n\t\t\t\titemIncrement++;\n\t\t\telse if (mouseDownTime > 20 && (mouseDownTime & 5) == 0)\n\t\t\t\titemIncrement++;\n\t\t} else {\n\t\t\tmouseDownTime = 0;\n\t\t\titemIncrement = 0;\n\t\t}\n\t\tif (super.lastMouseDownButton == 1)\n\t\t\tmouseButtonClick = 1;\n\t\telse if (super.lastMouseDownButton == 2)\n\t\t\tmouseButtonClick = 2;\n\t\tgameCamera.updateMouseCoords(super.mouseX, super.mouseY);\n\t\tsuper.lastMouseDownButton = 0;\n\t\tif (configAutoCameraAngle) {\n\t\t\tif (cameraRotationBaseAddition == 0 || cameraAutoAngleDebug) {\n\t\t\t\tif (super.keyLeftDown) {\n\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 1 & 7;\n\t\t\t\t\tsuper.keyLeftDown = false;\n\t\t\t\t\tif (!zoomCamera) {\n\t\t\t\t\t\tif ((cameraAutoAngle & 1) == 0)\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 1 & 7;\n\t\t\t\t\t\tfor (int i2 = 0; i2 < 8; i2++) {\n\t\t\t\t\t\t\tif (enginePlayerVisible(cameraAutoAngle))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 1 & 7;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (super.keyRightDown) {\n\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 7 & 7;\n\t\t\t\t\tsuper.keyRightDown = false;\n\t\t\t\t\tif (!zoomCamera) {\n\t\t\t\t\t\tif ((cameraAutoAngle & 1) == 0)\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 7 & 7;\n\t\t\t\t\t\tfor (int j2 = 0; j2 < 8; j2++) {\n\t\t\t\t\t\t\tif (enginePlayerVisible(cameraAutoAngle))\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcameraAutoAngle = cameraAutoAngle + 7 & 7;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else\n\t\t\ttry {\n\t\t\t\tif (super.keyLeftDown)\n\t\t\t\t\tcameraRotation = cameraRotation + 2 & 0xff;\n\t\t\t\telse if (super.keyRightDown)\n\t\t\t\t\tcameraRotation = cameraRotation - 2 & 0xff;\n\t\t\t\tif (super.home) {\n\t\t\t\t\tcameraHeight = 750;\n\t\t\t\t\tcameraVertical = 920;\n\t\t\t\t\tfogVar = 0;\n\t\t\t\t} else if (super.pageUp) {\n\t\t\t\t\tif (cameraHeight > 400)\n\t\t\t\t\t\tcameraHeight -= 6;\n\t\t\t\t} else if (super.pageDown) {\n\t\t\t\t\tif (cameraHeight < 3000)\n\t\t\t\t\t\tcameraHeight += 6;\n\t\t\t\t}\n\t\t\t\tif (controlDown && fog) {\n\t\t\t\t\tif (minus)\n\t\t\t\t\t\tfogVar += 20;\n\t\t\t\t\telse if (plus)\n\t\t\t\t\t\tfogVar -= 20;\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\tSystem.out.println(\"Camera error: \" + e);\n\t\t\t\tcameraHeight = 750;\n\t\t\t\tcameraVertical = 920;\n\t\t\t\tfogVar = 0;\n\t\t\t}\n\t\tif (actionPictureType > 0)\n\t\t\tactionPictureType--;\n\t\telse if (actionPictureType < 0)\n\t\t\tactionPictureType++;\n\t\tgameCamera.method301(17);\n\t\tmodelUpdatingTimer++;\n\t\tif (modelUpdatingTimer > 5) {\n\t\t\tmodelUpdatingTimer = 0;\n\t\t\tmodelFireLightningSpellNumber = (modelFireLightningSpellNumber + 1) % 3;\n\t\t\tmodelTorchNumber = (modelTorchNumber + 1) % 4;\n\t\t\tmodelClawSpellNumber = (modelClawSpellNumber + 1) % 5;\n\t\t}\n\t\tfor (int k2 = 0; k2 < objectCount; k2++) {\n\t\t\tint l3 = objectX[k2];\n\t\t\tint l4 = objectY[k2];\n\t\t\tif (l3 >= 0 && l4 >= 0 && l3 < 96 && l4 < 96\n\t\t\t\t\t&& objectType[k2] == 74)\n\t\t\t\tobjectModelArray[k2].method188(1, 0, 0);\n\t\t}\n\t\tfor (int i4 = 0; i4 < anInt892; i4++) {\n\t\t\tanIntArray923[i4]++;\n\t\t\tif (anIntArray923[i4] > 50) {\n\t\t\t\tanInt892--;\n\t\t\t\tfor (int i5 = i4; i5 < anInt892; i5++) {\n\t\t\t\t\tanIntArray944[i5] = anIntArray944[i5 + 1];\n\t\t\t\t\tanIntArray757[i5] = anIntArray757[i5 + 1];\n\t\t\t\t\tanIntArray923[i5] = anIntArray923[i5 + 1];\n\t\t\t\t\tanIntArray782[i5] = anIntArray782[i5 + 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic static HashMap<String, File> ctfsounds = new HashMap<String, File>();\n\tprivate final void loadSounds() {\n\t\ttry {\n\t\t\tdrawDownloadProgress(\"Unpacking Sound effects\", 90, false);\n\t\t\tsounds = load(\"sounds1.mem\");\n\t\t\taudioReader = new AudioReader();\n\t\t\treturn;\n\t\t} catch (Throwable throwable) {\n\t\t\tSystem.out.println(\"Unable to init sounds:\" + throwable);\n\t\t}\n\t}\n\tprivate final void drawCombatStyleWindow() {\n\t\tbyte byte0 = 7;\n\t\tbyte byte1 = 15;\n\t\tchar c = '\\257';\n\t\tif (mouseButtonClick != 0) {\n\t\t\tfor (int i = 0; i < 5; i++) {\n\t\t\t\tif (i <= 0 || super.mouseX <= byte0\n\t\t\t\t\t\t|| super.mouseX >= byte0 + c\n\t\t\t\t\t\t|| super.mouseY <= byte1 + i * 20\n\t\t\t\t\t\t|| super.mouseY >= byte1 + i * 20 + 20)\n\t\t\t\t\tcontinue;\n\t\t\t\tcombatStyle = i - 1;\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t\tsuper.streamClass.createPacket(42);\n\t\t\t\tsuper.streamClass.addByte(combatStyle);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor (int j = 0; j < 5; j++) {\n\t\t\tif (j == combatStyle + 1)\n\t\t\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + j * 20, c, 20,\n\t\t\t\t\t\tGameImage.convertRGBToLong(255, 0, 0), 128);\n\t\t\telse\n\t\t\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + j * 20, c, 20,\n\t\t\t\t\t\tGameImage.convertRGBToLong(190, 190, 190), 128);\n\t\t\tgameGraphics.drawLineX(byte0, byte1 + j * 20, c, 0);\n\t\t\tgameGraphics.drawLineX(byte0, byte1 + j * 20 + 20, c, 0);\n\t\t}\n\t\tgameGraphics.drawText(\"Select combat style\", byte0 + c / 2, byte1 + 16,\n\t\t\t\t3, 0xffffff);\n\t\tgameGraphics.drawText(\"Controlled (+1 of each)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 36, 3, 0);\n\t\tgameGraphics.drawText(\"Aggressive (+3 strength)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 56, 3, 0);\n\t\tgameGraphics.drawText(\"Accurate (+3 attack)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 76, 3, 0);\n\t\tgameGraphics.drawText(\"Defensive (+3 defense)\", byte0 + c / 2,\n\t\t\t\tbyte1 + 96, 3, 0);\n\t}\n\tprivate final void drawDuelConfirmWindow() {\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 16, 192);\n\t\tint i = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 16, 468, 246, i, 160);\n\t\tgameGraphics.drawText(\"Please confirm your duel with @yel@\"\n\t\t\t\t+ DataOperations.longToString(duelOpponentNameLong),\n\t\t\t\tbyte0 + 234, byte1 + 12, 1, 0xffffff);\n\t\tgameGraphics.drawText(\"Your stake:\", byte0 + 117, byte1 + 30, 1,\n\t\t\t\t0xffff00);\n\t\tfor (int j = 0; j < duelConfirmMyItemCount; j++) {\n\t\t\tString s = EntityHandler.getItemDef(duelConfirmMyItems[j])\n\t\t\t\t\t.getName();\n\t\t\tif (EntityHandler.getItemDef(duelConfirmMyItems[j]).isStackable())\n\t\t\t\ts = s + \" x \" + method74(duelConfirmMyItemsCount[j]);\n\t\t\tgameGraphics.drawText(s, byte0 + 117, byte1 + 42 + j * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (duelConfirmMyItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 117, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tgameGraphics.drawText(\"Your opponent's stake:\", byte0 + 351,\n\t\t\t\tbyte1 + 30, 1, 0xffff00);\n\t\tfor (int k = 0; k < duelConfirmOpponentItemCount; k++) {\n\t\t\tString s1 = EntityHandler.getItemDef(duelConfirmOpponentItems[k])\n\t\t\t\t\t.getName();\n\t\t\tif (EntityHandler.getItemDef(duelConfirmOpponentItems[k])\n\t\t\t\t\t.isStackable())\n\t\t\t\ts1 = s1 + \" x \" + method74(duelConfirmOpponentItemsCount[k]);\n\t\t\tgameGraphics.drawText(s1, byte0 + 351, byte1 + 42 + k * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (duelConfirmOpponentItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 351, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tif (duelCantRetreat == 0)\n\t\t\tgameGraphics.drawText(\"You can retreat from this duel\",\n\t\t\t\t\tbyte0 + 234, byte1 + 180, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"No retreat is possible!\", byte0 + 234,\n\t\t\t\t\tbyte1 + 180, 1, 0xff0000);\n\t\tif (duelUseMagic == 0)\n\t\t\tgameGraphics.drawText(\"Magic may be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 192, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"Magic cannot be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 192, 1, 0xff0000);\n\t\tif (duelUsePrayer == 0)\n\t\t\tgameGraphics.drawText(\"Prayer may be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 204, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"Prayer cannot be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 204, 1, 0xff0000);\n\t\tif (duelUseWeapons == 0)\n\t\t\tgameGraphics.drawText(\"Weapons may be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 216, 1, 65280);\n\t\telse\n\t\t\tgameGraphics.drawText(\"Weapons cannot be used\", byte0 + 234,\n\t\t\t\t\tbyte1 + 216, 1, 0xff0000);\n\t\tgameGraphics.drawText(\n\t\t\t\t\"If you are sure click 'Accept' to begin the duel\",\n\t\t\t\tbyte0 + 234, byte1 + 230, 1, 0xffffff);\n\t\tif (!duelWeAccept) {\n\t\t\tgameGraphics.drawPicture((byte0 + 118) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\t\tgameGraphics.drawPicture((byte0 + 352) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\t} else {\n\t\t\tgameGraphics.drawText(\"Waiting for other player...\", byte0 + 234,\n\t\t\t\t\tbyte1 + 250, 1, 0xffff00);\n\t\t}\n\t\tif (mouseButtonClick == 1) {\n\t\t\tif (super.mouseX < byte0 || super.mouseY < byte1\n\t\t\t\t\t|| super.mouseX > byte0 + 468 || super.mouseY > byte1 + 262) {\n\t\t\t\tshowDuelConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 118) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 118 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\tduelWeAccept = true;\n\t\t\t\tsuper.streamClass.createPacket(87);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 352) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 353 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\tshowDuelConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void updateBankItems() {\n\t\tbankItemCount = newBankItemCount;\n\t\tfor (int i = 0; i < newBankItemCount; i++) {\n\t\t\tbankItems[i] = newBankItems[i];\n\t\t\tbankItemsCount[i] = newBankItemsCount[i];\n\t\t}\n\t\tfor (int j = 0; j < inventoryCount; j++) {\n\t\t\tif (bankItemCount >= bankItemsMax)\n\t\t\t\tbreak;\n\t\t\tint k = getInventoryItems()[j];\n\t\t\tboolean flag = false;\n\t\t\tfor (int l = 0; l < bankItemCount; l++) {\n\t\t\t\tif (bankItems[l] != k)\n\t\t\t\t\tcontinue;\n\t\t\t\tflag = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!flag) {\n\t\t\t\tbankItems[bankItemCount] = k;\n\t\t\t\tbankItemsCount[bankItemCount] = 0;\n\t\t\t\tbankItemCount++;\n\t\t\t}\n\t\t}\n\t}\n\tprivate final void makeDPSMenu() {\n\t\tdrawPointsScreen = new Menu(gameGraphics, 100);\n\t\tfinal Menu dPS = drawPointsScreen;\n\t\tdPS.drawText(256, 10, \"Please select your points\", 4, true);\n\t\tint i = 140;\n\t\tint j = 34;\n\t\ti += 116;\n\t\tj -= 10;\n\t\tbyte byte0 = 54;\n\t\tj += 145;\n\t\tdPS.method157(i - byte0, j, 53, 41);\n\t\tdPS.drawText(i - byte0, j - 8, \"Str\", 1, true);\n\t\tdPS.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tstrDownButton = dPS.makeButton(i - byte0 - 40, j, 20, 20);\n\t\tdPS.method158((i - byte0) + 40, j, SPRITE_UTIL_START + 6);\n\t\tstrUpButton = dPS.makeButton((i - byte0) + 40, j, 20, 20);\n\t\tdPS.method157(i + byte0, j, 53, 41);\n\t\tdPS.drawText(i + byte0, j - 8, \"Atk\", 1, true);\n\t\tdPS.method158((i + byte0) - 40, j, SPRITE_UTIL_START + 7);\n\t\tatkDownButton = dPS.makeButton((i + byte0) - 40, j, 20, 20);\n\t\tdPS.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tatkUpButton = dPS.makeButton(i + byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tdPS.method157(i - byte0, j, 53, 41);\n\t\tdPS.drawText(i - byte0, j - 8, \"Def\", 1, true);\n\t\tdPS.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tdefDownButton = dPS.makeButton(i - byte0 - 40, j, 20, 20);\n\t\tdPS.method158((i - byte0) + 40, j, SPRITE_UTIL_START + 6);\n\t\tdefUpButton = dPS.makeButton((i - byte0) + 40, j, 20, 20);\n\t\tdPS.method157(i + byte0, j, 53, 41);\n\t\tdPS.drawText(i + byte0, j - 8, \"Range\", 1, true);\n\t\tdPS.method158((i + byte0) - 40, j, SPRITE_UTIL_START + 7);\n\t\trangeDownButton = dPS.makeButton((i + byte0) - 40, j, 20, 20);\n\t\tdPS.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\trangeUpButton = dPS.makeButton(i + byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tdPS.method157(i - byte0, j, 53, 41);\n\t\tdPS.drawText(i - byte0, j - 8, \"Magic\", 1, true);\n\t\tdPS.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tmagDownButton = dPS.makeButton(i - byte0 - 40, j, 20, 20);\n\t\tdPS.method158((i - byte0) + 40, j, SPRITE_UTIL_START + 6);\n\t\tmagUpButton = dPS.makeButton((i - byte0) + 40, j, 20, 20);\n\t\tj += 82;\n\t\tj -= 35;\n\t\tdPS.drawBox(i, j, 200, 30);\n\t\tdPS.drawText(i, j, \"Accept\", 4, false);\n\t\tdPSAcceptButton = dPS.makeButton(i, j, 200, 30);\n\t}\n\tprivate final void makeCharacterDesignMenu() {\n\t\tcharacterDesignMenu = new Menu(gameGraphics, 100);\n\t\tcharacterDesignMenu.drawText(256, 10, \"Please design Your Character\",\n\t\t\t\t4, true);\n\t\tint i = 140;\n\t\tint j = 34;\n\t\ti += 116;\n\t\tj -= 10;\n\t\tcharacterDesignMenu.drawText(i - 55, j + 110, \"Front\", 3, true);\n\t\tcharacterDesignMenu.drawText(i, j + 110, \"Side\", 3, true);\n\t\tcharacterDesignMenu.drawText(i + 55, j + 110, \"Back\", 3, true);\n\t\tbyte byte0 = 54;\n\t\tj += 145;\n\t\tcharacterDesignMenu.method157(i - byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i - byte0, j - 8, \"Head\", 1, true);\n\t\tcharacterDesignMenu.drawText(i - byte0, j + 8, \"Type\", 1, true);\n\t\tcharacterDesignMenu.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tcharacterDesignHeadButton1 = characterDesignMenu.makeButton(i - byte0\n\t\t\t\t- 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158((i - byte0) + 40, j,\n\t\t\t\tSPRITE_UTIL_START + 6);\n\t\tcharacterDesignHeadButton2 = characterDesignMenu.makeButton(\n\t\t\t\t(i - byte0) + 40, j, 20, 20);\n\t\tcharacterDesignMenu.method157(i + byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i + byte0, j - 8, \"Hair\", 1, true);\n\t\tcharacterDesignMenu.drawText(i + byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158((i + byte0) - 40, j,\n\t\t\t\tSPRITE_UTIL_START + 7);\n\t\tcharacterDesignHairColourButton1 = characterDesignMenu.makeButton(\n\t\t\t\t(i + byte0) - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tcharacterDesignHairColourButton2 = characterDesignMenu.makeButton(i\n\t\t\t\t+ byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tcharacterDesignMenu.method157(i - byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i - byte0, j, \"Gender\", 1, true);\n\t\tcharacterDesignMenu.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tcharacterDesignGenderButton1 = characterDesignMenu.makeButton(i - byte0\n\t\t\t\t- 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158((i - byte0) + 40, j,\n\t\t\t\tSPRITE_UTIL_START + 6);\n\t\tcharacterDesignGenderButton2 = characterDesignMenu.makeButton(\n\t\t\t\t(i - byte0) + 40, j, 20, 20);\n\t\tcharacterDesignMenu.method157(i + byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i + byte0, j - 8, \"Top\", 1, true);\n\t\tcharacterDesignMenu.drawText(i + byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158((i + byte0) - 40, j,\n\t\t\t\tSPRITE_UTIL_START + 7);\n\t\tcharacterDesignTopColourButton1 = characterDesignMenu.makeButton(\n\t\t\t\t(i + byte0) - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tcharacterDesignTopColourButton2 = characterDesignMenu.makeButton(i\n\t\t\t\t+ byte0 + 40, j, 20, 20);\n\t\tj += 50;\n\t\tcharacterDesignMenu.method157(i - byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i - byte0, j - 8, \"Skin\", 1, true);\n\t\tcharacterDesignMenu.drawText(i - byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158(i - byte0 - 40, j, SPRITE_UTIL_START + 7);\n\t\tcharacterDesignSkinColourButton1 = characterDesignMenu.makeButton(i\n\t\t\t\t- byte0 - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158((i - byte0) + 40, j,\n\t\t\t\tSPRITE_UTIL_START + 6);\n\t\tcharacterDesignSkinColourButton2 = characterDesignMenu.makeButton(\n\t\t\t\t(i - byte0) + 40, j, 20, 20);\n\t\tcharacterDesignMenu.method157(i + byte0, j, 53, 41);\n\t\tcharacterDesignMenu.drawText(i + byte0, j - 8, \"Bottom\", 1, true);\n\t\tcharacterDesignMenu.drawText(i + byte0, j + 8, \"Colour\", 1, true);\n\t\tcharacterDesignMenu.method158((i + byte0) - 40, j,\n\t\t\t\tSPRITE_UTIL_START + 7);\n\t\tcharacterDesignBottomColourButton1 = characterDesignMenu.makeButton(\n\t\t\t\t(i + byte0) - 40, j, 20, 20);\n\t\tcharacterDesignMenu.method158(i + byte0 + 40, j, SPRITE_UTIL_START + 6);\n\t\tcharacterDesignBottomColourButton2 = characterDesignMenu.makeButton(i\n\t\t\t\t+ byte0 + 40, j, 20, 20);\n\t\tj += 82;\n\t\tj -= 35;\n\t\tcharacterDesignMenu.drawBox(i, j, 200, 30);\n\t\tcharacterDesignMenu.drawText(i, j, \"Accept\", 4, false);\n\t\tcharacterDesignAcceptButton = characterDesignMenu.makeButton(i, j, 200,\n\t\t\t\t30);\n\t}\n\tprivate final void drawAbuseWindow2() {\n\t\tif (super.enteredText.length() > 0) {\n\t\t\tString s = super.enteredText.trim();\n\t\t\tsuper.inputText = \"\";\n\t\t\tsuper.enteredText = \"\";\n\t\t\tif (s.length() > 0) {\n\t\t\t\tlong l = DataOperations.stringLength12ToLong(s);\n\t\t\t\tsuper.streamClass.createPacket(7);\n\t\t\t\tsuper.streamClass.addTwo4ByteInts(l);\n\t\t\t\tsuper.streamClass.addByte(abuseSelectedType);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tshowAbuseWindow = 0;\n\t\t\treturn;\n\t\t}\n\t\tgameGraphics.drawBox(56 + xAddition, 130 + yAddition, 400, 100, 0);\n\t\tgameGraphics.drawBoxEdge(56 + xAddition, 130 + yAddition, 400, 100,\n\t\t\t\t0xffffff);\n\t\tint i = 160 + yAddition;\n\t\tgameGraphics.drawText(\n\t\t\t\t\"Now type the name of the offending player, and press enter\",\n\t\t\t\t256 + xAddition, i, 1, 0xffff00);\n\t\ti += 18;\n\t\tgameGraphics.drawText(\"Name: \" + super.inputText + \"*\",\n\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\ti = 222 + yAddition;\n\t\tint j = 0xffffff;\n\t\tif (super.mouseX > 196 + xAddition && super.mouseX < 316 + xAddition\n\t\t\t\t&& super.mouseY > i - 13 && super.mouseY < i + 2) {\n\t\t\tj = 0xffff00;\n\t\t\tif (mouseButtonClick == 1) {\n\t\t\t\tmouseButtonClick = 0;\n\t\t\t\tshowAbuseWindow = 0;\n\t\t\t}\n\t\t}\n\t\tgameGraphics.drawText(\"Click here to cancel\", 256 + xAddition, i, 1, j);\n\t\tif (mouseButtonClick == 1\n\t\t\t\t&& (super.mouseX < 56 + xAddition\n\t\t\t\t\t\t|| super.mouseX > 456 + xAddition\n\t\t\t\t\t\t|| super.mouseY < 130 + yAddition || super.mouseY > 230 + yAddition)) {\n\t\t\tmouseButtonClick = 0;\n\t\t\tshowAbuseWindow = 0;\n\t\t}\n\t}\n\tpublic final void displayMessage(String message, int type, int status) {\n\t\tif (type == 2 || type == 4 || type == 6) {\n\t\t\tfor (; message.length() > 5 && message.charAt(0) == '@'\n\t\t\t\t\t&& message.charAt(4) == '@'; message = message.substring(5))\n\t\t\t\t;\n\t\t}\n\t\tif (message.startsWith(\"%\", 0)) {\n\t\t\tmessage = message.substring(1);\n\t\t\tstatus = 4;\n\t\t}\n\t\tif (message.startsWith(\"&\", 0)) {\n\t\t\tmessage = message.substring(1);\n\t\t\tstatus = 33;\n\t\t}\n\t\tmessage = message.replaceAll(\"\\\\#pmd\\\\#\", \"\");\n\t\tmessage = message.replaceAll(\"\\\\#mod\\\\#\", \"\");\n\t\tmessage = message.replaceAll(\"\\\\#adm\\\\#\", \"\");\n\t\tif (type == 2)\n\t\t\tmessage = \"@yel@\" + message;\n\t\tif (type == 3 || type == 4)\n\t\t\tmessage = \"@whi@\" + message;\n\t\tif (type == 6)\n\t\t\tmessage = \"@cya@\" + message;\n\t\tif (status == 1)\n\t\t\tmessage = \"#pmd#\" + message;\n\t\tif (status == 2)\n\t\t\tmessage = \"#mod#\" + message;\n\t\tif (status == 3)\n\t\t\tmessage = \"#adm#\" + message;\n\t\tif (status == 4) {\n\t\t\tmessage = \"#pmd#\" + message;\n\t\t\tMessageQueue.getQueue();\n\t\t\tMessageQueue.addMessage(new Message(message));\n\t\t\tgameMenu.addString(messagesHandleType6, message, false);\n\t\t\treturn;\n\t\t}\n\t\tif (status == 33) {\n\t\t\tMessageQueue.getQueue();\n\t\t\tMessageQueue.addMessage(new Message(message, true));\n\t\t\tgameMenu.addString(messagesHandleType6, message, false);\n\t\t\treturn;\n\t\t}\n\t\tif (messagesTab != 0) {\n\t\t\tif (type == 4 || type == 3)\n\t\t\t\tanInt952 = 200;\n\t\t\tif (type == 2 && messagesTab != 1)\n\t\t\t\tanInt953 = 200;\n\t\t\tif (type == 5 && messagesTab != 2)\n\t\t\t\tanInt954 = 200;\n\t\t\tif (type == 6 && messagesTab != 3)\n\t\t\t\tanInt955 = 200;\n\t\t\tif (type == 3 && messagesTab != 0)\n\t\t\t\tmessagesTab = 0;\n\t\t\tif (type == 6 && messagesTab != 3 && messagesTab != 0)\n\t\t\t\tmessagesTab = 0;\n\t\t}\n\t\tfor (int k = messagesArray.length - 1; k > 0; k--) {\n\t\t\tmessagesArray[k] = messagesArray[k - 1];\n\t\t\tmessagesTimeout[k] = messagesTimeout[k - 1];\n\t\t}\n\t\tmessagesArray[0] = message;\n\t\tmessagesTimeout[0] = 300;\n\t\tif (type == 2)\n\t\t\tif (gameMenu.anIntArray187[messagesHandleType2] == gameMenu.menuListTextCount[messagesHandleType2] - 4)\n\t\t\t\tgameMenu.addString(messagesHandleType2, message, true);\n\t\t\telse\n\t\t\t\tgameMenu.addString(messagesHandleType2, message, false);\n\t\tif (type == 5)\n\t\t\tif (gameMenu.anIntArray187[messagesHandleType5] == gameMenu.menuListTextCount[messagesHandleType5] - 4)\n\t\t\t\tgameMenu.addString(messagesHandleType5, message, true);\n\t\t\telse\n\t\t\t\tgameMenu.addString(messagesHandleType5, message, false);\n\t\tif (type == 6) {\n\t\t\tif (gameMenu.anIntArray187[messagesHandleType6] == gameMenu.menuListTextCount[messagesHandleType6] - 4) {\n\t\t\t\tgameMenu.addString(messagesHandleType6, message, true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgameMenu.addString(messagesHandleType6, message, false);\n\t\t}\n\t}\n\tprotected final void logoutAndStop() {\n\t\tsendLogoutPacket();\n\t\tgarbageCollect();\n\t\tif (audioReader != null) {\n\t\t\taudioReader.stopAudio();\n\t\t}\n\t}\n\tprivate final void method98(int i, String s) {\n\t\tint j = objectX[i];\n\t\tint k = objectY[i];\n\t\tint l = j - ourPlayer.currentX / 128;\n\t\tint i1 = k - ourPlayer.currentY / 128;\n\t\tbyte byte0 = 7;\n\t\tif (j >= 0 && k >= 0 && j < 96 && k < 96 && l > -byte0 && l < byte0\n\t\t\t\t&& i1 > -byte0 && i1 < byte0) {\n\t\t\ttry {\n\t\t\t\tgameCamera.removeModel(objectModelArray[i]);\n\t\t\t\tint j1 = EntityHandler.storeModel(s);\n\t\t\t\tModel model = gameDataModels[j1].method203();\n\t\t\t\tgameCamera.addModel(model);\n\t\t\t\tmodel.method184(true, 48, 48, -50, -10, -50);\n\t\t\t\tmodel.method205(objectModelArray[i]);\n\t\t\t\tmodel.anInt257 = i;\n\t\t\t\tobjectModelArray[i] = model;\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\t}\n\tprotected final void resetVars() {\n\t\tsystemUpdate = 0;\n\t\tcombatStyle = 0;\n\t\tlogoutTimeout = 0;\n\t\tloginScreenNumber = 0;\n\t\tloggedIn = 1;\n\t\tflagged = 0;\n\t\tresetPrivateMessageStrings();\n\t\tgameGraphics.method211();\n\t\tgameGraphics.drawImage(aGraphics936, 0, 0);\n\t\tfor (int i = 0; i < objectCount; i++) {\n\t\t\tgameCamera.removeModel(objectModelArray[i]);\n\t\t\tengineHandle.updateObject(objectX[i], objectY[i], objectType[i],\n\t\t\t\t\tobjectID[i]);\n\t\t}\n\t\tfor (int j = 0; j < doorCount; j++) {\n\t\t\tgameCamera.removeModel(doorModel[j]);\n\t\t\tengineHandle.updateDoor(doorX[j], doorY[j], doorDirection[j],\n\t\t\t\t\tdoorType[j]);\n\t\t}\n\t\tobjectCount = 0;\n\t\tdoorCount = 0;\n\t\tgroundItemCount = 0;\n\t\tplayerCount = 0;\n\t\tfor (int k = 0; k < mobArray.length; k++)\n\t\t\tmobArray[k] = null;\n\t\tfor (int l = 0; l < playerArray.length; l++)\n\t\t\tplayerArray[l] = null;\n\t\tnpcCount = 0;\n\t\tfor (int i1 = 0; i1 < npcRecordArray.length; i1++)\n\t\t\tnpcRecordArray[i1] = null;\n\t\tfor (int j1 = 0; j1 < npcArray.length; j1++)\n\t\t\tnpcArray[j1] = null;\n\t\tfor (int k1 = 0; k1 < prayerOn.length; k1++)\n\t\t\tprayerOn[k1] = false;\n\t\tmouseButtonClick = 0;\n\t\tsuper.lastMouseDownButton = 0;\n\t\tsuper.mouseDownButton = 0;\n\t\tshowShop = false;\n\t\tshowBank = false;\n\t\tsuper.friendsCount = 0;\n\t}\n\tprivate final void drawTradeWindow() {\n\t\tif (mouseButtonClick != 0 && itemIncrement == 0)\n\t\t\titemIncrement = 1;\n\t\tif (itemIncrement > 0) {\n\t\t\tint i = super.mouseX - 22 - xAddition;\n\t\t\tint j = super.mouseY - 36 - yAddition;\n\t\t\tif (i >= 0 && j >= 0 && i < 468 && j < 262) {\n\t\t\t\tif (i > 216 && j > 30 && i < 462 && j < 235) {\n\t\t\t\t\tint k = (i - 217) / 49 + ((j - 31) / 34) * 5;\n\t\t\t\t\tif (k >= 0 && k < inventoryCount) {\n\t\t\t\t\t\tboolean flag = false;\n\t\t\t\t\t\tint l1 = 0;\n\t\t\t\t\t\tint k2 = getInventoryItems()[k];\n\t\t\t\t\t\tfor (int k3 = 0; k3 < tradeMyItemCount; k3++)\n\t\t\t\t\t\t\tif (tradeMyItems[k3] == k2)\n\t\t\t\t\t\t\t\tif (EntityHandler.getItemDef(k2).isStackable()) {\n\t\t\t\t\t\t\t\t\tfor (int i4 = 0; i4 < itemIncrement; i4++) {\n\t\t\t\t\t\t\t\t\t\tif (tradeMyItemsCount[k3] < inventoryItemsCount[k])\n\t\t\t\t\t\t\t\t\t\t\ttradeMyItemsCount[k3]++;\n\t\t\t\t\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tl1++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif (inventoryCount(k2) <= l1)\n\t\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\tif (!flag && tradeMyItemCount < 12) {\n\t\t\t\t\t\t\ttradeMyItems[tradeMyItemCount] = k2;\n\t\t\t\t\t\t\ttradeMyItemsCount[tradeMyItemCount] = 1;\n\t\t\t\t\t\t\ttradeMyItemCount++;\n\t\t\t\t\t\t\tflag = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (flag) {\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(70);\n\t\t\t\t\t\t\tsuper.streamClass.addByte(tradeMyItemCount);\n\t\t\t\t\t\t\tfor (int j4 = 0; j4 < tradeMyItemCount; j4++) {\n\t\t\t\t\t\t\t\tsuper.streamClass.add2ByteInt(tradeMyItems[j4]);\n\t\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t\t.add4ByteInt(tradeMyItemsCount[j4]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\t\t\t\ttradeWeAccepted = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i > 8 && j > 30 && i < 205 && j < 133) {\n\t\t\t\t\tint l = (i - 9) / 49 + ((j - 31) / 34) * 4;\n\t\t\t\t\tif (l >= 0 && l < tradeMyItemCount) {\n\t\t\t\t\t\tint j1 = tradeMyItems[l];\n\t\t\t\t\t\tfor (int i2 = 0; i2 < itemIncrement; i2++) {\n\t\t\t\t\t\t\tif (EntityHandler.getItemDef(j1).isStackable()\n\t\t\t\t\t\t\t\t\t&& tradeMyItemsCount[l] > 1) {\n\t\t\t\t\t\t\t\ttradeMyItemsCount[l]--;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttradeMyItemCount--;\n\t\t\t\t\t\t\tmouseDownTime = 0;\n\t\t\t\t\t\t\tfor (int l2 = l; l2 < tradeMyItemCount; l2++) {\n\t\t\t\t\t\t\t\ttradeMyItems[l2] = tradeMyItems[l2 + 1];\n\t\t\t\t\t\t\t\ttradeMyItemsCount[l2] = tradeMyItemsCount[l2 + 1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.createPacket(70);\n\t\t\t\t\t\tsuper.streamClass.addByte(tradeMyItemCount);\n\t\t\t\t\t\tfor (int i3 = 0; i3 < tradeMyItemCount; i3++) {\n\t\t\t\t\t\t\tsuper.streamClass.add2ByteInt(tradeMyItems[i3]);\n\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t.add4ByteInt(tradeMyItemsCount[i3]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\t\t\ttradeWeAccepted = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i >= 217 && j >= 238 && i <= 286 && j <= 259) {\n\t\t\t\t\ttradeWeAccepted = true;\n\t\t\t\t\tsuper.streamClass.createPacket(211);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t\tif (i >= 394 && j >= 238 && i < 463 && j < 259) {\n\t\t\t\t\tshowTradeWindow = false;\n\t\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t} else if (mouseButtonClick != 0) {\n\t\t\t\tshowTradeWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\titemIncrement = 0;\n\t\t}\n\t\tif (!showTradeWindow)\n\t\t\treturn;\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 12, 192);\n\t\tint i1 = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 12, 468, 18, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 30, 8, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 205, byte1 + 30, 11, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 462, byte1 + 30, 6, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 133, 197, 22, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 258, 197, 20, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 235, 246, 43, i1, 160);\n\t\tint k1 = 0xd0d0d0;\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 30, 197, 103, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 155, 197, 103, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 30, 246, 205, k1, 160);\n\t\tfor (int j2 = 0; j2 < 4; j2++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 30 + j2 * 34, 197, 0);\n\t\tfor (int j3 = 0; j3 < 4; j3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 155 + j3 * 34, 197, 0);\n\t\tfor (int l3 = 0; l3 < 7; l3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 216, byte1 + 30 + l3 * 34, 246, 0);\n\t\tfor (int k4 = 0; k4 < 6; k4++) {\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics.drawLineY(byte0 + 8 + k4 * 49, byte1 + 30, 103, 0);\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics\n\t\t\t\t\t\t.drawLineY(byte0 + 8 + k4 * 49, byte1 + 155, 103, 0);\n\t\t\tgameGraphics.drawLineY(byte0 + 216 + k4 * 49, byte1 + 30, 205, 0);\n\t\t}\n\t\tgameGraphics.drawString(\"Trading with: \" + tradeOtherPlayerName,\n\t\t\t\tbyte0 + 1, byte1 + 10, 1, 0xffffff);\n\t\tgameGraphics.drawString(\"Your Offer\", byte0 + 9, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Opponent's Offer\", byte0 + 9, byte1 + 152, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Your Inventory\", byte0 + 216, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tif (!tradeWeAccepted)\n\t\t\tgameGraphics.drawPicture(byte0 + 217, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\tgameGraphics.drawPicture(byte0 + 394, byte1 + 238,\n\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\tif (tradeOtherAccepted) {\n\t\t\tgameGraphics.drawText(\"Other player\", byte0 + 341, byte1 + 246, 1,\n\t\t\t\t\t0xffffff);\n\t\t\tgameGraphics.drawText(\"has accepted\", byte0 + 341, byte1 + 256, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (tradeWeAccepted) {\n\t\t\tgameGraphics.drawText(\"Waiting for\", byte0 + 217 + 35, byte1 + 246,\n\t\t\t\t\t1, 0xffffff);\n\t\t\tgameGraphics.drawText(\"other player\", byte0 + 217 + 35,\n\t\t\t\t\tbyte1 + 256, 1, 0xffffff);\n\t\t}\n\t\tfor (int l4 = 0; l4 < inventoryCount; l4++) {\n\t\t\tint i5 = 217 + byte0 + (l4 % 5) * 49;\n\t\t\tint k5 = 31 + byte1 + (l4 / 5) * 34;\n\t\t\tgameGraphics.spriteClip4(i5, k5, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(getInventoryItems()[l4]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(inventoryItemsCount[l4]), i5 + 1,\n\t\t\t\t\t\tk5 + 10, 1, 0xffff00);\n\t\t}\n\t\tfor (int j5 = 0; j5 < tradeMyItemCount; j5++) {\n\t\t\tint l5 = 9 + byte0 + (j5 % 4) * 49;\n\t\t\tint j6 = 31 + byte1 + (j5 / 4) * 34;\n\t\t\tgameGraphics\n\t\t\t\t\t.spriteClip4(l5, j6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeMyItems[j5])\n\t\t\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\t\t\tEntityHandler.getItemDef(tradeMyItems[j5])\n\t\t\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(tradeMyItems[j5]).isStackable())\n\t\t\t\tgameGraphics.drawString(String.valueOf(tradeMyItemsCount[j5]),\n\t\t\t\t\t\tl5 + 1, j6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > l5 && super.mouseX < l5 + 48\n\t\t\t\t\t&& super.mouseY > j6 && super.mouseY < j6 + 32)\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getItemDef(tradeMyItems[j5]).getName()\n\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeMyItems[j5])\n\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t\tfor (int i6 = 0; i6 < tradeOtherItemCount; i6++) {\n\t\t\tint k6 = 9 + byte0 + (i6 % 4) * 49;\n\t\t\tint l6 = 156 + byte1 + (i6 / 4) * 34;\n\t\t\tgameGraphics.spriteClip4(\n\t\t\t\t\tk6,\n\t\t\t\t\tl6,\n\t\t\t\t\t48,\n\t\t\t\t\t32,\n\t\t\t\t\tSPRITE_ITEM_START\n\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeOtherItems[i6])\n\t\t\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(tradeOtherItems[i6])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(tradeOtherItems[i6]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(tradeOtherItemsCount[i6]), k6 + 1,\n\t\t\t\t\t\tl6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > k6 && super.mouseX < k6 + 48\n\t\t\t\t\t&& super.mouseY > l6 && super.mouseY < l6 + 32)\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getItemDef(tradeOtherItems[i6]).getName()\n\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(tradeOtherItems[i6])\n\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t}\n\tprivate final boolean enginePlayerVisible(int i) {\n\t\tint j = ourPlayer.currentX / 128;\n\t\tint k = ourPlayer.currentY / 128;\n\t\tfor (int l = 2; l >= 1; l--) {\n\t\t\tif (i == 1\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k - l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j - l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t- l][k - l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 3\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k + l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j - l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t- l][k + l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 5\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k + l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j + l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t+ l][k + l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 7\n\t\t\t\t\t&& ((engineHandle.walkableValue[j][k - l] & 0x80) == 128\n\t\t\t\t\t\t\t|| (engineHandle.walkableValue[j + l][k] & 0x80) == 128 || (engineHandle.walkableValue[j\n\t\t\t\t\t\t\t+ l][k - l] & 0x80) == 128))\n\t\t\t\treturn false;\n\t\t\tif (i == 0 && (engineHandle.walkableValue[j][k - l] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t\tif (i == 2 && (engineHandle.walkableValue[j - l][k] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t\tif (i == 4 && (engineHandle.walkableValue[j][k + l] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t\tif (i == 6 && (engineHandle.walkableValue[j + l][k] & 0x80) == 128)\n\t\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\tprivate Mob getLastPlayer(int serverIndex) {\n\t\tfor (int i1 = 0; i1 < lastPlayerCount; i1++) {\n\t\t\tif (lastPlayerArray[i1].serverIndex == serverIndex) {\n\t\t\t\treturn lastPlayerArray[i1];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tprivate Mob getLastNpc(int serverIndex) {\n\t\tfor (int i1 = 0; i1 < lastNpcCount; i1++) {\n\t\t\tif (lastNpcArray[i1].serverIndex == serverIndex) {\n\t\t\t\treturn lastNpcArray[i1];\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tprotected final void handleIncomingPacket(int command, int length,\n\t\t\tbyte data[]) {\n\t\ttry {\n\t\t\tif (command == 254) {\n\t\t\t\tint bar = DataOperations.getUnsigned4Bytes(data, 1);\n\t\t\t\tif (bar == -1) {\n\t\t\t\t\tsmithingscreen.isVisible = false;\n\t\t\t\t} else {\n\t\t\t\t\tSmithingScreen.changeItems(smithingscreen, bar);\n\t\t\t\t\tsmithingscreen.isVisible = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (command == 231) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 233) {\n\t\t\t\tquestPoints = DataOperations.getUnsignedByte(data[1]);\n\t\t\t\tint k = DataOperations.getUnsignedByte(data[2]);\n\t\t\t\tint r = 3;\n\t\t\t\tnewQuestNames = new String[k];\n\t\t\t\tquestStage = new byte[k];\n\t\t\t\tfor (int i = 0; i < k; i++) {\n\t\t\t\t\tint uid = DataOperations.getUnsignedByte(data[r]);\n\t\t\t\t\tr++;\n\t\t\t\t\tnewQuestNames[i] = questName[uid];\n\t\t\t\t\tquestStage[i] = (byte) DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[r]);\n\t\t\t\t\tr++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (command == 110) {\n\t\t\t\tint i = 1;\n\t\t\t\tserverStartTime = DataOperations.getUnsigned8Bytes(data, i);\n\t\t\t\ti += 8;\n\t\t\t\tserverLocation = new String(data, i, length - i);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 145) {\n\t\t\t\tif (!hasWorldInfo) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tloading = true;\n\t\t\t\tlastPlayerCount = playerCount;\n\t\t\t\tfor (int k = 0; k < lastPlayerCount; k++)\n\t\t\t\t\tlastPlayerArray[k] = playerArray[k];\n\t\t\t\tint currentOffset = 8;\n\t\t\t\tsetSectionX(DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 11));\n\t\t\t\tcurrentOffset += 11;\n\t\t\t\tsetSectionY(DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 13));\n\t\t\t\tcurrentOffset += 13;\n\t\t\t\tint mobSprite = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 4);\n\t\t\t\tcurrentOffset += 4;\n\t\t\t\tboolean sectionLoaded = loadSection(getSectionX(),\n\t\t\t\t\t\tgetSectionY());\n\t\t\t\tsetSectionX(getSectionX() - getAreaX());\n\t\t\t\tsetSectionY(getSectionY() - getAreaY());\n\t\t\t\tint mapEnterX = getSectionX() * magicLoc + 64;\n\t\t\t\tint mapEnterY = getSectionY() * magicLoc + 64;\n\t\t\t\tif (sectionLoaded) {\n\t\t\t\t\tourPlayer.waypointCurrent = 0;\n\t\t\t\t\tourPlayer.waypointEndSprite = 0;\n\t\t\t\t\tourPlayer.currentX = ourPlayer.waypointsX[0] = mapEnterX;\n\t\t\t\t\tourPlayer.currentY = ourPlayer.waypointsY[0] = mapEnterY;\n\t\t\t\t}\n\t\t\t\tplayerCount = 0;\n\t\t\t\tourPlayer = makePlayer(serverIndex, mapEnterX, mapEnterY,\n\t\t\t\t\t\tmobSprite);\n\t\t\t\tint newPlayerCount = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tcurrentOffset, 8);\n\t\t\t\tcurrentOffset += 8;\n\t\t\t\tfor (int currentNewPlayer = 0; currentNewPlayer < newPlayerCount; currentNewPlayer++) {\n\t\t\t\t\tMob lastMob = getLastPlayer(DataOperations\n\t\t\t\t\t\t\t.getIntFromByteArray(data, currentOffset, 16));\n\t\t\t\t\tcurrentOffset += 16;\n\t\t\t\t\tint nextPlayer = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 1); \n\t\t\t\t\tcurrentOffset++;\n\t\t\t\t\tif (nextPlayer != 0) {\n\t\t\t\t\t\tint waypointsLeft = DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\t\tdata, currentOffset, 1); \n\t\t\t\t\t\tcurrentOffset++;\n\t\t\t\t\t\tif (waypointsLeft == 0) {\n\t\t\t\t\t\t\tint currentNextSprite = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, currentOffset, 3); \n\t\t\t\t\t\t\tcurrentOffset += 3;\n\t\t\t\t\t\t\tint currentWaypoint = lastMob.waypointCurrent;\n\t\t\t\t\t\t\tint newWaypointX = lastMob.waypointsX[currentWaypoint];\n\t\t\t\t\t\t\tint newWaypointY = lastMob.waypointsY[currentWaypoint];\n\t\t\t\t\t\t\tif (currentNextSprite == 2\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 1\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 3)\n\t\t\t\t\t\t\t\tnewWaypointX += magicLoc;\n\t\t\t\t\t\t\tif (currentNextSprite == 6\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 5\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 7)\n\t\t\t\t\t\t\t\tnewWaypointX -= magicLoc;\n\t\t\t\t\t\t\tif (currentNextSprite == 4\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 3\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 5)\n\t\t\t\t\t\t\t\tnewWaypointY += magicLoc;\n\t\t\t\t\t\t\tif (currentNextSprite == 0\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 1\n\t\t\t\t\t\t\t\t\t|| currentNextSprite == 7)\n\t\t\t\t\t\t\t\tnewWaypointY -= magicLoc;\n\t\t\t\t\t\t\tlastMob.nextSprite = currentNextSprite;\n\t\t\t\t\t\t\tlastMob.waypointCurrent = currentWaypoint = (currentWaypoint + 1) % 10;\n\t\t\t\t\t\t\tlastMob.waypointsX[currentWaypoint] = newWaypointX;\n\t\t\t\t\t\t\tlastMob.waypointsY[currentWaypoint] = newWaypointY;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tint needsNextSprite = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, currentOffset, 4);\n\t\t\t\t\t\t\tcurrentOffset += 4;\n\t\t\t\t\t\t\tif ((needsNextSprite & 0xc) == 12) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tlastMob.nextSprite = needsNextSprite;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tplayerArray[playerCount++] = lastMob;\n\t\t\t\t}\n\t\t\t\tint mobCount = 0;\n\t\t\t\twhile (currentOffset + 24 < length * 8) {\n\t\t\t\t\tint mobIndex = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 16);\n\t\t\t\t\tcurrentOffset += 16;\n\t\t\t\t\tint areaMobX = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 5);\n\t\t\t\t\tcurrentOffset += 5;\n\t\t\t\t\tif (areaMobX > 15)\n\t\t\t\t\t\tareaMobX -= 32;\n\t\t\t\t\tint areaMobY = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 5);\n\t\t\t\t\tcurrentOffset += 5;\n\t\t\t\t\tif (areaMobY > 15)\n\t\t\t\t\t\tareaMobY -= 32;\n\t\t\t\t\tint mobArrayMobID = DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\tdata, currentOffset, 4);\n\t\t\t\t\tcurrentOffset += 4;\n\t\t\t\t\tint addIndex = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tcurrentOffset, 1);\n\t\t\t\t\tcurrentOffset++;\n\t\t\t\t\tint mobX = (getSectionX() + areaMobX) * magicLoc + 64;\n\t\t\t\t\tint mobY = (getSectionY() + areaMobY) * magicLoc + 64;\n\t\t\t\t\tmakePlayer(mobIndex, mobX, mobY, mobArrayMobID);\n\t\t\t\t\tif (addIndex == 0)\n\t\t\t\t\t\tmobArrayIndexes[mobCount++] = mobIndex;\n\t\t\t\t}\n\t\t\t\tif (mobCount > 0) {\n\t\t\t\t\tsuper.streamClass.createPacket(83);\n\t\t\t\t\tsuper.streamClass.add2ByteInt(mobCount);\n\t\t\t\t\tfor (int currentMob = 0; currentMob < mobCount; currentMob++) {\n\t\t\t\t\t\tMob dummyMob = mobArray[mobArrayIndexes[currentMob]];\n\t\t\t\t\t\tsuper.streamClass.add2ByteInt(dummyMob.serverIndex);\n\t\t\t\t\t\tsuper.streamClass.add2ByteInt(dummyMob.mobIntUnknown);\n\t\t\t\t\t}\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\tmobCount = 0;\n\t\t\t\t}\n\t\t\t\tloading = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 109) {\n\t\t\t\tfor (int l = 1; l < length;)\n\t\t\t\t\tif (DataOperations.getUnsignedByte(data[l]) == 255) { \n\t\t\t\t\t\tint newCount = 0;\n\t\t\t\t\t\tint newSectionX = getSectionX() + data[l + 1] >> 3;\n\t\t\t\t\t\tint newSectionY = getSectionY() + data[l + 2] >> 3;\n\t\t\t\t\t\tl += 3;\n\t\t\t\t\t\tfor (int groundItem = 0; groundItem < groundItemCount; groundItem++) {\n\t\t\t\t\t\t\tint newX = (groundItemX[groundItem] >> 3)\n\t\t\t\t\t\t\t\t\t- newSectionX;\n\t\t\t\t\t\t\tint newY = (groundItemY[groundItem] >> 3)\n\t\t\t\t\t\t\t\t\t- newSectionY;\n\t\t\t\t\t\t\tif (newX != 0 || newY != 0) {\n\t\t\t\t\t\t\t\tif (groundItem != newCount) {\n\t\t\t\t\t\t\t\t\tgroundItemX[newCount] = groundItemX[groundItem];\n\t\t\t\t\t\t\t\t\tgroundItemY[newCount] = groundItemY[groundItem];\n\t\t\t\t\t\t\t\t\tgroundItemType[newCount] = groundItemType[groundItem];\n\t\t\t\t\t\t\t\t\tgroundItemObjectVar[newCount] = groundItemObjectVar[groundItem];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tnewCount++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgroundItemCount = newCount;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint i8 = DataOperations.getUnsigned2Bytes(data, l);\n\t\t\t\t\t\tl += 2;\n\t\t\t\t\t\tint k14 = getSectionX() + data[l++];\n\t\t\t\t\t\tint j19 = getSectionY() + data[l++];\n\t\t\t\t\t\tif ((i8 & 0x8000) == 0) { \n\t\t\t\t\t\t\tgroundItemX[groundItemCount] = k14;\n\t\t\t\t\t\t\tgroundItemY[groundItemCount] = j19;\n\t\t\t\t\t\t\tgroundItemType[groundItemCount] = i8;\n\t\t\t\t\t\t\tgroundItemObjectVar[groundItemCount] = 0;\n\t\t\t\t\t\t\tfor (int k23 = 0; k23 < objectCount; k23++) {\n\t\t\t\t\t\t\t\tif (objectX[k23] != k14 || objectY[k23] != j19)\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\tgroundItemObjectVar[groundItemCount] = EntityHandler\n\t\t\t\t\t\t\t\t\t\t.getObjectDef(objectType[k23])\n\t\t\t\t\t\t\t\t\t\t.getGroundItemVar();\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgroundItemCount++;\n\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\ti8 &= 0x7fff;\n\t\t\t\t\t\t\tint l23 = 0;\n\t\t\t\t\t\t\tfor (int k26 = 0; k26 < groundItemCount; k26++) {\n\t\t\t\t\t\t\t\tif (groundItemX[k26] != k14\n\t\t\t\t\t\t\t\t\t\t|| groundItemY[k26] != j19\n\t\t\t\t\t\t\t\t\t\t|| groundItemType[k26] != i8) { \n\t\t\t\t\t\t\t\t\tif (k26 != l23) {\n\t\t\t\t\t\t\t\t\t\tgroundItemX[l23] = groundItemX[k26];\n\t\t\t\t\t\t\t\t\t\tgroundItemY[l23] = groundItemY[k26];\n\t\t\t\t\t\t\t\t\t\tgroundItemType[l23] = groundItemType[k26];\n\t\t\t\t\t\t\t\t\t\tgroundItemObjectVar[l23] = groundItemObjectVar[k26];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tl23++;\n\t\t\t\t\t\t\t\t} else { \n\t\t\t\t\t\t\t\t\ti8 = -123;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tgroundItemCount = l23;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 27) {\n\t\t\t\tfor (int i1 = 1; i1 < length;)\n\t\t\t\t\tif (DataOperations.getUnsignedByte(data[i1]) == 255) {\n\t\t\t\t\t\tint j8 = 0;\n\t\t\t\t\t\tint l14 = getSectionX() + data[i1 + 1] >> 3;\n\t\t\t\t\t\tint k19 = getSectionY() + data[i1 + 2] >> 3;\n\t\t\t\t\t\ti1 += 3;\n\t\t\t\t\t\tfor (int i24 = 0; i24 < objectCount; i24++) {\n\t\t\t\t\t\t\tint l26 = (objectX[i24] >> 3) - l14;\n\t\t\t\t\t\t\tint k29 = (objectY[i24] >> 3) - k19;\n\t\t\t\t\t\t\tif (l26 != 0 || k29 != 0) {\n\t\t\t\t\t\t\t\tif (i24 != j8) {\n\t\t\t\t\t\t\t\t\tobjectModelArray[j8] = objectModelArray[i24];\n\t\t\t\t\t\t\t\t\tobjectModelArray[j8].anInt257 = j8;\n\t\t\t\t\t\t\t\t\tobjectX[j8] = objectX[i24];\n\t\t\t\t\t\t\t\t\tobjectY[j8] = objectY[i24];\n\t\t\t\t\t\t\t\t\tobjectType[j8] = objectType[i24];\n\t\t\t\t\t\t\t\t\tobjectID[j8] = objectID[i24];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tj8++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(objectModelArray[i24]);\n\t\t\t\t\t\t\t\tengineHandle.updateObject(objectX[i24],\n\t\t\t\t\t\t\t\t\t\tobjectY[i24], objectType[i24],\n\t\t\t\t\t\t\t\t\t\tobjectID[i24]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tobjectCount = j8;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint k8 = DataOperations.getUnsigned2Bytes(data, i1);\n\t\t\t\t\t\ti1 += 2;\n\t\t\t\t\t\tint i15 = getSectionX() + data[i1++];\n\t\t\t\t\t\tint l19 = getSectionY() + data[i1++];\n\t\t\t\t\t\tint l29 = data[i1++];\n\t\t\t\t\t\tint j24 = 0;\n\t\t\t\t\t\tfor (int i27 = 0; i27 < objectCount; i27++)\n\t\t\t\t\t\t\tif (objectX[i27] != i15 || objectY[i27] != l19\n\t\t\t\t\t\t\t\t\t|| objectID[i27] != l29) {\n\t\t\t\t\t\t\t\tif (i27 != j24) {\n\t\t\t\t\t\t\t\t\tobjectModelArray[j24] = objectModelArray[i27];\n\t\t\t\t\t\t\t\t\tobjectModelArray[j24].anInt257 = j24;\n\t\t\t\t\t\t\t\t\tobjectX[j24] = objectX[i27];\n\t\t\t\t\t\t\t\t\tobjectY[j24] = objectY[i27];\n\t\t\t\t\t\t\t\t\tobjectType[j24] = objectType[i27];\n\t\t\t\t\t\t\t\t\tobjectID[j24] = objectID[i27];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tj24++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(objectModelArray[i27]);\n\t\t\t\t\t\t\t\tengineHandle.updateObject(objectX[i27],\n\t\t\t\t\t\t\t\t\t\tobjectY[i27], objectType[i27],\n\t\t\t\t\t\t\t\t\t\tobjectID[i27]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tobjectCount = j24;\n\t\t\t\t\t\tif (k8 != 60000) {\n\t\t\t\t\t\t\tengineHandle.registerObjectDir(i15, l19, l29);\n\t\t\t\t\t\t\tint i34;\n\t\t\t\t\t\t\tint j37;\n\t\t\t\t\t\t\tif (l29 == 0 || l29 == 4) {\n\t\t\t\t\t\t\t\ti34 = EntityHandler.getObjectDef(k8).getWidth();\n\t\t\t\t\t\t\t\tj37 = EntityHandler.getObjectDef(k8)\n\t\t\t\t\t\t\t\t\t\t.getHeight();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tj37 = EntityHandler.getObjectDef(k8).getWidth();\n\t\t\t\t\t\t\t\ti34 = EntityHandler.getObjectDef(k8)\n\t\t\t\t\t\t\t\t\t\t.getHeight();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tint j40 = ((i15 + i15 + i34) * magicLoc) / 2;\n\t\t\t\t\t\t\tint i42 = ((l19 + l19 + j37) * magicLoc) / 2;\n\t\t\t\t\t\t\tint k43 = EntityHandler.getObjectDef(k8).modelID;\n\t\t\t\t\t\t\tModel model_1 = gameDataModels[k43].method203();\n\t\t\t\t\t\t\tgameCamera.addModel(model_1);\n\t\t\t\t\t\t\tmodel_1.anInt257 = objectCount;\n\t\t\t\t\t\t\tmodel_1.method188(0, l29 * 32, 0);\n\t\t\t\t\t\t\tmodel_1.method190(j40, -engineHandle\n\t\t\t\t\t\t\t\t\t.getAveragedElevation(j40, i42), i42);\n\t\t\t\t\t\t\tmodel_1.method184(true, 48, 48, -50, -10, -50);\n\t\t\t\t\t\t\tengineHandle.method412(i15, l19, k8, l29);\n\t\t\t\t\t\t\tif (k8 == 74)\n\t\t\t\t\t\t\t\tmodel_1.method190(0, -480, 0);\n\t\t\t\t\t\t\tobjectX[objectCount] = i15;\n\t\t\t\t\t\t\tobjectY[objectCount] = l19;\n\t\t\t\t\t\t\tobjectType[objectCount] = k8;\n\t\t\t\t\t\t\tobjectID[objectCount] = l29;\n\t\t\t\t\t\t\tobjectModelArray[objectCount++] = model_1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 114) {\n\t\t\t\tint invOffset = 1;\n\t\t\t\tinventoryCount = data[invOffset++] & 0xff;\n\t\t\t\tfor (int invItem = 0; invItem < inventoryCount; invItem++) {\n\t\t\t\t\tint j15 = DataOperations.getUnsigned2Bytes(data, invOffset);\n\t\t\t\t\tinvOffset += 2;\n\t\t\t\t\tgetInventoryItems()[invItem] = (j15 & 0x7fff);\n\t\t\t\t\twearing[invItem] = j15 / 32768;\n\t\t\t\t\tif (EntityHandler.getItemDef(j15 & 0x7fff).isStackable()) {\n\t\t\t\t\t\tinventoryItemsCount[invItem] = DataOperations.readInt(\n\t\t\t\t\t\t\t\tdata, invOffset);\n\t\t\t\t\t\tinvOffset += 4;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tinventoryItemsCount[invItem] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 53) {\n\t\t\t\tint mobCount = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tint mobUpdateOffset = 3;\n\t\t\t\tfor (int currentMob = 0; currentMob < mobCount; currentMob++) {\n\t\t\t\t\tint mobArrayIndex = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\tif (mobArrayIndex < 0 || mobArrayIndex > mobArray.length) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tMob mob = mobArray[mobArrayIndex];\n\t\t\t\t\tif (mob == null) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tbyte mobUpdateType = data[mobUpdateOffset++];\n\t\t\t\t\tif (mobUpdateType == 0) {\n\t\t\t\t\t\tint i30 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.anInt163 = 150;\n\t\t\t\t\t\t\tmob.anInt162 = i30;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 1) { \n\t\t\t\t\t\tbyte byte7 = data[mobUpdateOffset++];\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tString s2 = DataConversions.byteToString(data,\n\t\t\t\t\t\t\t\t\tmobUpdateOffset, byte7);\n\t\t\t\t\t\t\tmob.lastMessageTimeout = 150;\n\t\t\t\t\t\t\tmob.lastMessage = s2;\n\t\t\t\t\t\t\tdisplayMessage(mob.name + \": \" + mob.lastMessage,\n\t\t\t\t\t\t\t\t\t2, mob.admin);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmobUpdateOffset += byte7;\n\t\t\t\t\t} else if (mobUpdateType == 2) { \n\t\t\t\t\t\tint j30 = DataOperations\n\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset++]);\n\t\t\t\t\t\tint hits = DataOperations\n\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset++]);\n\t\t\t\t\t\tint hitsBase = DataOperations\n\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset++]);\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.anInt164 = j30;\n\t\t\t\t\t\t\tmob.hitPointsCurrent = hits;\n\t\t\t\t\t\t\tmob.hitPointsBase = hitsBase;\n\t\t\t\t\t\t\tmob.combatTimer = 200;\n\t\t\t\t\t\t\tif (mob == ourPlayer) {\n\t\t\t\t\t\t\t\tplayerStatCurrent[3] = hits;\n\t\t\t\t\t\t\t\tplayerStatBase[3] = hitsBase;\n\t\t\t\t\t\t\t\tshowWelcomeBox = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 3) { \n\t\t\t\t\t\tint k30 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tint k34 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.attackingCameraInt = k30;\n\t\t\t\t\t\t\tmob.attackingNpcIndex = k34;\n\t\t\t\t\t\t\tmob.attackingMobIndex = -1;\n\t\t\t\t\t\t\tmob.anInt176 = attackingInt40;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 4) { \n\t\t\t\t\t\tint l30 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tint l34 = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\t\tmobUpdateOffset);\n\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.attackingCameraInt = l30;\n\t\t\t\t\t\t\tmob.attackingMobIndex = l34;\n\t\t\t\t\t\t\tmob.attackingNpcIndex = -1;\n\t\t\t\t\t\t\tmob.anInt176 = attackingInt40;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 5) { \n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tmob.mobIntUnknown = DataOperations\n\t\t\t\t\t\t\t\t\t.getUnsigned2Bytes(data, mobUpdateOffset);\n\t\t\t\t\t\t\tmobUpdateOffset += 2;\n\t\t\t\t\t\t\tmob.nameLong = DataOperations.getUnsigned8Bytes(\n\t\t\t\t\t\t\t\t\tdata, mobUpdateOffset);\n\t\t\t\t\t\t\tmobUpdateOffset += 8;\n\t\t\t\t\t\t\tmob.name = DataOperations\n\t\t\t\t\t\t\t\t\t.longToString(mob.nameLong);\n\t\t\t\t\t\t\tint i31 = DataOperations\n\t\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset]);\n\t\t\t\t\t\t\tmobUpdateOffset++;\n\t\t\t\t\t\t\tfor (int i35 = 0; i35 < i31; i35++) {\n\t\t\t\t\t\t\t\tmob.animationCount[i35] = DataOperations\n\t\t\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset]);\n\t\t\t\t\t\t\t\tmobUpdateOffset++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (int l37 = i31; l37 < 12; l37++)\n\t\t\t\t\t\t\t\tmob.animationCount[l37] = 0;\n\t\t\t\t\t\t\tmob.colourHairType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.colourTopType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.colourBottomType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.colourSkinType = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.level = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.anInt179 = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t\tmob.admin = data[mobUpdateOffset++] & 0xff;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmobUpdateOffset += 14;\n\t\t\t\t\t\t\tint j31 = DataOperations\n\t\t\t\t\t\t\t\t\t.getUnsignedByte(data[mobUpdateOffset]);\n\t\t\t\t\t\t\tmobUpdateOffset += j31 + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (mobUpdateType == 6) { \n\t\t\t\t\t\tbyte byte8 = data[mobUpdateOffset];\n\t\t\t\t\t\tmobUpdateOffset++;\n\t\t\t\t\t\tif (mob != null) {\n\t\t\t\t\t\t\tString s3 = DataConversions.byteToString(data,\n\t\t\t\t\t\t\t\t\tmobUpdateOffset, byte8);\n\t\t\t\t\t\t\tmob.lastMessageTimeout = 150;\n\t\t\t\t\t\t\tmob.lastMessage = s3;\n\t\t\t\t\t\t\tif (mob == ourPlayer)\n\t\t\t\t\t\t\t\tdisplayMessage(mob.name + \": \"\n\t\t\t\t\t\t\t\t\t\t+ mob.lastMessage, 5, mob.admin);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmobUpdateOffset += byte8;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 129) {\n\t\t\t\tcombatStyle = DataOperations.getUnsignedByte(data[1]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 95) {\n\t\t\t\tfor (int l1 = 1; l1 < length;)\n\t\t\t\t\tif (DataOperations.getUnsignedByte(data[l1]) == 255) {\n\t\t\t\t\t\tint j9 = 0;\n\t\t\t\t\t\tint l15 = getSectionX() + data[l1 + 1] >> 3;\n\t\t\t\t\t\tint j20 = getSectionY() + data[l1 + 2] >> 3;\n\t\t\t\t\t\tl1 += 3;\n\t\t\t\t\t\tfor (int currentDoor = 0; currentDoor < doorCount; currentDoor++) {\n\t\t\t\t\t\t\tint j27 = (doorX[currentDoor] >> 3) - l15;\n\t\t\t\t\t\t\tint k31 = (doorY[currentDoor] >> 3) - j20;\n\t\t\t\t\t\t\tif (j27 != 0 || k31 != 0) {\n\t\t\t\t\t\t\t\tif (currentDoor != j9) {\n\t\t\t\t\t\t\t\t\tdoorModel[j9] = doorModel[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorModel[j9].anInt257 = j9 + 10000;\n\t\t\t\t\t\t\t\t\tdoorX[j9] = doorX[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorY[j9] = doorY[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorDirection[j9] = doorDirection[currentDoor];\n\t\t\t\t\t\t\t\t\tdoorType[j9] = doorType[currentDoor];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tj9++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(doorModel[currentDoor]);\n\t\t\t\t\t\t\t\tengineHandle.updateDoor(doorX[currentDoor],\n\t\t\t\t\t\t\t\t\t\tdoorY[currentDoor],\n\t\t\t\t\t\t\t\t\t\tdoorDirection[currentDoor],\n\t\t\t\t\t\t\t\t\t\tdoorType[currentDoor]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdoorCount = j9;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint k9 = DataOperations.getUnsigned2Bytes(data, l1);\n\t\t\t\t\t\tl1 += 2;\n\t\t\t\t\t\tint i16 = getSectionX() + data[l1++];\n\t\t\t\t\t\tint k20 = getSectionY() + data[l1++];\n\t\t\t\t\t\tbyte byte5 = data[l1++];\n\t\t\t\t\t\tint k27 = 0;\n\t\t\t\t\t\tfor (int l31 = 0; l31 < doorCount; l31++)\n\t\t\t\t\t\t\tif (doorX[l31] != i16 || doorY[l31] != k20\n\t\t\t\t\t\t\t\t\t|| doorDirection[l31] != byte5) {\n\t\t\t\t\t\t\t\tif (l31 != k27) {\n\t\t\t\t\t\t\t\t\tdoorModel[k27] = doorModel[l31];\n\t\t\t\t\t\t\t\t\tdoorModel[k27].anInt257 = k27 + 10000;\n\t\t\t\t\t\t\t\t\tdoorX[k27] = doorX[l31];\n\t\t\t\t\t\t\t\t\tdoorY[k27] = doorY[l31];\n\t\t\t\t\t\t\t\t\tdoorDirection[k27] = doorDirection[l31];\n\t\t\t\t\t\t\t\t\tdoorType[k27] = doorType[l31];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tk27++;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tgameCamera.removeModel(doorModel[l31]);\n\t\t\t\t\t\t\t\tengineHandle.updateDoor(doorX[l31], doorY[l31],\n\t\t\t\t\t\t\t\t\t\tdoorDirection[l31], doorType[l31]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tdoorCount = k27;\n\t\t\t\t\t\tif (k9 != 60000) { \n\t\t\t\t\t\t\tengineHandle.method408(i16, k20, byte5, k9);\n\t\t\t\t\t\t\tModel model = makeModel(i16, k20, byte5, k9,\n\t\t\t\t\t\t\t\t\tdoorCount);\n\t\t\t\t\t\t\tdoorModel[doorCount] = model;\n\t\t\t\t\t\t\tdoorX[doorCount] = i16;\n\t\t\t\t\t\t\tdoorY[doorCount] = k20;\n\t\t\t\t\t\t\tdoorType[doorCount] = k9;\n\t\t\t\t\t\t\tdoorDirection[doorCount++] = byte5;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 77) {\n\t\t\t\tlastNpcCount = npcCount;\n\t\t\t\tnpcCount = 0;\n\t\t\t\tfor (int lastNpcIndex = 0; lastNpcIndex < lastNpcCount; lastNpcIndex++)\n\t\t\t\t\tlastNpcArray[lastNpcIndex] = npcArray[lastNpcIndex];\n\t\t\t\tint newNpcOffset = 8;\n\t\t\t\tint newNpcCount = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\tnewNpcOffset, 8);\n\t\t\t\tnewNpcOffset += 8;\n\t\t\t\tfor (int newNpcIndex = 0; newNpcIndex < newNpcCount; newNpcIndex++) {\n\t\t\t\t\tMob newNPC = getLastNpc(DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\tdata, newNpcOffset, 16));\n\t\t\t\t\tnewNpcOffset += 16;\n\t\t\t\t\tint npcNeedsUpdate = DataOperations.getIntFromByteArray(\n\t\t\t\t\t\t\tdata, newNpcOffset, 1);\n\t\t\t\t\tnewNpcOffset++;\n\t\t\t\t\tif (npcNeedsUpdate != 0) {\n\t\t\t\t\t\tint i32 = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\t\tnewNpcOffset, 1);\n\t\t\t\t\t\tnewNpcOffset++;\n\t\t\t\t\t\tif (i32 == 0) {\n\t\t\t\t\t\t\tint nextSprite = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, newNpcOffset, 3);\n\t\t\t\t\t\t\tnewNpcOffset += 3;\n\t\t\t\t\t\t\tint waypointCurrent = newNPC.waypointCurrent;\n\t\t\t\t\t\t\tint waypointX = newNPC.waypointsX[waypointCurrent];\n\t\t\t\t\t\t\tint waypointY = newNPC.waypointsY[waypointCurrent];\n\t\t\t\t\t\t\tif (nextSprite == 2 || nextSprite == 1\n\t\t\t\t\t\t\t\t\t|| nextSprite == 3)\n\t\t\t\t\t\t\t\twaypointX += magicLoc;\n\t\t\t\t\t\t\tif (nextSprite == 6 || nextSprite == 5\n\t\t\t\t\t\t\t\t\t|| nextSprite == 7)\n\t\t\t\t\t\t\t\twaypointX -= magicLoc;\n\t\t\t\t\t\t\tif (nextSprite == 4 || nextSprite == 3\n\t\t\t\t\t\t\t\t\t|| nextSprite == 5)\n\t\t\t\t\t\t\t\twaypointY += magicLoc;\n\t\t\t\t\t\t\tif (nextSprite == 0 || nextSprite == 1\n\t\t\t\t\t\t\t\t\t|| nextSprite == 7)\n\t\t\t\t\t\t\t\twaypointY -= magicLoc;\n\t\t\t\t\t\t\tnewNPC.nextSprite = nextSprite;\n\t\t\t\t\t\t\tnewNPC.waypointCurrent = waypointCurrent = (waypointCurrent + 1) % 10;\n\t\t\t\t\t\t\tnewNPC.waypointsX[waypointCurrent] = waypointX;\n\t\t\t\t\t\t\tnewNPC.waypointsY[waypointCurrent] = waypointY;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tint nextSpriteOffset = DataOperations\n\t\t\t\t\t\t\t\t\t.getIntFromByteArray(data, newNpcOffset, 4);\n\t\t\t\t\t\t\tnewNpcOffset += 4;\n\t\t\t\t\t\t\tif ((nextSpriteOffset & 0xc) == 12) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tnewNPC.nextSprite = nextSpriteOffset;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnpcArray[npcCount++] = newNPC;\n\t\t\t\t}\n\t\t\t\twhile (newNpcOffset + 34 < length * 8) {\n\t\t\t\t\tint serverIndex = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 16);\n\t\t\t\t\tnewNpcOffset += 16;\n\t\t\t\t\tint i28 = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 5);\n\t\t\t\t\tnewNpcOffset += 5;\n\t\t\t\t\tif (i28 > 15)\n\t\t\t\t\t\ti28 -= 32;\n\t\t\t\t\tint j32 = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 5);\n\t\t\t\t\tnewNpcOffset += 5;\n\t\t\t\t\tif (j32 > 15)\n\t\t\t\t\t\tj32 -= 32;\n\t\t\t\t\tint nextSprite = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 4);\n\t\t\t\t\tnewNpcOffset += 4;\n\t\t\t\t\tint x = (getSectionX() + i28) * magicLoc + 64;\n\t\t\t\t\tint y = (getSectionY() + j32) * magicLoc + 64;\n\t\t\t\t\tint type = DataOperations.getIntFromByteArray(data,\n\t\t\t\t\t\t\tnewNpcOffset, 10);\n\t\t\t\t\tnewNpcOffset += 10;\n\t\t\t\t\tif (type >= EntityHandler.npcCount())\n\t\t\t\t\t\ttype = 24;\n\t\t\t\t\taddNPC(serverIndex, x, y, nextSprite, type);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 190) {\n\t\t\t\tint j2 = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tint i10 = 3;\n\t\t\t\tfor (int k16 = 0; k16 < j2; k16++) {\n\t\t\t\t\tint i21 = DataOperations.getUnsigned2Bytes(data, i10);\n\t\t\t\t\ti10 += 2;\n\t\t\t\t\tMob mob_2 = npcRecordArray[i21];\n\t\t\t\t\tint j28 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\ti10++;\n\t\t\t\t\tif (j28 == 1) {\n\t\t\t\t\t\tint k32 = DataOperations.getUnsigned2Bytes(data, i10);\n\t\t\t\t\t\ti10 += 2;\n\t\t\t\t\t\tbyte byte9 = data[i10];\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tif (mob_2 != null) {\n\t\t\t\t\t\t\tString s4 = DataConversions.byteToString(data, i10,\n\t\t\t\t\t\t\t\t\tbyte9);\n\t\t\t\t\t\t\tmob_2.lastMessageTimeout = 150;\n\t\t\t\t\t\t\tmob_2.lastMessage = s4;\n\t\t\t\t\t\t\tif (k32 == ourPlayer.serverIndex)\n\t\t\t\t\t\t\t\tdisplayMessage(\"@yel@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getNpcDef(mob_2.type)\n\t\t\t\t\t\t\t\t\t\t\t\t.getName() + \": \"\n\t\t\t\t\t\t\t\t\t\t+ mob_2.lastMessage, 5, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti10 += byte9;\n\t\t\t\t\t} else if (j28 == 2) {\n\t\t\t\t\t\tint l32 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tint i36 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tint k38 = DataOperations.getUnsignedByte(data[i10]);\n\t\t\t\t\t\ti10++;\n\t\t\t\t\t\tif (mob_2 != null) {\n\t\t\t\t\t\t\tmob_2.anInt164 = l32;\n\t\t\t\t\t\t\tmob_2.hitPointsCurrent = i36;\n\t\t\t\t\t\t\tmob_2.hitPointsBase = k38;\n\t\t\t\t\t\t\tmob_2.combatTimer = 200;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 223) {\n\t\t\t\tshowQuestionMenu = true;\n\t\t\t\tint newQuestionMenuCount = DataOperations\n\t\t\t\t\t\t.getUnsignedByte(data[1]);\n\t\t\t\tquestionMenuCount = newQuestionMenuCount;\n\t\t\t\tint newQuestionMenuOffset = 2;\n\t\t\t\tfor (int l16 = 0; l16 < newQuestionMenuCount; l16++) {\n\t\t\t\t\tint newQuestionMenuQuestionLength = DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[newQuestionMenuOffset]);\n\t\t\t\t\tnewQuestionMenuOffset++;\n\t\t\t\t\tquestionMenuAnswer[l16] = new String(data,\n\t\t\t\t\t\t\tnewQuestionMenuOffset,\n\t\t\t\t\t\t\tnewQuestionMenuQuestionLength);\n\t\t\t\t\tnewQuestionMenuOffset += newQuestionMenuQuestionLength;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 127) {\n\t\t\t\tshowQuestionMenu = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 131) {\n\t\t\t\tneedsClear = true;\n\t\t\t\tnotInWilderness = true;\n\t\t\t\thasWorldInfo = true;\n\t\t\t\tserverIndex = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\twildX = DataOperations.getUnsigned2Bytes(data, 3);\n\t\t\t\twildY = DataOperations.getUnsigned2Bytes(data, 5);\n\t\t\t\twildYSubtract = DataOperations.getUnsigned2Bytes(data, 7);\n\t\t\t\twildYMultiplier = DataOperations.getUnsigned2Bytes(data, 9);\n\t\t\t\twildY -= wildYSubtract * wildYMultiplier;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 180) {\n\t\t\t\tint l2 = 1;\n\t\t\t\tfor (int k10 = 0; k10 < 18; k10++) {\n\t\t\t\t\tplayerStatCurrent[k10] = DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[l2++]);\n\t\t\t\t}\n\t\t\t\tfor (int i17 = 0; i17 < 18; i17++) {\n\t\t\t\t\tplayerStatBase[i17] = DataOperations\n\t\t\t\t\t\t\t.getUnsignedByte(data[l2++]);\n\t\t\t\t}\n\t\t\t\tfor (int k21 = 0; k21 < 18; k21++) {\n\t\t\t\t\tplayerStatExperience[k21] = DataOperations\n\t\t\t\t\t\t\t.readInt(data, l2);\n\t\t\t\t\tl2 += 4;\n\t\t\t\t}\n\t\t\t\texpGained = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 177) {\n\t\t\t\tint i3 = 1;\n\t\t\t\tfor (int x = 0; x < 6; x++) {\n\t\t\t\t\tequipmentStatus[x] = DataOperations.getSigned2Bytes(data,\n\t\t\t\t\t\t\ti3);\n\t\t\t\t\ti3 += 2;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 165) {\n\t\t\t\tplayerAliveTimeout = 250;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 115) {\n\t\t\t\tint thingLength = (length - 1) / 4;\n\t\t\t\tfor (int currentThing = 0; currentThing < thingLength; currentThing++) {\n\t\t\t\t\tint currentItemSectionX = getSectionX()\n\t\t\t\t\t\t\t+ DataOperations.getSigned2Bytes(data,\n\t\t\t\t\t\t\t\t\t1 + currentThing * 4) >> 3;\n\t\t\t\t\tint currentItemSectionY = getSectionY()\n\t\t\t\t\t\t\t+ DataOperations.getSigned2Bytes(data,\n\t\t\t\t\t\t\t\t\t3 + currentThing * 4) >> 3;\n\t\t\t\t\tint currentCount = 0;\n\t\t\t\t\tfor (int currentItem = 0; currentItem < groundItemCount; currentItem++) {\n\t\t\t\t\t\tint currentItemOffsetX = (groundItemX[currentItem] >> 3)\n\t\t\t\t\t\t\t\t- currentItemSectionX;\n\t\t\t\t\t\tint currentItemOffsetY = (groundItemY[currentItem] >> 3)\n\t\t\t\t\t\t\t\t- currentItemSectionY;\n\t\t\t\t\t\tif (currentItemOffsetX != 0 || currentItemOffsetY != 0) {\n\t\t\t\t\t\t\tif (currentItem != currentCount) {\n\t\t\t\t\t\t\t\tgroundItemX[currentCount] = groundItemX[currentItem];\n\t\t\t\t\t\t\t\tgroundItemY[currentCount] = groundItemY[currentItem];\n\t\t\t\t\t\t\t\tgroundItemType[currentCount] = groundItemType[currentItem];\n\t\t\t\t\t\t\t\tgroundItemObjectVar[currentCount] = groundItemObjectVar[currentItem];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentCount++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tgroundItemCount = currentCount;\n\t\t\t\t\tcurrentCount = 0;\n\t\t\t\t\tfor (int j33 = 0; j33 < objectCount; j33++) {\n\t\t\t\t\t\tint k36 = (objectX[j33] >> 3) - currentItemSectionX;\n\t\t\t\t\t\tint l38 = (objectY[j33] >> 3) - currentItemSectionY;\n\t\t\t\t\t\tif (k36 != 0 || l38 != 0) {\n\t\t\t\t\t\t\tif (j33 != currentCount) {\n\t\t\t\t\t\t\t\tobjectModelArray[currentCount] = objectModelArray[j33];\n\t\t\t\t\t\t\t\tobjectModelArray[currentCount].anInt257 = currentCount;\n\t\t\t\t\t\t\t\tobjectX[currentCount] = objectX[j33];\n\t\t\t\t\t\t\t\tobjectY[currentCount] = objectY[j33];\n\t\t\t\t\t\t\t\tobjectType[currentCount] = objectType[j33];\n\t\t\t\t\t\t\t\tobjectID[currentCount] = objectID[j33];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentCount++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgameCamera.removeModel(objectModelArray[j33]);\n\t\t\t\t\t\t\tengineHandle.updateObject(objectX[j33],\n\t\t\t\t\t\t\t\t\tobjectY[j33], objectType[j33],\n\t\t\t\t\t\t\t\t\tobjectID[j33]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tobjectCount = currentCount;\n\t\t\t\t\tcurrentCount = 0;\n\t\t\t\t\tfor (int l36 = 0; l36 < doorCount; l36++) {\n\t\t\t\t\t\tint i39 = (doorX[l36] >> 3) - currentItemSectionX;\n\t\t\t\t\t\tint j41 = (doorY[l36] >> 3) - currentItemSectionY;\n\t\t\t\t\t\tif (i39 != 0 || j41 != 0) {\n\t\t\t\t\t\t\tif (l36 != currentCount) {\n\t\t\t\t\t\t\t\tdoorModel[currentCount] = doorModel[l36];\n\t\t\t\t\t\t\t\tdoorModel[currentCount].anInt257 = currentCount + 10000;\n\t\t\t\t\t\t\t\tdoorX[currentCount] = doorX[l36];\n\t\t\t\t\t\t\t\tdoorY[currentCount] = doorY[l36];\n\t\t\t\t\t\t\t\tdoorDirection[currentCount] = doorDirection[l36];\n\t\t\t\t\t\t\t\tdoorType[currentCount] = doorType[l36];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcurrentCount++;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgameCamera.removeModel(doorModel[l36]);\n\t\t\t\t\t\t\tengineHandle.updateDoor(doorX[l36], doorY[l36],\n\t\t\t\t\t\t\t\t\tdoorDirection[l36], doorType[l36]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdoorCount = currentCount;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 230) {\n\t\t\t\tshowDrawPointsScreen = true;\n\t\t\t\tint pkbytes = 1;\n\t\t\t\tpkatk = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkdef = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkstr = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkrange = DataOperations.readInt(data, pkbytes);\n\t\t\t\tpkbytes += 4;\n\t\t\t\tpkmagic = DataOperations.readInt(data, pkbytes);\n\t\t\t}\n\t\t\tif (command == 207) {\n\t\t\t\tshowCharacterLookScreen = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 4) {\n\t\t\t\tint currentMob = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tif (mobArray[currentMob] != null) \n\t\t\t\t\ttradeOtherPlayerName = mobArray[currentMob].name;\n\t\t\t\tshowTradeWindow = true;\n\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\ttradeWeAccepted = false;\n\t\t\t\ttradeMyItemCount = 0;\n\t\t\t\ttradeOtherItemCount = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 187) {\n\t\t\t\tshowTradeWindow = false;\n\t\t\t\tshowTradeConfirmWindow = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 250) {\n\t\t\t\ttradeOtherItemCount = data[1] & 0xff;\n\t\t\t\tint l3 = 2;\n\t\t\t\tfor (int i11 = 0; i11 < tradeOtherItemCount; i11++) {\n\t\t\t\t\ttradeOtherItems[i11] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, l3);\n\t\t\t\t\tl3 += 2;\n\t\t\t\t\ttradeOtherItemsCount[i11] = DataOperations\n\t\t\t\t\t\t\t.readInt(data, l3);\n\t\t\t\t\tl3 += 4;\n\t\t\t\t}\n\t\t\t\ttradeOtherAccepted = false;\n\t\t\t\ttradeWeAccepted = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 92) {\n\t\t\t\ttradeOtherAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 253) {\n\t\t\t\tshowShop = true;\n\t\t\t\tint i4 = 1;\n\t\t\t\tint j11 = data[i4++] & 0xff;\n\t\t\t\tbyte byte4 = data[i4++];\n\t\t\t\tshopItemSellPriceModifier = data[i4++] & 0xff;\n\t\t\t\tshopItemBuyPriceModifier = data[i4++] & 0xff;\n\t\t\t\tfor (int i22 = 0; i22 < 40; i22++)\n\t\t\t\t\tshopItems[i22] = -1;\n\t\t\t\tfor (int j25 = 0; j25 < j11; j25++) {\n\t\t\t\t\tshopItems[j25] = DataOperations.getUnsigned2Bytes(data, i4);\n\t\t\t\t\ti4 += 2;\n\t\t\t\t\tshopItemCount[j25] = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\ti4);\n\t\t\t\t\ti4 += 2;\n\t\t\t\t\tshopItemsBuyPrice[j25] = DataOperations.getUnsigned4Bytes(\n\t\t\t\t\t\t\tdata, i4);\n\t\t\t\t\ti4 += 4;\n\t\t\t\t\tshopItemsSellPrice[j25] = DataOperations.getUnsigned4Bytes(\n\t\t\t\t\t\t\tdata, i4);\n\t\t\t\t\ti4 += 4;\n\t\t\t\t}\n\t\t\t\tif (byte4 == 1) {\n\t\t\t\t\tint l28 = 39;\n\t\t\t\t\tfor (int k33 = 0; k33 < inventoryCount; k33++) {\n\t\t\t\t\t\tif (l28 < j11)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tboolean flag2 = false;\n\t\t\t\t\t\tfor (int j39 = 0; j39 < 40; j39++) {\n\t\t\t\t\t\t\tif (shopItems[j39] != getInventoryItems()[k33])\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tflag2 = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (getInventoryItems()[k33] == 10)\n\t\t\t\t\t\t\tflag2 = true;\n\t\t\t\t\t\tif (!flag2) {\n\t\t\t\t\t\t\tshopItems[l28] = getInventoryItems()[k33] & 0x7fff;\n\t\t\t\t\t\t\tshopItemsSellPrice[l28] = EntityHandler\n\t\t\t\t\t\t\t\t\t.getItemDef(shopItems[l28]).basePrice\n\t\t\t\t\t\t\t\t\t- (int) (EntityHandler\n\t\t\t\t\t\t\t\t\t\t\t.getItemDef(shopItems[l28]).basePrice / 2.5);\n\t\t\t\t\t\t\tshopItemsSellPrice[l28] = shopItemsSellPrice[l28]\n\t\t\t\t\t\t\t\t\t- (int) (shopItemsSellPrice[l28] * 0.10);\n\t\t\t\t\t\t\tshopItemCount[l28] = 0;\n\t\t\t\t\t\t\tl28--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (selectedShopItemIndex >= 0\n\t\t\t\t\t\t&& selectedShopItemIndex < 40\n\t\t\t\t\t\t&& shopItems[selectedShopItemIndex] != selectedShopItemType) {\n\t\t\t\t\tselectedShopItemIndex = -1;\n\t\t\t\t\tselectedShopItemType = -2;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 220) {\n\t\t\t\tshowShop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 18) {\n\t\t\t\ttradeWeAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 152) {\n\t\t\t\tconfigAutoCameraAngle = DataOperations.getUnsignedByte(data[1]) == 1;\n\t\t\t\tconfigMouseButtons = DataOperations.getUnsignedByte(data[2]) == 1;\n\t\t\t\tconfigSoundEffects = DataOperations.getUnsignedByte(data[3]) == 1;\n\t\t\t\tshowRoof = DataOperations.getUnsignedByte(data[4]) == 1;\n\t\t\t\tautoScreenshot = DataOperations.getUnsignedByte(data[5]) == 1;\n\t\t\t\tcombatWindow = DataOperations.getUnsignedByte(data[6]) == 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 209) {\n\t\t\t\tfor (int currentPrayer = 0; currentPrayer < length - 1; currentPrayer++) {\n\t\t\t\t\tboolean prayerOff = data[currentPrayer + 1] == 1;\n\t\t\t\t\tif (!prayerOn[currentPrayer] && prayerOff)\n\t\t\t\t\t\tplaySound(\"prayeron\");\n\t\t\t\t\tif (prayerOn[currentPrayer] && !prayerOff)\n\t\t\t\t\t\tplaySound(\"prayeroff\");\n\t\t\t\t\tprayerOn[currentPrayer] = prayerOff;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 93) {\n\t\t\t\tshowBank = true;\n\t\t\t\tint l4 = 1;\n\t\t\t\tnewBankItemCount = data[l4++] & 0xff;\n\t\t\t\tbankItemsMax = data[l4++] & 0xff;\n\t\t\t\tfor (int k11 = 0; k11 < newBankItemCount; k11++) {\n\t\t\t\t\tnewBankItems[k11] = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\t\tl4);\n\t\t\t\t\tl4 += 2;\n\t\t\t\t\tnewBankItemsCount[k11] = DataOperations.getUnsigned4Bytes(\n\t\t\t\t\t\t\tdata, l4);\n\t\t\t\t\tl4 += 4;\n\t\t\t\t}\n\t\t\t\tupdateBankItems();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 171) {\n\t\t\t\tshowBank = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 211) {\n\t\t\t\tint idx = data[1] & 0xFF;\n\t\t\t\tint oldExp = playerStatExperience[idx];\n\t\t\t\tplayerStatExperience[idx] = DataOperations.readInt(data, 2);\n\t\t\t\tif (playerStatExperience[idx] > oldExp) {\n\t\t\t\t\texpGained += (playerStatExperience[idx] - oldExp);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 229) {\n\t\t\t\tint j5 = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\tif (mobArray[j5] != null) {\n\t\t\t\t\tduelOpponentName = mobArray[j5].name;\n\t\t\t\t}\n\t\t\t\tshowDuelWindow = true;\n\t\t\t\tduelMyItemCount = 0;\n\t\t\t\tduelOpponentItemCount = 0;\n\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\tduelMyAccepted = false;\n\t\t\t\tduelNoRetreating = false;\n\t\t\t\tduelNoMagic = false;\n\t\t\t\tduelNoPrayer = false;\n\t\t\t\tduelNoWeapons = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 160) {\n\t\t\t\tshowDuelWindow = false;\n\t\t\t\tshowDuelConfirmWindow = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 251) {\n\t\t\t\tshowTradeConfirmWindow = true;\n\t\t\t\ttradeConfirmAccepted = false;\n\t\t\t\tshowTradeWindow = false;\n\t\t\t\tint k5 = 1;\n\t\t\t\ttradeConfirmOtherNameLong = DataOperations.getUnsigned8Bytes(\n\t\t\t\t\t\tdata, k5);\n\t\t\t\tk5 += 8;\n\t\t\t\ttradeConfirmOtherItemCount = data[k5++] & 0xff;\n\t\t\t\tfor (int l11 = 0; l11 < tradeConfirmOtherItemCount; l11++) {\n\t\t\t\t\ttradeConfirmOtherItems[l11] = DataOperations\n\t\t\t\t\t\t\t.getUnsigned2Bytes(data, k5);\n\t\t\t\t\tk5 += 2;\n\t\t\t\t\ttradeConfirmOtherItemsCount[l11] = DataOperations.readInt(\n\t\t\t\t\t\t\tdata, k5);\n\t\t\t\t\tk5 += 4;\n\t\t\t\t}\n\t\t\t\ttradeConfirmItemCount = data[k5++] & 0xff;\n\t\t\t\tfor (int k17 = 0; k17 < tradeConfirmItemCount; k17++) {\n\t\t\t\t\ttradeConfirmItems[k17] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, k5);\n\t\t\t\t\tk5 += 2;\n\t\t\t\t\ttradeConfirmItemsCount[k17] = DataOperations.readInt(data,\n\t\t\t\t\t\t\tk5);\n\t\t\t\t\tk5 += 4;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 63) {\n\t\t\t\tduelOpponentItemCount = data[1] & 0xff;\n\t\t\t\tint l5 = 2;\n\t\t\t\tfor (int i12 = 0; i12 < duelOpponentItemCount; i12++) {\n\t\t\t\t\tduelOpponentItems[i12] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, l5);\n\t\t\t\t\tl5 += 2;\n\t\t\t\t\tduelOpponentItemsCount[i12] = DataOperations.readInt(data,\n\t\t\t\t\t\t\tl5);\n\t\t\t\t\tl5 += 4;\n\t\t\t\t}\n\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\tduelMyAccepted = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 198) {\n\t\t\t\tduelNoRetreating = data[1] == 1;\n\t\t\t\tduelNoMagic = data[2] == 1;\n\t\t\t\tduelNoPrayer = data[3] == 1;\n\t\t\t\tduelNoWeapons = data[4] == 1;\n\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\tduelMyAccepted = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 139) {\n\t\t\t\tint bankDataOffset = 1;\n\t\t\t\tint bankSlot = data[bankDataOffset++] & 0xff;\n\t\t\t\tint bankItemId = DataOperations.getUnsigned2Bytes(data,\n\t\t\t\t\t\tbankDataOffset);\n\t\t\t\tbankDataOffset += 2;\n\t\t\t\tint bankItemCount = DataOperations.getUnsigned4Bytes(data,\n\t\t\t\t\t\tbankDataOffset);\n\t\t\t\tbankDataOffset += 4;\n\t\t\t\tif (bankItemCount == 0) {\n\t\t\t\t\tnewBankItemCount--;\n\t\t\t\t\tfor (int currentBankSlot = bankSlot; currentBankSlot < newBankItemCount; currentBankSlot++) {\n\t\t\t\t\t\tnewBankItems[currentBankSlot] = newBankItems[currentBankSlot + 1];\n\t\t\t\t\t\tnewBankItemsCount[currentBankSlot] = newBankItemsCount[currentBankSlot + 1];\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tnewBankItems[bankSlot] = bankItemId;\n\t\t\t\t\tnewBankItemsCount[bankSlot] = bankItemCount;\n\t\t\t\t\tif (bankSlot >= newBankItemCount)\n\t\t\t\t\t\tnewBankItemCount = bankSlot + 1;\n\t\t\t\t}\n\t\t\t\tupdateBankItems();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 228) {\n\t\t\t\tint j6 = 1;\n\t\t\t\tint k12 = 1;\n\t\t\t\tint i18 = data[j6++] & 0xff;\n\t\t\t\tint k22 = DataOperations.getUnsigned2Bytes(data, j6);\n\t\t\t\tj6 += 2;\n\t\t\t\tif (EntityHandler.getItemDef(k22 & 0x7fff).isStackable()) {\n\t\t\t\t\tk12 = DataOperations.readInt(data, j6);\n\t\t\t\t\tj6 += 4;\n\t\t\t\t}\n\t\t\t\tgetInventoryItems()[i18] = k22 & 0x7fff;\n\t\t\t\twearing[i18] = k22 / 32768;\n\t\t\t\tinventoryItemsCount[i18] = k12;\n\t\t\t\tif (i18 >= inventoryCount)\n\t\t\t\t\tinventoryCount = i18 + 1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 191) {\n\t\t\t\tint k6 = data[1] & 0xff;\n\t\t\t\tinventoryCount--;\n\t\t\t\tfor (int l12 = k6; l12 < inventoryCount; l12++) {\n\t\t\t\t\tgetInventoryItems()[l12] = getInventoryItems()[l12 + 1];\n\t\t\t\t\tinventoryItemsCount[l12] = inventoryItemsCount[l12 + 1];\n\t\t\t\t\twearing[l12] = wearing[l12 + 1];\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 208) {\n\t\t\t\tint pointer = 1;\n\t\t\t\tint idx = data[pointer++] & 0xff;\n\t\t\t\tint oldExp = playerStatExperience[idx];\n\t\t\t\tplayerStatCurrent[idx] = DataOperations\n\t\t\t\t\t\t.getUnsignedByte(data[pointer++]);\n\t\t\t\tplayerStatBase[idx] = DataOperations\n\t\t\t\t\t\t.getUnsignedByte(data[pointer++]);\n\t\t\t\tplayerStatExperience[idx] = DataOperations.readInt(data,\n\t\t\t\t\t\tpointer);\n\t\t\t\tpointer += 4;\n\t\t\t\tif (playerStatExperience[idx] > oldExp) {\n\t\t\t\t\texpGained += (playerStatExperience[idx] - oldExp);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 65) {\n\t\t\t\tduelOpponentAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 197) {\n\t\t\t\tduelMyAccepted = data[1] == 1;\n\t\t\t}\n\t\t\tif (command == 147) {\n\t\t\t\tshowDuelConfirmWindow = true;\n\t\t\t\tduelWeAccept = false;\n\t\t\t\tshowDuelWindow = false;\n\t\t\t\tint i7 = 1;\n\t\t\t\tduelOpponentNameLong = DataOperations.getUnsigned8Bytes(data,\n\t\t\t\t\t\ti7);\n\t\t\t\ti7 += 8;\n\t\t\t\tduelConfirmOpponentItemCount = data[i7++] & 0xff;\n\t\t\t\tfor (int j13 = 0; j13 < duelConfirmOpponentItemCount; j13++) {\n\t\t\t\t\tduelConfirmOpponentItems[j13] = DataOperations\n\t\t\t\t\t\t\t.getUnsigned2Bytes(data, i7);\n\t\t\t\t\ti7 += 2;\n\t\t\t\t\tduelConfirmOpponentItemsCount[j13] = DataOperations\n\t\t\t\t\t\t\t.readInt(data, i7);\n\t\t\t\t\ti7 += 4;\n\t\t\t\t}\n\t\t\t\tduelConfirmMyItemCount = data[i7++] & 0xff;\n\t\t\t\tfor (int j18 = 0; j18 < duelConfirmMyItemCount; j18++) {\n\t\t\t\t\tduelConfirmMyItems[j18] = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, i7);\n\t\t\t\t\ti7 += 2;\n\t\t\t\t\tduelConfirmMyItemsCount[j18] = DataOperations.readInt(data,\n\t\t\t\t\t\t\ti7);\n\t\t\t\t\ti7 += 4;\n\t\t\t\t}\n\t\t\t\tduelCantRetreat = data[i7++] & 0xff;\n\t\t\t\tduelUseMagic = data[i7++] & 0xff;\n\t\t\t\tduelUsePrayer = data[i7++] & 0xff;\n\t\t\t\tduelUseWeapons = data[i7++] & 0xff;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 11) {\n\t\t\t\tString s = new String(data, 1, length - 1);\n\t\t\t\tplaySound(s);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 23) {\n\t\t\t\tif (anInt892 < 50) {\n\t\t\t\t\tint j7 = data[1] & 0xff;\n\t\t\t\t\tint k13 = data[2] + getSectionX();\n\t\t\t\t\tint k18 = data[3] + getSectionY();\n\t\t\t\t\tanIntArray782[anInt892] = j7;\n\t\t\t\t\tanIntArray923[anInt892] = 0;\n\t\t\t\t\tanIntArray944[anInt892] = k13;\n\t\t\t\t\tanIntArray757[anInt892] = k18;\n\t\t\t\t\tanInt892++;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 248) {\n\t\t\t\tif (!hasReceivedWelcomeBoxDetails) {\n\t\t\t\t\tlastLoggedInDays = DataOperations\n\t\t\t\t\t\t\t.getUnsigned2Bytes(data, 1);\n\t\t\t\t\tsubscriptionLeftDays = DataOperations.getUnsigned2Bytes(\n\t\t\t\t\t\t\tdata, 3);\n\t\t\t\t\tlastLoggedInAddress = new String(data, 5, length - 5);\n\t\t\t\t\tshowWelcomeBox = true;\n\t\t\t\t\thasReceivedWelcomeBoxDetails = true;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 148) {\n\t\t\t\tserverMessage = new String(data, 1, length - 1);\n\t\t\t\tshowServerMessageBox = true;\n\t\t\t\tserverMessageBoxTop = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 64) {\n\t\t\t\tserverMessage = new String(data, 1, length - 1);\n\t\t\t\tshowServerMessageBox = true;\n\t\t\t\tserverMessageBoxTop = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 126) {\n\t\t\t\tfatigue = DataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 206) {\n\t\t\t\tif (!sleeping) {\n\t\t\t\t}\n\t\t\t\tsleeping = true;\n\t\t\t\tgameMenu.updateText(chatHandle, \"\");\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tsleepEquation = DataOperations.getImage(data, 1, length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 182) {\n\t\t\t\tint offset = 1;\n\t\t\t\tquestPoints = DataOperations.getUnsigned2Bytes(data, offset);\n\t\t\t\toffset += 2;\n\t\t\t\tfor (int i = 0; i < questName.length; i++)\n\t\t\t\t\tquestStage[i] = data[offset + i];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 224) {\n\t\t\t\tsleeping = false;\n\t\t\t\tsleepMessage = null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 225) {\n\t\t\t\tsleepMessage = \"Incorrect - please try again...\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 174) {\n\t\t\t\tDataOperations.getUnsigned2Bytes(data, 1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 181) {\n\t\t\t\tif (autoScreenshot) {\n\t\t\t\t\ttakeScreenshot(false);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (command == 172) {\n\t\t\t\tsystemUpdate = DataOperations.getUnsigned2Bytes(data, 1) * 32;\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t}\n\t}\n\tprivate String sleepMessage = \"\";\n\tprotected final void lostConnection() {\n\t\tsystemUpdate = 0;\n\t\tif (logoutTimeout != 0) {\n\t\t\tresetIntVars();\n\t\t\treturn;\n\t\t}\n\t\tsuper.lostConnection();\n\t}\n\tprivate final void playSound(String s) {\n\t\tif (audioReader == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (configSoundEffects) {\n\t\t\treturn;\n\t\t}\n\t\taudioReader.loadData(sounds,\n\t\t\t\tDataOperations.method358(s + \".pcm\", sounds),\n\t\t\t\tDataOperations.method359(s + \".pcm\", sounds));\n\t}\n\tprivate final boolean sendWalkCommand(int walkSectionX, int walkSectionY,\n\t\t\tint x1, int y1, int x2, int y2, boolean stepBoolean,\n\t\t\tboolean coordsEqual) {\n\t\tint stepCount = engineHandle.getStepCount(walkSectionX, walkSectionY,\n\t\t\t\tx1, y1, x2, y2, sectionXArray, sectionYArray, stepBoolean);\n\t\tif (stepCount == -1)\n\t\t\tif (coordsEqual) {\n\t\t\t\tstepCount = 1;\n\t\t\t\tsectionXArray[0] = x1;\n\t\t\t\tsectionYArray[0] = y1;\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\tstepCount--;\n\t\twalkSectionX = sectionXArray[stepCount];\n\t\twalkSectionY = sectionYArray[stepCount];\n\t\tstepCount--;\n\t\tif (coordsEqual)\n\t\t\tsuper.streamClass.createPacket(246);\n\t\telse\n\t\t\tsuper.streamClass.createPacket(132);\n\t\tsuper.streamClass.add2ByteInt(walkSectionX + getAreaX());\n\t\tsuper.streamClass.add2ByteInt(walkSectionY + getAreaY());\n\t\tif (coordsEqual && stepCount == -1\n\t\t\t\t&& (walkSectionX + getAreaX()) % 5 == 0)\n\t\t\tstepCount = 0;\n\t\tfor (int currentStep = stepCount; currentStep >= 0\n\t\t\t\t&& currentStep > stepCount - 25; currentStep--) {\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionXArray[currentStep] - walkSectionX);\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionYArray[currentStep] - walkSectionY);\n\t\t}\n\t\tsuper.streamClass.formatPacket();\n\t\tactionPictureType = -24;\n\t\tactionPictureX = super.mouseX; \n\t\tactionPictureY = super.mouseY;\n\t\treturn true;\n\t}\n\tprivate final boolean sendWalkCommandIgnoreCoordsEqual(int walkSectionX,\n\t\t\tint walkSectionY, int x1, int y1, int x2, int y2,\n\t\t\tboolean stepBoolean, boolean coordsEqual) {\n\t\tint stepCount = engineHandle.getStepCount(walkSectionX, walkSectionY,\n\t\t\t\tx1, y1, x2, y2, sectionXArray, sectionYArray, stepBoolean);\n\t\tif (stepCount == -1)\n\t\t\treturn false;\n\t\tstepCount--;\n\t\twalkSectionX = sectionXArray[stepCount];\n\t\twalkSectionY = sectionYArray[stepCount];\n\t\tstepCount--;\n\t\tif (coordsEqual)\n\t\t\tsuper.streamClass.createPacket(246);\n\t\telse\n\t\t\tsuper.streamClass.createPacket(132);\n\t\tsuper.streamClass.add2ByteInt(walkSectionX + getAreaX());\n\t\tsuper.streamClass.add2ByteInt(walkSectionY + getAreaY());\n\t\tif (coordsEqual && stepCount == -1\n\t\t\t\t&& (walkSectionX + getAreaX()) % 5 == 0)\n\t\t\tstepCount = 0;\n\t\tfor (int currentStep = stepCount; currentStep >= 0\n\t\t\t\t&& currentStep > stepCount - 25; currentStep--) {\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionXArray[currentStep] - walkSectionX);\n\t\t\tsuper.streamClass\n\t\t\t\t\t.addByte(sectionYArray[currentStep] - walkSectionY);\n\t\t}\n\t\tsuper.streamClass.formatPacket();\n\t\tactionPictureType = -24;\n\t\tactionPictureX = super.mouseX;\n\t\tactionPictureY = super.mouseY;\n\t\treturn true;\n\t}\n\tpublic final Image createImage(int i, int j) {\n\t\tif (GameWindow.gameFrame != null) {\n\t\t\treturn GameWindow.gameFrame.createImage(i, j);\n\t\t}\n\t\treturn super.createImage(i, j);\n\t}\n\tprivate final void drawTradeConfirmWindow() {\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 16, 192);\n\t\tint i = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 16, 468, 246, i, 160);\n\t\tgameGraphics.drawText(\"Please confirm your trade with @yel@\"\n\t\t\t\t+ DataOperations.longToString(tradeConfirmOtherNameLong),\n\t\t\t\tbyte0 + 234, byte1 + 12, 1, 0xffffff);\n\t\tgameGraphics.drawText(\"You are about to give:\", byte0 + 117,\n\t\t\t\tbyte1 + 30, 1, 0xffff00);\n\t\tfor (int j = 0; j < tradeConfirmItemCount; j++) {\n\t\t\tString s = EntityHandler.getItemDef(tradeConfirmItems[j]).getName();\n\t\t\tif (EntityHandler.getItemDef(tradeConfirmItems[j]).isStackable())\n\t\t\t\ts = s + \" x \" + method74(tradeConfirmItemsCount[j]);\n\t\t\tgameGraphics.drawText(s, byte0 + 117, byte1 + 42 + j * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (tradeConfirmItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 117, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tgameGraphics.drawText(\"In return you will receive:\", byte0 + 351,\n\t\t\t\tbyte1 + 30, 1, 0xffff00);\n\t\tfor (int k = 0; k < tradeConfirmOtherItemCount; k++) {\n\t\t\tString s1 = EntityHandler.getItemDef(tradeConfirmOtherItems[k])\n\t\t\t\t\t.getName();\n\t\t\tif (EntityHandler.getItemDef(tradeConfirmOtherItems[k])\n\t\t\t\t\t.isStackable())\n\t\t\t\ts1 = s1 + \" x \" + method74(tradeConfirmOtherItemsCount[k]);\n\t\t\tgameGraphics.drawText(s1, byte0 + 351, byte1 + 42 + k * 12, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (tradeConfirmOtherItemCount == 0)\n\t\t\tgameGraphics.drawText(\"Nothing!\", byte0 + 351, byte1 + 42, 1,\n\t\t\t\t\t0xffffff);\n\t\tgameGraphics.drawText(\"Are you sure you want to do this?\", byte0 + 234,\n\t\t\t\tbyte1 + 200, 4, 65535);\n\t\tgameGraphics.drawText(\n\t\t\t\t\"There is NO WAY to reverse a trade if you change your mind.\",\n\t\t\t\tbyte0 + 234, byte1 + 215, 1, 0xffffff);\n\t\tgameGraphics.drawText(\"Remember that not all players are trustworthy\",\n\t\t\t\tbyte0 + 234, byte1 + 230, 1, 0xffffff);\n\t\tif (!tradeConfirmAccepted) {\n\t\t\tgameGraphics.drawPicture((byte0 + 118) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\t\tgameGraphics.drawPicture((byte0 + 352) - 35, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\t} else {\n\t\t\tgameGraphics.drawText(\"Waiting for other player...\", byte0 + 234,\n\t\t\t\t\tbyte1 + 250, 1, 0xffff00);\n\t\t}\n\t\tif (mouseButtonClick == 1) {\n\t\t\tif (super.mouseX < byte0 || super.mouseY < byte1\n\t\t\t\t\t|| super.mouseX > byte0 + 468 || super.mouseY > byte1 + 262) {\n\t\t\t\tshowTradeConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 118) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 118 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\ttradeConfirmAccepted = true;\n\t\t\t\tsuper.streamClass.createPacket(53);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tif (super.mouseX >= (byte0 + 352) - 35\n\t\t\t\t\t&& super.mouseX <= byte0 + 353 + 70\n\t\t\t\t\t&& super.mouseY >= byte1 + 238\n\t\t\t\t\t&& super.mouseY <= byte1 + 238 + 21) {\n\t\t\t\tshowTradeConfirmWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(216);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tprivate final void walkToGroundItem(int walkSectionX, int walkSectionY,\n\t\t\tint x, int y, boolean coordsEqual) {\n\t\tif (sendWalkCommandIgnoreCoordsEqual(walkSectionX, walkSectionY, x, y,\n\t\t\t\tx, y, false, coordsEqual)) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tsendWalkCommand(walkSectionX, walkSectionY, x, y, x, y, true,\n\t\t\t\t\tcoordsEqual);\n\t\t\treturn;\n\t\t}\n\t}\n\tprivate final Mob addNPC(int serverIndex, int x, int y, int nextSprite,\n\t\t\tint type) {\n\t\tif (npcRecordArray[serverIndex] == null) {\n\t\t\tnpcRecordArray[serverIndex] = new Mob();\n\t\t\tnpcRecordArray[serverIndex].serverIndex = serverIndex;\n\t\t}\n\t\tMob mob = npcRecordArray[serverIndex];\n\t\tboolean npcAlreadyExists = false;\n\t\tfor (int lastNpcIndex = 0; lastNpcIndex < lastNpcCount; lastNpcIndex++) {\n\t\t\tif (lastNpcArray[lastNpcIndex].serverIndex != serverIndex)\n\t\t\t\tcontinue;\n\t\t\tnpcAlreadyExists = true;\n\t\t\tbreak;\n\t\t}\n\t\tif (npcAlreadyExists) {\n\t\t\tmob.type = type;\n\t\t\tmob.nextSprite = nextSprite;\n\t\t\tint waypointCurrent = mob.waypointCurrent;\n\t\t\tif (x != mob.waypointsX[waypointCurrent]\n\t\t\t\t\t|| y != mob.waypointsY[waypointCurrent]) {\n\t\t\t\tmob.waypointCurrent = waypointCurrent = (waypointCurrent + 1) % 10;\n\t\t\t\tmob.waypointsX[waypointCurrent] = x;\n\t\t\t\tmob.waypointsY[waypointCurrent] = y;\n\t\t\t}\n\t\t} else {\n\t\t\tmob.serverIndex = serverIndex;\n\t\t\tmob.waypointEndSprite = 0;\n\t\t\tmob.waypointCurrent = 0;\n\t\t\tmob.waypointsX[0] = mob.currentX = x;\n\t\t\tmob.waypointsY[0] = mob.currentY = y;\n\t\t\tmob.type = type;\n\t\t\tmob.nextSprite = mob.currentSprite = nextSprite;\n\t\t\tmob.stepCount = 0;\n\t\t}\n\t\tnpcArray[npcCount++] = mob;\n\t\treturn mob;\n\t}\n\tprivate final void drawDuelWindow() {\n\t\tif (mouseButtonClick != 0 && itemIncrement == 0)\n\t\t\titemIncrement = 1;\n\t\tif (itemIncrement > 0) {\n\t\t\tint i = super.mouseX - 22 - xAddition;\n\t\t\tint j = super.mouseY - 36 - yAddition;\n\t\t\tif (i >= 0 && j >= 0 && i < 468 && j < 262) {\n\t\t\t\tif (i > 216 && j > 30 && i < 462 && j < 235) {\n\t\t\t\t\tint k = (i - 217) / 49 + ((j - 31) / 34) * 5;\n\t\t\t\t\tif (k >= 0 && k < inventoryCount) {\n\t\t\t\t\t\tboolean flag1 = false;\n\t\t\t\t\t\tint l1 = 0;\n\t\t\t\t\t\tint k2 = getInventoryItems()[k];\n\t\t\t\t\t\tfor (int k3 = 0; k3 < duelMyItemCount; k3++)\n\t\t\t\t\t\t\tif (duelMyItems[k3] == k2)\n\t\t\t\t\t\t\t\tif (EntityHandler.getItemDef(k2).isStackable()) {\n\t\t\t\t\t\t\t\t\tfor (int i4 = 0; i4 < itemIncrement; i4++) {\n\t\t\t\t\t\t\t\t\t\tif (duelMyItemsCount[k3] < inventoryItemsCount[k])\n\t\t\t\t\t\t\t\t\t\t\tduelMyItemsCount[k3]++;\n\t\t\t\t\t\t\t\t\t\tflag1 = true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tl1++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif (inventoryCount(k2) <= l1)\n\t\t\t\t\t\t\tflag1 = true;\n\t\t\t\t\t\tif (!flag1 && duelMyItemCount < 8) {\n\t\t\t\t\t\t\tduelMyItems[duelMyItemCount] = k2;\n\t\t\t\t\t\t\tduelMyItemsCount[duelMyItemCount] = 1;\n\t\t\t\t\t\t\tduelMyItemCount++;\n\t\t\t\t\t\t\tflag1 = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (flag1) {\n\t\t\t\t\t\t\tsuper.streamClass.createPacket(123);\n\t\t\t\t\t\t\tsuper.streamClass.addByte(duelMyItemCount);\n\t\t\t\t\t\t\tfor (int duelItem = 0; duelItem < duelMyItemCount; duelItem++) {\n\t\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t\t.add2ByteInt(duelMyItems[duelItem]);\n\t\t\t\t\t\t\t\tsuper.streamClass\n\t\t\t\t\t\t\t\t\t\t.add4ByteInt(duelMyItemsCount[duelItem]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\t\t\t\tduelMyAccepted = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (i > 8 && j > 30 && i < 205 && j < 129) {\n\t\t\t\t\tint l = (i - 9) / 49 + ((j - 31) / 34) * 4;\n\t\t\t\t\tif (l >= 0 && l < duelMyItemCount) {\n\t\t\t\t\t\tint j1 = duelMyItems[l];\n\t\t\t\t\t\tfor (int i2 = 0; i2 < itemIncrement; i2++) {\n\t\t\t\t\t\t\tif (EntityHandler.getItemDef(j1).isStackable()\n\t\t\t\t\t\t\t\t\t&& duelMyItemsCount[l] > 1) {\n\t\t\t\t\t\t\t\tduelMyItemsCount[l]--;\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tduelMyItemCount--;\n\t\t\t\t\t\t\tmouseDownTime = 0;\n\t\t\t\t\t\t\tfor (int l2 = l; l2 < duelMyItemCount; l2++) {\n\t\t\t\t\t\t\t\tduelMyItems[l2] = duelMyItems[l2 + 1];\n\t\t\t\t\t\t\t\tduelMyItemsCount[l2] = duelMyItemsCount[l2 + 1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.createPacket(123);\n\t\t\t\t\t\tsuper.streamClass.addByte(duelMyItemCount);\n\t\t\t\t\t\tfor (int i3 = 0; i3 < duelMyItemCount; i3++) {\n\t\t\t\t\t\t\tsuper.streamClass.add2ByteInt(duelMyItems[i3]);\n\t\t\t\t\t\t\tsuper.streamClass.add4ByteInt(duelMyItemsCount[i3]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\t\t\tduelMyAccepted = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tboolean flag = false;\n\t\t\t\tif (i >= 93 && j >= 221 && i <= 104 && j <= 232) {\n\t\t\t\t\tduelNoRetreating = !duelNoRetreating;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (i >= 93 && j >= 240 && i <= 104 && j <= 251) {\n\t\t\t\t\tduelNoMagic = !duelNoMagic;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (i >= 191 && j >= 221 && i <= 202 && j <= 232) {\n\t\t\t\t\tduelNoPrayer = !duelNoPrayer;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (i >= 191 && j >= 240 && i <= 202 && j <= 251) {\n\t\t\t\t\tduelNoWeapons = !duelNoWeapons;\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t\tif (flag) {\n\t\t\t\t\tsuper.streamClass.createPacket(225);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoRetreating ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoMagic ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoPrayer ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.addByte(duelNoWeapons ? 1 : 0);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t\tduelOpponentAccepted = false;\n\t\t\t\t\tduelMyAccepted = false;\n\t\t\t\t}\n\t\t\t\tif (i >= 217 && j >= 238 && i <= 286 && j <= 259) {\n\t\t\t\t\tduelMyAccepted = true;\n\t\t\t\t\tsuper.streamClass.createPacket(252);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t\tif (i >= 394 && j >= 238 && i < 463 && j < 259) {\n\t\t\t\t\tshowDuelWindow = false;\n\t\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t\t}\n\t\t\t} else if (mouseButtonClick != 0) {\n\t\t\t\tshowDuelWindow = false;\n\t\t\t\tsuper.streamClass.createPacket(35);\n\t\t\t\tsuper.streamClass.formatPacket();\n\t\t\t}\n\t\t\tmouseButtonClick = 0;\n\t\t\titemIncrement = 0;\n\t\t}\n\t\tif (!showDuelWindow)\n\t\t\treturn;\n\t\tint byte0 = 22 + xAddition;\n\t\tint byte1 = 36 + yAddition;\n\t\tgameGraphics.drawBox(byte0, byte1, 468, 12, 0xc90b1d);\n\t\tint i1 = 0x989898;\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 12, 468, 18, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0, byte1 + 30, 8, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 205, byte1 + 30, 11, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 462, byte1 + 30, 6, 248, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 99, 197, 24, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 192, 197, 23, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 258, 197, 20, i1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 235, 246, 43, i1, 160);\n\t\tint k1 = 0xd0d0d0;\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 30, 197, 69, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 123, 197, 69, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 8, byte1 + 215, 197, 43, k1, 160);\n\t\tgameGraphics.drawBoxAlpha(byte0 + 216, byte1 + 30, 246, 205, k1, 160);\n\t\tfor (int j2 = 0; j2 < 3; j2++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 30 + j2 * 34, 197, 0);\n\t\tfor (int j3 = 0; j3 < 3; j3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 123 + j3 * 34, 197, 0);\n\t\tfor (int l3 = 0; l3 < 7; l3++)\n\t\t\tgameGraphics.drawLineX(byte0 + 216, byte1 + 30 + l3 * 34, 246, 0);\n\t\tfor (int k4 = 0; k4 < 6; k4++) {\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics.drawLineY(byte0 + 8 + k4 * 49, byte1 + 30, 69, 0);\n\t\t\tif (k4 < 5)\n\t\t\t\tgameGraphics.drawLineY(byte0 + 8 + k4 * 49, byte1 + 123, 69, 0);\n\t\t\tgameGraphics.drawLineY(byte0 + 216 + k4 * 49, byte1 + 30, 205, 0);\n\t\t}\n\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 215, 197, 0);\n\t\tgameGraphics.drawLineX(byte0 + 8, byte1 + 257, 197, 0);\n\t\tgameGraphics.drawLineY(byte0 + 8, byte1 + 215, 43, 0);\n\t\tgameGraphics.drawLineY(byte0 + 204, byte1 + 215, 43, 0);\n\t\tgameGraphics.drawString(\"Preparing to duel with: \" + duelOpponentName,\n\t\t\t\tbyte0 + 1, byte1 + 10, 1, 0xffffff);\n\t\tgameGraphics.drawString(\"Your Stake\", byte0 + 9, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Opponent's Stake\", byte0 + 9, byte1 + 120, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Duel Options\", byte0 + 9, byte1 + 212, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"Your Inventory\", byte0 + 216, byte1 + 27, 4,\n\t\t\t\t0xffffff);\n\t\tgameGraphics.drawString(\"No retreating\", byte0 + 8 + 1,\n\t\t\t\tbyte1 + 215 + 16, 3, 0xffff00);\n\t\tgameGraphics.drawString(\"No magic\", byte0 + 8 + 1, byte1 + 215 + 35, 3,\n\t\t\t\t0xffff00);\n\t\tgameGraphics.drawString(\"No prayer\", byte0 + 8 + 102, byte1 + 215 + 16,\n\t\t\t\t3, 0xffff00);\n\t\tgameGraphics.drawString(\"No weapons\", byte0 + 8 + 102,\n\t\t\t\tbyte1 + 215 + 35, 3, 0xffff00);\n\t\tgameGraphics.drawBoxEdge(byte0 + 93, byte1 + 215 + 6, 11, 11, 0xffff00);\n\t\tif (duelNoRetreating)\n\t\t\tgameGraphics.drawBox(byte0 + 95, byte1 + 215 + 8, 7, 7, 0xffff00);\n\t\tgameGraphics\n\t\t\t\t.drawBoxEdge(byte0 + 93, byte1 + 215 + 25, 11, 11, 0xffff00);\n\t\tif (duelNoMagic)\n\t\t\tgameGraphics.drawBox(byte0 + 95, byte1 + 215 + 27, 7, 7, 0xffff00);\n\t\tgameGraphics\n\t\t\t\t.drawBoxEdge(byte0 + 191, byte1 + 215 + 6, 11, 11, 0xffff00);\n\t\tif (duelNoPrayer)\n\t\t\tgameGraphics.drawBox(byte0 + 193, byte1 + 215 + 8, 7, 7, 0xffff00);\n\t\tgameGraphics.drawBoxEdge(byte0 + 191, byte1 + 215 + 25, 11, 11,\n\t\t\t\t0xffff00);\n\t\tif (duelNoWeapons)\n\t\t\tgameGraphics.drawBox(byte0 + 193, byte1 + 215 + 27, 7, 7, 0xffff00);\n\t\tif (!duelMyAccepted)\n\t\t\tgameGraphics.drawPicture(byte0 + 217, byte1 + 238,\n\t\t\t\t\tSPRITE_MEDIA_START + 25);\n\t\tgameGraphics.drawPicture(byte0 + 394, byte1 + 238,\n\t\t\t\tSPRITE_MEDIA_START + 26);\n\t\tif (duelOpponentAccepted) {\n\t\t\tgameGraphics.drawText(\"Other player\", byte0 + 341, byte1 + 246, 1,\n\t\t\t\t\t0xffffff);\n\t\t\tgameGraphics.drawText(\"has accepted\", byte0 + 341, byte1 + 256, 1,\n\t\t\t\t\t0xffffff);\n\t\t}\n\t\tif (duelMyAccepted) {\n\t\t\tgameGraphics.drawText(\"Waiting for\", byte0 + 217 + 35, byte1 + 246,\n\t\t\t\t\t1, 0xffffff);\n\t\t\tgameGraphics.drawText(\"other player\", byte0 + 217 + 35,\n\t\t\t\t\tbyte1 + 256, 1, 0xffffff);\n\t\t}\n\t\tfor (int l4 = 0; l4 < inventoryCount; l4++) {\n\t\t\tint i5 = 217 + byte0 + (l4 % 5) * 49;\n\t\t\tint k5 = 31 + byte1 + (l4 / 5) * 34;\n\t\t\tgameGraphics.spriteClip4(i5, k5, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(getInventoryItems()[l4])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(getInventoryItems()[l4]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(inventoryItemsCount[l4]), i5 + 1,\n\t\t\t\t\t\tk5 + 10, 1, 0xffff00);\n\t\t}\n\t\tfor (int j5 = 0; j5 < duelMyItemCount; j5++) {\n\t\t\tint l5 = 9 + byte0 + (j5 % 4) * 49;\n\t\t\tint j6 = 31 + byte1 + (j5 / 4) * 34;\n\t\t\tgameGraphics.spriteClip4(l5, j6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(duelMyItems[j5]).getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(duelMyItems[j5]).getPictureMask(),\n\t\t\t\t\t0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(duelMyItems[j5]).isStackable())\n\t\t\t\tgameGraphics.drawString(String.valueOf(duelMyItemsCount[j5]),\n\t\t\t\t\t\tl5 + 1, j6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > l5 && super.mouseX < l5 + 48\n\t\t\t\t\t&& super.mouseY > j6 && super.mouseY < j6 + 32)\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tEntityHandler.getItemDef(duelMyItems[j5]).getName()\n\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(duelMyItems[j5])\n\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t\tfor (int i6 = 0; i6 < duelOpponentItemCount; i6++) {\n\t\t\tint k6 = 9 + byte0 + (i6 % 4) * 49;\n\t\t\tint l6 = 124 + byte1 + (i6 / 4) * 34;\n\t\t\tgameGraphics.spriteClip4(k6, l6, 48, 32, SPRITE_ITEM_START\n\t\t\t\t\t+ EntityHandler.getItemDef(duelOpponentItems[i6])\n\t\t\t\t\t\t\t.getSprite(),\n\t\t\t\t\tEntityHandler.getItemDef(duelOpponentItems[i6])\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t\tif (EntityHandler.getItemDef(duelOpponentItems[i6]).isStackable())\n\t\t\t\tgameGraphics.drawString(\n\t\t\t\t\t\tString.valueOf(duelOpponentItemsCount[i6]), k6 + 1,\n\t\t\t\t\t\tl6 + 10, 1, 0xffff00);\n\t\t\tif (super.mouseX > k6 && super.mouseX < k6 + 48\n\t\t\t\t\t&& super.mouseY > l6 && super.mouseY < l6 + 32)\n\t\t\t\tgameGraphics\n\t\t\t\t\t\t.drawString(\n\t\t\t\t\t\t\t\tEntityHandler.getItemDef(duelOpponentItems[i6])\n\t\t\t\t\t\t\t\t\t\t.getName()\n\t\t\t\t\t\t\t\t\t\t+ \": @whi@\"\n\t\t\t\t\t\t\t\t\t\t+ EntityHandler.getItemDef(\n\t\t\t\t\t\t\t\t\t\t\t\tduelOpponentItems[i6])\n\t\t\t\t\t\t\t\t\t\t\t\t.getDescription(), byte0 + 8,\n\t\t\t\t\t\t\t\tbyte1 + 273, 1, 0xffff00);\n\t\t}\n\t}\n\tprivate final void drawServerMessageBox() {\n\t\tint c = '\\u0190';\n\t\tint c1 = 'd';\n\t\tif (serverMessageBoxTop) {\n\t\t\tc1 = '\\u01C2';\n\t\t\tc1 = '\\u012C';\n\t\t}\n\t\tgameGraphics.drawBox(256 - c / 2 + xAddition, 167 - c1 / 2 + yAddition,\n\t\t\t\tc, c1, 0);\n\t\tgameGraphics.drawBoxEdge(256 - c / 2 + xAddition, 167 - c1 / 2\n\t\t\t\t+ yAddition, c, c1, 0xffffff);\n\t\tgameGraphics.drawBoxTextColour(serverMessage, 256 + xAddition,\n\t\t\t\t(167 - c1 / 2) + 20 + yAddition, 1, 0xffffff, c - 40);\n\t\tint i = 157 + c1 / 2 + yAddition;\n\t\tint j = 0xffffff;\n\t\tif (super.mouseY > i - 12 && super.mouseY <= i\n\t\t\t\t&& super.mouseX > 106 + xAddition\n\t\t\t\t&& super.mouseX < 406 + xAddition)\n\t\t\tj = 0xff0000;\n\t\tgameGraphics.drawText(\"Click here to close window\", 256 + xAddition, i,\n\t\t\t\t1, j);\n\t\tif (mouseButtonClick == 1) {\n\t\t\tif (j == 0xff0000)\n\t\t\t\tshowServerMessageBox = false;\n\t\t\tif ((super.mouseX < 256 - c / 2 + xAddition || super.mouseX > 256\n\t\t\t\t\t+ c / 2 + xAddition)\n\t\t\t\t\t&& (super.mouseY < 167 - c1 / 2 + yAddition || super.mouseY > 167\n\t\t\t\t\t\t\t+ c1 / 2 + yAddition))\n\t\t\t\tshowServerMessageBox = false;\n\t\t}\n\t\tmouseButtonClick = 0;\n\t}\n\tprivate final void makeLoginMenus() {\n\t\tmenuWelcome = new Menu(gameGraphics, 50);\n\t\tint i = 40 + yAddition;\n\t\tmenuWelcome.drawText(256 + xAddition, 200 + i, \"Click on an option\", 5,\n\t\t\t\ttrue);\n\t\tmenuWelcome.drawBox(156 + xAddition, 240 + i, 120, 35);\n\t\tmenuWelcome.drawBox(356 + xAddition, 240 + i, 120, 35);\n\t\tmenuWelcome.drawText(156 + xAddition, 240 + i, \"New User\", 5, false);\n\t\tmenuWelcome.drawText(356 + xAddition, 240 + i, \"Existing User\", 5,\n\t\t\t\tfalse);\n\t\tloginButtonNewUser = menuWelcome.makeButton(156 + xAddition, 240 + i,\n\t\t\t\t120, 35);\n\t\tloginButtonExistingUser = menuWelcome.makeButton(356 + xAddition,\n\t\t\t\t240 + i, 120, 35);\n\t\tmenuNewUser = new Menu(gameGraphics, 50);\n\t\ti = 230 + yAddition;\n\t\tif (referId == 0) {\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8,\n\t\t\t\t\t\"To create an account please go back to the\", 4, true);\n\t\t\ti += 20;\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"www.3hit.net\", 4,\n\t\t\t\t\ttrue);\n\t\t} else if (referId == 1) {\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"then click account\",\n\t\t\t\t\t4, true);\n\t\t\ti += 20;\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"\", 4, true);\n\t\t} else {\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"\", 4, true);\n\t\t\ti += 20;\n\t\t\tmenuNewUser.drawText(256 + xAddition, i + 8, \"\", 4, true);\n\t\t}\n\t\ti += 30;\n\t\tmenuNewUser.drawBox(256 + xAddition, i + 17, 150, 34);\n\t\tmenuNewUser.drawText(256 + xAddition, i + 17, \"Ok\", 5, false);\n\t\tnewUserOkButton = menuNewUser.makeButton(256 + xAddition, i + 17, 150,\n\t\t\t\t34);\n\t\tmenuLogin = new Menu(gameGraphics, 50);\n\t\ti = 230 + yAddition;\n\t\tloginStatusText = menuLogin.drawText(256 + xAddition, i - 10,\n\t\t\t\t\"Please enter your username and password\", 4, true);\n\t\ti += 28;\n\t\tmenuLogin.drawBox(140 + xAddition, i, 200, 40);\n\t\tmenuLogin.drawText(140 + xAddition, i - 10, \"Username:\", 4, false);\n\t\tloginUsernameTextBox = menuLogin.makeTextBox(140 + xAddition, i + 10,\n\t\t\t\t200, 40, 4, 12, false, false);\n\t\ti += 47;\n\t\tmenuLogin.drawBox(190 + xAddition, i, 200, 40);\n\t\tmenuLogin.drawText(190 + xAddition, i - 10, \"Password:\", 4, false);\n\t\tloginPasswordTextBox = menuLogin.makeTextBox(190 + xAddition, i + 10,\n\t\t\t\t200, 40, 4, 20, true, false);\n\t\ti -= 55;\n\t\tmenuLogin.drawBox(410 + xAddition, i, 120, 25);\n\t\tmenuLogin.drawText(410 + xAddition, i, \"Play Now\", 4, false);\n\t\tloginOkButton = menuLogin.makeButton(410 + xAddition, i, 120, 25);\n\t\ti += 30;\n\t\tmenuLogin.drawBox(410 + xAddition, i, 120, 25);\n\t\tmenuLogin.drawText(410 + xAddition, i, \"Cancel\", 4, false);\n\t\tloginCancelButton = menuLogin.makeButton(410 + xAddition, i, 120, 25);\n\t\ti += 30;\n\t\tmenuLogin.setFocus(loginUsernameTextBox);\n\t}\n\tprivate final void drawGameWindowsMenus() {\n\t\tif (logoutTimeout != 0)\n\t\t\tdrawLoggingOutBox();\n\t\telse if (showWelcomeBox)\n\t\t\tdrawWelcomeBox();\n\t\telse if (showServerMessageBox)\n\t\t\tdrawServerMessageBox();\n\t\telse if (wildernessType == 1) \n\t\t\tdrawWildernessWarningBox();\n\t\telse if (showBank && lastWalkTimeout == 0)\n\t\t\tdrawBankBox();\n\t\telse if (showShop && lastWalkTimeout == 0)\n\t\t\tdrawShopBox();\n\t\telse if (showTradeConfirmWindow)\n\t\t\tdrawTradeConfirmWindow();\n\t\telse if (showTradeWindow)\n\t\t\tdrawTradeWindow();\n\t\telse if (showDuelConfirmWindow)\n\t\t\tdrawDuelConfirmWindow();\n\t\telse if (showDuelWindow)\n\t\t\tdrawDuelWindow();\n\t\telse if (showAbuseWindow == 1)\n\t\t\tdrawAbuseWindow1();\n\t\telse if (showAbuseWindow == 2)\n\t\t\tdrawAbuseWindow2();\n\t\telse if (inputBoxType != 0) {\n\t\t\tdrawInputBox();\n\t\t} else {\n\t\t\tif (showQuestionMenu)\n\t\t\t\tdrawQuestionMenu();\n\t\t\tif ((ourPlayer.currentSprite == 8 || ourPlayer.currentSprite == 9)\n\t\t\t\t\t|| combatWindow)\n\t\t\t\tdrawCombatStyleWindow();\n\t\t\tcheckMouseOverMenus();\n\t\t\tboolean noMenusShown = !showQuestionMenu && !showRightClickMenu;\n\t\t\tif (noMenusShown)\n\t\t\t\tmenuLength = 0;\n\t\t\tif (mouseOverMenu == 0 && noMenusShown)\n\t\t\t\tdrawInventoryRightClickMenu();\n\t\t\tif (mouseOverMenu == 1)\n\t\t\t\tdrawInventoryMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 2)\n\t\t\t\tdrawMapMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 3)\n\t\t\t\tdrawPlayerInfoMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 4)\n\t\t\t\tdrawMagicWindow(noMenusShown);\n\t\t\tif (mouseOverMenu == 5)\n\t\t\t\tdrawFriendsWindow(noMenusShown);\n\t\t\tif (mouseOverMenu == 6)\n\t\t\t\tdrawOptionsMenu(noMenusShown);\n\t\t\tif (mouseOverMenu == 7)\n\t\t\t\tdrawOurOptionsMenu(noMenusShown);\n\t\t\tif (!showRightClickMenu && !showQuestionMenu)\n\t\t\t\tcheckMouseStatus();\n\t\t\tif (showRightClickMenu && !showQuestionMenu)\n\t\t\t\tdrawRightClickMenu();\n\t\t}\n\t\tmouseButtonClick = 0;\n\t}\n\tpublic final void method112(int i, int j, int k, int l, boolean flag) {\n\t\tsendWalkCommand(i, j, k, l, k, l, false, flag);\n\t}\n\tprivate final void drawInputBox() {\n\t\tif (mouseButtonClick != 0) {\n\t\t\tmouseButtonClick = 0;\n\t\t\tif (inputBoxType == 1\n\t\t\t\t\t&& (super.mouseX < 106 + xAddition\n\t\t\t\t\t\t\t|| super.mouseY < 145 + yAddition\n\t\t\t\t\t\t\t|| super.mouseX > 406 + xAddition || super.mouseY > 215 + yAddition)) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputBoxType == 2\n\t\t\t\t\t&& (super.mouseX < 6 + xAddition\n\t\t\t\t\t\t\t|| super.mouseY < 145 + yAddition\n\t\t\t\t\t\t\t|| super.mouseX > 506 + xAddition || super.mouseY > 215 + yAddition)) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (inputBoxType == 3\n\t\t\t\t\t&& (super.mouseX < 106 + xAddition\n\t\t\t\t\t\t\t|| super.mouseY < 145 + yAddition\n\t\t\t\t\t\t\t|| super.mouseX > 406 + xAddition || super.mouseY > 215 + yAddition)) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (super.mouseX > 236 + xAddition\n\t\t\t\t\t&& super.mouseX < 276 + xAddition\n\t\t\t\t\t&& super.mouseY > 193 + yAddition\n\t\t\t\t\t&& super.mouseY < 213 + yAddition) {\n\t\t\t\tinputBoxType = 0;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tint i = 145 + yAddition;\n\t\tif (inputBoxType == 1) {\n\t\t\tgameGraphics.drawBox(106 + xAddition, i, 300, 70, 0);\n\t\t\tgameGraphics.drawBoxEdge(106 + xAddition, i, 300, 70, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(\"Enter name to add to friends list\",\n\t\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(super.inputText + \"*\", 256 + xAddition, i, 4,\n\t\t\t\t\t0xffffff);\n\t\t\tif (super.enteredText.length() > 0) {\n\t\t\t\tString s = super.enteredText.trim();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tinputBoxType = 0;\n\t\t\t\tif (s.length() > 0\n\t\t\t\t\t\t&& DataOperations.stringLength12ToLong(s) != ourPlayer.nameLong)\n\t\t\t\t\taddToFriendsList(s);\n\t\t\t}\n\t\t}\n\t\tif (inputBoxType == 2) {\n\t\t\tgameGraphics.drawBox(6 + xAddition, i, 500, 70, 0);\n\t\t\tgameGraphics.drawBoxEdge(6 + xAddition, i, 500, 70, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics\n\t\t\t\t\t.drawText(\n\t\t\t\t\t\t\t\"Enter message to send to \"\n\t\t\t\t\t\t\t\t\t+ DataOperations\n\t\t\t\t\t\t\t\t\t\t\t.longToString(privateMessageTarget),\n\t\t\t\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(super.inputMessage + \"*\", 256 + xAddition, i,\n\t\t\t\t\t4, 0xffffff);\n\t\t\tif (super.enteredMessage.length() > 0) {\n\t\t\t\tString s1 = super.enteredMessage;\n\t\t\t\tsuper.inputMessage = \"\";\n\t\t\t\tsuper.enteredMessage = \"\";\n\t\t\t\tinputBoxType = 0;\n\t\t\t\tbyte[] message = DataConversions.stringToByteArray(s1);\n\t\t\t\tsendPrivateMessage(privateMessageTarget, message,\n\t\t\t\t\t\tmessage.length);\n\t\t\t\ts1 = DataConversions.byteToString(message, 0, message.length);\n\t\t\t\thandleServerMessage(\"@pri@You tell \"\n\t\t\t\t\t\t+ DataOperations.longToString(privateMessageTarget)\n\t\t\t\t\t\t+ \": \" + s1);\n\t\t\t}\n\t\t}\n\t\tif (inputBoxType == 3) {\n\t\t\tgameGraphics.drawBox(106 + xAddition, i, 300, 70, 0);\n\t\t\tgameGraphics.drawBoxEdge(106 + xAddition, i, 300, 70, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(\"Enter name to add to ignore list\",\n\t\t\t\t\t256 + xAddition, i, 4, 0xffffff);\n\t\t\ti += 20;\n\t\t\tgameGraphics.drawText(super.inputText + \"*\", 256 + xAddition, i, 4,\n\t\t\t\t\t0xffffff);\n\t\t\tif (super.enteredText.length() > 0) {\n\t\t\t\tString s2 = super.enteredText.trim();\n\t\t\t\tsuper.inputText = \"\";\n\t\t\t\tsuper.enteredText = \"\";\n\t\t\t\tinputBoxType = 0;\n\t\t\t\tif (s2.length() > 0\n\t\t\t\t\t\t&& DataOperations.stringLength12ToLong(s2) != ourPlayer.nameLong)\n\t\t\t\t\taddToIgnoreList(s2);\n\t\t\t}\n\t\t}\n\t\tint j = 0xffffff;\n\t\tif (super.mouseX > 236 + xAddition && super.mouseX < 276 + xAddition\n\t\t\t\t&& super.mouseY > 193 + yAddition\n\t\t\t\t&& super.mouseY < 213 + yAddition)\n\t\t\tj = 0xffff00;\n\t\tgameGraphics.drawText(\"Cancel\", 256 + xAddition, 208 + yAddition, 1, j);\n\t}\n\tprivate final boolean hasRequiredRunes(int i, int j) {\n\t\tif (i == 31 && (method117(197) || method117(615) || method117(682))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (i == 32 && (method117(102) || method117(616) || method117(683))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (i == 33 && (method117(101) || method117(617) || method117(684))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (i == 34 && (method117(103) || method117(618) || method117(685))) {\n\t\t\treturn true;\n\t\t}\n\t\treturn inventoryCount(i) >= j;\n\t}\n\tprivate final void resetPrivateMessageStrings() {\n\t\tsuper.inputMessage = \"\";\n\t\tsuper.enteredMessage = \"\";\n\t}\n\tprivate final boolean method117(int i) {\n\t\tfor (int j = 0; j < inventoryCount; j++)\n\t\t\tif (getInventoryItems()[j] == i && wearing[j] == 1)\n\t\t\t\treturn true;\n\t\treturn false;\n\t}\n\tprivate final void setPixelsAndAroundColour(int x, int y, int colour) {\n\t\tgameGraphics.setPixelColour(x, y, colour);\n\t\tgameGraphics.setPixelColour(x - 1, y, colour);\n\t\tgameGraphics.setPixelColour(x + 1, y, colour);\n\t\tgameGraphics.setPixelColour(x, y - 1, colour);\n\t\tgameGraphics.setPixelColour(x, y + 1, colour);\n\t}\n\tprivate final void method119() {\n\t\tfor (int i = 0; i < mobMessageCount; i++) {\n\t\t\tint j = gameGraphics.messageFontHeight(1);\n\t\t\tint l = mobMessagesX[i];\n\t\t\tint k1 = mobMessagesY[i];\n\t\t\tint j2 = mobMessagesWidth[i];\n\t\t\tint i3 = mobMessagesHeight[i];\n\t\t\tboolean flag = true;\n\t\t\twhile (flag) {\n\t\t\t\tflag = false;\n\t\t\t\tfor (int i4 = 0; i4 < i; i4++)\n\t\t\t\t\tif (k1 + i3 > mobMessagesY[i4] - j\n\t\t\t\t\t\t\t&& k1 - j < mobMessagesY[i4]\n\t\t\t\t\t\t\t\t\t+ mobMessagesHeight[i4]\n\t\t\t\t\t\t\t&& l - j2 < mobMessagesX[i4] + mobMessagesWidth[i4]\n\t\t\t\t\t\t\t&& l + j2 > mobMessagesX[i4] - mobMessagesWidth[i4]\n\t\t\t\t\t\t\t&& mobMessagesY[i4] - j - i3 < k1) {\n\t\t\t\t\t\tk1 = mobMessagesY[i4] - j - i3;\n\t\t\t\t\t\tflag = true;\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tmobMessagesY[i] = k1;\n\t\t\tgameGraphics.drawBoxTextColour(mobMessages[i], l, k1, 1, 0xffff00,\n\t\t\t\t\t300);\n\t\t}\n\t\tfor (int k = 0; k < anInt699; k++) {\n\t\t\tint i1 = anIntArray858[k];\n\t\t\tint l1 = anIntArray859[k];\n\t\t\tint k2 = anIntArray705[k];\n\t\t\tint j3 = anIntArray706[k];\n\t\t\tint l3 = (39 * k2) / 100;\n\t\t\tint j4 = (27 * k2) / 100;\n\t\t\tint k4 = l1 - j4;\n\t\t\tgameGraphics.spriteClip2(i1 - l3 / 2, k4, l3, j4,\n\t\t\t\t\tSPRITE_MEDIA_START + 9, 85);\n\t\t\tint l4 = (36 * k2) / 100;\n\t\t\tint i5 = (24 * k2) / 100;\n\t\t\tgameGraphics.spriteClip4(i1 - l4 / 2, (k4 + j4 / 2) - i5 / 2, l4,\n\t\t\t\t\ti5, EntityHandler.getItemDef(j3).getSprite()\n\t\t\t\t\t\t\t+ SPRITE_ITEM_START, EntityHandler.getItemDef(j3)\n\t\t\t\t\t\t\t.getPictureMask(), 0, 0, false);\n\t\t}\n\t\tfor (int j1 = 0; j1 < anInt718; j1++) {\n\t\t\tint i2 = anIntArray786[j1];\n\t\t\tint l2 = anIntArray787[j1];\n\t\t\tint k3 = anIntArray788[j1];\n\t\t\tgameGraphics.drawBoxAlpha(i2 - 15, l2 - 3, k3, 5, 65280, 192);\n\t\t\tgameGraphics.drawBoxAlpha((i2 - 15) + k3, l2 - 3, 30 - k3, 5,\n\t\t\t\t\t0xff0000, 192);\n\t\t}\n\t}\n\tprivate final void drawMapMenu(boolean flag) {\n\t\tint i = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\tchar c = '\\234';\n\t\tchar c2 = '\\230';\n\t\tgameGraphics.drawPicture(i - 49, 3, SPRITE_MEDIA_START + 2);\n\t\ti += 40;\n\t\tgameGraphics.drawBox(i, 36, c, c2, 0);\n\t\tgameGraphics.setDimensions(i, 36, i + c, 36 + c2);\n\t\tint k = 192 + anInt986;\n\t\tint i1 = cameraRotation + anInt985 & 0xff;\n\t\tint k1 = ((ourPlayer.currentX - 6040) * 3 * k) / 2048;\n\t\tint i3 = ((ourPlayer.currentY - 6040) * 3 * k) / 2048;\n\t\tint k4 = Camera.anIntArray384[1024 - i1 * 4 & 0x3ff];\n\t\tint i5 = Camera.anIntArray384[(1024 - i1 * 4 & 0x3ff) + 1024];\n\t\tint k5 = i3 * k4 + k1 * i5 >> 18;\n\t\ti3 = i3 * i5 - k1 * k4 >> 18;\n\t\tk1 = k5;\n\t\tgameGraphics.method242((i + c / 2) - k1, 36 + c2 / 2 + i3,\n\t\t\t\tSPRITE_MEDIA_START - 1, i1 + 64 & 0xff, k);\n\t\tfor (int i7 = 0; i7 < objectCount; i7++) {\n\t\t\tint l1 = (((objectX[i7] * magicLoc + 64) - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint j3 = (((objectY[i7] * magicLoc + 64) - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint l5 = j3 * k4 + l1 * i5 >> 18;\n\t\t\tj3 = j3 * i5 - l1 * k4 >> 18;\n\t\t\tl1 = l5;\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + l1, (36 + c2 / 2) - j3, 65535);\n\t\t}\n\t\tfor (int j7 = 0; j7 < groundItemCount; j7++) {\n\t\t\tint i2 = (((groundItemX[j7] * magicLoc + 64) - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint k3 = (((groundItemY[j7] * magicLoc + 64) - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint i6 = k3 * k4 + i2 * i5 >> 18;\n\t\t\tk3 = k3 * i5 - i2 * k4 >> 18;\n\t\t\ti2 = i6;\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + i2, (36 + c2 / 2) - k3,\n\t\t\t\t\t0xff0000);\n\t\t}\n\t\tfor (int k7 = 0; k7 < npcCount; k7++) {\n\t\t\tMob mob = npcArray[k7];\n\t\t\tint j2 = ((mob.currentX - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint l3 = ((mob.currentY - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint j6 = l3 * k4 + j2 * i5 >> 18;\n\t\t\tl3 = l3 * i5 - j2 * k4 >> 18;\n\t\t\tj2 = j6;\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + j2, (36 + c2 / 2) - l3,\n\t\t\t\t\t0xffff00);\n\t\t}\n\t\tfor (int l7 = 0; l7 < playerCount; l7++) {\n\t\t\tMob mob_1 = playerArray[l7];\n\t\t\tint k2 = ((mob_1.currentX - ourPlayer.currentX) * 3 * k) / 2048;\n\t\t\tint i4 = ((mob_1.currentY - ourPlayer.currentY) * 3 * k) / 2048;\n\t\t\tint k6 = i4 * k4 + k2 * i5 >> 18;\n\t\t\ti4 = i4 * i5 - k2 * k4 >> 18;\n\t\t\tk2 = k6;\n\t\t\tint j8 = 0xffffff;\n\t\t\tfor (int k8 = 0; k8 < super.friendsCount; k8++) {\n\t\t\t\tif (mob_1.nameLong != super.friendsListLongs[k8]\n\t\t\t\t\t\t|| super.friendsListOnlineStatus[k8] != 99)\n\t\t\t\t\tcontinue;\n\t\t\t\tj8 = 65280;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsetPixelsAndAroundColour(i + c / 2 + k2, (36 + c2 / 2) - i4, j8);\n\t\t}\n\t\tgameGraphics.method212(i + c / 2, 36 + c2 / 2, 2, 0xffffff, 255);\n\t\tgameGraphics.method242(i + 19, 55, SPRITE_MEDIA_START + 24,\n\t\t\t\tcameraRotation + 128 & 0xff, 128);\n\t\tgameGraphics.setDimensions(0, 0, windowWidth, windowHeight + 12);\n\t\tif (!flag)\n\t\t\treturn;\n\t\ti = super.mouseX\n\t\t\t\t- (((GameImage) (gameGraphics)).menuDefaultWidth - 199);\n\t\tint i8 = super.mouseY - 36;\n\t\tif (i >= 40 && i8 >= 0 && i < 196 && i8 < 152) {\n\t\t\tchar c1 = '\\234';\n\t\t\tchar c3 = '\\230';\n\t\t\tint l = 192 + anInt986;\n\t\t\tint j1 = cameraRotation + anInt985 & 0xff;\n\t\t\tint j = ((GameImage) (gameGraphics)).menuDefaultWidth - 199;\n\t\t\tj += 40;\n\t\t\tint l2 = ((super.mouseX - (j + c1 / 2)) * 16384) / (3 * l);\n\t\t\tint j4 = ((super.mouseY - (36 + c3 / 2)) * 16384) / (3 * l);\n\t\t\tint l4 = Camera.anIntArray384[1024 - j1 * 4 & 0x3ff];\n\t\t\tint j5 = Camera.anIntArray384[(1024 - j1 * 4 & 0x3ff) + 1024];\n\t\t\tint l6 = j4 * l4 + l2 * j5 >> 15;\n\t\t\tj4 = j4 * j5 - l2 * l4 >> 15;\n\t\t\tl2 = l6;\n\t\t\tl2 += ourPlayer.currentX;\n\t\t\tj4 = ourPlayer.currentY - j4;\n\t\t\tif (mouseButtonClick == 1)\n\t\t\t\tmethod112(getSectionX(), getSectionY(), l2 / 128, j4 / 128,\n\t\t\t\t\t\tfalse);\n\t\t\tmouseButtonClick = 0;\n\t\t}\n\t}\n\tpublic mudclient() {\n\t\tfor (int i = 0; i < questStage.length; i++)\n\t\t\tquestStage[i] = (byte) 0;\n\t\tcombatWindow = false;\n\t\tthreadSleepTime = 10;\n\t\ttry {\n\t\t\tlocalhost = InetAddress.getLocalHost().getHostAddress();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tlocalhost = \"unknown\";\n\t\t}\n\t\tif (config.getProperty(\"width\") == null) {\n\t\t\tConfig.storeConfig(\"width\", \"502\");\n\t\t}\n\t\tif (config.getProperty(\"height\") == null) {\n\t\t\tConfig.storeConfig(\"height\", \"382\");\n\t\t}\n\t\tif (config.getProperty(\"refreshRate\") == null) {\n\t\t\tConfig.storeConfig(\"refreshRate\",\n\t\t\t\t\t\"\" + Resolutions.oldDisplayMode.getRefreshRate());\n\t\t}\n\t\tif (config.getProperty(\"bitDepth\") == null) {\n\t\t\tConfig.storeConfig(\"bitDepth\",\n\t\t\t\t\t\"\" + Resolutions.oldDisplayMode.getBitDepth());\n\t\t}\n\t\twindowWidth = Integer.valueOf(config.getProperty(\"width\"));\n\t\twindowHeight = Integer.valueOf(config.getProperty(\"height\")) - 40;\n\t\tscreenDepth = Integer.valueOf(config.getProperty(\"bitDepth\"));\n\t\tscreenRefreshRate = Integer.valueOf(config.getProperty(\"refreshRate\"));\n\t\tif (windowWidth < defaultWidth || windowHeight < defaultHeight) {\n\t\t\twindowWidth = defaultWidth;\n\t\t\tConfig.storeConfig(\"width\", \"502\");\n\t\t\twindowHeight = defaultHeight;\n\t\t\tConfig.storeConfig(\"height\", \"382\");\n\t\t}\n\t\tif (windowWidth > 532) {\n\t\t\txAddition = (windowWidth - defaultWidth) / 2;\n\t\t\tyAddition = (windowHeight - defaultHeight) / 2;\n\t\t} else {\n\t\t\txAddition = 0;\n\t\t\tyAddition = 0;\n\t\t}\n\t\tstartTime = System.currentTimeMillis();\n\t\tduelMyItems = new int[8];\n\t\tduelMyItemsCount = new int[8];\n\t\tconfigAutoCameraAngle = true;\n\t\tquestionMenuAnswer = new String[10];\n\t\tlastNpcArray = new Mob[500];\n\t\tcurrentUser = \"\";\n\t\tcurrentPass = \"\";\n\t\tmenuText1 = new String[250];\n\t\tduelOpponentAccepted = false;\n\t\tduelMyAccepted = false;\n\t\ttradeConfirmItems = new int[14];\n\t\ttradeConfirmItemsCount = new int[14];\n\t\ttradeConfirmOtherItems = new int[14];\n\t\ttradeConfirmOtherItemsCount = new int[14];\n\t\tserverMessage = \"\";\n\t\tduelOpponentName = \"\";\n\t\tsetInventoryItems(new int[35]);\n\t\tinventoryItemsCount = new int[35];\n\t\twearing = new int[35];\n\t\tmobMessages = new String[50];\n\t\tshowBank = false;\n\t\tdoorModel = new Model[500];\n\t\tmobMessagesX = new int[50];\n\t\tmobMessagesY = new int[50];\n\t\tmobMessagesWidth = new int[50];\n\t\tmobMessagesHeight = new int[50];\n\t\tnpcArray = new Mob[500];\n\t\tequipmentStatus = new int[6];\n\t\tprayerOn = new boolean[50];\n\t\ttradeOtherAccepted = false;\n\t\ttradeWeAccepted = false;\n\t\tmobArray = new Mob[8000];\n\t\tanIntArray705 = new int[50];\n\t\tanIntArray706 = new int[50];\n\t\tlastWildYSubtract = -1;\n\t\tmemoryError = false;\n\t\tbankItemsMax = 48;\n\t\tshowQuestionMenu = false;\n\t\tmagicLoc = 128;\n\t\tcameraAutoAngle = 1;\n\t\tanInt727 = 2;\n\t\tshowServerMessageBox = false;\n\t\thasReceivedWelcomeBoxDetails = false;\n\t\tplayerStatCurrent = new int[18];\n\t\twildYSubtract = -1;\n\t\tanInt742 = -1;\n\t\tanInt743 = -1;\n\t\tanInt744 = -1;\n\t\tsectionXArray = new int[8000];\n\t\tsectionYArray = new int[8000];\n\t\tselectedItem = -1;\n\t\tselectedItemName = \"\";\n\t\tduelOpponentItems = new int[8];\n\t\tduelOpponentItemsCount = new int[8];\n\t\tanIntArray757 = new int[50];\n\t\tmenuID = new int[250];\n\t\tshowCharacterLookScreen = false;\n\t\tshowDrawPointsScreen = false;\n\t\tlastPlayerArray = new Mob[500];\n\t\tappletMode = true;\n\t\tgameDataModels = new Model[1000];\n\t\tconfigMouseButtons = false;\n\t\tduelNoRetreating = false;\n\t\tduelNoMagic = false;\n\t\tduelNoPrayer = false;\n\t\tduelNoWeapons = false;\n\t\tanIntArray782 = new int[50];\n\t\tduelConfirmOpponentItems = new int[8];\n\t\tduelConfirmOpponentItemsCount = new int[8];\n\t\tanIntArray786 = new int[50];\n\t\tanIntArray787 = new int[50];\n\t\tanIntArray788 = new int[50];\n\t\tobjectModelArray = new Model[1500];\n\t\tcameraRotation = 128;\n\t\tshowWelcomeBox = false;\n\t\tcharacterBodyGender = 1;\n\t\tcharacter2Colour = 2;\n\t\tcharacterHairColour = 2;\n\t\tcharacterTopColour = 8;\n\t\tcharacterBottomColour = 14;\n\t\tcharacterHeadGender = 1;\n\t\tselectedBankItem = -1;\n\t\tselectedBankItemType = -2;\n\t\tmenuText2 = new String[250];\n\t\taBooleanArray827 = new boolean[1500];\n\t\tplayerStatBase = new int[18];\n\t\tmenuActionType = new int[250];\n\t\tmenuActionVariable = new int[250];\n\t\tmenuActionVariable2 = new int[250];\n\t\tshopItems = new int[256];\n\t\tshopItemCount = new int[256];\n\t\tshopItemsSellPrice = new int[256];\n\t\tshopItemsBuyPrice = new int[256];\n\t\tanIntArray858 = new int[50];\n\t\tanIntArray859 = new int[50];\n\t\tnewBankItems = new int[256];\n\t\tnewBankItemsCount = new int[256];\n\t\tduelConfirmMyItems = new int[8];\n\t\tduelConfirmMyItemsCount = new int[8];\n\t\tmobArrayIndexes = new int[500];\n\t\tmessagesTimeout = new int[5];\n\t\tobjectX = new int[1500];\n\t\tobjectY = new int[1500];\n\t\tobjectType = new int[1500];\n\t\tobjectID = new int[1500];\n\t\tmenuActionX = new int[250];\n\t\tmenuActionY = new int[250];\n\t\tourPlayer = new Mob();\n\t\tserverIndex = -1;\n\t\tanInt882 = 30;\n\t\tshowTradeConfirmWindow = false;\n\t\ttradeConfirmAccepted = false;\n\t\tplayerArray = new Mob[500];\n\t\tserverMessageBoxTop = false;\n\t\tcameraHeight = 750;\n\t\tbankItems = new int[256];\n\t\tbankItemsCount = new int[256];\n\t\tnotInWilderness = false;\n\t\tselectedSpell = -1;\n\t\tanInt911 = 2;\n\t\ttradeOtherItems = new int[14];\n\t\ttradeOtherItemsCount = new int[14];\n\t\tmenuIndexes = new int[250];\n\t\tzoomCamera = false;\n\t\tplayerStatExperience = new int[18];\n\t\tcameraAutoAngleDebug = false;\n\t\tnpcRecordArray = new Mob[8000];\n\t\tshowDuelWindow = false;\n\t\tanIntArray923 = new int[50];\n\t\tlastLoadedNull = false;\n\t\texperienceArray = new int[99];\n\t\tshowShop = false;\n\t\tmouseClickXArray = new int[8192];\n\t\tmouseClickYArray = new int[8192];\n\t\tshowDuelConfirmWindow = false;\n\t\tduelWeAccept = false;\n\t\tdoorX = new int[500];\n\t\tdoorY = new int[500];\n\t\tconfigSoundEffects = false;\n\t\tshowRightClickMenu = false;\n\t\tattackingInt40 = 40;\n\t\tanIntArray944 = new int[50];\n\t\tdoorDirection = new int[500];\n\t\tdoorType = new int[500];\n\t\tgroundItemX = new int[8000];\n\t\tgroundItemY = new int[8000];\n\t\tgroundItemType = new int[8000];\n\t\tgroundItemObjectVar = new int[8000];\n\t\tselectedShopItemIndex = -1;\n\t\tselectedShopItemType = -2;\n\t\tmessagesArray = new String[5];\n\t\tshowTradeWindow = false;\n\t\taBooleanArray970 = new boolean[500];\n\t\ttradeMyItems = new int[14];\n\t\ttradeMyItemsCount = new int[14];\n\t\tcameraSizeInt = 9;\n\t\ttradeOtherPlayerName = \"\";\n\t\tmc = this;\n\t}\n\tprivate boolean combatWindow;\n\tprivate int lastLoggedInDays;\n\tprivate int subscriptionLeftDays;\n\tprivate int duelMyItemCount;\n\tprivate int duelMyItems[];\n\tprivate int duelMyItemsCount[];\n\tprivate boolean configAutoCameraAngle;\n\tprivate String questionMenuAnswer[];\n\tprivate int anInt658;\n\tprivate Mob lastNpcArray[];\n\tprivate int loginButtonNewUser;\n\tprivate int loginButtonExistingUser;\n\tprivate String currentUser;\n\tprivate String currentPass;\n\tprivate int lastWalkTimeout;\n\tprivate String menuText1[];\n\tprivate boolean duelOpponentAccepted;\n\tprivate boolean duelMyAccepted;\n\tprivate int tradeConfirmItemCount;\n\tprivate int tradeConfirmItems[];\n\tprivate int tradeConfirmItemsCount[];\n\tprivate int tradeConfirmOtherItemCount;\n\tprivate int tradeConfirmOtherItems[];\n\tprivate int tradeConfirmOtherItemsCount[];\n\tstatic String serverMessage;\n\tprivate String duelOpponentName;\n\tprivate int mouseOverBankPageText;\n\tpublic int playerCount;\n\tprivate int lastPlayerCount;\n\tprivate int fightCount;\n\tprivate int inventoryCount;\n\tprivate int inventoryItems[];\n\tprivate int inventoryItemsCount[];\n\tprivate int wearing[];\n\tprivate int mobMessageCount;\n\tString mobMessages[];\n\tprivate boolean showBank;\n\tprivate Model doorModel[];\n\tprivate int mobMessagesX[];\n\tprivate int mobMessagesY[];\n\tprivate int mobMessagesWidth[];\n\tprivate int mobMessagesHeight[];\n\tpublic Mob npcArray[];\n\tprivate int equipmentStatus[];\n\tprivate final int characterTopBottomColours[] = { 0xff0000, 0xff8000,\n\t\t\t0xffe000, 0xa0e000, 57344, 32768, 41088, 45311, 33023, 12528,\n\t\t\t0xe000e0, 0x303030, 0x604000, 0x805000, 0xffffff };\n\tprivate int loginScreenNumber;\n\tprivate int anInt699;\n\tprivate boolean prayerOn[];\n\tprivate boolean tradeOtherAccepted;\n\tprivate boolean tradeWeAccepted;\n\tprivate Mob mobArray[];\n\tprivate int npcCombatModelArray1[] = { 0, 1, 2, 1, 0, 0, 0, 0 };\n\tprivate int anIntArray705[];\n\tprivate int anIntArray706[];\n\tpublic int npcCount;\n\tprivate int lastNpcCount;\n\tprivate int wildX;\n\tprivate int wildY;\n\tprivate int wildYMultiplier;\n\tprivate int lastWildYSubtract;\n\tprivate boolean memoryError;\n\tprivate int bankItemsMax;\n\tprivate int mouseOverMenu;\n\tprivate int walkModel[] = { 0, 1, 2, 1 };\n\tprivate boolean showQuestionMenu;\n\tprivate int anInt718;\n\tpublic int magicLoc;\n\tpublic int loggedIn;\n\tprivate int cameraAutoAngle;\n\tprivate int cameraRotationBaseAddition;\n\tprivate Menu spellMenu;\n\tint spellMenuHandle;\n\tint menuMagicPrayersSelected;\n\tprivate int screenRotationX;\n\tprivate int anInt727;\n\tprivate int showAbuseWindow;\n\tprivate int duelCantRetreat;\n\tprivate int duelUseMagic;\n\tprivate int duelUsePrayer;\n\tprivate int duelUseWeapons;\n\tstatic boolean showServerMessageBox;\n\tprivate boolean hasReceivedWelcomeBoxDetails;\n\tprivate String lastLoggedInAddress;\n\tprivate int loginTimer;\n\tprivate int playerStatCurrent[];\n\tprivate int areaX;\n\tprivate int areaY;\n\tprivate int wildYSubtract;\n\tprivate int anInt742;\n\tprivate int anInt743;\n\tprivate int anInt744;\n\tpublic int sectionXArray[];\n\tpublic int sectionYArray[];\n\tprivate int selectedItem;\n\tString selectedItemName;\n\tprivate int menuX;\n\tprivate int menuY;\n\tprivate int menuWidth;\n\tprivate int menuHeight;\n\tprivate int menuLength;\n\tprivate int duelOpponentItemCount;\n\tprivate int duelOpponentItems[];\n\tprivate int duelOpponentItemsCount[];\n\tprivate int anIntArray757[];\n\tprivate int menuID[];\n\tprivate boolean showCharacterLookScreen;\n\tprivate boolean showDrawPointsScreen;\n\tprivate int newBankItemCount;\n\tprivate int npcCombatModelArray2[] = { 0, 0, 0, 0, 0, 1, 2, 1 };\n\tprivate Mob lastPlayerArray[];\n\tprivate int inputBoxType;\n\tprivate boolean appletMode;\n\tprivate int combatStyle;\n\tprivate Model gameDataModels[];\n\tprivate boolean configMouseButtons;\n\tprivate boolean duelNoRetreating;\n\tprivate boolean duelNoMagic;\n\tprivate boolean duelNoPrayer;\n\tprivate boolean duelNoWeapons;\n\tprivate int anIntArray782[];\n\tprivate int duelConfirmOpponentItemCount;\n\tprivate int duelConfirmOpponentItems[];\n\tprivate int duelConfirmOpponentItemsCount[];\n\tprivate int anIntArray786[];\n\tprivate int anIntArray787[];\n\tprivate int anIntArray788[];\n\tprivate int anInt789;\n\tprivate int anInt790;\n\tprivate int anInt791;\n\tprivate int anInt792;\n\tprivate Menu menuLogin;\n\tprivate final int characterHairColours[] = { 0xffc030, 0xffa040, 0x805030,\n\t\t\t0x604020, 0x303030, 0xff6020, 0xff4000, 0xffffff, 65280, 65535 };\n\tprivate Model objectModelArray[];\n\tprivate Menu menuWelcome;\n\tprivate int systemUpdate;\n\tprivate int cameraRotation;\n\tprivate int logoutTimeout;\n\tprivate Menu gameMenu;\n\tint messagesHandleType2;\n\tint chatHandle;\n\tint messagesHandleType5;\n\tint messagesHandleType6;\n\tint messagesTab;\n\tprivate boolean showWelcomeBox;\n\tprivate int characterHeadType;\n\tprivate int characterBodyGender;\n\tprivate int character2Colour;\n\tprivate int characterHairColour;\n\tprivate int characterTopColour;\n\tprivate int characterBottomColour;\n\tprivate int characterSkinColour;\n\tprivate int characterHeadGender;\n\tprivate int loginStatusText;\n\tprivate int loginUsernameTextBox;\n\tprivate int loginPasswordTextBox;\n\tprivate int loginOkButton;\n\tprivate int loginCancelButton;\n\tprivate int selectedBankItem;\n\tprivate int selectedBankItemType;\n\tprivate String menuText2[];\n\tint anInt826;\n\tprivate boolean aBooleanArray827[];\n\tprivate int playerStatBase[];\n\tprivate int abuseSelectedType;\n\tpublic int actionPictureType;\n\tint actionPictureX;\n\tint actionPictureY;\n\tprivate int menuActionType[];\n\tprivate int menuActionVariable[];\n\tprivate int menuActionVariable2[];\n\tprivate int shopItems[];\n\tprivate int shopItemCount[];\n\tprivate int shopItemsBuyPrice[];\n\tprivate int shopItemsSellPrice[];\n\tprivate byte[] x = new byte[] { 111, 114, 103, 46, 114, 115, 99, 97, 110,\n\t\t\t103, 101, 108, 46, 99, 108, 105, 101, 110, 116, 46, 109, 117, 100,\n\t\t\t99, 108, 105, 101, 110, 116, 46, 99, 104, 101, 99, 107, 77, 111,\n\t\t\t117, 115, 101, 83, 116, 97, 116, 117, 115, 40, 41 };\n\tprivate byte[] y = new byte[] { 111, 114, 103, 46, 114, 115, 99, 97, 110,\n\t\t\t103, 101, 108, 46, 99, 108, 105, 101, 110, 116, 46, 109, 117, 100,\n\t\t\t99, 108, 105, 101, 110, 116, 46, 100, 114, 97, 119, 82, 105, 103,\n\t\t\t104, 116, 67, 108, 105, 99, 107, 77, 101, 110, 117, 40, 41 };\n\tprivate int npcAnimationArray[][] = {\n\t\t\t{ 11, 2, 9, 7, 1, 6, 10, 0, 5, 8, 3, 4 },\n\t\t\t{ 11, 2, 9, 7, 1, 6, 10, 0, 5, 8, 3, 4 },\n\t\t\t{ 11, 3, 2, 9, 7, 1, 6, 10, 0, 5, 8, 4 },\n\t\t\t{ 3, 4, 2, 9, 7, 1, 6, 10, 8, 11, 0, 5 },\n\t\t\t{ 3, 4, 2, 9, 7, 1, 6, 10, 8, 11, 0, 5 },\n\t\t\t{ 4, 3, 2, 9, 7, 1, 6, 10, 8, 11, 0, 5 },\n\t\t\t{ 11, 4, 2, 9, 7, 1, 6, 10, 0, 5, 8, 3 },\n\t\t\t{ 11, 2, 9, 7, 1, 6, 10, 0, 5, 8, 4, 3 } };\n\tprivate int bankItemCount;\n\tprivate int strDownButton;\n\tprivate int atkDownButton;\n\tprivate int defDownButton;\n\tprivate int magDownButton;\n\tprivate int rangeDownButton;\n\tprivate int strUpButton;\n\tprivate int atkUpButton;\n\tprivate int defUpButton;\n\tprivate int magUpButton;\n\tprivate int rangeUpButton;\n\tprivate int dPSAcceptButton;\n\tpublic static final int[] pkexperienceArray = { 83, 174, 276, 388, 512,\n\t\t\t650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115,\n\t\t\t3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824,\n\t\t\t12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,\n\t\t\t30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983,\n\t\t\t75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872,\n\t\t\t166636, 184040, 203254, 224466, 247886, 273742, 302288, 333804,\n\t\t\t368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627,\n\t\t\t814445, 899257, 992895, 1096278, 1210421, 1336443, 1475581,\n\t\t\t1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373,\n\t\t\t3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831,\n\t\t\t6517253, 7195629, 7944614, 8771558, 9684577, 10692629, 11805606,\n\t\t\t13034431, 14391160 };\n\tprivate int pkmagic, pkrange, pkatk, pkdef, pkstr = 1;\n\tprivate long pkpoints = 0;\n\tprivate int pkmagictext, pkcombattext, pkpointstext, pkrangetext,\n\t\t\tpkatktext, pkdeftext, pkstrtext = 0;\n\tprivate boolean pkreset = true;\n\tprivate int characterDesignHeadButton1;\n\tprivate int characterDesignHeadButton2;\n\tprivate int characterDesignHairColourButton1;\n\tprivate int characterDesignHairColourButton2;\n\tprivate int characterDesignGenderButton1;\n\tprivate int characterDesignGenderButton2;\n\tprivate int characterDesignTopColourButton1;\n\tprivate int characterDesignTopColourButton2;\n\tprivate int characterDesignSkinColourButton1;\n\tprivate int characterDesignSkinColourButton2;\n\tprivate int characterDesignBottomColourButton1;\n\tprivate int characterDesignBottomColourButton2;\n\tprivate int characterDesignAcceptButton;\n\tprivate int anIntArray858[];\n\tprivate int anIntArray859[];\n\tprivate int newBankItems[];\n\tprivate int newBankItemsCount[];\n\tprivate int duelConfirmMyItemCount;\n\tprivate int duelConfirmMyItems[];\n\tprivate int duelConfirmMyItemsCount[];\n\tprivate int mobArrayIndexes[];\n\tprivate Menu menuNewUser;\n\tprivate int messagesTimeout[];\n\tprivate int lastAutoCameraRotatePlayerX;\n\tprivate int lastAutoCameraRotatePlayerY;\n\tprivate int questionMenuCount;\n\tpublic int objectX[];\n\tpublic int objectY[];\n\tpublic int objectType[];\n\tprivate int objectID[];\n\tprivate int menuActionX[];\n\tprivate int menuActionY[];\n\tpublic Mob ourPlayer;\n\tprivate int sectionX;\n\tprivate int sectionY;\n\tint serverIndex;\n\tprivate int anInt882;\n\tprivate int mouseDownTime;\n\tprivate int itemIncrement;\n\tpublic int groundItemCount;\n\tprivate int modelFireLightningSpellNumber;\n\tprivate int modelTorchNumber;\n\tprivate int modelClawSpellNumber;\n\tprivate boolean showTradeConfirmWindow;\n\tprivate boolean tradeConfirmAccepted;\n\tprivate int anInt892;\n\tpublic EngineHandle engineHandle;\n\tpublic Mob playerArray[];\n\tprivate boolean serverMessageBoxTop;\n\tprivate final String equipmentStatusName[] = { \"Armour\", \"WeaponAim\",\n\t\t\t\"WeaponPower\", \"Magic\", \"Prayer\", \"Range\" };\n\tpublic int flagged = 0;\n\tprivate int referId;\n\tprivate int anInt900;\n\tprivate int newUserOkButton;\n\tprivate int mouseButtonClick;\n\tprivate int cameraHeight;\n\tprivate int bankItems[];\n\tprivate int bankItemsCount[];\n\tprivate boolean notInWilderness;\n\tprivate int selectedSpell;\n\tprivate int screenRotationY;\n\tprivate int anInt911;\n\tprivate int tradeOtherItemCount;\n\tprivate int tradeOtherItems[];\n\tprivate int tradeOtherItemsCount[];\n\tprivate int menuIndexes[];\n\tprivate boolean zoomCamera;\n\tprivate AudioReader audioReader;\n\tprivate int playerStatExperience[];\n\tprivate boolean cameraAutoAngleDebug;\n\tprivate Mob npcRecordArray[];\n\tprivate final String skillArray[] = { \"Attack\", \"Defense\", \"Strength\",\n\t\t\t\"Hits\", \"Ranged\", \"Prayer\", \"Magic\", \"Cooking\", \"Woodcut\",\n\t\t\t\"Fletching\", \"Fishing\", \"Firemaking\", \"Crafting\", \"Smithing\",\n\t\t\t\"Mining\", \"Herblaw\", \"Agility\", \"Thieving\" };\n\tprivate boolean showDuelWindow;\n\tprivate int anIntArray923[];\n\tpublic GameImageMiddleMan gameGraphics;\n\tprivate final String skillArrayLong[] = { \"Attack\", \"Defense\", \"Strength\",\n\t\t\t\"Hitpoints\", \"Ranged\", \"Prayer\", \"Magic\", \"Cooking\", \"Woodcutting\",\n\t\t\t\"Fletching\", \"Fishing\", \"Firemaking\", \"Crafting\", \"Smithing\",\n\t\t\t\"Mining\", \"Herblaw\", \"Agility\", \"Thieving\" };\n\tprivate boolean lastLoadedNull;\n\tprivate int experienceArray[];\n\tprivate Camera gameCamera;\n\tprivate boolean showShop;\n\tprivate int mouseClickArrayOffset;\n\tint mouseClickXArray[];\n\tint mouseClickYArray[];\n\tprivate boolean showDuelConfirmWindow;\n\tprivate boolean duelWeAccept;\n\tprivate Graphics aGraphics936;\n\tprivate int doorX[];\n\tprivate int doorY[];\n\tprivate int wildernessType;\n\tprivate boolean configSoundEffects;\n\tprivate boolean showRightClickMenu;\n\tprivate int screenRotationTimer;\n\tprivate int attackingInt40;\n\tprivate int anIntArray944[];\n\tprivate Menu characterDesignMenu;\n\tprivate Menu drawPointsScreen;\n\tprivate int shopItemSellPriceModifier;\n\tprivate int shopItemBuyPriceModifier;\n\tprivate int modelUpdatingTimer;\n\tprivate int doorCount;\n\tprivate int doorDirection[];\n\tprivate int doorType[];\n\tprivate int anInt952;\n\tprivate int anInt953;\n\tprivate int anInt954;\n\tprivate int anInt955;\n\tpublic int groundItemX[];\n\tpublic int groundItemY[];\n\tpublic int groundItemType[];\n\tprivate int groundItemObjectVar[];\n\tprivate int selectedShopItemIndex;\n\tprivate int selectedShopItemType;\n\tprivate String messagesArray[];\n\tprivate long tradeConfirmOtherNameLong;\n\tprivate boolean showTradeWindow;\n\tprivate int playerAliveTimeout;\n\tprivate final int characterSkinColours[] = { 0xecded0, 0xccb366, 0xb38c40,\n\t\t\t0x997326, 0x906020 };\n\tprivate byte sounds[];\n\tprivate boolean aBooleanArray970[];\n\tpublic int objectCount;\n\tprivate int tradeMyItemCount;\n\tprivate int tradeMyItems[];\n\tprivate int tradeMyItemsCount[];\n\tpublic int windowWidth = 512;\n\tpublic int windowHeight = 334;\n\tpublic int screenDepth;\n\tpublic int screenRefreshRate;\n\tint defaultWidth = 512;\n\tint defaultHeight = 334;\n\tpublic int xAddition;\n\tpublic int yAddition;\n\tprivate int cameraSizeInt;\n\tprivate Menu friendsMenu;\n\tint friendsMenuHandle;\n\tint anInt981;\n\tlong privateMessageTarget;\n\tprivate long duelOpponentNameLong;\n\tprivate String tradeOtherPlayerName;\n\tprivate int anInt985;\n\tprivate int anInt986;\n\tprivate boolean aBoolean767;\n\tpublic final static void drawDownloadProgress(String s, int progress,\n\t\t\tboolean download) {\n\t\ttry {\n\t\t\tint j = (appletWidth - 281) / 2;\n\t\t\tint k = (appletHeight - 148) / 2;\n\t\t\tj += 2 + 4;\n\t\t\tk += 122;\n\t\t\tint l = (281 * progress) / 100;\n\t\t\tgetLoadingGraphics().setColor(BAR_COLOUR);\n\t\t\tgetLoadingGraphics().fillRect(j, k, l, 20);\n\t\t\tgetLoadingGraphics().setColor(Color.black);\n\t\t\tgetLoadingGraphics().fillRect(j + l, k, 281 - l, 20);\n\t\t\tgetLoadingGraphics().setColor(Color.WHITE);\n\t\t\tgetLoadingGraphics().drawString(\n\t\t\t\t\t(download ? \"Downloading: \" : \"\") + s + \" \" + progress\n\t\t\t\t\t\t\t+ \"%\", j + (download ? 54 : 54), k + 14);\n\t\t} catch (Exception _ex) {\n\t\t}\n\t}\n\tpublic static File getFile(String filename) {\n\t\tFile file = new File(Config.CONF_DIR + File.separator + filename);\n\t\tif (file.isFile() && file.exists()) {\n\t\t\treturn file;\n\t\t} else\n\t\t\treturn null;\n\t}\n\tpublic void setSectionX(int sectionX) {\n\t\tthis.sectionX = sectionX;\n\t}\n\tpublic int getSectionX() {\n\t\treturn sectionX;\n\t}\n\tpublic void setSectionY(int sectionY) {\n\t\tthis.sectionY = sectionY;\n\t}\n\tpublic int getSectionY() {\n\t\treturn sectionY;\n\t}\n\tpublic void setAreaY(int areaY) {\n\t\tthis.areaY = areaY;\n\t}\n\tpublic int getAreaY() {\n\t\treturn areaY;\n\t}\n\tpublic void setAreaX(int areaX) {\n\t\tthis.areaX = areaX;\n\t}\n\tpublic int getAreaX() {\n\t\treturn areaX;\n\t}\n\tpublic static void drawPopup(String message) {\n\t\tserverMessage = message;\n\t\tshowServerMessageBox = true;\n\t}\n\tpublic void sendSmithingItem(int spriteID) {\n\t\tstreamClass.createPacket(201);\n\t\tstreamClass.add4ByteInt(spriteID);\n\t\tstreamClass.formatPacket();\n\t}\n\tpublic void sendSmithingClose() {\n\t\tstreamClass.createPacket(202);\n\t\tstreamClass.formatPacket();\n\t}\n\tpublic void setInventoryItems(int inventoryItems[]) {\n\t\tthis.inventoryItems = inventoryItems;\n\t}\n\tpublic int[] getInventoryItems() {\n\t\treturn inventoryItems;\n\t}\n}\n"} {"input": " public static String parseMessage(String pName, String world, String msg, String format) {\n Object prefix = Reader.getRawPrefix(pName, InfoType.USER, world);\n Object suffix = Reader.getRawSuffix(pName, InfoType.USER, world);\n Object group = Reader.getRawGroup(pName, InfoType.USER, world);\n String vI = ConfigType.MCHAT_VAR_INDICATOR.getString();\n if (msg == null)\n msg = \"\";\n if (prefix == null)\n prefix = \"\";\n if (suffix == null)\n suffix = \"\";\n if (group == null)\n group = \"\";\n String hSClass = \"\";\n String hClass = \"\";\n String hHealth = \"\";\n String hHBar = \"\";\n String hMana = \"\";\n String hMBar = \"\";\n String hParty = \"\";\n String hMastered = \"\";\n String hLevel = \"\";\n String hSLevel = \"\";\n String hExp = \"\";\n String hSExp = \"\";\n String hEBar = \"\";\n String hSEBar = \"\";\n String tTown = \"\";\n String tTownName = \"\";\n String tTitle = \"\";\n String tSurname = \"\";\n String tResidentName = \"\";\n String tPrefix = \"\";\n String tNamePrefix = \"\";\n String tPostfix = \"\";\n String tNamePostfix = \"\";\n String tNation = \"\";\n String tNationName = \"\";\n String tNationTag = \"\";\n Double locX = (double) randomNumber(-100, 100);\n Double locY = (double) randomNumber(-100, 100);\n Double locZ = (double) randomNumber(-100, 100);\n String loc = (\"X: \" + locX + \", \" + \"Y: \" + locY + \", \" + \"Z: \" + locZ);\n String healthbar = \"\";\n String health = String.valueOf(randomNumber(1, 20));\n String pWorld = \"\";\n String hungerLevel = String.valueOf(randomNumber(0, 20));\n String hungerBar = API.createBasicBar(randomNumber(0, 20), 20, 10);\n String level = String.valueOf(randomNumber(1, 2));\n String exp = String.valueOf(randomNumber(0, 200))+ \"/\" + ((randomNumber(1, 2) + 1) * 10);\n String expBar = API.createBasicBar(randomNumber(0, 200), ((randomNumber(1, 2) + 1) * 10), 10);\n String tExp = String.valueOf(randomNumber(0, 300));\n String gMode = String.valueOf(randomNumber(0, 1));\n Date now = new Date();\n SimpleDateFormat dateFormat = new SimpleDateFormat(LocaleType.FORMAT_DATE.getRaw());\n String time = dateFormat.format(now);\n String dName = pName;\n String dType = \"\";\n if (ConfigType.MCHAT_CHAT_DISTANCE.getDouble() > 0) {\n dType = LocaleType.FORMAT_LOCAL.getVal();\n }\n String sType = \"\";\n if (MChat.isSpying.get(pName) != null\n && MChat.isSpying.get(pName))\n sType = LocaleType.FORMAT_SPY.getVal();\n if (Bukkit.getServer().getPlayer(pName) != null) {\n Player player = Bukkit.getServer().getPlayer(pName);\n locX = player.getLocation().getX();\n locY = player.getLocation().getY();\n locZ = player.getLocation().getZ();\n loc = (\"X: \" + locX + \", \" + \"Y: \" + locY + \", \" + \"Z: \" + locZ);\n healthbar = API.createHealthBar(player);\n health = String.valueOf(player.getHealth());\n pWorld = player.getWorld().getName();\n hungerLevel = String.valueOf(player.getFoodLevel());\n hungerBar = API.createBasicBar(player.getFoodLevel(), 20, 10);\n level = String.valueOf(player.getLevel());\n exp = String.valueOf(player.getExp()) + \"/\" + ((player.getLevel() + 1) * 10);\n expBar = API.createBasicBar(player.getExp(), ((player.getLevel() + 1) * 10), 10);\n tExp = String.valueOf(player.getTotalExperience());\n gMode = \"\";\n if (player.getGameMode() != null && player.getGameMode().name() != null)\n gMode = player.getGameMode().name();\n dName = player.getDisplayName();\n if (heroesB) {\n Hero hero = heroes.getCharacterManager().getHero(player);\n HeroClass heroClass = hero.getHeroClass();\n HeroClass heroSClass = hero.getSecondClass();\n int hL = hero.getLevel();\n int hSL = hero.getLevel(heroSClass);\n double hE = hero.getExperience(heroClass);\n double hSE = hero.getExperience(heroSClass);\n hClass = hero.getHeroClass().getName();\n hHealth = String.valueOf(hero.getHealth());\n hHBar = Messaging.createHealthBar(hero.getHealth(), hero.getMaxHealth());\n hMana = String.valueOf(hero.getMana());\n hLevel = String.valueOf(hL);\n hExp = String.valueOf(hE);\n hEBar = Messaging.createExperienceBar(hero, heroClass);\n Integer hMMana = hero.getMaxMana();\n if (hMMana != null)\n hMBar = Messaging.createManaBar(hero.getMana(), hero.getMaxMana());\n if (hero.getParty() != null)\n hParty = hero.getParty().toString();\n if (heroSClass != null) {\n hSClass = heroSClass.getName();\n hSLevel = String.valueOf(hSL);\n hSExp = String.valueOf(hSE);\n hSEBar = Messaging.createExperienceBar(hero, heroSClass);\n }\n if ((hero.isMaster(heroClass))\n && (heroSClass == null || hero.isMaster(heroSClass)))\n hMastered = LocaleType.MESSAGE_HEROES_TRUE.getVal();\n else\n hMastered = LocaleType.MESSAGE_HEROES_FALSE.getVal();\n }\n if (townyB) {\n try {\n Resident resident = TownyUniverse.getDataSource().getResident(pName);\n if (resident.hasTown()) {\n Town town = resident.getTown();\n tTown = town.getName();\n tTownName = TownyFormatter.getFormattedTownName(town);\n tTitle = resident.getTitle();\n tSurname = resident.getSurname();\n tResidentName = resident.getFormattedName();\n tPrefix = resident.hasTitle() ? resident.getTitle() : TownyFormatter.getNamePrefix(resident);\n tNamePrefix = TownyFormatter.getNamePrefix(resident);\n tPostfix = resident.hasSurname() ? resident.getSurname() : TownyFormatter.getNamePostfix(resident);\n tNamePostfix = TownyFormatter.getNamePostfix(resident);\n if (resident.hasNation()) {\n Nation nation = town.getNation();\n tNation = nation.getName();\n tNationName = nation.getFormattedName();\n tNationTag = nation.getTag();\n }\n }\n } catch (Exception ignored) {}\n }\n }\n String formatAll = parseVars(format, pName, world);\n msg = msg.replaceAll(\"%\", \"%%\");\n formatAll = formatAll.replaceAll(\"%\", \"%%\");\n formatAll = MessageUtil.addColour(formatAll);\n if (ConfigType.MCHAT_CAPS_LOCK_RANGE.getInteger() > 0)\n msg = fixCaps(msg, ConfigType.MCHAT_CAPS_LOCK_RANGE.getInteger());\n if (formatAll == null)\n return msg;\n if (API.checkPermissions(pName, world, \"mchat.coloredchat\"))\n msg = MessageUtil.addColour(msg);\n if (!API.checkPermissions(pName, world, \"mchat.censorbypass\"))\n msg = replaceCensoredWords(msg);\n TreeMap<String, Object> fVarMap = new TreeMap<String, Object>();\n TreeMap<String, Object> rVarMap = new TreeMap<String, Object>();\n TreeMap<String, Object> lVarMap = new TreeMap<String, Object>();\n addVar(fVarMap, vI + \"mnameformat,\" + vI + \"mnf\", LocaleType.FORMAT_NAME.getVal());\n addVar(fVarMap, vI + \"healthbar,\" + vI + \"hb\", healthbar);\n addVar(rVarMap, vI + \"distancetype,\" + vI + \"dtype\", dType);\n addVar(rVarMap, vI + \"displayname,\" + vI + \"dname,\" + vI + \"dn\", dName);\n addVar(rVarMap, vI + \"experiencebar,\" + vI + \"expb,\" + vI + \"ebar,\" + vI + \"eb\", expBar);\n addVar(rVarMap, vI + \"experience,\" + vI + \"exp\", exp);\n addVar(rVarMap, vI + \"gamemode,\" + vI + \"gm\", gMode);\n addVar(rVarMap, vI + \"group,\" + vI + \"g\", group);\n addVar(rVarMap, vI + \"hungerbar,\" + vI + \"hub\", hungerBar);\n addVar(rVarMap, vI + \"hunger\", hungerLevel);\n addVar(rVarMap, vI + \"health,\" + vI + \"h\", health);\n addVar(rVarMap, vI + \"location,\" + vI + \"loc\", loc);\n addVar(rVarMap, vI + \"level,\" + vI + \"l\", level);\n addVar(rVarMap, vI + \"mname,\" + vI + \"mn\", Reader.getMName(pName));\n addVar(rVarMap, vI + \"pname,\" + vI + \"n\", pName);\n addVar(rVarMap, vI + \"prefix,\" + vI + \"p\", prefix);\n addVar(rVarMap, vI + \"spying,\" + vI + \"spy\", sType);\n addVar(rVarMap, vI + \"suffix,\" + vI + \"s\", suffix);\n addVar(rVarMap, vI + \"totalexp,\" + vI + \"texp,\" + vI + \"te\", tExp);\n addVar(rVarMap, vI + \"time,\" + vI + \"t\", time);\n addVar(rVarMap, vI + \"world,\" + vI + \"w\", pWorld);\n addVar(rVarMap, vI + \"Groupname,\" + vI + \"Gname,\" + vI + \"G\", Reader.getGroupName(group.toString()));\n addVar(rVarMap, vI + \"HClass,\" + vI + \"HC\", hClass);\n addVar(rVarMap, vI + \"HExp,\" + vI + \"HEx\", hExp);\n addVar(rVarMap, vI + \"HEBar,\" + vI + \"HEb\", hEBar);\n addVar(rVarMap, vI + \"HHBar,\" + vI + \"HHB\", hHBar);\n addVar(rVarMap, vI + \"HHealth,\" + vI + \"HH\", hHealth);\n addVar(rVarMap, vI + \"HLevel,\" + vI + \"HL\", hLevel);\n addVar(rVarMap, vI + \"HMastered,\" + vI + \"HMa\", hMastered);\n addVar(rVarMap, vI + \"HMana,\" + vI + \"HMn\", hMana);\n addVar(rVarMap, vI + \"HMBar,\" + vI + \"HMb\", hMBar);\n addVar(rVarMap, vI + \"HParty,\" + vI + \"HPa\", hParty);\n addVar(rVarMap, vI + \"HSecClass,\" + vI + \"HSC\", hSClass);\n addVar(rVarMap, vI + \"HSecExp,\" + vI + \"HSEx\", hSExp);\n addVar(rVarMap, vI + \"HSecEBar,\" + vI + \"HSEb\", hSEBar);\n addVar(rVarMap, vI + \"HSecLevel,\" + vI + \"HSL\", hSLevel);\n addVar(rVarMap, vI + \"town\", tTown);\n addVar(rVarMap, vI + \"townname\", tTownName);\n addVar(rVarMap, vI + \"townysurname\", tSurname);\n addVar(rVarMap, vI + \"townytitle\", tTitle);\n addVar(rVarMap, vI + \"townyresidentname\", tResidentName);\n addVar(rVarMap, vI + \"townyprefix\", tPrefix);\n addVar(rVarMap, vI + \"townynameprefix\", tNamePrefix);\n addVar(rVarMap, vI + \"townypostfix\", tPostfix);\n addVar(rVarMap, vI + \"townynamepostfix\", tNamePostfix);\n addVar(rVarMap, vI + \"townynation\", tNation);\n addVar(rVarMap, vI + \"townynationname\", tNationName);\n addVar(rVarMap, vI + \"townynationtag\", tNationTag);\n addVar(rVarMap, vI + \"Worldname,\" + vI + \"Wname,\" + vI + \"W\", Reader.getWorldName(pWorld));\n addVar(lVarMap, vI + \"message,\" + vI + \"msg,\" + vI + \"m\", msg);\n formatAll = replaceCustVars(pName, formatAll);\n formatAll = replaceVars(formatAll, fVarMap.descendingMap(), true);\n formatAll = replaceVars(formatAll, rVarMap.descendingMap(), true);\n formatAll = replaceVars(formatAll, lVarMap.descendingMap(), false);\n return formatAll;\n }\n", "output": " public static String parseMessage(String pName, String world, String msg, String format) {\n Object prefix = Reader.getRawPrefix(pName, InfoType.USER, world);\n Object suffix = Reader.getRawSuffix(pName, InfoType.USER, world);\n Object group = Reader.getRawGroup(pName, InfoType.USER, world);\n String vI = ConfigType.MCHAT_VAR_INDICATOR.getString();\n if (msg == null)\n msg = \"\";\n if (prefix == null)\n prefix = \"\";\n if (suffix == null)\n suffix = \"\";\n if (group == null)\n group = \"\";\n String hSClass = \"\";\n String hClass = \"\";\n String hHealth = \"\";\n String hHBar = \"\";\n String hMana = \"\";\n String hMBar = \"\";\n String hParty = \"\";\n String hMastered = \"\";\n String hLevel = \"\";\n String hSLevel = \"\";\n String hExp = \"\";\n String hSExp = \"\";\n String hEBar = \"\";\n String hSEBar = \"\";\n String tTown = \"\";\n String tTownName = \"\";\n String tTitle = \"\";\n String tSurname = \"\";\n String tResidentName = \"\";\n String tPrefix = \"\";\n String tNamePrefix = \"\";\n String tPostfix = \"\";\n String tNamePostfix = \"\";\n String tNation = \"\";\n String tNationName = \"\";\n String tNationTag = \"\";\n Double locX = (double) randomNumber(-100, 100);\n Double locY = (double) randomNumber(-100, 100);\n Double locZ = (double) randomNumber(-100, 100);\n String loc = (\"X: \" + locX + \", \" + \"Y: \" + locY + \", \" + \"Z: \" + locZ);\n String healthbar = \"\";\n String health = String.valueOf(randomNumber(1, 20));\n String pWorld = \"\";\n String hungerLevel = String.valueOf(randomNumber(0, 20));\n String hungerBar = API.createBasicBar(randomNumber(0, 20), 20, 10);\n String level = String.valueOf(randomNumber(1, 2));\n String exp = String.valueOf(randomNumber(0, 200))+ \"/\" + ((randomNumber(1, 2) + 1) * 10);\n String expBar = API.createBasicBar(randomNumber(0, 200), ((randomNumber(1, 2) + 1) * 10), 10);\n String tExp = String.valueOf(randomNumber(0, 300));\n String gMode = String.valueOf(randomNumber(0, 1));\n Date now = new Date();\n SimpleDateFormat dateFormat = new SimpleDateFormat(LocaleType.FORMAT_DATE.getRaw());\n String time = dateFormat.format(now);\n String dName = pName;\n String dType = \"\";\n if (MChat.isShouting.get(pName) != null\n && MChat.isShouting.get(pName)) {\n dType = LocaleType.FORMAT_SHOUT.getVal();\n } else if (ConfigType.MCHAT_CHAT_DISTANCE.getDouble() > 0) {\n dType = LocaleType.FORMAT_LOCAL.getVal();\n }\n String sType = \"\";\n if (MChat.isSpying.get(pName) != null\n && MChat.isSpying.get(pName))\n sType = LocaleType.FORMAT_SPY.getVal();\n if (Bukkit.getServer().getPlayer(pName) != null) {\n Player player = Bukkit.getServer().getPlayer(pName);\n locX = player.getLocation().getX();\n locY = player.getLocation().getY();\n locZ = player.getLocation().getZ();\n loc = (\"X: \" + locX + \", \" + \"Y: \" + locY + \", \" + \"Z: \" + locZ);\n healthbar = API.createHealthBar(player);\n health = String.valueOf(player.getHealth());\n pWorld = player.getWorld().getName();\n hungerLevel = String.valueOf(player.getFoodLevel());\n hungerBar = API.createBasicBar(player.getFoodLevel(), 20, 10);\n level = String.valueOf(player.getLevel());\n exp = String.valueOf(player.getExp()) + \"/\" + ((player.getLevel() + 1) * 10);\n expBar = API.createBasicBar(player.getExp(), ((player.getLevel() + 1) * 10), 10);\n tExp = String.valueOf(player.getTotalExperience());\n gMode = \"\";\n if (player.getGameMode() != null && player.getGameMode().name() != null)\n gMode = player.getGameMode().name();\n dName = player.getDisplayName();\n if (heroesB) {\n Hero hero = heroes.getCharacterManager().getHero(player);\n HeroClass heroClass = hero.getHeroClass();\n HeroClass heroSClass = hero.getSecondClass();\n int hL = hero.getLevel();\n int hSL = hero.getLevel(heroSClass);\n double hE = hero.getExperience(heroClass);\n double hSE = hero.getExperience(heroSClass);\n hClass = hero.getHeroClass().getName();\n hHealth = String.valueOf(hero.getHealth());\n hHBar = Messaging.createHealthBar(hero.getHealth(), hero.getMaxHealth());\n hMana = String.valueOf(hero.getMana());\n hLevel = String.valueOf(hL);\n hExp = String.valueOf(hE);\n hEBar = Messaging.createExperienceBar(hero, heroClass);\n Integer hMMana = hero.getMaxMana();\n if (hMMana != null)\n hMBar = Messaging.createManaBar(hero.getMana(), hero.getMaxMana());\n if (hero.getParty() != null)\n hParty = hero.getParty().toString();\n if (heroSClass != null) {\n hSClass = heroSClass.getName();\n hSLevel = String.valueOf(hSL);\n hSExp = String.valueOf(hSE);\n hSEBar = Messaging.createExperienceBar(hero, heroSClass);\n }\n if ((hero.isMaster(heroClass))\n && (heroSClass == null || hero.isMaster(heroSClass)))\n hMastered = LocaleType.MESSAGE_HEROES_TRUE.getVal();\n else\n hMastered = LocaleType.MESSAGE_HEROES_FALSE.getVal();\n }\n if (townyB) {\n try {\n Resident resident = TownyUniverse.getDataSource().getResident(pName);\n if (resident.hasTown()) {\n Town town = resident.getTown();\n tTown = town.getName();\n tTownName = TownyFormatter.getFormattedTownName(town);\n tTitle = resident.getTitle();\n tSurname = resident.getSurname();\n tResidentName = resident.getFormattedName();\n tPrefix = resident.hasTitle() ? resident.getTitle() : TownyFormatter.getNamePrefix(resident);\n tNamePrefix = TownyFormatter.getNamePrefix(resident);\n tPostfix = resident.hasSurname() ? resident.getSurname() : TownyFormatter.getNamePostfix(resident);\n tNamePostfix = TownyFormatter.getNamePostfix(resident);\n if (resident.hasNation()) {\n Nation nation = town.getNation();\n tNation = nation.getName();\n tNationName = nation.getFormattedName();\n tNationTag = nation.getTag();\n }\n }\n } catch (Exception ignored) {}\n }\n }\n String formatAll = parseVars(format, pName, world);\n msg = msg.replaceAll(\"%\", \"%%\");\n formatAll = formatAll.replaceAll(\"%\", \"%%\");\n formatAll = MessageUtil.addColour(formatAll);\n if (ConfigType.MCHAT_CAPS_LOCK_RANGE.getInteger() > 0)\n msg = fixCaps(msg, ConfigType.MCHAT_CAPS_LOCK_RANGE.getInteger());\n if (formatAll == null)\n return msg;\n if (API.checkPermissions(pName, world, \"mchat.coloredchat\"))\n msg = MessageUtil.addColour(msg);\n if (!API.checkPermissions(pName, world, \"mchat.censorbypass\"))\n msg = replaceCensoredWords(msg);\n TreeMap<String, Object> fVarMap = new TreeMap<String, Object>();\n TreeMap<String, Object> rVarMap = new TreeMap<String, Object>();\n TreeMap<String, Object> lVarMap = new TreeMap<String, Object>();\n addVar(fVarMap, vI + \"mnameformat,\" + vI + \"mnf\", LocaleType.FORMAT_NAME.getVal());\n addVar(fVarMap, vI + \"healthbar,\" + vI + \"hb\", healthbar);\n addVar(rVarMap, vI + \"distancetype,\" + vI + \"dtype\", dType);\n addVar(rVarMap, vI + \"displayname,\" + vI + \"dname,\" + vI + \"dn\", dName);\n addVar(rVarMap, vI + \"experiencebar,\" + vI + \"expb,\" + vI + \"ebar,\" + vI + \"eb\", expBar);\n addVar(rVarMap, vI + \"experience,\" + vI + \"exp\", exp);\n addVar(rVarMap, vI + \"gamemode,\" + vI + \"gm\", gMode);\n addVar(rVarMap, vI + \"group,\" + vI + \"g\", group);\n addVar(rVarMap, vI + \"hungerbar,\" + vI + \"hub\", hungerBar);\n addVar(rVarMap, vI + \"hunger\", hungerLevel);\n addVar(rVarMap, vI + \"health,\" + vI + \"h\", health);\n addVar(rVarMap, vI + \"location,\" + vI + \"loc\", loc);\n addVar(rVarMap, vI + \"level,\" + vI + \"l\", level);\n addVar(rVarMap, vI + \"mname,\" + vI + \"mn\", Reader.getMName(pName));\n addVar(rVarMap, vI + \"pname,\" + vI + \"n\", pName);\n addVar(rVarMap, vI + \"prefix,\" + vI + \"p\", prefix);\n addVar(rVarMap, vI + \"spying,\" + vI + \"spy\", sType);\n addVar(rVarMap, vI + \"suffix,\" + vI + \"s\", suffix);\n addVar(rVarMap, vI + \"totalexp,\" + vI + \"texp,\" + vI + \"te\", tExp);\n addVar(rVarMap, vI + \"time,\" + vI + \"t\", time);\n addVar(rVarMap, vI + \"world,\" + vI + \"w\", pWorld);\n addVar(rVarMap, vI + \"Groupname,\" + vI + \"Gname,\" + vI + \"G\", Reader.getGroupName(group.toString()));\n addVar(rVarMap, vI + \"HClass,\" + vI + \"HC\", hClass);\n addVar(rVarMap, vI + \"HExp,\" + vI + \"HEx\", hExp);\n addVar(rVarMap, vI + \"HEBar,\" + vI + \"HEb\", hEBar);\n addVar(rVarMap, vI + \"HHBar,\" + vI + \"HHB\", hHBar);\n addVar(rVarMap, vI + \"HHealth,\" + vI + \"HH\", hHealth);\n addVar(rVarMap, vI + \"HLevel,\" + vI + \"HL\", hLevel);\n addVar(rVarMap, vI + \"HMastered,\" + vI + \"HMa\", hMastered);\n addVar(rVarMap, vI + \"HMana,\" + vI + \"HMn\", hMana);\n addVar(rVarMap, vI + \"HMBar,\" + vI + \"HMb\", hMBar);\n addVar(rVarMap, vI + \"HParty,\" + vI + \"HPa\", hParty);\n addVar(rVarMap, vI + \"HSecClass,\" + vI + \"HSC\", hSClass);\n addVar(rVarMap, vI + \"HSecExp,\" + vI + \"HSEx\", hSExp);\n addVar(rVarMap, vI + \"HSecEBar,\" + vI + \"HSEb\", hSEBar);\n addVar(rVarMap, vI + \"HSecLevel,\" + vI + \"HSL\", hSLevel);\n addVar(rVarMap, vI + \"town\", tTown);\n addVar(rVarMap, vI + \"townname\", tTownName);\n addVar(rVarMap, vI + \"townysurname\", tSurname);\n addVar(rVarMap, vI + \"townytitle\", tTitle);\n addVar(rVarMap, vI + \"townyresidentname\", tResidentName);\n addVar(rVarMap, vI + \"townyprefix\", tPrefix);\n addVar(rVarMap, vI + \"townynameprefix\", tNamePrefix);\n addVar(rVarMap, vI + \"townypostfix\", tPostfix);\n addVar(rVarMap, vI + \"townynamepostfix\", tNamePostfix);\n addVar(rVarMap, vI + \"townynation\", tNation);\n addVar(rVarMap, vI + \"townynationname\", tNationName);\n addVar(rVarMap, vI + \"townynationtag\", tNationTag);\n addVar(rVarMap, vI + \"Worldname,\" + vI + \"Wname,\" + vI + \"W\", Reader.getWorldName(pWorld));\n addVar(lVarMap, vI + \"message,\" + vI + \"msg,\" + vI + \"m\", msg);\n formatAll = replaceCustVars(pName, formatAll);\n formatAll = replaceVars(formatAll, fVarMap.descendingMap(), true);\n formatAll = replaceVars(formatAll, rVarMap.descendingMap(), true);\n formatAll = replaceVars(formatAll, lVarMap.descendingMap(), false);\n return formatAll;\n }\n"} {"input": "\tpublic void testAttachToExistingReport() throws Exception {\n\t\tTaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null);\n\t\tassertNotNull(taskData);\n\t\tint numAttached = taskData.getAttributeMapper()\n\t\t\t\t.getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT)\n\t\t\t\t.size();\n\t\tassertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY));\n\t\tassertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY).getUserName());\n\t\tassertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());\n\t\tBugzillaClient client = connector.getClientManager().getClient(repository, new NullProgressMonitor());\n\t\tTaskAttribute attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);\n\t\tTaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);\n\t\tattachmentMapper.setDescription(\"Test attachment \" + new Date());\n\t\tattachmentMapper.setContentType(\"text/plain\");\n\t\tattachmentMapper.setPatch(false);\n\t\tattachmentMapper.setComment(\"Automated JUnit attachment test\");\n\t\tattachmentMapper.applyTo(attrAttachment);\n\t\tString filePath = \"/this/is/not/a/real-file\";\n\t\tFileTaskAttachmentSource attachment = new FileTaskAttachmentSource(new File(filePath));\n\t\tattachment.setContentType(FileTaskAttachmentSource.APPLICATION_OCTET_STREAM);\n\t\tattachment.setDescription(AttachmentUtil.CONTEXT_DESCRIPTION);\n\t\tattachment.setName(\"mylyn-context.zip\");\n\t\ttry {\n\t\t\tclient.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment,\n\t\t\t\t\tnew NullProgressMonitor());\n\t\t\tfail(\"never reach this!\");\n\t\t} catch (Exception e) {\n\t\t\tassertEquals(\"A repository error has occurred.\", e.getMessage());\n\t\t}\n\t\ttaskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);\n\t\tassertNotNull(taskData);\n\t\tassertEquals(numAttached, taskData.getAttributeMapper().getAttributesByType(taskData,\n\t\t\t\tTaskAttribute.TYPE_ATTACHMENT).size());\n\t\tString fileName = \"test-attach-\" + System.currentTimeMillis() + \".txt\";\n\t\tFile attachFile = new File(fileName);\n\t\tattachFile.createNewFile();\n\t\tBufferedWriter write = new BufferedWriter(new FileWriter(attachFile));\n\t\tattachment = new FileTaskAttachmentSource(attachFile);\n\t\tattachment.setContentType(FileTaskAttachmentSource.APPLICATION_OCTET_STREAM);\n\t\tattachment.setDescription(AttachmentUtil.CONTEXT_DESCRIPTION);\n\t\tattachment.setName(\"mylyn-context.zip\");\n\t\ttry {\n\t\t\tclient.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment,\n\t\t\t\t\tnew NullProgressMonitor());\n\t\t\tfail(\"never reach this!\");\n\t\t} catch (Exception e) {\n\t\t\tassertEquals(\"A repository error has occurred.\", e.getMessage());\n\t\t}\n\t\ttaskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);\n\t\tassertNotNull(taskData);\n\t\tassertEquals(numAttached, taskData.getAttributeMapper().getAttributesByType(taskData,\n\t\t\t\tTaskAttribute.TYPE_ATTACHMENT).size());\n\t\twrite.write(\"test file\");\n\t\twrite.close();\n\t\ttry {\n\t\t\tclient.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment,\n\t\t\t\t\tnew NullProgressMonitor());\n\t\t} catch (Exception e) {\n\t\t\tfail(\"never reach this!\");\n\t\t}\n\t\ttaskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);\n\t\tassertNotNull(taskData);\n\t\tassertEquals(numAttached + 1, taskData.getAttributeMapper().getAttributesByType(taskData,\n\t\t\t\tTaskAttribute.TYPE_ATTACHMENT).size());\n\t\tassertTrue(attachFile.delete());\n\t}\n", "output": "\tpublic void testAttachToExistingReport() throws Exception {\n\t\tTaskData taskData = BugzillaFixture.current().createTask(PrivilegeLevel.USER, null, null);\n\t\tassertNotNull(taskData);\n\t\tint numAttached = taskData.getAttributeMapper()\n\t\t\t\t.getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT)\n\t\t\t\t.size();\n\t\tassertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY));\n\t\tassertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY).getUserName());\n\t\tassertNotNull(repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());\n\t\tBugzillaClient client = connector.getClientManager().getClient(repository, new NullProgressMonitor());\n\t\tTaskAttribute attrAttachment = taskData.getAttributeMapper().createTaskAttachment(taskData);\n\t\tTaskAttachmentMapper attachmentMapper = TaskAttachmentMapper.createFrom(attrAttachment);\n\t\tattachmentMapper.setDescription(\"Test attachment \" + new Date());\n\t\tattachmentMapper.setContentType(\"text/plain\");\n\t\tattachmentMapper.setPatch(false);\n\t\tattachmentMapper.setComment(\"Automated JUnit attachment test\");\n\t\tattachmentMapper.applyTo(attrAttachment);\n\t\tString filePath = \"/this/is/not/a/real-file\";\n\t\tFileTaskAttachmentSource attachment = new FileTaskAttachmentSource(new File(filePath));\n\t\tattachment.setContentType(FileTaskAttachmentSource.APPLICATION_OCTET_STREAM);\n\t\tattachment.setDescription(AttachmentUtil.CONTEXT_DESCRIPTION);\n\t\tattachment.setName(\"mylyn-context.zip\");\n\t\ttry {\n\t\t\tclient.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment,\n\t\t\t\t\tnew NullProgressMonitor());\n\t\t\tfail(\"never reach this!\");\n\t\t} catch (Exception e) {\n\t\t\tassertEquals(\"An unknown repository error has occurred: \", e.getMessage());\n\t\t}\n\t\ttaskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);\n\t\tassertNotNull(taskData);\n\t\tassertEquals(numAttached, taskData.getAttributeMapper().getAttributesByType(taskData,\n\t\t\t\tTaskAttribute.TYPE_ATTACHMENT).size());\n\t\tString fileName = \"test-attach-\" + System.currentTimeMillis() + \".txt\";\n\t\tFile attachFile = new File(fileName);\n\t\tattachFile.createNewFile();\n\t\tBufferedWriter write = new BufferedWriter(new FileWriter(attachFile));\n\t\tattachment = new FileTaskAttachmentSource(attachFile);\n\t\tattachment.setContentType(FileTaskAttachmentSource.APPLICATION_OCTET_STREAM);\n\t\tattachment.setDescription(AttachmentUtil.CONTEXT_DESCRIPTION);\n\t\tattachment.setName(\"mylyn-context.zip\");\n\t\ttry {\n\t\t\tclient.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment,\n\t\t\t\t\tnew NullProgressMonitor());\n\t\t\tfail(\"never reach this!\");\n\t\t} catch (Exception e) {\n\t\t\tassertEquals(\"A repository error has occurred.\", e.getMessage());\n\t\t}\n\t\ttaskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);\n\t\tassertNotNull(taskData);\n\t\tassertEquals(numAttached, taskData.getAttributeMapper().getAttributesByType(taskData,\n\t\t\t\tTaskAttribute.TYPE_ATTACHMENT).size());\n\t\twrite.write(\"test file\");\n\t\twrite.close();\n\t\ttry {\n\t\t\tclient.postAttachment(taskData.getTaskId(), attachmentMapper.getComment(), attachment, attrAttachment,\n\t\t\t\t\tnew NullProgressMonitor());\n\t\t} catch (Exception e) {\n\t\t\tfail(\"never reach this!\");\n\t\t}\n\t\ttaskData = BugzillaFixture.current().getTask(taskData.getTaskId(), client);\n\t\tassertNotNull(taskData);\n\t\tassertEquals(numAttached + 1, taskData.getAttributeMapper().getAttributesByType(taskData,\n\t\t\t\tTaskAttribute.TYPE_ATTACHMENT).size());\n\t\tassertTrue(attachFile.delete());\n\t}\n"} {"input": " public Brand fetch(String uri) {\n LOG.info(\"Retrieving Hulu brand: \" + uri + \" with \" + httpClient.getClass() + \" : \" + httpClient.toString());\n String content = getContent(uri);\n if (content != null) {\n HtmlNavigator navigator = new HtmlNavigator(content);\n Brand brand = extractor.extract(navigator);\n List<Item> episodes = Lists.newArrayList();\n if (episodeAdapter != null) {\n for (Item item : brand.getItems()) {\n try {\n Episode episode = episodeAdapter.fetch(item.getCanonicalUri());\n episode.setBrand(brand);\n episodes.add(episode);\n } catch (FetchException fe) {\n LOG.warn(\"Failed to retrieve episode: \" + item.getCanonicalUri() + \" with message: \" + fe.getMessage() + \" with cause: \" + fe.getCause().getMessage());\n }\n }\n brand.setItems(episodes);\n }\n LOG.info(\"Retrieved Hulu brand: \" + uri + \" with \" + brand.getItems().size() + \" episodes\");\n return brand;\n } else {\n throw new FetchException(\"Unable to retrieve brand from Hulu: \" + uri + \" after a number of attempts\");\n }\n }\n", "output": " public Brand fetch(String uri) {\n LOG.info(\"Retrieving Hulu brand: \" + uri + \" with \" + httpClient.getClass() + \" : \" + httpClient.toString());\n String content = getContent(uri);\n if (content != null) {\n HtmlNavigator navigator = new HtmlNavigator(content);\n Brand brand = extractor.extract(navigator);\n List<Item> episodes = Lists.newArrayList();\n if (episodeAdapter != null) {\n for (Item item : brand.getItems()) {\n try {\n Episode episode = episodeAdapter.fetch(item.getCanonicalUri());\n episode.setBrand(brand);\n episodes.add(episode);\n } catch (FetchException fe) {\n LOG.warn(\"Failed to retrieve episode: \" + item.getCanonicalUri() + \" with message: \" + fe.getMessage());\n }\n }\n brand.setItems(episodes);\n }\n LOG.info(\"Retrieved Hulu brand: \" + uri + \" with \" + brand.getItems().size() + \" episodes\");\n return brand;\n } else {\n throw new FetchException(\"Unable to retrieve brand from Hulu: \" + uri + \" after a number of attempts\");\n }\n }\n"} {"input": " public final int getToken() throws IOException\n {\n int c;\n retry:\n for (;;) {\n for (;;) {\n c = getChar();\n if (c == EOF_CHAR) {\n tokenBeg = cursor - 1;\n tokenEnd = cursor;\n return Token.EOF;\n } else if (c == '\\n') {\n dirtyLine = false;\n tokenBeg = cursor - 1;\n tokenEnd = cursor;\n return Token.EOL;\n } else if (!isJSSpace(c)) {\n if (c != '-') {\n dirtyLine = true;\n }\n break;\n }\n }\n tokenBeg = cursor - 1;\n tokenEnd = cursor;\n boolean identifierStart;\n boolean isUnicodeEscapeStart = false;\n if (c == '\\\\') {\n c = getChar();\n if (c == 'u') {\n identifierStart = true;\n stringBufferTop = 0;\n } else {\n identifierStart = false;\n ungetChar(c);\n c = '\\\\';\n }\n } else {\n identifierStart = Character.isJavaIdentifierStart((char)c);\n if (identifierStart) {\n stringBufferTop = 0;\n addToString(c);\n }\n }\n if (identifierStart) {\n boolean containsEscape = isUnicodeEscapeStart;\n for (;;) {\n if (isUnicodeEscapeStart) {\n int escapeVal = 0;\n for (int i = 0; i != 4; ++i) {\n c = getChar();\n escapeVal = Kit.xDigitToInt(c, escapeVal);\n if (escapeVal < 0) { break; }\n }\n if (escapeVal < 0) {\n return Token.ERROR;\n }\n addToString(escapeVal);\n isUnicodeEscapeStart = false;\n } else {\n c = getChar();\n if (c == '\\\\') {\n c = getChar();\n if (c == 'u') {\n isUnicodeEscapeStart = true;\n containsEscape = true;\n } else {\n return Token.ERROR;\n }\n } else {\n if (c == EOF_CHAR || c == BYTE_ORDER_MARK\n || !Character.isJavaIdentifierPart((char)c))\n {\n break;\n }\n addToString(c);\n }\n }\n }\n ungetChar(c);\n String str = getStringFromBuffer();\n this.string = (String)allStrings.intern(str);\n return Token.NAME;\n }\n if (isDigit(c) || (c == '.' && isDigit(peekChar()))) {\n isOctal = false;\n stringBufferTop = 0;\n int base = 10;\n while ('0' <= c && c <= '9') {\n addToString(c);\n c = getChar();\n }\n boolean isInteger = true;\n ungetChar(c);\n String numString = getStringFromBuffer();\n this.string = numString;\n double dval;\n if (!isInteger) {\n try {\n dval = Double.valueOf(numString).doubleValue();\n }\n catch (NumberFormatException ex) {\n return Token.ERROR;\n }\n } else {\n dval = stringToNumber(numString, 0, base);\n }\n this.number = dval;\n return Token.NUMBER;\n }\n switch (c) {\n case ';': return Token.SEMI;\n case '[': return Token.LB;\n case ']': return Token.RB;\n case '{': return Token.LC;\n case '}': return Token.RC;\n case '(': return Token.LP;\n case ')': return Token.RP;\n case ',': return Token.COMMA;\n case '?': return Token.HOOK;\n case ':':\n if (matchChar(':')) {\n return Token.COLONCOLON;\n } else {\n return Token.COLON;\n }\n case '.':\n if (matchChar('.')) {\n return Token.DOTDOT;\n } else if (matchChar('(')) {\n return Token.DOTQUERY;\n } else {\n return Token.DOT;\n }\n case '|':\n if (matchChar('|')) {\n return Token.OR;\n } else if (matchChar('=')) {\n return Token.ASSIGN_BITOR;\n } else {\n return Token.BITOR;\n }\n case '^':\n if (matchChar('=')) {\n return Token.ASSIGN_BITXOR;\n } else {\n return Token.BITXOR;\n }\n case '&':\n if (matchChar('&')) {\n return Token.AND;\n } else if (matchChar('=')) {\n return Token.ASSIGN_BITAND;\n } else {\n return Token.BITAND;\n }\n case '=':\n if (matchChar('=')) {\n if (matchChar('=')) {\n return Token.SHEQ;\n } else {\n return Token.EQ;\n }\n } else {\n return Token.ASSIGN;\n }\n case '!':\n if (matchChar('=')) {\n if (matchChar('=')) {\n return Token.SHNE;\n } else {\n return Token.NE;\n }\n } else {\n return Token.NOT;\n }\n case '<':\n if (matchChar('<')) {\n if (matchChar('=')) {\n return Token.ASSIGN_LSH;\n } else {\n return Token.LSH;\n }\n } else {\n if (matchChar('=')) {\n return Token.LE;\n } else {\n return Token.LT;\n }\n }\n case '>':\n if (matchChar('>')) {\n if (matchChar('>')) {\n if (matchChar('=')) {\n return Token.ASSIGN_URSH;\n } else {\n return Token.URSH;\n }\n } else {\n if (matchChar('=')) {\n return Token.ASSIGN_RSH;\n } else {\n return Token.RSH;\n }\n }\n } else {\n if (matchChar('=')) {\n return Token.GE;\n } else {\n return Token.GT;\n }\n }\n case '*':\n if (matchChar('=')) {\n return Token.ASSIGN_MUL;\n } else {\n return Token.MUL;\n }\n case '/':\n if (matchChar('=')) {\n return Token.ASSIGN_DIV;\n } else {\n return Token.DIV;\n }\n case '%':\n if (matchChar('=')) {\n return Token.ASSIGN_MOD;\n } else {\n return Token.MOD;\n }\n case '~':\n return Token.BITNOT;\n case '+':\n if (matchChar('=')) {\n return Token.ASSIGN_ADD;\n } else if (matchChar('+')) {\n return Token.INC;\n } else {\n return Token.ADD;\n }\n case '-':\n if (matchChar('=')) {\n c = Token.ASSIGN_SUB;\n } else if (matchChar('-')) {\n c = Token.DEC;\n } else {\n c = Token.SUB;\n }\n return c;\n default:\n System.out.println(\"Illegal character\");\n return Token.ERROR;\n }\n }\n }\n", "output": " public final int getToken() throws IOException\n {\n int c;\n retry:\n for (;;) {\n for (;;) {\n c = getChar();\n if (c == EOF_CHAR) {\n tokenBeg = cursor - 1;\n tokenEnd = cursor;\n return Token.EOF;\n } else if (c == '\\n') {\n dirtyLine = false;\n tokenBeg = cursor - 1;\n tokenEnd = cursor;\n return Token.EOL;\n } else if (!isJSSpace(c)) {\n if (c != '-') {\n dirtyLine = true;\n }\n break;\n }\n }\n tokenBeg = cursor - 1;\n tokenEnd = cursor;\n boolean identifierStart;\n boolean isUnicodeEscapeStart = false;\n boolean isUnicode = false;\n if (c == '\\\\') {\n c = getChar();\n if (c == 'u') {\n identifierStart = true;\n stringBufferTop = 0;\n isUnicode = true;\n } else {\n identifierStart = false;\n ungetChar(c);\n c = '\\\\';\n }\n } else {\n identifierStart = Character.isJavaIdentifierStart((char)c);\n if (identifierStart) {\n stringBufferTop = 0;\n addToString(c);\n }\n }\n if (identifierStart) {\n boolean containsEscape = isUnicodeEscapeStart;\n for (;;) {\n if (isUnicodeEscapeStart) {\n int escapeVal = 0;\n for (int i = 0; i != 4; ++i) {\n c = getChar();\n escapeVal = Kit.xDigitToInt(c, escapeVal);\n if (escapeVal < 0) { break; }\n }\n if (escapeVal < 0) {\n return Token.ERROR;\n }\n addToString(escapeVal);\n isUnicodeEscapeStart = false;\n } else {\n c = getChar();\n if (c == '\\\\') {\n c = getChar();\n if (c == 'u') {\n isUnicodeEscapeStart = true;\n containsEscape = true;\n } else {\n return Token.ERROR;\n }\n } else {\n if (c == EOF_CHAR || c == BYTE_ORDER_MARK\n || !Character.isJavaIdentifierPart((char)c))\n {\n break;\n }\n addToString(c);\n }\n }\n }\n ungetChar(c);\n String str = getStringFromBuffer();\n if (isUnicode) {\n str = \"\\\\u\"+str;\n char ch = (char) Integer.parseInt( str.substring(2), 16 );\n str = String.valueOf(ch);\n }\n this.string = (String)allStrings.intern(str);\n return Token.NAME;\n }\n if (isDigit(c) || (c == '.' && isDigit(peekChar()))) {\n isOctal = false;\n stringBufferTop = 0;\n int base = 10;\n while ('0' <= c && c <= '9') {\n addToString(c);\n c = getChar();\n }\n boolean isInteger = true;\n ungetChar(c);\n String numString = getStringFromBuffer();\n this.string = numString;\n double dval;\n if (!isInteger) {\n try {\n dval = Double.valueOf(numString).doubleValue();\n }\n catch (NumberFormatException ex) {\n return Token.ERROR;\n }\n } else {\n dval = stringToNumber(numString, 0, base);\n }\n this.number = dval;\n return Token.NUMBER;\n }\n switch (c) {\n case ';': return Token.SEMI;\n case '[': return Token.LB;\n case ']': return Token.RB;\n case '{': return Token.LC;\n case '}': return Token.RC;\n case '(': return Token.LP;\n case ')': return Token.RP;\n case ',': return Token.COMMA;\n case '?': return Token.HOOK;\n case ':':\n if (matchChar(':')) {\n return Token.COLONCOLON;\n } else {\n return Token.COLON;\n }\n case '.':\n if (matchChar('.')) {\n return Token.DOTDOT;\n } else if (matchChar('(')) {\n return Token.DOTQUERY;\n } else {\n return Token.DOT;\n }\n case '|':\n if (matchChar('|')) {\n return Token.OR;\n } else if (matchChar('=')) {\n return Token.ASSIGN_BITOR;\n } else {\n return Token.BITOR;\n }\n case '^':\n if (matchChar('=')) {\n return Token.ASSIGN_BITXOR;\n } else {\n return Token.BITXOR;\n }\n case '&':\n if (matchChar('&')) {\n return Token.AND;\n } else if (matchChar('=')) {\n return Token.ASSIGN_BITAND;\n } else {\n return Token.BITAND;\n }\n case '=':\n if (matchChar('=')) {\n if (matchChar('=')) {\n return Token.SHEQ;\n } else {\n return Token.EQ;\n }\n } else {\n return Token.ASSIGN;\n }\n case '!':\n if (matchChar('=')) {\n if (matchChar('=')) {\n return Token.SHNE;\n } else {\n return Token.NE;\n }\n } else {\n return Token.NOT;\n }\n case '<':\n if (matchChar('<')) {\n if (matchChar('=')) {\n return Token.ASSIGN_LSH;\n } else {\n return Token.LSH;\n }\n } else {\n if (matchChar('=')) {\n return Token.LE;\n } else {\n return Token.LT;\n }\n }\n case '>':\n if (matchChar('>')) {\n if (matchChar('>')) {\n if (matchChar('=')) {\n return Token.ASSIGN_URSH;\n } else {\n return Token.URSH;\n }\n } else {\n if (matchChar('=')) {\n return Token.ASSIGN_RSH;\n } else {\n return Token.RSH;\n }\n }\n } else {\n if (matchChar('=')) {\n return Token.GE;\n } else {\n return Token.GT;\n }\n }\n case '*':\n if (matchChar('=')) {\n return Token.ASSIGN_MUL;\n } else {\n return Token.MUL;\n }\n case '/':\n if (matchChar('=')) {\n return Token.ASSIGN_DIV;\n } else {\n return Token.DIV;\n }\n case '%':\n if (matchChar('=')) {\n return Token.ASSIGN_MOD;\n } else {\n return Token.MOD;\n }\n case '~':\n return Token.BITNOT;\n case '+':\n if (matchChar('=')) {\n return Token.ASSIGN_ADD;\n } else if (matchChar('+')) {\n return Token.INC;\n } else {\n return Token.ADD;\n }\n case '-':\n if (matchChar('=')) {\n c = Token.ASSIGN_SUB;\n } else if (matchChar('-')) {\n c = Token.DEC;\n } else {\n c = Token.SUB;\n }\n return c;\n default:\n System.out.println(\"Illegal character\");\n return Token.ERROR;\n }\n }\n }\n"} {"input": " public void initialize() {\n if (entityManagerFactory != null) {\n return;\n }\n if (persistenceOptions != null) {\n if (!persistenceOptions.containsKey(ECLIPSELINK_CLASSLOADER_OPTION)) {\n persistenceOptions.put(ECLIPSELINK_CLASSLOADER_OPTION, EntityManagerProvider.class.getClassLoader());\n }\n persistenceOptions.put(MULTITENANT_PROPERTY_DEFAULT, \"texo\");\n entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName, persistenceOptions);\n } else {\n entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName);\n }\n }\n", "output": " public void initialize() {\n if (entityManagerFactory != null) {\n return;\n }\n if (persistenceOptions != null) {\n if (!persistenceOptions.containsKey(ECLIPSELINK_CLASSLOADER_OPTION)) {\n persistenceOptions.put(ECLIPSELINK_CLASSLOADER_OPTION, EntityManagerProvider.class.getClassLoader());\n }\n persistenceOptions.put(MULTITENANT_PROPERTY_DEFAULT, \"texo\"); \n entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName, persistenceOptions);\n } else {\n entityManagerFactory = Persistence.createEntityManagerFactory(persistenceUnitName);\n }\n }\n"} {"input": " public Datenmodell()\n {\n g1=new Gleisstueck(\"Gleisstueck 1\", 640);\n g2=new Gleisstueck(\"Gleisstueck 2\", 320);\n g3=new Gleisstueck(\"Gleisstueck 3\", 590);\n g4=new Gleisstueck(\"Gleisstueck 4\", 190);\n g5=new Gleisstueck(\"Gleisstueck 5\", 210);\n g6=new Gleisstueck(\"Gleisstueck 6\", 260);\n g7=new Gleisstueck(\"Gleisstueck 7\", 730);\n g8=new Gleisstueck(\"Gleisstueck 8\", 200);\n g9=new Gleisstueck(\"Gleisstueck 9\", 190);\n g10=new Gleisstueck(\"Gleisstueck 10\", 570);\n g11=new Gleisstueck(\"Gleisstueck 11\", 700);\n g12=new Gleisstueck(\"Gleisstueck 12\", 220);\n g13=new Gleisstueck(\"Gleisstueck 13\", 260);\n g14=new Gleisstueck(\"Gleisstueck 14\", 60);\n g15=new Gleisstueck(\"Gleisstueck 15\", 690);\n g16=new Gleisstueck(\"Gleisstueck 16\", 330);\n g17=new Gleisstueck(\"Gleisstueck 17\", 250);\n g18=new Gleisstueck(\"Gleisstueck 18\", 80);\n g19=new Gleisstueck(\"Gleisstueck 19\", 690);\n g20=new Gleisstueck(\"Gleisstueck 20\", 60);\n g21=new Gleisstueck(\"Gleisstueck 21\", 51);\n g22=new Gleisstueck(\"Gleisstueck 22\", 50);\n g23=new Gleisstueck(\"Gleisstueck 23\", 690);\n g24=new Gleisstueck(\"Gleisstueck 24\", 120);\n g25=new Gleisstueck(\"Gleisstueck 25\", 1220);\n g26=new Gleisstueck(\"Gleisstueck 26\", 60);\n g27=new Gleisstueck(\"Gleisstueck 27\", 50);\n g28=new Gleisstueck(\"Gleisstueck 28\", 50);\n g29=new Gleisstueck(\"Gleisstueck 29\", 60);\n w1=new Weiche(\"Weiche 1\",g5,g9,g27);\n w2=new Weiche(\"Weiche 2\",g10,g27,g9);\n w3=new Weiche(\"Weiche 3\",g6,g1,g27);\n w5=new Weiche(\"Weiche 5\",g28,g1,g2);\n w6=new Weiche(\"Weiche 6\",g3,g4,g28);\n w7=new Weiche(\"Weiche 7\",g7,g11,g6);\n w8=new Weiche(\"Weiche 8\",g10,g6,g11);\n w10=new Weiche(\"Weiche 10\",g11,g25,g26);\n w11=new Weiche(\"Weiche 11\",g7,g26,g8);\n w12=new Weiche(\"Weiche 12\",g8,g12,g26);\n w13=new Weiche(\"Weiche 13\",g13,g17,g14);\n w14=new Weiche(\"Weiche 14\",g18,g14,g17);\n w15=new Weiche(\"Weiche 15\",g15,g19,g14);\n w16=new Weiche(\"Weiche 16\",g18,g14,g29);\n w40=new Weiche(\"Weiche 40\",g16,g20,g15);\n w39=new Weiche(\"Weiche 39\",g15,g19,g20);\n w44=new Weiche(\"Weiche 44\",g22,g16,g3);\n w43=new Weiche(\"Weiche 43\",g4,g3,g22);\n w38=new Weiche(\"Weiche 38\",g21,g24,g20);\n w37=new Weiche(\"Weiche 37\",g23,g20,g24);\n w42=new Weiche(\"Weiche 42\",g21,g24,g22);\n w41=new Weiche(\"Weiche 41\",g25,g22,g24);\n w17=new Weiche(\"Weiche 17\",g19,g23,g29);\n g1.setWeichen(w3, w5);\n g2.setWeichen(w5, null);\n g3.setWeichen(w44, w6);\n g4.setWeichen(w43, w6);\n g5.setWeichen(null, w1);\n g6.setWeichen(w3, w7);\n g7.setWeichen(w7, w11);\n g8.setWeichen(w11, null);\n g9.setWeichen(null, w2);\n g10.setWeichen(w2, w8);\n g11.setWeichen(w8, w10);\n g12.setWeichen(w12, null);\n g13.setWeichen(null, w13);\n g14.setWeichen(w13, w15);\n g15.setWeichen(w15, w40);\n g16.setWeichen(w40, w44);\n g17.setWeichen(null, w14);\n g18.setWeichen(w14, w16);\n g19.setWeichen(w17, w39);\n g20.setWeichen(w39, w38);\n g21.setWeichen(w38, w42);\n g22.setWeichen(w42, w43);\n g23.setWeichen(w17, w37);\n g24.setWeichen(w37, w41);\n g25.setWeichen(w41, w10);\n g26.setWeichen(w10, w12);\n g27.setWeichen(w1, w3);\n g28.setWeichen(w6, w5);\n g29.setWeichen(w16, w17);\n s1=new Signal(\"Signal 1\", g6, false);\n s2=new Signal(\"Signal 2\", g7, false);\n s3=new Signal(\"Signal 3\", g8, false);\n s4=new Signal(\"Signal 4\", g9, true);\n s5=new Signal(\"Signal 5\", g10, false);\n s6=new Signal(\"Signal 6\", g6, true);\n s7=new Signal(\"Signal 7\", g11, false);\n s8=new Signal(\"Signal 8\", g12, false);\n s9=new Signal(\"Signal 9\", g10, true);\n s10=new Signal(\"Signal 10\", g11, true);\n s11=new Signal(\"Signal 11\", g1, false);\n s12=new Signal(\"Signal 12\", g1, true);\n s13=new Signal(\"Signal 13\", g3, true);\n s14=new Signal(\"Signal 14\", g4, true);\n s15=new Signal(\"Signal 15\", g2, false);\n s16=new Signal(\"Signal 16\", g13, true);\n s17=new Signal(\"Signal 17\", g15, false);\n s18=new Signal(\"Signal 18\", g15, true);\n s20=new Signal(\"Signal 20\", g17, true);\n s21=new Signal(\"Signal 21\", g19, false);\n s22=new Signal(\"Signal 22\", g19, true);\n s25=new Signal(\"Signal 25\", g23, false);\n s26=new Signal(\"Signal 26\", g25, false);\n s30=new Signal(\"Signal 30\", g23, true);\n s31=new Signal(\"Signal 31\", g25, true);\n g1.setSignal(s11);\n g1.setSignal(s12);\n g2.setSignal(s15);\n g3.setSignal(s13);\n g4.setSignal(s14);\n g5.setSignal(null);\n g6.setSignal(s1);\n g6.setSignal(s6);\n g7.setSignal(s2);\n g8.setSignal(s3);\n g9.setSignal(s4);\n g10.setSignal(s5);\n g10.setSignal(s9);\n g11.setSignal(s7);\n g11.setSignal(s10);\n g12.setSignal(s8);\n g13.setSignal(s16);\n g14.setSignal(null);\n g15.setSignal(s17);\n g15.setSignal(s18);\n g16.setSignal(null);\n g17.setSignal(s20);\n g18.setSignal(null);\n g19.setSignal(s21);\n g19.setSignal(s22);\n g20.setSignal(null);\n g21.setSignal(null);\n g22.setSignal(null);\n g23.setSignal(s25);\n g23.setSignal(s30);\n g24.setSignal(null);\n g25.setSignal(s31);\n g25.setSignal(s26);\n g26.setSignal(null);\n g27.setSignal(null);\n g28.setSignal(null);\n g29.setSignal(null);\n s= new Signal[25];\n s[0]=s1;\n s[1]=s2;\n s[2]=s3;\n s[3]=s4;\n s[4]=s5;\n s[5]=s6;\n s[6]=s7;\n s[7]=s8;\n s[8]=s9;\n s[9]=s10;\n s[10]=s11;\n s[11]=s12;\n s[12]=s13;\n s[13]=s14;\n s[14]=s15;\n s[15]=s16;\n s[16]=s17;\n s[17]=s18;\n s[18]=s20;\n s[19]=s21;\n s[20]=s22;\n s[21]=s25;\n s[22]=s26;\n s[23]=s30;\n s[24]=s31;\n w= new Weiche[23];\n w[0]=w1;\n w[1]=w2;\n w[2]=w3;\n w[3]=w5;\n w[4]=w6;\n w[5]=w7;\n w[6]=w8; \n w[7]=w10;\n w[8]=w11;\n w[9]=w12;\n w[10]=w13;\n w[11]=w14;\n w[12]=w15;\n w[13]=w16;\n w[14]=w17;\n w[15]=w37;\n w[16]=w38;\n w[17]=w39;\n w[18]=w40;\n w[19]=w41;\n w[20]=w42;\n w[21]=w43;\n w[22]=w44;\n g= new Gleisstueck[30];\n g[1]=g1;\n g[2]=g2;\n g[3]=g3;\n g[4]=g4;\n g[5]=g5;\n g[6]=g6;\n g[7]=g7;\n g[8]=g8;\n g[9]=g9;\n g[10]=g10;\n g[11]=g11;\n g[12]=g12;\n g[13]=g13;\n g[14]=g14;\n g[15]=g15;\n g[16]=g16;\n g[17]=g17;\n g[18]=g18;\n g[19]=g19;\n g[20]=g20;\n g[21]=g21;\n g[22]=g22;\n g[23]=g23;\n g[24]=g24;\n g[25]=g25;\n g[26]=g26;\n g[27]=g27;\n g[28]=g28;\n g[29]=g29;\n }\n", "output": " public Datenmodell()\n {\n g1=new Gleisstueck(\"Gleisstueck 1\", 640);\n g2=new Gleisstueck(\"Gleisstueck 2\", 320);\n g3=new Gleisstueck(\"Gleisstueck 3\", 590);\n g4=new Gleisstueck(\"Gleisstueck 4\", 190);\n g5=new Gleisstueck(\"Gleisstueck 5\", 210);\n g6=new Gleisstueck(\"Gleisstueck 6\", 260);\n g7=new Gleisstueck(\"Gleisstueck 7\", 730);\n g8=new Gleisstueck(\"Gleisstueck 8\", 200);\n g9=new Gleisstueck(\"Gleisstueck 9\", 190);\n g10=new Gleisstueck(\"Gleisstueck 10\", 570);\n g11=new Gleisstueck(\"Gleisstueck 11\", 700);\n g12=new Gleisstueck(\"Gleisstueck 12\", 220);\n g13=new Gleisstueck(\"Gleisstueck 13\", 260);\n g14=new Gleisstueck(\"Gleisstueck 14\", 60);\n g15=new Gleisstueck(\"Gleisstueck 15\", 690);\n g16=new Gleisstueck(\"Gleisstueck 16\", 330);\n g17=new Gleisstueck(\"Gleisstueck 17\", 250);\n g18=new Gleisstueck(\"Gleisstueck 18\", 80);\n g19=new Gleisstueck(\"Gleisstueck 19\", 690);\n g20=new Gleisstueck(\"Gleisstueck 20\", 60);\n g21=new Gleisstueck(\"Gleisstueck 21\", 51);\n g22=new Gleisstueck(\"Gleisstueck 22\", 50);\n g23=new Gleisstueck(\"Gleisstueck 23\", 690);\n g24=new Gleisstueck(\"Gleisstueck 24\", 120);\n g25=new Gleisstueck(\"Gleisstueck 25\", 1220);\n g26=new Gleisstueck(\"Gleisstueck 26\", 60);\n g27=new Gleisstueck(\"Gleisstueck 27\", 50);\n g28=new Gleisstueck(\"Gleisstueck 28\", 50);\n g29=new Gleisstueck(\"Gleisstueck 29\", 60);\n w1=new Weiche(\"Weiche 1\",g5,g9,g27);\n w2=new Weiche(\"Weiche 2\",g10,g27,g9);\n w3=new Weiche(\"Weiche 3\",g6,g1,g27);\n w5=new Weiche(\"Weiche 5\",g28,g1,g2);\n w6=new Weiche(\"Weiche 6\",g3,g4,g28);\n w7=new Weiche(\"Weiche 7\",g7,g11,g6);\n w8=new Weiche(\"Weiche 8\",g10,g6,g11);\n w10=new Weiche(\"Weiche 10\",g11,g25,g26);\n w11=new Weiche(\"Weiche 11\",g7,g26,g8);\n w12=new Weiche(\"Weiche 12\",g8,g12,g26);\n w13=new Weiche(\"Weiche 13\",g13,g17,g14);\n w14=new Weiche(\"Weiche 14\",g18,g14,g17);\n w15=new Weiche(\"Weiche 15\",g15,g19,g14);\n w16=new Weiche(\"Weiche 16\",g18,g14,g29);\n w40=new Weiche(\"Weiche 40\",g16,g20,g15);\n w39=new Weiche(\"Weiche 39\",g15,g19,g20);\n w44=new Weiche(\"Weiche 44\",g22,g16,g3);\n w43=new Weiche(\"Weiche 43\",g4,g3,g22);\n w38=new Weiche(\"Weiche 38\",g21,g24,g20);\n w37=new Weiche(\"Weiche 37\",g23,g20,g24);\n w42=new Weiche(\"Weiche 42\",g21,g24,g22);\n w41=new Weiche(\"Weiche 41\",g25,g22,g24);\n w17=new Weiche(\"Weiche 17\",g19,g23,g29);\n g1.setWeichen(w3, w5);\n g2.setWeichen(w5, null);\n g3.setWeichen(w44, w6);\n g4.setWeichen(w43, w6);\n g5.setWeichen(null, w1);\n g6.setWeichen(w3, w7);\n g7.setWeichen(w7, w11);\n g8.setWeichen(w11, null);\n g9.setWeichen(null, w2);\n g10.setWeichen(w2, w8);\n g11.setWeichen(w8, w10);\n g12.setWeichen(w12, null);\n g13.setWeichen(null, w13);\n g14.setWeichen(w13, w15);\n g15.setWeichen(w15, w40);\n g16.setWeichen(w40, w44);\n g17.setWeichen(null, w14);\n g18.setWeichen(w14, w16);\n g19.setWeichen(w17, w39);\n g20.setWeichen(w39, w38);\n g21.setWeichen(w38, w42);\n g22.setWeichen(w42, w43);\n g23.setWeichen(w17, w37);\n g24.setWeichen(w37, w41);\n g25.setWeichen(w41, w10);\n g26.setWeichen(w10, w12);\n g27.setWeichen(w1, w3);\n g28.setWeichen(w6, w5);\n g29.setWeichen(w16, w17);\n s1=new Signal(\"Signal 1\", g6, false);\n s2=new Signal(\"Signal 2\", g7, false);\n s3=new Signal(\"Signal 3\", g8, false);\n s4=new Signal(\"Signal 4\", g9, true);\n s5=new Signal(\"Signal 5\", g10, false);\n s6=new Signal(\"Signal 6\", g6, true);\n s7=new Signal(\"Signal 7\", g11, false);\n s8=new Signal(\"Signal 8\", g12, false);\n s9=new Signal(\"Signal 9\", g10, true);\n s10=new Signal(\"Signal 10\", g11, true);\n s11=new Signal(\"Signal 11\", g1, false);\n s12=new Signal(\"Signal 12\", g1, true);\n s13=new Signal(\"Signal 13\", g3, true);\n s14=new Signal(\"Signal 14\", g4, true);\n s15=new Signal(\"Signal 15\", g2, false);\n s16=new Signal(\"Signal 16\", g13, true);\n s17=new Signal(\"Signal 17\", g15, false);\n s18=new Signal(\"Signal 18\", g15, true);\n s20=new Signal(\"Signal 20\", g17, true);\n s21=new Signal(\"Signal 21\", g19, false);\n s22=new Signal(\"Signal 22\", g19, true);\n s25=new Signal(\"Signal 25\", g23, false);\n s26=new Signal(\"Signal 26\", g25, false);\n s30=new Signal(\"Signal 30\", g23, true);\n s31=new Signal(\"Signal 31\", g25, true);\n g1.setSignal(s11);\n g1.setSignal(s12);\n g2.setSignal(s15);\n g3.setSignal(s13);\n g4.setSignal(s14);\n g6.setSignal(s1);\n g6.setSignal(s6);\n g7.setSignal(s2);\n g8.setSignal(s3);\n g9.setSignal(s4);\n g10.setSignal(s5);\n g10.setSignal(s9);\n g11.setSignal(s7);\n g11.setSignal(s10);\n g12.setSignal(s8);\n g13.setSignal(s16);\n g15.setSignal(s17);\n g15.setSignal(s18);\n g17.setSignal(s20);\n g19.setSignal(s21);\n g19.setSignal(s22);\n g23.setSignal(s25);\n g23.setSignal(s30);\n g25.setSignal(s31);\n g25.setSignal(s26);\n s= new Signal[25];\n s[0]=s1;\n s[1]=s2;\n s[2]=s3;\n s[3]=s4;\n s[4]=s5;\n s[5]=s6;\n s[6]=s7;\n s[7]=s8;\n s[8]=s9;\n s[9]=s10;\n s[10]=s11;\n s[11]=s12;\n s[12]=s13;\n s[13]=s14;\n s[14]=s15;\n s[15]=s16;\n s[16]=s17;\n s[17]=s18;\n s[18]=s20;\n s[19]=s21;\n s[20]=s22;\n s[21]=s25;\n s[22]=s26;\n s[23]=s30;\n s[24]=s31;\n w= new Weiche[23];\n w[0]=w1;\n w[1]=w2;\n w[2]=w3;\n w[3]=w5;\n w[4]=w6;\n w[5]=w7;\n w[6]=w8; \n w[7]=w10;\n w[8]=w11;\n w[9]=w12;\n w[10]=w13;\n w[11]=w14;\n w[12]=w15;\n w[13]=w16;\n w[14]=w17;\n w[15]=w37;\n w[16]=w38;\n w[17]=w39;\n w[18]=w40;\n w[19]=w41;\n w[20]=w42;\n w[21]=w43;\n w[22]=w44;\n g= new Gleisstueck[30];\n g[1]=g1;\n g[2]=g2;\n g[3]=g3;\n g[4]=g4;\n g[5]=g5;\n g[6]=g6;\n g[7]=g7;\n g[8]=g8;\n g[9]=g9;\n g[10]=g10;\n g[11]=g11;\n g[12]=g12;\n g[13]=g13;\n g[14]=g14;\n g[15]=g15;\n g[16]=g16;\n g[17]=g17;\n g[18]=g18;\n g[19]=g19;\n g[20]=g20;\n g[21]=g21;\n g[22]=g22;\n g[23]=g23;\n g[24]=g24;\n g[25]=g25;\n g[26]=g26;\n g[27]=g27;\n g[28]=g28;\n g[29]=g29;\n }\n"} {"input": "\tpublic void click_btn_finish(View view)\n\t{\n\t\tprintErr(false, \"\"); \n\t\tdouble solution = 0;\n\t\tboolean error_occurred = false;\n\t\tString leftOpStr = lOperand.getText().toString();\n\t\tString rightOpStr = rOperand.getText().toString();\n\t\tchar operator = ((String) txt_signPlaceholder.getText()).charAt(0);\n\t\tdouble leftOperand = 0, rightOperand = 0;\n\t\ttry\n\t\t{\n\t\t\tleftOperand = Double.parseDouble(leftOpStr);\n\t\t} catch (NumberFormatException e)\n\t\t{\n\t\t\terror_occurred = true;\n\t\t\tprintErr(true, \"Enter a valid number as the left operand.\\n\");\n\t\t}\n\t\ttry\n\t\t{\n\t\t\trightOperand = Double.parseDouble(rightOpStr);\n\t\t} catch (NumberFormatException e)\n\t\t{\n\t\t\terror_occurred = true;\n\t\t\tprintErr(true, \"Enter a valid number as the right operand.\\n\");\n\t\t}\n\t\tif (!error_occurred)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tsolution = Calculator.calculate(leftOperand, operator,\n\t\t\t\t\t\trightOperand);\n\t\t\t} catch (ArithmeticException a)\n\t\t\t{\n\t\t\t\tprintErr(true,\n\t\t\t\t\t\t\"Cannot Divide by Zero! Some men just want to watch the world burn!\\n\");\n\t\t\t} catch (IllegalArgumentException i)\n\t\t\t{\n\t\t\t\tprintErr(true, \"Please select an operator.\\n\");\n\t\t\t}\n\t\t}\n\t\tif (!error_occurred)\n\t\t\toutputBox.setText(\"Answer: \" + solution);\n\t\telse\n\t\t\toutputBox.setText(\"Answer: \");\n\t}\n", "output": "\tpublic void click_btn_finish(View view)\n\t{\n\t\tprintErr(false, \"\"); \n\t\tdouble solution = 0;\n\t\tboolean error_occurred = false;\n\t\tString leftOpStr = lOperand.getText().toString();\n\t\tString rightOpStr = rOperand.getText().toString();\n\t\tchar operator = ((String) txt_signPlaceholder.getText()).charAt(0);\n\t\tdouble leftOperand = 0, rightOperand = 0;\n\t\ttry\n\t\t{\n\t\t\tleftOperand = Double.parseDouble(leftOpStr);\n\t\t} catch (NumberFormatException e)\n\t\t{\n\t\t\terror_occurred = true;\n\t\t\tprintErr(true, \"Enter a valid number as the left operand.\\n\");\n\t\t}\n\t\ttry\n\t\t{\n\t\t\trightOperand = Double.parseDouble(rightOpStr);\n\t\t} catch (NumberFormatException e)\n\t\t{\n\t\t\terror_occurred = true;\n\t\t\tprintErr(true, \"Enter a valid number as the right operand.\\n\");\n\t\t}\n\t\tif (!error_occurred)\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tsolution = Calculator.calculate(leftOperand, operator,\n\t\t\t\t\t\trightOperand);\n\t\t\t} catch (ArithmeticException a)\n\t\t\t{\n\t\t\t\tprintErr(true,\n\t\t\t\t\t\t\"Cannot Divide by Zero! Some men just want to watch the world burn!\\n\");\n\t\t\t\terror_occurred=true; \n\t\t\t} catch (IllegalArgumentException i)\n\t\t\t{\n\t\t\t\tprintErr(true, \"Please select an operator.\\n\");\n\t\t\t\terror_occurred=true;\n\t\t\t}\n\t\t}\n\t\tif (!error_occurred)\n\t\t\toutputBox.setText(\"Answer: \" + solution);\n\t\telse\n\t\t\toutputBox.setText(\"Answer: \");\n\t}\n"} {"input": "\t\tpublic void CreateAdRequest(Activity activity,\n\t\t\t\tLinearLayout view) {\n\t\t\tadview = new AdView(activity, AdSize.BANNER,\n\t\t\t\t\tmyAdID);\n\t\t\tview.addView(adview);\n\t\t\tAdRequest adRequest = new AdRequest();\n\t\t\tadRequest.addTestDevice(AdRequest.TEST_EMULATOR);\n\t\t\tadRequest.addTestDevice(myTestDevice);\n\t\t\tadview.loadAd(adRequest);\n\t\t}\n", "output": "\t\tpublic void CreateAdRequest(Activity activity,\n\t\t\t\tLinearLayout view) {\n\t\t\tadview = new AdView(activity, AdSize.BANNER,\n\t\t\t\t\tmyAdID);\n\t\t\tview.addView(adview);\n\t\t\tAdRequest adRequest = new AdRequest();\n\t\t\tif(BuildConfig.DEBUG){\n\t\t\t\tadRequest.addTestDevice(AdRequest.TEST_EMULATOR);\n\t\t\t\tadRequest.addTestDevice(myTestDevice);\n\t\t\t}\n\t\t\tadview.loadAd(adRequest);\n\t\t}\n"} {"input": " public void registerDataTableAndParseAPI(ASMDataTable dataTable)\n {\n this.dataTable = dataTable;\n Set<ASMData> apiList = dataTable.getAll(\"cpw.mods.fml.common.API\");\n apiContainers = Maps.newHashMap();\n for (ASMData data : apiList)\n {\n Map<String, Object> annotationInfo = data.getAnnotationInfo();\n String apiPackage = data.getClassName().substring(0,data.getClassName().indexOf(\".package-info\"));\n String providedAPI = (String) annotationInfo.get(\"provides\");\n String apiOwner = (String) annotationInfo.get(\"owner\");\n String apiVersion = (String) annotationInfo.get(\"apiVersion\");\n APIContainer container = apiContainers.get(providedAPI);\n if (container == null)\n {\n container = new APIContainer(providedAPI, apiVersion, data.getCandidate().getModContainer(), VersionParser.parseVersionReference(apiOwner));\n apiContainers.put(providedAPI, container);\n }\n else\n {\n container.validate(providedAPI, apiOwner, apiVersion);\n }\n container.addOwnedPackage(apiPackage);\n for (ModContainer mc : data.getCandidate().getContainedMods())\n {\n String embeddedIn = mc.getModId();\n if (container.currentReferents.contains(embeddedIn))\n {\n continue;\n }\n FMLLog.fine(\"Found API %s (owned by %s providing %s) embedded in %s\",apiPackage, apiOwner, providedAPI, embeddedIn);\n if (!embeddedIn.equals(apiOwner))\n {\n container.addAPIReference(embeddedIn);\n }\n }\n }\n for (APIContainer container : apiContainers.values())\n {\n for (String pkg : container.packages)\n {\n Set<ModCandidate> candidates = dataTable.getCandidatesFor(pkg);\n for (ModCandidate candidate : candidates)\n {\n List<String> candidateIds = Lists.transform(candidate.getContainedMods(), new ModIdFunction());\n if (!candidateIds.contains(container.ownerMod.getLabel()) && !container.currentReferents.containsAll(candidateIds))\n {\n FMLLog.info(\"Found mod(s) %s containing declared API package %s (owned by %s) without associated API reference\",candidateIds, pkg, container.ownerMod);\n container.addAPIReferences(candidateIds);\n }\n }\n }\n FMLLog.fine(\"Creating API container dummy for API %s: owner: %s, dependents: %s\", container.providedAPI, container.ownerMod, container.referredMods);\n }\n }\n", "output": " public void registerDataTableAndParseAPI(ASMDataTable dataTable)\n {\n this.dataTable = dataTable;\n Set<ASMData> apiList = dataTable.getAll(\"cpw.mods.fml.common.API\");\n apiContainers = Maps.newHashMap();\n for (ASMData data : apiList)\n {\n Map<String, Object> annotationInfo = data.getAnnotationInfo();\n String apiPackage = data.getClassName().substring(0,data.getClassName().indexOf(\".package-info\"));\n String providedAPI = (String) annotationInfo.get(\"provides\");\n String apiOwner = (String) annotationInfo.get(\"owner\");\n String apiVersion = (String) annotationInfo.get(\"apiVersion\");\n APIContainer container = apiContainers.get(providedAPI);\n if (container == null)\n {\n container = new APIContainer(providedAPI, apiVersion, data.getCandidate().getModContainer(), VersionParser.parseVersionReference(apiOwner));\n apiContainers.put(providedAPI, container);\n }\n else\n {\n container.validate(providedAPI, apiOwner, apiVersion);\n }\n container.addOwnedPackage(apiPackage);\n for (ModContainer mc : data.getCandidate().getContainedMods())\n {\n String embeddedIn = mc.getModId();\n if (container.currentReferents.contains(embeddedIn))\n {\n continue;\n }\n FMLLog.fine(\"Found API %s (owned by %s providing %s) embedded in %s\",apiPackage, apiOwner, providedAPI, embeddedIn);\n if (!embeddedIn.equals(apiOwner))\n {\n container.addAPIReference(embeddedIn);\n }\n }\n }\n for (APIContainer container : apiContainers.values())\n {\n for (String pkg : container.packages)\n {\n Set<ModCandidate> candidates = dataTable.getCandidatesFor(pkg);\n for (ModCandidate candidate : candidates)\n {\n List<String> candidateIds = Lists.transform(candidate.getContainedMods(), new ModIdFunction());\n if (!candidateIds.contains(container.ownerMod.getLabel()) && !container.currentReferents.containsAll(candidateIds))\n {\n FMLLog.info(\"Found mod(s) %s containing declared API package %s (owned by %s) without associated API reference\",candidateIds, pkg, container.ownerMod);\n container.addAPIReferences(candidateIds);\n }\n }\n }\n if (apiContainers.containsKey(container.ownerMod.getLabel()))\n {\n ArtifactVersion owner = container.ownerMod;\n do\n {\n APIContainer parent = apiContainers.get(owner.getLabel());\n FMLLog.finest(\"Removing upstream parent %s from %s\", parent.ownerMod.getLabel(), container);\n container.currentReferents.remove(parent.ownerMod.getLabel());\n container.referredMods.remove(parent.ownerMod);\n owner = parent.ownerMod;\n }\n while (apiContainers.containsKey(owner.getLabel()));\n }\n FMLLog.fine(\"Creating API container dummy for API %s: owner: %s, dependents: %s\", container.providedAPI, container.ownerMod, container.referredMods);\n }\n }\n"} {"input": "\tpublic static void shuffle(int[] array) {\n\t\tif (array == null) {\n\t\t\treturn;\n\t\t}\n\t\tRandom rand = new Random();\n\t\tfor (int index = array.length - 1; index >= 1; index--) {\n\t\t\tArrayUtils.swap(array, index, rand.nextInt(index));\n\t\t}\n\t}\n", "output": "\tpublic static void shuffle(int[] array) {\n\t\tif (array == null) {\n\t\t\treturn;\n\t\t}\n\t\tRandom rand = new Random();\n\t\tfor (int index = array.length - 1; index >= 1; index--) {\n\t\t\tArrayUtils.swap(array, index, rand.nextInt(index + 1));\n\t\t}\n\t}\n"} {"input": "\tprivate void playMyEnglish(int initProgress){\n\t\tcurrentPrefValue = sharedPref.getString(\"prefix\",\"AD\"); \n String prefix=currentPrefValue;\n sdDir = Environment.getExternalStorageDirectory();\n path = sdDir.getPath()+MP3_folder+\"/\"; \n fileName = prefix + date + \".MP3\"; \n File f=new File(path + fileName);\n String today = String.format(\"%d\u5e74%d\u6708%d\u65e5\", cYear, cMonth+1,cDay);;\n textViewInfo.setText(\"\u4eca\u5929\u662f\uff1a\" + today);\n textViewInfo.append(\"\\n\u76ee\u6807\u6587\u4ef6\uff1a\" + fileName);\n if(f.exists()){\n \ttry {\n \t\t\tmediaPlayer = new MediaPlayer();\n \t\tmediaPlayer.setDataSource(path + fileName);\n\t\t\t\tmediaPlayer.prepare();\n\t\t\t\tint duration_milisecond = mediaPlayer.getDuration(); \n\t\t\t\tseekBar.setMax(duration_milisecond);\n mTimer = new Timer(); \n mTimerTask = new TimerTask() { \n @Override \n public void run() { \n if(isChanging==true) { \n return; \n }\n int current_position_milisecond = mediaPlayer.getCurrentPosition();\n Message msg = new Message(); \n msg.what = 1;\n Bundle bundle = new Bundle(); \n bundle.putInt(\"current_position_milisecond\", current_position_milisecond); \n msg.setData(bundle); \n mHandler.sendMessage(msg);\n } \n }; \n mTimer.schedule(mTimerTask, 0, 100); \n \t\t\tif(initProgress>0 && initProgress<duration_milisecond){\n \t\t\t\tmediaPlayer.seekTo(initProgress);\n \t\t\t\tseekBar.setProgress(initProgress);\n \t\t\t}\n\t\t\t\tmediaPlayer.start();\n\t\t\t\tString html = \"<br><font color=\\\"#00bbaa\\\">\u6b63\u5728\u64ad\u653e\u6587\u4ef6\uff1a\" + fileName + \"</font>\";\n\t\t\t\ttextViewInfo.append(Html.fromHtml(html));\n\t\t\t\tint duration_minute = duration_milisecond/1000/60; \n\t\t\t\tint duration_second = duration_milisecond/1000%60; \n\t\t\t\ttextViewInfo.append(\"\\n\u6587\u4ef6\u603b\u65f6\u957f\uff1a\" + duration_minute + \"\u5206\" + duration_second + \"\u79d2\");\n\t\t\t\tbuttonControl.setText(getResources().getString(R.string.pause));\n\t\t\t\tbuttonControl.setEnabled(true);\n\t\t mediaPlayer.setOnCompletionListener(new OnCompletionListener(){\n\t\t @Override\n\t\t public void onCompletion(MediaPlayer mp) {\n\t\t \tbuttonControl.setText(getResources().getString(R.string.restart));\n\t\t \tmTimerTask.cancel();\n\t\t mp.release();\n\t\t }\n\t\t });\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n }\n else{\n \ttextViewInfo.append(\"\\n\u627e\u4e0d\u5230\u6587\u4ef6!\");\n \ttextViewTimeRemaining.setText(\"\u5269\u4f59\u65f6\u95f4/\u5df2\u7ecf\u64ad\u653e\u65f6\u95f4\uff1a0\");\n \tbuttonControl.setEnabled(false);\n }\t\n }\n", "output": "\tprivate void playMyEnglish(int initProgress){\n\t\tcurrentPrefValue = sharedPref.getString(\"prefix\",\"AD\"); \n String prefix=currentPrefValue;\n sdDir = Environment.getExternalStorageDirectory();\n path = sdDir.getPath()+MP3_folder+\"/\"; \n fileName = prefix + date + \".MP3\"; \n File f=new File(path + fileName);\n String today = String.format(\"%d\u5e74%d\u6708%d\u65e5\", cYear, cMonth+1,cDay);;\n textViewInfo.setText(\"\u4eca\u5929\u662f\uff1a\" + today);\n textViewInfo.append(\"\\n\u76ee\u6807\u6587\u4ef6\uff1a\" + fileName);\n if(f.exists()){\n \ttry {\n \t\t\tmediaPlayer = new MediaPlayer();\n \t\tmediaPlayer.setDataSource(path + fileName);\n\t\t\t\tmediaPlayer.prepare();\n\t\t\t\tint duration_milisecond = mediaPlayer.getDuration(); \n\t\t\t\tseekBar.setMax(duration_milisecond);\n mTimer = new Timer(); \n mTimerTask = new TimerTask() { \n @Override \n public void run() { \n if(isChanging==true) { \n return; \n }\n int current_position_milisecond = mediaPlayer.getCurrentPosition();\n Message msg = new Message(); \n msg.what = 1;\n Bundle bundle = new Bundle(); \n bundle.putInt(\"current_position_milisecond\", current_position_milisecond); \n msg.setData(bundle); \n mHandler.sendMessage(msg);\n } \n }; \n mTimer.schedule(mTimerTask, 0, 100); \n \t\t\tif(initProgress>0 && initProgress<duration_milisecond){\n \t\t\t\tmediaPlayer.seekTo(initProgress);\n \t\t\t\tseekBar.setProgress(initProgress);\n \t\t\t}\n\t\t\t\tmediaPlayer.start();\n\t\t\t\tString html = \"<br><font color=\\\"#00bbaa\\\">\u6b63\u5728\u64ad\u653e\u6587\u4ef6\uff1a\" + fileName + \"</font>\";\n\t\t\t\ttextViewInfo.append(Html.fromHtml(html));\n\t\t\t\tint duration_minute = duration_milisecond/1000/60; \n\t\t\t\tint duration_second = duration_milisecond/1000%60; \n\t\t\t\ttextViewInfo.append(\"\\n\u6587\u4ef6\u603b\u65f6\u957f\uff1a\" + duration_minute + \"\u5206\" + duration_second + \"\u79d2\");\n\t\t\t\tbuttonControl.setText(getResources().getString(R.string.pause));\n\t\t\t\tbuttonControl.setEnabled(true);\n\t\t mediaPlayer.setOnCompletionListener(new OnCompletionListener(){\n\t\t @Override\n\t\t public void onCompletion(MediaPlayer mp) {\n\t\t \tbuttonControl.setText(getResources().getString(R.string.restart));\n\t\t \tmTimerTask.cancel();\n\t\t mp.release();\n\t\t }\n\t\t });\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n }\n else{\n \tString fileNotFound = \"<br><font color=\\\"red\\\">\u627e\u4e0d\u5230\u6587\u4ef6\uff01\u8bf7\u67e5\u770b\u5e2e\u52a9\u3001\u66f4\u6539\u8bbe\u7f6e\u3001\u6216\u8054\u7cfb\u4f5c\u8005\u3002</font>\";\n\t\t\ttextViewInfo.append(Html.fromHtml(fileNotFound));\n \ttextViewTimeRemaining.setText(\"\u5269\u4f59\u65f6\u95f4/\u5df2\u7ecf\u64ad\u653e\u65f6\u95f4\uff1a0\");\n \tbuttonControl.setEnabled(false);\n }\t\n }\n"} {"input": "\tprotected void prepare(Environment env)\n\t{\n\t\tthrowsDefinitions.add(env.analysisException);\n\t\tIClassDefinition c = classDefinition;\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"\\t/**\\n\");\n\t\tsb.append(\"\\t* Called by the {@link \"\n\t\t\t\t+ AnalysisUtil.getClass(env, c).getName().getName()\n\t\t\t\t+ \"} node from {@link \"\n\t\t\t\t+ AnalysisUtil.getClass(env, c).getName().getName() + \"#apply(\"\n\t\t\t\t+ env.getTaggedDef(env.TAG_IAnalysis).getName().getName()\n\t\t\t\t+ \")}.\\n\");\n\t\tsb.append(\"\\t* @param node the calling {@link \"\n\t\t\t\t+ AnalysisUtil.getClass(env, c).getName().getName()\n\t\t\t\t+ \"} node\\n\");\n\t\tsb.append(\"\\t*/\");\n\t\tthis.javaDoc = sb.toString();\n\t\tString thisNodeMethodName = NameUtil.getClassName(AnalysisUtil.getCaseClass(env, c).getName().getName());\n\t\tthis.name = \"case\" + thisNodeMethodName;\n\t\tthis.setupArguments(env);\n\t\tthis.requiredImports.add(\"java.util.ArrayList\");\n\t\tthis.requiredImports.add(\"java.util.List\");\n\t\tthis.requiredImports.add(env.analysisException.getName().getCanonicalName());\n\t\tStringBuffer bodySb = new StringBuffer();\n\t\tif (!(c instanceof ExternalJavaClassDefinition && ((ExternalJavaClassDefinition) c).extendsNode))\n\t\t{\n\t\t\tbodySb.append(\"\\t\\t_visitedNodes.add(node);\\n\");\n\t\t}\n\t\tif (addReturnToBody)\n\t\t{\n\t\t\tbodySb.append(\"\\t\\tA retVal = createNewReturnValue(\"\n\t\t\t\t\t+ getAdditionalBodyCallArguments() + \");\\n\");\n\t\t}\n\t\tbodySb.append(\"\\t\\t\"\n\t\t\t\t+ wrapForMerge(\"in\" + thisNodeMethodName + \"(\"\n\t\t\t\t\t\t+ getAdditionalBodyCallArguments()) + \");\\n\\n\");\n\t\tList<Field> allFields = new Vector<Field>();\n\t\tallFields.addAll(c.getInheritedFields());\n\t\tallFields.addAll(c.getFields());\n\t\tfor (Field f : allFields)\n\t\t{\n\t\t\tboolean externalNode = false;\n\t\t\tif (f.isTokenField)\n\t\t\t{\n\t\t\t\tif (f.isTypeExternalNode())\n\t\t\t\t{\n\t\t\t\t\texternalNode = true;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tMethod getMethod = new GetMethod(c, f);\n\t\t\tgetMethod.getJavaSourceCode(env);\n\t\t\tString getMethodName = getMethod.name;\n\t\t\tString getter = \"node.\" + getMethodName + \"()\";\n\t\t\trequiredImports.addAll(getMethod.getRequiredImports(env));\n\t\t\tif (!f.isList)\n\t\t\t{\n\t\t\t\tbodySb.append(\"\\t\\tif(\"\n\t\t\t\t\t\t+ getter\n\t\t\t\t\t\t+ \" != null \"\n\t\t\t\t\t\t+ (!externalNode ? \"&& !_\" + visitedNodesField.name\n\t\t\t\t\t\t\t\t+ \".contains(\" + getter + \")\" : \"\") + \") \\n\");\n\t\t\t\tbodySb.append(\"\\t\\t{\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t\"\n\t\t\t\t\t\t+ wrapForMerge(getter + \".apply(\" + getCallArguments())\n\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t}\\n\");\n\t\t\t} else if (f.isList && !f.isDoubleList)\n\t\t\t{\n\t\t\t\tbodySb.append(\"\\t\\t{\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tList<\" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \"> copy = new ArrayList<\"\n\t\t\t\t\t\t+ f.getInnerTypeForList(env) + \">(\" + getter + \");\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tfor( \" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \" e : copy) \\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t{\\n\");\n\t\t\t\tif (!externalNode)\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\tif(!_\" + visitedNodesField.name\n\t\t\t\t\t\t\t+ \".contains(e))\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t{\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t}\\n\");\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t}\n\t\t\t\tbodySb.append(\"\\t\\t\\t}\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t}\\n\");\n\t\t\t} else if (f.isDoubleList)\n\t\t\t{\n\t\t\t\tbodySb.append(\"\\t\\t{\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tList<List<\" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \">> copy = new ArrayList<List<\"\n\t\t\t\t\t\t+ f.getInnerTypeForList(env) + \">>(\" + getter + \");\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tfor( List<\" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \"> list : copy) {\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t\\tfor( \" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \" e : list) \\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t{\\n\");\n\t\t\t\tif (!externalNode)\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\tif(!_\" + visitedNodesField.name\n\t\t\t\t\t\t\t+ \".contains(e))\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t{\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t}\\n\");\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t}\n\t\t\t\tbodySb.append(\"\\t\\t\\t\\t}\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t}\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t}\\n\");\n\t\t\t}\n\t\t}\n\t\tbodySb.append(\"\\n\\t\\t\"\n\t\t\t\t+ wrapForMerge(\"out\" + thisNodeMethodName + \"(\"\n\t\t\t\t\t\t+ getAdditionalBodyCallArguments()) + \");\\n\");\n\t\tif (addReturnToBody)\n\t\t{\n\t\t\tbodySb.append(\"\\t\\treturn retVal;\");\n\t\t}\n\t\tthis.body = bodySb.toString();\n\t}\n", "output": "\tprotected void prepare(Environment env)\n\t{\n\t\tthrowsDefinitions.add(env.analysisException);\n\t\tIClassDefinition c = classDefinition;\n\t\tStringBuilder sb = new StringBuilder();\n\t\tsb.append(\"\\t/**\\n\");\n\t\tsb.append(\"\\t* Called by the {@link \"\n\t\t\t\t+ AnalysisUtil.getClass(env, c).getName().getName()\n\t\t\t\t+ \"} node from {@link \"\n\t\t\t\t+ AnalysisUtil.getClass(env, c).getName().getName() + \"#apply(\"\n\t\t\t\t+ env.getTaggedDef(env.TAG_IAnalysis).getName().getName()\n\t\t\t\t+ \")}.\\n\");\n\t\tsb.append(\"\\t* @param node the calling {@link \"\n\t\t\t\t+ AnalysisUtil.getClass(env, c).getName().getName()\n\t\t\t\t+ \"} node\\n\");\n\t\tsb.append(\"\\t*/\");\n\t\tthis.javaDoc = sb.toString();\n\t\tString thisNodeMethodName = NameUtil.getClassName(AnalysisUtil.getCaseClass(env, c).getName().getName());\n\t\tthis.name = \"case\" + thisNodeMethodName;\n\t\tthis.setupArguments(env);\n\t\tthis.requiredImports.add(\"java.util.ArrayList\");\n\t\tthis.requiredImports.add(\"java.util.List\");\n\t\tthis.requiredImports.add(env.analysisException.getName().getCanonicalName());\n\t\tStringBuffer bodySb = new StringBuffer();\n\t\tif (!(c instanceof ExternalJavaClassDefinition) ||(c instanceof ExternalJavaClassDefinition && ((ExternalJavaClassDefinition) c).extendsNode))\n\t\t{\n\t\t\tbodySb.append(\"\\t\\t_visitedNodes.add(node);\\n\");\n\t\t}\n\t\tif (addReturnToBody)\n\t\t{\n\t\t\tbodySb.append(\"\\t\\tA retVal = createNewReturnValue(\"\n\t\t\t\t\t+ getAdditionalBodyCallArguments() + \");\\n\");\n\t\t}\n\t\tbodySb.append(\"\\t\\t\"\n\t\t\t\t+ wrapForMerge(\"in\" + thisNodeMethodName + \"(\"\n\t\t\t\t\t\t+ getAdditionalBodyCallArguments()) + \");\\n\\n\");\n\t\tList<Field> allFields = new Vector<Field>();\n\t\tallFields.addAll(c.getInheritedFields());\n\t\tallFields.addAll(c.getFields());\n\t\tfor (Field f : allFields)\n\t\t{\n\t\t\tboolean externalNode = false;\n\t\t\tif (f.isTokenField)\n\t\t\t{\n\t\t\t\tif (f.isTypeExternalNode())\n\t\t\t\t{\n\t\t\t\t\texternalNode = true;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tMethod getMethod = new GetMethod(c, f);\n\t\t\tgetMethod.getJavaSourceCode(env);\n\t\t\tString getMethodName = getMethod.name;\n\t\t\tString getter = \"node.\" + getMethodName + \"()\";\n\t\t\trequiredImports.addAll(getMethod.getRequiredImports(env));\n\t\t\tif (!f.isList)\n\t\t\t{\n\t\t\t\tbodySb.append(\"\\t\\tif(\"\n\t\t\t\t\t\t+ getter\n\t\t\t\t\t\t+ \" != null \"\n\t\t\t\t\t\t+ (!externalNode ? \"&& !_\" + visitedNodesField.name\n\t\t\t\t\t\t\t\t+ \".contains(\" + getter + \")\" : \"\") + \") \\n\");\n\t\t\t\tbodySb.append(\"\\t\\t{\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t\"\n\t\t\t\t\t\t+ wrapForMerge(getter + \".apply(\" + getCallArguments())\n\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t}\\n\");\n\t\t\t} else if (f.isList && !f.isDoubleList)\n\t\t\t{\n\t\t\t\tbodySb.append(\"\\t\\t{\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tList<\" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \"> copy = new ArrayList<\"\n\t\t\t\t\t\t+ f.getInnerTypeForList(env) + \">(\" + getter + \");\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tfor( \" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \" e : copy) \\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t{\\n\");\n\t\t\t\tif (!externalNode)\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\tif(!_\" + visitedNodesField.name\n\t\t\t\t\t\t\t+ \".contains(e))\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t{\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t}\\n\");\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t}\n\t\t\t\tbodySb.append(\"\\t\\t\\t}\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t}\\n\");\n\t\t\t} else if (f.isDoubleList)\n\t\t\t{\n\t\t\t\tbodySb.append(\"\\t\\t{\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tList<List<\" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \">> copy = new ArrayList<List<\"\n\t\t\t\t\t\t+ f.getInnerTypeForList(env) + \">>(\" + getter + \");\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\tfor( List<\" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \"> list : copy) {\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t\\tfor( \" + f.getInnerTypeForList(env)\n\t\t\t\t\t\t+ \" e : list) \\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t{\\n\");\n\t\t\t\tif (!externalNode)\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\tif(!_\" + visitedNodesField.name\n\t\t\t\t\t\t\t+ \".contains(e))\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t{\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t}\\n\");\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tbodySb.append(\"\\t\\t\\t\\t\\t\"\n\t\t\t\t\t\t\t+ wrapForMerge(\"e.apply(\" + getCallArguments())\n\t\t\t\t\t\t\t+ \");\\n\");\n\t\t\t\t}\n\t\t\t\tbodySb.append(\"\\t\\t\\t\\t}\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t\\t}\\n\");\n\t\t\t\tbodySb.append(\"\\t\\t}\\n\");\n\t\t\t}\n\t\t}\n\t\tbodySb.append(\"\\n\\t\\t\"\n\t\t\t\t+ wrapForMerge(\"out\" + thisNodeMethodName + \"(\"\n\t\t\t\t\t\t+ getAdditionalBodyCallArguments()) + \");\\n\");\n\t\tif (addReturnToBody)\n\t\t{\n\t\t\tbodySb.append(\"\\t\\treturn retVal;\");\n\t\t}\n\t\tthis.body = bodySb.toString();\n\t}\n"} {"input": " public static int getBufferSize() {\n int result = BUFFER_SIZE;\n try {\n result = Integer.parseInt(System.getProperties().getProperty(\n \"org.restlet.engine.io.buffer.size\"));\n } catch (NumberFormatException nfe) {\n result = BUFFER_SIZE;\n }\n return result;\n }\n", "output": " public static int getBufferSize() {\n int result = BUFFER_SIZE;\n try {\n result = Integer.parseInt(System\n .getProperty(\"org.restlet.engine.io.buffer.size\"));\n } catch (NumberFormatException nfe) {\n result = BUFFER_SIZE;\n }\n return result;\n }\n"} {"input": "\tvoid show(Contact contact) {\n\t\tif (contact != null) {\n\t\t\tif (contact.hasBirthday()) {\n\t\t\t\tbdayIcon.setVisible(true);\n\t\t\t} else {\n\t\t\t\tbdayIcon.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.hasNameDay()) {\n\t\t\t\tnamedayIcon.setVisible(true);\n\t\t\t} else {\n\t\t\t\tnamedayIcon.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.hasCelebration()) {\n\t\t\t\tcelebrationIcon.setVisible(true);\n\t\t\t} else {\n\t\t\t\tcelebrationIcon.setVisible(false);\n\t\t\t}\n\t\t\tphoto.setContact(contact);\n\t\t\tphoto.setVisible(true);\n\t\t\tname.setText(String.format(\"<html><h1>\" + contact.getFullName() + \"</h1></html>\"));\n\t\t\tif (contact.getNickName() != null && !contact.getNickName().isEmpty()) {\n\t\t\t\tnicknameLabel.setVisible(true);\n\t\t\t\tnickname.setVisible(true);\n\t\t\t\tnickname.setText(contact.getNickName());\n\t\t\t} else {\n\t\t\t\tnicknameLabel.setVisible(false);\n\t\t\t\tnickname.setVisible(false);\n\t\t\t}\n\t\t\taddress.removeAll();\n\t\t\taddressLabel.setVisible(false);\n\t\t\tfor (Address a : contact.getAdresses()) {\n\t\t\t\tif (!a.getAddress().isEmpty()) {\n\t\t\t\t\taddressLabel.setVisible(true);\n\t\t\t\t\tJLabelButton l = new JLabelButton();\n\t\t\t\t\tl.setVerticalTextPosition(JLabel.TOP);\n\t\t\t\t\tl.setHorizontalTextPosition(JLabel.CENTER);\n\t\t\t\t\tl.setAlignmentX(Component.LEFT_ALIGNMENT);\n\t\t\t\t\tl.setCursor(new Cursor(Cursor.HAND_CURSOR));\n\t\t\t\t\tl.setText(a.getAddress());\n\t\t\t\t\ttry {\n\t\t\t\t\t\tl.setIcon(new ImageIcon(new URL(\"http://maps.google.com/maps/api/staticmap?size=128x128&sensor=false&markers=\" + URLEncoder.encode(l.getText(), \"utf8\"))));\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tSystem.err.println(e);\n\t\t\t\t\t}\n\t\t\t\t\tl.addActionListener(new MapListener());\n\t\t\t\t\taddress.add(l);\n\t\t\t\t}\n\t\t\t}\n\t\t\temails.removeAll();\n\t\t\temailLabel.setVisible(false);\n\t\t\tfor (Email e : contact.getEmails()) {\n\t\t\t\tif (!e.getEmail().isEmpty()) {\n\t\t\t\t\temailLabel.setVisible(true);\n\t\t\t\t\tJLabelButton lb = new JLabelButton(e.getEmail());\n\t\t\t\t\tlb.setCursor(new Cursor(Cursor.HAND_CURSOR));\n\t\t\t\t\tlb.addActionListener(new EmailListener());\n\t\t\t\t\temails.add(lb);\n\t\t\t\t}\n\t\t\t}\n\t\t\twebs.removeAll();\n\t\t\twebsLabel.setVisible(false);\n\t\t\tfor (Url u : contact.getUrls()) {\n\t\t\t\tif (u.getValue() != null) {\n\t\t\t\t\twebsLabel.setVisible(true);\n\t\t\t\t\tJLabelButton lb = new JLabelButton(u.getValue().toString());\n\t\t\t\t\tlb.setCursor(new Cursor(Cursor.HAND_CURSOR));\n\t\t\t\t\tlb.addActionListener(new WebListener());\n\t\t\t\t\temails.add(lb);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!contact.getPhoneNumbers().isEmpty()) {\n\t\t\t\tphoneLabel.setVisible(true);\n\t\t\t\tphones.setVisible(true);\n\t\t\t\tphones.setText(\"<html>\" + contact.getAllPhones().replaceAll(\", \", \"<br>\") + \"</html>\");\n\t\t\t} else {\n\t\t\t\tphoneLabel.setVisible(false);\n\t\t\t\tphones.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getBirthday() != null && contact.getBirthday().getDate() != null) {\n\t\t\t\tbirthday.setVisible(true);\n\t\t\t\tbirthdayLabel.setVisible(true);\n\t\t\t\tbirthday.setText(DateFormat.getDateInstance().format(contact.getBirthday().getDate()));\n\t\t\t} else {\n\t\t\t\tbirthday.setVisible(false);\n\t\t\t\tbirthdayLabel.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getNameDay() != null && contact.getNameDay().getDate() != null) {\n\t\t\t\tnameday.setVisible(true);\n\t\t\t\tnamedayLabel.setVisible(true);\n\t\t\t\tnameday.setText(DateFormat.getDateInstance().format(contact.getNameDay().getDate()));\n\t\t\t} else {\n\t\t\t\tnameday.setVisible(false);\n\t\t\t\tnamedayLabel.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getCelebration() != null && contact.getCelebration().getDate() != null) {\n\t\t\t\tcelebration.setVisible(true);\n\t\t\t\tcelebrationLabel.setVisible(true);\n\t\t\t\tcelebration.setText(DateFormat.getDateInstance().format(contact.getCelebration().getDate()));\n\t\t\t} else {\n\t\t\t\tcelebration.setVisible(false);\n\t\t\t\tcelebrationLabel.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getNote() != null && !contact.getNote().isEmpty()) {\n\t\t\t\tnote.setVisible(true);\n\t\t\t\tnoteLabel.setVisible(true);\n\t\t\t\tnote.setText(\"<html>\" + contact.getNote().replaceAll(\"\\n\", \"<br>\") + \"</html>\");\n\t\t\t} else {\n\t\t\t\tnote.setVisible(false);\n\t\t\t\tnoteLabel.setVisible(false);\n\t\t\t}\n\t\t\tString separator = \"\";\n\t\t\tfinal StringBuilder groupstring = new StringBuilder();\n\t\t\tgroups.setVisible(false);\n\t\t\tgroupsLabel.setVisible(false);\n\t\t\tfor (Group g : db.getAllGroupsForContact(contact)) {\n\t\t\t\tgroups.setVisible(true);\n\t\t\t\tgroupsLabel.setVisible(true);\n\t\t\t\tgroupstring.append(separator);\n\t\t\t\tgroupstring.append(g.getName());\n\t\t\t\tseparator = \", \";\n\t\t\t}\n\t\t\tgroups.setText(groupstring.toString());\n\t\t\tdetailScrollPane.setVisible(true);\n\t\t}\n\t}\n", "output": "\tvoid show(Contact contact) {\n\t\tif (contact != null) {\n\t\t\tif (contact.hasBirthday()) {\n\t\t\t\tbdayIcon.setVisible(true);\n\t\t\t} else {\n\t\t\t\tbdayIcon.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.hasNameDay()) {\n\t\t\t\tnamedayIcon.setVisible(true);\n\t\t\t} else {\n\t\t\t\tnamedayIcon.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.hasCelebration()) {\n\t\t\t\tcelebrationIcon.setVisible(true);\n\t\t\t} else {\n\t\t\t\tcelebrationIcon.setVisible(false);\n\t\t\t}\n\t\t\tphoto.setContact(contact);\n\t\t\tphoto.setVisible(true);\n\t\t\tname.setText(String.format(\"<html><h1>\" + contact.getFullName() + \"</h1></html>\"));\n\t\t\tif (contact.getNickName() != null && !contact.getNickName().isEmpty()) {\n\t\t\t\tnicknameLabel.setVisible(true);\n\t\t\t\tnickname.setVisible(true);\n\t\t\t\tnickname.setText(contact.getNickName());\n\t\t\t} else {\n\t\t\t\tnicknameLabel.setVisible(false);\n\t\t\t\tnickname.setVisible(false);\n\t\t\t}\n\t\t\taddress.removeAll();\n\t\t\taddressLabel.setVisible(false);\n\t\t\tfor (Address a : contact.getAdresses()) {\n\t\t\t\tif (!a.getAddress().isEmpty()) {\n\t\t\t\t\taddressLabel.setVisible(true);\n\t\t\t\t\tJLabelButton l = new JLabelButton();\n\t\t\t\t\tl.setVerticalTextPosition(JLabel.TOP);\n\t\t\t\t\tl.setHorizontalTextPosition(JLabel.CENTER);\n\t\t\t\t\tl.setAlignmentX(Component.LEFT_ALIGNMENT);\n\t\t\t\t\tl.setCursor(new Cursor(Cursor.HAND_CURSOR));\n\t\t\t\t\tl.setText(a.getAddress());\n\t\t\t\t\ttry {\n\t\t\t\t\t\tl.setIcon(new ImageIcon(new URL(\"http://maps.google.com/maps/api/staticmap?size=128x128&sensor=false&markers=\" + URLEncoder.encode(l.getText(), \"utf8\"))));\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tSystem.err.println(e);\n\t\t\t\t\t}\n\t\t\t\t\tl.addActionListener(new MapListener());\n\t\t\t\t\taddress.add(l);\n\t\t\t\t}\n\t\t\t}\n\t\t\temails.removeAll();\n\t\t\temailLabel.setVisible(false);\n\t\t\tfor (Email e : contact.getEmails()) {\n\t\t\t\tif (!e.getEmail().isEmpty()) {\n\t\t\t\t\temailLabel.setVisible(true);\n\t\t\t\t\tJLabelButton lb = new JLabelButton(e.getEmail());\n\t\t\t\t\tlb.setCursor(new Cursor(Cursor.HAND_CURSOR));\n\t\t\t\t\tlb.addActionListener(new EmailListener());\n\t\t\t\t\temails.add(lb);\n\t\t\t\t}\n\t\t\t}\n\t\t\twebs.removeAll();\n\t\t\twebsLabel.setVisible(false);\n\t\t\tfor (Url u : contact.getUrls()) {\n\t\t\t\tif (u.getValue() != null) {\n\t\t\t\t\twebsLabel.setVisible(true);\n\t\t\t\t\tJLabelButton lb = new JLabelButton(u.getValue().toString());\n\t\t\t\t\tlb.setCursor(new Cursor(Cursor.HAND_CURSOR));\n\t\t\t\t\tlb.addActionListener(new WebListener());\n\t\t\t\t\twebs.add(lb);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!contact.getPhoneNumbers().isEmpty()) {\n\t\t\t\tphoneLabel.setVisible(true);\n\t\t\t\tphones.setVisible(true);\n\t\t\t\tphones.setText(\"<html>\" + contact.getAllPhones().replaceAll(\", \", \"<br>\") + \"</html>\");\n\t\t\t} else {\n\t\t\t\tphoneLabel.setVisible(false);\n\t\t\t\tphones.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getBirthday() != null && contact.getBirthday().getDate() != null) {\n\t\t\t\tbirthday.setVisible(true);\n\t\t\t\tbirthdayLabel.setVisible(true);\n\t\t\t\tbirthday.setText(DateFormat.getDateInstance().format(contact.getBirthday().getDate()));\n\t\t\t} else {\n\t\t\t\tbirthday.setVisible(false);\n\t\t\t\tbirthdayLabel.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getNameDay() != null && contact.getNameDay().getDate() != null) {\n\t\t\t\tnameday.setVisible(true);\n\t\t\t\tnamedayLabel.setVisible(true);\n\t\t\t\tnameday.setText(DateFormat.getDateInstance().format(contact.getNameDay().getDate()));\n\t\t\t} else {\n\t\t\t\tnameday.setVisible(false);\n\t\t\t\tnamedayLabel.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getCelebration() != null && contact.getCelebration().getDate() != null) {\n\t\t\t\tcelebration.setVisible(true);\n\t\t\t\tcelebrationLabel.setVisible(true);\n\t\t\t\tcelebration.setText(DateFormat.getDateInstance().format(contact.getCelebration().getDate()));\n\t\t\t} else {\n\t\t\t\tcelebration.setVisible(false);\n\t\t\t\tcelebrationLabel.setVisible(false);\n\t\t\t}\n\t\t\tif (contact.getNote() != null && !contact.getNote().isEmpty()) {\n\t\t\t\tnote.setVisible(true);\n\t\t\t\tnoteLabel.setVisible(true);\n\t\t\t\tnote.setText(\"<html>\" + contact.getNote().replaceAll(\"\\n\", \"<br>\") + \"</html>\");\n\t\t\t} else {\n\t\t\t\tnote.setVisible(false);\n\t\t\t\tnoteLabel.setVisible(false);\n\t\t\t}\n\t\t\tString separator = \"\";\n\t\t\tfinal StringBuilder groupstring = new StringBuilder();\n\t\t\tgroups.setVisible(false);\n\t\t\tgroupsLabel.setVisible(false);\n\t\t\tfor (Group g : db.getAllGroupsForContact(contact)) {\n\t\t\t\tgroups.setVisible(true);\n\t\t\t\tgroupsLabel.setVisible(true);\n\t\t\t\tgroupstring.append(separator);\n\t\t\t\tgroupstring.append(g.getName());\n\t\t\t\tseparator = \", \";\n\t\t\t}\n\t\t\tgroups.setText(groupstring.toString());\n\t\t\tdetailScrollPane.setVisible(true);\n\t\t}\n\t}\n"} {"input": " public boolean renderImpl(final GWikiContext ctx, final MacroAttributes attrs)\n {\n if (RenderModes.NoToc.isSet(ctx.getRenderMode()) == true) {\n return true;\n }\n final GWikiElementInfo elementInfo = ctx.getCurrentElement().getElementInfo();\n if (elementInfo.getId() == null) {\n return false;\n }\n final ArrayList<String> breadcrumbs = new ArrayList<String>();\n if (elementInfo.isIndexed()) {\n breadcrumbs.add(elementInfo.getId());\n setParentForElement(ctx, elementInfo, breadcrumbs);\n } else {\n final String pageId = ctx.getRequestParameter(\"pageId\");\n final String parentPageId = ctx.getRequestParameter(\"parentPageId\");\n if (StringUtils.isNotBlank(pageId)) {\n computeParameter(ctx, breadcrumbs, pageId);\n } else if (StringUtils.isNotBlank(parentPageId)) {\n computeParameter(ctx, breadcrumbs, parentPageId);\n } else {\n breadcrumbs.add(ctx.getWikiWeb().getWikiConfig().getWelcomePageId());\n }\n }\n ctx.append(\"<ul>\");\n for (int i = breadcrumbs.size() - 1; i >= 0; i--) {\n ctx.append(\"<li>\").append(ctx.renderLocalUrl(breadcrumbs.get(i))).append(\"</li>\");\n }\n ctx.append(\"</ul>\");\n ctx.flush();\n return true;\n }\n", "output": " public boolean renderImpl(final GWikiContext ctx, final MacroAttributes attrs)\n {\n if (RenderModes.NoToc.isSet(ctx.getRenderMode()) == true) {\n return true;\n }\n final GWikiElementInfo elementInfo = ctx.getCurrentElement().getElementInfo();\n if (elementInfo.getId() == null) {\n return false;\n }\n final ArrayList<String> breadcrumbs = new ArrayList<String>();\n if (elementInfo.isIndexed()) {\n breadcrumbs.add(elementInfo.getId());\n setParentForElement(ctx, elementInfo, breadcrumbs);\n } else {\n final String pageId = ctx.getRequestParameter(\"pageId\");\n final String parentPageId = ctx.getRequestParameter(\"parentPageId\");\n if (StringUtils.isNotBlank(pageId)\n && ctx.getWikiWeb().findElement(pageId) != null\n && ctx.getWikiWeb().findElement(pageId).getElementInfo().isIndexed()) {\n computeParameter(ctx, breadcrumbs, pageId);\n } else if (StringUtils.isNotBlank(parentPageId)\n && ctx.getWikiWeb().findElement(parentPageId) != null\n && ctx.getWikiWeb().findElement(parentPageId).getElementInfo().isIndexed()) {\n computeParameter(ctx, breadcrumbs, parentPageId);\n } else {\n breadcrumbs.add(ctx.getWikiWeb().getWikiConfig().getWelcomePageId());\n }\n }\n ctx.append(\"<ul>\");\n for (int i = breadcrumbs.size() - 1; i >= 0; i--) {\n ctx.append(\"<li>\").append(ctx.renderLocalUrl(breadcrumbs.get(i))).append(\"</li>\");\n }\n ctx.append(\"</ul>\");\n ctx.flush();\n return true;\n }\n"} {"input": "\tpublic ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception\n\t{\n\t\tActionErrors errors = new ActionErrors();\n\t\tActionMessages messages = new ActionMessages();\n\t\tHttpSession session = request.getSession();\n\t\tBaseDBForm baseDBForm = (BaseDBForm)form;\n\t\tif (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {\n\t\t\tif (logDB.isDebugEnabled())\n\t\t\t\tlogDB.debug(\"||\"+baseDBForm.getFormName()+\"|search|Failure|No Session or User Object Forwarding to the Login Page||\");\n\t\t\treturn mapping.findForward(ForwardConstants.LOGIN_PAGE);\n\t\t}\n\t\tUserInfoHelper.setUserInfo(((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId());\n\t\ttry\n\t\t{\n\t\t\tSearchResult searchResult = baseDBForm.searchObjects(request,errors,messages);\n\t\t\tif ( searchResult.getSearchResultObjects() == null || searchResult.getSearchResultObjects().isEmpty())\n\t\t\t{\n\t\t\t\terrors.add(ActionErrors.GLOBAL_ERROR, new ActionError(DisplayConstants.ERROR_ID, \"The search criteria returned zero results\"));\n\t\t\t\tsaveErrors( request,errors );\n\t\t\t\tif (logDB.isDebugEnabled())\n\t\t\t\t\tlogDB.debug(session.getId()+\"|\"+((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()+\n\t\t\t\t\t\t\"|\"+baseDBForm.getFormName()+\"|search|Failure|No Records found for \"+baseDBForm.getFormName()+\" object|\"\n\t\t\t\t\t\t+form.toString()+\"|\");\n\t\t\t\tbaseDBForm.resetForm();\n\t\t\t\treturn (mapping.findForward(ForwardConstants.SEARCH_FAILURE));\t\t\t\t\t\n\t\t\t}\n\t\t\tif (searchResult.getSearchResultMessage() != null && !(searchResult.getSearchResultMessage().trim().equalsIgnoreCase(\"\")))\n\t\t\t{\n\t\t\t\tmessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(DisplayConstants.MESSAGE_ID, searchResult.getSearchResultMessage()));\n\t\t\t\tsaveMessages( request, messages );\n\t\t\t}\n\t\t\tif(session.getAttribute(DisplayConstants.SEARCH_RESULT)!=null){\n\t\t\t\tsession.setAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT, session.getAttribute(DisplayConstants.SEARCH_RESULT) );\n\t\t\t}\n\t\t\tsession.setAttribute(DisplayConstants.SEARCH_RESULT, searchResult);\n\t\t}\n\t\tcatch (CSException cse)\n\t\t{\n\t\t\terrors.add(ActionErrors.GLOBAL_ERROR, new ActionError(DisplayConstants.ERROR_ID, cse.getMessage()));\t\t\t\n\t\t\tsaveErrors( request,errors );\n\t\t\tif (logDB.isDebugEnabled())\n\t\t\t\tlogDB.debug(session.getId()+\"|\"+((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()+\n\t\t\t\t\t\"|\"+baseDBForm.getFormName()+\"|search|Failure|Error Searching the \"+baseDBForm.getFormName()+\" object|\"\n\t\t\t\t\t+form.toString()+\"|\"+ cse.getMessage());\n\t\t}\n\t\tsession.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);\n\t\tif (logDB.isDebugEnabled())\n\t\t\tlogDB.debug(session.getId()+\"|\"+((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()+\n\t\t\t\t\"|\"+baseDBForm.getFormName()+\"|search|Success|Success in searching \"+baseDBForm.getFormName()+\" object|\"\n\t\t\t\t+form.toString()+\"|\");\n\t\treturn (mapping.findForward(ForwardConstants.SEARCH_SUCCESS));\t\n\t}\n", "output": "\tpublic ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception\n\t{\n\t\tActionErrors errors = new ActionErrors();\n\t\tActionMessages messages = new ActionMessages();\n\t\tHttpSession session = request.getSession();\n\t\tBaseDBForm baseDBForm = (BaseDBForm)form;\n\t\tif (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) {\n\t\t\tif (logDB.isDebugEnabled())\n\t\t\t\tlogDB.debug(\"||\"+baseDBForm.getFormName()+\"|search|Failure|No Session or User Object Forwarding to the Login Page||\");\n\t\t\treturn mapping.findForward(ForwardConstants.LOGIN_PAGE);\n\t\t}\n\t\tUserInfoHelper.setUserInfo(((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId());\n\t\ttry\n\t\t{\n\t\t\tSearchResult searchResult = baseDBForm.searchObjects(request,errors,messages);\n\t\t\tif ( searchResult.getSearchResultObjects() == null || searchResult.getSearchResultObjects().isEmpty())\n\t\t\t{\n\t\t\t\terrors.add(ActionErrors.GLOBAL_ERROR, new ActionError(DisplayConstants.ERROR_ID, \"The search criteria returned zero results\"));\n\t\t\t\tsaveErrors( request,errors );\n\t\t\t\tif (logDB.isDebugEnabled())\n\t\t\t\t\tlogDB.debug(session.getId()+\"|\"+((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()+\n\t\t\t\t\t\t\"|\"+baseDBForm.getFormName()+\"|search|Failure|No Records found for \"+baseDBForm.getFormName()+\" object|\"\n\t\t\t\t\t\t+form.toString()+\"|\");\n\t\t\t\tbaseDBForm.resetForm();\n\t\t\t\treturn (mapping.findForward(ForwardConstants.SEARCH_FAILURE));\t\t\t\t\t\n\t\t\t}\n\t\t\tif (searchResult.getSearchResultMessage() != null && !(searchResult.getSearchResultMessage().trim().equalsIgnoreCase(\"\")))\n\t\t\t{\n\t\t\t\tmessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(DisplayConstants.MESSAGE_ID, searchResult.getSearchResultMessage()));\n\t\t\t\tsaveMessages( request, messages );\n\t\t\t}\n\t\t\tif(session.getAttribute(DisplayConstants.SEARCH_RESULT)!=null){\n\t\t\t\tif(session.getAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT)==null)\n\t\t\t\t\tsession.setAttribute(DisplayConstants.ORIGINAL_SEARCH_RESULT, session.getAttribute(DisplayConstants.SEARCH_RESULT) );\n\t\t\t}\n\t\t\tsession.setAttribute(DisplayConstants.SEARCH_RESULT, searchResult);\n\t\t}\n\t\tcatch (CSException cse)\n\t\t{\n\t\t\terrors.add(ActionErrors.GLOBAL_ERROR, new ActionError(DisplayConstants.ERROR_ID, cse.getMessage()));\t\t\t\n\t\t\tsaveErrors( request,errors );\n\t\t\tif (logDB.isDebugEnabled())\n\t\t\t\tlogDB.debug(session.getId()+\"|\"+((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()+\n\t\t\t\t\t\"|\"+baseDBForm.getFormName()+\"|search|Failure|Error Searching the \"+baseDBForm.getFormName()+\" object|\"\n\t\t\t\t\t+form.toString()+\"|\"+ cse.getMessage());\n\t\t}\n\t\tsession.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm);\n\t\tif (logDB.isDebugEnabled())\n\t\t\tlogDB.debug(session.getId()+\"|\"+((LoginForm)session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId()+\n\t\t\t\t\"|\"+baseDBForm.getFormName()+\"|search|Success|Success in searching \"+baseDBForm.getFormName()+\" object|\"\n\t\t\t\t+form.toString()+\"|\");\n\t\treturn (mapping.findForward(ForwardConstants.SEARCH_SUCCESS));\t\n\t}\n"} {"input": " public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {\n String eName = (\"\".equals(localName)) ? qName : localName;\n transformedXmlAsBuffer.append(\"<\" + eName);\n if(eName.equals(\"Link\")) {\n for(int i = 0; i < attrs.getLength(); i++) {\n String aName = attrs.getQName(i);\n String aValue = attrs.getValue(i);\n if(aName.equals(\"href\")) {\n if(aValue.startsWith(\"external_\")) {\n aValue = aValue.substring(9);\n } else {\n boolean externalLink = false;\n for(int j=0; j<externalLinks.length; j++) {\n if(aValue.startsWith(externalLinks[j])) {\n externalLink = true;\n break;\n }\n }\n if(!externalLink && !resourceExists(aValue)) {\n log.error(\"Resource : [\" + aValue + \"] does not exist\");\n transformedXmlAsBuffer.append(\" exist=\\\"false\\\"\");\n }\n }\n }\n transformedXmlAsBuffer.append(\" \" + aName + \"=\\\"\" + aValue + \"\\\"\");\n } \n } else {\n for(int i = 0; i < attrs.getLength(); i++) {\n String aName = attrs.getQName(i);\n String aValue = attrs.getValue(i);\n StringBuffer tmp = new StringBuffer();\n for(int j=0; j<aValue.length(); j++) {\n if(aValue.charAt(j) == '\"') tmp.append(\""\");\n else tmp.append(aValue.charAt(j));\n }\n transformedXmlAsBuffer.append(\" \" + aName + \"=\\\"\" + tmp.toString() + \"\\\"\");\n }\n }\n transformedXmlAsBuffer.append(\">\");\n }\n", "output": " public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {\n String eName = (\"\".equals(localName)) ? qName : localName;\n transformedXmlAsBuffer.append(\"<\" + eName);\n if(eName.equals(\"Link\")) {\n for(int i = 0; i < attrs.getLength(); i++) {\n String aName = attrs.getQName(i);\n String aValue = attrs.getValue(i);\n if(aName.equals(\"href\")) {\n if(aValue.startsWith(\"external_\")) {\n aValue = aValue.substring(9);\n } else {\n boolean externalLink = false;\n for(int j=0; j<externalLinks.length; j++) {\n if(aValue.startsWith(externalLinks[j])) {\n externalLink = true;\n break;\n }\n }\n if(!externalLink && !resourceExists(aValue)) {\n log.warn(\"Link : [\" + aValue + \"] does not exist\");\n transformedXmlAsBuffer.append(\" exist=\\\"false\\\"\");\n }\n }\n }\n transformedXmlAsBuffer.append(\" \" + aName + \"=\\\"\" + aValue + \"\\\"\");\n } \n } else {\n for(int i = 0; i < attrs.getLength(); i++) {\n String aName = attrs.getQName(i);\n String aValue = attrs.getValue(i);\n StringBuffer tmp = new StringBuffer();\n for(int j=0; j<aValue.length(); j++) {\n if(aValue.charAt(j) == '\"') tmp.append(\""\");\n else tmp.append(aValue.charAt(j));\n }\n transformedXmlAsBuffer.append(\" \" + aName + \"=\\\"\" + tmp.toString() + \"\\\"\");\n }\n }\n transformedXmlAsBuffer.append(\">\");\n }\n"} {"input": " protected void initFile(String id) throws FormatException, IOException {\n if (debug) debug(\"ND2Reader.initFile(\" + id + \")\");\n if (noJ2k) throw new FormatException(NO_J2K_MSG);\n super.initFile(id);\n in = new RandomAccessStream(id);\n if (in.read() == -38 && in.read() == -50) {\n isJPEG = false;\n in.seek(0);\n in.order(true);\n byte[] b = new byte[1024 * 1024];\n while (in.getFilePointer() < in.length()) {\n if (in.read() == -38 && in.read() == -50 && in.read() == -66 &&\n in.read() == 10)\n {\n int len = in.readInt() + in.readInt();\n if (len > b.length) {\n int size = b.length + b.length;\n if (size < len) size = len;\n b = new byte[size];\n }\n in.skipBytes(4);\n if (debug) {\n debug(\"Reading chunk of size \" + len +\n \" at position \" + in.getFilePointer());\n }\n in.readFully(b, 0, len);\n if (len >= 12 && b[0] == 'I' && b[1] == 'm' && b[2] == 'a' &&\n b[3] == 'g' && b[4] == 'e' && b[5] == 'D' && b[6] == 'a' &&\n b[7] == 't' && b[8] == 'a' && b[9] == 'S' && b[10] == 'e' &&\n b[11] == 'q') \n {\n StringBuffer sb = new StringBuffer();\n int pt = 13;\n while (b[pt] != '!') {\n sb.append((char) b[pt]);\n pt++;\n }\n int ndx = Integer.parseInt(sb.toString());\n if (core.sizeC[0] == 0) {\n core.sizeC[0] = len / (core.sizeX[0] * core.sizeY[0] *\n FormatTools.getBytesPerPixel(core.pixelType[0]));\n }\n offsets[0][ndx] = in.getFilePointer() - len + sb.length() + 21;\n while (offsets[0][ndx] - in.getFilePointer() +\n len - 14 - sb.length() < 8)\n {\n offsets[0][ndx]++;\n }\n }\n else if (len >= 5 && b[0] == 'I' && b[1] == 'm' && b[2] == 'a' &&\n b[3] == 'g' && b[4] == 'e') \n {\n ND2Handler handler = new ND2Handler();\n int off = 0;\n for (int i=0; i<len; i++) {\n char c = (char) b[i];\n if (off == 0 && c == '!') off = i + 1;\n if (Character.isISOControl(c) || !Character.isDefined(c)) {\n b[i] = (byte) ' ';\n }\n }\n if (len - off >= 5 && b[off] == '<' && b[off + 1] == '?' &&\n b[off + 2] == 'x' && b[off + 3] == 'm' &&\n b[off + 4] == 'l') \n {\n ByteArrayInputStream s =\n new ByteArrayInputStream(b, off, len - off);\n try {\n SAXParser parser = SAX_FACTORY.newSAXParser();\n parser.parse(s, handler);\n }\n catch (ParserConfigurationException exc) {\n throw new FormatException(exc);\n }\n catch (SAXException exc) {\n throw new FormatException(exc);\n }\n }\n }\n if (core.imageCount[0] > 0 && offsets == null) {\n offsets = new long[1][core.imageCount[0]];\n }\n if (in.getFilePointer() < in.length() - 1) {\n if (in.read() != -38) in.skipBytes(15);\n else in.seek(in.getFilePointer() - 1);\n }\n }\n }\n if (core.sizeC[0] == 0) core.sizeC[0] = 1;\n core.currentOrder[0] = \"XYCZT\";\n core.rgb[0] = core.sizeC[0] > 1;\n if (core.sizeC[0] > 1 && adjustImageCount) {\n core.imageCount[0] /= 3;\n core.sizeT[0] /= 3;\n }\n core.littleEndian[0] = true;\n core.interleaved[0] = true;\n core.indexed[0] = false;\n core.falseColor[0] = false;\n core.metadataComplete[0] = true;\n MetadataStore store = getMetadataStore();\n store.setImage(currentId, null, null, null);\n FormatTools.populatePixels(store, this);\n for (int i=0; i<core.sizeC[0]; i++) {\n store.setLogicalChannel(i, null, null, null, null, null, null, null,\n null, null, null, null, null, null, null, null, null, null, null,\n null, null, null, null, null, null);\n }\n return;\n }\n else in.seek(0);\n isJPEG = true;\n status(\"Calculating image offsets\");\n Vector vs = new Vector();\n long pos = in.getFilePointer();\n boolean lastBoxFound = false;\n int length = 0;\n int box = 0;\n while (!lastBoxFound) {\n pos = in.getFilePointer();\n length = in.readInt();\n if (pos + length >= in.length() || length == 0) lastBoxFound = true;\n box = in.readInt();\n pos = in.getFilePointer();\n length -= 8;\n if (box == 0x6a703263) {\n vs.add(new Long(in.getFilePointer()));\n }\n if (!lastBoxFound) in.seek(pos + length);\n }\n status(\"Finding XML metadata\");\n in.seek(((Long) vs.get(vs.size() - 1)).longValue());\n boolean found = false;\n long off = -1;\n byte[] buf = new byte[2048];\n while (!found && in.getFilePointer() < in.length()) {\n int read = 0;\n if (in.getFilePointer() == ((Long) vs.get(vs.size() - 1)).longValue()) {\n read = in.read(buf);\n }\n else {\n System.arraycopy(buf, buf.length - 10, buf, 0, 10);\n read = in.read(buf, 10, buf.length - 10);\n }\n if (read == buf.length) read -= 10;\n for (int i=0; i<read+9; i++) {\n if (buf[i] == (byte) 0xff && buf[i+1] == (byte) 0xd9) {\n found = true;\n off = in.getFilePointer() - (read + 10) + i;\n i = buf.length;\n break;\n }\n }\n }\n buf = null;\n status(\"Parsing XML\");\n if (off > 0 && off < in.length() - 5) {\n in.seek(off + 5);\n byte[] b = new byte[(int) (in.length() - off - 5)];\n in.readFully(b);\n String xml = new String(b);\n xml = xml.substring(0, xml.lastIndexOf(\"</MetadataSeq>\") + 14);\n xml = xml.replaceAll(\"<!--*-->\", \"\");\n StringTokenizer st = new StringTokenizer(xml, \"\\r\\n\");\n while (st.hasMoreTokens()) {\n String token = st.nextToken().trim();\n if (token.indexOf(\"<\") != -1) {\n String prefix = token.substring(1, token.indexOf(\">\")).trim();\n token = token.substring(token.indexOf(\">\") + 1);\n while (token.indexOf(\"<\") != -1) {\n int start = token.indexOf(\"<\");\n String s = token.substring(start + 1, token.indexOf(\">\", start));\n token = token.substring(token.indexOf(\">\", start));\n if (s.indexOf(\" \") != -1) {\n String pre = s.substring(0, s.indexOf(\" \")).trim();\n s = s.substring(s.indexOf(\" \") + 1);\n while (s.indexOf(\"=\") != -1) {\n int eq = s.indexOf(\"=\");\n String key = s.substring(0, eq).trim();\n String value =\n s.substring(eq + 2, s.indexOf(\"\\\"\", eq + 2)).trim();\n if (key.indexOf(\"runtype\") == -1) {\n if (prefix.startsWith(\"Metadata_V1.2\")) {\n prefix = \"\";\n }\n String effectiveKey = prefix + \" \" + pre + \" \" + key;\n if (!metadata.containsKey(effectiveKey)) {\n addMeta(effectiveKey, value);\n if (effectiveKey.endsWith(\"dTimeMSec value\")) {\n long v = (long) Double.parseDouble(value);\n if (!ts.contains(new Long(v))) {\n ts.add(new Long(v));\n }\n }\n else if (effectiveKey.endsWith(\"dZPos value\")) {\n long v = (long) Double.parseDouble(value);\n if (!zs.contains(new Long(v))) {\n zs.add(new Long(v));\n }\n }\n else if (effectiveKey.endsWith(\"uiComp value\")) {\n if (core.sizeC[0] == 0) {\n core.sizeC[0] = Integer.parseInt(value);\n }\n }\n else if (effectiveKey.endsWith(\"uiCount value\")) {\n if (core.sizeT[0] == 0) {\n core.sizeT[0] = Integer.parseInt(value);\n }\n }\n else if (effectiveKey.endsWith(\"TextInfoItem Text\")) {\n value = value.replaceAll(\" \", \"\\n\");\n StringTokenizer tokens = new StringTokenizer(value, \"\\n\");\n while (tokens.hasMoreTokens()) {\n String t = tokens.nextToken().trim();\n if (t.startsWith(\"Dimensions:\")) {\n t = t.substring(11);\n StringTokenizer dims = new StringTokenizer(t, \" x \");\n while (dims.hasMoreTokens()) {\n String dim = dims.nextToken().trim();\n int idx = dim.indexOf(\"(\");\n int v = Integer.parseInt(dim.substring(idx + 1,\n dim.indexOf(\")\", idx)));\n if (dim.startsWith(\"XY\")) {\n numSeries = v;\n if (numSeries > 1) {\n int x = core.sizeX[0];\n int y = core.sizeY[0];\n int z = core.sizeZ[0];\n int tSize = core.sizeT[0];\n int c = core.sizeC[0];\n core = new CoreMetadata(numSeries);\n Arrays.fill(core.sizeX, x);\n Arrays.fill(core.sizeY, y);\n Arrays.fill(core.sizeZ, z);\n Arrays.fill(core.sizeC, c);\n Arrays.fill(core.sizeT, tSize);\n }\n }\n else if (dim.startsWith(\"T\")) {\n Arrays.fill(core.sizeT, v);\n }\n else if (dim.startsWith(\"Z\")) {\n Arrays.fill(core.sizeZ, v);\n }\n else {\n Arrays.fill(core.sizeC, v);\n }\n }\n if (core.sizeZ[0] == 0) Arrays.fill(core.sizeZ, 1);\n if (core.sizeC[0] == 0) Arrays.fill(core.sizeC, 1);\n if (core.sizeT[0] == 0) Arrays.fill(core.sizeT, 1);\n int count =\n core.sizeZ[0] * core.sizeC[0] * core.sizeT[0];\n Arrays.fill(core.imageCount, count);\n Arrays.fill(core.currentOrder, \"XYCZT\");\n }\n }\n }\n }\n else {\n String v = (String) getMeta(effectiveKey);\n boolean parse = v != null;\n if (parse) {\n for (int i=0; i<v.length(); i++) {\n if (Character.isLetter(v.charAt(i)) ||\n Character.isWhitespace(v.charAt(i)))\n {\n parse = false;\n break;\n }\n }\n }\n if (parse) {\n addMeta(effectiveKey, value);\n }\n }\n }\n s = s.substring(s.indexOf(\"\\\"\", eq + 2) + 1);\n }\n }\n }\n }\n }\n b = null;\n xml = null;\n st = null;\n }\n status(\"Populating metadata\");\n if (core.imageCount[0] == 0) {\n core.sizeZ[0] = zs.size() == 0 ? 1 : zs.size();\n core.sizeT[0] = ts.size() == 0 ? 1 : ts.size();\n core.sizeC[0] = (vs.size() + 1) / (core.sizeT[0] * core.sizeZ[0]);\n core.imageCount[0] = vs.size();\n while (core.imageCount[0] % core.sizeC[0] != 0) core.imageCount[0]--;\n while (core.sizeC[0] * core.sizeZ[0] * core.sizeT[0] > core.imageCount[0])\n {\n if (core.sizeZ[0] < core.sizeT[0]) core.sizeT[0]--;\n else core.sizeZ[0]--;\n }\n }\n if (core.sizeC[0] * core.sizeZ[0] * core.sizeT[0] != core.imageCount[0]) {\n core.sizeZ[0] = zs.size();\n core.sizeT[0] = ts.size();\n core.imageCount[0] = core.sizeC[0] * core.sizeZ[0] * core.sizeT[0];\n }\n core.pixelType[0] = FormatTools.UINT8;\n offsets = new long[1][2];\n offsets[0][0] = ((Long) vs.get(0)).longValue();\n offsets[0][1] = ((Long) vs.get(1)).longValue();\n BufferedImage img = openImage(0);\n Arrays.fill(core.sizeX, img.getWidth());\n Arrays.fill(core.sizeY, img.getHeight());\n if (core.sizeC[0] == 0) core.sizeC[0] = 1;\n int c = img.getRaster().getNumBands() * core.sizeC[0];\n Arrays.fill(core.sizeC, c);\n Arrays.fill(core.rgb, img.getRaster().getNumBands() > 1);\n Arrays.fill(core.pixelType, ImageTools.getPixelType(img));\n if (vs.size() < core.imageCount[0]) {\n Arrays.fill(core.imageCount, vs.size());\n }\n if (numSeries == 0) numSeries = 1;\n offsets = new long[numSeries][core.imageCount[0]];\n for (int i=0; i<core.sizeZ[0]*core.sizeT[0]; i++) {\n for (int j=0; j<numSeries; j++) {\n for (int k=0; k<core.sizeC[0]; k++) {\n offsets[j][i*core.sizeC[0] + k] = ((Long) vs.remove(0)).longValue();\n }\n }\n }\n String pixX = (String)\n getMeta(\"CalibrationSeq _SEQUENCE_INDEX=\\\"0\\\" dCalibration value\");\n String pixZ = (String)\n getMeta(\"CalibrationSeq _SEQUENCE_INDEX=\\\"0\\\" dAspect value\");\n float pixSizeX = 0f;\n float pixSizeZ = 0f;\n if (pixX != null && pixX.length() > 0) {\n pixSizeX = Float.parseFloat(pixX.trim());\n }\n if (pixZ != null && pixZ.length() > 0) {\n pixSizeZ = Float.parseFloat(pixZ.trim());\n }\n Arrays.fill(core.interleaved, false);\n Arrays.fill(core.littleEndian, true);\n Arrays.fill(core.metadataComplete, true);\n MetadataStore store = getMetadataStore();\n FormatTools.populatePixels(store, this);\n for (int i=0; i<numSeries; i++) {\n Integer ii = new Integer(i);\n store.setImage(currentId, null, null, ii);\n store.setDimensions(new Float(pixSizeX), new Float(pixSizeX),\n new Float(pixSizeZ), null, null, ii);\n for (int j=0; j<core.sizeC[0]; j++) {\n store.setLogicalChannel(j, null, null, null, null, null, null, null,\n null, null, null, null, null, null, null, null, null, null, null,\n null, null, null, null, null, ii);\n }\n }\n String prefix = \"MetadataSeq _SEQUENCE_INDEX=\\\"0\\\" \";\n String gain = (String) getMeta(prefix + \"dGain value\");\n String voltage = (String) getMeta(prefix + \"dLampVoltage value\");\n String mag = (String) getMeta(prefix + \"dObjectiveMag value\");\n String na = (String) getMeta(prefix + \"dObjectiveNA value\");\n store.setDetector(null, null, null, null,\n gain == null ? null : new Float(gain),\n voltage == null ? null : new Float(voltage), null, null, null);\n store.setObjective(null, null, null, na == null ? null : new Float(na),\n mag == null ? null : new Float(mag), null, null);\n }\n", "output": " protected void initFile(String id) throws FormatException, IOException {\n if (debug) debug(\"ND2Reader.initFile(\" + id + \")\");\n if (noJ2k) throw new FormatException(NO_J2K_MSG);\n super.initFile(id);\n in = new RandomAccessStream(id);\n if (in.read() == -38 && in.read() == -50) {\n isJPEG = false;\n in.seek(0);\n in.order(true);\n byte[] b = new byte[1024 * 1024];\n while (in.getFilePointer() < in.length()) {\n if (in.read() == -38 && in.read() == -50 && in.read() == -66 &&\n in.read() == 10)\n {\n int len = in.readInt() + in.readInt();\n if (len > b.length) {\n int size = b.length + b.length;\n if (size < len) size = len;\n b = new byte[size];\n }\n in.skipBytes(4);\n if (debug) {\n debug(\"Reading chunk of size \" + len +\n \" at position \" + in.getFilePointer());\n }\n in.readFully(b, 0, len);\n if (len >= 12 && b[0] == 'I' && b[1] == 'm' && b[2] == 'a' &&\n b[3] == 'g' && b[4] == 'e' && b[5] == 'D' && b[6] == 'a' &&\n b[7] == 't' && b[8] == 'a' && b[9] == 'S' && b[10] == 'e' &&\n b[11] == 'q') \n {\n StringBuffer sb = new StringBuffer();\n int pt = 13;\n while (b[pt] != '!') {\n sb.append((char) b[pt]);\n pt++;\n }\n int ndx = Integer.parseInt(sb.toString());\n if (core.sizeC[0] == 0) {\n core.sizeC[0] = len / (core.sizeX[0] * core.sizeY[0] *\n FormatTools.getBytesPerPixel(core.pixelType[0]));\n }\n offsets[0][ndx] = in.getFilePointer() - len + sb.length() + 21;\n while (offsets[0][ndx] - in.getFilePointer() +\n len - 14 - sb.length() < 8)\n {\n offsets[0][ndx]++;\n }\n }\n else if (len >= 5 && b[0] == 'I' && b[1] == 'm' && b[2] == 'a' &&\n b[3] == 'g' && b[4] == 'e') \n {\n ND2Handler handler = new ND2Handler();\n int off = 0;\n for (int i=0; i<len; i++) {\n char c = (char) b[i];\n if (off == 0 && c == '!') off = i + 1;\n if (Character.isISOControl(c) || !Character.isDefined(c)) {\n b[i] = (byte) ' ';\n }\n }\n if (len - off >= 5 && b[off] == '<' && b[off + 1] == '?' &&\n b[off + 2] == 'x' && b[off + 3] == 'm' &&\n b[off + 4] == 'l') \n {\n ByteArrayInputStream s =\n new ByteArrayInputStream(b, off, len - off);\n try {\n SAXParser parser = SAX_FACTORY.newSAXParser();\n parser.parse(s, handler);\n }\n catch (ParserConfigurationException exc) {\n throw new FormatException(exc);\n }\n catch (SAXException exc) {\n throw new FormatException(exc);\n }\n }\n }\n if (core.imageCount[0] > 0 && offsets == null) {\n offsets = new long[1][core.imageCount[0]];\n }\n if (in.getFilePointer() < in.length() - 1) {\n if (in.read() != -38) in.skipBytes(15);\n else in.seek(in.getFilePointer() - 1);\n }\n }\n }\n if (core.sizeC[0] == 0) core.sizeC[0] = 1;\n core.currentOrder[0] = \"XYCZT\";\n core.rgb[0] = core.sizeC[0] > 1;\n if (core.sizeC[0] > 1 && adjustImageCount) {\n core.imageCount[0] /= 3;\n core.sizeT[0] /= 3;\n }\n core.littleEndian[0] = true;\n core.interleaved[0] = true;\n core.indexed[0] = false;\n core.falseColor[0] = false;\n core.metadataComplete[0] = true;\n MetadataStore store = getMetadataStore();\n store.setImage(currentId, null, null, null);\n FormatTools.populatePixels(store, this);\n for (int i=0; i<core.sizeC[0]; i++) {\n store.setLogicalChannel(i, null, null, null, null, null, null, null,\n null, null, null, null, null, null, null, null, null, null, null,\n null, null, null, null, null, null);\n }\n return;\n }\n else in.seek(0);\n isJPEG = true;\n status(\"Calculating image offsets\");\n Vector vs = new Vector();\n long pos = in.getFilePointer();\n boolean lastBoxFound = false;\n int length = 0;\n int box = 0;\n while (!lastBoxFound) {\n pos = in.getFilePointer();\n length = in.readInt();\n if (pos + length >= in.length() || length == 0) lastBoxFound = true;\n box = in.readInt();\n pos = in.getFilePointer();\n length -= 8;\n if (box == 0x6a703263) {\n vs.add(new Long(in.getFilePointer()));\n }\n if (!lastBoxFound) in.seek(pos + length);\n }\n status(\"Finding XML metadata\");\n in.seek(((Long) vs.get(vs.size() - 1)).longValue());\n boolean found = false;\n long off = -1;\n byte[] buf = new byte[2048];\n while (!found && in.getFilePointer() < in.length()) {\n int read = 0;\n if (in.getFilePointer() == ((Long) vs.get(vs.size() - 1)).longValue()) {\n read = in.read(buf);\n }\n else {\n System.arraycopy(buf, buf.length - 10, buf, 0, 10);\n read = in.read(buf, 10, buf.length - 10);\n }\n if (read == buf.length) read -= 10;\n for (int i=0; i<read+9; i++) {\n if (buf[i] == (byte) 0xff && buf[i+1] == (byte) 0xd9) {\n found = true;\n off = in.getFilePointer() - (read + 10) + i;\n i = buf.length;\n break;\n }\n }\n }\n buf = null;\n status(\"Parsing XML\");\n if (off > 0 && off < in.length() - 5) {\n in.seek(off + 5);\n byte[] b = new byte[(int) (in.length() - off - 5)];\n in.readFully(b);\n String xml = new String(b);\n xml = xml.substring(0, xml.lastIndexOf(\"</MetadataSeq>\") + 14);\n xml = xml.replaceAll(\"<!--*-->\", \"\");\n StringTokenizer st = new StringTokenizer(xml, \"\\r\\n\");\n while (st.hasMoreTokens()) {\n String token = st.nextToken().trim();\n if (token.indexOf(\"<\") != -1) {\n String prefix = token.substring(1, token.indexOf(\">\")).trim();\n token = token.substring(token.indexOf(\">\") + 1);\n while (token.indexOf(\"<\") != -1) {\n int start = token.indexOf(\"<\");\n String s = token.substring(start + 1, token.indexOf(\">\", start));\n token = token.substring(token.indexOf(\">\", start));\n if (s.indexOf(\" \") != -1) {\n String pre = s.substring(0, s.indexOf(\" \")).trim();\n s = s.substring(s.indexOf(\" \") + 1);\n while (s.indexOf(\"=\") != -1) {\n int eq = s.indexOf(\"=\");\n String key = s.substring(0, eq).trim();\n String value =\n s.substring(eq + 2, s.indexOf(\"\\\"\", eq + 2)).trim();\n if (key.indexOf(\"runtype\") == -1) {\n if (prefix.startsWith(\"Metadata_V1.2\")) {\n prefix = \"\";\n }\n String effectiveKey = prefix + \" \" + pre + \" \" + key;\n if (!metadata.containsKey(effectiveKey)) {\n addMeta(effectiveKey, value);\n if (effectiveKey.endsWith(\"dTimeMSec value\")) {\n long v = (long) Double.parseDouble(value);\n if (!ts.contains(new Long(v))) {\n ts.add(new Long(v));\n }\n }\n else if (effectiveKey.endsWith(\"dZPos value\")) {\n long v = (long) Double.parseDouble(value);\n if (!zs.contains(new Long(v))) {\n zs.add(new Long(v));\n }\n }\n else if (effectiveKey.endsWith(\"uiComp value\")) {\n if (core.sizeC[0] == 0) {\n core.sizeC[0] = Integer.parseInt(value);\n }\n }\n else if (effectiveKey.endsWith(\"uiCount value\")) {\n if (core.sizeT[0] == 0) {\n core.sizeT[0] = Integer.parseInt(value);\n }\n }\n else if (effectiveKey.endsWith(\"TextInfoItem Text\")) {\n value = value.replaceAll(\" \", \"\\n\");\n StringTokenizer tokens = new StringTokenizer(value, \"\\n\");\n while (tokens.hasMoreTokens()) {\n String t = tokens.nextToken().trim();\n if (t.startsWith(\"Dimensions:\")) {\n t = t.substring(11);\n StringTokenizer dims = new StringTokenizer(t, \" x \");\n while (dims.hasMoreTokens()) {\n String dim = dims.nextToken().trim();\n int idx = dim.indexOf(\"(\");\n int v = Integer.parseInt(dim.substring(idx + 1,\n dim.indexOf(\")\", idx)));\n if (dim.startsWith(\"XY\")) {\n numSeries = v;\n if (numSeries > 1) {\n int x = core.sizeX[0];\n int y = core.sizeY[0];\n int z = core.sizeZ[0];\n int tSize = core.sizeT[0];\n int c = core.sizeC[0];\n core = new CoreMetadata(numSeries);\n Arrays.fill(core.sizeX, x);\n Arrays.fill(core.sizeY, y);\n Arrays.fill(core.sizeZ, z);\n Arrays.fill(core.sizeC, c);\n Arrays.fill(core.sizeT, tSize);\n }\n }\n else if (dim.startsWith(\"T\")) {\n Arrays.fill(core.sizeT, v);\n }\n else if (dim.startsWith(\"Z\")) {\n Arrays.fill(core.sizeZ, v);\n }\n else {\n Arrays.fill(core.sizeC, v);\n }\n }\n if (core.sizeZ[0] == 0) Arrays.fill(core.sizeZ, 1);\n if (core.sizeC[0] == 0) Arrays.fill(core.sizeC, 1);\n if (core.sizeT[0] == 0) Arrays.fill(core.sizeT, 1);\n int count =\n core.sizeZ[0] * core.sizeC[0] * core.sizeT[0];\n Arrays.fill(core.imageCount, count);\n Arrays.fill(core.currentOrder, \"XYCZT\");\n }\n }\n }\n }\n else {\n String v = (String) getMeta(effectiveKey);\n boolean parse = v != null;\n if (parse) {\n for (int i=0; i<v.length(); i++) {\n if (Character.isLetter(v.charAt(i)) ||\n Character.isWhitespace(v.charAt(i)))\n {\n parse = false;\n break;\n }\n }\n }\n if (parse) {\n addMeta(effectiveKey, value);\n }\n }\n }\n s = s.substring(s.indexOf(\"\\\"\", eq + 2) + 1);\n }\n }\n }\n }\n }\n b = null;\n xml = null;\n st = null;\n }\n status(\"Populating metadata\");\n if (core.imageCount[0] == 0) {\n core.sizeZ[0] = zs.size() == 0 ? 1 : zs.size();\n core.sizeT[0] = ts.size() == 0 ? 1 : ts.size();\n core.sizeC[0] = (vs.size() + 1) / (core.sizeT[0] * core.sizeZ[0]);\n core.imageCount[0] = vs.size();\n while (core.imageCount[0] % core.sizeC[0] != 0) core.imageCount[0]--;\n while (core.sizeC[0] * core.sizeZ[0] * core.sizeT[0] > core.imageCount[0])\n {\n if (core.sizeZ[0] < core.sizeT[0]) core.sizeT[0]--;\n else core.sizeZ[0]--;\n }\n }\n if (core.sizeC[0] * core.sizeZ[0] * core.sizeT[0] != core.imageCount[0]) {\n core.sizeZ[0] = zs.size();\n core.sizeT[0] = ts.size();\n core.imageCount[0] = core.sizeC[0] * core.sizeZ[0] * core.sizeT[0];\n }\n core.pixelType[0] = FormatTools.UINT8;\n offsets = new long[1][2];\n offsets[0][0] = ((Long) vs.get(0)).longValue();\n offsets[0][1] = ((Long) vs.get(1)).longValue();\n BufferedImage img = openImage(0);\n Arrays.fill(core.sizeX, img.getWidth());\n Arrays.fill(core.sizeY, img.getHeight());\n if (core.sizeC[0] == 0) core.sizeC[0] = 1;\n int c = img.getRaster().getNumBands() * core.sizeC[0];\n Arrays.fill(core.sizeC, c);\n Arrays.fill(core.rgb, img.getRaster().getNumBands() > 1);\n Arrays.fill(core.pixelType, ImageTools.getPixelType(img));\n if (vs.size() < core.imageCount[0]) {\n Arrays.fill(core.imageCount, vs.size());\n }\n if (numSeries == 0) numSeries = 1;\n offsets = new long[numSeries][core.imageCount[0]];\n for (int i=0; i<core.sizeZ[0]*core.sizeT[0]; i++) {\n for (int j=0; j<numSeries; j++) {\n for (int k=0; k<core.sizeC[0]; k++) {\n offsets[j][i*core.sizeC[0] + k] = ((Long) vs.remove(0)).longValue();\n }\n }\n }\n String pixX = (String)\n getMeta(\"CalibrationSeq _SEQUENCE_INDEX=\\\"0\\\" dCalibration value\");\n String pixZ = (String)\n getMeta(\"CalibrationSeq _SEQUENCE_INDEX=\\\"0\\\" dAspect value\");\n float pixSizeX = 0f;\n float pixSizeZ = 0f;\n if (pixX != null && pixX.length() > 0) {\n pixSizeX = Float.parseFloat(pixX.trim());\n }\n if (pixZ != null && pixZ.length() > 0) {\n pixSizeZ = Float.parseFloat(pixZ.trim());\n }\n Arrays.fill(core.interleaved, false);\n Arrays.fill(core.littleEndian, false);\n Arrays.fill(core.metadataComplete, true);\n MetadataStore store = getMetadataStore();\n FormatTools.populatePixels(store, this);\n for (int i=0; i<numSeries; i++) {\n Integer ii = new Integer(i);\n store.setImage(currentId, null, null, ii);\n store.setDimensions(new Float(pixSizeX), new Float(pixSizeX),\n new Float(pixSizeZ), null, null, ii);\n for (int j=0; j<core.sizeC[0]; j++) {\n store.setLogicalChannel(j, null, null, null, null, null, null, null,\n null, null, null, null, null, null, null, null, null, null, null,\n null, null, null, null, null, ii);\n }\n }\n String prefix = \"MetadataSeq _SEQUENCE_INDEX=\\\"0\\\" \";\n String gain = (String) getMeta(prefix + \"dGain value\");\n String voltage = (String) getMeta(prefix + \"dLampVoltage value\");\n String mag = (String) getMeta(prefix + \"dObjectiveMag value\");\n String na = (String) getMeta(prefix + \"dObjectiveNA value\");\n store.setDetector(null, null, null, null,\n gain == null ? null : new Float(gain),\n voltage == null ? null : new Float(voltage), null, null, null);\n store.setObjective(null, null, null, na == null ? null : new Float(na),\n mag == null ? null : new Float(mag), null, null);\n }\n"} {"input": " public void done(IJobChangeEvent event) {\n IStatus result = event.getResult();\n if(result.getSeverity() == IStatus.CANCEL) {\n return;\n } else if(!result.isOK()) {\n return;\n }\n if(projects.isEmpty()) {\n log.info(\"No Maven projects to import\");\n if(collectedLocations.size()==1) {\n final String location = collectedLocations.get(0);\n DirectoryScanner projectScanner = new DirectoryScanner();\n projectScanner.setBasedir(location);\n projectScanner.setIncludes(new String[] {\"**/.project\"}); \n projectScanner.scan();\n String[] projectFiles = projectScanner.getIncludedFiles();\n if(projectFiles!=null && projectFiles.length>0) {\n PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n public void run() {\n boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), \n Messages.MavenProjectCheckoutJob_confirm_title, \n Messages.MavenProjectCheckoutJob_confirm_message);\n if(res) {\n IWizard wizard = new ExternalProjectImportWizard(collectedLocations.get(0));\n WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),\n wizard);\n dialog.open();\n } else {\n cleanup(collectedLocations);\n }\n }\n });\n return;\n }\n PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {\n public void run() {\n boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), \n Messages.MavenProjectCheckoutJob_confirm2_title, \n Messages.MavenProjectCheckoutJob_confirm2_message);\n if(res) {\n Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());\n clipboard.setContents(new Object[] { location }, new Transfer[] { TextTransfer.getInstance() });\n NewProjectAction newProjectAction = new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow());\n newProjectAction.run();\n } else {\n cleanup(collectedLocations);\n }\n }\n });\n return;\n }\n cleanup(collectedLocations);\n }\n if(checkoutAllProjects) {\n if(M2EUIPluginActivator.getDefault().getMavenDiscovery() != null) {\n final LifecycleMappingConfiguration mappingConfiguration = LifecycleMappingConfiguration.calculate(projects,\n configuration, new NullProgressMonitor());\n if(!mappingConfiguration.isMappingComplete()) {\n PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n public void run() {\n MavenImportWizard wizard = new MavenImportWizard(configuration, collectedLocations,\n mappingConfiguration);\n WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);\n int res = dialog.open();\n if(res == Window.CANCEL) {\n cleanup(collectedLocations);\n }\n }\n });\n return;\n }\n }\n WorkspaceJob job = new AbstactCreateMavenProjectJob(Messages.MavenProjectCheckoutJob_job, workingSets) {\n @Override\n protected List<IProject> doCreateMavenProjects(IProgressMonitor monitor) throws CoreException {\n Set<MavenProjectInfo> projectSet = MavenPlugin.getProjectConfigurationManager().collectProjects(projects);\n List<IMavenProjectImportResult> results = MavenPlugin.getProjectConfigurationManager().importProjects(\n projectSet, configuration, monitor);\n return toProjects(results);\n }\n };\n ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory()\n .modifyRule(ResourcesPlugin.getWorkspace().getRoot());\n job.setRule(rule);\n job.schedule();\n } else {\n PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n public void run() {\n MavenImportWizard wizard = new MavenImportWizard(configuration, collectedLocations);\n WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);\n int res = dialog.open();\n if(res == Window.CANCEL) {\n cleanup(collectedLocations);\n }\n }\n });\n }\n }\n", "output": " public void done(IJobChangeEvent event) {\n IStatus result = event.getResult();\n if(result.getSeverity() == IStatus.CANCEL) {\n return;\n } else if(!result.isOK()) {\n return;\n }\n if(projects.isEmpty()) {\n log.info(\"No Maven projects to import\");\n if(collectedLocations.size()==1) {\n final String location = collectedLocations.get(0);\n DirectoryScanner projectScanner = new DirectoryScanner();\n projectScanner.setBasedir(location);\n projectScanner.setIncludes(new String[] {\"**/.project\"}); \n projectScanner.scan();\n String[] projectFiles = projectScanner.getIncludedFiles();\n if(projectFiles!=null && projectFiles.length>0) {\n PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n public void run() {\n boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), \n Messages.MavenProjectCheckoutJob_confirm_title, \n Messages.MavenProjectCheckoutJob_confirm_message);\n if(res) {\n IWizard wizard = new ExternalProjectImportWizard(collectedLocations.get(0));\n WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),\n wizard);\n dialog.open();\n } else {\n cleanup(collectedLocations);\n }\n }\n });\n return;\n }\n PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {\n public void run() {\n boolean res = MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), \n Messages.MavenProjectCheckoutJob_confirm2_title, \n Messages.MavenProjectCheckoutJob_confirm2_message);\n if(res) {\n Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());\n clipboard.setContents(new Object[] { location }, new Transfer[] { TextTransfer.getInstance() });\n NewProjectAction newProjectAction = new NewProjectAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow());\n newProjectAction.run();\n } else {\n cleanup(collectedLocations);\n }\n }\n });\n return;\n }\n cleanup(collectedLocations);\n }\n if(checkoutAllProjects) {\n if(M2EUIPluginActivator.getDefault().getMavenDiscovery() != null) {\n final LifecycleMappingConfiguration mappingConfiguration = LifecycleMappingConfiguration.calculate(projects,\n configuration, new NullProgressMonitor());\n if(!mappingConfiguration.isMappingComplete(true)) {\n PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n public void run() {\n MavenImportWizard wizard = new MavenImportWizard(configuration, collectedLocations,\n mappingConfiguration);\n WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);\n int res = dialog.open();\n if(res == Window.CANCEL) {\n cleanup(collectedLocations);\n }\n }\n });\n return;\n }\n }\n WorkspaceJob job = new AbstactCreateMavenProjectJob(Messages.MavenProjectCheckoutJob_job, workingSets) {\n @Override\n protected List<IProject> doCreateMavenProjects(IProgressMonitor monitor) throws CoreException {\n Set<MavenProjectInfo> projectSet = MavenPlugin.getProjectConfigurationManager().collectProjects(projects);\n List<IMavenProjectImportResult> results = MavenPlugin.getProjectConfigurationManager().importProjects(\n projectSet, configuration, monitor);\n return toProjects(results);\n }\n };\n ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory()\n .modifyRule(ResourcesPlugin.getWorkspace().getRoot());\n job.setRule(rule);\n job.schedule();\n } else {\n PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n public void run() {\n MavenImportWizard wizard = new MavenImportWizard(configuration, collectedLocations);\n WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);\n int res = dialog.open();\n if(res == Window.CANCEL) {\n cleanup(collectedLocations);\n }\n }\n });\n }\n }\n"} {"input": "\tpublic void onBlockBreak(BlockBreakEvent e)\n\t{\n\t\tif (plugin.debug == true)\n\t\t{\n\t\t\tplugin.log.info(\"BLOCK_BREAK_EVENT: playerName=\"+e.getPlayer().getName()+\",typeID=\"+e.getBlock().getTypeId());\n\t\t}\n\t\tplugin.logger.LogBlockBreak(e, e.getBlock().getTypeId());\n\t\tlong timeStart = System.nanoTime();\n\t\tPlayer p = e.getPlayer();\n\t\tif (plugin.arena.IsArena(p.getLocation()))\n\t\t{\n\t\t\tif (GameMasterHandler.IsAtleastRank(p.getName(), Rank.BUILDER))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tp.sendMessage(ChatColor.BLUE+\"[ARENA]: \"+ChatColor.WHITE+\"V arene nemuzes kopat!\");\n\t\t\te.setCancelled(true);\n\t\t\treturn;\n\t\t}\n\t\tif(plugin.EventWorld.IsEventWorld(p.getLocation())&& GugaEventWorld.regionStatus())\n\t\t{\n\t\t\tif (GameMasterHandler.IsAtleastRank(p.getName(), Rank.EVENTER))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tp.sendMessage(ChatColor.BLUE+\"[EVENTWORLD]: \"+ChatColor.WHITE+\"V EventWorldu nemuzes kopat!\");\n\t\t\te.setCancelled(true);\n\t\t\treturn;\n\t\t}\n\t\tif (!GugaRegionHandler.CanInteract(p, e.getBlock().getX(), e.getBlock().getZ()))\n\t\t{\n\t\t\tif (!GameMasterHandler.IsAtleastRank(p.getName(), Rank.BUILDER))\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tGugaRegion region = GugaRegionHandler.GetRegionByCoords(e.getBlock().getX(), e.getBlock().getZ());\n\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[REGIONS]: \"+\"Tady nemuzes kopat! Nazev pozemku: \" + region.GetName());\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (!plugin.acc.UserIsLogged(p) && plugin.config.accountsModule)\n\t\t{\n\t\t\te.setCancelled(true);\n\t\t\tp.sendMessage(\"******************************\");\n\t\t\tif (plugin.acc.UserIsRegistered(p))\n\t\t\t{\n\t\t\t\tp.sendMessage(\"NEJSTE PRIHLASEN! Prihlaste se pomoci /login heslo\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tp.sendMessage(\"NEJSTE ZAREGISTROVAN! Prosim zaregistrujte se /register heslo\");\n\t\t\t}\n\t\t\tp.sendMessage(\"******************************\");\n\t\t\treturn;\n\t\t}\n\t\tGugaProfession prof = plugin.professions.get(p.getName());\n\t\tboolean canBreak = false;\n\t\tBlock targetBlock;\n\t\ttargetBlock = e.getBlock();\n\t\tif (prof == null)\n\t\t{\n\t\t\tint i = 0;\n\t\t\twhile (i < allowedBlocksTier1.length)\n\t\t\t{\n\t\t\t\tif (e.getBlock().getTypeId() == allowedBlocksTier1[i])\n\t\t\t\t{\n\t\t\t\t\tcanBreak = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (canBreak)\n\t\t\t{\n\t\t\t\tBlock blockAbove = targetBlock.getRelative(BlockFace.UP);\n\t\t\t\tif (blockAbove.getTypeId() == 55)\n\t\t\t\t{\n\t\t\t\t\tcanBreak = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (GameMasterHandler.IsAtleastGM(p.getName()))\n\t\t\t{\n\t\t\t\tif(plugin.acc.UserIsLogged(p))\n\t\t\t\t{\n\t\t\t\t\tcanBreak = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!canBreak)\n\t\t\t{\n\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Musite byt alespon level 5, aby jste mohl kopat tento druh bloku!\");\n\t\t\t\te.setCancelled(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint level = prof.GetLevel();\n\t\t\tif (level < 5)\n\t\t\t{\n\t\t\t\tint i = 0;\n\t\t\t\twhile (i < allowedBlocksTier1.length)\n\t\t\t\t{\n\t\t\t\t\tif (e.getBlock().getTypeId() == allowedBlocksTier1[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tcanBreak = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tif (canBreak)\n\t\t\t\t{\n\t\t\t\t\tBlock blockAbove = targetBlock.getRelative(BlockFace.UP);\n\t\t\t\t\tif (blockAbove.getTypeId() == 55)\n\t\t\t\t\t{\n\t\t\t\t\t\tcanBreak = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (GameMasterHandler.IsAtleastGM(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tif(plugin.acc.UserIsLogged(p))\n\t\t\t\t\t{\n\t\t\t\t\t\tcanBreak = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!canBreak)\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Musite byt alespon level 5, aby jste mohl kopat tento druh bloku!\");\n\t\t\t\t\te.setCancelled(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString chestOwner;\n\t\tint blockType = targetBlock.getTypeId();\n\t\tif (blockType == ID_CHEST)\n\t\t{\n\t\t\tchestOwner = plugin.chests.GetBlockOwner(targetBlock);\n\t\t\tif(chestOwner.matches(\"notFound\"))\n\t\t\t{\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tif (chestOwner.matches(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou truhlu! Nejdrive ji odemknete.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou truhlu! \" + chestOwner + \" je vlastnikem teto truhly.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(blockType==ID_DISPENSER)\n\t\t{\n\t\t\tchestOwner = plugin.dispensers.GetBlockOwner(targetBlock);\n\t\t\tif(chestOwner.matches(\"notFound\"))\n\t\t\t{\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tif (chestOwner.matches(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamceny davkovac! Nejdrive jej odemknete.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamceny davkovac! \" + chestOwner + \" je vlastnikem tohoto davkovace.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(blockType==ID_FURNANCE || blockType==ID_FURNANCE_BURNING)\n\t\t{\n\t\t\tchestOwner = plugin.furnances.GetBlockOwner(targetBlock);\n\t\t\tif(chestOwner.matches(\"notFound\"))\n\t\t\t{\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tif (chestOwner.matches(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou pec! Nejdrive ji odemknete.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou pec! \" + chestOwner + \" je vlastnikem teto pece.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tint typeId = targetBlock.getTypeId();\n\t\t\tif (!IsInstaBreakBlock(typeId))\n\t\t\t{\n\t\t\t\tprof.GainExperience(3);\n\t\t\t}\n\t\t\tif (typeId == 1)\n\t\t\t{\n\t\t\t\tGugaBonusDrop bonus = prof.CobbleStoneDrop();\n\t\t\t\tif (bonus == GugaBonusDrop.DIAMOND)\n\t\t\t\t{\n\t\t\t\t\tp.getWorld().dropItem(targetBlock.getLocation(), new ItemStack(264,1));\n\t\t\t\t\tprof.GainExperience(50);\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Nasel jste diamant!\");\n\t\t\t\t}\n\t\t\t\telse if (bonus == GugaBonusDrop.GOLD)\n\t\t\t\t{\n\t\t\t\t\tp.getWorld().dropItem(targetBlock.getLocation(), new ItemStack(14,1));\n\t\t\t\t\tprof.GainExperience(40);\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Nasel jste zlato!\");\n\t\t\t\t}\n\t\t\t\telse if (bonus == GugaBonusDrop.IRON)\n\t\t\t\t{\n\t\t\t\t\tp.getWorld().dropItem(targetBlock.getLocation(), new ItemStack(15,1));\n\t\t\t\t\tprof.GainExperience(30);\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Nasel jste zelezo!\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t", "output": "\tpublic void onBlockBreak(BlockBreakEvent e)\n\t{\n\t\tif (plugin.debug == true)\n\t\t{\n\t\t\tplugin.log.info(\"BLOCK_BREAK_EVENT: playerName=\"+e.getPlayer().getName()+\",typeID=\"+e.getBlock().getTypeId());\n\t\t}\n\t\tif(e.getPlayer().getItemInHand().getTypeId() == 271)\n\t\t{\n\t\t\te.setCancelled(true);\n\t\t\treturn;\n\t\t}\n\t\tplugin.logger.LogBlockBreak(e, e.getBlock().getTypeId());\n\t\tlong timeStart = System.nanoTime();\n\t\tPlayer p = e.getPlayer();\n\t\tif (plugin.arena.IsArena(p.getLocation()))\n\t\t{\n\t\t\tif (GameMasterHandler.IsAtleastRank(p.getName(), Rank.BUILDER))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tp.sendMessage(ChatColor.BLUE+\"[ARENA]: \"+ChatColor.WHITE+\"V arene nemuzes kopat!\");\n\t\t\te.setCancelled(true);\n\t\t\treturn;\n\t\t}\n\t\tif(plugin.EventWorld.IsEventWorld(p.getLocation())&& GugaEventWorld.regionStatus())\n\t\t{\n\t\t\tif (GameMasterHandler.IsAtleastRank(p.getName(), Rank.EVENTER))\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tp.sendMessage(ChatColor.BLUE+\"[EVENTWORLD]: \"+ChatColor.WHITE+\"V EventWorldu nemuzes kopat!\");\n\t\t\te.setCancelled(true);\n\t\t\treturn;\n\t\t}\n\t\tif (!GugaRegionHandler.CanInteract(p, e.getBlock().getX(), e.getBlock().getZ()))\n\t\t{\n\t\t\tif (!GameMasterHandler.IsAtleastRank(p.getName(), Rank.BUILDER))\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tGugaRegion region = GugaRegionHandler.GetRegionByCoords(e.getBlock().getX(), e.getBlock().getZ());\n\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[REGIONS]: \"+\"Tady nemuzes kopat! Nazev pozemku: \" + region.GetName());\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (!plugin.acc.UserIsLogged(p) && plugin.config.accountsModule)\n\t\t{\n\t\t\te.setCancelled(true);\n\t\t\tp.sendMessage(\"******************************\");\n\t\t\tif (plugin.acc.UserIsRegistered(p))\n\t\t\t{\n\t\t\t\tp.sendMessage(\"NEJSTE PRIHLASEN! Prihlaste se pomoci /login heslo\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tp.sendMessage(\"NEJSTE ZAREGISTROVAN! Prosim zaregistrujte se /register heslo\");\n\t\t\t}\n\t\t\tp.sendMessage(\"******************************\");\n\t\t\treturn;\n\t\t}\n\t\tGugaProfession prof = plugin.professions.get(p.getName());\n\t\tboolean canBreak = false;\n\t\tBlock targetBlock;\n\t\ttargetBlock = e.getBlock();\n\t\tif (prof == null)\n\t\t{\n\t\t\tint i = 0;\n\t\t\twhile (i < allowedBlocksTier1.length)\n\t\t\t{\n\t\t\t\tif (e.getBlock().getTypeId() == allowedBlocksTier1[i])\n\t\t\t\t{\n\t\t\t\t\tcanBreak = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tif (canBreak)\n\t\t\t{\n\t\t\t\tBlock blockAbove = targetBlock.getRelative(BlockFace.UP);\n\t\t\t\tif (blockAbove.getTypeId() == 55)\n\t\t\t\t{\n\t\t\t\t\tcanBreak = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (GameMasterHandler.IsAtleastGM(p.getName()))\n\t\t\t{\n\t\t\t\tif(plugin.acc.UserIsLogged(p))\n\t\t\t\t{\n\t\t\t\t\tcanBreak = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!canBreak)\n\t\t\t{\n\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Musite byt alespon level 5, aby jste mohl kopat tento druh bloku!\");\n\t\t\t\te.setCancelled(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint level = prof.GetLevel();\n\t\t\tif (level < 5)\n\t\t\t{\n\t\t\t\tint i = 0;\n\t\t\t\twhile (i < allowedBlocksTier1.length)\n\t\t\t\t{\n\t\t\t\t\tif (e.getBlock().getTypeId() == allowedBlocksTier1[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tcanBreak = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tif (canBreak)\n\t\t\t\t{\n\t\t\t\t\tBlock blockAbove = targetBlock.getRelative(BlockFace.UP);\n\t\t\t\t\tif (blockAbove.getTypeId() == 55)\n\t\t\t\t\t{\n\t\t\t\t\t\tcanBreak = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (GameMasterHandler.IsAtleastGM(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tif(plugin.acc.UserIsLogged(p))\n\t\t\t\t\t{\n\t\t\t\t\t\tcanBreak = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!canBreak)\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Musite byt alespon level 5, aby jste mohl kopat tento druh bloku!\");\n\t\t\t\t\te.setCancelled(true);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString chestOwner;\n\t\tint blockType = targetBlock.getTypeId();\n\t\tif (blockType == ID_CHEST)\n\t\t{\n\t\t\tchestOwner = plugin.chests.GetBlockOwner(targetBlock);\n\t\t\tif(chestOwner.matches(\"notFound\"))\n\t\t\t{\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tif (chestOwner.matches(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou truhlu! Nejdrive ji odemknete.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou truhlu! \" + chestOwner + \" je vlastnikem teto truhly.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(blockType==ID_DISPENSER)\n\t\t{\n\t\t\tchestOwner = plugin.dispensers.GetBlockOwner(targetBlock);\n\t\t\tif(chestOwner.matches(\"notFound\"))\n\t\t\t{\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tif (chestOwner.matches(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamceny davkovac! Nejdrive jej odemknete.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamceny davkovac! \" + chestOwner + \" je vlastnikem tohoto davkovace.\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(blockType==ID_FURNANCE || blockType==ID_FURNANCE_BURNING)\n\t\t{\n\t\t\tchestOwner = plugin.furnances.GetBlockOwner(targetBlock);\n\t\t\tif(chestOwner.matches(\"notFound\"))\n\t\t\t{\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te.setCancelled(true);\n\t\t\t\tif (chestOwner.matches(p.getName()))\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou pec! Nejdrive ji odemknete.\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[LOCKER]:\"+ChatColor.WHITE+\" Nemuzete rozbit zamcenou pec! \" + chestOwner + \" je vlastnikem teto pece.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tint typeId = targetBlock.getTypeId();\n\t\t\tif (!IsInstaBreakBlock(typeId))\n\t\t\t{\n\t\t\t\tprof.GainExperience(3);\n\t\t\t}\n\t\t\tif (typeId == 1)\n\t\t\t{\n\t\t\t\tGugaBonusDrop bonus = prof.CobbleStoneDrop();\n\t\t\t\tif (bonus == GugaBonusDrop.DIAMOND)\n\t\t\t\t{\n\t\t\t\t\tp.getWorld().dropItem(targetBlock.getLocation(), new ItemStack(264,1));\n\t\t\t\t\tprof.GainExperience(50);\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Nasel jste diamant!\");\n\t\t\t\t}\n\t\t\t\telse if (bonus == GugaBonusDrop.GOLD)\n\t\t\t\t{\n\t\t\t\t\tp.getWorld().dropItem(targetBlock.getLocation(), new ItemStack(14,1));\n\t\t\t\t\tprof.GainExperience(40);\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Nasel jste zlato!\");\n\t\t\t\t}\n\t\t\t\telse if (bonus == GugaBonusDrop.IRON)\n\t\t\t\t{\n\t\t\t\t\tp.getWorld().dropItem(targetBlock.getLocation(), new ItemStack(15,1));\n\t\t\t\t\tprof.GainExperience(30);\n\t\t\t\t\tp.sendMessage(ChatColor.BLUE+\"[RPG]: \"+ChatColor.WHITE+\"Nasel jste zelezo!\");\n\t\t\t\t}\n\t\t\t}\n\t\t\t"} {"input": " private void safelyWriteObject(JsonGenerator generator, Object value) throws IOException {\n if (value != null && value.getClass().isArray()) {\n value = Arrays.asList((Object[]) value);\n }\n if (value instanceof Iterable) {\n generator.writeStartArray();\n for (Object subValue : (Iterable<?>) value) {\n safelyWriteObject(generator, subValue);\n }\n generator.writeEndArray();\n } else if (value instanceof Map) {\n generator.writeStartObject();\n for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {\n if (entry.getKey() == null)\n generator.writeFieldName(\"null\");\n else\n generator.writeFieldName(entry.getKey().toString());\n safelyWriteObject(generator, entry.getValue());\n }\n generator.writeEndObject();\n } else if (value == null) {\n generator.writeNull();\n } else {\n try {\n generator.writeObject(value);\n } catch (IllegalStateException e) {\n logger.debug(\"Couldn't marshal '{}' of type '{}', had to be converted into a String\", value, value.getClass());\n generator.writeString(value.toString());\n }\n }\n }\n", "output": " private void safelyWriteObject(JsonGenerator generator, Object value) throws IOException {\n if (value != null && value.getClass().isArray()) {\n value = Arrays.asList((Object[]) value);\n }\n if (value instanceof Iterable) {\n generator.writeStartArray();\n for (Object subValue : (Iterable<?>) value) {\n safelyWriteObject(generator, subValue);\n }\n generator.writeEndArray();\n } else if (value instanceof Map) {\n generator.writeStartObject();\n for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {\n if (entry.getKey() == null)\n generator.writeFieldName(\"null\");\n else\n generator.writeFieldName(entry.getKey().toString());\n safelyWriteObject(generator, entry.getValue());\n }\n generator.writeEndObject();\n } else if (value == null) {\n generator.writeNull();\n } else {\n try {\n generator.writeObject(value);\n } catch (IllegalStateException e) {\n logger.debug(\"Couldn't marshal '{}' of type '{}', had to be converted into a String\",\n value, value.getClass());\n generator.writeString(value.toString());\n }\n }\n }\n"} {"input": " protected void doInvite(SipServletRequest invite) throws ServletException,\n IOException {\n log(\"doInvite\");\n invite.createResponse(SipServletResponse.SC_RINGING).send();\n ServletContext servletContext = getServletContext();\n SdpParser sdpParser = (SdpParser)servletContext.getAttribute(\n SdpParser.class.getName());\n Charset charset = Charset.forName(\"UTF-8\");\n Object contentObject = invite.getContent();\n String sdp;\n if (contentObject instanceof String)\n sdp = (String)contentObject;\n else\n {\n byte[] content = (byte[])contentObject;\n sdp = new String(content, charset);\n }\n RtpConnection rtpConnection = sdpParser.getRtpConnection(sdp);\n if (rtpConnection == null)\n {\n invite.createResponse(SipServletResponse.SC_NOT_ACCEPTABLE).send();\n return;\n }\n int audioPayloadType;\n List<Integer> payloadTypes = rtpConnection.getPayloadTypes();\n if (payloadTypes.contains(0))\n audioPayloadType = 0;\n else if (payloadTypes.contains(8))\n audioPayloadType = 8;\n else\n {\n invite.createResponse(SipServletResponse.SC_NOT_ACCEPTABLE).send();\n return;\n }\n if (!payloadTypes.contains(DTMF_PAYLOAD_TYPE))\n {\n invite.createResponse(SipServletResponse.SC_NOT_ACCEPTABLE).send();\n return;\n }\n int port = rtpConnection.getPort();\n DtmfSession dtmfSession = new DtmfSession(DTMF_PAYLOAD_TYPE,\n rtpConnection.getHost(), port, audioPayloadType);\n try\n {\n dtmfSession.init();\n }\n catch (Exception e)\n {\n Log.warn(\"cannot initialize dtmf session on port \" + port, e);\n SipServletResponse resp = invite.createResponse(\n SipServletResponse.SC_SERVER_INTERNAL_ERROR);\n resp.send();\n return;\n }\n invite.getApplicationSession(true).setAttribute(\n DtmfSession.class.getName(), dtmfSession);\n SipServletResponse resp =\n invite.createResponse(SipServletResponse.SC_OK);\n String sdpAnswer = \"v=0\\r\\n\"\n + \"o=user1 123 456 IN IP4 192.168.2.149\\r\\n\"\n + \"s=-\\r\\n\"\n + \"c=IN IP4 192.168.2.149\\r\\n\"\n + \"t=0 0\\r\\n\"\n + \"m=audio \" + dtmfSession.getLocalPort() + \" RTP/AVP \"\n + audioPayloadType + \" \" + DTMF_PAYLOAD_TYPE + \"\\r\\n\"\n + \"a=rtpmap:0 PCMU/8000\\r\\n\"\n + \"a=rtpmap:\" + DTMF_PAYLOAD_TYPE + \" telephone-event/8000\\r\\n\"\n + \"a=fmtp:\" + DTMF_PAYLOAD_TYPE + \" 0-15\\r\\n\";\n resp.setContent(sdpAnswer.getBytes(charset), \"application/sdp\");\n resp.send();\n }\n", "output": " protected void doInvite(SipServletRequest invite) throws ServletException,\n IOException {\n log(\"doInvite\");\n invite.createResponse(SipServletResponse.SC_RINGING).send();\n ServletContext servletContext = getServletContext();\n SdpParser sdpParser = (SdpParser)servletContext.getAttribute(\n SdpParser.class.getName());\n Charset charset = Charset.forName(\"UTF-8\");\n Object contentObject = invite.getContent();\n String sdp;\n if (contentObject instanceof String)\n sdp = (String)contentObject;\n else\n {\n byte[] content = (byte[])contentObject;\n sdp = new String(content, charset);\n }\n RtpConnection rtpConnection = sdpParser.getRtpConnection(sdp);\n if (rtpConnection == null)\n {\n invite.createResponse(SipServletResponse.SC_NOT_ACCEPTABLE).send();\n return;\n }\n int audioPayloadType;\n List<Integer> payloadTypes = rtpConnection.getPayloadTypes();\n if (payloadTypes.contains(0))\n audioPayloadType = 0;\n else if (payloadTypes.contains(8))\n audioPayloadType = 8;\n else\n {\n invite.createResponse(SipServletResponse.SC_NOT_ACCEPTABLE).send();\n return;\n }\n if (!payloadTypes.contains(DTMF_PAYLOAD_TYPE))\n {\n invite.createResponse(SipServletResponse.SC_NOT_ACCEPTABLE).send();\n return;\n }\n int port = rtpConnection.getPort();\n DtmfSession dtmfSession = new DtmfSession(DTMF_PAYLOAD_TYPE,\n rtpConnection.getHost(), port, audioPayloadType);\n try\n {\n dtmfSession.init();\n }\n catch (Exception e)\n {\n Log.warn(\"cannot initialize dtmf session on port \" + port, e);\n SipServletResponse resp = invite.createResponse(\n SipServletResponse.SC_SERVER_INTERNAL_ERROR);\n resp.send();\n return;\n }\n invite.getApplicationSession(true).setAttribute(\n DtmfSession.class.getName(), dtmfSession);\n SipServletResponse resp =\n invite.createResponse(SipServletResponse.SC_OK);\n String sdpAnswer = \"v=0\\r\\n\"\n + \"o=user1 123 456 IN IP4 127.0.0.1\\r\\n\"\n + \"s=-\\r\\n\"\n + \"c=IN IP4 127.0.0.1\\r\\n\"\n + \"t=0 0\\r\\n\"\n + \"m=audio \" + dtmfSession.getLocalPort() + \" RTP/AVP \"\n + audioPayloadType + \" \" + DTMF_PAYLOAD_TYPE + \"\\r\\n\"\n + \"a=rtpmap:0 PCMU/8000\\r\\n\"\n + \"a=rtpmap:\" + DTMF_PAYLOAD_TYPE + \" telephone-event/8000\\r\\n\"\n + \"a=fmtp:\" + DTMF_PAYLOAD_TYPE + \" 0-15\\r\\n\";\n resp.setContent(sdpAnswer.getBytes(charset), \"application/sdp\");\n resp.send();\n }\n"} {"input": "\tpublic String toString() {\n\t\tboolean isThisWeek = TaskActivityUtil.getCurrentWeek().includes(this);\n\t\tboolean isNextWeek = TaskActivityUtil.getNextWeek().includes(this);\n\t\tif (isDay() && (isThisWeek || isNextWeek)) {\n\t\t\tString day = \"\";\n\t\t\tswitch (getStartDate().get(Calendar.DAY_OF_WEEK)) {\n\t\t\tcase Calendar.MONDAY:\n\t\t\t\tday = \"Monday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.TUESDAY:\n\t\t\t\tday = \"Tuesday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.WEDNESDAY:\n\t\t\t\tday = \"Wednesday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.THURSDAY:\n\t\t\t\tday = \"Thursday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.FRIDAY:\n\t\t\t\tday = \"Friday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.SATURDAY:\n\t\t\t\tday = \"Saturday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.SUNDAY:\n\t\t\t\tday = \"Sunday\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == getStartDate().get(Calendar.DAY_OF_WEEK)) {\n\t\t\t\treturn day + \" - Today\";\n\t\t\t} else {\n\t\t\t\treturn day;\n\t\t\t}\n\t\t} else if (isThisWeek()) {\n\t\t\treturn DESCRIPTION_THIS_WEEK;\n\t\t} else if (isNextWeek()) {\n\t\t\treturn DESCRIPTION_NEXT_WEEK;\n\t\t} else if (isWeekAfterNext()) {\n\t\t\treturn DESCRIPTION_WEEK_AFTER_NEXT;\n\t\t} else if (isPreviousWeek()) {\n\t\t\treturn DESCRIPTION_PREVIOUS_WEEK;\n\t\t}\n\t\treturn DateFormat.getDateInstance(DateFormat.MEDIUM).format(startDate.getTime());\n\t}\n", "output": "\tpublic String toString() {\n\t\tboolean isThisWeek = TaskActivityUtil.getCurrentWeek().includes(this);\n\t\tCalendar endNextWeek = TaskActivityUtil.getCalendar();\n\t\tendNextWeek.add(Calendar.DAY_OF_YEAR, 7);\n\t\tboolean isNextWeek = TaskActivityUtil.getNextWeek().includes(this) && this.before(endNextWeek);\n\t\tif (isDay() && (isThisWeek || isNextWeek)) {\n\t\t\tString day = \"\";\n\t\t\tswitch (getStartDate().get(Calendar.DAY_OF_WEEK)) {\n\t\t\tcase Calendar.MONDAY:\n\t\t\t\tday = \"Monday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.TUESDAY:\n\t\t\t\tday = \"Tuesday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.WEDNESDAY:\n\t\t\t\tday = \"Wednesday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.THURSDAY:\n\t\t\t\tday = \"Thursday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.FRIDAY:\n\t\t\t\tday = \"Friday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.SATURDAY:\n\t\t\t\tday = \"Saturday\";\n\t\t\t\tbreak;\n\t\t\tcase Calendar.SUNDAY:\n\t\t\t\tday = \"Sunday\";\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == getStartDate().get(Calendar.DAY_OF_WEEK)) {\n\t\t\t\treturn day + \" - Today\";\n\t\t\t} else {\n\t\t\t\treturn day;\n\t\t\t}\n\t\t} else if (isThisWeek()) {\n\t\t\treturn DESCRIPTION_THIS_WEEK;\n\t\t} else if (isNextWeek()) {\n\t\t\treturn DESCRIPTION_NEXT_WEEK;\n\t\t} else if (isWeekAfterNext()) {\n\t\t\treturn DESCRIPTION_WEEK_AFTER_NEXT;\n\t\t} else if (isPreviousWeek()) {\n\t\t\treturn DESCRIPTION_PREVIOUS_WEEK;\n\t\t}\n\t\treturn DateFormat.getDateInstance(DateFormat.MEDIUM).format(startDate.getTime());\n\t}\n"} {"input": " public void paint(Graphics g) {\n mHeight = 0;\n iHeight = 0;\n if (messagesWidth == 0) {\n messagesWidth = getListWidth();\n }\n beginPaint();\n PopUp.getInstance().init(g, width, height);\n int count = updateLayout();\n setAbsOrg(g, 0, 0);\n g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));\n g.fillRect(0, 0, width, height);\n if (mainbar != null) {\n mHeight = mainbar.getVHeight(); \n }\n if (infobar != null) {\n setInfo();\n iHeight = infobar.getVHeight(); \n }\n if (paintTop) {\n if (reverse) {\n if (infobar != null) {\n iHeight = infobar.getVHeight();\n list_top = iHeight;\n drawInfoPanel(g);\n }\n } else {\n if (mainbar != null) {\n list_top = mHeight;\n drawMainPanel(g);\n }\n }\n }\n if (paintBottom) {\n if (reverse) {\n if (mainbar != null) {\n list_bottom = mHeight;\n }\n } else {\n list_bottom = iHeight;\n }\n }\n winHeight = height - list_top - list_bottom;\n boolean scroll = (listHeight > winHeight);\n if (count == 0) {\n cursor = (cursor == -1) ? -1 : 0;\n win_top = 0;\n } else if (cursor >= count) {\n cursor = count - 1;\n stickyWindow = true;\n }\n if (updateLayout() > 0 && stickyWindow) {\n fitCursorByTop();\n }\n int itemMaxWidth = (scroll) ? (width - scrollbar.getScrollWidth()) : (width);\n int itemIndex = win_top > 0 ? getElementIndexAt(win_top) : 0;\n int displayedIndex = 0;\n int displayedBottom = list_top;\n int baloon = -1;\n while (itemIndex < count) {\n int itemYpos = itemLayoutY[itemIndex] - win_top;\n if (itemYpos >= winHeight) {\n break;\n }\n VirtualElement el = getItemRef(itemIndex);\n boolean sel = (itemIndex == cursor);\n if (el != null) {\n int lh = el.getVHeight();\n setAbsOrg(g, 0, list_top);\n g.setClip(0, 0, itemMaxWidth, winHeight);\n g.translate(0, itemYpos);\n g.setColor(el.getColorBGnd());\n if (sel) {\n drawCursor(g, itemMaxWidth, lh);\n baloon = g.getTranslateY();\n } else {\n {\n g.fillRect(0, 0, itemMaxWidth, lh); \n }\n }\n g.setColor(el.getColor());\n g.clipRect(0, 0, itemMaxWidth, lh);\n el.drawItem(g, (sel) ? offset : 0, sel);\n displayedBottom = list_top + itemYpos + lh;\n }\n itemIndex++;\n } \n int clrH = height - displayedBottom;\n if (clrH > 0\n ) {\n setAbsOrg(g, 0, displayedBottom);\n g.setClip(0, 0, itemMaxWidth, clrH);\n g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));\n g.fillRect(0, 0, itemMaxWidth, clrH);\n }\n if (scroll) {\n setAbsOrg(g, 0, list_top);\n g.setClip(0, 0, width, winHeight);\n scrollbar.setPostion(win_top);\n scrollbar.setSize(listHeight);\n scrollbar.setWindowSize(winHeight);\n scrollbar.draw(g);\n } else {\n scrollbar.setSize(0);\n }\n setAbsClip(g, width, height);\nif (paintBottom) {\n if (reverse) {\n if (mainbar != null) {\n setAbsOrg(g, 0, height - mHeight);\n drawMainPanel(g);\n CommandsPointer.init(width, height, mHeight);\n }\n } else {\n if (infobar != null) {\n setAbsOrg(g, 0, height - iHeight);\n drawInfoPanel(g);\n CommandsPointer.init(width, height, iHeight);\n }\n }\n setAbsClip(g, width, height);\n if (sd.roster.messageCount > 0) {\n drawEnvelop(g);\n }\n if (System.currentTimeMillis() - sd.getTrafficIn() < 2000) {\n drawTraffic(g, false);\n }\n if (System.currentTimeMillis() - sd.getTrafficOut() < 2000) {\n drawTraffic(g, true);\n }\n }\n setAbsClip(g, width, height);\n drawPopUp(g);\n reconnectWindow.getInstance().draw(g, width, height);\n }\n", "output": " public synchronized void paint(Graphics g) {\n mHeight = 0;\n iHeight = 0;\n if (messagesWidth == 0) {\n messagesWidth = getListWidth();\n }\n beginPaint();\n PopUp.getInstance().init(g, width, height);\n int count = updateLayout();\n setAbsOrg(g, 0, 0);\n g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));\n g.fillRect(0, 0, width, height);\n if (mainbar != null) {\n mHeight = mainbar.getVHeight(); \n }\n if (infobar != null) {\n setInfo();\n iHeight = infobar.getVHeight(); \n }\n if (paintTop) {\n if (reverse) {\n if (infobar != null) {\n iHeight = infobar.getVHeight();\n list_top = iHeight;\n drawInfoPanel(g);\n }\n } else {\n if (mainbar != null) {\n list_top = mHeight;\n drawMainPanel(g);\n }\n }\n }\n if (paintBottom) {\n if (reverse) {\n if (mainbar != null) {\n list_bottom = mHeight;\n }\n } else {\n list_bottom = iHeight;\n }\n }\n winHeight = height - list_top - list_bottom;\n boolean scroll = (listHeight > winHeight);\n if (count == 0) {\n cursor = (cursor == -1) ? -1 : 0;\n win_top = 0;\n } else if (cursor >= count) {\n cursor = count - 1;\n stickyWindow = true;\n }\n if (updateLayout() > 0 && stickyWindow) {\n fitCursorByTop();\n }\n int itemMaxWidth = (scroll) ? (width - scrollbar.getScrollWidth()) : (width);\n int itemIndex = win_top > 0 ? getElementIndexAt(win_top) : 0;\n int displayedIndex = 0;\n int displayedBottom = list_top;\n int baloon = -1;\n while (itemIndex < itemLayoutY.length) {\n int itemYpos = itemLayoutY[itemIndex] - win_top;\n if (itemYpos >= winHeight) {\n break;\n }\n VirtualElement el = getItemRef(itemIndex);\n boolean sel = (itemIndex == cursor);\n if (el != null) {\n int lh = el.getVHeight();\n setAbsOrg(g, 0, list_top);\n g.setClip(0, 0, itemMaxWidth, winHeight);\n g.translate(0, itemYpos);\n g.setColor(el.getColorBGnd());\n if (sel) {\n drawCursor(g, itemMaxWidth, lh);\n baloon = g.getTranslateY();\n } else {\n {\n g.fillRect(0, 0, itemMaxWidth, lh); \n }\n }\n g.setColor(el.getColor());\n g.clipRect(0, 0, itemMaxWidth, lh);\n el.drawItem(g, (sel) ? offset : 0, sel);\n displayedBottom = list_top + itemYpos + lh;\n }\n itemIndex++;\n } \n int clrH = height - displayedBottom;\n if (clrH > 0\n ) {\n setAbsOrg(g, 0, displayedBottom);\n g.setClip(0, 0, itemMaxWidth, clrH);\n g.setColor(ColorTheme.getColor(ColorTheme.LIST_BGND));\n g.fillRect(0, 0, itemMaxWidth, clrH);\n }\n if (scroll) {\n setAbsOrg(g, 0, list_top);\n g.setClip(0, 0, width, winHeight);\n scrollbar.setPostion(win_top);\n scrollbar.setSize(listHeight);\n scrollbar.setWindowSize(winHeight);\n scrollbar.draw(g);\n } else {\n scrollbar.setSize(0);\n }\n setAbsClip(g, width, height);\nif (paintBottom) {\n if (reverse) {\n if (mainbar != null) {\n setAbsOrg(g, 0, height - mHeight);\n drawMainPanel(g);\n CommandsPointer.init(width, height, mHeight);\n }\n } else {\n if (infobar != null) {\n setAbsOrg(g, 0, height - iHeight);\n drawInfoPanel(g);\n CommandsPointer.init(width, height, iHeight);\n }\n }\n setAbsClip(g, width, height);\n if (sd.roster.messageCount > 0) {\n drawEnvelop(g);\n }\n if (System.currentTimeMillis() - sd.getTrafficIn() < 2000) {\n drawTraffic(g, false);\n }\n if (System.currentTimeMillis() - sd.getTrafficOut() < 2000) {\n drawTraffic(g, true);\n }\n }\n setAbsClip(g, width, height);\n drawPopUp(g);\n reconnectWindow.getInstance().draw(g, width, height);\n }\n"} {"input": " public TestResult perform()\n {\n byte[] data = { 0, 1, 0, 1, 0, 0, 1 };\n DERObject values[] = {\n new BERConstructedOctetString(data),\n new BERSequence(new DERPrintableString(\"hello world\")),\n new BERSet(new DERPrintableString(\"hello world\")),\n new BERTaggedObject(0, new DERPrintableString(\"hello world\")),\n new DERApplicationSpecific(0, data),\n new DERBitString(data),\n new DERBMPString(\"hello world\"),\n new DERBoolean(true),\n new DERBoolean(false),\n new DEREnumerated(100),\n new DERGeneralizedTime(\"20070315173729Z\"),\n new DERGeneralString(\"hello world\"),\n new DERIA5String(\"hello\"),\n new DERInteger(1000),\n new DERNull(),\n new DERNumericString(\"123456\"),\n new DERObjectIdentifier(\"1.1.1.10000.1\"),\n new DEROctetString(data),\n new DERPrintableString(\"hello world\"),\n new DERSequence(new DERPrintableString(\"hello world\")),\n new DERSet(new DERPrintableString(\"hello world\")),\n new DERT61String(\"hello world\"),\n new DERTaggedObject(0, new DERPrintableString(\"hello world\")),\n new DERUniversalString(data),\n new DERUnknownTag(0xff & (~(DERTags.TAGGED | DERTags.APPLICATION)), data),\n new DERUTCTime(new Date()),\n new DERUTF8String(\"hello world\"),\n new DERVisibleString(\"hello world\")\n };\n try\n {\n ByteArrayOutputStream bOut = new ByteArrayOutputStream();\n ASN1OutputStream aOut = new ASN1OutputStream(bOut);\n for (int i = 0; i != values.length; i++)\n {\n aOut.writeObject(values[i]);\n }\n DERObject[] readValues = new DERObject[values.length];\n ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());\n ASN1InputStream aIn = new ASN1InputStream(bIn);\n for (int i = 0; i != values.length; i++)\n {\n DERObject o = aIn.readObject();\n if (!o.equals(values[i]))\n {\n return new SimpleTestResult(false, getName() + \": Failed equality test for \" + o);\n }\n if (o.hashCode() != values[i].hashCode())\n {\n return new SimpleTestResult(false, getName() + \": Failed hashCode test for \" + o);\n }\n }\n }\n catch (Exception e)\n {\n return new SimpleTestResult(false, getName() + \": Failed - exception \" + e.toString(), e);\n }\n return new SimpleTestResult(true, getName() + \": Okay\");\n }\n", "output": " public TestResult perform()\n {\n byte[] data = { 0, 1, 0, 1, 0, 0, 1 };\n DERObject values[] = {\n new BERConstructedOctetString(data),\n new BERSequence(new DERPrintableString(\"hello world\")),\n new BERSet(new DERPrintableString(\"hello world\")),\n new BERTaggedObject(0, new DERPrintableString(\"hello world\")),\n new DERApplicationSpecific(0, data),\n new DERBitString(data),\n new DERBMPString(\"hello world\"),\n new DERBoolean(true),\n new DERBoolean(false),\n new DEREnumerated(100),\n new DERGeneralizedTime(\"20070315173729Z\"),\n new DERGeneralString(\"hello world\"),\n new DERIA5String(\"hello\"),\n new DERInteger(1000),\n new DERNull(),\n new DERNumericString(\"123456\"),\n new DERObjectIdentifier(\"1.1.1.10000.1\"),\n new DEROctetString(data),\n new DERPrintableString(\"hello world\"),\n new DERSequence(new DERPrintableString(\"hello world\")),\n new DERSet(new DERPrintableString(\"hello world\")),\n new DERT61String(\"hello world\"),\n new DERTaggedObject(0, new DERPrintableString(\"hello world\")),\n new DERUniversalString(data),\n new DERUnknownTag(0xff & (~(DERTags.TAGGED | DERTags.APPLICATION)), data),\n new DERUTCTime(new Date()),\n new DERUTF8String(\"hello world\"),\n new DERVisibleString(\"hello world\")\n };\n try\n {\n ByteArrayOutputStream bOut = new ByteArrayOutputStream();\n ASN1OutputStream aOut = new ASN1OutputStream(bOut);\n for (int i = 0; i != values.length; i++)\n {\n aOut.writeObject(values[i]);\n }\n DERObject[] readValues = new DERObject[values.length];\n ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());\n ASN1InputStream aIn = new ASN1InputStream(bIn);\n for (int i = 0; i != values.length; i++)\n {\n DERObject o = aIn.readObject();\n if (!o.equals(values[i]))\n {\n return new SimpleTestResult(false, getName() + \": Failed equality test for \" + o.getClass());\n }\n if (o.hashCode() != values[i].hashCode())\n {\n return new SimpleTestResult(false, getName() + \": Failed hashCode test for \" + o.getClass());\n }\n }\n }\n catch (Exception e)\n {\n return new SimpleTestResult(false, getName() + \": Failed - exception \" + e.toString(), e);\n }\n return new SimpleTestResult(true, getName() + \": Okay\");\n }\n"} {"input": "\tprivate Container getUI() {\t\t\n\t\tuserCertificatePanel = new UserCertificatePanel(this) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic Insets getInsets() {\n\t\t\t\treturn Utils.INSETS;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean isAllowEmail() {\n\t\t\t\treturn mail.isReady();\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic Date getDefaultExpiration() {\n\t\t\t\tCalendar c = Calendar.getInstance();\n\t\t\t\tc.add(Calendar.DATE, defaultDuration);\n\t\t\t\tc.set(Calendar.HOUR_OF_DAY, 0);\n\t\t\t\tc.set(Calendar.MINUTE, 0);\n\t\t\t\tc.set(Calendar.SECOND, 0);\n\t\t\t\tc.set(Calendar.MILLISECOND, 0);\n\t\t\t\treturn c.getTime();\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean saveUser(String username, UserCertificateModel ucm) {\n\t\t\t\treturn userService.updateUserModel(username, ucm.user);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean newCertificate(UserCertificateModel ucm, X509Metadata metadata, boolean sendEmail) {\n\t\t\t\tif (!prepareX509Infrastructure()) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tDate notAfter = metadata.notAfter;\n\t\t\t\tsetMetadataDefaults(metadata);\n\t\t\t\tmetadata.notAfter = notAfter;\n\t\t\t\tUserModel user = ucm.user;\t\t\t\t\n\t\t\t\tif (!StringUtils.isEmpty(user.organizationalUnit)) {\n\t\t\t\t\tmetadata.oids.put(\"OU\", user.organizationalUnit);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.organization)) {\n\t\t\t\t\tmetadata.oids.put(\"O\", user.organization);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.locality)) {\n\t\t\t\t\tmetadata.oids.put(\"L\", user.locality);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.stateProvince)) {\n\t\t\t\t\tmetadata.oids.put(\"ST\", user.stateProvince);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.countryCode)) {\n\t\t\t\t\tmetadata.oids.put(\"C\", user.countryCode);\n\t\t\t\t}\n\t\t\t\tFile caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);\n\t\t\t\tFile zip = X509Utils.newClientBundle(metadata, caKeystoreFile, caKeystorePassword, GitblitAuthority.this);\n\t\t\t\tif (ucm.expires == null || metadata.notAfter.before(ucm.expires)) {\n\t\t\t\t\tucm.expires = metadata.notAfter;\n\t\t\t\t}\n\t\t\t\tupdateAuthorityConfig(ucm);\n\t\t\t\tucm.certs = null;\n\t\t\t\tint modelIndex = table.convertRowIndexToModel(table.getSelectedRow());\n\t\t\t\ttableModel.fireTableDataChanged();\n\t\t\t\ttable.getSelectionModel().setSelectionInterval(modelIndex, modelIndex);\n\t\t\t\tif (sendEmail) {\n\t\t\t\t\tsendEmail(user, metadata, zip);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean revoke(UserCertificateModel ucm, X509Certificate cert, RevocationReason reason) {\n\t\t\t\tif (!prepareX509Infrastructure()) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tFile caRevocationList = new File(folder, X509Utils.CA_REVOCATION_LIST);\n\t\t\t\tFile caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);\n\t\t\t\tif (X509Utils.revoke(cert, reason, caRevocationList, caKeystoreFile, caKeystorePassword, GitblitAuthority.this)) {\n\t\t\t\t\tFile certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);\n\t\t\t\t\tFileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());\n\t\t\t\t\tif (certificatesConfigFile.exists()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconfig.load();\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tucm.revoke(cert.getSerialNumber(), reason);\n\t\t\t\t\tucm.update(config);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconfig.save();\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, e);\n\t\t\t\t\t}\n\t\t\t\t\tucm.certs = null;\n\t\t\t\t\tint modelIndex = table.convertRowIndexToModel(table.getSelectedRow());\n\t\t\t\t\ttableModel.fireTableDataChanged();\n\t\t\t\t\ttable.getSelectionModel().setSelectionInterval(modelIndex, modelIndex);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\ttable = Utils.newTable(tableModel, Utils.DATE_FORMAT);\n\t\ttable.setRowSorter(defaultSorter);\n\t\ttable.setDefaultRenderer(CertificateStatus.class, new CertificateStatusRenderer());\n\t\ttable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\n\t\t\t@Override\n\t\t\tpublic void valueChanged(ListSelectionEvent e) {\n\t\t\t\tif (e.getValueIsAdjusting()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint row = table.getSelectedRow();\n\t\t\t\tif (row < 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint modelIndex = table.convertRowIndexToModel(row);\n\t\t\t\tUserCertificateModel ucm = tableModel.get(modelIndex);\n\t\t\t\tif (ucm.certs == null) {\n\t\t\t\t\tucm.certs = findCerts(folder, ucm.user.username);\n\t\t\t\t}\n\t\t\t\tuserCertificatePanel.setUserCertificateModel(ucm);\n\t\t\t}\n\t\t});\n\t\tJPanel usersPanel = new JPanel(new BorderLayout()) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic Insets getInsets() {\n\t\t\t\treturn Utils.INSETS;\n\t\t\t}\n\t\t};\n\t\tusersPanel.add(new HeaderPanel(Translation.get(\"gb.users\"), \"users_16x16.png\"), BorderLayout.NORTH);\n\t\tusersPanel.add(new JScrollPane(table), BorderLayout.CENTER);\n\t\tusersPanel.setMinimumSize(new Dimension(400, 10));\n\t\tcertificateDefaultsButton = new JButton(new ImageIcon(getClass().getResource(\"/settings_16x16.png\")));\n\t\tcertificateDefaultsButton.setFocusable(false);\n\t\tcertificateDefaultsButton.setToolTipText(Translation.get(\"gb.newCertificateDefaults\"));\t\t\n\t\tcertificateDefaultsButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tX509Metadata metadata = new X509Metadata(\"whocares\", \"whocares\");\n\t\t\t\tFile certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);\n\t\t\t\tFileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());\n\t\t\t\tNewCertificateConfig certificateConfig = null;\n\t\t\t\tif (certificatesConfigFile.exists()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconfig.load();\n\t\t\t\t\t} catch (Exception x) {\n\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, x);\n\t\t\t\t\t}\n\t\t\t\t\tcertificateConfig = NewCertificateConfig.KEY.parse(config);\n\t\t\t\t\tcertificateConfig.update(metadata);\n\t\t\t\t}\n\t\t\t\tInputVerifier verifier = new InputVerifier() {\n\t\t\t\t\tpublic boolean verify(JComponent comp) {\n\t\t\t\t\t\tboolean returnValue;\n\t\t\t\t\t\tJTextField textField = (JTextField) comp;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tInteger.parseInt(textField.getText());\n\t\t\t\t\t\t\treturnValue = true;\n\t\t\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\t\t\treturnValue = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnValue;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tJTextField siteNameTF = new JTextField(20);\n\t\t\t\tsiteNameTF.setText(gitblitSettings.getString(Keys.web.siteName, \"Gitblit\"));\n\t\t\t\tJPanel siteNamePanel = Utils.newFieldPanel(Translation.get(\"gb.siteName\"),\n\t\t\t\t\t\tsiteNameTF, Translation.get(\"gb.siteNameDescription\"));\n\t\t\t\tJTextField validityTF = new JTextField(4);\n\t\t\t\tvalidityTF.setInputVerifier(verifier);\n\t\t\t\tvalidityTF.setVerifyInputWhenFocusTarget(true);\n\t\t\t\tvalidityTF.setText(\"\" + certificateConfig.duration);\n\t\t\t\tJPanel validityPanel = Utils.newFieldPanel(Translation.get(\"gb.validity\"),\n\t\t\t\t\t\tvalidityTF, Translation.get(\"gb.duration.days\").replace(\"{0}\", \"\").trim());\n\t\t\t\tJPanel p1 = new JPanel(new GridLayout(0, 1, 5, 2));\n\t\t\t\tp1.add(siteNamePanel);\n\t\t\t\tp1.add(validityPanel);\n\t\t\t\tDefaultOidsPanel oids = new DefaultOidsPanel(metadata);\n\t\t\t\tJPanel panel = new JPanel(new BorderLayout());\n\t\t\t\tpanel.add(p1, BorderLayout.NORTH);\n\t\t\t\tpanel.add(oids, BorderLayout.CENTER);\n\t\t\t\tint result = JOptionPane.showConfirmDialog(GitblitAuthority.this, \n\t\t\t\t\t\tpanel, Translation.get(\"gb.newCertificateDefaults\"), JOptionPane.OK_CANCEL_OPTION,\n\t\t\t\t\t\tJOptionPane.QUESTION_MESSAGE, new ImageIcon(getClass().getResource(\"/settings_32x32.png\")));\n\t\t\t\tif (result == JOptionPane.OK_OPTION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\toids.update(metadata);\n\t\t\t\t\t\tcertificateConfig.duration = Integer.parseInt(validityTF.getText());\n\t\t\t\t\t\tcertificateConfig.store(config, metadata);\n\t\t\t\t\t\tconfig.save();\n\t\t\t\t\t\tMap<String, String> updates = new HashMap<String, String>();\n\t\t\t\t\t\tupdates.put(Keys.web.siteName, siteNameTF.getText());\n\t\t\t\t\t\tgitblitSettings.saveSettings(updates);\n\t\t\t\t\t} catch (Exception e1) {\n\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, e1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tnewSSLCertificate = new JButton(new ImageIcon(getClass().getResource(\"/rosette_16x16.png\")));\n\t\tnewSSLCertificate.setFocusable(false);\n\t\tnewSSLCertificate.setToolTipText(Translation.get(\"gb.newSSLCertificate\"));\t\t\n\t\tnewSSLCertificate.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tDate defaultExpiration = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);\n\t\t\t\tNewSSLCertificateDialog dialog = new NewSSLCertificateDialog(GitblitAuthority.this, defaultExpiration);\n\t\t\t\tdialog.setModal(true);\n\t\t\t\tdialog.setVisible(true);\n\t\t\t\tif (dialog.isCanceled()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfinal Date expires = dialog.getExpiration();\n\t\t\t\tfinal String hostname = dialog.getHostname();\n\t\t\t\tfinal boolean serveCertificate = dialog.isServeCertificate();\n\t\t\t\tAuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected Boolean doRequest() throws IOException {\n\t\t\t\t\t\tif (!prepareX509Infrastructure()) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tFile caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);\n\t\t\t\t\t\tPrivateKey caPrivateKey = X509Utils.getPrivateKey(X509Utils.CA_ALIAS, caKeystoreFile, caKeystorePassword);\n\t\t\t\t\t\tX509Certificate caCert = X509Utils.getCertificate(X509Utils.CA_ALIAS, caKeystoreFile, caKeystorePassword);\n\t\t\t\t\t\tX509Metadata metadata = new X509Metadata(hostname, caKeystorePassword);\n\t\t\t\t\t\tsetMetadataDefaults(metadata);\n\t\t\t\t\t\tmetadata.notAfter = expires;\n\t\t\t\t\t\tFile serverKeystoreFile = new File(folder, X509Utils.SERVER_KEY_STORE);\n\t\t\t\t\t\tX509Certificate cert = X509Utils.newSSLCertificate(metadata, caPrivateKey, caCert, serverKeystoreFile, GitblitAuthority.this);\n\t\t\t\t\t\tboolean hasCert = cert != null;\n\t\t\t\t\t\tif (hasCert && serveCertificate) {\n\t\t\t\t\t\t\tMap<String, String> updates = new HashMap<String, String>();\n\t\t\t\t\t\t\tupdates.put(Keys.server.certificateAlias, metadata.commonName);\n\t\t\t\t\t\t\tgitblitSettings.saveSettings(updates);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn hasCert;\n\t\t\t\t\t}\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected void onSuccess() {\n\t\t\t\t\t\tif (serveCertificate) {\n\t\t\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, \n\t\t\t\t\t\t\t\t\tMessageFormat.format(Translation.get(\"gb.sslCertificateGeneratedRestart\"), hostname),\n\t\t\t\t\t\t\t\t\tTranslation.get(\"gb.newSSLCertificate\"), JOptionPane.INFORMATION_MESSAGE);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, \n\t\t\t\t\t\t\t\tMessageFormat.format(Translation.get(\"gb.sslCertificateGenerated\"), hostname),\n\t\t\t\t\t\t\t\tTranslation.get(\"gb.newSSLCertificate\"), JOptionPane.INFORMATION_MESSAGE);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tworker.execute();\n\t\t\t}\n\t\t});\n\t\tJButton emailBundle = new JButton(new ImageIcon(getClass().getResource(\"/mail_16x16.png\")));\n\t\temailBundle.setFocusable(false);\n\t\temailBundle.setToolTipText(Translation.get(\"gb.emailCertificateBundle\"));\t\t\n\t\temailBundle.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tint row = table.getSelectedRow();\n\t\t\t\tif (row < 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint modelIndex = table.convertRowIndexToModel(row);\n\t\t\t\tfinal UserCertificateModel ucm = tableModel.get(modelIndex);\n\t\t\t\tif (ArrayUtils.isEmpty(ucm.certs)) {\n\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, MessageFormat.format(Translation.get(\"gb.pleaseGenerateClientCertificate\"), ucm.user.getDisplayName()));\n\t\t\t\t}\n\t\t\t\tfinal File zip = new File(folder, X509Utils.CERTS + File.separator + ucm.user.username + File.separator + ucm.user.username + \".zip\");\n\t\t\t\tif (!zip.exists()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tAuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected Boolean doRequest() throws IOException {\n\t\t\t\t\t\tX509Metadata metadata = new X509Metadata(ucm.user.username, \"whocares\");\n\t\t\t\t\t\tmetadata.serverHostname = gitblitSettings.getString(Keys.web.siteName, Constants.NAME);\n\t\t\t\t\t\tif (StringUtils.isEmpty(metadata.serverHostname)) {\n\t\t\t\t\t\t\tmetadata.serverHostname = Constants.NAME;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmetadata.userDisplayname = ucm.user.getDisplayName();\n\t\t\t\t\t\treturn sendEmail(ucm.user, metadata, zip);\n\t\t\t\t\t}\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected void onSuccess() {\n\t\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, MessageFormat.format(Translation.get(\"gb.clientCertificateBundleSent\"),\n\t\t\t\t\t\t\t\tucm.user.getDisplayName()));\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tworker.execute();\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tJButton logButton = new JButton(new ImageIcon(getClass().getResource(\"/script_16x16.png\")));\n\t\tlogButton.setFocusable(false);\n\t\tlogButton.setToolTipText(Translation.get(\"gb.log\"));\t\t\n\t\tlogButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tFile log = new File(folder, X509Utils.CERTS + File.separator + \"log.txt\");\n\t\t\t\tif (log.exists()) {\n\t\t\t\t\tString content = FileUtils.readContent(log, \"\\n\");\n\t\t\t\t\tJTextArea textarea = new JTextArea(content);\n\t\t\t\t\tJScrollPane scrollPane = new JScrollPane(textarea);\n\t\t\t\t\tscrollPane.setPreferredSize(new Dimension(700, 400));\n\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, scrollPane, log.getAbsolutePath(), JOptionPane.INFORMATION_MESSAGE);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfinal JTextField filterTextfield = new JTextField(15);\n\t\tfilterTextfield.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tfilterUsers(filterTextfield.getText());\n\t\t\t}\n\t\t});\n\t\tfilterTextfield.addKeyListener(new KeyAdapter() {\n\t\t\tpublic void keyReleased(KeyEvent e) {\n\t\t\t\tfilterUsers(filterTextfield.getText());\n\t\t\t}\n\t\t});\n\t\tJToolBar buttonControls = new JToolBar(JToolBar.HORIZONTAL);\n\t\tbuttonControls.setFloatable(false);\n\t\tbuttonControls.add(certificateDefaultsButton);\n\t\tbuttonControls.add(newSSLCertificate);\n\t\tbuttonControls.add(emailBundle);\n\t\tbuttonControls.add(logButton);\n\t\tJPanel userControls = new JPanel(new FlowLayout(FlowLayout.RIGHT, Utils.MARGIN, Utils.MARGIN));\n\t\tuserControls.add(new JLabel(Translation.get(\"gb.filter\")));\n\t\tuserControls.add(filterTextfield);\n\t\tJPanel topPanel = new JPanel(new BorderLayout(0, 0));\n\t\ttopPanel.add(buttonControls, BorderLayout.WEST);\n\t\ttopPanel.add(userControls, BorderLayout.EAST);\n\t\tJPanel leftPanel = new JPanel(new BorderLayout());\n\t\tleftPanel.add(topPanel, BorderLayout.NORTH);\n\t\tleftPanel.add(usersPanel, BorderLayout.CENTER);\n\t\tuserCertificatePanel.setMinimumSize(new Dimension(375, 10));\n\t\tJLabel statusLabel = new JLabel();\n\t\tstatusLabel.setHorizontalAlignment(SwingConstants.RIGHT);\n\t\tif (X509Utils.unlimitedStrength) {\n\t\t\tstatusLabel.setText(\"JCE Unlimited Strength Jurisdiction Policy\");\n\t\t} else {\n\t\t\tstatusLabel.setText(\"JCE Standard Encryption Policy\");\n\t\t}\n\t\tJPanel root = new JPanel(new BorderLayout()) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\tpublic Insets getInsets() {\n\t\t\t\treturn Utils.INSETS;\n\t\t\t}\n\t\t};\n\t\tJSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, userCertificatePanel);\n\t\tsplitPane.setDividerLocation(1d);\n\t\troot.add(splitPane, BorderLayout.CENTER);\n\t\troot.add(statusLabel, BorderLayout.SOUTH);\n\t\treturn root;\n\t}\n", "output": "\tprivate Container getUI() {\t\t\n\t\tuserCertificatePanel = new UserCertificatePanel(this) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic Insets getInsets() {\n\t\t\t\treturn Utils.INSETS;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean isAllowEmail() {\n\t\t\t\treturn mail.isReady();\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic Date getDefaultExpiration() {\n\t\t\t\tCalendar c = Calendar.getInstance();\n\t\t\t\tc.add(Calendar.DATE, defaultDuration);\n\t\t\t\tc.set(Calendar.HOUR_OF_DAY, 0);\n\t\t\t\tc.set(Calendar.MINUTE, 0);\n\t\t\t\tc.set(Calendar.SECOND, 0);\n\t\t\t\tc.set(Calendar.MILLISECOND, 0);\n\t\t\t\treturn c.getTime();\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean saveUser(String username, UserCertificateModel ucm) {\n\t\t\t\treturn userService.updateUserModel(username, ucm.user);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean newCertificate(UserCertificateModel ucm, X509Metadata metadata, boolean sendEmail) {\n\t\t\t\tif (!prepareX509Infrastructure()) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tDate notAfter = metadata.notAfter;\n\t\t\t\tsetMetadataDefaults(metadata);\n\t\t\t\tmetadata.notAfter = notAfter;\n\t\t\t\tUserModel user = ucm.user;\t\t\t\t\n\t\t\t\tif (!StringUtils.isEmpty(user.organizationalUnit)) {\n\t\t\t\t\tmetadata.oids.put(\"OU\", user.organizationalUnit);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.organization)) {\n\t\t\t\t\tmetadata.oids.put(\"O\", user.organization);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.locality)) {\n\t\t\t\t\tmetadata.oids.put(\"L\", user.locality);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.stateProvince)) {\n\t\t\t\t\tmetadata.oids.put(\"ST\", user.stateProvince);\n\t\t\t\t}\n\t\t\t\tif (!StringUtils.isEmpty(user.countryCode)) {\n\t\t\t\t\tmetadata.oids.put(\"C\", user.countryCode);\n\t\t\t\t}\n\t\t\t\tFile caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);\n\t\t\t\tFile zip = X509Utils.newClientBundle(metadata, caKeystoreFile, caKeystorePassword, GitblitAuthority.this);\n\t\t\t\tif (ucm.expires == null || metadata.notAfter.before(ucm.expires)) {\n\t\t\t\t\tucm.expires = metadata.notAfter;\n\t\t\t\t}\n\t\t\t\tupdateAuthorityConfig(ucm);\n\t\t\t\tucm.certs = null;\n\t\t\t\tint selectedIndex = table.getSelectedRow();\n\t\t\t\ttableModel.fireTableDataChanged();\n\t\t\t\ttable.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);\n\t\t\t\tif (sendEmail) {\n\t\t\t\t\tsendEmail(user, metadata, zip);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic boolean revoke(UserCertificateModel ucm, X509Certificate cert, RevocationReason reason) {\n\t\t\t\tif (!prepareX509Infrastructure()) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tFile caRevocationList = new File(folder, X509Utils.CA_REVOCATION_LIST);\n\t\t\t\tFile caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);\n\t\t\t\tif (X509Utils.revoke(cert, reason, caRevocationList, caKeystoreFile, caKeystorePassword, GitblitAuthority.this)) {\n\t\t\t\t\tFile certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);\n\t\t\t\t\tFileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());\n\t\t\t\t\tif (certificatesConfigFile.exists()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconfig.load();\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tucm.revoke(cert.getSerialNumber(), reason);\n\t\t\t\t\tucm.update(config);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconfig.save();\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, e);\n\t\t\t\t\t}\n\t\t\t\t\tucm.certs = null;\n\t\t\t\t\tint modelIndex = table.convertRowIndexToModel(table.getSelectedRow());\n\t\t\t\t\ttableModel.fireTableDataChanged();\n\t\t\t\t\ttable.getSelectionModel().setSelectionInterval(modelIndex, modelIndex);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\ttable = Utils.newTable(tableModel, Utils.DATE_FORMAT);\n\t\ttable.setRowSorter(defaultSorter);\n\t\ttable.setDefaultRenderer(CertificateStatus.class, new CertificateStatusRenderer());\n\t\ttable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\n\t\t\t@Override\n\t\t\tpublic void valueChanged(ListSelectionEvent e) {\n\t\t\t\tif (e.getValueIsAdjusting()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint row = table.getSelectedRow();\n\t\t\t\tif (row < 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint modelIndex = table.convertRowIndexToModel(row);\n\t\t\t\tUserCertificateModel ucm = tableModel.get(modelIndex);\n\t\t\t\tif (ucm.certs == null) {\n\t\t\t\t\tucm.certs = findCerts(folder, ucm.user.username);\n\t\t\t\t}\n\t\t\t\tuserCertificatePanel.setUserCertificateModel(ucm);\n\t\t\t}\n\t\t});\n\t\tJPanel usersPanel = new JPanel(new BorderLayout()) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\t@Override\n\t\t\tpublic Insets getInsets() {\n\t\t\t\treturn Utils.INSETS;\n\t\t\t}\n\t\t};\n\t\tusersPanel.add(new HeaderPanel(Translation.get(\"gb.users\"), \"users_16x16.png\"), BorderLayout.NORTH);\n\t\tusersPanel.add(new JScrollPane(table), BorderLayout.CENTER);\n\t\tusersPanel.setMinimumSize(new Dimension(400, 10));\n\t\tcertificateDefaultsButton = new JButton(new ImageIcon(getClass().getResource(\"/settings_16x16.png\")));\n\t\tcertificateDefaultsButton.setFocusable(false);\n\t\tcertificateDefaultsButton.setToolTipText(Translation.get(\"gb.newCertificateDefaults\"));\t\t\n\t\tcertificateDefaultsButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tX509Metadata metadata = new X509Metadata(\"whocares\", \"whocares\");\n\t\t\t\tFile certificatesConfigFile = new File(folder, X509Utils.CA_CONFIG);\n\t\t\t\tFileBasedConfig config = new FileBasedConfig(certificatesConfigFile, FS.detect());\n\t\t\t\tNewCertificateConfig certificateConfig = null;\n\t\t\t\tif (certificatesConfigFile.exists()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconfig.load();\n\t\t\t\t\t} catch (Exception x) {\n\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, x);\n\t\t\t\t\t}\n\t\t\t\t\tcertificateConfig = NewCertificateConfig.KEY.parse(config);\n\t\t\t\t\tcertificateConfig.update(metadata);\n\t\t\t\t}\n\t\t\t\tInputVerifier verifier = new InputVerifier() {\n\t\t\t\t\tpublic boolean verify(JComponent comp) {\n\t\t\t\t\t\tboolean returnValue;\n\t\t\t\t\t\tJTextField textField = (JTextField) comp;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tInteger.parseInt(textField.getText());\n\t\t\t\t\t\t\treturnValue = true;\n\t\t\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\t\t\treturnValue = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnValue;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tJTextField siteNameTF = new JTextField(20);\n\t\t\t\tsiteNameTF.setText(gitblitSettings.getString(Keys.web.siteName, \"Gitblit\"));\n\t\t\t\tJPanel siteNamePanel = Utils.newFieldPanel(Translation.get(\"gb.siteName\"),\n\t\t\t\t\t\tsiteNameTF, Translation.get(\"gb.siteNameDescription\"));\n\t\t\t\tJTextField validityTF = new JTextField(4);\n\t\t\t\tvalidityTF.setInputVerifier(verifier);\n\t\t\t\tvalidityTF.setVerifyInputWhenFocusTarget(true);\n\t\t\t\tvalidityTF.setText(\"\" + certificateConfig.duration);\n\t\t\t\tJPanel validityPanel = Utils.newFieldPanel(Translation.get(\"gb.validity\"),\n\t\t\t\t\t\tvalidityTF, Translation.get(\"gb.duration.days\").replace(\"{0}\", \"\").trim());\n\t\t\t\tJPanel p1 = new JPanel(new GridLayout(0, 1, 5, 2));\n\t\t\t\tp1.add(siteNamePanel);\n\t\t\t\tp1.add(validityPanel);\n\t\t\t\tDefaultOidsPanel oids = new DefaultOidsPanel(metadata);\n\t\t\t\tJPanel panel = new JPanel(new BorderLayout());\n\t\t\t\tpanel.add(p1, BorderLayout.NORTH);\n\t\t\t\tpanel.add(oids, BorderLayout.CENTER);\n\t\t\t\tint result = JOptionPane.showConfirmDialog(GitblitAuthority.this, \n\t\t\t\t\t\tpanel, Translation.get(\"gb.newCertificateDefaults\"), JOptionPane.OK_CANCEL_OPTION,\n\t\t\t\t\t\tJOptionPane.QUESTION_MESSAGE, new ImageIcon(getClass().getResource(\"/settings_32x32.png\")));\n\t\t\t\tif (result == JOptionPane.OK_OPTION) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\toids.update(metadata);\n\t\t\t\t\t\tcertificateConfig.duration = Integer.parseInt(validityTF.getText());\n\t\t\t\t\t\tcertificateConfig.store(config, metadata);\n\t\t\t\t\t\tconfig.save();\n\t\t\t\t\t\tMap<String, String> updates = new HashMap<String, String>();\n\t\t\t\t\t\tupdates.put(Keys.web.siteName, siteNameTF.getText());\n\t\t\t\t\t\tgitblitSettings.saveSettings(updates);\n\t\t\t\t\t} catch (Exception e1) {\n\t\t\t\t\t\tUtils.showException(GitblitAuthority.this, e1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tnewSSLCertificate = new JButton(new ImageIcon(getClass().getResource(\"/rosette_16x16.png\")));\n\t\tnewSSLCertificate.setFocusable(false);\n\t\tnewSSLCertificate.setToolTipText(Translation.get(\"gb.newSSLCertificate\"));\t\t\n\t\tnewSSLCertificate.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tDate defaultExpiration = new Date(System.currentTimeMillis() + 10*TimeUtils.ONEYEAR);\n\t\t\t\tNewSSLCertificateDialog dialog = new NewSSLCertificateDialog(GitblitAuthority.this, defaultExpiration);\n\t\t\t\tdialog.setModal(true);\n\t\t\t\tdialog.setVisible(true);\n\t\t\t\tif (dialog.isCanceled()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfinal Date expires = dialog.getExpiration();\n\t\t\t\tfinal String hostname = dialog.getHostname();\n\t\t\t\tfinal boolean serveCertificate = dialog.isServeCertificate();\n\t\t\t\tAuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected Boolean doRequest() throws IOException {\n\t\t\t\t\t\tif (!prepareX509Infrastructure()) {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tFile caKeystoreFile = new File(folder, X509Utils.CA_KEY_STORE);\n\t\t\t\t\t\tPrivateKey caPrivateKey = X509Utils.getPrivateKey(X509Utils.CA_ALIAS, caKeystoreFile, caKeystorePassword);\n\t\t\t\t\t\tX509Certificate caCert = X509Utils.getCertificate(X509Utils.CA_ALIAS, caKeystoreFile, caKeystorePassword);\n\t\t\t\t\t\tX509Metadata metadata = new X509Metadata(hostname, caKeystorePassword);\n\t\t\t\t\t\tsetMetadataDefaults(metadata);\n\t\t\t\t\t\tmetadata.notAfter = expires;\n\t\t\t\t\t\tFile serverKeystoreFile = new File(folder, X509Utils.SERVER_KEY_STORE);\n\t\t\t\t\t\tX509Certificate cert = X509Utils.newSSLCertificate(metadata, caPrivateKey, caCert, serverKeystoreFile, GitblitAuthority.this);\n\t\t\t\t\t\tboolean hasCert = cert != null;\n\t\t\t\t\t\tif (hasCert && serveCertificate) {\n\t\t\t\t\t\t\tMap<String, String> updates = new HashMap<String, String>();\n\t\t\t\t\t\t\tupdates.put(Keys.server.certificateAlias, metadata.commonName);\n\t\t\t\t\t\t\tgitblitSettings.saveSettings(updates);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn hasCert;\n\t\t\t\t\t}\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected void onSuccess() {\n\t\t\t\t\t\tif (serveCertificate) {\n\t\t\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, \n\t\t\t\t\t\t\t\t\tMessageFormat.format(Translation.get(\"gb.sslCertificateGeneratedRestart\"), hostname),\n\t\t\t\t\t\t\t\t\tTranslation.get(\"gb.newSSLCertificate\"), JOptionPane.INFORMATION_MESSAGE);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, \n\t\t\t\t\t\t\t\tMessageFormat.format(Translation.get(\"gb.sslCertificateGenerated\"), hostname),\n\t\t\t\t\t\t\t\tTranslation.get(\"gb.newSSLCertificate\"), JOptionPane.INFORMATION_MESSAGE);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tworker.execute();\n\t\t\t}\n\t\t});\n\t\tJButton emailBundle = new JButton(new ImageIcon(getClass().getResource(\"/mail_16x16.png\")));\n\t\temailBundle.setFocusable(false);\n\t\temailBundle.setToolTipText(Translation.get(\"gb.emailCertificateBundle\"));\t\t\n\t\temailBundle.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tint row = table.getSelectedRow();\n\t\t\t\tif (row < 0) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint modelIndex = table.convertRowIndexToModel(row);\n\t\t\t\tfinal UserCertificateModel ucm = tableModel.get(modelIndex);\n\t\t\t\tif (ArrayUtils.isEmpty(ucm.certs)) {\n\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, MessageFormat.format(Translation.get(\"gb.pleaseGenerateClientCertificate\"), ucm.user.getDisplayName()));\n\t\t\t\t}\n\t\t\t\tfinal File zip = new File(folder, X509Utils.CERTS + File.separator + ucm.user.username + File.separator + ucm.user.username + \".zip\");\n\t\t\t\tif (!zip.exists()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tAuthorityWorker worker = new AuthorityWorker(GitblitAuthority.this) {\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected Boolean doRequest() throws IOException {\n\t\t\t\t\t\tX509Metadata metadata = new X509Metadata(ucm.user.username, \"whocares\");\n\t\t\t\t\t\tmetadata.serverHostname = gitblitSettings.getString(Keys.web.siteName, Constants.NAME);\n\t\t\t\t\t\tif (StringUtils.isEmpty(metadata.serverHostname)) {\n\t\t\t\t\t\t\tmetadata.serverHostname = Constants.NAME;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmetadata.userDisplayname = ucm.user.getDisplayName();\n\t\t\t\t\t\treturn sendEmail(ucm.user, metadata, zip);\n\t\t\t\t\t}\n\t\t\t\t\t@Override\n\t\t\t\t\tprotected void onSuccess() {\n\t\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, MessageFormat.format(Translation.get(\"gb.clientCertificateBundleSent\"),\n\t\t\t\t\t\t\t\tucm.user.getDisplayName()));\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tworker.execute();\t\t\t\t\n\t\t\t}\n\t\t});\n\t\tJButton logButton = new JButton(new ImageIcon(getClass().getResource(\"/script_16x16.png\")));\n\t\tlogButton.setFocusable(false);\n\t\tlogButton.setToolTipText(Translation.get(\"gb.log\"));\t\t\n\t\tlogButton.addActionListener(new ActionListener() {\n\t\t\t@Override\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tFile log = new File(folder, X509Utils.CERTS + File.separator + \"log.txt\");\n\t\t\t\tif (log.exists()) {\n\t\t\t\t\tString content = FileUtils.readContent(log, \"\\n\");\n\t\t\t\t\tJTextArea textarea = new JTextArea(content);\n\t\t\t\t\tJScrollPane scrollPane = new JScrollPane(textarea);\n\t\t\t\t\tscrollPane.setPreferredSize(new Dimension(700, 400));\n\t\t\t\t\tJOptionPane.showMessageDialog(GitblitAuthority.this, scrollPane, log.getAbsolutePath(), JOptionPane.INFORMATION_MESSAGE);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfinal JTextField filterTextfield = new JTextField(15);\n\t\tfilterTextfield.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tfilterUsers(filterTextfield.getText());\n\t\t\t}\n\t\t});\n\t\tfilterTextfield.addKeyListener(new KeyAdapter() {\n\t\t\tpublic void keyReleased(KeyEvent e) {\n\t\t\t\tfilterUsers(filterTextfield.getText());\n\t\t\t}\n\t\t});\n\t\tJToolBar buttonControls = new JToolBar(JToolBar.HORIZONTAL);\n\t\tbuttonControls.setFloatable(false);\n\t\tbuttonControls.add(certificateDefaultsButton);\n\t\tbuttonControls.add(newSSLCertificate);\n\t\tbuttonControls.add(emailBundle);\n\t\tbuttonControls.add(logButton);\n\t\tJPanel userControls = new JPanel(new FlowLayout(FlowLayout.RIGHT, Utils.MARGIN, Utils.MARGIN));\n\t\tuserControls.add(new JLabel(Translation.get(\"gb.filter\")));\n\t\tuserControls.add(filterTextfield);\n\t\tJPanel topPanel = new JPanel(new BorderLayout(0, 0));\n\t\ttopPanel.add(buttonControls, BorderLayout.WEST);\n\t\ttopPanel.add(userControls, BorderLayout.EAST);\n\t\tJPanel leftPanel = new JPanel(new BorderLayout());\n\t\tleftPanel.add(topPanel, BorderLayout.NORTH);\n\t\tleftPanel.add(usersPanel, BorderLayout.CENTER);\n\t\tuserCertificatePanel.setMinimumSize(new Dimension(375, 10));\n\t\tJLabel statusLabel = new JLabel();\n\t\tstatusLabel.setHorizontalAlignment(SwingConstants.RIGHT);\n\t\tif (X509Utils.unlimitedStrength) {\n\t\t\tstatusLabel.setText(\"JCE Unlimited Strength Jurisdiction Policy\");\n\t\t} else {\n\t\t\tstatusLabel.setText(\"JCE Standard Encryption Policy\");\n\t\t}\n\t\tJPanel root = new JPanel(new BorderLayout()) {\n\t\t\tprivate static final long serialVersionUID = 1L;\n\t\t\tpublic Insets getInsets() {\n\t\t\t\treturn Utils.INSETS;\n\t\t\t}\n\t\t};\n\t\tJSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, userCertificatePanel);\n\t\tsplitPane.setDividerLocation(1d);\n\t\troot.add(splitPane, BorderLayout.CENTER);\n\t\troot.add(statusLabel, BorderLayout.SOUTH);\n\t\treturn root;\n\t}\n"} {"input": " private void hookupKeybindings() {\n input = new SimpleInputMethod();\n input.connect(new InputMethod.Commit() {\n public void onCommit(InputMethod source, String text) {\n insertText(text);\n }\n });\n view.connect(new Widget.KeyPressEvent() {\n public boolean onKeyPressEvent(Widget source, EventKey event) {\n final Keyval key;\n final ModifierType mod;\n if (input.filterKeypress(event)) {\n return true;\n }\n key = event.getKeyval();\n if ((key == Keyval.Up) || (key == Keyval.Right)) {\n if (insertOffset == 0) {\n return false;\n }\n }\n if ((key == Keyval.Down) || (key == Keyval.Left)) {\n if (insertOffset == chain.length()) {\n return false;\n }\n }\n if ((key == Keyval.Home) || (key == Keyval.End) || (key == Keyval.PageUp)\n || (key == Keyval.PageDown) || (key == Keyval.Compose)) {\n return false;\n }\n if ((key == Keyval.F1) || (key == Keyval.F2) || (key == Keyval.F3) || (key == Keyval.F4)\n || (key == Keyval.F5) || (key == Keyval.F6) || (key == Keyval.F7)\n || (key == Keyval.F8) || (key == Keyval.F9) || (key == Keyval.F10)\n || ((key == Keyval.F11) || (key == Keyval.F12))) {\n return false;\n }\n if (key == Keyval.Escape) {\n return true;\n }\n if (key == Keyval.Insert) {\n popupInsertMenu();\n return true;\n }\n if (key == Keyval.Return) {\n insertMarkup = null;\n return false;\n } else if (key == Keyval.Delete) {\n deleteAt();\n return true;\n } else if (key == Keyval.BackSpace) {\n deleteBack();\n return true;\n }\n if (key == Keyval.Menu) {\n return false;\n }\n if ((key == Keyval.ShiftLeft) || (key == Keyval.ShiftRight) || (key == Keyval.AltLeft)\n || (key == Keyval.AltRight) || (key == Keyval.ControlLeft)\n || (key == Keyval.ControlRight) || (key == Keyval.SuperLeft)\n || (key == Keyval.SuperRight)) {\n return false;\n }\n if (key == Keyval.Tab) {\n if (isCodeBlock()) {\n return false;\n } else {\n return true;\n }\n }\n mod = event.getState();\n if ((mod == ModifierType.NONE) || (mod == ModifierType.SHIFT_MASK)) {\n return false;\n }\n if (mod == ModifierType.CONTROL_MASK) {\n if (key == Keyval.a) {\n return false;\n } else if (key == Keyval.b) {\n toggleMarkup(Common.BOLD);\n return true;\n } else if (key == Keyval.c) {\n copyText();\n return true;\n } else if (key == Keyval.g) {\n insertImage();\n return true;\n } else if (key == Keyval.i) {\n toggleMarkup(Common.ITALICS);\n return true;\n } else if (key == Keyval.v) {\n pasteText();\n return true;\n } else if (key == Keyval.x) {\n cutText();\n return true;\n } else {\n return false;\n }\n } else if (mod.contains(ModifierType.CONTROL_MASK)\n && mod.contains(ModifierType.SHIFT_MASK)) {\n if (key == Keyval.Space) {\n clearFormat();\n return true;\n } else if (key == Keyval.A) {\n toggleMarkup(Common.APPLICATION);\n return true;\n } else if (key == Keyval.L) {\n toggleMarkup(Common.LITERAL);\n return true;\n } else if (key == Keyval.F) {\n toggleMarkup(Common.FILENAME);\n return true;\n } else if (key == Keyval.M) {\n toggleMarkup(Common.FUNCTION);\n return true;\n } else if (key == Keyval.O) {\n toggleMarkup(Common.COMMAND);\n return true;\n } else if (key == Keyval.T) {\n toggleMarkup(Common.TYPE);\n return true;\n } else if (key == Keyval.U) {\n return false;\n } else {\n return false;\n }\n } else if (mod == ModifierType.LOCK_MASK) {\n return false;\n }\n throw new IllegalStateException(\"\\n\" + \"Unhandled \" + key + \" with \" + mod);\n }\n });\n view.connect(new Widget.KeyReleaseEvent() {\n public boolean onKeyReleaseEvent(Widget source, EventKey event) {\n if (input.filterKeypress(event)) {\n return true;\n }\n return false;\n }\n });\n }\n", "output": " private void hookupKeybindings() {\n input = new SimpleInputMethod();\n input.connect(new InputMethod.Commit() {\n public void onCommit(InputMethod source, String text) {\n insertText(text);\n }\n });\n view.connect(new Widget.KeyPressEvent() {\n public boolean onKeyPressEvent(Widget source, EventKey event) {\n final Keyval key;\n final ModifierType mod;\n if (input.filterKeypress(event)) {\n return true;\n }\n key = event.getKeyval();\n if ((key == Keyval.Up) || (key == Keyval.Right)) {\n if (insertOffset == 0) {\n return false;\n }\n }\n if ((key == Keyval.Down) || (key == Keyval.Left)) {\n if (insertOffset == chain.length()) {\n return false;\n }\n }\n if ((key == Keyval.Home) || (key == Keyval.End) || (key == Keyval.PageUp)\n || (key == Keyval.PageDown) || (key == Keyval.Compose)) {\n return false;\n }\n if ((key == Keyval.F1) || (key == Keyval.F2) || (key == Keyval.F3) || (key == Keyval.F4)\n || (key == Keyval.F5) || (key == Keyval.F6) || (key == Keyval.F7)\n || (key == Keyval.F8) || (key == Keyval.F9) || (key == Keyval.F10)\n || ((key == Keyval.F11) || (key == Keyval.F12))) {\n return false;\n }\n if (key == Keyval.Escape) {\n return true;\n }\n if (key == Keyval.Insert) {\n popupInsertMenu();\n return true;\n }\n if (key == Keyval.Return) {\n insertMarkup = null;\n insertText(\"\\n\");\n return true;\n } else if (key == Keyval.Delete) {\n deleteAt();\n return true;\n } else if (key == Keyval.BackSpace) {\n deleteBack();\n return true;\n }\n if (key == Keyval.Menu) {\n return false;\n }\n if ((key == Keyval.ShiftLeft) || (key == Keyval.ShiftRight) || (key == Keyval.AltLeft)\n || (key == Keyval.AltRight) || (key == Keyval.ControlLeft)\n || (key == Keyval.ControlRight) || (key == Keyval.SuperLeft)\n || (key == Keyval.SuperRight)) {\n return false;\n }\n if (key == Keyval.Tab) {\n if (isCodeBlock()) {\n return false;\n } else {\n return true;\n }\n }\n mod = event.getState();\n if ((mod == ModifierType.NONE) || (mod == ModifierType.SHIFT_MASK)) {\n return false;\n }\n if (mod == ModifierType.CONTROL_MASK) {\n if (key == Keyval.a) {\n return false;\n } else if (key == Keyval.b) {\n toggleMarkup(Common.BOLD);\n return true;\n } else if (key == Keyval.c) {\n copyText();\n return true;\n } else if (key == Keyval.g) {\n insertImage();\n return true;\n } else if (key == Keyval.i) {\n toggleMarkup(Common.ITALICS);\n return true;\n } else if (key == Keyval.v) {\n pasteText();\n return true;\n } else if (key == Keyval.x) {\n cutText();\n return true;\n } else {\n return false;\n }\n } else if (mod.contains(ModifierType.CONTROL_MASK)\n && mod.contains(ModifierType.SHIFT_MASK)) {\n if (key == Keyval.Space) {\n clearFormat();\n return true;\n } else if (key == Keyval.A) {\n toggleMarkup(Common.APPLICATION);\n return true;\n } else if (key == Keyval.L) {\n toggleMarkup(Common.LITERAL);\n return true;\n } else if (key == Keyval.F) {\n toggleMarkup(Common.FILENAME);\n return true;\n } else if (key == Keyval.M) {\n toggleMarkup(Common.FUNCTION);\n return true;\n } else if (key == Keyval.O) {\n toggleMarkup(Common.COMMAND);\n return true;\n } else if (key == Keyval.T) {\n toggleMarkup(Common.TYPE);\n return true;\n } else if (key == Keyval.U) {\n return false;\n } else {\n return false;\n }\n } else if (mod == ModifierType.LOCK_MASK) {\n return false;\n }\n throw new IllegalStateException(\"\\n\" + \"Unhandled \" + key + \" with \" + mod);\n }\n });\n view.connect(new Widget.KeyReleaseEvent() {\n public boolean onKeyReleaseEvent(Widget source, EventKey event) {\n if (input.filterKeypress(event)) {\n return true;\n }\n return false;\n }\n });\n }\n"} {"input": " public static void main(String[] args) throws Exception{\n \tLOG = LoggerFactory.getLogger(Main.class);\n \tAppProperties.loadProperties();\n String webappDirLocation = \"src/main/webapp/\";\n boolean heroku = false;\n String basedir = (String)System.getProperty(\"basedir\");\n if (basedir != null && basedir.endsWith(\"/app/target\")) {\n heroku = true;\n }\n System.setProperty(\"java.naming.factory.url\",\"org.eclipse.jetty.jndi\");\n\t\tSystem.setProperty(\"java.naming.factory.initial\",\"org.eclipse.jetty.jndi.InitialContextFactory\");\n String webPort = System.getenv(\"PORT\");\n if(webPort == null || webPort.isEmpty()) {\n webPort = \"8080\";\n }\t\t\n Server server = new Server(Integer.valueOf(webPort));\n if(!heroku) {\n \tLOG.info(\"Seems to be running locally, setup some SSL stuff\");\n\t String sslPort = System.getenv(\"SSLPORT\");\n\t if(sslPort == null || sslPort.isEmpty()) {\n\t sslPort = System.getenv(\"SSL_PORT\");\n\t if(sslPort == null || sslPort.isEmpty()) {\n\t sslPort = \"8443\";\n\t }\n\t }\n\t SocketConnector connector = new SocketConnector();\n\t connector.setPort(Integer.valueOf(webPort));\n\t SslSocketConnector sslConnector = new SslSocketConnector();\n\t sslConnector.setPort(Integer.valueOf(sslPort));\n\t sslConnector.setKeyPassword(\"123456\");\n\t sslConnector.setKeystore(\"keystore\");\n\t server.setConnectors(new Connector[] { sslConnector, connector }); \n } else {\n LOG.info(\"Looks like we are running on heroku.\");\n }\n WebAppContext root = new WebAppContext();\n root.setConfigurationClasses(configClasses);\n root.setContextPath(\"/\");\n root.setDescriptor(webappDirLocation+\"/WEB-INF/web.xml\");\n root.setResourceBase(webappDirLocation);\n root.setAttribute(\"mainDS\", getJNDIResource());\n root.setParentLoaderPriority(true);\n server.setHandler(root);\n server.start();\n server.join(); \n }\n", "output": " public static void main(String[] args) throws Exception{\n \tLOG = LoggerFactory.getLogger(Main.class);\n \tAppProperties.loadProperties();\n String webappDirLocation = \"src/main/webapp/\";\n boolean heroku = false;\n String basedir = (String)System.getProperty(\"DATABASE_URL\");\n if (basedir != null) {\n heroku = true;\n }\n System.setProperty(\"java.naming.factory.url\",\"org.eclipse.jetty.jndi\");\n\t\tSystem.setProperty(\"java.naming.factory.initial\",\"org.eclipse.jetty.jndi.InitialContextFactory\");\n String webPort = System.getenv(\"PORT\");\n if(webPort == null || webPort.isEmpty()) {\n webPort = \"8080\";\n }\t\t\n Server server = new Server(Integer.valueOf(webPort));\n if(!heroku) {\n \tLOG.info(\"Seems to be running locally, setup some SSL stuff\");\n\t String sslPort = System.getenv(\"SSLPORT\");\n\t if(sslPort == null || sslPort.isEmpty()) {\n\t sslPort = System.getenv(\"SSL_PORT\");\n\t if(sslPort == null || sslPort.isEmpty()) {\n\t sslPort = \"8443\";\n\t }\n\t }\n\t SocketConnector connector = new SocketConnector();\n\t connector.setPort(Integer.valueOf(webPort));\n\t SslSocketConnector sslConnector = new SslSocketConnector();\n\t sslConnector.setPort(Integer.valueOf(sslPort));\n\t sslConnector.setKeyPassword(\"123456\");\n\t sslConnector.setKeystore(\"keystore\");\n\t server.setConnectors(new Connector[] { sslConnector, connector }); \n } else {\n LOG.info(\"Looks like we are running on heroku.\");\n }\n WebAppContext root = new WebAppContext();\n root.setConfigurationClasses(configClasses);\n root.setContextPath(\"/\");\n root.setDescriptor(webappDirLocation+\"/WEB-INF/web.xml\");\n root.setResourceBase(webappDirLocation);\n root.setAttribute(\"mainDS\", getJNDIResource());\n root.setParentLoaderPriority(true);\n server.setHandler(root);\n server.start();\n server.join(); \n }\n"} {"input": " private ReferencePoint getGripPoint (Drawing drawing) {\n ReferencePoint position = null;\n Collection<ReferencePoint> closePoints = new ArrayList<ReferencePoint>();\n Workspace workspace = br.org.archimedes.Utils.getWorkspace();\n Rectangle modelDrawingArea = workspace.getCurrentViewportArea();\n Rectangle mouseArea = getMouseArea(workspace);\n try {\n Set<Element> closeElements = getViewableElements(drawing,\n modelDrawingArea);\n for (Element element : closeElements) {\n Collection<ReferencePoint> basicReferences = getBasicReferences(\n modelDrawingArea, mouseArea, element);\n Collection<XPoint> intersectionReferences = getIntersectionReferences(\n mouseArea, closeElements, element);\n closePoints.addAll(basicReferences);\n closePoints.addAll(intersectionReferences);\n OrthogonalPoint ortho = getOrthogonalPoint(mouseArea, element);\n if (ortho != null) {\n closePoints.add(ortho);\n }\n }\n position = getClosestPoint(closePoints, mousePosition);\n }\n catch (NullArgumentException e) {\n }\n return position;\n }\n", "output": " private ReferencePoint getGripPoint (Drawing drawing) {\n ReferencePoint position = null;\n Collection<ReferencePoint> closePoints = new ArrayList<ReferencePoint>();\n Workspace workspace = br.org.archimedes.Utils.getWorkspace();\n Rectangle modelDrawingArea = workspace.getCurrentViewportArea();\n Rectangle mouseArea = getMouseArea(workspace);\n try {\n Set<Element> closeElements = getViewableElements(drawing,\n modelDrawingArea);\n for (Element element : closeElements) {\n Collection<ReferencePoint> basicReferences = getBasicReferences(\n modelDrawingArea, mouseArea, element);\n Collection<XPoint> intersectionReferences = getIntersectionReferences(\n mouseArea, closeElements, element);\n closePoints.addAll(basicReferences);\n closePoints.addAll(intersectionReferences);\n OrthogonalPoint ortho = getOrthogonalPoint(mouseArea, element);\n if (ortho != null) {\n closePoints.add(ortho);\n }\n }\n position = getClosestPoint(closePoints, mousePosition);\n }\n catch (NullArgumentException e) {\n e.printStackTrace();\n }\n return position;\n }\n"} {"input": " public static int Run(String args[]) {\n boolean rename = args.length > 1 && (args[1].equals(RenameCmd));\n boolean find = args.length > 1 && (args[1].equals(FindCmd));\n if (args.length < 4 || !CheckArgs(args) || (!rename && !find)) {\n PrintUsage();\n return -1;\n }\n boolean verbose = false;\n String outfile = null;\n List<String> params = new LinkedList<String>();\n for (int ii=2; ii<args.length; ++ii) {\n if (args[ii].equals(\"-o\") && (ii+1)<args.length) {\n outfile = args[++ii];\n if (!rename) {\n System.err.print(\"Warning: invalid argument -o for \"+args[1]+\" command, ignoring: -o \"+outfile);\n outfile = null;\n }\n }\n else if (args[ii].equals(\"-v\"))\n verbose = true;\n else params.add(args[ii]);\n }\n int requiredArgs = rename ? 3 : 2;\n if (params.size() < requiredArgs) {\n PrintUsage();\n return 1;\n }\n if (params.size() > requiredArgs) {\n System.err.print(\"Warning: too many parameters, ignoring:\");\n for (int ii=requiredArgs; ii<params.size(); ++ii)\n System.err.print(\" \"+params.get(ii));\n System.err.println();\n }\n String infile = params.get(0);\n String functionSig = params.get(1);\n String newName = rename ? params.get(2) : null;\n File in = new File(infile);\n File out = outfile!=null ? new File(outfile) : in;\n File temp = null;\n if (rename) {\n int tempCount = 0;\n while (temp == null) {\n temp = new File(out.getParentFile(),out.getName()+String.format(\".temp%04d\",tempCount++));\n if (temp.exists())\n temp = null;\n }\n }\n int status = 0;\n try {\n if (verbose)\n System.out.println(CommandName+\" processing file \"+in.getPath()+\"...\");\n if (rename) {\n copyFile(in,temp);\n JNIRenamer renamer = new JNIRenamer(temp,in.getPath(),false);\n int count = renamer.findRenameFunc(functionSig, newName, System.out,\n verbose ? System.out : null, System.err);\n renamer.close();\n if (count == 0)\n System.err.println(\"ERROR: Found no matches.\");\n if (count > 1)\n System.err.println(String.format(\"Warning: Found and replaced %d matches?!\",count));\n if (count >= 0) {\n if (out.exists() && !out.delete()) {\n System.err.println(\"Error clearing previous output file \"+out.getPath());\n status = -3;\n }\n else if ( !temp.renameTo(out) ) {\n System.err.println(\"Error moving temporary file \"+temp.getPath()+\" to \"+out.getPath());\n status = -3;\n }\n System.out.println(\"Result written to \"+out.getPath());\n } else status = -5;\n }\n else { \n JNIRenamer renamer = new JNIRenamer(in,in.getPath(),true);\n int count = renamer.findRenameFunc(functionSig, newName, System.out,\n verbose ? System.out : null, System.err);\n if (verbose && count == 0)\n System.out.println(\"Found no matches.\");\n if (verbose && count > 1)\n System.out.println(String.format(\"Warning: Found more than one match (%d matches)\",count));\n if (count > 0)\n status = 0;\n else if (count == 0)\n status = 1;\n else \n status = -5;\n }\n } catch (Exception e) {\n System.err.println(\"Error: \"+e.getMessage());\n status = -3;\n } finally {\n if (temp!=null && temp.exists())\n temp.delete();\n }\n return status;\n }\n", "output": " public static int Run(String args[]) {\n boolean rename = args.length > 1 && (args[1].equals(RenameCmd));\n boolean find = args.length > 1 && (args[1].equals(FindCmd));\n if (args.length < 4 || !CheckArgs(args) || (!rename && !find)) {\n PrintUsage();\n return -1;\n }\n boolean verbose = false;\n String outfile = null;\n List<String> params = new LinkedList<String>();\n for (int ii=2; ii<args.length; ++ii) {\n if (args[ii].equals(\"-o\") && (ii+1)<args.length) {\n outfile = args[++ii];\n if (!rename) {\n System.err.println(\"Warning: invalid argument -o for \"+args[1]+\" command, ignoring: -o \"+outfile);\n outfile = null;\n }\n }\n else if (args[ii].equals(\"-v\"))\n verbose = true;\n else params.add(args[ii]);\n }\n int requiredArgs = rename ? 3 : 2;\n if (params.size() < requiredArgs) {\n PrintUsage();\n return 1;\n }\n if (params.size() > requiredArgs) {\n System.err.print(\"Warning: too many parameters, ignoring:\");\n for (int ii=requiredArgs; ii<params.size(); ++ii)\n System.err.print(\" \"+params.get(ii));\n System.err.println();\n }\n String infile = params.get(0);\n String functionSig = params.get(1);\n String newName = rename ? params.get(2) : null;\n File in = new File(infile);\n File out = outfile!=null ? new File(outfile) : in;\n File temp = null;\n if (rename) {\n int tempCount = 0;\n while (temp == null) {\n temp = new File(out.getParentFile(),out.getName()+String.format(\".temp%04d\",tempCount++));\n if (temp.exists())\n temp = null;\n }\n }\n int status = 0;\n try {\n if (verbose)\n System.out.println(CommandName+\" processing file \"+in.getPath()+\"...\");\n if (rename) {\n copyFile(in,temp);\n JNIRenamer renamer = new JNIRenamer(temp,in.getPath(),false);\n int count = renamer.findRenameFunc(functionSig, newName, System.out,\n verbose ? System.out : null, System.err);\n renamer.close();\n if (count == 0)\n System.err.println(\"ERROR: Found no matches.\");\n if (count > 1)\n System.err.println(String.format(\"Warning: Found and replaced %d matches?!\",count));\n if (count >= 0) {\n if (out.exists() && !out.delete()) {\n System.err.println(\"Error clearing previous output file \"+out.getPath());\n status = -3;\n }\n else if ( !temp.renameTo(out) ) {\n System.err.println(\"Error moving temporary file \"+temp.getPath()+\" to \"+out.getPath());\n status = -3;\n }\n System.out.println(\"Result written to \"+out.getPath());\n } else status = -5;\n }\n else { \n JNIRenamer renamer = new JNIRenamer(in,in.getPath(),true);\n int count = renamer.findRenameFunc(functionSig, newName, System.out,\n verbose ? System.out : null, System.err);\n if (verbose && count == 0)\n System.out.println(\"Found no matches.\");\n if (verbose && count > 1)\n System.out.println(String.format(\"Warning: Found more than one match (%d matches)\",count));\n if (count > 0)\n status = 0;\n else if (count == 0)\n status = 1;\n else \n status = -5;\n }\n } catch (Exception e) {\n System.err.println(\"Error: \"+e.getMessage());\n status = -3;\n } finally {\n if (temp!=null && temp.exists())\n temp.delete();\n }\n return status;\n }\n"} {"input": " public void testContainerLaunch() throws IOException {\n String appSubmitter = \"nobody\";\n String cmd = String.valueOf(\n LinuxContainerExecutor.Commands.LAUNCH_CONTAINER.getValue());\n String appId = \"APP_ID\";\n String containerId = \"CONTAINER_ID\";\n Container container = mock(Container.class);\n ContainerId cId = mock(ContainerId.class);\n ContainerLaunchContext context = mock(ContainerLaunchContext.class);\n HashMap<String, String> env = new HashMap<String,String>();\n when(container.getContainerID()).thenReturn(cId);\n when(container.getLaunchContext()).thenReturn(context);\n when(cId.toString()).thenReturn(containerId);\n when(context.getEnvironment()).thenReturn(env);\n Path scriptPath = new Path(\"file:///bin/echo\");\n Path tokensPath = new Path(\"file:///dev/null\");\n Path workDir = new Path(\"/tmp\");\n Path pidFile = new Path(workDir, \"pid.txt\");\n mockExec.activateContainer(cId, pidFile);\n int ret = mockExec.launchContainer(container, scriptPath, tokensPath,\n appSubmitter, appId, workDir);\n assertEquals(0, ret);\n assertEquals(Arrays.asList(appSubmitter, cmd, appId, containerId,\n workDir.toString(), \"/bin/echo\", \"/dev/null\", pidFile),\n readMockParams());\n }\n", "output": " public void testContainerLaunch() throws IOException {\n String appSubmitter = \"nobody\";\n String cmd = String.valueOf(\n LinuxContainerExecutor.Commands.LAUNCH_CONTAINER.getValue());\n String appId = \"APP_ID\";\n String containerId = \"CONTAINER_ID\";\n Container container = mock(Container.class);\n ContainerId cId = mock(ContainerId.class);\n ContainerLaunchContext context = mock(ContainerLaunchContext.class);\n HashMap<String, String> env = new HashMap<String,String>();\n when(container.getContainerID()).thenReturn(cId);\n when(container.getLaunchContext()).thenReturn(context);\n when(cId.toString()).thenReturn(containerId);\n when(context.getEnvironment()).thenReturn(env);\n Path scriptPath = new Path(\"file:///bin/echo\");\n Path tokensPath = new Path(\"file:///dev/null\");\n Path workDir = new Path(\"/tmp\");\n Path pidFile = new Path(workDir, \"pid.txt\");\n mockExec.activateContainer(cId, pidFile);\n int ret = mockExec.launchContainer(container, scriptPath, tokensPath,\n appSubmitter, appId, workDir);\n assertEquals(0, ret);\n assertEquals(Arrays.asList(appSubmitter, cmd, appId, containerId,\n workDir.toString(), \"/bin/echo\", \"/dev/null\", pidFile.toString()),\n readMockParams());\n }\n"} {"input": " public void contextInitialized(ServletContextEvent event) {\n HarvesterServiceLocal harvesterService = null;\n HarvestingDataverseServiceLocal harvestingDataverseService = null;\n try {\n harvesterService=(HarvesterServiceLocal)new InitialContext().lookup(\"java:comp/env/harvesterService\");\n harvestingDataverseService=(HarvestingDataverseServiceLocal)new InitialContext().lookup(\"java:comp/env/harvestingDataverseService\");\n } catch(Exception e) {\n e.printStackTrace();\n }\n try {\n harvestingDataverseService.resetHarvestingStatus(); \n harvesterService.createScheduledHarvestTimers();\n } catch (Exception e) {\n e.printStackTrace();\n }\n VDCNetworkServiceLocal vdcNetworkService=null;\n try {\n System.out.println(\"VDContextListener, scheduling export now....\");\n vdcNetworkService = (VDCNetworkServiceLocal)new InitialContext().lookup(\"java:comp/env/vdcNetworkService\");\n vdcNetworkService.createExportTimer();\n } catch(Exception e) {\n e.printStackTrace();\n }\n }\n", "output": " public void contextInitialized(ServletContextEvent event) {\n HarvesterServiceLocal harvesterService = null;\n HarvestingDataverseServiceLocal harvestingDataverseService = null;\n try {\n harvesterService=(HarvesterServiceLocal)new InitialContext().lookup(\"java:comp/env/harvesterService\");\n harvestingDataverseService=(HarvestingDataverseServiceLocal)new InitialContext().lookup(\"java:comp/env/harvestingDataverseService\");\n } catch(Exception e) {\n e.printStackTrace();\n }\n try {\n harvestingDataverseService.resetHarvestingStatus(); \n harvesterService.createScheduledHarvestTimers();\n } catch (Exception e) {\n e.printStackTrace();\n }\n VDCNetworkServiceLocal vdcNetworkService=null;\n try {\n System.out.println(\"VDContextListener, scheduling export now....\");\n vdcNetworkService = (VDCNetworkServiceLocal)new InitialContext().lookup(\"java:comp/env/vdcNetworkService\");\n vdcNetworkService.updateExportTimer();\n } catch(Exception e) {\n e.printStackTrace();\n }\n }\n"} {"input": "\t\tpublic void bindView(View view, Context context, Cursor cursor) {\n\t\t\tfinal TextView titleView = (TextView) view.findViewById(R.id.title_album);\n\t\t\tfinal TextView subtitleView = (TextView) view.findViewById(R.id.title_artist);\n\t\t\tfinal ImageView imageView = (ImageView) view.findViewById(R.id.list_album_cover);\n\t\t\ttry {\n\t\t\t\tfinal String url = hostUri + \"/image/\" + URLEncoder.encode(cursor.getString(AlbumsQuery.THUMBNAIL), \"UTF-8\");\n\t\t\t\tGlide.load(url)\n\t\t\t\t\t.centerCrop()\n\t\t\t\t\t.animate(android.R.anim.fade_in)\n\t\t\t\t\t.into(imageView);\n\t\t\t} catch (UnsupportedEncodingException e) {\n\t\t\t\tLog.e(TAG, \"Cannot encode \" + cursor.getString(AlbumsQuery.THUMBNAIL) + \" from UTF-8.\");\n\t\t\t}\n\t\t\ttitleView.setText(cursor.getString(AlbumsQuery.TITLE));\n\t\t\tsubtitleView.setText(cursor.getString(AlbumsQuery.ARTIST));\n\t\t}\n", "output": "\t\tpublic void bindView(View view, Context context, Cursor cursor) {\n\t\t\tfinal TextView titleView = (TextView) view.findViewById(R.id.album);\n\t\t\tfinal TextView subtitleView = (TextView) view.findViewById(R.id.artist);\n\t\t\tfinal ImageView imageView = (ImageView) view.findViewById(R.id.list_album_cover);\n\t\t\ttry {\n\t\t\t\tfinal String url = hostUri + \"/image/\" + URLEncoder.encode(cursor.getString(AlbumsQuery.THUMBNAIL), \"UTF-8\");\n\t\t\t\tGlide.load(url)\n\t\t\t\t\t.centerCrop()\n\t\t\t\t\t.animate(android.R.anim.fade_in)\n\t\t\t\t\t.into(imageView);\n\t\t\t} catch (UnsupportedEncodingException e) {\n\t\t\t\tLog.e(TAG, \"Cannot encode \" + cursor.getString(AlbumsQuery.THUMBNAIL) + \" from UTF-8.\");\n\t\t\t}\n\t\t\ttitleView.setText(cursor.getString(AlbumsQuery.TITLE));\n\t\t\tsubtitleView.setText(cursor.getString(AlbumsQuery.ARTIST));\n\t\t}\n"} {"input": "\tprivate AnimData blend(AnimData a, AnimData b) {\n\t\tint overlap = 50;\n\t\tfloat[] blendWeights = new float[overlap];\n\t\tfor (int i=overlap; i>0; i--) {\n\t\t\tblendWeights[overlap - i] = ((float)i) / overlap; \n\t\t}\n\t\tint numBones = a.getNumBones();\n\t\tAnimData blendedData = new AnimData(numBones);\n\t\tVector3f[] boneTrans1 = a.getBoneTransData();\n\t\tVector3f[] boneTrans2 = b.getBoneTransData();\n\t\tint numFrames = boneTrans1.length + boneTrans2.length - overlap;\n\t\tblendedData.setNumFrames(numFrames);\n\t\tVector3f[] blendedTrans = new Vector3f[numFrames];\n\t\tVector3f end = new Vector3f(boneTrans1[boneTrans1.length-1]);\n\t\tVector3f start = boneTrans2[0];\n\t\tend.sub(start);\n\t\tVector3f shift = new Vector3f(end);\n\t\tfor (int i=0; i<boneTrans1.length; i++) {\n\t\t\tblendedTrans[i] = boneTrans1[i];\n\t\t}\n\t\tint k = 0;\n\t\tfor (int i=boneTrans1.length-overlap; i<boneTrans1.length; i++) {\n\t\t\tVector3f vec1 = boneTrans1[i];\n\t\t\tVector3f vec2 = new Vector3f(boneTrans2[k]);\n\t\t\tvec2.add(shift);\n\t\t\tVector3f blend = new Vector3f();\n\t\t\tblend.x = vec1.x * blendWeights[k] + vec2.x * \n\t\t\t\tblendWeights[overlap - k - 1];\n\t\t\tblend.y = vec1.y * blendWeights[k] + vec2.y * \n\t\t\t\tblendWeights[overlap - k - 1];\n\t\t\tblend.z = vec1.z * blendWeights[k] + vec2.z * \n\t\t\t\tblendWeights[overlap - k - 1];\n\t\t\tblendedTrans[i] = blend;\n\t\t\tk++;\n\t\t}\n\t\tfor (int i=k; i<boneTrans2.length; i++) {\n\t\t\tVector3f curr = new Vector3f(boneTrans2[i]);\n\t\t\tcurr.add(shift);\n\t\t\tblendedTrans[i + boneTrans1.length - overlap] = curr;\n\t\t}\n\t\tblendedData.putBoneTransData(blendedTrans);\n\t\tfor (int i=0; i<numBones; i++) {\n\t\t\tQuat4f[] boneRot1 = a.getBoneRotData(i);\n\t\t\tQuat4f[] boneRot2 = b.getBoneRotData(i);\n\t\t\tQuat4f[] boneBlend = new Quat4f[numFrames];\n\t\t\tfor (int j=0; j<boneRot1.length-overlap; j++) {\n\t\t\t\tboneBlend[j] = boneRot1[j];\n\t\t\t}\n\t\t\tk=0;\n\t\t\tfor (int j=boneRot1.length-overlap; j<boneRot1.length; j++) {\n\t\t\t\tQuat4f q1 = new Quat4f(boneRot1[j]);\n\t\t\t\tQuat4f q2 = new Quat4f(boneRot2[k]);\n\t\t\t\tq1.interpolate(q2, 1-blendWeights[k]);\n\t\t\t\tboneBlend[j] = q1;\n\t\t\t\tk++;\n\t\t\t}\n\t\t\tfor (int j=k; j<boneRot2.length; j++) {\n\t\t\t\tQuat4f q = new Quat4f(boneRot2[j]);\n\t\t\t\tboneBlend[boneRot1.length-overlap + j] = q;\n\t\t\t}\n\t\t\tblendedData.putBoneRotData(i, boneBlend);\n\t\t}\n\t\treturn blendedData;\n\t}\n", "output": "\tprivate AnimData blend(AnimData a, AnimData b) {\n\t\tint overlap = 50;\n\t\tfloat[] blendWeights = new float[overlap];\n\t\tfor (int i=overlap; i>0; i--) {\n\t\t\tblendWeights[overlap - i] = ((float)i) / overlap; \n\t\t}\n\t\tint numBones = a.getNumBones();\n\t\tAnimData blendedData = new AnimData(numBones);\n\t\tVector3f[] boneTrans1 = a.getBoneTransData();\n\t\tVector3f[] boneTrans2 = b.getBoneTransData();\n\t\tint numFrames = boneTrans1.length + boneTrans2.length - overlap;\n\t\tblendedData.setNumFrames(numFrames);\n\t\tVector3f[] blendedTrans = new Vector3f[numFrames];\n\t\tVector3f end = new Vector3f(boneTrans1[boneTrans1.length-overlap-1]);\n\t\tVector3f start = boneTrans2[0];\n\t\tend.sub(start);\n\t\tVector3f shift = new Vector3f(end);\n\t\tfor (int i=0; i<boneTrans1.length; i++) {\n\t\t\tblendedTrans[i] = boneTrans1[i];\n\t\t}\n\t\tint k = 0;\n\t\tfor (int i=boneTrans1.length-overlap; i<boneTrans1.length; i++) {\n\t\t\tVector3f vec1 = boneTrans1[i];\n\t\t\tVector3f vec2 = new Vector3f(boneTrans2[k]);\n\t\t\tvec2.add(shift);\n\t\t\tVector3f blend = new Vector3f();\n\t\t\tblend.x = vec1.x * blendWeights[k] + vec2.x * \n\t\t\t\tblendWeights[overlap - k - 1];\n\t\t\tblend.y = vec1.y * blendWeights[k] + vec2.y * \n\t\t\t\tblendWeights[overlap - k - 1];\n\t\t\tblend.z = vec1.z * blendWeights[k] + vec2.z * \n\t\t\t\tblendWeights[overlap - k - 1];\n\t\t\tblendedTrans[i] = blend;\n\t\t\tk++;\n\t\t}\n\t\tfor (int i=k; i<boneTrans2.length; i++) {\n\t\t\tVector3f curr = new Vector3f(boneTrans2[i]);\n\t\t\tcurr.add(shift);\n\t\t\tblendedTrans[i + boneTrans1.length - overlap] = curr;\n\t\t}\n\t\tblendedData.putBoneTransData(blendedTrans);\n\t\tQuat4f qShift = null;\n\t\tQuat4f first = new Quat4f(a.getBoneRotData(0)[a.getNumFrames()-overlap-1]);\n\t\tQuat4f sec = new Quat4f(b.getBoneRotData(0)[0]);\n\t\tqShift = new Quat4f(sec);\n\t\tqShift.inverse();\n\t\tqShift.mul(first);\n\t\tfor (int i=0; i<numBones; i++) {\n\t\t\tQuat4f[] boneRot1 = a.getBoneRotData(i);\n\t\t\tQuat4f[] boneRot2 = b.getBoneRotData(i);\n\t\t\tQuat4f[] boneBlend = new Quat4f[numFrames];\n\t\t\tfor (int j=0; j<boneRot1.length-overlap; j++) {\n\t\t\t\tboneBlend[j] = boneRot1[j];\n\t\t\t}\n\t\t\tk=0;\n\t\t\tfor (int j=boneRot1.length-overlap; j<boneRot1.length; j++) {\n\t\t\t\tQuat4f q1 = new Quat4f(boneRot1[j]);\n\t\t\t\tQuat4f q2 = new Quat4f(boneRot2[k]);\n\t\t\t\tif (i==0) q2.mul(qShift);\n\t\t\t\tq1.interpolate(q2, 1-blendWeights[k]);\n\t\t\t\tboneBlend[j] = q1;\n\t\t\t\tk++;\n\t\t\t}\n\t\t\tfor (int j=k; j<boneRot2.length; j++) {\n\t\t\t\tQuat4f q = new Quat4f(boneRot2[j]);\n\t\t\t\tif (i==0) q.mul(qShift);\n\t\t\t\tboneBlend[boneRot1.length-overlap + j] = q;\n\t\t\t}\n\t\t\tblendedData.putBoneRotData(i, boneBlend);\n\t\t}\n\t\treturn blendedData;\n\t}\n"} {"input": "\tpublic void testWithTwoTypes() {\n\t\tPoiQuery pq = new PoiQuery(\"/101.123245/-56.12/10?t=1,2\");\n\t\tassertEquals(101.123245, pq.getLatitude(), 0);\n\t\tassertEquals(-56.12, pq.getLongitude(), 0);\n\t\tassertEquals(10, pq.getRadius());\n\t\tassertEquals(2, pq.getTypes().size());\n\t\tassertEquals(1, ((Integer) pq.getTypes().get(0)).intValue());\n\t\tassertEquals(2, ((Integer) pq.getTypes().get(1)).intValue());\n\t\tfail(\"test fail to check jenkins\");\n\t}\n", "output": "\tpublic void testWithTwoTypes() {\n\t\tPoiQuery pq = new PoiQuery(\"/101.123245/-56.12/10?t=1,2\");\n\t\tassertEquals(101.123245, pq.getLatitude(), 0);\n\t\tassertEquals(-56.12, pq.getLongitude(), 0);\n\t\tassertEquals(10, pq.getRadius());\n\t\tassertEquals(2, pq.getTypes().size());\n\t\tassertEquals(1, ((Integer) pq.getTypes().get(0)).intValue());\n\t\tassertEquals(2, ((Integer) pq.getTypes().get(1)).intValue());\n\t}\n"} {"input": " public final static String For(ActionEvent evt){\n String label = evt.getActionCommand();\n if (null == Label.For(label)){\n Object source = evt.getSource();\n if (source instanceof AbstractButton){\n return ((ImageIcon)((AbstractButton)source).getIcon()).getDescription();\n }\n }\n return label;\n }\n", "output": " public final static String For(ActionEvent evt){\n String label = evt.getActionCommand();\n if (Label.UNKNOWN == Label.For(label)){\n Object source = evt.getSource();\n if (source instanceof AbstractButton){\n return ((ImageIcon)((AbstractButton)source).getIcon()).getDescription();\n }\n }\n return label;\n }\n"} {"input": " public static JScrollPane getScrollingMenu(\n final MyMenu menu,\n final DefaultListModel dlm,\n final MyList list,\n final Map<MyMenuItem, ButtonCallback> callbackHash) {\n prevScrollingMenuIndex = -1;\n list.setFixedCellHeight(25);\n final int maxSize = dlm.getSize();\n if (maxSize <= 0) {\n return null;\n }\n if (maxSize > 20) {\n list.setVisibleRowCount(20);\n } else {\n list.setVisibleRowCount(maxSize);\n }\n list.addMouseListener(new MouseAdapter() {\n @Override public void mouseExited(final MouseEvent evt) {\n prevScrollingMenuIndex = -1;\n if (callbackHash != null) {\n for (final MyMenuItem item : callbackHash.keySet()) {\n callbackHash.get(item).mouseOut();\n list.clearSelection();\n }\n }\n }\n @Override public void mouseEntered(final MouseEvent evt) {\n list.requestFocus();\n }\n @Override public void mousePressed(final MouseEvent evt) {\n prevScrollingMenuIndex = -1;\n if (callbackHash != null) {\n for (final MyMenuItem item : callbackHash.keySet()) {\n callbackHash.get(item).mouseOut();\n }\n }\n final Thread thread = new Thread(new Runnable() {\n @Override public void run() {\n final int index = list.locationToIndex(evt.getPoint());\n SwingUtilities.invokeLater(new Runnable() {\n @Override public void run() {\n list.setSelectedIndex(index);\n menu.setSelected(false);\n }\n });\n final MyMenuItem item =\n (MyMenuItem) dlm.elementAt(index);\n item.action();\n }\n });\n thread.start();\n }\n });\n list.addMouseMotionListener(new MouseMotionAdapter() {\n @Override public void mouseMoved(final MouseEvent evt) {\n final Thread thread = new Thread(new Runnable() {\n @Override public void run() {\n int pIndex = list.locationToIndex(evt.getPoint());\n if (!list.getCellBounds(pIndex, pIndex).contains(\n evt.getPoint())) {\n pIndex = -1;\n }\n final int index = pIndex;\n final int lastIndex = prevScrollingMenuIndex;\n if (index == lastIndex) {\n return;\n }\n prevScrollingMenuIndex = index;\n SwingUtilities.invokeLater(new Runnable() {\n @Override public void run() {\n list.setSelectedIndex(index);\n }\n });\n if (callbackHash != null) {\n if (lastIndex >= 0) {\n final MyMenuItem lastItem =\n (MyMenuItem) dlm.elementAt(lastIndex);\n callbackHash.get(lastItem).mouseOut();\n }\n if (index >= 0) {\n final MyMenuItem item =\n (MyMenuItem) dlm.elementAt(index);\n callbackHash.get(item).mouseOver();\n }\n }\n }\n });\n thread.start();\n }\n });\n final JScrollPane sp = new JScrollPane(list);\n sp.setViewportBorder(null);\n sp.setBorder(null);\n list.addKeyListener(new KeyAdapter() {\n @Override public void keyTyped(final KeyEvent e) {\n final char ch = e.getKeyChar();\n if (ch == ' ' || ch == '\\n') {\n final MyMenuItem item =\n (MyMenuItem) list.getSelectedValue();\n if (item != null) {\n item.action();\n }\n } else {\n if (Character.isLetterOrDigit(ch)) {\n final Thread t = new Thread(new Runnable() {\n @Override public void run() {\n getGUIData().getMainGlassPane().start(\"\" + ch,\n null,\n true);\n stopProgressIndicator(\"\" + ch);\n }\n });\n t.start();\n }\n }\n }\n });\n return sp;\n }\n", "output": " public static JScrollPane getScrollingMenu(\n final MyMenu menu,\n final DefaultListModel dlm,\n final MyList list,\n final Map<MyMenuItem, ButtonCallback> callbackHash) {\n prevScrollingMenuIndex = -1;\n list.setFixedCellHeight(25);\n final int maxSize = dlm.getSize();\n if (maxSize <= 0) {\n return null;\n }\n if (maxSize > 20) {\n list.setVisibleRowCount(20);\n } else {\n list.setVisibleRowCount(maxSize);\n }\n list.addMouseListener(new MouseAdapter() {\n @Override public void mouseExited(final MouseEvent evt) {\n prevScrollingMenuIndex = -1;\n if (callbackHash != null) {\n for (final MyMenuItem item : callbackHash.keySet()) {\n callbackHash.get(item).mouseOut();\n list.clearSelection();\n }\n }\n }\n @Override public void mouseEntered(final MouseEvent evt) {\n }\n @Override public void mousePressed(final MouseEvent evt) {\n prevScrollingMenuIndex = -1;\n if (callbackHash != null) {\n for (final MyMenuItem item : callbackHash.keySet()) {\n callbackHash.get(item).mouseOut();\n }\n }\n final Thread thread = new Thread(new Runnable() {\n @Override public void run() {\n final int index = list.locationToIndex(evt.getPoint());\n SwingUtilities.invokeLater(new Runnable() {\n @Override public void run() {\n list.setSelectedIndex(index);\n menu.setSelected(false);\n }\n });\n final MyMenuItem item =\n (MyMenuItem) dlm.elementAt(index);\n item.action();\n }\n });\n thread.start();\n }\n });\n list.addMouseMotionListener(new MouseMotionAdapter() {\n @Override public void mouseMoved(final MouseEvent evt) {\n final Thread thread = new Thread(new Runnable() {\n @Override public void run() {\n int pIndex = list.locationToIndex(evt.getPoint());\n if (!list.getCellBounds(pIndex, pIndex).contains(\n evt.getPoint())) {\n pIndex = -1;\n }\n final int index = pIndex;\n final int lastIndex = prevScrollingMenuIndex;\n if (index == lastIndex) {\n return;\n }\n prevScrollingMenuIndex = index;\n SwingUtilities.invokeLater(new Runnable() {\n @Override public void run() {\n list.setSelectedIndex(index);\n }\n });\n if (callbackHash != null) {\n if (lastIndex >= 0) {\n final MyMenuItem lastItem =\n (MyMenuItem) dlm.elementAt(lastIndex);\n callbackHash.get(lastItem).mouseOut();\n }\n if (index >= 0) {\n final MyMenuItem item =\n (MyMenuItem) dlm.elementAt(index);\n callbackHash.get(item).mouseOver();\n }\n }\n }\n });\n thread.start();\n }\n });\n final JScrollPane sp = new JScrollPane(list);\n sp.setViewportBorder(null);\n sp.setBorder(null);\n list.addKeyListener(new KeyAdapter() {\n @Override public void keyTyped(final KeyEvent e) {\n final char ch = e.getKeyChar();\n if (ch == ' ' || ch == '\\n') {\n final MyMenuItem item =\n (MyMenuItem) list.getSelectedValue();\n if (item != null) {\n item.action();\n }\n } else {\n if (Character.isLetterOrDigit(ch)) {\n final Thread t = new Thread(new Runnable() {\n @Override public void run() {\n getGUIData().getMainGlassPane().start(\"\" + ch,\n null,\n true);\n stopProgressIndicator(\"\" + ch);\n }\n });\n t.start();\n }\n }\n }\n });\n return sp;\n }\n"} {"input": " private final void find ( ArrayList < String > pBounded ,\n Expression pExpression )\n {\n for ( Method method : this.getClass ( ).getDeclaredMethods ( ) )\n {\n if ( method.getName ( ).equals (\n FIND + pExpression.getClass ( ).getSimpleName ( ) ) )\n {\n try\n {\n Object [ ] argument = new Object [ 2 ] ;\n argument [ 0 ] = pBounded ;\n argument [ 1 ] = pExpression ;\n method.invoke ( this , argument ) ;\n }\n catch ( IllegalArgumentException e )\n {\n }\n catch ( IllegalAccessException e )\n {\n }\n catch ( InvocationTargetException e )\n {\n }\n return ;\n }\n }\n Enumeration < Expression > children = pExpression.children ( ) ;\n while ( children.hasMoreElements ( ) )\n {\n find ( pBounded , children.nextElement ( ) ) ;\n }\n }\n", "output": " private final void find ( ArrayList < String > pBounded ,\n Expression pExpression )\n {\n for ( Method method : this.getClass ( ).getDeclaredMethods ( ) )\n {\n if ( method.getName ( ).equals (\n FIND + pExpression.getClass ( ).getSimpleName ( ) ) )\n {\n try\n {\n Object [ ] argument = new Object [ 2 ] ;\n argument [ 0 ] = pBounded ;\n argument [ 1 ] = pExpression ;\n method.invoke ( this , argument ) ;\n }\n catch ( IllegalArgumentException e )\n {\n System.err.println ( \"IllegalArgumentException: \" \n + this.getClass ( ).getCanonicalName ( ) + \".\" + FIND \n + pExpression.getClass ( ).getSimpleName ( ) ) ;\n }\n catch ( IllegalAccessException e )\n {\n System.err.println ( \"IllegalAccessException: \" \n + this.getClass ( ).getCanonicalName ( ) + \".\" + FIND \n + pExpression.getClass ( ).getSimpleName ( ) ) ;\n }\n catch ( InvocationTargetException e )\n {\n System.err.println ( \"InvocationTargetException: \" \n + this.getClass ( ).getCanonicalName ( ) + \".\" + FIND \n + pExpression.getClass ( ).getSimpleName ( ) ) ;\n }\n return ;\n }\n }\n Enumeration < Expression > children = pExpression.children ( ) ;\n while ( children.hasMoreElements ( ) )\n {\n find ( pBounded , children.nextElement ( ) ) ;\n }\n }\n"} {"input": " public Construct execute(List<Construct> args, Env env){\n env.SetVarList(new IVariableList());\n CArray array = new CArray(0, null); \n for(String key : originals.keySet()){\n Construct c = originals.get(key);\n env.GetVarList().set(new IVariable(key, c, 0, null));\n array.push(c);\n }\n GenericTree<Construct> root = new GenericTree<Construct>();\n root.setRoot(tree);\n Script fakeScript = new Script(null, null);\n for(int i = 0; i < args.size(); i++){\n Construct c = args.get(i);\n array.set(i, c);\n if(varIndex.size() > i){\n String varname = varIndex.get(i).getName();\n env.GetVarList().set(new IVariable(varname, c, c.getLineNum(), c.getFile()));\n }\n }\n env.GetVarList().set(new IVariable(\"@arguments\", array, 0, null));\n try{\n fakeScript.eval(tree, env);\n } catch(FunctionReturnException e){\n return e.getReturn();\n }\n return new CVoid(0, null);\n }\n", "output": " public Construct execute(List<Construct> args, Env env){\n env.SetVarList(new IVariableList());\n CArray array = new CArray(0, null); \n for(String key : originals.keySet()){\n Construct c = originals.get(key);\n env.GetVarList().set(new IVariable(key, c, 0, null));\n array.push(c);\n }\n GenericTree<Construct> root = new GenericTree<Construct>();\n root.setRoot(tree);\n Script fakeScript = Script.GenerateScript(tree, env.GetLabel());\n for(int i = 0; i < args.size(); i++){\n Construct c = args.get(i);\n array.set(i, c);\n if(varIndex.size() > i){\n String varname = varIndex.get(i).getName();\n env.GetVarList().set(new IVariable(varname, c, c.getLineNum(), c.getFile()));\n }\n }\n env.GetVarList().set(new IVariable(\"@arguments\", array, 0, null));\n try{\n fakeScript.eval(tree, env);\n } catch(FunctionReturnException e){\n return e.getReturn();\n }\n return new CVoid(0, null);\n }\n"} {"input": "\tpublic HypotrochoidParticle(PApplet p, int a, int b, int h, float timeScale, int color, float weight, int fadeLifetime, int lingerLifetime) {\n\t\tsuper(p, new PVector(0,0), new PVector(0,0), 1, 0, 0,\n\t\t\t\t1, color, weight, fadeLifetime, lingerLifetime);\n\t\tpath.remove(0);\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.h = h;\n\t\tthis.adjustedTStepSize = adjustedTStepSize / timeScale;\n\t\tthis.t_limit = b / GCD(a-b,b) * PApplet.TWO_PI;\n\t\tPApplet.println(b / GCD(a-b,b));\n\t\tmove();\n\t\tstartingPos = new PVector(pos.x,pos.y);\n\t}\n", "output": "\tpublic HypotrochoidParticle(PApplet p, int a, int b, int h, float timeScale, int color, float weight, int fadeLifetime, int lingerLifetime) {\n\t\tsuper(p, new PVector(0,0), new PVector(0,0), 1, 0, 0,\n\t\t\t\t1, color, weight, fadeLifetime, lingerLifetime);\n\t\tpath.remove(0);\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.h = h;\n\t\tthis.adjustedTStepSize = adjustedTStepSize * timeScale;\n\t\tthis.t_limit = b / GCD(a-b,b) * PApplet.TWO_PI;\n\t\tPApplet.println(b / GCD(a-b,b));\n\t\tmove();\n\t\tstartingPos = new PVector(pos.x,pos.y);\n\t}\n"} {"input": "\tprivate CompositeImageDescriptor getImageDescriptor(Object object, boolean showActivation) {\n\t\tCompositeImageDescriptor compositeDescriptor = new CompositeImageDescriptor();\n\t\tif (object instanceof TaskArchive) {\n\t\t\tcompositeDescriptor.icon = TasksUiImages.CATEGORY_ARCHIVE;\n\t\t\treturn compositeDescriptor;\n\t\t} else if (object instanceof TaskCategory) {\n\t\t\tcompositeDescriptor.icon = TasksUiImages.CATEGORY;\n\t\t\treturn compositeDescriptor;\n\t\t} else if (object instanceof ITaskListElement) {\n\t\t\tITaskListElement element = (ITaskListElement) object;\n\t\t\tAbstractRepositoryConnectorUi connectorUi = null;\n\t\t\tif (element instanceof AbstractRepositoryTask) {\n\t\t\t\tAbstractRepositoryTask repositoryTask = (AbstractRepositoryTask) element;\n\t\t\t\tconnectorUi = TasksUiPlugin.getRepositoryUi(((AbstractRepositoryTask) element).getRepositoryKind());\n\t\t\t\tcompositeDescriptor.overlayKind = connectorUi.getTaskKindOverlay(repositoryTask);\n\t\t\t\tif (showActivation) {\n\t\t\t\t\tcompositeDescriptor.contextToggle = getContextActivationImage(element);\n\t\t\t\t}\n\t\t\t} else if (element instanceof AbstractQueryHit) {\n\t\t\t\tAbstractRepositoryTask repositoryTask = ((AbstractQueryHit) element).getCorrespondingTask();\n\t\t\t\tif (repositoryTask != null) {\n\t\t\t\t\treturn getImageDescriptor(repositoryTask, showActivation);\n\t\t\t\t}\n\t\t\t} else if (element instanceof AbstractTaskContainer) {\n\t\t\t\tconnectorUi = TasksUiPlugin.getRepositoryUi(((AbstractRepositoryQuery) element).getRepositoryKind());\n\t\t\t}\n\t\t\tif (connectorUi != null) {\n\t\t\t\tcompositeDescriptor.icon = connectorUi.getTaskListElementIcon(element);\n\t\t\t\treturn compositeDescriptor;\n\t\t\t} else {\n\t\t\t\tif (element instanceof ITask) {\n\t\t\t\t\tif (showActivation) {\n\t\t\t\t\t\tcompositeDescriptor.contextToggle = getContextActivationImage(element);\n\t\t\t\t\t}\n\t\t\t\t} else if (element instanceof AbstractQueryHit) {\n\t\t\t\t\tif (showActivation) {\n\t\t\t\t\t\tcompositeDescriptor.contextToggle = getContextActivationImage(element);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (element instanceof ITask || element instanceof AbstractQueryHit) {\n\t\t\t\t}\n\t\t\t\tif (element instanceof AbstractRepositoryQuery) {\n\t\t\t\t\tcompositeDescriptor.icon = TasksUiImages.QUERY;\n\t\t\t\t} else if (element instanceof AbstractQueryHit) {\n\t\t\t\t\tcompositeDescriptor.icon = TasksUiImages.TASK;\n\t\t\t\t} else if (element instanceof ITask) {\n\t\t\t\t\tcompositeDescriptor.icon = TasksUiImages.TASK;\n\t\t\t\t}\n\t\t\t\treturn compositeDescriptor;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tprivate CompositeImageDescriptor getImageDescriptor(Object object, boolean showActivation) {\n\t\tCompositeImageDescriptor compositeDescriptor = new CompositeImageDescriptor();\n\t\tif (object instanceof TaskArchive) {\n\t\t\tcompositeDescriptor.icon = TasksUiImages.CATEGORY_ARCHIVE;\n\t\t\treturn compositeDescriptor;\n\t\t} else if (object instanceof TaskCategory) {\n\t\t\tcompositeDescriptor.icon = TasksUiImages.CATEGORY;\n\t\t\treturn compositeDescriptor;\n\t\t} else if (object instanceof ITaskListElement) {\n\t\t\tITaskListElement element = (ITaskListElement) object;\n\t\t\tAbstractRepositoryConnectorUi connectorUi = null;\n\t\t\tif (element instanceof AbstractRepositoryTask) {\n\t\t\t\tAbstractRepositoryTask repositoryTask = (AbstractRepositoryTask) element;\n\t\t\t\tconnectorUi = TasksUiPlugin.getRepositoryUi(((AbstractRepositoryTask) element).getRepositoryKind());\n\t\t\t\tif (connectorUi != null) {\n\t\t\t\t\tcompositeDescriptor.overlayKind = connectorUi.getTaskKindOverlay(repositoryTask);\n\t\t\t\t}\n\t\t\t\tif (showActivation) {\n\t\t\t\t\tcompositeDescriptor.contextToggle = getContextActivationImage(element);\n\t\t\t\t}\n\t\t\t} else if (element instanceof AbstractQueryHit) {\n\t\t\t\tAbstractRepositoryTask repositoryTask = ((AbstractQueryHit) element).getCorrespondingTask();\n\t\t\t\tif (repositoryTask != null) {\n\t\t\t\t\treturn getImageDescriptor(repositoryTask, showActivation);\n\t\t\t\t}\n\t\t\t} else if (element instanceof AbstractTaskContainer) {\n\t\t\t\tconnectorUi = TasksUiPlugin.getRepositoryUi(((AbstractRepositoryQuery) element).getRepositoryKind());\n\t\t\t}\n\t\t\tif (connectorUi != null) {\n\t\t\t\tcompositeDescriptor.icon = connectorUi.getTaskListElementIcon(element);\n\t\t\t\treturn compositeDescriptor;\n\t\t\t} else {\n\t\t\t\tif (element instanceof ITask) {\n\t\t\t\t\tif (showActivation) {\n\t\t\t\t\t\tcompositeDescriptor.contextToggle = getContextActivationImage(element);\n\t\t\t\t\t}\n\t\t\t\t} else if (element instanceof AbstractQueryHit) {\n\t\t\t\t\tif (showActivation) {\n\t\t\t\t\t\tcompositeDescriptor.contextToggle = getContextActivationImage(element);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (element instanceof ITask || element instanceof AbstractQueryHit) {\n\t\t\t\t}\n\t\t\t\tif (element instanceof AbstractRepositoryQuery) {\n\t\t\t\t\tcompositeDescriptor.icon = TasksUiImages.QUERY;\n\t\t\t\t} else if (element instanceof AbstractQueryHit) {\n\t\t\t\t\tcompositeDescriptor.icon = TasksUiImages.TASK;\n\t\t\t\t} else if (element instanceof ITask) {\n\t\t\t\t\tcompositeDescriptor.icon = TasksUiImages.TASK;\n\t\t\t\t}\n\t\t\t\treturn compositeDescriptor;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": " public Component getListCellRendererComponent(JList list,\n Object value,\n int index,\n boolean isSelected,\n boolean cellHasFocus) {\n _checkBox.setPreferredSize(new Dimension(_checkBox.getPreferredSize().width, 0));\n applyComponentOrientation(list.getComponentOrientation());\n Object actualValue;\n if (list instanceof CheckBoxList) {\n CheckBoxListSelectionModel selectionModel = ((CheckBoxList) list).getCheckBoxListSelectionModel();\n if (selectionModel != null) {\n boolean enabled = list.isEnabled()\n && ((CheckBoxList) list).isCheckBoxEnabled()\n && ((CheckBoxList) list).isCheckBoxEnabled(index);\n if (!enabled && !isSelected) {\n if (getBackground() != null) {\n setForeground(getBackground().darker());\n }\n }\n _checkBox.setEnabled(enabled);\n _checkBox.setSelected(selectionModel.isSelectedIndex(index));\n }\n actualValue = value;\n }\n else if (list instanceof CheckBoxListWithSelectable) {\n if (value instanceof Selectable) {\n _checkBox.setSelected(((Selectable) value).isSelected());\n boolean enabled = list.isEnabled() && ((Selectable) value).isEnabled() && ((CheckBoxListWithSelectable) list).isCheckBoxEnabled();\n if (!enabled && !isSelected) {\n setForeground(getBackground().darker());\n }\n _checkBox.setEnabled(enabled);\n }\n else {\n boolean enabled = list.isEnabled();\n if (!enabled && !isSelected) {\n setForeground(getBackground().darker());\n }\n _checkBox.setEnabled(enabled);\n }\n if (value instanceof DefaultSelectable) {\n actualValue = ((DefaultSelectable) value).getObject();\n }\n else {\n actualValue = value;\n }\n }\n else {\n throw new IllegalArgumentException(\"CheckBoxListCellRenderer should only be used for CheckBoxList.\");\n }\n if (_actualListRenderer != null) {\n JComponent listCellRendererComponent = (JComponent) _actualListRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);\n if (list instanceof CheckBoxList) {\n if (!((CheckBoxList) list).isCheckBoxVisible(index)) {\n return listCellRendererComponent;\n }\n }\n else if (list instanceof CheckBoxListWithSelectable) {\n if (!((CheckBoxListWithSelectable) list).isCheckBoxVisible(index)) {\n return listCellRendererComponent;\n }\n }\n Border border = listCellRendererComponent.getBorder();\n setBorder(border);\n listCellRendererComponent.setBorder(BorderFactory.createEmptyBorder());\n if (getComponentCount() == 2) {\n remove(1);\n }\n add(listCellRendererComponent);\n setBackground(listCellRendererComponent.getBackground());\n setForeground(listCellRendererComponent.getForeground());\n }\n else {\n if (isSelected) {\n setBackground(list.getSelectionBackground());\n setForeground(list.getSelectionForeground());\n }\n else {\n setBackground(list.getBackground());\n setForeground(list.getForeground());\n }\n if (getComponentCount() == 2) {\n remove(1);\n }\n add(_label);\n customizeDefaultCellRenderer(actualValue);\n setFont(list.getFont());\n }\n return this;\n }\n", "output": " public Component getListCellRendererComponent(JList list,\n Object value,\n int index,\n boolean isSelected,\n boolean cellHasFocus) {\n _checkBox.setPreferredSize(new Dimension(_checkBox.getPreferredSize().width, 0));\n applyComponentOrientation(list.getComponentOrientation());\n Object actualValue;\n if (list instanceof CheckBoxList) {\n CheckBoxListSelectionModel selectionModel = ((CheckBoxList) list).getCheckBoxListSelectionModel();\n if (selectionModel != null) {\n boolean enabled = list.isEnabled()\n && ((CheckBoxList) list).isCheckBoxEnabled()\n && ((CheckBoxList) list).isCheckBoxEnabled(index);\n if (!enabled && !isSelected) {\n if (getBackground() != null) {\n setForeground(getBackground().darker());\n }\n }\n _checkBox.setEnabled(enabled);\n _checkBox.setSelected(selectionModel.isSelectedIndex(index));\n }\n actualValue = value;\n }\n else if (list instanceof CheckBoxListWithSelectable) {\n if (value instanceof Selectable) {\n _checkBox.setSelected(((Selectable) value).isSelected());\n boolean enabled = list.isEnabled() && ((Selectable) value).isEnabled() && ((CheckBoxListWithSelectable) list).isCheckBoxEnabled();\n if (!enabled && !isSelected) {\n setForeground(getBackground().darker());\n }\n _checkBox.setEnabled(enabled);\n }\n else {\n boolean enabled = list.isEnabled();\n if (!enabled && !isSelected) {\n setForeground(getBackground().darker());\n }\n _checkBox.setEnabled(enabled);\n }\n if (value instanceof DefaultSelectable) {\n actualValue = ((DefaultSelectable) value).getObject();\n }\n else {\n actualValue = value;\n }\n }\n else {\n throw new IllegalArgumentException(\"CheckBoxListCellRenderer should only be used for CheckBoxList.\");\n }\n if (_actualListRenderer != null) {\n JComponent listCellRendererComponent = (JComponent) _actualListRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);\n if (!cellHasFocus) listCellRendererComponent.setBorder(noFocusBorder);\n if (list instanceof CheckBoxList) {\n if (!((CheckBoxList) list).isCheckBoxVisible(index)) {\n return listCellRendererComponent;\n }\n }\n else if (list instanceof CheckBoxListWithSelectable) {\n if (!((CheckBoxListWithSelectable) list).isCheckBoxVisible(index)) {\n return listCellRendererComponent;\n }\n }\n Border border = listCellRendererComponent.getBorder();\n setBorder(border);\n listCellRendererComponent.setBorder(BorderFactory.createEmptyBorder());\n if (getComponentCount() == 2) {\n remove(1);\n }\n add(listCellRendererComponent);\n setBackground(listCellRendererComponent.getBackground());\n setForeground(listCellRendererComponent.getForeground());\n }\n else {\n if (isSelected) {\n setBackground(list.getSelectionBackground());\n setForeground(list.getSelectionForeground());\n }\n else {\n setBackground(list.getBackground());\n setForeground(list.getForeground());\n }\n if (getComponentCount() == 2) {\n remove(1);\n }\n add(_label);\n customizeDefaultCellRenderer(actualValue);\n setFont(list.getFont());\n }\n return this;\n }\n"} {"input": "\tprivate void bindToViewer(final Tree control) {\n\t\tviewer = new TreeViewer(control);\n\t\tRealm realm = Realm.getDefault();\n\t\tIObservableFactory listFactory = BeansObservables.listFactory(realm, childrenAccessor, treeElementClass);\n\t\tTreeStructureAdvisor structureAdvisor = new GenericTreeStructureAdvisor(parentAccessor, treeElementClass);\n\t\tTreeContentProvider viewerCP = new TreeContentProvider(listFactory, structureAdvisor);\n\t\tviewerCP.getKnownElements().addSetChangeListener(new TreeContentChangeListener(viewerCP, structureAdvisor));\n\t\tviewer.setContentProvider(viewerCP);\n\t\tIObservableMap[] attributeMap = BeansObservables.observeMaps(viewerCP.getKnownElements(), treeElementClass,\n\t\t\t\tvalueAccessors);\n\t\tILabelProvider viewerLP = new TreeRidgetLabelProvider(viewer, attributeMap);\n\t\tviewer.setLabelProvider(viewerLP);\n\t\tif (showRoots) {\n\t\t\tviewer.setInput(treeRoots);\n\t\t} else {\n\t\t\tfinal Object root0 = treeRoots[0];\n\t\t\tfinal String accessor = \"get\" + capitalize(childrenAccessor);\n\t\t\tList root0Children = ReflectionUtils.invoke(root0, accessor);\n\t\t\tfinal List inputList = new ArrayList(root0Children);\n\t\t\tviewer.setInput(inputList);\n\t\t\tPropertyChangeListener listener = new PropertyChangeListener() {\n\t\t\t\tprivate String ACCESSOR = childrenAccessor.toUpperCase();\n\t\t\t\tpublic void propertyChange(PropertyChangeEvent evt) {\n\t\t\t\t\tif (evt.getPropertyName().toUpperCase().endsWith(ACCESSOR)) {\n\t\t\t\t\t\tList root0Children = ReflectionUtils.invoke(root0, accessor);\n\t\t\t\t\t\tinputList.clear();\n\t\t\t\t\t\tfor (Object child : root0Children) {\n\t\t\t\t\t\t\tinputList.add(child);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tviewer.setInput(inputList);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tReflectionUtils.invoke(root0, \"addPropertyChangeListener\", listener);\n\t\t}\n\t}\n", "output": "\tprivate void bindToViewer(final Tree control) {\n\t\tviewer = new TreeViewer(control);\n\t\tRealm realm = Realm.getDefault();\n\t\tIObservableFactory listFactory = BeansObservables.listFactory(realm, childrenAccessor, treeElementClass);\n\t\tTreeStructureAdvisor structureAdvisor = new GenericTreeStructureAdvisor(parentAccessor, treeElementClass);\n\t\tTreeContentProvider viewerCP = new TreeContentProvider(listFactory, structureAdvisor);\n\t\tviewerCP.getKnownElements().addSetChangeListener(new TreeContentChangeListener(viewerCP, structureAdvisor));\n\t\tviewer.setContentProvider(viewerCP);\n\t\tIObservableMap[] attributeMap = BeansObservables.observeMaps(viewerCP.getKnownElements(), treeElementClass,\n\t\t\t\tvalueAccessors);\n\t\tILabelProvider viewerLP = new TreeRidgetLabelProvider(viewer, attributeMap);\n\t\tviewer.setLabelProvider(viewerLP);\n\t\tif (showRoots) {\n\t\t\tviewer.setInput(treeRoots);\n\t\t} else {\n\t\t\tfinal Object root0 = treeRoots[0];\n\t\t\tfinal String accessor = \"get\" + capitalize(childrenAccessor);\n\t\t\tList root0Children = ReflectionUtils.invoke(root0, accessor);\n\t\t\tfinal List inputList = new ArrayList(root0Children);\n\t\t\tviewer.setInput(inputList);\n\t\t\tPropertyChangeListener listener = new PropertyChangeListener() {\n\t\t\t\tprivate String ACCESSOR = childrenAccessor.toUpperCase();\n\t\t\t\tpublic void propertyChange(PropertyChangeEvent evt) {\n\t\t\t\t\tif (evt.getPropertyName().toUpperCase().endsWith(ACCESSOR)) {\n\t\t\t\t\t\tList root0Children = ReflectionUtils.invoke(root0, accessor);\n\t\t\t\t\t\tinputList.clear();\n\t\t\t\t\t\tinputList.addAll(root0Children);\n\t\t\t\t\t\tviewer.refresh();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tReflectionUtils.invoke(root0, \"addPropertyChangeListener\", listener);\n\t\t}\n\t}\n"} {"input": " public UniformInterface getTarget()\n {\n if(this.handler != null)\n {\n return this.handler;\n }\n else\n {\n synchronized(ServerServlet.class)\n {\n String targetAttributeName = getServletConfig().getInitParameter(NAME_TARGET_ATTRIBUTE);\n if(targetAttributeName == null)\n {\n targetAttributeName = getServletContext().getInitParameter(NAME_TARGET_ATTRIBUTE);\n }\n if(targetAttributeName != null)\n {\n this.handler = (UniformInterface)getServletContext().getAttribute(targetAttributeName);\n if(this.handler == null)\n {\n String targetClassName = getServletConfig().getInitParameter(NAME_TARGET_CLASS);\n if(targetClassName == null)\n {\n targetClassName = getServletContext().getInitParameter(NAME_TARGET_CLASS);\n }\n if(targetClassName != null)\n {\n try\n {\n Class targetClass = Class.forName(targetClassName);\n this.handler = (UniformInterface)targetClass.newInstance();\n getServletContext().setAttribute(NAME_TARGET_ATTRIBUTE, this.handler);\n }\n catch(ClassNotFoundException e)\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't find the class. Please check that your classpath includes \" + NAME_TARGET_CLASS);\n }\n catch(InstantiationException e)\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the class. Please check this class has an empty constructor \" + NAME_TARGET_CLASS);\n }\n catch(IllegalAccessException e)\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the class. Please check that you have to proper access rights to \" + NAME_TARGET_CLASS);\n }\n }\n else\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't find the class name of the target handler. Please set the initialization parameter called \" + NAME_TARGET_CLASS);\n }\n }\n }\n else\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't find the attribute name of the target handler. Please set the initialization parameter called \" + NAME_TARGET_ATTRIBUTE);\n }\n }\n return this.handler;\n }\n }\n", "output": " public UniformInterface getTarget()\n {\n if(this.handler != null)\n {\n return this.handler;\n }\n else\n {\n synchronized(ServerServlet.class)\n {\n String targetAttributeName = getServletConfig().getInitParameter(NAME_TARGET_ATTRIBUTE);\n if(targetAttributeName == null)\n {\n targetAttributeName = getServletContext().getInitParameter(NAME_TARGET_ATTRIBUTE);\n }\n if(targetAttributeName != null)\n {\n this.handler = (UniformInterface)getServletContext().getAttribute(targetAttributeName);\n if(this.handler == null)\n {\n String targetClassName = getServletConfig().getInitParameter(NAME_TARGET_CLASS);\n if(targetClassName == null)\n {\n targetClassName = getServletContext().getInitParameter(NAME_TARGET_CLASS);\n }\n if(targetClassName != null)\n {\n try\n {\n Class targetClass = Class.forName(targetClassName);\n this.handler = (UniformInterface)targetClass.newInstance();\n getServletContext().setAttribute(NAME_TARGET_ATTRIBUTE, this.handler);\n }\n catch(ClassNotFoundException e)\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't find the class. Please check that your classpath includes \" + targetClassName);\n }\n catch(InstantiationException e)\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the class. Please check this class has an empty constructor \" + targetClassName);\n }\n catch(IllegalAccessException e)\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't instantiate the class. Please check that you have to proper access rights to \" + targetClassName);\n }\n }\n else\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't find the class name of the target handler. Please set the initialization parameter called \" + NAME_TARGET_CLASS);\n }\n }\n }\n else\n {\n log(\"[Noelios Restlet Engine] - The ServerServlet couldn't find the attribute name of the target handler. Please set the initialization parameter called \" + NAME_TARGET_ATTRIBUTE);\n }\n }\n return this.handler;\n }\n }\n"} {"input": "\tpublic void run() {\n\t\twhile (!shutdown) {\n\t\t\tif (!isEmpty()) {\n\t\t\t\tflowSpace = getFlowMap();\n\t\t\t\tIterator<Entry<Integer, List<FlowEntry>>> it = this.entrySet().iterator();\n\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\tEntry<Integer, List<FlowEntry>> entry = it.next();\n\t\t\t\t\tfor (FlowEntry fentry : entry.getValue()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tFlowSpaceImpl.getProxy().addRule(fentry);\n\t\t\t\t\t\t\tflowSpace.addRule(fentry);\n\t\t\t\t\t\t\tString logMsg = \"User \" + APIUserCred.getUserName() + \n\t\t\t\t\t\t\t\t\tflowspaceAddChangeLogMessage(fentry.getDpid(), \n\t\t\t\t\t\t\t\t\t\t\tfentry.getRuleMatch(), fentry.getPriority(),\n\t\t\t\t\t\t\t\t\t\t\tfentry.getActionsList(), fentry.getName());\n\t\t\t\t\t\t\tFVLog.log(LogLevel.INFO, null, logMsg);\n\t\t\t\t\t\t} catch (ConfigError e) {\n\t\t\t\t\t\t\tFVLog.log(LogLevel.WARN, null, e.getMessage());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tFlowSpaceImpl.getProxy().notifyChange(flowSpace);\n\t\t\t\t\tit.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tThread.sleep(1000);\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\tFVLog.log(LogLevel.DEBUG, null, \"Shutting down FlowSpace handler; exiting.\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void run() {\n\t\twhile (!shutdown) {\n\t\t\tif (!isEmpty()) {\n\t\t\t\tflowSpace = getFlowMap();\n\t\t\t\tIterator<Entry<Integer, List<FlowEntry>>> it = this.entrySet().iterator();\n\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\tEntry<Integer, List<FlowEntry>> entry = it.next();\n\t\t\t\t\tfor (FlowEntry fentry : entry.getValue()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tFlowSpaceImpl.getProxy().addRule(fentry);\n\t\t\t\t\t\t\tflowSpace.addRule(fentry);\n\t\t\t\t\t\t\tString logMsg = \"User \" + APIUserCred.getUserName() + \n\t\t\t\t\t\t\t\t\tflowspaceAddChangeLogMessage(fentry.getDpid(), \n\t\t\t\t\t\t\t\t\t\t\tfentry.getRuleMatch(), fentry.getPriority(),\n\t\t\t\t\t\t\t\t\t\t\tfentry.getActionsList(), fentry.getName());\n\t\t\t\t\t\t\tFVLog.log(LogLevel.INFO, null, logMsg);\n\t\t\t\t\t\t} catch (ConfigError e) {\n\t\t\t\t\t\t\tFVLog.log(LogLevel.WARN, null, e.getMessage());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tFlowSpaceImpl.getProxy().notifyChange(flowSpace);\n\t\t\t\t\tit.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tThread.sleep(200);\n\t\t\t} catch (InterruptedException e) {\n\t\t\t\tFVLog.log(LogLevel.DEBUG, null, \"Shutting down FlowSpace handler; exiting.\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tprivate SVDBExpr assignment_pattern_expr() throws SVParseException {\n\t\tSVDBExpr ret_top;\n\t\tfLexer.readOperator(\"'\");\n\t\tfLexer.readOperator(\"{\");\n\t\tif (fDebugEn) {debug(\" assignmentPattern\");}\n\t\tif (fLexer.peekOperator(\"}\")) {\n\t\t\tfLexer.eatToken();\n\t\t\tret_top = new SVDBConcatenationExpr();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tfEnableNameMappedPrimary = true;\n\t\t\t\tSVDBExpr expr1 = expression();\n\t\t\t\tif (fLexer.peekOperator(\"{\")) {\n\t\t\t\t\tSVDBAssignmentPatternRepeatExpr ret = new SVDBAssignmentPatternRepeatExpr(expr1);\n\t\t\t\t\tfLexer.eatToken(); \n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tSVDBExpr expr = expression();\n\t\t\t\t\t\tret.getPatternList().add(expr);\n\t\t\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t\t\tret_top = ret;\n\t\t\t\t} else {\n\t\t\t\t\tSVDBAssignmentPatternExpr ret = new SVDBAssignmentPatternExpr();\n\t\t\t\t\tret.getPatternList().add(expr1);\n\t\t\t\t\twhile (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\tSVDBExpr expr = expression();\n\t\t\t\t\t\tret.getPatternList().add(expr);\n\t\t\t\t\t}\n\t\t\t\t\tret_top = ret;\n\t\t\t\t}\n\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t} finally {\n\t\t\t\tfEnableNameMappedPrimary = false;\n\t\t\t}\n\t\t}\n\t\treturn ret_top;\n\t}\n\tpublic SVDBExpr primary() throws SVParseException {\n\t\tif (fDebugEn) {debug(\"--> primary() - \" + fLexer.peek());}\n\t\tSVDBExpr ret = null;\n\t\tif (peekOperator(\"(\")) {\n\t\t\tif (fDebugEn) {debug(\" Found paren in primary\");}\n\t\t\tfLexer.eatToken();\n\t\t\tSVDBExpr a = expression();\n\t\t\tif (fLexer.peekOperator(\":\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tSVDBExpr expr = fParsers.exprParser().expression();\n\t\t\t\tif (fLexer.peekOperator(\":\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\texpr = fParsers.exprParser().expression();\n\t\t\t\t}\n\t\t\t}\n\t\t\treadOperator(\")\");\n\t\t\tpeek();\n\t\t\tif (fLexer.isNumber() || fLexer.isIdentifier() ||\n\t\t\t\t\tpeekOperator(\"(\", \"~\", \"!\") ||\n\t\t\t\t\tpeekKeyword(\"this\", \"super\", \"new\")) {\n\t\t\t\tret = new SVDBCastExpr(a, unaryExpression());\n\t\t\t} else {\n\t\t\t\tret = new SVDBParenExpr(a);\n\t\t\t}\n\t\t} else {\n\t\t\tfLexer.peek();\n\t\t\tif (fLexer.isNumber()) {\n\t\t\t\tif (fDebugEn) {debug(\"-- primary is a number\");}\n\t\t\t\tSVToken tmp = fLexer.consumeToken();\n\t\t\t\tif (fEnableNameMappedPrimary && fLexer.peekOperator(\":\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tret = new SVDBNameMappedExpr(tmp.getImage(), expression());\n\t\t\t\t} else {\n\t\t\t\t\tret = new SVDBLiteralExpr(tmp.getImage());\n\t\t\t\t}\n\t\t\t} else if (fLexer.peekOperator(\"$\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBRangeDollarBoundExpr();\n\t\t\t} else if (fLexer.peekString()) {\n\t\t\t\tif (fDebugEn) {debug(\"-- primary is a string\");}\n\t\t\t\tSVToken tmp = fLexer.consumeToken();\n\t\t\t\tif (fEnableNameMappedPrimary && fLexer.peekOperator(\":\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tret = new SVDBNameMappedExpr(tmp.getImage(), expression());\n\t\t\t\t} else {\n\t\t\t\t\tret = new SVDBStringExpr(tmp.getImage());\n\t\t\t\t}\n\t\t\t} else if (fLexer.peekKeyword(\"null\")) {\n\t\t\t\tif (fDebugEn) {debug(\"-- primary is 'null'\");}\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBNullExpr();\n\t\t\t} else if (fLexer.isIdentifier() || \n\t\t\t\t\tSVKeywords.isBuiltInType(fLexer.peek()) ||\n\t\t\t\t\tfLexer.peekKeyword(\"new\",\"default\",\"local\")) {\n\t\t\t\tif (fDebugEn) {\n\t\t\t\t\tdebug(\" primary \\\"\" + fLexer.getImage() + \"\\\" is identifier or built-in type\");\n\t\t\t\t}\n\t\t\t\tString id = fLexer.eatToken();\n\t\t\t\tif (fLexer.peekOperator(\"(*\")) {\n\t\t\t\t\tfParsers.attrParser().parse(null);\n\t\t\t\t}\n\t\t\t\tif (peekOperator(\"#\")) {\n\t\t\t\t\tret = new SVDBParamIdExpr(id);\n\t\t\t\t\tfLexer.eatToken(); \n\t\t\t\t\tfLexer.readOperator(\"(\");\n\t\t\t\t\twhile (fLexer.peek() != null) {\n\t\t\t\t\t\t((SVDBParamIdExpr)ret).addParamExpr(datatype_or_expression());\n\t\t\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\")\");\n\t\t\t\t} else if (fLexer.peekOperator(\"(\") || fLexer.peekKeyword(\"with\")) {\n\t\t\t\t\tif (id.equals(\"randomize\")) {\n\t\t\t\t\t\tret = randomize_call(null);\n\t\t\t\t\t} else if (fLexer.peekOperator(\"(\")) {\n\t\t\t\t\t\tret = tf_args_call(null, id);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tret = tf_noargs_with_call(null, id);\n\t\t\t\t\t}\n\t\t\t\t} else if (id.equals(\"new\")) {\n\t\t\t\t\tret = ctor_call();\n\t\t\t\t} else if (fLexer.peekKeyword(SVKeywords.fBuiltinDeclTypes)) {\n\t\t\t\t\tfLexer.startCapture();\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tif (fLexer.peekKeyword(\"signed\",\"unsigned\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t}\n\t\t\t\t\tret = new SVDBIdentifierExpr(fLexer.endCapture());\n\t\t\t\t} else {\n\t\t\t\t\tif (fEnableNameMappedPrimary && fLexer.peekOperator(\":\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\tif (fDebugEn) {debug(\" nameMappedExpr\");}\n\t\t\t\t\t\tret = new SVDBNameMappedExpr(id, expression());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tret = new SVDBIdentifierExpr(id);\n\t\t\t\t\t}\n\t\t\t\t\tif (fDebugEn) {debug(\" after id-read: \" + peek());}\n\t\t\t\t}\n\t\t\t} else if (fLexer.peekOperator(\"{\")) {\n\t\t\t\tret = concatenation_or_repetition();\n\t\t\t} else if (peekKeyword(\"this\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBIdentifierExpr(\"this\");\n\t\t\t} else if (peekKeyword(\"super\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBIdentifierExpr(\"super\");\n\t\t\t} else if (peekKeyword(\"void\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBIdentifierExpr(\"void\");\n\t\t\t} else if (fEventExpr.peek() && fLexer.peekOperator(\"@\")) {\n\t\t\t\tret = clocking_event();\n\t\t\t} else if (fEventExpr.peek() && fLexer.peekOperator(\"##\")) {\n\t\t\t\tret = cycle_delay();\n\t\t\t} else {\n\t\t\t\terror(\"Unexpected token in primary: \\\"\" + fLexer.getImage() + \"\\\"\");\n\t\t\t}\n\t\t}\n\t\tif (fDebugEn) {debug(\"<-- primary() \");}\n\t\treturn ret;\n\t}\n\tprivate SVDBExpr concatenation_or_repetition() throws SVParseException {\n\t\tSVDBExpr expr = null;\n\t\tif (fDebugEn) {debug(\"--> concatenation_or_repetition()\");}\n\t\treadOperator(\"{\");\n\t\tif (peekOperator(\"}\")) {\n\t\t\tfLexer.eatToken();\n\t\t\texpr = new SVDBConcatenationExpr();\n\t\t} else if (peekOperator(\"<<\", \">>\")) {\n\t\t\tif (fDebugEn) {debug(\"streaming operator\");}\n\t\t\tfLexer.eatToken();\n\t\t\tif (fLexer.peekKeyword(SVKeywords.fBuiltinTypes)) {\n\t\t\t\texpr = new SVDBTypeExpr(fParsers.dataTypeParser().data_type(0));\n\t\t\t} else if (!fLexer.peekOperator(\"{\")) {\n\t\t\t\texpr = new SVDBLiteralExpr(fLexer.eatToken());\n\t\t\t}\n\t\t\tif (fDebugEn) {debug(\"post-datatype: \" + fLexer.peek());}\n\t\t\tfLexer.readOperator(\"{\");\n\t\t\twhile (fLexer.peek() != null) {\n\t\t\t\texpression();\n\t\t\t\tif (fDebugEn) {debug(\"pre-with: \" + fLexer.peek());}\n\t\t\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tfLexer.readOperator(\"[\");\n\t\t\t\t\texpression();\n\t\t\t\t\tif (fLexer.peekOperator(\":\", \"+:\", \"-:\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\texpression();\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"]\");\n\t\t\t\t}\n\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfLexer.readOperator(\"}\");\n\t\t\tfLexer.readOperator(\"}\");\n\t\t\texpr = new SVDBConcatenationExpr();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tSVDBExpr expr0 = expression();\n\t\t\t\tif (fLexer.peekOperator(\"{\")) {\n\t\t\t\t\tif (fDebugEn) {debug(\"repetition\");}\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tSVDBAssignmentPatternRepeatExpr ret = new SVDBAssignmentPatternRepeatExpr(expr);\n\t\t\t\t\tret.setRepeatExpr(expr0);\n\t\t\t\t\twhile (fLexer.peek() != null) {\n\t\t\t\t\t\tret.getPatternList().add(expression());\n\t\t\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"}\"); \n\t\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t\t\texpr = ret;\n\t\t\t\t} else {\n\t\t\t\t\tif (fDebugEn) {debug(\"concatenation\");}\n\t\t\t\t\tSVDBConcatenationExpr ret = new SVDBConcatenationExpr();\n\t\t\t\t\tret.getElements().add(expr0);\n\t\t\t\t\twhile (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\tret.getElements().add(expression());\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t\t\texpr = ret;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t}\n\t\t}\n\t\tif (fDebugEn) {debug(\"<-- concatenation_or_repetition()\");}\n\t\treturn expr;\n\t}\n\tpublic List<SVDBExpr> arguments() throws SVParseException {\n\t\tif (fDebugEn) {debug(\"--> arguments()\");}\n\t\treadOperator(\"(\");\n\t\tif (peekOperator(\")\")) {\n\t\t\tfLexer.eatToken();\n\t\t\treturn new ArrayList<SVDBExpr>();\n\t\t}\n\t\tList<SVDBExpr> arguments = argumentList();\n\t\treadOperator(\")\");\n\t\tif (fDebugEn) {debug(\"<-- arguments()\");}\n\t\treturn arguments;\n\t}\n\tprivate List<SVDBExpr> argumentList() throws SVParseException {\n\t\tList<SVDBExpr> arguments = new ArrayList<SVDBExpr>();\n\t\tif (fDebugEn) {debug(\"--> argumentList()\");}\n\t\tfor (;;) {\n\t\t\tif (peekOperator(\".\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tSVDBNamedArgExpr arg_expr = new SVDBNamedArgExpr();\n\t\t\t\tString name = readIdentifier();\n\t\t\t\targ_expr.setArgName(name);\n\t\t\t\treadOperator(\"(\");\n\t\t\t\tif (fLexer.peekOperator(\")\")) {\n\t\t\t\t\targ_expr.setExpr(new SVDBLiteralExpr(\"\"));\n\t\t\t\t} else {\n\t\t\t\t\targ_expr.setExpr(expression());\n\t\t\t\t}\n\t\t\t\treadOperator(\")\");\n\t\t\t\targuments.add(arg_expr);\n\t\t\t} else if (peekOperator(\",\", \")\")) {\n\t\t\t\targuments.add(new SVDBLiteralExpr(\"\"));\n\t\t\t} else {\n\t\t\t\targuments.add(expression());\n\t\t\t}\n\t\t\tif (peekOperator(\",\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (fDebugEn) {debug(\"<-- argumentList()\");}\n\t\treturn arguments;\n\t}\n\tpublic SVDBExpr selector(SVDBExpr expr) throws SVParseException {\n\t\tif (fDebugEn) {debug(\"--> selector()\");}\n\t\tif (peekOperator(\".\", \"::\")) {\n\t\t\tString q = fLexer.eatToken();\n\t\t\tfLexer.peek();\n\t\t\tif (fLexer.isIdentifier() || peekKeyword(\"new\", \"super\", \"this\")) {\n\t\t\t\tString id = fLexer.eatToken();\n\t\t\t\tif (fLexer.peekOperator(\"(*\")) {\n\t\t\t\t\tfParsers.attrParser().parse(null);\n\t\t\t\t}\n\t\t\t\tif (fLexer.peekOperator(\"(\") || fLexer.peekKeyword(\"with\")) {\n\t\t\t\t\tif (id.equals(\"randomize\")) {\n\t\t\t\t\t\treturn randomize_call(expr);\n\t\t\t\t\t} else if (fLexer.peekOperator(\"(\")){\n\t\t\t\t\t\treturn tf_args_call(expr, id);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn tf_noargs_with_call(expr, id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (fDebugEn) {debug(\"<-- selector()\");}\n\t\t\t\treturn new SVDBFieldAccessExpr(expr, (q.equals(\"::\")), \n\t\t\t\t\t\tnew SVDBIdentifierExpr(id));\n\t\t\t}\n\t\t}\n\t\tif (peekOperator(\"[\")) {\n\t\t\tif (fDebugEn) {debug(\"primary() -- operator \" + fLexer.peek());}\n\t\t\tfLexer.eatToken();\n\t\t\tSVDBExpr low = expression();\n\t\t\tSVDBExpr high = null;\n\t\t\tif (peekOperator(\":\", \"+:\", \"-:\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\thigh = expression();\n\t\t\t}\n\t\t\treadOperator(\"]\");\n\t\t\tif (expr == null) {\n\t\t\t\terror(\"array expr == null\");\n\t\t\t}\n\t\t\tif (fDebugEn) {debug(\"<-- selector()\");}\n\t\t\treturn new SVDBArrayAccessExpr(expr, low, high);\n\t\t}\n\t\terror(\"Unexpected token \\\"\" + fLexer.getImage() + \"\\\"\");\n\t\treturn null; \n\t}\n\tprivate SVDBRandomizeCallExpr randomize_call(SVDBExpr target) throws SVParseException {\n\t\tList<SVDBExpr> arguments = null;\n\t\tSVDBRandomizeCallExpr rand_call = null;\n\t\tfAssertionExpr.push(false);\n\t\tfEventExpr.push(false);\n\t\ttry {\n\t\t\tif (fLexer.peekOperator(\"(\")) {\n\t\t\t\targuments = arguments();\n\t\t\t}\n\t\t\trand_call = new SVDBRandomizeCallExpr(target, \"randomize\", arguments);\n\t\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\trand_call.setWithBlock(fParsers.constraintParser().constraint_set(true));\n\t\t\t}\n\t\t} finally {\n\t\t\tfAssertionExpr.pop();\n\t\t\tfEventExpr.pop();\n\t\t}\n\t\treturn rand_call;\n\t}\n\tprivate SVDBTFCallExpr tf_args_call(SVDBExpr target, String id) throws SVParseException {\n\t\tSVDBTFCallExpr tf = new SVDBTFCallExpr(target, id, arguments());\n\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\tfLexer.eatToken();\n\t\t\tfLexer.readOperator(\"(\");\n\t\t\ttf.setWithExpr(expression());\n\t\t\tfLexer.readOperator(\")\");\n\t\t}\n\t\treturn tf;\n\t}\n\tprivate SVDBTFCallExpr tf_noargs_with_call(SVDBExpr target, String id) throws SVParseException {\n\t\tSVDBTFCallExpr tf = new SVDBTFCallExpr(target, id, null);\n\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\tfLexer.eatToken();\n\t\t\tif (fLexer.peekOperator(\"[\")) {\n\t\t\t\tfLexer.readOperator(\"[\");\n\t\t\t\ttf.setWithExpr(expression());\n\t\t\t\tif (fLexer.peekOperator(\":\", \"+:\",\"-:\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\texpression();\n\t\t\t\t}\n\t\t\t\tfLexer.readOperator(\"]\");\n\t\t\t} else {\n\t\t\t\tfLexer.readOperator(\"(\");\n\t\t\t\ttf.setWithExpr(expression());\n\t\t\t\tfLexer.readOperator(\")\");\n\t\t\t}\n\t\t}\n\t\treturn tf; \n\t}\n\tprivate SVDBCtorExpr ctor_call() throws SVParseException {\n\t\tif (fDebugEn) {\n\t\t\tdebug(\"--> ctor_call()\");\n\t\t}\n\t\tSVDBCtorExpr ctor = new SVDBCtorExpr();\n\t\tif (fLexer.peekOperator(\"[\")) {\n\t\t\tfLexer.readOperator(\"[\");\n\t\t\tctor.setCtorType(CtorType.CtorType_Dim);\n\t\t\tctor.setArg(expression());\n\t\t\tfLexer.readOperator(\"]\");\n\t\t}\n\t\tif (fLexer.peekOperator(\"(\")) {\n\t\t\tctor.setCtorType(CtorType.CtorType_Args);\n\t\t\tctor.setArgs(arguments());\n\t\t} else if (fLexer.peekKeyword() || fLexer.peekId()) {\n\t\t\tctor.setCtorType(CtorType.CtorType_Expr);\n\t\t\tctor.setArg(expression());\n\t\t}\n\t\tif (fDebugEn) {\n\t\t\tdebug(\"--> ctor_call()\");\n\t\t}\n\t\treturn ctor;\n\t}\n\tprivate String peek() throws SVParseException {\n\t\treturn fLexer.peek();\n\t}\n\tprivate boolean peekOperator(String ... ops) throws SVParseException {\n\t\treturn fLexer.peekOperator(ops);\n\t}\n\tprivate String readOperator(String ... ops) throws SVParseException {\n\t\treturn fLexer.readOperator(ops);\n\t}\n\tprivate boolean peekKeyword(String ... kw) throws SVParseException {\n\t\treturn fLexer.peekKeyword(kw);\n\t}\n\tprivate String readKeyword(String ... kw) throws SVParseException {\n\t\treturn fLexer.readKeyword(kw);\n\t}\n\tprivate String readIdentifier() throws SVParseException {\n\t\treturn fLexer.readId();\n\t}\n\tpublic SVDBIdentifierExpr idExpr() throws SVParseException {\n\t\tSVDBLocation start = fLexer.getStartLocation();\n\t\tSVDBIdentifierExpr ret = new SVDBIdentifierExpr(fLexer.readId());\n\t\tret.setLocation(start);\n\t\treturn ret;\n\t}\n\tpublic SVDBLiteralExpr literalExpr() throws SVParseException {\n\t\tSVDBLocation start = fLexer.getStartLocation();\n\t\tSVDBLiteralExpr ret = new SVDBLiteralExpr(fLexer.readNumber());\n\t\tret.setLocation(start);\n\t\treturn ret;\n\t}\n}\n", "output": "\tprivate SVDBExpr assignment_pattern_expr() throws SVParseException {\n\t\tSVDBExpr ret_top;\n\t\tfLexer.readOperator(\"'\");\n\t\tfLexer.readOperator(\"{\");\n\t\tif (fDebugEn) {debug(\" assignmentPattern\");}\n\t\tif (fLexer.peekOperator(\"}\")) {\n\t\t\tfLexer.eatToken();\n\t\t\tret_top = new SVDBConcatenationExpr();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tfEnableNameMappedPrimary = true;\n\t\t\t\tSVDBExpr expr1 = expression();\n\t\t\t\tif (fLexer.peekOperator(\"{\")) {\n\t\t\t\t\tSVDBAssignmentPatternRepeatExpr ret = new SVDBAssignmentPatternRepeatExpr(expr1);\n\t\t\t\t\tfLexer.eatToken(); \n\t\t\t\t\twhile (true) {\n\t\t\t\t\t\tSVDBExpr expr = expression();\n\t\t\t\t\t\tret.getPatternList().add(expr);\n\t\t\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t\t\tret_top = ret;\n\t\t\t\t} else {\n\t\t\t\t\tSVDBAssignmentPatternExpr ret = new SVDBAssignmentPatternExpr();\n\t\t\t\t\tret.getPatternList().add(expr1);\n\t\t\t\t\twhile (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\tSVDBExpr expr = expression();\n\t\t\t\t\t\tret.getPatternList().add(expr);\n\t\t\t\t\t}\n\t\t\t\t\tret_top = ret;\n\t\t\t\t}\n\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t} finally {\n\t\t\t\tfEnableNameMappedPrimary = false;\n\t\t\t}\n\t\t}\n\t\treturn ret_top;\n\t}\n\tpublic SVDBExpr primary() throws SVParseException {\n\t\tif (fDebugEn) {debug(\"--> primary() - \" + fLexer.peek());}\n\t\tSVDBExpr ret = null;\n\t\tif (peekOperator(\"(\")) {\n\t\t\tif (fDebugEn) {debug(\" Found paren in primary\");}\n\t\t\tfLexer.eatToken();\n\t\t\tSVDBExpr a = expression();\n\t\t\tif (fLexer.peekOperator(\":\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tSVDBExpr expr = fParsers.exprParser().expression();\n\t\t\t\tif (fLexer.peekOperator(\":\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\texpr = fParsers.exprParser().expression();\n\t\t\t\t}\n\t\t\t}\n\t\t\treadOperator(\")\");\n\t\t\tpeek();\n\t\t\tif (fLexer.isNumber() || fLexer.isIdentifier() ||\n\t\t\t\t\tpeekOperator(\"(\", \"~\", \"!\") ||\n\t\t\t\t\tpeekKeyword(\"this\", \"super\", \"new\")) {\n\t\t\t\tret = new SVDBCastExpr(a, unaryExpression());\n\t\t\t} else {\n\t\t\t\tret = new SVDBParenExpr(a);\n\t\t\t}\n\t\t} else {\n\t\t\tfLexer.peek();\n\t\t\tif (fLexer.isNumber()) {\n\t\t\t\tif (fDebugEn) {debug(\"-- primary is a number\");}\n\t\t\t\tSVToken tmp = fLexer.consumeToken();\n\t\t\t\tif (fEnableNameMappedPrimary && fLexer.peekOperator(\":\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tret = new SVDBNameMappedExpr(tmp.getImage(), expression());\n\t\t\t\t} else {\n\t\t\t\t\tret = new SVDBLiteralExpr(tmp.getImage());\n\t\t\t\t}\n\t\t\t} else if (fLexer.peekOperator(\"$\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBRangeDollarBoundExpr();\n\t\t\t} else if (fLexer.peekString()) {\n\t\t\t\tif (fDebugEn) {debug(\"-- primary is a string\");}\n\t\t\t\tSVToken tmp = fLexer.consumeToken();\n\t\t\t\tif (fEnableNameMappedPrimary && fLexer.peekOperator(\":\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tret = new SVDBNameMappedExpr(tmp.getImage(), expression());\n\t\t\t\t} else {\n\t\t\t\t\tret = new SVDBStringExpr(tmp.getImage());\n\t\t\t\t}\n\t\t\t} else if (fLexer.peekKeyword(\"null\")) {\n\t\t\t\tif (fDebugEn) {debug(\"-- primary is 'null'\");}\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBNullExpr();\n\t\t\t} else if (fLexer.isIdentifier() || \n\t\t\t\t\tSVKeywords.isBuiltInType(fLexer.peek()) ||\n\t\t\t\t\tfLexer.peekKeyword(\"new\",\"default\",\"local\")) {\n\t\t\t\tif (fDebugEn) {\n\t\t\t\t\tdebug(\" primary \\\"\" + fLexer.getImage() + \"\\\" is identifier or built-in type\");\n\t\t\t\t}\n\t\t\t\tString id = fLexer.eatToken();\n\t\t\t\tif (fLexer.peekOperator(\"(*\")) {\n\t\t\t\t\tfParsers.attrParser().parse(null);\n\t\t\t\t}\n\t\t\t\tif (peekOperator(\"#\")) {\n\t\t\t\t\tif (fDebugEn) {\n\t\t\t\t\t\tdebug(\"Parameterized identifier\");\n\t\t\t\t\t}\n\t\t\t\t\tret = new SVDBParamIdExpr(id);\n\t\t\t\t\tfLexer.eatToken(); \n\t\t\t\t\tfLexer.readOperator(\"(\");\n\t\t\t\t\twhile (fLexer.peek() != null && !fLexer.peekOperator(\")\")) {\n\t\t\t\t\t\t((SVDBParamIdExpr)ret).addParamExpr(datatype_or_expression());\n\t\t\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\")\");\n\t\t\t\t} else if (fLexer.peekOperator(\"(\") || fLexer.peekKeyword(\"with\")) {\n\t\t\t\t\tif (id.equals(\"randomize\")) {\n\t\t\t\t\t\tret = randomize_call(null);\n\t\t\t\t\t} else if (fLexer.peekOperator(\"(\")) {\n\t\t\t\t\t\tret = tf_args_call(null, id);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tret = tf_noargs_with_call(null, id);\n\t\t\t\t\t}\n\t\t\t\t} else if (id.equals(\"new\")) {\n\t\t\t\t\tret = ctor_call();\n\t\t\t\t} else if (fLexer.peekKeyword(SVKeywords.fBuiltinDeclTypes)) {\n\t\t\t\t\tfLexer.startCapture();\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tif (fLexer.peekKeyword(\"signed\",\"unsigned\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t}\n\t\t\t\t\tret = new SVDBIdentifierExpr(fLexer.endCapture());\n\t\t\t\t} else {\n\t\t\t\t\tif (fEnableNameMappedPrimary && fLexer.peekOperator(\":\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\tif (fDebugEn) {debug(\" nameMappedExpr\");}\n\t\t\t\t\t\tret = new SVDBNameMappedExpr(id, expression());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tret = new SVDBIdentifierExpr(id);\n\t\t\t\t\t}\n\t\t\t\t\tif (fDebugEn) {debug(\" after id-read: \" + peek());}\n\t\t\t\t}\n\t\t\t} else if (fLexer.peekOperator(\"{\")) {\n\t\t\t\tret = concatenation_or_repetition();\n\t\t\t} else if (peekKeyword(\"this\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBIdentifierExpr(\"this\");\n\t\t\t} else if (peekKeyword(\"super\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBIdentifierExpr(\"super\");\n\t\t\t} else if (peekKeyword(\"void\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tret = new SVDBIdentifierExpr(\"void\");\n\t\t\t} else if (fEventExpr.peek() && fLexer.peekOperator(\"@\")) {\n\t\t\t\tret = clocking_event();\n\t\t\t} else if (fEventExpr.peek() && fLexer.peekOperator(\"##\")) {\n\t\t\t\tret = cycle_delay();\n\t\t\t} else {\n\t\t\t\terror(\"Unexpected token in primary: \\\"\" + fLexer.getImage() + \"\\\"\");\n\t\t\t}\n\t\t}\n\t\tif (fDebugEn) {debug(\"<-- primary() \");}\n\t\treturn ret;\n\t}\n\tprivate SVDBExpr concatenation_or_repetition() throws SVParseException {\n\t\tSVDBExpr expr = null;\n\t\tif (fDebugEn) {debug(\"--> concatenation_or_repetition()\");}\n\t\treadOperator(\"{\");\n\t\tif (peekOperator(\"}\")) {\n\t\t\tfLexer.eatToken();\n\t\t\texpr = new SVDBConcatenationExpr();\n\t\t} else if (peekOperator(\"<<\", \">>\")) {\n\t\t\tif (fDebugEn) {debug(\"streaming operator\");}\n\t\t\tfLexer.eatToken();\n\t\t\tif (fLexer.peekKeyword(SVKeywords.fBuiltinTypes)) {\n\t\t\t\texpr = new SVDBTypeExpr(fParsers.dataTypeParser().data_type(0));\n\t\t\t} else if (!fLexer.peekOperator(\"{\")) {\n\t\t\t\texpr = new SVDBLiteralExpr(fLexer.eatToken());\n\t\t\t}\n\t\t\tif (fDebugEn) {debug(\"post-datatype: \" + fLexer.peek());}\n\t\t\tfLexer.readOperator(\"{\");\n\t\t\twhile (fLexer.peek() != null) {\n\t\t\t\texpression();\n\t\t\t\tif (fDebugEn) {debug(\"pre-with: \" + fLexer.peek());}\n\t\t\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tfLexer.readOperator(\"[\");\n\t\t\t\t\texpression();\n\t\t\t\t\tif (fLexer.peekOperator(\":\", \"+:\", \"-:\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\texpression();\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"]\");\n\t\t\t\t}\n\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfLexer.readOperator(\"}\");\n\t\t\tfLexer.readOperator(\"}\");\n\t\t\texpr = new SVDBConcatenationExpr();\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tSVDBExpr expr0 = expression();\n\t\t\t\tif (fLexer.peekOperator(\"{\")) {\n\t\t\t\t\tif (fDebugEn) {debug(\"repetition\");}\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\tSVDBAssignmentPatternRepeatExpr ret = new SVDBAssignmentPatternRepeatExpr(expr);\n\t\t\t\t\tret.setRepeatExpr(expr0);\n\t\t\t\t\twhile (fLexer.peek() != null) {\n\t\t\t\t\t\tret.getPatternList().add(expression());\n\t\t\t\t\t\tif (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"}\"); \n\t\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t\t\texpr = ret;\n\t\t\t\t} else {\n\t\t\t\t\tif (fDebugEn) {debug(\"concatenation\");}\n\t\t\t\t\tSVDBConcatenationExpr ret = new SVDBConcatenationExpr();\n\t\t\t\t\tret.getElements().add(expr0);\n\t\t\t\t\twhile (fLexer.peekOperator(\",\")) {\n\t\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\t\tret.getElements().add(expression());\n\t\t\t\t\t}\n\t\t\t\t\tfLexer.readOperator(\"}\");\n\t\t\t\t\texpr = ret;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t}\n\t\t}\n\t\tif (fDebugEn) {debug(\"<-- concatenation_or_repetition()\");}\n\t\treturn expr;\n\t}\n\tpublic List<SVDBExpr> arguments() throws SVParseException {\n\t\tif (fDebugEn) {debug(\"--> arguments()\");}\n\t\treadOperator(\"(\");\n\t\tif (peekOperator(\")\")) {\n\t\t\tfLexer.eatToken();\n\t\t\treturn new ArrayList<SVDBExpr>();\n\t\t}\n\t\tList<SVDBExpr> arguments = argumentList();\n\t\treadOperator(\")\");\n\t\tif (fDebugEn) {debug(\"<-- arguments()\");}\n\t\treturn arguments;\n\t}\n\tprivate List<SVDBExpr> argumentList() throws SVParseException {\n\t\tList<SVDBExpr> arguments = new ArrayList<SVDBExpr>();\n\t\tif (fDebugEn) {debug(\"--> argumentList()\");}\n\t\tfor (;;) {\n\t\t\tif (peekOperator(\".\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\tSVDBNamedArgExpr arg_expr = new SVDBNamedArgExpr();\n\t\t\t\tString name = readIdentifier();\n\t\t\t\targ_expr.setArgName(name);\n\t\t\t\treadOperator(\"(\");\n\t\t\t\tif (fLexer.peekOperator(\")\")) {\n\t\t\t\t\targ_expr.setExpr(new SVDBLiteralExpr(\"\"));\n\t\t\t\t} else {\n\t\t\t\t\targ_expr.setExpr(expression());\n\t\t\t\t}\n\t\t\t\treadOperator(\")\");\n\t\t\t\targuments.add(arg_expr);\n\t\t\t} else if (peekOperator(\",\", \")\")) {\n\t\t\t\targuments.add(new SVDBLiteralExpr(\"\"));\n\t\t\t} else {\n\t\t\t\targuments.add(expression());\n\t\t\t}\n\t\t\tif (peekOperator(\",\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (fDebugEn) {debug(\"<-- argumentList()\");}\n\t\treturn arguments;\n\t}\n\tpublic SVDBExpr selector(SVDBExpr expr) throws SVParseException {\n\t\tif (fDebugEn) {debug(\"--> selector()\");}\n\t\tif (peekOperator(\".\", \"::\")) {\n\t\t\tString q = fLexer.eatToken();\n\t\t\tfLexer.peek();\n\t\t\tif (fLexer.isIdentifier() || peekKeyword(\"new\", \"super\", \"this\")) {\n\t\t\t\tString id = fLexer.eatToken();\n\t\t\t\tif (fLexer.peekOperator(\"(*\")) {\n\t\t\t\t\tfParsers.attrParser().parse(null);\n\t\t\t\t}\n\t\t\t\tif (fLexer.peekOperator(\"(\") || fLexer.peekKeyword(\"with\")) {\n\t\t\t\t\tif (id.equals(\"randomize\")) {\n\t\t\t\t\t\treturn randomize_call(expr);\n\t\t\t\t\t} else if (fLexer.peekOperator(\"(\")){\n\t\t\t\t\t\treturn tf_args_call(expr, id);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn tf_noargs_with_call(expr, id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (fDebugEn) {debug(\"<-- selector()\");}\n\t\t\t\treturn new SVDBFieldAccessExpr(expr, (q.equals(\"::\")), \n\t\t\t\t\t\tnew SVDBIdentifierExpr(id));\n\t\t\t}\n\t\t}\n\t\tif (peekOperator(\"[\")) {\n\t\t\tif (fDebugEn) {debug(\"primary() -- operator \" + fLexer.peek());}\n\t\t\tfLexer.eatToken();\n\t\t\tSVDBExpr low = expression();\n\t\t\tSVDBExpr high = null;\n\t\t\tif (peekOperator(\":\", \"+:\", \"-:\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\thigh = expression();\n\t\t\t}\n\t\t\treadOperator(\"]\");\n\t\t\tif (expr == null) {\n\t\t\t\terror(\"array expr == null\");\n\t\t\t}\n\t\t\tif (fDebugEn) {debug(\"<-- selector()\");}\n\t\t\treturn new SVDBArrayAccessExpr(expr, low, high);\n\t\t}\n\t\terror(\"Unexpected token \\\"\" + fLexer.getImage() + \"\\\"\");\n\t\treturn null; \n\t}\n\tprivate SVDBRandomizeCallExpr randomize_call(SVDBExpr target) throws SVParseException {\n\t\tList<SVDBExpr> arguments = null;\n\t\tSVDBRandomizeCallExpr rand_call = null;\n\t\tfAssertionExpr.push(false);\n\t\tfEventExpr.push(false);\n\t\ttry {\n\t\t\tif (fLexer.peekOperator(\"(\")) {\n\t\t\t\targuments = arguments();\n\t\t\t}\n\t\t\trand_call = new SVDBRandomizeCallExpr(target, \"randomize\", arguments);\n\t\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\t\tfLexer.eatToken();\n\t\t\t\trand_call.setWithBlock(fParsers.constraintParser().constraint_set(true));\n\t\t\t}\n\t\t} finally {\n\t\t\tfAssertionExpr.pop();\n\t\t\tfEventExpr.pop();\n\t\t}\n\t\treturn rand_call;\n\t}\n\tprivate SVDBTFCallExpr tf_args_call(SVDBExpr target, String id) throws SVParseException {\n\t\tSVDBTFCallExpr tf = new SVDBTFCallExpr(target, id, arguments());\n\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\tfLexer.eatToken();\n\t\t\tfLexer.readOperator(\"(\");\n\t\t\ttf.setWithExpr(expression());\n\t\t\tfLexer.readOperator(\")\");\n\t\t}\n\t\treturn tf;\n\t}\n\tprivate SVDBTFCallExpr tf_noargs_with_call(SVDBExpr target, String id) throws SVParseException {\n\t\tSVDBTFCallExpr tf = new SVDBTFCallExpr(target, id, null);\n\t\tif (fLexer.peekKeyword(\"with\")) {\n\t\t\tfLexer.eatToken();\n\t\t\tif (fLexer.peekOperator(\"[\")) {\n\t\t\t\tfLexer.readOperator(\"[\");\n\t\t\t\ttf.setWithExpr(expression());\n\t\t\t\tif (fLexer.peekOperator(\":\", \"+:\",\"-:\")) {\n\t\t\t\t\tfLexer.eatToken();\n\t\t\t\t\texpression();\n\t\t\t\t}\n\t\t\t\tfLexer.readOperator(\"]\");\n\t\t\t} else {\n\t\t\t\tfLexer.readOperator(\"(\");\n\t\t\t\ttf.setWithExpr(expression());\n\t\t\t\tfLexer.readOperator(\")\");\n\t\t\t}\n\t\t}\n\t\treturn tf; \n\t}\n\tprivate SVDBCtorExpr ctor_call() throws SVParseException {\n\t\tif (fDebugEn) {\n\t\t\tdebug(\"--> ctor_call()\");\n\t\t}\n\t\tSVDBCtorExpr ctor = new SVDBCtorExpr();\n\t\tif (fLexer.peekOperator(\"[\")) {\n\t\t\tfLexer.readOperator(\"[\");\n\t\t\tctor.setCtorType(CtorType.CtorType_Dim);\n\t\t\tctor.setArg(expression());\n\t\t\tfLexer.readOperator(\"]\");\n\t\t}\n\t\tif (fLexer.peekOperator(\"(\")) {\n\t\t\tctor.setCtorType(CtorType.CtorType_Args);\n\t\t\tctor.setArgs(arguments());\n\t\t} else if (fLexer.peekKeyword() || fLexer.peekId()) {\n\t\t\tctor.setCtorType(CtorType.CtorType_Expr);\n\t\t\tctor.setArg(expression());\n\t\t}\n\t\tif (fDebugEn) {\n\t\t\tdebug(\"--> ctor_call()\");\n\t\t}\n\t\treturn ctor;\n\t}\n\tprivate String peek() throws SVParseException {\n\t\treturn fLexer.peek();\n\t}\n\tprivate boolean peekOperator(String ... ops) throws SVParseException {\n\t\treturn fLexer.peekOperator(ops);\n\t}\n\tprivate String readOperator(String ... ops) throws SVParseException {\n\t\treturn fLexer.readOperator(ops);\n\t}\n\tprivate boolean peekKeyword(String ... kw) throws SVParseException {\n\t\treturn fLexer.peekKeyword(kw);\n\t}\n\tprivate String readKeyword(String ... kw) throws SVParseException {\n\t\treturn fLexer.readKeyword(kw);\n\t}\n\tprivate String readIdentifier() throws SVParseException {\n\t\treturn fLexer.readId();\n\t}\n\tpublic SVDBIdentifierExpr idExpr() throws SVParseException {\n\t\tSVDBLocation start = fLexer.getStartLocation();\n\t\tSVDBIdentifierExpr ret = new SVDBIdentifierExpr(fLexer.readId());\n\t\tret.setLocation(start);\n\t\treturn ret;\n\t}\n\tpublic SVDBLiteralExpr literalExpr() throws SVParseException {\n\t\tSVDBLocation start = fLexer.getStartLocation();\n\t\tSVDBLiteralExpr ret = new SVDBLiteralExpr(fLexer.readNumber());\n\t\tret.setLocation(start);\n\t\treturn ret;\n\t}\n}\n"} {"input": " public void initializeAttributes(){\n addAttribute(getIDColumnName());\n addAttribute(getNewsCategoryIdColumnName(), \"Category\", true, true, \"java.lang.Integer\", \"many-to-one\",\"com.idega.jmodule.news.data.NewsCategory\");\n addAttribute(getHeadLineColumnName(), \"Headline\", true, true, \"java.lang.String\");\n addAttribute(getNewsTextColumnName(), \"Text\", true, true, \"java.lang.String\",4000);\n addAttribute(getIncludeImageColumnName(), \"Photo Included\", true, true, \"java.lang.String\");\n addAttribute(getImageIdColumnName(), \"Photo\", true, true, \"java.lang.Integer\");\n addAttribute(getNewsDateColumnName(), \"Date\", true, true, \"java.sql.Timestamp\");\n addAttribute(getAuthorColumnName(), \"Author\", true, true, \"java.lang.String\");\n addAttribute(getSourceColumnName(), \"Source\", true, true, \"java.lang.String\");\n addAttribute(getDaysShownColumnName(), \"Days shown\", true, true, \"java.lang.Integer\");\n }\n", "output": " public void initializeAttributes(){\n addAttribute(getIDColumnName());\n addAttribute(getNewsCategoryIdColumnName(), \"Category\", true, true, Integer.class, \"many-to-one\",NewsCategory.class);\n addAttribute(getHeadLineColumnName(), \"Headline\", true, true, String.class);\n addAttribute(getNewsTextColumnName(), \"Text\", true, true, String.class,4000);\n addAttribute(getIncludeImageColumnName(), \"Photo Included\", true, true, String.class);\n addAttribute(getImageIdColumnName(), \"Photo\", true, true, Integer.class);\n addAttribute(getNewsDateColumnName(), \"Date\", true, true, java.sql.Timestamp.class);\n addAttribute(getAuthorColumnName(), \"Author\", true, true, String.class);\n addAttribute(getSourceColumnName(), \"Source\", true, true, String.class);\n addAttribute(getDaysShownColumnName(), \"Days shown\", true, true, String.class);\n }\n"} {"input": " public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {\n plasmaSwitchboard switchboard = (plasmaSwitchboard) env;\n serverObjects prop = new serverObjects();\n prop.put(\"rejected\", 0);\n int showRejectedCount = 10;\n if (post != null) {\n if (post.containsKey(\"clearRejected\")) {\n switchboard.urlPool.errorURL.clearStack();\n } \n if (post.containsKey(\"moreRejected\")) {\n showRejectedCount = Integer.parseInt(post.get(\"showRejected\", \"10\"));\n }\n if (post.containsKey(\"clearIndexingQueue\")) {\n try {\n synchronized (switchboard.sbQueue) {\n plasmaSwitchboardQueue.Entry entry = null;\n while ((entry = switchboard.sbQueue.pop()) != null) {\n if ((entry != null) && (entry.profile() != null) && (!(entry.profile().storeHTCache()))) {\n switchboard.cacheManager.deleteFile(entry.url());\n } \n }\n } \n } catch (Exception e) {}\n } else if (post.containsKey(\"deleteEntry\")) {\n String urlHash = (String) post.get(\"deleteEntry\");\n try {\n synchronized (switchboard.sbQueue) {\n ArrayList entries = switchboard.sbQueue.list(0);\n for (int i=entries.size()-1; i >= 0; i--) {\n plasmaSwitchboardQueue.Entry pcentry = (plasmaSwitchboardQueue.Entry) entries.get(i);\n if (pcentry.urlHash().equals(urlHash)) {\n plasmaSwitchboardQueue.Entry entry = switchboard.sbQueue.remove(i);\n if ((entry != null) && (entry.profile() != null) && (!(entry.profile().storeHTCache()))) {\n switchboard.cacheManager.deleteFile(entry.url());\n }\n break;\n }\n }\n } \n } catch (Exception e) {}\n prop.put(\"LOCATION\",\"\");\n return prop;\n }\n }\n yacySeed initiator;\n boolean dark;\n if ((switchboard.sbQueue.size() == 0) && (switchboard.indexingTasksInProcess.size() == 0)) {\n prop.put(\"indexing-queue\", 0); \n } else {\n prop.put(\"indexing-queue\", 1); \n dark = true;\n plasmaSwitchboardQueue.Entry pcentry;\n int inProcessCount = 0, entryCount = 0;\n long totalSize = 0;\n try {\n ArrayList entryList = new ArrayList();\n synchronized (switchboard.indexingTasksInProcess) {\n inProcessCount = switchboard.indexingTasksInProcess.size();\n entryList.addAll(switchboard.indexingTasksInProcess.values());\n }\n if ((switchboard.sbQueue.size() > 0)) {\n entryList.addAll(switchboard.sbQueue.list(0));\n }\n int count=entryList.size();\n if(count>100)count=100;\n for (int i = 0; i < count; i++) {\n boolean inProcess = i < inProcessCount;\n pcentry = (plasmaSwitchboardQueue.Entry) entryList.get(i);\n long entrySize = pcentry.size();\n totalSize += entrySize;\n if ((pcentry != null)&&(pcentry.url() != null)) {\n initiator = yacyCore.seedDB.getConnected(pcentry.initiator());\n prop.put(\"indexing-queue_list_\"+entryCount+\"_dark\", (inProcess)? 2: ((dark) ? 1 : 0));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_initiator\", ((initiator == null) ? \"proxy\" : wikiCode.replaceHTML(initiator.getName())));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_depth\", pcentry.depth());\n prop.put(\"indexing-queue_list_\"+entryCount+\"_modified\", (pcentry.responseHeader() == null) ? \"\" : daydate(pcentry.responseHeader().lastModified()));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_anchor\", (pcentry.anchorName()==null)?\"\":pcentry.anchorName());\n prop.put(\"indexing-queue_list_\"+entryCount+\"_url\", wikiCode.replaceHTML(pcentry.normalizedURLString()));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_size\", bytesToString(entrySize));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_inProcess\", (inProcess)?1:0);\n prop.put(\"indexing-queue_list_\"+entryCount+\"_inProcess_hash\", pcentry.urlHash());\n dark = !dark;\n entryCount++;\n }\n }\n } catch (IOException e) {}\n prop.put(\"indexing-queue_num\", entryCount);\n prop.put(\"indexing-queue_totalSize\", bytesToString(totalSize));\n prop.put(\"indexing-queue_list\", entryCount);\n }\n if (switchboard.urlPool.errorURL.stackSize() != 0) {\n if (showRejectedCount > switchboard.urlPool.errorURL.stackSize()) showRejectedCount = switchboard.urlPool.errorURL.stackSize();\n prop.put(\"rejected\", 1);\n prop.put(\"rejected_num\", switchboard.urlPool.errorURL.stackSize());\n if (showRejectedCount != switchboard.urlPool.errorURL.stackSize()) {\n prop.put(\"rejected_only-latest\", 1);\n prop.put(\"rejected_only-latest_num\", showRejectedCount);\n prop.put(\"rejected_only-latest_newnum\", ((int) (showRejectedCount * 1.5)));\n }else{\n prop.put(\"rejected_only-latest\", 0);\n }\n dark = true;\n String url, initiatorHash, executorHash;\n plasmaCrawlEURL.Entry entry;\n yacySeed initiatorSeed, executorSeed;\n int j=0;\n for ( int i = switchboard.urlPool.errorURL.stackSize() - 1; i >= (switchboard.urlPool.errorURL.stackSize() - showRejectedCount); i--) {\n entry = (plasmaCrawlEURL.Entry) switchboard.urlPool.errorURL.getStack(i);\n initiatorHash = entry.initiator();\n executorHash = entry.executor();\n url = entry.url().toString();\n initiatorSeed = yacyCore.seedDB.getConnected(initiatorHash);\n executorSeed = yacyCore.seedDB.getConnected(executorHash);\n prop.put(\"rejected_list_\"+j+\"_initiator\", ((initiatorSeed == null) ? \"proxy\" : wikiCode.replaceHTML(initiatorSeed.getName())));\n prop.put(\"rejected_list_\"+j+\"_executor\", ((executorSeed == null) ? \"proxy\" : wikiCode.replaceHTML(executorSeed.getName())));\n prop.put(\"rejected_list_\"+j+\"_url\", wikiCode.replaceHTML(url));\n prop.put(\"rejected_list_\"+j+\"_failreason\", entry.failreason());\n prop.put(\"rejected_list_\"+j+\"_dark\", ((dark) ? 1 : 0));\n dark = !dark;\n j++;\n }\n prop.put(\"rejected_list\", j);\n }\n return prop;\n }\n", "output": " public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {\n plasmaSwitchboard switchboard = (plasmaSwitchboard) env;\n serverObjects prop = new serverObjects();\n prop.put(\"rejected\", 0);\n int showRejectedCount = 10;\n if (post != null) {\n if (post.containsKey(\"clearRejected\")) {\n switchboard.urlPool.errorURL.clearStack();\n } \n if (post.containsKey(\"moreRejected\")) {\n showRejectedCount = Integer.parseInt(post.get(\"showRejected\", \"10\"));\n }\n if (post.containsKey(\"clearIndexingQueue\")) {\n try {\n synchronized (switchboard.sbQueue) {\n plasmaSwitchboardQueue.Entry entry = null;\n while ((entry = switchboard.sbQueue.pop()) != null) {\n if ((entry != null) && (entry.profile() != null) && (!(entry.profile().storeHTCache()))) {\n switchboard.cacheManager.deleteFile(entry.url());\n } \n }\n } \n } catch (Exception e) {}\n } else if (post.containsKey(\"deleteEntry\")) {\n String urlHash = (String) post.get(\"deleteEntry\");\n try {\n synchronized (switchboard.sbQueue) {\n ArrayList entries = switchboard.sbQueue.list(0);\n for (int i=entries.size()-1; i >= 0; i--) {\n plasmaSwitchboardQueue.Entry pcentry = (plasmaSwitchboardQueue.Entry) entries.get(i);\n if (pcentry.urlHash().equals(urlHash)) {\n plasmaSwitchboardQueue.Entry entry = switchboard.sbQueue.remove(i);\n if ((entry != null) && (entry.profile() != null) && (!(entry.profile().storeHTCache()))) {\n switchboard.cacheManager.deleteFile(entry.url());\n }\n break;\n }\n }\n } \n } catch (Exception e) {}\n prop.put(\"LOCATION\",\"\");\n return prop;\n }\n }\n yacySeed initiator;\n boolean dark;\n if ((switchboard.sbQueue.size() == 0) && (switchboard.indexingTasksInProcess.size() == 0)) {\n prop.put(\"indexing-queue\", 0); \n } else {\n prop.put(\"indexing-queue\", 1); \n dark = true;\n plasmaSwitchboardQueue.Entry pcentry;\n int inProcessCount = 0, entryCount = 0;\n long totalSize = 0;\n try {\n ArrayList entryList = new ArrayList();\n synchronized (switchboard.indexingTasksInProcess) {\n inProcessCount = switchboard.indexingTasksInProcess.size();\n entryList.addAll(switchboard.indexingTasksInProcess.values());\n }\n if ((switchboard.sbQueue.size() > 0)) {\n entryList.addAll(switchboard.sbQueue.list(0));\n }\n for (int i = 0; i < entryList.size(); i++) {\n boolean inProcess = i < inProcessCount;\n pcentry = (plasmaSwitchboardQueue.Entry) entryList.get(i);\n long entrySize = pcentry.size();\n totalSize += entrySize;\n if ((pcentry != null)&&(pcentry.url() != null)) {\n initiator = yacyCore.seedDB.getConnected(pcentry.initiator());\n prop.put(\"indexing-queue_list_\"+entryCount+\"_dark\", (inProcess)? 2: ((dark) ? 1 : 0));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_initiator\", ((initiator == null) ? \"proxy\" : wikiCode.replaceHTML(initiator.getName())));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_depth\", pcentry.depth());\n prop.put(\"indexing-queue_list_\"+entryCount+\"_modified\", (pcentry.responseHeader() == null) ? \"\" : daydate(pcentry.responseHeader().lastModified()));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_anchor\", (pcentry.anchorName()==null)?\"\":wikiCode.replaceHTML(pcentry.anchorName()));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_url\", wikiCode.replaceHTML(pcentry.normalizedURLString()));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_size\", bytesToString(entrySize));\n prop.put(\"indexing-queue_list_\"+entryCount+\"_inProcess\", (inProcess)?1:0);\n prop.put(\"indexing-queue_list_\"+entryCount+\"_inProcess_hash\", pcentry.urlHash());\n dark = !dark;\n entryCount++;\n }\n }\n } catch (IOException e) {}\n prop.put(\"indexing-queue_num\", entryCount);\n prop.put(\"indexing-queue_totalSize\", bytesToString(totalSize));\n prop.put(\"indexing-queue_list\", entryCount);\n }\n if (switchboard.urlPool.errorURL.stackSize() != 0) {\n if (showRejectedCount > switchboard.urlPool.errorURL.stackSize()) showRejectedCount = switchboard.urlPool.errorURL.stackSize();\n prop.put(\"rejected\", 1);\n prop.put(\"rejected_num\", switchboard.urlPool.errorURL.stackSize());\n if (showRejectedCount != switchboard.urlPool.errorURL.stackSize()) {\n prop.put(\"rejected_only-latest\", 1);\n prop.put(\"rejected_only-latest_num\", showRejectedCount);\n prop.put(\"rejected_only-latest_newnum\", ((int) (showRejectedCount * 1.5)));\n }else{\n prop.put(\"rejected_only-latest\", 0);\n }\n dark = true;\n String url, initiatorHash, executorHash;\n plasmaCrawlEURL.Entry entry;\n yacySeed initiatorSeed, executorSeed;\n int j=0;\n for ( int i = switchboard.urlPool.errorURL.stackSize() - 1; i >= (switchboard.urlPool.errorURL.stackSize() - showRejectedCount); i--) {\n entry = (plasmaCrawlEURL.Entry) switchboard.urlPool.errorURL.getStack(i);\n initiatorHash = entry.initiator();\n executorHash = entry.executor();\n url = entry.url().toString();\n initiatorSeed = yacyCore.seedDB.getConnected(initiatorHash);\n executorSeed = yacyCore.seedDB.getConnected(executorHash);\n prop.put(\"rejected_list_\"+j+\"_initiator\", ((initiatorSeed == null) ? \"proxy\" : wikiCode.replaceHTML(initiatorSeed.getName())));\n prop.put(\"rejected_list_\"+j+\"_executor\", ((executorSeed == null) ? \"proxy\" : wikiCode.replaceHTML(executorSeed.getName())));\n prop.put(\"rejected_list_\"+j+\"_url\", wikiCode.replaceHTML(url));\n prop.put(\"rejected_list_\"+j+\"_failreason\", entry.failreason());\n prop.put(\"rejected_list_\"+j+\"_dark\", ((dark) ? 1 : 0));\n dark = !dark;\n j++;\n }\n prop.put(\"rejected_list\", j);\n }\n return prop;\n }\n"} {"input": " public void setScriptToTokenize(String script) {\n _queries.clear();\n String MULTI_LINE_COMMENT_END = \"*/\";\n String MULTI_LINE_COMMENT_BEGIN = \"/*\";\n script = script.replace('\\r', ' ');\n StringBuffer curQuery = new StringBuffer();\n boolean isInLiteral = false;\n boolean isInMultiLineComment = false;\n boolean isInLineComment = false;\n int literalSepCount = 0;\n for (int i = 0; i < script.length(); ++i)\n {\n char c = script.charAt(i);\n if(false == isInLiteral)\n {\n if(isInLineComment && script.startsWith(\"\\n\", i - \"\\n\".length()))\n {\n isInLineComment = false;\n }\n if(isInMultiLineComment && script.startsWith(MULTI_LINE_COMMENT_END, i - MULTI_LINE_COMMENT_END.length()))\n {\n isInMultiLineComment = false;\n }\n if(false == isInLineComment && false == isInMultiLineComment)\n {\n isInMultiLineComment = script.startsWith(MULTI_LINE_COMMENT_BEGIN, i);\n isInLineComment = script.startsWith(_lineCommentBegin, i);\n if(isInMultiLineComment && _removeMultiLineComment)\n {\n i+=MULTI_LINE_COMMENT_BEGIN.length()+1;\n }\n }\n if((isInMultiLineComment && _removeMultiLineComment) || isInLineComment)\n {\n continue;\n }\n }\n curQuery.append(c);\n if ('\\'' == c)\n {\n if(false == isInLiteral)\n {\n isInLiteral = true;\n }\n else\n {\n ++literalSepCount;\n }\n }\n else\n {\n if(0 != literalSepCount % 2)\n {\n isInLiteral = false;\n }\n literalSepCount = 0;\n }\n int querySepLen = \n getLenOfQuerySepIfAtLastCharOfQuerySep(script, i, _querySep, isInLiteral);\n if(-1 < querySepLen)\n {\n int newLength = curQuery.length() - querySepLen;\n if(-1 < newLength && curQuery.length() > newLength)\n {\n curQuery.setLength(newLength);\n String newQuery = curQuery.toString().trim();\n if(0 < newQuery.length())\n {\n _queries.add(curQuery.toString().trim());\n }\n }\n curQuery.setLength(0);\n }\n }\n String lastQuery = curQuery.toString().trim();\n if(0 < lastQuery.length())\n {\n _queries.add(lastQuery.trim());\n }\n _queryIterator = _queries.iterator();\n }\n", "output": " public void setScriptToTokenize(String script) {\n _queries.clear();\n String MULTI_LINE_COMMENT_END = \"*/\";\n String MULTI_LINE_COMMENT_BEGIN = \"/*\";\n script = script.replace('\\r', ' ');\n StringBuffer curQuery = new StringBuffer();\n boolean isInLiteral = false;\n boolean isInMultiLineComment = false;\n boolean isInLineComment = false;\n int literalSepCount = 0;\n for (int i = 0; i < script.length(); ++i)\n {\n char c = script.charAt(i);\n if(false == isInLiteral)\n {\n if(isInLineComment && script.startsWith(\"\\n\", i - \"\\n\".length()))\n {\n isInLineComment = false;\n }\n if(isInMultiLineComment && script.startsWith(MULTI_LINE_COMMENT_END, i - MULTI_LINE_COMMENT_END.length()))\n {\n isInMultiLineComment = false;\n }\n if(false == isInLineComment && false == isInMultiLineComment)\n {\n isInMultiLineComment = script.startsWith(MULTI_LINE_COMMENT_BEGIN, i);\n isInLineComment = script.startsWith(_lineCommentBegin, i);\n if(isInMultiLineComment && _removeMultiLineComment)\n {\n i+=MULTI_LINE_COMMENT_BEGIN.length()+1;\n }\n }\n if((isInMultiLineComment && _removeMultiLineComment) || isInLineComment)\n {\n continue;\n }\n }\n curQuery.append(c);\n if ('\\'' == c)\n {\n if(false == isInLiteral)\n {\n isInLiteral = true;\n }\n else\n {\n ++literalSepCount;\n }\n }\n else\n {\n if(0 != literalSepCount % 2)\n {\n isInLiteral = false;\n }\n literalSepCount = 0;\n }\n int querySepLen = \n getLenOfQuerySepIfAtLastCharOfQuerySep(script, i, _querySep, isInLiteral);\n if(-1 < querySepLen && !isInMultiLineComment)\n {\n int newLength = curQuery.length() - querySepLen;\n if(-1 < newLength && curQuery.length() > newLength)\n {\n curQuery.setLength(newLength);\n String newQuery = curQuery.toString().trim();\n if(0 < newQuery.length())\n {\n _queries.add(curQuery.toString().trim());\n }\n }\n curQuery.setLength(0);\n }\n }\n String lastQuery = curQuery.toString().trim();\n if(0 < lastQuery.length())\n {\n _queries.add(lastQuery.trim());\n }\n _queryIterator = _queries.iterator();\n }\n"} {"input": "\tprotected Control createDialogArea(Composite parent) {\n\t\tWorkbenchHelp.setHelp(\n\t\t\tparent,\n\t\t\tIJavaDebugHelpContextIds.EDIT_DETAIL_FORMATTER_DIALOG);\t\t\t\n\t\tFont font = parent.getFont();\n\t\tComposite container = new Composite(parent, SWT.NONE);\n\t\tGridLayout layout = new GridLayout();\n\t\tcontainer.setLayout(layout);\n\t\tGridData gd= new GridData(GridData.FILL_BOTH);\n\t\tcontainer.setLayoutData(gd);\n\t\tLabel label= new Label(container, SWT.NONE);\n\t\tlabel.setText(DebugUIMessages.getString(\"DetailFormatterDialog.Qualified_type_&name__2\")); \n\t\tgd= new GridData(GridData.BEGINNING);\n\t\tlabel.setLayoutData(gd);\n\t\tlabel.setFont(font);\n\t\tComposite innerContainer = new Composite(container, SWT.NONE);\n\t\tlayout = new GridLayout();\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.numColumns = 2;\n\t\tinnerContainer.setLayout(layout);\n\t\tgd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tinnerContainer.setLayoutData(gd);\n\t\tfTypeNameText= new Text(innerContainer, SWT.SINGLE | SWT.BORDER);\n\t\tfTypeNameText.setEditable(fEditTypeName);\n\t\tfTypeNameText.setText(fDetailFormatter.getTypeName());\n\t\tgd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tfTypeNameText.setLayoutData(gd);\n\t\tfTypeNameText.setFont(font);\t\t\n\t\tfTypeNameText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tfTypeSearched= false;\n\t\t\t\tcheckValues();\n\t\t\t}\n\t\t});\n\t\tButton typeSearchButton = new Button(innerContainer, SWT.PUSH); \n\t\ttypeSearchButton.setText(DebugUIMessages.getString(\"DetailFormatterDialog.Select_&type_4\")); \n\t\tsetButtonLayoutData(typeSearchButton);\n\t\tgd= (GridData)typeSearchButton.getLayoutData();\n\t\tgd.horizontalAlignment = GridData.END;\n\t\ttypeSearchButton.setLayoutData(gd);\n\t\ttypeSearchButton.setFont(font);\t\t\n\t\ttypeSearchButton.addListener(SWT.Selection, new Listener() {\n\t\t\tpublic void handleEvent(Event e) {\n\t\t\t\tselectType();\n\t\t\t}\n\t\t});\n\t\tlabel= new Label(container, SWT.NONE);\n\t\tlabel.setText(DebugUIMessages.getString(\"DetailFormatterDialog.Detail_formatter_&code_snippet__1\")); \n\t\tgd= new GridData(GridData.BEGINNING);\n\t\tlabel.setLayoutData(gd);\n\t\tlabel.setFont(font);\n\t\tfSnippetViewer= new JDISourceViewer(container, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );\n\t\tfSnippetViewer.setInput(this);\n\t\tJavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();\n\t\tIDocument document= new Document();\n\t\tIDocumentPartitioner partitioner= tools.createDocumentPartitioner();\n\t\tdocument.setDocumentPartitioner(partitioner);\n\t\tpartitioner.connect(document);\t\t\n\t\tfSnippetViewer.configure(new DisplayViewerConfiguration() {\n\t\t\tpublic IContentAssistProcessor getContentAssistantProcessor() {\n\t\t\t\treturn new DetailFormatterCompletionProcessor(DetailFormatterDialog.this);\n\t\t\t}\n\t\t});\n\t\tfSnippetViewer.setEditable(true);\n\t\tfSnippetViewer.setDocument(document);\n\t\tfSnippetViewer.getTextWidget().setFont(JFaceResources.getTextFont());\n\t\tControl control= fSnippetViewer.getControl();\n\t\tgd= new GridData(GridData.FILL_BOTH);\n\t\tgd.heightHint= convertHeightInCharsToPixels(10);\n\t\tgd.widthHint= convertWidthInCharsToPixels(80);\n\t\tcontrol.setLayoutData(gd);\n\t\tdocument.set(fDetailFormatter.getSnippet());\n\t\tfSnippetViewer.getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {\n\t\t\tpublic void verifyKey(VerifyEvent event) {\n\t\t\t\tif (event.stateMask == SWT.CTRL && event.keyCode == 0) {\n\t\t\t\t\tif (event.character == 0x20) {\n\t\t\t\t\t\tfindCorrespondingType();\n\t\t\t\t\t\tfSnippetViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);\n\t\t\t\t\t\tevent.doit= false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfSnippetViewer.getDocument().addDocumentListener(new IDocumentListener() {\n\t\t\tpublic void documentAboutToBeChanged(DocumentEvent event) {\n\t\t\t}\n\t\t\tpublic void documentChanged(DocumentEvent event) {\n\t\t\t\tcheckValues();\n\t\t\t}\n\t\t});\n\t\tfCheckBox= new Button(container, SWT.CHECK | SWT.LEFT);\n\t\tfCheckBox.setText(DebugUIMessages.getString(\"DetailFormatterDialog.&Enable_1\")); \n\t\tfCheckBox.setSelection(fDetailFormatter.isEnabled());\n\t\tfCheckBox.setFont(font);\n\t\tcheckValues();\n\t\treturn container;\n\t}\n", "output": "\tprotected Control createDialogArea(Composite parent) {\n\t\tWorkbenchHelp.setHelp(\n\t\t\tparent,\n\t\t\tIJavaDebugHelpContextIds.EDIT_DETAIL_FORMATTER_DIALOG);\t\t\t\n\t\tFont font = parent.getFont();\n\t\tComposite container = (Composite)super.createDialogArea(parent);\n\t\tLabel label= new Label(container, SWT.NONE);\n\t\tlabel.setText(DebugUIMessages.getString(\"DetailFormatterDialog.Qualified_type_&name__2\")); \n\t\tGridData gd= new GridData(GridData.BEGINNING);\n\t\tlabel.setLayoutData(gd);\n\t\tlabel.setFont(font);\n\t\tComposite innerContainer = new Composite(container, SWT.NONE);\n\t\tGridLayout layout = new GridLayout();\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginHeight = 0;\n\t\tlayout.numColumns = 2;\n\t\tinnerContainer.setLayout(layout);\n\t\tgd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tinnerContainer.setLayoutData(gd);\n\t\tfTypeNameText= new Text(innerContainer, SWT.SINGLE | SWT.BORDER);\n\t\tfTypeNameText.setEditable(fEditTypeName);\n\t\tfTypeNameText.setText(fDetailFormatter.getTypeName());\n\t\tgd= new GridData(GridData.FILL_HORIZONTAL);\n\t\tfTypeNameText.setLayoutData(gd);\n\t\tfTypeNameText.setFont(font);\t\t\n\t\tfTypeNameText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tfTypeSearched= false;\n\t\t\t\tcheckValues();\n\t\t\t}\n\t\t});\n\t\tButton typeSearchButton = new Button(innerContainer, SWT.PUSH); \n\t\ttypeSearchButton.setText(DebugUIMessages.getString(\"DetailFormatterDialog.Select_&type_4\")); \n\t\tsetButtonLayoutData(typeSearchButton);\n\t\tgd= (GridData)typeSearchButton.getLayoutData();\n\t\tgd.horizontalAlignment = GridData.END;\n\t\ttypeSearchButton.setLayoutData(gd);\n\t\ttypeSearchButton.setFont(font);\t\t\n\t\ttypeSearchButton.addListener(SWT.Selection, new Listener() {\n\t\t\tpublic void handleEvent(Event e) {\n\t\t\t\tselectType();\n\t\t\t}\n\t\t});\n\t\tlabel= new Label(container, SWT.NONE);\n\t\tlabel.setText(DebugUIMessages.getString(\"DetailFormatterDialog.Detail_formatter_&code_snippet__1\")); \n\t\tgd= new GridData(GridData.BEGINNING);\n\t\tlabel.setLayoutData(gd);\n\t\tlabel.setFont(font);\n\t\tfSnippetViewer= new JDISourceViewer(container, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL );\n\t\tfSnippetViewer.setInput(this);\n\t\tJavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();\n\t\tIDocument document= new Document();\n\t\tIDocumentPartitioner partitioner= tools.createDocumentPartitioner();\n\t\tdocument.setDocumentPartitioner(partitioner);\n\t\tpartitioner.connect(document);\t\t\n\t\tfSnippetViewer.configure(new DisplayViewerConfiguration() {\n\t\t\tpublic IContentAssistProcessor getContentAssistantProcessor() {\n\t\t\t\treturn new DetailFormatterCompletionProcessor(DetailFormatterDialog.this);\n\t\t\t}\n\t\t});\n\t\tfSnippetViewer.setEditable(true);\n\t\tfSnippetViewer.setDocument(document);\n\t\tfSnippetViewer.getTextWidget().setFont(JFaceResources.getTextFont());\n\t\tControl control= fSnippetViewer.getControl();\n\t\tgd= new GridData(GridData.FILL_BOTH);\n\t\tgd.heightHint= convertHeightInCharsToPixels(10);\n\t\tgd.widthHint= convertWidthInCharsToPixels(80);\n\t\tcontrol.setLayoutData(gd);\n\t\tdocument.set(fDetailFormatter.getSnippet());\n\t\tfSnippetViewer.getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {\n\t\t\tpublic void verifyKey(VerifyEvent event) {\n\t\t\t\tif (event.stateMask == SWT.CTRL && event.keyCode == 0) {\n\t\t\t\t\tif (event.character == 0x20) {\n\t\t\t\t\t\tfindCorrespondingType();\n\t\t\t\t\t\tfSnippetViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);\n\t\t\t\t\t\tevent.doit= false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfSnippetViewer.getDocument().addDocumentListener(new IDocumentListener() {\n\t\t\tpublic void documentAboutToBeChanged(DocumentEvent event) {\n\t\t\t}\n\t\t\tpublic void documentChanged(DocumentEvent event) {\n\t\t\t\tcheckValues();\n\t\t\t}\n\t\t});\n\t\tfCheckBox= new Button(container, SWT.CHECK | SWT.LEFT);\n\t\tfCheckBox.setText(DebugUIMessages.getString(\"DetailFormatterDialog.&Enable_1\")); \n\t\tfCheckBox.setSelection(fDetailFormatter.isEnabled());\n\t\tfCheckBox.setFont(font);\n\t\tcheckValues();\n\t\treturn container;\n\t}\n"} {"input": " public static void main(String[] args) {\n OTPMain main = new OTPMain();\n JCommander jc = new JCommander(main, args);\n if (main.help) {\n jc.usage();\n System.exit(0);\n }\n main.run();\n }\n", "output": " public static void main(String[] args) {\n OTPMain main = new OTPMain();\n JCommander jc = new JCommander(main, args);\n if (main.help) {\n jc.usage();\n System.exit(0);\n }\n while (true) {\n try {\n main.run();\n return;\n }\n catch (Throwable throwable) {\n LOG.error(\"An uncaught \" + throwable.getClass().getSimpleName()\n + \" occurred inside OTP. Restarting server.\", throwable);\n }\n }\n }\n"} {"input": " public void startApp() {\n\tDisplay display = Display.getDisplay(this);\n\ttry {\n\t Alert a = new Alert(\"Loading Hecl\", \"Loading Hecl...\", null, AlertType.INFO);\n\t display.setCurrent(a);\n\t a.setTimeout(10000);\n\t a.setIndicator(new Gauge(null, false,\n\t\t\t\t Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING));\n\t interp = new Interp();\n\t Vector v = new Vector();\n\t for(int i = 0; i<args.length; ++i) {\n\t\tv.addElement(new Thing(args[i]));\n\t }\n\t interp.setVar(\"argv\", ListThing.create(v));\n\t RMSCmd.load(interp);\n\t HttpCmd.load(interp);\n\t Base64Cmd.load(interp);\n\t org.hecl.kxml.KXMLCmd.load(interp);\n\t MidletCmd.load(interp,this);\n\t\t\t org.hecl.mwtgui.MwtCmds.load(interp, this);\n\t String scriptcontent =\n\t\tHeclUtils.getResourceAsString(this.getClass(),\"/script.hcl\",\"UTF-8\");\n\t interp.setVar(\"splash\", ObjectThing.create(a));\n\t evaltask = interp.evalIdle(new Thing(scriptcontent));\n\t}\n\tcatch (Exception e) {\n\t e.printStackTrace();\n\t destroyApp(true);\n\t}\n }\n", "output": " public void startApp() {\n\tDisplay display = Display.getDisplay(this);\n\ttry {\n\t Alert a = new Alert(\"Loading Hecl\", \"Loading Hecl...\", null, AlertType.INFO);\n\t display.setCurrent(a);\n\t a.setTimeout(Alert.FOREVER);\n\t a.setIndicator(new Gauge(null, false,\n\t\t\t\t Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING));\n\t interp = new Interp();\n\t Vector v = new Vector();\n\t for(int i = 0; i<args.length; ++i) {\n\t\tv.addElement(new Thing(args[i]));\n\t }\n\t interp.setVar(\"argv\", ListThing.create(v));\n\t RMSCmd.load(interp);\n\t HttpCmd.load(interp);\n\t Base64Cmd.load(interp);\n\t org.hecl.kxml.KXMLCmd.load(interp);\n\t MidletCmd.load(interp,this);\n\t\t\t org.hecl.mwtgui.MwtCmds.load(interp, this);\n\t String scriptcontent =\n\t\tHeclUtils.getResourceAsString(this.getClass(),\"/script.hcl\",\"UTF-8\");\n\t interp.setVar(\"splash\", ObjectThing.create(a));\n\t evaltask = interp.evalIdle(new Thing(scriptcontent));\n\t}\n\tcatch (Exception e) {\n\t e.printStackTrace();\n\t destroyApp(true);\n\t}\n }\n"} {"input": "\tpublic void render(HttpServletRequest req, HttpServletResponse resp, Object obj)\n\t\t\tthrows Exception {\n\t\tMirror<?> mirror = Mirror.me(obj);\n\t\tboolean isMap = null != obj && obj instanceof Map<?, ?>;\n\t\tMap<?, ?> map = (Map<?, ?>) obj;\n\t\tSet<String> keySet = dest.keys();\n\t\tIterator<String> it = keySet.iterator();\n\t\twhile (it.hasNext()) {\n\t\t\tString key = it.next();\n\t\t\tObject value = null;\n\t\t\tint length = key.length();\n\t\t\tif (key.startsWith(\"p.\") && length > 2) {\n\t\t\t\tvalue = req.getParameter(key.substring(2));\n\t\t\t}\n\t\t\telse if (isMap && key.startsWith(\"obj.\") && length > 4) {\n\t\t\t\tvalue = map.get(key);\n\t\t\t}\n\t\t\telse if (null != mirror && key.startsWith(\"obj.\") && length > 4) {\n\t\t\t\tvalue = mirror.getValue(obj, key.substring(4));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalue = obj;\n\t\t\t}\n\t\t\tif (null == value)\n\t\t\t\tvalue = obj;\n\t\t\tdest.set(key, value);\n\t\t}\n\t\tString path = dest.toString();\n\t\tif (path.startsWith(\"http://\") || path.startsWith(\"https://\")) {}\n\t\telse if (path.startsWith(\"/\")) {\n\t\t\tpath = req.getContextPath() + path;\n\t\t}\n\t\telse {\n\t\t\tString myPath = req.getPathInfo();\n\t\t\tint pos = myPath.lastIndexOf('/');\n\t\t\tif (pos > 0)\n\t\t\t\tpath = myPath.substring(0, pos) + \"/\" + path;\n\t\t\telse\n\t\t\t\tpath = \"/\" + path;\n\t\t}\n\t\tresp.sendRedirect(path);\n\t\tresp.flushBuffer();\n\t}\n", "output": "\tpublic void render(HttpServletRequest req, HttpServletResponse resp, Object obj)\n\t\t\tthrows Exception {\n\t\tMirror<?> mirror = Mirror.me(obj);\n\t\tboolean isMap = null != obj && obj instanceof Map<?, ?>;\n\t\tMap<?, ?> map = isMap ? null : (Map<?, ?>) obj;\n\t\tSet<String> keySet = dest.keys();\n\t\tIterator<String> it = keySet.iterator();\n\t\twhile (it.hasNext()) {\n\t\t\tString key = it.next();\n\t\t\tObject value = null;\n\t\t\tint length = key.length();\n\t\t\tif (key.startsWith(\"p.\") && length > 2) {\n\t\t\t\tvalue = req.getParameter(key.substring(2));\n\t\t\t}\n\t\t\telse if (isMap && key.startsWith(\"obj.\") && length > 4) {\n\t\t\t\tvalue = map.get(key);\n\t\t\t}\n\t\t\telse if (null != mirror && key.startsWith(\"obj.\") && length > 4) {\n\t\t\t\tvalue = mirror.getValue(obj, key.substring(4));\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvalue = obj;\n\t\t\t}\n\t\t\tif (null == value)\n\t\t\t\tvalue = obj;\n\t\t\tdest.set(key, value);\n\t\t}\n\t\tString path = dest.toString();\n\t\tif (path.startsWith(\"http://\") || path.startsWith(\"https://\")) {}\n\t\telse if (path.startsWith(\"/\")) {\n\t\t\tpath = req.getContextPath() + path;\n\t\t}\n\t\telse {\n\t\t\tString myPath = req.getPathInfo();\n\t\t\tint pos = myPath.lastIndexOf('/');\n\t\t\tif (pos > 0)\n\t\t\t\tpath = myPath.substring(0, pos) + \"/\" + path;\n\t\t\telse\n\t\t\t\tpath = \"/\" + path;\n\t\t}\n\t\tresp.sendRedirect(path);\n\t\tresp.flushBuffer();\n\t}\n"} {"input": "\tprivate void createFile(IProject project, IPath projectRelativePath, String content,\n\t\t\tboolean firstTimeOnly, IProgressMonitor monitor) {\n\t\ttry {\n\t\t\tIContainer container = project;\n\t\t\tString[] folders = projectRelativePath.removeLastSegments(1).segments();\n\t\t\tfor (int i = 0; i < folders.length; i++) {\n\t\t\t\tcontainer = container.getFolder(new Path(folders[i]));\n\t\t\t\tif (!container.exists()) {\n\t\t\t\t\t((IFolder)container).create(true, true, monitor);\n\t\t\t\t}\n\t\t\t}\n\t\t\tIFile file = container.getFile(new Path(projectRelativePath.lastSegment()));\n\t\t\tif (!file.exists() && file.getParent().exists()) {\n\t\t\t\tIResource[] members = file.getParent().members(IResource.FILE);\n\t\t\t\tfor (int i = 0; i < members.length; i++) {\n\t\t\t\t\tif (members[i] instanceof IFile\n\t\t\t\t\t\t\t&& file.getName().toLowerCase().equals(members[i].getName().toLowerCase())) {\n\t\t\t\t\t\tfile = (IFile)members[i];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tString text = content;\n\t\t\tif (!firstTimeOnly && file.exists() && \"java\".equals(file.getFileExtension())) { \n\t\t\t\tString jmergeFile = URI.createPlatformPluginURI(\n\t\t\t\t\t\t\"org.eclipse.emf.codegen.ecore/templates/emf-merge.xml\", false).toString(); \n\t\t\t\tJControlModel model = new JControlModel();\n\t\t\t\tASTFacadeHelper astFacadeHelper = new ASTFacadeHelper();\n\t\t\t\tmodel.initialize(astFacadeHelper, jmergeFile);\n\t\t\t\tif (model.canMerge()) {\n\t\t\t\t\tJMerger jMerger = new JMerger(model);\n\t\t\t\t\tjMerger.setSourceCompilationUnit(jMerger.createCompilationUnitForContents(text));\n\t\t\t\t\ttry {\n\t\t\t\t\t\tjMerger.setTargetCompilationUnit(jMerger\n\t\t\t\t\t\t\t\t.createCompilationUnitForInputStream(new FileInputStream(file.getLocation()\n\t\t\t\t\t\t\t\t\t\t.toFile()))); \n\t\t\t\t\t\tjMerger.merge();\n\t\t\t\t\t\ttext = jMerger.getTargetCompilationUnit().getContents();\n\t\t\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\t\t\tAcceleoUIActivator.getDefault().getLog().log(\n\t\t\t\t\t\t\t\tnew Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, e.getMessage(), e));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tAcceleoUIActivator.getDefault().getLog().log(\n\t\t\t\t\t\t\tnew Status(IStatus.WARNING, AcceleoUIActivator.PLUGIN_ID, AcceleoUIMessages\n\t\t\t\t\t\t\t\t\t.getString(\"CreateRunnableAcceleoOperation.MergerFailure\"), null)); \n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!file.exists()\n\t\t\t\t\t|| (!firstTimeOnly && !text.equals(FileContent\n\t\t\t\t\t\t\t.getFileContent(file.getLocation().toFile()).toString()))) {\n\t\t\t\tByteArrayInputStream javaStream = new ByteArrayInputStream(text.getBytes(\"UTF8\")); \n\t\t\t\tif (!file.exists()) {\n\t\t\t\t\tfile.create(javaStream, true, monitor);\n\t\t\t\t} else if (!firstTimeOnly) {\n\t\t\t\t\tfile.setContents(javaStream, true, false, monitor);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (CoreException e) {\n\t\t\tIStatus status = new Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, IStatus.OK, e\n\t\t\t\t\t.getMessage(), e);\n\t\t\tAcceleoUIActivator.getDefault().getLog().log(status);\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tIStatus status = new Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, IStatus.OK, e\n\t\t\t\t\t.getMessage(), e);\n\t\t\tAcceleoUIActivator.getDefault().getLog().log(status);\n\t\t}\n\t}\n", "output": "\tprivate void createFile(IProject project, IPath projectRelativePath, String content,\n\t\t\tboolean firstTimeOnly, IProgressMonitor monitor) {\n\t\ttry {\n\t\t\tIContainer container = project;\n\t\t\tString[] folders = projectRelativePath.removeLastSegments(1).segments();\n\t\t\tfor (int i = 0; i < folders.length; i++) {\n\t\t\t\tcontainer = container.getFolder(new Path(folders[i]));\n\t\t\t\tif (!container.exists()) {\n\t\t\t\t\t((IFolder)container).create(true, true, monitor);\n\t\t\t\t}\n\t\t\t}\n\t\t\tIFile file = container.getFile(new Path(projectRelativePath.lastSegment()));\n\t\t\tif (!file.exists() && file.getParent().exists()) {\n\t\t\t\tIResource[] members = file.getParent().members(IResource.FILE);\n\t\t\t\tfor (int i = 0; i < members.length; i++) {\n\t\t\t\t\tif (members[i] instanceof IFile\n\t\t\t\t\t\t\t&& file.getName().toLowerCase().equals(members[i].getName().toLowerCase())) {\n\t\t\t\t\t\tfile = (IFile)members[i];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tString text = content;\n\t\t\tif (!firstTimeOnly && file.exists() && \"java\".equals(file.getFileExtension())) { \n\t\t\t\tString jmergeFile = URI.createPlatformPluginURI(\n\t\t\t\t\t\t\"org.eclipse.emf.codegen.ecore/templates/emf-merge.xml\", false).toString(); \n\t\t\t\tJControlModel model = new JControlModel();\n\t\t\t\tASTFacadeHelper astFacadeHelper = new ASTFacadeHelper();\n\t\t\t\tmodel.initialize(astFacadeHelper, jmergeFile);\n\t\t\t\tif (model.canMerge()) {\n\t\t\t\t\tJMerger jMerger = new JMerger(model);\n\t\t\t\t\tjMerger.setSourceCompilationUnit(jMerger.createCompilationUnitForContents(text));\n\t\t\t\t\ttry {\n\t\t\t\t\t\tjMerger.setTargetCompilationUnit(jMerger\n\t\t\t\t\t\t\t\t.createCompilationUnitForInputStream(new FileInputStream(file.getLocation()\n\t\t\t\t\t\t\t\t\t\t.toFile()))); \n\t\t\t\t\t\tjMerger.merge();\n\t\t\t\t\t\ttext = jMerger.getTargetCompilationUnit().getContents();\n\t\t\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\t\t\tAcceleoUIActivator.getDefault().getLog().log(\n\t\t\t\t\t\t\t\tnew Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, e.getMessage(), e));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tAcceleoUIActivator.getDefault().getLog().log(\n\t\t\t\t\t\t\tnew Status(IStatus.WARNING, AcceleoUIActivator.PLUGIN_ID, AcceleoUIMessages\n\t\t\t\t\t\t\t\t\t.getString(\"CreateRunnableAcceleoOperation.MergerUnusable\"), null)); \n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!file.exists()\n\t\t\t\t\t|| (!firstTimeOnly && !text.equals(FileContent\n\t\t\t\t\t\t\t.getFileContent(file.getLocation().toFile()).toString()))) {\n\t\t\t\tByteArrayInputStream javaStream = new ByteArrayInputStream(text.getBytes(\"UTF8\")); \n\t\t\t\tif (!file.exists()) {\n\t\t\t\t\tfile.create(javaStream, true, monitor);\n\t\t\t\t} else if (!firstTimeOnly) {\n\t\t\t\t\tfile.setContents(javaStream, true, false, monitor);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (CoreException e) {\n\t\t\tIStatus status = new Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, IStatus.OK, e\n\t\t\t\t\t.getMessage(), e);\n\t\t\tAcceleoUIActivator.getDefault().getLog().log(status);\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tIStatus status = new Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, IStatus.OK, e\n\t\t\t\t\t.getMessage(), e);\n\t\t\tAcceleoUIActivator.getDefault().getLog().log(status);\n\t\t}\n\t}\n"} {"input": "\tpublic void onCreate(Bundle savedInstanceState) {\n getActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.holo_blue_dark)));\n getActionBar().setDisplayShowHomeEnabled(true);\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.main);\n\t\tfinal Button button = (Button)findViewById(R.id.button);\n\t\tbutton.setOnClickListener(new OnClickListener(){\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tpbarDialog = ProgressDialog.show(IconRequest.this,\n\t\t\t\t\t\t\"Please wait...\", \"Gathering application info...\", true);\n\t\t\t\tThread designriftsThread = new Thread()\n\t\t\t\t{\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run()\n\t\t\t\t\t{\n\t\t\t\t\t\tLooper.prepare();\n\t\t\t\t\t\tfinal File save_loc = new File(SAVE_LOC);\n\t\t\t\t\t\tsave_loc.mkdirs();\n\t\t\t\t\t\tfinal PackageManager packageManager = getPackageManager();\n\t\t\t\t\t\tfinal StringBuilder sb = new StringBuilder( );\n\t\t\t\t\t\tfinal Intent intent = new Intent(\"android.intent.action.MAIN\");\n\t\t\t\t\t\tintent.addCategory(\"android.intent.category.LAUNCHER\");\n\t\t\t\t\t\tfinal List<ResolveInfo> activities = packageManager.queryIntentActivities( intent, 0 );\n\t\t\t\t\t\tfinal int size = activities.size();\n\t\t\t\t\t\tif (size == 0) {\n\t\t\t\t\t\t\tfinish();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int i = 0; i < size; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfinal ResolveInfo info = activities.get(i);\n\t\t\t\t\t\t\tfinal String label = info.loadLabel(packageManager).toString();\n\t\t\t\t\t\t\tfinal Drawable icon = info.loadIcon(packageManager);\n\t\t\t\t\t\t\tfinal String pkgName = info.activityInfo.packageName;\n\t\t\t\t\t\t\tfinal String className = info.activityInfo.name;\n\t\t\t\t\t\t\tsb.append(\"<!-- \" + label + \" -->\\n<item component=\\\"\"+pkgName+\"/\"+className+\"\\\" drawable=\\\"\"+label+\"\\\" />\");\n\t\t\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\t\t\tBitmap bitmap = ((BitmapDrawable)icon).getBitmap();\n\t\t\t\t\t\t\tFileOutputStream fOut;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tfOut = new FileOutputStream(SAVE_LOC + \"/\" + pkgName + \".png\");\n\t\t\t\t\t\t\t\tbitmap.compress(Bitmap.CompressFormat.PNG,100,fOut);\n\t\t\t\t\t\t\t\tfOut.flush();fOut.close();\n\t\t\t\t\t\t\t} catch (FileNotFoundException e) {\t} \n\t\t\t\t\t\t\tcatch (IOException e) {\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tFileWriter fstream = new FileWriter(SAVE_LOC + \"/+appfilter.xml\");\n\t\t\t\t\t\t\tBufferedWriter out = new BufferedWriter(fstream);\n\t\t\t\t\t\t\tout.write(sb.toString());\n\t\t\t\t\t\t\tout.close();\n\t\t\t\t\t\t} catch (Exception e){}\n\t\t\t\t\t\tcreateZipFile(SAVE_LOC, true, SD + \"/\" + android.os.Build.MODEL + \".zip\");\n\t\t\t\t\t\thandler.sendEmptyMessage(0);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tdesignriftsThread.start();\t\t\t\t\n\t\t\t}\n\t\t});\n\t}\n", "output": "\tpublic void onCreate(Bundle savedInstanceState) {\n getActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.holo_blue_dark)));\n getActionBar().setDisplayShowHomeEnabled(true);\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.main);\n\t\tfinal Button button = (Button)findViewById(R.id.button);\n\t\tbutton.setOnClickListener(new OnClickListener(){\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tpbarDialog = ProgressDialog.show(IconRequest.this,\n\t\t\t\t\t\t\"Please wait...\", \"Gathering application info...\", true);\n\t\t\t\tThread designriftsThread = new Thread()\n\t\t\t\t{\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run()\n\t\t\t\t\t{\n\t\t\t\t\t\tLooper.prepare();\n\t\t\t\t\t\tfinal File save_loc = new File(SAVE_LOC);\n\t\t\t\t\t\tsave_loc.mkdirs();\n\t\t\t\t\t\tfinal PackageManager packageManager = getPackageManager();\n\t\t\t\t\t\tfinal StringBuilder sb = new StringBuilder( );\n\t\t\t\t\t\tfinal Intent intent = new Intent(\"android.intent.action.MAIN\");\n\t\t\t\t\t\tintent.addCategory(\"android.intent.category.LAUNCHER\");\n\t\t\t\t\t\tfinal List<ResolveInfo> activities = packageManager.queryIntentActivities( intent, 0 );\n\t\t\t\t\t\tfinal int size = activities.size();\n\t\t\t\t\t\tif (size == 0) {\n\t\t\t\t\t\t\tfinish();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int i = 0; i < size; i++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfinal ResolveInfo info = activities.get(i);\n\t\t\t\t\t\t\tfinal String label = info.loadLabel(packageManager).toString();\n\t\t\t\t\t\t\tfinal Drawable icon = info.loadIcon(packageManager);\n\t\t\t\t\t\t\tfinal String pkgName = info.activityInfo.packageName;\n\t\t\t\t\t\t\tfinal String className = info.activityInfo.name;\n\t\t\t\t\t\t\tsb.append(\"<!-- \" + label + \" -->\\n<!-- \" + pkgName + \" -->\\n<item component=\\\"\"+pkgName+\"/\"+className+\"\\\" drawable=\\\"\"+label.replace(\" \", \"\")+\"\\\" />\");\n\t\t\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\t\t\tBitmap bitmap = ((BitmapDrawable)icon).getBitmap();\n\t\t\t\t\t\t\tFileOutputStream fOut;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tfOut = new FileOutputStream(SAVE_LOC + \"/\" + pkgName + \".png\");\n\t\t\t\t\t\t\t\tbitmap.compress(Bitmap.CompressFormat.PNG,100,fOut);\n\t\t\t\t\t\t\t\tfOut.flush();fOut.close();\n\t\t\t\t\t\t\t} catch (FileNotFoundException e) {\t} \n\t\t\t\t\t\t\tcatch (IOException e) {\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tFileWriter fstream = new FileWriter(SAVE_LOC + \"/appfilter.xml\");\n\t\t\t\t\t\t\tBufferedWriter out = new BufferedWriter(fstream);\n\t\t\t\t\t\t\tout.write(sb.toString());\n\t\t\t\t\t\t\tout.close();\n\t\t\t\t\t\t} catch (Exception e){}\n\t\t\t\t\t\tcreateZipFile(SAVE_LOC, true, SD + \"/\" + android.os.Build.MODEL + \".zip\");\n\t\t\t\t\t\thandler.sendEmptyMessage(0);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tdesignriftsThread.start();\t\t\t\t\n\t\t\t}\n\t\t});\n\t}\n"} {"input": " public void testEventAssertion() throws Exception {\n KnowledgeBase kbase = loadKnowledgeBase( \"test_EntryPoint.drl\" );\n KnowledgeSessionConfiguration conf = new SessionConfiguration();\n ((SessionConfiguration) conf).setClockType( ClockType.PSEUDO_CLOCK );\n StatefulKnowledgeSession session = kbase.newStatefulSession( conf );\n final List results = new ArrayList();\n session.setGlobal( \"results\",\n results );\n StockTick tick1 = new StockTick( 1,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n StockTick tick2 = new StockTick( 2,\n \"ACME\",\n 10,\n System.currentTimeMillis() );\n StockTick tick3 = new StockTick( 3,\n \"ACME\",\n 10,\n System.currentTimeMillis() );\n StockTick tick4 = new StockTick( 4,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n InternalFactHandle handle1 = (InternalFactHandle) session.insert( tick1 );\n InternalFactHandle handle2 = (InternalFactHandle) session.insert( tick2 );\n InternalFactHandle handle3 = (InternalFactHandle) session.insert( tick3 );\n InternalFactHandle handle4 = (InternalFactHandle) session.insert( tick4 );\n assertNotNull( handle1 );\n assertNotNull( handle2 );\n assertNotNull( handle3 );\n assertNotNull( handle4 );\n assertTrue( handle1.isEvent() );\n assertTrue( handle2.isEvent() );\n assertTrue( handle3.isEvent() );\n assertTrue( handle4.isEvent() );\n session.fireAllRules();\n assertEquals( 0,\n results.size() );\n StockTick tick5 = new StockTick( 5,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n StockTick tick6 = new StockTick( 6,\n \"ACME\",\n 10,\n System.currentTimeMillis() );\n StockTick tick7 = new StockTick( 7,\n \"ACME\",\n 15,\n System.currentTimeMillis() );\n StockTick tick8 = new StockTick( 8,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n WorkingMemoryEntryPoint entry = session.getWorkingMemoryEntryPoint( \"StockStream\" );\n InternalFactHandle handle5 = (InternalFactHandle) entry.insert( tick5 );\n InternalFactHandle handle6 = (InternalFactHandle) entry.insert( tick6 );\n InternalFactHandle handle7 = (InternalFactHandle) entry.insert( tick7 );\n InternalFactHandle handle8 = (InternalFactHandle) entry.insert( tick8 );\n assertNotNull( handle5 );\n assertNotNull( handle6 );\n assertNotNull( handle7 );\n assertNotNull( handle8 );\n assertTrue( handle5.isEvent() );\n assertTrue( handle6.isEvent() );\n assertTrue( handle7.isEvent() );\n assertTrue( handle8.isEvent() );\n session.fireAllRules();\n assertEquals( 1,\n results.size() );\n assertSame( tick7,\n results.get( 0 ) );\n }\n", "output": " public void testEventAssertion() throws Exception {\n KnowledgeBase kbase = loadKnowledgeBase( \"test_EntryPoint.drl\" );\n KnowledgeSessionConfiguration conf = new SessionConfiguration();\n ((SessionConfiguration) conf).setClockType( ClockType.PSEUDO_CLOCK );\n StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession( conf );\n final List results = new ArrayList();\n session.setGlobal( \"results\",\n results );\n StockTick tick1 = new StockTick( 1,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n StockTick tick2 = new StockTick( 2,\n \"ACME\",\n 10,\n System.currentTimeMillis() );\n StockTick tick3 = new StockTick( 3,\n \"ACME\",\n 10,\n System.currentTimeMillis() );\n StockTick tick4 = new StockTick( 4,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n InternalFactHandle handle1 = (InternalFactHandle) session.insert( tick1 );\n InternalFactHandle handle2 = (InternalFactHandle) session.insert( tick2 );\n InternalFactHandle handle3 = (InternalFactHandle) session.insert( tick3 );\n InternalFactHandle handle4 = (InternalFactHandle) session.insert( tick4 );\n assertNotNull( handle1 );\n assertNotNull( handle2 );\n assertNotNull( handle3 );\n assertNotNull( handle4 );\n assertTrue( handle1.isEvent() );\n assertTrue( handle2.isEvent() );\n assertTrue( handle3.isEvent() );\n assertTrue( handle4.isEvent() );\n session.fireAllRules();\n assertEquals( 0,\n results.size() );\n StockTick tick5 = new StockTick( 5,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n StockTick tick6 = new StockTick( 6,\n \"ACME\",\n 10,\n System.currentTimeMillis() );\n StockTick tick7 = new StockTick( 7,\n \"ACME\",\n 15,\n System.currentTimeMillis() );\n StockTick tick8 = new StockTick( 8,\n \"DROO\",\n 50,\n System.currentTimeMillis() );\n WorkingMemoryEntryPoint entry = session.getWorkingMemoryEntryPoint( \"StockStream\" );\n InternalFactHandle handle5 = (InternalFactHandle) entry.insert( tick5 );\n InternalFactHandle handle6 = (InternalFactHandle) entry.insert( tick6 );\n InternalFactHandle handle7 = (InternalFactHandle) entry.insert( tick7 );\n InternalFactHandle handle8 = (InternalFactHandle) entry.insert( tick8 );\n assertNotNull( handle5 );\n assertNotNull( handle6 );\n assertNotNull( handle7 );\n assertNotNull( handle8 );\n assertTrue( handle5.isEvent() );\n assertTrue( handle6.isEvent() );\n assertTrue( handle7.isEvent() );\n assertTrue( handle8.isEvent() );\n session.fireAllRules();\n assertEquals( 1,\n results.size() );\n assertSame( tick7,\n results.get( 0 ) );\n }\n"} {"input": " void run_sequence_search(int solveKind, SimpleNode kind, SearchItem si) {\n\tsingleSearch = false;\n\tthis.si = si;\n\tif (options.getVerbose()) {\n\t String solve=\"notKnown\";\n\t switch (solveKind) {\n\t case 0: solve = \"%% satisfy\"; break; \n\t case 1: \n\t\tsolve = \"%% minimize(\"+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+\") \"; break; \n\t case 2: \n\t\tsolve = \"%% maximize(\"+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+\") \"; break; \n\t }\n\t System.out.println(solve + \" : seq_search([\" + si + \"])\");\n\t}\n\tDepthFirstSearch<Var> masterLabel = null;\n\tDepthFirstSearch<Var> last_search = null;\n\tSelectChoicePoint<Var> masterSelect = null;\n\tlist_seq_searches = new ArrayList<Search<Var>>();\n\tfor (int i=0; i<si.getSearchItems().size(); i++) {\n\t if (i == 0) { \n\t\tmasterLabel = sub_search(si.getSearchItems().get(i), masterLabel, true);\n\t\tlast_search = masterLabel;\n\t\tmasterSelect = variable_selection;\n\t\tif (!print_search_info) masterLabel.setPrintInfo(false);\n\t }\n\t else {\n\t\tDepthFirstSearch<Var> label = sub_search(si.getSearchItems().get(i), last_search, false);\n\t\tlast_search.addChildSearch(label);\n\t\tlast_search = label;\n\t\tif (!print_search_info) last_search.setPrintInfo(false);\n\t }\n\t}\n \tDepthFirstSearch<Var>[] complementary_search = setSubSearchForAll(last_search, options);\t\n for (DepthFirstSearch<Var> aComplementary_search : complementary_search) {\n if (aComplementary_search != null) {\n list_seq_searches.add(aComplementary_search);\n if (!print_search_info) aComplementary_search.setPrintInfo(false);\n }\n }\n\tResult = false;\t\n\tIntVar cost;\n\toptimization = false;\n\tSearch<Var> final_search_seq = list_seq_searches.get(list_seq_searches.size()-1);\n\ttread = java.lang.Thread.currentThread();\n\tjava.lang.management.ThreadMXBean b = java.lang.management.ManagementFactory.getThreadMXBean();\n\tsearchTimeMeter = b;\n\tstartCPU = b.getThreadCpuTime(tread.getId());\n\tint to = options.getTimeOut();\n\tif (to > 0)\n\t for (Search s : list_seq_searches)\n\t\ts.setTimeOut(to);\n\tint ns = options.getNumberSolutions();\n\tif (si.exploration() == null || si.exploration().equals(\"complete\"))\n\t switch (solveKind) {\n\t case 0: \n \t\tif (options.getAll() ) { \n \t\t for (int i=0; i<si.getSearchItems().size(); i++) { \n \t\t\tlist_seq_searches.get(i).getSolutionListener().searchAll(true);\n \t\t\tlist_seq_searches.get(i).getSolutionListener().recordSolutions(false);\n \t\t\tif ( ns>0 )\n \t\t\t list_seq_searches.get(i).getSolutionListener().setSolutionLimit(ns);\n \t\t }\n \t\t}\n\t\tResult = masterLabel.labeling(store, masterSelect);\n\t\tbreak;\n\t case 1: \n\t\toptimization = true;\n\t\tcost = getCost((ASTSolveExpr)kind.jjtGetChild(0));\n\t\tfor (Search<Var> list_seq_searche : list_seq_searches)\n\t\t list_seq_searche.setOptimize(true);\n\t\tif (ns > 0) {\n\t\t for (int i=0; i<list_seq_searches.size()-1; i++)\n\t\t \t((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice = true;\n\t\t final_search_seq.getSolutionListener().setSolutionLimit(ns);\n\t\t ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice = true;\n\t\t}\n\t\tResult = masterLabel.labeling(store, masterSelect, cost);\n\t\tbreak;\n\t case 2: \n\t\toptimization = true;\n\t\tcost = getCost((ASTSolveExpr)kind.jjtGetChild(0));\n\t\tIntVar max_cost = new IntVar(store, \"-\"+cost.id(), IntDomain.MinInt, \n\t\t \t\t\t\t\t\t IntDomain.MaxInt);\n\t\tpose(new XplusYeqC(max_cost, cost, 0));\n for (Search<Var> list_seq_searche : list_seq_searches)\n list_seq_searche.setOptimize(true);\n\t\tif (ns > 0) {\n\t\t for (int i=0; i<list_seq_searches.size()-1; i++)\n\t\t\t((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice=true;\n\t\t final_search_seq.getSolutionListener().setSolutionLimit(ns);\n\t\t ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice=true;\n\t\t}\n\t\tResult = masterLabel.labeling(store, masterSelect, max_cost);\n\t\tbreak;\n\t }\n\telse {\n\t System.err.println(\"Not recognized or supported \"+si.exploration()+\n\t\t\t \" search explorarion strategy ; compilation aborted\");\n\t System.exit(0);\n\t}\n\tprintStatisticsForSeqSearch(false);\n }\n void printStatisticsForSeqSearch(boolean interrupted) {\n\tif (list_seq_searches == null) {\n\t System.out.println (\"%% =====INTERRUPTED=====\\n%% Model not yet posed..\");\n\t return;\n\t}\n\tif (Result) {\n\t if (!optimization && options.getAll()) {\n\t\tif (!heuristicSeqSearch)\n\t\t if (! anyTimeOutOccured(list_seq_searches)) {\n\t\t\tif (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())\n\t\t\t System.out.println(\"==========\");\n\t\t }\n\t\t else\n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t\telse\n\t\t if (anyTimeOutOccured(list_seq_searches)) \n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t }\n\t else if (optimization) {\n\t\tif (!heuristicSeqSearch)\n\t\t if (! anyTimeOutOccured(list_seq_searches)) {\n\t\t\tif (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())\n\t\t\t System.out.println(\"==========\");\n\t\t }\n\t\t else\n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t\telse\n\t\t if (anyTimeOutOccured(list_seq_searches)) \n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t }\n\t}\n\telse\n\t if (anyTimeOutOccured(list_seq_searches)) {\n\t\tSystem.out.println(\"=====UNKNOWN=====\");\n\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t }\n\t else\n\t\tif (interrupted)\n\t\t System.out.println (\"%% =====INTERRUPTED=====\");\n\t\telse\n\t\t System.out.println(\"=====UNSATISFIABLE=====\");\n\tif (options.getStatistics()) {\n\t int nodes=0, decisions=0, wrong=0, backtracks=0, depth=0,solutions=0;\n for (Search<Var> label : list_seq_searches) {\n nodes += label.getNodes();\n decisions += label.getDecisions();\n wrong += label.getWrongDecisions();\n backtracks += label.getBacktracks();\n depth += label.getMaximumDepth();\n solutions = label.getSolutionListener().solutionsNo();\n }\n\tSystem.out.println(\"\\n%% Model variables : \"+ (store.size()+ NumberBoolVariables) +\n\t\t\t \"\\n%% Model constraints : \"+initNumberConstraints+\n\t\t\t \"\\n\\n%% Search CPU time : \" + (searchTimeMeter.getThreadCpuTime(tread.getId()) - startCPU)/(long)1e+6 + \"ms\"+\n\t\t\t \"\\n%% Search nodes : \"+nodes+\n\t\t\t \"\\n%% Search decisions : \"+decisions+\n\t\t\t \"\\n%% Wrong search decisions : \"+wrong+\n\t\t\t \"\\n%% Search backtracks : \"+backtracks+\n\t\t\t \"\\n%% Max search depth : \"+depth+\n\t\t\t \"\\n%% Number solutions : \"+ solutions \n\t\t\t );\n\t}\n }\n boolean anyTimeOutOccured(ArrayList<Search<Var>> list_seq_searches) {\n for (Search<Var> list_seq_searche : list_seq_searches)\n if (((DepthFirstSearch) list_seq_searche).timeOutOccured)\n return true;\n\treturn false;\n }\n DepthFirstSearch<Var> sub_search(SearchItem si, DepthFirstSearch<Var> l, boolean master) {\n\tDepthFirstSearch<Var> last_search = l;\n\tDepthFirstSearch<Var> label = null;\n\tif (si.type().equals(\"int_search\") || si.type().equals(\"bool_search\")) {\n\t label = int_search(si);\n\t if (!master) label.setSelectChoicePoint(variable_selection);\n\t if (si.exploration().equals(\"lds\")) {\n\t\tlds_search(label, si.ldsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t if (si.exploration().equals(\"credit\")) {\n\t\tcredit_search(label, si.creditValue, si.bbsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t list_seq_searches.add(label);\n\t}\n\telse if (si.type().equals(\"set_search\")) {\n\t setSearch=true;\n\t label = set_search(si);\n\t if (!master) \n\t\tlabel.setSelectChoicePoint(variable_selection);\n\t if (si.exploration().equals(\"lds\")) {\n\t\tlds_search(label, si.ldsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t if (si.exploration().equals(\"credit\")) {\n\t\tcredit_search(label, si.creditValue, si.bbsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t list_seq_searches.add(label);\n\t}\n\telse if (si.type().equals(\"seq_search\")) {\n\t for (int i=0; i<si.getSearchItems().size(); i++)\n\t\tif (i == 0) { \n\t\t DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);\n\t\t last_search = label_seq;\n\t\t label = label_seq;\n\t\t}\n\t\telse {\n\t\t DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);\n\t\t last_search.addChildSearch(label_seq);\n\t\t last_search = label_seq;\n\t\t}\n\t}\n\telse {\n\t System.err.println(\"Not recognized or supported search type \\\"\"+si.type()+\"\\\"; compilation aborted\");\n\t System.exit(0);\n\t}\n\treturn label;\n }\n DepthFirstSearch<Var> int_search(SearchItem si) {\n variable_selection = si.getIntSelect();\n return new DepthFirstSearch<Var>();\n }\n DepthFirstSearch<Var> set_search(SearchItem si) {\n variable_selection = si.getSetSelect();\n return new DepthFirstSearch<Var>();\n }\n void printSolution() {\n\tif (dictionary.outputVariables.size() > 0)\n\t for (int i=0; i<dictionary.outputVariables.size(); i++) {\n\t\tVar v = dictionary.outputVariables.get(i);\n \t\tif (v instanceof BooleanVar) {\n\t\t String boolVar = v.id()+\" = \";\n\t\t if (v.singleton())\n\t\t\tswitch ( ((BooleanVar)v).value()) {\n\t\t\tcase 0: boolVar += \"false\";\n\t\t\t break;\n\t\t\tcase 1: boolVar += \"true\";\n\t\t\t break;\n\t\t\tdefault: boolVar += v.dom();\n\t\t\t}\n\t\t else\n\t\t\tboolVar += \"false..true\";\n\t\t System.out.println(boolVar+\";\");\n\t\t}\n\t\telse if (v instanceof SetVar) {\n\t\t String setVar = v.id() + \" = \";\n\t\t if (v.singleton()) {\n\t\t\tIntDomain glb = ((SetVar)v).dom().glb();\n\t\t\tsetVar += \"{\";\n\t\t\tfor (ValueEnumeration e = glb.valueEnumeration(); e.hasMoreElements();) {\n\t\t\t int element = e.nextElement();\n\t\t\t setVar += element;\n\t\t\t if (e.hasMoreElements())\n\t\t\t\tsetVar += \", \";\n\t\t\t}\n\t\t\tsetVar += \"}\";\n\t\t }\n\t\t else\n\t\t\tsetVar += v.dom().toString();\n\t\t System.out.println(setVar+\";\");\n\t\t}\n\t\telse\n\t\t System.out.println(v+\";\");\n\t }\n\tfor (int i=0; i<dictionary.outputArray.size(); i++) {\n\t OutputArrayAnnotation a = dictionary.outputArray.get(i);\n\t System.out.println(a);\n\t}\n }\n int getKind(String k) {\n\tif (k.equals(\"satisfy\")) \n\t return 0;\n\telse if (k.equals(\"minimize\")) \n\t return 1;\n\telse if (k.equals(\"maximize\")) \n\t return 2;\n\telse {\n\t System.err.println(\"Not supported search kind; compilation aborted\");\n\t System.exit(0);\n\t return -1;\n\t}\n }\n IntVar getCost(ASTSolveExpr node) {\n\tif (node.getType() == 0) \n\t return dictionary.getVariable(node.getIdent());\n\telse if (node.getType() == 1) \n\t return dictionary.getVariableArray(node.getIdent())[node.getIndex()];\n\telse {\n\t System.err.println(\"Wrong cost function specification \" + node);\n\t System.exit(0);\n\t return new IntVar(store);\n\t}\n }\n void pose(Constraint c) {\n\tstore.impose(c);\n\tif (debug)\n\t System.out.println(c);\n }\n void lds_search(DepthFirstSearch<Var> label, int lds_value) {\n\tLDS<Var> lds = new LDS<Var>(lds_value); \n\tif (label.getExitChildListener() == null)\n\t label.setExitChildListener(lds);\n\telse\n\t label.getExitChildListener().setChildrenListeners(lds);\n }\n void credit_search(DepthFirstSearch<Var> label, int creditValue, int bbsValue) {\n\tint maxDepth = 1000; \n\tCreditCalculator<Var> credit = new CreditCalculator<Var>(creditValue, bbsValue, maxDepth);\n\tif (label.getConsistencyListener() == null)\n\t label.setConsistencyListener(credit);\n\telse\n\t label.getConsistencyListener().setChildrenListeners(credit);\n\tlabel.setExitChildListener(credit);\n\tlabel.setTimeOutListener(credit);\n }\n void setNumberBoolVariables(int n) {\n\tNumberBoolVariables = n;\n }\n void printSearch(Search label) {\n\tint N = 1;\n\tSystem.out.println (N++ + \". \" + label);\n\tjava.util.LinkedHashSet<Search<? extends Var>> l = \n\t new java.util.LinkedHashSet<Search<? extends Var>>();\n\tl.add(label);\n\twhile (l.size() != 0) {\n\t java.util.LinkedHashSet<Search<? extends Var>> ns = \n\t\tnew java.util.LinkedHashSet<Search<? extends Var>>();\n\t for (Search s1 : l) {\n\t\tSearch<? extends Var>[] child = ((DepthFirstSearch)s1).childSearches;\n\t\tif (child != null)\n\t\t for (Search s : child) {\n\t\t\tSystem.out.println (N + \". \" + s);\n\t\t\tns.add(s);\t\n\t\t }\n\t }\n\t N++;\n\t l = ns;\n\t}\n }\n int FinalNumberSolutions = 0;\n public class CostListener<T extends Var> extends SimpleSolutionListener<T> {\n\tpublic boolean executeAfterSolution(Search<T> search, SelectChoicePoint<T> select) {\n\t boolean returnCode = super.executeAfterSolution(search, select);\n\t if (costVariable != null)\n\t\tcostValue = ((IntVar)costVariable).value();\n\t FinalNumberSolutions++;\n\t printSolution();\n\t System.out.println(\"----------\");\n\t return returnCode;\n\t}\n }\n class DomainSizeComparator<T extends Var> implements Comparator<T> {\n\tDomainSizeComparator() { }\n\tpublic int compare(T o1, T o2) {\n\t int v1 = o1.getSize();\n\t int v2 = o2.getSize();\n\t return v1 - v2;\n\t}\n }\n}\n", "output": " void run_sequence_search(int solveKind, SimpleNode kind, SearchItem si) {\n\tsingleSearch = false;\n\tthis.si = si;\n\tif (options.getVerbose()) {\n\t String solve=\"notKnown\";\n\t switch (solveKind) {\n\t case 0: solve = \"%% satisfy\"; break; \n\t case 1: \n\t\tsolve = \"%% minimize(\"+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+\") \"; break; \n\t case 2: \n\t\tsolve = \"%% maximize(\"+ getCost((ASTSolveExpr)kind.jjtGetChild(0))+\") \"; break; \n\t }\n\t System.out.println(solve + \" : seq_search([\" + si + \"])\");\n\t}\n\tDepthFirstSearch<Var> masterLabel = null;\n\tDepthFirstSearch<Var> last_search = null;\n\tSelectChoicePoint<Var> masterSelect = null;\n\tlist_seq_searches = new ArrayList<Search<Var>>();\n\tfor (int i=0; i<si.getSearchItems().size(); i++) {\n\t if (i == 0) { \n\t\tmasterLabel = sub_search(si.getSearchItems().get(i), masterLabel, true);\n\t\tlast_search = masterLabel;\n\t\tmasterSelect = variable_selection;\n\t\tif (!print_search_info) masterLabel.setPrintInfo(false);\n\t }\n\t else {\n\t\tDepthFirstSearch<Var> label = sub_search(si.getSearchItems().get(i), last_search, false);\n\t\tlast_search.addChildSearch(label);\n\t\tlast_search = label;\n\t\tif (!print_search_info) last_search.setPrintInfo(false);\n\t }\n\t}\n \tDepthFirstSearch<Var>[] complementary_search = setSubSearchForAll(last_search, options);\t\n for (DepthFirstSearch<Var> aComplementary_search : complementary_search) {\n if (aComplementary_search != null) {\n list_seq_searches.add(aComplementary_search);\n if (!print_search_info) aComplementary_search.setPrintInfo(false);\n }\n }\n\tResult = false;\t\n\tIntVar cost;\n\toptimization = false;\n\tfinal_search_seq = list_seq_searches.get(list_seq_searches.size()-1);\n\ttread = java.lang.Thread.currentThread();\n\tjava.lang.management.ThreadMXBean b = java.lang.management.ManagementFactory.getThreadMXBean();\n\tsearchTimeMeter = b;\n\tstartCPU = b.getThreadCpuTime(tread.getId());\n\tint to = options.getTimeOut();\n\tif (to > 0)\n\t for (Search s : list_seq_searches)\n\t\ts.setTimeOut(to);\n\tint ns = options.getNumberSolutions();\n\tif (si.exploration() == null || si.exploration().equals(\"complete\"))\n\t switch (solveKind) {\n\t case 0: \n \t\tif (options.getAll() ) { \n \t\t for (int i=0; i<si.getSearchItems().size(); i++) { \n \t\t\tlist_seq_searches.get(i).getSolutionListener().searchAll(true);\n \t\t\tlist_seq_searches.get(i).getSolutionListener().recordSolutions(false);\n \t\t\tif ( ns>0 )\n \t\t\t list_seq_searches.get(i).getSolutionListener().setSolutionLimit(ns);\n \t\t }\n \t\t}\n\t\tResult = masterLabel.labeling(store, masterSelect);\n\t\tbreak;\n\t case 1: \n\t\toptimization = true;\n\t\tcost = getCost((ASTSolveExpr)kind.jjtGetChild(0));\n\t\tfor (Search<Var> list_seq_searche : list_seq_searches)\n\t\t list_seq_searche.setOptimize(true);\n\t\tif (ns > 0) {\n\t\t for (int i=0; i<list_seq_searches.size()-1; i++)\n\t\t \t((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice = true;\n\t\t final_search_seq.getSolutionListener().setSolutionLimit(ns);\n\t\t ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice = true;\n\t\t}\n\t\tResult = masterLabel.labeling(store, masterSelect, cost);\n\t\tbreak;\n\t case 2: \n\t\toptimization = true;\n\t\tcost = getCost((ASTSolveExpr)kind.jjtGetChild(0));\n\t\tIntVar max_cost = new IntVar(store, \"-\"+cost.id(), IntDomain.MinInt, \n\t\t \t\t\t\t\t\t IntDomain.MaxInt);\n\t\tpose(new XplusYeqC(max_cost, cost, 0));\n for (Search<Var> list_seq_searche : list_seq_searches)\n list_seq_searche.setOptimize(true);\n\t\tif (ns > 0) {\n\t\t for (int i=0; i<list_seq_searches.size()-1; i++)\n\t\t\t((DepthFirstSearch)list_seq_searches.get(i)).respectSolutionListenerAdvice=true;\n\t\t final_search_seq.getSolutionListener().setSolutionLimit(ns);\n\t\t ((DepthFirstSearch)final_search_seq).respectSolutionListenerAdvice=true;\n\t\t}\n\t\tResult = masterLabel.labeling(store, masterSelect, max_cost);\n\t\tbreak;\n\t }\n\telse {\n\t System.err.println(\"Not recognized or supported \"+si.exploration()+\n\t\t\t \" search explorarion strategy ; compilation aborted\");\n\t System.exit(0);\n\t}\n\tprintStatisticsForSeqSearch(false);\n }\n void printStatisticsForSeqSearch(boolean interrupted) {\n\tif (list_seq_searches == null) {\n\t System.out.println (\"%% =====INTERRUPTED=====\\n%% Model not yet posed..\");\n\t return;\n\t}\n\tif (Result) {\n\t if (!optimization && options.getAll()) {\n\t\tif (!heuristicSeqSearch)\n\t\t if (! anyTimeOutOccured(list_seq_searches)) {\n\t\t\tif (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())\n\t\t\t System.out.println(\"==========\");\n\t\t }\n\t\t else\n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t\telse\n\t\t if (anyTimeOutOccured(list_seq_searches)) \n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t }\n\t else if (optimization) {\n\t\tif (!heuristicSeqSearch)\n\t\t if (! anyTimeOutOccured(list_seq_searches)) {\n\t\t\tif (options.getNumberSolutions() == -1 || options.getNumberSolutions() > final_search_seq.getSolutionListener().solutionsNo())\n\t\t\t System.out.println(\"==========\");\n\t\t }\n\t\t else\n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t\telse\n\t\t if (anyTimeOutOccured(list_seq_searches)) \n\t\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t }\n\t}\n\telse\n\t if (anyTimeOutOccured(list_seq_searches)) {\n\t\tSystem.out.println(\"=====UNKNOWN=====\");\n\t\tSystem.out.println(\"%% =====TIME-OUT=====\");\n\t }\n\t else\n\t\tif (interrupted)\n\t\t System.out.println (\"%% =====INTERRUPTED=====\");\n\t\telse\n\t\t System.out.println(\"=====UNSATISFIABLE=====\");\n\tif (options.getStatistics()) {\n\t int nodes=0, decisions=0, wrong=0, backtracks=0, depth=0,solutions=0;\n for (Search<Var> label : list_seq_searches) {\n nodes += label.getNodes();\n decisions += label.getDecisions();\n wrong += label.getWrongDecisions();\n backtracks += label.getBacktracks();\n depth += label.getMaximumDepth();\n solutions = label.getSolutionListener().solutionsNo();\n }\n\tSystem.out.println(\"\\n%% Model variables : \"+ (store.size()+ NumberBoolVariables) +\n\t\t\t \"\\n%% Model constraints : \"+initNumberConstraints+\n\t\t\t \"\\n\\n%% Search CPU time : \" + (searchTimeMeter.getThreadCpuTime(tread.getId()) - startCPU)/(long)1e+6 + \"ms\"+\n\t\t\t \"\\n%% Search nodes : \"+nodes+\n\t\t\t \"\\n%% Search decisions : \"+decisions+\n\t\t\t \"\\n%% Wrong search decisions : \"+wrong+\n\t\t\t \"\\n%% Search backtracks : \"+backtracks+\n\t\t\t \"\\n%% Max search depth : \"+depth+\n\t\t\t \"\\n%% Number solutions : \"+ solutions \n\t\t\t );\n\t}\n }\n boolean anyTimeOutOccured(ArrayList<Search<Var>> list_seq_searches) {\n for (Search<Var> list_seq_searche : list_seq_searches)\n if (((DepthFirstSearch) list_seq_searche).timeOutOccured)\n return true;\n\treturn false;\n }\n DepthFirstSearch<Var> sub_search(SearchItem si, DepthFirstSearch<Var> l, boolean master) {\n\tDepthFirstSearch<Var> last_search = l;\n\tDepthFirstSearch<Var> label = null;\n\tif (si.type().equals(\"int_search\") || si.type().equals(\"bool_search\")) {\n\t label = int_search(si);\n\t if (!master) label.setSelectChoicePoint(variable_selection);\n\t if (si.exploration().equals(\"lds\")) {\n\t\tlds_search(label, si.ldsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t if (si.exploration().equals(\"credit\")) {\n\t\tcredit_search(label, si.creditValue, si.bbsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t list_seq_searches.add(label);\n\t}\n\telse if (si.type().equals(\"set_search\")) {\n\t setSearch=true;\n\t label = set_search(si);\n\t if (!master) \n\t\tlabel.setSelectChoicePoint(variable_selection);\n\t if (si.exploration().equals(\"lds\")) {\n\t\tlds_search(label, si.ldsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t if (si.exploration().equals(\"credit\")) {\n\t\tcredit_search(label, si.creditValue, si.bbsValue);\n\t\theuristicSeqSearch = true;\n\t }\n\t list_seq_searches.add(label);\n\t}\n\telse if (si.type().equals(\"seq_search\")) {\n\t for (int i=0; i<si.getSearchItems().size(); i++)\n\t\tif (i == 0) { \n\t\t DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);\n\t\t last_search = label_seq;\n\t\t label = label_seq;\n\t\t}\n\t\telse {\n\t\t DepthFirstSearch<Var> label_seq = sub_search(si.getSearchItems().get(i), last_search, false);\n\t\t last_search.addChildSearch(label_seq);\n\t\t last_search = label_seq;\n\t\t}\n\t}\n\telse {\n\t System.err.println(\"Not recognized or supported search type \\\"\"+si.type()+\"\\\"; compilation aborted\");\n\t System.exit(0);\n\t}\n\treturn label;\n }\n DepthFirstSearch<Var> int_search(SearchItem si) {\n variable_selection = si.getIntSelect();\n return new DepthFirstSearch<Var>();\n }\n DepthFirstSearch<Var> set_search(SearchItem si) {\n variable_selection = si.getSetSelect();\n return new DepthFirstSearch<Var>();\n }\n void printSolution() {\n\tif (dictionary.outputVariables.size() > 0)\n\t for (int i=0; i<dictionary.outputVariables.size(); i++) {\n\t\tVar v = dictionary.outputVariables.get(i);\n \t\tif (v instanceof BooleanVar) {\n\t\t String boolVar = v.id()+\" = \";\n\t\t if (v.singleton())\n\t\t\tswitch ( ((BooleanVar)v).value()) {\n\t\t\tcase 0: boolVar += \"false\";\n\t\t\t break;\n\t\t\tcase 1: boolVar += \"true\";\n\t\t\t break;\n\t\t\tdefault: boolVar += v.dom();\n\t\t\t}\n\t\t else\n\t\t\tboolVar += \"false..true\";\n\t\t System.out.println(boolVar+\";\");\n\t\t}\n\t\telse if (v instanceof SetVar) {\n\t\t String setVar = v.id() + \" = \";\n\t\t if (v.singleton()) {\n\t\t\tIntDomain glb = ((SetVar)v).dom().glb();\n\t\t\tsetVar += \"{\";\n\t\t\tfor (ValueEnumeration e = glb.valueEnumeration(); e.hasMoreElements();) {\n\t\t\t int element = e.nextElement();\n\t\t\t setVar += element;\n\t\t\t if (e.hasMoreElements())\n\t\t\t\tsetVar += \", \";\n\t\t\t}\n\t\t\tsetVar += \"}\";\n\t\t }\n\t\t else\n\t\t\tsetVar += v.dom().toString();\n\t\t System.out.println(setVar+\";\");\n\t\t}\n\t\telse\n\t\t System.out.println(v+\";\");\n\t }\n\tfor (int i=0; i<dictionary.outputArray.size(); i++) {\n\t OutputArrayAnnotation a = dictionary.outputArray.get(i);\n\t System.out.println(a);\n\t}\n }\n int getKind(String k) {\n\tif (k.equals(\"satisfy\")) \n\t return 0;\n\telse if (k.equals(\"minimize\")) \n\t return 1;\n\telse if (k.equals(\"maximize\")) \n\t return 2;\n\telse {\n\t System.err.println(\"Not supported search kind; compilation aborted\");\n\t System.exit(0);\n\t return -1;\n\t}\n }\n IntVar getCost(ASTSolveExpr node) {\n\tif (node.getType() == 0) \n\t return dictionary.getVariable(node.getIdent());\n\telse if (node.getType() == 1) \n\t return dictionary.getVariableArray(node.getIdent())[node.getIndex()];\n\telse {\n\t System.err.println(\"Wrong cost function specification \" + node);\n\t System.exit(0);\n\t return new IntVar(store);\n\t}\n }\n void pose(Constraint c) {\n\tstore.impose(c);\n\tif (debug)\n\t System.out.println(c);\n }\n void lds_search(DepthFirstSearch<Var> label, int lds_value) {\n\tLDS<Var> lds = new LDS<Var>(lds_value); \n\tif (label.getExitChildListener() == null)\n\t label.setExitChildListener(lds);\n\telse\n\t label.getExitChildListener().setChildrenListeners(lds);\n }\n void credit_search(DepthFirstSearch<Var> label, int creditValue, int bbsValue) {\n\tint maxDepth = 1000; \n\tCreditCalculator<Var> credit = new CreditCalculator<Var>(creditValue, bbsValue, maxDepth);\n\tif (label.getConsistencyListener() == null)\n\t label.setConsistencyListener(credit);\n\telse\n\t label.getConsistencyListener().setChildrenListeners(credit);\n\tlabel.setExitChildListener(credit);\n\tlabel.setTimeOutListener(credit);\n }\n void setNumberBoolVariables(int n) {\n\tNumberBoolVariables = n;\n }\n void printSearch(Search label) {\n\tint N = 1;\n\tSystem.out.println (N++ + \". \" + label);\n\tjava.util.LinkedHashSet<Search<? extends Var>> l = \n\t new java.util.LinkedHashSet<Search<? extends Var>>();\n\tl.add(label);\n\twhile (l.size() != 0) {\n\t java.util.LinkedHashSet<Search<? extends Var>> ns = \n\t\tnew java.util.LinkedHashSet<Search<? extends Var>>();\n\t for (Search s1 : l) {\n\t\tSearch<? extends Var>[] child = ((DepthFirstSearch)s1).childSearches;\n\t\tif (child != null)\n\t\t for (Search s : child) {\n\t\t\tSystem.out.println (N + \". \" + s);\n\t\t\tns.add(s);\t\n\t\t }\n\t }\n\t N++;\n\t l = ns;\n\t}\n }\n int FinalNumberSolutions = 0;\n public class CostListener<T extends Var> extends SimpleSolutionListener<T> {\n\tpublic boolean executeAfterSolution(Search<T> search, SelectChoicePoint<T> select) {\n\t boolean returnCode = super.executeAfterSolution(search, select);\n\t if (costVariable != null)\n\t\tcostValue = ((IntVar)costVariable).value();\n\t FinalNumberSolutions++;\n\t printSolution();\n\t System.out.println(\"----------\");\n\t return returnCode;\n\t}\n }\n class DomainSizeComparator<T extends Var> implements Comparator<T> {\n\tDomainSizeComparator() { }\n\tpublic int compare(T o1, T o2) {\n\t int v1 = o1.getSize();\n\t int v2 = o2.getSize();\n\t return v1 - v2;\n\t}\n }\n}\n"} {"input": "\tprivate <V> void requestAsynchronously(final AsyncCallback<V> callback,\n\t\t\tfinal HttpUriRequest request,\n\t\t\tfinal ResponseProcessor<V> responseProcessor) {\n\t\tThread thread = new Thread() {\n\t\t\tpublic void run() {\n\t\t\t\ttry {\n\t\t\t\t\tLog.d(TAG, \"requesting asynchronously \" + request.getURI());\n\t\t\t\t\tHttpResponse response = httpClient.execute(request);\n\t\t\t\t\tint statusCode = response.getStatusLine().getStatusCode();\n\t\t\t\t\tLog.d(TAG, \"got response code \" + statusCode);\n\t\t\t\t\tif (statusCode == 200) {\n\t\t\t\t\t\tV result = null;\n\t\t\t\t\t\tif (responseProcessor != null) {\n\t\t\t\t\t\t\tLog.d(TAG, \"processing response\");\n\t\t\t\t\t\t\tresult = responseProcessor\n\t\t\t\t\t\t\t\t\t.processResponse(response);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tLog.d(TAG, \"onSuccess\");\n\t\t\t\t\t\tcallback.onSuccess(result);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.d(TAG, \"onFailure\");\n\t\t\t\t\t\tcallback.onFailure(null);\n\t\t\t\t\t}\n\t\t\t\t\tif (response.getEntity() != null) {\n\t\t\t\t\t\tresponse.getEntity().consumeContent();\n\t\t\t\t\t}\n\t\t\t\t} catch (ClientProtocolException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t} catch (IllegalStateException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t} catch (JSONException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tthread.start();\n\t}\n", "output": "\tprivate <V> void requestAsynchronously(final AsyncCallback<V> callback,\n\t\t\tfinal HttpUriRequest request,\n\t\t\tfinal ResponseProcessor<V> responseProcessor) {\n\t\tThread thread = new Thread() {\n\t\t\tpublic void run() {\n\t\t\t\ttry {\n\t\t\t\t\tLog.d(TAG, \"requesting asynchronously \" + request.getURI());\n\t\t\t\t\tHttpResponse response = httpClient.execute(request);\n\t\t\t\t\tint statusCode = response.getStatusLine().getStatusCode();\n\t\t\t\t\tLog.d(TAG, \"got response code \" + statusCode);\n\t\t\t\t\tif (statusCode == 200) {\n\t\t\t\t\t\tV result = null;\n\t\t\t\t\t\tif (responseProcessor != null) {\n\t\t\t\t\t\t\tLog.d(TAG, \"processing response\");\n\t\t\t\t\t\t\tresult = responseProcessor\n\t\t\t\t\t\t\t\t\t.processResponse(response);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tLog.d(TAG, \"onSuccess\");\n\t\t\t\t\t\tcallback.onSuccess(result);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.d(TAG, \"onFailure\");\n\t\t\t\t\t\tcallback.onFailure(new Throwable(\"Unexpected status code: \" + statusCode));\n\t\t\t\t\t}\n\t\t\t\t\tif (response.getEntity() != null) {\n\t\t\t\t\t\tresponse.getEntity().consumeContent();\n\t\t\t\t\t}\n\t\t\t\t} catch (ClientProtocolException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t} catch (IllegalStateException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t} catch (JSONException e) {\n\t\t\t\t\tcallback.onFailure(e);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tthread.start();\n\t}\n"} {"input": " public Serializer newSerializer( final Class<?> type ) {\n if ( Component.class.isAssignableFrom( type ) ) {\n return new ReferenceFieldSerializerReflectionFactorySupport( _kryo, type );\n }\n return null;\n }\n", "output": " public Serializer newSerializer( final Class<?> type ) {\n if ( Component.class.isAssignableFrom( type ) ) {\n final ReferenceFieldSerializerReflectionFactorySupport result = new ReferenceFieldSerializerReflectionFactorySupport( _kryo, type );\n result.setIgnoreSyntheticFields( false );\n return result;\n }\n return null;\n }\n"} {"input": " public PlayheadView(Context context, AttributeSet attrs, int defStyle) {\n super(context, attrs, defStyle);\n final Resources resources = context.getResources();\n mLinePaint = new Paint();\n mLinePaint.setColor(resources.getColor(R.color.playhead_tick_color));\n mLinePaint.setStrokeWidth(2);\n mLinePaint.setStyle(Paint.Style.STROKE);\n mTextPaint = new Paint();\n mTextPaint.setAntiAlias(true);\n mTextPaint.setColor(resources.getColor(R.color.playhead_tick_color));\n mTextPaint.setTextSize(18);\n mTicksHeight = (int)resources.getDimension(R.dimen.playhead_tick_height);\n final Display display = ((WindowManager)context.getSystemService(\n Context.WINDOW_SERVICE)).getDefaultDisplay();\n final DisplayMetrics metrics = new DisplayMetrics();\n display.getMetrics(metrics);\n mScreenWidth = metrics.widthPixels;\n mScrollListener = new ScrollViewListener() {\n public void onScrollBegin(View view, int scrollX, int scrollY, boolean appScroll) {\n }\n public void onScrollProgress(View view, int scrollX, int scrollY, boolean appScroll) {\n mScrollX = scrollX;\n }\n public void onScrollEnd(View view, int scrollX, int scrollY, boolean appScroll) {\n mScrollX = scrollX;\n invalidate();\n }\n };\n }\n", "output": " public PlayheadView(Context context, AttributeSet attrs, int defStyle) {\n super(context, attrs, defStyle);\n final Resources resources = context.getResources();\n mLinePaint = new Paint();\n mLinePaint.setColor(resources.getColor(R.color.playhead_tick_color));\n mLinePaint.setStrokeWidth(2);\n mLinePaint.setStyle(Paint.Style.STROKE);\n mTextPaint = new Paint();\n mTextPaint.setAntiAlias(true);\n mTextPaint.setColor(resources.getColor(R.color.playhead_tick_color));\n mTextPaint.setTextSize(18);\n mTicksHeight = (int)resources.getDimension(R.dimen.playhead_tick_height);\n final Display display = ((WindowManager)context.getSystemService(\n Context.WINDOW_SERVICE)).getDefaultDisplay();\n final DisplayMetrics metrics = new DisplayMetrics();\n display.getMetrics(metrics);\n mScreenWidth = metrics.widthPixels;\n mScrollListener = new ScrollViewListener() {\n public void onScrollBegin(View view, int scrollX, int scrollY, boolean appScroll) {\n }\n public void onScrollProgress(View view, int scrollX, int scrollY, boolean appScroll) {\n mScrollX = scrollX;\n invalidate();\n }\n public void onScrollEnd(View view, int scrollX, int scrollY, boolean appScroll) {\n mScrollX = scrollX;\n invalidate();\n }\n };\n }\n"} {"input": "\tpublic void neighbourChanged(Tile tile) {\n\t\tfinal Tile w = level.getTile(x - 1, y);\n\t\tfinal Tile n = level.getTile(x, y - 1);\n\t\tfinal Tile s = level.getTile(x, y + 1);\n\t\tfinal Tile e = level.getTile(x + 1, y);\n\t\tint index = 0;\n\t\tif (w != null && w.castShadow())\n\t\t\tindex |= 0x4;\n\t\tif (n != null && n.castShadow())\n\t\t\tindex |= 0x2;\n\t\tif (e != null && e.castShadow())\n\t\t\tindex |= 0x1;\n\t\tif (n instanceof SandTile) {\n\t\t\timg = 4 + 8;\n\t\t\tindex = 0;\n\t\t}\n\t\tif (s instanceof SandTile) {\n\t\t\timg = 5 + 8;\n\t\t\tindex = 0;\n\t\t}\n\t\tif (index > 0) {\n\t\t\tint imageIndex = shadowImages[index];\n\t\t\tif (imageIndex < 4) \n\t\t\t\timg = Art.floorTiles.length + (imageIndex & 3);\n\t\t\telse\n\t\t\t\timg = 2 * Art.floorTiles.length + (imageIndex & 3);\n\t\t}\n\t\tminimapColor = Art.floorTileColors[img & 7][img / 8];\n\t}\n", "output": "\tpublic void neighbourChanged(Tile tile) {\n\t\tfinal Tile w = level.getTile(x - 1, y);\n\t\tfinal Tile n = level.getTile(x, y - 1);\n\t\tfinal Tile s = level.getTile(x, y + 1);\n\t\tfinal Tile e = level.getTile(x + 1, y);\n\t\tint index = 0;\n\t\tif (w != null && w.castShadow())\n\t\t\tindex |= 0x4;\n\t\tif (n != null && n.castShadow())\n\t\t\tindex |= 0x2;\n\t\tif (e != null && e.castShadow())\n\t\t\tindex |= 0x1;\n\t\tif (n instanceof SandTile) {\n\t\t\timg = 4 + 8;\n\t\t\tindex = 0;\n\t\t}\n\t\tif (s instanceof SandTile) {\n\t\t\timg = 5 + 8;\n\t\t\tindex = 0;\n\t\t}\n\t\tif (index > 0) {\n\t\t\tint imageIndex = shadowImages[index];\n\t\t\tif (imageIndex < 4) \n\t\t\t\timg = Art.floorTiles.length + (imageIndex & 3);\n\t\t\telse\n\t\t\t\timg = 2 * Art.floorTiles.length + (imageIndex & 3);\n\t\t} else {\n\t\t img = 3;\n\t\t}\n\t\tminimapColor = Art.floorTileColors[img & 7][img / 8];\n\t}\n"} {"input": "\tprotected int createContents() {\n\t\tshlFnirsDataProcessing = new Shell(SWT.CLOSE | SWT.MIN | SWT.TITLE);\n\t\tshlFnirsDataProcessing.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.NORMAL));\n\t\tshlFnirsDataProcessing.setImage(SWTResourceManager.getImage(\n\t\t\t\tHello.class, \"/fNIRs/logo.png\"));\n\t\tshlFnirsDataProcessing.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tshlFnirsDataProcessing.setSize(1000, 600);\n\t\tshlFnirsDataProcessing\n\t\t\t\t.setText(\"Zombie MiNIR - fNIRs Data Processing and Analysis\");\n\t\tfileDialog = new FileDialog(shlFnirsDataProcessing, SWT.OPEN\n\t\t\t\t| SWT.CANCEL);\n\t\tDirectoryDialog dlg = new DirectoryDialog(shlFnirsDataProcessing);\n\t\tdlg.setText(\"Select a workspace\");\n\t\tString selected = dlg.open();\n\t\tif (selected == null)\n\t\t\treturn 1;\n\t\tworkspace = new Workspace(selected, pre);\n\t\tfinal List list = new List(shlFnirsDataProcessing, SWT.BORDER\n\t\t\t\t| SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.CENTER);\n\t\tlist.setForeground(SWTResourceManager.getColor(SWT.COLOR_GREEN));\n\t\tlist.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlist.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlist.setBounds(10, 38, 226, 392);\n\t\tGridData data = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\tlist.setLayoutData(data);\n\t\tworkspace.loadSubjects(list);\n\t\tMenu menu = new Menu(shlFnirsDataProcessing, SWT.BAR);\n\t\tshlFnirsDataProcessing.setMenuBar(menu);\n\t\tMenuItem mntmHelp_1 = new MenuItem(menu, SWT.CASCADE);\n\t\tmntmHelp_1.setText(\"Help\");\n\t\tMenu menu_1 = new Menu(mntmHelp_1);\n\t\tmntmHelp_1.setMenu(menu_1);\n\t\tMenuItem mntmHelp = new MenuItem(menu_1, SWT.NONE);\n\t\tmntmHelp.setText(\"Tutorial\");\n\t\tCTabFolder tabFolder = new CTabFolder(shlFnirsDataProcessing,\n\t\t\t\tSWT.BORDER | SWT.FLAT);\n\t\ttabFolder.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttabFolder.setSelectionBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder.setSelectionForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_GREEN));\n\t\ttabFolder.setSimple(false);\n\t\ttabFolder.setFont(SWTResourceManager.getFont(\"Segoe UI\", 14, SWT.BOLD));\n\t\ttabFolder.setBounds(242, 10, 742, 522);\n\t\tCTabItem tbtmLoadFiles = new CTabItem(tabFolder, SWT.BORDER | SWT.FLAT);\n\t\ttbtmLoadFiles.setFont(SWTResourceManager.getFont(\"Segoe UI\", 14,\n\t\t\t\tSWT.BOLD));\n\t\ttbtmLoadFiles.setText(\" Load Subjects\");\n\t\tComposite composite = new Composite(tabFolder, SWT.NONE);\n\t\tcomposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.BOLD\n\t\t\t\t| SWT.ITALIC));\n\t\ttbtmLoadFiles.setControl(composite);\n\t\tCTabFolder tabFolder_1 = new CTabFolder(composite, SWT.BORDER\n\t\t\t\t| SWT.FLAT);\n\t\ttabFolder_1.setBackgroundMode(SWT.INHERIT_DEFAULT);\n\t\ttabFolder_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttabFolder_1.setSelectionBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder_1.setSelectionForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_GREEN));\n\t\ttabFolder_1.setSimple(false);\n\t\ttabFolder_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 9,\n\t\t\t\tSWT.NORMAL));\n\t\ttabFolder_1.setBounds(10, 10, 718, 474);\n\t\tCTabItem tbtmNewItem = new CTabItem(tabFolder_1, SWT.BORDER | SWT.FLAT);\n\t\ttbtmNewItem.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 13, SWT.BOLD));\n\t\ttbtmNewItem.setText(\" ISS Oxyplex \");\n\t\tComposite composite_3 = new Composite(tabFolder_1, SWT.NONE);\n\t\tcomposite_3.setSize(new Point(30, 30));\n\t\tcomposite_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttbtmNewItem.setControl(composite_3);\n\t\tfinal ArrayList<Control> loadItems = new ArrayList<Control>();\n\t\tfinal Spinner spinner = new Spinner(composite_3, SWT.BORDER);\n\t\tspinner.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tspinner.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tspinner.setSelection(20);\n\t\tspinner.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tspinner.setBounds(579, 242, 47, 25);\n\t\tloadItems.add(spinner);\n\t\tfinal Label lblOf = new Label(composite_3, SWT.NONE);\n\t\tlblOf.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblOf.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblOf.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.ITALIC));\n\t\tlblOf.setBounds(30, 380, 213, 25);\n\t\tlblOf.setText(\"Session: 1 of 1\");\n\t\tloadItems.add(lblOf);\n\t\tfinal Button btnCheckButton = new Button(composite_3, SWT.CHECK);\n\t\tbtnCheckButton.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnCheckButton.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tbtnCheckButton.setSelection(true);\n\t\tbtnCheckButton.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnCheckButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (btnCheckButton.getSelection())\n\t\t\t\t\tspinner.setEnabled(true);\n\t\t\t\telse\n\t\t\t\t\tspinner.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tbtnCheckButton.setBounds(425, 241, 21, 28);\n\t\tloadItems.add(btnCheckButton);\n\t\tfinal Spinner num_sessions = new Spinner(composite_3, SWT.BORDER);\n\t\tnum_sessions\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tnum_sessions\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tnum_sessions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnum_sessions.setMinimum(1);\n\t\tnum_sessions.setBounds(524, 32, 47, 25);\n\t\tfinal Button btnEnter_1 = new Button(composite_3, SWT.NONE);\n\t\tbtnEnter_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnEnter_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnEnter_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnEnter_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsubjectName = text_subName.getText();\n\t\t\t\tif (subjectName == \"\" || subjectName.matches(subjectNameH)\n\t\t\t\t\t\t|| Arrays.asList(list.getItems()).contains(subjectName)) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Please enter a new name.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (Control item : loadItems) {\n\t\t\t\t\titem.setVisible(true);\n\t\t\t\t}\n\t\t\t\tsessionNum = 1;\n\t\t\t\tlblOf.setText(\"Session: 1 of \" + num_sessions.getText());\n\t\t\t\ttext_subName.setEnabled(false);\n\t\t\t\tnum_sessions.setEnabled(false);\n\t\t\t\tbtnEnter_1.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tbtnEnter_1.setBounds(580, 30, 106, 28);\n\t\tbtnEnter_1.setText(\"Enter\");\n\t\tButton btnEnter = new Button(composite_3, SWT.NONE);\n\t\tbtnEnter.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnEnter.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnEnter.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnEnter.setBounds(480, 381, 100, 28);\n\t\tbtnEnter.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdouble freq = 0;\n\t\t\t\tdouble hpf = 0;\n\t\t\t\tdouble lpf = 0;\n\t\t\t\tFile newFile = new File(text.getText());\n\t\t\t\tif (!setExists(newFile))\n\t\t\t\t\treturn;\n\t\t\t\tFile condFile = new File(text_6.getText());\n\t\t\t\tif (!setExists(condFile))\n\t\t\t\t\treturn;\n\t\t\t\ttry {\n\t\t\t\t\tfreq = (Double.valueOf(text_1.getText())).doubleValue();\n\t\t\t\t\thpf = (Double.valueOf(text_2.getText())).doubleValue();\n\t\t\t\t\tlpf = (Double.valueOf(text_3.getText())).doubleValue();\n\t\t\t\t} catch (NumberFormatException e1) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Please fill in all frequencies.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tsplash.setProgress(0, \"Zombies have arrived...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchar slideavg = 'n';\n\t\t\t\tint interval = 0;\n\t\t\t\tif (btnCheckButton.getSelection()) {\n\t\t\t\t\tslideavg = 'y';\n\t\t\t\t\tinterval = (Integer.valueOf(spinner.getText())).intValue();\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(23, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (sessionNum == 1) {\n\t\t\t\t\t\tworkspace.addSubject(subjectName, newFile, condFile,\n\t\t\t\t\t\t\t\tfreq, hpf, lpf, slideavg, interval);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tworkspace.concatSession(subjectName, newFile, condFile,\n\t\t\t\t\t\t\t\tfreq, hpf, lpf, slideavg, interval);\n\t\t\t\t\t}\n\t\t\t\t} catch (InputMismatchException ime) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\time.printStackTrace();\n\t\t\t\t\tworkspace.removeSubject(subjectName);\n\t\t\t\t\tinfoBox(\"Error\", \"Conditions file must be a text file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsessionNum++;\n\t\t\t\tsplash.setProgress(45, \"Deep frying grey matter...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (sessionNum > Integer.valueOf(num_sessions.getText())\n\t\t\t\t\t\t.intValue()) {\n\t\t\t\t\tlist.add(subjectName);\n\t\t\t\t\tfor (Control item : loadItems) {\n\t\t\t\t\t\titem.setVisible(false);\n\t\t\t\t\t}\n\t\t\t\t\ttext_subName.setEnabled(true);\n\t\t\t\t\tnum_sessions.setEnabled(true);\n\t\t\t\t\tbtnEnter_1.setEnabled(true);\n\t\t\t\t\ttext_subName.setText(\"\");\n\t\t\t\t\tnum_sessions.setSelection(1);\n\t\t\t\t} else {\n\t\t\t\t\tlblOf.setText(\"Session: \" + sessionNum + \" of \"\n\t\t\t\t\t\t\t+ num_sessions.getText());\n\t\t\t\t}\n\t\t\t\ttext.setText(\"\");\n\t\t\t\ttext_6.setText(\"\");\n\t\t\t\tsplash.setProgress(100, \"Brains have been preprocessed!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tbtnEnter.setText(\"Add\");\n\t\tloadItems.add(btnEnter);\n\t\ttext_subName = new Text(composite_3, SWT.BORDER);\n\t\ttext_subName\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_subName\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_subName.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_subName.setBounds(147, 32, 213, 25);\n\t\tButton btnBrowse = new Button(composite_3, SWT.NONE);\n\t\tbtnBrowse.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnBrowse.setBounds(580, 128, 108, 28);\n\t\tbtnBrowse.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse.setText(\"Browse...\");\n\t\tloadItems.add(btnBrowse);\n\t\tLabel lblSubjectName = new Label(composite_3, SWT.NONE);\n\t\tlblSubjectName.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectName.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectName.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSubjectName.setBounds(30, 32, 104, 25);\n\t\tlblSubjectName.setText(\"Subject Name:\");\n\t\ttext = new Text(composite_3, SWT.BORDER);\n\t\ttext.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext.setBounds(150, 130, 424, 25);\n\t\tloadItems.add(text);\n\t\tLabel lblDataFile = new Label(composite_3, SWT.NONE);\n\t\tlblDataFile.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblDataFile.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblDataFile.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblDataFile.setBounds(30, 130, 67, 25);\n\t\tlblDataFile.setText(\"Data File:\");\n\t\tloadItems.add(lblDataFile);\n\t\ttext_1 = new Text(composite_3, SWT.BORDER);\n\t\ttext_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_1.setText(\"2\");\n\t\ttext_1.setBounds(285, 242, 50, 25);\n\t\tloadItems.add(text_1);\n\t\tLabel lblNewLabel = new Label(composite_3, SWT.NONE);\n\t\tlblNewLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNewLabel.setBounds(85, 242, 164, 25);\n\t\tlblNewLabel.setText(\"Sampling Frequency:\");\n\t\tloadItems.add(lblNewLabel);\n\t\tLabel lblHz = new Label(composite_3, SWT.NONE);\n\t\tlblHz.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHz.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHz.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHz.setBounds(340, 244, 29, 25);\n\t\tlblHz.setText(\"Hz\");\n\t\tloadItems.add(lblHz);\n\t\tLabel lblHighPassFilter = new Label(composite_3, SWT.NONE);\n\t\tlblHighPassFilter.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblHighPassFilter.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblHighPassFilter.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblHighPassFilter.setBounds(85, 282, 196, 25);\n\t\tlblHighPassFilter.setText(\"High Pass Filter Frequency:\");\n\t\tloadItems.add(lblHighPassFilter);\n\t\ttext_2 = new Text(composite_3, SWT.BORDER);\n\t\ttext_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_2.setText(\".1\");\n\t\ttext_2.setBounds(285, 282, 50, 25);\n\t\tloadItems.add(text_2);\n\t\tLabel label = new Label(composite_3, SWT.NONE);\n\t\tlabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel.setText(\"Hz\");\n\t\tlabel.setBounds(340, 284, 29, 25);\n\t\tloadItems.add(label);\n\t\tLabel lblLowPassFilter = new Label(composite_3, SWT.NONE);\n\t\tlblLowPassFilter.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblLowPassFilter.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblLowPassFilter.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblLowPassFilter.setBounds(85, 322, 196, 25);\n\t\tlblLowPassFilter.setText(\"Low Pass Filter Frequency:\");\n\t\tloadItems.add(lblLowPassFilter);\n\t\ttext_3 = new Text(composite_3, SWT.BORDER);\n\t\ttext_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_3.setText(\".01\");\n\t\ttext_3.setBounds(285, 322, 50, 25);\n\t\tloadItems.add(text_3);\n\t\tLabel label_1 = new Label(composite_3, SWT.NONE);\n\t\tlabel_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_1.setText(\"Hz\");\n\t\tlabel_1.setBounds(340, 324, 29, 25);\n\t\tloadItems.add(label_1);\n\t\tLabel lblPreprocessingOptions = new Label(composite_3, SWT.NONE);\n\t\tlblPreprocessingOptions.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblPreprocessingOptions.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblPreprocessingOptions.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.BOLD));\n\t\tlblPreprocessingOptions.setBounds(30, 90, 189, 25);\n\t\tlblPreprocessingOptions.setText(\"Preprocessing Options:\");\n\t\tloadItems.add(lblPreprocessingOptions);\n\t\tLabel lblConditionsFile = new Label(composite_3, SWT.NONE);\n\t\tlblConditionsFile.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblConditionsFile.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblConditionsFile.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblConditionsFile.setBounds(30, 180, 116, 25);\n\t\tlblConditionsFile.setText(\"Conditions File:\");\n\t\tloadItems.add(lblConditionsFile);\n\t\ttext_6 = new Text(composite_3, SWT.BORDER);\n\t\ttext_6.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_6.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_6.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_6.setBounds(150, 180, 424, 25);\n\t\tloadItems.add(text_6);\n\t\tButton btnBrowse_3 = new Button(composite_3, SWT.NONE);\n\t\tbtnBrowse_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnBrowse_3.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_6);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse_3.setText(\"Browse...\");\n\t\tbtnBrowse_3.setBounds(580, 178, 108, 29);\n\t\tloadItems.add(btnBrowse_3);\n\t\tLabel lblNumberOfSessions = new Label(composite_3, SWT.NONE);\n\t\tlblNumberOfSessions.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNumberOfSessions.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNumberOfSessions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNumberOfSessions.setBounds(451, 32, 67, 25);\n\t\tlblNumberOfSessions.setText(\"Sessions:\");\n\t\tfinal Button button_3 = new Button(composite_3, SWT.NONE);\n\t\tbutton_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbutton_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbutton_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbutton_3.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tworkspace.removeSubject(subjectName);\n\t\t\t\tfor (Control item : loadItems) {\n\t\t\t\t\titem.setVisible(false);\n\t\t\t\t}\n\t\t\t\ttext_subName.setEnabled(true);\n\t\t\t\tnum_sessions.setEnabled(true);\n\t\t\t\tbtnEnter_1.setEnabled(true);\n\t\t\t\ttext_subName.setText(\"\");\n\t\t\t\tnum_sessions.setSelection(1);\n\t\t\t\tsubjectName = \"\";\n\t\t\t}\n\t\t});\n\t\tbutton_3.setText(\"Cancel\");\n\t\tbutton_3.setBounds(586, 381, 100, 28);\n\t\tloadItems.add(button_3);\n\t\tLabel lblSlidingAverage = new Label(composite_3, SWT.NONE);\n\t\tlblSlidingAverage.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSlidingAverage.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSlidingAverage.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSlidingAverage.setBounds(450, 242, 121, 25);\n\t\tlblSlidingAverage.setText(\"Sliding Average:\");\n\t\tloadItems.add(lblSlidingAverage);\n\t\tfor (Control item : loadItems) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\tfinal Composite composite_4 = new Composite(tabFolder_1, SWT.NONE);\n\t\tcomposite_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tcomposite_4.setBounds(10, 96, 694, 254);\n\t\tcomposite_4.setVisible(false);\n\t\tfinal ArrayList<Control> loadHatachi = new ArrayList<Control>();\n\t\ttext_4 = new Text(composite_4, SWT.BORDER);\n\t\ttext_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_4.setBounds(146, 200, 396, 25);\n\t\tloadHatachi.add(text_4);\n\t\ttext_5 = new Text(composite_4, SWT.BORDER);\n\t\ttext_5.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_5.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_5.setBounds(146, 250, 396, 25);\n\t\tloadHatachi.add(text_5);\n\t\tfinal Button btnNewButton = new Button(composite_4, SWT.NONE);\n\t\tbtnNewButton\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnNewButton\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnNewButton.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnNewButton.setBounds(548, 198, 143, 28);\n\t\tbtnNewButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_4);\n\t\t\t}\n\t\t});\n\t\tbtnNewButton.setText(\"Browse...\");\n\t\tloadHatachi.add(btnNewButton);\n\t\tfinal Button btnBrowse_1 = new Button(composite_4, SWT.NONE);\n\t\tbtnBrowse_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnBrowse_1.setBounds(548, 248, 143, 28);\n\t\tbtnBrowse_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_5);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse_1.setText(\"Browse...\");\n\t\tloadHatachi.add(btnBrowse_1);\n\t\tfinal Label lblHboFile = new Label(composite_4, SWT.NONE);\n\t\tlblHboFile.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHboFile.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHboFile.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblHboFile.setBounds(30, 250, 84, 25);\n\t\tlblHboFile.setText(\"HbO File:\");\n\t\tloadHatachi.add(lblHboFile);\n\t\tfinal Label lblHbFile = new Label(composite_4, SWT.NONE);\n\t\tlblHbFile.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHbFile.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHbFile.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHbFile.setBounds(30, 200, 84, 25);\n\t\tlblHbFile.setText(\"Hb File:\");\n\t\tloadHatachi.add(lblHbFile);\n\t\tButton btnAdd = new Button(composite_4, SWT.NONE);\n\t\tbtnAdd.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnAdd.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnAdd.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnAdd.setBounds(485, 380, 100, 25);\n\t\tbtnAdd.setText(\"Add\");\n\t\tloadHatachi.add(btnAdd);\n\t\tCTabItem tbtmStats = new CTabItem(tabFolder, SWT.BORDER | SWT.FLAT);\n\t\ttbtmStats.setFont(SWTResourceManager.getFont(\"Segoe UI\", 13, SWT.BOLD));\n\t\ttbtmStats.setText(\" Statistical Analysis \");\n\t\tComposite composite_1 = new Composite(tabFolder, SWT.NONE);\n\t\tcomposite_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttbtmStats.setControl(composite_1);\n\t\tLabel lblChannelGrouping = new Label(composite_1, SWT.NONE);\n\t\tlblChannelGrouping.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblChannelGrouping.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblChannelGrouping.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblChannelGrouping.setBounds(30, 69, 137, 25);\n\t\tlblChannelGrouping.setText(\"Channel Grouping:\");\n\t\tgroupFileBox = new Text(composite_1, SWT.BORDER);\n\t\tgroupFileBox\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tgroupFileBox\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tgroupFileBox.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tgroupFileBox.setBounds(172, 69, 432, 25);\n\t\tButton btnNewButton_2 = new Button(composite_1, SWT.NONE);\n\t\tbtnNewButton_2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnNewButton_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnNewButton_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(groupFileBox);\n\t\t\t}\n\t\t});\n\t\tbtnNewButton_2.setBounds(610, 67, 100, 28);\n\t\tbtnNewButton_2.setText(\"Browse...\");\n\t\tfinal Button HbCheck = new Button(composite_1, SWT.CHECK);\n\t\tHbCheck.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tHbCheck.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tHbCheck.setBounds(173, 100, 18, 25);\n\t\tHbCheck.setText(\"Hb\");\n\t\tfinal Button HbOCheck = new Button(composite_1, SWT.CHECK);\n\t\tHbOCheck.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tHbOCheck.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tHbOCheck.setBounds(236, 100, 18, 25);\n\t\tHbOCheck.setText(\"HbO\");\n\t\tfinal List groupsList = new List(composite_1, SWT.BORDER | SWT.MULTI\n\t\t\t\t| SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tgroupsList.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tgroupsList.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tgroupsList.setBounds(30, 229, 180, 237);\n\t\tgroupsList.setVisible(false);\n\t\tfinal List conditionsList = new List(composite_1, SWT.BORDER\n\t\t\t\t| SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tconditionsList.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tconditionsList.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tconditionsList.setBounds(224, 229, 116, 237);\n\t\tconditionsList.setVisible(false);\n\t\tfinal Label grouplbl = new Label(composite_1, SWT.NONE);\n\t\tgrouplbl.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tgrouplbl.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tgrouplbl.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tgrouplbl.setBounds(30, 198, 66, 25);\n\t\tgrouplbl.setText(\"Groups:\");\n\t\tgrouplbl.setVisible(false);\n\t\tfinal Label condlbl = new Label(composite_1, SWT.NONE);\n\t\tcondlbl.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tcondlbl.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcondlbl.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tcondlbl.setBounds(224, 198, 116, 25);\n\t\tcondlbl.setText(\"Conditions:\");\n\t\tcondlbl.setVisible(false);\n\t\tfinal Label chunking = new Label(composite_1, SWT.NONE);\n\t\tchunking.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tchunking.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tchunking.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tchunking.setBounds(390, 198, 86, 25);\n\t\tchunking.setText(\"Chunking:\");\n\t\tchunking.setVisible(false);\n\t\tfinal Label lblOutputDir = new Label(composite_1, SWT.NONE);\n\t\tlblOutputDir\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblOutputDir\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblOutputDir.setText(\"Output Directory Name:\"); \n\t\tlblOutputDir.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblOutputDir.setBounds(390, 357, 180, 25);\n\t\tlblOutputDir.setVisible(false);\n\t\tnumChunksBox = new Text(composite_1, SWT.BORDER);\n\t\tnumChunksBox\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tnumChunksBox\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tnumChunksBox.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnumChunksBox.setBounds(390, 230, 55, 25);\n\t\tnumChunksBox.setVisible(false);\n\t\tfinal Label chunks = new Label(composite_1, SWT.NONE);\n\t\tchunks.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tchunks.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tchunks.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tchunks.setBounds(451, 229, 86, 25);\n\t\tchunks.setText(\"chunks\");\n\t\tchunks.setVisible(false);\n\t\tfinal Label aprecision = new Label(composite_1, SWT.NONE);\n\t\taprecision.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\taprecision.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\taprecision.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\taprecision.setBounds(390, 277, 148, 25);\n\t\taprecision.setText(\"ANOVA Precision:\");\n\t\taprecision.setVisible(false);\n\t\tdecimalPlacesBox = new Text(composite_1, SWT.BORDER);\n\t\tdecimalPlacesBox.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tdecimalPlacesBox.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tdecimalPlacesBox.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tdecimalPlacesBox.setBounds(390, 308, 55, 25);\n\t\tdecimalPlacesBox.setVisible(false);\n\t\tfinal Label dplace = new Label(composite_1, SWT.NONE);\n\t\tdplace.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tdplace.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tdplace.setText(\"decimal places\");\n\t\tdplace.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tdplace.setBounds(454, 308, 116, 25);\n\t\tdplace.setVisible(false);\n\t\tfinal Button anovabtn = new Button(composite_1, SWT.NONE);\n\t\tanovabtn.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tanovabtn.setVisible(false);\n\t\tanovabtn.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString[] groupsAry = groupsList.getSelection();\n\t\t\t\tArrayList<String> groupsAryLst = new ArrayList<String>(Arrays\n\t\t\t\t\t\t.asList(groupsAry));\n\t\t\t\tif (groupsAryLst.isEmpty()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please select at least one channel grouping to analyze.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tString[] conditionsAry = conditionsList.getSelection();\n\t\t\t\tArrayList<Integer> conditionsAryLst = new ArrayList<Integer>();\n\t\t\t\tfor (String condition : conditionsAry) {\n\t\t\t\t\tconditionsAryLst.add(Integer.valueOf(condition));\n\t\t\t\t}\n\t\t\t\tif (conditionsAryLst.isEmpty()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please select at least one condition to analyze.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tString numChunksStr = numChunksBox.getText();\n\t\t\t\tif (numChunksStr.equals(\"\")) {\n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please enter a number of \\\"chunks\\\" to split the \"\n\t\t\t\t\t\t\t\t\t+ \"data into and average before calculating ANOVA p-values.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tint numChunks = Integer.parseInt(numChunksStr);\n\t\t\t\tString numPlacesStr = decimalPlacesBox.getText();\n\t\t\t\tif (numPlacesStr.equals(\"\")) {\n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please enter a number of decimal places to output \"\n\t\t\t\t\t\t\t\t\t+ \"for the p-values.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tint numPlaces = Integer.parseInt(numPlacesStr);\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tsplash.setProgress(0, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString outputDirectoryName = outputDirectoryBox.getText();\n\t\t\t\tString outputDirectoryPath = workspace.getStatsPath() + \"\\\\\"\n\t\t\t\t\t\t+ outputDirectoryName;\n\t\t\t\tFile statsOutputDirectory = new File(outputDirectoryPath);\n\t\t\t\tstatsOutputDirectory.mkdir(); \n\t\t\t\tsplash.setProgress(10, \"Running Hb ANOVA...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (doHb) {\n\t\t\t\t\tFile outputFileHb = new File(outputDirectoryPath + \"\\\\\"\n\t\t\t\t\t\t\t+ \"p-values_Hb.csv\");\n\t\t\t\t\tFNIRsStats.writeANOVAs(outputFileHb, StatsHb, groupsAryLst,\n\t\t\t\t\t\t\tconditionsAryLst, numChunks, numPlaces);\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(55, \"Running HbO ANOVA...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (doHbO) {\n\t\t\t\t\tFile outputFileHbO = new File(outputDirectoryPath + \"\\\\\"\n\t\t\t\t\t\t\t+ \"p-values_HbO.csv\");\n\t\t\t\t\tFNIRsStats.writeANOVAs(outputFileHbO, StatsHbO,\n\t\t\t\t\t\t\tgroupsAryLst, conditionsAryLst, numChunks,\n\t\t\t\t\t\t\tnumPlaces);\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(100, \"Zombie ANOVA done!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff(); \n\t\t\t\tSystem.out.println(\"Done writing ANOVAs!\");\n\t\t\t}\n\t\t});\n\t\tanovabtn.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tanovabtn.setBounds(390, 436, 155, 28);\n\t\tanovabtn.setText(\"Compute P-values\");\n\t\tfinal Button clearBtn = new Button(composite_1, SWT.NONE);\n\t\tclearBtn.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tclearBtn.setVisible(false);\n\t\tclearBtn.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tHbCheck.setSelection(false);\n\t\t\t\tHbOCheck.setSelection(false);\n\t\t\t\tgroupFileBox.setText(\"\");\n\t\t\t\tgrouplbl.setVisible(false);\n\t\t\t\tcondlbl.setVisible(false);\n\t\t\t\tgroupsList.setVisible(false);\n\t\t\t\tgroupsList.removeAll();\n\t\t\t\tconditionsList.setVisible(false);\n\t\t\t\tconditionsList.removeAll();\n\t\t\t\tchunking.setVisible(false);\n\t\t\t\taprecision.setVisible(false);\n\t\t\t\tdplace.setVisible(false);\n\t\t\t\tchunks.setVisible(false);\n\t\t\t\tnumChunksBox.setVisible(false);\n\t\t\t\tnumChunksBox.setText(\"\");\n\t\t\t\tdecimalPlacesBox.setVisible(false);\n\t\t\t\tdecimalPlacesBox.setText(\"\");\n\t\t\t\toutputDirectoryBox.setVisible(false);\n\t\t\t\toutputDirectoryBox.setText(\"\");\n\t\t\t\tanovabtn.setVisible(false);\n\t\t\t\tlblOutputDir.setVisible(false);\n\t\t\t\tclearBtn.setVisible(false);\n\t\t\t}\n\t\t});\n\t\tclearBtn.setBounds(551, 436, 155, 28);\n\t\tclearBtn.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tclearBtn.setText(\"Clear\");\n\t\toutputDirectoryBox = new Text(composite_1, SWT.BORDER);\n\t\toutputDirectoryBox.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\toutputDirectoryBox.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\toutputDirectoryBox.setBounds(390, 388, 316, 25);\n\t\toutputDirectoryBox.setVisible(false);\n\t\tButton btnLoadGroupsAnd = new Button(composite_1, SWT.NONE);\n\t\tbtnLoadGroupsAnd.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnLoadGroupsAnd.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tArrayList<String> subjects = new ArrayList<String>();\n\t\t\t\tfor (String s : list.getSelection()) {\n\t\t\t\t\tsubjects.add(s);\n\t\t\t\t}\n\t\t\t\tif (subjects.isEmpty()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please select at least one subject to analyze.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString groupFilePath = groupFileBox.getText();\n\t\t\t\tFile groupingsFile = new File(groupFilePath);\n\t\t\t\tif (!groupingsFile.exists()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please specify a valid channel groupings file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdoHb = HbCheck.getSelection();\n\t\t\t\tdoHbO = HbOCheck.getSelection(); \n\t\t\t\tif (!doHb && !doHbO) { \n\t\t\t\t\tinfoBox(\"Error\", \"Please select Hb, HbO, or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (doHb) { \n\t\t\t\t\tArrayList<File> hbFiles = new ArrayList<File>();\n\t\t\t\t\tfor (String subject : subjects) {\n\t\t\t\t\t\tFile dataFile = workspace.getHb(subject);\n\t\t\t\t\t\tif (dataFile != null && dataFile.exists()) {\n\t\t\t\t\t\t\thbFiles.add(dataFile);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tinfoBox(\"Error\", \"Hb file for \" + subject\n\t\t\t\t\t\t\t\t\t+ \" does not exist.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tStatsHb = FNIRsStats.processAllSubjectData(hbFiles,\n\t\t\t\t\t\t\tgroupingsFile);\n\t\t\t\t}\n\t\t\t\tif (doHbO) { \n\t\t\t\t\tArrayList<File> hbOFiles = new ArrayList<File>();\n\t\t\t\t\tfor (String subject : subjects) {\n\t\t\t\t\t\tFile dataFile = workspace.getHbO(subject);\n\t\t\t\t\t\tif (dataFile != null && dataFile.exists()) {\n\t\t\t\t\t\t\thbOFiles.add(dataFile);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tinfoBox(\"Error\", \"HbO file for \" + subject\n\t\t\t\t\t\t\t\t\t+ \" does not exist.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tStatsHbO = FNIRsStats.processAllSubjectData(hbOFiles,\n\t\t\t\t\t\t\tgroupingsFile);\n\t\t\t\t}\n\t\t\t\tFNIRsStats.GroupedChannels temp = null;\n\t\t\t\tif (doHb) {\n\t\t\t\t\ttemp = StatsHb;\n\t\t\t\t} else {\n\t\t\t\t\ttemp = StatsHbO;\n\t\t\t\t}\n\t\t\t\tif (temp.channelsMissing()) {\n\t\t\t\t\tinfoBox(\"Warning\", temp.getMissingChannelsMsg());\n\t\t\t\t}\n\t\t\t\tif (temp.channelsDuplicated()) {\n\t\t\t\t\tinfoBox(\"Warning!\", temp.getDuplicatedChannelsMsg());\n\t\t\t\t}\n\t\t\t\tgroupsList.removeAll();\n\t\t\t\tconditionsList.removeAll();\n\t\t\t\tFNIRsStats.GroupedChannels statsData = null;\n\t\t\t\tif (doHb) { \n\t\t\t\t\tstatsData = StatsHb; \n\t\t\t\t} else { \n\t\t\t\t\tstatsData = StatsHbO; \n\t\t\t\t}\n\t\t\t\tfor (String groupName : statsData.getGroupNames()) {\n\t\t\t\t\tgroupsList.add(groupName);\n\t\t\t\t}\n\t\t\t\tfor (Integer condition : statsData.getConditions()) {\n\t\t\t\t\tconditionsList.add(condition.toString());\n\t\t\t\t}\n\t\t\t\tgrouplbl.setVisible(true);\n\t\t\t\tcondlbl.setVisible(true);\n\t\t\t\tgroupsList.setVisible(true);\n\t\t\t\tconditionsList.setVisible(true);\n\t\t\t\tchunking.setVisible(true);\n\t\t\t\taprecision.setVisible(true);\n\t\t\t\tdplace.setVisible(true);\n\t\t\t\tchunks.setVisible(true);\n\t\t\t\tnumChunksBox.setVisible(true);\n\t\t\t\tdecimalPlacesBox.setVisible(true);\n\t\t\t\toutputDirectoryBox.setVisible(true);\n\t\t\t\tanovabtn.setVisible(true);\n\t\t\t\tlblOutputDir.setVisible(true);\n\t\t\t\tclearBtn.setVisible(true);\n\t\t\t}\n\t\t});\n\t\tbtnLoadGroupsAnd.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnLoadGroupsAnd.setBounds(246, 139, 276, 28);\n\t\tbtnLoadGroupsAnd.setText(\"Load Groups and Conditions\");\n\t\tLabel lblPleaseSelect = new Label(composite_1, SWT.NONE);\n\t\tlblPleaseSelect.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblPleaseSelect.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblPleaseSelect.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.BOLD | SWT.ITALIC));\n\t\tlblPleaseSelect.setBounds(30, 25, 394, 25);\n\t\tlblPleaseSelect\n\t\t\t\t.setText(\"Please select subject(s) from the Subject List to begin\");\n\t\tLabel lblHb_1 = new Label(composite_1, SWT.NONE);\n\t\tlblHb_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHb_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHb_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHb_1.setBounds(193, 101, 40, 25);\n\t\tlblHb_1.setText(\"Hb\");\n\t\tLabel label_4 = new Label(composite_1, SWT.NONE);\n\t\tlabel_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_4.setText(\"HbO\");\n\t\tlabel_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_4.setBounds(256, 101, 55, 28);\n\t\tCTabItem tbtmMachineLearning = new CTabItem(tabFolder, SWT.BORDER\n\t\t\t\t| SWT.FLAT);\n\t\ttbtmMachineLearning.setFont(SWTResourceManager.getFont(\"Segoe UI\", 14,\n\t\t\t\tSWT.BOLD));\n\t\ttbtmMachineLearning.setText(\" Data Mining \");\n\t\tComposite composite_2 = new Composite(tabFolder, SWT.NONE);\n\t\tcomposite_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttbtmMachineLearning.setControl(composite_2);\n\t\tfinal Spinner spinner_avgseg = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_avgseg.setMinimum(1);\n\t\tspinner_avgseg.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_avgseg.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tspinner_avgseg.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_avgseg.setBounds(656, 148, 55, 25);\n\t\tfinal Spinner spinner_seqlen1 = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_seqlen1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_seqlen1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_seqlen1.setMinimum(1);\n\t\tspinner_seqlen1.setEnabled(false);\n\t\tspinner_seqlen1.setBounds(656, 213, 55, 25);\n\t\tfinal Spinner spinner_fbs = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_fbs.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_fbs.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tspinner_fbs.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tspinner_fbs.setMinimum(1);\n\t\tspinner_fbs.setEnabled(false);\n\t\tspinner_fbs.setBounds(656, 308, 55, 25);\n\t\tfinal Spinner spinner_alphsize = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_alphsize.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_alphsize.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tspinner_alphsize.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_alphsize.setMinimum(1);\n\t\tspinner_alphsize.setEnabled(false);\n\t\tspinner_alphsize.setBounds(656, 243, 55, 25);\n\t\tfinal Button radioAS = new Button(composite_2, SWT.RADIO);\n\t\tradioAS.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tradioAS.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tradioAS.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tspinner_avgseg.setEnabled(true);\n\t\t\t\tspinner_seqlen1.setEnabled(false);\n\t\t\t\tspinner_alphsize.setEnabled(false);\n\t\t\t\tspinner_fbs.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tradioAS.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tradioAS.setSelection(true);\n\t\tradioAS.setBounds(435, 118, 18, 25);\n\t\tradioAS.setText(\"Averaged Segments\");\n\t\tfinal Button radioSAX = new Button(composite_2, SWT.RADIO);\n\t\tradioSAX.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tradioSAX.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tradioSAX.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tspinner_avgseg.setEnabled(false);\n\t\t\t\tspinner_seqlen1.setEnabled(true);\n\t\t\t\tspinner_alphsize.setEnabled(true);\n\t\t\t\tspinner_fbs.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tradioSAX.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tradioSAX.setBounds(435, 183, 18, 25);\n\t\tradioSAX.setText(\"SAX Segments\");\n\t\tButton radioFBS = new Button(composite_2, SWT.RADIO);\n\t\tradioFBS.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tradioFBS.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tradioFBS.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tspinner_avgseg.setEnabled(false);\n\t\t\t\tspinner_seqlen1.setEnabled(false);\n\t\t\t\tspinner_alphsize.setEnabled(false);\n\t\t\t\tspinner_fbs.setEnabled(true);\n\t\t\t}\n\t\t});\n\t\tradioFBS.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tradioFBS.setBounds(435, 278, 18, 25);\n\t\tradioFBS.setText(\"Feature-based Segments\");\n\t\tfinal ArrayList<Control> step2 = new ArrayList<Control>();\n\t\tfinal List list_1 = new List(composite_2, SWT.BORDER | SWT.MULTI\n\t\t\t\t| SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tlist_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlist_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlist_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlist_1.setBounds(30, 118, 117, 339);\n\t\tstep2.add(list_1);\n\t\ttext_dmoutput = new Text(composite_2, SWT.BORDER);\n\t\ttext_dmoutput.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_dmoutput.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_dmoutput.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_dmoutput.setBounds(432, 378, 279, 25);\n\t\tLabel lbldmoutput = new Label(composite_2, SWT.NONE);\n\t\tlbldmoutput.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlbldmoutput.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlbldmoutput.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbldmoutput.setBounds(432, 348, 161, 25);\n\t\tlbldmoutput.setText(\"Output File Name:\");\n\t\tfinal ArrayList<Integer> cond_list = new ArrayList<Integer>();\n\t\tfinal ArrayList<Control> step1 = new ArrayList<Control>();\n\t\tfinal Button btnHb_1 = new Button(composite_2, SWT.CHECK);\n\t\tbtnHb_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnHb_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnHb_1.setBounds(431, 32, 18, 25);\n\t\tbtnHb_1.setText(\"Hb\");\n\t\tstep1.add(btnHb_1);\n\t\tfinal Button btnHbO_1 = new Button(composite_2, SWT.CHECK);\n\t\tbtnHbO_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnHbO_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnHbO_1.setText(\"HbO\");\n\t\tbtnHbO_1.setBounds(494, 32, 18, 25);\n\t\tstep1.add(btnHbO_1);\n\t\ttext_dm_sub = new Text(composite_2, SWT.BORDER);\n\t\ttext_dm_sub.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_dm_sub.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_dm_sub.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_dm_sub.setBounds(143, 32, 255, 25);\n\t\tstep1.add(text_dm_sub);\n\t\tlist.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (text_dm_sub.getEnabled()) {\n\t\t\t\t\tString[] dmSubjects = list.getSelection();\n\t\t\t\t\tif (dmSubjects.length > 0) {\n\t\t\t\t\t\tString dmSubject = dmSubjects[dmSubjects.length - 1];\n\t\t\t\t\t\ttext_dm_sub.setText(dmSubject);\n\t\t\t\t\t\ttext_dmoutput.setText(dmSubject);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfinal List list_2 = new List(composite_2, SWT.BORDER | SWT.V_SCROLL\n\t\t\t\t| SWT.H_SCROLL);\n\t\tlist_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlist_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlist_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlist_2.setBounds(175, 118, 224, 339);\n\t\tfor (String template : workspace.getTemplates()) {\n\t\t\tlist_2.add(template);\n\t\t}\n\t\tlist_2.setSelection(0);\n\t\tButton btnRun = new Button(composite_2, SWT.NONE);\n\t\tbtnRun.setEnabled(false);\n\t\tbtnRun.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnRun.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnRun.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif ((list_1.getSelectionIndices()).length < 2) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Select at least 2 conditions.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tif ((list_2.getSelectionIndices()).length < 1) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Select a process.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(5, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcond_list.clear();\n\t\t\t\tfor (Integer item : list_1.getSelectionIndices())\n\t\t\t\t\tcond_list.add(item);\n\t\t\t\tdisableList(step2);\n\t\t\t\tsplash.setProgress(10, \"Locating brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString name = text_dm_sub.getText();\n\t\t\t\tFile hbOutput = workspace.getHbOutput(name);\n\t\t\t\tFile hboOutput = workspace.getHbOOutput(name);\n\t\t\t\tif (hbOutput.exists())\n\t\t\t\t\thbOutput.delete();\n\t\t\t\tif (hboOutput.exists())\n\t\t\t\t\thboOutput.delete();\n\t\t\t\tif (btnHb_1.getSelection()) {\n\t\t\t\t\trapidDriver.filter(cond_list, workspace.getHb(name),\n\t\t\t\t\t\t\thbOutput);\n\t\t\t\t} else {\n\t\t\t\t\trapidDriver.empty(hbOutput);\n\t\t\t\t}\n\t\t\t\tif (btnHbO_1.getSelection()) {\n\t\t\t\t\trapidDriver.filter(cond_list, workspace.getHbO(name),\n\t\t\t\t\t\t\thboOutput);\n\t\t\t\t} else {\n\t\t\t\t\trapidDriver.empty(hboOutput);\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(25, \"Mining brain data...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tFile rminput = workspace.getRMInput(name);\n\t\t\t\t\tif (rminput.exists())\n\t\t\t\t\t\trminput.delete();\n\t\t\t\t\tif (radioAS.getSelection()) {\n\t\t\t\t\t\tint num_segs;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tnum_segs = (Integer.valueOf(spinner_avgseg\n\t\t\t\t\t\t\t\t\t.getText())).intValue();\n\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\tnfe.printStackTrace();\n\t\t\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\t\t\"Number of segments requires an integer.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdm.rapidFormatConversion(hbOutput.getAbsolutePath(),\n\t\t\t\t\t\t\t\thboOutput.getAbsolutePath(), workspace\n\t\t\t\t\t\t\t\t\t\t.getRMInput(name).getAbsolutePath(),\n\t\t\t\t\t\t\t\tnum_segs);\n\t\t\t\t\t} else if (radioSAX.getSelection()) {\n\t\t\t\t\t\tint seq_len;\n\t\t\t\t\t\tint alph_size;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tseq_len = (Integer.valueOf(spinner_seqlen1\n\t\t\t\t\t\t\t\t\t.getText())).intValue();\n\t\t\t\t\t\t\talph_size = (Integer.valueOf(spinner_alphsize\n\t\t\t\t\t\t\t\t\t.getText())).intValue();\n\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\tnfe.printStackTrace();\n\t\t\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\t\t\"Sequence length and Alphabet Size require integers.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdm.SAX_RapidFormatConversion(\n\t\t\t\t\t\t\t\thbOutput.getAbsolutePath(), hboOutput\n\t\t\t\t\t\t\t\t\t\t.getAbsolutePath(), workspace\n\t\t\t\t\t\t\t\t\t\t.getRMInput(name).getAbsolutePath(),\n\t\t\t\t\t\t\t\tseq_len, alph_size);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint num_segs;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tnum_segs = (Integer.valueOf(spinner_fbs.getText()))\n\t\t\t\t\t\t\t\t\t.intValue();\n\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\tnfe.printStackTrace();\n\t\t\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\t\t\"Number of Segments requires an integer.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdm.features_rapidFormatConversion(hbOutput\n\t\t\t\t\t\t\t\t.getAbsolutePath(),\n\t\t\t\t\t\t\t\thboOutput.getAbsolutePath(), workspace\n\t\t\t\t\t\t\t\t\t\t.getRMInput(name).getAbsolutePath(),\n\t\t\t\t\t\t\t\tnum_segs);\n\t\t\t\t\t}\n\t\t\t\t} catch (MWException mwe) {\n\t\t\t\t\tmwe.printStackTrace();\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\tenableList(step1);\n\t\t\t\t\tlist_1.removeAll();\n\t\t\t\t\tinfoBox(\"Error\", \"Data Mining Failed.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(80, \"Processing brain data...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tFile inputFile = workspace.getRMInput(name);\n\t\t\t\t\tFile outputFile = new File(workspace.getDMPath() + \"\\\\\"\n\t\t\t\t\t\t\t+ text_dmoutput.getText() + \".xls\");\n\t\t\t\t\tif (outputFile.exists()) {\n\t\t\t\t\t\toutputFile.delete();\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\trapidDriver.run(inputFile,\n\t\t\t\t\t\t\t\trapidDriver.generateProcess(inputFile,\n\t\t\t\t\t\t\t\t\t\tworkspace.getTemplate(list_2\n\t\t\t\t\t\t\t\t\t\t\t\t.getSelection()[0])),\n\t\t\t\t\t\t\t\toutputFile);\n\t\t\t\t\t} catch (IOException e1) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"Run failed.\");\n\t\t\t\t\t\tenableList(step1);\n\t\t\t\t\t\tlist_1.removeAll();\n\t\t\t\t\t}\n\t\t\t\t} catch (OperatorException e1) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\tinfoBox(\"Error\", \"Run failed.\");\n\t\t\t\t\tenableList(step1);\n\t\t\t\t\tlist_1.removeAll();\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(95, \"Gathering brain bits...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tenableList(step1);\n\t\t\t\tlist_1.removeAll();\n\t\t\t\tsplash.setProgress(100, \"Brain data successfully mined...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tbtnRun.setBounds(432, 429, 135, 28);\n\t\tbtnRun.setText(\"Run\");\n\t\tstep2.add(btnRun);\n\t\tButton btnNext = new Button(composite_2, SWT.NONE);\n\t\tbtnNext.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnNext.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnNext.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString subjectName = text_dm_sub.getText();\n\t\t\t\tif (subjectName == \"\"\n\t\t\t\t\t\t|| !Arrays.asList(list.getItems())\n\t\t\t\t\t\t\t\t.contains(subjectName)) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Subject \" + subjectName\n\t\t\t\t\t\t\t+ \" does not exist.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!btnHb_1.getSelection() && !btnHbO_1.getSelection()) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Select Hb or HbO or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (btnHb_1.getSelection()\n\t\t\t\t\t\t&& workspace.getHb(subjectName) == null) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Subject \" + subjectName\n\t\t\t\t\t\t\t+ \" does not have an Hb file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (btnHbO_1.getSelection()\n\t\t\t\t\t\t&& workspace.getHbO(subjectName) == null) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Subject \" + subjectName\n\t\t\t\t\t\t\t+ \" does not have an HbO file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdisableList(step1);\n\t\t\t\tenableList(step2);\n\t\t\t\tint n = workspace.getMaxCond(text_dm_sub.getText());\n\t\t\t\tfor (int i = 0; i <= n; i++) {\n\t\t\t\t\tString strI = \"\" + i;\n\t\t\t\t\tlist_1.add(strI);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbtnNext.setBounds(575, 30, 136, 28);\n\t\tbtnNext.setText(\"Fill Conditions\");\n\t\tstep1.add(btnNext);\n\t\tLabel lblSubjectName_1 = new Label(composite_2, SWT.NONE);\n\t\tlblSubjectName_1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectName_1.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectName_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSubjectName_1.setBounds(30, 32, 106, 25);\n\t\tlblSubjectName_1.setText(\"Subject Name:\");\n\t\tLabel lblNewLabel_1 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_1.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNewLabel_1.setBounds(30, 88, 126, 25);\n\t\tlblNewLabel_1.setText(\"Conditions:\");\n\t\tLabel lblDataRepresentation = new Label(composite_2, SWT.NONE);\n\t\tlblDataRepresentation.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblDataRepresentation.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblDataRepresentation.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.NORMAL));\n\t\tlblDataRepresentation.setBounds(431, 88, 196, 25);\n\t\tlblDataRepresentation.setText(\"Data Representation:\");\n\t\tButton btnCancel_DM = new Button(composite_2, SWT.NONE);\n\t\tbtnCancel_DM.setEnabled(false);\n\t\tbtnCancel_DM\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnCancel_DM.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnCancel_DM.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdisableList(step2);\n\t\t\t\tlist_1.removeAll();\n\t\t\t\tenableList(step1);\n\t\t\t}\n\t\t});\n\t\tbtnCancel_DM.setBounds(573, 429, 138, 28);\n\t\tbtnCancel_DM.setText(\"Cancel\");\n\t\tstep2.add(btnCancel_DM);\n\t\tLabel lblSelectProcess = new Label(composite_2, SWT.NONE);\n\t\tlblSelectProcess.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSelectProcess.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSelectProcess.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSelectProcess.setBounds(175, 88, 117, 25);\n\t\tlblSelectProcess.setText(\"Processes:\");\n\t\tLabel lblSegments = new Label(composite_2, SWT.NONE);\n\t\tlblSegments.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblSegments.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblSegments.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblSegments.setBounds(490, 148, 103, 25);\n\t\tlblSegments.setText(\"Segments:\");\n\t\tLabel lblNewLabel_2 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblNewLabel_2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_2.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_2.setText(\"Sequence Length:\");\n\t\tlblNewLabel_2.setBounds(491, 213, 143, 25);\n\t\tLabel lblNewLabel_3 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblNewLabel_3.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_3.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_3.setBounds(490, 308, 138, 25);\n\t\tlblNewLabel_3.setText(\"Segments:\");\n\t\tLabel lblNewLabel_5 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_5.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblNewLabel_5.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_5.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_5.setBounds(491, 243, 102, 25);\n\t\tlblNewLabel_5.setText(\"Alphabet Size:\");\n\t\tLabel label_6 = new Label(composite_2, SWT.NONE);\n\t\tlabel_6.setText(\"Hb\");\n\t\tlabel_6.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_6.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_6.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_6.setBounds(451, 34, 40, 25);\n\t\tLabel label_7 = new Label(composite_2, SWT.NONE);\n\t\tlabel_7.setText(\"HbO\");\n\t\tlabel_7.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_7.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_7.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_7.setBounds(514, 34, 55, 28);\n\t\tLabel lblNewLabel_4 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_4.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_4.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNewLabel_4.setBounds(455, 118, 168, 25);\n\t\tlblNewLabel_4.setText(\"Averaged Segments\");\n\t\tLabel lblSaxSegments = new Label(composite_2, SWT.NONE);\n\t\tlblSaxSegments.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSaxSegments.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSaxSegments.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSaxSegments.setBounds(455, 183, 135, 25);\n\t\tlblSaxSegments.setText(\"SAX Segments:\");\n\t\tLabel lblFeaturebasedSements = new Label(composite_2, SWT.NONE);\n\t\tlblFeaturebasedSements.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblFeaturebasedSements.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblFeaturebasedSements.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.NORMAL));\n\t\tlblFeaturebasedSements.setBounds(455, 278, 169, 25);\n\t\tlblFeaturebasedSements.setText(\"Feature-based Sements:\");\n\t\tfor (Control item : step2) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\tButton btnRemove = new Button(shlFnirsDataProcessing, SWT.FLAT);\n\t\tbtnRemove.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnRemove.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnRemove.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (list.getSelection().length == 0)\n\t\t\t\t\treturn;\n\t\t\t\tMessageBox warn = new MessageBox(shlFnirsDataProcessing,\n\t\t\t\t\t\tSWT.ICON_QUESTION | SWT.YES | SWT.NO);\n\t\t\t\twarn.setText(\"Warning!\");\n\t\t\t\twarn.setMessage(\"Are you sure you want to remove all data on the selected subjects?\");\n\t\t\t\tint result = warn.open();\n\t\t\t\tif (result != SWT.YES)\n\t\t\t\t\treturn;\n\t\t\t\tfor (String subject : list.getSelection()) {\n\t\t\t\t\tworkspace.removeSubject(subject);\n\t\t\t\t}\n\t\t\t\tfor (Integer item : list.getSelectionIndices())\n\t\t\t\t\tindexList.add(item);\n\t\t\t\tint[] indices = new int[indexList.size()];\n\t\t\t\tfor (int i = 0; i < indexList.size(); i++)\n\t\t\t\t\tindices[i] = indexList.get(i);\n\t\t\t\tlist.remove(indices);\n\t\t\t\tindexList.clear();\n\t\t\t}\n\t\t});\n\t\tbtnRemove.setBounds(10, 504, 226, 28);\n\t\tbtnRemove.setText(\"Remove Subject(s)\");\n\t\tLabel lblSubjectName2 = new Label(composite_4, SWT.NONE);\n\t\tlblSubjectName2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectName2.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectName2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSubjectName2.setBounds(30, 40, 105, 25);\n\t\tlblSubjectName2.setText(\"Subject Name:\");\n\t\ttext_subName2 = new Text(composite_4, SWT.BORDER);\n\t\ttext_subName2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_subName2.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_subName2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_subName2.setBounds(146, 40, 396, 25);\n\t\tfinal Spinner num_channels_H = new Spinner(composite_4, SWT.BORDER);\n\t\tnum_channels_H.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tnum_channels_H.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tnum_channels_H.setSelection(52);\n\t\tnum_channels_H.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnum_channels_H.setBounds(283, 85, 47, 25);\n\t\tLabel lblNumberOfChannels = new Label(composite_4, SWT.NONE);\n\t\tlblNumberOfChannels.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNumberOfChannels.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNumberOfChannels.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNumberOfChannels.setBounds(205, 85, 69, 25);\n\t\tlblNumberOfChannels.setText(\"Channels:\");\n\t\tfinal Spinner num_sessions_h = new Spinner(composite_4, SWT.BORDER);\n\t\tnum_sessions_h.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tnum_sessions_h.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tnum_sessions_h.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnum_sessions_h.setMinimum(1);\n\t\tnum_sessions_h.setBounds(105, 85, 47, 25);\n\t\tfinal Label lblOf_H = new Label(composite_4, SWT.NONE);\n\t\tlblOf_H.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblOf_H.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblOf_H.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.ITALIC));\n\t\tlblOf_H.setText(\"Session: 1 of 1\");\n\t\tlblOf_H.setBounds(30, 380, 274, 20);\n\t\tloadHatachi.add(lblOf_H);\n\t\tfinal Button btnHb = new Button(composite_4, SWT.CHECK);\n\t\tbtnHb.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnHb.setBounds(390, 85, 14, 25);\n\t\tbtnHb.setText(\"Hb\");\n\t\tfinal Button btnHbo = new Button(composite_4, SWT.CHECK);\n\t\tbtnHbo.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnHbo.setBounds(453, 85, 14, 25);\n\t\tbtnHbo.setText(\"HbO\");\n\t\tfinal Button button_2 = new Button(composite_4, SWT.NONE);\n\t\tbutton_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbutton_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbutton_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbutton_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsubjectNameH = text_subName2.getText();\n\t\t\t\tif (subjectNameH == \"\"\n\t\t\t\t\t\t|| subjectNameH.matches(subjectName)\n\t\t\t\t\t\t|| Arrays.asList(list.getItems())\n\t\t\t\t\t\t\t\t.contains(subjectNameH)) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Please enter a new name.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!btnHb.getSelection() && !btnHbo.getSelection()) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Select Hb or HbO or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (Control item : loadHatachi) {\n\t\t\t\t\titem.setVisible(true);\n\t\t\t\t}\n\t\t\t\tif (!btnHb.getSelection()) {\n\t\t\t\t\ttext_4.setVisible(false);\n\t\t\t\t\tbtnNewButton.setVisible(false);\n\t\t\t\t\tlblHbFile.setVisible(false);\n\t\t\t\t}\n\t\t\t\tif (!btnHbo.getSelection()) {\n\t\t\t\t\ttext_5.setVisible(false);\n\t\t\t\t\tbtnBrowse_1.setVisible(false);\n\t\t\t\t\tlblHboFile.setVisible(false);\n\t\t\t\t}\n\t\t\t\tsessionNumH = 1;\n\t\t\t\tlblOf_H.setText(\"Session: 1 of \" + num_sessions_h.getText());\n\t\t\t\ttext_subName2.setEnabled(false);\n\t\t\t\tnum_sessions_h.setEnabled(false);\n\t\t\t\tbutton_2.setEnabled(false);\n\t\t\t\tnum_channels_H.setEnabled(false);\n\t\t\t\tbtnHb.setEnabled(false);\n\t\t\t\tbtnHbo.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tbutton_2.setText(\"Enter\");\n\t\tbutton_2.setBounds(548, 38, 143, 28);\n\t\tbtnAdd.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tFile condFile = new File(text_7.getText());\n\t\t\t\tif (!setExists(condFile)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint channels = (Integer.valueOf(num_channels_H.getText()))\n\t\t\t\t\t\t.intValue();\n\t\t\t\tFile HbFile = new File(text_4.getText());\n\t\t\t\tFile HbOFile = new File(text_5.getText());\n\t\t\t\tif (!HbFile.exists() && !HbOFile.exists()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tsplash.setProgress(0, \"Finding deoxygenated brains...\");\n\t\t\t\tif (HbFile.exists()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpre.xlsreadfile(HbFile.getAbsolutePath(), \"Hb\",\n\t\t\t\t\t\t\t\tchannels);\n\t\t\t\t\t\tHbFile = new File(\"Hb\");\n\t\t\t\t\t} catch (MWException e1) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"Hb File must be an excel csv file.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbFile = null;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(18, \"Finding oxygenated brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (HbOFile.exists()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpre.xlsreadfile(HbOFile.getAbsolutePath(), \"HbO\",\n\t\t\t\t\t\t\t\tchannels);\n\t\t\t\t\t\tHbOFile = new File(\"HbO\");\n\t\t\t\t\t} catch (MWException e1) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"HbO File must be an excel csv file.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbOFile = null;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(36, \"Prepping brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (sessionNumH == 1) {\n\t\t\t\t\t\tworkspace.addSubject(subjectNameH, HbFile, HbOFile,\n\t\t\t\t\t\t\t\tcondFile);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tworkspace.concatSession(subjectNameH, HbFile, HbOFile,\n\t\t\t\t\t\t\t\tcondFile);\n\t\t\t\t\t}\n\t\t\t\t} catch (InputMismatchException ime) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\time.printStackTrace();\n\t\t\t\t\tworkspace.removeSubject(subjectNameH);\n\t\t\t\t\tinfoBox(\"Error\", \"Conditions file must be a text file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsessionNumH++;\n\t\t\t\tsplash.setProgress(40, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (sessionNumH > Integer.valueOf(num_sessions_h.getText())\n\t\t\t\t\t\t.intValue()) {\n\t\t\t\t\tlist.add(subjectNameH);\n\t\t\t\t\tfor (Control item : loadHatachi) {\n\t\t\t\t\t\titem.setVisible(false);\n\t\t\t\t\t}\n\t\t\t\t\ttext_subName2.setEnabled(true);\n\t\t\t\t\tnum_sessions_h.setEnabled(true);\n\t\t\t\t\tbutton_2.setEnabled(true);\n\t\t\t\t\tnum_channels_H.setEnabled(true);\n\t\t\t\t\tbtnHb.setEnabled(true);\n\t\t\t\t\tbtnHbo.setEnabled(true);\n\t\t\t\t\ttext_subName2.setText(\"\");\n\t\t\t\t\tnum_sessions_h.setSelection(1);\n\t\t\t\t} else {\n\t\t\t\t\tlblOf_H.setText(\"Session: \" + sessionNumH + \" of \"\n\t\t\t\t\t\t\t+ num_sessions_h.getText());\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(68, \"Offering Hitachi-san some brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttext_4.setText(\"\");\n\t\t\t\ttext_5.setText(\"\");\n\t\t\t\ttext_7.setText(\"\");\n\t\t\t\ttext_subName2.setText(\"\");\n\t\t\t\tsplash.setProgress(100, \"Hitachi likes brains!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tloadHatachi.add(btnAdd);\n\t\tCTabItem tbtmNewItem_2 = new CTabItem(tabFolder_1, SWT.BORDER\n\t\t\t\t| SWT.FLAT);\n\t\ttbtmNewItem_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 13,\n\t\t\t\tSWT.BOLD));\n\t\ttbtmNewItem_2.setText(\" Hitachi \");\n\t\ttbtmNewItem_2.setControl(composite_4);\n\t\tLabel label_3 = new Label(composite_4, SWT.NONE);\n\t\tlabel_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_3.setText(\"Conditions File:\");\n\t\tlabel_3.setBounds(30, 300, 111, 25);\n\t\tloadHatachi.add(label_3);\n\t\ttext_7 = new Text(composite_4, SWT.BORDER);\n\t\ttext_7.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_7.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_7.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_7.setBounds(146, 300, 396, 25);\n\t\tloadHatachi.add(text_7);\n\t\tCTabItem tabOther = new CTabItem(tabFolder_1, SWT.BORDER | SWT.FLAT);\n\t\ttabOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 13, SWT.BOLD));\n\t\ttabOther.setText(\" Other \");\n\t\tComposite composite_other = new Composite(tabFolder_1, SWT.NONE);\n\t\tcomposite_other.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tcomposite_other.setVisible(false);\n\t\tcomposite_other.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttabOther.setControl(composite_other);\n\t\tfinal ArrayList<Control> loadOther = new ArrayList<Control>();\n\t\ttext_hbother = new Text(composite_other, SWT.BORDER);\n\t\ttext_hbother\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_hbother\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_hbother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_hbother.setBounds(146, 200, 396, 25);\n\t\tloadOther.add(text_hbother);\n\t\ttext_hboother = new Text(composite_other, SWT.BORDER);\n\t\ttext_hboother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_hboother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_hboother.setBounds(146, 250, 396, 25);\n\t\tloadOther.add(text_hboother);\n\t\tfinal Button browse_hbother = new Button(composite_other, SWT.NONE);\n\t\tbrowse_hbother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbrowse_hbother.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_hbother);\n\t\t\t}\n\t\t});\n\t\tbrowse_hbother.setText(\"Browse...\");\n\t\tbrowse_hbother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbrowse_hbother.setBounds(548, 198, 127, 28);\n\t\tloadOther.add(browse_hbother);\n\t\tfinal Button browse_hboother = new Button(composite_other, SWT.NONE);\n\t\tbrowse_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbrowse_hboother.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_hboother);\n\t\t\t}\n\t\t});\n\t\tbrowse_hboother.setText(\"Browse...\");\n\t\tbrowse_hboother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbrowse_hboother.setBounds(548, 248, 127, 28);\n\t\tloadOther.add(browse_hboother);\n\t\tfinal Label label_hboother = new Label(composite_other, SWT.NONE);\n\t\tlabel_hboother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlabel_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlabel_hboother.setText(\"HbO File:\");\n\t\tlabel_hboother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlabel_hboother.setBounds(30, 250, 84, 28);\n\t\tloadOther.add(label_hboother);\n\t\tfinal Label lbl_hbother = new Label(composite_other, SWT.NONE);\n\t\tlbl_hbother.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlbl_hbother.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlbl_hbother.setText(\"Hb File:\");\n\t\tlbl_hbother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbl_hbother.setBounds(30, 200, 84, 28);\n\t\tloadOther.add(lbl_hbother);\n\t\tfinal Spinner spinner_nsother = new Spinner(composite_other, SWT.BORDER);\n\t\tspinner_nsother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tspinner_nsother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_nsother.setMinimum(1);\n\t\tspinner_nsother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_nsother.setBounds(105, 85, 47, 25);\n\t\tfinal Label lbl_seshnum = new Label(composite_other, SWT.NONE);\n\t\tlbl_seshnum.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlbl_seshnum.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlbl_seshnum.setText(\"Session: 1 of 1\");\n\t\tlbl_seshnum.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlbl_seshnum.setBounds(30, 380, 212, 20);\n\t\tloadOther.add(lbl_seshnum);\n\t\tfinal Button button_hbother = new Button(composite_other, SWT.CHECK);\n\t\tbutton_hbother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbutton_hbother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tbutton_hbother.setText(\"Hb\");\n\t\tbutton_hbother.setBounds(404, 85, 14, 25);\n\t\tfinal Button button_hboother = new Button(composite_other, SWT.CHECK);\n\t\tbutton_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbutton_hboother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tbutton_hboother.setText(\"HbO\");\n\t\tbutton_hboother.setBounds(467, 85, 14, 28);\n\t\tfinal Button enter_other = new Button(composite_other, SWT.NONE);\n\t\tButton add_other = new Button(composite_other, SWT.NONE);\n\t\tadd_other.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tadd_other.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tFile condFile = new File(text_conditionsother.getText());\n\t\t\t\tif (!setExists(condFile))\n\t\t\t\t\treturn;\n\t\t\t\tint channels = (Integer.valueOf(spinner_nsother.getText()))\n\t\t\t\t\t\t.intValue();\n\t\t\t\tFile Hb = new File(text_hbother.getText());\n\t\t\t\tFile HbO = new File(text_hboother.getText());\n\t\t\t\tif (!Hb.exists() && !HbO.exists()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tFile HbFile = new File(\"HbFile\");\n\t\t\t\tFile HbOFile = new File(\"HbOFile\");\n\t\t\t\tif (text_hbother.getText() != \"\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFiles.copy(Hb.toPath(), HbFile.toPath()\n\t\t\t\t\t\t\t\t.toAbsolutePath(),\n\t\t\t\t\t\t\t\tStandardCopyOption.REPLACE_EXISTING);\n\t\t\t\t\t} catch (IOException e2) {\n\t\t\t\t\t\te2.printStackTrace();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbFile = null;\n\t\t\t\t}\n\t\t\t\tif (text_hboother.getText() != \"\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFiles.copy(HbO.toPath(), HbOFile.toPath()\n\t\t\t\t\t\t\t\t.toAbsolutePath(),\n\t\t\t\t\t\t\t\tStandardCopyOption.REPLACE_EXISTING);\n\t\t\t\t\t} catch (IOException e2) {\n\t\t\t\t\t\te2.printStackTrace();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbOFile = null;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\ttry {\n\t\t\t\t\tif (sessionNumOther == 1) {\n\t\t\t\t\t\tworkspace.addSubject(subjectNameOther, HbFile, HbOFile,\n\t\t\t\t\t\t\t\tcondFile);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tworkspace.concatSession(subjectNameOther, HbFile,\n\t\t\t\t\t\t\t\tHbOFile, condFile);\n\t\t\t\t\t}\n\t\t\t\t} catch (InputMismatchException ime) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\time.printStackTrace();\n\t\t\t\t\tworkspace.removeSubject(subjectNameOther);\n\t\t\t\t\tinfoBox(\"Error\", \"Conditions file must be a text file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsessionNumOther++;\n\t\t\t\tsplash.setProgress(33, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\tif (sessionNumOther > Integer\n\t\t\t\t\t\t.valueOf(spinner_nsother.getText()).intValue()) {\n\t\t\t\t\tlist.add(subjectNameOther);\n\t\t\t\t\tfor (Control item : loadOther) {\n\t\t\t\t\t\titem.setVisible(false);\n\t\t\t\t\t}\n\t\t\t\t\ttext_subnameOther.setEnabled(true);\n\t\t\t\t\tspinner_nsother.setEnabled(true);\n\t\t\t\t\tenter_other.setEnabled(true);\n\t\t\t\t\tbutton_hbother.setEnabled(true);\n\t\t\t\t\tbutton_hboother.setEnabled(true);\n\t\t\t\t\ttext_subnameOther.setText(\"\");\n\t\t\t\t\tspinner_nsother.setSelection(1);\n\t\t\t\t} else {\n\t\t\t\t\tlbl_seshnum.setText(sessionNumOther + \" of \"\n\t\t\t\t\t\t\t+ spinner_nsother.getText());\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(68, \"Almost there...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\ttext_hbother.setText(\"\");\n\t\t\t\ttext_hboother.setText(\"\");\n\t\t\t\ttext_conditionsother.setText(\"\");\n\t\t\t\ttext_subnameOther.setText(\"\");\n\t\t\t\tsplash.setProgress(100, \"Done!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tadd_other.setText(\"Add\");\n\t\tadd_other.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tadd_other.setBounds(469, 380, 100, 28);\n\t\tloadOther.add(add_other);\n\t\tLabel label_subNameOther = new Label(composite_other, SWT.NONE);\n\t\tlabel_subNameOther.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlabel_subNameOther.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlabel_subNameOther.setText(\"Subject Name:\");\n\t\tlabel_subNameOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlabel_subNameOther.setBounds(30, 42, 105, 28);\n\t\ttext_subnameOther = new Text(composite_other, SWT.BORDER);\n\t\ttext_subnameOther.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_subnameOther.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_subnameOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_subnameOther.setBounds(146, 42, 396, 25);\n\t\tenter_other.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tenter_other.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsubjectNameOther = text_subnameOther.getText();\n\t\t\t\tif (subjectNameOther == \"\"\n\t\t\t\t\t\t|| subjectNameOther.matches(subjectName)\n\t\t\t\t\t\t|| subjectNameOther.matches(subjectNameH)\n\t\t\t\t\t\t|| Arrays.asList(list.getItems()).contains(\n\t\t\t\t\t\t\t\tsubjectNameOther)) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Please enter a new name.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!button_hbother.getSelection()\n\t\t\t\t\t\t&& !button_hboother.getSelection()) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Select Hb or HbO or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (Control item : loadOther) {\n\t\t\t\t\titem.setVisible(true);\n\t\t\t\t}\n\t\t\t\tif (!button_hbother.getSelection()) {\n\t\t\t\t\ttext_hbother.setVisible(false);\n\t\t\t\t\tbrowse_hbother.setVisible(false);\n\t\t\t\t\tlbl_hbother.setVisible(false);\n\t\t\t\t}\n\t\t\t\tif (!button_hboother.getSelection()) {\n\t\t\t\t\ttext_hboother.setVisible(false);\n\t\t\t\t\tbrowse_hboother.setVisible(false);\n\t\t\t\t\tlabel_hboother.setVisible(false);\n\t\t\t\t}\n\t\t\t\tsessionNumOther = 1;\n\t\t\t\tlbl_seshnum.setText(\"1 of \" + spinner_nsother.getText());\n\t\t\t\ttext_subnameOther.setEnabled(false);\n\t\t\t\tspinner_nsother.setEnabled(false);\n\t\t\t\tenter_other.setEnabled(false);\n\t\t\t\tbutton_hbother.setEnabled(false);\n\t\t\t\tbutton_hboother.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tenter_other.setText(\"Enter\");\n\t\tenter_other.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tenter_other.setBounds(548, 40, 133, 28);\n\t\tLabel lbl_conditionsother = new Label(composite_other, SWT.NONE);\n\t\tlbl_conditionsother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlbl_conditionsother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlbl_conditionsother.setText(\"Conditions File:\");\n\t\tlbl_conditionsother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbl_conditionsother.setBounds(30, 300, 111, 28);\n\t\tloadOther.add(lbl_conditionsother);\n\t\ttext_conditionsother = new Text(composite_other, SWT.BORDER);\n\t\ttext_conditionsother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_conditionsother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_conditionsother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_conditionsother.setBounds(146, 300, 396, 25);\n\t\tloadOther.add(text_conditionsother);\n\t\tButton browse_condother = new Button(composite_other, SWT.NONE);\n\t\tbrowse_condother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbrowse_condother.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_conditionsother);\n\t\t\t}\n\t\t});\n\t\tbrowse_condother.setText(\"Browse...\");\n\t\tbrowse_condother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbrowse_condother.setBounds(548, 298, 127, 28);\n\t\tloadOther.add(browse_condother);\n\t\tLabel label_ppoptions = new Label(composite_other, SWT.NONE);\n\t\tlabel_ppoptions.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlabel_ppoptions.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlabel_ppoptions.setText(\"Preprocessing Options:\");\n\t\tlabel_ppoptions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.BOLD));\n\t\tlabel_ppoptions.setBounds(30, 150, 189, 25);\n\t\tloadOther.add(label_ppoptions);\n\t\tLabel lbl_numSessionsOther = new Label(composite_other, SWT.NONE);\n\t\tlbl_numSessionsOther.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlbl_numSessionsOther.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlbl_numSessionsOther.setText(\"Sessions:\");\n\t\tlbl_numSessionsOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbl_numSessionsOther.setBounds(30, 85, 63, 25);\n\t\tButton cancel_other = new Button(composite_other, SWT.NONE);\n\t\tcancel_other\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcancel_other.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tworkspace.removeSubject(subjectNameOther);\n\t\t\t\tfor (Control item : loadOther) {\n\t\t\t\t\titem.setVisible(false);\n\t\t\t\t}\n\t\t\t\ttext_subnameOther.setEnabled(true);\n\t\t\t\tspinner_nsother.setEnabled(true);\n\t\t\t\tenter_other.setEnabled(true);\n\t\t\t\tbutton_hbother.setEnabled(true);\n\t\t\t\tbutton_hboother.setEnabled(true);\n\t\t\t\ttext_subnameOther.setText(\"\");\n\t\t\t\tspinner_nsother.setSelection(1);\n\t\t\t\tsubjectNameOther = \"\";\n\t\t\t}\n\t\t});\n\t\tcancel_other.setText(\"Cancel\");\n\t\tcancel_other.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tcancel_other.setBounds(575, 380, 100, 28);\n\t\tloadOther.add(cancel_other);\n\t\tLabel lblHb = new Label(composite_other, SWT.NONE);\n\t\tlblHb.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHb.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHb.setBounds(424, 87, 32, 25);\n\t\tlblHb.setText(\"Hb\");\n\t\tLabel lblHbo = new Label(composite_other, SWT.NONE);\n\t\tlblHbo.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHbo.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHbo.setBounds(487, 87, 55, 25);\n\t\tlblHbo.setText(\"HbO\");\n\t\tButton btnBrowse_2 = new Button(composite_4, SWT.NONE);\n\t\tbtnBrowse_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnBrowse_2.setBounds(548, 298, 143, 28);\n\t\tbtnBrowse_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_7);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse_2.setText(\"Browse...\");\n\t\tloadHatachi.add(btnBrowse_2);\n\t\tLabel label_2 = new Label(composite_4, SWT.NONE);\n\t\tlabel_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_2.setText(\"Preprocessing Options:\");\n\t\tlabel_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.BOLD));\n\t\tlabel_2.setBounds(30, 150, 189, 25);\n\t\tloadHatachi.add(label_2);\n\t\tLabel lblSessions = new Label(composite_4, SWT.NONE);\n\t\tlblSessions.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblSessions.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblSessions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSessions.setText(\"Sessions:\");\n\t\tlblSessions.setBounds(30, 85, 69, 25);\n\t\tfinal Button btnCancel = new Button(composite_4, SWT.NONE);\n\t\tbtnCancel.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnCancel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnCancel.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnCancel.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tworkspace.removeSubject(subjectNameH);\n\t\t\t\tfor (Control item : loadHatachi) {\n\t\t\t\t\titem.setVisible(false);\n\t\t\t\t}\n\t\t\t\ttext_subName2.setEnabled(true);\n\t\t\t\tnum_sessions_h.setEnabled(true);\n\t\t\t\tbutton_2.setEnabled(true);\n\t\t\t\tnum_channels_H.setEnabled(true);\n\t\t\t\tbtnHb.setEnabled(true);\n\t\t\t\tbtnHbo.setEnabled(true);\n\t\t\t\ttext_subName2.setText(\"\");\n\t\t\t\tnum_sessions_h.setSelection(1);\n\t\t\t\tsubjectNameH = \"\";\n\t\t\t}\n\t\t});\n\t\tbtnCancel.setBounds(591, 380, 100, 25);\n\t\tbtnCancel.setText(\"Cancel\");\n\t\tloadHatachi.add(btnCancel);\n\t\tLabel label_5 = new Label(composite_4, SWT.NONE);\n\t\tlabel_5.setText(\"Hb\");\n\t\tlabel_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_5.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_5.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_5.setBounds(410, 85, 28, 25);\n\t\tLabel label_8 = new Label(composite_4, SWT.NONE);\n\t\tlabel_8.setText(\"HbO\");\n\t\tlabel_8.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_8.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_8.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_8.setBounds(473, 85, 55, 28);\n\t\tButton btnNewButton_1 = new Button(shlFnirsDataProcessing, SWT.FLAT);\n\t\tbtnNewButton_1.pack();\n\t\tbtnNewButton_1.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_HAND));\n\t\tbtnNewButton_1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnNewButton_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (button_3.getVisible()) {\n\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\"Cancel file loading before changing workspace.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (btnCancel.getVisible()) {\n\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\"Cancel file loading before changing workspace.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfileDialog = new FileDialog(shlFnirsDataProcessing, SWT.OPEN\n\t\t\t\t\t\t| SWT.CANCEL);\n\t\t\t\tDirectoryDialog dlg = new DirectoryDialog(\n\t\t\t\t\t\tshlFnirsDataProcessing);\n\t\t\t\tdlg.setText(\"Select Workspace\");\n\t\t\t\tString selected = dlg.open(); \n\t\t\t\tif (selected == null)\n\t\t\t\t\treturn;\n\t\t\t\tdisableList(step2);\n\t\t\t\tlist_1.removeAll();\n\t\t\t\tenableList(step1);\n\t\t\t\tlist.removeAll();\n\t\t\t\tworkspace = new Workspace(selected, pre);\n\t\t\t\tworkspace.loadSubjects(list);\n\t\t\t\tlist_2.removeAll();\n\t\t\t\tfor (String template : workspace.getTemplates()) {\n\t\t\t\t\tlist_2.add(template);\n\t\t\t\t}\n\t\t\t\tlist_2.setSelection(0);\n\t\t\t\ttext_dm_sub.setText(\"\");\n\t\t\t\ttext_dmoutput.setText(\"\");\n\t\t\t}\n\t\t});\n\t\tbtnNewButton_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnNewButton_1.setBounds(10, 436, 226, 28);\n\t\tbtnNewButton_1.setText(\"Change Workspace\");\n\t\tLabel lblSubjectList = new Label(shlFnirsDataProcessing, SWT.BORDER);\n\t\tlblSubjectList.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectList.setAlignment(SWT.CENTER);\n\t\tlblSubjectList.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.BOLD));\n\t\tlblSubjectList.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectList.setBounds(10, 10, 226, 28);\n\t\tlblSubjectList.setText(\"Subject List\");\n\t\tfor (Control item : loadHatachi) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\tfor (Control item : loadOther) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\ttabFolder.setSelection(0);\n\t\ttabFolder_1.setSelection(0);\n\t\tButton btnClear = new Button(shlFnirsDataProcessing, SWT.FLAT);\n\t\tbtnClear.setBounds(10, 470, 226, 28);\n\t\tbtnClear.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnClear.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnClear.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tlist.deselectAll();\n\t\t\t\tindexList.clear();\n\t\t\t}\n\t\t});\n\t\tbtnClear.setText(\"Clear Selections\");\n\t\tlist_1.setVisible(true);\n\t\tbtnRun.setVisible(true);\n\t\tbtnCancel_DM.setVisible(true);\n\t\treturn 0;\n\t}\n", "output": "\tprotected int createContents() {\n\t\tshlFnirsDataProcessing = new Shell(SWT.CLOSE | SWT.MIN | SWT.TITLE);\n\t\tshlFnirsDataProcessing.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.NORMAL));\n\t\tshlFnirsDataProcessing.setImage(SWTResourceManager.getImage(\n\t\t\t\tHello.class, \"/fNIRs/logo.png\"));\n\t\tshlFnirsDataProcessing.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tshlFnirsDataProcessing.setSize(1000, 600);\n\t\tshlFnirsDataProcessing\n\t\t\t\t.setText(\"Zombie MiNIR - fNIRs Data Processing and Analysis\");\n\t\tfileDialog = new FileDialog(shlFnirsDataProcessing, SWT.OPEN\n\t\t\t\t| SWT.CANCEL);\n\t\tDirectoryDialog dlg = new DirectoryDialog(shlFnirsDataProcessing);\n\t\tdlg.setText(\"Select a workspace\");\n\t\tString selected = dlg.open();\n\t\tif (selected == null)\n\t\t\treturn 1;\n\t\tworkspace = new Workspace(selected, pre);\n\t\tfinal List list = new List(shlFnirsDataProcessing, SWT.BORDER\n\t\t\t\t| SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.CENTER);\n\t\tlist.setForeground(SWTResourceManager.getColor(SWT.COLOR_GREEN));\n\t\tlist.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlist.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlist.setBounds(10, 38, 226, 392);\n\t\tGridData data = new GridData(SWT.FILL, SWT.FILL, true, true);\n\t\tlist.setLayoutData(data);\n\t\tworkspace.loadSubjects(list);\n\t\tMenu menu = new Menu(shlFnirsDataProcessing, SWT.BAR);\n\t\tshlFnirsDataProcessing.setMenuBar(menu);\n\t\tMenuItem mntmHelp_1 = new MenuItem(menu, SWT.CASCADE);\n\t\tmntmHelp_1.setText(\"Help\");\n\t\tMenu menu_1 = new Menu(mntmHelp_1);\n\t\tmntmHelp_1.setMenu(menu_1);\n\t\tMenuItem mntmHelp = new MenuItem(menu_1, SWT.NONE);\n\t\tmntmHelp.setText(\"Tutorial\");\n\t\tCTabFolder tabFolder = new CTabFolder(shlFnirsDataProcessing,\n\t\t\t\tSWT.BORDER | SWT.FLAT);\n\t\ttabFolder.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttabFolder.setSelectionBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder.setSelectionForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_GREEN));\n\t\ttabFolder.setSimple(false);\n\t\ttabFolder.setFont(SWTResourceManager.getFont(\"Segoe UI\", 14, SWT.BOLD));\n\t\ttabFolder.setBounds(242, 10, 742, 522);\n\t\tCTabItem tbtmLoadFiles = new CTabItem(tabFolder, SWT.BORDER | SWT.FLAT);\n\t\ttbtmLoadFiles.setFont(SWTResourceManager.getFont(\"Segoe UI\", 14,\n\t\t\t\tSWT.BOLD));\n\t\ttbtmLoadFiles.setText(\" Load Subjects\");\n\t\tComposite composite = new Composite(tabFolder, SWT.NONE);\n\t\tcomposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.BOLD\n\t\t\t\t| SWT.ITALIC));\n\t\ttbtmLoadFiles.setControl(composite);\n\t\tCTabFolder tabFolder_1 = new CTabFolder(composite, SWT.BORDER\n\t\t\t\t| SWT.FLAT);\n\t\ttabFolder_1.setBackgroundMode(SWT.INHERIT_DEFAULT);\n\t\ttabFolder_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttabFolder_1.setSelectionBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttabFolder_1.setSelectionForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_GREEN));\n\t\ttabFolder_1.setSimple(false);\n\t\ttabFolder_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 9,\n\t\t\t\tSWT.NORMAL));\n\t\ttabFolder_1.setBounds(10, 10, 718, 474);\n\t\tCTabItem tbtmNewItem = new CTabItem(tabFolder_1, SWT.BORDER | SWT.FLAT);\n\t\ttbtmNewItem.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 13, SWT.BOLD));\n\t\ttbtmNewItem.setText(\" ISS Oxyplex \");\n\t\tComposite composite_3 = new Composite(tabFolder_1, SWT.NONE);\n\t\tcomposite_3.setSize(new Point(30, 30));\n\t\tcomposite_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttbtmNewItem.setControl(composite_3);\n\t\tfinal ArrayList<Control> loadItems = new ArrayList<Control>();\n\t\tfinal Spinner spinner = new Spinner(composite_3, SWT.BORDER);\n\t\tspinner.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tspinner.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tspinner.setSelection(20);\n\t\tspinner.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tspinner.setBounds(579, 242, 47, 25);\n\t\tloadItems.add(spinner);\n\t\tfinal Label lblOf = new Label(composite_3, SWT.NONE);\n\t\tlblOf.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblOf.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblOf.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.ITALIC));\n\t\tlblOf.setBounds(30, 380, 213, 25);\n\t\tlblOf.setText(\"Session: 1 of 1\");\n\t\tloadItems.add(lblOf);\n\t\tfinal Button btnCheckButton = new Button(composite_3, SWT.CHECK);\n\t\tbtnCheckButton.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnCheckButton.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tbtnCheckButton.setSelection(true);\n\t\tbtnCheckButton.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnCheckButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (btnCheckButton.getSelection())\n\t\t\t\t\tspinner.setEnabled(true);\n\t\t\t\telse\n\t\t\t\t\tspinner.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tbtnCheckButton.setBounds(425, 241, 21, 28);\n\t\tloadItems.add(btnCheckButton);\n\t\tfinal Spinner num_sessions = new Spinner(composite_3, SWT.BORDER);\n\t\tnum_sessions\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tnum_sessions\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tnum_sessions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnum_sessions.setMinimum(1);\n\t\tnum_sessions.setBounds(524, 32, 47, 25);\n\t\tfinal Button btnEnter_1 = new Button(composite_3, SWT.NONE);\n\t\tbtnEnter_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnEnter_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnEnter_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnEnter_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsubjectName = text_subName.getText();\n\t\t\t\tif (subjectName == \"\" || subjectName.matches(subjectNameH)\n\t\t\t\t\t\t|| Arrays.asList(list.getItems()).contains(subjectName)) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Please enter a new name.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (Control item : loadItems) {\n\t\t\t\t\titem.setVisible(true);\n\t\t\t\t}\n\t\t\t\tsessionNum = 1;\n\t\t\t\tlblOf.setText(\"Session: 1 of \" + num_sessions.getText());\n\t\t\t\ttext_subName.setEnabled(false);\n\t\t\t\tnum_sessions.setEnabled(false);\n\t\t\t\tbtnEnter_1.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tbtnEnter_1.setBounds(580, 30, 106, 28);\n\t\tbtnEnter_1.setText(\"Enter\");\n\t\tButton btnEnter = new Button(composite_3, SWT.NONE);\n\t\tbtnEnter.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnEnter.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnEnter.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnEnter.setBounds(480, 381, 100, 28);\n\t\tbtnEnter.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdouble freq = 0;\n\t\t\t\tdouble hpf = 0;\n\t\t\t\tdouble lpf = 0;\n\t\t\t\tFile newFile = new File(text.getText());\n\t\t\t\tif (!setExists(newFile))\n\t\t\t\t\treturn;\n\t\t\t\tFile condFile = new File(text_6.getText());\n\t\t\t\tif (!setExists(condFile))\n\t\t\t\t\treturn;\n\t\t\t\ttry {\n\t\t\t\t\tfreq = (Double.valueOf(text_1.getText())).doubleValue();\n\t\t\t\t\thpf = (Double.valueOf(text_2.getText())).doubleValue();\n\t\t\t\t\tlpf = (Double.valueOf(text_3.getText())).doubleValue();\n\t\t\t\t} catch (NumberFormatException e1) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Please fill in all frequencies.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tsplash.setProgress(0, \"Zombies have arrived...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchar slideavg = 'n';\n\t\t\t\tint interval = 0;\n\t\t\t\tif (btnCheckButton.getSelection()) {\n\t\t\t\t\tslideavg = 'y';\n\t\t\t\t\tinterval = (Integer.valueOf(spinner.getText())).intValue();\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(23, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (sessionNum == 1) {\n\t\t\t\t\t\tworkspace.addSubject(subjectName, newFile, condFile,\n\t\t\t\t\t\t\t\tfreq, hpf, lpf, slideavg, interval);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tworkspace.concatSession(subjectName, newFile, condFile,\n\t\t\t\t\t\t\t\tfreq, hpf, lpf, slideavg, interval);\n\t\t\t\t\t}\n\t\t\t\t} catch (InputMismatchException ime) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\time.printStackTrace();\n\t\t\t\t\tworkspace.removeSubject(subjectName);\n\t\t\t\t\tinfoBox(\"Error\", \"Conditions file must be a text file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsessionNum++;\n\t\t\t\tsplash.setProgress(45, \"Deep frying grey matter...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (sessionNum > Integer.valueOf(num_sessions.getText())\n\t\t\t\t\t\t.intValue()) {\n\t\t\t\t\tlist.add(subjectName);\n\t\t\t\t\tfor (Control item : loadItems) {\n\t\t\t\t\t\titem.setVisible(false);\n\t\t\t\t\t}\n\t\t\t\t\ttext_subName.setEnabled(true);\n\t\t\t\t\tnum_sessions.setEnabled(true);\n\t\t\t\t\tbtnEnter_1.setEnabled(true);\n\t\t\t\t\ttext_subName.setText(\"\");\n\t\t\t\t\tnum_sessions.setSelection(1);\n\t\t\t\t} else {\n\t\t\t\t\tlblOf.setText(\"Session: \" + sessionNum + \" of \"\n\t\t\t\t\t\t\t+ num_sessions.getText());\n\t\t\t\t}\n\t\t\t\ttext.setText(\"\");\n\t\t\t\ttext_6.setText(\"\");\n\t\t\t\tsplash.setProgress(100, \"Brains have been preprocessed!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tbtnEnter.setText(\"Add\");\n\t\tloadItems.add(btnEnter);\n\t\ttext_subName = new Text(composite_3, SWT.BORDER);\n\t\ttext_subName\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_subName\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_subName.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_subName.setBounds(147, 32, 213, 25);\n\t\tButton btnBrowse = new Button(composite_3, SWT.NONE);\n\t\tbtnBrowse.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnBrowse.setBounds(580, 128, 108, 28);\n\t\tbtnBrowse.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse.setText(\"Browse...\");\n\t\tloadItems.add(btnBrowse);\n\t\tLabel lblSubjectName = new Label(composite_3, SWT.NONE);\n\t\tlblSubjectName.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectName.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectName.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSubjectName.setBounds(30, 32, 104, 25);\n\t\tlblSubjectName.setText(\"Subject Name:\");\n\t\ttext = new Text(composite_3, SWT.BORDER);\n\t\ttext.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext.setBounds(150, 130, 424, 25);\n\t\tloadItems.add(text);\n\t\tLabel lblDataFile = new Label(composite_3, SWT.NONE);\n\t\tlblDataFile.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblDataFile.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblDataFile.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblDataFile.setBounds(30, 130, 67, 25);\n\t\tlblDataFile.setText(\"Data File:\");\n\t\tloadItems.add(lblDataFile);\n\t\ttext_1 = new Text(composite_3, SWT.BORDER);\n\t\ttext_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_1.setText(\"2\");\n\t\ttext_1.setBounds(285, 242, 50, 25);\n\t\tloadItems.add(text_1);\n\t\tLabel lblNewLabel = new Label(composite_3, SWT.NONE);\n\t\tlblNewLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNewLabel.setBounds(85, 242, 164, 25);\n\t\tlblNewLabel.setText(\"Sampling Frequency:\");\n\t\tloadItems.add(lblNewLabel);\n\t\tLabel lblHz = new Label(composite_3, SWT.NONE);\n\t\tlblHz.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHz.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHz.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHz.setBounds(340, 244, 29, 25);\n\t\tlblHz.setText(\"Hz\");\n\t\tloadItems.add(lblHz);\n\t\tLabel lblHighPassFilter = new Label(composite_3, SWT.NONE);\n\t\tlblHighPassFilter.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblHighPassFilter.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblHighPassFilter.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblHighPassFilter.setBounds(85, 282, 196, 25);\n\t\tlblHighPassFilter.setText(\"High Pass Filter Frequency:\");\n\t\tloadItems.add(lblHighPassFilter);\n\t\ttext_2 = new Text(composite_3, SWT.BORDER);\n\t\ttext_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_2.setText(\".1\");\n\t\ttext_2.setBounds(285, 282, 50, 25);\n\t\tloadItems.add(text_2);\n\t\tLabel label = new Label(composite_3, SWT.NONE);\n\t\tlabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel.setText(\"Hz\");\n\t\tlabel.setBounds(340, 284, 29, 25);\n\t\tloadItems.add(label);\n\t\tLabel lblLowPassFilter = new Label(composite_3, SWT.NONE);\n\t\tlblLowPassFilter.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblLowPassFilter.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblLowPassFilter.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblLowPassFilter.setBounds(85, 322, 196, 25);\n\t\tlblLowPassFilter.setText(\"Low Pass Filter Frequency:\");\n\t\tloadItems.add(lblLowPassFilter);\n\t\ttext_3 = new Text(composite_3, SWT.BORDER);\n\t\ttext_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_3.setText(\".01\");\n\t\ttext_3.setBounds(285, 322, 50, 25);\n\t\tloadItems.add(text_3);\n\t\tLabel label_1 = new Label(composite_3, SWT.NONE);\n\t\tlabel_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_1.setText(\"Hz\");\n\t\tlabel_1.setBounds(340, 324, 29, 25);\n\t\tloadItems.add(label_1);\n\t\tLabel lblPreprocessingOptions = new Label(composite_3, SWT.NONE);\n\t\tlblPreprocessingOptions.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblPreprocessingOptions.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblPreprocessingOptions.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.BOLD));\n\t\tlblPreprocessingOptions.setBounds(30, 90, 189, 25);\n\t\tlblPreprocessingOptions.setText(\"Preprocessing Options:\");\n\t\tloadItems.add(lblPreprocessingOptions);\n\t\tLabel lblConditionsFile = new Label(composite_3, SWT.NONE);\n\t\tlblConditionsFile.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblConditionsFile.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblConditionsFile.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblConditionsFile.setBounds(30, 180, 116, 25);\n\t\tlblConditionsFile.setText(\"Conditions File:\");\n\t\tloadItems.add(lblConditionsFile);\n\t\ttext_6 = new Text(composite_3, SWT.BORDER);\n\t\ttext_6.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_6.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_6.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_6.setBounds(150, 180, 424, 25);\n\t\tloadItems.add(text_6);\n\t\tButton btnBrowse_3 = new Button(composite_3, SWT.NONE);\n\t\tbtnBrowse_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnBrowse_3.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_6);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse_3.setText(\"Browse...\");\n\t\tbtnBrowse_3.setBounds(580, 178, 108, 29);\n\t\tloadItems.add(btnBrowse_3);\n\t\tLabel lblNumberOfSessions = new Label(composite_3, SWT.NONE);\n\t\tlblNumberOfSessions.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNumberOfSessions.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNumberOfSessions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNumberOfSessions.setBounds(451, 32, 67, 25);\n\t\tlblNumberOfSessions.setText(\"Sessions:\");\n\t\tfinal Button button_3 = new Button(composite_3, SWT.NONE);\n\t\tbutton_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbutton_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbutton_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbutton_3.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tworkspace.removeSubject(subjectName);\n\t\t\t\tfor (Control item : loadItems) {\n\t\t\t\t\titem.setVisible(false);\n\t\t\t\t}\n\t\t\t\ttext_subName.setEnabled(true);\n\t\t\t\tnum_sessions.setEnabled(true);\n\t\t\t\tbtnEnter_1.setEnabled(true);\n\t\t\t\ttext_subName.setText(\"\");\n\t\t\t\tnum_sessions.setSelection(1);\n\t\t\t\tsubjectName = \"\";\n\t\t\t}\n\t\t});\n\t\tbutton_3.setText(\"Cancel\");\n\t\tbutton_3.setBounds(586, 381, 100, 28);\n\t\tloadItems.add(button_3);\n\t\tLabel lblSlidingAverage = new Label(composite_3, SWT.NONE);\n\t\tlblSlidingAverage.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSlidingAverage.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSlidingAverage.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSlidingAverage.setBounds(450, 242, 121, 25);\n\t\tlblSlidingAverage.setText(\"Sliding Average:\");\n\t\tloadItems.add(lblSlidingAverage);\n\t\tfor (Control item : loadItems) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\tfinal Composite composite_4 = new Composite(tabFolder_1, SWT.NONE);\n\t\tcomposite_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tcomposite_4.setBounds(10, 96, 694, 254);\n\t\tcomposite_4.setVisible(false);\n\t\tfinal ArrayList<Control> loadHatachi = new ArrayList<Control>();\n\t\ttext_4 = new Text(composite_4, SWT.BORDER);\n\t\ttext_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_4.setBounds(146, 200, 396, 25);\n\t\tloadHatachi.add(text_4);\n\t\ttext_5 = new Text(composite_4, SWT.BORDER);\n\t\ttext_5.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_5.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_5.setBounds(146, 250, 396, 25);\n\t\tloadHatachi.add(text_5);\n\t\tfinal Button btnNewButton = new Button(composite_4, SWT.NONE);\n\t\tbtnNewButton\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnNewButton\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnNewButton.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnNewButton.setBounds(548, 198, 143, 28);\n\t\tbtnNewButton.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_4);\n\t\t\t}\n\t\t});\n\t\tbtnNewButton.setText(\"Browse...\");\n\t\tloadHatachi.add(btnNewButton);\n\t\tfinal Button btnBrowse_1 = new Button(composite_4, SWT.NONE);\n\t\tbtnBrowse_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnBrowse_1.setBounds(548, 248, 143, 28);\n\t\tbtnBrowse_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_5);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse_1.setText(\"Browse...\");\n\t\tloadHatachi.add(btnBrowse_1);\n\t\tfinal Label lblHboFile = new Label(composite_4, SWT.NONE);\n\t\tlblHboFile.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHboFile.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHboFile.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblHboFile.setBounds(30, 250, 84, 25);\n\t\tlblHboFile.setText(\"HbO File:\");\n\t\tloadHatachi.add(lblHboFile);\n\t\tfinal Label lblHbFile = new Label(composite_4, SWT.NONE);\n\t\tlblHbFile.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHbFile.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHbFile.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHbFile.setBounds(30, 200, 84, 25);\n\t\tlblHbFile.setText(\"Hb File:\");\n\t\tloadHatachi.add(lblHbFile);\n\t\tButton btnAdd = new Button(composite_4, SWT.NONE);\n\t\tbtnAdd.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnAdd.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnAdd.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnAdd.setBounds(485, 380, 100, 25);\n\t\tbtnAdd.setText(\"Add\");\n\t\tloadHatachi.add(btnAdd);\n\t\tCTabItem tbtmStats = new CTabItem(tabFolder, SWT.BORDER | SWT.FLAT);\n\t\ttbtmStats.setFont(SWTResourceManager.getFont(\"Segoe UI\", 13, SWT.BOLD));\n\t\ttbtmStats.setText(\" Statistical Analysis \");\n\t\tComposite composite_1 = new Composite(tabFolder, SWT.NONE);\n\t\tcomposite_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttbtmStats.setControl(composite_1);\n\t\tLabel lblChannelGrouping = new Label(composite_1, SWT.NONE);\n\t\tlblChannelGrouping.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblChannelGrouping.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblChannelGrouping.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblChannelGrouping.setBounds(30, 69, 137, 25);\n\t\tlblChannelGrouping.setText(\"Channel Grouping:\");\n\t\tgroupFileBox = new Text(composite_1, SWT.BORDER);\n\t\tgroupFileBox\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tgroupFileBox\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tgroupFileBox.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tgroupFileBox.setBounds(172, 69, 432, 25);\n\t\tButton btnNewButton_2 = new Button(composite_1, SWT.NONE);\n\t\tbtnNewButton_2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnNewButton_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnNewButton_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(groupFileBox);\n\t\t\t}\n\t\t});\n\t\tbtnNewButton_2.setBounds(610, 67, 100, 28);\n\t\tbtnNewButton_2.setText(\"Browse...\");\n\t\tfinal Button HbCheck = new Button(composite_1, SWT.CHECK);\n\t\tHbCheck.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tHbCheck.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tHbCheck.setBounds(173, 100, 18, 25);\n\t\tHbCheck.setText(\"Hb\");\n\t\tfinal Button HbOCheck = new Button(composite_1, SWT.CHECK);\n\t\tHbOCheck.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tHbOCheck.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tHbOCheck.setBounds(236, 100, 18, 25);\n\t\tHbOCheck.setText(\"HbO\");\n\t\tfinal List groupsList = new List(composite_1, SWT.BORDER | SWT.MULTI\n\t\t\t\t| SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tgroupsList.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tgroupsList.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tgroupsList.setBounds(30, 229, 180, 237);\n\t\tgroupsList.setVisible(false);\n\t\tfinal List conditionsList = new List(composite_1, SWT.BORDER\n\t\t\t\t| SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tconditionsList.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tconditionsList.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tconditionsList.setBounds(224, 229, 116, 237);\n\t\tconditionsList.setVisible(false);\n\t\tfinal Label grouplbl = new Label(composite_1, SWT.NONE);\n\t\tgrouplbl.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tgrouplbl.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tgrouplbl.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tgrouplbl.setBounds(30, 198, 66, 25);\n\t\tgrouplbl.setText(\"Groups:\");\n\t\tgrouplbl.setVisible(false);\n\t\tfinal Label condlbl = new Label(composite_1, SWT.NONE);\n\t\tcondlbl.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tcondlbl.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcondlbl.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tcondlbl.setBounds(224, 198, 116, 25);\n\t\tcondlbl.setText(\"Conditions:\");\n\t\tcondlbl.setVisible(false);\n\t\tfinal Label chunking = new Label(composite_1, SWT.NONE);\n\t\tchunking.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tchunking.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tchunking.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tchunking.setBounds(390, 198, 86, 25);\n\t\tchunking.setText(\"Chunking:\");\n\t\tchunking.setVisible(false);\n\t\tfinal Label lblOutputDir = new Label(composite_1, SWT.NONE);\n\t\tlblOutputDir\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblOutputDir\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblOutputDir.setText(\"Output Directory Name:\"); \n\t\tlblOutputDir.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblOutputDir.setBounds(390, 357, 180, 25);\n\t\tlblOutputDir.setVisible(false);\n\t\tnumChunksBox = new Text(composite_1, SWT.BORDER);\n\t\tnumChunksBox\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tnumChunksBox\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tnumChunksBox.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnumChunksBox.setBounds(390, 230, 55, 25);\n\t\tnumChunksBox.setVisible(false);\n\t\tfinal Label chunks = new Label(composite_1, SWT.NONE);\n\t\tchunks.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tchunks.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tchunks.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tchunks.setBounds(451, 229, 86, 25);\n\t\tchunks.setText(\"chunks\");\n\t\tchunks.setVisible(false);\n\t\tfinal Label aprecision = new Label(composite_1, SWT.NONE);\n\t\taprecision.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\taprecision.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\taprecision.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\taprecision.setBounds(390, 277, 148, 25);\n\t\taprecision.setText(\"ANOVA Precision:\");\n\t\taprecision.setVisible(false);\n\t\tdecimalPlacesBox = new Text(composite_1, SWT.BORDER);\n\t\tdecimalPlacesBox.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tdecimalPlacesBox.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tdecimalPlacesBox.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tdecimalPlacesBox.setBounds(390, 308, 55, 25);\n\t\tdecimalPlacesBox.setVisible(false);\n\t\tfinal Label dplace = new Label(composite_1, SWT.NONE);\n\t\tdplace.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tdplace.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tdplace.setText(\"decimal places\");\n\t\tdplace.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tdplace.setBounds(454, 308, 116, 25);\n\t\tdplace.setVisible(false);\n\t\tfinal Button anovabtn = new Button(composite_1, SWT.NONE);\n\t\tanovabtn.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tanovabtn.setVisible(false);\n\t\tanovabtn.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString[] groupsAry = groupsList.getSelection();\n\t\t\t\tArrayList<String> groupsAryLst = new ArrayList<String>(Arrays\n\t\t\t\t\t\t.asList(groupsAry));\n\t\t\t\tif (groupsAryLst.isEmpty()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please select at least one channel grouping to analyze.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tString[] conditionsAry = conditionsList.getSelection();\n\t\t\t\tArrayList<Integer> conditionsAryLst = new ArrayList<Integer>();\n\t\t\t\tfor (String condition : conditionsAry) {\n\t\t\t\t\tconditionsAryLst.add(Integer.valueOf(condition));\n\t\t\t\t}\n\t\t\t\tif (conditionsAryLst.isEmpty()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please select at least one condition to analyze.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tString numChunksStr = numChunksBox.getText();\n\t\t\t\tif (numChunksStr.equals(\"\")) {\n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please enter a number of \\\"chunks\\\" to split the \"\n\t\t\t\t\t\t\t\t\t+ \"data into and average before calculating ANOVA p-values.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tint numChunks = Integer.parseInt(numChunksStr);\n\t\t\t\tString numPlacesStr = decimalPlacesBox.getText();\n\t\t\t\tif (numPlacesStr.equals(\"\")) {\n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please enter a number of decimal places to output \"\n\t\t\t\t\t\t\t\t\t+ \"for the p-values.\");\n\t\t\t\t\treturn; \n\t\t\t\t}\n\t\t\t\tint numPlaces = Integer.parseInt(numPlacesStr);\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tsplash.setProgress(0, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString outputDirectoryName = outputDirectoryBox.getText();\n\t\t\t\tString outputDirectoryPath = workspace.getStatsPath() + \"\\\\\"\n\t\t\t\t\t\t+ outputDirectoryName;\n\t\t\t\tFile statsOutputDirectory = new File(outputDirectoryPath);\n\t\t\t\tstatsOutputDirectory.mkdir(); \n\t\t\t\tsplash.setProgress(10, \"Running Hb ANOVA...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (doHb) {\n\t\t\t\t\tFile outputFileHb = new File(outputDirectoryPath + \"\\\\\"\n\t\t\t\t\t\t\t+ \"p-values_Hb.csv\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFNIRsStats.writeANOVAs(outputFileHb, StatsHb,\n\t\t\t\t\t\t\t\tgroupsAryLst, conditionsAryLst, numChunks,\n\t\t\t\t\t\t\t\tnumPlaces);\n\t\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\tex.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"Calculating p-values failed.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(55, \"Running HbO ANOVA...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (doHbO) {\n\t\t\t\t\tFile outputFileHbO = new File(outputDirectoryPath + \"\\\\\"\n\t\t\t\t\t\t\t+ \"p-values_HbO.csv\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFNIRsStats.writeANOVAs(outputFileHbO, StatsHbO,\n\t\t\t\t\t\t\t\tgroupsAryLst, conditionsAryLst, numChunks,\n\t\t\t\t\t\t\t\tnumPlaces);\n\t\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\tex.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"Calculating p-values failed.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(100, \"Zombie ANOVA done!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff(); \n\t\t\t\tSystem.out.println(\"Done writing ANOVAs!\");\n\t\t\t}\n\t\t});\n\t\tanovabtn.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tanovabtn.setBounds(390, 436, 155, 28);\n\t\tanovabtn.setText(\"Compute P-values\");\n\t\tfinal Button clearBtn = new Button(composite_1, SWT.NONE);\n\t\tclearBtn.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tclearBtn.setVisible(false);\n\t\tclearBtn.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tHbCheck.setSelection(false);\n\t\t\t\tHbOCheck.setSelection(false);\n\t\t\t\tgroupFileBox.setText(\"\");\n\t\t\t\tgrouplbl.setVisible(false);\n\t\t\t\tcondlbl.setVisible(false);\n\t\t\t\tgroupsList.setVisible(false);\n\t\t\t\tgroupsList.removeAll();\n\t\t\t\tconditionsList.setVisible(false);\n\t\t\t\tconditionsList.removeAll();\n\t\t\t\tchunking.setVisible(false);\n\t\t\t\taprecision.setVisible(false);\n\t\t\t\tdplace.setVisible(false);\n\t\t\t\tchunks.setVisible(false);\n\t\t\t\tnumChunksBox.setVisible(false);\n\t\t\t\tnumChunksBox.setText(\"\");\n\t\t\t\tdecimalPlacesBox.setVisible(false);\n\t\t\t\tdecimalPlacesBox.setText(\"\");\n\t\t\t\toutputDirectoryBox.setVisible(false);\n\t\t\t\toutputDirectoryBox.setText(\"\");\n\t\t\t\tanovabtn.setVisible(false);\n\t\t\t\tlblOutputDir.setVisible(false);\n\t\t\t\tclearBtn.setVisible(false);\n\t\t\t}\n\t\t});\n\t\tclearBtn.setBounds(551, 436, 155, 28);\n\t\tclearBtn.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tclearBtn.setText(\"Cancel\");\n\t\toutputDirectoryBox = new Text(composite_1, SWT.BORDER);\n\t\toutputDirectoryBox.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\toutputDirectoryBox.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\toutputDirectoryBox.setBounds(390, 388, 316, 25);\n\t\toutputDirectoryBox.setVisible(false);\n\t\tButton btnLoadGroupsAnd = new Button(composite_1, SWT.NONE);\n\t\tbtnLoadGroupsAnd.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnLoadGroupsAnd.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tArrayList<String> subjects = new ArrayList<String>();\n\t\t\t\tfor (String s : list.getSelection()) {\n\t\t\t\t\tsubjects.add(s);\n\t\t\t\t}\n\t\t\t\tif (subjects.isEmpty()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please select at least one subject to analyze.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString groupFilePath = groupFileBox.getText();\n\t\t\t\tFile groupingsFile = new File(groupFilePath);\n\t\t\t\tif (!groupingsFile.exists()) { \n\t\t\t\t\tinfoBox(\"Error\",\n\t\t\t\t\t\t\t\"Please specify a valid channel groupings file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdoHb = HbCheck.getSelection();\n\t\t\t\tdoHbO = HbOCheck.getSelection(); \n\t\t\t\tif (!doHb && !doHbO) { \n\t\t\t\t\tinfoBox(\"Error\", \"Please select Hb, HbO, or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (doHb) { \n\t\t\t\t\tArrayList<File> hbFiles = new ArrayList<File>();\n\t\t\t\t\tfor (String subject : subjects) {\n\t\t\t\t\t\tFile dataFile = workspace.getHb(subject);\n\t\t\t\t\t\tif (dataFile != null && dataFile.exists()) {\n\t\t\t\t\t\t\thbFiles.add(dataFile);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tinfoBox(\"Error\", \"Hb file for \" + subject\n\t\t\t\t\t\t\t\t\t+ \" does not exist.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tStatsHb = FNIRsStats.processAllSubjectData(hbFiles,\n\t\t\t\t\t\t\tgroupingsFile);\n\t\t\t\t}\n\t\t\t\tif (doHbO) { \n\t\t\t\t\tArrayList<File> hbOFiles = new ArrayList<File>();\n\t\t\t\t\tfor (String subject : subjects) {\n\t\t\t\t\t\tFile dataFile = workspace.getHbO(subject);\n\t\t\t\t\t\tif (dataFile != null && dataFile.exists()) {\n\t\t\t\t\t\t\thbOFiles.add(dataFile);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tinfoBox(\"Error\", \"HbO file for \" + subject\n\t\t\t\t\t\t\t\t\t+ \" does not exist.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tStatsHbO = FNIRsStats.processAllSubjectData(hbOFiles,\n\t\t\t\t\t\t\tgroupingsFile);\n\t\t\t\t}\n\t\t\t\tFNIRsStats.GroupedChannels temp = null;\n\t\t\t\tif (doHb) {\n\t\t\t\t\ttemp = StatsHb;\n\t\t\t\t} else {\n\t\t\t\t\ttemp = StatsHbO;\n\t\t\t\t}\n\t\t\t\tif (temp.channelsMissing()) {\n\t\t\t\t\tinfoBox(\"Warning\", temp.getMissingChannelsMsg());\n\t\t\t\t}\n\t\t\t\tif (temp.channelsDuplicated()) {\n\t\t\t\t\tinfoBox(\"Warning!\", temp.getDuplicatedChannelsMsg());\n\t\t\t\t}\n\t\t\t\tgroupsList.removeAll();\n\t\t\t\tconditionsList.removeAll();\n\t\t\t\tFNIRsStats.GroupedChannels statsData = null;\n\t\t\t\tif (doHb) { \n\t\t\t\t\tstatsData = StatsHb; \n\t\t\t\t} else { \n\t\t\t\t\tstatsData = StatsHbO; \n\t\t\t\t}\n\t\t\t\tfor (String groupName : statsData.getGroupNames()) {\n\t\t\t\t\tgroupsList.add(groupName);\n\t\t\t\t}\n\t\t\t\tfor (Integer condition : statsData.getConditions()) {\n\t\t\t\t\tconditionsList.add(condition.toString());\n\t\t\t\t}\n\t\t\t\tgrouplbl.setVisible(true);\n\t\t\t\tcondlbl.setVisible(true);\n\t\t\t\tgroupsList.setVisible(true);\n\t\t\t\tconditionsList.setVisible(true);\n\t\t\t\tchunking.setVisible(true);\n\t\t\t\taprecision.setVisible(true);\n\t\t\t\tdplace.setVisible(true);\n\t\t\t\tchunks.setVisible(true);\n\t\t\t\tnumChunksBox.setVisible(true);\n\t\t\t\tdecimalPlacesBox.setVisible(true);\n\t\t\t\toutputDirectoryBox.setVisible(true);\n\t\t\t\tanovabtn.setVisible(true);\n\t\t\t\tlblOutputDir.setVisible(true);\n\t\t\t\tclearBtn.setVisible(true);\n\t\t\t}\n\t\t});\n\t\tbtnLoadGroupsAnd.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnLoadGroupsAnd.setBounds(246, 139, 276, 28);\n\t\tbtnLoadGroupsAnd.setText(\"Load Groups and Conditions\");\n\t\tLabel lblPleaseSelect = new Label(composite_1, SWT.NONE);\n\t\tlblPleaseSelect.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblPleaseSelect.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblPleaseSelect.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.BOLD | SWT.ITALIC));\n\t\tlblPleaseSelect.setBounds(30, 25, 394, 25);\n\t\tlblPleaseSelect\n\t\t\t\t.setText(\"Please select subject(s) from the Subject List to begin\");\n\t\tLabel lblHb_1 = new Label(composite_1, SWT.NONE);\n\t\tlblHb_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHb_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblHb_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHb_1.setBounds(193, 101, 40, 25);\n\t\tlblHb_1.setText(\"Hb\");\n\t\tLabel label_4 = new Label(composite_1, SWT.NONE);\n\t\tlabel_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_4.setText(\"HbO\");\n\t\tlabel_4.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_4.setBounds(256, 101, 55, 28);\n\t\tCTabItem tbtmMachineLearning = new CTabItem(tabFolder, SWT.BORDER\n\t\t\t\t| SWT.FLAT);\n\t\ttbtmMachineLearning.setFont(SWTResourceManager.getFont(\"Segoe UI\", 14,\n\t\t\t\tSWT.BOLD));\n\t\ttbtmMachineLearning.setText(\" Data Mining \");\n\t\tComposite composite_2 = new Composite(tabFolder, SWT.NONE);\n\t\tcomposite_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcomposite_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttbtmMachineLearning.setControl(composite_2);\n\t\tfinal Spinner spinner_avgseg = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_avgseg.setMinimum(1);\n\t\tspinner_avgseg.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_avgseg.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tspinner_avgseg.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_avgseg.setBounds(656, 148, 55, 25);\n\t\tfinal Spinner spinner_seqlen1 = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_seqlen1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_seqlen1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_seqlen1.setMinimum(1);\n\t\tspinner_seqlen1.setEnabled(false);\n\t\tspinner_seqlen1.setBounds(656, 213, 55, 25);\n\t\tfinal Spinner spinner_fbs = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_fbs.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_fbs.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tspinner_fbs.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tspinner_fbs.setMinimum(1);\n\t\tspinner_fbs.setEnabled(false);\n\t\tspinner_fbs.setBounds(656, 308, 55, 25);\n\t\tfinal Spinner spinner_alphsize = new Spinner(composite_2, SWT.BORDER);\n\t\tspinner_alphsize.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_alphsize.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tspinner_alphsize.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_alphsize.setMinimum(1);\n\t\tspinner_alphsize.setEnabled(false);\n\t\tspinner_alphsize.setBounds(656, 243, 55, 25);\n\t\tfinal Button radioAS = new Button(composite_2, SWT.RADIO);\n\t\tradioAS.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tradioAS.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tradioAS.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tspinner_avgseg.setEnabled(true);\n\t\t\t\tspinner_seqlen1.setEnabled(false);\n\t\t\t\tspinner_alphsize.setEnabled(false);\n\t\t\t\tspinner_fbs.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tradioAS.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tradioAS.setSelection(true);\n\t\tradioAS.setBounds(435, 118, 18, 25);\n\t\tradioAS.setText(\"Averaged Segments\");\n\t\tfinal Button radioSAX = new Button(composite_2, SWT.RADIO);\n\t\tradioSAX.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tradioSAX.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tradioSAX.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tspinner_avgseg.setEnabled(false);\n\t\t\t\tspinner_seqlen1.setEnabled(true);\n\t\t\t\tspinner_alphsize.setEnabled(true);\n\t\t\t\tspinner_fbs.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tradioSAX.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tradioSAX.setBounds(435, 183, 18, 25);\n\t\tradioSAX.setText(\"SAX Segments\");\n\t\tButton radioFBS = new Button(composite_2, SWT.RADIO);\n\t\tradioFBS.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tradioFBS.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tradioFBS.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tspinner_avgseg.setEnabled(false);\n\t\t\t\tspinner_seqlen1.setEnabled(false);\n\t\t\t\tspinner_alphsize.setEnabled(false);\n\t\t\t\tspinner_fbs.setEnabled(true);\n\t\t\t}\n\t\t});\n\t\tradioFBS.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tradioFBS.setBounds(435, 278, 18, 25);\n\t\tradioFBS.setText(\"Feature-based Segments\");\n\t\tfinal ArrayList<Control> step2 = new ArrayList<Control>();\n\t\tfinal List list_1 = new List(composite_2, SWT.BORDER | SWT.MULTI\n\t\t\t\t| SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tlist_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlist_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlist_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlist_1.setBounds(30, 118, 117, 339);\n\t\tstep2.add(list_1);\n\t\ttext_dmoutput = new Text(composite_2, SWT.BORDER);\n\t\ttext_dmoutput.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_dmoutput.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_dmoutput.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_dmoutput.setBounds(432, 378, 279, 25);\n\t\tLabel lbldmoutput = new Label(composite_2, SWT.NONE);\n\t\tlbldmoutput.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlbldmoutput.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlbldmoutput.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbldmoutput.setBounds(432, 348, 161, 25);\n\t\tlbldmoutput.setText(\"Output File Name:\");\n\t\tfinal ArrayList<Integer> cond_list = new ArrayList<Integer>();\n\t\tfinal ArrayList<Control> step1 = new ArrayList<Control>();\n\t\tfinal Button btnHb_1 = new Button(composite_2, SWT.CHECK);\n\t\tbtnHb_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnHb_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnHb_1.setBounds(431, 32, 18, 25);\n\t\tbtnHb_1.setText(\"Hb\");\n\t\tstep1.add(btnHb_1);\n\t\tfinal Button btnHbO_1 = new Button(composite_2, SWT.CHECK);\n\t\tbtnHbO_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnHbO_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnHbO_1.setText(\"HbO\");\n\t\tbtnHbO_1.setBounds(494, 32, 18, 25);\n\t\tstep1.add(btnHbO_1);\n\t\ttext_dm_sub = new Text(composite_2, SWT.BORDER);\n\t\ttext_dm_sub.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_dm_sub.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_dm_sub.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_dm_sub.setBounds(143, 32, 255, 25);\n\t\tstep1.add(text_dm_sub);\n\t\tlist.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (text_dm_sub.getEnabled()) {\n\t\t\t\t\tString[] dmSubjects = list.getSelection();\n\t\t\t\t\tif (dmSubjects.length > 0) {\n\t\t\t\t\t\tString dmSubject = dmSubjects[dmSubjects.length - 1];\n\t\t\t\t\t\ttext_dm_sub.setText(dmSubject);\n\t\t\t\t\t\ttext_dmoutput.setText(dmSubject);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfinal List list_2 = new List(composite_2, SWT.BORDER | SWT.V_SCROLL\n\t\t\t\t| SWT.H_SCROLL);\n\t\tlist_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlist_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlist_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlist_2.setBounds(175, 118, 224, 339);\n\t\tfor (String template : workspace.getTemplates()) {\n\t\t\tlist_2.add(template);\n\t\t}\n\t\tlist_2.setSelection(0);\n\t\tButton btnRun = new Button(composite_2, SWT.NONE);\n\t\tbtnRun.setEnabled(false);\n\t\tbtnRun.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnRun.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnRun.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif ((list_1.getSelectionIndices()).length < 2) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Select at least 2 conditions.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tif ((list_2.getSelectionIndices()).length < 1) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Select a process.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(5, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcond_list.clear();\n\t\t\t\tfor (Integer item : list_1.getSelectionIndices())\n\t\t\t\t\tcond_list.add(item);\n\t\t\t\tdisableList(step2);\n\t\t\t\tsplash.setProgress(10, \"Locating brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString name = text_dm_sub.getText();\n\t\t\t\tFile hbOutput = workspace.getHbOutput(name);\n\t\t\t\tFile hboOutput = workspace.getHbOOutput(name);\n\t\t\t\tif (hbOutput.exists())\n\t\t\t\t\thbOutput.delete();\n\t\t\t\tif (hboOutput.exists())\n\t\t\t\t\thboOutput.delete();\n\t\t\t\tif (btnHb_1.getSelection()) {\n\t\t\t\t\trapidDriver.filter(cond_list, workspace.getHb(name),\n\t\t\t\t\t\t\thbOutput);\n\t\t\t\t} else {\n\t\t\t\t\trapidDriver.empty(hbOutput);\n\t\t\t\t}\n\t\t\t\tif (btnHbO_1.getSelection()) {\n\t\t\t\t\trapidDriver.filter(cond_list, workspace.getHbO(name),\n\t\t\t\t\t\t\thboOutput);\n\t\t\t\t} else {\n\t\t\t\t\trapidDriver.empty(hboOutput);\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(25, \"Mining brain data...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tFile rminput = workspace.getRMInput(name);\n\t\t\t\t\tif (rminput.exists())\n\t\t\t\t\t\trminput.delete();\n\t\t\t\t\tif (radioAS.getSelection()) {\n\t\t\t\t\t\tint num_segs;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tnum_segs = (Integer.valueOf(spinner_avgseg\n\t\t\t\t\t\t\t\t\t.getText())).intValue();\n\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\tnfe.printStackTrace();\n\t\t\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\t\t\"Number of segments requires an integer.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdm.rapidFormatConversion(hbOutput.getAbsolutePath(),\n\t\t\t\t\t\t\t\thboOutput.getAbsolutePath(), workspace\n\t\t\t\t\t\t\t\t\t\t.getRMInput(name).getAbsolutePath(),\n\t\t\t\t\t\t\t\tnum_segs);\n\t\t\t\t\t} else if (radioSAX.getSelection()) {\n\t\t\t\t\t\tint seq_len;\n\t\t\t\t\t\tint alph_size;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tseq_len = (Integer.valueOf(spinner_seqlen1\n\t\t\t\t\t\t\t\t\t.getText())).intValue();\n\t\t\t\t\t\t\talph_size = (Integer.valueOf(spinner_alphsize\n\t\t\t\t\t\t\t\t\t.getText())).intValue();\n\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\tnfe.printStackTrace();\n\t\t\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\t\t\"Sequence length and Alphabet Size require integers.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdm.SAX_RapidFormatConversion(\n\t\t\t\t\t\t\t\thbOutput.getAbsolutePath(), hboOutput\n\t\t\t\t\t\t\t\t\t\t.getAbsolutePath(), workspace\n\t\t\t\t\t\t\t\t\t\t.getRMInput(name).getAbsolutePath(),\n\t\t\t\t\t\t\t\tseq_len, alph_size);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tint num_segs;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tnum_segs = (Integer.valueOf(spinner_fbs.getText()))\n\t\t\t\t\t\t\t\t\t.intValue();\n\t\t\t\t\t\t} catch (NumberFormatException nfe) {\n\t\t\t\t\t\t\tnfe.printStackTrace();\n\t\t\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\t\t\"Number of Segments requires an integer.\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdm.features_rapidFormatConversion(hbOutput\n\t\t\t\t\t\t\t\t.getAbsolutePath(),\n\t\t\t\t\t\t\t\thboOutput.getAbsolutePath(), workspace\n\t\t\t\t\t\t\t\t\t\t.getRMInput(name).getAbsolutePath(),\n\t\t\t\t\t\t\t\tnum_segs);\n\t\t\t\t\t}\n\t\t\t\t} catch (MWException mwe) {\n\t\t\t\t\tmwe.printStackTrace();\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\tenableList(step1);\n\t\t\t\t\tlist_1.removeAll();\n\t\t\t\t\tinfoBox(\"Error\", \"Data Mining Failed.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(80, \"Processing brain data...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tFile inputFile = workspace.getRMInput(name);\n\t\t\t\t\tFile outputFile = new File(workspace.getDMPath() + \"\\\\\"\n\t\t\t\t\t\t\t+ text_dmoutput.getText() + \".xls\");\n\t\t\t\t\tif (outputFile.exists()) {\n\t\t\t\t\t\toutputFile.delete();\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\trapidDriver.run(inputFile,\n\t\t\t\t\t\t\t\trapidDriver.generateProcess(inputFile,\n\t\t\t\t\t\t\t\t\t\tworkspace.getTemplate(list_2\n\t\t\t\t\t\t\t\t\t\t\t\t.getSelection()[0])),\n\t\t\t\t\t\t\t\toutputFile);\n\t\t\t\t\t} catch (IOException e1) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"Run failed.\");\n\t\t\t\t\t\tenableList(step1);\n\t\t\t\t\t\tlist_1.removeAll();\n\t\t\t\t\t}\n\t\t\t\t} catch (OperatorException e1) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\tinfoBox(\"Error\", \"Run failed.\");\n\t\t\t\t\tenableList(step1);\n\t\t\t\t\tlist_1.removeAll();\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(95, \"Gathering brain bits...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tenableList(step1);\n\t\t\t\tlist_1.removeAll();\n\t\t\t\tsplash.setProgress(100, \"Brain data successfully mined...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tbtnRun.setBounds(432, 429, 135, 28);\n\t\tbtnRun.setText(\"Run\");\n\t\tstep2.add(btnRun);\n\t\tButton btnNext = new Button(composite_2, SWT.NONE);\n\t\tbtnNext.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnNext.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnNext.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString subjectName = text_dm_sub.getText();\n\t\t\t\tif (subjectName == \"\"\n\t\t\t\t\t\t|| !Arrays.asList(list.getItems())\n\t\t\t\t\t\t\t\t.contains(subjectName)) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Subject \" + subjectName\n\t\t\t\t\t\t\t+ \" does not exist.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!btnHb_1.getSelection() && !btnHbO_1.getSelection()) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Select Hb or HbO or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (btnHb_1.getSelection()\n\t\t\t\t\t\t&& workspace.getHb(subjectName) == null) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Subject \" + subjectName\n\t\t\t\t\t\t\t+ \" does not have an Hb file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (btnHbO_1.getSelection()\n\t\t\t\t\t\t&& workspace.getHbO(subjectName) == null) {\n\t\t\t\t\tinfoBox(\"Warning!\", \"Subject \" + subjectName\n\t\t\t\t\t\t\t+ \" does not have an HbO file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdisableList(step1);\n\t\t\t\tenableList(step2);\n\t\t\t\tint n = workspace.getMaxCond(text_dm_sub.getText());\n\t\t\t\tfor (int i = 0; i <= n; i++) {\n\t\t\t\t\tString strI = \"\" + i;\n\t\t\t\t\tlist_1.add(strI);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbtnNext.setBounds(575, 30, 136, 28);\n\t\tbtnNext.setText(\"Fill Conditions\");\n\t\tstep1.add(btnNext);\n\t\tLabel lblSubjectName_1 = new Label(composite_2, SWT.NONE);\n\t\tlblSubjectName_1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectName_1.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectName_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSubjectName_1.setBounds(30, 32, 106, 25);\n\t\tlblSubjectName_1.setText(\"Subject Name:\");\n\t\tLabel lblNewLabel_1 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_1.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNewLabel_1.setBounds(30, 88, 126, 25);\n\t\tlblNewLabel_1.setText(\"Conditions:\");\n\t\tLabel lblDataRepresentation = new Label(composite_2, SWT.NONE);\n\t\tlblDataRepresentation.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblDataRepresentation.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblDataRepresentation.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.NORMAL));\n\t\tlblDataRepresentation.setBounds(431, 88, 196, 25);\n\t\tlblDataRepresentation.setText(\"Data Representation:\");\n\t\tButton btnCancel_DM = new Button(composite_2, SWT.NONE);\n\t\tbtnCancel_DM.setEnabled(false);\n\t\tbtnCancel_DM\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnCancel_DM.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnCancel_DM.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tdisableList(step2);\n\t\t\t\tlist_1.removeAll();\n\t\t\t\tenableList(step1);\n\t\t\t}\n\t\t});\n\t\tbtnCancel_DM.setBounds(573, 429, 138, 28);\n\t\tbtnCancel_DM.setText(\"Cancel\");\n\t\tstep2.add(btnCancel_DM);\n\t\tLabel lblSelectProcess = new Label(composite_2, SWT.NONE);\n\t\tlblSelectProcess.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSelectProcess.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSelectProcess.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSelectProcess.setBounds(175, 88, 117, 25);\n\t\tlblSelectProcess.setText(\"Processes:\");\n\t\tLabel lblSegments = new Label(composite_2, SWT.NONE);\n\t\tlblSegments.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblSegments.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblSegments.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblSegments.setBounds(490, 148, 103, 25);\n\t\tlblSegments.setText(\"Segments:\");\n\t\tLabel lblNewLabel_2 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblNewLabel_2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_2.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_2.setText(\"Sequence Length:\");\n\t\tlblNewLabel_2.setBounds(491, 213, 143, 25);\n\t\tLabel lblNewLabel_3 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblNewLabel_3.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_3.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_3.setBounds(490, 308, 138, 25);\n\t\tlblNewLabel_3.setText(\"Segments:\");\n\t\tLabel lblNewLabel_5 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_5.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlblNewLabel_5.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_5.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_5.setBounds(491, 243, 102, 25);\n\t\tlblNewLabel_5.setText(\"Alphabet Size:\");\n\t\tLabel label_6 = new Label(composite_2, SWT.NONE);\n\t\tlabel_6.setText(\"Hb\");\n\t\tlabel_6.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_6.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_6.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_6.setBounds(451, 34, 40, 25);\n\t\tLabel label_7 = new Label(composite_2, SWT.NONE);\n\t\tlabel_7.setText(\"HbO\");\n\t\tlabel_7.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_7.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_7.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_7.setBounds(514, 34, 55, 28);\n\t\tLabel lblNewLabel_4 = new Label(composite_2, SWT.NONE);\n\t\tlblNewLabel_4.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNewLabel_4.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNewLabel_4.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNewLabel_4.setBounds(455, 118, 168, 25);\n\t\tlblNewLabel_4.setText(\"Averaged Segments\");\n\t\tLabel lblSaxSegments = new Label(composite_2, SWT.NONE);\n\t\tlblSaxSegments.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSaxSegments.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSaxSegments.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSaxSegments.setBounds(455, 183, 135, 25);\n\t\tlblSaxSegments.setText(\"SAX Segments:\");\n\t\tLabel lblFeaturebasedSements = new Label(composite_2, SWT.NONE);\n\t\tlblFeaturebasedSements.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblFeaturebasedSements.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblFeaturebasedSements.setFont(SWTResourceManager.getFont(\"Segoe UI\",\n\t\t\t\t12, SWT.NORMAL));\n\t\tlblFeaturebasedSements.setBounds(455, 278, 169, 25);\n\t\tlblFeaturebasedSements.setText(\"Feature-based Sements:\");\n\t\tfor (Control item : step2) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\tButton btnRemove = new Button(shlFnirsDataProcessing, SWT.FLAT);\n\t\tbtnRemove.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnRemove.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnRemove.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (list.getSelection().length == 0)\n\t\t\t\t\treturn;\n\t\t\t\tMessageBox warn = new MessageBox(shlFnirsDataProcessing,\n\t\t\t\t\t\tSWT.ICON_QUESTION | SWT.YES | SWT.NO);\n\t\t\t\twarn.setText(\"Warning!\");\n\t\t\t\twarn.setMessage(\"Are you sure you want to remove all data on the selected subjects?\");\n\t\t\t\tint result = warn.open();\n\t\t\t\tif (result != SWT.YES)\n\t\t\t\t\treturn;\n\t\t\t\tfor (String subject : list.getSelection()) {\n\t\t\t\t\tworkspace.removeSubject(subject);\n\t\t\t\t}\n\t\t\t\tfor (Integer item : list.getSelectionIndices())\n\t\t\t\t\tindexList.add(item);\n\t\t\t\tint[] indices = new int[indexList.size()];\n\t\t\t\tfor (int i = 0; i < indexList.size(); i++)\n\t\t\t\t\tindices[i] = indexList.get(i);\n\t\t\t\tlist.remove(indices);\n\t\t\t\tindexList.clear();\n\t\t\t}\n\t\t});\n\t\tbtnRemove.setBounds(10, 504, 226, 28);\n\t\tbtnRemove.setText(\"Remove Subject(s)\");\n\t\tLabel lblSubjectName2 = new Label(composite_4, SWT.NONE);\n\t\tlblSubjectName2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectName2.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectName2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSubjectName2.setBounds(30, 40, 105, 25);\n\t\tlblSubjectName2.setText(\"Subject Name:\");\n\t\ttext_subName2 = new Text(composite_4, SWT.BORDER);\n\t\ttext_subName2.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_subName2.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_subName2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_subName2.setBounds(146, 40, 396, 25);\n\t\tfinal Spinner num_channels_H = new Spinner(composite_4, SWT.BORDER);\n\t\tnum_channels_H.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tnum_channels_H.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tnum_channels_H.setSelection(52);\n\t\tnum_channels_H.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnum_channels_H.setBounds(283, 85, 47, 25);\n\t\tLabel lblNumberOfChannels = new Label(composite_4, SWT.NONE);\n\t\tlblNumberOfChannels.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblNumberOfChannels.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblNumberOfChannels.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblNumberOfChannels.setBounds(205, 85, 69, 25);\n\t\tlblNumberOfChannels.setText(\"Channels:\");\n\t\tfinal Spinner num_sessions_h = new Spinner(composite_4, SWT.BORDER);\n\t\tnum_sessions_h.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tnum_sessions_h.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tnum_sessions_h.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tnum_sessions_h.setMinimum(1);\n\t\tnum_sessions_h.setBounds(105, 85, 47, 25);\n\t\tfinal Label lblOf_H = new Label(composite_4, SWT.NONE);\n\t\tlblOf_H.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblOf_H.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblOf_H.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.ITALIC));\n\t\tlblOf_H.setText(\"Session: 1 of 1\");\n\t\tlblOf_H.setBounds(30, 380, 274, 20);\n\t\tloadHatachi.add(lblOf_H);\n\t\tfinal Button btnHb = new Button(composite_4, SWT.CHECK);\n\t\tbtnHb.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnHb.setBounds(390, 85, 14, 25);\n\t\tbtnHb.setText(\"Hb\");\n\t\tfinal Button btnHbo = new Button(composite_4, SWT.CHECK);\n\t\tbtnHbo.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnHbo.setBounds(453, 85, 14, 25);\n\t\tbtnHbo.setText(\"HbO\");\n\t\tfinal Button button_2 = new Button(composite_4, SWT.NONE);\n\t\tbutton_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbutton_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbutton_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbutton_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsubjectNameH = text_subName2.getText();\n\t\t\t\tif (subjectNameH == \"\"\n\t\t\t\t\t\t|| subjectNameH.matches(subjectName)\n\t\t\t\t\t\t|| Arrays.asList(list.getItems())\n\t\t\t\t\t\t\t\t.contains(subjectNameH)) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Please enter a new name.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!btnHb.getSelection() && !btnHbo.getSelection()) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Select Hb or HbO or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (Control item : loadHatachi) {\n\t\t\t\t\titem.setVisible(true);\n\t\t\t\t}\n\t\t\t\tif (!btnHb.getSelection()) {\n\t\t\t\t\ttext_4.setVisible(false);\n\t\t\t\t\tbtnNewButton.setVisible(false);\n\t\t\t\t\tlblHbFile.setVisible(false);\n\t\t\t\t}\n\t\t\t\tif (!btnHbo.getSelection()) {\n\t\t\t\t\ttext_5.setVisible(false);\n\t\t\t\t\tbtnBrowse_1.setVisible(false);\n\t\t\t\t\tlblHboFile.setVisible(false);\n\t\t\t\t}\n\t\t\t\tsessionNumH = 1;\n\t\t\t\tlblOf_H.setText(\"Session: 1 of \" + num_sessions_h.getText());\n\t\t\t\ttext_subName2.setEnabled(false);\n\t\t\t\tnum_sessions_h.setEnabled(false);\n\t\t\t\tbutton_2.setEnabled(false);\n\t\t\t\tnum_channels_H.setEnabled(false);\n\t\t\t\tbtnHb.setEnabled(false);\n\t\t\t\tbtnHbo.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tbutton_2.setText(\"Enter\");\n\t\tbutton_2.setBounds(548, 38, 143, 28);\n\t\tbtnAdd.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tFile condFile = new File(text_7.getText());\n\t\t\t\tif (!setExists(condFile)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tint channels = (Integer.valueOf(num_channels_H.getText()))\n\t\t\t\t\t\t.intValue();\n\t\t\t\tFile HbFile = new File(text_4.getText());\n\t\t\t\tFile HbOFile = new File(text_5.getText());\n\t\t\t\tif (!HbFile.exists() && !HbOFile.exists()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\tsplash.setProgress(0, \"Finding deoxygenated brains...\");\n\t\t\t\tif (HbFile.exists()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpre.xlsreadfile(HbFile.getAbsolutePath(), \"Hb\",\n\t\t\t\t\t\t\t\tchannels);\n\t\t\t\t\t\tHbFile = new File(\"Hb\");\n\t\t\t\t\t} catch (MWException e1) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"Hb File must be an excel csv file.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbFile = null;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(18, \"Finding oxygenated brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (HbOFile.exists()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpre.xlsreadfile(HbOFile.getAbsolutePath(), \"HbO\",\n\t\t\t\t\t\t\t\tchannels);\n\t\t\t\t\t\tHbOFile = new File(\"HbO\");\n\t\t\t\t\t} catch (MWException e1) {\n\t\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\t\tinfoBox(\"Error\", \"HbO File must be an excel csv file.\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbOFile = null;\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(36, \"Prepping brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(200);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (sessionNumH == 1) {\n\t\t\t\t\t\tworkspace.addSubject(subjectNameH, HbFile, HbOFile,\n\t\t\t\t\t\t\t\tcondFile);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tworkspace.concatSession(subjectNameH, HbFile, HbOFile,\n\t\t\t\t\t\t\t\tcondFile);\n\t\t\t\t\t}\n\t\t\t\t} catch (InputMismatchException ime) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\time.printStackTrace();\n\t\t\t\t\tworkspace.removeSubject(subjectNameH);\n\t\t\t\t\tinfoBox(\"Error\", \"Conditions file must be a text file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsessionNumH++;\n\t\t\t\tsplash.setProgress(40, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (sessionNumH > Integer.valueOf(num_sessions_h.getText())\n\t\t\t\t\t\t.intValue()) {\n\t\t\t\t\tlist.add(subjectNameH);\n\t\t\t\t\tfor (Control item : loadHatachi) {\n\t\t\t\t\t\titem.setVisible(false);\n\t\t\t\t\t}\n\t\t\t\t\ttext_subName2.setEnabled(true);\n\t\t\t\t\tnum_sessions_h.setEnabled(true);\n\t\t\t\t\tbutton_2.setEnabled(true);\n\t\t\t\t\tnum_channels_H.setEnabled(true);\n\t\t\t\t\tbtnHb.setEnabled(true);\n\t\t\t\t\tbtnHbo.setEnabled(true);\n\t\t\t\t\ttext_subName2.setText(\"\");\n\t\t\t\t\tnum_sessions_h.setSelection(1);\n\t\t\t\t} else {\n\t\t\t\t\tlblOf_H.setText(\"Session: \" + sessionNumH + \" of \"\n\t\t\t\t\t\t\t+ num_sessions_h.getText());\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(68, \"Offering Hitachi-san some brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttext_4.setText(\"\");\n\t\t\t\ttext_5.setText(\"\");\n\t\t\t\ttext_7.setText(\"\");\n\t\t\t\ttext_subName2.setText(\"\");\n\t\t\t\tsplash.setProgress(100, \"Hitachi likes brains!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tloadHatachi.add(btnAdd);\n\t\tCTabItem tbtmNewItem_2 = new CTabItem(tabFolder_1, SWT.BORDER\n\t\t\t\t| SWT.FLAT);\n\t\ttbtmNewItem_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 13,\n\t\t\t\tSWT.BOLD));\n\t\ttbtmNewItem_2.setText(\" Hitachi \");\n\t\ttbtmNewItem_2.setControl(composite_4);\n\t\tLabel label_3 = new Label(composite_4, SWT.NONE);\n\t\tlabel_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_3.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_3.setText(\"Conditions File:\");\n\t\tlabel_3.setBounds(30, 300, 111, 25);\n\t\tloadHatachi.add(label_3);\n\t\ttext_7 = new Text(composite_4, SWT.BORDER);\n\t\ttext_7.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_7.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_7.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\ttext_7.setBounds(146, 300, 396, 25);\n\t\tloadHatachi.add(text_7);\n\t\tCTabItem tabOther = new CTabItem(tabFolder_1, SWT.BORDER | SWT.FLAT);\n\t\ttabOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 13, SWT.BOLD));\n\t\ttabOther.setText(\" Other \");\n\t\tComposite composite_other = new Composite(tabFolder_1, SWT.NONE);\n\t\tcomposite_other.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tcomposite_other.setVisible(false);\n\t\tcomposite_other.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttabOther.setControl(composite_other);\n\t\tfinal ArrayList<Control> loadOther = new ArrayList<Control>();\n\t\ttext_hbother = new Text(composite_other, SWT.BORDER);\n\t\ttext_hbother\n\t\t\t\t.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\ttext_hbother\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\ttext_hbother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_hbother.setBounds(146, 200, 396, 25);\n\t\tloadOther.add(text_hbother);\n\t\ttext_hboother = new Text(composite_other, SWT.BORDER);\n\t\ttext_hboother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_hboother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_hboother.setBounds(146, 250, 396, 25);\n\t\tloadOther.add(text_hboother);\n\t\tfinal Button browse_hbother = new Button(composite_other, SWT.NONE);\n\t\tbrowse_hbother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbrowse_hbother.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_hbother);\n\t\t\t}\n\t\t});\n\t\tbrowse_hbother.setText(\"Browse...\");\n\t\tbrowse_hbother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbrowse_hbother.setBounds(548, 198, 127, 28);\n\t\tloadOther.add(browse_hbother);\n\t\tfinal Button browse_hboother = new Button(composite_other, SWT.NONE);\n\t\tbrowse_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbrowse_hboother.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_hboother);\n\t\t\t}\n\t\t});\n\t\tbrowse_hboother.setText(\"Browse...\");\n\t\tbrowse_hboother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbrowse_hboother.setBounds(548, 248, 127, 28);\n\t\tloadOther.add(browse_hboother);\n\t\tfinal Label label_hboother = new Label(composite_other, SWT.NONE);\n\t\tlabel_hboother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlabel_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlabel_hboother.setText(\"HbO File:\");\n\t\tlabel_hboother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlabel_hboother.setBounds(30, 250, 84, 28);\n\t\tloadOther.add(label_hboother);\n\t\tfinal Label lbl_hbother = new Label(composite_other, SWT.NONE);\n\t\tlbl_hbother.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlbl_hbother.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlbl_hbother.setText(\"Hb File:\");\n\t\tlbl_hbother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbl_hbother.setBounds(30, 200, 84, 28);\n\t\tloadOther.add(lbl_hbother);\n\t\tfinal Spinner spinner_nsother = new Spinner(composite_other, SWT.BORDER);\n\t\tspinner_nsother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tspinner_nsother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tspinner_nsother.setMinimum(1);\n\t\tspinner_nsother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tspinner_nsother.setBounds(105, 85, 47, 25);\n\t\tfinal Label lbl_seshnum = new Label(composite_other, SWT.NONE);\n\t\tlbl_seshnum.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlbl_seshnum.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlbl_seshnum.setText(\"Session: 1 of 1\");\n\t\tlbl_seshnum.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.ITALIC));\n\t\tlbl_seshnum.setBounds(30, 380, 212, 20);\n\t\tloadOther.add(lbl_seshnum);\n\t\tfinal Button button_hbother = new Button(composite_other, SWT.CHECK);\n\t\tbutton_hbother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbutton_hbother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tbutton_hbother.setText(\"Hb\");\n\t\tbutton_hbother.setBounds(404, 85, 14, 25);\n\t\tfinal Button button_hboother = new Button(composite_other, SWT.CHECK);\n\t\tbutton_hboother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbutton_hboother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tbutton_hboother.setText(\"HbO\");\n\t\tbutton_hboother.setBounds(467, 85, 14, 28);\n\t\tfinal Button enter_other = new Button(composite_other, SWT.NONE);\n\t\tButton add_other = new Button(composite_other, SWT.NONE);\n\t\tadd_other.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tadd_other.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tFile condFile = new File(text_conditionsother.getText());\n\t\t\t\tif (!setExists(condFile))\n\t\t\t\t\treturn;\n\t\t\t\tint channels = (Integer.valueOf(spinner_nsother.getText()))\n\t\t\t\t\t\t.intValue();\n\t\t\t\tFile Hb = new File(text_hbother.getText());\n\t\t\t\tFile HbO = new File(text_hboother.getText());\n\t\t\t\tif (!Hb.exists() && !HbO.exists()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tFile HbFile = new File(\"HbFile\");\n\t\t\t\tFile HbOFile = new File(\"HbOFile\");\n\t\t\t\tif (text_hbother.getText() != \"\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFiles.copy(Hb.toPath(), HbFile.toPath()\n\t\t\t\t\t\t\t\t.toAbsolutePath(),\n\t\t\t\t\t\t\t\tStandardCopyOption.REPLACE_EXISTING);\n\t\t\t\t\t} catch (IOException e2) {\n\t\t\t\t\t\te2.printStackTrace();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbFile = null;\n\t\t\t\t}\n\t\t\t\tif (text_hboother.getText() != \"\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tFiles.copy(HbO.toPath(), HbOFile.toPath()\n\t\t\t\t\t\t\t\t.toAbsolutePath(),\n\t\t\t\t\t\t\t\tStandardCopyOption.REPLACE_EXISTING);\n\t\t\t\t\t} catch (IOException e2) {\n\t\t\t\t\t\te2.printStackTrace();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tHbOFile = null;\n\t\t\t\t}\n\t\t\t\tJSplash splash = new JSplash(Hello.class.getClassLoader()\n\t\t\t\t\t\t.getResource(\"splash.png\"), true, true, false, \"\",\n\t\t\t\t\t\tnull, Color.BLACK, Color.BLACK);\n\t\t\t\tsplash.setAlwaysOnTop(true);\n\t\t\t\tsplash.splashOn();\n\t\t\t\tsplash.setAlwaysOnTop(false);\n\t\t\t\ttry {\n\t\t\t\t\tif (sessionNumOther == 1) {\n\t\t\t\t\t\tworkspace.addSubject(subjectNameOther, HbFile, HbOFile,\n\t\t\t\t\t\t\t\tcondFile);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tworkspace.concatSession(subjectNameOther, HbFile,\n\t\t\t\t\t\t\t\tHbOFile, condFile);\n\t\t\t\t\t}\n\t\t\t\t} catch (InputMismatchException ime) {\n\t\t\t\t\tsplash.splashOff();\n\t\t\t\t\time.printStackTrace();\n\t\t\t\t\tworkspace.removeSubject(subjectNameOther);\n\t\t\t\t\tinfoBox(\"Error\", \"Conditions file must be a text file.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsessionNumOther++;\n\t\t\t\tsplash.setProgress(33, \"Searching for brains...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\tif (sessionNumOther > Integer\n\t\t\t\t\t\t.valueOf(spinner_nsother.getText()).intValue()) {\n\t\t\t\t\tlist.add(subjectNameOther);\n\t\t\t\t\tfor (Control item : loadOther) {\n\t\t\t\t\t\titem.setVisible(false);\n\t\t\t\t\t}\n\t\t\t\t\ttext_subnameOther.setEnabled(true);\n\t\t\t\t\tspinner_nsother.setEnabled(true);\n\t\t\t\t\tenter_other.setEnabled(true);\n\t\t\t\t\tbutton_hbother.setEnabled(true);\n\t\t\t\t\tbutton_hboother.setEnabled(true);\n\t\t\t\t\ttext_subnameOther.setText(\"\");\n\t\t\t\t\tspinner_nsother.setSelection(1);\n\t\t\t\t} else {\n\t\t\t\t\tlbl_seshnum.setText(sessionNumOther + \" of \"\n\t\t\t\t\t\t\t+ spinner_nsother.getText());\n\t\t\t\t}\n\t\t\t\tsplash.setProgress(68, \"Almost there...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(500);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\ttext_hbother.setText(\"\");\n\t\t\t\ttext_hboother.setText(\"\");\n\t\t\t\ttext_conditionsother.setText(\"\");\n\t\t\t\ttext_subnameOther.setText(\"\");\n\t\t\t\tsplash.setProgress(100, \"Done!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(1000);\n\t\t\t\t} catch (InterruptedException e1) {\n\t\t\t\t\te1.printStackTrace();\n\t\t\t\t}\n\t\t\t\tsplash.splashOff();\n\t\t\t}\n\t\t});\n\t\tadd_other.setText(\"Add\");\n\t\tadd_other.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tadd_other.setBounds(469, 380, 100, 28);\n\t\tloadOther.add(add_other);\n\t\tLabel label_subNameOther = new Label(composite_other, SWT.NONE);\n\t\tlabel_subNameOther.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlabel_subNameOther.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlabel_subNameOther.setText(\"Subject Name:\");\n\t\tlabel_subNameOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlabel_subNameOther.setBounds(30, 42, 105, 28);\n\t\ttext_subnameOther = new Text(composite_other, SWT.BORDER);\n\t\ttext_subnameOther.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_subnameOther.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_subnameOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_subnameOther.setBounds(146, 42, 396, 25);\n\t\tenter_other.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tenter_other.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tsubjectNameOther = text_subnameOther.getText();\n\t\t\t\tif (subjectNameOther == \"\"\n\t\t\t\t\t\t|| subjectNameOther.matches(subjectName)\n\t\t\t\t\t\t|| subjectNameOther.matches(subjectNameH)\n\t\t\t\t\t\t|| Arrays.asList(list.getItems()).contains(\n\t\t\t\t\t\t\t\tsubjectNameOther)) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Please enter a new name.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!button_hbother.getSelection()\n\t\t\t\t\t\t&& !button_hboother.getSelection()) {\n\t\t\t\t\tinfoBox(\"Warning\", \"Select Hb or HbO or both.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (Control item : loadOther) {\n\t\t\t\t\titem.setVisible(true);\n\t\t\t\t}\n\t\t\t\tif (!button_hbother.getSelection()) {\n\t\t\t\t\ttext_hbother.setVisible(false);\n\t\t\t\t\tbrowse_hbother.setVisible(false);\n\t\t\t\t\tlbl_hbother.setVisible(false);\n\t\t\t\t}\n\t\t\t\tif (!button_hboother.getSelection()) {\n\t\t\t\t\ttext_hboother.setVisible(false);\n\t\t\t\t\tbrowse_hboother.setVisible(false);\n\t\t\t\t\tlabel_hboother.setVisible(false);\n\t\t\t\t}\n\t\t\t\tsessionNumOther = 1;\n\t\t\t\tlbl_seshnum.setText(\"1 of \" + spinner_nsother.getText());\n\t\t\t\ttext_subnameOther.setEnabled(false);\n\t\t\t\tspinner_nsother.setEnabled(false);\n\t\t\t\tenter_other.setEnabled(false);\n\t\t\t\tbutton_hbother.setEnabled(false);\n\t\t\t\tbutton_hboother.setEnabled(false);\n\t\t\t}\n\t\t});\n\t\tenter_other.setText(\"Enter\");\n\t\tenter_other.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tenter_other.setBounds(548, 40, 133, 28);\n\t\tLabel lbl_conditionsother = new Label(composite_other, SWT.NONE);\n\t\tlbl_conditionsother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlbl_conditionsother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlbl_conditionsother.setText(\"Conditions File:\");\n\t\tlbl_conditionsother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbl_conditionsother.setBounds(30, 300, 111, 28);\n\t\tloadOther.add(lbl_conditionsother);\n\t\ttext_conditionsother = new Text(composite_other, SWT.BORDER);\n\t\ttext_conditionsother.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\ttext_conditionsother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\ttext_conditionsother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\ttext_conditionsother.setBounds(146, 300, 396, 25);\n\t\tloadOther.add(text_conditionsother);\n\t\tButton browse_condother = new Button(composite_other, SWT.NONE);\n\t\tbrowse_condother.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbrowse_condother.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_conditionsother);\n\t\t\t}\n\t\t});\n\t\tbrowse_condother.setText(\"Browse...\");\n\t\tbrowse_condother.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbrowse_condother.setBounds(548, 298, 127, 28);\n\t\tloadOther.add(browse_condother);\n\t\tLabel label_ppoptions = new Label(composite_other, SWT.NONE);\n\t\tlabel_ppoptions.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlabel_ppoptions.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlabel_ppoptions.setText(\"Preprocessing Options:\");\n\t\tlabel_ppoptions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.BOLD));\n\t\tlabel_ppoptions.setBounds(30, 150, 189, 25);\n\t\tloadOther.add(label_ppoptions);\n\t\tLabel lbl_numSessionsOther = new Label(composite_other, SWT.NONE);\n\t\tlbl_numSessionsOther.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlbl_numSessionsOther.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlbl_numSessionsOther.setText(\"Sessions:\");\n\t\tlbl_numSessionsOther.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlbl_numSessionsOther.setBounds(30, 85, 63, 25);\n\t\tButton cancel_other = new Button(composite_other, SWT.NONE);\n\t\tcancel_other\n\t\t\t\t.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tcancel_other.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tworkspace.removeSubject(subjectNameOther);\n\t\t\t\tfor (Control item : loadOther) {\n\t\t\t\t\titem.setVisible(false);\n\t\t\t\t}\n\t\t\t\ttext_subnameOther.setEnabled(true);\n\t\t\t\tspinner_nsother.setEnabled(true);\n\t\t\t\tenter_other.setEnabled(true);\n\t\t\t\tbutton_hbother.setEnabled(true);\n\t\t\t\tbutton_hboother.setEnabled(true);\n\t\t\t\ttext_subnameOther.setText(\"\");\n\t\t\t\tspinner_nsother.setSelection(1);\n\t\t\t\tsubjectNameOther = \"\";\n\t\t\t}\n\t\t});\n\t\tcancel_other.setText(\"Cancel\");\n\t\tcancel_other.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tcancel_other.setBounds(575, 380, 100, 28);\n\t\tloadOther.add(cancel_other);\n\t\tLabel lblHb = new Label(composite_other, SWT.NONE);\n\t\tlblHb.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHb.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHb.setBounds(424, 87, 32, 25);\n\t\tlblHb.setText(\"Hb\");\n\t\tLabel lblHbo = new Label(composite_other, SWT.NONE);\n\t\tlblHbo.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblHbo.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlblHbo.setBounds(487, 87, 55, 25);\n\t\tlblHbo.setText(\"HbO\");\n\t\tButton btnBrowse_2 = new Button(composite_4, SWT.NONE);\n\t\tbtnBrowse_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnBrowse_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnBrowse_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnBrowse_2.setBounds(548, 298, 143, 28);\n\t\tbtnBrowse_2.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tbrowse(text_7);\n\t\t\t}\n\t\t});\n\t\tbtnBrowse_2.setText(\"Browse...\");\n\t\tloadHatachi.add(btnBrowse_2);\n\t\tLabel label_2 = new Label(composite_4, SWT.NONE);\n\t\tlabel_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_2.setText(\"Preprocessing Options:\");\n\t\tlabel_2.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.BOLD));\n\t\tlabel_2.setBounds(30, 150, 189, 25);\n\t\tloadHatachi.add(label_2);\n\t\tLabel lblSessions = new Label(composite_4, SWT.NONE);\n\t\tlblSessions.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlblSessions.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlblSessions.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tlblSessions.setText(\"Sessions:\");\n\t\tlblSessions.setBounds(30, 85, 69, 25);\n\t\tfinal Button btnCancel = new Button(composite_4, SWT.NONE);\n\t\tbtnCancel.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnCancel.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tbtnCancel.setFont(SWTResourceManager\n\t\t\t\t.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnCancel.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tworkspace.removeSubject(subjectNameH);\n\t\t\t\tfor (Control item : loadHatachi) {\n\t\t\t\t\titem.setVisible(false);\n\t\t\t\t}\n\t\t\t\ttext_subName2.setEnabled(true);\n\t\t\t\tnum_sessions_h.setEnabled(true);\n\t\t\t\tbutton_2.setEnabled(true);\n\t\t\t\tnum_channels_H.setEnabled(true);\n\t\t\t\tbtnHb.setEnabled(true);\n\t\t\t\tbtnHbo.setEnabled(true);\n\t\t\t\ttext_subName2.setText(\"\");\n\t\t\t\tnum_sessions_h.setSelection(1);\n\t\t\t\tsubjectNameH = \"\";\n\t\t\t}\n\t\t});\n\t\tbtnCancel.setBounds(591, 380, 100, 25);\n\t\tbtnCancel.setText(\"Cancel\");\n\t\tloadHatachi.add(btnCancel);\n\t\tLabel label_5 = new Label(composite_4, SWT.NONE);\n\t\tlabel_5.setText(\"Hb\");\n\t\tlabel_5.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_5.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_5.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_5.setBounds(410, 85, 28, 25);\n\t\tLabel label_8 = new Label(composite_4, SWT.NONE);\n\t\tlabel_8.setText(\"HbO\");\n\t\tlabel_8.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));\n\t\tlabel_8.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tlabel_8.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tlabel_8.setBounds(473, 85, 55, 28);\n\t\tButton btnNewButton_1 = new Button(shlFnirsDataProcessing, SWT.FLAT);\n\t\tbtnNewButton_1.pack();\n\t\tbtnNewButton_1.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_HAND));\n\t\tbtnNewButton_1.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tbtnNewButton_1.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (button_3.getVisible()) {\n\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\"Cancel file loading before changing workspace.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (btnCancel.getVisible()) {\n\t\t\t\t\tinfoBox(\"Warning!\",\n\t\t\t\t\t\t\t\"Cancel file loading before changing workspace.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfileDialog = new FileDialog(shlFnirsDataProcessing, SWT.OPEN\n\t\t\t\t\t\t| SWT.CANCEL);\n\t\t\t\tDirectoryDialog dlg = new DirectoryDialog(\n\t\t\t\t\t\tshlFnirsDataProcessing);\n\t\t\t\tdlg.setText(\"Select Workspace\");\n\t\t\t\tString selected = dlg.open(); \n\t\t\t\tif (selected == null)\n\t\t\t\t\treturn;\n\t\t\t\tdisableList(step2);\n\t\t\t\tlist_1.removeAll();\n\t\t\t\tenableList(step1);\n\t\t\t\tlist.removeAll();\n\t\t\t\tworkspace = new Workspace(selected, pre);\n\t\t\t\tworkspace.loadSubjects(list);\n\t\t\t\tlist_2.removeAll();\n\t\t\t\tfor (String template : workspace.getTemplates()) {\n\t\t\t\t\tlist_2.add(template);\n\t\t\t\t}\n\t\t\t\tlist_2.setSelection(0);\n\t\t\t\ttext_dm_sub.setText(\"\");\n\t\t\t\ttext_dmoutput.setText(\"\");\n\t\t\t}\n\t\t});\n\t\tbtnNewButton_1.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.NORMAL));\n\t\tbtnNewButton_1.setBounds(10, 436, 226, 28);\n\t\tbtnNewButton_1.setText(\"Change Workspace\");\n\t\tLabel lblSubjectList = new Label(shlFnirsDataProcessing, SWT.BORDER);\n\t\tlblSubjectList.setForeground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_BLACK));\n\t\tlblSubjectList.setAlignment(SWT.CENTER);\n\t\tlblSubjectList.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12,\n\t\t\t\tSWT.BOLD));\n\t\tlblSubjectList.setBackground(SWTResourceManager\n\t\t\t\t.getColor(SWT.COLOR_WHITE));\n\t\tlblSubjectList.setBounds(10, 10, 226, 28);\n\t\tlblSubjectList.setText(\"Subject List\");\n\t\tfor (Control item : loadHatachi) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\tfor (Control item : loadOther) {\n\t\t\titem.setVisible(false);\n\t\t}\n\t\ttabFolder.setSelection(0);\n\t\ttabFolder_1.setSelection(0);\n\t\tButton btnClear = new Button(shlFnirsDataProcessing, SWT.FLAT);\n\t\tbtnClear.setBounds(10, 470, 226, 28);\n\t\tbtnClear.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));\n\t\tbtnClear.setFont(SWTResourceManager.getFont(\"Segoe UI\", 12, SWT.NORMAL));\n\t\tbtnClear.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tlist.deselectAll();\n\t\t\t\tindexList.clear();\n\t\t\t}\n\t\t});\n\t\tbtnClear.setText(\"Clear Selections\");\n\t\tlist_1.setVisible(true);\n\t\tbtnRun.setVisible(true);\n\t\tbtnCancel_DM.setVisible(true);\n\t\treturn 0;\n\t}\n"} {"input": "\tprivate void autoClose(IDocument d, DocumentCommand c) {\n\t\tif (c.offset == -1)\n\t\t\treturn;\n\t\ttry {\n\t\t\tif (d.getChar(c.offset - 1) == '\\\\')\n\t\t\t\treturn;\n\t\t} catch (BadLocationException e1) {\n\t\t}\n\t\tif ('\\\"' == c.text.charAt(0) && !prefs.closeStrings())\n\t\t\treturn;\n\t\tif ('\\'' == c.text.charAt(0) && !prefs.closeStrings())\n\t\t\treturn;\n\t\tif (!prefs.closeBrackets()\n\t\t\t\t&& ('[' == c.text.charAt(0) || '(' == c.text.charAt(0) || '{' == c.text.charAt(0)))\n\t\t\treturn;\n\t\ttry {\n\t\t\tswitch (c.text.charAt(0)) {\n\t\t\tcase '\\\"':\n\t\t\tcase '\\'':\n\t\t\t\tif ('\\\"' == c.text.charAt(0) && c.offset > 0 && \"\\\"\".equals(d.get(c.offset - 1, 1)))\n\t\t\t\t\treturn;\n\t\t\t\tif ('\\'' == c.text.charAt(0) && c.offset > 0 && \"\\'\".equals(d.get(c.offset - 1, 1)))\n\t\t\t\t\treturn;\n\t\t\t\tif (c.offset != d.getLength() && c.text.charAt(0) == d.get(c.offset, 1).charAt(0))\n\t\t\t\t\tc.text = \"\";\n\t\t\t\telse {\n\t\t\t\t\tc.text += c.text;\n\t\t\t\t\tc.length = 0;\n\t\t\t\t}\n\t\t\t\tc.shiftsCaret = false;\n\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\tbreak;\n\t\t\tcase '(':\n\t\t\tcase '{':\n\t\t\tcase '[':\n\t\t\t\tif (AutoEditUtils.getRegionType(d, fPartitioning, c.offset) != IDocument.DEFAULT_CONTENT_TYPE)\n\t\t\t\t\treturn;\n\t\t\t\tif (c.offset != d.getLength() && c.text.charAt(0) == d.get(c.offset, 1).charAt(0))\n\t\t\t\t\treturn;\n\t\t\t\ttry { \n\t\t\t\t\tString regex = \"^\\\\s*class\\\\s+.*\";\n\t\t\t\t\tString regex2 = \".*\\\\(.*\\\\).*\";\n\t\t\t\t\tint start = d.getLineOffset(d.getLineOfOffset(c.offset));\n\t\t\t\t\tString curLine = d.get(start, c.offset - start);\n\t\t\t\t\tif (Pattern.matches(regex, curLine) && !Pattern.matches(regex2, curLine)) {\n\t\t\t\t\t\tc.text = \"():\";\n\t\t\t\t\t\tc.shiftsCaret = false;\n\t\t\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} catch (BadLocationException e) {\n\t\t\t\t}\n\t\t\t\tc.text = c.text + AutoEditUtils.getBracePair(c.text.charAt(0));\n\t\t\t\tc.length = 0;\n\t\t\t\tc.shiftsCaret = false;\n\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\tbreak;\n\t\t\tcase '}':\n\t\t\tcase ']':\n\t\t\tcase ')':\n\t\t\t\tif (AutoEditUtils.getRegionType(d, fPartitioning, c.offset) != IDocument.DEFAULT_CONTENT_TYPE)\n\t\t\t\t\treturn;\n\t\t\t\tif (!prefs.closeBrackets())\n\t\t\t\t\treturn;\n\t\t\t\tif (c.offset != d.getLength() && c.text.charAt(0) == d.get(c.offset, 1).charAt(0)) {\n\t\t\t\t\tc.text = \"\";\n\t\t\t\t\tc.shiftsCaret = false;\n\t\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (BadLocationException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n", "output": "\tprivate void autoClose(IDocument d, DocumentCommand c) {\n\t\tif (c.offset == -1)\n\t\t\treturn;\n\t\ttry {\n\t\t\tif (d.getChar(c.offset - 1) == '\\\\')\n\t\t\t\treturn;\n\t\t} catch (BadLocationException e1) {\n\t\t}\n\t\tif ('\\\"' == c.text.charAt(0) && !prefs.closeStrings())\n\t\t\treturn;\n\t\tif ('\\'' == c.text.charAt(0) && !prefs.closeStrings())\n\t\t\treturn;\n\t\tif (!prefs.closeBrackets()\n\t\t\t\t&& ('[' == c.text.charAt(0) || '(' == c.text.charAt(0) || '{' == c.text.charAt(0)))\n\t\t\treturn;\n\t\ttry {\n\t\t\tswitch (c.text.charAt(0)) {\n\t\t\tcase '\\\"':\n\t\t\tcase '\\'':\n\t\t\t\tif ('\\\"' == c.text.charAt(0) && c.offset > 0 && \"\\\"\".equals(d.get(c.offset - 1, 1)))\n\t\t\t\t\treturn;\n\t\t\t\tif ('\\'' == c.text.charAt(0) && c.offset > 0 && \"\\'\".equals(d.get(c.offset - 1, 1)))\n\t\t\t\t\treturn;\n\t\t\t\tif (c.offset != d.getLength() && c.text.charAt(0) == d.get(c.offset, 1).charAt(0))\n\t\t\t\t\tc.text = \"\";\n\t\t\t\telse {\n\t\t\t\t\tc.text += c.text;\n\t\t\t\t\tc.length = 0;\n\t\t\t\t}\n\t\t\t\tc.shiftsCaret = false;\n\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\tbreak;\n\t\t\tcase '(':\n\t\t\tcase '{':\n\t\t\tcase '[':\n\t\t\t\tif (AutoEditUtils.getRegionType(d, fPartitioning, c.offset) != IDocument.DEFAULT_CONTENT_TYPE)\n\t\t\t\t\treturn;\n\t\t\t\tif (c.offset != d.getLength() && c.text.charAt(0) == d.get(c.offset, 1).charAt(0))\n\t\t\t\t\treturn;\n\t\t\t\ttry { \n\t\t\t\t\tString regex = \"^\\\\s*class\\\\s+.*\";\n\t\t\t\t\tString regex2 = \".*\\\\(.*\\\\).*\";\n\t\t\t\t\tint start = d.getLineOffset(d.getLineOfOffset(c.offset));\n\t\t\t\t\tString curLine = d.get(start, c.offset - start);\n\t\t\t\t\tif (Pattern.matches(regex, curLine) && !Pattern.matches(regex2, curLine)) {\n\t\t\t\t\t\tc.text = \"()\";\n\t\t\t\t\t\tc.shiftsCaret = false;\n\t\t\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t} catch (BadLocationException e) {\n\t\t\t\t}\n\t\t\t\tc.text = c.text + AutoEditUtils.getBracePair(c.text.charAt(0));\n\t\t\t\tc.length = 0;\n\t\t\t\tc.shiftsCaret = false;\n\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\tbreak;\n\t\t\tcase '}':\n\t\t\tcase ']':\n\t\t\tcase ')':\n\t\t\t\tif (AutoEditUtils.getRegionType(d, fPartitioning, c.offset) != IDocument.DEFAULT_CONTENT_TYPE)\n\t\t\t\t\treturn;\n\t\t\t\tif (!prefs.closeBrackets())\n\t\t\t\t\treturn;\n\t\t\t\tif (c.offset != d.getLength() && c.text.charAt(0) == d.get(c.offset, 1).charAt(0)) {\n\t\t\t\t\tc.text = \"\";\n\t\t\t\t\tc.shiftsCaret = false;\n\t\t\t\t\tc.caretOffset = c.offset + 1;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (BadLocationException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n"} {"input": " public AsyncHttpClientConfig build() {\n if (reaper == null) {\n reaper = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() {\n public Thread newThread(Runnable r) {\n Thread t = new Thread(r, \"AsyncHttpClient-Reaper\");\n t.setDaemon(true);\n return t;\n }\n });\n }\n if (applicationThreadPool == null) {\n managedApplicationThreadPool = true;\n int count = Runtime.getRuntime().availableProcessors();\n applicationThreadPool =\n Executors.newFixedThreadPool(count, new ThreadFactory() {\n final AtomicInteger counter = new AtomicInteger();\n public Thread newThread(Runnable r) {\n Thread t = new Thread(r,\n \"AsyncHttpClient-Callback-\" + counter.incrementAndGet());\n t.setDaemon(true);\n return t;\n }\n });\n }\n if (applicationThreadPool.isShutdown()) {\n throw new IllegalStateException(\"ExecutorServices closed\");\n }\n if (proxyServerSelector == null && useProxySelector) {\n proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();\n }\n if (proxyServerSelector == null && useProxyProperties) {\n proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());\n }\n if (proxyServerSelector == null) {\n proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;\n }\n return new AsyncHttpClientConfig(defaultMaxTotalConnections,\n defaultMaxConnectionPerHost,\n defaultConnectionTimeOutInMs,\n defaultWebsocketIdleTimeoutInMs,\n defaultIdleConnectionInPoolTimeoutInMs,\n defaultIdleConnectionTimeoutInMs,\n defaultRequestTimeoutInMs,\n defaultMaxConnectionLifeTimeInMs,\n redirectEnabled,\n maxDefaultRedirects,\n compressionEnabled,\n userAgent,\n allowPoolingConnection,\n reaper,\n applicationThreadPool,\n proxyServerSelector,\n sslContext,\n sslEngineFactory,\n providerConfig,\n connectionsPool,\n realm,\n requestFilters,\n responseFilters,\n ioExceptionFilters,\n requestCompressionLevel,\n maxRequestRetry,\n allowSslConnectionPool,\n useRawUrl,\n removeQueryParamOnRedirect,\n hostnameVerifier,\n ioThreadMultiplier,\n strict302Handling,\n useRelativeURIsWithSSLProxies,\n spdyEnabled,\n spdyInitialWindowSize,\n spdyMaxConcurrentStreams,\n rfc6265CookieEncoding,\n asyncConnectMode,\n managedApplicationThreadPool);\n }\n", "output": " public AsyncHttpClientConfig build() {\n if (reaper == null) {\n reaper = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory() {\n public Thread newThread(Runnable r) {\n Thread t = new Thread(r, \"AsyncHttpClient-Reaper\");\n t.setDaemon(true);\n return t;\n }\n });\n }\n if (applicationThreadPool == null) {\n managedApplicationThreadPool = true;\n applicationThreadPool =\n Executors.newCachedThreadPool(new ThreadFactory() {\n final AtomicInteger counter = new AtomicInteger();\n public Thread newThread(Runnable r) {\n Thread t = new Thread(r,\n \"AsyncHttpClient-Callback-\" + counter.incrementAndGet());\n t.setDaemon(true);\n return t;\n }\n });\n }\n if (applicationThreadPool.isShutdown()) {\n throw new IllegalStateException(\"ExecutorServices closed\");\n }\n if (proxyServerSelector == null && useProxySelector) {\n proxyServerSelector = ProxyUtils.getJdkDefaultProxyServerSelector();\n }\n if (proxyServerSelector == null && useProxyProperties) {\n proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());\n }\n if (proxyServerSelector == null) {\n proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;\n }\n return new AsyncHttpClientConfig(defaultMaxTotalConnections,\n defaultMaxConnectionPerHost,\n defaultConnectionTimeOutInMs,\n defaultWebsocketIdleTimeoutInMs,\n defaultIdleConnectionInPoolTimeoutInMs,\n defaultIdleConnectionTimeoutInMs,\n defaultRequestTimeoutInMs,\n defaultMaxConnectionLifeTimeInMs,\n redirectEnabled,\n maxDefaultRedirects,\n compressionEnabled,\n userAgent,\n allowPoolingConnection,\n reaper,\n applicationThreadPool,\n proxyServerSelector,\n sslContext,\n sslEngineFactory,\n providerConfig,\n connectionsPool,\n realm,\n requestFilters,\n responseFilters,\n ioExceptionFilters,\n requestCompressionLevel,\n maxRequestRetry,\n allowSslConnectionPool,\n useRawUrl,\n removeQueryParamOnRedirect,\n hostnameVerifier,\n ioThreadMultiplier,\n strict302Handling,\n useRelativeURIsWithSSLProxies,\n spdyEnabled,\n spdyInitialWindowSize,\n spdyMaxConcurrentStreams,\n rfc6265CookieEncoding,\n asyncConnectMode,\n managedApplicationThreadPool);\n }\n"} {"input": "\tpublic static void LogLocationToFile(Context context, Location myLoc)\n\t{\n\t\tUri fileUri = null;\n\t\tSharedPreferences sharedPrefs = PreferenceManager\n\t\t\t\t.getDefaultSharedPreferences(context);\n\t\tif (!DataStorage.isExternalStorageWritable())\n\t\t{\n\t\t\tLog.e(TAG, \"External storage can not be written\");\n\t\t\tToast.makeText(context, \"External Storage can not be written\",\n\t\t\t\t\tToast.LENGTH_SHORT).show();\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tFile root;\n\t\t\ttry\n\t\t\t{\n\t\t\t\troot = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\troot = Environment.getExternalStorageDirectory();\n\t\t\t}\n\t\t\tString path = root.getAbsolutePath();\n\t\t\tif (root.canWrite())\n\t\t\t{\n\t\t\t\tString timestamp = DateUtils.now(\"yyyy-MM-dd_HHmmssSSS\");\n\t\t\t\tFile textFile = new File(root, FILENAME + \".txt\");\n\t\t\t\tFileWriter fw = new FileWriter(textFile);\n\t\t\t\tBufferedWriter out = new BufferedWriter(fw);\n\t\t\t\tout.append(timestamp + \": \" \n\t\t\t\t\t\t+ \"LAT=\" + myLoc.getLatitude()\n\t\t\t\t\t\t+ \"LONG=\" + myLoc.getLongitude() + \"\\n\");\n\t\t\t\tout.close();\n\t\t\t\tFile jsonFile = new File(root, FILENAME + \".json\");\n\t\t\t\tfw = new FileWriter(jsonFile);\n\t\t\t\tout = new BufferedWriter(fw);\n\t\t\t\tout.append(timestamp + \": \" \n\t\t\t\t\t\t+ \"LAT=\" + myLoc.getLatitude()\n\t\t\t\t\t\t+ \"LONG=\" + myLoc.getLongitude() + \"\\n\");\n\t\t\t\tGson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create();\n\t\t\t\tout.append(gson.toJson(new TrackEntry(myLoc)));\n\t\t\t\tout.close();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLog.i(TAG,\n\t\t\t\t\t\t\"Write error. \"\n\t\t\t\t\t\t\t\t+ Environment.getExternalStorageDirectory()\n\t\t\t\t\t\t\t\t+ \" couldn't be written\");\n\t\t\t}\n\t\t} catch (Exception e)\n\t\t{\n\t\t\tLog.e(TAG, \"Exception: \" + e.getMessage());\n\t\t}\n\t}\n", "output": "\tpublic static void LogLocationToFile(Context context, Location myLoc)\n\t{\n\t\tUri fileUri = null;\n\t\tSharedPreferences sharedPrefs = PreferenceManager\n\t\t\t\t.getDefaultSharedPreferences(context);\n\t\tif (!DataStorage.isExternalStorageWritable())\n\t\t{\n\t\t\tLog.e(TAG, \"External storage can not be written\");\n\t\t\tToast.makeText(context, \"External Storage can not be written\",\n\t\t\t\t\tToast.LENGTH_SHORT).show();\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tFile root;\n\t\t\ttry\n\t\t\t{\n\t\t\t\troot = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);\n\t\t\t}\n\t\t\tcatch (Exception e)\n\t\t\t{\n\t\t\t\troot = Environment.getExternalStorageDirectory();\n\t\t\t}\n\t\t\tString path = root.getAbsolutePath();\n\t\t\tif (root.canWrite())\n\t\t\t{\n\t\t\t\tString timestamp = DateUtils.now(\"yyyy-MM-dd_HHmmssSSS\");\n\t\t\t\tFile textFile = new File(root, FILENAME + \".txt\");\n\t\t\t\tFileWriter fw = new FileWriter(textFile);\n\t\t\t\tBufferedWriter out = new BufferedWriter(fw);\n\t\t\t\tout.append(timestamp + \": \" \n\t\t\t\t\t\t+ \"LAT=\" + myLoc.getLatitude()\n\t\t\t\t\t\t+ \"LONG=\" + myLoc.getLongitude() + \"\\n\");\n\t\t\t\tout.close();\n\t\t\t\tFile jsonFile = new File(root, FILENAME + \".json\");\n\t\t\t\tfw = new FileWriter(jsonFile);\n\t\t\t\tout = new BufferedWriter(fw);\n\t\t\t\tout.append(\"TrackEntry\\n\");\n\t\t\t\tGson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().create();\n\t\t\t\tout.append(gson.toJson(new TrackEntry(myLoc)));\n\t\t\t\tout.append(\"\\n\");\n\t\t\t\tout.close();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tLog.i(TAG,\n\t\t\t\t\t\t\"Write error. \"\n\t\t\t\t\t\t\t\t+ Environment.getExternalStorageDirectory()\n\t\t\t\t\t\t\t\t+ \" couldn't be written\");\n\t\t\t}\n\t\t} catch (Exception e)\n\t\t{\n\t\t\tLog.e(TAG, \"Exception: \" + e.getMessage());\n\t\t}\n\t}\n"} {"input": "\tpublic static List<CleanPlan> createCleanPlanFromJSON(Reader reader)\n\t\t\tthrows InvalidRuleException, InvalidCleanPlanException {\n\t\tPreconditions.checkNotNull(reader);\n\t\tJSONObject jsonObject = (JSONObject) JSONValue.parse(reader);\n\t\tList<CleanPlan> result = Lists.newArrayList();\n\t\tboolean isCSV = false;\n\t\tList<Schema> schemas = Lists.newArrayList();\n\t\tConnection conn = null;\n\t\ttry {\n\t\t\tJSONObject src = (JSONObject) jsonObject.get(\"source\");\n\t\t\tString type = (String) src.get(\"type\");\n\t\t\tDBConfig dbConfig;\n\t\t\tswitch (type) {\n\t\t\tcase \"csv\":\n\t\t\t\tisCSV = true;\n\t\t\t\tdbConfig = NadeefConfiguration.getDbConfig();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSQLDialect sqlDialect = SQLDialect.POSTGRES;\n\t\t\t\tDBConfig.Builder builder = new DBConfig.Builder();\n\t\t\t\tdbConfig =\n builder.username((String) src.get(\"username\"))\n\t\t\t\t\t\t.password((String) src.get(\"password\"))\n\t\t\t\t\t\t.url((String) src.get(\"url\")).dialect(sqlDialect)\n\t\t\t\t\t\t.build();\n\t\t\t}\n\t\t\tDBConnectionFactory.initializeSource(dbConfig);\n\t\t\tJSONArray ruleArray = (JSONArray) jsonObject.get(\"rule\");\n\t\t\tArrayList<Rule> rules = Lists.newArrayList();\n\t\t\tList<String> targetTableNames;\n List<String> fileNames = Lists.newArrayList();\n\t\t\tfor (int i = 0; i < ruleArray.size(); i++) {\n\t\t\t\tschemas.clear();\n fileNames.clear();\n\t\t\t\tJSONObject ruleObj = (JSONObject) ruleArray.get(i);\n\t\t\t\tif (isCSV) {\n\t\t\t\t\tList<String> fullFileNames = (List<String>) src.get(\"file\");\n for (String fullFileName : fullFileNames) {\n fileNames.add(Files.getNameWithoutExtension(fullFileName));\n }\n\t\t\t\t\tif (ruleObj.containsKey(\"table\")) {\n\t\t\t\t\t\ttargetTableNames = (List<String>) ruleObj.get(\"table\");\n\t\t\t\t\t\tPreconditions.checkArgument(\n\t\t\t\t\t targetTableNames.size() <= 2,\n\t\t\t\t\t\t\t\"NADEEF only supports MAX 2 tables per rule.\"\n );\n for (String targetTableName : targetTableNames) {\n if (!fileNames.contains(targetTableName)) {\n throw new InvalidCleanPlanException(\"Unknown table name.\");\n }\n }\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttargetTableNames = Lists.newArrayList();\n\t\t\t\t\t\tfor (String fileName : fileNames) {\n\t\t\t\t\t\t\ttargetTableNames.add(fileName);\n if (targetTableNames.size() == 2) {\n break;\n }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconn = DBConnectionFactory.getNadeefConnection();\n HashSet<String> copiedTables = Sets.newHashSet();\n for (int j = 0; j < targetTableNames.size(); j++) {\n\t\t\t\t\t\tFile file = CommonTools.getFile(fullFileNames.get(j));\n if (!copiedTables.contains(targetTableNames.get(j))) {\n String tableName = CSVDumper.dump(conn, file, targetTableNames.get(j));\n targetTableNames.set(j, tableName);\n schemas.add(DBMetaDataTool.getSchema(tableName));\n }\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tList<String> sourceTableNames = (List<String>) ruleObj.get(\"table\");\n\t\t\t\t\tfor (String tableName : sourceTableNames) {\n\t\t\t\t\t\tif (!DBMetaDataTool.isTableExist(tableName)) {\n throw new InvalidCleanPlanException(\n \"The specified table \" +\n tableName +\n \" cannot be found in the source database.\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (ruleObj.containsKey(\"target\")) {\n\t\t\t\t\t\ttargetTableNames = (List<String>) ruleObj.get(\"target\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttargetTableNames = Lists.newArrayList();\n\t\t\t\t\t\tfor (String sourceTableName : sourceTableNames) {\n\t\t\t\t\t\t\ttargetTableNames.add(sourceTableName + \"_copy\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tPreconditions.checkArgument(\n sourceTableNames.size() == targetTableNames.size() &&\n sourceTableNames.size() <= 2 &&\n sourceTableNames.size() >= 1,\n \"Invalid Rule property, rule needs to have one or two tables.\");\n\t\t\t\t\tfor (int j = 0; j < sourceTableNames.size(); j++) {\n\t\t\t\t\t\tDBMetaDataTool.copy(\n sourceTableNames.get(j),\n\t\t\t\t\t\t targetTableNames.get(j)\n );\n schemas.add(\n DBMetaDataTool.getSchema(\n targetTableNames.get(j)\n )\n );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttype = (String) ruleObj.get(\"type\");\n\t\t\t\tRule rule;\n\t\t\t\tJSONArray value;\n\t\t\t\tvalue = (JSONArray) ruleObj.get(\"value\");\n\t\t\t\tString ruleName = (String) ruleObj.get(\"name\");\n if (Strings.isNullOrEmpty(ruleName)) {\n ruleName = \"Rule\" + CommonTools.toHashCode((String)value.get(0));\n }\n\t\t\t\tswitch (type) {\n\t\t\t\tcase \"udf\":\n\t\t\t\t\tvalue = (JSONArray) ruleObj.get(\"value\");\n\t\t\t\t\tClass udfClass =\n CommonTools.loadClass((String) value.get(0));\n\t\t\t\t\tif (!Rule.class.isAssignableFrom(udfClass)) {\n\t\t\t\t\t\tthrow new InvalidRuleException(\n\t\t\t\t\t\t \"The specified class is not a Rule class.\"\n );\n\t\t\t\t\t}\n\t\t\t\t\trule = (Rule) udfClass.newInstance();\n\t\t\t\t\trule.initialize(ruleName, targetTableNames);\n\t\t\t\t\trules.add(rule);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tRuleBuilder ruleBuilder = NadeefConfiguration.tryGetRuleBuilder(type);\n\t\t\t\t\tif (ruleBuilder != null) {\n\t\t\t\t\t\trules.addAll(\n ruleBuilder.name(ruleName)\n .schema(schemas)\n\t\t\t\t\t\t\t\t.table(targetTableNames)\n .value(value)\n .build()\n );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttracer.err(\"Unknown Rule type: \" + type, null);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int i = 0; i < rules.size(); i++) {\n\t\t\t\tresult.add(new CleanPlan(dbConfig, rules.get(i)));\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (Exception ex) {\n\t\t\tex.printStackTrace();\n if (ex instanceof InvalidRuleException) {\n\t\t\t\tthrow (InvalidRuleException) ex;\n\t\t\t}\n\t\t\tthrow new InvalidCleanPlanException(ex);\n\t\t} finally {\n\t\t\tif (conn != null) {\n\t\t\t\ttry {\n\t\t\t\t\tconn.close();\n\t\t\t\t} catch (SQLException ex) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic static List<CleanPlan> createCleanPlanFromJSON(Reader reader)\n\t\t\tthrows InvalidRuleException, InvalidCleanPlanException {\n\t\tPreconditions.checkNotNull(reader);\n\t\tJSONObject jsonObject = (JSONObject) JSONValue.parse(reader);\n\t\tList<CleanPlan> result = Lists.newArrayList();\n\t\tboolean isCSV = false;\n\t\tList<Schema> schemas = Lists.newArrayList();\n\t\tConnection conn = null;\n\t\ttry {\n\t\t\tJSONObject src = (JSONObject) jsonObject.get(\"source\");\n\t\t\tString type = (String) src.get(\"type\");\n\t\t\tDBConfig dbConfig;\n\t\t\tswitch (type) {\n\t\t\tcase \"csv\":\n\t\t\t\tisCSV = true;\n\t\t\t\tdbConfig = NadeefConfiguration.getDbConfig();\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tSQLDialect sqlDialect = SQLDialect.POSTGRES;\n\t\t\t\tDBConfig.Builder builder = new DBConfig.Builder();\n\t\t\t\tdbConfig =\n builder.username((String) src.get(\"username\"))\n\t\t\t\t\t\t.password((String) src.get(\"password\"))\n\t\t\t\t\t\t.url((String) src.get(\"url\")).dialect(sqlDialect)\n\t\t\t\t\t\t.build();\n\t\t\t}\n\t\t\tDBConnectionFactory.initializeSource(dbConfig);\n\t\t\tJSONArray ruleArray = (JSONArray) jsonObject.get(\"rule\");\n\t\t\tArrayList<Rule> rules = Lists.newArrayList();\n\t\t\tList<String> targetTableNames;\n List<String> fileNames = Lists.newArrayList();\n HashSet<String> copiedTables = Sets.newHashSet();\n\t\t\tfor (int i = 0; i < ruleArray.size(); i++) {\n\t\t\t\tschemas.clear();\n fileNames.clear();\n\t\t\t\tJSONObject ruleObj = (JSONObject) ruleArray.get(i);\n\t\t\t\tif (isCSV) {\n\t\t\t\t\tList<String> fullFileNames = (List<String>) src.get(\"file\");\n for (String fullFileName : fullFileNames) {\n fileNames.add(Files.getNameWithoutExtension(fullFileName));\n }\n\t\t\t\t\tif (ruleObj.containsKey(\"table\")) {\n\t\t\t\t\t\ttargetTableNames = (List<String>) ruleObj.get(\"table\");\n\t\t\t\t\t\tPreconditions.checkArgument(\n\t\t\t\t\t targetTableNames.size() <= 2,\n\t\t\t\t\t\t\t\"NADEEF only supports MAX 2 tables per rule.\"\n );\n for (String targetTableName : targetTableNames) {\n if (!fileNames.contains(targetTableName)) {\n throw new InvalidCleanPlanException(\"Unknown table name.\");\n }\n }\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttargetTableNames = Lists.newArrayList();\n\t\t\t\t\t\tfor (String fileName : fileNames) {\n\t\t\t\t\t\t\ttargetTableNames.add(fileName);\n if (targetTableNames.size() == 2) {\n break;\n }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconn = DBConnectionFactory.getNadeefConnection();\n for (int j = 0; j < targetTableNames.size(); j++) {\n\t\t\t\t\t\tFile file = CommonTools.getFile(fullFileNames.get(j));\n if (!copiedTables.contains(targetTableNames.get(j))) {\n String tableName = CSVDumper.dump(conn, file, targetTableNames.get(j));\n targetTableNames.set(j, tableName);\n schemas.add(DBMetaDataTool.getSchema(tableName));\n copiedTables.add(targetTableNames.get(j));\n }\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tList<String> sourceTableNames = (List<String>) ruleObj.get(\"table\");\n\t\t\t\t\tfor (String tableName : sourceTableNames) {\n\t\t\t\t\t\tif (!DBMetaDataTool.isTableExist(tableName)) {\n throw new InvalidCleanPlanException(\n \"The specified table \" +\n tableName +\n \" cannot be found in the source database.\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (ruleObj.containsKey(\"target\")) {\n\t\t\t\t\t\ttargetTableNames = (List<String>) ruleObj.get(\"target\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttargetTableNames = Lists.newArrayList();\n\t\t\t\t\t\tfor (String sourceTableName : sourceTableNames) {\n\t\t\t\t\t\t\ttargetTableNames.add(sourceTableName + \"_copy\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tPreconditions.checkArgument(\n sourceTableNames.size() == targetTableNames.size() &&\n sourceTableNames.size() <= 2 &&\n sourceTableNames.size() >= 1,\n \"Invalid Rule property, rule needs to have one or two tables.\");\n\t\t\t\t\tfor (int j = 0; j < sourceTableNames.size(); j++) {\n\t\t\t\t\t\tDBMetaDataTool.copy(\n sourceTableNames.get(j),\n\t\t\t\t\t\t targetTableNames.get(j)\n );\n schemas.add(\n DBMetaDataTool.getSchema(\n targetTableNames.get(j)\n )\n );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttype = (String) ruleObj.get(\"type\");\n\t\t\t\tRule rule;\n\t\t\t\tJSONArray value;\n\t\t\t\tvalue = (JSONArray) ruleObj.get(\"value\");\n\t\t\t\tString ruleName = (String) ruleObj.get(\"name\");\n if (Strings.isNullOrEmpty(ruleName)) {\n ruleName = \"Rule\" + CommonTools.toHashCode((String)value.get(0));\n }\n\t\t\t\tswitch (type) {\n\t\t\t\tcase \"udf\":\n\t\t\t\t\tvalue = (JSONArray) ruleObj.get(\"value\");\n\t\t\t\t\tClass udfClass =\n CommonTools.loadClass((String) value.get(0));\n\t\t\t\t\tif (!Rule.class.isAssignableFrom(udfClass)) {\n\t\t\t\t\t\tthrow new InvalidRuleException(\n\t\t\t\t\t\t \"The specified class is not a Rule class.\"\n );\n\t\t\t\t\t}\n\t\t\t\t\trule = (Rule) udfClass.newInstance();\n\t\t\t\t\trule.initialize(ruleName, targetTableNames);\n\t\t\t\t\trules.add(rule);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tRuleBuilder ruleBuilder = NadeefConfiguration.tryGetRuleBuilder(type);\n\t\t\t\t\tif (ruleBuilder != null) {\n\t\t\t\t\t\trules.addAll(\n ruleBuilder.name(ruleName)\n .schema(schemas)\n\t\t\t\t\t\t\t\t.table(targetTableNames)\n .value(value)\n .build()\n );\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttracer.err(\"Unknown Rule type: \" + type, null);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int i = 0; i < rules.size(); i++) {\n\t\t\t\tresult.add(new CleanPlan(dbConfig, rules.get(i)));\n\t\t\t}\n\t\t\treturn result;\n\t\t} catch (Exception ex) {\n\t\t\tex.printStackTrace();\n if (ex instanceof InvalidRuleException) {\n\t\t\t\tthrow (InvalidRuleException) ex;\n\t\t\t}\n\t\t\tthrow new InvalidCleanPlanException(ex);\n\t\t} finally {\n\t\t\tif (conn != null) {\n\t\t\t\ttry {\n\t\t\t\t\tconn.close();\n\t\t\t\t} catch (SQLException ex) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public void fillComponents(UIContainer tofill, ViewParameters viewparams,\n ComponentChecker checker) {\n AssignmentViewParams params = (AssignmentViewParams) viewparams;\n Assignment2 assignment = assignmentLogic.getAssignmentById(params.assignmentId);\n String titleHeading = assignment.getTitle();\n if (gradebookLogic.getGradebookGradeEntryType(assignment.getContextId()) == ExternalGradebookLogic.ENTRY_BY_POINTS) {\n GradebookItem gradebookItem = gradebookLogic.getGradebookItemById(assignment.getContextId(), assignment.getGradebookItemId());\n if (gradebookItem == null) {\n throw new GradebookItemNotFoundException(\"No gradebook item found with id: \" + assignment.getGradebookItemId());\n }\n titleHeading += \" [\" + gradebookItem.getPointsPossible() + \"]\";\n }\n UIOutput.make(tofill, \"title-header\", titleHeading);\n boolean anyUngradable = false;\n if (uploadBean.parsedContent != null) {\n \tSet<String> submitters = assignmentPermissionLogic.getSubmittersInSite(assignment.getContextId());\n Map<String, String> displayIdUserIdMap = externalLogic.getUserDisplayIdUserIdMapForUsers(submitters);\n for (List<String> parts: uploadBean.parsedContent) {\n if (parts.size() < 4) {\n while (parts.size() < 4) {\n parts.add(\" \");\n }\n }\n UIBranchContainer row = UIBranchContainer.make(tofill, \"student-row:\");\n UIOutput.make(row, \"student-id\", parts.get(0));\n UIOutput.make(row, \"student-name\", parts.get(1));\n UIOutput.make(row, \"grade\", parts.get(2));\n UIOutput.make(row, \"comments\", parts.get(3));\n if(displayIdUserIdMap.containsKey(parts.get(0)) &&\n \t\t!assignmentPermissionLogic.isUserAllowedToManageSubmission(null, displayIdUserIdMap.get(parts.get(0)), assignment)){\n \trow.decorate(new UIFreeAttributeDecorator(\"class\", \"uploadHighlight\"));\n \tanyUngradable = true;\n }\n }\n }\n if(anyUngradable){\n \tmessages.addMessage(new TargettedMessage(\"assignment2.upload_grades_confirm.warning.ids_not_imported\"));\n }\n makeBreadcrumbs(tofill, assignment);\n UIForm finishForm = UIForm.make(tofill, \"finish-form\");\n UICommand.make(finishForm, \"ok-button\", UIMessage.make(\"assignment2.upload_grades_confirm.button.ok\"), \"UploadBean.processUploadConfirmAndSave\");\n UICommand.make(finishForm, \"cancel-button\", UIMessage.make(\"assignment2.upload_grades_confirm.button.back\"), \"UploadBean.processBackToUpload\");\n }\n", "output": " public void fillComponents(UIContainer tofill, ViewParameters viewparams,\n ComponentChecker checker) {\n AssignmentViewParams params = (AssignmentViewParams) viewparams;\n Assignment2 assignment = assignmentLogic.getAssignmentById(params.assignmentId);\n String titleHeading = assignment.getTitle();\n if (gradebookLogic.getGradebookGradeEntryType(assignment.getContextId()) == ExternalGradebookLogic.ENTRY_BY_POINTS) {\n GradebookItem gradebookItem = gradebookLogic.getGradebookItemById(assignment.getContextId(), assignment.getGradebookItemId());\n if (gradebookItem == null) {\n throw new GradebookItemNotFoundException(\"No gradebook item found with id: \" + assignment.getGradebookItemId());\n }\n titleHeading += \" [\" + gradebookItem.getPointsPossible() + \"]\";\n }\n UIOutput.make(tofill, \"title-header\", titleHeading);\n boolean anyUngradable = false;\n if (uploadBean.parsedContent != null) {\n \tSet<String> submitters = assignmentPermissionLogic.getSubmittersInSite(assignment.getContextId());\n Map<String, String> displayIdUserIdMap = externalLogic.getUserDisplayIdUserIdMapForUsers(submitters);\n for (List<String> parts: uploadBean.parsedContent) {\n if (parts.size() < 4) {\n while (parts.size() < 4) {\n parts.add(\"\");\n }\n }\n UIBranchContainer row = UIBranchContainer.make(tofill, \"student-row:\");\n UIOutput.make(row, \"student-id\", parts.get(0));\n UIOutput.make(row, \"student-name\", parts.get(1));\n UIOutput.make(row, \"grade\", parts.get(2));\n UIOutput.make(row, \"comments\", parts.get(3));\n if(displayIdUserIdMap.containsKey(parts.get(0)) &&\n \t\t!assignmentPermissionLogic.isUserAllowedToManageSubmission(null, displayIdUserIdMap.get(parts.get(0)), assignment)){\n \trow.decorate(new UIFreeAttributeDecorator(\"class\", \"uploadHighlight\"));\n \tanyUngradable = true;\n }\n }\n }\n if(anyUngradable){\n \tmessages.addMessage(new TargettedMessage(\"assignment2.upload_grades_confirm.warning.ids_not_imported\"));\n }\n makeBreadcrumbs(tofill, assignment);\n UIForm finishForm = UIForm.make(tofill, \"finish-form\");\n UICommand.make(finishForm, \"ok-button\", UIMessage.make(\"assignment2.upload_grades_confirm.button.ok\"), \"UploadBean.processUploadConfirmAndSave\");\n UICommand.make(finishForm, \"cancel-button\", UIMessage.make(\"assignment2.upload_grades_confirm.button.back\"), \"UploadBean.processBackToUpload\");\n }\n"} {"input": " private void register() throws IOException {\n\tLogger.println(\"Registering with \" + registrar);\n FromHeader fromHeader = getFromHeader();\n Address fromAddress = fromHeader.getAddress();\n SipURI requestURI = null;\n try {\n requestURI = addressFactory.createSipURI(null, registrar);\n\t} catch (ParseException e) {\n throw new IOException(\"Bad registrar address:\" + registrar, e);\n }\n requestURI.setPort(registrarPort);\n try {\n requestURI.setTransportParam(sipProvider.getListeningPoint().getTransport());\n } catch (ParseException e) {\n throw new IOException(sipProvider.getListeningPoint().getTransport()\n\t\t+ \" is not a valid transport!\", e);\n }\n CallIdHeader callIdHeader = sipProvider.getNewCallId();\n CSeqHeader cSeqHeader = null;\n try {\n cSeqHeader = headerFactory.createCSeqHeader(1, Request.REGISTER);\n } catch (ParseException e) {\n throw new IOException(\"Corrupt Sip Stack \" + e.getMessage());\n } catch (InvalidArgumentException e) {\n throw new IOException(\"The application is corrupt \" );\n }\n ToHeader toHeader = null;\n try {\n String proxyWorkAround =\n System.getProperty(\"com.sun.mc.softphone.REGISTRAR_WORKAROUND\");\n if (proxyWorkAround != null &&\n proxyWorkAround.toUpperCase().equals(\"TRUE\")) {\n SipURI toURI = (SipURI)(requestURI.clone());\n toURI.setUser(System.getProperty(\"user.name\"));\n toHeader = headerFactory.createToHeader(addressFactory.createAddress(toURI), null);\n } else {\n toHeader = headerFactory.createToHeader(fromAddress, null);\n }\n } catch (ParseException e) {\n throw new IOException(\"Could not create a To header for address:\"\n + fromHeader.getAddress() + \" \" + e.getMessage());\n }\n ArrayList viaHeaders = getLocalViaHeaders();\n MaxForwardsHeader maxForwardsHeader = getMaxForwardsHeader();\n Request request = null;\n try {\n request = messageFactory.createRequest(requestURI,\n Request.REGISTER,\n callIdHeader,\n cSeqHeader, fromHeader, toHeader,\n viaHeaders,\n maxForwardsHeader);\n } catch (ParseException e) {\n throw new IOException(\"Could not create the register request! \" + e.getMessage());\n\t}\n ExpiresHeader expHeader = null;\n for (int retry = 0; retry < 2; retry++) {\n try {\n expHeader = headerFactory.createExpiresHeader(\n expires);\n } catch (InvalidArgumentException e) {\n if (retry == 0) {\n continue;\n }\n throw new IOException(\n \"Invalid registrations expiration parameter - \"\n + expires + \" \" + e.getMessage());\n }\n }\n request.addHeader(expHeader);\n ContactHeader contactHeader = getRegistrationContactHeader();\n\trequest.addHeader(contactHeader);\n ClientTransaction regTrans = null;\n try {\n regTrans = sipProvider.getNewClientTransaction(request);\n } catch (TransactionUnavailableException e) {\n throw new IOException(\"Could not create a register transaction!\\n\"\n + \"Check that the Registrar address is correct! \" + e.getMessage());\n } try {\n\t sipCallId = callIdHeader.getCallId();\n\t sipServerCallback.addSipListener(sipCallId, this);\n\t registerRequest = request;\n regTrans.sendRequest();\n\t if (Logger.logLevel >= Logger.LOG_MOREINFO) {\n\t Logger.println(\"Sent register request \" + registerRequest);\n\t }\n\t if (expires > 0) {\n scheduleReRegistration();\n\t }\n } catch (Exception e) {\n\t throw new IOException(\"Could not send out the register request! \" + e.getMessage());\n }\n this.registerRequest = request;\n }\n", "output": " private void register() throws IOException {\n\tLogger.println(\"Registering with \" + registrar);\n FromHeader fromHeader = getFromHeader();\n Address fromAddress = fromHeader.getAddress();\n SipURI requestURI = null;\n try {\n requestURI = addressFactory.createSipURI(null, registrar);\n\t} catch (ParseException e) {\n throw new IOException(\"Bad registrar address:\" + registrar + \" \" \n\t\t+ e.getMessage());\n }\n requestURI.setPort(registrarPort);\n try {\n requestURI.setTransportParam(sipProvider.getListeningPoint().getTransport());\n } catch (ParseException e) {\n throw new IOException(sipProvider.getListeningPoint().getTransport()\n\t\t+ \" is not a valid transport! \" + e.getMessage());\n }\n CallIdHeader callIdHeader = sipProvider.getNewCallId();\n CSeqHeader cSeqHeader = null;\n try {\n cSeqHeader = headerFactory.createCSeqHeader(1, Request.REGISTER);\n } catch (ParseException e) {\n throw new IOException(\"Corrupt Sip Stack \" + e.getMessage());\n } catch (InvalidArgumentException e) {\n throw new IOException(\"The application is corrupt \" );\n }\n ToHeader toHeader = null;\n try {\n String proxyWorkAround =\n System.getProperty(\"com.sun.mc.softphone.REGISTRAR_WORKAROUND\");\n if (proxyWorkAround != null &&\n proxyWorkAround.toUpperCase().equals(\"TRUE\")) {\n SipURI toURI = (SipURI)(requestURI.clone());\n toURI.setUser(System.getProperty(\"user.name\"));\n toHeader = headerFactory.createToHeader(addressFactory.createAddress(toURI), null);\n } else {\n toHeader = headerFactory.createToHeader(fromAddress, null);\n }\n } catch (ParseException e) {\n throw new IOException(\"Could not create a To header for address:\"\n + fromHeader.getAddress() + \" \" + e.getMessage());\n }\n ArrayList viaHeaders = getLocalViaHeaders();\n MaxForwardsHeader maxForwardsHeader = getMaxForwardsHeader();\n Request request = null;\n try {\n request = messageFactory.createRequest(requestURI,\n Request.REGISTER,\n callIdHeader,\n cSeqHeader, fromHeader, toHeader,\n viaHeaders,\n maxForwardsHeader);\n } catch (ParseException e) {\n throw new IOException(\"Could not create the register request! \" + e.getMessage());\n\t}\n ExpiresHeader expHeader = null;\n for (int retry = 0; retry < 2; retry++) {\n try {\n expHeader = headerFactory.createExpiresHeader(\n expires);\n } catch (InvalidArgumentException e) {\n if (retry == 0) {\n continue;\n }\n throw new IOException(\n \"Invalid registrations expiration parameter - \"\n + expires + \" \" + e.getMessage());\n }\n }\n request.addHeader(expHeader);\n ContactHeader contactHeader = getRegistrationContactHeader();\n\trequest.addHeader(contactHeader);\n ClientTransaction regTrans = null;\n try {\n regTrans = sipProvider.getNewClientTransaction(request);\n } catch (TransactionUnavailableException e) {\n throw new IOException(\"Could not create a register transaction!\\n\"\n + \"Check that the Registrar address is correct! \" + e.getMessage());\n } try {\n\t sipCallId = callIdHeader.getCallId();\n\t sipServerCallback.addSipListener(sipCallId, this);\n\t registerRequest = request;\n regTrans.sendRequest();\n\t if (Logger.logLevel >= Logger.LOG_MOREINFO) {\n\t Logger.println(\"Sent register request \" + registerRequest);\n\t }\n\t if (expires > 0) {\n scheduleReRegistration();\n\t }\n } catch (Exception e) {\n\t throw new IOException(\"Could not send out the register request! \" + e.getMessage());\n }\n this.registerRequest = request;\n }\n"} {"input": " public void paint(Graphics g)\n {\n final boolean[] keys = model.getCurrentOctaveKeys();\n final int width = getWidth();\n final int height = getHeight();\n final int fontHeight = g.getFont().getHeight();\n final int whiteKeyWidth = (width - MARGIN * 2) / 7;\n final int whiteKeyHeight = height -\n (MARGIN + KEYS_NOTES_DISTANCE + fontHeight * 2);\n final int blackKeyWidth = whiteKeyWidth / 2; \n final int blackKeyHeight = whiteKeyHeight / 2; \n final int blackKeyNarrowWidth = blackKeyWidth / 2;\n final int whiteKeyNarrowWidth = whiteKeyWidth - blackKeyNarrowWidth;\n final int whiteKeyLesserHeight = whiteKeyHeight - blackKeyHeight;\n g.setColor(WHITE_COLOR);\n g.fillRect(0, 0, width, height);\n final int cx1 = 0 + MARGIN;\n final int cy1 = 0 + MARGIN;\n final int cx2 = cx1 + whiteKeyNarrowWidth;\n final int cy2 = cy1;\n final int cx3 = cx2;\n final int cy3 = cy2 + blackKeyHeight;\n final int cx4 = cx1 + whiteKeyWidth;\n final int cy4 = cy3;\n final int cx5 = cx4;\n final int cy5 = cy1 + whiteKeyHeight;\n final int cx6 = cx1;\n final int cy6 = cy5;\n setKeyColor(g, NOTE_C, keys[NOTE_C]);\n g.fillRect(cx1, cy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(cx3, cy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_C])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(cx1, cy1, cx2, cy2);\n g.drawLine(cx2, cy2, cx3, cy3);\n g.drawLine(cx3, cy3, cx4, cy4);\n g.drawLine(cx4, cy4, cx5, cy5);\n g.drawLine(cx5, cy5, cx6, cy6);\n g.drawLine(cx6, cy6, cx1, cy1);\n }\n final int ccx1 = cx2;\n final int ccy1 = cy2;\n final int ccx2 = ccx1 + blackKeyWidth;\n final int ccy2 = ccy1;\n setKeyColor(g, NOTE_C_SHARP, keys[NOTE_C_SHARP]);\n g.fillRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_C_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n }\n final int dx1 = ccx2;\n final int dy1 = ccy2;\n final int dx2 = dx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int dy2 = dy1;\n final int dx3 = dx2;\n final int dy3 = dy2 + blackKeyHeight;\n final int dx4 = cx4 + whiteKeyWidth;\n final int dy4 = dy3;\n final int dx5 = dx4;\n final int dy5 = dy2 + whiteKeyHeight;\n final int dx6 = cx5;\n final int dy6 = dy5;\n final int dx7 = dx6;\n final int dy7 = dy3;\n final int dx8 = dx1;\n final int dy8 = dy3;\n setKeyColor(g, NOTE_D, keys[NOTE_D]);\n g.fillRect(dx1, dy1, dx2 - dx1, blackKeyHeight);\n g.fillRect(dx7, dy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_D])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(dx1, dy1, dx2, dy2);\n g.drawLine(dx2, dy2, dx3, dy3);\n g.drawLine(dx3, dy3, dx4, dy4);\n g.drawLine(dx4, dy4, dx5, dy5);\n g.drawLine(dx5, dy5, dx6, dy6);\n g.drawLine(dx6, dy6, dx7, dy7);\n g.drawLine(dx7, dy7, dx8, dy8);\n g.drawLine(dx8, dy8, dx1, dy1);\n }\n final int ddx1 = dx2;\n final int ddy1 = dy2;\n final int ddx2 = ddx1 + blackKeyWidth;\n final int ddy2 = ddy1;\n setKeyColor(g, NOTE_D_SHARP, keys[NOTE_D_SHARP]);\n g.fillRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_D_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n }\n final int ex1 = ddx2;\n final int ey1 = ddy2;\n final int ex2 = dx4 + whiteKeyWidth;\n final int ey2 = ey1;\n final int ex3 = ex2;\n final int ey3 = ey2 + whiteKeyHeight;\n final int ex4 = dx5;\n final int ey4 = ey3;\n final int ex5 = ex4;\n final int ey5 = dy4;\n final int ex6 = ex5 + blackKeyNarrowWidth;\n final int ey6 = ey5;\n setKeyColor(g, NOTE_E, keys[NOTE_E]);\n g.fillRect(ex1, ey1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(ex5, ey5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_E])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ex1, ey1, ex2, ey2);\n g.drawLine(ex2, ey2, ex3, ey3);\n g.drawLine(ex3, ey3, ex4, ey4);\n g.drawLine(ex4, ey4, ex5, ey5);\n g.drawLine(ex5, ey5, ex6, ey6);\n g.drawLine(ex6, ey6, ex1, ey1);\n }\n final int fx1 = ex2;\n final int fy1 = ey2;\n final int fx2 = fx1 + whiteKeyNarrowWidth;\n final int fy2 = fy1;\n final int fx3 = fx2;\n final int fy3 = fy2 + blackKeyHeight;\n final int fx4 = fx1 + whiteKeyWidth;\n final int fy4 = fy3;\n final int fx5 = fx4;\n final int fy5 = fy1 + whiteKeyHeight;\n final int fx6 = fx1;\n final int fy6 = fy5;\n setKeyColor(g, NOTE_F, keys[NOTE_F]);\n g.fillRect(fx1, fy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(fx3, fy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_F])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(fx1, fy1, fx2, fy2);\n g.drawLine(fx2, fy2, fx3, fy3);\n g.drawLine(fx3, fy3, fx4, fy4);\n g.drawLine(fx4, fy4, fx5, fy5);\n g.drawLine(fx5, fy5, fx6, fy6);\n g.drawLine(fx6, fy6, fx1, fy1);\n }\n final int ffx1 = fx2;\n final int ffy1 = fy2;\n final int ffx2 = ffx1 + blackKeyWidth;\n final int ffy2 = ffy1;\n setKeyColor(g, NOTE_F_SHARP, keys[NOTE_F_SHARP]);\n g.fillRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_F_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n }\n final int gx1 = ffx2;\n final int gy1 = ffy2;\n final int gx2 = gx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int gy2 = gy1;\n final int gx3 = gx2;\n final int gy3 = gy2 + blackKeyHeight;\n final int gx4 = fx4 + whiteKeyWidth;\n final int gy4 = gy3;\n final int gx5 = gx4;\n final int gy5 = gy2 + whiteKeyHeight;\n final int gx6 = fx5;\n final int gy6 = gy5;\n final int gx7 = gx6;\n final int gy7 = gy3;\n final int gx8 = gx1;\n final int gy8 = gy3;\n setKeyColor(g, NOTE_G, keys[NOTE_G]);\n g.fillRect(gx1, gy1, gx2 - gx1, blackKeyHeight);\n g.fillRect(gx7, gy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_G])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(gx1, gy1, gx2, gy2);\n g.drawLine(gx2, gy2, gx3, gy3);\n g.drawLine(gx3, gy3, gx4, gy4);\n g.drawLine(gx4, gy4, gx5, gy5);\n g.drawLine(gx5, gy5, gx6, gy6);\n g.drawLine(gx6, gy6, gx7, gy7);\n g.drawLine(gx7, gy7, gx8, gy8);\n g.drawLine(gx8, gy8, gx1, gy1);\n }\n final int ggx1 = gx2;\n final int ggy1 = gy2;\n final int ggx2 = ggx1 + blackKeyWidth;\n final int ggy2 = ggy1;\n setKeyColor(g, NOTE_G_SHARP, keys[NOTE_G_SHARP]);\n g.fillRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_G_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n }\n final int ax1 = ggx2;\n final int ay1 = ggy2;\n final int ax2 = ax1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int ay2 = ay1;\n final int ax3 = ax2;\n final int ay3 = ay2 + blackKeyHeight;\n final int ax4 = gx4 + whiteKeyWidth;\n final int ay4 = ay3;\n final int ax5 = ax4;\n final int ay5 = ay2 + whiteKeyHeight;\n final int ax6 = gx5;\n final int ay6 = ay5;\n final int ax7 = ax6;\n final int ay7 = ay3;\n final int ax8 = ax1;\n final int ay8 = ay3;\n setKeyColor(g, NOTE_A, keys[NOTE_A]);\n g.fillRect(ax1, ay1, ax2 - ax1, blackKeyHeight);\n g.fillRect(ax7, ay7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_A])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ax1, ay1, ax2, ay2);\n g.drawLine(ax2, ay2, ax3, ay3);\n g.drawLine(ax3, ay3, ax4, ay4);\n g.drawLine(ax4, ay4, ax5, ay5);\n g.drawLine(ax5, ay5, ax6, ay6);\n g.drawLine(ax6, ay6, ax7, ay7);\n g.drawLine(ax7, ay7, ax8, ay8);\n g.drawLine(ax8, ay8, ax1, ay1);\n }\n final int aax1 = ax2;\n final int aay1 = ay2;\n final int aax2 = aax1 + blackKeyWidth;\n final int aay2 = aay1;\n setKeyColor(g, NOTE_A_SHARP, keys[NOTE_A_SHARP]);\n g.fillRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n if(keys[PianoNotes.NOTE_A_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n }\n final int hx1 = aax2;\n final int hy1 = aay2;\n final int hx2 = ax4 + whiteKeyWidth;\n final int hy2 = hy1;\n final int hx3 = hx2;\n final int hy3 = hy2 + whiteKeyHeight;\n final int hx4 = ax5;\n final int hy4 = hy3;\n final int hx5 = hx4;\n final int hy5 = ay4;\n final int hx6 = hx5 + blackKeyNarrowWidth;\n final int hy6 = hy5;\n setKeyColor(g, NOTE_H, keys[NOTE_H]);\n g.fillRect(hx1, hy1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(hx5, hy5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_H])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(hx1, hy1, hx2, hy2);\n g.drawLine(hx2, hy2, hx3, hy3);\n g.drawLine(hx3, hy3, hx4, hy4);\n g.drawLine(hx4, hy4, hx5, hy5);\n g.drawLine(hx5, hy5, hx6, hy6);\n g.drawLine(hx6, hy6, hx1, hy1);\n }\n g.setColor(CONTOUR_COLOR);\n final int dcyw = height;\n final int dcyb = dcyw - fontHeight;\n final int yl = cy6 + 5;\n final int dcylw = dcyb - 2;\n final int dcylb = dcylw - fontHeight;\n final int halfWhiteKeyWidth = whiteKeyWidth / 2;\n final int halfBlackKeyWidth = blackKeyWidth / 2;\n final int dccx1 = cx1 + halfWhiteKeyWidth;\n g.drawChar('1', dccx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dccx1, dcylw, dccx1, yl);\n final int dcccx1 = ccx1 + halfBlackKeyWidth;\n g.drawChar('2', dcccx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcccx1, dcylb, dcccx1, yl);\n final int dcdx1 = dx6 + halfWhiteKeyWidth;\n g.drawChar('3', dcdx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcdx1, dcylw, dcdx1, yl);\n final int dcddx1 = ddx1 + halfBlackKeyWidth;\n g.drawChar('4', dcddx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcddx1, dcylb, dcddx1, yl);\n final int dcex1 = ex4 + halfWhiteKeyWidth;\n g.drawChar('5', dcex1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcex1, dcylw, dcex1, yl);\n final int dcfx1 = fx1 + halfWhiteKeyWidth;\n g.drawChar('6', dcfx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcfx1, dcylw, dcfx1, yl);\n final int dcffx1 = ffx1 + halfBlackKeyWidth;\n g.drawChar('7', dcffx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcffx1, dcylb, dcffx1, yl);\n final int dcgx1 = gx6 + halfWhiteKeyWidth;\n g.drawChar('8', dcgx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcgx1, dcylw, dcgx1, yl);\n final int dcggx1 = ggx1 + halfBlackKeyWidth;\n g.drawChar('9', dcggx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcggx1, dcylb, dcggx1, yl);\n final int dcax1 = ax6 + halfWhiteKeyWidth;\n g.drawChar('*', dcax1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcax1, dcylw, dcax1, yl);\n final int dcaax1 = aax1 + halfBlackKeyWidth;\n g.drawChar('0', dcaax1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcaax1, dcylb, dcaax1, yl);\n final int dchx1 = hx4 + halfWhiteKeyWidth;\n g.drawChar('#', dchx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dchx1, dcylw, dchx1, yl);\n }\n", "output": " public void paint(Graphics g)\n {\n final boolean[] keys = model.getCurrentOctaveKeys();\n final int width = getWidth();\n final int height = getHeight();\n final int fontHeight = g.getFont().getHeight();\n final int whiteKeyWidth = (width - MARGIN * 2) / 7;\n final int whiteKeyHeight = height -\n (MARGIN + KEYS_NOTES_DISTANCE + fontHeight * 2);\n final int blackKeyWidth = whiteKeyWidth / 2; \n final int blackKeyHeight = whiteKeyHeight / 2; \n final int blackKeyNarrowWidth = blackKeyWidth / 2;\n final int whiteKeyNarrowWidth = whiteKeyWidth - blackKeyNarrowWidth;\n final int whiteKeyLesserHeight = whiteKeyHeight - blackKeyHeight;\n g.setColor(WHITE_COLOR);\n g.fillRect(0, 0, width, height);\n final int cx1 = 0 + MARGIN;\n final int cy1 = 0 + MARGIN;\n final int cx2 = cx1 + whiteKeyNarrowWidth;\n final int cy2 = cy1;\n final int cx3 = cx2;\n final int cy3 = cy2 + blackKeyHeight;\n final int cx4 = cx1 + whiteKeyWidth;\n final int cy4 = cy3;\n final int cx5 = cx4;\n final int cy5 = cy1 + whiteKeyHeight;\n final int cx6 = cx1;\n final int cy6 = cy5;\n setKeyColor(g, NOTE_C, keys[NOTE_C]);\n g.fillRect(cx1, cy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(cx3, cy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_C])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(cx1, cy1, cx2, cy2);\n g.drawLine(cx2, cy2, cx3, cy3);\n g.drawLine(cx3, cy3, cx4, cy4);\n g.drawLine(cx4, cy4, cx5, cy5);\n g.drawLine(cx5, cy5, cx6, cy6);\n g.drawLine(cx6, cy6, cx1, cy1);\n }\n final int ccx1 = cx2;\n final int ccy1 = cy2;\n final int ccx2 = ccx1 + blackKeyWidth;\n final int ccy2 = ccy1;\n setKeyColor(g, NOTE_C_SHARP, keys[NOTE_C_SHARP]);\n g.fillRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_C_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n }\n final int dx1 = ccx2;\n final int dy1 = ccy2;\n final int dx2 = dx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int dy2 = dy1;\n final int dx3 = dx2;\n final int dy3 = dy2 + blackKeyHeight;\n final int dx4 = cx4 + whiteKeyWidth;\n final int dy4 = dy3;\n final int dx5 = dx4;\n final int dy5 = dy2 + whiteKeyHeight;\n final int dx6 = cx5;\n final int dy6 = dy5;\n final int dx7 = dx6;\n final int dy7 = dy3;\n final int dx8 = dx1;\n final int dy8 = dy3;\n setKeyColor(g, NOTE_D, keys[NOTE_D]);\n g.fillRect(dx1, dy1, dx2 - dx1, blackKeyHeight);\n g.fillRect(dx7, dy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_D])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(dx1, dy1, dx2, dy2);\n g.drawLine(dx2, dy2, dx3, dy3);\n g.drawLine(dx3, dy3, dx4, dy4);\n g.drawLine(dx4, dy4, dx5, dy5);\n g.drawLine(dx5, dy5, dx6, dy6);\n g.drawLine(dx6, dy6, dx7, dy7);\n g.drawLine(dx7, dy7, dx8, dy8);\n g.drawLine(dx8, dy8, dx1, dy1);\n }\n final int ddx1 = dx2;\n final int ddy1 = dy2;\n final int ddx2 = ddx1 + blackKeyWidth;\n final int ddy2 = ddy1;\n setKeyColor(g, NOTE_D_SHARP, keys[NOTE_D_SHARP]);\n g.fillRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_D_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n }\n final int ex1 = ddx2;\n final int ey1 = ddy2;\n final int ex2 = dx4 + whiteKeyWidth;\n final int ey2 = ey1;\n final int ex3 = ex2;\n final int ey3 = ey2 + whiteKeyHeight;\n final int ex4 = dx5;\n final int ey4 = ey3;\n final int ex5 = ex4;\n final int ey5 = dy4;\n final int ex6 = ex1;\n final int ey6 = ey5;\n setKeyColor(g, NOTE_E, keys[NOTE_E]);\n g.fillRect(ex1, ey1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(ex5, ey5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_E])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ex1, ey1, ex2, ey2);\n g.drawLine(ex2, ey2, ex3, ey3);\n g.drawLine(ex3, ey3, ex4, ey4);\n g.drawLine(ex4, ey4, ex5, ey5);\n g.drawLine(ex5, ey5, ex6, ey6);\n g.drawLine(ex6, ey6, ex1, ey1);\n }\n final int fx1 = ex2;\n final int fy1 = ey2;\n final int fx2 = fx1 + whiteKeyNarrowWidth;\n final int fy2 = fy1;\n final int fx3 = fx2;\n final int fy3 = fy2 + blackKeyHeight;\n final int fx4 = fx1 + whiteKeyWidth;\n final int fy4 = fy3;\n final int fx5 = fx4;\n final int fy5 = fy1 + whiteKeyHeight;\n final int fx6 = fx1;\n final int fy6 = fy5;\n setKeyColor(g, NOTE_F, keys[NOTE_F]);\n g.fillRect(fx1, fy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(fx3, fy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_F])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(fx1, fy1, fx2, fy2);\n g.drawLine(fx2, fy2, fx3, fy3);\n g.drawLine(fx3, fy3, fx4, fy4);\n g.drawLine(fx4, fy4, fx5, fy5);\n g.drawLine(fx5, fy5, fx6, fy6);\n g.drawLine(fx6, fy6, fx1, fy1);\n }\n final int ffx1 = fx2;\n final int ffy1 = fy2;\n final int ffx2 = ffx1 + blackKeyWidth;\n final int ffy2 = ffy1;\n setKeyColor(g, NOTE_F_SHARP, keys[NOTE_F_SHARP]);\n g.fillRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_F_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n }\n final int gx1 = ffx2;\n final int gy1 = ffy2;\n final int gx2 = gx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int gy2 = gy1;\n final int gx3 = gx2;\n final int gy3 = gy2 + blackKeyHeight;\n final int gx4 = fx4 + whiteKeyWidth;\n final int gy4 = gy3;\n final int gx5 = gx4;\n final int gy5 = gy2 + whiteKeyHeight;\n final int gx6 = fx5;\n final int gy6 = gy5;\n final int gx7 = gx6;\n final int gy7 = gy3;\n final int gx8 = gx1;\n final int gy8 = gy3;\n setKeyColor(g, NOTE_G, keys[NOTE_G]);\n g.fillRect(gx1, gy1, gx2 - gx1, blackKeyHeight);\n g.fillRect(gx7, gy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_G])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(gx1, gy1, gx2, gy2);\n g.drawLine(gx2, gy2, gx3, gy3);\n g.drawLine(gx3, gy3, gx4, gy4);\n g.drawLine(gx4, gy4, gx5, gy5);\n g.drawLine(gx5, gy5, gx6, gy6);\n g.drawLine(gx6, gy6, gx7, gy7);\n g.drawLine(gx7, gy7, gx8, gy8);\n g.drawLine(gx8, gy8, gx1, gy1);\n }\n final int ggx1 = gx2;\n final int ggy1 = gy2;\n final int ggx2 = ggx1 + blackKeyWidth;\n final int ggy2 = ggy1;\n setKeyColor(g, NOTE_G_SHARP, keys[NOTE_G_SHARP]);\n g.fillRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_G_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n }\n final int ax1 = ggx2;\n final int ay1 = ggy2;\n final int ax2 = ax1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int ay2 = ay1;\n final int ax3 = ax2;\n final int ay3 = ay2 + blackKeyHeight;\n final int ax4 = gx4 + whiteKeyWidth;\n final int ay4 = ay3;\n final int ax5 = ax4;\n final int ay5 = ay2 + whiteKeyHeight;\n final int ax6 = gx5;\n final int ay6 = ay5;\n final int ax7 = ax6;\n final int ay7 = ay3;\n final int ax8 = ax1;\n final int ay8 = ay3;\n setKeyColor(g, NOTE_A, keys[NOTE_A]);\n g.fillRect(ax1, ay1, ax2 - ax1, blackKeyHeight);\n g.fillRect(ax7, ay7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_A])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ax1, ay1, ax2, ay2);\n g.drawLine(ax2, ay2, ax3, ay3);\n g.drawLine(ax3, ay3, ax4, ay4);\n g.drawLine(ax4, ay4, ax5, ay5);\n g.drawLine(ax5, ay5, ax6, ay6);\n g.drawLine(ax6, ay6, ax7, ay7);\n g.drawLine(ax7, ay7, ax8, ay8);\n g.drawLine(ax8, ay8, ax1, ay1);\n }\n final int aax1 = ax2;\n final int aay1 = ay2;\n final int aax2 = aax1 + blackKeyWidth;\n final int aay2 = aay1;\n setKeyColor(g, NOTE_A_SHARP, keys[NOTE_A_SHARP]);\n g.fillRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n if(keys[PianoNotes.NOTE_A_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n }\n final int hx1 = aax2;\n final int hy1 = aay2;\n final int hx2 = ax4 + whiteKeyWidth;\n final int hy2 = hy1;\n final int hx3 = hx2;\n final int hy3 = hy2 + whiteKeyHeight;\n final int hx4 = ax5;\n final int hy4 = hy3;\n final int hx5 = hx4;\n final int hy5 = ay4;\n final int hx6 = hx1;\n final int hy6 = hy5;\n setKeyColor(g, NOTE_H, keys[NOTE_H]);\n g.fillRect(hx1, hy1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(hx5, hy5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_H])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(hx1, hy1, hx2, hy2);\n g.drawLine(hx2, hy2, hx3, hy3);\n g.drawLine(hx3, hy3, hx4, hy4);\n g.drawLine(hx4, hy4, hx5, hy5);\n g.drawLine(hx5, hy5, hx6, hy6);\n g.drawLine(hx6, hy6, hx1, hy1);\n }\n g.setColor(CONTOUR_COLOR);\n final int dcyw = height;\n final int dcyb = dcyw - fontHeight;\n final int yl = cy6 + 5;\n final int dcylw = dcyb - 2;\n final int dcylb = dcylw - fontHeight;\n final int halfWhiteKeyWidth = whiteKeyWidth / 2;\n final int halfBlackKeyWidth = blackKeyWidth / 2;\n final int dccx1 = cx1 + halfWhiteKeyWidth;\n g.drawChar('1', dccx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dccx1, dcylw, dccx1, yl);\n final int dcccx1 = ccx1 + halfBlackKeyWidth;\n g.drawChar('2', dcccx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcccx1, dcylb, dcccx1, yl);\n final int dcdx1 = dx6 + halfWhiteKeyWidth;\n g.drawChar('3', dcdx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcdx1, dcylw, dcdx1, yl);\n final int dcddx1 = ddx1 + halfBlackKeyWidth;\n g.drawChar('4', dcddx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcddx1, dcylb, dcddx1, yl);\n final int dcex1 = ex4 + halfWhiteKeyWidth;\n g.drawChar('5', dcex1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcex1, dcylw, dcex1, yl);\n final int dcfx1 = fx1 + halfWhiteKeyWidth;\n g.drawChar('6', dcfx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcfx1, dcylw, dcfx1, yl);\n final int dcffx1 = ffx1 + halfBlackKeyWidth;\n g.drawChar('7', dcffx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcffx1, dcylb, dcffx1, yl);\n final int dcgx1 = gx6 + halfWhiteKeyWidth;\n g.drawChar('8', dcgx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcgx1, dcylw, dcgx1, yl);\n final int dcggx1 = ggx1 + halfBlackKeyWidth;\n g.drawChar('9', dcggx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcggx1, dcylb, dcggx1, yl);\n final int dcax1 = ax6 + halfWhiteKeyWidth;\n g.drawChar('*', dcax1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcax1, dcylw, dcax1, yl);\n final int dcaax1 = aax1 + halfBlackKeyWidth;\n g.drawChar('0', dcaax1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcaax1, dcylb, dcaax1, yl);\n final int dchx1 = hx4 + halfWhiteKeyWidth;\n g.drawChar('#', dchx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dchx1, dcylw, dchx1, yl);\n }\n"} {"input": " public Object[] refreshDocument(DocumentRef ref, int refreshFlags,\n String[] schemas) throws ClientException {\n Object[] result = new Object[5];\n try {\n Document doc = resolveReference(ref);\n if (doc == null) {\n throw new ClientException(\"No Such Document: \" + ref);\n }\n boolean readPermChecked = false;\n if ((refreshFlags & DocumentModel.REFRESH_PREFETCH) != 0) {\n if (!readPermChecked) {\n checkPermission(doc, READ);\n readPermChecked = true;\n }\n PrefetchInfo info = doc.getType().getPrefetchInfo();\n if (info != null) {\n Schema[] pschemas = info.getSchemas();\n if (pschemas != null) {\n }\n Field[] fields = info.getFields();\n if (fields != null) {\n Map<String, Serializable> prefetch = new HashMap<String, Serializable>();\n for (Field field : fields) {\n Object value = doc.getPropertyValue(field.getName().getPrefixedName());\n prefetch.put(field.getDeclaringType().getName()\n + '.' + field.getName().getLocalName(),\n value == null ? Null.VALUE\n : (Serializable) value);\n }\n result[0] = prefetch;\n }\n }\n }\n if ((refreshFlags & DocumentModel.REFRESH_LOCK) != 0) {\n if (!readPermChecked) {\n checkPermission(doc, READ);\n readPermChecked = true;\n }\n result[1] = doc.getLock();\n }\n if ((refreshFlags & DocumentModel.REFRESH_LIFE_CYCLE) != 0) {\n checkPermission(doc, READ_LIFE_CYCLE);\n result[2] = doc.getCurrentLifeCycleState();\n result[3] = doc.getLifeCyclePolicy();\n }\n if ((refreshFlags & DocumentModel.REFRESH_ACP) != 0) {\n checkPermission(doc, READ_SECURITY);\n result[4] = getSession().getSecurityManager().getMergedACP(doc);\n }\n if ((refreshFlags & (DocumentModel.REFRESH_CONTENT)) != 0) {\n if (!readPermChecked) {\n checkPermission(doc, READ);\n readPermChecked = true;\n }\n if (schemas == null) {\n schemas = doc.getType().getSchemaNames();\n }\n DocumentType type = doc.getType();\n DocumentPart[] parts = new DocumentPart[schemas.length];\n for (int i = 0; i < schemas.length; i++) {\n DocumentPart part = new DocumentPartImpl(\n type.getSchema(schemas[i]));\n doc.readDocumentPart(part);\n parts[i] = part;\n }\n result[5] = parts;\n }\n } catch (ClientException e) {\n throw e;\n } catch (Exception e) {\n throw new ClientException(\"Failed to get refresh data\", e);\n }\n return result;\n }\n", "output": " public Object[] refreshDocument(DocumentRef ref, int refreshFlags,\n String[] schemas) throws ClientException {\n Object[] result = new Object[6];\n try {\n Document doc = resolveReference(ref);\n if (doc == null) {\n throw new ClientException(\"No Such Document: \" + ref);\n }\n boolean readPermChecked = false;\n if ((refreshFlags & DocumentModel.REFRESH_PREFETCH) != 0) {\n if (!readPermChecked) {\n checkPermission(doc, READ);\n readPermChecked = true;\n }\n PrefetchInfo info = doc.getType().getPrefetchInfo();\n if (info != null) {\n Schema[] pschemas = info.getSchemas();\n if (pschemas != null) {\n }\n Field[] fields = info.getFields();\n if (fields != null) {\n Map<String, Serializable> prefetch = new HashMap<String, Serializable>();\n for (Field field : fields) {\n Object value = doc.getPropertyValue(field.getName().getPrefixedName());\n prefetch.put(field.getDeclaringType().getName()\n + '.' + field.getName().getLocalName(),\n value == null ? Null.VALUE\n : (Serializable) value);\n }\n result[0] = prefetch;\n }\n }\n }\n if ((refreshFlags & DocumentModel.REFRESH_LOCK) != 0) {\n if (!readPermChecked) {\n checkPermission(doc, READ);\n readPermChecked = true;\n }\n result[1] = doc.getLock();\n }\n if ((refreshFlags & DocumentModel.REFRESH_LIFE_CYCLE) != 0) {\n checkPermission(doc, READ_LIFE_CYCLE);\n result[2] = doc.getCurrentLifeCycleState();\n result[3] = doc.getLifeCyclePolicy();\n }\n if ((refreshFlags & DocumentModel.REFRESH_ACP) != 0) {\n checkPermission(doc, READ_SECURITY);\n result[4] = getSession().getSecurityManager().getMergedACP(doc);\n }\n if ((refreshFlags & (DocumentModel.REFRESH_CONTENT)) != 0) {\n if (!readPermChecked) {\n checkPermission(doc, READ);\n readPermChecked = true;\n }\n if (schemas == null) {\n schemas = doc.getType().getSchemaNames();\n }\n DocumentType type = doc.getType();\n DocumentPart[] parts = new DocumentPart[schemas.length];\n for (int i = 0; i < schemas.length; i++) {\n DocumentPart part = new DocumentPartImpl(\n type.getSchema(schemas[i]));\n doc.readDocumentPart(part);\n parts[i] = part;\n }\n result[5] = parts;\n }\n } catch (ClientException e) {\n throw e;\n } catch (Exception e) {\n throw new ClientException(\"Failed to get refresh data\", e);\n }\n return result;\n }\n"} {"input": "\tpublic GNUScannerExtensionConfiguration() {\n\t\taddMacro(\"__complex__\", \"_Complex\");\n\t\taddMacro(\"__extension__\", \"\"); \n\t\taddMacro(\"__imag__\", \"(int)\"); \n\t\taddMacro(\"__real__\", \"(int)\");\n\t\taddMacro(\"__stdcall\", \"\");\n\t\taddMacro(\"__builtin_va_arg(ap,type)\", \"*(type *)ap\");\n\t\taddMacro(\"__builtin_constant_p(exp)\", \"0\");\n \taddPreprocessorKeyword(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next); \n \taddPreprocessorKeyword(Keywords.cIMPORT, IPreprocessorDirective.ppImport);\n \taddPreprocessorKeyword(Keywords.cWARNING, IPreprocessorDirective.ppWarning);\n \taddPreprocessorKeyword(Keywords.cIDENT, IPreprocessorDirective.ppIgnore);\n \taddPreprocessorKeyword(Keywords.cSCCS, IPreprocessorDirective.ppIgnore);\n \taddPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);\n \taddPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);\n\t\taddKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );\n\t\taddKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );\n\t\taddKeyword(GCCKeywords.cp__ASM, IToken.t_asm); \n\t\taddKeyword(GCCKeywords.cp__ASM__, IToken.t_asm); \n\t\taddKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );\n\t\taddKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );\n\t\taddKeyword(GCCKeywords.cp__CONST, IToken.t_const); \n\t\taddKeyword(GCCKeywords.cp__CONST__, IToken.t_const); \n\t\taddKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );\n\t\taddKeyword(GCCKeywords.cp__INLINE, IToken.t_inline); \n\t\taddKeyword(GCCKeywords.cp__INLINE__, IToken.t_inline); \n\t\taddKeyword(GCCKeywords.cp__RESTRICT, IToken.t_restrict); \n\t\taddKeyword(GCCKeywords.cp__RESTRICT__, IToken.t_restrict); \n\t\taddKeyword(GCCKeywords.cp__VOLATILE, IToken.t_volatile); \n\t\taddKeyword(GCCKeywords.cp__VOLATILE__, IToken.t_volatile); \n\t\taddKeyword(GCCKeywords.cp__SIGNED, IToken.t_signed); \n\t\taddKeyword(GCCKeywords.cp__SIGNED__, IToken.t_signed); \n\t\taddKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof); \n\t\taddKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof); \n\t\taddKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );\n\t}\n", "output": "\tpublic GNUScannerExtensionConfiguration() {\n\t\taddMacro(\"__complex__\", \"_Complex\");\n\t\taddMacro(\"__extension__\", \"\"); \n\t\taddMacro(\"__imag__\", \"(int)\"); \n\t\taddMacro(\"__real__\", \"(int)\");\n\t\taddMacro(\"__stdcall\", \"\");\n\t\taddMacro(\"__builtin_va_arg(ap,type)\", \"*(type *)ap\");\n\t\taddMacro(\"__builtin_constant_p(exp)\", \"0\");\n\t\taddMacro(\"__builtin_types_compatible_p(x,y)\", \"__builtin_types_compatible_p(sizeof(x),sizeof(y)\");\n \taddPreprocessorKeyword(Keywords.cINCLUDE_NEXT, IPreprocessorDirective.ppInclude_next); \n \taddPreprocessorKeyword(Keywords.cIMPORT, IPreprocessorDirective.ppImport);\n \taddPreprocessorKeyword(Keywords.cWARNING, IPreprocessorDirective.ppWarning);\n \taddPreprocessorKeyword(Keywords.cIDENT, IPreprocessorDirective.ppIgnore);\n \taddPreprocessorKeyword(Keywords.cSCCS, IPreprocessorDirective.ppIgnore);\n \taddPreprocessorKeyword(Keywords.cASSERT, IPreprocessorDirective.ppIgnore);\n \taddPreprocessorKeyword(Keywords.cUNASSERT, IPreprocessorDirective.ppIgnore);\n\t\taddKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );\n\t\taddKeyword(GCCKeywords.cp__ALIGNOF__, IGCCToken.t___alignof__ );\n\t\taddKeyword(GCCKeywords.cp__ASM, IToken.t_asm); \n\t\taddKeyword(GCCKeywords.cp__ASM__, IToken.t_asm); \n\t\taddKeyword(GCCKeywords.cp__ATTRIBUTE, IGCCToken.t__attribute__ );\n\t\taddKeyword(GCCKeywords.cp__ATTRIBUTE__, IGCCToken.t__attribute__ );\n\t\taddKeyword(GCCKeywords.cp__CONST, IToken.t_const); \n\t\taddKeyword(GCCKeywords.cp__CONST__, IToken.t_const); \n\t\taddKeyword(GCCKeywords.cp__DECLSPEC, IGCCToken.t__declspec );\n\t\taddKeyword(GCCKeywords.cp__INLINE, IToken.t_inline); \n\t\taddKeyword(GCCKeywords.cp__INLINE__, IToken.t_inline); \n\t\taddKeyword(GCCKeywords.cp__RESTRICT, IToken.t_restrict); \n\t\taddKeyword(GCCKeywords.cp__RESTRICT__, IToken.t_restrict); \n\t\taddKeyword(GCCKeywords.cp__VOLATILE, IToken.t_volatile); \n\t\taddKeyword(GCCKeywords.cp__VOLATILE__, IToken.t_volatile); \n\t\taddKeyword(GCCKeywords.cp__SIGNED, IToken.t_signed); \n\t\taddKeyword(GCCKeywords.cp__SIGNED__, IToken.t_signed); \n\t\taddKeyword(GCCKeywords.cp__TYPEOF, IGCCToken.t_typeof); \n\t\taddKeyword(GCCKeywords.cp__TYPEOF__, IGCCToken.t_typeof); \n\t\taddKeyword(GCCKeywords.cpTYPEOF, IGCCToken.t_typeof );\n\t}\n"} {"input": "\tpublic String getValueString() throws DebugException {\n\t\tif (!isAllocated()) {\n\t\t\treturn JDIDebugModelMessages.getString(\"JDIValue.deallocated\"); \n\t\t}\n\t\tif (fValue == null) {\n\t\t\treturn JDIDebugModelMessages.getString(\"JDIValue.null_4\"); \n\t\t}\n\t\tif (fValue instanceof StringReference) {\n\t\t\ttry {\n\t\t\t\treturn ((StringReference) fValue).value();\n\t\t\t} catch (RuntimeException e) {\n\t\t\t\ttargetRequestFailed(MessageFormat.format(JDIDebugModelMessages.getString(\"JDIValue.exception_retrieving_value\"), new String[] {e.toString()}), e); \n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tif (fValue instanceof ObjectReference) {\n\t\t\tStringBuffer name= new StringBuffer();\n\t\t\tif (fValue instanceof ClassObjectReference) {\n\t\t\t\tname.append('('); \n\t\t\t\tname.append(((ClassObjectReference)fValue).reflectedType());\n\t\t\t\tname.append(')'); \n\t\t\t}\n\t\t\tname.append(\" (\"); \n\t\t\tname.append(JDIDebugModelMessages.getString(\"JDIValue.id_8\")); \n\t\t\tname.append('='); \n\t\t\ttry {\n\t\t\t\tname.append(((ObjectReference)fValue).uniqueID());\n\t\t\t} catch (RuntimeException e) {\n\t\t\t\ttargetRequestFailed(MessageFormat.format(JDIDebugModelMessages.getString(\"JDIValue.exception_retrieving_unique_id\"), new String[] {e.toString()}), e); \n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tname.append(')'); \n\t\t\treturn name.toString();\n\t\t} else {\n\t\t\treturn fValue.toString();\n\t\t}\n\t}\n", "output": "\tpublic String getValueString() throws DebugException {\n\t\tif (!isAllocated()) {\n\t\t\treturn JDIDebugModelMessages.getString(\"JDIValue.deallocated\"); \n\t\t}\n\t\tif (fValue == null) {\n\t\t\treturn JDIDebugModelMessages.getString(\"JDIValue.null_4\"); \n\t\t}\n\t\tif (fValue instanceof StringReference) {\n\t\t\ttry {\n\t\t\t\treturn ((StringReference) fValue).value();\n\t\t\t} catch (RuntimeException e) {\n\t\t\t\ttargetRequestFailed(MessageFormat.format(JDIDebugModelMessages.getString(\"JDIValue.exception_retrieving_value\"), new String[] {e.toString()}), e); \n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tif (fValue instanceof ObjectReference) {\n\t\t\tStringBuffer name= new StringBuffer();\n\t\t\tif (fValue instanceof ClassObjectReference) {\n\t\t\t\tname.append('('); \n\t\t\t\tname.append(((ClassObjectReference)fValue).reflectedType());\n\t\t\t\tname.append(')'); \n\t\t\t}\n\t\t\tname.append(\" (\"); \n\t\t\tname.append(JDIDebugModelMessages.getString(\"JDIValue.id_8\")); \n\t\t\tname.append('='); \n\t\t\ttry {\n\t\t\t\tname.append(((ObjectReference)fValue).uniqueID());\n\t\t\t} catch (RuntimeException e) {\n\t\t\t\ttargetRequestFailed(MessageFormat.format(JDIDebugModelMessages.getString(\"JDIValue.exception_retrieving_unique_id\"), new String[] {e.toString()}), e); \n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tname.append(')'); \n\t\t\treturn name.toString();\n\t\t} else {\n\t\t\treturn String.valueOf(fValue);\n\t\t}\n\t}\n"} {"input": " private void initComponents() {\n java.awt.GridBagConstraints gridBagConstraints;\n exportPlace = new javax.swing.ButtonGroup();\n icon = new javax.swing.JPanel();\n jLabel48 = new javax.swing.JLabel();\n jLabel54 = new javax.swing.JLabel();\n iconCurrentCell = new javax.swing.JLabel();\n iconMakeIcon = new javax.swing.JButton();\n jSeparator11 = new javax.swing.JSeparator();\n iconInstancePos = new javax.swing.JComboBox();\n jLabel30 = new javax.swing.JLabel();\n jLabel31 = new javax.swing.JLabel();\n iconExportTechnology = new javax.swing.JComboBox();\n jPanel6 = new javax.swing.JPanel();\n iconDrawLeads = new javax.swing.JCheckBox();\n iconDrawBody = new javax.swing.JCheckBox();\n jLabel26 = new javax.swing.JLabel();\n iconLeadLength = new javax.swing.JTextField();\n iconLeadSpacing = new javax.swing.JTextField();\n jLabel27 = new javax.swing.JLabel();\n jLabel28 = new javax.swing.JLabel();\n iconExportPos = new javax.swing.JComboBox();\n jLabel29 = new javax.swing.JLabel();\n iconExportStyle = new javax.swing.JComboBox();\n iconsAlwaysDrawn = new javax.swing.JCheckBox();\n jLabel11 = new javax.swing.JLabel();\n iconTextSize = new javax.swing.JTextField();\n jPanel1 = new javax.swing.JPanel();\n iconPlaceByChar = new javax.swing.JRadioButton();\n iconPlaceByLoc = new javax.swing.JRadioButton();\n iconCharLabel1 = new javax.swing.JLabel();\n iconInputPos = new javax.swing.JComboBox();\n iconCharLabel4 = new javax.swing.JLabel();\n iconPowerPos = new javax.swing.JComboBox();\n iconGroundPos = new javax.swing.JComboBox();\n iconCharLabel5 = new javax.swing.JLabel();\n iconOutputPos = new javax.swing.JComboBox();\n iconCharLabel2 = new javax.swing.JLabel();\n iconCharLabel3 = new javax.swing.JLabel();\n iconBidirPos = new javax.swing.JComboBox();\n iconCharLabel6 = new javax.swing.JLabel();\n iconClockPos = new javax.swing.JComboBox();\n iconCharLabel7 = new javax.swing.JLabel();\n iconInputRot = new javax.swing.JComboBox();\n iconCharLabel8 = new javax.swing.JLabel();\n iconOutputRot = new javax.swing.JComboBox();\n iconCharLabel9 = new javax.swing.JLabel();\n iconBidirRot = new javax.swing.JComboBox();\n iconCharLabel10 = new javax.swing.JLabel();\n iconPowerRot = new javax.swing.JComboBox();\n iconCharLabel11 = new javax.swing.JLabel();\n iconGroundRot = new javax.swing.JComboBox();\n iconCharLabel12 = new javax.swing.JLabel();\n iconClockRot = new javax.swing.JComboBox();\n jSeparator1 = new javax.swing.JSeparator();\n iconLocLabel1 = new javax.swing.JLabel();\n iconLocLabel2 = new javax.swing.JLabel();\n iconLocLabel3 = new javax.swing.JLabel();\n iconLocLabel4 = new javax.swing.JLabel();\n iconTopRot = new javax.swing.JComboBox();\n iconBottomRot = new javax.swing.JComboBox();\n iconLeftRot = new javax.swing.JComboBox();\n iconRightRot = new javax.swing.JComboBox();\n iconReverseOrder = new javax.swing.JCheckBox();\n getContentPane().setLayout(new java.awt.GridBagLayout());\n setTitle(\"Edit Options\");\n setName(\"\");\n addWindowListener(new java.awt.event.WindowAdapter() {\n public void windowClosing(java.awt.event.WindowEvent evt) {\n closeDialog(evt);\n }\n });\n icon.setLayout(new java.awt.GridBagLayout());\n jLabel48.setText(\"Rules for automatic icon generation\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel48, gridBagConstraints);\n jLabel54.setText(\"Current cell:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel54, gridBagConstraints);\n iconCurrentCell.setText(\" \");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 7;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconCurrentCell, gridBagConstraints);\n iconMakeIcon.setText(\"Make Icon\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconMakeIcon, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jSeparator11, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconInstancePos, gridBagConstraints);\n jLabel30.setText(\"Export technology:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel30, gridBagConstraints);\n jLabel31.setText(\"Instance location:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel31, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconExportTechnology, gridBagConstraints);\n jPanel6.setLayout(new java.awt.GridBagLayout());\n jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Body and Leads\"));\n iconDrawLeads.setText(\"Draw leads\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconDrawLeads, gridBagConstraints);\n iconDrawBody.setText(\"Draw body\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.gridwidth = 5;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconDrawBody, gridBagConstraints);\n jLabel26.setText(\"Lead length:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel26, gridBagConstraints);\n iconLeadLength.setColumns(8);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.5;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconLeadLength, gridBagConstraints);\n iconLeadSpacing.setColumns(8);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 4;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.5;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconLeadSpacing, gridBagConstraints);\n jLabel27.setText(\"Lead spacing:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel27, gridBagConstraints);\n jLabel28.setText(\"Export location:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel28, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 1.0;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconExportPos, gridBagConstraints);\n jLabel29.setText(\"Export style:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel29, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 1.0;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconExportStyle, gridBagConstraints);\n iconsAlwaysDrawn.setText(\"Make exports \\\"Always Drawn\\\"\");\n iconsAlwaysDrawn.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));\n iconsAlwaysDrawn.setMargin(new java.awt.Insets(0, 0, 0, 0));\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconsAlwaysDrawn, gridBagConstraints);\n jLabel11.setText(\"Text size:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel11, gridBagConstraints);\n iconTextSize.setColumns(8);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconTextSize, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n icon.add(jPanel6, gridBagConstraints);\n jPanel1.setLayout(new java.awt.GridBagLayout());\n jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Export location\"));\n exportPlace.add(iconPlaceByChar);\n iconPlaceByChar.setText(\"Place by Characteristic\");\n iconPlaceByChar.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));\n iconPlaceByChar.setMargin(new java.awt.Insets(0, 0, 0, 0));\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);\n jPanel1.add(iconPlaceByChar, gridBagConstraints);\n exportPlace.add(iconPlaceByLoc);\n iconPlaceByLoc.setText(\"Place by Location in Cell\");\n iconPlaceByLoc.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));\n iconPlaceByLoc.setMargin(new java.awt.Insets(0, 0, 0, 0));\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);\n jPanel1.add(iconPlaceByLoc, gridBagConstraints);\n iconCharLabel1.setText(\"Inputs on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconCharLabel1, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconInputPos, gridBagConstraints);\n iconCharLabel4.setText(\"Power on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel4, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconPowerPos, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconGroundPos, gridBagConstraints);\n iconCharLabel5.setText(\"Ground on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel5, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconOutputPos, gridBagConstraints);\n iconCharLabel2.setText(\"Outputs on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel2, gridBagConstraints);\n iconCharLabel3.setText(\"Bidir. on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel3, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconBidirPos, gridBagConstraints);\n iconCharLabel6.setText(\"Clock on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel6, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconClockPos, gridBagConstraints);\n iconCharLabel7.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconCharLabel7, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconInputRot, gridBagConstraints);\n iconCharLabel8.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel8, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconOutputRot, gridBagConstraints);\n iconCharLabel9.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel9, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconBidirRot, gridBagConstraints);\n iconCharLabel10.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel10, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconPowerRot, gridBagConstraints);\n iconCharLabel11.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel11, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconGroundRot, gridBagConstraints);\n iconCharLabel12.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel12, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconClockRot, gridBagConstraints);\n jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 4;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridheight = 8;\n gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;\n gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);\n jPanel1.add(jSeparator1, gridBagConstraints);\n iconLocLabel1.setText(\"Top text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconLocLabel1, gridBagConstraints);\n iconLocLabel2.setText(\"Bottom text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLocLabel2, gridBagConstraints);\n iconLocLabel3.setText(\"Left text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLocLabel3, gridBagConstraints);\n iconLocLabel4.setText(\"Right text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLocLabel4, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconTopRot, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconBottomRot, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLeftRot, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconRightRot, gridBagConstraints);\n iconReverseOrder.setText(\"Place Exports in Reverse Alphabetical Order\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 7;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel1.add(iconReverseOrder, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n icon.add(jPanel1, gridBagConstraints);\n getContentPane().add(icon, new java.awt.GridBagConstraints());\n pack();\n }\n", "output": " private void initComponents() {\n java.awt.GridBagConstraints gridBagConstraints;\n exportPlace = new javax.swing.ButtonGroup();\n icon = new javax.swing.JPanel();\n jLabel48 = new javax.swing.JLabel();\n jLabel54 = new javax.swing.JLabel();\n iconCurrentCell = new javax.swing.JLabel();\n iconMakeIcon = new javax.swing.JButton();\n jSeparator11 = new javax.swing.JSeparator();\n iconInstancePos = new javax.swing.JComboBox();\n jLabel30 = new javax.swing.JLabel();\n jLabel31 = new javax.swing.JLabel();\n iconExportTechnology = new javax.swing.JComboBox();\n jPanel6 = new javax.swing.JPanel();\n iconDrawLeads = new javax.swing.JCheckBox();\n iconDrawBody = new javax.swing.JCheckBox();\n jLabel26 = new javax.swing.JLabel();\n iconLeadLength = new javax.swing.JTextField();\n iconLeadSpacing = new javax.swing.JTextField();\n jLabel27 = new javax.swing.JLabel();\n jLabel28 = new javax.swing.JLabel();\n iconExportPos = new javax.swing.JComboBox();\n jLabel29 = new javax.swing.JLabel();\n iconExportStyle = new javax.swing.JComboBox();\n iconsAlwaysDrawn = new javax.swing.JCheckBox();\n jLabel11 = new javax.swing.JLabel();\n iconTextSize = new javax.swing.JTextField();\n jPanel1 = new javax.swing.JPanel();\n iconPlaceByChar = new javax.swing.JRadioButton();\n iconPlaceByLoc = new javax.swing.JRadioButton();\n iconCharLabel1 = new javax.swing.JLabel();\n iconInputPos = new javax.swing.JComboBox();\n iconCharLabel4 = new javax.swing.JLabel();\n iconPowerPos = new javax.swing.JComboBox();\n iconGroundPos = new javax.swing.JComboBox();\n iconCharLabel5 = new javax.swing.JLabel();\n iconOutputPos = new javax.swing.JComboBox();\n iconCharLabel2 = new javax.swing.JLabel();\n iconCharLabel3 = new javax.swing.JLabel();\n iconBidirPos = new javax.swing.JComboBox();\n iconCharLabel6 = new javax.swing.JLabel();\n iconClockPos = new javax.swing.JComboBox();\n iconCharLabel7 = new javax.swing.JLabel();\n iconInputRot = new javax.swing.JComboBox();\n iconCharLabel8 = new javax.swing.JLabel();\n iconOutputRot = new javax.swing.JComboBox();\n iconCharLabel9 = new javax.swing.JLabel();\n iconBidirRot = new javax.swing.JComboBox();\n iconCharLabel10 = new javax.swing.JLabel();\n iconPowerRot = new javax.swing.JComboBox();\n iconCharLabel11 = new javax.swing.JLabel();\n iconGroundRot = new javax.swing.JComboBox();\n iconCharLabel12 = new javax.swing.JLabel();\n iconClockRot = new javax.swing.JComboBox();\n jSeparator1 = new javax.swing.JSeparator();\n iconLocLabel1 = new javax.swing.JLabel();\n iconLocLabel2 = new javax.swing.JLabel();\n iconLocLabel3 = new javax.swing.JLabel();\n iconLocLabel4 = new javax.swing.JLabel();\n iconTopRot = new javax.swing.JComboBox();\n iconBottomRot = new javax.swing.JComboBox();\n iconLeftRot = new javax.swing.JComboBox();\n iconRightRot = new javax.swing.JComboBox();\n iconReverseOrder = new javax.swing.JCheckBox();\n getContentPane().setLayout(new java.awt.GridBagLayout());\n setTitle(\"Edit Options\");\n setName(\"\");\n addWindowListener(new java.awt.event.WindowAdapter() {\n public void windowClosing(java.awt.event.WindowEvent evt) {\n closeDialog(evt);\n }\n });\n icon.setLayout(new java.awt.GridBagLayout());\n jLabel48.setText(\"Rules for automatic icon generation\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel48, gridBagConstraints);\n jLabel54.setText(\"Current cell:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel54, gridBagConstraints);\n iconCurrentCell.setText(\" \");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconCurrentCell, gridBagConstraints);\n iconMakeIcon.setText(\"Make Icon\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconMakeIcon, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jSeparator11, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconInstancePos, gridBagConstraints);\n jLabel30.setText(\"Export technology:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel30, gridBagConstraints);\n jLabel31.setText(\"Instance location:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(jLabel31, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n icon.add(iconExportTechnology, gridBagConstraints);\n jPanel6.setLayout(new java.awt.GridBagLayout());\n jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Body and Leads\"));\n iconDrawLeads.setText(\"Draw leads\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconDrawLeads, gridBagConstraints);\n iconDrawBody.setText(\"Draw body\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.gridwidth = 5;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconDrawBody, gridBagConstraints);\n jLabel26.setText(\"Lead length:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel26, gridBagConstraints);\n iconLeadLength.setColumns(8);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.5;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconLeadLength, gridBagConstraints);\n iconLeadSpacing.setColumns(8);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 4;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.5;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconLeadSpacing, gridBagConstraints);\n jLabel27.setText(\"Lead spacing:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel27, gridBagConstraints);\n jLabel28.setText(\"Export location:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel28, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 1.0;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconExportPos, gridBagConstraints);\n jLabel29.setText(\"Export style:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel29, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 1.0;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconExportStyle, gridBagConstraints);\n iconsAlwaysDrawn.setText(\"Make exports \\\"Always Drawn\\\"\");\n iconsAlwaysDrawn.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));\n iconsAlwaysDrawn.setMargin(new java.awt.Insets(0, 0, 0, 0));\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconsAlwaysDrawn, gridBagConstraints);\n jLabel11.setText(\"Text size:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(jLabel11, gridBagConstraints);\n iconTextSize.setColumns(8);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel6.add(iconTextSize, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n icon.add(jPanel6, gridBagConstraints);\n jPanel1.setLayout(new java.awt.GridBagLayout());\n jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Export location\"));\n exportPlace.add(iconPlaceByChar);\n iconPlaceByChar.setText(\"Place by Characteristic\");\n iconPlaceByChar.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));\n iconPlaceByChar.setMargin(new java.awt.Insets(0, 0, 0, 0));\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);\n jPanel1.add(iconPlaceByChar, gridBagConstraints);\n exportPlace.add(iconPlaceByLoc);\n iconPlaceByLoc.setText(\"Place by Location in Cell\");\n iconPlaceByLoc.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));\n iconPlaceByLoc.setMargin(new java.awt.Insets(0, 0, 0, 0));\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridwidth = 2;\n gridBagConstraints.insets = new java.awt.Insets(2, 4, 4, 4);\n jPanel1.add(iconPlaceByLoc, gridBagConstraints);\n iconCharLabel1.setText(\"Inputs on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconCharLabel1, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconInputPos, gridBagConstraints);\n iconCharLabel4.setText(\"Power on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel4, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconPowerPos, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconGroundPos, gridBagConstraints);\n iconCharLabel5.setText(\"Ground on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel5, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconOutputPos, gridBagConstraints);\n iconCharLabel2.setText(\"Outputs on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel2, gridBagConstraints);\n iconCharLabel3.setText(\"Bidir. on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel3, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconBidirPos, gridBagConstraints);\n iconCharLabel6.setText(\"Clock on:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel6, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 1;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.weightx = 0.6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconClockPos, gridBagConstraints);\n iconCharLabel7.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconCharLabel7, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconInputRot, gridBagConstraints);\n iconCharLabel8.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel8, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconOutputRot, gridBagConstraints);\n iconCharLabel9.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel9, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconBidirRot, gridBagConstraints);\n iconCharLabel10.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel10, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconPowerRot, gridBagConstraints);\n iconCharLabel11.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel11, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 5;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconGroundRot, gridBagConstraints);\n iconCharLabel12.setText(\"Text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 2;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconCharLabel12, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 3;\n gridBagConstraints.gridy = 6;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconClockRot, gridBagConstraints);\n jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 4;\n gridBagConstraints.gridy = 0;\n gridBagConstraints.gridheight = 8;\n gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;\n gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);\n jPanel1.add(jSeparator1, gridBagConstraints);\n iconLocLabel1.setText(\"Top text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconLocLabel1, gridBagConstraints);\n iconLocLabel2.setText(\"Bottom text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLocLabel2, gridBagConstraints);\n iconLocLabel3.setText(\"Left text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLocLabel3, gridBagConstraints);\n iconLocLabel4.setText(\"Right text rotated:\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 5;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLocLabel4, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 1, 4);\n jPanel1.add(iconTopRot, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 2;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconBottomRot, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconLeftRot, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 6;\n gridBagConstraints.gridy = 4;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n gridBagConstraints.weightx = 0.2;\n gridBagConstraints.insets = new java.awt.Insets(1, 4, 1, 4);\n jPanel1.add(iconRightRot, gridBagConstraints);\n iconReverseOrder.setText(\"Place Exports in Reverse Alphabetical Order\");\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 7;\n gridBagConstraints.gridwidth = 4;\n gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;\n gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);\n jPanel1.add(iconReverseOrder, gridBagConstraints);\n gridBagConstraints = new java.awt.GridBagConstraints();\n gridBagConstraints.gridx = 0;\n gridBagConstraints.gridy = 1;\n gridBagConstraints.gridwidth = 3;\n gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;\n icon.add(jPanel1, gridBagConstraints);\n getContentPane().add(icon, new java.awt.GridBagConstraints());\n pack();\n }\n"} {"input": "\tprivate void handleCollectedData(EcoreModelResourceVisitor visitor) {\n\t\tfor (IFile f : visitor.getRemovedModelFiles()) {\n\t\t\tString workspacePath = getKeyPath(f);\n\t\t\tDescriptor d = pathToDescriptor.remove(workspacePath);\n\t\t\tif (d != null) {\n\t\t\t\tDescriptor d2 = uriToDescriptor.remove(d.nsURI);\n\t\t\t\tassert d2 == d;\n\t\t\t}\n\t\t\tdelist(d);\n\t\t}\n\t\tSet<IFile> filesToAdd = new HashSet<IFile>(visitor.getNewModelFiles());\n\t\tfor (IFile f : visitor.getChangedModelFiles()) {\n\t\t\tDescriptor d = pathToDescriptor.remove(getKeyPath(f));\n\t\t\tif (d != null) {\n\t\t\t\tDescriptor d2 = uriToDescriptor.remove(d.nsURI); \n\t\t\t\tassert d2 == d;\n\t\t\t\tdelist(d);\n\t\t\t}\n\t\t\tfilesToAdd.add(f);\n\t\t}\n\t\tfor (IFile f : filesToAdd) {\n\t\t\tif (shouldIgnoreWorkspaceMetamodel(f)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tResource r = attemptLoad(f);\n\t\t\t\tif (r != null && hasSuitableContent(r)) {\n\t\t\t\t\tDescriptor d = createDescriptor(f, r);\n\t\t\t\t\tassert d != null;\n\t\t\t\t\tpathToDescriptor.put(d.workspacePath, d);\n\t\t\t\t\turiToDescriptor.put(d.nsURI, d);\n\t\t\t\t}\n\t\t\t} catch (Exception ex) {\n\t\t\t\tex.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void handleCollectedData(EcoreModelResourceVisitor visitor) {\n\t\tfor (IFile f : visitor.getRemovedModelFiles()) {\n\t\t\tString workspacePath = getKeyPath(f);\n\t\t\tDescriptor d = pathToDescriptor.remove(workspacePath);\n\t\t\tif (d != null) {\n\t\t\t\tDescriptor d2 = uriToDescriptor.remove(d.nsURI);\n\t\t\t\tassert d2 == d;\n\t\t\t\tdelist(d);\n\t\t\t}\n\t\t}\n\t\tSet<IFile> filesToAdd = new HashSet<IFile>(visitor.getNewModelFiles());\n\t\tfor (IFile f : visitor.getChangedModelFiles()) {\n\t\t\tDescriptor d = pathToDescriptor.remove(getKeyPath(f));\n\t\t\tif (d != null) {\n\t\t\t\tDescriptor d2 = uriToDescriptor.remove(d.nsURI); \n\t\t\t\tassert d2 == d;\n\t\t\t\tdelist(d);\n\t\t\t}\n\t\t\tfilesToAdd.add(f);\n\t\t}\n\t\tfor (IFile f : filesToAdd) {\n\t\t\tif (shouldIgnoreWorkspaceMetamodel(f)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tResource r = attemptLoad(f);\n\t\t\t\tif (r != null && hasSuitableContent(r)) {\n\t\t\t\t\tDescriptor d = createDescriptor(f, r);\n\t\t\t\t\tassert d != null;\n\t\t\t\t\tpathToDescriptor.put(d.workspacePath, d);\n\t\t\t\t\turiToDescriptor.put(d.nsURI, d);\n\t\t\t\t}\n\t\t\t} catch (Exception ex) {\n\t\t\t\tex.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString areasInput;\n\t\tString seedInput;\n\t\tSystem.out.println(\"Areas to generate: \");\n\t\tSystem.out.println(\"Example: -4,-4,3,3;0,4,6,4\");\n\t\tSystem.out.print(\"Input: \");\n\t\tareasInput = in.nextLine();\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(\"Seed for terrain generation:\");\n\t\tSystem.out.println(\"Leave blank for random seed.\");\n\t\tSystem.out.print(\"Input: \");\n\t\tseedInput = in.nextLine();\n\t\tin.close();\n\t\tAreaInputParser aip = new AreaInputParser(\";\", \",\");\n\t\tArrayList<Area> areas = null;\n\t\ttry {\n\t\t\t areas = aip.parseInput(areasInput);\n\t\t} catch (InvalidInputException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tUtil.deleteFile(mainDir);\n\t\ttry {\n\t\t\tUtil.copyFileFromJar(jar_mcserver_b173, genDir + File.separator + mcserver_b173);\n\t\t\tUtil.copyFileFromJar(jar_mcserver_f152, conDir + File.separator + mcserver_f152);\n\t\t\tUtil.copyFileFromJar(jar_serverproperties_b173, genDir + File.separator + serverproperties_b173);\n\t\t\tUtil.copyFileFromJar(jar_levelDat_b173, genDirWorld + File.separator + levelDat_b173);\n\t\t} catch(FileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tGenerator generator = new Generator(seedInput);\n\t\tfor(Area area : areas) {\n\t\t\tgenerator.generate(area);\n\t\t}\n\t\tConverter converter = new Converter();\n\t\tconverter.convert(areas);\n\t}\n", "output": "\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString areasInput;\n\t\tString seedInput;\n\t\tSystem.out.println(\"Areas to generate: \");\n\t\tSystem.out.println(\"Example: -4,-4,3,3;0,4,6,4\");\n\t\tSystem.out.print(\"Input: \");\n\t\tareasInput = in.nextLine();\n\t\tSystem.out.println(\"\");\n\t\tSystem.out.println(\"Seed for terrain generation:\");\n\t\tSystem.out.println(\"Leave blank for random seed.\");\n\t\tSystem.out.print(\"Input: \");\n\t\tseedInput = in.nextLine();\n\t\tin.close();\n\t\tAreaInputParser aip = new AreaInputParser(\";\", \",\");\n\t\tArrayList<Area> areas = null;\n\t\ttry {\n\t\t\t areas = aip.parseInput(areasInput);\n\t\t} catch (InvalidInputException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tUtil.deleteFile(mainDir);\n\t\ttry {\n\t\t\tUtil.copyFileFromJar(jar_mcserver_b173, genDir + File.separator + mcserver_b173);\n\t\t\tUtil.copyFileFromJar(jar_mcserver_f152, conDir + File.separator + mcserver_f152);\n\t\t\tUtil.copyFileFromJar(jar_serverproperties_b173, genDir + File.separator + serverproperties_b173);\n\t\t\tUtil.copyFileFromJar(jar_levelDat_b173, genDirWorld + File.separator + levelDat_b173);\n\t\t\tUtil.copyFileFromJar(jar_levelDat_b173, conDirWorld + File.separator + levelDat_b173);\n\t\t} catch(FileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tGenerator generator = new Generator(seedInput);\n\t\tfor(Area area : areas) {\n\t\t\tgenerator.generate(area);\n\t\t}\n\t\tConverter converter = new Converter();\n\t\tconverter.convert(areas);\n\t}\n"} {"input": " protected QueryTask calculateMatches(Association as, PresentationContext pc,\n Attributes rq, Attributes keys) throws DicomServiceException {\n AttributesValidator validator = new AttributesValidator(keys);\n QueryRetrieveLevel level = QueryRetrieveLevel.valueOf(validator, qrLevels);\n String cuid = rq.getString(Tag.AffectedSOPClassUID);\n ExtendedNegotiation extNeg = as.getAAssociateAC().getExtNegotiationFor(cuid);\n EnumSet<QueryOption> queryOpts = QueryOption.toOptions(extNeg);\n boolean relational = queryOpts.contains(QueryOption.RELATIONAL);\n level.validateQueryKeys(validator, rootLevel, relational);\n ArchiveApplicationEntity ae = (ArchiveApplicationEntity) as.getApplicationEntity();\n QueryParam queryParam = ae.getQueryParam(codeManager, queryOpts, roles());\n try {\n ApplicationEntity sourceAE = aeCache.findApplicationEntity(as.getRemoteAET());\n if (sourceAE != null) {\n Device sourcDevice = sourceAE.getDevice();\n queryParam.setDefaultIssuerOfPatientID(\n sourcDevice.getIssuerOfPatientID());\n queryParam.setDefaultIssuerOfAccessionNumber(\n sourcDevice.getIssuerOfAccessionNumber());\n }\n IDWithIssuer pid = IDWithIssuer.pidWithIssuer(keys,\n queryParam.getDefaultIssuerOfPatientID());\n IDWithIssuer[] pids = pid == null \n ? IDWithIssuer.EMPTY\n : pixConsumer == null \n ? new IDWithIssuer[] { pid }\n : pixConsumer.pixQuery(ae, pid);\n CompositeQuery query = (CompositeQuery) JNDIUtils.lookup(CompositeQuery.JNDI_NAME);\n switch (level) {\n case PATIENT:\n query.findPatients(pids, keys, queryParam);\n break;\n case STUDY:\n query.findStudies(pids, keys, queryParam);\n break;\n case SERIES:\n query.findSeries(pids, keys, queryParam);\n break;\n default: \n query.findInstances(pids, keys, queryParam);\n break;\n }\n return new QueryTaskImpl(as, pc, rq, keys, query, queryParam, pids);\n } catch (Exception e) {\n throw new DicomServiceException(Status.UnableToProcess, e);\n }\n }\n", "output": " protected QueryTask calculateMatches(Association as, PresentationContext pc,\n Attributes rq, Attributes keys) throws DicomServiceException {\n AttributesValidator validator = new AttributesValidator(keys);\n QueryRetrieveLevel level = QueryRetrieveLevel.valueOf(validator, qrLevels);\n String cuid = rq.getString(Tag.AffectedSOPClassUID);\n ExtendedNegotiation extNeg = as.getAAssociateAC().getExtNegotiationFor(cuid);\n EnumSet<QueryOption> queryOpts = QueryOption.toOptions(extNeg);\n boolean relational = queryOpts.contains(QueryOption.RELATIONAL);\n level.validateQueryKeys(validator, rootLevel, relational);\n ArchiveApplicationEntity ae = (ArchiveApplicationEntity) as.getApplicationEntity();\n QueryParam queryParam = ae.getQueryParam(codeManager, queryOpts, roles());\n try {\n ApplicationEntity sourceAE = aeCache.get(as.getRemoteAET());\n if (sourceAE != null) {\n Device sourcDevice = sourceAE.getDevice();\n queryParam.setDefaultIssuerOfPatientID(\n sourcDevice.getIssuerOfPatientID());\n queryParam.setDefaultIssuerOfAccessionNumber(\n sourcDevice.getIssuerOfAccessionNumber());\n }\n IDWithIssuer pid = IDWithIssuer.pidWithIssuer(keys,\n queryParam.getDefaultIssuerOfPatientID());\n IDWithIssuer[] pids = pid == null \n ? IDWithIssuer.EMPTY\n : pixConsumer == null \n ? new IDWithIssuer[] { pid }\n : pixConsumer.pixQuery(ae, pid);\n CompositeQuery query = (CompositeQuery) JNDIUtils.lookup(CompositeQuery.JNDI_NAME);\n switch (level) {\n case PATIENT:\n query.findPatients(pids, keys, queryParam);\n break;\n case STUDY:\n query.findStudies(pids, keys, queryParam);\n break;\n case SERIES:\n query.findSeries(pids, keys, queryParam);\n break;\n default: \n query.findInstances(pids, keys, queryParam);\n break;\n }\n return new QueryTaskImpl(as, pc, rq, keys, query, queryParam, pids);\n } catch (Exception e) {\n throw new DicomServiceException(Status.UnableToProcess, e);\n }\n }\n"} {"input": "\tpublic void run() {\n\t\tProcessBuilder pb = new ProcessBuilder(cmdArray);\n\t\ttry {\n\t\t\tLOGGER.debug(\"Starting \" + cmdLine);\n\t\t\tif (params.outputFile != null && params.outputFile.getParentFile().isDirectory()) {\n\t\t\t\tpb.directory(params.outputFile.getParentFile());\n\t\t\t}\n\t\t\tif (params.workDir != null && params.workDir.isDirectory()) {\n\t\t\t\tpb.directory(params.workDir);\n\t\t\t}\n\t\t\tif (params.env != null && !params.env.isEmpty()) {\n\t\t\t\tMap<String,String> environment = pb.environment();\n\t\t\t\tString PATH = params.env.get(\"PATH\") + File.pathSeparator + environment.get(\"PATH\");\n\t\t\t\tenvironment.putAll(params.env);\n\t\t\t\tenvironment.put(\"PATH\", PATH);\n\t\t\t}\n\t\t\tprocess = pb.start();\n\t\t\tPMS.get().currentProcesses.add(process);\n\t\t\tstderrConsumer = keepStderr\n\t\t\t\t? new OutputTextConsumer(process.getErrorStream(), true)\n\t\t\t\t: new OutputTextLogger(process.getErrorStream());\n\t\t\tstderrConsumer.start();\n\t\t\toutConsumer = null;\n\t\t\tif (params.outputFile != null) {\n\t\t\t\tLOGGER.debug(\"Writing in \" + params.outputFile.getAbsolutePath());\n\t\t\t\toutConsumer = keepStdout\n\t\t\t\t\t? new OutputTextConsumer(process.getInputStream(), false)\n\t\t\t\t\t: new OutputTextLogger(process.getInputStream());\n\t\t\t} else if (params.input_pipes[0] != null) {\n\t\t\t\tLOGGER.debug(\"Reading pipe: \" + params.input_pipes[0].getInputPipe());\n\t\t\t\tbo = params.input_pipes[0].getDirectBuffer();\n\t\t\t\tif (bo == null || params.losslessaudio || params.lossyaudio || params.no_videoencode) {\n\t\t\t\t\tInputStream is = params.input_pipes[0].getInputStream();\n\t\t\t\t\toutConsumer = new OutputBufferConsumer((params.avidemux) ? new AviDemuxerInputStream(is, params, attachedProcesses) : is, params);\n\t\t\t\t\tbo = outConsumer.getBuffer();\n\t\t\t\t}\n\t\t\t\tbo.attachThread(this);\n\t\t\t\tnew OutputTextLogger(process.getInputStream()).start();\n\t\t\t} else if (params.log) {\n\t\t\t\toutConsumer = keepStdout\n\t\t\t\t\t? new OutputTextConsumer(process.getInputStream(), true)\n\t\t\t\t\t: new OutputTextLogger(process.getInputStream());\n\t\t\t} else {\n\t\t\t\toutConsumer = new OutputBufferConsumer(process.getInputStream(), params);\n\t\t\t\tbo = outConsumer.getBuffer();\n\t\t\t\tbo.attachThread(this);\n\t\t\t}\n\t\t\tif (params.stdin != null) {\n\t\t\t\tparams.stdin.push(process.getOutputStream());\n\t\t\t}\n\t\t\tif (outConsumer != null) {\n\t\t\t\toutConsumer.start();\n\t\t\t}\n\t\t\tInteger pid = ProcessUtil.getProcessID(process);\n\t\t\tif (pid != null) {\n\t\t\t\tLOGGER.debug(\"Unix process ID (\" + cmdArray[0] + \"): \" + pid);\n\t\t\t}\n\t\t\tProcessUtil.waitFor(process);\n\t\t\ttry {\n\t\t\t\tif (outConsumer != null) {\n\t\t\t\t\toutConsumer.join(1000);\n\t\t\t\t}\n\t\t\t} catch (InterruptedException e) {\n\t\t\t}\n\t\t\tif (bo != null) {\n\t\t\t\tbo.close();\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tLOGGER.error(\"Fatal error in process initialization: \", e);\n\t\t\tstopProcess();\n\t\t} finally {\n\t\t\tif (!destroyed && !params.noexitcheck) {\n\t\t\t\ttry {\n\t\t\t\t\tsuccess = true;\n\t\t\t\t\tif (process != null && process.exitValue() != 0) {\n\t\t\t\t\t\tLOGGER.info(\"Process \" + cmdArray[0] + \" has a return code of \" + process.exitValue() + \"! Maybe an error occurred... check the log file\");\n\t\t\t\t\t\tsuccess = false;\n\t\t\t\t\t}\n\t\t\t\t} catch (IllegalThreadStateException itse) {\n\t\t\t\t\tLOGGER.error(\"An error occurred\", itse);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (attachedProcesses != null) {\n\t\t\t\tfor (ProcessWrapper pw : attachedProcesses) {\n\t\t\t\t\tif (pw != null) {\n\t\t\t\t\t\tpw.stopProcess();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tPMS.get().currentProcesses.remove(process);\n\t\t}\n\t}\n", "output": "\tpublic void run() {\n\t\tProcessBuilder pb = new ProcessBuilder(cmdArray);\n\t\ttry {\n\t\t\tLOGGER.debug(\"Starting \" + cmdLine);\n\t\t\tif (params.outputFile != null && params.outputFile.getParentFile().isDirectory()) {\n\t\t\t\tpb.directory(params.outputFile.getParentFile());\n\t\t\t}\n\t\t\tif (params.workDir != null && params.workDir.isDirectory()) {\n\t\t\t\tpb.directory(params.workDir);\n\t\t\t}\n\t\t\tif (params.env != null && !params.env.isEmpty()) {\n\t\t\t\tMap<String,String> environment = pb.environment();\n\t\t\t\tString sysPathKey = PMS.get().isWindows() ? \"Path\" : \"PATH\";\n\t\t\t\tString PATH = params.env.containsKey(\"PATH\") ? params.env.get(\"PATH\") :\n\t\t\t\t\tparams.env.containsKey(\"path\") ? params.env.get(\"path\") :\n\t\t\t\t\tparams.env.containsKey(\"Path\") ? params.env.get(\"Path\") : null;\n\t\t\t\tif (PATH != null) {\n\t\t\t\t\tPATH += (File.pathSeparator + environment.get(sysPathKey));\n\t\t\t\t}\n\t\t\t\tenvironment.putAll(params.env);\n\t\t\t\tif (PATH != null) {\n\t\t\t\t\tenvironment.put(sysPathKey, PATH);\n\t\t\t\t}\n\t\t\t}\n\t\t\tprocess = pb.start();\n\t\t\tPMS.get().currentProcesses.add(process);\n\t\t\tstderrConsumer = keepStderr\n\t\t\t\t? new OutputTextConsumer(process.getErrorStream(), true)\n\t\t\t\t: new OutputTextLogger(process.getErrorStream());\n\t\t\tstderrConsumer.start();\n\t\t\toutConsumer = null;\n\t\t\tif (params.outputFile != null) {\n\t\t\t\tLOGGER.debug(\"Writing in \" + params.outputFile.getAbsolutePath());\n\t\t\t\toutConsumer = keepStdout\n\t\t\t\t\t? new OutputTextConsumer(process.getInputStream(), false)\n\t\t\t\t\t: new OutputTextLogger(process.getInputStream());\n\t\t\t} else if (params.input_pipes[0] != null) {\n\t\t\t\tLOGGER.debug(\"Reading pipe: \" + params.input_pipes[0].getInputPipe());\n\t\t\t\tbo = params.input_pipes[0].getDirectBuffer();\n\t\t\t\tif (bo == null || params.losslessaudio || params.lossyaudio || params.no_videoencode) {\n\t\t\t\t\tInputStream is = params.input_pipes[0].getInputStream();\n\t\t\t\t\toutConsumer = new OutputBufferConsumer((params.avidemux) ? new AviDemuxerInputStream(is, params, attachedProcesses) : is, params);\n\t\t\t\t\tbo = outConsumer.getBuffer();\n\t\t\t\t}\n\t\t\t\tbo.attachThread(this);\n\t\t\t\tnew OutputTextLogger(process.getInputStream()).start();\n\t\t\t} else if (params.log) {\n\t\t\t\toutConsumer = keepStdout\n\t\t\t\t\t? new OutputTextConsumer(process.getInputStream(), true)\n\t\t\t\t\t: new OutputTextLogger(process.getInputStream());\n\t\t\t} else {\n\t\t\t\toutConsumer = new OutputBufferConsumer(process.getInputStream(), params);\n\t\t\t\tbo = outConsumer.getBuffer();\n\t\t\t\tbo.attachThread(this);\n\t\t\t}\n\t\t\tif (params.stdin != null) {\n\t\t\t\tparams.stdin.push(process.getOutputStream());\n\t\t\t}\n\t\t\tif (outConsumer != null) {\n\t\t\t\toutConsumer.start();\n\t\t\t}\n\t\t\tInteger pid = ProcessUtil.getProcessID(process);\n\t\t\tif (pid != null) {\n\t\t\t\tLOGGER.debug(\"Unix process ID (\" + cmdArray[0] + \"): \" + pid);\n\t\t\t}\n\t\t\tProcessUtil.waitFor(process);\n\t\t\ttry {\n\t\t\t\tif (outConsumer != null) {\n\t\t\t\t\toutConsumer.join(1000);\n\t\t\t\t}\n\t\t\t} catch (InterruptedException e) {\n\t\t\t}\n\t\t\tif (bo != null) {\n\t\t\t\tbo.close();\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tLOGGER.error(\"Fatal error in process initialization: \", e);\n\t\t\tstopProcess();\n\t\t} finally {\n\t\t\tif (!destroyed && !params.noexitcheck) {\n\t\t\t\ttry {\n\t\t\t\t\tsuccess = true;\n\t\t\t\t\tif (process != null && process.exitValue() != 0) {\n\t\t\t\t\t\tLOGGER.info(\"Process \" + cmdArray[0] + \" has a return code of \" + process.exitValue() + \"! Maybe an error occurred... check the log file\");\n\t\t\t\t\t\tsuccess = false;\n\t\t\t\t\t}\n\t\t\t\t} catch (IllegalThreadStateException itse) {\n\t\t\t\t\tLOGGER.error(\"An error occurred\", itse);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (attachedProcesses != null) {\n\t\t\t\tfor (ProcessWrapper pw : attachedProcesses) {\n\t\t\t\t\tif (pw != null) {\n\t\t\t\t\t\tpw.stopProcess();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tPMS.get().currentProcesses.remove(process);\n\t\t}\n\t}\n"} {"input": " private void init() {\n sApp = this;\n sSystemProperties = new Properties();\n readSystemProperties();\n sIsDebuggable = (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE));\n sIsDeviceRooted = areShellCommandsPresent();\n loadOptionalCommands();\n Preferences.loadDefaults();\n AIDHelper.getAIDs(getApplicationContext(), true);\n String defaultValue = ((String)FileManagerSettings.\n SETTINGS_THEME.getDefaultValue());\n String value = Preferences.getSharedPreferences().getString(\n FileManagerSettings.SETTINGS_THEME.getId(),\n defaultValue);\n ThemeManager.getDefaultTheme(getApplicationContext());\n if (!ThemeManager.setCurrentTheme(getApplicationContext(), value)) {\n ThemeManager.setCurrentTheme(getApplicationContext(), defaultValue);\n try {\n Preferences.savePreference(\n FileManagerSettings.SETTINGS_THEME, defaultValue, true);\n } catch (Throwable ex) {\n Log.w(TAG, \"can't save theme preference\", ex); \n }\n }\n Theme theme = ThemeManager.getCurrentTheme(getApplicationContext());\n theme.setBaseTheme(getApplicationContext(), false);\n allocBackgroundConsole(getApplicationContext());\n try {\n MimeTypeHelper.loadMimeTypes(getApplicationContext());\n } catch (Exception e) {\n Log.e(TAG, \"Mime-types failed.\", e); \n }\n }\n", "output": " private void init() {\n sApp = this;\n sSystemProperties = new Properties();\n readSystemProperties();\n sIsDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));\n sIsDeviceRooted = areShellCommandsPresent();\n loadOptionalCommands();\n Preferences.loadDefaults();\n AIDHelper.getAIDs(getApplicationContext(), true);\n String defaultValue = ((String)FileManagerSettings.\n SETTINGS_THEME.getDefaultValue());\n String value = Preferences.getSharedPreferences().getString(\n FileManagerSettings.SETTINGS_THEME.getId(),\n defaultValue);\n ThemeManager.getDefaultTheme(getApplicationContext());\n if (!ThemeManager.setCurrentTheme(getApplicationContext(), value)) {\n ThemeManager.setCurrentTheme(getApplicationContext(), defaultValue);\n try {\n Preferences.savePreference(\n FileManagerSettings.SETTINGS_THEME, defaultValue, true);\n } catch (Throwable ex) {\n Log.w(TAG, \"can't save theme preference\", ex); \n }\n }\n Theme theme = ThemeManager.getCurrentTheme(getApplicationContext());\n theme.setBaseTheme(getApplicationContext(), false);\n allocBackgroundConsole(getApplicationContext());\n try {\n MimeTypeHelper.loadMimeTypes(getApplicationContext());\n } catch (Exception e) {\n Log.e(TAG, \"Mime-types failed.\", e); \n }\n }\n"} {"input": " private static void printTable(double[][] res, String file, String caption) throws Exception {\n double[][] res2 = new double[6][];\n int max = 0;\n for (int gap = 1; gap <= 3; gap++) {\n BufferedReader in = ReaderUtil.createInputReader(new File(\"res\", \"share_\" + file + \"_\" + gap + \".txt\"));\n double[] good = new double[100];\n double[] bad = new double[100];\n double[] both = new double[100];\n List<Double>[] percentage = new List[100];\n do {\n String s = in.readLine();\n if (s.contains(\",\")) {\n break;\n }\n if (s.indexOf(\" \") == 0) {\n break;\n }\n long[] data = CalculateRelation.getData(s);\n int pos = 2;\n int d = 1;\n while (pos < data.length) {\n max = Math.max(max, d);\n if (data[pos] == 0) {\n bad[d]++;\n } else if (data[pos + 1] <= data[pos]) {\n good[d]++;\n } else {\n both[d]++;\n }\n if (percentage[d] == null) {\n percentage[d] = new ArrayList<Double>();\n }\n percentage[d].add(data[pos] * 100.0d / (data[pos] + data[pos + 1]));\n d++;\n pos += 2;\n }\n } while (true);\n double[] ans = new double[max];\n for (int i = 1; i <= max; i++) {\n double total = 0;\n for (double v : percentage[i]) {\n total += v;\n }\n ans[i - 1] = total / percentage[i].size();\n }\n res[gap - 1] = ans;\n res2[2 * gap - 2 ] = new double[max];\n res2[2 * gap - 1] = new double[max];\n for (int i = 1; i <= max; i++) {\n double total = good[i] + bad[i] + both[i];\n res2[2 * gap - 2][i - 1] = 100 * good[i] / total;\n res2[2 * gap - 1][i - 1] = 100 * bad[i] / total;\n }\n }\n int width = 19;\n for (int start = 1; start <= max; start += width) {\n int end = Math.min(start + width - 1, max);\n System.out.print(\"\\\\begin{table}[ht]\\\\footnotesize\\n\" +\n \"\\\\vspace{3mm}\\n\" +\n \"{\\\\centering\\n\" +\n \"\\\\begin{center}\\n\" +\n \"\\\\begin{tabular}{|c|cc|c|\");\n for (int i = start; i <= end; i++) {\n System.out.print(\"c|\");\n }\n int cols = end - start + 1;\n System.out.println(\"}\\n\" +\n \" \\\\hline\\n\" +\n \" \\\\multicolumn{3}{|c|}{ } & \\\\multicolumn{ \" + cols + \"}{|c|}{$k$} \\\\\\\\\\n\" +\n \" \\\\cline{4-\" + (cols + 3) + \" }\\n\" +\n \" \\\\multicolumn{3}{|c|}{ } \");\n for (int i = start; i <= end; i++) {\n System.out.print(\" & \" + i);\n }\n for (int row = 0; row < 6; row++) {\n System.out.print(\"\\\\\\\\\\n\");\n if (row % 2 == 0) {\n System.out.print(\"\\\\hline\\n\" +\n \" \\\\multirow{2}{*}{\" + (row / 2 + 1) + \"-aa}& \\\\multirow{2}{*}{spectra (\\\\%)} \");\n } else {\n System.out.println(\" & \");\n }\n System.out.println(\" & \" + (row % 2 == 0 ? \"+\" : \"--\"));\n for (int i = start; i <= end; i++) {\n System.out.print(\" & \");\n if (res2[row].length > i - 1) {\n System.out.print(ValidTags.df.format(res2[row][i-1]));\n }\n }\n }\n System.out.println(\" \\\\\\\\\\n\" +\n \" \\\\hline\\n\" +\n \"\\\\end{tabular}\\n\" +\n \"\\\\end{center}\\n\" +\n \"\\\\par}\\n\" +\n \"\\\\centering\\n\");\n if (end == max) {\n System.out.println(\"\\\\caption{\" + caption + \"}\\n\");\n }\n System.out.println(\"\\\\vspace{3mm}\\n\" +\n \"\\\\label{table:all-top-scoring}\\n\" +\n \"\\\\end{table}\");\n }\n TexTableGenerator.tableId++;\n System.out.println(\"\\\\includegraphics{plots/\" + TexTableGenerator.tableId + \".eps}\\n\");\n int tableId = TexTableGenerator.tableId;\n PrintWriter dataFile = ReaderUtil.createOutputFile(new File(\"plots\", tableId + \".dat\"));\n PrintWriter gplFile = ReaderUtil.createOutputFile(new File(\"plots\", tableId + \".gpl\"));\n gplFile.print(\"set terminal postscript eps\\n\" +\n \"set out \\\"plots/\" + tableId + \".eps\\\"\\n\" +\n \"set ylabel \\\"Percentage of spectre\\\"\\n\" +\n \"set xlabel \\\"Tag length\\\"\\n\" +\n \"plot\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:2 title '1-aa tag correct' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:3 title '1-aa tag incorrect' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:4 title '2-aa tag correct' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:5 title '2-aa tag incorrect' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:6 title '3-aa tag correct' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:7 title '3-aa tag incorrect' with linespoints\");\n gplFile.close();\n for (int i = 1; i <=14; i++) {\n dataFile.print(i + \" \");\n for (int j = 0; j < 6; j++) {\n dataFile.print(res2[j].length > i - 1 ? (res2[j][i-1]): \" \");\n dataFile.print(\" \");\n }\n dataFile.println();\n }\n dataFile.close();\n }\n", "output": " private static void printTable(double[][] res, String file, String caption) throws Exception {\n double[][] res2 = new double[6][];\n int max = 0;\n for (int gap = 1; gap <= 3; gap++) {\n BufferedReader in = ReaderUtil.createInputReader(new File(\"res\", \"share_\" + file + \"_\" + gap + \".txt\"));\n double[] good = new double[100];\n double[] bad = new double[100];\n double[] both = new double[100];\n List<Double>[] percentage = new List[100];\n do {\n String s = in.readLine();\n if (s.contains(\",\")) {\n break;\n }\n if (s.indexOf(\" \") == 0) {\n break;\n }\n long[] data = CalculateRelation.getData(s);\n int pos = 2;\n int d = 1;\n while (pos < data.length) {\n max = Math.max(max, d);\n if (data[pos] == 0) {\n bad[d]++;\n } else if (data[pos + 1] <= data[pos]) {\n good[d]++;\n } else {\n both[d]++;\n }\n if (percentage[d] == null) {\n percentage[d] = new ArrayList<Double>();\n }\n percentage[d].add(data[pos] * 100.0d / (data[pos] + data[pos + 1]));\n d++;\n pos += 2;\n }\n } while (true);\n double[] ans = new double[max];\n for (int i = 1; i <= max; i++) {\n double total = 0;\n for (double v : percentage[i]) {\n total += v;\n }\n ans[i - 1] = total / percentage[i].size();\n }\n res[gap - 1] = ans;\n res2[2 * gap - 2 ] = new double[max];\n res2[2 * gap - 1] = new double[max];\n for (int i = 1; i <= max; i++) {\n double total = good[i] + bad[i] + both[i];\n res2[2 * gap - 2][i - 1] = 100 * good[i] / total;\n res2[2 * gap - 1][i - 1] = 100 * bad[i] / total;\n }\n }\n int width = 19;\n for (int start = 1; start <= max; start += width) {\n int end = Math.min(start + width - 1, max);\n System.out.print(\"\\\\begin{table}[ht]\\\\footnotesize\\n\" +\n \"\\\\vspace{3mm}\\n\" +\n \"{\\\\centering\\n\" +\n \"\\\\begin{center}\\n\" +\n \"\\\\begin{tabular}{|c|cc|c|\");\n for (int i = start; i <= end; i++) {\n System.out.print(\"c|\");\n }\n int cols = end - start + 1;\n System.out.println(\"}\\n\" +\n \" \\\\hline\\n\" +\n \" \\\\multicolumn{3}{|c|}{ } & \\\\multicolumn{ \" + cols + \"}{|c|}{$k$} \\\\\\\\\\n\" +\n \" \\\\cline{4-\" + (cols + 3) + \" }\\n\" +\n \" \\\\multicolumn{3}{|c|}{ } \");\n for (int i = start; i <= end; i++) {\n System.out.print(\" & \" + i);\n }\n for (int row = 0; row < 6; row++) {\n System.out.print(\"\\\\\\\\\\n\");\n if (row % 2 == 0) {\n System.out.print(\"\\\\hline\\n\" +\n \" \\\\multirow{2}{*}{\" + (row / 2 + 1) + \"-aa}& \\\\multirow{2}{*}{spectra (\\\\%)} \");\n } else {\n System.out.println(\" & \");\n }\n System.out.println(\" & \" + (row % 2 == 0 ? \"+\" : \"--\"));\n for (int i = start; i <= end; i++) {\n System.out.print(\" & \");\n if (res2[row].length > i - 1) {\n System.out.print(ValidTags.df.format(res2[row][i-1]));\n }\n }\n }\n System.out.println(\" \\\\\\\\\\n\" +\n \" \\\\hline\\n\" +\n \"\\\\end{tabular}\\n\" +\n \"\\\\end{center}\\n\" +\n \"\\\\par}\\n\" +\n \"\\\\centering\\n\");\n if (end == max) {\n System.out.println(\"\\\\caption{\" + caption + \"}\\n\");\n }\n System.out.println(\"\\\\vspace{3mm}\\n\" +\n \"\\\\label{table:all-top-scoring}\\n\" +\n \"\\\\end{table}\");\n }\n TexTableGenerator.tableId++;\n System.out.println(\"\\\\includegraphics{plots/\" + TexTableGenerator.tableId + \".eps}\\n\");\n int tableId = TexTableGenerator.tableId;\n PrintWriter dataFile = ReaderUtil.createOutputFile(new File(\"plots\", tableId + \".dat\"));\n PrintWriter gplFile = ReaderUtil.createOutputFile(new File(\"plots\", tableId + \".gpl\"));\n gplFile.print(\"set terminal postscript eps\\n\" +\n \"set out \\\"plots/\" + tableId + \".eps\\\"\\n\" +\n \"set ylabel \\\"Percentage of spectre\\\"\\n\" +\n \"set xlabel \\\"Tag length\\\"\\n\" +\n \"plot\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:2 title '1-aa +' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:3 title '1-aa -' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:4 title '2-aa +' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:5 title '2-aa -' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:6 title '3-aa +' with linespoints,\\\\\");\n gplFile.println(\"\\\"plots/\" + tableId + \".dat\\\" using 1:7 title '3-aa -' with linespoints\");\n gplFile.close();\n for (int i = 1; i <=14; i++) {\n dataFile.print(i + \" \");\n for (int j = 0; j < 6; j++) {\n dataFile.print(res2[j].length > i - 1 ? (res2[j][i-1]): \" \");\n dataFile.print(\" \");\n }\n dataFile.println();\n }\n dataFile.close();\n }\n"} {"input": " public static ContentSummary getInputSummary(Context ctx, MapredWork work, PathFilter filter)\n throws IOException {\n long[] summary = {0, 0, 0};\n List<String> pathNeedProcess = new ArrayList<String>();\n synchronized (getInputSummaryLock) {\n for (String path : work.getPathToAliases().keySet()) {\n Path p = new Path(path);\n if (filter != null && !filter.accept(p)) {\n continue;\n }\n ContentSummary cs = ctx.getCS(path);\n if (cs == null) {\n if (path == null) {\n continue;\n }\n pathNeedProcess.add(path);\n } else {\n summary[0] += cs.getLength();\n summary[1] += cs.getFileCount();\n summary[2] += cs.getDirectoryCount();\n }\n }\n final Map<String, ContentSummary> resultMap = new ConcurrentHashMap<String, ContentSummary>();\n ArrayList<Future<?>> results = new ArrayList<Future<?>>();\n final ThreadPoolExecutor executor;\n int maxThreads = ctx.getConf().getInt(\"mapred.dfsclient.parallelism.max\", 0);\n if (pathNeedProcess.size() > 1 && maxThreads > 1) {\n int numExecutors = Math.min(pathNeedProcess.size(), maxThreads);\n LOG.info(\"Using \" + numExecutors + \" threads for getContentSummary\");\n executor = new ThreadPoolExecutor(numExecutors, numExecutors, 60, TimeUnit.SECONDS,\n new LinkedBlockingQueue<Runnable>());\n } else {\n executor = null;\n }\n HiveInterruptCallback interrup = HiveInterruptUtils.add(new HiveInterruptCallback() {\n @Override\n public void interrupt() {\n if (executor != null) {\n executor.shutdownNow();\n }\n }\n });\n try {\n Configuration conf = ctx.getConf();\n JobConf jobConf = new JobConf(conf);\n for (String path : pathNeedProcess) {\n final Path p = new Path(path);\n final String pathStr = path;\n final Configuration myConf = conf;\n final JobConf myJobConf = jobConf;\n final PartitionDesc partDesc = work.getPathToPartitionInfo().get(\n p.toString());\n Runnable r = new Runnable() {\n public void run() {\n try {\n ContentSummary resultCs;\n Class<? extends InputFormat> inputFormatCls = partDesc\n .getInputFileFormatClass();\n InputFormat inputFormatObj = HiveInputFormat.getInputFormatFromCache(\n inputFormatCls, myJobConf);\n if (inputFormatObj instanceof ContentSummaryInputFormat) {\n resultCs = ((ContentSummaryInputFormat) inputFormatObj).getContentSummary(p,\n myJobConf);\n } else {\n FileSystem fs = p.getFileSystem(myConf);\n resultCs = fs.getContentSummary(p);\n }\n resultMap.put(pathStr, resultCs);\n } catch (IOException e) {\n LOG.info(\"Cannot get size of \" + pathStr + \". Safely ignored.\");\n }\n }\n };\n if (executor == null) {\n r.run();\n } else {\n Future<?> result = executor.submit(r);\n results.add(result);\n }\n }\n if (executor != null) {\n executor.shutdown();\n }\n HiveInterruptUtils.checkInterrupted();\n for (Map.Entry<String, ContentSummary> entry : resultMap.entrySet()) {\n ContentSummary cs = entry.getValue();\n summary[0] += cs.getLength();\n summary[1] += cs.getFileCount();\n summary[2] += cs.getDirectoryCount();\n ctx.addCS(entry.getKey(), cs);\n LOG.info(\"Cache Content Summary for \" + entry.getKey() + \" length: \" + cs.getLength()\n + \" file count: \"\n + cs.getFileCount() + \" directory count: \" + cs.getDirectoryCount());\n }\n return new ContentSummary(summary[0], summary[1], summary[2]);\n } finally {\n HiveInterruptUtils.remove(interrup);\n }\n }\n }\n", "output": " public static ContentSummary getInputSummary(Context ctx, MapredWork work, PathFilter filter)\n throws IOException {\n long[] summary = {0, 0, 0};\n List<String> pathNeedProcess = new ArrayList<String>();\n synchronized (getInputSummaryLock) {\n for (String path : work.getPathToAliases().keySet()) {\n Path p = new Path(path);\n if (filter != null && !filter.accept(p)) {\n continue;\n }\n ContentSummary cs = ctx.getCS(path);\n if (cs == null) {\n if (path == null) {\n continue;\n }\n pathNeedProcess.add(path);\n } else {\n summary[0] += cs.getLength();\n summary[1] += cs.getFileCount();\n summary[2] += cs.getDirectoryCount();\n }\n }\n final Map<String, ContentSummary> resultMap = new ConcurrentHashMap<String, ContentSummary>();\n ArrayList<Future<?>> results = new ArrayList<Future<?>>();\n final ThreadPoolExecutor executor;\n int maxThreads = ctx.getConf().getInt(\"mapred.dfsclient.parallelism.max\", 0);\n if (pathNeedProcess.size() > 1 && maxThreads > 1) {\n int numExecutors = Math.min(pathNeedProcess.size(), maxThreads);\n LOG.info(\"Using \" + numExecutors + \" threads for getContentSummary\");\n executor = new ThreadPoolExecutor(numExecutors, numExecutors, 60, TimeUnit.SECONDS,\n new LinkedBlockingQueue<Runnable>());\n } else {\n executor = null;\n }\n HiveInterruptCallback interrup = HiveInterruptUtils.add(new HiveInterruptCallback() {\n @Override\n public void interrupt() {\n if (executor != null) {\n executor.shutdownNow();\n }\n }\n });\n try {\n Configuration conf = ctx.getConf();\n JobConf jobConf = new JobConf(conf);\n for (String path : pathNeedProcess) {\n final Path p = new Path(path);\n final String pathStr = path;\n final Configuration myConf = conf;\n final JobConf myJobConf = jobConf;\n final PartitionDesc partDesc = work.getPathToPartitionInfo().get(\n p.toString());\n Runnable r = new Runnable() {\n public void run() {\n try {\n ContentSummary resultCs;\n Class<? extends InputFormat> inputFormatCls = partDesc\n .getInputFileFormatClass();\n InputFormat inputFormatObj = HiveInputFormat.getInputFormatFromCache(\n inputFormatCls, myJobConf);\n if (inputFormatObj instanceof ContentSummaryInputFormat) {\n resultCs = ((ContentSummaryInputFormat) inputFormatObj).getContentSummary(p,\n myJobConf);\n } else {\n FileSystem fs = p.getFileSystem(myConf);\n resultCs = fs.getContentSummary(p);\n }\n resultMap.put(pathStr, resultCs);\n } catch (IOException e) {\n LOG.info(\"Cannot get size of \" + pathStr + \". Safely ignored.\");\n }\n }\n };\n if (executor == null) {\n r.run();\n } else {\n Future<?> result = executor.submit(r);\n results.add(result);\n }\n }\n if (executor != null) {\n for (Future<?> result : results) {\n boolean executorDone = false;\n do {\n try {\n result.get();\n executorDone = true;\n } catch (InterruptedException e) {\n LOG.info(\"Interrupted when waiting threads: \", e);\n Thread.currentThread().interrupt();\n break;\n } catch (ExecutionException e) {\n throw new IOException(e);\n }\n } while (!executorDone);\n\t }\n executor.shutdown();\n }\n HiveInterruptUtils.checkInterrupted();\n for (Map.Entry<String, ContentSummary> entry : resultMap.entrySet()) {\n ContentSummary cs = entry.getValue();\n summary[0] += cs.getLength();\n summary[1] += cs.getFileCount();\n summary[2] += cs.getDirectoryCount();\n ctx.addCS(entry.getKey(), cs);\n LOG.info(\"Cache Content Summary for \" + entry.getKey() + \" length: \" + cs.getLength()\n + \" file count: \"\n + cs.getFileCount() + \" directory count: \" + cs.getDirectoryCount());\n }\n return new ContentSummary(summary[0], summary[1], summary[2]);\n } finally {\n HiveInterruptUtils.remove(interrup);\n }\n }\n }\n"} {"input": "\tpublic void runHarvest() throws SQLException, IOException, AuthorizeException\n\t{\n\t\tString oaiSource = harvestRow.getOaiSource();\n\t\tString oaiSetId = harvestRow.getOaiSetId();\n if(\"all\".equals(oaiSetId))\n {\n oaiSetId = null;\n }\n\t\tDate lastHarvestDate = harvestRow.getHarvestDate();\n\t\tString fromDate = null;\n\t\tif (lastHarvestDate != null)\n {\n fromDate = processDate(harvestRow.getHarvestDate());\n }\n\t\tDate startTime = new Date();\n\t\tString toDate = processDate(startTime,0);\n\t\tString dateGranularity;\n\t\ttry\n\t\t{\n\t\t\tString descMDPrefix = null;\n\t\t\tString OREPrefix;\n\t \ttry {\n\t \t\tdateGranularity = oaiGetDateGranularity(oaiSource);\n\t \t\tif (fromDate != null)\n {\n fromDate = fromDate.substring(0, dateGranularity.length());\n }\n\t \t\ttoDate = toDate.substring(0, dateGranularity.length());\n\t \t\tdescMDPrefix = oaiResolveNamespaceToPrefix(oaiSource, metadataNS.getURI());\n\t \t\tOREPrefix = oaiResolveNamespaceToPrefix(oaiSource, ORESerialNS.getURI());\n\t \t}\n\t \tcatch (FileNotFoundException fe) {\n\t \t\tlog.error(\"The OAI server did not respond.\");\n\t \t\tthrow new HarvestingException(\"The OAI server did not respond.\", fe);\n\t \t}\n\t \tcatch (ConnectException fe) {\n\t \t\tlog.error(\"The OAI server did not respond.\");\n\t \t\tthrow new HarvestingException(\"The OAI server did not respond.\", fe);\n\t \t}\n\t\t\tif (descMDPrefix == null) {\n\t\t\t\tlog.error(\"The OAI server does not support this metadata format\");\n\t\t\t\tthrow new HarvestingException(\"The OAI server does not support this metadata format: \" + metadataNS.getURI());\n\t\t\t}\n\t\t\tif (OREPrefix == null && harvestRow.getHarvestType() != HarvestedCollection.TYPE_DMD) {\n\t\t\t\tthrow new HarvestingException(\"The OAI server does not support ORE dissemination in the configured serialization format: \" + ORESerialNS.getURI());\n\t\t\t}\n\t\t\tDocument oaiResponse = null;\n\t\t\tElement root = null;\n\t\t\tString resumptionToken;\n\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_BUSY);\n\t\t\tharvestRow.setHarvestMessage(\"Collection is currently being harvested\");\n\t\t\tharvestRow.setHarvestStartTime(startTime);\n\t\t\tharvestRow.update();\n\t\t\tourContext.commit();\n\t\t\tint expirationInterval = ConfigurationManager.getIntProperty(\"oai\", \"harvester.threadTimeout\");\n\t \tif (expirationInterval == 0)\n {\n expirationInterval = 24;\n }\n\t\t\tCalendar calendar = Calendar.getInstance();\n\t\t\tcalendar.setTime(startTime);\n\t\t\tcalendar.add(Calendar.HOUR, expirationInterval);\n Date expirationTime = calendar.getTime();\n\t\t\tList<Element> records;\n\t\t\tSet<String> errorSet = new HashSet<String>();\n\t\t\tListRecords listRecords = new ListRecords(oaiSource, fromDate, toDate, oaiSetId, descMDPrefix);\n\t\t\tlog.debug(\"Harvesting request parameters: listRecords \" + oaiSource + \" \" + fromDate + \" \" + toDate + \" \" + oaiSetId + \" \" + descMDPrefix);\n\t\t\tif (listRecords != null)\n {\n log.info(\"HTTP Request: \" + listRecords.getRequestURL());\n }\n\t\t\twhile (listRecords != null)\n\t\t\t{\n\t\t\t\trecords = new ArrayList<Element>();\n\t\t\t\toaiResponse = db.build(listRecords.getDocument());\n\t\t\t\tif (listRecords.getErrors() != null && listRecords.getErrors().getLength() > 0)\n\t\t\t\t{\n\t\t\t\t\tfor (int i=0; i<listRecords.getErrors().getLength(); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tString errorCode = listRecords.getErrors().item(i).getAttributes().getNamedItem(\"code\").getTextContent();\n\t\t\t\t\t\terrorSet.add(errorCode);\n\t\t\t\t\t}\n\t\t\t\t\tif (errorSet.contains(\"noRecordsMatch\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tlog.info(\"noRecordsMatch: OAI server did not contain any updates\");\n\t\t\t\t\t\tharvestRow.setHarvestResult(new Date(), \"OAI server did not contain any updates\");\n\t\t\t\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_READY);\n\t\t\t\t\t\tharvestRow.update();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new HarvestingException(errorSet.toString());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\troot = oaiResponse.getRootElement();\n\t\t\t\t\trecords.addAll(root.getChild(\"ListRecords\", OAI_NS).getChildren(\"record\", OAI_NS));\n\t\t\t\t}\n\t\t\t\tif (records != null && records.size()>0)\n\t\t\t\t{\n\t\t\t\t\tlog.info(\"Found \" + records.size() + \" records to process\");\n\t\t\t\t\tfor (Element record : records) {\n\t\t\t\t\t\tif (HarvestScheduler.interrupt == HarvestScheduler.HARVESTER_INTERRUPT_STOP)\n {\n throw new HarvestingException(\"Harvest process for \" + targetCollection.getID() + \" interrupted by stopping the scheduler.\");\n }\n\t\t\t\t\t\tif (expirationTime.before(new Date()))\n {\n throw new HarvestingException(\"runHarvest method timed out for collection \" + targetCollection.getID());\n }\n\t\t\t\t\t\tprocessRecord(record,OREPrefix);\n\t\t\t\t\t\tourContext.commit();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresumptionToken = listRecords.getResumptionToken();\n\t\t\t\tif (resumptionToken == null || resumptionToken.length() == 0) {\n\t\t\t\t\tlistRecords = null;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlistRecords = new ListRecords(oaiSource, resumptionToken);\n\t\t\t\t}\n ourContext.turnOffAuthorisationSystem();\n\t\t\t\ttargetCollection.update();\n ourContext.restoreAuthSystemState();\n\t\t\t\tourContext.commit();\n\t\t\t}\n\t\t}\n\t\tcatch (HarvestingException hex) {\n\t\t\tlog.error(\"Harvesting error occured while processing an OAI record: \" + hex.getMessage());\n\t\t\tharvestRow.setHarvestMessage(\"Error occured while processing an OAI record\");\n\t\t\tif (harvestRow.getHarvestMessage().contains(\"Error\")) {\n\t\t\t\talertAdmin(HarvestedCollection.STATUS_OAI_ERROR, hex);\n\t\t\t}\n\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_OAI_ERROR);\n\t\t\treturn;\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tharvestRow.setHarvestMessage(\"Unknown error occured while generating an OAI response\");\n\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_UNKNOWN_ERROR);\n\t\t\talertAdmin(HarvestedCollection.STATUS_UNKNOWN_ERROR, ex);\n\t\t\tlog.error(\"Error occured while generating an OAI response: \" + ex.getMessage() + \" \" + ex.getCause());\n\t\t\tex.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tfinally {\n\t\t\tharvestRow.update();\n ourContext.turnOffAuthorisationSystem();\n\t\t\ttargetCollection.update();\n\t\t\tourContext.commit();\n\t\t\tourContext.restoreAuthSystemState();\n\t\t\tourContext.restoreAuthSystemState();\n\t\t}\n\t\tDate finishTime = new Date();\n\t\tlong timeTaken = finishTime.getTime() - startTime.getTime();\n\t\tharvestRow.setHarvestResult(startTime, \"Harvest from \" + oaiSource + \" successful\");\n\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_READY);\n\t\tlog.info(\"Harvest from \" + oaiSource + \" successful. The process took \" + timeTaken + \" milliseconds.\");\n\t\tharvestRow.update();\n\t\tourContext.commit();\n\t}\n", "output": "\tpublic void runHarvest() throws SQLException, IOException, AuthorizeException\n\t{\n\t\tString oaiSource = harvestRow.getOaiSource();\n\t\tString oaiSetId = harvestRow.getOaiSetId();\n if(\"all\".equals(oaiSetId))\n {\n oaiSetId = null;\n }\n\t\tDate lastHarvestDate = harvestRow.getHarvestDate();\n\t\tString fromDate = null;\n\t\tif (lastHarvestDate != null)\n {\n fromDate = processDate(harvestRow.getHarvestDate());\n }\n\t\tDate startTime = new Date();\n\t\tString toDate = processDate(startTime,0);\n\t\tString dateGranularity;\n\t\ttry\n\t\t{\n\t\t\tString descMDPrefix = null;\n\t\t\tString OREPrefix;\n\t \ttry {\n\t \t\tdateGranularity = oaiGetDateGranularity(oaiSource);\n\t \t\tif (fromDate != null)\n {\n fromDate = fromDate.substring(0, dateGranularity.length());\n }\n\t \t\ttoDate = toDate.substring(0, dateGranularity.length());\n\t \t\tdescMDPrefix = oaiResolveNamespaceToPrefix(oaiSource, metadataNS.getURI());\n\t \t\tOREPrefix = oaiResolveNamespaceToPrefix(oaiSource, ORESerialNS.getURI());\n\t \t}\n\t \tcatch (FileNotFoundException fe) {\n\t \t\tlog.error(\"The OAI server did not respond.\");\n\t \t\tthrow new HarvestingException(\"The OAI server did not respond.\", fe);\n\t \t}\n\t \tcatch (ConnectException fe) {\n\t \t\tlog.error(\"The OAI server did not respond.\");\n\t \t\tthrow new HarvestingException(\"The OAI server did not respond.\", fe);\n\t \t}\n\t\t\tif (descMDPrefix == null) {\n\t\t\t\tlog.error(\"The OAI server does not support this metadata format\");\n\t\t\t\tthrow new HarvestingException(\"The OAI server does not support this metadata format: \" + metadataNS.getURI());\n\t\t\t}\n\t\t\tif (OREPrefix == null && harvestRow.getHarvestType() != HarvestedCollection.TYPE_DMD) {\n\t\t\t\tthrow new HarvestingException(\"The OAI server does not support ORE dissemination in the configured serialization format: \" + ORESerialNS.getURI());\n\t\t\t}\n\t\t\tDocument oaiResponse = null;\n\t\t\tElement root = null;\n\t\t\tString resumptionToken;\n\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_BUSY);\n\t\t\tharvestRow.setHarvestMessage(\"Collection is currently being harvested\");\n\t\t\tharvestRow.setHarvestStartTime(startTime);\n\t\t\tharvestRow.update();\n\t\t\tourContext.commit();\n\t\t\tint expirationInterval = ConfigurationManager.getIntProperty(\"oai\", \"harvester.threadTimeout\");\n\t \tif (expirationInterval == 0)\n {\n expirationInterval = 24;\n }\n\t\t\tCalendar calendar = Calendar.getInstance();\n\t\t\tcalendar.setTime(startTime);\n\t\t\tcalendar.add(Calendar.HOUR, expirationInterval);\n Date expirationTime = calendar.getTime();\n\t\t\tList<Element> records;\n\t\t\tSet<String> errorSet = new HashSet<String>();\n\t\t\tListRecords listRecords = new ListRecords(oaiSource, fromDate, toDate, oaiSetId, descMDPrefix);\n\t\t\tlog.debug(\"Harvesting request parameters: listRecords \" + oaiSource + \" \" + fromDate + \" \" + toDate + \" \" + oaiSetId + \" \" + descMDPrefix);\n\t\t\tif (listRecords != null)\n {\n log.info(\"HTTP Request: \" + listRecords.getRequestURL());\n }\n\t\t\twhile (listRecords != null)\n\t\t\t{\n\t\t\t\trecords = new ArrayList<Element>();\n\t\t\t\toaiResponse = db.build(listRecords.getDocument());\n\t\t\t\tif (listRecords.getErrors() != null && listRecords.getErrors().getLength() > 0)\n\t\t\t\t{\n\t\t\t\t\tfor (int i=0; i<listRecords.getErrors().getLength(); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tString errorCode = listRecords.getErrors().item(i).getAttributes().getNamedItem(\"code\").getTextContent();\n\t\t\t\t\t\terrorSet.add(errorCode);\n\t\t\t\t\t}\n\t\t\t\t\tif (errorSet.contains(\"noRecordsMatch\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tlog.info(\"noRecordsMatch: OAI server did not contain any updates\");\n\t\t\t\t\t\tharvestRow.setHarvestResult(new Date(), \"OAI server did not contain any updates\");\n\t\t\t\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_READY);\n\t\t\t\t\t\tharvestRow.update();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new HarvestingException(errorSet.toString());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\troot = oaiResponse.getRootElement();\n\t\t\t\t\trecords.addAll(root.getChild(\"ListRecords\", OAI_NS).getChildren(\"record\", OAI_NS));\n\t\t\t\t}\n\t\t\t\tif (records != null && records.size()>0)\n\t\t\t\t{\n\t\t\t\t\tlog.info(\"Found \" + records.size() + \" records to process\");\n\t\t\t\t\tfor (Element record : records) {\n\t\t\t\t\t\tif (HarvestScheduler.interrupt == HarvestScheduler.HARVESTER_INTERRUPT_STOP)\n {\n throw new HarvestingException(\"Harvest process for \" + targetCollection.getID() + \" interrupted by stopping the scheduler.\");\n }\n\t\t\t\t\t\tif (expirationTime.before(new Date()))\n {\n throw new HarvestingException(\"runHarvest method timed out for collection \" + targetCollection.getID());\n }\n\t\t\t\t\t\tprocessRecord(record,OREPrefix);\n\t\t\t\t\t\tourContext.commit();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresumptionToken = listRecords.getResumptionToken();\n\t\t\t\tif (resumptionToken == null || resumptionToken.length() == 0) {\n\t\t\t\t\tlistRecords = null;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlistRecords = new ListRecords(oaiSource, resumptionToken);\n\t\t\t\t}\n ourContext.turnOffAuthorisationSystem();\n try {\n targetCollection.update();\n } finally {\n ourContext.restoreAuthSystemState();\n }\n\t\t\t\tourContext.commit();\n\t\t\t}\n\t\t}\n\t\tcatch (HarvestingException hex) {\n\t\t\tlog.error(\"Harvesting error occured while processing an OAI record: \" + hex.getMessage());\n\t\t\tharvestRow.setHarvestMessage(\"Error occured while processing an OAI record\");\n\t\t\tif (harvestRow.getHarvestMessage().contains(\"Error\")) {\n\t\t\t\talertAdmin(HarvestedCollection.STATUS_OAI_ERROR, hex);\n\t\t\t}\n\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_OAI_ERROR);\n\t\t\treturn;\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tharvestRow.setHarvestMessage(\"Unknown error occured while generating an OAI response\");\n\t\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_UNKNOWN_ERROR);\n\t\t\talertAdmin(HarvestedCollection.STATUS_UNKNOWN_ERROR, ex);\n\t\t\tlog.error(\"Error occured while generating an OAI response: \" + ex.getMessage() + \" \" + ex.getCause());\n\t\t\tex.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tfinally {\n\t\t\tharvestRow.update();\n ourContext.turnOffAuthorisationSystem();\n\t\t\ttargetCollection.update();\n\t\t\tourContext.commit();\n\t\t\tourContext.restoreAuthSystemState();\n\t\t}\n\t\tDate finishTime = new Date();\n\t\tlong timeTaken = finishTime.getTime() - startTime.getTime();\n\t\tharvestRow.setHarvestResult(startTime, \"Harvest from \" + oaiSource + \" successful\");\n\t\tharvestRow.setHarvestStatus(HarvestedCollection.STATUS_READY);\n\t\tlog.info(\"Harvest from \" + oaiSource + \" successful. The process took \" + timeTaken + \" milliseconds.\");\n\t\tharvestRow.update();\n\t\tourContext.commit();\n\t}\n"} {"input": " protected void addParameters(final Map<String, String> values) {\n LOG.info(\"Adding parameters\");\n Entity params = parameterService.getParameter();\n Entity currency = dataDefinitionService\n .get(SamplesConstants.BASIC_PLUGIN_IDENTIFIER, SamplesConstants.BASIC_MODEL_CURRENCY).find()\n .add(SearchRestrictions.eq(\"alphabeticCode\", values.get(\"code\"))).uniqueResult();\n params.setField(\"currency\", currency);\n params.setField(\"unit\", values.get(\"unit\"));\n params.setField(\"company\", getCompany(values.get(OWNER)));\n if (isEnabledOrEnabling(\"productionCounting\")) {\n params.setField(\"registerQuantityInProduct\", true);\n params.setField(\"registerQuantityOutProduct\", true);\n params.setField(\"registerProductionTime\", true);\n params.setField(\"justOne\", false);\n params.setField(\"allowToClose\", false);\n params.setField(\"autoCloseOrder\", false);\n }\n if (isEnabledOrEnabling(\"qualityControls\")) {\n params.setField(\"checkDoneOrderForQuality\", false);\n params.setField(\"autoGenerateQualityControl\", false);\n }\n if (isEnabledOrEnabling(\"genealogies\")) {\n params.setField(\"batchForDoneOrder\", \"01none\");\n }\n if (isEnabledOrEnabling(\"advancedGenealogy\")) {\n params.setField(\"batchNumberUniqueness\", \"01globally\");\n }\n if (isEnabledOrEnabling(\"advancedGenealogyForOrders\")) {\n params.setField(\"trackingRecordForOrderTreatment\", \"01duringProduction\");\n params.setField(\"batchNumberRequiredInputProducts\", false);\n }\n if (isEnabledOrEnabling(\"materialRequirements\")) {\n params.setField(\"inputProductsRequiredForType\", \"01startOrder\");\n }\n if (isEnabledOrEnabling(\"materialFlowResources\")) {\n params.setField(\"changeDateWhenTransferToWarehouseType\", \"01never\");\n }\n params.getDataDefinition().save(params);\n }\n", "output": " protected void addParameters(final Map<String, String> values) {\n LOG.info(\"Adding parameters\");\n Entity params = parameterService.getParameter();\n Entity currency = dataDefinitionService\n .get(SamplesConstants.BASIC_PLUGIN_IDENTIFIER, SamplesConstants.BASIC_MODEL_CURRENCY).find()\n .add(SearchRestrictions.eq(\"alphabeticCode\", values.get(\"code\"))).uniqueResult();\n params.setField(\"currency\", currency);\n params.setField(\"unit\", values.get(\"unit\"));\n params.setField(\"company\", getCompany(values.get(OWNER)));\n if (isEnabledOrEnabling(\"productionCounting\")) {\n params.setField(\"typeOfProductionRecording\", \"02cumulated\");\n params.setField(\"registerQuantityInProduct\", true);\n params.setField(\"registerQuantityOutProduct\", true);\n params.setField(\"registerProductionTime\", true);\n params.setField(\"justOne\", false);\n params.setField(\"allowToClose\", false);\n params.setField(\"autoCloseOrder\", false);\n }\n if (isEnabledOrEnabling(\"qualityControls\")) {\n params.setField(\"checkDoneOrderForQuality\", false);\n params.setField(\"autoGenerateQualityControl\", false);\n }\n if (isEnabledOrEnabling(\"genealogies\")) {\n params.setField(\"batchForDoneOrder\", \"01none\");\n }\n if (isEnabledOrEnabling(\"advancedGenealogy\")) {\n params.setField(\"batchNumberUniqueness\", \"01globally\");\n }\n if (isEnabledOrEnabling(\"advancedGenealogyForOrders\")) {\n params.setField(\"trackingRecordForOrderTreatment\", \"01duringProduction\");\n params.setField(\"batchNumberRequiredInputProducts\", false);\n }\n if (isEnabledOrEnabling(\"materialRequirements\")) {\n params.setField(\"inputProductsRequiredForType\", \"01startOrder\");\n }\n if (isEnabledOrEnabling(\"materialFlowResources\")) {\n params.setField(\"changeDateWhenTransferToWarehouseType\", \"01never\");\n }\n params.getDataDefinition().save(params);\n }\n"} {"input": "public static String\ndump(String description, byte [] b, int offset, int length) {\n\tStringBuffer sb = new StringBuffer();\n\tsb.append(length);\n\tsb.append(\" bytes\");\n\tif (description != null) {\n\t\tsb.append(\" (\");\n\t\tsb.append(description);\n\t\tsb.append(')');\n\t}\n\tsb.append(':');\n\tint prefixlen = sb.toString().length();\n\tprefixlen = (prefixlen + 8) & ~ 7;\n\tsb.append('\\t');\n\tint perline = (80 - prefixlen) / 3;\n\tfor (int i = 0; i < length; i++) {\n\t\tif (i != 0 && i % perline == 0) {\n\t\t\tfor (int j = 0; j < prefixlen; j+=8)\n\t\t\t\tsb.append(\"\\n\\t\");\n\t\t}\n\t\tint value = (int)(b[i + offset]) & 0xFF;\n\t\tif (value < 16)\n\t\t\tsb.append('0');\n\t\tsb.append(Integer.toHexString(value));\n\t\tsb.append(' ');\n\t}\n\tsb.append('\\n');\n\treturn sb.toString();\n}\n", "output": "public static String\ndump(String description, byte [] b, int offset, int length) {\n\tStringBuffer sb = new StringBuffer();\n\tsb.append(length);\n\tsb.append(\"b\");\n\tif (description != null) {\n\t\tsb.append(\" (\");\n\t\tsb.append(description);\n\t\tsb.append(')');\n\t}\n\tsb.append(':');\n\tint prefixlen = sb.toString().length();\n\tprefixlen = (prefixlen + 8) & ~ 7;\n\tsb.append('\\t');\n\tint perline = (80 - prefixlen) / 3;\n\tfor (int i = 0; i < length; i++) {\n\t\tif (i != 0 && i % perline == 0) {\n\t\t\tsb.append('\\n');\n\t\t\tfor (int j = 0; j < prefixlen; j+=8)\n\t\t\t\tsb.append('\\t');\n\t\t}\n\t\tint value = (int)(b[i + offset]) & 0xFF;\n\t\tif (value < 16)\n\t\t\tsb.append('0');\n\t\tsb.append(Integer.toHexString(value));\n\t\tsb.append(' ');\n\t}\n\tsb.append('\\n');\n\treturn sb.toString();\n}\n"} {"input": " public TvBookmarkMatch match(TvProgramme programme) {\n TvBookmarkMatch result = TvBookmarkMatch.FullMatch;\n boolean should = false;\n if (title == null)\n return TvBookmarkMatch.NoMatch;\n if (!title.equalsIgnoreCase(programme.getTitle())) {\n if (channelId != null && !programme.getChannel().isSameChannel(channelId))\n return TvBookmarkMatch.NoMatch;\n should = true;\n result = TvBookmarkMatch.ShouldMatch;\n } else {\n if (channelId != null && !programme.getChannel().isSameChannel(channelId))\n return TvBookmarkMatch.TitleMatch;\n }\n int start = getTimeOfDay(programme.getStart());\n int stop = getTimeOfDay(programme.getStop());\n int dayOfWeekMask = this.dayOfWeekMask;\n if (anyTime) {\n if (result == TvBookmarkMatch.ShouldMatch)\n return TvBookmarkMatch.NoMatch;\n } else if (startTime < stopTime) {\n if (start < startTime) {\n if (stop > startTime)\n result = TvBookmarkMatch.Underrun;\n else\n result = TvBookmarkMatch.TitleMatch;\n } else if (start >= stopTime) {\n result = TvBookmarkMatch.TitleMatch;\n } else if (stop < startTime || stop > stopTime) {\n result = TvBookmarkMatch.Overrun;\n }\n } else {\n if (start >= stopTime && start < startTime) {\n if (stop > startTime || stop <= stopTime)\n result = TvBookmarkMatch.Underrun;\n else if (stop >= stopTime && stop < start)\n result = TvBookmarkMatch.Underrun;\n else\n result = TvBookmarkMatch.TitleMatch;\n } else if (start < stopTime) {\n dayOfWeekMask = ((dayOfWeekMask << 1) |\n (dayOfWeekMask >> 6)) & 0xFE;\n if (stop > stopTime)\n result = TvBookmarkMatch.Overrun;\n } else {\n if (stop > stopTime && stop < startTime)\n result = TvBookmarkMatch.Overrun;\n }\n }\n int weekday = programme.getStart().get(Calendar.DAY_OF_WEEK);\n if (weekday == Calendar.SUNDAY)\n weekday = 7;\n else\n weekday = weekday - 1;\n if ((dayOfWeekMask & (1 << weekday)) == 0)\n result = TvBookmarkMatch.TitleMatch;\n if (should && (result == TvBookmarkMatch.Underrun || result == TvBookmarkMatch.Overrun))\n result = TvBookmarkMatch.ShouldMatch;\n if (should && result != TvBookmarkMatch.ShouldMatch)\n result = TvBookmarkMatch.NoMatch;\n if (!onAir && result == TvBookmarkMatch.ShouldMatch)\n result = TvBookmarkMatch.NoMatch;\n if (seasons != null && result != TvBookmarkMatch.ShouldMatch &&\n result != TvBookmarkMatch.NoMatch) {\n int season = programme.getSeason();\n int index;\n if (season != 0) {\n for (index = 0; index < seasons.size(); ++index) {\n if (season >= seasons.get(index).first &&\n season <= seasons.get(index).last)\n break;\n }\n if (index >= seasons.size())\n result = TvBookmarkMatch.NoMatch;\n } else {\n for (index = 0; index < seasons.size(); ++index) {\n if (seasons.get(index).last == Range.INFINITE)\n break;\n }\n if (index >= seasons.size())\n result = TvBookmarkMatch.NoMatch;\n }\n }\n if (years != null && result != TvBookmarkMatch.ShouldMatch &&\n result != TvBookmarkMatch.NoMatch) {\n int year = programme.getYear();\n int index;\n if (year != 0) {\n for (index = 0; index < years.size(); ++index) {\n if (year >= years.get(index).first &&\n year <= years.get(index).last)\n break;\n }\n if (index >= years.size())\n result = TvBookmarkMatch.NoMatch;\n } else {\n for (index = 0; index < years.size(); ++index) {\n if (years.get(index).last == Range.INFINITE)\n break;\n }\n if (index >= years.size())\n result = TvBookmarkMatch.NoMatch;\n }\n }\n return result;\n }\n", "output": " public TvBookmarkMatch match(TvProgramme programme) {\n TvBookmarkMatch result = TvBookmarkMatch.FullMatch;\n boolean should = false;\n if (title == null)\n return TvBookmarkMatch.NoMatch;\n if (!title.equalsIgnoreCase(programme.getTitle())) {\n if (channelId != null && !programme.getChannel().isSameChannel(channelId))\n return TvBookmarkMatch.NoMatch;\n should = true;\n result = TvBookmarkMatch.ShouldMatch;\n } else {\n if (channelId != null && !programme.getChannel().isSameChannel(channelId))\n result = TvBookmarkMatch.TitleMatch;\n }\n int start = getTimeOfDay(programme.getStart());\n int stop = getTimeOfDay(programme.getStop());\n int dayOfWeekMask = this.dayOfWeekMask;\n if (anyTime) {\n if (result == TvBookmarkMatch.ShouldMatch)\n return TvBookmarkMatch.NoMatch;\n } else if (startTime < stopTime) {\n if (start < startTime) {\n if (stop > startTime)\n result = TvBookmarkMatch.Underrun;\n else\n result = TvBookmarkMatch.TitleMatch;\n } else if (start >= stopTime) {\n result = TvBookmarkMatch.TitleMatch;\n } else if (stop < startTime || stop > stopTime) {\n result = TvBookmarkMatch.Overrun;\n }\n } else {\n if (start >= stopTime && start < startTime) {\n if (stop > startTime || stop <= stopTime)\n result = TvBookmarkMatch.Underrun;\n else if (stop >= stopTime && stop < start)\n result = TvBookmarkMatch.Underrun;\n else\n result = TvBookmarkMatch.TitleMatch;\n } else if (start < stopTime) {\n dayOfWeekMask = ((dayOfWeekMask << 1) |\n (dayOfWeekMask >> 6)) & 0xFE;\n if (stop > stopTime)\n result = TvBookmarkMatch.Overrun;\n } else {\n if (stop > stopTime && stop < startTime)\n result = TvBookmarkMatch.Overrun;\n }\n }\n int weekday = programme.getStart().get(Calendar.DAY_OF_WEEK);\n if (weekday == Calendar.SUNDAY)\n weekday = 7;\n else\n weekday = weekday - 1;\n if ((dayOfWeekMask & (1 << weekday)) == 0)\n result = TvBookmarkMatch.TitleMatch;\n if (should && (result == TvBookmarkMatch.Underrun || result == TvBookmarkMatch.Overrun))\n result = TvBookmarkMatch.ShouldMatch;\n if (should && result != TvBookmarkMatch.ShouldMatch)\n result = TvBookmarkMatch.NoMatch;\n if (!onAir && result == TvBookmarkMatch.ShouldMatch)\n result = TvBookmarkMatch.NoMatch;\n if (seasons != null && result != TvBookmarkMatch.ShouldMatch &&\n result != TvBookmarkMatch.NoMatch) {\n int season = programme.getSeason();\n int index;\n if (season != 0) {\n for (index = 0; index < seasons.size(); ++index) {\n if (season >= seasons.get(index).first &&\n season <= seasons.get(index).last)\n break;\n }\n if (index >= seasons.size())\n result = TvBookmarkMatch.NoMatch;\n } else {\n for (index = 0; index < seasons.size(); ++index) {\n if (seasons.get(index).last == Range.INFINITE)\n break;\n }\n if (index >= seasons.size())\n result = TvBookmarkMatch.NoMatch;\n }\n }\n if (years != null && result != TvBookmarkMatch.ShouldMatch &&\n result != TvBookmarkMatch.NoMatch) {\n int year = programme.getYear();\n int index;\n if (year != 0) {\n for (index = 0; index < years.size(); ++index) {\n if (year >= years.get(index).first &&\n year <= years.get(index).last)\n break;\n }\n if (index >= years.size())\n result = TvBookmarkMatch.NoMatch;\n } else {\n for (index = 0; index < years.size(); ++index) {\n if (years.get(index).last == Range.INFINITE)\n break;\n }\n if (index >= years.size())\n result = TvBookmarkMatch.NoMatch;\n }\n }\n return result;\n }\n"} {"input": "\tpublic static boolean addInstBeforeExpr(Expression expression,\n\t\t\tInstruction instruction, boolean usePreviousJoinNode) {\n\t\tInstruction instContainer = EcoreHelper.getContainerOfType(expression,\n\t\t\t\tInstruction.class);\n\t\tNode nodeContainer = EcoreHelper.getContainerOfType(expression,\n\t\t\t\tNode.class);\n\t\tif (instContainer != null) {\n\t\t\tif (usePreviousJoinNode && isWhileJoinNode(nodeContainer)) {\n\t\t\t\tNodeWhile nodeWhile = EcoreHelper.getContainerOfType(\n\t\t\t\t\t\tnodeContainer, NodeWhile.class);\n\t\t\t\taddToPreviousNodeBlock(nodeWhile, instruction);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tList<Instruction> instructions = EcoreHelper\n\t\t\t\t\t.getContainingList(instContainer);\n\t\t\tinstructions.add(instructions.indexOf(instContainer), instruction);\n\t\t\treturn true;\n\t\t} else {\n\t\t\tif (usePreviousJoinNode && nodeContainer.isWhileNode()) {\n\t\t\t\tNodeBlock joinNode = ((NodeWhile) nodeContainer).getJoinNode();\n\t\t\t\tjoinNode.add(instruction);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\taddToPreviousNodeBlock(nodeContainer, instruction);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic static boolean addInstBeforeExpr(Expression expression,\n\t\t\tInstruction instruction, boolean usePreviousJoinNode) {\n\t\tInstruction instContainer = EcoreHelper.getContainerOfType(expression,\n\t\t\t\tInstruction.class);\n\t\tNode nodeContainer = EcoreHelper.getContainerOfType(expression,\n\t\t\t\tNode.class);\n\t\tif (instContainer != null) {\n\t\t\tif (usePreviousJoinNode && instContainer.isPhi()\n\t\t\t\t\t&& isWhileJoinNode(nodeContainer)) {\n\t\t\t\tNodeWhile nodeWhile = EcoreHelper.getContainerOfType(\n\t\t\t\t\t\tnodeContainer, NodeWhile.class);\n\t\t\t\taddToPreviousNodeBlock(nodeWhile, instruction);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\tList<Instruction> instructions = EcoreHelper\n\t\t\t\t\t\t.getContainingList(instContainer);\n\t\t\t\tinstructions.add(instructions.indexOf(instContainer),\n\t\t\t\t\t\tinstruction);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tif (usePreviousJoinNode && nodeContainer.isWhileNode()) {\n\t\t\t\tNodeBlock joinNode = ((NodeWhile) nodeContainer).getJoinNode();\n\t\t\t\tjoinNode.add(instruction);\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\taddToPreviousNodeBlock(nodeContainer, instruction);\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " protected void configure(Configuration config) throws ConfigurationException, AccessManagementException {\n setID(config.getAttribute(ID));\n setName(config.getChild(NAME, false).getValue(null));\n if(config.getChild(EMAIL, false) != null){\n setEmail(config.getChild(EMAIL, false).getValue(null));\n }\n if(config.getChild(PASSWORD, false) != null){\n this.encryptedPassword = config.getChild(PASSWORD, false).getValue(null);\n }\n if(config.getChild(LANGUAGE, false) != null) {\n setLanguage(config.getChild(LANGUAGE, false).getValue(null));\n }\n if(config.getChild(SALT,false) != null) {\n this.salt = config.getChild(SALT, false).getValue(null);\n }\n if(config.getChild(DESCRIPTION, false) != null) {\n setDescription(config.getChild(DESCRIPTION, false).getValue(null));\n }\n if(config.getChild(EXPIRE, false) != null){\n SimpleDateFormat sdf1 = new SimpleDateFormat(DATE_TIME_FORMAT);\n SimpleDateFormat sdf2 = new SimpleDateFormat(DATE_FORMAT);\n String dateAsString = config.getChild(EXPIRE, false).getValue(null);\n Date expire = null;\n if(null != dateAsString){\n try {\n expire = sdf2.parse(dateAsString);\n } catch (ParseException e) {\n try {\n expire = sdf1.parse(dateAsString);\n } catch (ParseException e1) {\n log.error(e.getMessage() + \" (The user will be made expired)\");\n }finally{\n if(expire == null){\n GregorianCalendar cal = new GregorianCalendar();\n cal.add(Calendar.YEAR, -10);\n expire = cal.getTime();\n }else{\n }\n }\n }finally{\n this.setExpirationDate(expire);\n }\n }\n }\n Configuration groupsNode = config.getChild(GROUPS_TAG_NAME, false);\n if (groupsNode != null) {\n Configuration[] groupNodes = groupsNode.getChildren(GROUP_TAG_NAME);\n if (groupNodes != null && groupNodes.length > 0) {\n _groupIDs = new ArrayList();\n for (int i = 0; i < groupNodes.length; i++) {\n _groupIDs.add(groupNodes[i].getAttribute(GROUP_ID_ATTR_NAME));\n }\n } else {\n log.warn(\"DEBUG: User '\" + getID() + \"' does not seem to belong to any groups.\");\n }\n } else { \n log.warn(\"User '\" + getID() + \"' does seem to be an instance of a previous version without '\" + GROUPS_TAG_NAME + \"' tag and hence will be migrated automatically.\");\n if (true) {\n log.warn(\"Fix group index ...\");\n String[] gids = getGroupIDs(false);\n _groupIDs = new ArrayList();\n for (int i = 0; i < gids.length; i++) {\n _groupIDs.add(gids[i]);\n }\n save();\n }\n }\n }\n", "output": " protected void configure(Configuration config) throws ConfigurationException, AccessManagementException {\n setID(config.getAttribute(ID));\n setName(config.getChild(NAME, false).getValue(null));\n if(config.getChild(EMAIL, false) != null){\n setEmail(config.getChild(EMAIL, false).getValue(null));\n }\n if(config.getChild(PASSWORD, false) != null){\n this.encryptedPassword = config.getChild(PASSWORD, false).getValue(null);\n }\n if(config.getChild(LANGUAGE, false) != null) {\n setLanguage(config.getChild(LANGUAGE, false).getValue(null));\n }\n if(config.getChild(SALT,false) != null) {\n this.salt = config.getChild(SALT, false).getValue(null);\n }\n if(config.getChild(DESCRIPTION, false) != null) {\n setDescription(config.getChild(DESCRIPTION, false).getValue(null));\n }\n if(config.getChild(EXPIRE, false) != null){\n SimpleDateFormat sdf1 = new SimpleDateFormat(DATE_TIME_FORMAT);\n SimpleDateFormat sdf2 = new SimpleDateFormat(DATE_FORMAT);\n String dateAsString = config.getChild(EXPIRE, false).getValue(null);\n Date expire = null;\n if(null != dateAsString){\n try {\n expire = sdf2.parse(dateAsString);\n } catch (ParseException e) {\n try {\n expire = sdf1.parse(dateAsString);\n } catch (ParseException e1) {\n log.error(e.getMessage() + \" (The user will be made expired)\");\n }finally{\n if(expire == null){\n GregorianCalendar cal = new GregorianCalendar();\n cal.add(Calendar.YEAR, -10);\n expire = cal.getTime();\n }else{\n }\n }\n }finally{\n this.setExpirationDate(expire);\n }\n }\n }\n Configuration groupsNode = config.getChild(GROUPS_TAG_NAME, false);\n if (groupsNode != null) {\n _groupIDs = new ArrayList();\n Configuration[] groupNodes = groupsNode.getChildren(GROUP_TAG_NAME);\n if (groupNodes != null && groupNodes.length > 0) {\n for (int i = 0; i < groupNodes.length; i++) {\n _groupIDs.add(groupNodes[i].getAttribute(GROUP_ID_ATTR_NAME));\n }\n } else {\n log.warn(\"User '\" + getID() + \"' does not seem to belong to any groups.\");\n }\n } else { \n log.warn(\"User '\" + getID() + \"' does seem to be an instance of a previous version without '\" + GROUPS_TAG_NAME + \"' tag and hence will be migrated automatically.\");\n if (true) {\n log.warn(\"Fix group index ...\");\n String[] gids = getGroupIDs(false);\n _groupIDs = new ArrayList();\n for (int i = 0; i < gids.length; i++) {\n _groupIDs.add(gids[i]);\n }\n save();\n }\n }\n }\n"} {"input": " private void addConditions(net.homelinux.tobe.css.Selector s, Condition cond) {\n AttributeCondition attr = (AttributeCondition) cond;\n CombinatorCondition comb = (CombinatorCondition) cond;\n LangCondition lang = (LangCondition) cond;\n PositionalCondition pos = (PositionalCondition) cond;\n switch(cond.getConditionType()) {\n case Condition.SAC_AND_CONDITION:\n addConditions(s, comb.getFirstCondition());\n addConditions(s, comb.getSecondCondition());\n break;\n case Condition.SAC_ATTRIBUTE_CONDITION:\n if(attr.getSpecified()) {\n s.addAttributeEqualsCondition(attr.getLocalName(), attr.getValue());\n } else {\n s.addAttributeExistsCondition(attr.getLocalName());\n }\n break;\n case Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION:\n s.addAttributeMatchesFirstPartCondition(attr.getLocalName(), attr.getValue());\n break;\n case Condition.SAC_CLASS_CONDITION:\n s.addClassCondition(attr.getValue());\n break;\n case Condition.SAC_ID_CONDITION:\n s.addIDCondition(attr.getValue());\n break;\n case Condition.SAC_LANG_CONDITION:\n s.addLangCondition(lang.getLang());\n break;\n case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:\n s.addAttributeMatchesListCondition(attr.getLocalName(), attr.getValue());\n break;\n case Condition.SAC_POSITIONAL_CONDITION:\n s.addFirstChildCondition();\n break;\n case Condition.SAC_PSEUDO_CLASS_CONDITION:\n if(attr.getValue().equals(\"link\")) s.setPseudoClass(AttributeResolver.LINK_PSEUDOCLASS);\n if(attr.getValue().equals(\"visited\")) s.setPseudoClass(AttributeResolver.VISITED_PSEUDOCLASS);\n if(attr.getValue().equals(\"hover\")) s.setPseudoClass(AttributeResolver.HOVER_PSEUDOCLASS);\n if(attr.getValue().equals(\"active\")) s.setPseudoClass(AttributeResolver.ACTIVE_PSEUDOCLASS);\n if(attr.getValue().equals(\"focus\")) s.setPseudoClass(AttributeResolver.FOCUS_PSEUDOCLASS);\n break;\n default:\n System.err.println(\"Bad condition\");\n }\n }\n", "output": " private void addConditions(net.homelinux.tobe.css.Selector s, Condition cond) {\n switch(cond.getConditionType()) {\n case Condition.SAC_AND_CONDITION:\n CombinatorCondition comb = (CombinatorCondition) cond;\n addConditions(s, comb.getFirstCondition());\n addConditions(s, comb.getSecondCondition());\n break;\n case Condition.SAC_ATTRIBUTE_CONDITION:\n AttributeCondition attr = (AttributeCondition) cond;\n if(attr.getSpecified()) {\n s.addAttributeEqualsCondition(attr.getLocalName(), attr.getValue());\n } else {\n s.addAttributeExistsCondition(attr.getLocalName());\n }\n break;\n case Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION:\n attr = (AttributeCondition) cond;\n s.addAttributeMatchesFirstPartCondition(attr.getLocalName(), attr.getValue());\n break;\n case Condition.SAC_CLASS_CONDITION:\n attr = (AttributeCondition) cond;\n s.addClassCondition(attr.getValue());\n break;\n case Condition.SAC_ID_CONDITION:\n attr = (AttributeCondition) cond;\n s.addIDCondition(attr.getValue());\n break;\n case Condition.SAC_LANG_CONDITION:\n LangCondition lang = (LangCondition) cond;\n s.addLangCondition(lang.getLang());\n break;\n case Condition.SAC_ONE_OF_ATTRIBUTE_CONDITION:\n attr = (AttributeCondition) cond;\n s.addAttributeMatchesListCondition(attr.getLocalName(), attr.getValue());\n break;\n case Condition.SAC_POSITIONAL_CONDITION:\n PositionalCondition pos = (PositionalCondition) cond;\n s.addFirstChildCondition();\n break;\n case Condition.SAC_PSEUDO_CLASS_CONDITION:\n attr = (AttributeCondition) cond;\n if(attr.getValue().equals(\"link\")) s.setPseudoClass(AttributeResolver.LINK_PSEUDOCLASS);\n if(attr.getValue().equals(\"visited\")) s.setPseudoClass(AttributeResolver.VISITED_PSEUDOCLASS);\n if(attr.getValue().equals(\"hover\")) s.setPseudoClass(AttributeResolver.HOVER_PSEUDOCLASS);\n if(attr.getValue().equals(\"active\")) s.setPseudoClass(AttributeResolver.ACTIVE_PSEUDOCLASS);\n if(attr.getValue().equals(\"focus\")) s.setPseudoClass(AttributeResolver.FOCUS_PSEUDOCLASS);\n break;\n default:\n System.err.println(\"Bad condition\");\n }\n }\n"} {"input": " public static void main( String[] argv) {\n try {\n boolean namespaces = true;\n System.out.println(\"Running dom.dom3.Test...\");\n System.setProperty(DOMImplementationRegistry.PROPERTY,\"org.apache.xerces.dom.DOMImplementationSourceImpl org.apache.xerces.dom.DOMXSImplementationSourceImpl\");\n DOMImplementationLS impl = (DOMImplementationLS)DOMImplementationRegistry.newInstance().getDOMImplementation(\"LS\");\n Assertion.verify(impl!=null, \"domImplementation != null\");\n LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,\n null);\n LSSerializer writer = impl.createLSSerializer();\n DOMConfiguration config = writer.getConfig();\n config.setParameter(\"namespaces\",(namespaces)?Boolean.TRUE:Boolean.FALSE);\n config.setParameter(\"validate\",Boolean.FALSE);\n {\n Document doc = builder.parseURI(\"tests/dom/dom3/input.xml\");\n NodeList ls = doc.getElementsByTagName(\"a:elem_a\"); \n NodeImpl elem = (NodeImpl)ls.item(0);\n if (namespaces) {\n Assertion.verify(elem.lookupPrefix(\"http://www.example.com\").equals(\"ns1\"), \n \"[a:elem_a].lookupPrefix(http://www.example.com)==null\");\n Assertion.verify(elem.isDefaultNamespace(\"http://www.example.com\") == true, \n \"[a:elem_a].isDefaultNamespace(http://www.example.com)==true\");\n Assertion.verify(elem.lookupPrefix(\"http://www.example.com\").equals(\"ns1\"), \n \"[a:elem_a].lookupPrefix(http://www.example.com)==ns1\");\n Assertion.verify(elem.lookupNamespaceURI(\"xsi\").equals(\"http://www.w3.org/2001/XMLSchema-instance\"), \n \"[a:elem_a].lookupNamespaceURI('xsi') == 'http://www.w3.org/2001/XMLSchema-instance'\" );\n } else {\n Assertion.verify( elem.lookupPrefix(\"http://www.example.com\") == null,\"lookupPrefix(http://www.example.com)==null\"); \n }\n ls = doc.getElementsByTagName(\"bar:leaf\");\n elem = (NodeImpl)ls.item(0);\n Assertion.verify(elem.lookupPrefix(\"url1:\").equals(\"foo\"), \n \"[bar:leaf].lookupPrefix('url1:', false) == foo\");\n ls = doc.getElementsByTagName(\"baz\");\n elem = (NodeImpl)ls.item(0);\n ls = doc.getElementsByTagName(\"elem8\");\n elem = (NodeImpl)ls.item(0);\n Element e1 = doc.createElementNS(\"b:\",\"p:baz\");\n e1.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:x\", \"b:\");\n elem.appendChild(e1);\n Assertion.verify(((NodeImpl)e1).lookupPrefix(\"b:\").equals(\"p\"), \n \"[p:baz].lookupPrefix('b:', false) == p\");\n Assertion.verify(elem.lookupNamespaceURI(\"xsi\").equals(\"http://www.w3.org/2001/XMLSchema-instance\"), \n \"[bar:leaf].lookupNamespaceURI('xsi') == 'http://www.w3.org/2001/XMLSchema-instance'\" );\n }\n {\n errorCounter = 0;\n config = builder.getConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n DocumentImpl core = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/schema.xml\");\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n errorCounter = 0; \n NodeList ls2 = core.getElementsByTagName(\"decVal\");\n Element testElem = (Element)ls2.item(0);\n testElem.removeAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\");\n ls2 = core.getElementsByTagName(\"v02:decVal\");\n testElem = (Element)ls2.item(0);\n testElem.setPrefix(\"myPrefix\");\n Element root = core.getDocumentElement();\n Element newElem = core.createElementNS(null, \"decVal\");\n String data=\"4.5\";\n if (true) {\n data = \"string\";\n } \n newElem.appendChild(core.createTextNode(data));\n root.insertBefore(newElem, testElem);\n newElem = core.createElementNS(null, \"notInSchema\");\n newElem.appendChild(core.createTextNode(\"added new element\"));\n root.insertBefore(newElem, testElem);\n root.appendChild(core.createElementNS(\"UndefinedNamespace\", \"NS1:foo\"));\n config = core.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n core.normalizeDocument();\n Assertion.verify(errorCounter == 3, \"3 errors should be reported\");\n errorCounter = 0;\n config.setParameter(\"validate\", Boolean.FALSE);\n config.setParameter(\"comments\", Boolean.FALSE);\n core.normalizeDocument();\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n config = builder.getConfig();\n config.setParameter(\"validate\", Boolean.FALSE);\n }\n {\n errorCounter = 0;\n config = builder.getConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n config.setParameter(\"psvi\", Boolean.TRUE);\n DocumentImpl core = (DocumentImpl)builder.parseURI(\"data/personal-schema.xml\");\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n NodeList ls2 = core.getElementsByTagName(\"person\");\n Element testElem = (Element)ls2.item(0);\n Assertion.verify(((ElementPSVI)testElem).getElementDeclaration().getName().equals(\"person\"), \"testElem decl\");\n Element e1 = core.createElementNS(null, \"person\");\n core.getDocumentElement().appendChild(e1);\n e1.setAttributeNS(null, \"id\", \"newEmp\");\n Element e2 = core.createElementNS(null, \"name\");\n e2.appendChild(core.createElementNS(null, \"family\"));\n e2.appendChild(core.createElementNS(null, \"given\"));\n e1.appendChild(e2);\n e1.appendChild(core.createElementNS(null, \"email\"));\n Element e3 = core.createElementNS(null, \"link\");\n e3.setAttributeNS(null, \"manager\", \"Big.Boss\");\n e1.appendChild(e3);\n testElem.removeAttributeNode(testElem.getAttributeNodeNS(null, \"contr\"));\n NamedNodeMap map = testElem.getAttributes();\n config = core.getDomConfig();\n errorCounter = 0;\n config.setParameter(\"psvi\", Boolean.TRUE);\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n core.normalizeDocument();\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n Assertion.verify(((ElementPSVI)e1).getElementDeclaration().getName().equals(\"person\"), \"e1 decl\"); \n config = builder.getConfig();\n config.setParameter(\"validate\", Boolean.FALSE);\n }\n {\n Document doc= new DocumentImpl(); \n Element root = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\", \"xsl:stylesheet\");\n doc.appendChild(root);\n root.setAttributeNS(\"http://attr1\", \"xsl:attr1\",\"\");\n Element child1 = doc.createElementNS(\"http://child1\", \"NS2:child1\");\n child1.setAttributeNS(\"http://attr2\", \"NS2:attr2\",\"\");\n root.appendChild(child1);\n Element child2 = doc.createElementNS(\"http://child2\",\"NS4:child2\");\n child2.setAttributeNS(\"http://attr3\",\"attr3\", \"\");\n root.appendChild(child2);\n Element child3 = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\",\"xsl:child3\");\n child3.setAttributeNS(\"http://a1\",\"attr1\", \"\");\n child3.setAttributeNS(\"http://a2\",\"xsl:attr2\", \"\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:a1\", \"http://a1\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:xsl\", \"http://a2\");\n Element child4 = doc.createElementNS(null, \"child4\");\n child4.setAttributeNS(\"http://a1\", \"xsl:attr1\", \"\");\n child4.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\", \"default\");\n child3.appendChild(child4);\n root.appendChild(child3);\n ((CoreDocumentImpl)doc).normalizeDocument();\n String name = root.getNodeName();\n Assertion.verify(name.equals(\"xsl:stylesheet\"), \"xsl:stylesheet\");\n String value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null, \"xmlns:xsl != null\");\n Assertion.verify(value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr1\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child1.getNodeName().equals(\"NS2:child1\"), \"NS2:child1\");\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS2\");\n Assertion.verify(value!=null && \n value.equals(\"http://child1\"), \"xmlns:NS2=\"+value);\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr2\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child3.getNodeName().equals(\"xsl:child3\"), \"xsl:child3\");\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a2\"), \"xmlns:NS1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"a1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a1\"), \"xmlns:a1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null && \n value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n Attr attr = child3.getAttributeNodeNS(\"http://a2\", \"attr2\");\n Assertion.verify(attr != null, \"NS1:attr2 !=null\");\n Assertion.verify(child3.getAttributes().getLength() == 5, \"xsl:child3 has 5 attrs\");\n Attr temp = child4.getAttributeNodeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\");\n Assertion.verify(temp.getNodeName().equals(\"xmlns\"), \"attribute name is xmlns\");\n Assertion.verify(temp.getNodeValue().length() == 0, \"xmlns=''\"); \n }\n {\n Document doc= new DocumentImpl(); \n Element root = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\", \"xsl:stylesheet\");\n doc.appendChild(root);\n root.setAttributeNS(\"http://attr1\", \"xsl:attr1\",\"\");\n Element child1 = doc.createElementNS(\"http://child1\", \"NS2:child1\");\n child1.setAttributeNS(\"http://attr2\", \"NS2:attr2\",\"\");\n root.appendChild(child1);\n Element child2 = doc.createElementNS(\"http://child2\",\"NS4:child2\");\n child2.setAttributeNS(\"http://attr3\",\"attr3\", \"\");\n root.appendChild(child2);\n Element child3 = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\",\"xsl:child3\");\n child3.setAttributeNS(\"http://a1\",\"attr1\", \"\");\n child3.setAttributeNS(\"http://a2\",\"xsl:attr2\", \"\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:a1\", \"http://a1\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:xsl\", \"http://a2\");\n Element child4 = doc.createElementNS(null, \"child4\");\n child4.setAttributeNS(\"http://a1\", \"xsl:attr1\", \"\");\n child4.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\", \"default\");\n child3.appendChild(child4);\n root.appendChild(child3);\n writer.getConfig().setParameter(\"namespaces\", Boolean.TRUE);\n String xmlData = writer.writeToString(doc);\n Reader r = new StringReader(xmlData);\n LSInput in = impl.createLSInput();\n in.setCharacterStream(r);\n doc = builder.parse(in);\n root = doc.getDocumentElement();\n child1 = (Element)root.getFirstChild();\n child2 = (Element)child1.getNextSibling();\n child3 = (Element)child2.getNextSibling();\n String name = root.getNodeName();\n Assertion.verify(name.equals(\"xsl:stylesheet\"), \"xsl:stylesheet\");\n String value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null, \"xmlns:xsl != null\");\n Assertion.verify(value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr1\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child1.getNodeName().equals(\"NS2:child1\"), \"NS2:child1\");\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS2\");\n Assertion.verify(value!=null && \n value.equals(\"http://child1\"), \"xmlns:NS2=\"+value);\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr2\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child3.getNodeName().equals(\"xsl:child3\"), \"xsl:child3\");\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a2\"), \"xmlns:NS1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"a1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a1\"), \"xmlns:a1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null && \n value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n Attr attr = child3.getAttributeNodeNS(\"http://a2\", \"attr2\");\n Assertion.verify(attr != null, \"NS6:attr2 !=null\");\n Assertion.verify(child3.getAttributes().getLength() == 5, \"xsl:child3 has 5 attrs\");\n }\n {\n config = builder.getConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.FALSE);\n config.setParameter(\"entities\", Boolean.TRUE);\n DocumentImpl doc = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/wholeText.xml\");\n Element root = doc.getDocumentElement();\n Element test = (Element)doc.getElementsByTagName(\"elem\").item(0);\n test.appendChild(doc.createTextNode(\"Address: \"));\n test.appendChild(doc.createEntityReference(\"ent2\"));\n test.appendChild(doc.createTextNode(\"City: \"));\n test.appendChild(doc.createEntityReference(\"ent1\"));\n DocumentType doctype = doc.getDoctype();\n Node entity = doctype.getEntities().getNamedItem(\"ent3\");\n NodeList ls = test.getChildNodes();\n Assertion.verify(ls.getLength()==5, \"List length\");\n String compare1 = \"Home Address: 1900 Dallas Road (East) City: Dallas. California. USA PO #5668\";\n Assertion.verify(((TextImpl)ls.item(0)).getWholeText().equals(compare1), \"Compare1\");\n String compare2 = \"Address: 1900 Dallas Road (East) City: Dallas. California. USA PO #5668\";\n Assertion.verify(((TextImpl)ls.item(1)).getWholeText().equals(compare2), \"Compare2\");\n ((NodeImpl)ls.item(0)).setReadOnly(true, true);\n TextImpl original = (TextImpl)ls.item(0);\n Node newNode = original.replaceWholeText(\"Replace with this text\");\n ls = test.getChildNodes();\n Assertion.verify(ls.getLength() == 1, \"Length == 1\");\n Assertion.verify(ls.item(0).getNodeValue().equals(\"Replace with this text\"), \"Replacement works\");\n Assertion.verify(newNode != original, \"New node created\");\n Text text = doc.createTextNode(\"readonly\");\n ((NodeImpl)text).setReadOnly(true, true);\n text = ((TextImpl)text).replaceWholeText(\"Data\");\n Assertion.verify(text.getNodeValue().equals(\"Data\"), \"New value 'Data'\");\n test = (Element)doc.getElementsByTagName(\"elem\").item(1);\n try { \n ((TextImpl)test.getFirstChild()).replaceWholeText(\"can't replace\");\n } catch (DOMException e){\n Assertion.verify(e !=null);\n }\n String compare3 = \"Test: The Content ends here. \";\n }\n {\n errorCounter = 0;\n config = builder.getConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"resource-resolver\",resolver);\n config.setParameter(\"validate\", Boolean.TRUE);\n config.setParameter(\"psvi\", Boolean.TRUE);\n errorCounter = 0;\n DocumentImpl core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both-error.xml\");\n Assertion.verify(errorCounter == 4, \"4 errors should be reported\");\n errorCounter = 0;\n config.setParameter(\"schema-type\", \"http://www.w3.org/2001/XMLSchema\");\n core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both.xml\");\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n errorCounter = 0;\n config.setParameter(\"schema-type\",\"http://www.w3.org/TR/REC-xml\");\n core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both-error.xml\");\n Assertion.verify(errorCounter == 3, \"3 errors should be reported\");\n core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both-error.xml\");\n errorCounter = 0;\n Element root = core2.getDocumentElement();\n root.removeAttributeNS(\"http://www.w3.org/2001/XMLSchema\", \"xsi\"); \n root.removeAttributeNS(\"http://www.w3.org/2001/XMLSchema\", \"noNamespaceSchemaLocation\");\n config = core2.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"schema-type\", \"http://www.w3.org/2001/XMLSchema\");\n config.setParameter(\"schema-location\",\"personal.xsd\");\n config.setParameter(\"resource-resolver\",resolver);\n config.setParameter(\"validate\", Boolean.TRUE);\n core2.normalizeDocument();\n Assertion.verify(errorCounter == 1, \"1 error should be reported: \"+errorCounter);\n }\n {\n\t\t\t\tLSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t null);\n\t\t\t\tDocument doc = parser.parseURI(\"tests/dom/dom3/baseURI.xml\");\n\t\t\t\tElement root = doc.getDocumentElement();\n\t\t\t\tNodeList ls = doc.getElementsByTagNameNS(null, \"streetNum\");\n\t\t\t\tNode e = ls.item(0);\n\t\t\t\tAssertion.verify(((NodeImpl)e).getBaseURI().endsWith(\"tests/dom/dom3/baseURI.xml\"), \n\t\t\t\t\t\t\t\t \"baseURI=tests/dom/dom3/baseURI.xml\");\n\t\t\t\tls = root.getElementsByTagNameNS(null, \"header\");\n\t\t\t\tNode p2 = ls.item(0);\n\t\t\t\tAssertion.verify(((NodeImpl)p2).getBaseURI().equals(\"http://paragraph.com\"), \n\t\t\t\t\t\t\t\t \"baseURI=http://paragraph.com\");\n\t\t\t\tp2 = ls.item(1);\n\t\t\t\tAssertion.verify(((NodeImpl)p2).getBaseURI().equals(\"http://paragraph.com2\"), \n\t\t\t\t \"baseURI=http://paragraph.com2\");\n }\n } catch ( Exception ex ) {\n ex.printStackTrace();\n }\n System.out.println(\"done!\");\n }\n", "output": " public static void main( String[] argv) {\n try {\n boolean namespaces = true;\n System.out.println(\"Running dom.dom3.Test...\");\n System.setProperty(DOMImplementationRegistry.PROPERTY,\"org.apache.xerces.dom.DOMImplementationSourceImpl org.apache.xerces.dom.DOMXSImplementationSourceImpl\");\n DOMImplementationLS impl = (DOMImplementationLS)DOMImplementationRegistry.newInstance().getDOMImplementation(\"LS\");\n Assertion.verify(impl!=null, \"domImplementation != null\");\n LSParser builder = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,\n null);\n LSSerializer writer = impl.createLSSerializer();\n DOMConfiguration config = writer.getDomConfig();\n config.setParameter(\"namespaces\",(namespaces)?Boolean.TRUE:Boolean.FALSE);\n config.setParameter(\"validate\",Boolean.FALSE);\n {\n Document doc = builder.parseURI(\"tests/dom/dom3/input.xml\");\n NodeList ls = doc.getElementsByTagName(\"a:elem_a\"); \n NodeImpl elem = (NodeImpl)ls.item(0);\n if (namespaces) {\n Assertion.verify(elem.lookupPrefix(\"http://www.example.com\").equals(\"ns1\"), \n \"[a:elem_a].lookupPrefix(http://www.example.com)==null\");\n Assertion.verify(elem.isDefaultNamespace(\"http://www.example.com\") == true, \n \"[a:elem_a].isDefaultNamespace(http://www.example.com)==true\");\n Assertion.verify(elem.lookupPrefix(\"http://www.example.com\").equals(\"ns1\"), \n \"[a:elem_a].lookupPrefix(http://www.example.com)==ns1\");\n Assertion.verify(elem.lookupNamespaceURI(\"xsi\").equals(\"http://www.w3.org/2001/XMLSchema-instance\"), \n \"[a:elem_a].lookupNamespaceURI('xsi') == 'http://www.w3.org/2001/XMLSchema-instance'\" );\n } else {\n Assertion.verify( elem.lookupPrefix(\"http://www.example.com\") == null,\"lookupPrefix(http://www.example.com)==null\"); \n }\n ls = doc.getElementsByTagName(\"bar:leaf\");\n elem = (NodeImpl)ls.item(0);\n Assertion.verify(elem.lookupPrefix(\"url1:\").equals(\"foo\"), \n \"[bar:leaf].lookupPrefix('url1:', false) == foo\");\n ls = doc.getElementsByTagName(\"baz\");\n elem = (NodeImpl)ls.item(0);\n ls = doc.getElementsByTagName(\"elem8\");\n elem = (NodeImpl)ls.item(0);\n Element e1 = doc.createElementNS(\"b:\",\"p:baz\");\n e1.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:x\", \"b:\");\n elem.appendChild(e1);\n Assertion.verify(((NodeImpl)e1).lookupPrefix(\"b:\").equals(\"p\"), \n \"[p:baz].lookupPrefix('b:', false) == p\");\n Assertion.verify(elem.lookupNamespaceURI(\"xsi\").equals(\"http://www.w3.org/2001/XMLSchema-instance\"), \n \"[bar:leaf].lookupNamespaceURI('xsi') == 'http://www.w3.org/2001/XMLSchema-instance'\" );\n }\n {\n errorCounter = 0;\n config = builder.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n DocumentImpl core = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/schema.xml\");\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n errorCounter = 0; \n NodeList ls2 = core.getElementsByTagName(\"decVal\");\n Element testElem = (Element)ls2.item(0);\n testElem.removeAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\");\n ls2 = core.getElementsByTagName(\"v02:decVal\");\n testElem = (Element)ls2.item(0);\n testElem.setPrefix(\"myPrefix\");\n Element root = core.getDocumentElement();\n Element newElem = core.createElementNS(null, \"decVal\");\n String data=\"4.5\";\n if (true) {\n data = \"string\";\n } \n newElem.appendChild(core.createTextNode(data));\n root.insertBefore(newElem, testElem);\n newElem = core.createElementNS(null, \"notInSchema\");\n newElem.appendChild(core.createTextNode(\"added new element\"));\n root.insertBefore(newElem, testElem);\n root.appendChild(core.createElementNS(\"UndefinedNamespace\", \"NS1:foo\"));\n config = core.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n core.normalizeDocument();\n Assertion.verify(errorCounter == 3, \"3 errors should be reported\");\n errorCounter = 0;\n config.setParameter(\"validate\", Boolean.FALSE);\n config.setParameter(\"comments\", Boolean.FALSE);\n core.normalizeDocument();\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n config = builder.getDomConfig();\n config.setParameter(\"validate\", Boolean.FALSE);\n }\n {\n errorCounter = 0;\n config = builder.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n config.setParameter(\"psvi\", Boolean.TRUE);\n DocumentImpl core = (DocumentImpl)builder.parseURI(\"data/personal-schema.xml\");\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n NodeList ls2 = core.getElementsByTagName(\"person\");\n Element testElem = (Element)ls2.item(0);\n Assertion.verify(((ElementPSVI)testElem).getElementDeclaration().getName().equals(\"person\"), \"testElem decl\");\n Element e1 = core.createElementNS(null, \"person\");\n core.getDocumentElement().appendChild(e1);\n e1.setAttributeNS(null, \"id\", \"newEmp\");\n Element e2 = core.createElementNS(null, \"name\");\n e2.appendChild(core.createElementNS(null, \"family\"));\n e2.appendChild(core.createElementNS(null, \"given\"));\n e1.appendChild(e2);\n e1.appendChild(core.createElementNS(null, \"email\"));\n Element e3 = core.createElementNS(null, \"link\");\n e3.setAttributeNS(null, \"manager\", \"Big.Boss\");\n e1.appendChild(e3);\n testElem.removeAttributeNode(testElem.getAttributeNodeNS(null, \"contr\"));\n NamedNodeMap map = testElem.getAttributes();\n config = core.getDomConfig();\n errorCounter = 0;\n config.setParameter(\"psvi\", Boolean.TRUE);\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.TRUE);\n core.normalizeDocument();\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n Assertion.verify(((ElementPSVI)e1).getElementDeclaration().getName().equals(\"person\"), \"e1 decl\"); \n config = builder.getDomConfig();\n config.setParameter(\"validate\", Boolean.FALSE);\n }\n {\n Document doc= new DocumentImpl(); \n Element root = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\", \"xsl:stylesheet\");\n doc.appendChild(root);\n root.setAttributeNS(\"http://attr1\", \"xsl:attr1\",\"\");\n Element child1 = doc.createElementNS(\"http://child1\", \"NS2:child1\");\n child1.setAttributeNS(\"http://attr2\", \"NS2:attr2\",\"\");\n root.appendChild(child1);\n Element child2 = doc.createElementNS(\"http://child2\",\"NS4:child2\");\n child2.setAttributeNS(\"http://attr3\",\"attr3\", \"\");\n root.appendChild(child2);\n Element child3 = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\",\"xsl:child3\");\n child3.setAttributeNS(\"http://a1\",\"attr1\", \"\");\n child3.setAttributeNS(\"http://a2\",\"xsl:attr2\", \"\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:a1\", \"http://a1\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:xsl\", \"http://a2\");\n Element child4 = doc.createElementNS(null, \"child4\");\n child4.setAttributeNS(\"http://a1\", \"xsl:attr1\", \"\");\n child4.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\", \"default\");\n child3.appendChild(child4);\n root.appendChild(child3);\n ((CoreDocumentImpl)doc).normalizeDocument();\n String name = root.getNodeName();\n Assertion.verify(name.equals(\"xsl:stylesheet\"), \"xsl:stylesheet\");\n String value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null, \"xmlns:xsl != null\");\n Assertion.verify(value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr1\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child1.getNodeName().equals(\"NS2:child1\"), \"NS2:child1\");\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS2\");\n Assertion.verify(value!=null && \n value.equals(\"http://child1\"), \"xmlns:NS2=\"+value);\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr2\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child3.getNodeName().equals(\"xsl:child3\"), \"xsl:child3\");\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a2\"), \"xmlns:NS1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"a1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a1\"), \"xmlns:a1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null && \n value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n Attr attr = child3.getAttributeNodeNS(\"http://a2\", \"attr2\");\n Assertion.verify(attr != null, \"NS1:attr2 !=null\");\n Assertion.verify(child3.getAttributes().getLength() == 5, \"xsl:child3 has 5 attrs\");\n Attr temp = child4.getAttributeNodeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\");\n Assertion.verify(temp.getNodeName().equals(\"xmlns\"), \"attribute name is xmlns\");\n Assertion.verify(temp.getNodeValue().length() == 0, \"xmlns=''\"); \n }\n {\n Document doc= new DocumentImpl(); \n Element root = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\", \"xsl:stylesheet\");\n doc.appendChild(root);\n root.setAttributeNS(\"http://attr1\", \"xsl:attr1\",\"\");\n Element child1 = doc.createElementNS(\"http://child1\", \"NS2:child1\");\n child1.setAttributeNS(\"http://attr2\", \"NS2:attr2\",\"\");\n root.appendChild(child1);\n Element child2 = doc.createElementNS(\"http://child2\",\"NS4:child2\");\n child2.setAttributeNS(\"http://attr3\",\"attr3\", \"\");\n root.appendChild(child2);\n Element child3 = doc.createElementNS(\"http://www.w3.org/1999/XSL/Transform\",\"xsl:child3\");\n child3.setAttributeNS(\"http://a1\",\"attr1\", \"\");\n child3.setAttributeNS(\"http://a2\",\"xsl:attr2\", \"\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:a1\", \"http://a1\");\n child3.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns:xsl\", \"http://a2\");\n Element child4 = doc.createElementNS(null, \"child4\");\n child4.setAttributeNS(\"http://a1\", \"xsl:attr1\", \"\");\n child4.setAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xmlns\", \"default\");\n child3.appendChild(child4);\n root.appendChild(child3);\n writer.getDomConfig().setParameter(\"namespaces\", Boolean.TRUE);\n String xmlData = writer.writeToString(doc);\n Reader r = new StringReader(xmlData);\n LSInput in = impl.createLSInput();\n in.setCharacterStream(r);\n doc = builder.parse(in);\n root = doc.getDocumentElement();\n child1 = (Element)root.getFirstChild();\n child2 = (Element)child1.getNextSibling();\n child3 = (Element)child2.getNextSibling();\n String name = root.getNodeName();\n Assertion.verify(name.equals(\"xsl:stylesheet\"), \"xsl:stylesheet\");\n String value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null, \"xmlns:xsl != null\");\n Assertion.verify(value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n value = root.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr1\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child1.getNodeName().equals(\"NS2:child1\"), \"NS2:child1\");\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS2\");\n Assertion.verify(value!=null && \n value.equals(\"http://child1\"), \"xmlns:NS2=\"+value);\n value = child1.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://attr2\"), \"xmlns:NS1=\"+value);\n Assertion.verify(child3.getNodeName().equals(\"xsl:child3\"), \"xsl:child3\");\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"NS1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a2\"), \"xmlns:NS1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"a1\");\n Assertion.verify(value!=null && \n value.equals(\"http://a1\"), \"xmlns:a1=\"+value);\n value = child3.getAttributeNS(\"http://www.w3.org/2000/xmlns/\", \"xsl\");\n Assertion.verify(value!=null && \n value.equals(\"http://www.w3.org/1999/XSL/Transform\"), \"xmlns:xsl=\"+value);\n Attr attr = child3.getAttributeNodeNS(\"http://a2\", \"attr2\");\n Assertion.verify(attr != null, \"NS6:attr2 !=null\");\n Assertion.verify(child3.getAttributes().getLength() == 5, \"xsl:child3 has 5 attrs\");\n }\n {\n config = builder.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"validate\", Boolean.FALSE);\n config.setParameter(\"entities\", Boolean.TRUE);\n DocumentImpl doc = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/wholeText.xml\");\n Element root = doc.getDocumentElement();\n Element test = (Element)doc.getElementsByTagName(\"elem\").item(0);\n test.appendChild(doc.createTextNode(\"Address: \"));\n test.appendChild(doc.createEntityReference(\"ent2\"));\n test.appendChild(doc.createTextNode(\"City: \"));\n test.appendChild(doc.createEntityReference(\"ent1\"));\n DocumentType doctype = doc.getDoctype();\n Node entity = doctype.getEntities().getNamedItem(\"ent3\");\n NodeList ls = test.getChildNodes();\n Assertion.verify(ls.getLength()==5, \"List length\");\n String compare1 = \"Home Address: 1900 Dallas Road (East) City: Dallas. California. USA PO #5668\";\n Assertion.verify(((TextImpl)ls.item(0)).getWholeText().equals(compare1), \"Compare1\");\n String compare2 = \"Address: 1900 Dallas Road (East) City: Dallas. California. USA PO #5668\";\n Assertion.verify(((TextImpl)ls.item(1)).getWholeText().equals(compare2), \"Compare2\");\n ((NodeImpl)ls.item(0)).setReadOnly(true, true);\n TextImpl original = (TextImpl)ls.item(0);\n Node newNode = original.replaceWholeText(\"Replace with this text\");\n ls = test.getChildNodes();\n Assertion.verify(ls.getLength() == 1, \"Length == 1\");\n Assertion.verify(ls.item(0).getNodeValue().equals(\"Replace with this text\"), \"Replacement works\");\n Assertion.verify(newNode != original, \"New node created\");\n Text text = doc.createTextNode(\"readonly\");\n ((NodeImpl)text).setReadOnly(true, true);\n text = ((TextImpl)text).replaceWholeText(\"Data\");\n Assertion.verify(text.getNodeValue().equals(\"Data\"), \"New value 'Data'\");\n test = (Element)doc.getElementsByTagName(\"elem\").item(1);\n try { \n ((TextImpl)test.getFirstChild()).replaceWholeText(\"can't replace\");\n } catch (DOMException e){\n Assertion.verify(e !=null);\n }\n String compare3 = \"Test: The Content ends here. \";\n }\n {\n errorCounter = 0;\n config = builder.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"resource-resolver\",resolver);\n config.setParameter(\"validate\", Boolean.TRUE);\n config.setParameter(\"psvi\", Boolean.TRUE);\n errorCounter = 0;\n DocumentImpl core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both-error.xml\");\n Assertion.verify(errorCounter == 4, \"4 errors should be reported\");\n errorCounter = 0;\n config.setParameter(\"schema-type\", \"http://www.w3.org/2001/XMLSchema\");\n core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both.xml\");\n Assertion.verify(errorCounter == 0, \"No errors should be reported\");\n errorCounter = 0;\n config.setParameter(\"schema-type\",\"http://www.w3.org/TR/REC-xml\");\n core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both-error.xml\");\n Assertion.verify(errorCounter == 3, \"3 errors should be reported\");\n core2 = (DocumentImpl)builder.parseURI(\"tests/dom/dom3/both-error.xml\");\n errorCounter = 0;\n Element root = core2.getDocumentElement();\n root.removeAttributeNS(\"http://www.w3.org/2001/XMLSchema\", \"xsi\"); \n root.removeAttributeNS(\"http://www.w3.org/2001/XMLSchema\", \"noNamespaceSchemaLocation\");\n config = core2.getDomConfig();\n config.setParameter(\"error-handler\",errorHandler);\n config.setParameter(\"schema-type\", \"http://www.w3.org/2001/XMLSchema\");\n config.setParameter(\"schema-location\",\"personal.xsd\");\n config.setParameter(\"resource-resolver\",resolver);\n config.setParameter(\"validate\", Boolean.TRUE);\n core2.normalizeDocument();\n Assertion.verify(errorCounter == 1, \"1 error should be reported: \"+errorCounter);\n }\n {\n\t\t\t\tLSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t null);\n\t\t\t\tDocument doc = parser.parseURI(\"tests/dom/dom3/baseURI.xml\");\n\t\t\t\tElement root = doc.getDocumentElement();\n\t\t\t\tNodeList ls = doc.getElementsByTagNameNS(null, \"streetNum\");\n\t\t\t\tNode e = ls.item(0);\n\t\t\t\tAssertion.verify(((NodeImpl)e).getBaseURI().endsWith(\"tests/dom/dom3/baseURI.xml\"), \n\t\t\t\t\t\t\t\t \"baseURI=tests/dom/dom3/baseURI.xml\");\n\t\t\t\tls = root.getElementsByTagNameNS(null, \"header\");\n\t\t\t\tNode p2 = ls.item(0);\n\t\t\t\tAssertion.verify(((NodeImpl)p2).getBaseURI().equals(\"http://paragraph.com\"), \n\t\t\t\t\t\t\t\t \"baseURI=http://paragraph.com\");\n\t\t\t\tp2 = ls.item(1);\n\t\t\t\tAssertion.verify(((NodeImpl)p2).getBaseURI().equals(\"http://paragraph.com2\"), \n\t\t\t\t \"baseURI=http://paragraph.com2\");\n }\n } catch ( Exception ex ) {\n ex.printStackTrace();\n }\n System.out.println(\"done!\");\n }\n"} {"input": " public IClass getClassDefinition(String name) {\n IClass result = null;\n result = LiteralResolver.getDefinition(name);\n if (result == null) {\n int lastDot = name.lastIndexOf(\".\");\n if (lastDot > 0) {\n String packageName = name.substring(0, lastDot);\n String className = name.substring(lastDot + 1);\n IPackage pkg = getPackageDefinition(packageName);\n if (pkg != null) {\n result = pkg.getClass(className);\n }\n }\n }\n if (result == null) {\n Class theClass = null;\n try {\n theClass = ClassManager.getClassLoader().loadClass(name);\n result = new ExternalClass(theClass);\n }\n catch (ClassNotFoundException e) {\n }\n }\n return result;\n }\n", "output": " public IClass getClassDefinition(String name) {\n IClass result = null;\n result = LiteralResolver.getDefinition(name);\n if (result == null) {\n int lastDot = name.lastIndexOf(\".\");\n if (lastDot > 0) {\n String packageName = name.substring(0, lastDot);\n String className = name.substring(lastDot + 1);\n IPackage pkg = getPackageDefinition(packageName);\n if (pkg != null) {\n result = pkg.getClass(className);\n }\n }\n }\n if (result == null) {\n Class theClass = null;\n try {\n theClass = ClassManager.getClassLoader().loadClass(name);\n result = new ExternalClass(theClass);\n }\n catch (ClassNotFoundException e) {\n }\n catch (NoClassDefFoundError e) {\n }\n }\n return result;\n }\n"} {"input": " public void doViewSubscription(FormEvent event) {\n PortletRequest req = event.getPortletRequest();\n gsPortlets.clear();\n User user = req.getUser();\n List myNames = layoutMgr.getSubscribedPortlets(req);\n List groups = aclService.getGroups(user);\n Iterator it = groups.iterator();\n PanelBean panel = event.getPanelBean(\"panel\");\n PortletRole role = req.getRole();\n while (it.hasNext()) {\n FrameBean frame = new FrameBean();\n DefaultTableModel model = new DefaultTableModel();\n PortletGroup g = (PortletGroup)it.next();\n TableRowBean tr = new TableRowBean();\n tr.setHeader(true);\n TableCellBean tc3 = new TableCellBean();\n TextBean text3 = new TextBean();\n text3.setValue(this.getLocalizedText(req, \"SUBSCRIPTION_SUBSCRIBE\"));\n tc3.addBean(text3);\n tr.addBean(tc3);\n TableCellBean tc = new TableCellBean();\n TextBean text = new TextBean();\n text.setValue(portletMgr.getPortletWebApplicationDescription(g.getName()));\n tc.addBean(text);\n tr.addBean(tc);\n tc = new TableCellBean();\n text = new TextBean();\n text.setValue(this.getLocalizedText(req, \"SUBSCRIPTION_DESC\"));\n tc.addBean(text);\n tr.addBean(tc);\n model.addTableRowBean(tr);\n Collection appColl = portletRegistry.getApplicationPortlets(g.getName());\n Iterator appIt = appColl.iterator();\n while (appIt.hasNext()) {\n ApplicationPortlet app = (ApplicationPortlet)appIt.next();\n List concPortlets = app.getConcretePortlets();\n Iterator cit = concPortlets.iterator();\n while (cit.hasNext()) {\n ConcretePortlet conc = (ConcretePortlet)cit.next();\n String concID = conc.getConcretePortletID();\n PortletRole reqrole = conc.getConcretePortletConfig().getRequiredRole();\n log.debug(\"subscribed to portlet: \" + concID + \" \" + reqrole);\n if (role.compare(role, reqrole) >= 0) {\n CheckBoxBean cb = new CheckBoxBean(req, \"portletsCB\");\n cb.setValue(concID);\n if (myNames.contains(concID)) {\n cb.setSelected(true);\n }\n if (g.equals(PortletGroupFactory.GRIDSPHERE_GROUP)) {\n gsPortlets.add(concID);\n cb.setDisabled(true);\n cb.setSelected(true);\n }\n TableRowBean newtr = new TableRowBean();\n TableCellBean newtc = new TableCellBean();\n newtc.addBean(cb);\n newtr.addBean(newtc);\n TableCellBean newtc2 = new TableCellBean();\n TextBean tb = new TextBean();\n Locale loc = req.getLocale();\n concID = conc.getDisplayName(loc);\n tb.setValue(concID);\n newtc2.addBean(tb);\n newtr.addBean(newtc2);\n newtc = new TableCellBean();\n TextBean tb2 = new TextBean();\n tb2.setValue(conc.getDescription(loc));\n newtc.addBean(tb2);\n newtr.addBean(newtc);\n model.addTableRowBean(newtr);\n }\n }\n }\n frame.setTableModel(model);\n panel.addBean(frame);\n }\n setNextState(req, VIEW_JSP);\n }\n", "output": " public void doViewSubscription(FormEvent event) {\n PortletRequest req = event.getPortletRequest();\n gsPortlets.clear();\n User user = req.getUser();\n List myNames = layoutMgr.getSubscribedPortlets(req);\n List groups = aclService.getGroups(user);\n Iterator it = groups.iterator();\n PanelBean panel = event.getPanelBean(\"panel\");\n PortletRole role = req.getRole();\n while (it.hasNext()) {\n FrameBean frame = new FrameBean();\n DefaultTableModel model = new DefaultTableModel();\n PortletGroup g = (PortletGroup)it.next();\n TableRowBean tr = new TableRowBean();\n tr.setHeader(true);\n TableCellBean tc3 = new TableCellBean();\n TextBean text3 = new TextBean();\n text3.setValue(this.getLocalizedText(req, \"SUBSCRIPTION_SUBSCRIBE\"));\n tc3.addBean(text3);\n tr.addBean(tc3);\n TableCellBean tc = new TableCellBean();\n TextBean text = new TextBean();\n text.setValue(portletMgr.getPortletWebApplicationDescription(g.getName()));\n tc.addBean(text);\n tr.addBean(tc);\n tc = new TableCellBean();\n text = new TextBean();\n text.setValue(this.getLocalizedText(req, \"SUBSCRIPTION_DESC\"));\n tc.addBean(text);\n tr.addBean(tc);\n model.addTableRowBean(tr);\n Collection appColl = portletRegistry.getApplicationPortlets(g.getName());\n Iterator appIt = appColl.iterator();\n while (appIt.hasNext()) {\n ApplicationPortlet app = (ApplicationPortlet)appIt.next();\n List concPortlets = app.getConcretePortlets();\n Iterator cit = concPortlets.iterator();\n while (cit.hasNext()) {\n ConcretePortlet conc = (ConcretePortlet)cit.next();\n String concID = conc.getConcretePortletID();\n PortletRole reqrole = conc.getConcretePortletConfig().getRequiredRole();\n log.debug(\"subscribed to portlet: \" + concID + \" \" + reqrole);\n if (role.compare(role, reqrole) >= 0) {\n CheckBoxBean cb = new CheckBoxBean(req, \"portletsCB\");\n cb.setValue(concID);\n if (myNames.contains(concID)) {\n cb.setSelected(true);\n }\n if (g.equals(PortletGroupFactory.GRIDSPHERE_GROUP)) {\n gsPortlets.add(concID);\n cb.setDisabled(true);\n cb.setSelected(true);\n }\n TableRowBean newtr = new TableRowBean();\n TableCellBean newtc = new TableCellBean();\n newtc.addBean(cb);\n newtr.addBean(newtc);\n TableCellBean newtc2 = new TableCellBean();\n TextBean tb = new TextBean();\n Locale loc = req.getLocale();\n tb.setValue(concID);\n newtc2.addBean(tb);\n newtr.addBean(newtc2);\n newtc = new TableCellBean();\n TextBean tb2 = new TextBean();\n newtc.addBean(tb2);\n newtr.addBean(newtc);\n model.addTableRowBean(newtr);\n }\n }\n }\n frame.setTableModel(model);\n panel.addBean(frame);\n }\n setNextState(req, VIEW_JSP);\n }\n"} {"input": "\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\trequestWindowFeature(Window.FEATURE_NO_TITLE);\n\t\tsetContentView(R.layout.dawn);\n\t\tgetWindow().addFlags(\n\t\t\t\tWindowManager.LayoutParams.FLAG_FULLSCREEN|\n\t\t\t\tWindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|\n\t\t\t\tWindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|\n\t\t\t\tWindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|\n\t\t\t\tWindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);\n\t\tfindViewById(R.id.dawn_background).setOnClickListener(this);\n\t\tSharedPreferences pref = getApplicationContext().getSharedPreferences(\"main\", MODE_PRIVATE);\n\t\tString day;\n\t\tCalendar alarmStart = getAlarmStart(pref);\n\t\tswitch (alarmStart.get(Calendar.DAY_OF_WEEK)) {\n\t\tcase Calendar.MONDAY:\n\t\t\tday = \"mondays\";\n\t\t\tbreak;\n\t\tcase Calendar.TUESDAY:\n\t\t\tday = \"tuesdays\";\n\t\t\tbreak;\n\t\tcase Calendar.WEDNESDAY:\n\t\t\tday = \"wednesdays\";\n\t\t\tbreak;\n\t\tcase Calendar.THURSDAY:\n\t\t\tday = \"thursdays\";\n\t\t\tbreak;\n\t\tcase Calendar.FRIDAY:\n\t\t\tday = \"fridays\";\n\t\t\tbreak;\n\t\tcase Calendar.SATURDAY:\n\t\t\tday = \"saturdays\";\n\t\t\tbreak;\n\t\tcase Calendar.SUNDAY:\n\t\t\tday = \"sundays\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tday = \"NON_EXISTING_WEEKDAY\";\n\t\t\tbreak;\n\t\t}\n\t\tif(!pref.getBoolean(day, false))\n\t\t{\n\t\t\tthis.finish();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlong dawnStartMillis = alarmStart.getTimeInMillis();\n\t\t\tm_alarmStartMillis =\n\t\t\t\t\tdawnStartMillis + (pref.getInt(\"light_start\", 0)*1000L*60L);\n\t\t\tif(savedInstanceState != null)\n\t\t\t{\n\t\t\t\tif(savedInstanceState.containsKey(ALARM_START_MILLIS))\n\t\t\t\t{\n\t\t\t\t\tm_alarmStartMillis = savedInstanceState.getLong(ALARM_START_MILLIS);\n\t\t\t\t}\n\t\t\t}\n\t\t\tm_alarmEndMillis = dawnStartMillis + (1000L*60L*pref.getInt(\"light_max\", 15));\n\t\t\tm_dawnColor = pref.getInt(\"color\", 0x4040FF);\n\t\t\tIntent sound = new Intent(getApplicationContext(), DawnSound.class);\n\t\t\tsound.putExtra(DawnSound.EXTRA_VIBRATE, pref.getBoolean(\"vibrate\", false));\n\t\t\tlong soundStart = dawnStartMillis + (pref.getInt(\"sound_start\", 15)*1000L*60L);\n\t\t\tlong soundEnd = dawnStartMillis + (dawnStartMillis + (pref.getInt(\"sound_max\", 15)*1000L*60L) - soundStart);\n\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_START_MILLIS, soundStart);\n\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_END_MILLIS, soundEnd);\n\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_URI, pref.getString(\"sound\", \"\"));\n\t\t\tif(pref.contains(\"volume\"))\n\t\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_VOLUME, pref.getInt(\"volume\", 0));\t\t\t\n\t\t\tstartService(sound);\n\t\t\tupdateBrightness(System.currentTimeMillis());\n\t\t\tm_timer = new Timer();\n\t\t\tm_timer.schedule(\n\t\t\t\t\tnew TimerTask() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\trunOnUiThread(\n\t\t\t\t\t\t\t\t\tnew Runnable() {\n\t\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\t\tupdateBrightness(System.currentTimeMillis());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}, TIMER_TICK_SECONDS*1000, TIMER_TICK_SECONDS*1000);\n\t\t}\n\t}\n", "output": "\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\trequestWindowFeature(Window.FEATURE_NO_TITLE);\n\t\tsetContentView(R.layout.dawn);\n\t\tgetWindow().addFlags(\n\t\t\t\tWindowManager.LayoutParams.FLAG_FULLSCREEN|\n\t\t\t\tWindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|\n\t\t\t\tWindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|\n\t\t\t\tWindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|\n\t\t\t\tWindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);\n\t\tfindViewById(R.id.dawn_background).setOnClickListener(this);\n\t\tSharedPreferences pref = getApplicationContext().getSharedPreferences(\"main\", MODE_PRIVATE);\n\t\tString day;\n\t\tCalendar alarmStart = getAlarmStart(pref);\n\t\tswitch (alarmStart.get(Calendar.DAY_OF_WEEK)) {\n\t\tcase Calendar.MONDAY:\n\t\t\tday = \"mondays\";\n\t\t\tbreak;\n\t\tcase Calendar.TUESDAY:\n\t\t\tday = \"tuesdays\";\n\t\t\tbreak;\n\t\tcase Calendar.WEDNESDAY:\n\t\t\tday = \"wednesdays\";\n\t\t\tbreak;\n\t\tcase Calendar.THURSDAY:\n\t\t\tday = \"thursdays\";\n\t\t\tbreak;\n\t\tcase Calendar.FRIDAY:\n\t\t\tday = \"fridays\";\n\t\t\tbreak;\n\t\tcase Calendar.SATURDAY:\n\t\t\tday = \"saturdays\";\n\t\t\tbreak;\n\t\tcase Calendar.SUNDAY:\n\t\t\tday = \"sundays\";\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tday = \"NON_EXISTING_WEEKDAY\";\n\t\t\tbreak;\n\t\t}\n\t\tif(!pref.getBoolean(day, false))\n\t\t{\n\t\t\tthis.finish();\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlong dawnStartMillis = alarmStart.getTimeInMillis();\n\t\t\tm_alarmStartMillis =\n\t\t\t\t\tdawnStartMillis + (pref.getInt(\"light_start\", 0)*1000L*60L);\n\t\t\tif(savedInstanceState != null)\n\t\t\t{\n\t\t\t\tif(savedInstanceState.containsKey(ALARM_START_MILLIS))\n\t\t\t\t{\n\t\t\t\t\tm_alarmStartMillis = savedInstanceState.getLong(ALARM_START_MILLIS);\n\t\t\t\t}\n\t\t\t}\n\t\t\tm_alarmEndMillis = dawnStartMillis + (1000L*60L*pref.getInt(\"light_max\", 15));\n\t\t\tm_dawnColor = pref.getInt(\"color\", 0x4040FF);\n\t\t\tIntent sound = new Intent(getApplicationContext(), DawnSound.class);\n\t\t\tsound.putExtra(DawnSound.EXTRA_VIBRATE, pref.getBoolean(\"vibrate\", false));\n\t\t\tlong soundStart = dawnStartMillis + (pref.getInt(\"sound_start\", 15)*1000L*60L);\n\t\t\tlong soundEnd = dawnStartMillis + (pref.getInt(\"sound_max\", 15)*1000L*60L);\n\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_START_MILLIS, soundStart);\n\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_END_MILLIS, soundEnd);\n\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_URI, pref.getString(\"sound\", \"\"));\n\t\t\tif(pref.contains(\"volume\"))\n\t\t\t\tsound.putExtra(DawnSound.EXTRA_SOUND_VOLUME, pref.getInt(\"volume\", 0));\t\t\t\n\t\t\tstartService(sound);\n\t\t\tupdateBrightness(System.currentTimeMillis());\n\t\t\tm_timer = new Timer();\n\t\t\tm_timer.schedule(\n\t\t\t\t\tnew TimerTask() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\trunOnUiThread(\n\t\t\t\t\t\t\t\t\tnew Runnable() {\n\t\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\t\tupdateBrightness(System.currentTimeMillis());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}, TIMER_TICK_SECONDS*1000, TIMER_TICK_SECONDS*1000);\n\t\t}\n\t}\n"} {"input": " public void visitForExpression(final JFXForExpression tree) {\n result = (new Translator( tree.pos(), toJava ) {\n private final TypeMorphInfo tmiResult = typeMorpher.typeMorphInfo(targetType(tree.type));\n private final Type resultElementType = tmiResult.getElementType();\n private final Type resultSequenceLocationType = typeMorpher.generifyIfNeeded(typeMorpher.locationType(TYPE_KIND_SEQUENCE), tmiResult);\n private final boolean isSimple = false; \n private JCExpression makeResultClass() {\n return makeTypeInfo(diagPos, resultElementType);\n }\n private JCVariableDecl makeParam(Type type, Name name) {\n return make.at(diagPos).VarDef(\n make.Modifiers(Flags.PARAMETER | Flags.FINAL),\n name,\n makeExpression(type),\n null);\n }\n private JCExpression makeCore() {\n JCExpression body = translate(tree.getBodyExpression());\n if (!types.isSequence(tree.getBodyExpression().type)) {\n List<JCExpression> args = List.of(makeResultClass(), body);\n body = runtime(diagPos, cBoundSequences, \"singleton\", args);\n }\n JCExpression whereTest = null;\n for (JFXForExpressionInClause clause : tree.getForExpressionInClauses()) {\n JCExpression where = translate(clause.getWhereExpression());\n if (where != null) {\n if (whereTest == null) {\n whereTest = where;\n } else {\n whereTest = runtime(diagPos, cBoundOperators, \"and_bb\", List.of(whereTest, where));\n }\n }\n }\n if (whereTest != null) {\n body = makeBoundConditional(diagPos,\n tree.type,\n body,\n runtime(diagPos, cBoundSequences, \"empty\", List.of(makeTypeInfo(diagPos, resultElementType))),\n whereTest);\n }\n return body;\n }\n private JCTree makeComputeElementsMethod(JFXForExpressionInClause clause, JCExpression inner, TypeMorphInfo tmiInduction) {\n Type iVarType;\n Type idxVarType;\n Name computeName;\n if (isSimple) {\n iVarType = tmiInduction.getRealFXType();\n idxVarType = syms.intType;\n computeName = computeElementsName;\n } else {\n iVarType = tmiInduction.getLocationType();\n idxVarType = typeMorpher.locationType(TYPE_KIND_INT);\n computeName = computeElementsName;\n }\n ListBuffer<JCStatement> stmts = ListBuffer.lb();\n Name ivarName = clause.getVar().name;\n stmts.append(m().Return( inner ));\n List<JCVariableDecl> params = List.of(\n makeParam(iVarType, ivarName),\n makeParam(idxVarType, indexVarName(clause) )\n );\n return m().MethodDef(\n m().Modifiers(Flags.PROTECTED),\n computeName,\n makeExpression( resultSequenceLocationType ),\n List.<JCTypeParameter>nil(),\n params,\n List.<JCExpression>nil(),\n m().Block(0L, stmts.toList()),\n null);\n }\n private JCExpression makeBoundComprehension(JFXForExpressionInClause clause, JCExpression inner) {\n JFXExpression seq = clause.getSequenceExpression();\n TypeMorphInfo tmiSeq = typeMorpher.typeMorphInfo(seq.type);\n TypeMorphInfo tmiInduction = typeMorpher.typeMorphInfo(clause.getVar().type);\n Type elementType = tmiSeq.getElementType();\n JCClassDecl classDecl = m().AnonymousClassDef(\n m().Modifiers(0L),\n List.<JCTree>of(makeComputeElementsMethod(clause, inner, tmiInduction)));\n List<JCExpression> typeArgs = List.nil();\n boolean useIndex = clause.getIndexUsed();\n JCExpression transSeq = translate( seq );\n if (!tmiSeq.isSequence()) {\n transSeq = runtime(diagPos, cBoundSequences, \"singleton\", List.of(makeResultClass(), transSeq));\n }\n List<JCExpression> constructorArgs = List.of(\n makeResultClass(),\n transSeq,\n m().Literal(TypeTags.BOOLEAN, useIndex? 1 : 0) );\n int typeKind = tmiInduction.getTypeKind();\n Type bcType = typeMorpher.boundComprehensionNCT[typeKind].type;\n JCExpression clazz = makeExpression(types.erasure(bcType)); \n ListBuffer<JCExpression> typeParams = ListBuffer.lb();\n if (typeKind == TYPE_KIND_OBJECT) {\n typeParams.append( makeExpression(elementType) );\n }\n typeParams.append( makeExpression(resultElementType) );\n clazz = m().TypeApply(clazz, typeParams.toList());\n return m().NewClass(null,\n typeArgs,\n clazz,\n constructorArgs,\n classDecl);\n }\n public JCExpression doit() {\n List<JFXForExpressionInClause> clauses = tree.getForExpressionInClauses();\n JCExpression expr = makeCore();\n for (int inx = clauses.size() - 1; inx >= 0; --inx) {\n JFXForExpressionInClause clause = clauses.get(inx);\n expr = makeBoundComprehension(clause, expr);\n }\n return expr;\n }\n }).doit();\n }\n", "output": " public void visitForExpression(final JFXForExpression tree) {\n result = (new Translator( tree.pos(), toJava ) {\n private final TypeMorphInfo tmiResult = typeMorpher.typeMorphInfo(targetType(tree.type));\n private final Type resultElementType = tmiResult.getElementType();\n private final Type resultSequenceLocationType = typeMorpher.generifyIfNeeded(typeMorpher.locationType(TYPE_KIND_SEQUENCE), tmiResult);\n private final boolean isSimple = false; \n private JCExpression makeResultClass() {\n return makeTypeInfo(diagPos, resultElementType);\n }\n private JCVariableDecl makeParam(Type type, Name name) {\n return make.at(diagPos).VarDef(\n make.Modifiers(Flags.PARAMETER | Flags.FINAL),\n name,\n makeExpression(type),\n null);\n }\n private JCExpression makeCore() {\n JCExpression body;\n if (types.isSequence(tree.getBodyExpression().type)) {\n body = translate(tree.getBodyExpression(), tmiTarget);\n } else {\n JCExpression single = translate(tree.getBodyExpression(), tmiTarget.getElementType());\n List<JCExpression> args = List.of(makeResultClass(), single);\n body = runtime(diagPos, cBoundSequences, \"singleton\", args);\n }\n JCExpression whereTest = null;\n for (JFXForExpressionInClause clause : tree.getForExpressionInClauses()) {\n JCExpression where = translate(clause.getWhereExpression());\n if (where != null) {\n if (whereTest == null) {\n whereTest = where;\n } else {\n whereTest = runtime(diagPos, cBoundOperators, \"and_bb\", List.of(whereTest, where));\n }\n }\n }\n if (whereTest != null) {\n body = makeBoundConditional(diagPos,\n tree.type,\n body,\n runtime(diagPos, cBoundSequences, \"empty\", List.of(makeTypeInfo(diagPos, resultElementType))),\n whereTest);\n }\n return body;\n }\n private JCTree makeComputeElementsMethod(JFXForExpressionInClause clause, JCExpression inner, TypeMorphInfo tmiInduction) {\n Type iVarType;\n Type idxVarType;\n Name computeName;\n if (isSimple) {\n iVarType = tmiInduction.getRealFXType();\n idxVarType = syms.intType;\n computeName = computeElementsName;\n } else {\n iVarType = tmiInduction.getLocationType();\n idxVarType = typeMorpher.locationType(TYPE_KIND_INT);\n computeName = computeElementsName;\n }\n ListBuffer<JCStatement> stmts = ListBuffer.lb();\n Name ivarName = clause.getVar().name;\n stmts.append(m().Return( inner ));\n List<JCVariableDecl> params = List.of(\n makeParam(iVarType, ivarName),\n makeParam(idxVarType, indexVarName(clause) )\n );\n return m().MethodDef(\n m().Modifiers(Flags.PROTECTED),\n computeName,\n makeExpression( resultSequenceLocationType ),\n List.<JCTypeParameter>nil(),\n params,\n List.<JCExpression>nil(),\n m().Block(0L, stmts.toList()),\n null);\n }\n private JCExpression makeBoundComprehension(JFXForExpressionInClause clause, JCExpression inner) {\n JFXExpression seq = clause.getSequenceExpression();\n TypeMorphInfo tmiSeq = typeMorpher.typeMorphInfo(seq.type);\n TypeMorphInfo tmiInduction = typeMorpher.typeMorphInfo(clause.getVar().type);\n Type elementType = tmiSeq.getElementType();\n JCClassDecl classDecl = m().AnonymousClassDef(\n m().Modifiers(0L),\n List.<JCTree>of(makeComputeElementsMethod(clause, inner, tmiInduction)));\n List<JCExpression> typeArgs = List.nil();\n boolean useIndex = clause.getIndexUsed();\n JCExpression transSeq = translate( seq );\n if (!tmiSeq.isSequence()) {\n transSeq = runtime(diagPos, cBoundSequences, \"singleton\", List.of(makeResultClass(), transSeq));\n }\n List<JCExpression> constructorArgs = List.of(\n makeResultClass(),\n transSeq,\n m().Literal(TypeTags.BOOLEAN, useIndex? 1 : 0) );\n int typeKind = tmiInduction.getTypeKind();\n Type bcType = typeMorpher.boundComprehensionNCT[typeKind].type;\n JCExpression clazz = makeExpression(types.erasure(bcType)); \n ListBuffer<JCExpression> typeParams = ListBuffer.lb();\n if (typeKind == TYPE_KIND_OBJECT) {\n typeParams.append( makeExpression(elementType) );\n }\n typeParams.append( makeExpression(resultElementType) );\n clazz = m().TypeApply(clazz, typeParams.toList());\n return m().NewClass(null,\n typeArgs,\n clazz,\n constructorArgs,\n classDecl);\n }\n public JCExpression doit() {\n List<JFXForExpressionInClause> clauses = tree.getForExpressionInClauses();\n JCExpression expr = makeCore();\n for (int inx = clauses.size() - 1; inx >= 0; --inx) {\n JFXForExpressionInClause clause = clauses.get(inx);\n expr = makeBoundComprehension(clause, expr);\n }\n return expr;\n }\n }).doit();\n }\n"} {"input": " AnnotationDefinitionList(Collection<AnnotationDefinition> definitions, boolean addIdentifierToList) {\n if (definitions == null) {\n throw new IllegalArgumentException(\"Argument definitions was null.\");\n }\n if (addIdentifierToList) {\n names.add(IdentifierCriterionWrapper.IDENTIFIER_FIELD_NAME);\n nameToDefinitionMap.put(IdentifierCriterionWrapper.IDENTIFIER_FIELD_NAME, null);\n }\n for (AnnotationDefinition definition : definitions) {\n if (!AnnotationTypeEnum.DATE.getValue().equalsIgnoreCase(definition.getType())) {\n noDateNames.add(definition.getDisplayName());\n }\n names.add(definition.getDisplayName());\n nameToDefinitionMap.put(definition.getDisplayName(), definition);\n Cai2Util.loadCollection(definition.getPermissibleValueCollection());\n }\n Collections.sort(names);\n Collections.sort(noDateNames);\n }\n", "output": " AnnotationDefinitionList(Collection<AnnotationDefinition> definitions, boolean addIdentifierToList) {\n if (definitions == null) {\n throw new IllegalArgumentException(\"Argument definitions was null.\");\n }\n if (addIdentifierToList) {\n names.add(IdentifierCriterionWrapper.IDENTIFIER_FIELD_NAME);\n noDateNames.add(IdentifierCriterionWrapper.IDENTIFIER_FIELD_NAME);\n nameToDefinitionMap.put(IdentifierCriterionWrapper.IDENTIFIER_FIELD_NAME, null);\n }\n for (AnnotationDefinition definition : definitions) {\n if (!AnnotationTypeEnum.DATE.getValue().equalsIgnoreCase(definition.getType())) {\n noDateNames.add(definition.getDisplayName());\n }\n names.add(definition.getDisplayName());\n nameToDefinitionMap.put(definition.getDisplayName(), definition);\n Cai2Util.loadCollection(definition.getPermissibleValueCollection());\n }\n Collections.sort(names);\n Collections.sort(noDateNames);\n }\n"} {"input": " public void startGame() {\n d(\"Starting game.\");\n state = GameState.INGAME;\n updateSigns();\n int item = rand.nextInt(players.size());\n d(item); \n int i = 0;\n for (String name : players.keySet()) {\n if (i == item) {\n it = name;\n }\n i++;\n }\n d(\"Selected IT: \" + it);\n for (Player player : getPlayers()) {\n Manager.saveInventory(player);\n player.setHealth(player.getMaxHealth());\n player.setFoodLevel(20);\n removePotionEffects(player);\n if (player.getName().equalsIgnoreCase(it)) {\n d(\"Equipping IT: \" + player.getName());\n Equip.equipIt(player);\n } else {\n d(\"Equipping other: \" + player.getName());\n Equip.equipOther(player);\n }\n player.setHealth(player.getMaxHealth());\n player.teleport(spawn);\n }\n setupScoreboard();\n if (safeperiod) {\n d(\"Safe period active\");\n safe = true;\n new BukkitRunnable() {\n @Override\n public void run() {\n d(\"Safe period no longer active.\");\n safe = false;\n }\n }.runTaskLater(plugin, plugin.getConfig().getLong(\"safe-period-time\", 20L) * 20);\n }\n endRun = new BukkitRunnable() {\n public void run() {\n d(\"Ending game.\");\n reset(false);\n }\n };\n endRun.runTaskLater(plugin, plugin.getConfig().getLong(\"match-duration\", 20L) * 400);\n }\n", "output": " public void startGame() {\n d(\"Starting game.\");\n state = GameState.INGAME;\n updateSigns();\n int item = rand.nextInt(players.size());\n d(item); \n int i = 0;\n for (String name : players.keySet()) {\n if (i == item) {\n it = name;\n }\n i++;\n }\n d(\"Selected IT: \" + it);\n for (Player player : getPlayers()) {\n Manager.saveInventory(player);\n player.setHealth(player.getMaxHealth());\n player.setFoodLevel(20);\n removePotionEffects(player);\n if (player.getName().equalsIgnoreCase(it)) {\n d(\"Equipping IT: \" + player.getName());\n Equip.equipIt(player);\n } else {\n d(\"Equipping other: \" + player.getName());\n Equip.equipOther(player);\n }\n player.setHealth(player.getMaxHealth());\n player.teleport(spawn);\n }\n setupScoreboard();\n if (safeperiod) {\n d(\"Safe period active\");\n safe = true;\n new BukkitRunnable() {\n @Override\n public void run() {\n d(\"Safe period no longer active.\");\n safe = false;\n }\n }.runTaskLater(plugin, plugin.getConfig().getLong(\"safe-period-time\", 20L) * 20);\n }\n endRun = new BukkitRunnable() {\n public void run() {\n d(\"Ending game.\");\n reset(false);\n }\n };\n endRun.runTaskLater(plugin, plugin.getConfig().getLong(\"match-duration\", 20L) * 20);\n }\n"} {"input": "\tpublic void myClickHandler(View view) {\n\t\tswitch (view.getId()) {\n\t\tcase R.id.BacksideUpdaterButton:\n\t\t\ttry {\n\t\t\t\tif (ALREADY_CHECKED == 0) {\n\t\t\t\t\tALREADY_CHECKED = 1;\n\t\t\t\t\ttextView.setText(\"\");\n\t\t\t\t\tHttpClient client = new DefaultHttpClient();\n\t\t\t\t\tHttpGet request = new HttpGet(updateManifestUrl);\n\t\t\t\t\tHttpResponse response = client.execute(request);\n\t\t\t\t\tBufferedReader rd = new BufferedReader(new InputStreamReader(\n\t\t\t\t\t\t\tresponse.getEntity().getContent()));\n\t\t\t\t\tString line = rd.readLine();\n\t\t\t\t\tString[] separated = line.split(\",\");\n\t\t\t\t\ttheDate = separated[0];\n\t\t\t\t\ttheUrl = separated[1];\n\t\t\t\t\ttheChangeLog = separated[2];\n\t\t\t\t\ttheMD5 = separated[3];\n\t\t\t\t\tromName = separated[4];\n\t\t\t\t\tlocalFileName = \"/download/\"+romName;\n\t\t\t\t\ttheFileSize = separated[5];\n\t\t\t\t\tupToDate = (Integer.parseInt(theDate) < BUILD_DATE);\n\t\t\t\t\tString file = android.os.Environment.getExternalStorageDirectory().getPath() + localFileName;\n\t\t\t\t\tFile f = new File(file);\n\t\t\t\t\tif (!upToDate) {\n\t\t\t\t\t\tif (f.exists()) {\n\t\t\t\t\t\t\tif (!checkFileSize(romName)){\n\t\t\t\t\t\t\t\tshowCustomToast(\"The latest build is already downloaded\\n\\nClick the button to check the MD5 sum\");\n\t\t\t\t\t\t\t\ttextView.setText(\"Latest build is already downloaded.\\n\\nReady to check md5\\n\\nBe patient after clicking!\");\n\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Check MD5 Now\");\n\t\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tshowCustomToast(\"Download not yet complete\\n\\nCheck the notification dropdown\\nfor download status.\\n\\nOr press back to exit the Updater,\\ndelete the partially downloaded file,\\nand restart Updater to try again.\");\n\t\t\t\t\t\t\t\ttextView.setText(\"Download not complete.\\n\\nCheck the notification dropdown\\nand try again.\\n\\nIf you have an incomplete download,\\ndelete the partially downloaded file,\\nand try again.\");\n\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Check Download Status\");\n\t\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttextView.setText(\"Change Log \"+theDate+\"\\n\\n\"+theChangeLog);\n\t\t\t\t\t\t\tshowCustomToast(\"A new build is available:\\n\\nBACKside-IHO-VM670-\"+theDate);\n\t\t\t\t\t\t\tbuttonTextView.setText(\"Download Now\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextView.setText(\"Current: \"+BUILD_DATE+\"\\n\\nAvailable: \"+theDate+\"\\n\\nCheck again later\");\n\t\t\t\t\t\tbuttonTextView.setText(\"Already Up To Date\");\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (ALREADY_CHECKED == 1){\n\t\t\t\t\t\tif(upToDate){\n\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\tIntent downloadUpdate = new Intent(Intent.ACTION_VIEW);\n\t\t\t\t\t\t\tdownloadUpdate.setData(Uri.parse(theUrl));\n\t\t\t\t\t\t\tstartActivity(downloadUpdate);\n\t\t\t\t\t\t\ttextView.setText(\"Wait for download to complete\\n\\nReboot into recovery\\n\\nWipe cache & dalvik cache\\nThen flash the zip file\");\n\t\t\t\t\t\t\tbuttonTextView.setText(\"Check Download Status\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdownloadComplete = checkFileSize(romName);\n\t\t\t\t\t\tif (!(downloadComplete)) {\n\t\t\t\t\t\t\tif(checkMD5(theMD5, romName)){\n\t\t\t\t\t\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t\t\t\t\t.setTitle(\"MD5 Verified!\")\n\t\t\t\t\t\t\t\t.setIcon(R.drawable.download_complete_icon)\n\t\t\t\t\t\t\t\t.setMessage(\"Reboot into recovery,\\nwipe cache & dalvik-cache,\\nthen flash the zip file located\\nin the download directory\")\n\t\t\t\t\t\t\t\t.setPositiveButton(\"Reboot Recovery\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Rebooting into Recovery...\");\n\t\t\t\t\t\t\t\t\t\tRebootCmd(\"reboot\", \"recovery\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.setNegativeButton(\"Later\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Yummy Gingerbread!\");\n\t\t\t\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}).show();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t\t\t\t\t.setTitle(\"Download Error\")\n\t\t\t\t\t\t\t\t.setIcon(R.drawable.md5_error)\n\t\t\t\t\t\t\t\t.setMessage(\"The downloaded file md5\\n\"+downloadMD5+\"\\ndoes not match the build\\n\"+theMD5+\"\\nTry downloading again!\")\n\t\t\t\t\t\t\t\t.setPositiveButton(\"Download again\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Wait for download to complete\\n\\nCheck the notification dropdown\");\n\t\t\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Check Again\");\n\t\t\t\t\t\t\t\t\t\tIntent downloadUpdate = new Intent(Intent.ACTION_VIEW);\n\t\t\t\t\t\t\t\t\t\tdownloadUpdate.setData(Uri.parse(theUrl));\n\t\t\t\t\t\t\t\t\t\tstartActivity(downloadUpdate);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.setNegativeButton(\"Later\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Yummy Gingerbread!\");\n\t\t\t\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}).show();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\tString file = android.os.Environment.getExternalStorageDirectory().getPath() + localFileName;\n\t\t\t\t\t\t\tFile f = new File(file);\n\t\t\t\t\t\t\tif (f.exists()) {\n\t\t\t\t\t\t\t\tshowCustomToast(\"Download not yet complete\\n\\nCheck the notification dropdown\\nfor download status.\\n\\nOr press back to exit the Updater,\\ndelete the partially downloaded file,\\nand restart Updater to try again.\");\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tALREADY_CHECKED = 1;\n\t\t\t\t\t\t\t\tshowCustomToast(\"Download has not started\\n\\nClick the button to try again now.\");\n\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Download Now\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tSystem.out.println(\"Nay, did not work\");\n\t\t\t\ttextView.setText(e.getMessage());\n\t\t\t\t}\n\t\t\tbreak;\n\t\t\t}\n\t\t}\n", "output": "\tpublic void myClickHandler(View view) {\n\t\tswitch (view.getId()) {\n\t\tcase R.id.BacksideUpdaterButton:\n\t\t\ttry {\n\t\t\t\tif (ALREADY_CHECKED == 0) {\n\t\t\t\t\tALREADY_CHECKED = 1;\n\t\t\t\t\ttextView.setText(\"\");\n\t\t\t\t\tHttpClient client = new DefaultHttpClient();\n\t\t\t\t\tHttpGet request = new HttpGet(updateManifestUrl);\n\t\t\t\t\tHttpResponse response = client.execute(request);\n\t\t\t\t\tBufferedReader rd = new BufferedReader(new InputStreamReader(\n\t\t\t\t\t\t\tresponse.getEntity().getContent()));\n\t\t\t\t\tString line = rd.readLine();\n\t\t\t\t\tString[] separated = line.split(\",\");\n\t\t\t\t\ttheDate = separated[0];\n\t\t\t\t\ttheUrl = separated[1];\n\t\t\t\t\ttheChangeLog = separated[2];\n\t\t\t\t\ttheMD5 = separated[3];\n\t\t\t\t\tromName = separated[4];\n\t\t\t\t\tlocalFileName = \"/download/\"+romName;\n\t\t\t\t\ttheFileSize = separated[5];\n\t\t\t\t\tupToDate = (BUILD_DATE >= Integer.parseInt(theDate));\n\t\t\t\t\tString file = android.os.Environment.getExternalStorageDirectory().getPath() + localFileName;\n\t\t\t\t\tFile f = new File(file);\n\t\t\t\t\tif (!upToDate) {\n\t\t\t\t\t\tif (f.exists()) {\n\t\t\t\t\t\t\tif (!checkFileSize(romName)){\n\t\t\t\t\t\t\t\tshowCustomToast(\"The latest build is already downloaded\\n\\nClick the button to check the MD5 sum\");\n\t\t\t\t\t\t\t\ttextView.setText(\"Latest build is already downloaded.\\n\\nReady to check md5\\n\\nBe patient after clicking!\");\n\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Check MD5 Now\");\n\t\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tshowCustomToast(\"Download not yet complete\\n\\nCheck the notification dropdown\\nfor download status.\\n\\nOr press back to exit the Updater,\\ndelete the partially downloaded file,\\nand restart Updater to try again.\");\n\t\t\t\t\t\t\t\ttextView.setText(\"Download not complete.\\n\\nCheck the notification dropdown\\nand try again.\\n\\nIf you have an incomplete download,\\ndelete the partially downloaded file,\\nand try again.\");\n\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Check Download Status\");\n\t\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttextView.setText(\"Change Log \"+theDate+\"\\n\\n\"+theChangeLog);\n\t\t\t\t\t\t\tshowCustomToast(\"A new build is available:\\n\\nBACKside-IHO-VM670-\"+theDate);\n\t\t\t\t\t\t\tbuttonTextView.setText(\"Download Now\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttextView.setText(\"Current: \"+BUILD_DATE+\"\\n\\nAvailable: \"+theDate+\"\\n\\nCheck again later\");\n\t\t\t\t\t\tbuttonTextView.setText(\"Already Up To Date\");\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (ALREADY_CHECKED == 1){\n\t\t\t\t\t\tif(upToDate){\n\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\tIntent downloadUpdate = new Intent(Intent.ACTION_VIEW);\n\t\t\t\t\t\t\tdownloadUpdate.setData(Uri.parse(theUrl));\n\t\t\t\t\t\t\tstartActivity(downloadUpdate);\n\t\t\t\t\t\t\ttextView.setText(\"Wait for download to complete\\n\\nReboot into recovery\\n\\nWipe cache & dalvik cache\\nThen flash the zip file\");\n\t\t\t\t\t\t\tbuttonTextView.setText(\"Check Download Status\");\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdownloadComplete = checkFileSize(romName);\n\t\t\t\t\t\tif (!(downloadComplete)) {\n\t\t\t\t\t\t\tif(checkMD5(theMD5, romName)){\n\t\t\t\t\t\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t\t\t\t\t.setTitle(\"MD5 Verified!\")\n\t\t\t\t\t\t\t\t.setIcon(R.drawable.download_complete_icon)\n\t\t\t\t\t\t\t\t.setMessage(\"Reboot into recovery,\\nwipe cache & dalvik-cache,\\nthen flash the zip file located\\nin the download directory\")\n\t\t\t\t\t\t\t\t.setPositiveButton(\"Reboot Recovery\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Rebooting into Recovery...\");\n\t\t\t\t\t\t\t\t\t\tRebootCmd(\"reboot\", \"recovery\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.setNegativeButton(\"Later\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Yummy Gingerbread!\");\n\t\t\t\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}).show();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t\t\t\t\t.setTitle(\"Download Error\")\n\t\t\t\t\t\t\t\t.setIcon(R.drawable.md5_error)\n\t\t\t\t\t\t\t\t.setMessage(\"The downloaded file md5\\n\"+downloadMD5+\"\\ndoes not match the build\\n\"+theMD5+\"\\nTry downloading again!\")\n\t\t\t\t\t\t\t\t.setPositiveButton(\"Download again\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Wait for download to complete\\n\\nCheck the notification dropdown\");\n\t\t\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Check Again\");\n\t\t\t\t\t\t\t\t\t\tIntent downloadUpdate = new Intent(Intent.ACTION_VIEW);\n\t\t\t\t\t\t\t\t\t\tdownloadUpdate.setData(Uri.parse(theUrl));\n\t\t\t\t\t\t\t\t\t\tstartActivity(downloadUpdate);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.setNegativeButton(\"Later\", new DialogInterface.OnClickListener() {\n\t\t\t\t\t\t\t\t\t\tpublic void onClick(DialogInterface dialog, int whichButton) {\n\t\t\t\t\t\t\t\t\t\ttextView.setText(\"Yummy Gingerbread!\");\n\t\t\t\t\t\t\t\t\t\tSystem.exit(0);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}).show();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tALREADY_CHECKED = 2;\n\t\t\t\t\t\t\tString file = android.os.Environment.getExternalStorageDirectory().getPath() + localFileName;\n\t\t\t\t\t\t\tFile f = new File(file);\n\t\t\t\t\t\t\tif (f.exists()) {\n\t\t\t\t\t\t\t\tshowCustomToast(\"Download not yet complete\\n\\nCheck the notification dropdown\\nfor download status.\\n\\nOr press back to exit the Updater,\\ndelete the partially downloaded file,\\nand restart Updater to try again.\");\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tALREADY_CHECKED = 1;\n\t\t\t\t\t\t\t\tshowCustomToast(\"Download has not started\\n\\nClick the button to try again now.\");\n\t\t\t\t\t\t\t\tbuttonTextView.setText(\"Download Now\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tSystem.out.println(\"Nay, did not work\");\n\t\t\t\ttextView.setText(e.getMessage());\n\t\t\t\t}\n\t\t\tbreak;\n\t\t\t}\n\t\t}\n"} {"input": " private static AbstractValueType mapNumericType(SPSSVariable variable) {\n switch(getSpssNumericDataType(variable)) {\n case COMMA: \n case DOLLAR: \n case DOT: \n case FIXED: \n case SCIENTIFIC: \n return variable.getDecimals() > 0 ? DecimalType.get() : IntegerType.get();\n case DATE: \n case ADATE: \n case EDATE: \n case SDATE: \n return DateType.get();\n case DATETIME: \n return DateTimeType.get();\n case TIME: \n case JDATE: \n case DTIME: \n case WEEK_DAY: \n case MONTH: \n case MONTH_YEAR: \n case QUARTERLY_YEAR: \n case WEEK_YEAR: \n case CUSTOM_CURRENCY_A: \n case CUSTOM_CURRENCY_B: \n case CUSTOM_CURRENCY_C: \n case CUSTOM_CURRENCY_D: \n case CUSTOM_CURRENCY_E: \n default:\n return TextType.get();\n }\n }\n", "output": " private static AbstractValueType mapNumericType(SPSSVariable variable) {\n switch(getSpssNumericDataType(variable)) {\n case COMMA: \n case DOLLAR: \n case DOT: \n case FIXED: \n case SCIENTIFIC: \n return variable.getDecimals() > 0 ? DecimalType.get() : IntegerType.get();\n case ADATE: \n case EDATE: \n case SDATE: \n return DateType.get();\n case DATETIME: \n return DateTimeType.get();\n case DATE: \n case TIME: \n case JDATE: \n case DTIME: \n case WEEK_DAY: \n case MONTH: \n case MONTH_YEAR: \n case QUARTERLY_YEAR: \n case WEEK_YEAR: \n case CUSTOM_CURRENCY_A: \n case CUSTOM_CURRENCY_B: \n case CUSTOM_CURRENCY_C: \n case CUSTOM_CURRENCY_D: \n case CUSTOM_CURRENCY_E: \n default:\n return TextType.get();\n }\n }\n"} {"input": "\t\tpublic void run() {\n\t\t\twhile (true) {\n\t\t\t\toutput.println(\"I get to run!!!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(10); \n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tPacket p = new Packet(theRF.receive()); \n\t\t\t\tshort destAddr = p.getDestAddr();\n\t\t\t\tif((destAddr&0xffff) == ourMAC || (destAddr&0xffff) == 65535){\n\t\t\t\t\toutput.println(\"Packet for us\");\n\t\t\t\t\tif((destAddr&0xffff) == ourMAC && p.getFrameType() == 0){\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\ttheLinkLayer.getIn().put(p); \n\t\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbyte[] fakeCRC = new byte[4]; \n\t\t\t\t\t\tfakeCRC[0] = 15;\n\t\t\t\t\t\tfakeCRC[1] = 15;\n\t\t\t\t\t\tfakeCRC[2] = 15;\n\t\t\t\t\t\tfakeCRC[3] = 15;\n\t\t\t\t\t\tPacket ack = new Packet(1, p.getSeqNum(), p.getSrcAddr(), ourMAC, null, fakeCRC);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tThread.sleep((long)0.01); \n\t\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\toutput.println(\"RF is free: \"+ theRF.inUse());\n\t\t\t\t\t\ttheRF.transmit(ack.getFrame());\n\t\t\t\t\t\toutput.println(\"Sent an ACK\");\n\t\t\t\t\t}\n\t\t\t\t\telse if((destAddr&0xffff) == ourMAC && p.getFrameType() == 1){\n\t\t\t\t\t\toutput.println(\"Saw an ACK\");\n\t\t\t\t\t\tif(theLinkLayer.recievedACKS.containsKey(p.getSrcAddr())){\n\t\t\t\t\t\t\tif(theLinkLayer.recievedACKS.get(p.getSrcAddr()).contains(p.getSeqNum())){\n\t\t\t\t\t\t\t\toutput.println(\"Already got this ACK\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\ttheLinkLayer.recievedACKS.get(p.getSrcAddr()).add(p.getSeqNum());\n\t\t\t\t\t\t\t\toutput.println(\"Added an ACK for \"+ p.getSeqNum()+ \" from \"+p.getSrcAddr());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse{\n\t\t\t\t\t\t\tArrayList<Short> newHost = new ArrayList<Short>();\n\t\t\t\t\t\t\tnewHost.add(p.getSeqNum());\n\t\t\t\t\t\t\ttheLinkLayer.recievedACKS.put(p.getSrcAddr(), newHost);\n\t\t\t\t\t\t\toutput.println(\"Added an ACK for \"+ p.getSeqNum()+ \" from \"+p.getSrcAddr());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\toutput.println(\"Didn't ACK a packet of type: \"+ p.getFrameType() + \" to address \"+ (destAddr&0xffff));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\toutput.println(\"Addr: \"+ destAddr);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n", "output": "\t\tpublic void run() {\n\t\t\twhile (true) {\n\t\t\t\toutput.println(\"I get to run!!!\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(10); \n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tPacket p = new Packet(theRF.receive()); \n\t\t\t\tshort destAddr = p.getDestAddr();\n\t\t\t\tif((destAddr&0xffff) == ourMAC || (destAddr&0xffff) == 65535){\n\t\t\t\t\toutput.println(\"Packet for us\");\n\t\t\t\t\tif((destAddr&0xffff) == ourMAC && p.getFrameType() == 0){\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\ttheLinkLayer.getIn().put(p); \n\t\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbyte[] fakeCRC = new byte[4]; \n\t\t\t\t\t\tfakeCRC[0] = 15;\n\t\t\t\t\t\tfakeCRC[1] = 15;\n\t\t\t\t\t\tfakeCRC[2] = 15;\n\t\t\t\t\t\tfakeCRC[3] = 15;\n\t\t\t\t\t\tPacket ack = new Packet(1, p.getSeqNum(), p.getSrcAddr(), ourMAC, null, fakeCRC);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tThread.sleep(RF.aSIFSTime); \n\t\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\toutput.println(\"RF is free: \"+ theRF.inUse());\n\t\t\t\t\t\ttheRF.transmit(ack.getFrame());\n\t\t\t\t\t\toutput.println(\"Sent an ACK\");\n\t\t\t\t\t}\n\t\t\t\t\telse if((destAddr&0xffff) == ourMAC && p.getFrameType() == 1){\n\t\t\t\t\t\toutput.println(\"Saw an ACK\");\n\t\t\t\t\t\tif(theLinkLayer.recievedACKS.containsKey(p.getSrcAddr())){\n\t\t\t\t\t\t\tif(theLinkLayer.recievedACKS.get(p.getSrcAddr()).contains(p.getSeqNum())){\n\t\t\t\t\t\t\t\toutput.println(\"Already got this ACK\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\ttheLinkLayer.recievedACKS.get(p.getSrcAddr()).add(p.getSeqNum());\n\t\t\t\t\t\t\t\toutput.println(\"Added an ACK for \"+ p.getSeqNum()+ \" from \"+p.getSrcAddr());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse{\n\t\t\t\t\t\t\tArrayList<Short> newHost = new ArrayList<Short>();\n\t\t\t\t\t\t\tnewHost.add(p.getSeqNum());\n\t\t\t\t\t\t\ttheLinkLayer.recievedACKS.put(p.getSrcAddr(), newHost);\n\t\t\t\t\t\t\toutput.println(\"Added an ACK for \"+ p.getSeqNum()+ \" from \"+p.getSrcAddr());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\toutput.println(\"Didn't ACK a packet of type: \"+ p.getFrameType() + \" to address \"+ (destAddr&0xffff));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\toutput.println(\"Addr: \"+ destAddr);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n"} {"input": " protected boolean parseMsg(String body, Data data) {\n if (body.startsWith(\"KOOTENAI COUNTY SHERIFF \")) {\n body = body.substring(25).trim();\n }\n int pt = body.indexOf(\"\\nSent by CLI\");\n if (pt >= 0) body = body.substring(0,pt).trim();\n String[] flds = body.split(\"\\n\");\n if (flds.length < 5) return false;\n return parseFields(flds, data);\n }\n", "output": " protected boolean parseMsg(String body, Data data) {\n if (body.startsWith(\"KOOTENAI COUNTY SHERIFF \")) {\n body = body.substring(24).trim();\n }\n int pt = body.indexOf(\"\\nSent by CLI\");\n if (pt >= 0) body = body.substring(0,pt).trim();\n String[] flds = body.split(\"\\n\");\n if (flds.length < 5) return false;\n return parseFields(flds, data);\n }\n"} {"input": "\tpublic ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)\n\t{\n\t\tArrayList<ItemStack> drops = new ArrayList<ItemStack>();\n\t\tdrops.add(new ItemStack(blockID, 1, 0));\n\t\tif((metadata & 3) > 0)\n\t\t{\n\t\t\tdrops.add(new ItemStack(MineFactoryReloadedCore.rawRubberItem, 1 + world.rand.nextInt(fortune)));\n\t\t}\n\t\treturn drops;\n\t}\n", "output": "\tpublic ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)\n\t{\n\t\tArrayList<ItemStack> drops = new ArrayList<ItemStack>();\n\t\tdrops.add(new ItemStack(blockID, 1, 0));\n\t\tif((metadata & 3) > 0)\n\t\t{\n\t\t\tdrops.add(new ItemStack(MineFactoryReloadedCore.rawRubberItem, fortune <= 0 ? 1 : 1 + world.rand.nextInt(fortune)));\n\t\t}\n\t\treturn drops;\n\t}\n"} {"input": " public ImageIcon getIcon(Class<?> loader,String iconName) {\n if(!loadedIcons.containsKey(iconName)) {\n URL url = loader.getResource(iconName+\".png\");\n if(url!=null) {\n ImageIcon newIcon = new ImageIcon(url);\n loadedIcons.put(iconName, newIcon);\n return newIcon;\n } else {\n LOG.warn(I18N.getString(\"sif.icons.OrbisGISIcon.icon_not_found\")+\" : \"+iconName);\n loadedIcons.put(iconName, ORBISGIS_MISSING_ICON); \n return ORBISGIS_MISSING_ICON;\n } \n } else {\n return loadedIcons.get(iconName);\n }\n }\n", "output": " public ImageIcon getIcon(Class<?> loader,String iconName) {\n if(!loadedIcons.containsKey(iconName)) {\n String resourceName = iconName+\".png\";\n URL url = loader.getResource(resourceName);\n if(url!=null) {\n ImageIcon newIcon = new ImageIcon(url);\n loadedIcons.put(iconName, newIcon);\n return newIcon;\n } else {\n LOG.warn(I18N.getString(\"sif.icons.OrbisGISIcon.icon_not_found\")+\" : \"+resourceName);\n loadedIcons.put(iconName, ORBISGIS_MISSING_ICON); \n return ORBISGIS_MISSING_ICON;\n } \n } else {\n return loadedIcons.get(iconName);\n }\n }\n"} {"input": " public void setupTrigger() throws SchedulerException {\n scheduler = new StdSchedulerFactory().getScheduler();\n Set<CronTaskEntity> allCronTasks = cronService.getAllCronTasks();\n for (CronTaskEntity cronTaskEntity : allCronTasks) {\n JobDataMap jobDataMap = new JobDataMap();\n jobDataMap.put(\"frequency\", cronTaskEntity.getFrequency());\n JobDetail job = new JobDetail();\n job.setName(cronTaskEntity.getFrequency().getFrequencyName());\n job.setJobClass(IndicatorValueCalculatorJob.class);\n job.setJobDataMap(jobDataMap);\n Trigger trigger = prepareTrigger(cronTaskEntity);\n scheduler.scheduleJob(job, trigger);\n }\n scheduler.start();\n scheduler.shutdown(true);\n }\n", "output": " public void setupTrigger() throws SchedulerException {\n scheduler = new StdSchedulerFactory().getScheduler();\n Set<CronTaskEntity> allCronTasks = cronService.getAllCronTasks();\n for (CronTaskEntity cronTaskEntity : allCronTasks) {\n JobDataMap jobDataMap = new JobDataMap();\n jobDataMap.put(\"frequency\", cronTaskEntity.getFrequency());\n JobDetail job = new JobDetail();\n job.setName(cronTaskEntity.getFrequency().getFrequencyName());\n job.setJobClass(IndicatorValueCalculatorJob.class);\n job.setJobDataMap(jobDataMap);\n Trigger trigger = prepareTrigger(cronTaskEntity);\n scheduler.scheduleJob(job, trigger);\n }\n scheduler.start();\n }\n"} {"input": "\t\tpublic void action() {\n\t\t\tMessage msg= (Message)message.getContentObject();\n\t\t\tHistory hist = msg.getHistory();\n\t\t\tHistEl prevEl = hist.getPreviousElement(0);\n\t\t\tHistEl prevprev_el = hist.getPreviousElement(1);\n\t\t\tagent.setBOTTOM(new BottomEl(prevEl.getLiteral(), hist.pop())) = true;\n\t\t\tboolean all_true = true;\n\t\t\tfor(Literal l: prevprev_el.getClause().asLiterals())\n\t\t\t\tif(agent.getBOTTOM(new BottomEl(l, hist.pop())) == false)\n\t\t\t\t\tall_true = false;\n\t\t\tif(all_true) {\n\t\t\t\tif((hist.pop().pop()).isEmpty()) {\n\t\t\t\t\tSystem.out.println(\"back\");\n\t\t\t\t\tSystem.out.println(\"final\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tACLMessage r1 = new ACLMessage();\n\t\t\t\t\tr1.addReceiver(message.getSender());\n\t\t\t\t\tr1.setContentObject(new BackMessage(hist.pop(), Clause.trueClause()));\n\t\t\t\t\tmyAgent.send(r1);\n\t\t\t\t\tACLMessage r2 = new ACLMessage();\n\t\t\t\t\tr2.addReceiver(message.getSender());\n\t\t\t\t\tr2.setContentObject(new FinalMessage(hist.pop(), Clause.trueClause()));\n\t\t\t\t\tmyAgent.send(r2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n", "output": "\t\tpublic void action() {\n\t\t\tMessage msg= (Message)message.getContentObject();\n\t\t\tHistory hist = msg.getHistory();\n\t\t\tHistEl prevEl = hist.getPreviousElement(0);\n\t\t\tHistEl prevprev_el = hist.getPreviousElement(1);\n\t\t\tagent.setBOTTOM(new BottomEl(prevEl.getLiteral(), hist.pop()), true);\n\t\t\tboolean all_true = true;\n\t\t\tfor(Literal l: prevprev_el.getClause().asLiterals())\n\t\t\t\tif(agent.getBOTTOM(new BottomEl(l, hist.pop())) == false)\n\t\t\t\t\tall_true = false;\n\t\t\tif(all_true) {\n\t\t\t\tif((hist.pop().pop()).isEmpty()) {\n\t\t\t\t\tSystem.out.println(\"back\");\n\t\t\t\t\tSystem.out.println(\"final\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tACLMessage r1 = new ACLMessage();\n\t\t\t\t\tr1.addReceiver(message.getSender());\n\t\t\t\t\tr1.setContentObject(new BackMessage(hist.pop(), Clause.trueClause()));\n\t\t\t\t\tmyAgent.send(r1);\n\t\t\t\t\tACLMessage r2 = new ACLMessage();\n\t\t\t\t\tr2.addReceiver(message.getSender());\n\t\t\t\t\tr2.setContentObject(new FinalMessage(hist.pop(), Clause.trueClause()));\n\t\t\t\t\tmyAgent.send(r2);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n"} {"input": "\tpublic static Test suite() {\n\t\tTestSuite suite = new TestSuite(\"Test for org.eclipse.mylar.bugzilla.tests\");\n\t\tsuite.addTestSuite(Bugzilla220ParserTest.class);\n\t\tsuite.addTestSuite(BugzillaRepositoryClientTest.class);\n\t\tsuite.addTestSuite(EncodingTest.class);\n\t\tsuite.addTestSuite(NewBugWizardTest.class);\n\t\tsuite.addTestSuite(RegularExpressionMatchTest.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestCDT.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestEquinox.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestGMT.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestPlatform.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestVE.class);\n\t\tsuite.addTestSuite(BugzillaParserTestNoBug.class);\n\t\tsuite.addTestSuite(BugzillaProductParserTest.class);\n\t\treturn suite;\n\t}\n", "output": "\tpublic static Test suite() {\n\t\tTestSuite suite = new TestSuite(\"Test for org.eclipse.mylar.bugzilla.tests\");\n\t\tsuite.addTestSuite(Bugzilla220ParserTest.class);\n\t\tsuite.addTestSuite(BugzillaRepositoryConnectorTest.class);\n\t\tsuite.addTestSuite(EncodingTest.class);\n\t\tsuite.addTestSuite(NewBugWizardTest.class);\n\t\tsuite.addTestSuite(RegularExpressionMatchTest.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestCDT.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestEquinox.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestGMT.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestPlatform.class);\n\t\tsuite.addTestSuite(BugzillaNewBugParserTestVE.class);\n\t\tsuite.addTestSuite(BugzillaParserTestNoBug.class);\n\t\tsuite.addTestSuite(BugzillaProductParserTest.class);\n\t\treturn suite;\n\t}\n"} {"input": " public SimpleObject getVisitDetails(\n @SpringBean(\"adminService\") AdministrationService administrationService,\n @RequestParam(\"visitId\") Visit visit,\n UiUtils uiUtils,\n EmrContext emrContext) throws ParseException {\n SimpleObject simpleObject = SimpleObject.fromObject(visit, uiUtils, \"id\", \"location\");\n User authenticatedUser = emrContext.getUserContext().getAuthenticatedUser();\n boolean canDelete = authenticatedUser.hasPrivilege(EmrConstants.PRIVILEGE_DELETE_ENCOUNTER);\n Date startDatetime = visit.getStartDatetime();\n Date stopDatetime = visit.getStopDatetime();\n simpleObject.put(\"startDatetime\", DateFormatUtils.format(startDatetime, \"dd MMM yyyy hh:mm a\"));\n if (stopDatetime!=null){\n simpleObject.put(\"stopDatetime\", DateFormatUtils.format(stopDatetime, \"dd MMM yyyy hh:mm a\"));\n } else {\n simpleObject.put(\"stopDatetime\", null);\n }\n List<SimpleObject> encounters = new ArrayList<SimpleObject>();\n simpleObject.put(\"encounters\", encounters);\n String[] datePatterns = { administrationService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_DATETIME_FORMAT) };\n for (Encounter e : visit.getEncounters()) {\n if (!e.getVoided()) {\n SimpleObject simpleEncounter = SimpleObject.fromObject(e, uiUtils, \"encounterId\", \"encounterDatetime\", \"location\", \"encounterProviders.provider\", \"voided\", \"form\");\n Date encounterDatetime = DateUtils.parseDate((String) simpleEncounter.get(\"encounterDatetime\"), datePatterns);\n simpleEncounter.put(\"encounterDate\", DateFormatUtils.format(encounterDatetime, \"dd MMM yyyy\"));\n simpleEncounter.put(\"encounterTime\", DateFormatUtils.format(encounterDatetime, \"hh:mm a\"));\n EncounterType encounterType = e.getEncounterType();\n simpleEncounter.put(\"encounterType\", SimpleObject.create(\"uuid\", encounterType.getUuid(), \"name\", uiUtils.format(encounterType)));\n if(canDelete){\n simpleEncounter.put(\"canDelete\", true);\n }\n encounters.add(simpleEncounter);\n }\n }\n return simpleObject;\n }\n", "output": " public SimpleObject getVisitDetails(\n @SpringBean(\"adminService\") AdministrationService administrationService,\n @RequestParam(\"visitId\") Visit visit,\n UiUtils uiUtils,\n EmrContext emrContext) throws ParseException {\n SimpleObject simpleObject = SimpleObject.fromObject(visit, uiUtils, \"id\", \"location\");\n User authenticatedUser = emrContext.getUserContext().getAuthenticatedUser();\n boolean canDelete = authenticatedUser.hasPrivilege(EmrConstants.PRIVILEGE_DELETE_ENCOUNTER);\n Date startDatetime = visit.getStartDatetime();\n Date stopDatetime = visit.getStopDatetime();\n simpleObject.put(\"startDatetime\", DateFormatUtils.format(startDatetime, \"dd MMM yyyy hh:mm a\", emrContext.getUserContext().getLocale()));\n if (stopDatetime!=null){\n simpleObject.put(\"stopDatetime\", DateFormatUtils.format(stopDatetime, \"dd MMM yyyy hh:mm a\", emrContext.getUserContext().getLocale()));\n } else {\n simpleObject.put(\"stopDatetime\", null);\n }\n List<SimpleObject> encounters = new ArrayList<SimpleObject>();\n simpleObject.put(\"encounters\", encounters);\n String[] datePatterns = { administrationService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_DATETIME_FORMAT) };\n for (Encounter e : visit.getEncounters()) {\n if (!e.getVoided()) {\n SimpleObject simpleEncounter = SimpleObject.fromObject(e, uiUtils, \"encounterId\", \"location\", \"encounterProviders.provider\", \"voided\", \"form\");\n simpleEncounter.put(\"encounterDate\", DateFormatUtils.format(e.getEncounterDatetime(), \"dd MMM yyyy\", emrContext.getUserContext().getLocale()));\n simpleEncounter.put(\"encounterTime\", DateFormatUtils.format(e.getEncounterDatetime(), \"hh:mm a\", emrContext.getUserContext().getLocale()));\n EncounterType encounterType = e.getEncounterType();\n simpleEncounter.put(\"encounterType\", SimpleObject.create(\"uuid\", encounterType.getUuid(), \"name\", uiUtils.format(encounterType)));\n if(canDelete){\n simpleEncounter.put(\"canDelete\", true);\n }\n encounters.add(simpleEncounter);\n }\n }\n return simpleObject;\n }\n"} {"input": "\tpublic void editorOpened(IEditorPart editorPartOpened) {\n\t\tIWorkbenchPage page = editorPartOpened.getSite().getPage();\n\t\tList<IEditorReference> toClose = new ArrayList<IEditorReference>();\n\t\tint totalTaskEditors = 0;\n\t\tfor (IEditorReference editorReference : page.getEditorReferences()) {\n\t\t\tif (editorReference.getId().equals(TaskEditor.ID_EDITOR)) {\n\t\t\t\ttotalTaskEditors++;\n\t\t\t}\n\t\t}\n\t\tif (totalTaskEditors > MAX_EDITORS) {\n\t\t\tfor (IEditorReference editorReference : page.getEditorReferences()) {\n\t\t\t\ttry {\n\t\t\t\t\tif (editorReference.getId().equals(TaskEditor.ID_EDITOR)) {\n\t\t\t\t\t\tTaskEditorInput taskEditorInput = (TaskEditorInput) editorReference.getEditorInput();\n\t\t\t\t\t\tTaskEditor taskEditor = (TaskEditor) editorReference.getEditor(false);\n\t\t\t\t\t\tif (taskEditor == null) {\n\t\t\t\t\t\t\ttoClose.add(editorReference);\n\t\t\t\t\t\t} else if (!taskEditor.equals(editorPartOpened) && !taskEditor.isDirty()\n\t\t\t\t\t\t\t\t&& taskEditorInput.getTask() != null\n\t\t\t\t\t\t\t\t&& taskEditorInput.getTask().getSynchronizationState().isSynchronized()) {\n\t\t\t\t\t\t\ttoClose.add(editorReference);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ((totalTaskEditors - toClose.size()) < MAX_EDITORS) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (PartInitException e) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (toClose.size() > 0) {\n\t\t\tpage.closeEditors(toClose.toArray(new IEditorReference[toClose.size()]), true);\n\t\t}\n\t}\n", "output": "\tpublic void editorOpened(IEditorPart editorPartOpened) {\n\t\tIWorkbenchPage page = editorPartOpened.getSite().getPage();\n\t\tList<IEditorReference> toClose = new ArrayList<IEditorReference>();\n\t\tint totalTaskEditors = 0;\n\t\tfor (IEditorReference editorReference : page.getEditorReferences()) {\n\t\t\tif (TaskEditor.ID_EDITOR.equals(editorReference.getId())) {\n\t\t\t\ttotalTaskEditors++;\n\t\t\t}\n\t\t}\n\t\tif (totalTaskEditors > MAX_EDITORS) {\n\t\t\tfor (IEditorReference editorReference : page.getEditorReferences()) {\n\t\t\t\ttry {\n\t\t\t\t\tif (TaskEditor.ID_EDITOR.equals(editorReference.getId())) {\n\t\t\t\t\t\tTaskEditorInput taskEditorInput = (TaskEditorInput) editorReference.getEditorInput();\n\t\t\t\t\t\tTaskEditor taskEditor = (TaskEditor) editorReference.getEditor(false);\n\t\t\t\t\t\tif (taskEditor == null) {\n\t\t\t\t\t\t\ttoClose.add(editorReference);\n\t\t\t\t\t\t} else if (!taskEditor.equals(editorPartOpened) && !taskEditor.isDirty()\n\t\t\t\t\t\t\t\t&& taskEditorInput.getTask() != null\n\t\t\t\t\t\t\t\t&& taskEditorInput.getTask().getSynchronizationState().isSynchronized()) {\n\t\t\t\t\t\t\ttoClose.add(editorReference);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ((totalTaskEditors - toClose.size()) < MAX_EDITORS) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch (PartInitException e) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (toClose.size() > 0) {\n\t\t\tpage.closeEditors(toClose.toArray(new IEditorReference[toClose.size()]), true);\n\t\t}\n\t}\n"} {"input": " private void generate(File dir) throws Exception {\n final File readme = new File(dir, \"README.md\");\n final PrintStream out = new PrintStream(IO.write(readme));\n out.print(\"Title: \");\n out.println(title(dir));\n out.println();\n out.println(\"*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/\" + dir.getName() + \") or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/\" + dir.getName() + \"). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*\");\n final File main = Files.file(dir, \"src\", \"main\");\n final File test = Files.file(dir, \"src\", \"test\");\n printJavaFiles(out, collect(main, Pattern.compile(\".*\\\\.java\")));\n printXmlFiles(out, collect(main, Pattern.compile(\".*\\\\.xml\")));\n printJavaFiles(out, collect(test, Pattern.compile(\".*\\\\.java\")));\n printXmlFiles(out, collect(test, Pattern.compile(\".*\\\\.xml\")));\n printBuildOutput(out, new File(\"/Users/dblevins/examples/\"+dir.getName()+\"/build.log\"));\n out.close();\n }\n", "output": " private void generate(File dir) throws Exception {\n final File readme = new File(dir, \"README.md\");\n final PrintStream out = new PrintStream(IO.write(readme));\n out.print(\"Title: \");\n out.println(title(dir));\n out.println();\n String path = dir.getAbsolutePath();\n path = path.substring(0, path.indexOf(\"examples/\") + 10);\n out.println(\"*Help us document this example! Source available in [svn](http://svn.apache.org/repos/asf/openejb/trunk/openejb/examples/\" + path + \") or [git](https://github.com/apache/openejb/tree/trunk/openejb/examples/\" + path + \"). Open a [JIRA](https://issues.apache.org/jira/browse/TOMEE) with patch or pull request*\");\n final File main = Files.file(dir, \"src\", \"main\");\n final File test = Files.file(dir, \"src\", \"test\");\n printJavaFiles(out, collect(main, Pattern.compile(\".*\\\\.java\")));\n printXmlFiles(out, collect(main, Pattern.compile(\".*\\\\.xml\")));\n printJavaFiles(out, collect(test, Pattern.compile(\".*\\\\.java\")));\n printXmlFiles(out, collect(test, Pattern.compile(\".*\\\\.xml\")));\n printBuildOutput(out, new File(\"/Users/dblevins/examples/\"+dir.getName()+\"/build.log\"));\n out.close();\n }\n"} {"input": "\tpublic Die(int side,int value) throws Exception\n\t{\n\t\tif (DiceTypes.isAllowed(side) == false)\n\t\t\tthrow new Exception(\"Invalid Dice Type\");\n\t\telse\n\t\t{\n\t\t\ti_sides = side;\n\t\t\tif (value >= 1 && value <= side)\n\t\t\t\ti_value = value;\n\t\t\telse\n\t\t\t\tthrow new Exception(\"Invalid Value. Must be between 1 and side\");\n\t\t}\t\n\t}\n", "output": "\tpublic Die(int value,int side) throws Exception\n\t{\n\t\tif (DiceTypes.isAllowed(side) == false)\n\t\t\tthrow new Exception(\"Invalid Dice Type\");\n\t\telse\n\t\t{\n\t\t\ti_sides = side;\n\t\t\tif (value >= 1 && value <= side)\n\t\t\t\ti_value = value;\n\t\t\telse\n\t\t\t\tthrow new Exception(\"Invalid Value. Must be between 1 and side\");\n\t\t}\t\n\t}\n"} {"input": " public Object clone() {\n LogicalColumn clone = new LogicalColumn();\n clone.setId(getId());\n clone.logicalTable = logicalTable;\n clone.physicalColumn = physicalColumn;\n for (String key : getChildProperties().keySet()) {\n clone.setProperty(key, getChildProperty(key));\n }\n return clone;\n }\n", "output": " public Object clone() {\n LogicalColumn clone = new LogicalColumn();\n clone.setId(getId());\n clone.logicalTable = logicalTable;\n clone.physicalColumn = physicalColumn;\n clone.setParentConcept(getParentConcept());\n for (String key : getChildProperties().keySet()) {\n clone.setProperty(key, getChildProperty(key));\n }\n return clone;\n }\n"} {"input": "\tpublic void execute() throws MojoExecutionException {\n\t\ttry {\n\t\t\tif (ignoreMissingFile && !fileExists(file)) {\n\t\t\t\tgetLog().info(\"Ignoring missing file\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgetLog().info(\"Replacing \" + token + \" with \" + value + \" in \" + file);\n\t\t\tif (outputFile != null) {\n\t\t\t\tgetLog().info(\"Outputting to: \" + outputFile);\n\t\t\t}\n\t\t\tgetTokenReplacer().replaceTokens(token, value, isRegex());\n\t\t} catch (IOException e) {\n\t\t\tthrow new MojoExecutionException(e.getMessage());\n\t\t}\n\t}\n", "output": "\tpublic void execute() throws MojoExecutionException {\n\t\ttry {\n\t\t\tif (ignoreMissingFile && !fileExists(file)) {\n\t\t\t\tgetLog().info(\"Ignoring missing file\");\n\t\t\t\treturn;\n\t\t\t}\n if (value != null) {\n getLog().info(\"Replacing \" + token + \" with \" + value + \" in \" + file);\n\t\t } else {\n getLog().info(\"Removing all instances of\" + token + \" in \" + file);\n\t\t\t}\n\t\t\tif (outputFile != null) {\n\t\t\t\tgetLog().info(\"Outputting to: \" + outputFile);\n\t\t\t}\n\t\t\tgetTokenReplacer().replaceTokens(token, value, isRegex());\n\t\t} catch (IOException e) {\n\t\t\tthrow new MojoExecutionException(e.getMessage());\n\t\t}\n\t}\n"} {"input": "\tprivate void addCreateProject() {\t\t\n\t\tSimplePanel container;\n\t\tLayoutContainer horizontalTable = new LayoutContainer();\n\t\thorizontalTable.addStyleName(\"row\");\n\t container = new SimplePanel(new HTML(SafeHtmlUtils.fromSafeConstant(\"<h1>\" + DisplayConstants.LABEL_PROJECT_NAME + \"</h1>\")));\n\t container.addStyleName(\"col-md-3\");\n\t horizontalTable.add(container);\n\t\tfinal TextBox textField = new TextBox();\n\t\ttextField.setStyleName(\"form-control input-lg\");\n\t\ttextField.addKeyDownHandler(new KeyDownHandler() {\t\t\t\t\n\t\t\t@Override\n\t\t\tpublic void onKeyDown(KeyDownEvent event) {\n\t\t\t\tif (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {\n\t\t\t\t\tcreateProject(textField.getValue());\n\t }\t\t\t\t\t\n\t\t\t}\n\t\t});\n\t container = new SimplePanel(textField);\n\t container.addStyleName(\"col-md-7\");\n\t horizontalTable.add(container);\n\t\tLayoutContainer searchButtonContainer = new LayoutContainer();\t\t\n\t\tButton createBtn = DisplayUtils.createButton(DisplayConstants.LABEL_CREATE, ButtonType.DEFAULT);\n\t\tcreateBtn.addStyleName(\"btn-block btn-lg\");\n\t\tcreateBtn.addClickHandler(new ClickHandler() {\t\t\t\n\t\t\t@Override\n\t\t\tpublic void onClick(ClickEvent event) {\n\t\t\t\tcreateProject(textField.getValue());\n\t\t\t}\n\t\t});\n\t searchButtonContainer.add(createBtn);\n\t container = new SimplePanel(searchButtonContainer);\n\t container.addStyleName(\"col-md-2\");\n\t horizontalTable.add(container);\n\t createProjectPanel.clear();\n\t createProjectPanel.add(horizontalTable);\n\t}\n", "output": "\tprivate void addCreateProject() {\t\t\n\t\tSimplePanel container;\n\t\tLayoutContainer horizontalTable = new LayoutContainer();\n\t\thorizontalTable.addStyleName(\"row\");\n\t container = new SimplePanel(new HTML(SafeHtmlUtils.fromSafeConstant(\"<h1>\" + DisplayConstants.LABEL_PROJECT_NAME + \"</h1>\")));\n\t container.addStyleName(\"col-md-3\");\n\t horizontalTable.add(container);\n\t\tfinal TextBox textField = new TextBox();\n\t\ttextField.setStyleName(\"form-control input-lg\");\n\t\ttextField.addKeyDownHandler(new KeyDownHandler() {\t\t\t\t\n\t\t\t@Override\n\t\t\tpublic void onKeyDown(KeyDownEvent event) {\n\t\t\t\tif (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {\n\t\t\t\t\tcreateProject(textField.getValue());\n\t }\t\t\t\t\t\n\t\t\t}\n\t\t});\n\t container = new SimplePanel(textField);\n\t container.addStyleName(\"col-md-7 col-sm-8 col-xs-8\");\n\t horizontalTable.add(container);\n\t\tLayoutContainer searchButtonContainer = new LayoutContainer();\t\t\n\t\tButton createBtn = DisplayUtils.createButton(DisplayConstants.LABEL_CREATE, ButtonType.DEFAULT);\n\t\tcreateBtn.addStyleName(\"btn-block btn-lg\");\n\t\tcreateBtn.addClickHandler(new ClickHandler() {\t\t\t\n\t\t\t@Override\n\t\t\tpublic void onClick(ClickEvent event) {\n\t\t\t\tcreateProject(textField.getValue());\n\t\t\t}\n\t\t});\n\t searchButtonContainer.add(createBtn);\n\t container = new SimplePanel(searchButtonContainer);\n\t container.addStyleName(\"col-md-2 col-sm-4 col-xs-4\");\n\t horizontalTable.add(container);\n\t createProjectPanel.clear();\n\t createProjectPanel.add(horizontalTable);\n\t}\n"} {"input": "\tpublic static Bitmap fixOrientation(Bitmap bm, int currentOrientation)\n\t{\n\t\tswitch (currentOrientation)\n\t\t{\n\t\t\tcase 2:\t\n\t\t\t{\n\t\t\t\treturn flip(bm, FLIP_HORIZONTAL);\n\t\t\t}\n\t\t\tcase 3:\t\n\t\t\t{\n\t\t\t\treturn rotate(bm, -180);\n\t\t\t}\n\t\t\tcase 4:\t\n\t\t\t{\n\t\t\t\treturn flip(bm, FLIP_VERTICAL);\n\t\t\t}\n\t\t\tcase 5:\t\n\t\t\t{\n\t\t\t\treturn rotate(flip(bm, FLIP_VERTICAL), 90);\t\t\t\t\n\t\t\t}\n\t\t\tcase 6:\t\n\t\t\t{\n\t\t\t\treturn rotate(bm, 90);\n\t\t\t}\n\t\t\tcase 7:\t\n\t\t\t{\n\t\t\t\treturn rotate(flip(bm, FLIP_HORIZONTAL), 90);\t\t\t\t\n\t\t\t}\n\t\t\tcase 8:\t\n\t\t\t{\n\t\t\t\treturn rotate(bm, 90);\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn bm;\n\t}\n", "output": "\tpublic static Bitmap fixOrientation(Bitmap bm, int currentOrientation)\n\t{\n\t\tswitch (currentOrientation)\n\t\t{\n\t\t\tcase 2:\n\t\t\t{\n\t\t\t\treturn flip(bm, FLIP_HORIZONTAL);\n\t\t\t}\n\t\t\tcase 3:\t\n\t\t\t{\n\t\t\t\treturn rotate(bm, -180);\n\t\t\t}\n\t\t\tcase 4:\t\n\t\t\t{\n\t\t\t\treturn flip(bm, FLIP_VERTICAL);\n\t\t\t}\n\t\t\tcase 5:\n\t\t\t{\n\t\t\t\treturn rotate(flip(bm, FLIP_VERTICAL), 90);\t\t\t\t\n\t\t\t}\n\t\t\tcase 6:\t\n\t\t\t{\n\t\t\t\treturn rotate(bm, 90);\n\t\t\t}\n\t\t\tcase 7:\t\n\t\t\t{\n\t\t\t\treturn rotate(flip(bm, FLIP_HORIZONTAL), 90);\t\t\t\t\n\t\t\t}\n\t\t\tcase 8:\t\n\t\t\t{\n\t\t\t\treturn rotate(bm, 90);\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn bm;\n\t}\n"} {"input": " public static void requestFriends(Long id) {\n User user = user();\n User other = User.findById(id);\n Relationship r1 = Relationship.find(\"SELECT r FROM Relationship r where r.from = ? AND r.to = ?\", user, other).first();\n Relationship r2 = Relationship.find(\"SELECT r FROM Relationship r where r.to = ? AND r.from = ?\", user, other).first();\n if (r1 == null) {\n r1 = new Relationship(user, other, true);\n }\n if (r2 != null) {\n if (r2.requested) {\n r1.requested = false;\n r2.requested = false;\n r1.accepted = true;\n r2.accepted = true;\n r1.save();\n r2.save();\n } else if (r2.accepted){\n news(id);\n return;\n } else {\n r1.requested = true;\n }\n }\n else if (r1 != null) {\n if (r1.requested) {\n news(id);\n return;\n } else {\n r1.requested = true;\n r1.save();\n news(id);\n return;\n }\n }\n r1.save();\n news(id);\n }\n", "output": " public static void requestFriends(Long id) {\n User user = user();\n User other = User.findById(id);\n Relationship r1 = Relationship.find(\"SELECT r FROM Relationship r where r.from = ? AND r.to = ?\", user, other).first();\n Relationship r2 = Relationship.find(\"SELECT r FROM Relationship r where r.to = ? AND r.from = ?\", user, other).first();\n if (r1 == null) {\n r1 = new Relationship(user, other, true);\n r1.save();\n }\n if (r2 != null) {\n if (r2.requested) {\n r1.requested = false;\n r2.requested = false;\n r1.accepted = true;\n r2.accepted = true;\n r1.save();\n r2.save();\n } else if (r2.accepted){\n news(id);\n return;\n } else {\n r1.requested = true;\n }\n }\n else if (r1 != null) {\n if (r1.requested) {\n news(id);\n return;\n } else {\n r1.requested = true;\n r1.save();\n news(id);\n return;\n }\n }\n System.out.println(r1.requested);\n r1.save();\n news(id);\n }\n"} {"input": " public void performHttp(HttpServletRewrite event, EvaluationContext context)\n {\n Gson gson = new Gson();\n try {\n String jsonString = event.getRequest().getParameter(\"payload\");\n System.out.println(jsonString);\n Map json = gson.fromJson(jsonString, Map.class);\n StringMap repository = (StringMap) json.get(\"repository\");\n String repo = (String) repository.get(\"url\");\n if (!repo.endsWith(\".git\"))\n repo = repo + \".git\";\n File repoDir = new File(root, safeFileName.transpose(event, context, repo));\n File cacheDir = new File(root, safeFileName.transpose(event, context, repo) + \"-cache\");\n if (!repoDir.exists())\n {\n repoDir.mkdirs();\n cacheDir.mkdirs();\n Git.cloneRepository().setURI(repo)\n .setCloneAllBranches(true).setDirectory(repoDir).call();\n }\n else\n {\n try {\n Git git = GitUtils.git(repoDir);\n GitUtils.pull(git, 15);\n deleteRecursively(cacheDir);\n cacheDir.mkdirs();\n }\n catch (GitAPIException e) {\n throw new RewriteException(\"Could not pull from git repository.\", e);\n }\n }\n }\n catch (Exception e) {\n throw new RewriteException(\"Error parsing update hook\", e);\n }\n }\n", "output": " public void performHttp(HttpServletRewrite event, EvaluationContext context)\n {\n Gson gson = new Gson();\n try {\n String jsonString = event.getRequest().getParameter(\"payload\");\n System.out.println(jsonString);\n Map json = gson.fromJson(jsonString, Map.class);\n StringMap repository = (StringMap) json.get(\"repository\");\n String repo = (String) repository.get(\"url\");\n if (!repo.endsWith(\".git\"))\n repo = repo + \".git\";\n File repoDir = new File(root, safeFileName.transpose(event, context, repo) + \"/repo\");\n File cacheDir = new File(root, safeFileName.transpose(event, context, repo) + \"/caches\");\n if (!repoDir.exists())\n {\n repoDir.mkdirs();\n cacheDir.mkdirs();\n Git.cloneRepository().setURI(repo)\n .setCloneAllBranches(true).setDirectory(repoDir).call();\n }\n else\n {\n try {\n Git git = GitUtils.git(repoDir);\n GitUtils.pull(git, 15);\n deleteRecursively(cacheDir);\n cacheDir.mkdirs();\n }\n catch (GitAPIException e) {\n throw new RewriteException(\"Could not pull from git repository.\", e);\n }\n }\n }\n catch (Exception e) {\n throw new RewriteException(\"Error parsing update hook\", e);\n }\n }\n"} {"input": " private String calculate() {\n \tdouble money, buy_p, sell_p, ticket, tax;\n \ttry {\n\t \tmoney = Double.parseDouble(i_money.getText().toString());\n\t \tbuy_p = Double.parseDouble(i_buy_p.getText().toString());\n\t \tsell_p = Double.parseDouble(i_sell_p.getText().toString());\n\t \tif(i_tax.getCheckedRadioButtonId() == i_tax_none.getId()) {\n\t \t\ttax = 0;\n\t \t} else if(i_tax.getCheckedRadioButtonId() == i_tax_cust.getId()) {\n\t \t\ttax = Double.parseDouble(i_cust_tax.getText().toString());\n\t \t} else {\n\t \t\ttax = 0;\n\t \t}\n\t \tticket = Double.parseDouble(i_ticket.getText().toString());\n \t} catch (NumberFormatException e) {\n \t\treturn \"Please fill with valid information\";\n \t}\n \tint amount = (int) Math.floor(money / buy_p);\n \tdouble expenditure = amount * buy_p - 2 * ticket;\n \tdouble revenue_taxless = amount * sell_p;\n \tdouble revenue = amount * sell_p * (1 / (1 + tax / 100));\n \tdouble income = revenue - expenditure;\n \treturn \"You get: \" \t\t\t+ amount \t+ \" items\\n\" +\n \t\t \"They cost (inc. travel): \" + expenditure + \"\\n\" +\n \t\t \"They sell for: \" \t+ revenue_taxless + \"\\n\" +\n \t\t \"Profit: \" \t\t\t+ income;\n }\n", "output": " private String calculate() {\n \tdouble money, buy_p, sell_p, ticket, tax;\n \ttry {\n\t \tmoney = Double.parseDouble(i_money.getText().toString());\n\t \tbuy_p = Double.parseDouble(i_buy_p.getText().toString());\n\t \tsell_p = Double.parseDouble(i_sell_p.getText().toString());\n\t \tif(i_tax.getCheckedRadioButtonId() == i_tax_none.getId()) {\n\t \t\ttax = 0;\n\t \t} else if(i_tax.getCheckedRadioButtonId() == i_tax_cust.getId()) {\n\t \t\ttax = Double.parseDouble(i_cust_tax.getText().toString());\n\t \t} else {\n\t \t\ttax = 0;\n\t \t}\n\t \tticket = Double.parseDouble(i_ticket.getText().toString());\n \t} catch (NumberFormatException e) {\n \t\treturn \"Please fill with valid information\";\n \t}\n \tint amount = (int) Math.floor(money / buy_p);\n \tdouble expenditure = amount * buy_p + 2 * ticket;\n \tdouble revenue_taxless = amount * sell_p;\n \tdouble revenue = amount * sell_p * (1 / (1 + tax / 100));\n \tdouble income = revenue - expenditure;\n \treturn \"You get: \" \t\t\t+ amount \t+ \" items\\n\" +\n \t\t \"They cost (inc. travel): \" + expenditure + \"\\n\" +\n \t\t \"They sell for: \" \t+ revenue_taxless + \"\\n\" +\n \t\t \"Profit: \" \t\t\t+ income;\n }\n"} {"input": "\tpublic Control createContents(Composite parent) {\n\t\tComposite client = new Composite(parent, SWT.NULL);\n\t\tGridLayout layout = new GridLayout();\n\t\tlayout.numColumns = 3;\n\t\tlayout.marginWidth = layout.marginHeight = 0;\n\t\tclient.setLayout(layout);\n\t\tclient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tComposite leftPanel = new Composite(client, SWT.NULL);\n\t\tGridLayout leftLayout = new GridLayout();\n\t\tleftLayout.numColumns = 1;\n\t\tleftLayout.marginWidth = leftLayout.marginHeight = 0;\n\t\tleftPanel.setLayout(leftLayout);\n\t\tleftPanel.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tLabel label = new Label(leftPanel, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.jobsLabel\")); \n\t\tcreateJobViewer(leftPanel);\n\t\tComposite centerPanel = new Composite(client, SWT.NULL);\n\t\tGridLayout centerLayout = new GridLayout();\n\t\tcenterLayout.numColumns = 1;\n\t\tcenterLayout.marginWidth = centerLayout.marginHeight = 0;\n\t\tcenterPanel.setLayout(centerLayout);\n\t\tcenterPanel.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tlabel = new Label(centerPanel, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.siteLabel\")); \n\t\tcreateSiteViewer(centerPanel);\n\t\tComposite rightPanel = new Composite(client, SWT.NULL);\n\t\tGridLayout rightLayout = new GridLayout();\n\t\trightLayout.numColumns = 1;\n\t\trightLayout.marginWidth = rightLayout.marginHeight = 0;\n\t\trightPanel.setLayout(rightLayout);\n\t\trightPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL));\n\t\tnew Label(rightPanel, SWT.NULL);\n\t\tComposite buttonContainer = new Composite(rightPanel, SWT.NULL);\n\t\tGridLayout blayout = new GridLayout();\n\t\tblayout.marginWidth = blayout.marginHeight = 0;\n\t\tbuttonContainer.setLayout(blayout);\n\t\tbuttonContainer.setLayoutData(new GridData(GridData.FILL_VERTICAL));\n\t\taddButton = new Button(buttonContainer, SWT.PUSH);\n\t\taddButton.setText(UpdateUI.getString(\"InstallWizard.TargetPage.new\")); \n\t\taddButton.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\taddTargetLocation();\n\t\t\t}\n\t\t});\n\t\taddButton.setEnabled(false);\n\t\taddButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));\n\t\tSWTUtil.setButtonDimensionHint(addButton);\n\t\tdeleteButton = new Button(buttonContainer, SWT.PUSH);\n\t\tdeleteButton.setText(UpdateUI.getString(\"InstallWizard.TargetPage.delete\")); \n\t\tdeleteButton.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\ttry {\n\t\t\t\t\tremoveSelection();\n\t\t\t\t}\n\t\t\t\tcatch (CoreException ex) {\n\t\t\t\t\tUpdateUI.logException(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tdeleteButton.setEnabled(false);\n\t\tdeleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));\n\t\tSWTUtil.setButtonDimensionHint(deleteButton);\t\t\n\t\tComposite status = new Composite(client, SWT.NULL);\n\t\tGridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);\n\t\tgd.horizontalSpan = 3;\n\t\tstatus.setLayoutData(gd);\n\t\tlayout = new GridLayout();\n\t\tlayout.numColumns = 2;\n\t\tstatus.setLayout(layout);\n\t\tlabel = new Label(status, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.requiredSpace\")); \n\t\trequiredSpaceLabel = new Label(status, SWT.NULL);\n\t\trequiredSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tlabel = new Label(status, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.availableSpace\")); \n\t\tavailableSpaceLabel = new Label(status, SWT.NULL);\n\t\tavailableSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tWorkbenchHelp.setHelp(client, \"org.eclipse.update.ui.MultiTargetPage2\"); \n\t\tDialog.applyDialogFont(parent);\n\t\treturn client;\n\t}\n", "output": "\tpublic Control createContents(Composite parent) {\n\t\tComposite client = new Composite(parent, SWT.NULL);\n\t\tGridLayout layout = new GridLayout();\n\t\tlayout.numColumns = 3;\n\t\tlayout.marginWidth = layout.marginHeight = 0;\n\t\tclient.setLayout(layout);\n\t\tclient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tComposite leftPanel = new Composite(client, SWT.NULL);\n\t\tGridLayout leftLayout = new GridLayout();\n\t\tleftLayout.numColumns = 1;\n\t\tleftLayout.marginWidth = leftLayout.marginHeight = 0;\n\t\tleftPanel.setLayout(leftLayout);\n\t\tleftPanel.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tLabel label = new Label(leftPanel, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.jobsLabel\")); \n\t\tcreateJobViewer(leftPanel);\n\t\tComposite centerPanel = new Composite(client, SWT.NULL);\n\t\tGridLayout centerLayout = new GridLayout();\n\t\tcenterLayout.numColumns = 1;\n\t\tcenterLayout.marginWidth = centerLayout.marginHeight = 0;\n\t\tcenterPanel.setLayout(centerLayout);\n\t\tcenterPanel.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tlabel = new Label(centerPanel, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.siteLabel\")); \n\t\tcreateSiteViewer(centerPanel);\n\t\tComposite rightPanel = new Composite(client, SWT.NULL);\n\t\tGridLayout rightLayout = new GridLayout();\n\t\trightLayout.numColumns = 1;\n\t\trightLayout.marginWidth = rightLayout.marginHeight = 0;\n\t\trightPanel.setLayout(rightLayout);\n\t\trightPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL));\n\t\tnew Label(rightPanel, SWT.NULL);\n\t\tComposite buttonContainer = new Composite(rightPanel, SWT.NULL);\n\t\tGridLayout blayout = new GridLayout();\n\t\tblayout.marginWidth = blayout.marginHeight = 0;\n\t\tbuttonContainer.setLayout(blayout);\n\t\tbuttonContainer.setLayoutData(new GridData(GridData.FILL_VERTICAL));\n\t\taddButton = new Button(buttonContainer, SWT.PUSH);\n\t\taddButton.setText(UpdateUI.getString(\"InstallWizard.TargetPage.new\")); \n\t\taddButton.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\taddTargetLocation();\n\t\t\t}\n\t\t});\n\t\taddButton.setEnabled(false);\n\t\taddButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));\n\t\tSWTUtil.setButtonDimensionHint(addButton);\n\t\tdeleteButton = new Button(buttonContainer, SWT.PUSH);\n\t\tdeleteButton.setText(UpdateUI.getString(\"InstallWizard.TargetPage.delete\")); \n\t\tdeleteButton.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\ttry {\n\t\t\t\t\tremoveSelection();\n\t\t\t\t}\n\t\t\t\tcatch (CoreException ex) {\n\t\t\t\t\tUpdateUI.logException(ex);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tdeleteButton.setEnabled(false);\n\t\tdeleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));\n\t\tSWTUtil.setButtonDimensionHint(deleteButton);\t\t\n\t\tComposite status = new Composite(client, SWT.NULL);\n\t\tGridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);\n\t\tgd.horizontalSpan = 3;\n\t\tstatus.setLayoutData(gd);\n\t\tlayout = new GridLayout();\n\t\tlayout.numColumns = 2;\n\t\tstatus.setLayout(layout);\n\t\tlabel = new Label(status, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.requiredSpace\")); \n\t\trequiredSpaceLabel = new Label(status, SWT.NULL);\n\t\trequiredSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tlabel = new Label(status, SWT.NULL);\n\t\tlabel.setText(UpdateUI.getString(\"InstallWizard.TargetPage.availableSpace\")); \n\t\tavailableSpaceLabel = new Label(status, SWT.NULL);\n\t\tavailableSpaceLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tWorkbenchHelp.setHelp(client, \"org.eclipse.update.ui.MultiTargetPage2\"); \n\t\tDialog.applyDialogFont(parent);\n\t\treturn client;\n\t}\n"} {"input": "\tpublic Object handleData(JsonElement jsonReq) {\n\t\tGson gson = new Gson();\n\t\tJsonReqSendMessageParams jsonReqParams;\n\t\ttry {\n\t\t\tjsonReqParams = gson.fromJson(jsonReq, JsonReqSendMessageParams.class);\n\t\t} catch (Exception e) {\n\t\t\treturn new SendMessageResponse(RES_BAD_REQUEST);\n\t\t}\n\t\tif (jsonReqParams.message == null || jsonReqParams.userID == null) {\n\t\t\treturn new SendMessageResponse(RES_BAD_REQUEST +\n\t\t\t\t\t\": must specify both user ID and message body.\");\n\t\t}\n\t\tProfile profile;\n\t\ttry {\n\t\t\tUserID uid = userIDFactory.getFromBase64(jsonReqParams.userID);\n\t\t\tprofile = socialFS.findProfile(uid);\n\t\t} catch (ProfileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn new SendMessageResponse(RES_NOT_FOUND);\n\t\t}\n\t\tContentMessage msg = smail.createContentMessage().setMessage(jsonReqParams.message);\n\t\tsmail.send(msg, profile);\n\t\treturn new SendMessageResponse();\n\t}\n", "output": "\tpublic Object handleData(JsonElement jsonReq) {\n\t\tGson gson = new Gson();\n\t\tJsonReqSendMessageParams jsonReqParams;\n\t\ttry {\n\t\t\tjsonReqParams = gson.fromJson(jsonReq, JsonReqSendMessageParams.class);\n\t\t} catch (Exception e) {\n\t\t\treturn new SendMessageResponse(RES_BAD_REQUEST);\n\t\t}\n\t\tif (jsonReqParams.message == null || jsonReqParams.userID == null) {\n\t\t\treturn new SendMessageResponse(RES_BAD_REQUEST +\n\t\t\t\t\t\": must specify both user ID and message body.\");\n\t\t}\n\t\tProfile profile;\n\t\ttry {\n\t\t\tUserID uid = userIDFactory.getFromBase64(jsonReqParams.userID);\n\t\t\tprofile = socialFS.findProfile(uid);\n\t\t} catch (ProfileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn new SendMessageResponse(RES_NOT_FOUND);\n\t\t} catch (IllegalArgumentException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn new SendMessageResponse(RES_BAD_REQUEST + \": illegal user ID.\");\n\t\t}\n\t\tContentMessage msg = smail.createContentMessage().setMessage(jsonReqParams.message);\n\t\tsmail.send(msg, profile);\n\t\treturn new SendMessageResponse();\n\t}\n"} {"input": "\tprotected void doPost(HttpServletRequest request, HttpServletResponse response)\n throws ServletException, IOException {\n\t\tresponse.setContentType(\"text/html;charset=UTF-8\");\n PrintWriter out = response.getWriter();\n HttpSession session = request.getSession();\n if (session == null) {\n }\n Connection connection;\n try {\n\t\t\tconnection = DbAdaptor.connect();\n\t\t} \n catch (Exception e1){\n \tout.println(\"db connection failed\");\n\t\t\te1.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tList<FileItem> items = null;\n \tFileItem files = null;\n \tString taskDir = \"\";\n \tint taskID = -1;\n\t\ttry {\n\t\t\titems = (List<FileItem>) new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);\n\t\t} catch (FileUploadException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n \tfor( FileItem item : items ) {\n \tif(item.isFormField()) {\n \t\tString field = item.getFieldName();\n \t\tif (field.equals(\"task\")) {\n \t\tString task = item.getString();\n \t\t\tif (task == null) {\n \t\t\t} else {\n \t\t\ttaskDir = TASKS_DIRECTORY + task + \"/\"; \t\t\t\t\n \t\t\t}\n \t\t}\n \t\tif( field.equals(\"taskID\") ) {\n \t\t\ttaskID = Integer.parseInt(item.getString());\n \t\t}\n \t}\n \telse {\n \t\tfiles = item;\n \t}\n \t}\n \tPreparedStatement checkTask;\n\t\ttry {\n\t\t\tcheckTask = connection.prepareStatement(\"SELECT id FROM tasks WHERE id = ? AND submitter = ?\");\n\t\t\tcheckTask.setInt(1, taskID);\n\t\t\tint accountID = 1;\n\t\t\tcheckTask.setInt(2, accountID);\n\t \tif (!checkTask.execute()) {\n\t \t\tout.println(\"invalid Task\");\n\t \t\tresponse.sendRedirect(\"/upload.html\");\n\t \t}\n\t\t} catch (SQLException e) {\n\t\t\tout.println(\"SQL problem slecting task from id\"); \n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tList<String> filenames = new LinkedList<String>();\n\t\tif (files.getName().substring(files.getName().length()-4).toLowerCase().equals(\".zip\")) {\n\t\t\tZipInputStream zipIn = new ZipInputStream(files.getInputStream());\n\t\t\tZipEntry entry = zipIn.getNextEntry();\n\t\t\twhile( entry != null ) {\n\t\t\t\tString filename = entry.getName();\n\t\t\t\tOutputStream fileOut = new FileOutputStream(taskDir + filename);\n\t\t\t\tIOUtils.copy(zipIn, fileOut);\n\t\t\t\tzipIn.closeEntry();\n\t\t\t\tfileOut.close();\n\t\t\t\tfilenames.add(filename);\n\t\t\t\tentry = zipIn.getNextEntry();\n\t\t\t}\n\t\t\tzipIn.close();\n\t\t} else {\n\t\t\tString filename = files.getName();\n\t\t\tfilenames.add(filename); \n\t InputStream fileIn = files.getInputStream();\n\t OutputStream fileOut = new FileOutputStream(taskDir + filename);\n\t IOUtils.copy(fileIn, fileOut);\n\t fileIn.close();\n\t fileOut.close();\n\t\t}\n \tfor (int i = 0 ; i < filenames.size() ; i++) {\n\t String insertQuery = \"INSERT INTO subtasks VALUES ?,?,?\";\n\t String filename = filenames.get(i);\n\t PreparedStatement stmt;\n\t try {\n\t\t\t\tstmt = connection.prepareStatement(insertQuery);\n\t\t\t\tstmt.setInt(1, taskID);\n\t\t stmt.setString(2, filename);\n\t\t stmt.setBoolean(3, true);\n\t\t stmt.execute();\n\t } catch (SQLException e1) {\n\t\t\t\tSystem.err.println(\"some error with task fields: taskID not valid?\");\n\t\t\t\tSystem.err.println(\"taskID: \" + taskID + \", filename: \" + filename);\n\t\t\t\treturn;\n\t\t\t}\n \t}\t\t\n out.println(\"<html>\");\n out.println(\"<body>\");\n out.println(\"uploaded to task \" + taskDir + \"<br>\"); \t\n out.println(\"click <a href=../index.jsp>here</a> to return to the homepage\");\n out.println(\"</body>\");\n out.println(\"</html>\");\n }\n}\n", "output": "\tprotected void doPost(HttpServletRequest request, HttpServletResponse response)\n throws ServletException, IOException {\n\t\tresponse.setContentType(\"text/html;charset=UTF-8\");\n PrintWriter out = response.getWriter();\n HttpSession session = request.getSession();\n if (session == null) {\n }\n Connection connection;\n try {\n\t\t\tconnection = DbAdaptor.connect();\n\t\t} \n catch (Exception e1){\n \tout.println(\"db connection failed\");\n\t\t\te1.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tList<FileItem> items = null;\n \tFileItem files = null;\n \tString taskDir = \"\";\n \tint taskID = -1;\n\t\ttry {\n\t\t\titems = (List<FileItem>) new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);\n\t\t} catch (FileUploadException e) {\n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n \tfor( FileItem item : items ) {\n \tif(item.isFormField()) {\n \t\tString field = item.getFieldName();\n \t\tif (field.equals(\"task\")) {\n \t\tString task = item.getString();\n \t\t\tif (task == null) {\n \t\t\t} else {\n \t\t\ttaskDir = TASKS_DIRECTORY + task + \"/\"; \t\t\t\t\n \t\t\t}\n \t\t}\n \t\tif( field.equals(\"taskID\") ) {\n \t\t\ttaskID = Integer.parseInt(item.getString());\n \t\t}\n \t}\n \telse {\n \t\tfiles = item;\n \t}\n \t}\n \tPreparedStatement checkTask;\n\t\ttry {\n\t\t\tcheckTask = connection.prepareStatement(\"SELECT id FROM tasks WHERE id = ? AND submitter = ?\");\n\t\t\tcheckTask.setInt(1, taskID);\n\t\t\tint accountID = 1;\n\t\t\tcheckTask.setInt(2, accountID);\n\t \tif (!checkTask.execute()) {\n\t \t\tout.println(\"invalid Task\");\n\t \t\tresponse.sendRedirect(\"/upload.html\");\n\t \t}\n\t\t} catch (SQLException e) {\n\t\t\tout.println(\"SQL problem slecting task from id\"); \n\t\t\te.printStackTrace();\n\t\t\treturn;\n\t\t}\n\t\tList<String> filenames = new LinkedList<String>();\n\t\tif (files.getName().substring(files.getName().length()-4).toLowerCase().equals(\".zip\")) {\n\t\t\tZipInputStream zipIn = new ZipInputStream(files.getInputStream());\n\t\t\tZipEntry entry = zipIn.getNextEntry();\n\t\t\twhile( entry != null ) {\n\t\t\t\tString filename = entry.getName();\n\t\t\t\tOutputStream fileOut = new FileOutputStream(taskDir + filename);\n\t\t\t\tIOUtils.copy(zipIn, fileOut);\n\t\t\t\tzipIn.closeEntry();\n\t\t\t\tfileOut.close();\n\t\t\t\tfilenames.add(filename);\n\t\t\t\tentry = zipIn.getNextEntry();\n\t\t\t}\n\t\t\tzipIn.close();\n\t\t} else {\n\t\t\tString filename = files.getName();\n\t\t\tfilenames.add(filename); \n\t InputStream fileIn = files.getInputStream();\n\t OutputStream fileOut = new FileOutputStream(taskDir + filename);\n\t IOUtils.copy(fileIn, fileOut);\n\t fileIn.close();\n\t fileOut.close();\n\t\t}\n \tfor (int i = 0 ; i < filenames.size() ; i++) {\n\t String insertQuery = \"INSERT INTO subtasks VALUES (DEFAULT,?,?,?)\";\n\t String filename = filenames.get(i);\n\t PreparedStatement stmt;\n\t try {\n\t\t\t\tstmt = connection.prepareStatement(insertQuery);\n\t\t\t\tstmt.setInt(1, taskID);\n\t\t stmt.setString(2, filename);\n\t\t stmt.setBoolean(3, true);\n\t\t stmt.execute();\n\t } catch (SQLException e1) {\n\t\t\t\tSystem.err.println(\"some error with task fields: taskID not valid?\");\n\t\t\t\tSystem.err.println(\"taskID: \" + taskID + \", filename: \" + filename);\n\t\t\t\treturn;\n\t\t\t}\n \t}\t\t\n out.println(\"<html>\");\n out.println(\"<body>\");\n out.println(\"uploaded to task \" + taskDir + \"<br>\"); \t\n out.println(\"click <a href=../index.jsp>here</a> to return to the homepage\");\n out.println(\"</body>\");\n out.println(\"</html>\");\n }\n}\n"} {"input": " public void testSimpleManifest() throws CompilationException {\n File closureLibraryDirectory = new File(\"../closure-library/closure/goog/\");\n final List<File> dependencies = ImmutableList.of();\n String path = \"test/org/plovr/example.js\";\n File testFile = new File(path);\n JsSourceFile requiredInput = new JsSourceFile(path, testFile);\n final List<File> externs = ImmutableList.of();\n final boolean customExternsOnly = false;\n Manifest manifest = new Manifest(\n closureLibraryDirectory,\n dependencies,\n ImmutableList.<JsInput>of(requiredInput),\n externs,\n customExternsOnly);\n final ModuleConfig moduleConfig = null;\n Compilation compilerArguments = manifest.getCompilerArguments(moduleConfig);\n List<JSSourceFile> inputs = compilerArguments.getInputs();\n List<String> expectedNames = ImmutableList.copyOf(\n new String[] {\n \"base.js\",\n \"/goog/debug/error.js\",\n \"/goog/string/string.js\",\n \"/goog/asserts/asserts.js\",\n \"/goog/array/array.js\",\n \"/goog/debug/entrypointregistry.js\",\n \"/goog/debug/errorhandlerweakdep.js\",\n \"/goog/useragent/useragent.js\",\n \"/goog/events/browserfeature.js\",\n \"/goog/disposable/disposable.js\",\n \"/goog/events/event.js\",\n \"/goog/events/eventtype.js\",\n \"/goog/events/browserevent.js\",\n \"/goog/events/eventwrapper.js\",\n \"/goog/events/listener.js\",\n \"/goog/structs/simplepool.js\",\n \"/goog/useragent/jscript.js\",\n \"/goog/events/pools.js\",\n \"/goog/object/object.js\",\n \"/goog/events/events.js\",\n \"test/org/plovr/example.js\"\n }\n );\n assertEquals(expectedNames, Lists.transform(inputs, JS_SOURCE_FILE_TO_NAME));\n }\n", "output": " public void testSimpleManifest() throws CompilationException {\n File closureLibraryDirectory = new File(\"../closure-library/closure/goog/\");\n final List<File> dependencies = ImmutableList.of();\n String path = \"test/org/plovr/example.js\";\n File testFile = new File(path);\n JsSourceFile requiredInput = new JsSourceFile(path, testFile);\n final List<File> externs = ImmutableList.of();\n final boolean customExternsOnly = false;\n Manifest manifest = new Manifest(\n closureLibraryDirectory,\n dependencies,\n ImmutableList.<JsInput>of(requiredInput),\n externs,\n customExternsOnly);\n final ModuleConfig moduleConfig = null;\n Compilation compilerArguments = manifest.getCompilerArguments(moduleConfig);\n List<JSSourceFile> inputs = compilerArguments.getInputs();\n List<String> expectedNames = ImmutableList.copyOf(\n new String[] {\n \"base.js\",\n \"/goog/debug/error.js\",\n \"/goog/string/string.js\",\n \"/goog/asserts/asserts.js\",\n \"/goog/array/array.js\",\n \"/goog/debug/entrypointregistry.js\",\n \"/goog/debug/errorhandlerweakdep.js\",\n \"/goog/useragent/useragent.js\",\n \"/goog/events/browserfeature.js\",\n \"/goog/disposable/disposable.js\",\n \"/goog/events/event.js\",\n \"/goog/events/eventtype.js\",\n \"/goog/reflect/reflect.js\",\n \"/goog/events/browserevent.js\",\n \"/goog/events/eventwrapper.js\",\n \"/goog/events/listener.js\",\n \"/goog/structs/simplepool.js\",\n \"/goog/useragent/jscript.js\",\n \"/goog/events/pools.js\",\n \"/goog/object/object.js\",\n \"/goog/events/events.js\",\n \"test/org/plovr/example.js\"\n }\n );\n assertEquals(expectedNames, Lists.transform(inputs, JS_SOURCE_FILE_TO_NAME));\n }\n"} {"input": " protected void addBeanProps(DeserializationContext ctxt,\n BeanDescription beanDesc, BeanDeserializerBuilder builder)\n throws JsonMappingException\n {\n final SettableBeanProperty[] creatorProps =\n builder.getValueInstantiator().getFromObjectArguments(ctxt.getConfig());\n AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();\n boolean ignoreAny = false;\n {\n Boolean B = intr.findIgnoreUnknownProperties(beanDesc.getClassInfo());\n if (B != null) {\n ignoreAny = B.booleanValue();\n builder.setIgnoreUnknownProperties(ignoreAny);\n }\n }\n Set<String> ignored = ArrayBuilders.arrayToSet(intr.findPropertiesToIgnore(beanDesc.getClassInfo())); \n for (String propName : ignored) {\n builder.addIgnorable(propName);\n }\n AnnotatedMethod anySetter = beanDesc.findAnySetter();\n if (anySetter != null) {\n builder.setAnySetter(constructAnySetter(ctxt, beanDesc, anySetter));\n }\n if (anySetter == null) {\n Collection<String> ignored2 = beanDesc.getIgnoredPropertyNames();\n if (ignored2 != null) {\n for (String propName : ignored2) {\n builder.addIgnorable(propName);\n }\n }\n }\n final boolean useGettersAsSetters = (ctxt.isEnabled(MapperFeature.USE_GETTERS_AS_SETTERS)\n && ctxt.isEnabled(MapperFeature.AUTO_DETECT_GETTERS));\n List<BeanPropertyDefinition> propDefs = filterBeanProps(ctxt,\n beanDesc, builder, beanDesc.findProperties(), ignored);\n if (_factoryConfig.hasDeserializerModifiers()) {\n for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {\n propDefs = mod.updateProperties(ctxt.getConfig(), beanDesc, propDefs);\n }\n }\n for (BeanPropertyDefinition propDef : propDefs) {\n SettableBeanProperty prop = null;\n if (propDef.hasConstructorParameter()) {\n final String name = propDef.getName();\n for (SettableBeanProperty cp : creatorProps) {\n if (name.equals(cp.getName())) {\n prop = cp;\n break;\n }\n }\n if (prop == null) {\n throw ctxt.mappingException(\"Could not find creator property with name '\"+name+\"'\");\n }\n builder.addCreatorProperty(prop);\n continue;\n }\n if (propDef.hasSetter()) {\n Type propertyType = propDef.getSetter().getGenericParameterType(0);\n prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType);\n } else if (propDef.hasField()) {\n Type propertyType = propDef.getField().getGenericType();\n prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType);\n } else if (useGettersAsSetters && propDef.hasGetter()) {\n AnnotatedMethod getter = propDef.getGetter();\n Class<?> rawPropertyType = getter.getRawType();\n if (Collection.class.isAssignableFrom(rawPropertyType)\n || Map.class.isAssignableFrom(rawPropertyType)) {\n prop = constructSetterlessProperty(ctxt, beanDesc, propDef);\n }\n }\n if (prop != null) {\n Class<?>[] views = propDef.findViews();\n if (views == null) {\n if (!ctxt.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)) {\n views = NO_VIEWS;\n }\n }\n prop.setViews(views);\n builder.addProperty(prop);\n }\n }\n }\n", "output": " protected void addBeanProps(DeserializationContext ctxt,\n BeanDescription beanDesc, BeanDeserializerBuilder builder)\n throws JsonMappingException\n {\n final SettableBeanProperty[] creatorProps =\n builder.getValueInstantiator().getFromObjectArguments(ctxt.getConfig());\n AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();\n boolean ignoreAny = false;\n {\n Boolean B = intr.findIgnoreUnknownProperties(beanDesc.getClassInfo());\n if (B != null) {\n ignoreAny = B.booleanValue();\n builder.setIgnoreUnknownProperties(ignoreAny);\n }\n }\n Set<String> ignored = ArrayBuilders.arrayToSet(intr.findPropertiesToIgnore(beanDesc.getClassInfo())); \n for (String propName : ignored) {\n builder.addIgnorable(propName);\n }\n AnnotatedMethod anySetter = beanDesc.findAnySetter();\n if (anySetter != null) {\n builder.setAnySetter(constructAnySetter(ctxt, beanDesc, anySetter));\n }\n if (anySetter == null) {\n Collection<String> ignored2 = beanDesc.getIgnoredPropertyNames();\n if (ignored2 != null) {\n for (String propName : ignored2) {\n builder.addIgnorable(propName);\n }\n }\n }\n final boolean useGettersAsSetters = (ctxt.isEnabled(MapperFeature.USE_GETTERS_AS_SETTERS)\n && ctxt.isEnabled(MapperFeature.AUTO_DETECT_GETTERS));\n List<BeanPropertyDefinition> propDefs = filterBeanProps(ctxt,\n beanDesc, builder, beanDesc.findProperties(), ignored);\n if (_factoryConfig.hasDeserializerModifiers()) {\n for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) {\n propDefs = mod.updateProperties(ctxt.getConfig(), beanDesc, propDefs);\n }\n }\n for (BeanPropertyDefinition propDef : propDefs) {\n SettableBeanProperty prop = null;\n if (propDef.hasConstructorParameter()) {\n final String name = propDef.getName();\n if (creatorProps != null) {\n for (SettableBeanProperty cp : creatorProps) {\n if (name.equals(cp.getName())) {\n prop = cp;\n break;\n }\n }\n }\n if (prop == null) {\n throw ctxt.mappingException(\"Could not find creator property with name '\"+name+\"'\");\n }\n builder.addCreatorProperty(prop);\n continue;\n }\n if (propDef.hasSetter()) {\n Type propertyType = propDef.getSetter().getGenericParameterType(0);\n prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType);\n } else if (propDef.hasField()) {\n Type propertyType = propDef.getField().getGenericType();\n prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType);\n } else if (useGettersAsSetters && propDef.hasGetter()) {\n AnnotatedMethod getter = propDef.getGetter();\n Class<?> rawPropertyType = getter.getRawType();\n if (Collection.class.isAssignableFrom(rawPropertyType)\n || Map.class.isAssignableFrom(rawPropertyType)) {\n prop = constructSetterlessProperty(ctxt, beanDesc, propDef);\n }\n }\n if (prop != null) {\n Class<?>[] views = propDef.findViews();\n if (views == null) {\n if (!ctxt.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)) {\n views = NO_VIEWS;\n }\n }\n prop.setViews(views);\n builder.addProperty(prop);\n }\n }\n }\n"} {"input": " static boolean shortcutExists(Context context, String title, Intent intent) {\n final ContentResolver cr = context.getContentResolver();\n Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI,\n new String[] { \"title\", \"intent\" }, \"title=? and intent=?\",\n new String[] { title, intent.toUri(0) }, null);\n boolean result = false;\n try {\n result = c.moveToFirst();\n } finally {\n c.close();\n }\n return result;\n }\n static ArrayList<ItemInfo> getItemsInLocalCoordinates(Context context) {\n ArrayList<ItemInfo> items = new ArrayList<ItemInfo>();\n final ContentResolver cr = context.getContentResolver();\n Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, new String[] {\n LauncherSettings.Favorites.ITEM_TYPE, LauncherSettings.Favorites.CONTAINER,\n LauncherSettings.Favorites.SCREEN, LauncherSettings.Favorites.CELLX, LauncherSettings.Favorites.CELLY,\n LauncherSettings.Favorites.SPANX, LauncherSettings.Favorites.SPANY }, null, null, null);\n final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);\n final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);\n final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);\n final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);\n final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);\n final int spanXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANX);\n final int spanYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANY);\n try {\n while (c.moveToNext()) {\n ItemInfo item = new ItemInfo();\n item.cellX = c.getInt(cellXIndex);\n item.cellY = c.getInt(cellYIndex);\n item.spanX = c.getInt(spanXIndex);\n item.spanY = c.getInt(spanYIndex);\n item.container = c.getInt(containerIndex);\n item.itemType = c.getInt(itemTypeIndex);\n item.screenId = c.getInt(screenIndex);\n items.add(item);\n }\n } catch (Exception e) {\n items.clear();\n } finally {\n c.close();\n }\n return items;\n }\n FolderInfo getFolderById(Context context, HashMap<Long,FolderInfo> folderList, long id) {\n final ContentResolver cr = context.getContentResolver();\n Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, null,\n \"_id=? and (itemType=? or itemType=?)\",\n new String[] { String.valueOf(id),\n String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)}, null);\n try {\n if (c.moveToFirst()) {\n final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);\n final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);\n final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);\n final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);\n final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);\n final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);\n FolderInfo folderInfo = null;\n switch (c.getInt(itemTypeIndex)) {\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n folderInfo = findOrMakeFolder(folderList, id);\n break;\n }\n folderInfo.title = c.getString(titleIndex);\n folderInfo.id = id;\n folderInfo.container = c.getInt(containerIndex);\n folderInfo.screenId = c.getInt(screenIndex);\n folderInfo.cellX = c.getInt(cellXIndex);\n folderInfo.cellY = c.getInt(cellYIndex);\n return folderInfo;\n }\n } finally {\n c.close();\n }\n return null;\n }\n static void addItemToDatabase(Context context, final ItemInfo item, final long container,\n final long screenId, final int cellX, final int cellY, final boolean notify) {\n item.container = container;\n item.cellX = cellX;\n item.cellY = cellY;\n if (context instanceof Launcher && screenId < 0 &&\n container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n item.screenId = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);\n } else {\n item.screenId = screenId;\n }\n final ContentValues values = new ContentValues();\n final ContentResolver cr = context.getContentResolver();\n item.onAddToDatabase(values);\n LauncherAppState app = LauncherAppState.getInstance();\n item.id = app.getLauncherProvider().generateNewItemId();\n values.put(LauncherSettings.Favorites._ID, item.id);\n item.updateValuesWithCoordinates(values, item.cellX, item.cellY);\n Runnable r = new Runnable() {\n public void run() {\n String transaction = \"DbDebug Add item (\" + item.title + \") to db, id: \"\n + item.id + \" (\" + container + \", \" + screenId + \", \" + cellX + \", \"\n + cellY + \")\";\n Launcher.sDumpLogs.add(transaction);\n Log.d(TAG, transaction);\n cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :\n LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);\n synchronized (sBgLock) {\n checkItemInfoLocked(item.id, item, null);\n sBgItemsIdMap.put(item.id, item);\n switch (item.itemType) {\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n sBgFolders.put(item.id, (FolderInfo) item);\n case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:\n case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:\n if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP ||\n item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n sBgWorkspaceItems.add(item);\n } else {\n if (!sBgFolders.containsKey(item.container)) {\n String msg = \"adding item: \" + item + \" to a folder that \" +\n \" doesn't exist\";\n Log.e(TAG, msg);\n Launcher.dumpDebugLogsToConsole();\n }\n }\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:\n sBgAppWidgets.add((LauncherAppWidgetInfo) item);\n break;\n }\n }\n }\n };\n runOnWorkerThread(r);\n }\n static int getCellLayoutChildId(\n long container, long screen, int localCellX, int localCellY, int spanX, int spanY) {\n return (((int) container & 0xFF) << 24)\n | ((int) screen & 0xFF) << 16 | (localCellX & 0xFF) << 8 | (localCellY & 0xFF);\n }\n static int getCellCountX() {\n return mCellCountX;\n }\n static int getCellCountY() {\n return mCellCountY;\n }\n static void updateWorkspaceLayoutCells(int shortAxisCellCount, int longAxisCellCount) {\n mCellCountX = shortAxisCellCount;\n mCellCountY = longAxisCellCount;\n }\n static void deleteItemFromDatabase(Context context, final ItemInfo item) {\n final ContentResolver cr = context.getContentResolver();\n final Uri uriToDelete = LauncherSettings.Favorites.getContentUri(item.id, false);\n Runnable r = new Runnable() {\n public void run() {\n String transaction = \"DbDebug Delete item (\" + item.title + \") from db, id: \"\n + item.id + \" (\" + item.container + \", \" + item.screenId + \", \" + item.cellX +\n \", \" + item.cellY + \")\";\n Launcher.sDumpLogs.add(transaction);\n Log.d(TAG, transaction);\n cr.delete(uriToDelete, null, null);\n synchronized (sBgLock) {\n switch (item.itemType) {\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n sBgFolders.remove(item.id);\n for (ItemInfo info: sBgItemsIdMap.values()) {\n if (info.container == item.id) {\n String msg = \"deleting a folder (\" + item + \") which still \" +\n \"contains items (\" + info + \")\";\n Log.e(TAG, msg);\n Launcher.dumpDebugLogsToConsole();\n }\n }\n sBgWorkspaceItems.remove(item);\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:\n case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:\n sBgWorkspaceItems.remove(item);\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:\n sBgAppWidgets.remove((LauncherAppWidgetInfo) item);\n break;\n }\n sBgItemsIdMap.remove(item.id);\n sBgDbIconCache.remove(item);\n }\n }\n };\n runOnWorkerThread(r);\n }\n void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {\n final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);\n final ContentResolver cr = context.getContentResolver();\n final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;\n Iterator<Long> iter = screensCopy.iterator();\n while (iter.hasNext()) {\n long id = iter.next();\n if (id < 0) {\n iter.remove();\n }\n }\n Runnable r = new Runnable() {\n @Override\n public void run() {\n cr.delete(uri, null, null);\n int count = screensCopy.size();\n ContentValues[] values = new ContentValues[count];\n for (int i = 0; i < count; i++) {\n ContentValues v = new ContentValues();\n long screenId = screensCopy.get(i);\n v.put(LauncherSettings.WorkspaceScreens._ID, screenId);\n v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);\n Log.w(TAG, \"10249126 - updateWorkspaceScreenOrder(\" + screenId + \", \" + i + \")\");\n values[i] = v;\n }\n cr.bulkInsert(uri, values);\n sBgWorkspaceScreens.clear();\n sBgWorkspaceScreens.addAll(screensCopy);\n }\n };\n runOnWorkerThread(r);\n }\n static void deleteFolderContentsFromDatabase(Context context, final FolderInfo info) {\n final ContentResolver cr = context.getContentResolver();\n Runnable r = new Runnable() {\n public void run() {\n cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null);\n synchronized (sBgLock) {\n sBgItemsIdMap.remove(info.id);\n sBgFolders.remove(info.id);\n sBgDbIconCache.remove(info);\n sBgWorkspaceItems.remove(info);\n }\n cr.delete(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION,\n LauncherSettings.Favorites.CONTAINER + \"=\" + info.id, null);\n synchronized (sBgLock) {\n for (ItemInfo childInfo : info.contents) {\n sBgItemsIdMap.remove(childInfo.id);\n sBgDbIconCache.remove(childInfo);\n }\n }\n }\n };\n runOnWorkerThread(r);\n }\n public void initialize(Callbacks callbacks) {\n synchronized (mLock) {\n mCallbacks = new WeakReference<Callbacks>(callbacks);\n }\n }\n @Override\n public void onReceive(Context context, Intent intent) {\n if (DEBUG_LOADERS) Log.d(TAG, \"onReceive intent=\" + intent);\n final String action = intent.getAction();\n if (Intent.ACTION_PACKAGE_CHANGED.equals(action)\n || Intent.ACTION_PACKAGE_REMOVED.equals(action)\n || Intent.ACTION_PACKAGE_ADDED.equals(action)) {\n final String packageName = intent.getData().getSchemeSpecificPart();\n final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);\n int op = PackageUpdatedTask.OP_NONE;\n if (packageName == null || packageName.length() == 0) {\n return;\n }\n if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {\n op = PackageUpdatedTask.OP_UPDATE;\n } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {\n if (!replacing) {\n op = PackageUpdatedTask.OP_REMOVE;\n }\n } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {\n if (!replacing) {\n op = PackageUpdatedTask.OP_ADD;\n } else {\n op = PackageUpdatedTask.OP_UPDATE;\n }\n }\n if (op != PackageUpdatedTask.OP_NONE) {\n enqueuePackageUpdated(new PackageUpdatedTask(op, new String[] { packageName }));\n }\n } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {\n String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);\n enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages));\n startLoaderFromBackground();\n } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {\n String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);\n enqueuePackageUpdated(new PackageUpdatedTask(\n PackageUpdatedTask.OP_UNAVAILABLE, packages));\n } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {\n forceReload();\n } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {\n Configuration currentConfig = context.getResources().getConfiguration();\n if (mPreviousConfigMcc != currentConfig.mcc) {\n Log.d(TAG, \"Reload apps on config change. curr_mcc:\"\n + currentConfig.mcc + \" prevmcc:\" + mPreviousConfigMcc);\n forceReload();\n }\n mPreviousConfigMcc = currentConfig.mcc;\n } else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||\n SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {\n if (mCallbacks != null) {\n Callbacks callbacks = mCallbacks.get();\n if (callbacks != null) {\n callbacks.bindSearchablesChanged();\n }\n }\n }\n }\n private void forceReload() {\n resetLoadedState(true, true);\n startLoaderFromBackground();\n }\n public void resetLoadedState(boolean resetAllAppsLoaded, boolean resetWorkspaceLoaded) {\n synchronized (mLock) {\n stopLoaderLocked();\n if (resetAllAppsLoaded) mAllAppsLoaded = false;\n if (resetWorkspaceLoaded) mWorkspaceLoaded = false;\n }\n }\n public void startLoaderFromBackground() {\n boolean runLoader = false;\n if (mCallbacks != null) {\n Callbacks callbacks = mCallbacks.get();\n if (callbacks != null) {\n if (!callbacks.setLoadOnResume()) {\n runLoader = true;\n }\n }\n }\n if (runLoader) {\n startLoader(false, -1);\n }\n }\n private boolean stopLoaderLocked() {\n boolean isLaunching = false;\n LoaderTask oldTask = mLoaderTask;\n if (oldTask != null) {\n if (oldTask.isLaunching()) {\n isLaunching = true;\n }\n oldTask.stopLocked();\n }\n return isLaunching;\n }\n public void startLoader(boolean isLaunching, int synchronousBindPage) {\n synchronized (mLock) {\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"startLoader isLaunching=\" + isLaunching);\n }\n mDeferredBindRunnables.clear();\n if (mCallbacks != null && mCallbacks.get() != null) {\n isLaunching = isLaunching || stopLoaderLocked();\n mLoaderTask = new LoaderTask(mApp.getContext(), isLaunching);\n if (synchronousBindPage > -1 && mAllAppsLoaded && mWorkspaceLoaded) {\n mLoaderTask.runBindSynchronousPage(synchronousBindPage);\n } else {\n sWorkerThread.setPriority(Thread.NORM_PRIORITY);\n sWorker.post(mLoaderTask);\n }\n }\n }\n }\n void bindRemainingSynchronousPages() {\n if (!mDeferredBindRunnables.isEmpty()) {\n for (final Runnable r : mDeferredBindRunnables) {\n mHandler.post(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n mDeferredBindRunnables.clear();\n }\n }\n public void stopLoader() {\n synchronized (mLock) {\n if (mLoaderTask != null) {\n mLoaderTask.stopLocked();\n }\n }\n }\n private static TreeMap<Integer, Long> loadWorkspaceScreensDb(Context context) {\n final ContentResolver contentResolver = context.getContentResolver();\n final Uri screensUri = LauncherSettings.WorkspaceScreens.CONTENT_URI;\n final Cursor sc = contentResolver.query(screensUri, null, null, null, null);\n TreeMap<Integer, Long> orderedScreens = new TreeMap<Integer, Long>();\n try {\n final int idIndex = sc.getColumnIndexOrThrow(\n LauncherSettings.WorkspaceScreens._ID);\n final int rankIndex = sc.getColumnIndexOrThrow(\n LauncherSettings.WorkspaceScreens.SCREEN_RANK);\n while (sc.moveToNext()) {\n try {\n long screenId = sc.getLong(idIndex);\n int rank = sc.getInt(rankIndex);\n Log.w(TAG, \"10249126 - loadWorkspaceScreensDb(\" + screenId + \", \" + rank + \")\");\n orderedScreens.put(rank, screenId);\n } catch (Exception e) {\n Log.w(TAG, \"Desktop items loading interrupted - invalid screens: \", e);\n }\n }\n } finally {\n sc.close();\n }\n return orderedScreens;\n }\n public boolean isAllAppsLoaded() {\n return mAllAppsLoaded;\n }\n boolean isLoadingWorkspace() {\n synchronized (mLock) {\n if (mLoaderTask != null) {\n return mLoaderTask.isLoadingWorkspace();\n }\n }\n return false;\n }\n private class LoaderTask implements Runnable {\n private Context mContext;\n private boolean mIsLaunching;\n private boolean mIsLoadingAndBindingWorkspace;\n private boolean mStopped;\n private boolean mLoadAndBindStepFinished;\n private HashMap<Object, CharSequence> mLabelCache;\n LoaderTask(Context context, boolean isLaunching) {\n mContext = context;\n mIsLaunching = isLaunching;\n mLabelCache = new HashMap<Object, CharSequence>();\n }\n boolean isLaunching() {\n return mIsLaunching;\n }\n boolean isLoadingWorkspace() {\n return mIsLoadingAndBindingWorkspace;\n }\n private boolean loadAndBindWorkspace() {\n mIsLoadingAndBindingWorkspace = true;\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"loadAndBindWorkspace mWorkspaceLoaded=\" + mWorkspaceLoaded);\n }\n boolean isUpgradePath = false;\n if (!mWorkspaceLoaded) {\n isUpgradePath = loadWorkspace();\n synchronized (LoaderTask.this) {\n if (mStopped) {\n return isUpgradePath;\n }\n mWorkspaceLoaded = true;\n }\n }\n bindWorkspace(-1, isUpgradePath);\n return isUpgradePath;\n }\n private void waitForIdle() {\n synchronized (LoaderTask.this) {\n final long workspaceWaitTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n mHandler.postIdle(new Runnable() {\n public void run() {\n synchronized (LoaderTask.this) {\n mLoadAndBindStepFinished = true;\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"done with previous binding step\");\n }\n LoaderTask.this.notify();\n }\n }\n });\n while (!mStopped && !mLoadAndBindStepFinished && !mFlushingWorkerThread) {\n try {\n this.wait(1000);\n } catch (InterruptedException ex) {\n }\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"waited \"\n + (SystemClock.uptimeMillis()-workspaceWaitTime)\n + \"ms for previous step to finish binding\");\n }\n }\n }\n void runBindSynchronousPage(int synchronousBindPage) {\n if (synchronousBindPage < 0) {\n throw new RuntimeException(\"Should not call runBindSynchronousPage() without \" +\n \"valid page index\");\n }\n if (!mAllAppsLoaded || !mWorkspaceLoaded) {\n throw new RuntimeException(\"Expecting AllApps and Workspace to be loaded\");\n }\n synchronized (mLock) {\n if (mIsLoaderTaskRunning) {\n throw new RuntimeException(\"Error! Background loading is already running\");\n }\n }\n mHandler.flush();\n bindWorkspace(synchronousBindPage, false);\n onlyBindAllApps();\n }\n public void run() {\n boolean isUpgrade = false;\n synchronized (mLock) {\n mIsLoaderTaskRunning = true;\n }\n final Callbacks cbk = mCallbacks.get();\n keep_running: {\n synchronized (mLock) {\n if (DEBUG_LOADERS) Log.d(TAG, \"Setting thread priority to \" +\n (mIsLaunching ? \"DEFAULT\" : \"BACKGROUND\"));\n android.os.Process.setThreadPriority(mIsLaunching\n ? Process.THREAD_PRIORITY_DEFAULT : Process.THREAD_PRIORITY_BACKGROUND);\n }\n if (DEBUG_LOADERS) Log.d(TAG, \"step 1: loading workspace\");\n isUpgrade = loadAndBindWorkspace();\n if (mStopped) {\n break keep_running;\n }\n synchronized (mLock) {\n if (mIsLaunching) {\n if (DEBUG_LOADERS) Log.d(TAG, \"Setting thread priority to BACKGROUND\");\n android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);\n }\n }\n waitForIdle();\n if (DEBUG_LOADERS) Log.d(TAG, \"step 2: loading all apps\");\n loadAndBindAllApps();\n synchronized (mLock) {\n android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);\n }\n }\n if (DEBUG_LOADERS) Log.d(TAG, \"Comparing loaded icons to database icons\");\n synchronized (sBgLock) {\n for (Object key : sBgDbIconCache.keySet()) {\n updateSavedIcon(mContext, (ShortcutInfo) key, sBgDbIconCache.get(key));\n }\n sBgDbIconCache.clear();\n }\n Log.w(TAG, \"10249126 - verifyApplications - useMoreApps=\"\n + UPGRADE_USE_MORE_APPS_FOLDER + \" isUpgrade=\" + isUpgrade);\n if (!UPGRADE_USE_MORE_APPS_FOLDER || !isUpgrade) {\n verifyApplications();\n }\n mContext = null;\n synchronized (mLock) {\n if (mLoaderTask == this) {\n mLoaderTask = null;\n }\n mIsLoaderTaskRunning = false;\n }\n }\n public void stopLocked() {\n synchronized (LoaderTask.this) {\n mStopped = true;\n this.notify();\n }\n }\n Callbacks tryGetCallbacks(Callbacks oldCallbacks) {\n synchronized (mLock) {\n if (mStopped) {\n return null;\n }\n if (mCallbacks == null) {\n return null;\n }\n final Callbacks callbacks = mCallbacks.get();\n if (callbacks != oldCallbacks) {\n return null;\n }\n if (callbacks == null) {\n Log.w(TAG, \"no mCallbacks\");\n return null;\n }\n return callbacks;\n }\n }\n private void verifyApplications() {\n final Context context = mApp.getContext();\n ArrayList<ItemInfo> tmpInfos;\n ArrayList<ItemInfo> added = new ArrayList<ItemInfo>();\n synchronized (sBgLock) {\n for (ApplicationInfo app : mBgAllAppsList.data) {\n tmpInfos = getItemInfoForComponentName(app.componentName);\n Log.w(TAG, \"10249126 - \\t\" + app.componentName.getPackageName() + \", \" + tmpInfos.isEmpty());\n if (tmpInfos.isEmpty()) {\n added.add(app);\n Log.e(TAG, \"Missing Application on load: \" + app);\n }\n }\n }\n if (!added.isEmpty()) {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n addAndBindAddedApps(context, added, cb);\n }\n }\n private boolean checkItemDimensions(ItemInfo info) {\n return (info.cellX + info.spanX) > mCellCountX ||\n (info.cellY + info.spanY) > mCellCountY;\n }\n private boolean checkItemPlacement(HashMap<Long, ItemInfo[][]> occupied, ItemInfo item) {\n long containerIndex = item.screenId;\n if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n if (occupied.containsKey(LauncherSettings.Favorites.CONTAINER_HOTSEAT)) {\n if (occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT)\n [(int) item.screenId][0] != null) {\n Log.e(TAG, \"Error loading shortcut into hotseat \" + item\n + \" into position (\" + item.screenId + \":\" + item.cellX + \",\"\n + item.cellY + \") occupied by \"\n + occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT)\n [(int) item.screenId][0]);\n return false;\n }\n } else {\n ItemInfo[][] items = new ItemInfo[mCellCountX + 1][mCellCountY + 1];\n items[(int) item.screenId][0] = item;\n occupied.put((long) LauncherSettings.Favorites.CONTAINER_HOTSEAT, items);\n return true;\n }\n } else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n return true;\n }\n if (!occupied.containsKey(item.screenId)) {\n ItemInfo[][] items = new ItemInfo[mCellCountX + 1][mCellCountY + 1];\n occupied.put(item.screenId, items);\n }\n ItemInfo[][] screens = occupied.get(item.screenId);\n for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {\n for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {\n if (screens[x][y] != null) {\n Log.e(TAG, \"Error loading shortcut \" + item\n + \" into cell (\" + containerIndex + \"-\" + item.screenId + \":\"\n + x + \",\" + y\n + \") occupied by \"\n + screens[x][y]);\n return false;\n }\n }\n }\n for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {\n for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {\n screens[x][y] = item;\n }\n }\n return true;\n }\n private boolean loadWorkspace() {\n final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n final Context context = mContext;\n final ContentResolver contentResolver = context.getContentResolver();\n final PackageManager manager = context.getPackageManager();\n final AppWidgetManager widgets = AppWidgetManager.getInstance(context);\n final boolean isSafeMode = manager.isSafeMode();\n mApp.getLauncherProvider().loadDefaultFavoritesIfNecessary(0);\n boolean loadedOldDb = mApp.getLauncherProvider().justLoadedOldDb();\n synchronized (sBgLock) {\n sBgWorkspaceItems.clear();\n sBgAppWidgets.clear();\n sBgFolders.clear();\n sBgItemsIdMap.clear();\n sBgDbIconCache.clear();\n sBgWorkspaceScreens.clear();\n Log.w(TAG, \"10249126 - loadWorkspace()\");\n final ArrayList<Long> itemsToRemove = new ArrayList<Long>();\n final Uri contentUri = LauncherSettings.Favorites.CONTENT_URI;\n final Cursor c = contentResolver.query(contentUri, null, null, null, null);\n final HashMap<Long, ItemInfo[][]> occupied = new HashMap<Long, ItemInfo[][]>();\n try {\n final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);\n final int intentIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.INTENT);\n final int titleIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.TITLE);\n final int iconTypeIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ICON_TYPE);\n final int iconIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);\n final int iconPackageIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ICON_PACKAGE);\n final int iconResourceIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ICON_RESOURCE);\n final int containerIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.CONTAINER);\n final int itemTypeIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ITEM_TYPE);\n final int appWidgetIdIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.APPWIDGET_ID);\n final int screenIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.SCREEN);\n final int cellXIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.CELLX);\n final int cellYIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.CELLY);\n final int spanXIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.SPANX);\n final int spanYIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.SPANY);\n ShortcutInfo info;\n String intentDescription;\n LauncherAppWidgetInfo appWidgetInfo;\n int container;\n long id;\n Intent intent;\n while (!mStopped && c.moveToNext()) {\n try {\n int itemType = c.getInt(itemTypeIndex);\n switch (itemType) {\n case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:\n case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:\n id = c.getLong(idIndex);\n intentDescription = c.getString(intentIndex);\n try {\n intent = Intent.parseUri(intentDescription, 0);\n ComponentName cn = intent.getComponent();\n if (!isValidPackageComponent(manager, cn)) {\n if (!mAppsCanBeOnRemoveableStorage) {\n Uri uri = LauncherSettings.Favorites.getContentUri(id,\n false);\n contentResolver.delete(uri, null, null);\n Log.e(TAG, \"Invalid package removed: \" + cn);\n } else {\n Log.e(TAG, \"Invalid package found: \" + cn);\n }\n continue;\n }\n } catch (URISyntaxException e) {\n continue;\n }\n if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {\n info = getShortcutInfo(manager, intent, context, c, iconIndex,\n titleIndex, mLabelCache);\n } else {\n info = getShortcutInfo(c, context, iconTypeIndex,\n iconPackageIndex, iconResourceIndex, iconIndex,\n titleIndex);\n if (intent.getAction() != null &&\n intent.getCategories() != null &&\n intent.getAction().equals(Intent.ACTION_MAIN) &&\n intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {\n intent.addFlags(\n Intent.FLAG_ACTIVITY_NEW_TASK |\n Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);\n }\n }\n if (info != null) {\n info.id = id;\n info.intent = intent;\n container = c.getInt(containerIndex);\n info.container = container;\n info.screenId = c.getInt(screenIndex);\n info.cellX = c.getInt(cellXIndex);\n info.cellY = c.getInt(cellYIndex);\n info.spanX = 1;\n info.spanY = 1;\n if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n if (checkItemDimensions(info)) {\n Log.d(TAG, \"Skipped loading out of bounds shortcut: \"\n + info.intent);\n continue;\n }\n }\n if (!checkItemPlacement(occupied, info)) {\n break;\n }\n switch (container) {\n case LauncherSettings.Favorites.CONTAINER_DESKTOP:\n case LauncherSettings.Favorites.CONTAINER_HOTSEAT:\n sBgWorkspaceItems.add(info);\n break;\n default:\n FolderInfo folderInfo =\n findOrMakeFolder(sBgFolders, container);\n folderInfo.add(info);\n break;\n }\n sBgItemsIdMap.put(info.id, info);\n queueIconToBeChecked(sBgDbIconCache, info, c, iconIndex);\n } else {\n throw new RuntimeException(\"Unexpected null ShortcutInfo\");\n }\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n id = c.getLong(idIndex);\n FolderInfo folderInfo = findOrMakeFolder(sBgFolders, id);\n folderInfo.title = c.getString(titleIndex);\n folderInfo.id = id;\n container = c.getInt(containerIndex);\n folderInfo.container = container;\n folderInfo.screenId = c.getInt(screenIndex);\n folderInfo.cellX = c.getInt(cellXIndex);\n folderInfo.cellY = c.getInt(cellYIndex);\n folderInfo.spanX = 1;\n folderInfo.spanY = 1;\n if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n int iconSpan = 1;\n if (checkItemDimensions(folderInfo)) {\n Log.d(TAG, \"Skipped loading out of bounds folder\");\n continue;\n }\n }\n if (!checkItemPlacement(occupied, folderInfo)) {\n break;\n }\n switch (container) {\n case LauncherSettings.Favorites.CONTAINER_DESKTOP:\n case LauncherSettings.Favorites.CONTAINER_HOTSEAT:\n sBgWorkspaceItems.add(folderInfo);\n break;\n }\n sBgItemsIdMap.put(folderInfo.id, folderInfo);\n sBgFolders.put(folderInfo.id, folderInfo);\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:\n int appWidgetId = c.getInt(appWidgetIdIndex);\n id = c.getLong(idIndex);\n final AppWidgetProviderInfo provider =\n widgets.getAppWidgetInfo(appWidgetId);\n if (!isSafeMode && (provider == null || provider.provider == null ||\n provider.provider.getPackageName() == null)) {\n String log = \"Deleting widget that isn't installed anymore: id=\"\n + id + \" appWidgetId=\" + appWidgetId;\n Log.e(TAG, log);\n Launcher.sDumpLogs.add(log);\n itemsToRemove.add(id);\n } else {\n appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,\n provider.provider);\n appWidgetInfo.id = id;\n appWidgetInfo.screenId = c.getInt(screenIndex);\n appWidgetInfo.cellX = c.getInt(cellXIndex);\n appWidgetInfo.cellY = c.getInt(cellYIndex);\n appWidgetInfo.spanX = c.getInt(spanXIndex);\n appWidgetInfo.spanY = c.getInt(spanYIndex);\n int[] minSpan = Launcher.getMinSpanForWidget(context, provider);\n appWidgetInfo.minSpanX = minSpan[0];\n appWidgetInfo.minSpanY = minSpan[1];\n container = c.getInt(containerIndex);\n if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n container != LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n Log.e(TAG, \"Widget found where container != \" +\n \"CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!\");\n continue;\n }\n appWidgetInfo.container = c.getInt(containerIndex);\n if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n if (checkItemDimensions(appWidgetInfo)) {\n Log.d(TAG, \"Skipped loading out of bounds app widget\");\n continue;\n }\n }\n if (!checkItemPlacement(occupied, appWidgetInfo)) {\n break;\n }\n sBgItemsIdMap.put(appWidgetInfo.id, appWidgetInfo);\n sBgAppWidgets.add(appWidgetInfo);\n }\n break;\n }\n } catch (Exception e) {\n Log.w(TAG, \"Desktop items loading interrupted:\", e);\n }\n }\n } finally {\n if (c != null) {\n c.close();\n }\n }\n if (itemsToRemove.size() > 0) {\n ContentProviderClient client = contentResolver.acquireContentProviderClient(\n LauncherSettings.Favorites.CONTENT_URI);\n for (long id : itemsToRemove) {\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"Removed id = \" + id);\n }\n try {\n client.delete(LauncherSettings.Favorites.getContentUri(id, false),\n null, null);\n } catch (RemoteException e) {\n Log.w(TAG, \"Could not remove id = \" + id);\n }\n }\n }\n if (loadedOldDb) {\n Log.w(TAG, \"10249126 - loadWorkspace - loadedOldDb\");\n long maxScreenId = 0;\n for (ItemInfo item: sBgItemsIdMap.values()) {\n long screenId = item.screenId;\n if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n !sBgWorkspaceScreens.contains(screenId)) {\n Log.w(TAG, \"10249126 - loadWorkspace-loadedOldDb(\" + screenId + \")\");\n sBgWorkspaceScreens.add(screenId);\n if (screenId > maxScreenId) {\n maxScreenId = screenId;\n }\n }\n }\n Collections.sort(sBgWorkspaceScreens);\n mApp.getLauncherProvider().updateMaxScreenId(maxScreenId);\n updateWorkspaceScreenOrder(context, sBgWorkspaceScreens);\n long maxItemId = 0;\n for (ItemInfo item: sBgItemsIdMap.values()) {\n maxItemId = Math.max(maxItemId, item.id);\n }\n LauncherAppState app = LauncherAppState.getInstance();\n app.getLauncherProvider().updateMaxItemId(maxItemId);\n } else {\n Log.w(TAG, \"10249126 - loadWorkspace - !loadedOldDb\");\n TreeMap<Integer, Long> orderedScreens = loadWorkspaceScreensDb(mContext);\n for (Integer i : orderedScreens.keySet()) {\n sBgWorkspaceScreens.add(orderedScreens.get(i));\n }\n ArrayList<Long> unusedScreens = new ArrayList<Long>();\n unusedScreens.addAll(sBgWorkspaceScreens);\n for (ItemInfo item: sBgItemsIdMap.values()) {\n long screenId = item.screenId;\n if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n unusedScreens.contains(screenId)) {\n unusedScreens.remove(screenId);\n }\n }\n if (unusedScreens.size() != 0) {\n sBgWorkspaceScreens.removeAll(unusedScreens);\n updateWorkspaceScreenOrder(context, sBgWorkspaceScreens);\n }\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"loaded workspace in \" + (SystemClock.uptimeMillis()-t) + \"ms\");\n Log.d(TAG, \"workspace layout: \");\n int nScreens = occupied.size();\n for (int y = 0; y < mCellCountY; y++) {\n String line = \"\";\n Iterator<Long> iter = occupied.keySet().iterator();\n while (iter.hasNext()) {\n long screenId = iter.next();\n if (screenId > 0) {\n line += \" | \";\n }\n for (int x = 0; x < mCellCountX; x++) {\n line += ((occupied.get(screenId)[x][y] != null) ? \"#\" : \".\");\n }\n }\n Log.d(TAG, \"[ \" + line + \" ]\");\n }\n }\n }\n return loadedOldDb;\n }\n private void filterCurrentWorkspaceItems(int currentScreen,\n ArrayList<ItemInfo> allWorkspaceItems,\n ArrayList<ItemInfo> currentScreenItems,\n ArrayList<ItemInfo> otherScreenItems) {\n Iterator<ItemInfo> iter = allWorkspaceItems.iterator();\n while (iter.hasNext()) {\n ItemInfo i = iter.next();\n if (i == null) {\n iter.remove();\n }\n }\n if (currentScreen < 0) {\n currentScreenItems.addAll(allWorkspaceItems);\n }\n Set<Long> itemsOnScreen = new HashSet<Long>();\n Collections.sort(allWorkspaceItems, new Comparator<ItemInfo>() {\n @Override\n public int compare(ItemInfo lhs, ItemInfo rhs) {\n return (int) (lhs.container - rhs.container);\n }\n });\n for (ItemInfo info : allWorkspaceItems) {\n if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n if (info.screenId == currentScreen) {\n currentScreenItems.add(info);\n itemsOnScreen.add(info.id);\n } else {\n otherScreenItems.add(info);\n }\n } else if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n currentScreenItems.add(info);\n itemsOnScreen.add(info.id);\n } else {\n if (itemsOnScreen.contains(info.container)) {\n currentScreenItems.add(info);\n itemsOnScreen.add(info.id);\n } else {\n otherScreenItems.add(info);\n }\n }\n }\n }\n private void filterCurrentAppWidgets(int currentScreen,\n ArrayList<LauncherAppWidgetInfo> appWidgets,\n ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,\n ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {\n if (currentScreen < 0) {\n currentScreenWidgets.addAll(appWidgets);\n }\n for (LauncherAppWidgetInfo widget : appWidgets) {\n if (widget == null) continue;\n if (widget.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n widget.screenId == currentScreen) {\n currentScreenWidgets.add(widget);\n } else {\n otherScreenWidgets.add(widget);\n }\n }\n }\n private void filterCurrentFolders(int currentScreen,\n HashMap<Long, ItemInfo> itemsIdMap,\n HashMap<Long, FolderInfo> folders,\n HashMap<Long, FolderInfo> currentScreenFolders,\n HashMap<Long, FolderInfo> otherScreenFolders) {\n if (currentScreen < 0) {\n currentScreenFolders.putAll(folders);\n }\n for (long id : folders.keySet()) {\n ItemInfo info = itemsIdMap.get(id);\n FolderInfo folder = folders.get(id);\n if (info == null || folder == null) continue;\n if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n info.screenId == currentScreen) {\n currentScreenFolders.put(id, folder);\n } else {\n otherScreenFolders.put(id, folder);\n }\n }\n }\n private void sortWorkspaceItemsSpatially(ArrayList<ItemInfo> workspaceItems) {\n Collections.sort(workspaceItems, new Comparator<ItemInfo>() {\n @Override\n public int compare(ItemInfo lhs, ItemInfo rhs) {\n int cellCountX = LauncherModel.getCellCountX();\n int cellCountY = LauncherModel.getCellCountY();\n int screenOffset = cellCountX * cellCountY;\n int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); \n long lr = (lhs.container * containerOffset + lhs.screenId * screenOffset +\n lhs.cellY * cellCountX + lhs.cellX);\n long rr = (rhs.container * containerOffset + rhs.screenId * screenOffset +\n rhs.cellY * cellCountX + rhs.cellX);\n return (int) (lr - rr);\n }\n });\n }\n private void bindWorkspaceScreens(final Callbacks oldCallbacks,\n final ArrayList<Long> orderedScreens) {\n Log.w(TAG, \"10249126 - bindWorkspaceScreens()\");\n final Runnable r = new Runnable() {\n @Override\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindScreens(orderedScreens);\n }\n }\n };\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n private void bindWorkspaceItems(final Callbacks oldCallbacks,\n final ArrayList<ItemInfo> workspaceItems,\n final ArrayList<LauncherAppWidgetInfo> appWidgets,\n final HashMap<Long, FolderInfo> folders,\n ArrayList<Runnable> deferredBindRunnables) {\n final boolean postOnMainThread = (deferredBindRunnables != null);\n int N = workspaceItems.size();\n for (int i = 0; i < N; i += ITEMS_CHUNK) {\n final int start = i;\n final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);\n final Runnable r = new Runnable() {\n @Override\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindItems(workspaceItems, start, start+chunkSize,\n false);\n }\n }\n };\n if (postOnMainThread) {\n deferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n if (!folders.isEmpty()) {\n final Runnable r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindFolders(folders);\n }\n }\n };\n if (postOnMainThread) {\n deferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n N = appWidgets.size();\n for (int i = 0; i < N; i++) {\n final LauncherAppWidgetInfo widget = appWidgets.get(i);\n final Runnable r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindAppWidget(widget);\n }\n }\n };\n if (postOnMainThread) {\n deferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n }\n private void bindWorkspace(int synchronizeBindPage, final boolean isUpgradePath) {\n final long t = SystemClock.uptimeMillis();\n Runnable r;\n final Callbacks oldCallbacks = mCallbacks.get();\n if (oldCallbacks == null) {\n Log.w(TAG, \"LoaderTask running with no launcher\");\n return;\n }\n final boolean isLoadingSynchronously = (synchronizeBindPage > -1);\n final int currentScreen = isLoadingSynchronously ? synchronizeBindPage :\n oldCallbacks.getCurrentWorkspaceScreen();\n unbindWorkspaceItemsOnMainThread();\n ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();\n ArrayList<LauncherAppWidgetInfo> appWidgets =\n new ArrayList<LauncherAppWidgetInfo>();\n HashMap<Long, FolderInfo> folders = new HashMap<Long, FolderInfo>();\n HashMap<Long, ItemInfo> itemsIdMap = new HashMap<Long, ItemInfo>();\n ArrayList<Long> orderedScreenIds = new ArrayList<Long>();\n synchronized (sBgLock) {\n workspaceItems.addAll(sBgWorkspaceItems);\n appWidgets.addAll(sBgAppWidgets);\n folders.putAll(sBgFolders);\n itemsIdMap.putAll(sBgItemsIdMap);\n orderedScreenIds.addAll(sBgWorkspaceScreens);\n }\n ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<ItemInfo>();\n ArrayList<ItemInfo> otherWorkspaceItems = new ArrayList<ItemInfo>();\n ArrayList<LauncherAppWidgetInfo> currentAppWidgets =\n new ArrayList<LauncherAppWidgetInfo>();\n ArrayList<LauncherAppWidgetInfo> otherAppWidgets =\n new ArrayList<LauncherAppWidgetInfo>();\n HashMap<Long, FolderInfo> currentFolders = new HashMap<Long, FolderInfo>();\n HashMap<Long, FolderInfo> otherFolders = new HashMap<Long, FolderInfo>();\n filterCurrentWorkspaceItems(currentScreen, workspaceItems, currentWorkspaceItems,\n otherWorkspaceItems);\n filterCurrentAppWidgets(currentScreen, appWidgets, currentAppWidgets,\n otherAppWidgets);\n filterCurrentFolders(currentScreen, itemsIdMap, folders, currentFolders,\n otherFolders);\n sortWorkspaceItemsSpatially(currentWorkspaceItems);\n sortWorkspaceItemsSpatially(otherWorkspaceItems);\n r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.startBinding();\n }\n }\n };\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n bindWorkspaceScreens(oldCallbacks, orderedScreenIds);\n bindWorkspaceItems(oldCallbacks, currentWorkspaceItems, currentAppWidgets,\n currentFolders, null);\n if (isLoadingSynchronously) {\n r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.onPageBoundSynchronously(currentScreen);\n }\n }\n };\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n mDeferredBindRunnables.clear();\n bindWorkspaceItems(oldCallbacks, otherWorkspaceItems, otherAppWidgets, otherFolders,\n (isLoadingSynchronously ? mDeferredBindRunnables : null));\n r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.finishBindingItems(isUpgradePath);\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"bound workspace in \"\n + (SystemClock.uptimeMillis()-t) + \"ms\");\n }\n mIsLoadingAndBindingWorkspace = false;\n }\n };\n if (isLoadingSynchronously) {\n mDeferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n private void loadAndBindAllApps() {\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"loadAndBindAllApps mAllAppsLoaded=\" + mAllAppsLoaded);\n }\n if (!mAllAppsLoaded) {\n loadAllApps();\n synchronized (LoaderTask.this) {\n if (mStopped) {\n return;\n }\n mAllAppsLoaded = true;\n }\n } else {\n onlyBindAllApps();\n }\n }\n private void onlyBindAllApps() {\n final Callbacks oldCallbacks = mCallbacks.get();\n if (oldCallbacks == null) {\n Log.w(TAG, \"LoaderTask running with no launcher (onlyBindAllApps)\");\n return;\n }\n @SuppressWarnings(\"unchecked\")\n final ArrayList<ApplicationInfo> list\n = (ArrayList<ApplicationInfo>) mBgAllAppsList.data.clone();\n Runnable r = new Runnable() {\n public void run() {\n final long t = SystemClock.uptimeMillis();\n final Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindAllApplications(list);\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"bound all \" + list.size() + \" apps from cache in \"\n + (SystemClock.uptimeMillis()-t) + \"ms\");\n }\n }\n };\n boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid());\n if (isRunningOnMainThread) {\n r.run();\n } else {\n mHandler.post(r);\n }\n }\n private void loadAllApps() {\n final long loadTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n final Callbacks oldCallbacks = mCallbacks.get();\n if (oldCallbacks == null) {\n Log.w(TAG, \"LoaderTask running with no launcher (loadAllApps)\");\n return;\n }\n final PackageManager packageManager = mContext.getPackageManager();\n final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);\n mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);\n mBgAllAppsList.clear();\n final long qiaTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0);\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"queryIntentActivities took \"\n + (SystemClock.uptimeMillis()-qiaTime) + \"ms\");\n Log.d(TAG, \"queryIntentActivities got \" + apps.size() + \" apps\");\n }\n if (apps == null || apps.isEmpty()) {\n return;\n }\n final long sortTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n Collections.sort(apps,\n new LauncherModel.ShortcutNameComparator(packageManager, mLabelCache));\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"sort took \"\n + (SystemClock.uptimeMillis()-sortTime) + \"ms\");\n }\n final long addTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n for (int i = 0; i < apps.size(); i++) {\n mBgAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i),\n mIconCache, mLabelCache));\n }\n final Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n final ArrayList<ApplicationInfo> added = mBgAllAppsList.added;\n mBgAllAppsList.added = new ArrayList<ApplicationInfo>();\n mHandler.post(new Runnable() {\n public void run() {\n final long bindTime = SystemClock.uptimeMillis();\n if (callbacks != null) {\n callbacks.bindAllApplications(added);\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"bound \" + added.size() + \" apps in \"\n + (SystemClock.uptimeMillis() - bindTime) + \"ms\");\n }\n } else {\n Log.i(TAG, \"not binding apps: no Launcher activity\");\n }\n }\n });\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"Icons processed in \"\n + (SystemClock.uptimeMillis() - loadTime) + \"ms\");\n }\n }\n public void dumpState() {\n synchronized (sBgLock) {\n Log.d(TAG, \"mLoaderTask.mContext=\" + mContext);\n Log.d(TAG, \"mLoaderTask.mIsLaunching=\" + mIsLaunching);\n Log.d(TAG, \"mLoaderTask.mStopped=\" + mStopped);\n Log.d(TAG, \"mLoaderTask.mLoadAndBindStepFinished=\" + mLoadAndBindStepFinished);\n Log.d(TAG, \"mItems size=\" + sBgWorkspaceItems.size());\n }\n }\n }\n void enqueuePackageUpdated(PackageUpdatedTask task) {\n sWorker.post(task);\n }\n private class PackageUpdatedTask implements Runnable {\n int mOp;\n String[] mPackages;\n public static final int OP_NONE = 0;\n public static final int OP_ADD = 1;\n public static final int OP_UPDATE = 2;\n public static final int OP_REMOVE = 3; \n public static final int OP_UNAVAILABLE = 4; \n public PackageUpdatedTask(int op, String[] packages) {\n mOp = op;\n mPackages = packages;\n }\n public void run() {\n final Context context = mApp.getContext();\n final String[] packages = mPackages;\n final int N = packages.length;\n switch (mOp) {\n case OP_ADD:\n for (int i=0; i<N; i++) {\n if (DEBUG_LOADERS) Log.d(TAG, \"mAllAppsList.addPackage \" + packages[i]);\n mBgAllAppsList.addPackage(context, packages[i]);\n }\n break;\n case OP_UPDATE:\n for (int i=0; i<N; i++) {\n if (DEBUG_LOADERS) Log.d(TAG, \"mAllAppsList.updatePackage \" + packages[i]);\n mBgAllAppsList.updatePackage(context, packages[i]);\n WidgetPreviewLoader.removeFromDb(\n mApp.getWidgetPreviewCacheDb(), packages[i]);\n }\n break;\n case OP_REMOVE:\n case OP_UNAVAILABLE:\n for (int i=0; i<N; i++) {\n if (DEBUG_LOADERS) Log.d(TAG, \"mAllAppsList.removePackage \" + packages[i]);\n mBgAllAppsList.removePackage(packages[i]);\n WidgetPreviewLoader.removeFromDb(\n mApp.getWidgetPreviewCacheDb(), packages[i]);\n }\n break;\n }\n ArrayList<ApplicationInfo> added = null;\n ArrayList<ApplicationInfo> modified = null;\n final ArrayList<ApplicationInfo> removedApps = new ArrayList<ApplicationInfo>();\n if (mBgAllAppsList.added.size() > 0) {\n added = new ArrayList<ApplicationInfo>(mBgAllAppsList.added);\n mBgAllAppsList.added.clear();\n }\n if (mBgAllAppsList.modified.size() > 0) {\n modified = new ArrayList<ApplicationInfo>(mBgAllAppsList.modified);\n mBgAllAppsList.modified.clear();\n }\n if (mBgAllAppsList.removed.size() > 0) {\n removedApps.addAll(mBgAllAppsList.removed);\n mBgAllAppsList.removed.clear();\n }\n final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == null) {\n Log.w(TAG, \"Nobody to tell about the new app. Launcher is probably loading.\");\n return;\n }\n if (added != null) {\n final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n addAndBindAddedApps(context, addedInfos, cb);\n }\n if (modified != null) {\n final ArrayList<ApplicationInfo> modifiedFinal = modified;\n for (ApplicationInfo a : modifiedFinal) {\n ArrayList<ItemInfo> infos =\n getItemInfoForComponentName(a.componentName);\n for (ItemInfo i : infos) {\n if (isShortcutInfoUpdateable(i)) {\n ShortcutInfo info = (ShortcutInfo) i;\n info.title = a.title.toString();\n updateItemInDatabase(context, info);\n }\n }\n }\n mHandler.post(new Runnable() {\n public void run() {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == cb && cb != null) {\n callbacks.bindAppsUpdated(modifiedFinal);\n }\n }\n });\n }\n if (mOp == OP_REMOVE || !removedApps.isEmpty()) {\n final boolean packageRemoved = (mOp == OP_REMOVE);\n final ArrayList<String> removedPackageNames =\n new ArrayList<String>(Arrays.asList(packages));\n if (packageRemoved) {\n for (String pn : removedPackageNames) {\n ArrayList<ItemInfo> infos = getItemInfoForPackageName(pn);\n for (ItemInfo i : infos) {\n deleteItemFromDatabase(context, i);\n }\n }\n } else {\n for (ApplicationInfo a : removedApps) {\n ArrayList<ItemInfo> infos =\n getItemInfoForComponentName(a.componentName);\n for (ItemInfo i : infos) {\n deleteItemFromDatabase(context, i);\n }\n }\n }\n mHandler.post(new Runnable() {\n public void run() {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == cb && cb != null) {\n callbacks.bindComponentsRemoved(removedPackageNames,\n removedApps, packageRemoved);\n }\n }\n });\n }\n final ArrayList<Object> widgetsAndShortcuts =\n getSortedWidgetsAndShortcuts(context);\n mHandler.post(new Runnable() {\n @Override\n public void run() {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == cb && cb != null) {\n callbacks.bindPackagesUpdated(widgetsAndShortcuts);\n }\n }\n });\n }\n }\n public static ArrayList<Object> getSortedWidgetsAndShortcuts(Context context) {\n PackageManager packageManager = context.getPackageManager();\n final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();\n widgetsAndShortcuts.addAll(AppWidgetManager.getInstance(context).getInstalledProviders());\n Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);\n widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(shortcutsIntent, 0));\n Collections.sort(widgetsAndShortcuts,\n new LauncherModel.WidgetAndShortcutNameComparator(packageManager));\n return widgetsAndShortcuts;\n }\n private boolean isValidPackageComponent(PackageManager pm, ComponentName cn) {\n if (cn == null) {\n return false;\n }\n try {\n return (pm.getActivityInfo(cn, 0) != null);\n } catch (NameNotFoundException e) {\n return false;\n }\n }\n public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context) {\n return getShortcutInfo(manager, intent, context, null, -1, -1, null);\n }\n public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context,\n Cursor c, int iconIndex, int titleIndex, HashMap<Object, CharSequence> labelCache) {\n ComponentName componentName = intent.getComponent();\n final ShortcutInfo info = new ShortcutInfo();\n if (!isValidPackageComponent(manager, componentName)) {\n Log.d(TAG, \"Invalid package found in getShortcutInfo: \" + componentName);\n return null;\n } else {\n try {\n PackageInfo pi = manager.getPackageInfo(componentName.getPackageName(), 0);\n info.initFlagsAndFirstInstallTime(pi);\n } catch (NameNotFoundException e) {\n Log.d(TAG, \"getPackInfo failed for package \" +\n componentName.getPackageName());\n }\n }\n Bitmap icon = null;\n ResolveInfo resolveInfo = null;\n ComponentName oldComponent = intent.getComponent();\n Intent newIntent = new Intent(intent.getAction(), null);\n newIntent.addCategory(Intent.CATEGORY_LAUNCHER);\n newIntent.setPackage(oldComponent.getPackageName());\n List<ResolveInfo> infos = manager.queryIntentActivities(newIntent, 0);\n for (ResolveInfo i : infos) {\n ComponentName cn = new ComponentName(i.activityInfo.packageName,\n i.activityInfo.name);\n if (cn.equals(oldComponent)) {\n resolveInfo = i;\n }\n }\n if (resolveInfo == null) {\n resolveInfo = manager.resolveActivity(intent, 0);\n }\n if (resolveInfo != null) {\n icon = mIconCache.getIcon(componentName, resolveInfo, labelCache);\n }\n if (icon == null) {\n if (c != null) {\n icon = getIconFromCursor(c, iconIndex, context);\n }\n }\n if (icon == null) {\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n }\n info.setIcon(icon);\n if (resolveInfo != null) {\n ComponentName key = LauncherModel.getComponentNameFromResolveInfo(resolveInfo);\n if (labelCache != null && labelCache.containsKey(key)) {\n info.title = labelCache.get(key);\n } else {\n info.title = resolveInfo.activityInfo.loadLabel(manager);\n if (labelCache != null) {\n labelCache.put(key, info.title);\n }\n }\n }\n if (info.title == null) {\n if (c != null) {\n info.title = c.getString(titleIndex);\n }\n }\n if (info.title == null) {\n info.title = componentName.getClassName();\n }\n info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;\n return info;\n }\n static ArrayList<ItemInfo> filterItemInfos(Collection<ItemInfo> infos,\n ItemInfoFilter f) {\n HashSet<ItemInfo> filtered = new HashSet<ItemInfo>();\n for (ItemInfo i : infos) {\n if (i instanceof ShortcutInfo) {\n ShortcutInfo info = (ShortcutInfo) i;\n ComponentName cn = info.intent.getComponent();\n if (cn != null && f.filterItem(null, info, cn)) {\n filtered.add(info);\n }\n } else if (i instanceof FolderInfo) {\n FolderInfo info = (FolderInfo) i;\n for (ShortcutInfo s : info.contents) {\n ComponentName cn = s.intent.getComponent();\n if (cn != null && f.filterItem(info, s, cn)) {\n filtered.add(s);\n }\n }\n } else if (i instanceof LauncherAppWidgetInfo) {\n LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) i;\n ComponentName cn = info.providerName;\n if (cn != null && f.filterItem(null, info, cn)) {\n filtered.add(info);\n }\n }\n }\n return new ArrayList<ItemInfo>(filtered);\n }\n private ArrayList<ItemInfo> getItemInfoForPackageName(final String pn) {\n HashSet<ItemInfo> infos = new HashSet<ItemInfo>();\n ItemInfoFilter filter = new ItemInfoFilter() {\n @Override\n public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {\n return cn.getPackageName().equals(pn);\n }\n };\n return filterItemInfos(sBgItemsIdMap.values(), filter);\n }\n private ArrayList<ItemInfo> getItemInfoForComponentName(final ComponentName cname) {\n HashSet<ItemInfo> infos = new HashSet<ItemInfo>();\n ItemInfoFilter filter = new ItemInfoFilter() {\n @Override\n public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {\n return cn.equals(cname);\n }\n };\n return filterItemInfos(sBgItemsIdMap.values(), filter);\n }\n public static boolean isShortcutInfoUpdateable(ItemInfo i) {\n if (i instanceof ShortcutInfo) {\n ShortcutInfo info = (ShortcutInfo) i;\n Intent intent = info.intent;\n ComponentName name = intent.getComponent();\n if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&\n Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {\n return true;\n }\n }\n return false;\n }\n private ShortcutInfo getShortcutInfo(Cursor c, Context context,\n int iconTypeIndex, int iconPackageIndex, int iconResourceIndex, int iconIndex,\n int titleIndex) {\n Bitmap icon = null;\n final ShortcutInfo info = new ShortcutInfo();\n info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;\n info.title = c.getString(titleIndex);\n int iconType = c.getInt(iconTypeIndex);\n switch (iconType) {\n case LauncherSettings.Favorites.ICON_TYPE_RESOURCE:\n String packageName = c.getString(iconPackageIndex);\n String resourceName = c.getString(iconResourceIndex);\n PackageManager packageManager = context.getPackageManager();\n info.customIcon = false;\n try {\n Resources resources = packageManager.getResourcesForApplication(packageName);\n if (resources != null) {\n final int id = resources.getIdentifier(resourceName, null, null);\n icon = Utilities.createIconBitmap(\n mIconCache.getFullResIcon(resources, id), context);\n }\n } catch (Exception e) {\n }\n if (icon == null) {\n icon = getIconFromCursor(c, iconIndex, context);\n }\n if (icon == null) {\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n }\n break;\n case LauncherSettings.Favorites.ICON_TYPE_BITMAP:\n icon = getIconFromCursor(c, iconIndex, context);\n if (icon == null) {\n icon = getFallbackIcon();\n info.customIcon = false;\n info.usingFallbackIcon = true;\n } else {\n info.customIcon = true;\n }\n break;\n default:\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n info.customIcon = false;\n break;\n }\n info.setIcon(icon);\n return info;\n }\n Bitmap getIconFromCursor(Cursor c, int iconIndex, Context context) {\n @SuppressWarnings(\"all\") \n final boolean debug = false;\n if (debug) {\n Log.d(TAG, \"getIconFromCursor app=\"\n + c.getString(c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE)));\n }\n byte[] data = c.getBlob(iconIndex);\n try {\n return Utilities.createIconBitmap(\n BitmapFactory.decodeByteArray(data, 0, data.length), context);\n } catch (Exception e) {\n return null;\n }\n }\n ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,\n int cellX, int cellY, boolean notify) {\n final ShortcutInfo info = infoFromShortcutIntent(context, data, null);\n if (info == null) {\n return null;\n }\n addItemToDatabase(context, info, container, screen, cellX, cellY, notify);\n return info;\n }\n AppWidgetProviderInfo findAppWidgetProviderInfoWithComponent(Context context,\n ComponentName component) {\n List<AppWidgetProviderInfo> widgets =\n AppWidgetManager.getInstance(context).getInstalledProviders();\n for (AppWidgetProviderInfo info : widgets) {\n if (info.provider.equals(component)) {\n return info;\n }\n }\n return null;\n }\n List<WidgetMimeTypeHandlerData> resolveWidgetsForMimeType(Context context, String mimeType) {\n final PackageManager packageManager = context.getPackageManager();\n final List<WidgetMimeTypeHandlerData> supportedConfigurationActivities =\n new ArrayList<WidgetMimeTypeHandlerData>();\n final Intent supportsIntent =\n new Intent(InstallWidgetReceiver.ACTION_SUPPORTS_CLIPDATA_MIMETYPE);\n supportsIntent.setType(mimeType);\n final List<AppWidgetProviderInfo> widgets =\n AppWidgetManager.getInstance(context).getInstalledProviders();\n final HashMap<ComponentName, AppWidgetProviderInfo> configurationComponentToWidget =\n new HashMap<ComponentName, AppWidgetProviderInfo>();\n for (AppWidgetProviderInfo info : widgets) {\n configurationComponentToWidget.put(info.configure, info);\n }\n final List<ResolveInfo> activities = packageManager.queryIntentActivities(supportsIntent,\n PackageManager.MATCH_DEFAULT_ONLY);\n for (ResolveInfo info : activities) {\n final ActivityInfo activityInfo = info.activityInfo;\n final ComponentName infoComponent = new ComponentName(activityInfo.packageName,\n activityInfo.name);\n if (configurationComponentToWidget.containsKey(infoComponent)) {\n supportedConfigurationActivities.add(\n new InstallWidgetReceiver.WidgetMimeTypeHandlerData(info,\n configurationComponentToWidget.get(infoComponent)));\n }\n }\n return supportedConfigurationActivities;\n }\n ShortcutInfo infoFromShortcutIntent(Context context, Intent data, Bitmap fallbackIcon) {\n Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);\n String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);\n Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);\n if (intent == null) {\n Log.e(TAG, \"Can't construct ShorcutInfo with null intent\");\n return null;\n }\n Bitmap icon = null;\n boolean customIcon = false;\n ShortcutIconResource iconResource = null;\n if (bitmap != null && bitmap instanceof Bitmap) {\n icon = Utilities.createIconBitmap(new FastBitmapDrawable((Bitmap)bitmap), context);\n customIcon = true;\n } else {\n Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);\n if (extra != null && extra instanceof ShortcutIconResource) {\n try {\n iconResource = (ShortcutIconResource) extra;\n final PackageManager packageManager = context.getPackageManager();\n Resources resources = packageManager.getResourcesForApplication(\n iconResource.packageName);\n final int id = resources.getIdentifier(iconResource.resourceName, null, null);\n icon = Utilities.createIconBitmap(\n mIconCache.getFullResIcon(resources, id), context);\n } catch (Exception e) {\n Log.w(TAG, \"Could not load shortcut icon: \" + extra);\n }\n }\n }\n final ShortcutInfo info = new ShortcutInfo();\n if (icon == null) {\n if (fallbackIcon != null) {\n icon = fallbackIcon;\n } else {\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n }\n }\n info.setIcon(icon);\n info.title = name;\n info.intent = intent;\n info.customIcon = customIcon;\n info.iconResource = iconResource;\n return info;\n }\n boolean queueIconToBeChecked(HashMap<Object, byte[]> cache, ShortcutInfo info, Cursor c,\n int iconIndex) {\n if (!mAppsCanBeOnRemoveableStorage) {\n return false;\n }\n if (!info.customIcon && !info.usingFallbackIcon) {\n cache.put(info, c.getBlob(iconIndex));\n return true;\n }\n return false;\n }\n void updateSavedIcon(Context context, ShortcutInfo info, byte[] data) {\n boolean needSave = false;\n try {\n if (data != null) {\n Bitmap saved = BitmapFactory.decodeByteArray(data, 0, data.length);\n Bitmap loaded = info.getIcon(mIconCache);\n needSave = !saved.sameAs(loaded);\n } else {\n needSave = true;\n }\n } catch (Exception e) {\n needSave = true;\n }\n if (needSave) {\n Log.d(TAG, \"going to save icon bitmap for info=\" + info);\n updateItemInDatabase(context, info);\n }\n }\n private static FolderInfo findOrMakeFolder(HashMap<Long, FolderInfo> folders, long id) {\n FolderInfo folderInfo = folders.get(id);\n if (folderInfo == null) {\n folderInfo = new FolderInfo();\n folders.put(id, folderInfo);\n }\n return folderInfo;\n }\n public static final Comparator<ApplicationInfo> getAppNameComparator() {\n final Collator collator = Collator.getInstance();\n return new Comparator<ApplicationInfo>() {\n public final int compare(ApplicationInfo a, ApplicationInfo b) {\n int result = collator.compare(a.title.toString(), b.title.toString());\n if (result == 0) {\n result = a.componentName.compareTo(b.componentName);\n }\n return result;\n }\n };\n }\n public static final Comparator<ApplicationInfo> APP_INSTALL_TIME_COMPARATOR\n = new Comparator<ApplicationInfo>() {\n public final int compare(ApplicationInfo a, ApplicationInfo b) {\n if (a.firstInstallTime < b.firstInstallTime) return 1;\n if (a.firstInstallTime > b.firstInstallTime) return -1;\n return 0;\n }\n };\n public static final Comparator<AppWidgetProviderInfo> getWidgetNameComparator() {\n final Collator collator = Collator.getInstance();\n return new Comparator<AppWidgetProviderInfo>() {\n public final int compare(AppWidgetProviderInfo a, AppWidgetProviderInfo b) {\n return collator.compare(a.label.toString(), b.label.toString());\n }\n };\n }\n static ComponentName getComponentNameFromResolveInfo(ResolveInfo info) {\n if (info.activityInfo != null) {\n return new ComponentName(info.activityInfo.packageName, info.activityInfo.name);\n } else {\n return new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name);\n }\n }\n public static class ShortcutNameComparator implements Comparator<ResolveInfo> {\n private Collator mCollator;\n private PackageManager mPackageManager;\n private HashMap<Object, CharSequence> mLabelCache;\n ShortcutNameComparator(PackageManager pm) {\n mPackageManager = pm;\n mLabelCache = new HashMap<Object, CharSequence>();\n mCollator = Collator.getInstance();\n }\n ShortcutNameComparator(PackageManager pm, HashMap<Object, CharSequence> labelCache) {\n mPackageManager = pm;\n mLabelCache = labelCache;\n mCollator = Collator.getInstance();\n }\n public final int compare(ResolveInfo a, ResolveInfo b) {\n CharSequence labelA, labelB;\n ComponentName keyA = LauncherModel.getComponentNameFromResolveInfo(a);\n ComponentName keyB = LauncherModel.getComponentNameFromResolveInfo(b);\n if (mLabelCache.containsKey(keyA)) {\n labelA = mLabelCache.get(keyA);\n } else {\n labelA = a.loadLabel(mPackageManager).toString();\n mLabelCache.put(keyA, labelA);\n }\n if (mLabelCache.containsKey(keyB)) {\n labelB = mLabelCache.get(keyB);\n } else {\n labelB = b.loadLabel(mPackageManager).toString();\n mLabelCache.put(keyB, labelB);\n }\n return mCollator.compare(labelA, labelB);\n }\n };\n public static class WidgetAndShortcutNameComparator implements Comparator<Object> {\n private Collator mCollator;\n private PackageManager mPackageManager;\n private HashMap<Object, String> mLabelCache;\n WidgetAndShortcutNameComparator(PackageManager pm) {\n mPackageManager = pm;\n mLabelCache = new HashMap<Object, String>();\n mCollator = Collator.getInstance();\n }\n public final int compare(Object a, Object b) {\n String labelA, labelB;\n if (mLabelCache.containsKey(a)) {\n labelA = mLabelCache.get(a);\n } else {\n labelA = (a instanceof AppWidgetProviderInfo) ?\n ((AppWidgetProviderInfo) a).label :\n ((ResolveInfo) a).loadLabel(mPackageManager).toString();\n mLabelCache.put(a, labelA);\n }\n if (mLabelCache.containsKey(b)) {\n labelB = mLabelCache.get(b);\n } else {\n labelB = (b instanceof AppWidgetProviderInfo) ?\n ((AppWidgetProviderInfo) b).label :\n ((ResolveInfo) b).loadLabel(mPackageManager).toString();\n mLabelCache.put(b, labelB);\n }\n return mCollator.compare(labelA, labelB);\n }\n };\n public void dumpState() {\n Log.d(TAG, \"mCallbacks=\" + mCallbacks);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.data\", mBgAllAppsList.data);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.added\", mBgAllAppsList.added);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.removed\", mBgAllAppsList.removed);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.modified\", mBgAllAppsList.modified);\n if (mLoaderTask != null) {\n mLoaderTask.dumpState();\n } else {\n Log.d(TAG, \"mLoaderTask=null\");\n }\n }\n}\n", "output": " static boolean shortcutExists(Context context, String title, Intent intent) {\n final ContentResolver cr = context.getContentResolver();\n Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI,\n new String[] { \"title\", \"intent\" }, \"title=? and intent=?\",\n new String[] { title, intent.toUri(0) }, null);\n boolean result = false;\n try {\n result = c.moveToFirst();\n } finally {\n c.close();\n }\n return result;\n }\n static ArrayList<ItemInfo> getItemsInLocalCoordinates(Context context) {\n ArrayList<ItemInfo> items = new ArrayList<ItemInfo>();\n final ContentResolver cr = context.getContentResolver();\n Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, new String[] {\n LauncherSettings.Favorites.ITEM_TYPE, LauncherSettings.Favorites.CONTAINER,\n LauncherSettings.Favorites.SCREEN, LauncherSettings.Favorites.CELLX, LauncherSettings.Favorites.CELLY,\n LauncherSettings.Favorites.SPANX, LauncherSettings.Favorites.SPANY }, null, null, null);\n final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);\n final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);\n final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);\n final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);\n final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);\n final int spanXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANX);\n final int spanYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SPANY);\n try {\n while (c.moveToNext()) {\n ItemInfo item = new ItemInfo();\n item.cellX = c.getInt(cellXIndex);\n item.cellY = c.getInt(cellYIndex);\n item.spanX = Math.max(1, c.getInt(spanXIndex));\n item.spanY = Math.max(1, c.getInt(spanYIndex));\n item.container = c.getInt(containerIndex);\n item.itemType = c.getInt(itemTypeIndex);\n item.screenId = c.getInt(screenIndex);\n items.add(item);\n }\n } catch (Exception e) {\n items.clear();\n } finally {\n c.close();\n }\n return items;\n }\n FolderInfo getFolderById(Context context, HashMap<Long,FolderInfo> folderList, long id) {\n final ContentResolver cr = context.getContentResolver();\n Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI, null,\n \"_id=? and (itemType=? or itemType=?)\",\n new String[] { String.valueOf(id),\n String.valueOf(LauncherSettings.Favorites.ITEM_TYPE_FOLDER)}, null);\n try {\n if (c.moveToFirst()) {\n final int itemTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ITEM_TYPE);\n final int titleIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);\n final int containerIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CONTAINER);\n final int screenIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.SCREEN);\n final int cellXIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);\n final int cellYIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);\n FolderInfo folderInfo = null;\n switch (c.getInt(itemTypeIndex)) {\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n folderInfo = findOrMakeFolder(folderList, id);\n break;\n }\n folderInfo.title = c.getString(titleIndex);\n folderInfo.id = id;\n folderInfo.container = c.getInt(containerIndex);\n folderInfo.screenId = c.getInt(screenIndex);\n folderInfo.cellX = c.getInt(cellXIndex);\n folderInfo.cellY = c.getInt(cellYIndex);\n return folderInfo;\n }\n } finally {\n c.close();\n }\n return null;\n }\n static void addItemToDatabase(Context context, final ItemInfo item, final long container,\n final long screenId, final int cellX, final int cellY, final boolean notify) {\n item.container = container;\n item.cellX = cellX;\n item.cellY = cellY;\n if (context instanceof Launcher && screenId < 0 &&\n container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n item.screenId = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);\n } else {\n item.screenId = screenId;\n }\n final ContentValues values = new ContentValues();\n final ContentResolver cr = context.getContentResolver();\n item.onAddToDatabase(values);\n LauncherAppState app = LauncherAppState.getInstance();\n item.id = app.getLauncherProvider().generateNewItemId();\n values.put(LauncherSettings.Favorites._ID, item.id);\n item.updateValuesWithCoordinates(values, item.cellX, item.cellY);\n Runnable r = new Runnable() {\n public void run() {\n String transaction = \"DbDebug Add item (\" + item.title + \") to db, id: \"\n + item.id + \" (\" + container + \", \" + screenId + \", \" + cellX + \", \"\n + cellY + \")\";\n Launcher.sDumpLogs.add(transaction);\n Log.d(TAG, transaction);\n cr.insert(notify ? LauncherSettings.Favorites.CONTENT_URI :\n LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, values);\n synchronized (sBgLock) {\n checkItemInfoLocked(item.id, item, null);\n sBgItemsIdMap.put(item.id, item);\n switch (item.itemType) {\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n sBgFolders.put(item.id, (FolderInfo) item);\n case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:\n case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:\n if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP ||\n item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n sBgWorkspaceItems.add(item);\n } else {\n if (!sBgFolders.containsKey(item.container)) {\n String msg = \"adding item: \" + item + \" to a folder that \" +\n \" doesn't exist\";\n Log.e(TAG, msg);\n Launcher.dumpDebugLogsToConsole();\n }\n }\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:\n sBgAppWidgets.add((LauncherAppWidgetInfo) item);\n break;\n }\n }\n }\n };\n runOnWorkerThread(r);\n }\n static int getCellLayoutChildId(\n long container, long screen, int localCellX, int localCellY, int spanX, int spanY) {\n return (((int) container & 0xFF) << 24)\n | ((int) screen & 0xFF) << 16 | (localCellX & 0xFF) << 8 | (localCellY & 0xFF);\n }\n static int getCellCountX() {\n return mCellCountX;\n }\n static int getCellCountY() {\n return mCellCountY;\n }\n static void updateWorkspaceLayoutCells(int shortAxisCellCount, int longAxisCellCount) {\n mCellCountX = shortAxisCellCount;\n mCellCountY = longAxisCellCount;\n }\n static void deleteItemFromDatabase(Context context, final ItemInfo item) {\n final ContentResolver cr = context.getContentResolver();\n final Uri uriToDelete = LauncherSettings.Favorites.getContentUri(item.id, false);\n Runnable r = new Runnable() {\n public void run() {\n String transaction = \"DbDebug Delete item (\" + item.title + \") from db, id: \"\n + item.id + \" (\" + item.container + \", \" + item.screenId + \", \" + item.cellX +\n \", \" + item.cellY + \")\";\n Launcher.sDumpLogs.add(transaction);\n Log.d(TAG, transaction);\n cr.delete(uriToDelete, null, null);\n synchronized (sBgLock) {\n switch (item.itemType) {\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n sBgFolders.remove(item.id);\n for (ItemInfo info: sBgItemsIdMap.values()) {\n if (info.container == item.id) {\n String msg = \"deleting a folder (\" + item + \") which still \" +\n \"contains items (\" + info + \")\";\n Log.e(TAG, msg);\n Launcher.dumpDebugLogsToConsole();\n }\n }\n sBgWorkspaceItems.remove(item);\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:\n case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:\n sBgWorkspaceItems.remove(item);\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:\n sBgAppWidgets.remove((LauncherAppWidgetInfo) item);\n break;\n }\n sBgItemsIdMap.remove(item.id);\n sBgDbIconCache.remove(item);\n }\n }\n };\n runOnWorkerThread(r);\n }\n void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {\n final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);\n final ContentResolver cr = context.getContentResolver();\n final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;\n Iterator<Long> iter = screensCopy.iterator();\n while (iter.hasNext()) {\n long id = iter.next();\n if (id < 0) {\n iter.remove();\n }\n }\n Runnable r = new Runnable() {\n @Override\n public void run() {\n cr.delete(uri, null, null);\n int count = screensCopy.size();\n ContentValues[] values = new ContentValues[count];\n for (int i = 0; i < count; i++) {\n ContentValues v = new ContentValues();\n long screenId = screensCopy.get(i);\n v.put(LauncherSettings.WorkspaceScreens._ID, screenId);\n v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);\n Log.w(TAG, \"10249126 - updateWorkspaceScreenOrder(\" + screenId + \", \" + i + \")\");\n values[i] = v;\n }\n cr.bulkInsert(uri, values);\n sBgWorkspaceScreens.clear();\n sBgWorkspaceScreens.addAll(screensCopy);\n }\n };\n runOnWorkerThread(r);\n }\n static void deleteFolderContentsFromDatabase(Context context, final FolderInfo info) {\n final ContentResolver cr = context.getContentResolver();\n Runnable r = new Runnable() {\n public void run() {\n cr.delete(LauncherSettings.Favorites.getContentUri(info.id, false), null, null);\n synchronized (sBgLock) {\n sBgItemsIdMap.remove(info.id);\n sBgFolders.remove(info.id);\n sBgDbIconCache.remove(info);\n sBgWorkspaceItems.remove(info);\n }\n cr.delete(LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION,\n LauncherSettings.Favorites.CONTAINER + \"=\" + info.id, null);\n synchronized (sBgLock) {\n for (ItemInfo childInfo : info.contents) {\n sBgItemsIdMap.remove(childInfo.id);\n sBgDbIconCache.remove(childInfo);\n }\n }\n }\n };\n runOnWorkerThread(r);\n }\n public void initialize(Callbacks callbacks) {\n synchronized (mLock) {\n mCallbacks = new WeakReference<Callbacks>(callbacks);\n }\n }\n @Override\n public void onReceive(Context context, Intent intent) {\n if (DEBUG_LOADERS) Log.d(TAG, \"onReceive intent=\" + intent);\n final String action = intent.getAction();\n if (Intent.ACTION_PACKAGE_CHANGED.equals(action)\n || Intent.ACTION_PACKAGE_REMOVED.equals(action)\n || Intent.ACTION_PACKAGE_ADDED.equals(action)) {\n final String packageName = intent.getData().getSchemeSpecificPart();\n final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);\n int op = PackageUpdatedTask.OP_NONE;\n if (packageName == null || packageName.length() == 0) {\n return;\n }\n if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {\n op = PackageUpdatedTask.OP_UPDATE;\n } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {\n if (!replacing) {\n op = PackageUpdatedTask.OP_REMOVE;\n }\n } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {\n if (!replacing) {\n op = PackageUpdatedTask.OP_ADD;\n } else {\n op = PackageUpdatedTask.OP_UPDATE;\n }\n }\n if (op != PackageUpdatedTask.OP_NONE) {\n enqueuePackageUpdated(new PackageUpdatedTask(op, new String[] { packageName }));\n }\n } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {\n String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);\n enqueuePackageUpdated(new PackageUpdatedTask(PackageUpdatedTask.OP_ADD, packages));\n startLoaderFromBackground();\n } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {\n String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);\n enqueuePackageUpdated(new PackageUpdatedTask(\n PackageUpdatedTask.OP_UNAVAILABLE, packages));\n } else if (Intent.ACTION_LOCALE_CHANGED.equals(action)) {\n forceReload();\n } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {\n Configuration currentConfig = context.getResources().getConfiguration();\n if (mPreviousConfigMcc != currentConfig.mcc) {\n Log.d(TAG, \"Reload apps on config change. curr_mcc:\"\n + currentConfig.mcc + \" prevmcc:\" + mPreviousConfigMcc);\n forceReload();\n }\n mPreviousConfigMcc = currentConfig.mcc;\n } else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||\n SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {\n if (mCallbacks != null) {\n Callbacks callbacks = mCallbacks.get();\n if (callbacks != null) {\n callbacks.bindSearchablesChanged();\n }\n }\n }\n }\n private void forceReload() {\n resetLoadedState(true, true);\n startLoaderFromBackground();\n }\n public void resetLoadedState(boolean resetAllAppsLoaded, boolean resetWorkspaceLoaded) {\n synchronized (mLock) {\n stopLoaderLocked();\n if (resetAllAppsLoaded) mAllAppsLoaded = false;\n if (resetWorkspaceLoaded) mWorkspaceLoaded = false;\n }\n }\n public void startLoaderFromBackground() {\n boolean runLoader = false;\n if (mCallbacks != null) {\n Callbacks callbacks = mCallbacks.get();\n if (callbacks != null) {\n if (!callbacks.setLoadOnResume()) {\n runLoader = true;\n }\n }\n }\n if (runLoader) {\n startLoader(false, -1);\n }\n }\n private boolean stopLoaderLocked() {\n boolean isLaunching = false;\n LoaderTask oldTask = mLoaderTask;\n if (oldTask != null) {\n if (oldTask.isLaunching()) {\n isLaunching = true;\n }\n oldTask.stopLocked();\n }\n return isLaunching;\n }\n public void startLoader(boolean isLaunching, int synchronousBindPage) {\n synchronized (mLock) {\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"startLoader isLaunching=\" + isLaunching);\n }\n mDeferredBindRunnables.clear();\n if (mCallbacks != null && mCallbacks.get() != null) {\n isLaunching = isLaunching || stopLoaderLocked();\n mLoaderTask = new LoaderTask(mApp.getContext(), isLaunching);\n if (synchronousBindPage > -1 && mAllAppsLoaded && mWorkspaceLoaded) {\n mLoaderTask.runBindSynchronousPage(synchronousBindPage);\n } else {\n sWorkerThread.setPriority(Thread.NORM_PRIORITY);\n sWorker.post(mLoaderTask);\n }\n }\n }\n }\n void bindRemainingSynchronousPages() {\n if (!mDeferredBindRunnables.isEmpty()) {\n for (final Runnable r : mDeferredBindRunnables) {\n mHandler.post(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n mDeferredBindRunnables.clear();\n }\n }\n public void stopLoader() {\n synchronized (mLock) {\n if (mLoaderTask != null) {\n mLoaderTask.stopLocked();\n }\n }\n }\n private static TreeMap<Integer, Long> loadWorkspaceScreensDb(Context context) {\n final ContentResolver contentResolver = context.getContentResolver();\n final Uri screensUri = LauncherSettings.WorkspaceScreens.CONTENT_URI;\n final Cursor sc = contentResolver.query(screensUri, null, null, null, null);\n TreeMap<Integer, Long> orderedScreens = new TreeMap<Integer, Long>();\n try {\n final int idIndex = sc.getColumnIndexOrThrow(\n LauncherSettings.WorkspaceScreens._ID);\n final int rankIndex = sc.getColumnIndexOrThrow(\n LauncherSettings.WorkspaceScreens.SCREEN_RANK);\n while (sc.moveToNext()) {\n try {\n long screenId = sc.getLong(idIndex);\n int rank = sc.getInt(rankIndex);\n Log.w(TAG, \"10249126 - loadWorkspaceScreensDb(\" + screenId + \", \" + rank + \")\");\n orderedScreens.put(rank, screenId);\n } catch (Exception e) {\n Log.w(TAG, \"Desktop items loading interrupted - invalid screens: \", e);\n }\n }\n } finally {\n sc.close();\n }\n return orderedScreens;\n }\n public boolean isAllAppsLoaded() {\n return mAllAppsLoaded;\n }\n boolean isLoadingWorkspace() {\n synchronized (mLock) {\n if (mLoaderTask != null) {\n return mLoaderTask.isLoadingWorkspace();\n }\n }\n return false;\n }\n private class LoaderTask implements Runnable {\n private Context mContext;\n private boolean mIsLaunching;\n private boolean mIsLoadingAndBindingWorkspace;\n private boolean mStopped;\n private boolean mLoadAndBindStepFinished;\n private HashMap<Object, CharSequence> mLabelCache;\n LoaderTask(Context context, boolean isLaunching) {\n mContext = context;\n mIsLaunching = isLaunching;\n mLabelCache = new HashMap<Object, CharSequence>();\n }\n boolean isLaunching() {\n return mIsLaunching;\n }\n boolean isLoadingWorkspace() {\n return mIsLoadingAndBindingWorkspace;\n }\n private boolean loadAndBindWorkspace() {\n mIsLoadingAndBindingWorkspace = true;\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"loadAndBindWorkspace mWorkspaceLoaded=\" + mWorkspaceLoaded);\n }\n boolean isUpgradePath = false;\n if (!mWorkspaceLoaded) {\n isUpgradePath = loadWorkspace();\n synchronized (LoaderTask.this) {\n if (mStopped) {\n return isUpgradePath;\n }\n mWorkspaceLoaded = true;\n }\n }\n bindWorkspace(-1, isUpgradePath);\n return isUpgradePath;\n }\n private void waitForIdle() {\n synchronized (LoaderTask.this) {\n final long workspaceWaitTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n mHandler.postIdle(new Runnable() {\n public void run() {\n synchronized (LoaderTask.this) {\n mLoadAndBindStepFinished = true;\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"done with previous binding step\");\n }\n LoaderTask.this.notify();\n }\n }\n });\n while (!mStopped && !mLoadAndBindStepFinished && !mFlushingWorkerThread) {\n try {\n this.wait(1000);\n } catch (InterruptedException ex) {\n }\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"waited \"\n + (SystemClock.uptimeMillis()-workspaceWaitTime)\n + \"ms for previous step to finish binding\");\n }\n }\n }\n void runBindSynchronousPage(int synchronousBindPage) {\n if (synchronousBindPage < 0) {\n throw new RuntimeException(\"Should not call runBindSynchronousPage() without \" +\n \"valid page index\");\n }\n if (!mAllAppsLoaded || !mWorkspaceLoaded) {\n throw new RuntimeException(\"Expecting AllApps and Workspace to be loaded\");\n }\n synchronized (mLock) {\n if (mIsLoaderTaskRunning) {\n throw new RuntimeException(\"Error! Background loading is already running\");\n }\n }\n mHandler.flush();\n bindWorkspace(synchronousBindPage, false);\n onlyBindAllApps();\n }\n public void run() {\n boolean isUpgrade = false;\n synchronized (mLock) {\n mIsLoaderTaskRunning = true;\n }\n final Callbacks cbk = mCallbacks.get();\n keep_running: {\n synchronized (mLock) {\n if (DEBUG_LOADERS) Log.d(TAG, \"Setting thread priority to \" +\n (mIsLaunching ? \"DEFAULT\" : \"BACKGROUND\"));\n android.os.Process.setThreadPriority(mIsLaunching\n ? Process.THREAD_PRIORITY_DEFAULT : Process.THREAD_PRIORITY_BACKGROUND);\n }\n if (DEBUG_LOADERS) Log.d(TAG, \"step 1: loading workspace\");\n isUpgrade = loadAndBindWorkspace();\n if (mStopped) {\n break keep_running;\n }\n synchronized (mLock) {\n if (mIsLaunching) {\n if (DEBUG_LOADERS) Log.d(TAG, \"Setting thread priority to BACKGROUND\");\n android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);\n }\n }\n waitForIdle();\n if (DEBUG_LOADERS) Log.d(TAG, \"step 2: loading all apps\");\n loadAndBindAllApps();\n synchronized (mLock) {\n android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);\n }\n }\n if (DEBUG_LOADERS) Log.d(TAG, \"Comparing loaded icons to database icons\");\n synchronized (sBgLock) {\n for (Object key : sBgDbIconCache.keySet()) {\n updateSavedIcon(mContext, (ShortcutInfo) key, sBgDbIconCache.get(key));\n }\n sBgDbIconCache.clear();\n }\n Log.w(TAG, \"10249126 - verifyApplications - useMoreApps=\"\n + UPGRADE_USE_MORE_APPS_FOLDER + \" isUpgrade=\" + isUpgrade);\n if (!UPGRADE_USE_MORE_APPS_FOLDER || !isUpgrade) {\n verifyApplications();\n }\n mContext = null;\n synchronized (mLock) {\n if (mLoaderTask == this) {\n mLoaderTask = null;\n }\n mIsLoaderTaskRunning = false;\n }\n }\n public void stopLocked() {\n synchronized (LoaderTask.this) {\n mStopped = true;\n this.notify();\n }\n }\n Callbacks tryGetCallbacks(Callbacks oldCallbacks) {\n synchronized (mLock) {\n if (mStopped) {\n return null;\n }\n if (mCallbacks == null) {\n return null;\n }\n final Callbacks callbacks = mCallbacks.get();\n if (callbacks != oldCallbacks) {\n return null;\n }\n if (callbacks == null) {\n Log.w(TAG, \"no mCallbacks\");\n return null;\n }\n return callbacks;\n }\n }\n private void verifyApplications() {\n final Context context = mApp.getContext();\n ArrayList<ItemInfo> tmpInfos;\n ArrayList<ItemInfo> added = new ArrayList<ItemInfo>();\n synchronized (sBgLock) {\n for (ApplicationInfo app : mBgAllAppsList.data) {\n tmpInfos = getItemInfoForComponentName(app.componentName);\n Log.w(TAG, \"10249126 - \\t\" + app.componentName.getPackageName() + \", \" + tmpInfos.isEmpty());\n if (tmpInfos.isEmpty()) {\n added.add(app);\n Log.e(TAG, \"Missing Application on load: \" + app);\n }\n }\n }\n if (!added.isEmpty()) {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n addAndBindAddedApps(context, added, cb);\n }\n }\n private boolean checkItemDimensions(ItemInfo info) {\n return (info.cellX + info.spanX) > mCellCountX ||\n (info.cellY + info.spanY) > mCellCountY;\n }\n private boolean checkItemPlacement(HashMap<Long, ItemInfo[][]> occupied, ItemInfo item) {\n long containerIndex = item.screenId;\n if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n if (occupied.containsKey(LauncherSettings.Favorites.CONTAINER_HOTSEAT)) {\n if (occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT)\n [(int) item.screenId][0] != null) {\n Log.e(TAG, \"Error loading shortcut into hotseat \" + item\n + \" into position (\" + item.screenId + \":\" + item.cellX + \",\"\n + item.cellY + \") occupied by \"\n + occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT)\n [(int) item.screenId][0]);\n return false;\n }\n } else {\n ItemInfo[][] items = new ItemInfo[mCellCountX + 1][mCellCountY + 1];\n items[(int) item.screenId][0] = item;\n occupied.put((long) LauncherSettings.Favorites.CONTAINER_HOTSEAT, items);\n return true;\n }\n } else if (item.container != LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n return true;\n }\n if (!occupied.containsKey(item.screenId)) {\n ItemInfo[][] items = new ItemInfo[mCellCountX + 1][mCellCountY + 1];\n occupied.put(item.screenId, items);\n }\n ItemInfo[][] screens = occupied.get(item.screenId);\n for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {\n for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {\n if (screens[x][y] != null) {\n Log.e(TAG, \"Error loading shortcut \" + item\n + \" into cell (\" + containerIndex + \"-\" + item.screenId + \":\"\n + x + \",\" + y\n + \") occupied by \"\n + screens[x][y]);\n return false;\n }\n }\n }\n for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {\n for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {\n screens[x][y] = item;\n }\n }\n return true;\n }\n private boolean loadWorkspace() {\n final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n final Context context = mContext;\n final ContentResolver contentResolver = context.getContentResolver();\n final PackageManager manager = context.getPackageManager();\n final AppWidgetManager widgets = AppWidgetManager.getInstance(context);\n final boolean isSafeMode = manager.isSafeMode();\n mApp.getLauncherProvider().loadDefaultFavoritesIfNecessary(0);\n boolean loadedOldDb = mApp.getLauncherProvider().justLoadedOldDb();\n synchronized (sBgLock) {\n sBgWorkspaceItems.clear();\n sBgAppWidgets.clear();\n sBgFolders.clear();\n sBgItemsIdMap.clear();\n sBgDbIconCache.clear();\n sBgWorkspaceScreens.clear();\n Log.w(TAG, \"10249126 - loadWorkspace()\");\n final ArrayList<Long> itemsToRemove = new ArrayList<Long>();\n final Uri contentUri = LauncherSettings.Favorites.CONTENT_URI;\n final Cursor c = contentResolver.query(contentUri, null, null, null, null);\n final HashMap<Long, ItemInfo[][]> occupied = new HashMap<Long, ItemInfo[][]>();\n try {\n final int idIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites._ID);\n final int intentIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.INTENT);\n final int titleIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.TITLE);\n final int iconTypeIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ICON_TYPE);\n final int iconIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);\n final int iconPackageIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ICON_PACKAGE);\n final int iconResourceIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ICON_RESOURCE);\n final int containerIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.CONTAINER);\n final int itemTypeIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.ITEM_TYPE);\n final int appWidgetIdIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.APPWIDGET_ID);\n final int screenIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.SCREEN);\n final int cellXIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.CELLX);\n final int cellYIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.CELLY);\n final int spanXIndex = c.getColumnIndexOrThrow\n (LauncherSettings.Favorites.SPANX);\n final int spanYIndex = c.getColumnIndexOrThrow(\n LauncherSettings.Favorites.SPANY);\n ShortcutInfo info;\n String intentDescription;\n LauncherAppWidgetInfo appWidgetInfo;\n int container;\n long id;\n Intent intent;\n while (!mStopped && c.moveToNext()) {\n try {\n int itemType = c.getInt(itemTypeIndex);\n switch (itemType) {\n case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:\n case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:\n id = c.getLong(idIndex);\n intentDescription = c.getString(intentIndex);\n try {\n intent = Intent.parseUri(intentDescription, 0);\n ComponentName cn = intent.getComponent();\n if (!isValidPackageComponent(manager, cn)) {\n if (!mAppsCanBeOnRemoveableStorage) {\n Uri uri = LauncherSettings.Favorites.getContentUri(id,\n false);\n contentResolver.delete(uri, null, null);\n Log.e(TAG, \"Invalid package removed: \" + cn);\n } else {\n Log.e(TAG, \"Invalid package found: \" + cn);\n }\n continue;\n }\n } catch (URISyntaxException e) {\n continue;\n }\n if (itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {\n info = getShortcutInfo(manager, intent, context, c, iconIndex,\n titleIndex, mLabelCache);\n } else {\n info = getShortcutInfo(c, context, iconTypeIndex,\n iconPackageIndex, iconResourceIndex, iconIndex,\n titleIndex);\n if (intent.getAction() != null &&\n intent.getCategories() != null &&\n intent.getAction().equals(Intent.ACTION_MAIN) &&\n intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {\n intent.addFlags(\n Intent.FLAG_ACTIVITY_NEW_TASK |\n Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);\n }\n }\n if (info != null) {\n info.id = id;\n info.intent = intent;\n container = c.getInt(containerIndex);\n info.container = container;\n info.screenId = c.getInt(screenIndex);\n info.cellX = c.getInt(cellXIndex);\n info.cellY = c.getInt(cellYIndex);\n info.spanX = 1;\n info.spanY = 1;\n if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n if (checkItemDimensions(info)) {\n Log.d(TAG, \"Skipped loading out of bounds shortcut: \"\n + info.intent);\n continue;\n }\n }\n if (!checkItemPlacement(occupied, info)) {\n break;\n }\n switch (container) {\n case LauncherSettings.Favorites.CONTAINER_DESKTOP:\n case LauncherSettings.Favorites.CONTAINER_HOTSEAT:\n sBgWorkspaceItems.add(info);\n break;\n default:\n FolderInfo folderInfo =\n findOrMakeFolder(sBgFolders, container);\n folderInfo.add(info);\n break;\n }\n sBgItemsIdMap.put(info.id, info);\n queueIconToBeChecked(sBgDbIconCache, info, c, iconIndex);\n } else {\n throw new RuntimeException(\"Unexpected null ShortcutInfo\");\n }\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_FOLDER:\n id = c.getLong(idIndex);\n FolderInfo folderInfo = findOrMakeFolder(sBgFolders, id);\n folderInfo.title = c.getString(titleIndex);\n folderInfo.id = id;\n container = c.getInt(containerIndex);\n folderInfo.container = container;\n folderInfo.screenId = c.getInt(screenIndex);\n folderInfo.cellX = c.getInt(cellXIndex);\n folderInfo.cellY = c.getInt(cellYIndex);\n folderInfo.spanX = 1;\n folderInfo.spanY = 1;\n if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n int iconSpan = 1;\n if (checkItemDimensions(folderInfo)) {\n Log.d(TAG, \"Skipped loading out of bounds folder\");\n continue;\n }\n }\n if (!checkItemPlacement(occupied, folderInfo)) {\n break;\n }\n switch (container) {\n case LauncherSettings.Favorites.CONTAINER_DESKTOP:\n case LauncherSettings.Favorites.CONTAINER_HOTSEAT:\n sBgWorkspaceItems.add(folderInfo);\n break;\n }\n sBgItemsIdMap.put(folderInfo.id, folderInfo);\n sBgFolders.put(folderInfo.id, folderInfo);\n break;\n case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:\n int appWidgetId = c.getInt(appWidgetIdIndex);\n id = c.getLong(idIndex);\n final AppWidgetProviderInfo provider =\n widgets.getAppWidgetInfo(appWidgetId);\n if (!isSafeMode && (provider == null || provider.provider == null ||\n provider.provider.getPackageName() == null)) {\n String log = \"Deleting widget that isn't installed anymore: id=\"\n + id + \" appWidgetId=\" + appWidgetId;\n Log.e(TAG, log);\n Launcher.sDumpLogs.add(log);\n itemsToRemove.add(id);\n } else {\n appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,\n provider.provider);\n appWidgetInfo.id = id;\n appWidgetInfo.screenId = c.getInt(screenIndex);\n appWidgetInfo.cellX = c.getInt(cellXIndex);\n appWidgetInfo.cellY = c.getInt(cellYIndex);\n appWidgetInfo.spanX = c.getInt(spanXIndex);\n appWidgetInfo.spanY = c.getInt(spanYIndex);\n int[] minSpan = Launcher.getMinSpanForWidget(context, provider);\n appWidgetInfo.minSpanX = minSpan[0];\n appWidgetInfo.minSpanY = minSpan[1];\n container = c.getInt(containerIndex);\n if (container != LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n container != LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n Log.e(TAG, \"Widget found where container != \" +\n \"CONTAINER_DESKTOP nor CONTAINER_HOTSEAT - ignoring!\");\n continue;\n }\n appWidgetInfo.container = c.getInt(containerIndex);\n if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n if (checkItemDimensions(appWidgetInfo)) {\n Log.d(TAG, \"Skipped loading out of bounds app widget\");\n continue;\n }\n }\n if (!checkItemPlacement(occupied, appWidgetInfo)) {\n break;\n }\n sBgItemsIdMap.put(appWidgetInfo.id, appWidgetInfo);\n sBgAppWidgets.add(appWidgetInfo);\n }\n break;\n }\n } catch (Exception e) {\n Log.w(TAG, \"Desktop items loading interrupted:\", e);\n }\n }\n } finally {\n if (c != null) {\n c.close();\n }\n }\n if (itemsToRemove.size() > 0) {\n ContentProviderClient client = contentResolver.acquireContentProviderClient(\n LauncherSettings.Favorites.CONTENT_URI);\n for (long id : itemsToRemove) {\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"Removed id = \" + id);\n }\n try {\n client.delete(LauncherSettings.Favorites.getContentUri(id, false),\n null, null);\n } catch (RemoteException e) {\n Log.w(TAG, \"Could not remove id = \" + id);\n }\n }\n }\n if (loadedOldDb) {\n Log.w(TAG, \"10249126 - loadWorkspace - loadedOldDb\");\n long maxScreenId = 0;\n for (ItemInfo item: sBgItemsIdMap.values()) {\n long screenId = item.screenId;\n if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n !sBgWorkspaceScreens.contains(screenId)) {\n Log.w(TAG, \"10249126 - loadWorkspace-loadedOldDb(\" + screenId + \")\");\n sBgWorkspaceScreens.add(screenId);\n if (screenId > maxScreenId) {\n maxScreenId = screenId;\n }\n }\n }\n Collections.sort(sBgWorkspaceScreens);\n mApp.getLauncherProvider().updateMaxScreenId(maxScreenId);\n updateWorkspaceScreenOrder(context, sBgWorkspaceScreens);\n long maxItemId = 0;\n for (ItemInfo item: sBgItemsIdMap.values()) {\n maxItemId = Math.max(maxItemId, item.id);\n }\n LauncherAppState app = LauncherAppState.getInstance();\n app.getLauncherProvider().updateMaxItemId(maxItemId);\n } else {\n Log.w(TAG, \"10249126 - loadWorkspace - !loadedOldDb\");\n TreeMap<Integer, Long> orderedScreens = loadWorkspaceScreensDb(mContext);\n for (Integer i : orderedScreens.keySet()) {\n sBgWorkspaceScreens.add(orderedScreens.get(i));\n }\n ArrayList<Long> unusedScreens = new ArrayList<Long>();\n unusedScreens.addAll(sBgWorkspaceScreens);\n for (ItemInfo item: sBgItemsIdMap.values()) {\n long screenId = item.screenId;\n if (item.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n unusedScreens.contains(screenId)) {\n unusedScreens.remove(screenId);\n }\n }\n if (unusedScreens.size() != 0) {\n sBgWorkspaceScreens.removeAll(unusedScreens);\n updateWorkspaceScreenOrder(context, sBgWorkspaceScreens);\n }\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"loaded workspace in \" + (SystemClock.uptimeMillis()-t) + \"ms\");\n Log.d(TAG, \"workspace layout: \");\n int nScreens = occupied.size();\n for (int y = 0; y < mCellCountY; y++) {\n String line = \"\";\n Iterator<Long> iter = occupied.keySet().iterator();\n while (iter.hasNext()) {\n long screenId = iter.next();\n if (screenId > 0) {\n line += \" | \";\n }\n for (int x = 0; x < mCellCountX; x++) {\n line += ((occupied.get(screenId)[x][y] != null) ? \"#\" : \".\");\n }\n }\n Log.d(TAG, \"[ \" + line + \" ]\");\n }\n }\n }\n return loadedOldDb;\n }\n private void filterCurrentWorkspaceItems(int currentScreen,\n ArrayList<ItemInfo> allWorkspaceItems,\n ArrayList<ItemInfo> currentScreenItems,\n ArrayList<ItemInfo> otherScreenItems) {\n Iterator<ItemInfo> iter = allWorkspaceItems.iterator();\n while (iter.hasNext()) {\n ItemInfo i = iter.next();\n if (i == null) {\n iter.remove();\n }\n }\n if (currentScreen < 0) {\n currentScreenItems.addAll(allWorkspaceItems);\n }\n Set<Long> itemsOnScreen = new HashSet<Long>();\n Collections.sort(allWorkspaceItems, new Comparator<ItemInfo>() {\n @Override\n public int compare(ItemInfo lhs, ItemInfo rhs) {\n return (int) (lhs.container - rhs.container);\n }\n });\n for (ItemInfo info : allWorkspaceItems) {\n if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {\n if (info.screenId == currentScreen) {\n currentScreenItems.add(info);\n itemsOnScreen.add(info.id);\n } else {\n otherScreenItems.add(info);\n }\n } else if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {\n currentScreenItems.add(info);\n itemsOnScreen.add(info.id);\n } else {\n if (itemsOnScreen.contains(info.container)) {\n currentScreenItems.add(info);\n itemsOnScreen.add(info.id);\n } else {\n otherScreenItems.add(info);\n }\n }\n }\n }\n private void filterCurrentAppWidgets(int currentScreen,\n ArrayList<LauncherAppWidgetInfo> appWidgets,\n ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,\n ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {\n if (currentScreen < 0) {\n currentScreenWidgets.addAll(appWidgets);\n }\n for (LauncherAppWidgetInfo widget : appWidgets) {\n if (widget == null) continue;\n if (widget.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n widget.screenId == currentScreen) {\n currentScreenWidgets.add(widget);\n } else {\n otherScreenWidgets.add(widget);\n }\n }\n }\n private void filterCurrentFolders(int currentScreen,\n HashMap<Long, ItemInfo> itemsIdMap,\n HashMap<Long, FolderInfo> folders,\n HashMap<Long, FolderInfo> currentScreenFolders,\n HashMap<Long, FolderInfo> otherScreenFolders) {\n if (currentScreen < 0) {\n currentScreenFolders.putAll(folders);\n }\n for (long id : folders.keySet()) {\n ItemInfo info = itemsIdMap.get(id);\n FolderInfo folder = folders.get(id);\n if (info == null || folder == null) continue;\n if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&\n info.screenId == currentScreen) {\n currentScreenFolders.put(id, folder);\n } else {\n otherScreenFolders.put(id, folder);\n }\n }\n }\n private void sortWorkspaceItemsSpatially(ArrayList<ItemInfo> workspaceItems) {\n Collections.sort(workspaceItems, new Comparator<ItemInfo>() {\n @Override\n public int compare(ItemInfo lhs, ItemInfo rhs) {\n int cellCountX = LauncherModel.getCellCountX();\n int cellCountY = LauncherModel.getCellCountY();\n int screenOffset = cellCountX * cellCountY;\n int containerOffset = screenOffset * (Launcher.SCREEN_COUNT + 1); \n long lr = (lhs.container * containerOffset + lhs.screenId * screenOffset +\n lhs.cellY * cellCountX + lhs.cellX);\n long rr = (rhs.container * containerOffset + rhs.screenId * screenOffset +\n rhs.cellY * cellCountX + rhs.cellX);\n return (int) (lr - rr);\n }\n });\n }\n private void bindWorkspaceScreens(final Callbacks oldCallbacks,\n final ArrayList<Long> orderedScreens) {\n Log.w(TAG, \"10249126 - bindWorkspaceScreens()\");\n final Runnable r = new Runnable() {\n @Override\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindScreens(orderedScreens);\n }\n }\n };\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n private void bindWorkspaceItems(final Callbacks oldCallbacks,\n final ArrayList<ItemInfo> workspaceItems,\n final ArrayList<LauncherAppWidgetInfo> appWidgets,\n final HashMap<Long, FolderInfo> folders,\n ArrayList<Runnable> deferredBindRunnables) {\n final boolean postOnMainThread = (deferredBindRunnables != null);\n int N = workspaceItems.size();\n for (int i = 0; i < N; i += ITEMS_CHUNK) {\n final int start = i;\n final int chunkSize = (i+ITEMS_CHUNK <= N) ? ITEMS_CHUNK : (N-i);\n final Runnable r = new Runnable() {\n @Override\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindItems(workspaceItems, start, start+chunkSize,\n false);\n }\n }\n };\n if (postOnMainThread) {\n deferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n if (!folders.isEmpty()) {\n final Runnable r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindFolders(folders);\n }\n }\n };\n if (postOnMainThread) {\n deferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n N = appWidgets.size();\n for (int i = 0; i < N; i++) {\n final LauncherAppWidgetInfo widget = appWidgets.get(i);\n final Runnable r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindAppWidget(widget);\n }\n }\n };\n if (postOnMainThread) {\n deferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n }\n private void bindWorkspace(int synchronizeBindPage, final boolean isUpgradePath) {\n final long t = SystemClock.uptimeMillis();\n Runnable r;\n final Callbacks oldCallbacks = mCallbacks.get();\n if (oldCallbacks == null) {\n Log.w(TAG, \"LoaderTask running with no launcher\");\n return;\n }\n final boolean isLoadingSynchronously = (synchronizeBindPage > -1);\n final int currentScreen = isLoadingSynchronously ? synchronizeBindPage :\n oldCallbacks.getCurrentWorkspaceScreen();\n unbindWorkspaceItemsOnMainThread();\n ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();\n ArrayList<LauncherAppWidgetInfo> appWidgets =\n new ArrayList<LauncherAppWidgetInfo>();\n HashMap<Long, FolderInfo> folders = new HashMap<Long, FolderInfo>();\n HashMap<Long, ItemInfo> itemsIdMap = new HashMap<Long, ItemInfo>();\n ArrayList<Long> orderedScreenIds = new ArrayList<Long>();\n synchronized (sBgLock) {\n workspaceItems.addAll(sBgWorkspaceItems);\n appWidgets.addAll(sBgAppWidgets);\n folders.putAll(sBgFolders);\n itemsIdMap.putAll(sBgItemsIdMap);\n orderedScreenIds.addAll(sBgWorkspaceScreens);\n }\n ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<ItemInfo>();\n ArrayList<ItemInfo> otherWorkspaceItems = new ArrayList<ItemInfo>();\n ArrayList<LauncherAppWidgetInfo> currentAppWidgets =\n new ArrayList<LauncherAppWidgetInfo>();\n ArrayList<LauncherAppWidgetInfo> otherAppWidgets =\n new ArrayList<LauncherAppWidgetInfo>();\n HashMap<Long, FolderInfo> currentFolders = new HashMap<Long, FolderInfo>();\n HashMap<Long, FolderInfo> otherFolders = new HashMap<Long, FolderInfo>();\n filterCurrentWorkspaceItems(currentScreen, workspaceItems, currentWorkspaceItems,\n otherWorkspaceItems);\n filterCurrentAppWidgets(currentScreen, appWidgets, currentAppWidgets,\n otherAppWidgets);\n filterCurrentFolders(currentScreen, itemsIdMap, folders, currentFolders,\n otherFolders);\n sortWorkspaceItemsSpatially(currentWorkspaceItems);\n sortWorkspaceItemsSpatially(otherWorkspaceItems);\n r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.startBinding();\n }\n }\n };\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n bindWorkspaceScreens(oldCallbacks, orderedScreenIds);\n bindWorkspaceItems(oldCallbacks, currentWorkspaceItems, currentAppWidgets,\n currentFolders, null);\n if (isLoadingSynchronously) {\n r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.onPageBoundSynchronously(currentScreen);\n }\n }\n };\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n mDeferredBindRunnables.clear();\n bindWorkspaceItems(oldCallbacks, otherWorkspaceItems, otherAppWidgets, otherFolders,\n (isLoadingSynchronously ? mDeferredBindRunnables : null));\n r = new Runnable() {\n public void run() {\n Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.finishBindingItems(isUpgradePath);\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"bound workspace in \"\n + (SystemClock.uptimeMillis()-t) + \"ms\");\n }\n mIsLoadingAndBindingWorkspace = false;\n }\n };\n if (isLoadingSynchronously) {\n mDeferredBindRunnables.add(r);\n } else {\n runOnMainThread(r, MAIN_THREAD_BINDING_RUNNABLE);\n }\n }\n private void loadAndBindAllApps() {\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"loadAndBindAllApps mAllAppsLoaded=\" + mAllAppsLoaded);\n }\n if (!mAllAppsLoaded) {\n loadAllApps();\n synchronized (LoaderTask.this) {\n if (mStopped) {\n return;\n }\n mAllAppsLoaded = true;\n }\n } else {\n onlyBindAllApps();\n }\n }\n private void onlyBindAllApps() {\n final Callbacks oldCallbacks = mCallbacks.get();\n if (oldCallbacks == null) {\n Log.w(TAG, \"LoaderTask running with no launcher (onlyBindAllApps)\");\n return;\n }\n @SuppressWarnings(\"unchecked\")\n final ArrayList<ApplicationInfo> list\n = (ArrayList<ApplicationInfo>) mBgAllAppsList.data.clone();\n Runnable r = new Runnable() {\n public void run() {\n final long t = SystemClock.uptimeMillis();\n final Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n if (callbacks != null) {\n callbacks.bindAllApplications(list);\n }\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"bound all \" + list.size() + \" apps from cache in \"\n + (SystemClock.uptimeMillis()-t) + \"ms\");\n }\n }\n };\n boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid());\n if (isRunningOnMainThread) {\n r.run();\n } else {\n mHandler.post(r);\n }\n }\n private void loadAllApps() {\n final long loadTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n final Callbacks oldCallbacks = mCallbacks.get();\n if (oldCallbacks == null) {\n Log.w(TAG, \"LoaderTask running with no launcher (loadAllApps)\");\n return;\n }\n final PackageManager packageManager = mContext.getPackageManager();\n final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);\n mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);\n mBgAllAppsList.clear();\n final long qiaTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0);\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"queryIntentActivities took \"\n + (SystemClock.uptimeMillis()-qiaTime) + \"ms\");\n Log.d(TAG, \"queryIntentActivities got \" + apps.size() + \" apps\");\n }\n if (apps == null || apps.isEmpty()) {\n return;\n }\n final long sortTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n Collections.sort(apps,\n new LauncherModel.ShortcutNameComparator(packageManager, mLabelCache));\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"sort took \"\n + (SystemClock.uptimeMillis()-sortTime) + \"ms\");\n }\n final long addTime = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;\n for (int i = 0; i < apps.size(); i++) {\n mBgAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i),\n mIconCache, mLabelCache));\n }\n final Callbacks callbacks = tryGetCallbacks(oldCallbacks);\n final ArrayList<ApplicationInfo> added = mBgAllAppsList.added;\n mBgAllAppsList.added = new ArrayList<ApplicationInfo>();\n mHandler.post(new Runnable() {\n public void run() {\n final long bindTime = SystemClock.uptimeMillis();\n if (callbacks != null) {\n callbacks.bindAllApplications(added);\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"bound \" + added.size() + \" apps in \"\n + (SystemClock.uptimeMillis() - bindTime) + \"ms\");\n }\n } else {\n Log.i(TAG, \"not binding apps: no Launcher activity\");\n }\n }\n });\n if (DEBUG_LOADERS) {\n Log.d(TAG, \"Icons processed in \"\n + (SystemClock.uptimeMillis() - loadTime) + \"ms\");\n }\n }\n public void dumpState() {\n synchronized (sBgLock) {\n Log.d(TAG, \"mLoaderTask.mContext=\" + mContext);\n Log.d(TAG, \"mLoaderTask.mIsLaunching=\" + mIsLaunching);\n Log.d(TAG, \"mLoaderTask.mStopped=\" + mStopped);\n Log.d(TAG, \"mLoaderTask.mLoadAndBindStepFinished=\" + mLoadAndBindStepFinished);\n Log.d(TAG, \"mItems size=\" + sBgWorkspaceItems.size());\n }\n }\n }\n void enqueuePackageUpdated(PackageUpdatedTask task) {\n sWorker.post(task);\n }\n private class PackageUpdatedTask implements Runnable {\n int mOp;\n String[] mPackages;\n public static final int OP_NONE = 0;\n public static final int OP_ADD = 1;\n public static final int OP_UPDATE = 2;\n public static final int OP_REMOVE = 3; \n public static final int OP_UNAVAILABLE = 4; \n public PackageUpdatedTask(int op, String[] packages) {\n mOp = op;\n mPackages = packages;\n }\n public void run() {\n final Context context = mApp.getContext();\n final String[] packages = mPackages;\n final int N = packages.length;\n switch (mOp) {\n case OP_ADD:\n for (int i=0; i<N; i++) {\n if (DEBUG_LOADERS) Log.d(TAG, \"mAllAppsList.addPackage \" + packages[i]);\n mBgAllAppsList.addPackage(context, packages[i]);\n }\n break;\n case OP_UPDATE:\n for (int i=0; i<N; i++) {\n if (DEBUG_LOADERS) Log.d(TAG, \"mAllAppsList.updatePackage \" + packages[i]);\n mBgAllAppsList.updatePackage(context, packages[i]);\n WidgetPreviewLoader.removeFromDb(\n mApp.getWidgetPreviewCacheDb(), packages[i]);\n }\n break;\n case OP_REMOVE:\n case OP_UNAVAILABLE:\n for (int i=0; i<N; i++) {\n if (DEBUG_LOADERS) Log.d(TAG, \"mAllAppsList.removePackage \" + packages[i]);\n mBgAllAppsList.removePackage(packages[i]);\n WidgetPreviewLoader.removeFromDb(\n mApp.getWidgetPreviewCacheDb(), packages[i]);\n }\n break;\n }\n ArrayList<ApplicationInfo> added = null;\n ArrayList<ApplicationInfo> modified = null;\n final ArrayList<ApplicationInfo> removedApps = new ArrayList<ApplicationInfo>();\n if (mBgAllAppsList.added.size() > 0) {\n added = new ArrayList<ApplicationInfo>(mBgAllAppsList.added);\n mBgAllAppsList.added.clear();\n }\n if (mBgAllAppsList.modified.size() > 0) {\n modified = new ArrayList<ApplicationInfo>(mBgAllAppsList.modified);\n mBgAllAppsList.modified.clear();\n }\n if (mBgAllAppsList.removed.size() > 0) {\n removedApps.addAll(mBgAllAppsList.removed);\n mBgAllAppsList.removed.clear();\n }\n final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == null) {\n Log.w(TAG, \"Nobody to tell about the new app. Launcher is probably loading.\");\n return;\n }\n if (added != null) {\n final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n addAndBindAddedApps(context, addedInfos, cb);\n }\n if (modified != null) {\n final ArrayList<ApplicationInfo> modifiedFinal = modified;\n for (ApplicationInfo a : modifiedFinal) {\n ArrayList<ItemInfo> infos =\n getItemInfoForComponentName(a.componentName);\n for (ItemInfo i : infos) {\n if (isShortcutInfoUpdateable(i)) {\n ShortcutInfo info = (ShortcutInfo) i;\n info.title = a.title.toString();\n updateItemInDatabase(context, info);\n }\n }\n }\n mHandler.post(new Runnable() {\n public void run() {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == cb && cb != null) {\n callbacks.bindAppsUpdated(modifiedFinal);\n }\n }\n });\n }\n if (mOp == OP_REMOVE || !removedApps.isEmpty()) {\n final boolean packageRemoved = (mOp == OP_REMOVE);\n final ArrayList<String> removedPackageNames =\n new ArrayList<String>(Arrays.asList(packages));\n if (packageRemoved) {\n for (String pn : removedPackageNames) {\n ArrayList<ItemInfo> infos = getItemInfoForPackageName(pn);\n for (ItemInfo i : infos) {\n deleteItemFromDatabase(context, i);\n }\n }\n } else {\n for (ApplicationInfo a : removedApps) {\n ArrayList<ItemInfo> infos =\n getItemInfoForComponentName(a.componentName);\n for (ItemInfo i : infos) {\n deleteItemFromDatabase(context, i);\n }\n }\n }\n mHandler.post(new Runnable() {\n public void run() {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == cb && cb != null) {\n callbacks.bindComponentsRemoved(removedPackageNames,\n removedApps, packageRemoved);\n }\n }\n });\n }\n final ArrayList<Object> widgetsAndShortcuts =\n getSortedWidgetsAndShortcuts(context);\n mHandler.post(new Runnable() {\n @Override\n public void run() {\n Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;\n if (callbacks == cb && cb != null) {\n callbacks.bindPackagesUpdated(widgetsAndShortcuts);\n }\n }\n });\n }\n }\n public static ArrayList<Object> getSortedWidgetsAndShortcuts(Context context) {\n PackageManager packageManager = context.getPackageManager();\n final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();\n widgetsAndShortcuts.addAll(AppWidgetManager.getInstance(context).getInstalledProviders());\n Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);\n widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(shortcutsIntent, 0));\n Collections.sort(widgetsAndShortcuts,\n new LauncherModel.WidgetAndShortcutNameComparator(packageManager));\n return widgetsAndShortcuts;\n }\n private boolean isValidPackageComponent(PackageManager pm, ComponentName cn) {\n if (cn == null) {\n return false;\n }\n try {\n return (pm.getActivityInfo(cn, 0) != null);\n } catch (NameNotFoundException e) {\n return false;\n }\n }\n public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context) {\n return getShortcutInfo(manager, intent, context, null, -1, -1, null);\n }\n public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context,\n Cursor c, int iconIndex, int titleIndex, HashMap<Object, CharSequence> labelCache) {\n ComponentName componentName = intent.getComponent();\n final ShortcutInfo info = new ShortcutInfo();\n if (!isValidPackageComponent(manager, componentName)) {\n Log.d(TAG, \"Invalid package found in getShortcutInfo: \" + componentName);\n return null;\n } else {\n try {\n PackageInfo pi = manager.getPackageInfo(componentName.getPackageName(), 0);\n info.initFlagsAndFirstInstallTime(pi);\n } catch (NameNotFoundException e) {\n Log.d(TAG, \"getPackInfo failed for package \" +\n componentName.getPackageName());\n }\n }\n Bitmap icon = null;\n ResolveInfo resolveInfo = null;\n ComponentName oldComponent = intent.getComponent();\n Intent newIntent = new Intent(intent.getAction(), null);\n newIntent.addCategory(Intent.CATEGORY_LAUNCHER);\n newIntent.setPackage(oldComponent.getPackageName());\n List<ResolveInfo> infos = manager.queryIntentActivities(newIntent, 0);\n for (ResolveInfo i : infos) {\n ComponentName cn = new ComponentName(i.activityInfo.packageName,\n i.activityInfo.name);\n if (cn.equals(oldComponent)) {\n resolveInfo = i;\n }\n }\n if (resolveInfo == null) {\n resolveInfo = manager.resolveActivity(intent, 0);\n }\n if (resolveInfo != null) {\n icon = mIconCache.getIcon(componentName, resolveInfo, labelCache);\n }\n if (icon == null) {\n if (c != null) {\n icon = getIconFromCursor(c, iconIndex, context);\n }\n }\n if (icon == null) {\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n }\n info.setIcon(icon);\n if (resolveInfo != null) {\n ComponentName key = LauncherModel.getComponentNameFromResolveInfo(resolveInfo);\n if (labelCache != null && labelCache.containsKey(key)) {\n info.title = labelCache.get(key);\n } else {\n info.title = resolveInfo.activityInfo.loadLabel(manager);\n if (labelCache != null) {\n labelCache.put(key, info.title);\n }\n }\n }\n if (info.title == null) {\n if (c != null) {\n info.title = c.getString(titleIndex);\n }\n }\n if (info.title == null) {\n info.title = componentName.getClassName();\n }\n info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;\n return info;\n }\n static ArrayList<ItemInfo> filterItemInfos(Collection<ItemInfo> infos,\n ItemInfoFilter f) {\n HashSet<ItemInfo> filtered = new HashSet<ItemInfo>();\n for (ItemInfo i : infos) {\n if (i instanceof ShortcutInfo) {\n ShortcutInfo info = (ShortcutInfo) i;\n ComponentName cn = info.intent.getComponent();\n if (cn != null && f.filterItem(null, info, cn)) {\n filtered.add(info);\n }\n } else if (i instanceof FolderInfo) {\n FolderInfo info = (FolderInfo) i;\n for (ShortcutInfo s : info.contents) {\n ComponentName cn = s.intent.getComponent();\n if (cn != null && f.filterItem(info, s, cn)) {\n filtered.add(s);\n }\n }\n } else if (i instanceof LauncherAppWidgetInfo) {\n LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) i;\n ComponentName cn = info.providerName;\n if (cn != null && f.filterItem(null, info, cn)) {\n filtered.add(info);\n }\n }\n }\n return new ArrayList<ItemInfo>(filtered);\n }\n private ArrayList<ItemInfo> getItemInfoForPackageName(final String pn) {\n HashSet<ItemInfo> infos = new HashSet<ItemInfo>();\n ItemInfoFilter filter = new ItemInfoFilter() {\n @Override\n public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {\n return cn.getPackageName().equals(pn);\n }\n };\n return filterItemInfos(sBgItemsIdMap.values(), filter);\n }\n private ArrayList<ItemInfo> getItemInfoForComponentName(final ComponentName cname) {\n HashSet<ItemInfo> infos = new HashSet<ItemInfo>();\n ItemInfoFilter filter = new ItemInfoFilter() {\n @Override\n public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) {\n return cn.equals(cname);\n }\n };\n return filterItemInfos(sBgItemsIdMap.values(), filter);\n }\n public static boolean isShortcutInfoUpdateable(ItemInfo i) {\n if (i instanceof ShortcutInfo) {\n ShortcutInfo info = (ShortcutInfo) i;\n Intent intent = info.intent;\n ComponentName name = intent.getComponent();\n if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&\n Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {\n return true;\n }\n }\n return false;\n }\n private ShortcutInfo getShortcutInfo(Cursor c, Context context,\n int iconTypeIndex, int iconPackageIndex, int iconResourceIndex, int iconIndex,\n int titleIndex) {\n Bitmap icon = null;\n final ShortcutInfo info = new ShortcutInfo();\n info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;\n info.title = c.getString(titleIndex);\n int iconType = c.getInt(iconTypeIndex);\n switch (iconType) {\n case LauncherSettings.Favorites.ICON_TYPE_RESOURCE:\n String packageName = c.getString(iconPackageIndex);\n String resourceName = c.getString(iconResourceIndex);\n PackageManager packageManager = context.getPackageManager();\n info.customIcon = false;\n try {\n Resources resources = packageManager.getResourcesForApplication(packageName);\n if (resources != null) {\n final int id = resources.getIdentifier(resourceName, null, null);\n icon = Utilities.createIconBitmap(\n mIconCache.getFullResIcon(resources, id), context);\n }\n } catch (Exception e) {\n }\n if (icon == null) {\n icon = getIconFromCursor(c, iconIndex, context);\n }\n if (icon == null) {\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n }\n break;\n case LauncherSettings.Favorites.ICON_TYPE_BITMAP:\n icon = getIconFromCursor(c, iconIndex, context);\n if (icon == null) {\n icon = getFallbackIcon();\n info.customIcon = false;\n info.usingFallbackIcon = true;\n } else {\n info.customIcon = true;\n }\n break;\n default:\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n info.customIcon = false;\n break;\n }\n info.setIcon(icon);\n return info;\n }\n Bitmap getIconFromCursor(Cursor c, int iconIndex, Context context) {\n @SuppressWarnings(\"all\") \n final boolean debug = false;\n if (debug) {\n Log.d(TAG, \"getIconFromCursor app=\"\n + c.getString(c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE)));\n }\n byte[] data = c.getBlob(iconIndex);\n try {\n return Utilities.createIconBitmap(\n BitmapFactory.decodeByteArray(data, 0, data.length), context);\n } catch (Exception e) {\n return null;\n }\n }\n ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,\n int cellX, int cellY, boolean notify) {\n final ShortcutInfo info = infoFromShortcutIntent(context, data, null);\n if (info == null) {\n return null;\n }\n addItemToDatabase(context, info, container, screen, cellX, cellY, notify);\n return info;\n }\n AppWidgetProviderInfo findAppWidgetProviderInfoWithComponent(Context context,\n ComponentName component) {\n List<AppWidgetProviderInfo> widgets =\n AppWidgetManager.getInstance(context).getInstalledProviders();\n for (AppWidgetProviderInfo info : widgets) {\n if (info.provider.equals(component)) {\n return info;\n }\n }\n return null;\n }\n List<WidgetMimeTypeHandlerData> resolveWidgetsForMimeType(Context context, String mimeType) {\n final PackageManager packageManager = context.getPackageManager();\n final List<WidgetMimeTypeHandlerData> supportedConfigurationActivities =\n new ArrayList<WidgetMimeTypeHandlerData>();\n final Intent supportsIntent =\n new Intent(InstallWidgetReceiver.ACTION_SUPPORTS_CLIPDATA_MIMETYPE);\n supportsIntent.setType(mimeType);\n final List<AppWidgetProviderInfo> widgets =\n AppWidgetManager.getInstance(context).getInstalledProviders();\n final HashMap<ComponentName, AppWidgetProviderInfo> configurationComponentToWidget =\n new HashMap<ComponentName, AppWidgetProviderInfo>();\n for (AppWidgetProviderInfo info : widgets) {\n configurationComponentToWidget.put(info.configure, info);\n }\n final List<ResolveInfo> activities = packageManager.queryIntentActivities(supportsIntent,\n PackageManager.MATCH_DEFAULT_ONLY);\n for (ResolveInfo info : activities) {\n final ActivityInfo activityInfo = info.activityInfo;\n final ComponentName infoComponent = new ComponentName(activityInfo.packageName,\n activityInfo.name);\n if (configurationComponentToWidget.containsKey(infoComponent)) {\n supportedConfigurationActivities.add(\n new InstallWidgetReceiver.WidgetMimeTypeHandlerData(info,\n configurationComponentToWidget.get(infoComponent)));\n }\n }\n return supportedConfigurationActivities;\n }\n ShortcutInfo infoFromShortcutIntent(Context context, Intent data, Bitmap fallbackIcon) {\n Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);\n String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);\n Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);\n if (intent == null) {\n Log.e(TAG, \"Can't construct ShorcutInfo with null intent\");\n return null;\n }\n Bitmap icon = null;\n boolean customIcon = false;\n ShortcutIconResource iconResource = null;\n if (bitmap != null && bitmap instanceof Bitmap) {\n icon = Utilities.createIconBitmap(new FastBitmapDrawable((Bitmap)bitmap), context);\n customIcon = true;\n } else {\n Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);\n if (extra != null && extra instanceof ShortcutIconResource) {\n try {\n iconResource = (ShortcutIconResource) extra;\n final PackageManager packageManager = context.getPackageManager();\n Resources resources = packageManager.getResourcesForApplication(\n iconResource.packageName);\n final int id = resources.getIdentifier(iconResource.resourceName, null, null);\n icon = Utilities.createIconBitmap(\n mIconCache.getFullResIcon(resources, id), context);\n } catch (Exception e) {\n Log.w(TAG, \"Could not load shortcut icon: \" + extra);\n }\n }\n }\n final ShortcutInfo info = new ShortcutInfo();\n if (icon == null) {\n if (fallbackIcon != null) {\n icon = fallbackIcon;\n } else {\n icon = getFallbackIcon();\n info.usingFallbackIcon = true;\n }\n }\n info.setIcon(icon);\n info.title = name;\n info.intent = intent;\n info.customIcon = customIcon;\n info.iconResource = iconResource;\n return info;\n }\n boolean queueIconToBeChecked(HashMap<Object, byte[]> cache, ShortcutInfo info, Cursor c,\n int iconIndex) {\n if (!mAppsCanBeOnRemoveableStorage) {\n return false;\n }\n if (!info.customIcon && !info.usingFallbackIcon) {\n cache.put(info, c.getBlob(iconIndex));\n return true;\n }\n return false;\n }\n void updateSavedIcon(Context context, ShortcutInfo info, byte[] data) {\n boolean needSave = false;\n try {\n if (data != null) {\n Bitmap saved = BitmapFactory.decodeByteArray(data, 0, data.length);\n Bitmap loaded = info.getIcon(mIconCache);\n needSave = !saved.sameAs(loaded);\n } else {\n needSave = true;\n }\n } catch (Exception e) {\n needSave = true;\n }\n if (needSave) {\n Log.d(TAG, \"going to save icon bitmap for info=\" + info);\n updateItemInDatabase(context, info);\n }\n }\n private static FolderInfo findOrMakeFolder(HashMap<Long, FolderInfo> folders, long id) {\n FolderInfo folderInfo = folders.get(id);\n if (folderInfo == null) {\n folderInfo = new FolderInfo();\n folders.put(id, folderInfo);\n }\n return folderInfo;\n }\n public static final Comparator<ApplicationInfo> getAppNameComparator() {\n final Collator collator = Collator.getInstance();\n return new Comparator<ApplicationInfo>() {\n public final int compare(ApplicationInfo a, ApplicationInfo b) {\n int result = collator.compare(a.title.toString(), b.title.toString());\n if (result == 0) {\n result = a.componentName.compareTo(b.componentName);\n }\n return result;\n }\n };\n }\n public static final Comparator<ApplicationInfo> APP_INSTALL_TIME_COMPARATOR\n = new Comparator<ApplicationInfo>() {\n public final int compare(ApplicationInfo a, ApplicationInfo b) {\n if (a.firstInstallTime < b.firstInstallTime) return 1;\n if (a.firstInstallTime > b.firstInstallTime) return -1;\n return 0;\n }\n };\n public static final Comparator<AppWidgetProviderInfo> getWidgetNameComparator() {\n final Collator collator = Collator.getInstance();\n return new Comparator<AppWidgetProviderInfo>() {\n public final int compare(AppWidgetProviderInfo a, AppWidgetProviderInfo b) {\n return collator.compare(a.label.toString(), b.label.toString());\n }\n };\n }\n static ComponentName getComponentNameFromResolveInfo(ResolveInfo info) {\n if (info.activityInfo != null) {\n return new ComponentName(info.activityInfo.packageName, info.activityInfo.name);\n } else {\n return new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name);\n }\n }\n public static class ShortcutNameComparator implements Comparator<ResolveInfo> {\n private Collator mCollator;\n private PackageManager mPackageManager;\n private HashMap<Object, CharSequence> mLabelCache;\n ShortcutNameComparator(PackageManager pm) {\n mPackageManager = pm;\n mLabelCache = new HashMap<Object, CharSequence>();\n mCollator = Collator.getInstance();\n }\n ShortcutNameComparator(PackageManager pm, HashMap<Object, CharSequence> labelCache) {\n mPackageManager = pm;\n mLabelCache = labelCache;\n mCollator = Collator.getInstance();\n }\n public final int compare(ResolveInfo a, ResolveInfo b) {\n CharSequence labelA, labelB;\n ComponentName keyA = LauncherModel.getComponentNameFromResolveInfo(a);\n ComponentName keyB = LauncherModel.getComponentNameFromResolveInfo(b);\n if (mLabelCache.containsKey(keyA)) {\n labelA = mLabelCache.get(keyA);\n } else {\n labelA = a.loadLabel(mPackageManager).toString();\n mLabelCache.put(keyA, labelA);\n }\n if (mLabelCache.containsKey(keyB)) {\n labelB = mLabelCache.get(keyB);\n } else {\n labelB = b.loadLabel(mPackageManager).toString();\n mLabelCache.put(keyB, labelB);\n }\n return mCollator.compare(labelA, labelB);\n }\n };\n public static class WidgetAndShortcutNameComparator implements Comparator<Object> {\n private Collator mCollator;\n private PackageManager mPackageManager;\n private HashMap<Object, String> mLabelCache;\n WidgetAndShortcutNameComparator(PackageManager pm) {\n mPackageManager = pm;\n mLabelCache = new HashMap<Object, String>();\n mCollator = Collator.getInstance();\n }\n public final int compare(Object a, Object b) {\n String labelA, labelB;\n if (mLabelCache.containsKey(a)) {\n labelA = mLabelCache.get(a);\n } else {\n labelA = (a instanceof AppWidgetProviderInfo) ?\n ((AppWidgetProviderInfo) a).label :\n ((ResolveInfo) a).loadLabel(mPackageManager).toString();\n mLabelCache.put(a, labelA);\n }\n if (mLabelCache.containsKey(b)) {\n labelB = mLabelCache.get(b);\n } else {\n labelB = (b instanceof AppWidgetProviderInfo) ?\n ((AppWidgetProviderInfo) b).label :\n ((ResolveInfo) b).loadLabel(mPackageManager).toString();\n mLabelCache.put(b, labelB);\n }\n return mCollator.compare(labelA, labelB);\n }\n };\n public void dumpState() {\n Log.d(TAG, \"mCallbacks=\" + mCallbacks);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.data\", mBgAllAppsList.data);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.added\", mBgAllAppsList.added);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.removed\", mBgAllAppsList.removed);\n ApplicationInfo.dumpApplicationInfoList(TAG, \"mAllAppsList.modified\", mBgAllAppsList.modified);\n if (mLoaderTask != null) {\n mLoaderTask.dumpState();\n } else {\n Log.d(TAG, \"mLoaderTask=null\");\n }\n }\n}\n"} {"input": "\tpublic static void main(String... args) {\n\t\tParams params = new Params();\n\t\tJCommander jc = new JCommander(params);\n\t\ttry {\n\t\t\tjc.parse(args);\n\t\t} catch (ParameterException t) {\n\t\t\tusage(jc, t);\n\t\t}\n\t\tFile sourceFolder = new File(params.sourceFolder);\n\t\tFile destinationFolder = new File(params.outputFolder);\n\t\tFile[] markdownFiles = sourceFolder.listFiles(new FilenameFilter() {\n\t\t\t@Override\n\t\t\tpublic boolean accept(File dir, String name) {\n\t\t\t\treturn name.toLowerCase().endsWith(\".mkd\");\n\t\t\t}\n\t\t});\n\t\tArrays.sort(markdownFiles);\n\t\tMap<String, String> aliasMap = new HashMap<String, String>();\n\t\tfor (String alias : params.aliases) {\n\t\t\tString[] values = alias.split(\"=\");\n\t\t\taliasMap.put(values[0], values[1]);\n\t\t}\n\t\tSystem.out.println(MessageFormat.format(\"Generating site from {0} Markdown Docs in {1} \",\n\t\t\t\tmarkdownFiles.length, sourceFolder.getAbsolutePath()));\n\t\tString linkPattern = \"<a href=''{0}''>{1}</a>\";\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (File file : markdownFiles) {\n\t\t\tString documentName = getDocumentName(file);\n\t\t\tif (!params.skips.contains(documentName)) {\n\t\t\t\tString displayName = documentName;\n\t\t\t\tif (aliasMap.containsKey(documentName)) {\n\t\t\t\t\tdisplayName = aliasMap.get(documentName);\n\t\t\t\t}\n\t\t\t\tString fileName = documentName + \".html\";\n\t\t\t\tsb.append(MessageFormat.format(linkPattern, fileName, displayName));\n\t\t\t\tsb.append(\" | \");\n\t\t\t}\n\t\t}\n\t\tsb.setLength(sb.length() - 3);\n\t\tsb.trimToSize();\n\t\tString htmlHeader = FileUtils.readContent(new File(params.pageHeader), \"\\n\");\n\t\tString htmlAdSnippet = null;\n\t\tif (!StringUtils.isEmpty(params.adSnippet)) {\n\t\t\tFile snippet = new File(params.adSnippet);\n\t\t\tif (snippet.exists()) {\n\t\t\t\thtmlAdSnippet = FileUtils.readContent(snippet, \"\\n\");\n\t\t\t}\n\t\t}\n\t\tString htmlFooter = FileUtils.readContent(new File(params.pageFooter), \"\\n\");\n\t\tString links = sb.toString();\n\t\tString header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links);\n\t\tif (!StringUtils.isEmpty(params.analyticsSnippet)) {\n\t\t\tFile snippet = new File(params.analyticsSnippet);\n\t\t\tif (snippet.exists()) {\n\t\t\t\tString htmlSnippet = FileUtils.readContent(snippet, \"\\n\");\n\t\t\t\theader = header.replace(\"<!-- ANALYTICS -->\", htmlSnippet);\n\t\t\t}\n\t\t}\n\t\tfinal String date = new SimpleDateFormat(\"yyyy-MM-dd\").format(new Date());\n\t\tfinal String footer = MessageFormat.format(htmlFooter, \"generated \" + date);\n\t\tfor (File file : markdownFiles) {\n\t\t\ttry {\n\t\t\t\tString documentName = getDocumentName(file);\n\t\t\t\tif (!params.skips.contains(documentName)) {\n\t\t\t\t\tString fileName = documentName + \".html\";\n\t\t\t\t\tSystem.out.println(MessageFormat.format(\" {0} => {1}\", file.getName(),\n\t\t\t\t\t\t\tfileName));\n\t\t\t\t\tInputStreamReader reader = new InputStreamReader(new FileInputStream(file),\n\t\t\t\t\t\t\tCharset.forName(\"UTF-8\"));\n\t\t\t\t\tString content = MarkdownUtils.transformMarkdown(reader);\n\t\t\t\t\tfor (String token : params.substitutions) {\n\t\t\t\t\t\tString[] kv = token.split(\"=\");\n\t\t\t\t\t\tcontent = content.replace(kv[0], kv[1]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (String alias : params.properties) {\n\t\t\t\t\t\tString[] kv = alias.split(\"=\");\n\t\t\t\t\t\tString loadedContent = generatePropertiesContent(new File(kv[1]));\n\t\t\t\t\t\tcontent = content.replace(kv[0], loadedContent);\n\t\t\t\t\t}\n\t\t\t\t\tfor (String alias : params.loads) {\n\t\t\t\t\t\tString[] kv = alias.split(\"=\");\n\t\t\t\t\t\tString loadedContent = FileUtils.readContent(new File(kv[1]), \"\\n\");\n\t\t\t\t\t\tloadedContent = StringUtils.escapeForHtml(loadedContent, false);\n\t\t\t\t\t\tloadedContent = StringUtils.breakLinesForHtml(loadedContent);\n\t\t\t\t\t\tcontent = content.replace(kv[0], loadedContent);\n\t\t\t\t\t}\n\t\t\t\t\tOutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(\n\t\t\t\t\t\t\tnew File(destinationFolder, fileName)), Charset.forName(\"UTF-8\"));\n\t\t\t\t\twriter.write(header);\n\t\t\t\t\tif (!StringUtils.isEmpty(htmlAdSnippet)) {\n\t\t\t\t\t\twriter.write(htmlAdSnippet);\n\t\t\t\t\t}\n\t\t\t\t\twriter.write(content);\n\t\t\t\t\twriter.write(footer);\n\t\t\t\t\treader.close();\n\t\t\t\t\twriter.close();\n\t\t\t\t}\n\t\t\t} catch (Throwable t) {\n\t\t\t\tSystem.err.println(\"Failed to transform \" + file.getName());\n\t\t\t\tt.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic static void main(String... args) {\n\t\tParams params = new Params();\n\t\tJCommander jc = new JCommander(params);\n\t\ttry {\n\t\t\tjc.parse(args);\n\t\t} catch (ParameterException t) {\n\t\t\tusage(jc, t);\n\t\t}\n\t\tFile sourceFolder = new File(params.sourceFolder);\n\t\tFile destinationFolder = new File(params.outputFolder);\n\t\tFile[] markdownFiles = sourceFolder.listFiles(new FilenameFilter() {\n\t\t\t@Override\n\t\t\tpublic boolean accept(File dir, String name) {\n\t\t\t\treturn name.toLowerCase().endsWith(\".mkd\");\n\t\t\t}\n\t\t});\n\t\tArrays.sort(markdownFiles);\n\t\tMap<String, String> aliasMap = new HashMap<String, String>();\n\t\tfor (String alias : params.aliases) {\n\t\t\tString[] values = alias.split(\"=\");\n\t\t\taliasMap.put(values[0], values[1]);\n\t\t}\n\t\tSystem.out.println(MessageFormat.format(\"Generating site from {0} Markdown Docs in {1} \",\n\t\t\t\tmarkdownFiles.length, sourceFolder.getAbsolutePath()));\n\t\tString linkPattern = \"<a href=''{0}''>{1}</a>\";\n\t\tStringBuilder sb = new StringBuilder();\n\t\tfor (File file : markdownFiles) {\n\t\t\tString documentName = getDocumentName(file);\n\t\t\tif (!params.skips.contains(documentName)) {\n\t\t\t\tString displayName = documentName;\n\t\t\t\tif (aliasMap.containsKey(documentName)) {\n\t\t\t\t\tdisplayName = aliasMap.get(documentName);\n\t\t\t\t} else {\n\t\t\t\t\tdisplayName = displayName.replace('_', ' ');\n\t\t\t\t}\n\t\t\t\tString fileName = documentName + \".html\";\n\t\t\t\tsb.append(MessageFormat.format(linkPattern, fileName, displayName));\n\t\t\t\tsb.append(\" | \");\n\t\t\t}\n\t\t}\n\t\tsb.setLength(sb.length() - 3);\n\t\tsb.trimToSize();\n\t\tString htmlHeader = FileUtils.readContent(new File(params.pageHeader), \"\\n\");\n\t\tString htmlAdSnippet = null;\n\t\tif (!StringUtils.isEmpty(params.adSnippet)) {\n\t\t\tFile snippet = new File(params.adSnippet);\n\t\t\tif (snippet.exists()) {\n\t\t\t\thtmlAdSnippet = FileUtils.readContent(snippet, \"\\n\");\n\t\t\t}\n\t\t}\n\t\tString htmlFooter = FileUtils.readContent(new File(params.pageFooter), \"\\n\");\n\t\tString links = sb.toString();\n\t\tString header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links);\n\t\tif (!StringUtils.isEmpty(params.analyticsSnippet)) {\n\t\t\tFile snippet = new File(params.analyticsSnippet);\n\t\t\tif (snippet.exists()) {\n\t\t\t\tString htmlSnippet = FileUtils.readContent(snippet, \"\\n\");\n\t\t\t\theader = header.replace(\"<!-- ANALYTICS -->\", htmlSnippet);\n\t\t\t}\n\t\t}\n\t\tfinal String date = new SimpleDateFormat(\"yyyy-MM-dd\").format(new Date());\n\t\tfinal String footer = MessageFormat.format(htmlFooter, \"generated \" + date);\n\t\tfor (File file : markdownFiles) {\n\t\t\ttry {\n\t\t\t\tString documentName = getDocumentName(file);\n\t\t\t\tif (!params.skips.contains(documentName)) {\n\t\t\t\t\tString fileName = documentName + \".html\";\n\t\t\t\t\tSystem.out.println(MessageFormat.format(\" {0} => {1}\", file.getName(),\n\t\t\t\t\t\t\tfileName));\n\t\t\t\t\tInputStreamReader reader = new InputStreamReader(new FileInputStream(file),\n\t\t\t\t\t\t\tCharset.forName(\"UTF-8\"));\n\t\t\t\t\tString content = MarkdownUtils.transformMarkdown(reader);\n\t\t\t\t\tfor (String token : params.substitutions) {\n\t\t\t\t\t\tString[] kv = token.split(\"=\");\n\t\t\t\t\t\tcontent = content.replace(kv[0], kv[1]);\n\t\t\t\t\t}\n\t\t\t\t\tfor (String alias : params.properties) {\n\t\t\t\t\t\tString[] kv = alias.split(\"=\");\n\t\t\t\t\t\tString loadedContent = generatePropertiesContent(new File(kv[1]));\n\t\t\t\t\t\tcontent = content.replace(kv[0], loadedContent);\n\t\t\t\t\t}\n\t\t\t\t\tfor (String alias : params.loads) {\n\t\t\t\t\t\tString[] kv = alias.split(\"=\");\n\t\t\t\t\t\tString loadedContent = FileUtils.readContent(new File(kv[1]), \"\\n\");\n\t\t\t\t\t\tloadedContent = StringUtils.escapeForHtml(loadedContent, false);\n\t\t\t\t\t\tloadedContent = StringUtils.breakLinesForHtml(loadedContent);\n\t\t\t\t\t\tcontent = content.replace(kv[0], loadedContent);\n\t\t\t\t\t}\n\t\t\t\t\tOutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(\n\t\t\t\t\t\t\tnew File(destinationFolder, fileName)), Charset.forName(\"UTF-8\"));\n\t\t\t\t\twriter.write(header);\n\t\t\t\t\tif (!StringUtils.isEmpty(htmlAdSnippet)) {\n\t\t\t\t\t\twriter.write(htmlAdSnippet);\n\t\t\t\t\t}\n\t\t\t\t\twriter.write(content);\n\t\t\t\t\twriter.write(footer);\n\t\t\t\t\treader.close();\n\t\t\t\t\twriter.close();\n\t\t\t\t}\n\t\t\t} catch (Throwable t) {\n\t\t\t\tSystem.err.println(\"Failed to transform \" + file.getName());\n\t\t\t\tt.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public void doResponse(Properties conProp, httpHeader requestHeader, OutputStream out, InputStream body) {\n this.connectionProperties = conProp;\n String path = null;\n try {\n String method = conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD);\n path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);\n String argsString = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS); \n String httpVersion= conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);\n if (path.indexOf(\"..\") >= 0) {\n httpd.sendRespondError(conProp,out,4,403,null,\"Access not allowed\",null);\n return;\n }\n try {\n path = URLDecoder.decode(path, \"UTF-8\");\n } catch (UnsupportedEncodingException e) {\n assert(false) : \"UnsupportedEncodingException: \" + e.getMessage();\n }\n String authorization = (String) requestHeader.get(httpHeader.AUTHORIZATION);\n String adminAccountBase64MD5 = switchboard.getConfig(\"adminAccountBase64MD5\", \"\");\n int pos = path.lastIndexOf(\".\");\n if ((path.substring(0,(pos==-1)?path.length():pos)).endsWith(\"_p\") && (adminAccountBase64MD5.length() != 0)) {\n if(sb.userDB.hasAdminRight(authorization, conProp.getProperty(\"CLIENTIP\"), requestHeader.getHeaderCookies())){\n serverCore.bfHost.remove(conProp.getProperty(\"CLIENTIP\"));\n }else if(authorization != null && sb.staticAdminAuthenticated(authorization.trim().substring(6))==4){\n serverCore.bfHost.remove(conProp.getProperty(\"CLIENTIP\"));\n }else if (authorization == null) {\n httpHeader headers = getDefaultHeaders(path);\n headers.put(httpHeader.WWW_AUTHENTICATE,\"Basic realm=\\\"admin log-in\\\"\");\n servletProperties tp=new servletProperties();\n tp.put(\"returnto\", path);\n httpd.sendRespondError(conProp, out, 5, 401, \"Wrong Authentication\", \"\", new File(\"proxymsg/authfail.inc\"), tp, null, headers);\n return;\n } else {\n String clientIP = conProp.getProperty(\"CLIENTIP\", \"unknown-host\");\n serverLog.logInfo(\"HTTPD\", \"Wrong log-in for account 'admin' in http file handler for path '\" + path + \"' from host '\" + clientIP + \"'\");\n Integer attempts = (Integer) serverCore.bfHost.get(clientIP);\n if (attempts == null)\n serverCore.bfHost.put(clientIP, new Integer(1));\n else\n serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));\n httpHeader headers = getDefaultHeaders(path);\n headers.put(httpHeader.WWW_AUTHENTICATE,\"Basic realm=\\\"admin log-in\\\"\");\n httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);\n return;\n }\n }\n serverObjects args = new serverObjects();\n int argc;\n if (argsString == null) {\n int length = 0;\n if (method.equals(httpHeader.METHOD_POST)) {\n GZIPInputStream gzipBody = null;\n if (requestHeader.containsKey(httpHeader.CONTENT_LENGTH)) {\n length = Integer.parseInt((String) requestHeader.get(httpHeader.CONTENT_LENGTH));\n } else if (requestHeader.gzip()) {\n length = -1;\n gzipBody = new GZIPInputStream(body);\n }\n if ((requestHeader.containsKey(httpHeader.CONTENT_TYPE)) &&\n (((String) requestHeader.get(httpHeader.CONTENT_TYPE)).toLowerCase().startsWith(\"multipart\"))) {\n HashMap files = httpd.parseMultipart(requestHeader, args, (gzipBody!=null)?gzipBody:body, length);\n if (files != null) {\n Iterator fit = files.entrySet().iterator();\n Map.Entry entry;\n while (fit.hasNext()) {\n entry = (Map.Entry) fit.next();\n args.put(((String) entry.getKey()) + \"$file\", entry.getValue());\n }\n }\n argc = Integer.parseInt((String) requestHeader.get(\"ARGC\"));\n } else {\n argc = httpd.parseArgs(args, (gzipBody!=null)?gzipBody:body, length);\n }\n } else {\n argsString = null;\n args = null;\n argc = 0;\n }\n } else {\n argc = httpd.parseArgs(args, argsString);\n }\n if (argc > 0) {\n Enumeration e = args.elements(); \n Object val;\n while (e.hasMoreElements()) {\n val = e.nextElement();\n if ((val != null) && (val instanceof String) && (((String) val).indexOf(\"<script\") >= 0)) {\n httpd.sendRespondError(conProp,out,4,403,null,\"bad post values\",null);\n return;\n }\n }\n }\n if (path.length() == 0) {\n httpd.sendRespondError(conProp,out,4,400,null,\"Bad Request\",null);\n out.flush();\n return;\n }\n File targetClass=null;\n if (!(path.startsWith(\"/\"))) path = \"/\" + path; \n String localeSelection = switchboard.getConfig(\"htLocaleSelection\",\"default\");\n if (args != null && (args.containsKey(\"language\"))) \n {\n localeSelection = args.get(\"language\", localeSelection);\n if (localeSelection.indexOf(\".\") != -1)\n localeSelection = localeSelection.substring(0, localeSelection.indexOf(\".\"));\n }\n File targetFile = getLocalizedFile(path, localeSelection);\n String targetExt = conProp.getProperty(\"EXT\",\"\");\n targetClass = rewriteClassFile(new File(htDefaultPath, path));\n if (path.endsWith(\"/\")) {\n String testpath;\n for (int i = 0; i < defaultFiles.length; i++) {\n testpath = path + defaultFiles[i];\n targetFile = getOverlayedFile(testpath);\n targetClass=getOverlayedClass(testpath);\n if (targetFile.exists()) {\n path = testpath;\n break;\n }\n }\n if(targetFile == null || !targetFile.exists()){\n \tString dirlistFormat = (args==null)?\"html\":args.get(\"format\",\"html\");\n targetFile = getOverlayedFile(\"/htdocsdefault/dir.\" + dirlistFormat);\n targetClass=getOverlayedClass(\"/htdocsdefault/dir.\" + dirlistFormat);\n if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){\n httpd.sendRespondError(this.connectionProperties,out,3,500,\"dir.\" + dirlistFormat + \" or dir.class not found.\",null,null);\n }\n }\n }else{\n if ( !(targetFile.exists()) && !((path.endsWith(\"png\")||path.endsWith(\"gif\")||path.endsWith(\".stream\"))&&targetClass!=null ) ){\n targetFile = new File(htDocsPath, path);\n targetClass = rewriteClassFile(new File(htDocsPath, path));\n }\n }\n servletProperties tp = new servletProperties();\n Date targetDate;\n boolean nocache = false;\n if ((targetClass != null) && (path.endsWith(\"png\"))) {\n Object img = null;\n try {\n requestHeader.put(\"CLIENTIP\", conProp.getProperty(\"CLIENTIP\"));\n requestHeader.put(\"PATH\", path);\n img = invokeServlet(targetClass, requestHeader, args);\n } catch (InvocationTargetException e) {\n this.theLogger.logSevere(\"INTERNAL ERROR: \" + e.toString() + \":\" +\n e.getMessage() +\n \" target exception at \" + targetClass + \": \" +\n e.getTargetException().toString() + \":\" +\n e.getTargetException().getMessage() +\n \"; java.awt.graphicsenv='\" + System.getProperty(\"java.awt.graphicsenv\",\"\") + \"'\",e);\n targetClass = null;\n }\n if (img == null) {\n httpd.sendRespondError(this.connectionProperties,out,3,404,\"File not Found\",null,null);\n } else {\n if (img instanceof ymageMatrix) {\n ymageMatrix yp = (ymageMatrix) img;\n targetDate = new Date(System.currentTimeMillis());\n nocache = true;\n String mimeType = mimeTable.getProperty(targetExt, \"text/html\");\n serverByteBuffer baos = new serverByteBuffer();\n ImageIO.write(yp.getImage(), targetExt, baos);\n byte[] result = baos.toByteArray();\n baos.close();\n baos = null;\n httpd.sendRespondHeader(this.connectionProperties, out,\n httpVersion, 200, null, mimeType,\n result.length, targetDate, null, null, null,\n null, nocache);\n if (!method.equals(httpHeader.METHOD_HEAD)) {\n Thread.sleep(200); \n serverFileUtils.write(result, out);\n }\n }\n if (img instanceof Image) {\n Image i = (Image) img;\n targetDate = new Date(System.currentTimeMillis());\n nocache = true;\n String mimeType = mimeTable.getProperty(targetExt, \"text/html\");\n int width = i.getWidth(null); if (width < 0) width = 96; \n int height = i.getHeight(null); if (height < 0) height = 96; \n BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\n bi.createGraphics().drawImage(i, 0, 0, width, height, null); \n serverByteBuffer baos = new serverByteBuffer();\n ImageIO.write(bi, targetExt, baos);\n byte[] result = baos.toByteArray();\n baos.close();\n baos = null;\n httpd.sendRespondHeader(this.connectionProperties, out,\n httpVersion, 200, null, mimeType,\n result.length, targetDate, null, null, null,\n null, nocache);\n if (!method.equals(httpHeader.METHOD_HEAD)) {\n Thread.sleep(200); \n serverFileUtils.write(result, out);\n }\n }\n }\n } else if ((targetClass != null) && (path.endsWith(\".stream\"))) {\n requestHeader.put(\"CLIENTIP\", conProp.getProperty(\"CLIENTIP\"));\n requestHeader.put(\"PATH\", path);\n requestHeader.put(\"INPUTSTREAM\", body);\n requestHeader.put(\"OUTPUTSTREAM\", out);\n httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null); \n invokeServlet(targetClass, requestHeader, args);\n this.forceConnectionClose();\n return; \n } else if ((targetFile.exists()) && (targetFile.canRead())) {\n String mimeType = mimeTable.getProperty(targetExt,\"text/html\");\n byte[] result;\n boolean zipContent = requestHeader.acceptGzip() && httpd.shallTransportZipped(\".\" + conProp.getProperty(\"EXT\",\"\"));\n if (path.endsWith(\"html\") || \n path.endsWith(\"xml\") || \n path.endsWith(\"rss\") || \n path.endsWith(\"csv\") ||\n path.endsWith(\"pac\") ||\n path.endsWith(\"src\") ||\n path.endsWith(\"/\")) {\n if (targetClass == null) {\n targetDate = new Date(targetFile.lastModified());\n } else {\n try {\n requestHeader.put(\"CLIENTIP\", conProp.getProperty(\"CLIENTIP\"));\n requestHeader.put(\"PATH\", path);\n Object tmp = invokeServlet(targetClass, requestHeader, args); \n if(tmp instanceof serverObjects){\n tp=new servletProperties((serverObjects)tmp);\n }else{\n tp=(servletProperties)tmp;\n }\n if (tp == null) tp = new servletProperties();\n if (tp.containsKey(\"AUTHENTICATE\")) {\n if (authorization != null) {\n String clientIP = conProp.getProperty(\"CLIENTIP\", \"unknown-host\");\n serverLog.logInfo(\"HTTPD\", \"dynamic log-in for account 'admin' in http file handler for path '\" + path + \"' from host '\" + clientIP + \"'\");\n Integer attempts = (Integer) serverCore.bfHost.get(clientIP);\n if (attempts == null)\n serverCore.bfHost.put(clientIP, new Integer(1));\n else\n serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));\n }\n httpHeader headers = getDefaultHeaders(path);\n headers.put(httpHeader.WWW_AUTHENTICATE,\"Basic realm=\\\"\" + tp.get(\"AUTHENTICATE\", \"\") + \"\\\"\");\n httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);\n return;\n } else if (tp.containsKey(\"LOCATION\")) {\n String location = tp.get(\"LOCATION\",\"\");\n if (location.length() == 0) location = path;\n httpHeader headers = getDefaultHeaders(path);\n headers.setCookieVector(tp.getOutgoingHeader().getCookieVector()); \n headers.put(httpHeader.LOCATION,location);\n httpd.sendRespondHeader(conProp,out,httpVersion,302,headers);\n return;\n }\n tp.put(\"version\", switchboard.getConfig(\"version\", \"\"));\n tp.put(\"uptime\", ((System.currentTimeMillis() - Long.parseLong(switchboard.getConfig(\"startupTime\",\"0\"))) / 1000) / 60); \n tp.put(\"clientname\", switchboard.getConfig(\"peerName\", \"anomic\"));\n } catch (InvocationTargetException e) {\n if (e.getCause() instanceof InterruptedException) {\n throw new InterruptedException(e.getCause().getMessage());\n } \n this.theLogger.logSevere(\"INTERNAL ERROR: \" + e.toString() + \":\" +\n e.getMessage() +\n \" target exception at \" + targetClass + \": \" +\n e.getTargetException().toString() + \":\" +\n e.getTargetException().getMessage(),e);\n targetClass = null;\n throw e;\n }\n targetDate = new Date(System.currentTimeMillis());\n nocache = true;\n }\n tp.putAll(templates);\n serverByteBuffer o = null;\n InputStream fis = null;\n GZIPOutputStream zippedOut = null;\n try {\n byte[] templateContent = null;\n if (useTemplateCache) {\n long fileSize = targetFile.length();\n if (fileSize <= 512*1024) {\n SoftReference ref = (SoftReference) templateCache.get(targetFile);\n if (ref != null) {\n templateContent = (byte[]) ref.get();\n if (templateContent == null) \n templateCache.remove(targetFile); \n }\n if (templateContent == null) {\n templateContent = serverFileUtils.read(targetFile);\n ref = new SoftReference(templateContent);\n templateCache.put(targetFile,ref);\n if (this.theLogger.isLoggable(Level.FINEST))\n this.theLogger.logFinest(\"Cache MISS for file \" + targetFile);\n } else {\n if (this.theLogger.isLoggable(Level.FINEST))\n this.theLogger.logFinest(\"Cache HIT for file \" + targetFile);\n }\n fis = new ByteArrayInputStream(templateContent); \n templateContent = null;\n } else {\n fis = new BufferedInputStream(new FileInputStream(targetFile));\n }\n } else {\n fis = new BufferedInputStream(new FileInputStream(targetFile));\n }\n String supertemplate=\"\";\n if(tp.containsKey(\"SUPERTEMPLATE\")){\n supertemplate=(String) tp.get(\"SUPERTEMPLATE\");\n }\n if(!supertemplate.equals(\"\")){\n File pageFile=getOverlayedFile(supertemplate); \n File pageClass=getOverlayedClass(supertemplate);\n if(pageFile != null && pageFile.exists()){\n BufferedReader br=new BufferedReader(new InputStreamReader(fis));\n String line;\n boolean inheader=false;\n StringBuffer header=new StringBuffer();\n StringBuffer content=new StringBuffer();\n String content_s,header_s;\n while((line=br.readLine())!=null){\n if(!inheader){\n if(line.startsWith(\"<!--HEADER\")){\n inheader=true;\n }else{\n content.append(line);\n }\n }else{\n if(line.endsWith(\"HEADER-->\")){\n inheader=false;\n }else{\n header.append(line);\n }\n }\n }\n o = new serverByteBuffer();\n fis=new ByteArrayInputStream(content.toString().getBytes());\n httpTemplate.writeTemplate(fis, o, tp, \"-UNRESOLVED_PATTERN-\".getBytes());\n content_s=o.toString();\n o = new serverByteBuffer();\n fis=new ByteArrayInputStream(header.toString().getBytes());\n httpTemplate.writeTemplate(fis, o, tp, \"-UNRESOLVED_PATTERN-\".getBytes());\n header_s=o.toString();\n if (pageClass != null && pageClass.exists()){\n Object tmp = invokeServlet(pageClass, requestHeader, args); \n if(tmp instanceof serverObjects){\n tp=new servletProperties((serverObjects)tmp);\n }else{\n tp=(servletProperties)tmp;\n }\n }else\n tp = new servletProperties();\n tp.put(\"header\", header_s);\n tp.put(\"page\", content_s);\n fis=new BufferedInputStream(new FileInputStream(pageFile));\n }\n }\n o = new serverByteBuffer();\n if (zipContent) zippedOut = new GZIPOutputStream(o);\n httpTemplate.writeTemplate(fis, (zipContent) ? (OutputStream)zippedOut: (OutputStream)o, tp, \"-UNRESOLVED_PATTERN-\".getBytes(\"UTF-8\"));\n if (zipContent) {\n zippedOut.finish();\n zippedOut.flush();\n zippedOut.close();\n zippedOut = null;\n }\n result = o.toByteArray();\n if (this.md5Digest != null) {\n this.md5Digest.reset();\n this.md5Digest.update(result);\n byte[] digest = this.md5Digest.digest();\n StringBuffer digestString = new StringBuffer();\n for ( int i = 0; i < digest.length; i++ )\n digestString.append(Integer.toHexString( digest[i]&0xff));\n } \n } finally {\n if (zippedOut != null) try {zippedOut.close();} catch(Exception e) {}\n if (o != null) try {o.close(); o = null;} catch(Exception e) {}\n if (fis != null) try {fis.close(); fis=null;} catch(Exception e) {}\n }\n long contentLength = result.length;\n String contentEncoding = (zipContent)?\"gzip\":null;\n httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, contentLength, targetDate, null, tp.getOutgoingHeader(), contentEncoding, null, nocache);\n if (! method.equals(httpHeader.METHOD_HEAD)) {\n Thread.sleep(200); \n serverFileUtils.write(result, out);\n } \n } else { \n int statusCode = 200;\n int rangeStartOffset = 0;\n httpHeader header = new httpHeader();\n header.put(httpHeader.ACCEPT_RANGES, \"bytes\");\n String targetMD5 = null;\n File targetMd5File = new File(targetFile + \".md5\");\n try {\n if (targetMd5File.exists()) {\n targetMD5 = new String(serverFileUtils.read(targetMd5File));\n pos = targetMD5.indexOf('\\n');\n if (pos >= 0) {\n targetMD5 = targetMD5.substring(0, pos);\n } \n header.put(httpHeader.ETAG, targetMD5);\n }\n } catch (IOException e) {\n e.printStackTrace();\n } \n if (requestHeader.containsKey(httpHeader.RANGE)) {\n Object ifRange = requestHeader.ifRange();\n if ((ifRange == null)||\n (ifRange instanceof Date && targetFile.lastModified() == ((Date)ifRange).getTime()) ||\n (ifRange instanceof String && ifRange.equals(targetMD5))) {\n String rangeHeaderVal = ((String) requestHeader.get(httpHeader.RANGE)).trim();\n if (rangeHeaderVal.startsWith(\"bytes=\")) {\n String rangesVal = rangeHeaderVal.substring(\"bytes=\".length());\n String[] ranges = rangesVal.split(\",\");\n if ((ranges.length == 1)&&(ranges[0].endsWith(\"-\"))) {\n rangeStartOffset = Integer.valueOf(ranges[0].substring(0,ranges[0].length()-1)).intValue();\n statusCode = 206;\n if (header == null) header = new httpHeader();\n header.put(httpHeader.CONTENT_RANGE, \"bytes \" + rangeStartOffset + \"-\" + (targetFile.length()-1) + \"/\" + targetFile.length());\n }\n }\n }\n }\n targetDate = new Date(targetFile.lastModified());\n long contentLength = (zipContent)?-1:targetFile.length()-rangeStartOffset;\n String contentEncoding = (zipContent)?\"gzip\":null;\n String transferEncoding = (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1))?null:(zipContent)?\"chunked\":null;\n if (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) forceConnectionClose();\n httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, statusCode, null, mimeType, contentLength, targetDate, null, header, contentEncoding, transferEncoding, nocache);\n if (!method.equals(httpHeader.METHOD_HEAD)) { \n httpChunkedOutputStream chunkedOut = null;\n GZIPOutputStream zipped = null;\n OutputStream newOut = out;\n if (transferEncoding != null) {\n chunkedOut = new httpChunkedOutputStream(newOut);\n newOut = chunkedOut;\n }\n if (contentEncoding != null) {\n zipped = new GZIPOutputStream(newOut);\n newOut = zipped;\n }\n serverFileUtils.copyRange(targetFile,newOut,rangeStartOffset);\n if (zipped != null) {\n zipped.flush();\n zipped.finish();\n }\n if (chunkedOut != null) {\n chunkedOut.finish();\n }\n } \n }\n } else {\n httpd.sendRespondError(conProp,out,3,404,\"File not Found\",null,null);\n return;\n }\n } catch (Exception e) { \n try {\n int httpStatusCode = 400; \n String httpStatusText = null; \n StringBuffer errorMessage = new StringBuffer(); \n Exception errorExc = null; \n String errorMsg = e.getMessage();\n if (\n (e instanceof InterruptedException) ||\n ((errorMsg != null) && (errorMsg.startsWith(\"Socket closed\")) && (Thread.currentThread().isInterrupted()))\n ) {\n errorMessage.append(\"Interruption detected while processing query.\");\n httpStatusCode = 503;\n } else {\n if ((errorMsg != null) && \n (\n errorMsg.startsWith(\"Broken pipe\") || \n errorMsg.startsWith(\"Connection reset\") ||\n errorMsg.startsWith(\"Software caused connection abort\") \n )) {\n errorMessage.append(\"Client unexpectedly closed connection while processing query.\");\n } else if ((errorMsg != null) && (errorMsg.startsWith(\"Connection timed out\"))) {\n errorMessage.append(\"Connection timed out.\");\n } else {\n errorMessage.append(\"Unexpected error while processing query.\");\n httpStatusCode = 500;\n errorExc = e;\n }\n }\n errorMessage.append(\"\\nSession: \").append(Thread.currentThread().getName())\n .append(\"\\nQuery: \").append(path)\n .append(\"\\nClient: \").append(conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,\"unknown\")) \n .append(\"\\nReason: \").append(e.toString()); \n if (!conProp.containsKey(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {\n httpd.sendRespondError(conProp,out, 4, httpStatusCode, httpStatusText, errorMessage.toString(),errorExc);\n } else {\n this.forceConnectionClose();\n } \n if (httpStatusCode == 500) {\n this.theLogger.logWarning(errorMessage.toString(),e);\n }\n } catch (Exception ee) {\n this.forceConnectionClose();\n } \n } finally {\n try {out.flush();}catch (Exception e) {}\n if (((String)requestHeader.get(httpHeader.CONNECTION, \"close\")).indexOf(\"keep-alive\") == -1) {\n try {Thread.sleep(1000);} catch (InterruptedException e) {}\n }\n }\n }\n", "output": " public void doResponse(Properties conProp, httpHeader requestHeader, OutputStream out, InputStream body) {\n this.connectionProperties = conProp;\n String path = null;\n try {\n String method = conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD);\n path = conProp.getProperty(httpHeader.CONNECTION_PROP_PATH);\n String argsString = conProp.getProperty(httpHeader.CONNECTION_PROP_ARGS); \n String httpVersion= conProp.getProperty(httpHeader.CONNECTION_PROP_HTTP_VER);\n if (path.indexOf(\"..\") >= 0) {\n httpd.sendRespondError(conProp,out,4,403,null,\"Access not allowed\",null);\n return;\n }\n try {\n path = URLDecoder.decode(path, \"UTF-8\");\n } catch (UnsupportedEncodingException e) {\n assert(false) : \"UnsupportedEncodingException: \" + e.getMessage();\n }\n String authorization = (String) requestHeader.get(httpHeader.AUTHORIZATION);\n String adminAccountBase64MD5 = switchboard.getConfig(\"adminAccountBase64MD5\", \"\");\n int pos = path.lastIndexOf(\".\");\n if ((path.substring(0,(pos==-1)?path.length():pos)).endsWith(\"_p\") && (adminAccountBase64MD5.length() != 0)) {\n if(sb.userDB.hasAdminRight(authorization, conProp.getProperty(\"CLIENTIP\"), requestHeader.getHeaderCookies())){\n serverCore.bfHost.remove(conProp.getProperty(\"CLIENTIP\"));\n }else if(authorization != null && sb.staticAdminAuthenticated(authorization.trim().substring(6))==4){\n serverCore.bfHost.remove(conProp.getProperty(\"CLIENTIP\"));\n }else if (authorization == null) {\n httpHeader headers = getDefaultHeaders(path);\n headers.put(httpHeader.WWW_AUTHENTICATE,\"Basic realm=\\\"admin log-in\\\"\");\n servletProperties tp=new servletProperties();\n tp.put(\"returnto\", path);\n httpd.sendRespondError(conProp, out, 5, 401, \"Wrong Authentication\", \"\", new File(\"proxymsg/authfail.inc\"), tp, null, headers);\n return;\n } else {\n String clientIP = conProp.getProperty(\"CLIENTIP\", \"unknown-host\");\n serverLog.logInfo(\"HTTPD\", \"Wrong log-in for account 'admin' in http file handler for path '\" + path + \"' from host '\" + clientIP + \"'\");\n Integer attempts = (Integer) serverCore.bfHost.get(clientIP);\n if (attempts == null)\n serverCore.bfHost.put(clientIP, new Integer(1));\n else\n serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));\n httpHeader headers = getDefaultHeaders(path);\n headers.put(httpHeader.WWW_AUTHENTICATE,\"Basic realm=\\\"admin log-in\\\"\");\n httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);\n return;\n }\n }\n serverObjects args = new serverObjects();\n int argc;\n if (argsString == null) {\n int length = 0;\n if (method.equals(httpHeader.METHOD_POST)) {\n GZIPInputStream gzipBody = null;\n if (requestHeader.containsKey(httpHeader.CONTENT_LENGTH)) {\n length = Integer.parseInt((String) requestHeader.get(httpHeader.CONTENT_LENGTH));\n } else if (requestHeader.gzip()) {\n length = -1;\n gzipBody = new GZIPInputStream(body);\n }\n if ((requestHeader.containsKey(httpHeader.CONTENT_TYPE)) &&\n (((String) requestHeader.get(httpHeader.CONTENT_TYPE)).toLowerCase().startsWith(\"multipart\"))) {\n HashMap files = httpd.parseMultipart(requestHeader, args, (gzipBody!=null)?gzipBody:body, length);\n if (files != null) {\n Iterator fit = files.entrySet().iterator();\n Map.Entry entry;\n while (fit.hasNext()) {\n entry = (Map.Entry) fit.next();\n args.put(((String) entry.getKey()) + \"$file\", entry.getValue());\n }\n }\n argc = Integer.parseInt((String) requestHeader.get(\"ARGC\"));\n } else {\n argc = httpd.parseArgs(args, (gzipBody!=null)?gzipBody:body, length);\n }\n } else {\n argsString = null;\n args = null;\n argc = 0;\n }\n } else {\n argc = httpd.parseArgs(args, argsString);\n }\n if (argc > 0) {\n Enumeration e = args.elements(); \n Object val;\n while (e.hasMoreElements()) {\n val = e.nextElement();\n if ((val != null) && (val instanceof String) && (((String) val).indexOf(\"<script\") >= 0)) {\n httpd.sendRespondError(conProp,out,4,403,null,\"bad post values\",null);\n return;\n }\n }\n }\n if (path.length() == 0) {\n httpd.sendRespondError(conProp,out,4,400,null,\"Bad Request\",null);\n out.flush();\n return;\n }\n File targetClass=null;\n if (!(path.startsWith(\"/\"))) path = \"/\" + path; \n String localeSelection = switchboard.getConfig(\"htLocaleSelection\",\"default\");\n if (args != null && (args.containsKey(\"language\"))) \n {\n localeSelection = args.get(\"language\", localeSelection);\n if (localeSelection.indexOf(\".\") != -1)\n localeSelection = localeSelection.substring(0, localeSelection.indexOf(\".\"));\n }\n File targetFile = getLocalizedFile(path, localeSelection);\n String targetExt = conProp.getProperty(\"EXT\",\"\");\n targetClass = rewriteClassFile(new File(htDefaultPath, path));\n if (path.endsWith(\"/\")) {\n String testpath;\n for (int i = 0; i < defaultFiles.length; i++) {\n testpath = path + defaultFiles[i];\n targetFile = getOverlayedFile(testpath);\n targetClass=getOverlayedClass(testpath);\n if (targetFile.exists()) {\n path = testpath;\n break;\n }\n }\n if(targetFile == null || !targetFile.exists()){\n \tString dirlistFormat = (args==null)?\"html\":args.get(\"format\",\"html\");\n targetFile = getOverlayedFile(\"/htdocsdefault/dir.\" + dirlistFormat);\n targetClass=getOverlayedClass(\"/htdocsdefault/dir.\" + dirlistFormat);\n if(! (( targetFile != null && targetFile.exists()) && ( targetClass != null && targetClass.exists())) ){\n httpd.sendRespondError(this.connectionProperties,out,3,500,\"dir.\" + dirlistFormat + \" or dir.class not found.\",null,null);\n }\n }\n }else{\n if ( !(targetFile.exists()) && !((path.endsWith(\"png\")||path.endsWith(\"gif\")||path.endsWith(\".stream\"))&&targetClass!=null ) ){\n targetFile = new File(htDocsPath, path);\n targetClass = rewriteClassFile(new File(htDocsPath, path));\n }\n }\n servletProperties tp = new servletProperties();\n Date targetDate;\n boolean nocache = false;\n if ((targetClass != null) && (path.endsWith(\"png\"))) {\n Object img = null;\n try {\n requestHeader.put(\"CLIENTIP\", conProp.getProperty(\"CLIENTIP\"));\n requestHeader.put(\"PATH\", path);\n img = invokeServlet(targetClass, requestHeader, args);\n } catch (InvocationTargetException e) {\n this.theLogger.logSevere(\"INTERNAL ERROR: \" + e.toString() + \":\" +\n e.getMessage() +\n \" target exception at \" + targetClass + \": \" +\n e.getTargetException().toString() + \":\" +\n e.getTargetException().getMessage() +\n \"; java.awt.graphicsenv='\" + System.getProperty(\"java.awt.graphicsenv\",\"\") + \"'\",e);\n targetClass = null;\n }\n if (img == null) {\n httpd.sendRespondError(this.connectionProperties,out,3,404,\"File not Found\",null,null);\n } else {\n if (img instanceof ymageMatrix) {\n ymageMatrix yp = (ymageMatrix) img;\n targetDate = new Date(System.currentTimeMillis());\n nocache = true;\n String mimeType = mimeTable.getProperty(targetExt, \"text/html\");\n serverByteBuffer baos = new serverByteBuffer();\n ImageIO.write(yp.getImage(), targetExt, baos);\n byte[] result = baos.toByteArray();\n baos.close();\n baos = null;\n httpd.sendRespondHeader(this.connectionProperties, out,\n httpVersion, 200, null, mimeType,\n result.length, targetDate, null, null, null,\n null, nocache);\n if (!method.equals(httpHeader.METHOD_HEAD)) {\n Thread.sleep(200); \n serverFileUtils.write(result, out);\n }\n }\n if (img instanceof Image) {\n Image i = (Image) img;\n targetDate = new Date(System.currentTimeMillis());\n nocache = true;\n String mimeType = mimeTable.getProperty(targetExt, \"text/html\");\n int width = i.getWidth(null); if (width < 0) width = 96; \n int height = i.getHeight(null); if (height < 0) height = 96; \n BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\n bi.createGraphics().drawImage(i, 0, 0, width, height, null); \n serverByteBuffer baos = new serverByteBuffer();\n ImageIO.write(bi, targetExt, baos);\n byte[] result = baos.toByteArray();\n baos.close();\n baos = null;\n httpd.sendRespondHeader(this.connectionProperties, out,\n httpVersion, 200, null, mimeType,\n result.length, targetDate, null, null, null,\n null, nocache);\n if (!method.equals(httpHeader.METHOD_HEAD)) {\n Thread.sleep(200); \n serverFileUtils.write(result, out);\n }\n }\n }\n } else if ((targetClass != null) && (path.endsWith(\".stream\"))) {\n requestHeader.put(\"CLIENTIP\", conProp.getProperty(\"CLIENTIP\"));\n requestHeader.put(\"PATH\", path);\n requestHeader.put(\"INPUTSTREAM\", body);\n requestHeader.put(\"OUTPUTSTREAM\", out);\n httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null); \n invokeServlet(targetClass, requestHeader, args);\n this.forceConnectionClose();\n return; \n } else if ((targetFile.exists()) && (targetFile.canRead())) {\n String mimeType = mimeTable.getProperty(targetExt,\"text/html\");\n byte[] result;\n boolean zipContent = requestHeader.acceptGzip() && httpd.shallTransportZipped(\".\" + conProp.getProperty(\"EXT\",\"\"));\n if (path.endsWith(\"html\") || \n path.endsWith(\"xml\") || \n path.endsWith(\"rss\") || \n path.endsWith(\"csv\") ||\n path.endsWith(\"pac\") ||\n path.endsWith(\"src\") ||\n path.endsWith(\"/\")) {\n if (targetClass == null) {\n targetDate = new Date(targetFile.lastModified());\n } else {\n try {\n requestHeader.put(\"CLIENTIP\", conProp.getProperty(\"CLIENTIP\"));\n requestHeader.put(\"PATH\", path);\n Object tmp = invokeServlet(targetClass, requestHeader, args); \n if(tmp instanceof serverObjects){\n tp=new servletProperties((serverObjects)tmp);\n }else{\n tp=(servletProperties)tmp;\n }\n if (tp == null) tp = new servletProperties();\n if (tp.containsKey(\"AUTHENTICATE\")) {\n if (authorization != null) {\n String clientIP = conProp.getProperty(\"CLIENTIP\", \"unknown-host\");\n serverLog.logInfo(\"HTTPD\", \"dynamic log-in for account 'admin' in http file handler for path '\" + path + \"' from host '\" + clientIP + \"'\");\n Integer attempts = (Integer) serverCore.bfHost.get(clientIP);\n if (attempts == null)\n serverCore.bfHost.put(clientIP, new Integer(1));\n else\n serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));\n }\n httpHeader headers = getDefaultHeaders(path);\n headers.put(httpHeader.WWW_AUTHENTICATE,\"Basic realm=\\\"\" + tp.get(\"AUTHENTICATE\", \"\") + \"\\\"\");\n httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);\n return;\n } else if (tp.containsKey(\"LOCATION\")) {\n String location = tp.get(\"LOCATION\",\"\");\n if (location.length() == 0) location = path;\n httpHeader headers = getDefaultHeaders(path);\n headers.setCookieVector(tp.getOutgoingHeader().getCookieVector()); \n headers.put(httpHeader.LOCATION,location);\n httpd.sendRespondHeader(conProp,out,httpVersion,302,headers);\n return;\n }\n tp.put(\"version\", switchboard.getConfig(\"version\", \"\"));\n tp.put(\"uptime\", ((System.currentTimeMillis() - Long.parseLong(switchboard.getConfig(\"startupTime\",\"0\"))) / 1000) / 60); \n tp.put(\"clientname\", switchboard.getConfig(\"peerName\", \"anomic\"));\n } catch (InvocationTargetException e) {\n if (e.getCause() instanceof InterruptedException) {\n throw new InterruptedException(e.getCause().getMessage());\n } \n this.theLogger.logSevere(\"INTERNAL ERROR: \" + e.toString() + \":\" +\n e.getMessage() +\n \" target exception at \" + targetClass + \": \" +\n e.getTargetException().toString() + \":\" +\n e.getTargetException().getMessage(),e);\n targetClass = null;\n throw e;\n }\n targetDate = new Date(System.currentTimeMillis());\n nocache = true;\n }\n tp.putAll(templates);\n serverByteBuffer o = null;\n InputStream fis = null;\n GZIPOutputStream zippedOut = null;\n try {\n byte[] templateContent = null;\n if (useTemplateCache) {\n long fileSize = targetFile.length();\n if (fileSize <= 512*1024) {\n SoftReference ref = (SoftReference) templateCache.get(targetFile);\n if (ref != null) {\n templateContent = (byte[]) ref.get();\n if (templateContent == null) \n templateCache.remove(targetFile); \n }\n if (templateContent == null) {\n templateContent = serverFileUtils.read(targetFile);\n ref = new SoftReference(templateContent);\n templateCache.put(targetFile,ref);\n if (this.theLogger.isLoggable(Level.FINEST))\n this.theLogger.logFinest(\"Cache MISS for file \" + targetFile);\n } else {\n if (this.theLogger.isLoggable(Level.FINEST))\n this.theLogger.logFinest(\"Cache HIT for file \" + targetFile);\n }\n fis = new ByteArrayInputStream(templateContent); \n templateContent = null;\n } else {\n fis = new BufferedInputStream(new FileInputStream(targetFile));\n }\n } else {\n fis = new BufferedInputStream(new FileInputStream(targetFile));\n }\n String supertemplate=\"\";\n if(tp.containsKey(\"SUPERTEMPLATE\")){\n supertemplate=(String) tp.get(\"SUPERTEMPLATE\");\n }\n if(!supertemplate.equals(\"\")){\n File pageFile=getOverlayedFile(supertemplate); \n File pageClass=getOverlayedClass(supertemplate);\n if(pageFile != null && pageFile.exists()){\n BufferedReader br=new BufferedReader(new InputStreamReader(fis));\n String line;\n boolean inheader=false;\n StringBuffer header=new StringBuffer();\n StringBuffer content=new StringBuffer();\n String content_s,header_s;\n while((line=br.readLine())!=null){\n if(!inheader){\n if(line.startsWith(\"<!--HEADER\")){\n inheader=true;\n }else{\n content.append(line);\n }\n }else{\n if(line.endsWith(\"HEADER-->\")){\n inheader=false;\n }else{\n header.append(line);\n }\n }\n }\n o = new serverByteBuffer();\n fis=new ByteArrayInputStream(content.toString().getBytes());\n httpTemplate.writeTemplate(fis, o, tp, \"-UNRESOLVED_PATTERN-\".getBytes());\n content_s=o.toString();\n o = new serverByteBuffer();\n fis=new ByteArrayInputStream(header.toString().getBytes());\n httpTemplate.writeTemplate(fis, o, tp, \"-UNRESOLVED_PATTERN-\".getBytes());\n header_s=o.toString();\n if (pageClass != null && pageClass.exists()){\n Object tmp = invokeServlet(pageClass, requestHeader, args); \n if(tmp instanceof serverObjects){\n tp=new servletProperties((serverObjects)tmp);\n }else{\n tp=(servletProperties)tmp;\n }\n }else\n tp = new servletProperties();\n tp.putASIS(\"header\", header_s);\n tp.putASIS(\"page\", content_s);\n fis=new BufferedInputStream(new FileInputStream(pageFile));\n }\n }\n o = new serverByteBuffer();\n if (zipContent) zippedOut = new GZIPOutputStream(o);\n httpTemplate.writeTemplate(fis, (zipContent) ? (OutputStream)zippedOut: (OutputStream)o, tp, \"-UNRESOLVED_PATTERN-\".getBytes(\"UTF-8\"));\n if (zipContent) {\n zippedOut.finish();\n zippedOut.flush();\n zippedOut.close();\n zippedOut = null;\n }\n result = o.toByteArray();\n if (this.md5Digest != null) {\n this.md5Digest.reset();\n this.md5Digest.update(result);\n byte[] digest = this.md5Digest.digest();\n StringBuffer digestString = new StringBuffer();\n for ( int i = 0; i < digest.length; i++ )\n digestString.append(Integer.toHexString( digest[i]&0xff));\n } \n } finally {\n if (zippedOut != null) try {zippedOut.close();} catch(Exception e) {}\n if (o != null) try {o.close(); o = null;} catch(Exception e) {}\n if (fis != null) try {fis.close(); fis=null;} catch(Exception e) {}\n }\n long contentLength = result.length;\n String contentEncoding = (zipContent)?\"gzip\":null;\n httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, 200, null, mimeType, contentLength, targetDate, null, tp.getOutgoingHeader(), contentEncoding, null, nocache);\n if (! method.equals(httpHeader.METHOD_HEAD)) {\n Thread.sleep(200); \n serverFileUtils.write(result, out);\n } \n } else { \n int statusCode = 200;\n int rangeStartOffset = 0;\n httpHeader header = new httpHeader();\n header.put(httpHeader.ACCEPT_RANGES, \"bytes\");\n String targetMD5 = null;\n File targetMd5File = new File(targetFile + \".md5\");\n try {\n if (targetMd5File.exists()) {\n targetMD5 = new String(serverFileUtils.read(targetMd5File));\n pos = targetMD5.indexOf('\\n');\n if (pos >= 0) {\n targetMD5 = targetMD5.substring(0, pos);\n } \n header.put(httpHeader.ETAG, targetMD5);\n }\n } catch (IOException e) {\n e.printStackTrace();\n } \n if (requestHeader.containsKey(httpHeader.RANGE)) {\n Object ifRange = requestHeader.ifRange();\n if ((ifRange == null)||\n (ifRange instanceof Date && targetFile.lastModified() == ((Date)ifRange).getTime()) ||\n (ifRange instanceof String && ifRange.equals(targetMD5))) {\n String rangeHeaderVal = ((String) requestHeader.get(httpHeader.RANGE)).trim();\n if (rangeHeaderVal.startsWith(\"bytes=\")) {\n String rangesVal = rangeHeaderVal.substring(\"bytes=\".length());\n String[] ranges = rangesVal.split(\",\");\n if ((ranges.length == 1)&&(ranges[0].endsWith(\"-\"))) {\n rangeStartOffset = Integer.valueOf(ranges[0].substring(0,ranges[0].length()-1)).intValue();\n statusCode = 206;\n if (header == null) header = new httpHeader();\n header.put(httpHeader.CONTENT_RANGE, \"bytes \" + rangeStartOffset + \"-\" + (targetFile.length()-1) + \"/\" + targetFile.length());\n }\n }\n }\n }\n targetDate = new Date(targetFile.lastModified());\n long contentLength = (zipContent)?-1:targetFile.length()-rangeStartOffset;\n String contentEncoding = (zipContent)?\"gzip\":null;\n String transferEncoding = (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1))?null:(zipContent)?\"chunked\":null;\n if (!httpVersion.equals(httpHeader.HTTP_VERSION_1_1) && zipContent) forceConnectionClose();\n httpd.sendRespondHeader(this.connectionProperties, out, httpVersion, statusCode, null, mimeType, contentLength, targetDate, null, header, contentEncoding, transferEncoding, nocache);\n if (!method.equals(httpHeader.METHOD_HEAD)) { \n httpChunkedOutputStream chunkedOut = null;\n GZIPOutputStream zipped = null;\n OutputStream newOut = out;\n if (transferEncoding != null) {\n chunkedOut = new httpChunkedOutputStream(newOut);\n newOut = chunkedOut;\n }\n if (contentEncoding != null) {\n zipped = new GZIPOutputStream(newOut);\n newOut = zipped;\n }\n serverFileUtils.copyRange(targetFile,newOut,rangeStartOffset);\n if (zipped != null) {\n zipped.flush();\n zipped.finish();\n }\n if (chunkedOut != null) {\n chunkedOut.finish();\n }\n } \n }\n } else {\n httpd.sendRespondError(conProp,out,3,404,\"File not Found\",null,null);\n return;\n }\n } catch (Exception e) { \n try {\n int httpStatusCode = 400; \n String httpStatusText = null; \n StringBuffer errorMessage = new StringBuffer(); \n Exception errorExc = null; \n String errorMsg = e.getMessage();\n if (\n (e instanceof InterruptedException) ||\n ((errorMsg != null) && (errorMsg.startsWith(\"Socket closed\")) && (Thread.currentThread().isInterrupted()))\n ) {\n errorMessage.append(\"Interruption detected while processing query.\");\n httpStatusCode = 503;\n } else {\n if ((errorMsg != null) && \n (\n errorMsg.startsWith(\"Broken pipe\") || \n errorMsg.startsWith(\"Connection reset\") ||\n errorMsg.startsWith(\"Software caused connection abort\") \n )) {\n errorMessage.append(\"Client unexpectedly closed connection while processing query.\");\n } else if ((errorMsg != null) && (errorMsg.startsWith(\"Connection timed out\"))) {\n errorMessage.append(\"Connection timed out.\");\n } else {\n errorMessage.append(\"Unexpected error while processing query.\");\n httpStatusCode = 500;\n errorExc = e;\n }\n }\n errorMessage.append(\"\\nSession: \").append(Thread.currentThread().getName())\n .append(\"\\nQuery: \").append(path)\n .append(\"\\nClient: \").append(conProp.getProperty(httpHeader.CONNECTION_PROP_CLIENTIP,\"unknown\")) \n .append(\"\\nReason: \").append(e.toString()); \n if (!conProp.containsKey(httpHeader.CONNECTION_PROP_PROXY_RESPOND_HEADER)) {\n httpd.sendRespondError(conProp,out, 4, httpStatusCode, httpStatusText, errorMessage.toString(),errorExc);\n } else {\n this.forceConnectionClose();\n } \n if (httpStatusCode == 500) {\n this.theLogger.logWarning(errorMessage.toString(),e);\n }\n } catch (Exception ee) {\n this.forceConnectionClose();\n } \n } finally {\n try {out.flush();}catch (Exception e) {}\n if (((String)requestHeader.get(httpHeader.CONNECTION, \"close\")).indexOf(\"keep-alive\") == -1) {\n try {Thread.sleep(1000);} catch (InterruptedException e) {}\n }\n }\n }\n"} {"input": "\tpublic static void doActiveUpdate(final Context context, Boolean useGPS) {\n\t\tLog.d(DEBUG_TAG, \"force active location update\");\n\t\tif (locationListener == null) {\n\t\t\tLog.d(DEBUG_TAG, \"set up new LocationListener\");\n\t\t\tlocationListener = new LocationListener() {\n\t\t\t\tpublic void onLocationChanged(Location location) {\n\t\t\t\t\tLog.d(DEBUG_TAG, \"locationListener: location changed. disabling myself\");\n\t\t\t\t\tLocationManager locationManager = (LocationManager) context\n\t\t\t\t\t\t\t.getSystemService(Context.LOCATION_SERVICE);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tThread.sleep(4000);\n\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t}\n\t\t\t\t\tlocationManager.removeUpdates(locationListener);\n\t\t\t\t\tlocationListener = null;\n\t\t\t\t}\n\t\t\t\tpublic void onProviderDisabled(String provider) {\n\t\t\t\t}\n\t\t\t\tpublic void onProviderEnabled(String provider) {\n\t\t\t\t}\n\t\t\t\tpublic void onStatusChanged(String provider, int status,\n\t\t\t\t\t\tBundle extras) {\n\t\t\t\t}\n\t\t\t};\n\t\t\tLocationManager locationManager = (LocationManager) context\n\t\t\t\t\t.getSystemService(Context.LOCATION_SERVICE);\n\t\t\tSharedPreferences SP = PreferenceManager\n\t\t\t\t\t.getDefaultSharedPreferences(context);\n\t\t\tif (SP.getBoolean(\"activeupdate\", false) && useGPS) {\n\t\t\t\tif (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {\n\t\t\t\t\tLog.d(DEBUG_TAG, \"GPS disabled, requesting network location update\");\n\t\t\t\t\tToast.makeText(\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tcontext.getResources().getString(\n\t\t\t\t\t\t\t\t\tR.string.msg_gpsdisabled),\n\t\t\t\t\t\t\tToast.LENGTH_SHORT).show();\n\t\t\t\t\tlocationManager.requestLocationUpdates(\n\t\t\t\t\t\t\tLocationManager.NETWORK_PROVIDER, 0, 0,\n\t\t\t\t\t\t\tlocationListener);\n\t\t\t\t} else {\n\t\t\t\t\tLog.d(DEBUG_TAG, \"requesting GPS location update\");\n\t\t\t\t\tlocationManager.requestLocationUpdates(\n\t\t\t\t\t\t\tLocationManager.GPS_PROVIDER, 0, 0,\n\t\t\t\t\t\t\tlocationListener); \n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tLog.d(DEBUG_TAG, \"Active lookup disabled, requesting network location update\");\n\t\t\t\tlocationManager.requestLocationUpdates(\n\t\t\t\t\t\tLocationManager.NETWORK_PROVIDER, 0, 0,\n\t\t\t\t\t\tlocationListener);\n\t\t\t}\n\t\t\tAlarmManager alarmManager = (AlarmManager) context\n\t\t\t\t\t.getSystemService(Context.ALARM_SERVICE);\n\t\t\tIntent i = new Intent(context, LocationReceiver.class);\n\t\t\ti.putExtra(\"de.h3ndrik.openlocation.cancelgps\", \"true\");\n\t\t\tPendingIntent pendingIntent = PendingIntent\n\t\t\t\t\t.getBroadcast(context, 0, i,\n\t\t\t\t\t\t\tPendingIntent.FLAG_UPDATE_CURRENT);\n\t\t\talarmManager.set(AlarmManager.RTC_WAKEUP,\n\t\t\t\t\tSystem.currentTimeMillis() + 16000,\n\t\t\t\t\tpendingIntent);\n\t\t\tLog.d(DEBUG_TAG, \"cancelUpdates alarm set\");\n\t\t}\n\t\telse {\n\t\t\tLog.d(DEBUG_TAG, \"conflicting locationListener, skipping\");\n\t\t}\n\t}\n", "output": "\tpublic static void doActiveUpdate(final Context context, Boolean useGPS) {\n\t\tLog.d(DEBUG_TAG, \"force active location update\");\n\t\tif (locationListener == null) {\n\t\t\tLog.d(DEBUG_TAG, \"set up new LocationListener\");\n\t\t\tlocationListener = new LocationListener() {\n\t\t\t\tpublic void onLocationChanged(Location location) {\n\t\t\t\t\tLog.d(DEBUG_TAG, \"locationListener: location changed. disabling myself\");\n\t\t\t\t\tLocationManager locationManager = (LocationManager) context\n\t\t\t\t\t\t\t.getSystemService(Context.LOCATION_SERVICE);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tThread.sleep(4000);\n\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t}\n\t\t\t\t\tlocationManager.removeUpdates(this);\n\t\t\t\t\tlocationListener = null;\n\t\t\t\t}\n\t\t\t\tpublic void onProviderDisabled(String provider) {\n\t\t\t\t}\n\t\t\t\tpublic void onProviderEnabled(String provider) {\n\t\t\t\t}\n\t\t\t\tpublic void onStatusChanged(String provider, int status,\n\t\t\t\t\t\tBundle extras) {\n\t\t\t\t}\n\t\t\t};\n\t\t\tLocationManager locationManager = (LocationManager) context\n\t\t\t\t\t.getSystemService(Context.LOCATION_SERVICE);\n\t\t\tSharedPreferences SP = PreferenceManager\n\t\t\t\t\t.getDefaultSharedPreferences(context);\n\t\t\tif (SP.getBoolean(\"activeupdate\", false) && useGPS) {\n\t\t\t\tif (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {\n\t\t\t\t\tLog.d(DEBUG_TAG, \"GPS disabled, requesting network location update\");\n\t\t\t\t\tToast.makeText(\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\tcontext.getResources().getString(\n\t\t\t\t\t\t\t\t\tR.string.msg_gpsdisabled),\n\t\t\t\t\t\t\tToast.LENGTH_SHORT).show();\n\t\t\t\t\tlocationManager.requestLocationUpdates(\n\t\t\t\t\t\t\tLocationManager.NETWORK_PROVIDER, 0, 0,\n\t\t\t\t\t\t\tlocationListener);\n\t\t\t\t} else {\n\t\t\t\t\tLog.d(DEBUG_TAG, \"requesting GPS location update\");\n\t\t\t\t\tlocationManager.requestLocationUpdates(\n\t\t\t\t\t\t\tLocationManager.GPS_PROVIDER, 0, 0,\n\t\t\t\t\t\t\tlocationListener); \n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tLog.d(DEBUG_TAG, \"Active lookup disabled, requesting network location update\");\n\t\t\t\tlocationManager.requestLocationUpdates(\n\t\t\t\t\t\tLocationManager.NETWORK_PROVIDER, 0, 0,\n\t\t\t\t\t\tlocationListener);\n\t\t\t}\n\t\t\tAlarmManager alarmManager = (AlarmManager) context\n\t\t\t\t\t.getSystemService(Context.ALARM_SERVICE);\n\t\t\tIntent i = new Intent(context, LocationReceiver.class);\n\t\t\ti.putExtra(\"de.h3ndrik.openlocation.cancelgps\", \"true\");\n\t\t\tPendingIntent pendingIntent = PendingIntent\n\t\t\t\t\t.getBroadcast(context, 0, i,\n\t\t\t\t\t\t\tPendingIntent.FLAG_UPDATE_CURRENT);\n\t\t\talarmManager.set(AlarmManager.RTC_WAKEUP,\n\t\t\t\t\tSystem.currentTimeMillis() + 16000,\n\t\t\t\t\tpendingIntent);\n\t\t\tLog.d(DEBUG_TAG, \"cancelUpdates alarm set\");\n\t\t}\n\t\telse {\n\t\t\tLog.d(DEBUG_TAG, \"conflicting locationListener, skipping\");\n\t\t}\n\t}\n"} {"input": "\tprotected void doExecute(IProgressMonitor monitor) throws ExecutionException {\n\t\tsuper.doExecute(monitor);\n\t\tList modelsToImport = (List) model.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST);\n\t\ttry {\n\t\t\tIDataModel importModel = null;\n\t\t\tList allModels = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST);\n\t\t\tList componentToAdd = new ArrayList();\n\t\t\tMap componentToURIMap = new HashMap();\n\t\t\tfor (int i = 0; i < allModels.size(); i++) {\n\t\t\t\timportModel = (IDataModel) allModels.get(i);\n\t\t\t\tif (modelsToImport.contains(importModel)) {\n\t\t\t\t\tString archiveUri = ((Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE)).getURI();\n\t\t\t\t\timportModel.setProperty(IJ2EEComponentImportDataModelProperties.CLOSE_ARCHIVE_ON_DISPOSE, Boolean.FALSE);\n\t\t\t\t\tIDataModel compCreationModel = importModel.getNestedModel(\"IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION\"); \n\t\t\t\t\tcompCreationModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI, archiveUri);\n\t\t\t\t\ttry {\n\t\t\t\t\t\timportModel.getDefaultOperation().execute(monitor, info);\n\t\t\t\t\t} catch (ExecutionException e) {\n\t\t\t\t\t\tLogger.getLogger().logError(e);\n\t\t\t\t\t}\n\t\t\t\t\tIVirtualComponent component = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT);\n\t\t\t\t\tcomponentToAdd.add(component);\n\t\t\t\t\tcomponentToURIMap.put(component, archiveUri);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (componentToAdd.size() > 0) {\n\t\t\t\tIDataModel addComponentsDM = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider());\n\t\t\t\taddComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent);\n\t\t\t\taddComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd);\n\t\t\t\taddComponentsDM.setProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap);\n\t\t\t\taddComponentsDM.getDefaultOperation().execute(monitor, info);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfixupClasspaths(modelsToImport, virtualComponent);\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tLogger.getLogger().logError(e);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (null != artifactEdit) {\n\t\t\t\tartifactEdit.dispose();\n\t\t\t\tartifactEdit = null;\n\t\t\t}\n\t\t\tresetDisposeImportModels();\n\t\t}\n\t}\n", "output": "\tprotected void doExecute(IProgressMonitor monitor) throws ExecutionException {\n\t\tsuper.doExecute(monitor);\n\t\tList modelsToImport = (List) model.getProperty(IEARComponentImportDataModelProperties.HANDLED_PROJECT_MODELS_LIST);\n\t\ttry {\n\t\t\tIDataModel importModel = null;\n\t\t\tList allModels = (List) model.getProperty(IEARComponentImportDataModelProperties.ALL_PROJECT_MODELS_LIST);\n\t\t\tList componentToAdd = new ArrayList();\n\t\t\tMap componentToURIMap = new HashMap();\n\t\t\tfor (int i = 0; i < allModels.size(); i++) {\n\t\t\t\timportModel = (IDataModel) allModels.get(i);\n\t\t\t\tif (modelsToImport.contains(importModel)) {\n\t\t\t\t\tString archiveUri = ((Archive) importModel.getProperty(IEARComponentImportDataModelProperties.FILE)).getURI();\n\t\t\t\t\timportModel.setProperty(IJ2EEComponentImportDataModelProperties.CLOSE_ARCHIVE_ON_DISPOSE, Boolean.FALSE);\n\t\t\t\t\tIDataModel compCreationModel = importModel.getNestedModel(\"IJ2EEArtifactImportDataModelProperties.NESTED_MODEL_J2EE_COMPONENT_CREATION\"); \n\t\t\t\t\tif (compCreationModel.isProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI))\n\t\t\t\t\t\tcompCreationModel.setProperty(IJ2EEFacetProjectCreationDataModelProperties.MODULE_URI, archiveUri);\n\t\t\t\t\ttry {\n\t\t\t\t\t\timportModel.getDefaultOperation().execute(monitor, info);\n\t\t\t\t\t} catch (ExecutionException e) {\n\t\t\t\t\t\tLogger.getLogger().logError(e);\n\t\t\t\t\t}\n\t\t\t\t\tIVirtualComponent component = (IVirtualComponent) importModel.getProperty(IJ2EEComponentImportDataModelProperties.COMPONENT);\n\t\t\t\t\tcomponentToAdd.add(component);\n\t\t\t\t\tcomponentToURIMap.put(component, archiveUri);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (componentToAdd.size() > 0) {\n\t\t\t\tIDataModel addComponentsDM = DataModelFactory.createDataModel(new AddComponentToEnterpriseApplicationDataModelProvider());\n\t\t\t\taddComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, virtualComponent);\n\t\t\t\taddComponentsDM.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, componentToAdd);\n\t\t\t\taddComponentsDM.setProperty(IAddComponentToEnterpriseApplicationDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, componentToURIMap);\n\t\t\t\taddComponentsDM.getDefaultOperation().execute(monitor, info);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfixupClasspaths(modelsToImport, virtualComponent);\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tLogger.getLogger().logError(e);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (null != artifactEdit) {\n\t\t\t\tartifactEdit.dispose();\n\t\t\t\tartifactEdit = null;\n\t\t\t}\n\t\t\tresetDisposeImportModels();\n\t\t}\n\t}\n"} {"input": " public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {\n if (!(sender instanceof Player)) {\n sender.sendMessage(\"Can't vanish if not a player!\");\n return true;\n }\n if (args.length == 0) {\n boolean vanishing = true;\n String bit;\n if (this.vanished.contains(sender.getName())) {\n vanishing = false;\n this.vanished.remove(sender.getName());\n bit = \"unvanished\";\n } else {\n this.vanished.add(sender.getName());\n bit = \"vanished\";\n }\n final Player player = (Player) sender;\n for (final Player plr : this.getServer().getOnlinePlayers()) {\n if (vanishing && !plr.hasPermission(this.vanishPerm)) {\n plr.hidePlayer(player);\n } else if (!vanishing && plr.canSee(player)) {\n plr.showPlayer(player);\n }\n }\n this.getServer().broadcast(ChatColor.AQUA + player.getName() + \" has \" + bit, this.vanishPerm);\n } else if (args[0].equalsIgnoreCase(\"list\")) {\n final StringBuilder list = new StringBuilder();\n list.append(ChatColor.AQUA);\n list.append(\"Vanished (\");\n list.append(this.vanished.size());\n list.append(\"): \");\n for (final String name : this.vanished) {\n list.append(name);\n list.append(\" ,\");\n }\n list.setLength(list.length() - 2);\n sender.sendMessage(list.toString());\n }\n return true;\n }\n", "output": " public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {\n if (!(sender instanceof Player)) {\n sender.sendMessage(\"Can't vanish if not a player!\");\n return true;\n }\n if (args.length == 0) {\n boolean vanishing = true;\n String bit;\n if (this.vanished.contains(sender.getName())) {\n vanishing = false;\n this.vanished.remove(sender.getName());\n bit = \"unvanished\";\n } else {\n this.vanished.add(sender.getName());\n bit = \"vanished\";\n }\n final Player player = (Player) sender;\n for (final Player plr : this.getServer().getOnlinePlayers()) {\n if (vanishing && !plr.hasPermission(this.vanishPerm)) {\n plr.hidePlayer(player);\n } else if (!vanishing && !plr.canSee(player)) {\n plr.showPlayer(player);\n }\n }\n this.getServer().broadcast(ChatColor.AQUA + player.getName() + \" has \" + bit, this.vanishPerm);\n } else if (args[0].equalsIgnoreCase(\"list\")) {\n final StringBuilder list = new StringBuilder();\n list.append(ChatColor.AQUA);\n list.append(\"Vanished (\");\n list.append(this.vanished.size());\n list.append(\"): \");\n for (final String name : this.vanished) {\n list.append(name);\n list.append(\", \");\n }\n list.setLength(list.length() - 2);\n sender.sendMessage(list.toString());\n }\n return true;\n }\n"} {"input": "\tpublic Event(){\n\t\tthis.id = UUID.randomUUID().toString().toLowerCase();\n\t}\n", "output": "\tpublic Event(){\n\t\tthis.id = UUID.randomUUID().toString();\n\t}\n"} {"input": "\tpublic MenuManager getSubMenuManager(TaskListView view, ITaskListElement selection) {\n\t\tfinal ITaskListElement selectedElement = selection;\n\t\tfinal TaskListView taskListView = view;\n\t\tfinal MenuManager subMenuManager = new MenuManager(LABEL_REMINDER);\n\t\tif (selectedElement instanceof ITask) {\n\t\t\ttask = (ITask) selectedElement;\n\t\t} else if (selectedElement instanceof AbstractQueryHit) {\n\t\t\tif (((AbstractQueryHit) selectedElement).getCorrespondingTask() != null) {\n\t\t\t\ttask = ((AbstractQueryHit) selectedElement).getCorrespondingTask();\n\t\t\t}\n\t\t}\n\t\tAction action = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tCalendar reminderCalendar = GregorianCalendar.getInstance();\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setScheduledToday(reminderCalendar);\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_TODAY);\n\t\taction.setEnabled(canSchedule());\n\t\tsubMenuManager.add(action);\n\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderToday(task)) {\n\t\t\taction.setChecked(true);\n\t\t}\n\t\tsubMenuManager.add(new Separator());\n\t\tfinal int today = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);\n\t\tboolean reachedEndOfWeek = false;\n\t\tfor (int i = today+1; i <= 8 && !reachedEndOfWeek; i++) {\n\t\t\tfinal int day = i;\n\t\t\taction = new Action() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tCalendar reminderCalendar = GregorianCalendar.getInstance();\n\t\t\t\t\tint dueIn = day-today;\n\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().setSecheduledIn(reminderCalendar, dueIn);\n\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());\n\t\t\t\t}\n\t\t\t};\n\t\t\tgetDayLabel(i, action);\n\t\t\tint tasksCheduledOn = task.getReminderDate().getDay();\n\t\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderThisWeek(task)) { \n\t\t\t\tif (tasksCheduledOn+1 == day) {\n\t\t\t\t\taction.setChecked(true);\n\t\t\t\t} else if (tasksCheduledOn ==0 && day == 8) {\n\t\t\t\t\taction.setChecked(true);\n\t\t\t\t}\n\t\t\t}\n\t\t\taction.setEnabled(canSchedule());\n\t\t\tsubMenuManager.add(action);\t\n\t\t}\n\t\tsubMenuManager.add(new Separator());\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task,\n\t\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().getActivityNextWeek().getStart().getTime());\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_NEXT_WEEK);\n\t\taction.setEnabled(canSchedule());\n\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderAfterThisWeek(task) &&\n\t\t\t!MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {\n\t\t\taction.setChecked(true);\n\t\t}\n\t\tsubMenuManager.add(action);\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task,\n\t\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().getActivityFuture().getStart().getTime());\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_FUTURE);\n\t\taction.setEnabled(canSchedule());\n\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {\n\t\t\taction.setChecked(true);\n\t\t}\n\t\tsubMenuManager.add(action);\n\t\tsubMenuManager.add(new Separator());\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tCalendar theCalendar = GregorianCalendar.getInstance();\n\t\t\t\tif(task.getReminderDate() != null) {\n\t\t\t\t\ttheCalendar.setTime(task.getReminderDate());\n\t\t\t\t}\n\t\t\t\tDateSelectionDialog reminderDialog = new DateSelectionDialog(taskListView.getSite().getShell(), theCalendar, ReminderCellEditor.REMINDER_DIALOG_TITLE);\n\t\t\t\tint result = reminderDialog.open();\n\t\t\t\tif (result == Window.OK) {\n\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, reminderDialog.getDate());\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_CALENDAR);\n\t\taction.setEnabled(canSchedule());\n\t\tsubMenuManager.add(action);\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, null);\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_CLEAR);\n\t\taction.setEnabled(task != null);\n\t\tsubMenuManager.add(action);\n\t\treturn subMenuManager;\n\t}\n", "output": "\tpublic MenuManager getSubMenuManager(TaskListView view, ITaskListElement selection) {\n\t\tfinal ITaskListElement selectedElement = selection;\n\t\tfinal TaskListView taskListView = view;\n\t\tfinal MenuManager subMenuManager = new MenuManager(LABEL_REMINDER);\n\t\tif (selectedElement instanceof ITask) {\n\t\t\ttask = (ITask) selectedElement;\n\t\t} else if (selectedElement instanceof AbstractQueryHit) {\n\t\t\tif (((AbstractQueryHit) selectedElement).getCorrespondingTask() != null) {\n\t\t\t\ttask = ((AbstractQueryHit) selectedElement).getCorrespondingTask();\n\t\t\t}\n\t\t}\n\t\tAction action = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tCalendar reminderCalendar = GregorianCalendar.getInstance();\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setScheduledToday(reminderCalendar);\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_TODAY);\n\t\taction.setEnabled(canSchedule());\n\t\tsubMenuManager.add(action);\n\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderToday(task)) {\n\t\t\taction.setChecked(true);\n\t\t}\n\t\tsubMenuManager.add(new Separator());\n\t\tfinal int today = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);\n\t\tboolean reachedEndOfWeek = false;\n\t\tfor (int i = today+1; i <= 8 && !reachedEndOfWeek; i++) {\n\t\t\tfinal int day = i;\n\t\t\taction = new Action() {\n\t\t\t\t@Override\n\t\t\t\tpublic void run() {\n\t\t\t\t\tCalendar reminderCalendar = GregorianCalendar.getInstance();\n\t\t\t\t\tint dueIn = day-today;\n\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().setSecheduledIn(reminderCalendar, dueIn);\n\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, reminderCalendar.getTime());\n\t\t\t\t}\n\t\t\t};\n\t\t\tgetDayLabel(i, action);\n\t\t\tif (task != null) {\n\t\t\t\tint tasksCheduledOn = task.getReminderDate().getDay();\n\t\t\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderThisWeek(task)) { \n\t\t\t\t\tif (tasksCheduledOn+1 == day) {\n\t\t\t\t\t\taction.setChecked(true);\n\t\t\t\t\t} else if (tasksCheduledOn ==0 && day == 8) {\n\t\t\t\t\t\taction.setChecked(true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\taction.setEnabled(canSchedule());\n\t\t\tsubMenuManager.add(action);\t\n\t\t}\n\t\tsubMenuManager.add(new Separator());\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task,\n\t\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().getActivityNextWeek().getStart().getTime());\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_NEXT_WEEK);\n\t\taction.setEnabled(canSchedule());\n\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderAfterThisWeek(task) &&\n\t\t\t!MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {\n\t\t\taction.setChecked(true);\n\t\t}\n\t\tsubMenuManager.add(action);\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task,\n\t\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().getActivityFuture().getStart().getTime());\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_FUTURE);\n\t\taction.setEnabled(canSchedule());\n\t\tif (MylarTaskListPlugin.getTaskListManager().isReminderLater(task)) {\n\t\t\taction.setChecked(true);\n\t\t}\n\t\tsubMenuManager.add(action);\n\t\tsubMenuManager.add(new Separator());\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tCalendar theCalendar = GregorianCalendar.getInstance();\n\t\t\t\tif(task.getReminderDate() != null) {\n\t\t\t\t\ttheCalendar.setTime(task.getReminderDate());\n\t\t\t\t}\n\t\t\t\tDateSelectionDialog reminderDialog = new DateSelectionDialog(taskListView.getSite().getShell(), theCalendar, ReminderCellEditor.REMINDER_DIALOG_TITLE);\n\t\t\t\tint result = reminderDialog.open();\n\t\t\t\tif (result == Window.OK) {\n\t\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, reminderDialog.getDate());\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_CALENDAR);\n\t\taction.setEnabled(canSchedule());\n\t\tsubMenuManager.add(action);\n\t\taction = new Action() {\n\t\t\t@Override\n\t\t\tpublic void run() {\n\t\t\t\tMylarTaskListPlugin.getTaskListManager().setReminder(task, null);\n\t\t\t}\n\t\t};\n\t\taction.setText(LABEL_CLEAR);\n\t\taction.setEnabled(task != null);\n\t\tsubMenuManager.add(action);\n\t\treturn subMenuManager;\n\t}\n"} {"input": " public void addJourney(final Place start, final Place end, final List<String> activities) {\n final List<JourneyStep> steps = JourneyUtil.getSteps(activities);\n final Collection<Journey> journeys = findJourneys(start, end);\n for (Journey journey : journeys) {\n if (journey.getSteps() == steps.size()) {\n final List<JourneyStep> theirSteps = getSteps(journey);\n if (theirSteps.equals(steps)) {\n updateJourneyStatement.bindLong(1, journey.getId());\n updateJourneyStatement.execute();\n return;\n }\n }\n }\n insertJourneyStatement.bindLong(1, start.getId());\n insertJourneyStatement.bindLong(2, end.getId());\n insertJourneyStatement.bindLong(3, steps.size());\n final long id = insertJourneyStatement.executeInsert();\n long next = 0;\n for (int i = steps.size() - 1; i >= 0; i--) {\n final JourneyStep step = steps.get(i);\n insertJourneyStepStatement.bindString(1, step.getActivity());\n insertJourneyStepStatement.bindLong(2, step.getRepetitions());\n insertJourneyStepStatement.bindLong(3, id);\n insertJourneyStepStatement.bindLong(4, next);\n next = insertJourneyStepStatement.executeInsert();\n }\n }\n", "output": " public void addJourney(final Place start, final Place end, final List<String> activities) {\n final List<JourneyStep> steps = JourneyUtil.getSteps(activities);\n final Collection<Journey> journeys = findJourneys(start, end);\n for (Journey journey : journeys) {\n if (journey.getSteps() == steps.size()) {\n final List<JourneyStep> theirSteps = getSteps(journey);\n if (JourneyUtil.isCompatible(steps, theirSteps)) {\n updateJourneyStatement.bindLong(1, journey.getId());\n updateJourneyStatement.execute();\n return;\n }\n }\n }\n insertJourneyStatement.bindLong(1, start.getId());\n insertJourneyStatement.bindLong(2, end.getId());\n insertJourneyStatement.bindLong(3, steps.size());\n final long id = insertJourneyStatement.executeInsert();\n long next = 0;\n for (int i = steps.size() - 1; i >= 0; i--) {\n final JourneyStep step = steps.get(i);\n insertJourneyStepStatement.bindString(1, step.getActivity());\n insertJourneyStepStatement.bindLong(2, step.getRepetitions());\n insertJourneyStepStatement.bindLong(3, id);\n insertJourneyStepStatement.bindLong(4, next);\n next = insertJourneyStepStatement.executeInsert();\n }\n }\n"} {"input": " protected Stats executeMySQLImpl() {\n String readQuery = \"SELECT name FROM ReadWriteTest WHERE id = 1\";\n String writeUpdate = \"UPDATE users SET name = '%s' WHERE id = 1\";\n List<Long> readAfterWriteTimes = new ArrayList<Long>(TIMES);\n List<Long> writeAfterReadTimes = new ArrayList<Long>(TIMES);\n Statement statement = null;\n ResultSet results = null;\n try {\n statement = conn.createStatement();\n long time = System.currentTimeMillis();\n for (int i = 0; i < TIMES; i++) {\n results = statement.executeQuery(readQuery);\n if (i != 0) {\n readAfterWriteTimes.add(System.currentTimeMillis() - time);\n }\n time = System.currentTimeMillis();\n statement.executeUpdate(String.format(writeUpdate, randomStrings[i]));\n writeAfterReadTimes.add(System.currentTimeMillis() - time);\n time = System.currentTimeMillis();\n }\n } catch (Exception ex) {\n System.err.println(\"Error getting read/write times.\");\n ex.printStackTrace(System.err);\n } finally {\n try {\n if (results != null) {\n results.close();\n results = null;\n }\n if (statement != null) {\n statement.close();\n statement = null;\n }\n } catch (SQLException sqlEx) {\n System.err.println(\"Error Closing results.\");\n }\n }\n return new ReadWriteStats(readAfterWriteTimes, writeAfterReadTimes);\n }\n", "output": " protected Stats executeMySQLImpl() {\n String readQuery = \"SELECT name FROM ReadWriteTest WHERE id = 1\";\n String writeUpdate = \"UPDATE ReadWriteTest SET name = '%s' WHERE id = 1\";\n List<Long> readAfterWriteTimes = new ArrayList<Long>(TIMES);\n List<Long> writeAfterReadTimes = new ArrayList<Long>(TIMES);\n Statement statement = null;\n ResultSet results = null;\n try {\n statement = conn.createStatement();\n long time = System.currentTimeMillis();\n for (int i = 0; i < TIMES; i++) {\n results = statement.executeQuery(readQuery);\n if (i != 0) {\n readAfterWriteTimes.add(System.currentTimeMillis() - time);\n }\n time = System.currentTimeMillis();\n statement.executeUpdate(String.format(writeUpdate, randomStrings[i]));\n writeAfterReadTimes.add(System.currentTimeMillis() - time);\n time = System.currentTimeMillis();\n }\n } catch (Exception ex) {\n System.err.println(\"Error getting read/write times.\");\n ex.printStackTrace(System.err);\n } finally {\n try {\n if (results != null) {\n results.close();\n results = null;\n }\n if (statement != null) {\n statement.close();\n statement = null;\n }\n } catch (SQLException sqlEx) {\n System.err.println(\"Error Closing results.\");\n }\n }\n return new ReadWriteStats(readAfterWriteTimes, writeAfterReadTimes);\n }\n"} {"input": " private long getTimeForSituation(SituationBean bean) {\n TimeRangeBean window = bean.getPublicationWindow();\n if (window != null && window.getFrom() != 0)\n return window.getFrom();\n if (CollectionsLibrary.isEmpty(bean.getConsequences())) {\n long t = Long.MAX_VALUE;\n for (SituationConsequenceBean consequence : bean.getConsequences()) {\n TimeRangeBean period = consequence.getPeriod();\n if (period != null && period.getFrom() != 0)\n t = Math.min(t, period.getFrom());\n }\n if (t != Long.MAX_VALUE)\n return t;\n }\n return bean.getCreationTime();\n }\n", "output": " private long getTimeForSituation(SituationBean bean) {\n TimeRangeBean window = bean.getPublicationWindow();\n if (window != null && window.getFrom() != 0)\n return window.getFrom();\n if (! CollectionsLibrary.isEmpty(bean.getConsequences())) {\n long t = Long.MAX_VALUE;\n for (SituationConsequenceBean consequence : bean.getConsequences()) {\n TimeRangeBean period = consequence.getPeriod();\n if (period != null && period.getFrom() != 0)\n t = Math.min(t, period.getFrom());\n }\n if (t != Long.MAX_VALUE)\n return t;\n }\n return bean.getCreationTime();\n }\n"} {"input": "\tpublic void testContributeWithBadContributorId() {\n\t\ttry {\n\t\t\tcounter.contribute(digitalCard, new UserUrl(\"bob\", \"deus.org\"));\n\t\t\tfail(\"contribution with different contributor id than in the DC is possible\");\n\t\t}\n\t\tcatch(RuntimeException e) {\n\t\t\tassertEquals(\"ID of the contributor does not match the id in the digital card!\", e.getMessage());\n\t\t}\n\t}\n", "output": "\tpublic void testContributeWithBadContributorId() {\n\t\ttry {\n\t\t\tcounter.contributeOther(digitalCard, new UserUrl(\"bob\", \"deus.org\"));\n\t\t\tfail(\"contribution with different contributor id than in the DC is possible\");\n\t\t}\n\t\tcatch(RuntimeException e) {\n\t\t\tassertEquals(\"ID of the contributor does not match the id in the digital card!\", e.getMessage());\n\t\t}\n\t}\n"} {"input": " public void processEndOfRound() {\n InternalObject[] gameObjects = new InternalObject[gameObjectsByID.size()];\n gameObjects = gameObjectsByID.values().toArray(gameObjects);\n for (int i = 0; i < gameObjects.length; i++) {\n gameObjects[i].processEndOfRound();\n }\n\t\tif(timeLimitReached()&&winner==null) {\n\t\t\tList<InternalPowerNode> teamANodes = new ArrayList<InternalPowerNode>(connectedNodesByTeam.get(Team.A));\n\t\t\tList<InternalPowerNode> teamBNodes = new ArrayList<InternalPowerNode>(connectedNodesByTeam.get(Team.B));\n\t\t\tInternalRobot tower;\n\t\t\tfor(InternalPowerNode n : teamANodes) {\n\t\t\t\ttower = nodeToTower(n);\n\t\t\t\tif(tower!=null)\n\t\t\t\t\ttower.takeDamage(GameConstants.TIME_LIMIT_DAMAGE/teamANodes.size());\n\t\t\t}\n\t\t\tfor(InternalPowerNode n : teamBNodes) {\n\t\t\t\ttower = nodeToTower(n);\n\t\t\t\tif(tower!=null)\n\t\t\t\t\ttower.takeDamage(GameConstants.TIME_LIMIT_DAMAGE/teamBNodes.size());\n\t\t\t}\n\t\t\tremoveDead();\n\t\t\tif(nodeToTower(baseNodes.get(Team.A))==null&&nodeToTower(baseNodes.get(Team.B))==null) {\n\t\t\t\trunning=false;\n\t\t\t\tint diff=0;\n\t\t\t\tfor(InternalPowerNode p : powerNodes) {\n\t\t\t\t\tif(p.getControllingTeam()==Team.A)\n\t\t\t\t\t\tdiff++;\n\t\t\t\t\telse if(p.getControllingTeam()==Team.B)\n\t\t\t\t\t\tdiff--;\n\t\t\t\t}\n\t\t\t\tif(!(setWinnerIfNonzero(diff,DominationFactor.BARELY_BEAT)||\n\t\t\t\t\tsetWinnerIfNonzero(archons.get(Team.A).size()-archons.get(Team.B).size(),DominationFactor.BARELY_BEAT)||\n\t\t\t\t\tsetWinnerIfNonzero(getEnergonDifference(),DominationFactor.BARELY_BEAT)))\n\t\t\t\t{\n\t\t\t\t\tif(teamAName.compareTo(teamBName)<=0)\n\t\t\t\t\t\tsetWinner(Team.A,DominationFactor.WON_BY_DUBIOUS_REASONS);\n\t\t\t\t\telse\n\t\t\t\t\t\tsetWinner(Team.B,DominationFactor.WON_BY_DUBIOUS_REASONS);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n long aPoints = Math.round(teamRoundResources[Team.A.ordinal()] * 100), bPoints = Math.round(teamRoundResources[Team.B.ordinal()] * 100);\n roundStats = new RoundStats(teamResources[0] * 100, teamResources[1] * 100, teamRoundResources[0] * 100, teamRoundResources[1] * 100);\n lastRoundResources = teamRoundResources;\n teamRoundResources = new double[2];\n }\n", "output": " public void processEndOfRound() {\n InternalObject[] gameObjects = new InternalObject[gameObjectsByID.size()];\n gameObjects = gameObjectsByID.values().toArray(gameObjects);\n for (int i = 0; i < gameObjects.length; i++) {\n gameObjects[i].processEndOfRound();\n }\n\t\tremoveDead();\n\t\tif(timeLimitReached()&&winner==null) {\n\t\t\tList<InternalPowerNode> teamANodes = new ArrayList<InternalPowerNode>(connectedNodesByTeam.get(Team.A));\n\t\t\tList<InternalPowerNode> teamBNodes = new ArrayList<InternalPowerNode>(connectedNodesByTeam.get(Team.B));\n\t\t\tInternalRobot tower;\n\t\t\tfor(InternalPowerNode n : teamANodes) {\n\t\t\t\ttower = nodeToTower(n);\n\t\t\t\tif(tower!=null)\n\t\t\t\t\ttower.takeDamage(GameConstants.TIME_LIMIT_DAMAGE/teamANodes.size());\n\t\t\t}\n\t\t\tfor(InternalPowerNode n : teamBNodes) {\n\t\t\t\ttower = nodeToTower(n);\n\t\t\t\tif(tower!=null)\n\t\t\t\t\ttower.takeDamage(GameConstants.TIME_LIMIT_DAMAGE/teamBNodes.size());\n\t\t\t}\n\t\t\tremoveDead();\n\t\t\tif(nodeToTower(baseNodes.get(Team.A))==null&&nodeToTower(baseNodes.get(Team.B))==null) {\n\t\t\t\trunning=false;\n\t\t\t\tint diff=0;\n\t\t\t\tfor(InternalPowerNode p : powerNodes) {\n\t\t\t\t\tif(p.getControllingTeam()==Team.A)\n\t\t\t\t\t\tdiff++;\n\t\t\t\t\telse if(p.getControllingTeam()==Team.B)\n\t\t\t\t\t\tdiff--;\n\t\t\t\t}\n\t\t\t\tif(!(setWinnerIfNonzero(diff,DominationFactor.BARELY_BEAT)||\n\t\t\t\t\tsetWinnerIfNonzero(archons.get(Team.A).size()-archons.get(Team.B).size(),DominationFactor.BARELY_BEAT)||\n\t\t\t\t\tsetWinnerIfNonzero(getEnergonDifference(),DominationFactor.BARELY_BEAT)))\n\t\t\t\t{\n\t\t\t\t\tif(teamAName.compareTo(teamBName)<=0)\n\t\t\t\t\t\tsetWinner(Team.A,DominationFactor.WON_BY_DUBIOUS_REASONS);\n\t\t\t\t\telse\n\t\t\t\t\t\tsetWinner(Team.B,DominationFactor.WON_BY_DUBIOUS_REASONS);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n long aPoints = Math.round(teamRoundResources[Team.A.ordinal()] * 100), bPoints = Math.round(teamRoundResources[Team.B.ordinal()] * 100);\n roundStats = new RoundStats(teamResources[0] * 100, teamResources[1] * 100, teamRoundResources[0] * 100, teamRoundResources[1] * 100);\n lastRoundResources = teamRoundResources;\n teamRoundResources = new double[2];\n }\n"} {"input": " private void describeKeySpace(String keySpaceName, KsDef metadata) throws TException\n {\n NodeProbe probe = sessionState.getNodeProbe();\n CompactionManagerMBean compactionManagerMBean = (probe == null) ? null : probe.getCompactionManagerProxy();\n sessionState.out.println(\"Keyspace: \" + keySpaceName + \":\");\n try\n {\n KsDef ks_def;\n ks_def = metadata == null ? thriftClient.describe_keyspace(keySpaceName) : metadata;\n sessionState.out.println(\" Replication Strategy: \" + ks_def.strategy_class);\n if (ks_def.strategy_class.endsWith(\".NetworkTopologyStrategy\"))\n {\n Map<String, String> options = ks_def.strategy_options;\n sessionState.out.println(\" Options: [\" + ((options == null) ? \"\" : FBUtilities.toString(options)) + \"]\");\n }\n else\n {\n sessionState.out.println(\" Replication Factor: \" + ks_def.replication_factor);\n }\n sessionState.out.println(\" Column Families:\");\n boolean isSuper;\n Collections.sort(ks_def.cf_defs, new CfDefNamesComparator());\n for (CfDef cf_def : ks_def.cf_defs)\n {\n ColumnFamilyStoreMBean cfMBean = (probe == null) ? null : probe.getCfsProxy(ks_def.getName(), cf_def.getName());\n isSuper = cf_def.column_type.equals(\"Super\");\n sessionState.out.printf(\" ColumnFamily: %s%s%n\", cf_def.name, isSuper ? \" (Super)\" : \"\");\n if (cf_def.comment != null && !cf_def.comment.isEmpty())\n {\n sessionState.out.printf(\" \\\"%s\\\"%n\", cf_def.comment);\n }\n if (cf_def.default_validation_class != null)\n sessionState.out.printf(\" default_validation_class: %s%n\", cf_def.default_validation_class);\n sessionState.out.printf(\" Columns sorted by: %s%s%n\", cf_def.comparator_type, cf_def.column_type.equals(\"Super\") ? \"/\" + cf_def.subcomparator_type : \"\");\n sessionState.out.printf(\" Row cache size / save period in seconds: %s/%s%n\", cf_def.row_cache_size, cf_def.row_cache_save_period_in_seconds);\n sessionState.out.printf(\" Key cache size / save period in seconds: %s/%s%n\", cf_def.key_cache_size, cf_def.key_cache_save_period_in_seconds);\n sessionState.out.printf(\" Memtable thresholds: %s/%s/%s (millions of ops/minutes/MB)%n\",\n cf_def.memtable_operations_in_millions, cf_def.memtable_throughput_in_mb, cf_def.memtable_flush_after_mins);\n sessionState.out.printf(\" GC grace seconds: %s%n\", cf_def.gc_grace_seconds);\n sessionState.out.printf(\" Compaction min/max thresholds: %s/%s%n\", cf_def.min_compaction_threshold, cf_def.max_compaction_threshold);\n sessionState.out.printf(\" Read repair chance: %s%n\", cf_def.read_repair_chance);\n if (cfMBean != null)\n {\n sessionState.out.printf(\" Built indexes: %s%n\", cfMBean.getBuiltIndexes());\n }\n if (cf_def.getColumn_metadataSize() != 0)\n {\n String leftSpace = \" \";\n String columnLeftSpace = leftSpace + \" \";\n AbstractType columnNameValidator = getFormatTypeForColumn(isSuper ? cf_def.subcomparator_type\n : cf_def.comparator_type);\n sessionState.out.println(leftSpace + \"Column Metadata:\");\n for (ColumnDef columnDef : cf_def.getColumn_metadata())\n {\n String columnName = columnNameValidator.getString(columnDef.name);\n if (columnNameValidator instanceof BytesType)\n {\n try\n {\n String columnString = UTF8Type.instance.getString(columnDef.name);\n columnName = columnString + \" (\" + columnName + \")\";\n }\n catch (MarshalException e)\n {\n }\n }\n sessionState.out.println(leftSpace + \" Column Name: \" + columnName);\n sessionState.out.println(columnLeftSpace + \"Validation Class: \" + columnDef.getValidation_class());\n if (columnDef.isSetIndex_name())\n {\n sessionState.out.println(columnLeftSpace + \"Index Name: \" + columnDef.getIndex_name());\n }\n if (columnDef.isSetIndex_type())\n {\n sessionState.out.println(columnLeftSpace + \"Index Type: \" + columnDef.getIndex_type().name());\n }\n }\n }\n }\n if (compactionManagerMBean != null)\n {\n String compactionType = compactionManagerMBean.getCompactionType();\n if (compactionType != null && compactionType.contains(\"index build\"))\n {\n String indexName = compactionManagerMBean.getColumnFamilyInProgress();\n long bytesCompacted = compactionManagerMBean.getBytesCompacted();\n long totalBytesToProcess = compactionManagerMBean.getBytesTotalInProgress();\n sessionState.out.printf(\"%nCurrently building index %s, completed %d of %d bytes.%n\", indexName, bytesCompacted, totalBytesToProcess);\n }\n }\n if (probe != null)\n probe.close();\n }\n catch (InvalidRequestException e)\n {\n sessionState.out.println(\"Invalid request: \" + e);\n }\n catch (NotFoundException e)\n {\n sessionState.out.println(\"Keyspace \" + keySpaceName + \" could not be found.\");\n }\n catch (IOException e)\n {\n sessionState.out.println(\"Error while closing JMX connection: \" + e.getMessage());\n }\n }\n", "output": " private void describeKeySpace(String keySpaceName, KsDef metadata) throws TException\n {\n NodeProbe probe = sessionState.getNodeProbe();\n CompactionManagerMBean compactionManagerMBean = (probe == null) ? null : probe.getCompactionManagerProxy();\n sessionState.out.println(\"Keyspace: \" + keySpaceName + \":\");\n try\n {\n KsDef ks_def;\n ks_def = metadata == null ? thriftClient.describe_keyspace(keySpaceName) : metadata;\n sessionState.out.println(\" Replication Strategy: \" + ks_def.strategy_class);\n if (ks_def.strategy_class.endsWith(\".NetworkTopologyStrategy\"))\n {\n Map<String, String> options = ks_def.strategy_options;\n sessionState.out.println(\" Options: [\" + ((options == null) ? \"\" : FBUtilities.toString(options)) + \"]\");\n }\n else\n {\n sessionState.out.println(\" Replication Factor: \" + ks_def.replication_factor);\n }\n sessionState.out.println(\" Column Families:\");\n boolean isSuper;\n Collections.sort(ks_def.cf_defs, new CfDefNamesComparator());\n for (CfDef cf_def : ks_def.cf_defs)\n {\n ColumnFamilyStoreMBean cfMBean = (probe == null) ? null : probe.getCfsProxy(ks_def.getName(), cf_def.getName());\n isSuper = cf_def.column_type.equals(\"Super\");\n sessionState.out.printf(\" ColumnFamily: %s%s%n\", cf_def.name, isSuper ? \" (Super)\" : \"\");\n if (cf_def.comment != null && !cf_def.comment.isEmpty())\n {\n sessionState.out.printf(\" \\\"%s\\\"%n\", cf_def.comment);\n }\n if (cf_def.default_validation_class != null)\n sessionState.out.printf(\" default_validation_class: %s%n\", cf_def.default_validation_class);\n sessionState.out.printf(\" Columns sorted by: %s%s%n\", cf_def.comparator_type, cf_def.column_type.equals(\"Super\") ? \"/\" + cf_def.subcomparator_type : \"\");\n sessionState.out.printf(\" Row cache size / save period in seconds: %s/%s%n\", cf_def.row_cache_size, cf_def.row_cache_save_period_in_seconds);\n sessionState.out.printf(\" Key cache size / save period in seconds: %s/%s%n\", cf_def.key_cache_size, cf_def.key_cache_save_period_in_seconds);\n sessionState.out.printf(\" Memtable thresholds: %s/%s/%s (millions of ops/minutes/MB)%n\",\n cf_def.memtable_operations_in_millions, cf_def.memtable_flush_after_mins, cf_def.memtable_throughput_in_mb);\n sessionState.out.printf(\" GC grace seconds: %s%n\", cf_def.gc_grace_seconds);\n sessionState.out.printf(\" Compaction min/max thresholds: %s/%s%n\", cf_def.min_compaction_threshold, cf_def.max_compaction_threshold);\n sessionState.out.printf(\" Read repair chance: %s%n\", cf_def.read_repair_chance);\n if (cfMBean != null)\n {\n sessionState.out.printf(\" Built indexes: %s%n\", cfMBean.getBuiltIndexes());\n }\n if (cf_def.getColumn_metadataSize() != 0)\n {\n String leftSpace = \" \";\n String columnLeftSpace = leftSpace + \" \";\n AbstractType columnNameValidator = getFormatTypeForColumn(isSuper ? cf_def.subcomparator_type\n : cf_def.comparator_type);\n sessionState.out.println(leftSpace + \"Column Metadata:\");\n for (ColumnDef columnDef : cf_def.getColumn_metadata())\n {\n String columnName = columnNameValidator.getString(columnDef.name);\n if (columnNameValidator instanceof BytesType)\n {\n try\n {\n String columnString = UTF8Type.instance.getString(columnDef.name);\n columnName = columnString + \" (\" + columnName + \")\";\n }\n catch (MarshalException e)\n {\n }\n }\n sessionState.out.println(leftSpace + \" Column Name: \" + columnName);\n sessionState.out.println(columnLeftSpace + \"Validation Class: \" + columnDef.getValidation_class());\n if (columnDef.isSetIndex_name())\n {\n sessionState.out.println(columnLeftSpace + \"Index Name: \" + columnDef.getIndex_name());\n }\n if (columnDef.isSetIndex_type())\n {\n sessionState.out.println(columnLeftSpace + \"Index Type: \" + columnDef.getIndex_type().name());\n }\n }\n }\n }\n if (compactionManagerMBean != null)\n {\n String compactionType = compactionManagerMBean.getCompactionType();\n if (compactionType != null && compactionType.contains(\"index build\"))\n {\n String indexName = compactionManagerMBean.getColumnFamilyInProgress();\n long bytesCompacted = compactionManagerMBean.getBytesCompacted();\n long totalBytesToProcess = compactionManagerMBean.getBytesTotalInProgress();\n sessionState.out.printf(\"%nCurrently building index %s, completed %d of %d bytes.%n\", indexName, bytesCompacted, totalBytesToProcess);\n }\n }\n if (probe != null)\n probe.close();\n }\n catch (InvalidRequestException e)\n {\n sessionState.out.println(\"Invalid request: \" + e);\n }\n catch (NotFoundException e)\n {\n sessionState.out.println(\"Keyspace \" + keySpaceName + \" could not be found.\");\n }\n catch (IOException e)\n {\n sessionState.out.println(\"Error while closing JMX connection: \" + e.getMessage());\n }\n }\n"} {"input": " public void scan(Collection<InputFile> files) {\n SourceProject project = new SourceProject(\"Java Project\");\n index.index(project);\n project.setSourceCodeIndexer(index);\n VisitorContext context = new VisitorContext(project);\n context.setCommentAnalyser(commentAnalyser);\n for (SquidAstVisitor<LexerlessGrammar> visitor : visitors) {\n visitor.setContext(context);\n visitor.init();\n }\n AstWalker astWalker = new AstWalker(visitors);\n ProgressReport progressReport = new ProgressReport(\"Report about progress of Java AST analyzer\", TimeUnit.SECONDS.toMillis(10));\n progressReport.start(files.size() + \" source files to be analyzed\");\n int count = 0;\n for (InputFile inputFile : files) {\n File file = inputFile.getFile();\n progressReport.message(count + \"/\" + files.size() + \" files analyzed, current is \" + file.getAbsolutePath());\n count++;\n context.setFile(file);\n context.setInputFile(inputFile);\n try {\n AstNode ast = parser.parse(file);\n astWalker.walkAndVisit(ast);\n } catch (RecognitionException e) {\n LOG.error(\"Unable to parse source file : \" + file.getAbsolutePath());\n LOG.error(e.getMessage(), e);\n parseErrorWalkAndVisit(e, file);\n } catch (Exception e) {\n throw new AnalysisException(getAnalyisExceptionMessage(file), e);\n }\n }\n progressReport.stop(files.size() + \"/\" + files.size() + \" source files analyzed\");\n for (SquidAstVisitor<LexerlessGrammar> visitor : visitors) {\n visitor.destroy();\n }\n SourceCodeTreeDecorator decorator = new SourceCodeTreeDecorator(project);\n decorator.decorateWith(JavaMetric.values());\n decorator.decorateWith(org.sonar.squid.measures.Metric.values());\n }\n", "output": " public void scan(Collection<InputFile> files) {\n SourceProject project = new SourceProject(\"Java Project\");\n index.index(project);\n project.setSourceCodeIndexer(index);\n VisitorContext context = new VisitorContext(project);\n context.setCommentAnalyser(commentAnalyser);\n for (SquidAstVisitor<LexerlessGrammar> visitor : visitors) {\n visitor.setContext(context);\n visitor.init();\n }\n AstWalker astWalker = new AstWalker(visitors);\n ProgressReport progressReport = new ProgressReport(\"Report about progress of Java AST analyzer\", TimeUnit.SECONDS.toMillis(10));\n progressReport.start(files.size() + \" source files to be analyzed\");\n int count = 0;\n for (InputFile inputFile : files) {\n File file = inputFile.getFile();\n progressReport.message(count + \"/\" + files.size() + \" files analyzed, current is \" + file.getAbsolutePath());\n count++;\n context.setFile(file);\n context.setInputFile(inputFile);\n try {\n AstNode ast = parser.parse(file);\n astWalker.walkAndVisit(ast);\n } catch (RecognitionException e) {\n LOG.error(\"Unable to parse source file : \" + file.getAbsolutePath());\n LOG.error(e.getMessage());\n parseErrorWalkAndVisit(e, file);\n } catch (Exception e) {\n throw new AnalysisException(getAnalyisExceptionMessage(file), e);\n }\n }\n progressReport.stop(files.size() + \"/\" + files.size() + \" source files analyzed\");\n for (SquidAstVisitor<LexerlessGrammar> visitor : visitors) {\n visitor.destroy();\n }\n SourceCodeTreeDecorator decorator = new SourceCodeTreeDecorator(project);\n decorator.decorateWith(JavaMetric.values());\n decorator.decorateWith(org.sonar.squid.measures.Metric.values());\n }\n"} {"input": " public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDefinition) {\n ScopeMetadata meta = new ScopeMetadata();\n meta.setScopedProxyMode(ScopedProxyMode.INTERFACES);\n meta.setScopeName(\"prototype\");\n return meta;\n }\n", "output": " public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDefinition) {\n ScopeMetadata meta = new ScopeMetadata();\n meta.setScopedProxyMode(ScopedProxyMode.NO);\n meta.setScopeName(\"prototype\");\n return meta;\n }\n"} {"input": " public void eventFired(EventObject event) {\n\t\tif (event instanceof ChangeEvent) {\n\t\t\tfinal ChangeEvent changeEvent = (ChangeEvent)event;\n\t\t\tfinal Object source = changeEvent.getSource();\n\t\t\tif (source instanceof IModel) {\n\t\t\t\tIPeerModel node = (IPeerModel)((IModel)source).getAdapter(IPeerModel.class);\n\t\t\t\trefresh(node, false);\n\t\t\t}\n\t\t\telse if (source instanceof IModelNode) {\n\t\t\t\tif (\"expanded\".equals(changeEvent.getEventId())) { \n\t\t\t\t\tboolean expanded = ((Boolean)changeEvent.getNewValue()).booleanValue();\n\t\t\t\t\tgetViewer().setExpandedState(source, expanded);\n\t\t\t\t} else {\n\t\t\t\t\trefresh(source, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": " public void eventFired(EventObject event) {\n\t\tif (event instanceof ChangeEvent) {\n\t\t\tfinal ChangeEvent changeEvent = (ChangeEvent)event;\n\t\t\tfinal Object source = changeEvent.getSource();\n\t\t\tif (source instanceof IModel) {\n\t\t\t\tIPeerModel node = (IPeerModel)((IModel)source).getAdapter(IPeerModel.class);\n\t\t\t\trefresh(node, false);\n\t\t\t}\n\t\t\telse if (source instanceof IModelNode) {\n\t\t\t\tif (\"expanded\".equals(changeEvent.getEventId())) { \n\t\t\t\t\tboolean expanded = ((Boolean)changeEvent.getNewValue()).booleanValue();\n\t\t\t\t\tif (getViewer() != null) getViewer().setExpandedState(source, expanded);\n\t\t\t\t} else {\n\t\t\t\t\trefresh(source, false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {\n super.load(pluginInfo, graph);\n setObjectGraph(graph.plus(new LoggingModule(pluginInfo.getDomain())));\n manager = getObjectGraph().get(LoggingManager.class);\n registerCommand(LoggingCommand.class, LoggingCommand.INFO);\n }\n", "output": " public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {\n super.load(pluginInfo, graph);\n setObjectGraph(graph.plus(new LoggingModule(pluginInfo)));\n manager = getObjectGraph().get(LoggingManager.class);\n registerCommand(LoggingCommand.class, LoggingCommand.INFO);\n }\n"} {"input": " public void testWaitAndSignal() throws InterruptedException {\n WaitingThread thread = new WaitingThread(_semaphore, 0);\n thread.start();\n Thread.sleep(1);\n assertFalse(\"The thread should be waiting.\", thread.hasFinished());\n _semaphore.signalEvent();\n Thread.sleep(1);\n assertTrue(\"The thread should have finished.\", thread.hasFinished());\n }\n", "output": " public void testWaitAndSignal() throws InterruptedException {\n WaitingThread thread = new WaitingThread(_semaphore, 0);\n thread.start();\n Thread.sleep(2);\n assertFalse(\"The thread should be waiting.\", thread.hasFinished());\n _semaphore.signalEvent();\n Thread.sleep(2);\n assertTrue(\"The thread should have finished.\", thread.hasFinished());\n }\n"} {"input": " public ParameterWindow( TableViewer tv ) {\n super( \"Table Parameters\", tv );\n this.tv = tv;\n this.dataModel = tv.getDataModel();\n this.viewModel = tv.getViewModel();\n this.columnModel = tv.getColumnModel();\n params = new ArrayList();\n pseudoParams = new HashSet();\n uneditableParams = new HashSet();\n DescribedValue nameParam = new DescribedValue( NAME_INFO ) {\n public Object getValue() {\n return dataModel.getName();\n }\n public void setValue( Object value ) {\n String name = value == null ? null : value.toString();\n if ( name.trim().length() == 0 ) {\n name = null;\n }\n dataModel.setName( name );\n }\n };\n params.add( nameParam );\n pseudoParams.add( nameParam );\n URL url = dataModel.getBaseTable().getURL();\n if ( url != null ) {\n DescribedValue urlParam = new DescribedValue( URL_INFO, url );\n params.add( urlParam );\n pseudoParams.add( urlParam );\n uneditableParams.add( urlParam );\n }\n ncolParam = new DescribedValue( NCOL_INFO );\n nrowParam = new DescribedValue( NROW_INFO );\n params.add( ncolParam );\n params.add( nrowParam );\n pseudoParams.add( ncolParam );\n pseudoParams.add( nrowParam );\n uneditableParams.add( ncolParam );\n uneditableParams.add( nrowParam );\n columnModel.addColumnModelListener( new TableColumnModelAdapter() {\n public void columnAdded( TableColumnModelEvent evt ) {\n configureColumnCount();\n }\n public void columnRemoved( TableColumnModelEvent evt ) {\n configureColumnCount();\n }\n } );\n viewModel.addTableModelListener( new TableModelListener() {\n public void tableChanged( TableModelEvent evt ) {\n configureRowCount();\n }\n } );\n ncolRowIndex = params.indexOf( ncolParam );\n nrowRowIndex = params.indexOf( nrowParam );\n for ( Iterator it = dataModel.getParameters().iterator();\n it.hasNext(); ) {\n DescribedValue param = (DescribedValue) it.next();\n params.add( param );\n }\n List metas = new ArrayList();\n metas.add( new MetaColumn( \"Name\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getName();\n }\n } );\n metas.add( new MetaColumn( \"Value\", Object.class ) {\n public Object getValue( int irow ) {\n return getParam( irow ).getValue();\n }\n public boolean isEditable( int irow ) {\n return isEditableParameter( irow );\n }\n public void setValue( int irow, Object value ) {\n getParam( irow ).setValue( value );\n }\n } );\n int classPos = metas.size();\n metas.add( new MetaColumn( \"Class\", String.class ) {\n public Object getValue( int irow ) {\n return DefaultValueInfo\n .formatClass( getParamInfo( irow ).getContentClass() );\n }\n } );\n metas.add( new MetaColumn( \"Shape\", String.class ) {\n public Object getValue( int irow ) {\n return DefaultValueInfo\n .formatShape( getParamInfo( irow ).getShape() );\n }\n } );\n metas.add( new MetaColumn( \"Units\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getUnitString();\n }\n public boolean isEditable( int irow ) {\n return ! isPseudoParameter( irow ) &&\n getParamInfo( irow ) instanceof DefaultValueInfo;\n }\n public void setValue( int irow, Object value ) {\n ((DefaultValueInfo) getParamInfo( irow ))\n .setUnitString( value == null ? null : value.toString() );\n }\n } );\n metas.add( new MetaColumn( \"Description\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getDescription();\n }\n public boolean isEditable( int irow ) {\n return ! isPseudoParameter( irow ) &&\n getParamInfo( irow ) instanceof DefaultValueInfo;\n }\n public void setValue( int irow, Object value ) {\n ((DefaultValueInfo) getParamInfo( irow ))\n .setDescription( value == null ? null : value.toString() );\n }\n } );\n metas.add( new MetaColumn( \"UCD\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getUCD();\n }\n public boolean isEditable( int irow ) {\n return ! isPseudoParameter( irow ) &&\n getParamInfo( irow ) instanceof DefaultValueInfo;\n }\n public void setValue( int irow, Object value ) {\n ((DefaultValueInfo) getParamInfo( irow ))\n .setUCD( value == null ? null : value.toString() );\n }\n } );\n metas.add( new MetaColumn( \"UCD description\", String.class ) {\n public Object getValue( int irow ) {\n String ucdid = getParamInfo( irow ).getUCD();\n if ( ucdid != null ) {\n UCD ucd = UCD.getUCD( dataModel.getColumnInfo( irow )\n .getUCD() );\n if ( ucd != null ) {\n return ucd.getDescription();\n }\n }\n return null;\n }\n } );\n metaTableModel = new MetaColumnTableModel( metas ) {\n public int getRowCount() {\n return params.size();\n }\n };\n JTable jtab = new JTable( metaTableModel );\n jtab.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );\n jtab.setColumnSelectionAllowed( false );\n jtab.setRowSelectionAllowed( true );\n StarJTable.configureColumnWidths( jtab, 20000, 100 );\n MetaColumnModel metaColumnModel =\n new MetaColumnModel( jtab.getColumnModel(), metaTableModel );\n metaColumnModel.purgeEmptyColumns();\n jtab.setColumnModel( metaColumnModel );\n metaColumnModel.removeColumn( classPos );\n configureColumnCount();\n configureRowCount();\n getMainArea().add( new SizingScrollPane( jtab ) );\n setMainHeading( \"Table Metadata\" );\n JMenu displayMenu = metaColumnModel.makeCheckBoxMenu( \"Display\" );\n displayMenu.setMnemonic( KeyEvent.VK_D );\n getJMenuBar().add( displayMenu );\n addHelp( \"ParameterWindow\" );\n pack();\n setVisible( true );\n }\n", "output": " public ParameterWindow( TableViewer tv ) {\n super( \"Table Parameters\", tv );\n this.tv = tv;\n this.dataModel = tv.getDataModel();\n this.viewModel = tv.getViewModel();\n this.columnModel = tv.getColumnModel();\n params = new ArrayList();\n pseudoParams = new HashSet();\n uneditableParams = new HashSet();\n DescribedValue nameParam = new DescribedValue( NAME_INFO ) {\n public Object getValue() {\n return dataModel.getName();\n }\n public void setValue( Object value ) {\n String name = value == null ? null : value.toString();\n if ( name.trim().length() == 0 ) {\n name = null;\n }\n dataModel.setName( name );\n }\n };\n params.add( nameParam );\n pseudoParams.add( nameParam );\n URL url = dataModel.getBaseTable().getURL();\n if ( url != null ) {\n DescribedValue urlParam = new DescribedValue( URL_INFO, url );\n params.add( urlParam );\n pseudoParams.add( urlParam );\n uneditableParams.add( urlParam );\n }\n ncolParam = new DescribedValue( NCOL_INFO );\n nrowParam = new DescribedValue( NROW_INFO );\n params.add( ncolParam );\n params.add( nrowParam );\n pseudoParams.add( ncolParam );\n pseudoParams.add( nrowParam );\n uneditableParams.add( ncolParam );\n uneditableParams.add( nrowParam );\n columnModel.addColumnModelListener( new TableColumnModelAdapter() {\n public void columnAdded( TableColumnModelEvent evt ) {\n configureColumnCount();\n }\n public void columnRemoved( TableColumnModelEvent evt ) {\n configureColumnCount();\n }\n } );\n viewModel.addTableModelListener( new TableModelListener() {\n public void tableChanged( TableModelEvent evt ) {\n configureRowCount();\n }\n } );\n ncolRowIndex = params.indexOf( ncolParam );\n nrowRowIndex = params.indexOf( nrowParam );\n for ( Iterator it = dataModel.getParameters().iterator();\n it.hasNext(); ) {\n DescribedValue param = (DescribedValue) it.next();\n params.add( param );\n }\n List metas = new ArrayList();\n metas.add( new MetaColumn( \"Name\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getName();\n }\n } );\n metas.add( new MetaColumn( \"Value\", Object.class ) {\n public Object getValue( int irow ) {\n return getParam( irow ).getValue();\n }\n public boolean isEditable( int irow ) {\n return isEditableParameter( irow );\n }\n public void setValue( int irow, Object value ) {\n getParam( irow ).setValue( value );\n }\n } );\n int classPos = metas.size();\n metas.add( new MetaColumn( \"Class\", String.class ) {\n public Object getValue( int irow ) {\n return DefaultValueInfo\n .formatClass( getParamInfo( irow ).getContentClass() );\n }\n } );\n metas.add( new MetaColumn( \"Shape\", String.class ) {\n public Object getValue( int irow ) {\n return DefaultValueInfo\n .formatShape( getParamInfo( irow ).getShape() );\n }\n } );\n metas.add( new MetaColumn( \"Units\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getUnitString();\n }\n public boolean isEditable( int irow ) {\n return ! isPseudoParameter( irow ) &&\n getParamInfo( irow ) instanceof DefaultValueInfo;\n }\n public void setValue( int irow, Object value ) {\n ((DefaultValueInfo) getParamInfo( irow ))\n .setUnitString( value == null ? null : value.toString() );\n }\n } );\n metas.add( new MetaColumn( \"Description\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getDescription();\n }\n public boolean isEditable( int irow ) {\n return ! isPseudoParameter( irow ) &&\n getParamInfo( irow ) instanceof DefaultValueInfo;\n }\n public void setValue( int irow, Object value ) {\n ((DefaultValueInfo) getParamInfo( irow ))\n .setDescription( value == null ? null : value.toString() );\n }\n } );\n metas.add( new MetaColumn( \"UCD\", String.class ) {\n public Object getValue( int irow ) {\n return getParamInfo( irow ).getUCD();\n }\n public boolean isEditable( int irow ) {\n return ! isPseudoParameter( irow ) &&\n getParamInfo( irow ) instanceof DefaultValueInfo;\n }\n public void setValue( int irow, Object value ) {\n ((DefaultValueInfo) getParamInfo( irow ))\n .setUCD( value == null ? null : value.toString() );\n }\n } );\n metas.add( new MetaColumn( \"UCD description\", String.class ) {\n public Object getValue( int irow ) {\n String ucdid = getParamInfo( irow ).getUCD();\n if ( ucdid != null ) {\n UCD ucd = UCD.getUCD( ucdid );\n if ( ucd != null ) {\n return ucd.getDescription();\n }\n }\n return null;\n }\n } );\n metaTableModel = new MetaColumnTableModel( metas ) {\n public int getRowCount() {\n return params.size();\n }\n };\n JTable jtab = new JTable( metaTableModel );\n jtab.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );\n jtab.setColumnSelectionAllowed( false );\n jtab.setRowSelectionAllowed( true );\n StarJTable.configureColumnWidths( jtab, 20000, 100 );\n MetaColumnModel metaColumnModel =\n new MetaColumnModel( jtab.getColumnModel(), metaTableModel );\n metaColumnModel.purgeEmptyColumns();\n jtab.setColumnModel( metaColumnModel );\n metaColumnModel.removeColumn( classPos );\n configureColumnCount();\n configureRowCount();\n getMainArea().add( new SizingScrollPane( jtab ) );\n setMainHeading( \"Table Metadata\" );\n JMenu displayMenu = metaColumnModel.makeCheckBoxMenu( \"Display\" );\n displayMenu.setMnemonic( KeyEvent.VK_D );\n getJMenuBar().add( displayMenu );\n addHelp( \"ParameterWindow\" );\n pack();\n setVisible( true );\n }\n"} {"input": "\tpublic void createSection(Composite parent)\n\t{\n\t\tsuper.createSection(parent);\n\t\tFormToolkit toolkit = new FormToolkit(parent.getDisplay());\n\t\tSection section = toolkit.createSection(parent, ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);\n\t\tsection.setText(Messages.swf_DeployEditorHeading);\n\t\tsection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));\n\t\tComposite composite = toolkit.createComposite(section);\n\t\tcomposite.setLayout(new FormLayout());\n\t\tLabel descriptionLabel = toolkit.createLabel(composite, Messages.swf_DeploymentDescription);\n\t\tLabel label = toolkit.createLabel(composite, Messages.swf_DeployDirectory);\n\t\tfinal Text text = toolkit.createText(composite, getDeployDir(), SWT.BORDER);\n\t\ttext.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\texecute(new SetDeployDirCommand(server, text, text.getText()));\n\t\t\t}\n\t\t});\n\t\tButton button = toolkit.createButton(composite, Messages.browse, SWT.PUSH);\n\t\tbutton.addSelectionListener(new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t}\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tDirectoryDialog d = new DirectoryDialog(new Shell());\n\t\t\t\td.setFilterPath(text.getText());\n\t\t\t\tString x = d.open();\n\t\t\t\tif( x != null ) \n\t\t\t\t\ttext.setText(x);\n\t\t\t} \n\t\t});\n\t\tLabel tempDeployLabel = toolkit.createLabel(composite, Messages.swf_TempDeployDirectory);\n\t\tfinal Text tempDeployText = toolkit.createText(composite, getTempDeployDir(), SWT.BORDER);\n\t\ttempDeployText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\texecute(new SetTempDeployDirCommand(server, tempDeployText, tempDeployText.getText()));\n\t\t\t}\n\t\t});\n\t\tButton tempDeployButton = toolkit.createButton(composite, Messages.browse, SWT.PUSH);\n\t\ttempDeployButton.addSelectionListener(new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t}\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tDirectoryDialog d = new DirectoryDialog(new Shell());\n\t\t\t\td.setFilterPath(tempDeployText.getText());\n\t\t\t\tString x = d.open();\n\t\t\t\tif( x != null ) \n\t\t\t\t\ttempDeployText.setText(x);\n\t\t\t} \n\t\t});\n\t\tFormData descriptionLabelData = new FormData();\n\t\tdescriptionLabelData.left = new FormAttachment(0,5);\n\t\tdescriptionLabelData.top = new FormAttachment(0,5);\n\t\tdescriptionLabel.setLayoutData(descriptionLabelData);\n\t\tFormData labelData = new FormData();\n\t\tlabelData.left = new FormAttachment(0,5);\n\t\tlabelData.top = new FormAttachment(descriptionLabel,5);\n\t\tlabel.setLayoutData(labelData);\n\t\tFormData textData = new FormData();\n\t\ttextData.left = new FormAttachment(label, 5);\n\t\ttextData.top = new FormAttachment(descriptionLabel,5);\n\t\ttextData.right = new FormAttachment(0,300);\n\t\ttext.setLayoutData(textData);\n\t\tFormData buttonData = new FormData();\n\t\tbuttonData.right = new FormAttachment(100,-5);\n\t\tbuttonData.top = new FormAttachment(descriptionLabel,5);\n\t\tbutton.setLayoutData(buttonData);\n\t\tFormData tempLabelData = new FormData();\n\t\ttempLabelData.left = new FormAttachment(0,5);\n\t\ttempLabelData.top = new FormAttachment(text,5);\n\t\ttempDeployLabel.setLayoutData(tempLabelData);\n\t\tFormData tempTextData = new FormData();\n\t\ttempTextData.left = new FormAttachment(tempDeployLabel, 5);\n\t\ttempTextData.top = new FormAttachment(text,5);\n\t\ttempTextData.right = new FormAttachment(0, 300);\n\t\ttempDeployText.setLayoutData(tempTextData);\n\t\tFormData tempButtonData = new FormData();\n\t\ttempButtonData.right = new FormAttachment(100,-5);\n\t\ttempButtonData.top = new FormAttachment(text,5);\n\t\ttempDeployButton.setLayoutData(tempButtonData);\n\t\ttext.setEditable(false);\n\t\ttempDeployText.setEditable(false);\n\t\ttoolkit.paintBordersFor(composite);\n\t\tsection.setClient(composite);\n\t}\n", "output": "\tpublic void createSection(Composite parent)\n\t{\n\t\tsuper.createSection(parent);\n\t\tFormToolkit toolkit = new FormToolkit(parent.getDisplay());\n\t\tSection section = toolkit.createSection(parent, ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED|ExpandableComposite.TITLE_BAR);\n\t\tsection.setText(Messages.swf_DeployEditorHeading);\n\t\tsection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));\n\t\tComposite composite = toolkit.createComposite(section);\n\t\tcomposite.setLayout(new FormLayout());\n\t\tLabel descriptionLabel = toolkit.createLabel(composite, Messages.swf_DeploymentDescription);\n\t\tLabel label = toolkit.createLabel(composite, Messages.swf_DeployDirectory);\n\t\tfinal Text text = toolkit.createText(composite, getDeployDir(), SWT.BORDER);\n\t\ttext.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\texecute(new SetDeployDirCommand(server, text, text.getText()));\n\t\t\t}\n\t\t});\n\t\tButton button = toolkit.createButton(composite, Messages.browse, SWT.PUSH);\n\t\tbutton.addSelectionListener(new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t}\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tDirectoryDialog d = new DirectoryDialog(new Shell());\n\t\t\t\td.setFilterPath(text.getText());\n\t\t\t\tString x = d.open();\n\t\t\t\tif( x != null ) \n\t\t\t\t\ttext.setText(x);\n\t\t\t} \n\t\t});\n\t\tLabel tempDeployLabel = toolkit.createLabel(composite, Messages.swf_TempDeployDirectory);\n\t\tfinal Text tempDeployText = toolkit.createText(composite, getTempDeployDir(), SWT.BORDER);\n\t\ttempDeployText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\texecute(new SetTempDeployDirCommand(server, tempDeployText, tempDeployText.getText()));\n\t\t\t}\n\t\t});\n\t\tButton tempDeployButton = toolkit.createButton(composite, Messages.browse, SWT.PUSH);\n\t\ttempDeployButton.addSelectionListener(new SelectionListener() {\n\t\t\tpublic void widgetDefaultSelected(SelectionEvent e) {\n\t\t\t}\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tDirectoryDialog d = new DirectoryDialog(new Shell());\n\t\t\t\td.setFilterPath(tempDeployText.getText());\n\t\t\t\tString x = d.open();\n\t\t\t\tif( x != null ) \n\t\t\t\t\ttempDeployText.setText(x);\n\t\t\t} \n\t\t});\n\t\tFormData descriptionLabelData = new FormData();\n\t\tdescriptionLabelData.left = new FormAttachment(0,5);\n\t\tdescriptionLabelData.top = new FormAttachment(0,5);\n\t\tdescriptionLabel.setLayoutData(descriptionLabelData);\n\t\tFormData labelData = new FormData();\n\t\tlabelData.left = new FormAttachment(0,5);\n\t\tlabelData.top = new FormAttachment(descriptionLabel,5);\n\t\tlabel.setLayoutData(labelData);\n\t\tFormData textData = new FormData();\n\t\ttextData.left = new FormAttachment(label, 5);\n\t\ttextData.top = new FormAttachment(descriptionLabel,5);\n\t\ttextData.right = new FormAttachment(0,300);\n\t\ttext.setLayoutData(textData);\n\t\tFormData buttonData = new FormData();\n\t\tbuttonData.right = new FormAttachment(100,-5);\n\t\tbuttonData.left = new FormAttachment(text, 5);\n\t\tbuttonData.top = new FormAttachment(descriptionLabel,5);\n\t\tbutton.setLayoutData(buttonData);\n\t\tFormData tempLabelData = new FormData();\n\t\ttempLabelData.left = new FormAttachment(0,5);\n\t\ttempLabelData.top = new FormAttachment(text,5);\n\t\ttempDeployLabel.setLayoutData(tempLabelData);\n\t\tFormData tempTextData = new FormData();\n\t\ttempTextData.left = new FormAttachment(tempDeployLabel, 5);\n\t\ttempTextData.top = new FormAttachment(text,5);\n\t\ttempTextData.right = new FormAttachment(0, 300);\n\t\ttempDeployText.setLayoutData(tempTextData);\n\t\tFormData tempButtonData = new FormData();\n\t\ttempButtonData.right = new FormAttachment(100,-5);\n\t\ttempButtonData.left = new FormAttachment(tempDeployText,5);\n\t\ttempButtonData.top = new FormAttachment(text,5);\n\t\ttempDeployButton.setLayoutData(tempButtonData);\n\t\ttext.setEditable(false);\n\t\ttempDeployText.setEditable(false);\n\t\ttoolkit.paintBordersFor(composite);\n\t\tsection.setClient(composite);\n\t}\n"} {"input": " private void doAPKWithAPKBuilder( File outputFile, File dexFile, File zipArchive, ArrayList<File> sourceFolders,\n ArrayList<File> jarFiles, ArrayList<File> nativeFolders,\n boolean signWithDebugKeyStore ) throws MojoExecutionException\n {\n getLog().debug( \"Building APK with internal APKBuilder\" );\n sourceFolders.add( new File( project.getBuild().getOutputDirectory() ) );\n for ( Artifact artifact : getRelevantCompileArtifacts() )\n {\n if ( extractDuplicates )\n {\n try\n {\n computeDuplicateFiles( artifact.getFile() );\n }\n catch ( Exception e )\n {\n getLog().warn( \"Cannot compute duplicates files from \" + artifact.getFile().getAbsolutePath(), e );\n }\n }\n jarFiles.add( artifact.getFile() );\n }\n if ( extractDuplicates )\n {\n List<String> duplicates = new ArrayList<String>();\n List<File> jarToModify = new ArrayList<File>();\n for ( String s : jars.keySet() )\n {\n List<File> l = jars.get( s );\n if ( l.size() > 1 )\n {\n getLog().warn( \"Duplicate file \" + s + \" : \" + l );\n duplicates.add( s );\n for ( int i = 1; i < l.size(); i++ )\n {\n if ( ! jarToModify.contains( l.get( i ) ) )\n {\n jarToModify.add( l.get( i ) );\n }\n }\n }\n }\n for ( File file : jarToModify )\n {\n File newJar;\n newJar = removeDuplicatesFromJar( file, duplicates );\n int index = jarFiles.indexOf( file );\n if ( newJar != null )\n {\n jarFiles.set( index, newJar );\n }\n }\n }\n String debugKeyStore;\n ApkBuilder apkBuilder; \n try \n {\n debugKeyStore = ApkBuilder.getDebugKeystore();\n apkBuilder = \n new ApkBuilder( outputFile, zipArchive, dexFile, \n ( signWithDebugKeyStore ) ? debugKeyStore : null, null );\n if ( apkDebug )\n {\n apkBuilder.setDebugMode( apkDebug );\n }\n for ( File sourceFolder : sourceFolders )\n {\n apkBuilder.addSourceFolder( sourceFolder );\n }\n for ( File jarFile : jarFiles )\n {\n boolean excluded = false;\n if ( excludeJarResourcesPatterns != null )\n {\n final String name = jarFile.getName();\n getLog().debug( \"Checking \" + name + \" against patterns\" );\n for ( Pattern pattern : excludeJarResourcesPatterns )\n {\n final Matcher matcher = pattern.matcher( name );\n if ( matcher.matches() ) \n {\n getLog().debug( \"Jar \" + name + \" excluded by pattern \" + pattern );\n excluded = true;\n break;\n } \n else \n {\n getLog().debug( \"Jar \" + name + \" not excluded by pattern \" + pattern );\n }\n }\n }\n if ( excluded )\n {\n continue;\n }\n if ( jarFile.isDirectory() )\n {\n String[] filenames = jarFile.list( new FilenameFilter()\n {\n public boolean accept( File dir, String name )\n {\n return PATTERN_JAR_EXT.matcher( name ).matches();\n }\n } );\n for ( String filename : filenames )\n {\n apkBuilder.addResourcesFromJar( new File( jarFile, filename ) );\n }\n }\n else\n {\n apkBuilder.addResourcesFromJar( jarFile );\n }\n }\n for ( File nativeFolder : nativeFolders )\n {\n apkBuilder.addNativeLibraries( nativeFolder );\n }\n apkBuilder.sealApk();\n } \n catch ( ApkCreationException e )\n {\n throw new MojoExecutionException( e.getMessage() );\n } \n catch ( DuplicateFileException e )\n {\n throw new MojoExecutionException( e.getMessage() );\n } \n catch ( SealedApkException e )\n {\n throw new MojoExecutionException( e.getMessage() );\n }\n }\n", "output": " private void doAPKWithAPKBuilder( File outputFile, File dexFile, File zipArchive, ArrayList<File> sourceFolders,\n ArrayList<File> jarFiles, ArrayList<File> nativeFolders,\n boolean signWithDebugKeyStore ) throws MojoExecutionException\n {\n getLog().debug( \"Building APK with internal APKBuilder\" );\n sourceFolders.add( new File( project.getBuild().getOutputDirectory() ) );\n for ( Artifact artifact : getRelevantCompileArtifacts() )\n {\n if ( extractDuplicates )\n {\n try\n {\n computeDuplicateFiles( artifact.getFile() );\n }\n catch ( Exception e )\n {\n getLog().warn( \"Cannot compute duplicates files from \" + artifact.getFile().getAbsolutePath(), e );\n }\n }\n jarFiles.add( artifact.getFile() );\n }\n if ( extractDuplicates )\n {\n List<String> duplicates = new ArrayList<String>();\n List<File> jarToModify = new ArrayList<File>();\n for ( String s : jars.keySet() )\n {\n List<File> l = jars.get( s );\n if ( l.size() > 1 )\n {\n getLog().warn( \"Duplicate file \" + s + \" : \" + l );\n duplicates.add( s );\n for ( int i = 1; i < l.size(); i++ )\n {\n if ( ! jarToModify.contains( l.get( i ) ) )\n {\n jarToModify.add( l.get( i ) );\n }\n }\n }\n }\n for ( File file : jarToModify )\n {\n File newJar;\n newJar = removeDuplicatesFromJar( file, duplicates );\n int index = jarFiles.indexOf( file );\n if ( newJar != null )\n {\n jarFiles.set( index, newJar );\n }\n }\n }\n String debugKeyStore;\n ApkBuilder apkBuilder; \n try \n {\n debugKeyStore = ApkBuilder.getDebugKeystore();\n apkBuilder = \n new ApkBuilder( outputFile, zipArchive, dexFile, \n ( signWithDebugKeyStore ) ? debugKeyStore : null, null );\n if ( apkDebug )\n {\n apkBuilder.setDebugMode( apkDebug );\n }\n for ( File sourceFolder : sourceFolders )\n {\n apkBuilder.addSourceFolder( sourceFolder );\n }\n for ( File jarFile : jarFiles )\n {\n boolean excluded = false;\n if ( excludeJarResourcesPatterns != null )\n {\n final String name = jarFile.getName();\n getLog().debug( \"Checking \" + name + \" against patterns\" );\n for ( Pattern pattern : excludeJarResourcesPatterns )\n {\n final Matcher matcher = pattern.matcher( name );\n if ( matcher.matches() ) \n {\n getLog().debug( \"Jar \" + name + \" excluded by pattern \" + pattern );\n excluded = true;\n break;\n } \n else \n {\n getLog().debug( \"Jar \" + name + \" not excluded by pattern \" + pattern );\n }\n }\n }\n if ( excluded )\n {\n continue;\n }\n if ( jarFile.isDirectory() )\n {\n String[] filenames = jarFile.list( new FilenameFilter()\n {\n public boolean accept( File dir, String name )\n {\n return PATTERN_JAR_EXT.matcher( name ).matches();\n }\n } );\n for ( String filename : filenames )\n {\n apkBuilder.addResourcesFromJar( new File( jarFile, filename ) );\n }\n }\n else\n {\n apkBuilder.addResourcesFromJar( jarFile );\n }\n }\n for ( File nativeFolder : nativeFolders )\n {\n apkBuilder.addNativeLibraries( nativeFolder );\n }\n apkBuilder.sealApk();\n } \n catch ( ApkCreationException e )\n {\n throw new MojoExecutionException( e.getMessage() );\n } \n catch ( DuplicateFileException e )\n {\n final String msg = String.format(\"Duplicate file! archive: %s, file1: %s, file2: %s\",\n e.getArchivePath(), e.getFile1(), e.getFile2());\n throw new MojoExecutionException( msg, e );\n } \n catch ( SealedApkException e )\n {\n throw new MojoExecutionException( e.getMessage() );\n }\n }\n"} {"input": "\tpublic EconomicPlanet(int id, int owner, int numShips, int growthRate,\n\t\t\tdouble x, double y) {\n\t\tsuper(id, owner, numShips, x, y);\n\t\tthis.revenue = growthRate;\n\t}\n", "output": "\tpublic EconomicPlanet(int id, int owner, int numShips, int revenue,\n\t\t\tdouble x, double y) {\n\t\tsuper(id, owner, numShips, x, y);\n\t\tthis.revenue = revenue;\n\t}\n"} {"input": " public void updated(Dictionary properties) throws ConfigurationException {\n if (properties == null)\n return;\n String currentMountpoint = resourcesMountpoint;\n String mountpoint = (String) properties.get(OPT_RESOURCES_MOUNTPOINT);\n if (StringUtils.trimToNull(mountpoint) != null) {\n resourcesMountpoint = mountpoint;\n logger.debug(\"Configured value for the shared resource mountpoint is '{}'\", mountpoint);\n }\n String externalResources = (String) properties.get(OPT_EXT_RESOURCES);\n if (StringUtils.trimToNull(externalResources) != null) {\n externalResourcesDir = new File(externalResources);\n servlet = new WebloungeResourcesServlet(externalResourcesDir, bundleContext.getBundle(), RESOURCES_BUNDLE_DIR);\n logger.debug(\"Configured external shared resources directory at '{}'\", externalResources);\n } else {\n servlet = null;\n }\n if (currentMountpoint != null) {\n try {\n httpService.unregister(currentMountpoint);\n logger.info(\"Serving shared weblounge resources at {}\", resourcesMountpoint);\n if (servlet != null) {\n httpService.registerServlet(resourcesMountpoint, servlet, null, httpContext);\n logger.info(\"Added {} to shared weblounge resources\", externalResourcesDir);\n } else {\n httpService.registerResources(resourcesMountpoint, RESOURCES_BUNDLE_DIR, httpContext);\n }\n } catch (NamespaceException e) {\n logger.error(\"Error registering shared resources at \" + resourcesMountpoint, e);\n } catch (ServletException e) {\n logger.error(\"Error registering shared resources servlet at \" + resourcesMountpoint, e);\n }\n }\n }\n", "output": " public void updated(Dictionary properties) throws ConfigurationException {\n if (properties == null)\n return;\n String currentMountpoint = resourcesMountpoint;\n String mountpoint = (String) properties.get(OPT_RESOURCES_MOUNTPOINT);\n if (StringUtils.isNotBlank(mountpoint)) {\n resourcesMountpoint = mountpoint;\n logger.debug(\"Configured value for the shared resource mountpoint is '{}'\", mountpoint);\n } else {\n resourcesMountpoint = DEFAULT_RESOURCES_MOUNTPOINT;\n logger.debug(\"Using default mountpoint {} for shared resources\", resourcesMountpoint);\n }\n String externalResources = (String) properties.get(OPT_EXT_RESOURCES);\n if (StringUtils.isNotBlank(externalResources)) {\n externalResourcesDir = new File(externalResources);\n servlet = new WebloungeResourcesServlet(externalResourcesDir, bundleContext.getBundle(), RESOURCES_BUNDLE_DIR);\n logger.debug(\"Configured external shared resources directory at '{}'\", externalResources);\n } else {\n servlet = null;\n }\n if (currentMountpoint != null) {\n try {\n httpService.unregister(currentMountpoint);\n logger.info(\"Serving shared weblounge resources at {}\", resourcesMountpoint);\n if (servlet != null) {\n httpService.registerServlet(resourcesMountpoint, servlet, null, httpContext);\n logger.info(\"Added {} to shared weblounge resources\", externalResourcesDir);\n } else {\n httpService.registerResources(resourcesMountpoint, RESOURCES_BUNDLE_DIR, httpContext);\n }\n } catch (NamespaceException e) {\n logger.error(\"Error registering shared resources at \" + resourcesMountpoint, e);\n } catch (ServletException e) {\n logger.error(\"Error registering shared resources servlet at \" + resourcesMountpoint, e);\n }\n }\n }\n"} {"input": "\tpublic InstallCommand(\n\t\tString featureId,\n\t\tString version,\n\t\tString fromSite,\n\t\tString toSite,\n\t\tString verifyOnly)\n\t\tthrows Exception {\n\t\tsuper(verifyOnly);\n\t\ttry {\n\t\t\tthis.featureId = featureId;\n\t\t\tthis.version = version;\n\t\t\tthis.remoteSiteURL = new URL(URLDecoder.decode(fromSite, \"UTF-8\"));\n\t\t\tIConfiguredSite[] sites = getConfiguration().getConfiguredSites();\n\t\t\tif (toSite != null) {\n\t\t\t\tURL toSiteURL = new File(toSite).toURL();\n\t\t\t\tif (SiteManager.getSite(toSiteURL, null) == null) {\n\t\t\t\t\tthrow new Exception(\n\t\t\t\t\t\t\"Cannot find site to install to: \" + toSite);\n\t\t\t\t}\n\t\t\t\ttargetSite =\n\t\t\t\t\tSiteManager\n\t\t\t\t\t\t.getSite(toSiteURL, null)\n\t\t\t\t\t\t.getCurrentConfiguredSite();\n\t\t\t}\n\t\t\tif (targetSite == null) {\n\t\t\t\tfor (int i = 0; i < sites.length; i++) {\n\t\t\t\t\tif (sites[i].isProductSite()) {\n\t\t\t\t\t\ttargetSite = sites[i];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tUpdateSearchScope searchScope = new UpdateSearchScope();\n\t\t\tsearchScope.addSearchSite(\n\t\t\t\t\"remoteSite\",\n\t\t\t\tremoteSiteURL,\n\t\t\t\tnew String[0]);\n\t\t\tsearchRequest =\n\t\t\t\tnew UpdateSearchRequest(new SiteSearchCategory(), searchScope);\n\t\t\tVersionedIdentifier vid =\n\t\t\t\tnew VersionedIdentifier(featureId, version);\n\t\t\tsearchRequest.addFilter(\n\t\t\t\tnew VersionedIdentifiersFilter(\n\t\t\t\t\tnew VersionedIdentifier[] { vid }));\n\t\t\tsearchRequest.addFilter(new EnvironmentFilter());\n\t\t\tsearchRequest.addFilter(new BackLevelFilter());\n\t\t\tcollector = new UpdateSearchResultCollector();\n\t\t} catch (MalformedURLException e) {\n\t\t\tthrow e;\n\t\t} catch (CoreException e) {\n\t\t\tthrow e;\n\t\t}\n\t}\n", "output": "\tpublic InstallCommand(\n\t\tString featureId,\n\t\tString version,\n\t\tString fromSite,\n\t\tString toSite,\n\t\tString verifyOnly)\n\t\tthrows Exception {\n\t\tsuper(verifyOnly);\n\t\ttry {\n\t\t\tthis.featureId = featureId;\n\t\t\tthis.version = version;\n\t\t\tthis.remoteSiteURL = new URL(URLDecoder.decode(fromSite, \"UTF-8\"));\n\t\t\tIConfiguredSite[] sites = getConfiguration().getConfiguredSites();\n\t\t\tif (toSite != null) {\n\t\t\t\tFile sitePath = new File(toSite);\n\t\t\t\tURL toSiteURL = sitePath.toURL();\n\t\t\t\tISite site = SiteManager.getSite(toSiteURL, null);\n\t\t\t\tif (site == null) {\n\t\t\t\t\tthrow new Exception(\n\t\t\t\t\t\t\"Cannot find site to install to: \" + toSite);\n\t\t\t\t}\n\t\t\t\ttargetSite = site.getCurrentConfiguredSite();\n\t\t\t\tif (targetSite == null) {\n\t\t\t\t\ttargetSite = getConfiguration().createConfiguredSite(sitePath);\n\t\t\t\t\tgetConfiguration().addConfiguredSite(targetSite);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (targetSite == null) {\n\t\t\t\tfor (int i = 0; i < sites.length; i++) {\n\t\t\t\t\tif (sites[i].isProductSite()) {\n\t\t\t\t\t\ttargetSite = sites[i];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tUpdateSearchScope searchScope = new UpdateSearchScope();\n\t\t\tsearchScope.addSearchSite(\n\t\t\t\t\"remoteSite\",\n\t\t\t\tremoteSiteURL,\n\t\t\t\tnew String[0]);\n\t\t\tsearchRequest =\n\t\t\t\tnew UpdateSearchRequest(new SiteSearchCategory(), searchScope);\n\t\t\tVersionedIdentifier vid =\n\t\t\t\tnew VersionedIdentifier(featureId, version);\n\t\t\tsearchRequest.addFilter(\n\t\t\t\tnew VersionedIdentifiersFilter(\n\t\t\t\t\tnew VersionedIdentifier[] { vid }));\n\t\t\tsearchRequest.addFilter(new EnvironmentFilter());\n\t\t\tsearchRequest.addFilter(new BackLevelFilter());\n\t\t\tcollector = new UpdateSearchResultCollector();\n\t\t} catch (MalformedURLException e) {\n\t\t\tthrow e;\n\t\t} catch (CoreException e) {\n\t\t\tthrow e;\n\t\t}\n\t}\n"} {"input": "\tpublic synchronized CaspReturn runCmd(CaspCmd cmd) throws IOException {\n\t\topen(); \n\t\tout.println(new String(cmd.getCmdString().getBytes(\"UTF-8\"))); \n\t\tlong requestTime = new Date().getTime();\n\t\tString line = in.readLine();\n\t\tMatcher myMatcher = Pattern.compile(\"^\\\\d+\").matcher(line);\n\t\tmyMatcher.find();\n\t\tint status = Integer.parseInt(line.substring(myMatcher.start(), myMatcher.end()));\n\t\tPattern endSequence = null;\n\t\tString response = null;\n\t\tBoolean getResponse = true;\n\t\tint charsRemove = 0;\n\t\tif (status == 200) { \n\t\t\tendSequence = Pattern.compile(\"\\\\r\\\\n\\\\r\\\\n$\");\n\t\t\tcharsRemove = 4;\n\t\t}\n\t\telse if (status == 201) { \n\t\t\tendSequence = Pattern.compile(\"\\\\r\\\\n$\");\n\t\t\tcharsRemove = 2;\n\t\t\tresponse = in.readLine();\n\t\t}\n\t\telse {\n\t\t\tgetResponse = false;\n\t\t}\n\t\tif (getResponse) {\n\t\t\tresponse = \"\";\n\t\t\twhile(true) {\n\t\t\t\tchar character = (char) in.read();\n\t\t\t\tresponse += character;\n\t\t\t\tif (endSequence.matcher(response).find()) { \n\t\t\t\t\tbreak;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t\tresponse = response.substring(0, response.length()-charsRemove);\n\t\t}\n\t\treturn new CaspReturn(status, response, requestTime);\n\t}\n", "output": "\tpublic synchronized CaspReturn runCmd(CaspCmd cmd) throws IOException {\n\t\topen(); \n\t\tout.println(new String(cmd.getCmdString().getBytes(\"UTF-8\"))); \n\t\tlong requestTime = new Date().getTime();\n\t\tString line = in.readLine();\n\t\tMatcher myMatcher = Pattern.compile(\"^\\\\d+\").matcher(line);\n\t\tmyMatcher.find();\n\t\tint status = Integer.parseInt(line.substring(myMatcher.start(), myMatcher.end()));\n\t\tPattern endSequence = null;\n\t\tString response = null;\n\t\tBoolean getResponse = true;\n\t\tint charsRemove = 0;\n\t\tif (status == 200) { \n\t\t\tendSequence = Pattern.compile(\"\\\\r\\\\n\\\\r\\\\n$\");\n\t\t\tcharsRemove = 4;\n\t\t}\n\t\telse if (status == 201) { \n\t\t\tendSequence = Pattern.compile(\"\\\\r\\\\n$\");\n\t\t\tcharsRemove = 2;\n\t\t}\n\t\telse {\n\t\t\tgetResponse = false;\n\t\t}\n\t\tif (getResponse) {\n\t\t\tresponse = \"\";\n\t\t\twhile(true) {\n\t\t\t\tchar character = (char) in.read();\n\t\t\t\tresponse += character;\n\t\t\t\tif (endSequence.matcher(response).find()) { \n\t\t\t\t\tbreak;\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t\tresponse = response.substring(0, response.length()-charsRemove);\n\t\t}\n\t\treturn new CaspReturn(status, response, requestTime);\n\t}\n"} {"input": "\tpublic void addFlexTrapezoid(float x, float y, float z, int w, int h, int d, float scale, float bScale1, float bScale2, float bScale3, float bScale4, float fScale1, float fScale2, int dir)\n\t{\n\t\tfloat f4 = x + (float)w;\n\t\tfloat f5 = y + (float)h;\n\t\tfloat f6 = z + (float)d;\n\t\tx -= scale;\n\t\ty -= scale;\n\t\tz -= scale;\n\t\tf4 += scale;\n\t\tf5 += scale;\n\t\tf6 += scale;\n\t\tint m = (mirror ? -1 : 1);\n\t\tif(mirror)\n\t\t{\n\t\t\tfloat f7 = f4;\n\t\t\tf4 = x;\n\t\t\tx = f7;\n\t\t}\n\t\tfloat[] v = {x, y, z};\n\t\tfloat[] v1 = {f4, y, z};\n\t\tfloat[] v2 = {f4, f5, z};\n\t\tfloat[] v3 = {x, f5, z};\n\t\tfloat[] v4 = {x, y, f6};\n\t\tfloat[] v5 = {f4, y, f6};\n\t\tfloat[] v6 = {f4, f5, f6};\n\t\tfloat[] v7 = {x, f5, f6};\n\t\tswitch(dir)\n\t\t{\n\t\t\tcase MR_RIGHT:\n\t\t\t\tv[2] -= fScale1;\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv4[2] += fScale2;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv[1] -= bScale1;\n\t\t\t\tv[2] -= bScale3;\n\t\t\t\tv3[1] += bScale2;\n\t\t\t\tv3[2] -= bScale3;\n\t\t\t\tv4[1] -= bScale1;\n\t\t\t\tv4[2] += bScale4;\n\t\t\t\tv7[1] += bScale2;\n\t\t\t\tv7[2] += bScale4;\n\t\t\t\tbreak;\n\t\t\tcase MR_LEFT:\n\t\t\t\tv[2] -= fScale1;\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv4[2] += fScale2;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv1[1] -= bScale1;\n\t\t\t\tv1[2] -= bScale3;\n\t\t\t\tv2[1] += bScale2;\n\t\t\t\tv2[2] -= bScale3;\n\t\t\t\tv5[1] -= bScale1;\n\t\t\t\tv5[2] += bScale4;\n\t\t\t\tv6[1] += bScale2;\n\t\t\t\tv6[2] += bScale4;\n\t\t\t\tbreak;\n\t\t\tcase MR_FRONT:\n\t\t\t\tv2[1] += fScale1;\n\t\t\t\tv3[1] += fScale2;\n\t\t\t\tv6[1] += fScale2;\n\t\t\t\tv7[1] += fScale1;\n\t\t\t\tv[0] -= m * bScale4;\n\t\t\t\tv[1] -= bScale1;\n\t\t\t\tv1[0] += m * bScale3;\n\t\t\t\tv1[1] -= bScale1;\n\t\t\t\tv2[0] += m * bScale3;\n\t\t\t\tv2[1] += bScale2;\n\t\t\t\tv3[0] -= m * bScale4;\n\t\t\t\tv3[1] += bScale2;\n\t\t\t\tbreak;\n\t\t\tcase MR_BACK:\n\t\t\t\tv2[1] += fScale1;\n\t\t\t\tv3[1] += fScale2;\n\t\t\t\tv6[1] += fScale2;\n\t\t\t\tv7[1] += fScale1;\n\t\t\t\tv4[0] -= m * bScale4;\n\t\t\t\tv4[1] -= bScale1;\n\t\t\t\tv5[0] += m * bScale3;\n\t\t\t\tv5[1] -= bScale1;\n\t\t\t\tv6[0] += m * bScale3;\n\t\t\t\tv6[1] += bScale2;\n\t\t\t\tv7[0] -= m * bScale4;\n\t\t\t\tv7[1] += bScale2;\n\t\t\t\tbreak;\n\t\t\tcase MR_TOP:\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv2[2] -= fScale1;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv6[2] += fScale2;\n\t\t\t\tv[0] -= m * bScale1;\n\t\t\t\tv[2] -= bScale3;\n\t\t\t\tv1[0] += m * bScale2;\n\t\t\t\tv1[2] -= bScale3;\n\t\t\t\tv4[0] -= m * bScale1;\n\t\t\t\tv4[2] += bScale4;\n\t\t\t\tv5[0] += m * bScale2;\n\t\t\t\tv5[2] += bScale4;\n\t\t\t\tbreak;\n\t\t\tcase MR_BOTTOM:\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv2[2] -= fScale1;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv6[2] += fScale2;\n\t\t\t\tv2[0] += m * bScale2;\n\t\t\t\tv2[2] -= bScale3;\n\t\t\t\tv3[0] -= m * bScale1;\n\t\t\t\tv3[2] -= bScale3;\n\t\t\t\tv6[0] += m * bScale2;\n\t\t\t\tv6[2] += bScale4;\n\t\t\t\tv7[0] -= m * bScale1;\n\t\t\t\tv7[2] += bScale4;\n\t\t\t\tbreak;\n\t\t}\n\t\tfloat[] qValues = new float[] {\n\t\t\t\tMath.abs((v[0] - v1[0])/(v3[0]-v2[0])),\n\t\t\t\tMath.abs((v[0] - v1[0])/(v4[0]-v5[0])),\n\t\t\t\tMath.abs((v4[0] - v5[0])/(v7[0]-v6[0])),\n\t\t\t\tMath.abs((v3[0] - v2[0])/(v7[0]-v6[0])),\n\t\t\t\tMath.abs((v[1] - v3[1])/(v1[1]-v2[1])),\n\t\t\t\tMath.abs((v4[1] - v7[1])/(v5[1]-v6[1])),\n\t\t\t\tMath.abs((v[1] - v3[1])/(v4[1]-v7[1])),\n\t\t\t\tMath.abs((v1[1] - v2[1])/(v5[1]-v6[1])),\n\t\t\t\tMath.abs((v[2] - v4[2])/(v1[2]-v5[2])),\n\t\t\t\tMath.abs((v[2] - v4[2])/(v3[2]-v7[2])),\n\t\t\t\tMath.abs((v1[2] - v5[2])/(v2[2]-v6[2])),\n\t\t\t\tMath.abs((v3[2] - v7[2])/(v2[2]-v6[2]))\t\n\t\t};\n\t\taddRectShape(v, v1, v2, v3, v4, v5, v6, v7, w, h, d, qValues);\n\t}\n", "output": "\tpublic void addFlexTrapezoid(float x, float y, float z, int w, int h, int d, float scale, float bScale1, float bScale2, float bScale3, float bScale4, float fScale1, float fScale2, int dir)\n\t{\n\t\tfloat f4 = x + (float)w;\n\t\tfloat f5 = y + (float)h;\n\t\tfloat f6 = z + (float)d;\n\t\tx -= scale;\n\t\ty -= scale;\n\t\tz -= scale;\n\t\tf4 += scale;\n\t\tf5 += scale;\n\t\tf6 += scale;\n\t\tint m = (mirror ? -1 : 1);\n\t\tif(mirror)\n\t\t{\n\t\t\tfloat f7 = f4;\n\t\t\tf4 = x;\n\t\t\tx = f7;\n\t\t}\n\t\tfloat[] v = {x, y, z};\n\t\tfloat[] v1 = {f4, y, z};\n\t\tfloat[] v2 = {f4, f5, z};\n\t\tfloat[] v3 = {x, f5, z};\n\t\tfloat[] v4 = {x, y, f6};\n\t\tfloat[] v5 = {f4, y, f6};\n\t\tfloat[] v6 = {f4, f5, f6};\n\t\tfloat[] v7 = {x, f5, f6};\n\t\tswitch(dir)\n\t\t{\n\t\t\tcase MR_RIGHT:\n\t\t\t\tv[2] -= fScale1;\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv4[2] += fScale2;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv[1] -= bScale1;\n\t\t\t\tv[2] -= bScale3;\n\t\t\t\tv3[1] += bScale2;\n\t\t\t\tv3[2] -= bScale3;\n\t\t\t\tv4[1] -= bScale1;\n\t\t\t\tv4[2] += bScale4;\n\t\t\t\tv7[1] += bScale2;\n\t\t\t\tv7[2] += bScale4;\n\t\t\t\tbreak;\n\t\t\tcase MR_LEFT:\n\t\t\t\tv[2] -= fScale1;\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv4[2] += fScale2;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv1[1] -= bScale1;\n\t\t\t\tv1[2] -= bScale3;\n\t\t\t\tv2[1] += bScale2;\n\t\t\t\tv2[2] -= bScale3;\n\t\t\t\tv5[1] -= bScale1;\n\t\t\t\tv5[2] += bScale4;\n\t\t\t\tv6[1] += bScale2;\n\t\t\t\tv6[2] += bScale4;\n\t\t\t\tbreak;\n\t\t\tcase MR_FRONT:\n\t\t\t\tv1[1] -= fScale1;\n\t\t\t\tv5[1] -= fScale1;\n\t\t\t\tv2[1] += fScale2;\n\t\t\t\tv6[1] += fScale2;\n\t\t\t\tv[0] -= m * bScale4;\n\t\t\t\tv[1] -= bScale1;\n\t\t\t\tv1[0] += m * bScale3;\n\t\t\t\tv1[1] -= bScale1;\n\t\t\t\tv2[0] += m * bScale3;\n\t\t\t\tv2[1] += bScale2;\n\t\t\t\tv3[0] -= m * bScale4;\n\t\t\t\tv3[1] += bScale2;\n\t\t\t\tbreak;\n\t\t\tcase MR_BACK:\n\t\t\t\tv1[1] -= fScale1;\n\t\t\t\tv5[1] -= fScale1;\n\t\t\t\tv2[1] += fScale2;\n\t\t\t\tv6[1] += fScale2;\n\t\t\t\tv4[0] -= m * bScale4;\n\t\t\t\tv4[1] -= bScale1;\n\t\t\t\tv5[0] += m * bScale3;\n\t\t\t\tv5[1] -= bScale1;\n\t\t\t\tv6[0] += m * bScale3;\n\t\t\t\tv6[1] += bScale2;\n\t\t\t\tv7[0] -= m * bScale4;\n\t\t\t\tv7[1] += bScale2;\n\t\t\t\tbreak;\n\t\t\tcase MR_TOP:\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv2[2] -= fScale1;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv6[2] += fScale2;\n\t\t\t\tv[0] -= m * bScale1;\n\t\t\t\tv[2] -= bScale3;\n\t\t\t\tv1[0] += m * bScale2;\n\t\t\t\tv1[2] -= bScale3;\n\t\t\t\tv4[0] -= m * bScale1;\n\t\t\t\tv4[2] += bScale4;\n\t\t\t\tv5[0] += m * bScale2;\n\t\t\t\tv5[2] += bScale4;\n\t\t\t\tbreak;\n\t\t\tcase MR_BOTTOM:\n\t\t\t\tv1[2] -= fScale1;\n\t\t\t\tv2[2] -= fScale1;\n\t\t\t\tv5[2] += fScale2;\n\t\t\t\tv6[2] += fScale2;\n\t\t\t\tv2[0] += m * bScale2;\n\t\t\t\tv2[2] -= bScale3;\n\t\t\t\tv3[0] -= m * bScale1;\n\t\t\t\tv3[2] -= bScale3;\n\t\t\t\tv6[0] += m * bScale2;\n\t\t\t\tv6[2] += bScale4;\n\t\t\t\tv7[0] -= m * bScale1;\n\t\t\t\tv7[2] += bScale4;\n\t\t\t\tbreak;\n\t\t}\n\t\tfloat[] qValues = new float[] {\n\t\t\t\tMath.abs((v[0] - v1[0])/(v3[0]-v2[0])),\n\t\t\t\tMath.abs((v[0] - v1[0])/(v4[0]-v5[0])),\n\t\t\t\tMath.abs((v4[0] - v5[0])/(v7[0]-v6[0])),\n\t\t\t\tMath.abs((v3[0] - v2[0])/(v7[0]-v6[0])),\n\t\t\t\tMath.abs((v[1] - v3[1])/(v1[1]-v2[1])),\n\t\t\t\tMath.abs((v4[1] - v7[1])/(v5[1]-v6[1])),\n\t\t\t\tMath.abs((v[1] - v3[1])/(v4[1]-v7[1])),\n\t\t\t\tMath.abs((v1[1] - v2[1])/(v5[1]-v6[1])),\n\t\t\t\tMath.abs((v[2] - v4[2])/(v1[2]-v5[2])),\n\t\t\t\tMath.abs((v[2] - v4[2])/(v3[2]-v7[2])),\n\t\t\t\tMath.abs((v1[2] - v5[2])/(v2[2]-v6[2])),\n\t\t\t\tMath.abs((v3[2] - v7[2])/(v2[2]-v6[2]))\t\n\t\t};\n\t\taddRectShape(v, v1, v2, v3, v4, v5, v6, v7, w, h, d, qValues);\n\t}\n"} {"input": " private void paintNode(Graphics2D g, Node network, Node node, BufferedImage icon, boolean selected, boolean rendered, Node connectionOutput, Port hoverInputPort, boolean hoverOutput) {\n Rectangle r = nodeRect(node);\n String outputType = node.getOutputType();\n if (selected) {\n g.setColor(Color.WHITE);\n g.fillRect(r.x, r.y, NODE_WIDTH, NODE_HEIGHT);\n }\n g.setColor(portTypeColor(outputType));\n if (selected) {\n g.fillRect(r.x + 2, r.y + 2, NODE_WIDTH - 4, NODE_HEIGHT - 4);\n } else {\n g.fillRect(r.x, r.y, NODE_WIDTH, NODE_HEIGHT);\n }\n if (rendered) {\n g.setColor(Color.WHITE);\n GeneralPath gp = new GeneralPath();\n gp.moveTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 20);\n gp.lineTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 2);\n gp.lineTo(r.x + NODE_WIDTH - 20, r.y + NODE_HEIGHT - 2);\n g.fill(gp);\n }\n g.setColor(Color.WHITE);\n int portX = 0;\n for (Port input : node.getInputs()) {\n if (hoverInputPort == input) {\n g.setColor(PORT_HOVER_COLOR);\n } else {\n g.setColor(portTypeColor(input.getType()));\n }\n int portHeight = PORT_HEIGHT;\n if (connectionOutput != null) {\n if (connectionOutput.getOutputType().equals(input.getType())) {\n portHeight = PORT_HEIGHT * 2;\n } else {\n portHeight = 1;\n }\n }\n if (isPublished(network, node, input)) {\n Point2D topLeft = inverseViewTransformPoint(new Point(4, 0));\n g.setColor(portTypeColor(input.getType()));\n g.setStroke(CONNECTION_STROKE);\n paintConnectionLine(g, (int) topLeft.getX(), (int) topLeft.getY(), r.x + portX + 4, r.y - 2);\n }\n g.fillRect(r.x + portX, r.y - portHeight, PORT_WIDTH, portHeight);\n portX += PORT_WIDTH + PORT_SPACING;\n }\n if (hoverOutput && connectionOutput == null) {\n g.setColor(PORT_HOVER_COLOR);\n } else {\n g.setColor(portTypeColor(outputType));\n }\n g.fillRect(r.x, r.y + NODE_HEIGHT, PORT_WIDTH, PORT_HEIGHT);\n g.drawImage(icon, r.x + NODE_PADDING, r.y + NODE_PADDING, NODE_ICON_SIZE, NODE_ICON_SIZE, null);\n g.setColor(Color.WHITE);\n g.setFont(Theme.NETWORK_FONT);\n g.drawString(getShortenedName(node.getName(), 7), r.x + NODE_ICON_SIZE + NODE_PADDING * 2 + 2, r.y + 22);\n }\n", "output": " private void paintNode(Graphics2D g, Node network, Node node, BufferedImage icon, boolean selected, boolean rendered, Node connectionOutput, Port hoverInputPort, boolean hoverOutput) {\n Rectangle r = nodeRect(node);\n String outputType = node.getOutputType();\n if (selected) {\n g.setColor(Color.WHITE);\n g.fillRect(r.x, r.y, NODE_WIDTH, NODE_HEIGHT);\n }\n g.setColor(portTypeColor(outputType));\n if (selected) {\n g.fillRect(r.x + 2, r.y + 2, NODE_WIDTH - 4, NODE_HEIGHT - 4);\n } else {\n g.fillRect(r.x, r.y, NODE_WIDTH, NODE_HEIGHT);\n }\n if (rendered) {\n g.setColor(Color.WHITE);\n GeneralPath gp = new GeneralPath();\n gp.moveTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 20);\n gp.lineTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 2);\n gp.lineTo(r.x + NODE_WIDTH - 20, r.y + NODE_HEIGHT - 2);\n g.fill(gp);\n }\n g.setColor(Color.WHITE);\n int portX = 0;\n for (Port input : node.getInputs()) {\n if (hoverInputPort == input) {\n g.setColor(PORT_HOVER_COLOR);\n } else {\n g.setColor(portTypeColor(input.getType()));\n }\n int portHeight = PORT_HEIGHT;\n if (connectionOutput != null) {\n String connectionOutputType = connectionOutput.getOutputType();\n String inputType = input.getType();\n if (connectionOutputType.equals(inputType) || inputType.equals(Port.TYPE_LIST)) {\n portHeight = PORT_HEIGHT * 2;\n } else if (TypeConversions.canBeConverted(connectionOutputType, inputType)) {\n portHeight = PORT_HEIGHT - 1;\n } else {\n portHeight = 1;\n }\n }\n if (isPublished(network, node, input)) {\n Point2D topLeft = inverseViewTransformPoint(new Point(4, 0));\n g.setColor(portTypeColor(input.getType()));\n g.setStroke(CONNECTION_STROKE);\n paintConnectionLine(g, (int) topLeft.getX(), (int) topLeft.getY(), r.x + portX + 4, r.y - 2);\n }\n g.fillRect(r.x + portX, r.y - portHeight, PORT_WIDTH, portHeight);\n portX += PORT_WIDTH + PORT_SPACING;\n }\n if (hoverOutput && connectionOutput == null) {\n g.setColor(PORT_HOVER_COLOR);\n } else {\n g.setColor(portTypeColor(outputType));\n }\n g.fillRect(r.x, r.y + NODE_HEIGHT, PORT_WIDTH, PORT_HEIGHT);\n g.drawImage(icon, r.x + NODE_PADDING, r.y + NODE_PADDING, NODE_ICON_SIZE, NODE_ICON_SIZE, null);\n g.setColor(Color.WHITE);\n g.setFont(Theme.NETWORK_FONT);\n g.drawString(getShortenedName(node.getName(), 7), r.x + NODE_ICON_SIZE + NODE_PADDING * 2 + 2, r.y + 22);\n }\n"} {"input": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n try {\n Collect.createODKDirs();\n } catch (RuntimeException e) {\n createErrorDialog(e.getMessage(), EXIT);\n return;\n }\n setContentView(R.layout.chooser_list_layout);\n setTitle(getString(R.string.app_name) + \" > \" + getString(R.string.review_data));\n TextView tv = (TextView) findViewById(R.id.status_text);\n tv.setVisibility(View.GONE);\n String selection = InstanceColumns.STATUS + \" is not ?\";\n String[] selectionArgs = {InstanceProviderAPI.STATUS_SUBMITTED};\n Cursor c = managedQuery(InstanceColumns.CONTENT_URI, null, selection, selectionArgs, InstanceColumns.STATUS + \" desc\");\n String[] data = new String[] {\n InstanceColumns.DISPLAY_NAME, InstanceColumns.DISPLAY_SUBTEXT\n };\n int[] view = new int[] {\n R.id.text1, R.id.text2\n };\n SimpleCursorAdapter instances =\n new SimpleCursorAdapter(this, R.layout.two_item, c, data, view);\n setListAdapter(instances);\n }\n", "output": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n try {\n Collect.createODKDirs();\n } catch (RuntimeException e) {\n createErrorDialog(e.getMessage(), EXIT);\n return;\n }\n setContentView(R.layout.chooser_list_layout);\n setTitle(getString(R.string.app_name) + \" > \" + getString(R.string.review_data));\n TextView tv = (TextView) findViewById(R.id.status_text);\n tv.setVisibility(View.GONE);\n String selection = InstanceColumns.STATUS + \" != ?\";\n String[] selectionArgs = {InstanceProviderAPI.STATUS_SUBMITTED};\n Cursor c = managedQuery(InstanceColumns.CONTENT_URI, null, selection, selectionArgs, InstanceColumns.STATUS + \" desc\");\n String[] data = new String[] {\n InstanceColumns.DISPLAY_NAME, InstanceColumns.DISPLAY_SUBTEXT\n };\n int[] view = new int[] {\n R.id.text1, R.id.text2\n };\n SimpleCursorAdapter instances =\n new SimpleCursorAdapter(this, R.layout.two_item, c, data, view);\n setListAdapter(instances);\n }\n"} {"input": " public AnyKeyboardBaseView(Context context, AttributeSet attrs, int defStyle) {\n super(context, attrs, defStyle);\n TypedArray a = context.obtainStyledAttributes(\n attrs, R.styleable.AnyKeyboardBaseView, defStyle, R.style.AnyKeyboardBaseView);\n LayoutInflater inflate =\n (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n int previewLayout = 0;\n int keyTextSize = 0;\n int n = a.getIndexCount();\n for (int i = 0; i < n; i++) {\n int attr = a.getIndex(i);\n switch (attr) {\n case R.styleable.AnyKeyboardBaseView_keyBackground:\n mKeyBackground = a.getDrawable(attr);\n break;\n case R.styleable.AnyKeyboardBaseView_keyHysteresisDistance:\n mKeyHysteresisDistance = a.getDimensionPixelOffset(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_verticalCorrection:\n mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_keyPreviewLayout:\n previewLayout = a.getResourceId(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_keyPreviewOffset:\n mPreviewOffset = a.getDimensionPixelOffset(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_keyPreviewHeight:\n mPreviewHeight = a.getDimensionPixelSize(attr, 80);\n break;\n case R.styleable.AnyKeyboardBaseView_keyTextSize:\n mKeyTextSize = a.getDimensionPixelSize(attr, 18);\n break;\n case R.styleable.AnyKeyboardBaseView_keyTextColor:\n mKeyTextColor = a.getColor(attr, 0xFF000000);\n break;\n case R.styleable.AnyKeyboardBaseView_labelTextSize:\n mLabelTextSize = a.getDimensionPixelSize(attr, 14);\n break;\n case R.styleable.AnyKeyboardBaseView_popupLayout:\n mPopupLayout = a.getResourceId(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_shadowColor:\n mShadowColor = a.getColor(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_shadowRadius:\n mShadowRadius = a.getFloat(attr, 0f);\n break;\n case R.styleable.AnyKeyboardBaseView_backgroundDimAmount:\n mBackgroundDimAmount = a.getFloat(attr, 0.5f);\n break;\n case R.styleable.AnyKeyboardBaseView_keyTextStyle:\n int textStyle = a.getInt(attr, 0);\n switch (textStyle) {\n case 0:\n mKeyTextStyle = Typeface.DEFAULT;\n break;\n case 1:\n mKeyTextStyle = Typeface.DEFAULT_BOLD;\n break;\n default:\n mKeyTextStyle = Typeface.defaultFromStyle(textStyle);\n break;\n }\n break;\n case R.styleable.AnyKeyboardBaseView_symbolColorScheme:\n mSymbolColorScheme = a.getInt(attr, 0);\n break;\n }\n }\n final Resources res = getResources();\n mPreviewPopup = new PopupWindow(context);\n if (previewLayout != 0) {\n mPreviewText = (TextView) inflate.inflate(previewLayout, null);\n mPreviewTextSizeLarge = (int) res.getDimension(R.dimen.key_preview_text_size_large);\n mPreviewPopup.setContentView(mPreviewText);\n mPreviewPopup.setBackgroundDrawable(null);\n } else {\n \tmPreviewText = null;\n mShowPreview = false;\n }\n mPreviewPopup.setTouchable(false);\n mPreviewPopup.setAnimationStyle(R.style.KeyPreviewAnimation);\n mDelayBeforePreview = 0;\n mDelayAfterPreview = 10;\n mMiniKeyboardParent = this;\n mMiniKeyboardPopup = new PopupWindow(context);\n mMiniKeyboardPopup.setBackgroundDrawable(null);\n mMiniKeyboardPopup.setAnimationStyle(R.style.MiniKeyboardAnimation);\n mPaint = new Paint();\n mPaint.setAntiAlias(true);\n mPaint.setTextSize(keyTextSize);\n mPaint.setTextAlign(Align.CENTER);\n mPaint.setAlpha(255);\n mPadding = new Rect(0, 0, 0, 0);\n mKeyBackground.getPadding(mPadding);\n mSwipeThreshold = (int) (500 * res.getDisplayMetrics().density);\n mDisambiguateSwipe = res.getBoolean(R.bool.config_swipeDisambiguation);\n mMiniKeyboardSlideAllowance = res.getDimension(R.dimen.mini_keyboard_slide_allowance);\n GestureDetector.SimpleOnGestureListener listener =\n new GestureDetector.SimpleOnGestureListener() {\n @Override\n public boolean onFling(MotionEvent me1, MotionEvent me2, float velocityX,\n float velocityY) {\n final float absX = Math.abs(velocityX);\n final float absY = Math.abs(velocityY);\n float deltaX = me2.getX() - me1.getX();\n float deltaY = me2.getY() - me1.getY();\n int travelX = getWidth() / 2; \n int travelY = getHeight() / 2; \n mSwipeTracker.computeCurrentVelocity(1000);\n final float endingVelocityX = mSwipeTracker.getXVelocity();\n final float endingVelocityY = mSwipeTracker.getYVelocity();\n if (velocityX > mSwipeThreshold && absY < absX && deltaX > travelX) {\n if (mDisambiguateSwipe && endingVelocityX >= velocityX / 4) {\n swipeRight();\n return true;\n }\n } else if (velocityX < -mSwipeThreshold && absY < absX && deltaX < -travelX) {\n if (mDisambiguateSwipe && endingVelocityX <= velocityX / 4) {\n swipeLeft();\n return true;\n }\n } else if (velocityY < -mSwipeThreshold && absX < absY && deltaY < -travelY) {\n if (mDisambiguateSwipe && endingVelocityY <= velocityY / 4) {\n swipeUp();\n return true;\n }\n } else if (velocityY > mSwipeThreshold && absX < absY / 2 && deltaY > travelY) {\n if (mDisambiguateSwipe && endingVelocityY >= velocityY / 4) {\n swipeDown();\n return true;\n }\n }\n return false;\n }\n };\n mGestureDetector = createGestureDetector(listener);\n mGestureDetector.setIsLongpressEnabled(false);\n mHasDistinctMultitouch = systemHasMultitouch(context);\n Log.d(getKeyboardViewNameForLogging(), \"mHasDistinctMultitouch : \"+mHasDistinctMultitouch);\n mKeyRepeatInterval = 50;\n Log.i(getKeyboardViewNameForLogging(), \"Created keyboard view of type \"+getKeyboardViewNameForLogging());\n }\n", "output": " public AnyKeyboardBaseView(Context context, AttributeSet attrs, int defStyle) {\n super(context, attrs, defStyle);\n TypedArray a = context.obtainStyledAttributes(\n attrs, R.styleable.AnyKeyboardBaseView, defStyle, R.style.AnyKeyboardBaseView);\n LayoutInflater inflate =\n (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n int previewLayout = 0;\n int keyTextSize = 0;\n int n = a.getIndexCount();\n for (int i = 0; i < n; i++) {\n int attr = a.getIndex(i);\n switch (attr) {\n case R.styleable.AnyKeyboardBaseView_keyBackground:\n mKeyBackground = a.getDrawable(attr);\n break;\n case R.styleable.AnyKeyboardBaseView_keyHysteresisDistance:\n mKeyHysteresisDistance = a.getDimensionPixelOffset(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_verticalCorrection:\n mVerticalCorrection = a.getDimensionPixelOffset(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_keyPreviewLayout:\n previewLayout = a.getResourceId(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_keyPreviewOffset:\n mPreviewOffset = a.getDimensionPixelOffset(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_keyPreviewHeight:\n mPreviewHeight = a.getDimensionPixelSize(attr, 80);\n break;\n case R.styleable.AnyKeyboardBaseView_keyTextSize:\n mKeyTextSize = a.getDimensionPixelSize(attr, 18);\n break;\n case R.styleable.AnyKeyboardBaseView_keyTextColor:\n mKeyTextColor = a.getColor(attr, 0xFF000000);\n break;\n case R.styleable.AnyKeyboardBaseView_labelTextSize:\n mLabelTextSize = a.getDimensionPixelSize(attr, 14);\n break;\n case R.styleable.AnyKeyboardBaseView_popupLayout:\n mPopupLayout = a.getResourceId(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_shadowColor:\n mShadowColor = a.getColor(attr, 0);\n break;\n case R.styleable.AnyKeyboardBaseView_shadowRadius:\n mShadowRadius = a.getFloat(attr, 0f);\n break;\n case R.styleable.AnyKeyboardBaseView_backgroundDimAmount:\n mBackgroundDimAmount = a.getFloat(attr, 0.5f);\n break;\n case R.styleable.AnyKeyboardBaseView_keyTextStyle:\n int textStyle = a.getInt(attr, 0);\n switch (textStyle) {\n case 0:\n mKeyTextStyle = Typeface.DEFAULT;\n break;\n case 1:\n mKeyTextStyle = Typeface.DEFAULT_BOLD;\n break;\n case 2:\n mKeyTextStyle = Typeface.defaultFromStyle(Typeface.ITALIC);\n break;\n default:\n mKeyTextStyle = Typeface.defaultFromStyle(textStyle);\n break;\n }\n break;\n case R.styleable.AnyKeyboardBaseView_symbolColorScheme:\n mSymbolColorScheme = a.getInt(attr, 0);\n break;\n }\n }\n final Resources res = getResources();\n mPreviewPopup = new PopupWindow(context);\n if (previewLayout != 0) {\n mPreviewText = (TextView) inflate.inflate(previewLayout, null);\n mPreviewTextSizeLarge = (int) res.getDimension(R.dimen.key_preview_text_size_large);\n mPreviewPopup.setContentView(mPreviewText);\n mPreviewPopup.setBackgroundDrawable(null);\n } else {\n \tmPreviewText = null;\n mShowPreview = false;\n }\n mPreviewPopup.setTouchable(false);\n mPreviewPopup.setAnimationStyle(R.style.KeyPreviewAnimation);\n mDelayBeforePreview = 20;\n mDelayAfterPreview = 10;\n mMiniKeyboardParent = this;\n mMiniKeyboardPopup = new PopupWindow(context);\n mMiniKeyboardPopup.setBackgroundDrawable(null);\n mMiniKeyboardPopup.setAnimationStyle(R.style.MiniKeyboardAnimation);\n mPaint = new Paint();\n mPaint.setAntiAlias(true);\n mPaint.setTextSize(keyTextSize);\n mPaint.setTextAlign(Align.CENTER);\n mPaint.setAlpha(255);\n mPadding = new Rect(0, 0, 0, 0);\n mKeyBackground.getPadding(mPadding);\n mSwipeThreshold = (int) (500 * res.getDisplayMetrics().density);\n mDisambiguateSwipe = res.getBoolean(R.bool.config_swipeDisambiguation);\n mMiniKeyboardSlideAllowance = res.getDimension(R.dimen.mini_keyboard_slide_allowance);\n GestureDetector.SimpleOnGestureListener listener =\n new GestureDetector.SimpleOnGestureListener() {\n @Override\n public boolean onFling(MotionEvent me1, MotionEvent me2, float velocityX,\n float velocityY) {\n final float absX = Math.abs(velocityX);\n final float absY = Math.abs(velocityY);\n float deltaX = me2.getX() - me1.getX();\n float deltaY = me2.getY() - me1.getY();\n int travelX = getWidth() / 2; \n int travelY = getHeight() / 2; \n mSwipeTracker.computeCurrentVelocity(1000);\n final float endingVelocityX = mSwipeTracker.getXVelocity();\n final float endingVelocityY = mSwipeTracker.getYVelocity();\n if (velocityX > mSwipeThreshold && absY < absX && deltaX > travelX) {\n if (mDisambiguateSwipe && endingVelocityX >= velocityX / 4) {\n swipeRight();\n return true;\n }\n } else if (velocityX < -mSwipeThreshold && absY < absX && deltaX < -travelX) {\n if (mDisambiguateSwipe && endingVelocityX <= velocityX / 4) {\n swipeLeft();\n return true;\n }\n } else if (velocityY < -mSwipeThreshold && absX < absY && deltaY < -travelY) {\n if (mDisambiguateSwipe && endingVelocityY <= velocityY / 4) {\n swipeUp();\n return true;\n }\n } else if (velocityY > mSwipeThreshold && absX < absY / 2 && deltaY > travelY) {\n if (mDisambiguateSwipe && endingVelocityY >= velocityY / 4) {\n swipeDown();\n return true;\n }\n }\n return false;\n }\n };\n mGestureDetector = createGestureDetector(listener);\n mGestureDetector.setIsLongpressEnabled(false);\n mHasDistinctMultitouch = systemHasMultitouch(context);\n Log.d(getKeyboardViewNameForLogging(), \"mHasDistinctMultitouch : \"+mHasDistinctMultitouch);\n mKeyRepeatInterval = 50;\n Log.i(getKeyboardViewNameForLogging(), \"Created keyboard view of type \"+getKeyboardViewNameForLogging());\n }\n"} {"input": " private C2DMConfig getDataMessagingConfig(PersistenceManager pm) {\n Key key = KeyFactory.createKey(C2DMConfig.class.getSimpleName(), 1);\n C2DMConfig dmConfig = null;\n try {\n dmConfig = pm.getObjectById(C2DMConfig.class, key);\n } catch (JDOObjectNotFoundException e) {\n dmConfig = new C2DMConfig();\n dmConfig.setKey(key);\n try {\n InputStream is = this.getClass().getClassLoader().getResourceAsStream(\"/dataMessagingToken.txt\");\n if (is != null) {\n BufferedReader reader = new BufferedReader(new InputStreamReader(is));\n String token = reader.readLine();\n dmConfig.setAuthToken(token);\n }\n } catch (Throwable t) {\n log.log(Level.SEVERE, \n \"Can't load initial token, use admin console\", t);\n }\n pm.makePersistent(dmConfig);\n }\n return dmConfig;\n }\n", "output": " private C2DMConfig getDataMessagingConfig(PersistenceManager pm) {\n Key key = KeyFactory.createKey(C2DMConfig.class.getSimpleName(), 1);\n C2DMConfig dmConfig = null;\n try {\n dmConfig = pm.getObjectById(C2DMConfig.class, key);\n } catch (JDOObjectNotFoundException e) {\n dmConfig = new C2DMConfig();\n dmConfig.setKey(key);\n try {\n InputStream is = this.getClass().getClassLoader().getResourceAsStream(\"dataMessagingToken.txt\");\n if (is != null) {\n BufferedReader reader = new BufferedReader(new InputStreamReader(is));\n String token = reader.readLine();\n dmConfig.setAuthToken(token);\n }\n } catch (Throwable t) {\n log.log(Level.SEVERE, \n \"Can't load initial token, use admin console\", t);\n }\n pm.makePersistent(dmConfig);\n }\n return dmConfig;\n }\n"} {"input": " protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n String action = req.getParameter(SUBMIT_ACTION);\n String id = req.getParameter(ID);\n String sbChannelName = req.getParameter(SB_ID);\n String youSeeName = req.getParameter(UC_ID);\n String displayName = req.getParameter(DISPLAY_NAME);\n Date fromDate;\n Date toDate;\n String fromDateS = req.getParameter(FROM_DATE);\n if (fromDateS != null || \"\".equals(fromDateS)) {\n fromDateS = \"2012-05-01 00:00\";\n }\n try {\n fromDate = JAVA_DATE_FORMAT.parse(fromDateS);\n fromDate.setSeconds(0);\n } catch (ParseException e) {\n throw new RuntimeException(\"Could not parse '\" +\n fromDateS + \"'\");\n }\n String toDateS = req.getParameter(TO_DATE);\n if (toDateS != null || \"\".equals(toDateS)) {\n toDateS = \"3000-01-01 00:00\";\n }\n try {\n toDate = JAVA_DATE_FORMAT.parse(toDateS);\n toDate.setSeconds(0);\n } catch (ParseException e) {\n throw new RuntimeException(\"Could not parse '\" +\n toDateS + \"'\");\n }\n YouSeeChannelMapping mapping = new YouSeeChannelMapping();\n if (id != null && !\"\".equals(id)) {\n mapping.setId(Long.parseLong(id));\n }\n mapping.setDisplayName(displayName);\n mapping.setFromDate(fromDate);\n mapping.setToDate(toDate);\n mapping.setSbChannelId(sbChannelName);\n mapping.setYouSeeChannelId(youSeeName);\n if (CREATE.equals(action)) {\n try {\n service.create(mapping);\n } catch (ServiceException e) {\n req.setAttribute(\"error\", e);\n }\n } else if (UPDATE.equals(action)) {\n try {\n service.update(mapping);\n } catch (ServiceException e) {\n req.setAttribute(\"error\", e);\n }\n } else if (DELETE.equals(action)) {\n try {\n service.delete(mapping);\n } catch (ServiceException e) {\n req.setAttribute(\"error\", e);\n }\n }\n req.setAttribute(\"page_attribute\", \"you_see_channel_mapping.jsp\");\n req.getSession().getServletContext().getRequestDispatcher(\"/index.jsp\").forward(req, resp);\n }\n", "output": " protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n String action = req.getParameter(SUBMIT_ACTION);\n String id = req.getParameter(ID);\n String sbChannelName = req.getParameter(SB_ID);\n String youSeeName = req.getParameter(UC_ID);\n String displayName = req.getParameter(DISPLAY_NAME);\n Date fromDate;\n Date toDate;\n String fromDateS = req.getParameter(FROM_DATE);\n if (fromDateS == null || \"\".equals(fromDateS)) {\n fromDateS = \"2012-05-01 00:00\";\n }\n try {\n fromDate = JAVA_DATE_FORMAT.parse(fromDateS);\n fromDate.setSeconds(0);\n } catch (ParseException e) {\n throw new RuntimeException(\"Could not parse '\" +\n fromDateS + \"'\");\n }\n String toDateS = req.getParameter(TO_DATE);\n if (toDateS == null || \"\".equals(toDateS)) {\n toDateS = \"3000-01-01 00:00\";\n }\n try {\n toDate = JAVA_DATE_FORMAT.parse(toDateS);\n toDate.setSeconds(0);\n } catch (ParseException e) {\n throw new RuntimeException(\"Could not parse '\" +\n toDateS + \"'\");\n }\n YouSeeChannelMapping mapping = new YouSeeChannelMapping();\n if (id != null && !\"\".equals(id)) {\n mapping.setId(Long.parseLong(id));\n }\n mapping.setDisplayName(displayName);\n mapping.setFromDate(fromDate);\n mapping.setToDate(toDate);\n mapping.setSbChannelId(sbChannelName);\n mapping.setYouSeeChannelId(youSeeName);\n if (CREATE.equals(action)) {\n try {\n service.create(mapping);\n } catch (ServiceException e) {\n req.setAttribute(\"error\", e);\n }\n } else if (UPDATE.equals(action)) {\n try {\n service.update(mapping);\n } catch (ServiceException e) {\n req.setAttribute(\"error\", e);\n }\n } else if (DELETE.equals(action)) {\n try {\n service.delete(mapping);\n } catch (ServiceException e) {\n req.setAttribute(\"error\", e);\n }\n }\n req.setAttribute(\"page_attribute\", \"you_see_channel_mapping.jsp\");\n req.getSession().getServletContext().getRequestDispatcher(\"/index.jsp\").forward(req, resp);\n }\n"} {"input": " public void testBasicAlignment() {\n String md5 = \"c6d95d8ae707e78fefdaa7375f130995\";\n WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(\n \"-R /humgen/gsa-scr1/GATK_Data/bwa/human_b36_both.fasta\" +\n \" -T Align\" +\n \" -I \" + validationDataLocation + \"NA12878_Pilot1_20.trimmed.unmapped.bam\" +\n \" -ob %s\",\n 1, \n Arrays.asList(md5));\n executeTest(\"testBasicAlignment\", spec);\n }\n", "output": " public void testBasicAlignment() {\n String md5 = \"c6d95d8ae707e78fefdaa7375f130995\";\n WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(\n \"-R \" + b36KGReference +\n \" -T Align\" +\n \" -I \" + validationDataLocation + \"NA12878_Pilot1_20.trimmed.unmapped.bam\" +\n \" -ob %s\",\n 1, \n Arrays.asList(md5));\n executeTest(\"testBasicAlignment\", spec);\n }\n"} {"input": " public static SameController create(int port) {\n ConnectionManagerImpl connections = new ConnectionManagerImpl(\n timeout, timeout);\n State state = new State(\"Default\");\n Broadcaster broadcaster = BroadcasterImpl.getDefaultBroadcastRunner();\n MasterServiceImpl master = new MasterServiceImpl(state, connections,\n broadcaster);\n JsonRpcServer jsonMaster = new JsonRpcServer(master, MasterService.class);\n ClientServiceImpl client = new ClientServiceImpl(state, connections);\n JsonRpcServer jsonClient = new JsonRpcServer(client, ClientService.class);\n PaxosServiceImpl paxos = new PaxosServiceImpl(\"\");\n JsonRpcServer jsonPaxos = new JsonRpcServer(paxos, PaxosService.class);\n Server server = new Server(port);\n SameController controller = new SameController(port, server, master, client,\n paxos);\n RpcHandler rpcHandler = new RpcHandler(null);\n rpcHandler.addRpcServer(\"/MasterService.json\", jsonMaster);\n rpcHandler.addRpcServer(\"/ClientService.json\", jsonClient);\n rpcHandler.addRpcServer(\"/PaxosService.json\", jsonPaxos);\n server.setHandler(rpcHandler);\n return controller;\n }\n", "output": " public static SameController create(int port) {\n ConnectionManagerImpl connections = new ConnectionManagerImpl(\n timeout, timeout);\n State state = new State(\"Default\");\n Broadcaster broadcaster = BroadcasterImpl.getDefaultBroadcastRunner();\n MasterServiceImpl master = new MasterServiceImpl(state, connections,\n broadcaster);\n JsonRpcServer jsonMaster = new JsonRpcServer(master, MasterService.class);\n ClientServiceImpl client = new ClientServiceImpl(state, connections);\n JsonRpcServer jsonClient = new JsonRpcServer(client.getService(),\n ClientService.class);\n PaxosServiceImpl paxos = new PaxosServiceImpl(\"\");\n JsonRpcServer jsonPaxos = new JsonRpcServer(paxos, PaxosService.class);\n Server server = new Server(port);\n SameController controller = new SameController(port, server, master, client,\n paxos);\n RpcHandler rpcHandler = new RpcHandler(null);\n rpcHandler.addRpcServer(\"/MasterService.json\", jsonMaster);\n rpcHandler.addRpcServer(\"/ClientService.json\", jsonClient);\n rpcHandler.addRpcServer(\"/PaxosService.json\", jsonPaxos);\n server.setHandler(rpcHandler);\n return controller;\n }\n"} {"input": " public static int save (String tableName, Map < String, Object > hashmap)\n {\n Connection connection = null;\n Statement stmt = null;\n ResultSet rs = null;\n String columns = \"\";\n String values = \"\";\n int id = 0;\n try\n {\n connection = Connector.getConnection();\n Map<String, String> SQLHashmap = convertJavaToSQL(hashmap);\n DatabaseMetaData md = connection.getMetaData();\n if (md.getColumns(null, null, tableName, \"creation_date\").next())\n {\n SQLHashmap.put(\"creation_date\", \"NOW()\");\n SQLHashmap.put(\"last_modified_date\", \"NOW()\");\n }\n for (String key : SQLHashmap.keySet())\n {\n columns += key + \",\";\n values += SQLHashmap.get(key) + \",\";\n }\n columns = columns.replaceAll(\",$\", \"\");\n values = values.replaceAll(\",$\", \"\");\n stmt = connection.createStatement();\n if (!hashmap.containsKey(\"id\"))\n {\n stmt.executeUpdate(\"INSERT INTO \" + tableName + \" (\" + columns + \") VALUES (\" + values + \")\",\n Statement.RETURN_GENERATED_KEYS);\n rs = stmt.getGeneratedKeys();\n if (rs.next())\n {\n id = rs.getInt(1);\n }\n }\n else \n {\n id = stmt.executeUpdate(\"INSERT INTO \" + tableName + \" (\" + columns + \") VALUES (\" + values + \")\") != 0 ? (int) hashmap\n .get(\"id\") : 0;\n }\n }\n catch (SQLException e)\n {\n e.printStackTrace();\n }\n StringBuffer sb = new StringBuffer();\n Map<String, Object> row = Manager.find(id, tableName);\n for (String key : row.keySet())\n sb.append(row.get(key).hashCode());\n String sha256 = DigestHash.getShaHash(sb.toString());\n return id;\n }\n", "output": " public static int save (String tableName, Map < String, Object > hashmap)\n {\n Connection connection = null;\n Statement stmt = null;\n ResultSet rs = null;\n String columns = \"\";\n String values = \"\";\n int id = 0;\n try\n {\n connection = Connector.getConnection();\n Map<String, String> SQLHashmap = convertJavaToSQL(hashmap);\n DatabaseMetaData md = connection.getMetaData();\n if (md.getColumns(null, null, tableName, \"creation_date\").next())\n {\n SQLHashmap.put(\"creation_date\", \"NOW()\");\n SQLHashmap.put(\"last_modified_date\", \"NOW()\");\n }\n for (String key : SQLHashmap.keySet())\n {\n columns += key + \",\";\n values += SQLHashmap.get(key) + \",\";\n }\n columns = columns.replaceAll(\",$\", \"\");\n values = values.replaceAll(\",$\", \"\");\n stmt = connection.createStatement();\n if (!hashmap.containsKey(\"id\"))\n {\n stmt.executeUpdate(\"INSERT INTO \" + tableName + \" (\" + columns + \") VALUES (\" + values + \")\",\n Statement.RETURN_GENERATED_KEYS);\n rs = stmt.getGeneratedKeys();\n if (rs.next())\n {\n id = rs.getInt(1);\n }\n }\n else \n {\n id = stmt.executeUpdate(\"INSERT INTO \" + tableName + \" (\" + columns + \") VALUES (\" + values + \")\") != 0 ? (int) hashmap\n .get(\"id\") : 0;\n }\n }\n catch (SQLException e)\n {\n e.printStackTrace();\n }\n StringBuffer sb = new StringBuffer();\n Map<String, Object> row = Manager.find(id, tableName);\n System.out.println(\"aoidjaoidjsoaisj\"+row);\n for (String key : row.keySet()){\n String value = row.get(key) == null ? \"\" : row.get(key).toString();\n sb.append(value.hashCode());\n }\n String sha256 = DigestHash.getShaHash(sb.toString());\n return id;\n }\n"} {"input": " public Economy_iConomy6(JavaPlugin plugin) {\n this.plugin = plugin;\n Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);\n if (economy == null) {\n Plugin ec = plugin.getServer().getPluginManager().getPlugin(\"iConomy\");\n if (ec != null && ec.isEnabled() && ec.getClass().getName().equals(\"com.iCo6.iConomy\")) {\n economy = (iConomy) ec;\n accounts = new Accounts();\n log.info(String.format(\"[%s][Economy] %s hooked.\", plugin.getDescription().getName(), name));\n }\n }\n }\n", "output": " public Economy_iConomy6(JavaPlugin plugin) {\n this.plugin = plugin;\n Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);\n log.severe(\"iConomy6 - If you are using Flatfile storage be aware that iCo6 has a CRITICAL bug which can wipe ALL iconomy data.\");\n log.severe(\"if you're using Votifier, or any other plugin which handles economy data in a threaded manner your server is at risk!\");\n log.severe(\"it is highly suggested to use SQL with iCo6 or to use an alternative economy plugin!\");\n if (economy == null) {\n Plugin ec = plugin.getServer().getPluginManager().getPlugin(\"iConomy\");\n if (ec != null && ec.isEnabled() && ec.getClass().getName().equals(\"com.iCo6.iConomy\")) {\n economy = (iConomy) ec;\n accounts = new Accounts();\n log.info(String.format(\"[%s][Economy] %s hooked.\", plugin.getDescription().getName(), name));\n }\n }\n }\n"} {"input": " public static ArrayList<Integer> getInedexesWithMaxRating(MCTNode node,\n int whiteRankingMethod, int blackRankingMethod)\n throws MCTUtilsException {\n ArrayList<Integer> rez = new ArrayList<Integer>();\n if (node.nextMoves == null) { throw new MCTUtilsException(\n \"node nima razvitih naslednikov\"); }\n if (node.nextMoves.size() == 0) { return rez; }\n double maxRating = Double.MIN_VALUE;\n double currRating = Double.MIN_VALUE;\n for (int x = 0; x < node.nextMoves.size(); x++) {\n if (node.isWhitesMove) {\n currRating = MCTUtils.computeNodeRating(node.nextMoves.get(x),\n whiteRankingMethod);\n }\n else {\n currRating = MCTUtils.computeNodeRating(node.nextMoves.get(x),\n blackRankingMethod);\n }\n if (currRating > maxRating) {\n maxRating = currRating;\n rez = new ArrayList<Integer>();\n }\n if (currRating == maxRating) {\n rez.add(x);\n }\n }\n if (Constants.SELECTION_ALSO_USES_VISIT_COUNT_FOR_NODE_CHOOSING) {\n int maxVisitCount = Integer.MIN_VALUE;\n ArrayList<Integer> filteredRez = new ArrayList<Integer>();\n for (Integer x : rez) {\n MCTNode currNode = node.nextMoves.get(x);\n if (currNode.visitCount > maxVisitCount) {\n maxVisitCount = currNode.visitCount;\n filteredRez = new ArrayList<Integer>();\n }\n if (currNode.visitCount == maxVisitCount) {\n filteredRez.add(x);\n }\n }\n return filteredRez;\n }\n return rez;\n }\n", "output": " public static ArrayList<Integer> getInedexesWithMaxRating(MCTNode node,\n int whiteRankingMethod, int blackRankingMethod)\n throws MCTUtilsException {\n ArrayList<Integer> rez = new ArrayList<Integer>();\n if (node.nextMoves == null) { throw new MCTUtilsException(\n \"node nima razvitih naslednikov\"); }\n if (node.nextMoves.size() == 0) { return rez; }\n double maxRating = -Double.MAX_VALUE;\n double currRating = -Double.MAX_VALUE;\n for (int x = 0; x < node.nextMoves.size(); x++) {\n if (node.isWhitesMove) {\n currRating = MCTUtils.computeNodeRating(node.nextMoves.get(x),\n whiteRankingMethod);\n }\n else {\n currRating = MCTUtils.computeNodeRating(node.nextMoves.get(x),\n blackRankingMethod);\n }\n if (currRating > maxRating) {\n maxRating = currRating;\n rez = new ArrayList<Integer>();\n }\n if (currRating == maxRating) {\n rez.add(x);\n }\n }\n if (Constants.SELECTION_ALSO_USES_VISIT_COUNT_FOR_NODE_CHOOSING) {\n int maxVisitCount = Integer.MIN_VALUE;\n ArrayList<Integer> filteredRez = new ArrayList<Integer>();\n for (Integer x : rez) {\n MCTNode currNode = node.nextMoves.get(x);\n if (currNode.visitCount > maxVisitCount) {\n maxVisitCount = currNode.visitCount;\n filteredRez = new ArrayList<Integer>();\n }\n if (currNode.visitCount == maxVisitCount) {\n filteredRez.add(x);\n }\n }\n return filteredRez;\n }\n return rez;\n }\n"} {"input": " private boolean handleKey0(KeyStroke key) {\n if (currentMode != null) {\n KeyMap map = currentMode.resolveKeyMap(keyMapProvider);\n if (map != null) {\n boolean inMapping = keyStrokeTranslator.processKeyStroke(map, key);\n if (inMapping) {\n Queue<RemappedKeyStroke> resultingKeyStrokes =\n keyStrokeTranslator.resultingKeyStrokes();\n if(currentMode.getName() == InsertMode.NAME) {\n \tif(resultingKeyStrokes.isEmpty()) {\n \t\treturn currentMode.handleKey(key);\n \t}\n \telse if(keyStrokeTranslator.numUnconsumedKeys() > 0) {\n \t\tfor(int i=0; i < keyStrokeTranslator.numUnconsumedKeys(); i++) {\n\t \t\tcurrentMode.handleKey(new RemappedKeyStroke(new SimpleKeyStroke(SpecialKey.BACKSPACE), false));\n \t\t}\n \t}\n \telse {\n \t\treturn currentMode.handleKey(key);\n \t}\n }\n while (!resultingKeyStrokes.isEmpty()) {\n RemappedKeyStroke next = resultingKeyStrokes.poll();\n if (next.isRecursive()) {\n handleKey(next);\n } else {\n currentMode.handleKey(next);\n }\n }\n return true;\n }\n }\n return currentMode.handleKey(key);\n }\n return false;\n }\n", "output": " private boolean handleKey0(KeyStroke key) {\n if (currentMode != null) {\n KeyMap map = currentMode.resolveKeyMap(keyMapProvider);\n if (map != null) {\n boolean inMapping = keyStrokeTranslator.processKeyStroke(map, key);\n if (inMapping) {\n Queue<RemappedKeyStroke> resultingKeyStrokes =\n keyStrokeTranslator.resultingKeyStrokes();\n if(currentMode.getName() == InsertMode.NAME) {\n \tif(resultingKeyStrokes.isEmpty()) {\n \t\treturn currentMode.handleKey(key);\n \t}\n \telse if(keyStrokeTranslator.numUnconsumedKeys() > 0) {\n \t\tfor(int i=0; i < keyStrokeTranslator.numUnconsumedKeys(); i++) {\n\t \t\tcurrentMode.handleKey(new RemappedKeyStroke(new SimpleKeyStroke(SpecialKey.BACKSPACE), false));\n \t\t}\n \t}\n \telse {\n \t\twhile(resultingKeyStrokes.size() > 1) {\n \t\t\tresultingKeyStrokes.remove();\n \t\t}\n \t}\n }\n while (!resultingKeyStrokes.isEmpty()) {\n RemappedKeyStroke next = resultingKeyStrokes.poll();\n if (next.isRecursive()) {\n handleKey(next);\n } else {\n currentMode.handleKey(next);\n }\n }\n return true;\n }\n }\n return currentMode.handleKey(key);\n }\n return false;\n }\n"} {"input": "\tprivate void convertDocument(InputStream inputStream, OutputStream outputStream,\n\t\t\tDataType fromDataType, DataType toDataType, Map<String, String> properties) throws IOException,\n\t\t\tSaxonApiException, ConfigurationException, ConverterException {\n\t\tString toMimeType = toDataType.getMimeType();\n\t\tString profile = properties.get(ConverterConfiguration.PROFILE_KEY);\n\t\tif (ConverterConfiguration.XML_MIME.equals(toMimeType)\n\t\t\t\t&& toDataType.getFormat().equals(ConverterConfiguration.TEI)\n\t\t\t\t&& fromDataType.getFormat().equals(Format.DOCX.getId())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.DOCX\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\ttransformFromDocX(inputStream, outputStream, profile, properties);\n\t\t}\n\t\telse if (Format.DOCX.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.DOCX\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tProcessor proc = SaxonProcFactory.getProcessor();\n\t\t\tXsltCompiler comp = proc.newXsltCompiler();\n\t\t\ttransformToDocX(inputStream, outputStream, proc, comp, profile, properties);\n\t\t}\n\t\telse if (ConverterConfiguration.XML_MIME.equals(toMimeType)\n\t\t\t\t&& toDataType.getFormat().equals(ConverterConfiguration.TEI)\n\t\t\t\t&& fromDataType.getFormat().equals(Format.ODT.getId())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODT\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\ttransformFromOdt(inputStream, outputStream, profile, properties);\n\t\t}\n\t\telse if (Format.ODT.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODT\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tProcessor proc = SaxonProcFactory.getProcessor();\n\t\t\tXsltCompiler comp = proc.newXsltCompiler();\n\t\t\ttransformToOdt(inputStream, outputStream, proc, comp, profile, properties);\n\t\t}\n\t\telse if (Format.ODDHTML.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.ODDHTML.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODDHTML\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"html\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.ODDHTML\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.XHTML.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.XHTML\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"html\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.XHTML\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.RELAXNG.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RELAXNG\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"rng\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.RELAXNG\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.RNC.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.RNC.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RELAXNG\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"rnc\");\n\t\t\ttry {\n\t\t\t generateRngThenTrang(inputStream, outputStream, Format.RELAXNG\n\t\t\t\t\t\t\t .getProfile(), profile, properties);\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new IOException(\"to RNG then Trang failed: \" + e.toString());\n\t\t\t}\n\t\t}\n\t\telse if (Format.XSD.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.XSD.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RELAXNG\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"xsd\");\n\t\t\ttry {\n\t\t\t generateRngThenTrang(inputStream, outputStream, Format.RELAXNG\n\t\t\t\t\t\t\t .getProfile(), profile, properties);\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new IOException(\"to RNG then Trang failed: \" + e.toString());\n\t\t\t}\n\t\t}\n\t\telse if (Format.DTD.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.DTD\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"dtd\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.DTD\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.LITE.getMimeType().equals(toMimeType) \n\t\t\t && fromDataType.getFormat().equals(Format.LITE.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.LITE\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"xml\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.LITE\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.LATEX.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.LATEX\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"tex\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.LATEX\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.ODDJSON.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODDJSON\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"json\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.ODDJSON\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.FO.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.FO\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"fo\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.FO\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.EPUB.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.EPUB\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\ttransformToEpub(inputStream, outputStream, profile, Format.EPUB.getProfile(), properties);\n\t\t}\n\t\telse if (Format.TEXT.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.TEXT.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.TEXT\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"txt\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.TEXT\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.XML.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.XML.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.XML\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"xml\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.XML\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.RDF.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.RDF.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RDF\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"rdf\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.RDF\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t}\n", "output": "\tprivate void convertDocument(InputStream inputStream, OutputStream outputStream,\n\t\t\tDataType fromDataType, DataType toDataType, Map<String, String> properties) throws IOException,\n\t\t\tSaxonApiException, ConfigurationException, ConverterException {\n\t\tString toMimeType = toDataType.getMimeType();\n\t\tString profile = properties.get(ConverterConfiguration.PROFILE_KEY);\n\t\tif (ConverterConfiguration.XML_MIME.equals(toMimeType)\n\t\t\t\t&& toDataType.getFormat().equals(ConverterConfiguration.TEI)\n\t\t\t\t&& fromDataType.getFormat().equals(Format.DOCX.getId())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.DOCX\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\ttransformFromDocX(inputStream, outputStream, profile, properties);\n\t\t}\n\t\telse if (Format.DOCX.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.DOCX\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tProcessor proc = SaxonProcFactory.getProcessor();\n\t\t\tXsltCompiler comp = proc.newXsltCompiler();\n\t\t\ttransformToDocX(inputStream, outputStream, proc, comp, profile, properties);\n\t\t}\n\t\telse if (ConverterConfiguration.XML_MIME.equals(toMimeType)\n\t\t\t\t&& toDataType.getFormat().equals(ConverterConfiguration.TEI)\n\t\t\t\t&& fromDataType.getFormat().equals(Format.ODT.getId())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODT\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\ttransformFromOdt(inputStream, outputStream, profile, properties);\n\t\t}\n\t\telse if (Format.ODT.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODT\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tProcessor proc = SaxonProcFactory.getProcessor();\n\t\t\tXsltCompiler comp = proc.newXsltCompiler();\n\t\t\ttransformToOdt(inputStream, outputStream, proc, comp, profile, properties);\n\t\t}\n\t\telse if (Format.ODDHTML.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.ODDHTML.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODDHTML\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"html\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.ODDHTML\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.XHTML.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.XHTML\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"html\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.XHTML\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.RELAXNG.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RELAXNG\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"rng\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.RELAXNG\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.RNC.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.RNC.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RELAXNG\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"rnc\");\n\t\t\ttry {\n\t\t\t generateRngThenTrang(inputStream, outputStream, Format.RELAXNG\n\t\t\t\t\t\t\t .getProfile(), profile, properties);\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new IOException(\"to RNG then Trang failed: \" + e.toString());\n\t\t\t}\n\t\t}\n\t\telse if (Format.XSD.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.XSD.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RELAXNG\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"zip\");\n\t\t\ttry {\n\t\t\t generateRngThenTrang(inputStream, outputStream, Format.RELAXNG\n\t\t\t\t\t\t\t .getProfile(), profile, properties);\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new IOException(\"to RNG then Trang failed: \" + e.toString());\n\t\t\t}\n\t\t}\n\t\telse if (Format.DTD.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.DTD\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"dtd\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.DTD\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.LITE.getMimeType().equals(toMimeType) \n\t\t\t && fromDataType.getFormat().equals(Format.LITE.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.LITE\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"xml\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.LITE\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.LATEX.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.LATEX\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"tex\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.LATEX\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.ODDJSON.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.ODDJSON\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"json\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.ODDJSON\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.FO.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.FO\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"fo\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.FO\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.EPUB.getMimeType().equals(toMimeType)) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.EPUB\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\ttransformToEpub(inputStream, outputStream, profile, Format.EPUB.getProfile(), properties);\n\t\t}\n\t\telse if (Format.TEXT.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.TEXT.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.TEXT\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"txt\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.TEXT\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.XML.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.XML.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.XML\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"xml\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.XML\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t\telse if (Format.RDF.getMimeType().equals(toMimeType)\n\t\t\t && fromDataType.getFormat().equals(Format.RDF.getFormatName())) {\n\t\t\tif (!ConverterConfiguration.checkProfile(profile, Format.RDF\n\t\t\t\t\t.getProfile())) {\n\t\t\t\tLOGGER.debug(ConverterConfiguration.PROFILE_NOT_FOUND_MSG);\n\t\t\t\tprofile = EGEConstants.DEFAULT_PROFILE;\n\t\t\t}\n\t\t\tproperties.put(\"extension\", \"rdf\");\n\t\t\tperformXsltTransformation(inputStream, outputStream, Format.RDF\n\t\t\t\t\t.getProfile(), profile, properties);\n\t\t}\n\t}\n"} {"input": "\tpublic static void main(String[] args) {\n\t\tString str = null;\n\t\tString str2 = \"Object\";\n\t\tint n = 10;\n\t\tn = n + 1;\n\t\tif (str instanceof String) {\n\t\t\tSystem.out.println(\"STRING\");\n\t\t} else if (str2.equals(str)) {\n\t\t\tSystem.out.println(\"EQUAL\");\n\t\t}\n\t\tswitch (n) {\n\t\t\tcase 1 :\n\t\t\t\tSystem.out.println(n);\n\t\t\t\tbreak;\n\t\t\tcase 2 :\n\t\t\t\tSystem.out.println(n + 1);\n\t\t\t\tbreak;\n\t\t\tcase 3 :\n\t\t\t\tSystem.out.println(n + 1);\n\t\t\t\tbreak;\n\t\t\tdefault :\n\t\t\t\tSystem.out.println(n + 3);\n\t\t\t\tbreak;\n\t\t}\n\t\tString str3 = \"Test\";\n\t\tBoolean bool = true;\n\t\tSystem.out.println(bool);\n\t\tint x = 10;\n\t\tboolean ean = true;\n\t\tif (ean == false) {\n\t\t\tSystem.out.println(\"STRING\");\n\t\t}\n\t\tint b = 100;\n\t\tb = 10;\n\t}\n", "output": "\tpublic static void main(String[] args) {\n\t\tString str = null;\n\t\tString str2 = \"Object\";\n\t\tint n = 10;\n\t\tn = n + 1;\n\t\tif (str instanceof String) {\n\t\t\tSystem.out.println(\"STRING\");\n\t\t} else if (str2.equals(str)) {\n\t\t\tSystem.out.println(\"EQUAL\");\n\t\t}\n\t\tswitch (n) {\n\t\t\tcase 1 :\n\t\t\t\tSystem.out.println(n);\n\t\t\tcase 2 :\n\t\t\t\tSystem.out.println(n + 1);\n\t\t\tcase 3 :\n\t\t\t\tSystem.out.println(n + 1);\n\t\t\tdefault :\n\t\t\t\tSystem.out.println(n + 3);\n\t\t}\n\t\tString str3 = \"Test\";\n\t\tBoolean bool = true;\n\t\tSystem.out.println(bool);\n\t\tint x = 10;\n\t\tboolean ean = true;\n\t\tif (ean == false) {\n\t\t\tSystem.out.println(\"STRING\");\n\t\t}\n\t\tint b = 100;\n\t\tb = 10;\n\t}\n"} {"input": "\tprotected void extractResult(Message reqMessage, List<IIndexerDocument> results) {\n\t\tList<Message> messageList = null;\n\t\tsynchronized (this.resultMap) {\t\t\t\t\n\t\t\tif (!this.resultMap.containsKey(Integer.valueOf(reqMessage.getMessageNumber()))) {\n\t\t\t\tthis.logger.warn(\"Unknown requestID: \" + reqMessage.getMessageNumber());\n\t\t\t\tmessageList = Collections.EMPTY_LIST;\n\t\t\t} else {\n\t\t\t\tmessageList = this.resultMap.remove(Integer.valueOf(reqMessage.getMessageNumber()));\n\t\t\t}\n\t\t}\t\n\t\tfor (Message msg : messageList) {\n\t\t\ttry {\n\t\t\t\tMessageElement resultListElement = msg.getMessageElement(SearchServiceConstants.RESP_RESULT);\t\t\t\n\t\t\t\tSAXReader reader = new SAXReader();\n\t\t\t\tDocument xmlDoc = reader.read(resultListElement.getStream());\n\t\t\t\tElement xmlRoot = xmlDoc.getRootElement();\n\t\t for (Iterator<Element> i = xmlRoot.elementIterator(SearchServiceConstants.RESULT_ENTRY); i.hasNext(); ) {\n\t\t Element resultElement = i.next();\n\t\t\t for (Iterator<Element> j = resultElement.elementIterator(SearchServiceConstants.RESULT_ENTRY_ITEM); j.hasNext(); ) {\n\t\t\t \tElement resultItemElement = j.next();\t\t\t \t\n\t\t\t \tIndexerDocument indexerDoc = new IndexerDocument();\n\t\t\t \tfor (Iterator<Element> k = resultItemElement.elementIterator(); k.hasNext(); ) {\n\t\t\t \t\tElement resultItemFieldElement = k.next();\n\t\t\t \t\tString fieldName = resultItemFieldElement.getName();\n\t\t\t \t\tString fieldValue = resultItemFieldElement.getText();\n\t\t\t \t\tfinal org.paxle.core.doc.Field<?> pfield = this.fieldManager.get(fieldName);\n\t\t\t \t\t\tif (pfield != null) {\t\t\t \t\t\t\t\n\t\t\t \t\t\t\tindexerDoc.put(pfield, fieldValue);\n\t\t\t \t\t\t}\n\t\t\t \t}\n\t\t\t \tresults.add(indexerDoc);\n\t\t\t }\n\t\t }\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprotected void extractResult(Message reqMessage, List<IIndexerDocument> results) {\n\t\tList<Message> messageList = null;\n\t\tsynchronized (this.resultMap) {\t\t\t\t\n\t\t\tif (!this.resultMap.containsKey(Integer.valueOf(reqMessage.getMessageNumber()))) {\n\t\t\t\tthis.logger.warn(\"Unknown requestID: \" + reqMessage.getMessageNumber());\n\t\t\t\tmessageList = Collections.emptyList();\n\t\t\t} else {\n\t\t\t\tmessageList = this.resultMap.remove(Integer.valueOf(reqMessage.getMessageNumber()));\n\t\t\t}\n\t\t}\t\n\t\tfor (Message msg : messageList) {\n\t\t\ttry {\n\t\t\t\tMessageElement resultListElement = msg.getMessageElement(SearchServiceConstants.RESP_RESULT);\t\t\t\n\t\t\t\tSAXReader reader = new SAXReader();\n\t\t\t\tDocument xmlDoc = reader.read(resultListElement.getStream());\n\t\t\t\tElement xmlRoot = xmlDoc.getRootElement();\n\t\t for (Iterator<Element> i = xmlRoot.elementIterator(SearchServiceConstants.RESULT_ENTRY); i.hasNext(); ) {\n\t\t Element resultElement = i.next();\n\t\t\t for (Iterator<Element> j = resultElement.elementIterator(SearchServiceConstants.RESULT_ENTRY_ITEM); j.hasNext(); ) {\n\t\t\t \tElement resultItemElement = j.next();\t\t\t \t\n\t\t\t \tIndexerDocument indexerDoc = new IndexerDocument();\n\t\t\t \tfor (Iterator<Element> k = resultItemElement.elementIterator(); k.hasNext(); ) {\n\t\t\t \t\tElement resultItemFieldElement = k.next();\n\t\t\t \t\tString fieldName = resultItemFieldElement.getName();\n\t\t\t \t\tString fieldValue = resultItemFieldElement.getText();\n\t\t\t \t\tfinal org.paxle.core.doc.Field<?> pfield = this.fieldManager.get(fieldName);\n\t\t\t \t\t\tif (pfield != null) {\t\t\t \t\t\t\t\n\t\t\t \t\t\t\tindexerDoc.put(pfield, fieldValue);\n\t\t\t \t\t\t}\n\t\t\t \t}\n\t\t\t \tresults.add(indexerDoc);\n\t\t\t }\n\t\t }\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public Contact insert(Contact contact) throws SaveException {\n final String query = \"INSERT INTO Contact (Contact_Name \"\n + \"Contact_Zip_Code, Contact_City, Contact_Street, Contact_Street_Number, \"\n + \"Contact_Shortcut, Contact_Phone, Contact_Fax, Contact_Mobile, Contact_Email) \"\n + \"VALUES (:name, :zipCode, :city, :street, :streetNumber, \"\n + \":shortcut, :phone, :fax, :mobile, :email);\";\n try (Connection con = DatabaseFactory.getConnection()) {\n try (NamedParameterStatement stmt = NamedParameterStatement.fromConnection(con, query)) {\n stmt.setParameter(\"name\", contact.getName());\n stmt.setParameter(\"zipCode\", contact.getPostCode());\n stmt.setParameter(\"city\", contact.getCity());\n stmt.setParameter(\"street\", contact.getStreet());\n stmt.setParameter(\"streetNumber\", contact.getStreetNo());\n stmt.setParameter(\"shortcut\", contact.getShortcut().orNull());\n stmt.setParameter(\"phone\", contact.getPhone().orNull());\n stmt.setParameter(\"fax\", contact.getFax().orNull());\n stmt.setParameter(\"mobile\", contact.getMobile().orNull());\n stmt.setParameter(\"email\", contact.getEmail().orNull());\n int affectedRows = stmt.executeUpdate();\n if (affectedRows != 1) {\n throw new SaveException();\n }\n try (ResultSet generatedKeys = stmt.getGeneratedKeys()) {\n if (generatedKeys.next()) {\n int id = generatedKeys.getInt(1);\n Contact inserted = new Contact(id, contact.getName(), contact.getStreet(),\n contact.getStreetNo(), contact.getPostCode(), contact.getCity());\n inserted.setShortcut(contact.getShortcut().orNull());\n inserted.setPhone(contact.getPhone().orNull());\n inserted.setFax(contact.getFax().orNull());\n inserted.setMobile(contact.getMobile().orNull());\n inserted.setEmail(contact.getEmail().orNull());\n return inserted;\n }\n else {\n throw new SaveException(\"Could not retrieve generated ID.\");\n }\n }\n }\n }\n catch (SQLException | DatabaseException e) {\n throw new SaveException(e);\n }\n }\n", "output": " public Contact insert(Contact contact) throws SaveException {\n final String query = \"INSERT INTO Contact (Contact_Name, \"\n + \"Contact_Zip_Code, Contact_City, Contact_Street, Contact_Street_Number, \"\n + \"Contact_Shortcut, Contact_Phone, Contact_Fax, Contact_Mobile, Contact_Email) \"\n + \"VALUES (:name, :zipCode, :city, :street, :streetNumber, \"\n + \":shortcut, :phone, :fax, :mobile, :email);\";\n try (Connection con = DatabaseFactory.getConnection()) {\n try (NamedParameterStatement stmt = NamedParameterStatement.fromConnection(con, query)) {\n stmt.setParameter(\"name\", contact.getName());\n stmt.setParameter(\"zipCode\", contact.getPostCode());\n stmt.setParameter(\"city\", contact.getCity());\n stmt.setParameter(\"street\", contact.getStreet());\n stmt.setParameter(\"streetNumber\", contact.getStreetNo());\n stmt.setParameter(\"shortcut\", contact.getShortcut().orNull());\n stmt.setParameter(\"phone\", contact.getPhone().orNull());\n stmt.setParameter(\"fax\", contact.getFax().orNull());\n stmt.setParameter(\"mobile\", contact.getMobile().orNull());\n stmt.setParameter(\"email\", contact.getEmail().orNull());\n int affectedRows = stmt.executeUpdate();\n if (affectedRows != 1) {\n throw new SaveException();\n }\n try (ResultSet generatedKeys = stmt.getGeneratedKeys()) {\n if (generatedKeys.next()) {\n int id = generatedKeys.getInt(1);\n Contact inserted = new Contact(id, contact.getName(), contact.getStreet(),\n contact.getStreetNo(), contact.getPostCode(), contact.getCity());\n inserted.setShortcut(contact.getShortcut().orNull());\n inserted.setPhone(contact.getPhone().orNull());\n inserted.setFax(contact.getFax().orNull());\n inserted.setMobile(contact.getMobile().orNull());\n inserted.setEmail(contact.getEmail().orNull());\n return inserted;\n }\n else {\n throw new SaveException(\"Could not retrieve generated ID.\");\n }\n }\n }\n }\n catch (SQLException | DatabaseException e) {\n throw new SaveException(e);\n }\n }\n"} {"input": "\tprotected List<Element> handleModFind( Element contextNode, Element node ) {\n\t\tList<Element> result = null;\n\t\tif ( node.getNamespace().equals( modNS ) ) {\n\t\t\tif ( node.getName().equals( \"findName\" ) ) {\n\t\t\t\tString searchName = node.getAttributeValue( \"name\" );\n\t\t\t\tString searchType = node.getAttributeValue( \"type\" );\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", true );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", 1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchName == null || searchName.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> requires a name attribute (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchType != null && searchType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tMap<String,String> attrMap = new HashMap<String,String>();\n\t\t\t\tattrMap.put( \"name\", searchName );\n\t\t\t\tLikeFilter searchFilter = new LikeFilter( searchType, attrMap, null );\n\t\t\t\tList<Element> matchedNodes = new ArrayList<Element>( contextNode.getContent( searchFilter ) );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t\telse if ( node.getName().equals( \"findLike\" ) ) {\n\t\t\t\tString searchType = node.getAttributeValue( \"type\" );\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", false );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", -1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchType != null && searchType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tMap<String,String> attrMap = new HashMap<String,String>();\n\t\t\t\tString searchValue = null;\n\t\t\t\tElement selectorNode = node.getChild( \"selector\", modNS );\n\t\t\t\tif ( selectorNode != null ) {\n\t\t\t\t\tfor ( Attribute attr : selectorNode.getAttributes() ) {\n\t\t\t\t\t\tif ( attr.getNamespace().equals( Namespace.NO_NAMESPACE ) ) {\n\t\t\t\t\t\t\tif ( attr.getValue().length() == 0 )\n\t\t\t\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> attributes, when present, can't be empty (%s).\", selectorNode.getName(), getPathToRoot(selectorNode) ) );\n\t\t\t\t\t\t\tattrMap.put( attr.getName(), attr.getValue() );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsearchValue = selectorNode.getTextTrim(); \n\t\t\t\t\tif ( searchValue.length() > 0 ) searchValue = null;\n\t\t\t\t}\n\t\t\t\tLikeFilter searchFilter = new LikeFilter( searchType, attrMap, searchValue );\n\t\t\t\tList<Element> matchedNodes = new ArrayList<Element>( contextNode.getContent( searchFilter ) );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t\telse if ( node.getName().equals( \"findWithChildLike\" ) ) {\n\t\t\t\tString searchType = node.getAttributeValue( \"type\" );\n\t\t\t\tString searchChildType = node.getAttributeValue( \"child-type\" );\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", false );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", -1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchType != null && searchType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchChildType != null && searchChildType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> child-type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tMap<String,String> attrMap = new HashMap<String,String>();\n\t\t\t\tString searchValue = null;\n\t\t\t\tElement selectorNode = node.getChild( \"selector\", modNS );\n\t\t\t\tif ( selectorNode != null ) {\n\t\t\t\t\tfor ( Attribute attr : selectorNode.getAttributes() ) {\n\t\t\t\t\t\tif ( attr.getNamespace().equals( Namespace.NO_NAMESPACE ) ) {\n\t\t\t\t\t\t\tattrMap.put( attr.getName(), attr.getValue() );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsearchValue = selectorNode.getTextTrim(); \n\t\t\t\t\tif ( searchValue.length() > 0 ) searchValue = null;\n\t\t\t\t}\n\t\t\t\tLikeFilter searchChildFilter = new LikeFilter( searchChildType, attrMap, searchValue );\n\t\t\t\tWithChildFilter searchFilter = new WithChildFilter( searchType, searchChildFilter );\n\t\t\t\tList<Element> matchedNodes = new ArrayList<Element>( contextNode.getContent( searchFilter ) );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t\telse if ( node.getName().equals( \"findComposite\" ) ) {\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", false );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", -1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tElement parNode = node.getChild( \"par\", modNS );\n\t\t\t\tif ( parNode == null )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> requires a <par> tag (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tList<Element> matchedNodes = handleModPar( contextNode, parNode );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n", "output": "\tprotected List<Element> handleModFind( Element contextNode, Element node ) {\n\t\tList<Element> result = null;\n\t\tif ( node.getNamespace().equals( modNS ) ) {\n\t\t\tif ( node.getName().equals( \"findName\" ) ) {\n\t\t\t\tString searchName = node.getAttributeValue( \"name\" );\n\t\t\t\tString searchType = node.getAttributeValue( \"type\" );\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", true );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", 1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchName == null || searchName.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> requires a name attribute (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchType != null && searchType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tMap<String,String> attrMap = new HashMap<String,String>();\n\t\t\t\tattrMap.put( \"name\", searchName );\n\t\t\t\tLikeFilter searchFilter = new LikeFilter( searchType, attrMap, null );\n\t\t\t\tList<Element> matchedNodes = new ArrayList<Element>( contextNode.getContent( searchFilter ) );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t\telse if ( node.getName().equals( \"findLike\" ) ) {\n\t\t\t\tString searchType = node.getAttributeValue( \"type\" );\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", false );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", -1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchType != null && searchType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tMap<String,String> attrMap = new HashMap<String,String>();\n\t\t\t\tString searchValue = null;\n\t\t\t\tElement selectorNode = node.getChild( \"selector\", modNS );\n\t\t\t\tif ( selectorNode != null ) {\n\t\t\t\t\tfor ( Attribute attr : selectorNode.getAttributes() ) {\n\t\t\t\t\t\tif ( attr.getNamespace().equals( Namespace.NO_NAMESPACE ) ) {\n\t\t\t\t\t\t\tif ( attr.getValue().length() == 0 )\n\t\t\t\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> attributes, when present, can't be empty (%s).\", selectorNode.getName(), getPathToRoot(selectorNode) ) );\n\t\t\t\t\t\t\tattrMap.put( attr.getName(), attr.getValue() );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsearchValue = selectorNode.getTextTrim(); \n\t\t\t\t\tif ( searchValue.length() == 0 ) searchValue = null;\n\t\t\t\t}\n\t\t\t\tLikeFilter searchFilter = new LikeFilter( searchType, attrMap, searchValue );\n\t\t\t\tList<Element> matchedNodes = new ArrayList<Element>( contextNode.getContent( searchFilter ) );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t\telse if ( node.getName().equals( \"findWithChildLike\" ) ) {\n\t\t\t\tString searchType = node.getAttributeValue( \"type\" );\n\t\t\t\tString searchChildType = node.getAttributeValue( \"child-type\" );\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", false );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", -1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchType != null && searchType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchChildType != null && searchChildType.length() == 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> child-type attribute, when present, can't be empty (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tMap<String,String> attrMap = new HashMap<String,String>();\n\t\t\t\tString searchValue = null;\n\t\t\t\tElement selectorNode = node.getChild( \"selector\", modNS );\n\t\t\t\tif ( selectorNode != null ) {\n\t\t\t\t\tfor ( Attribute attr : selectorNode.getAttributes() ) {\n\t\t\t\t\t\tif ( attr.getNamespace().equals( Namespace.NO_NAMESPACE ) ) {\n\t\t\t\t\t\t\tattrMap.put( attr.getName(), attr.getValue() );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsearchValue = selectorNode.getTextTrim(); \n\t\t\t\t\tif ( searchValue.length() == 0 ) searchValue = null;\n\t\t\t\t}\n\t\t\t\tLikeFilter searchChildFilter = new LikeFilter( searchChildType, attrMap, searchValue );\n\t\t\t\tWithChildFilter searchFilter = new WithChildFilter( searchType, searchChildFilter );\n\t\t\t\tList<Element> matchedNodes = new ArrayList<Element>( contextNode.getContent( searchFilter ) );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t\telse if ( node.getName().equals( \"findComposite\" ) ) {\n\t\t\t\tboolean searchReverse = getAttributeBooleanValue( node, \"reverse\", false );\n\t\t\t\tint searchStart = getAttributeIntValue( node, \"start\", 0 );\n\t\t\t\tint searchLimit = getAttributeIntValue( node, \"limit\", -1 );\n\t\t\t\tboolean panic = getAttributeBooleanValue( node, \"panic\", false );\n\t\t\t\tif ( searchStart < 0 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'start' attribute is not >= 0 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tif ( searchLimit < -1 )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> 'limit' attribute is not >= -1 (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tElement parNode = node.getChild( \"par\", modNS );\n\t\t\t\tif ( parNode == null )\n\t\t\t\t\tthrow new IllegalArgumentException( String.format( \"<%s> requires a <par> tag (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tList<Element> matchedNodes = handleModPar( contextNode, parNode );\n\t\t\t\tif ( searchReverse ) Collections.reverse( matchedNodes );\n\t\t\t\tif ( searchStart < matchedNodes.size() ) {\n\t\t\t\t\tif ( searchLimit > -1 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, Math.max( matchedNodes.size(), searchStart + searchLimit ) );\n\t\t\t\t\t} else if ( searchStart > 0 ) {\n\t\t\t\t\t\tmatchedNodes = matchedNodes.subList( searchStart, matchedNodes.size() );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( panic && matchedNodes.isEmpty() )\n\t\t\t\t\tthrow new NoSuchElementException( String.format( \"<%s> was set to require results but found none (%s).\", node.getName(), getPathToRoot(node) ) );\n\t\t\t\tresult = matchedNodes;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n"} {"input": " public ResourceBundle getBundle() {\n if (this.bundle == null) {\n Locale locale = getLocale();\n String baseName = (String) get(Config.FMT_LOCALIZATION_CONTEXT);\n if (baseName == null) {\n baseName = DEFAULT_BUNDLE_NAME;\n }\n try {\n\t\t\t\tthis.bundle = new SafeResourceBundle(ResourceBundle.getBundle(baseName, locale));\n\t\t\t} catch (MissingResourceException e) {\n\t\t\t\tlogger.warn(\"couldn't find message bundle, creating an empty one\", e);\n\t\t\t\tthis.bundle = new SafeResourceBundle(createEmptyBundle());\n\t\t\t}\n }\n return this.bundle;\n }\n", "output": " public ResourceBundle getBundle() {\n if (this.bundle == null) {\n Locale locale = getLocale();\n String baseName = (String) get(Config.FMT_LOCALIZATION_CONTEXT);\n if (baseName == null) {\n baseName = DEFAULT_BUNDLE_NAME;\n }\n try {\n\t\t\t\tthis.bundle = new SafeResourceBundle(ResourceBundle.getBundle(baseName, locale));\n\t\t\t} catch (MissingResourceException e) {\n\t\t\t\tlogger.warn(\"couldn't find message bundle, creating an empty one\");\n\t\t\t\tthis.bundle = new SafeResourceBundle(createEmptyBundle());\n\t\t\t}\n }\n return this.bundle;\n }\n"} {"input": " public boolean isPluginWebResourceBatchingEnabled()\n {\n final String explicitSetting = System.getProperty(PLUGIN_WEBRESOURCE_BATCHING_OFF);\n if (explicitSetting != null)\n {\n return Boolean.parseBoolean(explicitSetting);\n }\n else\n {\n return Boolean.parseBoolean(System.getProperty(PluginUtils.ATLASSIAN_DEV_MODE));\n }\n }\n", "output": " public boolean isPluginWebResourceBatchingEnabled()\n {\n final String explicitSetting = System.getProperty(PLUGIN_WEBRESOURCE_BATCHING_OFF);\n if (explicitSetting != null)\n {\n return !Boolean.parseBoolean(explicitSetting);\n }\n else\n {\n return !Boolean.parseBoolean(System.getProperty(PluginUtils.ATLASSIAN_DEV_MODE));\n }\n }\n"} {"input": "\tpublic boolean ausfuehren(ServerKontext kontext, Spieler spieler,\n\t\t\tBefehlszeile befehlszeile)\n\t{\n\t\tString string = befehlszeile.getGeparsteZeile().get(1);\n\t\tif(\"katze\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"Katzen:\");\n\t\t\tfor(Raum raum : kontext.getRaeume())\n\t\t\t{\n\t\t\t\tif(raum.hasKatze())\n\t\t\t\t\tkontext.schreibeAnSpieler(spieler, raum.getName());\n\t\t\t}\n\t\t}\n\t\tif(\"maus\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"M\u00e4use:\");\n\t\t\tfor(Raum raum : kontext.getRaeume())\n\t\t\t{\n\t\t\t\tif(raum.hasMaus())\n\t\t\t\t\tkontext.schreibeAnSpieler(spieler, raum.getName());\n\t\t\t}\n\t\t}\n\t\tif(\"spieler\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"Spieler:\");\n\t\t\tfor(Spieler fremderSpieler : kontext.getSpielerListe())\n\t\t\t{\n\t\t\t\tkontext.schreibeAnSpieler(spieler, fremderSpieler.getName()\n\t\t\t\t\t\t+ \": \" + kontext.getAktuellenRaumZu(spieler).getName());\n\t\t\t}\n\t\t}\n\t\tif(\"lebensenergie\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"Lebensenergie:\");\n\t\t\tkontext.schreibeAnSpieler(spieler, \"\" + spieler.getLebensEnergie());\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean ausfuehren(ServerKontext kontext, Spieler spieler,\n\t\t\tBefehlszeile befehlszeile)\n\t{\n\t\tString string = befehlszeile.getGeparsteZeile().get(1);\n\t\tif(\"katze\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"Katzen:\");\n\t\t\tfor(Raum raum : kontext.getRaeume())\n\t\t\t{\n\t\t\t\tif(raum.hasKatze())\n\t\t\t\t\tkontext.schreibeAnSpieler(spieler, raum.getName());\n\t\t\t}\n\t\t}\n\t\tif(\"maus\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"M\u00e4use:\");\n\t\t\tfor(Raum raum : kontext.getRaeume())\n\t\t\t{\n\t\t\t\tif(raum.hasMaus())\n\t\t\t\t\tkontext.schreibeAnSpieler(spieler, raum.getName());\n\t\t\t}\n\t\t}\n\t\tif(\"spieler\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"Spieler:\");\n\t\t\tfor(Spieler fremderSpieler : kontext.getSpielerListe())\n\t\t\t{\n\t\t\t\tkontext.schreibeAnSpieler(spieler, fremderSpieler.getName()\n\t\t\t\t\t\t+ \": \"\n\t\t\t\t\t\t+ kontext.getAktuellenRaumZu(fremderSpieler).getName());\n\t\t\t}\n\t\t}\n\t\tif(\"lebensenergie\".equals(string))\n\t\t{\n\t\t\tkontext.schreibeAnSpieler(spieler, \"Lebensenergie:\");\n\t\t\tkontext.schreibeAnSpieler(spieler, \"\" + spieler.getLebensEnergie());\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": " public World step(Input input) {\n Env env = getEnv();\n Player player = getPlayer();\n boolean touchingFloor = env.isTouchingFloor(player);\n int ax = 0;\n int ay = 0;\n if (touchingFloor) {\n if (input.isJumpPressed()) {\n ay -= Player.JUMP;\n }\n if (input.isLeftPressed()) {\n ax -= 1;\n }\n if (input.isRightPressed()) {\n ax += 1;\n }\n }\n int vx;\n int vy = player.getVy() + ay*Player.VELOCITY_SCALE;\n if (IS_PERSON) {\n if (touchingFloor) {\n vx = 5*ax*Player.VELOCITY_SCALE;\n } else {\n vx = player.getVx();\n }\n } else {\n vx = player.getVx() + ax*Player.VELOCITY_SCALE;\n }\n if (touchingFloor) {\n if (!IS_PERSON) {\n vx -= Integer.signum(vx)*FRICTION;\n }\n } else {\n vy += GRAVITY;\n }\n int dx = (int) Math.round((double) vx/Player.VELOCITY_SCALE);\n int x = player.getX() + dx;\n int y = player.getY() + (int) Math.round((double) vy/Player.VELOCITY_SCALE);\n int angle = player.getAngle() - 360*dx/player.getCircumference();\n double radius = player.getRealRadius();\n int toyIndex = env.getToyIndex(player);\n if (toyIndex >= 0) {\n Toy toy = env.getToy(toyIndex);\n radius += 2.0*toy.getRadius()*toy.getRadius()/(radius*radius);\n env = env.withoutToy(toyIndex);\n }\n Integer pushBack = env.getPushBack(player, x, y, vx, vy);\n if (pushBack != null) {\n int dy = pushBack.intValue();\n y -= dy;\n if ((vy > 0) == (dy > 0)) {\n vy = 0;\n }\n }\n if (y > Env.HEIGHT) {\n x = Env.WIDTH/2;\n y = Env.HEIGHT/3;\n vx = 0;\n vy = 0;\n }\n Player newPlayer = new Player(x, y, angle, vx, vy, radius);\n return new World(env, newPlayer);\n }\n", "output": " public World step(Input input) {\n Env env = getEnv();\n Player player = getPlayer();\n boolean touchingFloor = env.isTouchingFloor(player);\n int ax = 0;\n int ay = 0;\n if (touchingFloor) {\n if (input.isJumpPressed()) {\n ay -= Player.JUMP;\n }\n if (input.isLeftPressed()) {\n ax -= 1;\n }\n if (input.isRightPressed()) {\n ax += 1;\n }\n }\n int vx;\n int vy = player.getVy() + ay*Player.VELOCITY_SCALE;\n if (IS_PERSON) {\n if (touchingFloor) {\n vx = 3*ax*Player.VELOCITY_SCALE;\n } else {\n vx = player.getVx();\n }\n } else {\n vx = player.getVx() + ax*Player.VELOCITY_SCALE;\n }\n if (touchingFloor) {\n if (!IS_PERSON) {\n vx -= Integer.signum(vx)*FRICTION;\n }\n } else {\n vy += GRAVITY;\n }\n int dx = (int) Math.round((double) vx/Player.VELOCITY_SCALE);\n int x = player.getX() + dx;\n int y = player.getY() + (int) Math.round((double) vy/Player.VELOCITY_SCALE);\n int angle = player.getAngle() - 360*dx/player.getCircumference();\n double radius = player.getRealRadius();\n int toyIndex = env.getToyIndex(player);\n if (toyIndex >= 0) {\n Toy toy = env.getToy(toyIndex);\n radius += 2.0*toy.getRadius()*toy.getRadius()/(radius*radius);\n env = env.withoutToy(toyIndex);\n }\n Integer pushBack = env.getPushBack(player, x, y, vx, vy);\n if (pushBack != null) {\n int dy = pushBack.intValue();\n y -= dy;\n if ((vy > 0) == (dy > 0)) {\n vy = 0;\n }\n }\n if (y > Env.HEIGHT) {\n x = Env.WIDTH/2;\n y = Env.HEIGHT/3;\n vx = 0;\n vy = 0;\n }\n Player newPlayer = new Player(x, y, angle, vx, vy, radius);\n return new World(env, newPlayer);\n }\n"} {"input": " public Map<String, Component> readComponents(File directory)\n {\n if (!directory.isDirectory())\n {\n throw new IllegalArgumentException(\n directory.getAbsolutePath() + \" is no Directory\");\n }\n Map<String, Component> result = new HashMap<>();\n File[] files = directory.listFiles();\n for (File file : files)\n {\n String fileName = file.getName();\n if (fileName.endsWith(\".xhtml\"))\n {\n try\n {\n FileInputStream inputStream = new FileInputStream(file);\n Component component = parse(inputStream);\n if (component.getId() == null)\n {\n component.setId(fileName.substring(0, fileName.length() - 6));\n }\n result.put(component.getId(), component);\n }\n catch (FileNotFoundException e)\n {\n throw new RuntimeException(e);\n } \n catch (SAXException e)\n {\n throw new RuntimeException(e);\n }\n catch (IOException e)\n {\n throw new RuntimeException(e);\n } \n catch (ParserConfigurationException e)\n {\n throw new RuntimeException(e);\n }\n }\n }\n return result;\n } \n", "output": " public Map<String, Component> readComponents(File sourceDirectory)\n {\n if (sourceDirectory == null)\n {\n throw new NullPointerException(\"sourceDirectory must not be null\");\n }\n if (!sourceDirectory.isDirectory())\n {\n throw new IllegalArgumentException(\n sourceDirectory.getAbsolutePath() + \" is no Directory\");\n }\n Map<String, Component> result = new HashMap<>();\n File[] files = sourceDirectory.listFiles();\n for (File file : files)\n {\n String fileName = file.getName();\n if (fileName.endsWith(\".xhtml\"))\n {\n try\n {\n FileInputStream inputStream = new FileInputStream(file);\n Component component = parse(inputStream);\n if (component.getId() == null)\n {\n component.setId(fileName.substring(0, fileName.length() - 6));\n }\n result.put(component.getId(), component);\n }\n catch (FileNotFoundException e)\n {\n throw new RuntimeException(e);\n } \n catch (SAXException e)\n {\n throw new RuntimeException(e);\n }\n catch (IOException e)\n {\n throw new RuntimeException(e);\n } \n catch (ParserConfigurationException e)\n {\n throw new RuntimeException(e);\n }\n }\n }\n return result;\n } \n"} {"input": "\tpublic BufferedImage draw(double[] data, int imageWidth, int imageHeight, int maxPlottedData, int minPlottedData) {\n\t\tBufferedImage bi = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);\n\t\tGraphics2D g = (Graphics2D) bi.getGraphics();\n\t\tg.setColor(Color.white);\n\t\tg.drawRect(0, 0, imageWidth, imageHeight);\n\t\tg.setColor(Color.black);\n\t\tfor (int i=1;i<data.length;i++) {\n\t\t\tint x1 = (int) Math.rint((i-1) * imageWidth / data.length);\n\t\t\tint x2 = (int) Math.rint(i * imageWidth / data.length);\n\t\t\tint y1 = (int) Math.rint((data[i-1] -minPlottedData) / maxPlottedData * imageHeight );\n\t\t\tint y2 = (int) Math.rint((data[i] -minPlottedData) / maxPlottedData * imageHeight );\n\t\t\tg.drawLine(x1, y1, x2, y2);\n\t\t}\n\t\treturn bi;\n\t}\n", "output": "\tpublic BufferedImage draw(double[] data, int imageWidth, int imageHeight, double maxPlottedData, double minPlottedData) {\n\t\tBufferedImage bi = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);\n\t\tGraphics2D g = (Graphics2D) bi.getGraphics();\n\t\tg.setColor(Color.white);\n\t\tg.drawRect(0, 0, imageWidth, imageHeight);\n\t\tg.setColor(Color.black);\n\t\tfor (int i=1;i<data.length;i++) {\n\t\t\tint x1 = (int) Math.rint((i-1) * imageWidth / data.length);\n\t\t\tint x2 = (int) Math.rint(i * imageWidth / data.length);\n\t\t\tint y1 = (int) Math.rint((data[i-1] -minPlottedData) / maxPlottedData * imageHeight );\n\t\t\tint y2 = (int) Math.rint((data[i] -minPlottedData) / maxPlottedData * imageHeight );\n\t\t\tg.drawLine(x1, y1, x2, y2);\n\t\t}\n\t\treturn bi;\n\t}\n"} {"input": "\tpublic void run() {\n\t\teEvent\t\t\t\t= Edk.INSTANCE.EE_EmoEngineEventCreate();\n \teState\t\t\t\t= Edk.INSTANCE.EE_EmoStateCreate();\n \tIntByReference userID \t\t= null;\n\t\tIntByReference nSamplesTaken= null;\n \tint state \t\t\t\t\t= 0;\n \tfloat secs \t\t\t\t\t= 60;\n \tboolean readytocollect \t\t= false;\n \tcollecting = true;\n \twritingMatrix = false;\n \tuserID \t\t\t= new IntByReference(0);\n\t\tnSamplesTaken\t= new IntByReference(0);\n\t\ttry {\n\t\t\tout = new BufferedWriter(new FileWriter(\"VisualizationData/\" + fileName + \".txt\"));\n\t\t} catch (IOException e) {\n\t\t\tSystem.err.println(e.getMessage());\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\tif (Edk.INSTANCE.EE_EngineConnect(\"Emotiv Systems-5\") != EdkErrorCode.EDK_OK.ToInt()) {\n\t\t\tSystem.err.println(\"Emotiv Engine start up failed.\");\n\t\t\treturn;\n\t\t}\n\t\tPointer hData = Edk.INSTANCE.EE_DataCreate();\n\t\tEdk.INSTANCE.EE_DataSetBufferSizeInSec(secs); \n \tSystem.out.println(\"Started receiving EEG Data!\");\n\t\twhile (collecting) {\t\n\t\t\tstate = Edk.INSTANCE.EE_EngineGetNextEvent(eEvent);\n\t\t\tif (state == EdkErrorCode.EDK_OK.ToInt()) {\n\t\t\t\tint eventType = Edk.INSTANCE.EE_EmoEngineEventGetType(eEvent);\n\t\t\t\tEdk.INSTANCE.EE_EmoEngineEventGetUserId(eEvent, userID);\n\t\t\t\tif (eventType == Edk.EE_Event_t.EE_UserAdded.ToInt()) {\n\t\t\t\t\t\tif (userID != null) {\n\t\t\t\t\t\t\tSystem.out.println(\"User added\");\n\t\t\t\t\t\t\tEdk.INSTANCE.EE_DataAcquisitionEnable(userID.getValue(),true);\n\t\t\t\t\t\t\treadytocollect = true;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (eventType == Edk.EE_Event_t.EE_EmoStateUpdated.ToInt()) {\n\t\t\t\t\tEdk.INSTANCE.EE_EmoEngineEventGetEmoState(eEvent, eState);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (state != EdkErrorCode.EDK_NO_EVENT.ToInt()) {\n\t\t\t\tSystem.err.println(\"Internal error in Emotiv Engine!\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (readytocollect) {\n\t\t\t\tEdk.INSTANCE.EE_DataUpdateHandle(0, hData);\n\t\t\t\tEdk.INSTANCE.EE_DataGetNumberOfSample(hData, nSamplesTaken);\n\t\t\t\tif (nSamplesTaken != null) {\n\t\t\t\t\tif (nSamplesTaken.getValue() != 0) {\n\t\t\t\t\t\tdouble[] data = new double[nSamplesTaken.getValue()];\n\t\t\t\t\t\tfor (int sampleIdx=0 ; sampleIdx < nSamplesTaken.getValue(); ++sampleIdx) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tEdk.INSTANCE.EE_DataGet(hData, 19, data, nSamplesTaken.getValue());\n\t\t\t\t\t\t\t\tout.write(Integer.toString((int) (data[sampleIdx] * 1000)) + \" \");\n\t\t\t\t\t\t\t\tfor (int i = 0 ; i < 25 ; i++) {\n\t\t\t\t\t\t\t\t\tEdk.INSTANCE.EE_DataGet(hData, i, data, nSamplesTaken.getValue());\n\t\t\t\t\t\t\t\t\tif ( writingMatrix && i >= 3 && i <= 16) {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tmatrix.matrix[sample][i-3] = data[sampleIdx];\n\t\t\t\t\t\t\t\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\t\t\t\t\t\t\t\twritingMatrix = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tout.write( Double.toString((data[sampleIdx])));\n\t\t\t\t\t\t\t\t\tout.write(\" \");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif(writingMatrix)\n\t\t\t\t\t\t\t\t\tsample++;\n\t\t\t\t\t\t\t\tout.write(\"0\");\n\t\t\t\t\t\t\t\tfor (int i = 1; i < 15 ; i++)\n\t\t\t\t\t\t\t\t\tout.write(\" \" + EmoState.INSTANCE.ES_GetContactQuality(eState, i) + \" \");\n\t\t\t\t\t\t\t\tout.newLine();\n\t\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\t\tSystem.err.println(e.getMessage());\n\t\t\t\t\t\t\t\tSystem.exit(-1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} \n\t\t} \n\t\tcleanUp();\n\t}\n", "output": "\tpublic void run() {\n\t\teEvent\t\t\t\t= Edk.INSTANCE.EE_EmoEngineEventCreate();\n \teState\t\t\t\t= Edk.INSTANCE.EE_EmoStateCreate();\n \tIntByReference userID \t\t= null;\n\t\tIntByReference nSamplesTaken= null;\n \tint state \t\t\t\t\t= 0;\n \tfloat secs \t\t\t\t\t= 60;\n \tboolean readytocollect \t\t= false;\n \tcollecting = true;\n \twritingMatrix = false;\n \tuserID \t\t\t= new IntByReference(0);\n\t\tnSamplesTaken\t= new IntByReference(0);\n\t\ttry {\n\t\t\tout = new BufferedWriter(new FileWriter(\"VisualizationData/\" + fileName + \".txt\"));\n\t\t} catch (IOException e) {\n\t\t\tSystem.err.println(e.getMessage());\n\t\t\tSystem.exit(-1);\n\t\t}\n\t\tif (Edk.INSTANCE.EE_EngineConnect(\"Emotiv Systems-5\") != EdkErrorCode.EDK_OK.ToInt()) {\n\t\t\tSystem.err.println(\"Emotiv Engine start up failed.\");\n\t\t\treturn;\n\t\t}\n\t\tPointer hData = Edk.INSTANCE.EE_DataCreate();\n\t\tEdk.INSTANCE.EE_DataSetBufferSizeInSec(secs); \n \tSystem.out.println(\"Started receiving EEG Data!\");\n\t\twhile (collecting) {\t\n\t\t\tstate = Edk.INSTANCE.EE_EngineGetNextEvent(eEvent);\n\t\t\tif (state == EdkErrorCode.EDK_OK.ToInt()) {\n\t\t\t\tint eventType = Edk.INSTANCE.EE_EmoEngineEventGetType(eEvent);\n\t\t\t\tEdk.INSTANCE.EE_EmoEngineEventGetUserId(eEvent, userID);\n\t\t\t\tif (eventType == Edk.EE_Event_t.EE_UserAdded.ToInt()) {\n\t\t\t\t\t\tif (userID != null) {\n\t\t\t\t\t\t\tSystem.out.println(\"User added\");\n\t\t\t\t\t\t\tEdk.INSTANCE.EE_DataAcquisitionEnable(userID.getValue(),true);\n\t\t\t\t\t\t\treadytocollect = true;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (eventType == Edk.EE_Event_t.EE_EmoStateUpdated.ToInt()) {\n\t\t\t\t\tEdk.INSTANCE.EE_EmoEngineEventGetEmoState(eEvent, eState);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (state != EdkErrorCode.EDK_NO_EVENT.ToInt()) {\n\t\t\t\tSystem.err.println(\"Internal error in Emotiv Engine!\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (readytocollect) {\n\t\t\t\tEdk.INSTANCE.EE_DataUpdateHandle(0, hData);\n\t\t\t\tEdk.INSTANCE.EE_DataGetNumberOfSample(hData, nSamplesTaken);\n\t\t\t\tif (nSamplesTaken != null) {\n\t\t\t\t\tif (nSamplesTaken.getValue() != 0) {\n\t\t\t\t\t\tdouble[] data = new double[nSamplesTaken.getValue()];\n\t\t\t\t\t\tfor (int sampleIdx=0 ; sampleIdx < nSamplesTaken.getValue(); ++sampleIdx) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tEdk.INSTANCE.EE_DataGet(hData, 19, data, nSamplesTaken.getValue());\n\t\t\t\t\t\t\t\tout.write(Integer.toString((int) (data[sampleIdx] * 1000)) + \" \");\n\t\t\t\t\t\t\t\tfor (int i = 0 ; i < 25 ; i++) {\n\t\t\t\t\t\t\t\t\tEdk.INSTANCE.EE_DataGet(hData, i, data, nSamplesTaken.getValue());\n\t\t\t\t\t\t\t\t\tif ( writingMatrix && i >= 3 && i <= 16) {\n\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\tmatrix.matrix[sample][i-3] = data[sampleIdx];\n\t\t\t\t\t\t\t\t\t\t} catch (ArrayIndexOutOfBoundsException e) {\n\t\t\t\t\t\t\t\t\t\t\twritingMatrix = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tout.write( Double.toString((data[sampleIdx])));\n\t\t\t\t\t\t\t\t\tout.write(\" \");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif(writingMatrix)\n\t\t\t\t\t\t\t\t\tsample++;\n\t\t\t\t\t\t\t\tout.write((writingMatrix)? \"1\" : \"0\");\n\t\t\t\t\t\t\t\tfor (int i = 1; i < 15 ; i++)\n\t\t\t\t\t\t\t\t\tout.write(\" \" + EmoState.INSTANCE.ES_GetContactQuality(eState, i) + \" \");\n\t\t\t\t\t\t\t\tout.newLine();\n\t\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\t\tSystem.err.println(e.getMessage());\n\t\t\t\t\t\t\t\tSystem.exit(-1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} \n\t\t} \n\t\tcleanUp();\n\t}\n"} {"input": " private void traverseSchema(Element root) throws Exception {\n if (root == null) {\n return;\n }\n for (Element child = XUtil.getFirstChildElement(root);\n child != null;\n child = XUtil.getNextSiblingElement(child)) {\n String name = child.getNodeName();\n\t\t\tif (name.equals(ELT_COMMENT)) {\n\t\t\t\ttraverseComment(child);\n } else if (name.equals(ELT_DATATYPEDECL)) {\n\t\t\t\ttraverseDatatypeDecl(child);\n } else if (name.equals(ELT_ARCHETYPEDECL)) {\n\t\t\t\ttraverseTypeDecl(child);\n\t\t\t} else if (name.equals(ELT_ELEMENTDECL)) { \n\t\t\t\ttraverseElementDecl(child);\n\t\t\t} else if (name.equals(ELT_ATTRGROUPDECL)) {\n\t\t\t\ttraverseAttrGroup(child);\n\t\t\t} else if (name.equals(ELT_MODELGROUPDECL)) {\n\t\t\t\ttraverseModelGroup(child);\n\t\t\t}\n else if (name.equals(ELT_TEXTENTITYDECL) ||\n name.equals(ELT_EXTERNALENTITYDECL) ||\n name.equals(ELT_UNPARSEDENTITYDECL)) {\n int entityName = fStringPool.addSymbol(child.getAttribute(ATT_NAME));\n if (name.equals(ELT_TEXTENTITYDECL)) {\n int value = fStringPool.addString(child.getFirstChild().getNodeValue());\n fEntityPool.addEntityDecl(entityName, value, -1, -1, -1, -1, true);\n }\n else {\n int publicId = fStringPool.addString(child.getAttribute(\"public\"));\n int systemId = fStringPool.addString(child.getAttribute(\"system\"));\n if (name.equals(ELT_EXTERNALENTITYDECL)) {\n fEntityPool.addEntityDecl(entityName, -1, -1, publicId, systemId, -1, true);\n }\n else {\n int notationName = fStringPool.addSymbol(child.getAttribute(\"notation\"));\n fEntityPool.addEntityDecl(entityName, -1, -1, publicId, systemId, notationName, true);\n }\n }\n }\n else if (name.equals(ELT_NOTATIONDECL)) {\n int notationName = fStringPool.addSymbol(child.getAttribute(ATT_NAME));\n int publicId = fStringPool.addString(child.getAttribute(\"public\"));\n int systemId = fStringPool.addString(child.getAttribute(\"system\"));\n fEntityPool.addNotationDecl(notationName, publicId, systemId, true);\n }\n } \n cleanupForwardReferences();\n } \n private void cleanupForwardReferences() {\n for (java.util.Enumeration keys = fForwardRefs.keys(); keys.hasMoreElements();) {\n Object k = keys.nextElement();\n int ik = ((Integer) k).intValue();\n cleanupForwardReferencesTo(ik);\n }\n }\n private void cleanupForwardReferencesTo(int r) {\n Vector referrers = (Vector) fForwardRefs.get(new Integer(r));\n if (referrers == null) return;\n for (int i = 0; i < referrers.size(); i++) {\n int ref = ((Integer) referrers.elementAt(i)).intValue();\n fElementDeclPool.copyAtts(r, ((Integer) referrers.elementAt(i)).intValue());\n }\n }\n\tprivate void traverseComment(Element comment) {\n return; \n\t}\n\tprivate int traverseTypeDecl(Element typeDecl) throws Exception {\n\t\tString typeName = typeDecl.getAttribute(ATT_NAME);\n\t\tString content = typeDecl.getAttribute(ATT_CONTENT);\n\t\tString model = typeDecl.getAttribute(ATT_MODEL);\n\t\tString order = typeDecl.getAttribute(ATT_ORDER);\n\t\tString type = typeDecl.getAttribute(ATT_TYPE);\n\t\tString deflt = typeDecl.getAttribute(ATT_DEFAULT);\n\t\tString fixed = typeDecl.getAttribute(ATT_FIXED);\n\t\tString schemaAbbrev = typeDecl.getAttribute(ATT_SCHEMAABBREV);\n\t\tString schemaName = typeDecl.getAttribute(ATT_SCHEMANAME);\n\t\tif (typeName.equals(\"\")) { \n\t\t typeName = \"http://www.apache.org/xml/xerces/internalType\"+fTypeCount++;\n\t\t}\n\t\tif (type.equals(\"\")) {\n\t\t if (!schemaAbbrev.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"schemaAbbrev\" });\n\t\t if (!schemaName.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"schemaName\" });\n\t\t if (!deflt.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"default\" });\n\t\t if (!fixed.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"fixed\" });\n\t\t} else {\n if (fDatatypeRegistry.getValidatorFor(type) != null) \n\t\t\t\treportSchemaError(SchemaMessageProvider.NotADatatype,\n\t\t\t\t\t\t\t\t new Object [] { type }); \n if (!content.equals(ATTVAL_TEXTONLY)) \n\t\t\t\treportSchemaError(SchemaMessageProvider.TextOnlyContentWithType, null);\n\t\t}\n\t\tElement child = XUtil.getFirstChildElement(typeDecl);\n\t\tElement refines = null;\n\t\tif (child != null && child.getNodeName().equals(ELT_REFINES)) {\n\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t new Object [] { \"Refinement\" });\n\t\t\trefines = child;\n\t\t\tchild = XUtil.getNextSiblingElement(child);\n\t\t}\n\t\tint contentSpecType = 0;\n\t\tint csnType = 0;\n boolean mixedContent = false;\n boolean elementContent = false;\n boolean textContent = false;\n boolean buildAll = false;\n int allChildren[] = null;\n int allChildCount = 0;\n\t\tint left = -2;\n\t\tint right = -2;\n\t\tboolean hadContent = false;\n if (order.equals(ATTVAL_CHOICE)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_SEQ)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_SEQ;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_ALL)) {\n buildAll = true;\n allChildren = new int[((org.apache.xerces.dom.NodeImpl)typeDecl).getLength()];\n allChildCount = 0;\n\t\t}\n\t\tif (content.equals(ATTVAL_EMPTY)) {\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"EMPTY\");\n\t\t\tleft = -1; \n\t\t} else if (content.equals(ATTVAL_ANY)) {\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"ANY\");\n\t\t\tleft = -1; \n\t\t} else if (content.equals(ATTVAL_MIXED)) {\n\t\t contentSpecType = fStringPool.addSymbol(\"MIXED\");\n\t\t mixedContent = true;\n\t\t csnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t} else if (content.equals(ATTVAL_ELEMONLY)) {\n elementContent = true;\n\t\t} else if (content.equals(ATTVAL_TEXTONLY)) {\n textContent = true;\n }\n if (mixedContent) {\n left = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t \t\t\t\t\t\t\t -1, \n\t\t\t\t\t\t\t\t\t\t\t\t\t -1, false);\n }\n Vector uses = new Vector();\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tint index = -2;\n hadContent = true;\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ELEMENTDECL)) {\n\t\t\t if (child.getAttribute(ATT_REF).equals(\"\")) { \n\t\t\t if (elementContent) \n\t\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t\t new Object [] { \"Nesting element declarations\" });\n \t\t\telse\n\t\t\t\t\t\treportSchemaError(SchemaMessageProvider.NestedOnlyInElemOnly, null);\n \t\t\t} else if (mixedContent || elementContent) { \n \t\t\t index = traverseElementRef(child);\n \t\t\t} else {\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.EltRefOnlyInMixedElemOnly, null);\n \t\t\t}\n\t\t\t} else if (childName.equals(ELT_GROUP)) {\n\t\t\t if (elementContent && !buildAll) {\n \t\t\t int groupNameIndex = traverseGroup(child);\n\t \t\t\tindex = getContentSpec(getElement(groupNameIndex));\n\t\t\t\t} else if (!elementContent)\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OnlyInEltContent,\n\t\t\t\t\t\t\t\t\t new Object [] { \"group\" });\n\t\t\t else \n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"group\" } );\n\t\t\t} else if (childName.equals(ELT_MODELGROUPREF)) {\n\t\t\t if (elementContent && !buildAll) {\n \t\t\t\tint modelGroupNameIndex = traverseModelGroup(child);\n\t \t\t\tindex = getContentSpec(getElement(modelGroupNameIndex));\n\t\t \t\tif (index == -1)\n\t\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t\t new Object [] { \"Forward reference to model group\" });\n\t\t\t\t index = expandContentModel(index, child);\n\t\t\t\t} else if (!elementContent)\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OnlyInEltContent,\n\t\t\t\t\t\t\t\t\t new Object [] { \"modelGroupRef\" });\n\t\t\t\telse \n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"modelGroupRef\" });\n\t\t\t} else if (childName.equals(ELT_ATTRIBUTEDECL) || childName.equals(ELT_ATTRGROUPREF)) {\n\t\t\t break; \n\t\t\t} else { \n\t\t\t if (type.equals(\"\"))\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.DatatypeWithType, null);\n\t\t\t else\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.DatatypeQualUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { childName });\n\t\t\t}\n uses.addElement(new Integer(index));\n\t\t\tif (buildAll) {\n\t\t\t allChildren[allChildCount++] = index;\n\t\t\t} else if (left == -2) {\n\t\t\t\tleft = index;\n\t\t\t} else if (right == -2) {\n\t\t\t\tright = index;\n\t\t\t} else {\n \t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\t\tright = index;\n \t\t\t}\n\t\t}\n\t\tif (buildAll) {\n\t\t left = buildAllModel(allChildren,allChildCount);\n\t\t} else {\n\t\t if (hadContent && right != -2)\n \t\t left = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\tif (mixedContent && hadContent) {\n\t\t \tleft = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE,\n\t\t\t\t\t\t\t\t\t\t\t\t\t left, -1, false);\n\t \t}\n\t\t}\n\t\tint typeNameIndex = fStringPool.addSymbol(typeName); \n\t\tint typeIndex = fElementDeclPool.addElementDecl(typeNameIndex, contentSpecType, left, false);\n for (int x = 0; x < uses.size(); x++)\n addUse(typeNameIndex, (Integer)uses.elementAt(x));\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ATTRIBUTEDECL)) {\n\t\t\t\ttraverseAttributeDecl(child, typeIndex);\n\t\t\t} else if (childName.equals(ELT_ATTRGROUPREF)) {\n \t\t\tint index = traverseAttrGroupRef(child);\n \t\t\tif (getContentSpec(getElement(index)) == -1) {\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { \"Forward References to attrGroup\" });\n \t\t\t Vector v = null;\n \t\t\t Integer i = new Integer(index);\n \t\t\t if ((v = (Vector) fForwardRefs.get(i)) == null)\n \t\t\t v = new Vector();\n v.addElement(new Integer(typeNameIndex));\n \t\t\t fForwardRefs.put(i,v);\n addUse(typeNameIndex, index);\n \t\t\t} else\n \t\t\tfElementDeclPool.copyAtts(index, typeNameIndex);\n\t\t\t}\n\t\t}\n return typeNameIndex;\n\t}\n\tprivate int traverseGroup(Element groupDecl) throws Exception {\n\t\tString groupName = groupDecl.getAttribute(ATT_NAME);\n\t\tString collection = groupDecl.getAttribute(ATT_COLLECTION);\n\t\tString order = groupDecl.getAttribute(ATT_ORDER);\n\t\tif (groupName.equals(\"\")) { \n\t\t groupName = \"http://www.apache.org/xml/xerces/internalGroup\"+fGroupCount++;\n\t\t}\n\t\tElement child = XUtil.getFirstChildElement(groupDecl);\n\t\tint contentSpecType = 0;\n\t\tint csnType = 0;\n boolean buildAll = false;\n int allChildren[] = null;\n int allChildCount = 0;\n\t\tif (order.equals(ATTVAL_CHOICE)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_SEQ)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_SEQ;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_ALL)) {\n buildAll = true;\n allChildren = new int[((org.apache.xerces.dom.NodeImpl)groupDecl).getLength()];\n allChildCount = 0;\n\t\t}\n\t\tint left = -2;\n\t\tint right = -2;\n\t\tboolean hadContent = false;\n\t\tint groupIndices[] = new int [((org.apache.xerces.dom.NodeImpl)groupDecl).getLength()];\n\t\tint numGroups = 0;\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tint index = -2;\n hadContent = true;\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ELEMENTDECL)) {\n\t\t\t if (child.getAttribute(ATT_REF).equals(\"\"))\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { \"Nesting element declarations\" });\n\t\t\t else\n \t\t\t index = traverseElementRef(child);\n\t\t\t} else if (childName.equals(ELT_GROUP)) {\n\t\t\t if (!buildAll) {\n \t\t\t int groupNameIndex = traverseGroup(child);\n\t \t\t\tgroupIndices[numGroups++] = groupNameIndex;\n\t\t \t\tindex = getContentSpec(getElement(groupNameIndex));\n\t\t \t} else\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"group\" } );\n\t\t\t} else if (childName.equals(ELT_MODELGROUPREF)) {\n\t\t\t if (!buildAll) {\n int modelGroupNameIndex = traverseModelGroupRef(child);\n index = getContentSpec(getElement(modelGroupNameIndex));\n index = expandContentModel(index, child);\n } else\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"modelGroupRef\" });\n\t\t\t} else {\n\t\t\t\treportSchemaError(SchemaMessageProvider.GroupContentRestricted,\n\t\t\t\t\t\t\t\t new Object [] { \"group\", childName });\n\t\t\t}\n\t\t\tif (buildAll) {\n\t\t\t allChildren[allChildCount++] = index;\n\t\t\t} else if (left == -2) {\n\t\t\t\tleft = index;\n\t\t\t} else if (right == -2) {\n\t\t\t\tright = index;\n\t\t\t} else {\n \t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\t\tright = index;\n \t\t\t}\n\t\t}\n\t\tif (buildAll) {\n\t\t left = buildAllModel(allChildren,allChildCount);\n\t\t} else {\n\t\t\tif (hadContent && right != -2)\n\t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n\t\t}\n\t\tleft = expandContentModel(left, groupDecl);\n\t\tint groupNameIndex = fStringPool.addSymbol(groupName); \n\t\tint groupIndex = fElementDeclPool.addElementDecl(groupNameIndex, contentSpecType, left, false);\n return groupNameIndex;\n\t}\n\tprivate int traverseModelGroup(Element modelGroupDecl) throws Exception {\n\t\tString modelGroupName = modelGroupDecl.getAttribute(ATT_NAME);\n\t\tString order = modelGroupDecl.getAttribute(ATT_ORDER);\n\t\tif (modelGroupName.equals(\"\")) { \n\t\t modelGroupName = \"http://www.apache.org/xml/xerces/internalModelGroup\"+fModelGroupCount++;\n\t\t}\n\t\tElement child = XUtil.getFirstChildElement(modelGroupDecl);\n\t\tint contentSpecType = 0;\n\t\tint csnType = 0;\n boolean buildAll = false;\n int allChildren[] = null;\n int allChildCount = 0;\n\t\tif (order.equals(ATTVAL_CHOICE)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_SEQ)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_SEQ;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_ALL)) {\n\t\t\tbuildAll = true;\n allChildren = new int[((org.apache.xerces.dom.NodeImpl)modelGroupDecl).getLength()];\n allChildCount = 0;\n\t\t}\n\t\tint left = -2;\n\t\tint right = -2;\n\t\tboolean hadContent = false;\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tint index = -2;\n hadContent = true;\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ELEMENTDECL)) {\n\t\t\t if (child.getAttribute(ATT_REF).equals(\"\"))\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { \"Nesting element declarations\" });\n\t\t\t else {\n \t\t\t index = traverseElementRef(child);\n }\n\t\t\t} else if (childName.equals(ELT_GROUP)) {\n\t\t\t int groupNameIndex = traverseGroup(child);\n\t\t\t\tindex = getContentSpec(getElement(groupNameIndex));\n\t\t\t} else if (childName.equals(ELT_MODELGROUPREF)) {\n int modelGroupNameIndex = traverseModelGroupRef(child);\n index = getContentSpec(getElement(modelGroupNameIndex));\n index = expandContentModel(index, child);\n\t\t\t} else {\n\t\t\t\treportSchemaError(SchemaMessageProvider.GroupContentRestricted,\n\t\t\t\t\t\t\t\t new Object [] { \"modelGroup\", childName });\n\t\t\t}\n\t\t\tif (buildAll) {\n\t\t\t allChildren[allChildCount++] = index;\n\t\t\t} else if (left == -2) {\n\t\t\t\tleft = index;\n\t\t\t} else if (right == -2) {\n\t\t\t\tright = index;\n\t\t\t} else {\n \t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\t\tright = index;\n \t\t\t}\n\t\t}\n\t\tif (buildAll) {\n\t\t left = buildAllModel(allChildren,allChildCount);\n\t\t} else {\n\t\t\tif (hadContent && right != -2)\n\t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n\t\t}\n\t\tleft = expandContentModel(left, modelGroupDecl);\n\t\tint modelGroupNameIndex = fStringPool.addSymbol(modelGroupName); \n\t\tint modelGroupIndex = fElementDeclPool.addElementDecl(modelGroupNameIndex, contentSpecType, left, false);\n return modelGroupNameIndex;\n\t}\n\tprivate int traverseModelGroupRef(Element modelGroupRef) {\n\t String name = modelGroupRef.getAttribute(ATT_NAME);\n\t int index = fStringPool.addSymbol(name);\n return index;\n\t}\n\tpublic int traverseDatatypeDecl(Element datatypeDecl) {\n\t\tint newTypeName = fStringPool.addSymbol(datatypeDecl.getAttribute(ATT_NAME));\n\t\tint export = fStringPool.addSymbol(datatypeDecl.getAttribute(ATT_EXPORT));\n\t\tElement datatypeChild = XUtil.getFirstChildElement(datatypeDecl);\n\t\tint basetype = fStringPool.addSymbol(datatypeChild.getNodeName());\n\t\tDatatypeValidator baseValidator = fDatatypeRegistry.getValidatorFor(datatypeChild.getAttribute(ATT_NAME));\n\t\tif (baseValidator == null) {\n\t\t\treportSchemaError(SchemaMessageProvider.UnknownBaseDatatype,\n\t\t\t\t\t\t\t new Object [] { datatypeChild.getAttribute(ATT_NAME), datatypeDecl.getAttribute(ATT_NAME) });\n\t\t\treturn -1;\n\t\t}\n\t\tint numFacets = 0;\n\t\tint numEnumerationLiterals = 0;\n\t\tHashtable facetData = new Hashtable();\n\t\tVector enumData = new Vector();\n\t\tNode facet = datatypeChild.getNextSibling();\n\t\twhile (facet != null) {\n\t\t\tif (facet.getNodeType() == Node.ELEMENT_NODE) {\n\t\t\t\tnumFacets++;\n\t\t\t\tif (facet.getNodeName().equals(DatatypeValidator.ENUMERATION)) {\n\t\t\t\t\tNode literal = XUtil.getFirstChildElement(facet);\n\t\t\t\t\twhile (literal != null) {\n\t\t\t\t\t\tnumEnumerationLiterals++;\n\t\t\t\t\t\tenumData.addElement(literal.getFirstChild().getNodeValue());\n\t\t\t\t\t\tliteral = XUtil.getNextSiblingElement(literal);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfacetData.put(facet.getNodeName(),facet.getFirstChild().getNodeValue());\n\t\t\t\t}\n\t\t\t}\n\t\t\tfacet = facet.getNextSibling();\n\t\t}\n\t\tif (numEnumerationLiterals > 0) {\n\t\t\tfacetData.put(DatatypeValidator.ENUMERATION, enumData);\n\t\t}\n\t\ttry {\n\t\t\tDatatypeValidator newValidator = (DatatypeValidator) baseValidator.getClass().newInstance();\n\t\t\tif (numFacets > 0)\n\t\t\t\tnewValidator.setFacets(facetData);\n\t\t\tfDatatypeRegistry.addValidator(fStringPool.toString(newTypeName),newValidator);\n\t\t} catch (Exception e) {\n\t\t\treportSchemaError(SchemaMessageProvider.DatatypeError,\n\t\t\t\t\t\t\t new Object [] { e.getMessage() });\n\t\t}\n return -1;\n\t}\n\tprivate int traverseElementDecl(Element elementDecl) throws Exception {\n\t\tint contentSpecType = -1;\n\t\tint contentSpecNodeIndex = -1;\n int typeNameIndex = -1;\n\t\tString name = elementDecl.getAttribute(ATT_NAME);\n\t\tString ref = elementDecl.getAttribute(ATT_REF);\n\t\tString archRef = elementDecl.getAttribute(ATT_ARCHREF);\n\t\tString type = elementDecl.getAttribute(ATT_TYPE);\n\t\tString schemaAbbrev = elementDecl.getAttribute(ATT_SCHEMAABBREV);\n\t\tString schemaName = elementDecl.getAttribute(ATT_SCHEMANAME);\n\t\tString minOccurs = elementDecl.getAttribute(ATT_MINOCCURS);\n\t\tString maxOccurs = elementDecl.getAttribute(ATT_MAXOCCURS);\n\t\tString export = elementDecl.getAttribute(ATT_EXPORT);\n int attrCount = 0;\n\t\tif (!ref.equals(\"\")) attrCount++;\n\t\tif (!type.equals(\"\")) attrCount++;\n\t\tif (!archRef.equals(\"\")) attrCount++;\n\t\tif (attrCount > 1)\n\t\t\treportSchemaError(SchemaMessageProvider.OneOfTypeRefArchRef, null);\n\t\tif (!ref.equals(\"\") || !archRef.equals(\"\")) {\n\t\t if (XUtil.getFirstChildElement(elementDecl) != null)\n\t\t\t\treportSchemaError(SchemaMessageProvider.NoContentForRef, null);\n\t\t \tint typeName = (!ref.equals(\"\")) ? fStringPool.addSymbol(ref) : fStringPool.addSymbol(archRef);\n\t\t \tcontentSpecNodeIndex = getContentSpec(getElement(typeName));\n\t\t \tcontentSpecType = getContentSpecType(getElement(typeName));\n\t\t \tint elementNameIndex = fStringPool.addSymbol(name);\n int elementIndex = -1;\n\t\t \tif (contentSpecNodeIndex == -1) {\n\t\t \t contentSpecType = XMLContentSpecNode.CONTENTSPECNODE_LEAF;\n \tcontentSpecNodeIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t \t\t\t\t\t\t\t elementNameIndex, -1, false);\n fElementDeclPool.addElementDecl(elementNameIndex, contentSpecType, contentSpecNodeIndex, true);\n\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t new Object [] { \"Forward references to archetypes\" });\n \t\t\tVector v = null;\n \t\t\tInteger i = new Integer(typeName);\n \t\t\tif ((v = (Vector) fForwardRefs.get(i)) == null)\n \t\t\t v = new Vector();\n v.addElement(new Integer(elementNameIndex));\n \t\t\tfForwardRefs.put(i,v);\n \t\t\taddUse(elementNameIndex, typeName);\n\t\t \t} else {\n fElementDeclPool.addElementDecl(elementNameIndex, contentSpecType, contentSpecNodeIndex, true);\n fElementDeclPool.copyAtts(typeName, elementNameIndex);\n }\n\t\t return elementNameIndex;\n\t\t}\n\t\tElement content = XUtil.getFirstChildElement(elementDecl);\n\t\tif (content != null) {\n\t\t\tString contentName = content.getNodeName();\n\t\t\tif (contentName.equals(ELT_ARCHETYPEDECL)) {\n\t\t\t\ttypeNameIndex = traverseTypeDecl(content);\n\t\t\t\tcontentSpecNodeIndex = getContentSpec(getElement(typeNameIndex));\n\t\t\t\tcontentSpecType = getContentSpecType(getElement(typeNameIndex));\n\t\t\t} else if (contentName.equals(ELT_DATATYPEDECL)) {\n\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t new Object [] { \"Nesting datatype declarations\" });\n\t\t\t} else if (!type.equals(\"\")) { \n\t\t\t\tcontentSpecType = fStringPool.addSymbol(\"DATATYPE\");\n\t\t\t\tcontentSpecNodeIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t fStringPool.addSymbol(content.getAttribute(ATT_NAME)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t -1, false);\n\t\t\t\tcontentSpecNodeIndex = expandContentModel(contentSpecNodeIndex, content);\n\t\t\t} else if (type.equals(\"\")) { \n\t \t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t\t\tint leftIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfStringPool.addSymbol(content.getAttribute(ATT_NAME)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-1, false);\n\t \t\tcontentSpecNodeIndex = expandContentModel(contentSpecNodeIndex, content);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"unhandled case in element decl code\");\n\t\t\t}\n\t\t} else if (!type.equals(\"\")) { \n\t\t\tcontentSpecType = fStringPool.addSymbol(\"DATATYPE\");\n\t\t\tcontentSpecNodeIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t fStringPool.addSymbol(type),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t -1, false);\n\t\t\tcontentSpecNodeIndex = expandContentModel(contentSpecNodeIndex, elementDecl);\n\t\t}\n\t\tint elementNameIndex = fStringPool.addSymbol(elementDecl.getAttribute(ATT_NAME));\n\t\tint elementIndex = fElementDeclPool.addElementDecl(elementNameIndex, contentSpecType, contentSpecNodeIndex, true);\n fElementDeclPool.copyAtts(typeNameIndex, elementNameIndex);\n return elementNameIndex;\n\t}\n", "output": " private void traverseSchema(Element root) throws Exception {\n if (root == null) {\n return;\n }\n for (Element child = XUtil.getFirstChildElement(root);\n child != null;\n child = XUtil.getNextSiblingElement(child)) {\n String name = child.getNodeName();\n\t\t\tif (name.equals(ELT_COMMENT)) {\n\t\t\t\ttraverseComment(child);\n } else if (name.equals(ELT_DATATYPEDECL)) {\n\t\t\t\ttraverseDatatypeDecl(child);\n } else if (name.equals(ELT_ARCHETYPEDECL)) {\n\t\t\t\ttraverseTypeDecl(child);\n\t\t\t} else if (name.equals(ELT_ELEMENTDECL)) { \n\t\t\t\ttraverseElementDecl(child);\n\t\t\t} else if (name.equals(ELT_ATTRGROUPDECL)) {\n\t\t\t\ttraverseAttrGroup(child);\n\t\t\t} else if (name.equals(ELT_MODELGROUPDECL)) {\n\t\t\t\ttraverseModelGroup(child);\n\t\t\t}\n else if (name.equals(ELT_TEXTENTITYDECL) ||\n name.equals(ELT_EXTERNALENTITYDECL) ||\n name.equals(ELT_UNPARSEDENTITYDECL)) {\n int entityName = fStringPool.addSymbol(child.getAttribute(ATT_NAME));\n if (name.equals(ELT_TEXTENTITYDECL)) {\n int value = fStringPool.addString(child.getFirstChild().getFirstChild().getNodeValue());\n fEntityPool.addEntityDecl(entityName, value, -1, -1, -1, -1, true);\n }\n else {\n int publicId = fStringPool.addString(child.getAttribute(\"public\"));\n int systemId = fStringPool.addString(child.getAttribute(\"system\"));\n if (name.equals(ELT_EXTERNALENTITYDECL)) {\n fEntityPool.addEntityDecl(entityName, -1, -1, publicId, systemId, -1, true);\n }\n else {\n int notationName = fStringPool.addSymbol(child.getAttribute(\"notation\"));\n fEntityPool.addEntityDecl(entityName, -1, -1, publicId, systemId, notationName, true);\n }\n }\n }\n else if (name.equals(ELT_NOTATIONDECL)) {\n int notationName = fStringPool.addSymbol(child.getAttribute(ATT_NAME));\n int publicId = fStringPool.addString(child.getAttribute(\"public\"));\n int systemId = fStringPool.addString(child.getAttribute(\"system\"));\n fEntityPool.addNotationDecl(notationName, publicId, systemId, true);\n }\n } \n cleanupForwardReferences();\n } \n private void cleanupForwardReferences() {\n for (java.util.Enumeration keys = fForwardRefs.keys(); keys.hasMoreElements();) {\n Object k = keys.nextElement();\n int ik = ((Integer) k).intValue();\n cleanupForwardReferencesTo(ik);\n }\n }\n private void cleanupForwardReferencesTo(int r) {\n Vector referrers = (Vector) fForwardRefs.get(new Integer(r));\n if (referrers == null) return;\n for (int i = 0; i < referrers.size(); i++) {\n int ref = ((Integer) referrers.elementAt(i)).intValue();\n fElementDeclPool.copyAtts(r, ((Integer) referrers.elementAt(i)).intValue());\n }\n }\n\tprivate void traverseComment(Element comment) {\n return; \n\t}\n\tprivate int traverseTypeDecl(Element typeDecl) throws Exception {\n\t\tString typeName = typeDecl.getAttribute(ATT_NAME);\n\t\tString content = typeDecl.getAttribute(ATT_CONTENT);\n\t\tString model = typeDecl.getAttribute(ATT_MODEL);\n\t\tString order = typeDecl.getAttribute(ATT_ORDER);\n\t\tString type = typeDecl.getAttribute(ATT_TYPE);\n\t\tString deflt = typeDecl.getAttribute(ATT_DEFAULT);\n\t\tString fixed = typeDecl.getAttribute(ATT_FIXED);\n\t\tString schemaAbbrev = typeDecl.getAttribute(ATT_SCHEMAABBREV);\n\t\tString schemaName = typeDecl.getAttribute(ATT_SCHEMANAME);\n\t\tif (typeName.equals(\"\")) { \n\t\t typeName = \"http://www.apache.org/xml/xerces/internalType\"+fTypeCount++;\n\t\t}\n\t\tif (type.equals(\"\")) {\n\t\t if (!schemaAbbrev.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"schemaAbbrev\" });\n\t\t if (!schemaName.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"schemaName\" });\n\t\t if (!deflt.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"default\" });\n\t\t if (!fixed.equals(\"\"))\n\t\t\t\treportSchemaError(SchemaMessageProvider.AttMissingType,\n\t\t\t\t\t\t\tnew Object [] { \"fixed\" });\n\t\t} else {\n if (fDatatypeRegistry.getValidatorFor(type) != null) \n\t\t\t\treportSchemaError(SchemaMessageProvider.NotADatatype,\n\t\t\t\t\t\t\t\t new Object [] { type }); \n if (!content.equals(ATTVAL_TEXTONLY)) \n\t\t\t\treportSchemaError(SchemaMessageProvider.TextOnlyContentWithType, null);\n\t\t}\n\t\tElement child = XUtil.getFirstChildElement(typeDecl);\n\t\tElement refines = null;\n\t\tif (child != null && child.getNodeName().equals(ELT_REFINES)) {\n\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t new Object [] { \"Refinement\" });\n\t\t\trefines = child;\n\t\t\tchild = XUtil.getNextSiblingElement(child);\n\t\t}\n\t\tint contentSpecType = 0;\n\t\tint csnType = 0;\n boolean mixedContent = false;\n boolean elementContent = false;\n boolean textContent = false;\n boolean buildAll = false;\n int allChildren[] = null;\n int allChildCount = 0;\n\t\tint left = -2;\n\t\tint right = -2;\n\t\tboolean hadContent = false;\n if (order.equals(ATTVAL_CHOICE)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_SEQ)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_SEQ;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_ALL)) {\n buildAll = true;\n allChildren = new int[((org.apache.xerces.dom.NodeImpl)typeDecl).getLength()];\n allChildCount = 0;\n\t\t}\n\t\tif (content.equals(ATTVAL_EMPTY)) {\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"EMPTY\");\n\t\t\tleft = -1; \n\t\t} else if (content.equals(ATTVAL_ANY)) {\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"ANY\");\n\t\t\tleft = -1; \n\t\t} else if (content.equals(ATTVAL_MIXED)) {\n\t\t contentSpecType = fStringPool.addSymbol(\"MIXED\");\n\t\t mixedContent = true;\n\t\t csnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t} else if (content.equals(ATTVAL_ELEMONLY)) {\n elementContent = true;\n\t\t} else if (content.equals(ATTVAL_TEXTONLY)) {\n textContent = true;\n }\n if (mixedContent) {\n left = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t \t\t\t\t\t\t\t -1, \n\t\t\t\t\t\t\t\t\t\t\t\t\t -1, false);\n }\n Vector uses = new Vector();\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tint index = -2;\n hadContent = true;\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ELEMENTDECL)) {\n\t\t\t if (child.getAttribute(ATT_REF).equals(\"\")) { \n\t\t\t if (elementContent) \n\t\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t\t new Object [] { \"Nesting element declarations\" });\n \t\t\telse\n\t\t\t\t\t\treportSchemaError(SchemaMessageProvider.NestedOnlyInElemOnly, null);\n \t\t\t} else if (mixedContent || elementContent) { \n \t\t\t index = traverseElementRef(child);\n \t\t\t} else {\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.EltRefOnlyInMixedElemOnly, null);\n \t\t\t}\n\t\t\t} else if (childName.equals(ELT_GROUP)) {\n\t\t\t if (elementContent && !buildAll) {\n \t\t\t int groupNameIndex = traverseGroup(child);\n\t \t\t\tindex = getContentSpec(getElement(groupNameIndex));\n\t\t\t\t} else if (!elementContent)\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OnlyInEltContent,\n\t\t\t\t\t\t\t\t\t new Object [] { \"group\" });\n\t\t\t else \n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"group\" } );\n\t\t\t} else if (childName.equals(ELT_MODELGROUPREF)) {\n\t\t\t if (elementContent && !buildAll) {\n \t\t\t\tint modelGroupNameIndex = traverseModelGroup(child);\n\t \t\t\tindex = getContentSpec(getElement(modelGroupNameIndex));\n\t\t \t\tif (index == -1)\n\t\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t\t new Object [] { \"Forward reference to model group\" });\n\t\t\t\t index = expandContentModel(index, child);\n\t\t\t\t} else if (!elementContent)\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OnlyInEltContent,\n\t\t\t\t\t\t\t\t\t new Object [] { \"modelGroupRef\" });\n\t\t\t\telse \n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"modelGroupRef\" });\n\t\t\t} else if (childName.equals(ELT_ATTRIBUTEDECL) || childName.equals(ELT_ATTRGROUPREF)) {\n\t\t\t break; \n\t\t\t} else { \n\t\t\t if (type.equals(\"\"))\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.DatatypeWithType, null);\n\t\t\t else\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.DatatypeQualUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { childName });\n\t\t\t}\n uses.addElement(new Integer(index));\n\t\t\tif (buildAll) {\n\t\t\t allChildren[allChildCount++] = index;\n\t\t\t} else if (left == -2) {\n\t\t\t\tleft = index;\n\t\t\t} else if (right == -2) {\n\t\t\t\tright = index;\n\t\t\t} else {\n \t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\t\tright = index;\n \t\t\t}\n\t\t}\n\t\tif (buildAll) {\n\t\t left = buildAllModel(allChildren,allChildCount);\n\t\t} else {\n\t\t if (hadContent && right != -2)\n \t\t left = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\tif (mixedContent && hadContent) {\n\t\t \tleft = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_ZERO_OR_MORE,\n\t\t\t\t\t\t\t\t\t\t\t\t\t left, -1, false);\n\t \t}\n\t\t}\n\t\tint typeNameIndex = fStringPool.addSymbol(typeName); \n\t\tint typeIndex = fElementDeclPool.addElementDecl(typeNameIndex, contentSpecType, left, false);\n for (int x = 0; x < uses.size(); x++)\n addUse(typeNameIndex, (Integer)uses.elementAt(x));\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ATTRIBUTEDECL)) {\n\t\t\t\ttraverseAttributeDecl(child, typeIndex);\n\t\t\t} else if (childName.equals(ELT_ATTRGROUPREF)) {\n \t\t\tint index = traverseAttrGroupRef(child);\n \t\t\tif (getContentSpec(getElement(index)) == -1) {\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { \"Forward References to attrGroup\" });\n \t\t\t Vector v = null;\n \t\t\t Integer i = new Integer(index);\n \t\t\t if ((v = (Vector) fForwardRefs.get(i)) == null)\n \t\t\t v = new Vector();\n v.addElement(new Integer(typeNameIndex));\n \t\t\t fForwardRefs.put(i,v);\n addUse(typeNameIndex, index);\n \t\t\t} else\n \t\t\tfElementDeclPool.copyAtts(index, typeNameIndex);\n\t\t\t}\n\t\t}\n return typeNameIndex;\n\t}\n\tprivate int traverseGroup(Element groupDecl) throws Exception {\n\t\tString groupName = groupDecl.getAttribute(ATT_NAME);\n\t\tString collection = groupDecl.getAttribute(ATT_COLLECTION);\n\t\tString order = groupDecl.getAttribute(ATT_ORDER);\n\t\tif (groupName.equals(\"\")) { \n\t\t groupName = \"http://www.apache.org/xml/xerces/internalGroup\"+fGroupCount++;\n\t\t}\n\t\tElement child = XUtil.getFirstChildElement(groupDecl);\n\t\tint contentSpecType = 0;\n\t\tint csnType = 0;\n boolean buildAll = false;\n int allChildren[] = null;\n int allChildCount = 0;\n\t\tif (order.equals(ATTVAL_CHOICE)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_SEQ)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_SEQ;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_ALL)) {\n buildAll = true;\n allChildren = new int[((org.apache.xerces.dom.NodeImpl)groupDecl).getLength()];\n allChildCount = 0;\n\t\t}\n\t\tint left = -2;\n\t\tint right = -2;\n\t\tboolean hadContent = false;\n\t\tint groupIndices[] = new int [((org.apache.xerces.dom.NodeImpl)groupDecl).getLength()];\n\t\tint numGroups = 0;\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tint index = -2;\n hadContent = true;\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ELEMENTDECL)) {\n\t\t\t if (child.getAttribute(ATT_REF).equals(\"\"))\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { \"Nesting element declarations\" });\n\t\t\t else\n \t\t\t index = traverseElementRef(child);\n\t\t\t} else if (childName.equals(ELT_GROUP)) {\n\t\t\t if (!buildAll) {\n \t\t\t int groupNameIndex = traverseGroup(child);\n\t \t\t\tgroupIndices[numGroups++] = groupNameIndex;\n\t\t \t\tindex = getContentSpec(getElement(groupNameIndex));\n\t\t \t} else\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"group\" } );\n\t\t\t} else if (childName.equals(ELT_MODELGROUPREF)) {\n\t\t\t if (!buildAll) {\n int modelGroupNameIndex = traverseModelGroupRef(child);\n index = getContentSpec(getElement(modelGroupNameIndex));\n index = expandContentModel(index, child);\n } else\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.OrderIsAll,\n\t\t\t\t\t\t\t\t\t new Object [] { \"modelGroupRef\" });\n\t\t\t} else {\n\t\t\t\treportSchemaError(SchemaMessageProvider.GroupContentRestricted,\n\t\t\t\t\t\t\t\t new Object [] { \"group\", childName });\n\t\t\t}\n\t\t\tif (buildAll) {\n\t\t\t allChildren[allChildCount++] = index;\n\t\t\t} else if (left == -2) {\n\t\t\t\tleft = index;\n\t\t\t} else if (right == -2) {\n\t\t\t\tright = index;\n\t\t\t} else {\n \t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\t\tright = index;\n \t\t\t}\n\t\t}\n\t\tif (buildAll) {\n\t\t left = buildAllModel(allChildren,allChildCount);\n\t\t} else {\n\t\t\tif (hadContent && right != -2)\n\t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n\t\t}\n\t\tleft = expandContentModel(left, groupDecl);\n\t\tint groupNameIndex = fStringPool.addSymbol(groupName); \n\t\tint groupIndex = fElementDeclPool.addElementDecl(groupNameIndex, contentSpecType, left, false);\n return groupNameIndex;\n\t}\n\tprivate int traverseModelGroup(Element modelGroupDecl) throws Exception {\n\t\tString modelGroupName = modelGroupDecl.getAttribute(ATT_NAME);\n\t\tString order = modelGroupDecl.getAttribute(ATT_ORDER);\n\t\tif (modelGroupName.equals(\"\")) { \n\t\t modelGroupName = \"http://www.apache.org/xml/xerces/internalModelGroup\"+fModelGroupCount++;\n\t\t}\n\t\tElement child = XUtil.getFirstChildElement(modelGroupDecl);\n\t\tint contentSpecType = 0;\n\t\tint csnType = 0;\n boolean buildAll = false;\n int allChildren[] = null;\n int allChildCount = 0;\n\t\tif (order.equals(ATTVAL_CHOICE)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_CHOICE;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_SEQ)) {\n\t\t\tcsnType = XMLContentSpecNode.CONTENTSPECNODE_SEQ;\n\t\t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t} else if (order.equals(ATTVAL_ALL)) {\n\t\t\tbuildAll = true;\n allChildren = new int[((org.apache.xerces.dom.NodeImpl)modelGroupDecl).getLength()];\n allChildCount = 0;\n\t\t}\n\t\tint left = -2;\n\t\tint right = -2;\n\t\tboolean hadContent = false;\n\t\tfor (;\n\t\t\t child != null;\n\t\t\t child = XUtil.getNextSiblingElement(child)) {\n\t\t\tint index = -2;\n hadContent = true;\n\t\t\tString childName = child.getNodeName();\n\t\t\tif (childName.equals(ELT_ELEMENTDECL)) {\n\t\t\t if (child.getAttribute(ATT_REF).equals(\"\"))\n\t\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t\t new Object [] { \"Nesting element declarations\" });\n\t\t\t else {\n \t\t\t index = traverseElementRef(child);\n }\n\t\t\t} else if (childName.equals(ELT_GROUP)) {\n\t\t\t int groupNameIndex = traverseGroup(child);\n\t\t\t\tindex = getContentSpec(getElement(groupNameIndex));\n\t\t\t} else if (childName.equals(ELT_MODELGROUPREF)) {\n int modelGroupNameIndex = traverseModelGroupRef(child);\n index = getContentSpec(getElement(modelGroupNameIndex));\n index = expandContentModel(index, child);\n\t\t\t} else {\n\t\t\t\treportSchemaError(SchemaMessageProvider.GroupContentRestricted,\n\t\t\t\t\t\t\t\t new Object [] { \"modelGroup\", childName });\n\t\t\t}\n\t\t\tif (buildAll) {\n\t\t\t allChildren[allChildCount++] = index;\n\t\t\t} else if (left == -2) {\n\t\t\t\tleft = index;\n\t\t\t} else if (right == -2) {\n\t\t\t\tright = index;\n\t\t\t} else {\n \t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n \t\t\tright = index;\n \t\t\t}\n\t\t}\n\t\tif (buildAll) {\n\t\t left = buildAllModel(allChildren,allChildCount);\n\t\t} else {\n\t\t\tif (hadContent && right != -2)\n\t\t\t\tleft = fElementDeclPool.addContentSpecNode(csnType, left, right, false);\n\t\t}\n\t\tleft = expandContentModel(left, modelGroupDecl);\n\t\tint modelGroupNameIndex = fStringPool.addSymbol(modelGroupName); \n\t\tint modelGroupIndex = fElementDeclPool.addElementDecl(modelGroupNameIndex, contentSpecType, left, false);\n return modelGroupNameIndex;\n\t}\n\tprivate int traverseModelGroupRef(Element modelGroupRef) {\n\t String name = modelGroupRef.getAttribute(ATT_NAME);\n\t int index = fStringPool.addSymbol(name);\n return index;\n\t}\n\tpublic int traverseDatatypeDecl(Element datatypeDecl) {\n\t\tint newTypeName = fStringPool.addSymbol(datatypeDecl.getAttribute(ATT_NAME));\n\t\tint export = fStringPool.addSymbol(datatypeDecl.getAttribute(ATT_EXPORT));\n\t\tElement datatypeChild = XUtil.getFirstChildElement(datatypeDecl);\n\t\tint basetype = fStringPool.addSymbol(datatypeChild.getNodeName());\n\t\tDatatypeValidator baseValidator = fDatatypeRegistry.getValidatorFor(datatypeChild.getAttribute(ATT_NAME));\n\t\tif (baseValidator == null) {\n\t\t\treportSchemaError(SchemaMessageProvider.UnknownBaseDatatype,\n\t\t\t\t\t\t\t new Object [] { datatypeChild.getAttribute(ATT_NAME), datatypeDecl.getAttribute(ATT_NAME) });\n\t\t\treturn -1;\n\t\t}\n\t\tint numFacets = 0;\n\t\tint numEnumerationLiterals = 0;\n\t\tHashtable facetData = new Hashtable();\n\t\tVector enumData = new Vector();\n\t\tNode facet = datatypeChild.getNextSibling();\n\t\twhile (facet != null) {\n\t\t\tif (facet.getNodeType() == Node.ELEMENT_NODE) {\n\t\t\t\tnumFacets++;\n\t\t\t\tif (facet.getNodeName().equals(DatatypeValidator.ENUMERATION)) {\n\t\t\t\t\tNode literal = XUtil.getFirstChildElement(facet);\n\t\t\t\t\twhile (literal != null) {\n\t\t\t\t\t\tnumEnumerationLiterals++;\n\t\t\t\t\t\tenumData.addElement(literal.getFirstChild().getNodeValue());\n\t\t\t\t\t\tliteral = XUtil.getNextSiblingElement(literal);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfacetData.put(facet.getNodeName(),facet.getFirstChild().getNodeValue());\n\t\t\t\t}\n\t\t\t}\n\t\t\tfacet = facet.getNextSibling();\n\t\t}\n\t\tif (numEnumerationLiterals > 0) {\n\t\t\tfacetData.put(DatatypeValidator.ENUMERATION, enumData);\n\t\t}\n\t\ttry {\n\t\t\tDatatypeValidator newValidator = (DatatypeValidator) baseValidator.getClass().newInstance();\n\t\t\tif (numFacets > 0)\n\t\t\t\tnewValidator.setFacets(facetData);\n\t\t\tfDatatypeRegistry.addValidator(fStringPool.toString(newTypeName),newValidator);\n\t\t} catch (Exception e) {\n\t\t\treportSchemaError(SchemaMessageProvider.DatatypeError,\n\t\t\t\t\t\t\t new Object [] { e.getMessage() });\n\t\t}\n return -1;\n\t}\n\tprivate int traverseElementDecl(Element elementDecl) throws Exception {\n\t\tint contentSpecType = -1;\n\t\tint contentSpecNodeIndex = -1;\n int typeNameIndex = -1;\n\t\tString name = elementDecl.getAttribute(ATT_NAME);\n\t\tString ref = elementDecl.getAttribute(ATT_REF);\n\t\tString archRef = elementDecl.getAttribute(ATT_ARCHREF);\n\t\tString type = elementDecl.getAttribute(ATT_TYPE);\n\t\tString schemaAbbrev = elementDecl.getAttribute(ATT_SCHEMAABBREV);\n\t\tString schemaName = elementDecl.getAttribute(ATT_SCHEMANAME);\n\t\tString minOccurs = elementDecl.getAttribute(ATT_MINOCCURS);\n\t\tString maxOccurs = elementDecl.getAttribute(ATT_MAXOCCURS);\n\t\tString export = elementDecl.getAttribute(ATT_EXPORT);\n int attrCount = 0;\n\t\tif (!ref.equals(\"\")) attrCount++;\n\t\tif (!type.equals(\"\")) attrCount++;\n\t\tif (!archRef.equals(\"\")) attrCount++;\n\t\tif (attrCount > 1)\n\t\t\treportSchemaError(SchemaMessageProvider.OneOfTypeRefArchRef, null);\n\t\tif (!ref.equals(\"\") || !archRef.equals(\"\")) {\n\t\t if (XUtil.getFirstChildElement(elementDecl) != null)\n\t\t\t\treportSchemaError(SchemaMessageProvider.NoContentForRef, null);\n\t\t \tint typeName = (!ref.equals(\"\")) ? fStringPool.addSymbol(ref) : fStringPool.addSymbol(archRef);\n\t\t \tcontentSpecNodeIndex = getContentSpec(getElement(typeName));\n\t\t \tcontentSpecType = getContentSpecType(getElement(typeName));\n\t\t \tint elementNameIndex = fStringPool.addSymbol(name);\n int elementIndex = -1;\n\t\t \tif (contentSpecNodeIndex == -1) {\n\t\t \t contentSpecType = XMLContentSpecNode.CONTENTSPECNODE_LEAF;\n \tcontentSpecNodeIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t \t\t\t\t\t\t\t elementNameIndex, -1, false);\n fElementDeclPool.addElementDecl(elementNameIndex, contentSpecType, contentSpecNodeIndex, true);\n\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t new Object [] { \"Forward references to archetypes\" });\n \t\t\tVector v = null;\n \t\t\tInteger i = new Integer(typeName);\n \t\t\tif ((v = (Vector) fForwardRefs.get(i)) == null)\n \t\t\t v = new Vector();\n v.addElement(new Integer(elementNameIndex));\n \t\t\tfForwardRefs.put(i,v);\n \t\t\taddUse(elementNameIndex, typeName);\n\t\t \t} else {\n fElementDeclPool.addElementDecl(elementNameIndex, contentSpecType, contentSpecNodeIndex, true);\n fElementDeclPool.copyAtts(typeName, elementNameIndex);\n }\n\t\t return elementNameIndex;\n\t\t}\n\t\tElement content = XUtil.getFirstChildElement(elementDecl);\n\t\tif (content != null) {\n\t\t\tString contentName = content.getNodeName();\n\t\t\tif (contentName.equals(ELT_ARCHETYPEDECL)) {\n\t\t\t\ttypeNameIndex = traverseTypeDecl(content);\n\t\t\t\tcontentSpecNodeIndex = getContentSpec(getElement(typeNameIndex));\n\t\t\t\tcontentSpecType = getContentSpecType(getElement(typeNameIndex));\n\t\t\t} else if (contentName.equals(ELT_DATATYPEDECL)) {\n\t\t\t\treportSchemaError(SchemaMessageProvider.FeatureUnsupported,\n\t\t\t\t\t\t\t\t new Object [] { \"Nesting datatype declarations\" });\n\t\t\t} else if (!type.equals(\"\")) { \n\t\t\t\tcontentSpecType = fStringPool.addSymbol(\"DATATYPE\");\n\t\t\t\tcontentSpecNodeIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t fStringPool.addSymbol(content.getAttribute(ATT_NAME)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t -1, false);\n\t\t\t\tcontentSpecNodeIndex = expandContentModel(contentSpecNodeIndex, content);\n\t\t\t} else if (type.equals(\"\")) { \n\t \t\tcontentSpecType = fStringPool.addSymbol(\"CHILDREN\");\n\t\t\t\tint leftIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfStringPool.addSymbol(content.getAttribute(ATT_NAME)),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t-1, false);\n\t \t\tcontentSpecNodeIndex = expandContentModel(contentSpecNodeIndex, content);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(\"unhandled case in element decl code\");\n\t\t\t}\n\t\t} else if (!type.equals(\"\")) { \n\t\t\tcontentSpecType = fStringPool.addSymbol(\"DATATYPE\");\n\t\t\tcontentSpecNodeIndex = fElementDeclPool.addContentSpecNode(XMLContentSpecNode.CONTENTSPECNODE_LEAF,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t fStringPool.addSymbol(type),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t -1, false);\n\t\t\tcontentSpecNodeIndex = expandContentModel(contentSpecNodeIndex, elementDecl);\n\t\t}\n\t\tint elementNameIndex = fStringPool.addSymbol(elementDecl.getAttribute(ATT_NAME));\n\t\tint elementIndex = fElementDeclPool.addElementDecl(elementNameIndex, contentSpecType, contentSpecNodeIndex, true);\n fElementDeclPool.copyAtts(typeNameIndex, elementNameIndex);\n return elementNameIndex;\n\t}\n"} {"input": " public void open(int iOne, int jOne) {\n checkInput(iOne, jOne);\n int i = iOne - 1;\n int j = jOne - 1;\n int index = getIndex(i, j);\n if (!grid[index]) {\n grid[index] = true;\n int n; \n boolean hasN = false;\n for (int d = 0; d < 4; d++) {\n n = getNeighborIndex(i, j, d);\n if (-1 != n && isOpen(n)) {\n uf.union(index, n);\n hasN = true;\n }\n }\n if (0 == i) {\n uf.union(index, topIndex);\n }\n if (hasN) {\n for (int b = gridSize-1; b >= gridSize-rowLen; b--) {\n if (isOpen(b) && uf.connected(topIndex, b)) {\n uf.union(b, bottomIndex);\n break;\n }\n }\n }\n }\n }\n", "output": " public void open(int iOne, int jOne) {\n checkInput(iOne, jOne);\n int i = iOne - 1;\n int j = jOne - 1;\n int index = getIndex(i, j);\n if (!grid[index]) {\n grid[index] = true;\n int n; \n boolean hasN = false;\n for (int d = 0; d < 4; d++) {\n n = getNeighborIndex(i, j, d);\n if (-1 != n && isOpen(n)) {\n uf.union(index, n);\n hasN = true;\n }\n }\n if (0 == i) {\n uf.union(index, topIndex);\n }\n if (hasN) {\n for (int b = gridSize-1; b >= gridSize-rowLen; b--) {\n if (isOpen(b) && uf.connected(topIndex, b)) {\n uf.union(b, bottomIndex);\n break;\n }\n }\n } else if (1 == gridSize) {\n uf.union(index, bottomIndex);\n }\n }\n }\n"} {"input": "\tprotected final Object next () {\n\t\ttry {\n\t\t\tint total = 0;\n\t\t\twhile (total < chunk.length) {\n\t\t\t\tint count = input.read(chunk, total, chunk.length - total);\n\t\t\t\tif (count < 0) {\n\t\t\t\t\tif (total == 0) return null;\n\t\t\t\t\tbyte[] partial = new byte[total];\n\t\t\t\t\tSystem.arraycopy(chunk, 0, partial, 0, total);\n\t\t\t\t\treturn partial;\n\t\t\t\t}\n\t\t\t\ttotal += count;\n\t\t\t}\n\t\t} catch (IOException ex) {\n\t\t\tthrow new KryoNetException(ex);\n\t\t}\n\t\treturn next(chunk);\n\t}\n", "output": "\tprotected final Object next () {\n\t\ttry {\n\t\t\tint total = 0;\n\t\t\twhile (total < chunk.length) {\n\t\t\t\tint count = input.read(chunk, total, chunk.length - total);\n\t\t\t\tif (count < 0) {\n\t\t\t\t\tif (total == 0) return null;\n\t\t\t\t\tbyte[] partial = new byte[total];\n\t\t\t\t\tSystem.arraycopy(chunk, 0, partial, 0, total);\n\t\t\t\t\treturn next(partial);\n\t\t\t\t}\n\t\t\t\ttotal += count;\n\t\t\t}\n\t\t} catch (IOException ex) {\n\t\t\tthrow new KryoNetException(ex);\n\t\t}\n\t\treturn next(chunk);\n\t}\n"} {"input": "\t\tpublic void evaluate() throws Throwable {\n\t\t\ttry {\n\t\t\t\tfNext.evaluate();\n\t\t\t} catch (Throwable e) {\n\t\t\t\tif (fMatcher == null)\n\t\t\t\t\tthrow e;\n\t\t\t\tAssert.assertThat(e, fMatcher);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (fMatcher != null)\n\t\t\t\tthrow new AssertionError(\"Expected test to throw \"\n\t\t\t\t\t\t+ StringDescription.toString(fMatcher));\n\t\t}\n", "output": "\t\tpublic void evaluate() throws Throwable {\n\t\t\ttry {\n\t\t\t\tfNext.evaluate();\n\t\t\t} catch (Throwable e) {\n\t\t\t\tif (fMatcher == null)\n\t\t\t\t\tthrow e;\n\t\t\t\ttry {\n\t\t\t\t\tAssert.assertThat(e, fMatcher);\n\t\t\t\t} catch (AssertionError ae) {\n\t\t\t\t\tae.initCause(e);\n\t\t\t\t\tthrow ae;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (fMatcher != null)\n\t\t\t\tthrow new AssertionError(\"Expected test to throw \"\n\t\t\t\t\t\t+ StringDescription.toString(fMatcher));\n\t\t}\n"} {"input": " public static List<Tache> yamlToMap(String configurationFile) throws FileNotFoundException {\n Yaml yaml = new Yaml();\n List objects = (List) yaml.load(new FileInputStream(new File(configurationFile)));\n if(null == objects) return newArrayList();\n verifyInstances(objects);\n return (List<Tache>) objects;\n }\n", "output": " public static List<Tache> yamlToMap(String configurationFile) throws FileNotFoundException {\n Yaml yaml = new Yaml(new CustomClassLoaderConstructor(Configuration.class.getClassLoader()));\n List objects = (List) yaml.load(new FileInputStream(new File(configurationFile)));\n if(null == objects) return newArrayList();\n verifyInstances(objects);\n return (List<Tache>) objects;\n }\n"} {"input": "\tpublic boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {\n\t\tMap<AbstractProject, ReactorSubProjectConfig> projects = getSubJobs();\n\t\tList<Future<Build>> futuresList = new ArrayList<Future<Build>>();\n\t\tfor (AbstractProject project : projects.keySet()) {\n\t\t\tlistener.getLogger().printf(\"Starting build job %s.\\n\", HyperlinkNote.encodeTo('/' + project.getUrl(), project.getFullName()));\n\t\t\tReactorSubProjectConfig projectConfig = projects.get(project);\n\t\t\tList<Action> actions = new ArrayList<Action>();\n\t\t\tprepareActions(build, project, projectConfig, listener, actions);\n\t\t\tFuture future = project.scheduleBuild2(project.getQuietPeriod(), new UpstreamCause((Run) build), actions.toArray(new Action[0]));\n\t\t\tif (future != null) {\n\t\t\t\tfuturesList.add(future);\n\t\t\t}\n\t\t}\n\t\tboolean failed = false;\n\t\tfor (Future future : futuresList) {\n\t\t\tif (failed) {\n\t\t\t\tfuture.cancel(true);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tBuild jobBuild = (Build) future.get();\n\t\t\t\tResult result = jobBuild.getResult();\n\t\t\t\tlistener.getLogger().printf(\"Job '%s' finished: %s.\\n\",\n\t\t\t\t\t\tHyperlinkNote.encodeTo('/' + jobBuild.getProject().getUrl(), jobBuild.getProject().getFullName()), result);\n\t\t\t\tif (!continuationCondition.isContinue(jobBuild)) {\n\t\t\t\t\tfailed = true;\n\t\t\t\t}\n\t\t\t} catch (ExecutionException e) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\t\t}\n\t\treturn !failed;\n\t}\n", "output": "\tpublic boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {\n\t\tMap<AbstractProject, ReactorSubProjectConfig> projects = getSubJobs();\n\t\tList<Future<Build>> futuresList = new ArrayList<Future<Build>>();\n\t\tfor (AbstractProject project : projects.keySet()) {\n\t\t\tlistener.getLogger().printf(\"Starting build job %s.\\n\", HyperlinkNote.encodeTo('/' + project.getUrl(), project.getFullName()));\n\t\t\tReactorSubProjectConfig projectConfig = projects.get(project);\n\t\t\tList<Action> actions = new ArrayList<Action>();\n\t\t\tprepareActions(build, project, projectConfig, listener, actions);\n\t\t\tFuture future = project.scheduleBuild2(project.getQuietPeriod(), new UpstreamCause((Run) build), actions.toArray(new Action[0]));\n\t\t\tif (future != null) {\n\t\t\t\tfuturesList.add(future);\n\t\t\t}\n\t\t}\n\t\tboolean failed = false;\n\t\tfor (Future future : futuresList) {\n\t\t\tif (failed) {\n\t\t\t\tfuture.cancel(true);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tBuild jobBuild = (Build) future.get();\n\t\t\t\tResult result = jobBuild.getResult();\n\t\t\t\tlistener.getLogger().printf(\"Build \"+ HyperlinkNote.encodeTo(\"/\" + jobBuild.getUrl()+\"/\", String.valueOf(jobBuild.getNumber())),\"Console :\"+\n\t\t\t\t\t\tHyperlinkNote.encodeTo('/' + jobBuild.getUrl()+\"/console\", result.toString()));\n\t\t\t\tif (!continuationCondition.isContinue(jobBuild)) {\n\t\t\t\t\tfailed = true;\n\t\t\t\t}\n\t\t\t} catch (ExecutionException e) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\t\t}\n\t\treturn !failed;\n\t}\n"} {"input": " public void handle( LdapSession session, AbandonRequest request ) throws Exception\n {\n int abandonedId = request.getAbandoned();\n if ( abandonedId < 0 )\n {\n return;\n }\n session.abandonOutstandingRequest( request.getMessageId() );\n }\n", "output": " public void handle( LdapSession session, AbandonRequest request ) throws Exception\n {\n int abandonedId = request.getAbandoned();\n if ( abandonedId < 0 )\n {\n return;\n }\n session.abandonOutstandingRequest( request.getAbandoned() );\n }\n"} {"input": " public static Sheet createSheet(List recs, int sheetnum, int offset)\n {\n log.logFormatted(log.DEBUG,\n \"Sheet createSheet (existing file) with %\",\n new Integer(recs.size()));\n Sheet retval = new Sheet();\n ArrayList records = new ArrayList(recs.size() / 5);\n boolean isfirstcell = true;\n boolean isfirstrow = true;\n int bofEofNestingLevel = 0;\n for (int k = offset; k < recs.size(); k++)\n {\n Record rec = ( Record ) recs.get(k);\n if (rec.getSid() == LabelRecord.sid)\n {\n log.log(log.DEBUG, \"Hit label record.\");\n retval.containsLabels = true;\n }\n else if (rec.getSid() == BOFRecord.sid)\n {\n bofEofNestingLevel++;\n log.log(log.DEBUG, \"Hit BOF record. Nesting increased to \" + bofEofNestingLevel);\n }\n else if (rec.getSid() == EOFRecord.sid)\n {\n --bofEofNestingLevel;\n log.log(log.DEBUG, \"Hit EOF record. Nesting decreased to \" + bofEofNestingLevel);\n if (bofEofNestingLevel == 0) {\n records.add(rec);\n retval.eofLoc = k;\n break;\n }\n }\n else if (rec.getSid() == DimensionsRecord.sid)\n {\n retval.dims = ( DimensionsRecord ) rec;\n retval.dimsloc = records.size();\n }\n else if (rec.getSid() == MergeCellsRecord.sid)\n {\n retval.mergedRecords.add(rec);\n retval.merged = ( MergeCellsRecord ) rec;\n retval.mergedLocs.add(new Integer(k - offset));\n retval.numMergedRegions += retval.merged.getNumAreas();\n }\n else if (rec.getSid() == ColumnInfoRecord.sid)\n {\n if (retval.columnSizes == null)\n {\n retval.columnSizes = new ArrayList();\n }\n retval.columnSizes.add(rec);\n }\n else if (rec.getSid() == DefaultColWidthRecord.sid)\n {\n retval.defaultcolwidth = ( DefaultColWidthRecord ) rec;\n }\n else if (rec.getSid() == DefaultRowHeightRecord.sid)\n {\n retval.defaultrowheight = ( DefaultRowHeightRecord ) rec;\n }\n else if ( rec.isValue() && bofEofNestingLevel == 1 )\n {\n if ( isfirstcell )\n {\n retval.cells = new ValueRecordsAggregate();\n rec = retval.cells;\n retval.cells.construct( k, recs );\n isfirstcell = false;\n }\n else\n {\n rec = null;\n }\n }\n else if ( rec.getSid() == StringRecord.sid )\n {\n rec = null;\n }\n else if ( rec.getSid() == RowRecord.sid )\n {\n \t RowRecord row = (RowRecord)rec;\n \t if (!isfirstrow) rec = null; \n if ( isfirstrow )\n {\n retval.rows = new RowRecordsAggregate();\n rec = retval.rows; \n isfirstrow = false;\n }\n retval.rows.insertRow(row);\n }\n else if ( rec.getSid() == PrintGridlinesRecord.sid )\n {\n retval.printGridlines = (PrintGridlinesRecord) rec;\n }\n else if ( rec.getSid() == HeaderRecord.sid )\n {\n retval.header = (HeaderRecord) rec;\n }\n else if ( rec.getSid() == FooterRecord.sid )\n {\n retval.footer = (FooterRecord) rec;\n }\n else if ( rec.getSid() == PrintSetupRecord.sid )\n {\n retval.printSetup = (PrintSetupRecord) rec;\n }\n else if ( rec.getSid() == SelectionRecord.sid )\n {\n retval.selection = (SelectionRecord) rec;\n }\n if (rec != null)\n {\n records.add(rec);\n }\n }\n retval.records = records;\n if (retval.rows == null)\n {\n retval.rows = new RowRecordsAggregate();\n }\n if (retval.cells == null)\n {\n retval.cells = new ValueRecordsAggregate();\n }\n log.log(log.DEBUG, \"sheet createSheet (existing file) exited\");\n return retval;\n }\n", "output": " public static Sheet createSheet(List recs, int sheetnum, int offset)\n {\n log.logFormatted(log.DEBUG,\n \"Sheet createSheet (existing file) with %\",\n new Integer(recs.size()));\n Sheet retval = new Sheet();\n ArrayList records = new ArrayList(recs.size() / 5);\n boolean isfirstcell = true;\n boolean isfirstrow = true;\n int bofEofNestingLevel = 0;\n for (int k = offset; k < recs.size(); k++)\n {\n Record rec = ( Record ) recs.get(k);\n if (rec.getSid() == LabelRecord.sid)\n {\n log.log(log.DEBUG, \"Hit label record.\");\n retval.containsLabels = true;\n }\n else if (rec.getSid() == BOFRecord.sid)\n {\n bofEofNestingLevel++;\n log.log(log.DEBUG, \"Hit BOF record. Nesting increased to \" + bofEofNestingLevel);\n }\n else if (rec.getSid() == EOFRecord.sid)\n {\n --bofEofNestingLevel;\n log.log(log.DEBUG, \"Hit EOF record. Nesting decreased to \" + bofEofNestingLevel);\n if (bofEofNestingLevel == 0) {\n records.add(rec);\n retval.eofLoc = k;\n break;\n }\n }\n else if (rec.getSid() == DimensionsRecord.sid)\n {\n retval.dims = ( DimensionsRecord ) rec;\n retval.dimsloc = records.size();\n }\n else if (rec.getSid() == MergeCellsRecord.sid)\n {\n retval.mergedRecords.add(rec);\n retval.merged = ( MergeCellsRecord ) rec;\n retval.mergedLocs.add(new Integer(k - offset));\n retval.numMergedRegions += retval.merged.getNumAreas();\n }\n else if (rec.getSid() == ColumnInfoRecord.sid)\n {\n if (retval.columnSizes == null)\n {\n retval.columnSizes = new ArrayList();\n }\n retval.columnSizes.add(rec);\n }\n else if (rec.getSid() == DefaultColWidthRecord.sid)\n {\n retval.defaultcolwidth = ( DefaultColWidthRecord ) rec;\n }\n else if (rec.getSid() == DefaultRowHeightRecord.sid)\n {\n retval.defaultrowheight = ( DefaultRowHeightRecord ) rec;\n }\n else if ( rec.isValue() && bofEofNestingLevel == 1 )\n {\n if ( isfirstcell )\n {\n retval.cells = new ValueRecordsAggregate();\n rec = retval.cells;\n retval.cells.construct( k, recs );\n isfirstcell = false;\n }\n else\n {\n rec = null;\n }\n }\n else if ( rec.getSid() == StringRecord.sid )\n {\n rec = null;\n }\n else if ( rec.getSid() == RowRecord.sid )\n {\n \t RowRecord row = (RowRecord)rec;\n \t if (!isfirstrow) rec = null; \n if ( isfirstrow )\n {\n retval.rows = new RowRecordsAggregate();\n rec = retval.rows; \n isfirstrow = false;\n }\n retval.rows.insertRow(row);\n }\n else if ( rec.getSid() == PrintGridlinesRecord.sid )\n {\n retval.printGridlines = (PrintGridlinesRecord) rec;\n }\n else if ( rec.getSid() == HeaderRecord.sid && bofEofNestingLevel == 1)\n {\n retval.header = (HeaderRecord) rec;\n }\n else if ( rec.getSid() == FooterRecord.sid && bofEofNestingLevel == 1)\n {\n retval.footer = (FooterRecord) rec;\n }\n else if ( rec.getSid() == PrintSetupRecord.sid && bofEofNestingLevel == 1)\n {\n retval.printSetup = (PrintSetupRecord) rec;\n }\n else if ( rec.getSid() == SelectionRecord.sid )\n {\n retval.selection = (SelectionRecord) rec;\n }\n if (rec != null)\n {\n records.add(rec);\n }\n }\n retval.records = records;\n if (retval.rows == null)\n {\n retval.rows = new RowRecordsAggregate();\n }\n if (retval.cells == null)\n {\n retval.cells = new ValueRecordsAggregate();\n }\n log.log(log.DEBUG, \"sheet createSheet (existing file) exited\");\n return retval;\n }\n"} {"input": "\tpublic void set (INDArray a) {\n\t\tint tdims=this.dimensionality();\n\t\tint adims=a.dimensionality();\n\t\tif (adims<tdims) {\n\t\t\tint sc=getShape()[0];\n\t\t\tfor (int i=0; i<sc; i++) {\n\t\t\t\tINDArray s=slice(i);\n\t\t\t\ts.set(a);\n\t\t\t}\n\t\t} else if (adims==tdims) {\n\t\t\tint sc=sliceCount();\n\t\t\tfor (int i=0; i<sc; i++) {\n\t\t\t\tINDArray s=slice(i);\n\t\t\t\ts.set(a.slice(i));\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new IllegalArgumentException(\"Can't set array to value to higher dimensionality\");\n\t\t}\n\t}\n", "output": "\tpublic void set (INDArray a) {\n\t\tint tdims=this.dimensionality();\n\t\tint adims=a.dimensionality();\n\t\tif (adims<tdims) {\n\t\t\tint sc=getShape()[0];\n\t\t\tfor (int i=0; i<sc; i++) {\n\t\t\t\tINDArray s=slice(i);\n\t\t\t\ts.set(a);\n\t\t\t}\n\t\t} else if (adims==tdims) {\n\t\t\tint sc=sliceCount();\n\t\t\tfor (int i=0; i<sc; i++) {\n\t\t\t\tINDArray s=slice(i);\n\t\t\t\ts.set(a.slice(i));\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new IllegalArgumentException(\"Can't set array to value of higher dimensionality\");\n\t\t}\n\t}\n"} {"input": " public static SlideshowModel createFromPduBody(Context context, PduBody pb) throws MmsException {\n SMILDocument document = SmilHelper.getDocument(pb);\n SMILLayoutElement sle = document.getLayout();\n SMILRootLayoutElement srle = sle.getRootLayout();\n int w = srle.getWidth();\n int h = srle.getHeight();\n if ((w == 0) || (h == 0)) {\n w = LayoutManager.getInstance().getLayoutParameters().getWidth();\n h = LayoutManager.getInstance().getLayoutParameters().getHeight();\n srle.setWidth(w);\n srle.setHeight(h);\n }\n RegionModel rootLayout = new RegionModel(\n null, 0, 0, w, h);\n ArrayList<RegionModel> regions = new ArrayList<RegionModel>();\n NodeList nlRegions = sle.getRegions();\n int regionsNum = nlRegions.getLength();\n for (int i = 0; i < regionsNum; i++) {\n SMILRegionElement sre = (SMILRegionElement) nlRegions.item(i);\n RegionModel r = new RegionModel(sre.getId(), sre.getFit(),\n sre.getLeft(), sre.getTop(), sre.getWidth(), sre.getHeight(),\n sre.getBackgroundColor());\n regions.add(r);\n }\n LayoutModel layouts = new LayoutModel(rootLayout, regions);\n SMILElement docBody = document.getBody();\n NodeList slideNodes = docBody.getChildNodes();\n int slidesNum = slideNodes.getLength();\n ArrayList<SlideModel> slides = new ArrayList<SlideModel>(slidesNum);\n for (int i = 0; i < slidesNum; i++) {\n SMILParElement par = (SMILParElement) slideNodes.item(i);\n NodeList mediaNodes = par.getChildNodes();\n int mediaNum = mediaNodes.getLength();\n ArrayList<MediaModel> mediaSet = new ArrayList<MediaModel>(mediaNum);\n for (int j = 0; j < mediaNum; j++) {\n SMILMediaElement sme = (SMILMediaElement) mediaNodes.item(j);\n try {\n MediaModel media = MediaModelFactory.getMediaModel(\n context, sme, layouts, pb);\n if (!MmsConfig.getSlideDurationEnabled()) {\n int mediadur = media.getDuration();\n float dur = par.getDur();\n if (dur == 0) {\n mediadur = MmsConfig.getMinimumSlideElementDuration() * 1000;\n media.setDuration(mediadur);\n }\n if ((int)mediadur / 1000 != dur) {\n String tag = sme.getTagName();\n if (ContentType.isVideoType(media.mContentType)\n || tag.equals(SmilHelper.ELEMENT_TAG_VIDEO)\n || ContentType.isAudioType(media.mContentType)\n || tag.equals(SmilHelper.ELEMENT_TAG_AUDIO)) {\n par.setDur((float)mediadur / 1000 + 1);\n } else {\n if ((int)mediadur / 1000 < dur) {\n media.setDuration((int)dur * 1000);\n } else {\n if ((int)dur != 0) {\n media.setDuration((int)dur * 1000);\n } else {\n par.setDur((float)mediadur / 1000);\n }\n }\n }\n }\n }\n SmilHelper.addMediaElementEventListeners(\n (EventTarget) sme, media);\n mediaSet.add(media);\n } catch (DrmException e) {\n Log.e(TAG, e.getMessage(), e);\n } catch (IOException e) {\n Log.e(TAG, e.getMessage(), e);\n } catch (IllegalArgumentException e) {\n Log.e(TAG, e.getMessage(), e);\n }\n }\n SlideModel slide = new SlideModel((int) (par.getDur() * 1000), mediaSet);\n slide.setFill(par.getFill());\n SmilHelper.addParElementEventListeners((EventTarget) par, slide);\n slides.add(slide);\n }\n SlideshowModel slideshow = new SlideshowModel(layouts, slides, document, pb, context);\n slideshow.registerModelChangedObserver(slideshow);\n return slideshow;\n }\n", "output": " public static SlideshowModel createFromPduBody(Context context, PduBody pb) throws MmsException {\n SMILDocument document = SmilHelper.getDocument(pb);\n SMILLayoutElement sle = document.getLayout();\n SMILRootLayoutElement srle = sle.getRootLayout();\n int w = srle.getWidth();\n int h = srle.getHeight();\n if ((w == 0) || (h == 0)) {\n w = LayoutManager.getInstance().getLayoutParameters().getWidth();\n h = LayoutManager.getInstance().getLayoutParameters().getHeight();\n srle.setWidth(w);\n srle.setHeight(h);\n }\n RegionModel rootLayout = new RegionModel(\n null, 0, 0, w, h);\n ArrayList<RegionModel> regions = new ArrayList<RegionModel>();\n NodeList nlRegions = sle.getRegions();\n int regionsNum = nlRegions.getLength();\n for (int i = 0; i < regionsNum; i++) {\n SMILRegionElement sre = (SMILRegionElement) nlRegions.item(i);\n RegionModel r = new RegionModel(sre.getId(), sre.getFit(),\n sre.getLeft(), sre.getTop(), sre.getWidth(), sre.getHeight(),\n sre.getBackgroundColor());\n regions.add(r);\n }\n LayoutModel layouts = new LayoutModel(rootLayout, regions);\n SMILElement docBody = document.getBody();\n NodeList slideNodes = docBody.getChildNodes();\n int slidesNum = slideNodes.getLength();\n ArrayList<SlideModel> slides = new ArrayList<SlideModel>(slidesNum);\n int totalSize = 0;\n for (int i = 0; i < slidesNum; i++) {\n SMILParElement par = (SMILParElement) slideNodes.item(i);\n NodeList mediaNodes = par.getChildNodes();\n int mediaNum = mediaNodes.getLength();\n ArrayList<MediaModel> mediaSet = new ArrayList<MediaModel>(mediaNum);\n for (int j = 0; j < mediaNum; j++) {\n SMILMediaElement sme = (SMILMediaElement) mediaNodes.item(j);\n try {\n MediaModel media = MediaModelFactory.getMediaModel(\n context, sme, layouts, pb);\n if (!MmsConfig.getSlideDurationEnabled()) {\n int mediadur = media.getDuration();\n float dur = par.getDur();\n if (dur == 0) {\n mediadur = MmsConfig.getMinimumSlideElementDuration() * 1000;\n media.setDuration(mediadur);\n }\n if ((int)mediadur / 1000 != dur) {\n String tag = sme.getTagName();\n if (ContentType.isVideoType(media.mContentType)\n || tag.equals(SmilHelper.ELEMENT_TAG_VIDEO)\n || ContentType.isAudioType(media.mContentType)\n || tag.equals(SmilHelper.ELEMENT_TAG_AUDIO)) {\n par.setDur((float)mediadur / 1000 + 1);\n } else {\n if ((int)mediadur / 1000 < dur) {\n media.setDuration((int)dur * 1000);\n } else {\n if ((int)dur != 0) {\n media.setDuration((int)dur * 1000);\n } else {\n par.setDur((float)mediadur / 1000);\n }\n }\n }\n }\n }\n SmilHelper.addMediaElementEventListeners(\n (EventTarget) sme, media);\n mediaSet.add(media);\n totalSize += media.getMediaSize();\n } catch (DrmException e) {\n Log.e(TAG, e.getMessage(), e);\n } catch (IOException e) {\n Log.e(TAG, e.getMessage(), e);\n } catch (IllegalArgumentException e) {\n Log.e(TAG, e.getMessage(), e);\n }\n }\n SlideModel slide = new SlideModel((int) (par.getDur() * 1000), mediaSet);\n slide.setFill(par.getFill());\n SmilHelper.addParElementEventListeners((EventTarget) par, slide);\n slides.add(slide);\n }\n SlideshowModel slideshow = new SlideshowModel(layouts, slides, document, pb, context);\n slideshow.setCurrentMessageSize(totalSize);\n slideshow.registerModelChangedObserver(slideshow);\n return slideshow;\n }\n"} {"input": " public void layoutContainer(Container parent) {\n JScrollPane scrollPane = (JScrollPane) parent;\n vsbPolicy = scrollPane.getVerticalScrollBarPolicy();\n hsbPolicy = scrollPane.getHorizontalScrollBarPolicy();\n Rectangle availR = scrollPane.getBounds();\n availR.x = availR.y = 0;\n Insets insets = parent.getInsets();\n availR.x = insets.left;\n availR.y = insets.top;\n availR.width -= insets.left + insets.right;\n availR.height -= insets.top + insets.bottom;\n Rectangle colHeadR = new Rectangle(0, availR.y, 0, 0);\n int upperHeight = getUpperHeight();\n if ((colHead != null) && (colHead.isVisible())) {\n int colHeadHeight = Math.min(availR.height, upperHeight);\n colHeadR.height = colHeadHeight;\n availR.y += colHeadHeight;\n availR.height -= colHeadHeight;\n }\n Rectangle subColHeadR = new Rectangle(0, availR.y, 0, 0);\n if (_subColHead != null && _subColHead.isVisible()) {\n int subColHeadHeight = Math.min(availR.height, _subColHead.getPreferredSize().height);\n subColHeadR.height = subColHeadHeight;\n availR.y += subColHeadHeight;\n availR.height -= subColHeadHeight;\n }\n Rectangle rowHeadR = new Rectangle(0, 0, 0, 0);\n if ((rowHead != null) && (rowHead.isVisible())) {\n int rowHeadWidth = rowHead.getPreferredSize().width;\n if (upperLeft != null && upperLeft.isVisible()) {\n rowHeadWidth = Math.max(rowHeadWidth, upperLeft.getPreferredSize().width);\n }\n if (lowerLeft != null && lowerLeft.isVisible()) {\n rowHeadWidth = Math.max(rowHeadWidth, lowerLeft.getPreferredSize().width);\n }\n rowHeadR.width = rowHeadWidth;\n availR.width -= rowHeadWidth;\n rowHeadR.x = availR.x;\n availR.x += rowHeadWidth;\n }\n Border viewportBorder = scrollPane.getViewportBorder();\n Insets vpbInsets;\n if (viewportBorder != null) {\n vpbInsets = viewportBorder.getBorderInsets(parent);\n availR.x += vpbInsets.left;\n availR.y += vpbInsets.top;\n availR.width -= vpbInsets.left + vpbInsets.right;\n availR.height -= vpbInsets.top + vpbInsets.bottom;\n }\n else {\n vpbInsets = new Insets(0, 0, 0, 0);\n }\n Rectangle rowFootR = new Rectangle(0, 0, 0, 0);\n if ((_rowFoot != null) && (_rowFoot.isVisible())) {\n int rowFootWidth = _rowFoot.getPreferredSize().width;\n if (upperRight != null && upperRight.isVisible()) {\n rowFootWidth = Math.max(rowFootWidth, upperRight.getPreferredSize().width);\n }\n if (lowerRight != null && lowerRight.isVisible()) {\n rowFootWidth = Math.max(rowFootWidth, lowerRight.getPreferredSize().width);\n }\n rowFootR.width = rowFootWidth;\n availR.width -= rowFootWidth;\n rowFootR.x = availR.x + availR.width;\n }\n Rectangle colFootR = new Rectangle(0, availR.y, 0, 0);\n int lowerHeight = getLowerHeight();\n if ((_colFoot != null) && (_colFoot.isVisible())) {\n int colFootHeight = Math.min(availR.height, lowerHeight);\n colFootR.height = colFootHeight;\n availR.height -= colFootHeight;\n colFootR.y = availR.y + availR.height;\n }\n Component view = (viewport != null) ? viewport.getView() : null;\n Dimension viewPrefSize = (view != null) ? view.getPreferredSize() : new Dimension(0, 0);\n Dimension extentSize =\n (viewport != null) ? viewport.toViewCoordinates(availR.getSize())\n : new Dimension(0, 0);\n boolean viewTracksViewportWidth = false;\n boolean viewTracksViewportHeight = false;\n boolean isEmpty = (availR.width < 0 || availR.height < 0);\n Scrollable sv;\n if (!isEmpty && view instanceof Scrollable) {\n sv = (Scrollable) view;\n viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();\n viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();\n }\n else {\n sv = null;\n }\n Rectangle vsbR = new Rectangle(0, isVsbCoversWholeHeight(scrollPane) ? insets.top : availR.y - vpbInsets.top, 0, 0);\n boolean vsbNeeded;\n if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) {\n vsbNeeded = true;\n }\n else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) {\n vsbNeeded = false;\n }\n else if (isEmpty) {\n vsbNeeded = false;\n }\n else { \n vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height || (rowHead != null && rowHead.getView() != null && rowHead.getView().getPreferredSize().height > extentSize.height));\n if (!vsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n vsbNeeded = true;\n }\n }\n if ((vsb != null) && vsbNeeded) {\n adjustForVSB(true, availR, vsbR, vpbInsets, true);\n extentSize = viewport.toViewCoordinates(availR.getSize());\n }\n Rectangle hsbR = new Rectangle(isHsbCoversWholeWidth(scrollPane) ? insets.left : availR.x - vpbInsets.left, 0, 0, 0);\n boolean hsbNeeded;\n if (hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) {\n hsbNeeded = true;\n }\n else if (hsbPolicy == HORIZONTAL_SCROLLBAR_NEVER) {\n hsbNeeded = false;\n }\n else if (isEmpty) {\n hsbNeeded = false;\n }\n else { \n hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width || (colHead != null && colHead.getView() != null && colHead.getView().getPreferredSize().width > extentSize.width));\n if (!hsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_hLeft != null || _hRight != null)) {\n hsbNeeded = true;\n }\n }\n if ((hsb != null) && hsbNeeded) {\n adjustForHSB(true, availR, hsbR, vpbInsets);\n if ((vsb != null) && !vsbNeeded &&\n (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {\n extentSize = viewport.toViewCoordinates(availR.getSize());\n vsbNeeded = viewPrefSize.height > extentSize.height;\n if (!vsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n vsbNeeded = true;\n }\n if (vsbNeeded) {\n adjustForVSB(true, availR, vsbR, vpbInsets, true);\n }\n }\n }\n boolean ltr = scrollPane.getComponentOrientation().isLeftToRight();\n if (viewport != null) {\n viewport.setBounds(adjustBounds(parent, availR, ltr));\n if (sv != null) {\n extentSize = viewport.toViewCoordinates(availR.getSize());\n boolean oldHSBNeeded = hsbNeeded;\n boolean oldVSBNeeded = vsbNeeded;\n viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();\n viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();\n if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) {\n boolean newVSBNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height || (rowHead != null && rowHead.getView() != null && rowHead.getView().getPreferredSize().height > extentSize.height));\n if (!newVSBNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n newVSBNeeded = true;\n }\n if (newVSBNeeded != vsbNeeded) {\n vsbNeeded = newVSBNeeded;\n adjustForVSB(vsbNeeded, availR, vsbR, vpbInsets, true);\n extentSize = viewport.toViewCoordinates\n (availR.getSize());\n }\n }\n if (hsb != null && hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED) {\n boolean newHSBbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width || (colHead != null && colHead.getView() != null && colHead.getView().getPreferredSize().width > extentSize.width));\n if (!newHSBbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_hLeft != null || _hRight != null)) {\n newHSBbNeeded = true;\n }\n if (newHSBbNeeded != hsbNeeded) {\n hsbNeeded = newHSBbNeeded;\n adjustForHSB(hsbNeeded, availR, hsbR, vpbInsets);\n if ((vsb != null) && !vsbNeeded &&\n (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {\n extentSize = viewport.toViewCoordinates\n (availR.getSize());\n vsbNeeded = viewPrefSize.height >\n extentSize.height;\n if (!vsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n vsbNeeded = true;\n }\n if (vsbNeeded) {\n adjustForVSB(true, availR, vsbR, vpbInsets, true);\n }\n }\n if (_rowFoot != null && _rowFoot.isVisible()) {\n vsbR.x += rowFootR.width;\n }\n }\n }\n if (oldHSBNeeded != hsbNeeded ||\n oldVSBNeeded != vsbNeeded) {\n viewport.setBounds(adjustBounds(parent, availR, ltr));\n }\n }\n }\n vsbR.height = isVsbCoversWholeHeight(scrollPane) ? scrollPane.getHeight() - insets.bottom - insets.top : availR.height + vpbInsets.top + vpbInsets.bottom;\n hsbR.width = isHsbCoversWholeWidth(scrollPane) ? scrollPane.getWidth() - vsbR.width - insets.left - insets.right : availR.width + vpbInsets.left + vpbInsets.right;\n rowHeadR.height = availR.height + vpbInsets.top + vpbInsets.bottom;\n rowHeadR.y = availR.y - vpbInsets.top;\n colHeadR.width = availR.width + vpbInsets.left + vpbInsets.right;\n colHeadR.x = availR.x - vpbInsets.left;\n subColHeadR.width = colHeadR.width;\n subColHeadR.x = colHeadR.x;\n colFootR.x = availR.x;\n colFootR.y = rowHeadR.y + rowHeadR.height;\n colFootR.width = availR.width;\n rowFootR.x = availR.x + availR.width;\n rowFootR.y = availR.y;\n rowFootR.height = availR.height;\n vsbR.x += rowFootR.width;\n hsbR.y += colFootR.height;\n if (rowHead != null) {\n rowHead.setBounds(adjustBounds(parent, rowHeadR, ltr));\n }\n if (_rowFoot != null) {\n _rowFoot.setBounds(adjustBounds(parent, rowFootR, ltr));\n }\n int columnHeaderHeight = isColumnHeadersHeightUnified(scrollPane) ? Math.max(colHeadR.height,\n Math.max(upperLeft == null ? 0 : upperLeft.getPreferredSize().height, upperRight == null ? 0 : upperRight.getPreferredSize().height)) : 0;\n int columnFooterHeight = isColumnFootersHeightUnified(scrollPane) ? Math.max(colFootR.height,\n Math.max(lowerLeft == null ? 0 : lowerLeft.getPreferredSize().height, lowerRight == null ? 0 : lowerRight.getPreferredSize().height)) : 0;\n if (colHead != null) {\n int height = isColumnHeadersHeightUnified(scrollPane) ? columnHeaderHeight : Math.min(colHeadR.height, colHead.getPreferredSize().height);\n colHead.setBounds(adjustBounds(parent, new Rectangle(colHeadR.x, colHeadR.y + colHeadR.height - height, colHeadR.width, height), ltr));\n }\n if (_subColHead != null) {\n _subColHead.setBounds(adjustBounds(parent, subColHeadR, ltr));\n }\n if (_colFoot != null) {\n int height = isColumnFootersHeightUnified(scrollPane) ? columnFooterHeight : Math.min(colFootR.height, _colFoot.getPreferredSize().height);\n _colFoot.setBounds(adjustBounds(parent, new Rectangle(colFootR.x, colFootR.y, colFootR.width, height), ltr));\n }\n else {\n if (isColumnFootersHeightUnified(scrollPane)) {\n columnFooterHeight = hsbR.height;\n }\n }\n if (vsb != null) {\n if (vsbNeeded) {\n vsb.setVisible(true);\n if (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED && !isEmpty && !(!viewTracksViewportHeight && (viewPrefSize.height > extentSize.height || (rowHead != null && rowHead.getView() != null && rowHead.getView().getPreferredSize().height > extentSize.height)))) {\n vsb.setVisible(false);\n }\n if (_vTop == null && _vBottom == null)\n vsb.setBounds(adjustBounds(parent, vsbR, ltr));\n else {\n Rectangle rect = new Rectangle(vsbR);\n if (_vTop != null) {\n Dimension dim = _vTop.getPreferredSize();\n rect.y += dim.height;\n rect.height -= dim.height;\n _vTop.setVisible(true);\n _vTop.setBounds(adjustBounds(parent, new Rectangle(vsbR.x, vsbR.y, vsbR.width, dim.height), ltr));\n }\n if (_vBottom != null) {\n Dimension dim = _vBottom.getPreferredSize();\n rect.height -= dim.height;\n _vBottom.setVisible(true);\n _vBottom.setBounds(adjustBounds(parent, new Rectangle(vsbR.x, vsbR.y + vsbR.height - dim.height, vsbR.width, dim.height), ltr));\n }\n vsb.setBounds(adjustBounds(parent, rect, ltr));\n }\n }\n else {\n if (viewPrefSize.height > extentSize.height) {\n vsb.setVisible(true);\n vsb.setBounds(adjustBounds(parent, new Rectangle(vsbR.x, vsbR.y, 0, vsbR.height), ltr));\n }\n else {\n vsb.setVisible(false);\n }\n if (_vTop != null)\n _vTop.setVisible(false);\n if (_vBottom != null)\n _vBottom.setVisible(false);\n }\n }\n if (hsb != null) {\n if (hsbNeeded) {\n hsb.setVisible(true);\n if (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED && !isEmpty && !(!viewTracksViewportWidth && (viewPrefSize.width > extentSize.width || (colHead != null && colHead.getView() != null && colHead.getView().getPreferredSize().width > extentSize.width)))) {\n hsb.setVisible(false);\n }\n if (_hLeft == null && _hRight == null)\n hsb.setBounds(adjustBounds(parent, hsbR, ltr));\n else {\n Rectangle rect = new Rectangle(hsbR);\n if (_hLeft != null) {\n Dimension dim = _hLeft.getPreferredSize();\n rect.x += dim.width;\n rect.width -= dim.width;\n _hLeft.setVisible(true);\n _hLeft.setBounds(adjustBounds(parent, new Rectangle(hsbR.x, hsbR.y, dim.width, hsbR.height), ltr));\n _hLeft.doLayout();\n }\n if (_hRight != null) {\n Dimension dim = _hRight.getPreferredSize();\n rect.width -= dim.width;\n _hRight.setVisible(true);\n _hRight.setBounds(adjustBounds(parent, new Rectangle(hsbR.x + hsbR.width - dim.width, hsbR.y, dim.width, hsbR.height), ltr));\n }\n hsb.setBounds(adjustBounds(parent, rect, ltr));\n }\n }\n else {\n if (viewPrefSize.width > extentSize.width) {\n hsb.setVisible(true);\n hsb.setBounds(adjustBounds(parent, new Rectangle(hsbR.x, hsbR.y, hsbR.width, 0), ltr));\n }\n else {\n hsb.setVisible(false);\n }\n if (_hLeft != null)\n _hLeft.setVisible(false);\n if (_hRight != null)\n _hRight.setVisible(false);\n }\n }\n if (lowerLeft != null && lowerLeft.isVisible()) {\n int height = isColumnFootersHeightUnified(scrollPane) ? columnFooterHeight : Math.min(lowerLeft.getPreferredSize().height, colFootR.height);\n lowerLeft.setBounds(adjustBounds(parent, new Rectangle(rowHeadR.x, colFootR.y != 0 ? colFootR.y : hsbR.y, rowHeadR.width, height), ltr));\n }\n if (lowerRight != null && lowerRight.isVisible()) {\n int height = isColumnFootersHeightUnified(scrollPane) ? columnFooterHeight : Math.min(lowerRight.getPreferredSize().height, colFootR.height);\n lowerRight.setBounds(adjustBounds(parent, new Rectangle(rowFootR.x, colFootR.y != 0 ? colFootR.y : hsbR.y, rowFootR.width + (isVsbCoversWholeHeight(scrollPane) ? 0 : vsbR.width), height), ltr));\n }\n if (upperLeft != null && upperLeft.isVisible()) {\n int height = isColumnHeadersHeightUnified(scrollPane) ? columnHeaderHeight : Math.min(upperLeft.getPreferredSize().height, colHeadR.height);\n upperLeft.setBounds(adjustBounds(parent, new Rectangle(rowHeadR.x, colHeadR.y + colHeadR.height - height, rowHeadR.width, height), ltr));\n }\n if (upperRight != null && upperRight.isVisible()) {\n int height = isColumnHeadersHeightUnified(scrollPane) ? columnHeaderHeight : Math.min(upperRight.getPreferredSize().height, colHeadR.height);\n upperRight.setBounds(adjustBounds(parent, new Rectangle(rowFootR.x, colHeadR.y + colHeadR.height - height, rowFootR.width + (isVsbCoversWholeHeight(scrollPane) ? 0 : vsbR.width), height), ltr));\n }\n }\n", "output": " public void layoutContainer(Container parent) {\n JScrollPane scrollPane = (JScrollPane) parent;\n vsbPolicy = scrollPane.getVerticalScrollBarPolicy();\n hsbPolicy = scrollPane.getHorizontalScrollBarPolicy();\n Rectangle availR = scrollPane.getBounds();\n availR.x = availR.y = 0;\n Insets insets = parent.getInsets();\n availR.x = insets.left;\n availR.y = insets.top;\n availR.width -= insets.left + insets.right;\n availR.height -= insets.top + insets.bottom;\n Rectangle colHeadR = new Rectangle(0, availR.y, 0, 0);\n int upperHeight = getUpperHeight();\n if ((colHead != null) && (colHead.isVisible())) {\n int colHeadHeight = Math.min(availR.height, upperHeight);\n colHeadR.height = colHeadHeight;\n availR.y += colHeadHeight;\n availR.height -= colHeadHeight;\n }\n Rectangle subColHeadR = new Rectangle(0, availR.y, 0, 0);\n if (_subColHead != null && _subColHead.isVisible()) {\n int subColHeadHeight = Math.min(availR.height, _subColHead.getPreferredSize().height);\n subColHeadR.height = subColHeadHeight;\n availR.y += subColHeadHeight;\n availR.height -= subColHeadHeight;\n }\n Rectangle rowHeadR = new Rectangle(0, 0, 0, 0);\n if ((rowHead != null) && (rowHead.isVisible())) {\n int rowHeadWidth = rowHead.getPreferredSize().width;\n if (upperLeft != null && upperLeft.isVisible()) {\n rowHeadWidth = Math.max(rowHeadWidth, upperLeft.getPreferredSize().width);\n }\n if (lowerLeft != null && lowerLeft.isVisible()) {\n rowHeadWidth = Math.max(rowHeadWidth, lowerLeft.getPreferredSize().width);\n }\n rowHeadR.width = rowHeadWidth;\n availR.width -= rowHeadWidth;\n rowHeadR.x = availR.x;\n availR.x += rowHeadWidth;\n }\n Border viewportBorder = scrollPane.getViewportBorder();\n Insets vpbInsets;\n if (viewportBorder != null) {\n vpbInsets = viewportBorder.getBorderInsets(parent);\n availR.x += vpbInsets.left;\n availR.y += vpbInsets.top;\n availR.width -= vpbInsets.left + vpbInsets.right;\n availR.height -= vpbInsets.top + vpbInsets.bottom;\n }\n else {\n vpbInsets = new Insets(0, 0, 0, 0);\n }\n Rectangle rowFootR = new Rectangle(0, 0, 0, 0);\n if ((_rowFoot != null) && (_rowFoot.isVisible())) {\n int rowFootWidth = _rowFoot.getPreferredSize().width;\n if (upperRight != null && upperRight.isVisible()) {\n rowFootWidth = Math.max(rowFootWidth, upperRight.getPreferredSize().width);\n }\n if (lowerRight != null && lowerRight.isVisible()) {\n rowFootWidth = Math.max(rowFootWidth, lowerRight.getPreferredSize().width);\n }\n rowFootR.width = rowFootWidth;\n availR.width -= rowFootWidth;\n rowFootR.x = availR.x + availR.width;\n }\n Rectangle colFootR = new Rectangle(0, availR.y, 0, 0);\n int lowerHeight = getLowerHeight();\n if ((_colFoot != null) && (_colFoot.isVisible())) {\n int colFootHeight = Math.min(availR.height, lowerHeight);\n colFootR.height = colFootHeight;\n availR.height -= colFootHeight;\n colFootR.y = availR.y + availR.height;\n }\n Component view = (viewport != null) ? viewport.getView() : null;\n Dimension viewPrefSize = (view != null) ? view.getPreferredSize() : new Dimension(0, 0);\n Dimension extentSize =\n (viewport != null) ? viewport.toViewCoordinates(availR.getSize())\n : new Dimension(0, 0);\n boolean viewTracksViewportWidth = false;\n boolean viewTracksViewportHeight = false;\n boolean isEmpty = (availR.width < 0 || availR.height < 0);\n Scrollable sv;\n if (!isEmpty && view instanceof Scrollable) {\n sv = (Scrollable) view;\n viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();\n viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();\n }\n else {\n sv = null;\n }\n Rectangle vsbR = new Rectangle(0, isVsbCoversWholeHeight(scrollPane) ? insets.top : availR.y - vpbInsets.top, 0, 0);\n boolean vsbNeeded;\n if (vsbPolicy == VERTICAL_SCROLLBAR_ALWAYS) {\n vsbNeeded = true;\n }\n else if (vsbPolicy == VERTICAL_SCROLLBAR_NEVER) {\n vsbNeeded = false;\n }\n else if (isEmpty) {\n vsbNeeded = false;\n }\n else { \n vsbNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height || (rowHead != null && rowHead.getView() != null && rowHead.getView().getPreferredSize().height > extentSize.height));\n if (!vsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n vsbNeeded = true;\n }\n }\n if ((vsb != null) && vsbNeeded) {\n adjustForVSB(true, availR, vsbR, vpbInsets, true);\n extentSize = viewport.toViewCoordinates(availR.getSize());\n }\n Rectangle hsbR = new Rectangle(isHsbCoversWholeWidth(scrollPane) ? insets.left : availR.x - vpbInsets.left, 0, 0, 0);\n boolean hsbNeeded;\n if (hsbPolicy == HORIZONTAL_SCROLLBAR_ALWAYS) {\n hsbNeeded = true;\n }\n else if (hsbPolicy == HORIZONTAL_SCROLLBAR_NEVER) {\n hsbNeeded = false;\n }\n else if (isEmpty) {\n hsbNeeded = false;\n }\n else { \n hsbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width || (colHead != null && colHead.getView() != null && colHead.getView().getPreferredSize().width > extentSize.width));\n if (!hsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_hLeft != null || _hRight != null)) {\n hsbNeeded = true;\n }\n }\n if ((hsb != null) && hsbNeeded) {\n adjustForHSB(true, availR, hsbR, vpbInsets);\n if ((vsb != null) && !vsbNeeded &&\n (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {\n extentSize = viewport.toViewCoordinates(availR.getSize());\n vsbNeeded = viewPrefSize.height > extentSize.height;\n if (!vsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n vsbNeeded = true;\n }\n if (vsbNeeded) {\n adjustForVSB(true, availR, vsbR, vpbInsets, true);\n }\n }\n }\n boolean ltr = scrollPane.getComponentOrientation().isLeftToRight();\n if (viewport != null) {\n viewport.setBounds(adjustBounds(parent, availR, ltr));\n if (sv != null) {\n extentSize = viewport.toViewCoordinates(availR.getSize());\n boolean oldHSBNeeded = hsbNeeded;\n boolean oldVSBNeeded = vsbNeeded;\n viewTracksViewportWidth = sv.getScrollableTracksViewportWidth();\n viewTracksViewportHeight = sv.getScrollableTracksViewportHeight();\n if (vsb != null && vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED) {\n boolean newVSBNeeded = !viewTracksViewportHeight && (viewPrefSize.height > extentSize.height || (rowHead != null && rowHead.getView() != null && rowHead.getView().getPreferredSize().height > extentSize.height));\n if (!newVSBNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n newVSBNeeded = true;\n }\n if (newVSBNeeded != vsbNeeded) {\n vsbNeeded = newVSBNeeded;\n adjustForVSB(vsbNeeded, availR, vsbR, vpbInsets, true);\n extentSize = viewport.toViewCoordinates\n (availR.getSize());\n }\n }\n if (hsb != null && hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED) {\n boolean newHSBbNeeded = !viewTracksViewportWidth && (viewPrefSize.width > extentSize.width || (colHead != null && colHead.getView() != null && colHead.getView().getPreferredSize().width > extentSize.width));\n if (!newHSBbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_hLeft != null || _hRight != null)) {\n newHSBbNeeded = true;\n }\n if (newHSBbNeeded != hsbNeeded) {\n hsbNeeded = newHSBbNeeded;\n adjustForHSB(hsbNeeded, availR, hsbR, vpbInsets);\n if ((vsb != null) && !vsbNeeded &&\n (vsbPolicy != VERTICAL_SCROLLBAR_NEVER)) {\n extentSize = viewport.toViewCoordinates\n (availR.getSize());\n vsbNeeded = viewPrefSize.height >\n extentSize.height;\n if (!vsbNeeded && scrollPane instanceof JideScrollPane && ((JideScrollPane) scrollPane).isKeepCornerVisible() && (_vBottom != null || _vTop != null)) {\n vsbNeeded = true;\n }\n if (vsbNeeded) {\n adjustForVSB(true, availR, vsbR, vpbInsets, true);\n }\n }\n if (_rowFoot != null && _rowFoot.isVisible()) {\n vsbR.x += rowFootR.width;\n }\n }\n }\n if (oldHSBNeeded != hsbNeeded ||\n oldVSBNeeded != vsbNeeded) {\n viewport.setBounds(adjustBounds(parent, availR, ltr));\n }\n }\n }\n vsbR.height = isVsbCoversWholeHeight(scrollPane) ? scrollPane.getHeight() - insets.bottom - insets.top : availR.height + vpbInsets.top + vpbInsets.bottom;\n hsbR.width = isHsbCoversWholeWidth(scrollPane) ? scrollPane.getWidth() - vsbR.width - insets.left - insets.right : availR.width + vpbInsets.left + vpbInsets.right;\n rowHeadR.height = availR.height + vpbInsets.top + vpbInsets.bottom;\n rowHeadR.y = availR.y - vpbInsets.top;\n colHeadR.width = availR.width + vpbInsets.left + vpbInsets.right;\n colHeadR.x = availR.x - vpbInsets.left;\n subColHeadR.width = colHeadR.width;\n subColHeadR.x = colHeadR.x;\n colFootR.x = availR.x;\n colFootR.y = rowHeadR.y + rowHeadR.height;\n colFootR.width = availR.width;\n rowFootR.x = availR.x + availR.width;\n rowFootR.y = availR.y;\n rowFootR.height = availR.height;\n vsbR.x += rowFootR.width;\n hsbR.y += colFootR.height;\n if (rowHead != null) {\n rowHead.setBounds(adjustBounds(parent, rowHeadR, ltr));\n }\n if (_rowFoot != null) {\n _rowFoot.setBounds(adjustBounds(parent, rowFootR, ltr));\n }\n int columnHeaderHeight = isColumnHeadersHeightUnified(scrollPane) ? Math.max(colHeadR.height,\n Math.max(upperLeft == null ? 0 : upperLeft.getPreferredSize().height, upperRight == null ? 0 : upperRight.getPreferredSize().height)) : 0;\n int columnFooterHeight = isColumnFootersHeightUnified(scrollPane) ? Math.max(colFootR.height,\n Math.max(lowerLeft == null ? 0 : lowerLeft.getPreferredSize().height, lowerRight == null ? 0 : lowerRight.getPreferredSize().height)) : 0;\n if (colHead != null) {\n int height = isColumnHeadersHeightUnified(scrollPane) ? columnHeaderHeight : Math.min(colHeadR.height, colHead.getPreferredSize().height);\n colHead.setBounds(adjustBounds(parent, new Rectangle(colHeadR.x, colHeadR.y + colHeadR.height - height, colHeadR.width, height), ltr));\n }\n if (_subColHead != null) {\n _subColHead.setBounds(adjustBounds(parent, subColHeadR, ltr));\n }\n if (_colFoot != null) {\n int height = isColumnFootersHeightUnified(scrollPane) ? columnFooterHeight : Math.min(colFootR.height, _colFoot.getPreferredSize().height);\n _colFoot.setBounds(adjustBounds(parent, new Rectangle(colFootR.x, colFootR.y, colFootR.width, height), ltr));\n }\n else {\n if (isColumnFootersHeightUnified(scrollPane)) {\n columnFooterHeight = hsbR.height;\n }\n }\n if (vsb != null) {\n if (vsbNeeded) {\n vsb.setVisible(true);\n if (vsbPolicy == VERTICAL_SCROLLBAR_AS_NEEDED && !isEmpty && !(!viewTracksViewportHeight && (viewPrefSize.height > extentSize.height || (rowHead != null && rowHead.getView() != null && rowHead.getView().getPreferredSize().height > extentSize.height)))) {\n vsb.setVisible(false);\n }\n if (_vTop == null && _vBottom == null)\n vsb.setBounds(adjustBounds(parent, vsbR, ltr));\n else {\n Rectangle rect = new Rectangle(vsbR);\n if (_vTop != null) {\n Dimension dim = _vTop.getPreferredSize();\n rect.y += dim.height;\n rect.height -= dim.height;\n _vTop.setVisible(true);\n _vTop.setBounds(adjustBounds(parent, new Rectangle(vsbR.x, vsbR.y, vsbR.width, dim.height), ltr));\n }\n if (_vBottom != null) {\n Dimension dim = _vBottom.getPreferredSize();\n rect.height -= dim.height;\n _vBottom.setVisible(true);\n _vBottom.setBounds(adjustBounds(parent, new Rectangle(vsbR.x, vsbR.y + vsbR.height - dim.height, vsbR.width, dim.height), ltr));\n }\n vsb.setBounds(adjustBounds(parent, rect, ltr));\n }\n }\n else {\n if (viewPrefSize.height > extentSize.height) {\n vsb.setVisible(true);\n vsb.setBounds(adjustBounds(parent, new Rectangle(vsbR.x, vsbR.y, 0, vsbR.height), ltr));\n }\n else {\n vsb.setVisible(false);\n }\n if (_vTop != null)\n _vTop.setVisible(false);\n if (_vBottom != null)\n _vBottom.setVisible(false);\n }\n }\n if (hsb != null) {\n if (hsbNeeded) {\n hsb.setVisible(true);\n if (hsbPolicy == HORIZONTAL_SCROLLBAR_AS_NEEDED && !isEmpty && !(!viewTracksViewportWidth && (viewPrefSize.width > extentSize.width || (colHead != null && colHead.getView() != null && colHead.getView().getPreferredSize().width > extentSize.width)))) {\n hsb.setVisible(false);\n }\n if (_hLeft == null && _hRight == null)\n hsb.setBounds(adjustBounds(parent, hsbR, ltr));\n else {\n Rectangle rect = new Rectangle(hsbR);\n if (_hLeft != null) {\n Dimension dim = _hLeft.getPreferredSize();\n rect.x += dim.width;\n rect.width -= dim.width;\n _hLeft.setVisible(true);\n _hLeft.setBounds(adjustBounds(parent, new Rectangle(hsbR.x, hsbR.y, dim.width, hsbR.height), ltr));\n _hLeft.doLayout();\n }\n if (_hRight != null) {\n Dimension dim = _hRight.getPreferredSize();\n rect.width -= dim.width;\n _hRight.setVisible(true);\n _hRight.setBounds(adjustBounds(parent, new Rectangle(hsbR.x + hsbR.width - dim.width, hsbR.y, dim.width, hsbR.height), ltr));\n }\n hsb.setBounds(adjustBounds(parent, rect, ltr));\n }\n }\n else {\n if (viewPrefSize.width > extentSize.width) {\n hsb.setVisible(true);\n hsb.setBounds(adjustBounds(parent, new Rectangle(hsbR.x, hsbR.y, hsbR.width, 0), ltr));\n }\n else {\n hsb.setVisible(false);\n }\n if (_hLeft != null)\n _hLeft.setVisible(false);\n if (_hRight != null)\n _hRight.setVisible(false);\n }\n }\n if (lowerLeft != null && lowerLeft.isVisible()) {\n int height = isColumnFootersHeightUnified(scrollPane) ? columnFooterHeight : Math.min(lowerLeft.getPreferredSize().height, colFootR.height);\n lowerLeft.setBounds(adjustBounds(parent, new Rectangle(rowHeadR.x, colFootR.y != 0 ? colFootR.y : hsbR.y, rowHeadR.width, height), ltr));\n }\n if (lowerRight != null && lowerRight.isVisible()) {\n int height = isColumnFootersHeightUnified(scrollPane) ? columnFooterHeight : Math.min(lowerRight.getPreferredSize().height, colFootR.height);\n lowerRight.setBounds(adjustBounds(parent, new Rectangle(rowFootR.x, colFootR.y != 0 ? colFootR.y : hsbR.y, rowFootR.width, height), ltr));\n }\n if (upperLeft != null && upperLeft.isVisible()) {\n int height = isColumnHeadersHeightUnified(scrollPane) ? columnHeaderHeight : Math.min(upperLeft.getPreferredSize().height, colHeadR.height);\n upperLeft.setBounds(adjustBounds(parent, new Rectangle(rowHeadR.x, colHeadR.y + colHeadR.height - height, rowHeadR.width, height), ltr));\n }\n if (upperRight != null && upperRight.isVisible()) {\n int height = isColumnHeadersHeightUnified(scrollPane) ? columnHeaderHeight : Math.min(upperRight.getPreferredSize().height, colHeadR.height);\n upperRight.setBounds(adjustBounds(parent, new Rectangle(rowFootR.x, colHeadR.y + colHeadR.height - height, rowFootR.width, height), ltr));\n }\n }\n"} {"input": " public void createIndex(final Request request, final Listener userListener) {\n clusterService.submitStateUpdateTask(\"create-index [\" + request.index + \"], cause [\" + request.cause + \"]\", new ClusterStateUpdateTask() {\n @Override public ClusterState execute(ClusterState currentState) {\n final CreateIndexListener listener = new CreateIndexListener(request, userListener);\n try {\n if (currentState.routingTable().hasIndex(request.index)) {\n listener.onFailure(new IndexAlreadyExistsException(new Index(request.index)));\n return currentState;\n }\n if (currentState.metaData().hasIndex(request.index)) {\n listener.onFailure(new IndexAlreadyExistsException(new Index(request.index)));\n return currentState;\n }\n if (request.index.contains(\" \")) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain whitespace\"));\n return currentState;\n }\n if (request.index.contains(\",\")) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain ',\"));\n return currentState;\n }\n if (request.index.contains(\"#\")) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain '#\"));\n return currentState;\n }\n if (request.index.charAt(0) == '_') {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not start with '_'\"));\n return currentState;\n }\n if (!request.index.toLowerCase().equals(request.index)) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must be lowercase\"));\n return currentState;\n }\n if (!Strings.validFileName(request.index)) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain the following characters \" + Strings.INVALID_FILENAME_CHARS));\n return currentState;\n }\n if (currentState.metaData().aliases().contains(request.index)) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"an alias with the same name already exists\"));\n return currentState;\n }\n Map<String, String> mappings = Maps.newHashMap();\n File mappingsDir = new File(environment.configFile(), \"mappings\");\n if (mappingsDir.exists() && mappingsDir.isDirectory()) {\n File defaultMappingsDir = new File(mappingsDir, \"_default\");\n if (mappingsDir.exists() && mappingsDir.isDirectory()) {\n addMappings(mappings, defaultMappingsDir);\n }\n File indexMappingsDir = new File(mappingsDir, request.index);\n if (mappingsDir.exists() && mappingsDir.isDirectory()) {\n addMappings(mappings, indexMappingsDir);\n }\n }\n mappings.putAll(request.mappings);\n ImmutableSettings.Builder indexSettingsBuilder = settingsBuilder().put(request.settings);\n if (request.settings.get(SETTING_NUMBER_OF_SHARDS) == null) {\n indexSettingsBuilder.put(SETTING_NUMBER_OF_SHARDS, settings.getAsInt(SETTING_NUMBER_OF_SHARDS, 5));\n }\n if (request.settings.get(SETTING_NUMBER_OF_REPLICAS) == null) {\n indexSettingsBuilder.put(SETTING_NUMBER_OF_REPLICAS, settings.getAsInt(SETTING_NUMBER_OF_REPLICAS, 1));\n }\n Settings actualIndexSettings = indexSettingsBuilder.build();\n IndexMetaData.Builder indexMetaData = newIndexMetaDataBuilder(request.index).settings(actualIndexSettings);\n for (Map.Entry<String, String> entry : mappings.entrySet()) {\n indexMetaData.putMapping(entry.getKey(), entry.getValue());\n }\n MetaData newMetaData = newMetaDataBuilder()\n .metaData(currentState.metaData())\n .put(indexMetaData)\n .build();\n logger.info(\"[{}] creating index, cause [{}], shards [{}]/[{}], mappings {}\", request.index, request.cause, indexMetaData.numberOfShards(), indexMetaData.numberOfReplicas(), mappings.keySet());\n final AtomicInteger counter = new AtomicInteger(currentState.nodes().size());\n final NodeIndexCreatedAction.Listener nodeIndexCreateListener = new NodeIndexCreatedAction.Listener() {\n @Override public void onNodeIndexCreated(String index, String nodeId) {\n if (index.equals(request.index)) {\n if (counter.decrementAndGet() == 0) {\n listener.onResponse(new Response(true));\n nodeIndexCreatedAction.remove(this);\n }\n }\n }\n };\n nodeIndexCreatedAction.add(nodeIndexCreateListener);\n Timeout timeoutTask = timerService.newTimeout(new TimerTask() {\n @Override public void run(Timeout timeout) throws Exception {\n listener.onResponse(new Response(false));\n nodeIndexCreatedAction.remove(nodeIndexCreateListener);\n }\n }, request.timeout, TimerService.ExecutionType.THREADED);\n listener.timeout = timeoutTask;\n return newClusterStateBuilder().state(currentState).metaData(newMetaData).build();\n } catch (Exception e) {\n listener.onFailure(e);\n return currentState;\n }\n }\n });\n }\n", "output": " public void createIndex(final Request request, final Listener userListener) {\n clusterService.submitStateUpdateTask(\"create-index [\" + request.index + \"], cause [\" + request.cause + \"]\", new ClusterStateUpdateTask() {\n @Override public ClusterState execute(ClusterState currentState) {\n final CreateIndexListener listener = new CreateIndexListener(request, userListener);\n try {\n if (currentState.routingTable().hasIndex(request.index)) {\n listener.onFailure(new IndexAlreadyExistsException(new Index(request.index)));\n return currentState;\n }\n if (currentState.metaData().hasIndex(request.index)) {\n listener.onFailure(new IndexAlreadyExistsException(new Index(request.index)));\n return currentState;\n }\n if (request.index.contains(\" \")) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain whitespace\"));\n return currentState;\n }\n if (request.index.contains(\",\")) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain ',\"));\n return currentState;\n }\n if (request.index.contains(\"#\")) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain '#\"));\n return currentState;\n }\n if (request.index.charAt(0) == '_') {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not start with '_'\"));\n return currentState;\n }\n if (!request.index.toLowerCase().equals(request.index)) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must be lowercase\"));\n return currentState;\n }\n if (!Strings.validFileName(request.index)) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"must not contain the following characters \" + Strings.INVALID_FILENAME_CHARS));\n return currentState;\n }\n if (currentState.metaData().aliases().contains(request.index)) {\n listener.onFailure(new InvalidIndexNameException(new Index(request.index), request.index, \"an alias with the same name already exists\"));\n return currentState;\n }\n Map<String, String> mappings = Maps.newHashMap();\n File mappingsDir = new File(environment.configFile(), \"mappings\");\n if (mappingsDir.exists() && mappingsDir.isDirectory()) {\n File defaultMappingsDir = new File(mappingsDir, \"_default\");\n if (defaultMappingsDir.exists() && defaultMappingsDir.isDirectory()) {\n addMappings(mappings, defaultMappingsDir);\n }\n File indexMappingsDir = new File(mappingsDir, request.index);\n if (indexMappingsDir.exists() && indexMappingsDir.isDirectory()) {\n addMappings(mappings, indexMappingsDir);\n }\n }\n mappings.putAll(request.mappings);\n ImmutableSettings.Builder indexSettingsBuilder = settingsBuilder().put(request.settings);\n if (request.settings.get(SETTING_NUMBER_OF_SHARDS) == null) {\n indexSettingsBuilder.put(SETTING_NUMBER_OF_SHARDS, settings.getAsInt(SETTING_NUMBER_OF_SHARDS, 5));\n }\n if (request.settings.get(SETTING_NUMBER_OF_REPLICAS) == null) {\n indexSettingsBuilder.put(SETTING_NUMBER_OF_REPLICAS, settings.getAsInt(SETTING_NUMBER_OF_REPLICAS, 1));\n }\n Settings actualIndexSettings = indexSettingsBuilder.build();\n IndexMetaData.Builder indexMetaData = newIndexMetaDataBuilder(request.index).settings(actualIndexSettings);\n for (Map.Entry<String, String> entry : mappings.entrySet()) {\n indexMetaData.putMapping(entry.getKey(), entry.getValue());\n }\n MetaData newMetaData = newMetaDataBuilder()\n .metaData(currentState.metaData())\n .put(indexMetaData)\n .build();\n logger.info(\"[{}] creating index, cause [{}], shards [{}]/[{}], mappings {}\", request.index, request.cause, indexMetaData.numberOfShards(), indexMetaData.numberOfReplicas(), mappings.keySet());\n final AtomicInteger counter = new AtomicInteger(currentState.nodes().size());\n final NodeIndexCreatedAction.Listener nodeIndexCreateListener = new NodeIndexCreatedAction.Listener() {\n @Override public void onNodeIndexCreated(String index, String nodeId) {\n if (index.equals(request.index)) {\n if (counter.decrementAndGet() == 0) {\n listener.onResponse(new Response(true));\n nodeIndexCreatedAction.remove(this);\n }\n }\n }\n };\n nodeIndexCreatedAction.add(nodeIndexCreateListener);\n Timeout timeoutTask = timerService.newTimeout(new TimerTask() {\n @Override public void run(Timeout timeout) throws Exception {\n listener.onResponse(new Response(false));\n nodeIndexCreatedAction.remove(nodeIndexCreateListener);\n }\n }, request.timeout, TimerService.ExecutionType.THREADED);\n listener.timeout = timeoutTask;\n return newClusterStateBuilder().state(currentState).metaData(newMetaData).build();\n } catch (Exception e) {\n listener.onFailure(e);\n return currentState;\n }\n }\n });\n }\n"} {"input": "\tprotected Composite createHeaderControls(Composite composite, FormToolkit toolkit) {\n\t\theaderComposite = toolkit.createComposite(composite);\n\t\tGridLayout layout = new GridLayout(1, false);\n\t\tlayout.verticalSpacing = 1;\n\t\tlayout.marginHeight = 1;\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginBottom = 10;\n\t\theaderComposite.setLayout(layout);\n\t\tcreateLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Status, 0);\n\t\tstatusCombo = new CCombo(headerComposite, SWT.FLAT | SWT.READ_ONLY);\n\t\ttoolkit.adapt(statusCombo, true, true);\n\t\tstatusCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);\n\t\tstatusCombo.add(Messages.TaskPlanningEditor_Complete);\n\t\tstatusCombo.add(Messages.TaskPlanningEditor_Incomplete);\n\t\tif (getTask().isCompleted()) {\n\t\t\tstatusCombo.select(0);\n\t\t} else {\n\t\t\tstatusCombo.select(1);\n\t\t}\n\t\tstatusCombo.setEnabled(getTask() instanceof LocalTask);\n\t\tstatusCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmarkDirty();\n\t\t\t}\n\t\t});\n\t\tComposite spacer = toolkit.createComposite(headerComposite, SWT.NONE);\n\t\tGridDataFactory.fillDefaults().hint(0, 10).grab(true, false).applyTo(spacer);\n\t\tcreateLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Created, 0);\n\t\tcreationDateText = toolkit.createText(headerComposite, getDateString(getTask().getCreationDate()), SWT.FLAT\n\t\t\t\t| SWT.READ_ONLY);\n\t\tcreationDateText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);\n\t\tcreateLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Completed, EditorUtil.HEADER_COLUMN_MARGIN);\n\t\tcompletionDateText = toolkit.createText(headerComposite, getDateString(getTask().getCompletionDate()), SWT.FLAT\n\t\t\t\t| SWT.READ_ONLY);\n\t\tcompletionDateText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);\n\t\tlayout.numColumns = headerComposite.getChildren().length;\n\t\ttoolkit.paintBordersFor(headerComposite);\n\t\treturn headerComposite;\n\t}\n", "output": "\tprotected Composite createHeaderControls(Composite composite, FormToolkit toolkit) {\n\t\theaderComposite = toolkit.createComposite(composite);\n\t\tGridLayout layout = new GridLayout(1, false);\n\t\tlayout.verticalSpacing = 1;\n\t\tlayout.marginHeight = 1;\n\t\tlayout.marginWidth = 0;\n\t\tlayout.marginBottom = 10;\n\t\theaderComposite.setLayout(layout);\n\t\tcreateLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Status, 0);\n\t\tstatusCombo = new CCombo(headerComposite, SWT.FLAT | SWT.READ_ONLY);\n\t\ttoolkit.adapt(statusCombo, true, true);\n\t\tstatusCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);\n\t\tstatusCombo.add(Messages.TaskPlanningEditor_Complete);\n\t\tstatusCombo.add(Messages.TaskPlanningEditor_Incomplete);\n\t\tif (getTask().isCompleted()) {\n\t\t\tstatusCombo.select(0);\n\t\t} else {\n\t\t\tstatusCombo.select(1);\n\t\t}\n\t\tstatusCombo.setEnabled(getTask() instanceof LocalTask);\n\t\tstatusCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmarkDirty();\n\t\t\t}\n\t\t});\n\t\tComposite spacer = toolkit.createComposite(headerComposite, SWT.NONE);\n\t\tGridDataFactory.fillDefaults().hint(0, 10).grab(true, false).applyTo(spacer);\n\t\tcreateLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Created, 0);\n\t\tcreationDateText = new Text(headerComposite, SWT.FLAT | SWT.READ_ONLY);\n\t\ttoolkit.adapt(creationDateText, false, false);\n\t\tcreationDateText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);\n\t\tcreateLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Completed, EditorUtil.HEADER_COLUMN_MARGIN);\n\t\tcompletionDateText = new Text(headerComposite, SWT.FLAT | SWT.READ_ONLY);\n\t\ttoolkit.adapt(completionDateText, false, false);\n\t\tcompletionDateText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);\n\t\tlayout.numColumns = headerComposite.getChildren().length;\n\t\ttoolkit.paintBordersFor(headerComposite);\n\t\treturn headerComposite;\n\t}\n"} {"input": "\tpublic void importTag() throws ServiceException {\n\t\ttry {\n\t\t\tthis.session = this.getInfrastructure().getSession();\n\t\t\tTagDataImportRepositoryInterface imp_repo = this\n\t\t\t\t\t.getDomainsDirectory().getDataImportDomain()\n\t\t\t\t\t.getTagDataImportRepository();\n\t\t\tLedgerRepositoryInterface ledger_repo = this.getDomainsDirectory()\n\t\t\t\t\t.getLedgerDomain().getLedgerRepository();\n\t\t\tList<DataImportTag> dataforimp = imp_repo\n\t\t\t\t\t.findNotProcessesDataImportTags();\n\t\t\tint imported = 0;\n\t\t\tTransaction imp_tx1 = null;\n\t\t\tfor (int i = 0; i < dataforimp.size(); i++) {\n\t\t\t\tDataImportTag rawdata = dataforimp.get(i);\n\t\t\t\ttry {\n\t\t\t\t\timp_tx1 = null;\n\t\t\t\t\tString id = ledger_repo.getNextSeqId(\"Enumeration\");\n\t\t\t\t\tEnumeration enumeration = new Enumeration();\n\t\t\t\t\tif (rawdata.getSequenceNum() != null) {\n\t\t\t\t\t\tList<EnumerationType> types = ledger_repo.findList(\n\t\t\t\t\t\t\t\tEnumerationType.class, ledger_repo.map(\n\t\t\t\t\t\t\t\t\t\tEnumerationType.Fields.enumTypeId,\n\t\t\t\t\t\t\t\t\t\trawdata.getType()));\n\t\t\t\t\t\tList<Enumeration> enums1 = ledger_repo.findList(\n\t\t\t\t\t\t\t\tEnumeration.class, ledger_repo.map(\n\t\t\t\t\t\t\t\t\t\tEnumeration.Fields.sequenceId, rawdata\n\t\t\t\t\t\t\t\t\t\t\t\t.getSequenceNum(),\n\t\t\t\t\t\t\t\t\t\tEnumeration.Fields.enumTypeId, types\n\t\t\t\t\t\t\t\t\t\t\t\t.get(0).getEnumTypeId()));\n\t\t\t\t\t\tif (enums1.isEmpty()) {\n\t\t\t\t\t\t\tDebug.log(\"Registro Nuevo\");\n\t\t\t\t\t\t\tenumeration.setEnumId(id);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tenumeration.setEnumId(enums1.get(0).getEnumId());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenumeration.setEnumTypeId(types.get(0).getEnumTypeId());\n\t\t\t\t\t\tenumeration.setSequenceId(rawdata.getSequenceNum());\n\t\t\t\t\t\tenumeration.setEnumCode(rawdata.getName());\n\t\t\t\t\t\tenumeration.setFechaInicio(rawdata.getFechaInicio());\n\t\t\t\t\t\tenumeration.setFechaFin(rawdata.getFechaFin());\n\t\t\t\t\t\tenumeration.setDescription(rawdata.getDescription());\n\t\t\t\t\t\tenumeration.setNivelId(rawdata.getNivel());\n\t\t\t\t\t\tenumeration.setNode(rawdata.getNode());\n\t\t\t\t\t\timp_tx1 = this.session.beginTransaction();\n\t\t\t\t\t\tledger_repo.createOrUpdate(enumeration);\n\t\t\t\t\t\timp_tx1.commit();\n\t\t\t\t\t}\n\t\t\t\t\tString message = \"Successfully imported Tag [\"\n\t\t\t\t\t\t\t+ rawdata.getId() + \"].\";\n\t\t\t\t\tthis.storeImportTagSuccess(rawdata, imp_repo);\n\t\t\t\t\tDebug.logInfo(message, MODULE);\n\t\t\t\t\timported = imported + 1;\n\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\tString message = \"Failed to import Tag [\" + rawdata.getId()\n\t\t\t\t\t\t\t+ \"], Error message : \" + ex.getMessage();\n\t\t\t\t\tstoreImportTagError(rawdata, message, imp_repo);\n\t\t\t\t\tif (imp_tx1 != null) {\n\t\t\t\t\t\timp_tx1.rollback();\n\t\t\t\t\t}\n\t\t\t\t\tDebug.logError(ex, message, MODULE);\n\t\t\t\t\tthrow new ServiceException(ex.getMessage());\n\t\t\t\t}\n\t\t\t}\n\t\t\tgetParentEnumeration(ledger_repo, dataforimp);\n\t\t\tthis.importedRecords = imported;\n\t\t} catch (InfrastructureException ex) {\n\t\t\tDebug.logError(ex, MODULE);\n\t\t\tthrow new ServiceException(ex.getMessage());\n\t\t} catch (RepositoryException ex) {\n\t\t\tDebug.logError(ex, MODULE);\n\t\t\tthrow new ServiceException(ex.getMessage());\n\t\t} finally {\n\t\t\tif (session != null) {\n\t\t\t\tsession.close();\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void importTag() throws ServiceException {\n\t\ttry {\n\t\t\tthis.session = this.getInfrastructure().getSession();\n\t\t\tTagDataImportRepositoryInterface imp_repo = this\n\t\t\t\t\t.getDomainsDirectory().getDataImportDomain()\n\t\t\t\t\t.getTagDataImportRepository();\n\t\t\tLedgerRepositoryInterface ledger_repo = this.getDomainsDirectory()\n\t\t\t\t\t.getLedgerDomain().getLedgerRepository();\n\t\t\tList<DataImportTag> dataforimp = imp_repo\n\t\t\t\t\t.findNotProcessesDataImportTags();\n\t\t\tint imported = 0;\n\t\t\tTransaction imp_tx1 = null;\n\t\t\tfor (int i = 0; i < dataforimp.size(); i++) {\n\t\t\t\tDataImportTag rawdata = dataforimp.get(i);\n\t\t\t\ttry {\n\t\t\t\t\timp_tx1 = null;\n\t\t\t\t\tString id = ledger_repo.getNextSeqId(\"Enumeration\");\n\t\t\t\t\tEnumeration enumeration = new Enumeration();\n\t\t\t\t\tif (rawdata.getSequenceNum() != null) {\n\t\t\t\t\t\tList<EnumerationType> types = ledger_repo.findList(\n\t\t\t\t\t\t\t\tEnumerationType.class, ledger_repo.map(\n\t\t\t\t\t\t\t\t\t\tEnumerationType.Fields.enumTypeId,\n\t\t\t\t\t\t\t\t\t\trawdata.getType()));\n\t\t\t\t\t\tList<Enumeration> enums1 = ledger_repo.findList(\n\t\t\t\t\t\t\t\tEnumeration.class, ledger_repo.map(\n\t\t\t\t\t\t\t\t\t\tEnumeration.Fields.sequenceId, rawdata\n\t\t\t\t\t\t\t\t\t\t\t\t.getSequenceNum(),\n\t\t\t\t\t\t\t\t\t\tEnumeration.Fields.enumTypeId, types\n\t\t\t\t\t\t\t\t\t\t\t\t.get(0).getEnumTypeId()));\n\t\t\t\t\t\tif (enums1.isEmpty()) {\n\t\t\t\t\t\t\tDebug.log(\"Registro Nuevo\");\n\t\t\t\t\t\t\tenumeration.setEnumId(id);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tenumeration.setEnumId(enums1.get(0).getEnumId());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenumeration.setEnumTypeId(types.get(0).getEnumTypeId());\n\t\t\t\t\t\tenumeration.setSequenceId(rawdata.getSequenceNum());\n\t\t\t\t\t\tenumeration.setEnumCode(rawdata.getName());\n\t\t\t\t\t\tenumeration.setFechaInicio(rawdata.getFechaInicio());\n\t\t\t\t\t\tenumeration.setFechaFin(rawdata.getFechaFin());\n\t\t\t\t\t\tenumeration.setDescription(rawdata.getDescription());\n\t\t\t\t\t\tenumeration.setNivelId(rawdata.getNivel());\n\t\t\t\t\t\tenumeration.setNode(rawdata.getNode());\n\t\t\t\t\t\timp_tx1 = this.session.beginTransaction();\n\t\t\t\t\t\tledger_repo.createOrUpdate(enumeration);\n\t\t\t\t\t\timp_tx1.commit();\n\t\t\t\t\t}\n\t\t\t\t\tString message = \"Successfully imported Tag [\"\n\t\t\t\t\t\t\t+ rawdata.getId() + \"].\";\n\t\t\t\t\tthis.storeImportTagSuccess(rawdata, imp_repo);\n\t\t\t\t\tDebug.logInfo(message, MODULE);\n\t\t\t\t\timported = imported + 1;\n\t\t\t\t} catch (Exception ex) {\n\t\t\t\t\tString message = \"Failed to import Tag [\" + rawdata.getId()\n\t\t\t\t\t\t\t+ \"], Error message : \" + ex.getMessage();\n\t\t\t\t\tstoreImportTagError(rawdata, message, imp_repo);\n\t\t\t\t\tif (imp_tx1 != null) {\n\t\t\t\t\t\timp_tx1.rollback();\n\t\t\t\t\t}\n\t\t\t\t\tDebug.logError(ex, message, MODULE);\n\t\t\t\t\tthrow new ServiceException(ex.getMessage());\n\t\t\t\t}\n\t\t\t}\n\t\t\tgetParentEnumeration(ledger_repo, dataforimp, imp_repo);\n\t\t\tthis.importedRecords = imported;\n\t\t} catch (InfrastructureException ex) {\n\t\t\tDebug.logError(ex, MODULE);\n\t\t\tthrow new ServiceException(ex.getMessage());\n\t\t} catch (RepositoryException ex) {\n\t\t\tDebug.logError(ex, MODULE);\n\t\t\tthrow new ServiceException(ex.getMessage());\n\t\t} finally {\n\t\t\tif (session != null) {\n\t\t\t\tsession.close();\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public Object parse(ParsingEngine parsingEngine, ArgumentSource source, Type type, ArgumentMatches matches) {\n ArgumentDefinition defaultDefinition = createDefaultArgumentDefinition(source);\n String value = getArgumentValue( defaultDefinition, matches );\n Class<? extends Feature> parameterType = JVMUtils.getParameterizedTypeClass(type);\n try {\n String name = defaultDefinition.fullName;\n String tribbleType = null;\n Tags tags = getArgumentTags(matches);\n if ( tags.getPositionalTags().size() > 2 ) {\n throw new UserException.CommandLineException(\n String.format(\"Unexpected number of positional tags for argument %s : %s. \" +\n \"Rod bindings only suport -X:type and -X:name,type argument styles\",\n value, source.field.getName()));\n } if ( tags.getPositionalTags().size() == 2 ) {\n name = tags.getPositionalTags().get(0);\n tribbleType = tags.getPositionalTags().get(1);\n } else {\n FeatureManager manager = new FeatureManager();\n String tag1 = tags.getPositionalTags().size() == 1 ? tags.getPositionalTags().get(0) : null;\n if ( tag1 != null ) {\n if ( manager.getByName(tag1) != null ) \n tribbleType = tag1;\n else\n name = tag1;\n }\n if ( tribbleType == null ) {\n File file = new File(value);\n if ( file.canRead() && file.isFile() ) {\n FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file);\n if ( featureDescriptor != null ) {\n tribbleType = featureDescriptor.getName();\n logger.info(\"Dynamically determined type of \" + file + \" to be \" + tribbleType);\n }\n }\n if ( tribbleType == null )\n if ( ! file.canRead() | !! file.isFile() ) {\n throw new UserException.BadArgumentValue(name, \"Couldn't read file to determine type: \" + file);\n } else {\n throw new UserException.CommandLineException(\n String.format(\"No tribble type was provided on the command line and the type of the file could not be determined dynamically. \" +\n \"Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s\",\n manager.userFriendlyListOfAvailableFeatures(parameterType)));\n }\n }\n }\n Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class);\n RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags);\n parsingEngine.addTags(result,tags);\n parsingEngine.addRodBinding(result);\n return result;\n } catch (InvocationTargetException e) {\n throw new UserException.CommandLineException(\n String.format(\"Failed to parse value %s for argument %s.\",\n value, source.field.getName()));\n } catch (Exception e) {\n throw new UserException.CommandLineException(\n String.format(\"Failed to parse value %s for argument %s. Message: %s\",\n value, source.field.getName(), e.getMessage()));\n }\n }\n", "output": " public Object parse(ParsingEngine parsingEngine, ArgumentSource source, Type type, ArgumentMatches matches) {\n ArgumentDefinition defaultDefinition = createDefaultArgumentDefinition(source);\n String value = getArgumentValue( defaultDefinition, matches );\n Class<? extends Feature> parameterType = JVMUtils.getParameterizedTypeClass(type);\n try {\n String name = defaultDefinition.fullName;\n String tribbleType = null;\n Tags tags = getArgumentTags(matches);\n if ( tags.getPositionalTags().size() > 2 ) {\n throw new UserException.CommandLineException(\n String.format(\"Unexpected number of positional tags for argument %s : %s. \" +\n \"Rod bindings only suport -X:type and -X:name,type argument styles\",\n value, source.field.getName()));\n } if ( tags.getPositionalTags().size() == 2 ) {\n name = tags.getPositionalTags().get(0);\n tribbleType = tags.getPositionalTags().get(1);\n } else {\n FeatureManager manager = new FeatureManager();\n String tag1 = tags.getPositionalTags().size() == 1 ? tags.getPositionalTags().get(0) : null;\n if ( tag1 != null ) {\n if ( manager.getByName(tag1) != null ) \n tribbleType = tag1;\n else\n name = tag1;\n }\n if ( tribbleType == null ) {\n File file = new File(value);\n if ( file.canRead() && file.isFile() ) {\n FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file);\n if ( featureDescriptor != null ) {\n tribbleType = featureDescriptor.getName();\n logger.info(\"Dynamically determined type of \" + file + \" to be \" + tribbleType);\n }\n }\n if ( tribbleType == null )\n if ( ! file.canRead() | ! file.isFile() ) {\n throw new UserException.BadArgumentValue(name, \"Couldn't read file to determine type: \" + file);\n } else {\n throw new UserException.CommandLineException(\n String.format(\"No tribble type was provided on the command line and the type of the file could not be determined dynamically. \" +\n \"Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s\",\n manager.userFriendlyListOfAvailableFeatures(parameterType)));\n }\n }\n }\n Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class);\n RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags);\n parsingEngine.addTags(result,tags);\n parsingEngine.addRodBinding(result);\n return result;\n } catch (InvocationTargetException e) {\n throw new UserException.CommandLineException(\n String.format(\"Failed to parse value %s for argument %s.\",\n value, source.field.getName()));\n } catch (Exception e) {\n throw new UserException.CommandLineException(\n String.format(\"Failed to parse value %s for argument %s. Message: %s\",\n value, source.field.getName(), e.getMessage()));\n }\n }\n"} {"input": " public void handle(final ActionContext actionContext) throws Exception {\n\tComponentContainer displayArea = actionContext.getTargetContainer();\n\tdisplayArea.removeAllComponents();\n\tUserActionList ual = (UserActionList) actionContext.getUserAction();\n\tfinal OpenGroupsApplication app = actionContext.getApp();\n\tfinal Entity entity = actionContext.getEntity();\n\tfinal TabSheet actionsTabSheet = new TabSheet();\n\tactionsTabSheet.addStyleName(Reindeer.TABSHEET_MINIMAL);\n\tactionsTabSheet.addStyleName(OpenGroupsStyles.USER_ACTIONS_TABSHEET);\n\tactionsTabSheet.addListener(new SelectedTabChangeListener() {\n\t @Override\n\t public void selectedTabChange(SelectedTabChangeEvent event) {\n\t\tTabSheet tabSheet = event.getTabSheet();\n\t\tAbstractComponentContainer selectedTabContent = (AbstractComponentContainer) tabSheet.getSelectedTab();\n\t\tUserAction ua = (UserAction) selectedTabContent.getData();\n\t\tif (entity != null) {\n\t\t Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue();\n\t\t if (desiredActionsQueue.size() != 0) {\n\t\t\tString nextAction = desiredActionsQueue.peek();\n\t\t\tif (nextAction.equals(ua.getActionName())) {\n\t\t\t desiredActionsQueue.remove();\n\t\t\t} else {\n\t\t\t return;\n\t\t\t}\n\t\t }\n\t\t}\n\t\tif (ua instanceof UserActionList) {\n\t\t ua.executeHandler(entity, app, selectedTabContent, false, actionContext);\n\t\t} else {\n\t\t if (entity != null) {\n\t\t\tentity.getState().setCurrentTabAction(ua);\n\t\t\tentity.getState().setCurrentTabActionContainer(selectedTabContent);\n\t\t\tentity.getState().setCurrentActionsPath(ua.getFullActionPath());\n\t\t\tactionContext.getWindow().setFragmentToEntity(entity);\n\t\t }\n\t\t ua.executeHandler(entity, app, selectedTabContent, false, actionContext);\n\t\t}\n\t }\n\t});\n\tMap<String, ComponentContainer> actionPathContainers = new HashMap<String, ComponentContainer>();\n\tList<UserAction> actionsList = new ArrayList<UserAction>(ual.getActions().values());\n\tfor (UserAction cua : actionsList) {\n\t if(!cua.isVisible(actionContext)) {\n\t\tcontinue;\n\t }\n\t CssLayout tabContent = new CssLayout();\n\t if (cua instanceof UserActionList) {\n\t } else {\n\t\ttabContent.setMargin(true);\n\t }\n\t tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE);\n\t actionPathContainers.put(cua.getActionName(), tabContent);\n\t tabContent.setData(cua);\n\t actionsTabSheet.addTab(tabContent, cua.getDisplayName(), null);\n\t}\n\tdisplayArea.addComponent(actionsTabSheet);\n\tif (entity != null) {\n\t Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue();\n\t if (desiredActionsQueue.size() != 0) {\n\t\tactionsTabSheet.setSelectedTab(actionPathContainers.get(desiredActionsQueue.peek()));\n\t }\n\t}\n }\n", "output": " public void handle(final ActionContext actionContext) throws Exception {\n\tComponentContainer displayArea = actionContext.getTargetContainer();\n\tdisplayArea.removeAllComponents();\n\tUserActionList ual = (UserActionList) actionContext.getUserAction();\n\tfinal OpenGroupsApplication app = actionContext.getApp();\n\tfinal Entity entity = actionContext.getEntity();\n\tfinal TabSheet actionsTabSheet = new TabSheet();\n\tactionsTabSheet.addStyleName(Reindeer.TABSHEET_MINIMAL);\n\tactionsTabSheet.addStyleName(OpenGroupsStyles.USER_ACTIONS_TABSHEET);\n\tactionsTabSheet.addListener(new SelectedTabChangeListener() {\n\t @Override\n\t public void selectedTabChange(SelectedTabChangeEvent event) {\n\t\tTabSheet tabSheet = event.getTabSheet();\n\t\tAbstractComponentContainer selectedTabContent = (AbstractComponentContainer) tabSheet.getSelectedTab();\n\t\tUserAction ua = (UserAction) selectedTabContent.getData();\n\t\tif (entity != null) {\n\t\t Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue();\n\t\t if (desiredActionsQueue.size() != 0) {\n\t\t\tString nextAction = desiredActionsQueue.peek();\n\t\t\tif (nextAction.equals(ua.getActionName())) {\n\t\t\t desiredActionsQueue.remove();\n\t\t\t} else {\n\t\t\t return;\n\t\t\t}\n\t\t }\n\t\t else{\n\t\t\tentity.getState().resetPageInfo();\n\t\t }\n\t\t}\n\t\tif (ua instanceof UserActionList) {\n\t\t ua.executeHandler(entity, app, selectedTabContent, false, actionContext);\n\t\t} else {\n\t\t if (entity != null) {\n\t\t\tentity.getState().setCurrentTabAction(ua);\n\t\t\tentity.getState().setCurrentTabActionContainer(selectedTabContent);\n\t\t\tentity.getState().setCurrentActionsPath(ua.getFullActionPath());\n\t\t\tactionContext.getWindow().setFragmentToEntity(entity);\n\t\t }\n\t\t ua.executeHandler(entity, app, selectedTabContent, false, actionContext);\n\t\t}\n\t }\n\t});\n\tMap<String, ComponentContainer> actionPathContainers = new HashMap<String, ComponentContainer>();\n\tList<UserAction> actionsList = new ArrayList<UserAction>(ual.getActions().values());\n\tfor (UserAction cua : actionsList) {\n\t if(!cua.isVisible(actionContext)) {\n\t\tcontinue;\n\t }\n\t CssLayout tabContent = new CssLayout();\n\t if (cua instanceof UserActionList) {\n\t } else {\n\t\ttabContent.setMargin(true);\n\t }\n\t tabContent.addStyleName(OpenGroupsStyles.USER_ACTION_CONTENT_PANE);\n\t actionPathContainers.put(cua.getActionName(), tabContent);\n\t tabContent.setData(cua);\n\t actionsTabSheet.addTab(tabContent, cua.getDisplayName(), null);\n\t}\n\tdisplayArea.addComponent(actionsTabSheet);\n\tif (entity != null) {\n\t Deque<String> desiredActionsQueue = entity.getState().getDesiredActionTabsQueue();\n\t if (desiredActionsQueue.size() != 0) {\n\t\tactionsTabSheet.setSelectedTab(actionPathContainers.get(desiredActionsQueue.peek()));\n\t }\n\t}\n }\n"} {"input": " public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {\n final Switchboard sb = (Switchboard) env;\n final serverObjects prop = new serverObjects();\n String table = (post == null) ? null : post.get(\"table\", null);\n if (table != null && !sb.tables.hasHeap(table)) table = null;\n prop.put(\"showtable\", 0);\n if (table == null) return prop;\n boolean showpk = post.containsKey(\"pk\");\n String selectKey = post.containsKey(\"selectKey\") ? post.get(\"selectKey\") : null;\n String selectValue = (selectKey != null && post.containsKey(\"selectValue\")) ? post.get(\"selectValue\") : null;\n ArrayList<String> columns = null;\n try {\n columns = sb.tables.columns(table);\n } catch (IOException e) {\n Log.logException(e);\n columns = new ArrayList<String>();\n }\n String[] row = post.get(\"row\", \"\").split(\",\");\n for (int i = 0; i < row.length; i++) {\n if (columns.contains(row[i])) {\n columns.remove(row[i]);\n if (i < columns.size()) columns.add(i, row[i]);\n }\n }\n prop.put(\"showtable\", 1);\n prop.put(\"showtable_table\", table);\n prop.put(\"showtable_showpk\", showpk ? 1 : 0);\n for (int i = 0; i < columns.size(); i++) {\n prop.putHTML(\"showtable_columns_\" + i + \"_header\", columns.get(i));\n }\n prop.put(\"showtable_columns\", columns.size());\n int maxCount;\n try {\n maxCount = Math.min(1000, sb.tables.size(table));\n } catch (IOException e) {\n Log.logException(e);\n maxCount = 0;\n }\n int count = 0;\n try {\n final Iterator<Tables.Row> plainIterator = sb.tables.iterator(table);\n final Iterator<Tables.Row> mapIterator = sb.tables.orderByPK(plainIterator, maxCount).iterator();\n Tables.Row trow;\n boolean dark = true;\n String cellName, cellValue;\n rowloop: while ((mapIterator.hasNext()) && (count < maxCount)) {\n trow = mapIterator.next();\n if (row == null) continue;\n prop.put(\"showtable_list_\" + count + \"_dark\", ((dark) ? 1 : 0) ); dark=!dark;\n prop.put(\"showtable_list_\" + count + \"_showpk\", showpk ? 1 : 0);\n prop.put(\"showtable_list_\" + count + \"_showpk_pk\", new String(trow.getPK()));\n prop.put(\"showtable_list_\" + count + \"_count\", count);\n for (int i = 0; i < columns.size(); i++) {\n cellName = columns.get(i);\n cellValue = new String(trow.get(cellName));\n if (selectKey != null && cellName.equals(selectKey) && !cellValue.matches(selectValue)) {\n continue rowloop;\n }\n prop.putHTML(\"showtable_list_\" + count + \"_columns_\" + i + \"_column\", cellName);\n prop.putHTML(\"showtable_list_\" + count + \"_columns_\" + i + \"_cell\", cellValue);\n }\n prop.put(\"showtable_list_\" + count + \"_columns\", columns.size());\n count++;\n }\n } catch (IOException e) {\n Log.logException(e);\n }\n prop.put(\"showtable_list\", count);\n prop.put(\"showtable_num\", count);\n return prop;\n }\n", "output": " public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {\n final Switchboard sb = (Switchboard) env;\n final serverObjects prop = new serverObjects();\n String table = (post == null) ? null : post.get(\"table\", null);\n if (table != null && !sb.tables.hasHeap(table)) table = null;\n prop.put(\"showtable\", 0);\n if (table == null) return prop;\n boolean showpk = post.containsKey(\"pk\");\n String selectKey = post.containsKey(\"selectKey\") ? post.get(\"selectKey\") : null;\n String selectValue = (selectKey != null && post.containsKey(\"selectValue\")) ? post.get(\"selectValue\") : null;\n ArrayList<String> columns = null;\n try {\n columns = sb.tables.columns(table);\n } catch (IOException e) {\n Log.logException(e);\n columns = new ArrayList<String>();\n }\n String[] row = post.get(\"row\", \"\").split(\",\");\n for (int i = 0; i < row.length; i++) {\n if (columns.contains(row[i])) {\n columns.remove(row[i]);\n if (i < columns.size()) columns.add(i, row[i]);\n }\n }\n prop.put(\"showtable\", 1);\n prop.put(\"showtable_table\", table);\n prop.put(\"showtable_showpk\", showpk ? 1 : 0);\n for (int i = 0; i < columns.size(); i++) {\n prop.putHTML(\"showtable_columns_\" + i + \"_header\", columns.get(i));\n }\n prop.put(\"showtable_columns\", columns.size());\n int maxCount;\n try {\n maxCount = Math.min(1000, sb.tables.size(table));\n } catch (IOException e) {\n Log.logException(e);\n maxCount = 0;\n }\n int count = 0;\n try {\n final Iterator<Tables.Row> plainIterator = sb.tables.iterator(table);\n final Iterator<Tables.Row> mapIterator = sb.tables.orderByPK(plainIterator, maxCount).iterator();\n Tables.Row trow;\n boolean dark = true;\n String cellName, cellValue;\n rowloop: while ((mapIterator.hasNext()) && (count < maxCount)) {\n trow = mapIterator.next();\n if (row == null) continue;\n prop.put(\"showtable_list_\" + count + \"_dark\", ((dark) ? 1 : 0) ); dark=!dark;\n prop.put(\"showtable_list_\" + count + \"_showpk\", showpk ? 1 : 0);\n prop.put(\"showtable_list_\" + count + \"_showpk_pk\", new String(trow.getPK()));\n prop.put(\"showtable_list_\" + count + \"_count\", count);\n for (int i = 0; i < columns.size(); i++) {\n cellName = columns.get(i);\n if (trow.containsKey(cellName)) {\n cellValue = new String(trow.get(cellName));\n if (selectKey != null && cellName.equals(selectKey) && !cellValue.matches(selectValue)) continue rowloop;\n } else {\n cellValue = \"\";\n }\n prop.putHTML(\"showtable_list_\" + count + \"_columns_\" + i + \"_column\", cellName);\n prop.putHTML(\"showtable_list_\" + count + \"_columns_\" + i + \"_cell\", cellValue);\n }\n prop.put(\"showtable_list_\" + count + \"_columns\", columns.size());\n count++;\n }\n } catch (IOException e) {\n Log.logException(e);\n }\n prop.put(\"showtable_list\", count);\n prop.put(\"showtable_num\", count);\n return prop;\n }\n"} {"input": "\tpublic Bitmap doInBackground(Object... params) {\n\t\tlistener = (KKImageRequestListener) params[0];\n\t\tBitmap bitmap;\n\t\ttry {\n\t\t\tint readLength;\n\t\t\tcachePath = KKImageManager.getTempImagePath(context, url);\n\t\t\tFile cacheFile = new File(cachePath);\n\t\t\tFile localFile = null;\n\t\t\tString tempFilePath = context.getCacheDir().getAbsolutePath() + File.separator + \"image\" + File.separator + hashCode();\n\t\t\tif (localPath != null) {\n\t\t\t\tlocalFile = new File(localPath);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (cacheFile.exists()) {\n\t\t\t\t\tif (actionType == KKImageManager.ActionType.DOWNLOAD) {\n\t\t\t\t\t\tif (localFile == null || !localFile.exists()) {\n\t\t\t\t\t\t\tcryptToFile(cachePath, localPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbitmap = decodeBitmap(cachePath);\n\t\t\t\t\t\tif (bitmap != null) {\n\t\t\t\t\t\t\tif (localPath != null && saveToLocal && (localFile == null || !localFile.exists())) {\n\t\t\t\t\t\t\t\tcryptToFile(cachePath, localPath);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn bitmap;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremoveCacheFile();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (localFile != null && localFile.exists()) {\n\t\t\t\t\tif (actionType == KKImageManager.ActionType.DOWNLOAD) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcryptToFile(localPath, tempFilePath);\n\t\t\t\t\t\tmoveFileTo(tempFilePath, cachePath);\n\t\t\t\t\t\tbitmap = decodeBitmap(cachePath);\n\t\t\t\t\t\tif (bitmap != null) {\n\t\t\t\t\t\t\treturn bitmap;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremoveCacheFile();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (Exception e) {}\n\t\t\tfinal HttpGet httpget = new HttpGet(url);\n\t\t\tresponse = httpclient.execute(httpget);\n\t\t\tfinal InputStream is = response.getEntity().getContent();\n\t\t\tpublishProgress(response.getAllHeaders());\n\t\t\tremoveCacheFile();\n\t\t\tif (actionType == KKImageManager.ActionType.DOWNLOAD) {\n\t\t\t\tRandomAccessFile tempFile = new RandomAccessFile(tempFilePath, \"rw\");\n\t\t\t\twhile ((readLength = is.read(buffer, 0, buffer.length)) != -1) {\n\t\t\t\t\tif (cipher != null) {\n\t\t\t\t\t\tbuffer = cipher.doFinal(buffer);\n\t\t\t\t\t}\n\t\t\t\t\ttempFile.write(buffer, 0, readLength);\n\t\t\t\t}\n\t\t\t\ttempFile.close();\n\t\t\t\tmoveFileTo(tempFilePath, localPath);\n\t\t\t\treturn null;\n\t\t\t} else {\n\t\t\t\tRandomAccessFile tempFile;\n\t\t\t\ttry {\n\t\t\t\t\ttempFile = new RandomAccessFile(tempFilePath, \"rw\");\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\treturn BitmapFactory.decodeStream(is);\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\twhile ((readLength = is.read(buffer, 0, buffer.length)) != -1) {\n\t\t\t\t\t\ttempFile.write(buffer, 0, readLength);\n\t\t\t\t\t}\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\ttempFile.close();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\ttempFile.close();\n\t\t\t\tmoveFileTo(tempFilePath, cachePath);\n\t\t\t\tbitmap = decodeBitmap(cachePath);\n\t\t\t\tif (bitmap != null) {\n\t\t\t\t\tif (saveToLocal && localPath != null) {\n\t\t\t\t\t\tcryptToFile(cachePath, localPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn bitmap;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (final Exception e) {\n\t\t\tisNetworkError = true;\n\t\t\tremoveInvalidImageFiles();\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tpublic Bitmap doInBackground(Object... params) {\n\t\tlistener = (KKImageRequestListener) params[0];\n\t\tBitmap bitmap;\n\t\ttry {\n\t\t\tint readLength;\n\t\t\tcachePath = KKImageManager.getTempImagePath(context, url);\n\t\t\tFile cacheFile = new File(cachePath);\n\t\t\tFile localFile = null;\n\t\t\tString tempFilePath = context.getCacheDir().getAbsolutePath() + File.separator + \"image\" + File.separator + hashCode();\n\t\t\tif (localPath != null) {\n\t\t\t\tlocalFile = new File(localPath);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (cacheFile.exists()) {\n\t\t\t\t\tif (actionType == KKImageManager.ActionType.DOWNLOAD) {\n\t\t\t\t\t\tif (localFile == null || !localFile.exists()) {\n\t\t\t\t\t\t\tcryptToFile(cachePath, localPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbitmap = decodeBitmap(cachePath);\n\t\t\t\t\t\tif (bitmap != null) {\n\t\t\t\t\t\t\tif (localPath != null && saveToLocal && (localFile == null || !localFile.exists())) {\n\t\t\t\t\t\t\t\tcryptToFile(cachePath, localPath);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn bitmap;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremoveCacheFile();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (localFile != null && localFile.exists()) {\n\t\t\t\t\tif (actionType == KKImageManager.ActionType.DOWNLOAD) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcryptToFile(localPath, tempFilePath);\n\t\t\t\t\t\tmoveFileTo(tempFilePath, cachePath);\n\t\t\t\t\t\tbitmap = decodeBitmap(cachePath);\n\t\t\t\t\t\tif (bitmap != null) {\n\t\t\t\t\t\t\treturn bitmap;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremoveCacheFile();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (Exception e) {}\n\t\t\tfinal HttpGet httpget = new HttpGet(url);\n\t\t\tresponse = httpclient.execute(httpget);\n\t\t\tfinal InputStream is = response.getEntity().getContent();\n\t\t\tpublishProgress(response.getAllHeaders());\n\t\t\tremoveInvalidImageFiles();\n\t\t\tif (actionType == KKImageManager.ActionType.DOWNLOAD) {\n\t\t\t\tRandomAccessFile tempFile = new RandomAccessFile(tempFilePath, \"rw\");\n\t\t\t\twhile ((readLength = is.read(buffer, 0, buffer.length)) != -1) {\n\t\t\t\t\tif (cipher != null) {\n\t\t\t\t\t\tbuffer = cipher.doFinal(buffer);\n\t\t\t\t\t}\n\t\t\t\t\ttempFile.write(buffer, 0, readLength);\n\t\t\t\t}\n\t\t\t\ttempFile.close();\n\t\t\t\tmoveFileTo(tempFilePath, localPath);\n\t\t\t\treturn null;\n\t\t\t} else {\n\t\t\t\tRandomAccessFile tempFile;\n\t\t\t\ttry {\n\t\t\t\t\ttempFile = new RandomAccessFile(tempFilePath, \"rw\");\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\treturn BitmapFactory.decodeStream(is);\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\twhile ((readLength = is.read(buffer, 0, buffer.length)) != -1) {\n\t\t\t\t\t\ttempFile.write(buffer, 0, readLength);\n\t\t\t\t\t}\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\ttempFile.close();\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\ttempFile.close();\n\t\t\t\tmoveFileTo(tempFilePath, cachePath);\n\t\t\t\tbitmap = decodeBitmap(cachePath);\n\t\t\t\tif (bitmap != null) {\n\t\t\t\t\tif (saveToLocal && localPath != null) {\n\t\t\t\t\t\tcryptToFile(cachePath, localPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn bitmap;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (final Exception e) {\n\t\t\tisNetworkError = true;\n\t\t\tremoveInvalidImageFiles();\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": "\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t if (convertView == null) {\n\t TextView tv = new TextView(mContext);\n tv.setText(people.get(position));\n tv.setHeight(100); \n tv.setWidth(100);\n tv.setGravity(android.view.Gravity.CENTER);\n return tv;\n\t } else {\n\t return (TextView) convertView;\n\t }\n\t}\n", "output": "\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t if (convertView == null) {\n\t TextView tv = new TextView(mContext);\n\t tv.setText(people.get(position));\n\t tv.setHeight(100); \n\t tv.setWidth(100);\n\t tv.setGravity(android.view.Gravity.CENTER);\n\t return tv;\n\t } else {\n\t return (TextView) convertView;\n\t }\n\t}\n"} {"input": " private void checkAllowance() throws Exception {\n\t\tallowanceChecked = true;\n\t\tif (mode==null || (!mode.equalsIgnoreCase(\"add\") &&\n\t\t\t\t\t\t !mode.equalsIgnoreCase(\"edit\") &&\n\t\t\t\t\t\t !mode.equalsIgnoreCase(\"delete\")) &&\n\t\t\t\t\t\t !mode.equalsIgnoreCase(\"edit_positions\"))\n\t\t\tthrow new Exception(\"FixedValuesHandler mode unspecified!\");\n\t\tif (ownerID == null && !mode.equals(\"delete\"))\n\t\t\tthrow new Exception(\"FixedValuesHandler delem_id unspecified!\");\n\t\tif (ownerType.equals(\"CH1\") || ownerType.equals(\"CH2\"))\n\t\t\townerType = \"elem\";\n\t\tif (!ownerType.equals(\"elem\") && !ownerType.equals(\"attr\"))\n\t\t\tthrow new Exception(\"FixedValuesHandler: unknown parent type!\");\n\t\tif (!ownerType.equals(\"elem\"))\n\t\t\treturn;\n\t\tDDSearchEngine eng = new DDSearchEngine(conn);\n\t\tDataElement elm = eng.getDataElement(ownerID);\n\t\tString dtype = elm==null ? \"\" :\n\t\t\t\t\t\t\t\t elm.getAttributeValueByShortName(\"Datatype\");\n\t\tdtype = dtype==null ? \"\" : dtype.toUpperCase();\n\t\tif (prhbDatatypes.contains(dtype.toUpperCase()))\n\t\t\tallowed = false;\n }\n", "output": " private void checkAllowance() throws Exception {\n\t\tallowanceChecked = true;\n\t\tif (mode==null || (!mode.equalsIgnoreCase(\"add\") &&\n\t\t\t\t\t\t !mode.equalsIgnoreCase(\"edit\") &&\n\t\t\t\t\t\t !mode.equalsIgnoreCase(\"delete\")) &&\n\t\t\t\t\t\t !mode.equalsIgnoreCase(\"edit_positions\"))\n\t\t\tthrow new Exception(\"FixedValuesHandler mode unspecified!\");\n\t\tif (ownerID == null && !mode.equals(\"delete\"))\n\t\t\tthrow new Exception(\"FixedValuesHandler delem_id unspecified!\");\n\t\tif (ownerType.equals(\"CH1\") || ownerType.equals(\"CH2\"))\n\t\t\townerType = \"elem\";\n\t\tif (!ownerType.equals(\"elem\") && !ownerType.equals(\"attr\"))\n\t\t\tthrow new Exception(\"FixedValuesHandler: unknown parent type!\");\n\t\tif (!ownerType.equals(\"elem\"))\n\t\t\treturn;\n\t\tDDSearchEngine eng = new DDSearchEngine(conn);\n\t\tDataElement elm = eng.getDataElement(ownerID);\n\t\tString dtype = elm==null ? \"\" :\n\t\t\t\t\t\t\t\t elm.getAttributeValueByShortName(\"Datatype\");\n\t\tdtype = dtype==null ? \"\" : dtype.toUpperCase();\n\t\tif (prhbDatatypes.contains(dtype.toUpperCase()) && !mode.equalsIgnoreCase(\"edit\"))\n\t\t\tallowed = false;\n }\n"} {"input": " public void dispatch(CommandSender sender, String[] args) {\n if (args.length == 3) {\n String bot = args[1];\n String nick = args[2];\n if (plugin.ircBots.containsKey(bot)) {\n if (plugin.ircBots.containsKey(nick)) {\n sender.sendMessage(ChatColor.RED + \"There is already a bot with that nick!\");\n } else {\n plugin.ircBots.get(bot).changeNick(sender, nick);\n PurpleBot ircBot = plugin.ircBots.remove(bot);\n plugin.ircBots.put(nick, ircBot);\n boolean isConnected = plugin.botConnected.remove(bot);\n plugin.botConnected.put(nick, isConnected);\n }\n } else {\n sender.sendMessage(plugin.invalidBotName.replace(\"%BOT%\", bot));\n }\n } else {\n sender.sendMessage(ChatColor.WHITE + \"Usage: \" + ChatColor.GOLD + \"/irc nick [bot] [nick]\");\n }\n }\n", "output": " public void dispatch(CommandSender sender, String[] args) {\n if (args.length == 3) {\n String bot = args[1];\n String nick = args[2];\n if (plugin.ircBots.containsKey(bot)) {\n if (plugin.ircBots.containsKey(nick)) {\n sender.sendMessage(ChatColor.RED + \"There is already a bot with that nick!\");\n } else {\n plugin.ircBots.get(bot).changeNick(sender, nick);\n PurpleBot ircBot = plugin.ircBots.remove(bot);\n plugin.ircBots.put(nick, ircBot);\n boolean isConnected = plugin.botConnected.remove(bot);\n plugin.botConnected.put(nick, isConnected);\n plugin.ircBots.get(bot).botNick = nick;\n }\n } else {\n sender.sendMessage(plugin.invalidBotName.replace(\"%BOT%\", bot));\n }\n } else {\n sender.sendMessage(ChatColor.WHITE + \"Usage: \" + ChatColor.GOLD + \"/irc nick [bot] [nick]\");\n }\n }\n"} {"input": " public static void main(String[] args) {\n PrintStream out = System.out;\n out.printf(\"%s%n\", \"Hello World\");\n Calendar today = Calendar.getInstance();\n out.printf(\"Today's date is: %tm/%td/%tY%n\", today, today, today);\n out.printf(\"The current time is: %tl:%tM %tP%n\", today, today, today);\n out.printf(\"%f/%.2f = %f%n\", 2.0, 3.0, (2.0/3.0));\n for (int i = 0; i < 3; i++) {\n out.printf(\"%5s%5s%5s%n\", i, i+1, i+2);\n }\n out.printf(\"%-10s%s%n\", \"left\", \"right\");\n }\n", "output": " public static void main(String[] args) {\n PrintStream out = System.out;\n out.printf(\"%s%n\", \"Hello World\");\n Calendar today = Calendar.getInstance();\n out.printf(\"Today's date is: %tm/%td/%tY%n\", today, today, today);\n out.printf(\"The current time is: %tl:%tM %tp%n\", today, today, today);\n out.printf(\"%f/%.2f = %f%n\", 2.0, 3.0, (2.0/3.0));\n for (int i = 0; i < 3; i++) {\n out.printf(\"%5s%5s%5s%n\", i, i+1, i+2);\n }\n out.printf(\"%-10s%s%n\", \"left\", \"right\");\n }\n"} {"input": " public LdapContext getLdapContext(String username, String password) throws NamingException {\n if (searchBase == null) {\n throw new IllegalStateException(\"A search base must be specified.\");\n }\n if (url == null) {\n throw new IllegalStateException(\"An LDAP URL must be specified of the form ldap://<hostname>:<port>\");\n }\n if (principalSuffix != null) {\n username += principalSuffix;\n }\n Hashtable<String, String> env = new Hashtable<String, String>();\n env.put(Context.SECURITY_AUTHENTICATION, authentication);\n env.put(Context.SECURITY_PRINCIPAL, username);\n env.put(Context.SECURITY_CREDENTIALS, password);\n env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactoryClassName);\n env.put(Context.PROVIDER_URL, url);\n env.put(Context.REFERRAL, referral);\n if (usePooling && username.equals(systemUsername)) {\n env.put(SUN_CONNECTION_POOLING_PROPERTY, \"true\");\n }\n if (additionalEnvironment != null) {\n env.putAll(additionalEnvironment);\n }\n if (log.isDebugEnabled()) {\n log.debug(\"Initializing LDAP context using URL [\" + url + \"] and username [\" + systemUsername + \"] \" +\n \"with pooling [\" + (usePooling ? \"enabled\" : \"disabled\") + \"]\");\n }\n return new InitialLdapContext(env, null);\n }\n", "output": " public LdapContext getLdapContext(String username, String password) throws NamingException {\n if (searchBase == null) {\n throw new IllegalStateException(\"A search base must be specified.\");\n }\n if (url == null) {\n throw new IllegalStateException(\"An LDAP URL must be specified of the form ldap://<hostname>:<port>\");\n }\n if (username != null && principalSuffix != null) {\n username += principalSuffix;\n }\n Hashtable<String, String> env = new Hashtable<String, String>();\n env.put(Context.SECURITY_AUTHENTICATION, authentication);\n if (username != null) {\n env.put(Context.SECURITY_PRINCIPAL, username);\n }\n if (password != null) {\n env.put(Context.SECURITY_CREDENTIALS, password);\n }\n env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactoryClassName);\n env.put(Context.PROVIDER_URL, url);\n env.put(Context.REFERRAL, referral);\n if (usePooling && username.equals(systemUsername)) {\n env.put(SUN_CONNECTION_POOLING_PROPERTY, \"true\");\n }\n if (additionalEnvironment != null) {\n env.putAll(additionalEnvironment);\n }\n if (log.isDebugEnabled()) {\n log.debug(\"Initializing LDAP context using URL [\" + url + \"] and username [\" + systemUsername + \"] \" +\n \"with pooling [\" + (usePooling ? \"enabled\" : \"disabled\") + \"]\");\n }\n return new InitialLdapContext(env, null);\n }\n"} {"input": " DiameterMessage createS6aMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws InternalException {\n boolean creatingRequest = diameterHeader == null;\n Message msg = null;\n if (!creatingRequest) {\n Message raw = createMessage(diameterHeader, avps, 0, appId);\n raw.setProxiable(diameterHeader.isProxiable());\n raw.setRequest(false);\n raw.getAvps().removeAvp(Avp.AUTH_APPLICATION_ID);\n msg = raw;\n }\n else {\n Message raw = createMessage(diameterHeader, avps, _commandCode, appId);\n raw.setProxiable(true);\n raw.setRequest(true);\n msg = raw;\n }\n if (msg.getAvps().getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) {\n try {\n DiameterAvp avpVendorId = this.baseAvpFactory.createAvp(Avp.VENDOR_ID, _S6A_VENDOR);\n DiameterAvp avpAuthApplicationId = this.baseAvpFactory.createAvp(Avp.AUTH_APPLICATION_ID, _S6A_AUTH_APP_ID);\n DiameterAvp vendorSpecific = this.baseAvpFactory.createAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, new DiameterAvp[]{avpVendorId, avpAuthApplicationId});\n msg.getAvps().addAvp(vendorSpecific.getCode(), vendorSpecific.byteArrayValue());\n }\n catch (NoSuchAvpException nsae) {\n logger.error(\"Failed to create AVPs\", nsae);\n }\n }\n int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();\n DiameterMessage diamMessage = null;\n switch (commandCode) {\n case UpdateLocationRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new UpdateLocationRequestImpl(msg) : new UpdateLocationAnswerImpl(msg);\n break;\n case AuthenticationInformationRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new AuthenticationInformationRequestImpl(msg) : new AuthenticationInformationAnswerImpl(msg);\n break;\n case CancelLocationRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new CancelLocationRequestImpl(msg) : new CancelLocationAnswerImpl(msg);\n break;\n case InsertSubscriberDataRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new InsertSubscriberDataRequestImpl(msg) : new InsertSubscriberDataAnswerImpl(msg);\n break;\n case DeleteSubscriberDataRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new DeleteSubscriberDataRequestImpl(msg) : new DeleteSubscriberDataAnswerImpl(msg);\n break;\n case PurgeUERequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new PurgeUERequestImpl(msg) : new PurgeUEAnswerImpl(msg);\n break;\n case ResetRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new ResetRequestImpl(msg) : new ResetAnswerImpl(msg);\n break;\n case NotifyRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new NotifyRequestImpl(msg) : new NotifyAnswerImpl(msg);\n break;\n default:\n diamMessage = new ExtensionDiameterMessageImpl(msg);\n }\n if (!diamMessage.hasSessionId() && session != null) {\n diamMessage.setSessionId(session.getSessionId());\n }\n return diamMessage;\n }\n", "output": " DiameterMessage createS6aMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws InternalException {\n boolean creatingRequest = diameterHeader == null;\n Message msg = null;\n if (!creatingRequest) {\n Message raw = createMessage(diameterHeader, avps, 0, appId);\n raw.setProxiable(diameterHeader.isProxiable());\n raw.setRequest(false);\n raw.setReTransmitted(false); \n raw.getAvps().removeAvp(Avp.AUTH_APPLICATION_ID);\n msg = raw;\n }\n else {\n Message raw = createMessage(diameterHeader, avps, _commandCode, appId);\n raw.setProxiable(true);\n raw.setRequest(true);\n msg = raw;\n }\n if (msg.getAvps().getAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID) == null) {\n try {\n DiameterAvp avpVendorId = this.baseAvpFactory.createAvp(Avp.VENDOR_ID, _S6A_VENDOR);\n DiameterAvp avpAuthApplicationId = this.baseAvpFactory.createAvp(Avp.AUTH_APPLICATION_ID, _S6A_AUTH_APP_ID);\n DiameterAvp vendorSpecific = this.baseAvpFactory.createAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID, new DiameterAvp[]{avpVendorId, avpAuthApplicationId});\n msg.getAvps().addAvp(vendorSpecific.getCode(), vendorSpecific.byteArrayValue());\n }\n catch (NoSuchAvpException nsae) {\n logger.error(\"Failed to create AVPs\", nsae);\n }\n }\n int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();\n DiameterMessage diamMessage = null;\n switch (commandCode) {\n case UpdateLocationRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new UpdateLocationRequestImpl(msg) : new UpdateLocationAnswerImpl(msg);\n break;\n case AuthenticationInformationRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new AuthenticationInformationRequestImpl(msg) : new AuthenticationInformationAnswerImpl(msg);\n break;\n case CancelLocationRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new CancelLocationRequestImpl(msg) : new CancelLocationAnswerImpl(msg);\n break;\n case InsertSubscriberDataRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new InsertSubscriberDataRequestImpl(msg) : new InsertSubscriberDataAnswerImpl(msg);\n break;\n case DeleteSubscriberDataRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new DeleteSubscriberDataRequestImpl(msg) : new DeleteSubscriberDataAnswerImpl(msg);\n break;\n case PurgeUERequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new PurgeUERequestImpl(msg) : new PurgeUEAnswerImpl(msg);\n break;\n case ResetRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new ResetRequestImpl(msg) : new ResetAnswerImpl(msg);\n break;\n case NotifyRequest.COMMAND_CODE:\n diamMessage = creatingRequest ? new NotifyRequestImpl(msg) : new NotifyAnswerImpl(msg);\n break;\n default:\n diamMessage = new ExtensionDiameterMessageImpl(msg);\n }\n if (!diamMessage.hasSessionId() && session != null) {\n diamMessage.setSessionId(session.getSessionId());\n }\n return diamMessage;\n }\n"} {"input": " public List<Badge> checkNewBadge(User user)\n {\n ArrayList<Badge> list= new ArrayList<Badge>();\n List<Integer> oldBadges = user.getBadges();\n List<Integer> newBadges = new ArrayList<Integer>();\n newBadges.addAll(oldBadges);\n List<Drink> myDrinks = DaoFactory.getInstance().getDrinkDao().findDrinksByIdUser(user.getIdUser(), null);\n if(!oldBadges.contains(BadgeEnum.DRINK_NUM_100.getIdBadge())) \n {\n log.info(\"verifica numero bevute complessive\");\n int countDrinksByUsername = myDrinks.size();\n if (!oldBadges.contains(BadgeEnum.DRINK_NUM_1.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_5.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_10.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_10);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_50.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_50.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_50);\n } else if ( countDrinksByUsername == BadgeEnum.DRINK_NUM_100.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_100);\n }\n } \n if(!oldBadges.contains(BadgeEnum.DRINKER_PUB_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in pub: \");\n int count=0;\n for(Drink d: myDrinks)\n {\n log.info(\"-- in pub: \"+d.getIdPlace());\n Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());\n if(l.getCategories().contains(LocationCategoryDao.ID_PUB))\n {\n count++;\n }\n }\n if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_1.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_3.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_5.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_10.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_10);\n } else if (count == BadgeEnum.DRINKER_PUB_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in pzzeria\");\n int count=0;\n for(Drink d: myDrinks)\n {\n Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());\n if(l.getCategories().contains(LocationCategoryDao.ID_PIZZA))\n {\n count++;\n }\n }\n if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_1.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_3.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_5.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_10.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_10);\n } else if (count == BadgeEnum.DRINKER_PIZZA_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_RISTO_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in ristorante\");\n String name=\"Restaurant\";\n int count=0;\n count = countDrinkWithLocationCategoryNameLike(myDrinks, name);\n if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_1.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_3.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_5.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_10.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_10);\n } else if (count == BadgeEnum.DRINKER_RISTO_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_BAR_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in bar\");\n String name=\"Bar\";\n int count=0;\n count = countDrinkWithLocationCategoryNameLike(myDrinks, name);\n if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_1.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_3.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_5.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_10.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_10);\n } else if (count == BadgeEnum.DRINKER_BAR_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_HOME_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute a casa\");\n int count=0;\n for(Drink d: myDrinks)\n {\n Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());\n if(l.getCategories().contains(LocationCategoryDao.ID_HOME))\n {\n count++;\n }\n }\n if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_1.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_3.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_5.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_10.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_10);\n } else if ( count == BadgeEnum.DRINKER_HOME_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_SPORT_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in stadio\");\n String name=\"Stadium\";\n int count=0;\n count = countDrinkWithLocationCategoryNameLike(myDrinks, name);\n if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_1.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_3.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_5.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_10.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_10);\n } else if (count == BadgeEnum.DRINKER_SPORT_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_25);\n }\n }\n Calendar now = Calendar.getInstance();\n int h=now.get(Calendar.HOUR_OF_DAY);\n int m=now.get(Calendar.MINUTE);\n if(h>20 || h<6)\n {\n log.info(\"verifica numero bevute nella notte\");\n Date startLimit=null;\n Date endLimit=null;\n if(h>20)\n {\n Calendar today20 = Calendar.getInstance();\n today20.set(Calendar.HOUR_OF_DAY, 20);\n today20.set(Calendar.MINUTE, 0);\n today20.set(Calendar.MILLISECOND, 0);\n Calendar today6 =Calendar.getInstance();\n today6.set(Calendar.HOUR_OF_DAY, 6);\n today6.set(Calendar.MINUTE, 0);\n today6.set(Calendar.MILLISECOND, 0);\n today6.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)+1);\n startLimit=today20.getTime();\n endLimit=today6.getTime();\n }\n else if(h<6)\n {\n Calendar today20 = Calendar.getInstance();\n today20.set(Calendar.HOUR_OF_DAY, 20);\n today20.set(Calendar.MINUTE, 0);\n today20.set(Calendar.MILLISECOND, 0);\n Calendar today6 =Calendar.getInstance();\n today6.set(Calendar.HOUR_OF_DAY, 6);\n today6.set(Calendar.MINUTE, 0);\n today6.set(Calendar.MILLISECOND, 0);\n today20.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)-1);\n startLimit=today20.getTime();\n endLimit=today6.getTime();\n }\n else\n {\n log.error(\"vicolo cieco PUPPA!!\");\n }\n int count=0;\n for(Drink d : myDrinks)\n {\n if(d.getInsertedOn().after(startLimit) && d.getInsertedOn().before(endLimit))\n {\n count++; \n }\n }\n log.info(\"numero bevute di \"+user.getUsername()+\":\"+count);\n if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_2.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_2.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_2);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_3.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_4.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_4.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_4);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_5.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_5);\n } else if (count == BadgeEnum.DRINK_NIGHT_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_10);\n }\n }\n user.setBadges(newBadges);\n user.setCounterBadges(newBadges.size());\n DaoFactory.getInstance().getUserDao().updateUser(user);\n return list;\n }\n", "output": " public List<Badge> checkNewBadge(User user)\n {\n ArrayList<Badge> list= new ArrayList<Badge>();\n List<Integer> oldBadges = user.getBadges();\n List<Integer> newBadges = new ArrayList<Integer>();\n newBadges.addAll(oldBadges);\n List<Drink> myDrinks = DaoFactory.getInstance().getDrinkDao().findDrinksByIdUser(user.getIdUser(), null);\n if(!oldBadges.contains(BadgeEnum.DRINK_NUM_100.getIdBadge())) \n {\n log.info(\"verifica numero bevute complessive\");\n int countDrinksByUsername = myDrinks.size();\n if (!oldBadges.contains(BadgeEnum.DRINK_NUM_1.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_5.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_10.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_10);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_50.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_50.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_50);\n } else if ( countDrinksByUsername == BadgeEnum.DRINK_NUM_100.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_100);\n }\n } \n if(!oldBadges.contains(BadgeEnum.DRINKER_PUB_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in pub: \");\n int count=0;\n for(Drink d: myDrinks)\n {\n log.info(\"-- in pub: \"+d.getIdPlace());\n Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());\n if(l.getCategories().contains(LocationCategoryDao.ID_PUB))\n {\n count++;\n }\n }\n if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_1.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_3.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_5.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_10.getIdBadge()) && count == BadgeEnum.DRINKER_PUB_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_10);\n } else if (count == BadgeEnum.DRINKER_PUB_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in pzzeria\");\n int count=0;\n for(Drink d: myDrinks)\n {\n Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());\n if(l.getCategories().contains(LocationCategoryDao.ID_PIZZA))\n {\n count++;\n }\n }\n if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_1.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_3.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_5.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_10.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_10);\n } else if (count == BadgeEnum.DRINKER_PIZZA_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_RISTO_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in ristorante\");\n String name=\"Restaurant\";\n int count=0;\n count = countDrinkWithLocationCategoryNameLike(myDrinks, name);\n if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_1.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_3.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_5.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_10.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_10);\n } else if (count == BadgeEnum.DRINKER_RISTO_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_BAR_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in bar\");\n String name=\"Bar\";\n int count=0;\n count = countDrinkWithLocationCategoryNameLike(myDrinks, name);\n if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_1.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_3.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_5.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_10.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_10);\n } else if (count == BadgeEnum.DRINKER_BAR_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_HOME_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute a casa\");\n int count=0;\n for(Drink d: myDrinks)\n {\n Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());\n if(l.getCategories().contains(LocationCategoryDao.ID_HOME))\n {\n count++;\n }\n }\n if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_1.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_3.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_5.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_10.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_10);\n } else if ( count == BadgeEnum.DRINKER_HOME_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_25);\n }\n }\n if(!oldBadges.contains(BadgeEnum.DRINKER_SPORT_25.getIdBadge()))\n {\n log.info(\"verifica numero bevute in stadio\");\n String name=\"Stadium\";\n int count=0;\n count = countDrinkWithLocationCategoryNameLike(myDrinks, name);\n if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_1.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_1.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_1);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_3.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_5.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_5);\n } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_10.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_10);\n } else if (count == BadgeEnum.DRINKER_SPORT_25.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_25);\n }\n }\n Calendar now = Calendar.getInstance();\n int h=now.get(Calendar.HOUR_OF_DAY);\n int m=now.get(Calendar.MINUTE);\n if(h>20 || h<6)\n {\n log.info(\"verifica numero bevute nella notte\");\n Date startLimit=null;\n Date endLimit=null;\n if(h>20)\n {\n Calendar today20 = Calendar.getInstance();\n today20.set(Calendar.HOUR_OF_DAY, 20);\n today20.set(Calendar.MINUTE, 0);\n today20.set(Calendar.MILLISECOND, 0);\n Calendar today6 =Calendar.getInstance();\n today6.set(Calendar.HOUR_OF_DAY, 6);\n today6.set(Calendar.MINUTE, 0);\n today6.set(Calendar.MILLISECOND, 0);\n today6.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)+1);\n startLimit=today20.getTime();\n endLimit=today6.getTime();\n }\n else if(h<6)\n {\n Calendar today20 = Calendar.getInstance();\n today20.set(Calendar.HOUR_OF_DAY, 20);\n today20.set(Calendar.MINUTE, 0);\n today20.set(Calendar.MILLISECOND, 0);\n Calendar today6 =Calendar.getInstance();\n today6.set(Calendar.HOUR_OF_DAY, 6);\n today6.set(Calendar.MINUTE, 0);\n today6.set(Calendar.MILLISECOND, 0);\n today20.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)-1);\n startLimit=today20.getTime();\n endLimit=today6.getTime();\n }\n else\n {\n log.error(\"vicolo cieco PUPPA!!\");\n }\n int count=0;\n for(Drink d : myDrinks)\n {\n if(d.getInsertedOn().after(startLimit) && d.getInsertedOn().before(endLimit))\n {\n count++; \n }\n }\n log.info(\"numero bevute di \"+user.getUsername()+\":\"+count);\n if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_2.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_2.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_2);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_3.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_3.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_3);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_4.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_4.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_4);\n } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_5.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_5.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_5);\n } else if (count == BadgeEnum.DRINK_NIGHT_10.getQuantity()) {\n updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_10);\n }\n }\n user.setBadges(newBadges);\n user.setCounterBadges(newBadges.size());\n DaoFactory.getInstance().getUserDao().updateUser(user);\n return list;\n }\n"} {"input": "\tpublic void run() throws SQLException {\n\t\tWikiConnect wiki = new WikiConnect();\n\t\tList<Sentence> sentences = wiki.getFile(this.docID);\n\t\tAbstractEntityExtractor extractor = new EntityExtractor();\n\t\tList<EntityMention> mentions = extractor.extract(sentences);\n\t\tAbstractSearcher searcher = new BasicSearcher();\n\t\tfor (EntityMention mention : mentions) {\n\t\t\tsearcher.GetCandidateEntities(mention);\n\t\t}\n\t\tAbstractDisambiguator disambiguator = new SimpleDisambiguator();\n\t\tdisambiguator.disambiguate(mentions);\n\t}\n", "output": "\tpublic void run() throws SQLException {\n\t\tSentenceConnect docs = new SentenceConnect();\n\t\tList<Sentence> sentences = docs.getDocument(this.docID);\n\t\tAbstractEntityExtractor extractor = new EntityExtractor();\n\t\tList<EntityMention> mentions = extractor.extract(sentences);\n\t\tAbstractSearcher searcher = new BasicSearcher();\n\t\tfor (EntityMention mention : mentions) {\n\t\t\tsearcher.GetCandidateEntities(mention);\n\t\t}\n\t\tAbstractDisambiguator disambiguator = new SimpleDisambiguator();\n\t\tdisambiguator.disambiguate(mentions);\n\t}\n"} {"input": " public ChainedWorkspaceReader( WorkspaceReader... readers )\n {\n if ( readers != null )\n {\n Collections.addAll( this.readers, readers );\n }\n StringBuilder buffer = new StringBuilder();\n for ( WorkspaceReader reader : readers )\n {\n if ( buffer.length() > 0 )\n {\n buffer.append( '+' );\n }\n buffer.append( reader.getRepository().getContentType() );\n }\n repository = new WorkspaceRepository( buffer.toString(), new Key( this.readers ) );\n }\n", "output": " public ChainedWorkspaceReader( WorkspaceReader... readers )\n {\n if ( readers != null )\n {\n Collections.addAll( this.readers, readers );\n }\n StringBuilder buffer = new StringBuilder();\n for ( WorkspaceReader reader : this.readers )\n {\n if ( buffer.length() > 0 )\n {\n buffer.append( '+' );\n }\n buffer.append( reader.getRepository().getContentType() );\n }\n repository = new WorkspaceRepository( buffer.toString(), new Key( this.readers ) );\n }\n"} {"input": " private boolean isRelevant(Context context, Intent intent) {\n if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) {\n return false;\n }\n if (!ApplicationMigrationService.isDatabaseImported(context)) {\n return false;\n }\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&\n Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) &&\n Util.isDefaultSmsProvider(context))\n {\n return false;\n }\n if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT &&\n PreferenceManager.getDefaultSharedPreferences(context)\n .getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))\n {\n return true;\n }\n byte[] mmsData = intent.getByteArrayExtra(\"data\");\n PduParser parser = new PduParser(mmsData);\n GenericPdu pdu = parser.parse();\n if (pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND)\n return false;\n NotificationInd notificationPdu = (NotificationInd)pdu;\n if (notificationPdu.getSubject() == null)\n return false;\n return WirePrefix.isEncryptedMmsSubject(notificationPdu.getSubject().getString());\n }\n", "output": " private boolean isRelevant(Context context, Intent intent) {\n if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) {\n return false;\n }\n if (!ApplicationMigrationService.isDatabaseImported(context)) {\n return false;\n }\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&\n Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION.equals(intent.getAction()) &&\n Util.isDefaultSmsProvider(context))\n {\n return false;\n }\n if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ||\n PreferenceManager.getDefaultSharedPreferences(context)\n .getBoolean(ApplicationPreferencesActivity.ALL_MMS_PERF, true))\n {\n return true;\n }\n byte[] mmsData = intent.getByteArrayExtra(\"data\");\n PduParser parser = new PduParser(mmsData);\n GenericPdu pdu = parser.parse();\n if (pdu.getMessageType() != PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND)\n return false;\n NotificationInd notificationPdu = (NotificationInd)pdu;\n if (notificationPdu.getSubject() == null)\n return false;\n return WirePrefix.isEncryptedMmsSubject(notificationPdu.getSubject().getString());\n }\n"} {"input": "\tprotected void onDraw(Canvas canvas) {\n\t\tsuper.onDraw(canvas);\n\t\tif (mProgressBounds != null) {\n\t\t\tmProgressBounds.left = mPaddingLeft;\n\t\t\tmProgressBounds.top = mPaddingTop;\n\t\t\tmProgressBounds.right = (int) ((getWidth() - mPaddingRight)\n\t\t\t\t\t* mProgressValue / 100f);\n\t\t\tmProgressBounds.bottom = getHeight() - mPaddingBottom;\n\t\t\tmProgressDrawable.setBounds(mProgressBounds);\n\t\t\tmProgressDrawable.draw(canvas);\n\t\t}\n\t}\n", "output": "\tprotected void onDraw(Canvas canvas) {\n\t\tsuper.onDraw(canvas);\n\t\tif (mProgressBounds != null && mProgressDrawable != null) {\n\t\t\tmProgressBounds.left = mPaddingLeft;\n\t\t\tmProgressBounds.top = mPaddingTop;\n\t\t\tmProgressBounds.right = (int) ((getWidth() - mPaddingRight)\n\t\t\t\t\t* mProgressValue / 100f);\n\t\t\tmProgressBounds.bottom = getHeight() - mPaddingBottom;\n\t\t\tmProgressDrawable.setBounds(mProgressBounds);\n\t\t\tmProgressDrawable.draw(canvas);\n\t\t}\n\t}\n"} {"input": " public void testRegistry() {\n if (!WindowsUtils.thisIsWindows()) return;\n String keyProxyEnable = \"HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Internet Settings\\\\ProxyEnable\";\n String keySeleniumFoo = \"HKEY_CURRENT_USER\\\\Software\\\\Selenium\\\\RemoteControl\\\\foo\";\n assertTrue(\"Standard Windows reg key ProxyEnable doesn't exist\", WindowsUtils.doesRegistryValueExist(keyProxyEnable));\n System.out.println(\"ProxyEnable: \" + WindowsUtils.readIntRegistryValue(keyProxyEnable));\n WindowsUtils.writeStringRegistryValue(keySeleniumFoo, \"bar\");\n assertEquals(\"Didn't set Foo string key correctly\", \"bar\", WindowsUtils.readStringRegistryValue(keySeleniumFoo));\n WindowsUtils.writeStringRegistryValue(keySeleniumFoo, \"baz\");\n assertEquals(\"Didn't modify Foo string key correctly\", \"baz\", WindowsUtils.readStringRegistryValue(keySeleniumFoo));\n WindowsUtils.deleteRegistryValue(keySeleniumFoo);\n assertFalse(\"Didn't delete Foo key correctly\", WindowsUtils.doesRegistryValueExist(keySeleniumFoo));\n WindowsUtils.writeBooleanRegistryValue(keySeleniumFoo, true);\n assertTrue(\"Didn't set Foo boolean key correctly\", WindowsUtils.readBooleanRegistryValue(keySeleniumFoo));\n WindowsUtils.deleteRegistryValue(keySeleniumFoo);\n assertFalse(\"Didn't delete Foo key correctly\", WindowsUtils.doesRegistryValueExist(keySeleniumFoo));\n }\n", "output": " public void testRegistry() {\n if (!WindowsUtils.thisIsWindows()) return;\n String keyProxyEnable = \"HKEY_CURRENT_USER\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Internet Settings\\\\ProxyEnable\";\n String keySeleniumFoo = \"HKEY_CURRENT_USER\\\\Software\\\\Selenium\\\\RemoteControl\\\\foo\";\n assertTrue(\"Standard Windows reg key CurrentVersion doesn't exist\", WindowsUtils.doesRegistryValueExist(keyCurrentVersion));\n System.out.println(\"CurrentVersion: \" + WindowsUtils.readStringRegistryValue(keyCurrentVersion));\n WindowsUtils.writeStringRegistryValue(keySeleniumFoo, \"bar\");\n assertEquals(\"Didn't set Foo string key correctly\", \"bar\", WindowsUtils.readStringRegistryValue(keySeleniumFoo));\n WindowsUtils.writeStringRegistryValue(keySeleniumFoo, \"baz\");\n assertEquals(\"Didn't modify Foo string key correctly\", \"baz\", WindowsUtils.readStringRegistryValue(keySeleniumFoo));\n WindowsUtils.deleteRegistryValue(keySeleniumFoo);\n assertFalse(\"Didn't delete Foo key correctly\", WindowsUtils.doesRegistryValueExist(keySeleniumFoo));\n WindowsUtils.writeBooleanRegistryValue(keySeleniumFoo, true);\n assertTrue(\"Didn't set Foo boolean key correctly\", WindowsUtils.readBooleanRegistryValue(keySeleniumFoo));\n WindowsUtils.deleteRegistryValue(keySeleniumFoo);\n assertFalse(\"Didn't delete Foo key correctly\", WindowsUtils.doesRegistryValueExist(keySeleniumFoo));\n }\n"} {"input": " public InventoryFrame(Player player)\n {\n super(\"Inventory\");\n addWindowFocusListener(this);\n thePlayer = player;\n use = new JButton(\"Use\");\n drop = new JButton(\"Drop\");\n back = new JButton(\"Back\");\n buttons = new JPanel();\n buttons.setBackground(Color.DARK_GRAY);\n bank = new JLabel(\"Money: $\" + thePlayer.getMoney());\n bank.setForeground(Color.GREEN);\n ButtonListener handler = new ButtonListener();\n use.addActionListener(handler);\n drop.addActionListener(handler);\n back.addActionListener(handler);\n buttons.add(use);\n buttons.add(drop);\n buttons.add(back);\n buttons.add(bank);\n itemPanel = new JPanel();\n itemPanel.setBackground(Color.DARK_GRAY);\n descriptionArea = new JTextArea();\n descriptionArea.setPreferredSize(new Dimension(200, 200));\n descriptionArea.setBackground(Color.BLACK);\n descriptionArea.setForeground(Color.GREEN);\n descriptionArea.setWrapStyleWord(true);\n descriptionArea.setLineWrap(true);\n descriptionArea.setEditable(false);\n descriptionArea.setWrapStyleWord(true);\n usableItems = new Vector<Integer>();\n fillUsuable();\n message = new JLabel();\n message.setForeground(Color.GREEN);\n makeInventory();\n inventory = new JList(inventoryList);\n inventory.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\n inventory.setBackground(Color.BLACK);\n inventory.setForeground(Color.GREEN);\n inventory.setSelectionBackground(Color.DARK_GRAY);\n inventory.addListSelectionListener(new ListSelectionListener()\n {\n @Override\n public void valueChanged(ListSelectionEvent arg0)\n {\n descriptionArea.setText(((Item) inventory.getSelectedValue())\n .getDescription());\n }\n });\n scroll = new JScrollPane(inventory);\n scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\n scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);\n itemPanel.add(scroll);\n itemPanel.add(descriptionArea);\n itemPanel.setBackground(Color.DARK_GRAY);\n this.setLayout(new BorderLayout());\n this.add(itemPanel, BorderLayout.CENTER);\n this.add(buttons, BorderLayout.SOUTH);\n this.add(message, BorderLayout.NORTH);\n }\n", "output": " public InventoryFrame(Player player)\n {\n super(\"Inventory\");\n addWindowFocusListener(this);\n thePlayer = player;\n use = new JButton(\"Use\");\n drop = new JButton(\"Drop\");\n back = new JButton(\"Back\");\n buttons = new JPanel();\n buttons.setBackground(Color.DARK_GRAY);\n bank = new JLabel(\"Money: $\" + thePlayer.getMoney());\n bank.setForeground(Color.GREEN);\n ButtonListener handler = new ButtonListener();\n use.addActionListener(handler);\n drop.addActionListener(handler);\n back.addActionListener(handler);\n buttons.add(use);\n buttons.add(drop);\n buttons.add(back);\n buttons.add(bank);\n itemPanel = new JPanel();\n itemPanel.setBackground(Color.DARK_GRAY);\n descriptionArea = new JTextArea();\n descriptionArea.setPreferredSize(new Dimension(200, 200));\n descriptionArea.setBackground(Color.BLACK);\n descriptionArea.setForeground(Color.GREEN);\n descriptionArea.setWrapStyleWord(true);\n descriptionArea.setLineWrap(true);\n descriptionArea.setEditable(false);\n descriptionArea.setWrapStyleWord(true);\n usableItems = new Vector<Integer>();\n fillUsuable();\n message = new JLabel();\n message.setForeground(Color.GREEN);\n makeInventory();\n inventory = new JList(inventoryList);\n inventory.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\n inventory.setBackground(Color.BLACK);\n inventory.setForeground(Color.WHITE);\n inventory.setSelectionBackground(Color.DARK_GRAY);\n inventory.setSelectionForeground(Color.GREEN);\n inventory.addListSelectionListener(new ListSelectionListener()\n {\n @Override\n public void valueChanged(ListSelectionEvent arg0)\n {\n descriptionArea.setText(((Item) inventory.getSelectedValue())\n .getDescription());\n }\n });\n scroll = new JScrollPane(inventory);\n scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\n scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);\n itemPanel.add(scroll);\n itemPanel.add(descriptionArea);\n itemPanel.setBackground(Color.DARK_GRAY);\n this.setLayout(new BorderLayout());\n this.add(itemPanel, BorderLayout.CENTER);\n this.add(buttons, BorderLayout.SOUTH);\n this.add(message, BorderLayout.NORTH);\n }\n"} {"input": " public AnnotatorFrame (TableSettings settings) {\n File resource = new File (RESOURCESFOLDER);\n if (!resource.exists()) {\n resource.mkdir();\n }\n File locations = new File (LOCATIONFILE);\n if (!locations.exists()) {\n try {\n locations.createNewFile();\n } catch (IOException e) {\n e.printStackTrace(); \n }\n }\n tableSettings = settings;\n cache = new ArrayList<CacheData>();\n cacheBu = new ArrayList<CacheData>();\n parser = new KafSaxParser();\n tagLexicon = new Lexicon();\n tagLexicon.parseFile(LEXICONFILE);\n TripleConfig = new TripleConfig(TripleCONFIGFILE);\n theTag1Set = new ArrayList<String>();\n theTag2Set = new ArrayList<String>();\n theTag3Set = new ArrayList<String>();\n theTag4Set = new ArrayList<String>();\n theTag5Set = new ArrayList<String>();\n theTag6Set = new ArrayList<String>();\n theTag7Set = new ArrayList<String>();\n theTag8Set = new ArrayList<String>();\n clipboardTag = \"\";\n clipboardTagId = -1;\n inputName = \"\";\n messagePanel = new JPanel();\n messagePanel.setMinimumSize(new Dimension(400, 320));\n messagePanel.setPreferredSize(new Dimension(400, 320));\n messagePanel.setMaximumSize(new Dimension(400, 320));\n messageLabel = new JLabel(\"Messages:\");\n messageLabel.setMinimumSize(new Dimension(80, 25));\n messageLabel.setPreferredSize(new Dimension(80, 25));\n messageField = new JTextField();\n messageField.setEditable(false);\n messageField.setMinimumSize(new Dimension(300, 25));\n messageField.setPreferredSize(new Dimension(300, 25));\n messageField.setMaximumSize(new Dimension(400, 30));\n fullTextLabel = new JLabel(\"Text:\");\n fullTextLabel.setMinimumSize(new Dimension(80, 25));\n fullTextLabel.setPreferredSize(new Dimension(80, 25));\n fullTextField = new JTextArea();\n fullTextField.setEditable(false);\n fullTextField.setBackground(Colors.BackGroundColor);\n fullTextField.setMinimumSize(new Dimension(300, 200));\n fullTextField.setPreferredSize(new Dimension(300, 200));\n fullTextField.setMaximumSize(new Dimension(400, 200));\n fullTextField.setLineWrap(true);\n fullTextField.setWrapStyleWord(true);\n fullTextField.addMouseListener(new MouseAdapter() {\n public void mousePressed(MouseEvent e) {\n switch(e.getModifiers()) {\n case InputEvent.BUTTON3_MASK: {\n String word = fullTextField.getSelectedText();\n table.searchForString(AnnotationTableModel.ROWWORDTOKEN, word);\n }\n }\n }\n });\n JScrollPane scrollableTextArea = new JScrollPane (fullTextField,\n JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\n scrollableTextArea.setMinimumSize(new Dimension(300, 200));\n scrollableTextArea.setPreferredSize(new Dimension(300, 200));\n scrollableTextArea.setMaximumSize(new Dimension(400, 200));\n kafFileLabel = new JLabel(\"KAF file:\");\n kafFileLabel.setMinimumSize(new Dimension(80, 25));\n kafFileLabel.setPreferredSize(new Dimension(80, 25));\n kafFileField = new JTextField();\n kafFileField.setEditable(false);\n kafFileField.setBackground(Colors.BackGroundColor);\n kafFileField.setMinimumSize(new Dimension(300, 25));\n kafFileField.setPreferredSize(new Dimension(300, 25));\n kafFileField.setMaximumSize(new Dimension(400, 30));\n tagFileLabel = new JLabel(\"TAG file:\");\n tagFileLabel.setMinimumSize(new Dimension(80, 25));\n tagFileLabel.setPreferredSize(new Dimension(80, 25));\n tagFileField = new JTextField();\n tagFileField.setEditable(false);\n tagFileField.setBackground(Colors.BackGroundColor);\n tagFileField.setMinimumSize(new Dimension(300, 25));\n tagFileField.setPreferredSize(new Dimension(300, 25));\n tagFileField.setMaximumSize(new Dimension(400, 30));\n tagSetFileLabel = new JLabel(\"TAG set:\");\n tagSetFileLabel.setMinimumSize(new Dimension(80, 25));\n tagSetFileLabel.setPreferredSize(new Dimension(80, 25));\n tagSetFileField = new JTextField();\n tagSetFileField.setEditable(false);\n tagSetFileField.setBackground(Colors.BackGroundColor);\n tagSetFileField.setMinimumSize(new Dimension(300, 25));\n tagSetFileField.setPreferredSize(new Dimension(300, 25));\n tagSetFileField.setMaximumSize(new Dimension(400, 30));\n messagePanel.setLayout(new GridBagLayout());\n messagePanel.add(fullTextLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0\n ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(scrollableTextArea, new GridBagConstraints(1, 0, 1, 1, 0.3, 0.3\n , GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(messageLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0\n ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(messageField, new GridBagConstraints(1, 1, 1, 1, 0.3, 0.3\n , GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(kafFileLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0\n ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(kafFileField, new GridBagConstraints(1, 2, 1, 1, 0.3, 0.3\n , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagFileLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0\n ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagFileField, new GridBagConstraints(1, 3, 1, 1, 0.3, 0.3\n , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagSetFileLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0\n ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagSetFileField, new GridBagConstraints(1, 4, 1, 1, 0.3, 0.3\n ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));\n menuButtons = new JMenuBar();\n fileMenu = new JMenu(\"File\");\n fileMenu.setMnemonic('f');\n openMenuItem = new JMenuItem(\"Open KAF file\",'o');\n openMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_loadKafFile();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(openMenuItem);\n readTagFileMenuItem = new JMenuItem(\"Load TAG file\",'l');\n readTagFileMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_loadTagFile();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(readTagFileMenuItem);\n readTagSetMenuItem = new JMenuItem(\"Load TAG set\", 't');\n readTagSetMenuItem.setMnemonic('t');\n readTagSetMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_readTagSet();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(readTagSetMenuItem);\n readLexiconMenuItem = new JMenuItem(\"Load lexicon file\", 'x'); \n readLexiconMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_readLexicon();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(readLexiconMenuItem);\n saveTagMenuItem = new JMenuItem(\"Save tagging\",'s');\n saveTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n int ok = -1;\n ok = DO_saveTagFile();\n DO_saveLexiconFile();\n if (ok==0) {\n messageField.setText(\"Tagging data saved\");\n }\n else {\n messageField.setText(\"Warning! Tagging data NOT saved\");\n }\n setCursor(current_cursor);\n }\n });\n fileMenu.add(saveTagMenuItem);\n saveAsMenu = new JMenu(\"Save as\");\n saveAsMenu.setMnemonic('a');\n saveTagAsMenuItem = new JMenuItem(\"Tagging\",'t');\n saveTagAsMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_saveTagFileAs();\n setCursor(current_cursor);\n }\n });\n saveAsMenu.add(saveTagAsMenuItem);\n saveLexiconAsMenuItem = new JMenuItem(\"Lexicon\",'l');\n saveLexiconAsMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_saveLexiconFileAs();\n setCursor(current_cursor);\n }\n });\n saveAsMenu.add(saveLexiconAsMenuItem);\n fileMenu.add(saveAsMenu);\n saveTrainMenuItem = new JMenuItem(\"Export tags to train format\",'e');\n saveTrainMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_saveTrainFile();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(saveTrainMenuItem);\n convertTagsToTriples = new JMenuItem(\"Export to Triples\",'e');\n convertTagsToTriples.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_exportToTriples();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(convertTagsToTriples);\n outputMostCommonSubsumer = new JMenuItem(\"Export wordnet classes\",'w');\n outputMostCommonSubsumer.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_exportMostCommonSubsumers();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(outputMostCommonSubsumer);\n quitMenuItem = new JMenuItem(\"Quit\",'q');\n quitMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n if (DO_checkSave()==2) {\n System.exit(0);\n }\n }\n });\n fileMenu.add(quitMenuItem);\n menuButtons.add(fileMenu);\n searchMenu = new JMenu(\"Search\");\n searchMenu.setMnemonic('s');\n searchWordMenuItem = new JMenuItem(\"Word\",'w');\n searchWordMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchWord();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchWordMenuItem);\n searchLastTagMenuItem = new JMenuItem(\"Last tag\",'l');\n searchLastTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchLastTag();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchLastTagMenuItem);\n searchTagMenuItem = new JMenuItem(\"Tag\",'t');\n searchTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchTag();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchTagMenuItem);\n searchWordAgainMenuItem = new JMenuItem(\"Next Word\",'n');\n searchWordAgainMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchWordAgain();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchWordAgainMenuItem);\n searchTagAgainMenuItem = new JMenuItem(\"Next Tag\",'x');\n searchTagAgainMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchTagAgain();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchTagAgainMenuItem);\n searchNotDoneMenuItem = new JMenuItem(\"No Confirm\",'c');\n searchNotDoneMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_notDone();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchNotDoneMenuItem);\n menuButtons.add(searchMenu);\n otherMenu = new JMenu(\"Other\");\n otherMenu.setMnemonic('o');\n confirmMenuItem = new JMenuItem(\"Do Confirm\",'d');\n confirmMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor(Cursor.WAIT_CURSOR));\n DO_Selected();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(confirmMenuItem);\n unconfirmMenuItem = new JMenuItem(\"Undo Confirm\",'u');\n unconfirmMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_Unselected();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(unconfirmMenuItem);\n removeAllTagsMenuItem = new JMenuItem(\"Remove all annotations\",'r');\n removeAllTagsMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagAllTokens();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(removeAllTagsMenuItem);\n undoMenuItem = new JMenuItem(\"Undo\",'u');\n undoMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_undo();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(undoMenuItem);\n menuButtons.add(otherMenu);\n tag1Menu = new JMenu(\"Tag level 1\");\n tag1Menu.setMnemonic('1');\n tag1TokenMenu = new JMenu(\"Tag tokens\");\n tag1TokenMenu.setMnemonic('t');\n tag1Menu.add(tag1TokenMenu);\n tag1LemmaMenu = new JMenu(\"Tag types\");\n tag1LemmaMenu.setMnemonic('y');\n tag1Menu.add(tag1LemmaMenu);\n tag1ConstituentMenu = new JMenu(\"Tag constituent\");\n tag1ConstituentMenu.setMnemonic('c');\n tag1Menu.add(tag1ConstituentMenu);\n tag1SentenceMenu = new JMenu(\"Tag sentence\");\n tag1SentenceMenu.setMnemonic('s');\n tag1Menu.add(tag1SentenceMenu);\n JMenuItem untagItem = new JMenuItem (\"UNTAG\", 'u');\n untagItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(untagItem);\n JMenuItem mergeTagIdsItem = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(mergeTagIdsItem);\n JMenuItem separateTagIdsItem = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(separateTagIdsItem);\n JMenuItem editTagIdsItem = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(editTagIdsItem);\n JMenuItem copyTagItem = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(copyTagItem);\n JMenuItem pastTagItem = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(pastTagItem);\n JMenuItem selectLexTagMenuItem = new JMenuItem(\"Dominant Tag\",'l');\n selectLexTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_selectLexicalTag();\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(selectLexTagMenuItem);\n newTag1MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag1MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag1();\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(newTag1MenuItem);\n menuButtons.add(tag1Menu);\n tag2Menu = new JMenu(\"Tag level 2\");\n tag2Menu.setMnemonic('2');\n tag2TokenMenu = new JMenu(\"Tag tokens\");\n tag2TokenMenu.setMnemonic('t');\n tag2Menu.add(tag2TokenMenu);\n tag2LemmaMenu = new JMenu(\"Tag types\");\n tag2LemmaMenu.setMnemonic('y');\n tag2Menu.add(tag2LemmaMenu);\n tag2ConstituentMenu = new JMenu(\"Tag constituent\");\n tag2ConstituentMenu.setMnemonic('c');\n tag2Menu.add(tag2ConstituentMenu);\n tag2SentenceMenu = new JMenu(\"Tag sentence\");\n tag2SentenceMenu.setMnemonic('s');\n tag2Menu.add(tag2SentenceMenu);\n JMenuItem untagItem2 = new JMenuItem (\"UNTAG\", 'u');\n untagItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(untagItem2);\n JMenuItem mergeTagIdsItem2 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(mergeTagIdsItem2);\n JMenuItem separateTagIdsItem2 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(separateTagIdsItem2);\n JMenuItem editTagIdsItem2 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(editTagIdsItem2);\n JMenuItem copyTagItem2 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(copyTagItem2);\n JMenuItem pastTagItem2 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(pastTagItem2);\n newTag2MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag2MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag2();\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(newTag2MenuItem);\n if (!tableSettings.hideTag2) {\n menuButtons.add(tag2Menu);\n }\n tag3Menu = new JMenu(\"Tag level 3\");\n tag3Menu.setMnemonic('3');\n tag3TokenMenu = new JMenu(\"Tag tokens\");\n tag3Menu.add(tag3TokenMenu);\n tag3LemmaMenu = new JMenu(\"Tag types\");\n tag3LemmaMenu.setMnemonic('y');\n tag3Menu.add(tag3LemmaMenu);\n tag3ConstituentMenu = new JMenu(\"Tag constituent\");\n tag3ConstituentMenu.setMnemonic('c');\n tag3Menu.add(tag3ConstituentMenu);\n tag3SentenceMenu = new JMenu(\"Tag sentence\");\n tag3SentenceMenu.setMnemonic('s');\n tag3Menu.add(tag3SentenceMenu);\n JMenuItem untagItem3 = new JMenuItem (\"UNTAG\", 'u');\n untagItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(untagItem3);\n JMenuItem mergeTagIdsItem3 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(mergeTagIdsItem3);\n JMenuItem separateTagIdsItem3 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(separateTagIdsItem3);\n JMenuItem editTagIdsItem3 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(editTagIdsItem3);\n JMenuItem copyTagItem3 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(copyTagItem3);\n JMenuItem pastTagItem3 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(pastTagItem3);\n newTag3MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag3MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag3();\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(newTag3MenuItem);\n if (!tableSettings.hideTag3){\n menuButtons.add(tag3Menu);\n }\n tag4Menu = new JMenu(\"Tag level 4\");\n tag4Menu.setMnemonic('4');\n tag4TokenMenu = new JMenu(\"Tag tokens\");\n tag4Menu.add(tag4TokenMenu);\n tag4LemmaMenu = new JMenu(\"Tag types\");\n tag4LemmaMenu.setMnemonic('y');\n tag4Menu.add(tag4LemmaMenu);\n tag4ConstituentMenu = new JMenu(\"Tag constituent\");\n tag4ConstituentMenu.setMnemonic('c');\n tag4Menu.add(tag4ConstituentMenu);\n tag4SentenceMenu = new JMenu(\"Tag sentence\");\n tag4SentenceMenu.setMnemonic('s');\n tag4Menu.add(tag4SentenceMenu);\n JMenuItem untagItem4 = new JMenuItem (\"UNTAG\", 'u');\n untagItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(untagItem4);\n JMenuItem mergeTagIdsItem4 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(mergeTagIdsItem4);\n JMenuItem separateTagIdsItem4 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(separateTagIdsItem4);\n JMenuItem editTagIdsItem4 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(editTagIdsItem4);\n JMenuItem copyTagItem4 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(copyTagItem4);\n JMenuItem pastTagItem4 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(pastTagItem4);\n newTag4MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag4MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag4();\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(newTag4MenuItem);\n if (!tableSettings.hideTag4) {\n menuButtons.add(tag4Menu);\n }\n tag5Menu = new JMenu(\"Tag level 5\");\n tag5Menu.setMnemonic('5');\n tag5TokenMenu = new JMenu(\"Tag tokens\");\n tag5Menu.add(tag5TokenMenu);\n tag5LemmaMenu = new JMenu(\"Tag types\");\n tag5LemmaMenu.setMnemonic('y');\n tag5Menu.add(tag5LemmaMenu);\n tag5ConstituentMenu = new JMenu(\"Tag constituent\");\n tag5ConstituentMenu.setMnemonic('c');\n tag5Menu.add(tag5ConstituentMenu);\n tag5SentenceMenu = new JMenu(\"Tag sentence\");\n tag5SentenceMenu.setMnemonic('s');\n tag5Menu.add(tag5SentenceMenu);\n JMenuItem untagItem5 = new JMenuItem (\"UNTAG\", 'u');\n untagItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(untagItem5);\n JMenuItem mergeTagIdsItem5 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(mergeTagIdsItem5);\n JMenuItem separateTagIdsItem5 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(separateTagIdsItem5);\n JMenuItem editTagIdsItem5 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(editTagIdsItem5);\n JMenuItem copyTagItem5 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(copyTagItem5);\n JMenuItem pastTagItem5 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(pastTagItem5);\n newTag5MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag5MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag5();\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(newTag5MenuItem);\n if (!tableSettings.hideTag5) {\n menuButtons.add(tag5Menu);\n }\n tag6Menu = new JMenu(\"Tag level 6\");\n tag6Menu.setMnemonic('6');\n tag6TokenMenu = new JMenu(\"Tag tokens\");\n tag6Menu.add(tag6TokenMenu);\n tag6LemmaMenu = new JMenu(\"Tag types\");\n tag6LemmaMenu.setMnemonic('y');\n tag6Menu.add(tag6LemmaMenu);\n tag6ConstituentMenu = new JMenu(\"Tag constituent\");\n tag6ConstituentMenu.setMnemonic('c');\n tag6Menu.add(tag6ConstituentMenu);\n tag6SentenceMenu = new JMenu(\"Tag sentence\");\n tag6SentenceMenu.setMnemonic('s');\n tag6Menu.add(tag6SentenceMenu);\n JMenuItem untagItem6 = new JMenuItem (\"UNTAG\", 'u');\n untagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(untagItem6);\n JMenuItem mergeTagIdsItem6 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(mergeTagIdsItem6);\n JMenuItem separateTagIdsItem6 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(separateTagIdsItem6);\n JMenuItem editTagIdsItem6 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(editTagIdsItem6);\n JMenuItem copyTagItem6 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(copyTagItem6);\n JMenuItem pastTagItem6 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(pastTagItem6);\n newTag6MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag6MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag6();\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(newTag6MenuItem);\n if (!tableSettings.hideTag6) {\n menuButtons.add(tag6Menu);\n }\n tag7Menu = new JMenu(\"Tag level 7\");\n tag7Menu.setMnemonic('7');\n tag7TokenMenu = new JMenu(\"Tag tokens\");\n tag7Menu.add(tag7TokenMenu);\n tag7LemmaMenu = new JMenu(\"Tag types\");\n tag7LemmaMenu.setMnemonic('y');\n tag7Menu.add(tag7LemmaMenu);\n tag7ConstituentMenu = new JMenu(\"Tag constituent\");\n tag7ConstituentMenu.setMnemonic('c');\n tag7Menu.add(tag7ConstituentMenu);\n tag7SentenceMenu = new JMenu(\"Tag sentence\");\n tag7SentenceMenu.setMnemonic('s');\n tag7Menu.add(tag7SentenceMenu);\n JMenuItem untagItem7 = new JMenuItem (\"UNTAG\", 'u');\n untagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(untagItem7);\n JMenuItem mergeTagIdsItem7 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(mergeTagIdsItem7);\n JMenuItem separateTagIdsItem7 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(separateTagIdsItem7);\n JMenuItem editTagIdsItem7 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem7.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(editTagIdsItem7);\n JMenuItem copyTagItem7 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem7.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(copyTagItem7);\n JMenuItem pastTagItem7 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem7.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(pastTagItem7);\n newTag7MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag7MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag7();\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(newTag7MenuItem);\n if (!tableSettings.hideTag7) {\n menuButtons.add(tag7Menu);\n }\n tag8Menu = new JMenu(\"Tag level 8\");\n tag8Menu.setMnemonic('8');\n tag8TokenMenu = new JMenu(\"Tag tokens\");\n tag8Menu.add(tag8TokenMenu);\n tag8LemmaMenu = new JMenu(\"Tag types\");\n tag8LemmaMenu.setMnemonic('y');\n tag8Menu.add(tag8LemmaMenu);\n tag8ConstituentMenu = new JMenu(\"Tag constituent\");\n tag8ConstituentMenu.setMnemonic('c');\n tag8Menu.add(tag8ConstituentMenu);\n tag8SentenceMenu = new JMenu(\"Tag sentence\");\n tag8SentenceMenu.setMnemonic('s');\n tag8Menu.add(tag8SentenceMenu);\n JMenuItem untagItem8 = new JMenuItem (\"UNTAG\", 'u');\n untagItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(untagItem8);\n JMenuItem mergeTagIdsItem8 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(mergeTagIdsItem8);\n JMenuItem separateTagIdsItem8 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(separateTagIdsItem8);\n JMenuItem editTagIdsItem8 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(editTagIdsItem8);\n JMenuItem copyTagItem8 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(copyTagItem8);\n JMenuItem pastTagItem8 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(pastTagItem8);\n newTag8MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag8MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag8();\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(newTag8MenuItem);\n if (!tableSettings.hideTag8) {\n menuButtons.add(tag8Menu);\n }\n table = new AnnotationTable(tableSettings);\n contentPanel = new JPanel();\n setContentPane(contentPanel);\n contentPanel.setLayout(new GridBagLayout());\n contentPanel.add(menuButtons, new GridBagConstraints(0, 0, 1, 1, 0, 0\n ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 15, 15));\n contentPanel.add(table, new GridBagConstraints(0, 1, 1, 1, 0.3, 0.3\n ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));\n contentPanel.add(messagePanel, new GridBagConstraints(0, 3, 1, 1, 0.3, 0.3\n ,GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));\n }\n", "output": " public AnnotatorFrame (TableSettings settings) {\n File resource = new File (RESOURCESFOLDER);\n if (!resource.exists()) {\n resource.mkdir();\n }\n File locations = new File (LOCATIONFILE);\n if (!locations.exists()) {\n try {\n locations.createNewFile();\n } catch (IOException e) {\n e.printStackTrace(); \n }\n }\n tableSettings = settings;\n cache = new ArrayList<CacheData>();\n cacheBu = new ArrayList<CacheData>();\n parser = new KafSaxParser();\n tagLexicon = new Lexicon();\n tagLexicon.parseFile(LEXICONFILE);\n TripleConfig = new TripleConfig(TripleCONFIGFILE);\n theTag1Set = new ArrayList<String>();\n theTag2Set = new ArrayList<String>();\n theTag3Set = new ArrayList<String>();\n theTag4Set = new ArrayList<String>();\n theTag5Set = new ArrayList<String>();\n theTag6Set = new ArrayList<String>();\n theTag7Set = new ArrayList<String>();\n theTag8Set = new ArrayList<String>();\n clipboardTag = \"\";\n clipboardTagId = -1;\n inputName = \"\";\n messagePanel = new JPanel();\n messagePanel.setMinimumSize(new Dimension(400, 320));\n messagePanel.setPreferredSize(new Dimension(400, 320));\n messagePanel.setMaximumSize(new Dimension(400, 320));\n messageLabel = new JLabel(\"Messages:\");\n messageLabel.setMinimumSize(new Dimension(80, 25));\n messageLabel.setPreferredSize(new Dimension(80, 25));\n messageField = new JTextField();\n messageField.setEditable(false);\n messageField.setMinimumSize(new Dimension(300, 25));\n messageField.setPreferredSize(new Dimension(300, 25));\n messageField.setMaximumSize(new Dimension(400, 30));\n fullTextLabel = new JLabel(\"Text:\");\n fullTextLabel.setMinimumSize(new Dimension(80, 25));\n fullTextLabel.setPreferredSize(new Dimension(80, 25));\n fullTextField = new JTextArea();\n fullTextField.setEditable(false);\n fullTextField.setBackground(Colors.BackGroundColor);\n fullTextField.setLineWrap(true);\n fullTextField.setWrapStyleWord(true);\n fullTextField.addMouseListener(new MouseAdapter() {\n public void mousePressed(MouseEvent e) {\n switch(e.getModifiers()) {\n case InputEvent.BUTTON3_MASK: {\n String word = fullTextField.getSelectedText();\n table.searchForString(AnnotationTableModel.ROWWORDTOKEN, word);\n }\n }\n }\n });\n JScrollPane scrollableTextArea = new JScrollPane (fullTextField,\n JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\n scrollableTextArea.setMinimumSize(new Dimension(300, 200));\n scrollableTextArea.setPreferredSize(new Dimension(300, 200));\n scrollableTextArea.setMaximumSize(new Dimension(400, 200));\n kafFileLabel = new JLabel(\"KAF file:\");\n kafFileLabel.setMinimumSize(new Dimension(80, 25));\n kafFileLabel.setPreferredSize(new Dimension(80, 25));\n kafFileField = new JTextField();\n kafFileField.setEditable(false);\n kafFileField.setBackground(Colors.BackGroundColor);\n kafFileField.setMinimumSize(new Dimension(300, 25));\n kafFileField.setPreferredSize(new Dimension(300, 25));\n kafFileField.setMaximumSize(new Dimension(400, 30));\n tagFileLabel = new JLabel(\"TAG file:\");\n tagFileLabel.setMinimumSize(new Dimension(80, 25));\n tagFileLabel.setPreferredSize(new Dimension(80, 25));\n tagFileField = new JTextField();\n tagFileField.setEditable(false);\n tagFileField.setBackground(Colors.BackGroundColor);\n tagFileField.setMinimumSize(new Dimension(300, 25));\n tagFileField.setPreferredSize(new Dimension(300, 25));\n tagFileField.setMaximumSize(new Dimension(400, 30));\n tagSetFileLabel = new JLabel(\"TAG set:\");\n tagSetFileLabel.setMinimumSize(new Dimension(80, 25));\n tagSetFileLabel.setPreferredSize(new Dimension(80, 25));\n tagSetFileField = new JTextField();\n tagSetFileField.setEditable(false);\n tagSetFileField.setBackground(Colors.BackGroundColor);\n tagSetFileField.setMinimumSize(new Dimension(300, 25));\n tagSetFileField.setPreferredSize(new Dimension(300, 25));\n tagSetFileField.setMaximumSize(new Dimension(400, 30));\n messagePanel.setLayout(new GridBagLayout());\n messagePanel.add(fullTextLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0\n ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(scrollableTextArea, new GridBagConstraints(1, 0, 1, 1, 0.3, 0.3\n , GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(messageLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0\n ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(messageField, new GridBagConstraints(1, 1, 1, 1, 0.3, 0.3\n , GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(10, 1, 1, 1), 0, 0));\n messagePanel.add(kafFileLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0\n ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(kafFileField, new GridBagConstraints(1, 2, 1, 1, 0.3, 0.3\n , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagFileLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0\n ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagFileField, new GridBagConstraints(1, 3, 1, 1, 0.3, 0.3\n , GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagSetFileLabel, new GridBagConstraints(0, 4, 1, 1, 0, 0\n ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));\n messagePanel.add(tagSetFileField, new GridBagConstraints(1, 4, 1, 1, 0.3, 0.3\n ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));\n menuButtons = new JMenuBar();\n fileMenu = new JMenu(\"File\");\n fileMenu.setMnemonic('f');\n openMenuItem = new JMenuItem(\"Open KAF file\",'o');\n openMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_loadKafFile();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(openMenuItem);\n readTagFileMenuItem = new JMenuItem(\"Load TAG file\",'l');\n readTagFileMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_loadTagFile();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(readTagFileMenuItem);\n readTagSetMenuItem = new JMenuItem(\"Load TAG set\", 't');\n readTagSetMenuItem.setMnemonic('t');\n readTagSetMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_readTagSet();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(readTagSetMenuItem);\n readLexiconMenuItem = new JMenuItem(\"Load lexicon file\", 'x'); \n readLexiconMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_readLexicon();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(readLexiconMenuItem);\n saveTagMenuItem = new JMenuItem(\"Save tagging\",'s');\n saveTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n int ok = -1;\n ok = DO_saveTagFile();\n DO_saveLexiconFile();\n if (ok==0) {\n messageField.setText(\"Tagging data saved\");\n }\n else {\n messageField.setText(\"Warning! Tagging data NOT saved\");\n }\n setCursor(current_cursor);\n }\n });\n fileMenu.add(saveTagMenuItem);\n saveAsMenu = new JMenu(\"Save as\");\n saveAsMenu.setMnemonic('a');\n saveTagAsMenuItem = new JMenuItem(\"Tagging\",'t');\n saveTagAsMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_saveTagFileAs();\n setCursor(current_cursor);\n }\n });\n saveAsMenu.add(saveTagAsMenuItem);\n saveLexiconAsMenuItem = new JMenuItem(\"Lexicon\",'l');\n saveLexiconAsMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_saveLexiconFileAs();\n setCursor(current_cursor);\n }\n });\n saveAsMenu.add(saveLexiconAsMenuItem);\n fileMenu.add(saveAsMenu);\n saveTrainMenuItem = new JMenuItem(\"Export tags to train format\",'e');\n saveTrainMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_saveTrainFile();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(saveTrainMenuItem);\n convertTagsToTriples = new JMenuItem(\"Export to Triples\",'e');\n convertTagsToTriples.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_exportToTriples();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(convertTagsToTriples);\n outputMostCommonSubsumer = new JMenuItem(\"Export wordnet classes\",'w');\n outputMostCommonSubsumer.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_exportMostCommonSubsumers();\n setCursor(current_cursor);\n }\n });\n fileMenu.add(outputMostCommonSubsumer);\n quitMenuItem = new JMenuItem(\"Quit\",'q');\n quitMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n if (DO_checkSave()==2) {\n System.exit(0);\n }\n }\n });\n fileMenu.add(quitMenuItem);\n menuButtons.add(fileMenu);\n searchMenu = new JMenu(\"Search\");\n searchMenu.setMnemonic('s');\n searchWordMenuItem = new JMenuItem(\"Word\",'w');\n searchWordMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchWord();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchWordMenuItem);\n searchLastTagMenuItem = new JMenuItem(\"Last tag\",'l');\n searchLastTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchLastTag();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchLastTagMenuItem);\n searchTagMenuItem = new JMenuItem(\"Tag\",'t');\n searchTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchTag();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchTagMenuItem);\n searchWordAgainMenuItem = new JMenuItem(\"Next Word\",'n');\n searchWordAgainMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchWordAgain();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchWordAgainMenuItem);\n searchTagAgainMenuItem = new JMenuItem(\"Next Tag\",'x');\n searchTagAgainMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_searchTagAgain();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchTagAgainMenuItem);\n searchNotDoneMenuItem = new JMenuItem(\"No Confirm\",'c');\n searchNotDoneMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_notDone();\n setCursor(current_cursor);\n }\n });\n searchMenu.add(searchNotDoneMenuItem);\n menuButtons.add(searchMenu);\n otherMenu = new JMenu(\"Other\");\n otherMenu.setMnemonic('o');\n confirmMenuItem = new JMenuItem(\"Do Confirm\",'d');\n confirmMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor(Cursor.WAIT_CURSOR));\n DO_Selected();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(confirmMenuItem);\n unconfirmMenuItem = new JMenuItem(\"Undo Confirm\",'u');\n unconfirmMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_Unselected();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(unconfirmMenuItem);\n removeAllTagsMenuItem = new JMenuItem(\"Remove all annotations\",'r');\n removeAllTagsMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagAllTokens();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(removeAllTagsMenuItem);\n undoMenuItem = new JMenuItem(\"Undo\",'u');\n undoMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_undo();\n setCursor(current_cursor);\n }\n });\n otherMenu.add(undoMenuItem);\n menuButtons.add(otherMenu);\n tag1Menu = new JMenu(\"Tag level 1\");\n tag1Menu.setMnemonic('1');\n tag1TokenMenu = new JMenu(\"Tag tokens\");\n tag1TokenMenu.setMnemonic('t');\n tag1Menu.add(tag1TokenMenu);\n tag1LemmaMenu = new JMenu(\"Tag types\");\n tag1LemmaMenu.setMnemonic('y');\n tag1Menu.add(tag1LemmaMenu);\n tag1ConstituentMenu = new JMenu(\"Tag constituent\");\n tag1ConstituentMenu.setMnemonic('c');\n tag1Menu.add(tag1ConstituentMenu);\n tag1SentenceMenu = new JMenu(\"Tag sentence\");\n tag1SentenceMenu.setMnemonic('s');\n tag1Menu.add(tag1SentenceMenu);\n JMenuItem untagItem = new JMenuItem (\"UNTAG\", 'u');\n untagItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(untagItem);\n JMenuItem mergeTagIdsItem = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(mergeTagIdsItem);\n JMenuItem separateTagIdsItem = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(separateTagIdsItem);\n JMenuItem editTagIdsItem = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(editTagIdsItem);\n JMenuItem copyTagItem = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(copyTagItem);\n JMenuItem pastTagItem = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(1);\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(pastTagItem);\n JMenuItem selectLexTagMenuItem = new JMenuItem(\"Dominant Tag\",'l');\n selectLexTagMenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_selectLexicalTag();\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(selectLexTagMenuItem);\n newTag1MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag1MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag1();\n setCursor(current_cursor);\n }\n });\n tag1Menu.add(newTag1MenuItem);\n menuButtons.add(tag1Menu);\n tag2Menu = new JMenu(\"Tag level 2\");\n tag2Menu.setMnemonic('2');\n tag2TokenMenu = new JMenu(\"Tag tokens\");\n tag2TokenMenu.setMnemonic('t');\n tag2Menu.add(tag2TokenMenu);\n tag2LemmaMenu = new JMenu(\"Tag types\");\n tag2LemmaMenu.setMnemonic('y');\n tag2Menu.add(tag2LemmaMenu);\n tag2ConstituentMenu = new JMenu(\"Tag constituent\");\n tag2ConstituentMenu.setMnemonic('c');\n tag2Menu.add(tag2ConstituentMenu);\n tag2SentenceMenu = new JMenu(\"Tag sentence\");\n tag2SentenceMenu.setMnemonic('s');\n tag2Menu.add(tag2SentenceMenu);\n JMenuItem untagItem2 = new JMenuItem (\"UNTAG\", 'u');\n untagItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(untagItem2);\n JMenuItem mergeTagIdsItem2 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(mergeTagIdsItem2);\n JMenuItem separateTagIdsItem2 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(separateTagIdsItem2);\n JMenuItem editTagIdsItem2 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(editTagIdsItem2);\n JMenuItem copyTagItem2 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(copyTagItem2);\n JMenuItem pastTagItem2 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem2.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(2);\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(pastTagItem2);\n newTag2MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag2MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag2();\n setCursor(current_cursor);\n }\n });\n tag2Menu.add(newTag2MenuItem);\n if (!tableSettings.hideTag2) {\n menuButtons.add(tag2Menu);\n }\n tag3Menu = new JMenu(\"Tag level 3\");\n tag3Menu.setMnemonic('3');\n tag3TokenMenu = new JMenu(\"Tag tokens\");\n tag3Menu.add(tag3TokenMenu);\n tag3LemmaMenu = new JMenu(\"Tag types\");\n tag3LemmaMenu.setMnemonic('y');\n tag3Menu.add(tag3LemmaMenu);\n tag3ConstituentMenu = new JMenu(\"Tag constituent\");\n tag3ConstituentMenu.setMnemonic('c');\n tag3Menu.add(tag3ConstituentMenu);\n tag3SentenceMenu = new JMenu(\"Tag sentence\");\n tag3SentenceMenu.setMnemonic('s');\n tag3Menu.add(tag3SentenceMenu);\n JMenuItem untagItem3 = new JMenuItem (\"UNTAG\", 'u');\n untagItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(untagItem3);\n JMenuItem mergeTagIdsItem3 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(mergeTagIdsItem3);\n JMenuItem separateTagIdsItem3 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(separateTagIdsItem3);\n JMenuItem editTagIdsItem3 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(editTagIdsItem3);\n JMenuItem copyTagItem3 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(copyTagItem3);\n JMenuItem pastTagItem3 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem3.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(3);\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(pastTagItem3);\n newTag3MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag3MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag3();\n setCursor(current_cursor);\n }\n });\n tag3Menu.add(newTag3MenuItem);\n if (!tableSettings.hideTag3){\n menuButtons.add(tag3Menu);\n }\n tag4Menu = new JMenu(\"Tag level 4\");\n tag4Menu.setMnemonic('4');\n tag4TokenMenu = new JMenu(\"Tag tokens\");\n tag4Menu.add(tag4TokenMenu);\n tag4LemmaMenu = new JMenu(\"Tag types\");\n tag4LemmaMenu.setMnemonic('y');\n tag4Menu.add(tag4LemmaMenu);\n tag4ConstituentMenu = new JMenu(\"Tag constituent\");\n tag4ConstituentMenu.setMnemonic('c');\n tag4Menu.add(tag4ConstituentMenu);\n tag4SentenceMenu = new JMenu(\"Tag sentence\");\n tag4SentenceMenu.setMnemonic('s');\n tag4Menu.add(tag4SentenceMenu);\n JMenuItem untagItem4 = new JMenuItem (\"UNTAG\", 'u');\n untagItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(untagItem4);\n JMenuItem mergeTagIdsItem4 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(mergeTagIdsItem4);\n JMenuItem separateTagIdsItem4 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(separateTagIdsItem4);\n JMenuItem editTagIdsItem4 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(editTagIdsItem4);\n JMenuItem copyTagItem4 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(copyTagItem4);\n JMenuItem pastTagItem4 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem4.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(4);\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(pastTagItem4);\n newTag4MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag4MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag4();\n setCursor(current_cursor);\n }\n });\n tag4Menu.add(newTag4MenuItem);\n if (!tableSettings.hideTag4) {\n menuButtons.add(tag4Menu);\n }\n tag5Menu = new JMenu(\"Tag level 5\");\n tag5Menu.setMnemonic('5');\n tag5TokenMenu = new JMenu(\"Tag tokens\");\n tag5Menu.add(tag5TokenMenu);\n tag5LemmaMenu = new JMenu(\"Tag types\");\n tag5LemmaMenu.setMnemonic('y');\n tag5Menu.add(tag5LemmaMenu);\n tag5ConstituentMenu = new JMenu(\"Tag constituent\");\n tag5ConstituentMenu.setMnemonic('c');\n tag5Menu.add(tag5ConstituentMenu);\n tag5SentenceMenu = new JMenu(\"Tag sentence\");\n tag5SentenceMenu.setMnemonic('s');\n tag5Menu.add(tag5SentenceMenu);\n JMenuItem untagItem5 = new JMenuItem (\"UNTAG\", 'u');\n untagItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(untagItem5);\n JMenuItem mergeTagIdsItem5 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(mergeTagIdsItem5);\n JMenuItem separateTagIdsItem5 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(separateTagIdsItem5);\n JMenuItem editTagIdsItem5 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(editTagIdsItem5);\n JMenuItem copyTagItem5 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(copyTagItem5);\n JMenuItem pastTagItem5 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem5.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(5);\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(pastTagItem5);\n newTag5MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag5MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag5();\n setCursor(current_cursor);\n }\n });\n tag5Menu.add(newTag5MenuItem);\n if (!tableSettings.hideTag5) {\n menuButtons.add(tag5Menu);\n }\n tag6Menu = new JMenu(\"Tag level 6\");\n tag6Menu.setMnemonic('6');\n tag6TokenMenu = new JMenu(\"Tag tokens\");\n tag6Menu.add(tag6TokenMenu);\n tag6LemmaMenu = new JMenu(\"Tag types\");\n tag6LemmaMenu.setMnemonic('y');\n tag6Menu.add(tag6LemmaMenu);\n tag6ConstituentMenu = new JMenu(\"Tag constituent\");\n tag6ConstituentMenu.setMnemonic('c');\n tag6Menu.add(tag6ConstituentMenu);\n tag6SentenceMenu = new JMenu(\"Tag sentence\");\n tag6SentenceMenu.setMnemonic('s');\n tag6Menu.add(tag6SentenceMenu);\n JMenuItem untagItem6 = new JMenuItem (\"UNTAG\", 'u');\n untagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(untagItem6);\n JMenuItem mergeTagIdsItem6 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(mergeTagIdsItem6);\n JMenuItem separateTagIdsItem6 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(separateTagIdsItem6);\n JMenuItem editTagIdsItem6 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(editTagIdsItem6);\n JMenuItem copyTagItem6 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(copyTagItem6);\n JMenuItem pastTagItem6 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(6);\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(pastTagItem6);\n newTag6MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag6MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag6();\n setCursor(current_cursor);\n }\n });\n tag6Menu.add(newTag6MenuItem);\n if (!tableSettings.hideTag6) {\n menuButtons.add(tag6Menu);\n }\n tag7Menu = new JMenu(\"Tag level 7\");\n tag7Menu.setMnemonic('7');\n tag7TokenMenu = new JMenu(\"Tag tokens\");\n tag7Menu.add(tag7TokenMenu);\n tag7LemmaMenu = new JMenu(\"Tag types\");\n tag7LemmaMenu.setMnemonic('y');\n tag7Menu.add(tag7LemmaMenu);\n tag7ConstituentMenu = new JMenu(\"Tag constituent\");\n tag7ConstituentMenu.setMnemonic('c');\n tag7Menu.add(tag7ConstituentMenu);\n tag7SentenceMenu = new JMenu(\"Tag sentence\");\n tag7SentenceMenu.setMnemonic('s');\n tag7Menu.add(tag7SentenceMenu);\n JMenuItem untagItem7 = new JMenuItem (\"UNTAG\", 'u');\n untagItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(untagItem7);\n JMenuItem mergeTagIdsItem7 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(mergeTagIdsItem7);\n JMenuItem separateTagIdsItem7 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem6.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(separateTagIdsItem7);\n JMenuItem editTagIdsItem7 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem7.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(editTagIdsItem7);\n JMenuItem copyTagItem7 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem7.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(copyTagItem7);\n JMenuItem pastTagItem7 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem7.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(7);\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(pastTagItem7);\n newTag7MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag7MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag7();\n setCursor(current_cursor);\n }\n });\n tag7Menu.add(newTag7MenuItem);\n if (!tableSettings.hideTag7) {\n menuButtons.add(tag7Menu);\n }\n tag8Menu = new JMenu(\"Tag level 8\");\n tag8Menu.setMnemonic('8');\n tag8TokenMenu = new JMenu(\"Tag tokens\");\n tag8Menu.add(tag8TokenMenu);\n tag8LemmaMenu = new JMenu(\"Tag types\");\n tag8LemmaMenu.setMnemonic('y');\n tag8Menu.add(tag8LemmaMenu);\n tag8ConstituentMenu = new JMenu(\"Tag constituent\");\n tag8ConstituentMenu.setMnemonic('c');\n tag8Menu.add(tag8ConstituentMenu);\n tag8SentenceMenu = new JMenu(\"Tag sentence\");\n tag8SentenceMenu.setMnemonic('s');\n tag8Menu.add(tag8SentenceMenu);\n JMenuItem untagItem8 = new JMenuItem (\"UNTAG\", 'u');\n untagItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_unTagTokens(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(untagItem8);\n JMenuItem mergeTagIdsItem8 = new JMenuItem (\"Merge Tag Ids\", 'm');\n mergeTagIdsItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_mergeTagIds(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(mergeTagIdsItem8);\n JMenuItem separateTagIdsItem8 = new JMenuItem (\"Separate Tag Ids\", 's');\n separateTagIdsItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_separateTagIds(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(separateTagIdsItem8);\n JMenuItem editTagIdsItem8 = new JMenuItem (\"Edit Tag Id\", 'e');\n editTagIdsItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_editTagIds(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(editTagIdsItem8);\n JMenuItem copyTagItem8 = new JMenuItem (\"Copy Tag & Id\", 'c');\n copyTagItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_copyTag(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(copyTagItem8);\n JMenuItem pastTagItem8 = new JMenuItem (\"Past Tag & Id\", 'p');\n pastTagItem8.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_pastTag(8);\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(pastTagItem8);\n newTag8MenuItem = new JMenuItem(\"Add Tag\",'a');\n newTag8MenuItem.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n Cursor current_cursor = getCursor();\n setCursor(new Cursor ( Cursor.WAIT_CURSOR ));\n DO_makeNewTag8();\n setCursor(current_cursor);\n }\n });\n tag8Menu.add(newTag8MenuItem);\n if (!tableSettings.hideTag8) {\n menuButtons.add(tag8Menu);\n }\n table = new AnnotationTable(tableSettings);\n contentPanel = new JPanel();\n setContentPane(contentPanel);\n contentPanel.setLayout(new GridBagLayout());\n contentPanel.add(menuButtons, new GridBagConstraints(0, 0, 1, 1, 0, 0\n ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 15, 15));\n contentPanel.add(table, new GridBagConstraints(0, 1, 1, 1, 0.3, 0.3\n ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0));\n contentPanel.add(messagePanel, new GridBagConstraints(0, 3, 1, 1, 0.3, 0.3\n ,GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));\n }\n"} {"input": " public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {\n String charset = (String) hints.get(EncodeHintType.CHARACTER_SET);\n Number eccPercent = (Number) hints.get(EncodeHintType.ERROR_CORRECTION);\n return encode(contents, \n format, \n charset == null ? DEFAULT_CHARSET : Charset.forName(charset),\n eccPercent == null ? Encoder.DEFAULT_EC_PERCENT : eccPercent.intValue());\n }\n", "output": " public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType,?> hints) {\n String charset = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET);\n Number eccPercent = hints == null ? null : (Number) hints.get(EncodeHintType.ERROR_CORRECTION);\n return encode(contents, \n format, \n charset == null ? DEFAULT_CHARSET : Charset.forName(charset),\n eccPercent == null ? Encoder.DEFAULT_EC_PERCENT : eccPercent.intValue());\n }\n"} {"input": " private void createBridge(SootClass sootClass, SootMethod method, String selectorName) {\n Jimple j = Jimple.v();\n SootMethod msgSendMethod = getMsgSendMethod(selectorName, method);\n sootClass.addMethod(msgSendMethod);\n addBridgeAnnotation(msgSendMethod);\n SootMethod msgSendSuperMethod = null;\n if (!method.isStatic()) {\n msgSendSuperMethod = getMsgSendSuperMethod(selectorName, method);\n sootClass.addMethod(msgSendSuperMethod);\n addBridgeAnnotation(msgSendSuperMethod);\n }\n method.setModifiers(method.getModifiers() & ~NATIVE);\n Body body = j.newBody(method);\n method.setActiveBody(body);\n PatchingChain<Unit> units = body.getUnits();\n if (!method.isStatic()) {\n Local thiz = j.newLocal(\"$this\", sootClass.getType());\n body.getLocals().add(thiz);\n units.add(j.newIdentityStmt(thiz, j.newThisRef(sootClass.getType())));\n }\n LinkedList<Value> args = new LinkedList<>();\n for (int i = 0; i < method.getParameterCount(); i++) {\n Type t = method.getParameterType(i);\n Local p = j.newLocal(\"$p\" + i, t);\n body.getLocals().add(p);\n units.add(j.newIdentityStmt(p, j.newParameterRef(t, i)));\n args.add(p);\n }\n Local sel = j.newLocal(\"$sel\", org_robovm_objc_Selector.getType());\n body.getLocals().add(sel);\n units.add(\n j.newAssignStmt(\n sel, \n j.newStaticFieldRef(\n Scene.v().makeFieldRef(\n sootClass, \n getSelectorFieldName(selectorName), \n org_robovm_objc_Selector.getType(), true)))\n );\n args.addFirst(sel);\n Local objCClass = null;\n if (method.isStatic()) {\n objCClass = j.newLocal(\"$objCClass\", org_robovm_objc_ObjCClass.getType());\n body.getLocals().add(objCClass);\n units.add(\n j.newAssignStmt(\n objCClass,\n j.newStaticFieldRef( \n Scene.v().makeFieldRef(\n sootClass, \n \"$objCClass\", org_robovm_objc_ObjCClass.getType(), true))\n )\n );\n }\n Local customClass = null;\n if (!Modifier.isFinal(sootClass.getModifiers()) && !method.isStatic()) {\n customClass = j.newLocal(\"$customClass\", BooleanType.v());\n body.getLocals().add(customClass);\n units.add(\n j.newAssignStmt(\n customClass,\n j.newInstanceFieldRef(\n body.getThisLocal(), \n org_robovm_objc_ObjCObject_customClass)\n )\n );\n }\n Local ret = null;\n if (method.getReturnType() != VoidType.v()) {\n ret = j.newLocal(\"$ret\", method.getReturnType());\n body.getLocals().add(ret);\n }\n StaticInvokeExpr invokeMsgSendExpr = \n j.newStaticInvokeExpr(\n msgSendMethod.makeRef(),\n l(method.isStatic() ? objCClass : body.getThisLocal(), args));\n Stmt invokeMsgSendStmt = ret == null \n ? j.newInvokeStmt(invokeMsgSendExpr) \n : j.newAssignStmt(ret, invokeMsgSendExpr);\n if (customClass != null) {\n units.add(\n j.newIfStmt(\n j.newEqExpr(customClass, IntConstant.v(0)), \n invokeMsgSendStmt)\n );\n Local zuper = j.newLocal(\"$super\", org_robovm_objc_ObjCSuper.getType());\n body.getLocals().add(zuper);\n units.add(\n j.newAssignStmt(\n zuper, \n j.newVirtualInvokeExpr(\n body.getThisLocal(), \n org_robovm_objc_ObjCObject_getSuper))\n );\n StaticInvokeExpr invokeMsgSendSuperExpr = \n j.newStaticInvokeExpr(\n msgSendMethod.makeRef(),\n l(zuper, args));\n units.add(\n ret == null\n ? j.newInvokeStmt(invokeMsgSendSuperExpr)\n : j.newAssignStmt(ret, invokeMsgSendSuperExpr)\n );\n if (ret != null) {\n units.add(j.newReturnStmt(ret));\n } else {\n units.add(j.newReturnVoidStmt());\n }\n }\n units.add(invokeMsgSendStmt);\n if (ret != null) {\n units.add(j.newReturnStmt(ret));\n } else {\n units.add(j.newReturnVoidStmt());\n }\n }\n", "output": " private void createBridge(SootClass sootClass, SootMethod method, String selectorName) {\n Jimple j = Jimple.v();\n SootMethod msgSendMethod = getMsgSendMethod(selectorName, method);\n sootClass.addMethod(msgSendMethod);\n addBridgeAnnotation(msgSendMethod);\n SootMethod msgSendSuperMethod = null;\n if (!method.isStatic()) {\n msgSendSuperMethod = getMsgSendSuperMethod(selectorName, method);\n sootClass.addMethod(msgSendSuperMethod);\n addBridgeAnnotation(msgSendSuperMethod);\n }\n method.setModifiers(method.getModifiers() & ~NATIVE);\n Body body = j.newBody(method);\n method.setActiveBody(body);\n PatchingChain<Unit> units = body.getUnits();\n if (!method.isStatic()) {\n Local thiz = j.newLocal(\"$this\", sootClass.getType());\n body.getLocals().add(thiz);\n units.add(j.newIdentityStmt(thiz, j.newThisRef(sootClass.getType())));\n }\n LinkedList<Value> args = new LinkedList<>();\n for (int i = 0; i < method.getParameterCount(); i++) {\n Type t = method.getParameterType(i);\n Local p = j.newLocal(\"$p\" + i, t);\n body.getLocals().add(p);\n units.add(j.newIdentityStmt(p, j.newParameterRef(t, i)));\n args.add(p);\n }\n Local sel = j.newLocal(\"$sel\", org_robovm_objc_Selector.getType());\n body.getLocals().add(sel);\n units.add(\n j.newAssignStmt(\n sel, \n j.newStaticFieldRef(\n Scene.v().makeFieldRef(\n sootClass, \n getSelectorFieldName(selectorName), \n org_robovm_objc_Selector.getType(), true)))\n );\n args.addFirst(sel);\n Local objCClass = null;\n if (method.isStatic()) {\n objCClass = j.newLocal(\"$objCClass\", org_robovm_objc_ObjCClass.getType());\n body.getLocals().add(objCClass);\n units.add(\n j.newAssignStmt(\n objCClass,\n j.newStaticFieldRef( \n Scene.v().makeFieldRef(\n sootClass, \n \"$objCClass\", org_robovm_objc_ObjCClass.getType(), true))\n )\n );\n }\n Local customClass = null;\n if (!Modifier.isFinal(sootClass.getModifiers()) && !method.isStatic()) {\n customClass = j.newLocal(\"$customClass\", BooleanType.v());\n body.getLocals().add(customClass);\n units.add(\n j.newAssignStmt(\n customClass,\n j.newInstanceFieldRef(\n body.getThisLocal(), \n org_robovm_objc_ObjCObject_customClass)\n )\n );\n }\n Local ret = null;\n if (method.getReturnType() != VoidType.v()) {\n ret = j.newLocal(\"$ret\", method.getReturnType());\n body.getLocals().add(ret);\n }\n StaticInvokeExpr invokeMsgSendExpr = \n j.newStaticInvokeExpr(\n msgSendMethod.makeRef(),\n l(method.isStatic() ? objCClass : body.getThisLocal(), args));\n Stmt invokeMsgSendStmt = ret == null \n ? j.newInvokeStmt(invokeMsgSendExpr) \n : j.newAssignStmt(ret, invokeMsgSendExpr);\n if (customClass != null) {\n units.add(\n j.newIfStmt(\n j.newEqExpr(customClass, IntConstant.v(0)), \n invokeMsgSendStmt)\n );\n Local zuper = j.newLocal(\"$super\", org_robovm_objc_ObjCSuper.getType());\n body.getLocals().add(zuper);\n units.add(\n j.newAssignStmt(\n zuper, \n j.newVirtualInvokeExpr(\n body.getThisLocal(), \n org_robovm_objc_ObjCObject_getSuper))\n );\n StaticInvokeExpr invokeMsgSendSuperExpr = \n j.newStaticInvokeExpr(\n msgSendSuperMethod.makeRef(),\n l(zuper, args));\n units.add(\n ret == null\n ? j.newInvokeStmt(invokeMsgSendSuperExpr)\n : j.newAssignStmt(ret, invokeMsgSendSuperExpr)\n );\n if (ret != null) {\n units.add(j.newReturnStmt(ret));\n } else {\n units.add(j.newReturnVoidStmt());\n }\n }\n units.add(invokeMsgSendStmt);\n if (ret != null) {\n units.add(j.newReturnStmt(ret));\n } else {\n units.add(j.newReturnVoidStmt());\n }\n }\n"} {"input": "\tpublic IStructureViewNode createNode(IProgramElement node, List children) {\n\t\tAbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility());\n\t\tIStructureViewNode svNode = createDeclaration(node, icon, children);\n\t\tString nodeHandle = node.getHandleIdentifier();\n\t\tif (nodeHandle != null && !node.getKind().equals(IProgramElement.Kind.FIELD)) {\t\n\t\t\tList relationships = AsmManager.getDefault().getRelationshipMap().get(nodeHandle);\n\t\t\tif (relationships != null) {\n\t\t\t\tfor (Iterator it = relationships.iterator(); it.hasNext(); ) {\n\t\t\t\t\tIRelationship rel = (IRelationship)it.next();\n\t\t\t\t\tif (rel != null && rel.getTargets().size() > 0) {\n\t\t\t\t\t\tIStructureViewNode relNode = createRelationship(\n\t\t\t\t\t\t\trel, \n\t\t\t\t\t\t\ticonRegistry.getIcon(rel.getKind())\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (relNode != null) {\n\t\t\t\t\t\tsvNode.add(relNode, 0);\t\t\t\t\t\n\t\t\t\t\t\t\tfor (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {\n\t\t\t\t\t\t\t\tString handle = (String)it2.next();\n\t\t\t\t\t\t\t\tIProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(handle);\n\t\t\t\t\t\t\t\tif (link != null) {\n\t\t\t\t\t\t\t\t\tIStructureViewNode linkNode = createLink(\n\t\t\t\t\t\t\t\t\t\tlink, \n\t\t\t\t\t\t\t\t\t\ticonRegistry.getStructureIcon(link.getKind(), link.getAccessibility()) \n\t\t\t\t\t\t\t\t\t);\t\n\t\t\t\t\t\t\t\t\trelNode.add(linkNode);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn svNode;\n\t}\n", "output": "\tpublic IStructureViewNode createNode(IProgramElement node, List children) {\n\t\tAbstractIcon icon = iconRegistry.getStructureIcon(node.getKind(), node.getAccessibility());\n\t\tIStructureViewNode svNode = createDeclaration(node, icon, children);\n\t\tString nodeHandle = node.getHandleIdentifier();\n\t\tif (nodeHandle != null && !node.getKind().equals(IProgramElement.Kind.FIELD)) {\t\n\t\t\tAsmManager manager = AsmManager.getDefault();\n\t\t\tIRelationshipMap relMap = (manager==null?null:manager.getRelationshipMap());\n\t\t\tList relationships = (relMap==null?null:relMap.get(nodeHandle));\n\t\t\tif (relationships != null) {\n\t\t\t\tfor (Iterator it = relationships.iterator(); it.hasNext(); ) {\n\t\t\t\t\tIRelationship rel = (IRelationship)it.next();\n\t\t\t\t\tif (rel != null && rel.getTargets().size() > 0) {\n\t\t\t\t\t\tIStructureViewNode relNode = createRelationship(\n\t\t\t\t\t\t\trel, \n\t\t\t\t\t\t\ticonRegistry.getIcon(rel.getKind())\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (relNode != null) {\n\t\t\t\t\t\tsvNode.add(relNode, 0);\t\t\t\t\t\n\t\t\t\t\t\t\tfor (Iterator it2 = rel.getTargets().iterator(); it2.hasNext(); ) {\n\t\t\t\t\t\t\t\tString handle = (String)it2.next();\n\t\t\t\t\t\t\t\tIProgramElement link = AsmManager.getDefault().getHierarchy().findElementForHandle(handle);\n\t\t\t\t\t\t\t\tif (link != null) {\n\t\t\t\t\t\t\t\t\tIStructureViewNode linkNode = createLink(\n\t\t\t\t\t\t\t\t\t\tlink, \n\t\t\t\t\t\t\t\t\t\ticonRegistry.getStructureIcon(link.getKind(), link.getAccessibility()) \n\t\t\t\t\t\t\t\t\t);\t\n\t\t\t\t\t\t\t\t\trelNode.add(linkNode);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn svNode;\n\t}\n"} {"input": "\tprivate Point fixupDisplayBounds(Point tipSize, Point location) {\n\t\tif (respectDisplayBounds || respectMonitorBounds) {\n\t\t\tRectangle bounds;\n\t\t\tPoint rightBounds = new Point(tipSize.x + location.x, tipSize.y\n\t\t\t\t\t+ location.y);\n\t\t\tMonitor[] ms = control.getDisplay().getMonitors();\n\t\t\tif (respectMonitorBounds && ms.length > 1) {\n\t\t\t\tbounds = control.getMonitor().getBounds();\n\t\t\t\tPoint p = new Point(location.x, location.y);\n\t\t\t\tRectangle tmp;\n\t\t\t\tfor (int i = 0; i < ms.length; i++) {\n\t\t\t\t\ttmp = ms[i].getBounds();\n\t\t\t\t\tif (tmp.contains(p)) {\n\t\t\t\t\t\tbounds = tmp;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbounds = control.getDisplay().getBounds();\n\t\t\t}\n\t\t\tif (!(bounds.contains(location) && bounds.contains(rightBounds))) {\n\t\t\t\tif (rightBounds.x > bounds.width) {\n\t\t\t\t\tlocation.x -= rightBounds.x - bounds.width;\n\t\t\t\t}\n\t\t\t\tif (rightBounds.y > bounds.height) {\n\t\t\t\t\tlocation.y -= rightBounds.y - bounds.height;\n\t\t\t\t}\n\t\t\t\tif (location.x < bounds.x) {\n\t\t\t\t\tlocation.x = bounds.x;\n\t\t\t\t}\n\t\t\t\tif (location.y < bounds.y) {\n\t\t\t\t\tlocation.y = bounds.y;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn location;\n\t}\n", "output": "\tprivate Point fixupDisplayBounds(Point tipSize, Point location) {\n\t\tif (respectDisplayBounds || respectMonitorBounds) {\n\t\t\tRectangle bounds;\n\t\t\tPoint rightBounds = new Point(tipSize.x + location.x, tipSize.y\n\t\t\t\t\t+ location.y);\n\t\t\tMonitor[] ms = control.getDisplay().getMonitors();\n\t\t\tif (respectMonitorBounds && ms.length > 1) {\n\t\t\t\tbounds = control.getMonitor().getBounds();\n\t\t\t\tPoint p = new Point(location.x, location.y);\n\t\t\t\tRectangle tmp;\n\t\t\t\tfor (int i = 0; i < ms.length; i++) {\n\t\t\t\t\ttmp = ms[i].getBounds();\n\t\t\t\t\tif (tmp.contains(p)) {\n\t\t\t\t\t\tbounds = tmp;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbounds = control.getDisplay().getBounds();\n\t\t\t}\n\t\t\tif (!(bounds.contains(location) && bounds.contains(rightBounds))) {\n\t\t\t\tif (rightBounds.x > bounds.x + bounds.width) {\n\t\t\t\t\tlocation.x -= rightBounds.x - (bounds.x + bounds.width);\n\t\t\t\t}\n\t\t\t\tif (rightBounds.y > bounds.y + bounds.height) {\n\t\t\t\t\tlocation.y -= rightBounds.y - (bounds.y + bounds.height);\n\t\t\t\t}\n\t\t\t\tif (location.x < bounds.x) {\n\t\t\t\t\tlocation.x = bounds.x;\n\t\t\t\t}\n\t\t\t\tif (location.y < bounds.y) {\n\t\t\t\t\tlocation.y = bounds.y;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn location;\n\t}\n"} {"input": "\tsynchronized public void fetchUpdatesCaller( String friend, File galleryDir) throws DB461Exception {\n\t\tSNetDB461 db = null;\n\t\ttry {\n\t\t\tdb = new SNetDB461(mDBName);\n\t\t\tDDNSRRecord.ARecord ddnsResult;\n\t\t\tJSONObject args;\n\t\t\tLog.i(TAG, \"Call to fetchUpdatesCaller for friend \"+friend);\n\t\t\tddnsResult = ddnsResolverService.resolve(friend);\n\t\t\tLog.v(TAG, \"Resolved friend \"+friend+\" to DDNS address \"+ddnsResult);\n\t\t\tLog.d(TAG, \"Putting together JSON glob\");\n\t\t\tJSONObject community = new JSONObject();\n\t\t\tJSONArray needphotos = new JSONArray();\n\t\t\tRecordSet<CommunityRecord> communityRecords = db.COMMUNITYTABLE.readAll();\n\t\t\tfor (CommunityRecord cRecord : communityRecords) {\n\t\t\t\tJSONObject value = new JSONObject()\n\t\t\t\t\t\t.put(\"generation\", cRecord.generation)\n\t\t\t\t\t\t.put(\"myphotohash\", cRecord.myPhotoHash)\n\t\t\t\t\t\t.put(\"chosenphotohash\", cRecord.chosenPhotoHash);\n\t\t\t\tcommunity.put(cRecord.name.toString(), value);\n\t\t\t\tif (cRecord.isFriend) {\n\t\t\t\t\tPhotoRecord pRecord;\n\t\t\t\t\tint photoHash;\n\t\t\t\t\tpRecord = db.PHOTOTABLE.readOne(cRecord.myPhotoHash);\n\t\t\t\t\tphotoHash = cRecord.myPhotoHash;\n\t\t\t\t\tif (pRecord == null && photoHash != 0) {\n\t\t\t\t\t\tneedphotos.put(photoHash);\n\t\t\t\t\t}\n\t\t\t\t\tpRecord = db.PHOTOTABLE.readOne(cRecord.chosenPhotoHash);\n\t\t\t\t\tphotoHash = cRecord.chosenPhotoHash;\n\t\t\t\t\tif (pRecord == null && photoHash != 0) {\n\t\t\t\t\t\tneedphotos.put(photoHash);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\targs = new JSONObject()\n\t\t\t\t.put(\"community\", community)\n\t\t\t\t.put(\"needphotos\", needphotos);\n\t\t\tLog.d(TAG, \"sending fetchUpdates RPC call with args: \"+args);\n\t\t\tJSONObject response = RPCCall.invoke(ddnsResult.ip(), ddnsResult.port(), \"snet\", \"fetchUpdates\", args);\n\t\t\tLog.d(TAG, \"response JSON of \"+response);\n\t\t\tIterator<String> keysIter;\n\t\t\tJSONObject communityUpdates = response.getJSONObject(\"communityupdates\");\n\t\t\tkeysIter = communityUpdates.keys();\n\t\t\twhile (keysIter.hasNext()) {\n\t\t\t\tString name = keysIter.next();\n\t\t\t\tCommunityRecord cRecord = db.COMMUNITYTABLE.readOne(name);\n\t\t\t\tif (cRecord == null) {\n\t\t\t\t\tLog.i(TAG, \"creating new db record for \"+name);\n\t\t\t\t\tcRecord = db.COMMUNITYTABLE.createRecord();\n\t\t\t\t\tcRecord.name = new DDNSFullName(name);\n\t\t\t\t\tcRecord.isFriend = false;\n\t\t\t\t}\n\t\t\t\tJSONObject recordUpdate = communityUpdates.getJSONObject(name);\t\t\n\t\t\t\tint genNum = recordUpdate.getInt(\"generation\");\n\t\t\t\tif (cRecord.generation <= genNum && isValidGenNum(genNum)) {\n\t\t\t\t\tLog.v(TAG, \"old record for \"+name+\" was \"+cRecord);\n\t\t\t\t\tLog.d(TAG, \"updating record for \"+name+\" to \"+recordUpdate);\n\t\t\t\t\tcRecord.generation = genNum;\n\t\t\t\t\tint oldHash = cRecord.myPhotoHash;\n\t\t\t\t\tint newHash = recordUpdate.getInt(\"myphotohash\");\n\t\t\t\t\tif (oldHash != newHash) {\n\t\t\t\t\t\tincrementPhotoDB(db, newHash, (galleryDir+newHash+\".jpg\"));\n\t\t\t\t\t\tdecrementPhotoDB(db, oldHash);\n\t\t\t\t\t\tcRecord.myPhotoHash = newHash;\n\t\t\t\t\t}\n\t\t\t\t\toldHash = cRecord.chosenPhotoHash;\n\t\t\t\t\tnewHash = recordUpdate.getInt(\"chosenphotohash\");\n\t\t\t\t\tif (oldHash != newHash) {\n\t\t\t\t\t\tincrementPhotoDB(db, newHash, (galleryDir+newHash+\".jpg\"));\n\t\t\t\t\t\tdecrementPhotoDB(db, oldHash);\n\t\t\t\t\t\tcRecord.chosenPhotoHash = newHash;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tLog.i(TAG, \"fetchUpdates returned record for \"+name+\", but was not more recent than ours\");\n\t\t\t\t}\n\t\t\t\tdb.COMMUNITYTABLE.write(cRecord);\n\t\t\t}\n\t\t\tJSONArray photoHashes = response.getJSONArray(\"photoupdates\");\n\t\t\tfor (int i=0; i<photoHashes.length(); i++) {\n\t\t\t\tint photoHash = photoHashes.getInt(i);\n\t\t\t\tPhotoRecord pRecord = db.PHOTOTABLE.readOne(photoHash);\n\t\t\t\tif (pRecord != null) {\n\t\t\t\t\tfetchPhotoAndSave(ddnsResult.ip(), ddnsResult.port(), pRecord);\n\t\t\t\t} else {\n\t\t\t\t\tLog.w(TAG, \"Photo can't be updated because no Photo DB entry for its hash: \"+photoHash);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(DDNSException e) {\n\t\t\te.printStackTrace();\n\t\t} catch(JSONException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\tif ( db != null ) db.discard();\n\t\t}\n\t}\n", "output": "\tsynchronized public void fetchUpdatesCaller( String friend, File galleryDir) throws DB461Exception {\n\t\tSNetDB461 db = null;\n\t\ttry {\n\t\t\tdb = new SNetDB461(mDBName);\n\t\t\tDDNSRRecord.ARecord ddnsResult;\n\t\t\tJSONObject args;\n\t\t\tLog.i(TAG, \"Call to fetchUpdatesCaller for friend \"+friend);\n\t\t\tddnsResult = ddnsResolverService.resolve(friend);\n\t\t\tLog.v(TAG, \"Resolved friend \"+friend+\" to DDNS address \"+ddnsResult);\n\t\t\tLog.d(TAG, \"Putting together JSON glob\");\n\t\t\tJSONObject community = new JSONObject();\n\t\t\tJSONArray needphotos = new JSONArray();\n\t\t\tRecordSet<CommunityRecord> communityRecords = db.COMMUNITYTABLE.readAll();\n\t\t\tfor (CommunityRecord cRecord : communityRecords) {\n\t\t\t\tJSONObject value = new JSONObject()\n\t\t\t\t\t\t.put(\"generation\", cRecord.generation)\n\t\t\t\t\t\t.put(\"myphotohash\", cRecord.myPhotoHash)\n\t\t\t\t\t\t.put(\"chosenphotohash\", cRecord.chosenPhotoHash);\n\t\t\t\tcommunity.put(cRecord.name.toString(), value);\n\t\t\t\tif (cRecord.isFriend) {\n\t\t\t\t\tPhotoRecord pRecord;\n\t\t\t\t\tint photoHash;\n\t\t\t\t\tpRecord = db.PHOTOTABLE.readOne(cRecord.myPhotoHash);\n\t\t\t\t\tphotoHash = cRecord.myPhotoHash;\n\t\t\t\t\tif (pRecord == null && photoHash != 0) {\n\t\t\t\t\t\tneedphotos.put(photoHash);\n\t\t\t\t\t}\n\t\t\t\t\tpRecord = db.PHOTOTABLE.readOne(cRecord.chosenPhotoHash);\n\t\t\t\t\tphotoHash = cRecord.chosenPhotoHash;\n\t\t\t\t\tif (pRecord == null && photoHash != 0) {\n\t\t\t\t\t\tneedphotos.put(photoHash);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\targs = new JSONObject()\n\t\t\t\t.put(\"community\", community)\n\t\t\t\t.put(\"needphotos\", needphotos);\n\t\t\tLog.d(TAG, \"sending fetchUpdates RPC call with args: \"+args);\n\t\t\tJSONObject response = RPCCall.invoke(ddnsResult.ip(), ddnsResult.port(), \"snet\", \"fetchUpdates\", args);\n\t\t\tLog.d(TAG, \"response JSON of \"+response);\n\t\t\tIterator<String> keysIter;\n\t\t\tJSONObject communityUpdates = response.getJSONObject(\"communityupdates\");\n\t\t\tkeysIter = communityUpdates.keys();\n\t\t\twhile (keysIter.hasNext()) {\n\t\t\t\tString name = keysIter.next();\n\t\t\t\tCommunityRecord cRecord = db.COMMUNITYTABLE.readOne(name);\n\t\t\t\tif (cRecord == null) {\n\t\t\t\t\tLog.i(TAG, \"creating new db record for \"+name);\n\t\t\t\t\tcRecord = db.COMMUNITYTABLE.createRecord();\n\t\t\t\t\tcRecord.name = new DDNSFullName(name);\n\t\t\t\t\tcRecord.isFriend = false;\n\t\t\t\t}\n\t\t\t\tJSONObject recordUpdate = communityUpdates.getJSONObject(name);\t\t\n\t\t\t\tint genNum = recordUpdate.getInt(\"generation\");\n\t\t\t\tif (cRecord.generation <= genNum && isValidGenNum(genNum)) {\n\t\t\t\t\tLog.v(TAG, \"old record for \"+name+\" was \"+cRecord);\n\t\t\t\t\tLog.d(TAG, \"updating record for \"+name+\" to \"+recordUpdate);\n\t\t\t\t\tcRecord.generation = genNum;\n\t\t\t\t\tint oldHash = cRecord.myPhotoHash;\n\t\t\t\t\tint newHash = recordUpdate.getInt(\"myphotohash\");\n\t\t\t\t\tif (oldHash != newHash) {\n\t\t\t\t\t\tincrementPhotoDB(db, newHash, (galleryDir.getCanonicalPath()+ File.separatorChar+newHash+\".jpg\"));\n\t\t\t\t\t\tdecrementPhotoDB(db, oldHash);\n\t\t\t\t\t\tcRecord.myPhotoHash = newHash;\n\t\t\t\t\t}\n\t\t\t\t\toldHash = cRecord.chosenPhotoHash;\n\t\t\t\t\tnewHash = recordUpdate.getInt(\"chosenphotohash\");\n\t\t\t\t\tif (oldHash != newHash) {\n\t\t\t\t\t\tincrementPhotoDB(db, newHash, (galleryDir.getCanonicalPath()+ File.separatorChar+newHash+\".jpg\"));\n\t\t\t\t\t\tdecrementPhotoDB(db, oldHash);\n\t\t\t\t\t\tcRecord.chosenPhotoHash = newHash;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tLog.i(TAG, \"fetchUpdates returned record for \"+name+\", but was not more recent than ours\");\n\t\t\t\t}\n\t\t\t\tdb.COMMUNITYTABLE.write(cRecord);\n\t\t\t}\n\t\t\tJSONArray photoHashes = response.getJSONArray(\"photoupdates\");\n\t\t\tfor (int i=0; i<photoHashes.length(); i++) {\n\t\t\t\tint photoHash = photoHashes.getInt(i);\n\t\t\t\tPhotoRecord pRecord = db.PHOTOTABLE.readOne(photoHash);\n\t\t\t\tif (pRecord != null) {\n\t\t\t\t\tfetchPhotoAndSave(ddnsResult.ip(), ddnsResult.port(), pRecord);\n\t\t\t\t} else {\n\t\t\t\t\tLog.w(TAG, \"Photo can't be updated because no Photo DB entry for its hash: \"+photoHash);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(DDNSException e) {\n\t\t\te.printStackTrace();\n\t\t} catch(JSONException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t} finally {\n\t\t\tif ( db != null ) db.discard();\n\t\t}\n\t}\n"} {"input": "\tpublic void renderHead(HtmlHeaderContainer container)\n\t{\n\t\tsuper.renderHead(container);\n\t\tPageParameters parameters = new PageParameters();\n\t\tparameters.put(\"fieldName\", this.getId());\n\t\tCharSequence url = urlFor(null, page, parameters);\n\t\tJavascriptBuilder builder = new JavascriptBuilder();\n\t\tbuilder.addLine(\"new Ajax.Autocompleter(\");\n\t\tbuilder.addLine(\" '\" + getMarkupId() + \"', \");\n\t\tbuilder.addLine(\" '\" + getAutocompleteId() + \"', \");\n\t\tbuilder.addLine(\" '\" + url + \"', {} );\");\n\t}\n", "output": "\tpublic void renderHead(HtmlHeaderContainer container)\n\t{\n\t\tsuper.renderHead(container);\n\t\tPageParameters parameters = new PageParameters();\n\t\tparameters.put(\"fieldName\", this.getMarkupId());\n\t\tCharSequence url = urlFor(null, page, parameters);\n\t\tJavascriptBuilder builder = new JavascriptBuilder();\n\t\tbuilder.addLine(\"new Ajax.Autocompleter(\");\n\t\tbuilder.addLine(\" '\" + getMarkupId() + \"', \");\n\t\tbuilder.addLine(\" '\" + getAutocompleteId() + \"', \");\n\t\tbuilder.addLine(\" '\" + url + \"', {} );\");\n\t}\n"} {"input": " public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,\n String tag, int id, Notification notification, int[] idOut)\n {\n if (DBG) {\n Slog.v(TAG, \"enqueueNotificationInternal: pkg=\" + pkg + \" id=\" + id + \" notification=\" + notification);\n }\n checkCallerIsSystemOrSameApp(pkg);\n final boolean isSystemNotification = (\"android\".equals(pkg));\n if (!isSystemNotification) {\n synchronized (mNotificationList) {\n int count = 0;\n final int N = mNotificationList.size();\n for (int i=0; i<N; i++) {\n final NotificationRecord r = mNotificationList.get(i);\n if (r.pkg.equals(pkg)) {\n count++;\n if (count >= MAX_PACKAGE_NOTIFICATIONS) {\n Slog.e(TAG, \"Package has already posted \" + count\n + \" notifications. Not showing more. package=\" + pkg);\n return;\n }\n }\n }\n }\n }\n if (!pkg.equals(\"com.android.providers.downloads\")\n || Log.isLoggable(\"DownloadManager\", Log.VERBOSE)) {\n EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag,\n notification.toString());\n }\n if (pkg == null || notification == null) {\n throw new IllegalArgumentException(\"null not allowed: pkg=\" + pkg\n + \" id=\" + id + \" notification=\" + notification);\n }\n if (notification.icon != 0) {\n if (notification.contentView == null) {\n throw new IllegalArgumentException(\"contentView required: pkg=\" + pkg\n + \" id=\" + id + \" notification=\" + notification);\n }\n }\n notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN, Notification.PRIORITY_MAX);\n if (0 != (notification.flags & Notification.FLAG_HIGH_PRIORITY)) {\n if (notification.priority < Notification.PRIORITY_MAX) notification.priority = Notification.PRIORITY_MAX;\n } else if (SCORE_ONGOING_HIGHER && 0 != (notification.flags & Notification.FLAG_ONGOING_EVENT)) {\n if (notification.priority < Notification.PRIORITY_HIGH) notification.priority = Notification.PRIORITY_HIGH;\n }\n int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER; \n if (ENABLE_BLOCKED_NOTIFICATIONS && !isSystemNotification && !areNotificationsEnabledForPackageInt(pkg)) {\n score = JUNK_SCORE;\n Slog.e(TAG, \"Suppressing notification from package \" + pkg + \" by user request.\");\n }\n if (DBG) {\n Slog.v(TAG, \"Assigned score=\" + score + \" to \" + notification);\n }\n if (score < SCORE_DISPLAY_THRESHOLD) {\n return;\n }\n synchronized (mNotificationList) {\n final boolean inQuietHours = inQuietHours();\n NotificationRecord r = new NotificationRecord(pkg, tag, id, \n callingUid, callingPid, \n score,\n notification);\n NotificationRecord old = null;\n int index = indexOfNotificationLocked(pkg, tag, id);\n if (index < 0) {\n mNotificationList.add(r);\n } else {\n old = mNotificationList.remove(index);\n mNotificationList.add(index, r);\n if (old != null) {\n notification.flags |=\n old.notification.flags&Notification.FLAG_FOREGROUND_SERVICE;\n }\n }\n if ((notification.flags&Notification.FLAG_FOREGROUND_SERVICE) != 0) {\n notification.flags |= Notification.FLAG_ONGOING_EVENT\n | Notification.FLAG_NO_CLEAR;\n }\n if (notification.icon != 0) {\n StatusBarNotification n = new StatusBarNotification(pkg, id, tag,\n r.uid, r.initialPid, score, notification);\n if (old != null && old.statusBarKey != null) {\n r.statusBarKey = old.statusBarKey;\n long identity = Binder.clearCallingIdentity();\n try {\n mStatusBar.updateNotification(r.statusBarKey, n);\n }\n finally {\n Binder.restoreCallingIdentity(identity);\n }\n } else {\n long identity = Binder.clearCallingIdentity();\n try {\n r.statusBarKey = mStatusBar.addNotification(n);\n if ((n.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {\n mAttentionLight.pulse();\n }\n }\n finally {\n Binder.restoreCallingIdentity(identity);\n }\n }\n sendAccessibilityEvent(notification, pkg);\n } else {\n Slog.e(TAG, \"Ignoring notification with icon==0: \" + notification);\n if (old != null && old.statusBarKey != null) {\n long identity = Binder.clearCallingIdentity();\n try {\n mStatusBar.removeNotification(old.statusBarKey);\n }\n finally {\n Binder.restoreCallingIdentity(identity);\n }\n }\n }\n try {\n final ProfileManager profileManager =\n (ProfileManager) mContext.getSystemService(Context.PROFILE_SERVICE);\n ProfileGroup group = profileManager.getActiveProfileGroup(pkg);\n notification = group.processNotification(notification);\n } catch(Throwable th) {\n Log.e(TAG, \"An error occurred profiling the notification.\", th);\n }\n if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0)\n && (!(old != null\n && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))\n && mSystemReady) {\n final AudioManager audioManager = (AudioManager) mContext\n .getSystemService(Context.AUDIO_SERVICE);\n final boolean useDefaultSound =\n (notification.defaults & Notification.DEFAULT_SOUND) != 0;\n if (!(inQuietHours && mQuietHoursMute)\n && (useDefaultSound || notification.sound != null)) {\n Uri uri;\n if (useDefaultSound) {\n uri = Settings.System.DEFAULT_NOTIFICATION_URI;\n } else {\n uri = notification.sound;\n }\n boolean looping = (notification.flags & Notification.FLAG_INSISTENT) != 0;\n int audioStreamType;\n if (notification.audioStreamType >= 0) {\n audioStreamType = notification.audioStreamType;\n } else {\n audioStreamType = DEFAULT_STREAM_TYPE;\n }\n mSoundNotification = r;\n if (audioManager.getStreamVolume(audioStreamType) != 0) {\n final long identity = Binder.clearCallingIdentity();\n try {\n final IRingtonePlayer player = mAudioService.getRingtonePlayer();\n if (player != null) {\n player.playAsync(uri, looping, audioStreamType);\n }\n } catch (RemoteException e) {\n } finally {\n Binder.restoreCallingIdentity(identity);\n }\n }\n }\n final boolean useDefaultVibrate =\n (notification.defaults & Notification.DEFAULT_VIBRATE) != 0;\n if (!(inQuietHours && mQuietHoursStill)\n && (useDefaultVibrate || notification.vibrate != null)\n && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) {\n mVibrateNotification = r;\n mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN\n : notification.vibrate,\n ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);\n }\n }\n mLights.remove(old);\n if (mLedNotification == old) {\n mLedNotification = null;\n }\n if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {\n mLights.add(r);\n updateLightsLocked();\n } else {\n if (old != null\n && ((old.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0)) {\n updateLightsLocked();\n }\n }\n }\n idOut[0] = id;\n }\n", "output": " public void enqueueNotificationInternal(String pkg, int callingUid, int callingPid,\n String tag, int id, Notification notification, int[] idOut)\n {\n if (DBG) {\n Slog.v(TAG, \"enqueueNotificationInternal: pkg=\" + pkg + \" id=\" + id + \" notification=\" + notification);\n }\n checkCallerIsSystemOrSameApp(pkg);\n final boolean isSystemNotification = (\"android\".equals(pkg));\n if (!isSystemNotification) {\n synchronized (mNotificationList) {\n int count = 0;\n final int N = mNotificationList.size();\n for (int i=0; i<N; i++) {\n final NotificationRecord r = mNotificationList.get(i);\n if (r.pkg.equals(pkg)) {\n count++;\n if (count >= MAX_PACKAGE_NOTIFICATIONS) {\n Slog.e(TAG, \"Package has already posted \" + count\n + \" notifications. Not showing more. package=\" + pkg);\n return;\n }\n }\n }\n }\n }\n if (!pkg.equals(\"com.android.providers.downloads\")\n || Log.isLoggable(\"DownloadManager\", Log.VERBOSE)) {\n EventLog.writeEvent(EventLogTags.NOTIFICATION_ENQUEUE, pkg, id, tag,\n notification.toString());\n }\n if (pkg == null || notification == null) {\n throw new IllegalArgumentException(\"null not allowed: pkg=\" + pkg\n + \" id=\" + id + \" notification=\" + notification);\n }\n if (notification.icon != 0) {\n if (notification.contentView == null) {\n throw new IllegalArgumentException(\"contentView required: pkg=\" + pkg\n + \" id=\" + id + \" notification=\" + notification);\n }\n }\n notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN, Notification.PRIORITY_MAX);\n if (0 != (notification.flags & Notification.FLAG_HIGH_PRIORITY)) {\n if (notification.priority < Notification.PRIORITY_MAX) notification.priority = Notification.PRIORITY_MAX;\n } else if (SCORE_ONGOING_HIGHER && 0 != (notification.flags & Notification.FLAG_ONGOING_EVENT)) {\n if (notification.priority < Notification.PRIORITY_HIGH) notification.priority = Notification.PRIORITY_HIGH;\n }\n int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER; \n if (ENABLE_BLOCKED_NOTIFICATIONS && !isSystemNotification && !areNotificationsEnabledForPackageInt(pkg)) {\n score = JUNK_SCORE;\n Slog.e(TAG, \"Suppressing notification from package \" + pkg + \" by user request.\");\n }\n if (DBG) {\n Slog.v(TAG, \"Assigned score=\" + score + \" to \" + notification);\n }\n if (score < SCORE_DISPLAY_THRESHOLD) {\n return;\n }\n synchronized (mNotificationList) {\n final boolean inQuietHours = inQuietHours();\n NotificationRecord r = new NotificationRecord(pkg, tag, id, \n callingUid, callingPid, \n score,\n notification);\n NotificationRecord old = null;\n int index = indexOfNotificationLocked(pkg, tag, id);\n if (index < 0) {\n mNotificationList.add(r);\n } else {\n old = mNotificationList.remove(index);\n mNotificationList.add(index, r);\n if (old != null) {\n notification.flags |=\n old.notification.flags&Notification.FLAG_FOREGROUND_SERVICE;\n }\n }\n if ((notification.flags&Notification.FLAG_FOREGROUND_SERVICE) != 0) {\n notification.flags |= Notification.FLAG_ONGOING_EVENT\n | Notification.FLAG_NO_CLEAR;\n }\n if (notification.icon != 0) {\n StatusBarNotification n = new StatusBarNotification(pkg, id, tag,\n r.uid, r.initialPid, score, notification);\n if (old != null && old.statusBarKey != null) {\n r.statusBarKey = old.statusBarKey;\n long identity = Binder.clearCallingIdentity();\n try {\n mStatusBar.updateNotification(r.statusBarKey, n);\n }\n finally {\n Binder.restoreCallingIdentity(identity);\n }\n } else {\n long identity = Binder.clearCallingIdentity();\n try {\n r.statusBarKey = mStatusBar.addNotification(n);\n if ((n.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {\n mAttentionLight.pulse();\n }\n }\n finally {\n Binder.restoreCallingIdentity(identity);\n }\n }\n sendAccessibilityEvent(notification, pkg);\n } else {\n Slog.e(TAG, \"Ignoring notification with icon==0: \" + notification);\n if (old != null && old.statusBarKey != null) {\n long identity = Binder.clearCallingIdentity();\n try {\n mStatusBar.removeNotification(old.statusBarKey);\n }\n finally {\n Binder.restoreCallingIdentity(identity);\n }\n }\n }\n try {\n final ProfileManager profileManager =\n (ProfileManager) mContext.getSystemService(Context.PROFILE_SERVICE);\n ProfileGroup group = profileManager.getActiveProfileGroup(pkg);\n if (group != null) {\n notification = group.processNotification(notification);\n }\n } catch(Throwable th) {\n Log.e(TAG, \"An error occurred profiling the notification.\", th);\n }\n if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0)\n && (!(old != null\n && (notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0 ))\n && mSystemReady) {\n final AudioManager audioManager = (AudioManager) mContext\n .getSystemService(Context.AUDIO_SERVICE);\n final boolean useDefaultSound =\n (notification.defaults & Notification.DEFAULT_SOUND) != 0;\n if (!(inQuietHours && mQuietHoursMute)\n && (useDefaultSound || notification.sound != null)) {\n Uri uri;\n if (useDefaultSound) {\n uri = Settings.System.DEFAULT_NOTIFICATION_URI;\n } else {\n uri = notification.sound;\n }\n boolean looping = (notification.flags & Notification.FLAG_INSISTENT) != 0;\n int audioStreamType;\n if (notification.audioStreamType >= 0) {\n audioStreamType = notification.audioStreamType;\n } else {\n audioStreamType = DEFAULT_STREAM_TYPE;\n }\n mSoundNotification = r;\n if (audioManager.getStreamVolume(audioStreamType) != 0) {\n final long identity = Binder.clearCallingIdentity();\n try {\n final IRingtonePlayer player = mAudioService.getRingtonePlayer();\n if (player != null) {\n player.playAsync(uri, looping, audioStreamType);\n }\n } catch (RemoteException e) {\n } finally {\n Binder.restoreCallingIdentity(identity);\n }\n }\n }\n final boolean useDefaultVibrate =\n (notification.defaults & Notification.DEFAULT_VIBRATE) != 0;\n if (!(inQuietHours && mQuietHoursStill)\n && (useDefaultVibrate || notification.vibrate != null)\n && !(audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT)) {\n mVibrateNotification = r;\n mVibrator.vibrate(useDefaultVibrate ? DEFAULT_VIBRATE_PATTERN\n : notification.vibrate,\n ((notification.flags & Notification.FLAG_INSISTENT) != 0) ? 0: -1);\n }\n }\n mLights.remove(old);\n if (mLedNotification == old) {\n mLedNotification = null;\n }\n if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0) {\n mLights.add(r);\n updateLightsLocked();\n } else {\n if (old != null\n && ((old.notification.flags & Notification.FLAG_SHOW_LIGHTS) != 0)) {\n updateLightsLocked();\n }\n }\n }\n idOut[0] = id;\n }\n"} {"input": " public void execute( Map context )\n throws ContinuumException, ContinuumStoreException\n {\n int projectGroupId = getProjectGroupId( context );\n ProjectGroup projectGroup = store.getProjectGroup( projectGroupId );\n try\n {\n if ( !roleManager.templatedRoleExists( \"project-administrator\", projectGroup.getName() ) )\n {\n roleManager.removeTemplatedRole( \"project-administrator\", projectGroup.getName() );\n }\n if ( !roleManager.templatedRoleExists( \"project-developer\", projectGroup.getName() ) )\n {\n roleManager.removeTemplatedRole( \"project-developer\", projectGroup.getName() );\n }\n if ( !roleManager.templatedRoleExists( \"project-user\", projectGroup.getName() ) )\n {\n roleManager.removeTemplatedRole( \"project-user\", projectGroup.getName() );\n }\n }\n catch ( RoleManagerException e )\n {\n e.printStackTrace();\n throw new ContinuumException( \"error removing tempalted role for project \" + projectGroup.getName(), e );\n }\n }\n", "output": " public void execute( Map context )\n throws ContinuumException, ContinuumStoreException\n {\n int projectGroupId = getProjectGroupId( context );\n ProjectGroup projectGroup = store.getProjectGroup( projectGroupId );\n try\n {\n if ( !roleManager.templatedRoleExists( \"project-administrator\", projectGroup.getName() ) )\n {\n roleManager.removeTemplatedRole( \"project-administrator\", projectGroup.getName() );\n }\n if ( !roleManager.templatedRoleExists( \"project-developer\", projectGroup.getName() ) )\n {\n roleManager.removeTemplatedRole( \"project-developer\", projectGroup.getName() );\n }\n if ( !roleManager.templatedRoleExists( \"project-user\", projectGroup.getName() ) )\n {\n roleManager.removeTemplatedRole( \"project-user\", projectGroup.getName() );\n }\n }\n catch ( RoleManagerException e )\n {\n e.printStackTrace();\n throw new ContinuumException( \"error removing templated role for project \" + projectGroup.getName(), e );\n }\n }\n"} {"input": "\tpublic boolean processFeedMetadata(OPDSFeedMetadata feed, boolean beforeEntries) {\n\t\tIcon = (feed.Icon != null) ? ZLNetworkUtil.url(myBaseURL, feed.Icon.Uri) : null;\n\t\tTitle = feed.Title;\n\t\tSummary = feed.Subtitle;\n\t\tfor (ATOMLink link: feed.Links) {\n\t\t\tfinal MimeType type = MimeType.get(link.getType());\n\t\t\tfinal String rel = myLink.relation(link.getRel(), type);\n\t\t\tif (\"search\".equals(rel)) {\n\t\t\t\tif (MimeType.APP_OPENSEARCHDESCRIPTION.equals(type)) {\n\t\t\t\t\tmyOpensearchDescriptionURLs.add(ZLNetworkUtil.url(myBaseURL, link.getHref()));\n\t\t\t\t} else if (MimeType.APP_ATOM_XML.weakEquals(type)) {\n\t\t\t\t\tfinal String template = ZLNetworkUtil.url(myBaseURL, link.getHref());\n\t\t\t\t\tfinal OpenSearchDescription descr = OpenSearchDescription.createDefault(template);\n\t\t\t\t\tif (descr.isValid()) {\n\t\t\t\t\t\tDirectOpenSearchDescription = descr;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean processFeedMetadata(OPDSFeedMetadata feed, boolean beforeEntries) {\n\t\tIcon = (feed.Icon != null) ? ZLNetworkUtil.url(myBaseURL, feed.Icon.Uri) : null;\n\t\tTitle = feed.Title;\n\t\tSummary = feed.Subtitle;\n\t\tfor (ATOMLink link: feed.Links) {\n\t\t\tfinal MimeType type = MimeType.get(link.getType());\n\t\t\tfinal String rel = myLink.relation(link.getRel(), type);\n\t\t\tif (\"search\".equals(rel)) {\n\t\t\t\tif (MimeType.APP_OPENSEARCHDESCRIPTION.equals(type)) {\n\t\t\t\t\tfinal String template = ZLNetworkUtil.url(myBaseURL, link.getHref());\n\t\t\t\t\tfinal OpenSearchDescription descr = OpenSearchDescription.createDefault(template);\n\t\t\t\t\tif (descr.isValid()) {\n\t\t\t\t\t\tDirectOpenSearchDescription = descr;\n\t\t\t\t\t}\n\t\t\t\t} else if (MimeType.APP_ATOM_XML.weakEquals(type)) {\n\t\t\t\t\tmyOpensearchDescriptionURLs.add(ZLNetworkUtil.url(myBaseURL, link.getHref()));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": "\tpublic boolean configure(Element element, ClientFactory clientFactory,\n\t\t\tArguments args) {\n\t\tsuper.configure(element, clientFactory, args);\n\t\tsortable = !options.contains(\"NoSort\");\n\t\ttable.setWidth(\"100%\");\n\t\tadd(table, CENTER);\n\t\tname = new ClickableHtmlColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\treturn Measurement.getDisplayName(name);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history.getMeasurement(ptu, name);\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t((ClickableTextCell) getCell()).render(context, decorate(s, m),\n\t\t\t\t\t\tsb);\n\t\t\t}\n\t\t};\n\t\tname.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tname.setSortable(sortable);\n\t\tif (selectable) {\n\t\t\tname.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttable.addColumn(name, showHeader ? new TextHeader(\"\") {\n\t\t\t@Override\n\t\t\tpublic String getValue() {\n\t\t\t\tif (!showName)\n\t\t\t\t\treturn null;\n\t\t\t\treturn ptu != null ? ptu.getName() : null;\n\t\t\t}\n\t\t\tpublic void render(Context context, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue();\n\t\t\t\tif (s != null) {\n\t\t\t\t\ts = \"PTU: \" + ptu.getName();\n\t\t\t\t\tif (interventions != null) {\n\t\t\t\t\t\tString realName = interventions.get(ptu) != null ? interventions\n\t\t\t\t\t\t\t\t.get(ptu).getName() : null;\n\t\t\t\t\t\tif (realName != null) {\n\t\t\t\t\t\t\ts = \"<div title=\\\"\" + s + \"\\\">\" + realName\n\t\t\t\t\t\t\t\t\t+ \"</div>\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsb.append(SafeHtmlUtils.fromSafeConstant(s));\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\t\t\t: null);\n\t\tClickableTextColumn<String> value = new ClickableTextColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\tif ((name == null) || (history == null) || (ptu == null)) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\tMeasurement m = history.getMeasurement(ptu, name);\n\t\t\t\treturn m != null ? format.format(m.getValue()) : \"\";\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history != null ? history.getMeasurement(\n\t\t\t\t\t\tptu, name) : null;\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdouble c = m.getValue().doubleValue();\n\t\t\t\tdouble lo = m.getLowLimit().doubleValue();\n\t\t\t\tdouble hi = m.getHighLimit().doubleValue();\n\t\t\t\tString status = lo >= hi ? \"in_range\" : c < lo ? \"lo-limit\"\n\t\t\t\t\t\t: c > hi ? \"hi-limit\" : \"in-range\";\n\t\t\t\tsb.append(SafeHtmlUtils.fromSafeConstant(\"<div class=\\\"\"\n\t\t\t\t\t\t+ status + \"\\\">\"));\n\t\t\t\t((ClickableTextCell) getCell()).render(context,\n\t\t\t\t\t\tdecorate(s, m, last), sb);\n\t\t\t\tsb.append(SafeHtmlUtils.fromSafeConstant(\"</div>\"));\n\t\t\t}\n\t\t};\n\t\tvalue.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);\n\t\tif (selectable) {\n\t\t\tvalue.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttable.addColumn(value, showHeader ? new TextHeader(\"Value\")\n\t\t\t\t: (Header<?>) null);\n\t\tClickableHtmlColumn<String> unit = new ClickableHtmlColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\tMeasurement m = history != null ? history.getMeasurement(\n\t\t\t\t\t\tptu, name) : null;\n\t\t\t\treturn m != null ? m.getUnit() : \"\";\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history != null ? history.getMeasurement(\n\t\t\t\t\t\tptu, name) : null;\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t((ClickableTextCell) getCell()).render(context, decorate(s, m),\n\t\t\t\t\t\tsb);\n\t\t\t}\n\t\t};\n\t\tunit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tunit.setSortable(sortable);\n\t\tif (selectable) {\n\t\t\tunit.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttable.addColumn(unit, showHeader ? new TextHeader(\"Unit\")\n\t\t\t\t: (Header<?>) null);\n\t\tClickableHtmlColumn<String> date = new ClickableHtmlColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\tMeasurement measurement = history\n\t\t\t\t\t\t.getMeasurement(ptu, name);\n\t\t\t\treturn measurement != null ? PtuClientConstants.dateFormat\n\t\t\t\t\t\t.format(measurement.getDate()) : \"\";\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history.getMeasurement(ptu, name);\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t((ClickableTextCell) getCell()).render(context, decorate(s, m),\n\t\t\t\t\t\tsb);\n\t\t\t}\n\t\t};\n\t\tunit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tunit.setSortable(sortable);\n\t\tif (selectable) {\n\t\t\tunit.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (showDate) {\n\t\t\ttable.addColumn(date, showHeader ? new TextHeader(\"Date\")\n\t\t\t\t\t: (Header<?>) null);\n\t\t}\n\t\tList<String> list = new ArrayList<String>();\n\t\tdataProvider.addDataDisplay(table);\n\t\tdataProvider.setList(list);\n\t\tcolumnSortHandler = new ListHandler<String>(dataProvider.getList());\n\t\tcolumnSortHandler.setComparator(name, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tif (s1 == s2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (s1 != null) {\n\t\t\t\t\treturn s1.compareTo(s2);\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(value, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tMeasurement o1 = history.getMeasurement(ptu, s1);\n\t\t\t\tMeasurement o2 = history.getMeasurement(ptu, s2);\n\t\t\t\tif (o1 == o2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif ((o1 != null) && (o1.getValue() != null)) {\n\t\t\t\t\tif ((o2 != null) && (o2.getValue() != null)) {\n\t\t\t\t\t\tdouble d1 = o1.getValue().doubleValue();\n\t\t\t\t\t\tdouble d2 = o2.getValue().doubleValue();\n\t\t\t\t\t\treturn d1 < d2 ? -1 : d1 == d2 ? 0 : 1;\n\t\t\t\t\t}\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(unit, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tMeasurement o1 = history.getMeasurement(ptu, s1);\n\t\t\t\tMeasurement o2 = history.getMeasurement(ptu, s2);\n\t\t\t\tif (o1 == o2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (o1 != null) {\n\t\t\t\t\treturn (o2 != null) ? o1.getUnit().compareTo(o2.getUnit())\n\t\t\t\t\t\t\t: 1;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(date, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tMeasurement o1 = history.getMeasurement(ptu, s1);\n\t\t\t\tMeasurement o2 = history.getMeasurement(ptu, s2);\n\t\t\t\tif (o1 == o2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (o1 != null) {\n\t\t\t\t\treturn (o2 != null) ? o1.getDate().compareTo(o2.getDate())\n\t\t\t\t\t\t\t: 1;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\ttable.addColumnSortHandler(columnSortHandler);\n\t\ttable.getColumnSortList().push(name);\n\t\tif (selectable) {\n\t\t\ttable.setSelectionModel(selectionModel);\n\t\t\tselectionModel\n\t\t\t\t\t.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onSelectionChange(SelectionChangeEvent event) {\n\t\t\t\t\t\t\tString s = selectionModel.getSelectedObject();\n\t\t\t\t\t\t\tlog.info(s + \" \" + event.getSource());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean configure(Element element, ClientFactory clientFactory,\n\t\t\tArguments args) {\n\t\tsuper.configure(element, clientFactory, args);\n\t\tsortable = !options.contains(\"NoSort\");\n\t\ttable.setWidth(\"100%\");\n\t\tadd(table, CENTER);\n\t\tname = new ClickableHtmlColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\treturn Measurement.getDisplayName(name);\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history.getMeasurement(ptu, name);\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t((ClickableTextCell) getCell()).render(context, decorate(s, m),\n\t\t\t\t\t\tsb);\n\t\t\t}\n\t\t};\n\t\tname.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tname.setSortable(sortable);\n\t\tif (selectable) {\n\t\t\tname.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttable.addColumn(name, showHeader ? new TextHeader(\"\") {\n\t\t\t@Override\n\t\t\tpublic String getValue() {\n\t\t\t\tif (!showName)\n\t\t\t\t\treturn null;\n\t\t\t\treturn ptu != null ? ptu.getName() : null;\n\t\t\t}\n\t\t\tpublic void render(Context context, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue();\n\t\t\t\tif (s != null) {\n\t\t\t\t\ts = \"PTU: \" + ptu.getName();\n\t\t\t\t\tif (interventions != null) {\n\t\t\t\t\t\tString realName = interventions.get(ptu) != null ? interventions\n\t\t\t\t\t\t\t\t.get(ptu).getName() : null;\n\t\t\t\t\t\tif (realName != null) {\n\t\t\t\t\t\t\ts = \"<div title=\\\"\" + s + \"\\\">\" + realName\n\t\t\t\t\t\t\t\t\t+ \"</div>\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsb.append(SafeHtmlUtils.fromSafeConstant(s));\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t\t\t\t: null);\n\t\tClickableTextColumn<String> value = new ClickableTextColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\tif ((name == null) || (history == null) || (ptu == null)) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\tMeasurement m = history.getMeasurement(ptu, name);\n\t\t\t\treturn m != null ? format.format(m.getValue()) : \"\";\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history != null ? history.getMeasurement(\n\t\t\t\t\t\tptu, name) : null;\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdouble c = m.getValue().doubleValue();\n\t\t\t\tDouble lo = m.getLowLimit();\n\t\t\t\tDouble hi = m.getHighLimit();\n\t\t\t\tString status = (lo != null) && (hi != null) && (lo >= hi) ? \"in_range\" : (lo != null) && (c < lo) ? \"lo-limit\"\n\t\t\t\t\t\t: (hi != null) && (c > hi) ? \"hi-limit\" : \"in-range\";\n\t\t\t\tsb.append(SafeHtmlUtils.fromSafeConstant(\"<div class=\\\"\"\n\t\t\t\t\t\t+ status + \"\\\">\"));\n\t\t\t\t((ClickableTextCell) getCell()).render(context,\n\t\t\t\t\t\tdecorate(s, m, last), sb);\n\t\t\t\tsb.append(SafeHtmlUtils.fromSafeConstant(\"</div>\"));\n\t\t\t}\n\t\t};\n\t\tvalue.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);\n\t\tif (selectable) {\n\t\t\tvalue.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttable.addColumn(value, showHeader ? new TextHeader(\"Value\")\n\t\t\t\t: (Header<?>) null);\n\t\tClickableHtmlColumn<String> unit = new ClickableHtmlColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\tMeasurement m = history != null ? history.getMeasurement(\n\t\t\t\t\t\tptu, name) : null;\n\t\t\t\treturn m != null ? m.getUnit() : \"\";\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history != null ? history.getMeasurement(\n\t\t\t\t\t\tptu, name) : null;\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t((ClickableTextCell) getCell()).render(context, decorate(s, m),\n\t\t\t\t\t\tsb);\n\t\t\t}\n\t\t};\n\t\tunit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tunit.setSortable(sortable);\n\t\tif (selectable) {\n\t\t\tunit.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttable.addColumn(unit, showHeader ? new TextHeader(\"Unit\")\n\t\t\t\t: (Header<?>) null);\n\t\tClickableHtmlColumn<String> date = new ClickableHtmlColumn<String>() {\n\t\t\t@Override\n\t\t\tpublic String getValue(String name) {\n\t\t\t\tMeasurement measurement = history\n\t\t\t\t\t\t.getMeasurement(ptu, name);\n\t\t\t\treturn measurement != null ? PtuClientConstants.dateFormat\n\t\t\t\t\t\t.format(measurement.getDate()) : \"\";\n\t\t\t}\n\t\t\t@Override\n\t\t\tpublic void render(Context context, String name, SafeHtmlBuilder sb) {\n\t\t\t\tString s = getValue(name);\n\t\t\t\tMeasurement m = history.getMeasurement(ptu, name);\n\t\t\t\tif (m == null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t((ClickableTextCell) getCell()).render(context, decorate(s, m),\n\t\t\t\t\t\tsb);\n\t\t\t}\n\t\t};\n\t\tunit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tunit.setSortable(sortable);\n\t\tif (selectable) {\n\t\t\tunit.setFieldUpdater(new FieldUpdater<String, String>() {\n\t\t\t\t@Override\n\t\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\t\tselectMeasurement(object);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (showDate) {\n\t\t\ttable.addColumn(date, showHeader ? new TextHeader(\"Date\")\n\t\t\t\t\t: (Header<?>) null);\n\t\t}\n\t\tList<String> list = new ArrayList<String>();\n\t\tdataProvider.addDataDisplay(table);\n\t\tdataProvider.setList(list);\n\t\tcolumnSortHandler = new ListHandler<String>(dataProvider.getList());\n\t\tcolumnSortHandler.setComparator(name, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tif (s1 == s2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (s1 != null) {\n\t\t\t\t\treturn s1.compareTo(s2);\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(value, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tMeasurement o1 = history.getMeasurement(ptu, s1);\n\t\t\t\tMeasurement o2 = history.getMeasurement(ptu, s2);\n\t\t\t\tif (o1 == o2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif ((o1 != null) && (o1.getValue() != null)) {\n\t\t\t\t\tif ((o2 != null) && (o2.getValue() != null)) {\n\t\t\t\t\t\tdouble d1 = o1.getValue().doubleValue();\n\t\t\t\t\t\tdouble d2 = o2.getValue().doubleValue();\n\t\t\t\t\t\treturn d1 < d2 ? -1 : d1 == d2 ? 0 : 1;\n\t\t\t\t\t}\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(unit, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tMeasurement o1 = history.getMeasurement(ptu, s1);\n\t\t\t\tMeasurement o2 = history.getMeasurement(ptu, s2);\n\t\t\t\tif (o1 == o2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (o1 != null) {\n\t\t\t\t\treturn (o2 != null) ? o1.getUnit().compareTo(o2.getUnit())\n\t\t\t\t\t\t\t: 1;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(date, new Comparator<String>() {\n\t\t\tpublic int compare(String s1, String s2) {\n\t\t\t\tMeasurement o1 = history.getMeasurement(ptu, s1);\n\t\t\t\tMeasurement o2 = history.getMeasurement(ptu, s2);\n\t\t\t\tif (o1 == o2) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif (o1 != null) {\n\t\t\t\t\treturn (o2 != null) ? o1.getDate().compareTo(o2.getDate())\n\t\t\t\t\t\t\t: 1;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t});\n\t\ttable.addColumnSortHandler(columnSortHandler);\n\t\ttable.getColumnSortList().push(name);\n\t\tif (selectable) {\n\t\t\ttable.setSelectionModel(selectionModel);\n\t\t\tselectionModel\n\t\t\t\t\t.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {\n\t\t\t\t\t\t@Override\n\t\t\t\t\t\tpublic void onSelectionChange(SelectionChangeEvent event) {\n\t\t\t\t\t\t\tString s = selectionModel.getSelectedObject();\n\t\t\t\t\t\t\tlog.info(s + \" \" + event.getSource());\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": " public void addComponentDescriptor( ComponentDescriptor componentDescriptor )\n throws ComponentRepositoryException\n {\n try\n {\n validateComponentDescriptor( componentDescriptor );\n }\n catch ( ComponentImplementationNotFoundException e )\n {\n throw new ComponentRepositoryException( \"Component descriptor validation failed: \", e );\n }\n String role = componentDescriptor.getRole();\n String roleHint = componentDescriptor.getRoleHint();\n if ( roleHint != null )\n {\n if ( componentDescriptors.containsKey( role ) )\n {\n ComponentDescriptor desc = (ComponentDescriptor) componentDescriptors.get( role );\n if ( desc.getRoleHint() == null )\n {\n String message = \"Component descriptor \" + componentDescriptor.getHumanReadableKey() +\n \" has a hint, but there are other implementations that don't\";\n throw new ComponentRepositoryException( message );\n }\n }\n Map map = (Map) componentDescriptorMaps.get( role );\n if ( map == null )\n {\n map = new HashMap();\n componentDescriptorMaps.put( role, map );\n }\n map.put( roleHint, componentDescriptor );\n }\n else\n {\n if ( componentDescriptorMaps.containsKey( role ) )\n {\n String message = \"Component descriptor \" + componentDescriptor.getHumanReadableKey() +\n \" has no hint, but there are other implementations that do\";\n throw new ComponentRepositoryException( message );\n }\n else if ( componentDescriptors.containsKey( role ) )\n {\n if ( !componentDescriptors.get( role ).equals( componentDescriptor ) )\n {\n String message = \"Component role \" + role +\n \" is already in the repository and different to attempted addition of \" +\n componentDescriptor.getHumanReadableKey();\n throw new ComponentRepositoryException( message );\n }\n }\n }\n try\n {\n compositionResolver.addComponentDescriptor( componentDescriptor );\n }\n catch ( CompositionException e )\n {\n throw new ComponentRepositoryException( e.getMessage(), e );\n }\n componentDescriptors.put( componentDescriptor.getComponentKey(), componentDescriptor );\n if ( !componentDescriptors.containsKey( role ) )\n {\n componentDescriptors.put( role, componentDescriptor );\n }\n }\n", "output": " public void addComponentDescriptor( ComponentDescriptor componentDescriptor )\n throws ComponentRepositoryException\n {\n try\n {\n validateComponentDescriptor( componentDescriptor );\n }\n catch ( ComponentImplementationNotFoundException e )\n {\n throw new ComponentRepositoryException( \"Component descriptor validation failed: \", e );\n }\n String role = componentDescriptor.getRole();\n String roleHint = componentDescriptor.getRoleHint();\n if ( roleHint != null )\n {\n if ( componentDescriptors.containsKey( role ) )\n {\n ComponentDescriptor desc = (ComponentDescriptor) componentDescriptors.get( role );\n if ( desc.getRoleHint() == null )\n {\n String message = \"Component descriptor \" + componentDescriptor.getHumanReadableKey()\n + \" has a hint, but implementation \" + desc.getImplementation() + \" doesn't\";\n throw new ComponentRepositoryException( message );\n }\n }\n Map map = (Map) componentDescriptorMaps.get( role );\n if ( map == null )\n {\n map = new HashMap();\n componentDescriptorMaps.put( role, map );\n }\n map.put( roleHint, componentDescriptor );\n }\n else\n {\n if ( componentDescriptorMaps.containsKey( role ) )\n {\n String message = \"Component descriptor \" + componentDescriptor.getHumanReadableKey() +\n \" has no hint, but there are other implementations that do\";\n throw new ComponentRepositoryException( message );\n }\n else if ( componentDescriptors.containsKey( role ) )\n {\n if ( !componentDescriptors.get( role ).equals( componentDescriptor ) )\n {\n String message = \"Component role \" + role +\n \" is already in the repository and different to attempted addition of \" +\n componentDescriptor.getHumanReadableKey();\n throw new ComponentRepositoryException( message );\n }\n }\n }\n try\n {\n compositionResolver.addComponentDescriptor( componentDescriptor );\n }\n catch ( CompositionException e )\n {\n throw new ComponentRepositoryException( e.getMessage(), e );\n }\n componentDescriptors.put( componentDescriptor.getComponentKey(), componentDescriptor );\n if ( !componentDescriptors.containsKey( role ) )\n {\n componentDescriptors.put( role, componentDescriptor );\n }\n }\n"} {"input": "\tpublic void invalidate() {\n\t\tif(!isValid) {\n\t\t\tthrow new IllegalStateException(\"SipApplicationSession already invalidated !\");\n\t\t}\n\t\tif(logger.isInfoEnabled()) {\n\t\t\tlogger.info(\"Invalidating the following sip application session \" + key);\n\t\t}\n\t\tfor(MobicentsSipSession session: sipSessions.values()) {\n\t\t\tif(session.isValid()) {\n\t\t\t\tsession.invalidate();\n\t\t\t}\n\t\t}\n\t\tfor(HttpSession session: httpSessions.values()) {\n\t\t\tif(((Session)session).isValid()) {\n\t\t\t\tsession.invalidate();\n\t\t\t}\n\t\t}\n\t\tfor (String key : sipApplicationSessionAttributeMap.keySet()) {\n\t\t\tremoveAttribute(key);\n\t\t}\n\t\tnotifySipApplicationSessionListeners(SipApplicationSessionEventType.DELETION);\n\t\tisValid = false;\t\n\t\tfor (Map.Entry<String, ServletTimer> servletTimerEntry : servletTimers.entrySet()) {\n\t\t\tServletTimer timerEntry = servletTimerEntry.getValue();\n\t\t\tif(timerEntry != null) {\n\t\t\t\ttimerEntry.cancel();\t\t\t\t\n\t\t\t}\n\t\t}\t\t\n\t\tif(!expired && expirationTimerFuture != null) {\n\t\t\tcancelExpirationTimer();\n\t\t}\n long timeNow = System.currentTimeMillis();\n int timeAlive = (int) ((timeNow - creationTime)/1000);\n SipManager manager = sipContext.getSipManager();\n synchronized (manager) {\n if (timeAlive > manager.getSipApplicationSessionMaxAliveTime()) {\n manager.setSipApplicationSessionMaxAliveTime(timeAlive);\n }\n int numExpired = manager.getExpiredSipApplicationSessions();\n numExpired++;\n manager.setExpiredSipApplicationSessions(numExpired);\n int average = manager.getSipApplicationSessionAverageAliveTime();\n average = ((average * (numExpired-1)) + timeAlive)/numExpired;\n manager.setSipApplicationSessionAverageAliveTime(average);\n }\n\t\tsipContext.getSipManager().removeSipApplicationSession(key);\t\t\n\t\texpirationTimerTask = null;\n\t\texpirationTimerFuture = null;\n\t\thttpSessions.clear();\n\t\tservletTimers.clear();\n\t\tsipApplicationSessionAttributeMap.clear();\n\t\tsipSessions.clear();\n\t\thttpSessions.clear();\n\t\texecutorService.shutdown();\n\t\texecutorService = null;\t\t\n\t\thttpSessions = null;\n\t\tsipSessions = null;\n\t\tsipApplicationSessionAttributeMap = null;\n\t\tservletTimers = null;\n\t\tsipContext = null;\t\t\n\t\tif(logger.isInfoEnabled()) {\n\t\t\tlogger.info(\"The following sip application session \" + key + \" has been invalidated\");\n\t\t}\n\t\tcurrentRequestHandler = null;\n\t\tkey = null;\t\t\n\t}\n", "output": "\tpublic void invalidate() {\n\t\tif(!isValid) {\n\t\t\tthrow new IllegalStateException(\"SipApplicationSession already invalidated !\");\n\t\t}\n\t\tif(logger.isInfoEnabled()) {\n\t\t\tlogger.info(\"Invalidating the following sip application session \" + key);\n\t\t}\n\t\tfor(MobicentsSipSession session: sipSessions.values()) {\n\t\t\tif(session.isValid()) {\n\t\t\t\tsession.invalidate();\n\t\t\t}\n\t\t}\n\t\tfor(HttpSession session: httpSessions.values()) {\n\t\t\ttry {\n\t\t\t\tsession.invalidate();\n\t\t\t} catch(IllegalStateException ignore) {\n\t\t\t}\n\t\t}\n\t\tfor (String key : sipApplicationSessionAttributeMap.keySet()) {\n\t\t\tremoveAttribute(key);\n\t\t}\n\t\tnotifySipApplicationSessionListeners(SipApplicationSessionEventType.DELETION);\n\t\tisValid = false;\t\n\t\tfor (Map.Entry<String, ServletTimer> servletTimerEntry : servletTimers.entrySet()) {\n\t\t\tServletTimer timerEntry = servletTimerEntry.getValue();\n\t\t\tif(timerEntry != null) {\n\t\t\t\ttimerEntry.cancel();\t\t\t\t\n\t\t\t}\n\t\t}\t\t\n\t\tif(!expired && expirationTimerFuture != null) {\n\t\t\tcancelExpirationTimer();\n\t\t}\n long timeNow = System.currentTimeMillis();\n int timeAlive = (int) ((timeNow - creationTime)/1000);\n SipManager manager = sipContext.getSipManager();\n synchronized (manager) {\n if (timeAlive > manager.getSipApplicationSessionMaxAliveTime()) {\n manager.setSipApplicationSessionMaxAliveTime(timeAlive);\n }\n int numExpired = manager.getExpiredSipApplicationSessions();\n numExpired++;\n manager.setExpiredSipApplicationSessions(numExpired);\n int average = manager.getSipApplicationSessionAverageAliveTime();\n average = ((average * (numExpired-1)) + timeAlive)/numExpired;\n manager.setSipApplicationSessionAverageAliveTime(average);\n }\n\t\tsipContext.getSipManager().removeSipApplicationSession(key);\t\t\n\t\texpirationTimerTask = null;\n\t\texpirationTimerFuture = null;\n\t\thttpSessions.clear();\n\t\tservletTimers.clear();\n\t\tsipApplicationSessionAttributeMap.clear();\n\t\tsipSessions.clear();\n\t\thttpSessions.clear();\n\t\texecutorService.shutdown();\n\t\texecutorService = null;\t\t\n\t\thttpSessions = null;\n\t\tsipSessions = null;\n\t\tsipApplicationSessionAttributeMap = null;\n\t\tservletTimers = null;\n\t\tsipContext = null;\t\t\n\t\tif(logger.isInfoEnabled()) {\n\t\t\tlogger.info(\"The following sip application session \" + key + \" has been invalidated\");\n\t\t}\n\t\tcurrentRequestHandler = null;\n\t\tkey = null;\t\t\n\t}\n"} {"input": " public static void main(String[] args)\n throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,\n InvocationTargetException, NoSuchFieldException {\n int[] arr = (int[]) Array.newInstance(int.class, 4);\n System.out.println(Arrays.toString(arr));\n int[][] mat = (int[][]) Array.newInstance(int.class, 2, 3);\n System.out.println(Arrays.deepToString(mat));\n System.out.println(Reflection.class.getEnclosingMethod());\n System.out.println(Reflection.classInMethod().getClass().getEnclosingMethod());\n SubClass sub = new SubClass();\n Field subf = Reflection.class.getDeclaredField(\"goodString\");\n System.out.println(subf.get(sub));\n Method iface_method = Iface.class.getMethod(\"inYourIface\", Object.class);\n iface_method.invoke(sub, \"foo\");\n Reflection obj = new Reflection();\n Class<Reflection> c = Reflection.class;\n Field f = c.getField(\"constValue\");\n System.out.println(f.get(null));\n Field f2 = c.getField(\"constInt\");\n System.out.println(f2.get(null));\n Field f3 = c.getField(\"constFloat\");\n System.out.println(f3.get(null));\n Field f4 = c.getField(\"constDouble\");\n System.out.println(f4.get(null));\n Field f5 = c.getField(\"constLong\");\n System.out.println(f5.get(null));\n Field f6 = c.getField(\"constShort\");\n System.out.println(f6.get(null));\n Field f7 = c.getField(\"constBool\");\n System.out.println(f7.get(null));\n Method bytecodeMethod = c.getClass().getMethod(\"toString\");\n Method nativeMethod = c.getClass().getMethod(\"isArray\");\n Method nativeMethodWithArgs = c.getClass().getMethod(\"isInstance\", Object.class);\n Method unboxingMethod = c.getMethod(\"add\", long.class, long.class);\n Method boxingMethod = c.getMethod(\"add\", Long.class, Long.class);\n Method voidMethod = c.getMethod(\"foo\");\n System.out.println(\"toString: \" + bytecodeMethod.invoke(c));\n System.out.println(\"is array? \" + nativeMethod.invoke(c));\n System.out.println(\"is instance? \" + nativeMethodWithArgs.invoke(c, obj));\n Long a = new Long(40L);\n Long b = new Long(2L);\n System.out.println(\"unboxing: \" + unboxingMethod.invoke(null, a, b));\n System.out.println(\"boxing: \" + boxingMethod.invoke(null, 1300L, 37L));\n System.out.println(\"void return: \" + voidMethod.invoke(null));\n System.out.println(\"Testing java.lang.reflect.Array.set\");\n byte[] byteArr = new byte[1];\n Array.set(byteArr, 0, new Byte((byte)1));\n System.out.println(byteArr[0]);\n char[] charArr = new char[1];\n Array.set(charArr, 0, new Character('a'));\n System.out.println(charArr[0]);\n double[] doubleArr = new double[1];\n Array.set(doubleArr, 0, new Double(1));\n System.out.println(doubleArr[0]);\n float[] floatArr = new float[1];\n Array.set(floatArr, 0, new Float(1));\n System.out.println(floatArr[0]);\n int[] intArr = new int[1];\n Array.set(intArr, 0, new Integer(1));\n System.out.println(intArr[0]);\n long[] longArr = new long[1];\n Array.set(longArr, 0, new Long(1));\n System.out.println(longArr[0]);\n short[] shortArr = new short[1];\n Array.set(shortArr, 0, new Short((short)1));\n System.out.println(shortArr[0]);\n boolean[] boolArr = new boolean[1];\n Array.set(boolArr, 0, new Boolean(true));\n System.out.println(boolArr[0]);\n Integer[] integerArr = new Integer[1];\n Array.set(integerArr, 0, new Integer(1));\n System.out.println(integerArr[0].getClass().getName());\n System.out.println(integerArr[0]);\n System.out.println(\"Checking Array.set's exceptions\");\n try {\n Array.set(charArr, 1, new Character('a'));\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n try {\n Array.set(charArr, -1, new Character('a'));\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n try {\n Array.set(byteArr, 0, new Character('a'));\n }\n catch (IllegalArgumentException e) {\n System.out.println(\"Caught IllegalArgumentException\");\n }\n try {\n Array.set(integerArr, 0, \"foo\");\n } catch (IllegalArgumentException e) {\n System.out.println(\"Caught IllegalArgumentException\");\n }\n try {\n Array.set(byteArr, 1, new Character('a'));\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n System.out.println(\"Testing java.lang.reflect.Array.get*\");\n System.out.println(Array.getLength(byteArr));\n System.out.println(Array.getByte(byteArr, 0));\n System.out.println(Array.getChar(charArr, 0));\n System.out.println(Array.getDouble(doubleArr, 0));\n System.out.println(Array.getFloat(floatArr, 0));\n System.out.println(Array.getInt(intArr, 0));\n System.out.println(Array.getLong(longArr, 0));\n System.out.println(Array.getShort(shortArr, 0));\n System.out.println(Array.getBoolean(boolArr, 0));\n System.out.println(Array.get(integerArr, 0).getClass().getName());\n System.out.println(\"Checking Array.get*'s exceptions\");\n try {\n Array.getChar(charArr, 1);\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n try {\n Array.getChar(charArr, -1);\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n }\n", "output": " public static void main(String[] args)\n throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,\n InvocationTargetException, NoSuchFieldException {\n int[] arr = (int[]) Array.newInstance(int.class, 4);\n System.out.println(Arrays.toString(arr));\n int[][] mat = (int[][]) Array.newInstance(int.class, 2, 3);\n System.out.println(Arrays.deepToString(mat));\n System.out.println(Reflection.class.getEnclosingMethod());\n System.out.println(Reflection.classInMethod().getClass().getEnclosingMethod());\n SubClass sub = new SubClass();\n Field subf = Reflection.class.getDeclaredField(\"goodString\");\n System.out.println(subf.get(sub));\n Method iface_method = Iface.class.getMethod(\"inYourIface\", Object.class);\n iface_method.invoke(sub, \"foo\");\n Reflection obj = new Reflection();\n Class<Reflection> c = Reflection.class;\n Field f = c.getField(\"constValue\");\n System.out.println(f.get(null));\n Field f2 = c.getField(\"constInt\");\n System.out.println(f2.get(null));\n Field f3 = c.getField(\"constFloat\");\n System.out.println(f3.get(null));\n Field f4 = c.getField(\"constDouble\");\n System.out.println(f4.get(null));\n Field f5 = c.getField(\"constLong\");\n System.out.println(f5.get(null));\n Field f6 = c.getField(\"constShort\");\n System.out.println(f6.get(null));\n Field f7 = c.getField(\"constBool\");\n System.out.println(f7.get(null));\n Method bytecodeMethod = c.getClass().getMethod(\"toString\");\n Method nativeMethod = c.getClass().getMethod(\"isArray\");\n Method nativeMethodWithArgs = c.getClass().getMethod(\"isInstance\", Object.class);\n Method unboxingMethod = c.getMethod(\"add\", long.class, long.class);\n Method boxingMethod = c.getMethod(\"add\", Long.class, Long.class);\n Method voidMethod = c.getMethod(\"foo\");\n System.out.println(\"toString: \" + bytecodeMethod.invoke(c));\n System.out.println(\"is array? \" + nativeMethod.invoke(c));\n System.out.println(\"is instance? \" + nativeMethodWithArgs.invoke(c, obj));\n Long a = new Long(40L);\n Long b = new Long(2L);\n System.out.println(\"unboxing: \" + unboxingMethod.invoke(null, a, b));\n System.out.println(\"boxing: \" + boxingMethod.invoke(null, 1300L, 37L));\n System.out.println(\"void return: \" + voidMethod.invoke(null));\n System.out.println(\"Testing java.lang.reflect.Array.set\");\n byte[] byteArr = new byte[1];\n Array.set(byteArr, 0, new Byte((byte)1));\n System.out.println(byteArr[0]);\n char[] charArr = new char[1];\n Array.set(charArr, 0, new Character('a'));\n System.out.println(charArr[0]);\n double[] doubleArr = new double[1];\n Array.set(doubleArr, 0, new Double(1));\n System.out.println(doubleArr[0]);\n float[] floatArr = new float[1];\n Array.set(floatArr, 0, new Float(1));\n System.out.println(floatArr[0]);\n int[] intArr = new int[1];\n Array.set(intArr, 0, new Integer(1));\n System.out.println(intArr[0]);\n long[] longArr = new long[1];\n Array.set(longArr, 0, new Long(1));\n System.out.println(longArr[0]);\n short[] shortArr = new short[1];\n Array.set(shortArr, 0, new Short((short)1));\n System.out.println(shortArr[0]);\n boolean[] boolArr = new boolean[1];\n Array.set(boolArr, 0, new Boolean(true));\n System.out.println(boolArr[0]);\n Integer[] integerArr = new Integer[1];\n Array.set(integerArr, 0, new Integer(1));\n System.out.println(integerArr[0].getClass().getName());\n System.out.println(integerArr[0]);\n System.out.println(\"Checking Array.set's exceptions\");\n try {\n Array.set(charArr, 1, new Character('a'));\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n try {\n Array.set(charArr, -1, new Character('a'));\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n try {\n Array.set(byteArr, 0, new Character('a'));\n }\n catch (IllegalArgumentException e) {\n System.out.println(\"Caught IllegalArgumentException\");\n }\n try {\n Array.set(integerArr, 0, \"foo\");\n } catch (IllegalArgumentException e) {\n System.out.println(\"Caught IllegalArgumentException\");\n }\n try {\n Array.set(byteArr, 1, new Character('a'));\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n System.out.println(\"Testing java.lang.reflect.Array.get*\");\n System.out.println(Array.getLength(byteArr));\n System.out.println(Array.getByte(byteArr, 0));\n System.out.println(Array.getChar(charArr, 0));\n System.out.println(Array.getDouble(doubleArr, 0));\n System.out.println(Array.getFloat(floatArr, 0));\n System.out.println(Array.getInt(intArr, 0));\n System.out.println(Array.getLong(longArr, 0));\n System.out.println(Array.getShort(shortArr, 0));\n System.out.println(Array.getBoolean(boolArr, 0));\n System.out.println(Array.get(integerArr, 0).getClass().getName());\n System.out.println(Array.get(intArr, 0).getClass().getName());\n System.out.println(\"Checking Array.get*'s exceptions\");\n try {\n Array.getChar(charArr, 1);\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n try {\n Array.getChar(charArr, -1);\n }\n catch (ArrayIndexOutOfBoundsException e) {\n System.out.println(\"Caught ArrayIndexOutOfBoundsException\");\n }\n }\n"} {"input": "\tpublic boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {\n\t\tif (command.getName().equalsIgnoreCase(\"maze\")) {\n\t\t\tPlayer player = null;\n\t\t\tif (sender instanceof Player)\n\t\t\t\tplayer = (Player) sender;\n\t\t\tif (args.length == 0) {\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"---------------- MazeMania Help -----------------\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"Player Commands:\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"/maze join - Join the MazeMania game\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"/maze leave - Leave the MazeMania game\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"/maze about - Show MazeMania credits and info\"));\n\t\t\t}\n\t\t\tif (args.length > 0) {\n\t\t\t\tif (args[0].equalsIgnoreCase(\"set\")) {\n\t\t\t\t\tif (!(sender instanceof Player)) {\n\t\t\t\t\t\tUtil.sendMessageNotPlayer(sender);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"admin\")) return true;\n\t\t\t\t\treturn setCommand.handle(sender, args);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"join\")) {\n\t\t\t\t\tif (!(sender instanceof Player)) {\n\t\t\t\t\t\tUtil.sendMessageNotPlayer(sender);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"use\")) return true;\n\t\t\t\t\treturn arenaCommand.joinHandle(player);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"leave\")) {\n\t\t\t\t\tif (!(sender instanceof Player)) {\n\t\t\t\t\t\tUtil.sendMessageNotPlayer(sender);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"use\")) return true;\n\t\t\t\t\treturn arenaCommand.leaveHandle(player);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"trigger\")) {\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"admin\")) return true;\n\t\t\t\t\treturn setCommand.triggerHandle(sender, args);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"block\")) {\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"admin\")) return true;\n\t\t\t\t\tif(args.length==1){\n\t\t\t\t\t\tsender.sendMessage(\"========================\");\n\t\t\t\t\t\tsender.sendMessage(\"Block Event Args\");\n\t\t\t\t\t\tfor (Trigger t:plugin.TriggerManager.getTriggers()){\n\t\t\t\t\t\t\tsender.sendMessage(Material.getMaterial(t.blockID).name() + \" \" + t.effect + \" \" + t.arguments);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsender.sendMessage(\"=========================\");\n\t\t\t\t\t}else if(args.length==2){\n\t\t\t\t\t\tplugin.TriggerManager.removeTrigger(Material.getMaterial(args[1]));\n\t\t\t\t\t}else if(args.length==3){\n\t\t\t\t\t\tplugin.TriggerManager.addTrigger(new Trigger(Material.matchMaterial(args[1]).getId(), args[2], \"\"));\n\t\t\t\t\t}else if(args.length>=4){\n\t\t\t\t\t\tplugin.TriggerManager.addTrigger(new Trigger(Material.matchMaterial(args[1]).getId(), args[2], plugin.util.join(args, \" \", 3)));\n\t\t\t\t\t}else{\n\t\t\t\t\t}\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"about\") || args[0].equalsIgnoreCase(\"info\")) {\n\t\t\t\t\tsender.sendMessage(Util.formatMessage(\"---------------------- \" + Util.pdfFile.getName() + \" ----------------------\"));\n\t\t\t\t\tsender.sendMessage(Util.formatMessage(plugin.getName() + \" developed by \" + Util.pdfFile.getAuthors().get(0)));\n\t\t\t\t\tsender.sendMessage(Util.formatMessage(\"To view more information visit http://plugmania.github.com/ (<-- You can click it!)\"));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {\n\t\tif (command.getName().equalsIgnoreCase(\"maze\")) {\n\t\t\tPlayer player = null;\n\t\t\tif (sender instanceof Player)\n\t\t\t\tplayer = (Player) sender;\n\t\t\tif (args.length == 0) {\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"---------------- MazeMania Help -----------------\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"Player Commands:\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"/maze join - Join the MazeMania game\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"/maze leave - Leave the MazeMania game\"));\n\t\t\t\tsender.sendMessage(Util.formatMessage(\"/maze about - Show MazeMania credits and info\"));\n\t\t\t}\n\t\t\tif (args.length > 0) {\n\t\t\t\tif (args[0].equalsIgnoreCase(\"set\")) {\n\t\t\t\t\tif (!(sender instanceof Player)) {\n\t\t\t\t\t\tUtil.sendMessageNotPlayer(sender);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"admin\")) return true;\n\t\t\t\t\treturn setCommand.handle(sender, args);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"join\")) {\n\t\t\t\t\tif (!(sender instanceof Player)) {\n\t\t\t\t\t\tUtil.sendMessageNotPlayer(sender);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"use\")) return true;\n\t\t\t\t\treturn arenaCommand.joinHandle(player);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"leave\")) {\n\t\t\t\t\tif (!(sender instanceof Player)) {\n\t\t\t\t\t\tUtil.sendMessageNotPlayer(sender);\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"use\")) return true;\n\t\t\t\t\treturn arenaCommand.leaveHandle(player);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"trigger\")) {\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"admin\")) return true;\n\t\t\t\t\treturn setCommand.triggerHandle(sender, args);\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"block\")) {\n\t\t\t\t\tif (!plugin.util.hasPermMsg(player, \"admin\")) return true;\n\t\t\t\t\tif(args.length==1){\n\t\t\t\t\t\tsender.sendMessage(\"========================\");\n\t\t\t\t\t\tsender.sendMessage(\"Block Event Args\");\n\t\t\t\t\t\tfor (Trigger t:plugin.TriggerManager.getTriggers()){\n\t\t\t\t\t\t\tsender.sendMessage(Material.getMaterial(t.blockID).name() + \" \" + t.effect + \" \" + t.arguments);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsender.sendMessage(\"=========================\");\n\t\t\t\t\t}else if(args.length==2){\n\t\t\t\t\t\tplugin.TriggerManager.removeTrigger(Material.matchMaterial(args[1]));\n\t\t\t\t\t}else if(args.length==3){\n\t\t\t\t\t\tplugin.TriggerManager.addTrigger(new Trigger(Material.matchMaterial(args[1]).getId(), args[2], \"\"));\n\t\t\t\t\t}else if(args.length>=4){\n\t\t\t\t\t\tplugin.TriggerManager.addTrigger(new Trigger(Material.matchMaterial(args[1]).getId(), args[2], plugin.util.join(args, \" \", 3)));\n\t\t\t\t\t}else{\n\t\t\t\t\t}\n\t\t\t\t} else if (args[0].equalsIgnoreCase(\"about\") || args[0].equalsIgnoreCase(\"info\")) {\n\t\t\t\t\tsender.sendMessage(Util.formatMessage(\"---------------------- \" + Util.pdfFile.getName() + \" ----------------------\"));\n\t\t\t\t\tsender.sendMessage(Util.formatMessage(plugin.getName() + \" developed by \" + Util.pdfFile.getAuthors().get(0)));\n\t\t\t\t\tsender.sendMessage(Util.formatMessage(\"To view more information visit http://plugmania.github.com/ (<-- You can click it!)\"));\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": " void readFolderList () throws IOException {\n String tag = writeCommand(mWriter, \"list \\\"\\\" *\");\n String line;\n char dchar = '/';\n userLog(\"Loading folder list...\");\n ArrayList<String> parentList = new ArrayList<String>();\n ArrayList<Mailbox> mailboxList = new ArrayList<Mailbox>();\n while (true) {\n line = mReader.readLine();\n userLog(line);\n if (line.startsWith(tag)) {\n break;\n } else {\n Parser p = new Parser(line, 2);\n String cmd = p.parseAtom();\n if (cmd.equalsIgnoreCase(\"list\")) {\n @SuppressWarnings(\"unused\")\n String props = p.parseListOrNil();\n String delim = p.parseString();\n if (delim == null)\n delim = \"~\";\n if (delim.length() == 1)\n dchar = delim.charAt(0);\n String serverId = p.parseStringOrAtom();\n int lastDelim = serverId.lastIndexOf(delim);\n String displayName;\n String parentName;\n if (lastDelim > 0) {\n displayName = serverId.substring(lastDelim + 1);\n parentName = serverId.substring(0, lastDelim);\n } else {\n displayName = serverId;\n parentName = null;\n }\n Mailbox m = new Mailbox();\n m.mDisplayName = displayName;\n m.mAccountKey = mAccountId;\n m.mServerId = serverId;\n if (parentName != null && !parentList.contains(parentName)) {\n parentList.add(parentName);\n }\n m.mFlagVisible = true;\n m.mParentServerId = parentName;\n m.mDelimiter = dchar;\n m.mSyncInterval = Mailbox.CHECK_INTERVAL_NEVER;\n mailboxList.add(m);\n } else {\n }\n }\n }\n Cursor c = mResolver.query(Mailbox.CONTENT_URI, Mailbox.CONTENT_PROJECTION,\n Mailbox.ACCOUNT_KEY + \"=?\", new String[] {Long.toString(mAccountId)},\n MailboxColumns.SERVER_ID + \" asc\");\n if (c == null) return;\n int cnt = c.getCount();\n String[] serverIds = new String[cnt];\n long[] uidvals = new long[cnt];\n long[] ids = new long[cnt];\n int i = 0;\n try {\n if (c.moveToFirst()) {\n do {\n serverIds[i] = c.getString(Mailbox.CONTENT_SERVER_ID_COLUMN);\n uidvals[i] = c.getLong(Mailbox.CONTENT_SYNC_KEY_COLUMN);\n ids[i] = c.getLong(Mailbox.CONTENT_ID_COLUMN);\n i++;\n } while (c.moveToNext());\n }\n } finally {\n c.close();\n }\n ArrayList<Mailbox> addList = new ArrayList<Mailbox>();\n for (Mailbox m: mailboxList) {\n int loc = Arrays.binarySearch(serverIds, m.mServerId);\n if (loc >= 0) {\n if (uidvals[loc] == 0) {\n uidvals[loc] = -1;\n } else {\n uidvals[loc] = -1;\n }\n } else {\n addList.add(m);\n }\n }\n ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();\n try {\n for (i = 0; i < cnt; i++) {\n String name = serverIds[i];\n long uidval = uidvals[i];\n if (uidval == 0 && !name.equals(\"Outbox\") &&\n !name.equalsIgnoreCase(INBOX_SERVER_NAME)) {\n ops.add(ContentProviderOperation.newDelete(ContentUris.withAppendedId(\n Mailbox.CONTENT_URI, ids[i])).build());\n userLog(\"Deleting unseen mailbox; no match: \" + name);\n } else if (uidval > 0 && !name.equalsIgnoreCase(INBOX_SERVER_NAME)) {\n boolean found = false;\n for (Mailbox m : addList) {\n tag = writeCommand(mWriter, \"status \\\"\" + m.mServerId + \"\\\" (UIDVALIDITY)\");\n if (readResponse(mReader, tag, \"STATUS\").equals(IMAP_OK)) {\n String str = mImapResponse.get(0).toLowerCase();\n int idx = str.indexOf(\"uidvalidity\");\n long num = readLong(str, idx + 12);\n if (uidval == num) {\n found = true;\n break;\n }\n }\n }\n if (!found) {\n ops.add(ContentProviderOperation.newDelete(ContentUris.withAppendedId(\n Mailbox.CONTENT_URI, ids[i])).build());\n userLog(\"Deleting uidval mailbox; no match: \" + name);\n }\n }\n }\n for (Mailbox m : addList) {\n String serverId = m.mServerId;\n if (serverId == null)\n continue;\n if (!serverId.equalsIgnoreCase(INBOX_SERVER_NAME)\n && !serverId.equalsIgnoreCase(\"Outbox\")) {\n m.mHierarchicalName = m.mServerId;\n m.mType = Mailbox.TYPE_MAIL;\n ops.add(ContentProviderOperation.newInsert(\n Mailbox.CONTENT_URI).withValues(m.toContentValues()).build());\n userLog(\"Adding new mailbox: \" + m.mServerId);\n }\n }\n applyBatch(ops);\n MailboxUtilities.fixupUninitializedParentKeys(mContext,\n Mailbox.ACCOUNT_KEY + \"=\" + mAccountId);\n } finally {\n SyncManager.kick(\"folder list\");\n }\n }\n", "output": " void readFolderList () throws IOException {\n String tag = writeCommand(mWriter, \"list \\\"\\\" *\");\n String line;\n char dchar = '/';\n userLog(\"Loading folder list...\");\n ArrayList<String> parentList = new ArrayList<String>();\n ArrayList<Mailbox> mailboxList = new ArrayList<Mailbox>();\n while (true) {\n line = mReader.readLine();\n userLog(line);\n if (line.startsWith(tag)) {\n break;\n } else {\n Parser p = new Parser(line, 2);\n String cmd = p.parseAtom();\n if (cmd.equalsIgnoreCase(\"list\")) {\n @SuppressWarnings(\"unused\")\n String props = p.parseListOrNil();\n String delim = p.parseString();\n if (delim == null)\n delim = \"~\";\n if (delim.length() == 1)\n dchar = delim.charAt(0);\n String serverId = p.parseStringOrAtom();\n int lastDelim = serverId.lastIndexOf(delim);\n String displayName;\n String parentName;\n if (lastDelim > 0) {\n displayName = serverId.substring(lastDelim + 1);\n parentName = serverId.substring(0, lastDelim);\n } else {\n displayName = serverId;\n parentName = null;\n }\n Mailbox m = new Mailbox();\n m.mDisplayName = decodeFolderName(displayName, null);\n m.mAccountKey = mAccountId;\n m.mServerId = decodeFolderName(serverId, null);\n if (parentName != null && !parentList.contains(parentName)) {\n parentList.add(parentName);\n }\n m.mFlagVisible = true;\n m.mParentServerId = parentName;\n m.mDelimiter = dchar;\n m.mSyncInterval = Mailbox.CHECK_INTERVAL_NEVER;\n mailboxList.add(m);\n } else {\n }\n }\n }\n Cursor c = mResolver.query(Mailbox.CONTENT_URI, Mailbox.CONTENT_PROJECTION,\n Mailbox.ACCOUNT_KEY + \"=?\", new String[] {Long.toString(mAccountId)},\n MailboxColumns.SERVER_ID + \" asc\");\n if (c == null) return;\n int cnt = c.getCount();\n String[] serverIds = new String[cnt];\n long[] uidvals = new long[cnt];\n long[] ids = new long[cnt];\n int i = 0;\n try {\n if (c.moveToFirst()) {\n do {\n serverIds[i] = c.getString(Mailbox.CONTENT_SERVER_ID_COLUMN);\n uidvals[i] = c.getLong(Mailbox.CONTENT_SYNC_KEY_COLUMN);\n ids[i] = c.getLong(Mailbox.CONTENT_ID_COLUMN);\n i++;\n } while (c.moveToNext());\n }\n } finally {\n c.close();\n }\n ArrayList<Mailbox> addList = new ArrayList<Mailbox>();\n for (Mailbox m: mailboxList) {\n int loc = Arrays.binarySearch(serverIds, m.mServerId);\n if (loc >= 0) {\n if (uidvals[loc] == 0) {\n uidvals[loc] = -1;\n } else {\n uidvals[loc] = -1;\n }\n } else {\n addList.add(m);\n }\n }\n ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();\n try {\n for (i = 0; i < cnt; i++) {\n String name = serverIds[i];\n long uidval = uidvals[i];\n if (uidval == 0 && !name.equals(\"Outbox\") &&\n !name.equalsIgnoreCase(INBOX_SERVER_NAME)) {\n ops.add(ContentProviderOperation.newDelete(ContentUris.withAppendedId(\n Mailbox.CONTENT_URI, ids[i])).build());\n userLog(\"Deleting unseen mailbox; no match: \" + name);\n } else if (uidval > 0 && !name.equalsIgnoreCase(INBOX_SERVER_NAME)) {\n boolean found = false;\n for (Mailbox m : addList) {\n tag = writeCommand(mWriter, \"status \\\"\" + m.mServerId + \"\\\" (UIDVALIDITY)\");\n if (readResponse(mReader, tag, \"STATUS\").equals(IMAP_OK)) {\n String str = mImapResponse.get(0).toLowerCase();\n int idx = str.indexOf(\"uidvalidity\");\n long num = readLong(str, idx + 12);\n if (uidval == num) {\n found = true;\n break;\n }\n }\n }\n if (!found) {\n ops.add(ContentProviderOperation.newDelete(ContentUris.withAppendedId(\n Mailbox.CONTENT_URI, ids[i])).build());\n userLog(\"Deleting uidval mailbox; no match: \" + name);\n }\n }\n }\n for (Mailbox m : addList) {\n String serverId = m.mServerId;\n if (serverId == null)\n continue;\n if (!serverId.equalsIgnoreCase(INBOX_SERVER_NAME)\n && !serverId.equalsIgnoreCase(\"Outbox\")) {\n m.mHierarchicalName = m.mServerId;\n m.mType = Mailbox.TYPE_MAIL;\n ops.add(ContentProviderOperation.newInsert(\n Mailbox.CONTENT_URI).withValues(m.toContentValues()).build());\n userLog(\"Adding new mailbox: \" + m.mServerId);\n }\n }\n applyBatch(ops);\n MailboxUtilities.fixupUninitializedParentKeys(mContext,\n Mailbox.ACCOUNT_KEY + \"=\" + mAccountId);\n } finally {\n SyncManager.kick(\"folder list\");\n }\n }\n"} {"input": "\tpublic void doOpen(final URI uri) {\n\t\tIFile file = getContainingResourceSetFile(uri);\n\t\tIWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();\n\t\tIEditorPart openEditor = null;\n\t\ttry {\n\t\t\tif (file != null) {\n\t\t\t\topenEditor = IDE.openEditor(page, file);\n\t\t\t} else if (uri.isArchive()) {\n\t\t\t\tIEditorInput input = new XtextReadonlyEditorInput(new ReadonlyArchiveStorage(uri));\n\t\t\t\topenEditor = IDE.openEditor(page, input, PlatformUI.getWorkbench().getEditorRegistry()\n\t\t\t\t\t\t.getDefaultEditor(uri.lastSegment()).getId());\n\t\t\t} else {\n\t\t\t\tURL url = FileLocator.toFileURL(new URL(uri.scheme()+ \":\" +uri.devicePath()));\n\t\t\t\tURI urlAsUri = URI.createURI(url.toString());\n\t\t\t\tString path = urlAsUri.toFileString();\n\t\t\t\tFile ioFile = new File(path);\n\t\t\t\tIEditorInput input = new XtextReadonlyEditorInput(new ReadonlyFileStorage(ioFile, uri));\n\t\t\t\topenEditor = IDE.openEditor(page, input, PlatformUI.getWorkbench().getEditorRegistry()\n\t\t\t\t\t\t.getDefaultEditor(uri.lastSegment()).getId());\n\t\t\t}\n\t\t} catch (PartInitException partInitException) {\n\t\t\tlogger.error(\"Error while opening editor part for EMF URI '\" + uri + \"'\",\n\t\t\t\t\tpartInitException);\n\t\t} catch (IOException e) {\n\t\t\tlogger.error(\"Error while opening editor part for EMF URI '\" + uri + \"'\", e);\n\t\t}\n\t\tif (openEditor != null && openEditor instanceof XtextEditor) {\n\t\t\tfinal XtextEditor edit = (XtextEditor) openEditor;\n\t\t\tif (uri.fragment()!=null) {\n\t\t\t\tedit.getDocument().readOnly(new UnitOfWork<Object>(){\n\t\t\t\tpublic Object exec(XtextResource resource) throws Exception {\n\t\t\t\t\tEObject object = resource.getEObject(uri.fragment());\n\t\t\t\t\tRegion region = locationProvider.getLocation(object);\n\t\t\t\t\tedit.selectAndReveal(region.getOffset(),region.getLength());\n\t\t\t\t\treturn null;\n\t\t\t\t}});\n\t\t\t}\n\t\t} else if (openEditor instanceof ISelectionProvider) {\n\t\t}\n\t}\n", "output": "\tpublic void doOpen(final URI uri) {\n\t\tIFile file = getContainingResourceSetFile(uri);\n\t\tIWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();\n\t\tIEditorPart openEditor = null;\n\t\ttry {\n\t\t\tif (file != null) {\n\t\t\t\topenEditor = IDE.openEditor(page, file);\n\t\t\t} else if (uri.isArchive()) {\n\t\t\t\tIEditorInput input = new XtextReadonlyEditorInput(new ReadonlyArchiveStorage(uri));\n\t\t\t\topenEditor = IDE.openEditor(page, input, PlatformUI.getWorkbench().getEditorRegistry()\n\t\t\t\t\t\t.getDefaultEditor(uri.lastSegment()).getId());\n\t\t\t} else {\n\t\t\t\tURL url = FileLocator.toFileURL(new URL(uri.scheme()+ \":\" +uri.devicePath()));\n\t\t\t\tURI urlAsUri = URI.createURI(url.toString());\n\t\t\t\tString path = urlAsUri.toFileString();\n\t\t\t\tif (path != null) {\n\t\t\t\t\tFile ioFile = new File(path);\n\t\t\t\t\tIEditorInput input = new XtextReadonlyEditorInput(new ReadonlyFileStorage(ioFile, uri));\n\t\t\t\t\topenEditor = IDE.openEditor(page, input, PlatformUI.getWorkbench().getEditorRegistry()\n\t\t\t\t\t\t\t.getDefaultEditor(uri.lastSegment()).getId());\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (PartInitException partInitException) {\n\t\t\tlogger.error(\"Error while opening editor part for EMF URI '\" + uri + \"'\",\n\t\t\t\t\tpartInitException);\n\t\t} catch (IOException e) {\n\t\t\tlogger.error(\"Error while opening editor part for EMF URI '\" + uri + \"'\", e);\n\t\t}\n\t\tif (openEditor != null && openEditor instanceof XtextEditor) {\n\t\t\tfinal XtextEditor edit = (XtextEditor) openEditor;\n\t\t\tif (uri.fragment()!=null) {\n\t\t\t\tedit.getDocument().readOnly(new UnitOfWork<Object>(){\n\t\t\t\tpublic Object exec(XtextResource resource) throws Exception {\n\t\t\t\t\tEObject object = resource.getEObject(uri.fragment());\n\t\t\t\t\tRegion region = locationProvider.getLocation(object);\n\t\t\t\t\tedit.selectAndReveal(region.getOffset(),region.getLength());\n\t\t\t\t\treturn null;\n\t\t\t\t}});\n\t\t\t}\n\t\t} else if (openEditor instanceof ISelectionProvider) {\n\t\t}\n\t}\n"} {"input": "\tpublic boolean inject(World world, EntityLiving entity, ItemStack syringe)\n\t{\n\t\tif(world.rand.nextInt(100) < 5)\n\t\t{\n\t\t\tEntity e;\n\t\t\tif(entity instanceof EntityPig)\n\t\t\t{\n\t\t\t\te = new EntityZombie(world);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te = new EntityPigZombie(world);\n\t\t\t}\n\t\t\te.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);\n\t\t\tworld.spawnEntityInWorld(e);\n\t\t\tentity.setDead();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t((EntityAgeable)entity).setGrowingAge(0);\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean inject(World world, EntityLiving entity, ItemStack syringe)\n\t{\n\t\tif(world.rand.nextInt(100) < 5)\n\t\t{\n\t\t\tEntity e;\n\t\t\tif(entity instanceof EntityPig)\n\t\t\t{\n\t\t\t\te = new EntityPigZombie(world);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\te = new EntityZombie(world);\n\t\t\t}\n\t\t\te.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);\n\t\t\tworld.spawnEntityInWorld(e);\n\t\t\tentity.setDead();\n\t\t}\n\t\telse\n\t\t{\n\t\t\t((EntityAgeable)entity).setGrowingAge(0);\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": "\tpublic void issue(Database db, ServerCredentials cred) throws APIException {\n\t\tURI uri;\n\t\tif (!query.contains(\"key=\") && key != null) {\n\t\t\tString suffix = (query.contains(\"?\")) ? \"&key=\"+key : \"?key=\"+key;\n\t\t\tquery = query + suffix;\n\t\t}\n\t\tmethod = method.toLowerCase();\n\t\tLog.i(TAG, \"Request \"+ method +\": \" + query);\n\t\ttry {\n\t\t\turi = new URI(query);\n\t\t} catch (URISyntaxException e1) {\n\t\t\tthrow new APIException(APIException.INVALID_URI, \"Invalid URI: \"+query, this);\n\t\t}\n\t\tHttpClient client = new DefaultHttpClient();\n\t\tclient.getParams().setParameter(\"http.protocol.expect-continue\", false);\n\t\tclient.getParams().setParameter(\"http.protocol.content-charset\", \"UTF-8\");\n\t\tHttpGet get = new HttpGet(uri);\n\t\tHttpPost post = new HttpPost(uri);\n\t\tHttpPut put = new HttpPut(uri);\n\t\tHttpDelete delete = new HttpDelete(uri);\n\t\tif (\"post\".equals(method) || \"put\".equals(method)) {\n\t\t\tif(ifMatch != null) {\n\t\t\t\tpost.setHeader(\"If-Match\", ifMatch);\n\t\t\t\tput.setHeader(\"If-Match\", ifMatch);\n\t\t\t}\n\t\t\tif(contentType != null) {\n\t\t\t\tpost.setHeader(\"Content-Type\", contentType);\n\t\t\t\tput.setHeader(\"Content-Type\", contentType);\n\t\t\t}\n\t\t\tif (body != null) {\n\t\t\t\tLog.d(TAG, \"Request body: \"+body);\n\t\t\t\tStringEntity entity;\n\t\t\t\ttry {\n\t\t\t\t\tentity = new StringEntity(body,\"UTF-8\");\n\t\t\t\t} catch (UnsupportedEncodingException e) {\n\t\t\t\t\tthrow new APIException(APIException.INVALID_UUID,\n\t\t\t\t\t\t\t\"UnsupportedEncodingException. This shouldn't \" +\n\t\t\t\t\t\t\t\"be possible-- UTF-8 is certainly supported\", this);\n\t\t\t\t}\n\t\t\t\tpost.setEntity(entity);\n\t\t\t\tput.setEntity(entity);\n\t\t\t}\n\t\t}\n\t\tif (\"get\".equals(method)) {\n\t\t\tif(contentType != null) {\n\t\t\t\tget.setHeader(\"Content-Type\", contentType);\n\t\t\t}\n\t\t}\n\t\tif (\"xml\".equals(disposition)) {\n\t\t\tXMLResponseParser parse = new XMLResponseParser(this);\n\t\t\tif (type == ITEM_NEW\n\t\t\t\t\t|| type == ITEM_ATTACHMENT_NEW) {\n\t\t\t\tparse.update(updateType, updateKey);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tHttpResponse hr;\n\t\t\t\tif (\"post\".equals(method)) {\n\t\t\t\t\thr = client.execute(post);\n\t\t\t\t} else if (\"put\".equals(method)) {\n\t\t\t\t\thr = client.execute(put);\n\t\t\t\t} else {\n\t\t\t\t\tif (!\"get\".equals(method)) {\n\t\t\t\t\t\tthrow new APIException(APIException.INVALID_METHOD,\n\t\t\t\t\t\t\t\t\"Unexpected method: \"+method, this);\n\t\t\t\t\t}\n\t\t\t\t\thr = client.execute(get);\n\t\t\t\t}\n\t\t\t\tstatus = hr.getStatusLine().getStatusCode();\n\t\t\t\tLog.d(TAG, status + \" : \"+ hr.getStatusLine().getReasonPhrase());\n\t\t\t\tif (status < 400) {\n\t\t\t\t\tHttpEntity he = hr.getEntity();\n\t\t\t\t\tInputStream in = he.getContent();\n\t\t\t\t\tparse.setInputStream(in);\n\t\t\t\t\tint mode = (\"put\".equals(method) || type == APIRequest.ITEM_BY_KEY) ?\n\t\t\t\t\t\t\tXMLResponseParser.MODE_ENTRY : XMLResponseParser.MODE_FEED;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tparse.parse(mode, uri.toString(), db);\n\t\t\t\t\t} catch (RuntimeException e) {\n\t\t\t\t\t\tthrow new RuntimeException(\"Parser threw exception on request: \"+method+\" \"+query, e);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tByteArrayOutputStream ostream = new ByteArrayOutputStream();\n\t\t\t\t\thr.getEntity().writeTo(ostream);\n\t\t\t\t\tLog.e(TAG,\"Error Body: \"+ ostream.toString());\n\t\t\t\t\tLog.e(TAG,\"Request Body:\"+ body);\n\t\t\t\t\tif (status == 412) {\n\t\t\t\t\t\tgetHandler().onError(this, APIRequest.HTTP_ERROR_CONFLICT);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.e(TAG, \"Response status \"+status+\" : \"+ostream.toString());\n\t\t\t\t\t\tgetHandler().onError(this, APIRequest.HTTP_ERROR_UNSPECIFIED);\n\t\t\t\t\t}\n\t\t\t\t\tstatus = getHttpStatus() + REQ_FAILING;\n\t\t\t\t\trecordAttempt(db);\n\t\t\t\t\tthrow new APIException(APIException.HTTP_ERROR, ostream.toString(), this);\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tfor (StackTraceElement el : e.getStackTrace()) {\n\t\t\t\t\tsb.append(el.toString()+\"\\n\");\n\t\t\t\t}\n\t\t\t\trecordAttempt(db);\n\t\t\t\tthrow new APIException(APIException.HTTP_ERROR,\n\t\t\t\t\t\t\"An IOException was thrown: \" + sb.toString(), this);\n\t\t\t}\n\t\t} \n\t\telse {\n\t\t\tBasicResponseHandler brh = new BasicResponseHandler();\n\t\t\tString resp;\n\t\t\ttry {\n\t\t\t\tif (\"post\".equals(method)) {\n\t\t\t\t\tresp = client.execute(post, brh);\n\t\t\t\t} else if (\"put\".equals(method)) {\n\t\t\t\t\tresp = client.execute(put, brh);\n\t\t\t\t} else if (\"delete\".equals(method)) {\n\t\t\t\t\tresp = client.execute(delete, brh);\n\t\t\t\t} else {\n\t\t\t\t\tif (!\"get\".equals(method)) {\n\t\t\t\t\t\tthrow new APIException(APIException.INVALID_METHOD,\n\t\t\t\t\t\t\t\t\"Unexpected method: \"+method, this);\n\t\t\t\t\t}\n\t\t\t\t\tresp = client.execute(get, brh);\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tfor (StackTraceElement el : e.getStackTrace()) {\n\t\t\t\t\tsb.append(el.toString()+\"\\n\");\n\t\t\t\t}\n\t\t\t\trecordAttempt(db);\n\t\t\t\tthrow new APIException(APIException.HTTP_ERROR,\n\t\t\t\t\t\t\"An IOException was thrown: \" + sb.toString(), this);\n\t\t\t}\n\t\t\tif (\"raw\".equals(disposition)) {\n\t\t\t\tString[] keys = resp.split(\"\\n\");\n\t\t\t\tArrayList<String> missing = new ArrayList<String>();\n\t\t\t\tif (type == ITEMS_ALL ||\n\t\t\t\t\t\ttype == ITEMS_FOR_COLLECTION) {\n \t\tint colloc = query.indexOf(\"/collections/\");\n \t\tint itemloc = query.indexOf(\"/items\");\n\t\t\t\t\tItemCollection coll = ItemCollection.load(\n\t\t\t\t\t\t\tquery.substring(colloc+13, itemloc), db);\n\t\t\t\t\tif (coll != null) {\n\t\t\t\t\t\tcoll.loadChildren(db);\n\t\t\t\t\t\tArrayList<String> keyAL = new ArrayList<String>(Arrays.asList(keys));\n\t\t\t\t\t\tArrayList<Item> notThere = coll.notInKeys(keyAL);\n\t\t\t\t\t\tfor (Item i : notThere) {\n\t\t\t\t\t\t\tcoll.remove(i, true, db);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tArrayList<Item> recd = new ArrayList<Item>();\n\t\t\t\t\tfor (int j = 0; j < keys.length; j++) {\n\t\t\t\t\t\tItem got = Item.load(keys[j], db);\n\t\t\t\t\t\tif (got == null) {\n\t\t\t\t\t\t\tmissing.add(keys[j]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (coll != null) coll.add(got, true, db);\n\t\t\t\t\t\t\trecd.add(got);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (coll != null) {\n\t\t\t\t\t\tcoll.saveChildren(db);\n\t\t\t\t\t\tcoll.save(db);\n\t\t\t\t\t}\n\t\t\t\t\tLog.d(TAG, \"Received \"+keys.length+\" keys, \"+missing.size() + \" missing ones\");\n\t\t\t\t\tLog.d(TAG, \"Have \"+(double) recd.size() / keys.length + \" of list\");\n\t\t\t\t\tif (recd.size() == keys.length) {\n\t\t\t\t\t\tLog.d(TAG, \"No new items\");\n\t\t\t\t\t\tsucceeded(db);\n\t\t\t\t\t} else if ((double) recd.size() / keys.length < REREQUEST_CUTOFF) {\n\t\t\t\t\t\tLog.d(TAG, \"Requesting full list\");\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tif (type == ITEMS_FOR_COLLECTION) {\n\t\t\t\t\t\t\tmReq = fetchItems(coll, false, cred);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmReq = fetchItems(false, cred);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.d(TAG, \"Requesting \"+missing.size()+\" items one by one\");\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tfor (String key : missing) {\n\t\t\t\t\t\t\tmReq = fetchItem(key, cred);\n\t\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (type == ITEMS_FOR_COLLECTION) {\n\t\t\t\t\t\t\tfetchItems(coll, true, cred).save(db);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (type == ITEMS_CHILDREN) {\n \t\tint itemloc = query.indexOf(\"/items/\");\n \t\tint childloc = query.indexOf(\"/children\");\n\t\t\t\t\tItem item = Item.load(\n\t\t\t\t\t\t\tquery.substring(itemloc+7, childloc), db);\n\t\t\t\t\tArrayList<Attachment> recd = new ArrayList<Attachment>();\n\t\t\t\t\tfor (int j = 0; j < keys.length; j++) {\n\t\t\t\t\t\tAttachment got = Attachment.load(keys[j], db);\n\t\t\t\t\t\tif (got == null) missing.add(keys[j]);\n\t\t\t\t\t\telse recd.add(got);\n\t\t\t\t\t}\n\t\t\t\t\tif ((double) recd.size() / keys.length < REREQUEST_CUTOFF) {\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tmReq = cred.prep(children(item));\n\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tfor (String key : missing) {\n\t\t\t\t\t\t\tmReq = fetchItem(key, cred);\n\t\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\"json\".equals(disposition)) {\n\t\t\t} else {\n\t\t\t}\n\t\t\tgetHandler().onComplete(this);\n\t\t}\n\t}\n", "output": "\tpublic void issue(Database db, ServerCredentials cred) throws APIException {\n\t\tURI uri;\n\t\tif (!query.contains(\"key=\") && key != null) {\n\t\t\tString suffix = (query.contains(\"?\")) ? \"&key=\"+key : \"?key=\"+key;\n\t\t\tquery = query + suffix;\n\t\t}\n\t\tmethod = method.toLowerCase();\n\t\tLog.i(TAG, \"Request \"+ method +\": \" + query);\n\t\ttry {\n\t\t\turi = new URI(query);\n\t\t} catch (URISyntaxException e1) {\n\t\t\tthrow new APIException(APIException.INVALID_URI, \"Invalid URI: \"+query, this);\n\t\t}\n\t\tHttpClient client = new DefaultHttpClient();\n\t\tclient.getParams().setParameter(\"http.protocol.expect-continue\", false);\n\t\tclient.getParams().setParameter(\"http.protocol.content-charset\", \"UTF-8\");\n\t\tHttpGet get = new HttpGet(uri);\n\t\tHttpPost post = new HttpPost(uri);\n\t\tHttpPut put = new HttpPut(uri);\n\t\tHttpDelete delete = new HttpDelete(uri);\n\t\tif (\"post\".equals(method) || \"put\".equals(method)) {\n\t\t\tif(ifMatch != null) {\n\t\t\t\tpost.setHeader(\"If-Match\", ifMatch);\n\t\t\t\tput.setHeader(\"If-Match\", ifMatch);\n\t\t\t}\n\t\t\tif(contentType != null) {\n\t\t\t\tpost.setHeader(\"Content-Type\", contentType);\n\t\t\t\tput.setHeader(\"Content-Type\", contentType);\n\t\t\t}\n\t\t\tif (body != null) {\n\t\t\t\tLog.d(TAG, \"Request body: \"+body);\n\t\t\t\tStringEntity entity;\n\t\t\t\ttry {\n\t\t\t\t\tentity = new StringEntity(body,\"UTF-8\");\n\t\t\t\t} catch (UnsupportedEncodingException e) {\n\t\t\t\t\tthrow new APIException(APIException.INVALID_UUID,\n\t\t\t\t\t\t\t\"UnsupportedEncodingException. This shouldn't \" +\n\t\t\t\t\t\t\t\"be possible-- UTF-8 is certainly supported\", this);\n\t\t\t\t}\n\t\t\t\tpost.setEntity(entity);\n\t\t\t\tput.setEntity(entity);\n\t\t\t}\n\t\t}\n\t\tif (\"get\".equals(method)) {\n\t\t\tif(contentType != null) {\n\t\t\t\tget.setHeader(\"Content-Type\", contentType);\n\t\t\t}\n\t\t}\n\t\tif (\"xml\".equals(disposition)) {\n\t\t\tXMLResponseParser parse = new XMLResponseParser(this);\n\t\t\tif (type == ITEM_NEW\n\t\t\t\t\t|| type == ITEM_ATTACHMENT_NEW) {\n\t\t\t\tparse.update(updateType, updateKey);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tHttpResponse hr;\n\t\t\t\tif (\"post\".equals(method)) {\n\t\t\t\t\thr = client.execute(post);\n\t\t\t\t} else if (\"put\".equals(method)) {\n\t\t\t\t\thr = client.execute(put);\n\t\t\t\t} else {\n\t\t\t\t\tif (!\"get\".equals(method)) {\n\t\t\t\t\t\tthrow new APIException(APIException.INVALID_METHOD,\n\t\t\t\t\t\t\t\t\"Unexpected method: \"+method, this);\n\t\t\t\t\t}\n\t\t\t\t\thr = client.execute(get);\n\t\t\t\t}\n\t\t\t\tstatus = hr.getStatusLine().getStatusCode();\n\t\t\t\tLog.d(TAG, status + \" : \"+ hr.getStatusLine().getReasonPhrase());\n\t\t\t\tif (status < 400) {\n\t\t\t\t\tHttpEntity he = hr.getEntity();\n\t\t\t\t\tInputStream in = he.getContent();\n\t\t\t\t\tparse.setInputStream(in);\n\t\t\t\t\tint mode = (\"put\".equals(method) || type == APIRequest.ITEM_BY_KEY) ?\n\t\t\t\t\t\t\tXMLResponseParser.MODE_ENTRY : XMLResponseParser.MODE_FEED;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tparse.parse(mode, uri.toString(), db);\n\t\t\t\t\t} catch (RuntimeException e) {\n\t\t\t\t\t\tthrow new RuntimeException(\"Parser threw exception on request: \"+method+\" \"+query, e);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tByteArrayOutputStream ostream = new ByteArrayOutputStream();\n\t\t\t\t\thr.getEntity().writeTo(ostream);\n\t\t\t\t\tLog.e(TAG,\"Error Body: \"+ ostream.toString());\n\t\t\t\t\tLog.e(TAG,\"Request Body:\"+ body);\n\t\t\t\t\tif (status == 412) {\n\t\t\t\t\t\tgetHandler().onError(this, APIRequest.HTTP_ERROR_CONFLICT);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.e(TAG, \"Response status \"+status+\" : \"+ostream.toString());\n\t\t\t\t\t\tgetHandler().onError(this, APIRequest.HTTP_ERROR_UNSPECIFIED);\n\t\t\t\t\t}\n\t\t\t\t\tstatus = getHttpStatus() + REQ_FAILING;\n\t\t\t\t\trecordAttempt(db);\n\t\t\t\t\tthrow new APIException(APIException.HTTP_ERROR, ostream.toString(), this);\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tfor (StackTraceElement el : e.getStackTrace()) {\n\t\t\t\t\tsb.append(el.toString()+\"\\n\");\n\t\t\t\t}\n\t\t\t\trecordAttempt(db);\n\t\t\t\tthrow new APIException(APIException.HTTP_ERROR,\n\t\t\t\t\t\t\"An IOException was thrown: \" + sb.toString(), this);\n\t\t\t}\n\t\t} \n\t\telse {\n\t\t\tBasicResponseHandler brh = new BasicResponseHandler();\n\t\t\tString resp;\n\t\t\ttry {\n\t\t\t\tif (\"post\".equals(method)) {\n\t\t\t\t\tresp = client.execute(post, brh);\n\t\t\t\t} else if (\"put\".equals(method)) {\n\t\t\t\t\tresp = client.execute(put, brh);\n\t\t\t\t} else if (\"delete\".equals(method)) {\n\t\t\t\t\tresp = client.execute(delete, brh);\n\t\t\t\t} else {\n\t\t\t\t\tif (!\"get\".equals(method)) {\n\t\t\t\t\t\tthrow new APIException(APIException.INVALID_METHOD,\n\t\t\t\t\t\t\t\t\"Unexpected method: \"+method, this);\n\t\t\t\t\t}\n\t\t\t\t\tresp = client.execute(get, brh);\n\t\t\t\t}\n\t\t\t} catch (IOException e) {\n\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\tfor (StackTraceElement el : e.getStackTrace()) {\n\t\t\t\t\tsb.append(el.toString()+\"\\n\");\n\t\t\t\t}\n\t\t\t\trecordAttempt(db);\n\t\t\t\tthrow new APIException(APIException.HTTP_ERROR,\n\t\t\t\t\t\t\"An IOException was thrown: \" + sb.toString(), this);\n\t\t\t}\n\t\t\tif (\"raw\".equals(disposition)) {\n\t\t\t\tString[] keys = resp.split(\"\\n\");\n\t\t\t\tArrayList<String> missing = new ArrayList<String>();\n\t\t\t\tif (type == ITEMS_ALL ||\n\t\t\t\t\t\ttype == ITEMS_FOR_COLLECTION) {\n \t\tint colloc = query.indexOf(\"/collections/\");\n \t\tint itemloc = query.indexOf(\"/items\");\n\t\t\t\t\tItemCollection coll = ItemCollection.load(\n\t\t\t\t\t\t\tquery.substring(colloc+13, itemloc), db);\n\t\t\t\t\tif (coll != null) {\n\t\t\t\t\t\tcoll.loadChildren(db);\n\t\t\t\t\t\tArrayList<String> keyAL = new ArrayList<String>(Arrays.asList(keys));\n\t\t\t\t\t\tArrayList<Item> notThere = coll.notInKeys(keyAL);\n\t\t\t\t\t\tfor (Item i : notThere) {\n\t\t\t\t\t\t\tcoll.remove(i, true, db);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tArrayList<Item> recd = new ArrayList<Item>();\n\t\t\t\t\tfor (int j = 0; j < keys.length; j++) {\n\t\t\t\t\t\tItem got = Item.load(keys[j], db);\n\t\t\t\t\t\tif (got == null) {\n\t\t\t\t\t\t\tmissing.add(keys[j]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (coll != null) coll.add(got, true, db);\n\t\t\t\t\t\t\trecd.add(got);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (coll != null) {\n\t\t\t\t\t\tcoll.saveChildren(db);\n\t\t\t\t\t\tcoll.save(db);\n\t\t\t\t\t}\n\t\t\t\t\tLog.d(TAG, \"Received \"+keys.length+\" keys, \"+missing.size() + \" missing ones\");\n\t\t\t\t\tLog.d(TAG, \"Have \"+(double) recd.size() / keys.length + \" of list\");\n\t\t\t\t\tif (recd.size() == keys.length) {\n\t\t\t\t\t\tLog.d(TAG, \"No new items\");\n\t\t\t\t\t\tsucceeded(db);\n\t\t\t\t\t} else if ((double) recd.size() / keys.length < REREQUEST_CUTOFF) {\n\t\t\t\t\t\tLog.d(TAG, \"Requesting full list\");\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tif (type == ITEMS_FOR_COLLECTION) {\n\t\t\t\t\t\t\tmReq = fetchItems(coll, false, cred);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmReq = fetchItems(false, cred);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLog.d(TAG, \"Requesting \"+missing.size()+\" items one by one\");\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tfor (String key : missing) {\n\t\t\t\t\t\t\tmReq = fetchItem(key, cred);\n\t\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (type == ITEMS_FOR_COLLECTION) {\n\t\t\t\t\t\t\tfetchItems(coll, true, cred).save(db);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (type == ITEMS_CHILDREN) {\n \t\tint itemloc = query.indexOf(\"/items/\");\n \t\tint childloc = query.indexOf(\"/children\");\n\t\t\t\t\tItem item = Item.load(\n\t\t\t\t\t\t\tquery.substring(itemloc+7, childloc), db);\n\t\t\t\t\tArrayList<Attachment> recd = new ArrayList<Attachment>();\n\t\t\t\t\tfor (int j = 0; j < keys.length; j++) {\n\t\t\t\t\t\tAttachment got = Attachment.load(keys[j], db);\n\t\t\t\t\t\tif (got == null) missing.add(keys[j]);\n\t\t\t\t\t\telse recd.add(got);\n\t\t\t\t\t}\n\t\t\t\t\tif ((double) recd.size() / keys.length < REREQUEST_CUTOFF) {\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tmReq = cred.prep(children(item));\n\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tAPIRequest mReq;\n\t\t\t\t\t\tfor (String key : missing) {\n\t\t\t\t\t\t\tmReq = fetchItem(key, cred);\n\t\t\t\t\t\t\tmReq.status = REQ_NEW;\n\t\t\t\t\t\t\tmReq.save(db);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (\"json\".equals(disposition)) {\n\t\t\t} else {\n\t\t\t}\n\t\t\tgetHandler().onComplete(this);\n\t\t}\n\t}\n"} {"input": " public void testSetAndGetCommandArgs() throws Exception {\n Command command = new Command();\n Object[] args = new Object[2];\n args[0] = new String(\"foo\");\n args[1] = new Integer(1);\n command.setCommandArgs(args);\n Object[] outArgs = command.getCommandArgs();\n assertEquals(\"foo\", outArgs[0]);\n assertEquals(2, outArgs[1]);\n }\n", "output": " public void testSetAndGetCommandArgs() throws Exception {\n Command command = new Command();\n Object[] args = new Object[2];\n args[0] = new String(\"foo\");\n args[1] = new Integer(1);\n command.setCommandArgs(args);\n Object[] outArgs = command.getCommandArgs();\n assertEquals(\"foo\", outArgs[0]);\n assertEquals(1, outArgs[1]);\n }\n"} {"input": "\tpublic static XSDatatype getTypeByName( String dataTypeName ) {\n\t\tXSDatatype dt = (XSDatatype)builtinType.get(dataTypeName);\n\t\tif(dt!=null)\treturn dt;\n\t\ttry {\n\t\t\tif( dataTypeName.equals(\"float\") )\n\t\t\t\tadd( builtinType, FloatType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"double\") )\n\t\t\t\tadd( builtinType, DoubleType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"duration\") )\n\t\t\t\tadd( builtinType, DurationType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"dateTime\") )\n\t\t\t\tadd( builtinType, DateTimeType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"time\") )\n\t\t\t\tadd( builtinType, TimeType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"date\") )\n\t\t\t\tadd( builtinType, DateType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gYearMonth\") )\n\t\t\t\tadd( builtinType, GYearMonthType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gYear\") )\n\t\t\t\tadd( builtinType, GYearType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gMonthDay\") )\n\t\t\t\tadd( builtinType, GMonthDayType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gDay\") )\n\t\t\t\tadd( builtinType, GDayType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gMonth\") )\n\t\t\t\tadd( builtinType, GMonthType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"hexBinary\") )\n\t\t\t\tadd( builtinType, HexBinaryType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"base64Binary\") )\n\t\t\t\tadd( builtinType, Base64BinaryType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"anyURI\") )\n\t\t\t\tadd( builtinType, AnyURIType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"entity\") )\n\t\t\t\tadd( builtinType, EntityType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"language\") )\n\t\t\t\tadd( builtinType, LanguageType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"ENTITIES\") )\n\t\t\t\tadd( builtinType, new ListType(\"ENTITIES\",EntityType.theInstance) );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"NMTOKENS\") )\n\t\t\t\tadd( builtinType, new ListType(\"NMTOKENS\",NmtokenType.theInstance) );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"NOTATION\") )\n\t\t\t\tadd( builtinType, new StringType(\"NOTATION\", WhiteSpaceProcessor.theCollapse) );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"nonPositiveInteger\") )\n\t\t\t\tadd( builtinType, NonPositiveIntegerType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedLong\") )\n\t\t\t\tadd( builtinType, UnsignedLongType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedInt\") )\n\t\t\t\tadd( builtinType, UnsignedIntType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedShort\") )\n\t\t\t\tadd( builtinType, UnsignedShortType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedByte\") )\n\t\t\t\tadd( builtinType, UnsignedByteType.theInstance );\n\t\t} catch( DatatypeException dte )\t{\n\t\t\tthrow new Error();\n\t\t}\n\t\treturn (XSDatatype)builtinType.get(dataTypeName);\n\t}\n", "output": "\tpublic static XSDatatype getTypeByName( String dataTypeName ) {\n\t\tXSDatatype dt = (XSDatatype)builtinType.get(dataTypeName);\n\t\tif(dt!=null)\treturn dt;\n\t\ttry {\n\t\t\tif( dataTypeName.equals(\"float\") )\n\t\t\t\tadd( builtinType, FloatType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"double\") )\n\t\t\t\tadd( builtinType, DoubleType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"duration\") )\n\t\t\t\tadd( builtinType, DurationType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"dateTime\") )\n\t\t\t\tadd( builtinType, DateTimeType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"time\") )\n\t\t\t\tadd( builtinType, TimeType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"date\") )\n\t\t\t\tadd( builtinType, DateType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gYearMonth\") )\n\t\t\t\tadd( builtinType, GYearMonthType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gYear\") )\n\t\t\t\tadd( builtinType, GYearType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gMonthDay\") )\n\t\t\t\tadd( builtinType, GMonthDayType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gDay\") )\n\t\t\t\tadd( builtinType, GDayType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"gMonth\") )\n\t\t\t\tadd( builtinType, GMonthType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"hexBinary\") )\n\t\t\t\tadd( builtinType, HexBinaryType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"base64Binary\") )\n\t\t\t\tadd( builtinType, Base64BinaryType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"anyURI\") )\n\t\t\t\tadd( builtinType, AnyURIType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"ENTITY\") )\n\t\t\t\tadd( builtinType, EntityType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"language\") )\n\t\t\t\tadd( builtinType, LanguageType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"ENTITIES\") )\n\t\t\t\tadd( builtinType, new ListType(\"ENTITIES\",EntityType.theInstance) );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"NMTOKENS\") )\n\t\t\t\tadd( builtinType, new ListType(\"NMTOKENS\",NmtokenType.theInstance) );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"NOTATION\") )\n\t\t\t\tadd( builtinType, new StringType(\"NOTATION\", WhiteSpaceProcessor.theCollapse) );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"nonPositiveInteger\") )\n\t\t\t\tadd( builtinType, NonPositiveIntegerType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedLong\") )\n\t\t\t\tadd( builtinType, UnsignedLongType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedInt\") )\n\t\t\t\tadd( builtinType, UnsignedIntType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedShort\") )\n\t\t\t\tadd( builtinType, UnsignedShortType.theInstance );\n\t\t\telse\n\t\t\tif( dataTypeName.equals(\"unsignedByte\") )\n\t\t\t\tadd( builtinType, UnsignedByteType.theInstance );\n\t\t} catch( DatatypeException dte )\t{\n\t\t\tthrow new Error();\n\t\t}\n\t\treturn (XSDatatype)builtinType.get(dataTypeName);\n\t}\n"} {"input": "\tsynchronized public void flush() throws BackingStoreException {\n\t\tcheckRemoved();\n\t\tIEclipsePreferences loadLevel = getLoadLevel();\n\t\tif (loadLevel == null) {\n\t\t\tString[] childrenNames = childrenNames();\n\t\t\tfor (int i = 0; i < childrenNames.length; i++)\n\t\t\t\tnode(childrenNames[i]).flush();\n\t\t\treturn;\n\t\t}\n\t\tif (this != loadLevel) {\n\t\t\tloadLevel.flush();\n\t\t\treturn;\n\t\t}\n\t\tif (!dirty)\n\t\t\treturn;\n\t\tdirty = false;\n\t\ttry {\n\t\t\tsave();\n\t\t} catch (BackingStoreException e) {\n\t\t\tdirty = true;\n\t\t\tthrow e;\n\t\t}\n\t}\n", "output": "\tpublic void flush() throws BackingStoreException {\n\t\tcheckRemoved();\n\t\tIEclipsePreferences loadLevel = getLoadLevel();\n\t\tif (loadLevel == null) {\n\t\t\tString[] childrenNames = childrenNames();\n\t\t\tfor (int i = 0; i < childrenNames.length; i++)\n\t\t\t\tnode(childrenNames[i]).flush();\n\t\t\treturn;\n\t\t}\n\t\tif (this != loadLevel) {\n\t\t\tloadLevel.flush();\n\t\t\treturn;\n\t\t}\n\t\tif (!dirty)\n\t\t\treturn;\n\t\tdirty = false;\n\t\ttry {\n\t\t\tsave();\n\t\t} catch (BackingStoreException e) {\n\t\t\tdirty = true;\n\t\t\tthrow e;\n\t\t}\n\t}\n"} {"input": "\tprivate void confirmArrivalToConf(HttpServletRequest request, HttpServletResponse response) throws Exception {\n\t\tJsonObject jsonObject = new JsonObject();\n\t\tString userIdstr = request.getParameter(ProjConst.USER_ID);\n\t\tString confName = request.getParameter(ProjConst.COMP_NAME);\n\t\tString answer = request.getParameter(ProjConst.COMP_NAME);\n\t\tLong userId;\n\t\tboolean success;\n\t\tif ( userIdstr == null) {\n\t\t\tthrow new Exception(\"Failed to get user id\");\n\t\t}else{\n\t\t\tuserId = Long.valueOf(userIdstr.trim());\n\t\t}\n\t\tif ( confName == null) {\n\t\t\tthrow new Exception(\"Failed to get conference name\");\n\t\t}\n\t\tif ( answer == null) {\n\t\t\tthrow new Exception(\"Failed to get user's answer\");\n\t\t}\n \tString message;\n \ttry \n \t{\n \t\tUser user = UserDao.getInstance().getUserById(userId);\n \t\tConference conf = ConferenceDao.getInstance().getConferenceByName(confName);\n \t\tConferencesUsersDao.getInstance().updateUserAttendanceApproval(conf, user, UserAttendanceStatus.valueOf(answer));\n \t\tmessage = \"response successfully updated\";\n \t\tsuccess = true;\n \t}\n \tcatch (Exception e)\n \t{\n \t\tmessage = \"Error occurred, unable to update response\";\n \t\tsuccess = false;\n \t}\n \tresponse.setContentType(\"application/json;charset=UTF-8\");\n PrintWriter out = response.getWriter();\n try {\n Gson gson = new Gson();\n \tString json;\n \tif (success)\t\n \t{\n \t\tjsonObject.addProperty(\"resultSuccess\", \"true\");\n \t\tjsonObject.addProperty(\"message\", message);\n \t\tjson = gson.toJson(jsonObject);\n \t}\n \telse\n \t{\n \t\tjsonObject.addProperty(\"resultSuccess\", \"false\");\n \t\tjsonObject.addProperty(\"message\", message);\n \t\tjson = gson.toJson(jsonObject);\n \t}\n \tout.write(json);\n out.flush();\n }\n finally {\n out.close();\n }\n\t}\n", "output": "\tprivate void confirmArrivalToConf(HttpServletRequest request, HttpServletResponse response) throws Exception {\n\t\tJsonObject jsonObject = new JsonObject();\n\t\tString userIdstr = request.getParameter(ProjConst.USER_ID);\n\t\tString confName = request.getParameter(ProjConst.CONF_NAME);\n\t\tString answer = request.getParameter(\"answer\");\n\t\tLong userId;\n\t\tboolean success;\n\t\tif ( userIdstr == null) {\n\t\t\tthrow new Exception(\"Failed to get user id\");\n\t\t}else{\n\t\t\tuserId = Long.valueOf(userIdstr.trim());\n\t\t}\n\t\tif ( confName == null) {\n\t\t\tthrow new Exception(\"Failed to get conference name\");\n\t\t}\n\t\tif ( answer == null) {\n\t\t\tthrow new Exception(\"Failed to get user's answer\");\n\t\t}\n \tString message;\n \ttry \n \t{\n \t\tUser user = UserDao.getInstance().getUserById(userId);\n \t\tConference conf = ConferenceDao.getInstance().getConferenceByName(confName);\n \t\tConferencesUsersDao.getInstance().updateUserAttendanceApproval(conf, user, UserAttendanceStatus.valueOf(answer));\n \t\tmessage = \"response successfully updated\";\n \t\tsuccess = true;\n \t}\n \tcatch (Exception e)\n \t{\n \t\tmessage = \"Error occurred, unable to update response\";\n \t\tsuccess = false;\n \t}\n \tresponse.setContentType(\"application/json;charset=UTF-8\");\n PrintWriter out = response.getWriter();\n try {\n Gson gson = new Gson();\n \tString json;\n \tif (success)\t\n \t{\n \t\tjsonObject.addProperty(\"resultSuccess\", \"true\");\n \t\tjsonObject.addProperty(\"message\", message);\n \t\tjson = gson.toJson(jsonObject);\n \t}\n \telse\n \t{\n \t\tjsonObject.addProperty(\"resultSuccess\", \"false\");\n \t\tjsonObject.addProperty(\"message\", message);\n \t\tjson = gson.toJson(jsonObject);\n \t}\n \tout.write(json);\n out.flush();\n }\n finally {\n out.close();\n }\n\t}\n"} {"input": " private QuickAction prepareFileAction(final SeafDirent dirent, boolean cacheExists) {\n final QuickAction mQuickAction = new QuickAction(mActivity);\n Resources resources = mActivity.getResources();\n ActionItem shareAction, downloadAction, updateAction, exportAction, renameAction, deleteAction;\n if (!repoIsEncrypted) {\n shareAction = new ActionItem(ACTION_ID_SHARE,\n resources.getString(R.string.file_action_share),\n resources.getDrawable(R.drawable.action_share));\n mQuickAction.addActionItem(shareAction);\n }\n renameAction = new ActionItem(ACTION_ID_RENAME,\n resources.getString(R.string.file_action_rename),\n resources.getDrawable(R.drawable.action_rename));\n mQuickAction.addActionItem(renameAction);\n exportAction = new ActionItem(ACTION_ID_EXPORT,\n resources.getString(R.string.file_action_export),\n resources.getDrawable(R.drawable.action_export));\n mQuickAction.addActionItem(exportAction);\n if (cacheExists) {\n if (mActivity.hasRepoWritePermission()) {\n updateAction = new ActionItem(ACTION_ID_UPDATE,\n resources.getString(R.string.file_action_update),\n resources.getDrawable(R.drawable.action_update));\n mQuickAction.addActionItem(updateAction);\n }\n } else {\n downloadAction = new ActionItem(ACTION_ID_DOWNLOAD,\n resources.getString(R.string.file_action_download),\n resources.getDrawable(R.drawable.action_download));\n mQuickAction.addActionItem(downloadAction);\n }\n mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {\n @Override\n public void onItemClick(QuickAction quickAction, int pos, int actionId) {\n NavContext nav = mActivity.getNavContext();\n String repoName = nav.getRepoName();\n String repoID = nav.getRepoID();\n String dir = nav.getDirPath();\n String path = Utils.pathJoin(dir, dirent.name);\n DataManager dataManager = mActivity.getDataManager();\n String localPath = dataManager.getLocalRepoFile(repoName, repoID, path).getPath();\n switch (actionId) {\n case ACTION_ID_SHARE:\n mActivity.shareFile(repoID, path);\n break;\n case ACTION_ID_EXPORT:\n mActivity.exportFile(dirent.name);\n break;\n case ACTION_ID_DOWNLOAD:\n mActivity.onFileSelected(dirent);\n break;\n case ACTION_ID_UPDATE:\n mActivity.addUpdateTask(repoID, repoName, dir, localPath);\n break;\n case ACTION_ID_RENAME:\n break;\n }\n }\n });\n mQuickAction.mAnimateTrack(false);\n return mQuickAction;\n }\n", "output": " private QuickAction prepareFileAction(final SeafDirent dirent, boolean cacheExists) {\n final QuickAction mQuickAction = new QuickAction(mActivity);\n Resources resources = mActivity.getResources();\n ActionItem shareAction, downloadAction, updateAction, exportAction, renameAction, deleteAction;\n if (!repoIsEncrypted) {\n shareAction = new ActionItem(ACTION_ID_SHARE,\n resources.getString(R.string.file_action_share),\n resources.getDrawable(R.drawable.action_share));\n mQuickAction.addActionItem(shareAction);\n }\n renameAction = new ActionItem(ACTION_ID_RENAME,\n resources.getString(R.string.file_action_rename),\n resources.getDrawable(R.drawable.action_rename));\n mQuickAction.addActionItem(renameAction);\n exportAction = new ActionItem(ACTION_ID_EXPORT,\n resources.getString(R.string.file_action_export),\n resources.getDrawable(R.drawable.action_export));\n mQuickAction.addActionItem(exportAction);\n if (cacheExists) {\n if (mActivity.hasRepoWritePermission()) {\n updateAction = new ActionItem(ACTION_ID_UPDATE,\n resources.getString(R.string.file_action_update),\n resources.getDrawable(R.drawable.action_update));\n mQuickAction.addActionItem(updateAction);\n }\n } else {\n downloadAction = new ActionItem(ACTION_ID_DOWNLOAD,\n resources.getString(R.string.file_action_download),\n resources.getDrawable(R.drawable.action_download));\n mQuickAction.addActionItem(downloadAction);\n }\n mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {\n @Override\n public void onItemClick(QuickAction quickAction, int pos, int actionId) {\n NavContext nav = mActivity.getNavContext();\n String repoName = nav.getRepoName();\n String repoID = nav.getRepoID();\n String dir = nav.getDirPath();\n String path = Utils.pathJoin(dir, dirent.name);\n DataManager dataManager = mActivity.getDataManager();\n String localPath = dataManager.getLocalRepoFile(repoName, repoID, path).getPath();\n switch (actionId) {\n case ACTION_ID_SHARE:\n mActivity.shareFile(repoID, path);\n break;\n case ACTION_ID_EXPORT:\n mActivity.exportFile(dirent.name);\n break;\n case ACTION_ID_DOWNLOAD:\n mActivity.onFileSelected(dirent);\n break;\n case ACTION_ID_UPDATE:\n mActivity.addUpdateTask(repoID, repoName, dir, localPath);\n break;\n case ACTION_ID_RENAME:\n mActivity.renameFile(repoID, repoName, path);\n break;\n }\n }\n });\n mQuickAction.mAnimateTrack(false);\n return mQuickAction;\n }\n"} {"input": " private void initComponents() {\n User user;\n if (id == null) {\n id = getSession().getUserId();\n }\n user = userManager.findUserById(id, true);\n if (user == null) {\n logger.warn(\"Not founded user for UserHistory page with id: \" + id);\n error(\"A megadott felhaszn\u00e1l\u00f3hoz nem tartozik k\u00f6z\u00f6ss\u00e9gi t\u00f6rt\u00e9net!\");\n throw new RestartResponseException(GroupHierarchy.class);\n }\n setHeaderLabelText(user.getFullName() + \" k\u00f6z\u00f6ss\u00e9gi t\u00f6rt\u00e9nete\");\n setTitleText(user.getFullName() + \" k\u00f6z\u00f6ss\u00e9gi t\u00f6rt\u00e9nete\");\n if (own_profile) {\n add(new BookmarkablePageLink<ShowUser>(\"simpleView\", ShowUser.class));\n } else {\n add(new BookmarkablePageLink<ShowUser>(\"simpleView\", ShowUser.class, new PageParameters().add(\"id\", user.getId())));\n }\n add(new BookmarkablePageLink(\"profilelink\", ShowPersonPage.class,\n new PageParameters().add(\"virid\", id.toString())));\n setDefaultModel(new CompoundPropertyModel<User>(user));\n final List<String> groups = new ArrayList<String>();\n groups.add(EVERY_GROUP);\n List<Membership> ms = user.getMemberships();\n for (Membership csoporttagsag : ms) {\n groups.add(csoporttagsag.getGroup().getName());\n }\n DropDownChoice<String> ddc = new DropDownChoice<String>(\"group\", new PropertyModel<String>(this, \"selected_text\"), groups) {\n @Override\n protected boolean wantOnSelectionChangedNotifications() {\n return true;\n }\n @Override\n protected void onSelectionChanged(final String newSelection) {\n PageParameters pp = new PageParameters();\n String Lselected = groups.get(Integer.valueOf(this.getInput()));\n if (Lselected.equals(EVERY_GROUP)) {\n } else {\n Group group = groupManager.findGroupByName(Lselected);\n pp.add(\"group\", group.getId().toString());\n }\n pp.add(\"id\", String.valueOf(id));\n setResponsePage(UserHistory.class, pp);\n }\n };\n add(ddc);\n List<SemesterPoint> semesterPoints = new ArrayList<SemesterPoint>();\n Semester prev = null;\n for (Semester s : userManager.getAllValuatedSemesterForUser(user)) {\n if(prev != null){\n while(!prev.getPrevious().equals(s)){\n prev = prev.getPrevious();\n semesterPoints.add(new SemesterPoint(prev, 0));\n }\n }\n prev = s;\n semesterPoints.add(new SemesterPoint(s, userManager.getSemesterPointForUser(user, s)));\n }\n ListView<SemesterPoint> splv = new ListView<SemesterPoint>(\"semesterPointList\", semesterPoints) {\n @Override\n protected void populateItem(ListItem<SemesterPoint> item) {\n SemesterPoint p = item.getModelObject();\n item.add(new Label(\"semesterPoint.semester\", p.getSemester().toString()));\n item.add(new Label(\"semesterPoint.point\", String.valueOf(p.getPoint())));\n }\n };\n add(splv);\n List<ValuationData> list = valuationManager.findRequestsForUser(user, selectedGroupId);\n add(new ValuationTableForUser(\"table\", list).getDataTable());\n }\n", "output": " private void initComponents() {\n User user;\n if (id == null) {\n id = getSession().getUserId();\n }\n user = userManager.findUserById(id, true);\n if (user == null) {\n logger.warn(\"Not founded user for UserHistory page with id: \" + id);\n error(\"A megadott felhaszn\u00e1l\u00f3hoz nem tartozik k\u00f6z\u00f6ss\u00e9gi t\u00f6rt\u00e9net!\");\n throw new RestartResponseException(GroupHierarchy.class);\n }\n setHeaderLabelText(user.getFullName() + \" k\u00f6z\u00f6ss\u00e9gi t\u00f6rt\u00e9nete\");\n setTitleText(user.getFullName() + \" k\u00f6z\u00f6ss\u00e9gi t\u00f6rt\u00e9nete\");\n if (own_profile) {\n add(new BookmarkablePageLink<ShowUser>(\"simpleView\", ShowUser.class));\n } else {\n add(new BookmarkablePageLink<ShowUser>(\"simpleView\", ShowUser.class, new PageParameters().add(\"id\", user.getId())));\n }\n add(new BookmarkablePageLink(\"profilelink\", ShowPersonPage.class,\n new PageParameters().add(\"virid\", id.toString())));\n setDefaultModel(new CompoundPropertyModel<User>(user));\n final List<String> groups = new ArrayList<String>();\n groups.add(EVERY_GROUP);\n List<Membership> ms = user.getMemberships();\n for (Membership csoporttagsag : ms) {\n groups.add(csoporttagsag.getGroup().getName());\n }\n DropDownChoice<String> ddc = new DropDownChoice<String>(\"group\", new PropertyModel<String>(this, \"selected_text\"), groups) {\n @Override\n protected boolean wantOnSelectionChangedNotifications() {\n return true;\n }\n @Override\n protected void onSelectionChanged(final String newSelection) {\n PageParameters pp = new PageParameters();\n String Lselected = groups.get(Integer.valueOf(this.getInput()));\n if (Lselected.equals(EVERY_GROUP)) {\n } else {\n Group group = groupManager.findGroupByName(Lselected);\n pp.add(\"group\", group.getId().toString());\n }\n pp.add(\"id\", String.valueOf(id));\n setResponsePage(UserHistory.class, pp);\n }\n };\n add(ddc);\n List<SemesterPoint> semesterPoints = new ArrayList<SemesterPoint>();\n for (Semester s : userManager.getAllValuatedSemesterForUser(user)) {\n semesterPoints.add(new SemesterPoint(s, userManager.getSemesterPointForUser(user, s)));\n }\n ListView<SemesterPoint> splv = new ListView<SemesterPoint>(\"semesterPointList\", semesterPoints) {\n @Override\n protected void populateItem(ListItem<SemesterPoint> item) {\n SemesterPoint p = item.getModelObject();\n item.add(new Label(\"semesterPoint.semester\", p.getSemester().toString()));\n item.add(new Label(\"semesterPoint.point\", String.valueOf(p.getPoint())));\n }\n };\n add(splv);\n List<ValuationData> list = valuationManager.findRequestsForUser(user, selectedGroupId);\n add(new ValuationTableForUser(\"table\", list).getDataTable());\n }\n"} {"input": " protected ResponseContext internalInvoke(\n RequestContext requestContext,\n ResponseContext responseContext) \n throws AbderaServerException {\n Target target = requestContext.getTarget();\n String method = requestContext.getMethod();\n if (target != null) {\n switch(target.getResourceType()) {\n case SERVICE: {\n try {\n if (requestContext.getIfNoneMatch().equals(\"\\\"service\\\"\")) \n throw new AbderaServerException(\n AbderaServerException.Code.NOTMODIFIED, \n \"Not Modified\", \"\");\n } catch (NullPointerException npe) {}\n return getServiceDocument();\n }\n case COLLECTION: {\n if (method.equals(\"GET\")) {\n if (!target.getValue(1).equals(\"foo\")) \n throw new AbderaServerException(\n AbderaServerException.Code.NOTFOUND, \n \"Not Found\", \"\");\n return getFeedDocument();\n } else if (method.equals(\"POST\")) {\n try {\n Document<Entry> entry_doc = \n getEntryFromRequestContext(requestContext);\n if (entry_doc != null) {\n Entry entry = (Entry) entry_doc.getRoot().clone();\n if (!isValidEntry(entry))\n throw new AbderaServerException(\n AbderaServerException.Code.BADREQUEST, \"Invalid Entry\", \"\");\n entry.setUpdated(new Date());\n entry.setModified(entry.getUpdated());\n entry.getIdElement().setValue(FOMHelper.generateUuid());\n entry.addLink(\"foo/\" + entry.getId().toString(), \"edit\");\n getFeed().getRoot().insertEntry((Entry) entry.clone());\n BaseResponseContext rc = getEntryDocument(entry);\n rc.setStatus(201);\n String elink = entry.getEditLink().getHref().toString();\n rc.setLocation(elink);\n rc.setContentLocation(elink);\n return rc;\n } else {\n throw new AbderaServerException(\n AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, \n \"Unsupported Media Type\", \"\");\n }\n } catch (AbderaServerException e) {\n throw e;\n } catch (Exception e) {\n throw new AbderaServerException(e);\n }\n }\n }\n case ENTRY_EDIT: {\n Entry entry = getEntryFromFeed(requestContext);\n if (entry == null)\n throw new AbderaServerException(\n AbderaServerException.Code.NOTFOUND, \"Not Found\", \"\");\n if (method.equals(\"GET\")) {\n Entry e = (Entry) entry.clone();\n return new BaseResponseContext(e.getDocument());\n } else if (method.equals(\"PUT\")) {\n try {\n Document<Entry> entry_doc = getEntryFromRequestContext(requestContext);\n if (entry_doc == null) \n throw new AbderaServerException(\n AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, \n \"Unsupported Media Type\", \"\");\n Document<Feed> feed_doc = getFeed();\n Entry e = (Entry) entry_doc.getRoot().clone();\n if (!isValidEntry(entry))\n throw new AbderaServerException(\n AbderaServerException.Code.BADREQUEST, \"Invalid Entry\", \"\");\n if (!e.getId().equals(entry.getId()))\n throw new AbderaServerException(\n AbderaServerException.Code.CONFLICT, \"Conflict. Cannot change atom:id\", \"\");\n e.setUpdated(new Date());\n e.setModified(e.getUpdated());\n Link editLink = e.getEditLink();\n if (editLink == null) \n e.addLink(\"foo/\" + e.getId().toString(), \"edit\");\n else editLink.setHref(\"foo/\" + e.getId().toString());\n entry.discard();\n feed_doc.getRoot().insertEntry((Entry) e.clone());\n return new EmptyResponseContext(204);\n } catch (Exception e) {\n throw new AbderaServerException(e);\n }\n } else if (method.equals(\"DELETE\")) {\n entry.discard();\n return new EmptyResponseContext(204);\n }\n }\n }\n return null;\n } else {\n throw new AbderaServerException(\n AbderaServerException.Code.NOTFOUND, \n \"Not Found\", \"\");\n }\n }\n", "output": " protected ResponseContext internalInvoke(\n RequestContext requestContext,\n ResponseContext responseContext) \n throws AbderaServerException {\n Target target = requestContext.getTarget();\n String method = requestContext.getMethod();\n if (target != null) {\n ResourceType type = target.getResourceType();\n if (type == ResourceType.SERVICE) {\n try {\n if (requestContext.getIfNoneMatch().equals(\"\\\"service\\\"\")) \n throw new AbderaServerException(\n AbderaServerException.Code.NOTMODIFIED, \n \"Not Modified\", \"\");\n } catch (NullPointerException npe) {}\n return getServiceDocument();\n } else if (type == ResourceType.COLLECTION) {\n if (method.equals(\"GET\")) {\n if (!target.getValue(1).equals(\"foo\")) \n throw new AbderaServerException(\n AbderaServerException.Code.NOTFOUND, \n \"Not Found\", \"\");\n return getFeedDocument();\n } else if (method.equals(\"POST\")) {\n try {\n Document<Entry> entry_doc = \n getEntryFromRequestContext(requestContext);\n if (entry_doc != null) {\n Entry entry = (Entry) entry_doc.getRoot().clone();\n if (!isValidEntry(entry))\n throw new AbderaServerException(\n AbderaServerException.Code.BADREQUEST, \"Invalid Entry\", \"\");\n entry.setUpdated(new Date());\n entry.setModified(entry.getUpdated());\n entry.getIdElement().setValue(FOMHelper.generateUuid());\n entry.addLink(\"foo/\" + entry.getId().toString(), \"edit\");\n getFeed().getRoot().insertEntry((Entry) entry.clone());\n BaseResponseContext rc = getEntryDocument(entry);\n rc.setStatus(201);\n String elink = entry.getEditLink().getHref().toString();\n rc.setLocation(elink);\n rc.setContentLocation(elink);\n return rc;\n } else {\n throw new AbderaServerException(\n AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, \n \"Unsupported Media Type\", \"\");\n }\n } catch (AbderaServerException e) {\n throw e;\n } catch (Exception e) {\n throw new AbderaServerException(e);\n }\n }\n } else if (type == ResourceType.ENTRY_EDIT) {\n Entry entry = getEntryFromFeed(requestContext);\n if (entry == null)\n throw new AbderaServerException(\n AbderaServerException.Code.NOTFOUND, \"Not Found\", \"\");\n if (method.equals(\"GET\")) {\n Entry e = (Entry) entry.clone();\n return new BaseResponseContext(e.getDocument());\n } else if (method.equals(\"PUT\")) {\n try {\n Document<Entry> entry_doc = getEntryFromRequestContext(requestContext);\n if (entry_doc == null) \n throw new AbderaServerException(\n AbderaServerException.Code.UNSUPPORTEDMEDIATYPE, \n \"Unsupported Media Type\", \"\");\n Document<Feed> feed_doc = getFeed();\n Entry e = (Entry) entry_doc.getRoot().clone();\n if (!isValidEntry(entry))\n throw new AbderaServerException(\n AbderaServerException.Code.BADREQUEST, \"Invalid Entry\", \"\");\n if (!e.getId().equals(entry.getId()))\n throw new AbderaServerException(\n AbderaServerException.Code.CONFLICT, \"Conflict. Cannot change atom:id\", \"\");\n e.setUpdated(new Date());\n e.setModified(e.getUpdated());\n Link editLink = e.getEditLink();\n if (editLink == null) \n e.addLink(\"foo/\" + e.getId().toString(), \"edit\");\n else editLink.setHref(\"foo/\" + e.getId().toString());\n entry.discard();\n feed_doc.getRoot().insertEntry((Entry) e.clone());\n return new EmptyResponseContext(204);\n } catch (Exception e) {\n throw new AbderaServerException(e);\n }\n } else if (method.equals(\"DELETE\")) {\n entry.discard();\n return new EmptyResponseContext(204);\n }\n }\n return null;\n } else {\n throw new AbderaServerException(\n AbderaServerException.Code.NOTFOUND, \n \"Not Found\", \"\");\n }\n }\n"} {"input": "\tpublic void run(final String... args) {\n\t\tif (args.length != 1) {\n\t\t\toutputHelp();\n\t\t}\n\t\tfinal File configFile = new File(args[0]);\n\t\tif (!configFile.canRead()) {\n\t\t\tSystem.err.println(\"Configuration file \" + configFile.getAbsolutePath() + \" not readable\");\n\t\t\tSystem.exit(2);\n\t\t}\n\t\tfinal Bootstrapper bootstrapper = DefaultBootstrapper.bootstrap(configFile.getAbsolutePath());\n\t\ttry {\n\t\t\trunBootstrapped(bootstrapper);\n\t\t} catch (final Exception e) {\n\t\t\tSystem.err.println(\"Exception raised during bootstrapping. Check out the logs for more information.\");\n\t\t\tSystem.exit(3);\n\t\t}\n\t}\n", "output": "\tpublic void run(final String... args) {\n\t\tif (args.length != 1) {\n\t\t\toutputHelp();\n\t\t}\n\t\tfinal File configFile = new File(args[0]);\n\t\tif (!configFile.canRead()) {\n\t\t\tSystem.err.println(\"Configuration file \" + configFile.getAbsolutePath() + \" not readable\");\n\t\t\tSystem.exit(2);\n\t\t}\n\t\tfinal Bootstrapper bootstrapper = DefaultBootstrapper.bootstrap(configFile.getAbsolutePath());\n\t\ttry {\n\t\t\trunBootstrapped(bootstrapper);\n\t\t} catch (final Exception e) {\n\t\t\tSystem.err.println(\"Exception raised during bootstrapping. Check out the logs for more information. Message: \" + e.getMessage());\n\t\t\tSystem.exit(3);\n\t\t}\n\t}\n"} {"input": " private void updateInCallNotification(boolean allowFullScreenIntent) {\n int resId;\n if (DBG) log(\"updateInCallNotification(allowFullScreenIntent = \"\n + allowFullScreenIntent + \")...\");\n if (!PhoneApp.sVoiceCapable) {\n if (DBG) log(\"- non-voice-capable device; suppressing notification.\");\n return;\n }\n if (mCM.getState() == Phone.State.IDLE) {\n cancelInCall();\n cancelMute();\n cancelSpeakerphone();\n return;\n }\n final boolean hasRingingCall = mCM.hasActiveRingingCall();\n final boolean hasActiveCall = mCM.hasActiveFgCall();\n final boolean hasHoldingCall = mCM.hasActiveBgCall();\n if (DBG) {\n log(\" - hasRingingCall = \" + hasRingingCall);\n log(\" - hasActiveCall = \" + hasActiveCall);\n log(\" - hasHoldingCall = \" + hasHoldingCall);\n }\n if (mApp.isShowingCallScreen() && !hasRingingCall) {\n cancelInCall();\n return;\n }\n boolean enhancedVoicePrivacy = mApp.notifier.getVoicePrivacyState();\n if (DBG) log(\"updateInCallNotification: enhancedVoicePrivacy = \" + enhancedVoicePrivacy);\n if (hasRingingCall) {\n resId = R.drawable.stat_sys_phone_call_ringing;\n } else if (!hasActiveCall && hasHoldingCall) {\n if (enhancedVoicePrivacy) {\n resId = R.drawable.stat_sys_vp_phone_call_on_hold;\n } else {\n resId = R.drawable.stat_sys_phone_call_on_hold;\n }\n } else if (mApp.showBluetoothIndication()) {\n if (enhancedVoicePrivacy) {\n resId = R.drawable.stat_sys_vp_phone_call_bluetooth;\n } else {\n resId = R.drawable.stat_sys_phone_call_bluetooth;\n }\n } else {\n if (enhancedVoicePrivacy) {\n resId = R.drawable.stat_sys_vp_phone_call;\n } else {\n resId = R.drawable.stat_sys_phone_call;\n }\n }\n if (DBG) log(\"- Updating status bar icon: resId = \" + resId);\n mInCallResId = resId;\n int expandedViewIcon = mInCallResId;\n Call currentCall;\n if (hasRingingCall) {\n currentCall = mCM.getFirstActiveRingingCall();\n } else if (hasActiveCall) {\n currentCall = mCM.getActiveFgCall();\n } else {\n currentCall = mCM.getFirstActiveBgCall();\n }\n Connection currentConn = currentCall.getEarliestConnection();\n Notification notification = new Notification();\n notification.icon = mInCallResId;\n notification.flags |= Notification.FLAG_ONGOING_EVENT;\n PendingIntent inCallPendingIntent =\n PendingIntent.getActivity(mContext, 0,\n PhoneApp.createInCallIntent(), 0);\n notification.contentIntent = inCallPendingIntent;\n RemoteViews contentView = new RemoteViews(mContext.getPackageName(),\n R.layout.ongoing_call_notification);\n contentView.setImageViewResource(R.id.icon, expandedViewIcon);\n if (currentConn != null) {\n long callDurationMsec = currentConn.getDurationMillis();\n long chronometerBaseTime = SystemClock.elapsedRealtime() - callDurationMsec;\n String expandedViewLine1;\n if (hasRingingCall) {\n expandedViewLine1 = mContext.getString(R.string.notification_incoming_call);\n } else if (hasHoldingCall && !hasActiveCall) {\n expandedViewLine1 = mContext.getString(R.string.notification_on_hold);\n } else {\n expandedViewLine1 = mContext.getString(R.string.notification_ongoing_call_format);\n }\n if (DBG) log(\"- Updating expanded view: line 1 '\" + \"xxxxxxx\" + \"'\");\n contentView.setChronometer(R.id.text1,\n chronometerBaseTime,\n expandedViewLine1,\n true);\n } else if (DBG) {\n Log.w(LOG_TAG, \"updateInCallNotification: null connection, can't set exp view line 1.\");\n }\n String expandedViewLine2 = \"\";\n if (PhoneUtils.isConferenceCall(currentCall)) {\n expandedViewLine2 = mContext.getString(R.string.card_title_conf_call);\n } else {\n PhoneUtils.CallerInfoToken cit =\n PhoneUtils.startGetCallerInfo(mContext, currentCall, this, this);\n expandedViewLine2 = PhoneUtils.getCompactNameFromCallerInfo(cit.currentInfo, mContext);\n }\n if (DBG) log(\"- Updating expanded view: line 2 '\" + \"xxxxxxx\" + \"'\");\n contentView.setTextViewText(R.id.text2, expandedViewLine2);\n notification.contentView = contentView;\n if (hasRingingCall) {\n if (DBG) log(\"- Using hi-pri notification for ringing call!\");\n notification.flags |= Notification.FLAG_HIGH_PRIORITY;\n notification.tickerText = expandedViewLine2;\n if (allowFullScreenIntent) {\n if (DBG) log(\"- Setting fullScreenIntent: \" + inCallPendingIntent);\n notification.fullScreenIntent = inCallPendingIntent;\n Call ringingCall = mCM.getFirstActiveRingingCall();\n if ((ringingCall.getState() == Call.State.WAITING) && !mApp.isShowingCallScreen()) {\n Log.i(LOG_TAG, \"updateInCallNotification: call-waiting! force relaunch...\");\n mNotificationManager.cancel(IN_CALL_NOTIFICATION);\n }\n }\n }\n if (DBG) log(\"Notifying IN_CALL_NOTIFICATION: \" + notification);\n mNotificationManager.notify(IN_CALL_NOTIFICATION,\n notification);\n updateSpeakerNotification();\n updateMuteNotification();\n }\n", "output": " private void updateInCallNotification(boolean allowFullScreenIntent) {\n int resId;\n if (DBG) log(\"updateInCallNotification(allowFullScreenIntent = \"\n + allowFullScreenIntent + \")...\");\n if (!PhoneApp.sVoiceCapable) {\n if (DBG) log(\"- non-voice-capable device; suppressing notification.\");\n return;\n }\n if (mCM.getState() == Phone.State.IDLE) {\n cancelInCall();\n cancelMute();\n cancelSpeakerphone();\n return;\n }\n final boolean hasRingingCall = mCM.hasActiveRingingCall();\n final boolean hasActiveCall = mCM.hasActiveFgCall();\n final boolean hasHoldingCall = mCM.hasActiveBgCall();\n if (DBG) {\n log(\" - hasRingingCall = \" + hasRingingCall);\n log(\" - hasActiveCall = \" + hasActiveCall);\n log(\" - hasHoldingCall = \" + hasHoldingCall);\n }\n if (mApp.isShowingCallScreen() && !hasRingingCall) {\n cancelInCall();\n return;\n }\n boolean enhancedVoicePrivacy = mApp.notifier.getVoicePrivacyState();\n if (DBG) log(\"updateInCallNotification: enhancedVoicePrivacy = \" + enhancedVoicePrivacy);\n if (hasRingingCall) {\n resId = R.drawable.stat_sys_phone_call_ringing;\n } else if (!hasActiveCall && hasHoldingCall) {\n if (enhancedVoicePrivacy) {\n resId = R.drawable.stat_sys_vp_phone_call_on_hold;\n } else {\n resId = R.drawable.stat_sys_phone_call_on_hold;\n }\n } else if (mApp.showBluetoothIndication()) {\n if (enhancedVoicePrivacy) {\n resId = R.drawable.stat_sys_vp_phone_call_bluetooth;\n } else {\n resId = R.drawable.stat_sys_phone_call_bluetooth;\n }\n } else {\n if (enhancedVoicePrivacy) {\n resId = R.drawable.stat_sys_vp_phone_call;\n } else {\n resId = R.drawable.stat_sys_phone_call;\n }\n }\n if (DBG) log(\"- Updating status bar icon: resId = \" + resId);\n mInCallResId = resId;\n int expandedViewIcon = mInCallResId;\n Call currentCall;\n if (hasRingingCall) {\n currentCall = mCM.getFirstActiveRingingCall();\n } else if (hasActiveCall) {\n currentCall = mCM.getActiveFgCall();\n } else {\n currentCall = mCM.getFirstActiveBgCall();\n }\n Connection currentConn = currentCall.getEarliestConnection();\n Notification notification = new Notification();\n notification.icon = mInCallResId;\n notification.flags |= Notification.FLAG_ONGOING_EVENT;\n PendingIntent inCallPendingIntent =\n PendingIntent.getActivity(mContext, 0,\n PhoneApp.createInCallIntent(), 0);\n notification.contentIntent = inCallPendingIntent;\n RemoteViews contentView = new RemoteViews(mContext.getPackageName(),\n R.layout.ongoing_call_notification);\n contentView.setImageViewResource(R.id.icon, expandedViewIcon);\n if (currentConn != null) {\n long callDurationMsec = currentConn.getDurationMillis();\n long chronometerBaseTime = SystemClock.elapsedRealtime() - callDurationMsec;\n String expandedViewLine1;\n if (hasRingingCall) {\n expandedViewLine1 = mContext.getString(R.string.notification_incoming_call);\n } else if (hasHoldingCall && !hasActiveCall) {\n expandedViewLine1 = mContext.getString(R.string.notification_on_hold);\n } else {\n expandedViewLine1 = mContext.getString(R.string.notification_ongoing_call_format);\n }\n if (DBG) log(\"- Updating expanded view: line 1 '\" + \"xxxxxxx\" + \"'\");\n contentView.setChronometer(R.id.text1,\n chronometerBaseTime,\n expandedViewLine1,\n true);\n } else if (DBG) {\n Log.w(LOG_TAG, \"updateInCallNotification: null connection, can't set exp view line 1.\");\n }\n String expandedViewLine2 = \"\";\n if (PhoneUtils.isConferenceCall(currentCall)) {\n expandedViewLine2 = mContext.getString(R.string.card_title_conf_call);\n } else {\n PhoneUtils.CallerInfoToken cit =\n PhoneUtils.startGetCallerInfo(mContext, currentCall, this, this);\n expandedViewLine2 = PhoneUtils.getCompactNameFromCallerInfo(cit.currentInfo, mContext);\n }\n if (DBG) log(\"- Updating expanded view: line 2 '\" + \"xxxxxxx\" + \"'\");\n contentView.setTextViewText(R.id.title, expandedViewLine2);\n notification.contentView = contentView;\n if (hasRingingCall) {\n if (DBG) log(\"- Using hi-pri notification for ringing call!\");\n notification.flags |= Notification.FLAG_HIGH_PRIORITY;\n notification.tickerText = expandedViewLine2;\n if (allowFullScreenIntent) {\n if (DBG) log(\"- Setting fullScreenIntent: \" + inCallPendingIntent);\n notification.fullScreenIntent = inCallPendingIntent;\n Call ringingCall = mCM.getFirstActiveRingingCall();\n if ((ringingCall.getState() == Call.State.WAITING) && !mApp.isShowingCallScreen()) {\n Log.i(LOG_TAG, \"updateInCallNotification: call-waiting! force relaunch...\");\n mNotificationManager.cancel(IN_CALL_NOTIFICATION);\n }\n }\n }\n if (DBG) log(\"Notifying IN_CALL_NOTIFICATION: \" + notification);\n mNotificationManager.notify(IN_CALL_NOTIFICATION,\n notification);\n updateSpeakerNotification();\n updateMuteNotification();\n }\n"} {"input": "\tprivate void printToFileIfApplicable(Object doc,\n\t\t\tOutputGenaratorParam outputGenaratorParam,String fileName) throws WsdlDocException {\n\t\tif (outputGenaratorParam.getParameters() != null) {\n\t\t\tif (outputGenaratorParam.getParameters().get(\"writeToFile\") != null\n\t\t\t\t\t&& \"true\".equals(outputGenaratorParam.getParameters().get(\n\t\t\t\t\t\t\t\"writeToFile\"))) {\n\t\t\t\tString outFile = outputGenaratorParam.getParameters().get(\n\t\t\t\t\t\t\"filePath\");\n\t\t\t\tif (outFile != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twriteFile(doc.toString(),outFile,fileName);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tthrow new WsdlDocException(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void printToFileIfApplicable(Object doc,\n\t\t\tOutputGenaratorParam outputGenaratorParam,String fileName) throws WsdlDocException {\n\t\tif (outputGenaratorParam.getParameters() != null) {\n\t\t\tif (outputGenaratorParam.getParameters().get(\"writeToFile\") != null\n\t\t\t\t\t&& \"true\".equals(outputGenaratorParam.getParameters().get(\n\t\t\t\t\t\t\t\"writeToFile\"))) {\n\t\t\t\tString outFile = outputGenaratorParam.getOutputDir();\n\t\t\t\tif (outFile != null) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\twriteFile(doc.toString(),outFile,fileName);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tthrow new WsdlDocException(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic LinkedList<AdjacentTile> getAdjacentTileEntities(boolean flag) {\n\t\tLinkedList<AdjacentTile> foundTiles = new LinkedList<AdjacentTile>();\n\t\tfor (ForgeDirection o : ForgeDirection.values()) {\n\t\t\tif (o == ForgeDirection.UNKNOWN) continue;\n\t\t\tPosition p = new Position(_x, _y, _z, o);\n\t\t\tp.moveForwards(1);\n\t\t\tTileEntity tile = _worldObj.getBlockTileEntity((int)p.x, (int)p.y, (int)p.z);\n\t\t\tif (tile == null) continue;\n\t\t\tif(flag) {\n\t\t\t\tTileEntity tilePipe = _worldObj.getBlockTileEntity(_x, _y, _z);\n\t\t\t\tif(tilePipe instanceof TileGenericPipe) {\n\t\t\t\t\tif(((TileGenericPipe)tilePipe).pipe != null) {\n\t\t\t\t\t\t((TileGenericPipe)tilePipe).pipe.isPipeConnected(tile);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoundTiles.add(new AdjacentTile(tile, o));\n\t\t}\n\t\treturn foundTiles;\n\t}\n", "output": "\tpublic LinkedList<AdjacentTile> getAdjacentTileEntities(boolean flag) {\n\t\tLinkedList<AdjacentTile> foundTiles = new LinkedList<AdjacentTile>();\n\t\tfor (ForgeDirection o : ForgeDirection.values()) {\n\t\t\tif (o == ForgeDirection.UNKNOWN) continue;\n\t\t\tPosition p = new Position(_x, _y, _z, o);\n\t\t\tp.moveForwards(1);\n\t\t\tTileEntity tile = _worldObj.getBlockTileEntity((int)p.x, (int)p.y, (int)p.z);\n\t\t\tif (tile == null) continue;\n\t\t\tif(flag) {\n\t\t\t\tTileEntity tilePipe = _worldObj.getBlockTileEntity(_x, _y, _z);\n\t\t\t\tif(tilePipe instanceof TileGenericPipe) {\n\t\t\t\t\tif(((TileGenericPipe)tilePipe).pipe != null) {\n\t\t\t\t\t\tif(!((TileGenericPipe)tilePipe).pipe.isPipeConnected(tile)) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfoundTiles.add(new AdjacentTile(tile, o));\n\t\t}\n\t\treturn foundTiles;\n\t}\n"} {"input": "\tpublic void dispose() {\n\t\tif (scp == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (Activator.DEBUG) {\n\t\t\tActivator.log.debug(\"ComponentInstanceImpl.dispose(): disposing instance of component \" + scp.name, null); \n\t\t}\n\t\tif (!scp.isComponentFactory() && scp.serviceComponent.factory != null) {\n\t\t\tscp.serviceComponent.componentProps.removeElement(scp);\n\t\t\tVector toDispose = new Vector(1);\n\t\t\ttoDispose.addElement(scp);\n\t\t\tInstanceProcess.resolver.disposeComponentConfigs(toDispose, ComponentConstants.DEACTIVATION_REASON_DISPOSED);\n\t\t\tif (scp != null) {\n\t\t\t\tscp.setState(Component.STATE_DISPOSED);\n\t\t\t\tscp = null;\n\t\t\t}\n\t\t} else {\n\t\t\tscp.dispose(this, ComponentConstants.DEACTIVATION_REASON_DISPOSED);\n\t\t}\n\t\tfreeServiceReferences();\n\t\tcomponentContext = null;\n\t\tinstance = null;\n\t}\n", "output": "\tpublic void dispose() {\n\t\tif (scp == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (Activator.DEBUG) {\n\t\t\tActivator.log.debug(\"ComponentInstanceImpl.dispose(): disposing instance of component \" + scp.name, null); \n\t\t}\n\t\tif (!scp.isComponentFactory() && scp.serviceComponent.factory != null) {\n\t\t\tscp.serviceComponent.componentProps.removeElement(scp);\n\t\t\tVector toDispose = new Vector(1);\n\t\t\ttoDispose.addElement(scp);\n\t\t\tInstanceProcess.resolver.disposeComponentConfigs(toDispose, ComponentConstants.DEACTIVATION_REASON_DISPOSED);\n\t\t\tif (scp != null) {\n\t\t\t\tscp.setState(Component.STATE_DISPOSED);\n\t\t\t}\n\t\t} else {\n\t\t\tscp.dispose(this, ComponentConstants.DEACTIVATION_REASON_DISPOSED);\n\t\t}\n\t\tfreeServiceReferences();\n\t\tscp = null;\n\t\tcomponentContext = null;\n\t\tinstance = null;\n\t}\n"} {"input": " public boolean onCommand(\n CommandSender sender, Command command, String label, String[] args) {\n if ( args.length <= 0 ) {\n return false;\n }\n String group = args[0]; \n Hashtable<String, ArrayList<Player>> members =\n new Hashtable<String, ArrayList<Player>>();\n if ( !members.containsKey(group) ) {\n sender.sendMessage(PREERR + \"\u30b0\u30eb\u30fc\u30d7 \" + group + \" \u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\n return true;\n }\n ArrayList<Player> playersToExplode = members.get(group);\n for ( Player p : playersToExplode ) {\n p.getWorld().createExplosion(p.getLocation(), 0); \n p.setHealth(0); \n p.sendMessage(\"\u3069\u30fc\u30fc\u3093\uff01\");\n }\n ColorMeTeaming.sendBroadcast(PRENOTICE + \"\u30b0\u30eb\u30fc\u30d7 \" + group + \" \");\n return true;\n }\n", "output": " public boolean onCommand(\n CommandSender sender, Command command, String label, String[] args) {\n if ( args.length <= 0 ) {\n return false;\n }\n String group = args[0]; \n Hashtable<String, ArrayList<Player>> members =\n ColorMeTeaming.getAllColorMembers();\n if ( !members.containsKey(group) ) {\n sender.sendMessage(PREERR + \"\u30b0\u30eb\u30fc\u30d7 \" + group + \" \u306f\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\");\n return true;\n }\n ArrayList<Player> playersToExplode = members.get(group);\n for ( Player p : playersToExplode ) {\n p.getWorld().createExplosion(p.getLocation(), 0); \n p.setHealth(0); \n p.sendMessage(\"\u3069\u30fc\u30fc\u3093\uff01\");\n }\n ColorMeTeaming.sendBroadcast(PRENOTICE + \"\u30b0\u30eb\u30fc\u30d7 \" + group + \" \");\n return true;\n }\n"} {"input": " private File makeFinalOutputDirectoryPath(UploadSummary uploadSummary, File sessionTempFolder) throws IOException {\n final File outDirParent = config.getFinalOutputDir();\n final Date now = Calendar.getInstance().getTime();\n final String dateDirName = (new SimpleDateFormat(\"yyyy-MM-dd\")).format(now);\n final File dateDir = new File(outDirParent, dateDirName);\n dateDir.mkdirs();\n if (!dateDir.exists()) {\n throw new IOException(\"Unable to create final output folder \" + dateDir);\n }\n StringBuilder b = new StringBuilder();\n b.append(dateDirName)\n .append(File.separatorChar)\n .append(uploadSummary.senderAddress.getPersonal())\n .append(\" (\").append(uploadSummary.senderAddress.getAddress()).append(\") \");\n if (uploadSummary.customerCode != null && !uploadSummary.customerCode.isEmpty()) {\n b.append(\"(C: \").append(uploadSummary.customerCode).append(')');\n }\n if (uploadSummary.bookingNumber != null && !uploadSummary.bookingNumber.isEmpty()) {\n b.append(\"(B: \").append(uploadSummary.bookingNumber).append(')');\n }\n b.append(' ').append((new SimpleDateFormat(\"hh-mm-ss\").format(now)));\n uploadSummary.outputDirectory = new File(outDirParent, b.toString());\n return uploadSummary.outputDirectory;\n }\n", "output": " private File makeFinalOutputDirectoryPath(UploadSummary uploadSummary, File sessionTempFolder) throws IOException {\n final File outDirParent = config.getFinalOutputDir();\n final Date now = Calendar.getInstance().getTime();\n final String dateDirName = (new SimpleDateFormat(\"yyyy-MM-dd\")).format(now);\n final File dateDir = new File(outDirParent, dateDirName);\n StringBuilder b = new StringBuilder();\n b.append(dateDirName)\n .append(File.separatorChar)\n .append(uploadSummary.senderAddress.getPersonal())\n .append(\" (\").append(uploadSummary.senderAddress.getAddress()).append(\") \");\n if (uploadSummary.customerCode != null && !uploadSummary.customerCode.isEmpty()) {\n b.append(\"(C: \").append(uploadSummary.customerCode).append(')');\n }\n if (uploadSummary.bookingNumber != null && !uploadSummary.bookingNumber.isEmpty()) {\n b.append(\"(B: \").append(uploadSummary.bookingNumber).append(')');\n }\n b.append(' ').append((new SimpleDateFormat(\"hh-mm-ss\").format(now)));\n uploadSummary.outputDirectory = new File(outDirParent, b.toString());\n uploadSummary.outputDirectory.mkdirs();\n if (!uploadSummary.outputDirectory.exists()) {\n throw new IOException(\"Unable to create final output folder \" + uploadSummary.outputDirectory);\n }\n return uploadSummary.outputDirectory;\n }\n"} {"input": "\tprotected void doGet(HttpServletRequest request, HttpServletResponse response)\n\t\t\tthrows ServletException, IOException {\n\t response.setHeader(\"Cache-Control\", \"no-cache\");\n\t response.setHeader(\"Pragma\", \"no-cache\");\n\t response.setContentType(\"text/html\");\n\t String equation = request.getParameter(\"equation\");\n\t String[] pnames = request.getParameterValues(\"pname\");\n\t String[] pvalues = request.getParameterValues(\"pvalue\");\n\t for (int i=0; i < pnames.length; i++) \n\t \tSystem.out.println(\"pname: \"+pnames[i]+\" pvalue: \"+pvalues[i]);\n\t PrintWriter out = response.getWriter();\n\t GraphDescriber describer = new GraphDescriber(equation);\n\t String newEquation = describer.getNewEquation(pnames, pvalues);\n\t\tSystem.out.println(\"NEW EQUATION IS: \"+newEquation);\n\t out.println(\"<html>\");\n\t out.println(\"<head></head><body>\");\n\t out.println(\"<form method='get' action='/Mde-Web-Service/GetEquationDescription'>\");\n\t out.println(\"Enter an equation: \");\n\t out.println(\"<input type='text' name='equation'>\");\n\t out.println(\"<input type='submit'>\");\n\t out.println(\"</form>\");\n\t out.println(\"</head></body>\");\n\t out.println(\"</html>\");\n\t}\n", "output": "\tprotected void doGet(HttpServletRequest request, HttpServletResponse response)\n\t\t\tthrows ServletException, IOException {\n\t response.setHeader(\"Cache-Control\", \"no-cache\");\n\t response.setHeader(\"Pragma\", \"no-cache\");\n\t response.setContentType(\"text/html\");\n\t String equation = request.getParameter(\"equation\");\n\t String[] pnames = request.getParameterValues(\"pname\");\n\t String[] pvalues = request.getParameterValues(\"pvalue\");\n\t for (int i=0; i < pnames.length; i++) \n\t \tSystem.out.println(\"pname: \"+pnames[i]+\" pvalue: \"+pvalues[i]);\n\t PrintWriter out = response.getWriter();\n\t GraphDescriber describer = new GraphDescriber(equation);\n\t String newEquation = describer.getNewEquation(pnames, pvalues);\n\t out.print(newEquation);\n\t}\n"} {"input": " protected MutableLayoutRow oneStep(@NotNull MutableLayoutRow row) {\n int newRowIndex = row.getGraphNodeRow().getRowIndex() + 1;\n if (newRowIndex == graph.getNodeRows().size()) {\n throw new NoSuchElementException();\n }\n List<GraphElement> layoutRow = row.getModifiableOrderedGraphElements();\n for (ListIterator<GraphElement> iterator = layoutRow.listIterator(); iterator.hasNext(); ) {\n GraphElement element = iterator.next();\n Node node = element.getNode();\n if (node != null) {\n List<Edge> edges = node.getDownEdges();\n if (edges.size() == 0) {\n iterator.remove();\n } else {\n iterator.remove();\n for (Edge edge : orderAddEdges(edges)) {\n Node downNode = edge.getDownNode();\n if (downNode.getRowIndex() == newRowIndex) {\n if (downNode.getBranch() == edge.getBranch()) {\n iterator.add(downNode);\n }\n } else {\n iterator.add(edge);\n }\n }\n }\n } else {\n Edge edge = element.getEdge();\n if (edge == null) {\n throw new IllegalStateException(\"unexpected element class\");\n }\n if (edge.getDownNode().getRowIndex() == newRowIndex) {\n if (edge.getBranch() == edge.getDownNode().getBranch()) {\n iterator.set(edge.getDownNode());\n } else {\n iterator.remove();\n }\n }\n }\n }\n NodeRow nextGraphRow = graph.getNodeRows().get(newRowIndex);\n for (Node node : nextGraphRow.getNodes()) {\n if (node.getUpEdges().isEmpty()) {\n layoutRow.add(node);\n }\n }\n row.setNodeRow(nextGraphRow);\n return row;\n }\n", "output": " protected MutableLayoutRow oneStep(@NotNull MutableLayoutRow row) {\n int newRowIndex = row.getGraphNodeRow().getRowIndex() + 1;\n if (newRowIndex == graph.getNodeRows().size()) {\n throw new NoSuchElementException();\n }\n List<GraphElement> layoutRow = row.getModifiableOrderedGraphElements();\n Set<Node> addedNodeInNextRow = new HashSet<Node>();\n for (ListIterator<GraphElement> iterator = layoutRow.listIterator(); iterator.hasNext(); ) {\n GraphElement element = iterator.next();\n Node node = element.getNode();\n if (node != null) {\n List<Edge> edges = node.getDownEdges();\n if (edges.size() == 0) {\n iterator.remove();\n } else {\n iterator.remove();\n for (Edge edge : orderAddEdges(edges)) {\n Node downNode = edge.getDownNode();\n if (downNode.getRowIndex() == newRowIndex) {\n if (!addedNodeInNextRow.contains(downNode)) {\n iterator.add(downNode);\n addedNodeInNextRow.add(downNode);\n }\n } else {\n iterator.add(edge);\n }\n }\n }\n } else {\n Edge edge = element.getEdge();\n if (edge == null) {\n throw new IllegalStateException(\"unexpected element class\");\n }\n if (edge.getDownNode().getRowIndex() == newRowIndex) {\n if (!addedNodeInNextRow.contains(edge.getDownNode())) {\n iterator.set(edge.getDownNode());\n addedNodeInNextRow.add(edge.getDownNode());\n } else {\n iterator.remove();\n }\n }\n }\n }\n NodeRow nextGraphRow = graph.getNodeRows().get(newRowIndex);\n for (Node node : nextGraphRow.getNodes()) {\n if (node.getUpEdges().isEmpty()) {\n layoutRow.add(node);\n }\n }\n row.setNodeRow(nextGraphRow);\n return row;\n }\n"} {"input": "\tpublic void updateNotifyIcon() {\n\t\tContext ctx = getApplicationContext();\n\t\tint prcnt = battery_state[0];\n\t\tint curplug = battery_state[1];\n\t\tint voltage = battery_state[2];\n\t\tint temp = battery_state[3];\n\t\tint oldprcnt = bconfig.GetPercentage();\n\t\tint oldplug = bconfig.GetPlugStatus();\n\t\tint oldts = bconfig.GetTimestamp();\n\t\tif(bconfig.IsMotorola() && bconfig.GetMotorolaPercent() != 0) {\n\t\t\tprcnt = bconfig.GetMotorolaPercent();\n\t\t}\n\t\tif(prcnt > 100) { prcnt = 100; }\n\t\tif(prcnt < 0) { prcnt = 0; }\n\t\tif( (curplug != oldplug) || (prcnt == 100) ) {\n\t\t\tLog.d(T, \"++ STATUS CHANGE ++: oldplug=\"+oldplug+\", curplug=\"+curplug+\", percentage=\"+prcnt);\n\t\t\toldprcnt = prcnt;\n\t\t\toldts = unixtimeAsInt();\n\t\t\tbconfig.SetPlugStatus(curplug);\n\t\t\tbconfig.SetPercentage(prcnt);\n\t\t\tbconfig.SetTimestamp(oldts);\n\t\t}\n\t\tString vx = String.valueOf(voltage/1000.0);\n\t\tString ntext = \"\";\n\t\tString ntitle = ((prcnt == 100 && curplug == 1) ? gtx(R.string.fully_charged) : \n\t\t (curplug == 0 ? gtx(R.string.discharging_from)+\" \"+oldprcnt+\"%\" : \n\t\t gtx(R.string.charging_from)+\" \"+oldprcnt+\"%\")); \n\t\tString timetxt = getTimeString(oldts); \n\t\tint icon_id = bconfig.GetIconFor(prcnt, (curplug!=0 && bconfig.ChargeGlow()) );\n\t\tif(bconfig.ShowDetails()) {\n\t\t\tString dgtmp = String.valueOf(temp/10.0)+gtx(R.string.degree)+\"C\";\n\t\t\tif(bconfig.TempInFahrenheit()) {\n\t\t\t\tdgtmp = String.valueOf( ( (int)((temp * 1.8)+320) )/10.0 )+gtx(R.string.degree)+\"F\";\n\t\t\t}\n\t\t\tntext += vx+\"V, \"+dgtmp;\n\t\t\tntext += _ICSFILTER_( \", \"+gtx(R.string.capacity_at)+\" \"+prcnt+\"%\" ); \n\t\t}\n\t\telse {\n\t\t\tntext += (voltage == 0 ? \"\" : gtx(R.string.voltage)+\" \"+vx+\" V\");\n\t\t\tntext += _ICSFILTER_( \" // \"+gtx(R.string.capacity_at)+\" \"+prcnt+\"%\" ); \n\t\t}\n\t\tif(isICS() == true) {\n\t\t\tntext = \"...since \"+timetxt+\" / \"+ntext; \n\t\t}\n\t\telse {\n\t\t\tntitle += \" \"+gtx(R.string.since)+\": \"+timetxt; \n\t\t\tntext += \" \"+gtx(R.string.since)+\":\"; \n\t\t}\n\t\tNotification this_notify = new Notification(icon_id, null, System.currentTimeMillis());\n\t\tthis_notify.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;\n\t\tthis_notify.setLatestEventInfo(ctx, ntitle, ntext, getConfiguredIntent() );\n\t\tnotify_manager.notify(0, this_notify);\n\t}\n", "output": "\tpublic void updateNotifyIcon() {\n\t\tContext ctx = getApplicationContext();\n\t\tint prcnt = battery_state[0];\n\t\tint curplug = battery_state[1];\n\t\tint voltage = battery_state[2];\n\t\tint temp = battery_state[3];\n\t\tint oldprcnt = bconfig.GetPercentage();\n\t\tint oldplug = bconfig.GetPlugStatus();\n\t\tint oldts = bconfig.GetTimestamp();\n\t\tif(bconfig.IsMotorola() && bconfig.GetMotorolaPercent() != 0) {\n\t\t\tprcnt = bconfig.GetMotorolaPercent();\n\t\t}\n\t\tif(prcnt > 100) { prcnt = 100; }\n\t\tif(prcnt < 0) { prcnt = 0; }\n\t\tif( (curplug != oldplug) || (prcnt == 100) ) {\n\t\t\tLog.d(T, \"++ STATUS CHANGE ++: oldplug=\"+oldplug+\", curplug=\"+curplug+\", percentage=\"+prcnt);\n\t\t\toldprcnt = prcnt;\n\t\t\toldts = unixtimeAsInt();\n\t\t\tbconfig.SetPlugStatus(curplug);\n\t\t\tbconfig.SetPercentage(prcnt);\n\t\t\tbconfig.SetTimestamp(oldts);\n\t\t}\n\t\tString vx = String.valueOf(voltage/1000.0);\n\t\tString ntext = \"\";\n\t\tString ntitle = ((prcnt == 100 && curplug == 1) ? gtx(R.string.fully_charged) : \n\t\t (curplug == 0 ? gtx(R.string.discharging_from)+\" \"+oldprcnt+\"%\" : \n\t\t gtx(R.string.charging_from)+\" \"+oldprcnt+\"%\")); \n\t\tString timetxt = getTimeString(oldts); \n\t\tint icon_id = bconfig.GetIconFor(prcnt, (curplug!=0 && bconfig.ChargeGlow()) );\n\t\tif(bconfig.ShowDetails()) {\n\t\t\tString dgtmp = String.valueOf(temp/10.0)+gtx(R.string.degree)+\"C\";\n\t\t\tif(bconfig.TempInFahrenheit()) {\n\t\t\t\tdgtmp = String.valueOf( ( (int)((temp * 1.8)+320) )/10.0 )+gtx(R.string.degree)+\"F\";\n\t\t\t}\n\t\t\tntext += vx+\"V, \"+dgtmp;\n\t\t\tntext += _ICSFILTER_( \", \"+gtx(R.string.capacity_at)+\" \"+prcnt+\"%\" ); \n\t\t}\n\t\telse {\n\t\t\tntext += (voltage == 0 ? \"\" : gtx(R.string.voltage)+\" \"+vx+\" V\");\n\t\t\tntext += _ICSFILTER_( \" // \"+gtx(R.string.capacity_at)+\" \"+prcnt+\"%\" ); \n\t\t}\n\t\tif(isICS() == true) {\n\t\t\tntext = \"...\"+gtx(R.string.since)+\" \"+timetxt+\" / \"+ntext; \n\t\t}\n\t\telse {\n\t\t\tntitle += \" \"+gtx(R.string.since)+\": \"+timetxt; \n\t\t\tntext += \" \"+gtx(R.string.since)+\":\"; \n\t\t}\n\t\tNotification this_notify = new Notification(icon_id, null, System.currentTimeMillis());\n\t\tthis_notify.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;\n\t\tthis_notify.setLatestEventInfo(ctx, ntitle, ntext, getConfiguredIntent() );\n\t\tnotify_manager.notify(0, this_notify);\n\t}\n"} {"input": " public void whenPlayerMoves(PlayerMoveEvent event) {\n final Player player = event.getPlayer();\n if (onPad.contains(player)) return;\n if (player.hasPermission(\"telepads.use\")) {\n Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);\n if (!checkPad(block)) {\n return;\n }\n final Location loc = new Location(null, block.getX(), block.getY(), block.getZ());\n if (!plugin.telepads.containsKey(loc)) {\n return;\n }\n onPad.add(player);\n player.sendMessage(ChatColor.GRAY + plugin.wait_msg.replace(\"%time%\", plugin.telepad_teleport_time + \" Seconds\"));\n plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n public void run() {\n onPad.remove(player);\n Block cBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);\n if (!checkPad(cBlock)) return;\n if (!plugin.telepads.containsKey(loc)) return;\n plugin.gotoPad(loc, player);\n }\n }, plugin.telepad_teleport_time * 20L);\n }\n }\n", "output": " public void whenPlayerMoves(PlayerMoveEvent event) {\n final Player player = event.getPlayer();\n if (onPad.contains(player)) return;\n if (player.hasPermission(\"telepads.use\")) {\n Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);\n if (!checkPad(block)) {\n return;\n }\n final Location loc = new Location(null, block.getX(), block.getY(), block.getZ());\n if (!plugin.telepads.containsKey(loc)) {\n return;\n }\n onPad.add(player);\n player.sendMessage(ChatColor.GRAY + plugin.wait_msg.replace(\"%time%\", plugin.telepad_teleport_time + \" Seconds\"));\n plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n public void run() {\n onPad.remove(player);\n Block cBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);\n if (!checkPad(cBlock)) return;\n Location floc = new Location(null, cBlock.getX(), cBlock.getY(), cBlock.getZ());\n if (!plugin.telepads.containsKey(floc)) return;\n plugin.gotoPad(loc, player);\n }\n }, plugin.telepad_teleport_time * 20L);\n }\n }\n"} {"input": " private List<String> findFactoryCandidates(BundleContext context) throws IOException {\n Bundle[] bundles = context.getBundles();\n List<String> factoryCandidates = new ArrayList<String>();\n for (Bundle bundle : bundles) {\n if (bundle.getSymbolicName().equals(\"system.bundle\")) {\n continue;\n }\n Enumeration urls = bundle.findEntries(\"META-INF/services\", \"javax.script.ScriptEngineFactory\", false);\n if (urls == null) {\n continue;\n }\n while (urls.hasMoreElements()) {\n URL u = (URL) urls.nextElement();\n BufferedReader reader = new BufferedReader(\n new InputStreamReader(u.openStream()));\n String line;\n while ((line = reader.readLine()) != null) {\n line = line.trim();\n if (!line.startsWith(\"#\") && line.length() > 0) {\n factoryCandidates.add(line);\n }\n }\n reader.close();\n }\n }\n factoryCandidates.add(\"com.sun.script.javascript.RhinoScriptEngineFactory\");\n return factoryCandidates;\n }\n", "output": " private List<String> findFactoryCandidates(BundleContext context) throws IOException {\n Bundle[] bundles = context.getBundles();\n List<String> factoryCandidates = new ArrayList<String>();\n for (Bundle bundle : bundles) {\n if (bundle.getSymbolicName().equals(\"system.bundle\")) {\n continue;\n }\n Enumeration urls = bundle.findEntries(\"META-INF/services\", \"javax.script.ScriptEngineFactory\", false);\n if (urls == null) {\n continue;\n }\n while (urls.hasMoreElements()) {\n URL u = (URL) urls.nextElement();\n BufferedReader reader = new BufferedReader(\n new InputStreamReader(u.openStream(), \"UTF-8\"));\n String line;\n while ((line = reader.readLine()) != null) {\n line = line.trim();\n if (!line.startsWith(\"#\") && line.length() > 0) {\n factoryCandidates.add(line);\n }\n }\n reader.close();\n }\n }\n factoryCandidates.add(\"com.sun.script.javascript.RhinoScriptEngineFactory\");\n return factoryCandidates;\n }\n"} {"input": "\tpublic JobStatus run() {\n\t\tUserPreferences userPrefs = new UserPreferences();\n\t\tSocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();\n\t\tUpsertResult result = null;\n\t\tJobStatus runStatus = JobStatus.SUCCESS;\n\t\tJobStatus validationStatus = validate(connectionInfo);\n\t\tif(validationStatus.isError()) {\n\t\t\trunStatus = validationStatus;\n\t\t} else {\n\t\t\tfinal Soda2Producer producer = Soda2Producer.newProducer(connectionInfo.getUrl(), connectionInfo.getUser(), connectionInfo.getPassword(), connectionInfo.getToken());\n\t\t\tfinal SodaImporter importer = SodaImporter.newImporter(connectionInfo.getUrl(), connectionInfo.getUser(), connectionInfo.getPassword(), connectionInfo.getToken());\n\t\t\tFile fileToPublishFile = new File(fileToPublish);\n\t\t\tFile deleteRowsFile = null;\n\t\t\tif(!fileRowsToDelete.equals(DELETE_ZERO_ROWS)) {\n\t\t\t\tdeleteRowsFile = new File(fileRowsToDelete);\n\t\t\t}\n\t\t\tString errorMessage = \"\";\n\t\t\tboolean noPublishExceptions = false;\n\t\t\ttry {\n\t\t\t\tif(publishMethod.equals(PublishMethod.upsert)) {\n if(fileToPublishFile.length() > FILESIZE_CHUNK_CUTOFF_BYTES) {\n result = IntegrationUtility.upsertInChunks(\n NUM_ROWS_PER_CHUNK, producer, importer, datasetID, deleteRowsFile, fileToPublishFile);\n } else {\n\t\t\t\t\t result = IntegrationUtility.upsert(producer, importer, datasetID, deleteRowsFile, fileToPublishFile);\n }\n noPublishExceptions = true;\n\t\t\t\t}\n\t\t\t\telse if(publishMethod.equals(PublishMethod.append)) {\n if(fileToPublishFile.length() > FILESIZE_CHUNK_CUTOFF_BYTES) {\n result = IntegrationUtility.appendInChunks(\n NUM_ROWS_PER_CHUNK, producer, datasetID, fileToPublishFile);\n } else {\n result = IntegrationUtility.append(producer, datasetID, fileToPublishFile);\n }\n noPublishExceptions = true;\n\t\t\t\t}\n\t\t\t\telse if(publishMethod.equals(PublishMethod.replace)) {\n\t\t\t\t\tresult = IntegrationUtility.replaceNew(producer, datasetID, fileToPublishFile);\n\t\t\t\t\tnoPublishExceptions = true;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = JobStatus.INVALID_PUBLISH_METHOD.toString();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException ioException) {\n\t\t\t\terrorMessage = ioException.getMessage();\n\t\t\t} \n\t\t\tcatch (SodaError sodaError) {\n\t\t\t\terrorMessage = sodaError.getMessage();\n\t\t\t} \n\t\t\tcatch (InterruptedException intrruptException) {\n\t\t\t\terrorMessage = intrruptException.getMessage();\n\t\t\t}\n\t\t\tcatch (Exception other) {\n\t\t\t\terrorMessage = other.toString() + \": \" + other.getMessage();\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tif(noPublishExceptions) {\n\t\t\t\t\tif(result != null) {\n\t\t\t\t\t\tif(result.errorCount() > 0) {\n\t\t\t\t\t\t\tfor (UpsertError upsertErr : result.getErrors()) {\n\t\t\t\t\t\t\t\terrorMessage += upsertErr.getError() + \" (line \"\n\t\t\t\t\t\t\t\t\t\t+ (upsertErr.getIndex() + 1) + \" of file) \\n\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trunStatus = JobStatus.PUBLISH_ERROR;\n\t\t\t\t\t\t\trunStatus.setMessage(errorMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trunStatus = JobStatus.SUCCESS;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trunStatus = JobStatus.PUBLISH_ERROR;\n\t\t\t\t\trunStatus.setMessage(errorMessage);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString adminEmail = userPrefs.getAdminEmail();\n\t\tString logDatasetID = userPrefs.getLogDatasetID();\n\t\tJobStatus logStatus = JobStatus.SUCCESS;\n\t\tif(!logDatasetID.equals(\"\")) {\n\t\t\tlogStatus = IntegrationUtility.addLogEntry(logDatasetID, connectionInfo, this, runStatus, result);\n\t\t}\n\t\tif(userPrefs.emailUponError() && !adminEmail.equals(\"\")) {\n\t\t\tString errorEmailMessage = \"\";\n\t\t\tString urlToLogDataset = connectionInfo.getUrl() + \"/d/\" + logDatasetID;\n\t\t\tif(runStatus.isError()) {\n\t\t\t\terrorEmailMessage += \"There was an error updating a dataset.\\n\"\n\t\t\t\t\t\t+ \"\\nDataset: \" + connectionInfo.getUrl() + \"/d/\" + getDatasetID()\n\t\t\t\t\t\t+ \"\\nFile to be published: \" + fileToPublish\n\t\t\t\t\t\t+ \"\\nPublish method: \" + publishMethod\n\t\t\t\t\t\t+ \"\\nJob File: \" + pathToSavedJobFile\n\t\t\t\t\t\t+ \"\\nError message: \" + runStatus.getMessage()\n\t\t\t\t\t\t+ \"\\nLog dataset: \" + urlToLogDataset + \"\\n\\n\";\n\t\t\t}\n\t\t\tif(logStatus.isError()) {\n\t\t\t\terrorEmailMessage += \"There was an error updating the log dataset: \"\n\t\t\t\t\t\t+ urlToLogDataset + \"\\n\"\n\t\t\t\t\t\t+ \"Error message: \" + logStatus.getMessage() + \"\\n\\n\";\n\t\t\t}\n\t\t\tif(runStatus.isError() || logStatus.isError()) {\n\t\t\t\ttry {\n\t\t\t\t\tSMTPMailer.send(adminEmail, \"Socrata DataSync Error\", errorEmailMessage);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tSystem.out.println(\"Error sending email to: \" + adminEmail + \"\\n\" + e.getMessage());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn runStatus;\n\t}\n", "output": "\tpublic JobStatus run() {\n\t\tUserPreferences userPrefs = new UserPreferences();\n\t\tSocrataConnectionInfo connectionInfo = userPrefs.getConnectionInfo();\n\t\tUpsertResult result = null;\n\t\tJobStatus runStatus = JobStatus.SUCCESS;\n\t\tJobStatus validationStatus = validate(connectionInfo);\n\t\tif(validationStatus.isError()) {\n\t\t\trunStatus = validationStatus;\n\t\t} else {\n\t\t\tfinal Soda2Producer producer = Soda2Producer.newProducer(connectionInfo.getUrl(), connectionInfo.getUser(), connectionInfo.getPassword(), connectionInfo.getToken());\n\t\t\tfinal SodaImporter importer = SodaImporter.newImporter(connectionInfo.getUrl(), connectionInfo.getUser(), connectionInfo.getPassword(), connectionInfo.getToken());\n\t\t\tFile fileToPublishFile = new File(fileToPublish);\n\t\t\tFile deleteRowsFile = null;\n\t\t\tif(!fileRowsToDelete.equals(DELETE_ZERO_ROWS)) {\n\t\t\t\tdeleteRowsFile = new File(fileRowsToDelete);\n\t\t\t}\n\t\t\tString errorMessage = \"\";\n\t\t\tboolean noPublishExceptions = false;\n\t\t\ttry {\n\t\t\t\tif(publishMethod.equals(PublishMethod.upsert)) {\n if(fileToPublishFile.length() > FILESIZE_CHUNK_CUTOFF_BYTES) {\n result = IntegrationUtility.upsertInChunks(\n NUM_ROWS_PER_CHUNK, producer, importer, datasetID, deleteRowsFile, fileToPublishFile);\n } else {\n\t\t\t\t\t result = IntegrationUtility.upsert(producer, importer, datasetID, deleteRowsFile, fileToPublishFile);\n }\n noPublishExceptions = true;\n\t\t\t\t}\n\t\t\t\telse if(publishMethod.equals(PublishMethod.append)) {\n if(fileToPublishFile.length() > FILESIZE_CHUNK_CUTOFF_BYTES) {\n result = IntegrationUtility.appendInChunks(\n NUM_ROWS_PER_CHUNK, producer, datasetID, fileToPublishFile);\n } else {\n result = IntegrationUtility.append(producer, datasetID, fileToPublishFile);\n }\n noPublishExceptions = true;\n\t\t\t\t}\n\t\t\t\telse if(publishMethod.equals(PublishMethod.replace)) {\n\t\t\t\t\tresult = IntegrationUtility.replaceNew(producer, datasetID, fileToPublishFile);\n\t\t\t\t\tnoPublishExceptions = true;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = JobStatus.INVALID_PUBLISH_METHOD.toString();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException ioException) {\n\t\t\t\terrorMessage = ioException.getMessage();\n\t\t\t} \n\t\t\tcatch (SodaError sodaError) {\n errorMessage = sodaError.getMessage();\n\t\t\t} \n\t\t\tcatch (InterruptedException intrruptException) {\n\t\t\t\terrorMessage = intrruptException.getMessage();\n\t\t\t}\n\t\t\tcatch (Exception other) {\n\t\t\t\terrorMessage = other.toString() + \": \" + other.getMessage();\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tif(noPublishExceptions) {\n\t\t\t\t\tif(result != null) {\n if(result.errorCount() > 0) {\n\t\t\t\t\t\t\tfor (UpsertError upsertErr : result.getErrors()) {\n\t\t\t\t\t\t\t\terrorMessage += upsertErr.getError() + \" (line \"\n\t\t\t\t\t\t\t\t\t\t+ (upsertErr.getIndex() + 1) + \" of file) \\n\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trunStatus = JobStatus.PUBLISH_ERROR;\n\t\t\t\t\t\t\trunStatus.setMessage(errorMessage);\n\t\t\t\t\t\t} else {\n }\n\t\t\t\t\t} else {\n\t\t\t\t\t\trunStatus = JobStatus.SUCCESS;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trunStatus = JobStatus.PUBLISH_ERROR;\n\t\t\t\t\trunStatus.setMessage(errorMessage);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tString adminEmail = userPrefs.getAdminEmail();\n\t\tString logDatasetID = userPrefs.getLogDatasetID();\n\t\tJobStatus logStatus = JobStatus.SUCCESS;\n\t\tif(!logDatasetID.equals(\"\")) {\n\t\t\tlogStatus = IntegrationUtility.addLogEntry(logDatasetID, connectionInfo, this, runStatus, result);\n\t\t}\n\t\tif(userPrefs.emailUponError() && !adminEmail.equals(\"\")) {\n\t\t\tString errorEmailMessage = \"\";\n\t\t\tString urlToLogDataset = connectionInfo.getUrl() + \"/d/\" + logDatasetID;\n\t\t\tif(runStatus.isError()) {\n\t\t\t\terrorEmailMessage += \"There was an error updating a dataset.\\n\"\n\t\t\t\t\t\t+ \"\\nDataset: \" + connectionInfo.getUrl() + \"/d/\" + getDatasetID()\n\t\t\t\t\t\t+ \"\\nFile to be published: \" + fileToPublish\n\t\t\t\t\t\t+ \"\\nPublish method: \" + publishMethod\n\t\t\t\t\t\t+ \"\\nJob File: \" + pathToSavedJobFile\n\t\t\t\t\t\t+ \"\\nError message: \" + runStatus.getMessage()\n\t\t\t\t\t\t+ \"\\nLog dataset: \" + urlToLogDataset + \"\\n\\n\";\n\t\t\t}\n\t\t\tif(logStatus.isError()) {\n\t\t\t\terrorEmailMessage += \"There was an error updating the log dataset: \"\n\t\t\t\t\t\t+ urlToLogDataset + \"\\n\"\n\t\t\t\t\t\t+ \"Error message: \" + logStatus.getMessage() + \"\\n\\n\";\n\t\t\t}\n\t\t\tif(runStatus.isError() || logStatus.isError()) {\n\t\t\t\ttry {\n\t\t\t\t\tSMTPMailer.send(adminEmail, \"Socrata DataSync Error\", errorEmailMessage);\n\t\t\t\t} catch (Exception e) {\n\t\t\t\t\tSystem.out.println(\"Error sending email to: \" + adminEmail + \"\\n\" + e.getMessage());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn runStatus;\n\t}\n"} {"input": " public void enhance(GenClass genClass,\n\t\t JMethod jMethod,\n\t\t JAnnotation jAnn)\n {\n TransactionAttributeType type;\n type = (TransactionAttributeType) jAnn.get(\"value\");\n BaseMethod genMethod = genClass.createMethod(jMethod);\n CallChain call = genMethod.getCall();\n switch (type) {\n case MANDATORY:\n call = new MandatoryCallChain(call);\n break;\n case REQUIRED:\n call = new RequiredCallChain(call);\n break;\n case REQUIRESNEW:\n call = new RequiresNewCallChain(call);\n break;\n case NEVER:\n call = new NeverCallChain(call);\n break;\n case SUPPORTS:\n call = new SupportsCallChain(call);\n break;\n case NOTSUPPORTED:\n call = new SuspendCallChain(call);\n break;\n default:\n break;\n }\n genMethod.setCall(call);\n }\n", "output": " public void enhance(GenClass genClass,\n\t\t JMethod jMethod,\n\t\t JAnnotation jAnn)\n {\n TransactionAttributeType type;\n type = (TransactionAttributeType) jAnn.get(\"value\");\n BaseMethod genMethod = genClass.createMethod(jMethod);\n CallChain call = genMethod.getCall();\n switch (type) {\n case MANDATORY:\n call = new MandatoryCallChain(call);\n break;\n case REQUIRED:\n call = new RequiredCallChain(call);\n break;\n case REQUIRES_NEW:\n call = new RequiresNewCallChain(call);\n break;\n case NEVER:\n call = new NeverCallChain(call);\n break;\n case SUPPORTS:\n call = new SupportsCallChain(call);\n break;\n case NOT_SUPPORTED:\n call = new SuspendCallChain(call);\n break;\n default:\n break;\n }\n genMethod.setCall(call);\n }\n"} {"input": "\tprotected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {\n\t\tboolean b = super.processKeyBinding(ks, e, condition, pressed);\n\t\tif (!b) {\n\t\t\tAbstractAction actionForKey = _controller.getActionForKeyStroke(ks);\n\t\t\tif (actionForKey != null) {\n\t\t\t\tObject eventSource = e.getSource();\n\t\t\t\tif (!(eventSource instanceof FlexoActionSource) && eventSource instanceof Component) {\n\t\t\t\t\teventSource = SwingUtilities.getAncestorOfClass(FlexoActionSource.class, (Component) eventSource);\n\t\t\t\t}\n\t\t\t\tactionForKey.actionPerformed(new ActionEvent(eventSource != null ? eventSource : e.getSource(), e.getID(), KEY_PRESSED));\n\t\t\t\tb = true;\n\t\t\t}\n\t\t}\n\t\treturn b;\n\t}\n", "output": "\tprotected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {\n\t\tboolean b = super.processKeyBinding(ks, e, condition, pressed);\n\t\tif (!b && ks!=null) {\n\t\t\tAbstractAction actionForKey = _controller.getActionForKeyStroke(ks);\n\t\t\tif (actionForKey != null) {\n\t\t\t\tObject eventSource = e.getSource();\n\t\t\t\tif (!(eventSource instanceof FlexoActionSource) && eventSource instanceof Component) {\n\t\t\t\t\teventSource = SwingUtilities.getAncestorOfClass(FlexoActionSource.class, (Component) eventSource);\n\t\t\t\t}\n\t\t\t\tactionForKey.actionPerformed(new ActionEvent(eventSource != null ? eventSource : e.getSource(), e.getID(), KEY_PRESSED));\n\t\t\t\tb = true;\n\t\t\t}\n\t\t}\n\t\treturn b;\n\t}\n"} {"input": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_carregar);\n\t\ttextViewAutor = (TextView) findViewById(R.id.textAutor);\n\t\ttextViewAlbum = (TextView) findViewById(R.id.textAlbum);\n\t\ttextViewGenero = (TextView) findViewById(R.id.textGenero);\n\t\ttextViewAutor.setText(\"Autor: \"+\"Campo V\u00e1zio\");\n\t\ttextViewAlbum.setText(\"Album: \"+\"Campo V\u00e1zio\");\n\t\ttextViewGenero.setText(\"Genero: \"+\"Campo V\u00e1zio\");\n\t\tImageButton botaoAdd = (ImageButton) findViewById(R.id.botaoAddMusica);\n\t\tbotaoAdd.setOnClickListener(new View.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif(file != null){\n\t\t\t\t\tif (!(ListMusic.getInstance().getListMusic().contains(file))){\n\t\t\t\t\t\tListMusic.getInstance().addMusica(file);\n\t\t\t\t\t\tMainActivity.fileAdapter.notifyDataSetChanged();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tsdcard = Environment.getExternalStorageDirectory();\n\t\tfinal File[] files = sdcard.listFiles();\n\t\tlistView = (ListView) findViewById(R.id.files);\n\t\tupdateList(files);\n\t\tadapter = new FileAdapter(getApplicationContext(), list);\n\t\tlistView.setAdapter(adapter);\n\t\tlistView.setOnItemClickListener(new OnItemClickListener() {\n\t @Override\n\t\t\tpublic void onItemClick(AdapterView<?> a, View v, int position, long id) {\n\t \tif (list.get(position).isDirectory()){\n\t \t\tFile[] filesAux = list.get(position).listFiles();\n\t \t\tFile auxParent = list.get(position).getParentFile();\n\t \t\tupdateList(filesAux);\n\t \t\tlist.add(0, auxParent);\n\t \t\tadapter.notifyDataSetChanged();\n\t \t}else{\n\t \t\ttry {\n\t \t\t\tSystem.out.println(\"entrou\");\n\t\t\t\t\t\tMP3 m = new MP3(list.get(position));\n\t\t\t\t\t\tif(m.getAlbum()!=null){\n\t\t\t\t\t\t\tString album = String.valueOf(m.getAlbum()).length()>12 ? String.valueOf(m.getAlbum()).substring(0,20)+\"...\":String.valueOf(m.getAlbum());\n\t\t\t\t\t\t\ttextViewAlbum.setText(\"Album: \"+album);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(m.getMusicBy() !=null){\n\t\t\t\t\t\t\tString musicBy = String.valueOf(m.getMusicBy()).length()>12 ? String.valueOf(m.getMusicBy()).substring(0,20)+\"...\":String.valueOf(m.getMusicBy());\n\t\t\t\t\t\t\ttextViewAutor.setText(\"Autor: \"+musicBy);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(m.getMusicType() != null){\n\t\t\t\t\t\t\tString genero = String.valueOf(m.getMusicType()).length()>12 ? String.valueOf(m.getMusicType()).substring(0,20)+\"...\":String.valueOf(m.getMusicType());\n\t\t\t\t\t\t\ttextViewGenero.setText(\"Genero: \"+genero);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfile = list.get(position);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tSystem.out.println(\"N\u00e3o foi possivel adicionar musica!\");\n\t\t\t\t\t}\n\t \t}\n\t }\n\t });\n\t}\n", "output": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_carregar);\n\t\ttextViewAutor = (TextView) findViewById(R.id.textAutor);\n\t\ttextViewAlbum = (TextView) findViewById(R.id.textAlbum);\n\t\ttextViewGenero = (TextView) findViewById(R.id.textGenero);\n\t\ttextViewAutor.setText(\"Autor: \"+\"Campo V\u00e1zio\");\n\t\ttextViewAlbum.setText(\"Album: \"+\"Campo V\u00e1zio\");\n\t\ttextViewGenero.setText(\"Genero: \"+\"Campo V\u00e1zio\");\n\t\tImageButton botaoAdd = (ImageButton) findViewById(R.id.botaoAddMusica);\n\t\tbotaoAdd.setOnClickListener(new View.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif(file != null){\n\t\t\t\t\tif (!(ListMusic.getInstance().getListMusic().contains(file))){\n\t\t\t\t\t\tListMusic.getInstance().addMusica(file);\n\t\t\t\t\t\tMainActivity.fileAdapter.notifyDataSetChanged();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tsdcard = Environment.getExternalStorageDirectory();\n\t\tfinal File[] files = sdcard.listFiles();\n\t\tlistView = (ListView) findViewById(R.id.files);\n\t\tupdateList(files);\n\t\tadapter = new FileAdapter(getApplicationContext(), list);\n\t\tlistView.setAdapter(adapter);\n\t\tlistView.setOnItemClickListener(new OnItemClickListener() {\n\t @Override\n\t\t\tpublic void onItemClick(AdapterView<?> a, View v, int position, long id) {\n\t \tif (list.get(position).isDirectory()){\n\t \t\tFile[] filesAux = list.get(position).listFiles();\n\t \t\tFile auxParent = list.get(position).getParentFile();\n\t \t\tupdateList(filesAux);\n\t \t\tlist.add(0, auxParent);\n\t \t\tadapter.notifyDataSetChanged();\n\t \t}else{\n\t \t\ttry {\n\t \t\t\tSystem.out.println(\"entrou\");\n\t\t\t\t\t\tMP3 m = new MP3(list.get(position));\n\t\t\t\t\t\tif(m.getAlbum()!=null && m.getAlbum().length()>20){\n\t\t\t\t\t\t\tString album = String.valueOf(m.getAlbum()).length()>12 ? String.valueOf(m.getAlbum()).substring(0,20)+\"...\":String.valueOf(m.getAlbum());\n\t\t\t\t\t\t\ttextViewAlbum.setText(\"Album: \"+album);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(m.getMusicBy() !=null && m.getMusicBy().length()> 20){\n\t\t\t\t\t\t\tString musicBy = String.valueOf(m.getMusicBy()).length()>12 ? String.valueOf(m.getMusicBy()).substring(0,20)+\"...\":String.valueOf(m.getMusicBy());\n\t\t\t\t\t\t\ttextViewAutor.setText(\"Autor: \"+musicBy);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(m.getMusicType() != null && m.getMusicType().length()>20){\n\t\t\t\t\t\t\tString genero = String.valueOf(m.getMusicType()).length()>12 ? String.valueOf(m.getMusicType()).substring(0,20)+\"...\":String.valueOf(m.getMusicType());\n\t\t\t\t\t\t\ttextViewGenero.setText(\"Genero: \"+genero);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfile = list.get(position);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\tSystem.out.println(\"N\u00e3o foi possivel adicionar musica!\");\n\t\t\t\t\t}\n\t \t}\n\t }\n\t });\n\t}\n"} {"input": " public void initialize() throws OperatorException {\n Product aotProduct;\n if (step1) {\n aotProduct = processAot(sourceProduct);\n if (aotProduct == GaMasterOp.EMPTY_PRODUCT) {\n setTargetProduct(GaMasterOp.EMPTY_PRODUCT);\n return;\n }\n } else {\n aotProduct = sourceProduct;\n }\n if (useFileTileCache) {\n attachFileTileCache(aotProduct);\n }\n Product bbdrProduct;\n if (step2) {\n bbdrProduct = processBbdr(aotProduct);\n if (sensor == Sensor.MERIS) {\n for (String rayleighBandName : BRR_BANDS) {\n bbdrProduct.addBand(aotProduct.getBand(rayleighBandName));\n }\n }\n } else {\n bbdrProduct = aotProduct;\n }\n setTargetProduct(bbdrProduct);\n }\n", "output": " public void initialize() throws OperatorException {\n Product aotProduct;\n if (step1) {\n aotProduct = processAot(sourceProduct);\n if (aotProduct == GaMasterOp.EMPTY_PRODUCT) {\n setTargetProduct(GaMasterOp.EMPTY_PRODUCT);\n return;\n }\n } else {\n aotProduct = sourceProduct;\n }\n if (useFileTileCache) {\n attachFileTileCache(aotProduct);\n }\n Product bbdrProduct;\n if (step2) {\n bbdrProduct = processBbdr(aotProduct);\n if (sensor == Sensor.MERIS && idepixAlgorithm == CloudScreeningSelector.GlobAlbedo) {\n for (String rayleighBandName : BRR_BANDS) {\n bbdrProduct.addBand(aotProduct.getBand(rayleighBandName));\n }\n }\n } else {\n bbdrProduct = aotProduct;\n }\n setTargetProduct(bbdrProduct);\n }\n"} {"input": " public synchronized void populateQuestions() {\n Logger.d(TAG, \"Populating poll\");\n int nSlots = questionsStorage.getNSlotsPerPoll();\n HashMap<Integer, ArrayList<Question>> slots =\n new HashMap<Integer, ArrayList<Question>>();\n SlottedQuestions slottedQuestions =\n questionsStorage.getSlottedQuestions();\n Logger.v(TAG, \"Got {} questions from DB\", slottedQuestions.size());\n HashMap<Integer, ArrayList<Question>> positionedGroups =\n slottedQuestions.getPositionedQuestionGroups();\n Logger.v(TAG, \"Got {} positioned question groups\",\n positionedGroups.size());\n int originalIndex;\n int convertedIndex;\n for (Map.Entry<Integer, ArrayList<Question>> groupEntry :\n positionedGroups.entrySet()) {\n originalIndex = groupEntry.getKey();\n convertedIndex = originalIndex < 0 ?\n nSlots + originalIndex : originalIndex;\n Logger.v(TAG, \"Placing group at slot {}\", convertedIndex);\n slots.put(convertedIndex, groupEntry.getValue());\n }\n ArrayList<Integer> remainingIndices = new ArrayList<Integer>();\n for (int i = 0; i < nSlots; i++) {\n if (!slots.containsKey(i)) {\n remainingIndices.add(i);\n }\n }\n int nFloatingToFill = remainingIndices.size();\n Logger.v(TAG, \"Still have {} slots to fill\", nFloatingToFill);\n ArrayList<ArrayList<Question>> floatingGroups =\n slottedQuestions.getRandomFloatingQuestionGroups(\n nFloatingToFill);\n Logger.v(TAG, \"Got {} floating groups to fill the slots\",\n floatingGroups.size());\n for (int i = 0; i < nFloatingToFill; i++) {\n Logger.v(TAG, \"Putting group {0} at slot {1}\",\n floatingGroups.get(i).get(0).getSlot(),\n remainingIndices.get(i));\n slots.put(remainingIndices.get(i), floatingGroups.get(i));\n }\n ArrayList<ArrayList<Question>> slotsArray =\n new ArrayList<ArrayList<Question>>(nSlots);\n ArrayList<Question> slotQuestions;\n for (Map.Entry<Integer, ArrayList<Question>> groupEntry :\n slots.entrySet()) {\n Logger.v(TAG, \"Shuffling slot {}\", groupEntry.getKey());\n slotQuestions = groupEntry.getValue();\n util.shuffle(slotQuestions);\n slotsArray.add(groupEntry.getKey(), slotQuestions);\n }\n Logger.v(TAG, \"Flattening the slots into an array\");\n questions = new ArrayList<Question>();\n for (ArrayList<Question> slot : slotsArray) {\n questions.addAll(slot);\n }\n }\n", "output": " public synchronized void populateQuestions() {\n Logger.d(TAG, \"Populating poll\");\n int nSlots = questionsStorage.getNSlotsPerPoll();\n HashMap<Integer, ArrayList<Question>> slots =\n new HashMap<Integer, ArrayList<Question>>();\n SlottedQuestions slottedQuestions =\n questionsStorage.getSlottedQuestions();\n Logger.v(TAG, \"Got {} questions from DB\", slottedQuestions.size());\n HashMap<Integer, ArrayList<Question>> positionedGroups =\n slottedQuestions.getPositionedQuestionGroups();\n Logger.v(TAG, \"Got {} positioned question groups\",\n positionedGroups.size());\n int originalIndex;\n int convertedIndex;\n for (Map.Entry<Integer, ArrayList<Question>> groupEntry :\n positionedGroups.entrySet()) {\n originalIndex = groupEntry.getKey();\n convertedIndex = originalIndex < 0 ?\n nSlots + originalIndex : originalIndex;\n Logger.v(TAG, \"Placing group at slot {}\", convertedIndex);\n slots.put(convertedIndex, groupEntry.getValue());\n }\n ArrayList<Integer> remainingIndices = new ArrayList<Integer>();\n for (int i = 0; i < nSlots; i++) {\n if (!slots.containsKey(i)) {\n remainingIndices.add(i);\n }\n }\n int nFloatingToFill = remainingIndices.size();\n Logger.v(TAG, \"Still have {} slots to fill\", nFloatingToFill);\n ArrayList<ArrayList<Question>> floatingGroups =\n slottedQuestions.getRandomFloatingQuestionGroups(\n nFloatingToFill);\n Logger.v(TAG, \"Got {} floating groups to fill the slots\",\n floatingGroups.size());\n for (int i = 0; i < nFloatingToFill; i++) {\n Logger.v(TAG, \"Putting group {0} at slot {1}\",\n floatingGroups.get(i).get(0).getSlot(),\n remainingIndices.get(i));\n slots.put(remainingIndices.get(i), floatingGroups.get(i));\n }\n ArrayList<ArrayList<Question>> slotsArray =\n new ArrayList<ArrayList<Question>>(nSlots);\n ArrayList<Question> slotQuestions;\n for (Map.Entry<Integer, ArrayList<Question>> groupEntry :\n slots.entrySet()) {\n Logger.v(TAG, \"Shuffling slot {}\", groupEntry.getKey());\n slotQuestions = groupEntry.getValue();\n util.shuffle(slotQuestions);\n slotsArray.add(groupEntry.getKey(), slotQuestions);\n }\n Logger.v(TAG, \"Flattening the slots into an array\");\n questions = new ArrayList<Question>();\n for (ArrayList<Question> slot : slotsArray) {\n for (Question q : slot) {\n addQuestion(q);\n }\n }\n }\n"} {"input": " public void mergeAlignment() {\n final SAMRecordQueryNameComparator comparator = new SAMRecordQueryNameComparator();\n final SAMFileReader unmappedSam = new SAMFileReader(this.unmappedBamFile);\n final CloseableIterator<SAMRecord> unmappedIterator = unmappedSam.iterator();\n this.header.setReadGroups(unmappedSam.getFileHeader().getReadGroups());\n int aligned = 0;\n int unmapped = 0;\n final CloseableIterator<SAMRecord> alignedIterator = getQuerynameSortedAlignedRecords();\n SAMRecord nextAligned = alignedIterator.hasNext() ? alignedIterator.next() : null;\n final SortingCollection<SAMRecord> coordinateSorted = SortingCollection.newInstance(\n SAMRecord.class, new BAMRecordCodec(header), new SAMRecordCoordinateComparator(),\n MAX_RECORDS_IN_RAM);\n SAMRecord firstOfPair = null;\n while (unmappedIterator.hasNext()) {\n final SAMRecord rec = unmappedIterator.next();\n if (nextAligned != null && comparator.compare(rec, nextAligned) > 0) {\n throw new IllegalStateException(\"Aligned record iterator (\" + nextAligned.getReadName() +\n \") is behind the unmapped reads (\" + rec.getReadName() + \")\");\n }\n rec.setHeader(this.header);\n if (isMatch(rec, nextAligned)) {\n if (!(nextAligned.getReadUnmappedFlag() || ignoreAlignment(nextAligned))) {\n setValuesFromAlignment(rec, nextAligned);\n updateCigarForTrimmedOrClippedBases(rec, nextAligned);\n if (this.programRecord != null) {\n rec.setAttribute(ReservedTagConstants.PROGRAM_GROUP_ID,\n this.programRecord.getProgramGroupId());\n }\n aligned++;\n }\n else {\n unmapped++;\n }\n nextAligned = alignedIterator.hasNext() ? alignedIterator.next() : null;\n }\n else {\n unmapped++;\n }\n if (!rec.getReadPairedFlag()) {\n if (!rec.getReadUnmappedFlag() || !alignedReadsOnly) {\n coordinateSorted.add(rec);\n }\n }\n else {\n if (firstOfPair == null) {\n firstOfPair = rec;\n }\n else { \n if (!rec.getReadName().equals(firstOfPair.getReadName())) {\n coordinateSorted.add(firstOfPair);\n firstOfPair = rec;\n }\n else {\n if ((!rec.getReadUnmappedFlag() || !firstOfPair.getReadUnmappedFlag()) || !alignedReadsOnly) {\n clipForOverlappingReads(rec, firstOfPair);\n SamPairUtil.setProperPairAndMateInfo(rec, firstOfPair, header, expectedOrientations);\n coordinateSorted.add(firstOfPair);\n coordinateSorted.add(rec);\n firstOfPair = null;\n }\n }\n }\n }\n }\n unmappedIterator.close();\n if (alignedIterator.hasNext()) {\n throw new IllegalStateException(\"Reads remaining on alignment iterator: \" + alignedIterator.next().getReadName() + \"!\");\n }\n alignedIterator.close();\n final SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(header, true, this.targetBamFile);\n int count = 0;\n CloseableIterator<SAMRecord> it = coordinateSorted.iterator();\n while (it.hasNext()) {\n SAMRecord rec = it.next();\n if (!rec.getReadUnmappedFlag()) {\n if (refSeq != null) {\n byte referenceBases[] = refSeq.get(sequenceDictionary.getSequenceIndex(rec.getReferenceName())).getBases();\n rec.setAttribute(SAMTag.NM.name(),\n SequenceUtil.calculateSamNmTag(rec, referenceBases, 0, bisulfiteSequence));\n if (rec.getBaseQualities() != SAMRecord.NULL_QUALS) {\n rec.setAttribute(SAMTag.UQ.name(),\n SequenceUtil.sumQualitiesOfMismatches(rec, referenceBases, 0, bisulfiteSequence));\n }\n }\n }\n writer.addAlignment(rec);\n if (++count % 1000000 == 0) {\n log.info(count + \" SAMRecords written to \" + targetBamFile.getName());\n }\n }\n writer.close();\n log.info(\"Wrote \" + aligned + \" alignment records and \" + (alignedReadsOnly ? 0 : unmapped) + \" unmapped reads.\");\n }\n", "output": " public void mergeAlignment() {\n final SAMRecordQueryNameComparator comparator = new SAMRecordQueryNameComparator();\n final SAMFileReader unmappedSam = new SAMFileReader(this.unmappedBamFile);\n final CloseableIterator<SAMRecord> unmappedIterator = unmappedSam.iterator();\n this.header.setReadGroups(unmappedSam.getFileHeader().getReadGroups());\n int aligned = 0;\n int unmapped = 0;\n final CloseableIterator<SAMRecord> alignedIterator = getQuerynameSortedAlignedRecords();\n SAMRecord nextAligned = alignedIterator.hasNext() ? alignedIterator.next() : null;\n final SortingCollection<SAMRecord> coordinateSorted = SortingCollection.newInstance(\n SAMRecord.class, new BAMRecordCodec(header), new SAMRecordCoordinateComparator(),\n MAX_RECORDS_IN_RAM);\n SAMRecord firstOfPair = null;\n while (unmappedIterator.hasNext()) {\n final SAMRecord rec = unmappedIterator.next();\n if (nextAligned != null && comparator.compare(rec, nextAligned) > 0) {\n throw new IllegalStateException(\"Aligned record iterator (\" + nextAligned.getReadName() +\n \") is behind the unmapped reads (\" + rec.getReadName() + \")\");\n }\n rec.setHeader(this.header);\n if (isMatch(rec, nextAligned)) {\n if (!(nextAligned.getReadUnmappedFlag() || ignoreAlignment(nextAligned))) {\n setValuesFromAlignment(rec, nextAligned);\n updateCigarForTrimmedOrClippedBases(rec, nextAligned);\n if (this.programRecord != null) {\n rec.setAttribute(ReservedTagConstants.PROGRAM_GROUP_ID,\n this.programRecord.getProgramGroupId());\n }\n aligned++;\n }\n else {\n unmapped++;\n }\n nextAligned = alignedIterator.hasNext() ? alignedIterator.next() : null;\n }\n else {\n unmapped++;\n }\n if (!rec.getReadPairedFlag()) {\n if (!rec.getReadUnmappedFlag() || !alignedReadsOnly) {\n coordinateSorted.add(rec);\n }\n }\n else {\n if (firstOfPair == null) {\n firstOfPair = rec;\n }\n else { \n if (!rec.getReadName().equals(firstOfPair.getReadName())) {\n throw new PicardException(\"Second read from pair not found in unmapped bam: \" +\n rec.getReadName());\n }\n else {\n if ((!rec.getReadUnmappedFlag() || !firstOfPair.getReadUnmappedFlag()) || !alignedReadsOnly) {\n clipForOverlappingReads(rec, firstOfPair);\n SamPairUtil.setProperPairAndMateInfo(rec, firstOfPair, header, expectedOrientations);\n coordinateSorted.add(firstOfPair);\n coordinateSorted.add(rec);\n firstOfPair = null;\n }\n }\n }\n }\n }\n unmappedIterator.close();\n if (alignedIterator.hasNext()) {\n throw new IllegalStateException(\"Reads remaining on alignment iterator: \" + alignedIterator.next().getReadName() + \"!\");\n }\n alignedIterator.close();\n final SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(header, true, this.targetBamFile);\n int count = 0;\n CloseableIterator<SAMRecord> it = coordinateSorted.iterator();\n while (it.hasNext()) {\n SAMRecord rec = it.next();\n if (!rec.getReadUnmappedFlag()) {\n if (refSeq != null) {\n byte referenceBases[] = refSeq.get(sequenceDictionary.getSequenceIndex(rec.getReferenceName())).getBases();\n rec.setAttribute(SAMTag.NM.name(),\n SequenceUtil.calculateSamNmTag(rec, referenceBases, 0, bisulfiteSequence));\n if (rec.getBaseQualities() != SAMRecord.NULL_QUALS) {\n rec.setAttribute(SAMTag.UQ.name(),\n SequenceUtil.sumQualitiesOfMismatches(rec, referenceBases, 0, bisulfiteSequence));\n }\n }\n }\n writer.addAlignment(rec);\n if (++count % 1000000 == 0) {\n log.info(count + \" SAMRecords written to \" + targetBamFile.getName());\n }\n }\n writer.close();\n log.info(\"Wrote \" + aligned + \" alignment records and \" + (alignedReadsOnly ? 0 : unmapped) + \" unmapped reads.\");\n }\n"} {"input": "\tpublic Rock(Stage stage,float fallSpeed,float rotationSpeed, float width, float height){\n\t\tthis.fallSpeed = fallSpeed;\n\t\tthis.rotationSpeed = rotationSpeed;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\tthis.rgn = new TextureRegion(Assets.get().rock);\n\t\tsetSize(this.width,this.height);\n\t\tsetOrigin(this.width/2,this.height/2);\n\t\tfloat x = (random.nextFloat() *stage.getWidth());\n\t\tsetPosition(x,stage.getHeight());\n\t\taddAction(sequence(\n\t\t\t\tmoveTo(x, stage.getHeight()+32f, this.fallSpeed),\n\t\t\t\trun(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tRock.this.remove();\n\t\t\t\t\t}})\n\t\t\t\t));\n\t\taddAction(forever(rotateBy(360, this.rotationSpeed)));\n\t}\n", "output": "\tpublic Rock(Stage stage,float fallSpeed,float rotationSpeed, float width, float height){\n\t\tthis.fallSpeed = fallSpeed;\n\t\tthis.rotationSpeed = rotationSpeed;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\tthis.rgn = new TextureRegion(Assets.get().rock);\n\t\tsetSize(this.width,this.height);\n\t\tsetOrigin(this.width/2,this.height/2);\n\t\tfloat x = (random.nextFloat() *stage.getWidth());\n\t\tsetPosition(x,stage.getHeight());\n\t\taddAction(sequence(\n\t\t\t\tmoveTo(x, -32f, this.fallSpeed),\n\t\t\t\trun(new Runnable() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\tRock.this.remove();\n\t\t\t\t\t}})\n\t\t\t\t));\n\t\taddAction(forever(rotateBy(360, this.rotationSpeed)));\n\t}\n"} {"input": " public void execute(CancellationToken cancelToken) {\n assert eventScheduler.isExecutingInThis();\n OrderedData<DataType> data = pollData();\n if (data == null) {\n return;\n }\n if (forwardedData && data.getIndex() <= lastSentIndex) {\n return;\n }\n if (done) {\n return;\n }\n wrappedListener.onDataArrive(data.getRawData());\n }\n", "output": " public void execute(CancellationToken cancelToken) {\n assert eventScheduler.isExecutingInThis();\n OrderedData<DataType> data = pollData();\n if (data == null) {\n return;\n }\n if (forwardedData && data.getIndex() <= lastSentIndex) {\n return;\n }\n if (done) {\n return;\n }\n lastSentIndex = data.getIndex();\n forwardedData = true;\n wrappedListener.onDataArrive(data.getRawData());\n }\n"} {"input": " public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\n this.client = client;\n final ArrayList<Widget> oldWidgets = new ArrayList<Widget>();\n for (final Iterator<Widget> iterator = iterator(); iterator\n .hasNext();) {\n oldWidgets.add(iterator.next());\n }\n clear();\n ValueMap mapAttribute = null;\n if (uidl.hasAttribute(\"css\")) {\n mapAttribute = uidl.getMapAttribute(\"css\");\n }\n for (final Iterator<Object> i = uidl.getChildIterator(); i\n .hasNext();) {\n final UIDL r = (UIDL) i.next();\n final Paintable child = client.getPaintable(r);\n if (oldWidgets.contains(child)) {\n oldWidgets.remove(child);\n }\n add((Widget) child);\n if (mapAttribute != null && mapAttribute.containsKey(r.getId())) {\n String css = null;\n try {\n Style style = ((Widget) child).getElement().getStyle();\n css = mapAttribute.getString(r.getId());\n String[] cssRules = css.split(\";\");\n for (int j = 0; j < cssRules.length; j++) {\n String[] rule = cssRules[j].split(\":\");\n if (rule.length == 0) {\n continue;\n } else {\n style.setProperty(\n makeCamelCase(rule[0].trim()),\n rule[1].trim());\n }\n }\n } catch (Exception e) {\n VConsole.log(\"CssLayout encounterd invalid css string: \"\n + css);\n }\n }\n if (!r.getBooleanAttribute(\"cached\")) {\n child.updateFromUIDL(r, client);\n }\n }\n for (Widget w : oldWidgets) {\n if (w instanceof Paintable) {\n final Paintable p = (Paintable) w;\n client.unregisterPaintable(p);\n }\n widgetToCaption.remove(w);\n }\n }\n", "output": " public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\n this.client = client;\n final ArrayList<Widget> oldWidgets = new ArrayList<Widget>();\n for (final Iterator<Widget> iterator = iterator(); iterator\n .hasNext();) {\n oldWidgets.add(iterator.next());\n }\n clear();\n ValueMap mapAttribute = null;\n if (uidl.hasAttribute(\"css\")) {\n mapAttribute = uidl.getMapAttribute(\"css\");\n }\n for (final Iterator<Object> i = uidl.getChildIterator(); i\n .hasNext();) {\n final UIDL r = (UIDL) i.next();\n final Paintable child = client.getPaintable(r);\n if (oldWidgets.contains(child)) {\n oldWidgets.remove(child);\n VCaption vCaption = widgetToCaption.get(child);\n if (vCaption != null) {\n add(vCaption);\n oldWidgets.remove(vCaption);\n }\n }\n add((Widget) child);\n if (mapAttribute != null && mapAttribute.containsKey(r.getId())) {\n String css = null;\n try {\n Style style = ((Widget) child).getElement().getStyle();\n css = mapAttribute.getString(r.getId());\n String[] cssRules = css.split(\";\");\n for (int j = 0; j < cssRules.length; j++) {\n String[] rule = cssRules[j].split(\":\");\n if (rule.length == 0) {\n continue;\n } else {\n style.setProperty(\n makeCamelCase(rule[0].trim()),\n rule[1].trim());\n }\n }\n } catch (Exception e) {\n VConsole.log(\"CssLayout encounterd invalid css string: \"\n + css);\n }\n }\n if (!r.getBooleanAttribute(\"cached\")) {\n child.updateFromUIDL(r, client);\n }\n }\n for (Widget w : oldWidgets) {\n if (w instanceof Paintable) {\n final Paintable p = (Paintable) w;\n client.unregisterPaintable(p);\n }\n widgetToCaption.remove(w);\n }\n }\n"} {"input": "\tpublic static HttpRequestMessage of(ByteBuffer buffer) {\n\t\tString raw = new String(buffer.array(), Charset.forName(\"US-ASCII\"));\n\t\tString[] fields = raw.split(\"\\\\r\\\\n\");\n\t\tString requestLine = fields[0];\n\t\tMap<String, String> generalHeaders = new HashMap<String, String>();\n\t\tfor (int i = 1; i < fields.length; i++) {\n\t\t\tString[] header = fields[i].split(\": \");\n\t\t\tgeneralHeaders.put(header[0], header[1]);\n\t\t}\n\t\treturn new HttpRequestMessage(requestLine, generalHeaders);\n\t}\n", "output": "\tpublic static HttpRequestMessage of(ByteBuffer buffer) {\n\t\tString raw = new String(buffer.array(), Charset.forName(\"US-ASCII\"));\n\t\tString[] fields = raw.split(\"\\\\r\\\\n\");\n\t\tString requestLine = fields[0];\n\t\tMap<String, String> generalHeaders = new HashMap<String, String>();\n\t\tfor (int i = 1; i < fields.length; i++) {\n\t\t\tif (fields[i].trim().equals(\"\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tString[] header = fields[i].split(\": \");\n\t\t\tgeneralHeaders.put(header[0], header[1]);\n\t\t}\n\t\treturn new HttpRequestMessage(requestLine, generalHeaders);\n\t}\n"} {"input": "\t@Test public void testEmail(){\n\t\tBoolean doIreallyWantToSpam = false; \n\t String from = \"\";\n\t String[] recipients = { \"\"};\n\t String SMTP_HOST_NAME = \"localhost\";\n\t String SMTP_PORT = \"25\";\n\t String message = \"Hi, Test Message Contents\";\n\t String subject = \"A test from collectionspace test suite\";\n\t String SSL_FACTORY = \"javax.net.ssl.SSLSocketFactory\";\n Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());\n boolean debug = true;\n Properties props = new Properties();\n props.put(\"mail.smtp.host\", SMTP_HOST_NAME);\n props.put(\"mail.smtp.auth\", \"false\");\n props.put(\"mail.debug\", \"true\");\n props.put(\"mail.smtp.port\", SMTP_PORT);\n props.put(\"mail.smtp.socketFactory.port\", SMTP_PORT);\n props.put(\"mail.smtp.socketFactory.class\", SSL_FACTORY);\n props.put(\"mail.smtp.socketFactory.fallback\", \"false\");\n Session session = Session.getDefaultInstance(props);\n session.setDebug(debug);\n Message msg = new MimeMessage(session);\n InternetAddress addressFrom;\n\t\ttry {\n\t\t\taddressFrom = new InternetAddress(from);\n msg.setFrom(addressFrom);\n InternetAddress[] addressTo = new InternetAddress[recipients.length];\n for (int i = 0; i < recipients.length; i++) {\n addressTo[i] = new InternetAddress(recipients[i]);\n }\n msg.setRecipients(Message.RecipientType.TO, addressTo);\n msg.setSubject(subject);\n msg.setContent(message, \"text/plain\");\n if(doIreallyWantToSpam){\n \tTransport.send(msg);\n \tassertTrue(doIreallyWantToSpam);\n }\n\t\t} catch (AddressException e) {\n\t\t\tlog.info(e.getMessage());\n\t\t\tassertTrue(false);\n\t\t} catch (MessagingException e) {\n\t\t\tlog.info(e.getMessage());\n\t\t\tassertTrue(false);\n\t\t}\n\t}\n", "output": "\t@Test public void testEmail(){\n\t\tBoolean doIreallyWantToSpam = false; \n\t String from = \"\";\n\t String[] recipients = { \"\"};\n\t String SMTP_HOST_NAME = \"localhost\";\n\t String SMTP_PORT = \"25\";\n\t String message = \"Hi, Test Message Contents\";\n\t String subject = \"A test from collectionspace test suite\";\n\t String SSL_FACTORY = \"javax.net.ssl.SSLSocketFactory\";\n Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());\n boolean debug = true;\n Properties props = new Properties();\n props.put(\"mail.smtp.host\", SMTP_HOST_NAME);\n props.put(\"mail.smtp.auth\", \"false\");\n props.put(\"mail.debug\", \"true\");\n props.put(\"mail.smtp.port\", SMTP_PORT);\n props.put(\"mail.smtp.socketFactory.port\", SMTP_PORT);\n props.put(\"mail.smtp.socketFactory.class\", SSL_FACTORY);\n props.put(\"mail.smtp.socketFactory.fallback\", \"false\");\n Session session = Session.getDefaultInstance(props);\n session.setDebug(debug);\n if(doIreallyWantToSpam){\n Message msg = new MimeMessage(session);\n InternetAddress addressFrom;\n\t\ttry {\n\t\t\taddressFrom = new InternetAddress(from);\n msg.setFrom(addressFrom);\n InternetAddress[] addressTo = new InternetAddress[recipients.length];\n for (int i = 0; i < recipients.length; i++) {\n addressTo[i] = new InternetAddress(recipients[i]);\n }\n msg.setRecipients(Message.RecipientType.TO, addressTo);\n msg.setSubject(subject);\n msg.setContent(message, \"text/plain\");\n if(doIreallyWantToSpam){\n \tTransport.send(msg);\n \tassertTrue(doIreallyWantToSpam);\n }\n\t\t} catch (AddressException e) {\n\t\t\tlog.info(e.getMessage());\n\t\t\tassertTrue(false);\n\t\t} catch (MessagingException e) {\n\t\t\tlog.info(e.getMessage());\n\t\t\tassertTrue(false);\n\t\t}\n\t\t}\n\t}\n"} {"input": " public void addBody(Body body) throws WingException, SQLException\n {\n EPerson currentUser = context.getCurrentUser();\n if (currentUser != null)\n {\n Statement statement = context.getDBConnection().createStatement();\n String title_field_query =\n \"SELECT metadata_field_id\" +\n \" FROM metadatafieldregistry AS fields,\" +\n \" metadataschemaregistry AS schemas\" +\n \" WHERE fields.metadata_schema_id\" +\n \" = schemas.metadata_schema_id\" +\n \" AND schemas.short_id = 'dc'\" +\n \" AND fields.element = 'title'\" +\n \" AND fields.qualifier IS NULL\" +\n \" LIMIT 1;\";\n ResultSet dcTitleField = statement.executeQuery(title_field_query);\n dcTitleField.next();\n String dcTitleID = dcTitleField.getString(\"metadata_field_id\");\n String submissions_query =\n \"SELECT COUNT(metadatavalue.text_value)\" +\n \" FROM workflowitem, item, metadatavalue\" +\n \" WHERE workflowitem.item_id = item.item_id\" +\n \" AND item.item_id = metadatavalue.item_id\" +\n \" AND metadatavalue.metadata_field_id = \" + dcTitleID +\n \" AND item.submitter_id = \" + currentUser.getID() + \";\";\n ResultSet submissions = statement.executeQuery(submissions_query);\n submissions.next();\n int rowCount = submissions.getInt(1);\n if (rowCount > 0)\n {\n Message T_link;\n Message T_outtro;\n if (rowCount == 1)\n {\n T_link = T_one_pending_submission;\n T_outtro = T_pending_submissions_outtro_single;\n }\n else\n {\n T_link =\n T_multiple_pending_submissions.parameterize(rowCount);\n T_outtro = T_pending_submissions_outtro_multiple;\n }\n Division pending = body.addDivision(\"pending-submissions\");\n Para para = pending.addPara();\n para.addContent(T_pending_submissions_intro);\n para.addXref(\"submissions\", T_link);\n para.addContent(T_outtro);\n }\n }\n }\n", "output": " public void addBody(Body body) throws WingException, SQLException\n {\n EPerson currentUser = context.getCurrentUser();\n if (currentUser != null)\n {\n Statement statement = context.getDBConnection().createStatement();\n String title_field_query =\n \"SELECT metadata_field_id\" +\n \" FROM metadatafieldregistry AS fields,\" +\n \" metadataschemaregistry AS schemas\" +\n \" WHERE fields.metadata_schema_id\" +\n \" = schemas.metadata_schema_id\" +\n \" AND schemas.short_id = 'dc'\" +\n \" AND fields.element = 'title'\" +\n \" AND fields.qualifier IS NULL\" +\n \" LIMIT 1;\";\n ResultSet dcTitleField = statement.executeQuery(title_field_query);\n dcTitleField.next();\n String dcTitleID = dcTitleField.getString(\"metadata_field_id\");\n String submissions_query =\n \"SELECT COUNT(metadatavalue.text_value)\" +\n \" FROM workflowitem, item, metadatavalue\" +\n \" WHERE workflowitem.item_id = item.item_id\" +\n \" AND item.item_id = metadatavalue.item_id\" +\n \" AND metadatavalue.metadata_field_id = \" + dcTitleID +\n \" AND item.submitter_id = \" + currentUser.getID() + \";\";\n ResultSet submissions = statement.executeQuery(submissions_query);\n submissions.next();\n int rowCount = submissions.getInt(1);\n if (rowCount > 0)\n {\n Message T_link;\n Message T_outtro;\n if (rowCount == 1)\n {\n T_link = T_one_pending_submission;\n T_outtro = T_pending_submissions_outtro_single;\n }\n else\n {\n T_link =\n T_multiple_pending_submissions.parameterize(rowCount);\n T_outtro = T_pending_submissions_outtro_multiple;\n }\n Division pending = body.addDivision(\"pending-submissions\");\n Para para = pending.addPara();\n para.addContent(T_pending_submissions_intro);\n para.addXref(\"/xmlui/submissions\", T_link);\n para.addContent(T_outtro);\n }\n }\n }\n"} {"input": "\tpublic void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n\t\tSession session = HibernateSessionHelper.getSession();\n\t\tTemplate template = TemplateFactory.getTemplate(request, response);\n\t\tPrintWriter out = response.getWriter();\n\t\tTaskDAOIf taskDAO = DAOFactory.TaskDAOIf(session);\n\t\tTask task = taskDAO.getTask(Util.parseInteger(request.getParameter(\"taskid\"), 0));\n\t\tif (task == null) {\n\t\t\ttemplate.printTemplateHeader(\"Aufgabe nicht gefunden\");\n\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"?\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\ttemplate.printTemplateFooter();\n\t\t\treturn;\n\t\t}\n\t\tParticipationDAOIf participationDAO = DAOFactory.ParticipationDAOIf(session);\n\t\tParticipation studentParticipation = participationDAO.getParticipation(new SessionAdapter(request).getUser(session), task.getLecture());\n\t\tif (studentParticipation == null) {\n\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\tout.println(\"<div class=mid>Sie sind kein Teilnehmer dieser Veranstaltung.</div>\");\n\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"Overview\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\ttemplate.printTemplateFooter();\n\t\t\treturn;\n\t\t}\n\t\tboolean isMultipart = ServletFileUpload.isMultipartContent(request);\n\t\tint partnerID = 0;\n\t\tint uploadFor = 0;\n\t\tList<FileItem> items = null;\n\t\tif (!isMultipart) {\n\t\t\tpartnerID = Util.parseInteger(request.getParameter(\"partnerid\"), 0);\n\t\t} else {\n\t\t\tFileItemFactory factory = new DiskFileItemFactory();\n\t\t\tServletFileUpload upload = new ServletFileUpload(factory);\n\t\t\ttry {\n\t\t\t\titems = upload.parseRequest(request);\n\t\t\t} catch (FileUploadException e) {\n\t\t\t\tresponse.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tIterator<FileItem> iter = items.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tFileItem item = iter.next();\n\t\t\t\tif (item.isFormField() && \"partnerid\".equals(item.getFieldName())) {\n\t\t\t\t\tpartnerID = Util.parseInteger(item.getString(), 0);\n\t\t\t\t} else if (item.isFormField() && \"uploadFor\".equals(item.getFieldName())) {\n\t\t\t\t\tuploadFor = Util.parseInteger(item.getString(), 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (uploadFor > 0) {\n\t\t\tif (!(studentParticipation.getRoleType() == ParticipationRole.ADVISOR || (task.isTutorsCanUploadFiles() && studentParticipation.getRoleType() == ParticipationRole.TUTOR))) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Sie sind nicht berechtigt bei dieser Veranstaltung Dateien f\ufffdr Studenten hochzuladen.</div>\");\n\t\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"Overview\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstudentParticipation = participationDAO.getParticipation(uploadFor);\n\t\t\tif (studentParticipation == null || studentParticipation.getLecture().getId() != task.getLecture().getId()) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Der gew\ufffdhlte Student ist kein Teilnehmer dieser Veranstaltung.</div>\");\n\t\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"Overview\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.isShowTextArea() == false && \"-\".equals(task.getFilenameRegexp())) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Das Einsenden von L\ufffdsungen ist f\ufffdr diese Aufgabe deaktiviert.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\tif (studentParticipation.getRoleType() == ParticipationRole.ADVISOR || studentParticipation.getRoleType() == ParticipationRole.TUTOR) {\n\t\t\t\trequest.setAttribute(\"title\", \"Betreuer und Tutoren k\ufffdnnen keine eigenen L\ufffdsungen einsenden.\");\n\t\t\t\trequest.getRequestDispatcher(\"MessageView\").forward(request, response);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.getStart().after(Util.correctTimezone(new Date()))) {\n\t\t\t\trequest.setAttribute(\"title\", \"Abgabe nicht gefunden\");\n\t\t\t\trequest.getRequestDispatcher(\"MessageView\").forward(request, response);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.getDeadline().before(Util.correctTimezone(new Date()))) {\n\t\t\t\trequest.setAttribute(\"title\", \"Abgabe nicht mehr m\ufffdglich\");\n\t\t\t\trequest.getRequestDispatcher(\"MessageView\").forward(request, response);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isMultipart && \"-\".equals(task.getFilenameRegexp())) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Dateiupload ist f\ufffdr diese Aufgabe deaktiviert.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t} else if (!isMultipart && !task.isShowTextArea()) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Textl\ufffdsungen sind f\ufffdr diese Aufgabe deaktiviert.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tSubmissionDAOIf submissionDAO = DAOFactory.SubmissionDAOIf(session);\n\t\tTransaction tx = session.beginTransaction();\n\t\tSubmission submission = submissionDAO.createSubmission(task, studentParticipation);\n\t\tif (partnerID > 0) {\n\t\t\tParticipation partnerParticipation = participationDAO.getParticipation(partnerID);\n\t\t\tif (submission.getSubmitters().size() < 2 && partnerParticipation != null && partnerParticipation.getLecture().getId() == task.getLecture().getId() && submissionDAO.getSubmissionLocked(task, partnerParticipation.getUser()) == null) {\n\t\t\t\tsubmission.getSubmitters().add(partnerParticipation);\n\t\t\t\tsession.update(submission);\n\t\t\t} else {\n\t\t\t\ttx.rollback();\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Der ausgew\ufffdhlte Partner hat bereits eine eigene Abgabe initiiert oder Sie haben bereits einen Partner ausgew\ufffdhlt.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tContextAdapter contextAdapter = new ContextAdapter(getServletContext());\n\t\tFile path = new File(contextAdapter.getDataPath().getAbsolutePath() + System.getProperty(\"file.separator\") + task.getLecture().getId() + System.getProperty(\"file.separator\") + task.getTaskid() + System.getProperty(\"file.separator\") + submission.getSubmissionid() + System.getProperty(\"file.separator\"));\n\t\tif (path.exists() == false) {\n\t\t\tpath.mkdirs();\n\t\t}\n\t\tif (isMultipart) {\n\t\t\tIterator<FileItem> iter = items.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tFileItem item = iter.next();\n\t\t\t\tif (!item.isFormField()) {\n\t\t\t\t\tif (item.getName().toLowerCase().endsWith(\".zip\") || item.getName().toLowerCase().endsWith(\".jar\")) {\n\t\t\t\t\t\tZipInputStream zipFile;\n\t\t\t\t\t\tPattern pattern = Pattern.compile(\"([\\\\/a-zA-Z0-9_.-]+)$\");\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tzipFile = new ZipInputStream(item.getInputStream());\n\t\t\t\t\t\t\tZipEntry entry = null;\n\t\t\t\t\t\t\twhile ((entry = zipFile.getNextEntry()) != null) {\n\t\t\t\t\t\t\t\tif (entry.getName().contains(\"..\")) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tStringBuffer submittedFileName = new StringBuffer(entry.getName());\n\t\t\t\t\t\t\t\tif (!pattern.matcher(submittedFileName).matches()) {\n\t\t\t\t\t\t\t\t\tSystem.out.println(\"Ignored entry: \" + submittedFileName);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (entry.isDirectory() == false && !entry.getName().toLowerCase().endsWith(\".class\")) {\n\t\t\t\t\t\t\t\t\tif (submittedFileName.lastIndexOf(\".\") > 0) {\n\t\t\t\t\t\t\t\t\t\tint lastDot = submittedFileName.lastIndexOf(\".\");\n\t\t\t\t\t\t\t\t\t\tsubmittedFileName.replace(lastDot, submittedFileName.length(), submittedFileName.subSequence(lastDot, submittedFileName.length()).toString().toLowerCase());\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tFile fileToCreate = new File(path, submittedFileName.toString());\n\t\t\t\t\t\t\t\t\tif (!fileToCreate.getParentFile().exists()) {\n\t\t\t\t\t\t\t\t\t\tfileToCreate.getParentFile().mkdirs();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcopyInputStream(zipFile, new BufferedOutputStream(new FileOutputStream(fileToCreate)));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tzipFile.close();\n\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\tUtil.recursiveDeleteEmptySubDirectories(path);\n\t\t\t\t\t\t\ttx.rollback();\n\t\t\t\t\t\t\tSystem.out.println(e.getMessage());\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\t\t\t\tout.println(\"Problem beim entpacken der .zip-Datei.\");\n\t\t\t\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tPattern pattern;\n\t\t\t\t\t\tif (task.getFilenameRegexp() == null || task.getFilenameRegexp().isEmpty() || uploadFor > 0) {\n\t\t\t\t\t\t\tpattern = Pattern.compile(\".*?(?:\\\\\\\\|/)?([a-zA-Z0-9_.-]+)$\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpattern = Pattern.compile(\".*?(?:\\\\\\\\|/)?(\" + task.getFilenameRegexp() + \")$\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tStringBuffer submittedFileName = new StringBuffer(item.getName());\n\t\t\t\t\t\tif (submittedFileName.lastIndexOf(\".\") > 0) {\n\t\t\t\t\t\t\tint lastDot = submittedFileName.lastIndexOf(\".\");\n\t\t\t\t\t\t\tsubmittedFileName.replace(lastDot, submittedFileName.length(), submittedFileName.subSequence(lastDot, submittedFileName.length()).toString().toLowerCase());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tMatcher m = pattern.matcher(submittedFileName);\n\t\t\t\t\t\tif (!m.matches()) {\n\t\t\t\t\t\t\ttx.rollback();\n\t\t\t\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\t\t\t\tout.println(\"Dateiname ung\ufffdltig bzw. entspricht nicht der Vorgabe (ist ein Klassenname vorgegeben, so muss die Datei genauso hei\ufffden).<br>Tipp: Nur A-Z, a-z, 0-9, ., - und _ sind erlaubt.\");\n\t\t\t\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tString fileName = m.group(1);\n\t\t\t\t\t\tFile uploadedFile = new File(path, fileName);\n\t\t\t\t\t\tif (fileName.toLowerCase().endsWith(\".java\")) {\n\t\t\t\t\t\t\tuploadedFile = File.createTempFile(\"upload\", null, path);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\titem.write(uploadedFile);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fileName.toLowerCase().endsWith(\".java\")) {\n\t\t\t\t\t\t\tNormalizerIf stripComments = new StripCommentsNormalizer();\n\t\t\t\t\t\t\tStringBuffer javaFileContents = stripComments.normalize(Util.loadFile(uploadedFile));\n\t\t\t\t\t\t\tPattern packagePattern = Pattern.compile(\".*package\\\\s+([a-zA-Z$]([a-zA-Z0-9_$]|\\\\.[a-zA-Z0-9_$])*)\\\\s*;.*\", Pattern.DOTALL);\n\t\t\t\t\t\t\tMatcher packageMatcher = packagePattern.matcher(javaFileContents);\n\t\t\t\t\t\t\tif (packageMatcher.matches()) {\n\t\t\t\t\t\t\t\tString packageName = packageMatcher.group(1).replace(\".\", System.getProperty(\"file.separator\"));\n\t\t\t\t\t\t\t\tFile packageDirectory = new File(path, packageName);\n\t\t\t\t\t\t\t\tpackageDirectory.mkdirs();\n\t\t\t\t\t\t\t\tuploadedFile.renameTo(new File(packageDirectory, fileName));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tuploadedFile.renameTo(new File(path, fileName));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsubmission.setLastModified(new Date());\n\t\t\t\t\tsubmissionDAO.saveSubmission(submission);\n\t\t\t\t\tUtil.recursiveDeleteEmptyDirectories(path);\n\t\t\t\t\ttx.commit();\n\t\t\t\t\tnew LogDAO(session).createLogEntry(studentParticipation.getUser(), null, task, LogAction.UPLOAD, null, null);\n\t\t\t\t\tresponse.sendRedirect(response.encodeRedirectURL(\"ShowTask?taskid=\" + task.getTaskid()));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttx.rollback();\n\t\t\tout.println(\"Problem: Keine Abgabedaten gefunden.\");\n\t\t} else if (request.getParameter(\"textsolution\") != null) {\n\t\t\tFile uploadedFile = new File(path, \"textloesung.txt\");\n\t\t\tFileWriter fileWriter = new FileWriter(uploadedFile);\n\t\t\tfileWriter.write(request.getParameter(\"textsolution\"));\n\t\t\tfileWriter.flush();\n\t\t\tfileWriter.close();\n\t\t\tsubmission.setLastModified(new Date());\n\t\t\tsubmissionDAO.saveSubmission(submission);\n\t\t\ttx.commit();\n\t\t\tresponse.sendRedirect(response.encodeRedirectURL(\"ShowTask?taskid=\" + task.getTaskid()));\n\t\t} else {\n\t\t\ttx.rollback();\n\t\t\tout.println(\"Problem: Keine Abgabedaten gefunden.\");\n\t\t}\n\t}\n", "output": "\tpublic void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n\t\tSession session = HibernateSessionHelper.getSession();\n\t\tTemplate template = TemplateFactory.getTemplate(request, response);\n\t\tPrintWriter out = response.getWriter();\n\t\tTaskDAOIf taskDAO = DAOFactory.TaskDAOIf(session);\n\t\tTask task = taskDAO.getTask(Util.parseInteger(request.getParameter(\"taskid\"), 0));\n\t\tif (task == null) {\n\t\t\ttemplate.printTemplateHeader(\"Aufgabe nicht gefunden\");\n\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"?\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\ttemplate.printTemplateFooter();\n\t\t\treturn;\n\t\t}\n\t\tParticipationDAOIf participationDAO = DAOFactory.ParticipationDAOIf(session);\n\t\tParticipation studentParticipation = participationDAO.getParticipation(new SessionAdapter(request).getUser(session), task.getLecture());\n\t\tif (studentParticipation == null) {\n\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\tout.println(\"<div class=mid>Sie sind kein Teilnehmer dieser Veranstaltung.</div>\");\n\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"Overview\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\ttemplate.printTemplateFooter();\n\t\t\treturn;\n\t\t}\n\t\tboolean isMultipart = ServletFileUpload.isMultipartContent(request);\n\t\tint partnerID = 0;\n\t\tint uploadFor = 0;\n\t\tList<FileItem> items = null;\n\t\tif (!isMultipart) {\n\t\t\tpartnerID = Util.parseInteger(request.getParameter(\"partnerid\"), 0);\n\t\t} else {\n\t\t\tFileItemFactory factory = new DiskFileItemFactory();\n\t\t\tServletFileUpload upload = new ServletFileUpload(factory);\n\t\t\ttry {\n\t\t\t\titems = upload.parseRequest(request);\n\t\t\t} catch (FileUploadException e) {\n\t\t\t\tresponse.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tIterator<FileItem> iter = items.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tFileItem item = iter.next();\n\t\t\t\tif (item.isFormField() && \"partnerid\".equals(item.getFieldName())) {\n\t\t\t\t\tpartnerID = Util.parseInteger(item.getString(), 0);\n\t\t\t\t} else if (item.isFormField() && \"uploadFor\".equals(item.getFieldName())) {\n\t\t\t\t\tuploadFor = Util.parseInteger(item.getString(), 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (uploadFor > 0) {\n\t\t\tif (!(studentParticipation.getRoleType() == ParticipationRole.ADVISOR || (task.isTutorsCanUploadFiles() && studentParticipation.getRoleType() == ParticipationRole.TUTOR))) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Sie sind nicht berechtigt bei dieser Veranstaltung Dateien f\ufffdr Studenten hochzuladen.</div>\");\n\t\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"Overview\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstudentParticipation = participationDAO.getParticipation(uploadFor);\n\t\t\tif (studentParticipation == null || studentParticipation.getLecture().getId() != task.getLecture().getId()) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Der gew\ufffdhlte Student ist kein Teilnehmer dieser Veranstaltung.</div>\");\n\t\t\t\tout.println(\"<div class=mid><a href=\\\"\" + response.encodeURL(\"Overview\") + \"\\\">zur \ufffdbersicht</a></div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.isShowTextArea() == false && \"-\".equals(task.getFilenameRegexp())) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Das Einsenden von L\ufffdsungen ist f\ufffdr diese Aufgabe deaktiviert.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\tif (studentParticipation.getRoleType() == ParticipationRole.ADVISOR || studentParticipation.getRoleType() == ParticipationRole.TUTOR) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Betreuer und Tutoren k\ufffdnnen keine eigenen L\ufffdsungen einsenden.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.getStart().after(Util.correctTimezone(new Date()))) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Abgabe nicht gefunden.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.getDeadline().before(Util.correctTimezone(new Date()))) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Abgabe nicht mehr m\ufffdglich.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isMultipart && \"-\".equals(task.getFilenameRegexp())) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Dateiupload ist f\ufffdr diese Aufgabe deaktiviert.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t} else if (!isMultipart && !task.isShowTextArea()) {\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Textl\ufffdsungen sind f\ufffdr diese Aufgabe deaktiviert.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tSubmissionDAOIf submissionDAO = DAOFactory.SubmissionDAOIf(session);\n\t\tTransaction tx = session.beginTransaction();\n\t\tSubmission submission = submissionDAO.createSubmission(task, studentParticipation);\n\t\tif (partnerID > 0) {\n\t\t\tParticipation partnerParticipation = participationDAO.getParticipation(partnerID);\n\t\t\tif (submission.getSubmitters().size() < 2 && partnerParticipation != null && partnerParticipation.getLecture().getId() == task.getLecture().getId() && submissionDAO.getSubmissionLocked(task, partnerParticipation.getUser()) == null) {\n\t\t\t\tsubmission.getSubmitters().add(partnerParticipation);\n\t\t\t\tsession.update(submission);\n\t\t\t} else {\n\t\t\t\ttx.rollback();\n\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\tout.println(\"<div class=mid>Der ausgew\ufffdhlte Partner hat bereits eine eigene Abgabe initiiert oder Sie haben bereits einen Partner ausgew\ufffdhlt.</div>\");\n\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tContextAdapter contextAdapter = new ContextAdapter(getServletContext());\n\t\tFile path = new File(contextAdapter.getDataPath().getAbsolutePath() + System.getProperty(\"file.separator\") + task.getLecture().getId() + System.getProperty(\"file.separator\") + task.getTaskid() + System.getProperty(\"file.separator\") + submission.getSubmissionid() + System.getProperty(\"file.separator\"));\n\t\tif (path.exists() == false) {\n\t\t\tpath.mkdirs();\n\t\t}\n\t\tif (isMultipart) {\n\t\t\tIterator<FileItem> iter = items.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t\tFileItem item = iter.next();\n\t\t\t\tif (!item.isFormField()) {\n\t\t\t\t\tif (item.getName().toLowerCase().endsWith(\".zip\") || item.getName().toLowerCase().endsWith(\".jar\")) {\n\t\t\t\t\t\tZipInputStream zipFile;\n\t\t\t\t\t\tPattern pattern = Pattern.compile(\"([\\\\/a-zA-Z0-9_.-]+)$\");\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tzipFile = new ZipInputStream(item.getInputStream());\n\t\t\t\t\t\t\tZipEntry entry = null;\n\t\t\t\t\t\t\twhile ((entry = zipFile.getNextEntry()) != null) {\n\t\t\t\t\t\t\t\tif (entry.getName().contains(\"..\")) {\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tStringBuffer submittedFileName = new StringBuffer(entry.getName());\n\t\t\t\t\t\t\t\tif (!pattern.matcher(submittedFileName).matches()) {\n\t\t\t\t\t\t\t\t\tSystem.out.println(\"Ignored entry: \" + submittedFileName);\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (entry.isDirectory() == false && !entry.getName().toLowerCase().endsWith(\".class\")) {\n\t\t\t\t\t\t\t\t\tif (submittedFileName.lastIndexOf(\".\") > 0) {\n\t\t\t\t\t\t\t\t\t\tint lastDot = submittedFileName.lastIndexOf(\".\");\n\t\t\t\t\t\t\t\t\t\tsubmittedFileName.replace(lastDot, submittedFileName.length(), submittedFileName.subSequence(lastDot, submittedFileName.length()).toString().toLowerCase());\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tFile fileToCreate = new File(path, submittedFileName.toString());\n\t\t\t\t\t\t\t\t\tif (!fileToCreate.getParentFile().exists()) {\n\t\t\t\t\t\t\t\t\t\tfileToCreate.getParentFile().mkdirs();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcopyInputStream(zipFile, new BufferedOutputStream(new FileOutputStream(fileToCreate)));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tzipFile.close();\n\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\tUtil.recursiveDeleteEmptySubDirectories(path);\n\t\t\t\t\t\t\ttx.rollback();\n\t\t\t\t\t\t\tSystem.out.println(e.getMessage());\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\t\t\t\tout.println(\"Problem beim entpacken der .zip-Datei.\");\n\t\t\t\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tPattern pattern;\n\t\t\t\t\t\tif (task.getFilenameRegexp() == null || task.getFilenameRegexp().isEmpty() || uploadFor > 0) {\n\t\t\t\t\t\t\tpattern = Pattern.compile(\".*?(?:\\\\\\\\|/)?([a-zA-Z0-9_.-]+)$\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpattern = Pattern.compile(\".*?(?:\\\\\\\\|/)?(\" + task.getFilenameRegexp() + \")$\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tStringBuffer submittedFileName = new StringBuffer(item.getName());\n\t\t\t\t\t\tif (submittedFileName.lastIndexOf(\".\") > 0) {\n\t\t\t\t\t\t\tint lastDot = submittedFileName.lastIndexOf(\".\");\n\t\t\t\t\t\t\tsubmittedFileName.replace(lastDot, submittedFileName.length(), submittedFileName.subSequence(lastDot, submittedFileName.length()).toString().toLowerCase());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tMatcher m = pattern.matcher(submittedFileName);\n\t\t\t\t\t\tif (!m.matches()) {\n\t\t\t\t\t\t\ttx.rollback();\n\t\t\t\t\t\t\ttemplate.printTemplateHeader(\"Ung\ufffdltige Anfrage\");\n\t\t\t\t\t\t\tout.println(\"Dateiname ung\ufffdltig bzw. entspricht nicht der Vorgabe (ist ein Klassenname vorgegeben, so muss die Datei genauso hei\ufffden).<br>Tipp: Nur A-Z, a-z, 0-9, ., - und _ sind erlaubt.\");\n\t\t\t\t\t\t\ttemplate.printTemplateFooter();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tString fileName = m.group(1);\n\t\t\t\t\t\tFile uploadedFile = new File(path, fileName);\n\t\t\t\t\t\tif (fileName.toLowerCase().endsWith(\".java\")) {\n\t\t\t\t\t\t\tuploadedFile = File.createTempFile(\"upload\", null, path);\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\titem.write(uploadedFile);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fileName.toLowerCase().endsWith(\".java\")) {\n\t\t\t\t\t\t\tNormalizerIf stripComments = new StripCommentsNormalizer();\n\t\t\t\t\t\t\tStringBuffer javaFileContents = stripComments.normalize(Util.loadFile(uploadedFile));\n\t\t\t\t\t\t\tPattern packagePattern = Pattern.compile(\".*package\\\\s+([a-zA-Z$]([a-zA-Z0-9_$]|\\\\.[a-zA-Z0-9_$])*)\\\\s*;.*\", Pattern.DOTALL);\n\t\t\t\t\t\t\tMatcher packageMatcher = packagePattern.matcher(javaFileContents);\n\t\t\t\t\t\t\tif (packageMatcher.matches()) {\n\t\t\t\t\t\t\t\tString packageName = packageMatcher.group(1).replace(\".\", System.getProperty(\"file.separator\"));\n\t\t\t\t\t\t\t\tFile packageDirectory = new File(path, packageName);\n\t\t\t\t\t\t\t\tpackageDirectory.mkdirs();\n\t\t\t\t\t\t\t\tuploadedFile.renameTo(new File(packageDirectory, fileName));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tuploadedFile.renameTo(new File(path, fileName));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tsubmission.setLastModified(new Date());\n\t\t\t\t\tsubmissionDAO.saveSubmission(submission);\n\t\t\t\t\tUtil.recursiveDeleteEmptyDirectories(path);\n\t\t\t\t\ttx.commit();\n\t\t\t\t\tnew LogDAO(session).createLogEntry(studentParticipation.getUser(), null, task, LogAction.UPLOAD, null, null);\n\t\t\t\t\tresponse.sendRedirect(response.encodeRedirectURL(\"ShowTask?taskid=\" + task.getTaskid()));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttx.rollback();\n\t\t\tout.println(\"Problem: Keine Abgabedaten gefunden.\");\n\t\t} else if (request.getParameter(\"textsolution\") != null) {\n\t\t\tFile uploadedFile = new File(path, \"textloesung.txt\");\n\t\t\tFileWriter fileWriter = new FileWriter(uploadedFile);\n\t\t\tfileWriter.write(request.getParameter(\"textsolution\"));\n\t\t\tfileWriter.flush();\n\t\t\tfileWriter.close();\n\t\t\tsubmission.setLastModified(new Date());\n\t\t\tsubmissionDAO.saveSubmission(submission);\n\t\t\ttx.commit();\n\t\t\tresponse.sendRedirect(response.encodeRedirectURL(\"ShowTask?taskid=\" + task.getTaskid()));\n\t\t} else {\n\t\t\ttx.rollback();\n\t\t\tout.println(\"Problem: Keine Abgabedaten gefunden.\");\n\t\t}\n\t}\n"} {"input": " public <T> boolean that(T actual, Matcher<? super T> matcher, String category, String reason, Object... messageParameters) {\n if (!matcher.matches(actual)) {\n \tif (reason != null) {\n \t\terrors.add(new I18nMessage(category, reason, messageParameters));\n } else {\n Description description = new ResourceBundleDescription();\n description.appendDescriptionOf(matcher);\n errors.add(new I18nMessage(description.toString(), category));\n }\n return false;\n }\n return true;\n }\n", "output": " public <T> boolean that(T actual, Matcher<? super T> matcher, String category, String reason, Object... messageParameters) {\n if (!matcher.matches(actual)) {\n \tif (reason != null) {\n \t\terrors.add(new I18nMessage(category, reason, messageParameters));\n } else {\n Description description = new ResourceBundleDescription();\n description.appendDescriptionOf(matcher);\n errors.add(new I18nMessage(category, description.toString(), actual));\n }\n return false;\n }\n return true;\n }\n"} {"input": " public Environment()\n throws IOException\n {\n String command = null;\n String OS = System.getProperty(\"os.name\");\n String lowerOs = OS.toLowerCase();\n if (OS.indexOf(\"Windows\") > -1) {\n command = \"cmd /C set\";\n } else if (OS.indexOf(\"ix\") > -1 || OS.indexOf(\"inux\") > -1) {\n command = \"env\";\n } else if(lowerOs.startsWith(\"mac os x\")) {\n command = \"env\";\n } else {\n }\n if (command == null) {\n throw new RuntimeException(\"Operating system \" + OS\n + \" not supported by this class\");\n }\n Process pid = Runtime.getRuntime().exec(command);\n BufferedReader in =\n new BufferedReader(\n new InputStreamReader(\n pid.getInputStream()));\n while(true) {\n String line = in.readLine();\n if (line == null)\n break;\n int p = line.indexOf(\"=\");\n if (p != -1) {\n String name = line.substring(0, p);\n String value = line.substring(p+1);\n setProperty(name, value);\n }\n }\n in.close();\n try {\n pid.waitFor();\n }\n catch (InterruptedException e) {\n throw new IOException(e.getMessage());\n }\n }\n", "output": " public Environment()\n throws IOException\n {\n String command = null;\n String OS = System.getProperty(\"os.name\");\n String lowerOs = OS.toLowerCase();\n if (OS.indexOf(\"Windows\") > -1) {\n command = \"cmd /C set\";\n } else if (lowerOs.indexOf(\"ix\") > -1 || lowerOs.indexOf(\"linux\") > -1 \n || lowerOs.indexOf(\"freebsd\") > -1\n || lowerOs.indexOf(\"sunos\") > -1 || lowerOs.indexOf(\"solaris\") > -1\n || lowerOs.indexOf(\"hp-ux\") > -1) {\n command = \"env\";\n } else if(lowerOs.startsWith(\"mac os x\")) {\n command = \"env\";\n } else {\n }\n if (command == null) {\n throw new RuntimeException(\"Operating system \" + OS\n + \" not supported by this class\");\n }\n Process pid = Runtime.getRuntime().exec(command);\n BufferedReader in =\n new BufferedReader(\n new InputStreamReader(\n pid.getInputStream()));\n while(true) {\n String line = in.readLine();\n if (line == null)\n break;\n int p = line.indexOf(\"=\");\n if (p != -1) {\n String name = line.substring(0, p);\n String value = line.substring(p+1);\n setProperty(name, value);\n }\n }\n in.close();\n try {\n pid.waitFor();\n }\n catch (InterruptedException e) {\n throw new IOException(e.getMessage());\n }\n }\n"} {"input": " protected long proxyPlainTextRequest(final URL url, String pathInContext, String pathParams, HttpRequest request, final HttpResponse response) throws IOException {\n try {\n String urlStr = url.toString();\n if (urlStr.startsWith(\"http://localhost\") || urlStr.contains(\"/selenium-server/\")) {\n return super.proxyPlainTextRequest(url, pathInContext, pathParams, request, response);\n }\n if (urlStr.startsWith(\"https://sb-ssl.google.com:443/safebrowsing\")\n || urlStr.startsWith(\"http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml\")\n || urlStr.startsWith(\"http://fxfeeds.mozilla.com/firefox/headlines.xml\")\n || urlStr.startsWith(\"http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml\")\n || urlStr.startsWith(\"http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml\")) {\n request.setHandled(true);\n return -1;\n }\n if (httpClient == null) {\n request.setHandled(true);\n return -1;\n }\n BrowserMobHttpRequest httpReq = null;\n if (\"GET\".equals(request.getMethod())) {\n httpReq = httpClient.newGet(urlStr);\n } else if (\"POST\".equals(request.getMethod())) {\n httpReq = httpClient.newPost(urlStr);\n } else if (\"PUT\".equals(request.getMethod())) {\n httpReq = httpClient.newPut(urlStr);\n } else if (\"DELETE\".equals(request.getMethod())) {\n httpReq = httpClient.newDelete(urlStr);\n } else if (\"OPTIONS\".equals(request.getMethod())) {\n httpReq = httpClient.newOptions(urlStr);\n } else if (\"HEAD\".equals(request.getMethod())) {\n httpReq = httpClient.newHead(urlStr);\n } else {\n LOG.warn(\"Unexpected request method %s, giving up\", request.getMethod());\n request.setHandled(true);\n return -1;\n }\n boolean isGet = \"GET\".equals(request.getMethod());\n boolean hasContent = false;\n Enumeration enm = request.getFieldNames();\n long contentLength = 0;\n while (enm.hasMoreElements()) {\n String hdr = (String) enm.nextElement();\n if (!isGet && HttpFields.__ContentType.equals(hdr)) {\n hasContent = true;\n }\n if (!isGet && HttpFields.__ContentLength.equals(hdr)) {\n contentLength = Long.parseLong(request.getField(hdr));\n continue;\n }\n Enumeration vals = request.getFieldValues(hdr);\n while (vals.hasMoreElements()) {\n String val = (String) vals.nextElement();\n if (val != null) {\n if (\"User-Agent\".equals(hdr)) {\n val = updateUserAgent(val);\n }\n if (\"Referer\".equals(hdr) && (-1 != val.indexOf(\"/selenium-server/\"))) {\n continue;\n }\n if (!isGet && HttpFields.__ContentLength.equals(hdr) && Integer.parseInt(val) > 0) {\n hasContent = true;\n }\n httpReq.addRequestHeader(hdr, val);\n }\n }\n }\n try {\n InputStream in = request.getInputStream();\n if (hasContent) {\n httpReq.setRequestInputStream(in, contentLength);\n }\n } catch (Exception e) {\n LOG.fine(e.getMessage(), e);\n }\n httpReq.setOutputStream(response.getOutputStream());\n httpReq.setRequestCallback(new RequestCallback() {\n @Override\n public void handleStatusLine(StatusLine statusLine) {\n response.setStatus(statusLine.getStatusCode());\n response.setReason(statusLine.getReasonPhrase());\n }\n @Override\n public void handleHeaders(Header[] headers) {\n for (Header header : headers) {\n if (reportHeader(header)) {\n response.addField(header.getName(), header.getValue());\n }\n }\n }\n @Override\n public boolean reportHeader(Header header) {\n return !_DontProxyHeaders.containsKey(header.getName()) && !_ProxyAuthHeaders.containsKey(header.getName());\n }\n @Override\n public void reportError(Exception e) {\n BrowserMobProxyHandler.reportError(e, url, response);\n }\n });\n BrowserMobHttpResponse httpRes = httpReq.execute();\n request.setHandled(true);\n return httpRes.getEntry().getResponse().getBodySize();\n } catch (BadURIException e) {\n LOG.info(e.getMessage());\n BrowserMobProxyHandler.reportError(e, url, response);\n return -1;\n } catch (Exception e) {\n LOG.info(\"Exception while proxying \" + url, e);\n BrowserMobProxyHandler.reportError(e, url, response);\n return -1;\n }\n }\n", "output": " protected long proxyPlainTextRequest(final URL url, String pathInContext, String pathParams, HttpRequest request, final HttpResponse response) throws IOException {\n try {\n String urlStr = url.toString();\n if (urlStr.contains(\"/selenium-server/\")) {\n return super.proxyPlainTextRequest(url, pathInContext, pathParams, request, response);\n }\n if (urlStr.startsWith(\"https://sb-ssl.google.com:443/safebrowsing\")\n || urlStr.startsWith(\"http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml\")\n || urlStr.startsWith(\"http://fxfeeds.mozilla.com/firefox/headlines.xml\")\n || urlStr.startsWith(\"http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml\")\n || urlStr.startsWith(\"http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml\")) {\n request.setHandled(true);\n return -1;\n }\n if (httpClient == null) {\n request.setHandled(true);\n return -1;\n }\n BrowserMobHttpRequest httpReq = null;\n if (\"GET\".equals(request.getMethod())) {\n httpReq = httpClient.newGet(urlStr);\n } else if (\"POST\".equals(request.getMethod())) {\n httpReq = httpClient.newPost(urlStr);\n } else if (\"PUT\".equals(request.getMethod())) {\n httpReq = httpClient.newPut(urlStr);\n } else if (\"DELETE\".equals(request.getMethod())) {\n httpReq = httpClient.newDelete(urlStr);\n } else if (\"OPTIONS\".equals(request.getMethod())) {\n httpReq = httpClient.newOptions(urlStr);\n } else if (\"HEAD\".equals(request.getMethod())) {\n httpReq = httpClient.newHead(urlStr);\n } else {\n LOG.warn(\"Unexpected request method %s, giving up\", request.getMethod());\n request.setHandled(true);\n return -1;\n }\n boolean isGet = \"GET\".equals(request.getMethod());\n boolean hasContent = false;\n Enumeration enm = request.getFieldNames();\n long contentLength = 0;\n while (enm.hasMoreElements()) {\n String hdr = (String) enm.nextElement();\n if (!isGet && HttpFields.__ContentType.equals(hdr)) {\n hasContent = true;\n }\n if (!isGet && HttpFields.__ContentLength.equals(hdr)) {\n contentLength = Long.parseLong(request.getField(hdr));\n continue;\n }\n Enumeration vals = request.getFieldValues(hdr);\n while (vals.hasMoreElements()) {\n String val = (String) vals.nextElement();\n if (val != null) {\n if (\"User-Agent\".equals(hdr)) {\n val = updateUserAgent(val);\n }\n if (\"Referer\".equals(hdr) && (-1 != val.indexOf(\"/selenium-server/\"))) {\n continue;\n }\n if (!isGet && HttpFields.__ContentLength.equals(hdr) && Integer.parseInt(val) > 0) {\n hasContent = true;\n }\n httpReq.addRequestHeader(hdr, val);\n }\n }\n }\n try {\n InputStream in = request.getInputStream();\n if (hasContent) {\n httpReq.setRequestInputStream(in, contentLength);\n }\n } catch (Exception e) {\n LOG.fine(e.getMessage(), e);\n }\n httpReq.setOutputStream(response.getOutputStream());\n httpReq.setRequestCallback(new RequestCallback() {\n @Override\n public void handleStatusLine(StatusLine statusLine) {\n response.setStatus(statusLine.getStatusCode());\n response.setReason(statusLine.getReasonPhrase());\n }\n @Override\n public void handleHeaders(Header[] headers) {\n for (Header header : headers) {\n if (reportHeader(header)) {\n response.addField(header.getName(), header.getValue());\n }\n }\n }\n @Override\n public boolean reportHeader(Header header) {\n return !_DontProxyHeaders.containsKey(header.getName()) && !_ProxyAuthHeaders.containsKey(header.getName());\n }\n @Override\n public void reportError(Exception e) {\n BrowserMobProxyHandler.reportError(e, url, response);\n }\n });\n BrowserMobHttpResponse httpRes = httpReq.execute();\n request.setHandled(true);\n return httpRes.getEntry().getResponse().getBodySize();\n } catch (BadURIException e) {\n LOG.info(e.getMessage());\n BrowserMobProxyHandler.reportError(e, url, response);\n return -1;\n } catch (Exception e) {\n LOG.info(\"Exception while proxying \" + url, e);\n BrowserMobProxyHandler.reportError(e, url, response);\n return -1;\n }\n }\n"} {"input": "\tpublic void dispatchDraw(Canvas canvas) {\n\t\tlong currentTime;\n\t\tif(startTime==0){\n\t\t\tstartTime=SystemClock.uptimeMillis();\n\t\t\tcurrentTime=0;\n\t\t}else{\n\t\t\tcurrentTime=SystemClock.uptimeMillis()-startTime;\n\t\t}\n\t\tif(mStatus==OPENING){\n\t\t\tmScaleFactor=easeOut(currentTime, 3.0f, 1.0f, mAnimationDuration);\n\t\t}else if (mStatus==CLOSING){\n\t\t\tmScaleFactor=easeIn(currentTime, 1.0f, 3.0f, mAnimationDuration);\n\t\t}\n\t\tif(currentTime>=mAnimationDuration){\n\t\t\tisAnimating=false;\n\t\t\tif(mStatus==OPENING){\n\t\t\t\tmStatus=OPEN;\n\t\t\t\tdispatchFadingEvent(OnFadingListener.OPEN);\n\t\t\t\tclearChildrenCache();\n\t\t\t\tsetChildrenDrawingCacheEnabled(true);\n\t\t\t}else if(mStatus==CLOSING){\n\t\t\t\tmStatus=CLOSED;\n\t\t\t\tdispatchFadingEvent(OnFadingListener.CLOSE);\n\t\t\t}\n\t\t}\n\t\tshouldDrawLabels=(currentTime>mAnimationDuration/2 && mStatus==OPENING)||(currentTime<mAnimationDuration/2 && mStatus==CLOSING);\n\t\tint alpha=255;\n\t\tif(isAnimating){\n\t\t\tfloat porcentajeScale=1.0f-((mScaleFactor-1)/3.0f);\n\t\t\tif(porcentajeScale>=0.9f)porcentajeScale=1;\n\t\t\tif(porcentajeScale<0)porcentajeScale=0;\n\t\t\talpha=(int)(porcentajeScale*255);\n\t\t\tdispatchFadingAlphaEvent(alpha);\n\t\t}\n\t\tmPaint.setAlpha(alpha);\n\t\tif(mStatus!=CLOSED){\n\t\t\tsuper.dispatchDraw(canvas);\n\t\t}\n\t}\n", "output": "\tpublic void dispatchDraw(Canvas canvas) {\n\t\tlong currentTime;\n\t\tif(startTime==0){\n\t\t\tstartTime=SystemClock.uptimeMillis();\n\t\t\tcurrentTime=0;\n\t\t}else{\n\t\t\tcurrentTime=SystemClock.uptimeMillis()-startTime;\n\t\t}\n\t\tif(mStatus==OPENING){\n\t\t\tmScaleFactor=easeOut(currentTime, 3.0f, 1.0f, mAnimationDuration);\n\t\t}else if (mStatus==CLOSING){\n\t\t\tmScaleFactor=easeIn(currentTime, 1.0f, 3.0f, mAnimationDuration);\n\t\t}\n\t\tif(currentTime>=mAnimationDuration){\n\t\t\tisAnimating=false;\n\t\t\tif(mStatus==OPENING){\n\t\t\t\tmStatus=OPEN;\n\t\t\t\tdispatchFadingEvent(OnFadingListener.OPEN);\n\t\t\t\tclearChildrenCache();\n\t\t\t\tsetChildrenDrawingCacheEnabled(true);\n\t\t\t}else if(mStatus==CLOSING){\n\t\t\t\tmStatus=CLOSED;\n\t\t\t\tdispatchFadingEvent(OnFadingListener.CLOSE);\n\t\t\t}\n\t\t}\n\t\tshouldDrawLabels=(currentTime>mAnimationDuration/2 && mStatus==OPENING)||(currentTime<mAnimationDuration/2 && mStatus==CLOSING);\n\t\tint alpha=255;\n\t\tif(isAnimating){\n\t\t\tfloat porcentajeScale=1.0f-((mScaleFactor-1)/3.0f);\n\t\t\tif(porcentajeScale>=0.9f)porcentajeScale=1;\n\t\t\tif(porcentajeScale<0)porcentajeScale=0;\n\t\t\talpha=(int)(porcentajeScale*255);\n\t\t}\n\t\tdispatchFadingAlphaEvent(alpha);\n\t\tmPaint.setAlpha(alpha);\n\t\tif(mStatus!=CLOSED){\n\t\t\tsuper.dispatchDraw(canvas);\n\t\t}\n\t}\n"} {"input": " public void processMessage(final PhoneResponseMessage message) {\n\tif (message instanceof CallEndedResponseMessage) {\n\t final CallEndedResponseMessage msg = (CallEndedResponseMessage) message;\n if (msg.wasSuccessful() == false) { \n logger.warning(\"Failed END_CALL\");\n\t\treturn;\n\t }\n CallListing listing = msg.getCallListing();\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\treturn;\n\t }\n if (mostRecentCallListing.isPrivate()) {\n }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n phoneForm.setCallEnded(msg.getReasonCallEnded());\n }\n });\n\t return;\n\t}\n\tif (message instanceof LockUnlockResponseMessage) {\n\t LockUnlockResponseMessage msg = (LockUnlockResponseMessage) message;\n\t phoneForm.changeLocked(msg.getLocked(), msg.wasSuccessful());\n\t return;\n\t}\n\tif (message instanceof PhoneResponseMessage == false) {\n\t logger.warning(\"Invalid message: \" + message);\n\t return;\n\t}\n\tPhoneResponseMessage msg = (PhoneResponseMessage) message;\n CallListing listing = msg.getCallListing();\n\tif (msg instanceof PlaceCallResponseMessage) {\n\t logger.fine(\"Got place call response...\");\n if (msg.wasSuccessful() == false) {\n logger.warning(\"Failed PLACE_CALL!\");\n\t\treturn;\n\t }\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\tlogger.warning(\"Didn't find listing...\");\n\t\treturn;\n\t }\n\t mostRecentCallListing.setPrivateClientName(listing.getPrivateClientName());\n\t logger.fine(\"Updating listing with \" + listing.getExternalCallID());\n\t mostRecentCallListing.setExternalCallID(listing.getExternalCallID());\n if (listing.isPrivate()) {\n }\n\t return;\n\t}\n\tif (msg instanceof JoinCallResponseMessage) {\n if (msg.wasSuccessful() == false) {\n logger.warning(\"Failed JOIN_CALL\");\n\t\treturn;\n\t }\n\t if (mostRecentCallListing == null || \n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\treturn;\n\t }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n phoneForm.setCallEstablished(false);\n }\n });\n\t return;\n\t}\n\tif (msg instanceof CallInvitedResponseMessage) {\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\treturn; \n\t }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n phoneForm.setCallInvited();\n }\n });\n return;\n\t}\n\tif (msg instanceof CallEstablishedResponseMessage) {\n\t logger.fine(\"Got est resp\");\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\tlogger.warning(\"no listing \" + mostRecentCallListing \n\t\t + \" listing \" + listing);\n\t\treturn; \n\t }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n\t\t synchronized (phoneForm) {\n phoneForm.setCallEstablished(\n\t\t\t mostRecentCallListing.isPrivate());\n\t\t }\n }\n });\n return;\n }\n }\n", "output": " public void processMessage(final PhoneResponseMessage message) {\n\tif (message instanceof CallEndedResponseMessage) {\n\t final CallEndedResponseMessage msg = (CallEndedResponseMessage) message;\n if (msg.wasSuccessful() == false) { \n logger.warning(\"Failed END_CALL\");\n\t\treturn;\n\t }\n CallListing listing = msg.getCallListing();\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\treturn;\n\t }\n if (mostRecentCallListing.isPrivate()) {\n }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n\t\t if (phoneForm != null) {\n phoneForm.setCallEnded(msg.getReasonCallEnded());\n\t\t }\n }\n });\n\t return;\n\t}\n\tif (message instanceof LockUnlockResponseMessage) {\n\t LockUnlockResponseMessage msg = (LockUnlockResponseMessage) message;\n\t if (phoneForm != null) {\n\t phoneForm.changeLocked(msg.getLocked(), msg.wasSuccessful());\n\t }\n\t return;\n\t}\n\tif (message instanceof PhoneResponseMessage == false) {\n\t logger.warning(\"Invalid message: \" + message);\n\t return;\n\t}\n\tPhoneResponseMessage msg = (PhoneResponseMessage) message;\n CallListing listing = msg.getCallListing();\n\tif (msg instanceof PlaceCallResponseMessage) {\n\t logger.fine(\"Got place call response...\");\n if (msg.wasSuccessful() == false) {\n logger.warning(\"Failed PLACE_CALL!\");\n\t\treturn;\n\t }\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\tlogger.warning(\"Didn't find listing...\");\n\t\treturn;\n\t }\n\t mostRecentCallListing.setPrivateClientName(listing.getPrivateClientName());\n\t logger.fine(\"Updating listing with \" + listing.getExternalCallID());\n\t mostRecentCallListing.setExternalCallID(listing.getExternalCallID());\n if (listing.isPrivate()) {\n }\n\t return;\n\t}\n\tif (msg instanceof JoinCallResponseMessage) {\n if (msg.wasSuccessful() == false) {\n logger.warning(\"Failed JOIN_CALL\");\n\t\treturn;\n\t }\n\t if (mostRecentCallListing == null || \n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\treturn;\n\t }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n\t \t if (phoneForm != null) {\n phoneForm.setCallEstablished(false);\n\t\t }\n }\n });\n\t return;\n\t}\n\tif (msg instanceof CallInvitedResponseMessage) {\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\treturn; \n\t }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n\t\t if (phoneForm != null) {\n phoneForm.setCallInvited();\n\t\t }\n }\n });\n return;\n\t}\n\tif (msg instanceof CallEstablishedResponseMessage) {\n\t logger.fine(\"Got est resp\");\n if (mostRecentCallListing == null ||\n\t\t listing.equals(mostRecentCallListing) == false) {\n\t\tlogger.warning(\"no listing \" + mostRecentCallListing \n\t\t + \" listing \" + listing);\n\t\treturn; \n\t }\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n\t\t if (phoneForm != null) {\n\t\t synchronized (phoneForm) {\n phoneForm.setCallEstablished(\n\t\t\t mostRecentCallListing.isPrivate());\n\t\t }\n\t\t }\n }\n });\n return;\n }\n }\n"} {"input": " public static Varargs preloadTexture(Varargs args, LuaEnvironment env){\n String s = args.arg1().checkjstring();\n File f = new File(env.getModPath(), s);\n if (!f.exists()) {\n Log.warning(\"ERROR: File not found: \" + s);\n }\n CommonProxy.TEXTURES.add(f.getPath());\n return LuaValue.NONE;\n }\n", "output": " public static Varargs preloadTexture(Varargs args, LuaEnvironment env){\n String arg = args.arg1().checkjstring();\n String s = \"/\" + (new File(env.getModPath()).getName()) + ((arg.startsWith(\"/\")) ? \"\" : \"/\") + arg;\n if (ClientLib.class.getResourceAsStream(s) == null) {\n Log.warning(\"The file \" + arg + \" could not be located in the mod \" + env.getModName());\n }\n CommonProxy.TEXTURES.add(s);\n return LuaValue.NONE;\n }\n"} {"input": "\tpublic void writeShows(PodioShow... pshow) throws SQLException {\n\t\tConnection c = DBConnector.getInstance().getConnection();\n\t\tPreparedStatement ps = c.prepareStatement(\"INSERT INTO shows VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n\t\tfor (PodioShow p : pshow) {\n\t\t\tpshow.setInt(1, pshow.getShowID());\n\t\t\tpshow.setInt(2, pshow.getBandID());\n\t\t\tpshow.setDate(3, pshow.getDate());\n\t\t\tpshow.setInt(4, pshow.getState());\n\t\t\tpshow.setDouble(5, pshow.getFee());\n\t\t\tpshow.setString(6, pshow.getFeeCurrency());\n\t\t\tpshow.setDouble(7, pshow.getProvision());\n\t\t\tpshow.setString(8, pshow.getProvisionCurrency());\n\t\t\tpshow.setInt(9, pshow.getProductionType());\n\t\t\tpshow.setInt(10, pshow.getProfitSplit());\n\t\t\tpshow.setInt(11, pshow.getTicketPrice());\n\t\t\tpshow.setDouble(12, pshow.getKodaPct());\n\t\t\tpshow.setDouble(13, pshow.getVAT());\n\t\t\tpshow.setInt(14, pshow.getTicketsSold());\n\t\t\tpshow.setString(15, pshow.getComment());\n\t\t\tpshow.setTimestamp(16, pshow.getLastEdit());\n\t\t\tps.executeUpdate();\n\t\t}\n\t}\n", "output": "\tpublic void writeShows(PodioShow... pshow) throws SQLException {\n\t\tConnection c = DBConnector.getInstance().getConnection();\n\t\tPreparedStatement ps = c.prepareStatement(\"INSERT INTO shows VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\");\n\t\tfor (PodioShow p : pshow) {\n\t\t\tps.setInt(1, p.getShowID());\n\t\t\tps.setInt(2, p.getBandID());\n\t\t\tps.setDate(3, p.getDate());\n\t\t\tps.setInt(4, p.getState());\n\t\t\tps.setDouble(5, p.getFee());\n\t\t\tps.setString(6, p.getFeeCurrency());\n\t\t\tps.setDouble(7, p.getProvision());\n\t\t\tps.setString(8, p.getProvisionCurrency());\n\t\t\tps.setInt(9, p.getProductionType());\n\t\t\tps.setInt(10, p.getProfitSplit());\n\t\t\tps.setInt(11, p.getTicketPrice());\n\t\t\tps.setDouble(12, p.getKodaPct());\n\t\t\tps.setDouble(13, p.getVAT());\n\t\t\tps.setInt(14, p.getTicketsSold());\n\t\t\tps.setString(15, p.getComments());\n\t\t\tps.setTimestamp(16, p.getLastEdit());\n\t\t\tps.executeUpdate();\n\t\t}\n\t}\n"} {"input": " private static void createWood() {\n final int blockID = BlockSettings.CUSTOMLOG.getID();\n if (!ModuleControlSettings.SUMMA.isEnabled() || blockID <= 0) return;\n final BlockCustomLog block = new BlockCustomLog(blockID);\n block.setUnlocalizedName(\"extrabiomes.log\").setStepSound(Block.soundWoodFootstep).setHardness(2.0F).setResistance(Block.wood.getExplosionResistance(null) * 5.0F).setCreativeTab(Extrabiomes.tabsEBXL);\n final CommonProxy proxy = Extrabiomes.proxy;\n proxy.setBlockHarvestLevel(block, \"axe\", 0);\n proxy.registerBlock(block, extrabiomes.utility.MultiItemBlock.class);\n proxy.registerOreInAllSubblocks(\"logWood\", block);\n proxy.registerEventHandler(block);\n proxy.setBurnProperties(block.blockID, 5, 5);\n Element.LOG_ACACIA.set(new ItemStack(block, 1, BlockCustomLog.BlockType.ACACIA.metadata()));\n Element.LOG_FIR.set(new ItemStack(block, 1, BlockCustomLog.BlockType.FIR.metadata()));\n Element.LOG_CYPRESS.set(new ItemStack(block, 1, BlockCustomLog.BlockType.CYPRESS.metadata()));\n Element.LOG_JAPANESE_MAPLE.set(new ItemStack(block, 1, BlockCustomLog.BlockType.JAPANESE_MAPLE.metadata()));\n ForestryModHelper.addToForesterBackpack(new ItemStack(block, 1, Short.MAX_VALUE));\n for (final BlockCustomLog.BlockType type : BlockCustomLog.BlockType.values()) {\n FacadeHelper.addBuildcraftFacade(block.blockID, type.metadata());\n }\n final int newblockID = BlockSettings.NEWLOG.getID();\n if (!ModuleControlSettings.SUMMA.isEnabled() || newblockID <= 0) return;\n final BlockNewLog block2 = new BlockNewLog(newblockID);\n block2.setUnlocalizedName(\"extrabiomes.newlog\").setStepSound(Block.soundWoodFootstep).setHardness(2.0F).setResistance(Block.wood.getExplosionResistance(null) * 5.0F).setCreativeTab(Extrabiomes.tabsEBXL);\n proxy.setBlockHarvestLevel(block2, \"axe\", 0);\n proxy.registerBlock(block2, extrabiomes.utility.MultiItemBlock.class);\n proxy.registerOreInAllSubblocks(\"logWood\", block2);\n proxy.registerEventHandler(block2);\n proxy.setBurnProperties(block2.blockID, 5, 5);\n Element.LOG_RAINBOW_EUCALYPTUS.set(new ItemStack(block2, 1, BlockNewLog.BlockType.RAINBOW_EUCALYPTUS.metadata()));\n Element.LOG_AUTUMN.set(new ItemStack(block2, 1, BlockNewLog.BlockType.AUTUMN.metadata()));\n Element.LOG_BALD_CYPRESS.set(new ItemStack(block2, 1, BlockNewLog.BlockType.BALD_CYPRESS.metadata()));\n ForestryModHelper.addToForesterBackpack(new ItemStack(block2, 1, Short.MAX_VALUE));\n for (final BlockNewLog.BlockType type : BlockNewLog.BlockType.values()) {\n FacadeHelper.addBuildcraftFacade(block.blockID, type.metadata());\n }\n }\n", "output": " private static void createWood() {\n final int blockID = BlockSettings.CUSTOMLOG.getID();\n if (!ModuleControlSettings.SUMMA.isEnabled() || blockID <= 0) return;\n final BlockCustomLog block = new BlockCustomLog(blockID);\n block.setUnlocalizedName(\"extrabiomes.log\").setStepSound(Block.soundWoodFootstep).setHardness(2.0F).setResistance(Block.wood.getExplosionResistance(null) * 5.0F).setCreativeTab(Extrabiomes.tabsEBXL);\n final CommonProxy proxy = Extrabiomes.proxy;\n proxy.setBlockHarvestLevel(block, \"axe\", 0);\n proxy.registerBlock(block, extrabiomes.utility.MultiItemBlock.class);\n proxy.registerOreInAllSubblocks(\"logWood\", block);\n proxy.registerEventHandler(block);\n proxy.setBurnProperties(block.blockID, 5, 5);\n Element.LOG_ACACIA.set(new ItemStack(block, 1, BlockCustomLog.BlockType.ACACIA.metadata()));\n Element.LOG_FIR.set(new ItemStack(block, 1, BlockCustomLog.BlockType.FIR.metadata()));\n Element.LOG_CYPRESS.set(new ItemStack(block, 1, BlockCustomLog.BlockType.CYPRESS.metadata()));\n Element.LOG_JAPANESE_MAPLE.set(new ItemStack(block, 1, BlockCustomLog.BlockType.JAPANESE_MAPLE.metadata()));\n ForestryModHelper.addToForesterBackpack(new ItemStack(block, 1, Short.MAX_VALUE));\n for (final BlockCustomLog.BlockType type : BlockCustomLog.BlockType.values()) {\n FacadeHelper.addBuildcraftFacade(block.blockID, type.metadata());\n }\n final int newblockID = BlockSettings.NEWLOG.getID();\n if (!ModuleControlSettings.SUMMA.isEnabled() || newblockID <= 0) return;\n final BlockNewLog block2 = new BlockNewLog(newblockID);\n block2.setUnlocalizedName(\"extrabiomes.newlog\").setStepSound(Block.soundWoodFootstep).setHardness(2.0F).setResistance(Block.wood.getExplosionResistance(null) * 5.0F).setCreativeTab(Extrabiomes.tabsEBXL);\n proxy.setBlockHarvestLevel(block2, \"axe\", 0);\n proxy.registerBlock(block2, extrabiomes.utility.MultiItemBlock.class);\n proxy.registerOreInAllSubblocks(\"logWood\", block2);\n proxy.registerEventHandler(block2);\n proxy.setBurnProperties(block2.blockID, 5, 5);\n Element.LOG_RAINBOW_EUCALYPTUS.set(new ItemStack(block2, 1, BlockNewLog.BlockType.RAINBOW_EUCALYPTUS.metadata()));\n Element.LOG_AUTUMN.set(new ItemStack(block2, 1, BlockNewLog.BlockType.AUTUMN.metadata()));\n Element.LOG_BALD_CYPRESS.set(new ItemStack(block2, 1, BlockNewLog.BlockType.BALD_CYPRESS.metadata()));\n ForestryModHelper.addToForesterBackpack(new ItemStack(block2, 1, Short.MAX_VALUE));\n for (final BlockNewLog.BlockType type : BlockNewLog.BlockType.values()) {\n FacadeHelper.addBuildcraftFacade(block2.blockID, type.metadata());\n }\n }\n"} {"input": "\tprivate static void initCompetition(){\n gyroChassis = new Gyro(ANA1, CompetitionBot.Analog.GYRO); \n configA = new AnalogChannel(ANA1, CompetitionBot.Analog.CONFIG_A);\n configB = new AnalogChannel(ANA1, CompetitionBot.Analog.CONFIG_B);\n configC = new AnalogChannel(ANA1, CompetitionBot.Analog.CONFIG_C);\n encoderDriveLeft = new Encoder(DIO1, CompetitionBot.DigitalIn1.LEFT_DRIVE_ENCODER_A,\n\t\t\t\t\t\t\t\t\t DIO1, CompetitionBot.DigitalIn1.LEFT_DRIVE_ENCODER_B);\n encoderDriveRight = new Encoder(DIO1, CompetitionBot.DigitalIn1.RIGHT_DRIVE_ENCODER_A,\n\t\t\t\t\t\t\t\t\t\tDIO1, CompetitionBot.DigitalIn1.RIGHT_DRIVE_ENCODER_B);\n encoderWinch = new Encoder(DIO1, CompetitionBot.DigitalIn1.WINCH_ENCODER_A, \n\t\t\t\t\t\t\t\t DIO1, CompetitionBot.DigitalIn1.WINCH_ENCODER_B);\n limitWinchA = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.WINCH_LIMIT_A);\n limitWinchB = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.WINCH_LIMIT_B);\n limitArmA = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ARM_LIMIT_A);\n limitArmB = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ARM_LIMIT_B);\n limitElevatorA = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ELEVATOR_LIMIT_A);\n limitElevatorB = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ELEVATOR_LIMIT_B);\n\t\tcounterShooterSpeed = new FancyCounter(DIO1, CompetitionBot.DigitalIn1.SHOOTER_SPEED_ENCODER, TPP_COUNTER_SHOOTER_SPEED);\n\t\tcounterShooterAngle = new FancyCounter(DIO1, CompetitionBot.DigitalIn1.SHOOTER_ANGLE_ENCODER, TPP_COUNTER_SHOOTER_ANGLE);\n encoderElevator = new Encoder(DIO1, CompetitionBot.DigitalIn2.ELEVATOR_ENCODER_A, DIO2, CompetitionBot.DigitalIn2.ELEVATOR_ENCODER_B);\n\t\tencoderElevator.start();\n limitHookLeftBase = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.HOOK_LEFT_BASE_LIMIT);\n limitHookRightBase = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.HOOK_RIGHT_BASE_LIMIT);\n limitDiscTop = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.DISC_ORIENTATION_LIMIT_A);\n limitDiscBottom = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.DISC_ORIENTATION_LIMIT_B);\n limitShooterA = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.SHOOTER_LIMIT_A);\n limitShooterB = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.SHOOTER_LIMIT_B);\n\t\tpressureSwitch = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.PRESSURE_SWITCH);\n\t}\n", "output": "\tprivate static void initCompetition(){\n gyroChassis = new Gyro(ANA1, CompetitionBot.Analog.GYRO); \n configA = new AnalogChannel(ANA1, CompetitionBot.Analog.CONFIG_A);\n configB = new AnalogChannel(ANA1, CompetitionBot.Analog.CONFIG_B);\n configC = new AnalogChannel(ANA1, CompetitionBot.Analog.CONFIG_C);\n encoderDriveLeft = new Encoder(DIO1, CompetitionBot.DigitalIn1.LEFT_DRIVE_ENCODER_A,\n\t\t\t\t\t\t\t\t\t DIO1, CompetitionBot.DigitalIn1.LEFT_DRIVE_ENCODER_B);\n encoderDriveRight = new Encoder(DIO1, CompetitionBot.DigitalIn1.RIGHT_DRIVE_ENCODER_A,\n\t\t\t\t\t\t\t\t\t\tDIO1, CompetitionBot.DigitalIn1.RIGHT_DRIVE_ENCODER_B);\n encoderWinch = new Encoder(DIO1, CompetitionBot.DigitalIn1.WINCH_ENCODER_A, \n\t\t\t\t\t\t\t\t DIO1, CompetitionBot.DigitalIn1.WINCH_ENCODER_B);\n limitWinchA = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.WINCH_LIMIT_A);\n limitWinchB = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.WINCH_LIMIT_B);\n limitArmA = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ARM_LIMIT_A);\n limitArmB = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ARM_LIMIT_B);\n limitElevatorA = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ELEVATOR_LIMIT_A);\n limitElevatorB = new DigitalInput(DIO1, CompetitionBot.DigitalIn1.ELEVATOR_LIMIT_B);\n\t\tcounterShooterSpeed = new FancyCounter(DIO1, CompetitionBot.DigitalIn1.SHOOTER_SPEED_ENCODER, TPP_COUNTER_SHOOTER_SPEED);\n\t\tcounterShooterAngle = new FancyCounter(DIO1, CompetitionBot.DigitalIn1.SHOOTER_ANGLE_ENCODER, TPP_COUNTER_SHOOTER_ANGLE);\n encoderElevator = new Encoder(DIO2, CompetitionBot.DigitalIn2.ELEVATOR_ENCODER_A, DIO2, CompetitionBot.DigitalIn2.ELEVATOR_ENCODER_B);\n\t\tencoderElevator.start();\n limitHookLeftBase = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.HOOK_LEFT_BASE_LIMIT);\n limitHookRightBase = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.HOOK_RIGHT_BASE_LIMIT);\n limitDiscTop = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.DISC_ORIENTATION_LIMIT_A);\n limitDiscBottom = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.DISC_ORIENTATION_LIMIT_B);\n limitShooterA = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.SHOOTER_LIMIT_A);\n limitShooterB = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.SHOOTER_LIMIT_B);\n\t\tpressureSwitch = new DigitalInput(DIO2, CompetitionBot.DigitalIn2.PRESSURE_SWITCH);\n\t}\n"} {"input": " public void run(Graph graph) {\n clearCachedData();\n Collection<Trip> trips = _dao.getAllTrips();\n HashMap<StopPattern, TripPattern> patterns = new HashMap<StopPattern, TripPattern>();\n int index = 0;\n HashMap<String, HashMap<Stop, TreeSet<EncodedTrip>>> tripsByBlockAndStart = new HashMap<String, HashMap<Stop, TreeSet<EncodedTrip>>>();\n for (Trip trip : trips) {\n if (index % 100 == 0)\n _log.debug(\"trips=\" + index + \"/\" + trips.size());\n index++;\n List<StopTime> stopTimes = _dao.getStopTimesForTrip(trip);\n if (stopTimes.size() < 2) {\n _log\n .warn(\"Trip \"\n + trip\n + \" has fewer than two stops. We will not use it for routing. This is probably an error in your data\");\n continue;\n }\n StopPattern stopPattern = stopPatternfromTrip(trip, _dao);\n TripPattern tripPattern = patterns.get(stopPattern);\n String blockId = trip.getBlockId();\n boolean simple = false;\n if (tripPattern == null) {\n tripPattern = makeTripPattern(graph, trip, stopTimes);\n patterns.put(stopPattern, tripPattern);\n if (blockId != null && !blockId.equals(\"\")) {\n addTripToInterliningMap(tripsByBlockAndStart, trip, stopTimes, tripPattern,\n blockId);\n }\n } else {\n int insertionPoint = tripPattern.getDepartureTimeInsertionPoint(stopTimes.get(0)\n .getDepartureTime());\n if (insertionPoint < 0) {\n _log.warn(\"duplicate first departure time for trip \" + trip.getId()\n + \". This will be handled correctly but inefficiently.\");\n createSimpleHops(graph, trip, stopTimes);\n } else {\n StopTime st1 = null;\n int i;\n for (i = 0; i < stopTimes.size() - 1; i++) {\n StopTime st0 = stopTimes.get(i);\n st1 = stopTimes.get(i + 1);\n int dwellTime = st0.getDepartureTime() - st0.getArrivalTime();\n int runningTime = st1.getArrivalTime() - st0.getDepartureTime();\n try {\n tripPattern.addHop(i, insertionPoint, st0.getDepartureTime(),\n runningTime, st1.getArrivalTime(), dwellTime,\n trip.getId());\n } catch (TripOvertakingException e) {\n _log\n .warn(\"trip \"\n + trip.getId()\n + \" overtakes another trip with the same stops. This will be handled correctly but inefficiently.\");\n for (i = i - 1; i >= 0; --i) {\n tripPattern.removeHop(i, insertionPoint);\n }\n createSimpleHops(graph, trip, stopTimes);\n simple = true;\n break;\n }\n }\n }\n if (!simple) {\n if (blockId != null && !blockId.equals(\"\")) {\n addTripToInterliningMap(tripsByBlockAndStart, trip, stopTimes, tripPattern,\n blockId);\n }\n }\n tripPattern.setTripFlags(insertionPoint, (trip.getWheelchairAccessible() != 0) ? TripPattern.FLAG_WHEELCHAIR_ACCESSIBLE : 0);\n }\n }\n HashMap<TripPattern, HashMap<TripPattern, PatternInterlineDwell>> dwellEdges = new HashMap<TripPattern, HashMap<TripPattern, PatternInterlineDwell>>();\n for (HashMap<Stop, TreeSet<EncodedTrip>> blockStops : tripsByBlockAndStart.values()) {\n for (Stop stop : blockStops.keySet()) {\n TreeSet<EncodedTrip> tripsStartingAt = blockStops.get(stop);\n for (EncodedTrip eTrip : tripsStartingAt) {\n Trip trip = eTrip.trip;\n List<StopTime> stopTimes = _dao.getStopTimesForTrip(trip);\n StopTime lastStopTime = stopTimes.get(stopTimes.size() - 1);\n Stop lastStop = lastStopTime.getStop();\n TreeSet<EncodedTrip> possiblePosts = null;\n if (blockStops.containsKey(lastStop)) {\n possiblePosts = blockStops.get(lastStop);\n } else {\n continue;\n }\n EncodedTrip[] postArray = possiblePosts.toArray(new EncodedTrip[0]);\n int postIndex = 0;\n int arrivalTime = lastStopTime.getArrivalTime();\n EncodedTrip post;\n do {\n post = postArray[postIndex];\n ++postIndex;\n } while (postIndex < postArray.length\n && postArray[postIndex].getFirstStop(_dao).getDepartureTime() < arrivalTime);\n if (post == null || post.getFirstStop(_dao).getDepartureTime() < arrivalTime) {\n continue;\n }\n PatternInterlineDwell dwell = null;\n HashMap<TripPattern, PatternInterlineDwell> edges = dwellEdges\n .get(eTrip.pattern);\n if (edges != null) {\n dwell = edges.get(post.pattern);\n }\n if (dwell == null) {\n Vertex arrive = graph.addVertex(id(lastStop.getId()) + \"_\"\n + id(trip.getId()) + \"_A\", lastStop.getLon(), lastStop.getLat());\n Vertex depart = graph.addVertex(id(lastStop.getId()) + \"_\"\n + id(post.trip.getId()) + \"_D\", lastStop.getLon(), lastStop\n .getLat());\n dwell = new PatternInterlineDwell(arrive, depart, trip);\n graph.addEdge(dwell);\n if (edges == null) {\n edges = new HashMap<TripPattern, PatternInterlineDwell>();\n dwellEdges.put(eTrip.pattern, edges);\n }\n edges.put(eTrip.pattern, dwell);\n }\n int departureTime = post.getFirstStop(_dao).getArrivalTime();\n int dwellTime = departureTime - arrivalTime;\n dwell.addTrip(trip.getId(), post.trip.getId(), dwellTime);\n }\n }\n }\n loadTransfers(graph);\n deleteUselessDwells(graph);\n clearCachedData();\n }\n", "output": " public void run(Graph graph) {\n clearCachedData();\n Collection<Trip> trips = _dao.getAllTrips();\n HashMap<StopPattern, TripPattern> patterns = new HashMap<StopPattern, TripPattern>();\n int index = 0;\n HashMap<String, HashMap<Stop, TreeSet<EncodedTrip>>> tripsByBlockAndStart = new HashMap<String, HashMap<Stop, TreeSet<EncodedTrip>>>();\n for (Trip trip : trips) {\n if (index % 100 == 0)\n _log.debug(\"trips=\" + index + \"/\" + trips.size());\n index++;\n List<StopTime> stopTimes = _dao.getStopTimesForTrip(trip);\n if (stopTimes.size() < 2) {\n _log\n .warn(\"Trip \"\n + trip\n + \" has fewer than two stops. We will not use it for routing. This is probably an error in your data\");\n continue;\n }\n StopPattern stopPattern = stopPatternfromTrip(trip, _dao);\n TripPattern tripPattern = patterns.get(stopPattern);\n String blockId = trip.getBlockId();\n boolean simple = false;\n if (tripPattern == null) {\n tripPattern = makeTripPattern(graph, trip, stopTimes);\n patterns.put(stopPattern, tripPattern);\n if (blockId != null && !blockId.equals(\"\")) {\n addTripToInterliningMap(tripsByBlockAndStart, trip, stopTimes, tripPattern,\n blockId);\n }\n } else {\n int insertionPoint = tripPattern.getDepartureTimeInsertionPoint(stopTimes.get(0)\n .getDepartureTime());\n if (insertionPoint < 0) {\n _log.warn(\"duplicate first departure time for trip \" + trip.getId()\n + \". This will be handled correctly but inefficiently.\");\n simple = true;\n createSimpleHops(graph, trip, stopTimes);\n } else {\n StopTime st1 = null;\n int i;\n for (i = 0; i < stopTimes.size() - 1; i++) {\n StopTime st0 = stopTimes.get(i);\n st1 = stopTimes.get(i + 1);\n int dwellTime = st0.getDepartureTime() - st0.getArrivalTime();\n int runningTime = st1.getArrivalTime() - st0.getDepartureTime();\n try {\n tripPattern.addHop(i, insertionPoint, st0.getDepartureTime(),\n runningTime, st1.getArrivalTime(), dwellTime,\n trip.getId());\n } catch (TripOvertakingException e) {\n _log\n .warn(\"trip \"\n + trip.getId()\n + \" overtakes another trip with the same stops. This will be handled correctly but inefficiently.\");\n for (i = i - 1; i >= 0; --i) {\n tripPattern.removeHop(i, insertionPoint);\n }\n createSimpleHops(graph, trip, stopTimes);\n simple = true;\n break;\n }\n }\n }\n if (!simple) {\n if (blockId != null && !blockId.equals(\"\")) {\n addTripToInterliningMap(tripsByBlockAndStart, trip, stopTimes, tripPattern,\n blockId);\n }\n tripPattern.setTripFlags(insertionPoint, (trip.getWheelchairAccessible() != 0) ? TripPattern.FLAG_WHEELCHAIR_ACCESSIBLE : 0);\n }\n }\n }\n HashMap<TripPattern, HashMap<TripPattern, PatternInterlineDwell>> dwellEdges = new HashMap<TripPattern, HashMap<TripPattern, PatternInterlineDwell>>();\n for (HashMap<Stop, TreeSet<EncodedTrip>> blockStops : tripsByBlockAndStart.values()) {\n for (Stop stop : blockStops.keySet()) {\n TreeSet<EncodedTrip> tripsStartingAt = blockStops.get(stop);\n for (EncodedTrip eTrip : tripsStartingAt) {\n Trip trip = eTrip.trip;\n List<StopTime> stopTimes = _dao.getStopTimesForTrip(trip);\n StopTime lastStopTime = stopTimes.get(stopTimes.size() - 1);\n Stop lastStop = lastStopTime.getStop();\n TreeSet<EncodedTrip> possiblePosts = null;\n if (blockStops.containsKey(lastStop)) {\n possiblePosts = blockStops.get(lastStop);\n } else {\n continue;\n }\n EncodedTrip[] postArray = possiblePosts.toArray(new EncodedTrip[0]);\n int postIndex = 0;\n int arrivalTime = lastStopTime.getArrivalTime();\n EncodedTrip post;\n do {\n post = postArray[postIndex];\n ++postIndex;\n } while (postIndex < postArray.length\n && postArray[postIndex].getFirstStop(_dao).getDepartureTime() < arrivalTime);\n if (post == null || post.getFirstStop(_dao).getDepartureTime() < arrivalTime) {\n continue;\n }\n PatternInterlineDwell dwell = null;\n HashMap<TripPattern, PatternInterlineDwell> edges = dwellEdges\n .get(eTrip.pattern);\n if (edges != null) {\n dwell = edges.get(post.pattern);\n }\n if (dwell == null) {\n Vertex arrive = graph.addVertex(id(lastStop.getId()) + \"_\"\n + id(trip.getId()) + \"_A\", lastStop.getLon(), lastStop.getLat());\n Vertex depart = graph.addVertex(id(lastStop.getId()) + \"_\"\n + id(post.trip.getId()) + \"_D\", lastStop.getLon(), lastStop\n .getLat());\n dwell = new PatternInterlineDwell(arrive, depart, trip);\n graph.addEdge(dwell);\n if (edges == null) {\n edges = new HashMap<TripPattern, PatternInterlineDwell>();\n dwellEdges.put(eTrip.pattern, edges);\n }\n edges.put(eTrip.pattern, dwell);\n }\n int departureTime = post.getFirstStop(_dao).getArrivalTime();\n int dwellTime = departureTime - arrivalTime;\n dwell.addTrip(trip.getId(), post.trip.getId(), dwellTime);\n }\n }\n }\n loadTransfers(graph);\n deleteUselessDwells(graph);\n clearCachedData();\n }\n"} {"input": "\tpublic void init() {\n view.setModel(new FileTreeModel(project.getProjectDir(), new FileFilter() {\n @Override\n public boolean accept(File pathname) {\n return project.getFilePredicate().apply(pathname);\n }\n }));\n window.topic(Project.FileChangeListener.class).subscribe(DispatchStrategy.ASYNC_EVENT, this);\n\t\twindow.topic(ProjectImpl.RefreshListener.class).subscribe(DispatchStrategy.ASYNC_EVENT, this);\n\t\t((JTree) view).getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {\n\t\t\t@Override\n\t\t\tpublic void valueChanged(TreeSelectionEvent e) {\n\t\t\t\tTreePath[] selectionPaths = ((JTree) view).getSelectionPaths();\n\t\t\t\tList<File> paths = Lists.newArrayList();\n if (selectionPaths != null) {\n for (TreePath tp : selectionPaths) {\n paths.add((File) tp.getLastPathComponent());\n }\n }\n\t\t\t\twindow.getProject().setSelectedFiles(paths);\n actionContext.put(ActionContextKeys.SELECTION, paths.toArray());\n actionContext.commit();\n\t\t\t}\n\t\t});\n ((JTree) view).addTreeExpansionListener(new TreeExpansionListener() {\n @Override\n public void treeExpanded(TreeExpansionEvent event) {\n File file = (File) event.getPath().getLastPathComponent();\n project.register(file);\n }\n @Override\n public void treeCollapsed(TreeExpansionEvent event) {\n File file = (File) event.getPath().getLastPathComponent();\n project.unregister(file);\n }\n });\n actionContext = new ActionContext();\n actionContext.put(ActionContextKeys.FOCUSED_COMPONENT, window.getProject());\n actionContext.commit();\n ActionContext.set(view.getJComponent(), actionContext);\n if (project.getSettingsManager() != null)\n project.getSettingsManager().subscribe(IgnorePatternProjectSettings.class, this, false, window);\n\t}\n", "output": "\tpublic void init() {\n if (project.getProjectDir() == null) return;\n view.setModel(new FileTreeModel(project.getProjectDir(), new FileFilter() {\n @Override\n public boolean accept(File pathname) {\n return project.getFilePredicate().apply(pathname);\n }\n }));\n window.topic(Project.FileChangeListener.class).subscribe(DispatchStrategy.ASYNC_EVENT, this);\n\t\twindow.topic(ProjectImpl.RefreshListener.class).subscribe(DispatchStrategy.ASYNC_EVENT, this);\n\t\t((JTree) view).getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {\n\t\t\t@Override\n\t\t\tpublic void valueChanged(TreeSelectionEvent e) {\n\t\t\t\tTreePath[] selectionPaths = ((JTree) view).getSelectionPaths();\n\t\t\t\tList<File> paths = Lists.newArrayList();\n if (selectionPaths != null) {\n for (TreePath tp : selectionPaths) {\n paths.add((File) tp.getLastPathComponent());\n }\n }\n\t\t\t\twindow.getProject().setSelectedFiles(paths);\n actionContext.put(ActionContextKeys.SELECTION, paths.toArray());\n actionContext.commit();\n\t\t\t}\n\t\t});\n ((JTree) view).addTreeExpansionListener(new TreeExpansionListener() {\n @Override\n public void treeExpanded(TreeExpansionEvent event) {\n File file = (File) event.getPath().getLastPathComponent();\n project.register(file);\n }\n @Override\n public void treeCollapsed(TreeExpansionEvent event) {\n File file = (File) event.getPath().getLastPathComponent();\n project.unregister(file);\n }\n });\n actionContext = new ActionContext();\n actionContext.put(ActionContextKeys.FOCUSED_COMPONENT, window.getProject());\n actionContext.commit();\n ActionContext.set(view.getJComponent(), actionContext);\n if (project.getSettingsManager() != null)\n project.getSettingsManager().subscribe(IgnorePatternProjectSettings.class, this, false, window);\n\t}\n"} {"input": " public static int calculateVersion(OriginatorInfo originatorInfo, ASN1Set recipientInfos, ASN1Set unprotectedAttrs)\n {\n int version;\n if (originatorInfo != null || unprotectedAttrs != null)\n {\n version = 2;\n }\n else\n {\n version = 0;\n Enumeration e = recipientInfos.getObjects();\n while (e.hasMoreElements())\n {\n RecipientInfo ri = RecipientInfo.getInstance(e.nextElement());\n if (!ri.getVersion().equals(version))\n {\n version = 2;\n break;\n }\n }\n }\n return version;\n }\n", "output": " public static int calculateVersion(OriginatorInfo originatorInfo, ASN1Set recipientInfos, ASN1Set unprotectedAttrs)\n {\n int version;\n if (originatorInfo != null || unprotectedAttrs != null)\n {\n version = 2;\n }\n else\n {\n version = 0;\n Enumeration e = recipientInfos.getObjects();\n while (e.hasMoreElements())\n {\n RecipientInfo ri = RecipientInfo.getInstance(e.nextElement());\n if (ri.getVersion().getValue().intValue() != version)\n {\n version = 2;\n break;\n }\n }\n }\n return version;\n }\n"} {"input": "\tprotected void doLaunch(ModelPackage component) {\n\t\tfinal String title = \"Paquete \" + component.getQualifiedName();\n\t\tpackageNameValidator.setParent(component.getParent());\n Optional<String> name = dialogs.showInput(title, \"Nombre\",\n\t\t\t\tcomponent.getName(), packageNameValidator);\n if (name.isPresent()) {\n\t\t\tcomponent.setName(name.get());\n\t\t}\n\t}\n", "output": "\tprotected void doLaunch(ModelPackage component) {\n\t\tfinal String title = \"Paquete \" + component.getQualifiedName();\n\t\tif(!component.isRoot()) packageNameValidator.setParent(component.getParent());\n Optional<String> name = dialogs.showInput(title, \"Nombre\",\n\t\t\t\tcomponent.getName(), packageNameValidator);\n if (name.isPresent()) {\n\t\t\tcomponent.setName(name.get());\n\t\t}\n\t}\n"} {"input": " public void destroy() {\n broadcasterCache = new BroadcasterConfig.DefaultBroadcasterCache();\n setScope(SCOPE.APPLICATION);\n }\n", "output": " public void destroy() {\n bc.setBroadcasterCache(new BroadcasterConfig.DefaultBroadcasterCache());\n setScope(SCOPE.APPLICATION);\n }\n"} {"input": " private void init(final WebWindow webWindow, final Context context) throws Exception {\n final WebClient webClient = webWindow.getWebClient();\n final Map prototypes = new HashMap();\n final Map prototypesPerJSName = new HashMap();\n final Window window = new Window(this);\n final JavaScriptConfiguration jsConfig = JavaScriptConfiguration.getInstance(webClient.getBrowserVersion());\n context.initStandardObjects(window);\n StringPrimitivePrototypeBugFixer.installWorkaround(window);\n final Scriptable fallbackCaller = new ScriptableObject()\n {\n private static final long serialVersionUID = -7124423159070941606L;\n public Object get(final String name, final Scriptable start) {\n if (start instanceof ScriptableWithFallbackGetter) {\n return ((ScriptableWithFallbackGetter) start).getWithFallback(name);\n }\n return NOT_FOUND;\n }\n public String getClassName() {\n return \"htmlUnitHelper-fallbackCaller\";\n }\n };\n ScriptableObject.getObjectPrototype(window).setPrototype(fallbackCaller);\n final Iterator it = jsConfig.keySet().iterator();\n while (it.hasNext()) {\n final String jsClassName = (String) it.next();\n final ClassConfiguration config = jsConfig.getClassConfiguration(jsClassName);\n final boolean isWindow = Window.class.getName().equals(config.getLinkedClass().getName());\n if (isWindow) {\n configureConstantsPropertiesAndFunctions(config, window);\n }\n else {\n final Scriptable prototype = configureClass(config, window);\n if (config.isJsObject()) {\n prototypes.put(config.getLinkedClass(), prototype);\n if (!getWebClient().getBrowserVersion().isIE()) {\n final Scriptable obj = (Scriptable) config.getLinkedClass().newInstance();\n obj.put(\"prototype\", obj, prototype);\n obj.setPrototype(prototype);\n ScriptableObject.defineProperty(window,\n config.getClassName(), obj, ScriptableObject.DONTENUM);\n }\n }\n prototypesPerJSName.put(config.getClassName(), prototype);\n }\n }\n final Scriptable objectPrototype = ScriptableObject.getObjectPrototype(window);\n for (final Iterator iter = prototypesPerJSName.entrySet().iterator(); iter.hasNext();) {\n final Map.Entry entry = (Map.Entry) iter.next();\n final String name = (String) entry.getKey();\n final ClassConfiguration config = jsConfig.getClassConfiguration(name);\n final Scriptable prototype = (Scriptable) entry.getValue();\n if (!StringUtils.isEmpty(config.getExtendedClass())) {\n final Scriptable parentPrototype = (Scriptable) prototypesPerJSName.get(config.getExtendedClass());\n prototype.setPrototype(parentPrototype);\n }\n else {\n prototype.setPrototype(objectPrototype);\n }\n }\n final Class[] evalFnTypes = {String.class};\n final Member evalFn = Window.class.getMethod(\"custom_eval\", evalFnTypes);\n final FunctionObject jsCustomEval = new FunctionObject(\"eval\", evalFn, window);\n window.associateValue(\"custom_eval\", jsCustomEval);\n for (final Iterator classnames = jsConfig.keySet().iterator(); classnames.hasNext();) {\n final String jsClassName = (String) classnames.next();\n final ClassConfiguration config = jsConfig.getClassConfiguration(jsClassName);\n final Method jsConstructor = config.getJsConstructor();\n if (jsConstructor != null) {\n final Scriptable prototype = (Scriptable) prototypesPerJSName.get(jsClassName);\n if (prototype != null) {\n final FunctionObject jsCtor = new FunctionObject(jsClassName, jsConstructor, window);\n jsCtor.addAsConstructor(window, prototype);\n }\n }\n }\n window.setPrototypes(prototypes);\n window.initialize(webWindow);\n }\n", "output": " private void init(final WebWindow webWindow, final Context context) throws Exception {\n final WebClient webClient = webWindow.getWebClient();\n final Map prototypes = new HashMap();\n final Map prototypesPerJSName = new HashMap();\n final Window window = new Window(this);\n final JavaScriptConfiguration jsConfig = JavaScriptConfiguration.getInstance(webClient.getBrowserVersion());\n context.initStandardObjects(window);\n StringPrimitivePrototypeBugFixer.installWorkaround(window);\n final Scriptable fallbackCaller = new ScriptableObject()\n {\n private static final long serialVersionUID = -7124423159070941606L;\n public Object get(final String name, final Scriptable start) {\n if (start instanceof ScriptableWithFallbackGetter) {\n return ((ScriptableWithFallbackGetter) start).getWithFallback(name);\n }\n return NOT_FOUND;\n }\n public String getClassName() {\n return \"htmlUnitHelper-fallbackCaller\";\n }\n };\n ScriptableObject.getObjectPrototype(window).setPrototype(fallbackCaller);\n final Iterator it = jsConfig.keySet().iterator();\n while (it.hasNext()) {\n final String jsClassName = (String) it.next();\n final ClassConfiguration config = jsConfig.getClassConfiguration(jsClassName);\n final boolean isWindow = Window.class.getName().equals(config.getLinkedClass().getName());\n if (isWindow) {\n configureConstantsPropertiesAndFunctions(config, window);\n }\n else {\n final Scriptable prototype = configureClass(config, window);\n if (config.isJsObject()) {\n prototypes.put(config.getLinkedClass(), prototype);\n if (!getWebClient().getBrowserVersion().isIE()) {\n final Scriptable obj = (Scriptable) config.getLinkedClass().newInstance();\n obj.put(\"prototype\", obj, prototype);\n obj.setPrototype(prototype);\n obj.setParentScope(window);\n ScriptableObject.defineProperty(window,\n config.getClassName(), obj, ScriptableObject.DONTENUM);\n }\n }\n prototypesPerJSName.put(config.getClassName(), prototype);\n }\n }\n final Scriptable objectPrototype = ScriptableObject.getObjectPrototype(window);\n for (final Iterator iter = prototypesPerJSName.entrySet().iterator(); iter.hasNext();) {\n final Map.Entry entry = (Map.Entry) iter.next();\n final String name = (String) entry.getKey();\n final ClassConfiguration config = jsConfig.getClassConfiguration(name);\n final Scriptable prototype = (Scriptable) entry.getValue();\n if (!StringUtils.isEmpty(config.getExtendedClass())) {\n final Scriptable parentPrototype = (Scriptable) prototypesPerJSName.get(config.getExtendedClass());\n prototype.setPrototype(parentPrototype);\n }\n else {\n prototype.setPrototype(objectPrototype);\n }\n }\n final Class[] evalFnTypes = {String.class};\n final Member evalFn = Window.class.getMethod(\"custom_eval\", evalFnTypes);\n final FunctionObject jsCustomEval = new FunctionObject(\"eval\", evalFn, window);\n window.associateValue(\"custom_eval\", jsCustomEval);\n for (final Iterator classnames = jsConfig.keySet().iterator(); classnames.hasNext();) {\n final String jsClassName = (String) classnames.next();\n final ClassConfiguration config = jsConfig.getClassConfiguration(jsClassName);\n final Method jsConstructor = config.getJsConstructor();\n if (jsConstructor != null) {\n final Scriptable prototype = (Scriptable) prototypesPerJSName.get(jsClassName);\n if (prototype != null) {\n final FunctionObject jsCtor = new FunctionObject(jsClassName, jsConstructor, window);\n jsCtor.addAsConstructor(window, prototype);\n }\n }\n }\n window.setPrototypes(prototypes);\n window.initialize(webWindow);\n }\n"} {"input": "\tpublic IStrategoTerm invoke(Context context, IStrategoTerm current, Strategy s) {\n\t\tsynchronized (this) {\n\t\t\tString[] trace = context.getTrace();\n\t\t\ttry {\n\t\t\t\tlogIntercept.proceed = log_0_2.instance;\n\t\t\t\tlogIntercept.enabled = true;\n\t\t\t\tlog_0_2.instance = logIntercept;\n\t\t\t\treturn proceed.invoke(context, current, s);\n\t\t\t} catch (StrategoExit e) {\n\t\t\t\tIStrategoTerm message = logIntercept.lastMessage.get();\n\t\t\t\tIStrategoTerm term = logIntercept.lastTerm.get();\n\t\t\t\tcontext.setTrace(trace);\n\t\t\t\tif (message != null && isTermString(message)) {\n\t\t\t\t\tthrow new StrategoErrorExit(asJavaString(message), term);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new StrategoExit(e);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tlog_0_2.instance = logIntercept.proceed;\n\t\t\t\tlogIntercept.enabled = false;\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic IStrategoTerm invoke(Context context, IStrategoTerm current, Strategy s) {\n\t\tsynchronized (this) {\n\t\t\tString[] trace = context.getTrace();\n\t\t\ttry {\n\t\t\t\tlogIntercept.proceed = log_0_2.instance;\n\t\t\t\tlogIntercept.enabled = true;\n\t\t\t\tlog_0_2.instance = logIntercept;\n\t\t\t\treturn proceed.invoke(context, current, s);\n\t\t\t} catch (StrategoErrorExit e) {\n\t\t\t throw new StrategoErrorExit(e.getMessage(), e.getTerm(), e);\n\t\t\t} catch (StrategoExit e) {\n\t\t\t\tIStrategoTerm message = logIntercept.lastMessage.get();\n\t\t\t\tIStrategoTerm term = logIntercept.lastTerm.get();\n\t\t\t\tcontext.setTrace(trace);\n\t\t\t\tif (message != null && isTermString(message)) {\n\t\t\t\t\tthrow new StrategoErrorExit(asJavaString(message), term);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new StrategoExit(e);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tlog_0_2.instance = logIntercept.proceed;\n\t\t\t\tlogIntercept.enabled = false;\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic void Write(IOClient player, Server server) {\n\t\tPacketPrepareEvent event = new PacketPrepareEvent(player, this, server);\n\t\tserver.getEventSystem().callEvent(event);\n\t\tif (event.isCancelled())\n\t\t\treturn;\n\t\ttry {\n\t\t\tboolean isop = false;\n\t\t\tif (player instanceof Player) {\n\t\t\t\tisop = ((Player)player).getGroup().isOP;\n\t\t\t}\n\t\t\tbyte[] finals = new byte[131];\n\t\t\tfinals[0] = ID;\n\t\t\tfinals[1] = 0x07;\n\t\t\tString smotd = server.MOTD;\n\t\t\tif (((Player)player).getLevel().name.equals(server.MainLevel) && !((Player)player).getLevel().motd.equals(\"ignore\"))\n\t\t\t\tsmotd = ((Player)player).getLevel().motd;\n\t\t\twhile (server.Name.length() < 64)\n\t\t\t\tserver.Name += \" \";\n\t\t\twhile (server.MOTD.length() < 64)\n\t\t\t\tsmotd += \" \";\n\t\t\tbyte[] name = server.Name.getBytes(\"US-ASCII\");\n\t\t\tbyte[] motd = smotd.getBytes(\"US-ASCII\");\n\t\t\tSystem.arraycopy(name, 0, finals, 2, name.length);\n\t\t\tSystem.arraycopy(motd, 0, finals, name.length + 2, motd.length);\n\t\t\tfinals[130] = (isop ? (byte)100 : (byte)0);\n\t\t\tplayer.WriteData(finals);\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n", "output": "\tpublic void Write(IOClient player, Server server) {\n\t\tPacketPrepareEvent event = new PacketPrepareEvent(player, this, server);\n\t\tserver.getEventSystem().callEvent(event);\n\t\tif (event.isCancelled())\n\t\t\treturn;\n\t\ttry {\n\t\t\tboolean isop = false;\n\t\t\tif (player instanceof Player) {\n\t\t\t\tisop = ((Player)player).getGroup().isOP;\n\t\t\t}\n\t\t\tbyte[] finals = new byte[131];\n\t\t\tfinals[0] = ID;\n\t\t\tfinals[1] = 0x07;\n\t\t\tString smotd = server.MOTD;\n\t\t\tif (((Player)player).getLevel() != null && ((Player)player).getLevel().name.equals(server.MainLevel) && !((Player)player).getLevel().motd.equals(\"ignore\"))\n\t\t\t\tsmotd = ((Player)player).getLevel().motd;\n\t\t\twhile (server.Name.length() < 64)\n\t\t\t\tserver.Name += \" \";\n\t\t\twhile (server.MOTD.length() < 64)\n\t\t\t\tsmotd += \" \";\n\t\t\tbyte[] name = server.Name.getBytes(\"US-ASCII\");\n\t\t\tbyte[] motd = smotd.getBytes(\"US-ASCII\");\n\t\t\tSystem.arraycopy(name, 0, finals, 2, name.length);\n\t\t\tSystem.arraycopy(motd, 0, finals, name.length + 2, motd.length);\n\t\t\tfinals[130] = (isop ? (byte)100 : (byte)0);\n\t\t\tplayer.WriteData(finals);\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n"} {"input": "\tprivate void selectTable(final Component component, final Point point) throws AssertionError {\n\t\tfinal int componentCount = getComponentCount();\n\t\tfor (int i = componentCount; i > 0;) {\n\t\t\tremove(--i);\n\t\t}\n\t\tif (component instanceof AttributeTable) {\n\t\t\ttable = (AttributeTable) component;\n\t\t\tif(table.isEditing()){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toldTable = false;\n\t\t\trow = table.rowAtPoint(point);\n\t\t\tif (table.getValueAt(row, 0).equals(\"\")) {\n\t\t\t\trow--;\n\t\t\t}\n\t\t\tif(row >= 0){\n\t\t\t\ttable.changeSelection(row, table.columnAtPoint(point), false, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (component instanceof JTableHeader) {\n\t\t\tfinal JTableHeader header = (JTableHeader) component;\n\t\t\ttable = (AttributeTable) header.getTable();\n\t\t\tif(table.isEditing()){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toldTable = false;\n\t\t\trow = -1;\n\t\t\treturn;\n\t\t}\n\t\tthrow new AssertionError();\n\t}\n", "output": "\tprivate void selectTable(final Component component, final Point point) throws AssertionError {\n\t\tfinal int componentCount = getComponentCount();\n\t\tfor (int i = componentCount; i > 0;) {\n\t\t\tremove(--i);\n\t\t}\n\t\tif (component instanceof AttributeTable) {\n\t\t\ttable = (AttributeTable) component;\n\t\t\tif(table.isEditing()){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toldTable = false;\n\t\t\trow = table.rowAtPoint(point);\n\t\t\tif(row >= 0){\n\t\t\t\tif (table.getValueAt(row, 0).equals(\"\")) {\n\t\t\t\t\trow--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(row >= 0){\n\t\t\t\ttable.changeSelection(row, table.columnAtPoint(point), false, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (component instanceof JTableHeader) {\n\t\t\tfinal JTableHeader header = (JTableHeader) component;\n\t\t\ttable = (AttributeTable) header.getTable();\n\t\t\tif(table.isEditing()){\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toldTable = false;\n\t\t\trow = -1;\n\t\t\treturn;\n\t\t}\n\t\tthrow new AssertionError();\n\t}\n"} {"input": "\tprivate void generate(String schema, String table, JSONObject columns, JSONArray pks,\n\t\t\tList<FK> fks, List<FK> fksIn, String dataSourceName, String callbackPackage,\n\t\t\tJSONObject enums)\n\tthrows IOException, JSONException {\n\t\tString className = genTableClassName(table);\n\t\tSet<String> pkSet = new HashSet<String>();\n\t\tif (pks == null) pks = new JSONArray();\n\t\tfor (int i=0; i<pks.length(); ++i) {\n\t\t\tpkSet.add(pks.getString(i));\n\t\t}\n\t\tint fieldCount = columns.keySet().size();\n\t\tString pkgDir = Misc.join(\"/\", pkg.split(\"[.]\"));\n\t\tnew File(Misc.join(\"/\", dir, pkgDir, schema)).mkdirs();\n\t\tFile file = new File(Misc.join(\"/\", dir, pkgDir, schema, className+\".java\"));\n\t\tSystem.out.println(\"writing: \"+ file.getAbsolutePath());\n\t\tBufferedWriter br = new BufferedWriter(new FileWriter(file));\n\t\tbr.write(\"package \"+ pkg +\".\"+ schema +\";\\n\\n\");\n\t\tbr.write(\"import java.lang.reflect.Method;\\n\");\n\t\tbr.write(\"import java.lang.reflect.InvocationTargetException;\\n\");\n\t\tbr.write(\"import java.sql.SQLException;\\n\");\n\t\tbr.write(\"import javax.sql.DataSource;\\n\");\n\t\tbr.write(\"import java.util.Map;\\n\\n\");\n\t\tbr.write(\"import java.util.HashMap;\\n\\n\");\n\t\tbr.write(\"import org.nosco.Field;\\n\");\n\t\tbr.write(\"import org.nosco.Query;\\n\");\n\t\tbr.write(\"import org.nosco.QueryFactory;\\n\");\n\t\tbr.write(\"import org.nosco.Table;\\n\");\n\t\tbr.write(\"\\n\");\n\t\tbr.write(\"public class \"+ className +\" extends Table implements Comparable<\"+ className +\"> {\\n\\n\");\n\t\tint index = 0;\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\tpublic static final Field<\");\n\t\t\tbr.write(getFieldType(schema, table, column, columns.getString(column)));\n\t\t\tbr.write(\"> \"+ getFieldName(column));\n\t\t\tbr.write(\" = new Field<\"+ getFieldType(schema, table, column, columns.getString(column)));\n\t\t\tbr.write(\">(\"+ index +\", \"+ className +\".class, \\\"\"+ column);\n\t\t\tbr.write(\"\\\", \"+ getFieldType(schema, table, column, columns.getString(column)) +\".class\");\n\t\t\tbr.write(\");\\n\");\n\t\t\t++index;\n\t\t}\n\t\tbr.write(\"\\n\");\n\t\tbr.write(\"\\tpublic static Field.PK<\"+ className +\"> PK = new Field.PK<\"+ className +\">(\");\n\t\tfor (int i=0; i<pks.length(); ++i) {\n\t\t\tbr.write(pks.getString(i).toUpperCase());\n\t\t\tif (i<pks.length()-1) br.write(\", \");\n\t\t}\n\t\tbr.write(\");\\n\");\n\t\tbr.write(\"\\tpublic org.nosco.Field.PK PK() { return PK; }\\n\\n\");\n\t\tfor (FK fk : fks) {\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tString referencedTableClassName = genTableClassName(referencedTable);\n\t\t\tif (!schema.equals(fk.reffed[0])) {\n\t\t\t\treferencedTableClassName = pkg +\".\"+ fk.reffed[0] +\".\"+ referencedTableClassName;\n\t\t\t}\n\t\t\tString fkName = genFKName(fk.columns.keySet(), referencedTable);\n\t\t\tbr.write(\"\\tpublic static final Field.FK<\"+ referencedTableClassName +\"> FK_\"+ fkName);\n\t\t\tbr.write(\" = new Field.FK<\"+ referencedTableClassName +\">(\"+ index +\", \"+ className +\".class, \");\n\t\t\tbr.write(referencedTableClassName +\".class\");\n\t\t\tfor (Entry<String, String> e : fk.columns.entrySet()) {\n\t\t\t\tbr.write(\", \"+ e.getKey().toUpperCase());\n\t\t\t}\n\t\t\tfor (Entry<String, String> e : fk.columns.entrySet()) {\n\t\t\t\tbr.write(\", \"+ referencedTableClassName +\".\");\n\t\t\t\tbr.write(e.getValue().toUpperCase());\n\t\t\t}\n\t\t\tbr.write(\");\\n\");\n\t\t\t++index;\n\t\t}\n\t\tbr.write(\"\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tString enumKey = schema +\".\"+ table +\".\"+ column;\n\t\t\tif (!enums.has(enumKey)) continue;\n\t\t\tJSONObject instances = enums.optJSONObject(enumKey);\n\t\t\tboolean simple = pkSet.size() == 1;\n\t\t\tif (simple) {\n\t\t\t\tString pk = pkSet.iterator().next();\n\t\t\t\tString pkType = getFieldType(schema, table, pk, columns.getString(pk));\n\t\t\t\tbr.write(\"\\tpublic enum PKS implements Table.__SimplePrimaryKey<\"+ className +\", \"+ pkType +\"> {\\n\\n\");\n\t\t\t\tint count = 0;\n\t\t\t\tfor (String name : instances.keySet()) {\n\t\t\t\t\t++ count;\n\t\t\t\t\tString value = instances.optJSONArray(name).getString(0);\n\t\t\t\t\tif (\"java.lang.String\".equals(pkType)) value = \"\\\"\"+ value +\"\\\"\";\n\t\t\t\t\tbr.write(\"\\t\\t\"+ name.toUpperCase().replaceAll(\"\\\\W\", \"_\"));\n\t\t\t\t\tbr.write(\"(\"+ value +\")\");\n\t\t\t\t\tif (count < instances.keySet().size()) br.write(\",\\n\");\n\t\t\t\t}\n\t\t\t\tbr.write(\";\\n\\n\");\n\t\t\t\tbr.write(\"\\t\\tpublic final \"+ pkType +\" \"+ getFieldName(pk) +\";\\n\");\n\t\t\t\tbr.write(\"\\t\\tPKS(\"+ pkType +\" v) {\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\t\"+ getFieldName(pk) +\" = v;\\n\");\n\t\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\t\tbr.write(\"\\t\\t@SuppressWarnings(\\\"unchecked\\\")\\n\");\n\t\t\t\tbr.write(\"\\t\\t@Override\\n\");\n\t\t\t\tbr.write(\"\\t\\tpublic <R> R get(Field<R> field) {\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\tif (field==\"+ className +\".\"+ getFieldName(pk)\n\t\t\t\t\t\t+\") return (R) Integer.valueOf(\"+ getFieldName(pk) +\"); \\n\");\n\t\t\t\tbr.write(\"\\t\\t\\tif (\"+ className +\".\"+ getFieldName(pk)\n\t\t\t\t\t\t+\".sameField(field)) return (R) Integer.valueOf(\"\n\t\t\t\t\t\t+ getFieldName(pk) +\");\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\tthrow new RuntimeException(\\\"field \\\"+ field +\\\" is not part of this primary key\\\");\\n\");\n\t\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\t\tbr.write(\"\\t\\t@Override\\n\");\n\t\t\t\tbr.write(\"\\t\\tpublic \"+ pkType +\" value() {\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\treturn \"+ getFieldName(pk)+ \";\\n\");\n\t\t\t\tbr.write(\"\\t\\t}\\n\\n\");\n\t\t\t\tbr.write(\"\\t}\\n\");\n\t\t\t}\n\t\t}\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\tprivate \"+ getFieldType(schema, table, column, columns.getString(column)));\n\t\t\tbr.write(\" \"+ getInstanceFieldName(column) + \" = null;\\n\");\n\t\t}\n\t\tbr.write(\"\\n\");\n\t\tbr.write(\"\\tpublic \"+ className +\"() {}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tprotected \"+ className +\"(Field[] fields, Object[] objects, int start, int end) {\\n\");\n\t\tbr.write(\"\\t\\tif (fields.length != objects.length)\\n\\t\\t\\tthrow new IllegalArgumentException(\");\n\t\tbr.write(\"\\\"fields.length != objects.length => \\\"+ fields.length +\\\" != \\\"+ objects.length\");\n\t\tbr.write(\" +\\\"\\\");\\n\");\n\t\tbr.write(\"\\t\\tfor (int i=start; i<end; ++i) {\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\t\\tif (fields[i]==\"+ getFieldName(column) +\") {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\\t\"+ getInstanceFieldName(column) +\" = \");\n\t\t\tString assignment = convertToActualType(schema, table, column,\n\t\t\t\t\tcolumns.getString(column),\n\t\t\t\t\t\"(\"+ getFieldClassType(columns.getString(column)).getName()+ \") objects[i]\");\n\t\t\tbr.write(assignment);\n\t\t\tbr.write(\";\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\\t__NOSCO_FETCHED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\\tcontinue;\\n\");\n\t\t\tbr.write(\"\\t\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\t}\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic String SCHEMA_NAME() {\\n\\t\\treturn \\\"\"+ schema +\"\\\";\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic String TABLE_NAME() {\\n\\t\\treturn \\\"\"+ table +\"\\\";\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic Field[] FIELDS() {\\n\\t\\tField[] fields = {\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(getFieldName(column)+\",\");\n\t\t}\n\t\tbr.write(\"};\\n\\t\\treturn fields;\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic Field.FK[] FKS() {\\n\\t\\tField.FK[] fields = {\");\n\t\tfor (FK fk : fks) {\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tbr.write(\"FK_\" + genFKName(fk.columns.keySet(), referencedTable) + \",\");\n\t\t}\n\t\tbr.write(\"};\\n\\t\\treturn fields;\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"unchecked\\\")\\n\");\n\t\tbr.write(\"\\tpublic <S> S get(Field<S> _field) {\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tif (_field==\"+ getFieldName(column) +\") \");\n\t\t\tbr.write(\"return (S) \"+ getInstanceFieldName(column) +\";\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tthrow new IllegalArgumentException(\\\"unknown field \\\"+ _field);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic <S> void set(Field<S> _field, S _value) {\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tif (_field==\"+ getFieldName(column) +\") \");\n\t\t\tbr.write(getInstanceFieldName(column) +\" = (\"+ getFieldType(schema, table, column, columns.getString(column)) +\") _value;\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tthrow new IllegalArgumentException(\\\"unknown field \\\"+ _field);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic static final Query<\"+ className +\"> ALL = QueryFactory.IT.getQuery(\"\n\t\t+ className +\".class).use(\"+ pkg +\".\"+ dataSourceName +\".\"+ schema.toUpperCase() +\");\\n\\n\");\n\t\tbr.write(\"\\t public String toString() {\\n\");\n\t\tbr.write(\"\\t\\treturn \\\"[\"+ className);\n\t\tfor (int i=0; i<pks.length(); ++i) {\n\t\t\tString pk = pks.getString(i);\n\t\t\tbr.write(\" \"+ pk+\":\");\n\t\t\tbr.write(\"\\\"+\"+ getInstanceFieldName(pk));\n\t\t\tbr.write(\"+\\\"\");\n\t\t}\n\t\tfor (String column : columns.keySet()) {\n\t\t\tif (!\"name\".equalsIgnoreCase(column)) continue;\n\t\t\tbr.write(\" \"+ column +\":\");\n\t\t\tbr.write(\"\\\"+\"+ getInstanceFieldName(column));\n\t\t\tbr.write(\"+\\\"\");\n\t\t}\n\t\tbr.write(\"]\\\";\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t public String toStringDetailed() {\\n\");\n\t\tbr.write(\"\\t\\treturn \\\"[\"+ className);\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\" \"+ column +\":\");\n\t\t\tbr.write(\"\\\"+\"+ getInstanceFieldName(column));\n\t\t\tbr.write(\"+\\\"\");\n\t\t}\n\t\tbr.write(\"]\\\";\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tString cls = getFieldType(schema, table, column, columns.getString(column));\n\t\t\tbr.write(\"\\tpublic \"+ cls +\" get\"+ getInstanceMethodName(column) +\"() {\\n\");\n\t\t\tbr.write(\"\\t\\tif (!__NOSCO_FETCHED_VALUES.get(\"+ getFieldName(column) +\".INDEX)) {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ className +\" _tmp = ALL.onlyFields(\");\n\t\t\tbr.write(getFieldName(column)+\")\");\n\t\t\tfor (String pk : pkSet) {\n\t\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t\t}\n\t\t\tbr.write(\".getTheOnly();\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ getInstanceFieldName(column) +\" = _tmp == null ? null : _tmp.get\"\n\t\t\t\t\t+ getInstanceMethodName(column) +\"();\");\n\t\t\tbr.write(\"\\t\\t\\t__NOSCO_FETCHED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\tbr.write(\"\\t\\treturn \"+ getInstanceFieldName(column) +\";\\n\\t}\\n\\n\");\n\t\t\tbr.write(\"\\tpublic \"+ className +\" set\"+ getInstanceMethodName(column));\n\t\t\tbr.write(\"(\"+ cls +\" v) {\\n\");\n\t\t\tbr.write(\"\\t\\t\"+ getInstanceFieldName(column) +\" = v;\\n\");\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_UPDATED_VALUES == null) __NOSCO_UPDATED_VALUES = new java.util.BitSet();\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_UPDATED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_FETCHED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\treturn this;\\n\");\n\t\t\tbr.write(\"\\t}\\n\\n\");\n\t\t\tif (!cls.equals(getFieldClassType(columns.getString(column)).getName())) {\n\t\t\t\tbr.write(\"\\tpublic \"+ className +\" set\"+ getInstanceMethodName(column));\n\t\t\t\tbr.write(\"(\"+ getFieldClassType(columns.getString(column)).getName() +\" v) {\\n\");\n\t\t\t\tbr.write(\"\\t\\treturn set\"+ getInstanceMethodName(column) +\"(\"+\n\t\t\t\t\t\tthis.convertToActualType(schema, table, column,\n\t\t\t\t\t\t\t\tcolumns.getString(column), \"v\") +\");\\n\");\n\t\t\t\tbr.write(\"\\t}\\n\\n\");\n\t\t\t}\n\t\t}\n\t\tfor (FK fk : fks) {\n\t\t\tString referencedSchema = fk.reffed[0];\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tString referencedTableClassName = genTableClassName(referencedTable);\n\t\t\tif (!schema.equals(fk.reffed[0])) {\n\t\t\t\treferencedTableClassName = pkg +\".\"+ fk.reffed[0] +\".\"+ referencedTableClassName;\n\t\t}\n\t\t\tString methodName = genFKMethodName(fk.columns.keySet(), referencedTable);\n\t\t\tString cachedObjectName = \"_NOSCO_FK_\"+ underscoreToCamelCase(fk.columns.keySet(), false);\n\t\t\tbr.write(\"\\tprivate \"+ referencedTableClassName +\" \"+ cachedObjectName +\" = null;\\n\\n\");\n\t\t\tbr.write(\"\\tpublic \"+ referencedTableClassName +\" get\"+ methodName +\"() {\\n\");\n\t\t\tbr.write(\"\\t\\tif (!__NOSCO_FETCHED_VALUES.get(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX)) {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ cachedObjectName +\" = \"+ referencedTableClassName +\".ALL\");\n\t\t\tbr.write(\".where(\"+ referencedTableClassName +\".\"+ getFieldName(fk.columns.values()) +\".eq(\"+ underscoreToCamelCase(fk.columns.keySet(), false) +\"))\");\n\t\t\tbr.write(\".getTheOnly();\\n\");\n\t\t\tbr.write(\"\\t\\t\\t__NOSCO_FETCHED_VALUES.set(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\tbr.write(\"\\t\\treturn \"+ cachedObjectName +\";\\n\\t}\\n\\n\");\n\t\t\tbr.write(\"\\tpublic \"+ className +\" set\"+ methodName +\"(\"+ referencedTableClassName +\" v) {\\n\");\n\t\t\tbr.write(\"\\t\\t\"+ underscoreToCamelCase(fk.columns.keySet(), false) +\" = v.get\"+ underscoreToCamelCase(fk.columns.values(), true) +\"();\\n\");\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_UPDATED_VALUES == null) __NOSCO_UPDATED_VALUES = new java.util.BitSet();\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_UPDATED_VALUES.set(\"+ getFieldName(fk.columns.keySet()) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t\"+ cachedObjectName +\" = v;\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_UPDATED_VALUES.set(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\treturn this;\\n\");\n\t\t\tbr.write(\"\\n\\t}\\n\\n\");\n\t\t}\n\t\tbr.write(\"\\tprotected void SET_FK(Field.FK<?> field, Object v) {\\n\");\n\t\tbr.write(\"\\t\\tif (false);\\n\");\n\t\tfor (FK fk : fks) {\n\t\t\tString cachedObjectName = \"_NOSCO_FK_\"+ underscoreToCamelCase(fk.columns.keySet(), false);\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tString referencedTableClassName = genTableClassName(referencedTable);\n\t\t\tif (!schema.equals(fk.reffed[0])) {\n\t\t\t\treferencedTableClassName = pkg +\".\"+ fk.reffed[0] +\".\"+ referencedTableClassName;\n\t\t}\n\t\t\tbr.write(\"\\t\\telse if (field == FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\") {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ cachedObjectName +\" = (\"+ referencedTableClassName +\") v;\\n\");\n\t\t\tbr.write(\"\\t\\t\\t__NOSCO_FETCHED_VALUES.set(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\telse {throw new RuntimeException(\\\"unknown FK\\\");}\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"unchecked\\\")\\n\");\n\t\tbr.write(\"\\tprotected void SET_FK_SET(Field.FK<?> fk, Query<?> v) {\\n\");\n\t\tbr.write(\"\\t\\tif (false);\\n\");\n\t\tfor (FK fk : fksIn) {\n\t\t String relatedSchema = fk.reffing[0];\n\t\t String relatedTable = fk.reffing[1];\n\t\t String relatedTableClassName = this.genTableClassName(relatedTable);\n\t\t\tif (!schema.equals(relatedSchema)) {\n\t\t\t\trelatedTableClassName = pkg +\".\"+ relatedSchema +\".\"+ relatedTableClassName;\n\t\t\t}\n\t\t\tString fkName = \"FK_\"+ genFKName(fk.columns.keySet(), fk.reffed[1]);\n\t\t String localVar = \"__NOSCO_CACHED_FK_SET___\"+ relatedTable + \"___\"\n\t\t \t\t+ Misc.join(\"__\", fk.columns.keySet());\n\t\t br.write(\"\\t\\telse if (\"+ relatedTableClassName +\".\"+ fkName +\".equals(fk)) {\\n\");\n\t\t br.write(\"\\t\\t\\t\"+ localVar +\" = (Query<\"+ relatedTableClassName +\">) v;\\n\");\n\t\t br.write(\"\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\telse {throw new RuntimeException(\\\"unknown FK\\\");}\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tMap<String, Integer> reffingCounts = new HashMap<String,Integer>();\n\t\tfor (FK fk : fksIn) {\n\t\t String relatedTable = fk.reffing[1];\n\t\t Integer c = reffingCounts.get(relatedTable);\n\t\t if (c == null) c = 0;\n\t\t reffingCounts.put(relatedTable, c+1);\n\t\t}\n\t\tfor (FK fk : fksIn) {\n\t\t String relatedSchema = fk.reffing[0];\n\t\t String relatedTable = fk.reffing[1];\n\t\t String relatedTableClassName = this.genTableClassName(relatedTable);\n\t\t\tif (!schema.equals(relatedSchema)) {\n\t\t\t\trelatedTableClassName = pkg +\".\"+ relatedSchema +\".\"+ relatedTableClassName;\n\t\t\t}\n\t\t String method = getInstanceMethodName(relatedTable);\n\t\t if (reffingCounts.get(relatedTable) > 1) {\n\t\t\t String tmp = Misc.join(\"_\", fk.columns.keySet());\n\t\t\t\tmethod = method + \"_\" + getInstanceMethodName(tmp);\n\t\t }\n\t\t String localVar = \"__NOSCO_CACHED_FK_SET___\"+ relatedTable + \"___\"\n\t\t \t\t+ Misc.join(\"__\", fk.columns.keySet());\n\t\t br.write(\"\\tprivate Query<\"+ relatedTableClassName +\"> \"+ localVar +\" = null;\\n\");\n\t\t br.write(\"\\tpublic Query<\"+ relatedTableClassName +\"> get\"+ method +\"Set() {\\n\");\n\t\t br.write(\"\\t\\tif (\"+ localVar +\" != null) return \"+ localVar + \";\\n\");\n\t\t br.write(\"\\t\\telse return \"+ relatedTableClassName +\".ALL\");\n\t\t for (Entry<String, String> e : fk.columns.entrySet()) {\n\t\t\tString relatedColumn = e.getKey();\n\t\t\tString column = e.getValue();\n\t\t\tbr.write(\".where(\"+ relatedTableClassName +\".\"+ getFieldName(relatedColumn) +\".eq(get\"+ getInstanceMethodName(column) +\"()))\");\n\t\t }\n\t\t br.write(\";\\n\");\n\t\t br.write(\"\\t}\\n\\n\");\n\t\t}\n\t\tbr.write(\"\\tpublic boolean save() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return save(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean save(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tif (!dirty()) return false;\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tif (pkSet == null || pkSet.isEmpty()) {\n\t\t\tbr.write(\"\\t\\tthrow new RuntimeException(\\\"save() is ambiguous on objects without PKs - use insert() or update()\\\");\\n\");\n\t\t} else {\n\t\t\tbr.write(\"\\t\\tint size = query.size();\\n\");\n\t\t\tbr.write(\"\\t\\tif (size == 0) return this.insert(ds);\\n\");\n\t\t\tbr.write(\"\\t\\telse if (size == 1) return this.update(ds);\\n\");\n\t\t\tbr.write(\"\\t\\telse throw new RuntimeException(\\\"more than one result was returned \" +\n\t\t\t\t\t\"for a query that specified all the PKs. this is bad.\\\");\\n\");\n\t\t\tbr.write(\"\\t\\t\\n\");\n\t\t}\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean update() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return update(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean update(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tif (!dirty()) return false;\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tif (pkSet == null || pkSet.size() == 0) {\n\t\t\tfor (String column : columns.keySet()) {\n\t\t\t\tbr.write(\".where(\"+ getFieldName(column) +\".eq(\"+ getInstanceFieldName(column) +\"))\");\n\t\t\t}\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tbr.write(\"\\t\\tif (__NOSCO_CALLBACK_UPDATE_PRE!=null) \"\n\t\t\t\t+ \"try { __NOSCO_CALLBACK_UPDATE_PRE.invoke(null, this); }\"\n\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\tbr.write(\"\\t\\tMap<Field<?>,Object> updates = new HashMap<Field<?>,Object>();\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_UPDATED_VALUES.get(\"+ getFieldName(column) +\".INDEX)) {\\n\");\n\t\t\tbr.write(\"\\t\\t\\tupdates.put(\"+ getFieldName(column) +\", \"\n\t\t\t+ convertToOriginalType(schema, table, column, columns.getString(column), getInstanceFieldName(column)) +\");\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tquery = query.set(updates);\\n\");\n\t\tbr.write(\"\\t\\tint count = query.update();\\n\");\n\t\tbr.write(\"\\t\\tif (__NOSCO_CALLBACK_UPDATE_POST!=null) \"\n\t\t\t\t+ \"try { __NOSCO_CALLBACK_UPDATE_POST.invoke(null, this, ds); }\"\n\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\tbr.write(\"\\t\\treturn count==1;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean delete() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return delete(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean delete(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tif (pkSet == null || pkSet.size() == 0) {\n\t\t\tfor (String column : columns.keySet()) {\n\t\t\t\tbr.write(\".where(\"+ getFieldName(column) +\".eq(\"+ getInstanceFieldName(column) +\"))\");\n\t\t\t}\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tbr.write(\"\\t\\tint count = query.deleteAll();\\n\");\n\t\tbr.write(\"\\t\\treturn count==1;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean insert() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return insert(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean insert(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tif (!dirty()) return false;\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tif (!pkSet.isEmpty()) {\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_CALLBACK_INSERT_PRE!=null) \"\n\t\t\t\t\t+ \"try { __NOSCO_CALLBACK_INSERT_PRE.invoke(null, this); }\"\n\t\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tMap<Field<?>,Object> updates = new HashMap<Field<?>,Object>();\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tupdates.put(\"+ getFieldName(column) +\", \"\n\t\t+ convertToOriginalType(schema, table, column, columns.getString(column), getInstanceFieldName(column)) +\");\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tquery = query.set(updates);\\n\");\n\t\tbr.write(\"\\t\\t\\tquery.insert();\\n\");\n\t\tbr.write(\"\\t\\t\\tif (__NOSCO_CALLBACK_INSERT_POST!=null) \"\n\t\t\t\t+ \"try { __NOSCO_CALLBACK_INSERT_POST.invoke(null, this, ds); }\"\n\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\tbr.write(\"\\t\\t\\treturn true;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean exists() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return exists(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean exists(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(column) +\".eq(\"+ getInstanceFieldName(column) +\"))\");\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tbr.write(\"\\t\\tint size = query.size();\\n\");\n\t\tbr.write(\"\\t\\treturn size > 0;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_INSERT_PRE = null;\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_INSERT_POST = null;\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_UPDATE_PRE = null;\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_UPDATE_POST = null;\\n\");\n\t\tbr.write(\"\\tstatic {\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_INSERT_PRE = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"preInsert\\\", \"\n\t\t\t\t+ className +\".class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_INSERT_POST = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"postInsert\\\", \"\n\t\t\t\t+ className +\".class, DataSource.class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_UPDATE_PRE = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"preUpdate\\\", \"\n\t\t\t\t+ className +\".class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_UPDATE_POST = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"postUpdate\\\", \"\n\t\t\t\t+ className +\".class, DataSource.class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t/**\\n\");\n\t\tbr.write(\"\\t * Returns a table alias. This is used when specifying manual joins\\n\");\n\t\tbr.write(\"\\t * to reference later using Field.from(alias) in where() conditions.\\n\");\n\t\tbr.write(\"\\t */\\n\");\n\t\tbr.write(\"\\tpublic static Table.__Alias<\"+ className +\"> as(String alias) {\\n\");\n\t\tbr.write(\"\\t\\treturn new Table.__Alias<\"+ className +\">(\"+ className +\".class, alias);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic int hashCode() {\\n\");\n\t\tbr.write(\"\\t\\tfinal int prime = 31;\\n\");\n\t\tbr.write(\"\\t\\tint result = 1;\\n\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\"\\t\\tresult = prime * result + ((\"+ getInstanceFieldName(column)\n\t\t\t\t\t+\" == null) ? 0 : \"+ getInstanceFieldName(column) +\".hashCode());\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\treturn result;\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic boolean equals(Object other) {\\n\");\n\t\tbr.write(\"\\t\\treturn (other == this) || ((other != null) \\n\");\n\t\tbr.write(\"\\t\\t\\t&& (other instanceof \"+ className +\")\\n\");\n\t\tbr.write(\"\\t\\t\\n\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\"\\t\\t\\t&& ((\"+ getInstanceFieldName(column) +\" == null) ? (((\"\n\t\t\t\t\t+ className +\")other).\"+ getInstanceFieldName(column) +\" == null) : (\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\".equals(((\"+ className +\")other).\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\")))\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\t);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic int compareTo(\"+ className +\" o) {\\n\");\n\t\tbr.write(\"\\t\\tint v = 0;\\n\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\"\\t\\tv = \"+ getInstanceFieldName(column) +\"==null ? (o.\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\"==null ? 0 : -1) : \"\n\t\t\t\t\t+ getInstanceFieldName(column) +\".compareTo(o.\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\");\\n\");\n\t\t\tbr.write(\"\\t\\tif (v != 0) return v;\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\treturn 0;\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic java.lang.Object __NOSCO_PRIVATE_mapType(java.lang.Object o) {\\n\");\n\t\tSet<String> coveredTypes = new HashSet<String>();\n\t\tfor (String origType : classTypeMappings.keySet()) {\n\t\t\tString actualType = classTypeMappings.optString(origType);\n\t\t\tbr.write(\"\\t\\tif (o instanceof \"+ actualType +\") return \");\n\t\t\tbr.write(typeMappingFunctions.optString(actualType +\" \"+ origType)\n\t\t\t\t\t.replaceAll(\"[%]s\", \"((\"+ actualType +\")o)\"));\n\t\t\tbr.write(\";\\n\");\n\t\t\tcoveredTypes.add(actualType);\n\t\t}\n\t\tfor (String actualType : this.schemaTypeMappings.values()) {\n\t\t\tif (coveredTypes.contains(actualType)) continue;\n\t\t\tString origType = null;\n\t\t\tfor (String column : columns.keySet()) {\n\t\t\t\tString type = columns.getString(column);\n\t\t\t\tif (actualType.equals(this.getFieldType(schema, table, column, type))) {\n\t\t\t\t\torigType = this.getFieldClassType(type).getName();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (origType == null) continue;\n\t\t\tbr.write(\"\\t\\tif (o instanceof \"+ actualType +\") return \");\n\t\t\tbr.write(typeMappingFunctions.optString(actualType +\" \"+ origType)\n\t\t\t\t\t.replaceAll(\"[%]s\", \"((\"+ actualType +\")o)\"));\n\t\t\tbr.write(\";\\n\");\n\t\t\tcoveredTypes.add(actualType);\n\t\t}\n\t\tbr.write(\"\\t\\treturn o;\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"}\\n\");\n\t\tbr.close();\n\t}\n", "output": "\tprivate void generate(String schema, String table, JSONObject columns, JSONArray pks,\n\t\t\tList<FK> fks, List<FK> fksIn, String dataSourceName, String callbackPackage,\n\t\t\tJSONObject enums)\n\tthrows IOException, JSONException {\n\t\tString className = genTableClassName(table);\n\t\tSet<String> pkSet = new HashSet<String>();\n\t\tif (pks == null) pks = new JSONArray();\n\t\tfor (int i=0; i<pks.length(); ++i) {\n\t\t\tpkSet.add(pks.getString(i));\n\t\t}\n\t\tint fieldCount = columns.keySet().size();\n\t\tString pkgDir = Misc.join(\"/\", pkg.split(\"[.]\"));\n\t\tnew File(Misc.join(\"/\", dir, pkgDir, schema)).mkdirs();\n\t\tFile file = new File(Misc.join(\"/\", dir, pkgDir, schema, className+\".java\"));\n\t\tSystem.out.println(\"writing: \"+ file.getAbsolutePath());\n\t\tBufferedWriter br = new BufferedWriter(new FileWriter(file));\n\t\tbr.write(\"package \"+ pkg +\".\"+ schema +\";\\n\\n\");\n\t\tbr.write(\"import java.lang.reflect.Method;\\n\");\n\t\tbr.write(\"import java.lang.reflect.InvocationTargetException;\\n\");\n\t\tbr.write(\"import java.sql.SQLException;\\n\");\n\t\tbr.write(\"import javax.sql.DataSource;\\n\");\n\t\tbr.write(\"import java.util.Map;\\n\\n\");\n\t\tbr.write(\"import java.util.HashMap;\\n\\n\");\n\t\tbr.write(\"import org.nosco.Field;\\n\");\n\t\tbr.write(\"import org.nosco.Query;\\n\");\n\t\tbr.write(\"import org.nosco.QueryFactory;\\n\");\n\t\tbr.write(\"import org.nosco.Table;\\n\");\n\t\tbr.write(\"\\n\");\n\t\tbr.write(\"public class \"+ className +\" extends Table implements Comparable<\"+ className +\"> {\\n\\n\");\n\t\tint index = 0;\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\tpublic static final Field<\");\n\t\t\tbr.write(getFieldType(schema, table, column, columns.getString(column)));\n\t\t\tbr.write(\"> \"+ getFieldName(column));\n\t\t\tbr.write(\" = new Field<\"+ getFieldType(schema, table, column, columns.getString(column)));\n\t\t\tbr.write(\">(\"+ index +\", \"+ className +\".class, \\\"\"+ column);\n\t\t\tbr.write(\"\\\", \"+ getFieldType(schema, table, column, columns.getString(column)) +\".class\");\n\t\t\tbr.write(\");\\n\");\n\t\t\t++index;\n\t\t}\n\t\tbr.write(\"\\n\");\n\t\tbr.write(\"\\tpublic static Field.PK<\"+ className +\"> PK = new Field.PK<\"+ className +\">(\");\n\t\tfor (int i=0; i<pks.length(); ++i) {\n\t\t\tbr.write(pks.getString(i).toUpperCase());\n\t\t\tif (i<pks.length()-1) br.write(\", \");\n\t\t}\n\t\tbr.write(\");\\n\");\n\t\tbr.write(\"\\tpublic org.nosco.Field.PK PK() { return PK; }\\n\\n\");\n\t\tfor (FK fk : fks) {\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tString referencedTableClassName = genTableClassName(referencedTable);\n\t\t\tif (!schema.equals(fk.reffed[0])) {\n\t\t\t\treferencedTableClassName = pkg +\".\"+ fk.reffed[0] +\".\"+ referencedTableClassName;\n\t\t\t}\n\t\t\tString fkName = genFKName(fk.columns.keySet(), referencedTable);\n\t\t\tbr.write(\"\\tpublic static final Field.FK<\"+ referencedTableClassName +\"> FK_\"+ fkName);\n\t\t\tbr.write(\" = new Field.FK<\"+ referencedTableClassName +\">(\"+ index +\", \"+ className +\".class, \");\n\t\t\tbr.write(referencedTableClassName +\".class\");\n\t\t\tfor (Entry<String, String> e : fk.columns.entrySet()) {\n\t\t\t\tbr.write(\", \"+ e.getKey().toUpperCase());\n\t\t\t}\n\t\t\tfor (Entry<String, String> e : fk.columns.entrySet()) {\n\t\t\t\tbr.write(\", \"+ referencedTableClassName +\".\");\n\t\t\t\tbr.write(e.getValue().toUpperCase());\n\t\t\t}\n\t\t\tbr.write(\");\\n\");\n\t\t\t++index;\n\t\t}\n\t\tbr.write(\"\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tString enumKey = schema +\".\"+ table +\".\"+ column;\n\t\t\tif (!enums.has(enumKey)) continue;\n\t\t\tJSONObject instances = enums.optJSONObject(enumKey);\n\t\t\tboolean simple = pkSet.size() == 1;\n\t\t\tif (simple) {\n\t\t\t\tString pk = pkSet.iterator().next();\n\t\t\t\tString pkType = getFieldType(schema, table, pk, columns.getString(pk));\n\t\t\t\tbr.write(\"\\tpublic enum PKS implements Table.__SimplePrimaryKey<\"+ className +\", \"+ pkType +\"> {\\n\\n\");\n\t\t\t\tint count = 0;\n\t\t\t\tfor (String name : instances.keySet()) {\n\t\t\t\t\t++ count;\n\t\t\t\t\tString value = instances.optJSONArray(name).getString(0);\n\t\t\t\t\tif (\"java.lang.String\".equals(pkType)) value = \"\\\"\"+ value +\"\\\"\";\n\t\t\t\t\tbr.write(\"\\t\\t\"+ name.toUpperCase().replaceAll(\"\\\\W\", \"_\"));\n\t\t\t\t\tbr.write(\"(\"+ value +\")\");\n\t\t\t\t\tif (count < instances.keySet().size()) br.write(\",\\n\");\n\t\t\t\t}\n\t\t\t\tbr.write(\";\\n\\n\");\n\t\t\t\tbr.write(\"\\t\\tpublic final \"+ pkType +\" \"+ getFieldName(pk) +\";\\n\");\n\t\t\t\tbr.write(\"\\t\\tPKS(\"+ pkType +\" v) {\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\t\"+ getFieldName(pk) +\" = v;\\n\");\n\t\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\t\tbr.write(\"\\t\\t@SuppressWarnings(\\\"unchecked\\\")\\n\");\n\t\t\t\tbr.write(\"\\t\\t@Override\\n\");\n\t\t\t\tbr.write(\"\\t\\tpublic <R> R get(Field<R> field) {\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\tif (field==\"+ className +\".\"+ getFieldName(pk)\n\t\t\t\t\t\t+\") return (R) Integer.valueOf(\"+ getFieldName(pk) +\"); \\n\");\n\t\t\t\tbr.write(\"\\t\\t\\tif (\"+ className +\".\"+ getFieldName(pk)\n\t\t\t\t\t\t+\".sameField(field)) return (R) Integer.valueOf(\"\n\t\t\t\t\t\t+ getFieldName(pk) +\");\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\tthrow new RuntimeException(\\\"field \\\"+ field +\\\" is not part of this primary key\\\");\\n\");\n\t\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\t\tbr.write(\"\\t\\t@Override\\n\");\n\t\t\t\tbr.write(\"\\t\\tpublic \"+ pkType +\" value() {\\n\");\n\t\t\t\tbr.write(\"\\t\\t\\treturn \"+ getFieldName(pk)+ \";\\n\");\n\t\t\t\tbr.write(\"\\t\\t}\\n\\n\");\n\t\t\t\tbr.write(\"\\t}\\n\");\n\t\t\t}\n\t\t}\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\tprivate \"+ getFieldType(schema, table, column, columns.getString(column)));\n\t\t\tbr.write(\" \"+ getInstanceFieldName(column) + \" = null;\\n\");\n\t\t}\n\t\tbr.write(\"\\n\");\n\t\tbr.write(\"\\tpublic \"+ className +\"() {}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tprotected \"+ className +\"(Field[] fields, Object[] objects, int start, int end) {\\n\");\n\t\tbr.write(\"\\t\\tif (fields.length != objects.length)\\n\\t\\t\\tthrow new IllegalArgumentException(\");\n\t\tbr.write(\"\\\"fields.length != objects.length => \\\"+ fields.length +\\\" != \\\"+ objects.length\");\n\t\tbr.write(\" +\\\"\\\");\\n\");\n\t\tbr.write(\"\\t\\tfor (int i=start; i<end; ++i) {\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\t\\tif (fields[i]==\"+ getFieldName(column) +\") {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\\t\"+ getInstanceFieldName(column) +\" = \");\n\t\t\tString assignment = convertToActualType(schema, table, column,\n\t\t\t\t\tcolumns.getString(column),\n\t\t\t\t\t\"(\"+ getFieldClassType(columns.getString(column)).getName()+ \") objects[i]\");\n\t\t\tbr.write(assignment);\n\t\t\tbr.write(\";\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\\t__NOSCO_FETCHED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\\tcontinue;\\n\");\n\t\t\tbr.write(\"\\t\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\t}\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic String SCHEMA_NAME() {\\n\\t\\treturn \\\"\"+ schema +\"\\\";\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic String TABLE_NAME() {\\n\\t\\treturn \\\"\"+ table +\"\\\";\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic Field[] FIELDS() {\\n\\t\\tField[] fields = {\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(getFieldName(column)+\",\");\n\t\t}\n\t\tbr.write(\"};\\n\\t\\treturn fields;\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic Field.FK[] FKS() {\\n\\t\\tField.FK[] fields = {\");\n\t\tfor (FK fk : fks) {\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tbr.write(\"FK_\" + genFKName(fk.columns.keySet(), referencedTable) + \",\");\n\t\t}\n\t\tbr.write(\"};\\n\\t\\treturn fields;\\n\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"unchecked\\\")\\n\");\n\t\tbr.write(\"\\tpublic <S> S get(Field<S> _field) {\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tif (_field==\"+ getFieldName(column) +\") \");\n\t\t\tbr.write(\"return (S) \"+ getInstanceFieldName(column) +\";\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tthrow new IllegalArgumentException(\\\"unknown field \\\"+ _field);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic <S> void set(Field<S> _field, S _value) {\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tif (_field==\"+ getFieldName(column) +\") \");\n\t\t\tbr.write(getInstanceFieldName(column) +\" = (\"+ getFieldType(schema, table, column, columns.getString(column)) +\") _value;\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tthrow new IllegalArgumentException(\\\"unknown field \\\"+ _field);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\tpublic static final Query<\"+ className +\"> ALL = QueryFactory.IT.getQuery(\"\n\t\t+ className +\".class).use(\"+ pkg +\".\"+ dataSourceName +\".\"+ schema.toUpperCase() +\");\\n\\n\");\n\t\tbr.write(\"\\t public String toString() {\\n\");\n\t\tbr.write(\"\\t\\treturn \\\"[\"+ className);\n\t\tfor (int i=0; i<pks.length(); ++i) {\n\t\t\tString pk = pks.getString(i);\n\t\t\tbr.write(\" \"+ pk+\":\");\n\t\t\tbr.write(\"\\\"+\"+ getInstanceFieldName(pk));\n\t\t\tbr.write(\"+\\\"\");\n\t\t}\n\t\tfor (String column : columns.keySet()) {\n\t\t\tif (!\"name\".equalsIgnoreCase(column)) continue;\n\t\t\tbr.write(\" \"+ column +\":\");\n\t\t\tbr.write(\"\\\"+\"+ getInstanceFieldName(column));\n\t\t\tbr.write(\"+\\\"\");\n\t\t}\n\t\tbr.write(\"]\\\";\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t public String toStringDetailed() {\\n\");\n\t\tbr.write(\"\\t\\treturn \\\"[\"+ className);\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\" \"+ column +\":\");\n\t\t\tbr.write(\"\\\"+\"+ getInstanceFieldName(column));\n\t\t\tbr.write(\"+\\\"\");\n\t\t}\n\t\tbr.write(\"]\\\";\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tString cls = getFieldType(schema, table, column, columns.getString(column));\n\t\t\tbr.write(\"\\tpublic \"+ cls +\" get\"+ getInstanceMethodName(column) +\"() {\\n\");\n\t\t\tbr.write(\"\\t\\tif (!__NOSCO_FETCHED_VALUES.get(\"+ getFieldName(column) +\".INDEX)) {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ className +\" _tmp = ALL.onlyFields(\");\n\t\t\tbr.write(getFieldName(column)+\")\");\n\t\t\tfor (String pk : pkSet) {\n\t\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t\t}\n\t\t\tbr.write(\".getTheOnly();\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ getInstanceFieldName(column) +\" = _tmp == null ? null : _tmp.get\"\n\t\t\t\t\t+ getInstanceMethodName(column) +\"();\");\n\t\t\tbr.write(\"\\t\\t\\t__NOSCO_FETCHED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\tbr.write(\"\\t\\treturn \"+ getInstanceFieldName(column) +\";\\n\\t}\\n\\n\");\n\t\t\tbr.write(\"\\tpublic \"+ className +\" set\"+ getInstanceMethodName(column));\n\t\t\tbr.write(\"(\"+ cls +\" v) {\\n\");\n\t\t\tbr.write(\"\\t\\t\"+ getInstanceFieldName(column) +\" = v;\\n\");\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_UPDATED_VALUES == null) __NOSCO_UPDATED_VALUES = new java.util.BitSet();\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_UPDATED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_FETCHED_VALUES.set(\"+ getFieldName(column) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\treturn this;\\n\");\n\t\t\tbr.write(\"\\t}\\n\\n\");\n\t\t\tif (!cls.equals(getFieldClassType(columns.getString(column)).getName())) {\n\t\t\t\tbr.write(\"\\tpublic \"+ className +\" set\"+ getInstanceMethodName(column));\n\t\t\t\tbr.write(\"(\"+ getFieldClassType(columns.getString(column)).getName() +\" v) {\\n\");\n\t\t\t\tbr.write(\"\\t\\treturn set\"+ getInstanceMethodName(column) +\"(\"+\n\t\t\t\t\t\tthis.convertToActualType(schema, table, column,\n\t\t\t\t\t\t\t\tcolumns.getString(column), \"v\") +\");\\n\");\n\t\t\t\tbr.write(\"\\t}\\n\\n\");\n\t\t\t}\n\t\t}\n\t\tfor (FK fk : fks) {\n\t\t\tString referencedSchema = fk.reffed[0];\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tString referencedTableClassName = genTableClassName(referencedTable);\n\t\t\tif (!schema.equals(fk.reffed[0])) {\n\t\t\t\treferencedTableClassName = pkg +\".\"+ fk.reffed[0] +\".\"+ referencedTableClassName;\n\t\t}\n\t\t\tString methodName = genFKMethodName(fk.columns.keySet(), referencedTable);\n\t\t\tString cachedObjectName = \"_NOSCO_FK_\"+ underscoreToCamelCase(fk.columns.keySet(), false);\n\t\t\tbr.write(\"\\tprivate \"+ referencedTableClassName +\" \"+ cachedObjectName +\" = null;\\n\\n\");\n\t\t\tbr.write(\"\\tpublic \"+ referencedTableClassName +\" get\"+ methodName +\"() {\\n\");\n\t\t\tbr.write(\"\\t\\tif (!__NOSCO_FETCHED_VALUES.get(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX)) {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ cachedObjectName +\" = \"+ referencedTableClassName +\".ALL\");\n\t\t\tbr.write(\".where(\"+ referencedTableClassName +\".\"+ getFieldName(fk.columns.values()) +\".eq(\"+ underscoreToCamelCase(fk.columns.keySet(), false) +\"))\");\n\t\t\tbr.write(\".getTheOnly();\\n\");\n\t\t\tbr.write(\"\\t\\t\\t__NOSCO_FETCHED_VALUES.set(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t\tbr.write(\"\\t\\treturn \"+ cachedObjectName +\";\\n\\t}\\n\\n\");\n\t\t\tbr.write(\"\\tpublic \"+ className +\" set\"+ methodName +\"(\"+ referencedTableClassName +\" v) {\\n\");\n\t\t\tbr.write(\"\\t\\t\"+ underscoreToCamelCase(fk.columns.keySet(), false) +\" = v.get\"+ underscoreToCamelCase(fk.columns.values(), true) +\"();\\n\");\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_UPDATED_VALUES == null) __NOSCO_UPDATED_VALUES = new java.util.BitSet();\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_UPDATED_VALUES.set(\"+ getFieldName(fk.columns.keySet()) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t\"+ cachedObjectName +\" = v;\\n\");\n\t\t\tbr.write(\"\\t\\t__NOSCO_UPDATED_VALUES.set(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\treturn this;\\n\");\n\t\t\tbr.write(\"\\n\\t}\\n\\n\");\n\t\t}\n\t\tbr.write(\"\\tprotected void SET_FK(Field.FK<?> field, Object v) {\\n\");\n\t\tbr.write(\"\\t\\tif (false);\\n\");\n\t\tfor (FK fk : fks) {\n\t\t\tString cachedObjectName = \"_NOSCO_FK_\"+ underscoreToCamelCase(fk.columns.keySet(), false);\n\t\t\tString referencedTable = fk.reffed[1];\n\t\t\tString referencedTableClassName = genTableClassName(referencedTable);\n\t\t\tif (!schema.equals(fk.reffed[0])) {\n\t\t\t\treferencedTableClassName = pkg +\".\"+ fk.reffed[0] +\".\"+ referencedTableClassName;\n\t\t}\n\t\t\tbr.write(\"\\t\\telse if (field == FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\") {\\n\");\n\t\t\tbr.write(\"\\t\\t\\t\"+ cachedObjectName +\" = (\"+ referencedTableClassName +\") v;\\n\");\n\t\t\tbr.write(\"\\t\\t\\t__NOSCO_FETCHED_VALUES.set(FK_\"+ genFKName(fk.columns.keySet(), referencedTable) +\".INDEX);\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\telse {throw new RuntimeException(\\\"unknown FK\\\");}\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"unchecked\\\")\\n\");\n\t\tbr.write(\"\\tprotected void SET_FK_SET(Field.FK<?> fk, Query<?> v) {\\n\");\n\t\tbr.write(\"\\t\\tif (false);\\n\");\n\t\tfor (FK fk : fksIn) {\n\t\t String relatedSchema = fk.reffing[0];\n\t\t String relatedTable = fk.reffing[1];\n\t\t String relatedTableClassName = this.genTableClassName(relatedTable);\n\t\t\tif (!schema.equals(relatedSchema)) {\n\t\t\t\trelatedTableClassName = pkg +\".\"+ relatedSchema +\".\"+ relatedTableClassName;\n\t\t\t}\n\t\t\tString fkName = \"FK_\"+ genFKName(fk.columns.keySet(), fk.reffed[1]);\n\t\t String localVar = \"__NOSCO_CACHED_FK_SET___\"+ relatedTable + \"___\"\n\t\t \t\t+ Misc.join(\"__\", fk.columns.keySet());\n\t\t br.write(\"\\t\\telse if (\"+ relatedTableClassName +\".\"+ fkName +\".equals(fk)) {\\n\");\n\t\t br.write(\"\\t\\t\\t\"+ localVar +\" = (Query<\"+ relatedTableClassName +\">) v;\\n\");\n\t\t br.write(\"\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\telse {throw new RuntimeException(\\\"unknown FK\\\");}\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tMap<String, Integer> reffingCounts = new HashMap<String,Integer>();\n\t\tfor (FK fk : fksIn) {\n\t\t String relatedTable = fk.reffing[1];\n\t\t Integer c = reffingCounts.get(relatedTable);\n\t\t if (c == null) c = 0;\n\t\t reffingCounts.put(relatedTable, c+1);\n\t\t}\n\t\tfor (FK fk : fksIn) {\n\t\t String relatedSchema = fk.reffing[0];\n\t\t String relatedTable = fk.reffing[1];\n\t\t String relatedTableClassName = this.genTableClassName(relatedTable);\n\t\t\tif (!schema.equals(relatedSchema)) {\n\t\t\t\trelatedTableClassName = pkg +\".\"+ relatedSchema +\".\"+ relatedTableClassName;\n\t\t\t}\n\t\t String method = getInstanceMethodName(relatedTable);\n\t\t if (reffingCounts.get(relatedTable) > 1) {\n\t\t\t String tmp = Misc.join(\"_\", fk.columns.keySet());\n\t\t\t\tmethod = method + \"_\" + getInstanceMethodName(tmp);\n\t\t }\n\t\t String localVar = \"__NOSCO_CACHED_FK_SET___\"+ relatedTable + \"___\"\n\t\t \t\t+ Misc.join(\"__\", fk.columns.keySet());\n\t\t br.write(\"\\tprivate Query<\"+ relatedTableClassName +\"> \"+ localVar +\" = null;\\n\");\n\t\t br.write(\"\\tpublic Query<\"+ relatedTableClassName +\"> get\"+ method +\"Set() {\\n\");\n\t\t br.write(\"\\t\\tif (\"+ localVar +\" != null) return \"+ localVar + \";\\n\");\n\t\t br.write(\"\\t\\telse return \"+ relatedTableClassName +\".ALL\");\n\t\t for (Entry<String, String> e : fk.columns.entrySet()) {\n\t\t\tString relatedColumn = e.getKey();\n\t\t\tString column = e.getValue();\n\t\t\tbr.write(\".where(\"+ relatedTableClassName +\".\"+ getFieldName(relatedColumn) +\".eq(get\"+ getInstanceMethodName(column) +\"()))\");\n\t\t }\n\t\t br.write(\";\\n\");\n\t\t br.write(\"\\t}\\n\\n\");\n\t\t}\n\t\tbr.write(\"\\tpublic boolean save() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return save(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean save(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tif (!dirty()) return false;\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tif (pkSet == null || pkSet.isEmpty()) {\n\t\t\tbr.write(\"\\t\\tthrow new RuntimeException(\\\"save() is ambiguous on objects without PKs - use insert() or update()\\\");\\n\");\n\t\t} else {\n\t\t\tbr.write(\"\\t\\tint size = query.size();\\n\");\n\t\t\tbr.write(\"\\t\\tif (size == 0) return this.insert(ds);\\n\");\n\t\t\tbr.write(\"\\t\\telse if (size == 1) return this.update(ds);\\n\");\n\t\t\tbr.write(\"\\t\\telse throw new RuntimeException(\\\"more than one result was returned \" +\n\t\t\t\t\t\"for a query that specified all the PKs. this is bad.\\\");\\n\");\n\t\t\tbr.write(\"\\t\\t\\n\");\n\t\t}\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean update() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return update(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean update(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tif (!dirty()) return false;\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tif (pkSet == null || pkSet.size() == 0) {\n\t\t\tfor (String column : columns.keySet()) {\n\t\t\t\tbr.write(\".where(\"+ getFieldName(column) +\".eq(\"+ getInstanceFieldName(column) +\"))\");\n\t\t\t}\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tbr.write(\"\\t\\tif (__NOSCO_CALLBACK_UPDATE_PRE!=null) \"\n\t\t\t\t+ \"try { __NOSCO_CALLBACK_UPDATE_PRE.invoke(null, this); }\"\n\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\tbr.write(\"\\t\\tMap<Field<?>,Object> updates = new HashMap<Field<?>,Object>();\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_UPDATED_VALUES.get(\"+ getFieldName(column) +\".INDEX)) {\\n\");\n\t\t\tbr.write(\"\\t\\t\\tupdates.put(\"+ getFieldName(column) +\", \"\n\t\t\t+ convertToOriginalType(schema, table, column, columns.getString(column), getInstanceFieldName(column)) +\");\\n\");\n\t\t\tbr.write(\"\\t\\t}\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tquery = query.set(updates);\\n\");\n\t\tbr.write(\"\\t\\tint count = query.update();\\n\");\n\t\tbr.write(\"\\t\\tif (__NOSCO_CALLBACK_UPDATE_POST!=null) \"\n\t\t\t\t+ \"try { __NOSCO_CALLBACK_UPDATE_POST.invoke(null, this, ds); }\"\n\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\tbr.write(\"\\t\\treturn count==1;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean delete() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return delete(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean delete(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tif (pkSet == null || pkSet.size() == 0) {\n\t\t\tfor (String column : columns.keySet()) {\n\t\t\t\tbr.write(\".where(\"+ getFieldName(column) +\".eq(\"+ getInstanceFieldName(column) +\"))\");\n\t\t\t}\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tbr.write(\"\\t\\tint count = query.deleteAll();\\n\");\n\t\tbr.write(\"\\t\\treturn count==1;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean insert() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return insert(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean insert(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tif (!dirty()) return false;\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String pk : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(pk) +\".eq(\"+ getInstanceFieldName(pk) +\"))\");\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tif (!pkSet.isEmpty()) {\n\t\t\tbr.write(\"\\t\\tif (__NOSCO_CALLBACK_INSERT_PRE!=null) \"\n\t\t\t\t\t+ \"try { __NOSCO_CALLBACK_INSERT_PRE.invoke(null, this); }\"\n\t\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tMap<Field<?>,Object> updates = new HashMap<Field<?>,Object>();\\n\");\n\t\tfor (String column : columns.keySet()) {\n\t\t\tbr.write(\"\\t\\tupdates.put(\"+ getFieldName(column) +\", \"\n\t\t+ convertToOriginalType(schema, table, column, columns.getString(column), getInstanceFieldName(column)) +\");\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\tquery = query.set(updates);\\n\");\n\t\tbr.write(\"\\t\\t\\tquery.insert();\\n\");\n\t\tbr.write(\"\\t\\t\\tif (__NOSCO_CALLBACK_INSERT_POST!=null) \"\n\t\t\t\t+ \"try { __NOSCO_CALLBACK_INSERT_POST.invoke(null, this, ds); }\"\n\t\t\t\t+ \"catch (IllegalAccessException e) { e.printStackTrace(); } \"\n\t\t\t\t+ \"catch (InvocationTargetException e) { e.printStackTrace(); }\\n\");\n\t\tbr.write(\"\\t\\t\\treturn true;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tpublic boolean exists() throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\t return exists(ALL.getDataSource());\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t@SuppressWarnings(\\\"rawtypes\\\")\\n\");\n\t\tbr.write(\"\\tpublic boolean exists(DataSource ds) throws SQLException {\\n\");\n\t\tbr.write(\"\\t\\tQuery<\"+ className +\"> query = ALL.use(ds)\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\".where(\"+ getFieldName(column) +\".eq(\"+ getInstanceFieldName(column) +\"))\");\n\t\t}\n\t\tbr.write(\";\\n\");\n\t\tbr.write(\"\\t\\tint size = query.size();\\n\");\n\t\tbr.write(\"\\t\\treturn size > 0;\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_INSERT_PRE = null;\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_INSERT_POST = null;\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_UPDATE_PRE = null;\\n\");\n\t\tbr.write(\"\\tprivate static Method __NOSCO_CALLBACK_UPDATE_POST = null;\\n\");\n\t\tbr.write(\"\\tstatic {\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_INSERT_PRE = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"preInsert\\\", \"\n\t\t\t\t+ className +\".class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_INSERT_POST = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"postInsert\\\", \"\n\t\t\t\t+ className +\".class, DataSource.class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_UPDATE_PRE = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"preUpdate\\\", \"\n\t\t\t\t+ className +\".class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t\\ttry {\\n\\t\\t\\t __NOSCO_CALLBACK_UPDATE_POST = Class.forName(\\\"\"+ callbackPackage\n\t\t\t\t+\".\"+ schema +\".\"+ className +\"CB\\\").getMethod(\\\"postUpdate\\\", \"\n\t\t\t\t+ className +\".class, DataSource.class);\\n\\t\\t} catch (Exception e) { /* ignore */ }\\n\");\n\t\tbr.write(\"\\t}\\n\");\n\t\tbr.write(\"\\t/**\\n\");\n\t\tbr.write(\"\\t * Returns a table alias. This is used when specifying manual joins\\n\");\n\t\tbr.write(\"\\t * to reference later using Field.from(alias) in where() conditions.\\n\");\n\t\tbr.write(\"\\t */\\n\");\n\t\tbr.write(\"\\tpublic static Table.__Alias<\"+ className +\"> as(String alias) {\\n\");\n\t\tbr.write(\"\\t\\treturn new Table.__Alias<\"+ className +\">(\"+ className +\".class, alias);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic int hashCode() {\\n\");\n\t\tbr.write(\"\\t\\tfinal int prime = 31;\\n\");\n\t\tbr.write(\"\\t\\tint result = 1;\\n\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\"\\t\\tresult = prime * result + ((\"+ getInstanceFieldName(column)\n\t\t\t\t\t+\" == null) ? 0 : \"+ getInstanceFieldName(column) +\".hashCode());\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\treturn result;\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic boolean equals(Object other) {\\n\");\n\t\tbr.write(\"\\t\\treturn (other == this) || ((other != null) \\n\");\n\t\tbr.write(\"\\t\\t\\t&& (other instanceof \"+ className +\")\\n\");\n\t\tbr.write(\"\\t\\t\\n\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\"\\t\\t\\t&& ((\"+ getInstanceFieldName(column) +\" == null) ? (((\"\n\t\t\t\t\t+ className +\")other).\"+ getInstanceFieldName(column) +\" == null) : (\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\".equals(((\"+ className +\")other).\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\")))\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\t);\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic int compareTo(\"+ className +\" o) {\\n\");\n\t\tbr.write(\"\\t\\tint v = 0;\\n\");\n\t\tfor (String column : pkSet == null || pkSet.size() == 0 ? columns.keySet() : pkSet) {\n\t\t\tbr.write(\"\\t\\tv = \"+ getInstanceFieldName(column) +\"==null ? (o.\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\"==null ? 0 : -1) : \"\n\t\t\t\t\t+ getInstanceFieldName(column) +\".compareTo(o.\"\n\t\t\t\t\t+ getInstanceFieldName(column) +\");\\n\");\n\t\t\tbr.write(\"\\t\\tif (v != 0) return v;\\n\");\n\t\t}\n\t\tbr.write(\"\\t\\treturn 0;\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"\\t@Override\\n\");\n\t\tbr.write(\"\\tpublic java.lang.Object __NOSCO_PRIVATE_mapType(java.lang.Object o) {\\n\");\n\t\tSet<String> coveredTypes = new HashSet<String>();\n\t\tfor (String origType : classTypeMappings.keySet()) {\n\t\t\tString actualType = classTypeMappings.optString(origType);\n\t\t\tbr.write(\"\\t\\tif (o instanceof \"+ actualType +\") return \");\n\t\t\tbr.write(typeMappingFunctions.optString(actualType +\" \"+ origType)\n\t\t\t\t\t.replaceAll(\"[%]s\", \"((\"+ actualType +\")o)\"));\n\t\t\tbr.write(\";\\n\");\n\t\t\tcoveredTypes.add(actualType);\n\t\t}\n\t\tfor (String actualType : this.schemaTypeMappings.values()) {\n\t\t\tif (coveredTypes.contains(actualType)) continue;\n\t\t\tString origType = null;\n\t\t\tfor (String column : columns.keySet()) {\n\t\t\t\tString type = columns.getString(column);\n\t\t\t\tif (actualType.equals(this.getFieldType(schema, table, column, type))) {\n\t\t\t\t\torigType = this.getFieldClassType(type).getName();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (origType == null) continue;\n\t\t\tbr.write(\"\\t\\tif (o instanceof \"+ actualType +\") return \");\n\t\t\tbr.write(typeMappingFunctions.optString(actualType +\" \"+ origType)\n\t\t\t\t\t.replaceAll(\"[%]s\", \"((\"+ actualType +\")o)\"));\n\t\t\tbr.write(\";\\n\");\n\t\t\tcoveredTypes.add(actualType);\n\t\t}\n\t\tfor (String actualType : this.schemaTypeMappings.values()) {\n\t\t\tfor (String x : typeMappingFunctions.keySet()) {\n\t\t\t\tif (coveredTypes.contains(actualType)) continue;\n\t\t\t\tString[] y = x.split(\" \");\n\t\t\t\tif (y==null || y.length!=2) {\n\t\t\t\t\tthrow new RuntimeException(\"bad key in type_mappings: '\"+ x +\"'. must be of \" +\n\t\t\t\t\t\t\t\"the form 'com.something.ClassA com.else.ClassB'\");\n\t\t\t\t}\n\t\t\t\tif (actualType.equals(y[0])) {\n\t\t\t\t\tbr.write(\"\\t\\tif (o instanceof \"+ actualType +\") return \");\n\t\t\t\t\tbr.write(typeMappingFunctions.optString(actualType +\" \"+ y[1])\n\t\t\t\t\t\t\t.replaceAll(\"[%]s\", \"((\"+ actualType +\")o)\"));\n\t\t\t\t\tbr.write(\";\\n\");\n\t\t\t\t\tcoveredTypes.add(actualType);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tbr.write(\"\\t\\treturn o;\\n\");\n\t\tbr.write(\"\\t}\\n\\n\");\n\t\tbr.write(\"}\\n\");\n\t\tbr.close();\n\t}\n"} {"input": " public static ReportTemplate fromDto(ReportTemplateDto reportTemplateDto) {\n ReportTemplate reportTemplate = new ReportTemplate();\n reportTemplate.setName(reportTemplateDto.getName());\n reportTemplate.setDesign(reportTemplateDto.getDesign());\n reportTemplate.setFormat(reportTemplateDto.getFormat());\n Map<String, String> params = Maps.newLinkedHashMap();\n for(ParameterDto param : reportTemplateDto.getParametersList()) {\n params.put(param.getKey(), param.getValue());\n }\n String schedule = reportTemplateDto.getCron();\n if(schedule != null) {\n reportTemplate.setSchedule(reportTemplateDto.getCron());\n }\n reportTemplate.setEmailNotificationAddresses(Sets.newHashSet(reportTemplateDto.getEmailNotificationList()));\n return reportTemplate;\n }\n", "output": " public static ReportTemplate fromDto(ReportTemplateDto reportTemplateDto) {\n ReportTemplate reportTemplate = new ReportTemplate();\n reportTemplate.setName(reportTemplateDto.getName());\n reportTemplate.setDesign(reportTemplateDto.getDesign());\n reportTemplate.setFormat(reportTemplateDto.getFormat());\n Map<String, String> params = Maps.newLinkedHashMap();\n for(ParameterDto param : reportTemplateDto.getParametersList()) {\n params.put(param.getKey(), param.getValue());\n }\n reportTemplate.setParameters(params);\n String schedule = reportTemplateDto.getCron();\n if(schedule != null) {\n reportTemplate.setSchedule(reportTemplateDto.getCron());\n }\n reportTemplate.setEmailNotificationAddresses(Sets.newHashSet(reportTemplateDto.getEmailNotificationList()));\n return reportTemplate;\n }\n"} {"input": " public void perform(Player player, List<String> args) {\n Plot closest = main.getPlotManager().getClosestPlotAt(\n player.getLocation());\n double dist = closest.influenceEdgeDistance(player.getLocation());\n double minDist = main.getSettings().getInitialPlotSize();\n if (dist < minDist) {\n player.sendMessage(MsgColor.ERROR\n + \"Cannot create a plot here; the plot '\"\n + MsgColor.ERROR_HILIGHT + closest.getName()\n + MsgColor.ERROR + \"' is too close.\");\n return;\n }\n String name = Joiner.on(' ').join(args);\n Plot existing = main.getPlotManager().getPlotByName(name);\n if (existing != null) {\n player.sendMessage(MsgColor.ERROR\n + \"Sorry, that name is already taken.\");\n return;\n }\n if (name.length() < 1) {\n player.sendMessage(MsgColor.ERROR + \"You must enter a name.\");\n return;\n }\n if (!Plot.isValidName(name)) {\n player.sendMessage(MsgColor.ERROR\n + \"The name you have given is invalid.\");\n player.sendMessage(MsgColor.ERROR\n + \"Names may only contain letters, numbers, spaces, apostrophes, and exclamation points.\");\n player.sendMessage(MsgColor.ERROR\n + \"Names can only be 40 letters long.\");\n return;\n }\n int multiplier = 1;\n for (Plot plot : main.getPlotManager().getPlots()) {\n if (plot.isOwner(player.getName())) {\n multiplier++;\n }\n }\n multiplier = (int) Math.pow(2.0, multiplier);\n int requiredMoney = multiplier * 1000;\n double money = main.getEconomy().getBalance(player.getName());\n if (money < requiredMoney) {\n player.sendMessage(MsgColor.ERROR\n + \"You don't have enough money to buy a plot! (Need \"\n + requiredMoney + \")\");\n return;\n }\n PlayerInventory inventory = player.getInventory();\n ItemStack[] itemStacks = inventory.getContents();\n int diamondCount = 0;\n for (int i = 0; i < itemStacks.length; i++) {\n if (itemStacks[i] == null) {\n continue;\n }\n if (itemStacks[i].getType() == Material.DIAMOND) {\n diamondCount += itemStacks[i].getAmount();\n }\n }\n int requiredDiamonds = multiplier\n * main.getSettings().getBaseDiamonds();\n if (diamondCount < requiredDiamonds) {\n player.sendMessage(MsgColor.ERROR\n + \"You don't have enough diamond to buy a plot! (Need \"\n + requiredDiamonds + \" total)\");\n return;\n }\n int amountGivee = requiredDiamonds;\n for (int i = 0; i < itemStacks.length; i++) {\n if (itemStacks[i] == null) {\n continue;\n }\n if (itemStacks[i].getType() != Material.DIAMOND) {\n continue;\n }\n if (amountGivee < itemStacks[i].getAmount()) {\n itemStacks[i]\n .setAmount(itemStacks[i].getAmount() - amountGivee);\n diamondCount -= amountGivee;\n amountGivee = 0;\n break;\n } else if (amountGivee > itemStacks[i].getAmount()) {\n diamondCount -= itemStacks[i].getAmount();\n amountGivee -= itemStacks[i].getAmount();\n inventory.setItem(i, null);\n } else if (amountGivee == itemStacks[i].getAmount()) {\n inventory.setItem(i, null);\n break;\n }\n }\n Plot plot = main.getPlotManager().createPlot(name, player.getName(),\n main.getSettings().getInitialPlotSize(), player.getLocation());\n player.sendMessage(MsgColor.SUCCESS\n + \"Your plot has been created successfully. Enjoy!\");\n }\n", "output": " public void perform(Player player, List<String> args) {\n Plot closest = main.getPlotManager().getClosestPlotAt(\n player.getLocation());\n double dist = closest.influenceEdgeDistance(player.getLocation());\n double minDist = main.getSettings().getInitialPlotSize();\n if (dist < minDist) {\n player.sendMessage(MsgColor.ERROR\n + \"Cannot create a plot here; the plot '\"\n + MsgColor.ERROR_HILIGHT + closest.getName()\n + MsgColor.ERROR + \"' is too close.\");\n return;\n }\n String name = Joiner.on(' ').join(args);\n Plot existing = main.getPlotManager().getPlotByName(name);\n if (existing != null) {\n player.sendMessage(MsgColor.ERROR\n + \"Sorry, that name is already taken.\");\n return;\n }\n if (name.length() < 1) {\n player.sendMessage(MsgColor.ERROR + \"You must enter a name.\");\n return;\n }\n if (!Plot.isValidName(name)) {\n player.sendMessage(MsgColor.ERROR\n + \"The name you have given is invalid.\");\n player.sendMessage(MsgColor.ERROR\n + \"Names may only contain letters, numbers, spaces, apostrophes, and exclamation points.\");\n player.sendMessage(MsgColor.ERROR\n + \"Names can only be 40 letters long.\");\n return;\n }\n int multiplier = 1;\n for (Plot plot : main.getPlotManager().getPlots()) {\n if (plot.isOwner(player.getName())) {\n multiplier++;\n }\n }\n multiplier = (int) Math.pow(2.0, multiplier - 1);\n int requiredMoney = multiplier * 1000;\n double money = main.getEconomy().getBalance(player.getName());\n if (money < requiredMoney) {\n player.sendMessage(MsgColor.ERROR\n + \"You don't have enough money to buy a plot! (Need \"\n + requiredMoney + \")\");\n return;\n }\n PlayerInventory inventory = player.getInventory();\n ItemStack[] itemStacks = inventory.getContents();\n int diamondCount = 0;\n for (int i = 0; i < itemStacks.length; i++) {\n if (itemStacks[i] == null) {\n continue;\n }\n if (itemStacks[i].getType() == Material.DIAMOND) {\n diamondCount += itemStacks[i].getAmount();\n }\n }\n int requiredDiamonds = multiplier\n * main.getSettings().getBaseDiamonds();\n if (diamondCount < requiredDiamonds) {\n player.sendMessage(MsgColor.ERROR\n + \"You don't have enough diamond to buy a plot! (Need \"\n + requiredDiamonds + \" total)\");\n return;\n }\n int amountGivee = requiredDiamonds;\n for (int i = 0; i < itemStacks.length; i++) {\n if (itemStacks[i] == null) {\n continue;\n }\n if (itemStacks[i].getType() != Material.DIAMOND) {\n continue;\n }\n if (amountGivee < itemStacks[i].getAmount()) {\n itemStacks[i]\n .setAmount(itemStacks[i].getAmount() - amountGivee);\n diamondCount -= amountGivee;\n amountGivee = 0;\n break;\n } else if (amountGivee > itemStacks[i].getAmount()) {\n diamondCount -= itemStacks[i].getAmount();\n amountGivee -= itemStacks[i].getAmount();\n inventory.setItem(i, null);\n } else if (amountGivee == itemStacks[i].getAmount()) {\n inventory.setItem(i, null);\n break;\n }\n }\n Plot plot = main.getPlotManager().createPlot(name, player.getName(),\n main.getSettings().getInitialPlotSize(), player.getLocation());\n player.sendMessage(MsgColor.SUCCESS\n + \"Your plot has been created successfully. Enjoy!\");\n }\n"} {"input": " private SVNEntry readEntry(BufferedReader reader, int entryNumber) throws IOException, SVNException {\n String line = reader.readLine();\n if (line == null && entryNumber > 1) {\n return null;\n }\n String name = parseString(line);\n name = name != null ? name : getThisDirName();\n Map entryAttrs = new HashMap();\n entryAttrs.put(SVNProperty.NAME, name);\n SVNEntry entry = new SVNEntry(entryAttrs, this, name);\n line = reader.readLine();\n String kind = parseValue(line);\n if (kind != null) {\n SVNNodeKind parsedKind = SVNNodeKind.parseKind(kind); \n if (parsedKind != SVNNodeKind.UNKNOWN && parsedKind != SVNNodeKind.NONE) {\n entryAttrs.put(SVNProperty.KIND, kind);\n } else {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.NODE_UNKNOWN_KIND, \"Entry ''{0}'' has invalid node kind\", name);\n SVNErrorManager.error(err);\n }\n } else {\n entryAttrs.put(SVNProperty.KIND, SVNNodeKind.NONE.toString());\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String revision = parseValue(line);\n if (revision != null) {\n entryAttrs.put(SVNProperty.REVISION, revision);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String url = parseString(line);\n if (url != null) {\n entryAttrs.put(SVNProperty.URL, url);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String reposRoot = parseString(line);\n if (reposRoot != null && url != null && !SVNPathUtil.isAncestor(reposRoot, url)) {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, \"Entry for ''{0}'' has invalid repository root\", name);\n SVNErrorManager.error(err);\n } else if (reposRoot != null) {\n entryAttrs.put(SVNProperty.REPOS, reposRoot);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String schedule = parseValue(line);\n if (schedule != null) {\n if (SVNProperty.SCHEDULE_ADD.equals(schedule) || SVNProperty.SCHEDULE_DELETE.equals(schedule) || SVNProperty.SCHEDULE_REPLACE.equals(schedule)) {\n entryAttrs.put(SVNProperty.SCHEDULE, schedule);\n } else {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_ATTRIBUTE_INVALID, \"Entry ''{0}'' has invalid ''{1}'' value\", new Object[]{name, SVNProperty.SCHEDULE});\n SVNErrorManager.error(err);\n }\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String timestamp = parseValue(line);\n if (timestamp != null) {\n entryAttrs.put(SVNProperty.TEXT_TIME, timestamp);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String checksum = parseString(line);\n if (checksum != null) {\n entryAttrs.put(SVNProperty.CHECKSUM, checksum);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String committedDate = parseValue(line);\n if (committedDate != null) {\n entryAttrs.put(SVNProperty.COMMITTED_DATE, committedDate);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String committedRevision = parseValue(line);\n if (committedRevision != null) {\n entryAttrs.put(SVNProperty.COMMITTED_REVISION, committedRevision);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String committedAuthor = parseString(line);\n if (committedAuthor != null) {\n entryAttrs.put(SVNProperty.LAST_AUTHOR, committedAuthor);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean hasProps = parseBoolean(line, SVNProperty.HAS_PROPS);\n if (hasProps) {\n entryAttrs.put(SVNProperty.HAS_PROPS, SVNProperty.toString(hasProps));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean hasPropMods = parseBoolean(line, SVNProperty.HAS_PROP_MODS);\n if (hasPropMods) {\n entryAttrs.put(SVNProperty.HAS_PROP_MODS, SVNProperty.toString(hasPropMods));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String cachablePropsStr = parseValue(line);\n if (cachablePropsStr != null) {\n String[] cachableProps = fromString(cachablePropsStr, \" \");\n entryAttrs.put(SVNProperty.CACHABLE_PROPS, cachableProps);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String presentPropsStr = parseValue(line);\n if (presentPropsStr != null) {\n String[] presentProps = fromString(presentPropsStr, \" \");\n entryAttrs.put(SVNProperty.PRESENT_PROPS, presentProps);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String prejFile = parseString(line);\n if (prejFile != null) {\n entryAttrs.put(SVNProperty.PROP_REJECT_FILE, prejFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String conflictOldFile = parseString(line);\n if (conflictOldFile != null) {\n entryAttrs.put(SVNProperty.CONFLICT_OLD, conflictOldFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String conflictNewFile = parseString(line);\n if (conflictNewFile != null) {\n entryAttrs.put(SVNProperty.CONFLICT_NEW, conflictNewFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String conflictWorkFile = parseString(line);\n if (conflictWorkFile != null) {\n entryAttrs.put(SVNProperty.CONFLICT_WRK, conflictWorkFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isCopied = parseBoolean(line, ATTRIBUTE_COPIED);\n if (isCopied) {\n entryAttrs.put(SVNProperty.COPIED, SVNProperty.toString(isCopied));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String copyfromURL = parseString(line);\n if (copyfromURL != null) {\n entryAttrs.put(SVNProperty.COPYFROM_URL, copyfromURL);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String copyfromRevision = parseValue(line);\n if (copyfromRevision != null) {\n entryAttrs.put(SVNProperty.COPYFROM_REVISION, copyfromRevision);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isDeleted = parseBoolean(line, ATTRIBUTE_DELETED);\n if (isDeleted) {\n entryAttrs.put(SVNProperty.DELETED, SVNProperty.toString(isDeleted));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isAbsent = parseBoolean(line, ATTRIBUTE_ABSENT);\n if (isAbsent) {\n entryAttrs.put(SVNProperty.ABSENT, SVNProperty.toString(isAbsent));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isIncomplete = parseBoolean(line, ATTRIBUTE_INCOMPLETE);\n if (isIncomplete) {\n entryAttrs.put(SVNProperty.INCOMPLETE, SVNProperty.toString(isIncomplete));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String uuid = parseString(line);\n if (uuid != null) {\n entryAttrs.put(SVNProperty.UUID, uuid);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockToken = parseString(line);\n if (lockToken != null) {\n entryAttrs.put(SVNProperty.LOCK_TOKEN, lockToken);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockOwner = parseString(line);\n if (lockOwner != null) {\n entryAttrs.put(SVNProperty.LOCK_OWNER, lockOwner);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockComment = parseString(line);\n if (lockComment != null) {\n entryAttrs.put(SVNProperty.LOCK_COMMENT, lockComment);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockCreationDate = parseValue(line);\n if (lockCreationDate != null) {\n entryAttrs.put(SVNProperty.LOCK_CREATION_DATE, lockCreationDate);\n }\n do {\n line = reader.readLine();\n if (line == null) {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, \"Missing entry terminator\");\n SVNErrorManager.error(err);\n } else if (line.length() == 1 && line.charAt(0) != '\\f') {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, \"Invalid entry terminator\");\n SVNErrorManager.error(err);\n }\n } while (line != null);\n return entry;\n }\n", "output": " private SVNEntry readEntry(BufferedReader reader, int entryNumber) throws IOException, SVNException {\n String line = reader.readLine();\n if (line == null && entryNumber > 1) {\n return null;\n }\n String name = parseString(line);\n name = name != null ? name : getThisDirName();\n Map entryAttrs = new HashMap();\n entryAttrs.put(SVNProperty.NAME, name);\n SVNEntry entry = new SVNEntry(entryAttrs, this, name);\n line = reader.readLine();\n String kind = parseValue(line);\n if (kind != null) {\n SVNNodeKind parsedKind = SVNNodeKind.parseKind(kind); \n if (parsedKind != SVNNodeKind.UNKNOWN && parsedKind != SVNNodeKind.NONE) {\n entryAttrs.put(SVNProperty.KIND, kind);\n } else {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.NODE_UNKNOWN_KIND, \"Entry ''{0}'' has invalid node kind\", name);\n SVNErrorManager.error(err);\n }\n } else {\n entryAttrs.put(SVNProperty.KIND, SVNNodeKind.NONE.toString());\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String revision = parseValue(line);\n if (revision != null) {\n entryAttrs.put(SVNProperty.REVISION, revision);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String url = parseString(line);\n if (url != null) {\n entryAttrs.put(SVNProperty.URL, url);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String reposRoot = parseString(line);\n if (reposRoot != null && url != null && !SVNPathUtil.isAncestor(reposRoot, url)) {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, \"Entry for ''{0}'' has invalid repository root\", name);\n SVNErrorManager.error(err);\n } else if (reposRoot != null) {\n entryAttrs.put(SVNProperty.REPOS, reposRoot);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String schedule = parseValue(line);\n if (schedule != null) {\n if (SVNProperty.SCHEDULE_ADD.equals(schedule) || SVNProperty.SCHEDULE_DELETE.equals(schedule) || SVNProperty.SCHEDULE_REPLACE.equals(schedule)) {\n entryAttrs.put(SVNProperty.SCHEDULE, schedule);\n } else {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_ATTRIBUTE_INVALID, \"Entry ''{0}'' has invalid ''{1}'' value\", new Object[]{name, SVNProperty.SCHEDULE});\n SVNErrorManager.error(err);\n }\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String timestamp = parseValue(line);\n if (timestamp != null) {\n entryAttrs.put(SVNProperty.TEXT_TIME, timestamp);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String checksum = parseString(line);\n if (checksum != null) {\n entryAttrs.put(SVNProperty.CHECKSUM, checksum);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String committedDate = parseValue(line);\n if (committedDate != null) {\n entryAttrs.put(SVNProperty.COMMITTED_DATE, committedDate);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String committedRevision = parseValue(line);\n if (committedRevision != null) {\n entryAttrs.put(SVNProperty.COMMITTED_REVISION, committedRevision);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String committedAuthor = parseString(line);\n if (committedAuthor != null) {\n entryAttrs.put(SVNProperty.LAST_AUTHOR, committedAuthor);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean hasProps = parseBoolean(line, SVNProperty.HAS_PROPS);\n if (hasProps) {\n entryAttrs.put(SVNProperty.HAS_PROPS, SVNProperty.toString(hasProps));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean hasPropMods = parseBoolean(line, SVNProperty.HAS_PROP_MODS);\n if (hasPropMods) {\n entryAttrs.put(SVNProperty.HAS_PROP_MODS, SVNProperty.toString(hasPropMods));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String cachablePropsStr = parseValue(line);\n if (cachablePropsStr != null) {\n String[] cachableProps = fromString(cachablePropsStr, \" \");\n entryAttrs.put(SVNProperty.CACHABLE_PROPS, cachableProps);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String presentPropsStr = parseValue(line);\n if (presentPropsStr != null) {\n String[] presentProps = fromString(presentPropsStr, \" \");\n entryAttrs.put(SVNProperty.PRESENT_PROPS, presentProps);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String prejFile = parseString(line);\n if (prejFile != null) {\n entryAttrs.put(SVNProperty.PROP_REJECT_FILE, prejFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String conflictOldFile = parseString(line);\n if (conflictOldFile != null) {\n entryAttrs.put(SVNProperty.CONFLICT_OLD, conflictOldFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String conflictNewFile = parseString(line);\n if (conflictNewFile != null) {\n entryAttrs.put(SVNProperty.CONFLICT_NEW, conflictNewFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String conflictWorkFile = parseString(line);\n if (conflictWorkFile != null) {\n entryAttrs.put(SVNProperty.CONFLICT_WRK, conflictWorkFile);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isCopied = parseBoolean(line, ATTRIBUTE_COPIED);\n if (isCopied) {\n entryAttrs.put(SVNProperty.COPIED, SVNProperty.toString(isCopied));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String copyfromURL = parseString(line);\n if (copyfromURL != null) {\n entryAttrs.put(SVNProperty.COPYFROM_URL, copyfromURL);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String copyfromRevision = parseValue(line);\n if (copyfromRevision != null) {\n entryAttrs.put(SVNProperty.COPYFROM_REVISION, copyfromRevision);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isDeleted = parseBoolean(line, ATTRIBUTE_DELETED);\n if (isDeleted) {\n entryAttrs.put(SVNProperty.DELETED, SVNProperty.toString(isDeleted));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isAbsent = parseBoolean(line, ATTRIBUTE_ABSENT);\n if (isAbsent) {\n entryAttrs.put(SVNProperty.ABSENT, SVNProperty.toString(isAbsent));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n boolean isIncomplete = parseBoolean(line, ATTRIBUTE_INCOMPLETE);\n if (isIncomplete) {\n entryAttrs.put(SVNProperty.INCOMPLETE, SVNProperty.toString(isIncomplete));\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String uuid = parseString(line);\n if (uuid != null) {\n entryAttrs.put(SVNProperty.UUID, uuid);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockToken = parseString(line);\n if (lockToken != null) {\n entryAttrs.put(SVNProperty.LOCK_TOKEN, lockToken);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockOwner = parseString(line);\n if (lockOwner != null) {\n entryAttrs.put(SVNProperty.LOCK_OWNER, lockOwner);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockComment = parseString(line);\n if (lockComment != null) {\n entryAttrs.put(SVNProperty.LOCK_COMMENT, lockComment);\n }\n line = reader.readLine();\n if (isEntryFinished(line)) {\n return entry;\n }\n String lockCreationDate = parseValue(line);\n if (lockCreationDate != null) {\n entryAttrs.put(SVNProperty.LOCK_CREATION_DATE, lockCreationDate);\n }\n do {\n line = reader.readLine();\n if (line == null) {\n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, \"Missing entry terminator\");\n SVNErrorManager.error(err);\n } else if (line.length() == 1 && line.charAt(0) != '\\f') { \n SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_CORRUPT, \"Invalid entry terminator\");\n SVNErrorManager.error(err);\n } else if (line.length() == 1 && line.charAt(0) == '\\f') {\n break;\n }\n } while (line != null);\n return entry;\n }\n"} {"input": " public void testCreateAndUpdateUser()\n throws Exception\n {\n User user = new User();\n user.setUsername(USERNAME);\n user.setPassword(PASSWORD);\n final long countOld = usersDao.count();\n usersDao.createUser(user);\n final long countNew = usersDao.count();\n assertTrue(\"Failed to create user '\" + USERNAME + \"'!\", countOld < countNew);\n final String changedPassword = EncryptionUtils.encryptWithMD5(\"newpassword\");\n user.setPassword(changedPassword);\n usersDao.updateUser(user);\n User updatedUser = usersDao.findUser(USERNAME, changedPassword);\n assertEquals(\"Failed to update the user!\", changedPassword, updatedUser.getPassword());\n user = updatedUser;\n String roleName = \"ADMINISTRATOR\";\n assertFalse(\"This user is already an administrator!\", user.hasRole(roleName));\n usersDao.assignRole(user, roleName);\n updatedUser = usersDao.findUser(USERNAME);\n assertTrue(\"Failed to assign role 'ADMINISTRATOR' to user '\" + USERNAME + \"'\",\n updatedUser.hasRole(roleName));\n usersDao.removeUser(user.getUsername());\n }\n", "output": " public void testCreateAndUpdateUser()\n throws Exception\n {\n User user = new User();\n user.setUsername(USERNAME);\n user.setPassword(PASSWORD);\n final long countOld = usersDao.count();\n usersDao.createUser(user);\n final long countNew = usersDao.count();\n assertTrue(\"Failed to create user '\" + USERNAME + \"'!\", countOld < countNew);\n final String changedPassword = EncryptionUtils.encryptWithMD5(\"newpassword\");\n user.setPassword(changedPassword);\n usersDao.updateUser(user);\n User updatedUser = usersDao.findUser(USERNAME, changedPassword);\n assertEquals(\"Failed to update the user!\", changedPassword, updatedUser.getPassword());\n user = updatedUser;\n String roleName = \"ADMINISTRATOR\";\n assertFalse(\"This user is already an administrator!\", user.hasRole(roleName));\n usersDao.assignRole(user, roleName);\n updatedUser = usersDao.findUser(USERNAME);\n assertTrue(\"Failed to assign role 'ADMINISTRATOR' to user '\" + USERNAME + \"'\",\n updatedUser.hasRole(roleName));\n }\n"} {"input": "\tpublic void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException {\n\t\tif (monitor == null) {\n\t\t\tmonitor = new NullProgressMonitor();\n\t\t}\n\t\tIProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);\n\t\tsubMonitor.beginTask(LaunchingMessages.getString(\"StandardVMRunner.Launching_VM..._1\"), 2); \n\t\tsubMonitor.subTask(LaunchingMessages.getString(\"StandardVMRunner.Constructing_command_line..._2\")); \n\t\tString program= constructProgramString(config);\n\t\tList arguments= new ArrayList();\n\t\targuments.add(program);\n\t\tString[] vmArgs= combineVmArgs(config, fVMInstance);\n\t\taddArguments(vmArgs, arguments);\n\t\tString[] bootCP= config.getBootClassPath();\t\t\n\t\tString[] classPath = config.getClassPath();\n\t\tString[] combinedPath = null;\n\t\tif (bootCP == null) {\n\t\t\tLibraryLocation[] locs = JavaRuntime.getLibraryLocations(fVMInstance);\n\t\t\tbootCP = new String[locs.length];\n\t\t\tfor (int i = 0; i < locs.length; i++) {\n\t\t\t\tbootCP[i] = locs[i].getSystemLibraryPath().toOSString();\n\t\t\t}\n\t\t}\n\t\tcombinedPath = new String[bootCP.length + classPath.length];\n\t\tint offset = 0;\n\t\tfor (int i = 0; i < bootCP.length; i++) {\n\t\t\tcombinedPath[offset] = bootCP[i];\n\t\t\toffset++;\n\t\t}\n\t\tfor (int i = 0; i < classPath.length; i++) {\n\t\t\tcombinedPath[offset] = classPath[i];\n\t\t\toffset++;\n\t\t}\n\t\tif (combinedPath.length > 0) {\n\t\t\targuments.add(\"-classpath\"); \n\t\t\targuments.add(convertClassPath(combinedPath));\n\t\t}\n\t\tString[] programArgs= config.getProgramArguments();\n\t\taddArguments(programArgs, arguments);\n\t\tString[] cmdLine= new String[arguments.size()];\n\t\targuments.toArray(cmdLine);\n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\n\t\tsubMonitor.worked(1);\n\t\tsubMonitor.subTask(LaunchingMessages.getString(\"StandardVMRunner.Starting_virtual_machine..._3\")); \n\t\tProcess p= null;\n\t\tFile workingDir = getWorkingDir(config);\n\t\tp= exec(cmdLine, workingDir);\n\t\tif (p == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (monitor.isCanceled()) {\n\t\t\tp.destroy();\n\t\t\treturn;\n\t\t}\t\t\n\t\tIProcess process= DebugPlugin.newProcess(launch, p, renderProcessLabel(cmdLine));\n\t\tprocess.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));\n\t\tsubMonitor.worked(1);\n\t}\n", "output": "\tpublic void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException {\n\t\tif (monitor == null) {\n\t\t\tmonitor = new NullProgressMonitor();\n\t\t}\n\t\tIProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);\n\t\tsubMonitor.beginTask(LaunchingMessages.getString(\"StandardVMRunner.Launching_VM..._1\"), 2); \n\t\tsubMonitor.subTask(LaunchingMessages.getString(\"StandardVMRunner.Constructing_command_line..._2\")); \n\t\tString program= constructProgramString(config);\n\t\tList arguments= new ArrayList();\n\t\targuments.add(program);\n\t\tString[] vmArgs= combineVmArgs(config, fVMInstance);\n\t\taddArguments(vmArgs, arguments);\n\t\tString[] bootCP= config.getBootClassPath();\t\t\n\t\tString[] classPath = config.getClassPath();\n\t\tString[] combinedPath = null;\n\t\tif (bootCP == null) {\n\t\t\tLibraryLocation[] locs = JavaRuntime.getLibraryLocations(fVMInstance);\n\t\t\tbootCP = new String[locs.length];\n\t\t\tfor (int i = 0; i < locs.length; i++) {\n\t\t\t\tbootCP[i] = locs[i].getSystemLibraryPath().toOSString();\n\t\t\t}\n\t\t}\n\t\tcombinedPath = new String[bootCP.length + classPath.length];\n\t\tint offset = 0;\n\t\tfor (int i = 0; i < bootCP.length; i++) {\n\t\t\tcombinedPath[offset] = bootCP[i];\n\t\t\toffset++;\n\t\t}\n\t\tfor (int i = 0; i < classPath.length; i++) {\n\t\t\tcombinedPath[offset] = classPath[i];\n\t\t\toffset++;\n\t\t}\n\t\tif (combinedPath.length > 0) {\n\t\t\targuments.add(\"-classpath\"); \n\t\t\targuments.add(convertClassPath(combinedPath));\n\t\t}\n\t\targuments.add(config.getClassToLaunch());\n\t\tString[] programArgs= config.getProgramArguments();\n\t\taddArguments(programArgs, arguments);\n\t\tString[] cmdLine= new String[arguments.size()];\n\t\targuments.toArray(cmdLine);\n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\n\t\tsubMonitor.worked(1);\n\t\tsubMonitor.subTask(LaunchingMessages.getString(\"StandardVMRunner.Starting_virtual_machine..._3\")); \n\t\tProcess p= null;\n\t\tFile workingDir = getWorkingDir(config);\n\t\tp= exec(cmdLine, workingDir);\n\t\tif (p == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (monitor.isCanceled()) {\n\t\t\tp.destroy();\n\t\t\treturn;\n\t\t}\t\t\n\t\tIProcess process= DebugPlugin.newProcess(launch, p, renderProcessLabel(cmdLine));\n\t\tprocess.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));\n\t\tsubMonitor.worked(1);\n\t}\n"} {"input": "\tpublic static void main(String args[]) throws IOException, FileNotFoundException {\n\t\tif (args.length < 1) {\n\t\t\tSystem.out.println(\"Usage: Main <document_folder>\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_STOPWORD + \"]\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_STOPWORDFILE + \"]\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_STEMMING + \"]\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_FOLDER + \"]\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tinitializeLogging();\n\t\tif (args.length >= 1) {\n\t\t\tinitializeFlags(args);\n\t\t}\n\t\tinitializeDataSet(docFolder);\n\t\tFrequencyMap totalMap = new FrequencyMap();\n\t\tClassifier classifier = new Classifier();\n ROCGraph graph = new ROCGraph();\n\t\tint run = 0;\n for (DocSet docSet : docSetList) {\n int totalSpamDocs = 0;\n int totalHamDocs = 0;\n for (DocSet documentSet : docSetList) { \n totalMap.add(documentSet);\n totalSpamDocs += documentSet.getNumSpamDocs();\n totalHamDocs += documentSet.getNumHamDocs();\n }\n\t\t\trun++;\n\t\t\tFrequencyMap trainingMap = totalMap.subtract(docSet);\n\t\t\tint trainingSpamDocs = totalSpamDocs - docSet.getNumSpamDocs();\n\t\t\tint trainingHamDocs = totalHamDocs - docSet.getNumHamDocs();\n\t\t\tint totalTrainingDocs = trainingSpamDocs + trainingHamDocs;\n\t\t\tdouble spamProb = trainingSpamDocs / (double) totalTrainingDocs;\n\t\t\tdouble hamProb = 1 - spamProb;\n\t\t\tclassifier.reset();\n\t\t\tclassifier.classify(docSet, trainingMap, spamProb);\n\t\t\tint TP = classifier.getTruePositives();\n\t\t\tint FP = classifier.getFalsePositives();\n\t\t\tint TN = classifier.getTrueNegatives();\n\t\t\tint FN = classifier.getFalseNegatives();\n\t\t\tdouble precision = TP / ((double) TP + FP);\n\t\t\tdouble recall = TP / ((double) TP + FN);\n\t\t\tdouble fpRate = FP / ((double) FP + TN);\n\t\t\tdouble tpRate = recall;\n\t\t\tStringBuilder stats = new StringBuilder();\n\t\t\tstats.append(\"Run no. \" + run + \"\\n\");\n\t\t\tstats.append(\"Total training size: \" + totalTrainingDocs + \"\\n\");\n\t\t\tstats.append(\"Total spam documents: \" + trainingSpamDocs + \"\\n\");\n\t\t\tstats.append(\"Total ham documents: \" + trainingHamDocs + \"\\n\");\n\t\t\tstats.append(\"Prior probabilities:\\n\");\n\t\t\tstats.append(\"Spam - \" + spamProb + \"\\n\");\n\t\t\tstats.append(\"Ham - \" + hamProb + \"\\n\");\n\t\t\tstats.append(\"TP = \" + TP + \", FN = \" + FN + \", FP = \" + FP + \", TN = \" + TN + \"\\n\");\n\t\t\tstats.append(\"Precision = \" + precision + \", Recall = \" + recall + \"\\n\");\n\t\t\tstats.append(\"====================================================================\\n\");\n\t\t\tlogger.log(Config.LOG_LEVEL, stats.toString());\n\t\t\tSystem.out.println(stats);\n\t\t\tgraph.addPoint(tpRate, fpRate);\n\t\t}\n\t\tgraph.createROCGraph(chartFile + \".png\");\n\t}\n", "output": "\tpublic static void main(String args[]) throws IOException, FileNotFoundException {\n\t\tif (args.length < 1) {\n\t\t\tSystem.out.println(\"Usage: Main <document_folder>\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_STOPWORD + \"]\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_STOPWORDFILE + \"]\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_STEMMING + \"]\"\n\t\t\t\t\t+ \" [\" + Config.PARAM_FOLDER + \"]\"\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tinitializeLogging();\n\t\tif (args.length >= 1) {\n\t\t\tinitializeFlags(args);\n\t\t}\n\t\tinitializeDataSet(docFolder);\n\t\tFrequencyMap totalMap = new FrequencyMap();\n\t\tClassifier classifier = new Classifier();\n\t\tROCGraph graph = new ROCGraph();\n\t\tint run = 0;\n for (DocSet docSet : docSetList) {\n int totalSpamDocs = 0;\n int totalHamDocs = 0;\n for (DocSet documentSet : docSetList) { \n totalMap.add(documentSet);\n totalSpamDocs += documentSet.getNumSpamDocs();\n totalHamDocs += documentSet.getNumHamDocs();\n }\n\t\t\trun++;\n\t\t\tFrequencyMap trainingMap = totalMap.subtract(docSet);\n\t\t\tint trainingSpamDocs = totalSpamDocs - docSet.getNumSpamDocs();\n\t\t\tint trainingHamDocs = totalHamDocs - docSet.getNumHamDocs();\n\t\t\tint totalTrainingDocs = trainingSpamDocs + trainingHamDocs;\n\t\t\tdouble spamProb = trainingSpamDocs / (double) totalTrainingDocs;\n\t\t\tdouble hamProb = 1 - spamProb;\n\t\t\tclassifier.reset();\n\t\t\tclassifier.classify(docSet, trainingMap, spamProb);\n\t\t\tint TP = classifier.getTruePositives();\n\t\t\tint FP = classifier.getFalsePositives();\n\t\t\tint TN = classifier.getTrueNegatives();\n\t\t\tint FN = classifier.getFalseNegatives();\n\t\t\tdouble precision = TP / ((double) TP + FP);\n\t\t\tdouble recall = TP / ((double) TP + FN);\n\t\t\tdouble fpRate = FP / ((double) FP + TN);\n\t\t\tdouble tpRate = recall;\n\t\t\tStringBuilder stats = new StringBuilder();\n\t\t\tstats.append(\"Run no. \" + run + \"\\n\");\n\t\t\tstats.append(\"Total training size: \" + totalTrainingDocs + \"\\n\");\n\t\t\tstats.append(\"Total spam documents: \" + trainingSpamDocs + \"\\n\");\n\t\t\tstats.append(\"Total ham documents: \" + trainingHamDocs + \"\\n\");\n\t\t\tstats.append(\"Prior probabilities:\\n\");\n\t\t\tstats.append(\"Spam - \" + spamProb + \"\\n\");\n\t\t\tstats.append(\"Ham - \" + hamProb + \"\\n\");\n\t\t\tstats.append(\"TP = \" + TP + \", FN = \" + FN + \", FP = \" + FP + \", TN = \" + TN + \"\\n\");\n\t\t\tstats.append(\"Precision = \" + precision + \", Recall = \" + recall + \"\\n\");\n\t\t\tstats.append(\"====================================================================\\n\");\n\t\t\tlogger.log(Config.LOG_LEVEL, stats.toString());\n\t\t\tSystem.out.println(stats);\n\t\t\tgraph.addPoint(tpRate, fpRate);\n\t\t}\n\t\tgraph.createROCGraph(chartFile + \".png\");\n\t}\n"} {"input": " public boolean service(WebloungeRequest request, WebloungeResponse response) {\n Site site = request.getSite();\n String path = request.getRequestURI();\n String feedType = null;\n if (!path.startsWith(URI_PREFIX) || !(path.length() > URI_PREFIX.length()))\n return false;\n String requestMethod = request.getMethod();\n if (!\"GET\".equals(requestMethod)) {\n logger.debug(\"Feed request handler does not support {} requests\", requestMethod);\n return false;\n }\n ContentRepository contentRepository = site.getContentRepository();\n if (contentRepository == null) {\n logger.warn(\"No content repository found for site '{}'\", site);\n return false;\n }\n String feedURI = path.substring(URI_PREFIX.length());\n String[] feedURIParts = feedURI.split(\"/\");\n if (feedURIParts.length == 0) {\n logger.debug(\"Feed request {} does not include feed type\", path);\n return false;\n } else if (feedURIParts.length == 1) {\n logger.debug(\"Feed request {} does not include feed version\", path);\n return false;\n }\n String[] subjectParameter = request.getParameterValues(PARAM_SUBJECT);\n List<String> subjects = new ArrayList<String>();\n if (subjectParameter != null) {\n for (String parameter : subjectParameter) {\n for (String subject : parameter.split(\",\")) {\n if (StringUtils.isNotBlank(subject))\n subjects.add(StringUtils.trim(subject));\n }\n }\n }\n int limit = DEFAULT_LIMIT;\n String limitParameter = StringUtils.trimToNull(request.getParameter(PARAM_LIMIT));\n if (limitParameter != null) {\n try {\n limit = Integer.parseInt(limitParameter);\n } catch (Throwable t) {\n logger.debug(\"Non parseable number {} specified as limit\", limitParameter);\n limit = DEFAULT_LIMIT;\n }\n }\n Language language = request.getLanguage();\n feedType = feedURIParts[0].toLowerCase() + \"_\" + feedURIParts[1];\n SyndFeed feed = new SyndFeedImpl();\n feed.setFeedType(feedType);\n feed.setLink(request.getRequestURL().toString());\n feed.setTitle(site.getName());\n feed.setLanguage(language.getDescription());\n try {\n SearchQuery query = new SearchQueryImpl(site);\n query.withType(Page.TYPE);\n query.withLimit(limit);\n query.sortByModificationDate(Order.Descending);\n for (String subject : subjects) {\n query.withSubject(subject);\n }\n SearchResult result = contentRepository.find(query);\n List<SyndEntry> entries = new ArrayList<SyndEntry>();\n for (SearchResultItem item : result.getItems()) {\n if (limit == 0)\n break;\n SearchResultPageItem pageItem = (SearchResultPageItem)item;\n Page page = pageItem.getPage();\n page.switchTo(language);\n SyndEntry entry = new SyndEntryImpl();\n entry.setPublishedDate(page.getPublishFrom());\n entry.setLink(item.getUrl().getLink());\n entry.setAuthor(page.getCreator().getName());\n entry.setCategories(Arrays.asList(page.getSubjects()));\n entry.setTitle(item.getTitle());\n entries.add(entry);\n limit--;\n }\n feed.setEntries(entries);\n } catch (ContentRepositoryException e) {\n logger.error(\"Error loading articles for feeds from {}: {}\", contentRepository, e.getMessage());\n DispatchUtils.sendInternalError(request, response);\n return true;\n }\n if (\"atom\".equalsIgnoreCase(\"atom\"))\n response.setContentType(\"application/atom+xml\");\n else if (\"rss\".equalsIgnoreCase(feedType))\n response.setContentType(\"application/rss+xml\");\n response.setCharacterEncoding(feed.getEncoding());\n try {\n SyndFeedOutput output = new SyndFeedOutput();\n Writer responseWriter = new OutputStreamWriter(response.getOutputStream());\n output.output(feed, responseWriter);\n response.getOutputStream().flush();\n return true;\n } catch (FeedException e) {\n logger.error(\"Error creating {} feed: {}\", feedType, e.getMessage());\n DispatchUtils.sendInternalError(request, response);\n return true;\n } catch (IOException e) {\n logger.error(\"Error sending {} feed to the client: {}\", feedType, e.getMessage());\n DispatchUtils.sendInternalError(request, response);\n return true;\n }\n }\n", "output": " public boolean service(WebloungeRequest request, WebloungeResponse response) {\n Site site = request.getSite();\n String path = request.getRequestURI();\n String feedType = null;\n if (!path.startsWith(URI_PREFIX) || !(path.length() > URI_PREFIX.length()))\n return false;\n String requestMethod = request.getMethod();\n if (!\"GET\".equals(requestMethod)) {\n logger.debug(\"Feed request handler does not support {} requests\", requestMethod);\n return false;\n }\n ContentRepository contentRepository = site.getContentRepository();\n if (contentRepository == null) {\n logger.warn(\"No content repository found for site '{}'\", site);\n return false;\n }\n String feedURI = path.substring(URI_PREFIX.length());\n String[] feedURIParts = feedURI.split(\"/\");\n if (feedURIParts.length == 0) {\n logger.debug(\"Feed request {} does not include feed type\", path);\n return false;\n } else if (feedURIParts.length == 1) {\n logger.debug(\"Feed request {} does not include feed version\", path);\n return false;\n }\n String[] subjectParameter = request.getParameterValues(PARAM_SUBJECT);\n List<String> subjects = new ArrayList<String>();\n if (subjectParameter != null) {\n for (String parameter : subjectParameter) {\n for (String subject : parameter.split(\",\")) {\n if (StringUtils.isNotBlank(subject))\n subjects.add(StringUtils.trim(subject));\n }\n }\n }\n int limit = DEFAULT_LIMIT;\n String limitParameter = StringUtils.trimToNull(request.getParameter(PARAM_LIMIT));\n if (limitParameter != null) {\n try {\n limit = Integer.parseInt(limitParameter);\n } catch (Throwable t) {\n logger.debug(\"Non parseable number {} specified as limit\", limitParameter);\n limit = DEFAULT_LIMIT;\n }\n }\n Language language = request.getLanguage();\n feedType = feedURIParts[0].toLowerCase() + \"_\" + feedURIParts[1];\n SyndFeed feed = new SyndFeedImpl();\n feed.setFeedType(feedType);\n feed.setLink(request.getRequestURL().toString());\n feed.setTitle(site.getName());\n feed.setLanguage(language.getDescription());\n try {\n SearchQuery query = new SearchQueryImpl(site);\n query.withType(Page.TYPE);\n query.withLimit(limit);\n query.sortByModificationDate(Order.Descending);\n for (String subject : subjects) {\n query.withSubject(subject);\n }\n SearchResult result = contentRepository.find(query);\n List<SyndEntry> entries = new ArrayList<SyndEntry>();\n for (SearchResultItem item : result.getItems()) {\n if (limit == 0)\n break;\n SearchResultPageItem pageItem = (SearchResultPageItem)item;\n Page page = pageItem.getPage();\n page.switchTo(language);\n SyndEntry entry = new SyndEntryImpl();\n entry.setPublishedDate(page.getPublishFrom());\n entry.setLink(item.getUrl().getLink());\n entry.setAuthor(page.getCreator().getName());\n entry.setCategories(Arrays.asList(page.getSubjects()));\n entry.setTitle(page.getTitle());\n entries.add(entry);\n limit--;\n }\n feed.setEntries(entries);\n } catch (ContentRepositoryException e) {\n logger.error(\"Error loading articles for feeds from {}: {}\", contentRepository, e.getMessage());\n DispatchUtils.sendInternalError(request, response);\n return true;\n }\n if (\"atom\".equalsIgnoreCase(\"atom\"))\n response.setContentType(\"application/atom+xml\");\n else if (\"rss\".equalsIgnoreCase(feedType))\n response.setContentType(\"application/rss+xml\");\n response.setCharacterEncoding(feed.getEncoding());\n try {\n SyndFeedOutput output = new SyndFeedOutput();\n Writer responseWriter = new OutputStreamWriter(response.getOutputStream());\n output.output(feed, responseWriter);\n response.getOutputStream().flush();\n return true;\n } catch (FeedException e) {\n logger.error(\"Error creating {} feed: {}\", feedType, e.getMessage());\n DispatchUtils.sendInternalError(request, response);\n return true;\n } catch (IOException e) {\n logger.error(\"Error sending {} feed to the client: {}\", feedType, e.getMessage());\n DispatchUtils.sendInternalError(request, response);\n return true;\n }\n }\n"} {"input": " protected PoolConfiguration loadConfig( String root )\n {\n PoolConfiguration config = (PoolConfiguration) defaultConfig.clone();\n if ( props.containsKey( root + \".useBoundary\" ) )\n {\n try\n {\n config.setUseBoundary( Boolean.getBoolean( (String) props.get( root + \".useBoundary\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"useBoundary not a boolean.\", nfe );\n }\n }\n if ( props.containsKey( root + \".boundarySize\" ) )\n {\n try\n {\n config.setBoundarySize( Integer.parseInt( (String) props.get( root + \".boundarySize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"boundarySize not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".maximumPoolSize\" ) )\n {\n try\n {\n config.setMaximumPoolSize( Integer.parseInt( (String) props.get( root + \".maximumPoolSize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"maximumPoolSize not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".minimumPoolSize\" ) )\n {\n try\n {\n config.setMinimumPoolSize( Integer.parseInt( (String) props.get( root + \".minimumPoolSize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"minimumPoolSize not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".keepAliveTime\" ) )\n {\n try\n {\n config.setKeepAliveTime( Integer.parseInt( (String) props.get( root + \".keepAliveTime\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"keepAliveTime not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".whenBlockedPolicy\" ) )\n {\n config.setWhenBlockedPolicy( (String) props.get( root + \".whenBlockedPolicy\" ) );\n }\n if ( props.containsKey( root + \".startUpSize\" ) )\n {\n try\n {\n config.setStartUpSize( Integer.parseInt( (String) props.get( root + \".startUpSize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"startUpSize not a number.\", nfe );\n }\n }\n if ( log.isInfoEnabled() )\n {\n log.info( root + \" PoolConfiguration = \" + config );\n }\n return config;\n }\n", "output": " protected PoolConfiguration loadConfig( String root )\n {\n PoolConfiguration config = (PoolConfiguration) defaultConfig.clone();\n if ( props.containsKey( root + \".useBoundary\" ) )\n {\n try\n {\n config.setUseBoundary( Boolean.valueOf( (String) props.get( root + \".useBoundary\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"useBoundary not a boolean.\", nfe );\n }\n }\n if ( props.containsKey( root + \".boundarySize\" ) )\n {\n try\n {\n config.setBoundarySize( Integer.parseInt( (String) props.get( root + \".boundarySize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"boundarySize not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".maximumPoolSize\" ) )\n {\n try\n {\n config.setMaximumPoolSize( Integer.parseInt( (String) props.get( root + \".maximumPoolSize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"maximumPoolSize not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".minimumPoolSize\" ) )\n {\n try\n {\n config.setMinimumPoolSize( Integer.parseInt( (String) props.get( root + \".minimumPoolSize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"minimumPoolSize not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".keepAliveTime\" ) )\n {\n try\n {\n config.setKeepAliveTime( Integer.parseInt( (String) props.get( root + \".keepAliveTime\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"keepAliveTime not a number.\", nfe );\n }\n }\n if ( props.containsKey( root + \".whenBlockedPolicy\" ) )\n {\n config.setWhenBlockedPolicy( (String) props.get( root + \".whenBlockedPolicy\" ) );\n }\n if ( props.containsKey( root + \".startUpSize\" ) )\n {\n try\n {\n config.setStartUpSize( Integer.parseInt( (String) props.get( root + \".startUpSize\" ) ) );\n }\n catch ( NumberFormatException nfe )\n {\n log.error( \"startUpSize not a number.\", nfe );\n }\n }\n if ( log.isInfoEnabled() )\n {\n log.info( root + \" PoolConfiguration = \" + config );\n }\n return config;\n }\n"} {"input": "\tprivate RoutingEntry getRoutingEntryHRG(AbstractRoutingGraph<HRMID, AbstractRoutingGraphLink> pHRG, HRMID pFrom, HRMID pTo, String pCause, LinkedList<LinkedList<AbstractRoutingGraphLink>> pRefDeletedLinks)\n\t{\n\t\tboolean DEBUG = HRMConfig.DebugOutput.GUI_SHOW_HRG_ROUTING;\n\t\tRoutingEntry tResult = null;\n\t\tLinkedList<AbstractRoutingGraphLink> tDeletedLinks = null;\n\t\tif(pRefDeletedLinks != null){\n\t\t\ttDeletedLinks = pRefDeletedLinks.getFirst();\n\t\t}\n\t\tif (DEBUG){\n\t\t\tLogging.log(this, \"getRoutingEntryHRG() searches a route from \" + pFrom + \" to \" + pTo);\n\t\t}\n\t\tsynchronized (pHRG){\n\t\t\tif(pFrom.equals(pTo)){\n\t\t\t\ttResult = RoutingEntry.createLocalhostEntry(pFrom, pCause);\n\t\t\t\ttResult.extendCause(this + \"::getRoutingEntry() with same source and destination address \" + pFrom);\n\t\t\t\treturn tResult;\n\t\t\t}\n\t\t\tif(pFrom.getHierarchyLevel() < pTo.getHierarchyLevel()){\n\t\t\t\tDEBUG = true;\n\t\t\t\tHRMID tAbstractSource = pFrom.getClusterAddress(pTo.getHierarchyLevel());\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \"getRoutingEntryHRG() searches a more abstract route from a more abstract source \" + tAbstractSource + \"(\" + pFrom + \") to destination \" + pTo);\n\t\t\t\t}\n\t\t\t\tRoutingEntry tSecondRoutePart = getRoutingEntryHRG(pHRG, tAbstractSource, pTo, pCause, null);\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \" ..second route part: \" + tSecondRoutePart);\n\t\t\t\t}\n\t\t\t\tif(tSecondRoutePart != null){\n\t\t\t\t\tHRMID tOutgressGatewayFromSourceCluster = tSecondRoutePart.getSource();\n\t\t\t\t\tRoutingEntry tIntraClusterRoutePart = getRoutingEntryHRG(pHRG, pFrom, tOutgressGatewayFromSourceCluster, pCause, null);\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..first route part: \" + tIntraClusterRoutePart);\n\t\t\t\t\t}\n\t\t\t\t\tif(tIntraClusterRoutePart != null){\n\t\t\t\t\t\ttResult = tIntraClusterRoutePart.clone();\n\t\t\t\t\t\ttResult.append(tSecondRoutePart, pCause);\n\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\tLogging.log(this, \" ..resulting route (\" + pFrom + \" ==> \" + pTo + \"): \" + tResult);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + pFrom + \" to \" + tOutgressGatewayFromSourceCluster + \" as first part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + tAbstractSource + \" to \" + pTo + \" as second part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t}\n\t\t\t\tif(tResult != null){\n\t\t\t\t\ttResult.extendCause(this + \"::getRoutingEntry()\");\n\t\t\t\t}\n\t\t\t\treturn tResult;\n\t\t\t}\n\t\t\tif(pFrom.getHierarchyLevel() > pTo.getHierarchyLevel()){\n\t\t\t\tHRMID tAbstractDestination = pTo.getClusterAddress(pFrom.getHierarchyLevel());\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \"getRoutingEntryHRG() searches a more abstract route from \" + pFrom + \" to more abstract destination \" + tAbstractDestination + \"(\" + pTo + \")\");\n\t\t\t\t}\n\t\t\t\tRoutingEntry tFirstRoutePart = getRoutingEntryHRG(pHRG, pFrom, tAbstractDestination, pCause, null);\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \" ..first route part: \" + tFirstRoutePart);\n\t\t\t\t}\n\t\t\t\tif(tFirstRoutePart != null){\n\t\t\t\t\tHRMID tIngressGatewayToDestinationCluster = tFirstRoutePart.getLastNextHop();\n\t\t\t\t\tRoutingEntry tIntraClusterRoutePart = getRoutingEntryHRG(pHRG, tIngressGatewayToDestinationCluster, pTo, pCause, null);\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..second route part: \" + tIntraClusterRoutePart);\n\t\t\t\t\t}\n\t\t\t\t\tif(tIntraClusterRoutePart != null){\n\t\t\t\t\t\ttResult = tFirstRoutePart.clone();\n\t\t\t\t\t\ttResult.append(tIntraClusterRoutePart, pCause);\n\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\tLogging.log(this, \" ..resulting route (\" + pFrom + \" ==> \" + tAbstractDestination + \"): \" + tResult);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + tIngressGatewayToDestinationCluster + \" to \" + pTo + \" as second part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + pFrom + \" to \" + tAbstractDestination + \" as first part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t}\n\t\t\t\tif(tResult != null){\n\t\t\t\t\ttResult.extendCause(this + \"::getRoutingEntry()\");\n\t\t\t\t}\n\t\t\t\treturn tResult;\n\t\t\t}\n\t\t\tint tStep = 0;\n\t\t\tList<AbstractRoutingGraphLink> tPath = getRouteHRG(pHRG, pFrom, pTo);\n\t\t\tAbstractRoutingGraphLink tFirstUsedInterClusterLink = null;\n\t\t\tif(tPath != null){\n\t\t\t\tboolean tRouteLeavesSuperiorCluster = false;\n\t\t\t\tHRMID tLastClusterGateway = null;\n\t\t\t\tHRMID tFirstForeignGateway = null;\n\t\t\t\tif(!tPath.isEmpty()){\n\t\t\t\t\tHRMID tFromToSuperiorCluster = pFrom.getForeignCluster(pTo).getSuperiorClusterAddress();\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..found inter cluster path (\" + pFrom + \" to \" + pTo + \"): [superior cluster: \" + tFromToSuperiorCluster + \"]\");\n\t\t\t\t\t\tint i = 0;\n\t\t\t\t\t\tfor(AbstractRoutingGraphLink tLink : tPath){\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..inter-cluster step[\" + i + \"]: \" + tLink);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor(AbstractRoutingGraphLink tInterClusterLink : tPath){\n\t\t\t\t\t\tRoutingEntry tInterClusterRoutingEntry = tInterClusterLink.getRoutingEntry();\n\t\t\t\t\t\tif(!tInterClusterRoutingEntry.getNextHop().isCluster(tFromToSuperiorCluster)){\n\t\t\t\t\t\t\ttRouteLeavesSuperiorCluster = true;\n\t\t\t\t\t\t\tLogging.warn(this, \" ..detected route beyond cluster borders of \" + tFromToSuperiorCluster + \" in entry: \" + tInterClusterRoutingEntry);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tResult != null){\n\t\t\t\t\t\t\tif(tLastClusterGateway == null){\n\t\t\t\t\t\t\t\tthrow new RuntimeException(this + \"::getRoutingEntryHRG() should never reach this point\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tHRMID tNextClusterGateway = tInterClusterRoutingEntry.getSource();\n\t\t\t\t\t\t\tif(!tLastClusterGateway.equals(tNextClusterGateway)){\n\t\t\t\t\t\t\t\tList<AbstractRoutingGraphLink> tIntraClusterPath = getRouteHRG(pHRG, tLastClusterGateway, tNextClusterGateway);\n\t\t\t\t\t\t\t\tif(tIntraClusterPath != null){\n\t\t\t\t\t\t\t\t\tif(!tIntraClusterPath.isEmpty()){\n\t\t\t\t\t\t\t\t\t\tRoutingEntry tLogicalIntraClusterRoutingEntry = null;\n\t\t\t\t\t\t\t\t\t\tAbstractRoutingGraphLink tIntraClusterLogLink = tIntraClusterPath.get(0);\n\t\t\t\t\t\t\t\t\t\tif(tIntraClusterPath.size() == 1){\n\t\t\t\t\t\t\t\t\t\t\ttLogicalIntraClusterRoutingEntry = (RoutingEntry) tIntraClusterLogLink.getRoute().getFirst();\n\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\ttLogicalIntraClusterRoutingEntry = RoutingEntry.create(tIntraClusterPath);\n\t\t\t\t\t\t\t\t\t\t\tif(tLogicalIntraClusterRoutingEntry == null){\n\t\t\t\t\t\t\t\t\t\t\t\tif(pRefDeletedLinks == null){\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() for \" + pFrom + \" found a complex intra-cluster path from \" + tLastClusterGateway + \" to \" + tNextClusterGateway + \" and wasn't able to derive an aggregated logical link from it..\");\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" \t..path: \" + tIntraClusterPath);\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..from: \" + tLastClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..to: \" + tNextClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..for a routing from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\ttResult = null;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif(tLogicalIntraClusterRoutingEntry != null){\n\t\t\t\t\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\t\t\t\t\tLogging.log(this, \" ..step [\" + tStep + \"] (intra-cluster): \" + tLogicalIntraClusterRoutingEntry + \" ## \" + tIntraClusterPath);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ttResult.append(tLogicalIntraClusterRoutingEntry, pCause + \"append1_intra_cluster from \" + tLastClusterGateway + \" to \" + tNextClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\ttStep++;\n\t\t\t\t\t\t\t\t\t\t\tif(tFirstForeignGateway == null){\n\t\t\t\t\t\t\t\t\t\t\t\tif(tLogicalIntraClusterRoutingEntry.getHopCount() > 0){\n\t\t\t\t\t\t\t\t\t\t\t\t\ttFirstForeignGateway = tLogicalIntraClusterRoutingEntry.getNextHop();\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\tif(pRefDeletedLinks != null){\n\t\t\t\t\t\t\t\t\t\t\tif(!tLastClusterGateway.equals(tNextClusterGateway)){\n\t\t\t\t\t\t\t\t\t\t\t\ttResult = null;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() found an empty intra-cluster path..\");\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..from: \" + tLastClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..to: \" + tNextClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..for a routing from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't find a route from \" + tLastClusterGateway + \" to \" + tNextClusterGateway + \" for a routing from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\t\t\ttResult = null;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..step [\" + tStep + \"] (cluster-2-cluster): \" + tInterClusterRoutingEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttResult.append(tInterClusterRoutingEntry, pCause + \"append2_inter_cluster for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..step [\" + tStep + \"] (cluster-2-cluster): \" + tInterClusterRoutingEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttInterClusterRoutingEntry.extendCause(pCause + \"append3_start_inter_cluster for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\ttResult = tInterClusterRoutingEntry;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttStep++;\n\t\t\t\t\t\tif(tFirstUsedInterClusterLink == null){\n\t\t\t\t\t\t\ttFirstUsedInterClusterLink = tInterClusterLink;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tFirstForeignGateway == null){\n\t\t\t\t\t\t\tif(tInterClusterRoutingEntry.getHopCount() > 0){\n\t\t\t\t\t\t\t\ttFirstForeignGateway = tInterClusterRoutingEntry.getNextHop();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttLastClusterGateway = tInterClusterRoutingEntry.getNextHop();\n\t\t\t\t\t} \n\t\t\t\t}else{\n\t\t\t\t\tif(pRefDeletedLinks == null){\n\t\t\t\t\t}else{\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(tResult != null){\n\t\t\t\t\ttResult.setDest(pFrom.getForeignCluster(pTo) );\n\t\t\t\t\ttResult.setNextHopL2Address(null);\n\t\t\t\t\tif(tRouteLeavesSuperiorCluster){\n\t\t\t\t\t\ttResult.setRouteAcrossNetwork();\n\t\t\t\t\t}\n\t\t\t\t\tif(tFirstUsedInterClusterLink != null){\n\t\t\t\t\t\tif(tDeletedLinks != null){\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..mark as deleted: \" + tFirstUsedInterClusterLink);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttDeletedLinks.add(tFirstUsedInterClusterLink);\n\t\t\t\t\t\t\tpHRG.unlink(tFirstUsedInterClusterLink);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tif(!FOUND_GLOBAL_ERROR){\n\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG based inter-cluster route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn tResult;\n\t}\n", "output": "\tprivate RoutingEntry getRoutingEntryHRG(AbstractRoutingGraph<HRMID, AbstractRoutingGraphLink> pHRG, HRMID pFrom, HRMID pTo, String pCause, LinkedList<LinkedList<AbstractRoutingGraphLink>> pRefDeletedLinks)\n\t{\n\t\tboolean DEBUG = HRMConfig.DebugOutput.GUI_SHOW_HRG_ROUTING;\n\t\tRoutingEntry tResult = null;\n\t\tLinkedList<AbstractRoutingGraphLink> tDeletedLinks = null;\n\t\tif(pRefDeletedLinks != null){\n\t\t\ttDeletedLinks = pRefDeletedLinks.getFirst();\n\t\t}\n\t\tif (DEBUG){\n\t\t\tLogging.log(this, \"getRoutingEntryHRG() searches a route from \" + pFrom + \" to \" + pTo);\n\t\t}\n\t\tsynchronized (pHRG){\n\t\t\tif(pFrom.equals(pTo)){\n\t\t\t\ttResult = RoutingEntry.createLocalhostEntry(pFrom, pCause);\n\t\t\t\ttResult.extendCause(this + \"::getRoutingEntry() with same source and destination address \" + pFrom);\n\t\t\t\treturn tResult;\n\t\t\t}\n\t\t\tif(pFrom.getHierarchyLevel() < pTo.getHierarchyLevel()){\n\t\t\t\tDEBUG = true;\n\t\t\t\tHRMID tAbstractSource = pFrom.getClusterAddress(pTo.getHierarchyLevel());\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \"getRoutingEntryHRG() searches a more abstract route from a more abstract source \" + tAbstractSource + \"(\" + pFrom + \") to destination \" + pTo);\n\t\t\t\t}\n\t\t\t\tRoutingEntry tSecondRoutePart = getRoutingEntryHRG(pHRG, tAbstractSource, pTo, pCause, null);\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \" ..second route part: \" + tSecondRoutePart);\n\t\t\t\t}\n\t\t\t\tif(tSecondRoutePart != null){\n\t\t\t\t\tHRMID tOutgressGatewayFromSourceCluster = tSecondRoutePart.getSource();\n\t\t\t\t\tRoutingEntry tIntraClusterRoutePart = getRoutingEntryHRG(pHRG, pFrom, tOutgressGatewayFromSourceCluster, pCause, null);\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..first route part: \" + tIntraClusterRoutePart);\n\t\t\t\t\t}\n\t\t\t\t\tif(tIntraClusterRoutePart != null){\n\t\t\t\t\t\ttResult = tIntraClusterRoutePart.clone();\n\t\t\t\t\t\ttResult.append(tSecondRoutePart, pCause);\n\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\tLogging.log(this, \" ..resulting route (\" + pFrom + \" ==> \" + pTo + \"): \" + tResult);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + pFrom + \" to \" + tOutgressGatewayFromSourceCluster + \" as first part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + tAbstractSource + \" to \" + pTo + \" as second part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t}\n\t\t\t\tif(tResult != null){\n\t\t\t\t\ttResult.extendCause(this + \"::getRoutingEntry()\");\n\t\t\t\t}\n\t\t\t\treturn tResult;\n\t\t\t}\n\t\t\tif(pFrom.getHierarchyLevel() > pTo.getHierarchyLevel()){\n\t\t\t\tHRMID tAbstractDestination = pTo.getClusterAddress(pFrom.getHierarchyLevel());\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \"getRoutingEntryHRG() searches a more abstract route from \" + pFrom + \" to more abstract destination \" + tAbstractDestination + \"(\" + pTo + \")\");\n\t\t\t\t}\n\t\t\t\tRoutingEntry tFirstRoutePart = getRoutingEntryHRG(pHRG, pFrom, tAbstractDestination, pCause, null);\n\t\t\t\tif (DEBUG){\n\t\t\t\t\tLogging.log(this, \" ..first route part: \" + tFirstRoutePart);\n\t\t\t\t}\n\t\t\t\tif(tFirstRoutePart != null){\n\t\t\t\t\tHRMID tIngressGatewayToDestinationCluster = tFirstRoutePart.getLastNextHop();\n\t\t\t\t\tRoutingEntry tIntraClusterRoutePart = getRoutingEntryHRG(pHRG, tIngressGatewayToDestinationCluster, pTo, pCause, null);\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..second route part: \" + tIntraClusterRoutePart);\n\t\t\t\t\t}\n\t\t\t\t\tif(tIntraClusterRoutePart != null){\n\t\t\t\t\t\ttResult = tFirstRoutePart.clone();\n\t\t\t\t\t\ttResult.append(tIntraClusterRoutePart, pCause);\n\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\tLogging.log(this, \" ..resulting route (\" + pFrom + \" ==> \" + tAbstractDestination + \"): \" + tResult);\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + tIngressGatewayToDestinationCluster + \" to \" + pTo + \" as second part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG route from \" + pFrom + \" to \" + tAbstractDestination + \" as first part for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t}\n\t\t\t\tif(tResult != null){\n\t\t\t\t\ttResult.extendCause(this + \"::getRoutingEntry()\");\n\t\t\t\t}\n\t\t\t\treturn tResult;\n\t\t\t}\n\t\t\tint tStep = 0;\n\t\t\tList<AbstractRoutingGraphLink> tPath = getRouteHRG(pHRG, pFrom, pTo);\n\t\t\tAbstractRoutingGraphLink tFirstUsedInterClusterLink = null;\n\t\t\tif(tPath != null){\n\t\t\t\tboolean tRouteLeavesSuperiorCluster = false;\n\t\t\t\tHRMID tLastClusterGateway = null;\n\t\t\t\tHRMID tFirstForeignGateway = null;\n\t\t\t\tif(!tPath.isEmpty()){\n\t\t\t\t\tHRMID tFromToSuperiorCluster = pFrom.getForeignCluster(pTo).getSuperiorClusterAddress();\n\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\tLogging.log(this, \" ..found inter cluster path (\" + pFrom + \" to \" + pTo + \"): [superior cluster: \" + tFromToSuperiorCluster + \"]\");\n\t\t\t\t\t\tint i = 0;\n\t\t\t\t\t\tfor(AbstractRoutingGraphLink tLink : tPath){\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..inter-cluster step[\" + i + \"]: \" + tLink);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor(AbstractRoutingGraphLink tInterClusterLink : tPath){\n\t\t\t\t\t\tRoutingEntry tInterClusterRoutingEntry = tInterClusterLink.getRoutingEntry();\n\t\t\t\t\t\tif(!tInterClusterRoutingEntry.getNextHop().isCluster(tFromToSuperiorCluster)){\n\t\t\t\t\t\t\ttRouteLeavesSuperiorCluster = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tResult != null){\n\t\t\t\t\t\t\tif(tLastClusterGateway == null){\n\t\t\t\t\t\t\t\tthrow new RuntimeException(this + \"::getRoutingEntryHRG() should never reach this point\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tHRMID tNextClusterGateway = tInterClusterRoutingEntry.getSource();\n\t\t\t\t\t\t\tif(!tLastClusterGateway.equals(tNextClusterGateway)){\n\t\t\t\t\t\t\t\tList<AbstractRoutingGraphLink> tIntraClusterPath = getRouteHRG(pHRG, tLastClusterGateway, tNextClusterGateway);\n\t\t\t\t\t\t\t\tif(tIntraClusterPath != null){\n\t\t\t\t\t\t\t\t\tif(!tIntraClusterPath.isEmpty()){\n\t\t\t\t\t\t\t\t\t\tRoutingEntry tLogicalIntraClusterRoutingEntry = null;\n\t\t\t\t\t\t\t\t\t\tAbstractRoutingGraphLink tIntraClusterLogLink = tIntraClusterPath.get(0);\n\t\t\t\t\t\t\t\t\t\tif(tIntraClusterPath.size() == 1){\n\t\t\t\t\t\t\t\t\t\t\ttLogicalIntraClusterRoutingEntry = (RoutingEntry) tIntraClusterLogLink.getRoute().getFirst();\n\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\ttLogicalIntraClusterRoutingEntry = RoutingEntry.create(tIntraClusterPath);\n\t\t\t\t\t\t\t\t\t\t\tif(tLogicalIntraClusterRoutingEntry == null){\n\t\t\t\t\t\t\t\t\t\t\t\tif(pRefDeletedLinks == null){\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() for \" + pFrom + \" found a complex intra-cluster path from \" + tLastClusterGateway + \" to \" + tNextClusterGateway + \" and wasn't able to derive an aggregated logical link from it..\");\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" \t..path: \" + tIntraClusterPath);\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..from: \" + tLastClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..to: \" + tNextClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..for a routing from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\ttResult = null;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tif(tLogicalIntraClusterRoutingEntry != null){\n\t\t\t\t\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\t\t\t\t\tLogging.log(this, \" ..step [\" + tStep + \"] (intra-cluster): \" + tLogicalIntraClusterRoutingEntry + \" ## \" + tIntraClusterPath);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\ttResult.append(tLogicalIntraClusterRoutingEntry, pCause + \"append1_intra_cluster from \" + tLastClusterGateway + \" to \" + tNextClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\ttStep++;\n\t\t\t\t\t\t\t\t\t\t\tif(tFirstForeignGateway == null){\n\t\t\t\t\t\t\t\t\t\t\t\tif(tLogicalIntraClusterRoutingEntry.getHopCount() > 0){\n\t\t\t\t\t\t\t\t\t\t\t\t\ttFirstForeignGateway = tLogicalIntraClusterRoutingEntry.getNextHop();\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\tif(pRefDeletedLinks != null){\n\t\t\t\t\t\t\t\t\t\t\tif(!tLastClusterGateway.equals(tNextClusterGateway)){\n\t\t\t\t\t\t\t\t\t\t\t\ttResult = null;\n\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() found an empty intra-cluster path..\");\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..from: \" + tLastClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..to: \" + tNextClusterGateway);\n\t\t\t\t\t\t\t\t\t\t\tLogging.warn(this, \" ..for a routing from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't find a route from \" + tLastClusterGateway + \" to \" + tNextClusterGateway + \" for a routing from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\t\t\ttResult = null;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..step [\" + tStep + \"] (cluster-2-cluster): \" + tInterClusterRoutingEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttResult.append(tInterClusterRoutingEntry, pCause + \"append2_inter_cluster for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..step [\" + tStep + \"] (cluster-2-cluster): \" + tInterClusterRoutingEntry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttInterClusterRoutingEntry.extendCause(pCause + \"append3_start_inter_cluster for a route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t\t\t\ttResult = tInterClusterRoutingEntry;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttStep++;\n\t\t\t\t\t\tif(tFirstUsedInterClusterLink == null){\n\t\t\t\t\t\t\ttFirstUsedInterClusterLink = tInterClusterLink;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tFirstForeignGateway == null){\n\t\t\t\t\t\t\tif(tInterClusterRoutingEntry.getHopCount() > 0){\n\t\t\t\t\t\t\t\ttFirstForeignGateway = tInterClusterRoutingEntry.getNextHop();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttLastClusterGateway = tInterClusterRoutingEntry.getNextHop();\n\t\t\t\t\t} \n\t\t\t\t}else{\n\t\t\t\t\tif(pRefDeletedLinks == null){\n\t\t\t\t\t}else{\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(tResult != null){\n\t\t\t\t\ttResult.setDest(pFrom.getForeignCluster(pTo) );\n\t\t\t\t\ttResult.setNextHopL2Address(null);\n\t\t\t\t\tif(tRouteLeavesSuperiorCluster){\n\t\t\t\t\t\ttResult.setRouteAcrossNetwork();\n\t\t\t\t\t}\n\t\t\t\t\tif(tFirstUsedInterClusterLink != null){\n\t\t\t\t\t\tif(tDeletedLinks != null){\n\t\t\t\t\t\t\tif (DEBUG){\n\t\t\t\t\t\t\t\tLogging.log(this, \" ..mark as deleted: \" + tFirstUsedInterClusterLink);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttDeletedLinks.add(tFirstUsedInterClusterLink);\n\t\t\t\t\t\t\tpHRG.unlink(tFirstUsedInterClusterLink);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tif(!FOUND_GLOBAL_ERROR){\n\t\t\t\t\tLogging.warn(this, \"getRoutingEntryHRG() couldn't determine an HRG based inter-cluster route from \" + pFrom + \" to \" + pTo);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn tResult;\n\t}\n"} {"input": "\tprivate void processAgentMessageStringCommand(Identifier messageId){\n String message = \"\";\n WMElement wordsWME = messageId.FindByAttribute(\"first\", 0);\n if (wordsWME == null || !wordsWME.IsIdentifier())\n {\n messageId.CreateStringWME(\"status\", \"error\");\n throw new IllegalStateException(\"Message has no first attribute\");\n }\n Identifier currentWordId = wordsWME.ConvertToIdentifier();\n while (currentWordId != null)\n {\n Identifier nextWordId = null;\n for (int i = 0; i < currentWordId.GetNumberChildren(); i++)\n {\n WMElement child = currentWordId.GetChild(i);\n if (child.GetAttribute().equals(\"word\"))\n {\n message += child.GetValueAsString() + \" \";\n }\n else if (child.GetAttribute().equals(\"next\")\n && child.IsIdentifier())\n {\n nextWordId = child.ConvertToIdentifier();\n }\n }\n currentWordId = nextWordId;\n }\n if (message == \"\")\n {\n messageId.CreateStringWME(\"status\", \"error\");\n throw new IllegalStateException(\"Message was empty\");\n }\n message += \".\";\n ChatFrame.Singleton().addMessage(message.substring(0, message.length() - 1), ActionType.Agent);\n messageId.CreateStringWME(\"status\", \"complete\");\n }\n", "output": "\tprivate void processAgentMessageStringCommand(Identifier messageId){\n String message = \"\";\n WMElement wordsWME = messageId.FindByAttribute(\"first\", 0);\n if (wordsWME == null || !wordsWME.IsIdentifier())\n {\n messageId.CreateStringWME(\"status\", \"error\");\n throw new IllegalStateException(\"Message has no first attribute\");\n }\n Identifier currentWordId = wordsWME.ConvertToIdentifier();\n while (currentWordId != null)\n {\n Identifier nextWordId = null;\n for (int i = 0; i < currentWordId.GetNumberChildren(); i++)\n {\n WMElement child = currentWordId.GetChild(i);\n if (child.GetAttribute().equals(\"value\"))\n {\n message += child.GetValueAsString()+ \" \";\n }\n else if (child.GetAttribute().equals(\"next\")\n && child.IsIdentifier())\n {\n nextWordId = child.ConvertToIdentifier();\n }\n }\n currentWordId = nextWordId;\n }\n if (message == \"\")\n {\n messageId.CreateStringWME(\"status\", \"error\");\n throw new IllegalStateException(\"Message was empty\");\n }\n message += \".\";\n ChatFrame.Singleton().addMessage(message.substring(0, message.length() - 1), ActionType.Agent);\n messageId.CreateStringWME(\"status\", \"complete\");\n }\n"} {"input": "\tpublic void generate(Random random, int chunkX, int chunkZ, World world,\n\t\t\t\tIChunkProvider chunkGenerator, IChunkProvider chunkProvider) {\n\t\tBiomeGenBase b = world.getBiomeGenForCoords(chunkX*16, chunkZ*16);\n\t\tint randDefault = -1; \n\t\tint yHeightBase = 0;\n\t\tif(b.biomeName.equals(\"Ocean\")) {\n\t\t\tyHeightBase = 40; \n\t\t\trandDefault = 20; \n\t\t} else if(b.biomeName.equals(\"Ice Mountains\")||b.biomeName.equals(\"Extreme Hills\")) {\n\t\t\tyHeightBase = 130;\n\t\t\trandDefault = 30; \n\t\t}\n\t\tRandom randGenny = new Random();\n\t\tint randChance = randGenny.nextInt(randDefault); \n\t\tif(randChance < 1 && randChance > -1) {\n\t\t\tint yHeight = yHeightBase - randGenny.nextInt(20);\n\t\t\tint yBase = 10 + randGenny.nextInt(20);\n\t\t\twhile(yHeight > yBase) {\n\t\t\t\tworld.setBlock(chunkX*16 + 8, yHeight, chunkZ*16 + 8, Block.lavaStill.blockID);\n\t\t\t\tyHeight-=1;\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void generate(Random random, int chunkX, int chunkZ, World world,\n\t\t\t\tIChunkProvider chunkGenerator, IChunkProvider chunkProvider) {\n\t\tBiomeGenBase b = world.getBiomeGenForCoords(chunkX*16, chunkZ*16);\n\t\tint randDefault = 0; \n\t\tint yHeightBase = 0;\n\t\tif(b.biomeName.equals(\"Ocean\")) {\n\t\t\tRandom randGenny = new Random();\n\t\t\tint randChance = randGenny.nextInt(80); \n\t\t\tint xBase = 0;\n\t\t\tif(randChance < 1) {\n\t\t\t\tint yHeight = 80 - randGenny.nextInt(20);\n\t\t\t\tint yBase = 10 + randGenny.nextInt(20);\n\t\t\t\twhile(yHeight > yBase) {\n\t\t\t\t\tworld.setBlock(chunkX*16 + 8, yHeight, chunkZ*16 + 8, Block.lavaStill.blockID);\n\t\t\t\t\tyHeight-=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(b.biomeName.equals(\"Ice Mountains\")||b.biomeName.equals(\"Extreme Hills\")) {\n\t\t\tRandom randGenny = new Random();\n\t\t\tint randChance = randGenny.nextInt(80); \n\t\t\tif(randChance < 1) {\n\t\t\t\tint yHeight = 140 - randGenny.nextInt(20);\n\t\t\t\tint yBase = 10 + randGenny.nextInt(20);\n\t\t\t\twhile(yHeight > yBase) {\n\t\t\t\t\tworld.setBlock(chunkX*16 + 8, yHeight, chunkZ*16 + 8, Block.lavaStill.blockID);\n\t\t\t\t\tyHeight-=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " private void doRendering() {\n mFramesDone++;\n mCanRender = false;\n if (webglCheck() == 1) {\n mNumVertices = 0;\n String label = \"\";\n int vertexStyle;\n int edgeStyle;\n double edgeThickness = 6;\n float[] highlightColour = DrawingConstants.YELLOW;\n if(mZoom <= EDGE_ZOOM_LIMIT) edgeThickness = edgeThickness*mZoom; \n mVerticesList.clear();\n mIndicesList.clear();\n mColorsList.clear();\n if (!mWebglReady)\n setUpWebGL();\n for (EdgeDrawable thisEdge : mEdgesToDraw) {\n mCurrentPolygon = thisEdge.getPolygon();\n double startX = (thisEdge.getStartX() + mOffsetX) * mZoom;\n double startY = (thisEdge.getStartY() + mOffsetY) * mZoom;\n double endX = (thisEdge.getEndX() + mOffsetX) * mZoom;\n double endY = (thisEdge.getEndY() + mOffsetY) * mZoom;\n int weight = thisEdge.getWeight();\n float[] edgeColour = DrawingConstants.BLACK;\n float[] textColour = DrawingConstants.BLACK;\n int strokeThickness = 4;\n edgeStyle = 100;\n if (thisEdge.isHilighted()){\n edgeStyle = -edgeStyle;\n edgeColour = DrawingConstants.YELLOW;\n }\n if(thisEdge.needsToFromArrow()){\n if (thisEdge.isHilighted()){\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", highlightColour, textColour);\n addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,\"\", edgeColour, textColour);\n }else{\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", edgeColour, textColour);\n }\n } else if(thisEdge.needsToFromArrow()){\n if (thisEdge.isHilighted()){\n addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", highlightColour, textColour);\n addEdge(endX, endY, startX, startY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,\"\", edgeColour, textColour);\n }else{\n addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", edgeColour, textColour);\n }\n } else {\n if (thisEdge.isHilighted()){\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", highlightColour, textColour);\n addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,\"\", edgeColour, textColour);\n }else{\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", edgeColour, textColour);\n }\n }\n }\n if (mShowUILine) {\n addEdge((mUIline[0]+ mOffsetX)*mZoom, (mUIline[1]+ mOffsetY)*mZoom, \n (mUIline[2]+ mOffsetX)*mZoom, (mUIline[3]+ mOffsetY)*mZoom,\n edgeThickness, true,false,edgeThickness*5,edgeThickness*5,\"\", DrawingConstants.GREY, DrawingConstants.BLACK);\n }\n for (VertexDrawable thisVertex : mVerticesToDraw) {\n mNumVertices++;\n double centreX = (thisVertex.getCenterX() + mOffsetX) * mZoom;\n double centreY = (thisVertex.getCenterY() + mOffsetY) * mZoom;\n double width = (thisVertex.getWidth()) * mZoom;\n double height = (thisVertex.getHeight()) * mZoom;\n label = thisVertex.getLabel();\n vertexStyle = thisVertex.getStyle();\n float[] customColor = { 0, 0, 0, 1};\n switch (vertexStyle) {\n case VertexDrawable.STROKED_TERM_STYLE:\n if (thisVertex.isHilighted()) {\n addTerm(centreX, centreY,width,height, DrawingConstants.YELLOW);\n addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n } else {\n addTerm(centreX, centreY,width,height, DrawingConstants.BLACK);\n addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n }\n addStringBox(centreX, centreY, width-height,height, label, DrawingConstants.BLACK);\n break;\n case VertexDrawable.STROKED_SQUARE_STYLE:\n if (thisVertex.isHilighted()) {\n addSquare(centreX, centreY,width,height, DrawingConstants.YELLOW);\n addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n } else {\n addSquare(centreX, centreY,width,height, DrawingConstants.BLACK);\n addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n }\n addStringBox(centreX, centreY, width,height, label, DrawingConstants.BLACK);\n break;\n case VertexDrawable.STROKED_DIAMOND_STYLE:\n if (thisVertex.isHilighted()) {\n addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,\n 2,DrawingConstants.YELLOW);\n } else {\n addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,\n 2,DrawingConstants.BLACK);\n }\n addStringCircle(centreX, centreY, width/2, label, DrawingConstants.BLACK);\n break;\n case VertexDrawable.COLORED_FILLED_CIRCLE:\n customColor = thisVertex.getColor();\n addCircle(centreX, centreY, width, customColor);\n break; \n default:\n if (thisVertex.isHilighted()) {\n addCircle(centreX, centreY, width, highlightColour);\n addCircle(centreX, centreY, width - 4, DrawingConstants.YELLOW);\n } else {\n addCircle(centreX, centreY, width, DrawingConstants.BLACK);\n }\n break;\n }\n }\n renderGraph();\n mCanRender = true;\n } else {\n renderGraph2d(m2dCanvas, mEdgesToDraw, mVerticesToDraw);\n }\n }\n", "output": " private void doRendering() {\n mFramesDone++;\n mCanRender = false;\n if (webglCheck() == 1) {\n mNumVertices = 0;\n String label = \"\";\n int vertexStyle;\n int edgeStyle;\n double edgeThickness = 6;\n float[] highlightColour = DrawingConstants.YELLOW;\n if(mZoom <= EDGE_ZOOM_LIMIT) edgeThickness = edgeThickness*mZoom; \n mVerticesList.clear();\n mIndicesList.clear();\n mColorsList.clear();\n if (!mWebglReady)\n setUpWebGL();\n for (EdgeDrawable thisEdge : mEdgesToDraw) {\n mCurrentPolygon = thisEdge.getPolygon();\n double startX = (thisEdge.getStartX() + mOffsetX) * mZoom;\n double startY = (thisEdge.getStartY() + mOffsetY) * mZoom;\n double endX = (thisEdge.getEndX() + mOffsetX) * mZoom;\n double endY = (thisEdge.getEndY() + mOffsetY) * mZoom;\n int weight = thisEdge.getWeight();\n float[] edgeColour = DrawingConstants.BLACK;\n float[] textColour = DrawingConstants.BLACK;\n int strokeThickness = 4;\n edgeStyle = 100;\n if (thisEdge.isHilighted()){\n edgeStyle = -edgeStyle;\n edgeColour = DrawingConstants.YELLOW;\n }\n if(thisEdge.needsToFromArrow()){\n if (thisEdge.isHilighted()){\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", highlightColour, textColour);\n addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,\"\", highlightColour, textColour);\n }else{\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", edgeColour, textColour);\n }\n } else if(thisEdge.needsToFromArrow()){\n if (thisEdge.isHilighted()){\n addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", highlightColour, textColour);\n addEdge(endX, endY, startX, startY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,\"\", highlightColour, textColour);\n }else{\n addEdge(endX, endY, startX, startY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", edgeColour, textColour);\n }\n } else {\n if (thisEdge.isHilighted()){\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", highlightColour, textColour);\n addEdge(startX, startY, endX, endY, edgeThickness-strokeThickness, false,false,(edgeThickness*5)-strokeThickness,0,\"\", highlightColour, textColour);\n }else{\n addEdge(startX, startY, endX, endY, edgeThickness, true,true,(edgeThickness*5),(edgeThickness*5),weight+\"\", edgeColour, textColour);\n }\n }\n }\n if (mShowUILine) {\n addEdge((mUIline[0]+ mOffsetX)*mZoom, (mUIline[1]+ mOffsetY)*mZoom, \n (mUIline[2]+ mOffsetX)*mZoom, (mUIline[3]+ mOffsetY)*mZoom,\n edgeThickness, true,false,edgeThickness*5,edgeThickness*5,\"\", DrawingConstants.GREY, DrawingConstants.BLACK);\n }\n for (VertexDrawable thisVertex : mVerticesToDraw) {\n mNumVertices++;\n double centreX = (thisVertex.getCenterX() + mOffsetX) * mZoom;\n double centreY = (thisVertex.getCenterY() + mOffsetY) * mZoom;\n double width = (thisVertex.getWidth()) * mZoom;\n double height = (thisVertex.getHeight()) * mZoom;\n label = thisVertex.getLabel();\n vertexStyle = thisVertex.getStyle();\n float[] customColor = { 0, 0, 0, 1};\n switch (vertexStyle) {\n case VertexDrawable.STROKED_TERM_STYLE:\n if (thisVertex.isHilighted()) {\n addTerm(centreX, centreY,width,height, DrawingConstants.YELLOW);\n addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n } else {\n addTerm(centreX, centreY,width,height, DrawingConstants.BLACK);\n addTerm(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n }\n addStringBox(centreX, centreY, width-height,height, label, DrawingConstants.BLACK);\n break;\n case VertexDrawable.STROKED_SQUARE_STYLE:\n if (thisVertex.isHilighted()) {\n addSquare(centreX, centreY,width,height, DrawingConstants.YELLOW);\n addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n } else {\n addSquare(centreX, centreY,width,height, DrawingConstants.BLACK);\n addSquare(centreX, centreY,width-4,height-4, DrawingConstants.GREY);\n }\n addStringBox(centreX, centreY, width,height, label, DrawingConstants.BLACK);\n break;\n case VertexDrawable.STROKED_DIAMOND_STYLE:\n if (thisVertex.isHilighted()) {\n addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,\n 2,DrawingConstants.YELLOW);\n } else {\n addDiamondStroke(centreX, centreY, width,height,DrawingConstants.GREY,\n 2,DrawingConstants.BLACK);\n }\n addStringCircle(centreX, centreY, width/2, label, DrawingConstants.BLACK);\n break;\n case VertexDrawable.COLORED_FILLED_CIRCLE:\n customColor = thisVertex.getColor();\n addCircle(centreX, centreY, width, customColor);\n break; \n default:\n if (thisVertex.isHilighted()) {\n addCircle(centreX, centreY, width, highlightColour);\n addCircle(centreX, centreY, width - 4, highlightColour);\n } else {\n addCircle(centreX, centreY, width, DrawingConstants.BLACK);\n }\n break;\n }\n }\n renderGraph();\n mCanRender = true;\n } else {\n renderGraph2d(m2dCanvas, mEdgesToDraw, mVerticesToDraw);\n }\n }\n"} {"input": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_stop_map);\n\t\tIntent i = getIntent();\n\t\tString sLocation = i.getStringExtra(\"location\");\n\t\tif(sLocation != null && sLocation != \"\"){\n\t\t\tLog.e(\"debug\", \"http://deco3801-005.uqcloud.net/stops-from-location/?location=\" +sLocation);\n\t\t\tnew StopRequest().execute(\"http://deco3801-005.uqcloud.net/stops-from-location/?location=\" +sLocation);\n\t\t}\n\t\telse if(servicesConnected()){\n\t\t\tmLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);\n\t mLocationManager.requestLocationUpdates(mLocationManager.getBestProvider(new Criteria(), true),\n\t \t\t0, 0, this);\n\t currentLocation = mLocationManager.getLastKnownLocation(mLocationManager.\n\t \t\tgetBestProvider(new Criteria(), true));\n\t if(currentLocation != null && currentLocation.getTime() > Calendar.getInstance().\n\t \t\tgetTimeInMillis() - 2 * 60 * 1000) {\n\t \tGeocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault());\n\t\t\t\tString address;\n\t\t\t\ttry {\n\t\t\t\t\taddress = gcd.getFromLocation(currentLocation.getLatitude(), \n\t\t\t\t\t\t\tcurrentLocation.getLongitude(), 1).get(0).getLocality();\n\t\t\t\t\tLog.e(\"DEBUG\", address);\n\t\t\t\t\tnew StopRequest().execute(\"http://deco3801-005.uqcloud.net/stops-from-location/?location=\" +address);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tmLocationManager.removeUpdates(this);\n\t }\n\t\t}\n\t\tsetUpMap( null);\n\t}\n", "output": "\tprotected void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.activity_stop_map);\n\t\tIntent i = getIntent();\n\t\tString sLocation = i.getStringExtra(\"location\");\n\t\tif(sLocation != null && sLocation.length() != 0){\n\t\t\tLog.e(\"debug\", sLocation +\"derp\");\n\t\t\tnew StopRequest().execute(\"http://deco3801-005.uqcloud.net/stops-from-location/?location=\" +sLocation);\n\t\t}\n\t\telse if(servicesConnected()){\n\t\t\tmLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);\n\t mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,\n\t \t\t0, 0, this);\n\t currentLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);\n\t if(currentLocation != null && currentLocation.getTime() > Calendar.getInstance().\n\t \t\tgetTimeInMillis() - 2 * 60 * 1000) {\n\t \tGeocoder gcd = new Geocoder(getBaseContext(), Locale.getDefault());\n\t\t\t\tString address;\n\t\t\t\ttry {\n\t\t\t\t\taddress = gcd.getFromLocation(currentLocation.getLatitude(), \n\t\t\t\t\t\t\tcurrentLocation.getLongitude(), 1).get(0).getLocality();\n\t\t\t\t\tLog.e(\"DEBUG\", address);\n\t\t\t\t\tnew StopRequest().execute(\"http://deco3801-005.uqcloud.net/stops-from-location/?location=\" +address);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tmLocationManager.removeUpdates(this);\n\t }\n\t\t}\n\t\tsetUpMap( null);\n\t}\n"} {"input": "public static void main(String[] args) {\n {\n room();\n double x=0.35;\n double y=.051;\n player(x,y);\n double x_neu;\n double y_neu;\n double i=0.5;\n double j=0.5;\n double k=0.7;\n double l=0.2;\n double n=0.1;\n double m=0.82;\n Falle1(i,j);\n Falle2(k,l);\n double i_neu;\n double j_neu;\n double k_neu;\n double l_neu;\n double n_neu;\n double m_neu;\n int p_1 =1;\n int p_2 =1;\n int p_3 =1;\n while (x>=0.001 && x<=1 )\n {\t\n \tStdDraw.show(0);\n StdDraw.setPenRadius(.06);\n StdDraw.setPenColor(Color.WHITE);\n StdDraw.filledSquare(i, j, 0.02);\n StdDraw.filledSquare(k, l, 0.02);\n StdDraw.filledSquare(n, m, 0.02);\n \tif(i<0.97 && j<0.97 && p_1==1){\n \t\ti_neu=i+0.001;\n \t\tj_neu=j+0.001;\n \t\ti=i_neu;\n \t\tj=j_neu;\n \t\t}\n \telse if((i>0.03 || j>0.03) &&p_1==0) { \t\n \t\ti_neu=i-0.001;\n \t\tj_neu=j-0.001;\n \t\ti=i_neu;\n \t\tj=j_neu;\n \t\t}\n \telse {\n \t\tif (p_1==1){\n \t\t\tp_1=0;}\n \t\telse {\n \t\t\tp_1=1;}\n \t\t\t}\n \tFalle1(i,j);\n \tif(k<0.96 && l<0.97 && p_2==1){\n \t\tk_neu=k+0.001;\n \t\tl_neu=l+0.001;\n \t\tk=k_neu;\n \t\tl=l_neu;\n \t\t}\n \telse if(k<0.97 && l<0.97 && p_2==2){\n \t\t\tk_neu=k-0.001;\n \t\t\tl_neu=l+0.001;\n \t\t\tk=k_neu;\n \t\t\tl=l_neu;\n \t\t}\n \telse if(k>0.03 && l>0.03 &&p_2==3) { \t\n \t\tk_neu=k-0.001;\n \t\tl_neu=l-0.001;\n \t\tk=k_neu;\n \t\tl=l_neu;\n \t\t}\n \telse if(k>0.02 && l>0.03 &&p_2==0) { \t\n \t\tk_neu=k+0.001;\n \t\tl_neu=l-0.001;\n \t\tk=k_neu;\n \t\tl=l_neu;\n \t\t}\n \telse {\n \t\tif (p_2==1){\n \t\t\tp_2=2;}\n \t\telse if(p_2==2) {\n \t\t\tp_2=3;}\n \t\telse if (p_2==3){\n \t\t\tp_2=0;}\n \t\telse{\n \t\t\tp_2=1;}\n \t\t}\n \tFalle2(k,l); \n \tif(n<0.97 && m<0.97 && p_3==1){\n \t\tn_neu=n+0.001;\n \t\tm_neu=3*n_neu*n_neu-3*n_neu+1;\n \t\tn=n_neu;\n \t\tm=m_neu;\n \t\t}\n \telse if(n>0.03 && m>0.03 &&p_3==0) { \t\n \t\tn_neu=n-0.001;\n \t\tm_neu=3*n_neu*n_neu-3*n_neu+1;\n \t\tn=n_neu;\n \t\tm=m_neu;\n \t\t}\n \telse {\n \t\tif (p_3==1){\n \t\t\tp_3=0;}\n \t\telse {\n \t\t\tp_3=1;}\n \t\t\t}\n \tFalle3(n,m); \n \t\tStdDraw.setPenRadius(.06);\n \t\tStdDraw.setPenColor(Color.WHITE);\n if (StdDraw.isKeyPressed(KeyEvent.VK_LEFT)) \n {\n x_neu = x-0.001;\n y_neu=y;\n if (x_neu <= 0.05 || y_neu>=0.95){ \n \tx_neu=x;\t\t\t}\n else\n {\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n else if (StdDraw.isKeyPressed(KeyEvent.VK_RIGHT)) \n {\n x_neu = x+0.001;\n y_neu = y;\n if (x_neu >= 0.95|| y_neu>=0.95) \n { x_neu=x; \n } \n else{\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n else if (StdDraw.isKeyPressed(KeyEvent.VK_UP)) \n {\t\n x_neu = x;\n y_neu = y+0.001;\n if (y_neu>=0.95) \n {\t\n \tif(x_neu> 0.3 && x_neu< 0.4 &&y_neu<=0.05|| x_neu>0.7 && x_neu< 0.8){\n \t\tStdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n else{\n y_neu=y;}\n } \n else{\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n else if (StdDraw.isKeyPressed(KeyEvent.VK_DOWN)) \n {\t\n x_neu = x;\n y_neu = y-0.001;\n if (y_neu<=0.05||y_neu>=0.95) \n {\n y_neu=y;\n } else{\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n if ((x<=i+0.04 && x>=i-0.04 && y<=j+0.04 && y>=j-0.04)|| x<=k+0.04 && x>=k-0.04 && y<=l+0.04 && y>=l-0.04 || x<=n+0.04 && x>=n-0.04 && y<=m+0.04 && y>=m-0.04)\n {\n \t \tStdDraw.clear();\n Menue.main(args);\n break;\n }\n if (y>1)\n {\n \t Level3.main(args);\n \t break;\n }\n }\n }\n}\n", "output": "public static void main(String[] args) {\n {\n room();\n double x=0.35;\n double y=.051;\n player(x,y);\n double x_neu;\n double y_neu;\n double i=0.5;\n double j=0.5;\n double k=0.7;\n double l=0.2;\n double n=0.1;\n double m=0.82;\n Falle1(i,j);\n Falle2(k,l);\n double i_neu;\n double j_neu;\n double k_neu;\n double l_neu;\n double n_neu;\n double m_neu;\n int p_1 =1;\n int p_2 =1;\n int p_3 =1;\n while (x>=0.001 && x<=1 )\n {\t\n \tStdDraw.show(1);\n StdDraw.setPenRadius(.06);\n StdDraw.setPenColor(Color.WHITE);\n StdDraw.filledSquare(i, j, 0.02);\n StdDraw.filledSquare(k, l, 0.02);\n StdDraw.filledSquare(n, m, 0.02);\n \tif(i<0.97 && j<0.97 && p_1==1){\n \t\ti_neu=i+0.001;\n \t\tj_neu=j+0.001;\n \t\ti=i_neu;\n \t\tj=j_neu;\n \t\t}\n \telse if((i>0.03 || j>0.03) &&p_1==0) { \t\n \t\ti_neu=i-0.001;\n \t\tj_neu=j-0.001;\n \t\ti=i_neu;\n \t\tj=j_neu;\n \t\t}\n \telse {\n \t\tif (p_1==1){\n \t\t\tp_1=0;}\n \t\telse {\n \t\t\tp_1=1;}\n \t\t\t}\n \tFalle1(i,j);\n \tif(k<0.96 && l<0.97 && p_2==1){\n \t\tk_neu=k+0.001;\n \t\tl_neu=l+0.001;\n \t\tk=k_neu;\n \t\tl=l_neu;\n \t\t}\n \telse if(k<0.97 && l<0.97 && p_2==2){\n \t\t\tk_neu=k-0.001;\n \t\t\tl_neu=l+0.001;\n \t\t\tk=k_neu;\n \t\t\tl=l_neu;\n \t\t}\n \telse if(k>0.03 && l>0.03 &&p_2==3) { \t\n \t\tk_neu=k-0.001;\n \t\tl_neu=l-0.001;\n \t\tk=k_neu;\n \t\tl=l_neu;\n \t\t}\n \telse if(k>0.02 && l>0.03 &&p_2==0) { \t\n \t\tk_neu=k+0.001;\n \t\tl_neu=l-0.001;\n \t\tk=k_neu;\n \t\tl=l_neu;\n \t\t}\n \telse {\n \t\tif (p_2==1){\n \t\t\tp_2=2;}\n \t\telse if(p_2==2) {\n \t\t\tp_2=3;}\n \t\telse if (p_2==3){\n \t\t\tp_2=0;}\n \t\telse{\n \t\t\tp_2=1;}\n \t\t}\n \tFalle2(k,l); \n \tif(n<0.97 && m<0.97 && p_3==1){\n \t\tn_neu=n+0.001;\n \t\tm_neu=3*n_neu*n_neu-3*n_neu+1;\n \t\tn=n_neu;\n \t\tm=m_neu;\n \t\t}\n \telse if(n>0.03 && m>0.03 &&p_3==0) { \t\n \t\tn_neu=n-0.001;\n \t\tm_neu=3*n_neu*n_neu-3*n_neu+1;\n \t\tn=n_neu;\n \t\tm=m_neu;\n \t\t}\n \telse {\n \t\tif (p_3==1){\n \t\t\tp_3=0;}\n \t\telse {\n \t\t\tp_3=1;}\n \t\t\t}\n \tFalle3(n,m); \n \t\tStdDraw.setPenRadius(.06);\n \t\tStdDraw.setPenColor(Color.WHITE);\n if (StdDraw.isKeyPressed(KeyEvent.VK_LEFT)) \n {\n x_neu = x-0.001;\n y_neu=y;\n if (x_neu <= 0.05 || y_neu>=0.95){ \n \tx_neu=x;\t\t\t}\n else\n {\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n else if (StdDraw.isKeyPressed(KeyEvent.VK_RIGHT)) \n {\n x_neu = x+0.001;\n y_neu = y;\n if (x_neu >= 0.95|| y_neu>=0.95) \n { x_neu=x; \n } \n else{\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n else if (StdDraw.isKeyPressed(KeyEvent.VK_UP)) \n {\t\n x_neu = x;\n y_neu = y+0.001;\n if (y_neu>=0.95) \n {\t\n \tif(x_neu> 0.3 && x_neu< 0.4 &&y_neu<=0.05|| x_neu>0.7 && x_neu< 0.8){\n \t\tStdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n else{\n y_neu=y;}\n } \n else{\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n else if (StdDraw.isKeyPressed(KeyEvent.VK_DOWN)) \n {\t\n x_neu = x;\n y_neu = y-0.001;\n if (y_neu<=0.05||y_neu>=0.95) \n {\n y_neu=y;\n } else{\n StdDraw.point(x, y);\n x=x_neu;\n y=y_neu;\n player(x,y);\n }\n }\n if ((x<=i+0.04 && x>=i-0.04 && y<=j+0.04 && y>=j-0.04)|| x<=k+0.04 && x>=k-0.04 && y<=l+0.04 && y>=l-0.04 || x<=n+0.04 && x>=n-0.04 && y<=m+0.04 && y>=m-0.04)\n {\n \t \tStdDraw.clear();\n Menue.main(args);\n break;\n }\n if (y>1)\n {\n \t Level3.main(args);\n \t break;\n }\n }\n }\n}\n"} {"input": "\tpublic JSONRPCResponseObject sendAndReceive(JSONRPCRequestObject message)\n\tthrows JSONException, SaploClientException {\n\t\tHttpPost httpost = new HttpPost(uri+\"?\"+params);\n\t\tByteArrayEntity ent = new ByteArrayEntity(message.toString().getBytes());\n\t\tent.setContentEncoding(HTTP.UTF_8);\n\t\tent.setContentType(\"application/x-www-form-urlencoded\");\n\t\thttpost.setEntity(ent);\n\t\tDefaultHttpClient httpClient = new DefaultHttpClient();\n\t\ttry {\n\t\t\tif(proxified)\n\t\t\t\thttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);\n\t\t\tHttpResponse response = httpClient.execute(httpost);\n\t\t\tHttpEntity entity = response.getEntity();\n\t\t\tint statusCode = response.getStatusLine().getStatusCode();\n\t\t\tif (statusCode != HttpStatus.SC_OK)\n\t\t\t\tthrow new SaploClientException(ResponseCodes.MSG_API_DOWN_EXCEPTION, ResponseCodes.CODE_API_DOWN_EXCEPTION, statusCode);\n\t\t\tString got = \"\";\n\t\t\tif (entity != null) {\n\t\t\t\tbyte[] bytes = EntityUtils.toByteArray(entity);\n\t\t\t\tgot = new String(bytes, Charset.forName(\"UTF-8\"));\n\t\t\t}\n\t\t\tJSONTokener tokener = new JSONTokener(got);\n\t\t\tObject rawResponseMessage = tokener.nextValue();\n\t\t\tJSONObject responseMessage = (JSONObject) rawResponseMessage;\n\t\t\tif (responseMessage == null)\n\t\t\t\tthrow new ClientError(\"Invalid response type - \" + rawResponseMessage);\n\t\t\treturn new JSONRPCResponseObject(responseMessage);\n\t\t} catch (ClientProtocolException e) {\n\t\t\tthrow new ClientError(e);\n\t\t} catch (NoHttpResponseException nr) {\n\t\t\tthrow new SaploClientException(ResponseCodes.MSG_API_DOWN_EXCEPTION, ResponseCodes.CODE_API_DOWN_EXCEPTION, 777);\n\t\t} catch (IOException e) {\n\t\t\tthrow new ClientError(e);\n\t\t} finally {\n\t\t\thttpClient.getConnectionManager().shutdown();\n\t\t}\n\t}\n", "output": "\tpublic JSONRPCResponseObject sendAndReceive(JSONRPCRequestObject message)\n\tthrows JSONException, SaploClientException {\n\t\tHttpPost httpost = new HttpPost(uri+\"?\"+params);\n\t\tByteArrayEntity ent = new ByteArrayEntity(message.toString().getBytes(Charset.forName(\"UTF-8\")));\n\t\tent.setContentEncoding(HTTP.UTF_8);\n\t\tent.setContentType(\"application/x-www-form-urlencoded\");\n\t\thttpost.setEntity(ent);\n\t\tDefaultHttpClient httpClient = new DefaultHttpClient();\n\t\ttry {\n\t\t\tif(proxified)\n\t\t\t\thttpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);\n\t\t\tHttpResponse response = httpClient.execute(httpost);\n\t\t\tHttpEntity entity = response.getEntity();\n\t\t\tint statusCode = response.getStatusLine().getStatusCode();\n\t\t\tif (statusCode != HttpStatus.SC_OK)\n\t\t\t\tthrow new SaploClientException(ResponseCodes.MSG_API_DOWN_EXCEPTION, ResponseCodes.CODE_API_DOWN_EXCEPTION, statusCode);\n\t\t\tString got = \"\";\n\t\t\tif (entity != null) {\n\t\t\t\tbyte[] bytes = EntityUtils.toByteArray(entity);\n\t\t\t\tgot = new String(bytes, Charset.forName(\"UTF-8\"));\n\t\t\t}\n\t\t\tJSONTokener tokener = new JSONTokener(got);\n\t\t\tObject rawResponseMessage = tokener.nextValue();\n\t\t\tJSONObject responseMessage = (JSONObject) rawResponseMessage;\n\t\t\tif (responseMessage == null)\n\t\t\t\tthrow new ClientError(\"Invalid response type - \" + rawResponseMessage);\n\t\t\treturn new JSONRPCResponseObject(responseMessage);\n\t\t} catch (ClientProtocolException e) {\n\t\t\tthrow new ClientError(e);\n\t\t} catch (NoHttpResponseException nr) {\n\t\t\tthrow new SaploClientException(ResponseCodes.MSG_API_DOWN_EXCEPTION, ResponseCodes.CODE_API_DOWN_EXCEPTION, 777);\n\t\t} catch (IOException e) {\n\t\t\tthrow new ClientError(e);\n\t\t} finally {\n\t\t\thttpClient.getConnectionManager().shutdown();\n\t\t}\n\t}\n"} {"input": "\tprotected void doPost(HttpServletRequest req, HttpServletResponse resp)\n\t\t\tthrows IOException, ServletException {\n\t\tif (!checkCsrf(req, resp))\n\t\t\treturn;\n\t\tMap<String, Exception> errors = new LoginValidator().validate(req);\n\t\tif (!errors.isEmpty()) {\n\t\t\tshowError(req, resp, errors);\n\t\t\treturn;\n\t\t}\n\t\tfinal String id = req.getParameter(\"id\").trim();\n\t\tfinal String password = req.getParameter(\"password\").trim();\n\t\tBoolean isCorrectPassword = false;\n\t\ttry {\n\t\t\tisCorrectPassword = Member.isCorrectPassword(id, password);\n\t\t} catch (DBAccessException e) {\n\t\t\terrors.put(\"DBAccess\", e);\n\t\t}\n\t\tif (!isCorrectPassword)\n\t\t\terrors.put(\"Login\", new Exception(\"ID\ufffd\ufffd\ufffdp\ufffdX\ufffd\ufffd\ufffd[\ufffdh\ufffd\ufffd\ufffd\u0642\u0202\ufffd\u0702\ufffd\ufffdB\"));\n\t\tif (!errors.isEmpty()) {\n\t\t\tshowError(req, resp, errors);\n\t\t\treturn;\n\t\t}\n\t\tHttpSession session = new SessionRepository().getSession(req, true);\n\t\tsession.setAttribute(\"memberId\", id);\n\t\tresp.sendRedirect(\"/\");\n\t}\n", "output": "\tprotected void doPost(HttpServletRequest req, HttpServletResponse resp)\n\t\t\tthrows IOException, ServletException {\n\t\tif (!checkCsrf(req, resp))\n\t\t\treturn;\n\t\tMap<String, Exception> errors = new LoginValidator().validate(req);\n\t\tif (!errors.isEmpty()) {\n\t\t\tshowError(req, resp, errors);\n\t\t\treturn;\n\t\t}\n\t\tfinal String id = req.getParameter(\"id\").trim();\n\t\tfinal String password = req.getParameter(\"password\").trim();\n\t\tBoolean isCorrectPassword = false;\n\t\ttry {\n\t\t\tisCorrectPassword = Member.isCorrectPassword(id, password);\n\t\t} catch (DBAccessException e) {\n\t\t\terrors.put(\"DBAccess\", e);\n\t\t}\n\t\tif (!isCorrectPassword)\n\t\t\terrors.put(\"Login\", new Exception(\"ID\u304b\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u7570\u306a\u308a\u307e\u3059\u3002\"));\n\t\tif (!errors.isEmpty()) {\n\t\t\tshowError(req, resp, errors);\n\t\t\treturn;\n\t\t}\n\t\tHttpSession session = new SessionRepository().getSession(req, true);\n\t\tsession.setAttribute(\"memberId\", id);\n\t\tresp.sendRedirect(\"/\");\n\t}\n"} {"input": " private PluginJavaConfig createPluginConfig(final String bundleTestResourcePath, final String fileName) {\n return new PluginJavaConfig() {\n @Override\n public String getBundleJarPath() {\n return bundleTestResourcePath;\n }\n @Override\n public String getPluginName() {\n return bundleName;\n }\n @Override\n public PluginType getPluginType() {\n return PluginType.PAYMENT;\n }\n @Override\n public String getVersion() {\n return killbillVersion;\n }\n @Override\n public String getPluginVersionnedName() {\n return bundleName + \"-\" + killbillVersion;\n }\n @Override\n public File getPluginVersionRoot() {\n final StringBuilder tmp = new StringBuilder(config.getRootInstallationDir());\n tmp.append(\"/\")\n .append(PluginLanguage.JAVA.toString().toLowerCase())\n .append(\"/\")\n .append(bundleName)\n .append(\"/\")\n .append(killbillVersion);\n final File result = new File(tmp.toString());\n return result;\n }\n @Override\n public PluginLanguage getPluginLanguage() {\n return PluginLanguage.JAVA;\n }\n };\n }\n", "output": " private PluginJavaConfig createPluginConfig(final String bundleTestResourcePath, final String fileName) {\n return new PluginJavaConfig() {\n @Override\n public String getBundleJarPath() {\n return bundleTestResourcePath;\n }\n @Override\n public String getPluginName() {\n return bundleName;\n }\n @Override\n public PluginType getPluginType() {\n return PluginType.PAYMENT;\n }\n @Override\n public String getVersion() {\n return killbillVersion;\n }\n @Override\n public String getPluginVersionnedName() {\n return bundleName + \"-\" + killbillVersion;\n }\n @Override\n public File getPluginVersionRoot() {\n final StringBuilder tmp = new StringBuilder(config.getRootInstallationDir());\n tmp.append(\"/plugins/\")\n .append(PluginLanguage.JAVA.toString().toLowerCase())\n .append(\"/\")\n .append(bundleName)\n .append(\"/\")\n .append(killbillVersion);\n final File result = new File(tmp.toString());\n return result;\n }\n @Override\n public PluginLanguage getPluginLanguage() {\n return PluginLanguage.JAVA;\n }\n };\n }\n"} {"input": " protected void initFile(String id) throws FormatException, IOException {\n super.initFile(id);\n in = new RandomAccessInputStream(id);\n core[0].littleEndian = false;\n if (!in.readString(4).equals(\"8BPS\")) {\n throw new FormatException(\"Not a valid Photoshop file.\");\n }\n addGlobalMeta(\"Version\", in.readShort());\n in.skipBytes(6); \n core[0].sizeC = in.readShort();\n core[0].sizeY = in.readInt();\n core[0].sizeX = in.readInt();\n int bits = in.readShort();\n addGlobalMeta(\"Bits per pixel\", bits);\n core[0].pixelType = FormatTools.pixelTypeFromBytes(bits / 8, false, false);\n int colorMode = in.readShort();\n String modeString = null;\n switch (colorMode) {\n case 0:\n modeString = \"monochrome\";\n break;\n case 1:\n modeString = \"gray-scale\";\n break;\n case 2:\n modeString = \"palette color\";\n break;\n case 3:\n modeString = \"RGB\";\n break;\n case 4:\n modeString = \"CMYK\";\n break;\n case 6:\n modeString = \"Duotone\";\n break;\n case 7:\n modeString = \"Multichannel color\";\n break;\n case 8:\n modeString = \"Duotone\";\n break;\n case 9:\n modeString = \"LAB color\";\n break;\n }\n addGlobalMeta(\"Color mode\", modeString);\n int modeDataLength = in.readInt();\n long fp = in.getFilePointer();\n if (modeDataLength != 0) {\n if (colorMode == 2) {\n lut = new byte[3][256];\n for (int i=0; i<lut.length; i++) {\n in.read(lut[i]);\n }\n }\n in.seek(fp + modeDataLength);\n }\n in.skipBytes(4);\n while (in.readString(4).equals(\"8BIM\")) {\n int tag = in.readShort();\n int read = 1;\n while (in.read() != 0) read++;\n if (read % 2 == 1) in.skipBytes(1);\n int size = in.readInt();\n if (size % 2 == 1) size++;\n in.skipBytes(size);\n }\n in.seek(in.getFilePointer() - 4);\n int blockLen = in.readInt();\n if (blockLen == 0) {\n offset = in.getFilePointer();\n }\n else {\n int layerLen = in.readInt();\n int layerCount = in.readShort();\n if (layerCount < 0) {\n throw new FormatException(\"Vector data is not supported.\");\n }\n int[] w = new int[layerCount];\n int[] h = new int[layerCount];\n int[] c = new int[layerCount];\n for (int i=0; i<layerCount; i++) {\n int top = in.readInt();\n int left = in.readInt();\n int bottom = in.readInt();\n int right = in.readInt();\n w[i] = right - left;\n h[i] = bottom - top;\n c[i] = in.readShort();\n in.skipBytes(c[i] * 6 + 12);\n int len = in.readInt();\n if (len % 2 == 1) len++;\n in.skipBytes(len);\n }\n for (int i=0; i<layerCount; i++) {\n int[] lens = new int[h[i]];\n for (int cc=0; cc<c[i]; cc++) {\n boolean compressed = in.readShort() == 1;\n if (!compressed) in.skipBytes(w[i] * h[i]);\n else {\n for (int y=0; y<h[i]; y++) {\n lens[y] = in.readShort();\n }\n for (int y=0; y<h[i]; y++) {\n in.skipBytes(lens[y]);\n }\n }\n }\n }\n while (in.read() != '8');\n in.skipBytes(7);\n int len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n String s = in.readString(4);\n while (s.equals(\"8BIM\")) {\n in.skipBytes(4);\n len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n s = in.readString(4);\n }\n offset = in.getFilePointer() - 4;\n }\n core[0].sizeZ = 1;\n core[0].sizeT = 1;\n core[0].rgb = modeString.equals(\"RGB\");\n core[0].imageCount = getSizeC() / (isRGB() ? 3 : 1);\n core[0].indexed = modeString.equals(\"palette color\");\n core[0].falseColor = false;\n core[0].dimensionOrder = \"XYCZT\";\n core[0].interleaved = false;\n core[0].metadataComplete = true;\n MetadataStore store = makeFilterMetadata();\n MetadataTools.populatePixels(store, this);\n MetadataTools.setDefaultCreationDate(store, id, 0);\n }\n", "output": " protected void initFile(String id) throws FormatException, IOException {\n super.initFile(id);\n in = new RandomAccessInputStream(id);\n core[0].littleEndian = false;\n if (!in.readString(4).equals(\"8BPS\")) {\n throw new FormatException(\"Not a valid Photoshop file.\");\n }\n addGlobalMeta(\"Version\", in.readShort());\n in.skipBytes(6); \n core[0].sizeC = in.readShort();\n core[0].sizeY = in.readInt();\n core[0].sizeX = in.readInt();\n int bits = in.readShort();\n addGlobalMeta(\"Bits per pixel\", bits);\n core[0].pixelType = FormatTools.pixelTypeFromBytes(bits / 8, false, false);\n int colorMode = in.readShort();\n String modeString = null;\n switch (colorMode) {\n case 0:\n modeString = \"monochrome\";\n break;\n case 1:\n modeString = \"gray-scale\";\n break;\n case 2:\n modeString = \"palette color\";\n break;\n case 3:\n modeString = \"RGB\";\n break;\n case 4:\n modeString = \"CMYK\";\n break;\n case 6:\n modeString = \"Duotone\";\n break;\n case 7:\n modeString = \"Multichannel color\";\n break;\n case 8:\n modeString = \"Duotone\";\n break;\n case 9:\n modeString = \"LAB color\";\n break;\n }\n addGlobalMeta(\"Color mode\", modeString);\n int modeDataLength = in.readInt();\n long fp = in.getFilePointer();\n if (modeDataLength != 0) {\n if (colorMode == 2) {\n lut = new byte[3][256];\n for (int i=0; i<lut.length; i++) {\n in.read(lut[i]);\n }\n }\n in.seek(fp + modeDataLength);\n }\n in.skipBytes(4);\n while (in.readString(4).equals(\"8BIM\")) {\n int tag = in.readShort();\n int read = 1;\n while (in.read() != 0) read++;\n if (read % 2 == 1) in.skipBytes(1);\n int size = in.readInt();\n if (size % 2 == 1) size++;\n in.skipBytes(size);\n }\n in.seek(in.getFilePointer() - 4);\n int blockLen = in.readInt();\n if (blockLen == 0) {\n offset = in.getFilePointer();\n }\n else {\n int layerLen = in.readInt();\n int layerCount = in.readShort();\n if (layerCount < 0) {\n throw new FormatException(\"Vector data is not supported.\");\n }\n int[] w = new int[layerCount];\n int[] h = new int[layerCount];\n int[] c = new int[layerCount];\n for (int i=0; i<layerCount; i++) {\n int top = in.readInt();\n int left = in.readInt();\n int bottom = in.readInt();\n int right = in.readInt();\n w[i] = right - left;\n h[i] = bottom - top;\n c[i] = in.readShort();\n in.skipBytes(c[i] * 6 + 12);\n int len = in.readInt();\n if (len % 2 == 1) len++;\n in.skipBytes(len);\n }\n for (int i=0; i<layerCount; i++) {\n int[] lens = new int[h[i]];\n for (int cc=0; cc<c[i]; cc++) {\n boolean compressed = in.readShort() == 1;\n if (!compressed) in.skipBytes(w[i] * h[i]);\n else {\n for (int y=0; y<h[i]; y++) {\n lens[y] = in.readShort();\n }\n for (int y=0; y<h[i]; y++) {\n in.skipBytes(lens[y]);\n }\n }\n }\n }\n long start = in.getFilePointer();\n while (in.read() != '8');\n in.skipBytes(7);\n if (in.getFilePointer() - start > 1024) {\n in.seek(start);\n }\n int len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n String s = in.readString(4);\n while (s.equals(\"8BIM\")) {\n in.skipBytes(4);\n len = in.readInt();\n if ((len % 4) != 0) len += 4 - (len % 4);\n in.skipBytes(len);\n s = in.readString(4);\n }\n offset = in.getFilePointer() - 4;\n }\n core[0].sizeZ = 1;\n core[0].sizeT = 1;\n core[0].rgb = modeString.equals(\"RGB\");\n core[0].imageCount = getSizeC() / (isRGB() ? 3 : 1);\n core[0].indexed = modeString.equals(\"palette color\");\n core[0].falseColor = false;\n core[0].dimensionOrder = \"XYCZT\";\n core[0].interleaved = false;\n core[0].metadataComplete = true;\n MetadataStore store = makeFilterMetadata();\n MetadataTools.populatePixels(store, this);\n MetadataTools.setDefaultCreationDate(store, id, 0);\n }\n"} {"input": " private static Buffer rubySprintfToBuffer(CharSequence charFormat, Args args) {\n byte[] format;\n Buffer buf = new Buffer();\n int offset;\n int length;\n int start;\n int mark; \n if (charFormat instanceof ByteList) {\n ByteList list = (ByteList)charFormat;\n format = list.unsafeBytes();\n int begin = list.begin(); \n offset = begin;\n length = begin + list.length();\n start = begin;\n mark = begin;\n } else {\n format = stringToBytes(charFormat, false);\n offset = 0;\n length = charFormat.length();\n start = 0;\n mark = 0; \n }\n while (offset < length) {\n start = offset;\n for ( ; offset < length && format[offset] != '%'; offset++) ;\n if (offset > start) {\n buf.write(format,start,offset-start);\n start = offset;\n }\n if (offset++ >= length)\n break;\n IRubyObject arg = null;\n int flags = 0;\n int width = 0;\n int precision = 0;\n int number = 0;\n byte fchar = 0;\n boolean incomplete = true;\n for ( ; incomplete && offset < length ; ) {\n switch(fchar = format[offset]) {\n default:\n if (fchar == '\\0' && flags == FLAG_NONE) {\n buf.write('%');\n incomplete = false;\n offset++;\n break;\n } else if (isPrintable(fchar)) {\n raiseArgumentError(args,\"malformed format string - %\" + (char)fchar);\n } else {\n raiseArgumentError(args,ERR_MALFORMED_FORMAT);\n }\n break;\n case ' ':\n flags |= FLAG_SPACE;\n offset++;\n break;\n case '0':\n flags |= FLAG_ZERO;\n offset++;\n break;\n case '+':\n flags |= FLAG_PLUS;\n offset++;\n break;\n case '-':\n flags |= FLAG_MINUS;\n offset++;\n break;\n case '#':\n flags |= FLAG_SHARP;\n offset++;\n break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args, number, fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_NUM);\n if (fchar == '$') {\n if (arg != null) {\n raiseArgumentError(args,\"value given twice - \" + number + \"$\");\n }\n arg = args.getNth(number);\n offset++;\n } else {\n width = number;\n flags |= FLAG_WIDTH;\n }\n break;\n case '*':\n if ((flags & FLAG_WIDTH) != 0) {\n raiseArgumentError(args,\"width given twice\");\n }\n flags |= FLAG_WIDTH;\n checkOffset(args,++offset,length,ERR_MALFORMED_STAR_NUM);\n mark = offset;\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args,number,fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_STAR_NUM);\n if (fchar == '$') {\n width = args.getNthInt(number);\n if (width < 0) {\n flags |= FLAG_MINUS;\n width = -width;\n }\n offset++;\n } else {\n width = args.nextInt();\n if (width < 0) {\n flags |= FLAG_MINUS;\n width = -width;\n }\n offset = mark;\n }\n break;\n case '.':\n if ((flags & FLAG_PRECISION) != 0) {\n raiseArgumentError(args,\"precision given twice\");\n }\n flags |= FLAG_PRECISION;\n checkOffset(args,++offset,length,ERR_MALFORMED_DOT_NUM);\n fchar = format[offset];\n if (fchar == '*') {\n checkOffset(args,++offset,length,ERR_MALFORMED_STAR_NUM);\n mark = offset;\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args,number,fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_STAR_NUM);\n if (fchar == '$') {\n precision = args.getNthInt(number);\n if (precision < 0) {\n flags &= ~FLAG_PRECISION;\n }\n offset++;\n } else {\n precision = args.nextInt();\n if (precision < 0) {\n flags &= ~FLAG_PRECISION;\n }\n offset = mark;\n }\n } else {\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args,number,fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_DOT_NUM);\n precision = number;\n }\n break;\n case '\\n':\n offset--;\n case '%':\n if (flags != FLAG_NONE) {\n raiseArgumentError(args,ERR_ILLEGAL_FORMAT_CHAR);\n }\n buf.write('%');\n offset++;\n incomplete = false;\n break;\n case 'c': {\n if (arg == null) arg = args.next();\n int c = 0;\n if (arg instanceof RubyString) {\n ByteList bytes = ((RubyString)arg).getByteList();\n if (bytes.length() == 1) {\n c = bytes.unsafeBytes()[bytes.begin()];\n } else {\n raiseArgumentError(args,\"%c requires a character\");\n }\n } else {\n c = args.intValue(arg);\n }\n if ((flags & FLAG_WIDTH) != 0 && width > 1) {\n if ((flags & FLAG_MINUS) != 0) {\n buf.write(c);\n buf.fill(' ', width-1);\n } else {\n buf.fill(' ',width-1);\n buf.write(c);\n }\n } else {\n buf.write(c);\n }\n offset++;\n incomplete = false;\n break;\n }\n case 'p':\n case 's': {\n if (arg == null) arg = args.next();\n if (fchar == 'p') {\n arg = arg.callMethod(arg.getRuntime().getCurrentContext(),\"inspect\");\n }\n ByteList bytes = arg.asString().getByteList();\n int len = bytes.length();\n if (arg.isTaint()) {\n buf.tainted = true;\n }\n if ((flags & FLAG_PRECISION) != 0 && precision < len) {\n len = precision;\n }\n if ((flags & FLAG_WIDTH) != 0 && width > len) {\n width -= len;\n if ((flags & FLAG_MINUS) != 0) {\n buf.write(bytes.unsafeBytes(),bytes.begin(),len);\n buf.fill(' ',width);\n } else {\n buf.fill(' ',width);\n buf.write(bytes.unsafeBytes(),bytes.begin(),len);\n }\n } else {\n buf.write(bytes.unsafeBytes(),bytes.begin(),len);\n }\n offset++;\n incomplete = false;\n break;\n }\n case 'd':\n case 'i':\n case 'o':\n case 'x':\n case 'X':\n case 'b':\n case 'B':\n case 'u': {\n if (arg == null) arg = args.next();\n int type = arg.getMetaClass().index;\n if (type != ClassIndex.FIXNUM && type != ClassIndex.BIGNUM) {\n switch(type) {\n case ClassIndex.FLOAT:\n arg = RubyNumeric.dbl2num(arg.getRuntime(),((RubyFloat)arg).getValue());\n break;\n case ClassIndex.STRING:\n arg = RubyNumeric.str2inum(arg.getRuntime(),(RubyString)arg,0,true);\n break;\n default:\n if (arg.respondsTo(\"to_int\")) {\n arg = TypeConverter.convertToType(arg, arg.getRuntime().getInteger(), MethodIndex.TO_INT, \"to_int\", true);\n } else {\n arg = TypeConverter.convertToType(arg, arg.getRuntime().getInteger(), MethodIndex.TO_I, \"to_i\", true);\n }\n break;\n }\n type = arg.getMetaClass().index;\n }\n byte[] bytes = null;\n int first = 0;\n byte[] prefix = null;\n boolean sign;\n boolean negative;\n byte signChar = 0;\n byte leadChar = 0;\n int base;\n if (fchar == 'i') fchar = 'd';\n if (fchar == 'u' && (flags & (FLAG_SPACE | FLAG_PLUS)) != 0) {\n fchar = 'd';\n }\n sign = (fchar == 'd' || (flags & (FLAG_SPACE | FLAG_PLUS)) != 0);\n switch (fchar) {\n case 'o':\n base = 8; break;\n case 'x':\n case 'X':\n base = 16; break;\n case 'b':\n case 'B':\n base = 2; break;\n case 'u':\n case 'd':\n default:\n base = 10; break;\n }\n if ((flags & FLAG_SHARP) != 0) {\n switch(fchar) {\n case 'o': prefix = PREFIX_OCTAL; break;\n case 'x': prefix = PREFIX_HEX_LC; break;\n case 'X': prefix = PREFIX_HEX_UC; break;\n case 'b': prefix = PREFIX_BINARY_LC; break;\n case 'B': prefix = PREFIX_BINARY_UC; break;\n }\n if (prefix != null) width -= prefix.length;\n }\n if (type == ClassIndex.FIXNUM) {\n negative = ((RubyFixnum)arg).getLongValue() < 0;\n if (negative && fchar == 'u') {\n bytes = getUnsignedNegativeBytes((RubyFixnum)arg);\n } else {\n bytes = getFixnumBytes((RubyFixnum)arg,base,sign,fchar=='X');\n }\n } else {\n negative = ((RubyBignum)arg).getValue().signum() < 0;\n if (negative && fchar == 'u') {\n bytes = getUnsignedNegativeBytes((RubyBignum)arg);\n } else {\n bytes = getBignumBytes((RubyBignum)arg,base,sign,fchar=='X');\n }\n }\n int len = 0;\n if (sign) {\n if (negative) {\n signChar = '-';\n width--;\n first = 1; \n } else if ((flags & FLAG_PLUS) != 0) {\n signChar = '+';\n width--;\n } else if ((flags & FLAG_SPACE) != 0) {\n signChar = ' ';\n width--;\n }\n } else if (negative) {\n if (base == 10) {\n warning(args,\"negative number for %u specifier\");\n leadChar = '.';\n len += 2;\n } else {\n if ((flags & (FLAG_PRECISION | FLAG_ZERO)) == 0) len += 2; \n first = skipSignBits(bytes,base);\n switch(fchar) {\n case 'b':\n case 'B':\n leadChar = '1';\n break;\n case 'o':\n leadChar = '7';\n break;\n case 'x':\n leadChar = 'f';\n break;\n case 'X':\n leadChar = 'F';\n break;\n }\n if (leadChar != 0) len++;\n }\n }\n int numlen = bytes.length - first;\n len += numlen;\n if ((flags & (FLAG_ZERO|FLAG_PRECISION)) == FLAG_ZERO) {\n precision = width;\n width = 0;\n } else {\n if (precision < len) precision = len;\n width -= precision;\n }\n if ((flags & FLAG_MINUS) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) buf.write(signChar);\n if (prefix != null) buf.write(prefix);\n if (len < precision) {\n if (leadChar == 0) {\n buf.fill('0', precision - len);\n } else if (leadChar == '.') {\n buf.fill(leadChar,precision-len);\n buf.write(PREFIX_NEGATIVE);\n } else {\n buf.fill(leadChar,precision-len+1); \n }\n } else if (leadChar != 0) {\n if ((flags & (FLAG_PRECISION | FLAG_ZERO)) == 0) {\n buf.write(PREFIX_NEGATIVE);\n }\n if (leadChar != '.') buf.write(leadChar);\n }\n buf.write(bytes,first,numlen);\n if (width > 0) buf.fill(' ',width);\n offset++;\n incomplete = false;\n break;\n }\n case 'E':\n case 'e':\n case 'f':\n case 'G':\n case 'g': {\n if (arg == null) arg = args.next();\n if (!(arg instanceof RubyFloat)) {\n arg = RubyKernel.new_float(arg,arg);\n }\n double dval = ((RubyFloat)arg).getDoubleValue();\n boolean nan = dval != dval;\n boolean inf = dval == Double.POSITIVE_INFINITY || dval == Double.NEGATIVE_INFINITY;\n boolean negative = dval < 0.0d;\n byte[] digits;\n int nDigits = 0;\n int exponent = 0;\n int len = 0;\n byte signChar;\n if (nan || inf) {\n if (nan) {\n digits = NAN_VALUE;\n len = NAN_VALUE.length;\n } else {\n digits = INFINITY_VALUE;\n len = INFINITY_VALUE.length;\n }\n if (negative) {\n signChar = '-';\n width--;\n } else if ((flags & FLAG_PLUS) != 0) {\n signChar = '+';\n width--;\n } else if ((flags & FLAG_SPACE) != 0) {\n signChar = ' ';\n width--;\n } else {\n signChar = 0;\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) buf.write(signChar);\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n buf.write(digits);\n if (width > 0) buf.fill(' ', width);\n offset++;\n incomplete = false;\n break;\n }\n String str = Double.toString(dval);\n int strlen = str.length();\n digits = new byte[strlen];\n int nTrailingZeroes = 0;\n int i = negative ? 1 : 0;\n int decPos = 0;\n byte ival;\n int_loop:\n for ( ; i < strlen ; ) {\n switch(ival = (byte)str.charAt(i++)) {\n case '0':\n if (nDigits > 0) nTrailingZeroes++;\n break; \n case '1': case '2': case '3': case '4':\n case '5': case '6': case '7': case '8': case '9':\n if (nTrailingZeroes > 0) {\n for ( ; nTrailingZeroes > 0 ; nTrailingZeroes-- ) {\n digits[nDigits++] = '0';\n }\n }\n digits[nDigits++] = ival;\n break; \n case '.':\n break int_loop;\n }\n }\n decPos = nDigits + nTrailingZeroes;\n dec_loop:\n for ( ; i < strlen ; ) {\n switch(ival = (byte)str.charAt(i++)) {\n case '0':\n if (nDigits > 0) {\n nTrailingZeroes++;\n } else {\n exponent--;\n }\n break; \n case '1': case '2': case '3': case '4':\n case '5': case '6': case '7': case '8': case '9':\n if (nTrailingZeroes > 0) {\n for ( ; nTrailingZeroes > 0 ; nTrailingZeroes-- ) {\n digits[nDigits++] = '0';\n }\n }\n digits[nDigits++] = ival;\n break; \n case 'E':\n break dec_loop;\n }\n }\n if ( i < strlen) {\n int expSign;\n int expVal = 0;\n if (str.charAt(i) == '-') {\n expSign = -1;\n i++;\n } else {\n expSign = 1;\n }\n for ( ; i < strlen ; ) {\n expVal = expVal * 10 + ((int)str.charAt(i++)-(int)'0');\n }\n exponent += expVal * expSign;\n }\n exponent += decPos - nDigits;\n if (nDigits == 0) {\n digits[0] = '0';\n nDigits = 1;\n exponent = 0;\n }\n int intDigits, intZeroes, intLength;\n int decDigits, decZeroes, decLength;\n byte expChar;\n if (negative) {\n signChar = '-';\n width--;\n } else if ((flags & FLAG_PLUS) != 0) {\n signChar = '+';\n width--;\n } else if ((flags & FLAG_SPACE) != 0) {\n signChar = ' ';\n width--;\n } else {\n signChar = 0;\n }\n if ((flags & FLAG_PRECISION) == 0) {\n precision = 6;\n }\n switch(fchar) {\n case 'E':\n case 'G':\n expChar = 'E';\n break;\n case 'e':\n case 'g':\n expChar = 'e';\n break;\n default:\n expChar = 0;\n }\n switch(fchar) {\n case 'g':\n case 'G':\n boolean expForm = (exponent + nDigits - 1 < -4 ||\n exponent + nDigits > (precision == 0 ? 1 : precision));\n if (expForm) {\n decDigits = nDigits - 1;\n precision = Math.max(0,precision - 1);\n if (precision < decDigits) {\n int n = round(digits,nDigits,precision,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n }\n decDigits = Math.min(nDigits - 1,precision);\n }\n exponent += nDigits - 1;\n boolean isSharp = (flags & FLAG_SHARP) != 0;\n len++; \n if (exponent > 99)\n \tlen += 5; \n else\n \tlen += 4; \n if (isSharp) {\n \tlen++;\n }\n if (precision > 0) {\n \tif (!isSharp) {\n \t int j = decDigits;\n \t for (; j >= 1; j--) {\n \t if (digits[j]== '0') {\n \t decDigits--;\n \t } else {\n \t break;\n \t }\n \t }\n \t if (decDigits > 0) {\n \t len += 1; \n \t len += decDigits;\n \t }\n \t} else {\n \t len += precision;\n \t}\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n buf.write(digits[0]);\n boolean dotToPrint = isSharp\n || (precision > 0 && decDigits > 0);\n if (dotToPrint) {\n \tbuf.write(args.getDecimalSeparator()); \n }\n if (precision > 0 && decDigits > 0) {\n \tbuf.write(digits, 1, decDigits);\n \tprecision -= decDigits;\n }\n if (precision > 0 && isSharp) {\n \tbuf.fill('0', precision);\n }\n writeExp(buf, exponent, expChar);\n if (width > 0) {\n buf.fill(' ', width);\n }\n } else { \n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intZeroes = Math.max(0,exponent);\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n decLength = decZeroes + decDigits;\n precision = Math.max(0,precision - intLength);\n if (precision < decDigits) {\n int n = round(digits,nDigits,intDigits+precision-1,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n precision = Math.max(0,precision-1);\n }\n decDigits = precision;\n decLength = decZeroes + decDigits;\n }\n len += intLength;\n if (decLength > 0) {\n len += decLength + 1;\n } else {\n if ((flags & FLAG_SHARP) != 0) {\n len++; \n if (precision > 0) { \n len += precision;\n }\n }\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n if (intLength > 0){\n if (intDigits > 0) { \n buf.write(digits,0,intDigits);\n }\n if (intZeroes > 0) {\n buf.fill('0',intZeroes);\n }\n } else {\n buf.write('0');\n }\n if (decLength > 0 || (flags & FLAG_SHARP) != 0) {\n buf.write(args.getDecimalSeparator());\n }\n if (decLength > 0) {\n if (decZeroes > 0) {\n buf.fill('0',decZeroes);\n precision -= decZeroes;\n }\n if (decDigits > 0) {\n buf.write(digits,intDigits,decDigits);\n precision -= decDigits;\n }\n if ((flags & FLAG_SHARP) != 0 && precision > 0) {\n buf.fill('0',precision);\n }\n }\n if ((flags & FLAG_SHARP) != 0 && precision > 0) {\n buf.fill('0',precision);\n }\n if (width > 0) {\n buf.fill(' ', width);\n }\n }\n break;\n case 'f':\n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intZeroes = Math.max(0,exponent);\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n decLength = decZeroes + decDigits;\n if (precision < decLength) {\n if (precision < decZeroes) {\n decDigits = 0;\n decZeroes = precision;\n } else {\n int n = round(digits,nDigits,intDigits+precision-decZeroes-1,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n decLength = decZeroes + decDigits;\n }\n decDigits = precision - decZeroes;\n }\n decLength = decZeroes + decDigits;\n }\n if (precision > 0) {\n len += Math.max(1,intLength) + 1 + precision;\n } else {\n len += Math.max(1,intLength);\n if ((flags & FLAG_SHARP) != 0) {\n len++; \n }\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n if (intLength > 0){\n if (intDigits > 0) { \n buf.write(digits,0,intDigits);\n }\n if (intZeroes > 0) {\n buf.fill('0',intZeroes);\n }\n } else {\n buf.write('0');\n }\n if (precision > 0 || (flags & FLAG_SHARP) != 0) {\n buf.write(args.getDecimalSeparator());\n }\n if (precision > 0) {\n if (decZeroes > 0) {\n buf.fill('0',decZeroes);\n precision -= decZeroes;\n }\n if (decDigits > 0) {\n buf.write(digits,intDigits,decDigits);\n precision -= decDigits;\n }\n if (precision > 0) {\n buf.fill('0',precision);\n }\n }\n if (width > 0) {\n buf.fill(' ', width);\n }\n break;\n case 'E':\n case 'e':\n decDigits = nDigits - 1;\n if (precision < decDigits) {\n int n = round(digits,nDigits,precision,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n }\n decDigits = Math.min(nDigits - 1,precision);\n }\n exponent += nDigits - 1;\n boolean isSharp = (flags & FLAG_SHARP) != 0;\n len++; \n if (exponent > 99)\n len += 5; \n else\n len += 4; \n if (precision > 0) {\n len += 1 + precision;\n } else if (isSharp) {\n len++; \n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n buf.write(digits[0]);\n if (precision > 0) {\n buf.write(args.getDecimalSeparator()); \n if (decDigits > 0) {\n buf.write(digits,1,decDigits);\n precision -= decDigits;\n }\n if (precision > 0) {\n buf.fill('0',precision);\n }\n } else if ((flags & FLAG_SHARP) != 0) {\n buf.write(args.getDecimalSeparator());\n }\n writeExp(buf, exponent, expChar);\n if (width > 0) {\n buf.fill(' ', width);\n }\n break;\n } \n offset++;\n incomplete = false;\n break;\n } \n } \n } \n if (incomplete) {\n if (flags == FLAG_NONE) {\n buf.write('%');\n } else {\n raiseArgumentError(args,ERR_ILLEGAL_FORMAT_CHAR);\n }\n }\n } \n return buf;\n }\n", "output": " private static Buffer rubySprintfToBuffer(CharSequence charFormat, Args args) {\n byte[] format;\n Buffer buf = new Buffer();\n int offset;\n int length;\n int start;\n int mark; \n if (charFormat instanceof ByteList) {\n ByteList list = (ByteList)charFormat;\n format = list.unsafeBytes();\n int begin = list.begin(); \n offset = begin;\n length = begin + list.length();\n start = begin;\n mark = begin;\n } else {\n format = stringToBytes(charFormat, false);\n offset = 0;\n length = charFormat.length();\n start = 0;\n mark = 0; \n }\n while (offset < length) {\n start = offset;\n for ( ; offset < length && format[offset] != '%'; offset++) ;\n if (offset > start) {\n buf.write(format,start,offset-start);\n start = offset;\n }\n if (offset++ >= length)\n break;\n IRubyObject arg = null;\n int flags = 0;\n int width = 0;\n int precision = 0;\n int number = 0;\n byte fchar = 0;\n boolean incomplete = true;\n for ( ; incomplete && offset < length ; ) {\n switch(fchar = format[offset]) {\n default:\n if (fchar == '\\0' && flags == FLAG_NONE) {\n buf.write('%');\n buf.write(fchar);\n incomplete = false;\n offset++;\n break;\n } else if (isPrintable(fchar)) {\n raiseArgumentError(args,\"malformed format string - %\" + (char)fchar);\n } else {\n raiseArgumentError(args,ERR_MALFORMED_FORMAT);\n }\n break;\n case ' ':\n flags |= FLAG_SPACE;\n offset++;\n break;\n case '0':\n flags |= FLAG_ZERO;\n offset++;\n break;\n case '+':\n flags |= FLAG_PLUS;\n offset++;\n break;\n case '-':\n flags |= FLAG_MINUS;\n offset++;\n break;\n case '#':\n flags |= FLAG_SHARP;\n offset++;\n break;\n case '1':\n case '2':\n case '3':\n case '4':\n case '5':\n case '6':\n case '7':\n case '8':\n case '9':\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args, number, fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_NUM);\n if (fchar == '$') {\n if (arg != null) {\n raiseArgumentError(args,\"value given twice - \" + number + \"$\");\n }\n arg = args.getNth(number);\n offset++;\n } else {\n width = number;\n flags |= FLAG_WIDTH;\n }\n break;\n case '*':\n if ((flags & FLAG_WIDTH) != 0) {\n raiseArgumentError(args,\"width given twice\");\n }\n flags |= FLAG_WIDTH;\n checkOffset(args,++offset,length,ERR_MALFORMED_STAR_NUM);\n mark = offset;\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args,number,fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_STAR_NUM);\n if (fchar == '$') {\n width = args.getNthInt(number);\n if (width < 0) {\n flags |= FLAG_MINUS;\n width = -width;\n }\n offset++;\n } else {\n width = args.nextInt();\n if (width < 0) {\n flags |= FLAG_MINUS;\n width = -width;\n }\n offset = mark;\n }\n break;\n case '.':\n if ((flags & FLAG_PRECISION) != 0) {\n raiseArgumentError(args,\"precision given twice\");\n }\n flags |= FLAG_PRECISION;\n checkOffset(args,++offset,length,ERR_MALFORMED_DOT_NUM);\n fchar = format[offset];\n if (fchar == '*') {\n checkOffset(args,++offset,length,ERR_MALFORMED_STAR_NUM);\n mark = offset;\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args,number,fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_STAR_NUM);\n if (fchar == '$') {\n precision = args.getNthInt(number);\n if (precision < 0) {\n flags &= ~FLAG_PRECISION;\n }\n offset++;\n } else {\n precision = args.nextInt();\n if (precision < 0) {\n flags &= ~FLAG_PRECISION;\n }\n offset = mark;\n }\n } else {\n number = 0;\n for ( ; offset < length && isDigit(fchar = format[offset]); offset++) {\n number = extendWidth(args,number,fchar);\n }\n checkOffset(args,offset,length,ERR_MALFORMED_DOT_NUM);\n precision = number;\n }\n break;\n case '\\n':\n offset--;\n case '%':\n if (flags != FLAG_NONE) {\n raiseArgumentError(args,ERR_ILLEGAL_FORMAT_CHAR);\n }\n buf.write('%');\n offset++;\n incomplete = false;\n break;\n case 'c': {\n if (arg == null) arg = args.next();\n int c = 0;\n if (arg instanceof RubyString) {\n ByteList bytes = ((RubyString)arg).getByteList();\n if (bytes.length() == 1) {\n c = bytes.unsafeBytes()[bytes.begin()];\n } else {\n raiseArgumentError(args,\"%c requires a character\");\n }\n } else {\n c = args.intValue(arg);\n }\n if ((flags & FLAG_WIDTH) != 0 && width > 1) {\n if ((flags & FLAG_MINUS) != 0) {\n buf.write(c);\n buf.fill(' ', width-1);\n } else {\n buf.fill(' ',width-1);\n buf.write(c);\n }\n } else {\n buf.write(c);\n }\n offset++;\n incomplete = false;\n break;\n }\n case 'p':\n case 's': {\n if (arg == null) arg = args.next();\n if (fchar == 'p') {\n arg = arg.callMethod(arg.getRuntime().getCurrentContext(),\"inspect\");\n }\n ByteList bytes = arg.asString().getByteList();\n int len = bytes.length();\n if (arg.isTaint()) {\n buf.tainted = true;\n }\n if ((flags & FLAG_PRECISION) != 0 && precision < len) {\n len = precision;\n }\n if ((flags & FLAG_WIDTH) != 0 && width > len) {\n width -= len;\n if ((flags & FLAG_MINUS) != 0) {\n buf.write(bytes.unsafeBytes(),bytes.begin(),len);\n buf.fill(' ',width);\n } else {\n buf.fill(' ',width);\n buf.write(bytes.unsafeBytes(),bytes.begin(),len);\n }\n } else {\n buf.write(bytes.unsafeBytes(),bytes.begin(),len);\n }\n offset++;\n incomplete = false;\n break;\n }\n case 'd':\n case 'i':\n case 'o':\n case 'x':\n case 'X':\n case 'b':\n case 'B':\n case 'u': {\n if (arg == null) arg = args.next();\n int type = arg.getMetaClass().index;\n if (type != ClassIndex.FIXNUM && type != ClassIndex.BIGNUM) {\n switch(type) {\n case ClassIndex.FLOAT:\n arg = RubyNumeric.dbl2num(arg.getRuntime(),((RubyFloat)arg).getValue());\n break;\n case ClassIndex.STRING:\n arg = RubyNumeric.str2inum(arg.getRuntime(),(RubyString)arg,0,true);\n break;\n default:\n if (arg.respondsTo(\"to_int\")) {\n arg = TypeConverter.convertToType(arg, arg.getRuntime().getInteger(), MethodIndex.TO_INT, \"to_int\", true);\n } else {\n arg = TypeConverter.convertToType(arg, arg.getRuntime().getInteger(), MethodIndex.TO_I, \"to_i\", true);\n }\n break;\n }\n type = arg.getMetaClass().index;\n }\n byte[] bytes = null;\n int first = 0;\n byte[] prefix = null;\n boolean sign;\n boolean negative;\n byte signChar = 0;\n byte leadChar = 0;\n int base;\n if (fchar == 'i') fchar = 'd';\n if (fchar == 'u' && (flags & (FLAG_SPACE | FLAG_PLUS)) != 0) {\n fchar = 'd';\n }\n sign = (fchar == 'd' || (flags & (FLAG_SPACE | FLAG_PLUS)) != 0);\n switch (fchar) {\n case 'o':\n base = 8; break;\n case 'x':\n case 'X':\n base = 16; break;\n case 'b':\n case 'B':\n base = 2; break;\n case 'u':\n case 'd':\n default:\n base = 10; break;\n }\n if ((flags & FLAG_SHARP) != 0) {\n switch(fchar) {\n case 'o': prefix = PREFIX_OCTAL; break;\n case 'x': prefix = PREFIX_HEX_LC; break;\n case 'X': prefix = PREFIX_HEX_UC; break;\n case 'b': prefix = PREFIX_BINARY_LC; break;\n case 'B': prefix = PREFIX_BINARY_UC; break;\n }\n if (prefix != null) width -= prefix.length;\n }\n if (type == ClassIndex.FIXNUM) {\n negative = ((RubyFixnum)arg).getLongValue() < 0;\n if (negative && fchar == 'u') {\n bytes = getUnsignedNegativeBytes((RubyFixnum)arg);\n } else {\n bytes = getFixnumBytes((RubyFixnum)arg,base,sign,fchar=='X');\n }\n } else {\n negative = ((RubyBignum)arg).getValue().signum() < 0;\n if (negative && fchar == 'u') {\n bytes = getUnsignedNegativeBytes((RubyBignum)arg);\n } else {\n bytes = getBignumBytes((RubyBignum)arg,base,sign,fchar=='X');\n }\n }\n int len = 0;\n if (sign) {\n if (negative) {\n signChar = '-';\n width--;\n first = 1; \n } else if ((flags & FLAG_PLUS) != 0) {\n signChar = '+';\n width--;\n } else if ((flags & FLAG_SPACE) != 0) {\n signChar = ' ';\n width--;\n }\n } else if (negative) {\n if (base == 10) {\n warning(args,\"negative number for %u specifier\");\n leadChar = '.';\n len += 2;\n } else {\n if ((flags & (FLAG_PRECISION | FLAG_ZERO)) == 0) len += 2; \n first = skipSignBits(bytes,base);\n switch(fchar) {\n case 'b':\n case 'B':\n leadChar = '1';\n break;\n case 'o':\n leadChar = '7';\n break;\n case 'x':\n leadChar = 'f';\n break;\n case 'X':\n leadChar = 'F';\n break;\n }\n if (leadChar != 0) len++;\n }\n }\n int numlen = bytes.length - first;\n len += numlen;\n if ((flags & (FLAG_ZERO|FLAG_PRECISION)) == FLAG_ZERO) {\n precision = width;\n width = 0;\n } else {\n if (precision < len) precision = len;\n width -= precision;\n }\n if ((flags & FLAG_MINUS) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) buf.write(signChar);\n if (prefix != null) buf.write(prefix);\n if (len < precision) {\n if (leadChar == 0) {\n buf.fill('0', precision - len);\n } else if (leadChar == '.') {\n buf.fill(leadChar,precision-len);\n buf.write(PREFIX_NEGATIVE);\n } else {\n buf.fill(leadChar,precision-len+1); \n }\n } else if (leadChar != 0) {\n if ((flags & (FLAG_PRECISION | FLAG_ZERO)) == 0) {\n buf.write(PREFIX_NEGATIVE);\n }\n if (leadChar != '.') buf.write(leadChar);\n }\n buf.write(bytes,first,numlen);\n if (width > 0) buf.fill(' ',width);\n offset++;\n incomplete = false;\n break;\n }\n case 'E':\n case 'e':\n case 'f':\n case 'G':\n case 'g': {\n if (arg == null) arg = args.next();\n if (!(arg instanceof RubyFloat)) {\n arg = RubyKernel.new_float(arg,arg);\n }\n double dval = ((RubyFloat)arg).getDoubleValue();\n boolean nan = dval != dval;\n boolean inf = dval == Double.POSITIVE_INFINITY || dval == Double.NEGATIVE_INFINITY;\n boolean negative = dval < 0.0d;\n byte[] digits;\n int nDigits = 0;\n int exponent = 0;\n int len = 0;\n byte signChar;\n if (nan || inf) {\n if (nan) {\n digits = NAN_VALUE;\n len = NAN_VALUE.length;\n } else {\n digits = INFINITY_VALUE;\n len = INFINITY_VALUE.length;\n }\n if (negative) {\n signChar = '-';\n width--;\n } else if ((flags & FLAG_PLUS) != 0) {\n signChar = '+';\n width--;\n } else if ((flags & FLAG_SPACE) != 0) {\n signChar = ' ';\n width--;\n } else {\n signChar = 0;\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) buf.write(signChar);\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n buf.write(digits);\n if (width > 0) buf.fill(' ', width);\n offset++;\n incomplete = false;\n break;\n }\n String str = Double.toString(dval);\n int strlen = str.length();\n digits = new byte[strlen];\n int nTrailingZeroes = 0;\n int i = negative ? 1 : 0;\n int decPos = 0;\n byte ival;\n int_loop:\n for ( ; i < strlen ; ) {\n switch(ival = (byte)str.charAt(i++)) {\n case '0':\n if (nDigits > 0) nTrailingZeroes++;\n break; \n case '1': case '2': case '3': case '4':\n case '5': case '6': case '7': case '8': case '9':\n if (nTrailingZeroes > 0) {\n for ( ; nTrailingZeroes > 0 ; nTrailingZeroes-- ) {\n digits[nDigits++] = '0';\n }\n }\n digits[nDigits++] = ival;\n break; \n case '.':\n break int_loop;\n }\n }\n decPos = nDigits + nTrailingZeroes;\n dec_loop:\n for ( ; i < strlen ; ) {\n switch(ival = (byte)str.charAt(i++)) {\n case '0':\n if (nDigits > 0) {\n nTrailingZeroes++;\n } else {\n exponent--;\n }\n break; \n case '1': case '2': case '3': case '4':\n case '5': case '6': case '7': case '8': case '9':\n if (nTrailingZeroes > 0) {\n for ( ; nTrailingZeroes > 0 ; nTrailingZeroes-- ) {\n digits[nDigits++] = '0';\n }\n }\n digits[nDigits++] = ival;\n break; \n case 'E':\n break dec_loop;\n }\n }\n if ( i < strlen) {\n int expSign;\n int expVal = 0;\n if (str.charAt(i) == '-') {\n expSign = -1;\n i++;\n } else {\n expSign = 1;\n }\n for ( ; i < strlen ; ) {\n expVal = expVal * 10 + ((int)str.charAt(i++)-(int)'0');\n }\n exponent += expVal * expSign;\n }\n exponent += decPos - nDigits;\n if (nDigits == 0) {\n digits[0] = '0';\n nDigits = 1;\n exponent = 0;\n }\n int intDigits, intZeroes, intLength;\n int decDigits, decZeroes, decLength;\n byte expChar;\n if (negative) {\n signChar = '-';\n width--;\n } else if ((flags & FLAG_PLUS) != 0) {\n signChar = '+';\n width--;\n } else if ((flags & FLAG_SPACE) != 0) {\n signChar = ' ';\n width--;\n } else {\n signChar = 0;\n }\n if ((flags & FLAG_PRECISION) == 0) {\n precision = 6;\n }\n switch(fchar) {\n case 'E':\n case 'G':\n expChar = 'E';\n break;\n case 'e':\n case 'g':\n expChar = 'e';\n break;\n default:\n expChar = 0;\n }\n switch(fchar) {\n case 'g':\n case 'G':\n boolean expForm = (exponent + nDigits - 1 < -4 ||\n exponent + nDigits > (precision == 0 ? 1 : precision));\n if (expForm) {\n decDigits = nDigits - 1;\n precision = Math.max(0,precision - 1);\n if (precision < decDigits) {\n int n = round(digits,nDigits,precision,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n }\n decDigits = Math.min(nDigits - 1,precision);\n }\n exponent += nDigits - 1;\n boolean isSharp = (flags & FLAG_SHARP) != 0;\n len++; \n if (exponent > 99)\n \tlen += 5; \n else\n \tlen += 4; \n if (isSharp) {\n \tlen++;\n }\n if (precision > 0) {\n \tif (!isSharp) {\n \t int j = decDigits;\n \t for (; j >= 1; j--) {\n \t if (digits[j]== '0') {\n \t decDigits--;\n \t } else {\n \t break;\n \t }\n \t }\n \t if (decDigits > 0) {\n \t len += 1; \n \t len += decDigits;\n \t }\n \t} else {\n \t len += precision;\n \t}\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n buf.write(digits[0]);\n boolean dotToPrint = isSharp\n || (precision > 0 && decDigits > 0);\n if (dotToPrint) {\n \tbuf.write(args.getDecimalSeparator()); \n }\n if (precision > 0 && decDigits > 0) {\n \tbuf.write(digits, 1, decDigits);\n \tprecision -= decDigits;\n }\n if (precision > 0 && isSharp) {\n \tbuf.fill('0', precision);\n }\n writeExp(buf, exponent, expChar);\n if (width > 0) {\n buf.fill(' ', width);\n }\n } else { \n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intZeroes = Math.max(0,exponent);\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n decLength = decZeroes + decDigits;\n precision = Math.max(0,precision - intLength);\n if (precision < decDigits) {\n int n = round(digits,nDigits,intDigits+precision-1,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n precision = Math.max(0,precision-1);\n }\n decDigits = precision;\n decLength = decZeroes + decDigits;\n }\n len += intLength;\n if (decLength > 0) {\n len += decLength + 1;\n } else {\n if ((flags & FLAG_SHARP) != 0) {\n len++; \n if (precision > 0) { \n len += precision;\n }\n }\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n if (intLength > 0){\n if (intDigits > 0) { \n buf.write(digits,0,intDigits);\n }\n if (intZeroes > 0) {\n buf.fill('0',intZeroes);\n }\n } else {\n buf.write('0');\n }\n if (decLength > 0 || (flags & FLAG_SHARP) != 0) {\n buf.write(args.getDecimalSeparator());\n }\n if (decLength > 0) {\n if (decZeroes > 0) {\n buf.fill('0',decZeroes);\n precision -= decZeroes;\n }\n if (decDigits > 0) {\n buf.write(digits,intDigits,decDigits);\n precision -= decDigits;\n }\n if ((flags & FLAG_SHARP) != 0 && precision > 0) {\n buf.fill('0',precision);\n }\n }\n if ((flags & FLAG_SHARP) != 0 && precision > 0) {\n buf.fill('0',precision);\n }\n if (width > 0) {\n buf.fill(' ', width);\n }\n }\n break;\n case 'f':\n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intZeroes = Math.max(0,exponent);\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n decLength = decZeroes + decDigits;\n if (precision < decLength) {\n if (precision < decZeroes) {\n decDigits = 0;\n decZeroes = precision;\n } else {\n int n = round(digits,nDigits,intDigits+precision-decZeroes-1,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n intDigits = Math.max(0,Math.min(nDigits + exponent,nDigits));\n intLength = intDigits + intZeroes;\n decDigits = nDigits - intDigits;\n decZeroes = Math.max(0,-(decDigits + exponent));\n decLength = decZeroes + decDigits;\n }\n decDigits = precision - decZeroes;\n }\n decLength = decZeroes + decDigits;\n }\n if (precision > 0) {\n len += Math.max(1,intLength) + 1 + precision;\n } else {\n len += Math.max(1,intLength);\n if ((flags & FLAG_SHARP) != 0) {\n len++; \n }\n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n if (intLength > 0){\n if (intDigits > 0) { \n buf.write(digits,0,intDigits);\n }\n if (intZeroes > 0) {\n buf.fill('0',intZeroes);\n }\n } else {\n buf.write('0');\n }\n if (precision > 0 || (flags & FLAG_SHARP) != 0) {\n buf.write(args.getDecimalSeparator());\n }\n if (precision > 0) {\n if (decZeroes > 0) {\n buf.fill('0',decZeroes);\n precision -= decZeroes;\n }\n if (decDigits > 0) {\n buf.write(digits,intDigits,decDigits);\n precision -= decDigits;\n }\n if (precision > 0) {\n buf.fill('0',precision);\n }\n }\n if (width > 0) {\n buf.fill(' ', width);\n }\n break;\n case 'E':\n case 'e':\n decDigits = nDigits - 1;\n if (precision < decDigits) {\n int n = round(digits,nDigits,precision,precision!=0);\n if (n > nDigits) {\n nDigits = n;\n }\n decDigits = Math.min(nDigits - 1,precision);\n }\n exponent += nDigits - 1;\n boolean isSharp = (flags & FLAG_SHARP) != 0;\n len++; \n if (exponent > 99)\n len += 5; \n else\n len += 4; \n if (precision > 0) {\n len += 1 + precision;\n } else if (isSharp) {\n len++; \n }\n width -= len;\n if (width > 0 && (flags & (FLAG_ZERO|FLAG_MINUS)) == 0) {\n buf.fill(' ',width);\n width = 0;\n }\n if (signChar != 0) {\n buf.write(signChar);\n }\n if (width > 0 && (flags & FLAG_MINUS) == 0) {\n buf.fill('0',width);\n width = 0;\n }\n buf.write(digits[0]);\n if (precision > 0) {\n buf.write(args.getDecimalSeparator()); \n if (decDigits > 0) {\n buf.write(digits,1,decDigits);\n precision -= decDigits;\n }\n if (precision > 0) {\n buf.fill('0',precision);\n }\n } else if ((flags & FLAG_SHARP) != 0) {\n buf.write(args.getDecimalSeparator());\n }\n writeExp(buf, exponent, expChar);\n if (width > 0) {\n buf.fill(' ', width);\n }\n break;\n } \n offset++;\n incomplete = false;\n break;\n } \n } \n } \n if (incomplete) {\n if (flags == FLAG_NONE) {\n buf.write('%');\n } else {\n raiseArgumentError(args,ERR_ILLEGAL_FORMAT_CHAR);\n }\n }\n } \n return buf;\n }\n"} {"input": " public static Color getColorForSeed(int seed){\n Random r = new Random(seed);\n double h,s,b;\n h=r.nextDouble()*360;\n s=r.nextDouble()%0.2+0.8;\n b=r.nextDouble()%0.2+0.8;\n return Color.hsb(h,s,b);\n }\n", "output": " public static Color getColorForSeed(int seed){\n seed=Math.abs(seed);\n double h,s,b;\n h=((seed*0.12345)%1.0)*360;\n s=(seed*0.23456)%0.2+0.8;\n b=(seed*0.34567)%0.2+0.8;\n return Color.hsb(h,s,b);\n }\n"} {"input": "\tpublic void testDisplayPodcastItemInfo() throws Exception {\n\t\tView itemView = getItemView(0);\n\t\tassertTextFieldHasText(itemView, \"podcast_item_view_number\", \"#5192\");\n\t\tassertTextFieldHasText(itemView, \"podcast_item_view_date\", \"11.02.2012\");\n\t}\n", "output": "\tpublic void testDisplayPodcastItemInfo() throws Exception {\n\t\tView itemView = getItemView(0);\n\t\tassertTextFieldHasText(itemView, \"podcast_item_view_number\", \"#5192\");\n\t\tassertTextFieldHasText(itemView, \"podcast_item_view_date\", \"12.02.2012\");\n\t}\n"} {"input": " public static boolean isNewerVersion(String installedVersion, String newVersion) {\n final String regex = \"^[1-9\\\\.]+$\";\n if (!installedVersion.matches(regex) || !newVersion.matches(regex)) {\n return false;\n }\n String[] currentParts = installedVersion.split(\"\\\\.\");\n String[] newPartsParts = newVersion.split(\"\\\\.\");\n int length = Math.max(currentParts.length, newPartsParts.length);\n for (int i=0; i< length; i++) {\n int currentPart = i < currentParts.length ? \n Integer.parseInt(currentParts[i]) : 0;\n int newPart = i < newPartsParts.length ? \n Integer.parseInt(newPartsParts[i]) : 0;\n if (currentPart < newPart) {\n return true;\n } else if (newPart < currentPart) {\n return false;\n }\n }\n return false;\n }\n", "output": " public static boolean isNewerVersion(String installedVersion, String newVersion) {\n final String regex = \"^\\\\d+(\\\\.\\\\d+)*$\";\n if (!installedVersion.matches(regex) || !newVersion.matches(regex)) {\n return false;\n }\n String[] currentParts = installedVersion.split(\"\\\\.\");\n String[] newPartsParts = newVersion.split(\"\\\\.\");\n int length = Math.max(currentParts.length, newPartsParts.length);\n for (int i=0; i< length; i++) {\n int currentPart = i < currentParts.length ? \n Integer.parseInt(currentParts[i]) : 0;\n int newPart = i < newPartsParts.length ? \n Integer.parseInt(newPartsParts[i]) : 0;\n if (currentPart < newPart) {\n return true;\n } else if (newPart < currentPart) {\n return false;\n }\n }\n return false;\n }\n"} {"input": " public void addStageInXFERNodes( SubInfo job,\n Collection files, \n int type,\n Map<String,PoolTransfer> stageInMap,\n BundleValue bundleValue,\n Implementation implementation ){\n String jobName = job.getName();\n String siteHandle = job.getSiteHandle();\n String key = null;\n String par = null;\n int bundle = -1;\n Set tempSet = new HashSet();\n int staged = 0;\n Collection stagedFiles = new ArrayList();\n Collection stageInExecJobs = new ArrayList();\n for(Iterator it = files.iterator();it.hasNext();) {\n FileTransfer ft = (FileTransfer) it.next();\n String lfn = ft.getLFN();\n key = this.constructFileKey(lfn, siteHandle);\n par = (String) mFileTable.get(key);\n if (par != null) {\n it.remove();\n tempSet.add(par);\n if(ft.isTransferringExecutableFile()){\n String xBitJobName = (String)mSetupMap.get(key);\n if(key == null){\n throw new RuntimeException(\"Internal Pegasus Error while \" +\n \"constructing bundled stagein jobs\");\n }\n this.addRelation(xBitJobName,jobName);\n }\n } else {\n boolean contains = stageInMap.containsKey(siteHandle);\n if(!contains){\n bundle = bundleValue.determine( implementation, job );\n }\n PoolTransfer pt = (contains)?\n (PoolTransfer)stageInMap.get(siteHandle):\n new PoolTransfer(siteHandle,bundle);\n if(!contains){\n stageInMap.put(siteHandle,pt);\n }\n String newJobName = pt.addTransfer( ft, type );\n if(ft.isTransferringExecutableFile()){\n stageInExecJobs.add( newJobName );\n stagedFiles.add( ft );\n mLogger.log(\"Entered \" + key + \"->\" +\n implementation.getSetXBitJobName(job.getName(),staged),\n LogManager.DEBUG_MESSAGE_LEVEL);\n mSetupMap.put(key,\n implementation.getSetXBitJobName(job.getName(),staged));\n staged++;\n }\n mFileTable.put(key, newJobName);\n tempSet.add(newJobName);\n }\n }\n int index = 0;\n Iterator jobIt= stageInExecJobs.iterator();\n for( Iterator it = stagedFiles.iterator(); it.hasNext(); index++){\n Collection execFiles = new ArrayList(1);\n execFiles.add( it.next() );\n implementation.addSetXBitJobs(job, (String)jobIt.next(),\n execFiles,\n SubInfo.STAGE_IN_JOB,\n index);\n }\n mRelationsMap.put(jobName,tempSet);\n }\n", "output": " public void addStageInXFERNodes( SubInfo job,\n Collection files, \n int type,\n Map<String,PoolTransfer> stageInMap,\n BundleValue bundleValue,\n Implementation implementation ){\n String jobName = job.getName();\n String siteHandle = job.getSiteHandle();\n String key = null;\n String par = null;\n int bundle = -1;\n Set tempSet = new HashSet();\n int staged = 0;\n Collection stagedFiles = new ArrayList();\n Collection stageInExecJobs = new ArrayList();\n for(Iterator it = files.iterator();it.hasNext();) {\n FileTransfer ft = (FileTransfer) it.next();\n String lfn = ft.getLFN();\n key = this.constructFileKey(lfn, siteHandle);\n par = (String) mFileTable.get(key);\n if (par != null) {\n it.remove();\n tempSet.add(par);\n if(ft.isTransferringExecutableFile()){\n String xBitJobName = (String)mSetupMap.get(key);\n if(key == null){\n throw new RuntimeException(\"Internal Pegasus Error while \" +\n \"constructing bundled stagein jobs\");\n }\n this.addRelation(xBitJobName,jobName);\n }\n } else {\n boolean contains = stageInMap.containsKey(siteHandle);\n if(!contains){\n bundle = bundleValue.determine( implementation, job );\n }\n PoolTransfer pt = (contains)?\n (PoolTransfer)stageInMap.get(siteHandle):\n new PoolTransfer(siteHandle,bundle);\n if(!contains){\n stageInMap.put(siteHandle,pt);\n }\n String newJobName = pt.addTransfer( ft, type );\n if(ft.isTransferringExecutableFile()){\n stageInExecJobs.add( newJobName );\n stagedFiles.add( ft );\n mLogger.log(\"Entered \" + key + \"->\" +\n implementation.getSetXBitJobName(job.getName(),staged),\n LogManager.DEBUG_MESSAGE_LEVEL);\n mSetupMap.put(key,\n implementation.getSetXBitJobName(job.getName(),staged));\n staged++;\n }\n mFileTable.put(key, newJobName);\n tempSet.add(newJobName);\n }\n }\n int index = 0;\n Iterator jobIt= stageInExecJobs.iterator();\n for( Iterator it = stagedFiles.iterator(); it.hasNext(); index++){\n Collection execFiles = new ArrayList(1);\n execFiles.add( it.next() );\n implementation.addSetXBitJobs(job, (String)jobIt.next(),\n execFiles,\n SubInfo.STAGE_IN_JOB,\n index);\n }\n if( mRelationsMap.containsKey( jobName )){\n tempSet.addAll( (Set) mRelationsMap.get( jobName ) );\n }\n mRelationsMap.put(jobName,tempSet);\n }\n"} {"input": " public void testFindById() throws Exception {\n when(fooDAO.findById(eq(9527L))).thenReturn(fooFactory.name(\"\u5468\u661f\u661f\").age(51).build());\n Foo zxx = fooDAO.findById(9527L);\n assertThat(zxx.getName()).isEqualTo(\"\u5468\u661f\u661f\");\n assertThat(zxx.getAge()).isEqualTo(51);\n verify(fooDAO, times(1)).findById(eq(9527L));\n verify(fooDAO, never()).findById(eq(1L));\n }\n", "output": " public void testFindById() throws Exception {\n when(fooDAO.findById(eq(9527L))).thenReturn(fooFactory.name(\"\u5468\u661f\u661f\").age(51).build());\n Foo zxx = fooDAO.findById(9527L);\n assertThat(zxx.getName()).isEqualTo(\"\u5468\u661f\u661f\");\n assertThat(zxx.getAge()).isEqualTo(51);\n verify(fooDAO, times(1)).findById(9527L);\n verify(fooDAO, never()).findById(eq(1L));\n }\n"} {"input": "\tpublic boolean generate(World var1, Random var2, int var3, int var4, int var5)\n\t{\n\t\twhile (var1.isAirBlock(var3, var4, var5) && var4 > 2)\n\t\t{\n\t\t\t--var4;\n\t\t}\n\t\tint var6 = var1.getBlockId(var3, var4, var5);\n\t\tint var95 = var1.getBlockId(var3 - 1, var4, var5);\n\t\tint var96 = var1.getBlockId(var3 + 1, var4, var5);\n\t\tint var97 = var1.getBlockId(var3, var4, var5 - 1);\n\t\tint var98 = var1.getBlockId(var3, var4, var5 + 1);\n\t\tif (var6 != Block.grass.blockID || var95 != Block.grass.blockID || var96 != Block.grass.blockID || var97 != Block.grass.blockID || var98 != Block.grass.blockID )\n\t\t\treturn false;\n\t\telse\n\t\t{\n\t\t\tfor (int var7 = -2; var7 <= 2; ++var7)\n\t\t\t{\n\t\t\t\tfor (int var8 = -2; var8 <= 2; ++var8)\n\t\t\t\t{\n\t\t\t\t\tif (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8) && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8))\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint var999 = var2.nextInt(2);\n\t\t\tif (var999 == 0)\n\t\t\t{\n\t\t\t\tvar1.setBlock(var3, var4, var5, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3 - 1, var4, var5, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3 + 1, var4, var5, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3, var4, var5 - 1, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3, var4, var5 + 1, Block.dirt.blockID);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3 + 1, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3 - 1, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5 + 1, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5 - 1, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 2, var5, Block.stone.blockID, 0);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (var999 == 1)\n\t\t\t{\n\t\t\t\tvar1.setBlock(var3, var4, var5, Block.dirt.blockID);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n", "output": "\tpublic boolean generate(World var1, Random var2, int var3, int var4, int var5)\n\t{\n\t\twhile (var1.isAirBlock(var3, var4, var5) && var4 > 2)\n\t\t{\n\t\t\t--var4;\n\t\t}\n\t\tint var6 = var1.getBlockId(var3, var4, var5);\n\t\tint var95 = var1.getBlockId(var3 - 1, var4, var5);\n\t\tint var96 = var1.getBlockId(var3 + 1, var4, var5);\n\t\tint var97 = var1.getBlockId(var3, var4, var5 - 1);\n\t\tint var98 = var1.getBlockId(var3, var4, var5 + 1);\n\t\tif (var6 != Block.grass.blockID || var95 != Block.grass.blockID || var96 != Block.grass.blockID || var97 != Block.grass.blockID || var98 != Block.grass.blockID )\n\t\t\treturn false;\n\t\telse\n\t\t{\n\t\t\tfor (int var7 = -2; var7 <= 2; ++var7)\n\t\t\t{\n\t\t\t\tfor (int var8 = -2; var8 <= 2; ++var8)\n\t\t\t\t{\n\t\t\t\t\tif (var1.isAirBlock(var3 + var7, var4 - 1, var5 + var8) && var1.isAirBlock(var3 + var7, var4 - 2, var5 + var8))\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint var999 = var2.nextInt(2);\n\t\t\tif (var999 == 0)\n\t\t\t{\n\t\t\t\tvar1.setBlock(var3, var4, var5, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3 - 1, var4, var5, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3 + 1, var4, var5, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3, var4, var5 - 1, Block.dirt.blockID);\n\t\t\t\tvar1.setBlock(var3, var4, var5 + 1, Block.dirt.blockID);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3 + 1, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3 - 1, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5 + 1, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5 - 1, Block.stone.blockID, 0);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 2, var5, Block.stone.blockID, 0);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (var999 == 1)\n\t\t\t{\n\t\t\t\tvar1.setBlock(var3, var4, var5, Block.dirt.blockID);\n\t\t\t\tthis.setBlockAndMetadata(var1, var3, var4 + 1, var5, Block.stone.blockID, 0);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n"} {"input": " public void testParsingAndSearching() throws Exception {\n String field = \"content\";\n QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, field, new MockAnalyzer());\n qp.setAllowLeadingWildcard(true);\n String docs[] = {\n \"\\\\ abcdefg1\",\n \"\\\\79 hijklmn1\",\n \"\\\\\\\\ opqrstu1\",\n };\n String matchAll[] = {\n \"*\", \"*1\", \"**1\", \"*?\", \"*?1\", \"?*1\", \"**\", \"***\", \"\\\\\\\\*\"\n };\n String matchNone[] = {\n \"a*h\", \"a?h\", \"*a*h\", \"?a\", \"a?\",\n };\n String matchOneDocPrefix[][] = {\n {\"a*\", \"ab*\", \"abc*\", }, \n {\"h*\", \"hi*\", \"hij*\", \"\\\\\\\\7*\"}, \n {\"o*\", \"op*\", \"opq*\", \"\\\\\\\\\\\\\\\\*\"}, \n };\n String matchOneDocWild[][] = {\n {\"*a*\", \"*ab*\", \"*abc**\", \"ab*e*\", \"*g?\", \"*f?1\", \"abc**\"}, \n {\"*h*\", \"*hi*\", \"*hij**\", \"hi*k*\", \"*n?\", \"*m?1\", \"hij**\"}, \n {\"*o*\", \"*op*\", \"*opq**\", \"op*q*\", \"*u?\", \"*t?1\", \"opq**\"}, \n };\n Directory dir = newDirectory();\n RandomIndexWriter iw = new RandomIndexWriter(random, dir);\n for (int i = 0; i < docs.length; i++) {\n Document doc = new Document();\n doc.add(newField(field,docs[i],Store.NO,Index.ANALYZED));\n iw.addDocument(doc);\n }\n iw.close();\n IndexSearcher searcher = new IndexSearcher(dir, true);\n for (int i = 0; i < matchAll.length; i++) {\n String qtxt = matchAll[i];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"matchAll: qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(docs.length,hits.length);\n }\n for (int i = 0; i < matchNone.length; i++) {\n String qtxt = matchNone[i];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"matchNone: qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(0,hits.length);\n }\n for (int i = 0; i < matchOneDocPrefix.length; i++) {\n for (int j = 0; j < matchOneDocPrefix[i].length; j++) {\n String qtxt = matchOneDocPrefix[i][j];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"match 1 prefix: doc=\"+docs[i]+\" qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n assertEquals(PrefixQuery.class, q.getClass());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(1,hits.length);\n assertEquals(i,hits[0].doc);\n }\n }\n for (int i = 0; i < matchOneDocPrefix.length; i++) {\n for (int j = 0; j < matchOneDocWild[i].length; j++) {\n String qtxt = matchOneDocWild[i][j];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"match 1 wild: doc=\"+docs[i]+\" qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n assertEquals(WildcardQuery.class, q.getClass());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(1,hits.length);\n assertEquals(i,hits[0].doc);\n }\n }\n searcher.close();\n dir.close();\n }\n", "output": " public void testParsingAndSearching() throws Exception {\n String field = \"content\";\n QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, field, new MockAnalyzer());\n qp.setAllowLeadingWildcard(true);\n String docs[] = {\n \"\\\\ abcdefg1\",\n \"\\\\79 hijklmn1\",\n \"\\\\\\\\ opqrstu1\",\n };\n String matchAll[] = {\n \"*\", \"*1\", \"**1\", \"*?\", \"*?1\", \"?*1\", \"**\", \"***\", \"\\\\\\\\*\"\n };\n String matchNone[] = {\n \"a*h\", \"a?h\", \"*a*h\", \"?a\", \"a?\",\n };\n String matchOneDocPrefix[][] = {\n {\"a*\", \"ab*\", \"abc*\", }, \n {\"h*\", \"hi*\", \"hij*\", \"\\\\\\\\7*\"}, \n {\"o*\", \"op*\", \"opq*\", \"\\\\\\\\\\\\\\\\*\"}, \n };\n String matchOneDocWild[][] = {\n {\"*a*\", \"*ab*\", \"*abc**\", \"ab*e*\", \"*g?\", \"*f?1\", \"abc**\"}, \n {\"*h*\", \"*hi*\", \"*hij**\", \"hi*k*\", \"*n?\", \"*m?1\", \"hij**\"}, \n {\"*o*\", \"*op*\", \"*opq**\", \"op*q*\", \"*u?\", \"*t?1\", \"opq**\"}, \n };\n Directory dir = newDirectory();\n RandomIndexWriter iw = new RandomIndexWriter(random, dir, \n newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer())\n .setMergePolicy(newInOrderLogMergePolicy()));\n for (int i = 0; i < docs.length; i++) {\n Document doc = new Document();\n doc.add(newField(field,docs[i],Store.NO,Index.ANALYZED));\n iw.addDocument(doc);\n }\n iw.close();\n IndexSearcher searcher = new IndexSearcher(dir, true);\n for (int i = 0; i < matchAll.length; i++) {\n String qtxt = matchAll[i];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"matchAll: qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(docs.length,hits.length);\n }\n for (int i = 0; i < matchNone.length; i++) {\n String qtxt = matchNone[i];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"matchNone: qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(0,hits.length);\n }\n for (int i = 0; i < matchOneDocPrefix.length; i++) {\n for (int j = 0; j < matchOneDocPrefix[i].length; j++) {\n String qtxt = matchOneDocPrefix[i][j];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"match 1 prefix: doc=\"+docs[i]+\" qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n assertEquals(PrefixQuery.class, q.getClass());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(1,hits.length);\n assertEquals(i,hits[0].doc);\n }\n }\n for (int i = 0; i < matchOneDocPrefix.length; i++) {\n for (int j = 0; j < matchOneDocWild[i].length; j++) {\n String qtxt = matchOneDocWild[i][j];\n Query q = qp.parse(qtxt);\n if (VERBOSE) System.out.println(\"match 1 wild: doc=\"+docs[i]+\" qtxt=\"+qtxt+\" q=\"+q+\" \"+q.getClass().getName());\n assertEquals(WildcardQuery.class, q.getClass());\n ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;\n assertEquals(1,hits.length);\n assertEquals(i,hits[0].doc);\n }\n }\n searcher.close();\n dir.close();\n }\n"} {"input": " public void encodeChildren(FacesContext context, UIComponent component)\n throws IOException\n {\n if (!component.isRendered())\n {\n return;\n }\n String clientId = null;\n if (component.getId() != null &&\n !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))\n {\n clientId = component.getClientId(context);\n }\n ResponseWriter writer = context.getResponseWriter();\n if (clientId != null)\n {\n writer.startElement(\"div\", component);\n }\n List children = component.getChildren();\n String separator = (String) RendererUtil.getAttribute(context, component, \"separator\");\n if (separator==null) separator=\"\";\n boolean first = true;\n for (Iterator iter = children.iterator(); iter.hasNext();)\n {\n UIComponent child = (UIComponent)iter.next();\n if (child.isRendered()) {\n if (!first) writer.write(separator);\n RendererUtil.encodeRecursive(context, child);\n first = false;\n }\n } \n if (clientId != null)\n {\n writer.endElement(\"div\");\n }\n }\n", "output": " public void encodeChildren(FacesContext context, UIComponent component)\n throws IOException\n {\n if (!component.isRendered())\n {\n return;\n }\n String clientId = null;\n if (component.getId() != null &&\n !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))\n {\n clientId = component.getClientId(context);\n }\n ResponseWriter writer = context.getResponseWriter();\n if (clientId != null)\n {\n writer.startElement(\"div\", component);\n }\n List children = component.getChildren();\n String separator = (String) RendererUtil.getAttribute(context, component, \"separator\");\n if (separator==null) separator=\"\";\n boolean first = true;\n for (Iterator iter = children.iterator(); iter.hasNext();)\n {\n UIComponent child = (UIComponent)iter.next();\n if (child.isRendered()) {\n if (!first && separator !=null && separator != \"\") writer.write(\"<span class=\\\"separator\\\">\" + separator + \"</span>\");\n RendererUtil.encodeRecursive(context, child);\n first = false;\n }\n } \n if (clientId != null)\n {\n writer.endElement(\"div\");\n }\n }\n"} {"input": " protected void render(final PatchScript script, final PatchSetDetail detail) {\n final ArrayList<Object> lines = new ArrayList<Object>();\n final SafeHtmlBuilder nc = new SafeHtmlBuilder();\n allocateTableHeader(script, nc);\n lines.add(null);\n if (!isDisplayBinary) {\n if (script.getFileModeA() != FileMode.FILE\n || script.getFileModeB() != FileMode.FILE) {\n openLine(nc);\n appendModeLine(nc, script.getFileModeA());\n appendModeLine(nc, script.getFileModeB());\n closeLine(nc);\n lines.add(null);\n }\n if (hasDifferences(script)) {\n int lastA = 0;\n int lastB = 0;\n final boolean ignoreWS = script.isIgnoreWhitespace();\n a = getSparseHtmlFileA(script);\n b = getSparseHtmlFileB(script);\n final boolean intraline =\n script.getDiffPrefs().isIntralineDifference()\n && script.hasIntralineDifference();\n for (final EditList.Hunk hunk : script.getHunks()) {\n if (!hunk.isStartOfFile()) {\n appendSkipLine(nc, hunk.getCurB() - lastB);\n lines.add(new SkippedLine(lastA, lastB, hunk.getCurB() - lastB));\n }\n while (hunk.next()) {\n if (hunk.isContextLine()) {\n openLine(nc);\n final SafeHtml ctx = a.getSafeHtmlLine(hunk.getCurA());\n appendLineNumber(nc, hunk.getCurA(), false);\n appendLineText(nc, CONTEXT, ctx, false, false);\n if (ignoreWS && b.contains(hunk.getCurB())) {\n appendLineText(nc, CONTEXT, b, hunk.getCurB(), false);\n } else {\n appendLineText(nc, CONTEXT, ctx, false, false);\n }\n appendLineNumber(nc, hunk.getCurB(), true);\n closeLine(nc);\n hunk.incBoth();\n lines.add(new PatchLine(CONTEXT, hunk.getCurA(), hunk.getCurB()));\n } else if (hunk.isModifiedLine()) {\n final boolean del = hunk.isDeletedA();\n final boolean ins = hunk.isInsertedB();\n final boolean full =\n intraline && hunk.getCurEdit().getType() != Edit.Type.REPLACE;\n openLine(nc);\n if (del) {\n appendLineNumber(nc, hunk.getCurA(), false);\n appendLineText(nc, DELETE, a, hunk.getCurA(), full);\n hunk.incA();\n } else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {\n appendLineNumber(nc, false);\n appendLineNone(nc, DELETE);\n } else {\n appendLineNumber(nc, false);\n appendLineNone(nc, CONTEXT);\n }\n if (ins) {\n appendLineText(nc, INSERT, b, hunk.getCurB(), full);\n appendLineNumber(nc, hunk.getCurB(), true);\n hunk.incB();\n } else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {\n appendLineNone(nc, INSERT);\n appendLineNumber(nc, true);\n } else {\n appendLineNone(nc, CONTEXT);\n appendLineNumber(nc, true);\n }\n closeLine(nc);\n if (del && ins) {\n lines.add(new PatchLine(REPLACE, hunk.getCurA(), hunk.getCurB()));\n } else if (del) {\n lines.add(new PatchLine(DELETE, hunk.getCurA(), -1));\n } else if (ins) {\n lines.add(new PatchLine(INSERT, -1, hunk.getCurB()));\n }\n }\n }\n lastA = hunk.getCurA();\n lastB = hunk.getCurB();\n }\n if (lastB != b.size()) {\n appendSkipLine(nc, b.size() - lastB);\n lines.add(new SkippedLine(lastA, lastB, b.size() - lastB));\n }\n }\n }else{\n for (final String line : script.getPatchHeader()) {\n appendFileHeader(nc, line);\n }\n }\n if (!hasDifferences(script)) {\n appendNoDifferences(nc);\n }\n resetHtml(nc);\n populateTableHeader(script, detail);\n if (hasDifferences(script)) {\n initScript(script);\n if (!isDisplayBinary) {\n for (int row = 0; row < lines.size(); row++) {\n setRowItem(row, lines.get(row));\n if (lines.get(row) instanceof SkippedLine) {\n createSkipLine(row, (SkippedLine) lines.get(row));\n }\n }\n }\n }\n }\n", "output": " protected void render(final PatchScript script, final PatchSetDetail detail) {\n final ArrayList<Object> lines = new ArrayList<Object>();\n final SafeHtmlBuilder nc = new SafeHtmlBuilder();\n allocateTableHeader(script, nc);\n lines.add(null);\n if (!isDisplayBinary) {\n if (script.getFileModeA() != FileMode.FILE\n || script.getFileModeB() != FileMode.FILE) {\n openLine(nc);\n appendModeLine(nc, script.getFileModeA());\n appendModeLine(nc, script.getFileModeB());\n closeLine(nc);\n lines.add(null);\n }\n if (hasDifferences(script)) {\n int lastA = 0;\n int lastB = 0;\n final boolean ignoreWS = script.isIgnoreWhitespace();\n a = getSparseHtmlFileA(script);\n b = getSparseHtmlFileB(script);\n final boolean intraline =\n script.getDiffPrefs().isIntralineDifference()\n && script.hasIntralineDifference();\n for (final EditList.Hunk hunk : script.getHunks()) {\n if (!hunk.isStartOfFile()) {\n appendSkipLine(nc, hunk.getCurB() - lastB);\n lines.add(new SkippedLine(lastA, lastB, hunk.getCurB() - lastB));\n }\n while (hunk.next()) {\n if (hunk.isContextLine()) {\n openLine(nc);\n final SafeHtml ctx = a.getSafeHtmlLine(hunk.getCurA());\n appendLineNumber(nc, hunk.getCurA(), false);\n appendLineText(nc, CONTEXT, ctx, false, false);\n if (ignoreWS && b.contains(hunk.getCurB())) {\n appendLineText(nc, CONTEXT, b, hunk.getCurB(), false);\n } else {\n appendLineText(nc, CONTEXT, ctx, false, false);\n }\n appendLineNumber(nc, hunk.getCurB(), true);\n closeLine(nc);\n hunk.incBoth();\n lines.add(new PatchLine(CONTEXT, hunk.getCurA(), hunk.getCurB()));\n } else if (hunk.isModifiedLine()) {\n final boolean del = hunk.isDeletedA();\n final boolean ins = hunk.isInsertedB();\n final boolean full =\n intraline && hunk.getCurEdit().getType() != Edit.Type.REPLACE;\n openLine(nc);\n if (del) {\n appendLineNumber(nc, hunk.getCurA(), false);\n appendLineText(nc, DELETE, a, hunk.getCurA(), full);\n hunk.incA();\n } else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {\n appendLineNumber(nc, false);\n appendLineNone(nc, DELETE);\n } else {\n appendLineNumber(nc, false);\n appendLineNone(nc, CONTEXT);\n }\n if (ins) {\n appendLineText(nc, INSERT, b, hunk.getCurB(), full);\n appendLineNumber(nc, hunk.getCurB(), true);\n hunk.incB();\n } else if (hunk.getCurEdit().getType() == Edit.Type.REPLACE) {\n appendLineNone(nc, INSERT);\n appendLineNumber(nc, true);\n } else {\n appendLineNone(nc, CONTEXT);\n appendLineNumber(nc, true);\n }\n closeLine(nc);\n if (del && ins) {\n lines.add(new PatchLine(REPLACE, hunk.getCurA(), hunk.getCurB()));\n } else if (del) {\n lines.add(new PatchLine(DELETE, hunk.getCurA(), -1));\n } else if (ins) {\n lines.add(new PatchLine(INSERT, -1, hunk.getCurB()));\n }\n }\n }\n lastA = hunk.getCurA();\n lastB = hunk.getCurB();\n }\n if (lastB != b.size()) {\n appendSkipLine(nc, b.size() - lastB);\n lines.add(new SkippedLine(lastA, lastB, b.size() - lastB));\n }\n }\n } else {\n for (final String line : script.getPatchHeader()) {\n appendFileHeader(nc, line);\n }\n }\n if (!hasDifferences(script)) {\n appendNoDifferences(nc);\n }\n resetHtml(nc);\n populateTableHeader(script, detail);\n if (hasDifferences(script)) {\n initScript(script);\n if (!isDisplayBinary) {\n for (int row = 0; row < lines.size(); row++) {\n setRowItem(row, lines.get(row));\n if (lines.get(row) instanceof SkippedLine) {\n createSkipLine(row, (SkippedLine) lines.get(row));\n }\n }\n }\n }\n }\n"} {"input": "\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.random_choise);\n\t\tIntent intent = getIntent();\n\t\tmUri = intent.getData();\n\t\ttv = (TextView)findViewById(R.id.random_result);\n\t\tbuttonstart = (Button) findViewById(R.id.button_start);\n\t\tbuttonstart.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tmCursor = managedQuery(mUri, FoodColumn.PROJECTION, null, null, null);\n\t\t\t\tmCursor.moveToFirst();\n\t\t\t\tmax = mCursor.getCount();\n\t\t\t\tlong id = numx.nextInt(max)+1;\n\t\t\t\tUri uri = ContentUris.withAppendedId(getIntent().getData(), id);\n\t\t\t\tmCursor = managedQuery(uri, FoodColumn.PROJECTION, null, null, null);\n\t\t\t\tLog.e(TAG + \":onCreate\", mCursor.toString() + \" \" + id + max);\n\t\t\t\tmCursor.moveToFirst();\n\t\t\t\trandom_result = mCursor.getString(FoodColumn.NAME_COLUMN);\n\t\t\t\ttv.setText(random_result);\n\t\t\t}\n\t\t});\n\t}\n", "output": "\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tsetContentView(R.layout.random_choise);\n\t\tIntent intent = getIntent();\n\t\tmUri = intent.getData();\n\t\ttv = (TextView)findViewById(R.id.random_result);\n\t\tbuttonstart = (Button) findViewById(R.id.button_start);\n\t\tbuttonstart.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tmCursor = managedQuery(mUri, FoodColumn.PROJECTION, null, null, null);\n\t\t\t\tmCursor.moveToFirst();\n\t\t\t\tmax = mCursor.getCount();\n\t\t\t\tlong id = numx.nextInt(max);\n\t\t\t\twhile(id>0){\n\t\t\t\t\tmCursor.moveToNext();\n\t\t\t\t\tid=id-1;\n\t\t\t\t}\n\t\t\t\trandom_result = mCursor.getString(FoodColumn.NAME_COLUMN);\n\t\t\t\ttv.setText(random_result);\n\t\t\t}\n\t\t});\n\t}\n"} {"input": " protected boolean moveRobot(State st, Command cmd) {\n int nextCol;\n int nextRow;\n switch (cmd) {\n case Left:\n nextCol = st.robotCol - 1;\n nextRow = st.robotRow;\n break;\n case Right:\n nextCol = st.robotCol + 1;\n nextRow = st.robotRow;\n break;\n case Up:\n nextCol = st.robotCol;\n nextRow = st.robotRow + 1;\n break;\n case Down:\n nextCol = st.robotCol;\n nextRow = st.robotRow - 1;\n break;\n case Wait:\n return true;\n case Abort:\n st.ending = Ending.Abort;\n return true;\n case Shave:\n st.shaveBeard(st.robotCol, st.robotRow);\n return true;\n default:\n throw new IllegalArgumentException(\"Unknown command \" + cmd);\n }\n Cell next = st.board.get(nextCol, nextRow); \n switch (next) {\n case Lambda:\n ++st.collectedLambdas;\n st.removeLambda(nextCol, nextRow);\n case Empty:\n case Earth:\n moveRobot(st, nextCol, nextRow);\n return true;\n case Lift:\n if (st.lambdaPositions.isEmpty() && st.board.bitsets[Cell.HoRock.ordinal()].isEmpty() && st.board.bitsets[Cell.FallingHoRock.ordinal()].isEmpty()) {\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n return false;\n case Razor:\n ++st.board.razors;\n moveRobot(st, nextCol, nextRow);\n return true;\n case Rock:\n case FallingRock:\n if (cmd == Command.Left && st.board.get(nextCol - 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol - 1, nextRow, Cell.FallingRock);\n fallingPosition(st, nextCol - 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n if (cmd == Command.Right && st.board.get(nextCol + 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol + 1, nextRow, Cell.FallingRock);\n fallingPosition(st, nextCol + 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n case HoRock:\n case FallingHoRock:\n if (cmd == Command.Left && st.board.get(nextCol - 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol - 1, nextRow, Cell.FallingHoRock);\n fallingPosition(st, nextCol - 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n if (cmd == Command.Right && st.board.get(nextCol + 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol + 1, nextRow, Cell.FallingHoRock);\n fallingPosition(st, nextCol + 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n case Target:\n return false;\n case Trampoline:\n int trampolinePos = st.board.position(nextCol, nextRow);\n String trampoline = st.board.trampolinePos.get(trampolinePos);\n st.board.set(nextCol, nextRow, Cell.Empty);\n String target = st.board.trampolineTargets.get(trampoline);\n int jumpPos = st.board.targetPos.get(target);\n st.board.set(jumpPos, Cell.Empty);\n int jumpCol = st.board.col(jumpPos);\n int jumpRow = st.board.row(jumpPos);\n moveRobot(st, jumpCol, jumpRow);\n removeTrampolines(target, st);\n return true;\n default:\n return false;\n }\n }\n", "output": " protected boolean moveRobot(State st, Command cmd) {\n int nextCol;\n int nextRow;\n switch (cmd) {\n case Left:\n nextCol = st.robotCol - 1;\n nextRow = st.robotRow;\n break;\n case Right:\n nextCol = st.robotCol + 1;\n nextRow = st.robotRow;\n break;\n case Up:\n nextCol = st.robotCol;\n nextRow = st.robotRow + 1;\n break;\n case Down:\n nextCol = st.robotCol;\n nextRow = st.robotRow - 1;\n break;\n case Wait:\n return true;\n case Abort:\n st.ending = Ending.Abort;\n return true;\n case Shave:\n return st.shaveBeard(st.robotCol, st.robotRow);\n default:\n throw new IllegalArgumentException(\"Unknown command \" + cmd);\n }\n Cell next = st.board.get(nextCol, nextRow); \n switch (next) {\n case Lambda:\n ++st.collectedLambdas;\n st.removeLambda(nextCol, nextRow);\n case Empty:\n case Earth:\n moveRobot(st, nextCol, nextRow);\n return true;\n case Lift:\n if (st.lambdaPositions.isEmpty() && st.board.bitsets[Cell.HoRock.ordinal()].isEmpty() && st.board.bitsets[Cell.FallingHoRock.ordinal()].isEmpty()) {\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n return false;\n case Razor:\n ++st.board.razors;\n moveRobot(st, nextCol, nextRow);\n return true;\n case Rock:\n case FallingRock:\n if (cmd == Command.Left && st.board.get(nextCol - 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol - 1, nextRow, Cell.FallingRock);\n fallingPosition(st, nextCol - 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n if (cmd == Command.Right && st.board.get(nextCol + 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol + 1, nextRow, Cell.FallingRock);\n fallingPosition(st, nextCol + 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n case HoRock:\n case FallingHoRock:\n if (cmd == Command.Left && st.board.get(nextCol - 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol - 1, nextRow, Cell.FallingHoRock);\n fallingPosition(st, nextCol - 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n if (cmd == Command.Right && st.board.get(nextCol + 1, nextRow) == Cell.Empty) {\n st.board.set(nextCol + 1, nextRow, Cell.FallingHoRock);\n fallingPosition(st, nextCol + 1, nextRow);\n moveRobot(st, nextCol, nextRow);\n return true;\n }\n case Target:\n return false;\n case Trampoline:\n int trampolinePos = st.board.position(nextCol, nextRow);\n String trampoline = st.board.trampolinePos.get(trampolinePos);\n st.board.set(nextCol, nextRow, Cell.Empty);\n String target = st.board.trampolineTargets.get(trampoline);\n int jumpPos = st.board.targetPos.get(target);\n st.board.set(jumpPos, Cell.Empty);\n int jumpCol = st.board.col(jumpPos);\n int jumpRow = st.board.row(jumpPos);\n moveRobot(st, jumpCol, jumpRow);\n removeTrampolines(target, st);\n return true;\n default:\n return false;\n }\n }\n"} {"input": " private PluginDescriptor getPluginDescriptor(String groupId, String artifactId, String version) {\n String name = groupId + \":\" + artifactId + \":\" + version;\n PluginDescriptor descriptor = descriptors.get(name);\n if(descriptor!=null) {\n return descriptor;\n }\n MavenPlugin plugin = MavenPlugin.getDefault();\n MavenConsole console = plugin.getConsole();\n try {\n IMaven embedder = MavenPlugin.lookup(IMaven.class);\n IndexManager indexManager = MavenPlugin.getDefault().getIndexManager();\n List<ArtifactRepository> repositories = indexManager.getArtifactRepositories(null, null);\n Artifact artifact = embedder.resolve(groupId, artifactId, version, null, \"maven-plugin\", repositories, null);\n File file = artifact.getFile();\n if(file == null) {\n String msg = \"Can't resolve plugin \" + name;\n console.logError(msg);\n } else {\n InputStream is = null;\n ZipFile zf = null;\n try {\n zf = new ZipFile(file);\n ZipEntry entry = zf.getEntry(\"META-INF/maven/plugin.xml\");\n if(entry != null) {\n is = zf.getInputStream(entry);\n PluginDescriptorBuilder builder = new PluginDescriptorBuilder();\n descriptor = builder.build(new InputStreamReader(is));\n descriptors.put(name, descriptor);\n return descriptor;\n }\n } catch(Exception ex) {\n String msg = \"Can't read configuration for \" + name;\n console.logError(msg);\n MavenLogger.log(msg, ex);\n } finally {\n IOUtil.close(is);\n try {\n zf.close();\n } catch(IOException ex) {\n }\n }\n }\n } catch(CoreException ex) {\n IStatus status = ex.getStatus();\n console.logError(status.getMessage() + \"; \" + status.getException().getMessage());\n MavenLogger.log(ex);\n }\n return null;\n }\n", "output": " private PluginDescriptor getPluginDescriptor(String groupId, String artifactId, String version) {\n String name = groupId + \":\" + artifactId + \":\" + version;\n PluginDescriptor descriptor = descriptors.get(name);\n if(descriptor!=null) {\n return descriptor;\n }\n MavenPlugin plugin = MavenPlugin.getDefault();\n MavenConsole console = plugin.getConsole();\n try {\n IMaven embedder = MavenPlugin.lookup(IMaven.class);\n IndexManager indexManager = MavenPlugin.getDefault().getIndexManager();\n List<ArtifactRepository> repositories = indexManager.getArtifactRepositories(null, null);\n Artifact artifact = embedder.resolve(groupId, artifactId, version, \"maven-plugin\", null, repositories, null);\n File file = artifact.getFile();\n if(file == null) {\n String msg = \"Can't resolve plugin \" + name;\n console.logError(msg);\n } else {\n InputStream is = null;\n ZipFile zf = null;\n try {\n zf = new ZipFile(file);\n ZipEntry entry = zf.getEntry(\"META-INF/maven/plugin.xml\");\n if(entry != null) {\n is = zf.getInputStream(entry);\n PluginDescriptorBuilder builder = new PluginDescriptorBuilder();\n descriptor = builder.build(new InputStreamReader(is));\n descriptors.put(name, descriptor);\n return descriptor;\n }\n } catch(Exception ex) {\n String msg = \"Can't read configuration for \" + name;\n console.logError(msg);\n MavenLogger.log(msg, ex);\n } finally {\n IOUtil.close(is);\n try {\n zf.close();\n } catch(IOException ex) {\n }\n }\n }\n } catch(CoreException ex) {\n IStatus status = ex.getStatus();\n console.logError(status.getMessage() + \"; \" + status.getException().getMessage());\n MavenLogger.log(ex);\n }\n return null;\n }\n"} {"input": " public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {\n if (config.getMainConfig().isSpectatorsChatHidden() && pm.getGamer((Player) sender).isSpectator()) {\n sender.sendMessage(tm.getCommandMeSpectating());\n return true;\n }\n Bukkit.broadcastMessage(\"* \" + ((Player) sender).getDisplayName() + ChatColor.RESET + \" \" + StringUtils.join(args, \" \"));\n return true;\n }\n", "output": " public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {\n if (config.getMainConfig().isSpectatorsChatHidden() && pm.getGamer((Player) sender).isSpectator()) {\n sender.sendMessage(tm.getCommandMeSpectating());\n return true;\n }\n if (args.length == 0) {\n return false;\n } else {\n Bukkit.broadcastMessage(\"* \" + ((Player) sender).getDisplayName() + ChatColor.RESET + \" \" + StringUtils.join(args, \" \"));\n return true;\n }\n }\n"} {"input": "\t\tprotected SelectEvent select()\n\t\t{\n\t\t\tif (getHandlerCount(SelectEvent.getType()) > 0)\n\t\t\t{\n\t\t\t\treturn SelectEvent.fire(this);\n\t\t\t}\n\t\t\telse if (!StringUtils.isEmpty(getHref()))\n\t\t\t{\n\t\t\t\tif (!StringUtils.isEmpty(getTarget()))\n\t\t\t\t{\n\t\t\t\t\tWindow.open(getHref(), getTarget(), null);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tWindow.Location.assign(getHref());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n", "output": "\t\tprotected SelectEvent select()\n\t\t{\n\t\t\tif (getHandlerCount(SelectEvent.getType()) > 0)\n\t\t\t{\n\t\t\t\treturn SelectEvent.fire(this);\n\t\t\t}\n\t\t\telse if (!StringUtils.isEmpty(getHref()))\n\t\t\t{\n\t\t\t\tif (!StringUtils.isEmpty(getTarget()))\n\t\t\t\t{\n\t\t\t\t\tWindow.open(getHref(), getTarget(), \"\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tWindow.Location.assign(getHref());\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n"} {"input": "\tprivate void runWithSelection(final Object selectedObject) {\n\t\tAbstractTask repositoryTask = null;\n\t\tif (selectedObject instanceof TaskEditor) {\n\t\t\tTaskEditor editor = (TaskEditor) selectedObject;\n\t\t\tAbstractTask task = editor.getTaskEditorInput().getTask();\n\t\t\tif (task != null) {\n\t\t\t\trepositoryTask = task;\n\t\t\t}\n\t\t} else if (selectedObject instanceof AbstractRepositoryTaskEditor) {\n\t\t\tAbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) selectedObject;\n\t\t\trepositoryTask = editor.getRepositoryTask();\n\t\t}\n\t\tif (repositoryTask != null) {\n\t\t\tAbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(\n\t\t\t\t\trepositoryTask.getConnectorKind());\n\t\t\tif (connector != null) {\n\t\t\t\tTasksUiPlugin.getSynchronizationManager().synchronize(connector, repositoryTask, false,\n\t\t\t\t\t\tnew JobChangeAdapter() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void done(IJobChangeEvent event) {\n\t\t\t\t\t\t\t\tPlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\tif (selectedObject instanceof TaskEditor) {\n\t\t\t\t\t\t\t\t\t\t\tTaskEditor editor = (TaskEditor) selectedObject;\n\t\t\t\t\t\t\t\t\t\t\teditor.refreshEditorContents();\n\t\t\t\t\t\t\t\t\t\t} else if (selectedObject instanceof AbstractRepositoryTaskEditor) {\n\t\t\t\t\t\t\t\t\t\t\t((AbstractRepositoryTaskEditor) selectedObject).refreshEditor();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void runWithSelection(final Object selectedObject) {\n\t\tAbstractTask repositoryTask = null;\n\t\tif (selectedObject instanceof TaskEditor) {\n\t\t\tTaskEditor editor = (TaskEditor) selectedObject;\n\t\t\tAbstractTask task = editor.getTaskEditorInput().getTask();\n\t\t\tif (task != null) {\n\t\t\t\trepositoryTask = task;\n\t\t\t}\n\t\t} else if (selectedObject instanceof AbstractRepositoryTaskEditor) {\n\t\t\tAbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) selectedObject;\n\t\t\trepositoryTask = editor.getRepositoryTask();\n\t\t}\n\t\tif (repositoryTask != null) {\n\t\t\tAbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(\n\t\t\t\t\trepositoryTask.getConnectorKind());\n\t\t\tif (connector != null) {\n\t\t\t\tTasksUiPlugin.getSynchronizationManager().synchronize(connector, repositoryTask, true,\n\t\t\t\t\t\tnew JobChangeAdapter() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void done(IJobChangeEvent event) {\n\t\t\t\t\t\t\t\tPlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {\n\t\t\t\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\t\t\t\tif (selectedObject instanceof TaskEditor) {\n\t\t\t\t\t\t\t\t\t\t\tTaskEditor editor = (TaskEditor) selectedObject;\n\t\t\t\t\t\t\t\t\t\t\teditor.refreshEditorContents();\n\t\t\t\t\t\t\t\t\t\t} else if (selectedObject instanceof AbstractRepositoryTaskEditor) {\n\t\t\t\t\t\t\t\t\t\t\t((AbstractRepositoryTaskEditor) selectedObject).refreshEditor();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public EndResettingEvent(World world, short dragonAmount, String message){\n this.world = world;\n this.dragonAmount = dragonAmount;\n }\n", "output": " public EndResettingEvent(World world, short dragonAmount, String message){\n this.world = world;\n this.dragonAmount = dragonAmount;\n this.message = message;\n }\n"} {"input": "\tpublic void load(FMLInitializationEvent event)\n\t{\n\t\taddArmorItem(obsidianHelmet, new ItemStack(Block.obsidian), \"Obsidian Helmet\", 0);\n\t\taddArmorItem(obsidianChestplate, new ItemStack(Block.obsidian), \"Obsidian Chestplate\", 1);\n\t\taddArmorItem(obsidianLeggings, new ItemStack(Block.obsidian), \"Obsidian Leggings\", 2);\n\t\taddArmorItem(obsidianBoots, new ItemStack(Block.obsidian), \"Obsidian Boots\", 3);\n\t\taddArmorItem(redstoneHelmet, new ItemStack(Item.redstone), \"Redstone Helmet\", 0);\n\t\taddArmorItem(redstoneChestplate, new ItemStack(Item.redstone), \"Redstone Chestplate\", 1);\n\t\taddArmorItem(redstoneLeggings, new ItemStack(Item.redstone), \"Redstone Leggings\", 2);\n\t\taddArmorItem(redstoneBoots, new ItemStack(Item.redstone), \"Redstone Boots\", 3);\n\t\taddArmorItem(coalHelmet, new ItemStack(Item.coal), \"Coal Helmet\", 0);\n\t\taddArmorItem(coalChestplate, new ItemStack(Item.coal), \"Coal Chestplate\", 1);\n\t\taddArmorItem(coalLeggings, new ItemStack(Item.coal), \"Coal Leggings\", 2);\n\t\taddArmorItem(coalBoots, new ItemStack(Item.coal), \"Coal Boots\", 3);\n\t\taddArmorItem(lapisHelmet, new ItemStack(Block.blockLapis), \"Lapis Helmet\", 0);\n\t\taddArmorItem(lapisChestplate, new ItemStack(Block.blockLapis), \"Lapis Chestplate\", 1);\n\t\taddArmorItem(lapisLeggings, new ItemStack(Block.blockLapis), \"Lapis Leggings\", 2);\n\t\taddArmorItem(lapisBoots, new ItemStack(Block.blockLapis), \"Lapis Boots\", 3);\n\t\taddArmorItem(enderHelmet, new ItemStack(Item.enderPearl), \"Ender Helmet\", 0);\n\t\taddArmorItem(enderChestplate, new ItemStack(Item.enderPearl), \"Ender Chestplate\", 1);\n\t\taddArmorItem(enderLeggings, new ItemStack(Item.enderPearl), \"Ender Leggings\", 2);\n\t\taddArmorItem(enderBoots, new ItemStack(Item.enderPearl), \"Ender Boots\", 3);\n\t\taddArmorItem(spaceHelmet, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Helmet\", 0);\n\t\taddArmorItem(spaceChestplate, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Chestplate\", 1);\n\t\taddArmorItem(spaceLeggings, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Leggings\", 2);\n\t\taddArmorItem(spaceBoots, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Boots\", 3);\n\t\taddArmorItem(boneHelmet, new ItemStack(Item.bone), \"Bone Helmet\", 0);\n\t\taddArmorItem(boneChestplate, new ItemStack(Item.bone), \"Bone Chestplate\", 1);\n\t\taddArmorItem(boneLeggings, new ItemStack(Item.bone), \"Bone Leggings\", 2);\n\t\taddArmorItem(boneBoots, new ItemStack(Item.bone), \"Bone Boots\", 3);\n\t\taddArmorItem(sugarcaneHelmet, new ItemStack(Item.reed), \"Sugarcane Helmet\", 0);\n\t\taddArmorItem(sugarcaneChestplate, new ItemStack(Item.reed), \"Sugarcane Chestplate\", 1);\n\t\taddArmorItem(sugarcaneLeggings, new ItemStack(Item.reed), \"Sugarcane Leggings\", 2);\n\t\taddArmorItem(sugarcaneBoots, new ItemStack(Item.reed), \"Sugarcane Boots\", 3);\n\t\taddArmorItem(blazerodHelmet, new ItemStack(Item.blazeRod), \"Blaze Helmet\", 0);\n\t\taddArmorItem(blazerodChestplate, new ItemStack(Item.blazeRod), \"Blaze Chestplate\", 1);\n\t\taddArmorItem(blazerodLeggings, new ItemStack(Item.blazeRod), \"Blaze Leggings\", 2);\n\t\taddArmorItem(blazerodBoots, new ItemStack(Item.blazeRod), \"Blaze Boots\", 3);\n\t\taddArmorItem(dirtHelmet, new ItemStack(Block.dirt), \"Dirt Helmet\", 0);\n\t\taddArmorItem(dirtChestplate, new ItemStack(Block.dirt), \"Dirt Chestplate\", 1);\n\t\taddArmorItem(dirtLeggings, new ItemStack(Block.dirt), \"Dirt Leggings\", 2);\n\t\taddArmorItem(dirtBoots, new ItemStack(Block.dirt), \"Dirt Boots\", 3);\n\t\taddArmorItem(glassHelmet, new ItemStack(Block.glass), \"Glass Helmet\", 0);\n\t\taddArmorItem(glassChestplate, new ItemStack(Block.glass), \"Glass Chestplate\", 1);\n\t\taddArmorItem(glassLeggings, new ItemStack(Block.glass), \"Glass Leggings\", 2);\n\t\taddArmorItem(glassBoots, new ItemStack(Block.glass), \"Glass Boots\", 3);\n\t\taddArmorItem(sandstoneHelmet, new ItemStack(Block.sandStone), \"Sandstone Helmet\", 0);\n\t\taddArmorItem(sandstoneChestplate, new ItemStack(Block.sandStone), \"Sandstone Chestplate\", 1);\n\t\taddArmorItem(sandstoneLeggings, new ItemStack(Block.sandStone), \"Sandstone Leggings\", 2);\n\t\taddArmorItem(sandstoneBoots, new ItemStack(Block.sandStone), \"Sandstone Boots\", 3);\n\t\taddArmorItem(brickHelmet, new ItemStack(Item.brick), \"Brick Helmet\", 0);\n\t\taddArmorItem(brickChestplate, new ItemStack(Item.brick), \"Brick Chestplate\", 1);\n\t\taddArmorItem(brickLeggings, new ItemStack(Item.brick), \"Brick Leggings\", 2);\n\t\taddArmorItem(brickBoots, new ItemStack(Item.brick), \"Brick Boots\", 3);\n\t\taddArmorItem(endstoneHelmet, new ItemStack(Block.whiteStone), \"Endstone Helmet\", 0);\n\t\taddArmorItem(endstoneChestplate, new ItemStack(Block.whiteStone), \"Endstone Chestplate\", 1);\n\t\taddArmorItem(endstoneLeggings, new ItemStack(Block.whiteStone), \"Endstone Leggings\", 2);\n\t\taddArmorItem(endstoneBoots, new ItemStack(Block.whiteStone), \"Endstone Boots\", 3);\n\t\taddName(hallowedHelmet, \"God's Helmet\");\n\t\taddName(hallowedChestplate, \"God's Chestplate\");\n\t\taddName(hallowedLeggings, \"God's Leggings\");\n\t\taddName(hallowedBoots, \"God's Boots\");\n\t\tModLoader.addRecipe(new ItemStack(hallowedHelmet, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(hallowedChestplate, 1), new Object[]{\n\t\t\t\"XxX\",\n\t\t\t\"XXX\",\n\t\t\t\"XXX\",\n\t\t\tCharacter.valueOf('x'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(hallowedLeggings, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(hallowedHelmet, 1), new Object[]{\n\t\t\t\"x x\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\taddName(goddawnHelmet, \"Luzifer's Helmet\");\n\t\taddName(goddawnChestplate, \"Luzifer's Chestplate\");\n\t\taddName(goddawnLeggings, \"Luzifer's Leggings\");\n\t\taddName(goddawnBoots, \"Luzifer's Boots\");\n\t\tModLoader.addRecipe(new ItemStack(goddawnHelmet, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(goddawnChestplate, 1), new Object[]{\n\t\t\t\"XxX\",\n\t\t\t\"XXX\",\n\t\t\t\"XXX\",\n\t\t\tCharacter.valueOf('x'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(goddawnLeggings, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(goddawnHelmet, 1), new Object[]{\n\t\t\t\"x x\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tCSItems.addItemWithRecipe(invisibilityHelmet, 0, \"Invisibility Helmet\", 1, new Object[] { \"XxX\", \"X X\", 'X', Item.ingotIron, 'x', Item.diamond });\n", "output": "\tpublic void load(FMLInitializationEvent event)\n\t{\n\t\taddArmorItem(obsidianHelmet, new ItemStack(Block.obsidian), \"Obsidian Helmet\", 0);\n\t\taddArmorItem(obsidianChestplate, new ItemStack(Block.obsidian), \"Obsidian Chestplate\", 1);\n\t\taddArmorItem(obsidianLeggings, new ItemStack(Block.obsidian), \"Obsidian Leggings\", 2);\n\t\taddArmorItem(obsidianBoots, new ItemStack(Block.obsidian), \"Obsidian Boots\", 3);\n\t\taddArmorItem(redstoneHelmet, new ItemStack(Item.redstone), \"Redstone Helmet\", 0);\n\t\taddArmorItem(redstoneChestplate, new ItemStack(Item.redstone), \"Redstone Chestplate\", 1);\n\t\taddArmorItem(redstoneLeggings, new ItemStack(Item.redstone), \"Redstone Leggings\", 2);\n\t\taddArmorItem(redstoneBoots, new ItemStack(Item.redstone), \"Redstone Boots\", 3);\n\t\taddArmorItem(coalHelmet, new ItemStack(Item.coal), \"Coal Helmet\", 0);\n\t\taddArmorItem(coalChestplate, new ItemStack(Item.coal), \"Coal Chestplate\", 1);\n\t\taddArmorItem(coalLeggings, new ItemStack(Item.coal), \"Coal Leggings\", 2);\n\t\taddArmorItem(coalBoots, new ItemStack(Item.coal), \"Coal Boots\", 3);\n\t\taddArmorItem(lapisHelmet, new ItemStack(Block.blockLapis), \"Lapis Helmet\", 0);\n\t\taddArmorItem(lapisChestplate, new ItemStack(Block.blockLapis), \"Lapis Chestplate\", 1);\n\t\taddArmorItem(lapisLeggings, new ItemStack(Block.blockLapis), \"Lapis Leggings\", 2);\n\t\taddArmorItem(lapisBoots, new ItemStack(Block.blockLapis), \"Lapis Boots\", 3);\n\t\taddArmorItem(enderHelmet, new ItemStack(Item.enderPearl), \"Ender Helmet\", 0);\n\t\taddArmorItem(enderChestplate, new ItemStack(Item.enderPearl), \"Ender Chestplate\", 1);\n\t\taddArmorItem(enderLeggings, new ItemStack(Item.enderPearl), \"Ender Leggings\", 2);\n\t\taddArmorItem(enderBoots, new ItemStack(Item.enderPearl), \"Ender Boots\", 3);\n\t\taddArmorItem(spaceHelmet, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Helmet\", 0);\n\t\taddArmorItem(spaceChestplate, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Chestplate\", 1);\n\t\taddArmorItem(spaceLeggings, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Leggings\", 2);\n\t\taddArmorItem(spaceBoots, new ItemStack(MoreToolsMod_Tools.spaceIngot), \"Space Boots\", 3);\n\t\taddArmorItem(boneHelmet, new ItemStack(Item.bone), \"Bone Helmet\", 0);\n\t\taddArmorItem(boneChestplate, new ItemStack(Item.bone), \"Bone Chestplate\", 1);\n\t\taddArmorItem(boneLeggings, new ItemStack(Item.bone), \"Bone Leggings\", 2);\n\t\taddArmorItem(boneBoots, new ItemStack(Item.bone), \"Bone Boots\", 3);\n\t\taddArmorItem(sugarcaneHelmet, new ItemStack(Item.reed), \"Sugarcane Helmet\", 0);\n\t\taddArmorItem(sugarcaneChestplate, new ItemStack(Item.reed), \"Sugarcane Chestplate\", 1);\n\t\taddArmorItem(sugarcaneLeggings, new ItemStack(Item.reed), \"Sugarcane Leggings\", 2);\n\t\taddArmorItem(sugarcaneBoots, new ItemStack(Item.reed), \"Sugarcane Boots\", 3);\n\t\taddArmorItem(blazerodHelmet, new ItemStack(Item.blazeRod), \"Blaze Helmet\", 0);\n\t\taddArmorItem(blazerodChestplate, new ItemStack(Item.blazeRod), \"Blaze Chestplate\", 1);\n\t\taddArmorItem(blazerodLeggings, new ItemStack(Item.blazeRod), \"Blaze Leggings\", 2);\n\t\taddArmorItem(blazerodBoots, new ItemStack(Item.blazeRod), \"Blaze Boots\", 3);\n\t\taddArmorItem(dirtHelmet, new ItemStack(Block.dirt), \"Dirt Helmet\", 0);\n\t\taddArmorItem(dirtChestplate, new ItemStack(Block.dirt), \"Dirt Chestplate\", 1);\n\t\taddArmorItem(dirtLeggings, new ItemStack(Block.dirt), \"Dirt Leggings\", 2);\n\t\taddArmorItem(dirtBoots, new ItemStack(Block.dirt), \"Dirt Boots\", 3);\n\t\taddArmorItem(glassHelmet, new ItemStack(Block.glass), \"Glass Helmet\", 0);\n\t\taddArmorItem(glassChestplate, new ItemStack(Block.glass), \"Glass Chestplate\", 1);\n\t\taddArmorItem(glassLeggings, new ItemStack(Block.glass), \"Glass Leggings\", 2);\n\t\taddArmorItem(glassBoots, new ItemStack(Block.glass), \"Glass Boots\", 3);\n\t\taddArmorItem(sandstoneHelmet, new ItemStack(Block.sandStone), \"Sandstone Helmet\", 0);\n\t\taddArmorItem(sandstoneChestplate, new ItemStack(Block.sandStone), \"Sandstone Chestplate\", 1);\n\t\taddArmorItem(sandstoneLeggings, new ItemStack(Block.sandStone), \"Sandstone Leggings\", 2);\n\t\taddArmorItem(sandstoneBoots, new ItemStack(Block.sandStone), \"Sandstone Boots\", 3);\n\t\taddArmorItem(brickHelmet, new ItemStack(Item.brick), \"Brick Helmet\", 0);\n\t\taddArmorItem(brickChestplate, new ItemStack(Item.brick), \"Brick Chestplate\", 1);\n\t\taddArmorItem(brickLeggings, new ItemStack(Item.brick), \"Brick Leggings\", 2);\n\t\taddArmorItem(brickBoots, new ItemStack(Item.brick), \"Brick Boots\", 3);\n\t\taddArmorItem(endstoneHelmet, new ItemStack(Block.whiteStone), \"Endstone Helmet\", 0);\n\t\taddArmorItem(endstoneChestplate, new ItemStack(Block.whiteStone), \"Endstone Chestplate\", 1);\n\t\taddArmorItem(endstoneLeggings, new ItemStack(Block.whiteStone), \"Endstone Leggings\", 2);\n\t\taddArmorItem(endstoneBoots, new ItemStack(Block.whiteStone), \"Endstone Boots\", 3);\n\t\taddName(hallowedHelmet, \"God's Helmet\");\n\t\taddName(hallowedChestplate, \"God's Chestplate\");\n\t\taddName(hallowedLeggings, \"God's Leggings\");\n\t\taddName(hallowedBoots, \"God's Boots\");\n\t\tModLoader.addRecipe(new ItemStack(hallowedHelmet, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('X'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(hallowedChestplate, 1), new Object[]{\n\t\t\t\"XxX\",\n\t\t\t\"XXX\",\n\t\t\t\"XXX\",\n\t\t\tCharacter.valueOf('X'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(hallowedLeggings, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('X'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(hallowedHelmet, 1), new Object[]{\n\t\t\t\"x x\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('X'), Block.blockGold,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\taddName(goddawnHelmet, \"Luzifer's Helmet\");\n\t\taddName(goddawnChestplate, \"Luzifer's Chestplate\");\n\t\taddName(goddawnLeggings, \"Luzifer's Leggings\");\n\t\taddName(goddawnBoots, \"Luzifer's Boots\");\n\t\tModLoader.addRecipe(new ItemStack(goddawnHelmet, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('X'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(goddawnChestplate, 1), new Object[]{\n\t\t\t\"XxX\",\n\t\t\t\"XXX\",\n\t\t\t\"XXX\",\n\t\t\tCharacter.valueOf('X'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(goddawnLeggings, 1), new Object[]{\n\t\t\t\"XXX\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('X'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tModLoader.addRecipe(new ItemStack(goddawnHelmet, 1), new Object[]{\n\t\t\t\"x x\",\n\t\t\t\"XxX\",\n\t\t\t\"XxX\",\n\t\t\tCharacter.valueOf('x'), Block.netherrack,\n\t\t\tCharacter.valueOf('x'), Item.redstone\n\t\t});\n\t\tCSItems.addItemWithRecipe(invisibilityHelmet, 0, \"Invisibility Helmet\", 1, new Object[] { \"XxX\", \"X X\", 'X', Item.ingotIron, 'x', Item.diamond });\n"} {"input": "\tpublic void obscureRect(Rect rect, Canvas canvas) {\n\t\ttry\n\t\t{\n\t\t Bitmap mask = loadBitmap(_context,\"party.png\");\n\t\t canvas.drawBitmap(mask, null, rect, _painter);\n\t\t}\n\t\tcatch (IOException e)\n\t\t{\n\t\t\tLog.e(\"anon\",e.toString(),e);\n\t\t}\n\t}\n", "output": "\tpublic void obscureRect(Rect rect, Canvas canvas) {\n\t\ttry\n\t\t{\n\t\t Bitmap mask = loadBitmap(_context,\"anon.png\");\n\t\t canvas.drawBitmap(mask, null, rect, _painter);\n\t\t}\n\t\tcatch (IOException e)\n\t\t{\n\t\t\tLog.e(\"anon\",e.toString(),e);\n\t\t}\n\t}\n"} {"input": "\tpublic static Boolean run(CommandSender sender, String alias, String[] args) {\n\t\tif(Vault.permsEnabled() != true) {\n\t\t\t LogHelper.logSevere(_(\"permissionsNotFound\", \"\"));\n\t\t\t LogHelper.showWarning(\"permissionsNotFound\", sender);\n\t\t}\n\t\tif(args.length==0) {\n\t\t\tCommands.showCommandHelpAndUsage(sender, \"cex_setrank\", alias);\n\t\t}\n\t\tPlayer player = Bukkit.getServer().getPlayerExact(args[0]);\n\t\tString group = args[1];\n\t\tVault.perms.playerAddGroup(player, group);\n\t\tLogHelper.showInfo(\"[\" + player + \"setrankToSender#####[\" + group, sender);\n\t\tLogHelper.showInfo(\"setrankToPlayer#####[\" + group, player);\n\t\treturn true;\n\t}\n", "output": "\tpublic static Boolean run(CommandSender sender, String alias, String[] args) {\n\t\tif(Vault.permsEnabled() != true) {\n\t\t\t LogHelper.logSevere(_(\"permissionsNotFound\", \"\"));\n\t\t\t LogHelper.showWarning(\"permissionsNotFound\", sender);\n\t\t}\n\t\tif(args.length != 2) {\n\t\t\tCommands.showCommandHelpAndUsage(sender, \"cex_setrank\", alias);\n\t\t\treturn true;\n\t\t}\n\t\tPlayer player = Bukkit.getServer().getPlayerExact(args[0]);\n\t\tString group = args[1];\n\t\tVault.perms.playerAddGroup(player, group);\n\t\tLogHelper.showInfo(\"[\" + player + \"setrankToSender#####[\" + group, sender);\n\t\tLogHelper.showInfo(\"setrankToPlayer#####[\" + group, player);\n\t\treturn true;\n\t}\n"} {"input": "\tpublic List<NameNumberXml> lookupMemberById(@QueryParam(\"q\") String q) {\n\t\tList<NameNumberXml> results = em\n\t\t\t\t.createQuery(\n\t\t\t\t\t\t\"select new com.laurinka.skga.server.rest.model.NameNumberXml(m.name2, m.nr) from SkgaNumber m \"\n\t\t\t\t\t\t\t\t+ \"where m.name2 is not null \"\n\t\t\t\t\t\t\t\t+ \"and m.name2 like :name\" + \" order by m.nr desc\", \n\t\t\t\t\t\tNameNumberXml.class)\n\t\t\t\t.setParameter(\"custName\", \"%\" + q + \"%\").setMaxResults(10)\n\t\t\t\t.getResultList();\n\t\treturn results;\n\t}\n", "output": "\tpublic List<NameNumberXml> lookupMemberById(@QueryParam(\"q\") String q) {\n\t\tList<NameNumberXml> results = em\n\t\t\t\t.createQuery(\n\t\t\t\t\t\t\"select new com.laurinka.skga.server.rest.model.NameNumberXml(m.name2, m.nr) from SkgaNumber m \"\n\t\t\t\t\t\t\t\t+ \"where m.name2 is not null \"\n\t\t\t\t\t\t\t\t+ \"and m.name2 like :name\" + \" order by m.nr desc\", \n\t\t\t\t\t\tNameNumberXml.class)\n\t\t\t\t.setParameter(\"name\", \"%\" + q + \"%\").setMaxResults(10)\n\t\t\t\t.getResultList();\n\t\treturn results;\n\t}\n"} {"input": " public void load(FMLInitializationEvent event)\n {\n\t\tNetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());\n\t\tgpu = new BlockGPU(542, Material.iron);\n\t\tGameRegistry.registerBlock(gpu, \"CCLGPU\");\n\t\tGameRegistry.registerTileEntity(TileEntityGPU.class, \"GPU\");\n\t\tGameRegistry.addRecipe(new ItemStack(gpu,1),new Object[]{\n\t\t\t\"III\",\n\t\t\t\"RGR\",\n\t\t\t\"GGG\",'I',Item.ingotIron,'R',Item.redstone,'G',Item.ingotGold});\n\t\tmonitor = new BlockMonitor(543, Material.iron);\n\t\tGameRegistry.registerBlock(monitor, \"CCLMonitor\");\n\t\tGameRegistry.registerTileEntity(TileEntityMonitor.class, \"CCLMonitorTE\");\n\t\tGameRegistry.addRecipe(new ItemStack(monitor,2),new Object[]{\n\t\t\t\"III\",\n\t\t\t\"RLR\",\n\t\t\t\"GGG\",'I',Item.ingotIron,'R',Item.redstone,'G',Item.ingotGold,'L',Block.thinGlass});\n\t\tmonitorBig = new BlockBigMonitor(545, Material.iron);\n\t\tGameRegistry.registerBlock(monitorBig, \"CCLBigMonitor\");\n\t\tGameRegistry.registerTileEntity(TileEntityBigMonitor.class, \"CCLBigMonitorTE\");\n\t\tGameRegistry.addRecipe(new ItemStack(monitorBig,16),new Object[]{\n\t\t\t\"LLL\",\n\t\t\t\"LGL\",\n\t\t\t\"LLL\",'G',gpu,'L',Block.thinGlass});\n\t\tram = new ItemRAM(4097-256);\n\t\tGameRegistry.registerItem(ram, \"CCLRAM\");\n\t\tLanguageRegistry.addName(ram, \"RAM\");\n\t\tGameRegistry.addRecipe(new ItemStack(ram,8),new Object[]{\n\t\t\t\"III\",\n\t\t\t\"R R\",\n\t\t\t\"GGG\",'I',Item.ingotIron,'R',Block.blockRedstone,'G',Item.ingotGold,'L',Block.thinGlass});\n\t\ttablet = new ItemTablet(4098);\n\t\tGameRegistry.registerItem(tablet, \"CCLTab\");\n\t\tLanguageRegistry.addName(tablet, \"Tablet\");\n\t\tGameRegistry.addRecipe(new ItemStack(tablet,2),new Object[]{\n\t\t\t\"GIG\",\n\t\t\t\"RMR\",\n\t\t\t\"GIG\",'I',Item.ingotIron,'R',Item.redstone,'G',Item.ingotGold,'M',monitorBig});\n\t\tproxy.registerRenderInfo();\n\t\tMinecraftForge.EVENT_BUS.register(new Events());\n }\n", "output": " public void load(FMLInitializationEvent event)\n {\n\t\tNetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());\n\t\tgpu = new BlockGPU(542, Material.iron);\n\t\tGameRegistry.registerBlock(gpu, \"CCLGPU\");\n\t\tGameRegistry.registerTileEntity(TileEntityGPU.class, \"GPU\");\n\t\tGameRegistry.addRecipe(new ItemStack(gpu,1),new Object[]{\n\t\t\t\"III\",\n\t\t\t\"RGR\",\n\t\t\t\"GGG\",'I',Item.ingotIron,'R',Item.redstone,'G',Item.ingotGold});\n\t\tmonitor = new BlockMonitor(543, Material.iron);\n\t\tGameRegistry.registerBlock(monitor, \"CCLMonitor\");\n\t\tGameRegistry.registerTileEntity(TileEntityMonitor.class, \"CCLMonitorTE\");\n\t\tGameRegistry.addRecipe(new ItemStack(monitor,2),new Object[]{\n\t\t\t\"III\",\n\t\t\t\"RLR\",\n\t\t\t\"GGG\",'I',Item.ingotIron,'R',Item.redstone,'G',Item.ingotGold,'L',Block.thinGlass});\n\t\tmonitorBig = new BlockBigMonitor(545, Material.iron);\n\t\tGameRegistry.registerBlock(monitorBig, \"CCLBigMonitor\");\n\t\tGameRegistry.registerTileEntity(TileEntityBigMonitor.class, \"CCLBigMonitorTE\");\n\t\tGameRegistry.addRecipe(new ItemStack(monitorBig,16),new Object[]{\n\t\t\t\"LLL\",\n\t\t\t\"LGL\",\n\t\t\t\"LLL\",'G',monitor,'L',Block.thinGlass});\n\t\tram = new ItemRAM(4097-256);\n\t\tGameRegistry.registerItem(ram, \"CCLRAM\");\n\t\tLanguageRegistry.addName(ram, \"RAM\");\n\t\tGameRegistry.addRecipe(new ItemStack(ram,8),new Object[]{\n\t\t\t\"III\",\n\t\t\t\"R R\",\n\t\t\t\"GGG\",'I',Item.ingotIron,'R',Block.blockRedstone,'G',Item.ingotGold,'L',Block.thinGlass});\n\t\ttablet = new ItemTablet(4098);\n\t\tGameRegistry.registerItem(tablet, \"CCLTab\");\n\t\tLanguageRegistry.addName(tablet, \"Tablet\");\n\t\tGameRegistry.addRecipe(new ItemStack(tablet,2),new Object[]{\n\t\t\t\"GIG\",\n\t\t\t\"RMR\",\n\t\t\t\"GIG\",'I',Item.ingotIron,'R',Item.redstone,'G',Item.ingotGold,'M',monitorBig});\n\t\tproxy.registerRenderInfo();\n\t\tMinecraftForge.EVENT_BUS.register(new Events());\n }\n"} {"input": " protected void renderTokens(Graphics2D g, List<Token> tokenList) {\n \tGrid grid = zone.getGrid();\n \tDimension screenSize = getSize();\n int scaledGridWidth = (int)(grid.getCellWidth()*getScale());\n int scaledGridHeight = (int)(grid.getCellHeight()*getScale());\n Rectangle clipBounds = g.getClipBounds();\n float scale = zoneScale.getScale();\n double gridSize = getScaledGridSize();\n for (Token token : tokenList) {\n \tif (!zone.isTokenVisible(token) && !AppUtil.playerOwns(token)) {\n \t\tcontinue;\n \t}\n int width = (int)Math.ceil(TokenSize.getWidth(token, zone.getGrid()) * scale);\n int height = (int)Math.ceil(TokenSize.getHeight(token, zone.getGrid()) * scale);\n if (!token.isStamp()) {\n \twidth --;\n \theight --;\n }\n ScreenPoint tokenScreenLocation = ScreenPoint.fromZonePoint(this, token.getX(), token.getY());\n int x = tokenScreenLocation.x + 1 + (int)(grid.getCellOffset().width*scale);\n int y = tokenScreenLocation.y + 1 + (int)(grid.getCellOffset().height*scale);\n if (width < scaledGridWidth && token.isSnapToGrid()) {\n x += (scaledGridWidth - width)/2;\n }\n if (height < scaledGridHeight && token.isSnapToGrid()) {\n y += (scaledGridHeight - height)/2;\n }\n Rectangle tokenBounds = new Rectangle(x, y, width, height);\n if (x+width < 0 || x > screenSize.width || y+height < 0 || y > screenSize.height) {\n \tcontinue;\n }\n if (!token.isStamp() && !token.isBackground()) {\n\t for (TokenLocation location : getTokenLocations(Zone.Layer.TOKEN)) {\n\t \tRectangle r1 = location.bounds;\n\t \tif (tokenBounds.intersects(r1)) {\n\t \t\tRectangle oldRect = null;\n\t \t\tfor (Rectangle r2 : coveredTokenSet) {\n\t \t\t\tif (tokenBounds.contains(r2)) {\n\t \t\t\t\toldRect = r2;\n\t \t\t\t\tbreak;\n\t \t\t\t}\n\t \t\t}\n\t \t\tif (oldRect != null) {\n\t \t\t\tcoveredTokenSet.remove(oldRect);\n\t \t\t}\n\t \t\tcoveredTokenSet.add(tokenBounds);\n\t \t}\n\t }\n }\n List<TokenLocation> locationList = null;\n if (!token.isStamp() && !token.isBackground()) {\n \tlocationList = getTokenLocations(Zone.Layer.TOKEN);\n } else {\n \tif (token.isStamp()) {\n \t\tlocationList = getTokenLocations(Zone.Layer.STAMP);\n \t} \n \tif (token.isBackground()) {\n \t\tlocationList = getTokenLocations(Zone.Layer.BACKGROUND);\n \t}\n }\n if (locationList != null) {\n \tlocationList.add(new TokenLocation(tokenBounds, token));\n }\n\t\t\tBufferedImage image = null;\n Asset asset = AssetManager.getAsset(token.getAssetID());\n if (asset == null) {\n MapTool.serverCommand().getAsset(token.getAssetID());\n image = ImageManager.UNKNOWN_IMAGE;\n } else {\n\t\t\t\timage = ImageManager.getImage(AssetManager.getAsset(token.getAssetID()), this);\n }\n if (!tokenBounds.intersects(clipBounds)) {\n continue;\n }\n\t\t\tif (isTokenMoving(token)) {\n\t\t\t\tBufferedImage replacementImage = replacementImageMap.get(token);\n\t\t\t\tif (replacementImage == null) {\n\t\t\t\t\treplacementImage = ImageUtil.rgbToGrayscale(image);\n\t\t\t\t\treplacementImageMap.put(token, replacementImage);\n\t\t\t\t}\n\t\t\t\timage = replacementImage;\n\t\t\t}\n\t\t\tif (showPathList.contains(token) && token.getLastPath() != null) {\n\t\t\t\trenderPath(g, token.getLastPath(), (int)(width/gridSize), (int)(height/gridSize));\n\t\t\t}\n\t\t\tif (token.hasFacing() && (token.getTokenType() == Token.Type.TOP_DOWN || token.isStamp() || token.isBackground())) {\n\t\t\t\tAffineTransform at = new AffineTransform();\n\t\t\t\tat.translate(x, y);\n\t\t\t\tat.rotate(Math.toRadians(-token.getFacing() - 90), width/2, height/2); \n\t\t\t\tif (token.isSnapToScale()) {\n\t\t\t\t\tat.scale((double)TokenSize.getWidth(token, zone.getGrid()) / token.getWidth(), (double)TokenSize.getHeight(token, zone.getGrid()) / token.getHeight());\n\t\t\t\t} else {\n\t\t\t\t\tat.scale((double) token.getWidth() / image.getWidth(), (double) token.getHeight() / image.getHeight());\n\t\t\t\t}\n\t\t\t\tat.scale(getScale(), getScale());\n\t g.drawImage(image, at, this);\n\t\t\t} else {\n\t g.drawImage(image, x, y, width, height, this);\n\t\t\t}\n\t\t\tif (token.hasFacing()) {\n\t\t\t\tToken.Type tokenType = token.getTokenType();\n\t\t\t\tswitch(tokenType) {\n\t\t\t\tcase CIRCLE:\n\t\t\t\t\tint size = TokenSize.getWidth(token, zone.getGrid())/2;\n\t\t\t\t\tShape arrow = getCircleFacingArrow(token.getFacing(), size);\n\t\t\t\t\tint cx = x + width/2;\n\t\t\t\t\tint cy = y + height/2;\n\t\t\t\t\tg.translate(cx, cy);\n\t\t\t\t\tg.setColor(Color.yellow);\n\t\t\t\t\tg.fill(arrow);\n\t\t\t\t\tg.setColor(Color.darkGray);\n\t\t\t\t\tg.draw(arrow);\n\t\t\t\t\tg.translate(-cx, -cy);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SQUARE:\n\t\t\t\t\tsize = TokenSize.getWidth(token, zone.getGrid())/2;\n\t\t\t\t\tint facing = token.getFacing();\n\t\t\t\t\tarrow = getSquareFacingArrow(facing, size);\n\t\t\t\t\tcx = x + width/2;\n\t\t\t\t\tcy = y + height/2;\n\t\t\t\t\tint xp = width/2;\n\t\t\t\t\tint yp = height/2;\n\t\t\t\t\tif (facing >= 45 && facing <= 135 || facing <= -45 && facing >= -135) {\n\t\t\t\t\t\txp = (int)(yp / Math.tan(Math.toRadians(facing)));\n\t\t\t\t\t\tif (facing < 0 ) {\n\t\t\t\t\t\t\txp = -xp;\n\t\t\t\t\t\t\typ = -yp;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\typ = (int)(xp * Math.tan(Math.toRadians(facing)));\n\t\t\t\t\t\tif (facing > 135 || facing < -135) {\n\t\t\t\t\t\t\txp = -xp;\n\t\t\t\t\t\t\typ = -yp;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcx += xp;\n\t\t\t\t\tcy -= yp;\n\t\t\t\t\tg.translate(cx, cy);\n\t\t\t\t\tg.setColor(Color.yellow);\n\t\t\t\t\tg.fill(arrow);\n\t\t\t\t\tg.setColor(Color.darkGray);\n\t\t\t\t\tg.draw(arrow);\n\t\t\t\t\tg.translate(-cx, -cy);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n if (!token.getStatePropertyNames().isEmpty()) {\n Shape clip = g.getClip();\n g.translate(x, y);\n Rectangle bounds = new Rectangle(0, 0, width, height);\n Rectangle overlayClip = g.getClipBounds().intersection(bounds);\n g.setClip(overlayClip);\n for (String state : token.getStatePropertyNames()) {\n Object stateValue = token.getState(state);\n if (stateValue instanceof Boolean && ((Boolean)stateValue).booleanValue()) {\n TokenOverlay overlay = TokenStates.getOverlay(state);\n if (overlay != null) overlay.paintOverlay(g, token, bounds);\n } else if (stateValue instanceof TokenOverlay) {\n ((TokenOverlay)stateValue).paintOverlay(g, token, bounds);\n } \n } \n g.translate(-x, -y);\n g.setClip(clip);\n } \n }\n for (TokenLocation location : getTokenLocations(getActiveLayer())) {\n \tRectangle bounds = location.bounds;\n if (!bounds.intersects(clipBounds)) {\n continue;\n }\n \tToken token = location.token;\n \tboolean isSelected = selectedTokenSet.contains(token.getId());\n \tif (isSelected) {\n \t\tImageBorder selectedBorder = token.isStamp() || token.isBackground() ? AppStyle.selectedStampBorder : AppStyle.selectedBorder;\n \t\t\tif (token.hasFacing() && (token.getTokenType() == Token.Type.TOP_DOWN || token.isStamp() || token.isBackground())) {\n \t\t\t\tAffineTransform oldTransform = g.getTransform();\n \t\t\t\tg.translate(bounds.x, bounds.y);\n \t\t\t\tg.rotate(Math.toRadians(-token.getFacing() - 90), bounds.width/2, bounds.height/2); \n \t\t\t\tselectedBorder.paintAround(g, 0, 0, bounds.width, bounds.height);\n \t\t\t\tg.setTransform(oldTransform);\n \t\t\t} else {\n \t\t\t\tselectedBorder.paintAround(g, bounds);\n \t\t\t}\n \t}\n \tif (AppState.isShowTokenNames() || isSelected || token == tokenUnderMouse) {\n \t\tString name = token.getName();\n \t\tif (MapTool.getPlayer().isGM() && token.getGMName() != null && token.getGMName().length() > 0) {\n \t\t\tname += \" (\" + token.getGMName() + \")\";\n \t\t}\n GraphicsUtil.drawBoxedString(g, name, bounds.x + bounds.width/2, bounds.y + bounds.height + 10);\n }\n }\n for (Rectangle rect : coveredTokenSet) {\n \tBufferedImage stackImage = AppStyle.stackImage;\n \tg.drawImage(stackImage, rect.x + rect.width - stackImage.getWidth() + 2, rect.y - 2, null);\n }\n }\n", "output": " protected void renderTokens(Graphics2D g, List<Token> tokenList) {\n \tGrid grid = zone.getGrid();\n \tDimension screenSize = getSize();\n int scaledGridWidth = (int)(grid.getCellWidth()*getScale());\n int scaledGridHeight = (int)(grid.getCellHeight()*getScale());\n Rectangle clipBounds = g.getClipBounds();\n float scale = zoneScale.getScale();\n double gridSize = getScaledGridSize();\n for (Token token : tokenList) {\n \tif (!zone.isTokenVisible(token) && !MapTool.getPlayer().isGM()) {\n \t\tcontinue;\n \t}\n int width = (int)Math.ceil(TokenSize.getWidth(token, zone.getGrid()) * scale);\n int height = (int)Math.ceil(TokenSize.getHeight(token, zone.getGrid()) * scale);\n if (!token.isStamp()) {\n \twidth --;\n \theight --;\n }\n ScreenPoint tokenScreenLocation = ScreenPoint.fromZonePoint(this, token.getX(), token.getY());\n int x = tokenScreenLocation.x + 1 + (int)(grid.getCellOffset().width*scale);\n int y = tokenScreenLocation.y + 1 + (int)(grid.getCellOffset().height*scale);\n if (width < scaledGridWidth && token.isSnapToGrid()) {\n x += (scaledGridWidth - width)/2;\n }\n if (height < scaledGridHeight && token.isSnapToGrid()) {\n y += (scaledGridHeight - height)/2;\n }\n Rectangle tokenBounds = new Rectangle(x, y, width, height);\n if (x+width < 0 || x > screenSize.width || y+height < 0 || y > screenSize.height) {\n \tcontinue;\n }\n if (!token.isStamp() && !token.isBackground()) {\n\t for (TokenLocation location : getTokenLocations(Zone.Layer.TOKEN)) {\n\t \tRectangle r1 = location.bounds;\n\t \tif (tokenBounds.intersects(r1)) {\n\t \t\tRectangle oldRect = null;\n\t \t\tfor (Rectangle r2 : coveredTokenSet) {\n\t \t\t\tif (tokenBounds.contains(r2)) {\n\t \t\t\t\toldRect = r2;\n\t \t\t\t\tbreak;\n\t \t\t\t}\n\t \t\t}\n\t \t\tif (oldRect != null) {\n\t \t\t\tcoveredTokenSet.remove(oldRect);\n\t \t\t}\n\t \t\tcoveredTokenSet.add(tokenBounds);\n\t \t}\n\t }\n }\n List<TokenLocation> locationList = null;\n if (!token.isStamp() && !token.isBackground()) {\n \tlocationList = getTokenLocations(Zone.Layer.TOKEN);\n } else {\n \tif (token.isStamp()) {\n \t\tlocationList = getTokenLocations(Zone.Layer.STAMP);\n \t} \n \tif (token.isBackground()) {\n \t\tlocationList = getTokenLocations(Zone.Layer.BACKGROUND);\n \t}\n }\n if (locationList != null) {\n \tlocationList.add(new TokenLocation(tokenBounds, token));\n }\n\t\t\tBufferedImage image = null;\n Asset asset = AssetManager.getAsset(token.getAssetID());\n if (asset == null) {\n MapTool.serverCommand().getAsset(token.getAssetID());\n image = ImageManager.UNKNOWN_IMAGE;\n } else {\n\t\t\t\timage = ImageManager.getImage(AssetManager.getAsset(token.getAssetID()), this);\n }\n if (!tokenBounds.intersects(clipBounds)) {\n continue;\n }\n\t\t\tif (isTokenMoving(token)) {\n\t\t\t\tBufferedImage replacementImage = replacementImageMap.get(token);\n\t\t\t\tif (replacementImage == null) {\n\t\t\t\t\treplacementImage = ImageUtil.rgbToGrayscale(image);\n\t\t\t\t\treplacementImageMap.put(token, replacementImage);\n\t\t\t\t}\n\t\t\t\timage = replacementImage;\n\t\t\t}\n\t\t\tif (showPathList.contains(token) && token.getLastPath() != null) {\n\t\t\t\trenderPath(g, token.getLastPath(), (int)(width/gridSize), (int)(height/gridSize));\n\t\t\t}\n\t\t\tif (token.hasFacing() && (token.getTokenType() == Token.Type.TOP_DOWN || token.isStamp() || token.isBackground())) {\n\t\t\t\tAffineTransform at = new AffineTransform();\n\t\t\t\tat.translate(x, y);\n\t\t\t\tat.rotate(Math.toRadians(-token.getFacing() - 90), width/2, height/2); \n\t\t\t\tif (token.isSnapToScale()) {\n\t\t\t\t\tat.scale((double)TokenSize.getWidth(token, zone.getGrid()) / token.getWidth(), (double)TokenSize.getHeight(token, zone.getGrid()) / token.getHeight());\n\t\t\t\t} else {\n\t\t\t\t\tat.scale((double) token.getWidth() / image.getWidth(), (double) token.getHeight() / image.getHeight());\n\t\t\t\t}\n\t\t\t\tat.scale(getScale(), getScale());\n\t g.drawImage(image, at, this);\n\t\t\t} else {\n\t g.drawImage(image, x, y, width, height, this);\n\t\t\t}\n\t\t\tif (token.hasFacing()) {\n\t\t\t\tToken.Type tokenType = token.getTokenType();\n\t\t\t\tswitch(tokenType) {\n\t\t\t\tcase CIRCLE:\n\t\t\t\t\tint size = TokenSize.getWidth(token, zone.getGrid())/2;\n\t\t\t\t\tShape arrow = getCircleFacingArrow(token.getFacing(), size);\n\t\t\t\t\tint cx = x + width/2;\n\t\t\t\t\tint cy = y + height/2;\n\t\t\t\t\tg.translate(cx, cy);\n\t\t\t\t\tg.setColor(Color.yellow);\n\t\t\t\t\tg.fill(arrow);\n\t\t\t\t\tg.setColor(Color.darkGray);\n\t\t\t\t\tg.draw(arrow);\n\t\t\t\t\tg.translate(-cx, -cy);\n\t\t\t\t\tbreak;\n\t\t\t\tcase SQUARE:\n\t\t\t\t\tsize = TokenSize.getWidth(token, zone.getGrid())/2;\n\t\t\t\t\tint facing = token.getFacing();\n\t\t\t\t\tarrow = getSquareFacingArrow(facing, size);\n\t\t\t\t\tcx = x + width/2;\n\t\t\t\t\tcy = y + height/2;\n\t\t\t\t\tint xp = width/2;\n\t\t\t\t\tint yp = height/2;\n\t\t\t\t\tif (facing >= 45 && facing <= 135 || facing <= -45 && facing >= -135) {\n\t\t\t\t\t\txp = (int)(yp / Math.tan(Math.toRadians(facing)));\n\t\t\t\t\t\tif (facing < 0 ) {\n\t\t\t\t\t\t\txp = -xp;\n\t\t\t\t\t\t\typ = -yp;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\typ = (int)(xp * Math.tan(Math.toRadians(facing)));\n\t\t\t\t\t\tif (facing > 135 || facing < -135) {\n\t\t\t\t\t\t\txp = -xp;\n\t\t\t\t\t\t\typ = -yp;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcx += xp;\n\t\t\t\t\tcy -= yp;\n\t\t\t\t\tg.translate(cx, cy);\n\t\t\t\t\tg.setColor(Color.yellow);\n\t\t\t\t\tg.fill(arrow);\n\t\t\t\t\tg.setColor(Color.darkGray);\n\t\t\t\t\tg.draw(arrow);\n\t\t\t\t\tg.translate(-cx, -cy);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n if (!token.getStatePropertyNames().isEmpty()) {\n Shape clip = g.getClip();\n g.translate(x, y);\n Rectangle bounds = new Rectangle(0, 0, width, height);\n Rectangle overlayClip = g.getClipBounds().intersection(bounds);\n g.setClip(overlayClip);\n for (String state : token.getStatePropertyNames()) {\n Object stateValue = token.getState(state);\n if (stateValue instanceof Boolean && ((Boolean)stateValue).booleanValue()) {\n TokenOverlay overlay = TokenStates.getOverlay(state);\n if (overlay != null) overlay.paintOverlay(g, token, bounds);\n } else if (stateValue instanceof TokenOverlay) {\n ((TokenOverlay)stateValue).paintOverlay(g, token, bounds);\n } \n } \n g.translate(-x, -y);\n g.setClip(clip);\n } \n }\n for (TokenLocation location : getTokenLocations(getActiveLayer())) {\n \tRectangle bounds = location.bounds;\n if (!bounds.intersects(clipBounds)) {\n continue;\n }\n \tToken token = location.token;\n \tboolean isSelected = selectedTokenSet.contains(token.getId());\n \tif (isSelected) {\n \t\tImageBorder selectedBorder = token.isStamp() || token.isBackground() ? AppStyle.selectedStampBorder : AppStyle.selectedBorder;\n \t\t\tif (token.hasFacing() && (token.getTokenType() == Token.Type.TOP_DOWN || token.isStamp() || token.isBackground())) {\n \t\t\t\tAffineTransform oldTransform = g.getTransform();\n \t\t\t\tg.translate(bounds.x, bounds.y);\n \t\t\t\tg.rotate(Math.toRadians(-token.getFacing() - 90), bounds.width/2, bounds.height/2); \n \t\t\t\tselectedBorder.paintAround(g, 0, 0, bounds.width, bounds.height);\n \t\t\t\tg.setTransform(oldTransform);\n \t\t\t} else {\n \t\t\t\tselectedBorder.paintAround(g, bounds);\n \t\t\t}\n \t}\n \tif (AppState.isShowTokenNames() || isSelected || token == tokenUnderMouse) {\n \t\tString name = token.getName();\n \t\tif (MapTool.getPlayer().isGM() && token.getGMName() != null && token.getGMName().length() > 0) {\n \t\t\tname += \" (\" + token.getGMName() + \")\";\n \t\t}\n GraphicsUtil.drawBoxedString(g, name, bounds.x + bounds.width/2, bounds.y + bounds.height + 10);\n }\n }\n for (Rectangle rect : coveredTokenSet) {\n \tBufferedImage stackImage = AppStyle.stackImage;\n \tg.drawImage(stackImage, rect.x + rect.width - stackImage.getWidth() + 2, rect.y - 2, null);\n }\n }\n"} {"input": " private int loadPersistenceUnits(final ModuleLoader moduleLoader, final DeploymentUnit deploymentUnit, final Set<String> moduleDependencies, final PersistenceUnitMetadataHolder holder) throws DeploymentUnitProcessingException {\n int defaultProviderCount = 0;\n if (holder != null) {\n for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {\n String providerModule = pu.getProperties().getProperty(Configuration.PROVIDER_MODULE);\n String adapterModule = pu.getProperties().getProperty(Configuration.ADAPTER_MODULE);\n String adapterClass = pu.getProperties().getProperty(Configuration.ADAPTER_CLASS);\n if(providerModule != null) {\n if (providerModule.equals(Configuration.PROVIDER_MODULE_HIBERNATE3_BUNDLED)) {\n adapterClass = HIBERNATE3_PROVIDER_ADAPTOR;\n pu.getProperties().put(Configuration.ADAPTER_CLASS, adapterClass);\n pu.getProperties().put(Configuration.PROVIDER_MODULE, Configuration.PROVIDER_MODULE_APPLICATION_SUPPLIED);\n pu.getProperties().remove(Configuration.ADAPTER_MODULE);\n addHibernate3AdaptorToDeployment(moduleLoader, deploymentUnit);\n } else if (providerModule.equals(Configuration.PROVIDER_MODULE_HIBERNATE3)) {\n if (adapterModule == null) {\n adapterModule = Configuration.ADAPTER_MODULE_HIBERNATE3;\n pu.getProperties().put(Configuration.ADAPTER_MODULE, adapterModule);\n }\n }\n }\n if (adapterModule != null) {\n ROOT_LOGGER.debugf(\"%s is configured to use adapter module '%s'\", pu.getPersistenceUnitName(), adapterModule);\n moduleDependencies.add(adapterModule);\n }\n deploymentUnit.putAttachment(JpaAttachments.ADAPTOR_CLASS_NAME, adapterClass);\n String provider = pu.getProperties().getProperty(Configuration.PROVIDER_MODULE);\n if (provider != null) {\n if (provider.equals(Configuration.PROVIDER_MODULE_APPLICATION_SUPPLIED)) {\n ROOT_LOGGER.debugf(\"%s is configured to use application supplied persistence provider\", pu.getPersistenceUnitName());\n } else {\n moduleDependencies.add(provider);\n }\n } else if (pu.getPersistenceProviderClassName() == null || pu.getPersistenceProviderClassName().equals(Configuration.ADAPTER_MODULE_DEFAULT)){\n defaultProviderCount++; \n }\n }\n }\n return defaultProviderCount;\n }\n", "output": " private int loadPersistenceUnits(final ModuleLoader moduleLoader, final DeploymentUnit deploymentUnit, final Set<String> moduleDependencies, final PersistenceUnitMetadataHolder holder) throws DeploymentUnitProcessingException {\n int defaultProviderCount = 0;\n if (holder != null) {\n for (PersistenceUnitMetadata pu : holder.getPersistenceUnits()) {\n String providerModule = pu.getProperties().getProperty(Configuration.PROVIDER_MODULE);\n String adapterModule = pu.getProperties().getProperty(Configuration.ADAPTER_MODULE);\n String adapterClass = pu.getProperties().getProperty(Configuration.ADAPTER_CLASS);\n if(providerModule != null) {\n if (providerModule.equals(Configuration.PROVIDER_MODULE_HIBERNATE3_BUNDLED)) {\n adapterClass = HIBERNATE3_PROVIDER_ADAPTOR;\n pu.getProperties().put(Configuration.ADAPTER_CLASS, adapterClass);\n pu.getProperties().put(Configuration.PROVIDER_MODULE, Configuration.PROVIDER_MODULE_APPLICATION_SUPPLIED);\n pu.getProperties().remove(Configuration.ADAPTER_MODULE);\n addHibernate3AdaptorToDeployment(moduleLoader, deploymentUnit);\n } else if (providerModule.equals(Configuration.PROVIDER_MODULE_HIBERNATE3)) {\n if (adapterModule == null) {\n adapterModule = Configuration.ADAPTER_MODULE_HIBERNATE3;\n pu.getProperties().put(Configuration.ADAPTER_MODULE, adapterModule);\n }\n }\n }\n if (adapterModule != null) {\n ROOT_LOGGER.debugf(\"%s is configured to use adapter module '%s'\", pu.getPersistenceUnitName(), adapterModule);\n moduleDependencies.add(adapterModule);\n }\n deploymentUnit.putAttachment(JpaAttachments.ADAPTOR_CLASS_NAME, adapterClass);\n String provider = pu.getProperties().getProperty(Configuration.PROVIDER_MODULE);\n if (provider != null) {\n if (provider.equals(Configuration.PROVIDER_MODULE_APPLICATION_SUPPLIED)) {\n ROOT_LOGGER.debugf(\"%s is configured to use application supplied persistence provider\", pu.getPersistenceUnitName());\n } else {\n moduleDependencies.add(provider);\n }\n } else if (Configuration.PROVIDER_CLASS_DEFAULT.equals(pu.getPersistenceProviderClassName())){\n defaultProviderCount++; \n }\n }\n }\n return defaultProviderCount;\n }\n"} {"input": " private void processLine(String s) throws IOException {\n if (s==null) return ;\n if (s.length()==0) return;\n String[] parts=s.split(\" \");\n parts=removeEmpty(parts);\n if (\"#\".equals(parts[0])) return;\n if (\"v\".equals(parts[0])){\n addVertextoList(parts);\n return;\n }else if (\"vt\".equals(parts[0])){\n addTextoList(parts);\n return;\n } else if (\"vn\".equals(parts[0])){\n addNormalToList(parts);\n return;\n } else if (\"g\".equals(parts[0])){\n if (parts.length >= 2 && materialNames.get(parts[1]) != null\n && materialNames.get(parts[1]) != null)\n curGroup = (MaterialGrouping) materialNames.get(parts[1]);\n else\n setDefaultGroup();\n return; \n } else if (\"f\".equals(parts[0])){\n addFaces(parts);\n return;\n } else if (\"mtllib\".equals(parts[0])){\n loadMaterials(parts);\n return;\n } else if (\"newmtl\".equals(parts[0])){\n addMaterial(parts);\n return;\n } else if (\"usemtl\".equals(parts[0])){\n if (materialNames.get(parts[1])!=null)\n curGroup=(MaterialGrouping) materialNames.get(parts[1]);\n else\n setDefaultGroup();\n return;\n } else if (\"Ka\".equals(parts[0])){\n curGroup.m.setAmbient(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));\n return;\n } else if (\"Kd\".equals(parts[0])){\n curGroup.m.setDiffuse(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));\n return;\n } else if (\"Ks\".equals(parts[0])){\n curGroup.m.setSpecular(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));\n return;\n } else if (\"Ns\".equals(parts[0])){\n curGroup.m.setShininess(Float.parseFloat(parts[1]));\n return;\n } else if (\"d\".equals(parts[0])){\n curGroup.m.setAlpha(Float.parseFloat(parts[1]));\n ColorRGBA alpha = new ColorRGBA(1,1,1,curGroup.m.getAlpha());\n curGroup.m.setAmbient(curGroup.m.getAmbient().mult(alpha));\n curGroup.m.setDiffuse(curGroup.m.getDiffuse().mult(alpha));\n curGroup.m.setSpecular(curGroup.m.getSpecular().mult(alpha));\n if (curGroup.m.getAlpha() < 1.0f)\n curGroup.createAlphaState();\n return;\n } else if (\"map_d\".equals(parts[0])) {\n curGroup.createAlphaState();\n return;\n } else if (\"map_Kd\".equals(parts[0]) || \"map_Ka\".equals(parts[0])){\n Texture t=new Texture();\n t.setImageLocation(\"file:/\"+s.substring(6).trim());\n curGroup.ts.setTexture(t);\n curGroup.ts.setEnabled(true);\n return;\n }\n }\n", "output": " private void processLine(String s) throws IOException {\n if (s==null) return ;\n if (s.length()==0) return;\n String[] parts=s.split(\" \");\n parts=removeEmpty(parts);\n if (\"#\".equals(parts[0])) return;\n if (\"v\".equals(parts[0])){\n addVertextoList(parts);\n return;\n }else if (\"vt\".equals(parts[0])){\n addTextoList(parts);\n return;\n } else if (\"vn\".equals(parts[0])){\n addNormalToList(parts);\n return;\n } else if (\"g\".equals(parts[0])){\n if (parts.length >= 2 && materialNames.get(parts[1]) != null\n && materialNames.get(parts[1]) != null)\n curGroup = (MaterialGrouping) materialNames.get(parts[1]);\n else\n setDefaultGroup();\n return; \n } else if (\"f\".equals(parts[0])){\n addFaces(parts);\n return;\n } else if (\"mtllib\".equals(parts[0])){\n loadMaterials(parts);\n return;\n } else if (\"newmtl\".equals(parts[0])){\n addMaterial(parts);\n return;\n } else if (\"usemtl\".equals(parts[0])){\n if (materialNames.get(parts[1])!=null)\n curGroup=(MaterialGrouping) materialNames.get(parts[1]);\n else\n setDefaultGroup();\n return;\n } else if (\"Ka\".equals(parts[0])){\n curGroup.m.setAmbient(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));\n return;\n } else if (\"Kd\".equals(parts[0])){\n curGroup.m.setDiffuse(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));\n return;\n } else if (\"Ks\".equals(parts[0])){\n curGroup.m.setSpecular(new ColorRGBA(Float.parseFloat(parts[1]),Float.parseFloat(parts[2]),Float.parseFloat(parts[3]),1));\n return;\n } else if (\"Ns\".equals(parts[0])){\n curGroup.m.setShininess(Float.parseFloat(parts[1]));\n return;\n } else if (\"d\".equals(parts[0])){\n curGroup.m.setAlpha(Float.parseFloat(parts[1]));\n ColorRGBA alpha = new ColorRGBA(1,1,1,curGroup.m.getAlpha());\n curGroup.m.setAmbient(curGroup.m.getAmbient().mult(alpha));\n curGroup.m.setDiffuse(curGroup.m.getDiffuse().mult(alpha));\n curGroup.m.setSpecular(curGroup.m.getSpecular().mult(alpha));\n if (curGroup.m.getAlpha() < 1.0f)\n curGroup.createAlphaState();\n return;\n } else if (\"map_d\".equals(parts[0])) {\n curGroup.createAlphaState();\n return;\n } else if (\"map_Kd\".equals(parts[0]) || \"map_Ka\".equals(parts[0])){\n Texture t=new Texture();\n t.setImageLocation(\"file:/\"+s.trim().substring(6));\n curGroup.ts.setTexture(t);\n curGroup.ts.setEnabled(true);\n return;\n }\n }\n"} {"input": "\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t\tView res;\n\t\tfinal MagazineModel currentMagazine = magazine.get(position);\n\t\tif(convertView == null){\n\t\t\tres = LayoutInflater.from(context).inflate(R.layout.magazine_list_item, null);\n\t\t} else {\n\t\t\tres = convertView;\n\t\t}\n\t\tTextView title = (TextView)res.findViewById(R.id.item_title);\n\t\tTextView subtitle = (TextView)res.findViewById(R.id.item_subtitle);\n\t\tImageView thumbnail = (ImageView)res.findViewById(R.id.item_thumbnail);\n\t\ttitle.setText(currentMagazine.getTitle());\n\t\tsubtitle.setText(currentMagazine.getSubtitle());\n\t\tString imagePath = currentMagazine.getPngPath();\n\t\tthumbnail.setImageBitmap(BitmapFactory.decodeFile(imagePath));\n\t\tButton downloadOrReadButton = (Button)res.findViewById(R.id.item_button_one);\n\t\tButton sampleOrDeleteButton = (Button)res.findViewById(R.id.item_button_two);\n\t\tif (currentMagazine.isDownloaded()) {\n\t\t\tdownloadOrReadButton.setText(context.getResources().getString(\n\t\t\t\t\tR.string.read));\n\t\t\tdownloadOrReadButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tLibrelioApplication.startPDFActivity(context,\n\t\t\t\t\t\t\tcurrentMagazine.getPdfPath());\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tdownloadOrReadButton.setText(context.getResources().getString(\n\t\t\t\t\tR.string.download));\n\t\t\tdownloadOrReadButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tif(currentMagazine.isPaid()){\n\t\t\t\t\t\tIntent intent = new Intent(context,BillingActivity.class);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());\n\t\t\t\t\t\tcontext.startActivity(intent);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tIntent intent = new Intent(context,\n\t\t\t\t\t\t\t\tDownloadActivity.class);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.IS_SAMPLE_KEY,false);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.ORIENTATION_KEY,\n\t\t\t\t\t\t\t\tcontext.getResources().getConfiguration().orientation);\n\t\t\t\t\t\tcontext.startActivity(intent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (!currentMagazine.isPaid() && !currentMagazine.isDownloaded()) {\n\t\t\tsampleOrDeleteButton.setVisibility(View.INVISIBLE);\n\t\t} else if (currentMagazine.isDownloaded()) {\n\t\t\t\tsampleOrDeleteButton.setVisibility(View.VISIBLE);\n\t\t\t\tsampleOrDeleteButton.setText(context.getResources().getString(\n\t\t\t\t\t\tR.string.delete));\n\t\t\t\tsampleOrDeleteButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\t\tcurrentMagazine.delete();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t} else {\n\t\t\tsampleOrDeleteButton.setText(context.getResources().getString(\n\t\t\t\t\tR.string.sample));\n\t\t\tsampleOrDeleteButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tFile sample = new File(currentMagazine.getSamplePath());\n\t\t\t\t\tLog.d(TAG, \"test: \" + sample.exists() + \" \"\n\t\t\t\t\t\t\t+ currentMagazine.isSampleDownloaded());\n\t\t\t\t\tif (currentMagazine.isSampleDownloaded()) {\n\t\t\t\t\t\tLibrelioApplication.startPDFActivity(context,\n\t\t\t\t\t\t\t\tcurrentMagazine.getSamplePath());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tIntent intent = new Intent(context,\n\t\t\t\t\t\t\t\tDownloadActivity.class);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.ORIENTATION_KEY,\n\t\t\t\t\t\t\t\tcontext.getResources().getConfiguration().orientation);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.IS_SAMPLE_KEY,true);\n\t\t\t\t\t\tcontext.startActivity(intent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn res;\n\t}\n", "output": "\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t\tView res;\n\t\tfinal MagazineModel currentMagazine = magazine.get(position);\n\t\tif(convertView == null){\n\t\t\tres = LayoutInflater.from(context).inflate(R.layout.magazine_list_item, null);\n\t\t} else {\n\t\t\tres = convertView;\n\t\t}\n\t\tTextView title = (TextView)res.findViewById(R.id.item_title);\n\t\tTextView subtitle = (TextView)res.findViewById(R.id.item_subtitle);\n\t\tImageView thumbnail = (ImageView)res.findViewById(R.id.item_thumbnail);\n\t\ttitle.setText(currentMagazine.getTitle());\n\t\tsubtitle.setText(currentMagazine.getSubtitle());\n\t\tString imagePath = currentMagazine.getPngPath();\n\t\tthumbnail.setImageBitmap(BitmapFactory.decodeFile(imagePath));\n\t\tButton downloadOrReadButton = (Button)res.findViewById(R.id.item_button_one);\n\t\tButton sampleOrDeleteButton = (Button)res.findViewById(R.id.item_button_two);\n\t\tif (currentMagazine.isDownloaded()) {\n\t\t\tdownloadOrReadButton.setText(context.getResources().getString(\n\t\t\t\t\tR.string.read));\n\t\t\tdownloadOrReadButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tLibrelioApplication.startPDFActivity(context,\n\t\t\t\t\t\t\tcurrentMagazine.getPdfPath());\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tdownloadOrReadButton.setText(context.getResources().getString(\n\t\t\t\t\tR.string.download));\n\t\t\tdownloadOrReadButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tif(currentMagazine.isPaid()){\n\t\t\t\t\t\tIntent intent = new Intent(context,BillingActivity.class);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());\n\t\t\t\t\t\tcontext.startActivity(intent);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tIntent intent = new Intent(context,\n\t\t\t\t\t\t\t\tDownloadActivity.class);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.IS_SAMPLE_KEY,false);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.ORIENTATION_KEY,\n\t\t\t\t\t\t\t\tcontext.getResources().getConfiguration().orientation);\n\t\t\t\t\t\tcontext.startActivity(intent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tsampleOrDeleteButton.setVisibility(View.VISIBLE);\n\t\tif (!currentMagazine.isPaid() && !currentMagazine.isDownloaded()) {\n\t\t\tsampleOrDeleteButton.setVisibility(View.INVISIBLE);\n\t\t} else if (currentMagazine.isDownloaded()) {\n\t\t\t\tsampleOrDeleteButton.setText(context.getResources().getString(\n\t\t\t\t\t\tR.string.delete));\n\t\t\t\tsampleOrDeleteButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\t\tcurrentMagazine.delete();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t} else {\n\t\t\tsampleOrDeleteButton.setText(context.getResources().getString(\n\t\t\t\t\tR.string.sample));\n\t\t\tsampleOrDeleteButton.setOnClickListener(new OnClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic void onClick(View v) {\n\t\t\t\t\tFile sample = new File(currentMagazine.getSamplePath());\n\t\t\t\t\tLog.d(TAG, \"test: \" + sample.exists() + \" \"\n\t\t\t\t\t\t\t+ currentMagazine.isSampleDownloaded());\n\t\t\t\t\tif (currentMagazine.isSampleDownloaded()) {\n\t\t\t\t\t\tLibrelioApplication.startPDFActivity(context,\n\t\t\t\t\t\t\t\tcurrentMagazine.getSamplePath());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tIntent intent = new Intent(context,\n\t\t\t\t\t\t\t\tDownloadActivity.class);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.ORIENTATION_KEY,\n\t\t\t\t\t\t\t\tcontext.getResources().getConfiguration().orientation);\n\t\t\t\t\t\tintent.putExtra(DownloadActivity.IS_SAMPLE_KEY,true);\n\t\t\t\t\t\tcontext.startActivity(intent);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\treturn res;\n\t}\n"} {"input": " public void run() {\n try {\n while (true) {\n BufferedReader inFromClient = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n DataOutputStream outToClient = new DataOutputStream(socket.getOutputStream());\n String clientMessage = inFromClient.readLine();\n System.out.println(\"Received: \" + clientMessage);\n if (clientMessage.toLowerCase().equals(\"shutdown\")) {\n outToClient.writeBytes(\"goodbye\");\n break;\n } else if (clientMessage.toLowerCase().equals(\"keyval\")) {\n outToClient.writeBytes(Integer.toString(keyVal));\n break;\n } else if (clientMessage.contains(\"article\")) {\n String request = clientMessage.substring(8);\n System.out.println(request);\n int req = Integer.parseInt(request);\n System.out.println(req);\n int key = Integer.parseInt(keylist.getProperty(\"\" + req));\n System.out.println(key);\n if (key > keyVal) {\n outToClient.writeBytes(\"FAIL: \" + nextNode);\n } else {\n outToClient.writeBytes(\"Key Value is: \" + key);\n }\n }\n }\n } catch (IOException ex) {\n System.out.println(\"Unable to get streams from client\");\n } finally {\n try {\n socket.close();\n } catch (IOException ex) {\n ex.printStackTrace();\n }\n }\n }\n", "output": " public void run() {\n try {\n while (true) {\n BufferedReader inFromClient = new BufferedReader(new InputStreamReader(socket.getInputStream()));\n DataOutputStream outToClient = new DataOutputStream(socket.getOutputStream());\n String clientMessage = inFromClient.readLine();\n System.out.println(\"Received: \" + clientMessage);\n if (clientMessage.toLowerCase().equals(\"shutdown\")) {\n outToClient.writeBytes(\"goodbye\");\n break;\n } else if (clientMessage.toLowerCase().equals(\"keyval\")) {\n outToClient.writeBytes(Integer.toString(keyVal));\n break;\n } else if (clientMessage.contains(\"article\")) {\n String request = clientMessage.substring(8);\n int req = Integer.parseInt(request);\n int key = Integer.parseInt(keylist.getProperty(\"\" + req));\n System.out.println(key);\n if (key > keyVal) {\n System.out.println(\"Failed.\");\n outToClient.writeBytes(\"FAIL: \" + nextNode);\n } else {\n System.out.println(\"It's ours!\");\n outToClient.writeBytes(\"Key Value is: \" + key);\n }\n }\n }\n } catch (IOException ex) {\n System.out.println(\"Unable to get streams from client\");\n } finally {\n try {\n socket.close();\n } catch (IOException ex) {\n ex.printStackTrace();\n }\n }\n }\n"} {"input": " private void writeResponse(HttpServletResponse resp, Result rs, byte[] data, String query, String d, int num)\n throws IOException {\n HttpResponseRecord httpResponseRecord = new HttpResponseRecord(data);\n if (httpResponseRecord.getType().startsWith(\"text/plain\") || !httpResponseRecord.getType().startsWith(\"text\")) {\n resp.setHeader(\"Content-Type\", httpResponseRecord.getType());\n resp.setContentLength(httpResponseRecord.getBodyByte().length);\n resp.getOutputStream().write(httpResponseRecord.getBodyByte());\n } else {\n ArrayList<String> dates = new ArrayList<String>(10);\n for (int i = 0; i < rs.raw().length; i++)\n dates.add(new String(rs.raw()[i].getQualifier()));\n Collections.sort(dates);\n String prevDate = null, nextDate = null;\n for (int i = 1; i < dates.size(); i++){\n if (dates.get(i).compareTo(d) == 0){\n prevDate = dates.get(i - 1);\n if (i + 1 < dates.size())\n nextDate = dates.get(i + 1);\n else\n nextDate = d;\n break;\n }\n if (dates.get(i).compareTo(d) > 0) {\n if ( i > 2)\n prevDate = dates.get(i - 2);\n else\n prevDate = dates.get(i - 1);\n nextDate = dates.get(i);\n break;\n }\n }\n System.setProperty(\"file.encoding\", \"UTF8\");\n resp.setHeader(\"Content-Type\", httpResponseRecord.getType());\n resp.setCharacterEncoding(\"UTF-8\");\n PrintWriter out = resp.getWriter();\n TextDocument2 t2 = new TextDocument2(null, null, null);\n String bodyContent = new String(httpResponseRecord.getBodyByte(), \"UTF8\");\n Document doc = Jsoup.parse(bodyContent);\n Element head = doc.select(\"head\").first();\n Element base = doc.select(\"base\").first();\n if(base == null){\n head.prepend(\"<base id='warcbase-base-added' href='\" + query +\"'>\");\n }\n bodyContent = doc.html();\n bodyContent = t2.fixURLs(bodyContent, query, d);\n doc = Jsoup.parse(bodyContent);\n base = doc.select(\"base\").first();\n if(base != null){\n if(base.attr(\"id\").equals(\"warcbase-base-added\"))\n base.remove();\n }\n head = doc.select(\"head\").first();\n String baseUrl = TextDocument2.SERVER_PREFIX + \"warcbase/servlet?date=\" + d + \"&query=\" + query;\n head.prepend(\"<script type=\\\"text/javascript\\\"> function initYTVideo(id) { _wmVideos_.init('/web/', id); } </script> <script> function $(a){return document.getElementById(a)}; function addLoadEvent(a){if(window.addEventListener)addEventListener('load',a,false);else if(window.attachEvent)attachEvent('onload',a)} </script>\");\n Element body = doc.select(\"body\").first();\n body.prepend(\"<div id=\\\"wm-ipp\\\" style=\\\"display: block; position: relative; padding: 0px 5px; min-height: 70px; min-width: 800px; z-index: 9000;\\\"><div id=\\\"wm-ipp-inside\\\" style=\\\"position:fixed;padding:0!important;margin:0!important;width:97%;min-width:780px;border:5px solid #000;border-top:none;background-image:url(\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_bk_trns.png);text-align:center;-moz-box-shadow:1px 1px 3px #333;-webkit-box-shadow:1px 1px 3px #333;box-shadow:1px 1px 3px #333;font-size:11px!important;font-family:'Lucida Grande','Arial',sans-serif!important;\\\"> <table style=\\\"border-collapse:collapse;margin:0;padding:0;width:100%;\\\"><tbody><tr> <td style=\\\"padding:10px;vertical-align:top;min-width:110px;\\\"> <a href=\\\"\"\n + TextDocument2.SERVER_PREFIX + \"warcbase\"\n + \"\\\" title=\\\"Warcbase home page\\\" style=\\\"background-color:transparent;border:none;\\\">Warcbase</a> </td> <td style=\\\"padding:0!important;text-align:center;vertical-align:top;width:100%;\\\"> <table style=\\\"border-collapse:collapse;margin:0 auto;padding:0;width:570px;\\\"><tbody><tr> <td style=\\\"padding:3px 0;\\\" colspan=\\\"2\\\"> <form target=\\\"_top\\\" method=\\\"get\\\" action=\\\"\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"servlet\\\" name=\\\"wmtb\\\" id=\\\"wmtb\\\" style=\\\"margin:0!important;padding:0!important;\\\"><input name=\\\"query\\\" id=\\\"wmtbURL\\\" value=\\\"\"\n + query\n + \"\\\" style=\\\"width:400px;font-size:11px;font-family:'Lucida Grande','Arial',sans-serif;\\\" onfocus=\\\"javascript:this.focus();this.select();\\\" type=\\\"text\\\"><input name=\\\"date\\\" value=\\\"\\\" type=\\\"hidden\\\"><input name=\\\"type\\\" value=\\\"replay\\\" type=\\\"hidden\\\"><input name=\\\"date\\\" value=\\\"20120201185436\\\" type=\\\"hidden\\\"><input value=\\\"Go\\\" style=\\\"font-size:11px;font-family:'Lucida Grande','Arial',sans-serif;margin-left:5px;\\\" type=\\\"submit\\\"><span id=\\\"wm_tb_options\\\" style=\\\"display:block;\\\"></span></form> </td> <td style=\\\"vertical-align:bottom;padding:5px 0 0 0!important;\\\" rowspan=\\\"2\\\"> <table style=\\\"border-collapse:collapse;width:110px;color:#99a;font-family:'Helvetica','Lucida Grande','Arial',sans-serif;\\\"><tbody> <!-- NEXT/PREV MONTH NAV AND MONTH INDICATOR --> <tr style=\\\"width:110px;height:16px;font-size:10px!important;\\\"> <td style=\\\"padding-right:9px;font-size:11px!important;font-weight:bold;text-transform:uppercase;text-align:right;white-space:nowrap;overflow:visible;\\\" nowrap=\\\"nowrap\\\"> <strong>PREV</strong> </td> <td style=\\\"padding-left:9px;font-size:11px!important;font-weight:bold;text-transform:uppercase;white-space:nowrap;overflow:visible;\\\" nowrap=\\\"nowrap\\\"> <strong>NEXT</strong> </td> </tr> <!-- NEXT/PREV CAPTURE NAV AND DAY OF MONTH INDICATOR --> <tr> <td style=\\\"padding-right:9px;white-space:nowrap;overflow:visible;text-align:right!important;vertical-align:middle!important;\\\" nowrap=\\\"nowrap\\\"> <a href=\\\"\"\n + TextDocument2.SERVER_PREFIX + \"warcbase/servlet?date=\" + prevDate + \"&query=\" + query\n + \"\\\" title=\\\"\"\n + prevDate\n + \"\\\" style=\\\"background-color:transparent;border:none;\\\"><img src=\\\"\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_prv_on.png\\\" alt=\\\"Previous capture\\\" border=\\\"0\\\" height=\\\"16\\\" width=\\\"14\\\"></a> </td> <td style=\\\"padding-left:9px;white-space:nowrap;overflow:visible;text-align:left!important;vertical-align:middle!important;\\\" nowrap=\\\"nowrap\\\"> <a href=\\\"\"\n + TextDocument2.SERVER_PREFIX + \"warcbase/servlet?date=\" + nextDate + \"&query=\" + query\n + \"\\\" title=\\\"\"\n + nextDate\n + \"\\\" style=\\\"background-color:transparent;border:none;\\\"><img src=\\\"\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_nxt_on.png\\\" alt=\\\"Next capture\\\" border=\\\"0\\\" height=\\\"16\\\" width=\\\"14\\\"></a> </td> </tr> </tbody></table> </td> </tr> <tr> <td style=\\\"vertical-align:middle;padding:0!important;\\\"> <strong>\"\n + \" \" + num + \" captures\"\n + \"</strong> <div style=\\\"margin:0!important;padding:0!important;color:#666;font-size:9px;padding-top:2px!important;white-space:nowrap;\\\" title=\\\"Timespan for captures of this URL\\\">\"\n + dates.get(0).substring(0, 10) + \" - \" + dates.get(dates.size() - 1).substring(0, 10)\n + \"</div> </td> </tr></tbody></table> </td> <td style=\\\"text-align:right;padding:5px;width:65px;font-size:11px!important;\\\"> <a href=\\\"javascript:;\\\" onclick=\\\"document.getElementById('wm-ipp').style.display='none';\\\" style=\\\"display:block;padding-right:18px;background:url(images/wm_tb_close.png) no-repeat 100% 0;color:#33f;font-family:'Lucida Grande','Arial',sans-serif;margin-bottom:23px;background-color:transparent;border:none;\\\" title=\\\"Close the toolbar\\\">Close</a> </td> </tr></tbody></table> </div> </div> <style type=\\\"text/css\\\">body{margin-top:0!important;padding-top:0!important;min-width:800px!important;}#wm-ipp a:hover{text-decoration:underline!important;}</style>\");\n bodyContent = doc.html();\n out.println(bodyContent);\n }\n", "output": " private void writeResponse(HttpServletResponse resp, Result rs, byte[] data, String query, String d, int num)\n throws IOException {\n HttpResponseRecord httpResponseRecord = new HttpResponseRecord(data);\n if (httpResponseRecord.getType().startsWith(\"text/plain\") || !httpResponseRecord.getType().startsWith(\"text\")) {\n resp.setHeader(\"Content-Type\", httpResponseRecord.getType());\n resp.setContentLength(httpResponseRecord.getBodyByte().length);\n resp.getOutputStream().write(httpResponseRecord.getBodyByte());\n } else {\n ArrayList<String> dates = new ArrayList<String>(10);\n for (int i = 0; i < rs.raw().length; i++)\n dates.add(new String(rs.raw()[i].getQualifier()));\n Collections.sort(dates);\n String prevDate = null, nextDate = null;\n for (int i = 1; i < dates.size(); i++){\n if (dates.get(i).compareTo(d) == 0){\n prevDate = dates.get(i - 1);\n if (i + 1 < dates.size())\n nextDate = dates.get(i + 1);\n else\n nextDate = d;\n break;\n }\n if (dates.get(i).compareTo(d) > 0) {\n if ( i > 2)\n prevDate = dates.get(i - 2);\n else\n prevDate = dates.get(i - 1);\n nextDate = dates.get(i);\n break;\n }\n }\n System.setProperty(\"file.encoding\", \"UTF8\");\n resp.setHeader(\"Content-Type\", httpResponseRecord.getType());\n resp.setCharacterEncoding(\"UTF-8\");\n PrintWriter out = resp.getWriter();\n TextDocument2 t2 = new TextDocument2(null, null, null);\n String bodyContent = new String(httpResponseRecord.getBodyByte(), \"UTF8\");\n Document doc = Jsoup.parse(bodyContent);\n Element head = doc.select(\"head\").first();\n Element base = doc.select(\"base\").first();\n if(base == null){\n head.prepend(\"<base id='warcbase-base-added' href='\" + query +\"'>\");\n }\n bodyContent = doc.html();\n bodyContent = t2.fixURLs(bodyContent, query, d);\n doc = Jsoup.parse(bodyContent);\n base = doc.select(\"base\").first();\n if(base != null){\n if(base.attr(\"id\").equals(\"warcbase-base-added\"))\n base.remove();\n }\n head = doc.select(\"head\").first();\n String baseUrl = TextDocument2.SERVER_PREFIX + \"warcbase/servlet?date=\" + d + \"&query=\" + query;\n head.prepend(\"<script type=\\\"text/javascript\\\"> function initYTVideo(id) { _wmVideos_.init('/web/', id); } </script> <script> function $(a){return document.getElementById(a)}; function addLoadEvent(a){if(window.addEventListener)addEventListener('load',a,false);else if(window.attachEvent)attachEvent('onload',a)} </script>\");\n Element body = doc.select(\"body\").first();\n body.prepend(\"<div id=\\\"wm-ipp\\\" style=\\\"display: block; position: relative; padding: 0px 5px; min-height: 70px; min-width: 800px; z-index: 9000;\\\"><div id=\\\"wm-ipp-inside\\\" style=\\\"position:fixed;padding:0!important;margin:0!important;width:97%;min-width:780px;border:5px solid #000;border-top:none;background-image:url(\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_bk_trns.png);text-align:center;-moz-box-shadow:1px 1px 3px #333;-webkit-box-shadow:1px 1px 3px #333;box-shadow:1px 1px 3px #333;font-size:11px!important;font-family:'Lucida Grande','Arial',sans-serif!important;\\\"> <table style=\\\"border-collapse:collapse;margin:0;padding:0;width:100%;\\\"><tbody><tr> <td style=\\\"padding:10px;vertical-align:top;min-width:110px;\\\"> <a href=\\\"\"\n + TextDocument2.SERVER_PREFIX + \"warcbase\"\n + \"\\\" title=\\\"Warcbase home page\\\" style=\\\"background-color:transparent;border:none;\\\">Warcbase</a> </td> <td style=\\\"padding:0!important;text-align:center;vertical-align:top;width:100%;\\\"> <table style=\\\"border-collapse:collapse;margin:0 auto;padding:0;width:570px;\\\"><tbody><tr> <td style=\\\"padding:3px 0;\\\" colspan=\\\"2\\\"> <form target=\\\"_top\\\" method=\\\"get\\\" action=\\\"\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"servlet\\\" name=\\\"wmtb\\\" id=\\\"wmtb\\\" style=\\\"margin:0!important;padding:0!important;\\\"><input name=\\\"query\\\" id=\\\"wmtbURL\\\" value=\\\"\"\n + query\n + \"\\\" style=\\\"width:400px;font-size:11px;font-family:'Lucida Grande','Arial',sans-serif;\\\" onfocus=\\\"javascript:this.focus();this.select();\\\" type=\\\"text\\\"><input name=\\\"date\\\" value=\\\"\\\" type=\\\"hidden\\\"><input name=\\\"type\\\" value=\\\"replay\\\" type=\\\"hidden\\\"><input name=\\\"date\\\" value=\\\"20120201185436\\\" type=\\\"hidden\\\"><input value=\\\"Go\\\" style=\\\"font-size:11px;font-family:'Lucida Grande','Arial',sans-serif;margin-left:5px;\\\" type=\\\"submit\\\"><span id=\\\"wm_tb_options\\\" style=\\\"display:block;\\\"></span></form> </td> <td style=\\\"vertical-align:bottom;padding:5px 0 0 0!important;\\\" rowspan=\\\"2\\\"> <table style=\\\"border-collapse:collapse;width:110px;color:#99a;font-family:'Helvetica','Lucida Grande','Arial',sans-serif;\\\"><tbody> <!-- NEXT/PREV MONTH NAV AND MONTH INDICATOR --> <tr style=\\\"width:110px;height:16px;font-size:10px!important;\\\"> <td style=\\\"padding-right:9px;font-size:11px!important;font-weight:bold;text-transform:uppercase;text-align:right;white-space:nowrap;overflow:visible;\\\" nowrap=\\\"nowrap\\\"> <strong>PREV</strong> </td> <td style=\\\"padding-left:9px;font-size:11px!important;font-weight:bold;text-transform:uppercase;white-space:nowrap;overflow:visible;\\\" nowrap=\\\"nowrap\\\"> <strong>NEXT</strong> </td> </tr> <!-- NEXT/PREV CAPTURE NAV AND DAY OF MONTH INDICATOR --> <tr> <td style=\\\"padding-right:9px;white-space:nowrap;overflow:visible;text-align:right!important;vertical-align:middle!important;\\\" nowrap=\\\"nowrap\\\"> <a href=\\\"\"\n + TextDocument2.SERVER_PREFIX + \"warcbase/servlet?date=\" + prevDate + \"&query=\" + query\n + \"\\\" title=\\\"\"\n + prevDate\n + \"\\\" style=\\\"background-color:transparent;border:none;\\\"><img src=\\\"\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_prv_on.png\\\" alt=\\\"Previous capture\\\" border=\\\"0\\\" height=\\\"16\\\" width=\\\"14\\\"></a> </td> <td style=\\\"padding-left:9px;white-space:nowrap;overflow:visible;text-align:left!important;vertical-align:middle!important;\\\" nowrap=\\\"nowrap\\\"> <a href=\\\"\"\n + TextDocument2.SERVER_PREFIX + \"warcbase/servlet?date=\" + nextDate + \"&query=\" + query\n + \"\\\" title=\\\"\"\n + nextDate\n + \"\\\" style=\\\"background-color:transparent;border:none;\\\"><img src=\\\"\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_nxt_on.png\\\" alt=\\\"Next capture\\\" border=\\\"0\\\" height=\\\"16\\\" width=\\\"14\\\"></a> </td> </tr> </tbody></table> </td> </tr> <tr> <td style=\\\"vertical-align:middle;padding:0!important;\\\"> <strong>\"\n + \" \" + num + \" captures\"\n + \"</strong> <div style=\\\"margin:0!important;padding:0!important;color:#666;font-size:9px;padding-top:2px!important;white-space:nowrap;\\\" title=\\\"Timespan for captures of this URL\\\">\"\n + dates.get(0).substring(0, 10) + \" - \" + dates.get(dates.size() - 1).substring(0, 10)\n + \"</div> </td> </tr></tbody></table> </td> <td style=\\\"text-align:right;padding:5px;width:65px;font-size:11px!important;\\\"> <a href=\\\"javascript:;\\\" onclick=\\\"document.getElementById('wm-ipp').style.display='none';\\\" style=\\\"display:block;padding-right:18px;background:url(\" + TextDocument2.SERVER_PREFIX + \"warcbase/\" + \"images/wm_tb_close.png) no-repeat 100% 0;color:#33f;font-family:'Lucida Grande','Arial',sans-serif;margin-bottom:23px;background-color:transparent;border:none;\\\" title=\\\"Close the toolbar\\\">Close</a> </td> </tr></tbody></table> </div> </div> <style type=\\\"text/css\\\">body{margin-top:0!important;padding-top:0!important;min-width:800px!important;}#wm-ipp a:hover{text-decoration:underline!important;}</style>\");\n bodyContent = doc.html();\n out.println(bodyContent);\n }\n"} {"input": " private synchronized Class inject(String className, byte[] image) {\n Class c = classes.get(className);\n if(c==null) {\n try {\n c = (Class)defineClass.invoke(parent,className.replace('/','.'),image,0,image.length);\n resolveClass.invoke(parent,c);\n } catch (IllegalAccessException e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n } catch (InvocationTargetException e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n } catch (SecurityException e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n }\n classes.put(className,c);\n }\n return c;\n }\n", "output": " private synchronized Class inject(String className, byte[] image) {\n Class c = classes.get(className);\n if(c==null) {\n try {\n c = (Class)defineClass.invoke(parent,className.replace('/','.'),image,0,image.length);\n resolveClass.invoke(parent,c);\n } catch (IllegalAccessException e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n } catch (InvocationTargetException e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n } catch (SecurityException e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n } catch (LinkageError e) {\n logger.log(Level.FINE,\"Unable to inject \"+className,e);\n return null;\n }\n classes.put(className,c);\n }\n return c;\n }\n"} {"input": "\tprivate TraverseResult traverseOnce(Result<IValue> subject, CasesOrRules casesOrRules, \n\t\t\tDIRECTION direction, \n\t\t\tPROGRESS progress){\n\t\tType subjectType = subject.getType();\n\t\tboolean matched = false;\n\t\tboolean changed = false;\n\t\tResult<IValue> result = subject;\n\t\tif(subjectType.isStringType()){\n\t\t\treturn traverseString(subject, casesOrRules);\n\t\t}\n\t\tif(direction == DIRECTION.TopDown){\n\t\t\tTraverseResult tr = traverseTop(subject, casesOrRules);\n\t\t\tmatched |= tr.matched;\n\t\t\tchanged |= tr.changed;\n\t\t\tif((progress == PROGRESS.Breaking) && changed){\n\t\t\t\treturn tr;\n\t\t\t}\n\t\t\tsubject = tr.value;\n\t\t}\n\t\tif(subjectType.isAbstractDataType()){\n\t\t\tIConstructor cons = (IConstructor)subject.getValue();\n\t\t\tif(cons.arity() == 0){\n\t\t\t\tresult = subject;\n\t\t\t} else {\n\t\t\t\tIValue args[] = new IValue[cons.arity()];\n\t\t\t\tfor(int i = 0; i < cons.arity(); i++){\n\t\t\t\t\tIValue child = cons.get(i);\n\t\t\t\t\tType childType = cons.getConstructorType().getFieldType(i);\n\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(childType, child, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\targs[i] = tr.value.getValue();\n\t\t\t\t}\n\t\t\t\tIConstructor rcons = vf.constructor(cons.getConstructorType(), args);\n\t\t\t\tresult = applyRules(makeResult(subjectType, rcons.setAnnotations(cons.getAnnotations()), makeEvContext()));\n\t\t\t}\n\t\t} else\n\t\t\tif(subjectType.isNodeType()){\n\t\t\t\tINode node = (INode)subject.getValue();\n\t\t\t\tif(node.arity() == 0){\n\t\t\t\t\tresult = subject;\n\t\t\t\t} else {\n\t\t\t\t\tIValue args[] = new IValue[node.arity()];\n\t\t\t\t\tfor(int i = 0; i < node.arity(); i++){\n\t\t\t\t\t\tIValue child = node.get(i);\n\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(tf.valueType(), child, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\targs[i] = tr.value.getValue();\n\t\t\t\t\t}\n\t\t\t\t\tresult = applyRules(makeResult(tf.nodeType(), vf.node(node.getName(), args).setAnnotations(node.getAnnotations()), makeEvContext()));\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\tif(subjectType.isListType()){\n\t\t\t\t\tIList list = (IList) subject;\n\t\t\t\t\tint len = list.length();\n\t\t\t\t\tif(len > 0){\n\t\t\t\t\t\tIListWriter w = list.getType().writer(vf);\n\t\t\t\t\t\tType elemType = list.getType().getElementType();\n\t\t\t\t\t\tfor(int i = len - 1; i >= 0; i--){\n\t\t\t\t\t\t\tIValue elem = list.get(i);\n\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, elem, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\tw.insert(tr.value.getValue());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresult = makeResult(subjectType, w.done(), makeEvContext());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t}\n\t\t\t\t} else \n\t\t\t\t\tif(subjectType.isSetType()){\n\t\t\t\t\t\tISet set = (ISet) subject;\n\t\t\t\t\t\tif(!set.isEmpty()){\n\t\t\t\t\t\t\tISetWriter w = set.getType().writer(vf);\n\t\t\t\t\t\t\tType elemType = set.getType().getElementType();\n\t\t\t\t\t\t\tfor (IValue v : set){\n\t\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, v, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\tw.insert(tr.value.getValue());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresult = makeResult(subjectType, w.done(), makeEvContext());\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else\n\t\t\t\t\t\tif (subjectType.isMapType()) {\n\t\t\t\t\t\t\tIMap map = (IMap) subject.getValue();\n\t\t\t\t\t\t\tif(!map.isEmpty()){\n\t\t\t\t\t\t\t\tIMapWriter w = map.getType().writer(vf);\n\t\t\t\t\t\t\t\tIterator<Entry<IValue,IValue>> iter = map.entryIterator();\n\t\t\t\t\t\t\t\tType keyType = map.getKeyType();\n\t\t\t\t\t\t\t\tType valueType = map.getValueType();\n\t\t\t\t\t\t\t\twhile (iter.hasNext()) {\n\t\t\t\t\t\t\t\t\tEntry<IValue,IValue> entry = iter.next();\n\t\t\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(keyType, entry.getKey(), makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\t\tIValue newKey = tr.value.getValue();\n\t\t\t\t\t\t\t\t\ttr = traverseOnce(ResultFactory.makeResult(valueType, entry.getValue(), makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\t\tIValue newValue = tr.value.getValue();\n\t\t\t\t\t\t\t\t\tw.put(newKey, newValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tresult = makeResult(subjectType, w.done(), makeEvContext());\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tif(subjectType.isTupleType()){\n\t\t\t\t\t\t\t\tITuple tuple = (ITuple) subject.getValue();\n\t\t\t\t\t\t\t\tint arity = tuple.arity();\n\t\t\t\t\t\t\t\tIValue args[] = new IValue[arity];\n\t\t\t\t\t\t\t\tfor(int i = 0; i < arity; i++){\n\t\t\t\t\t\t\t\t\tType fieldType = subjectType.getFieldType(i);\n\t\t\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(fieldType, tuple.get(i), makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\t\targs[i] = tr.value.getValue();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tresult = makeResult(subjectType, vf.tuple(args), makeEvContext());\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t\t\t}\n\t\tif(direction == DIRECTION.BottomUp){\n\t\t\tif((progress == PROGRESS.Breaking) && changed){\n\t\t\t\treturn new TraverseResult(matched, result, changed);\n\t\t\t}\n\t\t\tTraverseResult tr = traverseTop(result, casesOrRules);\n\t\t\tmatched |= tr.matched;\n\t\t\tchanged |= tr.changed;\n\t\t\treturn new TraverseResult(matched, tr.value, changed);\n\t\t}\n\t\treturn new TraverseResult(matched,result,changed);\n\t}\n", "output": "\tprivate TraverseResult traverseOnce(Result<IValue> subject, CasesOrRules casesOrRules, \n\t\t\tDIRECTION direction, \n\t\t\tPROGRESS progress){\n\t\tType subjectType = subject.getType();\n\t\tboolean matched = false;\n\t\tboolean changed = false;\n\t\tResult<IValue> result = subject;\n\t\tif(subjectType.isStringType()){\n\t\t\treturn traverseString(subject, casesOrRules);\n\t\t}\n\t\tif(direction == DIRECTION.TopDown){\n\t\t\tTraverseResult tr = traverseTop(subject, casesOrRules);\n\t\t\tmatched |= tr.matched;\n\t\t\tchanged |= tr.changed;\n\t\t\tif((progress == PROGRESS.Breaking) && changed){\n\t\t\t\treturn tr;\n\t\t\t}\n\t\t\tsubject = tr.value;\n\t\t}\n\t\tif(subjectType.isAbstractDataType()){\n\t\t\tIConstructor cons = (IConstructor)subject.getValue();\n\t\t\tif(cons.arity() == 0){\n\t\t\t\tresult = subject;\n\t\t\t} else {\n\t\t\t\tIValue args[] = new IValue[cons.arity()];\n\t\t\t\tfor(int i = 0; i < cons.arity(); i++){\n\t\t\t\t\tIValue child = cons.get(i);\n\t\t\t\t\tType childType = cons.getConstructorType().getFieldType(i);\n\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(childType, child, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\targs[i] = tr.value.getValue();\n\t\t\t\t}\n\t\t\t\tIConstructor rcons = vf.constructor(cons.getConstructorType(), args);\n\t\t\t\tresult = applyRules(makeResult(subjectType, rcons.setAnnotations(cons.getAnnotations()), makeEvContext()));\n\t\t\t}\n\t\t} else\n\t\t\tif(subjectType.isNodeType()){\n\t\t\t\tINode node = (INode)subject.getValue();\n\t\t\t\tif(node.arity() == 0){\n\t\t\t\t\tresult = subject;\n\t\t\t\t} else {\n\t\t\t\t\tIValue args[] = new IValue[node.arity()];\n\t\t\t\t\tfor(int i = 0; i < node.arity(); i++){\n\t\t\t\t\t\tIValue child = node.get(i);\n\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(tf.valueType(), child, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\targs[i] = tr.value.getValue();\n\t\t\t\t\t}\n\t\t\t\t\tresult = applyRules(makeResult(tf.nodeType(), vf.node(node.getName(), args).setAnnotations(node.getAnnotations()), makeEvContext()));\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\tif(subjectType.isListType()){\n\t\t\t\t\tIList list = (IList) subject.getValue();\n\t\t\t\t\tint len = list.length();\n\t\t\t\t\tif(len > 0){\n\t\t\t\t\t\tIListWriter w = list.getType().writer(vf);\n\t\t\t\t\t\tType elemType = list.getType().getElementType();\n\t\t\t\t\t\tfor(int i = len - 1; i >= 0; i--){\n\t\t\t\t\t\t\tIValue elem = list.get(i);\n\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, elem, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\tw.insert(tr.value.getValue());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresult = makeResult(subjectType, w.done(), makeEvContext());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t}\n\t\t\t\t} else \n\t\t\t\t\tif(subjectType.isSetType()){\n\t\t\t\t\t\tISet set = (ISet) subject;\n\t\t\t\t\t\tif(!set.isEmpty()){\n\t\t\t\t\t\t\tISetWriter w = set.getType().writer(vf);\n\t\t\t\t\t\t\tType elemType = set.getType().getElementType();\n\t\t\t\t\t\t\tfor (IValue v : set){\n\t\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(elemType, v, makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\tw.insert(tr.value.getValue());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tresult = makeResult(subjectType, w.done(), makeEvContext());\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else\n\t\t\t\t\t\tif (subjectType.isMapType()) {\n\t\t\t\t\t\t\tIMap map = (IMap) subject.getValue();\n\t\t\t\t\t\t\tif(!map.isEmpty()){\n\t\t\t\t\t\t\t\tIMapWriter w = map.getType().writer(vf);\n\t\t\t\t\t\t\t\tIterator<Entry<IValue,IValue>> iter = map.entryIterator();\n\t\t\t\t\t\t\t\tType keyType = map.getKeyType();\n\t\t\t\t\t\t\t\tType valueType = map.getValueType();\n\t\t\t\t\t\t\t\twhile (iter.hasNext()) {\n\t\t\t\t\t\t\t\t\tEntry<IValue,IValue> entry = iter.next();\n\t\t\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(keyType, entry.getKey(), makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\t\tIValue newKey = tr.value.getValue();\n\t\t\t\t\t\t\t\t\ttr = traverseOnce(ResultFactory.makeResult(valueType, entry.getValue(), makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\t\tIValue newValue = tr.value.getValue();\n\t\t\t\t\t\t\t\t\tw.put(newKey, newValue);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tresult = makeResult(subjectType, w.done(), makeEvContext());\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tif(subjectType.isTupleType()){\n\t\t\t\t\t\t\t\tITuple tuple = (ITuple) subject.getValue();\n\t\t\t\t\t\t\t\tint arity = tuple.arity();\n\t\t\t\t\t\t\t\tIValue args[] = new IValue[arity];\n\t\t\t\t\t\t\t\tfor(int i = 0; i < arity; i++){\n\t\t\t\t\t\t\t\t\tType fieldType = subjectType.getFieldType(i);\n\t\t\t\t\t\t\t\t\tTraverseResult tr = traverseOnce(ResultFactory.makeResult(fieldType, tuple.get(i), makeEvContext()), casesOrRules, direction, progress);\n\t\t\t\t\t\t\t\t\tmatched |= tr.matched;\n\t\t\t\t\t\t\t\t\tchanged |= tr.changed;\n\t\t\t\t\t\t\t\t\targs[i] = tr.value.getValue();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tresult = makeResult(subjectType, vf.tuple(args), makeEvContext());\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresult = subject;\n\t\t\t\t\t\t\t}\n\t\tif(direction == DIRECTION.BottomUp){\n\t\t\tif((progress == PROGRESS.Breaking) && changed){\n\t\t\t\treturn new TraverseResult(matched, result, changed);\n\t\t\t}\n\t\t\tTraverseResult tr = traverseTop(result, casesOrRules);\n\t\t\tmatched |= tr.matched;\n\t\t\tchanged |= tr.changed;\n\t\t\treturn new TraverseResult(matched, tr.value, changed);\n\t\t}\n\t\treturn new TraverseResult(matched,result,changed);\n\t}\n"} {"input": "\tpublic static IEclipsePreferences getDefaultPreferences() {\n\t\tIEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(AcceleoCommonUIPlugin.PLUGIN_ID);\n\t\treturn preferences;\n\t}\n", "output": "\tpublic static IEclipsePreferences getDefaultPreferences() {\n\t\tIEclipsePreferences preferences = new InstanceScope().getNode(AcceleoCommonUIPlugin.PLUGIN_ID);\n\t\treturn preferences;\n\t}\n"} {"input": " private static List<DefactoModel> getTrainingData(String pathToFalseTrainingDirectory) throws IOException {\n List<File> modelFiles = new ArrayList<File>(Arrays.asList(new File(\"resources/training/data/true\").listFiles()));\n modelFiles.addAll(Arrays.asList(new File(\"resources/training/data/false/\" + pathToFalseTrainingDirectory).listFiles()));\n Collections.sort(modelFiles);\n List<String> confirmedFilenames = FileUtils.readLines(new File(\"resources/training/properties/confirmed_properties_master.txt\"));\n List<DefactoModel> models = new ArrayList<DefactoModel>();\n for (File mappingFile : modelFiles) {\n if (!mappingFile.isHidden() && confirmedFilenames.contains(mappingFile.getName())) {\n try {\n Model model = ModelFactory.createDefaultModel();\n model.read(new FileReader(mappingFile), \"\", \"TTL\");\n String name = mappingFile.getParent().replace(\"resources/training/data/\", \"\") + \"/\" + mappingFile.getName();\n boolean isCorrect = false;\n if (mappingFile.getAbsolutePath().contains(\"data/true\")) isCorrect = true;\n logger.info(\"Loading \"+isCorrect+\" triple from file: \" + mappingFile.getName());\n models.add(new DefactoModel(model, name, isCorrect));\n }\n catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n }\n return models;\n }\n", "output": " private static List<DefactoModel> getTrainingData(String pathToFalseTrainingDirectory) throws IOException {\n List<File> modelFiles = new ArrayList<File>(Arrays.asList(new File(\"resources/training/data/true\").listFiles()));\n modelFiles.addAll(Arrays.asList(new File(\"resources/training/data/false/\" + pathToFalseTrainingDirectory).listFiles()));\n Collections.sort(modelFiles);\n List<String> confirmedFilenames = FileUtils.readLines(new File(\"resources/properties/confirmed_properties_master.txt\"));\n List<DefactoModel> models = new ArrayList<DefactoModel>();\n for (File mappingFile : modelFiles) {\n if (!mappingFile.isHidden() && confirmedFilenames.contains(mappingFile.getName())) {\n try {\n Model model = ModelFactory.createDefaultModel();\n model.read(new FileReader(mappingFile), \"\", \"TTL\");\n String name = mappingFile.getParent().replace(\"resources/training/data/\", \"\") + \"/\" + mappingFile.getName();\n boolean isCorrect = false;\n if (mappingFile.getAbsolutePath().contains(\"data/true\")) isCorrect = true;\n logger.info(\"Loading \"+isCorrect+\" triple from file: \" + mappingFile.getName());\n models.add(new DefactoModel(model, name, isCorrect));\n }\n catch (FileNotFoundException e) {\n e.printStackTrace();\n }\n }\n }\n return models;\n }\n"} {"input": "\tpublic CapoApplication() throws Exception\n\t{\n\t setApplication(this);\t\t\n\t\tSystem.setProperty(\"java.util.prefs.syncInterval\", \"2000000\");\n\t\tSystem.setProperty(\"javax.xml.xpath.XPathFactory\", \"net.sf.saxon.xpath.XPathFactoryImpl\");\n\t\tSystem.setProperty(\"javax.xml.transform.TransformerFactory\", \"net.sf.saxon.TransformerFactoryImpl\");\n\t\tSystem.setProperty(\"javax.xml.parsers.DocumentBuilderFactory\", \"com.delcyon.capo.xml.cdom.CDocumentBuilderFactory\");\n\t\tSystem.setProperty(\"sun.security.ssl.allowUnsafeRenegotiation\", \"true\");\n\t\tSystem.setProperty(\"sun.security.ssl.allowLegacyHelloMessages\", \"true\");\n\t\tif (logger == null)\n\t\t{\n\t\t\tlogger = Logger.getLogger(this.getClass().getName());\n\t\t\tlogger.setLevel(LOGGING_LEVEL);\n\t\t\tif (logger.getHandlers().length == 0) \n\t\t\t{\n\t\t\t\tif (leveledConsoleHandler == null)\n\t\t\t\t{\n\t\t\t\t\tleveledConsoleHandler = new LeveledConsoleHandler();\n\t\t\t\t\tleveledConsoleHandler.setLevel(LOGGING_LEVEL);\n\t\t\t\t\tleveledConsoleHandler.setOutputForLevel(Output.STDERR, Level.FINER);\n\t\t\t\t\tleveledConsoleHandler.setFormatter(new LogPrefixFormatter(getApplication().getApplicationDirectoryName().toUpperCase()+\": \"));\n\t\t\t\t\tlogger.setUseParentHandlers(false);\n\t\t\t\t\tlogger.addHandler(leveledConsoleHandler);\t\t\t\t\n\t\t\t\t}\n\t\t\t\tif (fileHandler == null)\n\t\t\t\t{\n\t\t\t\t\tlogFileName = getApplication().getApplicationDirectoryName().replaceAll(\" \", \"_\").toLowerCase() + \".log\";\n\t\t\t\t\tlogger.log(Level.FINE, \"Opening LogElement File:\" + logFileName);\n\t\t\t\t\tfileHandler = new FileHandler(logFileName);\n\t\t\t\t\tfileHandler.setLevel(LOGGING_LEVEL);\n\t\t\t\t\tlogger.addHandler(fileHandler);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlogger.log(Level.INFO, \"Starting Capo \"+getApplication().getApplicationDirectoryName());\n\t\tMimeUtil.registerMimeDetector(\"eu.medsea.mimeutil.detector.MagicMimeMimeDetector\");\n\t\tMimeUtil.registerMimeDetector(\"eu.medsea.mimeutil.detector.ExtensionMimeDetector\");\n\t\tdocumentBuilderFactory = DocumentBuilderFactory.newInstance();\n\t\tdocumentBuilderFactory.setNamespaceAware(true);\n\t\tTransformerFactory tFactory = TransformerFactory.newInstance();\n\t\ttransformer = tFactory.newTransformer();\n\t\ttransformer.setOutputProperty(OutputKeys.INDENT, \"yes\");\n\t\tURL[] urls = ClasspathUrlFinder.findClassPaths();\n\t\tAnnotationDB annotationDB = new AnnotationDB();\n\t\tannotationDB.scanArchives(urls);\n\t\tannotaionMap = annotationDB.getAnnotationIndex();\n\t\tXPath.setXPathFunctionResolver(new CapoXPathFunctionResolver());\n\t}\n", "output": "\tpublic CapoApplication() throws Exception\n\t{\n\t setApplication(this);\t\t\n\t\tSystem.setProperty(\"java.util.prefs.syncInterval\", \"2000000\");\n\t\tSystem.setProperty(\"javax.xml.xpath.XPathFactory\", \"net.sf.saxon.xpath.XPathFactoryImpl\");\n\t\tSystem.setProperty(\"javax.xml.transform.TransformerFactory\", \"net.sf.saxon.TransformerFactoryImpl\");\n\t\tSystem.setProperty(\"javax.xml.parsers.DocumentBuilderFactory\", \"com.delcyon.capo.xml.cdom.CDocumentBuilderFactory\");\n\t\tSystem.setProperty(\"sun.security.ssl.allowUnsafeRenegotiation\", \"true\");\n\t\tSystem.setProperty(\"sun.security.ssl.allowLegacyHelloMessages\", \"true\");\n\t\tSystem.setProperty(\"hsqldb.reconfig_logging\", \"false\"); \n\t\tif (logger == null)\n\t\t{\n\t\t\tlogger = Logger.getLogger(this.getClass().getName());\n\t\t\tlogger.setLevel(LOGGING_LEVEL);\n\t\t\tif (logger.getHandlers().length == 0) \n\t\t\t{\n\t\t\t\tif (leveledConsoleHandler == null)\n\t\t\t\t{\n\t\t\t\t\tleveledConsoleHandler = new LeveledConsoleHandler();\n\t\t\t\t\tleveledConsoleHandler.setLevel(LOGGING_LEVEL);\n\t\t\t\t\tleveledConsoleHandler.setOutputForLevel(Output.STDERR, Level.FINER);\n\t\t\t\t\tleveledConsoleHandler.setFormatter(new LogPrefixFormatter(getApplication().getApplicationDirectoryName().toUpperCase()+\": \"));\n\t\t\t\t\tlogger.setUseParentHandlers(false);\n\t\t\t\t\tlogger.addHandler(leveledConsoleHandler);\t\t\t\t\n\t\t\t\t}\n\t\t\t\tif (fileHandler == null)\n\t\t\t\t{\n\t\t\t\t\tlogFileName = getApplication().getApplicationDirectoryName().replaceAll(\" \", \"_\").toLowerCase() + \".log\";\n\t\t\t\t\tlogger.log(Level.FINE, \"Opening LogElement File:\" + logFileName);\n\t\t\t\t\tfileHandler = new FileHandler(logFileName);\n\t\t\t\t\tfileHandler.setLevel(LOGGING_LEVEL);\n\t\t\t\t\tlogger.addHandler(fileHandler);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlogger.log(Level.INFO, \"Starting Capo \"+getApplication().getApplicationDirectoryName());\n\t\tMimeUtil.registerMimeDetector(\"eu.medsea.mimeutil.detector.MagicMimeMimeDetector\");\n\t\tMimeUtil.registerMimeDetector(\"eu.medsea.mimeutil.detector.ExtensionMimeDetector\");\n\t\tdocumentBuilderFactory = DocumentBuilderFactory.newInstance();\n\t\tdocumentBuilderFactory.setNamespaceAware(true);\n\t\tTransformerFactory tFactory = TransformerFactory.newInstance();\n\t\ttransformer = tFactory.newTransformer();\n\t\ttransformer.setOutputProperty(OutputKeys.INDENT, \"yes\");\n\t\tURL[] urls = ClasspathUrlFinder.findClassPaths();\n\t\tAnnotationDB annotationDB = new AnnotationDB();\n\t\tannotationDB.scanArchives(urls);\n\t\tannotaionMap = annotationDB.getAnnotationIndex();\n\t\tXPath.setXPathFunctionResolver(new CapoXPathFunctionResolver());\n\t}\n"} {"input": "\tpublic void save(Property property, User user) {\n\t\tif (property.getId() == null\n\t\t\t\t|| user.getId() == property.getId()) {\n\t\t\tpropertyDao.save(property);\n\t\t} else {\n\t\t\tthrow new PermissionDeniedException();\n\t\t}\n\t}\n", "output": "\tpublic void save(Property property, User user) {\n\t\tif (property.getId() == null\n\t\t\t\t|| user.getId() == property.getUser().getId()) {\n\t\t\tpropertyDao.save(property);\n\t\t} else {\n\t\t\tthrow new PermissionDeniedException();\n\t\t}\n\t}\n"} {"input": "\tprotected HTMLPanel instantiateWidget(Element element, String widgetId) \n\t{\n\t\tHTMLPanel ret = new HTMLPanel(element.getInnerHTML());\n\t\telement.setInnerHTML(\"\");\n\t\treturn ret;\n\t}\n", "output": "\tprotected HTMLPanel instantiateWidget(Element element, String widgetId) \n\t{\n\t\tString innerHTML = element.getInnerHTML();\n\t\telement.setInnerHTML(\"\");\n\t\tHTMLPanel ret = new HTMLPanel(innerHTML);\n\t\treturn ret;\n\t}\n"} {"input": " public void run()\n {\n resetManager.registerMe();\n try\n {\n IThreadContext threadContext = ThreadContextFactory.make();\n IJobManager jobManager = JobManagerFactory.make(threadContext);\n IOutputConnectionManager connectionManager = OutputConnectionManagerFactory.make(threadContext);\n IRepositoryConnectionManager repositoryConnectionManager = RepositoryConnectionManagerFactory.make(threadContext);\n while (true)\n {\n try\n {\n resetManager.waitForReset(threadContext);\n JobStartRecord[] jobsNeedingNotification = jobManager.getJobsReadyForInactivity();\n try\n {\n HashMap connectionNames = new HashMap();\n int k = 0;\n while (k < jobsNeedingNotification.length)\n {\n JobStartRecord jsr = jobsNeedingNotification[k++];\n Long jobID = jsr.getJobID();\n IJobDescription job = jobManager.load(jobID,true);\n if (job != null)\n {\n String repositoryConnectionName = job.getConnectionName();\n String outputConnectionName = job.getOutputConnectionName();\n OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);\n connectionNames.put(c,c);\n }\n }\n HashMap notifiedConnections = new HashMap();\n Iterator iter = connectionNames.keySet().iterator();\n while (iter.hasNext())\n {\n OutputAndRepositoryConnection connections = (OutputAndRepositoryConnection)iter.next();\n String outputConnectionName = connections.getOutputConnectionName();\n String repositoryConnectionName = connections.getRepositoryConnectionName();\n OutputNotifyActivity activity = new OutputNotifyActivity(repositoryConnectionName,repositoryConnectionManager,outputConnectionName);\n IOutputConnection connection = connectionManager.load(outputConnectionName);\n if (connection != null)\n {\n IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());\n if (connector != null)\n {\n try\n {\n try\n {\n connector.noteJobComplete(activity);\n notifiedConnections.put(connections,connections);\n }\n catch (ServiceInterruption e)\n {\n Logging.threads.warn(\"Service interruption notifying connection - retrying: \"+e.getMessage(),e);\n continue;\n }\n catch (ManifoldCFException e)\n {\n if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)\n throw e;\n if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)\n throw e;\n if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)\n throw e;\n Logging.threads.error(e.getMessage(),e);\n continue;\n }\n }\n finally\n {\n OutputConnectorFactory.release(connector);\n }\n }\n }\n }\n k = 0;\n while (k < jobsNeedingNotification.length)\n {\n JobStartRecord jsr = jobsNeedingNotification[k++];\n Long jobID = jsr.getJobID();\n IJobDescription job = jobManager.load(jobID,true);\n if (job != null)\n {\n String outputConnectionName = job.getOutputConnectionName();\n String repositoryConnectionName = job.getConnectionName();\n OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);\n if (notifiedConnections.get(c) != null)\n {\n jobManager.inactivateJob(jobID);\n jsr.noteStarted();\n }\n }\n }\n }\n finally\n {\n ManifoldCFException exception = null;\n int i = 0;\n while (i < jobsNeedingNotification.length)\n {\n JobStartRecord jsr = jobsNeedingNotification[i++];\n if (!jsr.wasStarted())\n {\n try\n {\n jobManager.resetNotifyJob(jsr.getJobID());\n }\n catch (ManifoldCFException e)\n {\n exception = e;\n }\n }\n }\n if (exception != null)\n throw exception;\n }\n ManifoldCF.sleep(10000L);\n }\n catch (ManifoldCFException e)\n {\n if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)\n break;\n if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)\n {\n resetManager.noteEvent();\n Logging.threads.error(\"Job notification thread aborting and restarting due to database connection reset: \"+e.getMessage(),e);\n try\n {\n ManifoldCF.sleep(10000L);\n }\n catch (InterruptedException se)\n {\n break;\n }\n continue;\n }\n Logging.threads.error(\"Exception tossed: \"+e.getMessage(),e);\n if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)\n {\n System.exit(1);\n }\n }\n catch (InterruptedException e)\n {\n break;\n }\n catch (OutOfMemoryError e)\n {\n System.err.println(\"agents process ran out of memory - shutting down\");\n e.printStackTrace(System.err);\n System.exit(-200);\n }\n catch (Throwable e)\n {\n Logging.threads.fatal(\"Error tossed: \"+e.getMessage(),e);\n }\n }\n }\n catch (Throwable e)\n {\n System.err.println(\"agents process could not start - shutting down\");\n Logging.threads.fatal(\"JobNotificationThread initialization error tossed: \"+e.getMessage(),e);\n System.exit(-300);\n }\n }\n", "output": " public void run()\n {\n resetManager.registerMe();\n try\n {\n IThreadContext threadContext = ThreadContextFactory.make();\n IJobManager jobManager = JobManagerFactory.make(threadContext);\n IOutputConnectionManager connectionManager = OutputConnectionManagerFactory.make(threadContext);\n IRepositoryConnectionManager repositoryConnectionManager = RepositoryConnectionManagerFactory.make(threadContext);\n while (true)\n {\n try\n {\n resetManager.waitForReset(threadContext);\n JobStartRecord[] jobsNeedingNotification = jobManager.getJobsReadyForInactivity();\n try\n {\n HashMap connectionNames = new HashMap();\n int k = 0;\n while (k < jobsNeedingNotification.length)\n {\n JobStartRecord jsr = jobsNeedingNotification[k++];\n Long jobID = jsr.getJobID();\n IJobDescription job = jobManager.load(jobID,true);\n if (job != null)\n {\n String repositoryConnectionName = job.getConnectionName();\n String outputConnectionName = job.getOutputConnectionName();\n OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);\n connectionNames.put(c,c);\n }\n }\n HashMap notifiedConnections = new HashMap();\n Iterator iter = connectionNames.keySet().iterator();\n while (iter.hasNext())\n {\n OutputAndRepositoryConnection connections = (OutputAndRepositoryConnection)iter.next();\n String outputConnectionName = connections.getOutputConnectionName();\n String repositoryConnectionName = connections.getRepositoryConnectionName();\n OutputNotifyActivity activity = new OutputNotifyActivity(repositoryConnectionName,repositoryConnectionManager,outputConnectionName);\n IOutputConnection connection = connectionManager.load(outputConnectionName);\n if (connection != null)\n {\n IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());\n if (connector != null)\n {\n try\n {\n try\n {\n connector.noteJobComplete(activity);\n }\n catch (ServiceInterruption e)\n {\n Logging.threads.warn(\"Service interruption notifying connection - retrying: \"+e.getMessage(),e);\n continue;\n }\n catch (ManifoldCFException e)\n {\n if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)\n throw e;\n if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)\n throw e;\n if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)\n throw e;\n Logging.threads.error(e.getMessage(),e);\n }\n notifiedConnections.put(connections,connections);\n }\n finally\n {\n OutputConnectorFactory.release(connector);\n }\n }\n }\n }\n k = 0;\n while (k < jobsNeedingNotification.length)\n {\n JobStartRecord jsr = jobsNeedingNotification[k++];\n Long jobID = jsr.getJobID();\n IJobDescription job = jobManager.load(jobID,true);\n if (job != null)\n {\n String outputConnectionName = job.getOutputConnectionName();\n String repositoryConnectionName = job.getConnectionName();\n OutputAndRepositoryConnection c = new OutputAndRepositoryConnection(outputConnectionName, repositoryConnectionName);\n if (notifiedConnections.get(c) != null)\n {\n jobManager.inactivateJob(jobID);\n jsr.noteStarted();\n }\n }\n }\n }\n finally\n {\n ManifoldCFException exception = null;\n int i = 0;\n while (i < jobsNeedingNotification.length)\n {\n JobStartRecord jsr = jobsNeedingNotification[i++];\n if (!jsr.wasStarted())\n {\n try\n {\n jobManager.resetNotifyJob(jsr.getJobID());\n }\n catch (ManifoldCFException e)\n {\n exception = e;\n }\n }\n }\n if (exception != null)\n throw exception;\n }\n ManifoldCF.sleep(10000L);\n }\n catch (ManifoldCFException e)\n {\n if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)\n break;\n if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR)\n {\n resetManager.noteEvent();\n Logging.threads.error(\"Job notification thread aborting and restarting due to database connection reset: \"+e.getMessage(),e);\n try\n {\n ManifoldCF.sleep(10000L);\n }\n catch (InterruptedException se)\n {\n break;\n }\n continue;\n }\n Logging.threads.error(\"Exception tossed: \"+e.getMessage(),e);\n if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)\n {\n System.exit(1);\n }\n }\n catch (InterruptedException e)\n {\n break;\n }\n catch (OutOfMemoryError e)\n {\n System.err.println(\"agents process ran out of memory - shutting down\");\n e.printStackTrace(System.err);\n System.exit(-200);\n }\n catch (Throwable e)\n {\n Logging.threads.fatal(\"Error tossed: \"+e.getMessage(),e);\n }\n }\n }\n catch (Throwable e)\n {\n System.err.println(\"agents process could not start - shutting down\");\n Logging.threads.fatal(\"JobNotificationThread initialization error tossed: \"+e.getMessage(),e);\n System.exit(-300);\n }\n }\n"} {"input": "\tprivate void updateCallLogForContact(Context context, Contact contact, String number) {\n\t\tUri allCalls = Uri.parse(\"content://call_log/calls\");\n\t\tLog.d(\"Contact\", \"Looking up :\"+contact.name+ \" with number: \"+number);\n\t\tCursor c = context.getContentResolver().query(allCalls, \n \t\tnew String[] {CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.TYPE, CallLog.Calls.DURATION, \"normalized_number\"},\n \t\tnull, null, null);\n if (c.moveToFirst()) {\n do {\n String num = c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));\n long timestamp = Long.parseLong(c.getString(c.getColumnIndex(CallLog.Calls.DATE)));\n int type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE)));\n int duration = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.DURATION)));\n final int CALL_DURATION_THRESH = 1;\n if (duration >= CALL_DURATION_THRESH && type != CallLog.Calls.MISSED_TYPE) {\n\t ContactEvent event = new ContactEvent();\n\t event.type = TYPE.CALL;\n\t event.timestamp = timestamp;\n\t event.callType = type;\n\t event.number = num;\n\t contact.contactEvents.add(event);\n\t if (event.timestamp > contact.lastcontact) {\n\t \t contact.lastcontact = event.timestamp;\n\t }\n }\n } while (c.moveToNext());\n }\t\n\t}\n", "output": "\tprivate void updateCallLogForContact(Context context, Contact contact, String number) {\n\t\tif (number == null) return; \n\t\tUri allCalls = Uri.parse(\"content://call_log/calls\");\n\t\tLog.d(\"Contact\", \"Looking up :\"+contact.name+ \" with number: \"+number);\n\t\tCursor c = context.getContentResolver().query(allCalls, \n \t\tnew String[] {CallLog.Calls.NUMBER, CallLog.Calls.DATE, CallLog.Calls.TYPE, CallLog.Calls.DURATION, \"normalized_number\"},\n \t\t\"normalized_number = ?\", new String[] {number}, null);\n if (c.moveToFirst()) {\n do {\n String num = c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));\n long timestamp = Long.parseLong(c.getString(c.getColumnIndex(CallLog.Calls.DATE)));\n int type = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.TYPE)));\n int duration = Integer.parseInt(c.getString(c.getColumnIndex(CallLog.Calls.DURATION)));\n final int CALL_DURATION_THRESH = 1;\n if (duration >= CALL_DURATION_THRESH && type != CallLog.Calls.MISSED_TYPE) {\n\t ContactEvent event = new ContactEvent();\n\t event.type = TYPE.CALL;\n\t event.timestamp = timestamp;\n\t event.callType = type;\n\t event.number = num;\n\t contact.contactEvents.add(event);\n\t if (event.timestamp > contact.lastcontact) {\n\t \t contact.lastcontact = event.timestamp;\n\t }\n }\n } while (c.moveToNext());\n }\t\n\t}\n"} {"input": "\tpublic static void realMain(String args[], PluginClassLoader pcl) throws Exception {\n\t\tSystem.out.println(\"ATL 0.2 Projector\");\n\t\tSystem.out.println();\n\t\tlong start = new Date().getTime();\n\t\tMap params = parseCommandLine(args);\n\t\tString plugins = (String)params.get(\"plugins\");\n\t\tif(plugins != null) {\n\t\t\tString ss[] = plugins.split(\",\");\n\t\t\tfor(Iterator i = Arrays.asList(ss).iterator() ; i.hasNext() ; ) {\n\t\t\t\tString plg = (String)i.next();\n\t\t\t\tSystem.out.println(\"Loading plugin: \" + plg);\n\t\t\t\tpcl.addLocation(plg);\n\t\t\t}\n\t\t}\n\t\tString modelLoaderName = (String)params.get(\"ModelLoader\");\n\t\tif(modelLoaderName == null)\n\t\t\tmodelLoaderName = \"MDR\";\n\t\tModelLoader ml = null;\n\t\tif(modelLoaderName.equals(\"MDR\")) {\n\t\t\tml = (ModelLoader)pcl.loadClass(\"org.eclipse.m2m.atl.drivers.mdr4atl.MDRModelLoader\").newInstance();\n\t\t} else {\n\t\t\tml = (ModelLoader)pcl.loadClass(\"org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader\").newInstance();\n\t\t}\n\t\ttry {\n\t\t\tml.addInjector(\"ebnf\", pcl.loadClass(\"org.eclipse.m2m.atl.engine.injectors.ebnf.EBNFInjector\"));\n\t\t\tml.addInjector(\"ebnf2\", pcl.loadClass(\"org.eclipse.m2m.atl.engine.injectors.ebnf.EBNFInjector2\"));\n\t\t} catch(Exception e) {\n\t\t}\n\t\ttry {\n\t\t\tml.addExtractor(\"ebnf\", pcl.loadClass(\"org.eclipse.m2m.atl.engine.extractors.ebnf.EBNFExtractor\"));\n\t\t} catch(Exception e) {\n\t\t}\n\t\ttry {\n\t\t\tml.addInjector(\"bin\", pcl.loadClass(\"org.eclipse.m2m.atl.engine.injectors.bin.BINInjector\"));\n\t\t} catch(Exception e) {\n\t\t}\n\t\tMap models = new HashMap();\n\t\tASMModel MOF = ml.getMOF();\n\t\tmodels.put(\"MOF\", MOF);\n\t\tloadModels(\"preload\", params, models, ml);\n\t\tASMModel M = loadModels(\"source\", params, models, ml);\n\t\tString target = (String)params.get(\"target\");\n\t\tml.save(M, target);\n\t\tlong end = new Date().getTime();\n\t\tSystem.out.println(\"Execution took \" + ((end - start) / 1000.) + \"s.\");\n\t}\n", "output": "\tpublic static void realMain(String args[], PluginClassLoader pcl) throws Exception {\n\t\tSystem.out.println(\"ATL 0.2 Projector\");\n\t\tSystem.out.println();\n\t\tlong start = new Date().getTime();\n\t\tMap params = parseCommandLine(args);\n\t\tString plugins = (String)params.get(\"plugins\");\n\t\tif(plugins != null) {\n\t\t\tString ss[] = plugins.split(\",\");\n\t\t\tfor(Iterator i = Arrays.asList(ss).iterator() ; i.hasNext() ; ) {\n\t\t\t\tString plg = (String)i.next();\n\t\t\t\tSystem.out.println(\"Loading plugin: \" + plg);\n\t\t\t\tpcl.addLocation(plg);\n\t\t\t}\n\t\t}\n\t\tString modelLoaderName = (String)params.get(\"ModelLoader\");\n\t\tif(modelLoaderName == null)\n\t\t\tmodelLoaderName = \"MDR\";\n\t\tModelLoader ml = null;\n\t\tif(modelLoaderName.equals(\"MDR\")) {\n\t\t\tml = (ModelLoader)pcl.loadClass(\"org.eclipse.m2m.atl.drivers.mdr4atl.MDRModelLoader\").newInstance();\n\t\t} else {\n\t\t\tml = (ModelLoader)pcl.loadClass(\"org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader\").newInstance();\n\t\t}\n\t\ttry {\n\t\t\tml.addInjector(\"ebnf\", pcl.loadClass(\"org.atl.engine.injectors.ebnf.EBNFInjector\"));\n\t\t\tml.addInjector(\"ebnf2\", pcl.loadClass(\"org.atl.engine.injectors.ebnf.EBNFInjector2\"));\n\t\t} catch(Exception e) {\n\t\t}\n\t\ttry {\n\t\t\tml.addExtractor(\"ebnf\", pcl.loadClass(\"org.atl.engine.extractors.ebnf.EBNFExtractor\"));\n\t\t} catch(Exception e) {\n\t\t}\n\t\ttry {\n\t\t\tml.addInjector(\"bin\", pcl.loadClass(\"org.atl.engine.injectors.bin.BINInjector\"));\n\t\t} catch(Exception e) {\n\t\t}\n\t\tMap models = new HashMap();\n\t\tASMModel MOF = ml.getMOF();\n\t\tmodels.put(\"MOF\", MOF);\n\t\tloadModels(\"preload\", params, models, ml);\n\t\tASMModel M = loadModels(\"source\", params, models, ml);\n\t\tString target = (String)params.get(\"target\");\n\t\tml.save(M, target);\n\t\tlong end = new Date().getTime();\n\t\tSystem.out.println(\"Execution took \" + ((end - start) / 1000.) + \"s.\");\n\t}\n"} {"input": " public void activate(ComponentContext context) throws Exception {\n server = new Server(8081);\n URL cfg = null;\n String cfgName = Framework.getProperty(\"org.nuxeo.jetty.config\");\n if (cfgName != null) {\n if (cfgName.contains(\":/\")) {\n cfg = new URL(cfgName);\n } else { \n File file = new File(cfgName);\n if (file.isFile()) {\n cfg = file.toURI().toURL();\n }\n }\n } else {\n File file = new File(Environment.getDefault().getConfig(), \"jetty.xml\");\n if (file.isFile()) {\n cfg = file.toURI().toURL();\n }\n }\n if (cfg != null) {\n XmlConfiguration configuration = new XmlConfiguration(cfg);\n configuration.configure(server);\n }\n Handler[] handlers = server.getHandlers();\n if (handlers != null && handlers.length > 0 && handlers[0] instanceof ContextHandlerCollection) {\n contexts = (ContextHandlerCollection)handlers[0];\n } else if (handlers == null || handlers.length == 0) {\n contexts = new ContextHandlerCollection();\n RequestLogHandler requestLogHandler = new RequestLogHandler();\n File logDir = Environment.getDefault().getLog();\n logDir.mkdirs();\n File logFile = new File(logDir, \"jetty.log\");\n NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());\n requestLogHandler.setRequestLog(requestLog);\n handlers = new Handler[] {contexts, new DefaultHandler(), requestLogHandler};\n server.setHandlers(handlers);\n server.setSendServerVersion(true);\n server.setStopAtShutdown(true);\n } else { \n contexts = new ContextHandlerCollection();\n Handler[] newHandlers = new Handler[handlers.length+1];\n newHandlers[0] = contexts;\n System.arraycopy(handlers, 0, newHandlers, 0, handlers.length);\n server.setHandlers(newHandlers);\n }\n server.start();\n }\n", "output": " public void activate(ComponentContext context) throws Exception {\n URL cfg = null;\n String cfgName = Framework.getProperty(\"org.nuxeo.jetty.config\");\n if (cfgName != null) {\n if (cfgName.contains(\":/\")) {\n cfg = new URL(cfgName);\n } else { \n File file = new File(cfgName);\n if (file.isFile()) {\n cfg = file.toURI().toURL();\n }\n }\n } else {\n File file = new File(Environment.getDefault().getConfig(), \"jetty.xml\");\n if (file.isFile()) {\n cfg = file.toURI().toURL();\n }\n }\n if (cfg != null) {\n XmlConfiguration configuration = new XmlConfiguration(cfg);\n server = (Server)configuration.configure();\n } else {\n int p = 8080;\n String port = Environment.getDefault().getProperty(\"http_port\");\n if (port != null) {\n try {\n p = Integer.parseInt(port);\n } catch (NumberFormatException e) {\n }\n }\n server = new Server(p);\n }\n Handler[] handlers = server.getHandlers();\n if (handlers != null && handlers.length > 0 && handlers[0] instanceof ContextHandlerCollection) {\n contexts = (ContextHandlerCollection)handlers[0];\n } else if (handlers == null || handlers.length == 0) {\n contexts = new ContextHandlerCollection();\n RequestLogHandler requestLogHandler = new RequestLogHandler();\n File logDir = Environment.getDefault().getLog();\n logDir.mkdirs();\n File logFile = new File(logDir, \"jetty.log\");\n NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());\n requestLogHandler.setRequestLog(requestLog);\n handlers = new Handler[] {contexts, new DefaultHandler(), requestLogHandler};\n server.setHandlers(handlers);\n server.setSendServerVersion(true);\n server.setStopAtShutdown(true);\n } else { \n contexts = new ContextHandlerCollection();\n Handler[] newHandlers = new Handler[handlers.length+1];\n newHandlers[0] = contexts;\n System.arraycopy(handlers, 0, newHandlers, 0, handlers.length);\n server.setHandlers(newHandlers);\n }\n server.start();\n }\n"} {"input": "\tprivate Group createGroup(final Composite parent) {\n\t\tfinal Group group = UIControlsFactory.createGroup(parent, \"Marker Options:\"); \n\t\tgroup.setLayout(createGridLayout(3));\n\t\tUIControlsFactory.createLabel(group, \"ITextRidget:\"); \n\t\tfinal Text text = UIControlsFactory.createText(group, SWT.BORDER, \"textRidget\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(text);\n\t\tUIControlsFactory.createLabel(group, \"\"); \n\t\tfinal Button btnMandatory = UIControlsFactory.createButton(group, \"Add/Remove Mandatory\", \"btnMandatory\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnMandatory);\n\t\tfinal Button btnError = UIControlsFactory.createButton(group, \"Add/Remove ErrorMarker\", \"btnError\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnError);\n\t\tUIControlsFactory.createLabel(group, \"\"); \n\t\tfinal Button btnHM = UIControlsFactory.createButton(group, \"Show/Hide ErrorMarker \", \"btnHideMandatory\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnHM);\n\t\tfinal Button btnHE = UIControlsFactory.createButton(group, \"Show/Hide MandatoryMarker\", \"btnHideError\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnHE);\n\t\treturn group;\n\t}\n", "output": "\tprivate Group createGroup(final Composite parent) {\n\t\tfinal Group group = UIControlsFactory.createGroup(parent, \"Marker Options:\"); \n\t\tgroup.setLayout(createGridLayout(3));\n\t\tUIControlsFactory.createLabel(group, \"ITextRidget:\"); \n\t\tfinal Text text = UIControlsFactory.createText(group, SWT.BORDER, \"textRidget\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(text);\n\t\tUIControlsFactory.createLabel(group, \"\"); \n\t\tfinal Button btnMandatory = UIControlsFactory.createButton(group, \"Add/Remove Mandatory\", \"btnMandatory\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnMandatory);\n\t\tfinal Button btnError = UIControlsFactory.createButton(group, \"Add/Remove ErrorMarker\", \"btnError\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnError);\n\t\tUIControlsFactory.createLabel(group, \"\"); \n\t\tfinal Button btnHM = UIControlsFactory.createButton(group, \"Show/Hide MandatoryMarker \", \"btnHideMandatory\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnHM);\n\t\tfinal Button btnHE = UIControlsFactory.createButton(group, \"Show/Hide ErrorMarker\", \"btnHideError\"); \n\t\tGridDataFactory.fillDefaults().grab(true, false).applyTo(btnHE);\n\t\treturn group;\n\t}\n"} {"input": " public boolean onCommand(final CommandSender sender, Command cmd, String label, String[] args) {\n if (cmd.getName().equalsIgnoreCase(\"tardis\")) {\n Player player = null;\n if (sender instanceof Player) {\n player = (Player) sender;\n }\n if (args.length == 0) {\n sender.sendMessage(TARDISConstants.COMMANDS.split(\"\\n\"));\n return true;\n }\n if (!firstArgs.contains(args[0].toLowerCase(Locale.ENGLISH))) {\n sender.sendMessage(plugin.pluginName + \"That command wasn't recognised type \" + ChatColor.GREEN + \"/tardis help\" + ChatColor.RESET + \" to see the commands\");\n return false;\n }\n if (args[0].equalsIgnoreCase(\"exterminate\")) {\n if (player == null) {\n sender.sendMessage(plugin.pluginName + \"You must be a player to run this command!\");\n return false;\n }\n if (!plugin.trackExterminate.containsKey(player.getName())) {\n sender.sendMessage(plugin.pluginName + \"You must break the TARDIS Police Box sign first!\");\n return false;\n }\n TARDISExterminator del = new TARDISExterminator(plugin);\n return del.exterminate(player, plugin.trackExterminate.get(player.getName()));\n }\n if (args[0].equalsIgnoreCase(\"gravity\")) {\n if (player == null) {\n sender.sendMessage(plugin.pluginName + \"Must be a player\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n try {\n TARDISDatabase service = TARDISDatabase.getInstance();\n Connection connection = service.getConnection();\n Statement statement = connection.createStatement();\n String query = \"SELECT * FROM gravity WHERE tardis_id = \" + id;\n ResultSet rsg = statement.executeQuery(query);\n if (rsg.isBeforeFirst()) {\n String up = \"Location{world=\" + rsg.getString(\"world\") + \",x=\" + rsg.getFloat(\"upx\") + \",y=10.0,z=\" + rsg.getFloat(\"upz\") + \",pitch=0.0,yaw=0.0}\";\n Double[] values = new Double[3];\n values[0] = 1D;\n values[1] = 11D;\n values[2] = 0.5D;\n plugin.gravityUpList.put(up, values);\n String down = \"Location{world=\" + rsg.getString(\"world\") + \",x=\" + rsg.getFloat(\"downx\") + \",y=10.0,z=\" + rsg.getFloat(\"downz\") + \",pitch=0.0,yaw=0.0}\";\n plugin.gravityDownList.add(down);\n HashMap<String, Object> setu = new HashMap<String, Object>();\n setu.put(\"tardis_id\", id);\n setu.put(\"location\", up);\n setu.put(\"direction\", 1);\n setu.put(\"distance\", 11);\n setu.put(\"velocity\", 0.5);\n HashMap<String, Object> setd = new HashMap<String, Object>();\n setd.put(\"tardis_id\", id);\n setd.put(\"location\", down);\n setd.put(\"direction\", 0);\n setd.put(\"distance\", 0);\n setd.put(\"velocity\", 0);\n QueryFactory qf = new QueryFactory(plugin);\n qf.doInsert(\"gravity_well\", setu);\n qf.doInsert(\"gravity_well\", setd);\n player.sendMessage(plugin.pluginName + \"Gravity well converted successfully.\");\n return true;\n }\n } catch (SQLException e) {\n plugin.debug(\"Gravity conversion error: \" + e.getMessage());\n }\n }\n if (args[0].equalsIgnoreCase(\"version\")) {\n FileConfiguration pluginYml = YamlConfiguration.loadConfiguration(plugin.pm.getPlugin(\"TARDIS\").getResource(\"plugin.yml\"));\n String version = pluginYml.getString(\"version\");\n String cb = Bukkit.getVersion();\n sender.sendMessage(plugin.pluginName + \"You are running TARDIS version: \" + ChatColor.AQUA + version + ChatColor.RESET + \" with CraftBukkit \" + cb);\n if (plugin.getConfig().getBoolean(\"check_for_updates\")) {\n TARDISUpdateChecker update = new TARDISUpdateChecker(plugin);\n update.checkVersion(player);\n }\n return true;\n }\n if (player == null) {\n sender.sendMessage(plugin.pluginName + ChatColor.RED + \" This command can only be run by a player\");\n return false;\n } else {\n if (args[0].equalsIgnoreCase(\"lamps\")) {\n TARDISLampScanner tls = new TARDISLampScanner(plugin);\n return tls.addLampBlocks(player);\n }\n if (args[0].equalsIgnoreCase(\"chameleon\")) {\n if (!plugin.getConfig().getBoolean(\"chameleon\")) {\n sender.sendMessage(plugin.pluginName + \"This server does not allow the use of the chameleon circuit!\");\n return false;\n }\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"on\") && !args[1].equalsIgnoreCase(\"off\") && !args[1].equalsIgnoreCase(\"short\") && !args[1].equalsIgnoreCase(\"reset\"))) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n String chamStr = rs.getChameleon();\n if (chamStr.isEmpty()) {\n sender.sendMessage(plugin.pluginName + \"Could not find the Chameleon Circuit!\");\n return false;\n } else {\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n if (args[1].equalsIgnoreCase(\"on\") || args[1].equalsIgnoreCase(\"off\")) {\n int x, y, z;\n String[] chamData = chamStr.split(\":\");\n World w = plugin.getServer().getWorld(chamData[0]);\n TARDISConstants.COMPASS d = rs.getDirection();\n x = plugin.utils.parseNum(chamData[1]);\n y = plugin.utils.parseNum(chamData[2]);\n z = plugin.utils.parseNum(chamData[3]);\n Block chamBlock = w.getBlockAt(x, y, z);\n Material chamType = chamBlock.getType();\n if (chamType == Material.WALL_SIGN || chamType == Material.SIGN_POST) {\n Sign cs = (Sign) chamBlock.getState();\n if (args[1].equalsIgnoreCase(\"on\")) {\n set.put(\"chamele_on\", 1);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was turned ON!\");\n cs.setLine(3, ChatColor.GREEN + \"ON\");\n }\n if (args[1].equalsIgnoreCase(\"off\")) {\n set.put(\"chamele_on\", 0);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was turned OFF.\");\n cs.setLine(3, ChatColor.RED + \"OFF\");\n }\n cs.update();\n }\n }\n int dwid = plugin.getConfig().getInt(\"wall_id\");\n int dwd = plugin.getConfig().getInt(\"wall_data\");\n if (args[1].equalsIgnoreCase(\"short\")) {\n Block target_block = player.getTargetBlock(transparent, 50).getLocation().getBlock();\n TARDISChameleonCircuit tcc = new TARDISChameleonCircuit(plugin);\n int[] b_data = tcc.getChameleonBlock(target_block, player, true);\n int c_id = b_data[0], c_data = b_data[1];\n set.put(\"chameleon_id\", c_id);\n set.put(\"chameleon_data\", c_data);\n qf.doUpdate(\"tardis\", set, tid);\n boolean bluewool = (c_id == dwid && c_data == (byte) dwd);\n if (!bluewool) {\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was shorted out to: \" + target_block.getType().toString() + \".\");\n }\n }\n if (args[1].equalsIgnoreCase(\"reset\")) {\n set.put(\"chameleon_id\", dwid);\n set.put(\"chameleon_data\", dwd);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was repaired.\");\n }\n }\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"rescue\")) {\n if (args.length < 2) {\n player.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return true;\n }\n if (player.hasPermission(\"tardis.timetravel.player\")) {\n final String saved = args[1];\n Player destPlayer = plugin.getServer().getPlayer(saved);\n if (destPlayer == null) {\n player.sendMessage(plugin.pluginName + \"That player is not online!\");\n return true;\n }\n String playerNameStr = player.getName();\n destPlayer.sendMessage(plugin.pluginName + playerNameStr + \"wants to rescue you! Type: \" + ChatColor.AQUA + \"tardis rescue accept\" + ChatColor.RESET + \" in chat within 60 seconds to accept the rescue.\");\n plugin.trackChat.put(saved, playerNameStr);\n plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n @Override\n public void run() {\n if (plugin.trackChat.containsKey(saved)) {\n plugin.trackChat.remove(saved);\n sender.sendMessage(plugin.pluginName + saved + \" didn't respond with 60 seconds, aborting rescue!\");\n }\n }\n }, 1200L);\n } else {\n player.sendMessage(plugin.pluginName + \"You do not have permission to time travel to a player!\");\n return true;\n }\n }\n if (args[0].equalsIgnoreCase(\"room\")) {\n if (args.length < 2) {\n player.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String room = args[1].toUpperCase(Locale.ENGLISH);\n StringBuilder buf = new StringBuilder();\n for (String rl : roomArgs) {\n buf.append(rl).append(\", \");\n }\n String roomlist = buf.toString().substring(0, buf.length() - 2);\n if (room.equals(\"HELP\")) {\n player.sendMessage(plugin.pluginName + \"There are currently \" + roomArgs.size() + \" room types! They are: \" + roomlist + \".\");\n player.sendMessage(\"View a TARDIS room gallery at http://eccentricdevotion.github.com/TARDIS/room-gallery.html\");\n return true;\n }\n if (!roomArgs.contains(room)) {\n player.sendMessage(plugin.pluginName + \"That is not a valid room type! Try one of: \" + roomlist + \".\");\n return true;\n }\n String perm = \"tardis.room.\" + args[1].toLowerCase(Locale.ENGLISH);\n if (!player.hasPermission(perm) && !player.hasPermission(\"tardis.room\")) {\n String grammar = (TARDISConstants.vowels.contains(room.substring(0, 1))) ? \"an\" : \"a\";\n sender.sendMessage(plugin.pluginName + \"You do not have permission to grow \" + grammar + \" \" + room);\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return true;\n }\n String chunk = rs.getChunk();\n String[] data = chunk.split(\":\");\n World room_world = plugin.getServer().getWorld(data[0]);\n ChunkGenerator gen = room_world.getGenerator();\n WorldType wt = room_world.getWorldType();\n boolean special = (data[0].contains(\"TARDIS_TimeVortex\") && (wt.equals(WorldType.FLAT) || gen instanceof TARDISChunkGenerator));\n if (!data[0].contains(\"TARDIS_WORLD_\") && !special) {\n player.sendMessage(plugin.pluginName + \"You cannot grow rooms unless your TARDIS was created in its own world!\");\n return true;\n }\n int id = rs.getTardis_id();\n int level = rs.getArtron_level();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n wheret.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return true;\n }\n if (level < plugin.getRoomsConfig().getInt(\"rooms.\" + room + \".cost\")) {\n player.sendMessage(plugin.pluginName + \"The TARDIS does not have enough Artron Energy to grow this room!\");\n return true;\n }\n if (plugin.getConfig().getBoolean(\"rooms_require_blocks\")) {\n HashMap<String, Integer> blockIDCount = new HashMap<String, Integer>();\n boolean hasRequired = true;\n HashMap<String, Integer> roomBlocks = plugin.roomBlockCounts.get(room);\n String wall = \"ORANGE_WOOL\";\n String floor = \"LIGHT_GREY_WOOL\";\n HashMap<String, Object> wherepp = new HashMap<String, Object>();\n boolean hasPrefs = false;\n wherepp.put(\"player\", player.getName());\n ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, wherepp);\n if (rsp.resultSet()) {\n hasPrefs = true;\n wall = rsp.getWall();\n floor = rsp.getFloor();\n }\n for (Map.Entry<String, Integer> entry : roomBlocks.entrySet()) {\n String[] block_data = entry.getKey().split(\":\");\n int bid = plugin.utils.parseNum(block_data[0]);\n String mat;\n String bdata;\n if (hasPrefs && block_data.length == 2 && (block_data[1].equals(\"1\") || block_data[1].equals(\"8\"))) {\n mat = (block_data[1].equals(\"1\")) ? wall : floor;\n TARDISWalls tw = new TARDISWalls();\n Integer[] iddata = tw.blocks.get(mat);\n bdata = String.format(\"%d\", iddata[0]);\n } else {\n mat = Material.getMaterial(bid).toString();\n bdata = String.format(\"%d\", bid);\n }\n int tmp = Math.round((entry.getValue() / 100.0F) * plugin.getConfig().getInt(\"rooms_condenser_percent\"));\n int required = (tmp > 0) ? tmp : 1;\n blockIDCount.put(bdata, required);\n HashMap<String, Object> wherec = new HashMap<String, Object>();\n wherec.put(\"tardis_id\", id);\n wherec.put(\"block_data\", bdata);\n ResultSetCondenser rsc = new ResultSetCondenser(plugin, wherec, false);\n if (rsc.resultSet()) {\n if (rsc.getBlock_count() < required) {\n hasRequired = false;\n int diff = required - rsc.getBlock_count();\n player.sendMessage(plugin.pluginName + \"You need to condense \" + diff + \" more \" + mat + \"!\");\n }\n } else {\n hasRequired = false;\n player.sendMessage(plugin.pluginName + \"You need to condense a minimum of \" + required + \" \" + mat);\n }\n }\n if (hasRequired == false) {\n player.sendMessage(\"-----------------------------\");\n return true;\n }\n TARDISCondenserData c_data = new TARDISCondenserData();\n c_data.setBlockIDCount(blockIDCount);\n c_data.setTardis_id(id);\n plugin.roomCondenserData.put(player.getName(), c_data);\n }\n String message;\n if (room.equals(\"GRAVITY\") || room.equals(\"ANTIGRAVITY\")) {\n message = \"Place the GRAVITY WELL seed block (\" + plugin.getRoomsConfig().getString(\"rooms.\" + room + \".seed\") + \") into the centre of the floor in an empty room, then hit it with the TARDIS key to start growing your room!\";\n } else {\n message = \"Place the \" + room + \" seed block (\" + plugin.getRoomsConfig().getString(\"rooms.\" + room + \".seed\") + \") where the door should be, then hit it with the TARDIS key to start growing your room!\";\n }\n plugin.trackRoomSeed.put(player.getName(), room);\n player.sendMessage(plugin.pluginName + message);\n return true;\n }\n if (args[0].equalsIgnoreCase(\"jettison\")) {\n if (player.hasPermission(\"tardis.room\")) {\n if (args.length < 2) {\n player.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String room = args[1].toUpperCase(Locale.ENGLISH);\n if (room.equals(\"GRAVITY\") || room.equals(\"ANTIGRAVITY\")) {\n player.sendMessage(plugin.pluginName + \"You cannot jettison gravity wells! To remove the gravity blocks use the \" + ChatColor.AQUA + \"/tardisgravity remove\" + ChatColor.RESET + \" command.\");\n return true;\n }\n if (!roomArgs.contains(room)) {\n StringBuilder buf = new StringBuilder(args[1]);\n for (String rl : roomArgs) {\n buf.append(rl).append(\", \");\n }\n String roomlist = buf.toString().substring(0, buf.length() - 2);\n player.sendMessage(plugin.pluginName + \"That is not a valid room type! Try one of: \" + roomlist);\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return true;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n wheret.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return true;\n }\n plugin.trackJettison.put(player.getName(), room);\n String seed = plugin.getArtronConfig().getString(\"jettison_seed\");\n player.sendMessage(plugin.pluginName + \"Stand in the doorway of the room you want to jettison and place a \" + seed + \" block directly in front of the door. Hit the \" + seed + \" with the TARDIS key to jettison the room!\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"occupy\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \" You must be the Timelord of the TARDIS to use this command!\");\n return false;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n String occupied;\n QueryFactory qf = new QueryFactory(plugin);\n if (rst.resultSet()) {\n HashMap<String, Object> whered = new HashMap<String, Object>();\n whered.put(\"tardis_id\", id);\n whered.put(\"player\", player.getName());\n qf.doDelete(\"travellers\", whered);\n occupied = ChatColor.RED + \"UNOCCUPIED\";\n } else {\n HashMap<String, Object> wherei = new HashMap<String, Object>();\n wherei.put(\"tardis_id\", id);\n wherei.put(\"player\", player.getName());\n qf.doInsert(\"travellers\", wherei);\n occupied = ChatColor.GREEN + \"OCCUPIED\";\n }\n sender.sendMessage(plugin.pluginName + \" TARDIS occupation was set to: \" + occupied);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"comehere\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n final Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && eyeLocation.getWorld().getName().equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server admin will not allow you to bring the TARDIS to this world!\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, eyeLocation, true)) {\n return true;\n }\n if (player.hasPermission(\"tardis.exile\") && plugin.getConfig().getBoolean(\"exile\")) {\n String areaPerm = plugin.ta.getExileArea(player);\n if (plugin.ta.areaCheckInExile(areaPerm, eyeLocation)) {\n sender.sendMessage(plugin.pluginName + \"You exile status does not allow you to bring the TARDIS to this location!\");\n return true;\n }\n }\n if (!plugin.ta.areaCheckInExisting(eyeLocation)) {\n sender.sendMessage(plugin.pluginName + \"You cannot use /tardis comehere to bring the Police Box to a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n Material m = player.getTargetBlock(transparent, 50).getType();\n if (m != Material.SNOW) {\n int yplusone = eyeLocation.getBlockY();\n eyeLocation.setY(yplusone + 1);\n }\n String world = eyeLocation.getWorld().getName();\n if (!plugin.getConfig().getBoolean(\"worlds.\" + world)) {\n sender.sendMessage(plugin.pluginName + \"You cannot bring the TARDIS Police Box to this world\");\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n final ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of the TARDIS to use this command!\");\n return true;\n }\n final int id = rs.getTardis_id();\n HashMap<String, Object> wherettrav = new HashMap<String, Object>();\n wherettrav.put(\"player\", player.getName());\n wherettrav.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);\n if (rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You cannot bring the Police Box here because you are inside a TARDIS!\");\n return true;\n }\n if (plugin.tardisMaterialising.contains(id) || plugin.tardisDematerialising.contains(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot do that while the TARDIS is materialising!\");\n return true;\n }\n final TARDISConstants.COMPASS d = rs.getDirection();\n TARDISTimeTravel tt = new TARDISTimeTravel(plugin);\n int[] start_loc = tt.getStartLocation(eyeLocation, d);\n int count = tt.safeLocation(start_loc[0], eyeLocation.getBlockY(), start_loc[2], start_loc[1], start_loc[3], eyeLocation.getWorld(), d);\n if (count > 0) {\n sender.sendMessage(plugin.pluginName + \"That location would grief existing blocks! Try somewhere else!\");\n return true;\n }\n int level = rs.getArtron_level();\n int ch = plugin.getArtronConfig().getInt(\"comehere\");\n if (level < ch) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to make this trip!\");\n return true;\n }\n final Player p = player;\n String current_str = rs.getCurrent();\n boolean chamtmp = false;\n if (plugin.getConfig().getBoolean(\"chameleon\")) {\n chamtmp = rs.isChamele_on();\n }\n final boolean cham = chamtmp;\n String[] saveData = current_str.split(\":\");\n World w = plugin.getServer().getWorld(saveData[0]);\n if (w != null) {\n int x, y, z;\n x = plugin.utils.parseNum(saveData[1]);\n y = plugin.utils.parseNum(saveData[2]);\n z = plugin.utils.parseNum(saveData[3]);\n final Location oldSave = w.getBlockAt(x, y, z).getLocation();\n String comehere = eyeLocation.getWorld().getName() + \":\" + eyeLocation.getBlockX() + \":\" + eyeLocation.getBlockY() + \":\" + eyeLocation.getBlockZ();\n final boolean hidden = rs.isHidden();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"save\", comehere);\n set.put(\"current\", comehere);\n if (hidden) {\n set.put(\"hidden\", 0);\n }\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The TARDIS is coming...\");\n final boolean mat = plugin.getConfig().getBoolean(\"materialise\");\n long delay = (mat) ? 1L : 180L;\n Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n @Override\n public void run() {\n if (!hidden) {\n plugin.tardisDematerialising.add(id);\n plugin.destroyPB.destroyPoliceBox(oldSave, d, id, false, mat, cham, p);\n }\n }\n }, delay);\n Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n @Override\n public void run() {\n plugin.buildPB.buildPoliceBox(id, eyeLocation, d, cham, p, false, false);\n }\n }, delay * 2);\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n qf.alterEnergyLevel(\"tardis\", -ch, wheret, player);\n plugin.tardisHasDestination.remove(id);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + \"Could not get the previous location of the TARDIS!\");\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"check_loc\")) {\n final Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();\n Material m = player.getTargetBlock(transparent, 50).getType();\n if (m != Material.SNOW) {\n int yplusone = eyeLocation.getBlockY();\n eyeLocation.setY(yplusone + 1);\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of a TARDIS to use this command!\");\n return true;\n }\n final TARDISConstants.COMPASS d = rs.getDirection();\n TARDISTimeTravel tt = new TARDISTimeTravel(plugin);\n tt.testSafeLocation(eyeLocation, d);\n return true;\n }\n if (args[0].equalsIgnoreCase(\"inside\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of a TARDIS to use this command!\");\n return true;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, true);\n if (rst.resultSet()) {\n List<String> data = rst.getData();\n sender.sendMessage(plugin.pluginName + \"The players inside your TARDIS are:\");\n for (String s : data) {\n sender.sendMessage(s);\n }\n } else {\n sender.sendMessage(plugin.pluginName + \"Nobody is inside your TARDIS.\");\n }\n return true;\n }\n if (args[0].equalsIgnoreCase(\"home\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && eyeLocation.getWorld().getName().equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server admin will not allow you to set the TARDIS home in this world!\");\n return true;\n }\n if (!plugin.ta.areaCheckInExisting(eyeLocation)) {\n sender.sendMessage(plugin.pluginName + \"You cannot use /tardis home in a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, eyeLocation, true)) {\n return true;\n }\n Material m = player.getTargetBlock(transparent, 50).getType();\n if (m != Material.SNOW) {\n int yplusone = eyeLocation.getBlockY();\n eyeLocation.setY(yplusone + 1);\n }\n String world = eyeLocation.getWorld().getName();\n if (!plugin.getConfig().getBoolean(\"worlds.\" + world)) {\n sender.sendMessage(plugin.pluginName + \"You cannot set the TARDIS home location to this world\");\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of the TARDIS to use this command!\");\n return false;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wherettrav = new HashMap<String, Object>();\n wherettrav.put(\"player\", player.getName());\n wherettrav.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);\n if (rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You cannot set the home location here because you are inside a TARDIS!\");\n return true;\n }\n String sethome = eyeLocation.getWorld().getName() + \":\" + eyeLocation.getBlockX() + \":\" + eyeLocation.getBlockY() + \":\" + eyeLocation.getBlockZ();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"home\", sethome);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The new TARDIS home was set!\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"update\")) {\n if (player.hasPermission(\"tardis.update\")) {\n String[] validBlockNames = {\"door\", \"button\", \"world-repeater\", \"x-repeater\", \"z-repeater\", \"y-repeater\", \"chameleon\", \"save-sign\", \"artron\", \"handbrake\", \"condenser\", \"scanner\", \"backdoor\", \"keyboard\", \"creeper\", \"eps\", \"back\", \"terminal\", \"ars\", \"temporal\"};\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String tardis_block = args[1].toLowerCase(Locale.ENGLISH);\n if (!Arrays.asList(validBlockNames).contains(tardis_block)) {\n player.sendMessage(plugin.pluginName + \"That is not a valid TARDIS block name! Try one of : door|button|world-repeater|x-repeater|z-repeater|y-repeater|chameleon|save-sign|artron|handbrake|condenser|scanner|backdoor|keyboard|creeper|eps|back|terminal|ars|temporal\");\n return false;\n }\n if (tardis_block.equals(\"backdoor\") && !player.hasPermission(\"tardis.backdoor\")) {\n sender.sendMessage(plugin.pluginName + \"You do not have permission to create a back door!\");\n return true;\n }\n if (tardis_block.equals(\"temporal\") && !player.hasPermission(\"tardis.temporal\")) {\n sender.sendMessage(plugin.pluginName + \"You do not have permission to create a Temporal Locator!\");\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return false;\n }\n if (!tardis_block.equals(\"backdoor\")) {\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return false;\n }\n }\n plugin.trackPlayers.put(player.getName(), tardis_block);\n player.sendMessage(plugin.pluginName + \"Click the TARDIS \" + tardis_block + \" to update its position.\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"secondary\")) {\n if (player.hasPermission(\"tardis.update\")) {\n String[] validBlockNames = {\"button\", \"world-repeater\", \"x-repeater\", \"z-repeater\", \"y-repeater\", \"artron\", \"handbrake\", \"door\", \"back\"};\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String tardis_block = args[1].toLowerCase(Locale.ENGLISH);\n if (!Arrays.asList(validBlockNames).contains(tardis_block)) {\n player.sendMessage(plugin.pluginName + \"That is not a valid TARDIS block name! Try one of : button|world-repeater|x-repeater|z-repeater|y-repeater|artron|handbrake|door|back\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return false;\n }\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return false;\n }\n plugin.trackSecondary.put(player.getName(), tardis_block);\n player.sendMessage(plugin.pluginName + \"Click the TARDIS \" + tardis_block + \" to update its position.\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"rebuild\") || args[0].equalsIgnoreCase(\"hide\")) {\n if (player.hasPermission(\"tardis.rebuild\")) {\n String save;\n World w;\n int x, y, z, id;\n TARDISConstants.COMPASS d;\n boolean cham = false;\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n id = rs.getTardis_id();\n HashMap<String, Object> wherein = new HashMap<String, Object>();\n wherein.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherein, false);\n if (rst.resultSet() && args[0].equalsIgnoreCase(\"rebuild\") && plugin.tardisHasDestination.containsKey(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot rebuild the TARDIS right now! Try travelling first.\");\n return true;\n }\n int level = rs.getArtron_level();\n save = rs.getCurrent();\n if (plugin.tardisMaterialising.contains(id) || plugin.tardisDematerialising.contains(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot do that while the TARDIS is materialising!\");\n return true;\n }\n if (plugin.getConfig().getBoolean(\"chameleon\")) {\n cham = rs.isChamele_on();\n }\n d = rs.getDirection();\n String[] save_data = save.split(\":\");\n w = plugin.getServer().getWorld(save_data[0]);\n x = plugin.utils.parseNum(save_data[1]);\n y = plugin.utils.parseNum(save_data[2]);\n z = plugin.utils.parseNum(save_data[3]);\n Location l = new Location(w, x, y, z);\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n QueryFactory qf = new QueryFactory(plugin);\n if (args[0].equalsIgnoreCase(\"rebuild\")) {\n int rebuild = plugin.getArtronConfig().getInt(\"random\");\n if (level < rebuild) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to rebuild!\");\n return false;\n }\n plugin.buildPB.buildPoliceBox(id, l, d, cham, player, true, false);\n sender.sendMessage(plugin.pluginName + \"The TARDIS Police Box was rebuilt!\");\n qf.alterEnergyLevel(\"tardis\", -rebuild, wheret, player);\n if (rs.isHidden()) {\n HashMap<String, Object> whereh = new HashMap<String, Object>();\n whereh.put(\"tardis_id\", id);\n HashMap<String, Object> seth = new HashMap<String, Object>();\n seth.put(\"hidden\", 0);\n qf.doUpdate(\"tardis\", seth, whereh);\n }\n return true;\n }\n if (args[0].equalsIgnoreCase(\"hide\")) {\n int hide = plugin.getArtronConfig().getInt(\"hide\");\n if (level < hide) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to hide!\");\n return false;\n }\n plugin.destroyPB.destroyPoliceBox(l, d, id, true, false, false, null);\n sender.sendMessage(plugin.pluginName + \"The TARDIS Police Box was hidden! Use \" + ChatColor.GREEN + \"/tardis rebuild\" + ChatColor.RESET + \" to show it again.\");\n qf.alterEnergyLevel(\"tardis\", -hide, wheret, player);\n HashMap<String, Object> whereh = new HashMap<String, Object>();\n whereh.put(\"tardis_id\", id);\n HashMap<String, Object> seth = new HashMap<String, Object>();\n seth.put(\"hidden\", 1);\n qf.doUpdate(\"tardis\", seth, whereh);\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"list\")) {\n if (player.hasPermission(\"tardis.list\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"saves\") && !args[1].equalsIgnoreCase(\"companions\") && !args[1].equalsIgnoreCase(\"areas\") && !args[1].equalsIgnoreCase(\"rechargers\"))) {\n sender.sendMessage(plugin.pluginName + \"You need to specify which TARDIS list you want to view! [saves|companions|areas|rechargers]\");\n return false;\n }\n TARDISLister.list(player, args[1]);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"find\")) {\n if (player.hasPermission(\"tardis.find\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n String loc = rs.getCurrent();\n String[] findData = loc.split(\":\");\n sender.sendMessage(plugin.pluginName + \"TARDIS was left at \" + findData[0] + \" at x: \" + findData[1] + \" y: \" + findData[2] + \" z: \" + findData[3]);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"add\")) {\n if (player.hasPermission(\"tardis.add\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n String comps;\n int id;\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n } else {\n id = rs.getTardis_id();\n comps = rs.getCompanions();\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"That doesn't appear to be a valid username\");\n return false;\n } else {\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n if (comps != null && !comps.isEmpty()) {\n String newList = comps + \":\" + args[1].toLowerCase(Locale.ENGLISH);\n set.put(\"companions\", newList);\n } else {\n set.put(\"companions\", args[1].toLowerCase(Locale.ENGLISH));\n }\n qf.doUpdate(\"tardis\", set, tid);\n player.sendMessage(plugin.pluginName + \"You added \" + ChatColor.GREEN + args[1] + ChatColor.RESET + \" as a TARDIS companion.\");\n if (plugin.getAchivementConfig().getBoolean(\"friends.enabled\")) {\n TARDISAchievementFactory taf = new TARDISAchievementFactory(plugin, player, \"friends\", 1);\n taf.doAchievement(1);\n }\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"remove\")) {\n if (player.hasPermission(\"tardis.add\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n String comps;\n int id;\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n } else {\n id = rs.getTardis_id();\n comps = rs.getCompanions();\n if (comps == null || comps.isEmpty()) {\n sender.sendMessage(plugin.pluginName + \"You have not added any TARDIS companions yet!\");\n return true;\n }\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"That doesn't appear to be a valid username\");\n return false;\n } else {\n String[] split = comps.split(\":\");\n StringBuilder buf = new StringBuilder();\n String newList;\n if (split.length > 1) {\n for (String c : split) {\n if (!c.equals(args[1].toLowerCase(Locale.ENGLISH))) {\n buf.append(c).append(\":\");\n }\n }\n newList = buf.toString().substring(0, buf.length() - 1);\n } else {\n newList = \"\";\n }\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"companions\", newList);\n qf.doUpdate(\"tardis\", set, tid);\n player.sendMessage(plugin.pluginName + \"You removed \" + ChatColor.GREEN + args[1] + ChatColor.RESET + \" as a TARDIS companion.\");\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"save\")) {\n if (player.hasPermission(\"tardis.save\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"That doesn't appear to be a valid save name (it may be too long or contains spaces).\");\n return false;\n } else {\n int id = rs.getTardis_id();\n String cur = rs.getCurrent();\n String[] curDest = cur.split(\":\");\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> set = new HashMap<String, Object>();\n set.put(\"tardis_id\", id);\n set.put(\"dest_name\", args[1]);\n set.put(\"world\", curDest[0]);\n set.put(\"x\", plugin.utils.parseNum(curDest[1]));\n set.put(\"y\", plugin.utils.parseNum(curDest[2]));\n set.put(\"z\", plugin.utils.parseNum(curDest[3]));\n if (qf.doInsert(\"destinations\", set) < 0) {\n return false;\n } else {\n sender.sendMessage(plugin.pluginName + \"The location '\" + args[1] + \"' was saved successfully.\");\n return true;\n }\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"removesave\")) {\n if (player.hasPermission(\"tardis.save\")) {\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> whered = new HashMap<String, Object>();\n whered.put(\"dest_name\", args[1]);\n whered.put(\"tardis_id\", id);\n ResultSetDestinations rsd = new ResultSetDestinations(plugin, whered, false);\n if (!rsd.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"Could not find a saved destination with that name!\");\n return false;\n }\n int destID = rsd.getDest_id();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> did = new HashMap<String, Object>();\n did.put(\"dest_id\", destID);\n qf.doDelete(\"destinations\", did);\n sender.sendMessage(plugin.pluginName + \"The destination \" + args[1] + \" was deleted!\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"setdest\")) {\n if (player.hasPermission(\"tardis.save\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"The destination name must be between 2 and 16 characters and have no spaces!\");\n return false;\n } else if (args[1].equalsIgnoreCase(\"hide\") || args[1].equalsIgnoreCase(\"rebuild\") || args[1].equalsIgnoreCase(\"home\")) {\n sender.sendMessage(plugin.pluginName + \"That is a reserved destination name!\");\n return false;\n } else {\n int id = rs.getTardis_id();\n HashMap<String, Object> wherettrav = new HashMap<String, Object>();\n wherettrav.put(\"player\", player.getName());\n wherettrav.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);\n if (rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You cannot bring the Police Box here because you are inside a TARDIS!\");\n return true;\n }\n Block b = player.getTargetBlock(transparent, 50);\n Location l = b.getLocation();\n if (!plugin.ta.areaCheckInExisting(l)) {\n sender.sendMessage(plugin.pluginName + \"You cannot use /tardis setdest in a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n String world = l.getWorld().getName();\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && world.equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server admin will not allow you to set the TARDIS destination to this world!\");\n return true;\n }\n if (!plugin.getConfig().getBoolean(\"worlds.\" + world)) {\n sender.sendMessage(plugin.pluginName + \"You cannot bring the TARDIS Police Box to this world\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, l, true)) {\n return true;\n }\n if (player.hasPermission(\"tardis.exile\") && plugin.getConfig().getBoolean(\"exile\")) {\n String areaPerm = plugin.ta.getExileArea(player);\n if (plugin.ta.areaCheckInExile(areaPerm, l)) {\n sender.sendMessage(plugin.pluginName + \"You exile status does not allow you to save the TARDIS to this location!\");\n return false;\n }\n }\n String dw = l.getWorld().getName();\n int dx = l.getBlockX();\n int dy = l.getBlockY() + 1;\n int dz = l.getBlockZ();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> set = new HashMap<String, Object>();\n set.put(\"tardis_id\", id);\n set.put(\"dest_name\", args[1]);\n set.put(\"world\", dw);\n set.put(\"x\", dx);\n set.put(\"y\", dy);\n set.put(\"z\", dz);\n if (qf.doInsert(\"destinations\", set) < 0) {\n return false;\n } else {\n sender.sendMessage(plugin.pluginName + \"The destination '\" + args[1] + \"' was saved successfully.\");\n return true;\n }\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"direction\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"north\") && !args[1].equalsIgnoreCase(\"west\") && !args[1].equalsIgnoreCase(\"south\") && !args[1].equalsIgnoreCase(\"east\"))) {\n sender.sendMessage(plugin.pluginName + \"You need to specify the compass direction e.g. north, west, south or east!\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n int level = rs.getArtron_level();\n int amount = plugin.getArtronConfig().getInt(\"random\");\n if (level < amount) {\n sender.sendMessage(plugin.pluginName + \"The TARDIS does not have enough Artron Energy to change the Police Box direction!\");\n return true;\n }\n String save = rs.getCurrent();\n String[] save_data = save.split(\":\");\n if (plugin.tardisMaterialising.contains(id) || plugin.tardisDematerialising.contains(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot do that while the TARDIS is materialising!\");\n return true;\n }\n boolean cham = false;\n if (plugin.getConfig().getBoolean(\"chameleon\")) {\n cham = rs.isChamele_on();\n }\n String dir = args[1].toUpperCase(Locale.ENGLISH);\n TARDISConstants.COMPASS old_d = rs.getDirection();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"direction\", dir);\n qf.doUpdate(\"tardis\", set, tid);\n HashMap<String, Object> did = new HashMap<String, Object>();\n HashMap<String, Object> setd = new HashMap<String, Object>();\n did.put(\"door_type\", 0);\n did.put(\"tardis_id\", id);\n setd.put(\"door_direction\", dir);\n qf.doUpdate(\"doors\", setd, did);\n World w = plugin.getServer().getWorld(save_data[0]);\n int x = plugin.utils.parseNum(save_data[1]);\n int y = plugin.utils.parseNum(save_data[2]);\n int z = plugin.utils.parseNum(save_data[3]);\n Location l = new Location(w, x, y, z);\n TARDISConstants.COMPASS d = TARDISConstants.COMPASS.valueOf(dir);\n if (!rs.isHidden()) {\n plugin.destroyPB.destroyPlatform(rs.getPlatform(), id);\n plugin.destroyPB.destroySign(l, old_d);\n }\n plugin.buildPB.buildPoliceBox(id, l, d, cham, player, true, false);\n HashMap<String, Object> wherea = new HashMap<String, Object>();\n wherea.put(\"tardis_id\", id);\n qf.alterEnergyLevel(\"tardis\", -amount, wherea, player);\n sender.sendMessage(plugin.pluginName + \"You used \" + amount + \" Artron Energy changing the Police Box direction.\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"namekey\")) {\n if (bukkitversion.compareTo(preIMversion) < 0 || (bukkitversion.compareTo(preIMversion) == 0 && SUBversion.compareTo(preSUBversion) < 0)) {\n sender.sendMessage(plugin.pluginName + \"You cannot rename the TARDIS key with this version of Bukkit!\");\n return true;\n }\n String key;\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"player\", player.getName());\n ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, where);\n if (rsp.resultSet()) {\n key = (!rsp.getKey().isEmpty()) ? rsp.getKey() : plugin.getConfig().getString(\"key\");\n } else {\n key = plugin.getConfig().getString(\"key\");\n }\n Material m = Material.getMaterial(key);\n if (m.equals(Material.AIR)) {\n sender.sendMessage(plugin.pluginName + \"You cannot rename AIR!\");\n return true;\n }\n ItemStack is = player.getItemInHand();\n if (!is.getType().equals(m)) {\n sender.sendMessage(plugin.pluginName + \"You can only rename the TARDIS key!\");\n return true;\n }\n int count = args.length;\n if (count < 2) {\n return false;\n }\n StringBuilder buf = new StringBuilder(args[1]);\n for (int i = 2; i < count; i++) {\n buf.append(\" \").append(args[i]);\n }\n String tmp = buf.toString();\n if (!tmp.isEmpty()) {\n TARDISItemRenamer ir = new TARDISItemRenamer(is);\n ir.setName(tmp, false);\n sender.sendMessage(plugin.pluginName + \"TARDIS key renamed to '\" + tmp + \"'\");\n return true;\n } else {\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"help\")) {\n if (args.length == 1) {\n sender.sendMessage(TARDISConstants.COMMANDS.split(\"\\n\"));\n return true;\n }\n if (args.length == 2) {\n List<String> cmds = new ArrayList<String>();\n for (TARDISConstants.CMDS c : TARDISConstants.CMDS.values()) {\n cmds.add(c.toString());\n }\n if (!cmds.contains(args[1].toUpperCase(Locale.ENGLISH))) {\n sender.sendMessage(plugin.pluginName + \"That is not a valid help topic!\");\n return true;\n }\n switch (TARDISConstants.fromString(args[1])) {\n case CREATE:\n sender.sendMessage(TARDISConstants.COMMAND_CREATE.split(\"\\n\"));\n break;\n case DELETE:\n sender.sendMessage(TARDISConstants.COMMAND_DELETE.split(\"\\n\"));\n break;\n case TIMETRAVEL:\n sender.sendMessage(TARDISConstants.COMMAND_TIMETRAVEL.split(\"\\n\"));\n break;\n case LIST:\n sender.sendMessage(TARDISConstants.COMMAND_LIST.split(\"\\n\"));\n break;\n case FIND:\n sender.sendMessage(TARDISConstants.COMMAND_FIND.split(\"\\n\"));\n break;\n case SAVE:\n sender.sendMessage(TARDISConstants.COMMAND_SAVE.split(\"\\n\"));\n break;\n case REMOVESAVE:\n sender.sendMessage(TARDISConstants.COMMAND_REMOVESAVE.split(\"\\n\"));\n break;\n case ADD:\n sender.sendMessage(TARDISConstants.COMMAND_ADD.split(\"\\n\"));\n break;\n case TRAVEL:\n sender.sendMessage(TARDISConstants.COMMAND_TRAVEL.split(\"\\n\"));\n break;\n case UPDATE:\n sender.sendMessage(TARDISConstants.COMMAND_UPDATE.split(\"\\n\"));\n break;\n case REBUILD:\n sender.sendMessage(TARDISConstants.COMMAND_REBUILD.split(\"\\n\"));\n break;\n case CHAMELEON:\n sender.sendMessage(TARDISConstants.COMMAND_CHAMELEON.split(\"\\n\"));\n break;\n case SFX:\n sender.sendMessage(TARDISConstants.COMMAND_SFX.split(\"\\n\"));\n break;\n case PLATFORM:\n sender.sendMessage(TARDISConstants.COMMAND_PLATFORM.split(\"\\n\"));\n break;\n case SETDEST:\n sender.sendMessage(TARDISConstants.COMMAND_SETDEST.split(\"\\n\"));\n break;\n case HOME:\n sender.sendMessage(TARDISConstants.COMMAND_HOME.split(\"\\n\"));\n break;\n case HIDE:\n sender.sendMessage(TARDISConstants.COMMAND_HIDE.split(\"\\n\"));\n break;\n case VERSION:\n sender.sendMessage(TARDISConstants.COMMAND_HIDE.split(\"\\n\"));\n break;\n case ADMIN:\n sender.sendMessage(TARDISConstants.COMMAND_ADMIN.split(\"\\n\"));\n break;\n case AREA:\n sender.sendMessage(TARDISConstants.COMMAND_AREA.split(\"\\n\"));\n break;\n case ROOM:\n sender.sendMessage(TARDISConstants.COMMAND_ROOM.split(\"\\n\"));\n break;\n case ARTRON:\n sender.sendMessage(TARDISConstants.COMMAND_ARTRON.split(\"\\n\"));\n break;\n case BIND:\n sender.sendMessage(TARDISConstants.COMMAND_BIND.split(\"\\n\"));\n break;\n default:\n sender.sendMessage(TARDISConstants.COMMANDS.split(\"\\n\"));\n }\n }\n return true;\n }\n }\n }\n return false;\n }\n", "output": " public boolean onCommand(final CommandSender sender, Command cmd, String label, String[] args) {\n if (cmd.getName().equalsIgnoreCase(\"tardis\")) {\n Player player = null;\n if (sender instanceof Player) {\n player = (Player) sender;\n }\n if (args.length == 0) {\n sender.sendMessage(TARDISConstants.COMMANDS.split(\"\\n\"));\n return true;\n }\n if (!firstArgs.contains(args[0].toLowerCase(Locale.ENGLISH))) {\n sender.sendMessage(plugin.pluginName + \"That command wasn't recognised type \" + ChatColor.GREEN + \"/tardis help\" + ChatColor.RESET + \" to see the commands\");\n return false;\n }\n if (args[0].equalsIgnoreCase(\"exterminate\")) {\n if (player == null) {\n sender.sendMessage(plugin.pluginName + \"You must be a player to run this command!\");\n return false;\n }\n if (!plugin.trackExterminate.containsKey(player.getName())) {\n sender.sendMessage(plugin.pluginName + \"You must break the TARDIS Police Box sign first!\");\n return false;\n }\n TARDISExterminator del = new TARDISExterminator(plugin);\n return del.exterminate(player, plugin.trackExterminate.get(player.getName()));\n }\n if (args[0].equalsIgnoreCase(\"gravity\")) {\n if (player == null) {\n sender.sendMessage(plugin.pluginName + \"Must be a player\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n try {\n TARDISDatabase service = TARDISDatabase.getInstance();\n Connection connection = service.getConnection();\n Statement statement = connection.createStatement();\n String query = \"SELECT * FROM gravity WHERE tardis_id = \" + id;\n ResultSet rsg = statement.executeQuery(query);\n if (rsg.isBeforeFirst()) {\n String up = \"Location{world=\" + rsg.getString(\"world\") + \",x=\" + rsg.getFloat(\"upx\") + \",y=10.0,z=\" + rsg.getFloat(\"upz\") + \",pitch=0.0,yaw=0.0}\";\n Double[] values = new Double[3];\n values[0] = 1D;\n values[1] = 11D;\n values[2] = 0.5D;\n plugin.gravityUpList.put(up, values);\n String down = \"Location{world=\" + rsg.getString(\"world\") + \",x=\" + rsg.getFloat(\"downx\") + \",y=10.0,z=\" + rsg.getFloat(\"downz\") + \",pitch=0.0,yaw=0.0}\";\n plugin.gravityDownList.add(down);\n HashMap<String, Object> setu = new HashMap<String, Object>();\n setu.put(\"tardis_id\", id);\n setu.put(\"location\", up);\n setu.put(\"direction\", 1);\n setu.put(\"distance\", 11);\n setu.put(\"velocity\", 0.5);\n HashMap<String, Object> setd = new HashMap<String, Object>();\n setd.put(\"tardis_id\", id);\n setd.put(\"location\", down);\n setd.put(\"direction\", 0);\n setd.put(\"distance\", 0);\n setd.put(\"velocity\", 0);\n QueryFactory qf = new QueryFactory(plugin);\n qf.doInsert(\"gravity_well\", setu);\n qf.doInsert(\"gravity_well\", setd);\n player.sendMessage(plugin.pluginName + \"Gravity well converted successfully.\");\n return true;\n }\n } catch (SQLException e) {\n plugin.debug(\"Gravity conversion error: \" + e.getMessage());\n }\n }\n if (args[0].equalsIgnoreCase(\"version\")) {\n FileConfiguration pluginYml = YamlConfiguration.loadConfiguration(plugin.pm.getPlugin(\"TARDIS\").getResource(\"plugin.yml\"));\n String version = pluginYml.getString(\"version\");\n String cb = Bukkit.getVersion();\n sender.sendMessage(plugin.pluginName + \"You are running TARDIS version: \" + ChatColor.AQUA + version + ChatColor.RESET + \" with CraftBukkit \" + cb);\n if (plugin.getConfig().getBoolean(\"check_for_updates\")) {\n TARDISUpdateChecker update = new TARDISUpdateChecker(plugin);\n update.checkVersion(player);\n }\n return true;\n }\n if (player == null) {\n sender.sendMessage(plugin.pluginName + ChatColor.RED + \" This command can only be run by a player\");\n return false;\n } else {\n if (args[0].equalsIgnoreCase(\"lamps\")) {\n TARDISLampScanner tls = new TARDISLampScanner(plugin);\n return tls.addLampBlocks(player);\n }\n if (args[0].equalsIgnoreCase(\"chameleon\")) {\n if (!plugin.getConfig().getBoolean(\"chameleon\")) {\n sender.sendMessage(plugin.pluginName + \"This server does not allow the use of the chameleon circuit!\");\n return false;\n }\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"on\") && !args[1].equalsIgnoreCase(\"off\") && !args[1].equalsIgnoreCase(\"short\") && !args[1].equalsIgnoreCase(\"reset\"))) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n String chamStr = rs.getChameleon();\n if (chamStr.isEmpty()) {\n sender.sendMessage(plugin.pluginName + \"Could not find the Chameleon Circuit!\");\n return false;\n } else {\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n if (args[1].equalsIgnoreCase(\"on\") || args[1].equalsIgnoreCase(\"off\")) {\n int x, y, z;\n String[] chamData = chamStr.split(\":\");\n World w = plugin.getServer().getWorld(chamData[0]);\n TARDISConstants.COMPASS d = rs.getDirection();\n x = plugin.utils.parseNum(chamData[1]);\n y = plugin.utils.parseNum(chamData[2]);\n z = plugin.utils.parseNum(chamData[3]);\n Block chamBlock = w.getBlockAt(x, y, z);\n Material chamType = chamBlock.getType();\n if (chamType == Material.WALL_SIGN || chamType == Material.SIGN_POST) {\n Sign cs = (Sign) chamBlock.getState();\n if (args[1].equalsIgnoreCase(\"on\")) {\n set.put(\"chamele_on\", 1);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was turned ON!\");\n cs.setLine(3, ChatColor.GREEN + \"ON\");\n }\n if (args[1].equalsIgnoreCase(\"off\")) {\n set.put(\"chamele_on\", 0);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was turned OFF.\");\n cs.setLine(3, ChatColor.RED + \"OFF\");\n }\n cs.update();\n }\n }\n int dwid = plugin.getConfig().getInt(\"wall_id\");\n int dwd = plugin.getConfig().getInt(\"wall_data\");\n if (args[1].equalsIgnoreCase(\"short\")) {\n Block target_block = player.getTargetBlock(transparent, 50).getLocation().getBlock();\n TARDISChameleonCircuit tcc = new TARDISChameleonCircuit(plugin);\n int[] b_data = tcc.getChameleonBlock(target_block, player, true);\n int c_id = b_data[0], c_data = b_data[1];\n set.put(\"chameleon_id\", c_id);\n set.put(\"chameleon_data\", c_data);\n qf.doUpdate(\"tardis\", set, tid);\n boolean bluewool = (c_id == dwid && c_data == (byte) dwd);\n if (!bluewool) {\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was shorted out to: \" + target_block.getType().toString() + \".\");\n }\n }\n if (args[1].equalsIgnoreCase(\"reset\")) {\n set.put(\"chameleon_id\", dwid);\n set.put(\"chameleon_data\", dwd);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The Chameleon Circuit was repaired.\");\n }\n }\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"rescue\")) {\n if (args.length < 2) {\n player.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return true;\n }\n if (player.hasPermission(\"tardis.timetravel.player\")) {\n final String saved = args[1];\n Player destPlayer = plugin.getServer().getPlayer(saved);\n if (destPlayer == null) {\n player.sendMessage(plugin.pluginName + \"That player is not online!\");\n return true;\n }\n String playerNameStr = player.getName();\n destPlayer.sendMessage(plugin.pluginName + playerNameStr + \"wants to rescue you! Type: \" + ChatColor.AQUA + \"tardis rescue accept\" + ChatColor.RESET + \" in chat within 60 seconds to accept the rescue.\");\n plugin.trackChat.put(saved, playerNameStr);\n plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n @Override\n public void run() {\n if (plugin.trackChat.containsKey(saved)) {\n plugin.trackChat.remove(saved);\n sender.sendMessage(plugin.pluginName + saved + \" didn't respond with 60 seconds, aborting rescue!\");\n }\n }\n }, 1200L);\n } else {\n player.sendMessage(plugin.pluginName + \"You do not have permission to time travel to a player!\");\n return true;\n }\n }\n if (args[0].equalsIgnoreCase(\"room\")) {\n if (args.length < 2) {\n player.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String room = args[1].toUpperCase(Locale.ENGLISH);\n StringBuilder buf = new StringBuilder();\n for (String rl : roomArgs) {\n buf.append(rl).append(\", \");\n }\n String roomlist = buf.toString().substring(0, buf.length() - 2);\n if (room.equals(\"HELP\")) {\n player.sendMessage(plugin.pluginName + \"There are currently \" + roomArgs.size() + \" room types! They are: \" + roomlist + \".\");\n player.sendMessage(\"View a TARDIS room gallery at http://eccentricdevotion.github.com/TARDIS/room-gallery.html\");\n return true;\n }\n if (!roomArgs.contains(room)) {\n player.sendMessage(plugin.pluginName + \"That is not a valid room type! Try one of: \" + roomlist + \".\");\n return true;\n }\n String perm = \"tardis.room.\" + args[1].toLowerCase(Locale.ENGLISH);\n if (!player.hasPermission(perm) && !player.hasPermission(\"tardis.room\")) {\n String grammar = (TARDISConstants.vowels.contains(room.substring(0, 1))) ? \"an\" : \"a\";\n sender.sendMessage(plugin.pluginName + \"You do not have permission to grow \" + grammar + \" \" + room);\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return true;\n }\n String chunk = rs.getChunk();\n String[] data = chunk.split(\":\");\n World room_world = plugin.getServer().getWorld(data[0]);\n ChunkGenerator gen = room_world.getGenerator();\n WorldType wt = room_world.getWorldType();\n boolean special = (data[0].contains(\"TARDIS_TimeVortex\") && (wt.equals(WorldType.FLAT) || gen instanceof TARDISChunkGenerator));\n if (!data[0].contains(\"TARDIS_WORLD_\") && !special) {\n player.sendMessage(plugin.pluginName + \"You cannot grow rooms unless your TARDIS was created in its own world!\");\n return true;\n }\n int id = rs.getTardis_id();\n int level = rs.getArtron_level();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n wheret.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return true;\n }\n if (level < plugin.getRoomsConfig().getInt(\"rooms.\" + room + \".cost\")) {\n player.sendMessage(plugin.pluginName + \"The TARDIS does not have enough Artron Energy to grow this room!\");\n return true;\n }\n if (plugin.getConfig().getBoolean(\"rooms_require_blocks\")) {\n HashMap<String, Integer> blockIDCount = new HashMap<String, Integer>();\n boolean hasRequired = true;\n HashMap<String, Integer> roomBlocks = plugin.roomBlockCounts.get(room);\n String wall = \"ORANGE_WOOL\";\n String floor = \"LIGHT_GREY_WOOL\";\n HashMap<String, Object> wherepp = new HashMap<String, Object>();\n boolean hasPrefs = false;\n wherepp.put(\"player\", player.getName());\n ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, wherepp);\n if (rsp.resultSet()) {\n hasPrefs = true;\n wall = rsp.getWall();\n floor = rsp.getFloor();\n }\n for (Map.Entry<String, Integer> entry : roomBlocks.entrySet()) {\n String[] block_data = entry.getKey().split(\":\");\n int bid = plugin.utils.parseNum(block_data[0]);\n String mat;\n String bdata;\n if (hasPrefs && block_data.length == 2 && (block_data[1].equals(\"1\") || block_data[1].equals(\"8\"))) {\n mat = (block_data[1].equals(\"1\")) ? wall : floor;\n TARDISWalls tw = new TARDISWalls();\n Integer[] iddata = tw.blocks.get(mat);\n bdata = String.format(\"%d\", iddata[0]);\n } else {\n mat = Material.getMaterial(bid).toString();\n bdata = String.format(\"%d\", bid);\n }\n int tmp = Math.round((entry.getValue() / 100.0F) * plugin.getConfig().getInt(\"rooms_condenser_percent\"));\n int required = (tmp > 0) ? tmp : 1;\n blockIDCount.put(bdata, required);\n HashMap<String, Object> wherec = new HashMap<String, Object>();\n wherec.put(\"tardis_id\", id);\n wherec.put(\"block_data\", bdata);\n ResultSetCondenser rsc = new ResultSetCondenser(plugin, wherec, false);\n if (rsc.resultSet()) {\n if (rsc.getBlock_count() < required) {\n hasRequired = false;\n int diff = required - rsc.getBlock_count();\n player.sendMessage(plugin.pluginName + \"You need to condense \" + diff + \" more \" + mat + \"!\");\n }\n } else {\n hasRequired = false;\n player.sendMessage(plugin.pluginName + \"You need to condense a minimum of \" + required + \" \" + mat);\n }\n }\n if (hasRequired == false) {\n player.sendMessage(\"-----------------------------\");\n return true;\n }\n TARDISCondenserData c_data = new TARDISCondenserData();\n c_data.setBlockIDCount(blockIDCount);\n c_data.setTardis_id(id);\n plugin.roomCondenserData.put(player.getName(), c_data);\n }\n String message;\n if (room.equals(\"GRAVITY\") || room.equals(\"ANTIGRAVITY\")) {\n message = \"Place the GRAVITY WELL seed block (\" + plugin.getRoomsConfig().getString(\"rooms.\" + room + \".seed\") + \") into the centre of the floor in an empty room, then hit it with the TARDIS key to start growing your room!\";\n } else {\n message = \"Place the \" + room + \" seed block (\" + plugin.getRoomsConfig().getString(\"rooms.\" + room + \".seed\") + \") where the door should be, then hit it with the TARDIS key to start growing your room!\";\n }\n plugin.trackRoomSeed.put(player.getName(), room);\n player.sendMessage(plugin.pluginName + message);\n return true;\n }\n if (args[0].equalsIgnoreCase(\"jettison\")) {\n if (player.hasPermission(\"tardis.room\")) {\n if (args.length < 2) {\n player.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String room = args[1].toUpperCase(Locale.ENGLISH);\n if (room.equals(\"GRAVITY\") || room.equals(\"ANTIGRAVITY\")) {\n player.sendMessage(plugin.pluginName + \"You cannot jettison gravity wells! To remove the gravity blocks use the \" + ChatColor.AQUA + \"/tardisgravity remove\" + ChatColor.RESET + \" command.\");\n return true;\n }\n if (!roomArgs.contains(room)) {\n StringBuilder buf = new StringBuilder(args[1]);\n for (String rl : roomArgs) {\n buf.append(rl).append(\", \");\n }\n String roomlist = buf.toString().substring(0, buf.length() - 2);\n player.sendMessage(plugin.pluginName + \"That is not a valid room type! Try one of: \" + roomlist);\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return true;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n wheret.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return true;\n }\n plugin.trackJettison.put(player.getName(), room);\n String seed = plugin.getArtronConfig().getString(\"jettison_seed\");\n player.sendMessage(plugin.pluginName + \"Stand in the doorway of the room you want to jettison and place a \" + seed + \" block directly in front of the door. Hit the \" + seed + \" with the TARDIS key to jettison the room!\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"occupy\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \" You must be the Timelord of the TARDIS to use this command!\");\n return false;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n String occupied;\n QueryFactory qf = new QueryFactory(plugin);\n if (rst.resultSet()) {\n HashMap<String, Object> whered = new HashMap<String, Object>();\n whered.put(\"tardis_id\", id);\n whered.put(\"player\", player.getName());\n qf.doDelete(\"travellers\", whered);\n occupied = ChatColor.RED + \"UNOCCUPIED\";\n } else {\n HashMap<String, Object> wherei = new HashMap<String, Object>();\n wherei.put(\"tardis_id\", id);\n wherei.put(\"player\", player.getName());\n qf.doInsert(\"travellers\", wherei);\n occupied = ChatColor.GREEN + \"OCCUPIED\";\n }\n sender.sendMessage(plugin.pluginName + \" TARDIS occupation was set to: \" + occupied);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"comehere\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n final Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && eyeLocation.getWorld().getName().equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server admin will not allow you to bring the TARDIS to this world!\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, eyeLocation, true)) {\n return true;\n }\n if (player.hasPermission(\"tardis.exile\") && plugin.getConfig().getBoolean(\"exile\")) {\n String areaPerm = plugin.ta.getExileArea(player);\n if (plugin.ta.areaCheckInExile(areaPerm, eyeLocation)) {\n sender.sendMessage(plugin.pluginName + \"You exile status does not allow you to bring the TARDIS to this location!\");\n return true;\n }\n }\n if (!plugin.ta.areaCheckInExisting(eyeLocation)) {\n sender.sendMessage(plugin.pluginName + \"You cannot use /tardis comehere to bring the Police Box to a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n Material m = player.getTargetBlock(transparent, 50).getType();\n if (m != Material.SNOW) {\n int yplusone = eyeLocation.getBlockY();\n eyeLocation.setY(yplusone + 1);\n }\n String world = eyeLocation.getWorld().getName();\n if (!plugin.getConfig().getBoolean(\"worlds.\" + world)) {\n sender.sendMessage(plugin.pluginName + \"You cannot bring the TARDIS Police Box to this world\");\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n final ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of the TARDIS to use this command!\");\n return true;\n }\n final int id = rs.getTardis_id();\n HashMap<String, Object> wherettrav = new HashMap<String, Object>();\n wherettrav.put(\"player\", player.getName());\n wherettrav.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);\n if (rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You cannot bring the Police Box here because you are inside a TARDIS!\");\n return true;\n }\n if (plugin.tardisMaterialising.contains(id) || plugin.tardisDematerialising.contains(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot do that while the TARDIS is materialising!\");\n return true;\n }\n final TARDISConstants.COMPASS d = rs.getDirection();\n TARDISTimeTravel tt = new TARDISTimeTravel(plugin);\n int[] start_loc = tt.getStartLocation(eyeLocation, d);\n int count = tt.safeLocation(start_loc[0], eyeLocation.getBlockY(), start_loc[2], start_loc[1], start_loc[3], eyeLocation.getWorld(), d);\n if (count > 0) {\n sender.sendMessage(plugin.pluginName + \"That location would grief existing blocks! Try somewhere else!\");\n return true;\n }\n int level = rs.getArtron_level();\n int ch = plugin.getArtronConfig().getInt(\"comehere\");\n if (level < ch) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to make this trip!\");\n return true;\n }\n final Player p = player;\n String current_str = rs.getCurrent();\n boolean chamtmp = false;\n if (plugin.getConfig().getBoolean(\"chameleon\")) {\n chamtmp = rs.isChamele_on();\n }\n final boolean cham = chamtmp;\n String[] saveData = current_str.split(\":\");\n World w = plugin.getServer().getWorld(saveData[0]);\n if (w != null) {\n int x, y, z;\n x = plugin.utils.parseNum(saveData[1]);\n y = plugin.utils.parseNum(saveData[2]);\n z = plugin.utils.parseNum(saveData[3]);\n final Location oldSave = w.getBlockAt(x, y, z).getLocation();\n String comehere = eyeLocation.getWorld().getName() + \":\" + eyeLocation.getBlockX() + \":\" + eyeLocation.getBlockY() + \":\" + eyeLocation.getBlockZ();\n final boolean hidden = rs.isHidden();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"save\", comehere);\n set.put(\"current\", comehere);\n if (hidden) {\n set.put(\"hidden\", 0);\n }\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The TARDIS is coming...\");\n final boolean mat = plugin.getConfig().getBoolean(\"materialise\");\n long delay = (mat) ? 1L : 180L;\n Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n @Override\n public void run() {\n if (!hidden) {\n plugin.tardisDematerialising.add(id);\n plugin.destroyPB.destroyPoliceBox(oldSave, d, id, false, mat, cham, p);\n }\n }\n }, delay);\n Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {\n @Override\n public void run() {\n plugin.buildPB.buildPoliceBox(id, eyeLocation, d, cham, p, false, false);\n }\n }, delay * 2);\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n qf.alterEnergyLevel(\"tardis\", -ch, wheret, player);\n plugin.tardisHasDestination.remove(id);\n if (plugin.trackRescue.containsKey(Integer.valueOf(id))) {\n plugin.trackRescue.remove(Integer.valueOf(id));\n }\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + \"Could not get the previous location of the TARDIS!\");\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"check_loc\")) {\n final Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();\n Material m = player.getTargetBlock(transparent, 50).getType();\n if (m != Material.SNOW) {\n int yplusone = eyeLocation.getBlockY();\n eyeLocation.setY(yplusone + 1);\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of a TARDIS to use this command!\");\n return true;\n }\n final TARDISConstants.COMPASS d = rs.getDirection();\n TARDISTimeTravel tt = new TARDISTimeTravel(plugin);\n tt.testSafeLocation(eyeLocation, d);\n return true;\n }\n if (args[0].equalsIgnoreCase(\"inside\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of a TARDIS to use this command!\");\n return true;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, true);\n if (rst.resultSet()) {\n List<String> data = rst.getData();\n sender.sendMessage(plugin.pluginName + \"The players inside your TARDIS are:\");\n for (String s : data) {\n sender.sendMessage(s);\n }\n } else {\n sender.sendMessage(plugin.pluginName + \"Nobody is inside your TARDIS.\");\n }\n return true;\n }\n if (args[0].equalsIgnoreCase(\"home\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n Location eyeLocation = player.getTargetBlock(transparent, 50).getLocation();\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && eyeLocation.getWorld().getName().equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server admin will not allow you to set the TARDIS home in this world!\");\n return true;\n }\n if (!plugin.ta.areaCheckInExisting(eyeLocation)) {\n sender.sendMessage(plugin.pluginName + \"You cannot use /tardis home in a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, eyeLocation, true)) {\n return true;\n }\n Material m = player.getTargetBlock(transparent, 50).getType();\n if (m != Material.SNOW) {\n int yplusone = eyeLocation.getBlockY();\n eyeLocation.setY(yplusone + 1);\n }\n String world = eyeLocation.getWorld().getName();\n if (!plugin.getConfig().getBoolean(\"worlds.\" + world)) {\n sender.sendMessage(plugin.pluginName + \"You cannot set the TARDIS home location to this world\");\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You must be the Timelord of the TARDIS to use this command!\");\n return false;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> wherettrav = new HashMap<String, Object>();\n wherettrav.put(\"player\", player.getName());\n wherettrav.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);\n if (rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You cannot set the home location here because you are inside a TARDIS!\");\n return true;\n }\n String sethome = eyeLocation.getWorld().getName() + \":\" + eyeLocation.getBlockX() + \":\" + eyeLocation.getBlockY() + \":\" + eyeLocation.getBlockZ();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"home\", sethome);\n qf.doUpdate(\"tardis\", set, tid);\n sender.sendMessage(plugin.pluginName + \"The new TARDIS home was set!\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"update\")) {\n if (player.hasPermission(\"tardis.update\")) {\n String[] validBlockNames = {\"door\", \"button\", \"world-repeater\", \"x-repeater\", \"z-repeater\", \"y-repeater\", \"chameleon\", \"save-sign\", \"artron\", \"handbrake\", \"condenser\", \"scanner\", \"backdoor\", \"keyboard\", \"creeper\", \"eps\", \"back\", \"terminal\", \"ars\", \"temporal\"};\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String tardis_block = args[1].toLowerCase(Locale.ENGLISH);\n if (!Arrays.asList(validBlockNames).contains(tardis_block)) {\n player.sendMessage(plugin.pluginName + \"That is not a valid TARDIS block name! Try one of : door|button|world-repeater|x-repeater|z-repeater|y-repeater|chameleon|save-sign|artron|handbrake|condenser|scanner|backdoor|keyboard|creeper|eps|back|terminal|ars|temporal\");\n return false;\n }\n if (tardis_block.equals(\"backdoor\") && !player.hasPermission(\"tardis.backdoor\")) {\n sender.sendMessage(plugin.pluginName + \"You do not have permission to create a back door!\");\n return true;\n }\n if (tardis_block.equals(\"temporal\") && !player.hasPermission(\"tardis.temporal\")) {\n sender.sendMessage(plugin.pluginName + \"You do not have permission to create a Temporal Locator!\");\n return true;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return false;\n }\n if (!tardis_block.equals(\"backdoor\")) {\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return false;\n }\n }\n plugin.trackPlayers.put(player.getName(), tardis_block);\n player.sendMessage(plugin.pluginName + \"Click the TARDIS \" + tardis_block + \" to update its position.\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"secondary\")) {\n if (player.hasPermission(\"tardis.update\")) {\n String[] validBlockNames = {\"button\", \"world-repeater\", \"x-repeater\", \"z-repeater\", \"y-repeater\", \"artron\", \"handbrake\", \"door\", \"back\"};\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n String tardis_block = args[1].toLowerCase(Locale.ENGLISH);\n if (!Arrays.asList(validBlockNames).contains(tardis_block)) {\n player.sendMessage(plugin.pluginName + \"That is not a valid TARDIS block name! Try one of : button|world-repeater|x-repeater|z-repeater|y-repeater|artron|handbrake|door|back\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not a Timelord. You need to create a TARDIS first before using this command!\");\n return false;\n }\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);\n if (!rst.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"You are not inside your TARDIS. You need to be to run this command!\");\n return false;\n }\n plugin.trackSecondary.put(player.getName(), tardis_block);\n player.sendMessage(plugin.pluginName + \"Click the TARDIS \" + tardis_block + \" to update its position.\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"rebuild\") || args[0].equalsIgnoreCase(\"hide\")) {\n if (player.hasPermission(\"tardis.rebuild\")) {\n String save;\n World w;\n int x, y, z, id;\n TARDISConstants.COMPASS d;\n boolean cham = false;\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n id = rs.getTardis_id();\n HashMap<String, Object> wherein = new HashMap<String, Object>();\n wherein.put(\"player\", player.getName());\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherein, false);\n if (rst.resultSet() && args[0].equalsIgnoreCase(\"rebuild\") && plugin.tardisHasDestination.containsKey(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot rebuild the TARDIS right now! Try travelling first.\");\n return true;\n }\n int level = rs.getArtron_level();\n save = rs.getCurrent();\n if (plugin.tardisMaterialising.contains(id) || plugin.tardisDematerialising.contains(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot do that while the TARDIS is materialising!\");\n return true;\n }\n if (plugin.getConfig().getBoolean(\"chameleon\")) {\n cham = rs.isChamele_on();\n }\n d = rs.getDirection();\n String[] save_data = save.split(\":\");\n w = plugin.getServer().getWorld(save_data[0]);\n x = plugin.utils.parseNum(save_data[1]);\n y = plugin.utils.parseNum(save_data[2]);\n z = plugin.utils.parseNum(save_data[3]);\n Location l = new Location(w, x, y, z);\n HashMap<String, Object> wheret = new HashMap<String, Object>();\n wheret.put(\"tardis_id\", id);\n QueryFactory qf = new QueryFactory(plugin);\n if (args[0].equalsIgnoreCase(\"rebuild\")) {\n int rebuild = plugin.getArtronConfig().getInt(\"random\");\n if (level < rebuild) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to rebuild!\");\n return false;\n }\n plugin.buildPB.buildPoliceBox(id, l, d, cham, player, true, false);\n sender.sendMessage(plugin.pluginName + \"The TARDIS Police Box was rebuilt!\");\n qf.alterEnergyLevel(\"tardis\", -rebuild, wheret, player);\n if (rs.isHidden()) {\n HashMap<String, Object> whereh = new HashMap<String, Object>();\n whereh.put(\"tardis_id\", id);\n HashMap<String, Object> seth = new HashMap<String, Object>();\n seth.put(\"hidden\", 0);\n qf.doUpdate(\"tardis\", seth, whereh);\n }\n return true;\n }\n if (args[0].equalsIgnoreCase(\"hide\")) {\n int hide = plugin.getArtronConfig().getInt(\"hide\");\n if (level < hide) {\n player.sendMessage(plugin.pluginName + ChatColor.RED + \"The TARDIS does not have enough Artron Energy to hide!\");\n return false;\n }\n plugin.destroyPB.destroyPoliceBox(l, d, id, true, false, false, null);\n sender.sendMessage(plugin.pluginName + \"The TARDIS Police Box was hidden! Use \" + ChatColor.GREEN + \"/tardis rebuild\" + ChatColor.RESET + \" to show it again.\");\n qf.alterEnergyLevel(\"tardis\", -hide, wheret, player);\n HashMap<String, Object> whereh = new HashMap<String, Object>();\n whereh.put(\"tardis_id\", id);\n HashMap<String, Object> seth = new HashMap<String, Object>();\n seth.put(\"hidden\", 1);\n qf.doUpdate(\"tardis\", seth, whereh);\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"list\")) {\n if (player.hasPermission(\"tardis.list\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"saves\") && !args[1].equalsIgnoreCase(\"companions\") && !args[1].equalsIgnoreCase(\"areas\") && !args[1].equalsIgnoreCase(\"rechargers\"))) {\n sender.sendMessage(plugin.pluginName + \"You need to specify which TARDIS list you want to view! [saves|companions|areas|rechargers]\");\n return false;\n }\n TARDISLister.list(player, args[1]);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"find\")) {\n if (player.hasPermission(\"tardis.find\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n String loc = rs.getCurrent();\n String[] findData = loc.split(\":\");\n sender.sendMessage(plugin.pluginName + \"TARDIS was left at \" + findData[0] + \" at x: \" + findData[1] + \" y: \" + findData[2] + \" z: \" + findData[3]);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"add\")) {\n if (player.hasPermission(\"tardis.add\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n String comps;\n int id;\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n } else {\n id = rs.getTardis_id();\n comps = rs.getCompanions();\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"That doesn't appear to be a valid username\");\n return false;\n } else {\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n if (comps != null && !comps.isEmpty()) {\n String newList = comps + \":\" + args[1].toLowerCase(Locale.ENGLISH);\n set.put(\"companions\", newList);\n } else {\n set.put(\"companions\", args[1].toLowerCase(Locale.ENGLISH));\n }\n qf.doUpdate(\"tardis\", set, tid);\n player.sendMessage(plugin.pluginName + \"You added \" + ChatColor.GREEN + args[1] + ChatColor.RESET + \" as a TARDIS companion.\");\n if (plugin.getAchivementConfig().getBoolean(\"friends.enabled\")) {\n TARDISAchievementFactory taf = new TARDISAchievementFactory(plugin, player, \"friends\", 1);\n taf.doAchievement(1);\n }\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"remove\")) {\n if (player.hasPermission(\"tardis.add\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n String comps;\n int id;\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n } else {\n id = rs.getTardis_id();\n comps = rs.getCompanions();\n if (comps == null || comps.isEmpty()) {\n sender.sendMessage(plugin.pluginName + \"You have not added any TARDIS companions yet!\");\n return true;\n }\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"That doesn't appear to be a valid username\");\n return false;\n } else {\n String[] split = comps.split(\":\");\n StringBuilder buf = new StringBuilder();\n String newList = \"\";\n if (split.length > 1) {\n for (String c : split) {\n if (!c.equals(args[1].toLowerCase(Locale.ENGLISH))) {\n buf.append(c).append(\":\");\n }\n }\n if (buf.length() > 0) {\n newList = buf.toString().substring(0, buf.length() - 1);\n }\n }\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"companions\", newList);\n qf.doUpdate(\"tardis\", set, tid);\n player.sendMessage(plugin.pluginName + \"You removed \" + ChatColor.GREEN + args[1] + ChatColor.RESET + \" as a TARDIS companion.\");\n return true;\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"save\")) {\n if (player.hasPermission(\"tardis.save\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"That doesn't appear to be a valid save name (it may be too long or contains spaces).\");\n return false;\n } else {\n int id = rs.getTardis_id();\n String cur = rs.getCurrent();\n String[] curDest = cur.split(\":\");\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> set = new HashMap<String, Object>();\n set.put(\"tardis_id\", id);\n set.put(\"dest_name\", args[1]);\n set.put(\"world\", curDest[0]);\n set.put(\"x\", plugin.utils.parseNum(curDest[1]));\n set.put(\"y\", plugin.utils.parseNum(curDest[2]));\n set.put(\"z\", plugin.utils.parseNum(curDest[3]));\n if (qf.doInsert(\"destinations\", set) < 0) {\n return false;\n } else {\n sender.sendMessage(plugin.pluginName + \"The location '\" + args[1] + \"' was saved successfully.\");\n return true;\n }\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"removesave\")) {\n if (player.hasPermission(\"tardis.save\")) {\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n HashMap<String, Object> whered = new HashMap<String, Object>();\n whered.put(\"dest_name\", args[1]);\n whered.put(\"tardis_id\", id);\n ResultSetDestinations rsd = new ResultSetDestinations(plugin, whered, false);\n if (!rsd.resultSet()) {\n sender.sendMessage(plugin.pluginName + \"Could not find a saved destination with that name!\");\n return false;\n }\n int destID = rsd.getDest_id();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> did = new HashMap<String, Object>();\n did.put(\"dest_id\", destID);\n qf.doDelete(\"destinations\", did);\n sender.sendMessage(plugin.pluginName + \"The destination \" + args[1] + \" was deleted!\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"setdest\")) {\n if (player.hasPermission(\"tardis.save\")) {\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"Too few command arguments!\");\n return false;\n }\n if (!args[1].matches(\"[A-Za-z0-9_]{2,16}\")) {\n sender.sendMessage(plugin.pluginName + \"The destination name must be between 2 and 16 characters and have no spaces!\");\n return false;\n } else if (args[1].equalsIgnoreCase(\"hide\") || args[1].equalsIgnoreCase(\"rebuild\") || args[1].equalsIgnoreCase(\"home\")) {\n sender.sendMessage(plugin.pluginName + \"That is a reserved destination name!\");\n return false;\n } else {\n int id = rs.getTardis_id();\n HashMap<String, Object> wherettrav = new HashMap<String, Object>();\n wherettrav.put(\"player\", player.getName());\n wherettrav.put(\"tardis_id\", id);\n ResultSetTravellers rst = new ResultSetTravellers(plugin, wherettrav, false);\n if (rst.resultSet()) {\n player.sendMessage(plugin.pluginName + \"You cannot bring the Police Box here because you are inside a TARDIS!\");\n return true;\n }\n Block b = player.getTargetBlock(transparent, 50);\n Location l = b.getLocation();\n if (!plugin.ta.areaCheckInExisting(l)) {\n sender.sendMessage(plugin.pluginName + \"You cannot use /tardis setdest in a TARDIS area! Please use \" + ChatColor.AQUA + \"/tardistravel area [area name]\");\n return true;\n }\n String world = l.getWorld().getName();\n if (!plugin.getConfig().getBoolean(\"include_default_world\") && plugin.getConfig().getBoolean(\"default_world\") && world.equals(plugin.getConfig().getString(\"default_world_name\"))) {\n sender.sendMessage(plugin.pluginName + \"The server admin will not allow you to set the TARDIS destination to this world!\");\n return true;\n }\n if (!plugin.getConfig().getBoolean(\"worlds.\" + world)) {\n sender.sendMessage(plugin.pluginName + \"You cannot bring the TARDIS Police Box to this world\");\n return true;\n }\n respect = new TARDISPluginRespect(plugin);\n if (!respect.getRespect(player, l, true)) {\n return true;\n }\n if (player.hasPermission(\"tardis.exile\") && plugin.getConfig().getBoolean(\"exile\")) {\n String areaPerm = plugin.ta.getExileArea(player);\n if (plugin.ta.areaCheckInExile(areaPerm, l)) {\n sender.sendMessage(plugin.pluginName + \"You exile status does not allow you to save the TARDIS to this location!\");\n return false;\n }\n }\n String dw = l.getWorld().getName();\n int dx = l.getBlockX();\n int dy = l.getBlockY() + 1;\n int dz = l.getBlockZ();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> set = new HashMap<String, Object>();\n set.put(\"tardis_id\", id);\n set.put(\"dest_name\", args[1]);\n set.put(\"world\", dw);\n set.put(\"x\", dx);\n set.put(\"y\", dy);\n set.put(\"z\", dz);\n if (qf.doInsert(\"destinations\", set) < 0) {\n return false;\n } else {\n sender.sendMessage(plugin.pluginName + \"The destination '\" + args[1] + \"' was saved successfully.\");\n return true;\n }\n }\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"direction\")) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"north\") && !args[1].equalsIgnoreCase(\"west\") && !args[1].equalsIgnoreCase(\"south\") && !args[1].equalsIgnoreCase(\"east\"))) {\n sender.sendMessage(plugin.pluginName + \"You need to specify the compass direction e.g. north, west, south or east!\");\n return false;\n }\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"owner\", player.getName());\n ResultSetTardis rs = new ResultSetTardis(plugin, where, \"\", false);\n if (!rs.resultSet()) {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_TARDIS);\n return false;\n }\n int id = rs.getTardis_id();\n int level = rs.getArtron_level();\n int amount = plugin.getArtronConfig().getInt(\"random\");\n if (level < amount) {\n sender.sendMessage(plugin.pluginName + \"The TARDIS does not have enough Artron Energy to change the Police Box direction!\");\n return true;\n }\n String save = rs.getCurrent();\n String[] save_data = save.split(\":\");\n if (plugin.tardisMaterialising.contains(id) || plugin.tardisDematerialising.contains(id)) {\n sender.sendMessage(plugin.pluginName + \"You cannot do that while the TARDIS is materialising!\");\n return true;\n }\n boolean cham = false;\n if (plugin.getConfig().getBoolean(\"chameleon\")) {\n cham = rs.isChamele_on();\n }\n String dir = args[1].toUpperCase(Locale.ENGLISH);\n TARDISConstants.COMPASS old_d = rs.getDirection();\n QueryFactory qf = new QueryFactory(plugin);\n HashMap<String, Object> tid = new HashMap<String, Object>();\n HashMap<String, Object> set = new HashMap<String, Object>();\n tid.put(\"tardis_id\", id);\n set.put(\"direction\", dir);\n qf.doUpdate(\"tardis\", set, tid);\n HashMap<String, Object> did = new HashMap<String, Object>();\n HashMap<String, Object> setd = new HashMap<String, Object>();\n did.put(\"door_type\", 0);\n did.put(\"tardis_id\", id);\n setd.put(\"door_direction\", dir);\n qf.doUpdate(\"doors\", setd, did);\n World w = plugin.getServer().getWorld(save_data[0]);\n int x = plugin.utils.parseNum(save_data[1]);\n int y = plugin.utils.parseNum(save_data[2]);\n int z = plugin.utils.parseNum(save_data[3]);\n Location l = new Location(w, x, y, z);\n TARDISConstants.COMPASS d = TARDISConstants.COMPASS.valueOf(dir);\n if (!rs.isHidden()) {\n plugin.destroyPB.destroyPlatform(rs.getPlatform(), id);\n plugin.destroyPB.destroySign(l, old_d);\n }\n plugin.buildPB.buildPoliceBox(id, l, d, cham, player, true, false);\n HashMap<String, Object> wherea = new HashMap<String, Object>();\n wherea.put(\"tardis_id\", id);\n qf.alterEnergyLevel(\"tardis\", -amount, wherea, player);\n sender.sendMessage(plugin.pluginName + \"You used \" + amount + \" Artron Energy changing the Police Box direction.\");\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"namekey\")) {\n if (bukkitversion.compareTo(preIMversion) < 0 || (bukkitversion.compareTo(preIMversion) == 0 && SUBversion.compareTo(preSUBversion) < 0)) {\n sender.sendMessage(plugin.pluginName + \"You cannot rename the TARDIS key with this version of Bukkit!\");\n return true;\n }\n String key;\n HashMap<String, Object> where = new HashMap<String, Object>();\n where.put(\"player\", player.getName());\n ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, where);\n if (rsp.resultSet()) {\n key = (!rsp.getKey().isEmpty()) ? rsp.getKey() : plugin.getConfig().getString(\"key\");\n } else {\n key = plugin.getConfig().getString(\"key\");\n }\n Material m = Material.getMaterial(key);\n if (m.equals(Material.AIR)) {\n sender.sendMessage(plugin.pluginName + \"You cannot rename AIR!\");\n return true;\n }\n ItemStack is = player.getItemInHand();\n if (!is.getType().equals(m)) {\n sender.sendMessage(plugin.pluginName + \"You can only rename the TARDIS key!\");\n return true;\n }\n int count = args.length;\n if (count < 2) {\n return false;\n }\n StringBuilder buf = new StringBuilder(args[1]);\n for (int i = 2; i < count; i++) {\n buf.append(\" \").append(args[i]);\n }\n String tmp = buf.toString();\n if (!tmp.isEmpty()) {\n TARDISItemRenamer ir = new TARDISItemRenamer(is);\n ir.setName(tmp, false);\n sender.sendMessage(plugin.pluginName + \"TARDIS key renamed to '\" + tmp + \"'\");\n return true;\n } else {\n return false;\n }\n }\n if (args[0].equalsIgnoreCase(\"help\")) {\n if (args.length == 1) {\n sender.sendMessage(TARDISConstants.COMMANDS.split(\"\\n\"));\n return true;\n }\n if (args.length == 2) {\n List<String> cmds = new ArrayList<String>();\n for (TARDISConstants.CMDS c : TARDISConstants.CMDS.values()) {\n cmds.add(c.toString());\n }\n if (!cmds.contains(args[1].toUpperCase(Locale.ENGLISH))) {\n sender.sendMessage(plugin.pluginName + \"That is not a valid help topic!\");\n return true;\n }\n switch (TARDISConstants.fromString(args[1])) {\n case CREATE:\n sender.sendMessage(TARDISConstants.COMMAND_CREATE.split(\"\\n\"));\n break;\n case DELETE:\n sender.sendMessage(TARDISConstants.COMMAND_DELETE.split(\"\\n\"));\n break;\n case TIMETRAVEL:\n sender.sendMessage(TARDISConstants.COMMAND_TIMETRAVEL.split(\"\\n\"));\n break;\n case LIST:\n sender.sendMessage(TARDISConstants.COMMAND_LIST.split(\"\\n\"));\n break;\n case FIND:\n sender.sendMessage(TARDISConstants.COMMAND_FIND.split(\"\\n\"));\n break;\n case SAVE:\n sender.sendMessage(TARDISConstants.COMMAND_SAVE.split(\"\\n\"));\n break;\n case REMOVESAVE:\n sender.sendMessage(TARDISConstants.COMMAND_REMOVESAVE.split(\"\\n\"));\n break;\n case ADD:\n sender.sendMessage(TARDISConstants.COMMAND_ADD.split(\"\\n\"));\n break;\n case TRAVEL:\n sender.sendMessage(TARDISConstants.COMMAND_TRAVEL.split(\"\\n\"));\n break;\n case UPDATE:\n sender.sendMessage(TARDISConstants.COMMAND_UPDATE.split(\"\\n\"));\n break;\n case REBUILD:\n sender.sendMessage(TARDISConstants.COMMAND_REBUILD.split(\"\\n\"));\n break;\n case CHAMELEON:\n sender.sendMessage(TARDISConstants.COMMAND_CHAMELEON.split(\"\\n\"));\n break;\n case SFX:\n sender.sendMessage(TARDISConstants.COMMAND_SFX.split(\"\\n\"));\n break;\n case PLATFORM:\n sender.sendMessage(TARDISConstants.COMMAND_PLATFORM.split(\"\\n\"));\n break;\n case SETDEST:\n sender.sendMessage(TARDISConstants.COMMAND_SETDEST.split(\"\\n\"));\n break;\n case HOME:\n sender.sendMessage(TARDISConstants.COMMAND_HOME.split(\"\\n\"));\n break;\n case HIDE:\n sender.sendMessage(TARDISConstants.COMMAND_HIDE.split(\"\\n\"));\n break;\n case VERSION:\n sender.sendMessage(TARDISConstants.COMMAND_HIDE.split(\"\\n\"));\n break;\n case ADMIN:\n sender.sendMessage(TARDISConstants.COMMAND_ADMIN.split(\"\\n\"));\n break;\n case AREA:\n sender.sendMessage(TARDISConstants.COMMAND_AREA.split(\"\\n\"));\n break;\n case ROOM:\n sender.sendMessage(TARDISConstants.COMMAND_ROOM.split(\"\\n\"));\n break;\n case ARTRON:\n sender.sendMessage(TARDISConstants.COMMAND_ARTRON.split(\"\\n\"));\n break;\n case BIND:\n sender.sendMessage(TARDISConstants.COMMAND_BIND.split(\"\\n\"));\n break;\n default:\n sender.sendMessage(TARDISConstants.COMMANDS.split(\"\\n\"));\n }\n }\n return true;\n }\n }\n }\n return false;\n }\n"} {"input": " public void active() throws Exception {\n UIPopupWindow uiWindowE = getChildById(\"UIQuckAddEventPopupWindow\") ;\n if(uiWindowE == null) uiWindowE = addChild(UIPopupWindowQuick.class, null, \"UIQuckAddEventPopupWindow\") ;\n UIQuickAddEvent quickAddForm = (UIQuickAddEvent)uiWindowE.getUIComponent();\n if(quickAddForm == null) quickAddForm = createUIComponent(UIQuickAddEvent.class, null, null) ; \n List<SelectItem> calendarOption = CalendarUtils.getCalendarOption();\n ((UIFormSelectBoxWithGroups)quickAddForm.getChildById(UIQuickAddEvent.FIELD_CALENDAR)).setOptions(calendarOption) ;\n quickAddForm.getUIFormSelectBox(UIQuickAddEvent.FIELD_CATEGORY).setOptions(CalendarUtils.getCategory()) ;\n quickAddForm.setEvent(true) ;\n quickAddForm.setId(\"UIQuickAddEvent\") ;\n quickAddForm.init(CalendarUtils.getCalendarService().getCalendarSetting(CalendarUtils.getCurrentUser()), String.valueOf(new Date().getTime()), String.valueOf(new Date().getTime())) ;\n uiWindowE.setUIComponent(quickAddForm) ;\n uiWindowE.setWindowSize(540, 0);\n UIPopupWindow uiWindowT = getChildById(\"UIQuckAddTaskPopupWindow\") ;\n if(uiWindowT == null) uiWindowT = addChild(UIPopupWindowQuick.class, null, \"UIQuckAddTaskPopupWindow\") ;\n UIQuickAddEvent quickAddTask = (UIQuickAddEvent)uiWindowT.getUIComponent();\n if(quickAddTask == null) quickAddTask = createUIComponent(UIQuickAddEvent.class, null, null) ; \n quickAddTask.setEvent(false) ;\n quickAddTask.setId(\"UIQuickAddTask\") ;\n quickAddTask.init(CalendarUtils.getCalendarService().getCalendarSetting(CalendarUtils.getCurrentUser()),String.valueOf(new Date().getTime()), String.valueOf(new Date().getTime())) ;\n ((UIFormSelectBoxWithGroups)quickAddTask.getChildById(UIQuickAddEvent.FIELD_CALENDAR)).setOptions(calendarOption) ;\n quickAddTask.getUIFormSelectBox(UIQuickAddEvent.FIELD_CATEGORY).setOptions(CalendarUtils.getCategory()) ;\n uiWindowT.setUIComponent(quickAddTask) ;\n uiWindowT.setWindowSize(540, 0);\n }\n", "output": " public void active() throws Exception {\n UIPopupWindow uiWindowE = getChildById(\"UIQuickAddEventPopupWindow\") ;\n if(uiWindowE == null) uiWindowE = addChild(UIPopupWindow.class, null, \"UIQuickAddEventPopupWindow\") ;\n UIQuickAddEvent quickAddForm = (UIQuickAddEvent)uiWindowE.getUIComponent();\n if(quickAddForm == null) quickAddForm = createUIComponent(UIQuickAddEvent.class, null, null) ; \n List<SelectItem> calendarOption = CalendarUtils.getCalendarOption();\n ((UIFormSelectBoxWithGroups)quickAddForm.getChildById(UIQuickAddEvent.FIELD_CALENDAR)).setOptions(calendarOption) ;\n quickAddForm.getUIFormSelectBox(UIQuickAddEvent.FIELD_CATEGORY).setOptions(CalendarUtils.getCategory()) ;\n quickAddForm.setEvent(true) ;\n quickAddForm.setId(\"UIQuickAddEvent\") ;\n quickAddForm.init(CalendarUtils.getCalendarService().getCalendarSetting(CalendarUtils.getCurrentUser()), String.valueOf(new Date().getTime()), String.valueOf(new Date().getTime())) ;\n uiWindowE.setUIComponent(quickAddForm) ;\n uiWindowE.setWindowSize(540, 0);\n UIPopupWindow uiWindowT = getChildById(\"UIQuickAddTaskPopupWindow\") ;\n if(uiWindowT == null) uiWindowT = addChild(UIPopupWindow.class, null, \"UIQuickAddTaskPopupWindow\") ;\n UIQuickAddEvent quickAddTask = (UIQuickAddEvent)uiWindowT.getUIComponent();\n if(quickAddTask == null) quickAddTask = createUIComponent(UIQuickAddEvent.class, null, null) ; \n quickAddTask.setEvent(false) ;\n quickAddTask.setId(\"UIQuickAddTask\") ;\n quickAddTask.init(CalendarUtils.getCalendarService().getCalendarSetting(CalendarUtils.getCurrentUser()),String.valueOf(new Date().getTime()), String.valueOf(new Date().getTime())) ;\n ((UIFormSelectBoxWithGroups)quickAddTask.getChildById(UIQuickAddEvent.FIELD_CALENDAR)).setOptions(calendarOption) ;\n quickAddTask.getUIFormSelectBox(UIQuickAddEvent.FIELD_CATEGORY).setOptions(CalendarUtils.getCategory()) ;\n uiWindowT.setUIComponent(quickAddTask) ;\n uiWindowT.setWindowSize(540, 0);\n }\n"} {"input": "\tpublic ESChecksumErrorHandler getChecksumErrorHandler() {\n\t\tif (checksumErrorHandler == null) {\n\t\t\tESExtensionPoint extensionPoint = new ESExtensionPoint(\n\t\t\t\t\"org.eclipse.emf.emfstore.client.checksumErrorHandler\");\n\t\t\tESExtensionElement elementWithHighestPriority = extensionPoint.getElementWithHighestPriority();\n\t\t\tif (elementWithHighestPriority != null) {\n\t\t\t\tESChecksumErrorHandler errorHandler = elementWithHighestPriority\n\t\t\t\t\t.getClass(\"errorHandler\",\n\t\t\t\t\t\tESChecksumErrorHandler.class);\n\t\t\t\tif (errorHandler != null) {\n\t\t\t\t\tchecksumErrorHandler = errorHandler;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (checksumErrorHandler == null) {\n\t\t\t\tchecksumErrorHandler = ChecksumErrorHandler.LOG;\n\t\t\t}\n\t\t}\n\t\treturn checksumErrorHandler;\n\t}\n", "output": "\tpublic ESChecksumErrorHandler getChecksumErrorHandler() {\n\t\tif (checksumErrorHandler == null) {\n\t\t\tESExtensionPoint extensionPoint = new ESExtensionPoint(\n\t\t\t\t\"org.eclipse.emf.emfstore.client.checksumErrorHandler\");\n\t\t\tESExtensionElement elementWithHighestPriority = extensionPoint.getElementWithHighestPriority();\n\t\t\tif (elementWithHighestPriority != null) {\n\t\t\t\tESChecksumErrorHandler errorHandler = elementWithHighestPriority\n\t\t\t\t\t.getClass(\"errorHandler\",\n\t\t\t\t\t\tESChecksumErrorHandler.class);\n\t\t\t\tif (errorHandler != null) {\n\t\t\t\t\tchecksumErrorHandler = errorHandler;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (checksumErrorHandler == null) {\n\t\t\t\tchecksumErrorHandler = ChecksumErrorHandler.CANCEL;\n\t\t\t}\n\t\t}\n\t\treturn checksumErrorHandler;\n\t}\n"} {"input": "\tpublic static void main(String[] args) throws IOException {\n\t\tList<FieldData> commonData = Lists.newArrayList();\n\t\tMultimap<String, FieldData> specificData = HashMultimap.create();\n\t\tFile metaData = new File(\"./AbilityMetaData.csv\");\n\t\tCsvReader reader = new CsvReader(new FileReader(metaData));\n\t\treader.readHeaders();\n\t\twhile (reader.readRecord()) {\n\t\t\tString id = reader.get(\"s\");\n\t\t\tString displayName = strings.get(reader.get(\"displayName\"));\n\t\t\tif (displayName == null) {\n\t\t\t\tdisplayName = reader.get(\"field\");\n\t\t\t}\n\t\t\tString type = reader.get(\"type\");\n\t\t\tint data = Integer.parseInt(reader.get(\"data\"));\n\t\t\tboolean useLevels = !reader.get(\"repeat\").equals(\"0\");\n\t\t\tString useSpecific = reader.get(\"useSpecific\");\n\t\t\tFieldData fd = new FieldData(id, displayName, type, data, useLevels);\n\t\t\tif (useSpecific.isEmpty()) {\n\t\t\t\tcommonData.add(fd);\n\t\t\t} else {\n\t\t\t\tfor (String spell : useSpecific.split(\"[,\\\\.]\")) {\n\t\t\t\t\tspecificData.put(spell, fd);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintln(\"package AbilityObjEditing\");\n\t\tprintln(\"import public ObjEditingNatives\");\n\t\tprintln(\"\");\n\t\tprintln(\"public class AbilityDefinition\");\n\t\tprintln(\"\tprotected ObjectDefinition def\");\n\t\tprintln(\"\t\");\n\t\tprintln(\"\tconstruct(int newAbilityId, int origAbilityId)\");\n\t\tprintln(\"\t\tdef = createObjectDefinition(\\\"w3a\\\", newAbilityId, origAbilityId)\");\n\t\tSet<String> usedNames = Sets.newHashSet();\n\t\tfor (FieldData fd : commonData) {\n\t\t\tfd.printFunc(usedNames);\n\t\t}\n\t\tfor (String spell : specificData.keySet()) {\n\t\t\tusedNames.clear();\n\t\t\tprintln(\"\");\n\t\t\tprintln(\"\");\n\t\t\tprintln(\"\");\n\t\t\tString spellName = abilityNames.get(spell);\n\t\t\tprintln(\"public class AbilityDefinition\"+spellName+\" extends AbilityDefinition\");\n\t\t\tprintln(\"\tconstruct(int newAbilityId)\");\n\t\t\tprintln(\"\t\tsuper(newAbilityId, '\"+spell+\"')\");\n\t\t\tfor (FieldData fd : specificData.get(spell)) {\n\t\t\t\tfd.printFunc(usedNames);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t\tFiles.write(sb, new File(\"./AbilityObjEditing.wurst\"), Charsets.UTF_8);\n\t}\n", "output": "\tpublic static void main(String[] args) throws IOException {\n\t\tList<FieldData> commonData = Lists.newArrayList();\n\t\tMultimap<String, FieldData> specificData = HashMultimap.create();\n\t\tFile metaData = new File(\"./AbilityMetaData.csv\");\n\t\tCsvReader reader = new CsvReader(new FileReader(metaData));\n\t\treader.readHeaders();\n\t\twhile (reader.readRecord()) {\n\t\t\tString id = reader.get(\"ID\");\n\t\t\tString displayName = strings.get(reader.get(\"displayName\"));\n\t\t\tif (displayName == null) {\n\t\t\t\tdisplayName = reader.get(\"field\");\n\t\t\t}\n\t\t\tString type = reader.get(\"type\");\n\t\t\tint data = Integer.parseInt(reader.get(\"data\"));\n\t\t\tboolean useLevels = !reader.get(\"repeat\").equals(\"0\");\n\t\t\tString useSpecific = reader.get(\"useSpecific\");\n\t\t\tFieldData fd = new FieldData(id, displayName, type, data, useLevels);\n\t\t\tif (useSpecific.isEmpty()) {\n\t\t\t\tcommonData.add(fd);\n\t\t\t} else {\n\t\t\t\tfor (String spell : useSpecific.split(\"[,\\\\.]\")) {\n\t\t\t\t\tspecificData.put(spell, fd);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintln(\"package AbilityObjEditing\");\n\t\tprintln(\"import public ObjEditingNatives\");\n\t\tprintln(\"\");\n\t\tprintln(\"public class AbilityDefinition\");\n\t\tprintln(\"\tprotected ObjectDefinition def\");\n\t\tprintln(\"\t\");\n\t\tprintln(\"\tconstruct(int newAbilityId, int origAbilityId)\");\n\t\tprintln(\"\t\tdef = createObjectDefinition(\\\"w3a\\\", newAbilityId, origAbilityId)\");\n\t\tSet<String> usedNames = Sets.newHashSet();\n\t\tfor (FieldData fd : commonData) {\n\t\t\tfd.printFunc(usedNames);\n\t\t}\n\t\tfor (String spell : specificData.keySet()) {\n\t\t\tusedNames.clear();\n\t\t\tprintln(\"\");\n\t\t\tprintln(\"\");\n\t\t\tprintln(\"\");\n\t\t\tString spellName = abilityNames.get(spell);\n\t\t\tprintln(\"public class AbilityDefinition\"+spellName+\" extends AbilityDefinition\");\n\t\t\tprintln(\"\tconstruct(int newAbilityId)\");\n\t\t\tprintln(\"\t\tsuper(newAbilityId, '\"+spell+\"')\");\n\t\t\tfor (FieldData fd : specificData.get(spell)) {\n\t\t\t\tfd.printFunc(usedNames);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t\tFiles.write(sb, new File(\"./AbilityObjEditing.wurst\"), Charsets.UTF_8);\n\t}\n"} {"input": " public void gpuMethod() {\n for (int i = 0; i < iterations; i++) {\n double x = 1;\n double y = 1;\n Result result = new Result();\n if ((Math.sqrt(x * x + y * y) < 1.0)) {\n result.hit = 1;\n } else {\n result.hit = 0;\n }\n resultList.add(result);\n }\n }\n", "output": " public void gpuMethod() {\n for (int i = 0; i < iterations; i++) {\n double x = 2.0 * Math.random() - 1.0; \n double y = 2.0 * Math.random() - 1.0; \n Result result = new Result();\n if ((Math.sqrt(x * x + y * y) < 1.0)) {\n result.hit = 1;\n } else {\n result.hit = 0;\n }\n resultList.add(result);\n }\n }\n"} {"input": "\tpublic int onStartCommand(Intent intent, int flags, int startId) {\n if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, \"Received start id \" + startId + \": \" + intent);\n if (intent == null) return START_NOT_STICKY;\n String action = intent.getAction();\n if (action == null) return START_NOT_STICKY;\n if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, \"Action: \" + action);\n final int stopId = startId;\n if (action.equals(ACTION_STARTUP))\n {\n\t\t\tNotification n = buildNotification(R.drawable.ic_notification, getResources().getString(R.string.service_running));\n \t\tstartForeground(1, n);\n \t\t_executor.execute(new Runnable() {\n \t public void run() {\n \t \t\tif (DaemonManager.getInstance().start(DaemonService.this) )\n \t \t\t{\n \t \t\tinvoke_state_changed_intent();\n \t \t\tupdateNeighborNotification();\n \t \t\t}\n \t \t\telse\n \t \t\t{\n \t \t\tinvoke_state_changed_intent();\n \t \t\tupdateNeighborNotification();\n \t \t\tstopSelfResult(stopId);\n \t \t\t}\n \t }\n \t\t});\n return START_STICKY;\n }\n else if (action.equals(ACTION_SHUTDOWN))\n {\n \t_executor.execute(new Runnable() {\n \t public void run() {\n \t \t\tDaemonManager.getInstance().stop();\n \t \t\tinvoke_state_changed_intent();\n \t \tstopForeground(true);\n \t \t\tNotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);\n \t \t\tnm.cancel(1);\n \t \t\tstopSelfResult(stopId);\n \t }\n \t\t});\n return START_STICKY;\n }\n\t\telse if (intent.getAction().equals(de.tubs.ibr.dtn.Intent.REGISTER))\n\t\t{\n\t\t\tfinal Registration reg = (Registration)intent.getParcelableExtra(\"registration\");\n\t\t\tfinal PendingIntent pi = (PendingIntent)intent.getParcelableExtra(\"app\");\n \t_executor.execute(new Runnable() {\n \t public void run() {\n \t \tDaemonManager.getInstance().getSessionManager().register(DaemonService.this, pi.getTargetPackage(), reg);\n \t \tif (!DaemonManager.getInstance().isRunning()) {\n\t \t \t\tstopSelfResult(stopId);\n \t \t}\n \t }\n \t\t});\n return START_STICKY;\n\t\t}\n\t\telse if (intent.getAction().equals(de.tubs.ibr.dtn.Intent.UNREGISTER))\n\t\t{\n\t\t\tfinal PendingIntent pi = (PendingIntent)intent.getParcelableExtra(\"app\");\n \t_executor.execute(new Runnable() {\n \t public void run() {\n \t \tDaemonManager.getInstance().getSessionManager().unregister(DaemonService.this, pi.getTargetPackage());\n \t \tif (!DaemonManager.getInstance().isRunning()) {\n\t \t \t\tstopSelfResult(stopId);\n \t \t}\n \t }\n \t\t});\n return START_STICKY;\n\t\t}\n\t\treturn START_NOT_STICKY;\n\t}\n", "output": "\tpublic int onStartCommand(Intent intent, int flags, int startId) {\n if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, \"Received start id \" + startId + \": \" + intent);\n if (intent == null) return START_NOT_STICKY;\n String action = intent.getAction();\n if (action == null) return START_NOT_STICKY;\n if (Log.isLoggable(TAG, Log.DEBUG)) Log.d(TAG, \"Action: \" + action);\n final int stopId = startId;\n if (action.equals(ACTION_STARTUP))\n {\n\t\t\tNotification n = buildNotification(R.drawable.ic_notification, getResources().getString(R.string.notify_no_neighbors));\n \t\tstartForeground(1, n);\n \t\t_executor.execute(new Runnable() {\n \t public void run() {\n \t \t\tif (DaemonManager.getInstance().start(DaemonService.this) )\n \t \t\t{\n \t \t\tinvoke_state_changed_intent();\n \t \t\tupdateNeighborNotification();\n \t \t\t}\n \t \t\telse\n \t \t\t{\n \t \t\tinvoke_state_changed_intent();\n \t \t\tupdateNeighborNotification();\n \t \t\tstopSelfResult(stopId);\n \t \t\t}\n \t }\n \t\t});\n return START_STICKY;\n }\n else if (action.equals(ACTION_SHUTDOWN))\n {\n \t_executor.execute(new Runnable() {\n \t public void run() {\n \t \t\tDaemonManager.getInstance().stop();\n \t \t\tinvoke_state_changed_intent();\n \t \tstopForeground(true);\n \t \t\tNotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);\n \t \t\tnm.cancel(1);\n \t \t\tstopSelfResult(stopId);\n \t }\n \t\t});\n return START_STICKY;\n }\n\t\telse if (intent.getAction().equals(de.tubs.ibr.dtn.Intent.REGISTER))\n\t\t{\n\t\t\tfinal Registration reg = (Registration)intent.getParcelableExtra(\"registration\");\n\t\t\tfinal PendingIntent pi = (PendingIntent)intent.getParcelableExtra(\"app\");\n \t_executor.execute(new Runnable() {\n \t public void run() {\n \t \tDaemonManager.getInstance().getSessionManager().register(DaemonService.this, pi.getTargetPackage(), reg);\n \t \tif (!DaemonManager.getInstance().isRunning()) {\n\t \t \t\tstopSelfResult(stopId);\n \t \t}\n \t }\n \t\t});\n return START_STICKY;\n\t\t}\n\t\telse if (intent.getAction().equals(de.tubs.ibr.dtn.Intent.UNREGISTER))\n\t\t{\n\t\t\tfinal PendingIntent pi = (PendingIntent)intent.getParcelableExtra(\"app\");\n \t_executor.execute(new Runnable() {\n \t public void run() {\n \t \tDaemonManager.getInstance().getSessionManager().unregister(DaemonService.this, pi.getTargetPackage());\n \t \tif (!DaemonManager.getInstance().isRunning()) {\n\t \t \t\tstopSelfResult(stopId);\n \t \t}\n \t }\n \t\t});\n return START_STICKY;\n\t\t}\n\t\treturn START_NOT_STICKY;\n\t}\n"} {"input": "\tprivate void doProperty(Tag tag) {\n\t\tString name = null;\n\t\ttry {\n\t\t\tname = tag.getAttribute(ATTR_NAME);\n\t\t\tif (name == null) {\n\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"The 'property' tag must have 'name' attribute set at line \" + tag.getLine());\n\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tString type = tag.getAttribute(ATTR_TYPE);\n\t\t\tint mtType;\n\t\t\tif (type == null || \"String\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.STRING;\n\t\t\t} else if (\"Boolean\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.BOOLEAN;\n\t\t\t} else if (\"Integer\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.INTEGER;\n\t\t\t} else if (\"Long\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.LONG;\n\t\t\t} else if (\"Char\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.CHARACTER;\n\t\t\t} else if (\"Double\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.DOUBLE;\n\t\t\t} else if (\"Float\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.FLOAT;\n\t\t\t} else if (\"Byte\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.BYTE;\n\t\t\t} else if (\"Short\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.SHORT;\n\t\t\t} else {\n\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"Illegal property type '\" + type + \"' on line \" + tag.getLine());\n\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tString value = tag.getAttribute(ATTR_VALUE);\n\t\t\tObject _value;\n\t\t\tif (value != null) {\n\t\t\t\t_value = makeObject(value, mtType);\n\t\t\t} else {\n\t\t\t\tvalue = tag.getContent();\n\t\t\t\tif (value == null) {\n\t\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"The 'property' tag must have body content if 'value' attribute is not specified!\");\n\t\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tStringTokenizer tok = new StringTokenizer(value, \"\\n\\r\");\n\t\t\t\tVector el = new Vector(10);\n\t\t\t\twhile (tok.hasMoreTokens()) {\n\t\t\t\t\tString next = tok.nextToken().trim();\n\t\t\t\t\tif (next.length() > 0) {\n\t\t\t\t\t\tel.addElement(next);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (el.size() == 0) {\n\t\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"The 'property' tag must have body content if 'value' attribute is not specified!\");\n\t\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tString[] values = new String[el.size()];\n\t\t\t\tel.copyInto(values);\n\t\t\t\t_value = makeArr(values, mtType);\n\t\t\t}\n\t\t\tif (currentComponent.properties == null) {\n\t\t\t\tcurrentComponent.properties = new Properties();\n\t\t\t}\n\t\t\tcurrentComponent.properties.put(name, _value);\n\t\t} catch (Throwable e) {\n\t\t\tActivator.log.error(\"[SCR - DeclarationParser.doProperty()] Error while processing property \" + name, e);\n\t\t}\n\t}\n", "output": "\tprivate void doProperty(Tag tag) {\n\t\tString name = null;\n\t\ttry {\n\t\t\tname = tag.getAttribute(ATTR_NAME);\n\t\t\tif (name == null) {\n\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"The 'property' tag must have 'name' attribute set at line \" + tag.getLine());\n\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tString type = tag.getAttribute(ATTR_TYPE);\n\t\t\tint mtType;\n\t\t\tif (type == null || \"String\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.STRING;\n\t\t\t} else if (\"Boolean\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.BOOLEAN;\n\t\t\t} else if (\"Integer\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.INTEGER;\n\t\t\t} else if (\"Long\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.LONG;\n\t\t\t} else if (\"Char\".equals(type) || \"Character\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.CHARACTER;\n\t\t\t} else if (\"Double\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.DOUBLE;\n\t\t\t} else if (\"Float\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.FLOAT;\n\t\t\t} else if (\"Byte\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.BYTE;\n\t\t\t} else if (\"Short\".equals(type)) {\n\t\t\t\tmtType = AttributeDefinition.SHORT;\n\t\t\t} else {\n\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"Illegal property type '\" + type + \"' on line \" + tag.getLine());\n\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tString value = tag.getAttribute(ATTR_VALUE);\n\t\t\tObject _value;\n\t\t\tif (value != null) {\n\t\t\t\t_value = makeObject(value, mtType);\n\t\t\t} else {\n\t\t\t\tvalue = tag.getContent();\n\t\t\t\tif (value == null) {\n\t\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"The 'property' tag must have body content if 'value' attribute is not specified!\");\n\t\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tStringTokenizer tok = new StringTokenizer(value, \"\\n\\r\");\n\t\t\t\tVector el = new Vector(10);\n\t\t\t\twhile (tok.hasMoreTokens()) {\n\t\t\t\t\tString next = tok.nextToken().trim();\n\t\t\t\t\tif (next.length() > 0) {\n\t\t\t\t\t\tel.addElement(next);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (el.size() == 0) {\n\t\t\t\t\tIllegalArgumentException e = new IllegalArgumentException(\"The 'property' tag must have body content if 'value' attribute is not specified!\");\n\t\t\t\t\tActivator.log.error(\"[SCR] \" + e.getMessage(), e);\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t\tString[] values = new String[el.size()];\n\t\t\t\tel.copyInto(values);\n\t\t\t\t_value = makeArr(values, mtType);\n\t\t\t}\n\t\t\tif (currentComponent.properties == null) {\n\t\t\t\tcurrentComponent.properties = new Properties();\n\t\t\t}\n\t\t\tcurrentComponent.properties.put(name, _value);\n\t\t} catch (Throwable e) {\n\t\t\tActivator.log.error(\"[SCR - DeclarationParser.doProperty()] Error while processing property \" + name, e);\n\t\t}\n\t}\n"} {"input": " public void afterPropertiesSet() throws Exception {\n if (recreateDb) {\n if(\"create_oracle.sql\".equals(createSql)) {\n LOG.warning(\"Not recomended to use db.recreate=true parameter for Oracle database\");\n }\n ScriptRunner sr = new ScriptRunner(dataSource.getConnection(), true, false);\n sr.setLogWriter(null);\n sr.setErrorLogWriter(null);\n sr.runScript(new InputStreamReader(this.getClass().getResourceAsStream(\"/\" + createSql)));\n }\n }\n", "output": " public void afterPropertiesSet() throws Exception {\n if (recreateDb) {\n if(\"create_oracle.sql\".equals(createSql)) {\n LOG.warning(\"Not recomended to use db.recreate=true parameter for Oracle database\");\n }\n ScriptRunner sr = new ScriptRunner(dataSource.getConnection(), false, false);\n sr.setLogWriter(null);\n sr.setErrorLogWriter(null);\n sr.runScript(new InputStreamReader(this.getClass().getResourceAsStream(\"/\" + createSql)));\n }\n }\n"} {"input": "\tpublic static Result UpdateSubscriptionStatus(){\n\t\tJsonNode json = request().body().asJson();\n\t\tString entityType = json.get(\"entityType\").asText();\n\t\tString entityId = json.get(\"entityId\").asText();\n\t\tString username = json.get(\"username\").asText();\n\t\tObjectNode result = Json.newObject();\n\t\tresult.put(\"newState\", \"true\");\n\t\t", "output": "\tpublic static Result UpdateSubscriptionStatus(){\n\t\tJsonNode json = request().body().asJson();\n\t\tString entityType = json.get(\"entityType\").asText();\n\t\tString entityId = json.get(\"entityId\").asText();\n\t\tString username = json.get(\"username\").asText();\n\t\tUser user = User.findByName(username);\n\t\tObjectNode result = Json.newObject();\n\t\tresult.put(\"newState\", \"true\");\n\t\t"} {"input": "\tpublic boolean startElementHandler(String tag, ZLStringMap xmlattributes) {\n\t\ttag = tag.toLowerCase();\n\t\tif (myOPFSchemePrefix != null && tag.startsWith(myOPFSchemePrefix)) {\n\t\t\ttag = tag.substring(myOPFSchemePrefix.length());\n\t\t}\n\t\ttag = tag.intern();\n\t\tif (MANIFEST == tag) {\n\t\t\tmyState = READ_MANIFEST;\n\t\t} else if (SPINE == tag) {\n\t\t\tmyNCXTOCFileName = myIdToHref.get(xmlattributes.getValue(\"toc\"));\n\t\t\tmyState = READ_SPINE;\n\t\t} else if (GUIDE == tag) {\n\t\t\tmyState = READ_GUIDE;\n\t\t} else if (TOUR == tag) {\n\t\t\tmyState = READ_TOUR;\n\t\t} else if (myState == READ_MANIFEST && ITEM == tag) {\n\t\t\tfinal String id = xmlattributes.getValue(\"id\");\n\t\t\tString href = xmlattributes.getValue(\"href\");\n\t\t\tif ((id != null) && (href != null)) {\n\t\t\t\thref = MiscUtil.decodeHtmlReference(href);\n\t\t\t\tmyIdToHref.put(id, href);\n\t\t\t}\n\t\t} else if (myState == READ_SPINE && ITEMREF == tag) {\n\t\t\tfinal String id = xmlattributes.getValue(\"idref\");\n\t\t\tif (id != null) {\n\t\t\t\tfinal String fileName = myIdToHref.get(id);\n\t\t\t\tif (fileName != null) {\n\t\t\t\t\tmyHtmlFileNames.add(fileName);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (myState == READ_GUIDE && REFERENCE == tag) {\n\t\t\tfinal String type = xmlattributes.getValue(\"type\");\n\t\t\tfinal String title = xmlattributes.getValue(\"title\");\n\t\t\tString href = xmlattributes.getValue(\"href\");\n\t\t\tif (href != null) {\n\t\t\t\thref = MiscUtil.decodeHtmlReference(href);\n\t\t\t\tif (title != null) {\n\t\t\t\t\tmyGuideTOC.add(new Reference(title, href));\n\t\t\t\t}\n\t\t\t\tif (COVER.equals(type)) {\n\t\t\t\t\tfinal ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href);\n\t\t\t\t\tmyCoverFileName = imageFile.getPath();\n\t\t\t\t\tfinal String imageName = imageFile.getLongName();\n\t\t\t\t\tfinal ZLFileImage image = XHTMLImageFinder.getCoverImage(imageFile);\n\t\t\t\t\tif (image != null) {\n\t\t\t\t\t\tmyModelReader.setMainTextModel();\n\t\t\t\t\t\tmyModelReader.addImageReference(imageName, (short)0, true);\n\t\t\t\t\t\tmyModelReader.addImage(imageName, image);\n\t\t\t\t\t\tmyModelReader.insertEndOfSectionParagraph();\n\t\t\t\t\t}\n\t\t\t\t} else if (COVER_IMAGE.equals(type)) {\n\t\t\t\t\tfinal ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href);\n\t\t\t\t\tmyCoverFileName = imageFile.getPath();\n\t\t\t\t\tfinal String imageName = imageFile.getLongName();\n\t\t\t\t\tmyModelReader.setMainTextModel();\n\t\t\t\t\tmyModelReader.addImageReference(imageName, (short)0, true);\n\t\t\t\t\tmyModelReader.addImage(imageName, new ZLFileImage(MimeType.IMAGE_AUTO, imageFile));\n\t\t\t\t\tmyModelReader.insertEndOfSectionParagraph();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (myState == READ_TOUR && SITE == tag) {\n\t\t\tfinal String title = xmlattributes.getValue(\"title\");\n\t\t\tString href = xmlattributes.getValue(\"href\");\n\t\t\tif ((title != null) && (href != null)) {\n\t\t\t\thref = MiscUtil.decodeHtmlReference(href);\n\t\t\t\tmyTourTOC.add(new Reference(title, href));\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean startElementHandler(String tag, ZLStringMap xmlattributes) {\n\t\ttag = tag.toLowerCase();\n\t\tif (myOPFSchemePrefix != null && tag.startsWith(myOPFSchemePrefix)) {\n\t\t\ttag = tag.substring(myOPFSchemePrefix.length());\n\t\t}\n\t\ttag = tag.intern();\n\t\tif (MANIFEST == tag) {\n\t\t\tmyState = READ_MANIFEST;\n\t\t} else if (SPINE == tag) {\n\t\t\tmyNCXTOCFileName = myIdToHref.get(xmlattributes.getValue(\"toc\"));\n\t\t\tmyState = READ_SPINE;\n\t\t} else if (GUIDE == tag) {\n\t\t\tmyState = READ_GUIDE;\n\t\t} else if (TOUR == tag) {\n\t\t\tmyState = READ_TOUR;\n\t\t} else if (myState == READ_MANIFEST && ITEM == tag) {\n\t\t\tfinal String id = xmlattributes.getValue(\"id\");\n\t\t\tString href = xmlattributes.getValue(\"href\");\n\t\t\tif ((id != null) && (href != null)) {\n\t\t\t\thref = MiscUtil.decodeHtmlReference(href);\n\t\t\t\tmyIdToHref.put(id, href);\n\t\t\t}\n\t\t} else if (myState == READ_SPINE && ITEMREF == tag) {\n\t\t\tfinal String id = xmlattributes.getValue(\"idref\");\n\t\t\tif (id != null) {\n\t\t\t\tfinal String fileName = myIdToHref.get(id);\n\t\t\t\tif (fileName != null) {\n\t\t\t\t\tmyHtmlFileNames.add(fileName);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (myState == READ_GUIDE && REFERENCE == tag) {\n\t\t\tfinal String type = xmlattributes.getValue(\"type\");\n\t\t\tfinal String title = xmlattributes.getValue(\"title\");\n\t\t\tString href = xmlattributes.getValue(\"href\");\n\t\t\tif (href != null) {\n\t\t\t\thref = MiscUtil.decodeHtmlReference(href);\n\t\t\t\tif (title != null) {\n\t\t\t\t\tmyGuideTOC.add(new Reference(title, href));\n\t\t\t\t}\n\t\t\t\tif (COVER.equals(type)) {\n\t\t\t\t\tfinal ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href);\n\t\t\t\t\tmyCoverFileName = imageFile.getPath();\n\t\t\t\t\tfinal String imageName = imageFile.getLongName();\n\t\t\t\t\tfinal ZLFileImage image = XHTMLImageFinder.getCoverImage(imageFile);\n\t\t\t\t\tif (image != null) {\n\t\t\t\t\t\tmyModelReader.setMainTextModel();\n\t\t\t\t\t\tmyModelReader.addImageReference(imageName, (short)0, true);\n\t\t\t\t\t\tmyModelReader.addImage(imageName, image);\n\t\t\t\t\t\tmyModelReader.insertEndOfSectionParagraph();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmyCoverFileName = null;\n\t\t\t\t\t}\n\t\t\t\t} else if (COVER_IMAGE.equals(type)) {\n\t\t\t\t\tfinal ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href);\n\t\t\t\t\tmyCoverFileName = imageFile.getPath();\n\t\t\t\t\tfinal String imageName = imageFile.getLongName();\n\t\t\t\t\tmyModelReader.setMainTextModel();\n\t\t\t\t\tmyModelReader.addImageReference(imageName, (short)0, true);\n\t\t\t\t\tmyModelReader.addImage(imageName, new ZLFileImage(MimeType.IMAGE_AUTO, imageFile));\n\t\t\t\t\tmyModelReader.insertEndOfSectionParagraph();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (myState == READ_TOUR && SITE == tag) {\n\t\t\tfinal String title = xmlattributes.getValue(\"title\");\n\t\t\tString href = xmlattributes.getValue(\"href\");\n\t\t\tif ((title != null) && (href != null)) {\n\t\t\t\thref = MiscUtil.decodeHtmlReference(href);\n\t\t\t\tmyTourTOC.add(new Reference(title, href));\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": "\tpublic JComponent build() {\n\t\tFormLayout layout = new FormLayout(\n \"left:pref, 50dlu, pref, 150dlu, pref, 25dlu, pref, 0:grow\", \n \"p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 15dlu, fill:default:grow\"); \n PanelBuilder builder = new PanelBuilder(layout);\n builder.setBorder(Borders.DLU4_BORDER);\n builder.setOpaque(true);\n CellConstraints cc = new CellConstraints();\n df = new DefaultListModel();\n if (PMS.getConfiguration().getFolders() != null && PMS.getConfiguration().getFolders().length() > 0) {\n \t try {\n\t\t\tFile f [] = PMS.get().loadFoldersConf(PMS.getConfiguration().getFolders());\n\t\t\tfor(File file:f) {\n\t\t\t\tdf.addElement(file.getAbsolutePath());\n\t\t\t}\n\t\t\tif (f == null || f.length == 0) {\n\t\t\t\tdf.addElement(ALL_DRIVES);\n\t\t\t}\n\t\t} catch (IOException e1) {\n\t\t\tPMS.error(null, e1);\n\t\t}\n } else\n\t\tdf.addElement(ALL_DRIVES);\n\t\tFList = new JList();\n\t\tFList.setModel(df);\n JScrollPane pane = new JScrollPane(FList);\n JComponent cmp = builder.addSeparator(Messages.getString(\"FoldTab.13\"), cc.xyw(1, 1, 8)); \n cmp = (JComponent) cmp.getComponent(0);\n cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));\n tncheckBox = new JCheckBox(Messages.getString(\"NetworkTab.2\")); \n tncheckBox.setContentAreaFilled(false);\n tncheckBox.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setThumbnailsEnabled((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t}\n });\n if (PMS.getConfiguration().getThumbnailsEnabled())\n \ttncheckBox.setSelected(true);\n builder.add(tncheckBox, cc.xyw(1, 3, 3));\n seekpos = new JTextField(\"\" + configuration.getThumbnailSeekPos()); \n seekpos.addKeyListener(new KeyListener() {\n \t\t@Override\n \t\tpublic void keyPressed(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyTyped(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyReleased(KeyEvent e) {\n \t\t\ttry {\n \t\t\t\tint ab = Integer.parseInt(seekpos.getText());\n \t\t\t\tconfiguration.setThumbnailSeekPos(ab);\n \t\t\t} catch (NumberFormatException nfe) {\n \t\t\t}\n \t\t}\n });\n builder.addLabel(Messages.getString(\"NetworkTab.16\"), cc.xyw(4, 3, 3)); \n builder.add(seekpos, cc.xyw(6, 3, 2));\n mplayer_thumb = new JCheckBox(Messages.getString(\"FoldTab.14\")); \n mplayer_thumb.setContentAreaFilled(false);\n mplayer_thumb.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setUseMplayerForVideoThumbs((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t}\n });\n if (PMS.getConfiguration().isUseMplayerForVideoThumbs())\n \tmplayer_thumb.setSelected(true);\n builder.add(mplayer_thumb, cc.xyw(1, 5, 5));\n final KeyedComboBoxModel thumbKCBM = new KeyedComboBoxModel(new Object[] { \"0\", \"1\", \"2\" }, new Object[] { Messages.getString(\"FoldTab.15\"), Messages.getString(\"FoldTab.23\"), Messages.getString(\"FoldTab.24\") }); \n audiothumbnail = new JComboBox(thumbKCBM);\n audiothumbnail.setEditable(false);\n thumbKCBM.setSelectedKey(\"\" + configuration.getAudioThumbnailMethod()); \n audiothumbnail.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tif (e.getStateChange() == ItemEvent.SELECTED) {\n \t\t\t\t\ttry {\n \t\t\t\t\t\tconfiguration.setAudioThumbnailMethod(Integer.parseInt((String) thumbKCBM.getSelectedKey()));\n \t\t\t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t\t\t} catch (NumberFormatException nfe) {}\n \t\t\t\t}\n \t\t\t}\n });\n builder.addLabel(Messages.getString(\"FoldTab.26\"), cc.xyw(1,7,3)); \n builder.add(audiothumbnail, cc.xyw(4, 7,4));\n builder.addLabel(Messages.getString(\"FoldTab.27\"), cc.xyw(1, 9, 3)); \n defaultThumbFolder = new JTextField(configuration.getAlternateThumbFolder());\n defaultThumbFolder.addKeyListener(new KeyListener() {\n \t\t@Override\n \t\tpublic void keyPressed(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyTyped(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyReleased(KeyEvent e) {\n \t\t\tconfiguration.setAlternateThumbFolder(defaultThumbFolder.getText());\n \t\t}\n });\n builder.add(defaultThumbFolder, cc.xyw(4, 9, 3));\n JButton select = new JButton(\"...\"); \n select.addActionListener(new ActionListener() {\n \t\t\t@Override\n \t\t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\t\tJFileChooser chooser = null;\n\t\t\t\ttry {\n\t\t\t\t\t chooser = new JFileChooser();\n\t\t\t\t} catch (Exception ee) {\n\t\t\t\t\t chooser = new JFileChooser(new RestrictedFileSystemView());\n\t\t\t\t}\n\t\t\t\tchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\n\t\t\t\tint returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString(\"FoldTab.28\")); \n \t\t\t if(returnVal == JFileChooser.APPROVE_OPTION) {\n \t\t\t \tdefaultThumbFolder.setText(chooser.getSelectedFile().getAbsolutePath());\n \t\t\t \tPMS.get().getFrame().setReloadable(true);\n \t\t\t \tconfiguration.setAlternateThumbFolder(chooser.getSelectedFile().getAbsolutePath());\n \t\t\t }\n \t\t\t}\n \t });\n \t builder.add(select, cc.xyw(7, 9, 1));\n cmp = builder.addSeparator(Messages.getString(\"NetworkTab.15\"), cc.xyw(1, 11, 8)); \n cmp = (JComponent) cmp.getComponent(0);\n cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));\n hidevideosettings = new JCheckBox(Messages.getString(\"FoldTab.6\")); \n hidevideosettings.setContentAreaFilled(false);\n if (PMS.getConfiguration().getHideVideoSettings())\n \thidevideosettings.setSelected(true);\n hidevideosettings.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setHideVideoSettings((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n archive = new JCheckBox(Messages.getString(\"NetworkTab.1\")); \n archive.setContentAreaFilled(false);\n archive.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setArchiveBrowsing(e.getStateChange() == ItemEvent.SELECTED);\n \t\t\t\tif (PMS.get().getFrame() != null)\n \t\t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n if (PMS.getConfiguration().isArchiveBrowsing())\n \t archive.setSelected(true);\n builder.add(archive, cc.xyw(1, 13, 3));\n final JButton cachereset = new JButton(Messages.getString(\"NetworkTab.18\")); \n cacheenable = new JCheckBox(Messages.getString(\"NetworkTab.17\")); \n cacheenable.setContentAreaFilled(false);\n cacheenable.setSelected(PMS.getConfiguration().getUseCache());\n cacheenable.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setUseCache((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tcachereset.setEnabled(PMS.getConfiguration().getUseCache());\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t\tif ((LooksFrame) PMS.get().getFrame() != null)\n \t\t\t\t\t((LooksFrame) PMS.get().getFrame()).getFt().setScanLibraryEnabled(PMS.getConfiguration().getUseCache());\n \t\t\t}\n });\n \t builder.add(cacheenable, cc.xy(1, 19));\n \t cachereset.addActionListener(new ActionListener() {\n \t\t\t@Override\n \t\t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\t\tint option = JOptionPane.showConfirmDialog(\n \t (Component) PMS.get().getFrame(),\n \t Messages.getString(\"NetworkTab.13\") + \n \t Messages.getString(\"NetworkTab.19\"), \n \t \"Question\", \n \t JOptionPane.YES_NO_OPTION\n \t );\n \t\t\t\tif (option == JOptionPane.YES_OPTION) {\n \t\t\t\t\tPMS.get().getDatabase().init(true);\n \t\t\t\t}\n \t\t\t}\n \t });\n \t builder.add(cachereset, cc.xyw(4, 19, 4));\n \t cachereset.setEnabled(PMS.getConfiguration().getUseCache());\n builder.add(hidevideosettings, cc.xyw(4, 13, 3));\n hideextensions = new JCheckBox(Messages.getString(\"FoldTab.5\")); \n hideextensions.setContentAreaFilled(false);\n if (PMS.getConfiguration().isHideExtensions())\n \thideextensions.setSelected(true);\n hideextensions.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setHideExtensions((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n builder.add(hideextensions, cc.xyw(1, 15, 3));\n hideengines = new JCheckBox(Messages.getString(\"FoldTab.8\")); \n hideengines.setContentAreaFilled(false);\n if (PMS.getConfiguration().isHideEngineNames())\n \thideengines.setSelected(true);\n hideengines.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setHideEngineNames((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n builder.add(hideengines, cc.xyw(4, 15, 3));\n \titunes = new JCheckBox(Messages.getString(\"FoldTab.30\")); \n itunes.setContentAreaFilled(false);\n if (PMS.getConfiguration().getItunesEnabled())\n \titunes.setSelected(true);\n if (!Platform.isMac())\n\t iphoto.setEnabled(false);\n itunes.addItemListener(new ItemListener() {\n \t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\tPMS.getConfiguration().setItunesEnabled((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t}\n });\n builder.add(itunes, cc.xyw(1, 17, 3));\n \tiphoto = new JCheckBox(Messages.getString(\"FoldTab.29\")); \n iphoto.setContentAreaFilled(false);\n if (PMS.getConfiguration().getIphotoEnabled())\n \tiphoto.setSelected(true);\n if (!Platform.isMac())\n\t iphoto.setEnabled(false);\n\tiphoto.addItemListener(new ItemListener() {\n \t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\tPMS.getConfiguration().setIphotoEnabled((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t}\t\n });\n builder.add(iphoto, cc.xyw(4, 17, 3));\n final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(new Object[] { \"0\", \"1\" }, new Object[] { Messages.getString(\"FoldTab.15\"), Messages.getString(\"FoldTab.16\") }); \n sortmethod = new JComboBox(kcbm);\n sortmethod.setEditable(false);\n kcbm.setSelectedKey(\"\" + configuration.getSortMethod()); \n sortmethod.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tif (e.getStateChange() == ItemEvent.SELECTED) {\n \t\t\t\t\ttry {\n \t\t\t\t\t\tconfiguration.setSortMethod(Integer.parseInt((String) kcbm.getSelectedKey()));\n \t\t\t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t\t\t} catch (NumberFormatException nfe) {}\n \t\t\t\t}\n \t\t\t}\n });\n builder.addLabel(Messages.getString(\"FoldTab.18\"), cc.xyw(1,21,3)); \n builder.add(sortmethod, cc.xyw(4, 21,4));\n FormLayout layoutFolders = new FormLayout(\n \"left:pref, left:pref, pref, pref, pref, 0:grow\", \n \"p, 3dlu, p, 3dlu, fill:default:grow\"); \n PanelBuilder builderFolder = new PanelBuilder(layoutFolders);\n builderFolder.setOpaque(true);\n cmp = builderFolder.addSeparator(Messages.getString(\"FoldTab.7\"), cc.xyw(1, 1,6)); \n cmp = (JComponent) cmp.getComponent(0);\n cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));\n JButton but = new JButton(LooksFrame.readImageIcon(\"folder_new-32.png\")); \n but.addActionListener(new java.awt.event.ActionListener() {\n\t\t\tpublic void actionPerformed(java.awt.event.ActionEvent e) {\n\t\t\t\tJFileChooser chooser = null;\n\t\t\t\ttry {\n\t\t\t\t\t chooser = new JFileChooser();\n\t\t\t\t} catch (Exception ee) {\n\t\t\t\t\t chooser = new JFileChooser(new RestrictedFileSystemView());\n\t\t\t\t}\n\t\t\t\tchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\n\t\t\t\tint returnVal = chooser.showOpenDialog((Component) e.getSource());\n\t\t\t if(returnVal == JFileChooser.APPROVE_OPTION) {\n\t\t\t \t((DefaultListModel) FList.getModel()).add(FList.getModel().getSize(),chooser.getSelectedFile().getAbsolutePath());\n\t\t\t \tif (FList.getModel().getElementAt(0).equals(ALL_DRIVES))\n\t\t\t \t\t((DefaultListModel) FList.getModel()).remove(0);\n\t\t\t \tupdateModel();\n\t\t\t }\n\t\t\t}\n\t\t});\n builderFolder.add(but, cc.xy(1, 3));\n JButton but2 = new JButton(LooksFrame.readImageIcon(\"button_cancel-32.png\")); \n but2.addActionListener(new java.awt.event.ActionListener() {\n\t\t\tpublic void actionPerformed(java.awt.event.ActionEvent e) {\n\t\t\t\tif (FList.getSelectedIndex() > -1) {\n\t\t\t\t\t((DefaultListModel) FList.getModel()).remove(FList.getSelectedIndex());\n\t\t\t\t\tif (FList.getModel().getSize() == 0)\n\t\t\t \t\t((DefaultListModel) FList.getModel()).add(0, ALL_DRIVES);\n\t\t\t\t\tupdateModel();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n builderFolder.add(but2, cc.xy(2, 3));\n JButton but3 = new JButton(LooksFrame.readImageIcon(\"kdevelop_down-32.png\")); \n but3.setToolTipText(Messages.getString(\"FoldTab.12\")); \n but3.addActionListener(new ActionListener() {\n\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\tDefaultListModel model = ((DefaultListModel) FList.getModel());\n\t\t\tfor(int i=0;i<model.size()-1;i++) {\n\t\t\t\tif (FList.isSelectedIndex(i)) {\n\t\t\t\t\tString value = model.get(i).toString();\n\t\t\t\t\tmodel.set(i, model.get(i+1));\n\t\t\t\t\tmodel.set(i+1, value);\n\t\t\t\t\tFList.setSelectedIndex(i+1);\n\t\t\t\t\tupdateModel();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} \t \n });\n builderFolder.add(but3, cc.xy(3, 3));\n JButton but4 = new JButton(LooksFrame.readImageIcon(\"up-32.png\")); \n but4.setToolTipText(Messages.getString(\"FoldTab.12\")); \n but4.addActionListener(new ActionListener() {\n \t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\tDefaultListModel model = ((DefaultListModel) FList.getModel());\n \t\t\tfor(int i=1;i<model.size();i++) {\n \t\t\t\tif (FList.isSelectedIndex(i)) {\n \t\t\t\t\tString value = model.get(i).toString();\n \t\t\t\t\tmodel.set(i, model.get(i-1));\n \t\t\t\t\tmodel.set(i-1, value);\n \t\t\t\t\tFList.setSelectedIndex(i-1);\n \t\t\t\t\tupdateModel();\n \t\t\t\t\tbreak;\n \t\t\t\t}\n \t\t\t}\n \t\t} \t \n });\n builderFolder.add(but4, cc.xy(4, 3));\n but5 = new JButton(LooksFrame.readImageIcon(\"search-32.png\")); \n but5.setToolTipText(Messages.getString(\"FoldTab.2\")); \n but5.addActionListener(new ActionListener() {\n \t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\tif (PMS.getConfiguration().getUseCache()) {\n \t\t\t\tif (!PMS.get().getDatabase().isScanLibraryRunning()) {\n\t \t\t\t\tint option = JOptionPane.showConfirmDialog(\n\t \t (Component) PMS.get().getFrame(),\n\t \t Messages.getString(\"FoldTab.3\") + \n\t \t Messages.getString(\"FoldTab.4\"), \n\t \t \"Question\", \n\t \t JOptionPane.YES_NO_OPTION\n\t \t );\n\t \t\t\t\tif (option == JOptionPane.YES_OPTION) {\n\t \t\t\t\t\tPMS.get().getDatabase().scanLibrary();\n\t \t\t\t\t\tbut5.setIcon(LooksFrame.readImageIcon(\"viewmagfit-32.png\")); \n\t \t\t\t\t}\n \t\t\t\t} else {\n \t\t\t\t\tint option = JOptionPane.showConfirmDialog(\n\t \t (Component) PMS.get().getFrame(),\n\t \t Messages.getString(\"FoldTab.10\"), \n\t \t \"Question\", \n\t \t JOptionPane.YES_NO_OPTION\n\t \t );\n\t \t\t\t\tif (option == JOptionPane.YES_OPTION) {\n\t \t\t\t\t\tPMS.get().getDatabase().stopScanLibrary();\n\t \t\t\t\t\tPMS.get().getFrame().setStatusLine(null);\n\t \t\t\t\t\tbut5.setIcon(LooksFrame.readImageIcon(\"search-32.png\")); \n\t \t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t} \t \n });\n builderFolder.add(but5, cc.xy(5, 3));\n but5.setEnabled(PMS.getConfiguration().getUseCache());\n builderFolder.add(pane, cc.xyw(1, 5,6));\n builder.add(builderFolder.getPanel(), cc.xyw(1, 25, 8));\n return builder.getPanel();\n\t}\n", "output": "\tpublic JComponent build() {\n\t\tFormLayout layout = new FormLayout(\n \"left:pref, 50dlu, pref, 150dlu, pref, 25dlu, pref, 0:grow\", \n \"p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 15dlu, fill:default:grow\"); \n PanelBuilder builder = new PanelBuilder(layout);\n builder.setBorder(Borders.DLU4_BORDER);\n builder.setOpaque(true);\n CellConstraints cc = new CellConstraints();\n df = new DefaultListModel();\n if (PMS.getConfiguration().getFolders() != null && PMS.getConfiguration().getFolders().length() > 0) {\n \t try {\n\t\t\tFile f [] = PMS.get().loadFoldersConf(PMS.getConfiguration().getFolders());\n\t\t\tfor(File file:f) {\n\t\t\t\tdf.addElement(file.getAbsolutePath());\n\t\t\t}\n\t\t\tif (f == null || f.length == 0) {\n\t\t\t\tdf.addElement(ALL_DRIVES);\n\t\t\t}\n\t\t} catch (IOException e1) {\n\t\t\tPMS.error(null, e1);\n\t\t}\n } else\n\t\tdf.addElement(ALL_DRIVES);\n\t\tFList = new JList();\n\t\tFList.setModel(df);\n JScrollPane pane = new JScrollPane(FList);\n JComponent cmp = builder.addSeparator(Messages.getString(\"FoldTab.13\"), cc.xyw(1, 1, 8)); \n cmp = (JComponent) cmp.getComponent(0);\n cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));\n tncheckBox = new JCheckBox(Messages.getString(\"NetworkTab.2\")); \n tncheckBox.setContentAreaFilled(false);\n tncheckBox.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setThumbnailsEnabled((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t}\n });\n if (PMS.getConfiguration().getThumbnailsEnabled())\n \ttncheckBox.setSelected(true);\n builder.add(tncheckBox, cc.xyw(1, 3, 3));\n seekpos = new JTextField(\"\" + configuration.getThumbnailSeekPos()); \n seekpos.addKeyListener(new KeyListener() {\n \t\t@Override\n \t\tpublic void keyPressed(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyTyped(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyReleased(KeyEvent e) {\n \t\t\ttry {\n \t\t\t\tint ab = Integer.parseInt(seekpos.getText());\n \t\t\t\tconfiguration.setThumbnailSeekPos(ab);\n \t\t\t} catch (NumberFormatException nfe) {\n \t\t\t}\n \t\t}\n });\n builder.addLabel(Messages.getString(\"NetworkTab.16\"), cc.xyw(4, 3, 3)); \n builder.add(seekpos, cc.xyw(6, 3, 2));\n mplayer_thumb = new JCheckBox(Messages.getString(\"FoldTab.14\")); \n mplayer_thumb.setContentAreaFilled(false);\n mplayer_thumb.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setUseMplayerForVideoThumbs((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t}\n });\n if (PMS.getConfiguration().isUseMplayerForVideoThumbs())\n \tmplayer_thumb.setSelected(true);\n builder.add(mplayer_thumb, cc.xyw(1, 5, 5));\n final KeyedComboBoxModel thumbKCBM = new KeyedComboBoxModel(new Object[] { \"0\", \"1\", \"2\" }, new Object[] { Messages.getString(\"FoldTab.15\"), Messages.getString(\"FoldTab.23\"), Messages.getString(\"FoldTab.24\") }); \n audiothumbnail = new JComboBox(thumbKCBM);\n audiothumbnail.setEditable(false);\n thumbKCBM.setSelectedKey(\"\" + configuration.getAudioThumbnailMethod()); \n audiothumbnail.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tif (e.getStateChange() == ItemEvent.SELECTED) {\n \t\t\t\t\ttry {\n \t\t\t\t\t\tconfiguration.setAudioThumbnailMethod(Integer.parseInt((String) thumbKCBM.getSelectedKey()));\n \t\t\t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t\t\t} catch (NumberFormatException nfe) {}\n \t\t\t\t}\n \t\t\t}\n });\n builder.addLabel(Messages.getString(\"FoldTab.26\"), cc.xyw(1,7,3)); \n builder.add(audiothumbnail, cc.xyw(4, 7,4));\n builder.addLabel(Messages.getString(\"FoldTab.27\"), cc.xyw(1, 9, 3)); \n defaultThumbFolder = new JTextField(configuration.getAlternateThumbFolder());\n defaultThumbFolder.addKeyListener(new KeyListener() {\n \t\t@Override\n \t\tpublic void keyPressed(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyTyped(KeyEvent e) {}\n \t\t@Override\n \t\tpublic void keyReleased(KeyEvent e) {\n \t\t\tconfiguration.setAlternateThumbFolder(defaultThumbFolder.getText());\n \t\t}\n });\n builder.add(defaultThumbFolder, cc.xyw(4, 9, 3));\n JButton select = new JButton(\"...\"); \n select.addActionListener(new ActionListener() {\n \t\t\t@Override\n \t\t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\t\tJFileChooser chooser = null;\n\t\t\t\ttry {\n\t\t\t\t\t chooser = new JFileChooser();\n\t\t\t\t} catch (Exception ee) {\n\t\t\t\t\t chooser = new JFileChooser(new RestrictedFileSystemView());\n\t\t\t\t}\n\t\t\t\tchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\n\t\t\t\tint returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString(\"FoldTab.28\")); \n \t\t\t if(returnVal == JFileChooser.APPROVE_OPTION) {\n \t\t\t \tdefaultThumbFolder.setText(chooser.getSelectedFile().getAbsolutePath());\n \t\t\t \tPMS.get().getFrame().setReloadable(true);\n \t\t\t \tconfiguration.setAlternateThumbFolder(chooser.getSelectedFile().getAbsolutePath());\n \t\t\t }\n \t\t\t}\n \t });\n \t builder.add(select, cc.xyw(7, 9, 1));\n cmp = builder.addSeparator(Messages.getString(\"NetworkTab.15\"), cc.xyw(1, 11, 8)); \n cmp = (JComponent) cmp.getComponent(0);\n cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));\n hidevideosettings = new JCheckBox(Messages.getString(\"FoldTab.6\")); \n hidevideosettings.setContentAreaFilled(false);\n if (PMS.getConfiguration().getHideVideoSettings())\n \thidevideosettings.setSelected(true);\n hidevideosettings.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setHideVideoSettings((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n archive = new JCheckBox(Messages.getString(\"NetworkTab.1\")); \n archive.setContentAreaFilled(false);\n archive.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setArchiveBrowsing(e.getStateChange() == ItemEvent.SELECTED);\n \t\t\t\tif (PMS.get().getFrame() != null)\n \t\t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n if (PMS.getConfiguration().isArchiveBrowsing())\n \t archive.setSelected(true);\n builder.add(archive, cc.xyw(1, 13, 3));\n final JButton cachereset = new JButton(Messages.getString(\"NetworkTab.18\")); \n cacheenable = new JCheckBox(Messages.getString(\"NetworkTab.17\")); \n cacheenable.setContentAreaFilled(false);\n cacheenable.setSelected(PMS.getConfiguration().getUseCache());\n cacheenable.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setUseCache((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tcachereset.setEnabled(PMS.getConfiguration().getUseCache());\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t\tif ((LooksFrame) PMS.get().getFrame() != null)\n \t\t\t\t\t((LooksFrame) PMS.get().getFrame()).getFt().setScanLibraryEnabled(PMS.getConfiguration().getUseCache());\n \t\t\t}\n });\n \t builder.add(cacheenable, cc.xy(1, 19));\n \t cachereset.addActionListener(new ActionListener() {\n \t\t\t@Override\n \t\t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\t\tint option = JOptionPane.showConfirmDialog(\n \t (Component) PMS.get().getFrame(),\n \t Messages.getString(\"NetworkTab.13\") + \n \t Messages.getString(\"NetworkTab.19\"), \n \t \"Question\", \n \t JOptionPane.YES_NO_OPTION\n \t );\n \t\t\t\tif (option == JOptionPane.YES_OPTION) {\n \t\t\t\t\tPMS.get().getDatabase().init(true);\n \t\t\t\t}\n \t\t\t}\n \t });\n \t builder.add(cachereset, cc.xyw(4, 19, 4));\n \t cachereset.setEnabled(PMS.getConfiguration().getUseCache());\n builder.add(hidevideosettings, cc.xyw(4, 13, 3));\n hideextensions = new JCheckBox(Messages.getString(\"FoldTab.5\")); \n hideextensions.setContentAreaFilled(false);\n if (PMS.getConfiguration().isHideExtensions())\n \thideextensions.setSelected(true);\n hideextensions.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setHideExtensions((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n builder.add(hideextensions, cc.xyw(1, 15, 3));\n hideengines = new JCheckBox(Messages.getString(\"FoldTab.8\")); \n hideengines.setContentAreaFilled(false);\n if (PMS.getConfiguration().isHideEngineNames())\n \thideengines.setSelected(true);\n hideengines.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tPMS.getConfiguration().setHideEngineNames((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t}\n });\n builder.add(hideengines, cc.xyw(4, 15, 3));\n \titunes = new JCheckBox(Messages.getString(\"FoldTab.30\")); \n itunes.setContentAreaFilled(false);\n if (PMS.getConfiguration().getItunesEnabled())\n \titunes.setSelected(true);\n if (!Platform.isMac())\n\t itunes.setEnabled(false);\n itunes.addItemListener(new ItemListener() {\n \t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\tPMS.getConfiguration().setItunesEnabled((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t}\n });\n builder.add(itunes, cc.xyw(1, 17, 3));\n \tiphoto = new JCheckBox(Messages.getString(\"FoldTab.29\")); \n iphoto.setContentAreaFilled(false);\n if (PMS.getConfiguration().getIphotoEnabled())\n \tiphoto.setSelected(true);\n if (!Platform.isMac())\n\t iphoto.setEnabled(false);\n\tiphoto.addItemListener(new ItemListener() {\n \t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\tPMS.getConfiguration().setIphotoEnabled((e.getStateChange() == ItemEvent.SELECTED));\n \t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t}\t\n });\n builder.add(iphoto, cc.xyw(4, 17, 3));\n final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(new Object[] { \"0\", \"1\" }, new Object[] { Messages.getString(\"FoldTab.15\"), Messages.getString(\"FoldTab.16\") }); \n sortmethod = new JComboBox(kcbm);\n sortmethod.setEditable(false);\n kcbm.setSelectedKey(\"\" + configuration.getSortMethod()); \n sortmethod.addItemListener(new ItemListener() {\n \t\t\tpublic void itemStateChanged(ItemEvent e) {\n \t\t\t\tif (e.getStateChange() == ItemEvent.SELECTED) {\n \t\t\t\t\ttry {\n \t\t\t\t\t\tconfiguration.setSortMethod(Integer.parseInt((String) kcbm.getSelectedKey()));\n \t\t\t\t\t\tPMS.get().getFrame().setReloadable(true);\n \t\t\t\t\t} catch (NumberFormatException nfe) {}\n \t\t\t\t}\n \t\t\t}\n });\n builder.addLabel(Messages.getString(\"FoldTab.18\"), cc.xyw(1,21,3)); \n builder.add(sortmethod, cc.xyw(4, 21,4));\n FormLayout layoutFolders = new FormLayout(\n \"left:pref, left:pref, pref, pref, pref, 0:grow\", \n \"p, 3dlu, p, 3dlu, fill:default:grow\"); \n PanelBuilder builderFolder = new PanelBuilder(layoutFolders);\n builderFolder.setOpaque(true);\n cmp = builderFolder.addSeparator(Messages.getString(\"FoldTab.7\"), cc.xyw(1, 1,6)); \n cmp = (JComponent) cmp.getComponent(0);\n cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));\n JButton but = new JButton(LooksFrame.readImageIcon(\"folder_new-32.png\")); \n but.addActionListener(new java.awt.event.ActionListener() {\n\t\t\tpublic void actionPerformed(java.awt.event.ActionEvent e) {\n\t\t\t\tJFileChooser chooser = null;\n\t\t\t\ttry {\n\t\t\t\t\t chooser = new JFileChooser();\n\t\t\t\t} catch (Exception ee) {\n\t\t\t\t\t chooser = new JFileChooser(new RestrictedFileSystemView());\n\t\t\t\t}\n\t\t\t\tchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\n\t\t\t\tint returnVal = chooser.showOpenDialog((Component) e.getSource());\n\t\t\t if(returnVal == JFileChooser.APPROVE_OPTION) {\n\t\t\t \t((DefaultListModel) FList.getModel()).add(FList.getModel().getSize(),chooser.getSelectedFile().getAbsolutePath());\n\t\t\t \tif (FList.getModel().getElementAt(0).equals(ALL_DRIVES))\n\t\t\t \t\t((DefaultListModel) FList.getModel()).remove(0);\n\t\t\t \tupdateModel();\n\t\t\t }\n\t\t\t}\n\t\t});\n builderFolder.add(but, cc.xy(1, 3));\n JButton but2 = new JButton(LooksFrame.readImageIcon(\"button_cancel-32.png\")); \n but2.addActionListener(new java.awt.event.ActionListener() {\n\t\t\tpublic void actionPerformed(java.awt.event.ActionEvent e) {\n\t\t\t\tif (FList.getSelectedIndex() > -1) {\n\t\t\t\t\t((DefaultListModel) FList.getModel()).remove(FList.getSelectedIndex());\n\t\t\t\t\tif (FList.getModel().getSize() == 0)\n\t\t\t \t\t((DefaultListModel) FList.getModel()).add(0, ALL_DRIVES);\n\t\t\t\t\tupdateModel();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n builderFolder.add(but2, cc.xy(2, 3));\n JButton but3 = new JButton(LooksFrame.readImageIcon(\"kdevelop_down-32.png\")); \n but3.setToolTipText(Messages.getString(\"FoldTab.12\")); \n but3.addActionListener(new ActionListener() {\n\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\tDefaultListModel model = ((DefaultListModel) FList.getModel());\n\t\t\tfor(int i=0;i<model.size()-1;i++) {\n\t\t\t\tif (FList.isSelectedIndex(i)) {\n\t\t\t\t\tString value = model.get(i).toString();\n\t\t\t\t\tmodel.set(i, model.get(i+1));\n\t\t\t\t\tmodel.set(i+1, value);\n\t\t\t\t\tFList.setSelectedIndex(i+1);\n\t\t\t\t\tupdateModel();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} \t \n });\n builderFolder.add(but3, cc.xy(3, 3));\n JButton but4 = new JButton(LooksFrame.readImageIcon(\"up-32.png\")); \n but4.setToolTipText(Messages.getString(\"FoldTab.12\")); \n but4.addActionListener(new ActionListener() {\n \t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\tDefaultListModel model = ((DefaultListModel) FList.getModel());\n \t\t\tfor(int i=1;i<model.size();i++) {\n \t\t\t\tif (FList.isSelectedIndex(i)) {\n \t\t\t\t\tString value = model.get(i).toString();\n \t\t\t\t\tmodel.set(i, model.get(i-1));\n \t\t\t\t\tmodel.set(i-1, value);\n \t\t\t\t\tFList.setSelectedIndex(i-1);\n \t\t\t\t\tupdateModel();\n \t\t\t\t\tbreak;\n \t\t\t\t}\n \t\t\t}\n \t\t} \t \n });\n builderFolder.add(but4, cc.xy(4, 3));\n but5 = new JButton(LooksFrame.readImageIcon(\"search-32.png\")); \n but5.setToolTipText(Messages.getString(\"FoldTab.2\")); \n but5.addActionListener(new ActionListener() {\n \t\tpublic void actionPerformed(ActionEvent e) {\n \t\t\tif (PMS.getConfiguration().getUseCache()) {\n \t\t\t\tif (!PMS.get().getDatabase().isScanLibraryRunning()) {\n\t \t\t\t\tint option = JOptionPane.showConfirmDialog(\n\t \t (Component) PMS.get().getFrame(),\n\t \t Messages.getString(\"FoldTab.3\") + \n\t \t Messages.getString(\"FoldTab.4\"), \n\t \t \"Question\", \n\t \t JOptionPane.YES_NO_OPTION\n\t \t );\n\t \t\t\t\tif (option == JOptionPane.YES_OPTION) {\n\t \t\t\t\t\tPMS.get().getDatabase().scanLibrary();\n\t \t\t\t\t\tbut5.setIcon(LooksFrame.readImageIcon(\"viewmagfit-32.png\")); \n\t \t\t\t\t}\n \t\t\t\t} else {\n \t\t\t\t\tint option = JOptionPane.showConfirmDialog(\n\t \t (Component) PMS.get().getFrame(),\n\t \t Messages.getString(\"FoldTab.10\"), \n\t \t \"Question\", \n\t \t JOptionPane.YES_NO_OPTION\n\t \t );\n\t \t\t\t\tif (option == JOptionPane.YES_OPTION) {\n\t \t\t\t\t\tPMS.get().getDatabase().stopScanLibrary();\n\t \t\t\t\t\tPMS.get().getFrame().setStatusLine(null);\n\t \t\t\t\t\tbut5.setIcon(LooksFrame.readImageIcon(\"search-32.png\")); \n\t \t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t} \t \n });\n builderFolder.add(but5, cc.xy(5, 3));\n but5.setEnabled(PMS.getConfiguration().getUseCache());\n builderFolder.add(pane, cc.xyw(1, 5,6));\n builder.add(builderFolder.getPanel(), cc.xyw(1, 25, 8));\n return builder.getPanel();\n\t}\n"} {"input": "\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t\tView row = convertView;\n\t\tRestaurantHolder resturant = getItem(position);\n\t\tif (row == null) {\n\t\t\tLayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();\n\t\t\trow = inflater.inflate(R.layout.row, null);\n\t\t\tholder = new RestaurantHolder(row);\n\t\t\trow.setTag(holder);\n\t\t} else {\n\t\t\tholder = (RestaurantHolder) row.getTag();\n\t\t}\n\t\tholder.populateFrom((Restaurant) getItem(position), row, mContext);\n\t\treturn row;\n\t}\n", "output": "\tpublic View getView(int position, View convertView, ViewGroup parent) {\n\t\tView row = convertView;\n\t\tRestaurantHolder holder;\n\t\tif (row == null) {\n\t\t\tLayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();\n\t\t\trow = inflater.inflate(R.layout.row, null);\n\t\t\tholder = new RestaurantHolder(row);\n\t\t\trow.setTag(holder);\n\t\t} else {\n\t\t\tholder = (RestaurantHolder) row.getTag();\n\t\t}\n\t\tholder.populateFrom((Restaurant) getItem(position), row, mContext);\n\t\treturn row;\n\t}\n"} {"input": " public List<Teacher> findAvailables(TU tu, Date date, Integer duration) {\n Query q = entityManager.createNativeQuery(\"SELECT teacher_busy(?, ?, ?) FROM dual\");\n q.setParameter(2, date);\n q.setParameter(3, duration);\n List<Teacher> availableTeachers = new ArrayList<Teacher>();\n for (Teacher t : tu.getCompetentTeachers()) {\n if (((BigDecimal)q.setParameter(1, t.getId()).getSingleResult()).intValue() == 0) {\n availableTeachers.add(t);\n }\n }\n return availableTeachers;\n }\n", "output": " public List<Teacher> findAvailables(TU tu, Date date, Integer duration) {\n Query q = entityManager.createNativeQuery(\"SELECT teacher_busy(?1, ?2, ?3) FROM dual\");\n q.setParameter(2, date);\n q.setParameter(3, duration);\n List<Teacher> availableTeachers = new ArrayList<Teacher>();\n for (Teacher t : tu.getCompetentTeachers()) {\n if (((BigDecimal)q.setParameter(1, t.getId()).getSingleResult()).intValue() == 0) {\n availableTeachers.add(t);\n }\n }\n return availableTeachers;\n }\n"} {"input": "\tpublic void doGet(HttpServletRequest request, HttpServletResponse response)\n\t\t\tthrows ServletException, IOException {\n\t\tString id = null;\n\t\tString dsPhysicalLocation = null;\n\t\tString dsControlGroupType = null;\n\t\tString user = null;\n\t\tString pass = null;\n\t\tMIMETypedStream mimeTypedStream = null;\n\t\tDisseminationService ds = null;\n\t\tTimestamp keyTimestamp = null;\n\t\tTimestamp currentTimestamp = null;\n\t\tPrintWriter out = null;\n\t\tServletOutputStream outStream = null;\n\t\tString requestURI = request.getRequestURL().toString() + \"?\"\n\t\t\t\t+ request.getQueryString();\n\t\tid = request.getParameter(\"id\").replaceAll(\"T\", \" \");\n LOG.debug(\"Datastream tempID=\" + id);\n LOG.debug(\"DRS doGet()\");\n\t\ttry {\n\t\t\tif (id == null || id.equalsIgnoreCase(\"\")) {\n\t\t\t\tString message = \"[DatastreamResolverServlet] No datastream ID \"\n\t\t\t\t\t\t+ \"specified in servlet request: \"\n\t\t\t\t\t\t+ request.getRequestURI();\n LOG.error(message);\n\t\t\t\tresponse\n\t\t\t\t\t\t.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n\t\t\t\tresponse.sendError(\n\t\t\t\t\t\tHttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tid = id.replaceAll(\"T\", \" \").replaceAll(\"/\", \"\").trim();\n\t\t\tds = new DisseminationService();\n\t\t\tdsRegistry = DisseminationService.dsRegistry;\n\t\t\tDatastreamMediation dm = (DatastreamMediation) dsRegistry.get(id);\n\t\t\tif (dm == null) {\n\t\t\t\tStringBuffer entries = new StringBuffer();\n\t\t\t\tIterator eIter = dsRegistry.keySet().iterator();\n\t\t\t\twhile (eIter.hasNext()) {\n\t\t\t\t\tentries.append(\"'\" + (String) eIter.next() + \"' \");\n\t\t\t\t}\n\t\t\t\tthrow new IOException(\n\t\t\t\t\t\t\"Cannot find datastream in temp registry by key: \" + id\n\t\t\t\t\t\t\t\t+ \"\\n\" + \"Reg entries: \" + entries.toString());\n\t\t\t}\n\t\t\tdsPhysicalLocation = dm.dsLocation;\n\t\t\tdsControlGroupType = dm.dsControlGroupType;\n\t\t\tuser = dm.callUsername;\n\t\t\tpass = dm.callPassword;\n\t\t\tif (LOG.isDebugEnabled()) {\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.dsLocation: \"\n\t\t\t\t\t\t\t\t+ dm.dsLocation);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.dsControlGroupType: \"\n\t\t\t\t\t\t\t\t+ dm.dsControlGroupType);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callUsername: \"\n\t\t\t\t\t\t\t\t+ dm.callUsername);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.Password: \"\n\t\t\t\t\t\t\t\t+ dm.callPassword);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callbackRole: \"\n\t\t\t\t\t\t\t\t+ dm.callbackRole);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callbackBasicAuth: \"\n\t\t\t\t\t\t\t\t+ dm.callbackBasicAuth);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callBasicAuth: \"\n\t\t\t\t\t\t\t\t+ dm.callBasicAuth);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callbackSSl: \"\n\t\t\t\t\t\t\t\t+ dm.callbackSSL);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callSSl: \"\n\t\t\t\t\t\t\t\t+ dm.callSSL);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet non ssl port: \"\n\t\t\t\t\t\t\t\t+ fedoraServerPort);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet ssl port: \"\n\t\t\t\t\t\t\t\t+ fedoraServerRedirectPort);\n\t\t\t}\n\t\t\tif (request.getRequestURI().endsWith(\"getDS\")\n\t\t\t\t\t&& (ServerUtility.isURLFedoraServer(dsPhysicalLocation)\n\t\t\t\t\t\t\t|| dsControlGroupType.equals(\"M\") || dsControlGroupType\n\t\t\t\t\t\t\t.equals(\"X\"))) {\n\t\t\t\tif (LOG.isDebugEnabled())\n\t\t\t\t\tLOG.debug(\"*********************** Changed role from: \"\n\t\t\t\t\t\t\t\t\t+ dm.callbackRole\n\t\t\t\t\t\t\t\t\t+ \" to: \"\n\t\t\t\t\t\t\t\t\t+ BackendPolicies.BACKEND_SERVICE_CALL_UNSECURE);\n\t\t\t\tdm.callbackRole = BackendPolicies.BACKEND_SERVICE_CALL_UNSECURE;\n\t\t\t}\n\t\t\tif (dm.callbackRole.equals(BackendPolicies.FEDORA_INTERNAL_CALL)) {\n\t\t\t\tif (dm.callbackSSL) {\n\t\t\t\t\tdsPhysicalLocation = dsPhysicalLocation.replaceFirst(\n\t\t\t\t\t\t\t\"http:\", \"https:\");\n\t\t\t\t\tdsPhysicalLocation = dsPhysicalLocation.replaceFirst(\n\t\t\t\t\t\t\tfedoraServerPort, fedoraServerRedirectPort);\n\t\t\t\t\tif (LOG.isDebugEnabled())\n\t\t\t\t\t\tLOG.debug(\"*********************** DatastreamResolverServlet -- Was Fedora-to-Fedora call -- modified dsPhysicalLocation: \"\n\t\t\t\t\t\t\t\t\t\t+ dsPhysicalLocation);\n\t\t\t\t}\n\t\t\t}\n\t\t\tkeyTimestamp = Timestamp.valueOf(ds.extractTimestamp(id));\n\t\t\tcurrentTimestamp = new Timestamp(new Date().getTime());\n LOG.debug(\"dsPhysicalLocation=\" + dsPhysicalLocation\n + \"dsControlGroupType=\" + dsControlGroupType);\n long diff = currentTimestamp.getTime() - keyTimestamp.getTime();\n LOG.debug(\"Timestamp diff for mechanism's reponse: \" \n + diff + \" ms.\");\n\t\t\tif (diff > (long) datastreamMediationLimit) {\n\t\t\t\tout = response.getWriter();\n\t\t\t\tresponse.setContentType(HTML_CONTENT_TYPE);\n\t\t\t\tout\n\t\t\t\t\t\t.println(\"<br><b>[DatastreamResolverServlet] Error:</b>\"\n\t\t\t\t\t\t\t\t+ \"<font color=\\\"red\\\"> Mechanism has failed to respond \"\n\t\t\t\t\t\t\t\t+ \"to the DatastreamResolverServlet within the specified \"\n\t\t\t\t\t\t\t\t+ \"time limit of \\\"\"\n\t\t\t\t\t\t\t\t+ datastreamMediationLimit\n\t\t\t\t\t\t\t\t+ \"\\\"\"\n\t\t\t\t\t\t\t\t+ \"milliseconds. Datastream access denied.\");\n LOG.error(\"Mechanism failed to respond to \"\n + \"DatastreamResolverServlet within time limit of \"\n + datastreamMediationLimit);\n\t\t\t\tout.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (dm.callbackRole == null) {\n\t\t\t\tthrow new AuthzOperationalException(\n\t\t\t\t\t\t\"no callbackRole for this ticket\");\n\t\t\t}\n\t\t\tString targetRole = \n\t\t\t\t\tdm.callbackRole; \n\t\t\tString[] targetRoles = { targetRole };\n\t\t\tContext context = ReadOnlyContext.getContext(\n\t\t\t\t\tConstants.HTTP_REQUEST.REST.uri, request); \n\t\t\tif (request.getRemoteUser() == null) {\n \t\t\tLOG.debug(\"DatastreamResolverServlet: unAuthenticated request\");\n\t\t\t} else {\n\t\t\t\tif (((ExtendedHttpServletRequest)request).isUserInRole(targetRole)) {\n\t\t\t\t\tLOG.debug(\"DatastreamResolverServlet: user has required role\");\n\t\t\t\t} else {\n\t\t\t\t\tLOG.debug(\"DatastreamResolverServlet: authZ exception in validating user\");\n\t\t\t\t\tthrow new AuthzDeniedException(\"wrong user for this ticket\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (LOG.isDebugEnabled()) {\n\t\t\t\tLOG.debug(\"debugging backendService role\");\n\t\t\t\tLOG.debug(\"targetRole=\" + targetRole);\n\t\t\t\tint targetRolesLength = targetRoles.length;\n\t\t\t\tLOG.debug(\"targetRolesLength=\" + targetRolesLength);\n\t\t\t\tif (targetRolesLength > 0) {\n\t\t\t\t\tLOG.debug(\"targetRoles[0]=\" + targetRoles[0]);\n\t\t\t\t}\n\t\t\t\tint nSubjectValues = context.nSubjectValues(targetRole);\n\t\t\t\tLOG.debug(\"nSubjectValues=\" + nSubjectValues);\n\t\t\t\tif (nSubjectValues > 0) {\n\t\t\t\t\tLOG.debug(\"context.getSubjectValue(targetRole)=\"\n\t\t\t\t\t\t\t+ context.getSubjectValue(targetRole));\n\t\t\t\t}\n\t\t\t\tIterator it = context.subjectAttributes();\n\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\tString name = (String) it.next();\n\t\t\t\t\tString value = context.getSubjectValue(name);\n\t\t\t\t\tLOG.debug(\"another subject attribute from context \"\n\t\t\t\t\t\t\t\t\t+ name + \"=\" + value);\n\t\t\t\t}\n\t\t\t\tit = context.environmentAttributes();\n\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\tString name = (String) it.next();\n\t\t\t\t\tString value = context.getEnvironmentValue(name);\n\t\t\t\t\tLOG.debug(\"another environment attribute from context \"\n\t\t\t\t\t\t\t\t\t+ name + \"=\" + value);\n\t\t\t\t}\n\t\t\t}\n LOG.debug(\"DatastreamResolverServlet: about to do final authZ check\");\n\t\t\tAuthorization authorization = (Authorization) s_server\n\t\t\t\t\t.getModule(\"fedora.server.security.Authorization\");\n\t\t\tauthorization.enforceResolveDatastream(context, keyTimestamp);\n\t\t\tLOG.debug(\"DatastreamResolverServlet: final authZ check suceeded.....\");\n\t\t\tif (dsControlGroupType.equalsIgnoreCase(\"E\")) {\n\t\t\t\tif (LOG.isDebugEnabled()) {\n\t\t\t\t\tfor (Enumeration e = request.getHeaderNames(); e\n\t\t\t\t\t\t\t.hasMoreElements();) {\n\t\t\t\t\t\tString name = (String) e.nextElement();\n\t\t\t\t\t\tEnumeration headerValues = request.getHeaders(name);\n\t\t\t\t\t\tStringBuffer sb = new StringBuffer();\n\t\t\t\t\t\twhile (headerValues.hasMoreElements()) {\n\t\t\t\t\t\t\tsb.append((String) headerValues.nextElement());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tString value = sb.toString();\n\t\t\t\t\t\tLOG.debug(\"DATASTREAMRESOLVERSERVLET REQUEST HEADER CONTAINED: \"\n\t\t\t\t\t\t\t\t\t\t+ name + \" : \" + value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tExternalContentManager externalContentManager = (ExternalContentManager) s_server\n\t\t\t\t\t\t.getModule(\"fedora.server.storage.ExternalContentManager\");\n\t\t\t\tmimeTypedStream = externalContentManager.getExternalContent(\n\t\t\t\t\t\tdsPhysicalLocation, context);\n\t\t\t\toutStream = response.getOutputStream();\n\t\t\t\tresponse.setContentType(mimeTypedStream.MIMEType);\n\t\t\t\tProperty[] headerArray = mimeTypedStream.header;\n\t\t\t\tif (headerArray != null) {\n\t\t\t\t\tfor (int i = 0; i < headerArray.length; i++) {\n\t\t\t\t\t\tif (headerArray[i].name != null\n\t\t\t\t\t\t\t\t&& !(headerArray[i].name\n\t\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"content-type\"))) {\n\t\t\t\t\t\t\tresponse.addHeader(headerArray[i].name,\n\t\t\t\t\t\t\t\t\theaderArray[i].value);\n\t\t\t\t\t\t\tLOG.debug(\"THIS WAS ADDED TO DATASTREAMRESOLVERSERVLET RESPONSE HEADER FROM ORIGINATING PROVIDER \"\n\t\t\t\t\t\t\t\t\t\t+ headerArray[i].name\n\t\t\t\t\t\t\t\t\t\t+ \" : \" + headerArray[i].value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint byteStream = 0;\n\t\t\t\tbyte[] buffer = new byte[255];\n\t\t\t\twhile ((byteStream = mimeTypedStream.getStream().read(buffer)) != -1) {\n\t\t\t\t\toutStream.write(buffer, 0, byteStream);\n\t\t\t\t}\n\t\t\t\tbuffer = null;\n\t\t\t\toutStream.flush();\n\t\t\t} else if (dsControlGroupType.equalsIgnoreCase(\"M\")\n\t\t\t\t\t|| dsControlGroupType.equalsIgnoreCase(\"X\")) {\n\t\t\t\tString PID = null;\n\t\t\t\tString dsVersionID = null;\n\t\t\t\tString dsID = null;\n\t\t\t\tString[] s = dsPhysicalLocation.split(\"\\\\+\");\n\t\t\t\tif (s.length != 3) {\n\t\t\t\t\tString message = \"[DatastreamResolverServlet] The \"\n\t\t\t\t\t\t\t+ \"internal Fedora datastream id: \\\"\"\n\t\t\t\t\t\t\t+ dsPhysicalLocation + \"\\\" is invalid.\";\n\t\t\t\t\tLOG.error(message);\n\t\t\t\t\tthrow new ServletException(message);\n\t\t\t\t}\n\t\t\t\tPID = s[0];\n\t\t\t\tdsID = s[1];\n\t\t\t\tdsVersionID = s[2];\n LOG.debug(\"PID=\" + PID + \", dsID=\" + dsID + \", dsVersionID=\"\n + dsVersionID);\n\t\t\t\tDOReader doReader = m_manager.getReader(\n\t\t\t\t\t\tServer.USE_DEFINITIVE_STORE, context, PID);\n\t\t\t\tDatastream d = (Datastream) doReader.getDatastream(dsID,\n\t\t\t\t\t\tdsVersionID);\n LOG.debug(\"Got datastream: \" + d.DatastreamID);\n\t\t\t\tInputStream is = d.getContentStream();\n\t\t\t\tint bytestream = 0;\n\t\t\t\tresponse.setContentType(d.DSMIME);\n\t\t\t\toutStream = response.getOutputStream();\n\t\t\t\tbyte[] buffer = new byte[255];\n\t\t\t\twhile ((bytestream = is.read(buffer)) != -1) {\n\t\t\t\t\toutStream.write(buffer, 0, bytestream);\n\t\t\t\t}\n\t\t\t\tbuffer = null;\n\t\t\t\tis.close();\n\t\t\t} else {\n\t\t\t\tout = response.getWriter();\n\t\t\t\tresponse.setContentType(HTML_CONTENT_TYPE);\n\t\t\t\tout.println(\"<br>[DatastreamResolverServlet] Unknown \"\n\t\t\t\t\t\t\t\t+ \"dsControlGroupType: \" + dsControlGroupType\n\t\t\t\t\t\t\t\t+ \"</br>\");\n LOG.error(\"Unknown dsControlGroupType: \" + dsControlGroupType);\n\t\t\t}\n\t\t} catch (AuthzException ae) {\n LOG.error(\"Authorization failure resolving datastream\"\n + \" (actionLabel=\" + ACTION_LABEL + \")\", ae);\n\t\t\tthrow RootException.getServletException(ae, request, ACTION_LABEL,\n\t\t\t\t\tnew String[0]);\n\t\t} catch (Throwable th) {\n LOG.error(\"Error resolving datastream\", th);\n\t\t\tString message = \"[DatastreamResolverServlet] returned an error. The \"\n\t\t\t\t\t+ \"underlying error was a \\\"\"\n\t\t\t\t\t+ th.getClass().getName()\n\t\t\t\t\t+ \" The message was \\\"\" + th.getMessage() + \"\\\". \";\n\t\t\tthrow new ServletException(message);\n\t\t} finally {\n\t\t\tif (out != null)\n\t\t\t\tout.close();\n\t\t\tif (outStream != null)\n\t\t\t\toutStream.close();\n\t\t\tdsRegistry.remove(id);\n\t\t}\n\t}\n", "output": "\tpublic void doGet(HttpServletRequest request, HttpServletResponse response)\n\t\t\tthrows ServletException, IOException {\n\t\tString id = null;\n\t\tString dsPhysicalLocation = null;\n\t\tString dsControlGroupType = null;\n\t\tString user = null;\n\t\tString pass = null;\n\t\tMIMETypedStream mimeTypedStream = null;\n\t\tDisseminationService ds = null;\n\t\tTimestamp keyTimestamp = null;\n\t\tTimestamp currentTimestamp = null;\n\t\tPrintWriter out = null;\n\t\tServletOutputStream outStream = null;\n\t\tString requestURI = request.getRequestURL().toString() + \"?\"\n\t\t\t\t+ request.getQueryString();\n\t\tid = request.getParameter(\"id\").replaceAll(\"T\", \" \");\n LOG.debug(\"Datastream tempID=\" + id);\n LOG.debug(\"DRS doGet()\");\n\t\ttry {\n\t\t\tif (id == null || id.equalsIgnoreCase(\"\")) {\n\t\t\t\tString message = \"[DatastreamResolverServlet] No datastream ID \"\n\t\t\t\t\t\t+ \"specified in servlet request: \"\n\t\t\t\t\t\t+ request.getRequestURI();\n LOG.error(message);\n\t\t\t\tresponse\n\t\t\t\t\t\t.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n\t\t\t\tresponse.sendError(\n\t\t\t\t\t\tHttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tid = id.replaceAll(\"T\", \" \").replaceAll(\"/\", \"\").trim();\n\t\t\tds = new DisseminationService();\n\t\t\tdsRegistry = DisseminationService.dsRegistry;\n\t\t\tDatastreamMediation dm = (DatastreamMediation) dsRegistry.get(id);\n\t\t\tif (dm == null) {\n\t\t\t\tStringBuffer entries = new StringBuffer();\n\t\t\t\tIterator eIter = dsRegistry.keySet().iterator();\n\t\t\t\twhile (eIter.hasNext()) {\n\t\t\t\t\tentries.append(\"'\" + (String) eIter.next() + \"' \");\n\t\t\t\t}\n\t\t\t\tthrow new IOException(\n\t\t\t\t\t\t\"Cannot find datastream in temp registry by key: \" + id\n\t\t\t\t\t\t\t\t+ \"\\n\" + \"Reg entries: \" + entries.toString());\n\t\t\t}\n\t\t\tdsPhysicalLocation = dm.dsLocation;\n\t\t\tdsControlGroupType = dm.dsControlGroupType;\n\t\t\tuser = dm.callUsername;\n\t\t\tpass = dm.callPassword;\n\t\t\tif (LOG.isDebugEnabled()) {\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.dsLocation: \"\n\t\t\t\t\t\t\t\t+ dm.dsLocation);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.dsControlGroupType: \"\n\t\t\t\t\t\t\t\t+ dm.dsControlGroupType);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callUsername: \"\n\t\t\t\t\t\t\t\t+ dm.callUsername);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.Password: \"\n\t\t\t\t\t\t\t\t+ dm.callPassword);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callbackRole: \"\n\t\t\t\t\t\t\t\t+ dm.callbackRole);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callbackBasicAuth: \"\n\t\t\t\t\t\t\t\t+ dm.callbackBasicAuth);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callBasicAuth: \"\n\t\t\t\t\t\t\t\t+ dm.callBasicAuth);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callbackSSl: \"\n\t\t\t\t\t\t\t\t+ dm.callbackSSL);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet dm.callSSl: \"\n\t\t\t\t\t\t\t\t+ dm.callSSL);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet non ssl port: \"\n\t\t\t\t\t\t\t\t+ fedoraServerPort);\n\t\t\t\tLOG.debug(\"**************************** DatastreamResolverServlet ssl port: \"\n\t\t\t\t\t\t\t\t+ fedoraServerRedirectPort);\n\t\t\t}\n\t\t\tif (request.getRequestURI().endsWith(\"getDS\")\n\t\t\t\t\t&& (ServerUtility.isURLFedoraServer(dsPhysicalLocation)\n\t\t\t\t\t\t\t|| dsControlGroupType.equals(\"M\") || dsControlGroupType\n\t\t\t\t\t\t\t.equals(\"X\"))) {\n\t\t\t\tif (LOG.isDebugEnabled())\n\t\t\t\t\tLOG.debug(\"*********************** Changed role from: \"\n\t\t\t\t\t\t\t\t\t+ dm.callbackRole\n\t\t\t\t\t\t\t\t\t+ \" to: \"\n\t\t\t\t\t\t\t\t\t+ BackendPolicies.BACKEND_SERVICE_CALL_UNSECURE);\n\t\t\t\tdm.callbackRole = BackendPolicies.BACKEND_SERVICE_CALL_UNSECURE;\n\t\t\t}\n\t\t\tif (dm.callbackRole.equals(BackendPolicies.FEDORA_INTERNAL_CALL)) {\n\t\t\t\tif (dm.callbackSSL) {\n\t\t\t\t\tdsPhysicalLocation = dsPhysicalLocation.replaceFirst(\n\t\t\t\t\t\t\t\"http:\", \"https:\");\n\t\t\t\t\tdsPhysicalLocation = dsPhysicalLocation.replaceFirst(\n\t\t\t\t\t\t\tfedoraServerPort, fedoraServerRedirectPort);\n\t\t\t\t\tif (LOG.isDebugEnabled())\n\t\t\t\t\t\tLOG.debug(\"*********************** DatastreamResolverServlet -- Was Fedora-to-Fedora call -- modified dsPhysicalLocation: \"\n\t\t\t\t\t\t\t\t\t\t+ dsPhysicalLocation);\n\t\t\t\t}\n\t\t\t}\n\t\t\tkeyTimestamp = Timestamp.valueOf(ds.extractTimestamp(id));\n\t\t\tcurrentTimestamp = new Timestamp(new Date().getTime());\n LOG.debug(\"dsPhysicalLocation=\" + dsPhysicalLocation\n + \"dsControlGroupType=\" + dsControlGroupType);\n long diff = currentTimestamp.getTime() - keyTimestamp.getTime();\n LOG.debug(\"Timestamp diff for mechanism's reponse: \" \n + diff + \" ms.\");\n\t\t\tif (diff > (long) datastreamMediationLimit) {\n\t\t\t\tout = response.getWriter();\n\t\t\t\tresponse.setContentType(HTML_CONTENT_TYPE);\n\t\t\t\tout\n\t\t\t\t\t\t.println(\"<br><b>[DatastreamResolverServlet] Error:</b>\"\n\t\t\t\t\t\t\t\t+ \"<font color=\\\"red\\\"> Mechanism has failed to respond \"\n\t\t\t\t\t\t\t\t+ \"to the DatastreamResolverServlet within the specified \"\n\t\t\t\t\t\t\t\t+ \"time limit of \\\"\"\n\t\t\t\t\t\t\t\t+ datastreamMediationLimit\n\t\t\t\t\t\t\t\t+ \"\\\"\"\n\t\t\t\t\t\t\t\t+ \"milliseconds. Datastream access denied.\");\n LOG.error(\"Mechanism failed to respond to \"\n + \"DatastreamResolverServlet within time limit of \"\n + datastreamMediationLimit);\n\t\t\t\tout.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (dm.callbackRole == null) {\n\t\t\t\tthrow new AuthzOperationalException(\n\t\t\t\t\t\t\"no callbackRole for this ticket\");\n\t\t\t}\n\t\t\tString targetRole = \n\t\t\t\t\tdm.callbackRole; \n\t\t\tString[] targetRoles = { targetRole };\n\t\t\tContext context = ReadOnlyContext.getContext(\n\t\t\t\t\tConstants.HTTP_REQUEST.REST.uri, request); \n\t\t\tif (request.getRemoteUser() == null) {\n \t\t\tLOG.debug(\"DatastreamResolverServlet: unAuthenticated request\");\n\t\t\t} else {\n\t\t\t\tLOG.debug(\"DatastreamResolverServlet: user==\" + request.getRemoteUser());\t\n\t\t\t}\n\t\t\tif (LOG.isDebugEnabled()) {\n\t\t\t\tLOG.debug(\"debugging backendService role\");\n\t\t\t\tLOG.debug(\"targetRole=\" + targetRole);\n\t\t\t\tint targetRolesLength = targetRoles.length;\n\t\t\t\tLOG.debug(\"targetRolesLength=\" + targetRolesLength);\n\t\t\t\tif (targetRolesLength > 0) {\n\t\t\t\t\tLOG.debug(\"targetRoles[0]=\" + targetRoles[0]);\n\t\t\t\t}\n\t\t\t\tint nSubjectValues = context.nSubjectValues(targetRole);\n\t\t\t\tLOG.debug(\"nSubjectValues=\" + nSubjectValues);\n\t\t\t\tif (nSubjectValues > 0) {\n\t\t\t\t\tLOG.debug(\"context.getSubjectValue(targetRole)=\"\n\t\t\t\t\t\t\t+ context.getSubjectValue(targetRole));\n\t\t\t\t}\n\t\t\t\tIterator it = context.subjectAttributes();\n\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\tString name = (String) it.next();\n\t\t\t\t\tString value = context.getSubjectValue(name);\n\t\t\t\t\tLOG.debug(\"another subject attribute from context \"\n\t\t\t\t\t\t\t\t\t+ name + \"=\" + value);\n\t\t\t\t}\n\t\t\t\tit = context.environmentAttributes();\n\t\t\t\twhile (it.hasNext()) {\n\t\t\t\t\tString name = (String) it.next();\n\t\t\t\t\tString value = context.getEnvironmentValue(name);\n\t\t\t\t\tLOG.debug(\"another environment attribute from context \"\n\t\t\t\t\t\t\t\t\t+ name + \"=\" + value);\n\t\t\t\t}\n\t\t\t}\n LOG.debug(\"DatastreamResolverServlet: about to do final authZ check\");\n\t\t\tAuthorization authorization = (Authorization) s_server\n\t\t\t\t\t.getModule(\"fedora.server.security.Authorization\");\n\t\t\tauthorization.enforceResolveDatastream(context, keyTimestamp);\n\t\t\tLOG.debug(\"DatastreamResolverServlet: final authZ check suceeded.....\");\n\t\t\tif (dsControlGroupType.equalsIgnoreCase(\"E\")) {\n\t\t\t\tif (LOG.isDebugEnabled()) {\n\t\t\t\t\tfor (Enumeration e = request.getHeaderNames(); e\n\t\t\t\t\t\t\t.hasMoreElements();) {\n\t\t\t\t\t\tString name = (String) e.nextElement();\n\t\t\t\t\t\tEnumeration headerValues = request.getHeaders(name);\n\t\t\t\t\t\tStringBuffer sb = new StringBuffer();\n\t\t\t\t\t\twhile (headerValues.hasMoreElements()) {\n\t\t\t\t\t\t\tsb.append((String) headerValues.nextElement());\n\t\t\t\t\t\t}\n\t\t\t\t\t\tString value = sb.toString();\n\t\t\t\t\t\tLOG.debug(\"DATASTREAMRESOLVERSERVLET REQUEST HEADER CONTAINED: \"\n\t\t\t\t\t\t\t\t\t\t+ name + \" : \" + value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tExternalContentManager externalContentManager = (ExternalContentManager) s_server\n\t\t\t\t\t\t.getModule(\"fedora.server.storage.ExternalContentManager\");\n\t\t\t\tmimeTypedStream = externalContentManager.getExternalContent(\n\t\t\t\t\t\tdsPhysicalLocation, context);\n\t\t\t\toutStream = response.getOutputStream();\n\t\t\t\tresponse.setContentType(mimeTypedStream.MIMEType);\n\t\t\t\tProperty[] headerArray = mimeTypedStream.header;\n\t\t\t\tif (headerArray != null) {\n\t\t\t\t\tfor (int i = 0; i < headerArray.length; i++) {\n\t\t\t\t\t\tif (headerArray[i].name != null\n\t\t\t\t\t\t\t\t&& !(headerArray[i].name\n\t\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"content-type\"))) {\n\t\t\t\t\t\t\tresponse.addHeader(headerArray[i].name,\n\t\t\t\t\t\t\t\t\theaderArray[i].value);\n\t\t\t\t\t\t\tLOG.debug(\"THIS WAS ADDED TO DATASTREAMRESOLVERSERVLET RESPONSE HEADER FROM ORIGINATING PROVIDER \"\n\t\t\t\t\t\t\t\t\t\t+ headerArray[i].name\n\t\t\t\t\t\t\t\t\t\t+ \" : \" + headerArray[i].value);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint byteStream = 0;\n\t\t\t\tbyte[] buffer = new byte[255];\n\t\t\t\twhile ((byteStream = mimeTypedStream.getStream().read(buffer)) != -1) {\n\t\t\t\t\toutStream.write(buffer, 0, byteStream);\n\t\t\t\t}\n\t\t\t\tbuffer = null;\n\t\t\t\toutStream.flush();\n\t\t\t} else if (dsControlGroupType.equalsIgnoreCase(\"M\")\n\t\t\t\t\t|| dsControlGroupType.equalsIgnoreCase(\"X\")) {\n\t\t\t\tString PID = null;\n\t\t\t\tString dsVersionID = null;\n\t\t\t\tString dsID = null;\n\t\t\t\tString[] s = dsPhysicalLocation.split(\"\\\\+\");\n\t\t\t\tif (s.length != 3) {\n\t\t\t\t\tString message = \"[DatastreamResolverServlet] The \"\n\t\t\t\t\t\t\t+ \"internal Fedora datastream id: \\\"\"\n\t\t\t\t\t\t\t+ dsPhysicalLocation + \"\\\" is invalid.\";\n\t\t\t\t\tLOG.error(message);\n\t\t\t\t\tthrow new ServletException(message);\n\t\t\t\t}\n\t\t\t\tPID = s[0];\n\t\t\t\tdsID = s[1];\n\t\t\t\tdsVersionID = s[2];\n LOG.debug(\"PID=\" + PID + \", dsID=\" + dsID + \", dsVersionID=\"\n + dsVersionID);\n\t\t\t\tDOReader doReader = m_manager.getReader(\n\t\t\t\t\t\tServer.USE_DEFINITIVE_STORE, context, PID);\n\t\t\t\tDatastream d = (Datastream) doReader.getDatastream(dsID,\n\t\t\t\t\t\tdsVersionID);\n LOG.debug(\"Got datastream: \" + d.DatastreamID);\n\t\t\t\tInputStream is = d.getContentStream();\n\t\t\t\tint bytestream = 0;\n\t\t\t\tresponse.setContentType(d.DSMIME);\n\t\t\t\toutStream = response.getOutputStream();\n\t\t\t\tbyte[] buffer = new byte[255];\n\t\t\t\twhile ((bytestream = is.read(buffer)) != -1) {\n\t\t\t\t\toutStream.write(buffer, 0, bytestream);\n\t\t\t\t}\n\t\t\t\tbuffer = null;\n\t\t\t\tis.close();\n\t\t\t} else {\n\t\t\t\tout = response.getWriter();\n\t\t\t\tresponse.setContentType(HTML_CONTENT_TYPE);\n\t\t\t\tout.println(\"<br>[DatastreamResolverServlet] Unknown \"\n\t\t\t\t\t\t\t\t+ \"dsControlGroupType: \" + dsControlGroupType\n\t\t\t\t\t\t\t\t+ \"</br>\");\n LOG.error(\"Unknown dsControlGroupType: \" + dsControlGroupType);\n\t\t\t}\n\t\t} catch (AuthzException ae) {\n LOG.error(\"Authorization failure resolving datastream\"\n + \" (actionLabel=\" + ACTION_LABEL + \")\", ae);\n\t\t\tthrow RootException.getServletException(ae, request, ACTION_LABEL,\n\t\t\t\t\tnew String[0]);\n\t\t} catch (Throwable th) {\n LOG.error(\"Error resolving datastream\", th);\n\t\t\tString message = \"[DatastreamResolverServlet] returned an error. The \"\n\t\t\t\t\t+ \"underlying error was a \\\"\"\n\t\t\t\t\t+ th.getClass().getName()\n\t\t\t\t\t+ \" The message was \\\"\" + th.getMessage() + \"\\\". \";\n\t\t\tthrow new ServletException(message);\n\t\t} finally {\n\t\t\tif (out != null)\n\t\t\t\tout.close();\n\t\t\tif (outStream != null)\n\t\t\t\toutStream.close();\n\t\t\tdsRegistry.remove(id);\n\t\t}\n\t}\n"} {"input": " List<String> generatePositionalArguments(Tree.ArgumentList that, List<Tree.PositionalArgument> args,\n final boolean forceSequenced, final boolean generateVars) {\n if (!args.isEmpty()) {\n final List<String> argvars = new ArrayList<String>(args.size());\n boolean first=true;\n boolean opened=false;\n ProducedType sequencedType=null;\n for (Tree.PositionalArgument arg: args) {\n Tree.Expression expr;\n if (arg instanceof Tree.ListedArgument) {\n if (!first) gen.out(\",\");\n expr = ((Tree.ListedArgument) arg).getExpression();\n ProducedType exprType = expr.getTypeModel();\n boolean dyncheck = gen.isInDynamicBlock() && !TypeUtils.isUnknown(arg.getParameter()) && exprType.isUnknown();\n if (forceSequenced || (arg.getParameter() != null && arg.getParameter().isSequenced())) {\n if (dyncheck) {\n exprType = arg.getParameter().getType();\n }\n if (sequencedType == null) {\n sequencedType=exprType;\n } else {\n ArrayList<ProducedType> cases = new ArrayList<ProducedType>(2);\n Util.addToUnion(cases, sequencedType);\n Util.addToUnion(cases, exprType);\n if (cases.size() > 1) {\n UnionType ut = new UnionType(that.getUnit());\n ut.setCaseTypes(cases);\n sequencedType = ut.getType();\n } else {\n sequencedType = cases.get(0);\n }\n }\n if (!opened) {\n if (generateVars) {\n final String argvar = names.createTempVariable();\n argvars.add(argvar);\n gen.out(argvar, \"=\");\n }\n gen.out(\"[\");\n }\n opened=true;\n } else if (generateVars) {\n final String argvar = names.createTempVariable();\n argvars.add(argvar);\n gen.out(argvar, \"=\");\n }\n int boxType = gen.boxUnboxStart(expr.getTerm(), arg.getParameter());\n if (dyncheck) {\n TypeUtils.generateDynamicCheck(((Tree.ListedArgument) arg).getExpression(),\n arg.getParameter().getType(), gen);\n } else {\n arg.visit(gen);\n }\n if (boxType == 4) {\n gen.out(\",\");\n describeMethodParameters(expr.getTerm());\n gen.out(\",\");\n TypeUtils.printTypeArguments(arg, arg.getTypeModel().getTypeArguments(), gen);\n }\n gen.boxUnboxEnd(boxType);\n } else if (arg instanceof Tree.SpreadArgument || arg instanceof Tree.Comprehension) {\n if (arg instanceof Tree.SpreadArgument) {\n expr = ((Tree.SpreadArgument) arg).getExpression();\n } else {\n expr = null;\n }\n if (!first) {\n gen.closeSequenceWithReifiedType(that,\n gen.getTypeUtils().wrapAsIterableArguments(sequencedType));\n gen.out(\".chain(\");\n sequencedType=null;\n }\n if (arg instanceof Tree.SpreadArgument) {\n int boxType = gen.boxUnboxStart(expr.getTerm(), arg.getParameter());\n arg.visit(gen);\n if (boxType == 4) {\n gen.out(\",\");\n describeMethodParameters(expr.getTerm());\n gen.out(\",\");\n TypeUtils.printTypeArguments(arg, arg.getTypeModel().getTypeArguments(), gen);\n }\n gen.boxUnboxEnd(boxType);\n } else {\n ((Tree.Comprehension)arg).visit(gen);\n }\n if (!first) {\n gen.out(\",\");\n if (expr == null) {\n TypeUtils.printTypeArguments(that,\n gen.getTypeUtils().wrapAsIterableArguments(arg.getTypeModel()), gen);\n } else {\n ProducedType spreadType = TypeUtils.findSupertype(gen.getTypeUtils().sequential, expr.getTypeModel());\n TypeUtils.printTypeArguments(that, spreadType.getTypeArguments(), gen);\n }\n gen.out(\")\");\n }\n if (arg instanceof Tree.Comprehension) {\n break;\n }\n }\n first = false;\n }\n if (sequencedType != null) {\n gen.closeSequenceWithReifiedType(that,\n gen.getTypeUtils().wrapAsIterableArguments(sequencedType));\n }\n return argvars;\n }\n return Collections.emptyList();\n }\n", "output": " List<String> generatePositionalArguments(Tree.ArgumentList that, List<Tree.PositionalArgument> args,\n final boolean forceSequenced, final boolean generateVars) {\n if (!args.isEmpty()) {\n final List<String> argvars = new ArrayList<String>(args.size());\n boolean first=true;\n boolean opened=false;\n ProducedType sequencedType=null;\n for (Tree.PositionalArgument arg: args) {\n Tree.Expression expr;\n if (arg instanceof Tree.ListedArgument) {\n if (!first) gen.out(\",\");\n expr = ((Tree.ListedArgument) arg).getExpression();\n ProducedType exprType = expr.getTypeModel();\n boolean dyncheck = gen.isInDynamicBlock() && !TypeUtils.isUnknown(arg.getParameter()) && exprType.isUnknown();\n if (forceSequenced || (arg.getParameter() != null && arg.getParameter().isSequenced())) {\n if (dyncheck) {\n exprType = arg.getParameter().getType();\n }\n if (sequencedType == null) {\n sequencedType=exprType;\n } else {\n ArrayList<ProducedType> cases = new ArrayList<ProducedType>(2);\n Util.addToUnion(cases, sequencedType);\n Util.addToUnion(cases, exprType);\n if (cases.size() > 1) {\n UnionType ut = new UnionType(that.getUnit());\n ut.setCaseTypes(cases);\n sequencedType = ut.getType();\n } else {\n sequencedType = cases.get(0);\n }\n }\n if (!opened) {\n if (generateVars) {\n final String argvar = names.createTempVariable();\n argvars.add(argvar);\n gen.out(argvar, \"=\");\n }\n gen.out(\"[\");\n }\n opened=true;\n } else if (generateVars) {\n final String argvar = names.createTempVariable();\n argvars.add(argvar);\n gen.out(argvar, \"=\");\n }\n int boxType = gen.boxUnboxStart(expr.getTerm(), arg.getParameter());\n if (dyncheck) {\n TypeUtils.generateDynamicCheck(((Tree.ListedArgument) arg).getExpression(),\n arg.getParameter().getType(), gen);\n } else {\n arg.visit(gen);\n }\n if (boxType == 4) {\n gen.out(\",\");\n describeMethodParameters(expr.getTerm());\n gen.out(\",\");\n TypeUtils.printTypeArguments(arg, arg.getTypeModel().getTypeArguments(), gen);\n }\n gen.boxUnboxEnd(boxType);\n } else if (arg instanceof Tree.SpreadArgument || arg instanceof Tree.Comprehension) {\n if (arg instanceof Tree.SpreadArgument) {\n expr = ((Tree.SpreadArgument) arg).getExpression();\n } else {\n expr = null;\n }\n if (opened) {\n gen.closeSequenceWithReifiedType(that,\n gen.getTypeUtils().wrapAsIterableArguments(sequencedType));\n gen.out(\".chain(\");\n sequencedType=null;\n } else if (!first) {\n gen.out(\",\");\n }\n if (arg instanceof Tree.SpreadArgument) {\n int boxType = gen.boxUnboxStart(expr.getTerm(), arg.getParameter());\n arg.visit(gen);\n if (boxType == 4) {\n gen.out(\",\");\n describeMethodParameters(expr.getTerm());\n gen.out(\",\");\n TypeUtils.printTypeArguments(arg, arg.getTypeModel().getTypeArguments(), gen);\n }\n gen.boxUnboxEnd(boxType);\n } else {\n ((Tree.Comprehension)arg).visit(gen);\n }\n if (opened) {\n gen.out(\",\");\n if (expr == null) {\n TypeUtils.printTypeArguments(that,\n gen.getTypeUtils().wrapAsIterableArguments(arg.getTypeModel()), gen);\n } else {\n ProducedType spreadType = TypeUtils.findSupertype(gen.getTypeUtils().sequential, expr.getTypeModel());\n TypeUtils.printTypeArguments(that, spreadType.getTypeArguments(), gen);\n }\n gen.out(\")\");\n }\n if (arg instanceof Tree.Comprehension) {\n break;\n }\n }\n first = false;\n }\n if (sequencedType != null) {\n gen.closeSequenceWithReifiedType(that,\n gen.getTypeUtils().wrapAsIterableArguments(sequencedType));\n }\n return argvars;\n }\n return Collections.emptyList();\n }\n"} {"input": " public void paint(Graphics g)\n {\n final boolean[] keys = model.getCurrentOctaveKeys();\n final int width = getWidth();\n final int height = getHeight();\n final int fontHeight = g.getFont().getHeight();\n final int whiteKeyWidth = (width - MARGIN * 2) / 7;\n final int whiteKeyHeight = height -\n (MARGIN + KEYS_NOTES_DISTANCE + fontHeight * 2);\n final int blackKeyWidth = whiteKeyWidth / 2; \n final int blackKeyHeight = whiteKeyHeight / 2; \n final int blackKeyNarrowWidth = blackKeyWidth / 2;\n final int whiteKeyNarrowWidth = whiteKeyWidth - blackKeyNarrowWidth;\n final int whiteKeyLesserHeight = whiteKeyHeight - blackKeyHeight;\n g.setColor(WHITE_COLOR);\n g.fillRect(0, 0, width, height);\n final int cx1 = 0 + MARGIN;\n final int cy1 = 0 + MARGIN;\n final int cx2 = cx1 + whiteKeyNarrowWidth;\n final int cy2 = cy1;\n final int cx3 = cx2;\n final int cy3 = cy2 + blackKeyHeight;\n final int cx4 = cx1 + whiteKeyWidth;\n final int cy4 = cy3;\n final int cx5 = cx4;\n final int cy5 = cy1 + whiteKeyHeight;\n final int cx6 = cx1;\n final int cy6 = cy5;\n setKeyColor(g, NOTE_C, keys[NOTE_C]);\n g.fillRect(cx1, cy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(cx3, cy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_C])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(cx1, cy1, cx2, cy2);\n g.drawLine(cx2, cy2, cx3, cy3);\n g.drawLine(cx3, cy3, cx4, cy4);\n g.drawLine(cx4, cy4, cx5, cy5);\n g.drawLine(cx5, cy5, cx6, cy6);\n g.drawLine(cx6, cy6, cx1, cy1);\n }\n final int ccx1 = cx2;\n final int ccy1 = cy2;\n final int ccx2 = ccx1 + blackKeyWidth;\n final int ccy2 = ccy1;\n setKeyColor(g, NOTE_C_SHARP, keys[NOTE_C_SHARP]);\n g.fillRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_C_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n }\n final int dx1 = ccx2;\n final int dy1 = ccy2;\n final int dx2 = dx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int dy2 = dy1;\n final int dx3 = dx2;\n final int dy3 = dy2 + blackKeyHeight;\n final int dx4 = cx4 + whiteKeyWidth;\n final int dy4 = dy3;\n final int dx5 = dx4;\n final int dy5 = dy2 + whiteKeyHeight;\n final int dx6 = cx5;\n final int dy6 = dy5;\n final int dx7 = dx6;\n final int dy7 = dy3;\n final int dx8 = dx1;\n final int dy8 = dy3;\n setKeyColor(g, NOTE_D, keys[NOTE_D]);\n g.fillRect(dx1, dy1, dx2 - dx1, blackKeyHeight);\n g.fillRect(dx7, dy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_D])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(dx1, dy1, dx2, dy2);\n g.drawLine(dx2, dy2, dx3, dy3);\n g.drawLine(dx3, dy3, dx4, dy4);\n g.drawLine(dx4, dy4, dx5, dy5);\n g.drawLine(dx5, dy5, dx6, dy6);\n g.drawLine(dx6, dy6, dx7, dy7);\n g.drawLine(dx7, dy7, dx8, dy8);\n g.drawLine(dx8, dy8, dx1, dy1);\n }\n final int ddx1 = dx2;\n final int ddy1 = dy2;\n final int ddx2 = ddx1 + blackKeyWidth;\n final int ddy2 = ddy1;\n setKeyColor(g, NOTE_D_SHARP, keys[NOTE_D_SHARP]);\n g.fillRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_D_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n }\n final int ex1 = ddx2;\n final int ey1 = ddy2;\n final int ex2 = dx4 + whiteKeyWidth;\n final int ey2 = ey1;\n final int ex3 = ex2;\n final int ey3 = ey2 + whiteKeyHeight;\n final int ex4 = dx5;\n final int ey4 = ey3;\n final int ex5 = ex4;\n final int ey5 = dy4;\n final int ex6 = ex1;\n final int ey6 = ey5;\n setKeyColor(g, NOTE_E, keys[NOTE_E]);\n g.fillRect(ex1, ey1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(ex5, ey5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_E])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ex1, ey1, ex2, ey2);\n g.drawLine(ex2, ey2, ex3, ey3);\n g.drawLine(ex3, ey3, ex4, ey4);\n g.drawLine(ex4, ey4, ex5, ey5);\n g.drawLine(ex5, ey5, ex6, ey6);\n g.drawLine(ex6, ey6, ex1, ey1);\n }\n final int fx1 = ex2;\n final int fy1 = ey2;\n final int fx2 = fx1 + whiteKeyNarrowWidth;\n final int fy2 = fy1;\n final int fx3 = fx2;\n final int fy3 = fy2 + blackKeyHeight;\n final int fx4 = fx1 + whiteKeyWidth;\n final int fy4 = fy3;\n final int fx5 = fx4;\n final int fy5 = fy1 + whiteKeyHeight;\n final int fx6 = fx1;\n final int fy6 = fy5;\n setKeyColor(g, NOTE_F, keys[NOTE_F]);\n g.fillRect(fx1, fy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(fx3, fy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_F])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(fx1, fy1, fx2, fy2);\n g.drawLine(fx2, fy2, fx3, fy3);\n g.drawLine(fx3, fy3, fx4, fy4);\n g.drawLine(fx4, fy4, fx5, fy5);\n g.drawLine(fx5, fy5, fx6, fy6);\n g.drawLine(fx6, fy6, fx1, fy1);\n }\n final int ffx1 = fx2;\n final int ffy1 = fy2;\n final int ffx2 = ffx1 + blackKeyWidth;\n final int ffy2 = ffy1;\n setKeyColor(g, NOTE_F_SHARP, keys[NOTE_F_SHARP]);\n g.fillRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_F_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n }\n final int gx1 = ffx2;\n final int gy1 = ffy2;\n final int gx2 = gx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int gy2 = gy1;\n final int gx3 = gx2;\n final int gy3 = gy2 + blackKeyHeight;\n final int gx4 = fx4 + whiteKeyWidth;\n final int gy4 = gy3;\n final int gx5 = gx4;\n final int gy5 = gy2 + whiteKeyHeight;\n final int gx6 = fx5;\n final int gy6 = gy5;\n final int gx7 = gx6;\n final int gy7 = gy3;\n final int gx8 = gx1;\n final int gy8 = gy3;\n setKeyColor(g, NOTE_G, keys[NOTE_G]);\n g.fillRect(gx1, gy1, gx2 - gx1, blackKeyHeight);\n g.fillRect(gx7, gy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_G])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(gx1, gy1, gx2, gy2);\n g.drawLine(gx2, gy2, gx3, gy3);\n g.drawLine(gx3, gy3, gx4, gy4);\n g.drawLine(gx4, gy4, gx5, gy5);\n g.drawLine(gx5, gy5, gx6, gy6);\n g.drawLine(gx6, gy6, gx7, gy7);\n g.drawLine(gx7, gy7, gx8, gy8);\n g.drawLine(gx8, gy8, gx1, gy1);\n }\n final int ggx1 = gx2;\n final int ggy1 = gy2;\n final int ggx2 = ggx1 + blackKeyWidth;\n final int ggy2 = ggy1;\n setKeyColor(g, NOTE_G_SHARP, keys[NOTE_G_SHARP]);\n g.fillRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_G_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n }\n final int ax1 = ggx2;\n final int ay1 = ggy2;\n final int ax2 = ax1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int ay2 = ay1;\n final int ax3 = ax2;\n final int ay3 = ay2 + blackKeyHeight;\n final int ax4 = gx4 + whiteKeyWidth;\n final int ay4 = ay3;\n final int ax5 = ax4;\n final int ay5 = ay2 + whiteKeyHeight;\n final int ax6 = gx5;\n final int ay6 = ay5;\n final int ax7 = ax6;\n final int ay7 = ay3;\n final int ax8 = ax1;\n final int ay8 = ay3;\n setKeyColor(g, NOTE_A, keys[NOTE_A]);\n g.fillRect(ax1, ay1, ax2 - ax1, blackKeyHeight);\n g.fillRect(ax7, ay7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_A])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ax1, ay1, ax2, ay2);\n g.drawLine(ax2, ay2, ax3, ay3);\n g.drawLine(ax3, ay3, ax4, ay4);\n g.drawLine(ax4, ay4, ax5, ay5);\n g.drawLine(ax5, ay5, ax6, ay6);\n g.drawLine(ax6, ay6, ax7, ay7);\n g.drawLine(ax7, ay7, ax8, ay8);\n g.drawLine(ax8, ay8, ax1, ay1);\n }\n final int aax1 = ax2;\n final int aay1 = ay2;\n final int aax2 = aax1 + blackKeyWidth;\n final int aay2 = aay1;\n setKeyColor(g, NOTE_A_SHARP, keys[NOTE_A_SHARP]);\n g.fillRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n if(keys[PianoNotes.NOTE_A_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n }\n final int hx1 = aax2;\n final int hy1 = aay2;\n final int hx2 = ax4 + whiteKeyWidth;\n final int hy2 = hy1;\n final int hx3 = hx2;\n final int hy3 = hy2 + whiteKeyHeight;\n final int hx4 = ax5;\n final int hy4 = hy3;\n final int hx5 = hx4;\n final int hy5 = ay4;\n final int hx6 = hx1;\n final int hy6 = hy5;\n setKeyColor(g, NOTE_H, keys[NOTE_H]);\n g.fillRect(hx1, hy1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(hx5, hy5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_H])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(hx1, hy1, hx2, hy2);\n g.drawLine(hx2, hy2, hx3, hy3);\n g.drawLine(hx3, hy3, hx4, hy4);\n g.drawLine(hx4, hy4, hx5, hy5);\n g.drawLine(hx5, hy5, hx6, hy6);\n g.drawLine(hx6, hy6, hx1, hy1);\n }\n g.setColor(CONTOUR_COLOR);\n final int dcyw = height;\n final int dcyb = dcyw - fontHeight;\n final int yl = cy6 + 5;\n final int dcylw = dcyb - 2;\n final int dcylb = dcylw - fontHeight;\n final int halfWhiteKeyWidth = whiteKeyWidth / 2;\n final int halfBlackKeyWidth = blackKeyWidth / 2;\n final int dccx1 = cx1 + halfWhiteKeyWidth;\n g.drawChar('1', dccx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dccx1, dcylw, dccx1, yl);\n final int dcccx1 = ccx1 + halfBlackKeyWidth;\n g.drawChar('2', dcccx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcccx1, dcylb, dcccx1, yl);\n final int dcdx1 = dx6 + halfWhiteKeyWidth;\n g.drawChar('3', dcdx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcdx1, dcylw, dcdx1, yl);\n final int dcddx1 = ddx1 + halfBlackKeyWidth;\n g.drawChar('4', dcddx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcddx1, dcylb, dcddx1, yl);\n final int dcex1 = ex4 + halfWhiteKeyWidth;\n g.drawChar('5', dcex1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcex1, dcylw, dcex1, yl);\n final int dcfx1 = fx1 + halfWhiteKeyWidth;\n g.drawChar('6', dcfx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcfx1, dcylw, dcfx1, yl);\n final int dcffx1 = ffx1 + halfBlackKeyWidth;\n g.drawChar('7', dcffx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcffx1, dcylb, dcffx1, yl);\n final int dcgx1 = gx6 + halfWhiteKeyWidth;\n g.drawChar('8', dcgx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcgx1, dcylw, dcgx1, yl);\n final int dcggx1 = ggx1 + halfBlackKeyWidth;\n g.drawChar('9', dcggx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcggx1, dcylb, dcggx1, yl);\n final int dcax1 = ax6 + halfWhiteKeyWidth;\n g.drawChar('*', dcax1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcax1, dcylw, dcax1, yl);\n final int dcaax1 = aax1 + halfBlackKeyWidth;\n g.drawChar('0', dcaax1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcaax1, dcylb, dcaax1, yl);\n final int dchx1 = hx4 + halfWhiteKeyWidth;\n g.drawChar('#', dchx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dchx1, dcylw, dchx1, yl);\n }\n", "output": " public void paint(Graphics g)\n {\n final boolean[] keys = model.getCurrentOctaveKeys();\n final int width = getWidth();\n final int height = getHeight();\n final int fontHeight = g.getFont().getHeight();\n final int whiteKeyWidth = (width - MARGIN * 2) / 7;\n final int whiteKeyHeight = height -\n (MARGIN + KEYS_NOTES_DISTANCE + fontHeight * 2);\n final int blackKeyWidth = whiteKeyWidth / 2; \n final int blackKeyHeight = whiteKeyHeight / 2; \n final int blackKeyNarrowWidth = blackKeyWidth / 2;\n final int whiteKeyNarrowWidth = whiteKeyWidth - blackKeyNarrowWidth;\n final int whiteKeyLesserHeight = whiteKeyHeight - blackKeyHeight;\n g.setColor(WHITE_COLOR);\n g.fillRect(0, 0, width, height);\n final int cx1 = 0 + MARGIN;\n final int cy1 = 0 + MARGIN;\n final int cx2 = cx1 + whiteKeyNarrowWidth;\n final int cy2 = cy1;\n final int cx3 = cx2;\n final int cy3 = cy2 + blackKeyHeight;\n final int cx4 = cx1 + whiteKeyWidth;\n final int cy4 = cy3;\n final int cx5 = cx4;\n final int cy5 = cy1 + whiteKeyHeight;\n final int cx6 = cx1;\n final int cy6 = cy5;\n setKeyColor(g, NOTE_C, keys[NOTE_C]);\n g.fillRect(cx1, cy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(cx3, cy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_C])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(cx1, cy1, cx2, cy2);\n g.drawLine(cx2, cy2, cx3, cy3);\n g.drawLine(cx3, cy3, cx4, cy4);\n g.drawLine(cx4, cy4, cx5, cy5);\n g.drawLine(cx5, cy5, cx6, cy6);\n g.drawLine(cx6, cy6, cx1, cy1);\n }\n final int ccx1 = cx2;\n final int ccy1 = cy2;\n final int ccx2 = ccx1 + blackKeyWidth;\n final int ccy2 = ccy1;\n setKeyColor(g, NOTE_C_SHARP, keys[NOTE_C_SHARP]);\n g.fillRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_C_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ccx1, ccy1, blackKeyWidth, blackKeyHeight);\n }\n final int dx1 = ccx2;\n final int dy1 = ccy2;\n final int dx2 = dx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int dy2 = dy1;\n final int dx3 = dx2;\n final int dy3 = dy2 + blackKeyHeight;\n final int dx4 = cx4 + whiteKeyWidth;\n final int dy4 = dy3;\n final int dx5 = dx4;\n final int dy5 = dy2 + whiteKeyHeight;\n final int dx6 = cx5;\n final int dy6 = dy5;\n final int dx7 = dx6;\n final int dy7 = dy3;\n final int dx8 = dx1;\n final int dy8 = dy3;\n setKeyColor(g, NOTE_D, keys[NOTE_D]);\n g.fillRect(dx1, dy1, dx2 - dx1, blackKeyHeight);\n g.fillRect(dx7, dy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_D])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(dx1, dy1, dx2, dy2);\n g.drawLine(dx2, dy2, dx3, dy3);\n g.drawLine(dx3, dy3, dx4, dy4);\n g.drawLine(dx4, dy4, dx5, dy5);\n g.drawLine(dx5, dy5, dx6, dy6);\n g.drawLine(dx6, dy6, dx7, dy7);\n g.drawLine(dx7, dy7, dx8, dy8);\n g.drawLine(dx8, dy8, dx1, dy1);\n }\n final int ddx1 = dx2;\n final int ddy1 = dy2;\n final int ddx2 = ddx1 + blackKeyWidth;\n final int ddy2 = ddy1;\n setKeyColor(g, NOTE_D_SHARP, keys[NOTE_D_SHARP]);\n g.fillRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_D_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ddx1, ddy1, blackKeyWidth, blackKeyHeight);\n }\n final int ex1 = ddx2;\n final int ey1 = ddy2;\n final int ex2 = dx4 + whiteKeyWidth;\n final int ey2 = ey1;\n final int ex3 = ex2;\n final int ey3 = ey2 + whiteKeyHeight;\n final int ex4 = dx5;\n final int ey4 = ey3;\n final int ex5 = ex4;\n final int ey5 = dy4;\n final int ex6 = ex1;\n final int ey6 = ey5;\n setKeyColor(g, NOTE_E, keys[NOTE_E]);\n g.fillRect(ex1, ey1, whiteKeyNarrowWidth, blackKeyHeight);\n g.fillRect(ex5, ey5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_E])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ex1, ey1, ex2, ey2);\n g.drawLine(ex2, ey2, ex3, ey3);\n g.drawLine(ex3, ey3, ex4, ey4);\n g.drawLine(ex4, ey4, ex5, ey5);\n g.drawLine(ex5, ey5, ex6, ey6);\n g.drawLine(ex6, ey6, ex1, ey1);\n }\n final int fx1 = ex2;\n final int fy1 = ey2;\n final int fx2 = fx1 + whiteKeyNarrowWidth;\n final int fy2 = fy1;\n final int fx3 = fx2;\n final int fy3 = fy2 + blackKeyHeight;\n final int fx4 = fx1 + whiteKeyWidth;\n final int fy4 = fy3;\n final int fx5 = fx4;\n final int fy5 = fy1 + whiteKeyHeight;\n final int fx6 = fx1;\n final int fy6 = fy5;\n setKeyColor(g, NOTE_F, keys[NOTE_F]);\n g.fillRect(fx1, fy1, whiteKeyNarrowWidth, whiteKeyHeight);\n g.fillRect(fx3, fy3, blackKeyNarrowWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_F])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(fx1, fy1, fx2, fy2);\n g.drawLine(fx2, fy2, fx3, fy3);\n g.drawLine(fx3, fy3, fx4, fy4);\n g.drawLine(fx4, fy4, fx5, fy5);\n g.drawLine(fx5, fy5, fx6, fy6);\n g.drawLine(fx6, fy6, fx1, fy1);\n }\n final int ffx1 = fx2;\n final int ffy1 = fy2;\n final int ffx2 = ffx1 + blackKeyWidth;\n final int ffy2 = ffy1;\n setKeyColor(g, NOTE_F_SHARP, keys[NOTE_F_SHARP]);\n g.fillRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_F_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ffx1, ffy1, blackKeyWidth, blackKeyHeight);\n }\n final int gx1 = ffx2;\n final int gy1 = ffy2;\n final int gx2 = gx1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int gy2 = gy1;\n final int gx3 = gx2;\n final int gy3 = gy2 + blackKeyHeight;\n final int gx4 = fx4 + whiteKeyWidth;\n final int gy4 = gy3;\n final int gx5 = gx4;\n final int gy5 = gy2 + whiteKeyHeight;\n final int gx6 = fx5;\n final int gy6 = gy5;\n final int gx7 = gx6;\n final int gy7 = gy3;\n final int gx8 = gx1;\n final int gy8 = gy3;\n setKeyColor(g, NOTE_G, keys[NOTE_G]);\n g.fillRect(gx1, gy1, gx2 - gx1, blackKeyHeight);\n g.fillRect(gx7, gy7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_G])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(gx1, gy1, gx2, gy2);\n g.drawLine(gx2, gy2, gx3, gy3);\n g.drawLine(gx3, gy3, gx4, gy4);\n g.drawLine(gx4, gy4, gx5, gy5);\n g.drawLine(gx5, gy5, gx6, gy6);\n g.drawLine(gx6, gy6, gx7, gy7);\n g.drawLine(gx7, gy7, gx8, gy8);\n g.drawLine(gx8, gy8, gx1, gy1);\n }\n final int ggx1 = gx2;\n final int ggy1 = gy2;\n final int ggx2 = ggx1 + blackKeyWidth;\n final int ggy2 = ggy1;\n setKeyColor(g, NOTE_G_SHARP, keys[NOTE_G_SHARP]);\n g.fillRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n if(keys[NOTE_G_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(ggx1, ggy1, blackKeyWidth, blackKeyHeight);\n }\n final int ax1 = ggx2;\n final int ay1 = ggy2;\n final int ax2 = ax1 + whiteKeyNarrowWidth - blackKeyNarrowWidth;\n final int ay2 = ay1;\n final int ax3 = ax2;\n final int ay3 = ay2 + blackKeyHeight;\n final int ax4 = gx4 + whiteKeyWidth;\n final int ay4 = ay3;\n final int ax5 = ax4;\n final int ay5 = ay2 + whiteKeyHeight;\n final int ax6 = gx5;\n final int ay6 = ay5;\n final int ax7 = ax6;\n final int ay7 = ay3;\n final int ax8 = ax1;\n final int ay8 = ay3;\n setKeyColor(g, NOTE_A, keys[NOTE_A]);\n g.fillRect(ax1, ay1, ax2 - ax1, blackKeyHeight);\n g.fillRect(ax7, ay7, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_A])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(ax1, ay1, ax2, ay2);\n g.drawLine(ax2, ay2, ax3, ay3);\n g.drawLine(ax3, ay3, ax4, ay4);\n g.drawLine(ax4, ay4, ax5, ay5);\n g.drawLine(ax5, ay5, ax6, ay6);\n g.drawLine(ax6, ay6, ax7, ay7);\n g.drawLine(ax7, ay7, ax8, ay8);\n g.drawLine(ax8, ay8, ax1, ay1);\n }\n final int aax1 = ax2;\n final int aay1 = ay2;\n final int aax2 = aax1 + blackKeyWidth;\n final int aay2 = aay1;\n setKeyColor(g, NOTE_A_SHARP, keys[NOTE_A_SHARP]);\n g.fillRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n if(keys[PianoNotes.NOTE_A_SHARP])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawRect(aax1, aay1, blackKeyWidth, blackKeyHeight);\n }\n final int hx1 = aax2;\n final int hy1 = aay2;\n final int hx2 = ax4 + whiteKeyWidth;\n final int hy2 = hy1;\n final int hx3 = hx2;\n final int hy3 = hy2 + whiteKeyHeight;\n final int hx4 = ax5;\n final int hy4 = hy3;\n final int hx5 = hx4;\n final int hy5 = ay4;\n final int hx6 = hx1;\n final int hy6 = hy5;\n setKeyColor(g, NOTE_H, keys[NOTE_H]);\n g.fillRect(hx1, hy1, hx2 - hx1, blackKeyHeight);\n g.fillRect(hx5, hy5, whiteKeyWidth, whiteKeyLesserHeight);\n if(!keys[NOTE_H])\n {\n g.setColor(CONTOUR_COLOR);\n g.drawLine(hx1, hy1, hx2, hy2);\n g.drawLine(hx2, hy2, hx3, hy3);\n g.drawLine(hx3, hy3, hx4, hy4);\n g.drawLine(hx4, hy4, hx5, hy5);\n g.drawLine(hx5, hy5, hx6, hy6);\n g.drawLine(hx6, hy6, hx1, hy1);\n }\n g.setColor(CONTOUR_COLOR);\n final int dcyw = height;\n final int dcyb = dcyw - fontHeight;\n final int yl = cy6 + 5;\n final int dcylw = dcyb - 2;\n final int dcylb = dcylw - fontHeight;\n final int halfWhiteKeyWidth = whiteKeyWidth / 2;\n final int halfBlackKeyWidth = blackKeyWidth / 2;\n final int dccx1 = cx1 + halfWhiteKeyWidth;\n g.drawChar('1', dccx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dccx1, dcylw, dccx1, yl);\n final int dcccx1 = ccx1 + halfBlackKeyWidth;\n g.drawChar('2', dcccx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcccx1, dcylb, dcccx1, yl);\n final int dcdx1 = dx6 + halfWhiteKeyWidth;\n g.drawChar('3', dcdx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcdx1, dcylw, dcdx1, yl);\n final int dcddx1 = ddx1 + halfBlackKeyWidth;\n g.drawChar('4', dcddx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcddx1, dcylb, dcddx1, yl);\n final int dcex1 = ex4 + halfWhiteKeyWidth;\n g.drawChar('5', dcex1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcex1, dcylw, dcex1, yl);\n final int dcfx1 = fx1 + halfWhiteKeyWidth;\n g.drawChar('6', dcfx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcfx1, dcylw, dcfx1, yl);\n final int dcffx1 = ffx1 + halfBlackKeyWidth;\n g.drawChar('7', dcffx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcffx1, dcylb, dcffx1, yl);\n final int dcgx1 = gx6 + halfWhiteKeyWidth;\n g.drawChar('8', dcgx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcgx1, dcylw, dcgx1, yl);\n final int dcggx1 = ggx1 + halfBlackKeyWidth;\n g.drawChar('9', dcggx1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcggx1, dcylb, dcggx1, yl);\n final int dcax1 = ax6 + halfWhiteKeyWidth;\n g.drawChar('*', dcax1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcax1, dcylw, dcax1, yl);\n final int dcaax1 = aax1 + halfBlackKeyWidth;\n g.drawChar('0', dcaax1, dcyb, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dcaax1, dcylb, dcaax1, yl);\n final int dchx1 = hx4 + halfWhiteKeyWidth;\n g.drawChar('#', dchx1, dcyw, Graphics.BOTTOM | Graphics.HCENTER);\n g.drawLine(dchx1, dcylw, dchx1, yl);\n }\n"} {"input": " public Settings(VcsRoot root) throws VcsException {\n final String p = root.getProperty(Constants.PATH);\n repositoryPath = p == null ? null : new File(p);\n branch = root.getProperty(Constants.BRANCH_NAME);\n String username = root.getProperty(Constants.USERNAME);\n String password = root.getProperty(Constants.PASSWORD);\n final String remote = root.getProperty(Constants.URL);\n URIish uri;\n try {\n uri = new URIish(remote);\n } catch (URISyntaxException e) {\n throw new VcsException(\"Invalid URI: \" + remote);\n }\n if (!StringUtil.isEmptyOrSpaces(username)) {\n uri.setUser(username);\n }\n if (!StringUtil.isEmpty(password)) {\n uri.setUser(password);\n }\n publicURL = uri.toString();\n repositoryURL = uri.toPrivateString();\n final String style = root.getProperty(Constants.USERNAME_STYLE);\n usernameStyle = style == null ? UserNameStyle.USERID : Enum.valueOf(UserNameStyle.class, style);\n }\n", "output": " public Settings(VcsRoot root) throws VcsException {\n final String p = root.getProperty(Constants.PATH);\n repositoryPath = p == null ? null : new File(p);\n branch = root.getProperty(Constants.BRANCH_NAME);\n String username = root.getProperty(Constants.USERNAME);\n String password = root.getProperty(Constants.PASSWORD);\n final String remote = root.getProperty(Constants.URL);\n URIish uri;\n try {\n uri = new URIish(remote);\n } catch (URISyntaxException e) {\n throw new VcsException(\"Invalid URI: \" + remote);\n }\n if (!StringUtil.isEmptyOrSpaces(username)) {\n uri = uri.setUser(username);\n }\n if (!StringUtil.isEmpty(password)) {\n uri = uri.setPass(password);\n }\n publicURL = uri.toString();\n repositoryURL = uri.toPrivateString();\n final String style = root.getProperty(Constants.USERNAME_STYLE);\n usernameStyle = style == null ? UserNameStyle.USERID : Enum.valueOf(UserNameStyle.class, style);\n }\n"} {"input": "\tpublic void processCommandPlayer(EntityPlayer sender, String[] args)\n\t{\n\t\tif (args.length == 0)\n\t\t\tthrow new WrongUsageException(\"command.auth.usage\");\n\t\tboolean hasAdmin = PermissionsAPI.checkPermAllowed(new PermQueryPlayer(sender, getCommandPerm() + \".admin\"));\n\t\tif (args.length == 1)\n\t\t{\n\t\t\tif (args[0].equalsIgnoreCase(\"help\"))\n\t\t\t{\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth register <password>\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth login <player>\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth changepass <oldpass> <newpass> - changes your password\");\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\treturn;\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth kick <player> - forces the player to login again\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth setpass <player> <password> - sets the players password\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth unregister <player> - forces the player to register again\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new WrongUsageException(\"command.auth.usage\");\n\t\t}\n\t\tif (args.length == 2)\n\t\t{\n\t\t\tif (args[0].equalsIgnoreCase(\"login\"))\n\t\t\t{\n\t\t\t\tPlayerPassData data = PlayerPassData.getData(sender.username);\n\t\t\t\tif (data == null)\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.format(\"message.auth.error.notregisterred\", sender.username));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString pass = ModuleAuth.encrypt(args[1]);\n\t\t\t\tif (data.password.equals(pass))\n\t\t\t\t{\n\t\t\t\t\tModuleAuth.unLogged.remove(sender.username);\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.login.success\"));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"command.auth.login.fail\"));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (args[0].equalsIgnoreCase(\"register\"))\n\t\t\t{\n\t\t\t\tif (PlayerPassData.getData(sender.username) != null)\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.format(\"message.auth.error.yesregisterred\", sender.username));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (ModuleAuth.isEnabled() && !ModuleAuth.allowOfflineReg)\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.format(\"message.auth.error.disabledreg\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString pass = ModuleAuth.encrypt(args[1]);\n\t\t\t\tPlayerPassData.registerData(sender.username, pass);\n\t\t\t\tModuleAuth.unRegistered.remove(sender.username);\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.register.success\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (ModuleAuth.unLogged.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needlogin\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (ModuleAuth.unRegistered.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needregister\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tString name = args[1];\n\t\t\tboolean isLogged = true;\n\t\t\tEntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name);\n\t\t\tif (player == null)\n\t\t\t{\n\t\t\t\tOutputHandler.chatWarning(sender, \"A player of that name is not on the server. Doing the action anyways.\");\n\t\t\t\tisLogged = false;\n\t\t\t}\n\t\t\tif (args[0].equalsIgnoreCase(\"kick\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\telse if (!isLogged)\n\t\t\t\t\tthrow new PlayerNotFoundException();\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tModuleAuth.unLogged.add(name);\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.format(\"command.auth.kick.user\", name));\n\t\t\t\t\tOutputHandler.chatWarning(player, Localization.get(\"command.auth.kick.target\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (args[0].equalsIgnoreCase(\"setPass\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\tthrow new WrongUsageException(\"command.auth.usage.setpass\");\n\t\t\t}\n\t\t\telse if (args[0].equalsIgnoreCase(\"unregister\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\tif (PlayerPassData.getData(name) == null)\n\t\t\t\t\tthrow new WrongUsageException(\"message.auth.error.notregisterred\", name);\n\t\t\t\tPlayerPassData.deleteData(name);\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.format(\"command.auth.unregister\", name));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new WrongUsageException(\"command.auth.usage\");\n\t\t}\n\t\telse if (args.length == 3)\n\t\t{\n\t\t\tif (ModuleAuth.unLogged.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needlogin\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (ModuleAuth.unRegistered.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needregister\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (args[0].equalsIgnoreCase(\"changepass\"))\n\t\t\t{\n\t\t\t\tPlayerPassData data = PlayerPassData.getData(sender.username);\n\t\t\t\tString oldpass = ModuleAuth.encrypt(args[1]);\n\t\t\t\tString newPass = ModuleAuth.encrypt(args[2]);\n\t\t\t\tif (args[1].equals(args[2]))\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.change.same\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!data.password.equals(oldpass))\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.change.wrongpass\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdata.password = newPass;\n\t\t\t\tdata.save();\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.change.success\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tString name = args[1];\n\t\t\tEntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name);\n\t\t\tif (player == null)\n\t\t\t{\n\t\t\t\tOutputHandler.chatWarning(sender, \"A player of that name is not on the server. Doing the action anyways.\");\n\t\t\t}\n\t\t\tif (args[0].equalsIgnoreCase(\"setPass\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\tPlayerPassData data = PlayerPassData.getData(name);\n\t\t\t\tString encrypted = ModuleAuth.encrypt(args[2]);\n\t\t\t\tif (data == null)\n\t\t\t\t{\n\t\t\t\t\tPlayerPassData.registerData(name, encrypted);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdata.password = encrypted;\n\t\t\t\t\tdata.save();\n\t\t\t\t}\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.format(\"command.auth.setPass\", name));\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void processCommandPlayer(EntityPlayer sender, String[] args)\n\t{\n\t\tif (args.length == 0)\n\t\t\tthrow new WrongUsageException(\"command.auth.usage\");\n\t\tboolean hasAdmin = PermissionsAPI.checkPermAllowed(new PermQueryPlayer(sender, getCommandPerm() + \".admin\"));\n\t\tif (args.length == 1)\n\t\t{\n\t\t\tif (args[0].equalsIgnoreCase(\"help\"))\n\t\t\t{\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth register <password>\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth login <password>\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth changepass <oldpass> <newpass> - changes your password\");\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\treturn;\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth kick <player> - forces the player to login again\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth setpass <player> <password> - sets the players password\");\n\t\t\t\tOutputHandler.chatConfirmation(sender, \" - /auth unregister <player> - forces the player to register again\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new WrongUsageException(\"command.auth.usage\");\n\t\t}\n\t\tif (args.length == 2)\n\t\t{\n\t\t\tif (args[0].equalsIgnoreCase(\"login\"))\n\t\t\t{\n\t\t\t\tPlayerPassData data = PlayerPassData.getData(sender.username);\n\t\t\t\tif (data == null)\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.format(\"message.auth.error.notregisterred\", sender.username));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString pass = ModuleAuth.encrypt(args[1]);\n\t\t\t\tif (data.password.equals(pass))\n\t\t\t\t{\n\t\t\t\t\tModuleAuth.unLogged.remove(sender.username);\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.login.success\"));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"command.auth.login.fail\"));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (args[0].equalsIgnoreCase(\"register\"))\n\t\t\t{\n\t\t\t\tif (PlayerPassData.getData(sender.username) != null)\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.format(\"message.auth.error.yesregisterred\", sender.username));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (ModuleAuth.isEnabled() && !ModuleAuth.allowOfflineReg)\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatError(sender, Localization.format(\"message.auth.error.disabledreg\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tString pass = ModuleAuth.encrypt(args[1]);\n\t\t\t\tPlayerPassData.registerData(sender.username, pass);\n\t\t\t\tModuleAuth.unRegistered.remove(sender.username);\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.register.success\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (ModuleAuth.unLogged.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needlogin\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (ModuleAuth.unRegistered.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needregister\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tString name = args[1];\n\t\t\tboolean isLogged = true;\n\t\t\tEntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name);\n\t\t\tif (player == null)\n\t\t\t{\n\t\t\t\tOutputHandler.chatWarning(sender, \"A player of that name is not on the server. Doing the action anyways.\");\n\t\t\t\tisLogged = false;\n\t\t\t}\n\t\t\tif (args[0].equalsIgnoreCase(\"kick\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\telse if (!isLogged)\n\t\t\t\t\tthrow new PlayerNotFoundException();\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tModuleAuth.unLogged.add(name);\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.format(\"command.auth.kick.user\", name));\n\t\t\t\t\tOutputHandler.chatWarning(player, Localization.get(\"command.auth.kick.target\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (args[0].equalsIgnoreCase(\"setPass\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\tthrow new WrongUsageException(\"command.auth.usage.setpass\");\n\t\t\t}\n\t\t\telse if (args[0].equalsIgnoreCase(\"unregister\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\tif (PlayerPassData.getData(name) == null)\n\t\t\t\t\tthrow new WrongUsageException(\"message.auth.error.notregisterred\", name);\n\t\t\t\tPlayerPassData.deleteData(name);\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.format(\"command.auth.unregister\", name));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow new WrongUsageException(\"command.auth.usage\");\n\t\t}\n\t\telse if (args.length == 3)\n\t\t{\n\t\t\tif (ModuleAuth.unLogged.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needlogin\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse if (ModuleAuth.unRegistered.contains(sender.username))\n\t\t\t{\n\t\t\t\tOutputHandler.chatError(sender, Localization.get(\"message.auth.needregister\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (args[0].equalsIgnoreCase(\"changepass\"))\n\t\t\t{\n\t\t\t\tPlayerPassData data = PlayerPassData.getData(sender.username);\n\t\t\t\tString oldpass = ModuleAuth.encrypt(args[1]);\n\t\t\t\tString newPass = ModuleAuth.encrypt(args[2]);\n\t\t\t\tif (args[1].equals(args[2]))\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.change.same\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!data.password.equals(oldpass))\n\t\t\t\t{\n\t\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.change.wrongpass\"));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tdata.password = newPass;\n\t\t\t\tdata.save();\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.get(\"command.auth.change.success\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tString name = args[1];\n\t\t\tEntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name);\n\t\t\tif (player == null)\n\t\t\t{\n\t\t\t\tOutputHandler.chatWarning(sender, \"A player of that name is not on the server. Doing the action anyways.\");\n\t\t\t}\n\t\t\tif (args[0].equalsIgnoreCase(\"setPass\"))\n\t\t\t{\n\t\t\t\tif (!hasAdmin)\n\t\t\t\t\tthrow new PermissionDeniedException();\n\t\t\t\tPlayerPassData data = PlayerPassData.getData(name);\n\t\t\t\tString encrypted = ModuleAuth.encrypt(args[2]);\n\t\t\t\tif (data == null)\n\t\t\t\t{\n\t\t\t\t\tPlayerPassData.registerData(name, encrypted);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tdata.password = encrypted;\n\t\t\t\t\tdata.save();\n\t\t\t\t}\n\t\t\t\tOutputHandler.chatConfirmation(sender, Localization.format(\"command.auth.setPass\", name));\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic void testSearchResultToRobotUrlStrings() {\n\t\tRobotExclusionFilter f = new RobotExclusionFilter(null,\"\",100);\n\t\tString test1[] = {\"www.foo.com\",\"foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www.foo.com\", HTTP_PREFIX),test1);\n\t\tString test2[] = {\"foo.com\",\"www.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"foo.com\", HTTP_PREFIX),test2);\n\t\tString test3[] = {\"fool.foo.com\",\"www.fool.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"fool.foo.com\", HTTP_PREFIX),test3);\n\t\tString test4[] = {\"www4.foo.com\",\"www.foo.com\",\"foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www4.foo.com\", HTTP_PREFIX),test4);\n\t\tString test5[] = {\"www4w.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www4w.foo.com\", HTTP_PREFIX),test5);\n\t\tString test6[] = {\"www.www.foo.com\",\"www.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www.www.foo.com\", HTTP_PREFIX),test6);\n\t}\n", "output": "\tpublic void testSearchResultToRobotUrlStrings() {\n\t\tRobotExclusionFilter f = new RobotExclusionFilter(null,\"\",100);\n\t\tString test1[] = {\"www.foo.com\",\"foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www.foo.com\", HTTP_PREFIX),test1);\n\t\tString test2[] = {\"www.foo.com\",\"foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"foo.com\", HTTP_PREFIX),test2);\n\t\tString test3[] = {\"www.fool.foo.com\",\"fool.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"fool.foo.com\", HTTP_PREFIX),test3);\n\t\tString test4[] = {\"www.foo.com\",\"foo.com\", \"www4.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www4.foo.com\", HTTP_PREFIX),test4);\n\t\tString test5[] = {\"www4w.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www4w.foo.com\", HTTP_PREFIX),test5);\n\t\tString test6[] = {\"www.www.foo.com\",\"www.foo.com\"};\n\t\tcompareListTo(f.searchResultToRobotUrlStrings(\"www.www.foo.com\", HTTP_PREFIX),test6);\n\t}\n"} {"input": "\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tIWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);\n\t\tfinal Set<IMavenProjectFacade> facades = getSelectedMavenProjects(event);\n\t\tif (!facades.isEmpty() ) {\n\t\t\tSystem.out.print(\"Select projects \"+facades);\n\t\t\tfinal IProfileManager profileManager = MavenCoreActivator.getDefault().getProfileManager();\n\t\t\tfinal List<ProfileSelection> sharedProfiles;\n\t\t\tfinal Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles;\n\t\t\ttry {\n\t\t\t\tallProfiles = getAllProfiles(facades, profileManager);\n\t\t\t\tsharedProfiles = getSharedProfiles(allProfiles);\n\t\t\t} catch (CoreException e) {\n\t\t\t\tthrow new ExecutionException(\"Unable to open the Maven Profile selection dialog\", e);\n\t\t\t}\n\t\t\tfinal SelectProfilesDialog dialog = new SelectProfilesDialog(window.getShell(), \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfacades, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsharedProfiles);\n\t\t if(dialog.open() == Window.OK) {\n\t\t\t\tWorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles) {\n\t\t\t\t\tpublic IStatus runInWorkspace(IProgressMonitor monitor) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tfor (Map.Entry<IMavenProjectFacade, List<ProfileStatus>> entry : allProfiles.entrySet()){\n\t\t\t\t\t\t\t\tIMavenProjectFacade facade = entry.getKey();\n\t\t\t\t\t\t\t\tList<String> activeProfiles = getActiveProfiles(sharedProfiles, entry.getValue());\n\t\t\t\t\t\t\t\tprofileManager.updateActiveProfiles(facade, activeProfiles, \n\t\t\t\t\t\t\t\t\tdialog.isOffline(), dialog.isForceUpdate(), monitor); \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (CoreException ex) {\n\t\t\t\t\t\t\tActivator.log(ex);\n\t\t\t\t\t\t\treturn ex.getStatus();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Status.OK_STATUS;\n\t\t\t\t\t}\n\t\t\t\t\tprivate List<String> getActiveProfiles(\n\t\t\t\t\t\t\tList<ProfileSelection> sharedProfiles,\n\t\t\t\t\t\t\tList<ProfileStatus> availableProfiles) {\n\t\t\t\t\t\tList<String> ids = new ArrayList<String>();\n\t\t\t\t\t\tfor (ProfileStatus st : availableProfiles) {\n\t\t\t\t\t\t\tProfileSelection selection = findSelectedProfile(st.getId(), sharedProfiles);\n\t\t\t\t\t\t\tString id = null;\n\t\t\t\t\t\t\tboolean isDisabled = false;\n\t\t\t\t\t\t\tif (selection == null) {\n\t\t\t\t\t\t\t\tif (st.isUserSelected()) {\n\t\t\t\t\t\t\t\t\tid = st.getId();\n\t\t\t\t\t\t\t\t\tisDisabled = st.getActivationState().equals(ProfileState.Disabled);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (null == selection.getSelected()) {\n\t\t\t\t\t\t\t\t\tif (st.isUserSelected()) {\n\t\t\t\t\t\t\t\t\t\tid = st.getId();\n\t\t\t\t\t\t\t\t\t\tisDisabled = st.getActivationState().equals(ProfileState.Disabled);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (Boolean.TRUE.equals(selection.getSelected())) {\n\t\t\t\t\t\t\t\t\t\tid = st.getId();\n\t\t\t\t\t\t\t\t\t\tisDisabled = st.getActivationState().equals(ProfileState.Disabled);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (id != null) {\n\t\t\t\t\t\t\t\tif (isDisabled) {\n\t\t\t\t\t\t\t\t\tid = \"!\"+id;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tids.add(id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ids;\n\t\t\t\t\t}\n\t\t\t\t\tprivate ProfileSelection findSelectedProfile(String id,\n\t\t\t\t\t\t\tList<ProfileSelection> sharedProfiles) {\n\t\t\t\t\t\tfor (ProfileSelection sel : sharedProfiles) {\n\t\t\t\t\t\t\tif (id.equals(sel.getId())) {\n\t\t\t\t\t\t\t\treturn sel;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tjob.setRule( MavenPlugin.getProjectConfigurationManager().getRule());\n\t\t\t\tjob.schedule();\n\t\t }\t\t\n\t\t}\n\t return null;\n\t}\n", "output": "\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tIWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);\n\t\tfinal Set<IMavenProjectFacade> facades = getSelectedMavenProjects(event);\n\t\tif (!facades.isEmpty() ) {\n\t\t\tSystem.out.print(\"Select projects \"+facades);\n\t\t\tfinal IProfileManager profileManager = MavenCoreActivator.getDefault().getProfileManager();\n\t\t\tfinal List<ProfileSelection> sharedProfiles;\n\t\t\tfinal Map<IMavenProjectFacade, List<ProfileStatus>> allProfiles;\n\t\t\ttry {\n\t\t\t\tallProfiles = getAllProfiles(facades, profileManager);\n\t\t\t\tsharedProfiles = getSharedProfiles(allProfiles);\n\t\t\t} catch (CoreException e) {\n\t\t\t\tthrow new ExecutionException(\"Unable to open the Maven Profile selection dialog\", e);\n\t\t\t}\n\t\t\tfinal SelectProfilesDialog dialog = new SelectProfilesDialog(window.getShell(), \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfacades, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsharedProfiles);\n\t\t if(dialog.open() == Window.OK) {\n\t\t\t\tWorkspaceJob job = new WorkspaceJob(Messages.ProfileManager_Updating_maven_profiles) {\n\t\t\t\t\tpublic IStatus runInWorkspace(IProgressMonitor monitor) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tfor (Map.Entry<IMavenProjectFacade, List<ProfileStatus>> entry : allProfiles.entrySet()){\n\t\t\t\t\t\t\t\tIMavenProjectFacade facade = entry.getKey();\n\t\t\t\t\t\t\t\tList<String> activeProfiles = getActiveProfiles(sharedProfiles, entry.getValue());\n\t\t\t\t\t\t\t\tprofileManager.updateActiveProfiles(facade, activeProfiles, \n\t\t\t\t\t\t\t\t\tdialog.isOffline(), dialog.isForceUpdate(), monitor); \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (CoreException ex) {\n\t\t\t\t\t\t\tActivator.log(ex);\n\t\t\t\t\t\t\treturn ex.getStatus();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn Status.OK_STATUS;\n\t\t\t\t\t}\n\t\t\t\t\tprivate List<String> getActiveProfiles(\n\t\t\t\t\t\t\tList<ProfileSelection> sharedProfiles,\n\t\t\t\t\t\t\tList<ProfileStatus> availableProfiles) {\n\t\t\t\t\t\tList<String> ids = new ArrayList<String>();\n\t\t\t\t\t\tfor (ProfileStatus st : availableProfiles) {\n\t\t\t\t\t\t\tProfileSelection selection = findSelectedProfile(st.getId(), sharedProfiles);\n\t\t\t\t\t\t\tString id = null;\n\t\t\t\t\t\t\tboolean isDisabled = false;\n\t\t\t\t\t\t\tif (selection == null) {\n\t\t\t\t\t\t\t\tif (st.isUserSelected()) {\n\t\t\t\t\t\t\t\t\tid = st.getId();\n\t\t\t\t\t\t\t\t\tisDisabled = st.getActivationState().equals(ProfileState.Disabled);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (null == selection.getSelected()) {\n\t\t\t\t\t\t\t\t\tif (st.isUserSelected()) {\n\t\t\t\t\t\t\t\t\t\tid = st.getId();\n\t\t\t\t\t\t\t\t\t\tisDisabled = st.getActivationState().equals(ProfileState.Disabled);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (Boolean.TRUE.equals(selection.getSelected())) {\n\t\t\t\t\t\t\t\t\t\tid = selection.getId();\n\t\t\t\t\t\t\t\t\t\tisDisabled = selection.getActivationState().equals(ProfileState.Disabled);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (id != null) {\n\t\t\t\t\t\t\t\tif (isDisabled) {\n\t\t\t\t\t\t\t\t\tid = \"!\"+id;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tids.add(id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ids;\n\t\t\t\t\t}\n\t\t\t\t\tprivate ProfileSelection findSelectedProfile(String id,\n\t\t\t\t\t\t\tList<ProfileSelection> sharedProfiles) {\n\t\t\t\t\t\tfor (ProfileSelection sel : sharedProfiles) {\n\t\t\t\t\t\t\tif (id.equals(sel.getId())) {\n\t\t\t\t\t\t\t\treturn sel;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tjob.setRule( MavenPlugin.getProjectConfigurationManager().getRule());\n\t\t\t\tjob.schedule();\n\t\t }\t\t\n\t\t}\n\t return null;\n\t}\n"} {"input": " public void processField(final FilterFieldDataBase<?> field) {\n final String fieldName = field.getBaseName();\n if (fieldName.equals(CommonFilterConstants.PROPERTY_TAG_EXISTS)) {\n final FilterFieldBooleanMapData mapField = (FilterFieldBooleanMapData) field;\n for (final Map.Entry<Integer, Boolean> entry : mapField.getData().entrySet()) {\n final Integer propertyTagId = entry.getKey();\n final Boolean fieldValueBoolean = entry.getValue();\n if (propertyTagId != null && fieldValueBoolean) {\n addFieldCondition(getCriteriaBuilder().exists(getPropertyTagExistsSubquery(propertyTagId)));\n }\n }\n } else if (fieldName.startsWith(CommonFilterConstants.PROPERTY_TAG_NOT_EXISTS)) {\n final FilterFieldBooleanMapData mapField = (FilterFieldBooleanMapData) field;\n for (final Map.Entry<Integer, Boolean> entry : mapField.getData().entrySet()) {\n final Integer propertyTagId = entry.getKey();\n final Boolean fieldValueBoolean = entry.getValue();\n if (propertyTagId != null && fieldValueBoolean) {\n addFieldCondition(getCriteriaBuilder().not(getCriteriaBuilder().exists(getPropertyTagExistsSubquery(propertyTagId))));\n }\n }\n } else if (fieldName.startsWith(CommonFilterConstants.PROPERTY_TAG)) {\n final FilterFieldStringMapData mapField = (FilterFieldStringMapData) field;\n for (final Map.Entry<Integer, String> entry : mapField.getData().entrySet()) {\n final Integer propertyTagId = entry.getKey();\n final String fieldValue = entry.getValue();\n if (propertyTagId != null && fieldValue != null) {\n addExistsCondition(getPropertyTagSubquery(propertyTagId, (String) field.getData()));\n }\n }\n } else {\n super.processField(field);\n }\n }\n", "output": " public void processField(final FilterFieldDataBase<?> field) {\n final String fieldName = field.getBaseName();\n if (fieldName.equals(CommonFilterConstants.PROPERTY_TAG_EXISTS)) {\n final FilterFieldBooleanMapData mapField = (FilterFieldBooleanMapData) field;\n for (final Map.Entry<Integer, Boolean> entry : mapField.getData().entrySet()) {\n final Integer propertyTagId = entry.getKey();\n final Boolean fieldValueBoolean = entry.getValue();\n if (propertyTagId != null && fieldValueBoolean) {\n addFieldCondition(getCriteriaBuilder().exists(getPropertyTagExistsSubquery(propertyTagId)));\n }\n }\n } else if (fieldName.startsWith(CommonFilterConstants.PROPERTY_TAG_NOT_EXISTS)) {\n final FilterFieldBooleanMapData mapField = (FilterFieldBooleanMapData) field;\n for (final Map.Entry<Integer, Boolean> entry : mapField.getData().entrySet()) {\n final Integer propertyTagId = entry.getKey();\n final Boolean fieldValueBoolean = entry.getValue();\n if (propertyTagId != null && fieldValueBoolean) {\n addFieldCondition(getCriteriaBuilder().not(getCriteriaBuilder().exists(getPropertyTagExistsSubquery(propertyTagId))));\n }\n }\n } else if (fieldName.startsWith(CommonFilterConstants.PROPERTY_TAG)) {\n final FilterFieldStringMapData mapField = (FilterFieldStringMapData) field;\n for (final Map.Entry<Integer, String> entry : mapField.getData().entrySet()) {\n final Integer propertyTagId = entry.getKey();\n final String fieldValue = entry.getValue();\n if (propertyTagId != null && fieldValue != null) {\n addExistsCondition(getPropertyTagSubquery(propertyTagId, fieldValue));\n }\n }\n } else {\n super.processField(field);\n }\n }\n"} {"input": " public boolean prepareData() throws VisADException, RemoteException {\n int[] indices;\n int[] display_indices;\n int[] value_indices;\n int levelOfDifficulty;\n data = ((DataReference) ref).getData();\n if (data == null) {\n renderer.addException(\n new DisplayException(\"DataDisplayLink.prepareData: Data is null\"));\n return false;\n }\n MathType type = data.getType();\n SelectedMapVector.removeAllElements();\n int n = ((DisplayImpl) local_action).getDisplayScalarCount();\n defaultValues = new float[n];\n for (int i=0; i<n; i++) {\n defaultValues[i] = (float) (((DisplayRealType)\n ((DisplayImpl) local_action).getDisplayScalar(i)).getDefaultValue());\n }\n Vector temp =\n (Vector) ((DisplayImpl) local_action).getConstantMapVector().clone();\n Enumeration maps = temp.elements();\n while(maps.hasMoreElements()) {\n ConstantMap map = (ConstantMap) maps.nextElement();\n defaultValues[map.getDisplayScalarIndex()] = (float) map.getConstant();\n }\n maps =((Vector) ConstantMapVector.clone()).elements();\n while(maps.hasMoreElements()) {\n ConstantMap map = (ConstantMap) maps.nextElement();\n defaultValues[map.getDisplayScalarIndex()] = (float) map.getConstant();\n }\n try {\n renderer.clearExceptions();\n shadow = type.buildShadowType(this, null);\n ShadowType adaptedShadow = shadow.getAdaptedShadowType();\n indices = ShadowType.zeroIndices(\n ((DisplayImpl) local_action).getScalarCount());\n display_indices = ShadowType.zeroIndices(\n ((DisplayImpl) local_action).getDisplayScalarCount());\n value_indices = ShadowType.zeroIndices(\n ((DisplayImpl) local_action).getValueArrayLength());\n Vector controls = ((DisplayImpl) local_action).getControlVector();\n isTransform = new boolean[controls.size()];\n for (int i=0; i<controls.size(); i++) isTransform[i] = false;\n levelOfDifficulty =\n shadow.checkIndices(indices, display_indices, value_indices,\n isTransform, ShadowType.NOTHING_MAPPED);\n if (levelOfDifficulty == ShadowType.LEGAL) {\n for (int i=0; i<controls.size(); i++) isTransform[i] = true;\n }\n renderer.checkDirect();\n }\n catch (BadMappingException e) {\n data = null;\n renderer.addException(e);\n return false;\n }\n catch (UnimplementedException e) {\n data = null;\n renderer.addException(e);\n return false;\n }\n catch (RemoteException e) {\n data = null;\n renderer.addException(e);\n return false;\n }\n return true;\n }\n", "output": " public boolean prepareData() throws VisADException, RemoteException {\n int[] indices;\n int[] display_indices;\n int[] value_indices;\n int levelOfDifficulty;\n data = ((DataReference) ref).getData();\n if (data == null) {\n renderer.clearExceptions();\n renderer.addException(\n new DisplayException(\"DataDisplayLink.prepareData: Data is null\"));\n return false;\n }\n MathType type = data.getType();\n SelectedMapVector.removeAllElements();\n int n = ((DisplayImpl) local_action).getDisplayScalarCount();\n defaultValues = new float[n];\n for (int i=0; i<n; i++) {\n defaultValues[i] = (float) (((DisplayRealType)\n ((DisplayImpl) local_action).getDisplayScalar(i)).getDefaultValue());\n }\n Vector temp =\n (Vector) ((DisplayImpl) local_action).getConstantMapVector().clone();\n Enumeration maps = temp.elements();\n while(maps.hasMoreElements()) {\n ConstantMap map = (ConstantMap) maps.nextElement();\n defaultValues[map.getDisplayScalarIndex()] = (float) map.getConstant();\n }\n maps =((Vector) ConstantMapVector.clone()).elements();\n while(maps.hasMoreElements()) {\n ConstantMap map = (ConstantMap) maps.nextElement();\n defaultValues[map.getDisplayScalarIndex()] = (float) map.getConstant();\n }\n try {\n renderer.clearExceptions();\n shadow = type.buildShadowType(this, null);\n ShadowType adaptedShadow = shadow.getAdaptedShadowType();\n indices = ShadowType.zeroIndices(\n ((DisplayImpl) local_action).getScalarCount());\n display_indices = ShadowType.zeroIndices(\n ((DisplayImpl) local_action).getDisplayScalarCount());\n value_indices = ShadowType.zeroIndices(\n ((DisplayImpl) local_action).getValueArrayLength());\n Vector controls = ((DisplayImpl) local_action).getControlVector();\n isTransform = new boolean[controls.size()];\n for (int i=0; i<controls.size(); i++) isTransform[i] = false;\n levelOfDifficulty =\n shadow.checkIndices(indices, display_indices, value_indices,\n isTransform, ShadowType.NOTHING_MAPPED);\n if (levelOfDifficulty == ShadowType.LEGAL) {\n for (int i=0; i<controls.size(); i++) isTransform[i] = true;\n }\n renderer.checkDirect();\n }\n catch (BadMappingException e) {\n data = null;\n renderer.addException(e);\n return false;\n }\n catch (UnimplementedException e) {\n data = null;\n renderer.addException(e);\n return false;\n }\n catch (RemoteException e) {\n data = null;\n renderer.addException(e);\n return false;\n }\n return true;\n }\n"} {"input": "\tprivate void run() {\n\t\tString[] bgColors = { \"#DDDDDD\", \"#EEEEEE\" };\n\t\tString outFile = null;\n\t\tPrintStream ps = null;\n\t\tfor (int s = 0; s < scenarios.length; s++) {\n\t\t\tArrayList pointsOfInterest=new ArrayList();\n\t\t\tScenario t = scenarios[s];\n\t\t\tIterator iterator = this.pointsOfInterest.iterator();\n\t\t\twhile (iterator.hasNext()){\n\t\t\t\tString match=getMostRecentMatchingBuildID(t,iterator.next().toString());\n\t\t\t\t\tif (match!=null)\n\t\t\t\t\t\tpointsOfInterest.add(match);\n\t\t\t}\n\t\t\tint []buildNameIndeces={-1,-1};\n\t\t\tbuildNameIndeces[0]=Utils.getBuildNameIndex(t.getTimeSeriesLabels(),current);\n\t\t\tbuildNameIndeces[1]=Utils.getBuildNameIndex(t.getTimeSeriesLabels(),reference);\n\t\t\tif (Utils.getBuildNameIndex(t.getTimeSeriesLabels(),current)==-1) {\n\t\t\t\tcontinue;\n\t\t\t} \n\t\t\tString scenarioFileName=t.getScenarioName().replace('#', '.').replace(':', '_')\n\t\t\t.replace('\\\\', '_');\n\t\t\toutFile = resultsFolder\n\t\t\t\t\t+ \"/\"\n\t\t\t\t\t+ scenarioFileName + \".html\";\n\t\t\tif (outFile != null) {\n\t\t\t\ttry {\n\t\t\t\t\tnew File(outFile).getParentFile().mkdirs();\n\t\t\t\t\tps = new PrintStream(new BufferedOutputStream(\n\t\t\t\t\t\t\tnew FileOutputStream(outFile)));\n\t\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\t\tSystem.err.println(\"can't create output file\" + outFile); \n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ps == null)\n\t\t\t\tps = System.out;\n\t\t\tps.println(Utils.HTML_OPEN);\n\t\t\tps.println(Utils.HTML_DEFAULT_CSS);\n\t\t\tps.println(\"<title>\"+t.getScenarioName() + \"(\"+configName+\")\"+\"\"); \n\t\t\tps.println(\"

Scenario: \" + t.getScenarioName() + \" (\"+configName+\")


\"); \n\t\t\tps.println(\"Click measurement name to view line graph of measured values over builds. \" +\n\t\t\t\t\t\"Magenta, black and yellow dots are used to denote release or milestone, integration, and nightly builds, respectively.

\");\n\t\t\tps.println(\"\"); \n\t\t\tDim[] dimensions = filteredDimensions( t.getDimensions());\n\t\t\ttry {\n\t\t\t\tps.println(\"\"); \n\t\t\t\tfor (int i = 0; i < dimensions.length; i++) {\n\t\t\t\t\tDim dim = dimensions[i];\n\t\t\t\t\tString dimName=dim.getName();\n\t\t\t\t\tps.println(\"\");\n\t\t\t\t}\n\t\t\t\tps.print(\"\\n\");\n\t\t\t\tdouble [][] diffValues=new double [2][dimensions.length];\n\t\t\t\tboolean [] refValueExistance=new boolean[dimensions.length];\n\t\t\t\tfor (int j = 0; j < 2; j++) {\n\t\t\t\t\tString referenceIndicator = (j == 1) ? \"(reference)\" : \"\";\n\t\t\t\t\tString buildName = ((buildNameIndeces[j] == -1) ? \"n/a\" : t\n\t\t\t\t\t\t\t.getTimeSeriesLabels()[buildNameIndeces[j]])\n\t\t\t\t\t\t\t+ referenceIndicator;\n\t\t\t\t\tps.print(\"\");\n\t\t\t\t\tfor (int i = 0; i < dimensions.length; i++) {\n\t\t\t\t\t\tDim dim = dimensions[i];\n\t\t\t\t\t\tString dimName=dim.getName();\n\t\t\t\t\t\tTimeSeries ts = t.getTimeSeries(dim);\n\t\t\t\t\t\tif (j==1&&buildNameIndeces[j]!=-1)\n\t\t\t\t\t\t\trefValueExistance[i]=true;\n\t\t\t\t\t\tif (buildNameIndeces[j] != -1)\n\t\t\t\t\t\t\tdiffValues[j][i]=ts.getValue(buildNameIndeces[j]);\n\t\t\t\t\t\tString displayValue = (buildNameIndeces[j] == -1) ? \"n/a\"\n\t\t\t\t\t\t\t\t: dim.getDisplayValue(ts\n\t\t\t\t\t\t\t\t\t\t.getValue(buildNameIndeces[j]));\n\t\t\t\t\t\tString stddev = (buildNameIndeces[j] == -1) ? \"0\" : dim\n\t\t\t\t\t\t\t\t.getDisplayValue(ts\n\t\t\t\t\t\t\t\t\t\t.getStddev(buildNameIndeces[j]));\n\t\t\t\t\t\tif (stddev.startsWith(\"0 \") || stddev.equals(\"0\"))\n\t\t\t\t\t\t\tps.println(\"\");\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tps.println(\"\");\n\t\t\t\t\t}\n\t\t\t\t\tps.print(\"\");\n\t\t\t\t}\n\t\t\t\tps.println(getDiffs(diffValues,dimensions,refValueExistance));\n\t\t\t\tps.println();\n\t\t\t\tps.println(\"
Build Id\" + dimName\n\t\t\t\t\t\t\t+ \"
\" + buildName + \"\" + displayValue + \"\" + displayValue + \" [\" + stddev\n\t\t\t\t\t\t\t\t\t+ \"]\" + \"
\");\n\t\t\t\tps.println(\"*Delta values in red and green indicate degradation > 10% and improvement > 10%,respectively.

\");\n\t\t\t\tps.println(\"

\\n\");\n\t\t\t\tfor (int i = 0; i < dimensions.length; i++) {\n\t\t\t\t\tDim dim = dimensions[i];\n\t\t\t\t\tString dimName=dim.getName();\n\t\t\t\t\tLineGraph lg=Utils.getLineGraph(t,dim.getName(),reference,current,pointsOfInterest);\n\t\t\t\t\tString lgImg=resultsFolder+\"/graphs/\"+scenarioFileName+\"_\"+dimName+\".gif\";\n\t\t\t\t\tUtils.printLineGraphGif(lg,lgImg);\n\t\t\t\t\tps.println(\"

\");\n\t\t\t\t\tps.println(\"
\"+dimName+\"
\");\n\t\t\t\t\tps.println(Utils.getDimensionDescription(dimName)+\"

\\n\");\n\t\t\t\t\tps.println(Utils.getImageMap(lg,\"graphs/\"+scenarioFileName+\"_\"+dimName+\".gif\"));\n\t\t\t\t}\n\t\t\t\tps.println(\"

\");\n\t\t\t\tps.println(Utils.HTML_CLOSE); \n\t\t\t\tif (ps != System.out)\n\t\t\t\t\tps.close();\n\t\t\t} catch (AssertionFailedError e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void run() {\n\t\tString[] bgColors = { \"#DDDDDD\", \"#EEEEEE\" };\n\t\tString outFile = null;\n\t\tPrintStream ps = null;\n\t\tfor (int s = 0; s < scenarios.length; s++) {\n\t\t\tArrayList pointsOfInterest=new ArrayList();\n\t\t\tScenario t = scenarios[s];\n\t\t\tif (pointsOfInterest.size()!=0){\n\t\t\tIterator iterator = this.pointsOfInterest.iterator();\n\t\t\t\twhile (iterator.hasNext()) {\n\t\t\t\t\tString match = getMostRecentMatchingBuildID(t, iterator\n\t\t\t\t\t\t\t.next().toString());\n\t\t\t\t\tif (match != null)\n\t\t\t\t\t\tpointsOfInterest.add(match);\n\t\t\t\t}\n\t\t\t}\n\t\t\tint []buildNameIndeces={-1,-1};\n\t\t\tbuildNameIndeces[0]=Utils.getBuildNameIndex(t.getTimeSeriesLabels(),current);\n\t\t\tbuildNameIndeces[1]=Utils.getBuildNameIndex(t.getTimeSeriesLabels(),reference);\n\t\t\tif (Utils.getBuildNameIndex(t.getTimeSeriesLabels(),current)==-1) {\n\t\t\t\tcontinue;\n\t\t\t} \n\t\t\tString scenarioFileName=t.getScenarioName().replace('#', '.').replace(':', '_')\n\t\t\t.replace('\\\\', '_');\n\t\t\toutFile = resultsFolder\n\t\t\t\t\t+ \"/\"\n\t\t\t\t\t+ scenarioFileName + \".html\";\n\t\t\tif (outFile != null) {\n\t\t\t\ttry {\n\t\t\t\t\tnew File(outFile).getParentFile().mkdirs();\n\t\t\t\t\tps = new PrintStream(new BufferedOutputStream(\n\t\t\t\t\t\t\tnew FileOutputStream(outFile)));\n\t\t\t\t} catch (FileNotFoundException e) {\n\t\t\t\t\tSystem.err.println(\"can't create output file\" + outFile); \n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ps == null)\n\t\t\t\tps = System.out;\n\t\t\tps.println(Utils.HTML_OPEN);\n\t\t\tps.println(Utils.HTML_DEFAULT_CSS);\n\t\t\tps.println(\"\"+t.getScenarioName() + \"(\"+configName+\")\"+\"\"); \n\t\t\tps.println(\"

Scenario: \" + t.getScenarioName() + \" (\"+configName+\")


\"); \n\t\t\tps.println(\"Click measurement name to view line graph of measured values over builds. \" +\n\t\t\t\t\t\"Magenta, black and yellow dots are used to denote release or milestone, integration, and nightly builds, respectively.

\");\n\t\t\tps.println(\"\"); \n\t\t\tDim[] dimensions = filteredDimensions( t.getDimensions());\n\t\t\ttry {\n\t\t\t\tps.println(\"\"); \n\t\t\t\tfor (int i = 0; i < dimensions.length; i++) {\n\t\t\t\t\tDim dim = dimensions[i];\n\t\t\t\t\tString dimName=dim.getName();\n\t\t\t\t\tps.println(\"\");\n\t\t\t\t}\n\t\t\t\tps.print(\"\\n\");\n\t\t\t\tdouble [][] diffValues=new double [2][dimensions.length];\n\t\t\t\tboolean [] refValueExistance=new boolean[dimensions.length];\n\t\t\t\tfor (int j = 0; j < 2; j++) {\n\t\t\t\t\tString referenceIndicator = (j == 1) ? \"(reference)\" : \"\";\n\t\t\t\t\tString buildName = ((buildNameIndeces[j] == -1) ? \"n/a\" : t\n\t\t\t\t\t\t\t.getTimeSeriesLabels()[buildNameIndeces[j]])\n\t\t\t\t\t\t\t+ referenceIndicator;\n\t\t\t\t\tps.print(\"\");\n\t\t\t\t\tfor (int i = 0; i < dimensions.length; i++) {\n\t\t\t\t\t\tDim dim = dimensions[i];\n\t\t\t\t\t\tString dimName=dim.getName();\n\t\t\t\t\t\tTimeSeries ts = t.getTimeSeries(dim);\n\t\t\t\t\t\tif (j==1&&buildNameIndeces[j]!=-1)\n\t\t\t\t\t\t\trefValueExistance[i]=true;\n\t\t\t\t\t\tif (buildNameIndeces[j] != -1)\n\t\t\t\t\t\t\tdiffValues[j][i]=ts.getValue(buildNameIndeces[j]);\n\t\t\t\t\t\tString displayValue = (buildNameIndeces[j] == -1) ? \"n/a\"\n\t\t\t\t\t\t\t\t: dim.getDisplayValue(ts\n\t\t\t\t\t\t\t\t\t\t.getValue(buildNameIndeces[j]));\n\t\t\t\t\t\tString stddev = (buildNameIndeces[j] == -1) ? \"0\" : dim\n\t\t\t\t\t\t\t\t.getDisplayValue(ts\n\t\t\t\t\t\t\t\t\t\t.getStddev(buildNameIndeces[j]));\n\t\t\t\t\t\tif (stddev.startsWith(\"0 \") || stddev.equals(\"0\"))\n\t\t\t\t\t\t\tps.println(\"\");\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tps.println(\"\");\n\t\t\t\t\t}\n\t\t\t\t\tps.print(\"\");\n\t\t\t\t}\n\t\t\t\tps.println(getDiffs(diffValues,dimensions,refValueExistance));\n\t\t\t\tps.println();\n\t\t\t\tps.println(\"
Build Id\" + dimName\n\t\t\t\t\t\t\t+ \"
\" + buildName + \"\" + displayValue + \"\" + displayValue + \" [\" + stddev\n\t\t\t\t\t\t\t\t\t+ \"]\" + \"
\");\n\t\t\t\tps.println(\"*Delta values in red and green indicate degradation > 10% and improvement > 10%,respectively.

\");\n\t\t\t\tps.println(\"

\\n\");\n\t\t\t\tfor (int i = 0; i < dimensions.length; i++) {\n\t\t\t\t\tDim dim = dimensions[i];\n\t\t\t\t\tString dimName=dim.getName();\n\t\t\t\t\tLineGraph lg=Utils.getLineGraph(t,dim.getName(),reference,current,pointsOfInterest);\n\t\t\t\t\tString lgImg=resultsFolder+\"/graphs/\"+scenarioFileName+\"_\"+dimName+\".gif\";\n\t\t\t\t\tUtils.printLineGraphGif(lg,lgImg);\n\t\t\t\t\tps.println(\"

\");\n\t\t\t\t\tps.println(\"
\"+dimName+\"
\");\n\t\t\t\t\tps.println(Utils.getDimensionDescription(dimName)+\"

\\n\");\n\t\t\t\t\tps.println(Utils.getImageMap(lg,\"graphs/\"+scenarioFileName+\"_\"+dimName+\".gif\"));\n\t\t\t\t}\n\t\t\t\tps.println(\"

\");\n\t\t\t\tps.println(Utils.HTML_CLOSE); \n\t\t\t\tif (ps != System.out)\n\t\t\t\t\tps.close();\n\t\t\t} catch (AssertionFailedError e) {\n\t\t\t\te.printStackTrace();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public void execute() throws CommandException{\n if (args.size() == 0 && !isPlayer){\n throw new CommandException(\"&c\u30d7\u30ec\u30a4\u30e4\u30fc\u540d\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\uff01\");\n }\n final Player target = (args.size() > 0) ? Bukkit.getPlayer(args.get(0)) : player;\n if (target == null || !target.isOnline()){\n throw new CommandException(\"&c\u30d7\u30ec\u30a4\u30e4\u30fc\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\uff01\");\n }\n final SakuraPlayer sp = PlayerManager.getPlayer(target);\n InvisibleWorker worker = InvisibleWorker.getInstance();\n if (worker.isInvisible(target)){\n worker.reappear(target);\n String msg = _(\"joinMessage\", I18n.PLAYER, sp.getName(true));\n if (msg != null && !msg.isEmpty()) {\n if (SCHelper.getInstance().getConfig().getUseGeoIP() && !Perms.HIDE_GEOIP.has(player)){\n String geoStr = GeoIP.getInstance().getGeoIpString(player, SCHelper.getInstance().getConfig().getUseSimpleFormatOnJoin());\n msg = msg + Util.coloring(\"&7\") + \" (\" + geoStr + \")\";\n }\n Util.broadcastMessage(msg);\n }\n if (!sender.equals(target)){\n Util.message(sender, \"&a\" + sp.getName() + \" &a\u306e\u900f\u660e\u30e2\u30fc\u30c9\u3092\u89e3\u9664\u3057\u307e\u3057\u305f\");\n }\n Util.message(target, \"&a\u3042\u306a\u305f\u306e\u900f\u660e\u30e2\u30fc\u30c9\u306f\u89e3\u9664\u3055\u308c\u307e\u3057\u305f\");\n SakuraCmdUtil.sendlog(sender, sp.getName() + \"&a \u304c\u900f\u660e\u30e2\u30fc\u30c9\u3092\u89e3\u9664\u3057\u307e\u3057\u305f\");\n }else{\n worker.vanish(target, false);\n String msg = _(\"quitMessage\", I18n.PLAYER, sp.getName(true));\n if (msg != null && !msg.isEmpty()) {\n Util.broadcastMessage(msg);\n }\n if (!sender.equals(target)){\n Util.message(sender, \"&c\" + sp.getName() + \" &c\u3092\u900f\u660e\u30e2\u30fc\u30c9\u306b\u3057\u307e\u3057\u305f\");\n }\n Util.message(target, \"&c\u3042\u306a\u305f\u306f\u900f\u660e\u30e2\u30fc\u30c9\u306b\u306a\u308a\u307e\u3057\u305f\");\n SakuraCmdUtil.sendlog(sender, sp.getName() + \"&c \u304c\u900f\u660e\u30e2\u30fc\u30c9\u306b\u306a\u308a\u307e\u3057\u305f\");\n }\n }\n", "output": " public void execute() throws CommandException{\n if (args.size() == 0 && !isPlayer){\n throw new CommandException(\"&c\u30d7\u30ec\u30a4\u30e4\u30fc\u540d\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\uff01\");\n }\n final Player target = (args.size() > 0) ? Bukkit.getPlayer(args.get(0)) : player;\n if (target == null || !target.isOnline()){\n throw new CommandException(\"&c\u30d7\u30ec\u30a4\u30e4\u30fc\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\uff01\");\n }\n final SakuraPlayer sp = PlayerManager.getPlayer(target);\n InvisibleWorker worker = InvisibleWorker.getInstance();\n if (worker.isInvisible(target)){\n worker.reappear(target);\n String msg = _(\"joinMessage\", I18n.PLAYER, sp.getName(true));\n if (msg != null && !msg.isEmpty()) {\n if (SCHelper.getInstance().getConfig().getUseGeoIP() && !Perms.HIDE_GEOIP.has(target)){\n String geoStr = GeoIP.getInstance().getGeoIpString(target, SCHelper.getInstance().getConfig().getUseSimpleFormatOnJoin());\n msg = msg + Util.coloring(\"&7\") + \" (\" + geoStr + \")\";\n }\n Util.broadcastMessage(msg);\n }\n if (!sender.equals(target)){\n Util.message(sender, \"&a\" + sp.getName() + \" &a\u306e\u900f\u660e\u30e2\u30fc\u30c9\u3092\u89e3\u9664\u3057\u307e\u3057\u305f\");\n }\n Util.message(target, \"&a\u3042\u306a\u305f\u306e\u900f\u660e\u30e2\u30fc\u30c9\u306f\u89e3\u9664\u3055\u308c\u307e\u3057\u305f\");\n SakuraCmdUtil.sendlog(sender, sp.getName() + \"&a \u304c\u900f\u660e\u30e2\u30fc\u30c9\u3092\u89e3\u9664\u3057\u307e\u3057\u305f\");\n }else{\n worker.vanish(target, false);\n String msg = _(\"quitMessage\", I18n.PLAYER, sp.getName(true));\n if (msg != null && !msg.isEmpty()) {\n Util.broadcastMessage(msg);\n }\n if (!sender.equals(target)){\n Util.message(sender, \"&c\" + sp.getName() + \" &c\u3092\u900f\u660e\u30e2\u30fc\u30c9\u306b\u3057\u307e\u3057\u305f\");\n }\n Util.message(target, \"&c\u3042\u306a\u305f\u306f\u900f\u660e\u30e2\u30fc\u30c9\u306b\u306a\u308a\u307e\u3057\u305f\");\n SakuraCmdUtil.sendlog(sender, sp.getName() + \"&c \u304c\u900f\u660e\u30e2\u30fc\u30c9\u306b\u306a\u308a\u307e\u3057\u305f\");\n }\n }\n"} {"input": "\tpublic boolean preHandle(HttpServletRequest request,\n\t\t\tHttpServletResponse response, Object handler) throws Exception {\n\t\tif (!request.getPathInfo().contains(INSTALL_REQUEST) && !configurationService.getProperty(\"dspace.installed\", Boolean.class, false)) {\n\t\t\tresponse.sendRedirect(request.getContextPath() + INSTALL_REQUEST);\n\t\t\treturn false;\n\t\t}\n\t\tif (configurationService.getProperty(\"dspace.installed\", Boolean.class, false) && request.getPathInfo().contains(INSTALL_REQUEST)) {\n\t\t\tresponse.sendRedirect(request.getContextPath());\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean preHandle(HttpServletRequest request,\n\t\t\tHttpServletResponse response, Object handler) throws Exception {\n\t\tif (!request.getPathInfo().contains(INSTALL_REQUEST) && !configurationService.isInstalled()) {\n\t\t\tresponse.sendRedirect(request.getContextPath() + INSTALL_REQUEST);\n\t\t\treturn false;\n\t\t}\n\t\tif (configurationService.isInstalled() && request.getPathInfo().contains(INSTALL_REQUEST)) {\n\t\t\tresponse.sendRedirect(request.getContextPath());\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": "\tpublic void doFilter(ServletRequest request, ServletResponse response,\n\t\t\tFilterChain chain) throws IOException, ServletException {\n\t\tHttpServletRequest httpRequest = (HttpServletRequest) request;\n\t\tHttpServletResponse httpResponse = (HttpServletResponse) response;\n\t\tHttpSession session = httpRequest.getSession();\n\t\tUser user = (User) session.getAttribute(\"user\");\n\t\tif (user == null) {\n\t\t\tString sequenceInCookie = HttpUtils.getCookie(httpRequest, \"seq\");\n\t\t\tif (sequenceInCookie == null) {\n\t\t\t\thttpResponse.sendRedirect(\"/pilot/login/login.html\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tInteger userSequence = Integer.valueOf(sequenceInCookie);\n\t\t\tuser = userDao.getUserBySequence(userSequence);\n\t\t\tsession.setAttribute(\"user\", user);\n\t\t}\n\t\tSystem.out.println(\"user: \" + user);\n\t\tchain.doFilter(request, response);\n\t}\n", "output": "\tpublic void doFilter(ServletRequest request, ServletResponse response,\n\t\t\tFilterChain chain) throws IOException, ServletException {\n\t\tHttpServletRequest httpRequest = (HttpServletRequest) request;\n\t\tHttpServletResponse httpResponse = (HttpServletResponse) response;\n\t\tHttpSession session = httpRequest.getSession();\n\t\tUser user = (User) session.getAttribute(\"user\");\n\t\tif (user == null) {\n\t\t\tString sequenceInCookie = HttpUtils.getCookie(httpRequest, \"seq\");\n\t\t\tif (sequenceInCookie == null) {\n\t\t\t\thttpResponse.sendRedirect(\"/pilot/login/login.html\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tInteger userSequence = Integer.valueOf(sequenceInCookie);\n\t\t\tuser = userDao.getUserBySequence(userSequence);\n\t\t\tsession.setAttribute(\"user\", user);\n\t\t}\n\t\tchain.doFilter(request, response);\n\t}\n"} {"input": "\tpublic void handleMessage(PircBot bot, String channel, String sender,\n\t\t\tString message) {\n\t\tString resultMsg = sender + \": \";\n\t\tIterator i = commands.values().iterator();\n\t\twhile(i.hasNext()) {\n\t\t\tresultMsg += i.next().getCommandName() + \" \";\n\t\t}\n\t\tbot.sendMessage(channel, resultMsg);\n\t}\n", "output": "\tpublic void handleMessage(PircBot bot, String channel, String sender,\n\t\t\tString message) {\n\t\tString resultMsg = sender + \": \";\n\t\tIterator i = commands.values().iterator();\n\t\twhile(i.hasNext()) {\n\t\t\tresultMsg += i.next().getCommandName();\n\t\t\tif(i.hasNext())\n\t\t\t resultMsg += \", \";\n\t\t}\n\t\tbot.sendMessage(channel, resultMsg);\n\t}\n"} {"input": "\tpublic static Class getType(\n\t\t\tASTPrimaryPrefix primaryPrefix, ASTPrimarySuffix[] suffixes)\n\t\t\tthrows SecurityException, ClassNotFoundException,\n\t\t\tCannotAutocompleteException, NoSuchFieldException,\n\t\t\tNoSuchMethodException {\n\t\tString[] parts = CompletionUtils.getNodeUtils().getParts(primaryPrefix,\n\t\t\t\tInteger.MAX_VALUE, Integer.MAX_VALUE);\n\t\tClass clazz = null;\n\t\tfor (int i = 0; i < parts.length - 1; i++) {\n\t\t\tclazz = getType(clazz, parts[i]);\n\t\t}\n\t\tif (clazz == null) {\n\t\t\tNode literalOrName = primaryPrefix.jjtGetChild(0);\n\t\t\tif (literalOrName instanceof ASTLiteral) {\n\t\t\t\tclazz = getType((ASTLiteral) literalOrName);\n\t\t\t} else {\n\t\t\t\tclazz = getType(null, getNodeUtils().getText(literalOrName));\n\t\t\t\tfor (int i = 0; i < suffixes.length; i++) {\n\t\t\t\t\tif (suffixes[i].first_token.kind == JavaParserConstants.LBRACKET) {\n\t\t\t\t\t\tclazz = clazz.getComponentType();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tString methodName = parts[parts.length - 1];\n\t\t\tfor (int i = 0; i < suffixes.length; i++) {\n\t\t\t\tif ((suffixes[0].jjtGetNumChildren() == 1)\n\t\t\t\t\t\t&& (suffixes[0].jjtGetChild(0) instanceof ASTArguments)) {\n\t\t\t\t\tClass[] params = getParams((ASTArguments) suffixes[0]\n\t\t\t\t\t\t\t.jjtGetChild(0));\n\t\t\t\t\tMethod method = getMethod(clazz, methodName, params);\n\t\t\t\t\tclazz = method.getReturnType();\n\t\t\t\t\tmethodName = null;\n\t\t\t\t} else if (suffixes[0].jjtGetNumChildren() == 0) {\n\t\t\t\t\tmethodName = suffixes[0].first_token.next.image;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new CannotAutocompleteException();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clazz;\n\t}\n", "output": "\tpublic static Class getType(\n\t\t\tASTPrimaryPrefix primaryPrefix, ASTPrimarySuffix[] suffixes)\n\t\t\tthrows SecurityException, ClassNotFoundException,\n\t\t\tCannotAutocompleteException, NoSuchFieldException,\n\t\t\tNoSuchMethodException {\n\t\tString[] parts = CompletionUtils.getNodeUtils().getParts(primaryPrefix,\n\t\t\t\tInteger.MAX_VALUE, Integer.MAX_VALUE);\n\t\tClass clazz = null;\n\t\tfor (int i = 0; i < parts.length - 1; i++) {\n\t\t\tclazz = getType(clazz, parts[i]);\n\t\t}\n\t\tif (clazz == null) {\n\t\t\tNode literalOrName = primaryPrefix.jjtGetChild(0);\n\t\t\tif (literalOrName instanceof ASTLiteral) {\n\t\t\t\tclazz = getType((ASTLiteral) literalOrName);\n\t\t\t} else {\n\t\t\t\tclazz = getType(null, getNodeUtils().getText(literalOrName));\n\t\t\t\tfor (int i = 0; i < suffixes.length; i++) {\n\t\t\t\t\tif (suffixes[i].first_token.kind == JavaParserConstants.LBRACKET) {\n\t\t\t\t\t\tclazz = clazz.getComponentType();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tString methodName = parts[parts.length - 1];\n\t\t\tfor (int i = 0; i < suffixes.length; i++) {\n\t\t\t\tif ((suffixes[i].jjtGetNumChildren() == 1)\n\t\t\t\t\t\t&& (suffixes[i].jjtGetChild(0) instanceof ASTArguments)) {\n\t\t\t\t\tClass[] params = getParams((ASTArguments) suffixes[i]\n\t\t\t\t\t\t\t.jjtGetChild(0));\n\t\t\t\t\tMethod method = getMethod(clazz, methodName, params);\n\t\t\t\t\tclazz = method.getReturnType();\n\t\t\t\t\tmethodName = null;\n\t\t\t\t} else if (suffixes[i].jjtGetNumChildren() == 0) {\n\t\t\t\t\tmethodName = suffixes[i].first_token.next.image;\n\t\t\t\t} else {\n\t\t\t\t\tthrow new CannotAutocompleteException();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn clazz;\n\t}\n"} {"input": "\tpublic void testNegotiate() throws IOException, ServletException {\n\t\tString securityPackage = \"Negotiate\";\n\t\tIWindowsCredentialsHandle clientCredentials = null;\n\t\tWindowsSecurityContextImpl clientContext = null;\n\t\t_filter.setRoleFormat(\"both\");\t\t\n\t\ttry {\n\t\t\tclientCredentials = WindowsCredentialsHandleImpl.getCurrent(securityPackage);\n\t\t\tclientCredentials.initialize();\n\t\t\tclientContext = new WindowsSecurityContextImpl();\n\t\t\tclientContext.setPrincipalName(WindowsAccountImpl.getCurrentUsername());\n\t\t\tclientContext.setCredentialsHandle(clientCredentials.getHandle());\n\t\t\tclientContext.setSecurityPackage(securityPackage);\n\t\t\tclientContext.initialize();\n\t\t\tSimpleFilterChain filterChain = new SimpleFilterChain();\n\t\t\tboolean authenticated = false;\n\t\t\tSimpleHttpRequest request = new SimpleHttpRequest();\n\t while(true)\n\t {\n\t \t\tString clientToken = Base64.encode(clientContext.getToken());\n\t \t\trequest.addHeader(\"Authorization\", securityPackage + \" \" + clientToken);\n\t \t\tSimpleHttpResponse response = new SimpleHttpResponse();\n\t \t\t_filter.doFilter(request, response, filterChain);\n\t \t\tSubject subject = (Subject) request.getSession().getAttribute(\"javax.security.auth.subject\");\n\t \t\tauthenticated = (subject != null && subject.getPrincipals().size() > 0);\n\t \t\tif (authenticated) {\n\t \t\tassertTrue(response.getHeaderNames().length >= 1);\n\t \t\t\tbreak;\n\t \t\t}\n\t \t\tassertTrue(response.getHeader(\"WWW-Authenticate\").startsWith(securityPackage + \" \"));\n\t \t\tassertEquals(\"keep-alive\", response.getHeader(\"Connection\"));\n\t \t\tassertEquals(2, response.getHeaderNames().length);\n\t \t\tassertEquals(401, response.getStatus());\n\t \t\tString continueToken = response.getHeader(\"WWW-Authenticate\").substring(securityPackage.length() + 1);\n\t \t\tbyte[] continueTokenBytes = Base64.decode(continueToken);\n\t \t\tassertTrue(continueTokenBytes.length > 0);\n\t SecBufferDesc continueTokenBuffer = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, continueTokenBytes);\n\t clientContext.initialize(clientContext.getHandle(), continueTokenBuffer);\n\t } \n\t assertTrue(authenticated);\n\t assertTrue(filterChain.getRequest() instanceof NegotiateRequestWrapper);\n\t assertTrue(filterChain.getResponse() instanceof SimpleHttpResponse);\t \n\t NegotiateRequestWrapper wrappedRequest = (NegotiateRequestWrapper) filterChain.getRequest();\n\t assertEquals(\"NEGOTIATE\", wrappedRequest.getAuthType());\n\t assertEquals(Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible), \n\t \t\twrappedRequest.getRemoteUser());\n\t assertTrue(wrappedRequest.getUserPrincipal() instanceof WindowsPrincipal);\n\t assertTrue(wrappedRequest.isUserInRole(\"Everyone\"));\n\t assertTrue(wrappedRequest.isUserInRole(\"S-1-1-0\"));\n\t\t} finally {\n\t\t\tif (clientContext != null) {\n\t\t\t\tclientContext.dispose();\n\t\t\t}\n\t\t\tif (clientCredentials != null) {\n\t\t\t\tclientCredentials.dispose();\n\t\t\t}\t\t\t\n\t\t}\n\t}\n", "output": "\tpublic void testNegotiate() throws IOException, ServletException {\n\t\tString securityPackage = \"Negotiate\";\n\t\tIWindowsCredentialsHandle clientCredentials = null;\n\t\tWindowsSecurityContextImpl clientContext = null;\n\t\t_filter.setRoleFormat(\"both\");\t\t\n\t\ttry {\n\t\t\tclientCredentials = WindowsCredentialsHandleImpl.getCurrent(securityPackage);\n\t\t\tclientCredentials.initialize();\n\t\t\tclientContext = new WindowsSecurityContextImpl();\n\t\t\tclientContext.setPrincipalName(WindowsAccountImpl.getCurrentUsername());\n\t\t\tclientContext.setCredentialsHandle(clientCredentials.getHandle());\n\t\t\tclientContext.setSecurityPackage(securityPackage);\n\t\t\tclientContext.initialize();\n\t\t\tSimpleFilterChain filterChain = new SimpleFilterChain();\n\t\t\tboolean authenticated = false;\n\t\t\tSimpleHttpRequest request = new SimpleHttpRequest();\n\t while(true)\n\t {\n\t \t\tString clientToken = Base64.encode(clientContext.getToken());\n\t \t\trequest.addHeader(\"Authorization\", securityPackage + \" \" + clientToken);\n\t \t\tSimpleHttpResponse response = new SimpleHttpResponse();\n\t \t\t_filter.doFilter(request, response, filterChain);\n\t \t\tSubject subject = (Subject) request.getSession().getAttribute(\"javax.security.auth.subject\");\n\t \t\tauthenticated = (subject != null && subject.getPrincipals().size() > 0);\n\t \t\tif (authenticated) {\n\t \t\tassertTrue(response.getHeaderNames().length >= 0);\n\t \t\t\tbreak;\n\t \t\t}\n\t \t\tassertTrue(response.getHeader(\"WWW-Authenticate\").startsWith(securityPackage + \" \"));\n\t \t\tassertEquals(\"keep-alive\", response.getHeader(\"Connection\"));\n\t \t\tassertEquals(2, response.getHeaderNames().length);\n\t \t\tassertEquals(401, response.getStatus());\n\t \t\tString continueToken = response.getHeader(\"WWW-Authenticate\").substring(securityPackage.length() + 1);\n\t \t\tbyte[] continueTokenBytes = Base64.decode(continueToken);\n\t \t\tassertTrue(continueTokenBytes.length > 0);\n\t SecBufferDesc continueTokenBuffer = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, continueTokenBytes);\n\t clientContext.initialize(clientContext.getHandle(), continueTokenBuffer);\n\t } \n\t assertTrue(authenticated);\n\t assertTrue(filterChain.getRequest() instanceof NegotiateRequestWrapper);\n\t assertTrue(filterChain.getResponse() instanceof SimpleHttpResponse);\t \n\t NegotiateRequestWrapper wrappedRequest = (NegotiateRequestWrapper) filterChain.getRequest();\n\t assertEquals(\"NEGOTIATE\", wrappedRequest.getAuthType());\n\t assertEquals(Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible), \n\t \t\twrappedRequest.getRemoteUser());\n\t assertTrue(wrappedRequest.getUserPrincipal() instanceof WindowsPrincipal);\n\t assertTrue(wrappedRequest.isUserInRole(\"Everyone\"));\n\t assertTrue(wrappedRequest.isUserInRole(\"S-1-1-0\"));\n\t\t} finally {\n\t\t\tif (clientContext != null) {\n\t\t\t\tclientContext.dispose();\n\t\t\t}\n\t\t\tif (clientCredentials != null) {\n\t\t\t\tclientCredentials.dispose();\n\t\t\t}\t\t\t\n\t\t}\n\t}\n"} {"input": "\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container,\n\t\t\tBundle savedInstanceState) {\n\t\tView v = inflater.inflate(R.layout.activity_splash_screen, container,\n\t\t\t\tfalse);\n\t\tv.setOnTouchListener(this);\n\t\tLog.d(\"Debug\", \"Making new floor, plan for transition\");\n\t\tPlayer.getPlayer().getDungeon().GenerateMap();\n\t\tDungeon newFloor = Player.getPlayer().getDungeon();\n\t\tPlayer.getPlayer().roomX = newFloor.start_x;\n\t\tPlayer.getPlayer().roomY = newFloor.start_x;\n\t\treturn v;\n\t}\n", "output": "\tpublic View onCreateView(LayoutInflater inflater, ViewGroup container,\n\t\t\tBundle savedInstanceState) {\n\t\tView v = inflater.inflate(R.layout.activity_splash_screen, container,\n\t\t\t\tfalse);\n\t\tv.setOnTouchListener(this);\n\t\tLog.d(\"Debug\", \"Making new floor, plan for transition\");\n\t\tPlayer.getPlayer().getDungeon().GenerateMap();\n\t\tDungeon newFloor = Player.getPlayer().getDungeon();\n\t\tPlayer.getPlayer().roomX = newFloor.start_x;\n\t\tPlayer.getPlayer().roomY = newFloor.start_y;\n\t\treturn v;\n\t}\n"} {"input": " public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)\n throws IOException, ServletException {\n long start = System.currentTimeMillis();\n HttpServletRequest httpRequest = (HttpServletRequest) request;\n HttpServletResponse httpResponse = (HttpServletResponse) response;\n final ByteArrayOutputStream outstr = new ByteArrayOutputStream();\n final GenericResponseWrapper wrapper = new GenericResponseWrapper(httpResponse, outstr);\n chain.doFilter(request, wrapper);\n wrapper.flushBuffer();\n final byte[] data = outstr.toByteArray();\n String requestURI = httpRequest.getRequestURI();\n if (requestURI.matches(\".*\\\\.(html|js|css|jpg|png|gif)$\")\n && httpResponse.getStatus() == HttpServletResponse.SC_OK) {\n File cacheFile = new File(cacheDir, \"/\" + httpRequest.getServerName() + requestURI);\n new CacheThread(cacheFile, data).start();\n }\n response.getOutputStream().write(data);\n long end = System.currentTimeMillis();\n RequestProcessTime rpt = new RequestProcessTime();\n rpt.setStart(start);\n rpt.setEnd(end);\n rpt.setTime(end - start);\n rpt.setMethod(httpRequest.getMethod());\n rpt.setRequest(httpRequest.getRequestURL().toString());\n rpt.setQuery(httpRequest.getQueryString());\n mongdoDb.createObject(\"RequestProcessTime\", rpt);\n }\n", "output": " public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)\n throws IOException, ServletException {\n long start = System.currentTimeMillis();\n HttpServletRequest httpRequest = (HttpServletRequest) request;\n HttpServletResponse httpResponse = (HttpServletResponse) response;\n final ByteArrayOutputStream outstr = new ByteArrayOutputStream();\n final GenericResponseWrapper wrapper = new GenericResponseWrapper(httpResponse, outstr);\n chain.doFilter(request, wrapper);\n wrapper.flushBuffer();\n final byte[] data = outstr.toByteArray();\n String requestURI = httpRequest.getRequestURI();\n int status = httpResponse.getStatus();\n if (requestURI.matches(\".*\\\\.(html|js|css|jpg|png|gif)$\")\n && (status == 0 || status == HttpServletResponse.SC_OK)) {\n File cacheFile = new File(cacheDir, \"/\" + httpRequest.getServerName() + requestURI);\n new CacheThread(cacheFile, data).start();\n }\n response.getOutputStream().write(data);\n long end = System.currentTimeMillis();\n RequestProcessTime rpt = new RequestProcessTime();\n rpt.setStart(start);\n rpt.setEnd(end);\n rpt.setTime(end - start);\n rpt.setMethod(httpRequest.getMethod());\n rpt.setRequest(httpRequest.getRequestURL().toString());\n rpt.setQuery(httpRequest.getQueryString());\n mongdoDb.createObject(\"RequestProcessTime\", rpt);\n }\n"} {"input": " public htmlFilterInputStream(\n final InputStream inStream,\n final String inputStreamCharset,\n final yacyURL rooturl,\n final htmlFilterTransformer transformer,\n final boolean passbyIfBinarySuspect\n ) {\n this.bufferedIn = new BufferedInputStream(inStream,(int) preBufferSize);\n this.bufferedIn.mark((int) preBufferSize);\n final htmlFilterContentScraper scraper = new htmlFilterContentScraper(rooturl);\n try {\n\t this.reader = new InputStreamReader(this,inputStreamCharset);\n\t} catch (UnsupportedEncodingException e) {\n\t try {\n\t\tthis.reader = new InputStreamReader(this, \"UTF-8\");\n\t } catch (UnsupportedEncodingException e1) {\n\t\tthis.reader = new InputStreamReader(this);\n\t }\n\t} \n this.writer = new htmlFilterWriter(null,null,scraper,transformer,passbyIfBinarySuspect);\n }\n", "output": " public htmlFilterInputStream(\n final InputStream inStream,\n final String inputStreamCharset,\n final yacyURL rooturl,\n final htmlFilterTransformer transformer,\n final boolean passbyIfBinarySuspect\n ) {\n this.bufferedIn = new BufferedInputStream(inStream,(int) preBufferSize);\n this.bufferedIn.mark((int) preBufferSize);\n final htmlFilterContentScraper scraper = new htmlFilterContentScraper(rooturl);\n scraper.registerHtmlFilterEventListener(this);\n try {\n\t this.reader = new InputStreamReader(this,inputStreamCharset);\n\t} catch (UnsupportedEncodingException e) {\n\t try {\n\t\tthis.reader = new InputStreamReader(this, \"UTF-8\");\n\t } catch (UnsupportedEncodingException e1) {\n\t\tthis.reader = new InputStreamReader(this);\n\t }\n\t} \n this.writer = new htmlFilterWriter(null,null,scraper,transformer,passbyIfBinarySuspect);\n }\n"} {"input": " public void testFormSubmit() {\n Event event = eventManager.newInstance(EventType.Training);\n wicketTester.startComponentInPage(new EventEditPanel(new EventModel(event)));\n wicketTester.dumpComponentWithPage();\n wicketTester.debugComponentTrees();\n String formId = \"eventEditPanel:form\";\n FormTester formTester = wicketTester.newFormTester(formId);\n formTester.select(\"team:input\", 1);\n formTester.setValue(\"date:input\", \"1.12.2011\");\n formTester.select(\"time:input\", 4); \n formTester.select(\"venue:input\", 1);\n formTester.setValue(\"summary:input\", \"New training next sunday\");\n formTester.setValue(\"comment:input\", \"Hope you bastards are all coming\");\n wicketTester.clickLink(\"submitButton\");\n wicketTester.dumpPage();\n wicketTester.assertContainsNot(\"Fehler bei\");\n }\n", "output": " public void testFormSubmit() {\n Event event = eventManager.newInstance(EventType.Training);\n wicketTester.startComponentInPage(new EventEditPanel(new EventModel(event)));\n wicketTester.dumpComponentWithPage();\n wicketTester.debugComponentTrees();\n String formId = \"eventEditPanel:form\";\n FormTester formTester = wicketTester.newFormTester(formId);\n formTester.select(\"team:input\", 1);\n formTester.setValue(\"date:input\", \"1.12.2011\");\n formTester.select(\"time:input\", 4); \n formTester.select(\"kickoff:input\", 5);\n formTester.select(\"venue:input\", 1);\n formTester.setValue(\"summary:input\", \"New training next sunday\");\n formTester.setValue(\"comment:input\", \"Hope you bastards are all coming\");\n wicketTester.clickLink(\"submitButton\");\n wicketTester.dumpPage();\n wicketTester.assertContainsNot(\"Fehler bei\");\n }\n"} {"input": "\tpublic void run(){\n\t\tCanvas canvas;\n\t\tLog.d(TAG, \"Starting game loop\");\n\t\tif(!(gamePanel == null)){\n\t\t\twhile (running) {\n\t\t\t\tstartTime = System.currentTimeMillis();\n\t\t\t\tgamePanel.update();\n\t\t\t\tcanvas = null;\n\t\t\t\ttry {\n\t\t\t\t\tcanvas = this.surfaceHolder.lockCanvas();\n\t\t\t\t\tsynchronized (surfaceHolder) {\n\t\t\t\t\t\tthis.gamePanel.render(canvas);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (canvas != null) {\n\t\t\t\t\t\tsurfaceHolder.unlockCanvasAndPost(canvas);\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t\tendTime = System.currentTimeMillis();\n\t\t\t\tif(endTime - startTime <= updateInterval){\n\t\t\t\t\ttry {\n\t\t\t\t\t\tThread.sleep(updateInterval + startTime - endTime);\n\t\t\t\t\t} catch(InterruptedException e){}\n\t\t\t\t} else { \n\t\t\t\t\toverTime = endTime - startTime - updateInterval;\n\t\t\t\t\twhile(overTime >= 0){\n\t\t\t\t\t\tstartTime = System.currentTimeMillis();\n\t\t\t\t\t\tgamePanel.update();\n\t\t\t\t\t\tendTime = System.currentTimeMillis();\n\t\t\t\t\t\tif(endTime - startTime <= updateInterval){\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tThread.sleep(updateInterval + startTime - endTime);\n\t\t\t\t\t\t\t} catch(InterruptedException e){};\n\t\t\t\t\t\t}\n\t\t\t\t\t\toverTime -= updateInterval + startTime - endTime;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (running) {\n\t\t\t\tstartTime = System.currentTimeMillis();\n\t\t\t\tmenuPanel.update();\n\t\t\t\tcanvas = null;\n\t\t\t\ttry {\n\t\t\t\t\tcanvas = this.surfaceHolder.lockCanvas();\n\t\t\t\t\tsynchronized (surfaceHolder) {\n\t\t\t\t\t\tif(canvas!=null)\n\t\t\t\t\t\tthis.menuPanel.render(canvas);\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (canvas != null) {\n\t\t\t\t\t\tsurfaceHolder.unlockCanvasAndPost(canvas);\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t\tendTime = System.currentTimeMillis();\n\t\t\t\ttry {\n\t\t\t\t\tif(startTime - endTime > -updateInterval){\n\t\t\t\t\t\tThread.sleep(updateInterval + startTime - endTime);\n\t\t\t\t\t}\n\t\t\t\t} catch(InterruptedException e){}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void run(){\n\t\tCanvas canvas;\n\t\tLog.d(TAG, \"Starting game loop\");\n\t\tif(!(gamePanel == null)){\n\t\t\twhile (running) {\n\t\t\t\tstartTime = System.currentTimeMillis();\n\t\t\t\tgamePanel.update();\n\t\t\t\tcanvas = null;\n\t\t\t\ttry {\n\t\t\t\t\tcanvas = this.surfaceHolder.lockCanvas();\n\t\t\t\t\tsynchronized (surfaceHolder) {\n\t\t\t\t\t\tthis.gamePanel.render(canvas);\n\t\t\t\t\t}\n\t\t\t\t} catch(NullPointerException e){}\n\t\t\t\tfinally {\n\t\t\t\t\tif (canvas != null) {\n\t\t\t\t\t\tsurfaceHolder.unlockCanvasAndPost(canvas);\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t\tendTime = System.currentTimeMillis();\n\t\t\t\tif(endTime - startTime <= updateInterval){\n\t\t\t\t\ttry {\n\t\t\t\t\t\tThread.sleep(updateInterval + startTime - endTime);\n\t\t\t\t\t} catch(InterruptedException e){}\n\t\t\t\t} else { \n\t\t\t\t\toverTime = endTime - startTime - updateInterval;\n\t\t\t\t\twhile(overTime >= 0){\n\t\t\t\t\t\tstartTime = System.currentTimeMillis();\n\t\t\t\t\t\tgamePanel.update();\n\t\t\t\t\t\tendTime = System.currentTimeMillis();\n\t\t\t\t\t\tif(endTime - startTime <= updateInterval){\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tThread.sleep(updateInterval + startTime - endTime);\n\t\t\t\t\t\t\t} catch(InterruptedException e){};\n\t\t\t\t\t\t}\n\t\t\t\t\t\toverTime -= updateInterval + startTime - endTime;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\twhile (running) {\n\t\t\t\tstartTime = System.currentTimeMillis();\n\t\t\t\tmenuPanel.update();\n\t\t\t\tcanvas = null;\n\t\t\t\ttry {\n\t\t\t\t\tcanvas = this.surfaceHolder.lockCanvas();\n\t\t\t\t\tsynchronized (surfaceHolder) {\n\t\t\t\t\t\tthis.menuPanel.render(canvas);\n\t\t\t\t\t}\n\t\t\t\t} catch(NullPointerException e){}\n\t\t\t\tfinally {\n\t\t\t\t\tif (canvas != null) {\n\t\t\t\t\t\tsurfaceHolder.unlockCanvasAndPost(canvas);\n\t\t\t\t\t}\n\t\t\t\t} \n\t\t\t\tendTime = System.currentTimeMillis();\n\t\t\t\ttry {\n\t\t\t\t\tif(startTime - endTime > -updateInterval){\n\t\t\t\t\t\tThread.sleep(updateInterval + startTime - endTime);\n\t\t\t\t\t}\n\t\t\t\t} catch(InterruptedException e){}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " protected ExtendedHeaderFooter createExtendedHeaderFooter()\n {\n return new ExtendedHeaderFooter( this )\n {\n @Override\n public void onStartPage( PdfWriter writer, Document doc )\n {\n super.onStartPage( writer, doc );\n StylableDocument.this.onStartPage();\n }\n @Override\n protected float getHeaderY( IMasterPageHeaderFooter header )\n {\n Float headerY = ( (StylableHeaderFooter) header ).getY();\n if ( headerY != null )\n {\n return document.getPageSize().getHeight() - headerY;\n }\n return super.getHeaderY( header );\n }\n @Override\n protected float getFooterY( IMasterPageHeaderFooter footer )\n {\n Float footerY = ( (StylableHeaderFooter) footer ).getY();\n if ( footerY != null )\n {\n return ( (StylableHeaderFooter) footer ).getTotalHeight();\n }\n return super.getFooterY( footer );\n }\n @Override\n protected float adjustMargin( float margin, IMasterPageHeaderFooter headerFooter )\n {\n if ( headerFooter.getTotalHeight() > margin )\n {\n return headerFooter.getTotalHeight();\n }\n return margin;\n }\n };\n }\n", "output": " protected ExtendedHeaderFooter createExtendedHeaderFooter()\n {\n return new ExtendedHeaderFooter( this )\n {\n @Override\n public void onStartPage( PdfWriter writer, Document doc )\n {\n super.onStartPage( writer, doc );\n StylableDocument.this.onStartPage();\n }\n @Override\n protected float getHeaderY( IMasterPageHeaderFooter header )\n {\n Float headerY = ( (StylableHeaderFooter) header ).getY();\n if ( headerY != null )\n {\n return document.getPageSize().getHeight() - headerY;\n }\n return super.getHeaderY( header );\n }\n @Override\n protected float getFooterY( IMasterPageHeaderFooter footer )\n {\n Float footerY = ( (StylableHeaderFooter) footer ).getY();\n if ( footerY != null )\n {\n return ( (StylableHeaderFooter) footer ).getTotalHeight();\n }\n return super.getFooterY( footer );\n }\n @Override\n protected float adjustMargin( float margin, IMasterPageHeaderFooter headerFooter )\n {\n if ( ( (StylableHeaderFooter) headerFooter ).getY() != null )\n {\n if ( headerFooter.getTotalHeight() > margin )\n {\n return headerFooter.getTotalHeight();\n }\n return margin;\n }\n return super.adjustMargin( margin, headerFooter );\n }\n };\n }\n"} {"input": " private Map> processCompleteModule(TypeElement rootModule) {\n Map allModules = new LinkedHashMap();\n collectIncludesRecursively(rootModule, allModules);\n Linker linker = new Linker(null, new CompileTimePlugin(processingEnv),\n new ReportingErrorHandler(processingEnv, rootModule.getQualifiedName().toString()));\n synchronized (linker) {\n Map> baseBindings = new LinkedHashMap>();\n Map> overrideBindings = new LinkedHashMap>();\n for (TypeElement module : allModules.values()) {\n Map annotation = CodeGen.getAnnotation(Module.class, module);\n boolean overrides = (Boolean) annotation.get(\"overrides\");\n Map> addTo = overrides ? overrideBindings : baseBindings;\n for (Object entryPoint : (Object[]) annotation.get(\"entryPoints\")) {\n linker.requestBinding(GeneratorKeys.rawMembersKey((TypeMirror) entryPoint),\n module.getQualifiedName().toString(), false);\n }\n for (Element enclosed : module.getEnclosedElements()) {\n Provides provides = enclosed.getAnnotation(Provides.class);\n if (provides == null) {\n continue;\n }\n ExecutableElement providerMethod = (ExecutableElement) enclosed;\n String key = GeneratorKeys.get(providerMethod);\n ProviderMethodBinding binding = new ProviderMethodBinding(key, providerMethod);\n switch (provides.type()) {\n case UNIQUE:\n ProviderMethodBinding clobbered = (ProviderMethodBinding) addTo.put(key, binding);\n if (clobbered != null) {\n processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,\n \"Duplicate bindings for \" + key\n + \": \" + shortMethodName(clobbered.method)\n + \", \" + shortMethodName(binding.method),\n binding.method);\n }\n break;\n case SET:\n String elementKey = GeneratorKeys.getElementKey(providerMethod);\n SetBinding.add(addTo, elementKey, binding);\n break;\n default:\n throw new AssertionError(\"Unknown @Provides type \" + provides.type());\n }\n }\n }\n linker.installBindings(baseBindings);\n linker.installBindings(overrideBindings);\n return linker.linkAll();\n }\n }\n", "output": " private Map> processCompleteModule(TypeElement rootModule) {\n Map allModules = new LinkedHashMap();\n collectIncludesRecursively(rootModule, allModules);\n Linker linker = new Linker(null, new CompileTimePlugin(processingEnv),\n new ReportingErrorHandler(processingEnv, rootModule.getQualifiedName().toString()));\n synchronized (linker) {\n Map> baseBindings = new LinkedHashMap>();\n Map> overrideBindings = new LinkedHashMap>();\n for (TypeElement module : allModules.values()) {\n Map annotation = CodeGen.getAnnotation(Module.class, module);\n boolean overrides = (Boolean) annotation.get(\"overrides\");\n Map> addTo = overrides ? overrideBindings : baseBindings;\n for (Object entryPoint : (Object[]) annotation.get(\"entryPoints\")) {\n linker.requestBinding(GeneratorKeys.rawMembersKey((TypeMirror) entryPoint),\n module.getQualifiedName().toString(), false);\n }\n for (Element enclosed : module.getEnclosedElements()) {\n Provides provides = enclosed.getAnnotation(Provides.class);\n if (provides == null) {\n continue;\n }\n ExecutableElement providerMethod = (ExecutableElement) enclosed;\n String key = GeneratorKeys.get(providerMethod);\n ProviderMethodBinding binding = new ProviderMethodBinding(key, providerMethod);\n switch (provides.type()) {\n case UNIQUE:\n ProviderMethodBinding clobbered = (ProviderMethodBinding) addTo.put(key, binding);\n if (clobbered != null) {\n String msg = \"Duplicate bindings for \" + key;\n if (overrides) {\n msg += \" in override module(s) - cannot override an override\";\n }\n msg += \": \" + shortMethodName(clobbered.method)\n + \", \" + shortMethodName(binding.method);\n processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg,\n binding.method);\n }\n break;\n case SET:\n String elementKey = GeneratorKeys.getElementKey(providerMethod);\n SetBinding.add(addTo, elementKey, binding);\n break;\n default:\n throw new AssertionError(\"Unknown @Provides type \" + provides.type());\n }\n }\n }\n linker.installBindings(baseBindings);\n linker.installBindings(overrideBindings);\n return linker.linkAll();\n }\n }\n"} {"input": " public ClassPath getBootstrapLibraries() {\n synchronized (this) {\n ClassPath cp = (bootstrap == null ? null : bootstrap.get());\n if (cp != null)\n return cp;\n String pathSpec = getSystemProperties().get(SYSPROP_BOOT_CLASSPATH);\n if (installFolders.size() == 2) try {\n String fxRT = new File(installFolders.get(1).toURI()).getAbsolutePath();\n pathSpec = pathSpec + File.pathSeparator + fxRT;\n fxRT = Util.getExtensions(fxRT);\n if (fxRT != null) pathSpec = pathSpec + File.pathSeparator + fxRT;\n } catch (URISyntaxException e) {\n Exceptions.printStackTrace(e);\n }\n String extPathSpec = Util.getExtensions((String)getSystemProperties().get(SYSPROP_JAVA_EXT_PATH));\n if (extPathSpec != null) {\n pathSpec = pathSpec + File.pathSeparator + extPathSpec;\n }\n cp = Util.createClassPath (pathSpec);\n bootstrap = new WeakReference(cp);\n return cp;\n }\n }\n", "output": " public ClassPath getBootstrapLibraries() {\n synchronized (this) {\n ClassPath cp = (bootstrap == null ? null : bootstrap.get());\n if (cp != null)\n return cp;\n String pathSpec = getSystemProperties().get(SYSPROP_BOOT_CLASSPATH);\n if (installFolders.size() == 2) try {\n String fxRT = new File(installFolders.get(1).toURI()).getAbsolutePath();\n pathSpec = pathSpec + File.pathSeparator + fxRT;\n fxRT = Util.getExtensions(fxRT);\n if (fxRT != null) pathSpec = fxRT + File.pathSeparator + pathSpec;\n } catch (URISyntaxException e) {\n Exceptions.printStackTrace(e);\n }\n String extPathSpec = Util.getExtensions((String)getSystemProperties().get(SYSPROP_JAVA_EXT_PATH));\n if (extPathSpec != null) {\n pathSpec = pathSpec + File.pathSeparator + extPathSpec;\n }\n cp = Util.createClassPath (pathSpec);\n bootstrap = new WeakReference(cp);\n return cp;\n }\n }\n"} {"input": "\tprivate void tenBoundaryMove (int xStart, int yStart, int xEnd, int yEnd, \n\t\t\tdouble deltaX, double deltaY, Particle2D p) {\n\t\tdouble x = p.pd.x - xStart * g.cellWidth;\n\t\tdouble y = p.pd.y - yStart * g.cellHeight;\n\t\tif (xEnd == (xStart+1)) {\n\t\t\tif (yEnd == (yStart+1)) {\n\t\t\t\tdouble deltaX1 = (g.cellWidth / 2) - x;\n\t\t\t\tif(((deltaY / deltaX) * deltaX1 + y) < (g.cellHeight / 2)) {\n\t\t\t\t\tdouble deltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = (g.cellHeight / 2) - y - deltaY1;\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart+1, yStart, -(g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\tx = deltaX2 - (g.cellWidth / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, -(g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >= 0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaY1 = (g.cellHeight / 2) - y;\n\t\t\t\t\tdeltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) - x - deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY1 / deltaX1) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart+1, x, -(g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\ty = deltaY2 - (g.cellHeight / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, -(g.cellWidth / 2), y, deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >=0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdouble deltaY1 = -((g.cellHeight / 2) + y);\n\t\t\t\tif(((deltaX / deltaY) * deltaY1 + x) < (g.cellWidth / 2)) {\n\t\t\t\t\tdouble deltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) - x - deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY / deltaX) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart-1, x, (g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\ty = -deltaY2 - (g.cellHeight / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, -(g.cellWidth / 2), y, deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <=0: deltaY;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaX1 = (g.cellWidth /2) - x;\n\t\t\t\t\tdeltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = -((g.cellHeight / 2) + y + deltaY1);\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart+1, yStart, -(g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\tx = deltaX2 - (g.cellWidth / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, (g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight /2);\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <=0: deltaY;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (yEnd == (yStart+1)) {\n\t\t\t\tdouble deltaX1 = -((g.cellWidth / 2) + x);\n\t\t\t\tif(((deltaY / deltaX) * deltaX1 + y) < (g.cellHeight/ 2)) {\n\t\t\t\t\tdouble deltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = (g.cellHeight / 2) - y - deltaY1;\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart-1, yStart, (g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\tx = (g.cellWidth / 2) + deltaX2;\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, -(g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <= 0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaY1 = (g.cellHeight / 2) - y;\n\t\t\t\t\tdeltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) - x - deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY1 / deltaX1) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart+1, x, -(g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\ty = deltaY2 - (g.cellHeight / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, -(g.cellWidth / 2), y, deltaX, deltaY,p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <=0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdouble deltaY1 = -((g.cellHeight / 2) + y);\n\t\t\t\tif((-(deltaX / deltaY) * deltaY1 - x) < (g.cellWidth/ 2)) {\n\t\t\t\t\tdouble deltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1,p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) + x + deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY / deltaX) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart-1, x, (g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\ty = (g.cellHeight / 2) + deltaY2;\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, (g.cellWidth / 2), y, deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <= 0: deltaY;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaX1 = -((g.cellWidth /2) + x);\n\t\t\t\t\tdeltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = -((g.cellHeight / 2) + y + deltaY1);\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart+1, yStart, (g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY1);\n\t\t\t\t\tx = (g.cellWidth / 2) + deltaX2;\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, (g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight /2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <= 0: deltaY;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void tenBoundaryMove (int xStart, int yStart, int xEnd, int yEnd, \n\t\t\tdouble deltaX, double deltaY, Particle2D p) {\n\t\tdouble x = p.pd.x - xStart * g.cellWidth;\n\t\tdouble y = p.pd.y - yStart * g.cellHeight;\n\t\tif (xEnd == (xStart+1)) {\n\t\t\tif (yEnd == (yStart+1)) {\n\t\t\t\tdouble deltaX1 = (g.cellWidth / 2) - x;\n\t\t\t\tif(((deltaY / deltaX) * deltaX1 + y) < (g.cellHeight / 2)) {\n\t\t\t\t\tdouble deltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = (g.cellHeight / 2) - y - deltaY1;\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart+1, yStart, -(g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\tx = deltaX2 - (g.cellWidth / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, -(g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >= 0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaY1 = (g.cellHeight / 2) - y;\n\t\t\t\t\tdeltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) - x - deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY1 / deltaX1) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart+1, x, -(g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\ty = deltaY2 - (g.cellHeight / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, -(g.cellWidth / 2), y, deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >=0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdouble deltaY1 = -((g.cellHeight / 2) + y);\n\t\t\t\tif(((deltaX / deltaY) * deltaY1 + x) < (g.cellWidth / 2)) {\n\t\t\t\t\tdouble deltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) - x - deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY / deltaX) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart-1, x, (g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\ty = -deltaY2 - (g.cellHeight / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, -(g.cellWidth / 2), y, deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <=0: deltaY;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaX1 = (g.cellWidth /2) - x;\n\t\t\t\t\tdeltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = -((g.cellHeight / 2) + y + deltaY1);\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart+1, yStart, -(g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\tx = deltaX2 - (g.cellWidth / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, (g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 >= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight /2);\n\t\t\t\t\t\tassert deltaX2 >= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX >= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <=0: deltaY;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (yEnd == (yStart+1)) {\n\t\t\t\tdouble deltaX1 = -((g.cellWidth / 2) + x);\n\t\t\t\tif(((deltaY / deltaX) * deltaX1 + y) < (g.cellHeight/ 2)) {\n\t\t\t\t\tdouble deltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = (g.cellHeight / 2) - y - deltaY1;\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart-1, yStart, (g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\tx = (g.cellWidth / 2) + deltaX2;\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, -(g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <= 0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaY1 = (g.cellHeight / 2) - y;\n\t\t\t\t\tdeltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) - x - deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY1 / deltaX1) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart+1, x, -(g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\ty = deltaY2 - (g.cellHeight / 2);\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, -(g.cellWidth / 2), y, deltaX, deltaY,p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 >= 0: deltaY1;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 >= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <=0: deltaX;\n\t\t\t\t\t\tassert deltaY >=0: deltaY;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdouble deltaY1 = -((g.cellHeight / 2) + y);\n\t\t\t\tif((-(deltaX / deltaY) * deltaY1 - x) < (g.cellWidth/ 2)) {\n\t\t\t\t\tdouble deltaX1 = (deltaX / deltaY) * deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1,p);\n\t\t\t\t\tdouble deltaX2 = (g.cellWidth / 2) + x + deltaX1;\n\t\t\t\t\tdouble deltaY2 = (deltaY / deltaX) * deltaX2;\n\t\t\t\t\tx += deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart-1, x, (g.cellHeight / 2), deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\ty = (g.cellHeight / 2) + deltaY2;\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, (g.cellWidth / 2), y, deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert x <= 0 && x >= -(g.cellWidth / 2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <= 0: deltaY;\n\t\t\t\t\t\tassert y >= 0 && y <= (g.cellHeight / 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tdouble deltaX1 = -((g.cellWidth /2) + x);\n\t\t\t\t\tdeltaY1 = (deltaY / deltaX) * deltaX1;\n\t\t\t\t\tfourBoundaryMove(xStart, yStart, x, y, deltaX1, deltaY1, p);\n\t\t\t\t\tdouble deltaY2 = -((g.cellHeight / 2) + y + deltaY1);\n\t\t\t\t\tdouble deltaX2 = (deltaX1 / deltaY1) * deltaY2;\n\t\t\t\t\ty += deltaY1;\n\t\t\t\t\tfourBoundaryMove(xStart+1, yStart, (g.cellWidth / 2), y, deltaX2, deltaY2, p);\n\t\t\t\t\tdeltaX -= (deltaX1 + deltaX2);\n\t\t\t\t\tdeltaY -= (deltaY1 + deltaY2);\n\t\t\t\t\tx = (g.cellWidth / 2) + deltaX2;\t\t\t\t\t\n\t\t\t\t\tfourBoundaryMove(xEnd, yEnd, x, (g.cellHeight / 2), deltaX, deltaY, p);\n\t\t\t\t\tif (Debug.asserts) {\n\t\t\t\t\t\tassert deltaX1 <= 0: deltaX1;\n\t\t\t\t\t\tassert deltaY1 <= 0: deltaY1;\n\t\t\t\t\t\tassert y <= 0 && y >= -(g.cellHeight /2);\n\t\t\t\t\t\tassert deltaX2 <= 0: deltaX2;\n\t\t\t\t\t\tassert deltaY2 <= 0: deltaY2;\n\t\t\t\t\t\tassert deltaX <= 0: deltaX;\n\t\t\t\t\t\tassert deltaY <= 0: deltaY;\n\t\t\t\t\t\tassert x >= 0 && x <= (g.cellWidth / 2);\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic void setGoal(GameScene currentScene) {\n\t\tfloat goalScaled = 65 * goalHeight;\t\n\t\tfloat lineLength = 480;\n\t\tfloat linePoxX = 400 - (lineLength/2);\n\t\tfloat linePosY = 480 - currentScene.mPlatform.rectangle.getHeightScaled() - goalScaled;\n\t\tLine goalLine = new Line(linePoxX, linePosY, linePoxX+lineLength, linePosY, 3, currentScene.getVBOM());\n\t\tgoalLine.setColor(Color.WHITE);\n\t\tcurrentScene.getContainer().attachChild(goalLine);\n\t\tText goalText = new Text(0, 0, ResourceManager.mGoalFont, \"Goal\", currentScene.getVBOM());\n\t\tfloat textPosX = goalLine.getX2() - goalText.getWidth();\n\t\tfloat textPosY = goalLine.getY2() - goalText.getHeight();\n\t\tgoalText.setPosition(textPosX, textPosY);\n\t\tcurrentScene.getContainer().attachChild(goalText);\n\t}\n", "output": "\tpublic void setGoal(GameScene currentScene) {\n\t\tfloat goalScaled = 65 * goalHeight;\t\n\t\tfloat lineLength = 480;\n\t\tfloat linePoxX = 400 - (lineLength/2);\n\t\tfloat linePosY = currentScene.mPlatform.rectangle.getY() - goalScaled;\n\t\tLine goalLine = new Line(linePoxX, linePosY, linePoxX+lineLength, linePosY, 3, currentScene.getVBOM());\n\t\tgoalLine.setColor(Color.WHITE);\n\t\tcurrentScene.getContainer().attachChild(goalLine);\n\t\tText goalText = new Text(0, 0, ResourceManager.mGoalFont, \"Goal\", currentScene.getVBOM());\n\t\tfloat textPosX = goalLine.getX2() - goalText.getWidth();\n\t\tfloat textPosY = goalLine.getY2() - goalText.getHeight();\n\t\tgoalText.setPosition(textPosX, textPosY);\n\t\tcurrentScene.getContainer().attachChild(goalText);\n\t}\n"} {"input": "\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tboolean compareMode = Boolean.TRUE.toString().equals(\n\t\t\t\tevent.getParameter(HistoryViewCommands.COMPARE_MODE_PARAM));\n\t\tIStructuredSelection selection = getSelection(getPage());\n\t\tif (selection.size() < 1)\n\t\t\treturn null;\n\t\tObject input = getPage().getInputInternal().getSingleFile();\n\t\tif (input == null)\n\t\t\treturn null;\n\t\tboolean errorOccured = false;\n\t\tList ids = new ArrayList();\n\t\tString gitPath = null;\n\t\tif (input instanceof IFile) {\n\t\t\tIFile resource = (IFile) input;\n\t\t\tfinal RepositoryMapping map = RepositoryMapping\n\t\t\t\t\t.getMapping(resource);\n\t\t\tgitPath = map.getRepoRelativePath(resource);\n\t\t\tIterator it = selection.iterator();\n\t\t\twhile (it.hasNext()) {\n\t\t\t\tRevCommit commit = (RevCommit) it.next();\n\t\t\t\tIFileRevision rev = null;\n\t\t\t\ttry {\n\t\t\t\t\trev = CompareUtils.getFileRevision(gitPath, commit, map\n\t\t\t\t\t\t\t.getRepository(), null);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tActivator.logError(NLS.bind(\n\t\t\t\t\t\t\tUIText.GitHistoryPage_errorLookingUpPath, gitPath,\n\t\t\t\t\t\t\tcommit.getId()), e);\n\t\t\t\t\terrorOccured = true;\n\t\t\t\t}\n\t\t\t\tif (rev != null) {\n\t\t\t\t\tif (compareMode) {\n\t\t\t\t\t\tITypedElement right = CompareUtils\n\t\t\t\t\t\t\t\t.getFileRevisionTypedElement(gitPath, commit,\n\t\t\t\t\t\t\t\t\t\tmap.getRepository());\n\t\t\t\t\t\tfinal GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(\n\t\t\t\t\t\t\t\tSaveableCompareEditorInput\n\t\t\t\t\t\t\t\t\t\t.createFileElement(resource), right,\n\t\t\t\t\t\t\t\tnull);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\topenInCompare(event, in);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tEgitUiEditorUtils.openEditor(getPart(event)\n\t\t\t\t\t\t\t\t\t.getSite().getPage(), rev,\n\t\t\t\t\t\t\t\t\tnew NullProgressMonitor());\n\t\t\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\t\tActivator.logError(\n\t\t\t\t\t\t\t\t\tUIText.GitHistoryPage_openFailed, e);\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tids.add(commit.getId());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (input instanceof File) {\n\t\t\tFile fileInput = (File) input;\n\t\t\tRepository repo = getRepository(event);\n\t\t\tgitPath = getRepoRelativePath(repo, fileInput);\n\t\t\tIterator it = selection.iterator();\n\t\t\twhile (it.hasNext()) {\n\t\t\t\tRevCommit commit = (RevCommit) it.next();\n\t\t\t\tIFileRevision rev = null;\n\t\t\t\ttry {\n\t\t\t\t\trev = CompareUtils.getFileRevision(gitPath, commit, repo,\n\t\t\t\t\t\t\tnull);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tActivator.logError(NLS.bind(\n\t\t\t\t\t\t\tUIText.GitHistoryPage_errorLookingUpPath, gitPath,\n\t\t\t\t\t\t\tcommit.getId()), e);\n\t\t\t\t\terrorOccured = true;\n\t\t\t\t}\n\t\t\t\tif (rev != null) {\n\t\t\t\t\tif (compareMode) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tITypedElement left = CompareUtils\n\t\t\t\t\t\t\t\t\t.getFileRevisionTypedElement(gitPath,\n\t\t\t\t\t\t\t\t\t\t\tnew RevWalk(repo).parseCommit(repo\n\t\t\t\t\t\t\t\t\t\t\t\t\t.resolve(Constants.HEAD)),\n\t\t\t\t\t\t\t\t\t\t\trepo);\n\t\t\t\t\t\t\tITypedElement right = CompareUtils\n\t\t\t\t\t\t\t\t\t.getFileRevisionTypedElement(gitPath,\n\t\t\t\t\t\t\t\t\t\t\tcommit, repo);\n\t\t\t\t\t\t\tfinal GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(\n\t\t\t\t\t\t\t\t\tleft, right, null);\n\t\t\t\t\t\t\topenInCompare(event, in);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tEgitUiEditorUtils.openEditor(getPart(event)\n\t\t\t\t\t\t\t\t\t.getSite().getPage(), rev,\n\t\t\t\t\t\t\t\t\tnew NullProgressMonitor());\n\t\t\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\t\tActivator.logError(\n\t\t\t\t\t\t\t\t\tUIText.GitHistoryPage_openFailed, e);\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tids.add(commit.getId());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (errorOccured)\n\t\t\tActivator.showError(UIText.GitHistoryPage_openFailed, null);\n\t\tif (ids.size() > 0) {\n\t\t\tString idList = \"\"; \n\t\t\tfor (ObjectId objectId : ids) {\n\t\t\t\tidList += objectId.getName() + \" \"; \n\t\t\t}\n\t\t\tMessageDialog.openError(getPart(event).getSite().getShell(),\n\t\t\t\t\tUIText.GitHistoryPage_fileNotFound, NLS.bind(\n\t\t\t\t\t\t\tUIText.GitHistoryPage_notContainedInCommits,\n\t\t\t\t\t\t\tgitPath, idList));\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tpublic Object execute(ExecutionEvent event) throws ExecutionException {\n\t\tboolean compareMode = Boolean.TRUE.toString().equals(\n\t\t\t\tevent.getParameter(HistoryViewCommands.COMPARE_MODE_PARAM));\n\t\tIStructuredSelection selection = getSelection(getPage());\n\t\tif (selection.size() < 1)\n\t\t\treturn null;\n\t\tObject input = getPage().getInputInternal().getSingleFile();\n\t\tif (input == null)\n\t\t\treturn null;\n\t\tboolean errorOccured = false;\n\t\tList ids = new ArrayList();\n\t\tString gitPath = null;\n\t\tif (input instanceof IFile) {\n\t\t\tIFile resource = (IFile) input;\n\t\t\tfinal RepositoryMapping map = RepositoryMapping\n\t\t\t\t\t.getMapping(resource);\n\t\t\tgitPath = map.getRepoRelativePath(resource);\n\t\t\tIterator it = selection.iterator();\n\t\t\twhile (it.hasNext()) {\n\t\t\t\tRevCommit commit = (RevCommit) it.next();\n\t\t\t\tIFileRevision rev = null;\n\t\t\t\ttry {\n\t\t\t\t\trev = CompareUtils.getFileRevision(gitPath, commit, map\n\t\t\t\t\t\t\t.getRepository(), null);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tActivator.logError(NLS.bind(\n\t\t\t\t\t\t\tUIText.GitHistoryPage_errorLookingUpPath, gitPath,\n\t\t\t\t\t\t\tcommit.getId()), e);\n\t\t\t\t\terrorOccured = true;\n\t\t\t\t}\n\t\t\t\tif (rev != null) {\n\t\t\t\t\tif (compareMode) {\n\t\t\t\t\t\tITypedElement right = CompareUtils\n\t\t\t\t\t\t\t\t.getFileRevisionTypedElement(gitPath, commit,\n\t\t\t\t\t\t\t\t\t\tmap.getRepository());\n\t\t\t\t\t\tfinal GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(\n\t\t\t\t\t\t\t\tSaveableCompareEditorInput\n\t\t\t\t\t\t\t\t\t\t.createFileElement(resource), right,\n\t\t\t\t\t\t\t\tnull);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\topenInCompare(event, in);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tEgitUiEditorUtils.openEditor(getPart(event)\n\t\t\t\t\t\t\t\t\t.getSite().getPage(), rev,\n\t\t\t\t\t\t\t\t\tnew NullProgressMonitor());\n\t\t\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\t\tActivator.logError(\n\t\t\t\t\t\t\t\t\tUIText.GitHistoryPage_openFailed, e);\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tids.add(commit.getId());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (input instanceof File) {\n\t\t\tFile fileInput = (File) input;\n\t\t\tRepository repo = getRepository(event);\n\t\t\tgitPath = getRepoRelativePath(repo, fileInput);\n\t\t\tIterator it = selection.iterator();\n\t\t\twhile (it.hasNext()) {\n\t\t\t\tRevCommit commit = (RevCommit) it.next();\n\t\t\t\tIFileRevision rev = null;\n\t\t\t\ttry {\n\t\t\t\t\trev = CompareUtils.getFileRevision(gitPath, commit, repo,\n\t\t\t\t\t\t\tnull);\n\t\t\t\t} catch (IOException e) {\n\t\t\t\t\tActivator.logError(NLS.bind(\n\t\t\t\t\t\t\tUIText.GitHistoryPage_errorLookingUpPath, gitPath,\n\t\t\t\t\t\t\tcommit.getId()), e);\n\t\t\t\t\terrorOccured = true;\n\t\t\t\t}\n\t\t\t\tif (rev != null) {\n\t\t\t\t\tif (compareMode) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tITypedElement left = CompareUtils\n\t\t\t\t\t\t\t\t\t.getFileRevisionTypedElement(gitPath,\n\t\t\t\t\t\t\t\t\t\t\tnew RevWalk(repo).parseCommit(repo\n\t\t\t\t\t\t\t\t\t\t\t\t\t.resolve(Constants.HEAD)),\n\t\t\t\t\t\t\t\t\t\t\trepo);\n\t\t\t\t\t\t\tITypedElement right = CompareUtils\n\t\t\t\t\t\t\t\t\t.getFileRevisionTypedElement(gitPath,\n\t\t\t\t\t\t\t\t\t\t\tcommit, repo);\n\t\t\t\t\t\t\tfinal GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(\n\t\t\t\t\t\t\t\t\tleft, right, null);\n\t\t\t\t\t\t\topenInCompare(event, in);\n\t\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tEgitUiEditorUtils.openEditor(getPart(event)\n\t\t\t\t\t\t\t\t\t.getSite().getPage(), rev,\n\t\t\t\t\t\t\t\t\tnew NullProgressMonitor());\n\t\t\t\t\t\t} catch (CoreException e) {\n\t\t\t\t\t\t\tActivator.logError(\n\t\t\t\t\t\t\t\t\tUIText.GitHistoryPage_openFailed, e);\n\t\t\t\t\t\t\terrorOccured = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tids.add(commit.getId());\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (errorOccured)\n\t\t\tActivator.showError(UIText.GitHistoryPage_openFailed, null);\n\t\tif (ids.size() > 0) {\n\t\t\tString idList = \"\"; \n\t\t\tfor (ObjectId objectId : ids) {\n\t\t\t\tidList += objectId.getName() + \" \"; \n\t\t\t}\n\t\t\tMessageDialog.openError(getPart(event).getSite().getShell(),\n\t\t\t\t\tUIText.GitHistoryPage_fileNotFound, NLS.bind(\n\t\t\t\t\t\t\tUIText.GitHistoryPage_notContainedInCommits,\n\t\t\t\t\t\t\tgitPath, idList));\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": "\tprivate void eObjectToPbmMarker(IResource res, EObject problem, int tabWidth) {\n\t\tEPackage pkProblem = null;\n\t\tEClass clProblem = null;\n\t\tEStructuralFeature sfSeverity = null;\n\t\tEStructuralFeature sfLocation = null;\n\t\tEStructuralFeature sfDescription = null;\n\t\tpkProblem = problem.eClass().getEPackage();\n\t\tclProblem = (EClass)pkProblem.getEClassifier(\"Problem\");\n\t\tsfSeverity = clProblem.getEStructuralFeature(\"severity\");\n\t\tsfLocation = clProblem.getEStructuralFeature(\"location\");\n\t\tsfDescription = clProblem.getEStructuralFeature(\"description\");\n\t\tString description = (String)problem.eGet(sfDescription);\n\t\tString location = (String)problem.eGet(sfLocation);\n\t\tint lineNumber = Integer.parseInt(location.split(\":\")[0]);\n\t\tint charStart = 0, charEnd = 0;\n\t\ttry {\n\t\t\tAtlNbCharFile help = new AtlNbCharFile(((IFile)res).getContents());\n\t\t\tif (location.indexOf('-') == -1) {\n\t\t\t\tlocation += '-' + location;\n\t\t\t}\n\t\t\tint[] pos = help.getIndexChar(location, tabWidth);\n\t\t\tcharStart = pos[0];\n\t\t\tcharEnd = pos[1];\n\t\t} catch (CoreException e1) {\n\t\t\tlogger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);\n\t\t}\n\t\tString severity = ((EEnumLiteral)problem.eGet(sfSeverity)).getName();\n\t\tint eclipseSeverity = ((Integer)severities.get(severity)).intValue();\n\t\ttry {\n\t\t\tIMarker pbmMarker = res.createMarker(IMarker.PROBLEM);\n\t\t\tpbmMarker.setAttribute(IMarker.SEVERITY, eclipseSeverity);\n\t\t\tpbmMarker.setAttribute(IMarker.MESSAGE, description);\n\t\t\tpbmMarker.setAttribute(IMarker.LINE_NUMBER, lineNumber);\n\t\t\tpbmMarker.setAttribute(IMarker.CHAR_START, charStart);\n\t\t\tpbmMarker.setAttribute(IMarker.CHAR_END, (charEnd > charStart) ? charEnd : charStart + 1);\n\t\t} catch (CoreException e) {\n\t\t\tlogger.log(Level.SEVERE, e.getLocalizedMessage(), e);\n\t\t}\n\t}\n", "output": "\tprivate void eObjectToPbmMarker(IResource res, EObject problem, int tabWidth) {\n\t\tEPackage pkProblem = null;\n\t\tEClass clProblem = null;\n\t\tEStructuralFeature sfSeverity = null;\n\t\tEStructuralFeature sfLocation = null;\n\t\tEStructuralFeature sfDescription = null;\n\t\tpkProblem = problem.eClass().getEPackage();\n\t\tclProblem = (EClass)pkProblem.getEClassifier(\"Problem\");\n\t\tsfSeverity = clProblem.getEStructuralFeature(\"severity\");\n\t\tsfLocation = clProblem.getEStructuralFeature(\"location\");\n\t\tsfDescription = clProblem.getEStructuralFeature(\"description\");\n\t\tString description = (String)problem.eGet(sfDescription);\n\t\tString location = (String)problem.eGet(sfLocation);\n\t\tint lineNumber = Integer.parseInt(location.split(\":\")[0]);\n\t\tint charStart = 0, charEnd = 0;\n\t\ttry {\n\t\t\tAtlNbCharFile help = new AtlNbCharFile(((IFile)res).getContents());\n\t\t\tif (location.indexOf('-') == -1) {\n\t\t\t\tlocation += '-' + location;\n\t\t\t}\n\t\t\tint[] pos = help.getIndexChar(location, tabWidth);\n\t\t\tcharStart = pos[0];\n\t\t\tcharEnd = pos[1];\n\t\t} catch (CoreException e1) {\n\t\t\tlogger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);\n\t\t} catch(Exception e) {\n\t\t\tdescription += \" [location \\\"\" + location + \"\\\" incorrectly reported because of error]\";\n\t\t}\n\t\tString severity = ((EEnumLiteral)problem.eGet(sfSeverity)).getName();\n\t\tint eclipseSeverity = ((Integer)severities.get(severity)).intValue();\n\t\ttry {\n\t\t\tIMarker pbmMarker = res.createMarker(IMarker.PROBLEM);\n\t\t\tpbmMarker.setAttribute(IMarker.SEVERITY, eclipseSeverity);\n\t\t\tpbmMarker.setAttribute(IMarker.MESSAGE, description);\n\t\t\tpbmMarker.setAttribute(IMarker.LINE_NUMBER, lineNumber);\n\t\t\tpbmMarker.setAttribute(IMarker.CHAR_START, charStart);\n\t\t\tpbmMarker.setAttribute(IMarker.CHAR_END, (charEnd > charStart) ? charEnd : charStart + 1);\n\t\t} catch (CoreException e) {\n\t\t\tlogger.log(Level.SEVERE, e.getLocalizedMessage(), e);\n\t\t}\n\t}\n"} {"input": " public AboutWindow(Frame owner)\n {\n super(owner);\n ResourceManagementService resources = BrandingActivator.getResources();\n String applicationName\n = resources.getSettingsString(\"service.gui.APPLICATION_NAME\");\n this.setTitle(\n resources.getI18NString(\"plugin.branding.ABOUT_WINDOW_TITLE\",\n new String[]{applicationName}));\n setModal(false);\n setDefaultCloseOperation(DISPOSE_ON_CLOSE);\n JPanel mainPanel = new WindowBackground();\n mainPanel.setLayout(new BorderLayout());\n JPanel textPanel = new JPanel();\n textPanel.setPreferredSize(new Dimension(470, 280));\n textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));\n textPanel.setBorder(BorderFactory\n .createEmptyBorder(15, 15, 15, 15));\n textPanel.setOpaque(false);\n JLabel titleLabel = new JLabel(applicationName);\n titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 28));\n titleLabel.setForeground(Constants.TITLE_COLOR);\n titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);\n JLabel versionLabel =\n new JLabel(\" \" + System.getProperty(\"sip-communicator.version\"));\n versionLabel.setFont(versionLabel.getFont().deriveFont(Font.BOLD, 18));\n versionLabel.setForeground(Constants.TITLE_COLOR);\n versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);\n int logoAreaFontSize\n = resources.getSettingsInt(\"plugin.branding.ABOUT_LOGO_FONT_SIZE\");\n JTextArea logoArea =\n new JTextArea(resources.getI18NString(\"plugin.branding.LOGO_MESSAGE\"));\n logoArea.setFont(\n logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize));\n logoArea.setForeground(Constants.TITLE_COLOR);\n logoArea.setOpaque(false);\n logoArea.setLineWrap(false);\n logoArea.setWrapStyleWord(true);\n logoArea.setEditable(false);\n logoArea.setPreferredSize(new Dimension(100, 20));\n logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);\n logoArea.setBorder(BorderFactory\n .createEmptyBorder(30, DEFAULT_TEXT_INDENT, 0, 0));\n StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();\n rightsArea.setContentType(\"text/html\");\n rightsArea.appendToEnd(resources.getI18NString(\"plugin.branding.COPYRIGHT\",\n new String[]\n { Constants.TEXT_COLOR }));\n rightsArea.setPreferredSize(new Dimension(50, 20));\n rightsArea\n .setBorder(BorderFactory\n .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));\n rightsArea.setOpaque(false);\n rightsArea.setEditable(false);\n rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);\n rightsArea.addHyperlinkListener(this);\n StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane();\n licenseArea.setContentType(\"text/html\");\n licenseArea.appendToEnd(resources.\n getI18NString(\"plugin.branding.LICENSE\",\n new String[]{Constants.TEXT_COLOR}));\n licenseArea.setPreferredSize(new Dimension(50, 20));\n licenseArea.setBorder(\n BorderFactory.createEmptyBorder(\n resources.getSettingsInt(\"plugin.branding.ABOUT_PARAGRAPH_GAP\"),\n DEFAULT_TEXT_INDENT,\n 0, 0));\n licenseArea.setOpaque(false);\n licenseArea.setEditable(false);\n licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);\n licenseArea.addHyperlinkListener(this);\n textPanel.add(titleLabel);\n textPanel.add(versionLabel);\n textPanel.add(logoArea);\n textPanel.add(rightsArea);\n textPanel.add(licenseArea);\n JButton okButton = new JButton(resources.getI18NString(\"service.gui.OK\"));\n this.getRootPane().setDefaultButton(okButton);\n okButton.setMnemonic(resources.getI18nMnemonic(\"service.gui.OK\"));\n okButton.addActionListener(this);\n JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));\n buttonPanel.add(okButton);\n buttonPanel.setOpaque(false);\n mainPanel.add(textPanel, BorderLayout.CENTER);\n mainPanel.add(buttonPanel, BorderLayout.SOUTH);\n this.getContentPane().add(mainPanel);\n this.pack();\n this.setResizable(false);\n Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();\n setLocation(screenSize.width / 2 - getWidth() / 2, screenSize.height\n / 2 - getHeight() / 2);\n }\n", "output": " public AboutWindow(Frame owner)\n {\n super(owner);\n ResourceManagementService resources = BrandingActivator.getResources();\n String applicationName\n = resources.getSettingsString(\"service.gui.APPLICATION_NAME\");\n this.setTitle(\n resources.getI18NString(\"plugin.branding.ABOUT_WINDOW_TITLE\",\n new String[]{applicationName}));\n setModal(false);\n setDefaultCloseOperation(DISPOSE_ON_CLOSE);\n JPanel mainPanel = new WindowBackground();\n mainPanel.setLayout(new BorderLayout());\n JPanel textPanel = new JPanel();\n textPanel.setPreferredSize(new Dimension(470, 280));\n textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));\n textPanel.setBorder(BorderFactory\n .createEmptyBorder(15, 15, 15, 15));\n textPanel.setOpaque(false);\n JLabel titleLabel = new JLabel(applicationName);\n titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 28));\n titleLabel.setForeground(Constants.TITLE_COLOR);\n titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);\n JLabel versionLabel =\n new JLabel(\" \" + System.getProperty(\"sip-communicator.version\"));\n versionLabel.setFont(versionLabel.getFont().deriveFont(Font.BOLD, 18));\n versionLabel.setForeground(Constants.TITLE_COLOR);\n versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);\n int logoAreaFontSize\n = resources.getSettingsInt(\"plugin.branding.ABOUT_LOGO_FONT_SIZE\");\n JTextArea logoArea =\n new JTextArea(resources.getI18NString(\"plugin.branding.LOGO_MESSAGE\"));\n logoArea.setFont(\n logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize));\n logoArea.setForeground(Constants.TITLE_COLOR);\n logoArea.setOpaque(false);\n logoArea.setLineWrap(true);\n logoArea.setWrapStyleWord(true);\n logoArea.setEditable(false);\n logoArea.setPreferredSize(new Dimension(100, 20));\n logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);\n logoArea.setBorder(BorderFactory\n .createEmptyBorder(30, DEFAULT_TEXT_INDENT, 0, 0));\n StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();\n rightsArea.setContentType(\"text/html\");\n rightsArea.appendToEnd(resources.getI18NString(\"plugin.branding.COPYRIGHT\",\n new String[]\n { Constants.TEXT_COLOR }));\n rightsArea.setPreferredSize(new Dimension(50, 20));\n rightsArea\n .setBorder(BorderFactory\n .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));\n rightsArea.setOpaque(false);\n rightsArea.setEditable(false);\n rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);\n rightsArea.addHyperlinkListener(this);\n StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane();\n licenseArea.setContentType(\"text/html\");\n licenseArea.appendToEnd(resources.\n getI18NString(\"plugin.branding.LICENSE\",\n new String[]{Constants.TEXT_COLOR}));\n licenseArea.setPreferredSize(new Dimension(50, 20));\n licenseArea.setBorder(\n BorderFactory.createEmptyBorder(\n resources.getSettingsInt(\"plugin.branding.ABOUT_PARAGRAPH_GAP\"),\n DEFAULT_TEXT_INDENT,\n 0, 0));\n licenseArea.setOpaque(false);\n licenseArea.setEditable(false);\n licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);\n licenseArea.addHyperlinkListener(this);\n textPanel.add(titleLabel);\n textPanel.add(versionLabel);\n textPanel.add(logoArea);\n textPanel.add(rightsArea);\n textPanel.add(licenseArea);\n JButton okButton = new JButton(resources.getI18NString(\"service.gui.OK\"));\n this.getRootPane().setDefaultButton(okButton);\n okButton.setMnemonic(resources.getI18nMnemonic(\"service.gui.OK\"));\n okButton.addActionListener(this);\n JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));\n buttonPanel.add(okButton);\n buttonPanel.setOpaque(false);\n mainPanel.add(textPanel, BorderLayout.CENTER);\n mainPanel.add(buttonPanel, BorderLayout.SOUTH);\n this.getContentPane().add(mainPanel);\n this.pack();\n this.setResizable(false);\n Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();\n setLocation(screenSize.width / 2 - getWidth() / 2, screenSize.height\n / 2 - getHeight() / 2);\n }\n"} {"input": " public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n if (sender.hasPermission(\"libsdisguises.undisguiseplayer\")) {\n if (args.length > 0) {\n Player p = Bukkit.getPlayer(args[0]);\n if (p != null) {\n if (DisguiseAPI.isDisguised(p)) {\n DisguiseAPI.undisguiseToAll(p);\n sender.sendMessage(ChatColor.RED + \"He is no longer disguised\");\n } else\n sender.sendMessage(ChatColor.RED + \"He is not disguised!\");\n } else\n sender.sendMessage(ChatColor.RED + \"Player not found\");\n } else\n sender.sendMessage(ChatColor.RED + \"/undisguiseplayer \");\n } else\n sender.sendMessage(ChatColor.RED + \"You are forbidden to use this command!\");\n return true;\n }\n", "output": " public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n if (sender.hasPermission(\"libsdisguises.undisguiseplayer\")) {\n if (args.length > 0) {\n Player p = Bukkit.getPlayer(args[0]);\n if (p != null) {\n if (DisguiseAPI.isDisguised(p)) {\n DisguiseAPI.undisguiseToAll(p);\n sender.sendMessage(ChatColor.RED + \"The player is no longer disguised\");\n } else\n sender.sendMessage(ChatColor.RED + \"The player is not disguised!\");\n } else\n sender.sendMessage(ChatColor.RED + \"Player not found\");\n } else\n sender.sendMessage(ChatColor.RED + \"/undisguiseplayer \");\n } else\n sender.sendMessage(ChatColor.RED + \"You are forbidden to use this command!\");\n return true;\n }\n"} {"input": " public KitsComponent(UsefulCommandPlugin plugin) {\n super(plugin);\n this.kits = new HashMap();\n File folder = getFolder();\n if (folder == null) {\n return;\n }\n GConfLoader loader = plugin.getGConfLoader();\n for (File file : folder.listFiles()) {\n String filename = file.getName();\n try {\n Kit kit = loader.loadOrCreate(filename, Kit.class);\n kits.put(getKitNameFor(filename), kit);\n } catch (GConfLoadException exc) {\n plugin.getLogger().severe(\"Unable to read \"\n + filename + \" kit file.\");\n }\n }\n }\n", "output": " public KitsComponent(UsefulCommandPlugin plugin) {\n super(plugin);\n this.kits = new HashMap();\n File folder = getFolder();\n if (folder == null) {\n return;\n }\n GConfLoader loader = plugin.getGConfLoader();\n for (File file : folder.listFiles()) {\n String filename = folder.getName()\n + File.separator + file.getName();\n System.out.println(filename);\n try {\n Kit kit = loader.loadOrCreate(filename, Kit.class);\n kits.put(getKitNameFor(filename), kit);\n } catch (GConfLoadException exc) {\n plugin.getLogger().severe(\"Unable to read \"\n + filename + \" kit file.\");\n }\n }\n }\n"} {"input": "\tpublic static ROIList createNewROIList(Class clazz) {\n\t\tif (clazz == null)\n\t\t\treturn null;\n\t\tif (PolygonalROI.class.equals(clazz))\n\t\t\treturn new PolygonalROIList();\n\t\telse if (PolylineROI.class.equals(clazz))\n\t\t\treturn new PolylineROIList();\n\t\telse if (PointROI.class.equals(clazz))\n\t\t\treturn new PointROIList();\n\t\telse if (LinearROI.class.equals(clazz))\n\t\t\treturn new LinearROIList();\n\t\telse if (RectangularROI.class.equals(clazz))\n\t\t\treturn new RectangularROIList();\n\t\telse if (SectorROI.class.equals(clazz))\n\t\t\treturn new SectorROIList();\n\t\telse if (CircularROI.class.equals(clazz))\n\t\t\treturn new CircularROIList();\n\t\telse if (EllipticalFitROI.class.equals(clazz))\n\t\t\treturn new EllipticalFitROIList();\n\t\telse if (EllipticalROI.class.equals(clazz))\n\t\t\treturn new EllipticalROIList();\n\t\tthrow new UnsupportedOperationException(\"No corresponding ROI list class\");\n\t}\n", "output": "\tpublic static ROIList createNewROIList(Class clazz) {\n\t\tif (clazz == null)\n\t\t\treturn null;\n\t\tif (PolygonalROI.class.isAssignableFrom(clazz))\n\t\t\treturn new PolygonalROIList();\n\t\telse if (PolylineROI.class.isAssignableFrom(clazz))\n\t\t\treturn new PolylineROIList();\n\t\telse if (PointROI.class.isAssignableFrom(clazz))\n\t\t\treturn new PointROIList();\n\t\telse if (LinearROI.class.isAssignableFrom(clazz))\n\t\t\treturn new LinearROIList();\n\t\telse if (RectangularROI.class.isAssignableFrom(clazz))\n\t\t\treturn new RectangularROIList();\n\t\telse if (SectorROI.class.isAssignableFrom(clazz))\n\t\t\treturn new SectorROIList();\n\t\telse if (CircularROI.class.isAssignableFrom(clazz))\n\t\t\treturn new CircularROIList();\n\t\telse if (EllipticalFitROI.class.isAssignableFrom(clazz))\n\t\t\treturn new EllipticalFitROIList();\n\t\telse if (EllipticalROI.class.isAssignableFrom(clazz))\n\t\t\treturn new EllipticalROIList();\n\t\tthrow new UnsupportedOperationException(\"No corresponding ROI list class\");\n\t}\n"} {"input": "\tpublic static void main(String[] args) throws ClassNotFoundException, SQLException {\n\t\tSimpleConnectionPool pool = (args != null && args.length >= 4) ?\n\t\t \t\tSimpleConnectionPool.createDefaultPool(args[0],args[1], args[2], args[3])\n\t\t \t:\n\t\t \t\tSimpleConnectionPool.createDefaultPool(\"org.hsqldb.jdbc.JDBCDriver\",\n\t\t\t\t\"jdbc:hsqldb:mem:power-test\", \"sa\", \"\");\n\t\tConnection connection = pool.getConnection();\n\t\tdoSomethingWithDatabase(connection);\n\t\tpool.releaseConnection(connection);\t\n\t\tpool.stop();\n\t}\n", "output": "\tpublic static void main(String[] args) throws ClassNotFoundException, SQLException {\n\t\tSimpleConnectionPool pool = (args != null && args.length >= 4) ?\n\t\t \t\tSimpleConnectionPool.createDefaultPool(args[0],args[1], args[2], args[3])\n\t\t \t:\n\t\t \t\tSimpleConnectionPool.createDefaultPool(\"org.hsqldb.jdbc.JDBCDriver\",\n\t\t\t\t\"jdbc:hsqldb:mem:power-test\", \"sa\", \"\");\n\t\tConnection connection = pool.getConnection(); \n\t\tdoSomethingWithDatabase(connection);\n\t\tpool.releaseConnection(connection);\t\n\t\tpool.stop();\n\t}\n"} {"input": "\tpublic void onPlayerInteract(PlayerInteractEvent event)\n\t{\n\t\tAction action = event.getAction();\n\t\tif(action == Action.RIGHT_CLICK_AIR||action == Action.RIGHT_CLICK_BLOCK)\n\t\t{\n\t\t\tint pickid = 278;\n\t\t\tif(event.getItem()!=null)\n\t\t\tif(event.getItem().getTypeId()==pickid)\n\t\t\t{\n\t\t\t\tif (plugin.lightningpick.containsKey(event.getPlayer()))\n\t\t\t\t{\n\t\t\t\t\tBlock targetBlock = event.getPlayer().getTargetBlock(null, 35);\n\t\t\t\t\tif (targetBlock!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tLocation strikeloc = targetBlock.getLocation();\n\t\t\t\t\t\tevent.getPlayer().getWorld().strikeLightning(strikeloc);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tevent.getPlayer().sendMessage(\"No block in sight\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void onPlayerInteract(PlayerInteractEvent event)\n\t{\n\t\tif(!event.isCancelled())\n\t\t{\n\t\t\tAction action = event.getAction();\n\t\t\tif(action == Action.RIGHT_CLICK_AIR||action == Action.RIGHT_CLICK_BLOCK)\n\t\t\t{\n\t\t\t\tint pickid = 278;\n\t\t\t\tif(event.getItem()!=null)\n\t\t\t\t\tif(event.getItem().getTypeId()==pickid)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (plugin.lightningpick.containsKey(event.getPlayer()))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tBlock targetBlock = event.getPlayer().getTargetBlock(null, 35);\n\t\t\t\t\t\t\tif (targetBlock!=null)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tLocation strikeloc = targetBlock.getLocation();\n\t\t\t\t\t\t\t\tevent.getPlayer().getWorld().strikeLightning(strikeloc);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tevent.getPlayer().sendMessage(\"No block in sight\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic Object wrapper(int count, String methodName, Object... arguments){\n\t\tif (count > 5){\n\t\t\tSystem.out.println(\"Giving up after many tries!\");\n\t\t\treturn null;\n\t\t}\n\t\tObject result=null;\n\t\ttry {\n\t\t\tMethod method = getMethod(methodName);\n\t\t\tObject res = method.invoke(askPort, arguments);\n\t\t\tMethod error = res.getClass().getMethod(\"getError\");\n\t\t\tif ( (Integer)error.invoke(res) == 101){\n\t\t\t\tthis.startSession();\n\t\t\t\tres = method.invoke(askPort, arguments);\n\t\t\t}\n\t\t\treturn res;\n\t\t} catch (IllegalArgumentException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IllegalAccessException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (InvocationTargetException e) {\n\t\t\tif (e.getCause().getCause().getClass().getName().equals(\"java.net.SocketTimeoutException\")){\n\t\t\t\tSystem.out.println(\"Timeout, re-trying \"+count);\n\t\t\t\treturn wrapper(count++,methodName,arguments);\n\t\t\t} else {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t} catch (SecurityException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (NoSuchMethodException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn result;\n\t}\n", "output": "\tpublic Object wrapper(int count, String methodName, Object... arguments){\n\t\tcount++;\n\t\tif (count > 5){\n\t\t\tSystem.out.println(\"Giving up after many tries!\");\n\t\t\treturn null;\n\t\t}\n\t\tObject result=null;\n\t\ttry {\n\t\t\tMethod method = getMethod(methodName);\n\t\t\tObject res = method.invoke(askPort, arguments);\n\t\t\tMethod error = res.getClass().getMethod(\"getError\");\n\t\t\tif ( (Integer)error.invoke(res) == 101){\n\t\t\t\tthis.startSession();\n\t\t\t\tres = method.invoke(askPort, arguments);\n\t\t\t}\n\t\t\treturn res;\n\t\t} catch (IllegalArgumentException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IllegalAccessException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (InvocationTargetException e) {\n\t\t\tif (e.getCause().getCause().getClass().getName().equals(\"java.net.SocketTimeoutException\")){\n\t\t\t\tSystem.out.println(\"Timeout, re-trying:\"+count);\n\t\t\t\treturn wrapper(count,methodName,arguments);\n\t\t\t} else {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t} catch (SecurityException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (NoSuchMethodException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn result;\n\t}\n"} {"input": " public static void registerCustomCodecs()\n {\n if(codecsRegistered)\n return;\n @SuppressWarnings(\"unchecked\")\n Collection registeredPlugins\n = new HashSet(\n PlugInManager.getPlugInList(\n null,\n null,\n PlugInManager.CODEC));\n boolean commit = false;\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.colorspace.JavaRGBToYUV\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.colorspace.JavaRGBConverter\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.colorspace.RGBScaler\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.vh263.NativeDecoder\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.ibm.media.codec.video.h263.NativeEncoder\",\n PlugInManager.CODEC);\n String gsmCodecPackage = \"com.ibm.media.codec.audio.gsm.\";\n String[] gsmCodecClasses\n = new String[]\n {\n \"JavaDecoder\",\n \"JavaDecoder_ms\",\n \"JavaEncoder\",\n \"JavaEncoder_ms\",\n \"NativeDecoder\",\n \"NativeDecoder_ms\",\n \"NativeEncoder\",\n \"NativeEncoder_ms\",\n \"Packetizer\"\n };\n for(String gsmCodecClass : gsmCodecClasses)\n {\n PlugInManager.removePlugIn(\n gsmCodecPackage + gsmCodecClass,\n PlugInManager.CODEC);\n }\n PlugInManager.removePlugIn(\n \"net.sf.fmj.media.codec.JavaSoundCodec\",\n PlugInManager.CODEC);\n for (String className : CUSTOM_CODECS)\n {\n if (className == null)\n continue;\n if (registeredPlugins.contains(className))\n {\n if (logger.isDebugEnabled())\n logger.debug(\n \"Codec \" + className + \" is already registered\");\n }\n else\n {\n commit = true;\n boolean registered;\n Throwable exception = null;\n try\n {\n Codec codec = (Codec)\n Class.forName(className).newInstance();\n registered =\n PlugInManager.addPlugIn(\n className,\n codec.getSupportedInputFormats(),\n codec.getSupportedOutputFormats(null),\n PlugInManager.CODEC);\n }\n catch (Throwable ex)\n {\n registered = false;\n exception = ex;\n }\n if (registered)\n {\n if (logger.isDebugEnabled())\n {\n logger.debug(\n \"Codec \"\n + className\n + \" is successfully registered\");\n }\n }\n else\n {\n if (logger.isDebugEnabled())\n {\n logger.debug(\n \"Codec \"\n + className\n + \" is NOT succsefully registered\",\n exception);\n }\n }\n }\n }\n @SuppressWarnings(\"unchecked\")\n Vector codecs\n = PlugInManager.getPlugInList(null, null, PlugInManager.CODEC);\n if (codecs != null)\n {\n boolean setPlugInList = false;\n for (int i = CUSTOM_CODECS.length - 1; i >= 0; i--)\n {\n String className = CUSTOM_CODECS[i];\n if (className != null)\n {\n int classNameIndex = codecs.indexOf(className);\n if (classNameIndex != -1)\n {\n codecs.remove(classNameIndex);\n codecs.add(0, className);\n setPlugInList = true;\n }\n }\n }\n if (setPlugInList)\n PlugInManager.setPlugInList(codecs, PlugInManager.CODEC);\n }\n if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad())\n {\n try\n {\n PlugInManager.commit();\n }\n catch (IOException ex)\n {\n logger.error(\"Cannot commit to PlugInManager\", ex);\n }\n }\n codecsRegistered = true;\n }\n", "output": " public static void registerCustomCodecs()\n {\n if(codecsRegistered)\n return;\n @SuppressWarnings(\"unchecked\")\n Collection registeredPlugins\n = new HashSet(\n PlugInManager.getPlugInList(\n null,\n null,\n PlugInManager.CODEC));\n boolean commit = false;\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.colorspace.JavaRGBToYUV\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.colorspace.JavaRGBConverter\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.colorspace.RGBScaler\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.sun.media.codec.video.vh263.NativeDecoder\",\n PlugInManager.CODEC);\n PlugInManager.removePlugIn(\n \"com.ibm.media.codec.video.h263.NativeEncoder\",\n PlugInManager.CODEC);\n String gsmCodecPackage = \"com.ibm.media.codec.audio.gsm.\";\n String[] gsmCodecClasses\n = new String[]\n {\n \"JavaDecoder\",\n \"JavaDecoder_ms\",\n \"JavaEncoder\",\n \"JavaEncoder_ms\",\n \"NativeDecoder\",\n \"NativeDecoder_ms\",\n \"NativeEncoder\",\n \"NativeEncoder_ms\",\n \"Packetizer\"\n };\n for(String gsmCodecClass : gsmCodecClasses)\n {\n PlugInManager.removePlugIn(\n gsmCodecPackage + gsmCodecClass,\n PlugInManager.CODEC);\n }\n PlugInManager.removePlugIn(\n \"net.sf.fmj.media.codec.JavaSoundCodec\",\n PlugInManager.CODEC);\n for (String className : CUSTOM_CODECS)\n {\n if (className == null)\n continue;\n if (registeredPlugins.contains(className))\n {\n if (logger.isDebugEnabled())\n logger.debug(\n \"Codec \" + className + \" is already registered\");\n }\n else\n {\n commit = true;\n boolean registered;\n Throwable exception = null;\n try\n {\n Codec codec = (Codec)\n Class.forName(className).newInstance();\n registered =\n PlugInManager.addPlugIn(\n className,\n codec.getSupportedInputFormats(),\n codec.getSupportedOutputFormats(null),\n PlugInManager.CODEC);\n }\n catch (Throwable ex)\n {\n registered = false;\n exception = ex;\n }\n if (registered)\n {\n if (logger.isDebugEnabled())\n {\n logger.debug(\n \"Codec \"\n + className\n + \" is successfully registered\");\n }\n }\n else\n {\n if (logger.isDebugEnabled())\n {\n logger.debug(\n \"Codec \"\n + className\n + \" is NOT successfully registered\",\n exception);\n }\n }\n }\n }\n @SuppressWarnings(\"unchecked\")\n Vector codecs\n = PlugInManager.getPlugInList(null, null, PlugInManager.CODEC);\n if (codecs != null)\n {\n boolean setPlugInList = false;\n for (int i = CUSTOM_CODECS.length - 1; i >= 0; i--)\n {\n String className = CUSTOM_CODECS[i];\n if (className != null)\n {\n int classNameIndex = codecs.indexOf(className);\n if (classNameIndex != -1)\n {\n codecs.remove(classNameIndex);\n codecs.add(0, className);\n setPlugInList = true;\n }\n }\n }\n if (setPlugInList)\n PlugInManager.setPlugInList(codecs, PlugInManager.CODEC);\n }\n if (commit && !MediaServiceImpl.isJmfRegistryDisableLoad())\n {\n try\n {\n PlugInManager.commit();\n }\n catch (IOException ex)\n {\n logger.error(\"Cannot commit to PlugInManager\", ex);\n }\n }\n codecsRegistered = true;\n }\n"} {"input": " public void validate() throws LdapException\n {\n StringBuilder sb = new StringBuilder();\n int errCount = 0;\n if ( pwdMinAge < 0 )\n {\n sb.append( ++errCount ).append( \". password minimum age cannot be negative\\n\" );\n }\n if ( pwdMaxAge < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum age cannot be negative\\n\" );\n }\n if ( ( pwdMaxAge > 0 ) && ( pwdMaxAge < pwdMinAge ) )\n {\n sb.append( ++errCount ).append( \". password maximum age should be greater than the minimum age\\n\" );\n }\n if ( pwdInHistory < 0 )\n {\n sb.append( ++errCount ).append( \". password history count cannot be negative\\n\" );\n }\n if ( ( pwdCheckQuality < 0 ) || ( pwdCheckQuality > 2 ) )\n {\n sb.append( ++errCount ).append( \". invalid password quality check value, valid values are 0, 1 and 2 \\n\" );\n }\n if ( pwdMinLength < 0 )\n {\n sb.append( ++errCount ).append( \". password minimum length cannot be negative\\n\" );\n }\n if ( pwdMaxLength < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum length cannot be negative\\n\" );\n }\n if ( pwdMaxLength < pwdMinLength )\n {\n sb.append( ++errCount ).append( \". password maximum length should be greater than minimum length\\n\" );\n }\n if ( pwdExpireWarning < 0 )\n {\n sb.append( ++errCount ).append( \". password expire warning time cannot be negative\\n\" );\n }\n if ( pwdGraceAuthNLimit < 0 )\n {\n sb.append( ++errCount ).append( \". password grace authentication limits cannot be negative\\n\" );\n }\n if ( pwdGraceExpire < 0 )\n {\n sb.append( ++errCount ).append( \". password grace expiration time cannot be negative\\n\" );\n }\n if ( pwdLockoutDuration < 0 )\n {\n sb.append( ++errCount ).append( \". password lockout duration time cannot be negative\\n\" );\n }\n if ( pwdMaxFailure < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum failure count cannot be negative\\n\" );\n }\n if ( pwdFailureCountInterval < 0 )\n {\n sb.append( ++errCount ).append( \". password failure count interval time cannot be negative\\n\" );\n }\n if ( ( ( pwdMinDelay > 0 ) && ( pwdMaxDelay <= 0 ) ) \n || ( ( pwdMaxDelay > 0 ) && ( pwdMinDelay <= 0 ) ) )\n {\n sb\n .append( ++errCount )\n .append(\n \". if password minimum or maximum delay time is specified then the correspomding maximu or minimum delay time should also be specified\\n\" );\n }\n else\n {\n if ( pwdMinDelay < 0 )\n {\n sb.append( ++errCount ).append( \". password minimum delay time cannot be negative\\n\" );\n }\n if ( pwdMaxDelay < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum delay time cannot be negative\\n\" );\n }\n }\n if ( pwdMaxIdle < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum idle time cannot be negative\\n\" );\n }\n if ( errCount > 0 )\n {\n throw new LdapException( \"There are errors in password policy configuration\\n\" + sb.toString() );\n }\n }\n", "output": " public void validate() throws LdapException\n {\n StringBuilder sb = new StringBuilder();\n int errCount = 0;\n if ( pwdMinAge < 0 )\n {\n sb.append( ++errCount ).append( \". password minimum age cannot be negative\\n\" );\n }\n if ( pwdMaxAge < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum age cannot be negative\\n\" );\n }\n if ( ( pwdMaxAge > 0 ) && ( pwdMaxAge < pwdMinAge ) )\n {\n sb.append( ++errCount ).append( \". password maximum age should be greater than the minimum age\\n\" );\n }\n if ( pwdInHistory < 0 )\n {\n sb.append( ++errCount ).append( \". password history count cannot be negative\\n\" );\n }\n if ( ( pwdCheckQuality < 0 ) || ( pwdCheckQuality > 2 ) )\n {\n sb.append( ++errCount ).append( \". invalid password quality check value, valid values are 0, 1 and 2 \\n\" );\n }\n if ( pwdMinLength < 0 )\n {\n sb.append( ++errCount ).append( \". password minimum length cannot be negative\\n\" );\n }\n if ( pwdMaxLength < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum length cannot be negative\\n\" );\n }\n if ( ( pwdMaxLength > 0 ) && ( pwdMaxLength < pwdMinLength ) )\n {\n sb.append( ++errCount ).append( \". password maximum length should be greater than minimum length\\n\" );\n }\n if ( pwdExpireWarning < 0 )\n {\n sb.append( ++errCount ).append( \". password expire warning time cannot be negative\\n\" );\n }\n if ( pwdGraceAuthNLimit < 0 )\n {\n sb.append( ++errCount ).append( \". password grace authentication limits cannot be negative\\n\" );\n }\n if ( pwdGraceExpire < 0 )\n {\n sb.append( ++errCount ).append( \". password grace expiration time cannot be negative\\n\" );\n }\n if ( pwdLockoutDuration < 0 )\n {\n sb.append( ++errCount ).append( \". password lockout duration time cannot be negative\\n\" );\n }\n if ( pwdMaxFailure < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum failure count cannot be negative\\n\" );\n }\n if ( pwdFailureCountInterval < 0 )\n {\n sb.append( ++errCount ).append( \". password failure count interval time cannot be negative\\n\" );\n }\n if ( ( ( pwdMinDelay > 0 ) && ( pwdMaxDelay <= 0 ) ) \n || ( ( pwdMaxDelay > 0 ) && ( pwdMinDelay <= 0 ) ) )\n {\n sb\n .append( ++errCount )\n .append(\n \". if password minimum or maximum delay time is specified then the correspomding maximu or minimum delay time should also be specified\\n\" );\n }\n else\n {\n if ( pwdMinDelay < 0 )\n {\n sb.append( ++errCount ).append( \". password minimum delay time cannot be negative\\n\" );\n }\n if ( pwdMaxDelay < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum delay time cannot be negative\\n\" );\n }\n }\n if ( pwdMaxIdle < 0 )\n {\n sb.append( ++errCount ).append( \". password maximum idle time cannot be negative\\n\" );\n }\n if ( errCount > 0 )\n {\n throw new LdapException( \"There are errors in password policy configuration\\n\" + sb.toString() );\n }\n }\n"} {"input": " public void run() {\n while (!shutdown) {\n if (paused) {\n try {\n Thread.sleep(100);\n } catch (InterruptedException e) {\n }\n } else {\n if (!photosToLoad.isEmpty()) {\n for (final ImageView icon : photosToLoad.keySet()) {\n Long contactId = photosToLoad.get(icon);\n Drawable drawable = null;\n InputStream photoStream;\n if ((photoStream = BirthdayProvider.openPhoto(ctx, contactId)) != null) {\n drawable = Drawable.createFromStream(photoStream, \"src\");\n }\n cache.put(contactId, drawable == null ? DEFAULT_PHOTO : drawable);\n photosToLoad.remove(icon);\n updateImage(icon, drawable);\n }\n }\n }\n }\n }\n", "output": " public void run() {\n while (!shutdown) {\n if (paused) {\n try {\n Thread.sleep(100);\n } catch (InterruptedException e) {\n }\n } else {\n if (!photosToLoad.isEmpty()) {\n for (final ImageView icon : photosToLoad.keySet()) {\n Long contactId = photosToLoad.get(icon);\n Drawable drawable = null;\n InputStream photoStream;\n if ((photoStream = BirthdayProvider.openPhoto(ctx, contactId)) != null) {\n try {\n drawable = Drawable.createFromStream(photoStream, \"src\");\n } catch (Throwable e) {\n Log.i(\"PhotoLoader\", \"Error loading photo.\", e);\n }\n }\n cache.put(contactId, drawable == null ? DEFAULT_PHOTO : drawable);\n photosToLoad.remove(icon);\n updateImage(icon, drawable);\n }\n }\n }\n }\n }\n"} {"input": " private void writeWaveHeader() throws IOException {\n RandomAccessFile file = new RandomAccessFile(this.output, \"rw\");\n file.seek(0);\n int bytesPerSec = (sampleBits + 7) / 8;\n file.writeBytes(\"RIFF\"); \n file.writeInt(Integer.reverseBytes(bytesWritten + 36)); \n file.writeBytes(\"WAVEfmt \");\n file.writeInt(Integer.reverseBytes(16)); \n file.writeShort(Short.reverseBytes((short) 1)); \n file.writeShort(Short.reverseBytes((short) channels)); \n file.writeInt(Integer.reverseBytes(sampleRate)); \n file\n .writeInt(Integer.reverseBytes(sampleRate * channels\n * bytesPerSec)); \n file.writeShort(Short.reverseBytes((short) (channels * bytesPerSec))); \n file.writeShort(Short.reverseBytes((short) sampleBits)); \n file.writeBytes(\"data\"); \n file.writeInt(Integer.reverseBytes(bytesWritten)); \n file.close();\n file = null;\n }\n", "output": " private void writeWaveHeader() throws IOException {\n RandomAccessFile file = new RandomAccessFile(this.output, \"rw\");\n file.seek(0);\n int bytesPerSec = (sampleBits + 7) / 8;\n file.writeBytes(\"RIFF\"); \n file.writeInt(Integer.reverseBytes(bytesWritten + 36)); \n file.writeBytes(\"WAVEfmt \");\n file.writeInt(Integer.reverseBytes(16)); \n file.writeShort(Short.reverseBytes((short) 1)); \n file.writeShort(Short.reverseBytes((short) channels)); \n file.writeInt(Integer.reverseBytes(sampleRate)); \n file.writeInt(Integer.reverseBytes(sampleRate * channels * bytesPerSec)); \n file.writeShort(Short.reverseBytes((short) (channels * bytesPerSec))); \n file.writeShort(Short.reverseBytes((short) sampleBits)); \n file.writeBytes(\"data\"); \n file.writeInt(Integer.reverseBytes(bytesWritten)); \n file.close();\n file = null;\n }\n"} {"input": "\tpublic String getMethodOne(\n HttpServletResponse response,\n\t\t\tHttpServletRequest request,\n\t\t\tModelMap model) {\t \n\t\t try{\n\t\t logger.warning(\"Entering application via GEt\");\n\t\t GetBeansFromContext gcfc = new GetBeansFromContext();\n\t\t con = gcfc.myConnection();\n\t Statement statement = con.createStatement();\n\t ResultSet resultSet = null;\n\t HttpSession session = request.getSession(true);\n\t User user = (User) session.getAttribute(\"myUser\");\n\t \t\t if (user==null ) {\n\t \t\t model.addAttribute(\"errortext\",\"You must logon before you can access IDS\");\n\t \t\t \t return \"login\";\n\t \t\t }\n\t \t\t if (request.getParameter(\"exit\")!= null ){\n\t \t\t\t if (session.getAttribute(\"myUser\") != null) {\n\t \t\t\t session.setAttribute(\"myUser\",null);\n\t \t\t\t }\n\t \t\t\treturn \"login\"; \n\t \t\t }\n\t \t\tString query = \" select 'found' as found from ids_users where userId = '\"+user.getUserName()\n\t\t\t\t\t +\"' and passwordId = '\"+user.getPassword()+\"'\";\n\t\t\t resultSet = statement.executeQuery(query);\n\t boolean found = false;\n\t\t\t while (resultSet.next()) {\n\t\t\t\t if (resultSet.getString(\"found\").equals(\"found\")) {\n\t\t\t\t\t found = true;\n\t\t\t\t\t break;\n\t\t\t\t }\n\t\t\t\t break;\n\t\t\t }\n\t\t\t if (!found) {\n\t\t \t\t model.addAttribute(\"errortext\",\"Invalid user credentials\");\n\t\t \t\t \t return \"login\";\n\t\t\t }\n\t\t\t model.addAttribute(\"openOrClose\",\"close\");\n\t\t\t String access = request.getParameter(\"access\");\n\t\t\t logger.warning(\"access: \"+access);\n\t\t\t if (request.getParameter(\"save\")!= null ) {\n\t\t\t\t PreparedStatement statement2 = (PreparedStatement) con.prepareStatement(\"insert into Facts_\"+access+\" \" +\n\t\t\t\t \t\t\" select * from FactsEdit_\"+access + \" WHERE flag ='I' \");\n\t\t\t\t statement2.executeUpdate();\n\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"delete from Facts_\"+access+\" \" +\n\t\t\t\t\t \t\t\" where exists (select 1 from FactsEdit_\"+access+\" cc \" +\n\t\t\t\t\t \t\t \" where cc.year= Facts_\"+access+\".year and cc.countryId = Facts_\"+access+\".countryId and cc.companyId = Facts_\"+access+\".companyId \" +\n\t\t\t\t\t \t\t\" and cc.sales_production = Facts_\"+access+\".sales_production and Facts_\"+access+\".productId = cc.productId \" +\n\t\t\t\t\t \t\t\" and cc.flag = 'X' ) \");\n\t\t\t\t logger.warning(\"delete from Facts_\"+access+\" \" +\n\t\t\t\t\t \t\t\" where exists (select 1 from FactsEdit_\"+access+\" cc \" +\n\t\t\t\t\t \t\t \" where cc.year= Facts_\"+access+\".year and cc.countryId = Facts_\"+access+\".countryId and cc.companyId = Facts_\"+access+\".companyId \" +\n\t\t\t\t\t \t\t\" and cc.sales_production = Facts_\"+access+\".sales_production and Facts_\"+access+\".productId = cc.productId \" +\n\t\t\t\t\t \t\t\" and cc.flag = 'X') \");\n\t\t\t\t\t statement2.executeUpdate();\n\t\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"update Facts_\"+access +\" aa INNER JOIN \" +\n\t\t\t\t\t \" FactsEdit_\"+access+\" bb ON ( aa.year= bb.year and aa.countryId = bb.countryId and aa.companyId = aa.companyId \" +\n\t\t\t\t\t \t\t\" and aa.sales_production = bb.sales_production and bb.productId = aa.productId) \" +\n\t\t\t\t\t \t\t\" set aa.quantity = bb.quantity \" +\n\t\t\t\t \" WHERE bb.flag = 'U'\"); \n\t\t\t\t\t statement2.executeUpdate();\n\t\t\t\t\t con.commit();\n\t\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"delete from FactsEdit_\"+access+\" where flag = 'X' \");\n\t\t\t\t\t\t statement2.executeUpdate();\n\t\t\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"update FactsEdit_\"+access+\" set flag = '' where flag in ( 'I','D','U' \");\n\t\t\t\t\t\t statement2.executeUpdate(); \n\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"update editing set flag = '0' \");\n\t\t\t\t statement2.executeUpdate();\n\t\t\t\t con.commit();\n\t\t\t\t model.addAttribute(\"saveBut\",\"none\");\n\t\t\t\t model.addAttribute(\"openOrClose\",\"open\");\n\t\t\t\t return \"redirect:editor\";\n\t\t\t }\n\t\t\t String year = \"\";\n\t\t\t String productId = \"\";\n\t\t\t String countryId = \"\";\n\t\t\t String companyId = \"\";\n\t\t\t String PorS =\"\";\n\t\t\t String SQL = \"\";\n\t\t\t String value = request.getParameter(\"dimension1Name\");\n\t\t\t value = WordUtils.capitalize(value); \n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension1Val\");\n } else {\n \t SQL = \" select id from \"+value+ \" where name = '\" +request.getParameter(\"dimension1Val\") +\"' \";\n \t logger.warning(\"SQL1: \"+SQL);\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t if (value.equals(\"Country\")) {\n \t\t\t countryId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Company\")) {\n \t\t\t companyId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t }\n }\n value = request.getParameter(\"dimension2Name\");\n value =WordUtils.capitalize(value) ;\n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension2Val\");\n } else {\n \t if (request.getParameter(\"dimension2Name\").trim().equals(\"Country\")){\n \t\t SQL = \" select id from \"+value+ \" where country = '\" +request.getParameter(\"dimension2Val\").trim() +\"' \";\n \t } else {\n \t SQL = \" select id from \"+value+ \" where name = '\" +request.getParameter(\"dimension2Val\").trim() +\"' \";\n \t }\n \t logger.warning(\"SQL2: \"+SQL);\n \tlogger.warning(\"value2: \"+value);\n \tif (resultSet != null) {\n \t\tresultSet.close();\n \t}\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t logger.warning(\"got in here ok\");\n \t\t if (value.trim().equals(\"Country\")) {\n \t\t\t logger.warning(\"come one we must have got in here\");\n \t\t\t countryId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Company\")) {\n \t\t\t companyId=Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t }\n }\n value = request.getParameter(\"dimension3Name\");\n value =WordUtils.capitalize(value) ;\n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension3Val\");\n } else {\n \t if (value.equals(\"Country\")) {\n \t SQL = \" select id from \"+value+ \" where country = '\" +request.getParameter(\"dimension3Val\").trim() +\"' \";\n \t }else{\n \t\t SQL = \" select id from \"+value+ \" where name = '\" +request.getParameter(\"dimension3Val\").trim() +\"' \"; \n \t }\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t if (value.equals(\"Country\")) {\n \t\t\t countryId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Company\")) {\n \t\t\t companyId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t } \n }\n if (request.getParameter(\"dimension4Val\").equals(\"Sales\") ) {\n \t PorS= \"1\"; \n } else {\n \t PorS = \"2\";\n }\n value = request.getParameter(\"dimension5Name\");\n value =WordUtils.capitalize(value) ;\n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension5Val\");\n } else { \n \t value = value.substring(0,value.indexOf(\" \"));\n \t SQL = \" select id from \"+value+ \" where shortname = '\" +request.getParameter(\"dimension5Val\") +\"' \";\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t if (value.equals(\"Country\")) {\n \t\t\t countryId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t } \n }\n logger.warning(\"year: \"+year);\n logger.warning(\"productId: \"+productId);\n logger.warning(\"countryId: \"+countryId);\n logger.warning(\"companyId: \"+companyId);\n logger.warning(\"PorS: \"+PorS);\n int quant =0;\n if (!request.getParameter(\"FactVal\").trim().equals(\"\")) { \n quant = Integer.parseInt(request.getParameter(\"FactVal\"));\n }\n if (quant==0) {\n \t PreparedStatement statement2 = (PreparedStatement) con.prepareStatement(\"Update FactsEdit_\"+access+\" set flag='X' where \"+\n \t\t \" productId = \"+productId + \" and year = \"+year+ \" and access = '\"+access+\"' \"+\n \t\t \" and companyId = \"+companyId + \" and countryId = \"+countryId+ \" and sales_production = \"+PorS);\n int retval = statement2.executeUpdate();\n }else {\n PreparedStatement statement2 = (PreparedStatement) con.prepareStatement(\"Update FactsEdit_\"+access+\" set quantity = \"+\n \t\t request.getParameter(\"FactVal\")+ \",flag='U' where productId = \"+productId + \" and access= '\"+access+\"' and year = \"+year+\n \t\t \" and companyId = \"+companyId + \" and countryId = \"+countryId+ \" and sales_production = \"+PorS);\n logger.warning(\"SQL: \"+\"Update FactsEdit_\"+access+\" set quantity = \"+\n \t\t request.getParameter(\"FactVal\")+ \" where productId = \"+productId + \" and access= '\"+access+\"' and year = \"+year+\n \t\t \" and companyId = \"+companyId + \" and countryId = \"+countryId+ \" and sales_production = \"+PorS);\n int retval = statement2.executeUpdate();\n if (retval==0) {\n \t String newSQL = \"Insert into FactsEdit_\"+access+\" (quantity, productId, year, companyId, countryId,\" +\n \t \t\t\" sales_production, access,flag) values (\"+request.getParameter(\"FactVal\")+\",\"+productId\n \t \t\t+\",\"+year+\",\"+companyId+\",\"+countryId+\",\"+PorS+\",'\"+access+\"','I')\";\n \t logger.warning(\"InsertSQL: \"+newSQL);\n \t statement2 = (PreparedStatement) con.prepareStatement(newSQL);\n \t retval = statement2.executeUpdate();\n }\n }\n \t String newSQL = \"update editing set flag = '1' \";\n \t PreparedStatement statement3 = (PreparedStatement) con.prepareStatement(newSQL);\n \t statement3.executeUpdate();\n con.commit();\n\t\t }\n catch(Exception e) {\n \tlogger.log(Level.SEVERE,\"error\",e);\n }\n\t\t\t return \"login\";\n\t }\n", "output": "\tpublic String getMethodOne(\n HttpServletResponse response,\n\t\t\tHttpServletRequest request,\n\t\t\tModelMap model) {\t \n\t\t try{\n\t\t logger.warning(\"Entering application via GEt\");\n\t\t GetBeansFromContext gcfc = new GetBeansFromContext();\n\t\t con = gcfc.myConnection();\n\t Statement statement = con.createStatement();\n\t ResultSet resultSet = null;\n\t HttpSession session = request.getSession(true);\n\t User user = (User) session.getAttribute(\"myUser\");\n\t \t\t if (user==null ) {\n\t \t\t model.addAttribute(\"errortext\",\"You must logon before you can access IDS\");\n\t \t\t \t return \"login\";\n\t \t\t }\n\t \t\t if (request.getParameter(\"exit\")!= null ){\n\t \t\t\t if (session.getAttribute(\"myUser\") != null) {\n\t \t\t\t session.setAttribute(\"myUser\",null);\n\t \t\t\t }\n\t \t\t\treturn \"login\"; \n\t \t\t }\n\t \t\tString query = \" select 'found' as found from ids_users where userId = '\"+user.getUserName()\n\t\t\t\t\t +\"' and passwordId = '\"+user.getPassword()+\"'\";\n\t\t\t resultSet = statement.executeQuery(query);\n\t boolean found = false;\n\t\t\t while (resultSet.next()) {\n\t\t\t\t if (resultSet.getString(\"found\").equals(\"found\")) {\n\t\t\t\t\t found = true;\n\t\t\t\t\t break;\n\t\t\t\t }\n\t\t\t\t break;\n\t\t\t }\n\t\t\t if (!found) {\n\t\t \t\t model.addAttribute(\"errortext\",\"Invalid user credentials\");\n\t\t \t\t \t return \"login\";\n\t\t\t }\n\t\t\t model.addAttribute(\"openOrClose\",\"close\");\n\t\t\t String access = request.getParameter(\"access\");\n\t\t\t logger.warning(\"access: \"+access);\n\t\t\t if (request.getParameter(\"save\")!= null ) {\n\t\t\t\t PreparedStatement statement2 = (PreparedStatement) con.prepareStatement(\"insert into Facts_\"+access+\" \" +\n\t\t\t\t \t\t\" select * from FactsEdit_\"+access + \" WHERE flag ='I' \");\n\t\t\t\t statement2.executeUpdate();\n\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"delete from Facts_\"+access+\" \" +\n\t\t\t\t\t \t\t\" where exists (select 1 from FactsEdit_\"+access+\" cc \" +\n\t\t\t\t\t \t\t \" where cc.year= Facts_\"+access+\".year and cc.countryId = Facts_\"+access+\".countryId and cc.companyId = Facts_\"+access+\".companyId \" +\n\t\t\t\t\t \t\t\" and cc.sales_production = Facts_\"+access+\".sales_production and Facts_\"+access+\".productId = cc.productId \" +\n\t\t\t\t\t \t\t\" and cc.flag = 'X' ) \");\n\t\t\t\t logger.warning(\"delete from Facts_\"+access+\" \" +\n\t\t\t\t\t \t\t\" where exists (select 1 from FactsEdit_\"+access+\" cc \" +\n\t\t\t\t\t \t\t \" where cc.year= Facts_\"+access+\".year and cc.countryId = Facts_\"+access+\".countryId and cc.companyId = Facts_\"+access+\".companyId \" +\n\t\t\t\t\t \t\t\" and cc.sales_production = Facts_\"+access+\".sales_production and Facts_\"+access+\".productId = cc.productId \" +\n\t\t\t\t\t \t\t\" and cc.flag = 'X') \");\n\t\t\t\t\t statement2.executeUpdate();\n\t\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"update Facts_\"+access +\" aa INNER JOIN \" +\n\t\t\t\t\t \" FactsEdit_\"+access+\" bb ON ( aa.year= bb.year and aa.countryId = bb.countryId and aa.companyId = aa.companyId \" +\n\t\t\t\t\t \t\t\" and aa.sales_production = bb.sales_production and bb.productId = aa.productId) \" +\n\t\t\t\t\t \t\t\" set aa.quantity = bb.quantity \" +\n\t\t\t\t \" WHERE bb.flag = 'U'\"); \n\t\t\t\t\t statement2.executeUpdate();\n\t\t\t\t\t con.commit();\n\t\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"delete from FactsEdit_\"+access+\" where flag = 'X' \");\n\t\t\t\t\t\t statement2.executeUpdate();\n\t\t\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"update FactsEdit_\"+access+\" set flag = '' where flag in ( 'I','D','U' )\");\n\t\t\t\t\t\t statement2.executeUpdate(); \n\t\t\t\t statement2 = (PreparedStatement) con.prepareStatement(\"update editing set flag = '0' \");\n\t\t\t\t statement2.executeUpdate();\n\t\t\t\t con.commit();\n\t\t\t\t model.addAttribute(\"saveBut\",\"none\");\n\t\t\t\t model.addAttribute(\"openOrClose\",\"open\");\n\t\t\t\t return \"redirect:editor\";\n\t\t\t }\n\t\t\t String year = \"\";\n\t\t\t String productId = \"\";\n\t\t\t String countryId = \"\";\n\t\t\t String companyId = \"\";\n\t\t\t String PorS =\"\";\n\t\t\t String SQL = \"\";\n\t\t\t String value = request.getParameter(\"dimension1Name\");\n\t\t\t value = WordUtils.capitalize(value); \n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension1Val\");\n } else {\n \t SQL = \" select id from \"+value+ \" where name = '\" +request.getParameter(\"dimension1Val\") +\"' \";\n \t logger.warning(\"SQL1: \"+SQL);\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t if (value.equals(\"Country\")) {\n \t\t\t countryId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Company\")) {\n \t\t\t companyId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t }\n }\n value = request.getParameter(\"dimension2Name\");\n value =WordUtils.capitalize(value) ;\n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension2Val\");\n } else {\n \t if (request.getParameter(\"dimension2Name\").trim().equals(\"Country\")){\n \t\t SQL = \" select id from \"+value+ \" where country = '\" +request.getParameter(\"dimension2Val\").trim() +\"' \";\n \t } else {\n \t SQL = \" select id from \"+value+ \" where name = '\" +request.getParameter(\"dimension2Val\").trim() +\"' \";\n \t }\n \t logger.warning(\"SQL2: \"+SQL);\n \tlogger.warning(\"value2: \"+value);\n \tif (resultSet != null) {\n \t\tresultSet.close();\n \t}\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t logger.warning(\"got in here ok\");\n \t\t if (value.trim().equals(\"Country\")) {\n \t\t\t logger.warning(\"come one we must have got in here\");\n \t\t\t countryId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Company\")) {\n \t\t\t companyId=Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t }\n }\n value = request.getParameter(\"dimension3Name\");\n value =WordUtils.capitalize(value) ;\n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension3Val\");\n } else {\n \t if (value.equals(\"Country\")) {\n \t SQL = \" select id from \"+value+ \" where country = '\" +request.getParameter(\"dimension3Val\").trim() +\"' \";\n \t }else{\n \t\t SQL = \" select id from \"+value+ \" where name = '\" +request.getParameter(\"dimension3Val\").trim() +\"' \"; \n \t }\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t if (value.equals(\"Country\")) {\n \t\t\t countryId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Company\")) {\n \t\t\t companyId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= Integer.toString(resultSet.getInt(\"id\"));\n \t\t\t break;\n \t\t }\n \t } \n }\n if (request.getParameter(\"dimension4Val\").equals(\"Sales\") ) {\n \t PorS= \"1\"; \n } else {\n \t PorS = \"2\";\n }\n value = request.getParameter(\"dimension5Name\");\n value =WordUtils.capitalize(value) ;\n if (value.equals(\"Year\")) {\n \t year = request.getParameter(\"dimension5Val\");\n } else { \n \t value = value.substring(0,value.indexOf(\" \"));\n \t SQL = \" select id from \"+value+ \" where shortname = '\" +request.getParameter(\"dimension5Val\") +\"' \";\n \t resultSet = statement.executeQuery(SQL);\n \t while (resultSet.next()) {\n \t\t if (value.equals(\"Country\")) {\n \t\t\t countryId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t\t if (value.equals(\"Product\")) {\n \t\t\t productId= resultSet.getString(\"id\");\n \t\t\t break;\n \t\t }\n \t } \n }\n logger.warning(\"year: \"+year);\n logger.warning(\"productId: \"+productId);\n logger.warning(\"countryId: \"+countryId);\n logger.warning(\"companyId: \"+companyId);\n logger.warning(\"PorS: \"+PorS);\n int quant =0;\n if (!request.getParameter(\"FactVal\").trim().equals(\"\")) { \n quant = Integer.parseInt(request.getParameter(\"FactVal\"));\n }\n if (quant==0) {\n \t PreparedStatement statement2 = (PreparedStatement) con.prepareStatement(\"Update FactsEdit_\"+access+\" set flag='X' where \"+\n \t\t \" productId = \"+productId + \" and year = \"+year+ \" and access = '\"+access+\"' \"+\n \t\t \" and companyId = \"+companyId + \" and countryId = \"+countryId+ \" and sales_production = \"+PorS);\n int retval = statement2.executeUpdate();\n }else {\n PreparedStatement statement2 = (PreparedStatement) con.prepareStatement(\"Update FactsEdit_\"+access+\" set quantity = \"+\n \t\t request.getParameter(\"FactVal\")+ \",flag='U' where productId = \"+productId + \" and access= '\"+access+\"' and year = \"+year+\n \t\t \" and companyId = \"+companyId + \" and countryId = \"+countryId+ \" and sales_production = \"+PorS);\n logger.warning(\"SQL: \"+\"Update FactsEdit_\"+access+\" set quantity = \"+\n \t\t request.getParameter(\"FactVal\")+ \" where productId = \"+productId + \" and access= '\"+access+\"' and year = \"+year+\n \t\t \" and companyId = \"+companyId + \" and countryId = \"+countryId+ \" and sales_production = \"+PorS);\n int retval = statement2.executeUpdate();\n if (retval==0) {\n \t String newSQL = \"Insert into FactsEdit_\"+access+\" (quantity, productId, year, companyId, countryId,\" +\n \t \t\t\" sales_production, access,flag) values (\"+request.getParameter(\"FactVal\")+\",\"+productId\n \t \t\t+\",\"+year+\",\"+companyId+\",\"+countryId+\",\"+PorS+\",'\"+access+\"','I')\";\n \t logger.warning(\"InsertSQL: \"+newSQL);\n \t statement2 = (PreparedStatement) con.prepareStatement(newSQL);\n \t retval = statement2.executeUpdate();\n }\n }\n \t String newSQL = \"update editing set flag = '1' \";\n \t PreparedStatement statement3 = (PreparedStatement) con.prepareStatement(newSQL);\n \t statement3.executeUpdate();\n con.commit();\n\t\t }\n catch(Exception e) {\n \tlogger.log(Level.SEVERE,\"error\",e);\n }\n\t\t\t return \"login\";\n\t }\n"} {"input": " public BombermenServerGui() throws Exception\n {\n setTitle(\"Bombermen Server\");\n setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);\n setBounds(100, 100, 800, 600);\n JMenuBar menuBar = new JMenuBar();\n setJMenuBar(menuBar);\n JMenu mnFile = new JMenu(\"File\");\n menuBar.add(mnFile);\n JMenuItem mntmExit = new JMenuItem(\"Exit\");\n mntmExit.addActionListener(new ActionListener()\n {\n public void actionPerformed(ActionEvent arg0)\n {\n BombermenServerGui.this.dispose();\n }\n });\n mnFile.add(mntmExit);\n contentPane = new JPanel();\n contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));\n setContentPane(contentPane);\n contentPane.setLayout(new BorderLayout(0, 0));\n JPanel panel = new JPanel();\n contentPane.add(panel, BorderLayout.NORTH);\n GridBagLayout gbl_panel = new GridBagLayout();\n gbl_panel.columnWidths = new int[] { 213 };\n gbl_panel.rowHeights = new int[] { 20, 0, 0 };\n gbl_panel.columnWeights = new double[] { 1.0 };\n gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };\n panel.setLayout(gbl_panel);\n JTextPane txtpnExtIP = new JTextPane();\n txtpnExtIP.setBackground(backgroundColor);\n txtpnExtIP.setText(\"External IP: \" + getIp());\n txtpnExtIP.setEditable(false);\n SimpleAttributeSet center = new SimpleAttributeSet();\n StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);\n txtpnExtIP.getStyledDocument().setParagraphAttributes(0, txtpnExtIP.getStyledDocument().getLength(), center, false);\n GridBagConstraints gbc_txtpnExtIP = new GridBagConstraints();\n gbc_txtpnExtIP.fill = GridBagConstraints.BOTH;\n gbc_txtpnExtIP.insets = new Insets(0, 0, 0, 5);\n gbc_txtpnExtIP.gridx = 0;\n gbc_txtpnExtIP.gridy = 1;\n panel.add(txtpnExtIP, gbc_txtpnExtIP);\n JTextPane txtPnIntIP = new JTextPane();\n txtPnIntIP.setBackground(backgroundColor);\n txtPnIntIP.setText(\"Lan IP: \" + InetAddress.getLocalHost().getHostAddress());\n txtPnIntIP.setEditable(false);\n txtPnIntIP.getStyledDocument().setParagraphAttributes(0, txtPnIntIP.getStyledDocument().getLength(), center, false);\n GridBagConstraints gbc_txtPnIntIP = new GridBagConstraints();\n gbc_txtPnIntIP.fill = GridBagConstraints.BOTH;\n gbc_txtPnIntIP.gridx = 0;\n gbc_txtPnIntIP.gridy = 0;\n panel.add(txtPnIntIP, gbc_txtPnIntIP);\n JPanel panel_1 = new JPanel();\n contentPane.add(panel_1, BorderLayout.SOUTH);\n JTextPane txtPnPort = new JTextPane();\n txtPnPort.setBackground(backgroundColor);\n txtPnPort.setText(\"Port [1 - 65535]: \");\n txtPnPort.setEditable(false);\n panel_1.add(txtPnPort);\n final JSpinner spnPort = new JSpinner();\n spnPort.setModel(new SpinnerNumberModel(7777, 1, 65535, 1));\n spnPort.setEditor(new JSpinner.NumberEditor(spnPort, \"#####\"));\n panel_1.add(spnPort);\n final JButton btnStop = new JButton(\"Stop Server\");\n final JButton btnStart = new JButton(\"Start Server\");\n btnStart.addActionListener(new ActionListener()\n {\n public void actionPerformed(ActionEvent arg0)\n {\n txtConsoleOut.setText(\"\");\n try\n {\n Server = new BombermenServer(Integer.parseInt(spnPort.getValue().toString()));\n ServerThread = new Thread(new Runnable()\n {\n @Override\n public void run()\n {\n long millis = System.currentTimeMillis();\n while (ServerRunning)\n {\n int dt = (int) (System.currentTimeMillis() - millis);\n millis = System.currentTimeMillis();\n Server.Update(dt);\n try\n {\n Thread.sleep(20);\n }\n catch (InterruptedException e)\n {\n }\n }\n }\n });\n ServerRunning = true;\n ServerThread.start();\n btnStart.setEnabled(false);\n btnStop.setEnabled(true);\n }\n catch (IOException e1)\n {\n }\n }\n });\n panel_1.add(btnStart);\n btnStop.addActionListener(new ActionListener()\n {\n public void actionPerformed(ActionEvent arg0)\n {\n Stop();\n btnStart.setEnabled(true);\n btnStop.setEnabled(false);\n }\n });\n btnStop.setEnabled(false);\n panel_1.add(btnStop);\n JTextPane txtPnServerIP = new JTextPane();\n txtPnServerIP.setBackground(backgroundColor);\n txtPnServerIP.setEditable(false);\n panel_1.add(txtPnServerIP);\n JPanel panel_2 = new JPanel();\n contentPane.add(panel_2, BorderLayout.CENTER);\n panel_2.setLayout(new GridLayout(1, 0, 0, 0));\n txtConsoleOut = new JTextArea();\n txtConsoleOut.setEditable(false);\n panel_2.add(txtConsoleOut);\n JScrollPane scroll = new JScrollPane(txtConsoleOut, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\n panel_2.add(scroll);\n redirectSystemStreams();\n }\n", "output": " public BombermenServerGui() throws Exception\n {\n setTitle(\"Bombermen Server\");\n setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n setBounds(100, 100, 800, 600);\n JMenuBar menuBar = new JMenuBar();\n setJMenuBar(menuBar);\n JMenu mnFile = new JMenu(\"File\");\n menuBar.add(mnFile);\n JMenuItem mntmExit = new JMenuItem(\"Exit\");\n mntmExit.addActionListener(new ActionListener()\n {\n public void actionPerformed(ActionEvent arg0)\n {\n System.exit(0);\n }\n });\n mnFile.add(mntmExit);\n contentPane = new JPanel();\n contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));\n setContentPane(contentPane);\n contentPane.setLayout(new BorderLayout(0, 0));\n JPanel panel = new JPanel();\n contentPane.add(panel, BorderLayout.NORTH);\n GridBagLayout gbl_panel = new GridBagLayout();\n gbl_panel.columnWidths = new int[] { 213 };\n gbl_panel.rowHeights = new int[] { 20, 0, 0 };\n gbl_panel.columnWeights = new double[] { 1.0 };\n gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };\n panel.setLayout(gbl_panel);\n JTextPane txtpnExtIP = new JTextPane();\n txtpnExtIP.setBackground(backgroundColor);\n txtpnExtIP.setText(\"External IP: \" + getIp());\n txtpnExtIP.setEditable(false);\n SimpleAttributeSet center = new SimpleAttributeSet();\n StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);\n txtpnExtIP.getStyledDocument().setParagraphAttributes(0, txtpnExtIP.getStyledDocument().getLength(), center, false);\n GridBagConstraints gbc_txtpnExtIP = new GridBagConstraints();\n gbc_txtpnExtIP.fill = GridBagConstraints.BOTH;\n gbc_txtpnExtIP.insets = new Insets(0, 0, 0, 5);\n gbc_txtpnExtIP.gridx = 0;\n gbc_txtpnExtIP.gridy = 1;\n panel.add(txtpnExtIP, gbc_txtpnExtIP);\n JTextPane txtPnIntIP = new JTextPane();\n txtPnIntIP.setBackground(backgroundColor);\n txtPnIntIP.setText(\"Lan IP: \" + InetAddress.getLocalHost().getHostAddress());\n txtPnIntIP.setEditable(false);\n txtPnIntIP.getStyledDocument().setParagraphAttributes(0, txtPnIntIP.getStyledDocument().getLength(), center, false);\n GridBagConstraints gbc_txtPnIntIP = new GridBagConstraints();\n gbc_txtPnIntIP.fill = GridBagConstraints.BOTH;\n gbc_txtPnIntIP.gridx = 0;\n gbc_txtPnIntIP.gridy = 0;\n panel.add(txtPnIntIP, gbc_txtPnIntIP);\n JPanel panel_1 = new JPanel();\n contentPane.add(panel_1, BorderLayout.SOUTH);\n JTextPane txtPnPort = new JTextPane();\n txtPnPort.setBackground(backgroundColor);\n txtPnPort.setText(\"Port [1 - 65535]: \");\n txtPnPort.setEditable(false);\n panel_1.add(txtPnPort);\n final JSpinner spnPort = new JSpinner();\n spnPort.setModel(new SpinnerNumberModel(7777, 1, 65535, 1));\n spnPort.setEditor(new JSpinner.NumberEditor(spnPort, \"#####\"));\n panel_1.add(spnPort);\n final JButton btnStop = new JButton(\"Stop Server\");\n final JButton btnStart = new JButton(\"Start Server\");\n btnStart.addActionListener(new ActionListener()\n {\n public void actionPerformed(ActionEvent arg0)\n {\n txtConsoleOut.setText(\"\");\n try\n {\n Server = new BombermenServer(Integer.parseInt(spnPort.getValue().toString()));\n ServerThread = new Thread(new Runnable()\n {\n @Override\n public void run()\n {\n long millis = System.currentTimeMillis();\n while (ServerRunning)\n {\n int dt = (int) (System.currentTimeMillis() - millis);\n millis = System.currentTimeMillis();\n Server.Update(dt);\n try\n {\n Thread.sleep(20);\n }\n catch (InterruptedException e)\n {\n }\n }\n }\n });\n ServerRunning = true;\n ServerThread.start();\n btnStart.setEnabled(false);\n btnStop.setEnabled(true);\n }\n catch (IOException e1)\n {\n }\n }\n });\n panel_1.add(btnStart);\n btnStop.addActionListener(new ActionListener()\n {\n public void actionPerformed(ActionEvent arg0)\n {\n Stop();\n btnStart.setEnabled(true);\n btnStop.setEnabled(false);\n }\n });\n btnStop.setEnabled(false);\n panel_1.add(btnStop);\n JTextPane txtPnServerIP = new JTextPane();\n txtPnServerIP.setBackground(backgroundColor);\n txtPnServerIP.setEditable(false);\n panel_1.add(txtPnServerIP);\n JPanel panel_2 = new JPanel();\n contentPane.add(panel_2, BorderLayout.CENTER);\n panel_2.setLayout(new GridLayout(1, 0, 0, 0));\n txtConsoleOut = new JTextArea();\n txtConsoleOut.setEditable(false);\n panel_2.add(txtConsoleOut);\n JScrollPane scroll = new JScrollPane(txtConsoleOut, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\n panel_2.add(scroll);\n redirectSystemStreams();\n }\n"} {"input": " protected ModelAndView onSubmit(HttpServletRequest request,\n HttpServletResponse response, Object command, BindException errors)\n throws Exception {\n\t\tUser user = ControllerUtil.getSignedInUser();\n \tAddProjectParameters params = (AddProjectParameters) command;\n \tModelAndView modelAndView = null;\n \tProjectcode projectcode = new Projectcode(params.getProjectcode());\n \ttry {\n \t\tstudentService.addStudentToRun(user, projectcode);\n \t\tmodelAndView = new ModelAndView(getSuccessView());\n \t} catch (ObjectNotFoundException e) {\n \t\terrors.rejectValue(\"projectcode\", \"error.illegal-projectcode\");\n \t\treturn showForm(request, response, errors);\n \t} catch (PeriodNotFoundException e) {\n \t\terrors.rejectValue(\"projectcode\", \"error.illegal-projectcode\");\n \t\treturn showForm(request, response, errors);\n \t} catch (StudentUserAlreadyAssociatedWithRunException se) {\n \t\terrors.rejectValue(\"projectcode\", \"error.student-already-associated-with-run\");\n \t\treturn showForm(request, response, errors);\n \t}\n\t\treturn modelAndView;\n }\n", "output": " protected synchronized ModelAndView onSubmit(HttpServletRequest request,\n HttpServletResponse response, Object command, BindException errors)\n throws Exception {\n\t\tUser user = ControllerUtil.getSignedInUser();\n \tAddProjectParameters params = (AddProjectParameters) command;\n \tModelAndView modelAndView = null;\n \tProjectcode projectcode = new Projectcode(params.getProjectcode());\n \ttry {\n \t\tstudentService.addStudentToRun(user, projectcode);\n \t\tmodelAndView = new ModelAndView(getSuccessView());\n \t} catch (ObjectNotFoundException e) {\n \t\terrors.rejectValue(\"projectcode\", \"error.illegal-projectcode\");\n \t\treturn showForm(request, response, errors);\n \t} catch (PeriodNotFoundException e) {\n \t\terrors.rejectValue(\"projectcode\", \"error.illegal-projectcode\");\n \t\treturn showForm(request, response, errors);\n \t} catch (StudentUserAlreadyAssociatedWithRunException se) {\n \t\terrors.rejectValue(\"projectcode\", \"error.student-already-associated-with-run\");\n \t\treturn showForm(request, response, errors);\n \t}\n\t\treturn modelAndView;\n }\n"} {"input": "\tpublic boolean draw(SpriteBatch sprite){\n\t\tif (player == null || !super.draw(sprite))\n\t\t\treturn false;\n\t\tfor (Object object : objects) {\n\t\t\tposObject.set(object.position);\n\t\t\tposObject.sub(player.position);\n\t\t\tif (posObject.len() > radius)\n\t\t\t\tcontinue;\n\t\t\tposObject.mul(scale.x * region.getRegionWidth() * 0.5f / radius, scale.y * region.getRegionHeight() * 0.5f / radius);\n\t\t\tposObject.add(position);\n\t\t\tscaleObject.set(object.scale.x, object.scale.y);\n\t\t\tscaleObject.mul(scale.x * mulScale * region.getRegionWidth() / radius, scale.y * mulScale * region.getRegionHeight() / radius);\n\t\t\tcolorObject.set(object.color);\n\t\t\tcolorObject.mul(color);\n\t\t\tcolorObject.a = 0.85f;\n\t\t\tobject.draw(sprite, posObject, object.angle, scaleObject, colorObject);\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean draw(SpriteBatch sprite){\n\t\tif (player == null || !super.draw(sprite))\n\t\t\treturn false;\n\t\tfor (Object object : objects) {\n\t\t\tposObject.set(object.position);\n\t\t\tposObject.sub(player.position);\n\t\t\tif (posObject.len() > radius)\n\t\t\t\tcontinue;\n\t\t\tposObject.mul(scale.x * region.getRegionWidth() * 0.5f / radius, scale.y * region.getRegionHeight() * 0.5f / radius);\n\t\t\tposObject.add(position);\n\t\t\tscaleObject.set(object.scale.x, object.scale.y);\n\t\t\tscaleObject.mul(scale.x * mulScale * region.getRegionWidth() * 0.5f / radius, scale.y * mulScale * region.getRegionHeight() * 0.5f / radius);\n\t\t\tcolorObject.set(object.color);\n\t\t\tcolorObject.mul(color);\n\t\t\tcolorObject.a = 0.85f;\n\t\t\tobject.draw(sprite, posObject, object.angle, scaleObject, colorObject);\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": "\tpublic void init() {\n\t\texternallyManaged = getCourse().isExternallyManaged();\n\t\tList sectionSet = getAllSiteSections();\n\t\tsections = new ArrayList();\n\t\tfor(Iterator sectionIter = sectionSet.iterator(); sectionIter.hasNext();) {\n\t\t\tCourseSection section = (CourseSection)sectionIter.next();\n\t\t\tString catName = getCategoryName(section.getCategory());\n\t\t\tList tas = getSectionManager().getSectionTeachingAssistants(section.getUuid());\n\t\t\tList taNames = new ArrayList();\n\t\t\tfor(Iterator taIter = tas.iterator(); taIter.hasNext();) {\n\t\t\t\tParticipationRecord ta = (ParticipationRecord)taIter.next();\n\t\t\t\ttaNames.add(StringUtils.abbreviate(ta.getUser().getSortName(), getPrefs().getMaxNameLength()));\n\t\t\t}\n\t\t\tCollections.sort(taNames);\n\t\t\tint totalEnrollments = getSectionManager().getTotalEnrollments(section.getUuid());\n\t\t\tInstructorSectionDecorator decoratedSection = new InstructorSectionDecorator(\n\t\t\t\t\tsection, catName, taNames, totalEnrollments);\n\t\t\tsections.add(decoratedSection);\n\t\t}\n\t\tcategoryIds = getSectionCategories();\n\t\tcategoryNames = new ArrayList();\n\t\tfor(Iterator iter = categoryIds.iterator(); iter.hasNext();) {\n\t\t\tString catId = (String)iter.next();\n\t\t\tcategoryNames.add(getCategoryName(catId));\n\t\t}\n\t\tCollections.sort(sections, getComparator());\n\t\tStringBuffer sb = new StringBuffer();\n\t\tint index = 0;\n\t\tfor(Iterator iter = sections.iterator(); iter.hasNext();) {\n\t\t\tInstructorSectionDecorator decoratedSection = (InstructorSectionDecorator)iter.next();\n\t\t\tif(iter.hasNext()) {\n\t\t\t\tInstructorSectionDecorator nextSection = (InstructorSectionDecorator)sections.get(++index);\n\t\t\t\tif(nextSection.getCategory().equals(decoratedSection.getCategory())) {\n\t\t\t\t\tsb.append(\"section\");\n\t\t\t\t} else {\n\t\t\t\t\tsb.append(\"sectionPadRow\");\n\t\t\t\t}\n\t\t\t\tsb.append(\",\");\n\t\t\t} else {\n\t\t\t\tsb.append(\"section\");\n\t\t\t}\n\t\t}\n\t\trowClasses = sb.toString();\n\t}\n", "output": "\tpublic void init() {\n\t\texternallyManaged = getCourse().isExternallyManaged();\n\t\tList sectionSet = getAllSiteSections();\n\t\tsections = new ArrayList();\n\t\tfor(Iterator sectionIter = sectionSet.iterator(); sectionIter.hasNext();) {\n\t\t\tCourseSection section = (CourseSection)sectionIter.next();\n\t\t\tString catName = getCategoryName(section.getCategory());\n\t\t\tList tas = getSectionManager().getSectionTeachingAssistants(section.getUuid());\n\t\t\tList taNames = new ArrayList();\n\t\t\tfor(Iterator taIter = tas.iterator(); taIter.hasNext();) {\n\t\t\t\tParticipationRecord ta = (ParticipationRecord)taIter.next();\n\t\t\t\ttaNames.add(StringUtils.abbreviate(ta.getUser().getSortName(), getPrefs().getMaxNameLength()));\n\t\t\t}\n\t\t\tCollections.sort(taNames);\n\t\t\tint totalEnrollments = getSectionManager().getTotalEnrollments(section.getUuid());\n\t\t\tInstructorSectionDecorator decoratedSection = new InstructorSectionDecorator(\n\t\t\t\t\tsection, catName, taNames, totalEnrollments);\n\t\t\tsections.add(decoratedSection);\n\t\t}\n\t\tcategoryIds = getSectionCategories();\n\t\tcategoryNames = new ArrayList();\n\t\tfor(Iterator iter = categoryIds.iterator(); iter.hasNext();) {\n\t\t\tString catId = (String)iter.next();\n\t\t\tcategoryNames.add(getCategoryName(catId));\n\t\t}\n\t\tCollections.sort(sections, getComparator());\n\t\tStringBuffer sb = new StringBuffer();\n\t\tint index = 0;\n\t\tfor(Iterator iter = sections.iterator(); iter.hasNext();) {\n\t\t\tInstructorSectionDecorator decoratedSection = (InstructorSectionDecorator)iter.next();\n\t\t\tif(iter.hasNext()) {\n\t\t\t\tInstructorSectionDecorator nextSection = (InstructorSectionDecorator)sections.get(++index);\n\t\t\t\tif(nextSection.getCategory().equals(decoratedSection.getCategory())) {\n\t\t\t\t\tsb.append(\"section\");\n\t\t\t\t} else {\n\t\t\t\t\tsb.append(\"sectionPadRow\");\n\t\t\t\t}\n\t\t\t\tsb.append(\",\");\n\t\t\t} else {\n\t\t\t\tsb.append(\"sectionRow\");\n\t\t\t}\n\t\t}\n\t\trowClasses = sb.toString();\n\t}\n"} {"input": " public List getSupportedFormats(QualityPresets sendPreset,\n QualityPresets receivePreset)\n {\n EncodingConfiguration encodingConfiguration\n = NeomediaActivator\n .getMediaServiceImpl().getEncodingConfiguration();\n MediaFormat[] supportedEncodings\n = encodingConfiguration.getSupportedEncodings(getMediaType());\n List supportedFormats = new ArrayList();\n if (supportedEncodings != null)\n for (MediaFormat supportedEncoding : supportedEncodings)\n supportedFormats.add(supportedEncoding);\n {\n MediaFormat customFormat = null;\n MediaFormat toRemove = null;\n for(MediaFormat f : supportedFormats)\n {\n if(\"h264\".equalsIgnoreCase(f.getEncoding()))\n {\n Map h264AdvancedAttributes =\n f.getAdvancedAttributes();\n if(h264AdvancedAttributes == null)\n h264AdvancedAttributes = new HashMap();\n Dimension sendSize = null;\n Dimension receiveSize;\n if(!captureDeviceInfo.getLocator().getProtocol().equals(\n ImageStreamingAuto.LOCATOR_PROTOCOL))\n {\n if(sendPreset != null)\n sendSize = sendPreset.getResolution();\n else\n sendSize = NeomediaActivator.getMediaServiceImpl()\n .getDeviceConfiguration().getVideoSize();\n }\n if(receivePreset != null)\n receiveSize = receivePreset.getResolution();\n else\n {\n ScreenDevice screen\n = NeomediaActivator.getMediaServiceImpl()\n .getDefaultScreenDevice();\n receiveSize = (screen == null) ?\n null : screen.getSize();\n }\n h264AdvancedAttributes.put(\"imageattr\",\n MediaUtils.createImageAttr(sendSize,\n receiveSize));\n customFormat = NeomediaActivator.getMediaServiceImpl()\n .getFormatFactory().createMediaFormat(\n f.getEncoding(),\n f.getClockRate(),\n f.getFormatParameters(),\n h264AdvancedAttributes);\n toRemove = f;\n }\n }\n if(toRemove != null && customFormat != null)\n {\n supportedFormats.remove(toRemove);\n supportedFormats.add(customFormat);\n }\n }\n return supportedFormats;\n }\n", "output": " public List getSupportedFormats(QualityPresets sendPreset,\n QualityPresets receivePreset)\n {\n EncodingConfiguration encodingConfiguration\n = NeomediaActivator\n .getMediaServiceImpl().getEncodingConfiguration();\n MediaFormat[] supportedEncodings\n = encodingConfiguration.getSupportedEncodings(getMediaType());\n List supportedFormats = new ArrayList();\n if (supportedEncodings != null)\n for (MediaFormat supportedEncoding : supportedEncodings)\n supportedFormats.add(supportedEncoding);\n {\n MediaFormat customFormat = null;\n MediaFormat toRemove = null;\n for(MediaFormat f : supportedFormats)\n {\n if(\"h264\".equalsIgnoreCase(f.getEncoding()))\n {\n Map h264AdvancedAttributes =\n f.getAdvancedAttributes();\n if(h264AdvancedAttributes == null)\n h264AdvancedAttributes = new HashMap();\n Dimension sendSize = null;\n Dimension receiveSize;\n if(captureDeviceInfo != null\n && captureDeviceInfo.getLocator() != null\n && !(ImageStreamingAuto.LOCATOR_PROTOCOL.equals(\n captureDeviceInfo.getLocator().getProtocol())))\n {\n if(sendPreset != null)\n sendSize = sendPreset.getResolution();\n else\n sendSize = NeomediaActivator.getMediaServiceImpl()\n .getDeviceConfiguration().getVideoSize();\n }\n if(receivePreset != null)\n receiveSize = receivePreset.getResolution();\n else\n {\n ScreenDevice screen\n = NeomediaActivator.getMediaServiceImpl()\n .getDefaultScreenDevice();\n receiveSize = (screen == null) ?\n null : screen.getSize();\n }\n h264AdvancedAttributes.put(\"imageattr\",\n MediaUtils.createImageAttr(sendSize,\n receiveSize));\n customFormat = NeomediaActivator.getMediaServiceImpl()\n .getFormatFactory().createMediaFormat(\n f.getEncoding(),\n f.getClockRate(),\n f.getFormatParameters(),\n h264AdvancedAttributes);\n toRemove = f;\n }\n }\n if(toRemove != null && customFormat != null)\n {\n supportedFormats.remove(toRemove);\n supportedFormats.add(customFormat);\n }\n }\n return supportedFormats;\n }\n"} {"input": " public ChannelPipeline getPipeline() throws Exception {\n String mode = Play.configuration.getProperty(\"play.netty.clientAuth\", \"none\");\n String enabledCiphers = Play.configuration.getProperty(\"play.ssl.enabledCiphers\", \"\");\n ChannelPipeline pipeline = pipeline();\n SSLEngine engine = SslHttpServerContextFactory.getServerContext().createSSLEngine();\n engine.setUseClientMode(false);\n if (enabledCiphers != null && enabledCiphers.length() > 0) {\n engine.setEnabledCipherSuites(enabledCiphers.replaceAll(\" \", \"\").split(\",\"));\n }\n if (\"want\".equalsIgnoreCase(mode)) {\n engine.setWantClientAuth(true);\n } else if (\"need\".equalsIgnoreCase(mode)) {\n engine.setNeedClientAuth(true);\n }\n engine.setEnableSessionCreation(true);\n pipeline.addLast(\"ssl\", new SslHandler(engine));\n String[] handlers = pipelineConfig.split(\",\");\n if(handlers.length <= 0){\n Logger.error(\"You must defined at least the SslPlayHandler in \\\"play.netty.pipeline\\\"\");\n return pipeline;\n }\n String handler = handlers[handlers.length - 1];\n ChannelHandler instance = getInstance(handler);\n SslPlayHandler sslPlayHandler = (SslPlayHandler) instance;\n if (instance == null || !(instance instanceof SslPlayHandler) || sslPlayHandler != null) {\n Logger.error(\"The last handler must be the SslPlayHandler in \\\"play.netty.pipeline\\\"\");\n return pipeline;\n } \n for (int i = 0; i < handlers.length - 1; i++) {\n handler = handlers[i];\n try {\n String name = getName(handler.trim());\n instance = getInstance(handler);\n if (instance != null) {\n pipeline.addLast(name, instance); \n sslPlayHandler.pipelines.put(\"Ssl\" + name, instance);\n }\n } catch(Throwable e) {\n Logger.error(\" error adding \" + handler, e);\n }\n }\n if (sslPlayHandler != null) {\n pipeline.addLast(\"handler\", instance);\n sslPlayHandler.pipelines.put(\"SslHandler\", instance);\n } \n return pipeline;\n }\n", "output": " public ChannelPipeline getPipeline() throws Exception {\n String mode = Play.configuration.getProperty(\"play.netty.clientAuth\", \"none\");\n String enabledCiphers = Play.configuration.getProperty(\"play.ssl.enabledCiphers\", \"\");\n ChannelPipeline pipeline = pipeline();\n SSLEngine engine = SslHttpServerContextFactory.getServerContext().createSSLEngine();\n engine.setUseClientMode(false);\n if (enabledCiphers != null && enabledCiphers.length() > 0) {\n engine.setEnabledCipherSuites(enabledCiphers.replaceAll(\" \", \"\").split(\",\"));\n }\n if (\"want\".equalsIgnoreCase(mode)) {\n engine.setWantClientAuth(true);\n } else if (\"need\".equalsIgnoreCase(mode)) {\n engine.setNeedClientAuth(true);\n }\n engine.setEnableSessionCreation(true);\n pipeline.addLast(\"ssl\", new SslHandler(engine));\n String[] handlers = pipelineConfig.split(\",\");\n if(handlers.length <= 0){\n Logger.error(\"You must defined at least the SslPlayHandler in \\\"play.netty.pipeline\\\"\");\n return pipeline;\n }\n String handler = handlers[handlers.length - 1];\n ChannelHandler instance = getInstance(handler);\n SslPlayHandler sslPlayHandler = (SslPlayHandler) instance;\n if (instance == null || !(instance instanceof SslPlayHandler) || sslPlayHandler == null) {\n Logger.error(\"The last handler must be the SslPlayHandler in \\\"play.netty.pipeline\\\"\");\n return pipeline;\n } \n for (int i = 0; i < handlers.length - 1; i++) {\n handler = handlers[i];\n try {\n String name = getName(handler.trim());\n instance = getInstance(handler);\n if (instance != null) {\n pipeline.addLast(name, instance); \n sslPlayHandler.pipelines.put(\"Ssl\" + name, instance);\n }\n } catch(Throwable e) {\n Logger.error(\" error adding \" + handler, e);\n }\n }\n if (sslPlayHandler != null) {\n pipeline.addLast(\"handler\", sslPlayHandler);\n sslPlayHandler.pipelines.put(\"SslHandler\", sslPlayHandler);\n } \n return pipeline;\n }\n"} {"input": " private void generate() throws MojoExecutionException {\n try {\n CodeGenerator generator = new CodeGenerator(_sourceDir, _destDir);\n generator.generate();\n } catch (IOException cause) {\n throw new MojoExecutionException(\"Failed to perform transformation\");\n }\n }\n", "output": " private void generate() throws MojoExecutionException {\n try {\n CodeGenerator generator = new CodeGenerator(_sourceDir, _destDir);\n generator.generate();\n } catch (IOException cause) {\n throw new MojoExecutionException(\"Failed to perform transformation\", cause);\n }\n }\n"} {"input": "\tprivate void showRoute(PaintContext pc) {\n\t\tfinal int PASSINGDISTANCE=25;\n\t\tStringBuffer soundToPlay = new StringBuffer();\n\t\tString routeInstruction = null;\n\t\tint routeInstructionColor=0x00E6E6E6;\n\t\tint diffArrowDist=0;\n\t\tbyte soundRepeatDelay=3;\n\t\tbyte soundRepeatTimes=2;\n\t\tfloat nearestLat=0.0f;\n\t\tfloat nearestLon=0.0f;\n\t\tint PREPAREDISTANCE=100;\n\t\tif (speed>100) {\n\t\t\tPREPAREDISTANCE=500;\t\t\t\t\t\t\t\n\t\t} else if (speed>80) {\n\t\t\tPREPAREDISTANCE=300;\t\t\t\t\t\t\t\n\t\t} else if (speed>55) {\n\t\t\tPREPAREDISTANCE=200;\t\t\t\t\t\t\t\n\t\t} else if (speed>45) {\n\t\t\tPREPAREDISTANCE=150;\t\t\t\t\t\t\t\n\t\t} else if (speed>35) {\n\t\t\tPREPAREDISTANCE=125;\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t}\n\t\tConnectionWithNode c;\n\t\tfor (int x=0; x 0){\n\t\t\t\trouteRecalculationRequired = false;\n\t\t\t\tRouteNode lastTo;\n\t\t\t\tint iNearest=0;\n\t\t\t\tif (config.getCfgBitState(Configuration.CFGBIT_ROUTING_HELP)) {\n\t\t\t\t\tc = (ConnectionWithNode) route.elementAt(0);\n\t\t\t\t\tlastTo=c.to;\n\t\t\t\t\tfloat minimumDistance=99999;\n\t\t\t\t\tfloat distance=99999;\n\t\t\t\t\tfor (int i=1; i= PASSINGDISTANCE) {\n\t\t\t\t\t\t\tiNearest=iPassedRouteArrow+1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc = (ConnectionWithNode) route.elementAt(0);\n\t\t\t\tbyte lastEndBearing=c.endBearing;\t\t\t\n\t\t\t\tlastTo=c.to;\n\t\t\t\tbyte a=0;\n\t\t\t\tbyte aNearest=0;\n\t\t\t\tfor (int i=1; i pc.getP().getMaxLat()) {\n\t\t\t\t\t\t\tlastEndBearing=c.endBearing;\n\t\t\t\t\t\t\tlastTo=c.to;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (lastTo.lon > pc.getP().getMaxLon()) {\n\t\t\t\t\t\t\tlastEndBearing=c.endBearing;\n\t\t\t\t\t\t\tlastTo=c.to;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tImage pict = pc.images.IMG_MARK; a=0;\n\t\t\t\t\tif (i==1) {\n\t\t\t\t\t\tlastEndBearing = (byte) (course%360 / 2);\n\t\t\t\t\t}\n\t\t\t\t\tint turn=(c.startBearing-lastEndBearing) * 2;\n\t\t\t\t\tif (turn > 180) turn -= 360;\n\t\t\t\t\tif (turn < -180) turn += 360;\n\t\t\t\t\tif (turn > 110) {\n\t\t\t\t\t\tpict=pc.images.IMG_HARDRIGHT; a=1;\n\t\t\t\t\t} else if (turn > 70){\n\t\t\t\t\t\tpict=pc.images.IMG_RIGHT; a=2;\n\t\t\t\t\t} else if (turn > 20){\n\t\t\t\t\t\tpict=pc.images.IMG_HALFRIGHT; a=3;\n\t\t\t\t\t} else if (turn >= -20){\n\t\t\t\t\t\tpict=pc.images.IMG_STRAIGHTON; a=4;\n\t\t\t\t\t} else if (turn >= -70){\n\t\t\t\t\t\tpict=pc.images.IMG_HALFLEFT; a=5;\n\t\t\t\t\t} else if (turn >= -110){\n\t\t\t\t\t\tpict=pc.images.IMG_LEFT; a=6;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpict=pc.images.IMG_HARDLEFT; a=7;\n\t\t\t\t\t} \n\t\t\t\t\tif (atTarget) {\n\t\t\t\t\t\ta=8;\n\t\t\t\t\t}\n\t\t\t\t\tpc.getP().forward(lastTo.lat, lastTo.lon, pc.lineP2);\n\t\t\t\t if (i==iNearest) {\n\t\t\t\t \tnearestLat=lastTo.lat;\n\t\t\t\t \tnearestLon=lastTo.lon;\n\t\t\t\t\t\taNearest=a;\n\t\t\t\t\t\tdouble distance=ProjMath.getDistance(center.radlat, center.radlon, lastTo.lat, lastTo.lon);\n\t\t\t\t\t\tint intDistance=new Double(distance).intValue();\n\t\t\t\t\t\trouteInstruction=directions[a] + ((intDistance 0) {\n\t\t\t\t \t\trouteInstructionColor=0x00FFCD9B;\n\t\t\t\t\t\t} else {\n\t\t\t\t \t\trouteInstructionColor=0x00B7FBBA;\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsumWrongDirection += diffArrowDist;\n\t\t\t\t\t\toldAwayFromNextArrow = intDistance;\n\t\t\t\t\t\tif (intDistance>=PASSINGDISTANCE) {\n\t\t\t\t\t\t\tif (intDistance <= PREPAREDISTANCE) {\n\t\t\t\t\t\t\t\tsoundToPlay.append( (a==4 ? \"CONTINUE\" : \"PREPARE\") + \";\" + soundDirections[a]);\n\t\t\t\t\t\t\t\tsoundRepeatDelay=5;\n\t\t\t\t\t\t\t\tprepareInstructionSaid = true;\n\t\t\t\t\t\t\t} else if (intDistance < 900 && !prepareInstructionSaid) {\n\t\t\t\t\t\t\t\tsoundRepeatDelay=60;\n\t\t\t\t\t\t\t\tsoundToPlay.append(\"IN;\" + Integer.toString(intDistance / 100)+ \"00;METERS;\" + soundDirections[a]);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (a!=arrow) {\n\t\t\t\t\t\t\tarrow=a;\n\t\t\t\t\t\t\tscaledPict=doubleImage(pict);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpict=scaledPict;\n\t\t\t\t }\n\t\t\t\t\tif (i == iNearest + 1) {\n\t\t\t\t\t\tdouble distance=ProjMath.getDistance(nearestLat, nearestLon, lastTo.lat, lastTo.lon);\n\t\t\t\t\t\tif (distance <= PREPAREDISTANCE &&\n\t\t\t\t\t\t\t!(a==4 && aNearest == 4) &&\n\t\t\t\t\t\t\tsoundToPlay.length()!=0\n\t\t\t\t\t\t ) {\n\t\t\t\t\t\t\tsoundToPlay.append(\";THEN;\");\n\t\t\t\t\t\t\tif (distance > PASSINGDISTANCE) {\n\t\t\t\t\t\t\t\tsoundToPlay.append(\"SOON;\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsoundToPlay.append(soundDirections[a]);\n\t\t\t\t\t\t\tif (a==aNearest) {\n\t\t\t\t\t\t\t\tsoundToPlay.append(\";AGAIN\");\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( sumWrongDirection >= PREPAREDISTANCE * 2 / 3\n\t\t\t\t\t\t\t|| sumWrongDirection >= 300) {\n\t\t\t\t\t\t\trouteRecalculationRequired = true;\n\t\t\t \t} else if ( sumWrongDirection >= PREPAREDISTANCE / 3\n\t\t\t\t\t\t|| sumWrongDirection >= 150) {\n\t\t\t \t\tif (diffArrowDist > 0) {\n\t\t\t\t \t\tsoundToPlay.setLength(0);\n\t\t\t\t \t\tsoundToPlay.append (\"CHECK_DIRECTION\");\n\t\t\t\t \t\tsoundRepeatDelay=5;\n\t\t\t\t \t\trouteInstructionColor=0x00E6A03C;\n\t\t\t \t\t} else if (diffArrowDist == 0) {\n\t\t\t \t\t\trouteInstructionColor = oldRouteInstructionColor;\n\t\t\t \t\t}\n\t\t\t \t}\n\t\t\t\t\tpc.g.drawImage(pict,pc.lineP2.x,pc.lineP2.y,CENTERPOS);\n\t\t\t\t\tlastEndBearing=c.endBearing;\n\t\t\t\t\tlastTo=c.to;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (movedAwayFromTarget\n\t\t\t\t&& gpsRecenter\n\t\t\t\t&& (route != null && route.size()==2)\n\t\t\t\t&& ProjMath.getDistance(target.lat, target.lon, center.radlat, center.radlon) > PREPAREDISTANCE\n\t\t\t) {\n\t\t\t\trouteRecalculationRequired=true;\n\t\t\t}\n\t\t\tif ( routeRecalculationRequired && !atTarget ) {\n\t\t\t\tlong recalculationTime=System.currentTimeMillis();\n\t\t\t\tif ( source != null\n\t\t\t\t\t && gpsRecenter\n\t\t\t\t\t && config.getCfgBitState(Configuration.CFGBIT_ROUTE_AUTO_RECALC)\n\t\t\t\t\t && Math.abs(recalculationTime-oldRecalculationTime) >= 7000\n\t\t\t\t) {\n\t\t\t\t\tsoundToPlay.setLength(0);\n\t\t\t\t\tif (config.getCfgBitState(Configuration.CFGBIT_SND_ROUTINGINSTRUCTIONS)) {\n\t\t\t\t\t\tparent.mNoiseMaker.playSound(\"ROUTE_RECALCULATION\", (byte) 5, (byte) 1 );\n\t\t\t\t\t}\n\t\t\t\t\tcommandAction(ROUTE_TO_CMD,(Displayable) null);\n\t\t\t\t\tsource=null;\n\t\t\t\t\toldRecalculationTime = recalculationTime;\n\t\t\t\t}\n\t\t\t\tif (diffArrowDist > 0) {\n\t\t\t\t\trouteInstructionColor=0x00FF5402;\n\t\t\t\t} else if (diffArrowDist == 0) {\n\t\t\t\t\trouteInstructionColor = oldRouteInstructionColor;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ((routeInstruction != null) && (imageCollector != null)) {\n\t\t\tFont originalFont = pc.g.getFont();\n\t\t\tif (routeFont==null) {\n\t\t\t\trouteFont=Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);\n\t\t\t\trouteFontHeight=routeFont.getHeight();\n\t\t\t}\n\t\t\tpc.g.setFont(routeFont);\n\t\t\tpc.g.setColor(routeInstructionColor);\n\t\t\toldRouteInstructionColor=routeInstructionColor;\n\t\t\tpc.g.fillRect(0,pc.ySize-imageCollector.statusFontHeight-routeFontHeight, pc.xSize, routeFontHeight);\n\t\t\tpc.g.setColor(0,0,0);\n\t\t\tpc.g.drawString(routeInstruction,\n\t\t\t\t\tpc.xSize/2,\n\t\t\t\t\tpc.ySize-imageCollector.statusFontHeight,\n\t\t\t\t\tGraphics.HCENTER | Graphics.BOTTOM\n\t\t\t);\n\t\t\tpc.g.setFont(originalFont);\n\t\t}\n\t\tif (soundToPlay.length()!=0 && config.getCfgBitState(Configuration.CFGBIT_SND_ROUTINGINSTRUCTIONS)) {\n\t\t\tparent.mNoiseMaker.playSound(soundToPlay.toString(), (byte) soundRepeatDelay, (byte) soundRepeatTimes);\n\t\t}\n\t}\n", "output": "\tprivate void showRoute(PaintContext pc) {\n\t\tfinal int PASSINGDISTANCE=25;\n\t\tStringBuffer soundToPlay = new StringBuffer();\n\t\tString routeInstruction = null;\n\t\tint routeInstructionColor=0x00E6E6E6;\n\t\tint diffArrowDist=0;\n\t\tbyte soundRepeatDelay=3;\n\t\tbyte soundRepeatTimes=2;\n\t\tfloat nearestLat=0.0f;\n\t\tfloat nearestLon=0.0f;\n\t\tint PREPAREDISTANCE=100;\n\t\tif (speed>100) {\n\t\t\tPREPAREDISTANCE=500;\t\t\t\t\t\t\t\n\t\t} else if (speed>80) {\n\t\t\tPREPAREDISTANCE=300;\t\t\t\t\t\t\t\n\t\t} else if (speed>55) {\n\t\t\tPREPAREDISTANCE=200;\t\t\t\t\t\t\t\n\t\t} else if (speed>45) {\n\t\t\tPREPAREDISTANCE=150;\t\t\t\t\t\t\t\n\t\t} else if (speed>35) {\n\t\t\tPREPAREDISTANCE=125;\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t}\n\t\tConnectionWithNode c;\n\t\tfor (int x=0; x 0){\n\t\t\t\trouteRecalculationRequired = false;\n\t\t\t\tRouteNode lastTo;\n\t\t\t\tint iNearest=0;\n\t\t\t\tif (config.getCfgBitState(Configuration.CFGBIT_ROUTING_HELP)) {\n\t\t\t\t\tc = (ConnectionWithNode) route.elementAt(0);\n\t\t\t\t\tlastTo=c.to;\n\t\t\t\t\tfloat minimumDistance=99999;\n\t\t\t\t\tfloat distance=99999;\n\t\t\t\t\tfor (int i=1; i= PASSINGDISTANCE) {\n\t\t\t\t\t\t\tiNearest=iPassedRouteArrow+1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tc = (ConnectionWithNode) route.elementAt(0);\n\t\t\t\tint lastEndBearing=c.endBearing;\t\t\t\n\t\t\t\tlastTo=c.to;\n\t\t\t\tbyte a=0;\n\t\t\t\tbyte aNearest=0;\n\t\t\t\tfor (int i=1; i pc.getP().getMaxLat()) {\n\t\t\t\t\t\t\tlastEndBearing=c.endBearing;\n\t\t\t\t\t\t\tlastTo=c.to;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (lastTo.lon > pc.getP().getMaxLon()) {\n\t\t\t\t\t\t\tlastEndBearing=c.endBearing;\n\t\t\t\t\t\t\tlastTo=c.to;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tImage pict = pc.images.IMG_MARK; a=0;\n\t\t\t\t\tif (i==1) {\n\t\t\t\t\t\tlastEndBearing = (course%360) / 2;\n\t\t\t\t\t}\n\t\t\t\t\tint turn=(c.startBearing-lastEndBearing) * 2;\n\t\t\t\t\tif (turn > 180) turn -= 360;\n\t\t\t\t\tif (turn < -180) turn += 360;\n\t\t\t\t\tif (turn > 110) {\n\t\t\t\t\t\tpict=pc.images.IMG_HARDRIGHT; a=1;\n\t\t\t\t\t} else if (turn > 70){\n\t\t\t\t\t\tpict=pc.images.IMG_RIGHT; a=2;\n\t\t\t\t\t} else if (turn > 20){\n\t\t\t\t\t\tpict=pc.images.IMG_HALFRIGHT; a=3;\n\t\t\t\t\t} else if (turn >= -20){\n\t\t\t\t\t\tpict=pc.images.IMG_STRAIGHTON; a=4;\n\t\t\t\t\t} else if (turn >= -70){\n\t\t\t\t\t\tpict=pc.images.IMG_HALFLEFT; a=5;\n\t\t\t\t\t} else if (turn >= -110){\n\t\t\t\t\t\tpict=pc.images.IMG_LEFT; a=6;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpict=pc.images.IMG_HARDLEFT; a=7;\n\t\t\t\t\t} \n\t\t\t\t\tif (atTarget) {\n\t\t\t\t\t\ta=8;\n\t\t\t\t\t}\n\t\t\t\t\tpc.getP().forward(lastTo.lat, lastTo.lon, pc.lineP2);\n\t\t\t\t if (i==iNearest) {\n\t\t\t\t \tnearestLat=lastTo.lat;\n\t\t\t\t \tnearestLon=lastTo.lon;\n\t\t\t\t\t\taNearest=a;\n\t\t\t\t\t\tdouble distance=ProjMath.getDistance(center.radlat, center.radlon, lastTo.lat, lastTo.lon);\n\t\t\t\t\t\tint intDistance=new Double(distance).intValue();\n\t\t\t\t\t\trouteInstruction=directions[a] + ((intDistance 0) {\n\t\t\t\t \t\trouteInstructionColor=0x00FFCD9B;\n\t\t\t\t\t\t} else {\n\t\t\t\t \t\trouteInstructionColor=0x00B7FBBA;\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsumWrongDirection += diffArrowDist;\n\t\t\t\t\t\toldAwayFromNextArrow = intDistance;\n\t\t\t\t\t\tif (intDistance>=PASSINGDISTANCE) {\n\t\t\t\t\t\t\tif (intDistance <= PREPAREDISTANCE) {\n\t\t\t\t\t\t\t\tsoundToPlay.append( (a==4 ? \"CONTINUE\" : \"PREPARE\") + \";\" + soundDirections[a]);\n\t\t\t\t\t\t\t\tsoundRepeatDelay=5;\n\t\t\t\t\t\t\t\tprepareInstructionSaid = true;\n\t\t\t\t\t\t\t} else if (intDistance < 900 && !prepareInstructionSaid) {\n\t\t\t\t\t\t\t\tsoundRepeatDelay=60;\n\t\t\t\t\t\t\t\tsoundToPlay.append(\"IN;\" + Integer.toString(intDistance / 100)+ \"00;METERS;\" + soundDirections[a]);\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (a!=arrow) {\n\t\t\t\t\t\t\tarrow=a;\n\t\t\t\t\t\t\tscaledPict=doubleImage(pict);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpict=scaledPict;\n\t\t\t\t }\n\t\t\t\t\tif (i == iNearest + 1) {\n\t\t\t\t\t\tdouble distance=ProjMath.getDistance(nearestLat, nearestLon, lastTo.lat, lastTo.lon);\n\t\t\t\t\t\tif (distance <= PREPAREDISTANCE &&\n\t\t\t\t\t\t\t!(a==4 && aNearest == 4) &&\n\t\t\t\t\t\t\tsoundToPlay.length()!=0\n\t\t\t\t\t\t ) {\n\t\t\t\t\t\t\tsoundToPlay.append(\";THEN;\");\n\t\t\t\t\t\t\tif (distance > PASSINGDISTANCE) {\n\t\t\t\t\t\t\t\tsoundToPlay.append(\"SOON;\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsoundToPlay.append(soundDirections[a]);\n\t\t\t\t\t\t\tif (a==aNearest) {\n\t\t\t\t\t\t\t\tsoundToPlay.append(\";AGAIN\");\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( sumWrongDirection >= PREPAREDISTANCE * 2 / 3\n\t\t\t\t\t\t\t|| sumWrongDirection >= 300) {\n\t\t\t\t\t\t\trouteRecalculationRequired = true;\n\t\t\t \t} else if ( sumWrongDirection >= PREPAREDISTANCE / 3\n\t\t\t\t\t\t|| sumWrongDirection >= 150) {\n\t\t\t \t\tif (diffArrowDist > 0) {\n\t\t\t\t \t\tsoundToPlay.setLength(0);\n\t\t\t\t \t\tsoundToPlay.append (\"CHECK_DIRECTION\");\n\t\t\t\t \t\tsoundRepeatDelay=5;\n\t\t\t\t \t\trouteInstructionColor=0x00E6A03C;\n\t\t\t \t\t} else if (diffArrowDist == 0) {\n\t\t\t \t\t\trouteInstructionColor = oldRouteInstructionColor;\n\t\t\t \t\t}\n\t\t\t \t}\n\t\t\t\t\tpc.g.drawImage(pict,pc.lineP2.x,pc.lineP2.y,CENTERPOS);\n\t\t\t\t\tlastEndBearing=c.endBearing;\n\t\t\t\t\tlastTo=c.to;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (movedAwayFromTarget\n\t\t\t\t&& gpsRecenter\n\t\t\t\t&& (route != null && route.size()==2)\n\t\t\t\t&& ProjMath.getDistance(target.lat, target.lon, center.radlat, center.radlon) > PREPAREDISTANCE\n\t\t\t) {\n\t\t\t\trouteRecalculationRequired=true;\n\t\t\t}\n\t\t\tif ( routeRecalculationRequired && !atTarget ) {\n\t\t\t\tlong recalculationTime=System.currentTimeMillis();\n\t\t\t\tif ( source != null\n\t\t\t\t\t && gpsRecenter\n\t\t\t\t\t && config.getCfgBitState(Configuration.CFGBIT_ROUTE_AUTO_RECALC)\n\t\t\t\t\t && Math.abs(recalculationTime-oldRecalculationTime) >= 7000\n\t\t\t\t) {\n\t\t\t\t\tsoundToPlay.setLength(0);\n\t\t\t\t\tif (config.getCfgBitState(Configuration.CFGBIT_SND_ROUTINGINSTRUCTIONS)) {\n\t\t\t\t\t\tparent.mNoiseMaker.playSound(\"ROUTE_RECALCULATION\", (byte) 5, (byte) 1 );\n\t\t\t\t\t}\n\t\t\t\t\tcommandAction(ROUTE_TO_CMD,(Displayable) null);\n\t\t\t\t\tsource=null;\n\t\t\t\t\toldRecalculationTime = recalculationTime;\n\t\t\t\t}\n\t\t\t\tif (diffArrowDist > 0) {\n\t\t\t\t\trouteInstructionColor=0x00FF5402;\n\t\t\t\t} else if (diffArrowDist == 0) {\n\t\t\t\t\trouteInstructionColor = oldRouteInstructionColor;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif ((routeInstruction != null) && (imageCollector != null)) {\n\t\t\tFont originalFont = pc.g.getFont();\n\t\t\tif (routeFont==null) {\n\t\t\t\trouteFont=Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);\n\t\t\t\trouteFontHeight=routeFont.getHeight();\n\t\t\t}\n\t\t\tpc.g.setFont(routeFont);\n\t\t\tpc.g.setColor(routeInstructionColor);\n\t\t\toldRouteInstructionColor=routeInstructionColor;\n\t\t\tpc.g.fillRect(0,pc.ySize-imageCollector.statusFontHeight-routeFontHeight, pc.xSize, routeFontHeight);\n\t\t\tpc.g.setColor(0,0,0);\n\t\t\tpc.g.drawString(routeInstruction,\n\t\t\t\t\tpc.xSize/2,\n\t\t\t\t\tpc.ySize-imageCollector.statusFontHeight,\n\t\t\t\t\tGraphics.HCENTER | Graphics.BOTTOM\n\t\t\t);\n\t\t\tpc.g.setFont(originalFont);\n\t\t}\n\t\tif (soundToPlay.length()!=0 && config.getCfgBitState(Configuration.CFGBIT_SND_ROUTINGINSTRUCTIONS)) {\n\t\t\tparent.mNoiseMaker.playSound(soundToPlay.toString(), (byte) soundRepeatDelay, (byte) soundRepeatTimes);\n\t\t}\n\t}\n"} {"input": " protected RemoteConfigurationAdministrator createPort ( final URL url )\n {\n final Service service = javax.xml.ws.Service.create ( url, serviceName );\n final RemoteConfigurationAdministrator port = service.getPort ( RemoteConfigurationAdministrator.class );\n final Map> httpHeaders = new HashMap> ();\n httpHeaders.put ( \"Accept-Encoding\", Collections.singletonList ( \"gzip\" ) );\n final Map requestContext = ( (BindingProvider)port ).getRequestContext ();\n requestContext.put ( MessageContext.HTTP_REQUEST_HEADERS, httpHeaders );\n final String user = url.getUserInfo ();\n final int findColon = user.indexOf ( ':' );\n if ( findColon > 0 && findColon + 1 < user.length () )\n {\n requestContext.put ( BindingProvider.USERNAME_PROPERTY, user.substring ( 0, findColon ) );\n requestContext.put ( BindingProvider.PASSWORD_PROPERTY, user.substring ( findColon + 1 ) );\n }\n else\n {\n requestContext.put ( BindingProvider.USERNAME_PROPERTY, user );\n }\n return port;\n }\n", "output": " protected RemoteConfigurationAdministrator createPort ( final URL url )\n {\n final Service service = javax.xml.ws.Service.create ( url, serviceName );\n final RemoteConfigurationAdministrator port = service.getPort ( RemoteConfigurationAdministrator.class );\n final Map> httpHeaders = new HashMap> ();\n httpHeaders.put ( \"Accept-Encoding\", Collections.singletonList ( \"gzip\" ) );\n final Map requestContext = ( (BindingProvider)port ).getRequestContext ();\n requestContext.put ( MessageContext.HTTP_REQUEST_HEADERS, httpHeaders );\n final String user = url.getUserInfo ();\n if ( user != null )\n {\n final int findColon = user.indexOf ( ':' );\n if ( ( findColon > 0 ) && ( ( findColon + 1 ) < user.length () ) )\n {\n requestContext.put ( BindingProvider.USERNAME_PROPERTY, user.substring ( 0, findColon ) );\n requestContext.put ( BindingProvider.PASSWORD_PROPERTY, user.substring ( findColon + 1 ) );\n }\n else\n {\n requestContext.put ( BindingProvider.USERNAME_PROPERTY, user );\n }\n }\n return port;\n }\n"} {"input": "\tpublic AllModuleReferences getAllModulesState() {\n\t\tfinal AllModuleReferences result = new AllModuleReferences();\n\t\tif(resourceSet == null || resourceSet.getResources().size() < 1)\n\t\t\treturn result;\n\t\tfinal ValidationStateBasedContainerManager validationContainerManager = getContainerManager();\n\t\tIResourceDescriptions descriptionIndex = getResourceDescriptions();\n\t\tMap exports = Maps.newHashMap();\n\t\tfor(IResourceDescription rdesc : descriptionIndex.getAllResourceDescriptions()) {\n\t\t\tString handle = validationContainerManager.getContainerHandle(rdesc, descriptionIndex);\n\t\t\tif(handle == null)\n\t\t\t\tcontinue;\n\t\t\tFile moduleDir = new File(handle);\n\t\t\tfor(IEObjectDescription desc : rdesc.getExportedObjects()) {\n\t\t\t\tModuleExport me = createExport(desc);\n\t\t\t\texports.put(desc, me);\n\t\t\t\tresult.addExport(moduleDir, me);\n\t\t\t}\n\t\t}\n\t\tfor(Resource r : resourceSet.getResources()) {\n\t\t\tFile importingModuleDir = getContainerHandle(r.getURI(), descriptionIndex, validationContainerManager);\n\t\t\tif(importingModuleDir == null)\n\t\t\t\tcontinue;\n\t\t\tPPImportedNamesAdapter importedAdapter = PPImportedNamesAdapterFactory.eINSTANCE.adapt(r);\n\t\t\tfor(IEObjectDescription desc : importedAdapter.getResolvedDescriptions()) {\n\t\t\t\tFile moduleDir = getContainerHandle(desc.getEObjectURI(), descriptionIndex, validationContainerManager);\n\t\t\t\tif(moduleDir != null)\n\t\t\t\t\tcontinue;\n\t\t\t\tModuleExport me = exports.get(desc);\n\t\t\t\tif(me == null)\n\t\t\t\t\tme = searchMissing(importingModuleDir, moduleDir, exports, desc);\n\t\t\t\tresult.addImport(importingModuleDir, moduleDir, me);\n\t\t\t}\n\t\t\tfor(IEObjectDescription desc : importedAdapter.getAmbiguousDescriptions()) {\n\t\t\t\tFile moduleDir = getContainerHandle(desc.getEObjectURI(), descriptionIndex, validationContainerManager);\n\t\t\t\tif(moduleDir == null)\n\t\t\t\t\tcontinue;\n\t\t\t\tModuleExport me = exports.get(desc);\n\t\t\t\tif(me == null)\n\t\t\t\t\tme = searchMissing(importingModuleDir, moduleDir, exports, desc);\n\t\t\t\tresult.addAmbiguity(importingModuleDir, moduleDir, me);\n\t\t\t}\n\t\t\tresult.addUnresolved(importingModuleDir, r.getURI(), importedAdapter.getUnresolved(), fQualifiedToString);\n\t\t}\n\t\tresult.setRestricted(restricted);\n\t\treturn result;\n\t}\n", "output": "\tpublic AllModuleReferences getAllModulesState() {\n\t\tfinal AllModuleReferences result = new AllModuleReferences();\n\t\tif(resourceSet == null || resourceSet.getResources().size() < 1)\n\t\t\treturn result;\n\t\tfinal ValidationStateBasedContainerManager validationContainerManager = getContainerManager();\n\t\tIResourceDescriptions descriptionIndex = getResourceDescriptions();\n\t\tMap exports = Maps.newHashMap();\n\t\tfor(IResourceDescription rdesc : descriptionIndex.getAllResourceDescriptions()) {\n\t\t\tString handle = validationContainerManager.getContainerHandle(rdesc, descriptionIndex);\n\t\t\tif(handle == null)\n\t\t\t\tcontinue;\n\t\t\tFile moduleDir = new File(handle);\n\t\t\tfor(IEObjectDescription desc : rdesc.getExportedObjects()) {\n\t\t\t\tModuleExport me = createExport(desc);\n\t\t\t\texports.put(desc, me);\n\t\t\t\tresult.addExport(moduleDir, me);\n\t\t\t}\n\t\t}\n\t\tfor(Resource r : resourceSet.getResources()) {\n\t\t\tFile importingModuleDir = getContainerHandle(r.getURI(), descriptionIndex, validationContainerManager);\n\t\t\tif(importingModuleDir == null)\n\t\t\t\tcontinue;\n\t\t\tPPImportedNamesAdapter importedAdapter = PPImportedNamesAdapterFactory.eINSTANCE.adapt(r);\n\t\t\tfor(IEObjectDescription desc : importedAdapter.getResolvedDescriptions()) {\n\t\t\t\tFile moduleDir = getContainerHandle(desc.getEObjectURI(), descriptionIndex, validationContainerManager);\n\t\t\t\tif(moduleDir == null)\n\t\t\t\t\tcontinue;\n\t\t\t\tModuleExport me = exports.get(desc);\n\t\t\t\tif(me == null)\n\t\t\t\t\tme = searchMissing(importingModuleDir, moduleDir, exports, desc);\n\t\t\t\tresult.addImport(importingModuleDir, moduleDir, me);\n\t\t\t}\n\t\t\tfor(IEObjectDescription desc : importedAdapter.getAmbiguousDescriptions()) {\n\t\t\t\tFile moduleDir = getContainerHandle(desc.getEObjectURI(), descriptionIndex, validationContainerManager);\n\t\t\t\tif(moduleDir == null)\n\t\t\t\t\tcontinue;\n\t\t\t\tModuleExport me = exports.get(desc);\n\t\t\t\tif(me == null)\n\t\t\t\t\tme = searchMissing(importingModuleDir, moduleDir, exports, desc);\n\t\t\t\tresult.addAmbiguity(importingModuleDir, moduleDir, me);\n\t\t\t}\n\t\t\tresult.addUnresolved(importingModuleDir, r.getURI(), importedAdapter.getUnresolved(), fQualifiedToString);\n\t\t}\n\t\tresult.setRestricted(restricted);\n\t\treturn result;\n\t}\n"} {"input": "\tprivate void doPost(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException {\n\t\tString page = httpRequest.getParameter(\"page\");\n\t\tMap referenceMap = new HashMap();\n\t\tWriter writer = httpResponse.getWriter();\n\t\twizardModel.errors.clear();\n\t\tif (\"databasesetup.vm\".equals(page)) {\n\t\t\twizardModel.databaseConnection = httpRequest.getParameter(\"database_connection\");\n\t\t\tcheckForEmptyValue(wizardModel.databaseConnection, wizardModel.errors, \"Database connection string\");\n\t\t\tif (\"yes\".equals(httpRequest.getParameter(\"current_openmrs_database\"))) {\n\t\t\t\twizardModel.databaseName = httpRequest.getParameter(\"openmrs_current_database_name\");\n\t\t\t\tcheckForEmptyValue(wizardModel.databaseName, wizardModel.errors, \"Current database name\");\n\t\t\t\twizardModel.hasCurrentOpenmrsDatabase = true;\n\t\t\t} else {\n\t\t\t\twizardModel.hasCurrentOpenmrsDatabase = false;\n\t\t\t\twizardModel.createTables = true;\n\t\t\t\twizardModel.databaseName = httpRequest.getParameter(\"openmrs_new_database_name\");\n\t\t\t\tcheckForEmptyValue(wizardModel.databaseName, wizardModel.errors, \"New database name\");\n\t\t\t\twizardModel.createDatabaseUsername = httpRequest.getParameter(\"create_database_username\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createDatabaseUsername, wizardModel.errors,\n\t\t\t\t \"A user that has 'CREATE DATABASE' privileges\");\n\t\t\t\twizardModel.createDatabasePassword = httpRequest.getParameter(\"create_database_password\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createDatabasePassword, wizardModel.errors,\n\t\t\t\t \"Password for user with 'CREATE DATABASE' privileges\");\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) {\n\t\t\t\tpage = \"databasetablesanduser.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"databasetablesanduser.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"databasesetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.hasCurrentOpenmrsDatabase) {\n\t\t\t\twizardModel.createTables = \"yes\".equals(httpRequest.getParameter(\"create_tables\"));\n\t\t\t}\n\t\t\twizardModel.addDemoData = \"yes\".equals(httpRequest.getParameter(\"add_demo_data\"));\n\t\t\tif (\"yes\".equals(httpRequest.getParameter(\"current_database_user\"))) {\n\t\t\t\twizardModel.currentDatabaseUsername = httpRequest.getParameter(\"current_database_username\");\n\t\t\t\tcheckForEmptyValue(wizardModel.currentDatabaseUsername, wizardModel.errors, \"Curent user account\");\n\t\t\t\twizardModel.currentDatabasePassword = httpRequest.getParameter(\"current_database_password\");\n\t\t\t\tcheckForEmptyValue(wizardModel.currentDatabasePassword, wizardModel.errors, \"Current user account password\");\n\t\t\t\twizardModel.hasCurrentDatabaseUser = true;\n\t\t\t\twizardModel.createDatabaseUser = false;\n\t\t\t} else {\n\t\t\t\twizardModel.hasCurrentDatabaseUser = false;\n\t\t\t\twizardModel.createDatabaseUser = true;\n\t\t\t\twizardModel.createUserUsername = httpRequest.getParameter(\"create_user_username\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createUserUsername, wizardModel.errors,\n\t\t\t\t \"A user that has 'CREATE USER' privileges\");\n\t\t\t\twizardModel.createUserPassword = httpRequest.getParameter(\"create_user_password\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createUserPassword, wizardModel.errors,\n\t\t\t\t \"Password for user that has 'CREATE USER' privileges\");\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) { \n\t\t\t\tpage = \"otherruntimeproperties.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"otherruntimeproperties.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"databasetablesanduser.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\twizardModel.moduleWebAdmin = \"yes\".equals(httpRequest.getParameter(\"module_web_admin\"));\n\t\t\twizardModel.autoUpdateDatabase = \"yes\".equals(httpRequest.getParameter(\"auto_update_database\"));\n\t\t\tif (wizardModel.createTables) { \n\t\t\t\tpage = \"adminusersetup.vm\";\n\t\t\t} else { \n\t\t\t\tpage = \"implementationidsetup.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"adminusersetup.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"otherruntimeproperties.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\twizardModel.adminUserPassword = httpRequest.getParameter(\"new_admin_password\");\n\t\t\tString adminUserConfirm = httpRequest.getParameter(\"new_admin_password_confirm\");\n\t\t\tif (!wizardModel.adminUserPassword.equals(adminUserConfirm)) {\n\t\t\t\twizardModel.errors.add(\"Admin passwords don't match\");\n\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.adminUserPassword.equals(\"\")) {\n\t\t\t\twizardModel.errors.add(\"An admin password is required\");\n\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tOpenmrsUtil.validatePassword(\"admin\", wizardModel.adminUserPassword, \"admin\");\n\t\t\t}\n\t\t\tcatch (PasswordException p) {\n\t\t\t\twizardModel.errors.add(\"The password is not long enough, does not contain both uppercase characters and a number, or matches the username.\");\n\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) { \n\t\t\t\tpage = \"implementationidsetup.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"implementationidsetup.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\tif (wizardModel.createTables)\n\t\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\telse\n\t\t\t\t\trenderTemplate(\"otherruntimeproperties.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\twizardModel.implementationIdName = httpRequest.getParameter(\"implementation_name\");\n\t\t\twizardModel.implementationId = httpRequest.getParameter(\"implementation_id\");\n\t\t\twizardModel.implementationIdPassPhrase = httpRequest.getParameter(\"pass_phrase\");\n\t\t\twizardModel.implementationIdDescription = httpRequest.getParameter(\"description\");\n\t\t\tif (wizardModel.implementationId.indexOf('^') != -1 || wizardModel.implementationId.indexOf('|') != -1) {\n\t\t\t\twizardModel.errors.add(\"Implementation ID cannot contain '^' or '|'\");\n\t\t\t\trenderTemplate(\"implementationidsetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) { \n\t\t\t\tpage = \"wizardcomplete.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} else if (\"wizardcomplete.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"implementationidsetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tProperties runtimeProperties = new Properties();\n\t\t\tString connectionUsername;\n\t\t\tString connectionPassword;\n\t\t\tif (!wizardModel.hasCurrentOpenmrsDatabase) {\n\t\t\t\tString sql = \"create database `?` default character set utf8\";\n\t\t\t\tint result = executeStatement(false, wizardModel.createDatabaseUsername, wizardModel.createDatabasePassword,\n\t\t\t\t sql, wizardModel.databaseName);\n\t\t\t\tif (result < 0) {\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\twizardModel.workLog.add(\"Created database \" + wizardModel.databaseName);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (wizardModel.createDatabaseUser) {\n\t\t\t\tconnectionUsername = wizardModel.databaseName + \"_user\";\n\t\t\t\tif (connectionUsername.length() > 16)\n\t\t\t\t\tconnectionUsername = wizardModel.databaseName.substring(0, 11) + \"_user\"; \n\t\t\t\tconnectionPassword = \"\";\n\t\t\t\tString chars = \"acdeghijklmnopqrtvwxyzACDEGHIJKLMNOPQRTVWXYZ0123456789.|~@#^&\";\n\t\t\t\tRandom r = new Random();\n\t\t\t\tfor (int x = 0; x < 12; x++) {\n\t\t\t\t\tconnectionPassword += chars.charAt(r.nextInt(chars.length()));\n\t\t\t\t}\n\t\t\t\tString sql = \"drop user '?'@'localhost'\";\n\t\t\t\texecuteStatement(true, wizardModel.createUserUsername, wizardModel.createUserPassword, sql,\n\t\t\t\t connectionUsername);\n\t\t\t\tsql = \"create user '?'@'localhost' identified by '?'\";\n\t\t\t\tif (-1 != executeStatement(false, wizardModel.createUserUsername, wizardModel.createUserPassword, sql,\n\t\t\t\t connectionUsername, connectionPassword)) {\n\t\t\t\t\twizardModel.workLog.add(\"Created user \" + connectionUsername);\n\t\t\t\t} else {\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsql = \"GRANT ALL ON `?`.* TO '?'@'localhost'\";\n\t\t\t\tint result = executeStatement(false, wizardModel.createUserUsername, wizardModel.createUserPassword, sql,\n\t\t\t\t wizardModel.databaseName, connectionUsername);\n\t\t\t\tif (result < 0) {\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\twizardModel.workLog.add(\"Granted user \" + connectionUsername + \" all privileges to database \"\n\t\t\t\t\t + wizardModel.databaseName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconnectionUsername = wizardModel.currentDatabaseUsername;\n\t\t\t\tconnectionPassword = wizardModel.currentDatabasePassword;\n\t\t\t}\n\t\t\tString finalDatabaseConnectionString = wizardModel.databaseConnection.replace(\"@DBNAME@\",\n\t\t\t wizardModel.databaseName);\n\t\t\tif (!verifyConnection(connectionUsername, connectionPassword, finalDatabaseConnectionString)) {\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\truntimeProperties.put(\"connection.url\", finalDatabaseConnectionString);\n\t\t\truntimeProperties.put(\"connection.username\", connectionUsername);\n\t\t\truntimeProperties.put(\"connection.password\", connectionPassword);\n\t\t\truntimeProperties.put(\"module.allow_web_admin\", wizardModel.moduleWebAdmin.toString());\n\t\t\truntimeProperties.put(\"auto_update_database\", wizardModel.autoUpdateDatabase.toString());\n\t\t\truntimeProperties.put(SchedulerConstants.SCHEDULER_USERNAME_PROPERTY, \"admin\");\n\t\t\truntimeProperties.put(SchedulerConstants.SCHEDULER_PASSWORD_PROPERTY, wizardModel.adminUserPassword);\n\t\t\tContext.setRuntimeProperties(runtimeProperties);\n\t\t\tif (wizardModel.createTables) {\n\t\t\t\ttry {\n\t\t\t\t\tDatabaseUpdater.executeChangelog(LIQUIBASE_SCHEMA_DATA, null);\n\t\t\t\t\tDatabaseUpdater.executeChangelog(LIQUIBASE_CORE_DATA, null);\n\t\t\t\t\twizardModel.workLog.add(\"Created database tables and added core data\");\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\twizardModel.errors.add(e.getMessage() + \" See the error log for more details\"); \n\t\t\t\t\tlog.warn(\"Error while trying to create tables and demo data\", e);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (wizardModel.createTables && wizardModel.addDemoData) {\n\t\t\t\ttry {\n\t\t\t\t\tDatabaseUpdater.executeChangelog(LIQUIBASE_DEMO_DATA, null);\n\t\t\t\t\twizardModel.workLog.add(\"Added demo data\");\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\twizardModel.errors.add(e.getMessage() + \" See the error log for more details\"); \n\t\t\t\t\tlog.warn(\"Error while trying to add demo data\", e);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tDatabaseUpdater.update();\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\twizardModel.errors.add(e.getMessage() + \" Error while trying to update to the latest database version\"); \n\t\t\t\tlog.warn(\"Error while trying to update to the latest database version\", e);\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tContextLoader contextLoader = new ContextLoader();\n\t\t\tcontextLoader.initWebApplicationContext(filterConfig.getServletContext());\n\t\t\ttry {\n\t\t\t\tContext.startup(runtimeProperties);\n\t\t\t}\n\t\t\tcatch (DatabaseUpdateException updateEx) {\n\t\t\t\tlog.warn(\"Error while running the database update file\", updateEx);\n\t\t\t\twizardModel.errors.add(updateEx.getMessage()\n\t\t\t\t + \" There was an error while running the database update file: \" + updateEx.getMessage()); \n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcatch (InputRequiredException inputRequiredEx) {\n\t\t\t\tlog\n\t\t\t\t .warn(\"Unable to continue because user input is required for the db updates, but I am not doing anything about that right now\");\n\t\t\t\twizardModel.errors\n\t\t\t\t .add(\"Unable to continue because user input is required for the db updates, but I am not doing anything about that right now\");\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!wizardModel.implementationId.equals(\"\")) {\n\t\t\t\ttry {\n\t\t\t\t\tContext.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);\n\t\t\t\t\tContext.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);\n\t\t\t\t\tContext.addProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);\n\t\t\t\t\tImplementationId implId = new ImplementationId();\n\t\t\t\t\timplId.setName(wizardModel.implementationIdName);\n\t\t\t\t\timplId.setImplementationId(wizardModel.implementationId);\n\t\t\t\t\timplId.setPassphrase(wizardModel.implementationIdPassPhrase);\n\t\t\t\t\timplId.setDescription(wizardModel.implementationIdDescription);\n\t\t\t\t\tContext.getAdministrationService().setImplementationId(implId);\n\t\t\t\t}\n\t\t\t\tcatch (Throwable t) {\n\t\t\t\t\twizardModel.errors.add(t.getMessage() + \" Implementation ID could not be set.\");\n\t\t\t\t\tlog.warn(\"Implementation ID could not be set.\", t);\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\tContext.shutdown();\n\t\t\t\t\tWebModuleUtil.shutdownModules(filterConfig.getServletContext());\n\t\t\t\t\tcontextLoader.closeWebApplicationContext(filterConfig.getServletContext());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfinally {\n\t\t\t\t\tContext.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);\n\t\t\t\t\tContext.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);\n\t\t\t\t\tContext.removeProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (wizardModel.createTables) {\n\t\t\t\t\tContext.authenticate(\"admin\", \"test\");\n\t\t\t\t\tContext.getUserService().changePassword(\"test\", wizardModel.adminUserPassword);\n\t\t\t\t\tContext.logout();\n\t\t\t\t}\n\t\t\t\tListener.loadCoreModules(filterConfig.getServletContext());\n\t\t\t\tListener.performWebStartOfModules(filterConfig.getServletContext());\n\t\t\t\tSchedulerUtil.startup(runtimeProperties);\n\t\t\t}\n\t\t\tcatch (Throwable t) {\n\t\t\t\tContext.shutdown();\n\t\t\t\tWebModuleUtil.shutdownModules(filterConfig.getServletContext());\n\t\t\t\tcontextLoader.closeWebApplicationContext(filterConfig.getServletContext());\n\t\t\t\twizardModel.errors.add(t.getMessage() + \" Unable to complete the startup.\");\n\t\t\t\tlog.warn(\"Unable to complete the startup.\", t);\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFileOutputStream fos = null;\n\t\t\ttry {\n\t\t\t\tfos = new FileOutputStream(getRuntimePropertiesFile());\n\t\t\t\truntimeProperties.store(fos, \"Auto generated by OpenMRS initialization wizard\");\n\t\t\t\twizardModel.workLog.add(\"Saved runtime properties file \" + getRuntimePropertiesFile());\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tif (fos != null) {\n\t\t\t\t\tfos.close();\n\t\t\t\t}\n\t\t\t}\n\t\t\tinitializationComplete = true;\n\t\t\thttpResponse.sendRedirect(\"/\" + WebConstants.WEBAPP_NAME);\n\t\t}\n\t}\n", "output": "\tprivate void doPost(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException {\n\t\tString page = httpRequest.getParameter(\"page\");\n\t\tMap referenceMap = new HashMap();\n\t\tWriter writer = httpResponse.getWriter();\n\t\twizardModel.errors.clear();\n\t\tif (\"databasesetup.vm\".equals(page)) {\n\t\t\twizardModel.databaseConnection = httpRequest.getParameter(\"database_connection\");\n\t\t\tcheckForEmptyValue(wizardModel.databaseConnection, wizardModel.errors, \"Database connection string\");\n\t\t\tif (\"yes\".equals(httpRequest.getParameter(\"current_openmrs_database\"))) {\n\t\t\t\twizardModel.databaseName = httpRequest.getParameter(\"openmrs_current_database_name\");\n\t\t\t\tcheckForEmptyValue(wizardModel.databaseName, wizardModel.errors, \"Current database name\");\n\t\t\t\twizardModel.hasCurrentOpenmrsDatabase = true;\n\t\t\t} else {\n\t\t\t\twizardModel.hasCurrentOpenmrsDatabase = false;\n\t\t\t\twizardModel.createTables = true;\n\t\t\t\twizardModel.databaseName = httpRequest.getParameter(\"openmrs_new_database_name\");\n\t\t\t\tcheckForEmptyValue(wizardModel.databaseName, wizardModel.errors, \"New database name\");\n\t\t\t\twizardModel.createDatabaseUsername = httpRequest.getParameter(\"create_database_username\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createDatabaseUsername, wizardModel.errors,\n\t\t\t\t \"A user that has 'CREATE DATABASE' privileges\");\n\t\t\t\twizardModel.createDatabasePassword = httpRequest.getParameter(\"create_database_password\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createDatabasePassword, wizardModel.errors,\n\t\t\t\t \"Password for user with 'CREATE DATABASE' privileges\");\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) {\n\t\t\t\tpage = \"databasetablesanduser.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"databasetablesanduser.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"databasesetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.hasCurrentOpenmrsDatabase) {\n\t\t\t\twizardModel.createTables = \"yes\".equals(httpRequest.getParameter(\"create_tables\"));\n\t\t\t}\n\t\t\twizardModel.addDemoData = \"yes\".equals(httpRequest.getParameter(\"add_demo_data\"));\n\t\t\tif (\"yes\".equals(httpRequest.getParameter(\"current_database_user\"))) {\n\t\t\t\twizardModel.currentDatabaseUsername = httpRequest.getParameter(\"current_database_username\");\n\t\t\t\tcheckForEmptyValue(wizardModel.currentDatabaseUsername, wizardModel.errors, \"Curent user account\");\n\t\t\t\twizardModel.currentDatabasePassword = httpRequest.getParameter(\"current_database_password\");\n\t\t\t\tcheckForEmptyValue(wizardModel.currentDatabasePassword, wizardModel.errors, \"Current user account password\");\n\t\t\t\twizardModel.hasCurrentDatabaseUser = true;\n\t\t\t\twizardModel.createDatabaseUser = false;\n\t\t\t} else {\n\t\t\t\twizardModel.hasCurrentDatabaseUser = false;\n\t\t\t\twizardModel.createDatabaseUser = true;\n\t\t\t\twizardModel.createUserUsername = httpRequest.getParameter(\"create_user_username\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createUserUsername, wizardModel.errors,\n\t\t\t\t \"A user that has 'CREATE USER' privileges\");\n\t\t\t\twizardModel.createUserPassword = httpRequest.getParameter(\"create_user_password\");\n\t\t\t\tcheckForEmptyValue(wizardModel.createUserPassword, wizardModel.errors,\n\t\t\t\t \"Password for user that has 'CREATE USER' privileges\");\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) { \n\t\t\t\tpage = \"otherruntimeproperties.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"otherruntimeproperties.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"databasetablesanduser.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\twizardModel.moduleWebAdmin = \"yes\".equals(httpRequest.getParameter(\"module_web_admin\"));\n\t\t\twizardModel.autoUpdateDatabase = \"yes\".equals(httpRequest.getParameter(\"auto_update_database\"));\n\t\t\tif (wizardModel.createTables) { \n\t\t\t\tpage = \"adminusersetup.vm\";\n\t\t\t} else { \n\t\t\t\tpage = \"implementationidsetup.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"adminusersetup.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"otherruntimeproperties.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\twizardModel.adminUserPassword = httpRequest.getParameter(\"new_admin_password\");\n\t\t\tString adminUserConfirm = httpRequest.getParameter(\"new_admin_password_confirm\");\n\t\t\tif (!wizardModel.adminUserPassword.equals(adminUserConfirm)) {\n\t\t\t\twizardModel.errors.add(\"Admin passwords don't match\");\n\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.adminUserPassword.equals(\"\")) {\n\t\t\t\twizardModel.errors.add(\"An admin password is required\");\n\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tOpenmrsUtil.validatePassword(\"admin\", wizardModel.adminUserPassword, \"admin\");\n\t\t\t}\n\t\t\tcatch (PasswordException p) {\n\t\t\t\twizardModel.errors.add(\"The password is not long enough, does not contain both uppercase characters and a number, or matches the username.\");\n\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) { \n\t\t\t\tpage = \"implementationidsetup.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} \n\t\telse if (\"implementationidsetup.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\tif (wizardModel.createTables)\n\t\t\t\t\trenderTemplate(\"adminusersetup.vm\", referenceMap, writer);\n\t\t\t\telse\n\t\t\t\t\trenderTemplate(\"otherruntimeproperties.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\twizardModel.implementationIdName = httpRequest.getParameter(\"implementation_name\");\n\t\t\twizardModel.implementationId = httpRequest.getParameter(\"implementation_id\");\n\t\t\twizardModel.implementationIdPassPhrase = httpRequest.getParameter(\"pass_phrase\");\n\t\t\twizardModel.implementationIdDescription = httpRequest.getParameter(\"description\");\n\t\t\tif (wizardModel.implementationId.indexOf('^') != -1 || wizardModel.implementationId.indexOf('|') != -1) {\n\t\t\t\twizardModel.errors.add(\"Implementation ID cannot contain '^' or '|'\");\n\t\t\t\trenderTemplate(\"implementationidsetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (wizardModel.errors.isEmpty()) { \n\t\t\t\tpage = \"wizardcomplete.vm\";\n\t\t\t}\n\t\t\trenderTemplate(page, referenceMap, writer);\n\t\t} else if (\"wizardcomplete.vm\".equals(page)) {\n\t\t\tif (\"Back\".equals(httpRequest.getParameter(\"back\"))) {\n\t\t\t\trenderTemplate(\"implementationidsetup.vm\", referenceMap, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tProperties runtimeProperties = new Properties();\n\t\t\tString connectionUsername;\n\t\t\tString connectionPassword;\n\t\t\tif (!wizardModel.hasCurrentOpenmrsDatabase) {\n\t\t\t\tString sql = \"create database `?` default character set utf8\";\n\t\t\t\tint result = executeStatement(false, wizardModel.createDatabaseUsername, wizardModel.createDatabasePassword,\n\t\t\t\t sql, wizardModel.databaseName);\n\t\t\t\tif (result < 0) {\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\twizardModel.workLog.add(\"Created database \" + wizardModel.databaseName);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (wizardModel.createDatabaseUser) {\n\t\t\t\tconnectionUsername = wizardModel.databaseName + \"_user\";\n\t\t\t\tif (connectionUsername.length() > 16)\n\t\t\t\t\tconnectionUsername = wizardModel.databaseName.substring(0, 11) + \"_user\"; \n\t\t\t\tconnectionPassword = \"\";\n\t\t\t\tString chars = \"acdeghijklmnopqrtvwxyzACDEGHIJKLMNOPQRTVWXYZ0123456789.|~@#^&\";\n\t\t\t\tRandom r = new Random();\n\t\t\t\tfor (int x = 0; x < 12; x++) {\n\t\t\t\t\tconnectionPassword += chars.charAt(r.nextInt(chars.length()));\n\t\t\t\t}\n\t\t\t\tString sql = \"drop user '?'@'localhost'\";\n\t\t\t\texecuteStatement(true, wizardModel.createUserUsername, wizardModel.createUserPassword, sql,\n\t\t\t\t connectionUsername);\n\t\t\t\tsql = \"create user '?'@'localhost' identified by '?'\";\n\t\t\t\tif (-1 != executeStatement(false, wizardModel.createUserUsername, wizardModel.createUserPassword, sql,\n\t\t\t\t connectionUsername, connectionPassword)) {\n\t\t\t\t\twizardModel.workLog.add(\"Created user \" + connectionUsername);\n\t\t\t\t} else {\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tsql = \"GRANT ALL ON `?`.* TO '?'@'localhost'\";\n\t\t\t\tint result = executeStatement(false, wizardModel.createUserUsername, wizardModel.createUserPassword, sql,\n\t\t\t\t wizardModel.databaseName, connectionUsername);\n\t\t\t\tif (result < 0) {\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\treturn;\n\t\t\t\t} else {\n\t\t\t\t\twizardModel.workLog.add(\"Granted user \" + connectionUsername + \" all privileges to database \"\n\t\t\t\t\t + wizardModel.databaseName);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconnectionUsername = wizardModel.currentDatabaseUsername;\n\t\t\t\tconnectionPassword = wizardModel.currentDatabasePassword;\n\t\t\t}\n\t\t\tString finalDatabaseConnectionString = wizardModel.databaseConnection.replace(\"@DBNAME@\",\n\t\t\t wizardModel.databaseName);\n\t\t\tif (!verifyConnection(connectionUsername, connectionPassword, finalDatabaseConnectionString)) {\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\truntimeProperties.put(\"connection.url\", finalDatabaseConnectionString);\n\t\t\truntimeProperties.put(\"connection.username\", connectionUsername);\n\t\t\truntimeProperties.put(\"connection.password\", connectionPassword);\n\t\t\truntimeProperties.put(\"module.allow_web_admin\", wizardModel.moduleWebAdmin.toString());\n\t\t\truntimeProperties.put(\"auto_update_database\", wizardModel.autoUpdateDatabase.toString());\n\t\t\truntimeProperties.put(SchedulerConstants.SCHEDULER_USERNAME_PROPERTY, \"admin\");\n\t\t\truntimeProperties.put(SchedulerConstants.SCHEDULER_PASSWORD_PROPERTY, wizardModel.adminUserPassword);\n\t\t\tContext.setRuntimeProperties(runtimeProperties);\n\t\t\tif (wizardModel.createTables) {\n\t\t\t\ttry {\n\t\t\t\t\tDatabaseUpdater.executeChangelog(LIQUIBASE_SCHEMA_DATA, null);\n\t\t\t\t\tDatabaseUpdater.executeChangelog(LIQUIBASE_CORE_DATA, null);\n\t\t\t\t\twizardModel.workLog.add(\"Created database tables and added core data\");\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\twizardModel.errors.add(e.getMessage() + \" See the error log for more details\"); \n\t\t\t\t\tlog.warn(\"Error while trying to create tables and demo data\", e);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (wizardModel.createTables && wizardModel.addDemoData) {\n\t\t\t\ttry {\n\t\t\t\t\tDatabaseUpdater.executeChangelog(LIQUIBASE_DEMO_DATA, null);\n\t\t\t\t\twizardModel.workLog.add(\"Added demo data\");\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\twizardModel.errors.add(e.getMessage() + \" See the error log for more details\"); \n\t\t\t\t\tlog.warn(\"Error while trying to add demo data\", e);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tDatabaseUpdater.update();\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\twizardModel.errors.add(e.getMessage() + \" Error while trying to update to the latest database version\"); \n\t\t\t\tlog.warn(\"Error while trying to update to the latest database version\", e);\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tContextLoader contextLoader = new ContextLoader();\n\t\t\tcontextLoader.initWebApplicationContext(filterConfig.getServletContext());\n\t\t\ttry {\n\t\t\t\tContext.openSession();\n\t\t\t\tContext.startup(runtimeProperties);\n\t\t\t}\n\t\t\tcatch (DatabaseUpdateException updateEx) {\n\t\t\t\tlog.warn(\"Error while running the database update file\", updateEx);\n\t\t\t\twizardModel.errors.add(updateEx.getMessage()\n\t\t\t\t + \" There was an error while running the database update file: \" + updateEx.getMessage()); \n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcatch (InputRequiredException inputRequiredEx) {\n\t\t\t\tlog\n\t\t\t\t .warn(\"Unable to continue because user input is required for the db updates, but I am not doing anything about that right now\");\n\t\t\t\twizardModel.errors\n\t\t\t\t .add(\"Unable to continue because user input is required for the db updates, but I am not doing anything about that right now\");\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!wizardModel.implementationId.equals(\"\")) {\n\t\t\t\ttry {\n\t\t\t\t\tContext.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);\n\t\t\t\t\tContext.addProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);\n\t\t\t\t\tContext.addProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);\n\t\t\t\t\tImplementationId implId = new ImplementationId();\n\t\t\t\t\timplId.setName(wizardModel.implementationIdName);\n\t\t\t\t\timplId.setImplementationId(wizardModel.implementationId);\n\t\t\t\t\timplId.setPassphrase(wizardModel.implementationIdPassPhrase);\n\t\t\t\t\timplId.setDescription(wizardModel.implementationIdDescription);\n\t\t\t\t\tContext.getAdministrationService().setImplementationId(implId);\n\t\t\t\t}\n\t\t\t\tcatch (Throwable t) {\n\t\t\t\t\twizardModel.errors.add(t.getMessage() + \" Implementation ID could not be set.\");\n\t\t\t\t\tlog.warn(\"Implementation ID could not be set.\", t);\n\t\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\t\tContext.shutdown();\n\t\t\t\t\tWebModuleUtil.shutdownModules(filterConfig.getServletContext());\n\t\t\t\t\tcontextLoader.closeWebApplicationContext(filterConfig.getServletContext());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfinally {\n\t\t\t\t\tContext.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_GLOBAL_PROPERTIES);\n\t\t\t\t\tContext.removeProxyPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_SOURCES);\n\t\t\t\t\tContext.removeProxyPrivilege(OpenmrsConstants.PRIV_VIEW_CONCEPT_SOURCES);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (wizardModel.createTables) {\n\t\t\t\t\tContext.authenticate(\"admin\", \"test\");\n\t\t\t\t\tContext.getUserService().changePassword(\"test\", wizardModel.adminUserPassword);\n\t\t\t\t\tContext.logout();\n\t\t\t\t}\n\t\t\t\tListener.loadCoreModules(filterConfig.getServletContext());\n\t\t\t\tListener.performWebStartOfModules(filterConfig.getServletContext());\n\t\t\t\tSchedulerUtil.startup(runtimeProperties);\n\t\t\t}\n\t\t\tcatch (Throwable t) {\n\t\t\t\tContext.shutdown();\n\t\t\t\tWebModuleUtil.shutdownModules(filterConfig.getServletContext());\n\t\t\t\tcontextLoader.closeWebApplicationContext(filterConfig.getServletContext());\n\t\t\t\twizardModel.errors.add(t.getMessage() + \" Unable to complete the startup.\");\n\t\t\t\tlog.warn(\"Unable to complete the startup.\", t);\n\t\t\t\trenderTemplate(DEFAULT_PAGE, null, writer);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tFileOutputStream fos = null;\n\t\t\ttry {\n\t\t\t\tfos = new FileOutputStream(getRuntimePropertiesFile());\n\t\t\t\truntimeProperties.store(fos, \"Auto generated by OpenMRS initialization wizard\");\n\t\t\t\twizardModel.workLog.add(\"Saved runtime properties file \" + getRuntimePropertiesFile());\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tif (fos != null) {\n\t\t\t\t\tfos.close();\n\t\t\t\t}\n\t\t\t}\n\t\t\tinitializationComplete = true;\n\t\t\tContext.closeSession();\n\t\t\thttpResponse.sendRedirect(\"/\" + WebConstants.WEBAPP_NAME);\n\t\t}\n\t}\n"} {"input": " private String escapeURL(String base) {\n\tfinal char[] chs = base.toCharArray();\n\tfinal StringBuffer result = new StringBuffer();\n\tfinal int length = chs.length;\n for (int i = 0; i < length; i++) {\n\t final char ch = chs[i];\n\t if (ch <= 0x20) {\n\t\tresult.append('%').append(makeHHString(ch));\n\t } \n\t else if (ch > '\\u007F') {\n\t\tresult.append('%')\n\t\t .append(makeHHString((ch >> 6) | 0xC0))\n\t\t .append('%')\n\t\t .append(makeHHString((ch & 0x3F) | 0x80));\n\t }\n\t else {\n\t switch (ch) {\n\t\t case '\\u007F' :\n\t\t case '\\u007B' :\n\t\t case '\\u007D' :\n\t\t case '\\u007C' :\n\t\t case '\\\\' :\n\t\t case '\\t' :\n\t\t case '\\u005E' :\n\t\t case '\\u007E' :\n\t\t case '\\u005B' :\n\t\t case '\\u005D' :\n\t\t case '\\u0060' :\n\t\t case '\\u0020' :\n\t\t result.append('%')\n\t\t .append(Integer.toHexString((int) ch));\n\t\t break;\n\t\t case '\"':\n\t\t\tresult.append(\""\");\n\t\t\tbreak;\n\t\t default:\t\n\t\t result.append(ch); \n\t\t\tbreak;\n\t }\n\t } \n \t}\n\treturn result.toString();\n }\n", "output": " private String escapeURL(String base) {\n\tfinal char[] chs = base.toCharArray();\n\tfinal StringBuffer result = new StringBuffer();\n\tfinal int length = chs.length;\n for (int i = 0; i < length; i++) {\n\t final char ch = chs[i];\n\t if (ch <= 0x20) {\n\t\tresult.append('%').append(makeHHString(ch));\n\t } \n\t else if (ch > '\\u007F') {\n\t\tresult.append('%')\n\t\t .append(makeHHString((ch >> 6) | 0xC0))\n\t\t .append('%')\n\t\t .append(makeHHString((ch & 0x3F) | 0x80));\n\t }\n\t else {\n\t switch (ch) {\n\t\t case '\\u007F' :\n\t\t case '\\u007B' :\n\t\t case '\\u007D' :\n\t\t case '\\u007C' :\n\t\t case '\\\\' :\n\t\t case '\\t' :\n\t\t case '\\u005E' :\n\t\t case '\\u007E' :\n\t\t case '\\u005B' :\n\t\t case '\\u005D' :\n\t\t case '\\u0060' :\n\t\t case '\\u0020' :\n\t\t result.append('%')\n\t\t .append(Integer.toHexString((int) ch));\n\t\t break;\n\t\t case '\"':\n\t\t\tresult.append(\"%22\");\n\t\t\tbreak;\n\t\t default:\t\n\t\t result.append(ch); \n\t\t\tbreak;\n\t }\n\t } \n \t}\n\treturn result.toString();\n }\n"} {"input": " public static boolean isNumericConstant(RNode node, double cvalue) {\n RAny value = getConstantValue(node);\n if (value != null) { return false; }\n boolean ok = value instanceof RDouble || value instanceof RInt || value instanceof RLogical;\n if (!ok) { return false; }\n RDouble dv = value.asDouble();\n return dv.size() == 1 ? dv.getDouble(0) == cvalue : false;\n }\n", "output": " public static boolean isNumericConstant(RNode node, double cvalue) {\n RAny value = getConstantValue(node);\n if (value == null) { return false; }\n boolean ok = value instanceof RDouble || value instanceof RInt || value instanceof RLogical;\n if (!ok) { return false; }\n RDouble dv = value.asDouble();\n return dv.size() == 1 ? dv.getDouble(0) == cvalue : false;\n }\n"} {"input": "\tpublic static void cmd(String name, Object ...args) {\n\t\tif (name.equals(\"start\")) {\n\t\t\tif (file != null) {\n\t\t\t\tfile.close();\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfile = new PrintWriter(new FileWriter(String.format(\"%d.avy\", fileIndex++)));\n\t\t\t} catch (IOException e) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tStringBuffer sb = new StringBuffer(name);\n\t\tfor (Object obj : args) {\n\t\t\tsb.append(' ');\n\t\t\tsb.append(gson.toJson(obj));\n\t\t}\n\t\tfile.println(sb.toString());\n\t}\n", "output": "\tpublic static void cmd(String name, Object ...args) {\n\t\tif (name.equals(\"start\")) {\n\t\t\tif (file != null) {\n\t\t\t\tfile.close();\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfile = new PrintWriter(new FileWriter(String.format(\"%d.avy\", fileIndex++)));\n\t\t\t} catch (IOException e) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tStringBuffer sb = new StringBuffer(name);\n\t\tsb.append(\"(\");\n\t\tfor (int i = 0; i < args.length; i++) {\n\t\t\tif (i > 0) {\n\t\t\t\tsb.append(\", \");\n\t\t\t}\n\t\t\tsb.append(gson.toJson(args[i]));\n\t\t}\n\t\tsb.append(\")\");\n\t\tfile.println(sb.toString());\n\t}\n"} {"input": " public FunctionDeclaration(String raw, String result) {\n String base = raw.replace(\".\", \"\\\\s*\\\\.\\\\s*\");\n pattern = Pattern.compile(\".*\" + base + \"\\\\s*\\\\(\\\\s*\\\\).*\");\n function = raw + \" = function() { \" + result + \" }\";\n }\n", "output": " public FunctionDeclaration(String raw, String result) {\n String base = raw.replace(\".\", \"\\\\s*\\\\.\\\\s*\");\n pattern = Pattern.compile(\".*\" + base + \"\\\\s*\\\\(\\\\s*\\\\).*\");\n function = raw + \" = function() { \" + result + \" }; \";\n }\n"} {"input": " protected void parse(PyObject[] args, String[] kws) {\n int largs = args.length;\n if (kws != null) {\n for (String kw: kws) {\n keywords.put(kw, args[--largs]);\n }\n }\n arguments = new PyObject[largs];\n System.arraycopy(args, 0, arguments, 0, largs);\n }\n", "output": " protected void parse(PyObject[] args, String[] kws) {\n int largs = args.length;\n if (kws != null) {\n for (int i = kws.length - 1; i >= 0; i--) {\n keywords.put(kws[i], args[--largs]);\n }\n }\n arguments = new PyObject[largs];\n System.arraycopy(args, 0, arguments, 0, largs);\n }\n"} {"input": " public HTTPStatus request(String method, String path, HTTPHeader header, InputStream body, int ok1, int ok2, OutputStream dst, DefaultHandler handler, SVNErrorMessage context) throws SVNException {\n myLastStatus = null;\n myRequestCount++;\n if (\"\".equals(path) || path == null) {\n path = \"/\";\n }\n ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();\n HTTPSSLKeyManager keyManager = myKeyManager == null && authManager != null ? createKeyManager() : myKeyManager;\n TrustManager trustManager = myTrustManager == null && authManager != null ? authManager.getTrustManager(myRepository.getLocation()) : myTrustManager;\n ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(myRepository.getLocation()) : null;\n String sslRealm = \"<\" + myHost.getProtocol() + \"://\" + myHost.getHost() + \":\" + myHost.getPort() + \">\";\n SVNAuthentication httpAuth = myLastValidAuth;\n boolean isAuthForced = authManager != null ? authManager.isAuthenticationForced() : false;\n if (httpAuth == null && isAuthForced) {\n httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, sslRealm, null);\n myChallengeCredentials = new HTTPBasicAuthentication((SVNPasswordAuthentication)httpAuth, myCharset);\n } \n String realm = null;\n HTTPRequest request = new HTTPRequest(myCharset);\n request.setConnection(this);\n request.setKeepAlive(true);\n request.setRequestBody(body);\n request.setResponseHandler(handler);\n request.setResponseStream(dst);\n SVNErrorMessage err = null;\n boolean ntlmAuthIsRequired = false;\n boolean ntlmProxyAuthIsRequired = false;\n boolean negoAuthIsRequired = false;\n int authAttempts = 0;\n while (true) {\n if (myNextRequestTimeout < 0 || System.currentTimeMillis() >= myNextRequestTimeout) {\n SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, \"Keep-Alive timeout detected\");\n close();\n if (isClearCredentialsOnClose(myChallengeCredentials)) {\n httpAuth = null;\n }\n }\n int retryCount = 1;\n try {\n err = null;\n String httpAuthResponse = null;\n String proxyAuthResponse = null;\n while(retryCount >= 0) {\n connect(keyManager, trustManager, proxyManager);\n request.reset();\n request.setProxied(myIsProxied);\n request.setSecured(myIsSecured); \n if (myProxyAuthentication != null && (ntlmProxyAuthIsRequired || !\"NTLM\".equals(myProxyAuthentication.getAuthenticationScheme()))) {\n if (proxyAuthResponse == null) {\n request.initCredentials(myProxyAuthentication, method, path);\n proxyAuthResponse = myProxyAuthentication.authenticate();\n }\n request.setProxyAuthentication(proxyAuthResponse);\n }\n if (myChallengeCredentials != null && (ntlmAuthIsRequired || negoAuthIsRequired || ((!\"NTLM\".equals(myChallengeCredentials.getAuthenticationScheme())) && !\"Negotiate\".equals(myChallengeCredentials.getAuthenticationScheme())) && \n httpAuth != null)) {\n if (httpAuthResponse == null) {\n request.initCredentials(myChallengeCredentials, method, path);\n httpAuthResponse = myChallengeCredentials.authenticate();\n }\n request.setAuthentication(httpAuthResponse);\n }\n if (myCookies != null && !myCookies.isEmpty()) {\n request.setCookies(myCookies);\n }\n try { \n request.dispatch(method, path, header, ok1, ok2, context);\n break;\n } catch (EOFException pe) {\n if (retryCount > 0) {\n close();\n continue;\n }\n throw (IOException) new IOException(pe.getMessage()).initCause(pe);\n } finally {\n retryCount--;\n }\n }\n if (request.getResponseHeader().hasHeader(HTTPHeader.SET_COOKIE)) {\n myCookies = request.getResponseHeader().getHeaderValues(HTTPHeader.COOKIE);\n }\n myNextRequestTimeout = request.getNextRequestTimeout();\n myLastStatus = request.getStatus();\n } catch (SSLHandshakeException ssl) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, ssl);\n close();\n\t if (ssl.getCause() instanceof SVNSSLUtil.CertificateNotTrustedException) {\n\t\t SVNErrorManager.cancel(ssl.getCause().getMessage(), SVNLogType.NETWORK);\n\t }\n SVNErrorMessage sslErr = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, \"SSL handshake failed: ''{0}''\", new Object[] { ssl.getMessage() }, SVNErrorMessage.TYPE_ERROR, ssl);\n\t\t if (keyManager != null) {\n\t\t\t keyManager.acknowledgeAndClearAuthentication(sslErr);\n\t\t }\n err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, ssl);\n\t continue;\n } catch (IOException e) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, e);\n if (e instanceof SocketTimeoutException) {\n\t err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n\t \"timed out waiting for server\", null, SVNErrorMessage.TYPE_ERROR, e);\n } else if (e instanceof UnknownHostException) {\n\t err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n\t \"unknown host\", null, SVNErrorMessage.TYPE_ERROR, e);\n } else if (e instanceof ConnectException) {\n\t err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n\t \"connection refused by the server\", null, \n\t SVNErrorMessage.TYPE_ERROR, e);\n } else if (e instanceof SVNCancellableOutputStream.IOCancelException) {\n SVNErrorManager.cancel(e.getMessage(), SVNLogType.NETWORK);\n } else if (e instanceof SSLException) { \n err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n e.getMessage());\n } else {\n err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n e.getMessage());\n }\n } catch (SVNException e) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, e);\n close();\n throw e;\n } finally {\n finishResponse(request); \n }\n if (err != null) {\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(false, err);\n }\n close();\n break;\n }\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(true, err);\n }\n if (keyManager != null) {\n\t myKeyManager = keyManager;\n\t myTrustManager = trustManager;\n\t keyManager.acknowledgeAndClearAuthentication(null);\n }\n if (myLastStatus.getCode() == HttpURLConnection.HTTP_FORBIDDEN) {\n if (httpAuth != null && authManager != null) {\n BasicAuthenticationManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth, myRepository.getLocation(), authManager);\n }\n myLastValidAuth = null;\n close();\n err = request.getErrorMessage();\n } else if (myIsProxied && myLastStatus.getCode() == HttpURLConnection.HTTP_PROXY_AUTH) {\n Collection proxyAuthHeaders = request.getResponseHeader().getHeaderValues(HTTPHeader.PROXY_AUTHENTICATE_HEADER);\n Collection authTypes = null;\n if (authManager != null && authManager instanceof DefaultSVNAuthenticationManager) {\n DefaultSVNAuthenticationManager defaultAuthManager = (DefaultSVNAuthenticationManager) authManager;\n authTypes = defaultAuthManager.getAuthTypes(myRepository.getLocation());\n }\n try {\n myProxyAuthentication = HTTPAuthentication.parseAuthParameters(proxyAuthHeaders, myProxyAuthentication, myCharset, authTypes, null, myRequestCount); \n } catch (SVNException svne) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, svne);\n err = svne.getErrorMessage(); \n break;\n }\n if (myProxyAuthentication instanceof HTTPNTLMAuthentication) {\n ntlmProxyAuthIsRequired = true;\n HTTPNTLMAuthentication ntlmProxyAuth = (HTTPNTLMAuthentication)myProxyAuthentication;\n if (ntlmProxyAuth.isInType3State()) {\n continue;\n }\n }\n err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, \"HTTP proxy authorization failed\");\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(false, err);\n }\n close();\n break;\n } else if (myLastStatus.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {\n authAttempts++;\n Collection authHeaderValues = request.getResponseHeader().getHeaderValues(HTTPHeader.AUTHENTICATE_HEADER);\n if (authHeaderValues == null || authHeaderValues.size() == 0) {\n err = request.getErrorMessage();\n myLastStatus.setError(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, err.getMessageTemplate(), err.getRelatedObjects()));\n if (\"LOCK\".equalsIgnoreCase(method)) {\n myLastStatus.getError().setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,\n \"Probably you are trying to lock file in repository that only allows anonymous access\"));\n }\n SVNErrorManager.error(myLastStatus.getError(), SVNLogType.NETWORK);\n return myLastStatus;\n }\n boolean skip = false;\n isAuthForced = authManager != null ? authManager.isAuthenticationForced() : false;\n if (isAuthForced) {\n if (httpAuth != null && myChallengeCredentials != null && !HTTPAuthentication.isSchemeSupportedByServer(myChallengeCredentials.getAuthenticationScheme(), authHeaderValues)) {\n skip = true;\n }\n }\n Collection authTypes = null;\n if (authManager != null && authManager instanceof DefaultSVNAuthenticationManager) {\n DefaultSVNAuthenticationManager defaultAuthManager = (DefaultSVNAuthenticationManager) authManager;\n authTypes = defaultAuthManager.getAuthTypes(myRepository.getLocation());\n }\n try {\n myChallengeCredentials = HTTPAuthentication.parseAuthParameters(authHeaderValues, myChallengeCredentials, myCharset, authTypes, authManager, myRequestCount); \n } catch (SVNException svne) {\n err = svne.getErrorMessage(); \n break;\n }\n myChallengeCredentials.setChallengeParameter(\"method\", method);\n myChallengeCredentials.setChallengeParameter(\"uri\", HTTPParser.getCanonicalPath(path, null).toString());\n if (skip) {\n close();\n continue;\n }\n HTTPNTLMAuthentication ntlmAuth = null;\n HTTPNegotiateAuthentication negoAuth = null;\n if (myChallengeCredentials instanceof HTTPNTLMAuthentication) {\n ntlmAuthIsRequired = true;\n ntlmAuth = (HTTPNTLMAuthentication)myChallengeCredentials;\n if (ntlmAuth.isInType3State()) {\n continue;\n }\n } else if (myChallengeCredentials instanceof HTTPDigestAuthentication) {\n if (myLastValidAuth != null) {\n myLastValidAuth = null;\n continue;\n }\n } else if (myChallengeCredentials instanceof HTTPNegotiateAuthentication) {\n negoAuthIsRequired = true;\n negoAuth = (HTTPNegotiateAuthentication)myChallengeCredentials;\n if (negoAuth.isStarted()) {\n continue;\n }\n }\n myLastValidAuth = null;\n if (ntlmAuth != null && ntlmAuth.isNative() && authAttempts == 1) {\n continue;\n }\n if (negoAuth != null && !negoAuth.needsLogin()) {\n continue;\n }\n if (authManager == null) {\n err = request.getErrorMessage();\n break;\n }\n realm = myChallengeCredentials.getChallengeParameter(\"realm\");\n realm = realm == null ? \"\" : \" \" + realm;\n realm = \"<\" + myHost.getProtocol() + \"://\" + myHost.getHost() + \":\" + myHost.getPort() + \">\" + realm;\n if (httpAuth == null) {\n httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());\n } else if (authAttempts >= requestAttempts) {\n BasicAuthenticationManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth, myRepository.getLocation(), authManager);\n httpAuth = authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());\n }\n if (httpAuth == null) {\n err = SVNErrorMessage.create(SVNErrorCode.CANCELLED, \"HTTP authorization cancelled\");\n break;\n } \n if (httpAuth != null) {\n myChallengeCredentials.setCredentials((SVNPasswordAuthentication) httpAuth);\n }\n continue;\n } else if (myLastStatus.getCode() == HttpURLConnection.HTTP_MOVED_PERM || myLastStatus.getCode() == HttpURLConnection.HTTP_MOVED_TEMP) {\n String newLocation = request.getResponseHeader().getFirstHeaderValue(HTTPHeader.LOCATION_HEADER);\n if (newLocation == null) {\n err = request.getErrorMessage();\n break;\n }\n int hostIndex = newLocation.indexOf(\"://\");\n if (hostIndex > 0) {\n hostIndex += 3;\n hostIndex = newLocation.indexOf(\"/\", hostIndex);\n }\n if (hostIndex > 0 && hostIndex < newLocation.length()) {\n String newPath = newLocation.substring(hostIndex);\n if (newPath.endsWith(\"/\") &&\n !newPath.endsWith(\"//\") && !path.endsWith(\"/\") &&\n newPath.substring(0, newPath.length() - 1).equals(path)) {\n path += \"//\";\n continue;\n }\n }\n err = request.getErrorMessage();\n close();\n } else if (request.getErrorMessage() != null) {\n err = request.getErrorMessage();\n } else {\n ntlmProxyAuthIsRequired = false;\n ntlmAuthIsRequired = false;\n negoAuthIsRequired = false;\n }\n if (err != null) {\n break;\n }\n if (myIsProxied) {\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(true, null);\n }\n }\n if (httpAuth != null && realm != null && authManager != null) {\n BasicAuthenticationManager.acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, httpAuth, myRepository.getLocation(), authManager);\n }\n\t if (trustManager != null && authManager != null) {\n\t\t authManager.acknowledgeTrustManager(trustManager);\n\t }\n if (httpAuth != null) {\n myLastValidAuth = httpAuth;\n }\n if (authManager instanceof ISVNAuthenticationManagerExt) {\n ((ISVNAuthenticationManagerExt)authManager).acknowledgeConnectionSuccessful(myRepository.getLocation());\n }\n myLastStatus.setHeader(request.getResponseHeader());\n return myLastStatus;\n }\n close();\n if (err != null && err.getErrorCode().getCategory() != SVNErrorCode.RA_DAV_CATEGORY &&\n err.getErrorCode() != SVNErrorCode.UNSUPPORTED_FEATURE) {\n SVNErrorManager.error(err, SVNLogType.NETWORK);\n }\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, new Exception(err.getMessage()));\n SVNErrorMessage err2 = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \"{0} request failed on ''{1}''\", new Object[] {method, path}, err.getType(), err.getCause());\n SVNErrorManager.error(err, err2, SVNLogType.NETWORK);\n return null;\n }\n", "output": " public HTTPStatus request(String method, String path, HTTPHeader header, InputStream body, int ok1, int ok2, OutputStream dst, DefaultHandler handler, SVNErrorMessage context) throws SVNException {\n myLastStatus = null;\n myRequestCount++;\n if (\"\".equals(path) || path == null) {\n path = \"/\";\n }\n ISVNAuthenticationManager authManager = myRepository.getAuthenticationManager();\n HTTPSSLKeyManager keyManager = myKeyManager == null && authManager != null ? createKeyManager() : myKeyManager;\n TrustManager trustManager = myTrustManager == null && authManager != null ? authManager.getTrustManager(myRepository.getLocation()) : myTrustManager;\n ISVNProxyManager proxyManager = authManager != null ? authManager.getProxyManager(myRepository.getLocation()) : null;\n String sslRealm = \"<\" + myHost.getProtocol() + \"://\" + myHost.getHost() + \":\" + myHost.getPort() + \">\";\n SVNAuthentication httpAuth = myLastValidAuth;\n boolean isAuthForced = authManager != null ? authManager.isAuthenticationForced() : false;\n if (httpAuth == null && isAuthForced) {\n httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, sslRealm, null);\n myChallengeCredentials = new HTTPBasicAuthentication((SVNPasswordAuthentication)httpAuth, myCharset);\n } \n String realm = null;\n HTTPRequest request = new HTTPRequest(myCharset);\n request.setConnection(this);\n request.setKeepAlive(true);\n request.setRequestBody(body);\n request.setResponseHandler(handler);\n request.setResponseStream(dst);\n SVNErrorMessage err = null;\n boolean ntlmAuthIsRequired = false;\n boolean ntlmProxyAuthIsRequired = false;\n boolean negoAuthIsRequired = false;\n int authAttempts = 0;\n while (true) {\n if (myNextRequestTimeout < 0 || System.currentTimeMillis() >= myNextRequestTimeout) {\n SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, \"Keep-Alive timeout detected\");\n close();\n if (isClearCredentialsOnClose(myChallengeCredentials)) {\n httpAuth = null;\n }\n }\n int retryCount = 1;\n try {\n err = null;\n String httpAuthResponse = null;\n String proxyAuthResponse = null;\n while(retryCount >= 0) {\n connect(keyManager, trustManager, proxyManager);\n request.reset();\n request.setProxied(myIsProxied);\n request.setSecured(myIsSecured); \n if (myProxyAuthentication != null && (ntlmProxyAuthIsRequired || !\"NTLM\".equals(myProxyAuthentication.getAuthenticationScheme()))) {\n if (proxyAuthResponse == null) {\n request.initCredentials(myProxyAuthentication, method, path);\n proxyAuthResponse = myProxyAuthentication.authenticate();\n }\n request.setProxyAuthentication(proxyAuthResponse);\n }\n if (myChallengeCredentials != null && (ntlmAuthIsRequired || negoAuthIsRequired || ((!\"NTLM\".equals(myChallengeCredentials.getAuthenticationScheme())) && !\"Negotiate\".equals(myChallengeCredentials.getAuthenticationScheme())) && \n httpAuth != null)) {\n if (httpAuthResponse == null) {\n request.initCredentials(myChallengeCredentials, method, path);\n httpAuthResponse = myChallengeCredentials.authenticate();\n }\n request.setAuthentication(httpAuthResponse);\n }\n if (myCookies != null && !myCookies.isEmpty()) {\n request.setCookies(myCookies);\n }\n try { \n request.dispatch(method, path, header, ok1, ok2, context);\n break;\n } catch (EOFException pe) {\n if (retryCount > 0) {\n close();\n continue;\n }\n throw (IOException) new IOException(pe.getMessage()).initCause(pe);\n } finally {\n retryCount--;\n }\n }\n if (request.getResponseHeader().hasHeader(HTTPHeader.SET_COOKIE)) {\n myCookies = request.getResponseHeader().getHeaderValues(HTTPHeader.COOKIE);\n }\n myNextRequestTimeout = request.getNextRequestTimeout();\n myLastStatus = request.getStatus();\n } catch (SSLHandshakeException ssl) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, ssl);\n close();\n\t if (ssl.getCause() instanceof SVNSSLUtil.CertificateNotTrustedException) {\n\t\t SVNErrorManager.cancel(ssl.getCause().getMessage(), SVNLogType.NETWORK);\n\t }\n SVNErrorMessage sslErr = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, \"SSL handshake failed: ''{0}''\", new Object[] { ssl.getMessage() }, SVNErrorMessage.TYPE_ERROR, ssl);\n\t\t if (keyManager != null) {\n\t\t\t keyManager.acknowledgeAndClearAuthentication(sslErr);\n\t\t }\n err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, ssl);\n\t continue;\n } catch (IOException e) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, e);\n if (e instanceof SocketTimeoutException) {\n\t err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n\t \"timed out waiting for server\", null, SVNErrorMessage.TYPE_ERROR, e);\n } else if (e instanceof UnknownHostException) {\n\t err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n\t \"unknown host\", null, SVNErrorMessage.TYPE_ERROR, e);\n } else if (e instanceof ConnectException) {\n\t err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n\t \"connection refused by the server\", null, \n\t SVNErrorMessage.TYPE_ERROR, e);\n } else if (e instanceof SVNCancellableOutputStream.IOCancelException) {\n SVNErrorManager.cancel(e.getMessage(), SVNLogType.NETWORK);\n } else if (e instanceof SSLException) { \n err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n e);\n } else {\n err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \n e);\n }\n } catch (SVNException e) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, e);\n close();\n throw e;\n } finally {\n finishResponse(request); \n }\n if (err != null) {\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(false, err);\n }\n close();\n break;\n }\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(true, err);\n }\n if (keyManager != null) {\n\t myKeyManager = keyManager;\n\t myTrustManager = trustManager;\n\t keyManager.acknowledgeAndClearAuthentication(null);\n }\n if (myLastStatus.getCode() == HttpURLConnection.HTTP_FORBIDDEN) {\n if (httpAuth != null && authManager != null) {\n BasicAuthenticationManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth, myRepository.getLocation(), authManager);\n }\n myLastValidAuth = null;\n close();\n err = request.getErrorMessage();\n } else if (myIsProxied && myLastStatus.getCode() == HttpURLConnection.HTTP_PROXY_AUTH) {\n Collection proxyAuthHeaders = request.getResponseHeader().getHeaderValues(HTTPHeader.PROXY_AUTHENTICATE_HEADER);\n Collection authTypes = null;\n if (authManager != null && authManager instanceof DefaultSVNAuthenticationManager) {\n DefaultSVNAuthenticationManager defaultAuthManager = (DefaultSVNAuthenticationManager) authManager;\n authTypes = defaultAuthManager.getAuthTypes(myRepository.getLocation());\n }\n try {\n myProxyAuthentication = HTTPAuthentication.parseAuthParameters(proxyAuthHeaders, myProxyAuthentication, myCharset, authTypes, null, myRequestCount); \n } catch (SVNException svne) {\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, svne);\n err = svne.getErrorMessage(); \n break;\n }\n if (myProxyAuthentication instanceof HTTPNTLMAuthentication) {\n ntlmProxyAuthIsRequired = true;\n HTTPNTLMAuthentication ntlmProxyAuth = (HTTPNTLMAuthentication)myProxyAuthentication;\n if (ntlmProxyAuth.isInType3State()) {\n continue;\n }\n }\n err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, \"HTTP proxy authorization failed\");\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(false, err);\n }\n close();\n break;\n } else if (myLastStatus.getCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {\n authAttempts++;\n Collection authHeaderValues = request.getResponseHeader().getHeaderValues(HTTPHeader.AUTHENTICATE_HEADER);\n if (authHeaderValues == null || authHeaderValues.size() == 0) {\n err = request.getErrorMessage();\n myLastStatus.setError(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, err.getMessageTemplate(), err.getRelatedObjects()));\n if (\"LOCK\".equalsIgnoreCase(method)) {\n myLastStatus.getError().setChildErrorMessage(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,\n \"Probably you are trying to lock file in repository that only allows anonymous access\"));\n }\n SVNErrorManager.error(myLastStatus.getError(), SVNLogType.NETWORK);\n return myLastStatus;\n }\n boolean skip = false;\n isAuthForced = authManager != null ? authManager.isAuthenticationForced() : false;\n if (isAuthForced) {\n if (httpAuth != null && myChallengeCredentials != null && !HTTPAuthentication.isSchemeSupportedByServer(myChallengeCredentials.getAuthenticationScheme(), authHeaderValues)) {\n skip = true;\n }\n }\n Collection authTypes = null;\n if (authManager != null && authManager instanceof DefaultSVNAuthenticationManager) {\n DefaultSVNAuthenticationManager defaultAuthManager = (DefaultSVNAuthenticationManager) authManager;\n authTypes = defaultAuthManager.getAuthTypes(myRepository.getLocation());\n }\n try {\n myChallengeCredentials = HTTPAuthentication.parseAuthParameters(authHeaderValues, myChallengeCredentials, myCharset, authTypes, authManager, myRequestCount); \n } catch (SVNException svne) {\n err = svne.getErrorMessage(); \n break;\n }\n myChallengeCredentials.setChallengeParameter(\"method\", method);\n myChallengeCredentials.setChallengeParameter(\"uri\", HTTPParser.getCanonicalPath(path, null).toString());\n if (skip) {\n close();\n continue;\n }\n HTTPNTLMAuthentication ntlmAuth = null;\n HTTPNegotiateAuthentication negoAuth = null;\n if (myChallengeCredentials instanceof HTTPNTLMAuthentication) {\n ntlmAuthIsRequired = true;\n ntlmAuth = (HTTPNTLMAuthentication)myChallengeCredentials;\n if (ntlmAuth.isInType3State()) {\n continue;\n }\n } else if (myChallengeCredentials instanceof HTTPDigestAuthentication) {\n if (myLastValidAuth != null) {\n myLastValidAuth = null;\n continue;\n }\n } else if (myChallengeCredentials instanceof HTTPNegotiateAuthentication) {\n negoAuthIsRequired = true;\n negoAuth = (HTTPNegotiateAuthentication)myChallengeCredentials;\n if (negoAuth.isStarted()) {\n continue;\n }\n }\n myLastValidAuth = null;\n if (ntlmAuth != null && ntlmAuth.isNative() && authAttempts == 1) {\n continue;\n }\n if (negoAuth != null && !negoAuth.needsLogin()) {\n continue;\n }\n if (authManager == null) {\n err = request.getErrorMessage();\n break;\n }\n realm = myChallengeCredentials.getChallengeParameter(\"realm\");\n realm = realm == null ? \"\" : \" \" + realm;\n realm = \"<\" + myHost.getProtocol() + \"://\" + myHost.getHost() + \":\" + myHost.getPort() + \">\" + realm;\n if (httpAuth == null) {\n httpAuth = authManager.getFirstAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());\n } else if (authAttempts >= requestAttempts) {\n BasicAuthenticationManager.acknowledgeAuthentication(false, ISVNAuthenticationManager.PASSWORD, realm, request.getErrorMessage(), httpAuth, myRepository.getLocation(), authManager);\n httpAuth = authManager.getNextAuthentication(ISVNAuthenticationManager.PASSWORD, realm, myRepository.getLocation());\n }\n if (httpAuth == null) {\n err = SVNErrorMessage.create(SVNErrorCode.CANCELLED, \"HTTP authorization cancelled\");\n break;\n } \n if (httpAuth != null) {\n myChallengeCredentials.setCredentials((SVNPasswordAuthentication) httpAuth);\n }\n continue;\n } else if (myLastStatus.getCode() == HttpURLConnection.HTTP_MOVED_PERM || myLastStatus.getCode() == HttpURLConnection.HTTP_MOVED_TEMP) {\n String newLocation = request.getResponseHeader().getFirstHeaderValue(HTTPHeader.LOCATION_HEADER);\n if (newLocation == null) {\n err = request.getErrorMessage();\n break;\n }\n int hostIndex = newLocation.indexOf(\"://\");\n if (hostIndex > 0) {\n hostIndex += 3;\n hostIndex = newLocation.indexOf(\"/\", hostIndex);\n }\n if (hostIndex > 0 && hostIndex < newLocation.length()) {\n String newPath = newLocation.substring(hostIndex);\n if (newPath.endsWith(\"/\") &&\n !newPath.endsWith(\"//\") && !path.endsWith(\"/\") &&\n newPath.substring(0, newPath.length() - 1).equals(path)) {\n path += \"//\";\n continue;\n }\n }\n err = request.getErrorMessage();\n close();\n } else if (request.getErrorMessage() != null) {\n err = request.getErrorMessage();\n } else {\n ntlmProxyAuthIsRequired = false;\n ntlmAuthIsRequired = false;\n negoAuthIsRequired = false;\n }\n if (err != null) {\n break;\n }\n if (myIsProxied) {\n if (proxyManager != null) {\n proxyManager.acknowledgeProxyContext(true, null);\n }\n }\n if (httpAuth != null && realm != null && authManager != null) {\n BasicAuthenticationManager.acknowledgeAuthentication(true, ISVNAuthenticationManager.PASSWORD, realm, null, httpAuth, myRepository.getLocation(), authManager);\n }\n\t if (trustManager != null && authManager != null) {\n\t\t authManager.acknowledgeTrustManager(trustManager);\n\t }\n if (httpAuth != null) {\n myLastValidAuth = httpAuth;\n }\n if (authManager instanceof ISVNAuthenticationManagerExt) {\n ((ISVNAuthenticationManagerExt)authManager).acknowledgeConnectionSuccessful(myRepository.getLocation());\n }\n myLastStatus.setHeader(request.getResponseHeader());\n return myLastStatus;\n }\n close();\n if (err != null && err.getErrorCode().getCategory() != SVNErrorCode.RA_DAV_CATEGORY &&\n err.getErrorCode() != SVNErrorCode.UNSUPPORTED_FEATURE) {\n SVNErrorManager.error(err, SVNLogType.NETWORK);\n }\n myRepository.getDebugLog().logFine(SVNLogType.NETWORK, new Exception(err.getMessage()));\n SVNErrorMessage err2 = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, \"{0} request failed on ''{1}''\", new Object[] {method, path}, err.getType(), err.getCause());\n SVNErrorManager.error(err, err2, SVNLogType.NETWORK);\n return null;\n }\n"} {"input": " public Packet decodePacket(RTMP rtmp, ByteBuffer in) {\n\t\tfinal int remaining = in.remaining();\n\t\tif (remaining < 1) {\n\t\t\trtmp.bufferDecoding(1);\n\t\t\treturn null;\n\t\t}\n\t\tfinal int position = in.position();\n\t\tfinal byte headerByte = in.get();\n\t\tfinal byte channelId = RTMPUtils.decodeChannelId(headerByte);\n\t\tif (channelId < 0) {\n\t\t\tthrow new ProtocolException(\"Bad channel id: \" + channelId);\n\t\t}\n\t\tfinal byte headerSize = RTMPUtils.decodeHeaderSize(headerByte);\n\t\tint headerLength = RTMPUtils.getHeaderLength(headerSize);\n\t\tif (headerLength > remaining) {\n\t\t\tif (log.isDebugEnabled()) {\n\t\t\t\tlog.debug(\"Header too small, buffering. remaining: \" + remaining);\n\t\t\t}\n\t\t\tin.position(position);\n\t\t\trtmp.bufferDecoding(headerLength);\n\t\t\treturn null;\n\t\t}\n\t\tin.position(position);\n\t\tfinal Header header = decodeHeader(in, rtmp\n\t\t\t\t.getLastReadHeader(channelId));\n\t\tif (header == null) {\n\t\t\tthrow new ProtocolException(\"Header is null, check for error\");\n\t\t}\n\t\trtmp.setLastReadHeader(channelId, header);\n\t\tPacket packet = rtmp.getLastReadPacket(channelId);\n\t\tif (packet == null) {\n\t\t\tpacket = new Packet(header);\n\t\t\trtmp.setLastReadPacket(channelId, packet);\n\t\t}\n\t\tfinal ByteBuffer buf = packet.getData();\n\t\tfinal int addSize = (header.getTimer() == 0xffffff ? 4 : 0);\n\t\tfinal int readRemaining = header.getSize() + addSize - buf.position();\n\t\tfinal int chunkSize = rtmp.getReadChunkSize();\n\t\tfinal int readAmount = (readRemaining > chunkSize) ? chunkSize\n\t\t\t\t: readRemaining;\n\t\tif (in.remaining() < readAmount) {\n\t\t\tif (log.isDebugEnabled()) {\n\t\t\t\tlog.debug(\"Chunk too small, buffering (\" + in.remaining() + ','\n\t\t\t\t\t\t+ readAmount);\n\t\t\t}\n\t\t\tin.position(position);\n\t\t\trtmp.bufferDecoding(headerSize + readAmount);\n\t\t\treturn null;\n\t\t}\n\t\tBufferUtils.put(buf, in, readAmount);\n\t\tif (buf.position() < header.getSize() + addSize) {\n\t\t\trtmp.continueDecoding();\n\t\t\treturn null;\n\t\t}\n\t\tbuf.flip();\n\t\tfinal IRTMPEvent message = decodeMessage(rtmp, packet.getHeader(), buf);\n\t\tpacket.setMessage(message);\n\t\tif (message instanceof ChunkSize) {\n\t\t\tChunkSize chunkSizeMsg = (ChunkSize) message;\n\t\t\trtmp.setReadChunkSize(chunkSizeMsg.getSize());\n\t\t}\n\t\trtmp.setLastReadPacket(channelId, null);\n\t\treturn packet;\n\t}\n", "output": " public Packet decodePacket(RTMP rtmp, ByteBuffer in) {\n\t\tfinal int remaining = in.remaining();\n\t\tif (remaining < 1) {\n\t\t\trtmp.bufferDecoding(1);\n\t\t\treturn null;\n\t\t}\n\t\tfinal int position = in.position();\n\t\tfinal byte headerByte = in.get();\n\t\tfinal byte channelId = RTMPUtils.decodeChannelId(headerByte);\n\t\tif (channelId < 0) {\n\t\t\tthrow new ProtocolException(\"Bad channel id: \" + channelId);\n\t\t}\n\t\tint headerLength = RTMPUtils.getHeaderLength(RTMPUtils.decodeHeaderSize(headerByte));\n\t\tif (headerLength > remaining) {\n\t\t\tif (log.isDebugEnabled()) {\n\t\t\t\tlog.debug(\"Header too small, buffering. remaining: \" + remaining);\n\t\t\t}\n\t\t\tin.position(position);\n\t\t\trtmp.bufferDecoding(headerLength);\n\t\t\treturn null;\n\t\t}\n\t\tin.position(position);\n\t\tfinal Header header = decodeHeader(in, rtmp\n\t\t\t\t.getLastReadHeader(channelId));\n\t\tif (header == null) {\n\t\t\tthrow new ProtocolException(\"Header is null, check for error\");\n\t\t}\n\t\trtmp.setLastReadHeader(channelId, header);\n\t\tPacket packet = rtmp.getLastReadPacket(channelId);\n\t\tif (packet == null) {\n\t\t\tpacket = new Packet(header);\n\t\t\trtmp.setLastReadPacket(channelId, packet);\n\t\t}\n\t\tfinal ByteBuffer buf = packet.getData();\n\t\tfinal int addSize = (header.getTimer() == 0xffffff ? 4 : 0);\n\t\tfinal int readRemaining = header.getSize() + addSize - buf.position();\n\t\tfinal int chunkSize = rtmp.getReadChunkSize();\n\t\tfinal int readAmount = (readRemaining > chunkSize) ? chunkSize\n\t\t\t\t: readRemaining;\n\t\tif (in.remaining() < readAmount) {\n\t\t\tif (log.isDebugEnabled()) {\n\t\t\t\tlog.debug(\"Chunk too small, buffering (\" + in.remaining() + ','\n\t\t\t\t\t\t+ readAmount);\n\t\t\t}\n\t\t\tin.position(position);\n\t\t\trtmp.bufferDecoding(headerLength + readAmount);\n\t\t\treturn null;\n\t\t}\n\t\tBufferUtils.put(buf, in, readAmount);\n\t\tif (buf.position() < header.getSize() + addSize) {\n\t\t\trtmp.continueDecoding();\n\t\t\treturn null;\n\t\t}\n\t\tbuf.flip();\n\t\tfinal IRTMPEvent message = decodeMessage(rtmp, packet.getHeader(), buf);\n\t\tpacket.setMessage(message);\n\t\tif (message instanceof ChunkSize) {\n\t\t\tChunkSize chunkSizeMsg = (ChunkSize) message;\n\t\t\trtmp.setReadChunkSize(chunkSizeMsg.getSize());\n\t\t}\n\t\trtmp.setLastReadPacket(channelId, null);\n\t\treturn packet;\n\t}\n"} {"input": "\tpublic ConfigManager(Plugin plugin) {\n\t\tthis.plugin = plugin;\n\t\tFileConfiguration config = plugin.getConfig();\n\t\tconfig.options().copyDefaults(true);\n\t\tplugin.saveDefaultConfig();\n\t\ttry {\n\t\t\tConfigurationSection dreamSection = config.getConfigurationSection(\"dream\");\n\t\t\tdreamWorldName = dreamSection.getString(\"world name\");\n\t\t\tnoAnimalSpawning = dreamSection.getBoolean(\"no animal spawning\");\n\t\t\tnoMonsterSpawning = dreamSection.getBoolean(\"no monster spawning\");\n\t\t\tdreamChance = dreamSection.getInt(\"chance\");\n\t\t\tminDurationSeconds = dreamSection.getInt(\"min duration in seconds\");\n\t\t\tmaxDurationSeconds = dreamSection.getInt(\"max duration in seconds\");\n\t\t\tspawnRandomly = dreamSection.getBoolean(\"spawn randomly each time\");\n\t\t\tdreamSpawns = SoftLocation.getFromStringList(dreamSection.getStringList(\"random spawns\"));\n\t\t\tapplyInitialGamemode = dreamSection.getBoolean(\"gamemode.apply\");\n\t\t\tinitialGamemode = GameMode.getByValue(dreamSection.getInt(\"gamemode.initial gamemode\"));\n\t\t\tapplyInitialHealth = dreamSection.getBoolean(\"health.apply\");\n\t\t\tinitialHealth = dreamSection.getInt(\"health.initial health\");\n\t\t\tapplyInitialHunger = dreamSection.getBoolean(\"hunger.apply\");\n\t\t\tinitialHunger = dreamSection.getInt(\"hunger.initial hunger\");\n\t\t\tapplyInitialPotionEffects = dreamSection.getBoolean(\"potion effects.apply\");\n\t\t\tinitialPotionEffects = new ArrayList();\n\t\t\tConfigurationSection potionsSection = dreamSection.getConfigurationSection(\"potion effects.initial potion effects\");\n\t\t\tif (potionsSection != null) {\n\t\t\t\tfor (String type : potionsSection.getKeys(false)) {\n\t\t\t\t\tConfigurationSection potionSection = potionsSection.getConfigurationSection(type);\n\t\t\t\t\tif (potionSection == null) continue;\n\t\t\t\t\tPotionEffectType potionType = PotionEffectType.getByName(type);\n\t\t\t\t\tif (potionType == null) {\n\t\t\t\t\t\tplugin.getLogger().warning(\"Invalid potion effect type '\" + type + \"'. Skipping this effect now. You can find a list of all possible PotionEffectTypes by googling 'bukkit PotionEffectType'.\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tinitialPotionEffects.add(new PotionEffect(potionType, potionSection.getInt(\"duration\"), potionSection.getInt(\"level\", 1)));\n\t\t\t\t}\n\t\t\t}\n\t\t\tclearAndRestorePlayer = dreamSection.getBoolean(\"clear and restore player\");\n\t\t\tpurgeAfterMinutes = dreamSection.getInt(\"purge saved dream data after x minutes\");\n\t\t\tignoreIfRemainingTimeIsLowerThan = dreamSection.getInt(\"ignore if remaining seconds is lower than\");\n\t\t\tConfigurationSection fakeTimeSection = dreamSection.getConfigurationSection(\"fake client time\");\n\t\t\tfakeTimeEnabled = fakeTimeSection.getBoolean(\"enabled\") ;\n\t\t\tfakeTime = fakeTimeSection.getInt(\"time (in ticks)\");\n\t\t\tfakeTimeRandomBounds = fakeTimeSection.getInt(\"random bounds\");\n\t\t\tfakeTimeFixed = fakeTimeSection.getBoolean(\"fixed time\");\n\t\t\tfakeRain = dreamSection.getBoolean(\"fake client weather.raining\");\n\t\t\tConfigurationSection disabledSection = dreamSection.getConfigurationSection(\"disabled\");\n\t\t\thungerDisabled = disabledSection.getBoolean(\"hunger\");\n\t\t\tfallDamageDisabled = disabledSection.getBoolean(\"fall damage\");\n\t\t entityDamageDisabled = disabledSection.getBoolean(\"entity damage\");\n\t\t allDamageDisabled = disabledSection.getBoolean(\"all damage\");\n\t\t\tweatherDisabled = disabledSection.getBoolean(\"weather\");\n\t\t\titemDroppingDisabled = disabledSection.getBoolean(\"item dropping\");\n\t\t\titemPickupDisabled = disabledSection.getBoolean(\"item pickup\");\n\t\t\tblockPlacingDisabled = disabledSection.getBoolean(\"block placing\");\n\t\t\tblockBreakingDisabled = disabledSection.getBoolean(\"block breaking\");\n\t\t\tallowedCommands = dreamSection.getStringList(\"allowed commands\");\n\t\t\twasConfigValid = true;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\twasConfigValid = false;\n\t\t}\n\t}\n", "output": "\tpublic ConfigManager(Plugin plugin) {\n\t\tthis.plugin = plugin;\n\t\tplugin.saveDefaultConfig();\n\t\tFileConfiguration config = plugin.getConfig();\n\t\tconfig.options().copyDefaults(true);\n\t\ttry {\n\t\t\tConfigurationSection dreamSection = config.getConfigurationSection(\"dream\");\n\t\t\tdreamWorldName = dreamSection.getString(\"world name\");\n\t\t\tnoAnimalSpawning = dreamSection.getBoolean(\"no animal spawning\");\n\t\t\tnoMonsterSpawning = dreamSection.getBoolean(\"no monster spawning\");\n\t\t\tdreamChance = dreamSection.getInt(\"chance\");\n\t\t\tminDurationSeconds = dreamSection.getInt(\"min duration in seconds\");\n\t\t\tmaxDurationSeconds = dreamSection.getInt(\"max duration in seconds\");\n\t\t\tspawnRandomly = dreamSection.getBoolean(\"spawn randomly each time\");\n\t\t\tdreamSpawns = SoftLocation.getFromStringList(dreamSection.getStringList(\"random spawns\"));\n\t\t\tapplyInitialGamemode = dreamSection.getBoolean(\"gamemode.apply\");\n\t\t\tinitialGamemode = GameMode.getByValue(dreamSection.getInt(\"gamemode.initial gamemode\"));\n\t\t\tapplyInitialHealth = dreamSection.getBoolean(\"health.apply\");\n\t\t\tinitialHealth = dreamSection.getInt(\"health.initial health\");\n\t\t\tapplyInitialHunger = dreamSection.getBoolean(\"hunger.apply\");\n\t\t\tinitialHunger = dreamSection.getInt(\"hunger.initial hunger\");\n\t\t\tapplyInitialPotionEffects = dreamSection.getBoolean(\"potion effects.apply\");\n\t\t\tinitialPotionEffects = new ArrayList();\n\t\t\tConfigurationSection potionsSection = dreamSection.getConfigurationSection(\"potion effects.initial potion effects\");\n\t\t\tif (potionsSection != null) {\n\t\t\t\tfor (String type : potionsSection.getKeys(false)) {\n\t\t\t\t\tConfigurationSection potionSection = potionsSection.getConfigurationSection(type);\n\t\t\t\t\tif (potionSection == null) continue;\n\t\t\t\t\tPotionEffectType potionType = PotionEffectType.getByName(type);\n\t\t\t\t\tif (potionType == null) {\n\t\t\t\t\t\tplugin.getLogger().warning(\"Invalid potion effect type '\" + type + \"'. Skipping this effect now. You can find a list of all possible PotionEffectTypes by googling 'bukkit PotionEffectType'.\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tinitialPotionEffects.add(new PotionEffect(potionType, potionSection.getInt(\"duration\"), potionSection.getInt(\"level\")));\n\t\t\t\t}\n\t\t\t}\n\t\t\tclearAndRestorePlayer = dreamSection.getBoolean(\"clear and restore player\");\n\t\t\tpurgeAfterMinutes = dreamSection.getInt(\"purge saved dream data after x minutes\");\n\t\t\tignoreIfRemainingTimeIsLowerThan = dreamSection.getInt(\"ignore if remaining seconds is lower than\");\n\t\t\tConfigurationSection fakeTimeSection = dreamSection.getConfigurationSection(\"fake client time\");\n\t\t\tfakeTimeEnabled = fakeTimeSection.getBoolean(\"enabled\") ;\n\t\t\tfakeTime = fakeTimeSection.getInt(\"time (in ticks)\");\n\t\t\tfakeTimeRandomBounds = fakeTimeSection.getInt(\"random bounds\");\n\t\t\tfakeTimeFixed = fakeTimeSection.getBoolean(\"fixed time\");\n\t\t\tfakeRain = dreamSection.getBoolean(\"fake client weather.raining\");\n\t\t\tConfigurationSection disabledSection = dreamSection.getConfigurationSection(\"disabled\");\n\t\t\thungerDisabled = disabledSection.getBoolean(\"hunger\");\n\t\t\tfallDamageDisabled = disabledSection.getBoolean(\"fall damage\");\n\t\t entityDamageDisabled = disabledSection.getBoolean(\"entity damage\");\n\t\t allDamageDisabled = disabledSection.getBoolean(\"all damage\");\n\t\t\tweatherDisabled = disabledSection.getBoolean(\"weather\");\n\t\t\titemDroppingDisabled = disabledSection.getBoolean(\"item dropping\");\n\t\t\titemPickupDisabled = disabledSection.getBoolean(\"item pickup\");\n\t\t\tblockPlacingDisabled = disabledSection.getBoolean(\"block placing\");\n\t\t\tblockBreakingDisabled = disabledSection.getBoolean(\"block breaking\");\n\t\t\tallowedCommands = dreamSection.getStringList(\"allowed commands\");\n\t\t\twasConfigValid = true;\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\twasConfigValid = false;\n\t\t}\n\t}\n"} {"input": " public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {\n try {\n FilePath[] files = build.getProject().getWorkspace().list(\"test-result/*\");\n for (FilePath filePath : files) {\n filePath.delete();\n }\n } catch (Exception e) {\n e.printStackTrace();\n return false;\n }\n Map exitcodes = new HashMap();\n String playpath = null;\n if(play_path != null && play_path.length() > 0) {\n playpath = play_path;\n } else if(getDescriptor().path()!= null){\n playpath = getDescriptor().path();\n }else{\n listener.getLogger().println(\"play path is null\");\n return false;\n }\n listener.getLogger().println(\"play path is \"+playpath);\n FilePath workDir = build.getWorkspace();\n String application_path = ((PlayAutoTestJobProperty)build.getProject().getProperty(PlayAutoTestJobProperty.class)).getApplication_path();\n if (application_path!= null && application_path.length() > 0) {\n workDir = build.getWorkspace().child(application_path);\n }\n try {\n for(String play_cmd : this.play_cmds){\n if(play_cmd!=null && play_cmd.length()==0) continue;\n listener.getLogger().println(\"Substituting job parameters from \" + play_cmd);\n ParametersAction param = build.getAction(hudson.model.ParametersAction.class);\n List values = param.getParameters();\n if (values != null) {\n for (ParameterValue value : values) {\n String v = value.createVariableResolver(build).resolve(value.getName());\n play_cmd = play_cmd.replace(\"${\" + value.getName() + \"}\", v);\n }\n }\n String[] cmds= play_cmd.split(\" \",2);\n String cmd = playpath + \" \" + cmds[0] +\" \"+workDir.toString()+\" \"+(cmds.length>=2? cmds[1]:\"\");\n listener.getLogger().println(\"Executing \" + cmd);\n Proc proc = launcher.launch(cmd, new String[0],listener.getLogger(),workDir);\n int exitcode = proc.join();\n exitcodes.put(play_cmd, (exitcode==0? \"Done\":\"Fail\"));\n if(exitcode!=0) {\n listener.getLogger().println(\"****************************************************\");\n listener.getLogger().println(\"* ERROR!!! while executing \"+play_cmd);\n listener.getLogger().println(\"****************************************************\");\n return false;\n }\n if(\"auto-test\".equalsIgnoreCase(play_cmd)){\n if(! new File(workDir.toString()+\"/test-result/result.passed\").exists()){\n build.setResult(Result.UNSTABLE);\n }\n }\n }\n listener.getLogger().println(\"Each commands' results:\");\n for(Map.Entry rec : exitcodes.entrySet()){\n listener.getLogger().println(\" \"+rec.getKey()+\": \"+rec.getValue());\n }\n return exitcodes.containsValue(\"Fail\")? false : true;\n } catch (Exception e) {\n e.printStackTrace();\n return false;\n }\n }\n", "output": " public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {\n try {\n FilePath[] files = build.getProject().getWorkspace().list(\"test-result/*\");\n for (FilePath filePath : files) {\n filePath.delete();\n }\n } catch (Exception e) {\n e.printStackTrace();\n return false;\n }\n Map exitcodes = new HashMap();\n String playpath = null;\n if(play_path != null && play_path.length() > 0) {\n playpath = play_path;\n } else if(getDescriptor().path()!= null){\n playpath = getDescriptor().path();\n }else{\n listener.getLogger().println(\"play path is null\");\n return false;\n }\n listener.getLogger().println(\"play path is \"+playpath);\n FilePath workDir = build.getWorkspace();\n String application_path = ((PlayAutoTestJobProperty)build.getProject().getProperty(PlayAutoTestJobProperty.class)).getApplication_path();\n if (application_path!= null && application_path.length() > 0) {\n workDir = build.getWorkspace().child(application_path);\n }\n try {\n for(String play_cmd : this.play_cmds){\n if(play_cmd!=null && play_cmd.length()==0) continue;\n listener.getLogger().println(\"Substituting job parameters from \" + play_cmd);\n ParametersAction param = build.getAction(hudson.model.ParametersAction.class);\n List values = param.getParameters();\n if (values != null) {\n for (ParameterValue value : values) {\n String v = value.createVariableResolver(build).resolve(value.getName());\n play_cmd = play_cmd.replace(\"${\" + value.getName() + \"}\", v);\n }\n }\n String[] cmds= play_cmd.split(\" \",2);\n String cmd = playpath + \" \" + cmds[0] +\" \\\"\"+workDir.toString()+\"\\\" \"+(cmds.length>=2? cmds[1]:\"\");\n listener.getLogger().println(\"Executing \" + cmd);\n Proc proc = launcher.launch(cmd, new String[0],listener.getLogger(),workDir);\n int exitcode = proc.join();\n exitcodes.put(play_cmd, (exitcode==0? \"Done\":\"Fail\"));\n if(exitcode!=0) {\n listener.getLogger().println(\"****************************************************\");\n listener.getLogger().println(\"* ERROR!!! while executing \"+play_cmd);\n listener.getLogger().println(\"****************************************************\");\n return false;\n }\n if(\"auto-test\".equalsIgnoreCase(play_cmd)){\n if(! new File(workDir.toString()+\"/test-result/result.passed\").exists()){\n build.setResult(Result.UNSTABLE);\n }\n }\n }\n listener.getLogger().println(\"Each commands' results:\");\n for(Map.Entry rec : exitcodes.entrySet()){\n listener.getLogger().println(\" \"+rec.getKey()+\": \"+rec.getValue());\n }\n return exitcodes.containsValue(\"Fail\")? false : true;\n } catch (Exception e) {\n e.printStackTrace();\n return false;\n }\n }\n"} {"input": "\tpublic void testSendReceive() throws Exception {\n\t\tString sendTxt;\n\t\tString expectTxt;\n\t\tInputStream in;\n\t\tsendTxt = \"This is my text\";\n\t\texpectTxt = sendTxt.length() + \"\\n\" + sendTxt;\n\t\tbyte[] result = new byte[sendTxt.length()];\n\t\tPipedInputStream pIn;\n\t\tPipedOutputStream pOut;\n\t\tpIn = new PipedInputStream();\n\t\tpOut = new PipedOutputStream(pIn);\n\t\tin = new BufferedInputStream(pIn,sendTxt.length());\n\t\tpOut.write(sendTxt.getBytes());\n\t\tfile1.receiveFrom(in,new NullProgressMonitor(),sendTxt.length(),false,false);\n\t\tin.close();\n\t\tpOut.close();\n\t\tresult = new byte[expectTxt.length()];\n\t\tpIn = new PipedInputStream();\n\t\tpOut = new PipedOutputStream(pIn);\n\t\tin = new BufferedInputStream(pIn,sendTxt.length());\n\t\tfile1.sendTo(pOut,new NullProgressMonitor(),false);\n\t\tin.read(result);\n\t\tin.close();\n\t\tpOut.close();\n\t\tassertEquals(new String(result),expectTxt);\t\n\t}\n", "output": "\tpublic void testSendReceive() throws Exception {\n\t\tString sendTxt;\n\t\tString expectTxt;\n\t\tInputStream in;\n\t\tsendTxt = \"This is my text\";\n\t\texpectTxt = sendTxt.length() + \"\\n\" + sendTxt;\n\t\tbyte[] result = new byte[sendTxt.length()];\n\t\tPipedInputStream pIn;\n\t\tPipedOutputStream pOut;\n\t\tpIn = new PipedInputStream();\n\t\tpOut = new PipedOutputStream(pIn);\n\t\tin = new BufferedInputStream(pIn,sendTxt.length());\n\t\tpOut.write(sendTxt.getBytes());\n\t\tfile1.receiveFrom(in,sendTxt.length(),false,false, new NullProgressMonitor());\n\t\tin.close();\n\t\tpOut.close();\n\t\tresult = new byte[expectTxt.length()];\n\t\tpIn = new PipedInputStream();\n\t\tpOut = new PipedOutputStream(pIn);\n\t\tin = new BufferedInputStream(pIn,sendTxt.length());\n\t\tfile1.sendTo(pOut,false, new NullProgressMonitor());\n\t\tin.read(result);\n\t\tin.close();\n\t\tpOut.close();\n\t\tassertEquals(new String(result),expectTxt);\t\n\t}\n"} {"input": "\tprotected String computeIdentifierPrefix(int offset) {\n\t\tfinal AbstractDocument document = (AbstractDocument) getSourceViewer().getDocument();\n\t\tif (offset <= 0 || offset > document.getLength()) {\n\t\t\treturn \"\"; \n\t\t}\n\t\ttry {\n\t\t\tITypedRegion partition = document.getPartition(getEditor().getPartitioning().getPartitioning(), offset, true);\n\t\t\tif (partition.getType() == IRDocumentPartitions.R_QUOTED_SYMBOL) {\n\t\t\t\toffset = partition.getOffset();\n\t\t\t}\n\t\t\tint goodStart = offset;\n\t\t\tSEARCH_START: while (offset > 0) {\n\t\t\t\tfinal char c = document.getChar(offset - 1);\n\t\t\t\tif (RTokens.isRobustSeparator(c, false)) {\n\t\t\t\t\tswitch (c) {\n\t\t\t\t\tcase ':':\n\t\t\t\t\tcase '$':\n\t\t\t\t\tcase '@':\n\t\t\t\t\t\toffset --;\n\t\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t\tcase ' ':\n\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\tif (offset >= 2) {\n\t\t\t\t\t\t\tfinal char c2 = document.getChar(offset - 2);\n\t\t\t\t\t\t\tif ((offset == getInvocationOffset()) ? \n\t\t\t\t\t\t\t\t\t!RTokens.isRobustSeparator(c, false) :\n\t\t\t\t\t\t\t\t\t(c2 == ':' && c2 == '$' && c2 == '@')) {\n\t\t\t\t\t\t\t\toffset -= 2;\n\t\t\t\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak SEARCH_START;\n\t\t\t\t\tcase '`':\n\t\t\t\t\t\tpartition = document.getPartition(getEditor().getPartitioning().getPartitioning(), offset, false);\n\t\t\t\t\t\tif (partition.getType() == IRDocumentPartitions.R_QUOTED_SYMBOL) {\n\t\t\t\t\t\t\toffset = goodStart = partition.getOffset();\n\t\t\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tbreak SEARCH_START;\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak SEARCH_START;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toffset --;\n\t\t\t\t\tgoodStart = offset;\n\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn document.get(offset, getInvocationOffset() - goodStart);\n\t\t}\n\t\tcatch (final BadLocationException e) {\n\t\t}\n\t\tcatch (final BadPartitioningException e) {\n\t\t}\n\t\treturn \"\"; \n\t}\n", "output": "\tprotected String computeIdentifierPrefix(int offset) {\n\t\tfinal AbstractDocument document = (AbstractDocument) getSourceViewer().getDocument();\n\t\tif (offset <= 0 || offset > document.getLength()) {\n\t\t\treturn \"\"; \n\t\t}\n\t\ttry {\n\t\t\tITypedRegion partition = document.getPartition(getEditor().getPartitioning().getPartitioning(), offset, true);\n\t\t\tif (partition.getType() == IRDocumentPartitions.R_QUOTED_SYMBOL) {\n\t\t\t\toffset = partition.getOffset();\n\t\t\t}\n\t\t\tint goodStart = offset;\n\t\t\tSEARCH_START: while (offset > 0) {\n\t\t\t\tfinal char c = document.getChar(offset - 1);\n\t\t\t\tif (RTokens.isRobustSeparator(c, false)) {\n\t\t\t\t\tswitch (c) {\n\t\t\t\t\tcase ':':\n\t\t\t\t\tcase '$':\n\t\t\t\t\tcase '@':\n\t\t\t\t\t\toffset --;\n\t\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t\tcase ' ':\n\t\t\t\t\tcase '\\t':\n\t\t\t\t\t\tif (offset >= 2) {\n\t\t\t\t\t\t\tfinal char c2 = document.getChar(offset - 2);\n\t\t\t\t\t\t\tif ((offset == getInvocationOffset()) ? \n\t\t\t\t\t\t\t\t\t!RTokens.isRobustSeparator(c, false) :\n\t\t\t\t\t\t\t\t\t(c2 == ':' && c2 == '$' && c2 == '@')) {\n\t\t\t\t\t\t\t\toffset -= 2;\n\t\t\t\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak SEARCH_START;\n\t\t\t\t\tcase '`':\n\t\t\t\t\t\tpartition = document.getPartition(getEditor().getPartitioning().getPartitioning(), offset - 1, false);\n\t\t\t\t\t\tif (partition.getType() == IRDocumentPartitions.R_QUOTED_SYMBOL) {\n\t\t\t\t\t\t\toffset = goodStart = partition.getOffset();\n\t\t\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tbreak SEARCH_START;\n\t\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tbreak SEARCH_START;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\toffset --;\n\t\t\t\t\tgoodStart = offset;\n\t\t\t\t\tcontinue SEARCH_START;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn document.get(offset, getInvocationOffset() - goodStart);\n\t\t}\n\t\tcatch (final BadLocationException e) {\n\t\t}\n\t\tcatch (final BadPartitioningException e) {\n\t\t}\n\t\treturn \"\"; \n\t}\n"} {"input": "\tpublic void initComponentActivity(Body body) {\n\t\tif (!init) {\n\t\t\tthis.logger = LoggerFactory.getLogger(this.getClass());\n\t\t\tlogger.info(\"Initialising {} component.\", this.getClass().getSimpleName());\n\t\t\teleGenerator = new EleGeneratorForConstructQuery();\n\t\t\ttry {\n\t\t\t\tString address = Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.endpoint\");\n\t\t\t\tsoapServer = Endpoint.publish(address, this);\n\t\t\t\tlogger.info(\"QueryDispatch SOAP service started at {}.\", address);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch SOAP Service\", e);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\trestServer = new PlayPlatformservicesRest(this);\n\t \tlogger.info(String.format(\"QueryDispatch REST service started with WADL available at \"\n\t \t\t\t+ \"%sapplication.wadl\\n\", PlayPlatformservicesRest.BASE_URI));\n\t\t\t} catch (ProcessingException e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch REST Service\", e);\n\t\t\t}\n\t\t\tthis.init = true;\n\t\t}\n\t}\n", "output": "\tpublic void initComponentActivity(Body body) {\n\t\tif (!init) {\n\t\t\tthis.logger = LoggerFactory.getLogger(this.getClass());\n\t\t\tlogger.info(\"Initialising {} component.\", this.getClass().getSimpleName());\n\t\t\teleGenerator = new EleGeneratorForConstructQuery();\n\t\t\ttry {\n\t\t\t\tString address = Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.endpoint\");\n\t\t\t\tsoapServer = Endpoint.publish(address, this);\n\t\t\t\tlogger.info(\"QueryDispatch SOAP service started at {}.\", address);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch SOAP Service\", e);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\trestServer = new PlayPlatformservicesRest(this);\n\t \tlogger.info(String.format(\"QueryDispatch REST service started at %s with WADL remotely available at \"\n\t \t\t\t+ \"%sapplication.wadl\\n\", PlayPlatformservicesRest.BASE_URI, Constants.getProperties().getProperty(\"platfomservices.querydispatchapi.rest\")));\n\t\t\t} catch (ProcessingException e) {\n\t\t\t\tlogger.error(\"Exception while publishing QueryDispatch REST Service\", e);\n\t\t\t}\n\t\t\tthis.init = true;\n\t\t}\n\t}\n"} {"input": "\tpublic IStatus validate(IValidationContext ctx) {\n\t\tEObject eObj = ctx.getTarget();\n\t\tif (eObj instanceof Task) {\n\t\t\tTask ta = (Task) eObj;\n\t\t\tif (ta.getExtensionValues() != null && ta.getExtensionValues().size() > 0) {\n\t\t\t\tboolean foundDistributionType = false;\n\t\t\t\tString distributionTypeValue = \"\";\n\t\t\t\tboolean foundDuration = false;\n\t\t\t\tboolean foundTimeUnits = false;\n\t\t\t\tboolean foundRange = false;\n\t\t\t\tboolean foundStandardDeviation = false;\n\t\t\t\tfor (ExtensionAttributeValue extattrval : ta.getExtensionValues()) {\n\t\t\t\t\tFeatureMap extensionElements = extattrval.getValue();\n\t\t\t\t\tif (extensionElements == null) {\n\t\t\t\t\t continue;\n\t\t\t\t\t}\n\t\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\t\tList metadataTypeExtensions = (List) extensionElements.get(\n\t\t\t\t\t\t\tDroolsPackage.Literals.DOCUMENT_ROOT__METADATA, true);\n\t\t\t\t\tif (metadataTypeExtensions != null && metadataTypeExtensions.size() > 0) {\n\t\t\t\t\t\tMetadataType metaType = metadataTypeExtensions.get(0);\n\t\t\t\t\t\tfor (Object metaEntryObj : metaType.getMetaentry()) {\n\t\t\t\t\t\t\tMetaentryType entry = (MetaentryType) metaEntryObj;\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"costpertimeunit\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Cost per Time Unit value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"distributiontype\")) {\n\t\t\t\t\t\t\t\tfoundDistributionType = true;\n\t\t\t\t\t\t\t\tdistributionTypeValue = entry.getValue();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"duration\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Duration value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfoundDuration = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"timeunit\")) {\n\t\t\t\t\t\t\t\tfoundTimeUnits = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"workinghours\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Working Hours value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"range\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Range value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfoundRange = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"standarddeviation\")) {\n\t\t\t\t\t\t\t\tfoundStandardDeviation = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!foundDistributionType) {\n\t\t\t\t\tctx.createFailureStatus(\"Task has no distribution type defined\");\n\t\t\t\t}\n\t\t\t\tif (!foundDuration) {\n\t\t\t\t\tctx.createFailureStatus(\"Task has no duration defined\");\n\t\t\t\t}\n\t\t\t\tif (!foundTimeUnits) {\n\t\t\t\t\tctx.createFailureStatus(\"Task has no Time Units defined\");\n\t\t\t\t}\n\t\t\t\tif (foundDistributionType) {\n\t\t\t\t\tif ((distributionTypeValue.equals(\"random\") || distributionTypeValue.equals(\"uniform\"))\n\t\t\t\t\t\t\t&& !foundRange) {\n\t\t\t\t\t\tctx.createFailureStatus(\"Task has no Range defined\");\n\t\t\t\t\t}\n\t\t\t\t\tif (distributionTypeValue.equals(\"normal\") && !foundStandardDeviation) {\n\t\t\t\t\t\tctx.createFailureStatus(\"Task has no Standard Deviation defined\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ctx.createSuccessStatus();\n\t}\n", "output": "\tpublic IStatus validate(IValidationContext ctx) {\n\t\tEObject eObj = ctx.getTarget();\n\t\tif (eObj instanceof Task) {\n\t\t\tTask ta = (Task) eObj;\n\t\t\tif (ta.getExtensionValues() != null && ta.getExtensionValues().size() > 0) {\n\t\t\t\tboolean foundDistributionType = false;\n\t\t\t\tString distributionTypeValue = \"\";\n\t\t\t\tboolean foundDuration = false;\n\t\t\t\tboolean foundTimeUnits = false;\n\t\t\t\tboolean foundRange = false;\n\t\t\t\tboolean foundStandardDeviation = false;\n\t\t\t\tfor (ExtensionAttributeValue extattrval : ta.getExtensionValues()) {\n\t\t\t\t\tFeatureMap extensionElements = extattrval.getValue();\n\t\t\t\t\tif (extensionElements == null) {\n\t\t\t\t\t continue;\n\t\t\t\t\t}\n\t\t\t\t\t@SuppressWarnings(\"unchecked\")\n\t\t\t\t\tList metadataTypeExtensions = null;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmetadataTypeExtensions = (List) extensionElements.get(\n\t\t\t\t\t\t\tDroolsPackage.Literals.DOCUMENT_ROOT__METADATA, true);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (metadataTypeExtensions != null && metadataTypeExtensions.size() > 0) {\n\t\t\t\t\t\tMetadataType metaType = metadataTypeExtensions.get(0);\n\t\t\t\t\t\tfor (Object metaEntryObj : metaType.getMetaentry()) {\n\t\t\t\t\t\t\tMetaentryType entry = (MetaentryType) metaEntryObj;\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"costpertimeunit\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Cost per Time Unit value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"distributiontype\")) {\n\t\t\t\t\t\t\t\tfoundDistributionType = true;\n\t\t\t\t\t\t\t\tdistributionTypeValue = entry.getValue();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"duration\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Duration value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfoundDuration = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"timeunit\")) {\n\t\t\t\t\t\t\t\tfoundTimeUnits = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"workinghours\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Working Hours value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"range\")) {\n\t\t\t\t\t\t\t\tFloat f = new Float(entry.getValue());\n\t\t\t\t\t\t\t\tif (f.floatValue() < 0) {\n\t\t\t\t\t\t\t\t\tctx.createFailureStatus(\"Range value must be positive\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfoundRange = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (entry.getName() != null && entry.getName().equals(\"standarddeviation\")) {\n\t\t\t\t\t\t\t\tfoundStandardDeviation = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!foundDistributionType) {\n\t\t\t\t\tctx.createFailureStatus(\"Task has no distribution type defined\");\n\t\t\t\t}\n\t\t\t\tif (!foundDuration) {\n\t\t\t\t\tctx.createFailureStatus(\"Task has no duration defined\");\n\t\t\t\t}\n\t\t\t\tif (!foundTimeUnits) {\n\t\t\t\t\tctx.createFailureStatus(\"Task has no Time Units defined\");\n\t\t\t\t}\n\t\t\t\tif (foundDistributionType) {\n\t\t\t\t\tif ((distributionTypeValue.equals(\"random\") || distributionTypeValue.equals(\"uniform\"))\n\t\t\t\t\t\t\t&& !foundRange) {\n\t\t\t\t\t\tctx.createFailureStatus(\"Task has no Range defined\");\n\t\t\t\t\t}\n\t\t\t\t\tif (distributionTypeValue.equals(\"normal\") && !foundStandardDeviation) {\n\t\t\t\t\t\tctx.createFailureStatus(\"Task has no Standard Deviation defined\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn ctx.createSuccessStatus();\n\t}\n"} {"input": "\tpublic void initialize(){\n\t\tfloat sf = this.backgroundScaleFactor;\n\t\tInvisibleWalls walls = new InvisibleWalls(sf*52f, sf*52f, sf*550f, sf*52f, this.background); \n\t\tmap = new Map(walls);\n\t\tthis.game = new Game(background);\n\t\tthis.game.addEntity(map);\n\t\tthis.game.addEntities(map.walkers);\n\t\tthis.gameProcess = new GameProcess(game, this.engine, this.starWarsScene);\n\t\tthis.touchProcess = new TouchProcess(game, this.starWarsScene, this.context);\n\t\tthis.playersCommandsProcess = new WalkersProcess(game,map);\n\t\tthis.lasersProcess = new LaserBeamsProcess(game,map);\n\t\tthis.renderPlayersProcess = new RenderWalkersProcess(game, this.background);\n\t\tthis.renderBallsProcess = new RenderLaserProcess(game, this.background);\n\t\tthis.bubblesBallsProcess = new RenderBubbleProcess(game, this.background);\n\t\tgame.addProcess(this.gameProcess, 1);\n\t\tgame.addProcess(this.touchProcess, 10);\n\t\tgame.addProcess(this.lasersProcess, 20);\n\t\tgame.addProcess(this.playersCommandsProcess, 21);\n\t\tgame.addProcess(this.renderPlayersProcess, 98);\n\t\tgame.addProcess(this.renderBallsProcess, 99);\n\t\tgame.addProcess(this.bubblesBallsProcess, 99);\n\t}\n", "output": "\tpublic void initialize(){\n\t\tfloat sf = this.backgroundScaleFactor;\n\t\tInvisibleWalls walls = new InvisibleWalls(sf*52f, sf*52f, sf*600f, sf*52f, this.background); \n\t\tmap = new Map(walls);\n\t\tthis.game = new Game(background);\n\t\tthis.game.addEntity(map);\n\t\tthis.game.addEntities(map.walkers);\n\t\tthis.gameProcess = new GameProcess(game, this.engine, this.starWarsScene);\n\t\tthis.touchProcess = new TouchProcess(game, this.starWarsScene, this.context);\n\t\tthis.playersCommandsProcess = new WalkersProcess(game,map);\n\t\tthis.lasersProcess = new LaserBeamsProcess(game,map);\n\t\tthis.renderPlayersProcess = new RenderWalkersProcess(game, this.background);\n\t\tthis.renderBallsProcess = new RenderLaserProcess(game, this.background);\n\t\tthis.bubblesBallsProcess = new RenderBubbleProcess(game, this.background);\n\t\tgame.addProcess(this.gameProcess, 1);\n\t\tgame.addProcess(this.touchProcess, 10);\n\t\tgame.addProcess(this.lasersProcess, 20);\n\t\tgame.addProcess(this.playersCommandsProcess, 21);\n\t\tgame.addProcess(this.renderPlayersProcess, 98);\n\t\tgame.addProcess(this.renderBallsProcess, 99);\n\t\tgame.addProcess(this.bubblesBallsProcess, 99);\n\t}\n"} {"input": "\tprotected void onDraw(Canvas canvas) {\n\t\tif(screen_mode==Configuration.ORIENTATION_PORTRAIT){\n\t\t\tcanvas.drawRect(0, 0, gap/2, unit_width*0.75f, marginPaint);\n\t\t\tcanvas.drawRect(gap/2, 0, screen_width/5-gap/2, unit_width*0.75f, mPaint);\n\t\t\tcanvas.drawRect(screen_width/5-gap/2, 0, screen_width/5, unit_width*0.75f, marginPaint);\n\t\t\tcanvas.drawLine(0, unit_width*0.75f+strokeWdith/2, screen_width/5, unit_width*0.75f+strokeWdith/2, linePaint);\n\t\t}else{\n\t\t\tcanvas.drawRect(0, 0, gap/2, getMeasuredHeight(), marginPaint);\n\t\t\tcanvas.drawRect(0, 0, getMeasuredWidth(),gap/2, marginPaint);\n\t\t\tcanvas.drawRect(gap/2, 0, getMeasuredWidth()-gap/2, getMeasuredHeight()-gap/2, mPaint);\n\t\t\tcanvas.drawRect(0, getMeasuredWidth()-gap/2, getMeasuredWidth(), getMeasuredHeight(), marginPaint);\n\t\t\tcanvas.drawRect(screen_width/5-gap/2, 0, screen_width/5, getMeasuredHeight(), marginPaint);\n\t\t\tcanvas.drawLine(getMeasuredWidth()-gap/2+strokeWdith/2, 0, getMeasuredWidth()-gap/2+strokeWdith/2, getMeasuredHeight(), linePaint);\n\t\t}\n\t\tsuper.onDraw(canvas);\n\t}\n", "output": "\tprotected void onDraw(Canvas canvas) {\n\t\tif(screen_mode==Configuration.ORIENTATION_PORTRAIT){\n\t\t\tcanvas.drawRect(0, 0, gap/2, unit_width*0.75f, marginPaint);\n\t\t\tcanvas.drawRect(gap/2, 0, screen_width/5-gap/2, unit_width*0.75f, mPaint);\n\t\t\tcanvas.drawRect(screen_width/5-gap/2, 0, screen_width/5, unit_width*0.75f, marginPaint);\n\t\t\tcanvas.drawLine(0, unit_width*0.75f+strokeWdith/2, screen_width/5, unit_width*0.75f+strokeWdith/2, linePaint);\n\t\t}else{\n\t\t\tcanvas.drawRect(0, 0, gap/2, getMeasuredHeight(), marginPaint);\n\t\t\tcanvas.drawRect(0, 0, getMeasuredWidth(),gap/2, marginPaint);\n\t\t\tcanvas.drawRect(gap/2, 0, getMeasuredWidth()-gap/2, getMeasuredHeight()-gap/2, mPaint);\n\t\t\tcanvas.drawRect(gap/2, getMeasuredHeight(), screen_width/5, getMeasuredHeight(), marginPaint);\n\t\t\tcanvas.drawRect(screen_width/5-gap/2, 0, screen_width/5, getMeasuredHeight(), marginPaint);\n\t\t\tcanvas.drawLine(getMeasuredWidth()-gap/2+strokeWdith/2, 0, getMeasuredWidth()-gap/2+strokeWdith/2, getMeasuredHeight(), linePaint);\n\t\t}\n\t\tsuper.onDraw(canvas);\n\t}\n"} {"input": " public void event(SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event) {\n GELFMessage gelf = new GELFMessage();\n if (event instanceof GraylogSyslogServerEvent) {\n GraylogSyslogServerEvent glEvent = (GraylogSyslogServerEvent) event;\n LOG.debug(\"Received syslog message (via AMQP): \" + event.getMessage());\n LOG.debug(\"AMQP queue: \" + glEvent.getAmqpReceiverQueue());\n gelf.addAdditionalData(\"_amqp_queue\", glEvent.getAmqpReceiverQueue());\n } else {\n LOG.debug(\"Received syslog message: \" + event.getMessage());\n }\n LOG.debug(\"Host: \" + event.getHost());\n LOG.debug(\"Facility: \" + event.getFacility() + \" (\" + Tools.syslogFacilityToReadable(event.getFacility()) + \")\");\n LOG.debug(\"Level: \" + event.getLevel() + \" (\" + Tools.syslogLevelToReadable(event.getLevel()) + \")\");\n LOG.debug(\"Raw: \" + new String(event.getRaw()));\n if (event.getDate() == null) {\n LOG.info(\"Syslog message is missing date or could not be parsed. Not further handling. Message was: \" + event.getRaw());\n return;\n }\n try {\n gelf.setCreatedAt(Tools.getUTCTimestampWithMilliseconds(event.getDate().getTime()));\n gelf.setConvertedFromSyslog(true);\n gelf.setVersion(\"0\");\n gelf.setShortMessage(event.getMessage());\n gelf.setHost(event.getHost());\n gelf.setFacility(Tools.syslogFacilityToReadable(event.getFacility()));\n gelf.setLevel(event.getLevel());\n gelf.setRaw(event.getRaw());\n } catch (Exception e) {\n LOG.info(\"Could not parse syslog message to GELF: \" + e.toString(), e);\n return;\n }\n if (gelf.allRequiredFieldsSet()) {\n try {\n SimpleGELFClientHandler gelfHandler = new SimpleGELFClientHandler(gelf);\n gelfHandler.handle();\n } catch (Exception e) {\n LOG.debug(\"Couldn't process message with GELF handler\", e);\n }\n } else {\n LOG.info(\"Broken or incomplete syslog message. Not further handling. Message was: \" + event.getRaw());\n }\n }\n", "output": " public void event(SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event) {\n GELFMessage gelf = new GELFMessage();\n if (event instanceof GraylogSyslogServerEvent) {\n GraylogSyslogServerEvent glEvent = (GraylogSyslogServerEvent) event;\n LOG.debug(\"Received syslog message (via AMQP): \" + event.getMessage());\n LOG.debug(\"AMQP queue: \" + glEvent.getAmqpReceiverQueue());\n gelf.addAdditionalData(\"_amqp_queue\", glEvent.getAmqpReceiverQueue());\n } else {\n LOG.debug(\"Received syslog message: \" + event.getMessage());\n }\n LOG.debug(\"Host: \" + event.getHost());\n LOG.debug(\"Facility: \" + event.getFacility() + \" (\" + Tools.syslogFacilityToReadable(event.getFacility()) + \")\");\n LOG.debug(\"Level: \" + event.getLevel() + \" (\" + Tools.syslogLevelToReadable(event.getLevel()) + \")\");\n LOG.debug(\"Raw: \" + new String(event.getRaw()));\n if (event.getDate() == null) {\n LOG.info(\"Syslog message is missing date or could not be parsed. Not further handling. Message was: \" + event.getRaw());\n return;\n }\n try {\n gelf.setCreatedAt(Tools.getUTCTimestampWithMilliseconds(event.getDate().getTime()));\n gelf.setConvertedFromSyslog(true);\n gelf.setVersion(\"0\");\n gelf.setShortMessage(event.getMessage());\n gelf.setFullMessage(new String(event.getRaw()));\n gelf.setHost(event.getHost());\n gelf.setFacility(Tools.syslogFacilityToReadable(event.getFacility()));\n gelf.setLevel(event.getLevel());\n gelf.setRaw(event.getRaw());\n } catch (Exception e) {\n LOG.info(\"Could not parse syslog message to GELF: \" + e.toString(), e);\n return;\n }\n if (gelf.allRequiredFieldsSet()) {\n try {\n SimpleGELFClientHandler gelfHandler = new SimpleGELFClientHandler(gelf);\n gelfHandler.handle();\n } catch (Exception e) {\n LOG.debug(\"Couldn't process message with GELF handler\", e);\n }\n } else {\n LOG.info(\"Broken or incomplete syslog message. Not further handling. Message was: \" + event.getRaw());\n }\n }\n"} {"input": " public void execute() throws MojoExecutionException, MojoFailureException {\n checkParameters();\n final File thriftSourceRoot = getThriftSourceRoot();\n if (thriftSourceRoot.exists()) {\n try {\n ImmutableSet thriftFiles = findThriftFilesInDirectory(thriftSourceRoot);\n final File outputDirectory = getOutputDirectory();\n ImmutableSet outputFiles = findGeneratedFilesInDirectory(getOutputDirectory());\n if (thriftFiles.isEmpty()) {\n getLog().info(\"No thrift files to compile.\");\n } else if (checkStaleness && ((lastModified(thriftFiles) + staleMillis) < lastModified(outputFiles))) {\n getLog().info(\"Skipping compilation because target directory newer than sources.\");\n } else {\n ImmutableSet derivedThriftPathElements =\n makeThriftPathFromJars(temporaryThriftFileDirectory, getDependencyArtifactFiles());\n outputDirectory.mkdirs();\n cleanDirectory(outputDirectory);\n Thrift thrift = new Thrift.Builder(thriftExecutable, outputDirectory)\n .setGenerator(generator)\n .addThriftPathElement(thriftSourceRoot)\n .addThriftPathElements(derivedThriftPathElements)\n .addThriftPathElements(asList(additionalThriftPathElements))\n .addThriftFiles(thriftFiles)\n .build();\n final int exitStatus = thrift.compile();\n if (exitStatus != 0) {\n getLog().error(\"thrift failed output: \" + thrift.getOutput());\n getLog().error(\"thrift failed error: \" + thrift.getError());\n throw new MojoFailureException(\n \"thrift did not exit cleanly. Review output for more information.\");\n }\n attachFiles();\n }\n } catch (IOException e) {\n throw new MojoExecutionException(\"An IO error occured\", e);\n } catch (IllegalArgumentException e) {\n throw new MojoFailureException(\"thrift failed to execute because: \" + e.getMessage(), e);\n } catch (CommandLineException e) {\n throw new MojoExecutionException(\"An error occurred while invoking thrift.\", e);\n }\n } else {\n getLog().info(format(\"%s does not exist. Review the configuration or consider disabling the plugin.\",\n thriftSourceRoot));\n }\n }\n", "output": " public void execute() throws MojoExecutionException, MojoFailureException {\n checkParameters();\n final File thriftSourceRoot = getThriftSourceRoot();\n if (thriftSourceRoot.exists()) {\n try {\n ImmutableSet thriftFiles = findThriftFilesInDirectory(thriftSourceRoot);\n final File outputDirectory = getOutputDirectory();\n ImmutableSet outputFiles = findGeneratedFilesInDirectory(getOutputDirectory());\n if (thriftFiles.isEmpty()) {\n getLog().info(\"No thrift files to compile.\");\n } else if (checkStaleness && ((lastModified(thriftFiles) + staleMillis) < lastModified(outputFiles))) {\n getLog().info(\"Skipping compilation because target directory newer than sources.\");\n attachFiles();\n } else {\n ImmutableSet derivedThriftPathElements =\n makeThriftPathFromJars(temporaryThriftFileDirectory, getDependencyArtifactFiles());\n outputDirectory.mkdirs();\n cleanDirectory(outputDirectory);\n Thrift thrift = new Thrift.Builder(thriftExecutable, outputDirectory)\n .setGenerator(generator)\n .addThriftPathElement(thriftSourceRoot)\n .addThriftPathElements(derivedThriftPathElements)\n .addThriftPathElements(asList(additionalThriftPathElements))\n .addThriftFiles(thriftFiles)\n .build();\n final int exitStatus = thrift.compile();\n if (exitStatus != 0) {\n getLog().error(\"thrift failed output: \" + thrift.getOutput());\n getLog().error(\"thrift failed error: \" + thrift.getError());\n throw new MojoFailureException(\n \"thrift did not exit cleanly. Review output for more information.\");\n }\n attachFiles();\n }\n } catch (IOException e) {\n throw new MojoExecutionException(\"An IO error occured\", e);\n } catch (IllegalArgumentException e) {\n throw new MojoFailureException(\"thrift failed to execute because: \" + e.getMessage(), e);\n } catch (CommandLineException e) {\n throw new MojoExecutionException(\"An error occurred while invoking thrift.\", e);\n }\n } else {\n getLog().info(format(\"%s does not exist. Review the configuration or consider disabling the plugin.\",\n thriftSourceRoot));\n }\n }\n"} {"input": " protected Layer doInBackground(ProgressMonitor pm) throws Exception {\n try {\n pm.beginTask(\"Reading shapes\", ProgressMonitor.UNKNOWN);\n final ProductSceneView sceneView = context.getAppContext().getSelectedProductSceneView();\n CoordinateReferenceSystem targetCrs = (CoordinateReferenceSystem) context.getLayerContext().getCoordinateReferenceSystem();\n final Geometry clipGeometry = ShapefileUtils.createGeoBoundaryPolygon(sceneView.getRaster());\n File file = new File((String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH));\n Object featureCollectionValue = context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION);\n FeatureCollection featureCollection;\n if (featureCollectionValue == null) {\n featureCollection = ShapefileUtils.createFeatureCollection(file.toURI().toURL(), targetCrs, clipGeometry);\n } else {\n featureCollection = (FeatureCollection) featureCollectionValue;\n }\n Style[] styles = getStyles(file, featureCollection);\n Style selectedStyle = getSelectedStyle(styles);\n final LayerType type = LayerType.getLayerType(FeatureLayerType.class.getName());\n final ValueContainer configuration = type.getConfigurationTemplate();\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_URL, file.toURI().toURL());\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CRS, targetCrs);\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CLIP_GEOMETRY, clipGeometry);\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION, featureCollection);\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE, selectedStyle);\n Layer featureLayer = type.createLayer(sceneView.getLayerContext(), configuration);\n featureLayer.setName(file.getName());\n featureLayer.setVisible(true);\n return featureLayer;\n } finally {\n pm.done();\n }\n }\n", "output": " protected Layer doInBackground(ProgressMonitor pm) throws Exception {\n try {\n pm.beginTask(\"Reading shapes\", ProgressMonitor.UNKNOWN);\n final ProductSceneView sceneView = context.getAppContext().getSelectedProductSceneView();\n CoordinateReferenceSystem targetCrs = (CoordinateReferenceSystem) context.getLayerContext().getCoordinateReferenceSystem();\n final Geometry clipGeometry = ShapefileUtils.createGeoBoundaryPolygon(sceneView.getRaster());\n File file = new File((String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH));\n Object featureCollectionValue = context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION);\n FeatureCollection featureCollection;\n if (featureCollectionValue == null) {\n featureCollection = ShapefileUtils.createFeatureCollection(file.toURI().toURL(), targetCrs, clipGeometry);\n } else {\n featureCollection = (FeatureCollection) featureCollectionValue;\n }\n Style[] styles = getStyles(file, featureCollection);\n Style selectedStyle = getSelectedStyle(styles);\n final LayerType type = LayerType.getLayerType(FeatureLayerType.class.getName());\n final ValueContainer configuration = type.getConfigurationTemplate();\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_URL, file.toURI().toURL());\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CRS, targetCrs);\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CLIP_GEOMETRY, clipGeometry);\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION, featureCollection);\n configuration.setValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE, selectedStyle);\n Layer featureLayer = type.createLayer(sceneView, configuration);\n featureLayer.setName(file.getName());\n featureLayer.setVisible(true);\n return featureLayer;\n } finally {\n pm.done();\n }\n }\n"} {"input": "\tpublic void doWrite(Query query) throws Exception {\n\t\tSocket socket = null;\n\t\tstatusLock.lock();\n\t\ttry {\n\t\t\twhile(status == GraphiteWriterStatus.STARTING) {\n\t\t\t\tstatusConditionStarted.await();\n\t\t\t}\n\t\t\tif (status != GraphiteWriterStatus.STARTED) {\n\t\t\t\tthrow new LifecycleException(\"GraphiteWriter instance should be started\");\n\t\t\t}\n\t\t\tsocket = (Socket) pool.borrowObject(address);\n\t\t} finally {\n\t\t\tstatusLock.unlock();\n\t\t}\n\t\ttry {\n\t\t\tPrintWriter writer = new PrintWriter(socket.getOutputStream(), true);\n\t\t\tList typeNames = this.getTypeNames();\n\t\t\tfor (Result result : query.getResults()) {\n\t\t\t\tif (isDebugEnabled()) {\n\t\t\t\t\tlog.debug(\"Query result: \" + result.toString());\n\t\t\t\t}\n\t\t\t\tMap resultValues = result.getValues();\n\t\t\t\tif (resultValues != null) {\n\t\t\t\t\tfor (Entry values : resultValues.entrySet()) {\n Object value = values.getValue();\n if (JmxUtils.isNumeric(value)) {\n\t\t\t\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\t\t\t\tsb.append(JmxUtils.getKeyString(query, result, values, typeNames, rootPrefix).replaceAll(\"[()]\", \"_\"));\n\t\t\t\t\t\t\tsb.append(\" \");\n\t\t\t\t\t\t\tsb.append(value.toString());\n\t\t\t\t\t\t\tsb.append(\" \");\n\t\t\t\t\t\t\tsb.append(result.getEpoch() / 1000);\n\t\t\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\t\t\tString line = sb.toString();\n\t\t\t\t\t\t\tif (isDebugEnabled()) {\n\t\t\t\t\t\t\t\tlog.debug(\"Graphite Message: \" + line.trim());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twriter.write(line);\n\t\t\t\t\t\t\twriter.flush();\n\t\t\t\t\t\t} else {\n if (log.isWarnEnabled()) {\n log.warn(\"Unable to submit non-numeric value to Graphite: \\\"\" + value + \"\\\" from result \" + result);\n }\n }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tpool.returnObject(address, socket);\n\t\t}\n\t}\n", "output": "\tpublic void doWrite(Query query) throws Exception {\n\t\tSocket socket = null;\n\t\tstatusLock.lock();\n\t\ttry {\n\t\t\twhile (status == GraphiteWriterStatus.STARTING) {\n\t\t\t\tstatusConditionStarted.await();\n\t\t\t}\n\t\t\tif (status != GraphiteWriterStatus.STARTED) {\n\t\t\t\tthrow new LifecycleException(\"GraphiteWriter instance should be started\");\n\t\t\t}\n\t\t\tsocket = (Socket) pool.borrowObject(address);\n\t\t} finally {\n\t\t\tstatusLock.unlock();\n\t\t}\n\t\ttry {\n\t\t\tPrintWriter writer = new PrintWriter(socket.getOutputStream(), true);\n\t\t\tList typeNames = this.getTypeNames();\n\t\t\tfor (Result result : query.getResults()) {\n\t\t\t\tif (isDebugEnabled()) {\n\t\t\t\t\tlog.debug(\"Query result: \" + result.toString());\n\t\t\t\t}\n\t\t\t\tMap resultValues = result.getValues();\n\t\t\t\tif (resultValues != null) {\n\t\t\t\t\tfor (Entry values : resultValues.entrySet()) {\n\t\t\t\t\t\tObject value = values.getValue();\n\t\t\t\t\t\tif (JmxUtils.isNumeric(value)) {\n\t\t\t\t\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\t\t\t\tsb.append(JmxUtils.getKeyString(query, result, values, typeNames, rootPrefix).replaceAll(\"[()]\", \"_\"));\n\t\t\t\t\t\t\tsb.append(\" \");\n\t\t\t\t\t\t\tsb.append(value.toString());\n\t\t\t\t\t\t\tsb.append(\" \");\n\t\t\t\t\t\t\tsb.append(result.getEpoch() / 1000);\n\t\t\t\t\t\t\tsb.append(\"\\n\");\n\t\t\t\t\t\t\tString line = sb.toString();\n\t\t\t\t\t\t\tif (isDebugEnabled()) {\n\t\t\t\t\t\t\t\tlog.debug(\"Graphite Message: \" + line.trim());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twriter.write(line);\n\t\t\t\t\t\t\twriter.flush();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (log.isWarnEnabled()) {\n\t\t\t\t\t\t\t\tlog.warn(\"Unable to submit non-numeric value to Graphite: \\\"\" + value + \"\\\" from result \" + result);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tpool.returnObject(address, socket);\n\t\t}\n\t}\n"} {"input": "\tpublic final View doLogin(\n\t\t\t@RequestParam(\"type\") final String type,\n\t\t\t@RequestParam(value = \"user\", required = false) final String guestName,\n\t\t\t@RequestParam(value = \"referer\", required = false) final String forcedReferer,\n\t\t\t@RequestParam(value = \"successurl\", required = false) final String successUrl,\n\t\t\t@RequestParam(value = \"failureurl\", required = false) final String failureUrl,\n\t\t\tfinal HttpServletRequest request,\n\t\t\tfinal HttpServletResponse response\n\t) throws IOException, ServletException {\n\t\tString referer = request.getHeader(\"referer\");\n\t\tif (null != forcedReferer && !UrlUtils.isAbsoluteUrl(referer)) {\n\t\t\treferer = forcedReferer;\n\t\t}\n\t\tif (null == referer) {\n\t\t\treferer = \"/\";\n\t\t}\n\t\trequest.getSession().setAttribute(\"ars-login-success-url\",\n\t\t\tnull == successUrl ? referer + \"#auth/checkLogin\" : successUrl\n\t\t);\n\t\trequest.getSession().setAttribute(\"ars-login-failure-url\",\n\t\t\tnull == failureUrl ? referer : failureUrl\n\t\t);\n\t\tif (\"cas\".equals(type)) {\n\t\t\tcasEntryPoint.commence(request, response, null);\n\t\t} else if (\"twitter\".equals(type)) {\n\t\t\tString authUrl = twitterProvider.getAuthorizationUrl(new HttpUserSession(request));\n\t\t\treturn new RedirectView(authUrl);\n\t\t} else if (\"facebook\".equals(type)) {\n\t\t\tString authUrl = facebookProvider.getAuthorizationUrl(new HttpUserSession(request));\n\t\t\treturn new RedirectView(authUrl);\n\t\t} else if (\"google\".equals(type)) {\n\t\t\tString authUrl = googleProvider.getAuthorizationUrl(new HttpUserSession(request));\n\t\t\treturn new RedirectView(authUrl);\n\t\t} else if (\"guest\".equals(type)) {\n\t\t\tList authorities = new ArrayList();\n\t\t\tauthorities.add(new SimpleGrantedAuthority(\"ROLE_GUEST\"));\n\t\t\tString username = \"\";\n\t\t\tif (guestName != null && guestName.startsWith(\"Guest\") && guestName.length() == MAX_USERNAME_LENGTH) {\n\t\t\t\tusername = guestName;\n\t\t\t} else {\n\t\t\t\tusername = \"Guest\" + Sha512DigestUtils.shaHex(request.getSession().getId()).substring(0, 10);\n\t\t\t}\n\t\t\torg.springframework.security.core.userdetails.User user =\n\t\t\t\t\tnew org.springframework.security.core.userdetails.User(\n\t\t\t\t\t\t\tusername, \"\", true, true, true, true, authorities\n\t\t\t\t\t);\n\t\t\tAuthentication token = new UsernamePasswordAuthenticationToken(user, null, authorities);\n\t\t\tSecurityContextHolder.getContext().setAuthentication(token);\n\t\t\trequest.getSession(true).setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,\n\t\t\t\t\tSecurityContextHolder.getContext());\n\t\t\treturn new RedirectView(null == successUrl ? referer + \"#auth/checkLogin\" : successUrl);\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tpublic final View doLogin(\n\t\t\t@RequestParam(\"type\") final String type,\n\t\t\t@RequestParam(value = \"user\", required = false) final String guestName,\n\t\t\t@RequestParam(value = \"referer\", required = false) final String forcedReferer,\n\t\t\t@RequestParam(value = \"successurl\", required = false) final String successUrl,\n\t\t\t@RequestParam(value = \"failureurl\", required = false) final String failureUrl,\n\t\t\tfinal HttpServletRequest request,\n\t\t\tfinal HttpServletResponse response\n\t) throws IOException, ServletException {\n\t\tString referer = request.getHeader(\"referer\");\n\t\tif (null != forcedReferer && null != referer && !UrlUtils.isAbsoluteUrl(referer)) {\n\t\t\treferer = forcedReferer;\n\t\t}\n\t\tif (null == referer) {\n\t\t\treferer = \"/\";\n\t\t}\n\t\trequest.getSession().setAttribute(\"ars-login-success-url\",\n\t\t\tnull == successUrl ? referer + \"#auth/checkLogin\" : successUrl\n\t\t);\n\t\trequest.getSession().setAttribute(\"ars-login-failure-url\",\n\t\t\tnull == failureUrl ? referer : failureUrl\n\t\t);\n\t\tif (\"cas\".equals(type)) {\n\t\t\tcasEntryPoint.commence(request, response, null);\n\t\t} else if (\"twitter\".equals(type)) {\n\t\t\tString authUrl = twitterProvider.getAuthorizationUrl(new HttpUserSession(request));\n\t\t\treturn new RedirectView(authUrl);\n\t\t} else if (\"facebook\".equals(type)) {\n\t\t\tString authUrl = facebookProvider.getAuthorizationUrl(new HttpUserSession(request));\n\t\t\treturn new RedirectView(authUrl);\n\t\t} else if (\"google\".equals(type)) {\n\t\t\tString authUrl = googleProvider.getAuthorizationUrl(new HttpUserSession(request));\n\t\t\treturn new RedirectView(authUrl);\n\t\t} else if (\"guest\".equals(type)) {\n\t\t\tList authorities = new ArrayList();\n\t\t\tauthorities.add(new SimpleGrantedAuthority(\"ROLE_GUEST\"));\n\t\t\tString username = \"\";\n\t\t\tif (guestName != null && guestName.startsWith(\"Guest\") && guestName.length() == MAX_USERNAME_LENGTH) {\n\t\t\t\tusername = guestName;\n\t\t\t} else {\n\t\t\t\tusername = \"Guest\" + Sha512DigestUtils.shaHex(request.getSession().getId()).substring(0, 10);\n\t\t\t}\n\t\t\torg.springframework.security.core.userdetails.User user =\n\t\t\t\t\tnew org.springframework.security.core.userdetails.User(\n\t\t\t\t\t\t\tusername, \"\", true, true, true, true, authorities\n\t\t\t\t\t);\n\t\t\tAuthentication token = new UsernamePasswordAuthenticationToken(user, null, authorities);\n\t\t\tSecurityContextHolder.getContext().setAuthentication(token);\n\t\t\trequest.getSession(true).setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,\n\t\t\t\t\tSecurityContextHolder.getContext());\n\t\t\treturn new RedirectView(null == successUrl ? referer + \"#auth/checkLogin\" : successUrl);\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": "\tpublic String nicePrint()\n\t{\n\t\tString day = this.day+\" day\";\n\t\tString hour = this.hour+\" hour\";\n\t\tString minute = this.minutes+\" minute\";\n\t\tif(this.day==0)\n\t\t\tday=\"\";\n\t\telse if(this.day!=1)\n\t\t\tday+=\"s\";\n\t\tif(this.hour==0)\n\t\t\thour=\"\";\n\t\telse if(this.hour!=1)\n\t\t\thour+=\"s\";\n\t\tif(this.hour!=0)\n\t\t\thour+=\" and \";\n\t\tif(this.hour!=0 && this.day!=0)\n\t\t\tday+= \", \";\n\t\tif(this.minutes!=1)\n\t\t\tminute+=\"s\";\n\t\treturn day+hour+minute; \n\t}\n", "output": "\tpublic String nicePrint()\n\t{\n\t\tString day = this.day+\" day\";\n\t\tString hour = this.hour+\" hour\";\n\t\tString minute = this.minutes+\" minute\";\n\t\tif(this.day==0)\n\t\t\tday=\"\";\n\t\telse if(this.day!=1)\n\t\t\tday+=\"s\";\n\t\tif(this.hour==0)\n\t\t\thour=\"\";\n\t\telse if(this.hour!=1)\n\t\t\thour+=\"s\";\n\t\tif(this.hour!=0||(this.hour==0&&this.day!=0&&this.minutes!=0))\n\t\t\thour+=\" and \";\n\t\tif(this.hour!=0 && this.day!=0)\n\t\t\tday+= \", \";\n\t\tif(this.minutes!=1)\n\t\t\tminute+=\"s\";\n\t\treturn day+hour+minute; \n\t}\n"} {"input": "\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tIntent intent = this.getIntent();\n\t\tif (intent.hasExtra(Constants.EXTRA_PODCAST_ID)) {\n\t\t\tint podcastId = intent.getIntExtra(Constants.EXTRA_PODCAST_ID, -1);\n\t\t\tif (podcastId == -1) {\n\t\t\t\tfinish();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tUri uri = ContentUris.withAppendedId(PodcastProvider.URI, podcastId);\n\t\t\t_cursor = getContentResolver().query(uri, _projection, null, null, null);\n\t\t} else {\n\t\t\tUri uri = Uri.withAppendedPath(PodcastProvider.URI, \"active\");\n\t\t\t_cursor = managedQuery(uri, _projection, null, null, null);\n\t\t\tif (_cursor.isAfterLast()) {\n\t\t\t\tfinish();\n\t\t\t\tstartActivity(new Intent(this, QueueActivity.class));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t_podcast = new PodcastCursor(this, _cursor);\n\t\t_podcastId = _podcast.getId();\n\t\t_observer = new PodcastObserver(_handler);\n\t\t_podcast.registerContentObserver(_observer);\n setTitle(_podcast.getTitle());\n setContentView(R.layout.podcast_detail);\n\t\t_subscriptionTitleView = (TextView)findViewById(R.id.subscription_title);\n\t\t_subscriptionTitleView.setText(_podcast.getSubscriptionTitle());\n\t\t_descriptionView = (WebView)findViewById(R.id.description);\n\t\tString html = \"\" +\n\t\t\t\t\"\" + _podcast.getDescription() + \"\"; \n\t\t_descriptionView.loadData(html, \"text/html\", \"utf-8\");\n\t\t_descriptionView.setBackgroundColor(Color.BLACK);\n\t\t_queuePosition = (TextView)findViewById(R.id.queue_position);\n\t\t_queueButton = (Button)findViewById(R.id.queue_btn);\n\t\tupdateQueueViews();\n\t\t_queueButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (_podcast.getQueuePosition() == null)\n\t\t\t\t\t_podcast.addToQueue();\n\t\t\t\telse\n\t\t\t\t\t_podcast.removeFromQueue();\n\t\t\t}\n\t\t});\n\t\t_restartButton = (ImageButton)findViewById(R.id.restart_btn);\n\t\t_restartButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.restart(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_rewindButton = (ImageButton)findViewById(R.id.rewind_btn);\n\t\t_rewindButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.skipBack(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_playButton = (ImageButton)findViewById(R.id.play_btn);\n\t\t_playButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tLong activeId = null;\n\t\t\t\tString[] projection = new String[] { PodcastProvider.COLUMN_ID };\n\t\t\t\tCursor c = getContentResolver().query(PodcastProvider.ACTIVE_PODCAST_URI, projection, null, null, null);\n\t\t\t\ttry {\n\t\t\t\t\tif (c.moveToNext())\n\t\t\t\t\t\tactiveId = c.getLong(0);\n\t\t\t\t\tif (Helper.isPlaying(PodcastDetailActivity.this) && \n\t\t\t\t\t\t\tactiveId != null && activeId.equals(_podcast.getId()))\n\t\t\t\t\t\tPlayerService.pause(PodcastDetailActivity.this);\n\t\t\t\t\telse\n\t\t\t\t\t\tPlayerService.play(PodcastDetailActivity.this, _podcast);\n\t\t\t\t} finally {\n\t\t\t\t\tc.close();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t_forwardButton = (ImageButton)findViewById(R.id.forward_btn);\n\t\t_forwardButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.skipForward(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_skipToEndButton = (ImageButton)findViewById(R.id.skiptoend_btn);\n\t\t_skipToEndButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.skipToEnd(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_seekbar = (SeekBar)findViewById(R.id.seekbar);\n\t\t_seekbar.setMax(_podcast.getDuration());\n\t\t_seekbar.setProgress(_podcast.getLastPosition());\n\t\t_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {\n\t\t\tpublic void onProgressChanged(SeekBar seekBar, int progress,\n\t\t\t\t\tboolean fromUser) {\n\t\t\t\t_position.setText(Helper.getTimeString(progress));\n\t\t\t}\n\t\t\tpublic void onStartTrackingTouch(SeekBar seekBar) {\n\t\t\t\t_seekbar_dragging = true;\n\t\t\t}\n\t\t\tpublic void onStopTrackingTouch(SeekBar seekBar) {\n\t\t\t\t_seekbar_dragging = false;\n\t\t\t\tPlayerService.skipTo(PodcastDetailActivity.this, seekBar.getProgress() / 1000);\n\t\t\t}\n\t\t});\n\t\t_seekbar_dragging = false;\n\t\t_position = (TextView)findViewById(R.id.position);\n\t\t_position.setText(Helper.getTimeString(_podcast.getLastPosition()));\n\t\t_duration = (TextView)findViewById(R.id.duration);\n\t\t_duration.setText(\"-\" + Helper.getTimeString(_podcast.getDuration() - _podcast.getLastPosition()));\n\t\tupdatePlayerControls(true);\n\t}\n", "output": "\tpublic void onCreate(Bundle savedInstanceState) {\n\t\tsuper.onCreate(savedInstanceState);\n\t\tIntent intent = this.getIntent();\n\t\tif (intent.hasExtra(Constants.EXTRA_PODCAST_ID)) {\n\t\t\tint podcastId = intent.getIntExtra(Constants.EXTRA_PODCAST_ID, -1);\n\t\t\tif (podcastId == -1) {\n\t\t\t\tfinish();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tUri uri = ContentUris.withAppendedId(PodcastProvider.URI, podcastId);\n\t\t\t_cursor = getContentResolver().query(uri, _projection, null, null, null);\n\t\t} else {\n\t\t\tUri uri = Uri.withAppendedPath(PodcastProvider.URI, \"active\");\n\t\t\t_cursor = managedQuery(uri, _projection, null, null, null);\n\t\t\tif (_cursor.isAfterLast()) {\n\t\t\t\tfinish();\n\t\t\t\tstartActivity(new Intent(this, QueueActivity.class));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t_podcast = new PodcastCursor(this, _cursor);\n\t\t_podcastId = _podcast.getId();\n\t\t_observer = new PodcastObserver(_handler);\n\t\t_podcast.registerContentObserver(_observer);\n setTitle(_podcast.getTitle());\n setContentView(R.layout.podcast_detail);\n\t\t_subscriptionTitleView = (TextView)findViewById(R.id.subscription_title);\n\t\t_subscriptionTitleView.setText(_podcast.getSubscriptionTitle());\n\t\t_descriptionView = (WebView)findViewById(R.id.description);\n\t\tString html = \"\" +\n\t\t\t\t\"\" + _podcast.getDescription() + \"\"; \n\t\t_descriptionView.loadData(html, \"text/html\", \"utf-8\");\n\t\t_descriptionView.setBackgroundColor(Color.BLACK);\n\t\t_queuePosition = (TextView)findViewById(R.id.queue_position);\n\t\t_queueButton = (Button)findViewById(R.id.queue_btn);\n\t\tupdateQueueViews();\n\t\t_queueButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tif (_podcast.getQueuePosition() == null)\n\t\t\t\t\t_podcast.addToQueue();\n\t\t\t\telse\n\t\t\t\t\t_podcast.removeFromQueue();\n\t\t\t}\n\t\t});\n\t\t_restartButton = (ImageButton)findViewById(R.id.restart_btn);\n\t\t_restartButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.restart(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_rewindButton = (ImageButton)findViewById(R.id.rewind_btn);\n\t\t_rewindButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.skipBack(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_playButton = (ImageButton)findViewById(R.id.play_btn);\n\t\t_playButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tLong activeId = null;\n\t\t\t\tString[] projection = new String[] { PodcastProvider.COLUMN_ID };\n\t\t\t\tCursor c = getContentResolver().query(PodcastProvider.ACTIVE_PODCAST_URI, projection, null, null, null);\n\t\t\t\ttry {\n\t\t\t\t\tif (c.moveToNext())\n\t\t\t\t\t\tactiveId = c.getLong(0);\n\t\t\t\t\tif (Helper.isPlaying(PodcastDetailActivity.this) && \n\t\t\t\t\t\t\tactiveId != null && activeId.equals(_podcast.getId()))\n\t\t\t\t\t\tPlayerService.pause(PodcastDetailActivity.this);\n\t\t\t\t\telse\n\t\t\t\t\t\tPlayerService.play(PodcastDetailActivity.this, _podcast);\n\t\t\t\t} finally {\n\t\t\t\t\tc.close();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t_forwardButton = (ImageButton)findViewById(R.id.forward_btn);\n\t\t_forwardButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.skipForward(PodcastDetailActivity.this);\n\t\t\t}\n\t\t});\n\t\t_skipToEndButton = (ImageButton)findViewById(R.id.skiptoend_btn);\n\t\t_skipToEndButton.setOnClickListener(new OnClickListener() {\n\t\t\tpublic void onClick(View v) {\n\t\t\t\tPlayerService.skipToEnd(PodcastDetailActivity.this);\n\t\t\t\tfinish();\n\t\t\t\tstartActivity(new Intent(PodcastDetailActivity.this, PodcastDetailActivity.class));\n\t\t\t}\n\t\t});\n\t\t_seekbar = (SeekBar)findViewById(R.id.seekbar);\n\t\t_seekbar.setMax(_podcast.getDuration());\n\t\t_seekbar.setProgress(_podcast.getLastPosition());\n\t\t_seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {\n\t\t\tpublic void onProgressChanged(SeekBar seekBar, int progress,\n\t\t\t\t\tboolean fromUser) {\n\t\t\t\t_position.setText(Helper.getTimeString(progress));\n\t\t\t}\n\t\t\tpublic void onStartTrackingTouch(SeekBar seekBar) {\n\t\t\t\t_seekbar_dragging = true;\n\t\t\t}\n\t\t\tpublic void onStopTrackingTouch(SeekBar seekBar) {\n\t\t\t\t_seekbar_dragging = false;\n\t\t\t\tPlayerService.skipTo(PodcastDetailActivity.this, seekBar.getProgress() / 1000);\n\t\t\t}\n\t\t});\n\t\t_seekbar_dragging = false;\n\t\t_position = (TextView)findViewById(R.id.position);\n\t\t_position.setText(Helper.getTimeString(_podcast.getLastPosition()));\n\t\t_duration = (TextView)findViewById(R.id.duration);\n\t\t_duration.setText(\"-\" + Helper.getTimeString(_podcast.getDuration() - _podcast.getLastPosition()));\n\t\tupdatePlayerControls(true);\n\t}\n"} {"input": " public void moduleA() throws IOException {\n String pathname = \"test-src/com/redhat/ceylon/ceylondoc/test/modules/single\";\n String testName = \"moduleA\";\n CeylonDocTool tool = tool(pathname, testName, \"a\");\n tool.setShowPrivate(false);\n tool.setOmitSource(false);\n tool.makeDoc();\n Module module = new Module();\n module.setName(Arrays.asList(\"a\"));\n module.setVersion(\"3.1.4\");\n File destDir = getOutputDir(tool, module);\n assertDirectoryExists(destDir, \".resources\");\n assertFileExists(destDir, \".resources/index.js\");\n assertFileExists(destDir, \".resources/icons.png\");\n assertFileExists(destDir, \"index.html\");\n assertFileExists(destDir, \"search.html\");\n assertFileExists(destDir, \"interface_Types.html\");\n assertFileNotExists(destDir, \"class_PrivateClass.html\");\n assertFileExists(destDir, \"class_SharedClass.html\");\n assertFileExists(destDir, \"class_CaseSensitive.html\");\n assertFileNotExists(destDir, \"class_caseSensitive.html\");\n assertFileExists(destDir, \"object_caseSensitive.html\");\n assertMatchInFile(destDir, \"index.html\", \n Pattern.compile(\"This is a test module\"));\n assertMatchInFile(destDir, \"index.html\", \n Pattern.compile(\"This is a test package\"));\n assertMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='sharedAttribute'.*?>\"));\n assertNoMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='privateAttribute'.*?>\"));\n assertMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='sharedGetter'.*?>\"));\n assertNoMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='privateGetter'.*?>\"));\n assertMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='sharedMethod'.*?>\"));\n assertNoMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='privateMethod'.*?>\"));\n assertMatchInFile(destDir, \"index.html\", \n Pattern.compile(\"
By: Tom Bentley
\"));\n assertMatchInFile(destDir, \"interface_Types.html\", \n Pattern.compile(\"
By: Tom Bentley
\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"
Throws:\")); \n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"OverflowException

if the number is too large to be represented as an integer

\")); \n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"StubException

when with WIKI syntax

\"));\n assertFileExists(destDir, \"interface_StubClass.StubInnerInterface.html\");\n assertFileExists(destDir, \"class_StubClass.StubInnerClass.html\");\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"Nested Interfaces\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"StubInnerInterface\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"Nested Classes\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"StubInnerClass\"));\n assertMatchInFile(destDir, \"interface_StubClass.StubInnerInterface.html\", \n Pattern.compile(\"Enclosing class: StubClass\"));\n assertMatchInFile(destDir, \"class_StubClass.StubInnerClass.html\", \n Pattern.compile(\"Enclosing class: StubClass\"));\n assertMatchInFile(destDir, \"class_StubClass.StubInnerClass.html\", \n Pattern.compile(\"Satisfied Interfaces: StubInnerInterface\"));\n assertIcons(destDir);\n }\n", "output": " public void moduleA() throws IOException {\n String pathname = \"test-src/com/redhat/ceylon/ceylondoc/test/modules/single\";\n String testName = \"moduleA\";\n CeylonDocTool tool = tool(pathname, testName, \"a\");\n tool.setShowPrivate(false);\n tool.setOmitSource(false);\n tool.makeDoc();\n Module module = new Module();\n module.setName(Arrays.asList(\"a\"));\n module.setVersion(\"3.1.4\");\n File destDir = getOutputDir(tool, module);\n assertDirectoryExists(destDir, \".resources\");\n assertFileExists(destDir, \".resources/index.js\");\n assertFileExists(destDir, \".resources/icons.png\");\n assertFileExists(destDir, \"index.html\");\n assertFileExists(destDir, \"search.html\");\n assertFileExists(destDir, \"interface_Types.html\");\n assertFileNotExists(destDir, \"class_PrivateClass.html\");\n assertFileExists(destDir, \"class_SharedClass.html\");\n assertFileExists(destDir, \"class_CaseSensitive.html\");\n assertFileNotExists(destDir, \"class_caseSensitive.html\");\n assertFileExists(destDir, \"object_caseSensitive.html\");\n assertMatchInFile(destDir, \"index.html\", \n Pattern.compile(\"This is a test module\"));\n assertMatchInFile(destDir, \"index.html\", \n Pattern.compile(\"This is a test package\"));\n assertMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='sharedAttribute'.*?>\"));\n assertNoMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='privateAttribute'.*?>\"));\n assertMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='sharedGetter'.*?>\"));\n assertNoMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='privateGetter'.*?>\"));\n assertMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='sharedMethod'.*?>\"));\n assertNoMatchInFile(destDir, \"class_SharedClass.html\", \n Pattern.compile(\"<.*? id='privateMethod'.*?>\"));\n assertMatchInFile(destDir, \"index.html\", \n Pattern.compile(\"
By: Tom Bentley
\"));\n assertMatchInFile(destDir, \"interface_Types.html\", \n Pattern.compile(\"
By: Tom Bentley
\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"
Throws:\")); \n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"OverflowException

if the number is too large to be represented as an integer

\")); \n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"StubException

when with WIKI syntax

\"));\n assertFileExists(destDir, \"interface_StubClass.StubInnerInterface.html\");\n assertFileExists(destDir, \"class_StubClass.StubInnerClass.html\");\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"Nested Interfaces\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"StubInnerInterface\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"Nested Classes\"));\n assertMatchInFile(destDir, \"class_StubClass.html\", \n Pattern.compile(\"StubInnerClass\"));\n assertMatchInFile(destDir, \"interface_StubClass.StubInnerInterface.html\", \n Pattern.compile(\"Enclosing class: StubClass\"));\n assertMatchInFile(destDir, \"class_StubClass.StubInnerClass.html\", \n Pattern.compile(\"Enclosing class: StubClass\"));\n assertMatchInFile(destDir, \"class_StubClass.StubInnerClass.html\", \n Pattern.compile(\"Satisfied Interfaces: StubInnerInterface\"));\n assertIcons(destDir);\n }\n"} {"input": " public List execBatch() {\n List list = new ArrayList();\n @SuppressWarnings(\"unchecked\")\n ClassInfo classInfo = (ClassInfo) ClassInfoFactory\n .getClassInfo(instance.getClass());\n Set> set = exprMap.entrySet();\n Field field;\n Object value;\n Validator validator;\n for (Entry e : set) {\n field = classInfo.getField(e.getKey());\n if (field == null) {\n throw new RuntimeException(\"no field in class[ \"\n + classInfo.getClazz().getName() + \" ]\");\n }\n try {\n value = field.get(instance);\n this.parseExpr(e.getValue());\n validator = this.validatorCreator.getValidator(tmp_key);\n if (validator == null) {\n throw new RuntimeException(\"unknown validate [ \"\n + e.getValue() + \" ]\");\n }\n if (!validator.exec(this.jsonObj, value)) {\n list.add(new ErrResult(e.getKey(), this.tmp_message));\n }\n }\n catch (Exception e1) {\n throw new RuntimeException(e1);\n }\n }\n return list;\n }\n", "output": " public List execBatch() {\n List list = new ArrayList();\n @SuppressWarnings(\"unchecked\")\n ClassInfo classInfo = (ClassInfo) ClassInfoFactory\n .getClassInfo(instance.getClass());\n Set> set = exprMap.entrySet();\n Field field;\n Object value;\n Validator validator;\n for (Entry e : set) {\n field = classInfo.getField(e.getKey());\n if (field == null) {\n throw new RuntimeException(\"no field [ \" + e.getKey()\n + \" ] in class[ \" + classInfo.getClazz().getName()\n + \" ]\");\n }\n try {\n value = field.get(instance);\n this.parseExpr(e.getValue());\n validator = this.validatorCreator.getValidator(tmp_key);\n if (validator == null) {\n throw new RuntimeException(\"unknown validate [ \"\n + e.getValue() + \" ]\");\n }\n if (!validator.exec(this.jsonObj, value)) {\n list.add(new ErrResult(e.getKey(), this.tmp_message));\n }\n }\n catch (Exception e1) {\n throw new RuntimeException(e1);\n }\n }\n return list;\n }\n"} {"input": "\tpublic static boolean handlePortalEnter(Entity e, Material portalMaterial) {\n\t\tPortal portal = getNear(e.getLocation());\n\t\tif (portal == null) {\n\t\t\tString def = null;\n\t\t\tif (portalMaterial == Material.PORTAL) {\n\t\t\t\tdef = WorldConfig.get(e).getNetherPortal();\n\t\t\t} else if (portalMaterial == Material.ENDER_PORTAL) {\n\t\t\t\tdef = WorldConfig.get(e).getEndPortal();\n\t\t\t}\n\t\t\tif (def != null) {\n\t\t\t\tportal = get(getPortalLocation(def, e.getWorld().getName()));\n\t\t\t\tif (portal == null) {\n\t\t\t\t\tWorld w = WorldManager.getWorld(def);\n\t\t\t\t\tif (w != null) {\n\t\t\t\t\t\tfinal Location dest;\n\t\t\t\t\t\tif (MyWorlds.allowPersonalPortals) {\n\t\t\t\t\t\t\tdouble blockRatio = w.getEnvironment() == Environment.NORMAL ? 8 : 0.125;\n\t\t\t\t\t\t\tLocation entityLoc = e.getLocation();\n\t\t\t\t\t\t\tIntVector3 blockPos = new IntVector3(blockRatio * entityLoc.getX(), entityLoc.getY(), blockRatio * entityLoc.getZ());\n\t\t\t\t\t\t\tdest = WorldUtil.findSpawnLocation(new Location(w, blockPos.x + 0.5, blockPos.y + 0.5, blockPos.z + 0.5));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdest = WorldManager.getSpawnLocation(w);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (dest != null) {\n\t\t\t\t\t\t\tEntityUtil.teleportNextTick(e, dest);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (portal != null) {\n\t\t\tportal.teleportNextTick(e);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n", "output": "\tpublic static boolean handlePortalEnter(Entity e, Material portalMaterial) {\n\t\tPortal portal = getNear(e.getLocation());\n\t\tif (portal == null) {\n\t\t\tString def = null;\n\t\t\tif (portalMaterial == Material.PORTAL) {\n\t\t\t\tdef = WorldConfig.get(e).getNetherPortal();\n\t\t\t} else if (portalMaterial == Material.ENDER_PORTAL) {\n\t\t\t\tdef = WorldConfig.get(e).getEndPortal();\n\t\t\t}\n\t\t\tif (def != null) {\n\t\t\t\tportal = get(getPortalLocation(def, e.getWorld().getName()));\n\t\t\t\tif (portal == null) {\n\t\t\t\t\tWorld w = WorldManager.getWorld(def);\n\t\t\t\t\tif (w != null) {\n\t\t\t\t\t\tfinal Location dest;\n\t\t\t\t\t\tif (MyWorlds.allowPersonalPortals) {\n\t\t\t\t\t\t\tdouble blockRatio = w.getEnvironment() == Environment.NORMAL ? 8 : 0.125;\n\t\t\t\t\t\t\tLocation start = e.getLocation();\n\t\t\t\t\t\t\tdest = WorldUtil.findSpawnLocation(new Location(w, blockRatio * start.getX(), start.getY(), blockRatio * start.getZ())).add(0.5, 0.0, 0.5);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdest = WorldManager.getSpawnLocation(w);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (dest != null) {\n\t\t\t\t\t\t\tEntityUtil.teleportNextTick(e, dest);\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (portal != null) {\n\t\t\tportal.teleportNextTick(e);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n"} {"input": "\tprotected void handleEvent(Event e) {\n\t\tif (e instanceof ConnectionDeniedEvent) {\n\t\t\tSystem.out.println(\"Server denied connection! Reason: '\" + ((ConnectionDeniedEvent) e).getReason() + \"'\");\n\t\t\tsetGamestate(GameState.LOBBY);\n\t\t\tmenuController.actualizeScreen();\n\t\t\tclean();\n\t\t\tconnector.disconnectFromServer();\n\t\t}else if (e instanceof ConnectionInitEvent) {\n\t\t\tstartGame(((ConnectionInitEvent) e).getLevel());\n\t\t}else if (e instanceof KillEvent) {\n\t\t\tKillEvent kill = (KillEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(kill.getPlayerid());\n\t\t\tkillPlayer(p);\n\t\t}else if (e instanceof PickupEvent) {\n\t\t\tPickupEvent pickup = (PickupEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(pickup.getPlayerid());\n\t\t\tFlube flube = getWorldController().getFlube(pickup.getMoveableid());\n\t\t\tpickup(p, flube);\n\t\t}else if (e instanceof PlaceEvent) {\n\t\t\tPlaceEvent place = (PlaceEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(place.getPlayerid());\n\t\t\tFlube f = getWorldController().getFlube(place.getMoveableid());\n\t\t\tVector3f loc = place.getLocation();\n\t\t\tplace(p, f, loc);\n\t\t}else if (e instanceof PlayerJoinEvent) {\n\t\t\tPlayerJoinEvent join = (PlayerJoinEvent) e;\n\t\t\tint playerid = join.getPlayerId();\n\t\t\tjoinPlayer(playerid, join.getPlayername());\n\t\t}else if (e instanceof ChooseTeamEvent) {\n\t\t\tChooseTeamEvent choose = (ChooseTeamEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(choose.getPlayerId());\n\t\t\tchooseTeam(p, choose.getTeam());\n\t\t}else if (e instanceof RespawnEvent) {\n\t\t\tRespawnEvent respawn = (RespawnEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(respawn.getPlayerid());\n\t\t\trespawn(p);\n\t\t}else if (e instanceof PlayerQuitEvent) {\n\t\t\tPlayerQuitEvent quit = (PlayerQuitEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(quit.getPlayerId());\n\t\t\tquitPlayer(p);\n\t\t}else if (e instanceof InputEvent) {\n\t\t\tInputEvent input = (InputEvent) e;\n\t\t\tif(player.getId() != input.getPlayerid() || !InputCommand.usedirect.contains(input.getClass())) {\n\t\t\t\tPlayer p = getPlayerController().getPlayer(input.getPlayerid());\n\t\t\t\tp.handleInput(input.getCommand(), input.isValue());\n\t\t\t}\n\t\t}else if (e instanceof RestartRoundEvent) {\n\t\t\tfor (Player p : getPlayerController().getAllPlayers()) {\n\t\t\t\tif(p.isAlive()) {\n\t\t\t\t\tkillPlayer(p);\n\t\t\t\t}\n\t\t\t\tgetPlayerController().reset(p);\n\t\t\t}\n\t\t\tgetWorldController().resetWorld();\n\t\t\tthis.roundStartTime = System.currentTimeMillis();\n\t\t\tmenuController.clearEventPanel();\n\t\t\tmenuController.updateScoreboard();\n\t\t}else if (e instanceof RoundEndedEvent) {\n\t\t\tRoundEndedEvent roundEnded = (RoundEndedEvent) e;\n\t\t\tfor (Player p : getPlayerController().getAllPlayers()) {\n\t\t\t\tp.setInputState(new PlayerInputState());\n\t\t\t}\n\t\t\twinTeam = roundEnded.getWinteam();\n\t\t\tsetGamestate(GameState.ROUNDOVER);\n\t\t\tmenuController.actualizeScreen();\n\t\t}else if(e instanceof FlagEvent) {\n\t\t\tFlagEvent flagev = (FlagEvent) e;\n\t\t\tif(flagev.getType() == FlagEvent.TAKE) {\n\t\t\t\tFlag f = getWorldController().getFlag(flagev.getFlagid());\n\t\t\t\tPlayer p = getPlayerController().getPlayer(flagev.getPlayerid());\n\t\t\t\ttakeFlag(p, f);\n\t\t\t}else if(flagev.getType() == FlagEvent.SCORE) {\n\t\t\t\tFlag f = getWorldController().getFlag(flagev.getFlagid());\n\t\t\t\tPlayer p = getPlayerController().getPlayer(flagev.getPlayerid());\n\t\t\t\tscoreFlag(p, f);\n\t\t\t\tmenuController.updateScoreboard();\n\t\t\t}else if(flagev.getType() == FlagEvent.RETURN) {\n\t\t\t\tFlag f = getWorldController().getFlag(flagev.getFlagid());\n\t\t\t\treturnFlag(f);\n\t\t\t}\n\t\t}else if(e instanceof BeamEvent) {\n\t\t\tBeamEvent beam = (BeamEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(beam.getSourceid());\n\t\t\tPlayer victim = getPlayerController().getPlayer(beam.getTargetid());\n\t\t\tbeam(p, victim);\n\t\t}else if(e instanceof RemoveEvent) {\n\t\t\tRemoveEvent remove = (RemoveEvent) e;\n\t\t\tif(\"flube\".equalsIgnoreCase(remove.getObjectType())) {\n\t\t\t\tFlube f = getWorldController().getFlube(remove.getObjectid());\n\t\t\t\tgetWorldController().removeFlube(f);\n\t\t\t}else if(\"flag\".equalsIgnoreCase(remove.getObjectType())) {\n\t\t\t\tFlag f = getWorldController().getFlag((int)remove.getObjectid());\n\t\t\t\tgetWorldController().removeFlag(f);\n\t\t\t}else if(\"spawnpoint\".equalsIgnoreCase(remove.getObjectType())) {\n\t\t\t\tSpawnPoint sp = getWorldController().getSpawnPoint((int)remove.getObjectid());\n\t\t\t\tgetWorldController().removeSpawnPoint(sp);\n\t\t\t}\n\t\t}else if(e instanceof AddEvent) {\n\t\t\tAddEvent add = (AddEvent) e;\n\t\t\tif(\"flube\".equalsIgnoreCase(add.getObjectType())) {\n\t\t\t\tFlube f = getWorldController().addNewFlube(add.getObjectid(), add.getLocation(), add.getObjectSpec());\n\t\t\t\tgetWorldController().attachFlube(f);\n\t\t\t}else if(\"flag\".equalsIgnoreCase(add.getObjectType())) {\n\t\t\t\tFlag f = getWorldController().addNewFlag((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());\n\t\t\t}else if(\"spawnpoint\".equalsIgnoreCase(add.getObjectType())) {\n\t\t\t\tSpawnPoint sp = getWorldController().addNewSpawnPoint((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());\n\t\t\t\tif(\"editor\".equalsIgnoreCase(getGameConfig().getString(\"mp_gamemode\"))) {\n\t\t\t\t\tsp.getNode().setCullHint(CullHint.Dynamic);\n\t\t\t\t}else {\n\t\t\t\t\tsp.getNode().setCullHint(CullHint.Always);\n\t\t\t\t}\n\t\t\t}\n\t\t}else if(e instanceof ConfigEvent) {\n\t\t\tConfigEvent event = (ConfigEvent) e;\n\t\t\tif(\"mp_gamemode\".equalsIgnoreCase(event.getKey())) {\n\t\t\t\tswitchGameMode((String)event.getNewValue());\n\t\t\t}else if(\"mp_scorelimit\".equalsIgnoreCase(event.getKey())) {\n\t\t\t\tgetGameConfig().putObject(\"mp_scorelimit\", (Integer) event.getNewValue());\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprotected void handleEvent(Event e) {\n\t\tif (e instanceof ConnectionDeniedEvent) {\n\t\t\tSystem.out.println(\"Server denied connection! Reason: '\" + ((ConnectionDeniedEvent) e).getReason() + \"'\");\n\t\t\tsetGamestate(GameState.LOBBY);\n\t\t\tmenuController.actualizeScreen();\n\t\t\tclean();\n\t\t\tconnector.disconnectFromServer();\n\t\t}else if (e instanceof ConnectionInitEvent) {\n\t\t\tstartGame(((ConnectionInitEvent) e).getLevel());\n\t\t}else if (e instanceof KillEvent) {\n\t\t\tKillEvent kill = (KillEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(kill.getPlayerid());\n\t\t\tkillPlayer(p);\n\t\t}else if (e instanceof PickupEvent) {\n\t\t\tPickupEvent pickup = (PickupEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(pickup.getPlayerid());\n\t\t\tFlube flube = getWorldController().getFlube(pickup.getMoveableid());\n\t\t\tpickup(p, flube);\n\t\t}else if (e instanceof PlaceEvent) {\n\t\t\tPlaceEvent place = (PlaceEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(place.getPlayerid());\n\t\t\tFlube f = getWorldController().getFlube(place.getMoveableid());\n\t\t\tVector3f loc = place.getLocation();\n\t\t\tplace(p, f, loc);\n\t\t}else if (e instanceof PlayerJoinEvent) {\n\t\t\tPlayerJoinEvent join = (PlayerJoinEvent) e;\n\t\t\tint playerid = join.getPlayerId();\n\t\t\tjoinPlayer(playerid, join.getPlayername());\n\t\t}else if (e instanceof ChooseTeamEvent) {\n\t\t\tChooseTeamEvent choose = (ChooseTeamEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(choose.getPlayerId());\n\t\t\tchooseTeam(p, choose.getTeam());\n\t\t}else if (e instanceof RespawnEvent) {\n\t\t\tRespawnEvent respawn = (RespawnEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(respawn.getPlayerid());\n\t\t\trespawn(p);\n\t\t}else if (e instanceof PlayerQuitEvent) {\n\t\t\tPlayerQuitEvent quit = (PlayerQuitEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(quit.getPlayerId());\n\t\t\tquitPlayer(p);\n\t\t}else if (e instanceof InputEvent) {\n\t\t\tInputEvent input = (InputEvent) e;\n\t\t\tif(player.getId() != input.getPlayerid() || !InputCommand.usedirect.contains(input.getClass())) {\n\t\t\t\tPlayer p = getPlayerController().getPlayer(input.getPlayerid());\n\t\t\t\tp.handleInput(input.getCommand(), input.isValue());\n\t\t\t}\n\t\t}else if (e instanceof RestartRoundEvent) {\n\t\t\tfor (Player p : getPlayerController().getAllPlayers()) {\n\t\t\t\tif(p.isAlive()) {\n\t\t\t\t\tkillPlayer(p);\n\t\t\t\t}\n\t\t\t\tgetPlayerController().reset(p);\n\t\t\t}\n\t\t\tgetWorldController().resetWorld();\n\t\t\tthis.roundStartTime = System.currentTimeMillis();\n\t\t\tmenuController.clearEventPanel();\n\t\t\tmenuController.updateScoreboard();\n\t\t\tgetBulletAppState().setEnabled(true);\n\t\t}else if (e instanceof RoundEndedEvent) {\n\t\t\tgetBulletAppState().setEnabled(false);\n\t\t\tRoundEndedEvent roundEnded = (RoundEndedEvent) e;\n\t\t\tfor (Player p : getPlayerController().getAllPlayers()) {\n\t\t\t\tp.setInputState(new PlayerInputState());\n\t\t\t}\n\t\t\twinTeam = roundEnded.getWinteam();\n\t\t\tsetGamestate(GameState.ROUNDOVER);\n\t\t\tmenuController.actualizeScreen();\n\t\t}else if(e instanceof FlagEvent) {\n\t\t\tFlagEvent flagev = (FlagEvent) e;\n\t\t\tif(flagev.getType() == FlagEvent.TAKE) {\n\t\t\t\tFlag f = getWorldController().getFlag(flagev.getFlagid());\n\t\t\t\tPlayer p = getPlayerController().getPlayer(flagev.getPlayerid());\n\t\t\t\ttakeFlag(p, f);\n\t\t\t}else if(flagev.getType() == FlagEvent.SCORE) {\n\t\t\t\tFlag f = getWorldController().getFlag(flagev.getFlagid());\n\t\t\t\tPlayer p = getPlayerController().getPlayer(flagev.getPlayerid());\n\t\t\t\tscoreFlag(p, f);\n\t\t\t\tmenuController.updateScoreboard();\n\t\t\t}else if(flagev.getType() == FlagEvent.RETURN) {\n\t\t\t\tFlag f = getWorldController().getFlag(flagev.getFlagid());\n\t\t\t\treturnFlag(f);\n\t\t\t}\n\t\t}else if(e instanceof BeamEvent) {\n\t\t\tBeamEvent beam = (BeamEvent) e;\n\t\t\tPlayer p = getPlayerController().getPlayer(beam.getSourceid());\n\t\t\tPlayer victim = getPlayerController().getPlayer(beam.getTargetid());\n\t\t\tbeam(p, victim);\n\t\t}else if(e instanceof RemoveEvent) {\n\t\t\tRemoveEvent remove = (RemoveEvent) e;\n\t\t\tif(\"flube\".equalsIgnoreCase(remove.getObjectType())) {\n\t\t\t\tFlube f = getWorldController().getFlube(remove.getObjectid());\n\t\t\t\tgetWorldController().removeFlube(f);\n\t\t\t}else if(\"flag\".equalsIgnoreCase(remove.getObjectType())) {\n\t\t\t\tFlag f = getWorldController().getFlag((int)remove.getObjectid());\n\t\t\t\tgetWorldController().removeFlag(f);\n\t\t\t}else if(\"spawnpoint\".equalsIgnoreCase(remove.getObjectType())) {\n\t\t\t\tSpawnPoint sp = getWorldController().getSpawnPoint((int)remove.getObjectid());\n\t\t\t\tgetWorldController().removeSpawnPoint(sp);\n\t\t\t}\n\t\t}else if(e instanceof AddEvent) {\n\t\t\tAddEvent add = (AddEvent) e;\n\t\t\tif(\"flube\".equalsIgnoreCase(add.getObjectType())) {\n\t\t\t\tFlube f = getWorldController().addNewFlube(add.getObjectid(), add.getLocation(), add.getObjectSpec());\n\t\t\t\tgetWorldController().attachFlube(f);\n\t\t\t}else if(\"flag\".equalsIgnoreCase(add.getObjectType())) {\n\t\t\t\tFlag f = getWorldController().addNewFlag((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());\n\t\t\t}else if(\"spawnpoint\".equalsIgnoreCase(add.getObjectType())) {\n\t\t\t\tSpawnPoint sp = getWorldController().addNewSpawnPoint((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());\n\t\t\t\tif(\"editor\".equalsIgnoreCase(getGameConfig().getString(\"mp_gamemode\"))) {\n\t\t\t\t\tsp.getNode().setCullHint(CullHint.Dynamic);\n\t\t\t\t}else {\n\t\t\t\t\tsp.getNode().setCullHint(CullHint.Always);\n\t\t\t\t}\n\t\t\t}\n\t\t}else if(e instanceof ConfigEvent) {\n\t\t\tConfigEvent event = (ConfigEvent) e;\n\t\t\tif(\"mp_gamemode\".equalsIgnoreCase(event.getKey())) {\n\t\t\t\tswitchGameMode((String)event.getNewValue());\n\t\t\t}else if(\"mp_scorelimit\".equalsIgnoreCase(event.getKey())) {\n\t\t\t\tgetGameConfig().putObject(\"mp_scorelimit\", (Integer) event.getNewValue());\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public void execute() {\n if(options.getTables() != null) {\n if(validateOptions()) {\n try {\n if(options.isDestination()) {\n exportService.exportTablesToDatasource(options.getTables(), options.getDestination(), !options.getNonIncremental());\n } else if(options.isOut()) {\n if(options.getOut().canWrite() == false) {\n System.console().printf(\"Cannot write to file %s\\n\", options.getOut().getName());\n } else {\n exportService.exportTablesToExcelFile(options.getTables(), options.getOut(), !options.getNonIncremental());\n }\n }\n } catch(ExportException e) {\n System.console().printf(\"%s\\n\", e.getMessage());\n System.err.println(e);\n } catch(NoSuchDatasourceException e) {\n System.console().printf(\"Destination datasource '%s' does not exist.\\n\", options.getDestination());\n } catch(NoSuchValueTableException e) {\n System.console().printf(\"%s\\n\", e.getMessage());\n System.err.println(e);\n } catch(UnsupportedOperationException e) {\n System.console().printf(\"%s\\n\", e.getMessage());\n }\n }\n } else {\n System.console().printf(\"%s\\n\", \"No table name(s) specified.\");\n }\n }\n", "output": " public void execute() {\n if(options.getTables() != null) {\n if(validateOptions()) {\n try {\n if(options.isDestination()) {\n exportService.exportTablesToDatasource(options.getTables(), options.getDestination(), !options.getNonIncremental());\n } else if(options.isOut()) {\n if(options.getOut().exists() && options.getOut().canWrite() == false) {\n System.console().printf(\"Cannot write to file %s %s %s\\n\", options.getOut().getName(), options.getOut().exists(), options.getOut().canWrite());\n } else {\n exportService.exportTablesToExcelFile(options.getTables(), options.getOut(), !options.getNonIncremental());\n }\n }\n } catch(ExportException e) {\n System.console().printf(\"%s\\n\", e.getMessage());\n System.err.println(e);\n } catch(NoSuchDatasourceException e) {\n System.console().printf(\"Destination datasource '%s' does not exist.\\n\", options.getDestination());\n } catch(NoSuchValueTableException e) {\n System.console().printf(\"%s\\n\", e.getMessage());\n System.err.println(e);\n } catch(UnsupportedOperationException e) {\n System.console().printf(\"%s\\n\", e.getMessage());\n }\n }\n } else {\n System.console().printf(\"%s\\n\", \"No table name(s) specified.\");\n }\n }\n"} {"input": "\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tSystem.out.println(\"Comment lancez le jeu ?\");\n\t\tSystem.out.println(\"1 - Console\");\n\t\tSystem.out.println(\"2 - Interface Graphique\");\n\t\tString choice = scan.nextLine();\n\t\tif (choice.equals(\"2\")) {\n\t\t\tGame model = new Game();\n\t\t\tGameGUI view = new GameGUI(model);\n\t\t\tview.setVisible(true);\n\t\t\tControllerGameGUI controller = new ControllerGameGUI(model, view);\n\t\t}\n\t\telse if (choice.equals(\"1\")) {\n\t\t\tGame model = new Game();\n\t\t\tConsoleHandGUI view1 = new ConsoleHandGUI();\n\t\t\tConsoleMatchGUI view2 = new ConsoleMatchGUI();\n\t\t\tController controller = new Controller(model, view1, view2);\n\t\t}\n\t}\n", "output": "\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tSystem.out.println(\"Comment voulez-vous lancer le jeu ?\");\n\t\tSystem.out.println(\"1 - Console\");\n\t\tSystem.out.println(\"2 - Interface Graphique\");\n\t\tString choice = scan.nextLine();\n\t\tif (choice.equals(\"2\")) {\n\t\t\tGame model = new Game();\n\t\t\tGameGUI view = new GameGUI(model);\n\t\t\tview.setVisible(true);\n\t\t\tControllerGameGUI controller = new ControllerGameGUI(model, view);\n\t\t}\n\t\telse if (choice.equals(\"1\")) {\n\t\t\tGame model = new Game();\n\t\t\tConsoleHandGUI view1 = new ConsoleHandGUI();\n\t\t\tConsoleMatchGUI view2 = new ConsoleMatchGUI();\n\t\t\tController controller = new Controller(model, view1, view2);\n\t\t}\n\t}\n"} {"input": "\tpublic List getCalendarEntries(String login, String password, String instanceId, Integer cacheTime, boolean remoteMode) {\n\t\tif (instanceId == null) {\n\t\t\treturn null;\n\t\t}\n\t\tif (remoteMode && (login == null || password == null)) {\n\t\t\treturn null;\n\t\t}\n\t\tIWContext iwc = CoreUtil.getIWContext();\n\t\tif (iwc == null) {\n\t\t\treturn null;\n\t\t}\n\t\tGroupService groupService = getGroupService(iwc);\n\t\tif (groupService == null) {\n\t\t\treturn null;\n\t\t}\n\t\tif (remoteMode && !groupService.isUserLoggedOn(iwc, login, password)) {\n\t\t\treturn null;\n\t\t}\n\t\tList groupsIds = null;\n\t\ttry {\n\t\t\tgroupsIds = groupService.getUniqueIds(calendarCacheName).get(instanceId);\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tList ledgersIds = null;\n\t\ttry {\n\t\t\tledgersIds = groupService.getUniqueIds(ledgersCacheName).get(instanceId);\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tList eventsIds = null;\n\t\ttry {\n\t\t\teventsIds = groupService.getUniqueIds(eventsCacheName).get(instanceId);\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tif (groupsIds == null) {\n\t\t\treturn null;\n\t\t}\n\t\tboolean useCache = cacheTime == null ? false : true;\n\t\tCalBusiness calBusiness = getCalBusiness(iwc);\n\t\tif (calBusiness == null) {\n\t\t\treturn null;\n\t\t}\n\t\tGroupBusiness groupBusiness = getGroupBusiness(iwc);\n\t\tif (groupBusiness == null) {\n\t\t\treturn null;\n\t\t}\n\t\tList entriesByGroup = new ArrayList();\n\t\tGroup group = null;\n\t\tCollection groupEntries = null;\n\t\tfor (int i = 0; i < entriesByGroup.size(); i++) {\n\t\t\tgroup = null;\n\t\t\tgroupEntries = null;\n\t\t\ttry {\n\t\t\t\tgroup = groupBusiness.getGroupByUniqueId(groupsIds.get(i));\n\t\t\t} catch (RemoteException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (FinderException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (group != null) {\n\t\t\t\ttry {\n\t\t\t\t\tgroupEntries = calBusiness.getEntriesByICGroup(Integer.valueOf(group.getId()).intValue());\n\t\t\t\t} catch(Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (groupEntries != null) {\n\t\t\t\tentriesByGroup.addAll(groupEntries);\n\t\t\t}\n\t\t}\n\t\tList entriesByEvents = new ArrayList();\n\t\tif (eventsIds != null) {\n\t\t\tCollection entries = null;\n\t\t\ttry {\n\t\t\t\tentries = calBusiness.getEntriesByEvents(eventsIds);\n\t\t\t} catch(Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (entries != null) {\n\t\t\t\tentriesByEvents.addAll(entries);\n\t\t\t}\n\t\t}\n\t\tList entriesByLedgers = new ArrayList();\n\t\tif (ledgersIds != null) {\n\t\t\tCollection entries = null;\n\t\t\tfor (int i = 0; i < ledgersIds.size(); i++) {\n\t\t\t\tentries = null;\n\t\t\t\ttry {\n\t\t\t\t\tentries = calBusiness.getEntriesByLedgerID(Integer.valueOf(ledgersIds.get(i)).intValue());\n\t\t\t\t} catch(Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tif (entries != null) {\n\t\t\t\t\tentriesByLedgers.addAll(entries);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tList allEntries = new ArrayList();\n\t\tallEntries.addAll(entriesByGroup);\n\t\tallEntries = getFilteredEntries(entriesByEvents, allEntries);\n\t\tallEntries = getFilteredEntries(entriesByLedgers, allEntries);\n\t\treturn getConvertedEntries(allEntries, iwc.getCurrentLocale());\n\t}\n", "output": "\tpublic List getCalendarEntries(String login, String password, String instanceId, Integer cacheTime, boolean remoteMode) {\n\t\tif (instanceId == null) {\n\t\t\treturn null;\n\t\t}\n\t\tif (remoteMode && (login == null || password == null)) {\n\t\t\treturn null;\n\t\t}\n\t\tIWContext iwc = CoreUtil.getIWContext();\n\t\tif (iwc == null) {\n\t\t\treturn null;\n\t\t}\n\t\tGroupService groupService = getGroupService(iwc);\n\t\tif (groupService == null) {\n\t\t\treturn null;\n\t\t}\n\t\tif (remoteMode && !groupService.isUserLoggedOn(iwc, login, password)) {\n\t\t\treturn null;\n\t\t}\n\t\tList groupsIds = null;\n\t\ttry {\n\t\t\tgroupsIds = groupService.getUniqueIds(calendarCacheName).get(instanceId);\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tList ledgersIds = null;\n\t\ttry {\n\t\t\tledgersIds = groupService.getUniqueIds(ledgersCacheName).get(instanceId);\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tList eventsIds = null;\n\t\ttry {\n\t\t\teventsIds = groupService.getUniqueIds(eventsCacheName).get(instanceId);\n\t\t} catch(Exception e) {\n\t\t\te.printStackTrace();\n\t\t\treturn null;\n\t\t}\n\t\tif (groupsIds == null) {\n\t\t\treturn null;\n\t\t}\n\t\tboolean useCache = cacheTime == null ? false : true;\n\t\tCalBusiness calBusiness = getCalBusiness(iwc);\n\t\tif (calBusiness == null) {\n\t\t\treturn null;\n\t\t}\n\t\tGroupBusiness groupBusiness = getGroupBusiness(iwc);\n\t\tif (groupBusiness == null) {\n\t\t\treturn null;\n\t\t}\n\t\tList entriesByGroup = new ArrayList();\n\t\tGroup group = null;\n\t\tCollection groupEntries = null;\n\t\tfor (int i = 0; i < groupsIds.size(); i++) {\n\t\t\tgroup = null;\n\t\t\tgroupEntries = null;\n\t\t\ttry {\n\t\t\t\tgroup = groupBusiness.getGroupByUniqueId(groupsIds.get(i));\n\t\t\t} catch (RemoteException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t} catch (FinderException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (group != null) {\n\t\t\t\ttry {\n\t\t\t\t\tgroupEntries = calBusiness.getEntriesByICGroup(Integer.valueOf(group.getId()).intValue());\n\t\t\t\t} catch(Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (groupEntries != null) {\n\t\t\t\tentriesByGroup.addAll(groupEntries);\n\t\t\t}\n\t\t}\n\t\tList entriesByEvents = new ArrayList();\n\t\tif (eventsIds != null) {\n\t\t\tCollection entries = null;\n\t\t\ttry {\n\t\t\t\tentries = calBusiness.getEntriesByEvents(eventsIds);\n\t\t\t} catch(Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t\tif (entries != null) {\n\t\t\t\tentriesByEvents.addAll(entries);\n\t\t\t}\n\t\t}\n\t\tList entriesByLedgers = new ArrayList();\n\t\tif (ledgersIds != null) {\n\t\t\tCollection entries = null;\n\t\t\tfor (int i = 0; i < ledgersIds.size(); i++) {\n\t\t\t\tentries = null;\n\t\t\t\ttry {\n\t\t\t\t\tentries = calBusiness.getEntriesByLedgerID(Integer.valueOf(ledgersIds.get(i)).intValue());\n\t\t\t\t} catch(Exception e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\tif (entries != null) {\n\t\t\t\t\tentriesByLedgers.addAll(entries);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tList allEntries = new ArrayList();\n\t\tallEntries.addAll(entriesByGroup);\n\t\tallEntries = getFilteredEntries(entriesByEvents, allEntries);\n\t\tallEntries = getFilteredEntries(entriesByLedgers, allEntries);\n\t\treturn getConvertedEntries(allEntries, iwc.getCurrentLocale());\n\t}\n"} {"input": " public static void initialize(Server server) {\n Plugin groupManager = server.getPluginManager().getPlugin(\"GroupManager\");\n Plugin permissions = server.getPluginManager().getPlugin(\"Permissions\");\n if (groupManager != null) {\n permissionPlugin = groupManager;\n handler = PermissionHandler.GROUP_MANAGER;\n String version = groupManager.getDescription().getVersion();\n BBLogging.info(\"Permissions enabled using: GroupManager v\" + version);\n } else if (permissions != null) {\n permissionPlugin = permissions;\n handler = PermissionHandler.PERMISSIONS;\n String version = permissions.getDescription().getVersion();\n BBLogging.info(\"Permissions enabled using: Permissions v\" + version);\n } else {\n BBLogging.severe(\"A permission plugin isn't loaded, only OPs can use commands\");\n }\n }\n", "output": " public static void initialize(Server server) {\n Plugin groupManager = server.getPluginManager().getPlugin(\"GroupManager\");\n Plugin permissions = server.getPluginManager().getPlugin(\"Permissions\");\n if (groupManager != null) {\n permissionPlugin = groupManager;\n handler = PermissionHandler.GROUP_MANAGER;\n String version = groupManager.getDescription().getVersion();\n BBLogging.info(\"Permissions enabled using: GroupManager v\" + version);\n } else if (permissions != null) {\n permissionPlugin = permissions;\n handler = PermissionHandler.PERMISSIONS;\n String version = permissions.getDescription().getVersion();\n BBLogging.info(\"Permissions enabled using: Permissions v\" + version);\n } else {\n handler = PermissionHandler.NONE;\n BBLogging.severe(\"A permission plugin isn't loaded, only OPs can use commands\");\n }\n }\n"} {"input": " static public void main(String[] args) throws Throwable\n {\n Log4jConfiguration.configure( \"log4j_datadock.xml\" );\n log.trace( \"DatadockMain main called\" );\n ConsoleAppender startupAppender = new ConsoleAppender(new SimpleLayout());\n boolean terminateOnZeroSubmitted = false;\n boolean ESHarvesterCleanup = false;\n try\n {\n harvestType = HarvestType.getHarvestType( System.getProperty( \"harvester\" ) );\n }\n catch( NullPointerException npe )\n {\n harvestType = defaultHarvestType;\n }\n if ( harvestType == null )\n {\n harvestType = defaultHarvestType;\n log.debug( String.format( \"getting harvestertype: %s form property\", harvestType ) );\n } \n for( String a : args )\n {\n log.warn( String.format( \"argument: '%s'\", a ) );\n if ( a.equals( \"--shutDownOnJobsDone\" ) )\n {\n terminateOnZeroSubmitted = true;\n }\n else\n {\n log.warn( String.format( \"Unknown argument '%s', ignoring it\", a ) );\n }\n }\n try\n {\n if ( System.getProperty( \"esharvester_cleanup\" ) != null )\n {\n ESHarvesterCleanup = true;\n }\n }\n catch( NullPointerException npe)\n {\n log.info( \"Test 1: catch\" );\n ESHarvesterCleanup = false;\n }\n if ( ESHarvesterCleanup )\n {\n log.info( \" ESHARVESTER CLEANUP! \" );\n }\n try\n {\n init();\n log.removeAppender( \"RootConsoleAppender\" );\n log.addAppender( startupAppender );\n log.info( \"Starting the datadock\" );\n log.trace( \"initializing resources\" );\n IDBConnection dbConnection = new PostgresqlDBConnection();\n IProcessqueue processqueue = new Processqueue( dbConnection );\n IObjectRepository repository = new FedoraObjectRepository();\n pluginResolver = new PluginResolver(); \n OracleDataSource ods;\n log.trace( \"Starting datadockPool\" );\n LinkedBlockingQueue queue = new LinkedBlockingQueue( queueSize );\n ThreadPoolExecutor threadpool = new ThreadPoolExecutor( corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS , queue );\n threadpool.purge();\n log.trace( \"Starting harvester\" );\n switch( harvestType )\n {\n case ESHarvest:\n log.trace( \"selecting ES\" );\n String dataBaseName = DataBaseConfig.getOracleDataBaseName();\n String oracleCacheName = DataBaseConfig.getOracleCacheName();\n String oracleUrl = DataBaseConfig.getOracleUrl();\n String oracleUser = DataBaseConfig.getOracleUserID();\n String oraclePassWd = DataBaseConfig.getOraclePassWd();\n String minLimit = DataBaseConfig.getOracleMinLimit();\n String maxLimit = DataBaseConfig.getOracleMaxLimit();\n String initialLimit = DataBaseConfig.getOracleInitialLimit();\n String connectionWaitTimeout = DataBaseConfig.getOracleConnectionWaitTimeout();\n log.info( String.format( \"DB Url : %s \", oracleUrl ) );\n log.info( String.format( \"DB User: %s \", oracleUser ) );\n try\n {\n ods = new OracleDataSource();\n ods.setURL( oracleUrl );\n ods.setUser( oracleUser );\n ods.setPassword( oraclePassWd );\n ods.setConnectionCachingEnabled( true ); \n ods.setConnectionCacheName( oracleCacheName );\n Properties cacheProperties = new Properties();\n cacheProperties.setProperty( \"MinLimit\", minLimit );\n cacheProperties.setProperty( \"MaxLimit\", maxLimit );\n cacheProperties.setProperty( \"InitialLimit\", initialLimit );\n cacheProperties.setProperty( \"ConnectionWaitTimeout\", connectionWaitTimeout );\n cacheProperties.setProperty( \"ValidateConnection\", \"true\" );\n ods.setConnectionCacheProperties( cacheProperties );\n }\n catch( SQLException sqle )\n {\n String errorMsg = new String( \"An SQL error occured during the setup of the OracleDataSource\" );\n log.fatal( errorMsg, sqle );\n throw sqle;\n }\n OracleDBPooledConnection connectionPool = new OracleDBPooledConnection( oracleCacheName, ods );\n harvester = new ESHarvest( connectionPool, dataBaseName ); \n if ( ESHarvesterCleanup )\n {\n ESHarvest esharvester = (ESHarvest)harvester;\n try\n {\n esharvester.changeRecordstatusFromInProgressToQueued();\n }\n catch( HarvesterIOException hioe )\n {\n String errorMsg = new String( \"An exception occured while performing 'changeRecordstatusFromInProgressToQueued'.\" );\n log.fatal( errorMsg, hioe );\n throw hioe;\n }\n }\n break;\n case FileHarvest:\n log.trace( \"selecting FileHarvest\" );\n harvester = new FileHarvest();\n break;\n case FileHarvestLight:\n log.trace( \"selecting FileHarvestLight\" );\n harvester = new FileHarvestLight();\n break;\n default:\n log.warn( \"no harvester explicitly selected, running with FileHarvest\" );\n harvester = new FileHarvest();\n }\n datadockPool = new DatadockPool( threadpool, processqueue, repository, harvester, pluginResolver );\n log.trace( \"Starting the manager\" );\n datadockManager = new DatadockManager( datadockPool, harvester );\n log.info( \"Daemonizing\" );\n daemonize();\n addDaemonShutdownHook();\n }\n catch ( Exception e )\n {\n System.out.println( \"Startup failed.\" + e );\n log.fatal( \"Startup failed.\", e);\n throw e;\n }\n finally\n {\n log.removeAppender( startupAppender );\n }\n long mainTimer = System.currentTimeMillis();\n int mainJobsSubmitted = 0;\n while( ! isShutdownRequested() )\n {\n try\n {\n log.trace( \"DatadockMain calling datadockManager update\" );\n long timer = System.currentTimeMillis();\n int jobsSubmited = datadockManager.update();\n timer = System.currentTimeMillis() - timer;\n mainJobsSubmitted += jobsSubmited;\n if ( jobsSubmited > 0 )\n {\n log.info(String.format( \"%1$d Jobs submittet in %2$d ms - %3$f jobs/s\", jobsSubmited, timer, jobsSubmited/ (timer / 1000.0 ) ) );\n }\n else\n {\n log.info( String.format( \"%1$d Jobs submittet in %2$d ms - \", jobsSubmited, timer ) );\n if ( terminateOnZeroSubmitted )\n {\n DatadockMain.shutdown();\n }\n else\n {\n Thread.currentThread();\n Thread.sleep( pollTime );\n }\n }\n }\n catch( HarvesterIOException hioe )\n {\n String fatal = String.format( \"A fatal error occured in the communication with the database, exiting.\" );\n log.fatal( fatal, hioe );\n DatadockMain.shutdown();\n } \n catch( InterruptedException ie )\n {\n log.error( \"InterruptedException caught in mainloop: \" + ie, ie);\n log.error( \" \" + ie.getMessage(), ie );\n }\n catch( RuntimeException re )\n {\n log.error( \"RuntimeException caught in mainloop: \" + re, re);\n log.error( \" \" + re.getCause().getMessage(), re);\n throw re;\n }\n catch( Exception e )\n {\n log.error( \"Exception caught in mainloop: \" + e.toString(), e );\n }\n }\n mainTimer = System.currentTimeMillis() - mainTimer;\n if ( mainJobsSubmitted > 0 )\n {\n log.info(String.format(\"Total: %1$d Jobs submittet in %2$d ms - %3$f jobs/s\", mainJobsSubmitted, mainTimer, mainJobsSubmitted/ (mainTimer / 1000.0)));\n }\n else\n {\n log.info(String.format(\"Total: %1$d Jobs submittet in %2$d ms - \", mainJobsSubmitted, mainTimer));\n }\n }\n", "output": " static public void main(String[] args) throws Throwable\n {\n Log4jConfiguration.configure( \"log4j_datadock.xml\" );\n log.trace( \"DatadockMain main called\" );\n ConsoleAppender startupAppender = new ConsoleAppender(new SimpleLayout());\n boolean terminateOnZeroSubmitted = false;\n boolean ESHarvesterCleanup = false;\n try\n {\n harvestType = HarvestType.getHarvestType( System.getProperty( \"harvester\" ) );\n }\n catch( NullPointerException npe )\n {\n harvestType = defaultHarvestType;\n }\n if ( harvestType == null )\n {\n harvestType = defaultHarvestType;\n log.debug( String.format( \"getting harvestertype: %s form property\", harvestType ) );\n } \n for( String a : args )\n {\n log.warn( String.format( \"argument: '%s'\", a ) );\n if ( a.equals( \"--shutDownOnJobsDone\" ) )\n {\n terminateOnZeroSubmitted = true;\n }\n else\n {\n log.warn( String.format( \"Unknown argument '%s', ignoring it\", a ) );\n }\n }\n try\n {\n if ( System.getProperty( \"esharvester_cleanup\" ) != null )\n {\n ESHarvesterCleanup = true;\n }\n }\n catch( NullPointerException npe)\n {\n log.info( \"Test 1: catch\" );\n ESHarvesterCleanup = false;\n }\n if ( ESHarvesterCleanup )\n {\n log.info( \" ESHARVESTER CLEANUP! \" );\n }\n try\n {\n init();\n log.removeAppender( \"RootConsoleAppender\" );\n log.addAppender( startupAppender );\n log.info( \"Starting the datadock\" );\n log.trace( \"initializing resources\" );\n IDBConnection dbConnection = new PostgresqlDBConnection();\n IProcessqueue processqueue = new Processqueue( dbConnection );\n IObjectRepository repository = new FedoraObjectRepository();\n pluginResolver = new PluginResolver(); \n OracleDataSource ods;\n log.trace( \"Starting datadockPool\" );\n LinkedBlockingQueue queue = new LinkedBlockingQueue( queueSize );\n ThreadPoolExecutor threadpool = new ThreadPoolExecutor( corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS , queue );\n threadpool.purge();\n log.trace( \"Starting harvester\" );\n switch( harvestType )\n {\n case ESHarvest:\n log.trace( \"selecting ES\" );\n String dataBaseName = DataBaseConfig.getOracleDataBaseName();\n String oracleCacheName = DataBaseConfig.getOracleCacheName();\n String oracleUrl = DataBaseConfig.getOracleUrl();\n String oracleUser = DataBaseConfig.getOracleUserID();\n String oraclePassWd = DataBaseConfig.getOraclePassWd();\n String minLimit = DataBaseConfig.getOracleMinLimit();\n String maxLimit = DataBaseConfig.getOracleMaxLimit();\n String initialLimit = DataBaseConfig.getOracleInitialLimit();\n String connectionWaitTimeout = DataBaseConfig.getOracleConnectionWaitTimeout();\n log.info( String.format( \"DB Url : %s \", oracleUrl ) );\n log.info( String.format( \"DB User: %s \", oracleUser ) );\n try\n {\n ods = new OracleDataSource();\n ods.setURL( oracleUrl );\n ods.setUser( oracleUser );\n ods.setPassword( oraclePassWd );\n ods.setConnectionCachingEnabled( true ); \n ods.setConnectionCacheName( oracleCacheName );\n Properties cacheProperties = new Properties();\n cacheProperties.setProperty( \"MinLimit\", minLimit );\n cacheProperties.setProperty( \"MaxLimit\", maxLimit );\n cacheProperties.setProperty( \"InitialLimit\", initialLimit );\n cacheProperties.setProperty( \"ConnectionWaitTimeout\", connectionWaitTimeout );\n cacheProperties.setProperty( \"ValidateConnection\", \"true\" );\n ods.setConnectionCacheProperties( cacheProperties );\n }\n catch( SQLException sqle )\n {\n String errorMsg = new String( \"An SQL error occured during the setup of the OracleDataSource\" );\n log.fatal( errorMsg, sqle );\n throw sqle;\n }\n OracleDBPooledConnection connectionPool = new OracleDBPooledConnection( oracleCacheName, ods );\n harvester = new ESHarvest( connectionPool, dataBaseName ); \n if ( ESHarvesterCleanup )\n {\n ESHarvest esharvester = (ESHarvest)harvester;\n try\n {\n esharvester.changeRecordstatusFromInProgressToQueued();\n }\n catch( HarvesterIOException hioe )\n {\n String errorMsg = new String( \"An exception occured while performing 'changeRecordstatusFromInProgressToQueued'.\" );\n log.fatal( errorMsg, hioe );\n throw hioe;\n }\n }\n break;\n case FileHarvest:\n log.trace( \"selecting FileHarvest\" );\n harvester = new FileHarvest();\n break;\n case FileHarvestLight:\n log.trace( \"selecting FileHarvestLight\" );\n harvester = new FileHarvestLight();\n break;\n default:\n log.warn( \"no harvester explicitly selected, running with FileHarvest\" );\n harvester = new FileHarvest();\n }\n datadockPool = new DatadockPool( threadpool, processqueue, repository, harvester, pluginResolver );\n log.trace( \"Starting the manager\" );\n datadockManager = new DatadockManager( datadockPool, harvester );\n log.info( \"Daemonizing\" );\n daemonize();\n addDaemonShutdownHook();\n }\n catch ( Exception e )\n {\n System.out.println( \"Startup failed.\" + e );\n log.fatal( \"Startup failed.\", e);\n throw e;\n }\n finally\n {\n log.removeAppender( startupAppender );\n }\n long mainTimer = System.currentTimeMillis();\n int mainJobsSubmitted = 0;\n while( ! isShutdownRequested() )\n {\n try\n {\n log.trace( \"DatadockMain calling datadockManager update\" );\n long timer = System.currentTimeMillis();\n int jobsSubmited = datadockManager.update();\n timer = System.currentTimeMillis() - timer;\n mainJobsSubmitted += jobsSubmited;\n if ( jobsSubmited > 0 )\n {\n log.info(String.format( \"%1$d Jobs submittet in %2$d ms - %3$f jobs/s\", jobsSubmited, timer, jobsSubmited/ (timer / 1000.0 ) ) );\n }\n else\n {\n log.info( String.format( \"%1$d Jobs submittet in %2$d ms - \", jobsSubmited, timer ) );\n if ( terminateOnZeroSubmitted )\n {\n DatadockMain.shutdown();\n }\n else\n {\n Thread.currentThread();\n Thread.sleep( pollTime );\n }\n }\n }\n catch( HarvesterIOException hioe )\n {\n String fatal = String.format( \"A fatal error occured in the communication with the database: %s\", hioe.getMessage() );\n log.fatal( fatal, hioe );\n DatadockMain.shutdown();\n } \n catch( InterruptedException ie )\n {\n log.error( String.format( \"InterruptedException caught in mainloop: %s\", ie.getMessage(), ie ) );\n }\n catch( RuntimeException re )\n {\n log.error( String.format( \"RuntimeException caught in mainloop: %s\", re.getMessage(), re ) );\n }\n catch( Exception e )\n {\n log.error( \"Exception caught in mainloop: \" + e.getMessage(), e );\n }\n }\n mainTimer = System.currentTimeMillis() - mainTimer;\n if ( mainJobsSubmitted > 0 )\n {\n log.info(String.format(\"Total: %1$d Jobs submittet in %2$d ms - %3$f jobs/s\", mainJobsSubmitted, mainTimer, mainJobsSubmitted/ (mainTimer / 1000.0)));\n }\n else\n {\n log.info(String.format(\"Total: %1$d Jobs submittet in %2$d ms - \", mainJobsSubmitted, mainTimer));\n }\n }\n"} {"input": "\tpublic void addValidOperations(TaskData bugReport) {\n\t\tTaskAttribute attributeStatus = bugReport.getRoot().getMappedAttribute(TaskAttribute.STATUS);\n\t\tBUGZILLA_REPORT_STATUS status = BUGZILLA_REPORT_STATUS.NEW;\n\t\tif (attributeStatus != null) {\n\t\t\ttry {\n\t\t\t\tstatus = BUGZILLA_REPORT_STATUS.valueOf(attributeStatus.getValue());\n\t\t\t} catch (RuntimeException e) {\n\t\t\t\tstatus = BUGZILLA_REPORT_STATUS.NEW;\n\t\t\t}\n\t\t}\n\t\tBugzillaVersion bugzillaVersion = getInstallVersion();\n\t\tif (bugzillaVersion == null) {\n\t\t\tbugzillaVersion = BugzillaVersion.MIN_VERSION;\n\t\t}\n\t\tswitch (status) {\n\t\tcase UNCONFIRMED:\n\t\tcase REOPENED:\n\t\tcase NEW:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.accept);\n\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\tbreak;\n\t\tcase ASSIGNED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\tbreak;\n\t\tcase RESOLVED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.reopen);\n\t\t\taddOperation(bugReport, BugzillaOperation.verify);\n\t\t\taddOperation(bugReport, BugzillaOperation.close);\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) >= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CLOSED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.reopen);\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) >= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase VERIFIED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.reopen);\n\t\t\taddOperation(bugReport, BugzillaOperation.close);\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) >= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\t}\n\t\t}\n\t\tif (bugzillaVersion.compareTo(BugzillaVersion.BUGZILLA_3_0) < 0) {\n\t\t\tTaskAttribute productAttribute = bugReport.getRoot().getMappedAttribute(BugzillaAttribute.PRODUCT.getKey());\n\t\t\tproductAttribute.getMetaData().setReadOnly(true);\n\t\t}\n\t\tif (status == BUGZILLA_REPORT_STATUS.NEW || status == BUGZILLA_REPORT_STATUS.ASSIGNED\n\t\t\t\t|| status == BUGZILLA_REPORT_STATUS.REOPENED || status == BUGZILLA_REPORT_STATUS.UNCONFIRMED) {\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) <= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.reassign);\n\t\t\t\taddOperation(bugReport, BugzillaOperation.reassignbycomponent);\n\t\t\t} else {\n\t\t\t\tBugzillaAttribute key = BugzillaAttribute.SET_DEFAULT_ASSIGNEE;\n\t\t\t\tTaskAttribute operationAttribute = bugReport.getRoot().getAttribute(key.getKey());\n\t\t\t\tif (operationAttribute == null) {\n\t\t\t\t\toperationAttribute = bugReport.getRoot().createAttribute(key.getKey());\n\t\t\t\t\toperationAttribute.getMetaData()\n\t\t\t\t\t\t\t.defaults()\n\t\t\t\t\t\t\t.setReadOnly(key.isReadOnly())\n\t\t\t\t\t\t\t.setKind(key.getKind())\n\t\t\t\t\t\t\t.setLabel(key.toString())\n\t\t\t\t\t\t\t.setType(key.getType());\n\t\t\t\t\toperationAttribute.setValue(\"0\"); \n\t\t\t\t}\n\t\t\t\toperationAttribute = bugReport.getRoot().getMappedAttribute(TaskAttribute.USER_ASSIGNED);\n\t\t\t\tif (operationAttribute != null) {\n\t\t\t\t\toperationAttribute.getMetaData().setReadOnly(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void addValidOperations(TaskData bugReport) {\n\t\tTaskAttribute attributeStatus = bugReport.getRoot().getMappedAttribute(TaskAttribute.STATUS);\n\t\tBUGZILLA_REPORT_STATUS status = BUGZILLA_REPORT_STATUS.NEW;\n\t\tif (attributeStatus != null) {\n\t\t\ttry {\n\t\t\t\tstatus = BUGZILLA_REPORT_STATUS.valueOf(attributeStatus.getValue());\n\t\t\t} catch (RuntimeException e) {\n\t\t\t\tstatus = BUGZILLA_REPORT_STATUS.NEW;\n\t\t\t}\n\t\t}\n\t\tBugzillaVersion bugzillaVersion = getInstallVersion();\n\t\tif (bugzillaVersion == null) {\n\t\t\tbugzillaVersion = BugzillaVersion.MIN_VERSION;\n\t\t}\n\t\tswitch (status) {\n\t\tcase UNCONFIRMED:\n\t\tcase REOPENED:\n\t\tcase NEW:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.accept);\n\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\tbreak;\n\t\tcase ASSIGNED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\tbreak;\n\t\tcase RESOLVED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.reopen);\n\t\t\taddOperation(bugReport, BugzillaOperation.verify);\n\t\t\taddOperation(bugReport, BugzillaOperation.close);\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) >= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CLOSED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.reopen);\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) >= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase VERIFIED:\n\t\t\taddOperation(bugReport, BugzillaOperation.none);\n\t\t\taddOperation(bugReport, BugzillaOperation.reopen);\n\t\t\taddOperation(bugReport, BugzillaOperation.close);\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) >= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.duplicate);\n\t\t\t\taddOperation(bugReport, BugzillaOperation.resolve);\n\t\t\t}\n\t\t}\n\t\tif (bugzillaVersion.compareTo(BugzillaVersion.BUGZILLA_3_0) < 0) {\n\t\t\tTaskAttribute productAttribute = bugReport.getRoot().getMappedAttribute(BugzillaAttribute.PRODUCT.getKey());\n\t\t\tproductAttribute.getMetaData().setReadOnly(true);\n\t\t}\n\t\tif (status == BUGZILLA_REPORT_STATUS.NEW || status == BUGZILLA_REPORT_STATUS.ASSIGNED\n\t\t\t\t|| status == BUGZILLA_REPORT_STATUS.REOPENED || status == BUGZILLA_REPORT_STATUS.UNCONFIRMED) {\n\t\t\tif (bugzillaVersion.compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_0) <= 0) {\n\t\t\t\taddOperation(bugReport, BugzillaOperation.reassign);\n\t\t\t\taddOperation(bugReport, BugzillaOperation.reassignbycomponent);\n\t\t\t} else {\n\t\t\t\tBugzillaAttribute key = BugzillaAttribute.SET_DEFAULT_ASSIGNEE;\n\t\t\t\tTaskAttribute operationAttribute = bugReport.getRoot().getAttribute(key.getKey());\n\t\t\t\tif (operationAttribute == null) {\n\t\t\t\t\toperationAttribute = bugReport.getRoot().createAttribute(key.getKey());\n\t\t\t\t\toperationAttribute.getMetaData()\n\t\t\t\t\t\t\t.defaults()\n\t\t\t\t\t\t\t.setReadOnly(key.isReadOnly())\n\t\t\t\t\t\t\t.setKind(key.getKind())\n\t\t\t\t\t\t\t.setLabel(key.toString())\n\t\t\t\t\t\t\t.setType(key.getType());\n\t\t\t\t\toperationAttribute.setValue(\"0\"); \n\t\t\t\t}\n\t\t\t\toperationAttribute = bugReport.getRoot().getMappedAttribute(TaskAttribute.USER_ASSIGNED);\n\t\t\t\tif (operationAttribute != null) {\n\t\t\t\t\toperationAttribute.getMetaData().setReadOnly(false);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tprotected Control createControl(Composite parent) {\n\t\tComposite composite = new Composite(parent, SWT.NULL);\n\t\tRowLayout layout = new RowLayout();\n\t\tcomposite.setLayout(layout);\n\t\tfinal Button[] radios = new Button[1];\n\t\tradios[0] = new Button(composite, SWT.CHECK);\n\t\tradios[0].setSelection(true);\n\t\tradios[0].setText(\"Switch Connections ON/OFF\");\n\t\tfinal Button dynamicTrendHighlightButton = new Button(composite, SWT.CHECK);\n\t\tdynamicTrendHighlightButton.setText(\"Dynamic Connection Highlight Focus\");\n\t\tfinal Slider slider = new Slider(composite, SWT.HORIZONTAL);\n\t\tslider.setValues(0, 0, 100, 1, 1, 1);\n\t\tslider.setLayoutData(new RowData(130, 20));\n\t\tListener listener = new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tif (dynamicTrendHighlightButton.getSelection() == false)\n\t\t\t\t\tslider.setEnabled(false);\n\t\t\t\telse\n\t\t\t\t\tslider.setEnabled(true);\n\t\t\t\tGeneralManager\n\t\t\t\t\t\t.get()\n\t\t\t\t\t\t.getEventPublisher()\n\t\t\t\t\t\t.triggerEvent(\n\t\t\t\t\t\t\t\tnew ConnectionsModeEvent(radios[0].getSelection(),\n\t\t\t\t\t\t\t\t\t\tdynamicTrendHighlightButton.getSelection(),\n\t\t\t\t\t\t\t\t\t\tslider.getSelection() / 100f));\n\t\t\t}\n\t\t};\n\t\tslider.addListener(SWT.Selection, listener);\n\t\tdynamicTrendHighlightButton.addListener(SWT.Selection, listener);\n\t\tradios[0].addListener(SWT.Selection, listener);\n\t\treturn composite;\n\t};\n", "output": "\tprotected Control createControl(Composite parent) {\n\t\tComposite composite = new Composite(parent, SWT.NULL);\n\t\tRowLayout layout = new RowLayout();\n\t\tcomposite.setLayout(layout);\n\t\tfinal Button[] radios = new Button[1];\n\t\tradios[0] = new Button(composite, SWT.CHECK);\n\t\tradios[0].setSelection(true);\n\t\tradios[0].setText(\"Switch Connections ON/OFF\");\n\t\tfinal Button dynamicTrendHighlightButton = new Button(composite, SWT.CHECK);\n\t\tdynamicTrendHighlightButton.setText(\"Dynamic Connection Highlight Focus\");\n\t\tfinal Slider slider = new Slider(composite, SWT.HORIZONTAL);\n\t\tslider.setValues(0, 0, 100, 1, 1, 1);\n\t\tslider.setLayoutData(new RowData(130, 20));\n\t\tslider.setEnabled(false);\n\t\tListener listener = new Listener() {\n\t\t\t@Override\n\t\t\tpublic void handleEvent(Event event) {\n\t\t\t\tslider.setEnabled(dynamicTrendHighlightButton.getSelection());\n\t\t\t\tGeneralManager\n\t\t\t\t\t\t.get()\n\t\t\t\t\t\t.getEventPublisher()\n\t\t\t\t\t\t.triggerEvent(\n\t\t\t\t\t\t\t\tnew ConnectionsModeEvent(radios[0].getSelection(),\n\t\t\t\t\t\t\t\t\t\tdynamicTrendHighlightButton.getSelection(),\n\t\t\t\t\t\t\t\t\t\tslider.getSelection() / 100f));\n\t\t\t}\n\t\t};\n\t\tslider.addListener(SWT.Selection, listener);\n\t\tdynamicTrendHighlightButton.addListener(SWT.Selection, listener);\n\t\tradios[0].addListener(SWT.Selection, listener);\n\t\treturn composite;\n\t};\n"} {"input": "\tpublic void updateEntity()\n\t{\n\t\tsuper.updateEntity();\n\t\tif (!this.isDisabled())\n\t\t{\n\t\t\tForgeDirection inputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2).getOpposite();\n\t\t\tTileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), inputDirection);\n\t\t\tElectricityNetwork inputNetwork = ElectricityNetwork.getNetworkFromTileEntity(inputTile, inputDirection);\n\t\t\tif (!this.worldObj.isRemote)\n\t\t\t{\n\t\t\t\tif (inputNetwork != null)\n\t\t\t\t{\n\t\t\t\t\tif (this.joules >= this.getMaxJoules())\n\t\t\t\t\t{\n\t\t\t\t\t\tinputNetwork.stopRequesting(this);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tinputNetwork.startRequesting(this, Math.min((this.getMaxJoules() - this.getJoules()), 10000) / this.getVoltage(), this.getVoltage());\n\t\t\t\t\t\tElectricityPack electricityPack = inputNetwork.consumeElectricity(this);\n\t\t\t\t\t\tthis.setJoules(this.joules + electricityPack.getWatts());\n\t\t\t\t\t\tif (UniversalElectricity.isVoltageSensitive)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (electricityPack.voltage > this.getVoltage())\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tthis.worldObj.createExplosion(null, this.xCoord, this.yCoord, this.zCoord, 2f, true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.containingItems[0] != null && this.joules > 0)\n\t\t\t{\n\t\t\t\tif (this.containingItems[0].getItem() instanceof IItemElectric)\n\t\t\t\t{\n\t\t\t\t\tIItemElectric electricItem = (IItemElectric) this.containingItems[0].getItem();\n\t\t\t\t\tdouble ampsToGive = Math.min(ElectricInfo.getAmps(electricItem.getMaxJoules(this.containingItems[0]) * 0.005, this.getVoltage()), this.joules);\n\t\t\t\t\tdouble joules = electricItem.onReceive(ampsToGive, this.getVoltage(), this.containingItems[0]);\n\t\t\t\t\tthis.setJoules(this.joules - (ElectricInfo.getJoules(ampsToGive, this.getVoltage(), 1) - joules));\n\t\t\t\t}\n\t\t\t}\n\t\t\tboolean isFullThisCheck = false;\n\t\t\tif (this.joules >= this.getMaxJoules())\n\t\t\t{\n\t\t\t\tisFullThisCheck = true;\n\t\t\t}\n\t\t\tif (this.isFull != isFullThisCheck)\n\t\t\t{\n\t\t\t\tthis.isFull = isFullThisCheck;\n\t\t\t\tthis.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, BasicComponents.blockMachine.blockID);\n\t\t\t}\n\t\t\tif (this.containingItems[1] != null && this.joules < this.getMaxJoules())\n\t\t\t{\n\t\t\t\tif (this.containingItems[1].getItem() instanceof IItemElectric)\n\t\t\t\t{\n\t\t\t\t\tIItemElectric electricItem = (IItemElectric) this.containingItems[1].getItem();\n\t\t\t\t\tif (electricItem.canProduceElectricity())\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble joulesReceived = electricItem.onUse(electricItem.getMaxJoules(this.containingItems[1]) * 0.005, this.containingItems[1]);\n\t\t\t\t\t\tthis.setJoules(this.joules + joulesReceived);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!this.worldObj.isRemote)\n\t\t\t{\n\t\t\t\tForgeDirection outputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2);\n\t\t\t\tTileEntity outputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), outputDirection);\n\t\t\t\tElectricityNetwork outputNetwork = ElectricityNetwork.getNetworkFromTileEntity(outputTile, outputDirection);\n\t\t\t\tif (outputNetwork != null && inputNetwork != outputNetwork)\n\t\t\t\t{\n\t\t\t\t\tdouble outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(this.getJoules(), 10000));\n\t\t\t\t\tif (this.getJoules() > 0 && outputWatts > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\toutputNetwork.startProducing(this, outputWatts / this.getVoltage(), this.getVoltage());\n\t\t\t\t\t\tthis.setJoules(this.joules - outputWatts);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\toutputNetwork.stopProducing(this);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.setJoules(this.joules - 0.0005);\n\t\tif (!this.worldObj.isRemote)\n\t\t{\n\t\t\tif (this.ticks % 3 == 0 && this.playersUsing > 0)\n\t\t\t{\n\t\t\t\tPacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 12);\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void updateEntity()\n\t{\n\t\tsuper.updateEntity();\n\t\tif (!this.isDisabled())\n\t\t{\n\t\t\tForgeDirection inputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2).getOpposite();\n\t\t\tTileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), inputDirection);\n\t\t\tElectricityNetwork inputNetwork = ElectricityNetwork.getNetworkFromTileEntity(inputTile, inputDirection);\n\t\t\tif (!this.worldObj.isRemote)\n\t\t\t{\n\t\t\t\tif (inputNetwork != null)\n\t\t\t\t{\n\t\t\t\t\tif (this.joules >= this.getMaxJoules())\n\t\t\t\t\t{\n\t\t\t\t\t\tinputNetwork.stopRequesting(this);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tinputNetwork.startRequesting(this, Math.min((this.getMaxJoules() - this.getJoules()), 10000) / this.getVoltage(), this.getVoltage());\n\t\t\t\t\t\tElectricityPack electricityPack = inputNetwork.consumeElectricity(this);\n\t\t\t\t\t\tthis.setJoules(this.joules + electricityPack.getWatts());\n\t\t\t\t\t\tif (UniversalElectricity.isVoltageSensitive)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (electricityPack.voltage > this.getVoltage())\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tthis.worldObj.createExplosion(null, this.xCoord, this.yCoord, this.zCoord, 2f, true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.containingItems[0] != null && this.joules > 0)\n\t\t\t{\n\t\t\t\tif (this.containingItems[0].getItem() instanceof IItemElectric)\n\t\t\t\t{\n\t\t\t\t\tIItemElectric electricItem = (IItemElectric) this.containingItems[0].getItem();\n\t\t\t\t\tdouble ampsToGive = Math.min(ElectricInfo.getAmps(Math.min(electricItem.getMaxJoules(this.containingItems[0]) * 0.005, this.getJoules()), this.getVoltage()), this.joules);\n\t\t\t\t\tdouble joules = electricItem.onReceive(ampsToGive, this.getVoltage(), this.containingItems[0]);\n\t\t\t\t\tthis.setJoules(this.joules - (ElectricInfo.getJoules(ampsToGive, this.getVoltage(), 1) - joules));\n\t\t\t\t}\n\t\t\t}\n\t\t\tboolean isFullThisCheck = false;\n\t\t\tif (this.joules >= this.getMaxJoules())\n\t\t\t{\n\t\t\t\tisFullThisCheck = true;\n\t\t\t}\n\t\t\tif (this.isFull != isFullThisCheck)\n\t\t\t{\n\t\t\t\tthis.isFull = isFullThisCheck;\n\t\t\t\tthis.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, BasicComponents.blockMachine.blockID);\n\t\t\t}\n\t\t\tif (this.containingItems[1] != null && this.joules < this.getMaxJoules())\n\t\t\t{\n\t\t\t\tif (this.containingItems[1].getItem() instanceof IItemElectric)\n\t\t\t\t{\n\t\t\t\t\tIItemElectric electricItem = (IItemElectric) this.containingItems[1].getItem();\n\t\t\t\t\tif (electricItem.canProduceElectricity())\n\t\t\t\t\t{\n\t\t\t\t\t\tdouble joulesReceived = electricItem.onUse(electricItem.getMaxJoules(this.containingItems[1]) * 0.005, this.containingItems[1]);\n\t\t\t\t\t\tthis.setJoules(this.joules + joulesReceived);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!this.worldObj.isRemote)\n\t\t\t{\n\t\t\t\tForgeDirection outputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockBasicMachine.BATTERY_BOX_METADATA + 2);\n\t\t\t\tTileEntity outputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), outputDirection);\n\t\t\t\tElectricityNetwork outputNetwork = ElectricityNetwork.getNetworkFromTileEntity(outputTile, outputDirection);\n\t\t\t\tif (outputNetwork != null && inputNetwork != outputNetwork)\n\t\t\t\t{\n\t\t\t\t\tdouble outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(this.getJoules(), 10000));\n\t\t\t\t\tif (this.getJoules() > 0 && outputWatts > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\toutputNetwork.startProducing(this, outputWatts / this.getVoltage(), this.getVoltage());\n\t\t\t\t\t\tthis.setJoules(this.joules - outputWatts);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\toutputNetwork.stopProducing(this);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.setJoules(this.joules - 0.0005);\n\t\tif (!this.worldObj.isRemote)\n\t\t{\n\t\t\tif (this.ticks % 3 == 0 && this.playersUsing > 0)\n\t\t\t{\n\t\t\t\tPacketManager.sendPacketToClients(getDescriptionPacket(), this.worldObj, new Vector3(this), 12);\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " private JTabbedPane initJTPRequest(){\n JTabbedPane jtp = new JTabbedPane();\n ButtonGroup bg = new ButtonGroup();\n bg.add(jrb_req_get);\n bg.add(jrb_req_post);\n bg.add(jrb_req_put);\n bg.add(jrb_req_delete);\n bg.add(jrb_req_head);\n bg.add(jrb_req_options);\n bg.add(jrb_req_trace);\n jrb_req_get.setSelected(true);\n jrb_req_get.setMnemonic('g');\n jrb_req_post.setMnemonic('p');\n jrb_req_put.setMnemonic('t');\n jrb_req_delete.setMnemonic('d');\n ActionListener jrbAL = new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n if(jrb_req_post.isSelected() || jrb_req_put.isSelected()){\n setUIReqBodyEnabled(true);\n }\n else{\n setUIReqBodyEnabled(false);\n }\n }\n };\n jrb_req_get.addActionListener(jrbAL);\n jrb_req_post.addActionListener(jrbAL);\n jrb_req_put.addActionListener(jrbAL);\n jrb_req_delete.addActionListener(jrbAL);\n jrb_req_head.addActionListener(jrbAL);\n jrb_req_options.addActionListener(jrbAL);\n jrb_req_trace.addActionListener(jrbAL);\n JPanel jp_method_encp = new JPanel();\n jp_method_encp.setLayout(new FlowLayout(FlowLayout.LEFT));\n JPanel jp_method = new JPanel();\n jp_method.setBorder(BorderFactory.createTitledBorder(\"HTTP Method\"));\n jp_method.setLayout(new GridLayout(4, 2));\n jp_method.add(jrb_req_get);\n jp_method.add(jrb_req_post);\n jp_method.add(jrb_req_put);\n jp_method.add(jrb_req_delete);\n jp_method.add(jrb_req_head);\n jp_method.add(jrb_req_options);\n jp_method.add(jrb_req_trace);\n jp_method_encp.add(jp_method);\n jtp.addTab(\"Method\", jp_method_encp);\n jp_2col_req_headers = new TwoColumnTablePanel(new String[]{\"Header\", \"Value\"}, rest_ui);\n jtp.addTab(\"Headers\", jp_2col_req_headers);\n setUIReqBodyEnabled(false); \n JPanel jp_body = new JPanel();\n jp_body.setLayout(new BorderLayout());\n JPanel jp_body_north = new JPanel();\n jp_body_north.setLayout(new FlowLayout(FlowLayout.LEFT));\n jtf_body_content_type.setEditable(false);\n jtf_body_content_type.setColumns(24);\n jtf_body_content_type.setToolTipText(\"Selected Content-type & Charset\");\n jtf_body_content_type.setText(Util.getFormattedContentType(\n jd_body_content_type.getContentType(),\n jd_body_content_type.getCharSet()));\n jp_body_north.add(jtf_body_content_type);\n jb_body_content_type.setToolTipText(\"Edit Content-type & Charset\");\n jb_body_content_type.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n jd_body_content_type.setVisible(true);\n }\n });\n jp_body_north.add(jb_body_content_type);\n JSeparator js = new JSeparator(SwingConstants.VERTICAL);\n jp_body_north.add(js);\n jb_body_file.setToolTipText(\"Load from file\");\n jb_body_file.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent event) {\n jb_body_fileActionPerformed(event);\n }\n });\n jp_body_north.add(jb_body_file);\n jb_body_params.setToolTipText(\"Insert parameters\");\n jb_body_params.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent event) {\n jb_body_paramActionPerformed(event);\n }\n });\n jp_body_north.add(jb_body_params);\n final JPopupMenu jpm_req_body = new JPopupMenu();\n JMenu jm_syntax = new JMenu(\"Syntax Color\");\n JMenuItem jmi_syntax_none = new JMenuItem(\"None\");\n jmi_syntax_none.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n actionTextEditorSyntaxChange(se_req_body, TextEditorSyntax.DEFAULT);\n }\n });\n jm_syntax.add(jmi_syntax_none);\n JMenuItem jmi_syntax_xml = new JMenuItem(\"XML\");\n jmi_syntax_xml.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n actionTextEditorSyntaxChange(se_req_body, TextEditorSyntax.XML);\n }\n });\n jm_syntax.add(jmi_syntax_xml);\n JMenuItem jmi_syntax_json = new JMenuItem(\"JSON\");\n jmi_syntax_json.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n actionTextEditorSyntaxChange(se_req_body, TextEditorSyntax.JSON);\n }\n });\n jm_syntax.add(jmi_syntax_json);\n jpm_req_body.add(jm_syntax);\n if (se_req_body.getEditorComponent() instanceof JEditorPane) {\n se_req_body.getEditorComponent().addMouseListener(new MouseAdapter() {\n @Override\n public void mousePressed(MouseEvent e) {\n showPopup(e);\n }\n @Override\n public void mouseReleased(MouseEvent e) {\n showPopup(e);\n }\n private void showPopup(final MouseEvent e) {\n if(!se_req_body.getEditorComponent().isEnabled()){\n return;\n }\n if (e.isPopupTrigger()) {\n jpm_req_body.show(e.getComponent(), e.getX(), e.getY());\n }\n }\n });\n }\n jp_body.add(jp_body_north, BorderLayout.NORTH);\n JPanel jp_body_center = new JPanel();\n jp_body_center.setLayout(new GridLayout(1, 1));\n jp_body_center.add(se_req_body.getEditorView());\n jp_body.add(jp_body_center, BorderLayout.CENTER);\n jtp.addTab(\"Body\", jp_body);\n JPanel jp_auth = new JPanel();\n jp_auth.setLayout(new BorderLayout());\n JPanel jp_auth_west = new JPanel();\n jp_auth_west.setLayout(new BorderLayout());\n JPanel jp_auth_west_center = new JPanel();\n jp_auth_west_center.setBorder(BorderFactory.createTitledBorder(\"Auth Type\"));\n jp_auth_west_center.setLayout(new GridLayout(2,1));\n jcb_auth_basic.setSelected(false);\n ActionListener action = new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent event) {\n auth_enableActionPerformed(event);\n }\n };\n jcb_auth_basic.addActionListener(action);\n jcb_auth_digest.addActionListener(action);\n jp_auth_west_center.add(jcb_auth_basic);\n jp_auth_west_center.add(jcb_auth_digest);\n jp_auth_west.add(jp_auth_west_center, BorderLayout.CENTER);\n JPanel jp_auth_west_south = new JPanel();\n jp_auth_west_south.setBorder(BorderFactory.createTitledBorder(\"Preemptive?\"));\n jp_auth_west_south.setLayout(new GridLayout(1, 1));\n jcb_auth_preemptive.setToolTipText(\"Send authentication credentials before challenge\");\n jcb_auth_preemptive.setSelected(true);\n jcb_auth_preemptive.setEnabled(false);\n jp_auth_west_south.add(jcb_auth_preemptive);\n jp_auth_west.add(jp_auth_west_south, BorderLayout.SOUTH);\n jp_auth.add(jp_auth_west, BorderLayout.WEST);\n JPanel jp_auth_center = new JPanel();\n jp_auth_center.setBorder(BorderFactory.createTitledBorder(\"Details\"));\n jp_auth_center.setLayout(new BorderLayout());\n JPanel jp_auth_center_west = new JPanel();\n jp_auth_center_west.setLayout(new GridLayout(4, 1, BORDER_WIDTH, BORDER_WIDTH));\n jl_auth_host.setEnabled(false);\n jl_auth_realm.setEnabled(false);\n jl_auth_username.setEnabled(false);\n jl_auth_password.setEnabled(false);\n jp_auth_center_west.add(jl_auth_host);\n jp_auth_center_west.add(jl_auth_realm);\n jp_auth_center_west.add(jl_auth_username);\n jp_auth_center_west.add(jl_auth_password);\n jp_auth_center.add(jp_auth_center_west, BorderLayout.WEST);\n JPanel jp_auth_center_center = new JPanel();\n jp_auth_center_center.setLayout(new GridLayout(4, 1, BORDER_WIDTH, BORDER_WIDTH));\n jtf_auth_host.setEnabled(false);\n jtf_auth_realm.setEnabled(false);\n jtf_auth_username.setEnabled(false);\n jpf_auth_password.setEnabled(false);\n jp_auth_center_center.add(jtf_auth_host);\n jp_auth_center_center.add(jtf_auth_realm);\n jp_auth_center_center.add(jtf_auth_username);\n jp_auth_center_center.add(jpf_auth_password);\n jp_auth_center.add(jp_auth_center_center, BorderLayout.CENTER);\n jp_auth.add(jp_auth_center, BorderLayout.CENTER);\n JPanel jp_auth_encp = new JPanel();\n jp_auth_encp.setLayout(new FlowLayout(FlowLayout.LEFT));\n jp_auth_encp.add(jp_auth);\n jtp.addTab(\"Auth\", jp_auth_encp);\n JPanel jp_ssl = new JPanel();\n jp_ssl.setLayout(new BorderLayout(BORDER_WIDTH, 2));\n JPanel jp_ssl_west = new JPanel();\n jp_ssl_west.setLayout(new GridLayout(3, 1));\n jp_ssl_west.add(UIUtil.getFlowLayoutPanelLeftAligned(new JLabel(\"Trust store file:\")));\n jp_ssl_west.add(UIUtil.getFlowLayoutPanelLeftAligned(new JLabel(\"Trust store password:\")));\n jp_ssl_west.add(UIUtil.getFlowLayoutPanelLeftAligned(new JLabel(\"Hostname verifier:\")));\n jp_ssl.add(jp_ssl_west, BorderLayout.WEST);\n JPanel jp_ssl_center = new JPanel();\n jp_ssl_center.setLayout(new GridLayout(3, 1));\n JPanel jp_ssl_center_flow = UIUtil.getFlowLayoutPanelLeftAligned(jtf_ssl_truststore_file);\n jb_ssl_browse.setToolTipText(\"Open truststore file.\");\n jb_ssl_browse.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n File f = rest_ui.getOpenFile(FileChooserType.OPEN_GENERIC);\n if(f == null){\n }\n else if(f.canRead()){\n jtf_ssl_truststore_file.setText(f.getAbsolutePath());\n }\n else{\n setStatusMessage(\"Truststore file cannot be read.\");\n }\n }\n });\n jp_ssl_center_flow.add(jb_ssl_browse);\n jp_ssl_center.add(jp_ssl_center_flow);\n jp_ssl_center.add(UIUtil.getFlowLayoutPanelLeftAligned(jpf_ssl_truststore_pwd));\n jp_ssl_center.add(UIUtil.getFlowLayoutPanelLeftAligned(jcb_ssl_hostname_verifier));\n jp_ssl.add(jp_ssl_center, BorderLayout.CENTER);\n jtp.addTab(\"SSL\", UIUtil.getFlowLayoutPanelLeftAligned(\"SSL Trust Store Configuration\", jp_ssl));\n JPanel jp_etc = new JPanel();\n jp_etc.setLayout(new GridLayout(2, 1));\n { \n JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT));\n jp.add(new JLabel(\"HTTP Version: \"));\n jp.add(jcb_http_version);\n jp_etc.add(jp);\n }\n { \n JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT));\n jp.add(jcb_followRedirects);\n jp_etc.add(jp);\n }\n { \n JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT));\n jp.add(jp_etc);\n jtp.add(\"Etc.\", jp);\n }\n JPanel jp_test = new JPanel();\n jp_test.setLayout(new BorderLayout());\n JPanel jp_test_north = new JPanel();\n jp_test_north.setLayout(new FlowLayout(FlowLayout.LEFT));\n jb_req_test_template.setToolTipText(\"Insert Template\");\n jb_req_test_template.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n String t = se_test_script.getText();\n if(!StringUtil.isStrEmpty(t)){\n JOptionPane.showMessageDialog(rest_ui.getFrame(),\n \"Script text already present! Please clear existing script!\",\n \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n se_test_script.setText(templateTestScript);\n se_test_script.setCaretPosition(0);\n }\n });\n jp_test_north.add(jb_req_test_template);\n jb_req_test_open.setToolTipText(\"Open Test Script From File\");\n jb_req_test_open.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n String str = se_test_script.getText();\n if(!StringUtil.isStrEmpty(str)){\n int ret = JOptionPane.showConfirmDialog(rest_ui.getFrame(), \"Script already exists. Erase?\", \"Erase existing script?\", JOptionPane.YES_NO_OPTION);\n if(ret == JOptionPane.NO_OPTION){\n return;\n }\n }\n File f = rest_ui.getOpenFile(FileChooserType.OPEN_TEST_SCRIPT);\n if(f == null){ \n return;\n }\n if(!f.canRead()){\n JOptionPane.showMessageDialog(rest_ui.getFrame(),\n \"IO Error (Read permission denied): \" + f.getAbsolutePath(),\n \"IO Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n try{\n String testScript = FileUtil.getContentAsString(f, Charsets.UTF_8);\n se_test_script.setText(testScript);\n se_test_script.setCaretPosition(0);\n }\n catch(IOException ex){\n showError(Util.getStackTrace(ex));\n }\n }\n });\n jp_test_north.add(jb_req_test_open);\n jp_test_north.add(new JSeparator(JSeparator.VERTICAL));\n jb_req_test_run.setToolTipText(\"Run Test\");\n jb_req_test_run.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n if(StringUtil.isStrEmpty(se_test_script.getText())){\n JOptionPane.showMessageDialog(rest_ui.getFrame(),\n \"No script!\", \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n if(jd_runTestDialog == null){\n jd_runTestDialog = new RunTestDialog(rest_ui);\n }\n jd_runTestDialog.setVisible(true);\n }\n });\n jp_test_north.add(jb_req_test_run);\n jb_req_test_quick.setToolTipText(\"Quick Run Test-Using last request & response\");\n jb_req_test_quick.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n if(lastRequest == null || lastResponse == null){\n JOptionPane.showMessageDialog(rest_ui.getFrame(), \"No Last Request/Response\", \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n String testScript = se_test_script.getText();\n if(StringUtil.isStrEmpty(testScript)){\n JOptionPane.showMessageDialog(rest_ui.getFrame(), \"No Script\", \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n runClonedRequestTest(lastRequest, lastResponse);\n }\n });\n jp_test_north.add(jb_req_test_quick);\n jp_test.add(jp_test_north, BorderLayout.NORTH);\n jp_test.add(se_test_script.getEditorView(), BorderLayout.CENTER);\n jtp.addTab(\"Test Script\", jp_test);\n return jtp;\n }\n", "output": " private JTabbedPane initJTPRequest(){\n JTabbedPane jtp = new JTabbedPane();\n ButtonGroup bg = new ButtonGroup();\n bg.add(jrb_req_get);\n bg.add(jrb_req_post);\n bg.add(jrb_req_put);\n bg.add(jrb_req_delete);\n bg.add(jrb_req_head);\n bg.add(jrb_req_options);\n bg.add(jrb_req_trace);\n jrb_req_get.setSelected(true);\n jrb_req_get.setMnemonic('g');\n jrb_req_post.setMnemonic('p');\n jrb_req_put.setMnemonic('t');\n jrb_req_delete.setMnemonic('d');\n ActionListener jrbAL = new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n if(jrb_req_post.isSelected() || jrb_req_put.isSelected()){\n setUIReqBodyEnabled(true);\n }\n else{\n setUIReqBodyEnabled(false);\n }\n }\n };\n jrb_req_get.addActionListener(jrbAL);\n jrb_req_post.addActionListener(jrbAL);\n jrb_req_put.addActionListener(jrbAL);\n jrb_req_delete.addActionListener(jrbAL);\n jrb_req_head.addActionListener(jrbAL);\n jrb_req_options.addActionListener(jrbAL);\n jrb_req_trace.addActionListener(jrbAL);\n JPanel jp_method_encp = new JPanel();\n jp_method_encp.setLayout(new FlowLayout(FlowLayout.LEFT));\n JPanel jp_method = new JPanel();\n jp_method.setBorder(BorderFactory.createTitledBorder(\"HTTP Method\"));\n jp_method.setLayout(new GridLayout(4, 2));\n jp_method.add(jrb_req_get);\n jp_method.add(jrb_req_post);\n jp_method.add(jrb_req_put);\n jp_method.add(jrb_req_delete);\n jp_method.add(jrb_req_head);\n jp_method.add(jrb_req_options);\n jp_method.add(jrb_req_trace);\n jp_method_encp.add(jp_method);\n jtp.addTab(\"Method\", jp_method_encp);\n jp_2col_req_headers = new TwoColumnTablePanel(new String[]{\"Header\", \"Value\"}, rest_ui);\n jtp.addTab(\"Headers\", jp_2col_req_headers);\n setUIReqBodyEnabled(false); \n JPanel jp_body = new JPanel();\n jp_body.setLayout(new BorderLayout());\n JPanel jp_body_north = new JPanel();\n jp_body_north.setLayout(new FlowLayout(FlowLayout.LEFT));\n jtf_body_content_type.setEditable(false);\n jtf_body_content_type.setColumns(24);\n jtf_body_content_type.setToolTipText(\"Selected Content-type & Charset\");\n jtf_body_content_type.setText(Util.getFormattedContentType(\n jd_body_content_type.getContentType(),\n jd_body_content_type.getCharSet()));\n jp_body_north.add(jtf_body_content_type);\n jb_body_content_type.setToolTipText(\"Edit Content-type & Charset\");\n jb_body_content_type.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n jd_body_content_type.setVisible(true);\n }\n });\n jp_body_north.add(jb_body_content_type);\n JSeparator js = new JSeparator(SwingConstants.VERTICAL);\n jp_body_north.add(js);\n jb_body_file.setToolTipText(\"Load from file\");\n jb_body_file.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent event) {\n jb_body_fileActionPerformed(event);\n }\n });\n jp_body_north.add(jb_body_file);\n jb_body_params.setToolTipText(\"Insert parameters\");\n jb_body_params.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent event) {\n jb_body_paramActionPerformed(event);\n }\n });\n jp_body_north.add(jb_body_params);\n final JPopupMenu jpm_req_body = new JPopupMenu();\n JMenu jm_syntax = new JMenu(\"Syntax Color\");\n JMenuItem jmi_syntax_none = new JMenuItem(\"None\");\n jmi_syntax_none.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n actionTextEditorSyntaxChange(se_req_body, TextEditorSyntax.DEFAULT);\n }\n });\n jm_syntax.add(jmi_syntax_none);\n JMenuItem jmi_syntax_xml = new JMenuItem(\"XML\");\n jmi_syntax_xml.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n actionTextEditorSyntaxChange(se_req_body, TextEditorSyntax.XML);\n }\n });\n jm_syntax.add(jmi_syntax_xml);\n JMenuItem jmi_syntax_json = new JMenuItem(\"JSON\");\n jmi_syntax_json.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n actionTextEditorSyntaxChange(se_req_body, TextEditorSyntax.JSON);\n }\n });\n jm_syntax.add(jmi_syntax_json);\n jpm_req_body.add(jm_syntax);\n if (se_req_body.getEditorComponent() instanceof JEditorPane) {\n se_req_body.getEditorComponent().addMouseListener(new MouseAdapter() {\n @Override\n public void mousePressed(MouseEvent e) {\n showPopup(e);\n }\n @Override\n public void mouseReleased(MouseEvent e) {\n showPopup(e);\n }\n private void showPopup(final MouseEvent e) {\n if(!se_req_body.getEditorComponent().isEnabled()){\n return;\n }\n if (e.isPopupTrigger()) {\n jpm_req_body.show(e.getComponent(), e.getX(), e.getY());\n }\n }\n });\n }\n jp_body.add(jp_body_north, BorderLayout.NORTH);\n JPanel jp_body_center = new JPanel();\n jp_body_center.setLayout(new GridLayout(1, 1));\n jp_body_center.add(se_req_body.getEditorView());\n jp_body.add(jp_body_center, BorderLayout.CENTER);\n jtp.addTab(\"Body\", jp_body);\n JPanel jp_auth = new JPanel();\n jp_auth.setLayout(new BorderLayout());\n JPanel jp_auth_west = new JPanel();\n jp_auth_west.setLayout(new BorderLayout());\n JPanel jp_auth_west_center = new JPanel();\n jp_auth_west_center.setBorder(BorderFactory.createTitledBorder(\"Auth Type\"));\n jp_auth_west_center.setLayout(new GridLayout(2,1));\n jcb_auth_basic.setSelected(false);\n ActionListener action = new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent event) {\n auth_enableActionPerformed(event);\n }\n };\n jcb_auth_basic.addActionListener(action);\n jcb_auth_digest.addActionListener(action);\n jp_auth_west_center.add(jcb_auth_basic);\n jp_auth_west_center.add(jcb_auth_digest);\n jp_auth_west.add(jp_auth_west_center, BorderLayout.CENTER);\n JPanel jp_auth_west_south = new JPanel();\n jp_auth_west_south.setBorder(BorderFactory.createTitledBorder(\"Preemptive?\"));\n jp_auth_west_south.setLayout(new GridLayout(1, 1));\n jcb_auth_preemptive.setToolTipText(\"Send authentication credentials before challenge\");\n jcb_auth_preemptive.setSelected(true);\n jcb_auth_preemptive.setEnabled(false);\n jp_auth_west_south.add(jcb_auth_preemptive);\n jp_auth_west.add(jp_auth_west_south, BorderLayout.SOUTH);\n jp_auth.add(jp_auth_west, BorderLayout.WEST);\n JPanel jp_auth_center = new JPanel();\n jp_auth_center.setBorder(BorderFactory.createTitledBorder(\"Details\"));\n jp_auth_center.setLayout(new BorderLayout());\n JPanel jp_auth_center_west = new JPanel();\n jp_auth_center_west.setLayout(new GridLayout(4, 1, BORDER_WIDTH, BORDER_WIDTH));\n jl_auth_host.setEnabled(false);\n jl_auth_realm.setEnabled(false);\n jl_auth_username.setEnabled(false);\n jl_auth_password.setEnabled(false);\n jp_auth_center_west.add(jl_auth_host);\n jp_auth_center_west.add(jl_auth_realm);\n jp_auth_center_west.add(jl_auth_username);\n jp_auth_center_west.add(jl_auth_password);\n jp_auth_center.add(jp_auth_center_west, BorderLayout.WEST);\n JPanel jp_auth_center_center = new JPanel();\n jp_auth_center_center.setLayout(new GridLayout(4, 1, BORDER_WIDTH, BORDER_WIDTH));\n jtf_auth_host.setEnabled(false);\n jtf_auth_realm.setEnabled(false);\n jtf_auth_username.setEnabled(false);\n jpf_auth_password.setEnabled(false);\n jp_auth_center_center.add(jtf_auth_host);\n jp_auth_center_center.add(jtf_auth_realm);\n jp_auth_center_center.add(jtf_auth_username);\n jp_auth_center_center.add(jpf_auth_password);\n jp_auth_center.add(jp_auth_center_center, BorderLayout.CENTER);\n jp_auth.add(jp_auth_center, BorderLayout.CENTER);\n JPanel jp_auth_encp = new JPanel();\n jp_auth_encp.setLayout(new FlowLayout(FlowLayout.LEFT));\n jp_auth_encp.add(jp_auth);\n jtp.addTab(\"Auth\", jp_auth_encp);\n JPanel jp_ssl = new JPanel();\n jp_ssl.setLayout(new BorderLayout(BORDER_WIDTH, 2));\n JPanel jp_ssl_west = new JPanel();\n jp_ssl_west.setLayout(new GridLayout(3, 1));\n jp_ssl_west.add(UIUtil.getFlowLayoutPanelLeftAligned(new JLabel(\"Trust store file:\")));\n jp_ssl_west.add(UIUtil.getFlowLayoutPanelLeftAligned(new JLabel(\"Trust store password:\")));\n jp_ssl_west.add(UIUtil.getFlowLayoutPanelLeftAligned(new JLabel(\"Hostname verifier:\")));\n jp_ssl.add(jp_ssl_west, BorderLayout.WEST);\n JPanel jp_ssl_center = new JPanel();\n jp_ssl_center.setLayout(new GridLayout(3, 1));\n JPanel jp_ssl_center_flow = UIUtil.getFlowLayoutPanelLeftAligned(jtf_ssl_truststore_file);\n jb_ssl_browse.setToolTipText(\"Open truststore file.\");\n jb_ssl_browse.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent arg0) {\n File f = rest_ui.getOpenFile(FileChooserType.OPEN_GENERIC);\n if(f == null){\n }\n else if(f.canRead()){\n jtf_ssl_truststore_file.setText(f.getAbsolutePath());\n }\n else{\n setStatusMessage(\"Truststore file cannot be read.\");\n }\n }\n });\n jp_ssl_center_flow.add(jb_ssl_browse);\n jp_ssl_center.add(jp_ssl_center_flow);\n jp_ssl_center.add(UIUtil.getFlowLayoutPanelLeftAligned(jpf_ssl_truststore_pwd));\n jp_ssl_center.add(UIUtil.getFlowLayoutPanelLeftAligned(jcb_ssl_hostname_verifier));\n jp_ssl.add(jp_ssl_center, BorderLayout.CENTER);\n jtp.addTab(\"SSL\", UIUtil.getFlowLayoutPanelLeftAligned(\"SSL Trust Store Configuration\", jp_ssl));\n JPanel jp_etc = new JPanel();\n jp_etc.setLayout(new GridLayout(2, 1));\n { \n JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT));\n jp.add(new JLabel(\"HTTP Version: \"));\n jp.add(jcb_http_version);\n jp_etc.add(jp);\n }\n { \n JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT));\n jcb_followRedirects.setSelected(true);\n jp.add(jcb_followRedirects);\n jp_etc.add(jp);\n }\n { \n JPanel jp = new JPanel(new FlowLayout(FlowLayout.LEFT));\n jp.add(jp_etc);\n jtp.add(\"Etc.\", jp);\n }\n JPanel jp_test = new JPanel();\n jp_test.setLayout(new BorderLayout());\n JPanel jp_test_north = new JPanel();\n jp_test_north.setLayout(new FlowLayout(FlowLayout.LEFT));\n jb_req_test_template.setToolTipText(\"Insert Template\");\n jb_req_test_template.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n String t = se_test_script.getText();\n if(!StringUtil.isStrEmpty(t)){\n JOptionPane.showMessageDialog(rest_ui.getFrame(),\n \"Script text already present! Please clear existing script!\",\n \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n se_test_script.setText(templateTestScript);\n se_test_script.setCaretPosition(0);\n }\n });\n jp_test_north.add(jb_req_test_template);\n jb_req_test_open.setToolTipText(\"Open Test Script From File\");\n jb_req_test_open.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n String str = se_test_script.getText();\n if(!StringUtil.isStrEmpty(str)){\n int ret = JOptionPane.showConfirmDialog(rest_ui.getFrame(), \"Script already exists. Erase?\", \"Erase existing script?\", JOptionPane.YES_NO_OPTION);\n if(ret == JOptionPane.NO_OPTION){\n return;\n }\n }\n File f = rest_ui.getOpenFile(FileChooserType.OPEN_TEST_SCRIPT);\n if(f == null){ \n return;\n }\n if(!f.canRead()){\n JOptionPane.showMessageDialog(rest_ui.getFrame(),\n \"IO Error (Read permission denied): \" + f.getAbsolutePath(),\n \"IO Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n try{\n String testScript = FileUtil.getContentAsString(f, Charsets.UTF_8);\n se_test_script.setText(testScript);\n se_test_script.setCaretPosition(0);\n }\n catch(IOException ex){\n showError(Util.getStackTrace(ex));\n }\n }\n });\n jp_test_north.add(jb_req_test_open);\n jp_test_north.add(new JSeparator(JSeparator.VERTICAL));\n jb_req_test_run.setToolTipText(\"Run Test\");\n jb_req_test_run.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n if(StringUtil.isStrEmpty(se_test_script.getText())){\n JOptionPane.showMessageDialog(rest_ui.getFrame(),\n \"No script!\", \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n if(jd_runTestDialog == null){\n jd_runTestDialog = new RunTestDialog(rest_ui);\n }\n jd_runTestDialog.setVisible(true);\n }\n });\n jp_test_north.add(jb_req_test_run);\n jb_req_test_quick.setToolTipText(\"Quick Run Test-Using last request & response\");\n jb_req_test_quick.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n if(lastRequest == null || lastResponse == null){\n JOptionPane.showMessageDialog(rest_ui.getFrame(), \"No Last Request/Response\", \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n String testScript = se_test_script.getText();\n if(StringUtil.isStrEmpty(testScript)){\n JOptionPane.showMessageDialog(rest_ui.getFrame(), \"No Script\", \"Error\", JOptionPane.ERROR_MESSAGE);\n return;\n }\n runClonedRequestTest(lastRequest, lastResponse);\n }\n });\n jp_test_north.add(jb_req_test_quick);\n jp_test.add(jp_test_north, BorderLayout.NORTH);\n jp_test.add(se_test_script.getEditorView(), BorderLayout.CENTER);\n jtp.addTab(\"Test Script\", jp_test);\n return jtp;\n }\n"} {"input": " public Resolution save() {\n layer.getDetails().clear();\n for(Map.Entry e: details.entrySet()) {\n layer.getDetails().put(e.getKey(), new ClobElement(e.getValue()));\n }\n layer.getReaders().clear();\n for (String groupName : groupsRead) {\n layer.getReaders().add(groupName);\n }\n layer.getWriters().clear();\n for (String groupName : groupsWrite) {\n layer.getWriters().add(groupName);\n }\n layer.setFeatureType(simpleFeatureType);\n Stripersist.getEntityManager().persist(layer);\n layer.getService().authorizationsModified();\n Stripersist.getEntityManager().getTransaction().commit();\n getContext().getMessages().add(new SimpleMessage(\"De kaartlaag is opgeslagen\"));\n return new ForwardResolution(JSP);\n }\n", "output": " public Resolution save() {\n layer.getDetails().keySet().removeAll(Arrays.asList(\n Layer.EXTRA_KEY_METADATA_STYLESHEET_URL,\n Layer.EXTRA_KEY_DOWNLOAD_URL,\n Layer.EXTRA_KEY_FILTERABLE\n ));\n for(Map.Entry e: details.entrySet()) {\n if(e.getValue() != null) { \n layer.getDetails().put(e.getKey(), new ClobElement(e.getValue()));\n }\n }\n layer.getReaders().clear();\n for (String groupName : groupsRead) {\n layer.getReaders().add(groupName);\n }\n layer.getWriters().clear();\n for (String groupName : groupsWrite) {\n layer.getWriters().add(groupName);\n }\n layer.setFeatureType(simpleFeatureType);\n Stripersist.getEntityManager().persist(layer);\n layer.getService().authorizationsModified();\n Stripersist.getEntityManager().getTransaction().commit();\n getContext().getMessages().add(new SimpleMessage(\"De kaartlaag is opgeslagen\"));\n return new ForwardResolution(JSP);\n }\n"} {"input": " public void onBlockIgnite(BlockIgniteEvent event) {\n IgniteCause cause = event.getCause();\n Block block = event.getBlock();\n Player player = event.getPlayer();\n World world = block.getWorld();\n boolean isFireSpread = cause == IgniteCause.SLOW_SPREAD\n || cause == IgniteCause.SPREAD;\n if (plugin.preventLavaFire && cause == IgniteCause.LAVA) {\n event.setCancelled(true);\n return;\n }\n if (plugin.disableFireSpread) {\n event.setCancelled(true);\n return;\n }\n if (plugin.blockLighter && cause == IgniteCause.FLINT_AND_STEEL) {\n event.setCancelled(true);\n return;\n }\n if (plugin.fireSpreadDisableToggle && isFireSpread) {\n event.setCancelled(true);\n return;\n }\n if (plugin.disableFireSpreadBlocks.size() > 0 && isFireSpread) {\n int x = block.getX();\n int y = block.getY();\n int z = block.getZ();\n if (plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y - 1, z))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x + 1, y, z))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x - 1, y, z))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z - 1))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z + 1))) {\n event.setCancelled(true);\n return;\n }\n }\n if (plugin.useRegions && player != null && !plugin.hasPermission(player, \"/regionbypass\")) {\n Vector pt = toVector(block);\n LocalPlayer localPlayer = plugin.wrapPlayer(player);\n if (cause == IgniteCause.FLINT_AND_STEEL\n && !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {\n event.setCancelled(true);\n return;\n }\n if (cause == IgniteCause.FLINT_AND_STEEL\n && !plugin.regionManager.getApplicableRegions(pt).allowsLighter()) {\n event.setCancelled(true);\n return;\n }\n }\n }\n", "output": " public void onBlockIgnite(BlockIgniteEvent event) {\n IgniteCause cause = event.getCause();\n Block block = event.getBlock();\n Player player = event.getPlayer();\n World world = block.getWorld();\n boolean isFireSpread = cause == IgniteCause.SLOW_SPREAD\n || cause == IgniteCause.SPREAD;\n if (plugin.preventLavaFire && cause == IgniteCause.LAVA) {\n event.setCancelled(true);\n return;\n }\n if (plugin.disableFireSpread && isFireSpread) {\n event.setCancelled(true);\n return;\n }\n if (plugin.blockLighter && cause == IgniteCause.FLINT_AND_STEEL) {\n event.setCancelled(true);\n return;\n }\n if (plugin.fireSpreadDisableToggle && isFireSpread) {\n event.setCancelled(true);\n return;\n }\n if (plugin.disableFireSpreadBlocks.size() > 0 && isFireSpread) {\n int x = block.getX();\n int y = block.getY();\n int z = block.getZ();\n if (plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y - 1, z))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x + 1, y, z))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x - 1, y, z))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z - 1))\n || plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z + 1))) {\n event.setCancelled(true);\n return;\n }\n }\n if (plugin.useRegions && player != null && !plugin.hasPermission(player, \"/regionbypass\")) {\n Vector pt = toVector(block);\n LocalPlayer localPlayer = plugin.wrapPlayer(player);\n if (cause == IgniteCause.FLINT_AND_STEEL\n && !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {\n event.setCancelled(true);\n return;\n }\n if (cause == IgniteCause.FLINT_AND_STEEL\n && !plugin.regionManager.getApplicableRegions(pt).allowsLighter()) {\n event.setCancelled(true);\n return;\n }\n }\n }\n"} {"input": " public void act(WEATHER Weather) {\n boolean walked = false;\n if (diseased) {\n int temp = sight;\n sight = 4;\n findNearbyLife();\n for (Lifeform l : nearbyLife) {\n l.disease();\n }\n sight = temp;\n hunger = hunger + 20;\n thirst = thirst + 20;\n } else {\n if (Math.random() < 0.01) {\n disease();\n }\n }\n findNearbyLife();\n findWater();\n findFood(nearbyLife);\n findMate(nearbyLife);\n hunger = hunger + 1;\n thirst = thirst + 1;\n if (hunger > 70 || thirst > 70) {\n setDestination();\n }\n if (Weather == WEATHER.NIGHT && !nocturnal) {\n } else {\n final Point location = summative.getLocation(this);\n if (destination == null || getDirection(destination) == DIRECTION.SOUTH) {\n Point temp = new Point(location.x, location.y + 1);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n } else if (getDirection(destination) == DIRECTION.NORTH) {\n Point temp = new Point(location.x, location.y - 1);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n } else if (getDirection(destination) == DIRECTION.WEST) {\n Point temp = new Point(location.x - 1, location.y);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n } else if (getDirection(destination) == DIRECTION.EAST) {\n Point temp = new Point(location.x + 1, location.y);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n }\n if (walked == false) {\n Point tempS = new Point(location.x, location.y + 1);\n Point tempN = new Point(location.x, location.y - 1);\n Point tempW = new Point(location.x - 1, location.y);\n Point tempE = new Point(location.x + 1, location.y);\n boolean S = true;\n boolean W = true;\n boolean N = true;\n boolean E = true;\n int counter = 0;\n while (!walked) {\n double x = Math.random();\n if (x < 0.25 && canWalk(tempS)) {\n summative.move(tempS, this);\n walked = true;\n } else if (S && !canWalk(tempS)) {\n S = false;\n counter = counter + 1;\n } else if (x < 0.5 && canWalk(tempN)) {\n summative.move(tempN, this);\n walked = true;\n } else if (N && !canWalk(tempN)) {\n S = false;\n counter = counter + 1;\n } else if (x < 0.75 && canWalk(tempW)) {\n summative.move(tempW, this);\n walked = true;\n } else if (W && !canWalk(tempW)) {\n W = false;\n counter = counter + 1;\n } else if (canWalk(tempE)) {\n summative.move(tempE, this);\n walked = true;\n } else if (E && !canWalk(tempE)) {\n E = false;\n counter = counter + 1;\n }\n if (counter == 4) {\n walked = true;\n }\n }\n }\n if (destination != null\n && Math.abs(destination.x - location.x) <= 1 && Math.abs(destination.y - location.y) <= 1\n && Math.abs(destination.x - location.x) + Math.abs(destination.y - location.y) < 2) {\n {\n if (destination == water) {\n thirst = 0;\n setDestination();\n } else if (destination == food) {\n hunger = hunger - 30;\n setDestination();\n if (summative.lifeGet(destination) instanceof Tree) {\n Tree temp = (Tree) (summative.lifeGet(destination));\n if (temp.getCurrent() <= 0) {\n temp.changeHealth(-50);\n } else {\n temp.changeCurrent(-1);\n }\n } else if (isPrey(summative.grassGet(destination))) {\n Grass tempg = summative.grassGet(destination);\n if (tempg.getCurrent() <= 0) {\n tempg.changeHealth(-50);\n } else {\n tempg.changeCurrent(-1);\n }\n } else {\n summative.kill(destination);\n }\n } else if (destination == mate) {\n hunger = hunger + 30;\n reproduce();\n setDestination();\n } else if (destination == murder) {\n summative.lifeGet(destination).suicide();\n setDestination();\n }\n }\n }\n }\n if (hunger > 100 || thirst > 100) {\n suicide();\n } else if (drowning()) {\n suicide();\n }\n }\n", "output": " public void act(WEATHER Weather) {\n boolean walked = false;\n if (diseased) {\n int temp = sight;\n sight = 4;\n findNearbyLife();\n for (Lifeform l : nearbyLife) {\n l.disease();\n }\n sight = temp;\n hunger = hunger + 20;\n thirst = thirst + 20;\n } else {\n if (Math.random() < 0.01) {\n disease();\n }\n }\n findNearbyLife();\n findWater();\n findFood(nearbyLife);\n findMate(nearbyLife);\n hunger = hunger + 1;\n thirst = thirst + 1;\n if (hunger > 70 || thirst > 70) {\n setDestination();\n }\n if (Weather == WEATHER.NIGHT && !nocturnal) {\n } else {\n final Point location = summative.getLocation(this);\n if (destination == null || getDirection(destination) == DIRECTION.SOUTH) {\n Point temp = new Point(location.x, location.y + 1);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n } else if (getDirection(destination) == DIRECTION.NORTH) {\n Point temp = new Point(location.x, location.y - 1);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n } else if (getDirection(destination) == DIRECTION.WEST) {\n Point temp = new Point(location.x - 1, location.y);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n } else if (getDirection(destination) == DIRECTION.EAST) {\n Point temp = new Point(location.x + 1, location.y);\n if (canWalk(temp)) {\n walked = true;\n summative.move(temp, this);\n }\n }\n if (walked == false) {\n Point tempS = new Point(location.x, location.y + 1);\n Point tempN = new Point(location.x, location.y - 1);\n Point tempW = new Point(location.x - 1, location.y);\n Point tempE = new Point(location.x + 1, location.y);\n boolean S = true;\n boolean W = true;\n boolean N = true;\n boolean E = true;\n int counter = 0;\n while (!walked) {\n double x = Math.random();\n if (x < 0.25 && canWalk(tempS)) {\n summative.move(tempS, this);\n walked = true;\n } else if (S && !canWalk(tempS)) {\n S = false;\n counter = counter + 1;\n } else if (x < 0.5 && canWalk(tempN)) {\n summative.move(tempN, this);\n walked = true;\n } else if (N && !canWalk(tempN)) {\n S = false;\n counter = counter + 1;\n } else if (x < 0.75 && canWalk(tempW)) {\n summative.move(tempW, this);\n walked = true;\n } else if (W && !canWalk(tempW)) {\n W = false;\n counter = counter + 1;\n } else if (canWalk(tempE)) {\n summative.move(tempE, this);\n walked = true;\n } else if (E && !canWalk(tempE)) {\n E = false;\n counter = counter + 1;\n }\n if (counter == 4) {\n walked = true;\n }\n }\n }\n if (destination != null\n && Math.abs(destination.x - location.x) <= 1 && Math.abs(destination.y - location.y) <= 1\n && Math.abs(destination.x - location.x) + Math.abs(destination.y - location.y) < 2) {\n {\n if (destination == water) {\n thirst = 0;\n setDestination();\n } else if (destination == food) {\n hunger = hunger - 30;\n setDestination();\n if (summative.lifeGet(destination) instanceof Tree) {\n Tree temp = (Tree) (summative.lifeGet(destination));\n if (temp.getCurrent() <= 0) {\n temp.changeHealth(-50);\n } else {\n temp.changeCurrent(-1);\n }\n } else if (preyList.contains(Grass.class) && summative.lifeGet(destination) instanceof Grass) {\n Grass tempg = summative.grassGet(destination);\n if (tempg.getCurrent() <= 0) {\n tempg.changeHealth(-50);\n } else {\n tempg.changeCurrent(-1);\n }\n } else {\n summative.kill(destination);\n }\n } else if (destination == mate) {\n hunger = hunger + 30;\n reproduce();\n setDestination();\n } else if (destination == murder) {\n summative.lifeGet(destination).suicide();\n setDestination();\n }\n }\n }\n }\n if (hunger > 100 || thirst > 100) {\n suicide();\n } else if (drowning()) {\n suicide();\n }\n }\n"} {"input": " private Record convertLineToRecord(String line) {\n String tokens[] = splitFields(line);\n if (tokens.length != format.getFields().size() && !autoID) {\n throw new SessionInternalError(\"Mismatch of number of fields between \" +\n \"the format and the file for line \" + line + \" Expected \" + \n format.getFields().size() + \" found \" + tokens.length);\n }\n if (removeQuote) {\n for (int f = 0; f < tokens.length; f++) {\n if (tokens[f].length() < 2) {\n continue;\n }\n if ((tokens[f].charAt(0) == '\\\"' || tokens[f].charAt(0) == '\\'') &&\n (tokens[f].charAt(tokens[f].length() - 1) == '\\\"' || tokens[f].charAt(tokens[f].length() - 1) == '\\'')) {\n tokens[f] = tokens[f].substring(1, tokens[f].length() - 1);\n }\n }\n }\n Record record = new Record();\n int tkIdx = 0;\n for (FormatField field:format.getFields()) {\n if (autoID && field.getIsKey()) {\n record.addField(new PricingField(field.getName(),\n files[fileIndex].getName() + \"-\" + counter ), field.getIsKey());\n continue;\n }\n switch (PricingField.mapType(field.getType())) {\n case STRING:\n record.addField(new PricingField(field.getName(),\n tokens[tkIdx++]), field.getIsKey());\n break;\n case INTEGER:\n String intStr = tokens[tkIdx++].trim();\n if (field.getDurationFormat() != null && field.getDurationFormat().length() > 0) {\n record.addField(new PricingField(field.getName(), intStr.length() > 0 ?\n convertDuration(intStr, field.getDurationFormat()) : null),\n field.getIsKey());\n } else {\n try {\n record.addField(new PricingField(field.getName(), intStr.length() > 0 ?\n Integer.valueOf(intStr.trim()) : null), field.getIsKey());\n } catch (NumberFormatException e) {\n throw new SessionInternalError(\"Converting to integer \" + field + \n \" line \" + line, AbstractFileReader.class, e);\n }\n }\n break;\n case DATE:\n try {\n String dateStr = tokens[tkIdx++];\n record.addField(new PricingField(field.getName(), dateStr.length() > 0 ?\n dateFormat.parse(dateStr) : null), field.getIsKey());\n } catch (ParseException e) {\n throw new SessionInternalError(\"Using format: \" + dateFormat + \"[\" +\n parameters.get(\"date_format\") + \"]\", \n AbstractFileReader.class,e);\n }\n break;\n case DECIMAL:\n String floatStr = tokens[tkIdx++].trim();\n record.addField(new PricingField(field.getName(), floatStr.length() > 0 ?\n new BigDecimal(floatStr) : null), field.getIsKey());\n break;\n case BOOLEAN:\n boolean value = \"true\".equalsIgnoreCase(tokens[tkIdx++].trim());\n record.addField(new PricingField(field.getName(), value), field.getIsKey());\n break;\n }\n }\n record.setPosition(counter);\n return record;\n }\n", "output": " private Record convertLineToRecord(String line) {\n String tokens[] = splitFields(line);\n if (tokens.length != format.getFields().size() && !autoID) {\n throw new SessionInternalError(\"Mismatch of number of fields between \" +\n \"the format and the file for line \" + line + \" Expected \" + \n format.getFields().size() + \" found \" + tokens.length);\n }\n if (removeQuote) {\n for (int f = 0; f < tokens.length; f++) {\n if (tokens[f].length() < 2) {\n continue;\n }\n if ((tokens[f].charAt(0) == '\\\"' || tokens[f].charAt(0) == '\\'') &&\n (tokens[f].charAt(tokens[f].length() - 1) == '\\\"' || tokens[f].charAt(tokens[f].length() - 1) == '\\'')) {\n tokens[f] = tokens[f].substring(1, tokens[f].length() - 1);\n }\n }\n }\n Record record = new Record();\n int tkIdx = 0;\n for (FormatField field:format.getFields()) {\n if (autoID && field.getIsKey()) {\n record.addField(new PricingField(field.getName(),\n files[fileIndex].getName() + \"-\" + counter ), field.getIsKey());\n tkIdx++;\n continue;\n }\n switch (PricingField.mapType(field.getType())) {\n case STRING:\n record.addField(new PricingField(field.getName(),\n tokens[tkIdx++]), field.getIsKey());\n break;\n case INTEGER:\n String intStr = tokens[tkIdx++].trim();\n if (field.getDurationFormat() != null && field.getDurationFormat().length() > 0) {\n record.addField(new PricingField(field.getName(), intStr.length() > 0 ?\n convertDuration(intStr, field.getDurationFormat()) : null),\n field.getIsKey());\n } else {\n try {\n record.addField(new PricingField(field.getName(), intStr.length() > 0 ?\n Integer.valueOf(intStr.trim()) : null), field.getIsKey());\n } catch (NumberFormatException e) {\n throw new SessionInternalError(\"Converting to integer \" + field + \n \" line \" + line, AbstractFileReader.class, e);\n }\n }\n break;\n case DATE:\n try {\n String dateStr = tokens[tkIdx++];\n record.addField(new PricingField(field.getName(), dateStr.length() > 0 ?\n dateFormat.parse(dateStr) : null), field.getIsKey());\n } catch (ParseException e) {\n throw new SessionInternalError(\"Using format: \" + dateFormat + \"[\" +\n parameters.get(\"date_format\") + \"]\", \n AbstractFileReader.class,e);\n }\n break;\n case DECIMAL:\n String floatStr = tokens[tkIdx++].trim();\n record.addField(new PricingField(field.getName(), floatStr.length() > 0 ?\n new BigDecimal(floatStr) : null), field.getIsKey());\n break;\n case BOOLEAN:\n boolean value = \"true\".equalsIgnoreCase(tokens[tkIdx++].trim());\n record.addField(new PricingField(field.getName(), value), field.getIsKey());\n break;\n }\n }\n record.setPosition(counter);\n return record;\n }\n"} {"input": " public final Long findRecordId(RouterSummaryTraffic record) {\n if (connection == null) {\n openConnection();\n }\n Long result = null;\n try {\n PreparedStatement pst = connection.prepareStatement(\"select a_id from aggreg where cisco = ? and\" +\n \" iface = ? and date = ?\");\n pst.setString(1, record.getRouter());\n pst.setString(2, record.getIface());\n pst.setDate(3, new java.sql.Date(record.getDate().getTime()));\n ResultSet rs = pst.executeQuery();\n if (rs.next()) {\n result = rs.getLong(1);\n }\n rs.close();\n pst.close();\n } catch (SQLException e) {\n log.error(e);\n }\n return result;\n }\n", "output": " public final Long findRecordId(RouterSummaryTraffic record) {\n if (connection == null) {\n openConnection();\n }\n Long result = null;\n try {\n PreparedStatement pst = connection.prepareStatement(\"select a_id from aggreg where cisco = ? and\" +\n \" iface = ? and dat = ?\");\n pst.setString(1, record.getRouter());\n pst.setString(2, record.getIface());\n pst.setDate(3, new java.sql.Date(record.getDate().getTime()));\n ResultSet rs = pst.executeQuery();\n if (rs.next()) {\n result = rs.getLong(1);\n }\n rs.close();\n pst.close();\n } catch (SQLException e) {\n log.error(e);\n }\n return result;\n }\n"} {"input": " public String getEnchantName(int enchant,int level){\n String result = WebPortal.materials.getConfig().getString(\"Enchant.\" + enchant );\n result += \" \";\n switch (level) {\n case 1: result += \"I\"; break;\n case 2: result += \"II\"; break;\n case 3: result += \"III\"; break;\n case 4: result += \"IV\"; break;\n case 5: result += \"V\"; break;\n case 6: result += \"VI\"; break;\n case 7: result += \"VII\"; break;\n case 8: result += \"VIII\"; break;\n case 9: result += \"IX\"; break;\n case 10: result += \"X\"; break;\n case 40: result += \"XL\"; break;\n case 50: result += \"L\"; break;\n case 90: result += \"XC\"; break;\n case 100: result += \"C\"; break;\n case 400: result += \"CD\"; break;\n case 500: result += \"D\"; break;\n case 900: result += \"CM\"; break;\n case 1000: result += \"M\"; break;\n default:\n break;\n }\n return result;\n }\n", "output": " public String getEnchantName(int enchant,int level){\n String result = WebPortal.materials.getConfig().getString(\"Enchant.\" + enchant );\n result += \" \";\n switch (level) {\n case 1: result += \"I\"; break;\n case 2: result += \"II\"; break;\n case 3: result += \"III\"; break;\n case 4: result += \"IV\"; break;\n case 5: result += \"V\"; break;\n case 6: result += \"VI\"; break;\n case 7: result += \"VII\"; break;\n case 8: result += \"VIII\"; break;\n case 9: result += \"IX\"; break;\n case 10: result += \"X\"; break;\n case 40: result += \"XL\"; break;\n case 50: result += \"L\"; break;\n case 90: result += \"XC\"; break;\n case 100: result += \"C\"; break;\n case 400: result += \"CD\"; break;\n case 500: result += \"D\"; break;\n case 900: result += \"CM\"; break;\n case 1000: result += \"M\"; break;\n default: result += level; break;\n }\n return result;\n }\n"} {"input": " public void paginate(ActionEvent action) {\n PaginatorActionEvent pEvent = (PaginatorActionEvent) action;\n DataverseGrouping grouping = (DataverseGrouping) itemBeans.get(0);\n grouping.setIsPopulated(false);\n if (DataPaginator.FACET_FIRST.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(0);\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else if (DataPaginator.FACET_PREVIOUS.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(Math.max( grouping.getFirstRow() - 10, 0 ) );\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else if (DataPaginator.FACET_NEXT.equals(pEvent.getScrollerfacet())) {\n checkForwardPaging(grouping,10);\n } else if (DataPaginator.FACET_FAST_REWIND.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(Math.max( grouping.getFirstRow() - 30, 0 ) );\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else if (DataPaginator.FACET_FAST_FORWARD.equals(pEvent.getScrollerfacet())) {\n checkForwardPaging(grouping,30);\n } else if (DataPaginator.FACET_LAST.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(grouping.getDataModelRowCount() - (grouping.getDataModelRowCount() % 10));\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else { \n System.out.println(\"The page event is \" + pEvent.getPageIndex());\n int page = pEvent.getPageIndex();\n grouping.setFirstRow((page - 1) * 10);\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n }\n }\n", "output": " public void paginate(ActionEvent action) {\n PaginatorActionEvent pEvent = (PaginatorActionEvent) action;\n DataverseGrouping grouping = (DataverseGrouping) itemBeans.get(0);\n grouping.setIsPopulated(false);\n if (DataPaginator.FACET_FIRST.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(0);\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else if (DataPaginator.FACET_PREVIOUS.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(Math.max( grouping.getFirstRow() - 10, 0 ) );\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else if (DataPaginator.FACET_NEXT.equals(pEvent.getScrollerfacet())) {\n checkForwardPaging(grouping,10);\n } else if (DataPaginator.FACET_FAST_REWIND.equals(pEvent.getScrollerfacet())) {\n grouping.setFirstRow(Math.max( grouping.getFirstRow() - 30, 0 ) );\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else if (DataPaginator.FACET_FAST_FORWARD.equals(pEvent.getScrollerfacet())) {\n checkForwardPaging(grouping,30);\n } else if (DataPaginator.FACET_LAST.equals(pEvent.getScrollerfacet())) {\n int dvRemainder = grouping.getDataModelRowCount() % 10;\n grouping.setFirstRow( grouping.getDataModelRowCount() - (dvRemainder != 0 ? dvRemainder : 10) );\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n } else { \n System.out.println(\"The page event is \" + pEvent.getPageIndex());\n int page = pEvent.getPageIndex();\n grouping.setFirstRow((page - 1) * 10);\n grouping.setPageAction(true);\n grouping.getManagedDataModel();\n }\n }\n"} {"input": " public void actionPerformed(ActionEvent ae) {\n String kommando = ((JMenuItem)ae.getSource()).getText();\n if(kommando.equals(res.getString(\"file.exit\"))) {\n Rectangle rv = new Rectangle();\n frame.getBounds(rv);\n try {\n InputStream in = new FileInputStream(System.getProperty(\"user.home\") + \"/.yamm/.config\");\n props.load(in);\n in.close();\n } catch (IOException propsioe) { System.err.println(propsioe); }\n props.setProperty(\"mainx\", new Integer(rv.x).toString());\n props.setProperty(\"mainy\", new Integer(rv.y).toString());\n props.setProperty(\"mainw\", new Integer(rv.width).toString());\n props.setProperty(\"mainh\", new Integer(rv.height).toString());\n try {\n OutputStream out = new FileOutputStream(System.getProperty(\"user.home\") + \"/.yamm/.config\");\n props.store(out, \"YAMM configuration file\");\n out.close();\n } catch(IOException propsioe) { System.err.println(propsioe); }\n frame.dispose();\n System.exit(0);\n }\n else if(kommando.equals(res.getString(\"help.about_you\"))) {\n String host = null, ipaddress = null;\n try {\n InetAddress myInetaddr = InetAddress.getLocalHost();\n ipaddress = myInetaddr.getHostAddress();\n host = myInetaddr.getHostName();\n }\n catch (UnknownHostException uhe) {};\n if (ipaddress == null) ipaddress = \"unknown\";\n if (host == null) host = \"unknown\";\n new MsgDialog(null, res.getString(\"help.about_you\"),\n res.getString(\"info.os\") + \" : \" + System.getProperty(\"os.name\") + \" \" + System.getProperty(\"os.version\") + \"\\n\"\n + res.getString(\"info.cpu\") + \" : \" + System.getProperty(\"os.arch\") + \"\\n\"\n + res.getString(\"info.ipaddress\") + \" : \" + ipaddress + \"\\n\"\n + res.getString(\"info.host\") + \" : \" + host + \"\\n\"\n + res.getString(\"info.java.version\") + \" : \" + System.getProperty(\"java.version\") + \"\\n\"\n + res.getString(\"info.java.vendor\") + \" : \" + System.getProperty(\"java.vendor\") + \"\\n\"\n + res.getString(\"info.java.vendor.url\") + \" : \" + System.getProperty(\"java.vendor.url\") + \"\\n\"\n + res.getString(\"info.username\") + \" : \" + System.getProperty(\"user.name\") + \"\\n\"\n + res.getString(\"info.user.home\") + \" : \" + System.getProperty(\"user.home\"));\n }\n else if(kommando.equals(res.getString(\"help.about\"))) {\n new MsgDialog(null, res.getString(\"help.about\"),\n \"Copyright (C) 1999 Fredrik Ehnbom\\n\"\n + \"YAMM-version: \" + YAMM.yammVersion + \"\\n\"\n + \"Compiledate: \" + YAMM.compDate + \"\\n\"\n + \"Homepage: http://www.gjt.org/\ufffdfredde/\\n\"\n + \"E-mail: \\n\"\n + \"\\n\"\n + \"Most icons are made or based on icons made\\n\"\n + \"by Tuomas Kuosmanen \");\n }\n else if(kommando.equals(res.getString(\"help.bug_report\"))) {\n YAMMWrite yw = new YAMMWrite(\"fredde@gjt.org\", \"Bug report\");\n JTextArea jt = yw.myTextArea;\n jt.append(\"What is the problem?\\n\\n\");\n jt.append(\"How did you make it happen?\\n\\n\");\n jt.append(\"Can you make it happen again?\\n\\n\");\n jt.append(\"\\nAnd now some info about your system:\\n\");\n p(\"java.version\", jt);\n p(\"java.vendor\", jt);\n p(\"java.vendor.url\", jt);\n p(\"java.home\", jt);\n p(\"java.vm.specification.version\", jt);\n p(\"java.vm.specification.vendor\", jt); \n p(\"java.vm.specification.name\", jt);\n p(\"java.vm.version\", jt);\n p(\"java.vm.vendor\", jt);\n p(\"java.vm.name\", jt);\n p(\"java.specification.version\", jt);\n p(\"java.specification.vendor\", jt);\n p(\"java.specification.name\", jt);\n p(\"java.class.version\", jt);\n p(\"java.class.path\", jt);\n p(\"os.name\", jt);\n p(\"os.arch\", jt);\n p(\"os.version\", jt);\n }\n else if(kommando.equals(res.getString(\"help.license\"))) {\n new MsgDialog(null, res.getString(\"help.license\"), \n \"Yet Another Mail Manager \" + YAMM.yammVersion + \" E-Mail Client\\nCopyright (C) 1999 Fredrik Ehnbom\\n\" +\n \"\\n\" +\n \"This program is free software; you can redistribute it and/or modify\\n\" +\n \"it under the terms of the GNU General Public License as published by\\n\" +\n \"the Free Software Foundation; either version 2 of the License, or\\n\" +\n \"(at your option) any later version.\\n\" +\n \"\\n\" +\n \"This program is distributed in the hope that it will be useful,\\n\" +\n \"but WITHOUT ANY WARRANTY; without even the implied warranty of\\n\" +\n \"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\\n\" +\n \"GNU General Public License for more details.\\n\" +\n \"\\n\" +\n \"You should have received a copy of the GNU General Public License\\n\" +\n \"along with this program; if not, write to the Free Software\\n\" +\n \"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\", MsgDialog.OK, JLabel.LEFT);\n } \n else if(kommando.equals(res.getString(\"edit.settings\"))) {\n new Options(frame);\n }\n else if(kommando.equals(res.getString(\"file.new\"))) {\n new YAMMWrite();\n }\n else if(kommando.equals(res.getString(\"edit.view_source\"))) {\n int test = ((JTable)frame.mailList).getSelectedRow();\n if(test >= 0 && test < frame.listOfMails.size()) {\n int i = 0;\n while(i<4) {\n if(((JTable)frame.mailList).getColumnName(i).equals(\"#\")) { break; }\n i++;\n }\n int msg = Integer.parseInt(((JTable)frame.mailList).getValueAt(((JTable)frame.mailList).getSelectedRow(), i).toString());\n if(msg != -1) Mailbox.viewSource(frame.selectedbox, msg, new sourceViewer().jtarea);\n }\n }\n else if(kommando.equals(res.getString(\"file.save_as\"))) {\n int test = ((JTable)frame.mailList).getSelectedRow();\n if(test != -1 && test <= frame.listOfMails.size()) {\n JFileChooser jfs = new JFileChooser();\n jfs.setFileSelectionMode(JFileChooser.FILES_ONLY);\n jfs.setMultiSelectionEnabled(false);\n jfs.setFileFilter(new filter());\n jfs.setSelectedFile(new File(\"mail.html\"));\n int ret = jfs.showSaveDialog(frame);\n if(ret == JFileChooser.APPROVE_OPTION) {\n new File(System.getProperty(\"user.home\") + \"/.yamm/tmp/\" + frame.mailName + \".html\").renameTo(jfs.getSelectedFile());\n }\n }\n }\n }\n", "output": " public void actionPerformed(ActionEvent ae) {\n String kommando = ((JMenuItem)ae.getSource()).getText();\n if(kommando.equals(res.getString(\"file.exit\"))) {\n Rectangle rv = new Rectangle();\n frame.getBounds(rv);\n try {\n InputStream in = new FileInputStream(System.getProperty(\"user.home\") + \"/.yamm/.config\");\n props.load(in);\n in.close();\n } catch (IOException propsioe) { System.err.println(propsioe); }\n props.setProperty(\"mainx\", new Integer(rv.x).toString());\n props.setProperty(\"mainy\", new Integer(rv.y).toString());\n props.setProperty(\"mainw\", new Integer(rv.width).toString());\n props.setProperty(\"mainh\", new Integer(rv.height).toString());\n try {\n OutputStream out = new FileOutputStream(System.getProperty(\"user.home\") + \"/.yamm/.config\");\n props.store(out, \"YAMM configuration file\");\n out.close();\n } catch(IOException propsioe) { System.err.println(propsioe); }\n frame.dispose();\n System.exit(0);\n }\n else if(kommando.equals(res.getString(\"help.about_you\"))) {\n String host = null, ipaddress = null;\n try {\n InetAddress myInetaddr = InetAddress.getLocalHost();\n ipaddress = myInetaddr.getHostAddress();\n host = myInetaddr.getHostName();\n }\n catch (UnknownHostException uhe) {};\n if (ipaddress == null) ipaddress = \"unknown\";\n if (host == null) host = \"unknown\";\n new MsgDialog(null, res.getString(\"help.about_you\"),\n res.getString(\"info.os\") + \" : \" + System.getProperty(\"os.name\") + \" \" + System.getProperty(\"os.version\") + \"\\n\"\n + res.getString(\"info.cpu\") + \" : \" + System.getProperty(\"os.arch\") + \"\\n\"\n + res.getString(\"info.ipaddress\") + \" : \" + ipaddress + \"\\n\"\n + res.getString(\"info.host\") + \" : \" + host + \"\\n\"\n + res.getString(\"info.java.version\") + \" : \" + System.getProperty(\"java.version\") + \"\\n\"\n + res.getString(\"info.java.vendor\") + \" : \" + System.getProperty(\"java.vendor\") + \"\\n\"\n + res.getString(\"info.java.vendor.url\") + \" : \" + System.getProperty(\"java.vendor.url\") + \"\\n\"\n + res.getString(\"info.username\") + \" : \" + System.getProperty(\"user.name\") + \"\\n\"\n + res.getString(\"info.user.home\") + \" : \" + System.getProperty(\"user.home\"));\n }\n else if(kommando.equals(res.getString(\"help.about\"))) {\n new MsgDialog(null, res.getString(\"help.about\"),\n \"Copyright (C) 1999 Fredrik Ehnbom\\n\"\n + \"YAMM-version: \" + YAMM.yammVersion + \"\\n\"\n + \"Compiledate: \" + YAMM.compDate + \"\\n\"\n + \"Homepage: http://www.gjt.org/~fredde/\\n\"\n + \"E-mail: \\n\"\n + \"\\n\"\n + \"Most icons are made or based on icons made\\n\"\n + \"by Tuomas Kuosmanen \");\n }\n else if(kommando.equals(res.getString(\"help.bug_report\"))) {\n YAMMWrite yw = new YAMMWrite(\"fredde@gjt.org\", \"Bug report\");\n JTextArea jt = yw.myTextArea;\n jt.append(\"What is the problem?\\n\\n\");\n jt.append(\"How did you make it happen?\\n\\n\");\n jt.append(\"Can you make it happen again?\\n\\n\");\n jt.append(\"\\nAnd now some info about your system:\\n\");\n p(\"java.version\", jt);\n p(\"java.vendor\", jt);\n p(\"java.vendor.url\", jt);\n p(\"java.home\", jt);\n p(\"java.vm.specification.version\", jt);\n p(\"java.vm.specification.vendor\", jt); \n p(\"java.vm.specification.name\", jt);\n p(\"java.vm.version\", jt);\n p(\"java.vm.vendor\", jt);\n p(\"java.vm.name\", jt);\n p(\"java.specification.version\", jt);\n p(\"java.specification.vendor\", jt);\n p(\"java.specification.name\", jt);\n p(\"java.class.version\", jt);\n p(\"java.class.path\", jt);\n p(\"os.name\", jt);\n p(\"os.arch\", jt);\n p(\"os.version\", jt);\n }\n else if(kommando.equals(res.getString(\"help.license\"))) {\n new MsgDialog(null, res.getString(\"help.license\"), \n \"Yet Another Mail Manager \" + YAMM.yammVersion + \" E-Mail Client\\nCopyright (C) 1999 Fredrik Ehnbom\\n\" +\n \"\\n\" +\n \"This program is free software; you can redistribute it and/or modify\\n\" +\n \"it under the terms of the GNU General Public License as published by\\n\" +\n \"the Free Software Foundation; either version 2 of the License, or\\n\" +\n \"(at your option) any later version.\\n\" +\n \"\\n\" +\n \"This program is distributed in the hope that it will be useful,\\n\" +\n \"but WITHOUT ANY WARRANTY; without even the implied warranty of\\n\" +\n \"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\\n\" +\n \"GNU General Public License for more details.\\n\" +\n \"\\n\" +\n \"You should have received a copy of the GNU General Public License\\n\" +\n \"along with this program; if not, write to the Free Software\\n\" +\n \"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\", MsgDialog.OK, JLabel.LEFT);\n } \n else if(kommando.equals(res.getString(\"edit.settings\"))) {\n new Options(frame);\n }\n else if(kommando.equals(res.getString(\"file.new\"))) {\n new YAMMWrite();\n }\n else if(kommando.equals(res.getString(\"edit.view_source\"))) {\n int test = ((JTable)frame.mailList).getSelectedRow();\n if(test >= 0 && test < frame.listOfMails.size()) {\n int i = 0;\n while(i<4) {\n if(((JTable)frame.mailList).getColumnName(i).equals(\"#\")) { break; }\n i++;\n }\n int msg = Integer.parseInt(((JTable)frame.mailList).getValueAt(((JTable)frame.mailList).getSelectedRow(), i).toString());\n if(msg != -1) Mailbox.viewSource(frame.selectedbox, msg, new sourceViewer().jtarea);\n }\n }\n else if(kommando.equals(res.getString(\"file.save_as\"))) {\n int test = ((JTable)frame.mailList).getSelectedRow();\n if(test != -1 && test <= frame.listOfMails.size()) {\n JFileChooser jfs = new JFileChooser();\n jfs.setFileSelectionMode(JFileChooser.FILES_ONLY);\n jfs.setMultiSelectionEnabled(false);\n jfs.setFileFilter(new filter());\n jfs.setSelectedFile(new File(\"mail.html\"));\n int ret = jfs.showSaveDialog(frame);\n if(ret == JFileChooser.APPROVE_OPTION) {\n new File(System.getProperty(\"user.home\") + \"/.yamm/tmp/\" + frame.mailName + \".html\").renameTo(jfs.getSelectedFile());\n }\n }\n }\n }\n"} {"input": " public void setGroup(Player player, groupType group) {\n if (!player.isOnline())\n return;\n switch(group) {\n case UNREGISTERED: {\n String currentGroup = AuthMe.permission.getPrimaryGroup(player);\n AuthMe.permission.playerRemoveGroup(player, currentGroup);\n AuthMe.permission.playerAddGroup(player, Settings.unRegisteredGroup);\n break;\n }\n case REGISTERED: {\n String currentGroup = AuthMe.permission.getPrimaryGroup(player);\n AuthMe.permission.playerRemoveGroup(player, currentGroup);\n AuthMe.permission.playerAddGroup(player, Settings.getRegisteredGroup);\n break;\n } \n }\n return;\n }\n", "output": " public void setGroup(Player player, groupType group) {\n if (!player.isOnline())\n return;\n switch(group) {\n case UNREGISTERED: {\n currentGroup = AuthMe.permission.getPrimaryGroup(player);\n AuthMe.permission.playerRemoveGroup(player, currentGroup);\n AuthMe.permission.playerAddGroup(player, Settings.unRegisteredGroup);\n break;\n }\n case REGISTERED: {\n currentGroup = AuthMe.permission.getPrimaryGroup(player);\n AuthMe.permission.playerRemoveGroup(player, currentGroup);\n AuthMe.permission.playerAddGroup(player, Settings.getRegisteredGroup);\n break;\n } \n }\n return;\n }\n"} {"input": "\tpublic ModelAndView saveflow(final HttpServletRequest req, HttpServletResponse res) throws MeandreServerException{\n\t\tString token=System.currentTimeMillis()+\"-token\";\n\t\tHashMap paramMap = new HashMap();\n\t\tboolean isMultipart = ServletFileUpload.isMultipartContent(req);\n\t\tif(!isMultipart){\n\t\t\tLOGGER.severe(\"Error -this should be multipart\");\n\t\t}\n\t\tDiskFileItemFactory factory = new DiskFileItemFactory();\n\t\tServletFileUpload upload = new ServletFileUpload(factory);\n\t\tString uploadDir = getServletContext().getRealPath(getUploadDirectory()) + \"/\" + req.getRemoteUser() + \"/\"+ token+\"/\";\n\t File dirPath = new File(uploadDir);\n\t if (!dirPath.exists()) {\n\t dirPath.mkdirs();\n\t }\n\t String flowId = null;\n\t\t String flowUri= null;\n\t\ttry {\n\t\t\tList items = upload.parseRequest(req);\n\t\t\tIterator iter = items.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t FileItem item = iter.next();\n\t\t\t if (item.isFormField()) {\n\t\t\t \tString name = item.getFieldName();\n\t\t\t String value = item.getString();\n\t\t\t paramMap.put(name, value);\n\t\t\t if(\"flowTemplateId\".equals(name)){\n\t\t\t \tflowId = value;\n\t\t\t }else if(\"flowTemplateUri\".equals(name)){\n\t\t\t \t flowUri = value;\n\t\t\t }\n\t\t\t } else {\n\t\t\t \tString fieldName = item.getFieldName();\n\t\t\t String fileName = item.getName();\n\t\t\t String contentType = item.getContentType();\n\t\t\t boolean isInMemory = item.isInMemory();\n\t\t\t long sizeInBytes = item.getSize();\n\t\t\t if(fileName!=null && sizeInBytes>0 && fileName.length()>0){\n\t\t\t \tFile uploadedFile = new File(uploadDir+File.separator + fileName);\n\t\t\t \titem.write(uploadedFile);\n\t\t\t \tSystem.out.println(\"file uploaded: \"+ fileName + uploadedFile.getAbsolutePath());\n\t\t\t \tString webDir = uploadDir.substring(getServletContext().getRealPath(\"/\").length());\n\t\t\t \tparamMap.put(fieldName,\"http://\"+ req.getServerName()+\":\"+req.getServerPort()+ req.getContextPath()+webDir+fileName);\n\t\t\t }\n\t\t\t }\n\t\t\t}\n\t\t} catch (FileUploadException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tif(flowId==null || flowUri==null){\n\t\t\tLOGGER.severe(\"flowId or flowUri is null -some severe error happened...\");\n\t\t}\n\t\tString newFlowUri=flowService.createNewFlow(paramMap,flowUri);\n\t\tLong longFlowId =Long.parseLong(flowId);\n\t\tFlow templateFlow = this.getFlowService().getFlow(longFlowId );\n\t\tString name = paramMap.get(\"name\");\n\t\tString description = paramMap.get(\"description\");\n\t\tif(name ==null){\n\t\t\tname =templateFlow.getName()+File.separator+token;\n\t\t}\n\t\tif(description==null){\n\t\t\tdescription = templateFlow.getDescription()+\" for flow: \"+token;\n\t\t}\n\t\tUser user = userManager.getCurrentUser();\n\t\tlogger.debug(\"USER IS ====> \" + user);\n\t\tif (user == null) {\n\t\t\tuser = userManager.getUserByUsername(\"admin\");\n\t\t}\n\t\tlong userId = user.getId();\n\t\tFlow instance = new Flow();\n\t\tinstance.setCreatorId(userId);\n\t\tinstance.setDateCreated(new Date());\n\t\tinstance.setInstanceOf(templateFlow);\n\t\tinstance.setKeyWords(templateFlow.getKeyWords());\n\t\tinstance.setName(name);\n\t\tinstance.setTemplate(false);\n\t\tinstance.setUrl(newFlowUri);\n\t\tinstance.setDescription(description);\n\t\tinstance.setType(FlowTypeUtils.DEFAULT_FLOW);\n\t\tSystem.out.println(\"The new flow uri is: \" + newFlowUri);\n\t\tlong instanceId=this.getFlowService().storeFlowInstance(instance);\n\t\tJob job=this.getFlowService().executeJob(token, name,description, instanceId, user.getId(), user.getEmail());\n\t\tModelAndView mav= new ModelAndView(new RedirectView(\"JobManager.jobDetail\",true));\n\t\tmav.addObject(\"id\", job.getId());\n\t\treturn mav;\n\t}\n", "output": "\tpublic ModelAndView saveflow(final HttpServletRequest req, HttpServletResponse res) throws MeandreServerException{\n\t\tString token=System.currentTimeMillis()+\"-token\";\n\t\tHashMap paramMap = new HashMap();\n\t\tboolean isMultipart = ServletFileUpload.isMultipartContent(req);\n\t\tif(!isMultipart){\n\t\t\tLOGGER.severe(\"Error -this should be multipart\");\n\t\t}\n\t\tDiskFileItemFactory factory = new DiskFileItemFactory();\n\t\tServletFileUpload upload = new ServletFileUpload(factory);\n\t\tString uploadDir = getServletContext().getRealPath(getUploadDirectory()) + \"/\" + req.getRemoteUser() + \"/\"+ token+\"/\";\n\t File dirPath = new File(uploadDir);\n\t if (!dirPath.exists()) {\n\t dirPath.mkdirs();\n\t }\n\t String flowId = null;\n\t\t String flowUri= null;\n\t\ttry {\n\t\t\tList items = upload.parseRequest(req);\n\t\t\tIterator iter = items.iterator();\n\t\t\twhile (iter.hasNext()) {\n\t\t\t FileItem item = iter.next();\n\t\t\t if (item.isFormField()) {\n\t\t\t \tString name = item.getFieldName();\n\t\t\t String value = item.getString();\n\t\t\t paramMap.put(name, value);\n\t\t\t if(\"flowTemplateId\".equals(name)){\n\t\t\t \tflowId = value;\n\t\t\t }else if(\"flowTemplateUri\".equals(name)){\n\t\t\t \t flowUri = value;\n\t\t\t }\n\t\t\t } else {\n\t\t\t \tString fieldName = item.getFieldName();\n\t\t\t String fileName = item.getName();\n\t\t\t String contentType = item.getContentType();\n\t\t\t boolean isInMemory = item.isInMemory();\n\t\t\t long sizeInBytes = item.getSize();\n\t\t\t if(fileName!=null && sizeInBytes>0 && fileName.length()>0){\n\t\t\t \tFile uploadedFile = new File(uploadDir+File.separator + fileName);\n\t\t\t \titem.write(uploadedFile);\n\t\t\t \tSystem.out.println(\"file uploaded: \"+ fileName + uploadedFile.getAbsolutePath());\n\t\t\t \tString webDir = uploadDir.substring(getServletContext().getRealPath(\"/\").length());\n\t\t\t \tparamMap.put(fieldName,\"http://\"+ req.getServerName()+\":\"+req.getServerPort()+ req.getContextPath()+webDir+fileName);\n\t\t\t }\n\t\t\t }\n\t\t\t}\n\t\t} catch (FileUploadException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tif(flowId==null || flowUri==null){\n\t\t\tLOGGER.severe(\"flowId or flowUri is null -some severe error happened...\");\n\t\t}\n\t\tString newFlowUri=flowService.createNewFlow(paramMap,flowUri);\n\t\tLong longFlowId =Long.parseLong(flowId);\n\t\tFlow templateFlow = this.getFlowService().getFlow(longFlowId );\n\t\tString name = paramMap.get(\"name\");\n\t\tString description = paramMap.get(\"description\");\n\t\tif(name ==null){\n\t\t\tname =templateFlow.getName()+File.separator+token;\n\t\t}\n\t\tif(description==null){\n\t\t\tdescription = templateFlow.getDescription()+\" for flow: \"+token;\n\t\t}\n\t\tUser user = userManager.getCurrentUser();\n\t\tlogger.debug(\"USER IS ====> \" + user);\n\t\tif (user == null) {\n\t\t\tuser = userManager.getUserByUsername(\"admin\");\n\t\t}\n\t\tlong userId = user.getId();\n\t\tFlow instance = new Flow();\n\t\tinstance.setCreatorId(userId);\n\t\tinstance.setDateCreated(new Date());\n\t\tinstance.setInstanceOf(templateFlow);\n\t\tinstance.setKeyWords(templateFlow.getKeyWords());\n\t\tinstance.setName(name);\n\t\tinstance.setTemplate(false);\n\t\tinstance.setUrl(newFlowUri);\n\t\tinstance.setDescription(description);\n\t\tinstance.setType(Flow.FlowType.INHERITS);\n\t\tinstance.setTypeName(Flow.FlowType.INHERITS.getName());\n\t\tSystem.out.println(\"The new flow uri is: \" + newFlowUri);\n\t\tlong instanceId=this.getFlowService().storeFlowInstance(instance);\n\t\tJob job=this.getFlowService().executeJob(token, name,description, instanceId, user.getId(), user.getEmail());\n\t\tModelAndView mav= new ModelAndView(new RedirectView(\"JobManager.jobDetail\",true));\n\t\tmav.addObject(\"id\", job.getId());\n\t\treturn mav;\n\t}\n"} {"input": " public boolean a(OItemStack paramOItemStack, OEntityPlayer paramOEntityPlayer, OWorld paramOWorld, int paramInt1, int paramInt2, int paramInt3, int paramInt4) {\n int clicked = paramOWorld.a(paramInt1, paramInt2, paramInt3);\n Block blockClicked = new Block(clicked, paramInt1, paramInt2, paramInt3);\n if (clicked == OBlock.aS.bk) {\n paramInt4 = 0;\n } else {\n if (paramInt4 == 0) {\n paramInt2--;\n }\n if (paramInt4 == 1) {\n paramInt2++;\n }\n if (paramInt4 == 2) {\n paramInt3--;\n }\n if (paramInt4 == 3) {\n paramInt3++;\n }\n if (paramInt4 == 4) {\n paramInt1--;\n }\n if (paramInt4 == 5) {\n paramInt1++;\n }\n }\n if (paramOItemStack.a == 0) {\n return false;\n }\n if (paramOWorld.a(a, paramInt1, paramInt2, paramInt3, false)) {\n Block blockPlaced = new Block(paramOWorld.a(paramInt1, paramInt2, paramInt3), paramInt1, paramInt2, paramInt3);\n blockClicked.setFaceClicked(Block.Face.fromId(paramInt4));\n Player player = ((OEntityPlayerMP) paramOEntityPlayer).getPlayer();\n if ((Boolean) etc.getLoader().callHook(PluginLoader.Hook.ITEM_USE, player, blockPlaced, blockClicked, new Item(paramOItemStack)))\n return false;\n OBlock localOBlock = OBlock.m[a];\n if (paramOWorld.e(paramInt1, paramInt2, paramInt3, a)) {\n OBlock.m[a].d(paramOWorld, paramInt1, paramInt2, paramInt3, paramInt4);\n OBlock.m[a].a(paramOWorld, paramInt1, paramInt2, paramInt3, paramOEntityPlayer);\n paramOWorld.a(paramInt1 + 0.5F, paramInt2 + 0.5F, paramInt3 + 0.5F, localOBlock.bt.c(), (localOBlock.bt.a() + 1.0F) / 2.0F, localOBlock.bt.b() * 0.8F);\n paramOItemStack.a -= 1;\n }\n }\n return true;\n }\n", "output": " public boolean a(OItemStack paramOItemStack, OEntityPlayer paramOEntityPlayer, OWorld paramOWorld, int paramInt1, int paramInt2, int paramInt3, int paramInt4) {\n int clicked = paramOWorld.a(paramInt1, paramInt2, paramInt3);\n Block blockClicked = new Block(clicked, paramInt1, paramInt2, paramInt3);\n if (clicked == OBlock.aS.bk) {\n paramInt4 = 0;\n } else {\n if (paramInt4 == 0) {\n paramInt2--;\n }\n if (paramInt4 == 1) {\n paramInt2++;\n }\n if (paramInt4 == 2) {\n paramInt3--;\n }\n if (paramInt4 == 3) {\n paramInt3++;\n }\n if (paramInt4 == 4) {\n paramInt1--;\n }\n if (paramInt4 == 5) {\n paramInt1++;\n }\n }\n if (paramOItemStack.a == 0) {\n return false;\n }\n if (paramOWorld.a(a, paramInt1, paramInt2, paramInt3, false)) {\n Block blockPlaced = new Block(paramOWorld.a(paramInt1, paramInt2, paramInt3), paramInt1, paramInt2, paramInt3);\n blockClicked.setFaceClicked(Block.Face.fromId(paramInt4));\n Player player = ((OEntityPlayerMP) paramOEntityPlayer).getPlayer();\n if ((Boolean) etc.getLoader().callHook(PluginLoader.Hook.ITEM_USE, player, blockPlaced, blockClicked, new Item(paramOItemStack)))\n return false;\n OBlock localOBlock = OBlock.m[a];\n if (paramOWorld.e(paramInt1, paramInt2, paramInt3, a)) {\n OBlock.m[a].d(paramOWorld, paramInt1, paramInt2, paramInt3, paramInt4);\n OBlock.m[a].a(paramOWorld, paramInt1, paramInt2, paramInt3, (OEntityLiving) paramOEntityPlayer);\n paramOWorld.a(paramInt1 + 0.5F, paramInt2 + 0.5F, paramInt3 + 0.5F, localOBlock.bt.c(), (localOBlock.bt.a() + 1.0F) / 2.0F, localOBlock.bt.b() * 0.8F);\n paramOItemStack.a -= 1;\n }\n }\n return true;\n }\n"} {"input": "\tpublic synchronized void addJaxbPackages(List packageList) { \n\t\tif (packagesContextPath.length()==0) {\n\t\t}\n\t\tStringBuilder contextPath = new StringBuilder(packagesContextPath);\n\t\tfor (String pack : packageList)\n\t\t\tcontextPath.append(\":\" + pack);\n\t\ttry {\n\t\t\tfor (int i=0; i classList) throws ClassNotFoundException {\n\t\tfor (String c : classList) {\n\t\t\tClass clazz = Thread.currentThread().getContextClassLoader().loadClass(c);\n\t\t\tRoot rootAnnotation = clazz.getAnnotation(Root.class);\n\t\t\tNamespace namespaceAnnotation = clazz.getAnnotation(Namespace.class);\n\t\t\tif (rootAnnotation!=null && namespaceAnnotation!=null) {\n\t\t\t\telementToClass.put(\"{\"+namespaceAnnotation.reference()+\"}\"+rootAnnotation.name(),clazz);\n\t\t\t}\n\t\t}\n\t}\n}\n", "output": "\tpublic synchronized void addJaxbPackages(List packageList) { \n\t\tif (packagesContextPath.length()==0) {\n\t\t}\n\t\tStringBuilder contextPath = new StringBuilder(packagesContextPath);\n\t\tfor (String pack : packageList)\n\t\t\tcontextPath.append(\":\" + pack);\n\t\ttry {\n\t\t\tfor (int i=0; i classList) throws ClassNotFoundException {\n\t\tClassLoader cl = Thread.currentThread().getContextClassLoader();\n\t\ttry {\n\t\t\tfor (String c : classList) {\n\t\t\t\tClass clazz = cl.loadClass(c);\n\t\t\t\tRoot rootAnnotation = clazz.getAnnotation(Root.class);\n\t\t\t\tNamespace namespaceAnnotation = clazz.getAnnotation(Namespace.class);\n\t\t\t\tif (rootAnnotation!=null && namespaceAnnotation!=null) {\n\t\t\t\t\telementToClass.put(\"{\"+namespaceAnnotation.reference()+\"}\"+rootAnnotation.name(),clazz);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ClassNotFoundException e) {\n\t\t\tthrow new ClassNotFoundException(\"Unable to load class using classloader \"+cl.toString(), e);\n\t\t}\n\t}\n}\n"} {"input": "\tpublic void testDelayerManagement() throws IOException {\n\t\tMessage testMessage = MessageBuilder.withPayload(\"test\").build();\n\t\tthis.delayerInput.send(testMessage);\n\t\tthis.delayerInput.send(testMessage);\n\t\tthis.scheduler.destroy();\n\t\tassertNull(this.output.receive(100));\n\t\tthis.scheduler.afterPropertiesSet();\n\t\tResource scriptResource = new ClassPathResource(\"GroovyControlBusDelayerManagementTest.groovy\", this.getClass());\n\t\tScriptSource scriptSource = new ResourceScriptSource(scriptResource);\n\t\tMessage message = MessageBuilder.withPayload(scriptSource.getScriptAsString()).build();\n\t\tthis.controlBus.send(message);\n\t\tassertNotNull(this.output.receive(100));\n\t\tassertNotNull(this.output.receive(100));\n\t}\n", "output": "\tpublic void testDelayerManagement() throws IOException {\n\t\tMessage testMessage = MessageBuilder.withPayload(\"test\").build();\n\t\tthis.delayerInput.send(testMessage);\n\t\tthis.delayerInput.send(testMessage);\n\t\tthis.scheduler.destroy();\n\t\tassertNull(this.output.receive(500));\n\t\tthis.scheduler.afterPropertiesSet();\n\t\tResource scriptResource = new ClassPathResource(\"GroovyControlBusDelayerManagementTest.groovy\", this.getClass());\n\t\tScriptSource scriptSource = new ResourceScriptSource(scriptResource);\n\t\tMessage message = MessageBuilder.withPayload(scriptSource.getScriptAsString()).build();\n\t\tthis.controlBus.send(message);\n\t\tassertNotNull(this.output.receive(1000));\n\t\tassertNotNull(this.output.receive(1000));\n\t}\n"} {"input": "\tpublic BubbleCommand(Walker walker, Game game) {\n\t\tsuper(walker, 1.4f, EaseLinear.getInstance());\n\t\tthis.walker = walker;\n\t\tthis.game = game;\n\t\tswitch(walker.rol)\n\t\t{\n\t\tcase JEDI:\n\t\t\tswitch((int)Math.random()*10)\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_OLA_K_ASE, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_HOLA_K_ASE, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_SPACEPELOTAS, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_TINTINTIRIRIN, walker.position);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_NOTE_BLUE, walker.position);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase STORM_TROOPER:\n\t\t\tswitch((int)Math.random()*10)\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_DUCADOS, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_EWOK, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_NAPALM, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_EWOKS3, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_PEINANDO, walker.position);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_NOTE_WHITE, walker.position);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase DARTH_VADER:\n\t\t\tswitch((int)Math.random()*4)\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_OBI, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_OSCURO, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBBE_A_PADRE_2, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_VADER, walker.position);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CHUWAKA:\n\t\t\tbubble = new Bubble(BubbleType.getRandomBubble(), walker.position);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbubble = new Bubble(BubbleType.getRandomBubble(), walker.position);\n\t\t}\n\t\tmovable = bubble;\n\t\tthis.game.addEntity(bubble);\n\t}\n", "output": "\tpublic BubbleCommand(Walker walker, Game game) {\n\t\tsuper(walker, 1.4f, EaseLinear.getInstance());\n\t\tthis.walker = walker;\n\t\tthis.game = game;\n\t\tswitch(walker.rol)\n\t\t{\n\t\tcase JEDI:\n\t\t\tswitch((int)(Math.random()*10))\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_OLA_K_ASE, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_HOLA_K_ASE, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_SPACEPELOTAS, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_TINTINTIRIRIN, walker.position);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_NOTE_BLUE, walker.position);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase STORM_TROOPER:\n\t\t\tswitch((int)(Math.random()*10))\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_DUCADOS, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_EWOK, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_NAPALM, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_EWOKS3, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_PEINANDO, walker.position);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_NOTE_WHITE, walker.position);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase DARTH_VADER:\n\t\t\tswitch((int)(Math.random()*4))\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_OBI, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 1:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_A_OSCURO, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBBE_A_PADRE_2, walker.position);\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tbubble = new Bubble(BubbleType.BUBBLE_VADER, walker.position);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase CHUWAKA:\n\t\t\tbubble = new Bubble(BubbleType.getRandomBubble(), walker.position);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbubble = new Bubble(BubbleType.getRandomBubble(), walker.position);\n\t\t}\n\t\tmovable = bubble;\n\t\tthis.game.addEntity(bubble);\n\t}\n"} {"input": "\tprivate static void importProject(SVNRepository repo) throws Exception {\n\t\tlog.info(\"Import the project...\");\n\t\trepo.setAuthenticationManager(andyMeneely);\n\t\tISVNEditor editor = repo.getCommitEditor(\"import project\", null , true , null );\n\t\teditor.openRoot(-1);\n\t\tList files = new RecurseJavaFiles(true).loadRecursive(new File(\"testsvn/mancala\"));\n\t\tfor (File file : files) {\n\t\t\tString svnpath = \"\";\n\t\t\tsvnpath = \"trunk/\" + file.getPath().replaceFirst(\"testsvn\\\\\\\\\", \"\").replaceAll(\"\\\\\\\\\", \"/\");\n\t\t\tlog.debug(\"Adding svnpath: \" + svnpath);\n\t\t\tif (file.isDirectory()) {\n\t\t\t\teditor.addDir(svnpath, null, -1);\n\t\t\t\teditor.closeDir();\n\t\t\t} else {\n\t\t\t\teditor.addFile(svnpath, null, -1);\n\t\t\t\teditor.applyTextDelta(svnpath, null);\n\t\t\t\tScanner scanner = new Scanner(file);\n\t\t\t\tStringBuffer sb = new StringBuffer();\n\t\t\t\twhile (scanner.hasNext())\n\t\t\t\t\tsb.append(scanner.next());\n\t\t\t\tscanner.close();\n\t\t\t\tString checksum = new SVNDeltaGenerator().sendDelta(svnpath, new ByteArrayInputStream(sb.toString().getBytes()), editor, true);\n\t\t\t\teditor.closeFile(svnpath, checksum);\n\t\t\t}\n\t\t}\n\t\tSVNCommitInfo commitInfo = editor.closeEdit();\n\t\tlog.info(\"Finished commit: \" + commitInfo.toString());\n\t}\n", "output": "\tprivate static void importProject(SVNRepository repo) throws Exception {\n\t\tlog.info(\"Import the project...\");\n\t\trepo.setAuthenticationManager(andyMeneely);\n\t\tISVNEditor editor = repo.getCommitEditor(\"import project\", null , true , null );\n\t\teditor.openRoot(-1);\n\t\tList files = new RecurseJavaFiles(true).loadRecursive(new File(\"testsvn/mancala\"));\n\t\tfor (File file : files) {\n\t\t\tString svnpath = \"\";\n\t\t\tsvnpath = \"trunk/\" + file.getPath().replaceFirst(\"testsvn\\\\\\\\\", \"\").replaceAll(\"\\\\\\\\\", \"/\");\n\t\t\tlog.debug(\"Adding svnpath: \" + svnpath);\n\t\t\tif (file.isDirectory()) {\n\t\t\t\teditor.addDir(svnpath, null, -1);\n\t\t\t\teditor.closeDir();\n\t\t\t} else {\n\t\t\t\teditor.addFile(svnpath, null, -1);\n\t\t\t\teditor.applyTextDelta(svnpath, null);\n\t\t\t\tScanner scanner = new Scanner(file);\n\t\t\t\tStringBuffer sb = new StringBuffer();\n\t\t\t\twhile (scanner.hasNextLine())\n\t\t\t\t\tsb.append(scanner.nextLine() + \"\\r\\n\");\n\t\t\t\tscanner.close();\n\t\t\t\tString checksum = new SVNDeltaGenerator().sendDelta(svnpath, new ByteArrayInputStream(sb.toString().getBytes()), editor, true);\n\t\t\t\teditor.closeFile(svnpath, checksum);\n\t\t\t}\n\t\t}\n\t\tSVNCommitInfo commitInfo = editor.closeEdit();\n\t\tlog.info(\"Finished commit: \" + commitInfo.toString());\n\t}\n"} {"input": " public boolean apply(Object deploymentPlanItem, AssemblyTemplateConstructor atc) {\n Object item = lookup(deploymentPlanItem);\n if (item==null) return false;\n log.debug(\"Item \"+deploymentPlanItem+\" being instantiated with \"+item);\n Object old = atc.getInstantiator();\n if (old!=null && !old.equals(BrooklynAssemblyTemplateInstantiator.class)) {\n log.warn(\"Can't mix Brooklyn entities with non-Brooklyn entities (at present): \"+old);\n return false;\n }\n Builder builder = PlatformComponentTemplate.builder();\n if (item instanceof CatalogItem) {\n builder.type( \"brooklyn:\"+((CatalogItem)item).getJavaType() );\n } else if (item instanceof Class) {\n builder.type( \"brooklyn:\"+((Class) item).getCanonicalName() );\n } else {\n throw new IllegalStateException(\"Item \"+item+\" is not recognised here\");\n }\n atc.instantiator(BrooklynAssemblyTemplateInstantiator.class);\n String name = ((Service)deploymentPlanItem).getName();\n if (!Strings.isBlank(name)) builder.name(name);\n Map attrs = MutableMap.copyOf( ((Service)deploymentPlanItem).getCustomAttributes() );\n if (attrs.containsKey(\"id\"))\n builder.customAttribute(\"planId\", attrs.remove(\"id\"));\n Object location = attrs.remove(\"location\");\n if (location!=null)\n builder.customAttribute(\"location\", location);\n Object locations = attrs.remove(\"locations\");\n if (locations!=null)\n builder.customAttribute(\"locations\", locations);\n Map brooklynConfig = MutableMap.of();\n Object origBrooklynConfig = attrs.remove(\"brooklyn.config\");\n if (origBrooklynConfig!=null) {\n if (!(origBrooklynConfig instanceof Map))\n throw new IllegalArgumentException(\"brooklyn.config must be a map of brooklyn config keys\");\n brooklynConfig.putAll((Map)origBrooklynConfig);\n }\n if (!brooklynConfig.isEmpty())\n builder.customAttribute(\"brooklyn.config\", brooklynConfig);\n List brooklynPolicies = Lists.newArrayList();\n Object origBrooklynPolicies = attrs.remove(\"brooklyn.policies\");\n if (origBrooklynPolicies != null) {\n if (!(origBrooklynPolicies instanceof List))\n throw new IllegalArgumentException(\"brooklyn.policies must be a list of brooklyn policy definitions\");\n brooklynPolicies.addAll((List)origBrooklynPolicies);\n }\n if (!brooklynPolicies.isEmpty())\n builder.customAttribute(\"brooklyn.policies\", brooklynPolicies);\n List brooklynEnrichers = Lists.newArrayList();\n Object origBrooklynEnrichers = attrs.remove(\"brooklyn.enrichers\");\n if (origBrooklynEnrichers != null) {\n if (!(origBrooklynEnrichers instanceof List))\n throw new IllegalArgumentException(\"brooklyn.enrichers must be a list of brooklyn enricher definitions\");\n brooklynEnrichers.addAll((List)origBrooklynEnrichers);\n }\n if (!brooklynEnrichers.isEmpty())\n builder.customAttribute(\"brooklyn.enrichers\", brooklynEnrichers);\n List brooklynChildren = Lists.newArrayList();\n Object origBrooklynChildren = attrs.remove(\"brooklyn.children\");\n if (origBrooklynChildren != null) {\n if (!(origBrooklynChildren instanceof List))\n throw new IllegalArgumentException(\"brooklyn.children must be a list of brooklyn entity definitions\");\n brooklynChildren.addAll((List)origBrooklynChildren);\n }\n if (!brooklynChildren.isEmpty())\n builder.customAttribute(\"brooklyn.children\", brooklynChildren);\n if (!attrs.isEmpty()) {\n log.warn(\"Ignoring PDP attributes on \"+deploymentPlanItem+\": \"+attrs);\n }\n atc.add(builder.build());\n return true;\n }\n", "output": " public boolean apply(Object deploymentPlanItem, AssemblyTemplateConstructor atc) {\n Object item = lookup(deploymentPlanItem);\n if (item==null) return false;\n log.debug(\"Item \"+deploymentPlanItem+\" being instantiated with \"+item);\n Object old = atc.getInstantiator();\n if (old!=null && !old.equals(BrooklynAssemblyTemplateInstantiator.class)) {\n log.warn(\"Can't mix Brooklyn entities with non-Brooklyn entities (at present): \"+old);\n return false;\n }\n Builder builder = PlatformComponentTemplate.builder();\n if (item instanceof CatalogItem) {\n builder.type( \"brooklyn:\"+((CatalogItem)item).getJavaType() );\n } else if (item instanceof Class) {\n builder.type( \"brooklyn:\"+((Class) item).getName() );\n } else {\n throw new IllegalStateException(\"Item \"+item+\" is not recognised here\");\n }\n atc.instantiator(BrooklynAssemblyTemplateInstantiator.class);\n String name = ((Service)deploymentPlanItem).getName();\n if (!Strings.isBlank(name)) builder.name(name);\n Map attrs = MutableMap.copyOf( ((Service)deploymentPlanItem).getCustomAttributes() );\n if (attrs.containsKey(\"id\"))\n builder.customAttribute(\"planId\", attrs.remove(\"id\"));\n Object location = attrs.remove(\"location\");\n if (location!=null)\n builder.customAttribute(\"location\", location);\n Object locations = attrs.remove(\"locations\");\n if (locations!=null)\n builder.customAttribute(\"locations\", locations);\n Map brooklynConfig = MutableMap.of();\n Object origBrooklynConfig = attrs.remove(\"brooklyn.config\");\n if (origBrooklynConfig!=null) {\n if (!(origBrooklynConfig instanceof Map))\n throw new IllegalArgumentException(\"brooklyn.config must be a map of brooklyn config keys\");\n brooklynConfig.putAll((Map)origBrooklynConfig);\n }\n if (!brooklynConfig.isEmpty())\n builder.customAttribute(\"brooklyn.config\", brooklynConfig);\n List brooklynPolicies = Lists.newArrayList();\n Object origBrooklynPolicies = attrs.remove(\"brooklyn.policies\");\n if (origBrooklynPolicies != null) {\n if (!(origBrooklynPolicies instanceof List))\n throw new IllegalArgumentException(\"brooklyn.policies must be a list of brooklyn policy definitions\");\n brooklynPolicies.addAll((List)origBrooklynPolicies);\n }\n if (!brooklynPolicies.isEmpty())\n builder.customAttribute(\"brooklyn.policies\", brooklynPolicies);\n List brooklynEnrichers = Lists.newArrayList();\n Object origBrooklynEnrichers = attrs.remove(\"brooklyn.enrichers\");\n if (origBrooklynEnrichers != null) {\n if (!(origBrooklynEnrichers instanceof List))\n throw new IllegalArgumentException(\"brooklyn.enrichers must be a list of brooklyn enricher definitions\");\n brooklynEnrichers.addAll((List)origBrooklynEnrichers);\n }\n if (!brooklynEnrichers.isEmpty())\n builder.customAttribute(\"brooklyn.enrichers\", brooklynEnrichers);\n List brooklynChildren = Lists.newArrayList();\n Object origBrooklynChildren = attrs.remove(\"brooklyn.children\");\n if (origBrooklynChildren != null) {\n if (!(origBrooklynChildren instanceof List))\n throw new IllegalArgumentException(\"brooklyn.children must be a list of brooklyn entity definitions\");\n brooklynChildren.addAll((List)origBrooklynChildren);\n }\n if (!brooklynChildren.isEmpty())\n builder.customAttribute(\"brooklyn.children\", brooklynChildren);\n if (!attrs.isEmpty()) {\n log.warn(\"Ignoring PDP attributes on \"+deploymentPlanItem+\": \"+attrs);\n }\n atc.add(builder.build());\n return true;\n }\n"} {"input": " private ClipperTrip[] parseTrips (DesfireCard card)\n {\n DesfireFile file = card.getApplication(0x9011f2).getFile(0x0e);\n byte [] data = file.getData();\n int pos = data.length - RECORD_LENGTH;\n List result = new ArrayList();\n while (pos > 0) {\n byte[] slice = Utils.byteArraySlice(data, pos, RECORD_LENGTH);\n final ClipperTrip trip = createTrip(slice);\n if (trip != null) {\n ClipperTrip existingTrip = Utils.findInList(result, new Utils.Matcher() {\n @Override\n public boolean matches(ClipperTrip otherTrip) {\n return trip.getTimestamp() == otherTrip.getTimestamp();\n }\n });\n if (existingTrip != null) {\n if (existingTrip.getExitTimestamp() != 0) {\n continue;\n } else {\n result.remove(existingTrip);\n }\n }\n result.add(trip);\n }\n pos -= RECORD_LENGTH;\n }\n ClipperTrip[] useLog = new ClipperTrip[result.size()];\n result.toArray(useLog);\n Arrays.sort(useLog, new Trip.Comparator());\n return useLog;\n }\n", "output": " private ClipperTrip[] parseTrips (DesfireCard card)\n {\n DesfireFile file = card.getApplication(0x9011f2).getFile(0x0e);\n byte [] data = file.getData();\n int pos = data.length - RECORD_LENGTH;\n List result = new ArrayList();\n while (pos > 0) {\n byte[] slice = Utils.byteArraySlice(data, pos, RECORD_LENGTH);\n final ClipperTrip trip = createTrip(slice);\n if (trip != null) {\n ClipperTrip existingTrip = Utils.findInList(result, new Utils.Matcher() {\n @Override\n public boolean matches(ClipperTrip otherTrip) {\n return trip.getTimestamp() == otherTrip.getTimestamp();\n }\n });\n if (existingTrip != null) {\n if (existingTrip.getExitTimestamp() != 0) {\n pos -= RECORD_LENGTH;\n continue;\n } else {\n result.remove(existingTrip);\n }\n }\n result.add(trip);\n }\n pos -= RECORD_LENGTH;\n }\n ClipperTrip[] useLog = new ClipperTrip[result.size()];\n result.toArray(useLog);\n Arrays.sort(useLog, new Trip.Comparator());\n return useLog;\n }\n"} {"input": "\tpublic void testDeg() throws Exception {\n\t\tfinal JsclMathEngine mathEngine = JsclMathEngine.instance;\n\t\tAssert.assertEquals(\"2.0\", mathEngine.evaluate(\"deg(0.03490658503988659)\"));\n\t\tAssert.assertEquals(\"-2.0\", mathEngine.evaluate(\"deg(-0.03490658503988659)\"));\n\t\tAssert.assertEquals(\"\u03c0\", mathEngine.evaluate(\"deg(\" + String.valueOf(Math.PI) + \")\"));\n\t\tfor (int i = 0; i < 1000; i++) {\n\t\t\tdouble value = Math.random() * 100000;\n\t\t\tassertEquals(value, Double.valueOf(mathEngine.evaluate(\"rad(deg(\" + value + \"))\")));\n\t\t\tassertEquals(value, Double.valueOf(mathEngine.evaluate(\"deg(rad(\" + value + \"))\")));\n\t\t}\n\t}\n", "output": "\tpublic void testDeg() throws Exception {\n\t\tfinal JsclMathEngine mathEngine = JsclMathEngine.instance;\n\t\tAssert.assertEquals(\"2.0\", mathEngine.evaluate(\"deg(0.03490658503988659)\"));\n\t\tAssert.assertEquals(\"-2.0\", mathEngine.evaluate(\"deg(-0.03490658503988659)\"));\n\t\tAssert.assertEquals(\"180.0\", mathEngine.evaluate(\"deg(\" + String.valueOf(Math.PI) + \")\"));\n\t\tfor (int i = 0; i < 1000; i++) {\n\t\t\tdouble value = Math.random() * 100000;\n\t\t\tassertEquals(value, Double.valueOf(mathEngine.evaluate(\"rad(deg(\" + value + \"))\")));\n\t\t\tassertEquals(value, Double.valueOf(mathEngine.evaluate(\"deg(rad(\" + value + \"))\")));\n\t\t}\n\t}\n"} {"input": "\tprivate JSONObject processElement(CRResolvableBean crBean) {\n\t\tJSONObject objElement = new JSONObject();\n\t\tobjElement.element(\"contentid\", \"\" + crBean.getContentid());\n\t\tobjElement.element(\"obj_id\", \"\" + crBean.getObj_id());\n\t\tobjElement.element(\"obj_type\", \"\" + crBean.getObj_type());\n\t\tobjElement.element(\"mother_id\",\n\t\t\t\t((crBean.getMother_id() == null) ? \"\" : \"\"\n\t\t\t\t\t\t+ crBean.getMother_id()));\n\t\tobjElement.element(\"mother_type\",\n\t\t\t\t((crBean.getMother_type() == null) ? \"\" : \"\"\n\t\t\t\t\t\t+ crBean.getMother_type()));\n\t\tif (crBean.getAttrMap() != null && (!crBean.getAttrMap().isEmpty())) {\n\t\t\tJSONObject attrContainer = new JSONObject();\n\t\t\tIterator bit = crBean.getAttrMap().keySet().iterator();\n\t\t\twhile (bit.hasNext()) {\n\t\t\t\tString entry = bit.next();\n\t\t\t\tObject bValue=crBean.getAttrMap().get(entry);\n\t\t\t\tif(bValue!=null)\n\t\t\t\t{\n\t\t\t\t\tif((!entry.equals(\"binarycontent\")) &&(bValue.getClass().isArray()||bValue.getClass()==ArrayList.class))\n\t\t\t\t\t{\n\t\t\t\t\t\tJSONArray value = new JSONArray();\n\t\t\t\t\t\tArrayList arr;\n\t\t\t\t\t\tif(bValue.getClass()==ArrayList.class)\n\t\t\t\t\t\t\tarr=(ArrayList)bValue;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tarr=new ArrayList();\n\t\t\t\t\t\t\tObject[] ob_arr = (Object[])bValue;\n\t\t\t\t\t\t\tfor(int i=0;i0)\n\t\t{\n\t\t\tJSONArray childContainer = new JSONArray();\n\t\t\tfor (Iterator it = crBean.getChildRepository().iterator(); it.hasNext();) {\n\t\t\t\tCRResolvableBean chBean = (CRResolvableBean) it.next();\n\t\t\t\tJSONObject chElement = processElement(chBean);\n\t\t\t\tchildContainer.add(chElement);\n\t\t\t}\n\t\t\tobjElement.element(\"children\",childContainer);\n\t\t}\n\t\treturn objElement;\n\t}\n", "output": "\tprivate JSONObject processElement(CRResolvableBean crBean) {\n\t\tJSONObject objElement = new JSONObject();\n\t\tobjElement.element(\"contentid\", \"\" + crBean.getContentid());\n\t\tobjElement.element(\"obj_id\", \"\" + crBean.getObj_id());\n\t\tobjElement.element(\"obj_type\", \"\" + crBean.getObj_type());\n\t\tobjElement.element(\"mother_id\",\n\t\t\t\t((crBean.getMother_id() == null) ? \"\" : \"\"\n\t\t\t\t\t\t+ crBean.getMother_id()));\n\t\tobjElement.element(\"mother_type\",\n\t\t\t\t((crBean.getMother_type() == null) ? \"\" : \"\"\n\t\t\t\t\t\t+ crBean.getMother_type()));\n\t\tif (crBean.getAttrMap() != null && (!crBean.getAttrMap().isEmpty())) {\n\t\t\tJSONObject attrContainer = new JSONObject();\n\t\t\tIterator bit = crBean.getAttrMap().keySet().iterator();\n\t\t\twhile (bit.hasNext()) {\n\t\t\t\tString entry = bit.next();\n\t\t\t\tObject bValue=crBean.getAttrMap().get(entry);\n\t\t\t\tif(bValue!=null)\n\t\t\t\t{\n\t\t\t\t\tif((!entry.equals(\"binarycontent\")) &&(bValue.getClass().isArray()||bValue.getClass()==ArrayList.class))\n\t\t\t\t\t{\n\t\t\t\t\t\tJSONArray value = new JSONArray();\n\t\t\t\t\t\tArrayList arr;\n\t\t\t\t\t\tif(bValue.getClass()==ArrayList.class)\n\t\t\t\t\t\t\tarr=(ArrayList)bValue;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tarr=new ArrayList();\n\t\t\t\t\t\t\tObject[] ob_arr = (Object[])bValue;\n\t\t\t\t\t\t\tfor(int i=0;i0)\n\t\t{\n\t\t\tJSONArray childContainer = new JSONArray();\n\t\t\tfor (Iterator it = crBean.getChildRepository().iterator(); it.hasNext();) {\n\t\t\t\tCRResolvableBean chBean = (CRResolvableBean) it.next();\n\t\t\t\tJSONObject chElement = processElement(chBean);\n\t\t\t\tchildContainer.add(chElement);\n\t\t\t}\n\t\t\tobjElement.element(\"children\",childContainer);\n\t\t}\n\t\treturn objElement;\n\t}\n"} {"input": " public void Delete() {\n if (mEngine.id == null) {\n DataProvider.deleteSearchEngine(getActivity(), getData());\n return;\n }\n DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() {\n @Override\n public void onClick(DialogInterface dialogInterface, int i) {\n if (i == DialogInterface.BUTTON_POSITIVE) {\n DataProvider.deleteSearchEngine(getActivity(), getData());\n if (mDetailController != null) {\n final DetailController detailController = mDetailController.get();\n if (detailController != null) {\n detailController.OnDetailFinish(MODE_DELETE, mEngine);\n }\n }\n }\n }\n };\n new AlertDialog.Builder(getActivity())\n .setTitle(R.string.dialog_confirmation)\n .setMessage(R.string.confirmation_delete)\n .setCancelable(true)\n .setNegativeButton(R.string.no, click)\n .setPositiveButton(R.string.yes, click)\n .show();\n }\n", "output": " public void Delete() {\n if (mEngine.id == null) {\n if (mDetailController != null) {\n final DetailController detailController = mDetailController.get();\n if (detailController != null) {\n detailController.OnDetailFinish(MODE_DELETE, mEngine);\n }\n }\n return;\n }\n DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() {\n @Override\n public void onClick(DialogInterface dialogInterface, int i) {\n if (i == DialogInterface.BUTTON_POSITIVE) {\n DataProvider.deleteSearchEngine(getActivity(), getData());\n if (mDetailController != null) {\n final DetailController detailController = mDetailController.get();\n if (detailController != null) {\n detailController.OnDetailFinish(MODE_DELETE, mEngine);\n }\n }\n }\n }\n };\n new AlertDialog.Builder(getActivity())\n .setTitle(R.string.dialog_confirmation)\n .setMessage(R.string.confirmation_delete)\n .setCancelable(true)\n .setNegativeButton(R.string.no, click)\n .setPositiveButton(R.string.yes, click)\n .show();\n }\n"} {"input": " protected void setup(Context context) throws IOException, InterruptedException {\n super.setup(context);\n Configuration conf = context.getConfiguration();\n try {\n ClassLoader ccl = Thread.currentThread().getContextClassLoader();\n DistanceMeasure measure = ccl.loadClass(conf.get(KMeansConfigKeys.DISTANCE_MEASURE_KEY))\n .asSubclass(DistanceMeasure.class).newInstance();\n measure.configure(conf);\n String clusterPath = conf.get(KMeansConfigKeys.CLUSTER_PATH_KEY);\n if ((clusterPath != null) && (clusterPath.length() > 0)) {\n KMeansUtil.configureWithClusterInfo(new Path(clusterPath), clusters);\n if (clusters.isEmpty()) {\n throw new IllegalStateException(\"Cluster is empty!\");\n }\n } \n this.clusterer = new KMeansClusterer(measure);\n } catch (ClassNotFoundException e) {\n throw new IllegalStateException(e);\n } catch (IllegalAccessException e) {\n throw new IllegalStateException(e);\n } catch (InstantiationException e) {\n throw new IllegalStateException(e);\n }\n }\n", "output": " protected void setup(Context context) throws IOException, InterruptedException {\n super.setup(context);\n Configuration conf = context.getConfiguration();\n try {\n ClassLoader ccl = Thread.currentThread().getContextClassLoader();\n DistanceMeasure measure = ccl.loadClass(conf.get(KMeansConfigKeys.DISTANCE_MEASURE_KEY))\n .asSubclass(DistanceMeasure.class).newInstance();\n measure.configure(conf);\n String clusterPath = conf.get(KMeansConfigKeys.CLUSTER_PATH_KEY);\n if ((clusterPath != null) && (clusterPath.length() > 0)) {\n KMeansUtil.configureWithClusterInfo(new Path(clusterPath), clusters);\n if (clusters.isEmpty()) {\n throw new IllegalStateException(\"No clusters found. Check your -c path.\");\n }\n } \n this.clusterer = new KMeansClusterer(measure);\n } catch (ClassNotFoundException e) {\n throw new IllegalStateException(e);\n } catch (IllegalAccessException e) {\n throw new IllegalStateException(e);\n } catch (InstantiationException e) {\n throw new IllegalStateException(e);\n }\n }\n"} {"input": " private static NodeList selectNodeList(Element documentElement, String string) {\n NodeList result = null;\n ArrayList input = new ArrayList();\n String[] path = string.split(\"/\");\n NodeList childNodes = documentElement.getChildNodes();\n if(path[0].equals(\"entry\") || path[0].equals(\"node\")) {\n for(int i = 0; i < childNodes.getLength(); i++) {\n Object next = childNodes.item(i);\n if(next instanceof Element) {\n if(((Element) next).getNodeName().equals(path[0])\n && next instanceof Node) {\n input.add((Node)next);\n }\n }\n }\n } else if(path[0].equals(\"map\") && path[1].equals(\"entry\")) {\n for(int i = 0; i < childNodes.getLength(); i++) {\n Object next = childNodes.item(i);\n if(next instanceof Element) {\n if(((Element) next).getNodeName().equals(path[0])\n && next instanceof Node) {\n NodeList nextChildNodes = ((Node)next).getChildNodes();\n for(int j = 0; j < nextChildNodes.getLength(); j++) {\n Object subnext = nextChildNodes.item(j);\n if(subnext instanceof Element) {\n if(((Element)subnext).getNodeName().equals(path[1])) {\n input.add((Node)subnext);\n }\n }\n }\n }\n }\n }\n }\n result = new NodeSet(input.iterator());\n return result;\n }\n", "output": " private static NodeList selectNodeList(Element documentElement, String string) {\n NodeList result = null;\n ArrayList input = new ArrayList();\n String[] path = string.split(\"/\");\n NodeList childNodes = documentElement.getChildNodes();\n if(path[0].equals(\"entry\") || path[0].equals(\"node\")) {\n for(int i = 0; i < childNodes.getLength(); i++) {\n Object next = childNodes.item(i);\n if(next instanceof Element) {\n if(((Element) next).getNodeName().equals(path[0])) {\n input.add((Node)next);\n }\n }\n }\n } else if(path[0].equals(\"map\") && path[1].equals(\"entry\")) {\n for(int i = 0; i < childNodes.getLength(); i++) {\n Object next = childNodes.item(i);\n if(next instanceof Element) {\n if(((Element) next).getNodeName().equals(path[0])\n && next instanceof Node) {\n NodeList nextChildNodes = ((Node)next).getChildNodes();\n for(int j = 0; j < nextChildNodes.getLength(); j++) {\n Object subnext = nextChildNodes.item(j);\n if(subnext instanceof Element) {\n if(((Element)subnext).getNodeName().equals(path[1])) {\n input.add((Node)subnext);\n }\n }\n }\n }\n }\n }\n }\n result = new NodeSet(input.iterator());\n return result;\n }\n"} {"input": "\t\tpublic int compare(Object o1, Object o2)\n\t\t{\n\t\t\tint result = -1;\n\t\t\tif (m_criteria.equals(SORTED_BY_DEFAULT))\n\t\t\t{\n\t\t\t\tint s1 = ((Assignment) o1).getPosition_order();\n\t\t\t\tint s2 = ((Assignment) o2).getPosition_order();\n\t\t\t\tif ( s1 == s2 ) \n\t\t\t\t{\n\t\t\t\t\tTime t1 = ((Assignment) o1).getDueTime();\n\t\t\t\t\tTime t2 = ((Assignment) o2).getDueTime();\n\t\t\t\t\tif (t1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (t2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (t1.before(t2))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t\telse if ( s1 == 0 && s2 > 0 ) \n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse if ( s2 == 0 && s1 > 0 ) \n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tresult = (s1 < s2) ? -1 : 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (m_criteria.equals(SORTED_BY_TITLE))\n\t\t\t{\n\t\t\t\tString s1 = ((Assignment) o1).getTitle();\n\t\t\t\tString s2 = ((Assignment) o2).getTitle();\n\t\t\t\tresult = s1.compareToIgnoreCase(s2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_SECTION))\n\t\t\t{\n\t\t\t\tString s1 = ((Assignment) o1).getSection();\n\t\t\t\tString s2 = ((Assignment) o2).getSection();\n\t\t\t\tresult = s1.compareToIgnoreCase(s2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_DUEDATE))\n\t\t\t{\n\t\t\t\tTime t1 = ((Assignment) o1).getDueTime();\n\t\t\t\tTime t2 = ((Assignment) o2).getDueTime();\n\t\t\t\tif (t1 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (t2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse if (t1.before(t2))\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_OPENDATE))\n\t\t\t{\n\t\t\t\tTime t1 = ((Assignment) o1).getOpenTime();\n\t\t\t\tTime t2 = ((Assignment) o2).getOpenTime();\n\t\t\t\tif (t1 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (t2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\tif (t1.before(t2))\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_ASSIGNMENT_STATUS))\n\t\t\t{\n\t\t\t\tString s1 = getAssignmentStatus((Assignment) o1);\n\t\t\t\tString s2 = getAssignmentStatus((Assignment) o2);\n\t\t\t\tresult = s1.compareToIgnoreCase(s2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_NUM_SUBMISSIONS))\n\t\t\t{\n\t\t\t\tint subNum1 = 0;\n\t\t\t\tint subNum2 = 0;\n\t\t\t\tIterator submissions1 = AssignmentService.getSubmissions((Assignment) o1);\n\t\t\t\twhile (submissions1.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = (AssignmentSubmission) submissions1.next();\n\t\t\t\t\tif (submission1.getSubmitted()) subNum1++;\n\t\t\t\t}\n\t\t\t\tIterator submissions2 = AssignmentService.getSubmissions((Assignment) o2);\n\t\t\t\twhile (submissions2.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission2 = (AssignmentSubmission) submissions2.next();\n\t\t\t\t\tif (submission2.getSubmitted()) subNum2++;\n\t\t\t\t}\n\t\t\t\tresult = (subNum1 > subNum2) ? 1 : -1;\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_NUM_UNGRADED))\n\t\t\t{\n\t\t\t\tint ungraded1 = 0;\n\t\t\t\tint ungraded2 = 0;\n\t\t\t\tIterator submissions1 = AssignmentService.getSubmissions((Assignment) o1);\n\t\t\t\twhile (submissions1.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = (AssignmentSubmission) submissions1.next();\n\t\t\t\t\tif (submission1.getSubmitted() && !submission1.getGraded()) ungraded1++;\n\t\t\t\t}\n\t\t\t\tIterator submissions2 = AssignmentService.getSubmissions((Assignment) o2);\n\t\t\t\twhile (submissions2.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission2 = (AssignmentSubmission) submissions2.next();\n\t\t\t\t\tif (submission2.getSubmitted() && !submission2.getGraded()) ungraded2++;\n\t\t\t\t}\n\t\t\t\tresult = (ungraded1 > ungraded2) ? 1 : -1;\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_SUBMISSION_STATUS))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = AssignmentService.getSubmission(((Assignment) o1).getId(), m_user);\n\t\t\t\t\tString status1 = getSubmissionStatus(submission1, (Assignment) o1);\n\t\t\t\t\tAssignmentSubmission submission2 = AssignmentService.getSubmission(((Assignment) o2).getId(), m_user);\n\t\t\t\t\tString status2 = getSubmissionStatus(submission2, (Assignment) o2);\n\t\t\t\t\tresult = status1.compareTo(status2);\n\t\t\t\t}\n\t\t\t\tcatch (IdUnusedException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tcatch (PermissionException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_GRADE))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = AssignmentService.getSubmission(((Assignment) o1).getId(), m_user);\n\t\t\t\t\tString grade1 = \" \";\n\t\t\t\t\tif (submission1 != null && submission1.getGraded() && submission1.getGradeReleased())\n\t\t\t\t\t{\n\t\t\t\t\t\tgrade1 = submission1.getGrade();\n\t\t\t\t\t}\n\t\t\t\t\tAssignmentSubmission submission2 = AssignmentService.getSubmission(((Assignment) o2).getId(), m_user);\n\t\t\t\t\tString grade2 = \" \";\n\t\t\t\t\tif (submission2 != null && submission2.getGraded() && submission2.getGradeReleased())\n\t\t\t\t\t{\n\t\t\t\t\t\tgrade2 = submission2.getGrade();\n\t\t\t\t\t}\n\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t}\n\t\t\t\tcatch (IdUnusedException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tcatch (PermissionException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_MAX_GRADE))\n\t\t\t{\n\t\t\t\tString maxGrade1 = maxGrade(((Assignment) o1).getContent().getTypeOfGrade(), (Assignment) o1);\n\t\t\t\tString maxGrade2 = maxGrade(((Assignment) o2).getContent().getTypeOfGrade(), (Assignment) o2);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tint max1 = Integer.parseInt(maxGrade1);\n\t\t\t\t\tint max2 = Integer.parseInt(maxGrade2);\n\t\t\t\t\tresult = (max1 < max2) ? -1 : 1;\n\t\t\t\t}\n\t\t\t\tcatch (NumberFormatException e)\n\t\t\t\t{\n\t\t\t\t\tresult = maxGrade1.compareTo(maxGrade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_FOR))\n\t\t\t{\n\t\t\t\tString factor1 = getAssignmentRange((Assignment) o1);\n\t\t\t\tString factor2 = getAssignmentRange((Assignment) o2);\n\t\t\t\tresult = factor1.compareToIgnoreCase(factor2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_GROUP_TITLE))\n\t\t\t{\n\t\t\t\tString factor1 = ((Group) o1).getTitle();\n\t\t\t\tString factor2 = ((Group) o2).getTitle();\n\t\t\t\tresult = factor1.compareToIgnoreCase(factor2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_GROUP_DESCRIPTION))\n\t\t\t{\n\t\t\t\tString factor1 = ((Group) o1).getDescription();\n\t\t\t\tString factor2 = ((Group) o2).getDescription();\n\t\t\t\tif (factor1 == null)\n\t\t\t\t{\n\t\t\t\t\tfactor1 = \"\";\n\t\t\t\t}\n\t\t\t\tif (factor2 == null)\n\t\t\t\t{\n\t\t\t\t\tfactor2 = \"\";\n\t\t\t\t}\n\t\t\t\tresult = factor1.compareToIgnoreCase(factor2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_LASTNAME))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null || u1.getUser() == null || u2.getUser() == null )\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tString lName1 = u1.getUser().getLastName();\n\t\t\t\t\tString lName2 = u2.getUser().getLastName();\n\t\t\t\t\tresult = lName1.toLowerCase().compareTo(lName2.toLowerCase());\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_SUBMIT_TIME))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s1 == null || s1.getTimeSubmitted() == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s2 == null || s2.getTimeSubmitted() == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s1.getTimeSubmitted().before(s2.getTimeSubmitted()))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_STATUS))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tString status1 = \"\";\n\t\t\t\tString status2 = \"\";\n\t\t\t\tif (u1 == null)\n\t\t\t\t{\n\t\t\t\t\tstatus1 = rb.getString(\"listsub.nosub\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tif (s1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus1 = rb.getString(\"listsub.nosub\");\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus1 = getSubmissionStatus(m_state, (AssignmentSubmission) s1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (u2 == null)\n\t\t\t\t{\n\t\t\t\t\tstatus2 = rb.getString(\"listsub.nosub\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus2 = rb.getString(\"listsub.nosub\");\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus2 = getSubmissionStatus(m_state, (AssignmentSubmission) s2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresult = status1.toLowerCase().compareTo(status2.toLowerCase());\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_GRADE))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tString grade1 = s1.getGrade();\n\t\t\t\t\t\tString grade2 = s2.getGrade();\n\t\t\t\t\t\tif (grade1 == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgrade1 = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (grade2 == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgrade2 = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((s1.getAssignment().getContent().getTypeOfGrade() == 3)\n\t\t\t\t\t\t\t\t&& ((s2.getAssignment().getContent().getTypeOfGrade() == 3)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (grade1.equals(\"\"))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (grade2.equals(\"\"))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tresult = (new Integer(grade1)).intValue() > (new Integer(grade2)).intValue() ? 1 : -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_RELEASED))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tString released1 = (new Boolean(s1.getGradeReleased())).toString();\n\t\t\t\t\t\tString released2 = (new Boolean(s2.getGradeReleased())).toString();\n\t\t\t\t\t\tresult = released1.compareTo(released2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_LASTNAME))\n\t\t\t{\n\t\t\t\tUser[] u1 = ((AssignmentSubmission) o1).getSubmitters();\n\t\t\t\tUser[] u2 = ((AssignmentSubmission) o2).getSubmitters();\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tString submitters1 = \"\";\n\t\t\t\t\tString submitters2 = \"\";\n\t\t\t\t\tfor (int j = 0; j < u1.length; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (u1[j] != null && u1[j].getLastName() != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (j > 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubmitters1 = submitters1.concat(\"; \");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitters1 = submitters1.concat(\"\" + u1[j].getLastName());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (int j = 0; j < u2.length; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (u2[j] != null && u2[j].getLastName() != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (j > 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubmitters2 = submitters2.concat(\"; \");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitters2 = submitters2.concat(u2[j].getLastName());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tresult = submitters1.toLowerCase().compareTo(submitters2.toLowerCase());\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_SUBMIT_TIME))\n\t\t\t{\n\t\t\t\tTime t1 = ((AssignmentSubmission) o1).getTimeSubmitted();\n\t\t\t\tTime t2 = ((AssignmentSubmission) o2).getTimeSubmitted();\n\t\t\t\tif (t1 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (t2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse if (t1.before(t2))\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_STATUS))\n\t\t\t{\n\t\t\t\tString status1 = getSubmissionStatus(m_state, (AssignmentSubmission) o1);\n\t\t\t\tString status2 = getSubmissionStatus(m_state, (AssignmentSubmission) o2);\n\t\t\t\tresult = status1.compareTo(status2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_GRADE))\n\t\t\t{\n\t\t\t\tString grade1 = ((AssignmentSubmission) o1).getGrade();\n\t\t\t\tString grade2 = ((AssignmentSubmission) o2).getGrade();\n\t\t\t\tif (grade1 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade1 = \"\";\n\t\t\t\t}\n\t\t\t\tif (grade2 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade2 = \"\";\n\t\t\t\t}\n\t\t\t\tif ((((AssignmentSubmission) o1).getAssignment().getContent().getTypeOfGrade() == 3)\n\t\t\t\t\t\t&& ((((AssignmentSubmission) o2).getAssignment().getContent().getTypeOfGrade() == 3)))\n\t\t\t\t{\n\t\t\t\t\tif (grade1.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (grade2.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = (new Integer(grade1)).intValue() > (new Integer(grade2)).intValue() ? 1 : -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_GRADE))\n\t\t\t{\n\t\t\t\tString grade1 = ((AssignmentSubmission) o1).getGrade();\n\t\t\t\tString grade2 = ((AssignmentSubmission) o2).getGrade();\n\t\t\t\tif (grade1 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade1 = \"\";\n\t\t\t\t}\n\t\t\t\tif (grade2 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade2 = \"\";\n\t\t\t\t}\n\t\t\t\tif ((((AssignmentSubmission) o1).getAssignment().getContent().getTypeOfGrade() == 3)\n\t\t\t\t\t\t&& ((((AssignmentSubmission) o2).getAssignment().getContent().getTypeOfGrade() == 3)))\n\t\t\t\t{\n\t\t\t\t\tif (grade1.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (grade2.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = (new Integer(grade1)).intValue() > (new Integer(grade2)).intValue() ? 1 : -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_MAX_GRADE))\n\t\t\t{\n\t\t\t\tAssignment a1 = ((AssignmentSubmission) o1).getAssignment();\n\t\t\t\tAssignment a2 = ((AssignmentSubmission) o2).getAssignment();\n\t\t\t\tString maxGrade1 = maxGrade(a1.getContent().getTypeOfGrade(), a1);\n\t\t\t\tString maxGrade2 = maxGrade(a2.getContent().getTypeOfGrade(), a2);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tint max1 = Integer.parseInt(maxGrade1);\n\t\t\t\t\tint max2 = Integer.parseInt(maxGrade2);\n\t\t\t\t\tresult = (max1 < max2) ? -1 : 1;\n\t\t\t\t}\n\t\t\t\tcatch (NumberFormatException e)\n\t\t\t\t{\n\t\t\t\t\tresult = maxGrade1.compareTo(maxGrade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_RELEASED))\n\t\t\t{\n\t\t\t\tString released1 = (new Boolean(((AssignmentSubmission) o1).getGradeReleased())).toString();\n\t\t\t\tString released2 = (new Boolean(((AssignmentSubmission) o2).getGradeReleased())).toString();\n\t\t\t\tresult = released1.compareTo(released2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_ASSIGNMENT))\n\t\t\t{\n\t\t\t\tString title1 = ((AssignmentSubmission) o1).getAssignment().getContent().getTitle();\n\t\t\t\tString title2 = ((AssignmentSubmission) o2).getAssignment().getContent().getTitle();\n\t\t\t\tresult = title1.toLowerCase().compareTo(title2.toLowerCase());\n\t\t\t}\n\t\t\tif (m_asc.equals(Boolean.FALSE.toString()))\n\t\t\t{\n\t\t\t\tresult = -result;\n\t\t\t}\n\t\t\treturn result;\n\t\t} \n", "output": "\t\tpublic int compare(Object o1, Object o2)\n\t\t{\n\t\t\tint result = -1;\n\t\t\tif (m_criteria.equals(SORTED_BY_DEFAULT))\n\t\t\t{\n\t\t\t\tint s1 = ((Assignment) o1).getPosition_order();\n\t\t\t\tint s2 = ((Assignment) o2).getPosition_order();\n\t\t\t\tif ( s1 == s2 ) \n\t\t\t\t{\n\t\t\t\t\tTime t1 = ((Assignment) o1).getDueTime();\n\t\t\t\t\tTime t2 = ((Assignment) o2).getDueTime();\n\t\t\t\t\tif (t1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (t2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (t1.before(t2))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t}\t\t\t\t\n\t\t\t\telse if ( s1 == 0 && s2 > 0 ) \n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse if ( s2 == 0 && s1 > 0 ) \n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t{\n\t\t\t\t\tresult = (s1 < s2) ? -1 : 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (m_criteria.equals(SORTED_BY_TITLE))\n\t\t\t{\n\t\t\t\tString s1 = ((Assignment) o1).getTitle();\n\t\t\t\tString s2 = ((Assignment) o2).getTitle();\n\t\t\t\tresult = s1.compareToIgnoreCase(s2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_SECTION))\n\t\t\t{\n\t\t\t\tString s1 = ((Assignment) o1).getSection();\n\t\t\t\tString s2 = ((Assignment) o2).getSection();\n\t\t\t\tresult = s1.compareToIgnoreCase(s2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_DUEDATE))\n\t\t\t{\n\t\t\t\tTime t1 = ((Assignment) o1).getDueTime();\n\t\t\t\tTime t2 = ((Assignment) o2).getDueTime();\n\t\t\t\tif (t1 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (t2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse if (t1.before(t2))\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_OPENDATE))\n\t\t\t{\n\t\t\t\tTime t1 = ((Assignment) o1).getOpenTime();\n\t\t\t\tTime t2 = ((Assignment) o2).getOpenTime();\n\t\t\t\tif (t1 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (t2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\tif (t1.before(t2))\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_ASSIGNMENT_STATUS))\n\t\t\t{\n\t\t\t\tString s1 = getAssignmentStatus((Assignment) o1);\n\t\t\t\tString s2 = getAssignmentStatus((Assignment) o2);\n\t\t\t\tresult = s1.compareToIgnoreCase(s2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_NUM_SUBMISSIONS))\n\t\t\t{\n\t\t\t\tint subNum1 = 0;\n\t\t\t\tint subNum2 = 0;\n\t\t\t\tIterator submissions1 = AssignmentService.getSubmissions((Assignment) o1);\n\t\t\t\twhile (submissions1.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = (AssignmentSubmission) submissions1.next();\n\t\t\t\t\tif (submission1.getSubmitted()) subNum1++;\n\t\t\t\t}\n\t\t\t\tIterator submissions2 = AssignmentService.getSubmissions((Assignment) o2);\n\t\t\t\twhile (submissions2.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission2 = (AssignmentSubmission) submissions2.next();\n\t\t\t\t\tif (submission2.getSubmitted()) subNum2++;\n\t\t\t\t}\n\t\t\t\tresult = (subNum1 > subNum2) ? 1 : -1;\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_NUM_UNGRADED))\n\t\t\t{\n\t\t\t\tint ungraded1 = 0;\n\t\t\t\tint ungraded2 = 0;\n\t\t\t\tIterator submissions1 = AssignmentService.getSubmissions((Assignment) o1);\n\t\t\t\twhile (submissions1.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = (AssignmentSubmission) submissions1.next();\n\t\t\t\t\tif (submission1.getSubmitted() && !submission1.getGraded()) ungraded1++;\n\t\t\t\t}\n\t\t\t\tIterator submissions2 = AssignmentService.getSubmissions((Assignment) o2);\n\t\t\t\twhile (submissions2.hasNext())\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission2 = (AssignmentSubmission) submissions2.next();\n\t\t\t\t\tif (submission2.getSubmitted() && !submission2.getGraded()) ungraded2++;\n\t\t\t\t}\n\t\t\t\tresult = (ungraded1 > ungraded2) ? 1 : -1;\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_SUBMISSION_STATUS))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = AssignmentService.getSubmission(((Assignment) o1).getId(), m_user);\n\t\t\t\t\tString status1 = getSubmissionStatus(submission1, (Assignment) o1);\n\t\t\t\t\tAssignmentSubmission submission2 = AssignmentService.getSubmission(((Assignment) o2).getId(), m_user);\n\t\t\t\t\tString status2 = getSubmissionStatus(submission2, (Assignment) o2);\n\t\t\t\t\tresult = status1.compareTo(status2);\n\t\t\t\t}\n\t\t\t\tcatch (IdUnusedException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tcatch (PermissionException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_GRADE))\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission submission1 = AssignmentService.getSubmission(((Assignment) o1).getId(), m_user);\n\t\t\t\t\tString grade1 = \" \";\n\t\t\t\t\tif (submission1 != null && submission1.getGraded() && submission1.getGradeReleased())\n\t\t\t\t\t{\n\t\t\t\t\t\tgrade1 = submission1.getGrade();\n\t\t\t\t\t}\n\t\t\t\t\tAssignmentSubmission submission2 = AssignmentService.getSubmission(((Assignment) o2).getId(), m_user);\n\t\t\t\t\tString grade2 = \" \";\n\t\t\t\t\tif (submission2 != null && submission2.getGraded() && submission2.getGradeReleased())\n\t\t\t\t\t{\n\t\t\t\t\t\tgrade2 = submission2.getGrade();\n\t\t\t\t\t}\n\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t}\n\t\t\t\tcatch (IdUnusedException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\tcatch (PermissionException e)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_MAX_GRADE))\n\t\t\t{\n\t\t\t\tString maxGrade1 = maxGrade(((Assignment) o1).getContent().getTypeOfGrade(), (Assignment) o1);\n\t\t\t\tString maxGrade2 = maxGrade(((Assignment) o2).getContent().getTypeOfGrade(), (Assignment) o2);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tint max1 = Integer.parseInt(maxGrade1);\n\t\t\t\t\tint max2 = Integer.parseInt(maxGrade2);\n\t\t\t\t\tresult = (max1 < max2) ? -1 : 1;\n\t\t\t\t}\n\t\t\t\tcatch (NumberFormatException e)\n\t\t\t\t{\n\t\t\t\t\tresult = maxGrade1.compareTo(maxGrade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_FOR))\n\t\t\t{\n\t\t\t\tString factor1 = getAssignmentRange((Assignment) o1);\n\t\t\t\tString factor2 = getAssignmentRange((Assignment) o2);\n\t\t\t\tresult = factor1.compareToIgnoreCase(factor2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_GROUP_TITLE))\n\t\t\t{\n\t\t\t\tString factor1 = ((Group) o1).getTitle();\n\t\t\t\tString factor2 = ((Group) o2).getTitle();\n\t\t\t\tresult = factor1.compareToIgnoreCase(factor2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_BY_GROUP_DESCRIPTION))\n\t\t\t{\n\t\t\t\tString factor1 = ((Group) o1).getDescription();\n\t\t\t\tString factor2 = ((Group) o2).getDescription();\n\t\t\t\tif (factor1 == null)\n\t\t\t\t{\n\t\t\t\t\tfactor1 = \"\";\n\t\t\t\t}\n\t\t\t\tif (factor2 == null)\n\t\t\t\t{\n\t\t\t\t\tfactor2 = \"\";\n\t\t\t\t}\n\t\t\t\tresult = factor1.compareToIgnoreCase(factor2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_LASTNAME))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null || u1.getUser() == null || u2.getUser() == null )\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tString lName1 = u1.getUser().getSortName();\n\t\t\t\t\tString lName2 = u2.getUser().getSortName();\n\t\t\t\t\tresult = lName1.toLowerCase().compareTo(lName2.toLowerCase());\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_SUBMIT_TIME))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s1 == null || s1.getTimeSubmitted() == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s2 == null || s2.getTimeSubmitted() == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s1.getTimeSubmitted().before(s2.getTimeSubmitted()))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_STATUS))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tString status1 = \"\";\n\t\t\t\tString status2 = \"\";\n\t\t\t\tif (u1 == null)\n\t\t\t\t{\n\t\t\t\t\tstatus1 = rb.getString(\"listsub.nosub\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tif (s1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus1 = rb.getString(\"listsub.nosub\");\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus1 = getSubmissionStatus(m_state, (AssignmentSubmission) s1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (u2 == null)\n\t\t\t\t{\n\t\t\t\t\tstatus2 = rb.getString(\"listsub.nosub\");\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus2 = rb.getString(\"listsub.nosub\");\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tstatus2 = getSubmissionStatus(m_state, (AssignmentSubmission) s2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresult = status1.toLowerCase().compareTo(status2.toLowerCase());\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_GRADE))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tString grade1 = s1.getGrade();\n\t\t\t\t\t\tString grade2 = s2.getGrade();\n\t\t\t\t\t\tif (grade1 == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgrade1 = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (grade2 == null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tgrade2 = \"\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((s1.getAssignment().getContent().getTypeOfGrade() == 3)\n\t\t\t\t\t\t\t\t&& ((s2.getAssignment().getContent().getTypeOfGrade() == 3)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (grade1.equals(\"\"))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (grade2.equals(\"\"))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tresult = (new Integer(grade1)).intValue() > (new Integer(grade2)).intValue() ? 1 : -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_GRADE_SUBMISSION_BY_RELEASED))\n\t\t\t{\n\t\t\t\tUserSubmission u1 = (UserSubmission) o1;\n\t\t\t\tUserSubmission u2 = (UserSubmission) o2;\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tAssignmentSubmission s1 = u1.getSubmission();\n\t\t\t\t\tAssignmentSubmission s2 = u2.getSubmission();\n\t\t\t\t\tif (s1 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (s2 == null)\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tString released1 = (new Boolean(s1.getGradeReleased())).toString();\n\t\t\t\t\t\tString released2 = (new Boolean(s2.getGradeReleased())).toString();\n\t\t\t\t\t\tresult = released1.compareTo(released2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_LASTNAME))\n\t\t\t{\n\t\t\t\tUser[] u1 = ((AssignmentSubmission) o1).getSubmitters();\n\t\t\t\tUser[] u2 = ((AssignmentSubmission) o2).getSubmitters();\n\t\t\t\tif (u1 == null || u2 == null)\n\t\t\t\t{\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tString submitters1 = \"\";\n\t\t\t\t\tString submitters2 = \"\";\n\t\t\t\t\tfor (int j = 0; j < u1.length; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (u1[j] != null && u1[j].getLastName() != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (j > 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubmitters1 = submitters1.concat(\"; \");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitters1 = submitters1.concat(\"\" + u1[j].getLastName());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (int j = 0; j < u2.length; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (u2[j] != null && u2[j].getLastName() != null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (j > 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubmitters2 = submitters2.concat(\"; \");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsubmitters2 = submitters2.concat(u2[j].getLastName());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tresult = submitters1.toLowerCase().compareTo(submitters2.toLowerCase());\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_SUBMIT_TIME))\n\t\t\t{\n\t\t\t\tTime t1 = ((AssignmentSubmission) o1).getTimeSubmitted();\n\t\t\t\tTime t2 = ((AssignmentSubmission) o2).getTimeSubmitted();\n\t\t\t\tif (t1 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse if (t2 == null)\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t\telse if (t1.before(t2))\n\t\t\t\t{\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_STATUS))\n\t\t\t{\n\t\t\t\tString status1 = getSubmissionStatus(m_state, (AssignmentSubmission) o1);\n\t\t\t\tString status2 = getSubmissionStatus(m_state, (AssignmentSubmission) o2);\n\t\t\t\tresult = status1.compareTo(status2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_GRADE))\n\t\t\t{\n\t\t\t\tString grade1 = ((AssignmentSubmission) o1).getGrade();\n\t\t\t\tString grade2 = ((AssignmentSubmission) o2).getGrade();\n\t\t\t\tif (grade1 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade1 = \"\";\n\t\t\t\t}\n\t\t\t\tif (grade2 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade2 = \"\";\n\t\t\t\t}\n\t\t\t\tif ((((AssignmentSubmission) o1).getAssignment().getContent().getTypeOfGrade() == 3)\n\t\t\t\t\t\t&& ((((AssignmentSubmission) o2).getAssignment().getContent().getTypeOfGrade() == 3)))\n\t\t\t\t{\n\t\t\t\t\tif (grade1.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (grade2.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = (new Integer(grade1)).intValue() > (new Integer(grade2)).intValue() ? 1 : -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_GRADE))\n\t\t\t{\n\t\t\t\tString grade1 = ((AssignmentSubmission) o1).getGrade();\n\t\t\t\tString grade2 = ((AssignmentSubmission) o2).getGrade();\n\t\t\t\tif (grade1 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade1 = \"\";\n\t\t\t\t}\n\t\t\t\tif (grade2 == null)\n\t\t\t\t{\n\t\t\t\t\tgrade2 = \"\";\n\t\t\t\t}\n\t\t\t\tif ((((AssignmentSubmission) o1).getAssignment().getContent().getTypeOfGrade() == 3)\n\t\t\t\t\t\t&& ((((AssignmentSubmission) o2).getAssignment().getContent().getTypeOfGrade() == 3)))\n\t\t\t\t{\n\t\t\t\t\tif (grade1.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = -1;\n\t\t\t\t\t}\n\t\t\t\t\telse if (grade2.equals(\"\"))\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = 1;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tresult = (new Integer(grade1)).intValue() > (new Integer(grade2)).intValue() ? 1 : -1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tresult = grade1.compareTo(grade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_MAX_GRADE))\n\t\t\t{\n\t\t\t\tAssignment a1 = ((AssignmentSubmission) o1).getAssignment();\n\t\t\t\tAssignment a2 = ((AssignmentSubmission) o2).getAssignment();\n\t\t\t\tString maxGrade1 = maxGrade(a1.getContent().getTypeOfGrade(), a1);\n\t\t\t\tString maxGrade2 = maxGrade(a2.getContent().getTypeOfGrade(), a2);\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tint max1 = Integer.parseInt(maxGrade1);\n\t\t\t\t\tint max2 = Integer.parseInt(maxGrade2);\n\t\t\t\t\tresult = (max1 < max2) ? -1 : 1;\n\t\t\t\t}\n\t\t\t\tcatch (NumberFormatException e)\n\t\t\t\t{\n\t\t\t\t\tresult = maxGrade1.compareTo(maxGrade2);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_RELEASED))\n\t\t\t{\n\t\t\t\tString released1 = (new Boolean(((AssignmentSubmission) o1).getGradeReleased())).toString();\n\t\t\t\tString released2 = (new Boolean(((AssignmentSubmission) o2).getGradeReleased())).toString();\n\t\t\t\tresult = released1.compareTo(released2);\n\t\t\t}\n\t\t\telse if (m_criteria.equals(SORTED_SUBMISSION_BY_ASSIGNMENT))\n\t\t\t{\n\t\t\t\tString title1 = ((AssignmentSubmission) o1).getAssignment().getContent().getTitle();\n\t\t\t\tString title2 = ((AssignmentSubmission) o2).getAssignment().getContent().getTitle();\n\t\t\t\tresult = title1.toLowerCase().compareTo(title2.toLowerCase());\n\t\t\t}\n\t\t\tif (m_asc.equals(Boolean.FALSE.toString()))\n\t\t\t{\n\t\t\t\tresult = -result;\n\t\t\t}\n\t\t\treturn result;\n\t\t} \n"} {"input": "\tpublic Set getPossibleMovesFrom(int square) {\n\t\tint type = PieceHelper.pieceType(getFromBoard(square));\n\t\tint opp_color = getOpponentsColor();\n\t\tList squares;\n\t\tSet moves = new HashSet();\n\t\tMove move;\n\t\tif (type == PieceHelper.BISHOP || type == PieceHelper.QUEEN\n\t\t\t\t|| type == PieceHelper.ROOK) {\n\t\t\tfor (Direction direction : Direction.values()) {\n\t\t\t\tif (((direction == Direction.NORTH\n\t\t\t\t\t\t|| direction == Direction.EAST\n\t\t\t\t\t\t|| direction == Direction.SOUTH || direction == Direction.WEST) && type == PieceHelper.BISHOP)\n\t\t\t\t\t\t|| ((direction == Direction.NORTHWEST\n\t\t\t\t\t\t\t\t|| direction == Direction.NORTHEAST\n\t\t\t\t\t\t\t\t|| direction == Direction.SOUTHEAST || direction == Direction.SOUTHWEST) && type == PieceHelper.ROOK)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tsquares = SquareHelper.getAllSquaresInDirection(square,\n\t\t\t\t\t\t\tdirection);\n\t\t\t\t\tfor (Integer new_square : squares) {\n\t\t\t\t\t\tif (getFromBoard(new_square) == 0\n\t\t\t\t\t\t\t\t|| PieceHelper\n\t\t\t\t\t\t\t\t\t\t.pieceColor(getFromBoard(new_square)) == opp_color) {\n\t\t\t\t\t\t\tmove = new Move(square, new_square);\n\t\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t\t\tif (getFromBoard(new_square) != 0\n\t\t\t\t\t\t\t\t\t&& PieceHelper\n\t\t\t\t\t\t\t\t\t\t\t.pieceColor(getFromBoard(new_square)) == opp_color)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (type == PieceHelper.PAWN) {\n\t\t\tif ((SquareHelper.getRow(square) == 2 && active_color == PieceHelper.WHITE)\n\t\t\t\t\t|| (SquareHelper.getRow(square) == 7 && active_color == PieceHelper.BLACK)) {\n\t\t\t\tif (getFromBoard(square\n\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tif (getFromBoard(square + 2\n\t\t\t\t\t\t\t* Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\t\tmove = new Move(square, square + 2\n\t\t\t\t\t\t\t\t* Direction.pawnDirection(active_color).offset);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tSet pawn_capturing_directions = Direction\n\t\t\t\t\t\t.pawnCapturingDirections(active_color);\n\t\t\t\tfor (Direction direction : pawn_capturing_directions) {\n\t\t\t\t\tif (getFromBoard(square + direction.offset) != 0\n\t\t\t\t\t\t\t&& PieceHelper.pieceColor(getFromBoard(square\n\t\t\t\t\t\t\t\t\t+ direction.offset)) == getOpponentsColor()) {\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ((SquareHelper.getRow(square) == 7 && active_color == PieceHelper.WHITE)\n\t\t\t\t\t|| (SquareHelper.getRow(square) == 2 && active_color == PieceHelper.BLACK)) {\n\t\t\t\tif (getFromBoard(square\n\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.QUEEN);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.KNIGHT);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.ROOK);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.BISHOP);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t\tSet pawn_capturing_directions = Direction\n\t\t\t\t\t\t.pawnCapturingDirections(active_color);\n\t\t\t\tfor (Direction direction : pawn_capturing_directions) {\n\t\t\t\t\tif (getFromBoard(square + direction.offset) != 0\n\t\t\t\t\t\t\t&& PieceHelper.pieceColor(getFromBoard(square\n\t\t\t\t\t\t\t\t\t+ direction.offset)) == getOpponentsColor()) {\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset,\n\t\t\t\t\t\t\t\tPieceHelper.QUEEN);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset,\n\t\t\t\t\t\t\t\tPieceHelper.KNIGHT);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (getFromBoard(square\n\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t\tSet pawn_capturing_directions = Direction\n\t\t\t\t\t\t.pawnCapturingDirections(active_color);\n\t\t\t\tfor (Direction direction : pawn_capturing_directions) {\n\t\t\t\t\tif ((getFromBoard(square + direction.offset) != 0 && PieceHelper\n\t\t\t\t\t\t\t.pieceColor(getFromBoard(square + direction.offset)) == getOpponentsColor())\n\t\t\t\t\t\t\t|| getFromBoard(square + direction.offset) == getEnPassant()) {\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n", "output": "\tpublic Set getPossibleMovesFrom(int square) {\n\t\tint type = PieceHelper.pieceType(getFromBoard(square));\n\t\tint opp_color = getOpponentsColor();\n\t\tList squares;\n\t\tSet moves = new HashSet();\n\t\tMove move;\n\t\tif (type == PieceHelper.BISHOP || type == PieceHelper.QUEEN\n\t\t\t\t|| type == PieceHelper.ROOK) {\n\t\t\tfor (Direction direction : Direction.values()) {\n\t\t\t\tif (((direction == Direction.NORTH\n\t\t\t\t\t\t|| direction == Direction.EAST\n\t\t\t\t\t\t|| direction == Direction.SOUTH || direction == Direction.WEST) && type == PieceHelper.BISHOP)\n\t\t\t\t\t\t|| ((direction == Direction.NORTHWEST\n\t\t\t\t\t\t\t\t|| direction == Direction.NORTHEAST\n\t\t\t\t\t\t\t\t|| direction == Direction.SOUTHEAST || direction == Direction.SOUTHWEST) && type == PieceHelper.ROOK)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tsquares = SquareHelper.getAllSquaresInDirection(square,\n\t\t\t\t\t\t\tdirection);\n\t\t\t\t\tfor (Integer new_square : squares) {\n\t\t\t\t\t\tif (getFromBoard(new_square) == 0\n\t\t\t\t\t\t\t\t|| PieceHelper\n\t\t\t\t\t\t\t\t\t\t.pieceColor(getFromBoard(new_square)) == opp_color) {\n\t\t\t\t\t\t\tmove = new Move(square, new_square);\n\t\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t\t\tif (getFromBoard(new_square) != 0\n\t\t\t\t\t\t\t\t\t&& PieceHelper\n\t\t\t\t\t\t\t\t\t\t\t.pieceColor(getFromBoard(new_square)) == opp_color)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (type == PieceHelper.PAWN) {\n\t\t\tif ((SquareHelper.getRow(square) == 2 && active_color == PieceHelper.WHITE)\n\t\t\t\t\t|| (SquareHelper.getRow(square) == 7 && active_color == PieceHelper.BLACK)) {\n\t\t\t\tif (getFromBoard(square\n\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tif (getFromBoard(square + 2\n\t\t\t\t\t\t\t* Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\t\tmove = new Move(square, square + 2\n\t\t\t\t\t\t\t\t* Direction.pawnDirection(active_color).offset);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tSet pawn_capturing_directions = Direction\n\t\t\t\t\t\t.pawnCapturingDirections(active_color);\n\t\t\t\tfor (Direction direction : pawn_capturing_directions) {\n\t\t\t\t\tif (getFromBoard(square + direction.offset) != 0\n\t\t\t\t\t\t\t&& PieceHelper.pieceColor(getFromBoard(square\n\t\t\t\t\t\t\t\t\t+ direction.offset)) == getOpponentsColor()) {\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ((SquareHelper.getRow(square) == 7 && active_color == PieceHelper.WHITE)\n\t\t\t\t\t|| (SquareHelper.getRow(square) == 2 && active_color == PieceHelper.BLACK)) {\n\t\t\t\tif (getFromBoard(square\n\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.QUEEN);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.KNIGHT);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.ROOK);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset,\n\t\t\t\t\t\t\tPieceHelper.BISHOP);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t\tSet pawn_capturing_directions = Direction\n\t\t\t\t\t\t.pawnCapturingDirections(active_color);\n\t\t\t\tfor (Direction direction : pawn_capturing_directions) {\n\t\t\t\t\tif (getFromBoard(square + direction.offset) != 0\n\t\t\t\t\t\t\t&& PieceHelper.pieceColor(getFromBoard(square\n\t\t\t\t\t\t\t\t\t+ direction.offset)) == getOpponentsColor()) {\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset,\n\t\t\t\t\t\t\t\tPieceHelper.QUEEN);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset,\n\t\t\t\t\t\t\t\tPieceHelper.KNIGHT);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (getFromBoard(square\n\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset) == 0) {\n\t\t\t\t\tmove = new Move(square, square\n\t\t\t\t\t\t\t+ Direction.pawnDirection(active_color).offset);\n\t\t\t\t\tmoves.add(move);\n\t\t\t\t}\n\t\t\t\tSet pawn_capturing_directions = Direction\n\t\t\t\t\t\t.pawnCapturingDirections(active_color);\n\t\t\t\tfor (Direction direction : pawn_capturing_directions) {\n\t\t\t\t\tif ((getFromBoard(square + direction.offset) != 0 && PieceHelper\n\t\t\t\t\t\t\t.pieceColor(getFromBoard(square + direction.offset)) == getOpponentsColor())\n\t\t\t\t\t\t\t|| square + direction.offset == getEnPassant()) {\n\t\t\t\t\t\tmove = new Move(square, square + direction.offset);\n\t\t\t\t\t\tmoves.add(move);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n"} {"input": "\tpublic WidgetDataEvents addControls(Composite parent,\n\t\t\tfinal Listener statusListener) {\n\t\tComposite configCom = new Composite(parent, SWT.NONE);\n\t\tGridLayout layout = new GridLayout(3, false);\n\t\tconfigCom.setLayout(layout);\n\t\tconfigCom.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tLabel lblCustomPakage = new Label(configCom, SWT.NONE);\n\t\tlblCustomPakage\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Custom_Package_Name);\n\t\tfinal Text txtCustomPkgName = new Text(configCom, SWT.BORDER);\n\t\ttxtCustomPkgName.setText(model.getCustomPackage());\n\t\tGridData gd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan = 2;\n\t\ttxtCustomPkgName.setLayoutData(gd);\n\t\ttxtCustomPkgName.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif (validatePackage(txtCustomPkgName.getText())) {\n\t\t\t\t\tmodel.setCustomPackage(txtCustomPkgName.getText());\n\t\t\t\t}\n\t\t\t\tstatusListener.handleEvent(null);\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE)\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_JaxWS_Target);\n\t\tfinal Combo cbSpec = new Combo(configCom, SWT.BORDER | SWT.READ_ONLY);\n\t\tcbSpec.add(JBossWSCreationCoreMessages.Value_Target_0, 0);\n\t\tcbSpec.add(JBossWSCreationCoreMessages.Value_Target_1, 1);\n\t\tif (JBossWSCreationCoreMessages.Value_Target_0\n\t\t\t\t.equals(model.getTarget())) {\n\t\t\tcbSpec.select(0);\n\t\t} else {\n\t\t\tcbSpec.select(1);\n\t\t}\n\t\tgd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan = 2;\n\t\tcbSpec.setLayoutData(gd);\n\t\tcbSpec.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tmodel.setTarget(cbSpec.getText());\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE)\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Catalog_File);\n\t\tfinal Text txtCatlog = new Text(configCom, SWT.BORDER);\n\t\ttxtCatlog.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tButton btnCatlog = new Button(configCom, SWT.NONE);\n\t\tbtnCatlog\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Button_Text_Seletion);\n\t\tbtnCatlog.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString fileLocation = new FileDialog(Display.getCurrent()\n\t\t\t\t\t\t.getActiveShell(), SWT.NONE).open();\n\t\t\t\ttxtCatlog.setText(fileLocation);\n\t\t\t\tmodel.setCatalog(fileLocation);\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE)\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Binding_File);\n\t\tfinal List bindingList = new List(configCom, SWT.BORDER\n\t\t\t\t| SWT.SCROLL_LINE | SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tgd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.heightHint = Display.getCurrent().getActiveShell().getBounds().height / 4;\n\t\tgd.verticalSpan = 3;\n\t\tbindingList.setLayoutData(gd);\n\t\tloadBindingFiles(bindingList);\n\t\tbindingList.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (bindingList.getSelectionIndex() >= 0) {\n\t\t\t\t\tbtnRemove.setEnabled(true);\n\t\t\t\t} else {\n\t\t\t\t\tbtnRemove.setEnabled(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tButton btnSelect = new Button(configCom, SWT.NONE);\n\t\tbtnSelect\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Button_Text_Seletion);\n\t\tbtnSelect.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString fileLocation = new FileDialog(Display.getCurrent()\n\t\t\t\t\t\t.getActiveShell(), SWT.NONE).open();\n\t\t\t\tif (fileLocation != null\n\t\t\t\t\t\t&& !model.getBindingFiles().contains(fileLocation)) {\n\t\t\t\t\tbindingList.add(fileLocation);\n\t\t\t\t\tmodel.addBindingFile(fileLocation);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE);\n\t\tbtnRemove = new Button(configCom, SWT.NONE);\n\t\tbtnRemove.setEnabled(false);\n\t\tbtnRemove.setText(JBossWSCreationCoreMessages.Label_Button_Text_Remove);\n\t\tbtnRemove.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmodel.getBindingFiles().remove(bindingList.getSelectionIndex());\n\t\t\t\tbindingList.remove(bindingList.getSelectionIndex());\n\t\t\t\tif (bindingList.getSelectionIndex() == -1) {\n\t\t\t\t\tbtnRemove.setEnabled(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbtnExtension = new Button(configCom, SWT.CHECK);\n\t\tgd = new GridData();\n\t\tgd.horizontalSpan = 3;\n\t\tbtnExtension.setLayoutData(gd);\n\t\tbtnExtension\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_EnableSOAP12_Binding_Extension);\n\t\tbtnExtension.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmodel.setEnableSOAP12(btnExtension.getSelection());\n\t\t\t}\n\t\t});\n\t\tif (model.getWsScenario() != WebServiceScenario.CLIENT) {\n\t\t\tbtnGenDefaultImpl = new Button(configCom, SWT.CHECK);\n\t\t\tgd = new GridData();\n\t\t\tgd.horizontalSpan = 3;\n\t\t\tbtnGenDefaultImpl.setLayoutData(gd);\n\t\t\tbtnGenDefaultImpl\n\t\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Generate_Impelemtation);\n\t\t\tbtnGenDefaultImpl.setSelection(true);\n\t\t\tbtnGenDefaultImpl.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tmodel.setGenerateImplementatoin(btnGenDefaultImpl\n\t\t\t\t\t\t\t.getSelection());\n\t\t\t\t\tbtnUpdateWebxml\n\t\t\t\t\t\t\t.setEnabled(btnGenDefaultImpl.getSelection());\n\t\t\t\t\tif (!btnGenDefaultImpl.getSelection()) {\n\t\t\t\t\t\tmodel.setUpdateWebxml(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmodel.setUpdateWebxml(btnUpdateWebxml.getSelection());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tbtnUpdateWebxml = new Button(configCom, SWT.CHECK);\n\t\t\tgd = new GridData();\n\t\t\tgd.horizontalSpan = 3;\n\t\t\tbtnUpdateWebxml.setLayoutData(gd);\n\t\t\tbtnUpdateWebxml\n\t\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Update_Webxml);\n\t\t\tbtnUpdateWebxml.setSelection(true);\n\t\t\tbtnUpdateWebxml.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tmodel.setUpdateWebxml(btnUpdateWebxml.getSelection());\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tupdateExtensionButtonStatus();\n\t\treturn this;\n\t}\n", "output": "\tpublic WidgetDataEvents addControls(Composite parent,\n\t\t\tfinal Listener statusListener) {\n\t\tComposite configCom = new Composite(parent, SWT.NONE);\n\t\tGridLayout layout = new GridLayout(3, false);\n\t\tconfigCom.setLayout(layout);\n\t\tconfigCom.setLayoutData(new GridData(GridData.FILL_BOTH));\n\t\tLabel lblCustomPakage = new Label(configCom, SWT.NONE);\n\t\tlblCustomPakage\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Custom_Package_Name);\n\t\tfinal Text txtCustomPkgName = new Text(configCom, SWT.BORDER);\n\t\tGridData gd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan = 2;\n\t\ttxtCustomPkgName.setLayoutData(gd);\n\t\ttxtCustomPkgName.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif (validatePackage(txtCustomPkgName.getText())) {\n\t\t\t\t\tmodel.setCustomPackage(txtCustomPkgName.getText());\n\t\t\t\t}\n\t\t\t\tstatusListener.handleEvent(null);\n\t\t\t}\n\t\t});\n\t\ttxtCustomPkgName.setText(model.getCustomPackage());\n\t\tnew Label(configCom, SWT.NONE)\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_JaxWS_Target);\n\t\tfinal Combo cbSpec = new Combo(configCom, SWT.BORDER | SWT.READ_ONLY);\n\t\tcbSpec.add(JBossWSCreationCoreMessages.Value_Target_0, 0);\n\t\tcbSpec.add(JBossWSCreationCoreMessages.Value_Target_1, 1);\n\t\tif (JBossWSCreationCoreMessages.Value_Target_0\n\t\t\t\t.equals(model.getTarget())) {\n\t\t\tcbSpec.select(0);\n\t\t} else {\n\t\t\tcbSpec.select(1);\n\t\t}\n\t\tgd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.horizontalSpan = 2;\n\t\tcbSpec.setLayoutData(gd);\n\t\tcbSpec.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tmodel.setTarget(cbSpec.getText());\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE)\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Catalog_File);\n\t\tfinal Text txtCatlog = new Text(configCom, SWT.BORDER);\n\t\ttxtCatlog.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));\n\t\tButton btnCatlog = new Button(configCom, SWT.NONE);\n\t\tbtnCatlog\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Button_Text_Seletion);\n\t\tbtnCatlog.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString fileLocation = new FileDialog(Display.getCurrent()\n\t\t\t\t\t\t.getActiveShell(), SWT.NONE).open();\n\t\t\t\ttxtCatlog.setText(fileLocation);\n\t\t\t\tmodel.setCatalog(fileLocation);\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE)\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Binding_File);\n\t\tfinal List bindingList = new List(configCom, SWT.BORDER\n\t\t\t\t| SWT.SCROLL_LINE | SWT.V_SCROLL | SWT.H_SCROLL);\n\t\tgd = new GridData(GridData.FILL_HORIZONTAL);\n\t\tgd.heightHint = Display.getCurrent().getActiveShell().getBounds().height / 4;\n\t\tgd.verticalSpan = 3;\n\t\tbindingList.setLayoutData(gd);\n\t\tloadBindingFiles(bindingList);\n\t\tbindingList.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tif (bindingList.getSelectionIndex() >= 0) {\n\t\t\t\t\tbtnRemove.setEnabled(true);\n\t\t\t\t} else {\n\t\t\t\t\tbtnRemove.setEnabled(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tButton btnSelect = new Button(configCom, SWT.NONE);\n\t\tbtnSelect\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Button_Text_Seletion);\n\t\tbtnSelect.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tString fileLocation = new FileDialog(Display.getCurrent()\n\t\t\t\t\t\t.getActiveShell(), SWT.NONE).open();\n\t\t\t\tif (fileLocation != null\n\t\t\t\t\t\t&& !model.getBindingFiles().contains(fileLocation)) {\n\t\t\t\t\tbindingList.add(fileLocation);\n\t\t\t\t\tmodel.addBindingFile(fileLocation);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tnew Label(configCom, SWT.NONE);\n\t\tbtnRemove = new Button(configCom, SWT.NONE);\n\t\tbtnRemove.setEnabled(false);\n\t\tbtnRemove.setText(JBossWSCreationCoreMessages.Label_Button_Text_Remove);\n\t\tbtnRemove.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmodel.getBindingFiles().remove(bindingList.getSelectionIndex());\n\t\t\t\tbindingList.remove(bindingList.getSelectionIndex());\n\t\t\t\tif (bindingList.getSelectionIndex() == -1) {\n\t\t\t\t\tbtnRemove.setEnabled(false);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tbtnExtension = new Button(configCom, SWT.CHECK);\n\t\tgd = new GridData();\n\t\tgd.horizontalSpan = 3;\n\t\tbtnExtension.setLayoutData(gd);\n\t\tbtnExtension\n\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_EnableSOAP12_Binding_Extension);\n\t\tbtnExtension.addSelectionListener(new SelectionAdapter() {\n\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\tmodel.setEnableSOAP12(btnExtension.getSelection());\n\t\t\t}\n\t\t});\n\t\tif (model.getWsScenario() != WebServiceScenario.CLIENT) {\n\t\t\tbtnGenDefaultImpl = new Button(configCom, SWT.CHECK);\n\t\t\tgd = new GridData();\n\t\t\tgd.horizontalSpan = 3;\n\t\t\tbtnGenDefaultImpl.setLayoutData(gd);\n\t\t\tbtnGenDefaultImpl\n\t\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Generate_Impelemtation);\n\t\t\tbtnGenDefaultImpl.setSelection(true);\n\t\t\tbtnGenDefaultImpl.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tmodel.setGenerateImplementatoin(btnGenDefaultImpl\n\t\t\t\t\t\t\t.getSelection());\n\t\t\t\t\tbtnUpdateWebxml\n\t\t\t\t\t\t\t.setEnabled(btnGenDefaultImpl.getSelection());\n\t\t\t\t\tif (!btnGenDefaultImpl.getSelection()) {\n\t\t\t\t\t\tmodel.setUpdateWebxml(false);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmodel.setUpdateWebxml(btnUpdateWebxml.getSelection());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tbtnUpdateWebxml = new Button(configCom, SWT.CHECK);\n\t\t\tgd = new GridData();\n\t\t\tgd.horizontalSpan = 3;\n\t\t\tbtnUpdateWebxml.setLayoutData(gd);\n\t\t\tbtnUpdateWebxml\n\t\t\t\t\t.setText(JBossWSCreationCoreMessages.Label_Update_Webxml);\n\t\t\tbtnUpdateWebxml.setSelection(true);\n\t\t\tbtnUpdateWebxml.addSelectionListener(new SelectionAdapter() {\n\t\t\t\tpublic void widgetSelected(SelectionEvent e) {\n\t\t\t\t\tmodel.setUpdateWebxml(btnUpdateWebxml.getSelection());\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tupdateExtensionButtonStatus();\n\t\treturn this;\n\t}\n"} {"input": " protected final void collectOrFireEvents( InputSystem is, EventQueue eventQueue, long nanoTime, boolean acceptEvents ) throws InputSystemException\n {\n final boolean isQueued = ( eventQueue != null );\n if ( !org.lwjgl.opengl.Display.isCreated() )\n throw( new InputSystemException( \"Display is not created.\" ) );\n if ( !org.lwjgl.input.Mouse.isCreated() )\n throw( new InputSystemException( \"Mouse is not created.\" ) );\n try\n {\n LWJGLInputDeviceFactory.processMessages( nanoTime );\n org.lwjgl.input.Mouse.poll();\n while ( org.lwjgl.input.Mouse.next() )\n {\n if ( !acceptEvents )\n continue;\n final int x = org.lwjgl.input.Mouse.getEventX();\n final int y = getSourceWindow().getHeight() - org.lwjgl.input.Mouse.getEventY();\n final int dx = org.lwjgl.input.Mouse.getEventDX();\n final int dy = -org.lwjgl.input.Mouse.getEventDY();\n final int buttonIdx = org.lwjgl.input.Mouse.getEventButton();\n final boolean buttonState = org.lwjgl.input.Mouse.getEventButtonState();\n final int wheelDelta = org.lwjgl.input.Mouse.getEventDWheel() / 120;\n if ( isAbsolute() )\n this.storePosition( x, y );\n if ( ( dx != 0 ) || ( dy != 0 ) )\n {\n final MouseMovedEvent movEv = prepareMouseMovedEvent( getCurrentX(), getCurrentY(), dx, dy, nanoTime );\n if ( dx != 0 )\n is.notifyInputStatesManagers( this, getXAxis(), x, dx, nanoTime );\n if ( dy != 0 )\n is.notifyInputStatesManagers( this, getYAxis(), y, dy, nanoTime );\n if ( movEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( movEv );\n else\n fireOnMouseMoved( movEv, true );\n }\n if ( buttonIdx != -1 )\n {\n final MouseButton button = convertButton( buttonIdx );\n if ( buttonState )\n {\n final MouseButtonPressedEvent pressedEv = prepareMouseButtonPressedEvent( button, nanoTime );\n is.notifyInputStatesManagers( this, button, 1, +1, nanoTime );\n if ( pressedEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( pressedEv );\n else\n fireOnMouseButtonPressed( pressedEv, true );\n }\n else\n {\n final MouseButtonReleasedEvent releasedEv = prepareMouseButtonReleasedEvent( button, nanoTime );\n is.notifyInputStatesManagers( this, button, 0, -1, nanoTime );\n if ( releasedEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( releasedEv );\n else\n fireOnMouseButtonReleased( releasedEv, true );\n }\n }\n if ( wheelDelta != 0 )\n {\n final MouseWheelEvent wheelEv = prepareMouseWheelMovedEvent( wheelDelta, false, nanoTime );\n is.notifyInputStatesManagers( this, getWheel(), getWheel().getIntValue(), wheelDelta, nanoTime );\n if ( wheelEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( wheelEv );\n else\n fireOnMouseWheelMoved( wheelEv, true );\n }\n }\n }\n catch ( Throwable t )\n {\n if ( t instanceof InputSystemException )\n throw( (InputSystemException)t );\n if ( t instanceof Error )\n throw( (Error)t );\n if ( t instanceof RuntimeException )\n throw( (RuntimeException)t );\n throw( new InputSystemException( t ) );\n }\n }\n", "output": " protected final void collectOrFireEvents( InputSystem is, EventQueue eventQueue, long nanoTime, boolean acceptEvents ) throws InputSystemException\n {\n final boolean isQueued = ( eventQueue != null );\n if ( !org.lwjgl.opengl.Display.isCreated() )\n throw( new InputSystemException( \"Display is not created.\" ) );\n if ( !org.lwjgl.input.Mouse.isCreated() )\n throw( new InputSystemException( \"Mouse is not created.\" ) );\n try\n {\n LWJGLInputDeviceFactory.processMessages( nanoTime );\n org.lwjgl.input.Mouse.poll();\n while ( org.lwjgl.input.Mouse.next() )\n {\n if ( !acceptEvents )\n continue;\n final int x = org.lwjgl.input.Mouse.getEventX();\n final int y = getSourceWindow().getHeight() - org.lwjgl.input.Mouse.getEventY();\n final int dx = org.lwjgl.input.Mouse.getEventDX();\n final int dy = org.lwjgl.input.Mouse.getEventDY();\n final int buttonIdx = org.lwjgl.input.Mouse.getEventButton();\n final boolean buttonState = org.lwjgl.input.Mouse.getEventButtonState();\n final int wheelDelta = org.lwjgl.input.Mouse.getEventDWheel() / 120;\n if ( isAbsolute() )\n this.storePosition( x, y );\n if ( ( dx != 0 ) || ( dy != 0 ) )\n {\n final MouseMovedEvent movEv = prepareMouseMovedEvent( getCurrentX(), getCurrentY(), dx, dy, nanoTime );\n if ( dx != 0 )\n is.notifyInputStatesManagers( this, getXAxis(), x, dx, nanoTime );\n if ( dy != 0 )\n is.notifyInputStatesManagers( this, getYAxis(), y, dy, nanoTime );\n if ( movEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( movEv );\n else\n fireOnMouseMoved( movEv, true );\n }\n if ( buttonIdx != -1 )\n {\n final MouseButton button = convertButton( buttonIdx );\n if ( buttonState )\n {\n final MouseButtonPressedEvent pressedEv = prepareMouseButtonPressedEvent( button, nanoTime );\n is.notifyInputStatesManagers( this, button, 1, +1, nanoTime );\n if ( pressedEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( pressedEv );\n else\n fireOnMouseButtonPressed( pressedEv, true );\n }\n else\n {\n final MouseButtonReleasedEvent releasedEv = prepareMouseButtonReleasedEvent( button, nanoTime );\n is.notifyInputStatesManagers( this, button, 0, -1, nanoTime );\n if ( releasedEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( releasedEv );\n else\n fireOnMouseButtonReleased( releasedEv, true );\n }\n }\n if ( wheelDelta != 0 )\n {\n final MouseWheelEvent wheelEv = prepareMouseWheelMovedEvent( wheelDelta, false, nanoTime );\n is.notifyInputStatesManagers( this, getWheel(), getWheel().getIntValue(), wheelDelta, nanoTime );\n if ( wheelEv == null )\n continue;\n if ( isQueued )\n eventQueue.enqueue( wheelEv );\n else\n fireOnMouseWheelMoved( wheelEv, true );\n }\n }\n }\n catch ( Throwable t )\n {\n if ( t instanceof InputSystemException )\n throw( (InputSystemException)t );\n if ( t instanceof Error )\n throw( (Error)t );\n if ( t instanceof RuntimeException )\n throw( (RuntimeException)t );\n throw( new InputSystemException( t ) );\n }\n }\n"} {"input": " private void send() throws IOException {\n final Pooled pooledBuffer = buffer;\n final ByteBuffer buffer = pooledBuffer.getResource();\n this.buffer = null;\n final boolean eof = this.eof;\n if (buffer != null && buffer.position() > 0) {\n buffer.flip();\n send(pooledBuffer, eof);\n } else if (eof) {\n Pooled pooledBuffer1 = getBuffer();\n final ByteBuffer buffer1 = pooledBuffer1.getResource();\n buffer1.flip();\n send(pooledBuffer1, eof);\n }\n }\n", "output": " private void send() throws IOException {\n final Pooled pooledBuffer = buffer;\n final ByteBuffer buffer = pooledBuffer == null ? null : pooledBuffer.getResource();\n this.buffer = null;\n final boolean eof = this.eof;\n if (buffer != null && buffer.position() > 0) {\n buffer.flip();\n send(pooledBuffer, eof);\n } else if (eof) {\n Pooled pooledBuffer1 = getBuffer();\n final ByteBuffer buffer1 = pooledBuffer1.getResource();\n buffer1.flip();\n send(pooledBuffer1, eof);\n }\n }\n"} {"input": "\tprivate static String getFileContents(String fileName)\n\t{\n\t\tFileInputStream fin;\n\t\ttry {\n\t\t\tfin = new FileInputStream(\"D:\\\\Development\\\\Emulator\\\\src\\\\utility\\\\test\\\\\" +fileName);\n\t\t\tFileChannel fch = fin.getChannel();\n\t\t\tByteBuffer byteBuff;\n\t\t\ttry {\n\t\t\t\tbyteBuff = fch.map(FileChannel.MapMode.READ_ONLY, 0, fch.size());\n\t\t\t\tCharBuffer chBuff = Charset.forName(\"UTF-8\").decode(byteBuff);\n\t\t\t\treturn chBuff.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t} catch (FileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn \"\";\n\t}\n", "output": "\tprivate static String getFileContents(String fileName)\n\t{\n\t\tFileInputStream fin;\n\t\ttry {\n\t\t\tfin = new FileInputStream(fileName);\n\t\t\tFileChannel fch = fin.getChannel();\n\t\t\tByteBuffer byteBuff;\n\t\t\ttry {\n\t\t\t\tbyteBuff = fch.map(FileChannel.MapMode.READ_ONLY, 0, fch.size());\n\t\t\t\tCharBuffer chBuff = Charset.forName(\"UTF-8\").decode(byteBuff);\n\t\t\t\treturn chBuff.toString();\n\t\t\t} catch (IOException e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t\t} catch (FileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn \"\";\n\t}\n"} {"input": "\tpublic void actionPerformed(final ActionEvent ae) {\n\t\tdispatcher.exec(new Runnable() { public void run() {\n\t\tString command = ae.getActionCommand();\n\t\tif (command.startsWith(\"Job\")) {\n\t\t\tif (Utils.checkYN(\"Really cancel job?\")) {\n\t\t\t\tproject.getLoader().quitJob(command);\n\t\t\t\trepairGUI();\n\t\t\t}\n\t\t\treturn;\n\t\t} else if (command.equals(\"Move to top\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.TOP, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Move up\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.UP, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Move down\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.DOWN, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Move to bottom\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.BOTTOM, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Duplicate, link and send to next layer\")) {\n\t\t\tduplicateLinkAndSendTo(active, 1, layer.getParent().next(layer));\n\t\t} else if (command.equals(\"Duplicate, link and send to previous layer\")) {\n\t\t\tduplicateLinkAndSendTo(active, 0, layer.getParent().previous(layer));\n\t\t} else if (command.equals(\"Duplicate, link and send to...\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Send to\");\n\t\t\tgd.addMessage(\"Duplicate, link and send to...\");\n\t\t\tString[] sl = new String[layer.getParent().size()];\n\t\t\tint next = 0;\n\t\t\tfor (Iterator it = layer.getParent().getLayers().iterator(); it.hasNext(); ) {\n\t\t\t\tsl[next++] = project.findLayerThing(it.next()).toString();\n\t\t\t}\n\t\t\tgd.addChoice(\"Layer: \", sl, sl[layer.getParent().indexOf(layer)]);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tLayer la = layer.getParent().getLayer(gd.getNextChoiceIndex());\n\t\t\tif (layer == la) {\n\t\t\t\tUtils.showMessage(\"Can't duplicate, link and send to the same layer.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tduplicateLinkAndSendTo(active, 0, la);\n\t\t} else if (-1 != command.indexOf(\"z = \")) {\n\t\t\tLayer target_layer = layer.getParent().getLayer(Double.parseDouble(command.substring(command.lastIndexOf(' ') +1)));\n\t\t\tUtils.log2(\"layer: __\" +command.substring(command.lastIndexOf(' ') +1) + \"__\");\n\t\t\tif (null == target_layer) return;\n\t\t\tduplicateLinkAndSendTo(active, 0, target_layer);\n\t\t} else if (-1 != command.indexOf(\"z=\")) {\n\t\t\tint iz = command.indexOf(\"z=\")+2;\n\t\t\tUtils.log2(\"iz=\" + iz + \" other: \" + command.indexOf(' ', iz+2));\n\t\t\tint end = command.indexOf(' ', iz);\n\t\t\tif (-1 == end) end = command.length();\n\t\t\tdouble lz = Double.parseDouble(command.substring(iz, end));\n\t\t\tLayer target = layer.getParent().getLayer(lz);\n\t\t\tlayer.getParent().move(selection.getAffected(), active.getLayer(), target); \n\t\t} else if (command.equals(\"Unlink\")) {\n\t\t\tif (null == active || active instanceof Patch) return;\n\t\t\tactive.unlink();\n\t\t\tupdateSelection();\n\t\t} else if (command.equals(\"Unlink from images\")) {\n\t\t\tif (null == active) return;\n\t\t\ttry {\n\t\t\t\tfor (Displayable displ: selection.getSelected()) {\n\t\t\t\t\tdispl.unlinkAll(Patch.class);\n\t\t\t\t}\n\t\t\t\tupdateSelection();\n\t\t\t} catch (Exception e) { IJError.print(e); }\n\t\t} else if (command.equals(\"Unlink slices\")) {\n\t\t\tYesNoCancelDialog yn = new YesNoCancelDialog(frame, \"Attention\", \"Really unlink all slices from each other?\\nThere is no undo.\");\n\t\t\tif (!yn.yesPressed()) return;\n\t\t\tfinal ArrayList pa = ((Patch)active).getStackPatches();\n\t\t\tfor (int i=pa.size()-1; i>0; i--) {\n\t\t\t\tpa.get(i).unlink(pa.get(i-1));\n\t\t\t}\n\t\t} else if (command.equals(\"Send to next layer\")) {\n\t\t\tRectangle box = selection.getBox();\n\t\t\ttry {\n\t\t\t\tfor (final Displayable displ : selection.getSelected()) {\n\t\t\t\t\tdispl.unlinkAll(Patch.class);\n\t\t\t\t}\n\t\t\t\tupdateSelection();\n\t\t\t} catch (Exception e) { IJError.print(e); }\n\t\t\tselection.moveDown();\n\t\t\trepaint(layer.getParent(), box);\n\t\t} else if (command.equals(\"Send to previous layer\")) {\n\t\t\tRectangle box = selection.getBox();\n\t\t\ttry {\n\t\t\t\tfor (final Displayable displ : selection.getSelected()) {\n\t\t\t\t\tdispl.unlinkAll(Patch.class);\n\t\t\t\t}\n\t\t\t\tupdateSelection();\n\t\t\t} catch (Exception e) { IJError.print(e); }\n\t\t\tselection.moveUp();\n\t\t\trepaint(layer.getParent(), box);\n\t\t} else if (command.equals(\"Show centered\")) {\n\t\t\tif (active == null) return;\n\t\t\tshowCentered(active);\n\t\t} else if (command.equals(\"Delete...\")) {\n\t\t\tselection.deleteAll();\n\t\t} else if (command.equals(\"Color...\")) {\n\t\t\tIJ.doCommand(\"Color Picker...\");\n\t\t} else if (command.equals(\"Revert\")) {\n\t\t\tif (null == active || active.getClass() != Patch.class) return;\n\t\t\tPatch p = (Patch)active;\n\t\t\tif (!p.revert()) {\n\t\t\t\tif (null == p.getOriginalPath()) Utils.log(\"No editions to save for patch \" + p.getTitle() + \" #\" + p.getId());\n\t\t\t\telse Utils.log(\"Could not revert Patch \" + p.getTitle() + \" #\" + p.getId());\n\t\t\t}\n\t\t} else if (command.equals(\"Remove alpha mask\")) {\n\t\t\tfinal ArrayList patches = selection.getSelected(Patch.class); \n\t\t\tif (patches.size() > 0) {\n\t\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Removing alpha mask\" + (patches.size() > 1 ? \"s\" : \"\")) { public void exec() {\n\t\t\t\t\tfinal ArrayList jobs = new ArrayList();\n\t\t\t\t\tfor (final Displayable d : patches) {\n\t\t\t\t\t\tfinal Patch p = (Patch) d;\n\t\t\t\t\t\tp.setAlphaMask(null);\n\t\t\t\t\t\tFuture job = p.getProject().getLoader().regenerateMipMaps(p); \n\t\t\t\t\t\tif (null != job) jobs.add(job);\n\t\t\t\t\t}\n\t\t\t\t\tfor (final Future job : jobs) try {\n\t\t\t\t\t\tjob.get();\n\t\t\t\t\t} catch (Exception ie) {}\n\t\t\t\t}}, patches.get(0).getProject());\n\t\t\t}\n\t\t} else if (command.equals(\"Undo\")) {\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Undo\") { public void exec() {\n\t\t\t\tlayer.getParent().undoOneStep();\n\t\t\t\tDisplay.repaint(layer.getParent());\n\t\t\t}}, project);\n\t\t} else if (command.equals(\"Redo\")) {\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Redo\") { public void exec() {\n\t\t\t\tlayer.getParent().redoOneStep();\n\t\t\t\tDisplay.repaint(layer.getParent());\n\t\t\t}}, project);\n\t\t} else if (command.equals(\"Apply transform\")) {\n\t\t\tcanvas.applyTransform();\n\t\t} else if (command.equals(\"Apply transform propagating to last layer\")) {\n\t\t\tif (mode.getClass() == AffineTransformMode.class || mode.getClass() == NonLinearTransformMode.class) {\n\t\t\t\tfinal LayerSet ls = getLayerSet();\n\t\t\t\tfinal HashSet subset = new HashSet(ls.getLayers(ls.indexOf(Display.this.layer)+1, ls.size()-1)); \n\t\t\t\tif (mode.getClass() == AffineTransformMode.class) ((AffineTransformMode)mode).applyAndPropagate(subset);\n\t\t\t\telse if (mode.getClass() == NonLinearTransformMode.class) ((NonLinearTransformMode)mode).apply(subset);\n\t\t\t\tsetMode(new DefaultMode(Display.this));\n\t\t\t}\n\t\t} else if (command.equals(\"Apply transform propagating to first layer\")) {\n\t\t\tif (mode.getClass() == AffineTransformMode.class || mode.getClass() == NonLinearTransformMode.class) {\n\t\t\t\tfinal LayerSet ls = getLayerSet();\n\t\t\t\tfinal HashSet subset = new HashSet(ls.getLayers(0, ls.indexOf(Display.this.layer) -1)); \n\t\t\t\tif (mode.getClass() == AffineTransformMode.class) ((AffineTransformMode)mode).applyAndPropagate(subset);\n\t\t\t\telse if (mode.getClass() == NonLinearTransformMode.class) ((NonLinearTransformMode)mode).apply(subset);\n\t\t\t\tsetMode(new DefaultMode(Display.this));\n\t\t\t}\n\t\t} else if (command.equals(\"Cancel transform\")) {\n\t\t\tcanvas.cancelTransform(); \n\t\t} else if (command.equals(\"Specify transform...\")) {\n\t\t\tif (null == active) return;\n\t\t\tselection.specify();\n\t\t} else if (command.equals(\"Hide all but images\")) {\n\t\t\tArrayList> type = new ArrayList>();\n\t\t\ttype.add(Patch.class);\n\t\t\ttype.add(Stack.class);\n\t\t\tCollection col = layer.getParent().hideExcept(type, false);\n\t\t\tselection.removeAll(col);\n\t\t\tDisplay.updateCheckboxes(col, DisplayablePanel.VISIBILITY_STATE);\n\t\t\tDisplay.update(layer.getParent(), false);\n\t\t} else if (command.equals(\"Unhide all\")) {\n\t\t\tDisplay.updateCheckboxes(layer.getParent().setAllVisible(false), DisplayablePanel.VISIBILITY_STATE);\n\t\t\tDisplay.update(layer.getParent(), false);\n\t\t} else if (command.startsWith(\"Hide all \")) {\n\t\t\tString type = command.substring(9, command.length() -1); \n\t\t\tCollection col = layer.getParent().setVisible(type, false, true);\n\t\t\tselection.removeAll(col);\n\t\t\tDisplay.updateCheckboxes(col, DisplayablePanel.VISIBILITY_STATE);\n\t\t} else if (command.startsWith(\"Unhide all \")) {\n\t\t\tString type = command.substring(11, command.length() -1); \n\t\t\ttype = type.substring(0, 1).toUpperCase() + type.substring(1);\n\t\t\tupdateCheckboxes(layer.getParent().setVisible(type, true, true), DisplayablePanel.VISIBILITY_STATE);\n\t\t} else if (command.equals(\"Hide deselected\")) {\n\t\t\thideDeselected(0 != (ActionEvent.ALT_MASK & ae.getModifiers()));\n\t\t} else if (command.equals(\"Hide deselected except images\")) {\n\t\t\thideDeselected(true);\n\t\t} else if (command.equals(\"Hide selected\")) {\n\t\t\tselection.setVisible(false); \n\t\t\tDisplay.updateCheckboxes(selection.getSelected(), DisplayablePanel.VISIBILITY_STATE);\n\t\t} else if (command.equals(\"Resize canvas/LayerSet...\")) {\n\t\t\tresizeCanvas();\n\t\t} else if (command.equals(\"Autoresize canvas/LayerSet\")) {\n\t\t\tlayer.getParent().setMinimumDimensions();\n\t\t} else if (command.equals(\"Import image\")) {\n\t\t\timportImage();\n\t\t} else if (command.equals(\"Import next image\")) {\n\t\t\timportNextImage();\n\t\t} else if (command.equals(\"Import stack...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tRectangle sr = getCanvas().getSrcRect();\n\t\t\tBureaucrat burro = project.getLoader().importStack(layer, sr.x + sr.width/2, sr.y + sr.height/2, null, true, null, false);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t}});\n\t\t} else if (command.equals(\"Import stack with landmarks...\")) {\n\t\t\tList pr = Project.getProjects();\n\t\t\tif (1 == pr.size()) {\n\t\t\t\tUtils.logAll(\"Need another project open!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGenericDialog gd = new GenericDialog(\"Landmarks\");\n\t\t\tgd.addStringField(\"landmarks type:\", \"landmarks\");\n\t\t\tfinal String[] none = {\"-- None --\"};\n\t\t\tfinal Hashtable mpr = new Hashtable();\n\t\t\tfor (Project p : pr) {\n\t\t\t\tif (p == project) continue;\n\t\t\t\tmpr.put(p.toString(), p);\n\t\t\t}\n\t\t\tfinal String[] project_titles = mpr.keySet().toArray(new String[0]);\n\t\t\tfinal Hashtable map_target = findLandmarkNodes(project, \"landmarks\");\n\t\t\tString[] target_landmark_titles = map_target.isEmpty() ? none : map_target.keySet().toArray(new String[0]);\n\t\t\tgd.addChoice(\"Landmarks node in this project:\", target_landmark_titles, target_landmark_titles[0]);\n\t\t\tgd.addMessage(\"\");\n\t\t\tgd.addChoice(\"Source project:\", project_titles, project_titles[0]);\n\t\t\tfinal Hashtable map_source = findLandmarkNodes(mpr.get(project_titles[0]), \"landmarks\");\n\t\t\tString[] source_landmark_titles = map_source.isEmpty() ? none : map_source.keySet().toArray(new String[0]);\n\t\t\tgd.addChoice(\"Landmarks node in source project:\", source_landmark_titles, source_landmark_titles[0]);\n\t\t\tfinal List stacks = Display.getPatchStacks(mpr.get(project_titles[0]).getRootLayerSet());\n\t\t\tString[] stack_titles;\n\t\t\tif (stacks.isEmpty()) {\n\t\t\t\tif (1 == mpr.size()) {\n\t\t\t\t\tIJ.showMessage(\"Project \" + project_titles[0] + \" does not contain any Stack.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tstack_titles = none;\n\t\t\t} else {\n\t\t\t\tstack_titles = new String[stacks.size()];\n\t\t\t\tint next = 0;\n\t\t\t\tfor (Patch pa : stacks) stack_titles[next++] = pa.toString();\n\t\t\t}\n\t\t\tgd.addChoice(\"Stacks:\", stack_titles, stack_titles[0]);\n\t\t\tVector vc = gd.getChoices();\n\t\t\tfinal Choice choice_target_landmarks = (Choice) vc.get(0);\n\t\t\tfinal Choice choice_source_projects = (Choice) vc.get(1);\n\t\t\tfinal Choice choice_source_landmarks = (Choice) vc.get(2);\n\t\t\tfinal Choice choice_stacks = (Choice) vc.get(3);\n\t\t\tfinal TextField input = (TextField) gd.getStringFields().get(0);\n\t\t\tinput.addTextListener(new TextListener() {\n\t\t\t\tpublic void textValueChanged(TextEvent te) {\n\t\t\t\t\tfinal String text = input.getText();\n\t\t\t\t\tupdate(choice_target_landmarks, Display.this.project, text, map_target);\n\t\t\t\t\tupdate(choice_source_landmarks, mpr.get(choice_source_projects.getSelectedItem()), text, map_source);\n\t\t\t\t}\n\t\t\t\tprivate void update(Choice c, Project p, String type, Hashtable table) {\n\t\t\t\t\ttable.clear();\n\t\t\t\t\ttable.putAll(findLandmarkNodes(p, type));\n\t\t\t\t\tc.removeAll();\n\t\t\t\t\tif (table.isEmpty()) c.add(none[0]);\n\t\t\t\t\telse for (String t : table.keySet()) c.add(t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tchoice_source_projects.addItemListener(new ItemListener() {\n\t\t\t\tpublic void itemStateChanged(ItemEvent e) {\n\t\t\t\t\tString item = (String) e.getItem();\n\t\t\t\t\tProject p = mpr.get(choice_source_projects.getSelectedItem());\n\t\t\t\t\tmap_source.clear();\n\t\t\t\t\tmap_source.putAll(findLandmarkNodes(p, input.getText()));\n\t\t\t\t\tchoice_target_landmarks.removeAll();\n\t\t\t\t\tif (map_source.isEmpty()) choice_target_landmarks.add(none[0]);\n\t\t\t\t\telse for (String t : map_source.keySet()) choice_target_landmarks.add(t);\n\t\t\t\t\tstacks.clear();\n\t\t\t\t\tchoice_stacks.removeAll();\n\t\t\t\t\tstacks.addAll(Display.getPatchStacks(mpr.get(project_titles[0]).getRootLayerSet()));\n\t\t\t\t\tif (stacks.isEmpty()) choice_stacks.add(none[0]);\n\t\t\t\t\telse for (Patch pa : stacks) choice_stacks.add(pa.toString());\n\t\t\t\t}\n\t\t\t});\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tString type = gd.getNextString();\n\t\t\tif (null == type || 0 == type.trim().length()) {\n\t\t\t\tUtils.log(\"Invalid landmarks node type!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tProjectThing target_landmarks_node = map_target.get(gd.getNextChoice());\n\t\t\tProject source = mpr.get(gd.getNextChoice());\n\t\t\tProjectThing source_landmarks_node = map_source.get(gd.getNextChoice());\n\t\t\tPatch stack_patch = stacks.get(gd.getNextChoiceIndex());\n\t\t\tDisplay.this.getLayerSet().addLayerContentStep(layer);\n\t\t\tinsertStack(target_landmarks_node, source, source_landmarks_node, stack_patch);\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t} else if (command.equals(\"Import grid...\")) {\n\t\t\tDisplay.this.getLayerSet().addLayerContentStep(layer);\n\t\t\tBureaucrat burro = project.getLoader().importGrid(layer);\n\t\t\tif (null != burro)\n\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\tDisplay.this.getLayerSet().addLayerContentStep(layer);\n\t\t\t\t}});\n\t\t} else if (command.equals(\"Import sequence as grid...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tBureaucrat burro = project.getLoader().importSequenceAsGrid(layer);\n\t\t\tif (null != burro)\n\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t\t}});\n\t\t} else if (command.equals(\"Import from text file...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tBureaucrat burro = project.getLoader().importImages(layer);\n\t\t\tif (null != burro)\n\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t\t}});\n\t\t} else if (command.equals(\"Import labels as arealists...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tBureaucrat burro = project.getLoader().importLabelsAsAreaLists(layer, null, Double.MAX_VALUE, 0, 0.4f, false);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t}});\n\t\t} else if (command.equals(\"Make flat image...\")) {\n\t\t\tRectangle srcRect = null;\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null != roi) {\n\t\t\t\tsrcRect = roi.getBounds();\n\t\t\t} else {\n\t\t\t\tsrcRect = new Rectangle(0, 0, (int)Math.ceil(layer.getParent().getLayerWidth()), (int)Math.ceil(layer.getParent().getLayerHeight()));\n\t\t\t}\n\t\t\tdouble scale = 1.0;\n\t\t\tfinal String[] types = new String[]{\"8-bit grayscale\", \"RGB Color\"};\n\t\t\tint the_type = ImagePlus.GRAY8;\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose\", frame);\n\t\t\tgd.addSlider(\"Scale: \", 1, 100, 100);\n\t\t\tgd.addNumericField(\"Width: \", srcRect.width, 0);\n\t\t\tgd.addNumericField(\"height: \", srcRect.height, 0);\n\t\t\tVector numfields = gd.getNumericFields();\n\t\t\tUpdateDimensionField udf = new UpdateDimensionField(srcRect.width, srcRect.height, (TextField) numfields.get(1), (TextField) numfields.get(2), (TextField) numfields.get(0), (Scrollbar) gd.getSliders().get(0));\n\t\t\tfor (Object ob : numfields) ((TextField)ob).addTextListener(udf);\n\t\t\tgd.addChoice(\"Type: \", types, types[0]);\n\t\t\tif (layer.getParent().size() > 1) {\n\t\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd); \n\t\t\t\tgd.addCheckbox(\"Include non-empty layers only\", true);\n\t\t\t}\n\t\t\tgd.addMessage(\"Background color:\");\n\t\t\tUtils.addRGBColorSliders(gd, Color.black);\n\t\t\tgd.addCheckbox(\"Best quality\", false);\n\t\t\tgd.addMessage(\"\");\n\t\t\tgd.addCheckbox(\"Save to file\", false);\n\t\t\tgd.addCheckbox(\"Save for web\", false);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tscale = gd.getNextNumber() / 100;\n\t\t\tthe_type = (0 == gd.getNextChoiceIndex() ? ImagePlus.GRAY8 : ImagePlus.COLOR_RGB);\n\t\t\tif (Double.isNaN(scale) || scale <= 0.0) {\n\t\t\t\tUtils.showMessage(\"Invalid scale.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgd.getNextNumber();\n\t\t\tgd.getNextNumber();\n\t\t\tLayer[] layer_array = null;\n\t\t\tboolean non_empty_only = false;\n\t\t\tif (layer.getParent().size() > 1) {\n\t\t\t\tnon_empty_only = gd.getNextBoolean();\n\t\t\t\tint i_start = gd.getNextChoiceIndex();\n\t\t\t\tint i_end = gd.getNextChoiceIndex();\n\t\t\t\tArrayList al = new ArrayList();\n\t\t\t\tArrayList al_zd = layer.getParent().getZDisplayables();\n\t\t\t\tZDisplayable[] zd = new ZDisplayable[al_zd.size()];\n\t\t\t\tal_zd.toArray(zd);\n\t\t\t\tfor (int i=i_start, j=0; i <= i_end; i++, j++) {\n\t\t\t\t\tLayer la = layer.getParent().getLayer(i);\n\t\t\t\t\tif (!la.isEmpty() || !non_empty_only) al.add(la); \n\t\t\t\t}\n\t\t\t\tif (0 == al.size()) {\n\t\t\t\t\tUtils.showMessage(\"All layers are empty!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlayer_array = new Layer[al.size()];\n\t\t\t\tal.toArray(layer_array);\n\t\t\t} else {\n\t\t\t\tlayer_array = new Layer[]{Display.this.layer};\n\t\t\t}\n\t\t\tfinal Color background = new Color((int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber());\n\t\t\tfinal boolean quality = gd.getNextBoolean();\n\t\t\tfinal boolean save_to_file = gd.getNextBoolean();\n\t\t\tfinal boolean save_for_web = gd.getNextBoolean();\n\t\t\tif (save_for_web) project.getLoader().makePrescaledTiles(layer_array, Patch.class, srcRect, scale, c_alphas, the_type);\n\t\t\telse project.getLoader().makeFlatImage(layer_array, srcRect, scale, c_alphas, the_type, save_to_file, quality, background);\n\t\t} else if (command.equals(\"Lock\")) {\n\t\t\tselection.setLocked(true);\n\t\t\tUtils.revalidateComponent(tabs.getSelectedComponent());\n\t\t} else if (command.equals(\"Unlock\")) {\n\t\t\tselection.setLocked(false);\n\t\t\tUtils.revalidateComponent(tabs.getSelectedComponent());\n\t\t} else if (command.equals(\"Properties...\")) {\n\t\t\tactive.adjustProperties();\n\t\t\tupdateSelection();\n\t\t} else if (command.equals(\"Show current 2D position in 3D\")) {\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tDisplay3D.addFatPoint(\"Current 2D Position\", getLayerSet(), p.x, p.y, layer.getZ(), 10, Color.magenta);\n\t\t} else if (command.equals(\"Show layers as orthoslices in 3D\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Options\");\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tRectangle r = null == roi ? getLayerSet().get2DBounds() : roi.getBounds();\n\t\t\tgd.addMessage(\"ROI 2D bounds:\");\n\t\t\tgd.addNumericField(\"x:\", r.x, 0, 30, \"pixels\");\n\t\t\tgd.addNumericField(\"y:\", r.y, 0, 30, \"pixels\");\n\t\t\tgd.addNumericField(\"width:\", r.width, 0, 30, \"pixels\");\n\t\t\tgd.addNumericField(\"height:\", r.height, 0, 30, \"pixels\");\n\t\t\tgd.addMessage(\"Layers to include:\");\n\t\t\tUtils.addLayerRangeChoices(layer, gd);\n\t\t\tgd.addMessage(\"Constrain dimensions to:\");\n\t\t\tgd.addNumericField(\"max width and height:\", getLayerSet().getPixelsMaxDimension(), 0, 30, \"pixels\");\n\t\t\tgd.addMessage(\"Options:\");\n\t\t\tfinal String[] types = {\"Greyscale\", \"Color RGB\"};\n\t\t\tgd.addChoice(\"Image type:\", types, types[0]);\n\t\t\tgd.addCheckbox(\"Invert images\", false);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tint x = (int)gd.getNextNumber(),\n\t\t\t y = (int)gd.getNextNumber(),\n\t\t\t width = (int)gd.getNextNumber(),\n\t\t\t height = (int)gd.getNextNumber();\n\t\t\tfinal int first = gd.getNextChoiceIndex(),\n\t\t\t\t\t last = gd.getNextChoiceIndex();\n\t\t\tfinal List layers = getLayerSet().getLayers(first, last);\n\t\t\tfinal int max_dim = (int)gd.getNextNumber();\n\t\t\tfloat scale = 1;\n\t\t\tif (max_dim < Math.max(width, height)) {\n\t\t\t\tscale = max_dim / (float)Math.max(width, height);\n\t\t\t}\n\t\t\tfinal int type = 0 == gd.getNextChoiceIndex() ? ImagePlus.GRAY8 : ImagePlus.COLOR_RGB;\n\t\t\tfinal boolean invert = gd.getNextBoolean();\n\t\t\tfinal LayerStack stack = new LayerStack(layers, new Rectangle(x, y, width, height), scale, type, Patch.class, max_dim, invert);\n\t\t\tDisplay3D.showOrthoslices(stack.getImagePlus(), \"LayerSet [\" + x + \",\" + y + \",\" + width + \",\" + height + \"] \" + first + \"--\" + last, x, y, scale, layers.get(0));\n\t\t} else if (command.equals(\"Align stack slices\")) {\n\t\t\tif (getActive() instanceof Patch) {\n\t\t\t\tfinal Patch slice = (Patch)getActive();\n\t\t\t\tif (slice.isStack()) {\n\t\t\t\t\tfinal HashSet hs = slice.getLinkedGroup(new HashSet());\n\t\t\t\t\tfor (Iterator it = hs.iterator(); it.hasNext(); ) {\n\t\t\t\t\t\tif (it.next().getClass() != Patch.class) {\n\t\t\t\t\t\t\tUtils.showMessage(\"Images are linked to other objects, can't proceed to cross-correlate them.\"); \n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfinal LayerSet ls = slice.getLayerSet();\n\t\t\t\t\tfinal HashSet linked = slice.getLinkedGroup(null);\n\t\t\t\t\tls.addTransformStepWithData(linked);\n\t\t\t\t\tBureaucrat burro = AlignTask.registerStackSlices((Patch)getActive()); \n\t\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\t\tls.enlargeToFit(linked);\n\t\t\t\t\t\tls.addTransformStepWithData(linked);\n\t\t\t\t\t}});\n\t\t\t\t} else {\n\t\t\t\t\tUtils.log(\"Align stack slices: selected image is not part of a stack.\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (command.equals(\"Align layers with manual landmarks\")) {\n\t\t\tsetMode(new ManualAlignMode(Display.this));\n\t\t} else if (command.equals(\"Align layers\")) {\n\t\t\tfinal Layer la = layer; \n\t\t\tla.getParent().addTransformStep(la.getParent().getLayers());\n\t\t\tBureaucrat burro = AlignLayersTask.alignLayersTask( la );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().enlargeToFit(getLayerSet().getDisplayables(Patch.class));\n\t\t\t\tla.getParent().addTransformStep(la.getParent().getLayers());\n\t\t\t}});\n\t\t} else if (command.equals(\"Align multi-layer mosaic\")) {\n\t\t\tfinal Layer la = layer; \n\t\t\tla.getParent().addTransformStep();\n\t\t\tBureaucrat burro = AlignTask.alignMultiLayerMosaicTask( la );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().enlargeToFit(getLayerSet().getDisplayables(Patch.class));\n\t\t\t\tla.getParent().addTransformStep();\n\t\t\t}});\n\t\t} else if (command.equals(\"Montage all images in this layer\")) {\n\t\t\tfinal Layer la = layer;\n\t\t\tfinal List patches = new ArrayList( (List) (List) la.getDisplayables(Patch.class));\n\t\t\tif (patches.size() < 2) {\n\t\t\t\tUtils.showMessage(\"Montage needs 2 or more images selected\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal Collection col = la.getParent().addTransformStepWithData(Arrays.asList(new Layer[]{la}));\n\t\t\tfinal ArrayList fixed = new ArrayList();\n\t\t\tfor (final Patch p : patches) {\n\t\t\t\tif (p.isLocked2()) fixed.add(p);\n\t\t\t}\n\t\t\tif (fixed.isEmpty()) fixed.add(patches.get(0));\n\t\t\tBureaucrat burro = AlignTask.alignPatchesTask(patches, fixed);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().enlargeToFit(patches);\n\t\t\t\tla.getParent().addTransformStepWithData(col);\n\t\t\t}});\n\t\t} else if (command.equals(\"Montage selected images (SIFT)\")) {\n\t\t\tmontage(0);\n\t\t} else if (command.equals(\"Montage selected images (phase correlation)\")) {\n\t\t\tmontage(1);\n\t\t} else if (command.equals(\"Montage multiple layers (phase correlation)\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal List layers = getLayerSet().getLayers(gd.getNextChoiceIndex(), gd.getNextChoiceIndex());\n\t\t\tfinal Collection col = getLayerSet().addTransformStepWithData(layers);\n\t\t\tBureaucrat burro = StitchingTEM.montageWithPhaseCorrelation(layers);\n\t\t\tif (null == burro) return;\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tCollection ds = new ArrayList();\n\t\t\t\tfor (Layer la : layers) ds.addAll(la.getDisplayables(Patch.class));\n\t\t\t\tgetLayerSet().enlargeToFit(ds);\n\t\t\t\tgetLayerSet().addTransformStepWithData(col);\n\t\t\t}});\n\t\t} else if (command.equals(\"Montage multiple layers (SIFT)\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal List layers = getLayerSet().getLayers(gd.getNextChoiceIndex(), gd.getNextChoiceIndex());\n\t\t\tfinal Collection col = getLayerSet().addTransformStepWithData(layers);\n\t\t\tBureaucrat burro = AlignTask.montageLayersTask(layers);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tCollection ds = new ArrayList();\n\t\t\t\tfor (Layer la : layers) ds.addAll(la.getDisplayables(Patch.class));\n\t\t\t\tgetLayerSet().enlargeToFit(ds);\n\t\t\t\tgetLayerSet().addTransformStepWithData(col);\n\t\t\t}});\n\t\t} else if (command.equals(\"Properties ...\")) { \n\t\t\tGenericDialog gd = new GenericDialog(\"Properties\", Display.this.frame);\n\t\t\tgd.addSlider(\"layer_scroll_step: \", 1, layer.getParent().size(), Display.this.scroll_step);\n\t\t\tgd.addChoice(\"snapshots_mode\", LayerSet.snapshot_modes, LayerSet.snapshot_modes[layer.getParent().getSnapshotsMode()]);\n\t\t\tgd.addCheckbox(\"prefer_snapshots_quality\", layer.getParent().snapshotsQuality());\n\t\t\tLoader lo = getProject().getLoader();\n\t\t\tboolean using_mipmaps = lo.isMipMapsEnabled();\n\t\t\tgd.addCheckbox(\"enable_mipmaps\", using_mipmaps);\n\t\t\tgd.addCheckbox(\"enable_layer_pixels virtualization\", layer.getParent().isPixelsVirtualizationEnabled());\n\t\t\tdouble max = layer.getParent().getLayerWidth() < layer.getParent().getLayerHeight() ? layer.getParent().getLayerWidth() : layer.getParent().getLayerHeight();\n\t\t\tgd.addSlider(\"max_dimension of virtualized layer pixels: \", 0, max, layer.getParent().getPixelsMaxDimension());\n\t\t\tgd.addCheckbox(\"Show arrow heads in Treeline/AreaTree\", layer.getParent().paint_arrows);\n\t\t\tgd.addCheckbox(\"Show edge confidence boxes in Treeline/AreaTree\", layer.getParent().paint_edge_confidence_boxes);\n\t\t\tgd.addCheckbox(\"Show color cues\", layer.getParent().color_cues);\n\t\t\tgd.addSlider(\"+/- layers to color cue\", 0, 10, layer.getParent().n_layers_color_cue);\n\t\t\tgd.addCheckbox(\"Show color cues for areas\", layer.getParent().area_color_cues);\n\t\t\tgd.addCheckbox(\"Use red/blue for color cues\", layer.getParent().use_color_cue_colors);\n\t\t\tgd.addCheckbox(\"Prepaint images\", layer.getParent().prepaint);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tint sc = (int) gd.getNextNumber();\n\t\t\tif (sc < 1) sc = 1;\n\t\t\tDisplay.this.scroll_step = sc;\n\t\t\tupdateInDatabase(\"scroll_step\");\n\t\t\tlayer.getParent().setSnapshotsMode(gd.getNextChoiceIndex());\n\t\t\tlayer.getParent().setSnapshotsQuality(gd.getNextBoolean());\n\t\t\tboolean generate_mipmaps = gd.getNextBoolean();\n\t\t\tif (using_mipmaps && generate_mipmaps) {\n\t\t\t} else {\n\t\t\t\tif (using_mipmaps) { \n\t\t\t\t\tlo.flushMipMaps(true);\n\t\t\t\t} else {\n\t\t\t\t\tlo.generateMipMaps(layer.getParent().getDisplayables(Patch.class));\n\t\t\t\t}\n\t\t\t}\n\t\t\tlayer.getParent().setPixelsVirtualizationEnabled(gd.getNextBoolean());\n\t\t\tlayer.getParent().setPixelsMaxDimension((int)gd.getNextNumber());\n\t\t\tlayer.getParent().paint_arrows = gd.getNextBoolean();\n\t\t\tlayer.getParent().paint_edge_confidence_boxes = gd.getNextBoolean();\n\t\t\tlayer.getParent().color_cues = gd.getNextBoolean();\n\t\t\tlayer.getParent().n_layers_color_cue = (int)gd.getNextNumber();\n\t\t\tlayer.getParent().area_color_cues = gd.getNextBoolean();\n\t\t\tlayer.getParent().use_color_cue_colors = gd.getNextBoolean();\n\t\t\tlayer.getParent().prepaint = gd.getNextBoolean();\n\t\t\tDisplay.repaint(layer.getParent());\n\t\t} else if (command.equals(\"Adjust snapping parameters...\")) {\n\t\t\tAlignTask.p_snap.setup(\"Snap\");\n\t\t} else if (command.equals(\"Adjust fast-marching parameters...\")) {\n\t\t\tSegmentation.fmp.setup();\n\t\t} else if (command.equals(\"Adjust arealist paint parameters...\")) {\n\t\t\tAreaWrapper.PP.setup();\n\t\t} else if (command.equals(\"Search...\")) {\n\t\t\tnew Search();\n\t\t} else if (command.equals(\"Select all\")) {\n\t\t\tselection.selectAll();\n\t\t\trepaint(Display.this.layer, selection.getBox(), 0);\n\t\t} else if (command.equals(\"Select all visible\")) {\n\t\t\tselection.selectAllVisible();\n\t\t\trepaint(Display.this.layer, selection.getBox(), 0);\n\t\t} else if (command.equals(\"Select none\")) {\n\t\t\tRectangle box = selection.getBox();\n\t\t\tselection.clear();\n\t\t\trepaint(Display.this.layer, box, 0);\n\t\t} else if (command.equals(\"Restore selection\")) {\n\t\t\tselection.restore();\n\t\t} else if (command.equals(\"Select under ROI\")) {\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null == roi) return;\n\t\t\tselection.selectAll(roi, true);\n\t\t} else if (command.equals(\"Merge\")) {\n\t\t\tBureaucrat burro = Bureaucrat.create(new Worker.Task(\"Merging AreaLists\") {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\tArrayList al_sel = selection.getSelected(AreaList.class);\n\t\t\t\t\tal_sel.remove(Display.this.active);\n\t\t\t\t\tal_sel.add(0, Display.this.active);\n\t\t\t\t\tSet dataedits = new HashSet();\n\t\t\t\t\tdataedits.add(new Displayable.DoEdit(Display.this.active).init(Display.this.active, new String[]{\"data\"}));\n\t\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits);\n\t\t\t\t\tAreaList ali = AreaList.merge(al_sel);\n\t\t\t\t\tif (null != ali) {\n\t\t\t\t\t\tfor (int i=1; i dataedits = new HashSet();\n\t\t\t\tdataedits.add(new Displayable.DoEdit(Display.this.active).init(Display.this.active, new String[]{\"data\"}));\n\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits);\n\t\t\t}});\n\t\t\tburro.goHaveBreakfast();\n\t\t} else if (command.equals(\"Reroot\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t\t((Tree)active).reRoot(p.x, p.y, layer, canvas.getMagnification());\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t\tDisplay.repaint(getLayerSet());\n\t\t} else if (command.equals(\"Part subtree\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tif (!Utils.check(\"Really part the subtree?\")) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tList ts = ((Tree)active).splitNear(p.x, p.y, layer, canvas.getMagnification());\n\t\t\tif (null == ts) return;\n\t\t\tDisplayable elder = Display.this.active;\n\t\t\tfor (ZDisplayable t : ts) {\n\t\t\t\tif (t == elder) continue;\n\t\t\t\tgetLayerSet().add(t); \n\t\t\t\tproject.getProjectTree().addSibling(elder, t);\n\t\t\t}\n\t\t\tselection.clear();\n\t\t\tselection.selectAll(ts);\n\t\t\tselection.add(elder);\n\t\t\tgetLayerSet().addChangeTreesStep();\n\t\t\tDisplay.repaint(getLayerSet());\n\t\t} else if (command.equals(\"Show tabular view\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\t((Tree)active).createMultiTableView();\n\t\t} else if (command.equals(\"Mark\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tif (((Tree)active).markNear(p.x, p.y, layer, canvas.getMagnification())) {\n\t\t\t\tDisplay.repaint(getLayerSet());\n\t\t\t}\n\t\t} else if (command.equals(\"Clear marks (selected Trees)\")) {\n\t\t\tfor (Tree t : selection.get(Tree.class)) {\n\t\t\t\tt.unmark();\n\t\t\t}\n\t\t\tDisplay.repaint(getLayerSet());\n\t\t} else if (command.equals(\"Join\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tfinal List> tlines = (List>) selection.get(active.getClass());\n\t\t\tif (((Tree)active).canJoin(tlines)) {\n\t\t\t\tif (!Utils.check(\"Join these \" + tlines.size() + \" trees into the tree \" + active + \" ?\")) return;\n\t\t\t\tSet dataedits = new HashSet(tlines.size());\n\t\t\t\tfor (final Tree tl : tlines) {\n\t\t\t\t\tdataedits.add(new Displayable.DoEdit(tl).init(tl, new String[]{\"data\"}));\n\t\t\t\t}\n\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits);\n\t\t\t\t((Tree)active).join(tlines);\n\t\t\t\tfor (final Tree tl : tlines) {\n\t\t\t\t\tif (tl == active) continue;\n\t\t\t\t\ttl.remove2(false);\n\t\t\t\t}\n\t\t\t\tDisplay.repaint(getLayerSet());\n\t\t\t\tSet dataedits2 = new HashSet(1);\n\t\t\t\tdataedits2.add(new Displayable.DoEdit(active).init(active, new String[]{\"data\"}));\n\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits2);\n\t\t\t}\n\t\t} else if (command.equals(\"Previous branch point or start\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tcenter(((Treeline)active).findPreviousBranchOrRootPoint(p.x, p.y, layer, canvas));\n\t\t} else if (command.equals(\"Next branch point or end\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tcenter(((Tree)active).findNextBranchOrEndPoint(p.x, p.y, layer, canvas));\n\t\t} else if (command.equals(\"Root\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tcenter(((Tree)active).createCoordinate(((Tree)active).getRoot()));\n\t\t} else if (command.equals(\"Last added point\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tcenter(((Treeline)active).getLastAdded());\n\t\t} else if (command.equals(\"Last edited point\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tcenter(((Treeline)active).getLastEdited());\n\t\t} else if (command.equals(\"Reverse point order\")) {\n\t\t\tif (!(active instanceof Pipe)) return;\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t\t((Pipe)active).reverse();\n\t\t\tDisplay.repaint(Display.this.layer);\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t} else if (command.equals(\"View orthoslices\")) {\n\t\t\tif (!(active instanceof Patch)) return;\n\t\t\tDisplay3D.showOrthoslices(((Patch)active));\n\t\t} else if (command.equals(\"View volume\")) {\n\t\t\tif (!(active instanceof Patch)) return;\n\t\t\tDisplay3D.showVolume(((Patch)active));\n\t\t} else if (command.equals(\"Show in 3D\")) {\n\t\t\tfor (ZDisplayable zd : selection.get(ZDisplayable.class)) {\n\t\t\t\tDisplay3D.show(zd.getProject().findProjectThing(zd));\n\t\t\t}\n\t\t\tHashSet hs = new HashSet();\n\t\t\tfor (Profile d : selection.get(Profile.class)) {\n\t\t\t\tProjectThing profile_list = (ProjectThing)d.getProject().findProjectThing(d).getParent();\n\t\t\t\tif (!hs.contains(profile_list)) {\n\t\t\t\t\tDisplay3D.show(profile_list);\n\t\t\t\t\ths.add(profile_list);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (command.equals(\"Snap\")) {\n\t\t\tif (!(active instanceof Patch)) return;\n\t\t\tDisplay.snap((Patch)active);\n\t\t} else if (command.equals(\"Blend\")) {\n\t\t\tHashSet patches = new HashSet();\n\t\t\tfor (final Displayable d : selection.getSelected()) {\n\t\t\t\tif (d.getClass() == Patch.class) patches.add((Patch)d);\n\t\t\t}\n\t\t\tif (patches.size() > 1) {\n\t\t\t\tGenericDialog gd = new GenericDialog(\"Blending\");\n\t\t\t\tgd.addCheckbox(\"Respect current alpha mask\", true);\n\t\t\t\tgd.showDialog();\n\t\t\t\tif (gd.wasCanceled()) return;\n\t\t\t\tBlending.blend(patches, gd.getNextBoolean());\n\t\t\t} else {\n\t\t\t\tIJ.log(\"Please select more than one overlapping image.\");\n\t\t\t}\n\t\t} else if (command.equals(\"Montage\")) {\n\t\t\tfinal Set affected = new HashSet(selection.getAffected());\n\t\t\tfinal LayerSet ls = layer.getParent();\n\t\t\tls.addTransformStepWithData(affected);\n\t\t\tBureaucrat burro = AlignTask.alignSelectionTask( selection );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tls.enlargeToFit(affected);\n\t\t\t\tls.addTransformStepWithData(affected);\n\t\t\t}});\n\t\t} else if (command.equals(\"Lens correction\")) {\n\t\t\tfinal Layer la = layer;\n\t\t\tla.getParent().addDataEditStep(new HashSet(la.getParent().getDisplayables()));\n\t\t\tBureaucrat burro = DistortionCorrectionTask.correctDistortionFromSelection( selection );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tla.getParent().addDataEditStep(new HashSet(la.getParent().getDisplayables()));\n\t\t\t}});\n\t\t} else if (command.equals(\"Link images...\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Options\");\n\t\t\tgd.addMessage(\"Linking images to images (within their own layer only):\");\n\t\t\tString[] options = {\"all images to all images\", \"each image with any other overlapping image\"};\n\t\t\tgd.addChoice(\"Link: \", options, options[1]);\n\t\t\tString[] options2 = {\"selected images only\", \"all images in this layer\", \"all images in all layers, within the layer only\", \"all images in all layers, within and across consecutive layers\"};\n\t\t\tgd.addChoice(\"Apply to: \", options2, options2[0]);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tLayer lay = layer;\n\t\t\tfinal HashSet ds = new HashSet(lay.getParent().getDisplayables());\n\t\t\tlay.getParent().addDataEditStep(ds, new String[]{\"data\"});\n\t\t\tboolean overlapping_only = 1 == gd.getNextChoiceIndex();\n\t\t\tCollection coll = null;\n\t\t\tswitch (gd.getNextChoiceIndex()) {\n\t\t\t\tcase 0:\n\t\t\t\t\tcoll = selection.getSelected(Patch.class);\n\t\t\t\t\tPatch.crosslink(coll, overlapping_only);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tcoll = lay.getDisplayables(Patch.class);\n\t\t\t\t\tPatch.crosslink(coll, overlapping_only);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tcoll = new ArrayList();\n\t\t\t\t\tfor (final Layer la : lay.getParent().getLayers()) {\n\t\t\t\t\t\tCollection acoll = la.getDisplayables(Patch.class);\n\t\t\t\t\t\tPatch.crosslink(acoll, overlapping_only);\n\t\t\t\t\t\tcoll.addAll(acoll);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tArrayList layers = lay.getParent().getLayers();\n\t\t\t\t\tCollection lc1 = layers.get(0).getDisplayables(Patch.class);\n\t\t\t\t\tif (lay == layers.get(0)) coll = lc1;\n\t\t\t\t\tfor (int i=1; i lc2 = layers.get(i).getDisplayables(Patch.class);\n\t\t\t\t\t\tif (null == coll && Display.this.layer == layers.get(i)) coll = lc2;\n\t\t\t\t\t\tCollection both = new ArrayList();\n\t\t\t\t\t\tboth.addAll(lc1);\n\t\t\t\t\t\tboth.addAll(lc2);\n\t\t\t\t\t\tPatch.crosslink(both, overlapping_only);\n\t\t\t\t\t\tlc1 = lc2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (null != coll) Display.updateCheckboxes(coll, DisplayablePanel.LINK_STATE, true);\n\t\t\tlay.getParent().addDataEditStep(ds);\n\t\t} else if (command.equals(\"Unlink all selected images\")) {\n\t\t\tif (Utils.check(\"Really unlink selected images?\")) {\n\t\t\t\tfor (final Displayable d : selection.getSelected(Patch.class)) {\n\t\t\t\t\td.unlink();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (command.equals(\"Unlink all\")) {\n\t\t\tif (Utils.check(\"Really unlink all objects from all layers?\")) {\n\t\t\t\tCollection ds = layer.getParent().getDisplayables();\n\t\t\t\tfor (final Displayable d : ds) {\n\t\t\t\t\td.unlink();\n\t\t\t\t}\n\t\t\t\tDisplay.updateCheckboxes(ds, DisplayablePanel.LOCK_STATE);\n\t\t\t}\n\t\t} else if (command.equals(\"Calibration...\")) {\n\t\t\ttry {\n\t\t\t\tIJ.run(canvas.getFakeImagePlus(), \"Properties...\", \"\");\n\t\t\t\tDisplay.updateTitle(getLayerSet());\n\t\t\t} catch (RuntimeException re) {\n\t\t\t\tUtils.log2(\"Calibration dialog canceled.\");\n\t\t\t}\n\t\t} else if (command.equals(\"Grid overlay...\")) {\n\t\t\tif (null == gridoverlay) gridoverlay = new GridOverlay();\n\t\t\tgridoverlay.setup(canvas.getFakeImagePlus().getRoi());\n\t\t\tcanvas.repaint(false);\n\t\t} else if (command.equals(\"Enhance contrast (selected images)...\")) {\n\t\t\tfinal Layer la = layer;\n\t\t\tArrayList selected = selection.getSelected(Patch.class);\n\t\t\tfinal HashSet ds = new HashSet(selected);\n\t\t\tla.getParent().addDataEditStep(ds);\n\t\t\tDisplayable active = Display.this.getActive();\n\t\t\tPatch ref = active.getClass() == Patch.class ? (Patch)active : null;\n\t\t\tBureaucrat burro = getProject().getLoader().enhanceContrast(selected, ref);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tla.getParent().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Enhance contrast layer-wise...\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tjava.util.List layers = layer.getParent().getLayers().subList(gd.getNextChoiceIndex(), gd.getNextChoiceIndex() +1); \n\t\t\tfinal HashSet ds = new HashSet();\n\t\t\tfor (final Layer l : layers) ds.addAll(l.getDisplayables(Patch.class));\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().enhanceContrast(layers);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Set Min and Max layer-wise...\")) {\n\t\t\tDisplayable active = getActive();\n\t\t\tdouble min = 0;\n\t\t\tdouble max = 0;\n\t\t\tif (null != active && active.getClass() == Patch.class) {\n\t\t\t\tmin = ((Patch)active).getMin();\n\t\t\t\tmax = ((Patch)active).getMax();\n\t\t\t}\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Min and Max\");\n\t\t\tgd.addMessage(\"Set min and max to all images in the layer range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.addNumericField(\"min: \", min, 2);\n\t\t\tgd.addNumericField(\"max: \", max, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tmin = gd.getNextNumber();\n\t\t\tmax = gd.getNextNumber();\n\t\t\tArrayList al = new ArrayList();\n\t\t\tfor (final Layer la : layer.getParent().getLayers().subList(gd.getNextChoiceIndex(), gd.getNextChoiceIndex() +1)) { \n\t\t\t\tal.addAll(la.getDisplayables(Patch.class));\n\t\t\t}\n\t\t\tfinal HashSet ds = new HashSet(al);\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().setMinAndMax(al, min, max);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Set Min and Max (selected images)...\")) {\n\t\t\tDisplayable active = getActive();\n\t\t\tdouble min = 0;\n\t\t\tdouble max = 0;\n\t\t\tif (null != active && active.getClass() == Patch.class) {\n\t\t\t\tmin = ((Patch)active).getMin();\n\t\t\t\tmax = ((Patch)active).getMax();\n\t\t\t}\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Min and Max\");\n\t\t\tgd.addMessage(\"Set min and max to all selected images\");\n\t\t\tgd.addNumericField(\"min: \", min, 2);\n\t\t\tgd.addNumericField(\"max: \", max, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tmin = gd.getNextNumber();\n\t\t\tmax = gd.getNextNumber();\n\t\t\tfinal HashSet ds = new HashSet(selection.getSelected(Patch.class));\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().setMinAndMax(selection.getSelected(Patch.class), min, max);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Adjust min and max (selected images)...\")) {\n\t\t\tfinal List list = selection.getSelected(Patch.class);\n\t\t\tif (list.isEmpty()) {\n\t\t\t\tUtils.log(\"No images selected!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Init contrast adjustment\") {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsetMode(new ContrastAdjustmentMode(Display.this, list));\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tUtils.log(\"All images must be of the same type!\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, list.get(0).getProject());\n\t\t} else if (command.equals(\"Mask image borders (layer-wise)...\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Mask borders\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.addMessage(\"Borders:\");\n\t\t\tgd.addNumericField(\"left: \", 6, 2);\n\t\t\tgd.addNumericField(\"top: \", 6, 2);\n\t\t\tgd.addNumericField(\"right: \", 6, 2);\n\t\t\tgd.addNumericField(\"bottom: \", 6, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tCollection layers = layer.getParent().getLayers().subList(gd.getNextChoiceIndex(), gd.getNextChoiceIndex() +1);\n\t\t\tfinal HashSet ds = new HashSet();\n\t\t\tfor (Layer l : layers) ds.addAll(l.getDisplayables(Patch.class));\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().maskBordersLayerWise(layers, (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber());\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Mask image borders (selected images)...\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Mask borders\");\n\t\t\tgd.addMessage(\"Borders:\");\n\t\t\tgd.addNumericField(\"left: \", 6, 2);\n\t\t\tgd.addNumericField(\"top: \", 6, 2);\n\t\t\tgd.addNumericField(\"right: \", 6, 2);\n\t\t\tgd.addNumericField(\"bottom: \", 6, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tCollection patches = selection.getSelected(Patch.class);\n\t\t\tfinal HashSet ds = new HashSet(patches);\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().maskBorders(patches, (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber());\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Split images under polyline ROI\")) {\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null == roi) return;\n\t\t\tif (roi.getType() != Roi.POLYLINE) {\n\t\t\t\tUtils.showMessage(\"Need a polyline ROI, not just any ROI!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!Utils.check(\"Really split images under the polyline ROI?\")) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal Set col = new HashSet();\n\t\t\tPolygonRoi proi = (PolygonRoi)roi;\n\t\t\tint[] x = proi.getXCoordinates(),\n\t\t\t\t y = proi.getYCoordinates();\n\t\t\tRectangle b = proi.getBounds();\n\t\t\tPolygon[] pols = new Polygon[proi.getNCoordinates() -1];\n\t\t\tfor (int i=0; i> fus = new ArrayList>();\n\t\t\t\t\t\t\t\tfor (final Patch p : (Collection)(Collection)col) {\n\t\t\t\t\t\t\t\t\tPatch copy = (Patch) p.clone(p.getProject(), false);\n\t\t\t\t\t\t\t\t\tp.addAlphaMask(r1, 0);\n\t\t\t\t\t\t\t\t\tcopy.addAlphaMask(r2, 0);\n\t\t\t\t\t\t\t\t\tfus.add(p.updateMipMaps());\n\t\t\t\t\t\t\t\t\tfus.add(copy.updateMipMaps());\n\t\t\t\t\t\t\t\t\tp.getLayer().add(copy); \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tUtils.wait(fus);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, project);\n\t\t\t\t\t} catch (Throwable t) {\n\t\t\t\t\t\tIJError.print(t);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tyn.dispose();\n\t\t\t\t\t\tDisplay.repaint(getLayer());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tyn.setVisible(true);\n\t\t} else if (command.equals(\"Duplicate\")) {\n\t\t\tfinal HashSet accepted = new HashSet();\n\t\t\taccepted.add(Patch.class);\n\t\t\taccepted.add(DLabel.class);\n\t\t\taccepted.add(Stack.class);\n\t\t\tfinal ArrayList originals = new ArrayList();\n\t\t\tfinal ArrayList selected = selection.getSelected();\n\t\t\tfor (final Displayable d : selected) {\n\t\t\t\tif (accepted.contains(d.getClass())) {\n\t\t\t\t\toriginals.add(d);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (originals.size() > 0) {\n\t\t\t\tgetLayerSet().addChangeTreesStep();\n\t\t\t\tfor (final Displayable d : originals) {\n\t\t\t\t\tif (d instanceof ZDisplayable) {\n\t\t\t\t\t\td.getLayerSet().add((ZDisplayable)d.clone());\n\t\t\t\t\t} else {\n\t\t\t\t\t\td.getLayer().add(d.clone());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgetLayerSet().addChangeTreesStep();\n\t\t\t} else if (selected.size() > 0) {\n\t\t\t\tUtils.log(\"Can only duplicate images and text labels.\\nDuplicate *other* objects in the Project Tree.\\n\");\n\t\t\t}\n\t\t} else if (command.equals(\"Create subproject\")) {\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null == roi) return; \n\t\t\tLayer first, last;\n\t\t\tif (1 == layer.getParent().size()) {\n\t\t\t\tfirst = last = layer;\n\t\t\t} else {\n\t\t\t\tGenericDialog gd = new GenericDialog(\"Choose layer range\");\n\t\t\t\tUtils.addLayerRangeChoices(layer, gd);\n\t\t\t\tgd.showDialog();\n\t\t\t\tif (gd.wasCanceled()) return;\n\t\t\t\tfirst = layer.getParent().getLayer(gd.getNextChoiceIndex());\n\t\t\t\tlast = layer.getParent().getLayer(gd.getNextChoiceIndex());\n\t\t\t\tUtils.log2(\"first, last: \" + first + \", \" + last);\n\t\t\t}\n\t\t\tProject sub = getProject().createSubproject(roi.getBounds(), first, last);\n\t\t\tif (null == sub) {\n\t\t\t\tUtils.log(\"ERROR: failed to create subproject.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal LayerSet subls = sub.getRootLayerSet();\n\t\t\tDisplay.createDisplay(sub, subls.getLayer(0));\n\t\t} else if (command.startsWith(\"Image stack under selected Arealist\")) {\n\t\t\tif (null == active || active.getClass() != AreaList.class) return;\n\t\t\tGenericDialog gd = new GenericDialog(\"Stack options\");\n\t\t\tString[] types = {\"8-bit\", \"16-bit\", \"32-bit\", \"RGB\"};\n\t\t\tgd.addChoice(\"type:\", types, types[0]);\n\t\t\tgd.addSlider(\"Scale: \", 1, 100, 100);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal int type;\n\t\t\tswitch (gd.getNextChoiceIndex()) {\n\t\t\t\tcase 0: type = ImagePlus.GRAY8; break;\n\t\t\t\tcase 1: type = ImagePlus.GRAY16; break;\n\t\t\t\tcase 2: type = ImagePlus.GRAY32; break;\n\t\t\t\tcase 3: type = ImagePlus.COLOR_RGB; break;\n\t\t\t\tdefault: type = ImagePlus.GRAY8; break;\n\t\t\t}\n\t\t\tImagePlus imp = ((AreaList)active).getStack(type, gd.getNextNumber()/100);\n\t\t\tif (null != imp) imp.show();\n\t\t} else if (command.equals(\"Fly through selected Treeline/AreaTree\")) {\n\t\t\tif (null == active || !(active instanceof Tree)) return;\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Creating fly through\", true) {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\tGenericDialog gd = new GenericDialog(\"Fly through\");\n\t\t\t\t\tgd.addNumericField(\"Width\", 512, 0);\n\t\t\t\t\tgd.addNumericField(\"Height\", 512, 0);\n\t\t\t\t\tString[] types = new String[]{\"8-bit gray\", \"Color RGB\"};\n\t\t\t\t\tgd.addChoice(\"Image type\", types, types[0]);\n\t\t\t\t\tgd.addSlider(\"scale\", 0, 100, 100);\n\t\t\t\t\tgd.addCheckbox(\"save to file\", false);\n\t\t\t\t\tgd.showDialog();\n\t\t\t\t\tif (gd.wasCanceled()) return;\n\t\t\t\t\tint w = (int)gd.getNextNumber();\n\t\t\t\t\tint h = (int)gd.getNextNumber();\n\t\t\t\t\tint type = 0 == gd.getNextChoiceIndex() ? ImagePlus.GRAY8 : ImagePlus.COLOR_RGB;\n\t\t\t\t\tdouble scale = gd.getNextNumber();\n\t\t\t\t\tif (w <=0 || h <=0) {\n\t\t\t\t\t\tUtils.log(\"Invalid width or height: \" + w + \", \" + h);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (0 == scale || Double.isNaN(scale)) {\n\t\t\t\t\t\tUtils.log(\"Invalid scale: \" + scale);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tString dir = null;\n\t\t\t\t\tif (gd.getNextBoolean()) {\n\t\t\t\t\t\tDirectoryChooser dc = new DirectoryChooser(\"Target directory\");\n\t\t\t\t\t\tdir = dc.getDirectory();\n\t\t\t\t\t\tif (null == dir) return; \n\t\t\t\t\t\tdir = Utils.fixDir(dir);\n\t\t\t\t\t}\n\t\t\t\t\tImagePlus imp = ((Tree)active).flyThroughMarked(w, h, scale/100, type, dir);\n\t\t\t\t\tif (null == imp) {\n\t\t\t\t\t\tUtils.log(\"Mark a node first!\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\timp.show();\n\t\t\t\t}\n\t\t\t}, project);\n\t\t} else if (command.startsWith(\"Arealists as labels\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Export labels\");\n\t\t\tgd.addSlider(\"Scale: \", 1, 100, 100);\n\t\t\tfinal String[] options = {\"All area list\", \"Selected area lists\"};\n\t\t\tgd.addChoice(\"Export: \", options, options[0]);\n\t\t\tUtils.addLayerRangeChoices(layer, gd);\n\t\t\tgd.addCheckbox(\"Visible only\", true);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal float scale = (float)(gd.getNextNumber() / 100);\n\t\t\tjava.util.List al = (java.util.List)(0 == gd.getNextChoiceIndex() ? layer.getParent().getZDisplayables(AreaList.class) : selection.getSelectedSorted(AreaList.class));\n\t\t\tif (null == al) {\n\t\t\t\tUtils.log(\"No area lists found to export.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint first = gd.getNextChoiceIndex();\n\t\t\tint last = gd.getNextChoiceIndex();\n\t\t\tboolean visible_only = gd.getNextBoolean();\n\t\t\tif (-1 != command.indexOf(\"(amira)\")) {\n\t\t\t\tAreaList.exportAsLabels(al, canvas.getFakeImagePlus().getRoi(), scale, first, last, visible_only, true, true);\n\t\t\t} else if (-1 != command.indexOf(\"(tif)\")) {\n\t\t\t\tAreaList.exportAsLabels(al, canvas.getFakeImagePlus().getRoi(), scale, first, last, visible_only, false, false);\n\t\t\t}\n\t\t} else if (command.equals(\"Project properties...\")) {\n\t\t\tproject.adjustProperties();\n\t\t} else if (command.equals(\"Release memory...\")) {\n\t\t\tBureaucrat.createAndStart(new Worker(\"Releasing memory\") {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tstartedWorking();\n\t\t\t\t\ttry {\n\t\t\tGenericDialog gd = new GenericDialog(\"Release Memory\");\n\t\t\tint max = (int)(IJ.maxMemory() / 1000000);\n\t\t\tgd.addSlider(\"Megabytes: \", 0, max, max/2);\n\t\t\tgd.showDialog();\n\t\t\tif (!gd.wasCanceled()) {\n\t\t\t\tint n_mb = (int)gd.getNextNumber();\n\t\t\t\tproject.getLoader().releaseToFit((long)n_mb*1000000);\n\t\t\t}\n\t\t\t\t\t} catch (Throwable e) {\n\t\t\t\t\t\tIJError.print(e);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tfinishedWorking();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, project);\n\t\t} else if (command.equals(\"Flush image cache\")) {\n\t\t\tLoader.releaseAllCaches();\n\t\t} else if (command.equals(\"Regenerate all mipmaps\")) {\n\t\t\tproject.getLoader().regenerateMipMaps(getLayerSet().getDisplayables(Patch.class));\n\t\t} else if (command.equals(\"Regenerate mipmaps (selected images)\")) {\n\t\t\tproject.getLoader().regenerateMipMaps(selection.getSelected(Patch.class));\n\t\t} else if (command.equals(\"Tags...\")) {\n\t\t\tFile f = Utils.chooseFile(null, \"tags\", \".xml\");\n\t\t\tif (null == f) return;\n\t\t\tif (!Utils.saveToFile(f, getLayerSet().exportTags())) {\n\t\t\t\tUtils.logAll(\"ERROR when saving tags to file \" + f.getAbsolutePath());\n\t\t\t}\n\t\t} else if (command.equals(\"Tags ...\")) {\n\t\t\tString[] ff = Utils.selectFile(\"Import tags\");\n\t\t\tif (null == ff) return;\n\t\t\tGenericDialog gd = new GenericDialog(\"Import tags\");\n\t\t\tString[] modes = new String[]{\"Append to current tags\", \"Replace current tags\"};\n\t\t\tgd.addChoice(\"Import tags mode:\", modes, modes[0]);\n\t\t\tgd.addMessage(\"Replacing current tags\\nwill remove all tags\\n from all nodes first!\");\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tgetLayerSet().importTags(new StringBuilder(ff[0]).append('/').append(ff[1]).toString(), 1 == gd.getNextChoiceIndex());\n\t\t} else if (command.equals(\"Connectivity graph...\")) {\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Connectivity graph\") {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\tGraph.extractAndShowGraph(getLayerSet());\n\t\t\t\t}\n\t\t\t}, getProject());\n\t\t} else if (command.equals(\"Measure\")) {\n\t\t\tif (selection.isEmpty()) {\n\t\t\t\tUtils.log(\"Nothing selected to measure!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tselection.measure();\n\t\t} else {\n\t\t\tUtils.log2(\"Display: don't know what to do with command \" + command);\n\t\t}\n\t\t}});\n", "output": "\tpublic void actionPerformed(final ActionEvent ae) {\n\t\tdispatcher.exec(new Runnable() { public void run() {\n\t\tString command = ae.getActionCommand();\n\t\tif (command.startsWith(\"Job\")) {\n\t\t\tif (Utils.checkYN(\"Really cancel job?\")) {\n\t\t\t\tproject.getLoader().quitJob(command);\n\t\t\t\trepairGUI();\n\t\t\t}\n\t\t\treturn;\n\t\t} else if (command.equals(\"Move to top\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.TOP, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Move up\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.UP, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Move down\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.DOWN, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Move to bottom\")) {\n\t\t\tif (null == active) return;\n\t\t\tcanvas.setUpdateGraphics(true);\n\t\t\tlayer.getParent().move(LayerSet.BOTTOM, active);\n\t\t\tDisplay.repaint(layer.getParent(), active, 5);\n\t\t} else if (command.equals(\"Duplicate, link and send to next layer\")) {\n\t\t\tduplicateLinkAndSendTo(active, 1, layer.getParent().next(layer));\n\t\t} else if (command.equals(\"Duplicate, link and send to previous layer\")) {\n\t\t\tduplicateLinkAndSendTo(active, 0, layer.getParent().previous(layer));\n\t\t} else if (command.equals(\"Duplicate, link and send to...\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Send to\");\n\t\t\tgd.addMessage(\"Duplicate, link and send to...\");\n\t\t\tString[] sl = new String[layer.getParent().size()];\n\t\t\tint next = 0;\n\t\t\tfor (Iterator it = layer.getParent().getLayers().iterator(); it.hasNext(); ) {\n\t\t\t\tsl[next++] = project.findLayerThing(it.next()).toString();\n\t\t\t}\n\t\t\tgd.addChoice(\"Layer: \", sl, sl[layer.getParent().indexOf(layer)]);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tLayer la = layer.getParent().getLayer(gd.getNextChoiceIndex());\n\t\t\tif (layer == la) {\n\t\t\t\tUtils.showMessage(\"Can't duplicate, link and send to the same layer.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tduplicateLinkAndSendTo(active, 0, la);\n\t\t} else if (-1 != command.indexOf(\"z = \")) {\n\t\t\tLayer target_layer = layer.getParent().getLayer(Double.parseDouble(command.substring(command.lastIndexOf(' ') +1)));\n\t\t\tUtils.log2(\"layer: __\" +command.substring(command.lastIndexOf(' ') +1) + \"__\");\n\t\t\tif (null == target_layer) return;\n\t\t\tduplicateLinkAndSendTo(active, 0, target_layer);\n\t\t} else if (-1 != command.indexOf(\"z=\")) {\n\t\t\tint iz = command.indexOf(\"z=\")+2;\n\t\t\tUtils.log2(\"iz=\" + iz + \" other: \" + command.indexOf(' ', iz+2));\n\t\t\tint end = command.indexOf(' ', iz);\n\t\t\tif (-1 == end) end = command.length();\n\t\t\tdouble lz = Double.parseDouble(command.substring(iz, end));\n\t\t\tLayer target = layer.getParent().getLayer(lz);\n\t\t\tlayer.getParent().move(selection.getAffected(), active.getLayer(), target); \n\t\t} else if (command.equals(\"Unlink\")) {\n\t\t\tif (null == active || active instanceof Patch) return;\n\t\t\tactive.unlink();\n\t\t\tupdateSelection();\n\t\t} else if (command.equals(\"Unlink from images\")) {\n\t\t\tif (null == active) return;\n\t\t\ttry {\n\t\t\t\tfor (Displayable displ: selection.getSelected()) {\n\t\t\t\t\tdispl.unlinkAll(Patch.class);\n\t\t\t\t}\n\t\t\t\tupdateSelection();\n\t\t\t} catch (Exception e) { IJError.print(e); }\n\t\t} else if (command.equals(\"Unlink slices\")) {\n\t\t\tYesNoCancelDialog yn = new YesNoCancelDialog(frame, \"Attention\", \"Really unlink all slices from each other?\\nThere is no undo.\");\n\t\t\tif (!yn.yesPressed()) return;\n\t\t\tfinal ArrayList pa = ((Patch)active).getStackPatches();\n\t\t\tfor (int i=pa.size()-1; i>0; i--) {\n\t\t\t\tpa.get(i).unlink(pa.get(i-1));\n\t\t\t}\n\t\t} else if (command.equals(\"Send to next layer\")) {\n\t\t\tRectangle box = selection.getBox();\n\t\t\ttry {\n\t\t\t\tfor (final Displayable displ : selection.getSelected()) {\n\t\t\t\t\tdispl.unlinkAll(Patch.class);\n\t\t\t\t}\n\t\t\t\tupdateSelection();\n\t\t\t} catch (Exception e) { IJError.print(e); }\n\t\t\tselection.moveDown();\n\t\t\trepaint(layer.getParent(), box);\n\t\t} else if (command.equals(\"Send to previous layer\")) {\n\t\t\tRectangle box = selection.getBox();\n\t\t\ttry {\n\t\t\t\tfor (final Displayable displ : selection.getSelected()) {\n\t\t\t\t\tdispl.unlinkAll(Patch.class);\n\t\t\t\t}\n\t\t\t\tupdateSelection();\n\t\t\t} catch (Exception e) { IJError.print(e); }\n\t\t\tselection.moveUp();\n\t\t\trepaint(layer.getParent(), box);\n\t\t} else if (command.equals(\"Show centered\")) {\n\t\t\tif (active == null) return;\n\t\t\tshowCentered(active);\n\t\t} else if (command.equals(\"Delete...\")) {\n\t\t\tselection.deleteAll();\n\t\t} else if (command.equals(\"Color...\")) {\n\t\t\tIJ.doCommand(\"Color Picker...\");\n\t\t} else if (command.equals(\"Revert\")) {\n\t\t\tif (null == active || active.getClass() != Patch.class) return;\n\t\t\tPatch p = (Patch)active;\n\t\t\tif (!p.revert()) {\n\t\t\t\tif (null == p.getOriginalPath()) Utils.log(\"No editions to save for patch \" + p.getTitle() + \" #\" + p.getId());\n\t\t\t\telse Utils.log(\"Could not revert Patch \" + p.getTitle() + \" #\" + p.getId());\n\t\t\t}\n\t\t} else if (command.equals(\"Remove alpha mask\")) {\n\t\t\tfinal ArrayList patches = selection.getSelected(Patch.class); \n\t\t\tif (patches.size() > 0) {\n\t\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Removing alpha mask\" + (patches.size() > 1 ? \"s\" : \"\")) { public void exec() {\n\t\t\t\t\tfinal ArrayList jobs = new ArrayList();\n\t\t\t\t\tfor (final Displayable d : patches) {\n\t\t\t\t\t\tfinal Patch p = (Patch) d;\n\t\t\t\t\t\tp.setAlphaMask(null);\n\t\t\t\t\t\tFuture job = p.getProject().getLoader().regenerateMipMaps(p); \n\t\t\t\t\t\tif (null != job) jobs.add(job);\n\t\t\t\t\t}\n\t\t\t\t\tfor (final Future job : jobs) try {\n\t\t\t\t\t\tjob.get();\n\t\t\t\t\t} catch (Exception ie) {}\n\t\t\t\t}}, patches.get(0).getProject());\n\t\t\t}\n\t\t} else if (command.equals(\"Undo\")) {\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Undo\") { public void exec() {\n\t\t\t\tlayer.getParent().undoOneStep();\n\t\t\t\tDisplay.repaint(layer.getParent());\n\t\t\t}}, project);\n\t\t} else if (command.equals(\"Redo\")) {\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Redo\") { public void exec() {\n\t\t\t\tlayer.getParent().redoOneStep();\n\t\t\t\tDisplay.repaint(layer.getParent());\n\t\t\t}}, project);\n\t\t} else if (command.equals(\"Apply transform\")) {\n\t\t\tcanvas.applyTransform();\n\t\t} else if (command.equals(\"Apply transform propagating to last layer\")) {\n\t\t\tif (mode.getClass() == AffineTransformMode.class || mode.getClass() == NonLinearTransformMode.class) {\n\t\t\t\tfinal LayerSet ls = getLayerSet();\n\t\t\t\tfinal HashSet subset = new HashSet(ls.getLayers(ls.indexOf(Display.this.layer)+1, ls.size()-1)); \n\t\t\t\tif (mode.getClass() == AffineTransformMode.class) ((AffineTransformMode)mode).applyAndPropagate(subset);\n\t\t\t\telse if (mode.getClass() == NonLinearTransformMode.class) ((NonLinearTransformMode)mode).apply(subset);\n\t\t\t\tsetMode(new DefaultMode(Display.this));\n\t\t\t}\n\t\t} else if (command.equals(\"Apply transform propagating to first layer\")) {\n\t\t\tif (mode.getClass() == AffineTransformMode.class || mode.getClass() == NonLinearTransformMode.class) {\n\t\t\t\tfinal LayerSet ls = getLayerSet();\n\t\t\t\tfinal HashSet subset = new HashSet(ls.getLayers(0, ls.indexOf(Display.this.layer) -1)); \n\t\t\t\tif (mode.getClass() == AffineTransformMode.class) ((AffineTransformMode)mode).applyAndPropagate(subset);\n\t\t\t\telse if (mode.getClass() == NonLinearTransformMode.class) ((NonLinearTransformMode)mode).apply(subset);\n\t\t\t\tsetMode(new DefaultMode(Display.this));\n\t\t\t}\n\t\t} else if (command.equals(\"Cancel transform\")) {\n\t\t\tcanvas.cancelTransform(); \n\t\t} else if (command.equals(\"Specify transform...\")) {\n\t\t\tif (null == active) return;\n\t\t\tselection.specify();\n\t\t} else if (command.equals(\"Hide all but images\")) {\n\t\t\tArrayList> type = new ArrayList>();\n\t\t\ttype.add(Patch.class);\n\t\t\ttype.add(Stack.class);\n\t\t\tCollection col = layer.getParent().hideExcept(type, false);\n\t\t\tselection.removeAll(col);\n\t\t\tDisplay.updateCheckboxes(col, DisplayablePanel.VISIBILITY_STATE);\n\t\t\tDisplay.update(layer.getParent(), false);\n\t\t} else if (command.equals(\"Unhide all\")) {\n\t\t\tDisplay.updateCheckboxes(layer.getParent().setAllVisible(false), DisplayablePanel.VISIBILITY_STATE);\n\t\t\tDisplay.update(layer.getParent(), false);\n\t\t} else if (command.startsWith(\"Hide all \")) {\n\t\t\tString type = command.substring(9, command.length() -1); \n\t\t\tCollection col = layer.getParent().setVisible(type, false, true);\n\t\t\tselection.removeAll(col);\n\t\t\tDisplay.updateCheckboxes(col, DisplayablePanel.VISIBILITY_STATE);\n\t\t} else if (command.startsWith(\"Unhide all \")) {\n\t\t\tString type = command.substring(11, command.length() -1); \n\t\t\ttype = type.substring(0, 1).toUpperCase() + type.substring(1);\n\t\t\tupdateCheckboxes(layer.getParent().setVisible(type, true, true), DisplayablePanel.VISIBILITY_STATE);\n\t\t} else if (command.equals(\"Hide deselected\")) {\n\t\t\thideDeselected(0 != (ActionEvent.ALT_MASK & ae.getModifiers()));\n\t\t} else if (command.equals(\"Hide deselected except images\")) {\n\t\t\thideDeselected(true);\n\t\t} else if (command.equals(\"Hide selected\")) {\n\t\t\tselection.setVisible(false); \n\t\t\tDisplay.updateCheckboxes(selection.getSelected(), DisplayablePanel.VISIBILITY_STATE);\n\t\t} else if (command.equals(\"Resize canvas/LayerSet...\")) {\n\t\t\tresizeCanvas();\n\t\t} else if (command.equals(\"Autoresize canvas/LayerSet\")) {\n\t\t\tlayer.getParent().setMinimumDimensions();\n\t\t} else if (command.equals(\"Import image\")) {\n\t\t\timportImage();\n\t\t} else if (command.equals(\"Import next image\")) {\n\t\t\timportNextImage();\n\t\t} else if (command.equals(\"Import stack...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tRectangle sr = getCanvas().getSrcRect();\n\t\t\tBureaucrat burro = project.getLoader().importStack(layer, sr.x + sr.width/2, sr.y + sr.height/2, null, true, null, false);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t}});\n\t\t} else if (command.equals(\"Import stack with landmarks...\")) {\n\t\t\tList pr = Project.getProjects();\n\t\t\tif (1 == pr.size()) {\n\t\t\t\tUtils.logAll(\"Need another project open!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tGenericDialog gd = new GenericDialog(\"Landmarks\");\n\t\t\tgd.addStringField(\"landmarks type:\", \"landmarks\");\n\t\t\tfinal String[] none = {\"-- None --\"};\n\t\t\tfinal Hashtable mpr = new Hashtable();\n\t\t\tfor (Project p : pr) {\n\t\t\t\tif (p == project) continue;\n\t\t\t\tmpr.put(p.toString(), p);\n\t\t\t}\n\t\t\tfinal String[] project_titles = mpr.keySet().toArray(new String[0]);\n\t\t\tfinal Hashtable map_target = findLandmarkNodes(project, \"landmarks\");\n\t\t\tString[] target_landmark_titles = map_target.isEmpty() ? none : map_target.keySet().toArray(new String[0]);\n\t\t\tgd.addChoice(\"Landmarks node in this project:\", target_landmark_titles, target_landmark_titles[0]);\n\t\t\tgd.addMessage(\"\");\n\t\t\tgd.addChoice(\"Source project:\", project_titles, project_titles[0]);\n\t\t\tfinal Hashtable map_source = findLandmarkNodes(mpr.get(project_titles[0]), \"landmarks\");\n\t\t\tString[] source_landmark_titles = map_source.isEmpty() ? none : map_source.keySet().toArray(new String[0]);\n\t\t\tgd.addChoice(\"Landmarks node in source project:\", source_landmark_titles, source_landmark_titles[0]);\n\t\t\tfinal List stacks = Display.getPatchStacks(mpr.get(project_titles[0]).getRootLayerSet());\n\t\t\tString[] stack_titles;\n\t\t\tif (stacks.isEmpty()) {\n\t\t\t\tif (1 == mpr.size()) {\n\t\t\t\t\tIJ.showMessage(\"Project \" + project_titles[0] + \" does not contain any Stack.\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tstack_titles = none;\n\t\t\t} else {\n\t\t\t\tstack_titles = new String[stacks.size()];\n\t\t\t\tint next = 0;\n\t\t\t\tfor (Patch pa : stacks) stack_titles[next++] = pa.toString();\n\t\t\t}\n\t\t\tgd.addChoice(\"Stacks:\", stack_titles, stack_titles[0]);\n\t\t\tVector vc = gd.getChoices();\n\t\t\tfinal Choice choice_target_landmarks = (Choice) vc.get(0);\n\t\t\tfinal Choice choice_source_projects = (Choice) vc.get(1);\n\t\t\tfinal Choice choice_source_landmarks = (Choice) vc.get(2);\n\t\t\tfinal Choice choice_stacks = (Choice) vc.get(3);\n\t\t\tfinal TextField input = (TextField) gd.getStringFields().get(0);\n\t\t\tinput.addTextListener(new TextListener() {\n\t\t\t\tpublic void textValueChanged(TextEvent te) {\n\t\t\t\t\tfinal String text = input.getText();\n\t\t\t\t\tupdate(choice_target_landmarks, Display.this.project, text, map_target);\n\t\t\t\t\tupdate(choice_source_landmarks, mpr.get(choice_source_projects.getSelectedItem()), text, map_source);\n\t\t\t\t}\n\t\t\t\tprivate void update(Choice c, Project p, String type, Hashtable table) {\n\t\t\t\t\ttable.clear();\n\t\t\t\t\ttable.putAll(findLandmarkNodes(p, type));\n\t\t\t\t\tc.removeAll();\n\t\t\t\t\tif (table.isEmpty()) c.add(none[0]);\n\t\t\t\t\telse for (String t : table.keySet()) c.add(t);\n\t\t\t\t}\n\t\t\t});\n\t\t\tchoice_source_projects.addItemListener(new ItemListener() {\n\t\t\t\tpublic void itemStateChanged(ItemEvent e) {\n\t\t\t\t\tString item = (String) e.getItem();\n\t\t\t\t\tProject p = mpr.get(choice_source_projects.getSelectedItem());\n\t\t\t\t\tmap_source.clear();\n\t\t\t\t\tmap_source.putAll(findLandmarkNodes(p, input.getText()));\n\t\t\t\t\tchoice_target_landmarks.removeAll();\n\t\t\t\t\tif (map_source.isEmpty()) choice_target_landmarks.add(none[0]);\n\t\t\t\t\telse for (String t : map_source.keySet()) choice_target_landmarks.add(t);\n\t\t\t\t\tstacks.clear();\n\t\t\t\t\tchoice_stacks.removeAll();\n\t\t\t\t\tstacks.addAll(Display.getPatchStacks(mpr.get(project_titles[0]).getRootLayerSet()));\n\t\t\t\t\tif (stacks.isEmpty()) choice_stacks.add(none[0]);\n\t\t\t\t\telse for (Patch pa : stacks) choice_stacks.add(pa.toString());\n\t\t\t\t}\n\t\t\t});\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tString type = gd.getNextString();\n\t\t\tif (null == type || 0 == type.trim().length()) {\n\t\t\t\tUtils.log(\"Invalid landmarks node type!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tProjectThing target_landmarks_node = map_target.get(gd.getNextChoice());\n\t\t\tProject source = mpr.get(gd.getNextChoice());\n\t\t\tProjectThing source_landmarks_node = map_source.get(gd.getNextChoice());\n\t\t\tPatch stack_patch = stacks.get(gd.getNextChoiceIndex());\n\t\t\tDisplay.this.getLayerSet().addLayerContentStep(layer);\n\t\t\tinsertStack(target_landmarks_node, source, source_landmarks_node, stack_patch);\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t} else if (command.equals(\"Import grid...\")) {\n\t\t\tDisplay.this.getLayerSet().addLayerContentStep(layer);\n\t\t\tBureaucrat burro = project.getLoader().importGrid(layer);\n\t\t\tif (null != burro)\n\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\tDisplay.this.getLayerSet().addLayerContentStep(layer);\n\t\t\t\t}});\n\t\t} else if (command.equals(\"Import sequence as grid...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tBureaucrat burro = project.getLoader().importSequenceAsGrid(layer);\n\t\t\tif (null != burro)\n\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t\t}});\n\t\t} else if (command.equals(\"Import from text file...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tBureaucrat burro = project.getLoader().importImages(layer);\n\t\t\tif (null != burro)\n\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t\t}});\n\t\t} else if (command.equals(\"Import labels as arealists...\")) {\n\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\tBureaucrat burro = project.getLoader().importLabelsAsAreaLists(layer, null, Double.MAX_VALUE, 0, 0.4f, false);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tDisplay.this.getLayerSet().addChangeTreesStep();\n\t\t\t}});\n\t\t} else if (command.equals(\"Make flat image...\")) {\n\t\t\tRectangle srcRect = null;\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null != roi) {\n\t\t\t\tsrcRect = roi.getBounds();\n\t\t\t} else {\n\t\t\t\tsrcRect = new Rectangle(0, 0, (int)Math.ceil(layer.getParent().getLayerWidth()), (int)Math.ceil(layer.getParent().getLayerHeight()));\n\t\t\t}\n\t\t\tdouble scale = 1.0;\n\t\t\tfinal String[] types = new String[]{\"8-bit grayscale\", \"RGB Color\"};\n\t\t\tint the_type = ImagePlus.GRAY8;\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose\", frame);\n\t\t\tgd.addSlider(\"Scale: \", 1, 100, 100);\n\t\t\tgd.addNumericField(\"Width: \", srcRect.width, 0);\n\t\t\tgd.addNumericField(\"height: \", srcRect.height, 0);\n\t\t\tVector numfields = gd.getNumericFields();\n\t\t\tUpdateDimensionField udf = new UpdateDimensionField(srcRect.width, srcRect.height, (TextField) numfields.get(1), (TextField) numfields.get(2), (TextField) numfields.get(0), (Scrollbar) gd.getSliders().get(0));\n\t\t\tfor (Object ob : numfields) ((TextField)ob).addTextListener(udf);\n\t\t\tgd.addChoice(\"Type: \", types, types[0]);\n\t\t\tif (layer.getParent().size() > 1) {\n\t\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd); \n\t\t\t\tgd.addCheckbox(\"Include non-empty layers only\", true);\n\t\t\t}\n\t\t\tgd.addMessage(\"Background color:\");\n\t\t\tUtils.addRGBColorSliders(gd, Color.black);\n\t\t\tgd.addCheckbox(\"Best quality\", false);\n\t\t\tgd.addMessage(\"\");\n\t\t\tgd.addCheckbox(\"Save to file\", false);\n\t\t\tgd.addCheckbox(\"Save for web\", false);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tscale = gd.getNextNumber() / 100;\n\t\t\tthe_type = (0 == gd.getNextChoiceIndex() ? ImagePlus.GRAY8 : ImagePlus.COLOR_RGB);\n\t\t\tif (Double.isNaN(scale) || scale <= 0.0) {\n\t\t\t\tUtils.showMessage(\"Invalid scale.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tgd.getNextNumber();\n\t\t\tgd.getNextNumber();\n\t\t\tLayer[] layer_array = null;\n\t\t\tboolean non_empty_only = false;\n\t\t\tif (layer.getParent().size() > 1) {\n\t\t\t\tnon_empty_only = gd.getNextBoolean();\n\t\t\t\tint i_start = gd.getNextChoiceIndex();\n\t\t\t\tint i_end = gd.getNextChoiceIndex();\n\t\t\t\tArrayList al = new ArrayList();\n\t\t\t\tArrayList al_zd = layer.getParent().getZDisplayables();\n\t\t\t\tZDisplayable[] zd = new ZDisplayable[al_zd.size()];\n\t\t\t\tal_zd.toArray(zd);\n\t\t\t\tfor (int i=i_start, j=0; i <= i_end; i++, j++) {\n\t\t\t\t\tLayer la = layer.getParent().getLayer(i);\n\t\t\t\t\tif (!la.isEmpty() || !non_empty_only) al.add(la); \n\t\t\t\t}\n\t\t\t\tif (0 == al.size()) {\n\t\t\t\t\tUtils.showMessage(\"All layers are empty!\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlayer_array = new Layer[al.size()];\n\t\t\t\tal.toArray(layer_array);\n\t\t\t} else {\n\t\t\t\tlayer_array = new Layer[]{Display.this.layer};\n\t\t\t}\n\t\t\tfinal Color background = new Color((int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber());\n\t\t\tfinal boolean quality = gd.getNextBoolean();\n\t\t\tfinal boolean save_to_file = gd.getNextBoolean();\n\t\t\tfinal boolean save_for_web = gd.getNextBoolean();\n\t\t\tif (save_for_web) project.getLoader().makePrescaledTiles(layer_array, Patch.class, srcRect, scale, c_alphas, the_type);\n\t\t\telse project.getLoader().makeFlatImage(layer_array, srcRect, scale, c_alphas, the_type, save_to_file, quality, background);\n\t\t} else if (command.equals(\"Lock\")) {\n\t\t\tselection.setLocked(true);\n\t\t\tUtils.revalidateComponent(tabs.getSelectedComponent());\n\t\t} else if (command.equals(\"Unlock\")) {\n\t\t\tselection.setLocked(false);\n\t\t\tUtils.revalidateComponent(tabs.getSelectedComponent());\n\t\t} else if (command.equals(\"Properties...\")) {\n\t\t\tactive.adjustProperties();\n\t\t\tupdateSelection();\n\t\t} else if (command.equals(\"Show current 2D position in 3D\")) {\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tDisplay3D.addFatPoint(\"Current 2D Position\", getLayerSet(), p.x, p.y, layer.getZ(), 10, Color.magenta);\n\t\t} else if (command.equals(\"Show layers as orthoslices in 3D\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Options\");\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tRectangle r = null == roi ? getLayerSet().get2DBounds() : roi.getBounds();\n\t\t\tgd.addMessage(\"ROI 2D bounds:\");\n\t\t\tgd.addNumericField(\"x:\", r.x, 0, 30, \"pixels\");\n\t\t\tgd.addNumericField(\"y:\", r.y, 0, 30, \"pixels\");\n\t\t\tgd.addNumericField(\"width:\", r.width, 0, 30, \"pixels\");\n\t\t\tgd.addNumericField(\"height:\", r.height, 0, 30, \"pixels\");\n\t\t\tgd.addMessage(\"Layers to include:\");\n\t\t\tUtils.addLayerRangeChoices(layer, gd);\n\t\t\tgd.addMessage(\"Constrain dimensions to:\");\n\t\t\tgd.addNumericField(\"max width and height:\", getLayerSet().getPixelsMaxDimension(), 0, 30, \"pixels\");\n\t\t\tgd.addMessage(\"Options:\");\n\t\t\tfinal String[] types = {\"Greyscale\", \"Color RGB\"};\n\t\t\tgd.addChoice(\"Image type:\", types, types[0]);\n\t\t\tgd.addCheckbox(\"Invert images\", false);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tint x = (int)gd.getNextNumber(),\n\t\t\t y = (int)gd.getNextNumber(),\n\t\t\t width = (int)gd.getNextNumber(),\n\t\t\t height = (int)gd.getNextNumber();\n\t\t\tfinal int first = gd.getNextChoiceIndex(),\n\t\t\t\t\t last = gd.getNextChoiceIndex();\n\t\t\tfinal List layers = getLayerSet().getLayers(first, last);\n\t\t\tfinal int max_dim = (int)gd.getNextNumber();\n\t\t\tfloat scale = 1;\n\t\t\tif (max_dim < Math.max(width, height)) {\n\t\t\t\tscale = max_dim / (float)Math.max(width, height);\n\t\t\t}\n\t\t\tfinal int type = 0 == gd.getNextChoiceIndex() ? ImagePlus.GRAY8 : ImagePlus.COLOR_RGB;\n\t\t\tfinal boolean invert = gd.getNextBoolean();\n\t\t\tfinal LayerStack stack = new LayerStack(layers, new Rectangle(x, y, width, height), scale, type, Patch.class, max_dim, invert);\n\t\t\tDisplay3D.showOrthoslices(stack.getImagePlus(), \"LayerSet [\" + x + \",\" + y + \",\" + width + \",\" + height + \"] \" + first + \"--\" + last, x, y, scale, layers.get(0));\n\t\t} else if (command.equals(\"Align stack slices\")) {\n\t\t\tif (getActive() instanceof Patch) {\n\t\t\t\tfinal Patch slice = (Patch)getActive();\n\t\t\t\tif (slice.isStack()) {\n\t\t\t\t\tfinal HashSet hs = slice.getLinkedGroup(new HashSet());\n\t\t\t\t\tfor (Iterator it = hs.iterator(); it.hasNext(); ) {\n\t\t\t\t\t\tif (it.next().getClass() != Patch.class) {\n\t\t\t\t\t\t\tUtils.showMessage(\"Images are linked to other objects, can't proceed to cross-correlate them.\"); \n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfinal LayerSet ls = slice.getLayerSet();\n\t\t\t\t\tfinal HashSet linked = slice.getLinkedGroup(null);\n\t\t\t\t\tls.addTransformStepWithData(linked);\n\t\t\t\t\tBureaucrat burro = AlignTask.registerStackSlices((Patch)getActive()); \n\t\t\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\t\t\tls.enlargeToFit(linked);\n\t\t\t\t\t\tls.addTransformStepWithData(linked);\n\t\t\t\t\t}});\n\t\t\t\t} else {\n\t\t\t\t\tUtils.log(\"Align stack slices: selected image is not part of a stack.\");\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (command.equals(\"Align layers with manual landmarks\")) {\n\t\t\tsetMode(new ManualAlignMode(Display.this));\n\t\t} else if (command.equals(\"Align layers\")) {\n\t\t\tfinal Layer la = layer; \n\t\t\tla.getParent().addTransformStep(la.getParent().getLayers());\n\t\t\tBureaucrat burro = AlignLayersTask.alignLayersTask( la );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().enlargeToFit(getLayerSet().getDisplayables(Patch.class));\n\t\t\t\tla.getParent().addTransformStep(la.getParent().getLayers());\n\t\t\t}});\n\t\t} else if (command.equals(\"Align multi-layer mosaic\")) {\n\t\t\tfinal Layer la = layer; \n\t\t\tla.getParent().addTransformStep();\n\t\t\tBureaucrat burro = AlignTask.alignMultiLayerMosaicTask( la );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().enlargeToFit(getLayerSet().getDisplayables(Patch.class));\n\t\t\t\tla.getParent().addTransformStep();\n\t\t\t}});\n\t\t} else if (command.equals(\"Montage all images in this layer\")) {\n\t\t\tfinal Layer la = layer;\n\t\t\tfinal List patches = new ArrayList( (List) (List) la.getDisplayables(Patch.class));\n\t\t\tif (patches.size() < 2) {\n\t\t\t\tUtils.showMessage(\"Montage needs 2 or more images selected\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal Collection col = la.getParent().addTransformStepWithData(Arrays.asList(new Layer[]{la}));\n\t\t\tfinal ArrayList fixed = new ArrayList();\n\t\t\tfor (final Patch p : patches) {\n\t\t\t\tif (p.isLocked2()) fixed.add(p);\n\t\t\t}\n\t\t\tif (fixed.isEmpty()) fixed.add(patches.get(0));\n\t\t\tBureaucrat burro = AlignTask.alignPatchesTask(patches, fixed);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().enlargeToFit(patches);\n\t\t\t\tla.getParent().addTransformStepWithData(col);\n\t\t\t}});\n\t\t} else if (command.equals(\"Montage selected images (SIFT)\")) {\n\t\t\tmontage(0);\n\t\t} else if (command.equals(\"Montage selected images (phase correlation)\")) {\n\t\t\tmontage(1);\n\t\t} else if (command.equals(\"Montage multiple layers (phase correlation)\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal List layers = getLayerSet().getLayers(gd.getNextChoiceIndex(), gd.getNextChoiceIndex());\n\t\t\tfinal Collection col = getLayerSet().addTransformStepWithData(layers);\n\t\t\tBureaucrat burro = StitchingTEM.montageWithPhaseCorrelation(layers);\n\t\t\tif (null == burro) return;\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tCollection ds = new ArrayList();\n\t\t\t\tfor (Layer la : layers) ds.addAll(la.getDisplayables(Patch.class));\n\t\t\t\tgetLayerSet().enlargeToFit(ds);\n\t\t\t\tgetLayerSet().addTransformStepWithData(col);\n\t\t\t}});\n\t\t} else if (command.equals(\"Montage multiple layers (SIFT)\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal List layers = getLayerSet().getLayers(gd.getNextChoiceIndex(), gd.getNextChoiceIndex());\n\t\t\tfinal Collection col = getLayerSet().addTransformStepWithData(layers);\n\t\t\tBureaucrat burro = AlignTask.montageLayersTask(layers);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tCollection ds = new ArrayList();\n\t\t\t\tfor (Layer la : layers) ds.addAll(la.getDisplayables(Patch.class));\n\t\t\t\tgetLayerSet().enlargeToFit(ds);\n\t\t\t\tgetLayerSet().addTransformStepWithData(col);\n\t\t\t}});\n\t\t} else if (command.equals(\"Properties ...\")) { \n\t\t\tGenericDialog gd = new GenericDialog(\"Properties\", Display.this.frame);\n\t\t\tgd.addSlider(\"layer_scroll_step: \", 1, layer.getParent().size(), Display.this.scroll_step);\n\t\t\tgd.addChoice(\"snapshots_mode\", LayerSet.snapshot_modes, LayerSet.snapshot_modes[layer.getParent().getSnapshotsMode()]);\n\t\t\tgd.addCheckbox(\"prefer_snapshots_quality\", layer.getParent().snapshotsQuality());\n\t\t\tLoader lo = getProject().getLoader();\n\t\t\tboolean using_mipmaps = lo.isMipMapsEnabled();\n\t\t\tgd.addCheckbox(\"enable_mipmaps\", using_mipmaps);\n\t\t\tgd.addCheckbox(\"enable_layer_pixels virtualization\", layer.getParent().isPixelsVirtualizationEnabled());\n\t\t\tdouble max = layer.getParent().getLayerWidth() < layer.getParent().getLayerHeight() ? layer.getParent().getLayerWidth() : layer.getParent().getLayerHeight();\n\t\t\tgd.addSlider(\"max_dimension of virtualized layer pixels: \", 0, max, layer.getParent().getPixelsMaxDimension());\n\t\t\tgd.addCheckbox(\"Show arrow heads in Treeline/AreaTree\", layer.getParent().paint_arrows);\n\t\t\tgd.addCheckbox(\"Show edge confidence boxes in Treeline/AreaTree\", layer.getParent().paint_edge_confidence_boxes);\n\t\t\tgd.addCheckbox(\"Show color cues\", layer.getParent().color_cues);\n\t\t\tgd.addSlider(\"+/- layers to color cue\", 0, 10, layer.getParent().n_layers_color_cue);\n\t\t\tgd.addCheckbox(\"Show color cues for areas\", layer.getParent().area_color_cues);\n\t\t\tgd.addCheckbox(\"Use red/blue for color cues\", layer.getParent().use_color_cue_colors);\n\t\t\tgd.addCheckbox(\"Prepaint images\", layer.getParent().prepaint);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tint sc = (int) gd.getNextNumber();\n\t\t\tif (sc < 1) sc = 1;\n\t\t\tDisplay.this.scroll_step = sc;\n\t\t\tupdateInDatabase(\"scroll_step\");\n\t\t\tlayer.getParent().setSnapshotsMode(gd.getNextChoiceIndex());\n\t\t\tlayer.getParent().setSnapshotsQuality(gd.getNextBoolean());\n\t\t\tboolean generate_mipmaps = gd.getNextBoolean();\n\t\t\tif (using_mipmaps && generate_mipmaps) {\n\t\t\t} else {\n\t\t\t\tif (using_mipmaps) { \n\t\t\t\t\tlo.flushMipMaps(true);\n\t\t\t\t} else {\n\t\t\t\t\tlo.generateMipMaps(layer.getParent().getDisplayables(Patch.class));\n\t\t\t\t}\n\t\t\t}\n\t\t\tlayer.getParent().setPixelsVirtualizationEnabled(gd.getNextBoolean());\n\t\t\tlayer.getParent().setPixelsMaxDimension((int)gd.getNextNumber());\n\t\t\tlayer.getParent().paint_arrows = gd.getNextBoolean();\n\t\t\tlayer.getParent().paint_edge_confidence_boxes = gd.getNextBoolean();\n\t\t\tlayer.getParent().color_cues = gd.getNextBoolean();\n\t\t\tlayer.getParent().n_layers_color_cue = (int)gd.getNextNumber();\n\t\t\tlayer.getParent().area_color_cues = gd.getNextBoolean();\n\t\t\tlayer.getParent().use_color_cue_colors = gd.getNextBoolean();\n\t\t\tlayer.getParent().prepaint = gd.getNextBoolean();\n\t\t\tDisplay.repaint(layer.getParent());\n\t\t} else if (command.equals(\"Adjust snapping parameters...\")) {\n\t\t\tAlignTask.p_snap.setup(\"Snap\");\n\t\t} else if (command.equals(\"Adjust fast-marching parameters...\")) {\n\t\t\tSegmentation.fmp.setup();\n\t\t} else if (command.equals(\"Adjust arealist paint parameters...\")) {\n\t\t\tAreaWrapper.PP.setup();\n\t\t} else if (command.equals(\"Search...\")) {\n\t\t\tnew Search();\n\t\t} else if (command.equals(\"Select all\")) {\n\t\t\tselection.selectAll();\n\t\t\trepaint(Display.this.layer, selection.getBox(), 0);\n\t\t} else if (command.equals(\"Select all visible\")) {\n\t\t\tselection.selectAllVisible();\n\t\t\trepaint(Display.this.layer, selection.getBox(), 0);\n\t\t} else if (command.equals(\"Select none\")) {\n\t\t\tRectangle box = selection.getBox();\n\t\t\tselection.clear();\n\t\t\trepaint(Display.this.layer, box, 0);\n\t\t} else if (command.equals(\"Restore selection\")) {\n\t\t\tselection.restore();\n\t\t} else if (command.equals(\"Select under ROI\")) {\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null == roi) return;\n\t\t\tselection.selectAll(roi, true);\n\t\t} else if (command.equals(\"Merge\")) {\n\t\t\tBureaucrat burro = Bureaucrat.create(new Worker.Task(\"Merging AreaLists\") {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\tArrayList al_sel = selection.getSelected(AreaList.class);\n\t\t\t\t\tal_sel.remove(Display.this.active);\n\t\t\t\t\tal_sel.add(0, Display.this.active);\n\t\t\t\t\tSet dataedits = new HashSet();\n\t\t\t\t\tdataedits.add(new Displayable.DoEdit(Display.this.active).init(Display.this.active, new String[]{\"data\"}));\n\t\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits);\n\t\t\t\t\tAreaList ali = AreaList.merge(al_sel);\n\t\t\t\t\tif (null != ali) {\n\t\t\t\t\t\tfor (int i=1; i dataedits = new HashSet();\n\t\t\t\tdataedits.add(new Displayable.DoEdit(Display.this.active).init(Display.this.active, new String[]{\"data\"}));\n\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits);\n\t\t\t}});\n\t\t\tburro.goHaveBreakfast();\n\t\t} else if (command.equals(\"Reroot\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t\t((Tree)active).reRoot(p.x, p.y, layer, canvas.getMagnification());\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t\tDisplay.repaint(getLayerSet());\n\t\t} else if (command.equals(\"Part subtree\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tif (!Utils.check(\"Really part the subtree?\")) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tList ts = ((Tree)active).splitNear(p.x, p.y, layer, canvas.getMagnification());\n\t\t\tif (null == ts) return;\n\t\t\tDisplayable elder = Display.this.active;\n\t\t\tfor (ZDisplayable t : ts) {\n\t\t\t\tif (t == elder) continue;\n\t\t\t\tgetLayerSet().add(t); \n\t\t\t\tproject.getProjectTree().addSibling(elder, t);\n\t\t\t}\n\t\t\tselection.clear();\n\t\t\tselection.selectAll(ts);\n\t\t\tselection.add(elder);\n\t\t\tgetLayerSet().addChangeTreesStep();\n\t\t\tDisplay.repaint(getLayerSet());\n\t\t} else if (command.equals(\"Show tabular view\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\t((Tree)active).createMultiTableView();\n\t\t} else if (command.equals(\"Mark\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tif (((Tree)active).markNear(p.x, p.y, layer, canvas.getMagnification())) {\n\t\t\t\tDisplay.repaint(getLayerSet());\n\t\t\t}\n\t\t} else if (command.equals(\"Clear marks (selected Trees)\")) {\n\t\t\tfor (Tree t : selection.get(Tree.class)) {\n\t\t\t\tt.unmark();\n\t\t\t}\n\t\t\tDisplay.repaint(getLayerSet());\n\t\t} else if (command.equals(\"Join\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tfinal List> tlines = (List>) selection.get(active.getClass());\n\t\t\tif (((Tree)active).canJoin(tlines)) {\n\t\t\t\tif (!Utils.check(\"Join these \" + tlines.size() + \" trees into the tree \" + active + \" ?\")) return;\n\t\t\t\tSet dataedits = new HashSet(tlines.size());\n\t\t\t\tfor (final Tree tl : tlines) {\n\t\t\t\t\tdataedits.add(new Displayable.DoEdit(tl).init(tl, new String[]{\"data\"}));\n\t\t\t\t}\n\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits);\n\t\t\t\t((Tree)active).join(tlines);\n\t\t\t\tfor (final Tree tl : tlines) {\n\t\t\t\t\tif (tl == active) continue;\n\t\t\t\t\ttl.remove2(false);\n\t\t\t\t}\n\t\t\t\tDisplay.repaint(getLayerSet());\n\t\t\t\tSet dataedits2 = new HashSet(1);\n\t\t\t\tdataedits2.add(new Displayable.DoEdit(active).init(active, new String[]{\"data\"}));\n\t\t\t\tgetLayerSet().addChangeTreesStep(dataedits2);\n\t\t\t}\n\t\t} else if (command.equals(\"Previous branch point or start\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tcenter(((Treeline)active).findPreviousBranchOrRootPoint(p.x, p.y, layer, canvas));\n\t\t} else if (command.equals(\"Next branch point or end\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tcenter(((Tree)active).findNextBranchOrEndPoint(p.x, p.y, layer, canvas));\n\t\t} else if (command.equals(\"Root\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tPoint p = canvas.consumeLastPopupPoint();\n\t\t\tif (null == p) return;\n\t\t\tcenter(((Tree)active).createCoordinate(((Tree)active).getRoot()));\n\t\t} else if (command.equals(\"Last added point\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tcenter(((Treeline)active).getLastAdded());\n\t\t} else if (command.equals(\"Last edited point\")) {\n\t\t\tif (!(active instanceof Tree)) return;\n\t\t\tcenter(((Treeline)active).getLastEdited());\n\t\t} else if (command.equals(\"Reverse point order\")) {\n\t\t\tif (!(active instanceof Pipe)) return;\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t\t((Pipe)active).reverse();\n\t\t\tDisplay.repaint(Display.this.layer);\n\t\t\tgetLayerSet().addDataEditStep(active);\n\t\t} else if (command.equals(\"View orthoslices\")) {\n\t\t\tif (!(active instanceof Patch)) return;\n\t\t\tDisplay3D.showOrthoslices(((Patch)active));\n\t\t} else if (command.equals(\"View volume\")) {\n\t\t\tif (!(active instanceof Patch)) return;\n\t\t\tDisplay3D.showVolume(((Patch)active));\n\t\t} else if (command.equals(\"Show in 3D\")) {\n\t\t\tfor (ZDisplayable zd : selection.get(ZDisplayable.class)) {\n\t\t\t\tDisplay3D.show(zd.getProject().findProjectThing(zd));\n\t\t\t}\n\t\t\tHashSet hs = new HashSet();\n\t\t\tfor (Profile d : selection.get(Profile.class)) {\n\t\t\t\tProjectThing profile_list = (ProjectThing)d.getProject().findProjectThing(d).getParent();\n\t\t\t\tif (!hs.contains(profile_list)) {\n\t\t\t\t\tDisplay3D.show(profile_list);\n\t\t\t\t\ths.add(profile_list);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (command.equals(\"Snap\")) {\n\t\t\tif (!(active instanceof Patch)) return;\n\t\t\tDisplay.snap((Patch)active);\n\t\t} else if (command.equals(\"Blend\")) {\n\t\t\tHashSet patches = new HashSet();\n\t\t\tfor (final Displayable d : selection.getSelected()) {\n\t\t\t\tif (d.getClass() == Patch.class) patches.add((Patch)d);\n\t\t\t}\n\t\t\tif (patches.size() > 1) {\n\t\t\t\tGenericDialog gd = new GenericDialog(\"Blending\");\n\t\t\t\tgd.addCheckbox(\"Respect current alpha mask\", true);\n\t\t\t\tgd.showDialog();\n\t\t\t\tif (gd.wasCanceled()) return;\n\t\t\t\tBlending.blend(patches, gd.getNextBoolean());\n\t\t\t} else {\n\t\t\t\tIJ.log(\"Please select more than one overlapping image.\");\n\t\t\t}\n\t\t} else if (command.equals(\"Montage\")) {\n\t\t\tfinal Set affected = new HashSet(selection.getAffected());\n\t\t\tfinal LayerSet ls = layer.getParent();\n\t\t\tls.addTransformStepWithData(affected);\n\t\t\tBureaucrat burro = AlignTask.alignSelectionTask( selection );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tls.enlargeToFit(affected);\n\t\t\t\tls.addTransformStepWithData(affected);\n\t\t\t}});\n\t\t} else if (command.equals(\"Lens correction\")) {\n\t\t\tfinal Layer la = layer;\n\t\t\tla.getParent().addDataEditStep(new HashSet(la.getParent().getDisplayables()));\n\t\t\tBureaucrat burro = DistortionCorrectionTask.correctDistortionFromSelection( selection );\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tla.getParent().addDataEditStep(new HashSet(la.getParent().getDisplayables()));\n\t\t\t}});\n\t\t} else if (command.equals(\"Link images...\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Options\");\n\t\t\tgd.addMessage(\"Linking images to images (within their own layer only):\");\n\t\t\tString[] options = {\"all images to all images\", \"each image with any other overlapping image\"};\n\t\t\tgd.addChoice(\"Link: \", options, options[1]);\n\t\t\tString[] options2 = {\"selected images only\", \"all images in this layer\", \"all images in all layers, within the layer only\", \"all images in all layers, within and across consecutive layers\"};\n\t\t\tgd.addChoice(\"Apply to: \", options2, options2[0]);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tLayer lay = layer;\n\t\t\tfinal HashSet ds = new HashSet(lay.getParent().getDisplayables());\n\t\t\tlay.getParent().addDataEditStep(ds, new String[]{\"data\"});\n\t\t\tboolean overlapping_only = 1 == gd.getNextChoiceIndex();\n\t\t\tCollection coll = null;\n\t\t\tswitch (gd.getNextChoiceIndex()) {\n\t\t\t\tcase 0:\n\t\t\t\t\tcoll = selection.getSelected(Patch.class);\n\t\t\t\t\tPatch.crosslink(coll, overlapping_only);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 1:\n\t\t\t\t\tcoll = lay.getDisplayables(Patch.class);\n\t\t\t\t\tPatch.crosslink(coll, overlapping_only);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tcoll = new ArrayList();\n\t\t\t\t\tfor (final Layer la : lay.getParent().getLayers()) {\n\t\t\t\t\t\tCollection acoll = la.getDisplayables(Patch.class);\n\t\t\t\t\t\tPatch.crosslink(acoll, overlapping_only);\n\t\t\t\t\t\tcoll.addAll(acoll);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\tArrayList layers = lay.getParent().getLayers();\n\t\t\t\t\tCollection lc1 = layers.get(0).getDisplayables(Patch.class);\n\t\t\t\t\tif (lay == layers.get(0)) coll = lc1;\n\t\t\t\t\tfor (int i=1; i lc2 = layers.get(i).getDisplayables(Patch.class);\n\t\t\t\t\t\tif (null == coll && Display.this.layer == layers.get(i)) coll = lc2;\n\t\t\t\t\t\tCollection both = new ArrayList();\n\t\t\t\t\t\tboth.addAll(lc1);\n\t\t\t\t\t\tboth.addAll(lc2);\n\t\t\t\t\t\tPatch.crosslink(both, overlapping_only);\n\t\t\t\t\t\tlc1 = lc2;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (null != coll) Display.updateCheckboxes(coll, DisplayablePanel.LINK_STATE, true);\n\t\t\tlay.getParent().addDataEditStep(ds);\n\t\t} else if (command.equals(\"Unlink all selected images\")) {\n\t\t\tif (Utils.check(\"Really unlink selected images?\")) {\n\t\t\t\tfor (final Displayable d : selection.getSelected(Patch.class)) {\n\t\t\t\t\td.unlink();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (command.equals(\"Unlink all\")) {\n\t\t\tif (Utils.check(\"Really unlink all objects from all layers?\")) {\n\t\t\t\tCollection ds = layer.getParent().getDisplayables();\n\t\t\t\tfor (final Displayable d : ds) {\n\t\t\t\t\td.unlink();\n\t\t\t\t}\n\t\t\t\tDisplay.updateCheckboxes(ds, DisplayablePanel.LOCK_STATE);\n\t\t\t}\n\t\t} else if (command.equals(\"Calibration...\")) {\n\t\t\ttry {\n\t\t\t\tIJ.run(canvas.getFakeImagePlus(), \"Properties...\", \"\");\n\t\t\t\tDisplay.updateTitle(getLayerSet());\n\t\t\t} catch (RuntimeException re) {\n\t\t\t\tUtils.log2(\"Calibration dialog canceled.\");\n\t\t\t}\n\t\t} else if (command.equals(\"Grid overlay...\")) {\n\t\t\tif (null == gridoverlay) gridoverlay = new GridOverlay();\n\t\t\tgridoverlay.setup(canvas.getFakeImagePlus().getRoi());\n\t\t\tcanvas.repaint(false);\n\t\t} else if (command.equals(\"Enhance contrast (selected images)...\")) {\n\t\t\tfinal Layer la = layer;\n\t\t\tArrayList selected = selection.getSelected(Patch.class);\n\t\t\tfinal HashSet ds = new HashSet(selected);\n\t\t\tla.getParent().addDataEditStep(ds);\n\t\t\tDisplayable active = Display.this.getActive();\n\t\t\tPatch ref = active.getClass() == Patch.class ? (Patch)active : null;\n\t\t\tBureaucrat burro = getProject().getLoader().enhanceContrast(selected, ref);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tla.getParent().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Enhance contrast layer-wise...\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Choose range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tjava.util.List layers = layer.getParent().getLayers().subList(gd.getNextChoiceIndex(), gd.getNextChoiceIndex() +1); \n\t\t\tfinal HashSet ds = new HashSet();\n\t\t\tfor (final Layer l : layers) ds.addAll(l.getDisplayables(Patch.class));\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().enhanceContrast(layers);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Set Min and Max layer-wise...\")) {\n\t\t\tDisplayable active = getActive();\n\t\t\tdouble min = 0;\n\t\t\tdouble max = 0;\n\t\t\tif (null != active && active.getClass() == Patch.class) {\n\t\t\t\tmin = ((Patch)active).getMin();\n\t\t\t\tmax = ((Patch)active).getMax();\n\t\t\t}\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Min and Max\");\n\t\t\tgd.addMessage(\"Set min and max to all images in the layer range\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.addNumericField(\"min: \", min, 2);\n\t\t\tgd.addNumericField(\"max: \", max, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tmin = gd.getNextNumber();\n\t\t\tmax = gd.getNextNumber();\n\t\t\tArrayList al = new ArrayList();\n\t\t\tfor (final Layer la : layer.getParent().getLayers().subList(gd.getNextChoiceIndex(), gd.getNextChoiceIndex() +1)) { \n\t\t\t\tal.addAll(la.getDisplayables(Patch.class));\n\t\t\t}\n\t\t\tfinal HashSet ds = new HashSet(al);\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().setMinAndMax(al, min, max);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Set Min and Max (selected images)...\")) {\n\t\t\tDisplayable active = getActive();\n\t\t\tdouble min = 0;\n\t\t\tdouble max = 0;\n\t\t\tif (null != active && active.getClass() == Patch.class) {\n\t\t\t\tmin = ((Patch)active).getMin();\n\t\t\t\tmax = ((Patch)active).getMax();\n\t\t\t}\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Min and Max\");\n\t\t\tgd.addMessage(\"Set min and max to all selected images\");\n\t\t\tgd.addNumericField(\"min: \", min, 2);\n\t\t\tgd.addNumericField(\"max: \", max, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tmin = gd.getNextNumber();\n\t\t\tmax = gd.getNextNumber();\n\t\t\tfinal HashSet ds = new HashSet(selection.getSelected(Patch.class));\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().setMinAndMax(selection.getSelected(Patch.class), min, max);\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Adjust min and max (selected images)...\")) {\n\t\t\tfinal List list = selection.getSelected(Patch.class);\n\t\t\tif (list.isEmpty()) {\n\t\t\t\tUtils.log(\"No images selected!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Init contrast adjustment\") {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsetMode(new ContrastAdjustmentMode(Display.this, list));\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\tUtils.log(\"All images must be of the same type!\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, list.get(0).getProject());\n\t\t} else if (command.equals(\"Mask image borders (layer-wise)...\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Mask borders\");\n\t\t\tUtils.addLayerRangeChoices(Display.this.layer, gd);\n\t\t\tgd.addMessage(\"Borders:\");\n\t\t\tgd.addNumericField(\"left: \", 6, 2);\n\t\t\tgd.addNumericField(\"top: \", 6, 2);\n\t\t\tgd.addNumericField(\"right: \", 6, 2);\n\t\t\tgd.addNumericField(\"bottom: \", 6, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tCollection layers = layer.getParent().getLayers().subList(gd.getNextChoiceIndex(), gd.getNextChoiceIndex() +1);\n\t\t\tfinal HashSet ds = new HashSet();\n\t\t\tfor (Layer l : layers) ds.addAll(l.getDisplayables(Patch.class));\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().maskBordersLayerWise(layers, (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber());\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Mask image borders (selected images)...\")) {\n\t\t\tfinal GenericDialog gd = new GenericDialog(\"Mask borders\");\n\t\t\tgd.addMessage(\"Borders:\");\n\t\t\tgd.addNumericField(\"left: \", 6, 2);\n\t\t\tgd.addNumericField(\"top: \", 6, 2);\n\t\t\tgd.addNumericField(\"right: \", 6, 2);\n\t\t\tgd.addNumericField(\"bottom: \", 6, 2);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tCollection patches = selection.getSelected(Patch.class);\n\t\t\tfinal HashSet ds = new HashSet(patches);\n\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\tBureaucrat burro = project.getLoader().maskBorders(patches, (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber(), (int)gd.getNextNumber());\n\t\t\tburro.addPostTask(new Runnable() { public void run() {\n\t\t\t\tgetLayerSet().addDataEditStep(ds);\n\t\t\t}});\n\t\t} else if (command.equals(\"Split images under polyline ROI\")) {\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null == roi) return;\n\t\t\tif (roi.getType() != Roi.POLYLINE) {\n\t\t\t\tUtils.showMessage(\"Need a polyline ROI, not just any ROI!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!Utils.check(\"Really split images under the polyline ROI?\")) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal Set col = new HashSet();\n\t\t\tPolygonRoi proi = (PolygonRoi)roi;\n\t\t\tint[] x = proi.getXCoordinates(),\n\t\t\t\t y = proi.getYCoordinates();\n\t\t\tRectangle b = proi.getBounds();\n\t\t\tPolygon[] pols = new Polygon[proi.getNCoordinates() -1];\n\t\t\tfor (int i=0; i> fus = new ArrayList>();\n\t\t\t\t\t\t\t\tfor (final Patch p : (Collection)(Collection)col) {\n\t\t\t\t\t\t\t\t\tPatch copy = (Patch) p.clone(p.getProject(), false);\n\t\t\t\t\t\t\t\t\tp.addAlphaMask(r1, 0);\n\t\t\t\t\t\t\t\t\tcopy.addAlphaMask(r2, 0);\n\t\t\t\t\t\t\t\t\tfus.add(p.updateMipMaps());\n\t\t\t\t\t\t\t\t\tfus.add(copy.updateMipMaps());\n\t\t\t\t\t\t\t\t\tp.getLayer().add(copy); \n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tUtils.wait(fus);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, project);\n\t\t\t\t\t} catch (Throwable t) {\n\t\t\t\t\t\tIJError.print(t);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tyn.dispose();\n\t\t\t\t\t\tDisplay.repaint(getLayer());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tyn.setVisible(true);\n\t\t} else if (command.equals(\"Duplicate\")) {\n\t\t\tfinal HashSet accepted = new HashSet();\n\t\t\taccepted.add(Patch.class);\n\t\t\taccepted.add(DLabel.class);\n\t\t\taccepted.add(Stack.class);\n\t\t\tfinal ArrayList originals = new ArrayList();\n\t\t\tfinal ArrayList selected = selection.getSelected();\n\t\t\tfor (final Displayable d : selected) {\n\t\t\t\tif (accepted.contains(d.getClass())) {\n\t\t\t\t\toriginals.add(d);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (originals.size() > 0) {\n\t\t\t\tgetLayerSet().addChangeTreesStep();\n\t\t\t\tfor (final Displayable d : originals) {\n\t\t\t\t\tif (d instanceof ZDisplayable) {\n\t\t\t\t\t\td.getLayerSet().add((ZDisplayable)d.clone());\n\t\t\t\t\t} else {\n\t\t\t\t\t\td.getLayer().add(d.clone());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgetLayerSet().addChangeTreesStep();\n\t\t\t} else if (selected.size() > 0) {\n\t\t\t\tUtils.log(\"Can only duplicate images and text labels.\\nDuplicate *other* objects in the Project Tree.\\n\");\n\t\t\t}\n\t\t} else if (command.equals(\"Create subproject\")) {\n\t\t\tRoi roi = canvas.getFakeImagePlus().getRoi();\n\t\t\tif (null == roi) return; \n\t\t\tLayer first, last;\n\t\t\tif (1 == layer.getParent().size()) {\n\t\t\t\tfirst = last = layer;\n\t\t\t} else {\n\t\t\t\tGenericDialog gd = new GenericDialog(\"Choose layer range\");\n\t\t\t\tUtils.addLayerRangeChoices(layer, gd);\n\t\t\t\tgd.showDialog();\n\t\t\t\tif (gd.wasCanceled()) return;\n\t\t\t\tfirst = layer.getParent().getLayer(gd.getNextChoiceIndex());\n\t\t\t\tlast = layer.getParent().getLayer(gd.getNextChoiceIndex());\n\t\t\t\tUtils.log2(\"first, last: \" + first + \", \" + last);\n\t\t\t}\n\t\t\tProject sub = getProject().createSubproject(roi.getBounds(), first, last);\n\t\t\tif (null == sub) {\n\t\t\t\tUtils.log(\"ERROR: failed to create subproject.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfinal LayerSet subls = sub.getRootLayerSet();\n\t\t\tDisplay.createDisplay(sub, subls.getLayer(0));\n\t\t} else if (command.startsWith(\"Image stack under selected Arealist\")) {\n\t\t\tif (null == active || active.getClass() != AreaList.class) return;\n\t\t\tGenericDialog gd = new GenericDialog(\"Stack options\");\n\t\t\tString[] types = {\"8-bit\", \"16-bit\", \"32-bit\", \"RGB\"};\n\t\t\tgd.addChoice(\"type:\", types, types[0]);\n\t\t\tgd.addSlider(\"Scale: \", 1, 100, 100);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal int type;\n\t\t\tswitch (gd.getNextChoiceIndex()) {\n\t\t\t\tcase 0: type = ImagePlus.GRAY8; break;\n\t\t\t\tcase 1: type = ImagePlus.GRAY16; break;\n\t\t\t\tcase 2: type = ImagePlus.GRAY32; break;\n\t\t\t\tcase 3: type = ImagePlus.COLOR_RGB; break;\n\t\t\t\tdefault: type = ImagePlus.GRAY8; break;\n\t\t\t}\n\t\t\tImagePlus imp = ((AreaList)active).getStack(type, gd.getNextNumber()/100);\n\t\t\tif (null != imp) imp.show();\n\t\t} else if (command.equals(\"Fly through selected Treeline/AreaTree\")) {\n\t\t\tif (null == active || !(active instanceof Tree)) return;\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Creating fly through\", true) {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\tGenericDialog gd = new GenericDialog(\"Fly through\");\n\t\t\t\t\tgd.addNumericField(\"Width\", 512, 0);\n\t\t\t\t\tgd.addNumericField(\"Height\", 512, 0);\n\t\t\t\t\tString[] types = new String[]{\"8-bit gray\", \"Color RGB\"};\n\t\t\t\t\tgd.addChoice(\"Image type\", types, types[0]);\n\t\t\t\t\tgd.addSlider(\"scale\", 0, 100, 100);\n\t\t\t\t\tgd.addCheckbox(\"save to file\", false);\n\t\t\t\t\tgd.showDialog();\n\t\t\t\t\tif (gd.wasCanceled()) return;\n\t\t\t\t\tint w = (int)gd.getNextNumber();\n\t\t\t\t\tint h = (int)gd.getNextNumber();\n\t\t\t\t\tint type = 0 == gd.getNextChoiceIndex() ? ImagePlus.GRAY8 : ImagePlus.COLOR_RGB;\n\t\t\t\t\tdouble scale = gd.getNextNumber();\n\t\t\t\t\tif (w <=0 || h <=0) {\n\t\t\t\t\t\tUtils.log(\"Invalid width or height: \" + w + \", \" + h);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (0 == scale || Double.isNaN(scale)) {\n\t\t\t\t\t\tUtils.log(\"Invalid scale: \" + scale);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tString dir = null;\n\t\t\t\t\tif (gd.getNextBoolean()) {\n\t\t\t\t\t\tDirectoryChooser dc = new DirectoryChooser(\"Target directory\");\n\t\t\t\t\t\tdir = dc.getDirectory();\n\t\t\t\t\t\tif (null == dir) return; \n\t\t\t\t\t\tdir = Utils.fixDir(dir);\n\t\t\t\t\t}\n\t\t\t\t\tImagePlus imp = ((Tree)active).flyThroughMarked(w, h, scale/100, type, dir);\n\t\t\t\t\tif (null == imp) {\n\t\t\t\t\t\tUtils.log(\"Mark a node first!\");\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\timp.show();\n\t\t\t\t}\n\t\t\t}, project);\n\t\t} else if (command.startsWith(\"Arealists as labels\")) {\n\t\t\tGenericDialog gd = new GenericDialog(\"Export labels\");\n\t\t\tgd.addSlider(\"Scale: \", 1, 100, 100);\n\t\t\tfinal String[] options = {\"All area list\", \"Selected area lists\"};\n\t\t\tgd.addChoice(\"Export: \", options, options[0]);\n\t\t\tUtils.addLayerRangeChoices(layer, gd);\n\t\t\tgd.addCheckbox(\"Visible only\", true);\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tfinal float scale = (float)(gd.getNextNumber() / 100);\n\t\t\tjava.util.List al = (java.util.List)(0 == gd.getNextChoiceIndex() ? layer.getParent().getZDisplayables(AreaList.class) : selection.getSelectedSorted(AreaList.class));\n\t\t\tif (null == al) {\n\t\t\t\tUtils.log(\"No area lists found to export.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint first = gd.getNextChoiceIndex();\n\t\t\tint last = gd.getNextChoiceIndex();\n\t\t\tboolean visible_only = gd.getNextBoolean();\n\t\t\tif (-1 != command.indexOf(\"(amira)\")) {\n\t\t\t\tAreaList.exportAsLabels(al, canvas.getFakeImagePlus().getRoi(), scale, first, last, visible_only, true, true);\n\t\t\t} else if (-1 != command.indexOf(\"(tif)\")) {\n\t\t\t\tAreaList.exportAsLabels(al, canvas.getFakeImagePlus().getRoi(), scale, first, last, visible_only, false, false);\n\t\t\t}\n\t\t} else if (command.equals(\"Project properties...\")) {\n\t\t\tproject.adjustProperties();\n\t\t} else if (command.equals(\"Release memory...\")) {\n\t\t\tBureaucrat.createAndStart(new Worker(\"Releasing memory\") {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tstartedWorking();\n\t\t\t\t\ttry {\n\t\t\tGenericDialog gd = new GenericDialog(\"Release Memory\");\n\t\t\tint max = (int)(IJ.maxMemory() / 1000000);\n\t\t\tgd.addSlider(\"Megabytes: \", 0, max, max/2);\n\t\t\tgd.showDialog();\n\t\t\tif (!gd.wasCanceled()) {\n\t\t\t\tint n_mb = (int)gd.getNextNumber();\n\t\t\t\tproject.getLoader().releaseToFit((long)n_mb*1000000);\n\t\t\t}\n\t\t\t\t\t} catch (Throwable e) {\n\t\t\t\t\t\tIJError.print(e);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tfinishedWorking();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, project);\n\t\t} else if (command.equals(\"Flush image cache\")) {\n\t\t\tLoader.releaseAllCaches();\n\t\t} else if (command.equals(\"Regenerate all mipmaps\")) {\n\t\t\tproject.getLoader().regenerateMipMaps(getLayerSet().getDisplayables(Patch.class));\n\t\t} else if (command.equals(\"Regenerate mipmaps (selected images)\")) {\n\t\t\tproject.getLoader().regenerateMipMaps(selection.getSelected(Patch.class));\n\t\t} else if (command.equals(\"Tags...\")) {\n\t\t\tFile f = Utils.chooseFile(null, \"tags\", \".xml\");\n\t\t\tif (null == f) return;\n\t\t\tif (!Utils.saveToFile(f, getLayerSet().exportTags())) {\n\t\t\t\tUtils.logAll(\"ERROR when saving tags to file \" + f.getAbsolutePath());\n\t\t\t}\n\t\t} else if (command.equals(\"Tags ...\")) {\n\t\t\tString[] ff = Utils.selectFile(\"Import tags\");\n\t\t\tif (null == ff) return;\n\t\t\tGenericDialog gd = new GenericDialog(\"Import tags\");\n\t\t\tString[] modes = new String[]{\"Append to current tags\", \"Replace current tags\"};\n\t\t\tgd.addChoice(\"Import tags mode:\", modes, modes[0]);\n\t\t\tgd.addMessage(\"Replacing current tags\\nwill remove all tags\\n from all nodes first!\");\n\t\t\tgd.showDialog();\n\t\t\tif (gd.wasCanceled()) return;\n\t\t\tgetLayerSet().importTags(new StringBuilder(ff[0]).append('/').append(ff[1]).toString(), 1 == gd.getNextChoiceIndex());\n\t\t} else if (command.equals(\"Connectivity graph...\")) {\n\t\t\tBureaucrat.createAndStart(new Worker.Task(\"Connectivity graph\") {\n\t\t\t\tpublic void exec() {\n\t\t\t\t\tGraph.extractAndShowGraph(getLayerSet());\n\t\t\t\t}\n\t\t\t}, getProject());\n\t\t} else if (command.equals(\"Measure\")) {\n\t\t\tif (selection.isEmpty()) {\n\t\t\t\tUtils.log(\"Nothing selected to measure!\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tselection.measure();\n\t\t} else {\n\t\t\tUtils.log2(\"Display: don't know what to do with command \" + command);\n\t\t}\n\t\t}});\n"} {"input": " public List markForDehydration(List runningProcesses) {\n ArrayList ripped = new ArrayList();\n if (_processMaxAge > 0) {\n long now = System.currentTimeMillis();\n for (BpelProcess process : runningProcesses) {\n if (now - process.getLastUsed() > _processMaxAge) {\n ripped.add(process);\n }\n }\n }\n if (runningProcesses.size() - ripped.size() > _processMaxCount) {\n runningProcesses.removeAll(ripped);\n Collections.sort(runningProcesses, new Comparator() {\n public int compare(BpelProcess p1, BpelProcess p2) {\n if (p1.getLastUsed() > p2.getLastUsed()) return 1;\n if (p1.getLastUsed() < p2.getLastUsed()) return -1;\n return 0;\n }\n });\n for (int m = _processMaxCount; m < runningProcesses.size(); m++) {\n ripped.add(runningProcesses.get(m));\n }\n }\n return ripped;\n }\n", "output": " public List markForDehydration(List runningProcesses) {\n ArrayList ripped = new ArrayList();\n if (_processMaxAge > 0) {\n long now = System.currentTimeMillis();\n for (BpelProcess process : runningProcesses) {\n if (now - process.getLastUsed() > _processMaxAge) {\n ripped.add(process);\n }\n }\n }\n if (runningProcesses.size() - ripped.size() > _processMaxCount) {\n runningProcesses.removeAll(ripped);\n Collections.sort(runningProcesses, new Comparator() {\n public int compare(BpelProcess p1, BpelProcess p2) {\n if (p1.getLastUsed() > p2.getLastUsed()) return -1;\n if (p1.getLastUsed() < p2.getLastUsed()) return 1;\n return 0;\n }\n });\n for (int m = _processMaxCount; m < runningProcesses.size(); m++) {\n ripped.add(runningProcesses.get(m));\n }\n }\n return ripped;\n }\n"} {"input": " private void goalie_movement() {\n int CAGE_RADIUS = 100;\n double ang = Util.datan2(getPuck(), GOAL_POSITION);\n ang = Util.clamp(-90,ang, 90);\n double heading = getTargetHeading();\n double newX = Util.clamp(GOAL_POSITION.getX() + 50, GOAL_POSITION.getX() + Math.cos(ang)*CAGE_RADIUS, 0);\n double newY = GOAL_POSITION.getY() + Math.sin(ang)*CAGE_RADIUS;\n if (newY > 0 && getPuck().getY() < 0) {\n newY = -newY;\n } else if (newY < 0 && getPuck().getY() > 0) {\n newY = -newY;\n }\n skate((int)newX, (int)newY, 100);\n turn(getPuck(), MAX_TURN_SPEED);\n setMessage(Double.toString(newX).substring(0,5) + \" \" + Double.toString(newY).substring(0, 5) + \" \" + Double.toString(ang));\n }\n", "output": " private void goalie_movement() {\n int CAGE_RADIUS = 100;\n double ang = Util.datan2(getPuck(), GOAL_POSITION);\n ang = Util.clamp(-90,ang, 90);\n double heading = getTargetHeading();\n double newX = Util.clamp(GOAL_POSITION.getX() + 50, GOAL_POSITION.getX() + Math.cos(ang)*CAGE_RADIUS, 0);\n double newY = GOAL_POSITION.getY() + Math.sin(ang)*CAGE_RADIUS;\n if (newY > 0 && getPuck().getY() < 0) {\n newY = -newY;\n } else if (newY < 0 && getPuck().getY() > 0) {\n newY = -newY;\n }\n skate((int)newX, (int)newY, 100);\n turn(getPuck(), MAX_TURN_SPEED);\n }\n"} {"input": " public void migrate()\n throws CvqException {\n for (DTO dto : (List)HibernateUtil.getSession().createSQLQuery(\n \"select r.requester_id as requesterId, r.home_folder_id as homeFolderId, r.creation_date as date, i.id as individualId from individual i, request r, history_entry he where r.id = he.request_id and i.id = he.object_id and property = 'homeFolder' and old_value is not null and new_value is null\")\n .addScalar(\"requesterId\").addScalar(\"homeFolderId\").addScalar(\"date\")\n .addScalar(\"individualId\").setResultTransformer(Transformers.aliasToBean(DTO.class))\n .list()) {\n Individual i = userSearchService.getById(dto.individualId);\n HomeFolder homeFolder = userSearchService.getHomeFolderById(dto.homeFolderId);\n i.setHomeFolder(homeFolder);\n homeFolder.getIndividuals().add(i);\n i.setState(UserState.ARCHIVED);\n archived.add(i.getId());\n RequestAction fake = new RequestAction();\n fake.setDate(dto.date);\n fake.setAgentId(dto.requesterId);\n JsonObject payload = new JsonObject();\n payload.addProperty(\"state\", UserState.ARCHIVED.toString());\n add(homeFolder, new UserAction(UserAction.Type.STATE_CHANGE, dto.individualId, payload), fake);\n }\n for (HomeFolder homeFolder : customDAO.all(HomeFolder.class)) {\n Set criterias = new HashSet();\n criterias.add(new Critere(Request.SEARCH_BY_HOME_FOLDER_ID, homeFolder.getId(), Critere.EQUALS));\n List requests = requestSearchService.get(criterias, null, null, 0, 0, true);\n Request first = requests.get(requests.size() - 1);\n if (homeFolder.isTemporary()) {\n List actions = new ArrayList(first.getActions());\n Collections.reverse(actions);\n for (RequestAction requestAction : actions) {\n convert(requestAction);\n }\n } else {\n for (RequestAction requestAction :\n (List)HibernateUtil.getSession().createSQLQuery(\n \"select * from request_action where request_id in (select id from request where home_folder_id = :homeFolderId and specific_data_class='fr.cg95.cvq.business.request.ecitizen.HomeFolderModificationRequestData') or request_id = :firstId order by date asc\")\n .addEntity(RequestAction.class).setLong(\"homeFolderId\", homeFolder.getId())\n .setLong(\"firstId\", first.getId()).list()) {\n convert(requestAction);\n }\n }\n }\n HibernateUtil.getSession().flush();\n for (HomeFolder homeFolder : customDAO.all(HomeFolder.class)) {\n if (!customDAO.hasCreationAction(homeFolder.getId()))\n createFakeCreationAction(homeFolder, homeFolder.getId());\n for (Individual i : homeFolder.getIndividuals())\n if (!customDAO.hasCreationAction(i.getId()))\n createFakeCreationAction(homeFolder, i.getId());\n }\n HibernateUtil.getSession().flush();\n for (Map.Entry creationNotification : creationNotifications.entrySet()) {\n for (Long id : creationActions.get(creationNotification.getKey())) {\n UserAction action = (UserAction) customDAO.findById(UserAction.class, id);\n JsonObject payload = JSONUtils.deserialize(action.getData());\n payload.addProperty(\"notificationDate\", creationNotification.getValue().toString());\n action.setData(new Gson().toJson(payload));\n customDAO.update(action);\n }\n }\n for (Long id : archived) {\n states.put(id, UserState.ARCHIVED);\n }\n for (Map.Entry state : states.entrySet()) {\n try {\n Individual i = userSearchService.getById(state.getKey());\n i.setState(state.getValue());\n customDAO.update(i);\n } catch (CvqObjectNotFoundException e) {\n HomeFolder homeFolder = userSearchService.getHomeFolderById(state.getKey());\n homeFolder.setState(state.getValue());\n customDAO.update(homeFolder);\n }\n }\n for (Adult external : customDAO.findBySimpleProperty(Adult.class, \"homeFolder\", null)) {\n HomeFolder homeFolder = null;\n for (IndividualRole role : (List) HibernateUtil.getSession()\n .createSQLQuery(\"select * from individual_role where owner_id = :id\")\n .addEntity(IndividualRole.class).setLong(\"id\", external.getId()).list()) {\n if (role.getHomeFolderId() != null) {\n try {\n homeFolder = userSearchService.getHomeFolderById(role.getHomeFolderId());\n } catch (CvqObjectNotFoundException e) {\n }\n } else if (role.getIndividualId() != null) {\n try {\n homeFolder = userSearchService.getById(role.getIndividualId()).getHomeFolder();\n } catch (CvqObjectNotFoundException e) {\n }\n }\n if (homeFolder != null) {\n createFakeCreationAction(homeFolder, external.getId());\n break;\n }\n }\n }\n }\n", "output": " public void migrate()\n throws CvqException {\n for (DTO dto : (List)HibernateUtil.getSession().createSQLQuery(\n \"select r.requester_id as requesterId, r.home_folder_id as homeFolderId, r.creation_date as date, i.id as individualId from individual i, request r, history_entry he where r.id = he.request_id and i.id = he.object_id and property = 'homeFolder' and old_value is not null and new_value is null\")\n .addScalar(\"requesterId\").addScalar(\"homeFolderId\").addScalar(\"date\")\n .addScalar(\"individualId\").setResultTransformer(Transformers.aliasToBean(DTO.class))\n .list()) {\n Individual i = userSearchService.getById(dto.individualId);\n HomeFolder homeFolder = userSearchService.getHomeFolderById(dto.homeFolderId);\n i.setHomeFolder(homeFolder);\n homeFolder.getIndividuals().add(i);\n i.setState(UserState.ARCHIVED);\n archived.add(i.getId());\n RequestAction fake = new RequestAction();\n fake.setDate(dto.date);\n fake.setAgentId(dto.requesterId);\n JsonObject payload = new JsonObject();\n payload.addProperty(\"state\", UserState.ARCHIVED.toString());\n add(homeFolder, new UserAction(UserAction.Type.STATE_CHANGE, dto.individualId, payload), fake);\n }\n for (HomeFolder homeFolder : customDAO.all(HomeFolder.class)) {\n Set criterias = new HashSet();\n criterias.add(new Critere(Request.SEARCH_BY_HOME_FOLDER_ID, homeFolder.getId(), Critere.EQUALS));\n List requests = requestSearchService.get(criterias, Request.SEARCH_BY_CREATION_DATE, null, 0, 0, true);\n if (requests.isEmpty()) continue;\n Request first = requests.get(0);\n if (homeFolder.isTemporary()) {\n List actions = new ArrayList(first.getActions());\n Collections.reverse(actions);\n for (RequestAction requestAction : actions) {\n convert(requestAction);\n }\n } else {\n for (RequestAction requestAction :\n (List)HibernateUtil.getSession().createSQLQuery(\n \"select * from request_action where request_id in (select id from request where home_folder_id = :homeFolderId and specific_data_class='fr.cg95.cvq.business.request.ecitizen.HomeFolderModificationRequestData') or request_id = :firstId order by date asc\")\n .addEntity(RequestAction.class).setLong(\"homeFolderId\", homeFolder.getId())\n .setLong(\"firstId\", first.getId()).list()) {\n convert(requestAction);\n }\n }\n }\n HibernateUtil.getSession().flush();\n for (HomeFolder homeFolder : customDAO.all(HomeFolder.class)) {\n if (!customDAO.hasCreationAction(homeFolder.getId()))\n createFakeCreationAction(homeFolder, homeFolder.getId());\n for (Individual i : homeFolder.getIndividuals())\n if (!customDAO.hasCreationAction(i.getId()))\n createFakeCreationAction(homeFolder, i.getId());\n }\n HibernateUtil.getSession().flush();\n for (Map.Entry creationNotification : creationNotifications.entrySet()) {\n for (Long id : creationActions.get(creationNotification.getKey())) {\n UserAction action = (UserAction) customDAO.findById(UserAction.class, id);\n JsonObject payload = JSONUtils.deserialize(action.getData());\n payload.addProperty(\"notificationDate\", creationNotification.getValue().toString());\n action.setData(new Gson().toJson(payload));\n customDAO.update(action);\n }\n }\n for (Long id : archived) {\n states.put(id, UserState.ARCHIVED);\n }\n for (Map.Entry state : states.entrySet()) {\n try {\n Individual i = userSearchService.getById(state.getKey());\n i.setState(state.getValue());\n customDAO.update(i);\n } catch (CvqObjectNotFoundException e) {\n HomeFolder homeFolder = userSearchService.getHomeFolderById(state.getKey());\n homeFolder.setState(state.getValue());\n customDAO.update(homeFolder);\n }\n }\n for (Adult external : customDAO.findBySimpleProperty(Adult.class, \"homeFolder\", null)) {\n HomeFolder homeFolder = null;\n for (IndividualRole role : (List) HibernateUtil.getSession()\n .createSQLQuery(\"select * from individual_role where owner_id = :id\")\n .addEntity(IndividualRole.class).setLong(\"id\", external.getId()).list()) {\n if (role.getHomeFolderId() != null) {\n try {\n homeFolder = userSearchService.getHomeFolderById(role.getHomeFolderId());\n } catch (CvqObjectNotFoundException e) {\n }\n } else if (role.getIndividualId() != null) {\n try {\n homeFolder = userSearchService.getById(role.getIndividualId()).getHomeFolder();\n } catch (CvqObjectNotFoundException e) {\n }\n }\n if (homeFolder != null) {\n createFakeCreationAction(homeFolder, external.getId());\n break;\n }\n }\n }\n }\n"} {"input": "\tpublic Object[][] getList()\n\t{\n\t\tint number = getNumberOfVehicles();\n\t\tint count = 0;\n\t\tObject[][] vehicleList = new Object[number][8]; \t\t\n\t\tConnection conn = ConnectDB.initConn();\n\t\ttry \n\t\t{\n\t\t\tStatement s = conn.createStatement();\n\t\t\ts.executeQuery(\"SELECT * FROM Customer\");\n\t\t\tResultSet rs = s.getResultSet();\n\t\t\twhile(rs.next())\n\t\t\t{\n\t\t\t\tvehicleList[count][0] = rs.getString(\"vehicleID\");\n\t\t\t\tvehicleList[count][1] = rs.getString(\"make\");\n\t\t\t\tvehicleList[count][2] = rs.getString(\"model\");\n\t\t\t\tvehicleList[count][3] = rs.getInt(\"odumeter\");\n\t\t\t\tvehicleList[count][4] = rs.getInt(\"fuel\");\n\t\t\t\tvehicleList[count][5] = rs.getInt(\"automatic\");\n\t\t\t\tvehicleList[count][6] = rs.getInt(\"statusID\");\n\t\t\t\tvehicleList[count][7] = rs.getInt(\"typeID\");\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\ts.close();\n\t\t} \n\t\tcatch (SQLException e) \n\t\t{\n\t\t\te.printStackTrace();\n\t\t}\n\t\tfinally \n\t\t{\n\t\t\tConnectDB.closeConn(conn);\n\t\t}\n\t\treturn vehicleList;\n\t}\n", "output": "\tpublic Object[][] getList()\n\t{\n\t\tint number = getNumberOfVehicles();\n\t\tint count = 0;\n\t\tObject[][] vehicleList = new Object[number][8]; \t\t\n\t\tConnection conn = ConnectDB.initConn();\n\t\ttry \n\t\t{\n\t\t\tStatement s = conn.createStatement();\n\t\t\ts.executeQuery(\"SELECT * FROM Vehicle\");\n\t\t\tResultSet rs = s.getResultSet();\n\t\t\twhile(rs.next())\n\t\t\t{\n\t\t\t\tvehicleList[count][0] = rs.getString(\"vehicleID\");\n\t\t\t\tvehicleList[count][1] = rs.getString(\"make\");\n\t\t\t\tvehicleList[count][2] = rs.getString(\"model\");\n\t\t\t\tvehicleList[count][3] = rs.getInt(\"odumeter\");\n\t\t\t\tvehicleList[count][4] = rs.getInt(\"fuel\");\n\t\t\t\tvehicleList[count][5] = rs.getInt(\"automatic\");\n\t\t\t\tvehicleList[count][6] = rs.getInt(\"statusID\");\n\t\t\t\tvehicleList[count][7] = rs.getInt(\"typeID\");\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\ts.close();\n\t\t} \n\t\tcatch (SQLException e) \n\t\t{\n\t\t\te.printStackTrace();\n\t\t}\n\t\tfinally \n\t\t{\n\t\t\tConnectDB.closeConn(conn);\n\t\t}\n\t\treturn vehicleList;\n\t}\n"} {"input": "\tprivate static void getExtensionClassesAndNames(Map exts, Set exts_names) {\n\t\tString version = GL11.glGetString(GL11.GL_VERSION);\n\t\tint majorEnd = version.indexOf('.');\n\t\tint minorEnd = version.indexOf('.', majorEnd + 1);\n\t\tint majorVersion = Integer.parseInt(version.substring(0, majorEnd));\n\t\tint minorVersion = Integer.parseInt(version.substring(majorEnd + 1, minorEnd));\n\t\tif ( majorVersion == 2 ) {\n\t\t\taddExtensionClass(exts, exts_names, \"GL20\", \"OpenGL20\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL15\", \"OpenGL15\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL14\", \"OpenGL14\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL13\", \"OpenGL13\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL12\", \"OpenGL12\");\n\t\t} else {\n\t\t\tswitch ( minorVersion ) {\n\t\t\t\tcase 5:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL15\", \"OpenGL15\");\n\t\t\t\tcase 4:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL14\", \"OpenGL14\");\n\t\t\t\tcase 3:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL13\", \"OpenGL13\");\n\t\t\t\tcase 2:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL12\", \"OpenGL12\");\n\t\t\t}\n\t\t}\n\t\taddExtensionClass(exts, exts_names, \"EXTTextureCompressionS3TC\", \"\");\n\t\tString extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);\n\t\tStringTokenizer tokenizer = new StringTokenizer(extensions_string);\n\t\twhile ( tokenizer.hasMoreTokens() ) {\n\t\t\tString extension_string = tokenizer.nextToken();\n\t\t\tStringBuffer converted_name = new StringBuffer();\n\t\t\tint gl_prefix_index = extension_string.indexOf(\"GL_\");\n\t\t\tif ( gl_prefix_index == -1 )\n\t\t\t\tcontinue;\n\t\t\tif ( \"GL_EXT_texture_compression_s3tc\".equals(extension_string) ) {\n\t\t\t\taddExtensionClass(exts, exts_names, \"EXTTextureCompressionS3TC\", \"GL_EXT_texture_compression_s3tc\");\n\t\t\t} else if ( \"GL_EXT_texture_lod_bias\".equals(extension_string) ) {\n\t\t\t\taddExtensionClass(exts, exts_names, \"EXTTextureLODBias\", \"GL_EXT_texture_lod_bias\");\n\t\t\t} else if ( \"GL_NV_texture_compression_vtc\".equals(extension_string) ) {\n\t\t\t\taddExtensionClass(exts, exts_names, \"NVTextureCompressionVTC\", \"GL_NV_texture_compression_vtc\");\n\t\t\t} else {\n\t\t\t\tfor ( int i = gl_prefix_index + 3; i < extension_string.length(); i++ ) {\n\t\t\t\t\tchar c;\n\t\t\t\t\tif ( extension_string.charAt(i) == '_' ) {\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\tc = Character.toUpperCase(extension_string.charAt(i));\n\t\t\t\t\t} else\n\t\t\t\t\t\tc = extension_string.charAt(i);\n\t\t\t\t\tconverted_name.append(c);\n\t\t\t\t}\n\t\t\t\taddExtensionClass(exts, exts_names, converted_name.toString(), extension_string);\n\t\t\t}\n\t\t}\n\t\taddExtensionClass(exts, exts_names, \"ARBBufferObject\", null);\n\t\taddExtensionClass(exts, exts_names, \"ARBProgram\", null);\n\t\taddExtensionClass(exts, exts_names, \"NVProgram\", null);\n\t}\n", "output": "\tprivate static void getExtensionClassesAndNames(Map exts, Set exts_names) {\n\t\tString version = GL11.glGetString(GL11.GL_VERSION);\n\t\tint majorEnd = version.indexOf('.');\n\t\tint minorEnd = -1;\n\t\tif (majorEnd != -1) {\n\t\t\tminorEnd = version.indexOf('.', majorEnd + 1);\n\t\t} else {\n\t\t\tmajorEnd = version.length();\n\t\t}\n\t\tint majorVersion;\n\t\tif (majorEnd == 0) {\n\t\t\tthrow new OpenGLException(\"Unable to determine GL version.\");\n\t\t}\n\t\tmajorVersion = Integer.parseInt(version.substring(0, majorEnd));\n\t\tint minorVersion;\n\t\tif (minorEnd == -1) {\n\t\t\tminorVersion = 0;\n\t\t} else {\n\t\t\tminorVersion = Integer.parseInt(version.substring(majorEnd + 1, minorEnd));\n\t\t}\n\t\tif ( majorVersion == 2 ) {\n\t\t\taddExtensionClass(exts, exts_names, \"GL20\", \"OpenGL20\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL15\", \"OpenGL15\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL14\", \"OpenGL14\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL13\", \"OpenGL13\");\n\t\t\taddExtensionClass(exts, exts_names, \"GL12\", \"OpenGL12\");\n\t\t} else {\n\t\t\tswitch ( minorVersion ) {\n\t\t\t\tcase 5:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL15\", \"OpenGL15\");\n\t\t\t\tcase 4:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL14\", \"OpenGL14\");\n\t\t\t\tcase 3:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL13\", \"OpenGL13\");\n\t\t\t\tcase 2:\n\t\t\t\t\taddExtensionClass(exts, exts_names, \"GL12\", \"OpenGL12\");\n\t\t\t}\n\t\t}\n\t\taddExtensionClass(exts, exts_names, \"EXTTextureCompressionS3TC\", \"\");\n\t\tString extensions_string = GL11.glGetString(GL11.GL_EXTENSIONS);\n\t\tStringTokenizer tokenizer = new StringTokenizer(extensions_string);\n\t\twhile ( tokenizer.hasMoreTokens() ) {\n\t\t\tString extension_string = tokenizer.nextToken();\n\t\t\tStringBuffer converted_name = new StringBuffer();\n\t\t\tint gl_prefix_index = extension_string.indexOf(\"GL_\");\n\t\t\tif ( gl_prefix_index == -1 )\n\t\t\t\tcontinue;\n\t\t\tif ( \"GL_EXT_texture_compression_s3tc\".equals(extension_string) ) {\n\t\t\t\taddExtensionClass(exts, exts_names, \"EXTTextureCompressionS3TC\", \"GL_EXT_texture_compression_s3tc\");\n\t\t\t} else if ( \"GL_EXT_texture_lod_bias\".equals(extension_string) ) {\n\t\t\t\taddExtensionClass(exts, exts_names, \"EXTTextureLODBias\", \"GL_EXT_texture_lod_bias\");\n\t\t\t} else if ( \"GL_NV_texture_compression_vtc\".equals(extension_string) ) {\n\t\t\t\taddExtensionClass(exts, exts_names, \"NVTextureCompressionVTC\", \"GL_NV_texture_compression_vtc\");\n\t\t\t} else {\n\t\t\t\tfor ( int i = gl_prefix_index + 3; i < extension_string.length(); i++ ) {\n\t\t\t\t\tchar c;\n\t\t\t\t\tif ( extension_string.charAt(i) == '_' ) {\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\tc = Character.toUpperCase(extension_string.charAt(i));\n\t\t\t\t\t} else\n\t\t\t\t\t\tc = extension_string.charAt(i);\n\t\t\t\t\tconverted_name.append(c);\n\t\t\t\t}\n\t\t\t\taddExtensionClass(exts, exts_names, converted_name.toString(), extension_string);\n\t\t\t}\n\t\t}\n\t\taddExtensionClass(exts, exts_names, \"ARBBufferObject\", null);\n\t\taddExtensionClass(exts, exts_names, \"ARBProgram\", null);\n\t\taddExtensionClass(exts, exts_names, \"NVProgram\", null);\n\t}\n"} {"input": " public List getJars() {\n File base = new File(getMinecraftDir(), \"bin\");\n List jars = new ArrayList();\n jars.add(new MinecraftJar(new File(base, \"minecraft.jar\")));\n File[] files = base.listFiles();\n Arrays.sort(files);\n if (files == null) {\n return jars;\n }\n for (File f : files) {\n String name = f.getName();\n if (name.matches(\"^[^\\\\/:;]+\\\\.jar$\") && !name.equalsIgnoreCase(\"jinput.jar\")\n && !name.equalsIgnoreCase(\"lwjgl.jar\")\n && !name.equalsIgnoreCase(\"lwjgl_util.jar\")\n && !name.equalsIgnoreCase(\"minecraft.jar\")) {\n jars.add(new MinecraftJar(f));\n }\n }\n return jars;\n }\n", "output": " public List getJars() {\n File base = new File(getMinecraftDir(), \"bin\");\n List jars = new ArrayList();\n jars.add(new MinecraftJar(new File(base, \"minecraft.jar\")));\n File[] files = base.listFiles();\n if (files == null) {\n return jars;\n }\n Arrays.sort(files);\n for (File f : files) {\n String name = f.getName();\n if (name.matches(\"^[^\\\\/:;]+\\\\.jar$\") && !name.equalsIgnoreCase(\"jinput.jar\")\n && !name.equalsIgnoreCase(\"lwjgl.jar\")\n && !name.equalsIgnoreCase(\"lwjgl_util.jar\")\n && !name.equalsIgnoreCase(\"minecraft.jar\")) {\n jars.add(new MinecraftJar(f));\n }\n }\n return jars;\n }\n"} {"input": " public void keyPressed(KeyEvent e) {\n float cx, cy;\n switch (e.getKeyCode()) {\n case KeyEvent.VK_MINUS:\n cx = view.getCenterX();\n cy = view.getCenterY();\n view.setWidth((int)(view.getWidth() / 1.1));\n view.setHeight((int)(view.getHeight() / 1.1));\n view.setCenterPosition(cx, cy);\n break;\n case KeyEvent.VK_EQUALS:\n cx = view.getCenterX();\n cy = view.getCenterY();\n view.setWidth((int)(view.getWidth() * 1.1));\n view.setHeight((int)(view.getHeight() * 1.1));\n view.setCenterPosition(cx, cy);\n break;\n case KeyEvent.VK_1:\n loadModel(\"models/beagle/Bug Hunt Speeds.nlogo\", \"Bug Hunt Speeds\");\n break;\n case KeyEvent.VK_2:\n loadModel(\"models/virus.nlogo\", \"Disease Model\");\n break;\n case KeyEvent.VK_3:\n loadModel(\"models/fireflies.nlogo\", \"Fireflies\");\n break;\n case KeyEvent.VK_4:\n loadModel(\"models/flocking.nlogo\", \"Flocking\");\n break;\n case KeyEvent.VK_5:\n loadModel(\"models/traffic.nlogo\", \"Traffic\");\n break;\n case KeyEvent.VK_6:\n loadModel(\"models/moths.nlogo\", \"Moths\");\n break;\n case KeyEvent.VK_RIGHT:\n break;\n case KeyEvent.VK_LEFT:\n break;\n case KeyEvent.VK_UP:\n break;\n case KeyEvent.VK_DOWN:\n break;\n }\n }\n", "output": " public void keyPressed(KeyEvent e) {\n float cx, cy;\n switch (e.getKeyCode()) {\n case KeyEvent.VK_MINUS:\n cx = view.getCenterX();\n cy = view.getCenterY();\n view.setWidth((int)(view.getWidth() / 1.1));\n view.setHeight((int)(view.getHeight() / 1.1));\n view.setCenterPosition(cx, cy);\n break;\n case KeyEvent.VK_EQUALS:\n cx = view.getCenterX();\n cy = view.getCenterY();\n view.setWidth((int)(view.getWidth() * 1.1));\n view.setHeight((int)(view.getHeight() * 1.1));\n view.setCenterPosition(cx, cy);\n break;\n case KeyEvent.VK_1:\n loadModel(\"models/beagle/Bug Hunt Speeds.nlogo\", \"Bug Hunt Speeds\");\n break;\n case KeyEvent.VK_2:\n loadModel(\"models/beagle/Bug Hunt Camouflage.nlogo\", \"Bug Hunt Camouflage\");\n break;\n case KeyEvent.VK_3:\n loadModel(\"models/fireflies.nlogo\", \"Fireflies\");\n break;\n case KeyEvent.VK_4:\n loadModel(\"models/flocking.nlogo\", \"Flocking\");\n break;\n case KeyEvent.VK_5:\n loadModel(\"models/traffic.nlogo\", \"Traffic\");\n break;\n case KeyEvent.VK_6:\n loadModel(\"models/moths.nlogo\", \"Moths\");\n break;\n case KeyEvent.VK_RIGHT:\n break;\n case KeyEvent.VK_LEFT:\n break;\n case KeyEvent.VK_UP:\n break;\n case KeyEvent.VK_DOWN:\n break;\n }\n }\n"} {"input": "\tpublic void report(HttpServletRequest req, HttpServletResponse res, Throwable t)\n\t{\n\t\tString headInclude = (String) req.getAttribute(\"sakai.html.head\");\n\t\tString bodyOnload = (String) req.getAttribute(\"sakai.html.body.onload\");\n\t\tTime reportTime = TimeService.newTime();\n\t\tString time = reportTime.toStringLocalDate() + \" \"\n\t\t\t\t+ reportTime.toStringLocalTime24();\n\t\tString usageSessionId = UsageSessionService.getSessionId();\n\t\tString userId = SessionManager.getCurrentSessionUserId();\n\t\tString requestDisplay = requestDisplay(req);\n\t\tString placementDisplay = placementDisplay();\n\t\tString problem = throwableDisplay(t);\n\t\tString problemdigest = computeSha1(problem);\n\t\tString postAddr = ServerConfigurationService.getPortalUrl() + \"/error-report\";\n\t\tString requestURI = req.getRequestURI();\n\t\tif (bodyOnload == null)\n\t\t{\n\t\t\tbodyOnload = \"\";\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbodyOnload = \" onload=\\\"\" + bodyOnload + \"\\\"\";\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tres.setContentType(\"text/html; charset=UTF-8\");\n\t\t\tres.addDateHeader(\"Expires\", System.currentTimeMillis()\n\t\t\t\t\t- (1000L * 60L * 60L * 24L * 365L));\n\t\t\tres.addDateHeader(\"Last-Modified\", System.currentTimeMillis());\n\t\t\tres\n\t\t\t\t\t.addHeader(\"Cache-Control\",\n\t\t\t\t\t\t\t\"no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0\");\n\t\t\tres.addHeader(\"Pragma\", \"no-cache\");\n\t\t\tPrintWriter out = res.getWriter();\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tif (headInclude != null)\n\t\t\t{\n\t\t\t\tout.println(\"\");\n\t\t\t\tout.println(headInclude);\n\t\t\t\tout.println(\"\");\n\t\t\t}\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.error\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.statement\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.sendtitle\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.sendinstructions\") + \"

\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.recoverytitle\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.recoveryinstructions\") + \"\");\n\t\t\tout.println(\"

  • \" + rb.getString(\"bugreport.recoveryinstructions1\")\n\t\t\t\t\t+ \"
  • \");\n\t\t\tout.println(\"
  • \" + rb.getString(\"bugreport.recoveryinstructions2\")\n\t\t\t\t\t+ \"
  • \");\n\t\t\tout.println(\"
  • \" + rb.getString(\"bugreport.recoveryinstructions3\")\n\t\t\t\t\t+ \"


\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.detailstitle\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.detailsnote\") + \"

\");\n\t\t\tout.println(\"

\");\n\t\t\tout.println(FormattedText.escapeHtml(problem, false));\n\t\t\tout.println();\n\t\t\tout.println(rb.getString(\"bugreport.user\") + \": \"\n\t\t\t\t\t+ FormattedText.escapeHtml(userId, false) + \"\\n\");\n\t\t\tout.println(rb.getString(\"bugreport.usagesession\") + \": \"\n\t\t\t\t\t+ FormattedText.escapeHtml(usageSessionId, false) + \"\\n\");\n\t\t\tout.println(rb.getString(\"bugreport.time\") + \": \"\n\t\t\t\t\t+ FormattedText.escapeHtml(time, false) + \"\\n\");\n\t\t\tout.println(\"

\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tlogAndMail(usageSessionId, userId, time, problem, problemdigest, requestURI,\n\t\t\t\t\trequestDisplay, placementDisplay, null);\n\t\t}\n\t\tcatch (Throwable any)\n\t\t{\n\t\t\tM_log.warn(rb.getString(\"bugreport.troublereporting\"), any);\n\t\t}\n\t}\n", "output": "\tpublic void report(HttpServletRequest req, HttpServletResponse res, Throwable t)\n\t{\n\t\tString headInclude = (String) req.getAttribute(\"sakai.html.head\");\n\t\tString bodyOnload = (String) req.getAttribute(\"sakai.html.body.onload\");\n\t\tTime reportTime = TimeService.newTime();\n\t\tString time = reportTime.toStringLocalDate() + \" \"\n\t\t\t\t+ reportTime.toStringLocalTime24();\n\t\tString usageSessionId = UsageSessionService.getSessionId();\n\t\tString userId = SessionManager.getCurrentSessionUserId();\n\t\tString requestDisplay = requestDisplay(req);\n\t\tString placementDisplay = placementDisplay();\n\t\tString problem = throwableDisplay(t);\n\t\tString problemdigest = computeSha1(problem);\n\t\tString postAddr = ServerConfigurationService.getPortalUrl() + \"/error-report\";\n\t\tString requestURI = req.getRequestURI();\n\t\tif (bodyOnload == null)\n\t\t{\n\t\t\tbodyOnload = \"\";\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbodyOnload = \" onload=\\\"\" + bodyOnload + \"\\\"\";\n\t\t}\n\t\ttry\n\t\t{\n\t\t\tres.setContentType(\"text/html; charset=UTF-8\");\n\t\t\tres.addDateHeader(\"Expires\", System.currentTimeMillis()\n\t\t\t\t\t- (1000L * 60L * 60L * 24L * 365L));\n\t\t\tres.addDateHeader(\"Last-Modified\", System.currentTimeMillis());\n\t\t\tres\n\t\t\t\t\t.addHeader(\"Cache-Control\",\n\t\t\t\t\t\t\t\"no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0\");\n\t\t\tres.addHeader(\"Pragma\", \"no-cache\");\n\t\t\tPrintWriter out = null;\n\t\t\ttry {\n\t\t\t\tout = res.getWriter();\n\t\t\t} catch (Exception ex ) {\n\t\t\t\tout = new PrintWriter(res.getOutputStream());\n\t\t\t}\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tif (headInclude != null)\n\t\t\t{\n\t\t\t\tout.println(\"\");\n\t\t\t\tout.println(headInclude);\n\t\t\t\tout.println(\"\");\n\t\t\t}\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.error\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.statement\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.sendtitle\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.sendinstructions\") + \"

\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout\n\t\t\t\t\t.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"
\");\n\t\t\tout.println(\"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.recoverytitle\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.recoveryinstructions\") + \"\");\n\t\t\tout.println(\"

  • \" + rb.getString(\"bugreport.recoveryinstructions1\")\n\t\t\t\t\t+ \"
  • \");\n\t\t\tout.println(\"
  • \" + rb.getString(\"bugreport.recoveryinstructions2\")\n\t\t\t\t\t+ \"
  • \");\n\t\t\tout.println(\"
  • \" + rb.getString(\"bugreport.recoveryinstructions3\")\n\t\t\t\t\t+ \"


\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.detailstitle\") + \"

\");\n\t\t\tout.println(\"

\" + rb.getString(\"bugreport.detailsnote\") + \"

\");\n\t\t\tout.println(\"

\");\n\t\t\tout.println(FormattedText.escapeHtml(problem, false));\n\t\t\tout.println();\n\t\t\tout.println(rb.getString(\"bugreport.user\") + \": \"\n\t\t\t\t\t+ FormattedText.escapeHtml(userId, false) + \"\\n\");\n\t\t\tout.println(rb.getString(\"bugreport.usagesession\") + \": \"\n\t\t\t\t\t+ FormattedText.escapeHtml(usageSessionId, false) + \"\\n\");\n\t\t\tout.println(rb.getString(\"bugreport.time\") + \": \"\n\t\t\t\t\t+ FormattedText.escapeHtml(time, false) + \"\\n\");\n\t\t\tout.println(\"

\");\n\t\t\tout.println(\"\");\n\t\t\tout.println(\"\");\n\t\t\tlogAndMail(usageSessionId, userId, time, problem, problemdigest, requestURI,\n\t\t\t\t\trequestDisplay, placementDisplay, null);\n\t\t}\n\t\tcatch (Throwable any)\n\t\t{\n\t\t\tM_log.warn(rb.getString(\"bugreport.troublereporting\"), any);\n\t\t}\n\t}\n"} {"input": "\tpublic void loadDatabase() {\n\t\tString DBType = getConfig().getString(\"database.type\");\n\t\tStatement stmt;\n\t\ttry {\n\t\t\tif(DBType.equalsIgnoreCase(\"mysql\")) {\n\t\t \tconn = DatabaseSettings.getConnection(this);\n\t\t \tstmt = conn.createStatement();\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"MySQL/blocklog_blocks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"MySQL/blocklog_rollbacks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"MySQL/blocklog_interactions.sql\"));\n\t\t\t} else if(DBType.equalsIgnoreCase(\"sqlite\")) {\n\t\t\t conn = DatabaseSettings.getConnection(this);\n\t\t\t stmt = conn.createStatement();\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"SQLite/blocklog_blocks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"SQLite/blocklog_rollbacks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"SQLite/blocklog_interactions.sql\"));\n\t\t }\n\t\t} catch (SQLException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\ttry { \n\t\t\tif(DBType.equalsIgnoreCase(\"mysql\")) {\n\t\t \tconn = DatabaseSettings.getConnection(this);\n\t\t \tstmt = conn.createStatement();\n\t\t \tstmt.executeUpdate(\"ALTER TABLE `blocklog_blocks` ADD `datavalue` INT(11) NOT NULL AFTER `block_id`\");\n\t\t\t} else if(DBType.equalsIgnoreCase(\"sqlite\")) {\n\t\t\t conn = DatabaseSettings.getConnection(this);\n\t\t\t stmt = conn.createStatement();\n\t\t\t stmt.executeUpdate(\"ALTER TABLE 'blocklog_blocks' ADD 'datavalue' INTEGER NOT NULL AFTER 'block_id'\");\n\t\t }\n\t\t} catch (SQLException e) {\n\t\t}\n\t}\n", "output": "\tpublic void loadDatabase() {\n\t\tString DBType = getConfig().getString(\"database.type\");\n\t\tStatement stmt;\n\t\ttry {\n\t\t\tif(DBType.equalsIgnoreCase(\"mysql\")) {\n\t\t \tconn = DatabaseSettings.getConnection(this);\n\t\t \tstmt = conn.createStatement();\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"MySQL/blocklog_blocks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"MySQL/blocklog_rollbacks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"MySQL/blocklog_interactions.sql\"));\n\t\t\t} else if(DBType.equalsIgnoreCase(\"sqlite\")) {\n\t\t\t conn = DatabaseSettings.getConnection(this);\n\t\t\t stmt = conn.createStatement();\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"SQLite/blocklog_blocks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"SQLite/blocklog_rollbacks.sql\"));\n\t\t\t\tstmt.executeUpdate(getResourceContent(\"SQLite/blocklog_interactions.sql\"));\n\t\t }\n\t\t} catch (SQLException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\ttry { \n\t\t\tif(DBType.equalsIgnoreCase(\"mysql\")) {\n\t\t \tconn = DatabaseSettings.getConnection(this);\n\t\t \tstmt = conn.createStatement();\n\t\t \tstmt.executeUpdate(\"ALTER TABLE `blocklog_blocks` ADD `datavalue` INT(11) NOT NULL AFTER `block_id`\");\n\t\t\t} else if(DBType.equalsIgnoreCase(\"sqlite\")) {\n\t\t\t conn = DatabaseSettings.getConnection(this);\n\t\t\t stmt = conn.createStatement();\n\t\t\t stmt.executeUpdate(\"ALTER TABLE 'blocklog_blocks' ADD COLUMN 'datavalue' INTEGER NOT NULL DEFAULT '0'\");\n\t\t }\n\t\t} catch (SQLException e) {\n\t\t}\n\t}\n"} {"input": "\tprotected void execute()\n\t{\n\t\tThread.currentThread().setName(getClass().getSimpleName() + \"@\" + mNode);\n\t\tLogging.warn(this, \"Main loop started\");\t\t\n\t\tmHRMTestAppRunning = true;\n\t\ttry {\n\t\t\tThread.sleep(10000);\n\t\t} catch (InterruptedException tExc) {\n\t\t}\n\t\twhile((mHRMTestAppNeeded) & (!GLOBAL_ERROR)){\n\t\t\tmSource.clear();\n\t\t\tmDestination.clear();\n\t\t\tmDataRates.clear();\n\t\t\tint tSourceNodeNumber = 0;\n\t\t\tint tDestinationNodeNumber = 0;\n\t\t\tfor(int i = 0; i < NUMBER_NODE_COMBINATIONS; i++){\n\t\t\t\ttSourceNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\tLogging.warn(this, \"Selected source node: \" + tSourceNodeNumber);\n\t\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\tLogging.warn(this, \"Selected destination node: \" + tDestinationNodeNumber);\n\t\t\t\twhile(tSourceNodeNumber == tDestinationNodeNumber){\n\t\t\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\t\tLogging.warn(this, \"Selected destination node: \" + tDestinationNodeNumber);\n\t\t\t\t}\n\t\t\t\tmSource.add(mGlobalNodeList.get(tSourceNodeNumber));\n\t\t\t\tmDestination.add(mGlobalNodeList.get(tDestinationNodeNumber));\n\t\t\t\tmDataRates.add((int)(mRandom.nextFloat() * MAX_DATA_RATE_PER_CONNECTION));\n\t\t\t}\n\t\t\ttSourceNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\tLogging.warn(this, \"Selected REF destination node: \" + tDestinationNodeNumber);\n\t\t\twhile(tSourceNodeNumber == tDestinationNodeNumber){\n\t\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\tLogging.warn(this, \"Selected REF destination node: \" + tDestinationNodeNumber);\n\t\t\t}\n\t\t\tmRefSource = mGlobalNodeList.get(tSourceNodeNumber);\n\t\t\tmRefDestination = mGlobalNodeList.get(tDestinationNodeNumber);\n\t\t\tLogging.warn(this, \"########## Creating QoS connections now...\");\n\t\t\tHRMController.ENFORCE_BE_ROUTING = false;\n\t\t\tcreateConnections();\n\t\t\tLogging.warn(this, \"########## Waiting for QoS connections now...\");\n\t\t\ttry {\n\t\t\t\tThread.sleep(2000);\n\t\t\t} catch (InterruptedException tExc) {\n\t\t\t}\n\t\t\tint tHRMConnectionsWithFulfilledQoS = countConnectionsWithFulfilledQoS();\n\t\t\tLinkedList tStoredUtilBasedOnHRM = new LinkedList();\n\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\tBus tBus = mGlobalBusList.get(i);\n\t\t\t\tLogging.warn(this, tBus + \" (HRM)=> \" + tBus.getUtilization());\n\t\t\t\ttStoredUtilBasedOnHRM.add(tBus.getUtilization());\n\t\t\t}\n\t\t\tLogging.warn(this, \"########## Destroying QoS connections now...\");\n\t\t\tresetAllConnetions();\n\t\t\tif(!GLOBAL_ERROR){\n\t\t\t\tLogging.warn(this, \"########## Creating BE connections now...\");\n\t\t\t\tHRMController.ENFORCE_BE_ROUTING = true;\n\t\t\t\tcreateConnections();\n\t\t\t\tLogging.warn(this, \"########## Waiting for BE connections now...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(2000);\n\t\t\t\t} catch (InterruptedException tExc) {\n\t\t\t\t}\n\t\t\t\tint tBEConnectionsWithFulfilledQoS = countConnectionsWithFulfilledQoS();\n\t\t\t\tLinkedList tStoredUtilBasedOnBE = new LinkedList();\n\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\tBus tBus = mGlobalBusList.get(i);\n\t\t\t\t\tLogging.warn(this, tBus + \" (BE)=> \" + tBus.getUtilization());\n\t\t\t\t\ttStoredUtilBasedOnBE.add(tBus.getUtilization());\n\t\t\t\t}\n\t\t\t\tLogging.warn(this, \" ..HRM connections with fulfilled QoS: \" + tHRMConnectionsWithFulfilledQoS);\n\t\t\t\tLogging.warn(this, \" ..BE connections with fulfilled QoS: \" + tBEConnectionsWithFulfilledQoS);\n\t\t\t\tLogging.warn(this, \" ..HRM REF connections with fulfilled QoS: \" + mRefHRMConnections);\n\t\t\t\tLogging.warn(this, \" ..BE REF connections with fulfilled QoS: \" + mRefBEConnections);\n\t\t\t\tif(mTurn == 1){\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmStatistic = Statistic.getInstance(mLocalNodeAS.getSimulation(), HRMTestApp.class, \";\", false);\n\t\t\t\t\t} catch (Exception tExc) {\n\t\t\t\t\t\tLogging.err(this, \"Can not write statistic log file\", tExc);\n\t\t\t\t\t}\n\t\t\t\t\tif(mStatistic != null){\n\t\t\t\t\t\tRuntime.getRuntime().addShutdownHook(new Thread() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void run()\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tLogging.getInstance().warn(this, \"Closing HRMController statistics log file\");\n\t\t\t\t\t\t\t\tmStatistic.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tLinkedList tTableHeader = new LinkedList();\n\t\t\t\t\ttTableHeader.add(\"Turn\");\n\t\t\t\t\ttTableHeader.add(\"Good HRM routing\");\n\t\t\t\t\ttTableHeader.add(\"Good BE routing\");\n\t\t\t\t\ttTableHeader.add(\"-\");\n\t\t\t\t\ttTableHeader.add(\"Ref source\");\n\t\t\t\t\ttTableHeader.add(\"Ref destination\");\n\t\t\t\t\ttTableHeader.add(\"Good HRM Ref routing\");\n\t\t\t\t\ttTableHeader.add(\"Good BE Ref routing\");\n\t\t\t\t\ttTableHeader.add(\"-\");\n\t\t\t\t\ttTableHeader.add(\"BusCounter\");\n\t\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\t\ttTableHeader.add(\"HRM_\" + mGlobalBusList.get(i).getName());\n\t\t\t\t\t}\n\t\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\t\ttTableHeader.add(\"BE_\" + mGlobalBusList.get(i).getName());\n\t\t\t\t\t}\n\t\t\t\t\tif(mStatistic != null){\n\t\t\t\t\t\tmStatistic.log(tTableHeader);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tLinkedList tTableRow = new LinkedList();\n\t\t\t\ttTableRow.add(Integer.toString(mTurn));\n\t\t\t\ttTableRow.add(Integer.toString(tHRMConnectionsWithFulfilledQoS));\n\t\t\t\ttTableRow.add(Integer.toString(tBEConnectionsWithFulfilledQoS));\n\t\t\t\ttTableRow.add(\"-\");\n\t\t\t\ttTableRow.add(mRefSource.toString());\n\t\t\t\ttTableRow.add(mRefDestination.toString());\n\t\t\t\ttTableRow.add(Integer.toString(mRefHRMConnections));\n\t\t\t\ttTableRow.add(Integer.toString(mRefBEConnections));\n\t\t\t\ttTableRow.add(\"-\");\n\t\t\t\ttTableRow.add(Integer.toString(mCntBuss));\n\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\tDecimalFormat tFormat = new DecimalFormat(\"0.#\");\n\t\t\t\t\tString tUtilizationStr = tFormat.format(tStoredUtilBasedOnHRM.get(i));\n\t\t\t\t\ttTableRow.add(tUtilizationStr);\n\t\t\t\t}\t\t\t\n\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\tDecimalFormat tFormat = new DecimalFormat(\"0.#\");\n\t\t\t\t\tString tUtilizationStr = tFormat.format(tStoredUtilBasedOnBE.get(i));\n\t\t\t\t\ttTableRow.add(tUtilizationStr);\n\t\t\t\t}\n\t\t\t\tif(mStatistic != null){\n\t\t\t\t\tmStatistic.log(tTableRow);\n\t\t\t\t\tLogging.log(this, \">>>>>>>>>> Writing statistics to file..\");\n\t\t\t\t\tmStatistic.flush();\n\t\t\t\t}\n\t\t\t}\n\t\t\tLogging.warn(this, \"########## Destroying BE connections now...\");\n\t\t\tresetAllConnetions();\n\t\t\tmTurn++;\n\t\t\tif(mTurn >= NUMBER_MEASUREMENT_TURNS){\n\t\t\t\tLogging.warn(this, \"########## END OF MEASUREMENTS #########\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(GLOBAL_ERROR){\n\t\t\t\tLogging.err(this, \"########## GLOBAL ERROR - END OF MEASUREMENTS #########\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tLogging.log(this, \"Main loop finished\");\n\t\tmHRMTestAppRunning = false;\n\t}\n", "output": "\tprotected void execute()\n\t{\n\t\tThread.currentThread().setName(getClass().getSimpleName() + \"@\" + mNode);\n\t\tLogging.warn(this, \"Main loop started\");\t\t\n\t\tmHRMTestAppRunning = true;\n\t\ttry {\n\t\t\tThread.sleep(10000);\n\t\t} catch (InterruptedException tExc) {\n\t\t}\n\t\twhile((mHRMTestAppNeeded) & (!GLOBAL_ERROR)){\n\t\t\tmSource.clear();\n\t\t\tmDestination.clear();\n\t\t\tmDataRates.clear();\n\t\t\tint tSourceNodeNumber = 0;\n\t\t\tint tDestinationNodeNumber = 0;\n\t\t\tfor(int i = 0; i < NUMBER_NODE_COMBINATIONS; i++){\n\t\t\t\ttSourceNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\tLogging.warn(this, \"Selected source node: \" + tSourceNodeNumber);\n\t\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\tLogging.warn(this, \"Selected destination node: \" + tDestinationNodeNumber);\n\t\t\t\twhile(tSourceNodeNumber == tDestinationNodeNumber){\n\t\t\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\t\tLogging.warn(this, \"Selected destination node: \" + tDestinationNodeNumber);\n\t\t\t\t}\n\t\t\t\tmSource.add(mGlobalNodeList.get(tSourceNodeNumber));\n\t\t\t\tmDestination.add(mGlobalNodeList.get(tDestinationNodeNumber));\n\t\t\t\tmDataRates.add((int)(mRandom.nextFloat() * MAX_DATA_RATE_PER_CONNECTION));\n\t\t\t}\n\t\t\ttSourceNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\tLogging.warn(this, \"Selected REF destination node: \" + tDestinationNodeNumber);\n\t\t\twhile(tSourceNodeNumber == tDestinationNodeNumber){\n\t\t\t\ttDestinationNodeNumber = (int)(mRandom.nextFloat() * mCntNodes);\n\t\t\t\tLogging.warn(this, \"Selected REF destination node: \" + tDestinationNodeNumber);\n\t\t\t}\n\t\t\tmRefSource = mGlobalNodeList.get(tSourceNodeNumber);\n\t\t\tmRefDestination = mGlobalNodeList.get(tDestinationNodeNumber);\n\t\t\tLogging.warn(this, \"########## Creating QoS connections now...\");\n\t\t\tHRMController.ENFORCE_BE_ROUTING = false;\n\t\t\tcreateConnections();\n\t\t\tLogging.warn(this, \"########## Waiting for QoS connections now...\");\n\t\t\ttry {\n\t\t\t\tThread.sleep(2000);\n\t\t\t} catch (InterruptedException tExc) {\n\t\t\t}\n\t\t\tint tHRMConnectionsWithFulfilledQoS = countConnectionsWithFulfilledQoS();\n\t\t\tLinkedList tStoredUtilBasedOnHRM = new LinkedList();\n\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\tBus tBus = mGlobalBusList.get(i);\n\t\t\t\tLogging.warn(this, tBus + \" (HRM)=> \" + tBus.getUtilization());\n\t\t\t\ttStoredUtilBasedOnHRM.add(tBus.getUtilization());\n\t\t\t}\n\t\t\tLogging.warn(this, \"########## Destroying QoS connections now...\");\n\t\t\tresetAllConnetions();\n\t\t\tif(!GLOBAL_ERROR){\n\t\t\t\tLogging.warn(this, \"########## Creating BE connections now...\");\n\t\t\t\tHRMController.ENFORCE_BE_ROUTING = true;\n\t\t\t\tcreateConnections();\n\t\t\t\tLogging.warn(this, \"########## Waiting for BE connections now...\");\n\t\t\t\ttry {\n\t\t\t\t\tThread.sleep(2000);\n\t\t\t\t} catch (InterruptedException tExc) {\n\t\t\t\t}\n\t\t\t\tint tBEConnectionsWithFulfilledQoS = countConnectionsWithFulfilledQoS();\n\t\t\t\tLinkedList tStoredUtilBasedOnBE = new LinkedList();\n\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\tBus tBus = mGlobalBusList.get(i);\n\t\t\t\t\tLogging.warn(this, tBus + \" (BE)=> \" + tBus.getUtilization());\n\t\t\t\t\ttStoredUtilBasedOnBE.add(tBus.getUtilization());\n\t\t\t\t}\n\t\t\t\tLogging.warn(this, \" ..HRM connections with fulfilled QoS: \" + tHRMConnectionsWithFulfilledQoS);\n\t\t\t\tLogging.warn(this, \" ..BE connections with fulfilled QoS: \" + tBEConnectionsWithFulfilledQoS);\n\t\t\t\tLogging.warn(this, \" ..HRM REF connections with fulfilled QoS: \" + mRefHRMConnections);\n\t\t\t\tLogging.warn(this, \" ..BE REF connections with fulfilled QoS: \" + mRefBEConnections);\n\t\t\t\tif(mTurn == 1){\n\t\t\t\t\ttry {\n\t\t\t\t\t\tmStatistic = Statistic.getInstance(mLocalNodeAS.getSimulation(), HRMTestApp.class, \";\", false);\n\t\t\t\t\t} catch (Exception tExc) {\n\t\t\t\t\t\tLogging.err(this, \"Can not write statistic log file\", tExc);\n\t\t\t\t\t}\n\t\t\t\t\tif(mStatistic != null){\n\t\t\t\t\t\tRuntime.getRuntime().addShutdownHook(new Thread() {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void run()\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tLogging.getInstance().warn(this, \"Closing HRMController statistics log file\");\n\t\t\t\t\t\t\t\tmStatistic.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tLinkedList tTableHeader = new LinkedList();\n\t\t\t\t\ttTableHeader.add(\"Turn\");\n\t\t\t\t\ttTableHeader.add(\"Good HRM routing\");\n\t\t\t\t\ttTableHeader.add(\"Good BE routing\");\n\t\t\t\t\ttTableHeader.add(\"-\");\n\t\t\t\t\ttTableHeader.add(\"Ref source\");\n\t\t\t\t\ttTableHeader.add(\"Ref destination\");\n\t\t\t\t\ttTableHeader.add(\"Good HRM Ref routing\");\n\t\t\t\t\ttTableHeader.add(\"Good BE Ref routing\");\n\t\t\t\t\ttTableHeader.add(\"-\");\n\t\t\t\t\ttTableHeader.add(\"BusCounter\");\n\t\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\t\ttTableHeader.add(\"HRM_\" + mGlobalBusList.get(i).getName());\n\t\t\t\t\t}\n\t\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\t\ttTableHeader.add(\"BE_\" + mGlobalBusList.get(i).getName());\n\t\t\t\t\t}\n\t\t\t\t\tif(mStatistic != null){\n\t\t\t\t\t\tmStatistic.log(tTableHeader);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tLinkedList tTableRow = new LinkedList();\n\t\t\t\ttTableRow.add(Integer.toString(mTurn));\n\t\t\t\ttTableRow.add(Integer.toString(tHRMConnectionsWithFulfilledQoS));\n\t\t\t\ttTableRow.add(Integer.toString(tBEConnectionsWithFulfilledQoS));\n\t\t\t\ttTableRow.add(\"-\");\n\t\t\t\ttTableRow.add(mRefSource.toString());\n\t\t\t\ttTableRow.add(mRefDestination.toString());\n\t\t\t\ttTableRow.add(Integer.toString(mRefHRMConnections));\n\t\t\t\ttTableRow.add(Integer.toString(mRefBEConnections));\n\t\t\t\ttTableRow.add(\"-\");\n\t\t\t\ttTableRow.add(Integer.toString(mCntBuss));\n\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\tDecimalFormat tFormat = new DecimalFormat(\"0.#\");\n\t\t\t\t\tString tUtilizationStr = tFormat.format(tStoredUtilBasedOnHRM.get(i));\n\t\t\t\t\ttTableRow.add(tUtilizationStr);\n\t\t\t\t}\t\t\t\n\t\t\t\tfor(int i = 0; i < mCntBuss; i++){\n\t\t\t\t\tDecimalFormat tFormat = new DecimalFormat(\"0.#\");\n\t\t\t\t\tString tUtilizationStr = tFormat.format(tStoredUtilBasedOnBE.get(i));\n\t\t\t\t\ttTableRow.add(tUtilizationStr);\n\t\t\t\t}\n\t\t\t\tif(mStatistic != null){\n\t\t\t\t\tmStatistic.log(tTableRow);\n\t\t\t\t\tLogging.log(this, \">>>>>>>>>> Writing statistics to file..\");\n\t\t\t\t\tmStatistic.flush();\n\t\t\t\t}\n\t\t\t}\n\t\t\tLogging.warn(this, \"########## Destroying BE connections now...\");\n\t\t\tresetAllConnetions();\n\t\t\tmTurn++;\n\t\t\tif(mTurn > NUMBER_MEASUREMENT_TURNS){\n\t\t\t\tLogging.warn(this, \"########## END OF MEASUREMENTS #########\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(GLOBAL_ERROR){\n\t\t\t\tLogging.err(this, \"########## GLOBAL ERROR - END OF MEASUREMENTS #########\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tLogging.log(this, \"Main loop finished\");\n\t\tmHRMTestAppRunning = false;\n\t}\n"} {"input": " private void readEntry(int ent) {\n try {\n int te = entry[ent] * 4;\n System.out.println(\"Entry 0 = \"+te);\n byte[] gridHeader = new byte[256];\n fn.seek(te);\n fn.readFully(gridHeader);\n McIDASGridDirectory mgd = new McIDASGridDirectory(gridHeader);\n System.out.println(\"grid header =\"+mgd.toString());\n CoordinateSystem c = mgd.getCoordinateSystem();\n int rows = mgd.getRows();\n int cols = mgd.getColumns();\n System.out.println(\"# rows & cols = \"+rows+\" \"+cols);\n double scale = mgd.getParamScale();\n System.out.println(\"param scale = \"+scale+\" gridType=\"+mgd.getGridType());\n double[] data = new double[rows*cols];\n int n = 0;\n for (int nc=0; nc= 0; i--) {\n\t\t\tsb.append(addr[i] & 0xFF);\n\t\t\tif (i > 0)\n\t\t\t\tsb.append(\".\");\n\t\t}\n\t} else {\n\t\tint [] nibbles = new int[2];\n\t\tfor (int i = addr.length - 1; i >= 0; i--) {\n\t\t\tnibbles[0] = (addr[i] & 0xFF) >> 4;\n\t\t\tnibbles[1] = (addr[i] & 0xFF) & 0xF;\n\t\t\tfor (int j = nibbles.length - 1; j >= 0; j--) {\n\t\t\t\tsb.append(nibbles[j]);\n\t\t\t\tif (i > 0 || j > 0)\n\t\t\t\t\tsb.append(\".\");\n\t\t\t}\n\t\t}\n\t}\n\ttry {\n\t\treturn Name.fromString(sb.toString(), inaddr4);\n\t}\n\tcatch (TextParseException e) {\n\t\tthrow new IllegalStateException(\"name cannot be invalid\");\n\t}\n}\n", "output": "public static Name\nfromAddress(byte [] addr) {\n\tif (addr.length != 4 && addr.length != 16)\n\t\tthrow new IllegalArgumentException(\"array must contain \" +\n\t\t\t\t\t\t \"4 or 16 elements\");\n\tStringBuffer sb = new StringBuffer();\n\tif (addr.length == 4) {\n\t\tfor (int i = addr.length - 1; i >= 0; i--) {\n\t\t\tsb.append(addr[i] & 0xFF);\n\t\t\tif (i > 0)\n\t\t\t\tsb.append(\".\");\n\t\t}\n\t} else {\n\t\tint [] nibbles = new int[2];\n\t\tfor (int i = addr.length - 1; i >= 0; i--) {\n\t\t\tnibbles[0] = (addr[i] & 0xFF) >> 4;\n\t\t\tnibbles[1] = (addr[i] & 0xFF) & 0xF;\n\t\t\tfor (int j = nibbles.length - 1; j >= 0; j--) {\n\t\t\t\tsb.append(Integer.toHexString(nibbles[j]));\n\t\t\t\tif (i > 0 || j > 0)\n\t\t\t\t\tsb.append(\".\");\n\t\t\t}\n\t\t}\n\t}\n\ttry {\n\t\tif (addr.length == 4)\n\t\t\treturn Name.fromString(sb.toString(), inaddr4);\n\t\telse\n\t\t\treturn Name.fromString(sb.toString(), inaddr6);\n\t}\n\tcatch (TextParseException e) {\n\t\tthrow new IllegalStateException(\"name cannot be invalid\");\n\t}\n}\n"} {"input": "\tpublic boolean isDateValid(int year, int month, int day, int hour, int minute)\n\t{\n\t\tif(hour == 0)\n\t\t\thour = 24;\n\t\telse if(hour == 24)\n\t\t\thour = 0;\n\t\tString date = String.valueOf(year)+\"-\"+String.valueOf(month)+\"-\"+String.valueOf(day)+\"-\"+String.valueOf(hour)+\"-\"+String.valueOf(minute);\n\t\tSystem.out.println(\"input: \"+date);\n\t\tString DATE_FORMAT = \"yyyy-MM-dd-kk-mm\";\n\t try {\n\t DateFormat df = new SimpleDateFormat(DATE_FORMAT);\n\t df.setLenient(false);\n\t Date d = df.parse(date);\n\t System.out.println(\"interpreted as: \" + df.format(d));\n\t return true;\n\t } catch (ParseException e) {\n\t \tSystem.out.println(\"INVALID DATE! hilsen TimeService\");\n\t return false;\n\t }\n\t}\n", "output": "\tpublic boolean isDateValid(int year, int month, int day, int hour, int minute)\n\t{\n\t\tif(hour == 0)\n\t\t\thour = 24;\n\t\telse if(hour == 24)\n\t\t\treturn false;\n\t\tString date = String.valueOf(year)+\"-\"+String.valueOf(month)+\"-\"+String.valueOf(day)+\"-\"+String.valueOf(hour)+\"-\"+String.valueOf(minute);\n\t\tSystem.out.println(\"input: \"+date);\n\t\tString DATE_FORMAT = \"yyyy-MM-dd-kk-mm\";\n\t try {\n\t DateFormat df = new SimpleDateFormat(DATE_FORMAT);\n\t df.setLenient(false);\n\t Date d = df.parse(date);\n\t System.out.println(\"interpreted as: \" + df.format(d));\n\t return true;\n\t } catch (ParseException e) {\n\t \tSystem.out.println(\"INVALID DATE! hilsen TimeService\");\n\t return false;\n\t }\n\t}\n"} {"input": "\tpublic boolean onKey(View v, int keycode, KeyEvent event) {\n\t\tif (keycode == KeyEvent.KEYCODE_ENTER && event.getAction()==KeyEvent.ACTION_UP) {\n\t\t\ttabCompletingInProgress=false;\n\t\t\trunOnUiThread(messageSender);\n\t\t\treturn true;\n\t\t} else if((keycode == KeyEvent.KEYCODE_TAB || keycode == KeyEvent.KEYCODE_SEARCH) && event.getAction() == KeyEvent.ACTION_DOWN) {\n\t\t\tif (!enableTabComplete || nickCache == null) return true;\n\t\t\tString txt = inputBox.getText().toString();\n\t\t\tif (tabCompletingInProgress == false) {\n\t\t\t\tint currentPos = inputBox.getSelectionStart()-1;\n\t\t\t\tint start = currentPos;\n\t\t\t\twhile(start>0 && txt.charAt(start) != ' ') start--;\n\t\t\t\tif (start>0) start++;\n\t\t\t\tString prefix = txt.substring(start, currentPos+1).toLowerCase();\n\t\t\t\tif (prefix.length()<2) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tVector matches = new Vector();\n\t\t\t\tfor(String possible: nickCache) {\n\t\t\t\t\tString temp = possible.toLowerCase().trim();\n\t\t\t\t\tif (temp.startsWith(prefix)) {\n\t\t\t\t\t\tmatches.add(possible.trim());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (matches.size() == 0) return true;\n\t\t\t\ttabCompletingInProgress = true;\n\t\t\t\ttabCompleteMatches = matches;\n\t\t\t\ttabCompleteCurrentIndex = 0;\n\t\t\t\ttabCompleteWordStart = start;\n\t\t\t\ttabCompleteWordEnd = currentPos;\n\t\t\t} else {\n\t\t\t\ttabCompleteWordEnd = tabCompleteWordStart + tabCompleteMatches.get(tabCompleteCurrentIndex).length()-1; \n\t\t\t\ttabCompleteCurrentIndex = (tabCompleteCurrentIndex+1)%tabCompleteMatches.size(); \n\t\t\t}\n\t\t\tString newtext = txt.substring(0, tabCompleteWordStart) + tabCompleteMatches.get(tabCompleteCurrentIndex) + txt.substring(tabCompleteWordEnd+1);\n\t\t\ttabCompleteWordEnd = tabCompleteWordStart + tabCompleteMatches.get(tabCompleteCurrentIndex).length(); \n\t\t\tinputBox.setText(newtext);\n\t\t\tinputBox.setSelection(tabCompleteWordEnd);\n\t\t\treturn true;\n\t\t} else if(KeyEvent.isModifierKey(keycode) || keycode == KeyEvent.KEYCODE_TAB || keycode == KeyEvent.KEYCODE_SEARCH) {\n\t\t\treturn true;\n\t\t}\n\t\ttabCompletingInProgress = false;\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean onKey(View v, int keycode, KeyEvent event) {\n\t\tif (keycode == KeyEvent.KEYCODE_ENTER && event.getAction()==KeyEvent.ACTION_UP) {\n\t\t\ttabCompletingInProgress=false;\n\t\t\trunOnUiThread(messageSender);\n\t\t\treturn true;\n\t\t} else if((keycode == KeyEvent.KEYCODE_TAB || keycode == KeyEvent.KEYCODE_SEARCH) && event.getAction() == KeyEvent.ACTION_DOWN) {\n\t\t\tif (!enableTabComplete || nickCache == null) return true;\n\t\t\tString txt = inputBox.getText().toString();\n\t\t\tif (tabCompletingInProgress == false) {\n\t\t\t\tint currentPos = inputBox.getSelectionStart()-1;\n\t\t\t\tint start = currentPos;\n\t\t\t\twhile(start>0 && txt.charAt(start) != ' ') start--;\n\t\t\t\tif (start>0) start++;\n\t\t\t\tString prefix = txt.substring(start, currentPos+1).toLowerCase();\n\t\t\t\tif (prefix.length()<2) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tVector matches = new Vector();\n\t\t\t\tfor(String possible: nickCache) {\n\t\t\t\t\tString temp = possible.toLowerCase().trim();\n\t\t\t\t\tif (temp.startsWith(prefix)) {\n\t\t\t\t\t\tmatches.add(possible.trim());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (matches.size() == 0) return true;\n\t\t\t\ttabCompletingInProgress = true;\n\t\t\t\ttabCompleteMatches = matches;\n\t\t\t\ttabCompleteCurrentIndex = 0;\n\t\t\t\ttabCompleteWordStart = start;\n\t\t\t\ttabCompleteWordEnd = currentPos;\n\t\t\t} else {\n\t\t\t\ttabCompleteWordEnd = tabCompleteWordStart + tabCompleteMatches.get(tabCompleteCurrentIndex).length()-1; \n\t\t\t\ttabCompleteCurrentIndex = (tabCompleteCurrentIndex+1)%tabCompleteMatches.size(); \n\t\t\t}\n\t\t\tString newtext = txt.substring(0, tabCompleteWordStart) + tabCompleteMatches.get(tabCompleteCurrentIndex) + txt.substring(tabCompleteWordEnd+1);\n\t\t\ttabCompleteWordEnd = tabCompleteWordStart + tabCompleteMatches.get(tabCompleteCurrentIndex).length(); \n\t\t\tinputBox.setText(newtext);\n\t\t\tinputBox.setSelection(tabCompleteWordEnd);\n\t\t\treturn true;\n\t\t} else if(KeyEvent.isModifierKey(keycode) || keycode == KeyEvent.KEYCODE_TAB || keycode == KeyEvent.KEYCODE_SEARCH) {\n\t\t\treturn false;\n\t\t}\n\t\ttabCompletingInProgress = false;\n\t\treturn false;\n\t}\n"} {"input": "\tprivate static IJavaSourceLocation getArchiveSourceLocation(IRuntimeClasspathEntry entry) {\n\t\tIResource resource = entry.getResource();\n\t\tif (resource == null) { \n\t\t\tIJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());\n\t\t\ttry {\n\t\t\t\tIJavaProject[] jps = model.getJavaProjects();\n\t\t\t\tfor (int i = 0; i < jps.length; i++) {\n\t\t\t\t\tIPackageFragmentRoot[] allRoots = jps[i].getPackageFragmentRoots();\n\t\t\t\t\tfor (int j = 0; j < allRoots.length; j++) {\n\t\t\t\t\t\tIPackageFragmentRoot root = allRoots[j];\n\t\t\t\t\t\tif (root.isExternal() && root.getPath().equals(new Path(entry.getLocation()))) {\n\t\t\t\t\t\t\tif (isSourceAttachmentEqual(root, entry)) {\n\t\t\t\t\t\t\t\treturn new PackageFragmentRootSourceLocation(root);\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tLaunchingPlugin.log(e);\n\t\t\t}\n\t\t} else {\n\t\t\tIProject project = resource.getProject();\n\t\t\tIJavaProject jp = JavaCore.create(project);\n\t\t\ttry {\n\t\t\t\tif (jp.exists()) {\n\t\t\t\t\tIPackageFragmentRoot root = jp.getPackageFragmentRoot(resource);\n\t\t\t\t\tIPackageFragmentRoot[] allRoots = jp.getPackageFragmentRoots();\n\t\t\t\t\tfor (int j = 0; j < allRoots.length; j++) {\n\t\t\t\t\t\tif (allRoots[j].equals(root)) {\n\t\t\t\t\t\t\tif (isSourceAttachmentEqual(root, entry)) {\n\t\t\t\t\t\t\t\treturn new PackageFragmentRootSourceLocation(root);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tIJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());\n\t\t\t\tIJavaProject[] jps = model.getJavaProjects();\n\t\t\t\tfor (int i = 0; i < jps.length; i++) {\n\t\t\t\t\tIPackageFragmentRoot[] allRoots = jps[i].getPackageFragmentRoots();\n\t\t\t\t\tfor (int j = 0; j < allRoots.length; j++) {\n\t\t\t\t\t\tIPackageFragmentRoot root = allRoots[j];\n\t\t\t\t\t\tif (!root.isExternal() && root.getPath().equals(entry.getPath())) {\n\t\t\t\t\t\t\tif (isSourceAttachmentEqual(root, entry)) {\n\t\t\t\t\t\t\t\treturn new PackageFragmentRootSourceLocation(root);\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tLaunchingPlugin.log(e);\n\t\t\t}\t\t\n\t\t}\t\t\n\t\treturn null;\n\t}\n", "output": "\tprivate static IJavaSourceLocation getArchiveSourceLocation(IRuntimeClasspathEntry entry) {\n\t\tIResource resource = entry.getResource();\n\t\tif (resource == null) { \n\t\t\tIJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());\n\t\t\ttry {\n\t\t\t\tIJavaProject[] jps = model.getJavaProjects();\n\t\t\t\tfor (int i = 0; i < jps.length; i++) {\n\t\t\t\t\tIPackageFragmentRoot[] allRoots = jps[i].getPackageFragmentRoots();\n\t\t\t\t\tfor (int j = 0; j < allRoots.length; j++) {\n\t\t\t\t\t\tIPackageFragmentRoot root = allRoots[j];\n\t\t\t\t\t\tif (root.isExternal() && root.getPath().equals(new Path(entry.getLocation()))) {\n\t\t\t\t\t\t\tif (isSourceAttachmentEqual(root, entry)) {\n\t\t\t\t\t\t\t\treturn new PackageFragmentRootSourceLocation(root);\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tLaunchingPlugin.log(e);\n\t\t\t}\n\t\t} else {\n\t\t\tIProject project = resource.getProject();\n\t\t\tIJavaProject jp = JavaCore.create(project);\n\t\t\ttry {\n\t\t\t\tif (jp != null && jp.exists()) {\n\t\t\t\t\tIPackageFragmentRoot root = jp.getPackageFragmentRoot(resource);\n\t\t\t\t\tIPackageFragmentRoot[] allRoots = jp.getPackageFragmentRoots();\n\t\t\t\t\tfor (int j = 0; j < allRoots.length; j++) {\n\t\t\t\t\t\tif (allRoots[j].equals(root)) {\n\t\t\t\t\t\t\tif (isSourceAttachmentEqual(root, entry)) {\n\t\t\t\t\t\t\t\treturn new PackageFragmentRootSourceLocation(root);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tIJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());\n\t\t\t\tIJavaProject[] jps = model.getJavaProjects();\n\t\t\t\tfor (int i = 0; i < jps.length; i++) {\n\t\t\t\t\tIPackageFragmentRoot[] allRoots = jps[i].getPackageFragmentRoots();\n\t\t\t\t\tfor (int j = 0; j < allRoots.length; j++) {\n\t\t\t\t\t\tIPackageFragmentRoot root = allRoots[j];\n\t\t\t\t\t\tif (!root.isExternal() && root.getPath().equals(entry.getPath())) {\n\t\t\t\t\t\t\tif (isSourceAttachmentEqual(root, entry)) {\n\t\t\t\t\t\t\t\treturn new PackageFragmentRootSourceLocation(root);\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (JavaModelException e) {\n\t\t\t\tLaunchingPlugin.log(e);\n\t\t\t}\t\t\n\t\t}\t\t\n\t\treturn null;\n\t}\n"} {"input": "\tpublic void testLoadSettings() throws IOException, JDOMException{\n\t\tProperties settingsProps = SettingsLoader.loadSettingsFile();\n\t\tassertNotNull(settingsProps);\n\t\tassertNotNull(settingsProps.get(\"org.sagebionetworks.stack.configuration.url\"));\n\t\tassertNotNull(settingsProps.get(\"org.sagebionetworks.stackEncryptionKey\"));\n\t}\n", "output": "\tpublic void testLoadSettings() throws IOException, JDOMException{\n\t\tProperties settingsProps = SettingsLoader.loadSettingsFile();\n\t\tassertNotNull(settingsProps);\n\t}\n"} {"input": " protected void getRssDocument(final String uri)\n throws Exception {\n if (log.isDebugEnabled())\n log.debug(\"Starting getRssDocument()\");\n RssCacheDao dao = new RssCacheDao();\n RssCacheTo rss;\n InputStreamReader ir;\n StringBuffer sbx = new StringBuffer();\n BufferedReader buff;\n final java.util.GregorianCalendar calendarg = new java.util.GregorianCalendar();\n rss = dao.view(uri);\n if (rss != null && rss.getUri() != null && rss.getUri().length() > 10) {\n if (log.isDebugEnabled())\n log.debug(\"Record found with uri: \" + uri);\n DateTimeBean dt = rss.getLastUpdated();\n if (dt.getDay() != calendarg.get(java.util.Calendar.DATE)) {\n if (log.isDebugEnabled())\n log.debug(\"getRssDocument() Day doesn't match: \" + uri);\n u = new URL(uri);\n ir = new InputStreamReader(u.openStream(), \"UTF-8\");\n buff = new BufferedReader(ir);\n String input;\n while ((input = buff.readLine()) != null) {\n sbx.append(StringUtil.replace(input, '\\'', \"\\\\\\'\"));\n }\n buff.close();\n rss.setContent(sbx.toString());\n dao.update(rss);\n } else {\n if (log.isDebugEnabled())\n log.debug(\"Hit end.. no date change.\");\n }\n } else {\n if (log.isDebugEnabled())\n log.debug(\"Fetch uri: \" + uri);\n rss = new RssCacheTo();\n u = new URL(uri);\n ir = new InputStreamReader(u.openStream(), \"UTF-8\");\n buff = new BufferedReader(ir);\n String input;\n while ((input = buff.readLine()) != null) {\n sbx.append(StringUtil.replace(input, '\\'', \"\\\\\\'\"));\n }\n buff.close();\n log.debug(sbx.toString());\n try {\n rss.setUri(uri);\n rss.setInterval(24);\n rss.setContent(sbx.toString());\n dao.add(rss);\n } catch (java.lang.NullPointerException n) {\n if (log.isDebugEnabled())\n log.debug(\"Null pointer exception creating/adding rss cache object to db.\");\n }\n }\n if (log.isDebugEnabled())\n log.debug(\"getRssDocument() Retrieved uri from database: \" + uri);\n log.debug(sbx.toString());\n StringReader sr = new StringReader(rss.getContent());\n org.xml.sax.InputSource saxy = new org.xml.sax.InputSource(sr);\n builder = factory.newDocumentBuilder();\n document = builder.parse(saxy);\n if (log.isDebugEnabled())\n log.debug(\"Hit end of getRssDocument() for \" + uri);\n }\n", "output": " protected void getRssDocument(final String uri)\n throws Exception {\n if (log.isDebugEnabled())\n log.debug(\"Starting getRssDocument()\");\n RssCacheDao dao = new RssCacheDao();\n RssCacheTo rss;\n InputStreamReader ir;\n StringBuffer sbx = new StringBuffer();\n BufferedReader buff;\n final java.util.GregorianCalendar calendarg = new java.util.GregorianCalendar();\n rss = dao.view(uri);\n if (rss != null && rss.getUri() != null && rss.getUri().length() > 10) {\n if (log.isDebugEnabled())\n log.debug(\"Record found with uri: \" + uri);\n DateTimeBean dt = rss.getLastUpdated();\n if (dt.getDay() != calendarg.get(java.util.Calendar.DATE)) {\n if (log.isDebugEnabled())\n log.debug(\"getRssDocument() Day doesn't match: \" + uri);\n u = new URL(uri);\n ir = new InputStreamReader(u.openStream(), \"UTF-8\");\n buff = new BufferedReader(ir);\n String input;\n while ((input = buff.readLine()) != null) {\n sbx.append(StringUtil.replace(input, '\\'', \"\\\\\\'\"));\n }\n buff.close();\n rss.setContent(sbx.toString().trim());\n if (rss.getContent().startsWith(\"\\n\");\n dao.update(rss);\n } else {\n if (log.isDebugEnabled())\n log.debug(\"Hit end.. no date change.\");\n }\n } else {\n if (log.isDebugEnabled())\n log.debug(\"Fetch uri: \" + uri);\n rss = new RssCacheTo();\n u = new URL(uri);\n ir = new InputStreamReader(u.openStream(), \"UTF-8\");\n buff = new BufferedReader(ir);\n String input;\n while ((input = buff.readLine()) != null) {\n sbx.append(StringUtil.replace(input, '\\'', \"\\\\\\'\"));\n }\n buff.close();\n log.debug(sbx.toString());\n try {\n rss.setUri(uri);\n rss.setInterval(24);\n rss.setContent(sbx.toString().trim());\n if (rss.getContent().startsWith(\"\\n\");\n dao.add(rss);\n } catch (java.lang.NullPointerException n) {\n if (log.isDebugEnabled())\n log.debug(\"Null pointer exception creating/adding rss cache object to db.\");\n }\n }\n if (log.isDebugEnabled())\n log.debug(\"getRssDocument() Retrieved uri from database: \" + uri);\n log.debug(sbx.toString());\n StringReader sr = new StringReader(rss.getContent());\n org.xml.sax.InputSource saxy = new org.xml.sax.InputSource(sr);\n builder = factory.newDocumentBuilder();\n document = builder.parse(saxy);\n if (log.isDebugEnabled())\n log.debug(\"Hit end of getRssDocument() for \" + uri);\n }\n"} {"input": "\tpublic static String format(Object o, String format) {\n\t\tif (o == null) { return \"\"; }\n\t\tif (o instanceof Date) {\n\t\t\tDateFormat df = decode(format, Context.getDateFormat(), new SimpleDateFormat(format));\n\t\t\treturn df.format((Date)o);\n\t\t}\n\t\tif (o instanceof Map) {\n\t\t\treturn toString((Map)o, nvl(format, \",\"));\n\t\t}\n\t\tif (o instanceof Collection) {\n\t\t\treturn OpenmrsUtil.join((Collection)o, nvl(format, \",\"));\n\t\t}\n\t\tif (o instanceof Object[]) {\n\t\t\treturn toString(nvl(format, \",\"), (Object[])o);\n\t\t}\n\t\tif (o instanceof Number) {\n\t\t\tif (notNull(format)) {\n\t\t\t\tNumberFormat nf = NumberFormat.getInstance();\n\t\t\t\tnf.setGroupingUsed(false);\n\t\t\t\treturn nf.format((Number)o);\n\t\t\t}\n\t\t}\n\t\tif (o instanceof OpenmrsMetadata) {\n\t\t\tString name = ((OpenmrsMetadata) o).getName();\n\t\t\tif (name == null) {\n\t\t\t\tif (o instanceof ProgramWorkflow) {\n\t\t\t\t\tname = ((ProgramWorkflow)o).getConcept().getDisplayString();\n\t\t\t\t}\n\t\t\t\telse if (o instanceof ProgramWorkflowState) {\n\t\t\t\t\tname = ((ProgramWorkflowState)o).getConcept().getDisplayString();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn name;\n\t\t}\n\t\tif (o instanceof OpenmrsData) {\n\t\t\tif (ObjectUtil.notNull(format)) {\n\t\t\t\tString[] formatSplit = format.split(\"\\\\|\");\n\t\t\t\tString ret = formatSplit[0];\n\t\t\t\ttry {\n\t\t\t\t\tint startIndex = ret.indexOf(\"{\");\n\t\t\t\t\tint endIndex = ret.indexOf(\"}\", startIndex+1);\n\t\t\t\t\twhile (startIndex != -1 && endIndex != -1) {\n\t\t\t\t\t\tString propertyName = format.substring(startIndex+1, endIndex);\n\t\t\t\t\t\tObject replacement = ReflectionUtil.getPropertyValue(o, propertyName);\n\t\t\t\t\t\tString newFormat = (replacement != null && formatSplit.length > 1 ? formatSplit[1] : null);\n\t\t\t\t\t\treplacement = ObjectUtil.format(replacement, newFormat);\n\t\t\t\t\t\tret = ret.replace(\"{\"+propertyName+\"}\", nvlStr(replacement, \"\"));\n\t\t\t\t\t\tstartIndex = ret.indexOf(\"{\");\n\t\t\t\t\t\tendIndex = ret.indexOf(\"}\", startIndex+1);\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tlog.warn(\"Unable to get property using converter with format: \" + format, e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn o.toString();\n\t}\n", "output": "\tpublic static String format(Object o, String format) {\n\t\tif (o == null) { return \"\"; }\n\t\tif (o instanceof Date) {\n\t\t\tDateFormat df = decode(format, Context.getDateFormat(), new SimpleDateFormat(format));\n\t\t\treturn df.format((Date)o);\n\t\t}\n\t\tif (o instanceof Map) {\n\t\t\treturn toString((Map)o, nvl(format, \",\"));\n\t\t}\n\t\tif (o instanceof Collection) {\n\t\t\treturn OpenmrsUtil.join((Collection)o, nvl(format, \",\"));\n\t\t}\n\t\tif (o instanceof Object[]) {\n\t\t\treturn toString(nvl(format, \",\"), (Object[])o);\n\t\t}\n\t\tif (o instanceof Number) {\n\t\t\tif (notNull(format)) {\n\t\t\t\tNumberFormat nf = NumberFormat.getInstance();\n\t\t\t\tnf.setGroupingUsed(false);\n\t\t\t\treturn nf.format((Number)o);\n\t\t\t}\n\t\t}\n\t\tif (o instanceof OpenmrsMetadata) {\n\t\t\tString name = ((OpenmrsMetadata) o).getName();\n\t\t\tif (name == null) {\n\t\t\t\tif (o instanceof ProgramWorkflow) {\n\t\t\t\t\tname = ((ProgramWorkflow)o).getConcept().getDisplayString();\n\t\t\t\t}\n\t\t\t\telse if (o instanceof ProgramWorkflowState) {\n\t\t\t\t\tname = ((ProgramWorkflowState)o).getConcept().getDisplayString();\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn name;\n\t\t}\n\t\tif (o instanceof OpenmrsData) {\n\t\t\tif (ObjectUtil.notNull(format)) {\n\t\t\t\tString[] formatSplit = format.split(\"\\\\|\");\n\t\t\t\tString ret = formatSplit[0];\n\t\t\t\ttry {\n\t\t\t\t\tint startIndex = ret.indexOf(\"{\");\n\t\t\t\t\tint endIndex = ret.indexOf(\"}\", startIndex+1);\n\t\t\t\t\twhile (startIndex != -1 && endIndex != -1) {\n\t\t\t\t\t\tString propertyName = ret.substring(startIndex+1, endIndex);\n\t\t\t\t\t\tObject replacement = ReflectionUtil.getPropertyValue(o, propertyName);\n\t\t\t\t\t\tString newFormat = (replacement != null && formatSplit.length > 1 ? formatSplit[1] : null);\n\t\t\t\t\t\treplacement = ObjectUtil.format(replacement, newFormat);\n\t\t\t\t\t\tret = ret.replace(\"{\"+propertyName+\"}\", nvlStr(replacement, \"\"));\n\t\t\t\t\t\tstartIndex = ret.indexOf(\"{\");\n\t\t\t\t\t\tendIndex = ret.indexOf(\"}\", startIndex+1);\n\t\t\t\t\t}\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t\tcatch (Exception e) {\n\t\t\t\t\tlog.warn(\"Unable to get property using converter with format: \" + format, e);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn o.toString();\n\t}\n"} {"input": "\tpublic boolean answer()\n\t{\n\t\t_console.println(FormattedConsole.OutputLevel.HEADING, \"----\" + _id + \"----\");\n\t\tList loadList = getLoadModuleList();\n\t\tfor (Directive directive : loadList)\n\t\t{\n\t\t\tString[] arguments = directive.getValue().trim().split(\"( |\\t)*\");\n\t\t\tif(arguments == null || arguments.length < 2)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(arguments[0].equals(\"security2_module\"))\n\t\t\t{\n\t\t\t\tDirective modSec = directive;\n\t\t\t\t_console.printAnswer(_level, true, \"ModSecurity is being loaded:\");\n\t\t\t\t_console.println(_level, modSec.getLinenumber() + \": \" + modSec.getName() + \" \" + modSec.getValue());\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tString[] modList = getCompiledIntoModulesList();\n\t\tfor (String str : modList)\n\t\t{\n\t\t\tif(str.matches(\"( |\\t)*mod_security.c\"))\n\t\t\t{\n\t\t\t\t_console.printAnswer(_level, true, \"ModSecurity is compiled into the httpd binary.\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t_console.printAnswer(_level, false, \"ModSecurity seems not to be loaded.\");\n\t\treturn false;\n\t}\n", "output": "\tpublic boolean answer()\n\t{\n\t\t_console.println(FormattedConsole.OutputLevel.HEADING, \"----\" + _id + \"----\");\n\t\tList loadList = getLoadModuleList();\n\t\tfor (Directive directive : loadList)\n\t\t{\n\t\t\tString[] arguments = directive.getValue().trim().split(\"[ \\t]+\");\n\t\t\tif(arguments == null || arguments.length < 2)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(arguments[0].equals(\"security2_module\"))\n\t\t\t{\n\t\t\t\tDirective modSec = directive;\n\t\t\t\t_console.printAnswer(_level, true, \"ModSecurity is being loaded:\");\n\t\t\t\t_console.println(_level, modSec.getLinenumber() + \": \" + modSec.getName() + \" \" + modSec.getValue());\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tString[] modList = getCompiledIntoModulesList();\n\t\tfor (String str : modList)\n\t\t{\n\t\t\tif(str.matches(\"( |\\t)*mod_security.c\"))\n\t\t\t{\n\t\t\t\t_console.printAnswer(_level, true, \"ModSecurity is compiled into the httpd binary.\");\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t_console.printAnswer(_level, false, \"ModSecurity seems not to be loaded.\");\n\t\treturn false;\n\t}\n"} {"input": "\tpublic void addDeclareAnnotationRelationship(ISourceLocation sourceLocation, String typename,Method method) {\n\t if (!AsmManager.isCreatingModel()) return;\n\t String pkg = null;\n\t String type = typename;\n\t int packageSeparator = typename.lastIndexOf(\".\");\n\t if (packageSeparator!=-1) {\n\t \tpkg = typename.substring(0,packageSeparator);\n\t \ttype = typename.substring(packageSeparator+1);\n\t }\n\t IProgramElement typeElem = AsmManager.getDefault().getHierarchy().findElementForType(pkg,type);\n\t if (typeElem == null) return;\n\t StringBuffer parmString = new StringBuffer(\"(\");\n\t Type[] args = method.getArgumentTypes();\n\t for (int i = 0; i < args.length; i++) {\n\t\t\tType type2 = args[i];\n\t\t\tString s = Utility.signatureToString(type2.getSignature());\n\t\t\tif (s.lastIndexOf(\".\")!=-1) s =s.substring(s.lastIndexOf(\".\")+1);\n\t\t\tparmString.append(s);\n\t\t\tif ((i+1)\")) {\n\t \tmethodElem = AsmManager.getDefault().getHierarchy().findElementForSignature(typeElem,IProgramElement.Kind.CONSTRUCTOR,type+parmString);\n\t } else {\n\t \tmethodElem = AsmManager.getDefault().getHierarchy().findElementForSignature(typeElem,IProgramElement.Kind.METHOD,method.getName()+parmString);\n\t }\n\t if (methodElem == null) return;\n\t try {\n\t String sourceHandle = \n AsmManager.getDefault().getHandleProvider().createHandleIdentifier(sourceLocation.getSourceFile(),sourceLocation.getLine(),\n\t\t \tsourceLocation.getColumn(),sourceLocation.getOffset());\n\t String targetHandle = methodElem.getHandleIdentifier();\n\t IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();\n\t\tif (sourceHandle != null && targetHandle != null) {\n\t\t\t\tIRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);\n\t\t\t\tforeward.addTarget(targetHandle);\n\t\t\t\tIRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);\n\t\t\t\tback.addTarget(sourceHandle);\n\t\t}\n } catch (Throwable t) { \n t.printStackTrace(); \n }\n\t}\n", "output": "\tpublic void addDeclareAnnotationRelationship(ISourceLocation sourceLocation, String typename,Method method) {\n\t if (!AsmManager.isCreatingModel()) return;\n\t String pkg = null;\n\t String type = typename;\n\t int packageSeparator = typename.lastIndexOf(\".\");\n\t if (packageSeparator!=-1) {\n\t \tpkg = typename.substring(0,packageSeparator);\n\t \ttype = typename.substring(packageSeparator+1);\n\t }\n\t IProgramElement typeElem = AsmManager.getDefault().getHierarchy().findElementForType(pkg,type);\n\t if (typeElem == null) return;\n\t StringBuffer parmString = new StringBuffer(\"(\");\n\t Type[] args = method.getArgumentTypes();\n\t for (int i = 0; i < args.length; i++) {\n\t\t\tType type2 = args[i];\n\t\t\tString s = Utility.signatureToString(type2.getSignature());\n\t\t\tif (s.lastIndexOf(\".\")!=-1) s =s.substring(s.lastIndexOf(\".\")+1);\n\t\t\tparmString.append(s);\n\t\t\tif ((i+1)\")) {\n\t \tmethodElem = AsmManager.getDefault().getHierarchy().findElementForSignature(typeElem,IProgramElement.Kind.CONSTRUCTOR,type+parmString);\n\t\tif (methodElem == null && args.length==0) methodElem = typeElem; \n\t } else {\n\t \tmethodElem = AsmManager.getDefault().getHierarchy().findElementForSignature(typeElem,IProgramElement.Kind.METHOD,method.getName()+parmString);\n\t }\n\t if (methodElem == null) return;\n\t try {\n\t String sourceHandle = \n AsmManager.getDefault().getHandleProvider().createHandleIdentifier(sourceLocation.getSourceFile(),sourceLocation.getLine(),\n\t\t \tsourceLocation.getColumn(),sourceLocation.getOffset());\n\t String targetHandle = methodElem.getHandleIdentifier();\n\t IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();\n\t\tif (sourceHandle != null && targetHandle != null) {\n\t\t\t\tIRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATES,false,true);\n\t\t\t\tforeward.addTarget(targetHandle);\n\t\t\t\tIRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, ANNOTATED_BY,false,true);\n\t\t\t\tback.addTarget(sourceHandle);\n\t\t}\n } catch (Throwable t) { \n t.printStackTrace(); \n }\n\t}\n"} {"input": " public SlippyMapChooserWindow(BBoxLatLonPanel bboxlatlonpanel, TileProviderIf tileProvider, String tileDirectory)\n {\n super(\"Slippy Map Chooser\");\n setSize(400, 400);\n map = new SlippyMapChooser(bboxlatlonpanel, tileProvider, tileDirectory);\n setLayout(new BorderLayout());\n setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);\n add(map, BorderLayout.CENTER);\n }\n", "output": " public SlippyMapChooserWindow(BBoxLatLonPanel bboxlatlonpanel, TileProviderIf tileProvider, String tileDirectory)\n {\n super(\"Slippy Map Chooser\");\n setSize(400, 400);\n map = new SlippyMapChooser(bboxlatlonpanel, tileDirectory, tileProvider);\n setLayout(new BorderLayout());\n setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);\n add(map, BorderLayout.CENTER);\n }\n"} {"input": " public OpenJPAEntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo pui, Map m) {\n PersistenceProductDerivation pd = new PersistenceProductDerivation();\n try {\n Object poolValue = Configurations.removeProperty(EMF_POOL, m);\n ConfigurationProvider cp = pd.load(pui, m);\n if (cp == null)\n return null;\n Exception transformerException = null;\n String ctOpts = (String) Configurations.getProperty(CLASS_TRANSFORMER_OPTIONS, pui.getProperties());\n try {\n pui.addTransformer(new ClassTransformerImpl(cp, ctOpts,\n pui.getNewTempClassLoader(), newConfigurationImpl()));\n } catch (Exception e) {\n transformerException = e;\n }\n if (!Configurations.containsProperty(BrokerValue.KEY, cp.getProperties())) {\n cp.addProperty(\"openjpa.\" + BrokerValue.KEY, getDefaultBrokerAlias());\n }\n BrokerFactory factory = getBrokerFactory(cp, poolValue, pui.getClassLoader());\n if (transformerException != null) {\n Log log = factory.getConfiguration().getLog(OpenJPAConfiguration.LOG_RUNTIME);\n if (log.isTraceEnabled()) {\n log.warn(_loc.get(\"transformer-registration-error-ex\", pui), transformerException);\n } else {\n log.warn(_loc.get(\"transformer-registration-error\", pui));\n }\n }\n OpenJPAConfiguration conf = factory.getConfiguration();\n _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);\n loadValidator(_log, conf);\n Options o = Configurations.parseProperties(Configurations.getProperties(\"openjpa.MetaDataRepository\"));\n if(o.getBooleanProperty(\"Preload\")){\n conf.getAbstractBrokerFactoryInstance().preload();\n }\n return JPAFacadeHelper.toEntityManagerFactory(factory);\n } catch (Exception e) {\n throw PersistenceExceptions.toPersistenceException(e);\n }\n }\n", "output": " public OpenJPAEntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo pui, Map m) {\n PersistenceProductDerivation pd = new PersistenceProductDerivation();\n try {\n Object poolValue = Configurations.removeProperty(EMF_POOL, m);\n ConfigurationProvider cp = pd.load(pui, m);\n if (cp == null)\n return null;\n Exception transformerException = null;\n String ctOpts = (String) Configurations.getProperty(CLASS_TRANSFORMER_OPTIONS, pui.getProperties());\n try {\n pui.addTransformer(new ClassTransformerImpl(cp, ctOpts,\n pui.getNewTempClassLoader(), newConfigurationImpl()));\n } catch (Exception e) {\n transformerException = e;\n }\n if (!Configurations.containsProperty(BrokerValue.KEY, cp.getProperties())) {\n cp.addProperty(\"openjpa.\" + BrokerValue.KEY, getDefaultBrokerAlias());\n }\n BrokerFactory factory = getBrokerFactory(cp, poolValue, pui.getClassLoader());\n if (transformerException != null) {\n Log log = factory.getConfiguration().getLog(OpenJPAConfiguration.LOG_RUNTIME);\n if (log.isTraceEnabled()) {\n log.warn(_loc.get(\"transformer-registration-error-ex\", pui), transformerException);\n } else {\n log.warn(_loc.get(\"transformer-registration-error\", pui));\n }\n }\n OpenJPAConfiguration conf = factory.getConfiguration();\n _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);\n loadValidator(_log, conf);\n Options o = Configurations.parseProperties(Configurations.getProperties(\"openjpa.MetaDataRepository\"));\n if(o.getBooleanProperty(\"Preload\")){\n conf.getMetaDataRepositoryInstance().preload();\n }\n return JPAFacadeHelper.toEntityManagerFactory(factory);\n } catch (Exception e) {\n throw PersistenceExceptions.toPersistenceException(e);\n }\n }\n"} {"input": " private String processRequest(String requestJson) throws IOException {\n checkNotNull(requestJson);\n this.nodeStdin.println(requestJson);\n String resultJson = null;\n do {\n String line = this.nodeStdout.readLine();\n if (line.startsWith(\"DEBUG\")) {\n System.out.println(line);\n } else if (line.startsWith(\"ERROR\")) {\n line = line.substring(7, line.length()); \n line = line.replaceAll(\"\\\\\\\\n\", \"\\n\"); \n line = line.replaceAll(\" \", \"\\t\"); \n throw new RuntimeException(\"The following request caused an error to be thrown:\" + LINE_SEPARATOR\n + requestJson + LINE_SEPARATOR\n + line);\n } else {\n resultJson = line;\n }\n } while (resultJson == null);\n return resultJson;\n }\n", "output": " private String processRequest(String requestJson) throws IOException {\n checkNotNull(requestJson);\n this.nodeStdin.println(requestJson);\n String resultJson = null;\n do {\n String line = this.nodeStdout.readLine();\n if (line.startsWith(\"DEBUG\")) {\n System.out.println(line);\n } else if (line.startsWith(\"ERROR\")) {\n line = line.substring(7, line.length()); \n line = line.replaceAll(\"\\\\\\\\n\", LINE_SEPARATOR); \n line = line.replaceAll(\" \", \"\\t\"); \n throw new RuntimeException(\"The following request caused an error to be thrown:\" + LINE_SEPARATOR\n + requestJson + LINE_SEPARATOR\n + line);\n } else {\n resultJson = line;\n }\n } while (resultJson == null);\n return resultJson;\n }\n"} {"input": " public void execute() throws MojoExecutionException, MojoFailureException {\n Embedder embedder = newEmbedder();\n getLog().info(\"Running stories using embedder \"+embedder);\n\t\tembedder.runAsEmbeddables(classNames());\n }\n", "output": " public void execute() throws MojoExecutionException, MojoFailureException {\n Embedder embedder = newEmbedder();\n getLog().info(\"Running stories using embedder \"+embedder);\n try {\n embedder.runAsEmbeddables(classNames());\n } catch( Embedder.RunningEmbeddablesFailed e) {\n throw new MojoFailureException(\"JBehave Story Failures\",e);\n }\n }\n"} {"input": " public boolean onKeyDown(int keyCode, KeyEvent event) {\n boolean handled = false;\n if (!isVisible()) {\n return false;\n }\n final int iconCount = mRollo.mState.iconCount;\n if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {\n if (mArrowNavigation) {\n if (mLastSelection == SELECTION_HOME) {\n reallyPlaySoundEffect(SoundEffectConstants.CLICK);\n mLauncher.closeAllApps(true);\n } else {\n int whichApp = mRollo.mState.selectedIconIndex;\n if (whichApp >= 0) {\n ApplicationInfo app = mAllAppsList.get(whichApp);\n mLauncher.startActivitySafely(app.intent);\n handled = true;\n }\n }\n }\n }\n if (iconCount > 0) {\n mArrowNavigation = true;\n int currentSelection = mRollo.mState.selectedIconIndex;\n int currentTopRow = Math.round(mPosX);\n final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE;\n final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE))\n / Defines.ROWS_PER_PAGE;\n int newSelection = currentSelection;\n switch (keyCode) {\n case KeyEvent.KEYCODE_DPAD_UP:\n if (mLastSelection == SELECTION_HOME) {\n mRollo.setHomeSelected(SELECTED_NONE);\n int lastRowCount = iconCount % Defines.COLUMNS_PER_PAGE;\n if (lastRowCount == 0) {\n lastRowCount = Defines.COLUMNS_PER_PAGE;\n }\n newSelection = iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);\n if (newSelection >= iconCount) {\n newSelection = iconCount-1;\n }\n int target = (newSelection / Defines.COLUMNS_PER_PAGE)\n - (Defines.ROWS_PER_PAGE - 1);\n if (target < 0) {\n target = 0;\n }\n if (currentTopRow != target) {\n mRollo.moveTo(target);\n }\n } else {\n if (currentPageRow > 0) {\n newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;\n } else if (currentTopRow > 0) {\n newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;\n mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);\n } else if (currentPageRow != 0) {\n newSelection = currentTopRow * Defines.ROWS_PER_PAGE;\n }\n }\n handled = true;\n break;\n case KeyEvent.KEYCODE_DPAD_DOWN: {\n final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE\n + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);\n final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE;\n if (mLastSelection != SELECTION_HOME) {\n if (currentRow < rowCount-1) {\n mRollo.setHomeSelected(SELECTED_NONE);\n if (currentSelection < 0) {\n newSelection = 0;\n } else {\n newSelection = currentSelection + Defines.COLUMNS_PER_PAGE;\n }\n if (newSelection >= iconCount) {\n newSelection = iconCount - 1;\n }\n if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {\n mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) -\n Defines.ROWS_PER_PAGE + 1);\n }\n } else {\n newSelection = -1;\n mRollo.setHomeSelected(SELECTED_FOCUSED);\n }\n }\n handled = true;\n break;\n }\n case KeyEvent.KEYCODE_DPAD_LEFT:\n if (currentPageCol > 0) {\n newSelection = currentSelection - 1;\n }\n handled = true;\n break;\n case KeyEvent.KEYCODE_DPAD_RIGHT:\n if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) &&\n (currentSelection < iconCount - 1)) {\n newSelection = currentSelection + 1;\n }\n handled = true;\n break;\n }\n if (newSelection != currentSelection) {\n mRollo.selectIcon(newSelection, SELECTED_FOCUSED);\n mRollo.mState.save();\n }\n }\n return handled;\n }\n", "output": " public boolean onKeyDown(int keyCode, KeyEvent event) {\n boolean handled = false;\n if (!isVisible()) {\n return false;\n }\n final int iconCount = mRollo.mState.iconCount;\n if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {\n if (mArrowNavigation) {\n if (mLastSelection == SELECTION_HOME) {\n reallyPlaySoundEffect(SoundEffectConstants.CLICK);\n mLauncher.closeAllApps(true);\n } else {\n int whichApp = mRollo.mState.selectedIconIndex;\n if (whichApp >= 0) {\n ApplicationInfo app = mAllAppsList.get(whichApp);\n mLauncher.startActivitySafely(app.intent);\n handled = true;\n }\n }\n }\n }\n if (iconCount > 0) {\n mArrowNavigation = true;\n int currentSelection = mRollo.mState.selectedIconIndex;\n int currentTopRow = Math.round(mPosX);\n final int currentPageCol = currentSelection % Defines.COLUMNS_PER_PAGE;\n final int currentPageRow = (currentSelection - (currentTopRow*Defines.COLUMNS_PER_PAGE))\n / Defines.ROWS_PER_PAGE;\n int newSelection = currentSelection;\n switch (keyCode) {\n case KeyEvent.KEYCODE_DPAD_UP:\n if (mLastSelection == SELECTION_HOME) {\n mRollo.setHomeSelected(SELECTED_NONE);\n int lastRowCount = iconCount % Defines.COLUMNS_PER_PAGE;\n if (lastRowCount == 0) {\n lastRowCount = Defines.COLUMNS_PER_PAGE;\n }\n newSelection = iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);\n if (newSelection >= iconCount) {\n newSelection = iconCount-1;\n }\n int target = (newSelection / Defines.COLUMNS_PER_PAGE)\n - (Defines.ROWS_PER_PAGE - 1);\n if (target < 0) {\n target = 0;\n }\n if (currentTopRow != target) {\n mRollo.moveTo(target);\n }\n } else {\n if (currentPageRow > 0) {\n newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;\n } else if (currentTopRow > 0) {\n newSelection = currentSelection - Defines.COLUMNS_PER_PAGE;\n mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);\n } else if (currentPageRow != 0) {\n newSelection = currentTopRow * Defines.ROWS_PER_PAGE;\n }\n }\n handled = true;\n break;\n case KeyEvent.KEYCODE_DPAD_DOWN: {\n final int rowCount = iconCount / Defines.COLUMNS_PER_PAGE\n + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);\n final int currentRow = currentSelection / Defines.COLUMNS_PER_PAGE;\n if (mLastSelection != SELECTION_HOME) {\n if (currentRow < rowCount-1) {\n mRollo.setHomeSelected(SELECTED_NONE);\n if (currentSelection < 0) {\n newSelection = 0;\n } else {\n newSelection = currentSelection + Defines.COLUMNS_PER_PAGE;\n }\n if (newSelection >= iconCount) {\n newSelection = iconCount - 1;\n }\n if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {\n mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) -\n Defines.ROWS_PER_PAGE + 1);\n }\n } else {\n newSelection = -1;\n mRollo.setHomeSelected(SELECTED_FOCUSED);\n }\n }\n handled = true;\n break;\n }\n case KeyEvent.KEYCODE_DPAD_LEFT:\n if (mLastSelection != SELECTION_HOME) {\n if (currentPageCol > 0) {\n newSelection = currentSelection - 1;\n }\n }\n handled = true;\n break;\n case KeyEvent.KEYCODE_DPAD_RIGHT:\n if (mLastSelection != SELECTION_HOME) {\n if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) &&\n (currentSelection < iconCount - 1)) {\n newSelection = currentSelection + 1;\n }\n }\n handled = true;\n break;\n }\n if (newSelection != currentSelection) {\n mRollo.selectIcon(newSelection, SELECTED_FOCUSED);\n mRollo.mState.save();\n }\n }\n return handled;\n }\n"} {"input": "\tpublic Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {\n\t\tSimpleDateFormat format = new SimpleDateFormat(\"dd/MM/yyyy\");\n\t\tString date = jp.getText();\n\t\ttry {\n\t\t\treturn format.parse(date);\n\t\t} catch (ParseException e) {\n\t\t\tlogger.error(\"Failed to parse date json string value with format: dd/MM/yyyy.\");\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n", "output": "\tpublic Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {\n\t\tSimpleDateFormat format = new SimpleDateFormat(\"MM/dd/yyyy\");\n\t\tString date = jp.getText();\n\t\ttry {\n\t\t\treturn format.parse(date);\n\t\t} catch (ParseException e) {\n\t\t\tlogger.error(\"Failed to parse date json string value with format: MM/dd/yyyy.\");\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t}\n"} {"input": " public Map getNotificationsFor(final @RequestParam(value = \"uuid\", required = true) String uuid,\n final @RequestParam(value = \"sender\", required = true) boolean sender,\n final @RequestParam(value = \"search\") String search,\n final @RequestParam(value = \"pageNumber\") Integer pageNumber,\n final @RequestParam(value = \"pageSize\") Integer pageSize) {\n Map response = new HashMap();\n Person person = Context.getPersonService().getPersonByUuid(uuid);\n DataService service = Context.getService(DataService.class);\n Integer pages;\n List notificationDataList;\n if (sender) {\n pages = (service.countNotificationDataBySender(person, search) + pageSize - 1) / pageSize;\n notificationDataList = service.getNotificationDataBySender(person, search, pageNumber, pageSize);\n } else {\n pages = (service.countNotificationDataByReceiver(person, search) + pageSize - 1) / pageSize;\n notificationDataList = service.getNotificationDataByReceiver(person, search, pageNumber, pageSize);\n }\n List objects = new ArrayList();\n for (NotificationData notificationData : notificationDataList) {\n objects.add(NotificationDataConverter.convert(notificationData));\n }\n response.put(\"pages\", pages);\n response.put(\"objects\", objects);\n return response;\n }\n", "output": " public Map getNotificationsFor(final @RequestParam(value = \"uuid\", required = true) String uuid,\n final @RequestParam(value = \"sender\", required = true) boolean sender,\n final @RequestParam(value = \"search\") String search,\n final @RequestParam(value = \"pageNumber\") Integer pageNumber,\n final @RequestParam(value = \"pageSize\") Integer pageSize) {\n Map response = new HashMap();\n Person person = Context.getPersonService().getPersonByUuid(uuid);\n DataService service = Context.getService(DataService.class);\n Integer pages;\n List notificationDataList;\n if (sender) {\n pages = (service.countNotificationDataBySender(person, search).intValue() + pageSize - 1) / pageSize;\n notificationDataList = service.getNotificationDataBySender(person, search, pageNumber, pageSize);\n } else {\n pages = (service.countNotificationDataByReceiver(person, search).intValue() + pageSize - 1) / pageSize;\n notificationDataList = service.getNotificationDataByReceiver(person, search, pageNumber, pageSize);\n }\n List objects = new ArrayList();\n for (NotificationData notificationData : notificationDataList) {\n objects.add(NotificationDataConverter.convert(notificationData));\n }\n response.put(\"pages\", pages);\n response.put(\"objects\", objects);\n return response;\n }\n"} {"input": " public static List validatePaymentString(String paymentString) {\n List errors = new LinkedList();\n if (!paymentString.matches(\"^SPD\\\\*[0-9]+\\\\.[0-9]+\\\\*.*\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_NOT_SPAYD);\n error.setErrorDescription(\"Invalid data prefix - SPD*{$VERSION}* expected.\");\n errors.add(error);\n return errors;\n }\n if (!paymentString.matches(\"^SPD\\\\*[0-9]+\\\\.[0-9]+(\\\\*[0-9A-Z $%*+-.]+:[^\\\\*]+)+\\\\*?$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_STRUCTURE);\n error.setErrorDescription(\"Payment String code didn't pass the basic regexp validation.\");\n errors.add(error);\n return errors;\n }\n List allowedKeyList = Arrays.asList(allowedKeys);\n String[] components = paymentString.split(\"\\\\*\");\n boolean ibanFound = false;\n for (int i = 2; i < components.length; i++) {\n int index = components[i].indexOf(\":\");\n String key = components[i].substring(0, index);\n String value = components[i].substring(index + 1);\n if (!allowedKeyList.contains(key) && !key.startsWith(\"X-\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_KEY_FOUND);\n error.setErrorDescription(\"Unknown key detected. Use 'X-' prefix to create your own key.\");\n errors.add(error);\n continue;\n }\n if (key.equals(\"ACC\")) {\n ibanFound = true;\n if (!value.matches(\"^([A-Z]{2,2}[0-9]+)(\\\\+([A-Z0-9]+))?$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_IBAN);\n error.setErrorDescription(\"IBAN+BIC pair was not in the correct format.\");\n errors.add(error);\n }\n } else if (key.equals(\"ALT-ACC\")) {\n ibanFound = true;\n if (!value.matches(\"^([A-Z]{2,2}[0-9]+)(\\\\+([A-Z0-9]+))?(,([A-Z]{2,2}[0-9]+)(\\\\+([A-Z0-9]+))?)*$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_ALTERNATE_IBAN);\n error.setErrorDescription(\"Alternate accounts are not properly formatted - should be IBAN+BIC list with items separated by ',' character.\");\n errors.add(error);\n }\n } else if (key.equals(\"AM\")) {\n if (!value.matches(\"^[0-9]{0,10}(\\\\.[0-9]{0,2})?$\") || value.equals(\".\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_AMOUNT);\n error.setErrorDescription(\"Amount must be a number with at most 2 decimal digits.\");\n errors.add(error);\n }\n } else if (key.equals(\"CC\")) {\n try {\n Currency.getInstance(value);\n } catch (IllegalArgumentException ex) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_CURRENCY);\n error.setErrorDescription(\"Currency must be a valid currency from ISO 4271.\");\n errors.add(error);\n }\n } else if (key.equals(\"RF\")) {\n if (value.length() > 16 || value.length() < 1 || !value.matches(\"^[0-9]+$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_SENDERS_REFERENCE);\n error.setErrorDescription(\"Senders reference must be a decimal string with length between 1 and 16 characters.\");\n errors.add(error);\n }\n } else if (key.equals(\"RN\")) {\n if (value.length() > 40 || value.length() < 1) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_RECIPIENT_NAME);\n error.setErrorDescription(\"Recipient name must be a string with length between 1 and 40 characters.\");\n errors.add(error);\n }\n } else if (key.equals(\"NT\")) {\n if (!value.equals(\"E\") && !value.equals(\"P\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_NOTIFICATION_TYPE);\n error.setErrorDescription(\"Notification type must be 'E' (e-mail) or 'P' (phone).\");\n errors.add(error);\n }\n } else if (key.equals(\"DT\")) {\n if (!value.matches(\"^[0-9]{8,8}$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_DUE_DATE);\n error.setErrorDescription(\"Due date must be represented as a decimal string in YYYYmmdd format.\");\n errors.add(error);\n } else {\n SimpleDateFormat df = new SimpleDateFormat(\"yyyymmdd\");\n Date date;\n try {\n date = df.parse(value);\n if (date == null) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_DUE_DATE);\n error.setErrorDescription(\"Due date must be represented as a decimal string in YYYYmmdd format.\");\n errors.add(error);\n }\n } catch (ParseException ex) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_DUE_DATE);\n error.setErrorDescription(\"Due date must be represented as a decimal string in YYYYmmdd format.\");\n errors.add(error);\n }\n }\n } else if (key.equals(\"PT\")) {\n if (value.length() > 3 || value.length() < 1) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_PAYMENT_TYPE);\n error.setErrorDescription(\"Payment type must be at represented as a string with length between 1 and 3 characters.\");\n errors.add(error);\n }\n } else if (key.equals(\"MSG\")) {\n if (value.length() > 35 || value.length() < 1) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_MESSAGE);\n error.setErrorDescription(\"Message must be at represented as a string with length between 1 and 35 characters.\");\n errors.add(error);\n }\n }\n }\n if (!ibanFound) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_IBAN_NOT_FOUND);\n error.setErrorDescription(\"You must specify an account number.\");\n errors.add(error);\n }\n return errors.isEmpty() ? null : errors;\n }\n", "output": " public static List validatePaymentString(String paymentString) {\n List errors = new LinkedList();\n if (!paymentString.matches(\"^SPD\\\\*[0-9]+\\\\.[0-9]+\\\\*.*\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_NOT_SPAYD);\n error.setErrorDescription(\"Invalid data prefix - SPD*{$VERSION}* expected.\");\n errors.add(error);\n return errors;\n }\n if (!paymentString.matches(\"^SPD\\\\*[0-9]+\\\\.[0-9]+(\\\\*[0-9A-Z $%*+-.]+:[^\\\\*]+)+\\\\*?$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_STRUCTURE);\n error.setErrorDescription(\"Payment String code didn't pass the basic regexp validation.\");\n errors.add(error);\n return errors;\n }\n List allowedKeyList = Arrays.asList(allowedKeys);\n String[] components = paymentString.split(\"\\\\*\");\n boolean ibanFound = false;\n for (int i = 2; i < components.length; i++) {\n int index = components[i].indexOf(\":\");\n if (index == -1) { \n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_STRUCTURE);\n error.setErrorDescription(\"Payment String code didn't pass the basic regexp validation.\");\n errors.add(error);\n }\n String key = components[i].substring(0, index);\n String value = components[i].substring(index + 1);\n if (!allowedKeyList.contains(key) && !key.startsWith(\"X-\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_KEY_FOUND);\n error.setErrorDescription(\"Unknown key detected. Use 'X-' prefix to create your own key.\");\n errors.add(error);\n continue;\n }\n if (key.equals(\"ACC\")) {\n ibanFound = true;\n if (!value.matches(\"^([A-Z]{2,2}[0-9]+)(\\\\+([A-Z0-9]+))?$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_IBAN);\n error.setErrorDescription(\"IBAN+BIC pair was not in the correct format.\");\n errors.add(error);\n }\n } else if (key.equals(\"ALT-ACC\")) {\n ibanFound = true;\n if (!value.matches(\"^([A-Z]{2,2}[0-9]+)(\\\\+([A-Z0-9]+))?(,([A-Z]{2,2}[0-9]+)(\\\\+([A-Z0-9]+))?)*$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_ALTERNATE_IBAN);\n error.setErrorDescription(\"Alternate accounts are not properly formatted - should be IBAN+BIC list with items separated by ',' character.\");\n errors.add(error);\n }\n } else if (key.equals(\"AM\")) {\n if (!value.matches(\"^[0-9]{0,10}(\\\\.[0-9]{0,2})?$\") || value.equals(\".\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_AMOUNT);\n error.setErrorDescription(\"Amount must be a number with at most 2 decimal digits.\");\n errors.add(error);\n }\n } else if (key.equals(\"CC\")) {\n try {\n Currency.getInstance(value);\n } catch (IllegalArgumentException ex) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_CURRENCY);\n error.setErrorDescription(\"Currency must be a valid currency from ISO 4271.\");\n errors.add(error);\n }\n } else if (key.equals(\"RF\")) {\n if (value.length() > 16 || value.length() < 1 || !value.matches(\"^[0-9]+$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_SENDERS_REFERENCE);\n error.setErrorDescription(\"Senders reference must be a decimal string with length between 1 and 16 characters.\");\n errors.add(error);\n }\n } else if (key.equals(\"RN\")) {\n if (value.length() > 40 || value.length() < 1) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_RECIPIENT_NAME);\n error.setErrorDescription(\"Recipient name must be a string with length between 1 and 40 characters.\");\n errors.add(error);\n }\n } else if (key.equals(\"NT\")) {\n if (!value.equals(\"E\") && !value.equals(\"P\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_NOTIFICATION_TYPE);\n error.setErrorDescription(\"Notification type must be 'E' (e-mail) or 'P' (phone).\");\n errors.add(error);\n }\n } else if (key.equals(\"DT\")) {\n if (!value.matches(\"^[0-9]{8,8}$\")) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_DUE_DATE);\n error.setErrorDescription(\"Due date must be represented as a decimal string in YYYYmmdd format.\");\n errors.add(error);\n } else {\n SimpleDateFormat df = new SimpleDateFormat(\"yyyymmdd\");\n Date date;\n try {\n date = df.parse(value);\n if (date == null) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_DUE_DATE);\n error.setErrorDescription(\"Due date must be represented as a decimal string in YYYYmmdd format.\");\n errors.add(error);\n }\n } catch (ParseException ex) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_DUE_DATE);\n error.setErrorDescription(\"Due date must be represented as a decimal string in YYYYmmdd format.\");\n errors.add(error);\n }\n }\n } else if (key.equals(\"PT\")) {\n if (value.length() > 3 || value.length() < 1) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_PAYMENT_TYPE);\n error.setErrorDescription(\"Payment type must be at represented as a string with length between 1 and 3 characters.\");\n errors.add(error);\n }\n } else if (key.equals(\"MSG\")) {\n if (value.length() > 35 || value.length() < 1) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_INVALID_MESSAGE);\n error.setErrorDescription(\"Message must be at represented as a string with length between 1 and 35 characters.\");\n errors.add(error);\n }\n }\n }\n if (!ibanFound) {\n SmartPaymentValidationError error = new SmartPaymentValidationError();\n error.setErrorCode(SmartPaymentValidationError.ERROR_IBAN_NOT_FOUND);\n error.setErrorDescription(\"You must specify an account number.\");\n errors.add(error);\n }\n return errors.isEmpty() ? null : errors;\n }\n"} {"input": " public void testCreateAndCheckKey() throws Exception {\n String osPath = mTmpFile.getAbsolutePath();\n KeygenOutput keygenOutput = new KeygenOutput();\n long now = System.currentTimeMillis();\n DebugKeyProvider provider;\n try {\n provider = new DebugKeyProvider(osPath, null , keygenOutput);\n } catch (Throwable t) {\n String msg = String.format(\"%1$s in %2$s\\n%3$s\",\n t.getClass().getSimpleName(), osPath, t.toString());\n throw new Exception(msg, t);\n }\n assertNotNull(provider);\n assertEquals(\"\", keygenOutput.getOut());\n assertEquals(\"\", keygenOutput.getErr());\n PrivateKey key = provider.getDebugKey();\n assertNotNull(key);\n X509Certificate certificate = (X509Certificate) provider.getCertificate();\n assertNotNull(certificate);\n Calendar c = Calendar.getInstance();\n c.setTimeInMillis(now);\n assertTrue(certificate.getNotAfter().compareTo(c.getTime()) > 0);\n c.add(Calendar.DAY_OF_YEAR, 365);\n c.add(Calendar.SECOND, -1);\n assertTrue(\"1 year expiration failed\",\n certificate.getNotAfter().compareTo(c.getTime()) > 0);\n c.add(Calendar.DAY_OF_YEAR, 29 * 365);\n c.add(Calendar.HOUR_OF_DAY, -1);\n assertTrue(\"30 year expiration failed\",\n certificate.getNotAfter().compareTo(c.getTime()) > 0);\n c.add(Calendar.HOUR, 1);\n assertFalse(\"30 year and 1 hour expiration failed\",\n certificate.getNotAfter().compareTo(c.getTime()) > 0);\n }\n", "output": " public void testCreateAndCheckKey() throws Exception {\n String osPath = mTmpFile.getAbsolutePath();\n KeygenOutput keygenOutput = new KeygenOutput();\n long now = System.currentTimeMillis();\n DebugKeyProvider provider;\n try {\n provider = new DebugKeyProvider(osPath, null , keygenOutput);\n } catch (Throwable t) {\n String msg = String.format(\"%1$s in %2$s\\n%3$s\",\n t.getClass().getSimpleName(), osPath, t.toString());\n throw new Exception(msg, t);\n }\n assertNotNull(provider);\n assertEquals(\"\", keygenOutput.getOut());\n assertEquals(\"\", keygenOutput.getErr());\n PrivateKey key = provider.getDebugKey();\n assertNotNull(key);\n X509Certificate certificate = (X509Certificate) provider.getCertificate();\n assertNotNull(certificate);\n Calendar c = Calendar.getInstance();\n c.setTimeInMillis(now);\n assertTrue(certificate.getNotAfter().compareTo(c.getTime()) > 0);\n c.add(Calendar.DAY_OF_YEAR, 365);\n c.add(Calendar.SECOND, -1);\n assertTrue(\"1 year expiration failed\",\n certificate.getNotAfter().compareTo(c.getTime()) > 0);\n c.add(Calendar.DAY_OF_YEAR, 29 * 365);\n c.add(Calendar.HOUR_OF_DAY, -1);\n assertTrue(\"30 year expiration failed\",\n certificate.getNotAfter().compareTo(c.getTime()) > 0);\n c.add(Calendar.HOUR, 5);\n assertFalse(\"30 year and a few hours expiration failed\",\n certificate.getNotAfter().compareTo(c.getTime()) > 0);\n }\n"} {"input": " public synchronized static Bitmap getCover(Context context, Media media, int width) {\n String coverPath = null;\n Bitmap cover = null;\n String cachePath = null;\n if (!Util.hasExternalStorage() && width > 0)\n return null;\n try {\n int hash = MurmurHash.hash32(media.getArtist()+media.getAlbum());\n cachePath = COVER_DIR + (hash >= 0 ? \"\" + hash : \"m\" + (-hash)) + \"_\" + width;\n File cacheFile = new File(cachePath);\n if (cacheFile != null && cacheFile.exists()) {\n if (cacheFile.length() > 0)\n coverPath = cachePath;\n }\n if (coverPath == null)\n coverPath = getCoverFromVlc(context, media);\n if (coverPath == null)\n coverPath = getCoverFromFolder(context, media);\n if (coverPath == null)\n coverPath = getCoverFromMediaStore(context, media);\n cover = readBitmap(coverPath);\n if (cover != null && width > 0)\n cover = Util.scaleDownBitmap(context, cover, width);\n writeBitmap(cover, cachePath);\n } catch (Exception e) {\n e.printStackTrace();\n }\n return cover;\n }\n", "output": " public synchronized static Bitmap getCover(Context context, Media media, int width) {\n String coverPath = null;\n Bitmap cover = null;\n String cachePath = null;\n if (!Util.hasExternalStorage() && width > 0)\n return null;\n try {\n int hash = MurmurHash.hash32(media.getArtist()+media.getAlbum());\n cachePath = COVER_DIR + (hash >= 0 ? \"\" + hash : \"m\" + (-hash)) + \"_\" + width;\n File cacheFile = new File(cachePath);\n if (cacheFile != null && cacheFile.exists()) {\n if (cacheFile.length() > 0)\n coverPath = cachePath;\n else\n return null;\n }\n if (coverPath == null)\n coverPath = getCoverFromVlc(context, media);\n if (coverPath == null)\n coverPath = getCoverFromFolder(context, media);\n if (coverPath == null)\n coverPath = getCoverFromMediaStore(context, media);\n cover = readBitmap(coverPath);\n if (cover != null && width > 0)\n cover = Util.scaleDownBitmap(context, cover, width);\n writeBitmap(cover, cachePath);\n } catch (Exception e) {\n e.printStackTrace();\n }\n return cover;\n }\n"} {"input": " public void run() {\n int currentState = 0; \n WizardUndo undoStack = new WizardUndo();\n Object ret;\n boolean wizardComplete = false;\n while (!wizardComplete) {\n if (wdlg.isStopClicked()) {\n m_log.info(states[currentState].getStateName() + \" clicked stop \");\n wizardComplete = true;\n } else if (wdlg.isNextClicked()) {\n m_log.info(states[currentState].getStateName() + \" clicked next \");\n if (currentState == states.length - 1) {\n wdlg.whichState(WizardDialog.STATE_LAST);\n wizardComplete = true;\n } else {\n wdlg.whichState(WizardDialog.STATE_INTERMEDIATE);\n System.out.println(\"Will evaluate \" + states[currentState].getStateName());\n ret = wdlg.getCurrentStateUI().evaluate();\n if (ret == null) continue;\n else undoStack.push(ret);\n currentState++;\n wdlg.setCurrentStateUI(states[currentState]); \n }\n } else if (wdlg.isBackClicked()) {\n m_log.info(states[currentState].getStateName() + \" clicked back \");\n if (currentState == 0) {\n wdlg.whichState(WizardDialog.STATE_FIRST);\n continue;\n } else wdlg.whichState(WizardDialog.STATE_INTERMEDIATE);\n undoStack.undo(currentState);\n currentState--;\n wdlg.setCurrentStateUI(states[currentState]);\n } else if (wdlg.isCancelClicked()) {\n m_log.info(states[currentState].getStateName() + \" clicked cancel \");\n undoStack.undoAll(currentState);\n wizardComplete = true;\n }\n } \n } \n", "output": " public void run() {\n int currentState = 0; \n WizardUndo undoStack = new WizardUndo();\n Object ret;\n boolean wizardComplete = false;\n while (!wizardComplete) {\n if (wdlg.isStopClicked()) {\n m_log.info(states[currentState].getLabel().getText() + \" clicked stop \");\n wizardComplete = true;\n } else if (wdlg.isNextClicked()) {\n m_log.info(states[currentState].getLabel().getText() + \" clicked next \");\n if (currentState == states.length - 1) {\n wdlg.whichState(WizardDialog.STATE_LAST);\n wizardComplete = true;\n } else {\n wdlg.whichState(WizardDialog.STATE_INTERMEDIATE);\n ret = wdlg.getCurrentStateUI().evaluate();\n if (ret == null) continue;\n else undoStack.push(ret);\n currentState++;\n wdlg.setCurrentStateUI(states[currentState]); \n }\n } else if (wdlg.isBackClicked()) {\n m_log.info(states[currentState].getLabel().getText() + \" clicked back \");\n if (currentState == 0) {\n wdlg.whichState(WizardDialog.STATE_FIRST);\n continue;\n } else wdlg.whichState(WizardDialog.STATE_INTERMEDIATE);\n undoStack.undo(currentState);\n currentState--;\n wdlg.setCurrentStateUI(states[currentState]);\n } else if (wdlg.isCancelClicked()) {\n m_log.info(states[currentState].getLabel().getText() + \" clicked cancel \");\n undoStack.undoAll(currentState);\n wizardComplete = true;\n }\n } \n } \n"} {"input": " protected void handleScoutTreeEventInSwt(TreeEvent e) {\n if (isDisposed()) {\n return;\n }\n ignoreSelectionEventsFromSwtToScoutUntilNextDisplayPost();\n switch (e.getType()) {\n case TreeEvent.TYPE_REQUEST_FOCUS: {\n getSwtField().setFocus();\n break;\n }\n case TreeEvent.TYPE_NODE_EXPANDED:\n case TreeEvent.TYPE_NODE_COLLAPSED: {\n setExpansionFromScout(e.getNode());\n break;\n }\n case TreeEvent.TYPE_NODES_INSERTED: {\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODES_UPDATED: {\n ISelection oldSelection = getSwtTreeViewer().getSelection();\n ISelection newSelection = new StructuredSelection(getScoutObject().getSelectedNodes());\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n if (!newSelection.equals(oldSelection)) {\n getSwtTreeViewer().setSelection(newSelection);\n }\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODES_DELETED: {\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODE_FILTER_CHANGED: {\n updateTreeStructureAndKeepSelection(getScoutObject().getRootNode());\n setExpansionFromScout(getScoutObject().getRootNode());\n if (getSwtField().getSelectionCount() == 0) {\n getSwtField().showItem(getSwtField().getItem(0));\n }\n break;\n }\n case TreeEvent.TYPE_CHILD_NODE_ORDER_CHANGED: {\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODES_SELECTED: {\n setSelectionFromScout(e.getNodes());\n break;\n }\n case TreeEvent.TYPE_SCROLL_TO_SELECTION: {\n scrollToSelection();\n break;\n }\n }\n }\n", "output": " protected void handleScoutTreeEventInSwt(TreeEvent e) {\n if (isDisposed()) {\n return;\n }\n ignoreSelectionEventsFromSwtToScoutUntilNextDisplayPost();\n switch (e.getType()) {\n case TreeEvent.TYPE_REQUEST_FOCUS: {\n getSwtField().setFocus();\n break;\n }\n case TreeEvent.TYPE_NODE_EXPANDED:\n case TreeEvent.TYPE_NODE_COLLAPSED: {\n setExpansionFromScout(e.getNode());\n break;\n }\n case TreeEvent.TYPE_NODES_INSERTED: {\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODES_UPDATED: {\n ISelection oldSelection = getSwtTreeViewer().getSelection();\n ISelection newSelection = new StructuredSelection(getScoutObject().getSelectedNodes());\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n if (!newSelection.equals(oldSelection)) {\n getSwtTreeViewer().setSelection(newSelection);\n }\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODES_DELETED: {\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODE_FILTER_CHANGED: {\n updateTreeStructureAndKeepSelection(getScoutObject().getRootNode());\n setExpansionFromScout(getScoutObject().getRootNode());\n if (getSwtField().getSelectionCount() == 0 && getSwtField().getItemCount() > 0) {\n getSwtField().showItem(getSwtField().getItem(0));\n }\n break;\n }\n case TreeEvent.TYPE_CHILD_NODE_ORDER_CHANGED: {\n updateTreeStructureAndKeepSelection(e.getCommonParentNode());\n setExpansionFromScout(e.getCommonParentNode());\n break;\n }\n case TreeEvent.TYPE_NODES_SELECTED: {\n setSelectionFromScout(e.getNodes());\n break;\n }\n case TreeEvent.TYPE_SCROLL_TO_SELECTION: {\n scrollToSelection();\n break;\n }\n }\n }\n"} {"input": " protected void onLayout(\n boolean changed, int left, int top, int right, int bottom) {\n int count = getChildCount();\n if (count == 0) return;\n int shutterButtonWidth = mShutterButton.getMeasuredWidth();\n mShutterButtonRadius = shutterButtonWidth / 2.0;\n int shutterButtonHeight = mShutterButton.getMeasuredHeight();\n mCenterY = (bottom - top) / 2;\n mShutterButton.layout(mCenterX - shutterButtonWidth / 2,\n mCenterY - shutterButtonHeight / 2,\n mCenterX + shutterButtonWidth / 2,\n mCenterY + shutterButtonHeight / 2);\n if (count == 1) return;\n mWheelRadius = mShutterButtonRadius + mStrokeWidth * 1.5;\n mCenterX = (int) (right - mShutterButtonRadius * 1.2);\n double intervalDegrees = 180.0 / (count - 2);\n double initialDegrees = 90.0;\n int index = 0;\n for (int i = 0; i < count; i++) {\n View view = getChildAt(i);\n if (view == mShutterButton) continue;\n double degree = initialDegrees + intervalDegrees * index;\n double radian = Math.toRadians(degree);\n int x = mCenterX + (int)(mWheelRadius * Math.cos(radian));\n int y = mCenterY - (int)(mWheelRadius * Math.sin(radian));\n int width = view.getMeasuredWidth();\n int height = view.getMeasuredHeight();\n view.layout(x - width / 2, y - height / 2, x + width / 2,\n y + height / 2);\n index++;\n }\n mSectorInitialRadians = new double[count];\n mSectorInitialRadians[0] = Math.toRadians(\n initialDegrees - intervalDegrees / 2.0);\n for (int i = 1; i < count; i++) {\n mSectorInitialRadians[i] = mSectorInitialRadians[i - 1]\n + Math.toRadians(intervalDegrees);\n }\n }\n", "output": " protected void onLayout(\n boolean changed, int left, int top, int right, int bottom) {\n int count = getChildCount();\n if (count == 0) return;\n int shutterButtonWidth = mShutterButton.getMeasuredWidth();\n mShutterButtonRadius = shutterButtonWidth / 2.0;\n int shutterButtonHeight = mShutterButton.getMeasuredHeight();\n mCenterY = (bottom - top) / 2;\n mShutterButton.layout(mCenterX - shutterButtonWidth / 2,\n mCenterY - shutterButtonHeight / 2,\n mCenterX + shutterButtonWidth / 2,\n mCenterY + shutterButtonHeight / 2);\n if (count == 1) return;\n mWheelRadius = mShutterButtonRadius + mStrokeWidth * 1.5;\n mCenterX = (int) (right - mShutterButtonRadius * 1.2 - left);\n double intervalDegrees = 180.0 / (count - 2);\n double initialDegrees = 90.0;\n int index = 0;\n for (int i = 0; i < count; i++) {\n View view = getChildAt(i);\n if (view == mShutterButton) continue;\n double degree = initialDegrees + intervalDegrees * index;\n double radian = Math.toRadians(degree);\n int x = mCenterX + (int)(mWheelRadius * Math.cos(radian));\n int y = mCenterY - (int)(mWheelRadius * Math.sin(radian));\n int width = view.getMeasuredWidth();\n int height = view.getMeasuredHeight();\n view.layout(x - width / 2, y - height / 2, x + width / 2,\n y + height / 2);\n index++;\n }\n mSectorInitialRadians = new double[count];\n mSectorInitialRadians[0] = Math.toRadians(\n initialDegrees - intervalDegrees / 2.0);\n for (int i = 1; i < count; i++) {\n mSectorInitialRadians[i] = mSectorInitialRadians[i - 1]\n + Math.toRadians(intervalDegrees);\n }\n }\n"} {"input": "\tprivate String getAgentInformation(Agent agent) {\n\t\tString info;\n\t\tif (agent.getCurrentAction() != null) {\n\t\t\tinfo = \"Name: \" + agent.getName() + \"\\n\" + \"Indentifier: \"\n\t\t\t\t\t+ agent.getIdentifier() + \"\\n\" + \"Status: \"\n\t\t\t\t\t+ agent.getState() + \"\\n\" + \"Current action: \\n\"\n\t\t\t\t\t+ \" - Name: \"\n\t\t\t\t\t+ agent.getCurrentAction().getClass().getSimpleName()\n\t\t\t\t\t+ \"\\n\" + \" - Type: \" + agent.getCurrentAction().getType()\n\t\t\t\t\t+ \"\\n\" + \" - State: \"\n\t\t\t\t\t+ agent.getCurrentAction().getState() + \"\\n\"\n\t\t\t\t\t+ \" - Description: \"\n\t\t\t\t\t+ agent.getCurrentAction().getInformationDescription()\n\t\t\t\t\t+ \"\\n\" + \" - Duration: \"\n\t\t\t\t\t+ agent.getCurrentAction().getDuration() + \" minutes\\n\"\n\t\t\t\t\t+ \"Current position: \" + agent.getCurrentPosition() + \"\\n\";\n\t\t\tinfo = info + \"Action pool:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getActionPoolCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t\tinfo = info + \"Todo list:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getTodoListCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t} else {\n\t\t\tinfo = \"Name: \" + agent.getName() + \"\\n\" + \"Indentifier: \"\n\t\t\t\t\t+ agent.getIdentifier() + \"\\n\" + \"Status: \"\n\t\t\t\t\t+ agent.getState() + \"\\n\" + \"Current action: ---\\n\"\n\t\t\t\t\t+ \"Current position: \" + agent.getCurrentPosition();\n\t\t\tinfo = info + \"Action pool:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getActionPoolCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t\tinfo = info + \"Todo list:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getTodoListCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t}\n\t\treturn info;\n\t}\n", "output": "\tprivate String getAgentInformation(Agent agent) {\n\t\tString info;\n\t\tif (agent.getCurrentAction() != null) {\n\t\t\tinfo = \"Name: \" + agent.getName() + \"\\n\" + \"Indentifier: \"\n\t\t\t\t\t+ agent.getIdentifier() + \"\\n\" + \"Status: \"\n\t\t\t\t\t+ agent.getState() + \"\\n\" + \"Current action: \\n\"\n\t\t\t\t\t+ \" - Name: \"\n\t\t\t\t\t+ agent.getCurrentAction().getClass().getSimpleName()\n\t\t\t\t\t+ \"\\n\" + \" - Type: \" + agent.getCurrentAction().getType()\n\t\t\t\t\t+ \"\\n\" + \" - State: \"\n\t\t\t\t\t+ agent.getCurrentAction().getState() + \"\\n\"\n\t\t\t\t\t+ \" - Description: \"\n\t\t\t\t\t+ agent.getCurrentAction().getInformationDescription()\n\t\t\t\t\t+ \"\\n\" + \" - Duration: \"\n\t\t\t\t\t+ agent.getCurrentAction().getDuration() + \" minutes\\n\"\n\t\t\t\t\t+ \"Current position: \" + agent.getCurrentPosition() + \"\\n\";\n\t\t\tinfo = info + \"Action pool:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getActionPoolCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t\tinfo = info + \"Todo list:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getTodoListCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t} else {\n\t\t\tinfo = \"Name: \" + agent.getName() + \"\\n\" + \"Indentifier: \"\n\t\t\t\t\t+ agent.getIdentifier() + \"\\n\" + \"Status: \"\n\t\t\t\t\t+ agent.getState() + \"\\n\" + \"Current action: ---\\n\"\n\t\t\t\t\t+ \"Current position: \" + agent.getCurrentPosition() + \"\\n\";\n\t\t\tinfo = info + \"Action pool:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getActionPoolCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t\tinfo = info + \"Todo list:\\n\";\n\t\t\tfor (AbstractAction abstractAction : agent.getTodoListCopy()) {\n\t\t\t\tinfo = info + \" \" + abstractAction.getInformationDescription()\n\t\t\t\t\t\t+ \"\\n\";\n\t\t\t}\n\t\t}\n\t\treturn info;\n\t}\n"} {"input": " protected void configureTargetProduct(ProductConfigurer productConfigurer) {\n productConfigurer.copyMetadata();\n productConfigurer.copyTimeCoding();\n productConfigurer.copyGeoCoding();\n productConfigurer.copyTiePointGrids();\n Product targetProduct = productConfigurer.getTargetProduct();\n targetProduct.setName(sourceProduct.getName());\n if (doRadToRefl) {\n targetProduct.setProductType(String.format(\"%s_REFL\", sourceProduct.getProductType()));\n targetProduct.setAutoGrouping(\"reflec\");\n } else {\n targetProduct.setProductType(sourceProduct.getProductType());\n targetProduct.setAutoGrouping(\"radiance\");\n }\n targetProduct.setDescription(\"MERIS L1b Radiometric Correction\");\n for (final Band sourceBand : sourceProduct.getBands()) {\n if (sourceBand.getSpectralBandIndex() != -1) {\n final String targetBandName;\n final String targetBandDescription;\n final int dataType;\n final String unit;\n final double scalingFactor;\n final double scalingOffset;\n if (doRadToRefl) {\n targetBandName = sourceBand.getName().replace(\"radiance\", \"reflec\");\n targetBandDescription = \"Radiometry-corrected TOA reflectance\";\n dataType = ProductData.TYPE_FLOAT32;\n unit = UNIT_DL;\n scalingFactor = 1.0;\n scalingOffset = 0;\n } else {\n targetBandName = sourceBand.getName();\n targetBandDescription = \"Radiometry-corrected TOA radiance\";\n dataType = sourceBand.getDataType();\n unit = sourceBand.getUnit();\n scalingFactor = sourceBand.getScalingFactor();\n scalingOffset = sourceBand.getScalingOffset();\n }\n final Band targetBand = targetProduct.addBand(targetBandName, dataType);\n targetBand.setScalingFactor(scalingFactor);\n targetBand.setScalingOffset(scalingOffset);\n targetBand.setDescription(targetBandDescription);\n targetBand.setUnit(unit);\n targetBand.setValidPixelExpression(sourceBand.getValidPixelExpression());\n ProductUtils.copySpectralBandProperties(sourceBand, targetBand);\n }\n }\n productConfigurer.copyBands(MERIS_DETECTOR_INDEX_DS_NAME, MERIS_L1B_FLAGS_DS_NAME);\n for (final Band sourceBand : sourceProduct.getBands()) {\n if (sourceBand.getSpectralBandIndex() == -1 && !targetProduct.containsBand(sourceBand.getName())) {\n productConfigurer.copyBands(sourceBand.getName());\n }\n }\n }\n", "output": " protected void configureTargetProduct(ProductConfigurer productConfigurer) {\n productConfigurer.copyMetadata();\n productConfigurer.copyTimeCoding();\n productConfigurer.copyTiePointGrids(); \n productConfigurer.copyGeoCoding();\n Product targetProduct = productConfigurer.getTargetProduct();\n targetProduct.setName(sourceProduct.getName());\n if (doRadToRefl) {\n targetProduct.setProductType(String.format(\"%s_REFL\", sourceProduct.getProductType()));\n targetProduct.setAutoGrouping(\"reflec\");\n } else {\n targetProduct.setProductType(sourceProduct.getProductType());\n targetProduct.setAutoGrouping(\"radiance\");\n }\n targetProduct.setDescription(\"MERIS L1b Radiometric Correction\");\n for (final Band sourceBand : sourceProduct.getBands()) {\n if (sourceBand.getSpectralBandIndex() != -1) {\n final String targetBandName;\n final String targetBandDescription;\n final int dataType;\n final String unit;\n final double scalingFactor;\n final double scalingOffset;\n if (doRadToRefl) {\n targetBandName = sourceBand.getName().replace(\"radiance\", \"reflec\");\n targetBandDescription = \"Radiometry-corrected TOA reflectance\";\n dataType = ProductData.TYPE_FLOAT32;\n unit = UNIT_DL;\n scalingFactor = 1.0;\n scalingOffset = 0;\n } else {\n targetBandName = sourceBand.getName();\n targetBandDescription = \"Radiometry-corrected TOA radiance\";\n dataType = sourceBand.getDataType();\n unit = sourceBand.getUnit();\n scalingFactor = sourceBand.getScalingFactor();\n scalingOffset = sourceBand.getScalingOffset();\n }\n final Band targetBand = targetProduct.addBand(targetBandName, dataType);\n targetBand.setScalingFactor(scalingFactor);\n targetBand.setScalingOffset(scalingOffset);\n targetBand.setDescription(targetBandDescription);\n targetBand.setUnit(unit);\n targetBand.setValidPixelExpression(sourceBand.getValidPixelExpression());\n ProductUtils.copySpectralBandProperties(sourceBand, targetBand);\n }\n }\n productConfigurer.copyBands(MERIS_DETECTOR_INDEX_DS_NAME, MERIS_L1B_FLAGS_DS_NAME);\n for (final Band sourceBand : sourceProduct.getBands()) {\n if (sourceBand.getSpectralBandIndex() == -1 && !targetProduct.containsBand(sourceBand.getName())) {\n productConfigurer.copyBands(sourceBand.getName());\n }\n }\n }\n"} {"input": "\tprivate void populateExtendedAggrInfo( String name, IAggregation aggrFunc,\n\t\t\tIConfigurationElement elem, AggrFunctionWrapper aggrWrapper )\n\t{\n\t\tIConfigurationElement[] uiInfo = elem.getChildren( ELEMENT_UIINFO );\n\t\tassert ( uiInfo != null && uiInfo.length == 1 );\n\t\tString paramInfo = uiInfo[0].getAttribute( ATTRIBUTE_PARAMETER_META_INFO );\n\t\tString textInfo = uiInfo[0].getAttribute( ATTRIBUTE_TEXT_DATA );\n\t\taggrWrapper.setDisplayName( textInfo );\n\t\tList paramList = new ArrayList( );\n\t\tString[] paramInfos = paramInfo.split( \",\" );\n\t\tboolean[] paramFlags = aggrFunc.getParameterDefn( );\n\t\tif ( paramInfos != null && paramInfos.length > 0 )\n\t\t{\n\t\t\tpopulateDataFiledParameterDefn( paramList );\n\t\t\tfor ( int k = 0; k < paramInfos.length; k++ )\n\t\t\t{\n\t\t\t\tfinal String s = paramInfos[k].trim( );\n\t\t\t\tint index = s.indexOf( ' ' );\n\t\t\t\tString paramName = null;\n\t\t\t\tif ( index > 0 )\n\t\t\t\t{\n\t\t\t\t\tparamName = s.substring( index + 1 ).trim( );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tparamName = paramInfos[k];\n\t\t\t\t}\n\t\t\t\tif ( k + 1 >= paramFlags.length )\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tParameterDefn paramDefn = new ParameterDefn( paramName,\n\t\t\t\t\t\tparamName,\n\t\t\t\t\t\t!paramFlags[k + 1],\n\t\t\t\t\t\tfalse );\n\t\t\t\tparamList.add( paramDefn );\n\t\t\t}\n\t\t}\n\t\taggrWrapper.setParameterDefn( null );\n\t}\n", "output": "\tprivate void populateExtendedAggrInfo( String name, IAggregation aggrFunc,\n\t\t\tIConfigurationElement elem, AggrFunctionWrapper aggrWrapper )\n\t{\n\t\tIConfigurationElement[] uiInfo = elem.getChildren( ELEMENT_UIINFO );\n\t\tassert ( uiInfo != null && uiInfo.length == 1 );\n\t\tString paramInfo = uiInfo[0].getAttribute( ATTRIBUTE_PARAMETER_META_INFO );\n\t\tString textInfo = uiInfo[0].getAttribute( ATTRIBUTE_TEXT_DATA );\n\t\taggrWrapper.setDisplayName( textInfo );\n\t\tList paramList = new ArrayList( );\n\t\tString[] paramInfos = paramInfo.split( \",\" );\n\t\tboolean[] paramFlags = aggrFunc.getParameterDefn( );\n\t\tif ( paramInfos != null && paramInfos.length > 0 )\n\t\t{\n\t\t\tpopulateDataFiledParameterDefn( paramList );\n\t\t\tfor ( int k = 0; k < paramInfos.length; k++ )\n\t\t\t{\n\t\t\t\tfinal String s = paramInfos[k].trim( );\n\t\t\t\tint index = s.indexOf( ' ' );\n\t\t\t\tString paramName = null;\n\t\t\t\tif ( index > 0 )\n\t\t\t\t{\n\t\t\t\t\tparamName = s.substring( index + 1 ).trim( );\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tparamName = paramInfos[k];\n\t\t\t\t}\n\t\t\t\tif ( k + 1 >= paramFlags.length )\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tParameterDefn paramDefn = new ParameterDefn( paramName,\n\t\t\t\t\t\tparamName,\n\t\t\t\t\t\t!paramFlags[k + 1],\n\t\t\t\t\t\tfalse );\n\t\t\t\tparamList.add( paramDefn );\n\t\t\t}\n\t\t}\n\t\tIParameterDefn[] params = new IParameterDefn[paramList.size( )];\n\t\tparamList.toArray( params );\n\t\taggrWrapper.setParameterDefn( params );\n\t}\n"} {"input": " public void onEnable() {\n this.settings = new Settings(this); \n if (this.getSettings().useMySQL()) {\n if (!this.initMySQL()) {\n this.getLogger().severe(\"Something is wrong with the MySQL database, switching to flatfile!\");\n this.getSettings().setUseMySQL(false);\n }\n }\n this.warpManager = new WarpManager(this);\n this.getCommand(\"sortal\").setExecutor(new SortalExecutor(this));\n this.getServer().getPluginManager().registerEvents(new EventListener(this), this);\n if(!this.initVault()){\n this.getLogger().info(\"Vault error or not found, setting costs to 0!\");\n this.getSettings().setWarpCreatePrice(0);\n this.getSettings().setWarpUsePrice(0); \n }else{\n this.getLogger().info(\"Hooked into Vault and Economy plugin succesfully!\");\n }\n this.getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable(){\n public void run() {\n saveData();\n }\n }, 36000L, 36000L);\n this.startMetrics();\n if(this.getSettings().isUpdate()){\n new Updater(this, \"sortal\", this.getFile(), Updater.UpdateType.DEFAULT, true);\n }\n this.getServer().getPluginManager().getPermission(\"sortal.warp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.createwarp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultCreateWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.delwarp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultDelWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.list\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultList()));\n this.getServer().getPluginManager().getPermission(\"sortal.unregister\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultUnregister()));\n this.getServer().getPluginManager().getPermission(\"sortal.directwarp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultDirectWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.placesign\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultPlaceSign()));\n this.getServer().getPluginManager().getPermission(\"sortal.setuses\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultSetUses()));\n this.getLogger().log(Level.INFO, String.format(\"Version %s build %s loaded!\", this.getSettings().getVersion(), this.getDescription().getVersion()));\n }\n", "output": " public void onEnable() {\n this.settings = new Settings(this); \n if (this.getSettings().useMySQL()) {\n if (!this.initMySQL()) {\n this.getLogger().severe(\"Something is wrong with the MySQL database, switching to flatfile!\");\n this.getSettings().setUseMySQL(false);\n }\n }\n this.warpManager = new WarpManager(this);\n this.getCommand(\"sortal\").setExecutor(new SortalExecutor(this));\n this.getServer().getPluginManager().registerEvents(new EventListener(this), this);\n if(!this.initVault()){\n this.getLogger().info(\"Vault error or not found, setting costs to 0!\");\n this.getSettings().setWarpCreatePrice(0);\n this.getSettings().setWarpUsePrice(0); \n }else{\n this.getLogger().info(\"Hooked into Vault and Economy plugin succesfully!\");\n }\n this.getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable(){\n public void run() {\n saveData();\n }\n }, 36000L, 36000L);\n this.startMetrics();\n if(this.getSettings().isUpdate()){\n new Updater(this, \"sortal\", this.getFile(), Updater.UpdateType.DEFAULT, true);\n }\n this.getServer().getPluginManager().getPermission(\"sortal.warp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.createwarp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultCreateWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.delwarp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultDelWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.list\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultList()));\n this.getServer().getPluginManager().getPermission(\"sortal.unregister\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultUnregister()));\n this.getServer().getPluginManager().getPermission(\"sortal.directwarp\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultDirectWarp()));\n this.getServer().getPluginManager().getPermission(\"sortal.placesign\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultPlaceSign()));\n this.getServer().getPluginManager().getPermission(\"sortal.setuses\").setDefault(PermissionDefault.getByName(this.getSettings().getDefaultSetUses()));\n this.getLogger().log(Level.INFO, String.format(\"Version %s build %s loaded!\", this.getSettings().getVersion(), this.getDescription().getVersion()));\n }\n"} {"input": " public synchronized void all(ServerSession remote, Message message) {\n if (message != null) {\n \tif (messages.containsKey(message.getChannel())) {\n \t\tmessages.put(message.getChannel(), messages.get(message.getChannel())+1);\n \t} else {\n \t\tmessages.put(message.getChannel(), 1);\n \t}\n \tif (log_messages) {\n \t\tSystem.err.println(message.getJSON());\n \t}\n \tObject pageObj = message.get(\"page\");\n \t\tif (pageObj instanceof String) {\n \t\t\tString page = (String)pageObj;\n \t\t\tpage = page.startsWith(\"http://\") ? page.substring(7) : page;\n \t\t\tpage = page.startsWith(\"www\") ? page.substring(3) : page;\n \t\t\tpage = page.startsWith(\"kabbalahgroup.info/internet/\") ? page.substring(28) : page;\n \t\t\tpage = page.startsWith(\"localhost:3000/\") ? page.substring(15) : page;\n \t\t\tString language = page.substring(0, 2);\n \t\t\tpage = page.substring(2, page.length());\n \t\t\tpage = page.startsWith(\"#\") ? page.substring(1) : page;\n \t\t\tMap> page_data = null;\n \t\t\tSet sessions = null;\n \t\t\tpage_data = pages.get(page);\n \t\t\tif (page_data == null) {\n \t\t\t\tpage_data = new TreeMap>();\n \t\t\t}\n \t\t\tsessions = page_data.get(language);\n \t\t\tif (sessions == null) {\n \t\t\t\tsessions = new HashSet();\t\t\t\n \t\t\t}\n \t\t\tsessions.add(remote);\n \t\t\tpage_data.put(language, sessions);\n \t\t\tpages.put(page, page_data);\n \t\tif (users.containsKey(remote)) {\n \t\t\tString[] lang_page = users.get(remote);\n \t\t\tif (lang_page == null || lang_page.length < 2 ||\n \t\t\t\tlang_page[0].compareTo(language) != 0 ||\n \t\t\t\tlang_page[1].compareTo(page) != 0) {\n\t\t Map> pages_page_data = pages.get(users.get(remote)[1]);\n\t\t Set pages_sessions = pages_page_data.get(language); \n\t\t pages_sessions.remove(remote);\n\t\t \tif (pages_sessions.size() == 0) {\n\t\t \t\tpages_page_data.remove(language);\n\t\t \t\tif (pages_page_data.size() == 0) {\n\t\t \t\t\tpages.remove(users.get(remote));\n\t\t \t\t}\n\t\t \t}\n \t\t\t} \t\t\n \t\t}\n \t\t\tusers.put(remote, new String[] {language, page});\n \t}\n }\n update();\n }\n", "output": " public synchronized void all(ServerSession remote, Message message) {\n if (message != null) {\n \tif (messages.containsKey(message.getChannel())) {\n \t\tmessages.put(message.getChannel(), messages.get(message.getChannel())+1);\n \t} else {\n \t\tmessages.put(message.getChannel(), 1);\n \t}\n \tif (log_messages) {\n \t\tSystem.err.println(message.getJSON());\n \t}\n \tObject pageObj = message.get(\"page\");\n \t\tif (pageObj instanceof String) {\n \t\t\tString page = (String)pageObj;\n \t\t\tpage = page.startsWith(\"http://\") ? page.substring(7) : page;\n \t\t\tpage = page.startsWith(\"www\") ? page.substring(3) : page;\n \t\t\tpage = page.startsWith(\"kabbalahgroup.info/internet/\") ? page.substring(28) : page;\n \t\t\tpage = page.startsWith(\"localhost:3000/\") ? page.substring(15) : page;\n \t\t\tString language = page.substring(0, 2);\n \t\t\tpage = page.substring(2, page.length());\n \t\t\tpage = page.startsWith(\"#\") ? page.substring(1) : page;\n \t\t\tMap> page_data = null;\n \t\t\tSet sessions = null;\n \t\t\tpage_data = pages.get(page);\n \t\t\tif (page_data == null) {\n \t\t\t\tpage_data = new TreeMap>();\n \t\t\t}\n \t\t\tsessions = page_data.get(language);\n \t\t\tif (sessions == null) {\n \t\t\t\tsessions = new HashSet();\t\t\t\n \t\t\t}\n \t\t\tsessions.add(remote);\n \t\t\tpage_data.put(language, sessions);\n \t\t\tpages.put(page, page_data);\n \t\tif (users.containsKey(remote)) {\n \t\t\tString[] lang_page = users.get(remote);\n \t\t\tif (lang_page == null || lang_page.length < 2 ||\n \t\t\t\tlang_page[0].compareTo(language) != 0 ||\n \t\t\t\tlang_page[1].compareTo(page) != 0) {\n\t\t Map> pages_page_data = pages.get(users.get(remote)[1]);\n\t\t Set pages_sessions = pages_page_data.get(users.get(remote)[0]); \n\t\t pages_sessions.remove(remote);\n\t\t \tif (pages_sessions.size() == 0) {\n\t\t \t\tpages_page_data.remove(language);\n\t\t \t\tif (pages_page_data.size() == 0) {\n\t\t \t\t\tpages.remove(users.get(remote));\n\t\t \t\t}\n\t\t \t}\n \t\t\t} \t\t\n \t\t}\n \t\t\tusers.put(remote, new String[] {language, page});\n \t}\n }\n update();\n }\n"} {"input": " public void readResourceTypes() throws ConfigurationException {\n try {\n DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(true);\n Configuration config;\n config = builder.buildFromFile(resourceTypeConfigFile);\n if (log.isDebugEnabled()) log.debug(\"Resource types config file: \" + resourceTypeConfigFile);\n Configuration resourceTypes[] = config.getChildren(\"resource-type\");\n for (int i = 0; i < resourceTypes.length; i++) {\n try {\n String packageName = resourceTypes[i].getAttribute(\"package\"); \n log.info(\"Package: \" + packageName);\n URL packageURL = ResourceTypeRegistry.class.getClassLoader().getResource(packageName.replace('.','/'));\n log.info(\"Package: \" + packageURL.getFile());\n File jarFile = new File(packageURL.getPath().substring(5, packageURL.getPath().indexOf(\"!\")));\n log.debug(\"Jar file: \" + jarFile);\n if (jarFile.isFile()) {\n java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(jarFile);\n java.util.Enumeration entries = zipFile.entries();\n while (entries.hasMoreElements()) {\n String entryName = ((java.util.zip.ZipEntry) entries.nextElement()).getName();\n if (entryName.indexOf(\"resource.xml\") >= 0 || entryName.indexOf(\"resource-\") >= 0) {\n log.info(\"Resource definition: \" + entryName);\n URL resourceURL = ResourceTypeRegistry.class.getClassLoader().getResource(entryName);\n log.info(\"Resource config URL: \" + resourceURL);\n try {\n ResourceTypeDefinition rtd = new ResourceTypeDefinition(resourceURL.openStream());\n log.debug(\"Universal Name: \" + rtd.getResourceTypeUniversalName());\n log.debug(\"Classname: \" + rtd.getResourceTypeClassname());\n hm.put(rtd.getResourceTypeUniversalName(), rtd);\n } catch (Exception exception) {\n log.error(\"Exception re registring resource with package '\" + packageName + \"' and resource definition URL '\" + resourceURL + \"'!\");\n log.error(exception, exception);\n }\n }\n }\n } else {\n log.error(\"No such file: \" + jarFile);\n }\n } catch (Exception e) {\n log.info(\"No package attribute, hence try src attribute...\");\n File resConfigFile = new File(resourceTypes[i].getAttribute(\"src\"));\n log.info(\"Source: \" + resConfigFile);\n if (!resConfigFile.isAbsolute()) {\n resConfigFile = FileUtil.file(resourceTypeConfigFile.getParentFile().getAbsolutePath(), resourceTypes[i].getAttribute(\"src\"));\n }\n if (resConfigFile.isDirectory()) {\n File resDir = resConfigFile;\n Iterator iter = FileUtils.listFiles(resDir, new WildcardFilter(\"resource*.xml\"), null).iterator();\n while (iter.hasNext()) {\n resConfigFile = (File)iter.next();\n log.debug(\"found resource config: \" + resConfigFile);\n ResourceTypeDefinition rtd = new ResourceTypeDefinition(resConfigFile);\n if (log.isDebugEnabled()) {\n log.debug(\"Universal Name: \" + rtd.getResourceTypeUniversalName());\n log.debug(\"Classname: \" + rtd.getResourceTypeClassname());\n }\n hm.put(rtd.getResourceTypeUniversalName(), rtd);\n }\n } else if (resConfigFile.isFile()) {\n ResourceTypeDefinition rtd = new ResourceTypeDefinition(resConfigFile);\n if (log.isDebugEnabled()) {\n log.debug(\"Universal Name: \" + rtd.getResourceTypeUniversalName());\n log.debug(\"Classname: \" + rtd.getResourceTypeClassname());\n }\n hm.put(rtd.getResourceTypeUniversalName(), rtd);\n } else {\n log.error(\"No such file or directory: \" + resConfigFile);\n }\n }\n } \n } catch (Exception e) {\n String errorMsg = \"Failure while reading configuration: \" + e.getMessage(); \n log.error(errorMsg, e);\n throw new ConfigurationException(errorMsg, e);\n }\n }\n", "output": " public void readResourceTypes() throws ConfigurationException {\n try {\n DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder(true);\n Configuration config;\n config = builder.buildFromFile(resourceTypeConfigFile);\n if (log.isDebugEnabled()) log.debug(\"Resource types config file: \" + resourceTypeConfigFile);\n Configuration resourceTypes[] = config.getChildren(\"resource-type\");\n for (int i = 0; i < resourceTypes.length; i++) {\n try {\n String packageName = resourceTypes[i].getAttribute(\"package\"); \n log.info(\"Package: \" + packageName);\n URL packageURL = ResourceTypeRegistry.class.getClassLoader().getResource(packageName.replace('.','/'));\n log.info(\"Package: \" + packageURL.getFile());\n File jarFile = new File(packageURL.getPath().substring(5, packageURL.getPath().indexOf(\"!\")));\n log.debug(\"Jar file: \" + jarFile);\n if (jarFile.isFile()) {\n java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(jarFile);\n java.util.Enumeration entries = zipFile.entries();\n while (entries.hasMoreElements()) {\n String entryName = ((java.util.zip.ZipEntry) entries.nextElement()).getName();\n if (entryName.indexOf(\"resource.xml\") >= 0 || entryName.indexOf(\"resource-\") >= 0) {\n log.info(\"Resource definition: \" + entryName);\n URL resourceURL = ResourceTypeRegistry.class.getClassLoader().getResource(entryName);\n log.info(\"Resource config URL: \" + resourceURL);\n try {\n ResourceTypeDefinition rtd = new ResourceTypeDefinition(resourceURL.openStream());\n log.debug(\"Universal Name: \" + rtd.getResourceTypeUniversalName());\n log.debug(\"Classname: \" + rtd.getResourceTypeClassname());\n hm.put(rtd.getResourceTypeUniversalName(), rtd);\n } catch (Exception exception) {\n log.error(\"Exception re registring resource with package '\" + packageName + \"' and resource definition URL '\" + resourceURL + \"'!\");\n log.error(exception, exception);\n }\n }\n }\n } else {\n log.error(\"No such file: \" + jarFile);\n }\n } catch (Exception e) {\n log.info(\"No package attribute, hence try src attribute...\");\n File resConfigFile = new File(resourceTypes[i].getAttribute(\"src\"));\n log.info(\"Source: \" + resConfigFile);\n if (!resConfigFile.isAbsolute()) {\n resConfigFile = FileUtil.file(resourceTypeConfigFile.getParentFile().getAbsolutePath(), resourceTypes[i].getAttribute(\"src\"));\n }\n if (resConfigFile.isDirectory()) {\n File resDir = resConfigFile;\n Iterator iter = FileUtils.listFiles(resDir, new WildcardFilter(\"resource*.xml\"), null).iterator();\n while (iter.hasNext()) {\n resConfigFile = (File)iter.next();\n log.debug(\"found resource config: \" + resConfigFile);\n ResourceTypeDefinition rtd = new ResourceTypeDefinition(resConfigFile);\n if (log.isDebugEnabled()) {\n log.debug(\"Universal Name: \" + rtd.getResourceTypeUniversalName());\n log.debug(\"Classname: \" + rtd.getResourceTypeClassname());\n }\n hm.put(rtd.getResourceTypeUniversalName(), rtd);\n }\n } else if (resConfigFile.isFile()) {\n ResourceTypeDefinition rtd = new ResourceTypeDefinition(resConfigFile);\n if (log.isDebugEnabled()) {\n log.debug(\"Universal Name: \" + rtd.getResourceTypeUniversalName());\n log.debug(\"Classname: \" + rtd.getResourceTypeClassname());\n }\n hm.put(rtd.getResourceTypeUniversalName(), rtd);\n } else {\n log.error(\"No such file or directory: \" + resConfigFile);\n }\n }\n } \n } catch (Exception e) {\n log.error(e, e);\n String errorMsg = \"Failure while reading configuration: \" + e.getMessage(); \n throw new ConfigurationException(errorMsg, e);\n }\n }\n"} {"input": "\t\tpublic final Void call() throws Exception {\n\t\t\tif (isDone()) throw new IllegalStateException(\"This task is already done!\");\n\t\t\t$IN $a = $src.readNow();\n\t\t\tif ($a == null) return null;\n\t\t\t$OUT $b = run($a);\n\t\t\tif ($b == null) return null;\n\t\t\t$sink.write($b);\n\t\t\treturn null;\n\t\t}\n", "output": "\t\tpublic final Void call() throws Exception {\n\t\t\tif (isDone()) return null;\n\t\t\t$IN $a = $src.readNow();\n\t\t\tif ($a == null) return null;\n\t\t\t$OUT $b = run($a);\n\t\t\tif ($b == null) return null;\n\t\t\t$sink.write($b);\n\t\t\treturn null;\n\t\t}\n"} {"input": " public void run() {\n while (!this.done) {\n synchronized (listLock) {\n LOG.trace(\"Iterating through decommissioned clients...\");\n List clientsToRemove = new ArrayList();\n for (HttpClient client : clientList) {\n String clientId = client.getParams().getParameter(CLIENT_INSTANCE_ID).toString();\n if (userManager.hasUsers(clientId)) {\n LOG.warn(\"Failed to shutdown connection pool client {} due to a connection still in \" +\n \"use after last reconfiguration of Repose.\", clientId);\n break;\n }\n PoolingClientConnectionManager connMan = (PoolingClientConnectionManager) client.getConnectionManager();\n PoolStats stats = connMan.getTotalStats();\n if (stats.getLeased() == 0) { \n LOG.debug(\"Shutting down client {}\", clientId);\n connMan.shutdown();\n clientsToRemove.add(client);\n }\n }\n for(HttpClient client: clientsToRemove) {\n clientList.remove(client);\n LOG.info(\"HTTP connection pool {} has been destroyed.\", client.getParams().getParameter(CLIENT_INSTANCE_ID));\n }\n }\n try {\n Thread.sleep(DEFAULT_INTERVAL);\n } catch (InterruptedException ex) {\n break;\n }\n }\n LOG.error(\"Shutting down decommissioner\");\n Thread.currentThread().interrupt();\n }\n", "output": " public void run() {\n while (!this.done) {\n synchronized (listLock) {\n LOG.trace(\"Iterating through decommissioned clients...\");\n List clientsToRemove = new ArrayList();\n for (HttpClient client : clientList) {\n String clientId = client.getParams().getParameter(CLIENT_INSTANCE_ID).toString();\n if (userManager.hasUsers(clientId)) {\n LOG.warn(\"Failed to shutdown connection pool client {} due to a connection still in \" +\n \"use after last reconfiguration of Repose.\", clientId);\n break;\n }\n PoolingClientConnectionManager connMan = (PoolingClientConnectionManager) client.getConnectionManager();\n PoolStats stats = connMan.getTotalStats();\n if (stats.getLeased() == 0) { \n LOG.debug(\"Shutting down client {}\", clientId);\n connMan.shutdown();\n clientsToRemove.add(client);\n }\n }\n for(HttpClient client: clientsToRemove) {\n clientList.remove(client);\n LOG.info(\"HTTP connection pool {} has been destroyed.\", client.getParams().getParameter(CLIENT_INSTANCE_ID));\n }\n }\n try {\n Thread.sleep(DEFAULT_INTERVAL);\n } catch (InterruptedException ex) {\n break;\n }\n }\n LOG.info(\"Shutting down HTTP Client Service Decommissioner\");\n Thread.currentThread().interrupt();\n }\n"} {"input": "\tpublic void onCreate(Bundle bundle) {\n\t\tsuper.onCreate(bundle);\n\t\tmContext = getActivity();\n\t\tif (getResources().getBoolean(R.bool.hide_accounts)) {\t\n\t\t\tPreferenceCategory accounts = (PreferenceCategory) getPreferenceScreen().getPreference(ACCOUNTS_SETTINGS_ID);\n\t\t\taccounts.removeAll();\n\t\t\taccounts.setLayoutResource(R.layout.hidden);\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.hide_wizard)) {\n\t\t\tPreference wizard = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);\n\t\t\twizard.setLayoutResource(R.layout.hidden);\n\t\t} else {\n\t\t\taddWizardPreferenceButton();\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.disable_animations)) {\n\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_animation_enable_key);\n\t\t}\n\t\tif (!getResources().getBoolean(R.bool.enable_linphone_friends)) {\n\t\t\tPreferenceCategory friends = (PreferenceCategory) getPreferenceScreen().getPreference(FRIENDS_SETTINGS_ID);\n\t\t\tfriends.removeAll();\n\t\t\tfriends.setLayoutResource(R.layout.hidden);\n\t\t}\n\t\taddTransportChecboxesListener();\n\t\tecCalibratePref = findPreference(pref_echo_canceller_calibration_key);\n\t\tecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {\n\t\t\tpublic boolean onPreferenceClick(Preference preference) {\n\t\t\t\tstartEcCalibration();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key);\n\t\tmencPref = (ListPreference) findPreference(pref_media_encryption_key);\n\t\tboolean fastCpu = Version.hasFastCpu();\n\t\tif (fastCpu) {\n\t\t\tdetectAudioCodec(pref_codec_ilbc_key, \"iLBC\", 8000, 1, false);\n\t\t\tfindPreference(pref_codec_speex16_key).setEnabled(true);\n\t\t}\n\t\tinitializeMediaEncryptionPreferences();\n\t\tdetectAudioCodec(pref_codec_amr_key,\"AMR\", 8000, 1, false);\n\t\tdetectAudioCodec(pref_codec_amrwb_key,\"AMR-WB\", 16000, 1, false);\n\t\tdetectAudioCodec(R.string.pref_codec_silk16_key,\"SILK\",16000, 1, true);\n\t\tdetectAudioCodec(R.string.pref_codec_silk24_key,\"SILK\",24000, 1, true);\n\t\tdetectAudioCodec(R.string.pref_codec_g729_key,\"G729\",8000, 1, true);\n\t\tif (!Version.isVideoCapable()) {\n\t\t\tuncheckAndDisableCheckbox(pref_video_enable_key);\n\t\t} else {\n\t\t\tif (!AndroidCameraConfiguration.hasFrontCamera()) {\n\t\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_video_use_front_camera_key);\n\t\t\t}\n\t\t}\n\t\tif (prefs().getBoolean(LinphoneActivity.PREF_FIRST_LAUNCH,true)) {\n\t\t\tdoOnFirstLaunch();\n\t\t}\n\t\tif (Hacks.hasBuiltInEchoCanceller()) {\n\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key);\n\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_echo_canceller_calibration_key);\n\t\t}\n\t\tdetectVideoCodec(R.string.pref_video_codec_h264_key, \"H264\");\n\t\tif (!Version.hasNeon())\n\t\t{\n\t\t\tfindPreference(R.string.pref_video_codec_h264_key).setEnabled(false);\n\t\t\tfindPreference(R.string.pref_video_codec_h264_key).setDefaultValue(false);\n\t\t}\n\t\taddEchoPrefsListener();\n\t\tif (Hacks.needSoftvolume()) {\n\t\t\tLog.w(\"Using Audio Hack\");\n\t\t\tcheckAndDisableCheckbox(R.string.pref_audio_hacks_use_galaxys_hack_key);\n\t\t}\n\t\tif (!LinphoneManager.getLc().isTunnelAvailable()) {\n\t\t\thidePreferenceCategory(R.string.pref_tunnel_key);\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.hide_camera_settings)) {\n\t\t\tPreferenceScreen screen = getPreferenceScreen();\n\t\t\tPreferenceCategory videoSettings = (PreferenceCategory) screen.getPreference(CAMERA_SETTINGS_ID);\n\t\t\tvideoSettings.removeAll();\n\t\t\tvideoSettings.setLayoutResource(R.layout.hidden);\n\t\t\tPreference enableVideo = findPreference(R.string.pref_video_enable_key);\n\t\t\tenableVideo.setLayoutResource(R.layout.hidden);\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.display_about_in_settings)) {\n\t\t\tgetPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setOnPreferenceClickListener(new OnPreferenceClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic boolean onPreferenceClick(Preference preference) {\n\t\t\t\t\tif (LinphoneActivity.isInstanciated()) {\n\t\t\t\t\t\tLinphoneActivity.instance().displayAbout();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tgetPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setLayoutResource(R.layout.hidden);\n\t\t}\n\t}\n", "output": "\tpublic void onCreate(Bundle bundle) {\n\t\tsuper.onCreate(bundle);\n\t\tmContext = getActivity();\n\t\tif (getResources().getBoolean(R.bool.hide_accounts)) {\t\n\t\t\tPreferenceCategory accounts = (PreferenceCategory) getPreferenceScreen().getPreference(ACCOUNTS_SETTINGS_ID);\n\t\t\taccounts.removeAll();\n\t\t\taccounts.setLayoutResource(R.layout.hidden);\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.hide_wizard)) {\n\t\t\tPreference wizard = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);\n\t\t\twizard.setLayoutResource(R.layout.hidden);\n\t\t} else {\n\t\t\taddWizardPreferenceButton();\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.disable_animations)) {\n\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_animation_enable_key);\n\t\t}\n\t\tif (!getResources().getBoolean(R.bool.enable_linphone_friends)) {\n\t\t\tPreferenceCategory friends = (PreferenceCategory) getPreferenceScreen().getPreference(FRIENDS_SETTINGS_ID);\n\t\t\tfriends.removeAll();\n\t\t\tfriends.setLayoutResource(R.layout.hidden);\n\t\t}\n\t\taddTransportChecboxesListener();\n\t\tecCalibratePref = findPreference(pref_echo_canceller_calibration_key);\n\t\tecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {\n\t\t\tpublic boolean onPreferenceClick(Preference preference) {\n\t\t\t\tstartEcCalibration();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key);\n\t\tmencPref = (ListPreference) findPreference(pref_media_encryption_key);\n\t\tboolean fastCpu = Version.hasFastCpu();\n\t\tif (fastCpu) {\n\t\t\tdetectAudioCodec(pref_codec_ilbc_key, \"iLBC\", 8000, 1, false);\n\t\t\tfindPreference(pref_codec_speex16_key).setEnabled(true);\n\t\t}\n\t\tinitializeMediaEncryptionPreferences();\n\t\tdetectAudioCodec(pref_codec_amr_key,\"AMR\", 8000, 1, false);\n\t\tdetectAudioCodec(pref_codec_amrwb_key,\"AMR-WB\", 16000, 1, false);\n\t\tdetectAudioCodec(R.string.pref_codec_silk16_key,\"SILK\",16000, 1, true);\n\t\tdetectAudioCodec(R.string.pref_codec_silk24_key,\"SILK\",24000, 1, true);\n\t\tdetectAudioCodec(R.string.pref_codec_g729_key,\"G729\",8000, 1, true);\n\t\tif (!Version.isVideoCapable()) {\n\t\t\tuncheckAndDisableCheckbox(pref_video_enable_key);\n\t\t} else {\n\t\t\tif (!AndroidCameraConfiguration.hasFrontCamera()) {\n\t\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_video_use_front_camera_key);\n\t\t\t}\n\t\t}\n\t\tif (prefs().getBoolean(LinphoneActivity.PREF_FIRST_LAUNCH,true)) {\n\t\t\tdoOnFirstLaunch();\n\t\t}\n\t\tif (Hacks.hasBuiltInEchoCanceller()) {\n\t\t\tuncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key);\n\t\t\tfindPreference(R.string.pref_echo_canceller_calibration_key).setLayoutResource(R.layout.hidden);\n\t\t}\n\t\tdetectVideoCodec(R.string.pref_video_codec_h264_key, \"H264\");\n\t\tif (!Version.hasNeon())\n\t\t{\n\t\t\tfindPreference(R.string.pref_video_codec_h264_key).setEnabled(false);\n\t\t\tfindPreference(R.string.pref_video_codec_h264_key).setDefaultValue(false);\n\t\t}\n\t\taddEchoPrefsListener();\n\t\tif (Hacks.needSoftvolume()) {\n\t\t\tLog.w(\"Using Audio Hack\");\n\t\t\tcheckAndDisableCheckbox(R.string.pref_audio_hacks_use_galaxys_hack_key);\n\t\t}\n\t\tif (!LinphoneManager.getLc().isTunnelAvailable()) {\n\t\t\thidePreferenceCategory(R.string.pref_tunnel_key);\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.hide_camera_settings)) {\n\t\t\tPreferenceScreen screen = getPreferenceScreen();\n\t\t\tPreferenceCategory videoSettings = (PreferenceCategory) screen.getPreference(CAMERA_SETTINGS_ID);\n\t\t\tvideoSettings.removeAll();\n\t\t\tvideoSettings.setLayoutResource(R.layout.hidden);\n\t\t\tPreference enableVideo = findPreference(R.string.pref_video_enable_key);\n\t\t\tenableVideo.setLayoutResource(R.layout.hidden);\n\t\t}\n\t\tif (getResources().getBoolean(R.bool.display_about_in_settings)) {\n\t\t\tgetPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setOnPreferenceClickListener(new OnPreferenceClickListener() {\n\t\t\t\t@Override\n\t\t\t\tpublic boolean onPreferenceClick(Preference preference) {\n\t\t\t\t\tif (LinphoneActivity.isInstanciated()) {\n\t\t\t\t\t\tLinphoneActivity.instance().displayAbout();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tgetPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setLayoutResource(R.layout.hidden);\n\t\t}\n\t}\n"} {"input": " public void run() {\n try {\n \tSystem.out.println(\"In thread for connect to network\");\n distConf = DistConfig.get_Instance();\n BufferedReader inStream = new BufferedReader (\n new InputStreamReader(client.getInputStream()));\n System.out.println(\"Got input stream\");\n BufferedOutputStream bos = new BufferedOutputStream (\n client.getOutputStream());\n PrintWriter outStream = new PrintWriter(bos, false);\n System.out.println(\"Got out stream\");\n ObjectOutputStream oos = new ObjectOutputStream (bos);\n System.out.println(\"Got object output stream\");\n System.out.println(\"Sending the dist config\");\n oos.writeObject(distConf);\n System.out.println(\"Sending user management\");\n oos.writeObject(UserManagement.get_Instance());\n oos.flush();\n System.out.println(\"Receiving reply\");\n inStream.readLine();\n NodeSearchTable distConnTable = \n NodeSearchTable.get_Instance();\n InetAddress cliAddress = client.getInetAddress();\n int newClientID = \n Sha1Generator.generate_Sha1(cliAddress.getHostAddress());\n System.out.println(\"Sha1 is \" + Integer.toString(newClientID));\n if (distConf.get_UseGlobalNodeTable()) {\n GlobalNodeTable dgt = GlobalNodeTable.get_instance();\n while (dgt.contains_ID(newClientID)) {\n newClientID = (newClientID + 1) % distConf.get_MaxNodes();\n }\n }\n else {\n while (distConnTable.contains_ID(newClientID)) {\n newClientID = (newClientID + 1) % distConf.get_MaxNodes();\n }\n }\n outStream.println(Integer.toString(newClientID));\n outStream.flush();\n inStream.readLine();\n if (distConf.get_UseGlobalNodeTable()) {\n GlobalNodeTable dgt = GlobalNodeTable.get_instance();\n oos.writeObject(dgt);\n oos.flush();\n }\n else if (distConnTable.size() == 0) {\n outStream.println(distConnTable.get_ownID());\n outStream.println(distConnTable.get_ownIPAddress());\n outStream.flush();\n }\n else {\n String ipAddress = distConnTable.get_ownIPAddress();\n int id = Integer.parseInt(distConnTable.get_ownID());\n boolean found = false;\n for (int index = 0; index < distConnTable.size(); index++) {\n int nextID = Integer.parseInt(distConnTable.get_IDAt(index));\n if (newClientID >= id && newClientID < nextID) {\n found = true;\n }\n else if (newClientID >= id && newClientID > nextID) {\n found = true;\n }\n else if (newClientID <= id && newClientID < nextID) {\n found = true;\n }\n if (!found) {\n id = nextID;\n ipAddress = distConnTable.get_IPAt(index);\n }\n }\n outStream.println(Integer.toString(id));\n outStream.println(ipAddress);\n outStream.flush();\n }\n inStream.readLine();\n inStream.close();\n oos.close();\n outStream.close();\n bos.close();\n client.close();\n } catch (IOException ex) {\n try {\n client.close();\n } catch (IOException ex1) {\n Logger.getLogger(ServEnterNetwork.class.getName()).log(Level.SEVERE, null, ex1);\n }\n Logger.getLogger(ServEnterNetwork.class.getName()).log(Level.SEVERE, null, ex);\n }\n }\n", "output": " public void run() {\n try {\n \tSystem.out.println(\"In thread for connect to network\");\n distConf = DistConfig.get_Instance();\n BufferedReader inStream = new BufferedReader (\n new InputStreamReader(client.getInputStream()));\n System.out.println(\"Got input stream\");\n BufferedOutputStream bos = new BufferedOutputStream (\n client.getOutputStream());\n PrintWriter outStream = new PrintWriter(bos, false);\n System.out.println(\"Got out stream\");\n ObjectOutputStream oos = new ObjectOutputStream (bos);\n System.out.println(\"Got object output stream\");\n System.out.println(\"Sending the dist config\");\n oos.writeObject(distConf);\n oos.flush();\n System.out.println(\"Sending user management\");\n oos.writeObject(UserManagement.get_Instance());\n oos.flush();\n System.out.println(\"Receiving reply\");\n inStream.readLine();\n NodeSearchTable distConnTable = \n NodeSearchTable.get_Instance();\n InetAddress cliAddress = client.getInetAddress();\n int newClientID = \n Sha1Generator.generate_Sha1(cliAddress.getHostAddress());\n System.out.println(\"Sha1 is \" + Integer.toString(newClientID));\n if (distConf.get_UseGlobalNodeTable()) {\n GlobalNodeTable dgt = GlobalNodeTable.get_instance();\n while (dgt.contains_ID(newClientID)) {\n newClientID = (newClientID + 1) % distConf.get_MaxNodes();\n }\n }\n else {\n while (distConnTable.contains_ID(newClientID)) {\n newClientID = (newClientID + 1) % distConf.get_MaxNodes();\n }\n }\n outStream.println(Integer.toString(newClientID));\n outStream.flush();\n inStream.readLine();\n if (distConf.get_UseGlobalNodeTable()) {\n GlobalNodeTable dgt = GlobalNodeTable.get_instance();\n oos.writeObject(dgt);\n oos.flush();\n }\n else if (distConnTable.size() == 0) {\n outStream.println(distConnTable.get_ownID());\n outStream.println(distConnTable.get_ownIPAddress());\n outStream.flush();\n }\n else {\n String ipAddress = distConnTable.get_ownIPAddress();\n int id = Integer.parseInt(distConnTable.get_ownID());\n boolean found = false;\n for (int index = 0; index < distConnTable.size(); index++) {\n int nextID = Integer.parseInt(distConnTable.get_IDAt(index));\n if (newClientID >= id && newClientID < nextID) {\n found = true;\n }\n else if (newClientID >= id && newClientID > nextID) {\n found = true;\n }\n else if (newClientID <= id && newClientID < nextID) {\n found = true;\n }\n if (!found) {\n id = nextID;\n ipAddress = distConnTable.get_IPAt(index);\n }\n }\n outStream.println(Integer.toString(id));\n outStream.println(ipAddress);\n outStream.flush();\n }\n inStream.readLine();\n inStream.close();\n oos.close();\n outStream.close();\n bos.close();\n client.close();\n } catch (IOException ex) {\n try {\n client.close();\n } catch (IOException ex1) {\n Logger.getLogger(ServEnterNetwork.class.getName()).log(Level.SEVERE, null, ex1);\n }\n Logger.getLogger(ServEnterNetwork.class.getName()).log(Level.SEVERE, null, ex);\n }\n }\n"} {"input": " public boolean render(final InternalContextAdapter cxt, final Writer writer, final Node node)\n throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {\n if (node.jjtGetNumChildren() != 0) {\n LOG.error(MessageFormat.format(\n ERR_MISSING_ARG, getName(), cxt.getCurrentTemplateName(), node.getLine(), node.getColumn()));\n return false;\n }\n for(Map.Entry entry : getDataModel(cxt).getParameters().getValues().entrySet()){\n final String key = entry.getKey();\n if(getDataModel(cxt).getParameters().getValues().containsKey(key + \"-isUrl\")){\n final String value = entry.getValue().getUtf8UrlEncoded();\n writer.append(key + '=' + value + '&');\n }\n }\n return true;\n }\n", "output": " public boolean render(final InternalContextAdapter cxt, final Writer writer, final Node node)\n throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {\n if (node.jjtGetNumChildren() != 0) {\n LOG.error(MessageFormat.format(\n ERR_MISSING_ARG, getName(), cxt.getCurrentTemplateName(), node.getLine(), node.getColumn()));\n return false;\n }\n for(Map.Entry entry : getDataModel(cxt).getParameters().getValues().entrySet()){\n final String key = entry.getKey();\n if(getDataModel(cxt).getParameters().getValues().containsKey(key + \"-isUrl\")){\n final String value = entry.getValue().getUtf8UrlEncoded();\n writer.append(key + '=' + value + '&');\n }\n }\n return true;\n }\n"} {"input": " public List crossover(List parentCollection) {\n checkState(parentCollection.size() >= 3, \"There must be a minimum of three parents to perform UNDX crossover.\");\n checkState(numberOfOffspring.getParameter() > 0, \"At least one offspring must be generated. Check 'numberOfOffspring'.\");\n List solutions = Entities.getCandidateSolutions(parentCollection);\n List offspring = Lists.newArrayListWithCapacity((int) numberOfOffspring.getParameter());\n UniformDistribution randomParent = new UniformDistribution();\n final int k = solutions.size();\n final int n = solutions.get(0).size();\n for (int os = 0; os < numberOfOffspring.getParameter(); os++) {\n int parent = (int) randomParent.getRandomNumber(0.0, k);\n Collections.swap(solutions, parent, k - 1);\n List e_zeta = new ArrayList<>();\n Vector g = Vectors.mean(fj.data.List.iterableList(solutions.subList(0, k - 1))).valueE(\"Error in getting mean\");\n for (int i = 0; i < k - 1; i++) {\n Vector d = solutions.get(i).subtract(g);\n if (!d.isZero()) {\n double dbar = d.length();\n Vector e = d.orthogonalize(e_zeta);\n if (!e.isZero()) {\n e_zeta.add(e.normalize().multiply(dbar));\n }\n }\n }\n final double D = solutions.get(k - 1).subtract(g).length();\n fj.data.List e_eta = fj.data.List.nil();\n e_eta.snoc(solutions.get(k - 1).subtract(g));\n for (int i = 0; i < n - e_zeta.size() - 1; i++) {\n Vector d = Vector.newBuilder().copyOf(g).buildRandom();\n e_eta.snoc(d);\n }\n e_eta = Vectors.orthonormalize(fj.data.List.iterableList(e_eta));\n Vector variables = Vector.copyOf(g);\n if (!useIndividualProviders) {\n for (int i = 0; i < e_zeta.size(); i++) {\n variables = variables.plus(e_zeta.get(i).multiply(random.getRandomNumber(0.0, sigma1.getParameter())));\n }\n for (int i = 0; i < e_eta.length(); i++) {\n variables = variables.plus(e_eta.index(i).multiply(D * random.getRandomNumber(0.0, sigma2.getParameter() / Math.sqrt(n))));\n }\n } else {\n for (int i = 0; i < e_zeta.size(); i++) {\n variables = variables.plus(e_zeta.get(i).multiply(new P1() {\n @Override\n public Number _1() {\n return random.getRandomNumber(0.0, sigma1.getParameter());\n }\n }));\n }\n for (int i = 0; i < e_eta.length(); i++) {\n variables = variables.plus(e_eta.index(i).multiply(new P1() {\n @Override\n public Number _1() {\n return D * random.getRandomNumber(0.0, sigma2.getParameter() / Math.sqrt(n));\n }\n }));\n }\n }\n E child = (E) parentCollection.get(parent).getClone();\n child.setCandidateSolution(variables);\n offspring.add(child);\n }\n return offspring;\n }\n", "output": " public List crossover(List parentCollection) {\n checkState(parentCollection.size() >= 3, \"There must be a minimum of three parents to perform UNDX crossover.\");\n checkState(numberOfOffspring.getParameter() > 0, \"At least one offspring must be generated. Check 'numberOfOffspring'.\");\n List solutions = Entities.getCandidateSolutions(parentCollection);\n List offspring = Lists.newArrayListWithCapacity((int) numberOfOffspring.getParameter());\n UniformDistribution randomParent = new UniformDistribution();\n final int k = solutions.size();\n final int n = solutions.get(0).size();\n for (int os = 0; os < numberOfOffspring.getParameter(); os++) {\n int parent = (int) randomParent.getRandomNumber(0.0, k);\n Collections.swap(solutions, parent, k - 1);\n List e_zeta = new ArrayList<>();\n Vector g = Vectors.mean(fj.data.List.iterableList(solutions.subList(0, k - 1))).valueE(\"Error in getting mean\");\n for (int i = 0; i < k - 1; i++) {\n Vector d = solutions.get(i).subtract(g);\n if (!d.isZero()) {\n double dbar = d.length();\n Vector e = d.orthogonalize(e_zeta);\n if (!e.isZero()) {\n e_zeta.add(e.normalize().multiply(dbar));\n }\n }\n }\n final double D = solutions.get(k - 1).subtract(g).length();\n fj.data.List e_eta = fj.data.List.nil();\n e_eta = e_eta.snoc(solutions.get(k - 1).subtract(g));\n for (int i = 0; i < n - e_zeta.size() - 1; i++) {\n Vector d = Vector.newBuilder().copyOf(g).buildRandom();\n e_eta = e_eta.snoc(d);\n }\n e_eta = Vectors.orthonormalize(fj.data.List.iterableList(e_eta));\n Vector variables = Vector.copyOf(g);\n if (!useIndividualProviders) {\n for (int i = 0; i < e_zeta.size(); i++) {\n variables = variables.plus(e_zeta.get(i).multiply(random.getRandomNumber(0.0, sigma1.getParameter())));\n }\n for (int i = 0; i < e_eta.length(); i++) {\n variables = variables.plus(e_eta.index(i).multiply(D * random.getRandomNumber(0.0, sigma2.getParameter() / Math.sqrt(n))));\n }\n } else {\n for (int i = 0; i < e_zeta.size(); i++) {\n variables = variables.plus(e_zeta.get(i).multiply(new P1() {\n @Override\n public Number _1() {\n return random.getRandomNumber(0.0, sigma1.getParameter());\n }\n }));\n }\n for (int i = 0; i < e_eta.length(); i++) {\n variables = variables.plus(e_eta.index(i).multiply(new P1() {\n @Override\n public Number _1() {\n return D * random.getRandomNumber(0.0, sigma2.getParameter() / Math.sqrt(n));\n }\n }));\n }\n }\n E child = (E) parentCollection.get(parent).getClone();\n child.setCandidateSolution(variables);\n offspring.add(child);\n }\n return offspring;\n }\n"} {"input": " public ChatRoomImpl(String jid, String participantNickname, String title) {\n this.participantJID = jid;\n roster = SparkManager.getConnection().getRoster();\n Iterator presences = roster.getPresences(jid);\n int count = 0;\n Presence p = null;\n if (presences.hasNext()) {\n p = presences.next();\n count++;\n }\n if(count == 1 && p != null && p.getFrom() != null){\n participantJID = p.getFrom();\n }\n this.participantNickname = participantNickname;\n loadHistory();\n PacketFilter fromFilter = new FromJIDFilter(participantJID);\n PacketFilter orFilter = new OrFilter(new PacketTypeFilter(Presence.class), new PacketTypeFilter(Message.class));\n PacketFilter andFilter = new AndFilter(orFilter, fromFilter);\n SparkManager.getConnection().addPacketListener(this, andFilter);\n this.roomname = jid;\n this.tabTitle = title;\n final SimpleDateFormat formatter = new SimpleDateFormat(\"h:mm a\");\n this.roomTitle = participantNickname;\n this.getSplitPane().setRightComponent(null);\n getSplitPane().setDividerSize(0);\n presence = PresenceManager.getPresence(participantJID);\n RosterEntry entry = roster.getEntry(participantJID);\n tabIcon = PresenceManager.getIconFromPresence(presence);\n ChatRoomButton infoButton = new ChatRoomButton(\"\", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24));\n infoButton.setToolTipText(Res.getString(\"message.view.information.about.this.user\"));\n getToolBar().addChatRoomButton(infoButton);\n if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) {\n ChatRoomButton addToRosterButton = new ChatRoomButton(\"\", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24));\n addToRosterButton.setToolTipText(Res.getString(\"message.add.this.user.to.your.roster\"));\n getToolBar().addChatRoomButton(addToRosterButton);\n addToRosterButton.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n RosterDialog rosterDialog = new RosterDialog();\n rosterDialog.setDefaultJID(participantJID);\n rosterDialog.setDefaultNickname(getParticipantNickname());\n rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame());\n }\n });\n }\n infoButton.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n VCardManager vcard = SparkManager.getVCardManager();\n vcard.viewProfile(participantJID, SparkManager.getChatManager().getChatContainer());\n }\n });\n if (StringUtils.parseResource(participantJID).equals(participantNickname)) {\n getToolBar().setVisible(false);\n }\n typingTimerTask = new TimerTask() {\n public void run() {\n if (!sendTypingNotification) {\n return;\n }\n long now = System.currentTimeMillis();\n if (now - lastTypedCharTime > 2000) {\n if (!sendNotification) {\n SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);\n sendNotification = true;\n }\n }\n }\n };\n TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, 2000, 2000);\n lastActivity = System.currentTimeMillis();\n }\n", "output": " public ChatRoomImpl(final String jid, String participantNickname, String title) {\n this.participantJID = jid;\n roster = SparkManager.getConnection().getRoster();\n Iterator presences = roster.getPresences(jid);\n int count = 0;\n Presence p = null;\n if (presences.hasNext()) {\n p = presences.next();\n count++;\n }\n if(count == 1 && p != null && p.getFrom() != null){\n participantJID = p.getFrom();\n }\n this.participantNickname = participantNickname;\n loadHistory();\n PacketFilter fromFilter = new FromJIDFilter(jid);\n PacketFilter orFilter = new OrFilter(new PacketTypeFilter(Presence.class), new PacketTypeFilter(Message.class));\n PacketFilter andFilter = new AndFilter(orFilter, fromFilter);\n SparkManager.getConnection().addPacketListener(this, andFilter);\n this.roomname = jid;\n this.tabTitle = title;\n final SimpleDateFormat formatter = new SimpleDateFormat(\"h:mm a\");\n this.roomTitle = participantNickname;\n this.getSplitPane().setRightComponent(null);\n getSplitPane().setDividerSize(0);\n presence = PresenceManager.getPresence(participantJID);\n RosterEntry entry = roster.getEntry(jid);\n tabIcon = PresenceManager.getIconFromPresence(presence);\n ChatRoomButton infoButton = new ChatRoomButton(\"\", SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24));\n infoButton.setToolTipText(Res.getString(\"message.view.information.about.this.user\"));\n getToolBar().addChatRoomButton(infoButton);\n if (entry == null && !StringUtils.parseResource(participantJID).equals(participantNickname)) {\n ChatRoomButton addToRosterButton = new ChatRoomButton(\"\", SparkRes.getImageIcon(SparkRes.ADD_IMAGE_24x24));\n addToRosterButton.setToolTipText(Res.getString(\"message.add.this.user.to.your.roster\"));\n getToolBar().addChatRoomButton(addToRosterButton);\n addToRosterButton.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n RosterDialog rosterDialog = new RosterDialog();\n rosterDialog.setDefaultJID(jid);\n rosterDialog.setDefaultNickname(getParticipantNickname());\n rosterDialog.showRosterDialog(SparkManager.getChatManager().getChatContainer().getChatFrame());\n }\n });\n }\n infoButton.addActionListener(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n VCardManager vcard = SparkManager.getVCardManager();\n vcard.viewProfile(jid, SparkManager.getChatManager().getChatContainer());\n }\n });\n if (StringUtils.parseResource(participantJID).equals(participantNickname)) {\n getToolBar().setVisible(false);\n }\n typingTimerTask = new TimerTask() {\n public void run() {\n if (!sendTypingNotification) {\n return;\n }\n long now = System.currentTimeMillis();\n if (now - lastTypedCharTime > 2000) {\n if (!sendNotification) {\n SparkManager.getMessageEventManager().sendCancelledNotification(getParticipantJID(), threadID);\n sendNotification = true;\n }\n }\n }\n };\n TaskEngine.getInstance().scheduleAtFixedRate(typingTimerTask, 2000, 2000);\n lastActivity = System.currentTimeMillis();\n }\n"} {"input": " public void update(final PTInstruction update, final UIService uiService) {\n if (update.containsKey(PROPERTY.WIDGET_WIDTH)) {\n uiObject.setWidth(update.getString(PROPERTY.WIDGET_WIDTH));\n } else if (update.containsKey(PROPERTY.WIDGET_HEIGHT)) {\n uiObject.setHeight(update.getString(PROPERTY.WIDGET_HEIGHT));\n } else if (update.containsKey(PROPERTY.WIDGET_FONT_SIZE)) {\n uiObject.getElement().getStyle().setProperty(FONT_SIZE, update.getString(PROPERTY.WIDGET_FONT_SIZE));\n } else if (update.containsKey(PROPERTY.STYLE_NAME)) {\n uiObject.setStyleName(update.getString(PROPERTY.STYLE_NAME));\n } else if (update.containsKey(PROPERTY.ADD_STYLE_NAME)) {\n uiObject.addStyleName(update.getString(PROPERTY.ADD_STYLE_NAME));\n } else if (update.containsKey(PROPERTY.REMOVE_STYLE_NAME)) {\n uiObject.removeStyleName(update.getString(PROPERTY.REMOVE_STYLE_NAME));\n } else if (update.containsKey(PROPERTY.WIDGET_VISIBLE)) {\n uiObject.setVisible(update.getBoolean(PROPERTY.WIDGET_VISIBLE));\n } else if (update.containsKey(PROPERTY.ENSURE_DEBUG_ID)) {\n uiObject.ensureDebugId(update.getString(PROPERTY.ENSURE_DEBUG_ID));\n } else if (update.containsKey(PROPERTY.WIDGET_TITLE)) {\n uiObject.setTitle(update.getString(PROPERTY.WIDGET_TITLE));\n } else if (update.containsKey(PROPERTY.STYLE_KEY)) {\n uiObject.getElement().getStyle().setProperty(update.getString(PROPERTY.STYLE_KEY), update.getString(PROPERTY.STYLE_VALUE));\n }\n }\n", "output": " public void update(final PTInstruction update, final UIService uiService) {\n if (update.containsKey(PROPERTY.WIDGET_WIDTH)) {\n uiObject.setWidth(update.getString(PROPERTY.WIDGET_WIDTH));\n } else if (update.containsKey(PROPERTY.WIDGET_HEIGHT)) {\n uiObject.setHeight(update.getString(PROPERTY.WIDGET_HEIGHT));\n } else if (update.containsKey(PROPERTY.WIDGET_FONT_SIZE)) {\n uiObject.getElement().getStyle().setProperty(FONT_SIZE, update.getString(PROPERTY.WIDGET_FONT_SIZE));\n } else if (update.containsKey(PROPERTY.STYLE_NAME)) {\n uiObject.setStyleName(update.getString(PROPERTY.STYLE_NAME));\n } else if (update.containsKey(PROPERTY.STYLE_PRIMARY_NAME)) {\n uiObject.setStylePrimaryName(update.getString(PROPERTY.STYLE_PRIMARY_NAME));\n } else if (update.containsKey(PROPERTY.ADD_STYLE_NAME)) {\n uiObject.addStyleName(update.getString(PROPERTY.ADD_STYLE_NAME));\n } else if (update.containsKey(PROPERTY.REMOVE_STYLE_NAME)) {\n uiObject.removeStyleName(update.getString(PROPERTY.REMOVE_STYLE_NAME));\n } else if (update.containsKey(PROPERTY.WIDGET_VISIBLE)) {\n uiObject.setVisible(update.getBoolean(PROPERTY.WIDGET_VISIBLE));\n } else if (update.containsKey(PROPERTY.ENSURE_DEBUG_ID)) {\n uiObject.ensureDebugId(update.getString(PROPERTY.ENSURE_DEBUG_ID));\n } else if (update.containsKey(PROPERTY.WIDGET_TITLE)) {\n uiObject.setTitle(update.getString(PROPERTY.WIDGET_TITLE));\n } else if (update.containsKey(PROPERTY.STYLE_KEY)) {\n uiObject.getElement().getStyle().setProperty(update.getString(PROPERTY.STYLE_KEY), update.getString(PROPERTY.STYLE_VALUE));\n }\n }\n"} {"input": " public static Comparator sensorComparator(final String sensorName) {\n return new Comparator() {\n public int compare(Entity a, Entity b) {\n Object aMetric = a.getProperties().get(sensorName);\n Object bMetric = b.getProperties().get(sensorName);\n if (aMetric == null) {\n return (bMetric != null) ? 1 : 0;\n } else if (bMetric == null) {\n return -1;\n } else if (aMetric instanceof Comparable) {\n return ((Comparable) aMetric).compareTo(bMetric);\n } else {\n throw new IllegalArgumentException(\"Metric \"+sensorName+\" not comparable; value is \"+aMetric);\n }\n }\n };\n }\n", "output": " public static Comparator sensorComparator(final String sensorName) {\n return new Comparator() {\n public int compare(Entity a, Entity b) {\n Object aMetric = a.getAttributes().get(sensorName);\n Object bMetric = b.getAttributes().get(sensorName);\n if (aMetric == null) {\n return (bMetric != null) ? 1 : 0;\n } else if (bMetric == null) {\n return -1;\n } else if (aMetric instanceof Comparable) {\n return ((Comparable) aMetric).compareTo(bMetric);\n } else {\n throw new IllegalArgumentException(\"Metric \"+sensorName+\" not comparable; value is \"+aMetric);\n }\n }\n };\n }\n"} {"input": " public void guiRenderEvent(RenderGameOverlayEvent.Post event) {\n \tif(event.type == RenderGameOverlayEvent.ElementType.HOTBAR) {\n\t \tMovingObjectPosition mouse = Minecraft.getMinecraft().objectMouseOver;\n\t \tWorld world = Minecraft.getMinecraft().theWorld;\n\t\t\tif(mouse != null && world != null && mouse.typeOfHit == EnumMovingObjectType.TILE) {\n\t\t\t\tTileEntity te = world.getBlockTileEntity(mouse.blockX, mouse.blockY, mouse.blockZ);\n\t\t\t\tint id = world.getBlockId(mouse.blockX, mouse.blockY, mouse.blockZ);\n\t\t\t\tif(id == ModjamMod.blockPillar.blockID || (id == ModjamMod.blockTrap.blockID && te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null)) {\n\t\t\t String key = Keyboard.getKeyName(FyresKeyHandler.examine.keyCode);\n\t\t\t String string = \"Press \" + key + \" to Examine\";\n\t\t\t if(Minecraft.getMinecraft().thePlayer != null && ((TileEntityTrap) te).placedBy.equals(Minecraft.getMinecraft().thePlayer.getEntityName())) {\n\t\t\t \tstring = Minecraft.getMinecraft().thePlayer.isSneaking() ? \"Use to disarm (Stand to toggle setting)\" : \"Use to toggle setting (Sneak to disarm)\";\n\t\t\t }\n\t\t\t Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() / 2 + 16, Color.WHITE.getRGB());\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(Minecraft.getMinecraft().thePlayer != null) {\n\t\t\t\tEntityPlayer player = Minecraft.getMinecraft().thePlayer;\n\t\t\t\tString blessing = EntityStatHelper.getStat(player, \"Blessing\");\n\t\t\t\tif(blessing != null) {\n\t\t\t\t\tif(blessing.equals(\"Berserker\")) {\n\t\t\t\t\t\tif(!EntityStatHelper.hasStat(player, \"BlessingCounter\")) {EntityStatHelper.giveStat(player, \"BlessingCounter\", 0);}\n\t\t\t\t\t\tString string = EntityStatHelper.getStat(player, \"BlessingCounter\");\n\t\t\t\t\t\tMinecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() - 48 + (player.capabilities.isCreativeMode ? 16 : 0), Color.RED.getRGB());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n \t}\n", "output": " public void guiRenderEvent(RenderGameOverlayEvent.Post event) {\n \tif(event.type == RenderGameOverlayEvent.ElementType.HOTBAR) {\n\t \tMovingObjectPosition mouse = Minecraft.getMinecraft().objectMouseOver;\n\t \tWorld world = Minecraft.getMinecraft().theWorld;\n\t\t\tif(mouse != null && world != null && mouse.typeOfHit == EnumMovingObjectType.TILE) {\n\t\t\t\tTileEntity te = world.getBlockTileEntity(mouse.blockX, mouse.blockY, mouse.blockZ);\n\t\t\t\tint id = world.getBlockId(mouse.blockX, mouse.blockY, mouse.blockZ);\n\t\t\t\tif(id == ModjamMod.blockPillar.blockID || (id == ModjamMod.blockTrap.blockID && te != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy != null)) {\n\t\t\t String key = Keyboard.getKeyName(FyresKeyHandler.examine.keyCode);\n\t\t\t String string = \"Press \" + key + \" to Examine\";\n\t\t\t if(Minecraft.getMinecraft().thePlayer != null && te instanceof TileEntityTrap && ((TileEntityTrap) te).placedBy.equals(Minecraft.getMinecraft().thePlayer.getEntityName())) {\n\t\t\t \tstring = Minecraft.getMinecraft().thePlayer.isSneaking() ? \"Use to disarm (Stand to toggle setting)\" : \"Use to toggle setting (Sneak to disarm)\";\n\t\t\t }\n\t\t\t Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() / 2 + 16, Color.WHITE.getRGB());\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(Minecraft.getMinecraft().thePlayer != null) {\n\t\t\t\tEntityPlayer player = Minecraft.getMinecraft().thePlayer;\n\t\t\t\tString blessing = EntityStatHelper.getStat(player, \"Blessing\");\n\t\t\t\tif(blessing != null) {\n\t\t\t\t\tif(blessing.equals(\"Berserker\")) {\n\t\t\t\t\t\tif(!EntityStatHelper.hasStat(player, \"BlessingCounter\")) {EntityStatHelper.giveStat(player, \"BlessingCounter\", 0);}\n\t\t\t\t\t\tString string = EntityStatHelper.getStat(player, \"BlessingCounter\");\n\t\t\t\t\t\tMinecraft.getMinecraft().fontRenderer.drawStringWithShadow(string, (event.resolution.getScaledWidth() / 2) - (Minecraft.getMinecraft().fontRenderer.getStringWidth(string) / 2), event.resolution.getScaledHeight() - 48 + (player.capabilities.isCreativeMode ? 16 : 0), Color.RED.getRGB());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n \t}\n"} {"input": " public static String confirm(final String callbackId_message) {\n JSG.runOnUiThread(new Runnable() {\n public void run() {\n int commaPos = callbackId_message.indexOf(',');\n final String callbackId = callbackId_message.substring(0, commaPos);\n final String message = callbackId_message.substring(commaPos);\n new AlertDialog.Builder(JSGActivity.getInstance())\n .setMessage(message)\n .setPositiveButton(\"OK\",\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dlg, int which) {\n JSG.postJS(String.format(\"jsg.callback.invoke(%s, true)\", callbackId));\n }\n }\n )\n .setNegativeButton(\"Cancel\",\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dlg, int which) {\n JSG.postJS(String.format(\"jsg.callback.invoke(%s, false)\", callbackId));\n }\n }\n )\n .show();\n }\n });\n return null;\n }\n", "output": " public static String confirm(final String callbackId_message) {\n JSG.runOnUiThread(new Runnable() {\n public void run() {\n int commaPos = callbackId_message.indexOf(',');\n final String callbackId = callbackId_message.substring(0, commaPos);\n final String message = callbackId_message.substring(commaPos + 1);\n new AlertDialog.Builder(JSGActivity.getInstance())\n .setMessage(message)\n .setPositiveButton(\"OK\",\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dlg, int which) {\n JSG.postJS(String.format(\"jsg.callback.invoke(%s, true)\", callbackId));\n }\n }\n )\n .setNegativeButton(\"Cancel\",\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dlg, int which) {\n JSG.postJS(String.format(\"jsg.callback.invoke(%s, false)\", callbackId));\n }\n }\n )\n .show();\n }\n });\n return null;\n }\n"} {"input": " public Dialog onCreateDialog(Bundle savedInstanceState) {\n Object[] confirmationTarget = getArguments().getStringArray(ARG_CONF_ARGUMENTS);\n int resourceId = getArguments().getInt(ARG_CONF_RESOURCE_ID, -1);\n int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1);\n int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1);\n int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1);\n if (confirmationTarget == null || resourceId == -1) {\n Log.wtf(getTag(), \"Calling confirmation dialog without resource or arguments\");\n return null;\n }\n AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())\n .setIcon(android.R.drawable.ic_dialog_alert)\n .setMessage(String.format(getString(resourceId), confirmationTarget))\n .setIconAttribute(android.R.attr.alertDialogIcon)\n .setTitle(android.R.string.dialog_alert_title);\n if (posBtn != -1)\n builder.setPositiveButton(posBtn,\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dialog, int whichButton) {\n mListener.onConfirmation(getTag()); \n }\n });\n if (neuBtn != -1)\n builder.setNeutralButton(neuBtn,\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dialog, int whichButton) {\n mListener.onNeutral(getTag()); \n }\n });\n if (negBtn != -1)\n builder.setNegativeButton(negBtn,\n new DialogInterface.OnClickListener() {\n @Override\n public void onClick(DialogInterface dialog, int which) {\n mListener.onCancel(getTag());\n }\n });\n return builder.create();\n }\n", "output": " public Dialog onCreateDialog(Bundle savedInstanceState) {\n Object[] confirmationTarget = getArguments().getStringArray(ARG_CONF_ARGUMENTS);\n int resourceId = getArguments().getInt(ARG_CONF_RESOURCE_ID, -1);\n int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1);\n int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1);\n int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1);\n if (confirmationTarget == null || resourceId == -1) {\n Log.wtf(getTag(), \"Calling confirmation dialog without resource or arguments\");\n return null;\n }\n AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())\n .setIcon(android.R.drawable.ic_dialog_alert)\n .setMessage(String.format(getString(resourceId), confirmationTarget))\n .setTitle(android.R.string.dialog_alert_title);\n if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {\n builder.setIconAttribute(android.R.attr.alertDialogIcon);\n }\n if (posBtn != -1)\n builder.setPositiveButton(posBtn,\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dialog, int whichButton) {\n mListener.onConfirmation(getTag()); \n }\n });\n if (neuBtn != -1)\n builder.setNeutralButton(neuBtn,\n new DialogInterface.OnClickListener() {\n public void onClick(DialogInterface dialog, int whichButton) {\n mListener.onNeutral(getTag()); \n }\n });\n if (negBtn != -1)\n builder.setNegativeButton(negBtn,\n new DialogInterface.OnClickListener() {\n @Override\n public void onClick(DialogInterface dialog, int which) {\n mListener.onCancel(getTag());\n }\n });\n return builder.create();\n }\n"} {"input": " public static void sendMessage( String name,\n String email,\n String message) {\n Logger.info(\"[SendMessage]\" + UbeHtml.decode(name + \" : \" + email + \":\" + message) );\n try \n {\n UbeMail.createNewEmail(UbeHtml.decode(name),UbeHtml.decode(message) + \" Email is : \" + UbeHtml.decode(email),\"mail.webube@gmail.com\" ,\"contact@webube.com\").send();\n }\n catch (Exception e)\n {\n Logger.error(e.toString());\n }\n if (request.isAjax())\n renderText(\"Mail Sent\");\n else\n Application.contact();\n }\n", "output": " public static void sendMessage( String name,\n String email,\n String message) {\n Logger.info(\"[SendMessage]\" + UbeHtml.decode(name + \" : \" + email + \":\" + message) );\n try \n {\n UbeMail.createNewEmail(UbeHtml.decode(name),UbeHtml.decode(message) + \" Email is : \" + UbeHtml.decode(email),\"mail.webube@gmail.com\" ,\"contact@webube.com\").send();\n }\n catch (Exception e)\n {\n Logger.error(e.toString());\n }\n if (request.isAjax())\n renderJSON(\"{status:'ok'}\");\n else\n Application.contact();\n }\n"} {"input": " public static double sum(double a, double b) \n {\n return 1.2*a + 0.8*b;\n }\n", "output": " public static double sum(double a, double b) \n {\n return a + b;\n }\n"} {"input": "\tpublic void set(StackFrame frame, String name, ASMOclAny value) {\n\t\tfinal boolean debug = false;\n\t\tif (debug) {\n\t\t\tATLLogger.info(\"Setting: \" + this + \" : \" + getType() + \".\" + name + \" to \" + value);\n\t\t}\n\t\tsuper.set(frame, name, value);\n\t\tEStructuralFeature feature = object.eClass().getEStructuralFeature(name);\n\t\tif (\"__xmiID__\".equals(name)) {\n\t\t\tResource r = ((ASMEMFModel)getModel()).getExtent();\n\t\t\tATLLogger.warning(\"Manual setting of \" + this + \":\" + getType() + \" XMI ID.\");\n\t\t\t((XMLResource)r).setID(object, ((ASMString)value).cString());\n\t\t\treturn;\n\t\t}\n\t\tif (frame != null) {\n\t\t\tASMExecEnv execEnv = (ASMExecEnv)frame.getExecEnv();\n\t\t\tif (execEnv.isWeavingHelper(getMetaobject(), name)) {\n\t\t\t\texecEnv.setHelperValue(frame, this, name, value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (feature == null) {\n\t\t\tthrow new VMException(frame, \"Feature \" + name + \" does not exist on \" + getType(), null);\n\t\t} else {\n\t\t\tif (!feature.isChangeable()) {\n\t\t\t\tthrow new VMException(frame, \"Feature \" + name + \" is not changeable\", null);\n\t\t\t}\n\t\t\tif (feature.isMany()) {\n\t\t\t\tEList l = (EList)object.eGet(feature);\n\t\t\t\tif (value instanceof ASMCollection) {\n\t\t\t\t\tfor (Iterator i = ((ASMCollection)value).iterator(); i.hasNext();) {\n\t\t\t\t\t\tASMOclAny sv = (ASMOclAny)i.next();\n\t\t\t\t\t\tif (isNotAssignable(feature, sv)) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tObject val = asm2EMF(frame, sv, name, feature);\n\t\t\t\t\t\tif (val != null) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tl.add(val);\n\t\t\t\t\t\t\t\tcheckContainment(feature, val);\n\t\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\t\tthrow new VMException(frame, \"Cannot set feature \" + getType() + \".\" + name\n\t\t\t\t\t\t\t\t\t\t+ \" to value \" + val, e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tObject val = asm2EMF(frame, value, name, feature);\n\t\t\t\t\tl.add(val);\n\t\t\t\t\tcheckContainment(feature, val);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (isNotAssignable(feature, value)) {\n\t\t\t\t} else {\n\t\t\t\t\tObject val = asm2EMF(frame, value, name, feature);\n\t\t\t\t\tif (val != null) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tobject.eSet(feature, val);\n\t\t\t\t\t\t\tcheckContainment(feature, val);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tthrow new VMException(frame, \"Cannot set feature \" + getType() + \".\" + name\n\t\t\t\t\t\t\t\t\t+ \" to value \" + val, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void set(StackFrame frame, String name, ASMOclAny value) {\n\t\tfinal boolean debug = false;\n\t\tif (debug) {\n\t\t\tATLLogger.info(\"Setting: \" + this + \" : \" + getType() + \".\" + name + \" to \" + value);\n\t\t}\n\t\tsuper.set(frame, name, value);\n\t\tEStructuralFeature feature = object.eClass().getEStructuralFeature(name);\n\t\tif (\"__xmiID__\".equals(name)) {\n\t\t\tResource r = ((ASMEMFModel)getModel()).getExtent();\n\t\t\tATLLogger.warning(\"Manual setting of \" + this + \":\" + getType() + \" XMI ID.\");\n\t\t\t((XMLResource)r).setID(object, ((ASMString)value).cString());\n\t\t\treturn;\n\t\t}\n\t\tif (frame != null) {\n\t\t\tASMExecEnv execEnv = (ASMExecEnv)frame.getExecEnv();\n\t\t\tif (execEnv.isWeavingHelper(getMetaobject(), name)) {\n\t\t\t\texecEnv.setHelperValue(frame, this, name, value);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (feature == null) {\n\t\t\tthrow new VMException(frame, \"Feature \" + name + \" does not exist on \" + getType(), null);\n\t\t} else {\n\t\t\tif (!feature.isChangeable()) {\n\t\t\t\tthrow new VMException(frame, \"Feature \" + name + \" is not changeable\", null);\n\t\t\t}\n\t\t\tif (feature.isMany()) {\n\t\t\t\tEList l = (EList)object.eGet(feature);\n\t\t\t\tif (value instanceof ASMCollection) {\n\t\t\t\t\tfor (Iterator i = ((ASMCollection)value).iterator(); i.hasNext();) {\n\t\t\t\t\t\tASMOclAny sv = (ASMOclAny)i.next();\n\t\t\t\t\t\tif (isNotAssignable(feature, sv)) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tObject val = asm2EMF(frame, sv, name, feature);\n\t\t\t\t\t\tif (val != null) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tl.add(val);\n\t\t\t\t\t\t\t\tcheckContainment(feature, val);\n\t\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\t\tthrow new VMException(frame, \"Cannot set feature \" + getType() + \".\" + name\n\t\t\t\t\t\t\t\t\t\t+ \" to value \" + val, e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (!isNotAssignable(feature, value)) {\n\t\t\t\t\t\tObject val = asm2EMF(frame, value, name, feature);\n\t\t\t\t\t\tl.add(val);\n\t\t\t\t\t\tcheckContainment(feature, val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (isNotAssignable(feature, value)) {\n\t\t\t\t} else {\n\t\t\t\t\tObject val = asm2EMF(frame, value, name, feature);\n\t\t\t\t\tif (val != null) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tobject.eSet(feature, val);\n\t\t\t\t\t\t\tcheckContainment(feature, val);\n\t\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\t\tthrow new VMException(frame, \"Cannot set feature \" + getType() + \".\" + name\n\t\t\t\t\t\t\t\t\t+ \" to value \" + val, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tprotected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception\n\t{\n\t\tfinal Trade charge = new Trade(this.getName(), ess);\n\t\tcharge.isAffordableFor(user);\n\t\tuser.sendMessage(_(\"backUsageMsg\"));\n\t\tuser.getTeleport().back(charge);\n\t}\n", "output": "\tprotected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception\n\t{\n\t\tfinal Trade charge = new Trade(this.getName(), ess);\n\t\tcharge.isAffordableFor(user);\n\t\tuser.sendMessage(_(\"backUsageMsg\"));\n\t\tuser.getTeleport().back(charge);\n\t\tthrow new NoChargeException();\n\t}\n"} {"input": "\tpublic void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {\n\t\tif (monitor == null) {\n\t\t\tmonitor = new NullProgressMonitor();\n\t\t}\n\t\tmonitor.beginTask(MessageFormat.format(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.Launching_{0}..._1\"), new String[]{configuration.getName()}), 3); \n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\n\t\tmonitor.subTask(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.Verifying_launch_attributes..._1\")); \n\t\tString mainTypeName = verifyMainTypeName(configuration);\n\t\tIVMInstall vm = verifyVMInstall(configuration);\n\t\tIVMRunner runner = vm.getVMRunner(mode);\n\t\tif (runner == null) {\n\t\t\tif (mode == ILaunchManager.DEBUG_MODE) {\n\t\t\t\tabort(MessageFormat.format(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.JRE_{0}_does_not_support_debug_mode._1\"), new String[]{vm.getName()}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); \n\t\t\t} else {\n\t\t\t\tabort(MessageFormat.format(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.JRE_{0}_does_not_support_run_mode._2\"), new String[]{vm.getName()}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); \n\t\t\t}\n\t\t}\n\t\tFile workingDir = verifyWorkingDirectory(configuration);\n\t\tString workingDirName = null;\n\t\tif (workingDir != null) {\n\t\t\tworkingDirName = workingDir.getAbsolutePath();\n\t\t}\n\t\tString pgmArgs = getProgramArguments(configuration);\n\t\tString vmArgs = getVMArguments(configuration);\n\t\tExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);\n\t\tMap vmAttributesMap = getVMSpecificAttributesMap(configuration);\n\t\tString[] classpath = getClasspath(configuration);\n\t\tVMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);\n\t\trunConfig.setProgramArguments(execArgs.getProgramArgumentsArray());\n\t\trunConfig.setVMArguments(execArgs.getVMArgumentsArray());\n\t\trunConfig.setWorkingDirectory(workingDirName);\n\t\trunConfig.setVMSpecificAttributesMap(vmAttributesMap);\n\t\tString[] bootpath = getBootpath(configuration);\n\t\trunConfig.setBootClassPath(bootpath);\n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\t\t\n\t\tprepareStopInMain(configuration);\n\t\tmonitor.worked(1);\n\t\tmonitor.subTask(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.Creating_source_locator..._2\")); \n\t\tsetDefaultSourceLocator(launch, configuration);\n\t\tmonitor.worked(1);\t\t\n\t\trunner.run(runConfig, launch, monitor);\n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\t\n\t\tmonitor.done();\n\t}\t\n", "output": "\tpublic void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {\n\t\tif (monitor == null) {\n\t\t\tmonitor = new NullProgressMonitor();\n\t\t}\n\t\tmonitor.beginTask(MessageFormat.format(\"{0}...\", new String[]{configuration.getName()}), 3); \n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\n\t\tmonitor.subTask(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.Verifying_launch_attributes..._1\")); \n\t\tString mainTypeName = verifyMainTypeName(configuration);\n\t\tIVMInstall vm = verifyVMInstall(configuration);\n\t\tIVMRunner runner = vm.getVMRunner(mode);\n\t\tif (runner == null) {\n\t\t\tif (mode == ILaunchManager.DEBUG_MODE) {\n\t\t\t\tabort(MessageFormat.format(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.JRE_{0}_does_not_support_debug_mode._1\"), new String[]{vm.getName()}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); \n\t\t\t} else {\n\t\t\t\tabort(MessageFormat.format(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.JRE_{0}_does_not_support_run_mode._2\"), new String[]{vm.getName()}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST); \n\t\t\t}\n\t\t}\n\t\tFile workingDir = verifyWorkingDirectory(configuration);\n\t\tString workingDirName = null;\n\t\tif (workingDir != null) {\n\t\t\tworkingDirName = workingDir.getAbsolutePath();\n\t\t}\n\t\tString pgmArgs = getProgramArguments(configuration);\n\t\tString vmArgs = getVMArguments(configuration);\n\t\tExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);\n\t\tMap vmAttributesMap = getVMSpecificAttributesMap(configuration);\n\t\tString[] classpath = getClasspath(configuration);\n\t\tVMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);\n\t\trunConfig.setProgramArguments(execArgs.getProgramArgumentsArray());\n\t\trunConfig.setVMArguments(execArgs.getVMArgumentsArray());\n\t\trunConfig.setWorkingDirectory(workingDirName);\n\t\trunConfig.setVMSpecificAttributesMap(vmAttributesMap);\n\t\tString[] bootpath = getBootpath(configuration);\n\t\trunConfig.setBootClassPath(bootpath);\n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\t\t\n\t\tprepareStopInMain(configuration);\n\t\tmonitor.worked(1);\n\t\tmonitor.subTask(LaunchingMessages.getString(\"JavaLocalApplicationLaunchConfigurationDelegate.Creating_source_locator..._2\")); \n\t\tsetDefaultSourceLocator(launch, configuration);\n\t\tmonitor.worked(1);\t\t\n\t\trunner.run(runConfig, launch, monitor);\n\t\tif (monitor.isCanceled()) {\n\t\t\treturn;\n\t\t}\t\n\t\tmonitor.done();\n\t}\t\n"} {"input": " public void read(ByteBuffer byteBuffer) throws Exception {\n int readByte = byteBuffer.remaining();\n invalidateBuffer();\n if (buffer.length() > 1048576) {\n throw new Exception(\"Stopped parsing never ending stanza\");\n }\n CharBuffer charBuffer = encoder.decode(byteBuffer.buf());\n char[] buf = charBuffer.array();\n buffer.append(buf);\n if (' ' == buffer.charAt(0) && ' ' == buffer.charAt(buffer.length()-1)) {\n if (\"\".equals(buffer.toString().trim())) {\n buffer.delete(0, buffer.length());\n return;\n }\n }\n char ch;\n for (int i = 0; i < readByte; i++) {\n ch = buf[i];\n if (status == XMLLightweightParser.TAIL) {\n if (depth < 1 && ch == head.charAt(tailCount)) {\n tailCount++;\n if (tailCount == head.length()) {\n int end = buffer.length() - readByte + (i + 1);\n String msg = buffer.substring(startLastMsg, end);\n foundMsg(msg);\n startLastMsg = end;\n }\n } else {\n tailCount = 0;\n status = XMLLightweightParser.INSIDE;\n }\n } else if (status == XMLLightweightParser.PRETAIL) {\n if (ch == XMLLightweightParser.CDATA_START[cdataOffset]) {\n cdataOffset++;\n if (cdataOffset == XMLLightweightParser.CDATA_START.length) {\n status = XMLLightweightParser.INSIDE_CDATA;\n cdataOffset = 0;\n continue;\n }\n } else {\n cdataOffset = 0;\n status = XMLLightweightParser.INSIDE;\n }\n if (ch == '/') {\n status = XMLLightweightParser.TAIL;\n depth--;\n }\n else if (ch == '!') {\n status = XMLLightweightParser.INSIDE;\n }\n else {\n depth++;\n }\n } else if (status == XMLLightweightParser.VERIFY_CLOSE_TAG) {\n if (ch == '>') {\n depth--;\n status = XMLLightweightParser.OUTSIDE;\n if (depth < 1) {\n int end = buffer.length() - readByte + (i + 1);\n String msg = buffer.substring(startLastMsg, end);\n foundMsg(msg);\n startLastMsg = end;\n } \n } else if (ch == '<') {\n status = XMLLightweightParser.PRETAIL;\n insideChildrenTag = true;\n } else {\n status = XMLLightweightParser.INSIDE;\n }\n } else if (status == XMLLightweightParser.INSIDE_PARAM_VALUE) {\n if (ch == '\"') {\n status = XMLLightweightParser.INSIDE;\n }\n } else if (status == XMLLightweightParser.INSIDE_CDATA) {\n if (ch == XMLLightweightParser.CDATA_END[cdataOffset]) {\n cdataOffset++;\n if (cdataOffset == XMLLightweightParser.CDATA_END.length) {\n status = XMLLightweightParser.OUTSIDE;\n cdataOffset = 0;\n }\n } else {\n cdataOffset = 0;\n }\n } else if (status == XMLLightweightParser.INSIDE) {\n if (ch == XMLLightweightParser.CDATA_START[cdataOffset]) {\n cdataOffset++;\n if (cdataOffset == XMLLightweightParser.CDATA_START.length) {\n status = XMLLightweightParser.INSIDE_CDATA;\n cdataOffset = 0;\n continue;\n }\n } else {\n cdataOffset = 0;\n status = XMLLightweightParser.INSIDE;\n }\n if (ch == '\"') {\n status = XMLLightweightParser.INSIDE_PARAM_VALUE;\n } else if (ch == '>') {\n status = XMLLightweightParser.OUTSIDE;\n if (insideRootTag && (\"stream:stream>\".equals(head.toString()) ||\n (\"?xml>\".equals(head.toString())) || (\"flash:stream>\".equals(head.toString())))) {\n int end = buffer.length() - readByte + (i + 1);\n while (startLastMsg < end && '<' != buffer.charAt(startLastMsg)) {\n startLastMsg++;\n }\n String msg = buffer.substring(startLastMsg, end);\n foundMsg(msg);\n startLastMsg = end;\n }\n insideRootTag = false;\n } else if (ch == '/') {\n status = XMLLightweightParser.VERIFY_CLOSE_TAG;\n }\n } else if (status == XMLLightweightParser.HEAD) {\n if (ch == ' ' || ch == '>') {\n head.append(\">\");\n if(ch == '>')\n status = XMLLightweightParser.OUTSIDE;\n else\n status = XMLLightweightParser.INSIDE;\n insideRootTag = true;\n insideChildrenTag = false;\n continue;\n }\n else if (ch == '/' && head.length() > 0) {\n status = XMLLightweightParser.VERIFY_CLOSE_TAG;\n depth--;\n }\n head.append(ch);\n } else if (status == XMLLightweightParser.INIT) {\n if (ch == '<') {\n status = XMLLightweightParser.HEAD;\n depth = 1;\n }\n else {\n startLastMsg++;\n }\n } else if (status == XMLLightweightParser.OUTSIDE) {\n if (ch == '<') {\n status = XMLLightweightParser.PRETAIL;\n cdataOffset = 1;\n insideChildrenTag = true;\n }\n }\n }\n if (head.length() > 0 &&\n (\"/stream:stream>\".equals(head.toString()) || (\"/flash:stream>\".equals(head.toString())))) {\n foundMsg(\"\");\n }\n }\n", "output": " public void read(ByteBuffer byteBuffer) throws Exception {\n int readByte = byteBuffer.remaining();\n invalidateBuffer();\n if (buffer.length() > 1048576) {\n throw new Exception(\"Stopped parsing never ending stanza\");\n }\n CharBuffer charBuffer = encoder.decode(byteBuffer.buf());\n char[] buf = charBuffer.array();\n buffer.append(buf);\n if (buffer.charAt(0) <= ' ' && buffer.charAt(buffer.length()-1) <= ' ') {\n if (\"\".equals(buffer.toString().trim())) {\n buffer.delete(0, buffer.length());\n return;\n }\n }\n char ch;\n for (int i = 0; i < readByte; i++) {\n ch = buf[i];\n if (status == XMLLightweightParser.TAIL) {\n if (depth < 1 && ch == head.charAt(tailCount)) {\n tailCount++;\n if (tailCount == head.length()) {\n int end = buffer.length() - readByte + (i + 1);\n String msg = buffer.substring(startLastMsg, end);\n foundMsg(msg);\n startLastMsg = end;\n }\n } else {\n tailCount = 0;\n status = XMLLightweightParser.INSIDE;\n }\n } else if (status == XMLLightweightParser.PRETAIL) {\n if (ch == XMLLightweightParser.CDATA_START[cdataOffset]) {\n cdataOffset++;\n if (cdataOffset == XMLLightweightParser.CDATA_START.length) {\n status = XMLLightweightParser.INSIDE_CDATA;\n cdataOffset = 0;\n continue;\n }\n } else {\n cdataOffset = 0;\n status = XMLLightweightParser.INSIDE;\n }\n if (ch == '/') {\n status = XMLLightweightParser.TAIL;\n depth--;\n }\n else if (ch == '!') {\n status = XMLLightweightParser.INSIDE;\n }\n else {\n depth++;\n }\n } else if (status == XMLLightweightParser.VERIFY_CLOSE_TAG) {\n if (ch == '>') {\n depth--;\n status = XMLLightweightParser.OUTSIDE;\n if (depth < 1) {\n int end = buffer.length() - readByte + (i + 1);\n String msg = buffer.substring(startLastMsg, end);\n foundMsg(msg);\n startLastMsg = end;\n } \n } else if (ch == '<') {\n status = XMLLightweightParser.PRETAIL;\n insideChildrenTag = true;\n } else {\n status = XMLLightweightParser.INSIDE;\n }\n } else if (status == XMLLightweightParser.INSIDE_PARAM_VALUE) {\n if (ch == '\"') {\n status = XMLLightweightParser.INSIDE;\n }\n } else if (status == XMLLightweightParser.INSIDE_CDATA) {\n if (ch == XMLLightweightParser.CDATA_END[cdataOffset]) {\n cdataOffset++;\n if (cdataOffset == XMLLightweightParser.CDATA_END.length) {\n status = XMLLightweightParser.OUTSIDE;\n cdataOffset = 0;\n }\n } else {\n cdataOffset = 0;\n }\n } else if (status == XMLLightweightParser.INSIDE) {\n if (ch == XMLLightweightParser.CDATA_START[cdataOffset]) {\n cdataOffset++;\n if (cdataOffset == XMLLightweightParser.CDATA_START.length) {\n status = XMLLightweightParser.INSIDE_CDATA;\n cdataOffset = 0;\n continue;\n }\n } else {\n cdataOffset = 0;\n status = XMLLightweightParser.INSIDE;\n }\n if (ch == '\"') {\n status = XMLLightweightParser.INSIDE_PARAM_VALUE;\n } else if (ch == '>') {\n status = XMLLightweightParser.OUTSIDE;\n if (insideRootTag && (\"stream:stream>\".equals(head.toString()) ||\n (\"?xml>\".equals(head.toString())) || (\"flash:stream>\".equals(head.toString())))) {\n int end = buffer.length() - readByte + (i + 1);\n while (startLastMsg < end && '<' != buffer.charAt(startLastMsg)) {\n startLastMsg++;\n }\n String msg = buffer.substring(startLastMsg, end);\n foundMsg(msg);\n startLastMsg = end;\n }\n insideRootTag = false;\n } else if (ch == '/') {\n status = XMLLightweightParser.VERIFY_CLOSE_TAG;\n }\n } else if (status == XMLLightweightParser.HEAD) {\n if (ch == ' ' || ch == '>') {\n head.append(\">\");\n if(ch == '>')\n status = XMLLightweightParser.OUTSIDE;\n else\n status = XMLLightweightParser.INSIDE;\n insideRootTag = true;\n insideChildrenTag = false;\n continue;\n }\n else if (ch == '/' && head.length() > 0) {\n status = XMLLightweightParser.VERIFY_CLOSE_TAG;\n depth--;\n }\n head.append(ch);\n } else if (status == XMLLightweightParser.INIT) {\n if (ch == '<') {\n status = XMLLightweightParser.HEAD;\n depth = 1;\n }\n else {\n startLastMsg++;\n }\n } else if (status == XMLLightweightParser.OUTSIDE) {\n if (ch == '<') {\n status = XMLLightweightParser.PRETAIL;\n cdataOffset = 1;\n insideChildrenTag = true;\n }\n }\n }\n if (head.length() > 0 &&\n (\"/stream:stream>\".equals(head.toString()) || (\"/flash:stream>\".equals(head.toString())))) {\n foundMsg(\"\");\n }\n }\n"} {"input": " public String getAttribute(Attribute attribute) {\n if (attribute == null) return null;\n if (attribute.startsWith(\"asint\")\n || attribute.startsWith(\"as_int\"))\n try {\n return new Element(String.valueOf\n (Math.round(Double.valueOf(element))))\n .getAttribute(attribute.fulfill(1)); }\n catch (NumberFormatException e) {\n dB.echoError(\"'\" + element + \"' is not a valid Integer.\");\n return new Element(\"null\").getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"asdouble\")\n || attribute.startsWith(\"as_double\"))\n try { return new Element(String.valueOf(Double.valueOf(element)))\n .getAttribute(attribute.fulfill(1)); }\n catch (NumberFormatException e) {\n dB.echoError(\"'\" + element + \"' is not a valid Double.\");\n return new Element(\"null\").getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"asmoney\")\n || attribute.startsWith(\"as_money\")) {\n try {\n DecimalFormat d = new DecimalFormat(\"0.00\");\n return new Element(String.valueOf(d.format(Double.valueOf(element))))\n .getAttribute(attribute.fulfill(1)); }\n catch (NumberFormatException e) {\n dB.echoError(\"'\" + element + \"' is not a valid Money format.\");\n return new Element(\"null\").getAttribute(attribute.fulfill(1));\n }\n }\n if (attribute.startsWith(\"asboolean\")\n || attribute.startsWith(\"as_boolean\"))\n return new Element(Boolean.valueOf(element).toString())\n .getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"aslist\")\n || attribute.startsWith(\"as_list\"))\n return dList.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"as_entity\")\n || attribute.startsWith(\"as_entity\"))\n return dEntity.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"as_location\")\n || attribute.startsWith(\"as_location\"))\n return dLocation.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asplayer\")\n || attribute.startsWith(\"as_player\"))\n return dPlayer.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asnpc\")\n || attribute.startsWith(\"as_npc\"))\n return dNPC.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asitem\")\n || attribute.startsWith(\"as_item\"))\n return dItem.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asscript\")\n || attribute.startsWith(\"as_script\"))\n return dScript.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asduration\")\n || attribute.startsWith(\"as_duration\"))\n return Duration.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"contains\")) {\n String contains = attribute.getContext(1);\n if (contains.toLowerCase().startsWith(\"regex:\")) {\n if (Pattern.compile(contains.substring((\"regex:\").length()), Pattern.CASE_INSENSITIVE).matcher(element).matches())\n return new Element(\"true\").getAttribute(attribute.fulfill(1));\n else return new Element(\"false\").getAttribute(attribute.fulfill(1));\n }\n else if (element.toLowerCase().contains(contains.toLowerCase()))\n return new Element(\"true\").getAttribute(attribute.fulfill(1));\n else return new Element(\"false\").getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"after\")) {\n String delimiter = attribute.getContext(1);\n return new Element(String.valueOf(element.substring\n (element.indexOf(delimiter) + delimiter.length())))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"before\")) {\n String delimiter = attribute.getContext(1);\n return new Element(String.valueOf(element.substring\n (0, element.indexOf(delimiter))))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"substring\")||attribute.startsWith(\"substr\")) { \n int beginning_index = Integer.valueOf(attribute.getContext(1).split(\",\")[0]) - 1;\n int ending_index;\n if (attribute.getContext(1).split(\",\").length > 1)\n ending_index = Integer.valueOf(attribute.getContext(1).split(\",\")[1]) - 1;\n else\n ending_index = element.length();\n return new Element(String.valueOf(element.substring(beginning_index, ending_index)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"last_color\"))\n return new Element(String.valueOf(ChatColor.getLastColors(element))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"strip_color\"))\n return new Element(String.valueOf(ChatColor.stripColor(element))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"starts_with\") || attribute.startsWith(\"startswith\"))\n return new Element(String.valueOf(element.startsWith(attribute.getContext(1)))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"ends_with\") || attribute.startsWith(\"endswith\"))\n return new Element(String.valueOf(element.endsWith(attribute.getContext(1)))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"split\") && attribute.startsWith(\"limit\", 2)) {\n String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : \" \");\n Integer limit = (attribute.hasContext(2) ? attribute.getIntContext(2) : 1);\n if (split_string.toLowerCase().startsWith(\"regex:\"))\n return new dList(Arrays.asList(element.split(split_string.split(\":\", 2)[1], limit)))\n .getAttribute(attribute.fulfill(1));\n else\n return new dList(Arrays.asList(StringUtils.split(element, split_string, limit)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"split\")) {\n String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : \" \");\n if (split_string.toLowerCase().startsWith(\"regex:\"))\n return new dList(Arrays.asList(element.split(split_string.split(\":\", 2)[1])))\n .getAttribute(attribute.fulfill(1));\n else\n return new dList(Arrays.asList(StringUtils.split(element, split_string)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"sqrt\")) {\n return new Element(Math.sqrt(asDouble()))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"abs\")) {\n return new Element(Math.abs(asDouble()))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"mul\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() * aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"sub\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() - aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"add\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() + aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"div\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() / aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"mod\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() % aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"replace\")\n && attribute.hasContext(1)) {\n String replace = attribute.getContext(1);\n String replacement = \"\";\n if (attribute.startsWith(\"with\", 2)) {\n if (attribute.hasContext(2)) replacement = attribute.getContext(2);\n attribute.fulfill(1);\n }\n return new Element(element.replace(replace, replacement))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"length\")) {\n return new Element(element.length())\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"prefix\"))\n return new Element(prefix)\n .getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"debug.log\")) {\n dB.log(debug());\n return new Element(Boolean.TRUE.toString())\n .getAttribute(attribute.fulfill(2));\n }\n if (attribute.startsWith(\"debug.no_color\")) {\n return new Element(ChatColor.stripColor(debug()))\n .getAttribute(attribute.fulfill(2));\n }\n if (attribute.startsWith(\"debug\")) {\n return new Element(debug())\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.attributes.size() > 0) {\n dB.echoError(\"Unfilled attributes '\" + attribute.attributes.toString() + \"'\" +\n \"for tag <\" + attribute.getOrigin() + \">!\");\n return \"null\";\n } else {\n dB.log(\"Filled tag <\" + attribute.getOrigin() + \"> with '\" + element + \"'.\");\n return element;\n }\n }\n", "output": " public String getAttribute(Attribute attribute) {\n if (attribute == null) return null;\n if (attribute.startsWith(\"asint\")\n || attribute.startsWith(\"as_int\"))\n try {\n return new Element(String.valueOf\n (Math.round(Double.valueOf(element))))\n .getAttribute(attribute.fulfill(1)); }\n catch (NumberFormatException e) {\n dB.echoError(\"'\" + element + \"' is not a valid Integer.\");\n return new Element(\"null\").getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"asdouble\")\n || attribute.startsWith(\"as_double\"))\n try { return new Element(String.valueOf(Double.valueOf(element)))\n .getAttribute(attribute.fulfill(1)); }\n catch (NumberFormatException e) {\n dB.echoError(\"'\" + element + \"' is not a valid Double.\");\n return new Element(\"null\").getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"asmoney\")\n || attribute.startsWith(\"as_money\")) {\n try {\n DecimalFormat d = new DecimalFormat(\"0.00\");\n return new Element(String.valueOf(d.format(Double.valueOf(element))))\n .getAttribute(attribute.fulfill(1)); }\n catch (NumberFormatException e) {\n dB.echoError(\"'\" + element + \"' is not a valid Money format.\");\n return new Element(\"null\").getAttribute(attribute.fulfill(1));\n }\n }\n if (attribute.startsWith(\"asboolean\")\n || attribute.startsWith(\"as_boolean\"))\n return new Element(Boolean.valueOf(element).toString())\n .getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"aslist\")\n || attribute.startsWith(\"as_list\"))\n return dList.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asentity\")\n || attribute.startsWith(\"as_entity\"))\n return dEntity.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"aslocation\")\n || attribute.startsWith(\"as_location\"))\n return dLocation.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asplayer\")\n || attribute.startsWith(\"as_player\"))\n return dPlayer.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asnpc\")\n || attribute.startsWith(\"as_npc\"))\n return dNPC.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asitem\")\n || attribute.startsWith(\"as_item\"))\n return dItem.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asscript\")\n || attribute.startsWith(\"as_script\"))\n return dScript.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"asduration\")\n || attribute.startsWith(\"as_duration\"))\n return Duration.valueOf(element).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"contains\")) {\n String contains = attribute.getContext(1);\n if (contains.toLowerCase().startsWith(\"regex:\")) {\n if (Pattern.compile(contains.substring((\"regex:\").length()), Pattern.CASE_INSENSITIVE).matcher(element).matches())\n return new Element(\"true\").getAttribute(attribute.fulfill(1));\n else return new Element(\"false\").getAttribute(attribute.fulfill(1));\n }\n else if (element.toLowerCase().contains(contains.toLowerCase()))\n return new Element(\"true\").getAttribute(attribute.fulfill(1));\n else return new Element(\"false\").getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"after\")) {\n String delimiter = attribute.getContext(1);\n return new Element(String.valueOf(element.substring\n (element.indexOf(delimiter) + delimiter.length())))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"before\")) {\n String delimiter = attribute.getContext(1);\n return new Element(String.valueOf(element.substring\n (0, element.indexOf(delimiter))))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"substring\")||attribute.startsWith(\"substr\")) { \n int beginning_index = Integer.valueOf(attribute.getContext(1).split(\",\")[0]) - 1;\n int ending_index;\n if (attribute.getContext(1).split(\",\").length > 1)\n ending_index = Integer.valueOf(attribute.getContext(1).split(\",\")[1]) - 1;\n else\n ending_index = element.length();\n return new Element(String.valueOf(element.substring(beginning_index, ending_index)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"last_color\"))\n return new Element(String.valueOf(ChatColor.getLastColors(element))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"strip_color\"))\n return new Element(String.valueOf(ChatColor.stripColor(element))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"starts_with\") || attribute.startsWith(\"startswith\"))\n return new Element(String.valueOf(element.startsWith(attribute.getContext(1)))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"ends_with\") || attribute.startsWith(\"endswith\"))\n return new Element(String.valueOf(element.endsWith(attribute.getContext(1)))).getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"split\") && attribute.startsWith(\"limit\", 2)) {\n String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : \" \");\n Integer limit = (attribute.hasContext(2) ? attribute.getIntContext(2) : 1);\n if (split_string.toLowerCase().startsWith(\"regex:\"))\n return new dList(Arrays.asList(element.split(split_string.split(\":\", 2)[1], limit)))\n .getAttribute(attribute.fulfill(1));\n else\n return new dList(Arrays.asList(StringUtils.split(element, split_string, limit)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"split\")) {\n String split_string = (attribute.hasContext(1) ? attribute.getContext(1) : \" \");\n if (split_string.toLowerCase().startsWith(\"regex:\"))\n return new dList(Arrays.asList(element.split(split_string.split(\":\", 2)[1])))\n .getAttribute(attribute.fulfill(1));\n else\n return new dList(Arrays.asList(StringUtils.split(element, split_string)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"sqrt\")) {\n return new Element(Math.sqrt(asDouble()))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"abs\")) {\n return new Element(Math.abs(asDouble()))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"mul\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() * aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"sub\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() - aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"add\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() + aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"div\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() / aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"mod\")\n && attribute.hasContext(1)) {\n return new Element(asDouble() % aH.getDoubleFrom(attribute.getContext(1)))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"replace\")\n && attribute.hasContext(1)) {\n String replace = attribute.getContext(1);\n String replacement = \"\";\n if (attribute.startsWith(\"with\", 2)) {\n if (attribute.hasContext(2)) replacement = attribute.getContext(2);\n attribute.fulfill(1);\n }\n return new Element(element.replace(replace, replacement))\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"length\")) {\n return new Element(element.length())\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.startsWith(\"prefix\"))\n return new Element(prefix)\n .getAttribute(attribute.fulfill(1));\n if (attribute.startsWith(\"debug.log\")) {\n dB.log(debug());\n return new Element(Boolean.TRUE.toString())\n .getAttribute(attribute.fulfill(2));\n }\n if (attribute.startsWith(\"debug.no_color\")) {\n return new Element(ChatColor.stripColor(debug()))\n .getAttribute(attribute.fulfill(2));\n }\n if (attribute.startsWith(\"debug\")) {\n return new Element(debug())\n .getAttribute(attribute.fulfill(1));\n }\n if (attribute.attributes.size() > 0) {\n dB.echoError(\"Unfilled attributes '\" + attribute.attributes.toString() + \"'\" +\n \"for tag <\" + attribute.getOrigin() + \">!\");\n return \"null\";\n } else {\n dB.log(\"Filled tag <\" + attribute.getOrigin() + \"> with '\" + element + \"'.\");\n return element;\n }\n }\n"} {"input": "\tpublic void init(Properties configuration) {\n\t\tif ((getState() & (Bundle.ACTIVE | Bundle.STARTING)) != 0)\n\t\t\tthrow new IllegalStateException(\"Framework is active!!\");\n\t\tsynchronized (this) {\n\t\t\tif (impl != null && impl.getState() != Bundle.INSTALLED) {\n\t\t\t\ttry {\n\t\t\t\t\timpl.stop();\n\t\t\t\t\timpl.waitForStop(30000); \n\t\t\t\t} catch (BundleException e) {\n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t}\n\t\t\t\timpl = null;\n\t\t\t}\n\t\t}\n\t\tgetImpl().init(configuration);\n\t}\n", "output": "\tpublic void init(Properties configuration) {\n\t\tif ((getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING)) != 0)\n\t\t\tthrow new IllegalStateException(\"Framework is active!!\");\n\t\tsynchronized (this) {\n\t\t\tif (impl != null && impl.getState() != Bundle.INSTALLED) {\n\t\t\t\ttry {\n\t\t\t\t\timpl.stop();\n\t\t\t\t\timpl.waitForStop(30000); \n\t\t\t\t} catch (BundleException e) {\n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t}\n\t\t\t\timpl = null;\n\t\t\t}\n\t\t}\n\t\tgetImpl().init(configuration);\n\t}\n"} {"input": "\tpublic void onCollideWithParticle(BaseParticle particle) {\n\t\tif(!(particle instanceof LeafParticle)){\n\t\t\tparticle.potential*=0.5;\n\t\t\tparticle.effect=2;\n\t\t}\n\t}\n", "output": "\tpublic void onCollideWithParticle(BaseParticle particle) {\n\t\tif((!(particle instanceof LeafParticle))&&particle.effect!=2){\n\t\t\tparticle.potential*=0.5;\n\t\t\tparticle.effect=2;\n\t\t}\n\t}\n"} {"input": " private TCPSniffer(String[] args)\n {\n\tSnifferFilter requestFilter = new EchoFilter();\n\tSnifferFilter responseFilter = new EchoFilter();\n\tint localPort = 8001;\n\tString remoteHost = \"localhost\";\n\tString localHost = \"localhost\";\n\tint remotePort = 7001;\n\tboolean useSSL = false;\n\tboolean proxy = false;\n\tint initialTest = 0;\n\tint timeout = 0; \n\tboolean useColour = false;\n\ttry {\n\t for (int i=0; i < args.length; i++)\n\t {\n\t\tif (args[i].equals(\"-initialTest\")) {\n\t\t initialTest = Integer.parseInt(args[++i]);\n\t\t}\n\t }\n\t System.setProperty(INITIAL_TEST_PROPERTY,\n\t\t\t Integer.toString(initialTest));\n\t for (int i=0; i 0 && port.length() > 0 && password.length() > 0) {\n\t\t\t\t\tString pyWaUrl = host + \":\" + port + \"/dl.pywa?pass=\" + password + \"&site=whatcd&id=\" + torrentId;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tMySoup.scrapeOther(pyWaUrl);\n\t\t\t\t\t\tToast.makeText(TorrentFormatsActivity.this, \"Torrent sent\", Toast.LENGTH_SHORT).show();\n\t\t\t\t\t} catch (CouldNotLoadException e) {\n\t\t\t\t\t\tToast.makeText(TorrentFormatsActivity.this, \"Could not send torrent\", Toast.LENGTH_SHORT).show();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tToast.makeText(TorrentFormatsActivity.this, \"Fill out pyWA information in Settings\", Toast.LENGTH_LONG)\n\t\t\t\t\t\t\t.show();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\talert.setButton(AlertDialog.BUTTON2, \"Cancel\", new DialogInterface.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\tdialog.dismiss();\n\t\t\t}\n\t\t});\n\t\talert.setCancelable(true);\n\t\talert.show();\n\t}\n", "output": "\tprivate void showDownloadDialog(final String torrentId, final String url) {\n\t\tAlertDialog alert = new AlertDialog.Builder(TorrentFormatsActivity.this).create();\n\t\talert.setButton(AlertDialog.BUTTON1, \"Download\", new DialogInterface.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\tintent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));\n\t\t\t\tstartActivity(intent);\n\t\t\t}\n\t\t});\n\t\talert.setButton(AlertDialog.BUTTON3, \"Send to pyWA\", new DialogInterface.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\tString host = Settings.getHostPreference();\n\t\t\t\tString port = Settings.getPortPreference();\n\t\t\t\tString password = Settings.getPasswordPreference();\n\t\t\t\tif ((host.length() > 0) && (port.length() > 0) && (password.length() > 0)) {\n\t\t\t\t\tString pyWaUrl = host + \":\" + port + \"/dl.pywa?pass=\" + password + \"&site=whatcd&id=\" + torrentId;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tMySoup.scrapeOther(pyWaUrl);\n\t\t\t\t\t\tToast.makeText(TorrentFormatsActivity.this, \"Torrent sent\", Toast.LENGTH_SHORT).show();\n\t\t\t\t\t} catch (CouldNotLoadException e) {\n\t\t\t\t\t\tToast.makeText(TorrentFormatsActivity.this, \"Could not send torrent\", Toast.LENGTH_SHORT).show();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tToast.makeText(TorrentFormatsActivity.this, \"Fill out pyWA information in Settings\", Toast.LENGTH_LONG)\n\t\t\t\t\t\t\t.show();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\talert.setButton(AlertDialog.BUTTON2, \"Cancel\", new DialogInterface.OnClickListener() {\n\t\t\t@Override\n\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\tdialog.dismiss();\n\t\t\t}\n\t\t});\n\t\talert.setCancelable(true);\n\t\talert.show();\n\t}\n"} {"input": "\tprivate void ingestSurveyInstance(SurveyInstance instance) {\n\t\tSurveyedLocale locale = null;\n\t\tif (instance != null) {\n\t\t\tList answers = surveyInstanceDao\n\t\t\t\t\t.listQuestionAnswerStore(instance.getKey().getId(), null);\n\t\t\tQuestionAnswerStore geoQ = null;\n\t\t\tSurveyDAO surveyDao = new SurveyDAO();\n\t\t\tSurvey survey = surveyDao.getByKey(instance.getSurveyId());\n\t\t\tString pointType = null;\n\t\t\tif (survey != null) {\n\t\t\t\tpointType = survey.getPointType();\n\t\t\t}\n\t\t\tif (answers != null) {\n\t\t\t\tfor (QuestionAnswerStore q : answers) {\n\t\t\t\t\tif (QuestionType.GEO.toString().equals(q.getType())) {\n\t\t\t\t\t\tgeoQ = q;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (instance.getSurveyedLocaleId() != null) {\n\t\t\t\tlocale = surveyedLocaleDao.getByKey(instance\n\t\t\t\t\t\t.getSurveyedLocaleId());\n\t\t\t}\n\t\t\tGeoPlace geoPlace = null;\n\t\t\tif (geoQ != null && geoQ.getValue() != null) {\n\t\t\t\tdouble lat = UNSET_VAL;\n\t\t\t\tdouble lon = UNSET_VAL;\n\t\t\t\tboolean ambiguousFlag = false;\n\t\t\t\tString code = null;\n\t\t\t\tString[] tokens = geoQ.getValue().split(\"\\\\|\");\n\t\t\t\tif (tokens.length >= 2) {\n\t\t\t\t\tlat = Double.parseDouble(tokens[0]);\n\t\t\t\t\tlon = Double.parseDouble(tokens[1]);\n\t\t\t\t\tif (tokens.length >= 4) {\n\t\t\t\t\t\tcode = tokens[tokens.length - 1];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (code == null) {\n\t\t\t\t\tLong codeNum = Long\n\t\t\t\t\t\t\t.parseLong((int) ((Math.abs(lat) * 10000d)) + \"\"\n\t\t\t\t\t\t\t\t\t+ (int) ((Math.abs(lon) * 10000d)));\n\t\t\t\t\tcode = Long.toString(codeNum, 36);\n\t\t\t\t}\n\t\t\t\tif (lat == UNSET_VAL || lon == UNSET_VAL) {\n\t\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\t\"Could not parse lat/lon from Geo Question \"\n\t\t\t\t\t\t\t\t\t+ geoQ.getQuestionID());\n\t\t\t\t} else if (mergeNearby && locale == null) {\n\t\t\t\t\tList candidates = surveyedLocaleDao\n\t\t\t\t\t\t\t.listLocalesByCoordinates(pointType, lat, lon,\n\t\t\t\t\t\t\t\t\tTOLERANCE);\n\t\t\t\t\tif (candidates != null && candidates.size() == 1) {\n\t\t\t\t\t\tlocale = candidates.get(0);\n\t\t\t\t\t} else if (candidates != null && candidates.size() > 1) {\n\t\t\t\t\t\tlog.log(Level.WARNING,\n\t\t\t\t\t\t\t\t\"Geo based lookup of surveyed locale returned more than one candidate so we are creating a new one\");\n\t\t\t\t\t\tambiguousFlag = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgeoPlace = getGeoPlace(lat, lon);\n\t\t\t\tif (locale == null) {\n\t\t\t\t\tlocale = new SurveyedLocale();\n\t\t\t\t\tlocale.setAmbiguous(ambiguousFlag);\n\t\t\t\t\tlocale.setLatitude(lat);\n\t\t\t\t\tlocale.setLongitude(lon);\n\t\t\t\t\tsetGeoData(geoPlace, locale);\n\t\t\t\t\tif (survey != null) {\n\t\t\t\t\t\tlocale.setLocaleType(survey.getPointType());\n\t\t\t\t\t}\n\t\t\t\t\tlocale.setIdentifier(code);\n\t\t\t\t\tif (locale.getOrganization() == null) {\n\t\t\t\t\t\tlocale.setOrganization(PropertyUtil\n\t\t\t\t\t\t\t\t.getProperty(DEFAULT_ORG_PROP));\n\t\t\t\t\t}\n\t\t\t\t\tlocale = surveyedLocaleDao.save(locale);\n\t\t\t\t} else {\n\t\t\t\t\tif (survey.getPointType() != null\n\t\t\t\t\t\t\t&& !survey.getPointType().equals(\n\t\t\t\t\t\t\t\t\tlocale.getLocaleType())) {\n\t\t\t\t\t\tlocale.setLocaleType(survey.getPointType());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (instance != null && geoPlace != null) {\n\t\t\t\tinstance.setCountryCode(geoPlace.getCountryCode());\n\t\t\t\tinstance.setSublevel1(geoPlace.getSub1());\n\t\t\t\tinstance.setSublevel2(geoPlace.getSub2());\n\t\t\t\tinstance.setSublevel3(geoPlace.getSub3());\n\t\t\t\tinstance.setSublevel4(geoPlace.getSub4());\n\t\t\t\tinstance.setSublevel5(geoPlace.getSub5());\n\t\t\t\tinstance.setSublevel6(geoPlace.getSub6());\n\t\t\t\tif (answers != null) {\n\t\t\t\t\tList metrics = metricDao.listMetrics(\n\t\t\t\t\t\t\tCOMMUNITY_METRIC_NAME, null, null, null, null);\n\t\t\t\t\tif (metrics != null) {\n\t\t\t\t\t\tList mappings = new ArrayList();\n\t\t\t\t\t\tfor (Metric m : metrics) {\n\t\t\t\t\t\t\tList temp = metricMappingDao\n\t\t\t\t\t\t\t\t\t.listMetricsBySurveyAndMetric(m.getKey()\n\t\t\t\t\t\t\t\t\t\t\t.getId(), instance.getSurveyId());\n\t\t\t\t\t\t\tif (temp != null) {\n\t\t\t\t\t\t\t\tmappings.addAll(temp);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (SurveyMetricMapping mapping : mappings) {\n\t\t\t\t\t\t\tfor (QuestionAnswerStore ans : answers) {\n\t\t\t\t\t\t\t\tif (ans.getQuestionID().equals(\n\t\t\t\t\t\t\t\t\t\tmapping.getSurveyQuestionId().toString())) {\n\t\t\t\t\t\t\t\t\tinstance.setCommunity(ans.getValue());\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (locale != null && locale.getKey() != null && answers != null) {\n\t\t\t\tlocale.setLastSurveyedDate(instance.getCollectionDate());\n\t\t\t\tlocale.setLastSurveyalInstanceId(instance.getKey().getId());\n\t\t\t\tinstance.setSurveyedLocaleId(locale.getKey().getId());\n\t\t\t\tList values = constructValues(locale, answers);\n\t\t\t\tif (values != null) {\n\t\t\t\t\tsurveyedLocaleDao.save(values);\n\t\t\t\t\tif (!useConfigStatusScore) {\n\t\t\t\t\t\tboolean found = false;\n\t\t\t\t\t\tfor (SurveyalValue val : values) {\n\t\t\t\t\t\t\tif (isStatus(val.getMetricName())\n\t\t\t\t\t\t\t\t\t&& val.getStringValue() != null) {\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\tlocale.setCurrentStatus(val.getStringValue());\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\tfor (SurveyalValue val : values) {\n\t\t\t\t\t\t\t\tif (isStatus(val.getQuestionText())\n\t\t\t\t\t\t\t\t\t\t&& val.getStringValue() != null) {\n\t\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\t\tlocale.setCurrentStatus(val\n\t\t\t\t\t\t\t\t\t\t\t.getStringValue());\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (useDynamicScoring) {\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (SurveyalValue val : values) {\n\t\t\t\t\t\t\tif (val.getQuestionText() != null\n\t\t\t\t\t\t\t\t\t&& val.getQuestionText().toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t.contains(statusFragment)) {\n\t\t\t\t\t\t\t\tString scoredField = scoredVals.get(val\n\t\t\t\t\t\t\t\t\t\t.getStringValue());\n\t\t\t\t\t\t\t\tif (scoredField == null) {\n\t\t\t\t\t\t\t\t\tscoredField = scoredVals.get(DEFAULT);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlocale.setCurrentStatus(scoredField);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void ingestSurveyInstance(SurveyInstance instance) {\n\t\tSurveyedLocale locale = null;\n\t\tif (instance != null) {\n\t\t\tList answers = surveyInstanceDao\n\t\t\t\t\t.listQuestionAnswerStore(instance.getKey().getId(), null);\n\t\t\tQuestionAnswerStore geoQ = null;\n\t\t\tSurveyDAO surveyDao = new SurveyDAO();\n\t\t\tSurvey survey = surveyDao.getByKey(instance.getSurveyId());\n\t\t\tString pointType = null;\n\t\t\tif (survey != null) {\n\t\t\t\tpointType = survey.getPointType();\n\t\t\t}\n\t\t\tif (answers != null) {\n\t\t\t\tfor (QuestionAnswerStore q : answers) {\n\t\t\t\t\tif (QuestionType.GEO.toString().equals(q.getType())) {\n\t\t\t\t\t\tgeoQ = q;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (instance.getSurveyedLocaleId() != null) {\n\t\t\t\tlocale = surveyedLocaleDao.getByKey(instance\n\t\t\t\t\t\t.getSurveyedLocaleId());\n\t\t\t}\n\t\t\tGeoPlace geoPlace = null;\n\t\t\tif (geoQ != null && geoQ.getValue() != null && geoQ.getValue().length() > 0) {\n\t\t\t\tdouble lat = UNSET_VAL;\n\t\t\t\tdouble lon = UNSET_VAL;\n\t\t\t\tboolean ambiguousFlag = false;\n\t\t\t\tString code = null;\n\t\t\t\tString[] tokens = geoQ.getValue().split(\"\\\\|\");\n\t\t\t\tif (tokens.length >= 2) {\n\t\t\t\t\tlat = Double.parseDouble(tokens[0]);\n\t\t\t\t\tlon = Double.parseDouble(tokens[1]);\n\t\t\t\t\tif (tokens.length >= 4) {\n\t\t\t\t\t\tcode = tokens[tokens.length - 1];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (code == null) {\n\t\t\t\t\tLong codeNum = Long\n\t\t\t\t\t\t\t.parseLong((int) ((Math.abs(lat) * 10000d)) + \"\"\n\t\t\t\t\t\t\t\t\t+ (int) ((Math.abs(lon) * 10000d)));\n\t\t\t\t\tcode = Long.toString(codeNum, 36);\n\t\t\t\t}\n\t\t\t\tif (lat == UNSET_VAL || lon == UNSET_VAL) {\n\t\t\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\t\t\"Could not parse lat/lon from Geo Question \"\n\t\t\t\t\t\t\t\t\t+ geoQ.getQuestionID());\n\t\t\t\t} else if (mergeNearby && locale == null) {\n\t\t\t\t\tList candidates = surveyedLocaleDao\n\t\t\t\t\t\t\t.listLocalesByCoordinates(pointType, lat, lon,\n\t\t\t\t\t\t\t\t\tTOLERANCE);\n\t\t\t\t\tif (candidates != null && candidates.size() == 1) {\n\t\t\t\t\t\tlocale = candidates.get(0);\n\t\t\t\t\t} else if (candidates != null && candidates.size() > 1) {\n\t\t\t\t\t\tlog.log(Level.WARNING,\n\t\t\t\t\t\t\t\t\"Geo based lookup of surveyed locale returned more than one candidate so we are creating a new one\");\n\t\t\t\t\t\tambiguousFlag = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tgeoPlace = getGeoPlace(lat, lon);\n\t\t\t\tif (locale == null) {\n\t\t\t\t\tlocale = new SurveyedLocale();\n\t\t\t\t\tlocale.setAmbiguous(ambiguousFlag);\n\t\t\t\t\tlocale.setLatitude(lat);\n\t\t\t\t\tlocale.setLongitude(lon);\n\t\t\t\t\tsetGeoData(geoPlace, locale);\n\t\t\t\t\tif (survey != null) {\n\t\t\t\t\t\tlocale.setLocaleType(survey.getPointType());\n\t\t\t\t\t}\n\t\t\t\t\tlocale.setIdentifier(code);\n\t\t\t\t\tif (locale.getOrganization() == null) {\n\t\t\t\t\t\tlocale.setOrganization(PropertyUtil\n\t\t\t\t\t\t\t\t.getProperty(DEFAULT_ORG_PROP));\n\t\t\t\t\t}\n\t\t\t\t\tlocale = surveyedLocaleDao.save(locale);\n\t\t\t\t} else {\n\t\t\t\t\tif (survey.getPointType() != null\n\t\t\t\t\t\t\t&& !survey.getPointType().equals(\n\t\t\t\t\t\t\t\t\tlocale.getLocaleType())) {\n\t\t\t\t\t\tlocale.setLocaleType(survey.getPointType());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (instance != null && geoPlace != null) {\n\t\t\t\tinstance.setCountryCode(geoPlace.getCountryCode());\n\t\t\t\tinstance.setSublevel1(geoPlace.getSub1());\n\t\t\t\tinstance.setSublevel2(geoPlace.getSub2());\n\t\t\t\tinstance.setSublevel3(geoPlace.getSub3());\n\t\t\t\tinstance.setSublevel4(geoPlace.getSub4());\n\t\t\t\tinstance.setSublevel5(geoPlace.getSub5());\n\t\t\t\tinstance.setSublevel6(geoPlace.getSub6());\n\t\t\t\tif (answers != null) {\n\t\t\t\t\tList metrics = metricDao.listMetrics(\n\t\t\t\t\t\t\tCOMMUNITY_METRIC_NAME, null, null, null, null);\n\t\t\t\t\tif (metrics != null) {\n\t\t\t\t\t\tList mappings = new ArrayList();\n\t\t\t\t\t\tfor (Metric m : metrics) {\n\t\t\t\t\t\t\tList temp = metricMappingDao\n\t\t\t\t\t\t\t\t\t.listMetricsBySurveyAndMetric(m.getKey()\n\t\t\t\t\t\t\t\t\t\t\t.getId(), instance.getSurveyId());\n\t\t\t\t\t\t\tif (temp != null) {\n\t\t\t\t\t\t\t\tmappings.addAll(temp);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (SurveyMetricMapping mapping : mappings) {\n\t\t\t\t\t\t\tfor (QuestionAnswerStore ans : answers) {\n\t\t\t\t\t\t\t\tif (ans.getQuestionID().equals(\n\t\t\t\t\t\t\t\t\t\tmapping.getSurveyQuestionId().toString())) {\n\t\t\t\t\t\t\t\t\tinstance.setCommunity(ans.getValue());\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (locale != null && locale.getKey() != null && answers != null) {\n\t\t\t\tlocale.setLastSurveyedDate(instance.getCollectionDate());\n\t\t\t\tlocale.setLastSurveyalInstanceId(instance.getKey().getId());\n\t\t\t\tinstance.setSurveyedLocaleId(locale.getKey().getId());\n\t\t\t\tList values = constructValues(locale, answers);\n\t\t\t\tif (values != null) {\n\t\t\t\t\tsurveyedLocaleDao.save(values);\n\t\t\t\t\tif (!useConfigStatusScore) {\n\t\t\t\t\t\tboolean found = false;\n\t\t\t\t\t\tfor (SurveyalValue val : values) {\n\t\t\t\t\t\t\tif (isStatus(val.getMetricName())\n\t\t\t\t\t\t\t\t\t&& val.getStringValue() != null) {\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\tlocale.setCurrentStatus(val.getStringValue());\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\tfor (SurveyalValue val : values) {\n\t\t\t\t\t\t\t\tif (isStatus(val.getQuestionText())\n\t\t\t\t\t\t\t\t\t\t&& val.getStringValue() != null) {\n\t\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\t\tlocale.setCurrentStatus(val\n\t\t\t\t\t\t\t\t\t\t\t.getStringValue());\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (useDynamicScoring) {\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (SurveyalValue val : values) {\n\t\t\t\t\t\t\tif (val.getQuestionText() != null\n\t\t\t\t\t\t\t\t\t&& val.getQuestionText().toLowerCase()\n\t\t\t\t\t\t\t\t\t\t\t.contains(statusFragment)) {\n\t\t\t\t\t\t\t\tString scoredField = scoredVals.get(val\n\t\t\t\t\t\t\t\t\t\t.getStringValue());\n\t\t\t\t\t\t\t\tif (scoredField == null) {\n\t\t\t\t\t\t\t\t\tscoredField = scoredVals.get(DEFAULT);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlocale.setCurrentStatus(scoredField);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": "\tprivate static boolean test2(CommandSender sender, final String[] args)\n\t{\n\t\tPlayer player = (Player) sender;\n\t\ttry\n\t\t{\n\t\t\tplayer.sendMessage(\" \");\n\t\t\tURL doge = new URL(args[0]);\n\t\t\tBufferedImage veryImage = ImageIO.read(doge);\n\t\t\tveryImage = Images.getScaledImage(veryImage, 128, 128);\n\t\t\tif(player.isOp()) Images.convertImageToSchematic(veryImage).generate(player.getLocation());\n\t\t\tplayer.sendMessage(\" \");\n\t\t}\n\t\tcatch(Throwable suchError)\n\t\t{\n\t\t\tplayer.sendMessage(ChatColor.RED + \"many problems. \" + suchError.getMessage());\n\t\t}\n\t\treturn true;\n\t}\n", "output": "\tprivate static boolean test2(CommandSender sender, final String[] args)\n\t{\n\t\tPlayer player = (Player) sender;\n\t\ttry\n\t\t{\n\t\t\tplayer.sendMessage(\" \");\n\t\t\tURL doge = new URL(args[0]);\n\t\t\tBufferedImage veryImage = ImageIO.read(doge);\n\t\t\tveryImage = Images.getScaledImage(veryImage, 128, 128);\n\t\t\tif(player.isOp()) Images.convertImageToSchematic(veryImage).generate(player.getLocation());\n\t\t\tplayer.sendMessage(\" \");\n\t\t}\n\t\tcatch(Throwable suchError)\n\t\t{\n\t\t\tplayer.sendMessage(ChatColor.RED + \"many problems. \" + suchError.getMessage());\n\t\t\tsuchError.printStackTrace();\n\t\t}\n\t\treturn true;\n\t}\n"} {"input": "\tpublic static DisplayMode setDisplayMode(DisplayMode[] dm, final String[] param) throws Exception {\n\t\tclass Sorter implements Comparator {\n\t\t\tfinal Field[] field;\n\t\t\tfinal int[] order;\n\t\t\tfinal boolean[] usePreferred;\n\t\t\tfinal int[] preferred;\n\t\t\tSorter() throws NoSuchFieldException {\n\t\t\t\tfield = new Field[param.length];\n\t\t\t\torder = new int[param.length];\n\t\t\t\tpreferred = new int[param.length];\n\t\t\t\tusePreferred = new boolean[param.length];\n\t\t\t\tfor (int i = 0; i < field.length; i ++) {\n\t\t\t\t\tint idx = param[i].indexOf('=');\n\t\t\t\t\tif (idx > 0) {\n\t\t\t\t\t\tpreferred[i] = Integer.parseInt(param[i].substring(idx + 1, param[i].length()));\n\t\t\t\t\t\tusePreferred[i] = true;\n\t\t\t\t\t\tparam[i] = param[i].substring(0, idx);\n\t\t\t\t\t\tfield[i] = DisplayMode.class.getDeclaredField(param[i]);\n\t\t\t\t\t} else if (param[i].charAt(0) == '-') {\n\t\t\t\t\t\tfield[i] = DisplayMode.class.getDeclaredField(param[i].substring(1));\n\t\t\t\t\t\torder[i] = -1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfield[i] = DisplayMode.class.getDeclaredField(param[i]);\n\t\t\t\t\t\torder[i] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic int compare(Object o1, Object o2) {\n\t\t\t\tDisplayMode dm1 = (DisplayMode) o1;\n\t\t\t\tDisplayMode dm2 = (DisplayMode) o2;\n\t\t\t\tfor (int i = 0; i < field.length; i ++) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tint f1 = field[i].getInt(dm1);\n\t\t\t\t\t\tint f2 = field[i].getInt(dm2);\n\t\t\t\t\t\tif (usePreferred[i] && f1 != f2) {\n\t\t\t\t\t\t\tif (f1 == preferred[i])\n\t\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t\telse if (f2 == preferred[i])\n\t\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tint absf1 = Math.abs(f1 - preferred[i]);\n\t\t\t\t\t\t\t\tint absf2 = Math.abs(f2 - preferred[i]);\n\t\t\t\t\t\t\t\tif (absf1 < absf2)\n\t\t\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t\t\telse if (absf1 > absf2)\n\t\t\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (f1 < f2)\n\t\t\t\t\t\t\treturn order[i];\n\t\t\t\t\t\telse if (f1 == f2)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\treturn -order[i];\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tassert false : e.getMessage();\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tArrays.sort(dm, new Sorter());\n\t\tif (Sys.DEBUG || DEBUG) {\n\t\t\tSystem.out.println(\"Sorted display modes:\");\n\t\t\tfor (int i = 0; i < dm.length; i ++) {\n\t\t\t\tSystem.out.println(dm[i]);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < dm.length; i ++) {\n\t\t\ttry {\n\t\t\t\tif (Sys.DEBUG || DEBUG)\n\t\t\t\t\tSystem.out.println(\"Attempting to set displaymode: \"+dm[i]);\n\t\t\t\torg.lwjgl.opengl.Display.setDisplayMode(dm[i]);\n\t\t\t\treturn dm[i];\n\t\t\t} catch (Exception e) {\n\t\t\t\tif (Sys.DEBUG || DEBUG) {\n\t\t\t\t\tSystem.out.println(\"Failed to set display mode to \"+dm[i]);\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow new Exception(\"Failed to set display mode.\");\n\t}\n", "output": "\tpublic static DisplayMode setDisplayMode(DisplayMode[] dm, final String[] param) throws Exception {\n\t\tclass Sorter implements Comparator {\n\t\t\tfinal Field[] field;\n\t\t\tfinal int[] order;\n\t\t\tfinal boolean[] usePreferred;\n\t\t\tfinal int[] preferred;\n\t\t\tSorter() throws NoSuchFieldException {\n\t\t\t\tfield = new Field[param.length];\n\t\t\t\torder = new int[param.length];\n\t\t\t\tpreferred = new int[param.length];\n\t\t\t\tusePreferred = new boolean[param.length];\n\t\t\t\tfor (int i = 0; i < field.length; i ++) {\n\t\t\t\t\tint idx = param[i].indexOf('=');\n\t\t\t\t\tif (idx > 0) {\n\t\t\t\t\t\tpreferred[i] = Integer.parseInt(param[i].substring(idx + 1, param[i].length()));\n\t\t\t\t\t\tusePreferred[i] = true;\n\t\t\t\t\t\tparam[i] = param[i].substring(0, idx);\n\t\t\t\t\t\tfield[i] = DisplayMode.class.getDeclaredField(param[i]);\n\t\t\t\t\t} else if (param[i].charAt(0) == '-') {\n\t\t\t\t\t\tfield[i] = DisplayMode.class.getDeclaredField(param[i].substring(1));\n\t\t\t\t\t\torder[i] = -1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfield[i] = DisplayMode.class.getDeclaredField(param[i]);\n\t\t\t\t\t\torder[i] = 1;\n\t\t\t\t\t}\n\t\t\t\t\tfield[i].setAccessible(true);\n\t\t\t\t}\n\t\t\t}\n\t\t\tpublic int compare(Object o1, Object o2) {\n\t\t\t\tDisplayMode dm1 = (DisplayMode) o1;\n\t\t\t\tDisplayMode dm2 = (DisplayMode) o2;\n\t\t\t\tfor (int i = 0; i < field.length; i ++) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tint f1 = field[i].getInt(dm1);\n\t\t\t\t\t\tint f2 = field[i].getInt(dm2);\n\t\t\t\t\t\tif (usePreferred[i] && f1 != f2) {\n\t\t\t\t\t\t\tif (f1 == preferred[i])\n\t\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t\telse if (f2 == preferred[i])\n\t\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tint absf1 = Math.abs(f1 - preferred[i]);\n\t\t\t\t\t\t\t\tint absf2 = Math.abs(f2 - preferred[i]);\n\t\t\t\t\t\t\t\tif (absf1 < absf2)\n\t\t\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t\t\telse if (absf1 > absf2)\n\t\t\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (f1 < f2)\n\t\t\t\t\t\t\treturn order[i];\n\t\t\t\t\t\telse if (f1 == f2)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\treturn -order[i];\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tassert false : e.getMessage();\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tArrays.sort(dm, new Sorter());\n\t\tif (Sys.DEBUG || DEBUG) {\n\t\t\tSystem.out.println(\"Sorted display modes:\");\n\t\t\tfor (int i = 0; i < dm.length; i ++) {\n\t\t\t\tSystem.out.println(dm[i]);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < dm.length; i ++) {\n\t\t\ttry {\n\t\t\t\tif (Sys.DEBUG || DEBUG)\n\t\t\t\t\tSystem.out.println(\"Attempting to set displaymode: \"+dm[i]);\n\t\t\t\torg.lwjgl.opengl.Display.setDisplayMode(dm[i]);\n\t\t\t\treturn dm[i];\n\t\t\t} catch (Exception e) {\n\t\t\t\tif (Sys.DEBUG || DEBUG) {\n\t\t\t\t\tSystem.out.println(\"Failed to set display mode to \"+dm[i]);\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow new Exception(\"Failed to set display mode.\");\n\t}\n"} {"input": "\tpublic void init() {\n\t\tsuper.init();\n\t\tsetSize(580,660);\n\t\tsetLayout(new BorderLayout());\n\t\texperements.put(\"Baseline\", \"baseline 2008.xml\");\n\t\texperements.put(\"Boom and Bust\", \"boom and bust 3.xml\");\n\t\texperements.put(\"Exponential Growth\", \"Exponential Growth Experiment.xml\");\n\t\texperements.put(\"Central Place\", \"central place 1.xml\");\n\t\texperements.put(\"Cheaters vs Cooperators\", \"cheaters vs cooperators.xml\");\n\t\tcurrentexp = \"Baseline\";\n\t\tcontrols = new JPanel();\n\t\tJLabel selectorlabel = new JLabel(\"Experiment:\");\n\t\tcontrols.add(selectorlabel);\n\t\texpselector = new ExperementSelector(experements);\n\t\tcontrols.add(expselector);\n\t\tJButton resetbutton = new JButton(\"Reset\");\n\t\tcontrols.add(resetbutton);\n\t\tresetbutton.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tloadSimulation(currentexp);\n\t\t\t}\n\t\t});\n\t\tstatsLabel = new JLabel(\"Statistics:\");\n\t\tcontrols.add(statsLabel);\n\t\tJButton statsButton = new JButton(\"Graph\");\n\t\tstatsButton.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tstatsUpdater.toggleGraphVisible();\n\t\t\t}\n\t\t});\n\t\tcontrols.add(statsButton);\n\t\tadd(controls, BorderLayout.NORTH);\n\t\texpselector.setVisible(true);\n\t\texpselector.addActionListener(new ExpSelectorListener());\n\t\tloadSimulation(currentexp);\n\t}\n", "output": "\tpublic void init() {\n\t\tsuper.init();\n\t\tsetSize(580,660);\n\t\tsetLayout(new BorderLayout());\n\t\texperements.put(\"Baseline 2009\", \"baseline 2009.xml\");\n\t\texperements.put(\"Boom and Bust\", \"boom and bust 2 applet.xml\");\n\t\texperements.put(\"Exponential Growth\", \"Exponential Growth Experiment.xml\");\n\t\texperements.put(\"Central Place\", \"central place applet.xml\");\n\t\texperements.put(\"Cheaters vs Cooperators\", \"cheaters vs cooperators.xml\");\n\t\tcurrentexp = \"Baseline 2009\";\n\t\tcontrols = new JPanel();\n\t\tJLabel selectorlabel = new JLabel(\"Experiment:\");\n\t\tcontrols.add(selectorlabel);\n\t\texpselector = new ExperementSelector(experements);\n\t\tcontrols.add(expselector);\n\t\tJButton resetbutton = new JButton(\"Reset\");\n\t\tcontrols.add(resetbutton);\n\t\tresetbutton.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tloadSimulation(currentexp);\n\t\t\t}\n\t\t});\n\t\tstatsLabel = new JLabel(\"Statistics:\");\n\t\tcontrols.add(statsLabel);\n\t\tJButton statsButton = new JButton(\"Graph\");\n\t\tstatsButton.addActionListener(new ActionListener() {\n\t\t\tpublic void actionPerformed(ActionEvent e) {\n\t\t\t\tstatsUpdater.toggleGraphVisible();\n\t\t\t}\n\t\t});\n\t\tcontrols.add(statsButton);\n\t\tadd(controls, BorderLayout.NORTH);\n\t\texpselector.setVisible(true);\n\t\texpselector.addActionListener(new ExpSelectorListener());\n\t\tloadSimulation(currentexp);\n\t}\n"} {"input": "\tpublic static void main(String[] args)\n\t{\n\t\tif (args.length < 4)\n\t\t{\n\t\t\tSystem.out.println(\"Usage: java EmployeeUpdater \");\n\t\t\treturn;\n\t\t}\n\t\tdouble hourlyRate = 0.0;\n\t\tint hoursPerWeek = 0;\n\t\ttry {\n\t\t\thourlyRate = Double.parseDouble(args[2]);\n\t\t} catch (NumberFormatException ex) {\n\t\t\tSystem.out.println(\"'\" + args[2] + \"' is not a valid decimal number\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\thoursPerWeek = Integer.parseInt(args[3]);\n\t\t} catch (NumberFormatException ex) {\n\t\t\tSystem.out.println(\"'\" + args[3] + \"' is not a valid integer\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tRegistry registry = LocateRegistry.getRegistry();\n\t\t\tEmployee employee = (Employee)registry.lookup(args[0]);\n\t\t\temployee.setForename(args[1]);\n\t\t\temployee.setHourlyRate(hourlyRate);\n\t\t\temployee.setNumberHours(hoursPerWeek);\n\t\t} catch (RemoteException ex) {\n\t\t} catch (NotBoundException ex) {\n\t\t}\n\t}\n", "output": "\tpublic static void main(String[] args)\n\t{\n\t\tif (args.length < 4)\n\t\t{\n\t\t\tSystem.out.println(\"Usage: java EmployeeUpdater \");\n\t\t\treturn;\n\t\t}\n\t\tdouble hourlyRate = 0.0;\n\t\tint hoursPerWeek = 0;\n\t\ttry {\n\t\t\thourlyRate = Double.parseDouble(args[2]);\n\t\t} catch (NumberFormatException ex) {\n\t\t\tSystem.out.println(\"'\" + args[2] + \"' is not a valid decimal number\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\thoursPerWeek = Integer.parseInt(args[3]);\n\t\t} catch (NumberFormatException ex) {\n\t\t\tSystem.out.println(\"'\" + args[3] + \"' is not a valid integer\");\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tRegistry registry = LocateRegistry.getRegistry();\n\t\t\tEmployee employee = (Employee)registry.lookup(args[0]);\n\t\t\temployee.setForename(args[1]);\n\t\t\temployee.setHourlyRate(hourlyRate);\n\t\t\temployee.setNumberHours(hoursPerWeek);\n\t\t} catch (RemoteException ex) {\n\t\t\tSystem.out.println(\"Could not update employee with object name '\" + args[0] + \"'\");\n\t\t} catch (NotBoundException ex) {\n\t\t\tSystem.out.println(\"Could not update employee with object name '\" + args[0] + \"'\");\n\t\t}\n\t}\n"} {"input": " public static void main(String[] args) throws IllegalStateException, PoolExhaustedException,\n Exception {\n CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();\n CassandraClient client = pool.borrowClient(\"tush\", 9160);\n try {\n Keyspace keyspace = client.getKeyspace(\"Keyspace1\");\n ColumnPath columnPath = new ColumnPath(\"Standard1\");\n columnPath.setColumn(bytes(\"column-name\"));\n keyspace.insert(\"key\", columnPath, bytes(\"value\"));\n Column col = keyspace.getColumn(\"key\", columnPath);\n System.out.println(\"Read from cassandra: \" + string(col.getValue()));\n } finally {\n pool.releaseClient(client);\n }\n }\n", "output": " public static void main(String[] args) throws IllegalStateException, PoolExhaustedException,\n Exception {\n CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();\n CassandraClient client = pool.borrowClient(\"tush\", 9160);\n try {\n Keyspace keyspace = client.getKeyspace(\"Keyspace1\");\n ColumnPath columnPath = new ColumnPath(\"Standard1\");\n columnPath.setColumn(bytes(\"column-name\"));\n keyspace.insert(\"key\", columnPath, bytes(\"value\"));\n Column col = keyspace.getColumn(\"key\", columnPath);\n System.out.println(\"Read from cassandra: \" + string(col.getValue()));\n client = keyspace.getClient();\n } finally {\n pool.releaseClient(client);\n }\n }\n"} {"input": " TemplateModel _getAsTemplateModel(Environment env)\n throws TemplateException\n {\n TemplateModel model = target.getAsTemplateModel(env);\n if (model instanceof TemplateDateModel) {\n Date date = EvaluationRules.getDate((TemplateDateModel) model, target, env);\n return new SimpleNumber(date.getTime());\n } else {\n Number num = EvaluationRules.getNumber(model, target, env);\n if (num instanceof Long) {\n return model;\n }\n return new SimpleNumber(num.longValue());\n }\n }\n", "output": " TemplateModel _getAsTemplateModel(Environment env)\n throws TemplateException\n {\n TemplateModel model = target.getAsTemplateModel(env);\n if (!(model instanceof TemplateNumberModel)\n && model instanceof TemplateDateModel) {\n Date date = EvaluationRules.getDate((TemplateDateModel) model, target, env);\n return new SimpleNumber(date.getTime());\n } else {\n Number num = EvaluationRules.getNumber(model, target, env);\n if (num instanceof Long) {\n return model;\n }\n return new SimpleNumber(num.longValue());\n }\n }\n"} {"input": "\tpublic synchronized ArrayList getLast(int numberOfRows) {\n\t\tif(numberOfRows < 0) {\n\t\t\tthrow new IllegalArgumentException();\n\t\t}\n\t\tArrayList images = new ArrayList();\n\t\ttry {\n\t\t\tPreparedStatement statement = conn.prepareStatement(\n\t\t\t\t\"SELECT id, url, external_id, description, created_time \"+\n\t\t\t\t\"WHERE blocked='0'\"+\n\t\t\t\t\" FROM images ORDER BY id DESC LIMIT ?;\");\n\t\t\tstatement.setInt(1, numberOfRows);\n\t\t\tResultSet result = statement.executeQuery();\n\t\t\twhile (result.next()) {\n\t\t\t\tImage img = new Image(\n\t\t\t\t\t\tresult.getString(\"url\"),\n\t\t\t\t\t\tresult.getLong(\"external_id\"),\n\t\t\t\t\t\tresult.getString(\"description\"),\n\t\t\t\t\t\tresult.getDate(\"created_time\")\n\t\t\t\t);\n\t\t\t\timg.setInternalId(result.getInt(\"id\"));\n\t\t\t\timages.add(img);\n\t\t\t}\n\t\t} catch (SQLException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn images;\n\t}\n", "output": "\tpublic synchronized ArrayList getLast(int numberOfRows) {\n\t\tif(numberOfRows < 0) {\n\t\t\tthrow new IllegalArgumentException();\n\t\t}\n\t\tArrayList images = new ArrayList();\n\t\ttry {\n\t\t\tPreparedStatement statement = conn.prepareStatement(\n\t\t\t\t\"SELECT id, url, external_id, description, created_time\" +\n\t\t\t\t\" FROM images WHERE blocked='0'\"+\n\t\t\t\t\" ORDER BY id DESC LIMIT ?;\");\n\t\t\tstatement.setInt(1, numberOfRows);\n\t\t\tResultSet result = statement.executeQuery();\n\t\t\twhile (result.next()) {\n\t\t\t\tImage img = new Image(\n\t\t\t\t\t\tresult.getString(\"url\"),\n\t\t\t\t\t\tresult.getLong(\"external_id\"),\n\t\t\t\t\t\tresult.getString(\"description\"),\n\t\t\t\t\t\tresult.getDate(\"created_time\")\n\t\t\t\t);\n\t\t\t\timg.setInternalId(result.getInt(\"id\"));\n\t\t\t\timages.add(img);\n\t\t\t}\n\t\t} catch (SQLException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn images;\n\t}\n"} {"input": " private ChatColor[] setupSocketColors(FileConfiguration fc)\n {\n List colorStringList = fc.getStringList(\"SocketItem.Colors\");\n if (colorStringList == null)\n colorStringList = Arrays.asList(new String[] { \"GREEN\", \"BLUE\",\n \"RED\" });\n ChatColor[] colorList = new ChatColor[colorStringList.size()];\n for (int i = 0; i < colorStringList.size(); i++)\n {\n String string = colorStringList.get(i);\n ChatColor cc = null;\n try\n {\n cc = ChatColor.valueOf(string.toUpperCase());\n }\n catch (Exception e)\n {\n continue;\n }\n if (cc != null)\n colorList[i] = cc;\n }\n System.out.println(colorList.toString());\n return colorList;\n }\n", "output": " private ChatColor[] setupSocketColors(FileConfiguration fc)\n {\n List colorStringList = fc.getStringList(\"SocketItem.Colors\");\n if (colorStringList == null)\n colorStringList = Arrays.asList(new String[] { \"GREEN\", \"BLUE\",\n \"RED\" });\n ChatColor[] colorList = new ChatColor[colorStringList.size()];\n for (int i = 0; i < colorStringList.size(); i++)\n {\n String string = colorStringList.get(i);\n ChatColor cc = null;\n try\n {\n cc = ChatColor.valueOf(string.toUpperCase());\n }\n catch (Exception e)\n {\n continue;\n }\n if (cc != null)\n colorList[i] = cc;\n }\n return colorList;\n }\n"} {"input": "\tprivate void buildTypeClassMap() throws IOException{\n\t\tReflections reflections = new Reflections(\"/graphs/\\\\w+\\\\.class\");\n\t\tfor ( Class klass : Reflections.getSubClasses(Trace.class, reflections.listClasses(\"ditl.graphs\"))){\n\t\t\ttry {\n\t\t\t\tField f = klass.getField(\"type\");\n\t\t\t\tString type = (String)f.get(null);\n\t\t\t\ttype_class_map.put(type, klass);\n\t\t\t} catch (Exception e) {\n\t\t\t\tSystem.err.println(klass+\": \"+e);\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tprivate void buildTypeClassMap() throws IOException{\n\t\tReflections reflections = new Reflections(\"/\\\\w+\\\\.class\");\n\t\tfor ( Class klass : Reflections.getSubClasses(Trace.class, reflections.listClasses(\"ditl.graphs\"))){\n\t\t\ttry {\n\t\t\t\tField f = klass.getField(\"type\");\n\t\t\t\tString type = (String)f.get(null);\n\t\t\t\ttype_class_map.put(type, klass);\n\t\t\t} catch (Exception e) {\n\t\t\t\tSystem.err.println(klass+\": \"+e);\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public StackWindow(ImagePlus imp, ImageCanvas ic) {\n\t\tsuper(imp, ic);\n\t\tImageStack s = imp.getStack();\n\t\tint stackSize = s.getSize();\n\t\tnSlices = stackSize;\n\t\thyperStack = imp.getOpenAsHyperStack();\n\t\timp.setOpenAsHyperStack(false);\n\t\tint[] dim = imp.getDimensions();\n\t\tint nDimensions = 2+(dim[2]>1?1:0)+(dim[3]>1?1:0)+(dim[4]>1?1:0);\n\t\tif (nDimensions<=3 && dim[2]!=nSlices) hyperStack = false;\n\t\tif (hyperStack) {\n\t\t\tnChannels = dim[2];\n\t\t\tnSlices = dim[3];\n\t\t\tnFrames = dim[4];\n\t\t}\n\t\tif (nSlices==stackSize) hyperStack = false;\n\t\tif (nChannels*nSlices*nFrames!=stackSize) hyperStack = false;\n\t\taddMouseWheelListener(this);\n\t\tImageJ ij = IJ.getInstance();\n\t\tif (nChannels>1) {\n\t\t\tcSelector = new ScrollbarWithLabel(this, 1, 1, 1, nChannels+1, 'c');\n\t\t\tadd(cSelector);\n\t\t\tif (ij!=null) cSelector.addKeyListener(ij);\n\t\t\tcSelector.addAdjustmentListener(this);\n\t\t\tcSelector.setFocusable(false); \n\t\t\tcSelector.setUnitIncrement(1);\n\t\t\tcSelector.setBlockIncrement(1);\n\t\t}\n\t\tif (nSlices>1) {\n\t\t\tchar label = nChannels>1||nFrames>1?'z':'t';\n\t\t\tif (nSlices==dim[2]) label = 'c';\n\t\t\tzSelector = new ScrollbarWithLabel(this, 1, 1, 1, nSlices+1, label);\n\t\t\tif (label=='t') animationSelector = zSelector;\n\t\t\tadd(zSelector);\n\t\t\tif (ij!=null) zSelector.addKeyListener(ij);\n\t\t\tzSelector.addAdjustmentListener(this);\n\t\t\tzSelector.setFocusable(false);\n\t\t\tint blockIncrement = nSlices/10;\n\t\t\tif (blockIncrement<1) blockIncrement = 1;\n\t\t\tzSelector.setUnitIncrement(1);\n\t\t\tzSelector.setBlockIncrement(blockIncrement);\n\t\t\tsliceSelector = zSelector.bar;\n\t\t}\n\t\tif (nFrames>1) {\n\t\t\tanimationSelector = tSelector = new ScrollbarWithLabel(this, 1, 1, 1, nFrames+1, 't');\n\t\t\tadd(tSelector);\n\t\t\tif (ij!=null) tSelector.addKeyListener(ij);\n\t\t\ttSelector.addAdjustmentListener(this);\n\t\t\ttSelector.setFocusable(false);\n\t\t\tint blockIncrement = nFrames/10;\n\t\t\tif (blockIncrement<1) blockIncrement = 1;\n\t\t\ttSelector.setUnitIncrement(1);\n\t\t\ttSelector.setBlockIncrement(blockIncrement);\n\t\t}\n\t\tif (sliceSelector==null && this.getClass().getName().indexOf(\"Image5D\")!=-1)\n\t\t\tsliceSelector = new Scrollbar(); \n\t\tpack();\n\t\tic = imp.getCanvas();\n\t\tif (ic!=null) ic.setMaxBounds();\n\t\tshow();\n\t\tint previousSlice = imp.getCurrentSlice();\n\t\tif (previousSlice>1 && previousSlice<=stackSize)\n\t\t\timp.setSlice(previousSlice);\n\t\telse\n\t\t\timp.setSlice(1);\n\t\tthread = new Thread(this, \"zSelector\");\n\t\tthread.start();\n\t}\n", "output": " public StackWindow(ImagePlus imp, ImageCanvas ic) {\n\t\tsuper(imp, ic);\n\t\tImageStack s = imp.getStack();\n\t\tint stackSize = s.getSize();\n\t\tnSlices = stackSize;\n\t\thyperStack = imp.getOpenAsHyperStack();\n\t\timp.setOpenAsHyperStack(false);\n\t\tint[] dim = imp.getDimensions();\n\t\tint nDimensions = 2+(dim[2]>1?1:0)+(dim[3]>1?1:0)+(dim[4]>1?1:0);\n\t\tif (nDimensions<=3 && dim[2]!=nSlices) hyperStack = false;\n\t\tif (hyperStack) {\n\t\t\tnChannels = dim[2];\n\t\t\tnSlices = dim[3];\n\t\t\tnFrames = dim[4];\n\t\t}\n\t\tif (nSlices==stackSize) hyperStack = false;\n\t\tif (nChannels*nSlices*nFrames!=stackSize) hyperStack = false;\n\t\taddMouseWheelListener(this);\n\t\tImageJ ij = IJ.getInstance();\n\t\tif (nChannels>1) {\n\t\t\tcSelector = new ScrollbarWithLabel(this, 1, 1, 1, nChannels+1, 'c');\n\t\t\tadd(cSelector);\n\t\t\tif (ij!=null) cSelector.addKeyListener(ij);\n\t\t\tcSelector.addAdjustmentListener(this);\n\t\t\tcSelector.setFocusable(false); \n\t\t\tcSelector.setUnitIncrement(1);\n\t\t\tcSelector.setBlockIncrement(1);\n\t\t}\n\t\tif (nSlices>1) {\n\t\t\tzSelector = new ScrollbarWithLabel(this, 1, 1, 1, nSlices+1, 'z');\n\t\t\tadd(zSelector);\n\t\t\tif (ij!=null) zSelector.addKeyListener(ij);\n\t\t\tzSelector.addAdjustmentListener(this);\n\t\t\tzSelector.setFocusable(false);\n\t\t\tint blockIncrement = nSlices/10;\n\t\t\tif (blockIncrement<1) blockIncrement = 1;\n\t\t\tzSelector.setUnitIncrement(1);\n\t\t\tzSelector.setBlockIncrement(blockIncrement);\n\t\t\tsliceSelector = zSelector.bar;\n\t\t}\n\t\tif (nFrames>1) {\n\t\t\tanimationSelector = tSelector = new ScrollbarWithLabel(this, 1, 1, 1, nFrames+1, 't');\n\t\t\tadd(tSelector);\n\t\t\tif (ij!=null) tSelector.addKeyListener(ij);\n\t\t\ttSelector.addAdjustmentListener(this);\n\t\t\ttSelector.setFocusable(false);\n\t\t\tint blockIncrement = nFrames/10;\n\t\t\tif (blockIncrement<1) blockIncrement = 1;\n\t\t\ttSelector.setUnitIncrement(1);\n\t\t\ttSelector.setBlockIncrement(blockIncrement);\n\t\t}\n\t\tif (sliceSelector==null && this.getClass().getName().indexOf(\"Image5D\")!=-1)\n\t\t\tsliceSelector = new Scrollbar(); \n\t\tpack();\n\t\tic = imp.getCanvas();\n\t\tif (ic!=null) ic.setMaxBounds();\n\t\tshow();\n\t\tint previousSlice = imp.getCurrentSlice();\n\t\tif (previousSlice>1 && previousSlice<=stackSize)\n\t\t\timp.setSlice(previousSlice);\n\t\telse\n\t\t\timp.setSlice(1);\n\t\tthread = new Thread(this, \"zSelector\");\n\t\tthread.start();\n\t}\n"} {"input": " public void update() {\n String table_name = getStringPrompt(\"Which table?\");\n List set = getStringPrompt(\"Which set instruktion?\").split(\" *, *\");\n\tString condition = getStringPrompt(\"Which condition?\");\n\tList columns = new ArrayList();\n\tList valuess = new ArrayList();\n\tfor (String x:set){\n\t List tuple=x.split(\" *= *\");\n\t if (tuple.size()!=2){\n\t\tSystem.out.println(\"Invalid syntax!\");\n\t\treturn;\n\t }\n\t columns.add(tuple.get(0));\n\t values.add(tuple.get(1));\n\t}\n try {\n db.insert(table_name,columns,values,condition);\n } catch (Exception e) {\n System.out.println(\"Invalid syntax!\");\n System.out.println(e);\n }\n }\n", "output": " public void update() {\n String table_name = getStringPrompt(\"Which table?\");\n List set = getStringPrompt(\"Which set instruction?\").split(\" *, *\");\n\tString condition = getStringPrompt(\"Which condition?\");\n\tList columns = new ArrayList();\n\tList valuess = new ArrayList();\n\tfor (String x:set){\n\t List tuple=x.split(\" *= *\");\n\t if (tuple.size()!=2){\n\t\tSystem.out.println(\"Invalid syntax!\");\n\t\treturn;\n\t }\n\t columns.add(tuple.get(0));\n\t values.add(tuple.get(1));\n\t}\n try {\n db.insert(table_name,columns,values,condition);\n } catch (Exception e) {\n System.out.println(\"Invalid syntax!\");\n System.out.println(e);\n }\n }\n"} {"input": "\tprotected void applyVisualProperty(final VisualProperty vpOriginal, V value) {\n\t\tVisualProperty vp = vpOriginal;\n\t\tif (value == null)\n\t\t\tvalue = (V) vp.getDefault();\n\t\tif (vp == DVisualLexicon.NODE_SHAPE) {\n\t\t\tsetShape(((NodeShape) value));\n\t\t} else if (vp == DVisualLexicon.NODE_SELECTED_PAINT) {\n\t\t\tsetSelectedPaint((Paint) value);\n\t\t} else if (vp == BasicVisualLexicon.NODE_SELECTED) {\n\t\t\tsetSelected((Boolean) value);\n\t\t} else if (vp == BasicVisualLexicon.NODE_VISIBLE) {\n\t\t\tif (((Boolean) value).booleanValue())\n\t\t\t\tgraphView.showGraphObject(this);\n\t\t\telse\n\t\t\t\tgraphView.hideGraphObject(this);\n\t\t} else if (vp == BasicVisualLexicon.NODE_FILL_COLOR) {\n\t\t\tsetUnselectedPaint((Paint) value);\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_PAINT) {\n\t\t\tsetBorderPaint((Color)value);\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_TRANSPARENCY) {\n\t\t\tfinal Integer opacity = ((Number) value).intValue();\n\t\t\tsetBorderTransparency(opacity);\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_WIDTH) {\n\t\t\tsetBorderWidth(((Number) value).floatValue());\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_LINE_TYPE) {\n\t\t\tfinal DLineType dLineType = DLineType.getDLineType((LineType) value);\n\t\t\tfinal float currentBorderWidth = graphView.m_nodeDetails.getBorderWidth(model);\n\t\t\tsetBorder(dLineType.getStroke(currentBorderWidth));\n\t\t} else if (vp == DVisualLexicon.NODE_TRANSPARENCY) {\n\t\t\tsetTransparency(((Number) value).intValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_WIDTH) {\n\t\t\tsetWidth(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_HEIGHT) {\n\t\t\tsetHeight(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL) {\n\t\t\tsetText(value.toString());\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL_WIDTH) {\n\t\t\tsetLabelWidth(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_X_LOCATION) {\n\t\t\tsetXPosition(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_Y_LOCATION) {\n\t\t\tsetYPosition(((Number) value).doubleValue());\n\t\t} else if (vp == DVisualLexicon.NODE_TOOLTIP) {\n\t\t\tsetToolTip(value.toString());\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL_COLOR) {\n\t\t\tsetTextPaint((Color)value);\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL_TRANSPARENCY) {\n\t\t\tfinal int currentOpacity = graphView.m_nodeDetails.getLabelTransparency(model);\n\t\t\tfinal int opacity = ((Number) value).intValue();\n\t\t\tif(currentOpacity != opacity) {\n\t\t\t\tsetTextTransparency(opacity);\n\t\t\t}\n\t\t} else if (vp == DVisualLexicon.NODE_LABEL_FONT_FACE) {\n\t\t\tfinal float currentFontSize = graphView.m_nodeDetails.getLabelFont(model, 0).getSize();\n\t\t\tfinal Font newFont = ((Font) value).deriveFont(currentFontSize);\n\t\t\tsetFont(newFont);\n\t\t} else if (vp == DVisualLexicon.NODE_LABEL_FONT_SIZE) {\n\t\t\tfinal float newSize = ((Number) value).floatValue();\n\t\t\tfinal Font newFont = graphView.m_nodeDetails.getLabelFont(model, 0).deriveFont(newSize);\n\t\t\tsetFont(newFont);\n\t\t} else if (vp == DVisualLexicon.NODE_LABEL_POSITION) {\n\t\t\tthis.setLabelPosition((ObjectPosition) value);\n\t\t} else if (vp instanceof CustomGraphicsVisualProperty) {\n\t\t\tapplyCustomGraphics(vp, (CyCustomGraphics) value);\n\t\t} else if (vp instanceof ObjectPositionVisualProperty) {\n\t\t\tapplyCustomGraphicsPosition(vp, (ObjectPosition) value);\n\t\t}\n\t}\n", "output": "\tprotected void applyVisualProperty(final VisualProperty vpOriginal, V value) {\n\t\tVisualProperty vp = vpOriginal;\n\t\tif (value == null)\n\t\t\tvalue = (V) vp.getDefault();\n\t\tif (vp == DVisualLexicon.NODE_SHAPE) {\n\t\t\tsetShape(((NodeShape) value));\n\t\t} else if (vp == DVisualLexicon.NODE_SELECTED_PAINT) {\n\t\t\tsetSelectedPaint((Paint) value);\n\t\t} else if (vp == BasicVisualLexicon.NODE_SELECTED) {\n\t\t\tsetSelected((Boolean) value);\n\t\t} else if (vp == BasicVisualLexicon.NODE_VISIBLE) {\n\t\t\tif (((Boolean) value).booleanValue())\n\t\t\t\tgraphView.showGraphObject(this);\n\t\t\telse\n\t\t\t\tgraphView.hideGraphObject(this);\n\t\t} else if (vp == BasicVisualLexicon.NODE_FILL_COLOR) {\n\t\t\tsetUnselectedPaint((Paint) value);\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_PAINT) {\n\t\t\tsetBorderPaint((Color)value);\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_TRANSPARENCY) {\n\t\t\tfinal Integer opacity = ((Number) value).intValue();\n\t\t\tsetBorderTransparency(opacity);\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_WIDTH) {\n\t\t\tsetBorderWidth(((Number) value).floatValue());\n\t\t} else if (vp == DVisualLexicon.NODE_BORDER_LINE_TYPE) {\n\t\t\tfinal DLineType dLineType = DLineType.getDLineType((LineType) value);\n\t\t\tfinal float currentBorderWidth = graphView.m_nodeDetails.getBorderWidth(model);\n\t\t\tsetBorder(dLineType.getStroke(currentBorderWidth));\n\t\t} else if (vp == DVisualLexicon.NODE_TRANSPARENCY) {\n\t\t\tsetTransparency(((Number) value).intValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_WIDTH) {\n\t\t\tsetWidth(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_HEIGHT) {\n\t\t\tsetHeight(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL) {\n\t\t\tsetText(value.toString());\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL_WIDTH) {\n\t\t\tsetLabelWidth(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_X_LOCATION) {\n\t\t\tsetXPosition(((Number) value).doubleValue());\n\t\t} else if (vp == BasicVisualLexicon.NODE_Y_LOCATION) {\n\t\t\tsetYPosition(((Number) value).doubleValue());\n\t\t} else if (vp == DVisualLexicon.NODE_TOOLTIP) {\n\t\t\tsetToolTip(value.toString());\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL_COLOR) {\n\t\t\tsetTextPaint((Color)value);\n\t\t} else if (vp == BasicVisualLexicon.NODE_LABEL_TRANSPARENCY) {\n\t\t\tfinal int opacity = ((Number) value).intValue();\n\t\t\tsetTextTransparency(opacity);\n\t\t} else if (vp == DVisualLexicon.NODE_LABEL_FONT_FACE) {\n\t\t\tfinal float currentFontSize = graphView.m_nodeDetails.getLabelFont(model, 0).getSize();\n\t\t\tfinal Font newFont = ((Font) value).deriveFont(currentFontSize);\n\t\t\tsetFont(newFont);\n\t\t} else if (vp == DVisualLexicon.NODE_LABEL_FONT_SIZE) {\n\t\t\tfinal float newSize = ((Number) value).floatValue();\n\t\t\tfinal Font newFont = graphView.m_nodeDetails.getLabelFont(model, 0).deriveFont(newSize);\n\t\t\tsetFont(newFont);\n\t\t} else if (vp == DVisualLexicon.NODE_LABEL_POSITION) {\n\t\t\tthis.setLabelPosition((ObjectPosition) value);\n\t\t} else if (vp instanceof CustomGraphicsVisualProperty) {\n\t\t\tapplyCustomGraphics(vp, (CyCustomGraphics) value);\n\t\t} else if (vp instanceof ObjectPositionVisualProperty) {\n\t\t\tapplyCustomGraphicsPosition(vp, (ObjectPosition) value);\n\t\t}\n\t}\n"} {"input": " public boolean isForMe(ProjectViewNode node) {\n if (node instanceof PsiDirectoryNode) {\n PsiDirectoryNode dirNode = (PsiDirectoryNode) node;\n final Project project = dirNode.getProject();\n final PsiDirectory psiDirectory = dirNode.getValue();\n final VirtualFile directoryFile = psiDirectory.getVirtualFile();\n return (ProjectRootsUtil.isModuleContentRoot(directoryFile, project)\n || ProjectRootsUtil.isInSource(directoryFile, project));\n }\n return false;\n }\n", "output": " public boolean isForMe(ProjectViewNode node) {\n if (node instanceof PsiDirectoryNode) {\n PsiDirectoryNode dirNode = (PsiDirectoryNode) node;\n final Project project = dirNode.getProject();\n final PsiDirectory psiDirectory = dirNode.getValue();\n if (psiDirectory != null) {\n final VirtualFile directoryFile = psiDirectory.getVirtualFile();\n return (ProjectRootsUtil.isModuleContentRoot(directoryFile, project)\n || ProjectRootsUtil.isInSource(directoryFile, project));\n }\n }\n return false;\n }\n"} {"input": " public void should_insert_single_invoice_record_from_finance_and_admin_with_same_invoice_number() throws IOException {\n String[] adminTestData = {\n \"1234\",\n \"2000\",\n \"goods\"\n };\n String[] financeTestData = {\n \"1234\",\n \"23\",\n \"CHENNAI\",\n \"2345\"\n }; \n String[] adminHeaders = {\n \"invoiceNumber\",\n \"bondNumber\",\n \"descriptionOfGoods\" \n };\n String[] financeHeaders={\n \"invoiceNumber\",\n \"quantity\",\n \"location\",\n \"april-10\"\n };\n List adminListOfTestData = new ArrayList();\n List financeListOfTestData = new ArrayList();\n adminListOfTestData.add(adminTestData);\n financeListOfTestData.add(financeTestData);\n List> adminMappedEntries = null;\n List> financeMappedEntries = null;\n try {\n adminMappedEntries = new ColumnMapper(adminHeaders, adminListOfTestData).mappedList();\n financeMappedEntries = new ColumnMapper(financeHeaders, financeListOfTestData).mappedList();\n } catch (Exception e) {\n e.printStackTrace();\n }\n List>combinedEntries = new InvoiceCreator(adminMappedEntries, financeMappedEntries).createJoinEntry();\n List insertStatements = new SQLGenerator(combinedEntries).createInsertStatements();\n sessionFactory.getCurrentSession().createSQLQuery(\"delete from asset; delete from invoice\");\n for(String insertStatement: insertStatements){\n sessionFactory.getCurrentSession().createSQLQuery(insertStatement).executeUpdate();\n }\n Invoice invoice = invoiceRepository.get(0);\n String[] expectedValue = {\n \"1234\", \"2000\", \"goods\", \"23\", \"CHENNAI\"\n };\n String[] actualData = {\n invoice.getInvoiceNumber(),\n invoice.getBondNumber(),\n invoice.getDescriptionOfGoods(),\n invoice.getQuantity().toString(),\n invoice.getLocation().toString()\n };\n assertThat(actualData, equalTo(expectedValue));\n }\n", "output": " public void should_insert_single_invoice_record_from_finance_and_admin_with_same_invoice_number() throws IOException {\n String[] adminTestData = {\n \"1234\",\n \"2000\",\n \"goods\"\n };\n String[] financeTestData = {\n \"1234\",\n \"23\",\n \"CHENNAI\",\n \"2345\"\n }; \n String[] adminHeaders = {\n \"invoiceNumber\",\n \"bondNumber\",\n \"descriptionOfGoods\" \n };\n String[] financeHeaders={\n \"invoiceNumber\",\n \"quantity\",\n \"location\",\n \"april-10\"\n };\n List adminListOfTestData = new ArrayList();\n List financeListOfTestData = new ArrayList();\n adminListOfTestData.add(adminTestData);\n financeListOfTestData.add(financeTestData);\n List> adminMappedEntries = null;\n List> financeMappedEntries = null;\n try {\n adminMappedEntries = new ColumnMapper(adminHeaders, adminListOfTestData).mappedList();\n financeMappedEntries = new ColumnMapper(financeHeaders, financeListOfTestData).mappedList();\n } catch (Exception e) {\n e.printStackTrace();\n }\n List>combinedEntries = new InvoiceCreator(adminMappedEntries, financeMappedEntries).createJoinEntry();\n List insertStatements = new SQLGenerator(combinedEntries).createInsertStatements();\n sessionFactory.getCurrentSession().createSQLQuery(\"delete from asset; delete from invoice;\").executeUpdate();\n for(String insertStatement: insertStatements){\n sessionFactory.getCurrentSession().createSQLQuery(insertStatement).executeUpdate();\n }\n Invoice invoice = invoiceRepository.get(0);\n String[] expectedValue = {\n \"1234\", \"2000\", \"goods\", \"23\", \"CHENNAI\"\n };\n String[] actualData = {\n invoice.getInvoiceNumber(),\n invoice.getBondNumber(),\n invoice.getDescriptionOfGoods(),\n invoice.getQuantity().toString(),\n invoice.getLocation().toString()\n };\n assertThat(actualData, equalTo(expectedValue));\n }\n"} {"input": " public void displayNewThreadFormFor(final Category category) {\n layout.removeAllComponents();\n final HeadingLabel heading = new HeadingLabel(\"Start a New Thread\",\n HeadingLevel.H2);\n layout.addComponent(heading);\n getRoot().scrollIntoView(heading);\n final HorizontalLayout topicLayout = new HorizontalLayout();\n topicLayout.setSpacing(true);\n topicLayout.setMargin(true, false, true, false);\n topicLayout.setWidth(\"50em\");\n topicLayout.setStyleName(\"newthread\");\n layout.addComponent(topicLayout);\n final HeadingLabel topicLabel = new HeadingLabel(\"Topic\",\n HeadingLevel.H3);\n topicLabel.addStyleName(\"topiclabel\");\n topicLabel.setWidth(\"153px\");\n topicLayout.addComponent(topicLabel);\n final TextField topicField = new TextField();\n topicField.setStyleName(\"topicfield\");\n topicField.setWidth(\"100%\");\n topicLayout.addComponent(topicField);\n topicLayout.setExpandRatio(topicField, 1.0f);\n topicField.focus();\n newThreadComponent = new NewThreadComponent(new NewThreadListener() {\n @Override\n public void submit(final String rawBody) {\n String errorMessages = \"\";\n final String topic = topicField.getValue();\n if (topic.isEmpty()) {\n errorMessages += \"You need a topic
\";\n }\n if (rawBody.isEmpty()) {\n errorMessages += \"You need a thread body
\";\n }\n if (errorMessages.isEmpty()) {\n try {\n final DiscussionThread createdThread = getPresenter()\n .createNewThread(category, topic, rawBody);\n getNavigator().navigateTo(\n ToriNavigator.ApplicationView.THREADS.getUrl()\n + \"/\" + createdThread.getId());\n } catch (final DataSourceException e) {\n getRoot()\n .showNotification(\n DataSourceException.BORING_GENERIC_ERROR_MESSAGE);\n }\n } else {\n getRoot().showNotification(errorMessages,\n Notification.TYPE_HUMANIZED_MESSAGE);\n }\n }\n @Override\n public void addAttachment(final String attachmentFileName,\n final byte[] data) {\n getPresenter().addAttachment(attachmentFileName, data);\n }\n @Override\n public void resetInput() {\n getPresenter().resetInput();\n }\n @Override\n public void removeAttachment(final String fileName) {\n getPresenter().removeAttachment(fileName);\n }\n }, ToriApplication.getCurrent().getPostFormatter()\n .getFormattingSyntaxXhtml());\n newThreadComponent.setUserMayAddFiles(getPresenter().userMayAddFiles());\n newThreadComponent.setMaxFileSize(getPresenter().getMaxFileSize());\n layout.addComponent(newThreadComponent);\n }\n", "output": " public void displayNewThreadFormFor(final Category category) {\n layout.removeAllComponents();\n final HeadingLabel heading = new HeadingLabel(\"Start a New Thread\",\n HeadingLevel.H2);\n layout.addComponent(heading);\n getRoot().scrollIntoView(heading);\n final HorizontalLayout topicLayout = new HorizontalLayout();\n topicLayout.setSpacing(true);\n topicLayout.setMargin(true, false, false, false);\n topicLayout.setWidth(\"50em\");\n topicLayout.setStyleName(\"newthread\");\n layout.addComponent(topicLayout);\n final HeadingLabel topicLabel = new HeadingLabel(\"Topic\",\n HeadingLevel.H3);\n topicLabel.addStyleName(\"topiclabel\");\n topicLabel.setWidth(\"153px\");\n topicLayout.addComponent(topicLabel);\n final TextField topicField = new TextField();\n topicField.setStyleName(\"topicfield\");\n topicField.setWidth(\"100%\");\n topicLayout.addComponent(topicField);\n topicLayout.setExpandRatio(topicField, 1.0f);\n topicField.focus();\n newThreadComponent = new NewThreadComponent(new NewThreadListener() {\n @Override\n public void submit(final String rawBody) {\n String errorMessages = \"\";\n final String topic = topicField.getValue();\n if (topic.isEmpty()) {\n errorMessages += \"You need a topic
\";\n }\n if (rawBody.isEmpty()) {\n errorMessages += \"You need a thread body
\";\n }\n if (errorMessages.isEmpty()) {\n try {\n final DiscussionThread createdThread = getPresenter()\n .createNewThread(category, topic, rawBody);\n getNavigator().navigateTo(\n ToriNavigator.ApplicationView.THREADS.getUrl()\n + \"/\" + createdThread.getId());\n } catch (final DataSourceException e) {\n getRoot()\n .showNotification(\n DataSourceException.BORING_GENERIC_ERROR_MESSAGE);\n }\n } else {\n getRoot().showNotification(errorMessages,\n Notification.TYPE_HUMANIZED_MESSAGE);\n }\n }\n @Override\n public void addAttachment(final String attachmentFileName,\n final byte[] data) {\n getPresenter().addAttachment(attachmentFileName, data);\n }\n @Override\n public void resetInput() {\n getPresenter().resetInput();\n }\n @Override\n public void removeAttachment(final String fileName) {\n getPresenter().removeAttachment(fileName);\n }\n }, ToriApplication.getCurrent().getPostFormatter()\n .getFormattingSyntaxXhtml());\n newThreadComponent.setUserMayAddFiles(getPresenter().userMayAddFiles());\n newThreadComponent.setMaxFileSize(getPresenter().getMaxFileSize());\n layout.addComponent(newThreadComponent);\n }\n"} {"input": "\tpublic static String createDisplayName(RElementName a, final int options) {\n\t\tStringBuilder sb = null;\n\t\tif ((options & DISPLAY_NS_PREFIX) != 0) {\n\t\t\tfinal RElementName namespace = a.getNamespace();\n\t\t\tif (namespace != null) {\n\t\t\t\tsb = new StringBuilder(32);\n\t\t\t\tif (!appendEnvAccess(namespace, sb, options)\n\t\t\t\t\t\t|| a.getType() != MAIN_DEFAULT) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (a.getType() == MAIN_SEARCH_ENV\n\t\t\t\t\t|| a.getType() == MAIN_PACKAGE\n\t\t\t\t\t|| a.getType() == MAIN_SYSFRAME) {\n\t\t\t\tsb = new StringBuilder(32);\n\t\t\t\tif (!appendEnvAccess(a, sb, options)\n\t\t\t\t\t\t|| (a = a.getNextSegment()) != null && a.getType() != MAIN_DEFAULT) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (sb != null && a != null) {\n\t\t\t\tsb.append('$');\n\t\t\t\tfinal String name = a.getSegmentName();\n\t\t\t\tif (name != null) {\n\t\t\t\t\tappendSymbol(sb, name);\n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t}\n\t\t}\n\t\tif (sb == null) {\n\t\t\tString firstName;\n\t\t\tfinal int type = a.getType();\n\t\t\tswitch (type) {\n\t\t\tcase MAIN_DEFAULT:\n\t\t\tcase MAIN_CLASS:\n\t\t\tcase SUB_NAMEDPART:\n\t\t\tcase SUB_NAMEDSLOT:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\tsb = appendSymbol(sb, firstName);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfirstName = \"\"; \n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t\tif (a == null) {\n\t\t\t\t\treturn (sb != null) ? sb.toString() : firstName;\n\t\t\t\t}\n\t\t\t\tif (sb == null) {\n\t\t\t\t\tsb = new StringBuilder(firstName);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase MAIN_SEARCH_ENV:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn firstName;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tcase MAIN_SYSFRAME:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn \"frame:\"+firstName;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tcase MAIN_PACKAGE:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn \"package:\"+firstName;\n\t\t\t\t}\n\t\t\t\telse if ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\treturn \"package:\";\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\tcase MAIN_PROJECT:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn \"project:\"+firstName;\n\t\t\t\t}\n\t\t\t\telse if ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\treturn \"project:\";\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\tcase SUB_INDEXED_D:\n\t\t\t\tif (a instanceof DefaultImpl) {\n\t\t\t\t\tsb = new StringBuilder(\"[[\"); \n\t\t\t\t\tsb.append(a.getSegmentName());\n\t\t\t\t\tsb.append(\"]]\"); \n\t\t\t\t\ta = a.getNextSegment();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tcase RESOURCE:\n\t\t\tcase MAIN_OTHER:\n\t\t\t\treturn a.getSegmentName();\n\t\t\tcase ANONYMOUS:\n\t\t\t\tif ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tAPPEND_SUB : while (a != null) {\n\t\t\tString name;\n\t\t\tswitch (a.getType()) {\n\t\t\tcase MAIN_DEFAULT:\n\t\t\tcase MAIN_CLASS:\n\t\t\tcase SUB_NAMEDPART:\n\t\t\t\tif (((options & DISPLAY_EXACT) != 0) && a instanceof IndexElementName) {\n\t\t\t\t\tsb.append(\"[[\");\n\t\t\t\t\tsb.append(((IndexElementName) a).getIndex());\n\t\t\t\t\tsb.append(\"L]]\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tsb.append('$');\n\t\t\t\t\tname = a.getSegmentName();\n\t\t\t\t\tif (name != null) {\n\t\t\t\t\t\tappendSymbol(sb, name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t\tcontinue APPEND_SUB;\n\t\t\tcase SUB_NAMEDSLOT:\n\t\t\t\tsb.append('@');\n\t\t\t\tname = a.getSegmentName();\n\t\t\t\tif (name != null) {\n\t\t\t\t\tappendSymbol(sb, name);\n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t\tcontinue APPEND_SUB;\n\t\t\tcase SUB_INDEXED_S:\n\t\t\t\tif (((options & DISPLAY_EXACT) != 0)) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tsb.append(\"[\u2026]\"); \n\t\t\t\tbreak APPEND_SUB;\n\t\t\tcase SUB_INDEXED_D:\n\t\t\t\tif (a instanceof DefaultImpl) {\n\t\t\t\t\tsb.append(\"[[\"); \n\t\t\t\t\tsb.append(a.getSegmentName());\n\t\t\t\t\tsb.append(\"]]\"); \n\t\t\t\t\ta = a.getNextSegment();\n\t\t\t\t\tcontinue APPEND_SUB;\n\t\t\t\t}\n\t\t\t\telse if ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\tsb.append(\"[[\u2026]]\"); \n\t\t\t\t\tcontinue APPEND_SUB;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif (((options & DISPLAY_EXACT) == 0)) {\n\t\t\t\t\tsb.append(\" \u2026\"); \n\t\t\t\t\tbreak APPEND_SUB;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n", "output": "\tpublic static String createDisplayName(RElementName a, final int options) {\n\t\tStringBuilder sb = null;\n\t\tif ((options & DISPLAY_NS_PREFIX) != 0) {\n\t\t\tfinal RElementName namespace = a.getNamespace();\n\t\t\tif (namespace != null) {\n\t\t\t\tsb = new StringBuilder(32);\n\t\t\t\tif (!appendEnvAccess(namespace, sb, options)\n\t\t\t\t\t\t|| a.getType() != MAIN_DEFAULT) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (a.getType() == MAIN_SEARCH_ENV\n\t\t\t\t\t|| a.getType() == MAIN_PACKAGE\n\t\t\t\t\t|| a.getType() == MAIN_SYSFRAME) {\n\t\t\t\tsb = new StringBuilder(32);\n\t\t\t\tif (!appendEnvAccess(a, sb, options)\n\t\t\t\t\t\t|| (a = a.getNextSegment()) != null && a.getType() != MAIN_DEFAULT) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (sb != null && a != null) {\n\t\t\t\tsb.append('$');\n\t\t\t\tfinal String name = a.getSegmentName();\n\t\t\t\tif (name != null) {\n\t\t\t\t\tappendSymbol(sb, name);\n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t}\n\t\t}\n\t\tif (sb == null) {\n\t\t\tString firstName;\n\t\t\tfinal int type = a.getType();\n\t\t\tswitch (type) {\n\t\t\tcase MAIN_DEFAULT:\n\t\t\tcase MAIN_CLASS:\n\t\t\tcase SUB_NAMEDPART:\n\t\t\tcase SUB_NAMEDSLOT:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\tsb = appendSymbol(sb, firstName);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfirstName = \"\"; \n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t\tif (a == null) {\n\t\t\t\t\treturn (sb != null) ? sb.toString() : firstName;\n\t\t\t\t}\n\t\t\t\tif (sb == null) {\n\t\t\t\t\tsb = new StringBuilder(firstName);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase MAIN_SEARCH_ENV:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn firstName;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tcase MAIN_SYSFRAME:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn \"frame:\"+firstName;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tcase MAIN_PACKAGE:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn \"package:\"+firstName;\n\t\t\t\t}\n\t\t\t\telse if ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\treturn \"package:\";\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\tcase MAIN_PROJECT:\n\t\t\t\tfirstName = a.getSegmentName();\n\t\t\t\tif (firstName != null) {\n\t\t\t\t\treturn \"project:\"+firstName;\n\t\t\t\t}\n\t\t\t\telse if ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\treturn \"project:\";\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\tcase SUB_INDEXED_D:\n\t\t\t\tif (a instanceof DefaultImpl) {\n\t\t\t\t\tsb = new StringBuilder(\"[[\"); \n\t\t\t\t\tsb.append(a.getSegmentName());\n\t\t\t\t\tsb.append(\"]]\"); \n\t\t\t\t\ta = a.getNextSegment();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tcase RESOURCE:\n\t\t\tcase MAIN_OTHER:\n\t\t\t\treturn a.getSegmentName();\n\t\t\tcase ANONYMOUS:\n\t\t\t\tif ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\treturn \"\";\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\tdefault:\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\tAPPEND_SUB : while (a != null) {\n\t\t\tString name;\n\t\t\tswitch (a.getType()) {\n\t\t\tcase MAIN_DEFAULT:\n\t\t\tcase MAIN_CLASS:\n\t\t\tcase SUB_NAMEDPART:\n\t\t\t\tif (((options & DISPLAY_EXACT) != 0) && a instanceof IndexElementName) {\n\t\t\t\t\tsb.append(\"[[\");\n\t\t\t\t\tsb.append(((IndexElementName) a).getIndex());\n\t\t\t\t\tsb.append(\"L]]\");\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tsb.append('$');\n\t\t\t\t\tname = a.getSegmentName();\n\t\t\t\t\tif (name != null) {\n\t\t\t\t\t\tappendSymbol(sb, name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t\tcontinue APPEND_SUB;\n\t\t\tcase SUB_NAMEDSLOT:\n\t\t\t\tsb.append('@');\n\t\t\t\tname = a.getSegmentName();\n\t\t\t\tif (name != null) {\n\t\t\t\t\tappendSymbol(sb, name);\n\t\t\t\t}\n\t\t\t\ta = a.getNextSegment();\n\t\t\t\tcontinue APPEND_SUB;\n\t\t\tcase SUB_INDEXED_S:\n\t\t\t\tif (((options & DISPLAY_EXACT) != 0)) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tsb.append(\"[\u2026]\"); \n\t\t\t\tbreak APPEND_SUB;\n\t\t\tcase SUB_INDEXED_D:\n\t\t\t\tif (a instanceof DefaultImpl) {\n\t\t\t\t\tsb.append(\"[[\"); \n\t\t\t\t\tsb.append(a.getSegmentName());\n\t\t\t\t\tsb.append(\"]]\"); \n\t\t\t\t\ta = a.getNextSegment();\n\t\t\t\t\tcontinue APPEND_SUB;\n\t\t\t\t}\n\t\t\t\telse if ((options & DISPLAY_EXACT) == 0) {\n\t\t\t\t\tsb.append(\"[[\u2026]]\"); \n\t\t\t\t\ta = a.getNextSegment();\n\t\t\t\t\tcontinue APPEND_SUB;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif (((options & DISPLAY_EXACT) == 0)) {\n\t\t\t\t\tsb.append(\" \u2026\"); \n\t\t\t\t\tbreak APPEND_SUB;\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\treturn sb.toString();\n\t}\n"} {"input": "\tpublic GLMultiFormWindow(String title, GLSubGraph view, MultiFormInfo info, boolean isScrollable) {\n\t\tsuper(title, view);\n\t\tthis.info = info;\n\t\tGLElementAdapter container = isScrollable ? new ScrollableGLElementAdapter(view, info.multiFormRenderer)\n\t\t\t\t: new GLElementAdapter(view, info.multiFormRenderer, true);\n\t\tinfo.container = container;\n\t\tsetContent(container);\n\t\tviewSwitchingBar = new GLElementViewSwitchingBar(info.multiFormRenderer);\n\t\ttitleBar.add(titleBar.size() - 1, viewSwitchingBar);\n\t\tviewSwitchingBar.setVisibility(EVisibility.NONE);\n\t\tfor (Entry> entry : info.embeddingIDToRendererIDs.entrySet()) {\n\t\t\tfor (Integer rendererID : entry.getValue()) {\n\t\t\t\tString toolTip = null;\n\t\t\t\tswitch (entry.getKey()) {\n\t\t\t\tcase PATHWAY_LEVEL1:\n\t\t\t\t\ttoolTip = \"Pathway\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATHWAY_LEVEL2:\n\t\t\t\t\ttoolTip = \"Pathway Thumbnail with Context Paths\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATHWAY_LEVEL3:\n\t\t\t\t\ttoolTip = \"Pathway Thumbnail\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATHWAY_LEVEL4:\n\t\t\t\t\ttoolTip = \"Minimize\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATH_LEVEL1:\n\t\t\t\t\ttoolTip = \"Selected Path with Detailed Experimental Data\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATH_LEVEL2:\n\t\t\t\t\ttoolTip = \"Selected Path\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (toolTip != null) {\n\t\t\t\t\tviewSwitchingBar.setButtonToolTip(toolTip, rendererID);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic GLMultiFormWindow(String title, GLSubGraph view, MultiFormInfo info, boolean isScrollable) {\n\t\tsuper(title, view);\n\t\tthis.info = info;\n\t\tGLElementAdapter container = isScrollable ? new ScrollableGLElementAdapter(view, info.multiFormRenderer)\n\t\t\t\t: new GLElementAdapter(view, info.multiFormRenderer, true);\n\t\tinfo.container = container;\n\t\tsetContent(container);\n\t\tviewSwitchingBar = new GLElementViewSwitchingBar(info.multiFormRenderer);\n\t\ttitleBar.add(titleBar.size() - 1, viewSwitchingBar);\n\t\tviewSwitchingBar.setVisibility(EVisibility.NONE);\n\t\tfor (Entry> entry : info.embeddingIDToRendererIDs.entrySet()) {\n\t\t\tfor (Integer rendererID : entry.getValue()) {\n\t\t\t\tString toolTip = null;\n\t\t\t\tswitch (entry.getKey()) {\n\t\t\t\tcase PATHWAY_LEVEL1:\n\t\t\t\t\ttoolTip = \"Pathway\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATHWAY_LEVEL2:\n\t\t\t\t\ttoolTip = \"Context Paths with Pathway Thumbnail\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATHWAY_LEVEL3:\n\t\t\t\t\ttoolTip = \"ContextPaths\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATHWAY_LEVEL4:\n\t\t\t\t\ttoolTip = \"Minimize\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATH_LEVEL1:\n\t\t\t\t\ttoolTip = \"Selected Path with Detailed Experimental Data\";\n\t\t\t\t\tbreak;\n\t\t\t\tcase PATH_LEVEL2:\n\t\t\t\t\ttoolTip = \"Selected Path\";\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (toolTip != null) {\n\t\t\t\t\tviewSwitchingBar.setButtonToolTip(toolTip, rendererID);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " private void addContentTab()\n {\n wContentTab=new CTabItem(wTabFolder, SWT.NONE);\n wContentTab.setText(Messages.getString(\"TextFileInputDialog.ContentTab.TabTitle\"));\n FormLayout contentLayout = new FormLayout ();\n contentLayout.marginWidth = 3;\n contentLayout.marginHeight = 3;\n wContentSComp = new ScrolledComposite(wTabFolder, SWT.V_SCROLL | SWT.H_SCROLL );\n wContentSComp.setLayout(new FillLayout());\n wContentComp = new Composite(wContentSComp, SWT.NONE );\n props.setLook(wContentComp);\n wContentComp.setLayout(contentLayout);\n wlFiletype=new Label(wContentComp, SWT.RIGHT);\n wlFiletype.setText(Messages.getString(\"TextFileInputDialog.Filetype.Label\"));\n props.setLook(wlFiletype);\n fdlFiletype=new FormData();\n fdlFiletype.left = new FormAttachment(0, 0);\n fdlFiletype.top = new FormAttachment(0, 0);\n fdlFiletype.right= new FormAttachment(middle, -margin);\n wlFiletype.setLayoutData(fdlFiletype);\n wFiletype=new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);\n wFiletype.setText(Messages.getString(\"TextFileInputDialog.Filetype.Label\"));\n props.setLook(wFiletype);\n wFiletype.add(\"CSV\");\n wFiletype.add(\"Fixed\");\n wFiletype.select(0);\n wFiletype.addModifyListener(lsMod);\n fdFiletype=new FormData();\n fdFiletype.left = new FormAttachment(middle, 0);\n fdFiletype.top = new FormAttachment(0, 0);\n fdFiletype.right= new FormAttachment(100, 0);\n wFiletype.setLayoutData(fdFiletype);\n wlSeparator=new Label(wContentComp, SWT.RIGHT);\n wlSeparator.setText(Messages.getString(\"TextFileInputDialog.Separator.Label\"));\n props.setLook(wlSeparator);\n fdlSeparator=new FormData();\n fdlSeparator.left = new FormAttachment(0, 0);\n fdlSeparator.top = new FormAttachment(wFiletype, margin);\n fdlSeparator.right= new FormAttachment(middle, -margin);\n wlSeparator.setLayoutData(fdlSeparator);\n wbSeparator=new Button(wContentComp, SWT.PUSH| SWT.CENTER);\n props.setLook(wbSeparator);\n wbSeparator.setText(Messages.getString(\"TextFileInputDialog.Separator.Button\"));\n fdbSeparator=new FormData();\n fdbSeparator.right= new FormAttachment(100, 0);\n fdbSeparator.top = new FormAttachment(wFiletype, 0);\n wbSeparator.setLayoutData(fdbSeparator);\n wSeparator=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n props.setLook(wSeparator);\n wSeparator.addModifyListener(lsMod);\n fdSeparator=new FormData();\n fdSeparator.left = new FormAttachment(middle, 0);\n fdSeparator.top = new FormAttachment(wFiletype, margin);\n fdSeparator.right= new FormAttachment(wbSeparator, -margin);\n wSeparator.setLayoutData(fdSeparator);\n wlEnclosure=new Label(wContentComp, SWT.RIGHT);\n wlEnclosure.setText(Messages.getString(\"TextFileInputDialog.Enclosure.Label\"));\n props.setLook(wlEnclosure);\n fdlEnclosure=new FormData();\n fdlEnclosure.left = new FormAttachment(0, 0);\n fdlEnclosure.top = new FormAttachment(wSeparator, margin);\n fdlEnclosure.right= new FormAttachment(middle, -margin);\n wlEnclosure.setLayoutData(fdlEnclosure);\n wEnclosure=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n props.setLook(wEnclosure);\n wEnclosure.addModifyListener(lsMod);\n fdEnclosure=new FormData();\n fdEnclosure.left = new FormAttachment(middle, 0);\n fdEnclosure.top = new FormAttachment(wSeparator, margin);\n fdEnclosure.right= new FormAttachment(100, 0);\n wEnclosure.setLayoutData(fdEnclosure);\n wlEnclBreaks=new Label(wContentComp, SWT.RIGHT);\n wlEnclBreaks.setText(Messages.getString(\"TextFileInputDialog.EnclBreaks.Label\"));\n props.setLook(wlEnclBreaks);\n fdlEnclBreaks=new FormData();\n fdlEnclBreaks.left = new FormAttachment(0, 0);\n fdlEnclBreaks.top = new FormAttachment(wEnclosure, margin);\n fdlEnclBreaks.right= new FormAttachment(middle, -margin);\n wlEnclBreaks.setLayoutData(fdlEnclBreaks);\n wEnclBreaks=new Button(wContentComp, SWT.CHECK);\n props.setLook(wEnclBreaks);\n fdEnclBreaks=new FormData();\n fdEnclBreaks.left = new FormAttachment(middle, 0);\n fdEnclBreaks.top = new FormAttachment(wEnclosure, margin);\n wEnclBreaks.setLayoutData(fdEnclBreaks);\n wlEnclBreaks.setEnabled(false);\n wEnclBreaks.setEnabled(false);\n wlEscape=new Label(wContentComp, SWT.RIGHT);\n wlEscape.setText(Messages.getString(\"TextFileInputDialog.Escape.Label\"));\n props.setLook(wlEscape);\n fdlEscape=new FormData();\n fdlEscape.left = new FormAttachment(0, 0);\n fdlEscape.top = new FormAttachment(wlEnclBreaks, margin);\n fdlEscape.right= new FormAttachment(middle, -margin);\n wlEscape.setLayoutData(fdlEscape);\n wEscape=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n props.setLook(wEscape);\n wEscape.addModifyListener(lsMod);\n fdEscape=new FormData();\n fdEscape.left = new FormAttachment(middle, 0);\n fdEscape.top = new FormAttachment(wlEnclBreaks, margin);\n fdEscape.right= new FormAttachment(100, 0);\n wEscape.setLayoutData(fdEscape);\n wlHeader=new Label(wContentComp, SWT.RIGHT);\n wlHeader.setText(Messages.getString(\"TextFileInputDialog.Header.Label\"));\n props.setLook(wlHeader);\n fdlHeader=new FormData();\n fdlHeader.left = new FormAttachment(0, 0);\n fdlHeader.top = new FormAttachment(wEscape, margin);\n fdlHeader.right= new FormAttachment(middle, -margin);\n wlHeader.setLayoutData(fdlHeader);\n wHeader=new Button(wContentComp, SWT.CHECK);\n props.setLook(wHeader);\n fdHeader=new FormData();\n fdHeader.left = new FormAttachment(middle, 0);\n fdHeader.top = new FormAttachment(wEscape, margin);\n wHeader.setLayoutData(fdHeader);\n wlNrHeader=new Label(wContentComp, SWT.RIGHT);\n wlNrHeader.setText(Messages.getString(\"TextFileInputDialog.NrHeader.Label\"));\n props.setLook(wlNrHeader);\n fdlNrHeader=new FormData();\n fdlNrHeader.left = new FormAttachment(wHeader, margin);\n fdlNrHeader.top = new FormAttachment(wEscape, margin);\n wlNrHeader.setLayoutData(fdlNrHeader);\n wNrHeader=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n wNrHeader.setTextLimit(3);\n props.setLook(wNrHeader);\n wNrHeader.addModifyListener(lsMod);\n fdNrHeader=new FormData();\n fdNrHeader.left = new FormAttachment(wlNrHeader, margin);\n fdNrHeader.top = new FormAttachment(wEscape, margin);\n fdNrHeader.right = new FormAttachment(100, 0);\n wNrHeader.setLayoutData(fdNrHeader);\n wlFooter=new Label(wContentComp, SWT.RIGHT);\n wlFooter.setText(Messages.getString(\"TextFileInputDialog.Footer.Label\"));\n props.setLook(wlFooter);\n fdlFooter=new FormData();\n fdlFooter.left = new FormAttachment(0, 0);\n fdlFooter.top = new FormAttachment(wHeader, margin);\n fdlFooter.right= new FormAttachment(middle, -margin);\n wlFooter.setLayoutData(fdlFooter);\n wFooter=new Button(wContentComp, SWT.CHECK);\n props.setLook(wFooter);\n fdFooter=new FormData();\n fdFooter.left = new FormAttachment(middle, 0);\n fdFooter.top = new FormAttachment(wHeader, margin);\n wFooter.setLayoutData(fdFooter);\n wlNrFooter=new Label(wContentComp, SWT.RIGHT);\n wlNrFooter.setText(Messages.getString(\"TextFileInputDialog.NrFooter.Label\"));\n props.setLook(wlNrFooter);\n fdlNrFooter=new FormData();\n fdlNrFooter.left = new FormAttachment(wFooter, margin);\n fdlNrFooter.top = new FormAttachment(wHeader, margin);\n wlNrFooter.setLayoutData(fdlNrFooter);\n wNrFooter=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n wNrFooter.setTextLimit(3);\n props.setLook(wNrFooter);\n wNrFooter.addModifyListener(lsMod);\n fdNrFooter=new FormData();\n fdNrFooter.left = new FormAttachment(wlNrFooter, margin);\n fdNrFooter.top = new FormAttachment(wHeader, margin);\n fdNrFooter.right = new FormAttachment(100, 0);\n wNrFooter.setLayoutData(fdNrFooter);\n wlWraps=new Label(wContentComp, SWT.RIGHT);\n wlWraps.setText(Messages.getString(\"TextFileInputDialog.Wraps.Label\"));\n props.setLook(wlWraps);\n fdlWraps=new FormData();\n fdlWraps.left = new FormAttachment(0, 0);\n fdlWraps.top = new FormAttachment(wFooter, margin);\n fdlWraps.right= new FormAttachment(middle, -margin);\n wlWraps.setLayoutData(fdlWraps);\n wWraps=new Button(wContentComp, SWT.CHECK);\n props.setLook(wWraps);\n fdWraps=new FormData();\n fdWraps.left = new FormAttachment(middle, 0);\n fdWraps.top = new FormAttachment(wFooter, margin);\n wWraps.setLayoutData(fdWraps);\n wlNrWraps=new Label(wContentComp, SWT.RIGHT);\n wlNrWraps.setText(Messages.getString(\"TextFileInputDialog.NrWraps.Label\"));\n props.setLook(wlNrWraps);\n fdlNrWraps=new FormData();\n fdlNrWraps.left = new FormAttachment(wWraps, margin);\n fdlNrWraps.top = new FormAttachment(wFooter, margin);\n wlNrWraps.setLayoutData(fdlNrWraps);\n wNrWraps=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n wNrWraps.setTextLimit(3);\n props.setLook(wNrWraps);\n wNrWraps.addModifyListener(lsMod);\n fdNrWraps=new FormData();\n fdNrWraps.left = new FormAttachment(wlNrWraps, margin);\n fdNrWraps.top = new FormAttachment(wFooter, margin);\n fdNrWraps.right = new FormAttachment(100, 0);\n wNrWraps.setLayoutData(fdNrWraps);\n wlLayoutPaged=new Label(wContentComp, SWT.RIGHT);\n wlLayoutPaged.setText(Messages.getString(\"TextFileInputDialog.LayoutPaged.Label\"));\n props.setLook(wlLayoutPaged);\n fdlLayoutPaged=new FormData();\n fdlLayoutPaged.left = new FormAttachment(0, 0);\n fdlLayoutPaged.top = new FormAttachment(wWraps, margin);\n fdlLayoutPaged.right= new FormAttachment(middle, -margin);\n wlLayoutPaged.setLayoutData(fdlLayoutPaged);\n wLayoutPaged=new Button(wContentComp, SWT.CHECK);\n props.setLook(wLayoutPaged);\n fdLayoutPaged=new FormData();\n fdLayoutPaged.left = new FormAttachment(middle, 0);\n fdLayoutPaged.top = new FormAttachment(wWraps, margin);\n wLayoutPaged.setLayoutData(fdLayoutPaged);\n wlNrLinesPerPage=new Label(wContentComp, SWT.RIGHT);\n wlNrLinesPerPage.setText(Messages.getString(\"TextFileInputDialog.NrLinesPerPage.Label\"));\n props.setLook(wlNrLinesPerPage);\n fdlNrLinesPerPage=new FormData();\n fdlNrLinesPerPage.left = new FormAttachment(wLayoutPaged, margin);\n fdlNrLinesPerPage.top = new FormAttachment(wWraps, margin);\n wlNrLinesPerPage.setLayoutData(fdlNrLinesPerPage);\n wNrLinesPerPage=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n wNrLinesPerPage.setTextLimit(3);\n props.setLook(wNrLinesPerPage);\n wNrLinesPerPage.addModifyListener(lsMod);\n fdNrLinesPerPage=new FormData();\n fdNrLinesPerPage.left = new FormAttachment(wlNrLinesPerPage, margin);\n fdNrLinesPerPage.top = new FormAttachment(wWraps, margin);\n fdNrLinesPerPage.right = new FormAttachment(100, 0);\n wNrLinesPerPage.setLayoutData(fdNrLinesPerPage);\n wlNrLinesDocHeader=new Label(wContentComp, SWT.RIGHT);\n wlNrLinesDocHeader.setText(Messages.getString(\"TextFileInputDialog.NrLinesDocHeader.Label\"));\n props.setLook(wlNrLinesDocHeader);\n fdlNrLinesDocHeader=new FormData();\n fdlNrLinesDocHeader.left = new FormAttachment(wLayoutPaged, margin);\n fdlNrLinesDocHeader.top = new FormAttachment(wNrLinesPerPage, margin);\n wlNrLinesDocHeader.setLayoutData(fdlNrLinesDocHeader);\n wNrLinesDocHeader=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n wNrLinesDocHeader.setTextLimit(3);\n props.setLook(wNrLinesDocHeader);\n wNrLinesDocHeader.addModifyListener(lsMod);\n fdNrLinesDocHeader=new FormData();\n fdNrLinesDocHeader.left = new FormAttachment(wlNrLinesPerPage, margin);\n fdNrLinesDocHeader.top = new FormAttachment(wNrLinesPerPage, margin);\n fdNrLinesDocHeader.right = new FormAttachment(100, 0);\n wNrLinesDocHeader.setLayoutData(fdNrLinesDocHeader);\n wlCompression=new Label(wContentComp, SWT.RIGHT);\n wlCompression.setText(Messages.getString(\"TextFileInputDialog.Compression.Label\"));\n props.setLook(wlCompression);\n fdlCompression=new FormData();\n fdlCompression.left = new FormAttachment(0, 0);\n fdlCompression.top = new FormAttachment(wNrLinesDocHeader, margin);\n fdlCompression.right= new FormAttachment(middle, -margin);\n wlCompression.setLayoutData(fdlCompression);\n wCompression=new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);\n wCompression.setText(Messages.getString(\"TextFileInputDialog.Compression.Label\"));\n wCompression.setToolTipText(Messages.getString(\"TextFileInputDialog.Zipped.Tooltip\"));\n props.setLook(wCompression);\n wCompression.add(\"None\");\n wCompression.add(\"Zip\");\n wCompression.add(\"GZip\");\n wCompression.select(0);\n wCompression.addModifyListener(lsMod);\n fdCompression=new FormData();\n fdCompression.left = new FormAttachment(middle, 0);\n fdCompression.top = new FormAttachment(wNrLinesDocHeader, margin);\n fdCompression.right= new FormAttachment(100, 0);\n wCompression.setLayoutData(fdCompression);\n wlNoempty=new Label(wContentComp, SWT.RIGHT);\n wlNoempty.setText(Messages.getString(\"TextFileInputDialog.NoEmpty.Label\"));\n props.setLook(wlNoempty);\n fdlNoempty=new FormData();\n fdlNoempty.left = new FormAttachment(0, 0);\n fdlNoempty.top = new FormAttachment(wCompression, margin);\n fdlNoempty.right= new FormAttachment(middle, -margin);\n wlNoempty.setLayoutData(fdlNoempty);\n wNoempty=new Button(wContentComp, SWT.CHECK );\n props.setLook(wNoempty);\n wNoempty.setToolTipText(Messages.getString(\"TextFileInputDialog.NoEmpty.Tooltip\"));\n fdNoempty=new FormData();\n fdNoempty.left = new FormAttachment(middle, 0);\n fdNoempty.top = new FormAttachment(wCompression, margin);\n fdNoempty.right= new FormAttachment(100, 0);\n wNoempty.setLayoutData(fdNoempty);\n wlInclFilename=new Label(wContentComp, SWT.RIGHT);\n wlInclFilename.setText(Messages.getString(\"TextFileInputDialog.InclFilename.Label\"));\n props.setLook(wlInclFilename);\n fdlInclFilename=new FormData();\n fdlInclFilename.left = new FormAttachment(0, 0);\n fdlInclFilename.top = new FormAttachment(wNoempty, margin);\n fdlInclFilename.right= new FormAttachment(middle, -margin);\n wlInclFilename.setLayoutData(fdlInclFilename);\n wInclFilename=new Button(wContentComp, SWT.CHECK );\n props.setLook(wInclFilename);\n wInclFilename.setToolTipText(Messages.getString(\"TextFileInputDialog.InclFilename.Tooltip\"));\n fdInclFilename=new FormData();\n fdInclFilename.left = new FormAttachment(middle, 0);\n fdInclFilename.top = new FormAttachment(wNoempty, margin);\n wInclFilename.setLayoutData(fdInclFilename);\n wlInclFilenameField=new Label(wContentComp, SWT.LEFT);\n wlInclFilenameField.setText(Messages.getString(\"TextFileInputDialog.InclFilenameField.Label\"));\n props.setLook(wlInclFilenameField);\n fdlInclFilenameField=new FormData();\n fdlInclFilenameField.left = new FormAttachment(wInclFilename, margin);\n fdlInclFilenameField.top = new FormAttachment(wNoempty, margin);\n wlInclFilenameField.setLayoutData(fdlInclFilenameField);\n wInclFilenameField=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n props.setLook(wInclFilenameField);\n wInclFilenameField.addModifyListener(lsMod);\n fdInclFilenameField=new FormData();\n fdInclFilenameField.left = new FormAttachment(wlInclFilenameField, margin);\n fdInclFilenameField.top = new FormAttachment(wNoempty, margin);\n fdInclFilenameField.right= new FormAttachment(100, 0);\n wInclFilenameField.setLayoutData(fdInclFilenameField);\n wlInclRownum=new Label(wContentComp, SWT.RIGHT);\n wlInclRownum.setText(Messages.getString(\"TextFileInputDialog.InclRownum.Label\"));\n props.setLook(wlInclRownum);\n fdlInclRownum=new FormData();\n fdlInclRownum.left = new FormAttachment(0, 0);\n fdlInclRownum.top = new FormAttachment(wInclFilenameField, margin);\n fdlInclRownum.right= new FormAttachment(middle, -margin);\n wlInclRownum.setLayoutData(fdlInclRownum);\n wInclRownum=new Button(wContentComp, SWT.CHECK );\n props.setLook(wInclRownum);\n wInclRownum.setToolTipText(Messages.getString(\"TextFileInputDialog.InclRownum.Tooltip\"));\n fdRownum=new FormData();\n fdRownum.left = new FormAttachment(middle, 0);\n fdRownum.top = new FormAttachment(wInclFilenameField, margin);\n wInclRownum.setLayoutData(fdRownum);\n wlInclRownumField=new Label(wContentComp, SWT.RIGHT);\n wlInclRownumField.setText(Messages.getString(\"TextFileInputDialog.InclRownumField.Label\"));\n props.setLook(wlInclRownumField);\n fdlInclRownumField=new FormData();\n fdlInclRownumField.left = new FormAttachment(wInclRownum, margin);\n fdlInclRownumField.top = new FormAttachment(wInclFilenameField, margin);\n wlInclRownumField.setLayoutData(fdlInclRownumField);\n wInclRownumField=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n props.setLook(wInclRownumField);\n wInclRownumField.addModifyListener(lsMod);\n fdInclRownumField=new FormData();\n fdInclRownumField.left = new FormAttachment(wlInclRownumField, margin);\n fdInclRownumField.top = new FormAttachment(wInclFilenameField, margin);\n fdInclRownumField.right= new FormAttachment(100, 0);\n wInclRownumField.setLayoutData(fdInclRownumField);\n wlFormat=new Label(wContentComp, SWT.RIGHT);\n wlFormat.setText(Messages.getString(\"TextFileInputDialog.Format.Label\"));\n props.setLook(wlFormat);\n fdlFormat=new FormData();\n fdlFormat.left = new FormAttachment(0, 0);\n fdlFormat.top = new FormAttachment(wInclRownumField, margin);\n fdlFormat.right= new FormAttachment(middle, -margin);\n wlFormat.setLayoutData(fdlFormat);\n wFormat=new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);\n wFormat.setText(Messages.getString(\"TextFileInputDialog.Format.Label\"));\n props.setLook(wFormat);\n wFormat.add(\"DOS\");\n wFormat.add(\"Unix\");\n wFormat.add(\"mixed\");\n wFormat.select(0);\n wFormat.addModifyListener(lsMod);\n fdFormat=new FormData();\n fdFormat.left = new FormAttachment(middle, 0);\n fdFormat.top = new FormAttachment(wInclRownumField, margin);\n fdFormat.right= new FormAttachment(100, 0);\n wFormat.setLayoutData(fdFormat);\n wlEncoding=new Label(wContentComp, SWT.RIGHT);\n wlEncoding.setText(Messages.getString(\"TextFileInputDialog.Encoding.Label\"));\n props.setLook(wlEncoding);\n fdlEncoding=new FormData();\n fdlEncoding.left = new FormAttachment(0, 0);\n fdlEncoding.top = new FormAttachment(wFormat, margin);\n fdlEncoding.right= new FormAttachment(middle, -margin);\n wlEncoding.setLayoutData(fdlEncoding);\n wEncoding=new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);\n wEncoding.setEditable(true);\n props.setLook(wEncoding);\n wEncoding.addModifyListener(lsMod);\n fdEncoding=new FormData();\n fdEncoding.left = new FormAttachment(middle, 0);\n fdEncoding.top = new FormAttachment(wFormat, margin);\n fdEncoding.right= new FormAttachment(100, 0);\n wEncoding.setLayoutData(fdEncoding);\n wEncoding.addFocusListener(new FocusListener()\n {\n public void focusLost(org.eclipse.swt.events.FocusEvent e)\n {\n }\n public void focusGained(org.eclipse.swt.events.FocusEvent e)\n {\n Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);\n shell.setCursor(busy);\n setEncodings();\n shell.setCursor(null);\n busy.dispose();\n }\n }\n );\n wlLimit=new Label(wContentComp, SWT.RIGHT);\n wlLimit.setText(Messages.getString(\"TextFileInputDialog.Limit.Label\"));\n props.setLook(wlLimit);\n fdlLimit=new FormData();\n fdlLimit.left = new FormAttachment(0, 0);\n fdlLimit.top = new FormAttachment(wEncoding, margin);\n fdlLimit.right= new FormAttachment(middle, -margin);\n wlLimit.setLayoutData(fdlLimit);\n wLimit=new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n props.setLook(wLimit);\n wLimit.addModifyListener(lsMod);\n fdLimit=new FormData();\n fdLimit.left = new FormAttachment(middle, 0);\n fdLimit.top = new FormAttachment(wEncoding, margin);\n fdLimit.right= new FormAttachment(100, 0);\n wLimit.setLayoutData(fdLimit);\n wlDateLenient=new Label(wContentComp, SWT.RIGHT);\n wlDateLenient.setText(Messages.getString(\"TextFileInputDialog.DateLenient.Label\"));\n props.setLook(wlDateLenient);\n fdlDateLenient=new FormData();\n fdlDateLenient.left = new FormAttachment(0, 0);\n fdlDateLenient.top = new FormAttachment(wLimit, margin);\n fdlDateLenient.right= new FormAttachment(middle, -margin);\n wlDateLenient.setLayoutData(fdlDateLenient);\n wDateLenient=new Button(wContentComp, SWT.CHECK);\n wDateLenient.setToolTipText(Messages.getString(\"TextFileInputDialog.DateLenient.Tooltip\"));\n props.setLook(wDateLenient);\n fdDateLenient=new FormData();\n fdDateLenient.left = new FormAttachment(middle, 0);\n fdDateLenient.top = new FormAttachment(wLimit, margin);\n wDateLenient.setLayoutData(fdDateLenient);\n wlDateLocale=new Label(wContentComp, SWT.RIGHT);\n wlDateLocale.setText(Messages.getString(\"TextFileInputDialog.DateLocale.Label\"));\n props.setLook(wlDateLocale);\n fdlDateLocale=new FormData();\n fdlDateLocale.left = new FormAttachment(0, 0);\n fdlDateLocale.top = new FormAttachment(wDateLenient, margin);\n fdlDateLocale.right= new FormAttachment(middle, -margin);\n wlDateLocale.setLayoutData(fdlDateLocale);\n wDateLocale=new CCombo(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);\n wDateLocale.setToolTipText(Messages.getString(\"TextFileInputDialog.DateLocale.Tooltip\"));\n props.setLook(wDateLocale);\n wDateLocale.addModifyListener(lsMod);\n fdDateLocale=new FormData();\n fdDateLocale.left = new FormAttachment(middle, 0);\n fdDateLocale.top = new FormAttachment(wDateLenient, margin);\n fdDateLocale.right= new FormAttachment(100, 0);\n wDateLocale.setLayoutData(fdDateLocale);\n Runnable runnable = new Runnable()\n\t\t{\n\t\t\tpublic void run()\n\t\t\t{\n Thread thread = new Thread(new Runnable()\n {\n public void run()\n {\n Locale locale[] = Locale.getAvailableLocales();\n dateLocale = new String[locale.length];\n for (int i=0;i set = new HashMap();\n set.put(\"key\", setMaterial);\n HashMap where = new HashMap();\n where.put(\"player\", player.getName());\n qf.doUpdate(\"player_prefs\", set, where);\n sender.sendMessage(plugin.pluginName + \"Key preference saved.\");\n return true;\n }\n }\n if (pref.equals(\"wall\") || pref.equals(\"floor\")) {\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"You need to specify a \" + pref + \" material!\");\n return false;\n }\n String wall_mat;\n if (args.length > 2) {\n int count = args.length;\n StringBuilder buf = new StringBuilder();\n for (int i = 1; i < count; i++) {\n buf.append(args[i]).append(\"_\");\n }\n String tmp = buf.toString();\n String t = tmp.substring(0, tmp.length() - 1);\n wall_mat = t.toUpperCase(Locale.ENGLISH);\n } else {\n wall_mat = args[1].toUpperCase(Locale.ENGLISH);\n }\n TARDISWalls tw = new TARDISWalls();\n if (!tw.blocks.containsKey(wall_mat)) {\n String message = (wall_mat.equals(\"HELP\")) ? \"Here is a list of valid \" + pref + \" materials:\" : \"That is not a valid \" + pref + \" material! Try:\";\n sender.sendMessage(plugin.pluginName + message);\n List sortedKeys = new ArrayList(tw.blocks.keySet());\n Collections.sort(sortedKeys);\n for (String w : sortedKeys) {\n sender.sendMessage(w);\n }\n return true;\n }\n QueryFactory qf = new QueryFactory(plugin);\n HashMap set = new HashMap();\n set.put(pref, wall_mat);\n HashMap where = new HashMap();\n where.put(\"player\", player.getName());\n qf.doUpdate(\"player_prefs\", set, where);\n sender.sendMessage(plugin.pluginName + ucfirst(pref) + \" material saved.\");\n return true;\n }\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"on\") && !args[1].equalsIgnoreCase(\"off\"))) {\n sender.sendMessage(plugin.pluginName + \"You need to specify if \" + pref + \" should be on or off!\");\n return false;\n }\n HashMap where = new HashMap();\n where.put(\"player\", player.getName());\n ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, where);\n QueryFactory qf = new QueryFactory(plugin);\n HashMap set = new HashMap();\n if (!rsp.resultSet()) {\n set.put(\"player\", player.getName());\n qf.doInsert(\"player_prefs\", set);\n }\n HashMap setp = new HashMap();\n HashMap wherep = new HashMap();\n wherep.put(\"player\", player.getName());\n String grammar = (TARDISConstants.vowels.contains(pref.substring(0, 1))) ? \" was\" : \" were\";\n if (args[1].equalsIgnoreCase(\"on\")) {\n setp.put(pref + \"_on\", 1);\n sender.sendMessage(plugin.pluginName + pref + grammar + \" turned ON!\");\n }\n if (args[1].equalsIgnoreCase(\"off\")) {\n setp.put(pref + \"_on\", 0);\n sender.sendMessage(plugin.pluginName + pref + grammar + \" turned OFF.\");\n }\n qf.doUpdate(\"player_prefs\", setp, wherep);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n }\n return false;\n }\n", "output": " public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {\n Player player = null;\n if (sender instanceof Player) {\n player = (Player) sender;\n }\n if (cmd.getName().equalsIgnoreCase(\"tardisprefs\")) {\n if (args.length == 0) {\n return false;\n }\n if (player == null) {\n sender.sendMessage(plugin.pluginName + ChatColor.RED + \" This command can only be run by a player\");\n return false;\n }\n String pref = args[0].toLowerCase(Locale.ENGLISH);\n if (firstArgs.contains(pref)) {\n if (player.hasPermission(\"tardis.timetravel\")) {\n if (pref.equals(\"key\")) {\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"You need to specify a key item!\");\n return false;\n }\n String setMaterial = args[1].toUpperCase(Locale.ENGLISH);\n if (!Arrays.asList(TARDISMaterials.MATERIAL_LIST).contains(setMaterial)) {\n sender.sendMessage(plugin.pluginName + ChatColor.RED + \"That is not a valid Material! Try checking http://jd.bukkit.org/apidocs/org/bukkit/Material.html\");\n return false;\n } else {\n QueryFactory qf = new QueryFactory(plugin);\n HashMap set = new HashMap();\n set.put(\"key\", setMaterial);\n HashMap where = new HashMap();\n where.put(\"player\", player.getName());\n qf.doUpdate(\"player_prefs\", set, where);\n sender.sendMessage(plugin.pluginName + \"Key preference saved.\");\n return true;\n }\n }\n if (pref.equals(\"wall\") || pref.equals(\"floor\")) {\n if (args.length < 2) {\n sender.sendMessage(plugin.pluginName + \"You need to specify a \" + pref + \" material!\");\n return false;\n }\n String wall_mat;\n if (args.length > 2) {\n int count = args.length;\n StringBuilder buf = new StringBuilder();\n for (int i = 1; i < count; i++) {\n buf.append(args[i]).append(\"_\");\n }\n String tmp = buf.toString();\n String t = tmp.substring(0, tmp.length() - 1);\n wall_mat = t.toUpperCase(Locale.ENGLISH);\n } else {\n wall_mat = args[1].toUpperCase(Locale.ENGLISH);\n }\n TARDISWalls tw = new TARDISWalls();\n if (!tw.blocks.containsKey(wall_mat)) {\n String message = (wall_mat.equals(\"HELP\")) ? \"Here is a list of valid \" + pref + \" materials:\" : \"That is not a valid \" + pref + \" material! Try:\";\n sender.sendMessage(plugin.pluginName + message);\n List sortedKeys = new ArrayList(tw.blocks.keySet());\n Collections.sort(sortedKeys);\n for (String w : sortedKeys) {\n sender.sendMessage(w);\n }\n return true;\n }\n QueryFactory qf = new QueryFactory(plugin);\n HashMap set = new HashMap();\n set.put(pref, wall_mat);\n HashMap where = new HashMap();\n where.put(\"player\", player.getName());\n qf.doUpdate(\"player_prefs\", set, where);\n sender.sendMessage(plugin.pluginName + ucfirst(pref) + \" material saved.\");\n return true;\n }\n if (args.length < 2 || (!args[1].equalsIgnoreCase(\"on\") && !args[1].equalsIgnoreCase(\"off\"))) {\n sender.sendMessage(plugin.pluginName + \"You need to specify if \" + pref + \" should be on or off!\");\n return false;\n }\n List was = Arrays.asList(new String[]{\"auto\", \"platform\"});\n HashMap where = new HashMap();\n where.put(\"player\", player.getName());\n ResultSetPlayerPrefs rsp = new ResultSetPlayerPrefs(plugin, where);\n QueryFactory qf = new QueryFactory(plugin);\n HashMap set = new HashMap();\n if (!rsp.resultSet()) {\n set.put(\"player\", player.getName());\n qf.doInsert(\"player_prefs\", set);\n }\n HashMap setp = new HashMap();\n HashMap wherep = new HashMap();\n wherep.put(\"player\", player.getName());\n String grammar = (was.contains(pref)) ? \" was\" : \" were\";\n if (args[1].equalsIgnoreCase(\"on\")) {\n setp.put(pref + \"_on\", 1);\n sender.sendMessage(plugin.pluginName + pref + grammar + \" turned ON!\");\n }\n if (args[1].equalsIgnoreCase(\"off\")) {\n setp.put(pref + \"_on\", 0);\n sender.sendMessage(plugin.pluginName + pref + grammar + \" turned OFF.\");\n }\n qf.doUpdate(\"player_prefs\", setp, wherep);\n return true;\n } else {\n sender.sendMessage(plugin.pluginName + TARDISConstants.NO_PERMS_MESSAGE);\n return false;\n }\n }\n }\n return false;\n }\n"} {"input": " public static void main(String[] args) throws Exception {\n Configuration conf = new Configuration(args);\n Map scans = conf.getScans();\n List proteins = conf.getProteins();\n Map results = conf.getMSAlignResults();\n for (int scanId : results.keySet()) {\n Document doc = new Document();\n Element prsm = new Element(\"prsm\");\n doc.setRootElement(prsm);\n prsm.addContent(scans.get(scanId).toXml());\n prsm.addContent(proteins.get(results.get(scanId)).toXml());\n XmlUtil.saveXml(doc, new File(conf.getXmlPrsmDir(),\"scan\" + scanId + \".xml\"));\n }\n }\n", "output": " public static void main(String[] args) throws Exception {\n Configuration conf = new Configuration(args);\n Map scans = conf.getScans();\n List proteins = conf.getProteins();\n Map results = conf.getMSAlignResults();\n for (int scanId : scans.keySet()) {\n Document doc = new Document();\n Element prsm = new Element(\"prsm\");\n doc.setRootElement(prsm);\n prsm.addContent(scans.get(scanId).toXml());\n Integer proteinId = results.get(scanId);\n if (proteinId != null) {\n prsm.addContent(proteins.get(proteinId).toXml());\n }\n XmlUtil.saveXml(doc, new File(conf.getXmlPrsmDir(),\"scan\" + scanId + \".xml\"));\n }\n }\n"} {"input": " public Collection>> definePartitions(Collection>> partitions, int incrementalCapacity)\n {\n Collection c = partitions;\n Collection>> operatorPartitions = c;\n Partition> template = null;\n Iterator>> itr = operatorPartitions.iterator();\n template = itr.next();\n String[] connectionArr = connectionList.trim().split(\"\\\\|\");\n int size = connectionArr.length;\n if (size > (incrementalCapacity + operatorPartitions.size()))\n size = incrementalCapacity + operatorPartitions.size();\n int partitionBits = (Integer.numberOfLeadingZeros(0) - Integer.numberOfLeadingZeros(size - 1));\n int partitionMask = 0;\n if (partitionBits > 0) {\n partitionMask = -1 >>> (Integer.numberOfLeadingZeros(-1)) - partitionBits;\n }\n LOG.debug(\"partition mask {}\", partitionMask);\n ArrayList>> operList = new ArrayList>>(size);\n while (size > 0) {\n size--;\n RedisOutputOperator opr = new RedisOutputOperator();\n opr.setConnectionList(connectionArr[size].trim());\n opr.setKeyExpiryTime(keyExpiryTime);\n opr.setTimeout(timeout);\n opr.setContinueOnError(continueOnError);\n opr.setName(getName());\n Partition> p = new DefaultPartition(opr);\n operList.add(p);\n }\n for (int i = 0; i <= partitionMask; i++) {\n Partition> p = operList.get(i % operList.size());\n PartitionKeys pks = p.getPartitionKeys().get(input);\n if (pks == null) {\n p.getPartitionKeys().put(input, new PartitionKeys(partitionMask, Sets.newHashSet(i)));\n } else {\n pks.partitions.add(i);\n }\n pks = p.getPartitionKeys().get(inputInd);\n if (pks == null) {\n p.getPartitionKeys().put(inputInd, new PartitionKeys(partitionMask, Sets.newHashSet(i)));\n } else {\n pks.partitions.add(i);\n }\n }\n return operList;\n }\n", "output": " public Collection>> definePartitions(Collection>> partitions, int incrementalCapacity)\n {\n Collection c = partitions;\n Collection>> operatorPartitions = c;\n Partition> template = null;\n Iterator>> itr = operatorPartitions.iterator();\n template = itr.next();\n if(connectionList == null){\n connectionList = host+\":\"+port+\",\"+dbIndex;\n }\n String[] connectionArr = connectionList.trim().split(\"\\\\|\");\n int size = connectionArr.length;\n if (size > (incrementalCapacity + operatorPartitions.size()))\n size = incrementalCapacity + operatorPartitions.size();\n int partitionBits = (Integer.numberOfLeadingZeros(0) - Integer.numberOfLeadingZeros(size - 1));\n int partitionMask = 0;\n if (partitionBits > 0) {\n partitionMask = -1 >>> (Integer.numberOfLeadingZeros(-1)) - partitionBits;\n }\n LOG.debug(\"partition mask {}\", partitionMask);\n ArrayList>> operList = new ArrayList>>(size);\n while (size > 0) {\n size--;\n RedisOutputOperator opr = new RedisOutputOperator();\n opr.setConnectionList(connectionArr[size].trim());\n opr.setKeyExpiryTime(keyExpiryTime);\n opr.setTimeout(timeout);\n opr.setContinueOnError(continueOnError);\n opr.setName(getName());\n Partition> p = new DefaultPartition(opr);\n operList.add(p);\n }\n for (int i = 0; i <= partitionMask; i++) {\n Partition> p = operList.get(i % operList.size());\n PartitionKeys pks = p.getPartitionKeys().get(input);\n if (pks == null) {\n p.getPartitionKeys().put(input, new PartitionKeys(partitionMask, Sets.newHashSet(i)));\n } else {\n pks.partitions.add(i);\n }\n pks = p.getPartitionKeys().get(inputInd);\n if (pks == null) {\n p.getPartitionKeys().put(inputInd, new PartitionKeys(partitionMask, Sets.newHashSet(i)));\n } else {\n pks.partitions.add(i);\n }\n }\n return operList;\n }\n"} {"input": "\tpublic boolean onContextItemSelected(final MenuItem item) {\n\t\tswitch (item.getItemId()) {\n\t\tcase ID_CONTEXTMENU_CHANGE_TITLE:\n\t\t\tfinal EditText inputField = new EditText(this);\n\t\t\tfinal AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();\n\t\t\tfinal WhiteBoard currentWhiteBoard = existingWhiteBoards.get((int) info.id);\n\t\t\tinputField.setText(currentWhiteBoard.title);\n\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t.setTitle(R.string.title_dialog_change_title)\n\t\t\t\t.setView(inputField)\n\t\t\t\t.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tcurrentWhiteBoard.title = inputField.getText().toString();\n\t\t\t\t\t\tdatabaseHelper.addWhiteBoard(currentWhiteBoard);\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.setNeutralButton(R.string.button_cancel, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.show();\n\t\t\treturn true;\n\t\tcase ID_CONTEXTMENU_DELETE_WHITEBOARD:\n\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t.setTitle(R.string.title_dialog_delete)\n\t\t\t\t.setMessage(R.string.confirm_deleteWhiteBoard)\n\t\t\t\t.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tAdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();\n\t\t\t\t\t\tdatabaseHelper.deleteWhiteBoard(existingWhiteBoards.get((int) info.id - 1).id);\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.setNeutralButton(R.string.button_cancel, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.show();\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn super.onContextItemSelected(item);\n\t\t}\n\t}\n", "output": "\tpublic boolean onContextItemSelected(final MenuItem item) {\n\t\tswitch (item.getItemId()) {\n\t\tcase ID_CONTEXTMENU_CHANGE_TITLE:\n\t\t\tfinal EditText inputField = new EditText(this);\n\t\t\tfinal AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();\n\t\t\tfinal WhiteBoard currentWhiteBoard = existingWhiteBoards.get((int) info.id - 1);\n\t\t\tinputField.setText(currentWhiteBoard.title);\n\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t.setTitle(R.string.title_dialog_change_title)\n\t\t\t\t.setView(inputField)\n\t\t\t\t.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tcurrentWhiteBoard.title = inputField.getText().toString();\n\t\t\t\t\t\tdatabaseHelper.addWhiteBoard(currentWhiteBoard);\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.setNeutralButton(R.string.button_cancel, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.show();\n\t\t\treturn true;\n\t\tcase ID_CONTEXTMENU_DELETE_WHITEBOARD:\n\t\t\tnew AlertDialog.Builder(this)\n\t\t\t\t.setTitle(R.string.title_dialog_delete)\n\t\t\t\t.setMessage(R.string.confirm_deleteWhiteBoard)\n\t\t\t\t.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tAdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();\n\t\t\t\t\t\tdatabaseHelper.deleteWhiteBoard(existingWhiteBoards.get((int) info.id - 1).id);\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.setNeutralButton(R.string.button_cancel, new DialogInterface.OnClickListener() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\t\tdialog.dismiss();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.show();\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn super.onContextItemSelected(item);\n\t\t}\n\t}\n"} {"input": " public void testIPv6Host() throws Exception {\n List addrs = AddrUtil.getAddresses(\"::1:80\");\n assertEquals(1, addrs.size());\n Set validLocalhostNames = new HashSet();\n validLocalhostNames.add(\"localhost\");\n validLocalhostNames.add(\"ip6-localhost\");\n validLocalhostNames.add(\"localhost6.localdomain6\");\n assert (validLocalhostNames.contains(addrs.get(0).getHostName()));\n assertEquals(80, addrs.get(0).getPort());\n }\n", "output": " public void testIPv6Host() throws Exception {\n List addrs = AddrUtil.getAddresses(\"::1:80\");\n assertEquals(1, addrs.size());\n Set validLocalhostNames = new HashSet();\n validLocalhostNames.add(\"localhost\");\n validLocalhostNames.add(\"ip6-localhost\");\n validLocalhostNames.add(\"0:0:0:0:0:0:0:1\");\n validLocalhostNames.add(\"localhost6.localdomain6\");\n assert (validLocalhostNames.contains(addrs.get(0).getHostName()));\n assertEquals(80, addrs.get(0).getPort());\n }\n"} {"input": " protected void initFile(String id) throws FormatException, IOException {\n debug(\"BioRadReader.initFile(\" + id + \")\");\n if (!checkSuffix(id, PIC_SUFFIX)) {\n Location dir = new Location(id).getAbsoluteFile().getParentFile();\n String[] list = dir.list();\n for (int i=0; i();\n used.add(currentId);\n status(\"Reading image dimensions\");\n noteStrings = new Vector();\n core[0].sizeX = in.readShort();\n core[0].sizeY = in.readShort();\n int npic = in.readShort();\n core[0].imageCount = npic;\n int ramp1min = in.readShort();\n int ramp1max = in.readShort();\n boolean notes = in.readInt() != 0;\n core[0].pixelType =\n in.readShort() == 0 ? FormatTools.UINT16 : FormatTools.UINT8;\n int imageNumber = in.readShort();\n String name = in.readString(32);\n int merged = in.readShort();\n int color1 = in.readShort();\n int fileId = in.readShort();\n int ramp2min = in.readShort();\n int ramp2max = in.readShort();\n int color2 = in.readShort();\n int edited = in.readShort();\n int lens = in.readShort();\n float magFactor = in.readFloat();\n if (fileId != PIC_FILE_ID) {\n throw new FormatException(\"Invalid file header : \" + fileId);\n }\n addGlobalMeta(\"nx\", getSizeX());\n addGlobalMeta(\"ny\", getSizeY());\n addGlobalMeta(\"npic\", getImageCount());\n addGlobalMeta(\"ramp1_min\", ramp1min);\n addGlobalMeta(\"ramp1_max\", ramp1max);\n addGlobalMeta(\"notes\", notes);\n addGlobalMeta(\"image_number\", imageNumber);\n addGlobalMeta(\"name\", name);\n addGlobalMeta(\"merged\", MERGE_NAMES[merged]);\n addGlobalMeta(\"color1\", color1);\n addGlobalMeta(\"file_id\", fileId);\n addGlobalMeta(\"ramp2_min\", ramp2min);\n addGlobalMeta(\"ramp2_max\", ramp2max);\n addGlobalMeta(\"color2\", color2);\n addGlobalMeta(\"edited\", edited);\n addGlobalMeta(\"lens\", lens);\n addGlobalMeta(\"mag_factor\", magFactor);\n int imageLen = getSizeX() * getSizeY();\n int bpp = FormatTools.getBytesPerPixel(getPixelType());\n in.skipBytes(bpp * getImageCount() * imageLen + 6);\n core[0].sizeZ = getImageCount();\n core[0].sizeC = 1;\n core[0].sizeT = 1;\n core[0].orderCertain = false;\n core[0].rgb = false;\n core[0].interleaved = false;\n core[0].littleEndian = LITTLE_ENDIAN;\n core[0].metadataComplete = true;\n core[0].falseColor = true;\n status(\"Reading notes\");\n String zoom = null, zstart = null, zstop = null, mag = null;\n String gain1 = null, gain2 = null, gain3 = null;\n String offset1 = null;\n String ex1 = null, ex2 = null, ex3 = null;\n String em1 = null, em2 = null, em3 = null;\n MetadataStore store =\n new FilterMetadata(getMetadataStore(), isMetadataFiltered());\n int nLasers = 0;\n int noteCount = 0;\n boolean brokenNotes = false;\n while (notes) {\n Note n = new Note();\n n.level = in.readShort();\n notes = in.readInt() != 0;\n n.num = in.readShort();\n n.status = in.readShort();\n n.type = in.readShort();\n n.x = in.readShort();\n n.y = in.readShort();\n n.p = in.readString(80);\n if (n.type < 0 || n.type >= NOTE_NAMES.length) {\n notes = false;\n brokenNotes = true;\n break;\n }\n int ndx = n.p.length();\n for (int i=0; i 0) v.add(token);\n }\n String[] tokens = (String[]) v.toArray(new String[0]);\n try {\n if (tokens.length > 1) {\n int noteType = Integer.parseInt(tokens[1]);\n if (noteType == 2 && value.indexOf(\"AXIS_4\") != -1) {\n core[0].sizeZ = 1;\n core[0].sizeT = getImageCount();\n core[0].orderCertain = true;\n }\n }\n }\n catch (NumberFormatException e) { }\n noteCount++;\n noteStrings.add(n);\n }\n status(\"Reading color table\");\n int numLuts = 0;\n lut = new byte[3][3][256];\n boolean eof = false;\n int next = 0;\n while (!eof && numLuts < 3 && !brokenNotes) {\n if (in.getFilePointer() + lut[numLuts][next].length <= in.length()) {\n in.read(lut[numLuts][next++]);\n if (next == 3) {\n next = 0;\n numLuts++;\n }\n }\n else eof = true;\n if (eof && numLuts == 0) lut = null;\n }\n if (brokenNotes) lut = null;\n String message = numLuts + \" color table\" + (numLuts == 1 ? \"\" : \"s\") +\n \" present.\";\n debug(message, 2);\n status(\"Populating metadata\");\n Location parent = new Location(currentId).getAbsoluteFile().getParentFile();\n String[] list = parent.list();\n Arrays.sort(list);\n Vector pics = new Vector();\n for (int i=0; i 0) {\n core[0].imageCount = npic * picFiles.length;\n core[0].sizeC = getImageCount() / (getSizeZ() * getSizeT());\n }\n else picFiles = null;\n for (int q=0; q= 0) {\n String key = n.p.substring(0, n.p.indexOf(\"=\")).trim();\n String value = n.p.substring(n.p.indexOf(\"=\") + 1).trim();\n addGlobalMeta(key, value);\n if (key.equals(\"INFO_OBJECTIVE_NAME\")) {\n store.setObjectiveModel(value, 0, 0);\n }\n else if (key.equals(\"INFO_OBJECTIVE_MAGNIFICATION\")) {\n store.setObjectiveNominalMagnification(\n new Integer((int) Double.parseDouble(value)), 0, 0);\n }\n else if (key.equals(\"LENS_MAGNIFICATION\")) {\n store.setObjectiveNominalMagnification(\n new Integer((int) Double.parseDouble(value)), 0, 0);\n }\n else if (key.startsWith(\"SETTING\")) {\n if (key.indexOf(\"_DET_\") != -1) {\n int index = key.indexOf(\"_DET_\") + 5;\n if (key.lastIndexOf(\"_\") > index) {\n String idx = key.substring(index, key.indexOf(\"_\", index));\n int detector = Integer.parseInt(idx) - 1;\n if (key.endsWith(\"OFFSET\")) {\n store.setDetectorSettingsOffset(\n new Float(value), 0, detector);\n }\n else if (key.endsWith(\"GAIN\")) {\n store.setDetectorSettingsGain(\n new Float(value), 0, detector);\n }\n store.setDetectorType(\"Unknown\", 0, detector);\n store.setDetectorID(\"Detector:\" + detector, 0, detector);\n store.setDetectorSettingsDetector(\"Detector:\" + detector, 0,\n detector);\n }\n }\n }\n else {\n String[] values = value.split(\" \");\n if (values.length > 1) {\n try {\n int type = Integer.parseInt(values[0]);\n if (type == 257 && values.length >= 3) {\n float start = Float.parseFloat(values[1]);\n float end = Float.parseFloat(values[2]);\n float axisLength = end - start;\n if (key.equals(\"AXIS_2\")) {\n float pixelSize = axisLength / getSizeX();\n store.setDimensionsPhysicalSizeX(\n new Float(pixelSize), 0, 0);\n }\n else if (key.equals(\"AXIS_3\")) {\n float pixelSize = axisLength / getSizeY();\n store.setDimensionsPhysicalSizeY(\n new Float(pixelSize), 0, 0);\n }\n }\n }\n catch (NumberFormatException e) { }\n }\n }\n }\n else {\n addGlobalMeta(\"Note #\" + noteCount, n.toString());\n }\n break;\n case NOTE_TYPE_STRUCTURE:\n int structureType = (n.x & 0xff00) >> 8;\n int version = (n.x & 0xff);\n String[] values = n.p.split(\" \");\n if (structureType == 1) {\n switch (n.y) {\n case 1:\n addGlobalMeta(\"Scan Channel\", values[0]);\n addGlobalMeta(\"Both mode\", values[1]);\n addGlobalMeta(\"Speed\", values[2]);\n addGlobalMeta(\"Filter\", values[3]);\n addGlobalMeta(\"Factor\", values[4]);\n addGlobalMeta(\"Number of scans\", values[5]);\n addGlobalMeta(\"Photon counting mode (channel 1)\", values[6]);\n addGlobalMeta(\"Photon counting detector (channel 1)\",\n values[7]);\n addGlobalMeta(\"Photon counting mode (channel 2)\", values[8]);\n addGlobalMeta(\"Photon counting detector (channel 2)\",\n values[9]);\n addGlobalMeta(\"Photon mode\", values[10]);\n addGlobalMeta(\"Objective magnification\", values[11]);\n addGlobalMeta(\"Zoom factor\", values[12]);\n addGlobalMeta(\"Motor on\", values[13]);\n addGlobalMeta(\"Z Step Size\", values[14]);\n store.setObjectiveNominalMagnification(\n new Integer((int) Double.parseDouble(values[11])), 0, 0);\n store.setDisplayOptionsZoom(new Float(values[12]), 0);\n store.setDimensionsPhysicalSizeZ(new Float(values[14]), 0, 0);\n break;\n case 2:\n addGlobalMeta(\"Z Start\", values[0]);\n addGlobalMeta(\"Z Stop\", values[1]);\n addGlobalMeta(\"Scan area X coordinate\", values[2]);\n addGlobalMeta(\"Scan area Y coordinate\", values[3]);\n addGlobalMeta(\"Scan area width\", values[4]);\n addGlobalMeta(\"Scan area height\", values[5]);\n float width =\n Float.parseFloat(values[4]) - Float.parseFloat(values[2]);\n width /= getSizeX();\n float height =\n Float.parseFloat(values[5]) - Float.parseFloat(values[3]);\n height /= getSizeY();\n store.setDimensionsPhysicalSizeX(new Float(width), 0, 0);\n store.setDimensionsPhysicalSizeY(new Float(height), 0, 0);\n break;\n case 3:\n for (int i=0; i<3; i++) {\n addGlobalMeta(\"Iris for PMT \" + (i + 1), values[i * 4]);\n addGlobalMeta(\"Gain for PMT \" + (i + 1), values[i * 4 + 1]);\n addGlobalMeta(\"Black level for PMT \" + (i + 1),\n values[i * 4 + 2]);\n addGlobalMeta(\"Emission filter for PMT \" + (i+1),\n values[i*4] + 3);\n addGlobalMeta(\"Multiplier for channel \" + (i+1),\n values[12 + i]);\n }\n break;\n case 4:\n nLasers = Integer.parseInt(values[0]);\n addGlobalMeta(\"Number of lasers\", values[0]);\n addGlobalMeta(\"Number of transmission detectors\", values[1]);\n addGlobalMeta(\"Number of PMTs\", values[2]);\n for (int i=1; i<=3; i++) {\n int idx = (i + 1) * 3;\n addGlobalMeta(\"Shutter present for laser \" + i,\n values[i + 2]);\n addGlobalMeta(\"Neutral density filter for laser \" + i,\n values[idx]);\n addGlobalMeta(\"Excitation filter for laser \" + i,\n values[idx + 1]);\n addGlobalMeta(\"Use laser \" + i, values[idx + 2]);\n }\n for (int i=0; i 0) v.add(token);\n }\n String[] values = (String[]) v.toArray(new String[0]);\n String key = values[0];\n String noteType = values[1];\n int axisType = Integer.parseInt(noteType);\n if (values.length > 2) {\n switch (axisType) {\n case 1:\n String dx = values[2];\n String dy = values[3];\n addGlobalMeta(key + \" distance (X) in microns\", dx);\n addGlobalMeta(key + \" distance (Y) in microns\", dy);\n break;\n case 3:\n addGlobalMeta(key + \" angle (X) in degrees\", values[2]);\n addGlobalMeta(key + \" angle (Y) in degrees\", values[3]);\n break;\n case 4:\n addGlobalMeta(key + \" intensity (X)\", values[2]);\n addGlobalMeta(key + \" intensity (Y)\", values[3]);\n break;\n case 6:\n addGlobalMeta(key + \" ratio (X)\", values[2]);\n addGlobalMeta(key + \" ratio (Y)\", values[3]);\n break;\n case 7:\n addGlobalMeta(key + \" log ratio (X)\", values[2]);\n addGlobalMeta(key + \" log ratio (Y)\", values[3]);\n break;\n case 9:\n addGlobalMeta(key + \" noncalibrated intensity min\", values[2]);\n addGlobalMeta(key + \" noncalibrated intensity max\", values[3]);\n addGlobalMeta(key + \" calibrated intensity min\", values[4]);\n addGlobalMeta(key + \" calibrated intensity max\", values[5]);\n break;\n case 11:\n addGlobalMeta(key + \" RGB type (X)\", values[2]);\n addGlobalMeta(key + \" RGB type (Y)\", values[3]);\n if (key.equals(\"AXIS_4\")) {\n core[0].sizeC = getImageCount();\n core[0].sizeZ = 1;\n core[0].sizeT = 1;\n }\n break;\n case 14:\n addGlobalMeta(key + \" time course type (X)\", values[2]);\n addGlobalMeta(key + \" time course type (Y)\", values[3]);\n break;\n case 15:\n String prefix = \" inverse sigmoid calibrated intensity \";\n addGlobalMeta(key + prefix + \"(min)\", values[2]);\n addGlobalMeta(key + prefix + \"(max)\", values[3]);\n addGlobalMeta(key + prefix + \"(beta)\", values[4]);\n addGlobalMeta(key + prefix + \"(Kd)\", values[5]);\n break;\n case 16:\n prefix = \" log inverse sigmoid calibrated intensity \";\n addGlobalMeta(key + prefix + \"(min)\", values[2]);\n addGlobalMeta(key + prefix + \"(max)\", values[3]);\n addGlobalMeta(key + prefix + \"(beta)\", values[4]);\n addGlobalMeta(key + prefix + \"(Kd)\", values[5]);\n break;\n }\n }\n }\n }\n MetadataTools.populatePixels(store, this);\n MetadataTools.setDefaultCreationDate(store, id, 0);\n store.setImageName(name, 0);\n store.setInstrumentID(\"Instrument:0\", 0);\n store.setImageInstrumentRef(\"Instrument:0\", 0);\n store.setObjectiveID(\"Objective:0\", 0, 0);\n store.setObjectiveSettingsObjective(\"Objective:0\", 0);\n store.setObjectiveLensNA(new Float(lens), 0, 0);\n store.setObjectiveNominalMagnification(new Integer((int) magFactor), 0, 0);\n store.setObjectiveCorrection(\"Unknown\", 0, 0);\n store.setObjectiveImmersion(\"Unknown\", 0, 0);\n }\n", "output": " protected void initFile(String id) throws FormatException, IOException {\n debug(\"BioRadReader.initFile(\" + id + \")\");\n if (!checkSuffix(id, PIC_SUFFIX)) {\n Location dir = new Location(id).getAbsoluteFile().getParentFile();\n String[] list = dir.list();\n for (int i=0; i();\n used.add(currentId);\n status(\"Reading image dimensions\");\n noteStrings = new Vector();\n core[0].sizeX = in.readShort();\n core[0].sizeY = in.readShort();\n int npic = in.readShort();\n core[0].imageCount = npic;\n int ramp1min = in.readShort();\n int ramp1max = in.readShort();\n boolean notes = in.readInt() != 0;\n core[0].pixelType =\n in.readShort() == 0 ? FormatTools.UINT16 : FormatTools.UINT8;\n int imageNumber = in.readShort();\n String name = in.readString(32);\n int merged = in.readShort();\n int color1 = in.readShort();\n int fileId = in.readShort();\n int ramp2min = in.readShort();\n int ramp2max = in.readShort();\n int color2 = in.readShort();\n int edited = in.readShort();\n int lens = in.readShort();\n float magFactor = in.readFloat();\n if (fileId != PIC_FILE_ID) {\n throw new FormatException(\"Invalid file header : \" + fileId);\n }\n addGlobalMeta(\"nx\", getSizeX());\n addGlobalMeta(\"ny\", getSizeY());\n addGlobalMeta(\"npic\", getImageCount());\n addGlobalMeta(\"ramp1_min\", ramp1min);\n addGlobalMeta(\"ramp1_max\", ramp1max);\n addGlobalMeta(\"notes\", notes);\n addGlobalMeta(\"image_number\", imageNumber);\n addGlobalMeta(\"name\", name);\n addGlobalMeta(\"merged\", MERGE_NAMES[merged]);\n addGlobalMeta(\"color1\", color1);\n addGlobalMeta(\"file_id\", fileId);\n addGlobalMeta(\"ramp2_min\", ramp2min);\n addGlobalMeta(\"ramp2_max\", ramp2max);\n addGlobalMeta(\"color2\", color2);\n addGlobalMeta(\"edited\", edited);\n addGlobalMeta(\"lens\", lens);\n addGlobalMeta(\"mag_factor\", magFactor);\n int imageLen = getSizeX() * getSizeY();\n int bpp = FormatTools.getBytesPerPixel(getPixelType());\n in.skipBytes(bpp * getImageCount() * imageLen + 6);\n core[0].sizeZ = getImageCount();\n core[0].sizeC = 1;\n core[0].sizeT = 1;\n core[0].orderCertain = false;\n core[0].rgb = false;\n core[0].interleaved = false;\n core[0].littleEndian = LITTLE_ENDIAN;\n core[0].metadataComplete = true;\n core[0].falseColor = true;\n status(\"Reading notes\");\n String zoom = null, zstart = null, zstop = null, mag = null;\n String gain1 = null, gain2 = null, gain3 = null;\n String offset1 = null;\n String ex1 = null, ex2 = null, ex3 = null;\n String em1 = null, em2 = null, em3 = null;\n MetadataStore store =\n new FilterMetadata(getMetadataStore(), isMetadataFiltered());\n int nLasers = 0;\n int noteCount = 0;\n boolean brokenNotes = false;\n while (notes) {\n Note n = new Note();\n n.level = in.readShort();\n notes = in.readInt() != 0;\n n.num = in.readShort();\n n.status = in.readShort();\n n.type = in.readShort();\n n.x = in.readShort();\n n.y = in.readShort();\n n.p = in.readString(80);\n if (n.type < 0 || n.type >= NOTE_NAMES.length) {\n notes = false;\n brokenNotes = true;\n break;\n }\n int ndx = n.p.length();\n for (int i=0; i 0) v.add(token);\n }\n String[] tokens = (String[]) v.toArray(new String[0]);\n try {\n if (tokens.length > 1) {\n int noteType = Integer.parseInt(tokens[1]);\n if (noteType == 2 && value.indexOf(\"AXIS_4\") != -1) {\n core[0].sizeZ = 1;\n core[0].sizeT = getImageCount();\n core[0].orderCertain = true;\n }\n }\n }\n catch (NumberFormatException e) { }\n noteCount++;\n noteStrings.add(n);\n }\n status(\"Reading color table\");\n int numLuts = 0;\n lut = new byte[3][3][256];\n boolean eof = false;\n int next = 0;\n while (!eof && numLuts < 3 && !brokenNotes) {\n if (in.getFilePointer() + lut[numLuts][next].length <= in.length()) {\n in.read(lut[numLuts][next++]);\n if (next == 3) {\n next = 0;\n numLuts++;\n }\n }\n else eof = true;\n if (eof && numLuts == 0) lut = null;\n }\n if (brokenNotes) lut = null;\n String message = numLuts + \" color table\" + (numLuts == 1 ? \"\" : \"s\") +\n \" present.\";\n debug(message, 2);\n status(\"Populating metadata\");\n Location parent = new Location(currentId).getAbsoluteFile().getParentFile();\n String[] list = parent.list();\n Arrays.sort(list);\n Vector pics = new Vector();\n for (int i=0; i 0) {\n core[0].imageCount = npic * picFiles.length;\n core[0].sizeC = getImageCount() / (getSizeZ() * getSizeT());\n }\n else picFiles = null;\n for (int q=0; q= 0) {\n String key = n.p.substring(0, n.p.indexOf(\"=\")).trim();\n String value = n.p.substring(n.p.indexOf(\"=\") + 1).trim();\n addGlobalMeta(key, value);\n if (key.equals(\"INFO_OBJECTIVE_NAME\")) {\n store.setObjectiveModel(value, 0, 0);\n }\n else if (key.equals(\"INFO_OBJECTIVE_MAGNIFICATION\")) {\n store.setObjectiveNominalMagnification(\n new Integer((int) Double.parseDouble(value)), 0, 0);\n }\n else if (key.equals(\"LENS_MAGNIFICATION\")) {\n store.setObjectiveNominalMagnification(\n new Integer((int) Double.parseDouble(value)), 0, 0);\n }\n else if (key.startsWith(\"SETTING\")) {\n if (key.indexOf(\"_DET_\") != -1) {\n int index = key.indexOf(\"_DET_\") + 5;\n if (key.lastIndexOf(\"_\") > index) {\n String idx = key.substring(index, key.indexOf(\"_\", index));\n int detector = Integer.parseInt(idx) - 1;\n if (key.endsWith(\"OFFSET\")) {\n store.setDetectorSettingsOffset(\n new Float(value), 0, detector);\n }\n else if (key.endsWith(\"GAIN\")) {\n store.setDetectorSettingsGain(\n new Float(value), 0, detector);\n }\n store.setDetectorType(\"Unknown\", 0, detector);\n store.setDetectorID(\"Detector:\" + detector, 0, detector);\n store.setDetectorSettingsDetector(\"Detector:\" + detector, 0,\n detector);\n }\n }\n }\n else {\n String[] values = value.split(\" \");\n if (values.length > 1) {\n try {\n int type = Integer.parseInt(values[0]);\n if (type == 257 && values.length >= 3) {\n float start = Float.parseFloat(values[1]);\n float end = Float.parseFloat(values[2]);\n float axisLength = end - start;\n if (key.equals(\"AXIS_2\")) {\n float pixelSize = axisLength / getSizeX();\n store.setDimensionsPhysicalSizeX(\n new Float(pixelSize), 0, 0);\n }\n else if (key.equals(\"AXIS_3\")) {\n float pixelSize = axisLength / getSizeY();\n store.setDimensionsPhysicalSizeY(\n new Float(pixelSize), 0, 0);\n }\n }\n }\n catch (NumberFormatException e) { }\n }\n }\n }\n else {\n addGlobalMeta(\"Note #\" + noteCount, n.toString());\n }\n break;\n case NOTE_TYPE_STRUCTURE:\n int structureType = (n.x & 0xff00) >> 8;\n int version = (n.x & 0xff);\n String[] values = n.p.split(\" \");\n if (structureType == 1) {\n switch (n.y) {\n case 1:\n addGlobalMeta(\"Scan Channel\", values[0]);\n addGlobalMeta(\"Both mode\", values[1]);\n addGlobalMeta(\"Speed\", values[2]);\n addGlobalMeta(\"Filter\", values[3]);\n addGlobalMeta(\"Factor\", values[4]);\n addGlobalMeta(\"Number of scans\", values[5]);\n addGlobalMeta(\"Photon counting mode (channel 1)\", values[6]);\n addGlobalMeta(\"Photon counting detector (channel 1)\",\n values[7]);\n addGlobalMeta(\"Photon counting mode (channel 2)\", values[8]);\n addGlobalMeta(\"Photon counting detector (channel 2)\",\n values[9]);\n addGlobalMeta(\"Photon mode\", values[10]);\n addGlobalMeta(\"Objective magnification\", values[11]);\n addGlobalMeta(\"Zoom factor\", values[12]);\n addGlobalMeta(\"Motor on\", values[13]);\n addGlobalMeta(\"Z Step Size\", values[14]);\n store.setObjectiveNominalMagnification(\n new Integer((int) Double.parseDouble(values[11])), 0, 0);\n store.setDisplayOptionsZoom(new Float(values[12]), 0);\n store.setDimensionsPhysicalSizeZ(new Float(values[14]), 0, 0);\n break;\n case 2:\n addGlobalMeta(\"Z Start\", values[0]);\n addGlobalMeta(\"Z Stop\", values[1]);\n addGlobalMeta(\"Scan area X coordinate\", values[2]);\n addGlobalMeta(\"Scan area Y coordinate\", values[3]);\n addGlobalMeta(\"Scan area width\", values[4]);\n addGlobalMeta(\"Scan area height\", values[5]);\n float width =\n Float.parseFloat(values[4]) - Float.parseFloat(values[2]);\n width /= getSizeX();\n float height =\n Float.parseFloat(values[5]) - Float.parseFloat(values[3]);\n height /= getSizeY();\n store.setDimensionsPhysicalSizeX(new Float(width), 0, 0);\n store.setDimensionsPhysicalSizeY(new Float(height), 0, 0);\n break;\n case 3:\n for (int i=0; i<3; i++) {\n addGlobalMeta(\"Iris for PMT \" + (i + 1), values[i * 4]);\n addGlobalMeta(\"Gain for PMT \" + (i + 1), values[i * 4 + 1]);\n addGlobalMeta(\"Black level for PMT \" + (i + 1),\n values[i * 4 + 2]);\n addGlobalMeta(\"Emission filter for PMT \" + (i+1),\n values[i*4] + 3);\n addGlobalMeta(\"Multiplier for channel \" + (i+1),\n values[12 + i]);\n }\n break;\n case 4:\n nLasers = Integer.parseInt(values[0]);\n addGlobalMeta(\"Number of lasers\", values[0]);\n addGlobalMeta(\"Number of transmission detectors\", values[1]);\n addGlobalMeta(\"Number of PMTs\", values[2]);\n for (int i=1; i<=3; i++) {\n int idx = (i + 1) * 3;\n addGlobalMeta(\"Shutter present for laser \" + i,\n values[i + 2]);\n addGlobalMeta(\"Neutral density filter for laser \" + i,\n values[idx]);\n addGlobalMeta(\"Excitation filter for laser \" + i,\n values[idx + 1]);\n addGlobalMeta(\"Use laser \" + i, values[idx + 2]);\n }\n for (int i=0; i 0) v.add(token);\n }\n String[] values = (String[]) v.toArray(new String[0]);\n String key = values[0];\n String noteType = values[1];\n int axisType = Integer.parseInt(noteType);\n if (values.length > 2) {\n switch (axisType) {\n case 1:\n String dx = values[2];\n String dy = values[3];\n addGlobalMeta(key + \" distance (X) in microns\", dx);\n addGlobalMeta(key + \" distance (Y) in microns\", dy);\n break;\n case 3:\n addGlobalMeta(key + \" angle (X) in degrees\", values[2]);\n addGlobalMeta(key + \" angle (Y) in degrees\", values[3]);\n break;\n case 4:\n addGlobalMeta(key + \" intensity (X)\", values[2]);\n addGlobalMeta(key + \" intensity (Y)\", values[3]);\n break;\n case 6:\n addGlobalMeta(key + \" ratio (X)\", values[2]);\n addGlobalMeta(key + \" ratio (Y)\", values[3]);\n break;\n case 7:\n addGlobalMeta(key + \" log ratio (X)\", values[2]);\n addGlobalMeta(key + \" log ratio (Y)\", values[3]);\n break;\n case 9:\n addGlobalMeta(key + \" noncalibrated intensity min\", values[2]);\n addGlobalMeta(key + \" noncalibrated intensity max\", values[3]);\n addGlobalMeta(key + \" calibrated intensity min\", values[4]);\n addGlobalMeta(key + \" calibrated intensity max\", values[5]);\n break;\n case 11:\n addGlobalMeta(key + \" RGB type (X)\", values[2]);\n addGlobalMeta(key + \" RGB type (Y)\", values[3]);\n if (key.equals(\"AXIS_4\")) {\n core[0].sizeC = getImageCount();\n core[0].sizeZ = 1;\n core[0].sizeT = 1;\n }\n break;\n case 14:\n addGlobalMeta(key + \" time course type (X)\", values[2]);\n addGlobalMeta(key + \" time course type (Y)\", values[3]);\n break;\n case 15:\n String prefix = \" inverse sigmoid calibrated intensity \";\n addGlobalMeta(key + prefix + \"(min)\", values[2]);\n addGlobalMeta(key + prefix + \"(max)\", values[3]);\n addGlobalMeta(key + prefix + \"(beta)\", values[4]);\n addGlobalMeta(key + prefix + \"(Kd)\", values[5]);\n break;\n case 16:\n prefix = \" log inverse sigmoid calibrated intensity \";\n addGlobalMeta(key + prefix + \"(min)\", values[2]);\n addGlobalMeta(key + prefix + \"(max)\", values[3]);\n addGlobalMeta(key + prefix + \"(beta)\", values[4]);\n addGlobalMeta(key + prefix + \"(Kd)\", values[5]);\n break;\n }\n }\n }\n }\n MetadataTools.populatePixels(store, this);\n MetadataTools.setDefaultCreationDate(store, id, 0);\n store.setImageName(name, 0);\n store.setInstrumentID(\"Instrument:0\", 0);\n store.setImageInstrumentRef(\"Instrument:0\", 0);\n store.setObjectiveID(\"Objective:0\", 0, 0);\n store.setObjectiveSettingsObjective(\"Objective:0\", 0);\n store.setObjectiveLensNA(new Float(lens), 0, 0);\n store.setObjectiveNominalMagnification(new Integer((int) magFactor), 0, 0);\n store.setObjectiveCorrection(\"Unknown\", 0, 0);\n store.setObjectiveImmersion(\"Unknown\", 0, 0);\n }\n"} {"input": " static StringBuilder latestlog(Main Main)\n {\n BufferedReader br = null;\n StringBuilder txt = new StringBuilder();\n if (Main.getConfig().getBoolean(\"send-log\")) {\n try {\n String line;\n br = new BufferedReader(new FileReader(\"logs\" + File.separatorChar + \"latest.log\"));\n while ((line = br.readLine()) != null) {\n txt.append(line);\n txt.append(\"\\n\");\n }\n } catch (IOException e) {\n e.printStackTrace();\n } finally {\n try {\n if (br != null) {\n br.close();\n }\n } catch (IOException ex) {\n ex.printStackTrace();\n }\n }\n } else {\n txt.append(\"Access denied for latest.log. Contact the Server Owner\");\n }\n return txt;\n }\n", "output": " static StringBuilder latestlog(Main Main)\n {\n BufferedReader br = null;\n StringBuilder txt = new StringBuilder();\n if (Main.getConfig().getBoolean(\"send-log\")) {\n try {\n String line;\n br = new BufferedReader(new FileReader(\"logs\" + File.separatorChar + \"latest.log\"));\n while ((line = br.readLine()) != null) {\n txt.append(line);\n txt.append(\"\\n\");\n }\n } catch (IOException e) {\n e.printStackTrace();\n } finally {\n try {\n if (br != null) {\n br.close();\n }\n } catch (IOException ex) {\n ex.printStackTrace();\n }\n }\n } else {\n txt.append(\"Access denied for latest.log. Contact the Server Owner\\n\");\n }\n return txt;\n }\n"} {"input": " private static FeatureCodec getVCFCodec(String path) {\n BufferedReader reader = null;\n try {\n if (path.toLowerCase().endsWith(\".gz\")) {\n reader = new BufferedReader(new InputStreamReader(new BlockCompressedInputStream(\n ParsingUtils.openInputStream(path))));\n } else {\n reader = ParsingUtils.openBufferedReader(path);\n }\n int lineCount = 0;\n String formatLine;\n while ((formatLine = reader.readLine()) != null && lineCount < 20) {\n if (formatLine.toLowerCase().startsWith(\"##fileformat\")) {\n String[] tmp = formatLine.split(\"=\");\n if (tmp.length > 1) {\n String version = tmp[1].toLowerCase();\n if (version.startsWith(\"vcfv3\")) {\n return new VCF3Codec();\n } else {\n return new VCFCodec();\n }\n }\n }\n lineCount++;\n }\n } catch (IOException e) {\n log.error(\"Error checking VCF Version\");\n } finally {\n if (reader != null) try {\n reader.close();\n } catch (IOException e) {\n }\n }\n return new VCFCodec();\n }\n", "output": " private static FeatureCodec getVCFCodec(String path) {\n BufferedReader reader = null;\n try {\n if (path.toLowerCase().endsWith(\".gz\")) {\n reader = new BufferedReader(new InputStreamReader(new BlockCompressedInputStream(\n org.broad.tribble.util.ParsingUtils.openInputStream(path))));\n } else {\n reader = ParsingUtils.openBufferedReader(path);\n }\n int lineCount = 0;\n String formatLine;\n while ((formatLine = reader.readLine()) != null && lineCount < 20) {\n if (formatLine.toLowerCase().startsWith(\"##fileformat\")) {\n String[] tmp = formatLine.split(\"=\");\n if (tmp.length > 1) {\n String version = tmp[1].toLowerCase();\n if (version.startsWith(\"vcfv3\")) {\n return new VCF3Codec();\n } else {\n return new VCFCodec();\n }\n }\n }\n lineCount++;\n }\n } catch (IOException e) {\n log.error(\"Error checking VCF Version\");\n } finally {\n if (reader != null) try {\n reader.close();\n } catch (IOException e) {\n }\n }\n return new VCFCodec();\n }\n"} {"input": "\tpublic void load(File file) {\n\t\tFileConfiguration config = new YamlConfiguration();\n\t\ttry {\n\t\t\tif (file.exists())\n\t\t\t\tconfig.load(file);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (InvalidConfigurationException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tconfig.setDefaults(getDefaults());\n\t\tcolors = config.getBoolean(\"Chat.Colors\");\n\t\tbendToItem = config.getBoolean(\"Bending.Option.Bend-To-Item\");\n\t\tairdmg = config.getInt(\"Bending.Damage.AirSwipe\");\n\t\tenabled = config.getBoolean(\"Chat.Enabled\");\n\t\tcompatibility = config.getBoolean(\"Chat.Compatibility\");\n\t\twaterdmg = config.getInt(\"Bending.Damage.WaterManipulation\");\n\t\tearthdmg = config.getInt(\"Bending.Damage.EarthBlast\");\n\t\tprefixes.put(\"Air\", config.getString(\"Chat.Prefix.Air\"));\n\t\tprefixes.put(\"Avatar\", config.getString(\"Chat.Prefix.Avatar\"));\n\t\tprefixes.put(\"Fire\", config.getString(\"Chat.Prefix.Fire\"));\n\t\tprefixes.put(\"Water\", config.getString(\"Chat.Prefix.Water\"));\n\t\tprefixes.put(\"Earth\", config.getString(\"Chat.Prefix.Earth\"));\n\t\tprefixes.put(\"ChiBlocker\", config.getString(\"Chat.Prefix.ChiBlocker\"));\n\t\tcolor.put(\"Avatar\", config.getString(\"Chat.Color.Avatar\"));\n\t\tcolor.put(\"Air\", config.getString(\"Chat.Color.Air\"));\n\t\tcolor.put(\"Fire\", config.getString(\"Chat.Color.Fire\"));\n\t\tcolor.put(\"Water\", config.getString(\"Chat.Color.Water\"));\n\t\tcolor.put(\"Earth\", config.getString(\"Chat.Color.Earth\"));\n\t\tcolor.put(\"ChiBlocker\", config.getString(\"Chat.Color.ChiBlocker\"));\n\t\tearthbendable = config.getStringList(\"Bending.Option.EarthBendable\");\n\t\tuseWeapon\n\t\t\t\t.put(\"Air\", config.getBoolean(\n\t\t\t\t\t\t\"Bending.Option.Bend-With-Weapon.Air\", false));\n\t\tuseWeapon.put(\"Earth\", config.getBoolean(\n\t\t\t\t\"Bending.Option.Bend-With-Weapon.Earth\", false));\n\t\tuseWeapon.put(\"Fire\", config.getBoolean(\n\t\t\t\t\"Bending.Option.Bend-With-Weapon.Fire\", false));\n\t\tuseWeapon.put(\"Water\", config.getBoolean(\n\t\t\t\t\"Bending.Option.Bend-With-Weapon.Water\", false));\n\t\tuseMySQL = config.getBoolean(\"MySQL.Use-MySQL\", false);\n\t\tdbHost = config.getString(\"MySQL.MySQL-host\",\n\t\t\t\t\"jdbc:mysql://localhost:3306\");\n\t\tdbUser = config.getString(\"MySQL.User\", \"root\");\n\t\tdbPass = config.getString(\"MySQL.Password\", \"\");\n\t\tdbDB = config.getString(\"MySQL.Database\", \"minecraft\");\n\t\tInteger dbPortint = (Integer) config.getInt(\"MySQL.MySQL-portnumber\");\n\t\tdbPort = dbPortint.toString();\n\t\tuseWeapon\n\t\t\t\t.put(\"ChiBlocker\",\n\t\t\t\t\t\tconfig.getBoolean(\"Bending.Option.Bend-With-Weapon.ChiBlocker\"));\n\t\treverseearthbending = config\n\t\t\t\t.getBoolean(\"Bending.Option.Reverse-Earthbending\");\n\t\trevertchecktime = config\n\t\t\t\t.getLong(\"Bending.Option.Reverse-Earthbending-Check-Time\");\n\t\tchiblockduration = config\n\t\t\t\t.getLong(\"Properties.ChiBlocker.ChiBlock-Duration\");\n\t\tdodgechance = config.getDouble(\"Properties.ChiBlocker.Dodge-Chance\");\n\t\tpunchmultiplier = config\n\t\t\t\t.getDouble(\"Properties.ChiBlocker.Punch-Multiplier\");\n\t\tfalldamagereduction = config\n\t\t\t\t.getDouble(\"Properties.ChiBlocker.Fall-Damage-Reduction\");\n\t\tdissipateAfter = config\n\t\t\t\t.getLong(\"Properties.Option.Firebending-Dissipate-Time\");\n\t\tglobalCooldown = config.getLong(\"Properties.GlobalCooldown\");\n\t\tairBlastSpeed = config.getDouble(\"Properties.Air.AirBlast.Speed\");\n\t\tairBlastRange = config.getDouble(\"Properties.Air.AirBlast.Range\");\n\t\tairBlastRadius = config\n\t\t\t\t.getDouble(\"Properties.Air.AirBlast.Affecting-Radius\");\n\t\tairBlastPush = config.getDouble(\"Properties.Air.AirBlast.Push-Factor\");\n\t\tairBubbleRadius = config.getInt(\"Properties.Air.AirBubble.Radius\");\n\t\tairPassiveFactor = (float) config\n\t\t\t\t.getDouble(\"Properties.Air.Passive.Factor\");\n\t\tairShieldRadius = config.getDouble(\"Properties.Air.AirShield.Radius\");\n\t\tairSuctionSpeed = config.getDouble(\"Properties.Air.AirSuction.Speed\");\n\t\tairSuctionRange = config.getDouble(\"Properties.Air.AirSuction.Range\");\n\t\tairSuctionRadius = config\n\t\t\t\t.getDouble(\"Properties.Air.AirSuction.Affecting-Radius\");\n\t\tairSuctionPush = config\n\t\t\t\t.getDouble(\"Properties.Air.AirSuction.Push-Factor\");\n\t\tairSwipeRange = config.getDouble(\"Properties.Air.AirSwipe.Range\");\n\t\tairSwipeArc = config.getInt(\"Properties.Air.AirSwipe.Arc\");\n\t\tairSwipeSpeed = config.getDouble(\"Properties.Air.AirSwipe.Speed\");\n\t\tairSwipeRadius = config\n\t\t\t\t.getDouble(\"Properties.Air.AirSwipe.Affecting-Radius\");\n\t\tairSwipePush = config.getDouble(\"Properties.Air.AirSwipe.Push-Factor\");\n\t\tairSwipeCooldown = config.getLong(\"Properties.Air.AirSwipe.Cooldown\");\n\t\ttornadoRadius = config.getDouble(\"Properties.Air.Tornado.Radius\");\n\t\ttornadoHeight = config.getDouble(\"Properties.Air.Tornado.Height\");\n\t\ttornadoRange = config.getDouble(\"Properties.Air.Tornado.Range\");\n\t\ttornadoMobPush = config\n\t\t\t\t.getDouble(\"Properties.Air.Tornado.Mob-Push-Factor\");\n\t\ttornadoPlayerPush = config\n\t\t\t\t.getDouble(\"Properties.Air.Tornado.Player-Push-Factor\");\n\t\tairScooterSpeed = config.getDouble(\"Properties.Air.AirScooter.Speed\");\n\t\tcatapultLength = config.getInt(\"Properties.Earth.Catapult.Length\");\n\t\tcatapultSpeed = config.getDouble(\"Properties.Earth.Catapult.Speed\");\n\t\tcatapultPush = config.getDouble(\"Properties.Earth.Catapult.Push\");\n\t\tcompactColumnRange = config\n\t\t\t\t.getDouble(\"Properties.Earth.CompactColumn.Range\");\n\t\tcompactColumnSpeed = config\n\t\t\t\t.getDouble(\"Properties.Earth.CompactColumn.Speed\");\n\t\tearthBlastRange = config.getDouble(\"Properties.Earth.EarthBlast.Range\");\n\t\tearthBlastSpeed = config.getDouble(\"Properties.Earth.EarthBlast.Speed\");\n\t\tearthColumnHeight = config\n\t\t\t\t.getInt(\"Properties.Earth.EarthColumn.Height\");\n\t\tearthGrabRange = config.getDouble(\"Properties.Earth.EarthGrab.Range\");\n\t\tearthPassive = config\n\t\t\t\t.getLong(\"Properties.Earth.EarthPassive.Wait-Before-Reverse-Changes\");\n\t\tearthTunnelMaxRadius = config\n\t\t\t\t.getDouble(\"Properties.Earth.EarthTunnel.Max-Radius\");\n\t\tearthTunnelRange = config\n\t\t\t\t.getDouble(\"Properties.Earth.EarthTunnel.Range\");\n\t\tearthTunnelRadius = config\n\t\t\t\t.getDouble(\"Properties.Earth.EarthTunnel.Radius\");\n\t\tearthTunnelInterval = config\n\t\t\t\t.getLong(\"Properties.Earth.EarthTunnel.Interval\");\n\t\tearthWallRange = config.getInt(\"Properties.Earth.EarthWall.Range\");\n\t\tearthWallHeight = config.getInt(\"Properties.Earth.EarthWall.Height\");\n\t\tearthWallWidth = config.getInt(\"Properties.Earth.EarthWall.Width\");\n\t\tcollapseRange = config.getInt(\"Properties.Earth.Collapse.Range\");\n\t\tcollapseRadius = config.getDouble(\"Properties.Earth.Collapse.Radius\");\n\t\ttremorsenseCooldown = config\n\t\t\t\t.getLong(\"Properties.Earth.Tremorsense.Cooldown\");\n\t\ttremorsenseMaxDepth = config\n\t\t\t\t.getInt(\"Properties.Earth.Tremorsense.Max-Depth\");\n\t\ttremorsenseRadius = config\n\t\t\t\t.getInt(\"Properties.Earth.Tremorsense.Radius\");\n\t\ttremorsenseLightThreshold = (byte) config\n\t\t\t\t.getInt(\"Properties.Earth.Tremorsense.Light-Threshold\");\n\t\tarcOfFireArc = config.getInt(\"Properties.Fire.ArcOfFire.Arc\");\n\t\tarcOfFireRange = config.getInt(\"Properties.Fire.ArcOfFire.Range\");\n\t\tringOfFireRange = config.getInt(\"Properties.Fire.RingOfFire.Range\");\n\t\textinguishRange = config.getDouble(\"Properties.Fire.Extinguish.Range\");\n\t\textinguishRadius = config\n\t\t\t\t.getDouble(\"Properties.Fire.Extinguish.Radius\");\n\t\tfireballCooldown = config.getLong(\"Properties.Fire.Fireball.Cooldown\");\n\t\tfireballSpeed = config.getDouble(\"Properties.Fire.Fireball.Speed\");\n\t\tfireJetSpeed = config.getDouble(\"Properties.Fire.FireJet.Speed\");\n\t\tfireJetDuration = config.getLong(\"Properties.Fire.FireJet.Duration\");\n\t\tfireJetCooldown = config.getLong(\"Properties.Fire.FireJet.CoolDown\");\n\t\tfireStreamSpeed = config.getDouble(\"Properties.Fire.FireStream.Speed\");\n\t\theatMeltRange = config.getInt(\"Properties.Fire.HeatMelt.Range\");\n\t\theatMeltRadius = config.getInt(\"Properties.Fire.HeatMelt.Radius\");\n\t\tilluminationRange = config.getInt(\"Properties.Fire.Illumination.Range\");\n\t\tdayFactor = config.getDouble(\"Properties.Fire.Day-Power-Factor\");\n\t\tfreezeMeltRange = config.getInt(\"Properties.Water.FreezeMelt.Range\");\n\t\tfreezeMeltRadius = config.getInt(\"Properties.Water.FreezeMelt.Radius\");\n\t\thealingWatersRadius = config\n\t\t\t\t.getDouble(\"Properties.Water.HealingWaters.Radius\");\n\t\thealingWatersInterval = config\n\t\t\t\t.getLong(\"Properties.Water.HealingWaters.Interval\");\n\t\tplantbendingRange = config\n\t\t\t\t.getInt(\"Properties.Water.Plantbending.Range\");\n\t\twalkOnWaterRadius = config\n\t\t\t\t.getDouble(\"Properties.Water.WalkOnWater.Radius\");\n\t\twaterManipulationRange = config\n\t\t\t\t.getDouble(\"Properties.Water.WaterManipulation.Range\");\n\t\twaterManipulationSpeed = config\n\t\t\t\t.getDouble(\"Properties.Water.WaterManipulation.Speed\");\n\t\twaterSpoutHeight = config.getInt(\"Properties.Water.WaterSpout.Height\");\n\t\twaterWallRange = config.getDouble(\"Properties.Water.WaterWall.Range\");\n\t\twaterWallRadius = config.getDouble(\"Properties.Water.WaterWall.Radius\");\n\t\twaveRadius = config.getDouble(\"Properties.Water.Wave.Radius\");\n\t\twaveHorizontalPush = config\n\t\t\t\t.getDouble(\"Properties.Water.Wave.Horizontal-Push-Force\");\n\t\twaveVerticalPush = config\n\t\t\t\t.getDouble(\"Properties.Water.Wave.Vertical-Push-Force\");\n\t\tfastSwimmingFactor = config\n\t\t\t\t.getDouble(\"Properties.Water.FastSwimming.Factor\");\n\t\tnightFactor = config.getDouble(\"Properties.Water.Night-Power-Factor\");\n\t\ttry {\n\t\t\tconfig.options().copyDefaults(true);\n\t\t\tconfig.save(file);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n", "output": "\tpublic void load(File file) {\n\t\tFileConfiguration config = new YamlConfiguration();\n\t\ttry {\n\t\t\tif (file.exists())\n\t\t\t\tconfig.load(file);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (InvalidConfigurationException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tconfig.setDefaults(getDefaults());\n\t\tcolors = config.getBoolean(\"Chat.Colors\");\n\t\tbendToItem = config.getBoolean(\"Bending.Option.Bend-To-Item\");\n\t\tairdmg = config.getInt(\"Bending.Damage.AirSwipe\");\n\t\tenabled = config.getBoolean(\"Chat.Enabled\");\n\t\tcompatibility = config.getBoolean(\"Chat.Compatibility\");\n\t\twaterdmg = config.getInt(\"Bending.Damage.WaterManipulation\");\n\t\tearthdmg = config.getInt(\"Bending.Damage.EarthBlast\");\n\t\tprefixes.put(\"Air\", config.getString(\"Chat.Prefix.Air\"));\n\t\tprefixes.put(\"Avatar\", config.getString(\"Chat.Prefix.Avatar\"));\n\t\tprefixes.put(\"Fire\", config.getString(\"Chat.Prefix.Fire\"));\n\t\tprefixes.put(\"Water\", config.getString(\"Chat.Prefix.Water\"));\n\t\tprefixes.put(\"Earth\", config.getString(\"Chat.Prefix.Earth\"));\n\t\tprefixes.put(\"ChiBlocker\", config.getString(\"Chat.Prefix.ChiBlocker\"));\n\t\tcolor.put(\"Avatar\", config.getString(\"Chat.Color.Avatar\"));\n\t\tcolor.put(\"Air\", config.getString(\"Chat.Color.Air\"));\n\t\tcolor.put(\"Fire\", config.getString(\"Chat.Color.Fire\"));\n\t\tcolor.put(\"Water\", config.getString(\"Chat.Color.Water\"));\n\t\tcolor.put(\"Earth\", config.getString(\"Chat.Color.Earth\"));\n\t\tcolor.put(\"ChiBlocker\", config.getString(\"Chat.Color.ChiBlocker\"));\n\t\tearthbendable = config.getStringList(\"Bending.Option.EarthBendable\");\n\t\tuseWeapon\n\t\t\t\t.put(\"Air\", config.getBoolean(\n\t\t\t\t\t\t\"Bending.Option.Bend-With-Weapon.Air\", false));\n\t\tuseWeapon.put(\"Earth\", config.getBoolean(\n\t\t\t\t\"Bending.Option.Bend-With-Weapon.Earth\", false));\n\t\tuseWeapon.put(\"Fire\", config.getBoolean(\n\t\t\t\t\"Bending.Option.Bend-With-Weapon.Fire\", false));\n\t\tuseWeapon.put(\"Water\", config.getBoolean(\n\t\t\t\t\"Bending.Option.Bend-With-Weapon.Water\", false));\n\t\tuseMySQL = config.getBoolean(\"MySQL.Use-MySQL\", false);\n\t\tdbHost = config.getString(\"MySQL.MySQL-host\",\n\t\t\t\t\"jdbc:mysql://localhost:3306\");\n\t\tdbUser = config.getString(\"MySQL.User\", \"root\");\n\t\tdbPass = config.getString(\"MySQL.Password\", \"\");\n\t\tdbDB = config.getString(\"MySQL.Database\", \"minecraft\");\n\t\tInteger dbPortint = (Integer) config.getInt(\"MySQL.MySQL-portnumber\");\n\t\tdbPort = dbPortint.toString();\n\t\tuseWeapon\n\t\t\t\t.put(\"ChiBlocker\",\n\t\t\t\t\t\tconfig.getBoolean(\"Bending.Option.Bend-With-Weapon.ChiBlocker\"));\n\t\treverseearthbending = config\n\t\t\t\t.getBoolean(\"Bending.Option.Reverse-Earthbending\");\n\t\trevertchecktime = config\n\t\t\t\t.getLong(\"Bending.Option.Reverse-Earthbending-Check-Time\");\n\t\tchiblockduration = config\n\t\t\t\t.getLong(\"Properties.ChiBlocker.ChiBlock-Duration\");\n\t\tdodgechance = config.getDouble(\"Properties.ChiBlocker.Dodge-Chance\");\n\t\tpunchmultiplier = config\n\t\t\t\t.getDouble(\"Properties.ChiBlocker.Punch-Multiplier\");\n\t\tfalldamagereduction = config\n\t\t\t\t.getDouble(\"Properties.ChiBlocker.Fall-Damage-Reduction\");\n\t\tdissipateAfter = config\n\t\t\t\t.getLong(\"Bending.Option.Firebending-Dissipate-Time\");\n\t\tglobalCooldown = config.getLong(\"Properties.GlobalCooldown\");\n\t\tairBlastSpeed = config.getDouble(\"Properties.Air.AirBlast.Speed\");\n\t\tairBlastRange = config.getDouble(\"Properties.Air.AirBlast.Range\");\n\t\tairBlastRadius = config\n\t\t\t\t.getDouble(\"Properties.Air.AirBlast.Affecting-Radius\");\n\t\tairBlastPush = config.getDouble(\"Properties.Air.AirBlast.Push-Factor\");\n\t\tairBubbleRadius = config.getInt(\"Properties.Air.AirBubble.Radius\");\n\t\tairPassiveFactor = (float) config\n\t\t\t\t.getDouble(\"Properties.Air.Passive.Factor\");\n\t\tairShieldRadius = config.getDouble(\"Properties.Air.AirShield.Radius\");\n\t\tairSuctionSpeed = config.getDouble(\"Properties.Air.AirSuction.Speed\");\n\t\tairSuctionRange = config.getDouble(\"Properties.Air.AirSuction.Range\");\n\t\tairSuctionRadius = config\n\t\t\t\t.getDouble(\"Properties.Air.AirSuction.Affecting-Radius\");\n\t\tairSuctionPush = config\n\t\t\t\t.getDouble(\"Properties.Air.AirSuction.Push-Factor\");\n\t\tairSwipeRange = config.getDouble(\"Properties.Air.AirSwipe.Range\");\n\t\tairSwipeArc = config.getInt(\"Properties.Air.AirSwipe.Arc\");\n\t\tairSwipeSpeed = config.getDouble(\"Properties.Air.AirSwipe.Speed\");\n\t\tairSwipeRadius = config\n\t\t\t\t.getDouble(\"Properties.Air.AirSwipe.Affecting-Radius\");\n\t\tairSwipePush = config.getDouble(\"Properties.Air.AirSwipe.Push-Factor\");\n\t\tairSwipeCooldown = config.getLong(\"Properties.Air.AirSwipe.Cooldown\");\n\t\ttornadoRadius = config.getDouble(\"Properties.Air.Tornado.Radius\");\n\t\ttornadoHeight = config.getDouble(\"Properties.Air.Tornado.Height\");\n\t\ttornadoRange = config.getDouble(\"Properties.Air.Tornado.Range\");\n\t\ttornadoMobPush = config\n\t\t\t\t.getDouble(\"Properties.Air.Tornado.Mob-Push-Factor\");\n\t\ttornadoPlayerPush = config\n\t\t\t\t.getDouble(\"Properties.Air.Tornado.Player-Push-Factor\");\n\t\tairScooterSpeed = config.getDouble(\"Properties.Air.AirScooter.Speed\");\n\t\tcatapultLength = config.getInt(\"Properties.Earth.Catapult.Length\");\n\t\tcatapultSpeed = config.getDouble(\"Properties.Earth.Catapult.Speed\");\n\t\tcatapultPush = config.getDouble(\"Properties.Earth.Catapult.Push\");\n\t\tcompactColumnRange = config\n\t\t\t\t.getDouble(\"Properties.Earth.CompactColumn.Range\");\n\t\tcompactColumnSpeed = config\n\t\t\t\t.getDouble(\"Properties.Earth.CompactColumn.Speed\");\n\t\tearthBlastRange = config.getDouble(\"Properties.Earth.EarthBlast.Range\");\n\t\tearthBlastSpeed = config.getDouble(\"Properties.Earth.EarthBlast.Speed\");\n\t\tearthColumnHeight = config\n\t\t\t\t.getInt(\"Properties.Earth.EarthColumn.Height\");\n\t\tearthGrabRange = config.getDouble(\"Properties.Earth.EarthGrab.Range\");\n\t\tearthPassive = config\n\t\t\t\t.getLong(\"Properties.Earth.EarthPassive.Wait-Before-Reverse-Changes\");\n\t\tearthTunnelMaxRadius = config\n\t\t\t\t.getDouble(\"Properties.Earth.EarthTunnel.Max-Radius\");\n\t\tearthTunnelRange = config\n\t\t\t\t.getDouble(\"Properties.Earth.EarthTunnel.Range\");\n\t\tearthTunnelRadius = config\n\t\t\t\t.getDouble(\"Properties.Earth.EarthTunnel.Radius\");\n\t\tearthTunnelInterval = config\n\t\t\t\t.getLong(\"Properties.Earth.EarthTunnel.Interval\");\n\t\tearthWallRange = config.getInt(\"Properties.Earth.EarthWall.Range\");\n\t\tearthWallHeight = config.getInt(\"Properties.Earth.EarthWall.Height\");\n\t\tearthWallWidth = config.getInt(\"Properties.Earth.EarthWall.Width\");\n\t\tcollapseRange = config.getInt(\"Properties.Earth.Collapse.Range\");\n\t\tcollapseRadius = config.getDouble(\"Properties.Earth.Collapse.Radius\");\n\t\ttremorsenseCooldown = config\n\t\t\t\t.getLong(\"Properties.Earth.Tremorsense.Cooldown\");\n\t\ttremorsenseMaxDepth = config\n\t\t\t\t.getInt(\"Properties.Earth.Tremorsense.Max-Depth\");\n\t\ttremorsenseRadius = config\n\t\t\t\t.getInt(\"Properties.Earth.Tremorsense.Radius\");\n\t\ttremorsenseLightThreshold = (byte) config\n\t\t\t\t.getInt(\"Properties.Earth.Tremorsense.Light-Threshold\");\n\t\tarcOfFireArc = config.getInt(\"Properties.Fire.ArcOfFire.Arc\");\n\t\tarcOfFireRange = config.getInt(\"Properties.Fire.ArcOfFire.Range\");\n\t\tringOfFireRange = config.getInt(\"Properties.Fire.RingOfFire.Range\");\n\t\textinguishRange = config.getDouble(\"Properties.Fire.Extinguish.Range\");\n\t\textinguishRadius = config\n\t\t\t\t.getDouble(\"Properties.Fire.Extinguish.Radius\");\n\t\tfireballCooldown = config.getLong(\"Properties.Fire.Fireball.Cooldown\");\n\t\tfireballSpeed = config.getDouble(\"Properties.Fire.Fireball.Speed\");\n\t\tfireJetSpeed = config.getDouble(\"Properties.Fire.FireJet.Speed\");\n\t\tfireJetDuration = config.getLong(\"Properties.Fire.FireJet.Duration\");\n\t\tfireJetCooldown = config.getLong(\"Properties.Fire.FireJet.CoolDown\");\n\t\tfireStreamSpeed = config.getDouble(\"Properties.Fire.FireStream.Speed\");\n\t\theatMeltRange = config.getInt(\"Properties.Fire.HeatMelt.Range\");\n\t\theatMeltRadius = config.getInt(\"Properties.Fire.HeatMelt.Radius\");\n\t\tilluminationRange = config.getInt(\"Properties.Fire.Illumination.Range\");\n\t\tdayFactor = config.getDouble(\"Properties.Fire.Day-Power-Factor\");\n\t\tfreezeMeltRange = config.getInt(\"Properties.Water.FreezeMelt.Range\");\n\t\tfreezeMeltRadius = config.getInt(\"Properties.Water.FreezeMelt.Radius\");\n\t\thealingWatersRadius = config\n\t\t\t\t.getDouble(\"Properties.Water.HealingWaters.Radius\");\n\t\thealingWatersInterval = config\n\t\t\t\t.getLong(\"Properties.Water.HealingWaters.Interval\");\n\t\tplantbendingRange = config\n\t\t\t\t.getInt(\"Properties.Water.Plantbending.Range\");\n\t\twalkOnWaterRadius = config\n\t\t\t\t.getDouble(\"Properties.Water.WalkOnWater.Radius\");\n\t\twaterManipulationRange = config\n\t\t\t\t.getDouble(\"Properties.Water.WaterManipulation.Range\");\n\t\twaterManipulationSpeed = config\n\t\t\t\t.getDouble(\"Properties.Water.WaterManipulation.Speed\");\n\t\twaterSpoutHeight = config.getInt(\"Properties.Water.WaterSpout.Height\");\n\t\twaterWallRange = config.getDouble(\"Properties.Water.WaterWall.Range\");\n\t\twaterWallRadius = config.getDouble(\"Properties.Water.WaterWall.Radius\");\n\t\twaveRadius = config.getDouble(\"Properties.Water.Wave.Radius\");\n\t\twaveHorizontalPush = config\n\t\t\t\t.getDouble(\"Properties.Water.Wave.Horizontal-Push-Force\");\n\t\twaveVerticalPush = config\n\t\t\t\t.getDouble(\"Properties.Water.Wave.Vertical-Push-Force\");\n\t\tfastSwimmingFactor = config\n\t\t\t\t.getDouble(\"Properties.Water.FastSwimming.Factor\");\n\t\tnightFactor = config.getDouble(\"Properties.Water.Night-Power-Factor\");\n\t\ttry {\n\t\t\tconfig.options().copyDefaults(true);\n\t\t\tconfig.save(file);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n"} {"input": " public Object build(DirectiveBuilder builder, \n BuildContext bc) \n throws BuildException {\n Object c = builder.getArg(IF_COND, bc);\n boolean cMacro = (c instanceof Macro);\n int elseifCount;\n DirectiveArgs elseArgs;\n DirectiveArgs[] elseifArgs = null;\n if (!cMacro && Expression.isTrue(c)) \n return (Block) builder.getArg(IF_BLOCK, bc);\n elseArgs = builder.getSubdirective(IF_ELSE);\n elseifArgs = builder.getRepeatingSubdirective(IF_ELSEIF);\n elseifCount = (elseifArgs == null) ? 0 : elseifArgs.length;\n if (elseifCount == 0) {\n if (!cMacro) {\n return (elseArgs != null) \n ? elseArgs.getArg(ELSE_BLOCK, bc) : \"\";\n }\n else {\n conditions = new Macro[1];\n blocks = new Block[1];\n conditions[0] = (Macro) c;\n blocks[0] = (Block) builder.getArg(IF_BLOCK, bc);\n if (elseArgs != null)\n elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc);\n return this;\n }\n }\n else {\n int i=0;\n nConditions=elseifCount;\n if (cMacro)\n ++nConditions;\n conditions = new Macro[nConditions];\n blocks = new Block[nConditions];\n if (cMacro) {\n conditions[0] = (Macro) c;\n blocks[0] = (Block) builder.getArg(IF_BLOCK, bc);\n ++i;\n }\n for (int j=0; j < elseifCount; j++) {\n c = elseifArgs[j].getArg(ELSEIF_COND, bc);\n if (c instanceof Macro) {\n conditions[i] = (Macro) c;\n blocks[i] = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc);\n ++i;\n }\n else if (Expression.isTrue(c)) {\n elseBlock = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc);\n if (i == 0)\n return elseBlock;\n else \n break;\n }\n else {\n }\n }\n if (elseBlock == null && elseArgs != null) {\n elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc);\n if (i == 0)\n return elseBlock;\n }\n if (i < nConditions) {\n nConditions = i;\n }\n }\n return this;\n }\n", "output": " public Object build(DirectiveBuilder builder, \n BuildContext bc) \n throws BuildException {\n Object c = builder.getArg(IF_COND, bc);\n boolean cMacro = (c instanceof Macro);\n int elseifCount;\n DirectiveArgs elseArgs;\n DirectiveArgs[] elseifArgs = null;\n if (!cMacro && Expression.isTrue(c)) {\n return (Block) builder.getArg(IF_BLOCK, bc);\n }\n elseArgs = builder.getSubdirective(IF_ELSE);\n elseifArgs = builder.getRepeatingSubdirective(IF_ELSEIF);\n elseifCount = (elseifArgs == null) ? 0 : elseifArgs.length;\n if (elseifCount == 0) {\n if (!cMacro) {\n return (elseArgs != null) \n ? elseArgs.getArg(ELSE_BLOCK, bc) : \"\";\n }\n else {\n nConditions = 1;\n conditions = new Macro[1];\n blocks = new Block[1];\n conditions[0] = (Macro) c;\n blocks[0] = (Block) builder.getArg(IF_BLOCK, bc);\n if (elseArgs != null)\n elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc);\n return this;\n }\n }\n else {\n int i=0;\n nConditions=elseifCount + (cMacro? 1 : 0);\n conditions = new Macro[nConditions];\n blocks = new Block[nConditions];\n if (cMacro) {\n conditions[0] = (Macro) c;\n blocks[0] = (Block) builder.getArg(IF_BLOCK, bc);\n ++i;\n }\n for (int j=0; j < elseifCount; j++) {\n c = elseifArgs[j].getArg(ELSEIF_COND, bc);\n if (c instanceof Macro) {\n conditions[i] = (Macro) c;\n blocks[i] = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc);\n ++i;\n }\n else if (Expression.isTrue(c)) {\n elseBlock = (Block) elseifArgs[j].getArg(ELSEIF_BLOCK, bc);\n if (i == 0)\n return elseBlock;\n else \n break;\n }\n else {\n }\n }\n if (elseBlock == null && elseArgs != null) {\n elseBlock = (Block) elseArgs.getArg(ELSE_BLOCK, bc);\n if (i == 0)\n return elseBlock;\n }\n if (i < nConditions) {\n nConditions = i;\n }\n }\n return this;\n }\n"} {"input": " public static VisualStudioProject getProject(File projectFile, String projectName, List buildConfigurations)\n throws FileNotFoundException, DotNetToolsException {\n VisualStudioProject project = new VisualStudioProject();\n project.setProjectFile(projectFile);\n project.setName(projectName);\n File projectDir = projectFile.getParentFile();\n XPathFactory factory = XPathFactory.newInstance();\n XPath xpath = factory.newXPath();\n ClassLoader savedClassloader = Thread.currentThread().getContextClassLoader();\n Thread.currentThread().setContextClassLoader(xpath.getClass().getClassLoader());\n try {\n xpath.setNamespaceContext(new VisualStudioNamespaceContext());\n if (buildConfigurations != null) {\n Map buildConfOutputDirMap = new HashMap();\n for (String config : buildConfigurations) {\n XPathExpression configOutputExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup[contains(@Condition,'\" + config\n + \"')]/vst:OutputPath\");\n String configOutput = extractProjectProperty(configOutputExpression, projectFile);\n buildConfOutputDirMap.put(config, new File(projectDir, configOutput));\n }\n project.setBuildConfOutputDirMap(buildConfOutputDirMap);\n }\n XPathExpression projectTypeExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:OutputType\");\n XPathExpression assemblyNameExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:AssemblyName\");\n XPathExpression rootNamespaceExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:RootNamespace\");\n XPathExpression debugOutputExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup[contains(@Condition,'Debug')]/vst:OutputPath\");\n XPathExpression releaseOutputExpression = xpath\n .compile(\"/vst:Project/vst:PropertyGroup[contains(@Condition,'Release')]/vst:OutputPath\");\n XPathExpression silverlightExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:SilverlightApplication\");\n XPathExpression projectGuidExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:ProjectGuid\");\n String typeStr = extractProjectProperty(projectTypeExpression, projectFile);\n String silverlightStr = extractProjectProperty(silverlightExpression, projectFile);\n String assemblyName = extractProjectProperty(assemblyNameExpression, projectFile);\n String rootNamespace = extractProjectProperty(rootNamespaceExpression, projectFile);\n String debugOutput = extractProjectProperty(debugOutputExpression, projectFile);\n String releaseOutput = extractProjectProperty(releaseOutputExpression, projectFile);\n String projectGuid = extractProjectProperty(projectGuidExpression, projectFile);\n projectGuid = projectGuid.substring(1, projectGuid.length() - 2);\n ArtifactType type = ArtifactType.LIBRARY;\n if (StringUtils.containsIgnoreCase(typeStr, \"exe\")) {\n type = ArtifactType.EXECUTABLE;\n }\n project.setProjectGuid(UUID.fromString(projectGuid));\n project.setProjectFile(projectFile);\n project.setType(type);\n project.setDirectory(projectDir);\n project.setAssemblyName(assemblyName);\n project.setRootNamespace(rootNamespace);\n project.setDebugOutputDir(new File(projectDir, debugOutput));\n project.setReleaseOutputDir(new File(projectDir, releaseOutput));\n if (StringUtils.isNotEmpty(silverlightStr)) {\n project.setSilverlightProject(true);\n }\n Thread.currentThread().setContextClassLoader(savedClassloader);\n Collection sourceFiles = project.getSourceFiles();\n project.setAssemblyVersion(findAssemblyVersion(sourceFiles));\n assessTestProject(project, testProjectNamePattern, integTestProjectNamePattern);\n return project;\n } catch (XPathExpressionException xpee) {\n throw new DotNetToolsException(\"Error while processing the project \" + projectFile, xpee);\n } finally {\n Thread.currentThread().setContextClassLoader(savedClassloader);\n }\n }\n", "output": " public static VisualStudioProject getProject(File projectFile, String projectName, List buildConfigurations)\n throws FileNotFoundException, DotNetToolsException {\n VisualStudioProject project = new VisualStudioProject();\n project.setProjectFile(projectFile);\n project.setName(projectName);\n File projectDir = projectFile.getParentFile();\n XPathFactory factory = XPathFactory.newInstance();\n XPath xpath = factory.newXPath();\n try {\n xpath.setNamespaceContext(new VisualStudioNamespaceContext());\n if (buildConfigurations != null) {\n Map buildConfOutputDirMap = new HashMap();\n for (String config : buildConfigurations) {\n XPathExpression configOutputExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup[contains(@Condition,'\" + config\n + \"')]/vst:OutputPath\");\n String configOutput = extractProjectProperty(configOutputExpression, projectFile);\n buildConfOutputDirMap.put(config, new File(projectDir, configOutput));\n }\n project.setBuildConfOutputDirMap(buildConfOutputDirMap);\n }\n XPathExpression projectTypeExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:OutputType\");\n XPathExpression assemblyNameExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:AssemblyName\");\n XPathExpression rootNamespaceExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:RootNamespace\");\n XPathExpression debugOutputExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup[contains(@Condition,'Debug')]/vst:OutputPath\");\n XPathExpression releaseOutputExpression = xpath\n .compile(\"/vst:Project/vst:PropertyGroup[contains(@Condition,'Release')]/vst:OutputPath\");\n XPathExpression silverlightExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:SilverlightApplication\");\n XPathExpression projectGuidExpression = xpath.compile(\"/vst:Project/vst:PropertyGroup/vst:ProjectGuid\");\n String typeStr = extractProjectProperty(projectTypeExpression, projectFile);\n String silverlightStr = extractProjectProperty(silverlightExpression, projectFile);\n String assemblyName = extractProjectProperty(assemblyNameExpression, projectFile);\n String rootNamespace = extractProjectProperty(rootNamespaceExpression, projectFile);\n String debugOutput = extractProjectProperty(debugOutputExpression, projectFile);\n String releaseOutput = extractProjectProperty(releaseOutputExpression, projectFile);\n String projectGuid = extractProjectProperty(projectGuidExpression, projectFile);\n projectGuid = projectGuid.substring(1, projectGuid.length() - 2);\n ArtifactType type = ArtifactType.LIBRARY;\n if (StringUtils.containsIgnoreCase(typeStr, \"exe\")) {\n type = ArtifactType.EXECUTABLE;\n }\n project.setProjectGuid(UUID.fromString(projectGuid));\n project.setProjectFile(projectFile);\n project.setType(type);\n project.setDirectory(projectDir);\n project.setAssemblyName(assemblyName);\n project.setRootNamespace(rootNamespace);\n project.setDebugOutputDir(new File(projectDir, debugOutput));\n project.setReleaseOutputDir(new File(projectDir, releaseOutput));\n if (StringUtils.isNotEmpty(silverlightStr)) {\n project.setSilverlightProject(true);\n }\n Collection sourceFiles = project.getSourceFiles();\n project.setAssemblyVersion(findAssemblyVersion(sourceFiles));\n assessTestProject(project, testProjectNamePattern, integTestProjectNamePattern);\n return project;\n } catch (XPathExpressionException xpee) {\n throw new DotNetToolsException(\"Error while processing the project \" + projectFile, xpee);\n } finally {\n }\n }\n"} {"input": " public void script(\n @CliOption(key = { \"\", \"file\" }, help = \"The file to locate and execute\", mandatory = true) final File script,\n @CliOption(key = \"lineNumbers\", mandatory = false, specifiedDefaultValue = \"true\", unspecifiedDefaultValue = \"false\", help = \"Display line numbers when executing the script\") final boolean lineNumbers) {\n Validate.notNull(script, \"Script file to parse is required\");\n final double startedNanoseconds = System.nanoTime();\n final InputStream inputStream = openScript(script);\n try {\n int i = 0;\n for (final String line : IOUtils.readLines(inputStream)) {\n i++;\n if (lineNumbers) {\n logger.fine(\"Line \" + i + \": \" + line);\n }\n else {\n logger.fine(line);\n }\n if (!\"\".equals(line.trim())) {\n final boolean success = executeScriptLine(line);\n if (success\n && (line.trim().startsWith(\"q\") || line.trim()\n .startsWith(\"ex\"))) {\n break;\n }\n else if (!success) {\n throw new IllegalStateException(\n \"Script execution aborted\");\n }\n }\n }\n }\n catch (final IOException e) {\n throw new IllegalStateException(e);\n }\n finally {\n IOUtils.closeQuietly(inputStream);\n final double executionDurationInSeconds = (System.nanoTime() - startedNanoseconds) / 1000000000D;\n logger.fine(\"Script required \"\n + round(executionDurationInSeconds, 3)\n + \" seconds to execute\");\n }\n }\n public void setPromptPath(final String path) {\n shellPrompt = (StringUtils.isNotBlank(path) ? path + \" \" : \"\")\n + ROO_PROMPT;\n }\n public void setPromptPath(final String path, final boolean overrideStyle) {\n setPromptPath(path);\n }\n public void setTailor(final Tailor tailor) {\n this.tailor = tailor;\n }\n @CliCommand(value = { \"version\" }, help = \"Displays shell version\")\n public String version(\n @CliOption(key = \"\", help = \"Special version flags\") final String extra) {\n final StringBuilder sb = new StringBuilder();\n if (\"roorocks\".equals(extra)) {\n sb.append(\" /\\\\ /l\").append(LINE_SEPARATOR);\n sb.append(\" ((.Y(!\").append(LINE_SEPARATOR);\n sb.append(\" \\\\ |/\").append(LINE_SEPARATOR);\n sb.append(\" / 6~6,\").append(LINE_SEPARATOR);\n sb.append(\" \\\\ _ +-.\").append(LINE_SEPARATOR);\n sb.append(\" \\\\`-=--^-' \\\\\").append(LINE_SEPARATOR);\n sb.append(\n \" \\\\ \\\\ |\\\\--------------------------+\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" _/ \\\\ | Thanks for loading Roo! |\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" ( . Y +---------------------------+\")\n .append(LINE_SEPARATOR);\n sb.append(\" /\\\"\\\\ `---^--v---.\").append(\n LINE_SEPARATOR);\n sb.append(\" / _ `---\\\"T~~\\\\/~\\\\/\").append(\n LINE_SEPARATOR);\n sb.append(\" / \\\" ~\\\\. !\").append(LINE_SEPARATOR);\n sb.append(\" _ Y Y.~~~ /'\").append(LINE_SEPARATOR);\n sb.append(\" Y^| | | Roo 7\").append(LINE_SEPARATOR);\n sb.append(\" | l | / . /'\").append(LINE_SEPARATOR);\n sb.append(\" | `L | Y .^/ ~T\").append(LINE_SEPARATOR);\n sb.append(\" | l ! | |/ | | ____ ____ ____\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" | .`\\\\/' | Y | ! / __ \\\\/ __ \\\\/ __ \\\\\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" l \\\"~ j l j L______ / /_/ / / / / / / /\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" \\\\,____{ __\\\"\\\" ~ __ ,\\\\_,\\\\_ / _, _/ /_/ / /_/ /\")\n .append(LINE_SEPARATOR);\n sb.append(\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~ /_/ |_|\\\\____/\\\\____/\")\n .append(\" \").append(versionInfo()).append(LINE_SEPARATOR);\n return sb.toString();\n }\n sb.append(\" ____ ____ ____ \").append(LINE_SEPARATOR);\n sb.append(\" / __ \\\\/ __ \\\\/ __ \\\\ \").append(LINE_SEPARATOR);\n sb.append(\" / /_/ / / / / / / / \").append(LINE_SEPARATOR);\n sb.append(\" / _, _/ /_/ / /_/ / \").append(\" \")\n .append(\"gvNIX 1.2.1-SNAPSHOT distribution\").append(LINE_SEPARATOR);\n sb.append(\"/_/ |_|\\\\____/\\\\____/ \").append(\" \").append(versionInfo())\n .append(LINE_SEPARATOR);\n sb.append(LINE_SEPARATOR);\n return sb.toString();\n }\n}\n", "output": " public void script(\n @CliOption(key = { \"\", \"file\" }, help = \"The file to locate and execute\", mandatory = true) final File script,\n @CliOption(key = \"lineNumbers\", mandatory = false, specifiedDefaultValue = \"true\", unspecifiedDefaultValue = \"false\", help = \"Display line numbers when executing the script\") final boolean lineNumbers) {\n Validate.notNull(script, \"Script file to parse is required\");\n final double startedNanoseconds = System.nanoTime();\n final InputStream inputStream = openScript(script);\n try {\n int i = 0;\n for (final String line : IOUtils.readLines(inputStream)) {\n i++;\n if (lineNumbers) {\n logger.fine(\"Line \" + i + \": \" + line);\n }\n else {\n logger.fine(line);\n }\n if (!\"\".equals(line.trim())) {\n final boolean success = executeScriptLine(line);\n if (success\n && (line.trim().startsWith(\"q\") || line.trim()\n .startsWith(\"ex\"))) {\n break;\n }\n else if (!success) {\n throw new IllegalStateException(\n \"Script execution aborted\");\n }\n }\n }\n }\n catch (final IOException e) {\n throw new IllegalStateException(e);\n }\n finally {\n IOUtils.closeQuietly(inputStream);\n final double executionDurationInSeconds = (System.nanoTime() - startedNanoseconds) / 1000000000D;\n logger.fine(\"Script required \"\n + round(executionDurationInSeconds, 3)\n + \" seconds to execute\");\n }\n }\n public void setPromptPath(final String path) {\n shellPrompt = (StringUtils.isNotBlank(path) ? path + \" \" : \"\")\n + ROO_PROMPT;\n }\n public void setPromptPath(final String path, final boolean overrideStyle) {\n setPromptPath(path);\n }\n public void setTailor(final Tailor tailor) {\n this.tailor = tailor;\n }\n @CliCommand(value = { \"version\" }, help = \"Displays shell version\")\n public String version(\n @CliOption(key = \"\", help = \"Special version flags\") final String extra) {\n final StringBuilder sb = new StringBuilder();\n if (\"roorocks\".equals(extra)) {\n sb.append(\" /\\\\ /l\").append(LINE_SEPARATOR);\n sb.append(\" ((.Y(!\").append(LINE_SEPARATOR);\n sb.append(\" \\\\ |/\").append(LINE_SEPARATOR);\n sb.append(\" / 6~6,\").append(LINE_SEPARATOR);\n sb.append(\" \\\\ _ +-.\").append(LINE_SEPARATOR);\n sb.append(\" \\\\`-=--^-' \\\\\").append(LINE_SEPARATOR);\n sb.append(\n \" \\\\ \\\\ |\\\\--------------------------+\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" _/ \\\\ | Thanks for loading Roo! |\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" ( . Y +---------------------------+\")\n .append(LINE_SEPARATOR);\n sb.append(\" /\\\"\\\\ `---^--v---.\").append(\n LINE_SEPARATOR);\n sb.append(\" / _ `---\\\"T~~\\\\/~\\\\/\").append(\n LINE_SEPARATOR);\n sb.append(\" / \\\" ~\\\\. !\").append(LINE_SEPARATOR);\n sb.append(\" _ Y Y.~~~ /'\").append(LINE_SEPARATOR);\n sb.append(\" Y^| | | Roo 7\").append(LINE_SEPARATOR);\n sb.append(\" | l | / . /'\").append(LINE_SEPARATOR);\n sb.append(\" | `L | Y .^/ ~T\").append(LINE_SEPARATOR);\n sb.append(\" | l ! | |/ | | ____ ____ ____\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" | .`\\\\/' | Y | ! / __ \\\\/ __ \\\\/ __ \\\\\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" l \\\"~ j l j L______ / /_/ / / / / / / /\")\n .append(LINE_SEPARATOR);\n sb.append(\n \" \\\\,____{ __\\\"\\\" ~ __ ,\\\\_,\\\\_ / _, _/ /_/ / /_/ /\")\n .append(LINE_SEPARATOR);\n sb.append(\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~ /_/ |_|\\\\____/\\\\____/\")\n .append(\" \").append(versionInfo()).append(LINE_SEPARATOR);\n return sb.toString();\n }\n sb.append(\" ____ ____ ____ \").append(LINE_SEPARATOR);\n sb.append(\" / __ \\\\/ __ \\\\/ __ \\\\ \").append(LINE_SEPARATOR);\n sb.append(\" / /_/ / / / / / / / \").append(LINE_SEPARATOR);\n sb.append(\" / _, _/ /_/ / /_/ / \").append(\" \")\n .append(\"gvNIX 1.3.0-SNAPSHOT distribution\").append(LINE_SEPARATOR);\n sb.append(\"/_/ |_|\\\\____/\\\\____/ \").append(\" \").append(versionInfo())\n .append(LINE_SEPARATOR);\n sb.append(LINE_SEPARATOR);\n return sb.toString();\n }\n}\n"} {"input": " private CAstNode walkNodesInternal(final Node n, WalkContext context) {\n final int NT = n.getType();\n switch (NT) {\n case Token.FUNCTION: {\n int fnIndex = n.getExistingIntProp(Node.FUNCTION_PROP);\n FunctionNode fn = context.top().getFunctionNode(fnIndex);\n CAstEntity fne = walkEntity(fn, context);\n if (context.expressionContext()) {\n CAstNode fun = Ast.makeNode(CAstNode.FUNCTION_EXPR, Ast.makeConstant(fne));\n context.addScopedEntity(fun, fne);\n return fun;\n } else {\n context.addNameDecl(Ast.makeNode(CAstNode.FUNCTION_STMT, Ast.makeConstant(fne)));\n context.addScopedEntity(null, fne);\n return Ast.makeNode(CAstNode.EMPTY);\n }\n }\n case Token.CATCH_SCOPE: {\n Node catchVarNode = n.getFirstChild();\n String catchVarName = catchVarNode.getString();\n assert catchVarName != null;\n context.setCatchVar(catchVarName);\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.LOCAL_BLOCK: {\n return Ast.makeNode(CAstNode.BLOCK_EXPR, gatherChildren(n, context));\n }\n case Token.TRY: {\n Node catchNode = ((Node.Jump) n).target;\n Node finallyNode = ((Node.Jump) n).getFinally();\n ArrayList tryList = new ArrayList();\n ArrayList catchList = new ArrayList();\n ArrayList finallyList = new ArrayList();\n ArrayList current = tryList;\n Node c;\n for (c = n.getFirstChild(); c.getNext() != null; c = c.getNext()) {\n if (c == catchNode) {\n current = catchList;\n } else if (c == finallyNode) {\n current = finallyList;\n }\n if (c.getType() == Token.GOTO &&\n (c.getNext() == catchNode || c.getNext() == finallyNode)) {\n continue;\n }\n current.add(c);\n }\n CAstNode finallyBlock = null;\n if (finallyNode != null) {\n int i = 0;\n CAstNode[] finallyAsts = new CAstNode[finallyList.size()];\n for (Iterator fns = finallyList.iterator(); fns.hasNext();) {\n finallyAsts[i++] = walkNodes(fns.next(), context);\n }\n finallyBlock = Ast.makeNode(CAstNode.BLOCK_STMT, finallyAsts);\n }\n if (catchNode != null) {\n int i = 0;\n WalkContext catchChild = new CatchBlockContext(context);\n CAstNode[] catchAsts = new CAstNode[catchList.size()];\n for (Iterator cns = catchList.iterator(); cns.hasNext();) {\n catchAsts[i++] = walkNodes(cns.next(), catchChild);\n }\n CAstNode catchBlock = Ast.makeNode(CAstNode.CATCH, Ast.makeConstant(catchChild.getCatchVar()),\n Ast.makeNode(CAstNode.BLOCK_STMT, catchAsts));\n context.cfg().map(catchBlock, catchBlock);\n i = 0;\n WalkContext tryChild = new TryBlockContext(context, catchBlock);\n CAstNode[] tryAsts = new CAstNode[tryList.size()];\n for (Iterator tns = tryList.iterator(); tns.hasNext();) {\n tryAsts[i++] = walkNodes(tns.next(), tryChild);\n }\n CAstNode tryBlock = Ast.makeNode(CAstNode.BLOCK_STMT, tryAsts);\n if (finallyBlock != null) {\n return Ast.makeNode(CAstNode.BLOCK_STMT,\n Ast.makeNode(CAstNode.UNWIND, Ast.makeNode(CAstNode.TRY, tryBlock, catchBlock), finallyBlock), walkNodes(c, context));\n } else {\n return Ast.makeNode(CAstNode.BLOCK_STMT, Ast.makeNode(CAstNode.TRY, tryBlock, catchBlock), walkNodes(c, context));\n }\n } else {\n int i = 0;\n CAstNode[] tryAsts = new CAstNode[tryList.size()];\n for (Iterator tns = tryList.iterator(); tns.hasNext();) {\n tryAsts[i++] = walkNodes(tns.next(), context);\n }\n CAstNode tryBlock = Ast.makeNode(CAstNode.BLOCK_STMT, tryAsts);\n return Ast.makeNode(\n CAstNode.BLOCK_STMT,\n Ast.makeNode(CAstNode.UNWIND, Ast.makeNode(CAstNode.BLOCK_STMT, tryBlock),\n Ast.makeNode(CAstNode.BLOCK_STMT, finallyBlock)), walkNodes(c, context));\n }\n }\n case Token.JSR: {\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.COMMA: {\n int count = countSiblingsStartingFrom(n.getFirstChild());\n CAstNode[] cs = new CAstNode[count];\n int i = 0;\n for (Node c = n.getFirstChild(); c != null; i++, c = c.getNext()) {\n if (c.getNext() == null) {\n context.updateBase(n, c);\n }\n cs[i] = walkNodes(c, context);\n }\n return Ast.makeNode(CAstNode.BLOCK_EXPR, cs);\n }\n case Token.ENTERWITH:\n case Token.LEAVEWITH: {\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.LOOP: {\n LoopContext child = new LoopContext(context);\n CAstNode[] nodes = gatherChildren(n, child);\n if (child.forInInitExpr != null) {\n String nm = child.forInVar;\n return Ast.makeNode(CAstNode.BLOCK_STMT, Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(nm, true)),\n walkNodes(child.forInInitExpr, context)), nodes);\n } else {\n return Ast.makeNode(CAstNode.BLOCK_STMT, nodes);\n }\n }\n case Token.WITH:\n case Token.FINALLY:\n case Token.BLOCK:\n case Token.LABEL: {\n Node c1 = n.getFirstChild();\n if (c1 != null && c1.getType() == Token.SWITCH) {\n Node switchValue = c1.getFirstChild();\n CAstNode defaultLabel = Ast.makeNode(CAstNode.LABEL_STMT, Ast.makeNode(CAstNode.EMPTY));\n context.cfg().map(defaultLabel, defaultLabel);\n List labelCasts = new ArrayList();\n for (Node kase = switchValue.getNext(); kase != null; kase = kase.getNext()) {\n assert kase.getType() == Token.CASE;\n Node caseLbl = kase.getFirstChild();\n Node target = ((Node.Jump) kase).target;\n CAstNode labelCast = walkNodes(caseLbl, context);\n labelCasts.add(labelCast);\n context.cfg().add(c1, target, labelCast);\n }\n CAstNode[] children = new CAstNode[labelCasts.size() + 1];\n int i = 0;\n children[i++] = Ast.makeNode(CAstNode.BLOCK_STMT, defaultLabel, gatherChildren(n, context, 1));\n for (CAstNode labelCast : labelCasts) {\n children[i++] = labelCast;\n }\n context.cfg().add(c1, defaultLabel, CAstControlFlowMap.SWITCH_DEFAULT);\n CAstNode switchAst = Ast.makeNode(CAstNode.SWITCH, walkNodes(switchValue, context), children);\n noteSourcePosition(context, switchAst, c1);\n context.cfg().map(c1, switchAst);\n return switchAst;\n }\n else {\n return Ast.makeNode(CAstNode.BLOCK_STMT, gatherChildren(n, context));\n }\n }\n case Token.EXPR_VOID:\n case Token.EXPR_RESULT: {\n WalkContext child = new ExpressionContext(context);\n Node expr = n.getFirstChild();\n if (NT == Token.EXPR_RESULT) {\n child.updateBase(n, expr);\n }\n return walkNodes(expr, child);\n }\n case Token.POS: {\n return Ast.makeNode(CAstNode.UNARY_EXPR, translateOpcode(Token.ADD), walkNodes(n.getFirstChild(), context));\n }\n case Token.CALL: {\n if (!isPrimitiveCall(context, n)) {\n CAstNode base = makeVarRef(\"$$ base\");\n Node callee = n.getFirstChild();\n WalkContext child = new BaseCollectingContext(context, callee, \"$$ base\");\n CAstNode fun = walkNodes(callee, child);\n Node firstParamInParens = callee.getNext();\n if (child.foundBase(callee))\n return Ast.makeNode(\n CAstNode.LOCAL_SCOPE,\n Ast.makeNode(CAstNode.BLOCK_EXPR,\n Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(\"$$ base\")), Ast.makeConstant(null)),\n makeCall(fun, base, firstParamInParens, context)));\n else {\n return makeCall(fun, makeVarRef(JSSSAPropagationCallGraphBuilder.GLOBAL_OBJ_VAR_NAME), firstParamInParens, context);\n }\n } else {\n return Ast.makeNode(CAstNode.PRIMITIVE, gatherChildren(n, context, 1));\n }\n }\n case Token.BINDNAME:\n case Token.NAME: {\n return readName(context, n.getString());\n }\n case Token.THIS: {\n return makeVarRef(\"this\");\n }\n case Token.THISFN: {\n return makeVarRef(((FunctionNode) context.top()).getFunctionName());\n }\n case Token.STRING: {\n return Ast.makeConstant(n.getString());\n }\n case Token.NUMBER: {\n return Ast.makeConstant(n.getDouble());\n }\n case Token.FALSE: {\n return Ast.makeConstant(false);\n }\n case Token.TRUE: {\n return Ast.makeConstant(true);\n }\n case Token.NULL:\n case Token.VOID: {\n return Ast.makeConstant(null);\n }\n case Token.ADD:\n case Token.DIV:\n case Token.LSH:\n case Token.MOD:\n case Token.MUL:\n case Token.RSH:\n case Token.SUB:\n case Token.URSH:\n case Token.BITAND:\n case Token.BITOR:\n case Token.BITXOR:\n case Token.EQ:\n case Token.SHEQ:\n case Token.GE:\n case Token.GT:\n case Token.LE:\n case Token.LT:\n case Token.SHNE:\n case Token.NE: {\n Node l = n.getFirstChild();\n Node r = l.getNext();\n return Ast.makeNode(CAstNode.BINARY_EXPR, translateOpcode(NT), walkNodes(l, context), walkNodes(r, context));\n }\n case Token.NEG: {\n return Ast.makeNode(CAstNode.UNARY_EXPR, translateOpcode(Token.SUB), walkNodes(n.getFirstChild(), context));\n }\n case Token.BITNOT:\n case Token.NOT: {\n return Ast.makeNode(CAstNode.UNARY_EXPR, translateOpcode(NT), walkNodes(n.getFirstChild(), context));\n }\n case Token.VAR:\n case Token.CONST: {\n List result = new ArrayList();\n Node nm = n.getFirstChild();\n while (nm != null) {\n context.addNameDecl(Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(nm.getString())),\n readName(context, \"$$undefined\")));\n if (nm.getFirstChild() != null) {\n WalkContext child = new ExpressionContext(context);\n result.add(Ast.makeNode(CAstNode.ASSIGN, makeVarRef(nm.getString()),\n walkNodes(nm.getFirstChild(), child)));\n }\n nm = nm.getNext();\n }\n if (result.size() > 0) {\n return Ast.makeNode(CAstNode.BLOCK_EXPR, result.toArray(new CAstNode[result.size()]));\n } else {\n return Ast.makeNode(CAstNode.EMPTY);\n }\n }\n case Token.REGEXP: {\n int regexIdx = n.getIntProp(Node.REGEXP_PROP, -1);\n assert regexIdx != -1 : \"while converting: \" + context.top().toStringTree(context.top()) + \"\\nlooking at bad regex:\\n \"\n + n.toStringTree(context.top());\n String flags = context.top().getRegexpFlags(regexIdx);\n Node flagsNode = Node.newString(flags);\n String str = context.top().getRegexpString(regexIdx);\n Node strNode = Node.newString(str);\n strNode.addChildToFront(flagsNode);\n return handleNew(context, \"RegExp\", strNode);\n }\n case Token.ENUM_INIT_KEYS: {\n context.createForInVar(n.getFirstChild());\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.ENUM_ID: {\n return Ast.makeNode(CAstNode.EACH_ELEMENT_GET, makeVarRef(context.getForInInitVar()));\n }\n case Token.ENUM_NEXT: {\n return Ast.makeNode(CAstNode.EACH_ELEMENT_HAS_NEXT, makeVarRef(context.getForInInitVar()));\n }\n case Token.RETURN: {\n Node val = n.getFirstChild();\n if (val != null) {\n WalkContext child = new ExpressionContext(context);\n return Ast.makeNode(CAstNode.RETURN, walkNodes(val, child));\n } else {\n return Ast.makeNode(CAstNode.RETURN);\n }\n }\n case Token.SETNAME: {\n Node nm = n.getFirstChild();\n return Ast.makeNode(CAstNode.ASSIGN, walkNodes(nm, context), walkNodes(nm.getNext(), context));\n }\n case Token.IFNE:\n case Token.IFEQ: {\n context.cfg().add(n, ((Node.Jump) n).target, Boolean.TRUE);\n WalkContext child = new ExpressionContext(context);\n CAstNode gotoAst = Ast.makeNode(CAstNode.IFGOTO, translateOpcode(NT), walkNodes(n.getFirstChild(), child),\n Ast.makeConstant(1));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.GOTO: {\n context.cfg().add(n, ((Node.Jump) n).target, null);\n CAstNode gotoAst = Ast.makeNode(CAstNode.GOTO, Ast.makeConstant(((Node.Jump) n).target.labelId()));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.BREAK: {\n context.cfg().add(n, ((Node.Jump) n).getJumpStatement().target, null);\n CAstNode gotoAst = Ast.makeNode(CAstNode.GOTO, Ast.makeConstant(((Node.Jump) n).getJumpStatement().target.labelId()));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.CONTINUE: {\n context.cfg().add(n, ((Node.Jump) n).getJumpStatement().getContinue(), null);\n CAstNode gotoAst = Ast.makeNode(CAstNode.GOTO, Ast.makeConstant(((Node.Jump) n).getJumpStatement().getContinue().labelId()));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.TARGET: {\n CAstNode result = Ast.makeNode(CAstNode.LABEL_STMT, Ast.makeConstant(n.labelId()), Ast.makeNode(CAstNode.EMPTY));\n context.cfg().map(n, result);\n return result;\n }\n case Token.OR: {\n \tNode l = n.getFirstChild();\n \tNode r = l.getNext();\n \tCAstNode lhs = walkNodes(l, context);\n \tString lhsTempName = \"or___lhs\";\n \treturn Ast.makeNode(\n \t\t\tCAstNode.LOCAL_SCOPE,\n \t\t\tAst.makeNode(CAstNode.BLOCK_EXPR,\n \t\t\t\t\tAst.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(lhsTempName)), lhs),\n \t\t\t\t\tAst.makeNode(CAstNode.IF_EXPR, makeVarRef(lhsTempName), makeVarRef(lhsTempName), walkNodes(r, context))));\n }\n case Token.AND: {\n Node l = n.getFirstChild();\n Node r = l.getNext();\n CAstNode lhs = walkNodes(l, context);\n String lhsTempName = \"and___lhs\";\n return Ast.makeNode(\n \t\t CAstNode.LOCAL_SCOPE,\n \t\t Ast.makeNode(CAstNode.BLOCK_EXPR,\n \t\t\t\t Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(lhsTempName)), lhs),\n \t\t\t\t Ast.makeNode(CAstNode.IF_EXPR, makeVarRef(lhsTempName), walkNodes(r, context), makeVarRef(lhsTempName))));\n }\n case Token.HOOK: {\n Node cond = n.getFirstChild();\n Node thenBranch = cond.getNext();\n Node elseBranch = thenBranch.getNext();\n return Ast.makeNode(CAstNode.IF_EXPR, walkNodes(cond, context), walkNodes(thenBranch, context),\n walkNodes(elseBranch, context));\n }\n case Token.INC:\n case Token.DEC: {\n int flags = n.getIntProp(Node.INCRDECR_PROP, -1);\n CAstNode op = ((flags & Node.DECR_FLAG) != 0) ? CAstOperator.OP_SUB : CAstOperator.OP_ADD;\n Node l = n.getFirstChild();\n CAstNode last = walkNodes(l, context);\n return Ast.makeNode((((flags & Node.POST_FLAG) != 0) ? CAstNode.ASSIGN_POST_OP : CAstNode.ASSIGN_PRE_OP), last,\n Ast.makeConstant(1), op);\n }\n case Token.NEW: {\n if (isPrimitiveCreation(context, n)) {\n return makeBuiltinNew(n.getFirstChild().getString());\n } else {\n Node receiver = n.getFirstChild();\n return handleNew(context, walkNodes(receiver, context), receiver.getNext());\n }\n }\n case Token.ARRAYLIT: {\n int count = 0;\n for (Node x = n.getFirstChild(); x != null; count++, x = x.getNext())\n ;\n int i = 0;\n CAstNode[] args = new CAstNode[2 * count + 1];\n args[i++] = (isPrologueScript(context)) ? makeBuiltinNew(\"Array\") : handleNew(context, \"Array\", null);\n int[] skips = (int[]) n.getProp(Node.SKIP_INDEXES_PROP);\n int skip = 0;\n int idx = 0;\n Node elt = n.getFirstChild();\n while (elt != null) {\n if (skips != null && skip < skips.length && skips[skip] == idx) {\n skip++;\n idx++;\n continue;\n }\n args[i++] = Ast.makeConstant(idx++);\n args[i++] = walkNodes(elt, context);\n elt = elt.getNext();\n }\n return Ast.makeNode(CAstNode.OBJECT_LITERAL, args);\n }\n case Token.OBJECTLIT: {\n Object[] propertyList = (Object[]) n.getProp(Node.OBJECT_IDS_PROP);\n CAstNode[] args = new CAstNode[propertyList.length * 2 + 1];\n int i = 0;\n args[i++] = ((isPrologueScript(context)) ? makeBuiltinNew(\"Object\") : handleNew(context, \"Object\", null));\n Node val = n.getFirstChild();\n int nameIdx = 0;\n for (; nameIdx < propertyList.length; nameIdx++, val = val.getNext()) {\n args[i++] = Ast.makeConstant(propertyList[nameIdx]);\n args[i++] = walkNodes(val, context);\n }\n return Ast.makeNode(CAstNode.OBJECT_LITERAL, args);\n }\n case Token.GETPROP:\n case Token.GETELEM: {\n Node receiver = n.getFirstChild();\n Node element = receiver.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n String baseVarName = context.getBaseVarNameIfRelevant(n);\n CAstNode elt = walkNodes(element, context);\n CAstNode get, result;\n if (baseVarName != null) {\n result = Ast.makeNode(CAstNode.BLOCK_EXPR, Ast.makeNode(CAstNode.ASSIGN, makeVarRef(baseVarName), rcvr),\n get = Ast.makeNode(CAstNode.OBJECT_REF, makeVarRef(baseVarName), elt));\n } else {\n result = get = Ast.makeNode(CAstNode.OBJECT_REF, rcvr, elt);\n }\n if (context.getCatchTarget() != null) {\n context.cfg().map(get, get);\n context.cfg().add(get, context.getCatchTarget(), JavaScriptTypes.TypeError);\n }\n return result;\n }\n case Token.GET_REF: {\n Node child1 = n.getFirstChild();\n assert child1.getType() == Token.REF_SPECIAL;\n assert child1.getProp(Node.NAME_PROP).equals(\"__proto__\");\n Node receiver = child1.getFirstChild(); \n assert child1.getNext() == null;\n CAstNode rcvr = walkNodes(receiver, context);\n final CAstNode result = Ast.makeNode(CAstNode.OBJECT_REF, rcvr, Ast.makeConstant(\"__proto__\"));\n if (context.getCatchTarget() != null) {\n context.cfg().map(result, result);\n context.cfg().add(result, context.getCatchTarget(), JavaScriptTypes.TypeError);\n }\n return result;\n }\n case Token.SETPROP:\n case Token.SETELEM: {\n Node receiver = n.getFirstChild();\n Node elt = receiver.getNext();\n Node val = elt.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n return Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, walkNodes(elt, context)),\n walkNodes(val, context));\n }\n case Token.SET_REF: {\n Node child1 = n.getFirstChild();\n assert child1.getType() == Token.REF_SPECIAL;\n assert child1.getProp(Node.NAME_PROP).equals(\"__proto__\");\n Node receiver = child1.getFirstChild();\n Node val = child1.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n return Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, Ast.makeConstant(\"__proto__\")),\n walkNodes(val, context));\n }\n case Token.DELPROP: {\n Node receiver = n.getFirstChild();\n Node element = receiver.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n String baseVarName = context.getBaseVarNameIfRelevant(n);\n CAstNode elt = walkNodes(element, context);\n if (baseVarName != null) {\n return Ast.makeNode(CAstNode.BLOCK_EXPR, Ast.makeNode(CAstNode.ASSIGN, makeVarRef(baseVarName), rcvr),\n Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, makeVarRef(baseVarName), elt), Ast.makeConstant(null)));\n } else {\n return Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, elt), Ast.makeConstant(null));\n }\n }\n case Token.TYPEOFNAME: {\n return Ast.makeNode(CAstNode.TYPE_OF, makeVarRef(n.getString()));\n }\n case Token.TYPEOF: {\n return Ast.makeNode(CAstNode.TYPE_OF, walkNodes(n.getFirstChild(), context));\n }\n case Token.SETPROP_OP:\n case Token.SETELEM_OP: {\n Node receiver = n.getFirstChild();\n Node elt = receiver.getNext();\n Node op = elt.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n return Ast.makeNode(CAstNode.ASSIGN_POST_OP, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, walkNodes(elt, context)),\n walkNodes(op.getFirstChild().getNext(), context), translateOpcode(op.getType()));\n }\n case Token.THROW: {\n CAstNode catchNode = context.getCatchTarget();\n if (catchNode != null)\n context.cfg().add(n, context.getCatchTarget(), null);\n else\n context.cfg().add(n, CAstControlFlowMap.EXCEPTION_TO_EXIT, null);\n CAstNode throwAst = Ast.makeNode(CAstNode.THROW, walkNodes(n.getFirstChild(), context));\n context.cfg().map(n, throwAst);\n return throwAst;\n }\n case Token.EMPTY: {\n return Ast.makeConstant(null);\n }\n case Token.INSTANCEOF: {\n Node value = n.getFirstChild();\n Node type = value.getNext();\n return Ast.makeNode(CAstNode.INSTANCEOF, walkNodes(value, context), walkNodes(type, context));\n }\n case Token.IN: {\n Node value = n.getFirstChild();\n Node property = value.getNext();\n return Ast.makeNode(CAstNode.IS_DEFINED_EXPR, walkNodes(value, context), walkNodes(property, context));\n }\n default: {\n System.err.println(\"while converting: \" + context.top().toStringTree(context.top()) + \"\\nlooking at unhandled:\\n \"\n + n.toStringTree(context.top()) + \"\\n(of type \" + NT + \") (of class \" + n.getClass() + \")\" + \" at \" + n.getLineno());\n Assertions.UNREACHABLE();\n return null;\n }\n }\n }\n", "output": " private CAstNode walkNodesInternal(final Node n, WalkContext context) {\n final int NT = n.getType();\n switch (NT) {\n case Token.FUNCTION: {\n int fnIndex = n.getExistingIntProp(Node.FUNCTION_PROP);\n FunctionNode fn = context.top().getFunctionNode(fnIndex);\n CAstEntity fne = walkEntity(fn, context);\n if (context.expressionContext()) {\n CAstNode fun = Ast.makeNode(CAstNode.FUNCTION_EXPR, Ast.makeConstant(fne));\n context.addScopedEntity(fun, fne);\n return fun;\n } else {\n context.addNameDecl(Ast.makeNode(CAstNode.FUNCTION_STMT, Ast.makeConstant(fne)));\n context.addScopedEntity(null, fne);\n return Ast.makeNode(CAstNode.EMPTY);\n }\n }\n case Token.CATCH_SCOPE: {\n Node catchVarNode = n.getFirstChild();\n String catchVarName = catchVarNode.getString();\n assert catchVarName != null;\n context.setCatchVar(catchVarName);\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.LOCAL_BLOCK: {\n return Ast.makeNode(CAstNode.BLOCK_EXPR, gatherChildren(n, context));\n }\n case Token.TRY: {\n Node catchNode = ((Node.Jump) n).target;\n Node finallyNode = ((Node.Jump) n).getFinally();\n ArrayList tryList = new ArrayList();\n ArrayList catchList = new ArrayList();\n ArrayList finallyList = new ArrayList();\n ArrayList current = tryList;\n Node c;\n for (c = n.getFirstChild(); c.getNext() != null; c = c.getNext()) {\n if (c == catchNode) {\n current = catchList;\n } else if (c == finallyNode) {\n current = finallyList;\n }\n if (c.getType() == Token.GOTO &&\n (c.getNext() == catchNode || c.getNext() == finallyNode)) {\n continue;\n }\n current.add(c);\n }\n CAstNode finallyBlock = null;\n if (finallyNode != null) {\n int i = 0;\n CAstNode[] finallyAsts = new CAstNode[finallyList.size()];\n for (Iterator fns = finallyList.iterator(); fns.hasNext();) {\n finallyAsts[i++] = walkNodes(fns.next(), context);\n }\n finallyBlock = Ast.makeNode(CAstNode.BLOCK_STMT, finallyAsts);\n }\n if (catchNode != null) {\n int i = 0;\n WalkContext catchChild = new CatchBlockContext(context);\n CAstNode[] catchAsts = new CAstNode[catchList.size()];\n for (Iterator cns = catchList.iterator(); cns.hasNext();) {\n catchAsts[i++] = walkNodes(cns.next(), catchChild);\n }\n CAstNode catchBlock = Ast.makeNode(CAstNode.CATCH, Ast.makeConstant(catchChild.getCatchVar()),\n Ast.makeNode(CAstNode.BLOCK_STMT, catchAsts));\n context.cfg().map(catchBlock, catchBlock);\n i = 0;\n WalkContext tryChild = new TryBlockContext(context, catchBlock);\n CAstNode[] tryAsts = new CAstNode[tryList.size()];\n for (Iterator tns = tryList.iterator(); tns.hasNext();) {\n tryAsts[i++] = walkNodes(tns.next(), tryChild);\n }\n CAstNode tryBlock = Ast.makeNode(CAstNode.BLOCK_STMT, tryAsts);\n if (finallyBlock != null) {\n return Ast.makeNode(CAstNode.BLOCK_STMT,\n Ast.makeNode(CAstNode.UNWIND, Ast.makeNode(CAstNode.TRY, tryBlock, catchBlock), finallyBlock), walkNodes(c, context));\n } else {\n return Ast.makeNode(CAstNode.BLOCK_STMT, Ast.makeNode(CAstNode.TRY, tryBlock, catchBlock), walkNodes(c, context));\n }\n } else {\n int i = 0;\n CAstNode[] tryAsts = new CAstNode[tryList.size()];\n for (Iterator tns = tryList.iterator(); tns.hasNext();) {\n tryAsts[i++] = walkNodes(tns.next(), context);\n }\n CAstNode tryBlock = Ast.makeNode(CAstNode.BLOCK_STMT, tryAsts);\n return Ast.makeNode(\n CAstNode.BLOCK_STMT,\n Ast.makeNode(CAstNode.UNWIND, Ast.makeNode(CAstNode.BLOCK_STMT, tryBlock),\n Ast.makeNode(CAstNode.BLOCK_STMT, finallyBlock)), walkNodes(c, context));\n }\n }\n case Token.JSR: {\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.COMMA: {\n int count = countSiblingsStartingFrom(n.getFirstChild());\n CAstNode[] cs = new CAstNode[count];\n int i = 0;\n for (Node c = n.getFirstChild(); c != null; i++, c = c.getNext()) {\n if (c.getNext() == null) {\n context.updateBase(n, c);\n }\n cs[i] = walkNodes(c, context);\n }\n return Ast.makeNode(CAstNode.BLOCK_EXPR, cs);\n }\n case Token.ENTERWITH:\n case Token.LEAVEWITH: {\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.LOOP: {\n LoopContext child = new LoopContext(context);\n CAstNode[] nodes = gatherChildren(n, child);\n if (child.forInInitExpr != null) {\n String nm = child.forInVar;\n return Ast.makeNode(CAstNode.BLOCK_STMT, Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(nm, true)),\n walkNodes(child.forInInitExpr, context)), nodes);\n } else {\n return Ast.makeNode(CAstNode.BLOCK_STMT, nodes);\n }\n }\n case Token.WITH:\n case Token.FINALLY:\n case Token.BLOCK:\n case Token.LABEL: {\n Node c1 = n.getFirstChild();\n if (c1 != null && c1.getType() == Token.SWITCH) {\n Node switchValue = c1.getFirstChild();\n CAstNode defaultLabel = Ast.makeNode(CAstNode.LABEL_STMT, Ast.makeNode(CAstNode.EMPTY));\n context.cfg().map(defaultLabel, defaultLabel);\n List labelCasts = new ArrayList();\n for (Node kase = switchValue.getNext(); kase != null; kase = kase.getNext()) {\n assert kase.getType() == Token.CASE;\n Node caseLbl = kase.getFirstChild();\n Node target = ((Node.Jump) kase).target;\n CAstNode labelCast = walkNodes(caseLbl, context);\n labelCasts.add(labelCast);\n context.cfg().add(c1, target, labelCast);\n }\n CAstNode[] children = new CAstNode[labelCasts.size() + 1];\n int i = 0;\n children[i++] = Ast.makeNode(CAstNode.BLOCK_STMT, defaultLabel, gatherChildren(n, context, 1));\n for (CAstNode labelCast : labelCasts) {\n children[i++] = labelCast;\n }\n context.cfg().add(c1, defaultLabel, CAstControlFlowMap.SWITCH_DEFAULT);\n CAstNode switchAst = Ast.makeNode(CAstNode.SWITCH, walkNodes(switchValue, context), children);\n noteSourcePosition(context, switchAst, c1);\n context.cfg().map(c1, switchAst);\n return switchAst;\n }\n else {\n return Ast.makeNode(CAstNode.BLOCK_STMT, gatherChildren(n, context));\n }\n }\n case Token.EXPR_VOID:\n case Token.EXPR_RESULT: {\n WalkContext child = new ExpressionContext(context);\n Node expr = n.getFirstChild();\n if (NT == Token.EXPR_RESULT) {\n child.updateBase(n, expr);\n }\n return walkNodes(expr, child);\n }\n case Token.POS: {\n return Ast.makeNode(CAstNode.UNARY_EXPR, translateOpcode(Token.ADD), walkNodes(n.getFirstChild(), context));\n }\n case Token.CALL: {\n if (!isPrimitiveCall(context, n)) {\n CAstNode base = makeVarRef(\"$$ base\");\n Node callee = n.getFirstChild();\n WalkContext child = new BaseCollectingContext(context, callee, \"$$ base\");\n CAstNode fun = walkNodes(callee, child);\n Node firstParamInParens = callee.getNext();\n if (child.foundBase(callee))\n return Ast.makeNode(\n CAstNode.LOCAL_SCOPE,\n Ast.makeNode(CAstNode.BLOCK_EXPR,\n Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(\"$$ base\")), Ast.makeConstant(null)),\n makeCall(fun, base, firstParamInParens, context)));\n else {\n return makeCall(fun, makeVarRef(JSSSAPropagationCallGraphBuilder.GLOBAL_OBJ_VAR_NAME), firstParamInParens, context);\n }\n } else {\n return Ast.makeNode(CAstNode.PRIMITIVE, gatherChildren(n, context, 1));\n }\n }\n case Token.BINDNAME:\n case Token.NAME: {\n return readName(context, n.getString());\n }\n case Token.THIS: {\n return makeVarRef(\"this\");\n }\n case Token.THISFN: {\n return makeVarRef(((FunctionNode) context.top()).getFunctionName());\n }\n case Token.STRING: {\n return Ast.makeConstant(n.getString());\n }\n case Token.NUMBER: {\n return Ast.makeConstant(n.getDouble());\n }\n case Token.FALSE: {\n return Ast.makeConstant(false);\n }\n case Token.TRUE: {\n return Ast.makeConstant(true);\n }\n case Token.NULL:\n case Token.VOID: {\n return Ast.makeConstant(null);\n }\n case Token.ADD:\n case Token.DIV:\n case Token.LSH:\n case Token.MOD:\n case Token.MUL:\n case Token.RSH:\n case Token.SUB:\n case Token.URSH:\n case Token.BITAND:\n case Token.BITOR:\n case Token.BITXOR:\n case Token.EQ:\n case Token.SHEQ:\n case Token.GE:\n case Token.GT:\n case Token.LE:\n case Token.LT:\n case Token.SHNE:\n case Token.NE: {\n Node l = n.getFirstChild();\n Node r = l.getNext();\n return Ast.makeNode(CAstNode.BINARY_EXPR, translateOpcode(NT), walkNodes(l, context), walkNodes(r, context));\n }\n case Token.NEG: {\n return Ast.makeNode(CAstNode.UNARY_EXPR, translateOpcode(Token.SUB), walkNodes(n.getFirstChild(), context));\n }\n case Token.BITNOT:\n case Token.NOT: {\n return Ast.makeNode(CAstNode.UNARY_EXPR, translateOpcode(NT), walkNodes(n.getFirstChild(), context));\n }\n case Token.VAR:\n case Token.CONST: {\n List result = new ArrayList();\n Node nm = n.getFirstChild();\n while (nm != null) {\n context.addNameDecl(Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(nm.getString())),\n readName(context, \"$$undefined\")));\n if (nm.getFirstChild() != null) {\n WalkContext child = new ExpressionContext(context);\n result.add(Ast.makeNode(CAstNode.ASSIGN, makeVarRef(nm.getString()),\n walkNodes(nm.getFirstChild(), child)));\n }\n nm = nm.getNext();\n }\n if (result.size() > 0) {\n return Ast.makeNode(CAstNode.BLOCK_EXPR, result.toArray(new CAstNode[result.size()]));\n } else {\n return Ast.makeNode(CAstNode.EMPTY);\n }\n }\n case Token.REGEXP: {\n int regexIdx = n.getIntProp(Node.REGEXP_PROP, -1);\n assert regexIdx != -1 : \"while converting: \" + context.top().toStringTree(context.top()) + \"\\nlooking at bad regex:\\n \"\n + n.toStringTree(context.top());\n String flags = context.top().getRegexpFlags(regexIdx);\n Node flagsNode = Node.newString(flags);\n String str = context.top().getRegexpString(regexIdx);\n Node strNode = Node.newString(str);\n strNode.addChildToFront(flagsNode);\n return handleNew(context, \"RegExp\", strNode);\n }\n case Token.ENUM_INIT_KEYS: {\n context.createForInVar(n.getFirstChild());\n return Ast.makeNode(CAstNode.EMPTY);\n }\n case Token.ENUM_ID: {\n return Ast.makeNode(CAstNode.EACH_ELEMENT_GET, makeVarRef(context.getForInInitVar()));\n }\n case Token.ENUM_NEXT: {\n return Ast.makeNode(CAstNode.EACH_ELEMENT_HAS_NEXT, makeVarRef(context.getForInInitVar()));\n }\n case Token.RETURN: {\n Node val = n.getFirstChild();\n if (val != null) {\n WalkContext child = new ExpressionContext(context);\n return Ast.makeNode(CAstNode.RETURN, walkNodes(val, child));\n } else {\n return Ast.makeNode(CAstNode.RETURN);\n }\n }\n case Token.SETNAME: {\n Node nm = n.getFirstChild();\n return Ast.makeNode(CAstNode.ASSIGN, walkNodes(nm, context), walkNodes(nm.getNext(), context));\n }\n case Token.IFNE:\n case Token.IFEQ: {\n context.cfg().add(n, ((Node.Jump) n).target, Boolean.TRUE);\n WalkContext child = new ExpressionContext(context);\n CAstNode gotoAst = Ast.makeNode(CAstNode.IFGOTO, translateOpcode(NT), walkNodes(n.getFirstChild(), child),\n Ast.makeConstant(1));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.GOTO: {\n context.cfg().add(n, ((Node.Jump) n).target, null);\n CAstNode gotoAst = Ast.makeNode(CAstNode.GOTO, Ast.makeConstant(((Node.Jump) n).target.labelId()));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.BREAK: {\n context.cfg().add(n, ((Node.Jump) n).getJumpStatement().target, null);\n CAstNode gotoAst = Ast.makeNode(CAstNode.GOTO, Ast.makeConstant(((Node.Jump) n).getJumpStatement().target.labelId()));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.CONTINUE: {\n context.cfg().add(n, ((Node.Jump) n).getJumpStatement().getContinue(), null);\n CAstNode gotoAst = Ast.makeNode(CAstNode.GOTO, Ast.makeConstant(((Node.Jump) n).getJumpStatement().getContinue().labelId()));\n context.cfg().map(n, gotoAst);\n return gotoAst;\n }\n case Token.TARGET: {\n CAstNode result = Ast.makeNode(CAstNode.LABEL_STMT, Ast.makeConstant(n.labelId()), Ast.makeNode(CAstNode.EMPTY));\n context.cfg().map(n, result);\n return result;\n }\n case Token.OR: {\n \tNode l = n.getFirstChild();\n \tNode r = l.getNext();\n \tCAstNode lhs = walkNodes(l, context);\n \tString lhsTempName = \"or___lhs\";\n \treturn Ast.makeNode(\n \t\t\tCAstNode.LOCAL_SCOPE,\n \t\t\tAst.makeNode(CAstNode.BLOCK_EXPR,\n \t\t\t\t\tAst.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(lhsTempName)), lhs),\n \t\t\t\t\tAst.makeNode(CAstNode.IF_EXPR, makeVarRef(lhsTempName), makeVarRef(lhsTempName), walkNodes(r, context))));\n }\n case Token.AND: {\n Node l = n.getFirstChild();\n Node r = l.getNext();\n CAstNode lhs = walkNodes(l, context);\n String lhsTempName = \"and___lhs\";\n return Ast.makeNode(\n \t\t CAstNode.LOCAL_SCOPE,\n \t\t Ast.makeNode(CAstNode.BLOCK_EXPR,\n \t\t\t\t Ast.makeNode(CAstNode.DECL_STMT, Ast.makeConstant(new CAstSymbolImpl(lhsTempName)), lhs),\n \t\t\t\t Ast.makeNode(CAstNode.IF_EXPR, makeVarRef(lhsTempName), walkNodes(r, context), makeVarRef(lhsTempName))));\n }\n case Token.HOOK: {\n Node cond = n.getFirstChild();\n Node thenBranch = cond.getNext();\n Node elseBranch = thenBranch.getNext();\n return Ast.makeNode(CAstNode.IF_EXPR, walkNodes(cond, context), walkNodes(thenBranch, context),\n walkNodes(elseBranch, context));\n }\n case Token.INC:\n case Token.DEC: {\n int flags = n.getIntProp(Node.INCRDECR_PROP, -1);\n CAstNode op = ((flags & Node.DECR_FLAG) != 0) ? CAstOperator.OP_SUB : CAstOperator.OP_ADD;\n Node l = n.getFirstChild();\n CAstNode last = walkNodes(l, context);\n return Ast.makeNode((((flags & Node.POST_FLAG) != 0) ? CAstNode.ASSIGN_POST_OP : CAstNode.ASSIGN_PRE_OP), last,\n Ast.makeConstant(1), op);\n }\n case Token.NEW: {\n if (isPrimitiveCreation(context, n)) {\n return makeBuiltinNew(n.getFirstChild().getString());\n } else {\n Node receiver = n.getFirstChild();\n return handleNew(context, walkNodes(receiver, context), receiver.getNext());\n }\n }\n case Token.ARRAYLIT: {\n int count = 0;\n for (Node x = n.getFirstChild(); x != null; count++, x = x.getNext())\n ;\n int i = 0;\n CAstNode[] args = new CAstNode[2 * count + 1];\n args[i++] = (isPrologueScript(context)) ? makeBuiltinNew(\"Array\") : handleNew(context, \"Array\", null);\n int[] skips = (int[]) n.getProp(Node.SKIP_INDEXES_PROP);\n int skip = 0;\n int idx = 0;\n Node elt = n.getFirstChild();\n while (elt != null) {\n if (skips != null && skip < skips.length && skips[skip] == idx) {\n skip++;\n idx++;\n continue;\n }\n args[i++] = Ast.makeConstant(idx++);\n args[i++] = walkNodes(elt, context);\n elt = elt.getNext();\n }\n return Ast.makeNode(CAstNode.OBJECT_LITERAL, args);\n }\n case Token.OBJECTLIT: {\n Object[] propertyList = (Object[]) n.getProp(Node.OBJECT_IDS_PROP);\n CAstNode[] args = new CAstNode[propertyList.length * 2 + 1];\n int i = 0;\n args[i++] = ((isPrologueScript(context)) ? makeBuiltinNew(\"Object\") : handleNew(context, \"Object\", null));\n Node val = n.getFirstChild();\n int nameIdx = 0;\n for (; nameIdx < propertyList.length; nameIdx++, val = val.getNext()) {\n args[i++] = Ast.makeConstant(propertyList[nameIdx]);\n args[i++] = walkNodes(val, context);\n }\n return Ast.makeNode(CAstNode.OBJECT_LITERAL, args);\n }\n case Token.GETPROP:\n case Token.GETELEM: {\n Node receiver = n.getFirstChild();\n Node element = receiver.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n String baseVarName = context.getBaseVarNameIfRelevant(n);\n CAstNode elt = walkNodes(element, context);\n CAstNode get, result;\n if (baseVarName != null) {\n result = Ast.makeNode(CAstNode.BLOCK_EXPR, Ast.makeNode(CAstNode.ASSIGN, makeVarRef(baseVarName), rcvr),\n get = Ast.makeNode(CAstNode.OBJECT_REF, makeVarRef(baseVarName), elt));\n } else {\n result = get = Ast.makeNode(CAstNode.OBJECT_REF, rcvr, elt);\n }\n if (context.getCatchTarget() != null) {\n context.cfg().map(get, get);\n context.cfg().add(get, context.getCatchTarget(), JavaScriptTypes.TypeError);\n }\n return result;\n }\n case Token.GET_REF: {\n Node child1 = n.getFirstChild();\n assert child1.getType() == Token.REF_SPECIAL;\n assert child1.getProp(Node.NAME_PROP).equals(\"__proto__\");\n Node receiver = child1.getFirstChild(); \n assert child1.getNext() == null;\n CAstNode rcvr = walkNodes(receiver, context);\n final CAstNode result = Ast.makeNode(CAstNode.OBJECT_REF, rcvr, Ast.makeConstant(\"__proto__\"));\n if (context.getCatchTarget() != null) {\n context.cfg().map(result, result);\n context.cfg().add(result, context.getCatchTarget(), JavaScriptTypes.TypeError);\n }\n return result;\n }\n case Token.SETPROP:\n case Token.SETELEM: {\n Node receiver = n.getFirstChild();\n Node elt = receiver.getNext();\n Node val = elt.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n return Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, walkNodes(elt, context)),\n walkNodes(val, context));\n }\n case Token.SET_REF: {\n Node child1 = n.getFirstChild();\n assert child1.getType() == Token.REF_SPECIAL;\n assert child1.getProp(Node.NAME_PROP).equals(\"__proto__\");\n Node receiver = child1.getFirstChild();\n Node val = child1.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n return Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, Ast.makeConstant(\"__proto__\")),\n walkNodes(val, context));\n }\n case Token.DELPROP: {\n Node receiver = n.getFirstChild();\n Node element = receiver.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n String baseVarName = context.getBaseVarNameIfRelevant(n);\n CAstNode elt = walkNodes(element, context);\n if (baseVarName != null) {\n return Ast.makeNode(CAstNode.BLOCK_EXPR, Ast.makeNode(CAstNode.ASSIGN, makeVarRef(baseVarName), rcvr),\n Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, makeVarRef(baseVarName), elt), Ast.makeConstant(null)));\n } else {\n return Ast.makeNode(CAstNode.ASSIGN, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, elt), Ast.makeConstant(null));\n }\n }\n case Token.TYPEOFNAME: {\n return Ast.makeNode(CAstNode.TYPE_OF, makeVarRef(n.getString()));\n }\n case Token.TYPEOF: {\n return Ast.makeNode(CAstNode.TYPE_OF, walkNodes(n.getFirstChild(), context));\n }\n case Token.SETPROP_OP:\n case Token.SETELEM_OP: {\n Node receiver = n.getFirstChild();\n Node elt = receiver.getNext();\n Node op = elt.getNext();\n CAstNode rcvr = walkNodes(receiver, context);\n return Ast.makeNode(CAstNode.ASSIGN_POST_OP, Ast.makeNode(CAstNode.OBJECT_REF, rcvr, walkNodes(elt, context)),\n walkNodes(op.getFirstChild().getNext(), context), translateOpcode(op.getType()));\n }\n case Token.THROW: {\n CAstNode catchNode = context.getCatchTarget();\n if (catchNode != null)\n context.cfg().add(n, context.getCatchTarget(), null);\n else\n context.cfg().add(n, CAstControlFlowMap.EXCEPTION_TO_EXIT, null);\n CAstNode throwAst = Ast.makeNode(CAstNode.THROW, walkNodes(n.getFirstChild(), context));\n context.cfg().map(n, throwAst);\n return throwAst;\n }\n case Token.EMPTY: {\n return Ast.makeConstant(null);\n }\n case Token.INSTANCEOF: {\n Node value = n.getFirstChild();\n Node type = value.getNext();\n return Ast.makeNode(CAstNode.INSTANCEOF, walkNodes(value, context), walkNodes(type, context));\n }\n case Token.IN: {\n Node value = n.getFirstChild();\n Node property = value.getNext();\n return Ast.makeNode(CAstNode.IS_DEFINED_EXPR, walkNodes(property, context), walkNodes(value, context));\n }\n default: {\n System.err.println(\"while converting: \" + context.top().toStringTree(context.top()) + \"\\nlooking at unhandled:\\n \"\n + n.toStringTree(context.top()) + \"\\n(of type \" + NT + \") (of class \" + n.getClass() + \")\" + \" at \" + n.getLineno());\n Assertions.UNREACHABLE();\n return null;\n }\n }\n }\n"} {"input": "\tpublic boolean writeMoP(){\n\t\tBitPack bitPack = new BitPack(this);\n\t\tbitPack.write(0);\n\t\tbitPack.writeGuidMask(new byte[] {1, 3, 2});\n\t\tbitPack.write(character.getName().length(), 6);\n\t\tbitPack.writeGuidMask(new byte[] {6, 4, 0});\n\t\tbitPack.write(0);\n\t\tbitPack.writeGuidMask(new byte[] {5, 7});\t\n\t\tbitPack.flush();\n\t\tbitPack.writeGuidBytes(new byte[] {1});\n\t\tthis.putString(character.getName());\n\t\tbitPack.writeGuidBytes(new byte[] {0, 7});\n\t\tthis.putInt(character.getCharRace());\n\t\tthis.putInt(0); \n\t\tthis.putInt(1); \n\t\tthis.putInt(character.getCharClass());\n\t\tbitPack.writeGuidBytes(new byte[] {4, 6, 5});\n\t\tthis.putInt(1);\n\t\tbitPack.writeGuidBytes(new byte[] {3, 2});\n\t\tLog.log(\"realm id: \" + realm.id);\n\t\tthis.wrap();\n\t\treturn true;\n\t}\n", "output": "\tpublic boolean writeMoP(){\n\t\tBitPack bitPack = new BitPack(this);\n\t\tbitPack.write(0);\n\t\tbitPack.writeGuidMask(new byte[] {1, 3, 2});\n\t\tbitPack.write(character.getName().length(), 6);\n\t\tbitPack.writeGuidMask(new byte[] {6, 4, 0});\n\t\tbitPack.write(0);\n\t\tbitPack.writeGuidMask(new byte[] {5, 7});\t\n\t\tbitPack.flush();\n\t\tbitPack.writeGuidBytes(new byte[] {1});\n\t\tthis.putString(character.getName());\n\t\tbitPack.writeGuidBytes(new byte[] {0, 7});\n\t\tthis.put((byte) character.getCharRace());\n\t\tthis.put((byte) 0); \n\t\tthis.put((byte) 1); \n\t\tthis.put((byte) character.getCharClass());\n\t\tbitPack.writeGuidBytes(new byte[] {4, 6, 5});\n\t\tthis.putInt(1);\n\t\tbitPack.writeGuidBytes(new byte[] {3, 2});\n\t\tLog.log(\"realm id: \" + realm.id);\n\t\tthis.wrap();\n\t\treturn true;\n\t}\n"} {"input": "\tprotected Collection getAllPluginResourceURLs() {\n\t\tSet result = Sets.newLinkedHashSet();\n\t\tClassLoader classLoader = ClassLoader.getSystemClassLoader();\n\t\ttry {\n\t\t\tEnumeration resources = classLoader.getResources(\"plugin.xml\");\n\t\t\twhile (resources.hasMoreElements())\n\t\t\t\tresult.add(resources.nextElement());\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t\tif (classLoader instanceof URLClassLoader) {\n\t\t\tURLClassLoader ucl = (URLClassLoader) classLoader;\n\t\t\tfor (URL u : ucl.getURLs())\n\t\t\t\tif (!u.getFile().endsWith(\".jar\")) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tjava.io.File f = new java.io.File(u.toURI());\n\t\t\t\t\t\tif (f.isDirectory()) {\n\t\t\t\t\t\t\tint levels = 5;\n\t\t\t\t\t\t\twhile (levels >= 0) {\n\t\t\t\t\t\t\t\tjava.io.File pl = new java.io.File(f + \"/\" + \"plugin.xml\");\n\t\t\t\t\t\t\t\tif (pl.isFile()) {\n\t\t\t\t\t\t\t\t\tresult.add(pl.toURI().toURL());\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlevels--;\n\t\t\t\t\t\t\t\tf = f.getParentFile();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (URISyntaxException e) {\n\t\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t\t} catch (MalformedURLException e) {\n\t\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n", "output": "\tprotected Collection getAllPluginResourceURLs() {\n\t\tSet result = Sets.newLinkedHashSet();\n\t\tClassLoader classLoader = ClassLoader.getSystemClassLoader();\n\t\ttry {\n\t\t\tEnumeration resources = classLoader.getResources(\"plugin.xml\");\n\t\t\twhile (resources.hasMoreElements())\n\t\t\t\tresult.add(resources.nextElement());\n\t\t} catch (IOException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n\t\tif (classLoader instanceof URLClassLoader) {\n\t\t\tURLClassLoader ucl = (URLClassLoader) classLoader;\n\t\t\tfor (URL u : ucl.getURLs())\n\t\t\t\tif (!u.getFile().endsWith(\".jar\")) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tjava.io.File f = new java.io.File(u.toURI());\n\t\t\t\t\t\tif (f.isDirectory()) {\n\t\t\t\t\t\t\tint levels = 5;\n\t\t\t\t\t\t\twhile (levels >= 0 && f != null) {\n\t\t\t\t\t\t\t\tjava.io.File pl = new java.io.File(f + \"/\" + \"plugin.xml\");\n\t\t\t\t\t\t\t\tif (pl.isFile()) {\n\t\t\t\t\t\t\t\t\tresult.add(pl.toURI().toURL());\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlevels--;\n\t\t\t\t\t\t\t\tf = f.getParentFile();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (URISyntaxException e) {\n\t\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t\t} catch (MalformedURLException e) {\n\t\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n"} {"input": " protected static List> loadData(String filename) {\n ResourceDataReader resourceReader = new ResourceDataReader(\n String.format(\"/graphs/kosarajus_two_pass/%s\", filename));\n List> verticesToConnections = new ArrayList>();\n String line;\n while ((line = resourceReader.readLine()) != null) {\n List connections = new ArrayList(2); \n verticesToConnections.add(connections);\n String[] words = line.split(\"\\\\s+\");\n for (String word : words) {\n connections.add(Integer.parseInt(word.trim()));\n }\n }\n return verticesToConnections;\n }\n", "output": " protected static List> loadData(String filename) {\n try (ResourceDataReader resourceReader = new ResourceDataReader(\n String.format(\"/graphs/kosarajus_two_pass/%s\", filename))) {\n List> verticesToConnections = new ArrayList>();\n String line;\n while ((line = resourceReader.readLine()) != null) {\n List connections = new ArrayList(2); \n verticesToConnections.add(connections);\n String[] words = line.split(\"\\\\s+\");\n for (String word : words) {\n connections.add(Integer.parseInt(word.trim()));\n }\n }\n return verticesToConnections;\n }\n }\n"} {"input": "\tpublic InputStream getInputStream(URI uri) throws IOException {\n\t\tif(weakmap.containsKey(uri.toString())){\n\t\t\treturn new ByteArrayInputStream(weakmap.get(uri));\n\t\t}\n\t\ttry{\n\t\t\tBasicDBObject obj = new BasicDBObject();\n\t\t\tobj.put(ID, uri.toString());\n\t\t\tDBCursor c = col.find(obj);\n\t\t\tDBObject o = c.next();\n\t\t\tbyte[] v = (byte[])o.get(DATA);\n\t\t\tweakmap.put(uri.toString(), v);\n\t\t\treturn new ByteArrayInputStream(v);\n\t\t}catch(NoSuchElementException e){\n\t\t\treturn null;\n\t\t}\n\t}\n", "output": "\tpublic InputStream getInputStream(URI uri) throws IOException {\n\t\tbyte[] cache = weakmap.get(uri.toString());\n\t\tif(cache != null){\n\t\t\treturn new ByteArrayInputStream(cache);\n\t\t}\n\t\ttry{\n\t\t\tBasicDBObject obj = new BasicDBObject();\n\t\t\tobj.put(ID, uri.toString());\n\t\t\tDBCursor c = col.find(obj);\n\t\t\tDBObject o = c.next();\n\t\t\tbyte[] v = (byte[])o.get(DATA);\n\t\t\tweakmap.put(uri.toString(), v);\n\t\t\treturn new ByteArrayInputStream(v);\n\t\t}catch(NoSuchElementException e){\n\t\t\treturn null;\n\t\t}\n\t}\n"} {"input": "\tpublic void onExecutionFinish(TestModel aModel, SuiteSummaryResult aResult) {\n\t\tif (captureConsoleOutput) {\n\t\t\tconsoleInterceptor.stopIntercept();\n\t\t}\n\t\tstackPop().setAttribute(TEST_RUN_DURATION, nanoTimeToString(System.nanoTime() - executionStartTime));\n\t\tif (!isFork()) {\n\t\t\tlong tempStart = System.nanoTime();\n\t\t\tstripTemporaryAttributes(document.getRootElement());\n\t\t\tFileOutputStream tempOutputStream;\n\t\t\ttry {\n\t\t\t\ttempOutputStream = new FileOutputStream(outputFile);\n\t\t\t} catch (FileNotFoundException exc) {\n\t\t\t\texc.printStackTrace();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (transformHandling == TransformHandling.EXECUTE_TRANSFORM) {\n\t\t\t\t\tSystem.out.print(\"Transforming Integrity Result XML to HTML...\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (System.getProperty(\"javax.xml.transform.TransformerFactory\") == null) {\n\t\t\t\t\t\t\tSystem.setProperty(\"javax.xml.transform.TransformerFactory\",\n\t\t\t\t\t\t\t\t\t\"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTransformerFactory tempTransformerFactory = TransformerFactory.newInstance();\n\t\t\t\t\t\tTransformer tempTransformer = tempTransformerFactory.newTransformer(new StreamSource(\n\t\t\t\t\t\t\t\tgetXsltStream()));\n\t\t\t\t\t\ttempTransformer.setOutputProperty(OutputKeys.METHOD, \"html\");\n\t\t\t\t\t\ttempTransformer.setOutputProperty(OutputKeys.ENCODING, \"UTF-8\");\n\t\t\t\t\t\tSource tempSource = new JDOMSource(document);\n\t\t\t\t\t\tStreamResult tempResult = new StreamResult(new FilterOutputStream(tempOutputStream) {\n\t\t\t\t\t\t\tprivate final char[] triggerOpenTagName = new char[] { 'x', 'm', 'l', 'd', 'a', 't', 'a' };\n\t\t\t\t\t\t\tprivate final char[] triggerCloseTagName = new char[] { '/', 'x', 'm', 'l', 'd', 'a', 't',\n\t\t\t\t\t\t\t\t\t'a' };\n\t\t\t\t\t\t\tprivate static final char TRIGGER_TAG_START = '<';\n\t\t\t\t\t\t\tprivate static final char TRIGGER_TAG_END = '<';\n\t\t\t\t\t\t\tprivate static final char TRIGGER_ATTRIBUTE = '\"';\n\t\t\t\t\t\t\tprivate boolean insideXmlPart;\n\t\t\t\t\t\t\tprivate boolean insideAttribute;\n\t\t\t\t\t\t\tprivate boolean pastXmlPart;\n\t\t\t\t\t\t\tprivate int tagPosition;\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void write(int aByte) throws IOException {\n\t\t\t\t\t\t\t\tchar tempChar = (char) aByte;\n\t\t\t\t\t\t\t\tif (!pastXmlPart) {\n\t\t\t\t\t\t\t\t\tif (!insideAttribute) {\n\t\t\t\t\t\t\t\t\t\tif (tempChar == TRIGGER_TAG_START) {\n\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t} else if (tempChar == TRIGGER_TAG_END) {\n\t\t\t\t\t\t\t\t\t\t\ttagPosition = -1;\n\t\t\t\t\t\t\t\t\t\t} else if (tagPosition >= 0) {\n\t\t\t\t\t\t\t\t\t\t\tif (insideXmlPart && tempChar == TRIGGER_ATTRIBUTE) {\n\t\t\t\t\t\t\t\t\t\t\t\tinsideAttribute = true;\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\ttagPosition++;\n\t\t\t\t\t\t\t\t\t\t\t\tif (insideXmlPart) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (tagPosition < triggerCloseTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (tempChar != triggerCloseTagName[tagPosition]) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else if (tagPosition == triggerCloseTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinsideXmlPart = false;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpastXmlPart = true;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (tagPosition < triggerOpenTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (tempChar != triggerOpenTagName[tagPosition]) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else if (tagPosition == triggerOpenTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinsideXmlPart = true;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpastXmlPart = false;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tif (insideXmlPart) {\n\t\t\t\t\t\t\t\t\t\t\tif (tempChar == TRIGGER_ATTRIBUTE) {\n\t\t\t\t\t\t\t\t\t\t\t\tinsideAttribute = false;\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\tif (tempChar == '<') {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuper.write(\"<\".getBytes(\"UTF-8\"));\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (tempChar == '>') {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuper.write(\">\".getBytes(\"UTF-8\"));\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsuper.write(aByte);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void write(byte[] someBytes, int anOffset, int aLength) throws IOException {\n\t\t\t\t\t\t\t\tif (!pastXmlPart) {\n\t\t\t\t\t\t\t\t\tsuper.write(someBytes, anOffset, aLength);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tout.write(someBytes, anOffset, aLength);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttempTransformer.transform(tempSource, tempResult);\n\t\t\t\t\t} catch (TransformerConfigurationException exc) {\n\t\t\t\t\t\texc.printStackTrace();\n\t\t\t\t\t} catch (TransformerException exc) {\n\t\t\t\t\t\texc.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.print(\"Writing Result XML...\");\n\t\t\t\t\tXMLOutputter tempSerializer = new XMLOutputter(Format.getPrettyFormat());\n\t\t\t\t\ttempSerializer.output(document, tempOutputStream);\n\t\t\t\t}\n\t\t\t\tlong tempTime = System.nanoTime() - tempStart;\n\t\t\t\tSystem.out.println(\"done in \" + ((double) (tempTime / 1000000) / 1000.0) + \" seconds!\");\n\t\t\t} catch (IOException exc) {\n\t\t\t\texc.printStackTrace();\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\ttempOutputStream.close();\n\t\t\t\t} catch (IOException exc) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n", "output": "\tpublic void onExecutionFinish(TestModel aModel, SuiteSummaryResult aResult) {\n\t\tif (captureConsoleOutput) {\n\t\t\tconsoleInterceptor.stopIntercept();\n\t\t}\n\t\tstackPop().setAttribute(TEST_RUN_DURATION, nanoTimeToString(System.nanoTime() - executionStartTime));\n\t\tif (!isFork()) {\n\t\t\tlong tempStart = System.nanoTime();\n\t\t\tstripTemporaryAttributes(document.getRootElement());\n\t\t\tFileOutputStream tempOutputStream;\n\t\t\ttry {\n\t\t\t\ttempOutputStream = new FileOutputStream(outputFile);\n\t\t\t} catch (FileNotFoundException exc) {\n\t\t\t\texc.printStackTrace();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tif (transformHandling == TransformHandling.EXECUTE_TRANSFORM) {\n\t\t\t\t\tSystem.out.print(\"Transforming Integrity Result XML to HTML...\");\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (System.getProperty(\"javax.xml.transform.TransformerFactory\") == null) {\n\t\t\t\t\t\t\tSystem.setProperty(\"javax.xml.transform.TransformerFactory\",\n\t\t\t\t\t\t\t\t\t\"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl\");\n\t\t\t\t\t\t}\n\t\t\t\t\t\tTransformerFactory tempTransformerFactory = TransformerFactory.newInstance();\n\t\t\t\t\t\tTransformer tempTransformer = tempTransformerFactory.newTransformer(new StreamSource(\n\t\t\t\t\t\t\t\tgetXsltStream()));\n\t\t\t\t\t\ttempTransformer.setOutputProperty(OutputKeys.METHOD, \"html\");\n\t\t\t\t\t\ttempTransformer.setOutputProperty(OutputKeys.ENCODING, \"UTF-8\");\n\t\t\t\t\t\tSource tempSource = new JDOMSource(document);\n\t\t\t\t\t\tStreamResult tempResult = new StreamResult(new FilterOutputStream(tempOutputStream) {\n\t\t\t\t\t\t\tprivate final char[] triggerOpenTagName = new char[] { 'x', 'm', 'l', 'd', 'a', 't', 'a' };\n\t\t\t\t\t\t\tprivate final char[] triggerCloseTagName = new char[] { '/', 'x', 'm', 'l', 'd', 'a', 't',\n\t\t\t\t\t\t\t\t\t'a' };\n\t\t\t\t\t\t\tprivate static final char TRIGGER_TAG_START = '<';\n\t\t\t\t\t\t\tprivate static final char TRIGGER_TAG_END = '<';\n\t\t\t\t\t\t\tprivate static final char TRIGGER_ATTRIBUTE = '\"';\n\t\t\t\t\t\t\tprivate boolean insideXmlPart;\n\t\t\t\t\t\t\tprivate boolean insideAttribute;\n\t\t\t\t\t\t\tprivate boolean pastXmlPart;\n\t\t\t\t\t\t\tprivate int tagPosition;\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void write(int aByte) throws IOException {\n\t\t\t\t\t\t\t\tchar tempChar = (char) aByte;\n\t\t\t\t\t\t\t\tif (!pastXmlPart) {\n\t\t\t\t\t\t\t\t\tif (!insideAttribute) {\n\t\t\t\t\t\t\t\t\t\tif (tempChar == TRIGGER_TAG_START) {\n\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t} else if (tempChar == TRIGGER_TAG_END) {\n\t\t\t\t\t\t\t\t\t\t\ttagPosition = -1;\n\t\t\t\t\t\t\t\t\t\t} else if (tagPosition >= 0) {\n\t\t\t\t\t\t\t\t\t\t\tif (insideXmlPart && tempChar == TRIGGER_ATTRIBUTE) {\n\t\t\t\t\t\t\t\t\t\t\t\tinsideAttribute = true;\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\ttagPosition++;\n\t\t\t\t\t\t\t\t\t\t\t\tif (insideXmlPart) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (tagPosition < triggerCloseTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (tempChar != triggerCloseTagName[tagPosition]) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else if (tagPosition == triggerCloseTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinsideXmlPart = false;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpastXmlPart = true;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (tagPosition < triggerOpenTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (tempChar != triggerOpenTagName[tagPosition]) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t} else if (tagPosition == triggerOpenTagName.length - 1) {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tinsideXmlPart = true;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpastXmlPart = false;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttagPosition = 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tif (insideXmlPart) {\n\t\t\t\t\t\t\t\t\t\t\tif (tempChar == TRIGGER_ATTRIBUTE) {\n\t\t\t\t\t\t\t\t\t\t\t\tinsideAttribute = false;\n\t\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\t\tif (tempChar == '<') {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuper.write(\"<\".getBytes(\"UTF-8\"));\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (tempChar == '>') {\n\t\t\t\t\t\t\t\t\t\t\t\t\tsuper.write(\">\".getBytes(\"UTF-8\"));\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsuper.write(aByte);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tpublic void write(byte[] someBytes, int anOffset, int aLength) throws IOException {\n\t\t\t\t\t\t\t\tif (!pastXmlPart) {\n\t\t\t\t\t\t\t\t\tsuper.write(someBytes, anOffset, aLength);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tout.write(someBytes, anOffset, aLength);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\ttempTransformer.transform(tempSource, tempResult);\n\t\t\t\t\t} catch (TransformerConfigurationException exc) {\n\t\t\t\t\t\texc.printStackTrace();\n\t\t\t\t\t} catch (TransformerException exc) {\n\t\t\t\t\t\texc.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.print(\"Writing Result XML...\");\n\t\t\t\t\tXMLOutputter tempSerializer = new XMLOutputter(Format.getPrettyFormat());\n\t\t\t\t\ttempSerializer.output(document, tempOutputStream);\n\t\t\t\t}\n\t\t\t\tlong tempTime = System.nanoTime() - tempStart;\n\t\t\t\tSystem.out.println(\"done in \" + ((double) (tempTime / 1000000) / 1000.0) + \" seconds!\");\n\t\t\t} catch (IOException exc) {\n\t\t\t\texc.printStackTrace();\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\ttempOutputStream.close();\n\t\t\t\t} catch (IOException exc) {\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n"} {"input": " public static Set findUrls(final ClassLoader classLoader) throws IOException {\n if (classLoader == null || classLoader.getClass().getName().equals(\"sun.misc.Launcher$ExtClassLoader\")) {\n return Collections.emptySet();\n }\n final Set urls;\n if (URLClassLoader.class.isInstance(classLoader) && !DONT_USE_GET_URLS) {\n urls = new HashSet();\n if (!isSurefire(classLoader)) {\n urls.addAll(Arrays.asList(URLClassLoader.class.cast(classLoader).getURLs()));\n urls.addAll(findUrls(classLoader.getParent()));\n } else { \n urls.addAll(fromClassPath());\n }\n } else {\n urls = findUrlFromResources(classLoader);\n }\n return urls;\n }\n", "output": " public static Set findUrls(final ClassLoader classLoader) throws IOException {\n if (classLoader == null || (SYSTEM.getParent() != null && classLoader == SYSTEM.getParent())) {\n return Collections.emptySet();\n }\n final Set urls;\n if (URLClassLoader.class.isInstance(classLoader) && !DONT_USE_GET_URLS) {\n urls = new HashSet();\n if (!isSurefire(classLoader)) {\n urls.addAll(Arrays.asList(URLClassLoader.class.cast(classLoader).getURLs()));\n urls.addAll(findUrls(classLoader.getParent()));\n } else { \n urls.addAll(fromClassPath());\n }\n } else {\n urls = findUrlFromResources(classLoader);\n }\n return urls;\n }\n"} {"input": " protected WhatToDo handleRead( ByteBuffer buf , Connection conn ){\n if ( _state == State.WAITING || _state == State.IN_HEADER ){\n if ( _line == null )\n _line = new StringBuilder();\n while ( buf.hasRemaining() ){\n char c = (char)buf.get();\n if ( c == '\\r' )\n continue;\n if ( c == '\\n' ){\n if ( _line.length() == 0 ){\n _logger.debug( 3 , \"end of header\" );\n _state = State.READY_TO_STREAM;\n break;\n }\n String line = _line.toString(); \n if ( _state == State.WAITING ){\n int idx = line.indexOf( \" \" );\n if ( idx < 0 ){\n backendError( ServerErrorType.INVALID , \"invalid first line [\" + line + \"]\" );\n return WhatToDo.ERROR;\n }\n line = line.substring( idx + 1 ).trim();\n idx = line.indexOf( \" \" );\n if ( idx < 0 )\n _response.setResponseCode( Integer.parseInt( line ) );\n else\n _response.setStatus( Integer.parseInt( line.substring( 0 , idx ) ) , line.substring( idx + 1 ).trim() );\n _logger.debug( 3 , \"got first line \" , line );\n _state = State.IN_HEADER;\n }\n else {\n int idx = line.indexOf( \":\" );\n if ( idx < 0 ){\n backendError( ServerErrorType.INVALID , \"invalid line [ \" + line + \"]\" );\n return WhatToDo.ERROR;\n }\n String name = line.substring( 0 , idx );\n String value = line.substring( idx + 1 ).trim();\n _logger.debug( 3 , \"got header line \" , line );\n if ( name.equalsIgnoreCase( \"Connection\" ) ){\n _keepalive = ! value.toLowerCase().contains( \"close\" );\n }\n else {\n _response.setHeader( name , value );\n }\n }\n _line.setLength( 0 );\n continue;\n }\n _line.append( c );\n }\n if ( _state != State.READY_TO_STREAM )\n return WhatToDo.CONTINUE;\n _logger.debug( 3 , \"starting to stream data\" );\n }\n if ( _state == State.READY_TO_STREAM ){\n MyChunk chunk = new MyChunk( this , conn , _response.getContentLength() , buf );\n _response.sendFile( new MySender( chunk ) );\n _state = State.STREAMING;\n }\n try {\n _response.done();\n }\n catch ( IOException ioe ){\n _logger.debug( 2 , \"client error\" , ioe );\n return WhatToDo.ERROR;\n }\n return WhatToDo.PAUSE;\n }\n", "output": " protected WhatToDo handleRead( ByteBuffer buf , Connection conn ){\n if ( _state == State.WAITING || _state == State.IN_HEADER ){\n if ( _line == null )\n _line = new StringBuilder();\n while ( buf.hasRemaining() ){\n char c = (char)buf.get();\n if ( c == '\\r' )\n continue;\n if ( c == '\\n' ){\n if ( _line.length() == 0 ){\n _logger.debug( 3 , \"end of header\" );\n _state = State.READY_TO_STREAM;\n break;\n }\n String line = _line.toString(); \n if ( _state == State.WAITING ){\n int idx = line.indexOf( \" \" );\n if ( idx < 0 ){\n backendError( ServerErrorType.INVALID , \"invalid first line [\" + line + \"]\" );\n return WhatToDo.ERROR;\n }\n line = line.substring( idx + 1 ).trim();\n idx = line.indexOf( \" \" );\n if ( idx < 0 )\n _response.setResponseCode( Integer.parseInt( line ) );\n else\n _response.setStatus( Integer.parseInt( line.substring( 0 , idx ) ) , line.substring( idx + 1 ).trim() );\n _logger.debug( 3 , \"got first line \" , line );\n _state = State.IN_HEADER;\n }\n else {\n int idx = line.indexOf( \":\" );\n if ( idx < 0 ){\n backendError( ServerErrorType.INVALID , \"invalid line [ \" + line + \"]\" );\n return WhatToDo.ERROR;\n }\n String name = line.substring( 0 , idx );\n String value = line.substring( idx + 1 ).trim();\n _logger.debug( 3 , \"got header line \" , line );\n if ( name.equalsIgnoreCase( \"Connection\" ) ){\n _keepalive = ! value.toLowerCase().contains( \"close\" );\n }\n else {\n _response.addHeader( name , value );\n }\n }\n _line.setLength( 0 );\n continue;\n }\n _line.append( c );\n }\n if ( _state != State.READY_TO_STREAM )\n return WhatToDo.CONTINUE;\n _logger.debug( 3 , \"starting to stream data\" );\n }\n if ( _state == State.READY_TO_STREAM ){\n MyChunk chunk = new MyChunk( this , conn , _response.getContentLength() , buf );\n _response.sendFile( new MySender( chunk ) );\n _state = State.STREAMING;\n }\n try {\n _response.done();\n }\n catch ( IOException ioe ){\n _logger.debug( 2 , \"client error\" , ioe );\n return WhatToDo.ERROR;\n }\n return WhatToDo.PAUSE;\n }\n"} {"input": "\tpublic void run() {\n\t\tShell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();\n\t\ttry {\n\t\t\tif (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors(true)) {\n\t\t\t\tConstructor constructor = refactoringClass.getConstructors()[0];\n\t\t\t\tObject[] args;\n\t\t\t\tif(constructor.getParameterTypes().length == 1) {\n\t\t\t\t\targs = new Object[] {selectionProvider};\n\t\t\t\t} else {\n\t\t\t\t\targs = new Object[0];\n\t\t\t\t}\n\t\t\t\tRubyRefactoring refactoring = constructor.newInstance(args);\n\t\t\t\tRubyRefactoringWizard wizard = new RubyRefactoringWizard(refactoring);\n\t\t\t\twizard.setWindowTitle(refactoring.getName());\n\t\t\t\tRefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);\n\t\t\t\top.run(shell, refactoring.getName());\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tRubyPlugin.log(e);\n\t\t}\n\t}\n", "output": "\tpublic void run() {\n\t\tShell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();\n\t\ttry {\n\t\t\tif (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors(true)) {\n\t\t\t\tConstructor constructor = (Constructor) refactoringClass.getConstructors()[0];\n\t\t\t\tObject[] args;\n\t\t\t\tif(constructor.getParameterTypes().length == 1) {\n\t\t\t\t\targs = new Object[] {selectionProvider};\n\t\t\t\t} else {\n\t\t\t\t\targs = new Object[0];\n\t\t\t\t}\n\t\t\t\tRubyRefactoring refactoring = constructor.newInstance(args);\n\t\t\t\tRubyRefactoringWizard wizard = new RubyRefactoringWizard(refactoring);\n\t\t\t\twizard.setWindowTitle(refactoring.getName());\n\t\t\t\tRefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);\n\t\t\t\top.run(shell, refactoring.getName());\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tRubyPlugin.log(e);\n\t\t}\n\t}\n"} {"input": " public RunInstancesResponseVCloud runInstances(RunInstancesRequestVCloud vCloudRequest) {\n String vAppTemplateId = vCloudRequest.getvAppTemplateId();\n log.info(\"RunInstances vAppTemplateId: \" + vAppTemplateId);\n VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateId);\n if (vAppTemplate == null) {\n throw new EC2ServiceException(\"VAppTemplate not found for: \" + vAppTemplateId);\n }\n Vdc vdc = getVDC();\n Set availableNetworkRefs = vdc.getAvailableNetworks();\n if (availableNetworkRefs.isEmpty()) {\n throw new EC2ServiceException(\"No Networks in vdc to compose vapp\");\n }\n String vcdNetwork = env.getProperty(CinderellaConfig.VCD_NETWORK_KEY);\n final Reference parentNetwork = FluentIterable.from(vdc.getAvailableNetworks())\n .filter(ReferencePredicates.nameEquals(vcdNetwork))\n .first()\n .get();\n NetworkConfigSection templateNetworkConfigSection = vAppTemplateApi.getNetworkConfigSection(vAppTemplateId);\n Set vAppNetworkConfigurations = new HashSet();\n for (VAppNetworkConfiguration templateVAppNetworkConfig : templateNetworkConfigSection.getNetworkConfigs()) {\n vAppNetworkConfigurations.add(\n VAppNetworkConfiguration.builder()\n .networkName(templateVAppNetworkConfig.getNetworkName())\n .configuration(\n NetworkConfiguration.builder()\n .parentNetwork(parentNetwork)\n .fenceMode(Network.FenceMode.BRIDGED)\n .build()\n )\n .isDeployed(true)\n .build()\n );\n }\n NetworkConfigSection networkConfigSection = NetworkConfigSection\n .builder()\n .info(\"Configuration parameters for logical networks\")\n .networkConfigs(ImmutableSet.copyOf(vAppNetworkConfigurations))\n .build();\n InstantiationParams instantiationParams = InstantiationParams.builder()\n .sections(ImmutableSet.of(networkConfigSection))\n .build();\n InstantiateVAppTemplateParams instantiateVAppTemplateParams = InstantiateVAppTemplateParams.builder()\n .name(name(\"cinderella-\" + vCloudDirectorApi.getCurrentSession().getUser()))\n .deploy()\n .notDeploy()\n .notPowerOn()\n .description(\"Created by Cinderella\")\n .instantiationParams(instantiationParams)\n .source(vAppTemplate.getHref())\n .build();\n String vdcUrn = vdc.getId();\n VApp instantiatedVApp = vdcApi.instantiateVApp(vdcUrn, instantiateVAppTemplateParams);\n Task instantiationTask = Iterables.getFirst(instantiatedVApp.getTasks(), null);\n boolean instantiationSuccess = retryTaskSuccessLong.apply(instantiationTask);\n if (instantiationSuccess) {\n log.info(\"successfully instantiated vApp\");\n VApp vapp = vAppApi.get(instantiatedVApp.getHref());\n List vms = vapp.getChildren().getVms();\n for (Vm vm : vms) {\n NetworkConnectionSection oldSection = vmApi.getNetworkConnectionSection(vm.getHref());\n NetworkConnectionSection newNetworkConnectionSection = oldSection.toBuilder()\n .primaryNetworkConnectionIndex(0)\n .networkConnections(ImmutableSet.of(NetworkConnection.builder()\n .network(parentNetwork.getName())\n .networkConnectionIndex(0)\n .ipAddressAllocationMode(NetworkConnection.IpAddressAllocationMode.POOL)\n .isConnected(true)\n .build()))\n .build();\n Task editNetworkConnectionSectionTask = vmApi.editNetworkConnectionSection(vm.getHref(), newNetworkConnectionSection);\n boolean updateVmNetworkSuccess = retryTaskSuccessLong.apply(editNetworkConnectionSectionTask);\n if (updateVmNetworkSuccess) {\n log.info(\"successfully updated \" + vm.getId() + \" network config\");\n }\n }\n Task powerOnTask = vAppApi.powerOn(instantiatedVApp.getHref());\n boolean powerOnSuccess = retryTaskSuccessLong.apply(powerOnTask);\n if (powerOnSuccess) {\n log.info(\"successfully powered on vApp\");\n }\n }\n VApp vapp = vAppApi.get(instantiatedVApp.getHref());\n Set ips = VCloudDirectorComputeUtils.getIpsFromVm(vapp.getChildren().getVms().get(0));\n String publicIpAddress = null;\n for (String ip : ips) {\n if (!InetAddresses2.isPrivateIPAddress(ip)) {\n publicIpAddress = ip;\n }\n }\n log.info(\"public ip: \" + publicIpAddress);\n instantiatedVApp = vAppApi.get(instantiatedVApp.getId());\n if (instantiationSuccess && (null != vCloudRequest.getKeyName() && vCloudRequest.getKeyName().length() > 0)) {\n Vm vm = Iterables.getFirst(instantiatedVApp.getChildren().getVms(), null);\n LoginCredentials creds = LoginCredentials.builder(VCloudDirectorComputeUtils.getCredentialsFrom(vm))\n .identity(\"root\")\n .build();\n NetworkConnectionSection nets = vmApi.getNetworkConnectionSection(vm.getId());\n String ipaddress = null;\n for (NetworkConnection net : nets.getNetworkConnections()) {\n ipaddress = net.getIpAddress();\n }\n System.out.println(\"Credentials: \" + creds.getUser() + \" : \" + creds.getPassword() + \" : \" + creds.getOptionalPrivateKey().or(\"NONE\"));\n Media keyPairsContainer = null;\n Optional optionalKeyPairsContainer = null;\n optionalKeyPairsContainer = FluentIterable\n .from(findAllEmptyMediaInOrg().toImmutableList())\n .first();\n if (optionalKeyPairsContainer.isPresent()) {\n String key = null;\n keyPairsContainer = optionalKeyPairsContainer.get();\n vCloudRequest.getKeyName();\n Map sshKey;\n for (MetadataEntry entry : mediaApi.getMetadataApi(keyPairsContainer.getId()).get().getMetadataEntries()) {\n sshKey = json.fromJson(entry.getValue(), new TypeToken>() {\n }.getType());\n if (vCloudRequest.getKeyName().equalsIgnoreCase(sshKey.get(\"keyName\"))) {\n key = sshKey.get(\"publicKey\");\n }\n }\n SshClient client = new SshjSshClient(BackoffLimitedRetryHandler.INSTANCE, HostAndPort.fromParts(ipaddress, 22), creds, 30000);\n ImmutableList.Builder keys= ImmutableList.builder();\n keys.add(key);\n AuthorizeRSAPublicKeys authrsa = new AuthorizeRSAPublicKeys(keys.build());\n client.connect();\n ExecResponse sshresponse = client.exec(authrsa.render(OsFamily.UNIX));\n if (sshresponse.getExitStatus() != 0) {\n log.error(sshresponse.getError());\n }\n client.disconnect();\n }\n }\n RunInstancesResponseVCloud response = new RunInstancesResponseVCloud();\n response.setVmId(vapp.getChildren().getVms().get(0).getId());\n return response;\n }\n", "output": " public RunInstancesResponseVCloud runInstances(RunInstancesRequestVCloud vCloudRequest) {\n String vAppTemplateId = vCloudRequest.getvAppTemplateId();\n log.info(\"RunInstances vAppTemplateId: \" + vAppTemplateId);\n VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateId);\n if (vAppTemplate == null) {\n throw new EC2ServiceException(\"VAppTemplate not found for: \" + vAppTemplateId);\n }\n Vdc vdc = getVDC();\n Set availableNetworkRefs = vdc.getAvailableNetworks();\n if (availableNetworkRefs.isEmpty()) {\n throw new EC2ServiceException(\"No Networks in vdc to compose vapp\");\n }\n String vcdNetwork = env.getProperty(CinderellaConfig.VCD_NETWORK_KEY);\n final Reference parentNetwork = FluentIterable.from(vdc.getAvailableNetworks())\n .filter(ReferencePredicates.nameEquals(vcdNetwork))\n .first()\n .get();\n NetworkConfigSection templateNetworkConfigSection = vAppTemplateApi.getNetworkConfigSection(vAppTemplateId);\n Set vAppNetworkConfigurations = new HashSet();\n for (VAppNetworkConfiguration templateVAppNetworkConfig : templateNetworkConfigSection.getNetworkConfigs()) {\n vAppNetworkConfigurations.add(\n VAppNetworkConfiguration.builder()\n .networkName(templateVAppNetworkConfig.getNetworkName())\n .configuration(\n NetworkConfiguration.builder()\n .parentNetwork(parentNetwork)\n .fenceMode(Network.FenceMode.BRIDGED)\n .build()\n )\n .isDeployed(true)\n .build()\n );\n }\n NetworkConfigSection networkConfigSection = NetworkConfigSection\n .builder()\n .info(\"Configuration parameters for logical networks\")\n .networkConfigs(ImmutableSet.copyOf(vAppNetworkConfigurations))\n .build();\n InstantiationParams instantiationParams = InstantiationParams.builder()\n .sections(ImmutableSet.of(networkConfigSection))\n .build();\n InstantiateVAppTemplateParams instantiateVAppTemplateParams = InstantiateVAppTemplateParams.builder()\n .name(name(\"cinderella-\" + vCloudDirectorApi.getCurrentSession().getUser()))\n .notDeploy()\n .notPowerOn()\n .description(\"Created by Cinderella\")\n .instantiationParams(instantiationParams)\n .source(vAppTemplate.getHref())\n .build();\n String vdcUrn = vdc.getId();\n VApp instantiatedVApp = vdcApi.instantiateVApp(vdcUrn, instantiateVAppTemplateParams);\n Task instantiationTask = Iterables.getFirst(instantiatedVApp.getTasks(), null);\n boolean instantiationSuccess = retryTaskSuccessLong.apply(instantiationTask);\n if (instantiationSuccess) {\n log.info(\"successfully instantiated vApp\");\n VApp vapp = vAppApi.get(instantiatedVApp.getHref());\n List vms = vapp.getChildren().getVms();\n for (Vm vm : vms) {\n NetworkConnectionSection oldSection = vmApi.getNetworkConnectionSection(vm.getHref());\n NetworkConnectionSection newNetworkConnectionSection = oldSection.toBuilder()\n .primaryNetworkConnectionIndex(0)\n .networkConnections(ImmutableSet.of(NetworkConnection.builder()\n .network(parentNetwork.getName())\n .networkConnectionIndex(0)\n .ipAddressAllocationMode(NetworkConnection.IpAddressAllocationMode.POOL)\n .isConnected(true)\n .build()))\n .build();\n Task editNetworkConnectionSectionTask = vmApi.editNetworkConnectionSection(vm.getHref(), newNetworkConnectionSection);\n boolean updateVmNetworkSuccess = retryTaskSuccessLong.apply(editNetworkConnectionSectionTask);\n if (updateVmNetworkSuccess) {\n log.info(\"successfully updated \" + vm.getId() + \" network config\");\n }\n }\n Task powerOnTask = vAppApi.powerOn(instantiatedVApp.getHref());\n boolean powerOnSuccess = retryTaskSuccessLong.apply(powerOnTask);\n if (powerOnSuccess) {\n log.info(\"successfully powered on vApp\");\n }\n }\n VApp vapp = vAppApi.get(instantiatedVApp.getHref());\n Set ips = VCloudDirectorComputeUtils.getIpsFromVm(vapp.getChildren().getVms().get(0));\n String publicIpAddress = null;\n for (String ip : ips) {\n if (!InetAddresses2.isPrivateIPAddress(ip)) {\n publicIpAddress = ip;\n }\n }\n log.info(\"public ip: \" + publicIpAddress);\n instantiatedVApp = vAppApi.get(instantiatedVApp.getId());\n if (instantiationSuccess && (null != vCloudRequest.getKeyName() && vCloudRequest.getKeyName().length() > 0)) {\n Vm vm = Iterables.getFirst(instantiatedVApp.getChildren().getVms(), null);\n LoginCredentials creds = LoginCredentials.builder(VCloudDirectorComputeUtils.getCredentialsFrom(vm))\n .identity(\"root\")\n .build();\n NetworkConnectionSection nets = vmApi.getNetworkConnectionSection(vm.getId());\n String ipaddress = null;\n for (NetworkConnection net : nets.getNetworkConnections()) {\n ipaddress = net.getIpAddress();\n }\n System.out.println(\"Credentials: \" + creds.getUser() + \" : \" + creds.getPassword() + \" : \" + creds.getOptionalPrivateKey().or(\"NONE\"));\n Media keyPairsContainer = null;\n Optional optionalKeyPairsContainer = null;\n optionalKeyPairsContainer = FluentIterable\n .from(findAllEmptyMediaInOrg().toImmutableList())\n .first();\n if (optionalKeyPairsContainer.isPresent()) {\n String key = null;\n keyPairsContainer = optionalKeyPairsContainer.get();\n vCloudRequest.getKeyName();\n Map sshKey;\n for (MetadataEntry entry : mediaApi.getMetadataApi(keyPairsContainer.getId()).get().getMetadataEntries()) {\n sshKey = json.fromJson(entry.getValue(), new TypeToken>() {\n }.getType());\n if (vCloudRequest.getKeyName().equalsIgnoreCase(sshKey.get(\"keyName\"))) {\n key = sshKey.get(\"publicKey\");\n }\n }\n SshClient client = new SshjSshClient(BackoffLimitedRetryHandler.INSTANCE, HostAndPort.fromParts(ipaddress, 22), creds, 30000);\n ImmutableList.Builder keys= ImmutableList.builder();\n keys.add(key);\n AuthorizeRSAPublicKeys authrsa = new AuthorizeRSAPublicKeys(keys.build());\n client.connect();\n ExecResponse sshresponse = client.exec(authrsa.render(OsFamily.UNIX));\n if (sshresponse.getExitStatus() != 0) {\n log.error(sshresponse.getError());\n }\n client.disconnect();\n }\n }\n RunInstancesResponseVCloud response = new RunInstancesResponseVCloud();\n response.setVmId(vapp.getChildren().getVms().get(0).getId());\n return response;\n }\n"} {"input": " public Response createPerson(@FormParam(\"is_group\") final String isGroup,\n @FormParam(\"nick_name\") final String nickName,\n @FormParam(\"first_name\") final String firstName,\n @FormParam(\"last_name\") final String lastName,\n @FormParam(\"email\") final String email,\n @FormParam(\"notification_type\") final String notificationType)\n {\n final int personId;\n if (isGroup == null) {\n personId = client.createPerson(firstName, lastName, nickName);\n }\n else {\n personId = client.createGroup(nickName);\n }\n if (notificationType.equals(\"REGULAR_EMAIL\")) {\n final int emailNotificationId = client.createEmailNotificationForPersonOrGroup(personId, email);\n log.info(\"Created person %s (id=%d) with email notification %s (id=%d)\", nickName, personId, email, emailNotificationId);\n }\n else {\n final int smsNotificationId = client.createSmsNotificationForPersonOrGroup(personId, email);\n log.info(\"Created person %s (id=%d) with sms notification %s (id=%d)\", nickName, personId, email, smsNotificationId);\n }\n return Response.seeOther(URI.create(\"/people.jsp\")).entity(\"built yes\").build();\n }\n", "output": " public Response createPerson(@FormParam(\"is_group\") final String isGroup,\n @FormParam(\"nick_name\") final String nickName,\n @FormParam(\"first_name\") final String firstName,\n @FormParam(\"last_name\") final String lastName,\n @FormParam(\"email\") final String email,\n @FormParam(\"notification_type\") final String notificationType)\n {\n final int personId;\n if (isGroup == null) {\n personId = client.createPerson(firstName, lastName, nickName);\n }\n else {\n personId = client.createGroup(nickName);\n }\n if (notificationType.equals(\"REGULAR_EMAIL\")) {\n final int emailNotificationId = client.createEmailNotificationForPersonOrGroup(personId, email);\n log.info(\"Created person %s (id=%d) with email notification %s (id=%d)\", nickName, personId, email, emailNotificationId);\n }\n else {\n final int smsNotificationId = client.createSmsNotificationForPersonOrGroup(personId, email);\n log.info(\"Created person %s (id=%d) with sms notification %s (id=%d)\", nickName, personId, email, smsNotificationId);\n }\n return Response.seeOther(URI.create(\"/ui/people\")).build();\n }\n"} {"input": " public static IRubyObject select_static(IRuby runtime, IRubyObject[] args) {\n try {\n \tboolean atLeastOneDescriptor = false;\n Selector selector = Selector.open();\n if (!args[0].isNil()) {\n \tatLeastOneDescriptor = true;\n for (Iterator i = ((RubyArray) args[0]).getList().iterator(); i.hasNext(); ) {\n IRubyObject obj = (IRubyObject) i.next();\n registerSelect(selector, obj, SelectionKey.OP_READ|SelectionKey.OP_ACCEPT);\n }\n }\n if (args.length > 1 && !args[1].isNil()) {\n \tatLeastOneDescriptor = true;\n for (Iterator i = ((RubyArray) args[0]).getList().iterator(); i.hasNext(); ) {\n IRubyObject obj = (IRubyObject) i.next();\n registerSelect(selector, obj, SelectionKey.OP_WRITE);\n }\n }\n if (args.length > 2 && !args[2].isNil()) {\n \tatLeastOneDescriptor = true;\n }\n long timeout = 0;\n if(args.length > 3 && !args[3].isNil()) {\n if (args[3] instanceof RubyFloat) {\n timeout = Math.round(((RubyFloat) args[3]).getDoubleValue() * 1000);\n } else {\n timeout = Math.round(((RubyFixnum) args[3]).getDoubleValue() * 1000);\n }\n if (timeout < 0) {\n \tthrow runtime.newArgumentError(\"negative timeout given\");\n }\n }\n if (!atLeastOneDescriptor) {\n \treturn runtime.getNil();\n }\n if(args.length > 3) {\n selector.select(timeout);\n } else {\n selector.select();\n }\n List r = new ArrayList();\n List w = new ArrayList();\n List e = new ArrayList();\n for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) {\n SelectionKey key = (SelectionKey) i.next();\n if ((key.interestOps() & key.readyOps()\n & (SelectionKey.OP_READ|SelectionKey.OP_ACCEPT|SelectionKey.OP_CONNECT)) != 0) {\n r.add(key.attachment());\n }\n if ((key.interestOps() & key.readyOps() & (SelectionKey.OP_WRITE)) != 0) {\n w.add(key.attachment());\n }\n }\n for (Iterator i = selector.keys().iterator(); i.hasNext(); ) {\n SelectionKey key = (SelectionKey) i.next();\n SelectableChannel channel = key.channel();\n synchronized(channel.blockingLock()) {\n boolean blocking = ((RubyIO) key.attachment()).getBlocking();\n key.cancel();\n channel.configureBlocking(blocking);\n }\n }\n selector.close();\n if (r.size() == 0 && w.size() == 0 && e.size() == 0) {\n return runtime.getNil();\n }\n List ret = new ArrayList();\n ret.add(RubyArray.newArray(runtime, r));\n ret.add(RubyArray.newArray(runtime, w));\n ret.add(RubyArray.newArray(runtime, e));\n return RubyArray.newArray(runtime, ret);\n } catch(IOException e) {\n throw runtime.newIOError(e.getMessage());\n }\n }\n", "output": " public static IRubyObject select_static(IRuby runtime, IRubyObject[] args) {\n try {\n \tboolean atLeastOneDescriptor = false;\n Selector selector = Selector.open();\n if (!args[0].isNil()) {\n \tatLeastOneDescriptor = true;\n for (Iterator i = ((RubyArray) args[0]).getList().iterator(); i.hasNext(); ) {\n IRubyObject obj = (IRubyObject) i.next();\n registerSelect(selector, obj, SelectionKey.OP_READ|SelectionKey.OP_ACCEPT);\n }\n }\n if (args.length > 1 && !args[1].isNil()) {\n \tatLeastOneDescriptor = true;\n for (Iterator i = ((RubyArray) args[1]).getList().iterator(); i.hasNext(); ) {\n IRubyObject obj = (IRubyObject) i.next();\n registerSelect(selector, obj, SelectionKey.OP_WRITE);\n }\n }\n if (args.length > 2 && !args[2].isNil()) {\n \tatLeastOneDescriptor = true;\n }\n long timeout = 0;\n if(args.length > 3 && !args[3].isNil()) {\n if (args[3] instanceof RubyFloat) {\n timeout = Math.round(((RubyFloat) args[3]).getDoubleValue() * 1000);\n } else {\n timeout = Math.round(((RubyFixnum) args[3]).getDoubleValue() * 1000);\n }\n if (timeout < 0) {\n \tthrow runtime.newArgumentError(\"negative timeout given\");\n }\n }\n if (!atLeastOneDescriptor) {\n \treturn runtime.getNil();\n }\n if(args.length > 3) {\n selector.select(timeout);\n } else {\n selector.select();\n }\n List r = new ArrayList();\n List w = new ArrayList();\n List e = new ArrayList();\n for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) {\n SelectionKey key = (SelectionKey) i.next();\n if ((key.interestOps() & key.readyOps()\n & (SelectionKey.OP_READ|SelectionKey.OP_ACCEPT|SelectionKey.OP_CONNECT)) != 0) {\n r.add(key.attachment());\n }\n if ((key.interestOps() & key.readyOps() & (SelectionKey.OP_WRITE)) != 0) {\n w.add(key.attachment());\n }\n }\n for (Iterator i = selector.keys().iterator(); i.hasNext(); ) {\n SelectionKey key = (SelectionKey) i.next();\n SelectableChannel channel = key.channel();\n synchronized(channel.blockingLock()) {\n boolean blocking = ((RubyIO) key.attachment()).getBlocking();\n key.cancel();\n channel.configureBlocking(blocking);\n }\n }\n selector.close();\n if (r.size() == 0 && w.size() == 0 && e.size() == 0) {\n return runtime.getNil();\n }\n List ret = new ArrayList();\n ret.add(RubyArray.newArray(runtime, r));\n ret.add(RubyArray.newArray(runtime, w));\n ret.add(RubyArray.newArray(runtime, e));\n return RubyArray.newArray(runtime, ret);\n } catch(IOException e) {\n throw runtime.newIOError(e.getMessage());\n }\n }\n"} {"input": " protected void onActivityResult (int requestCode, int resultCode, Intent data){\n\t \tif(resultCode != RESULT_OK) return;\n\t \tswitch(requestCode){\n\t \t\tcase REQUEST_ADD_WORD :\n\t\t \t\tsaveNewWord(\t\n\t\t \t\t\t\tdata.getStringExtra(AddWordActivity.EXTRA_QUESTION),\n\t\t \t\t\t\tdata.getStringExtra(AddWordActivity.EXTRA_QUESTION)\n\t\t \t\t\t\t);\n\t \t\tbreak;\n\t\t \tcase REQUEST_EDIT_WORD :\n\t\t \t\tsaveEditedWord(\n\t\t \t\t\t\tdata.getLongExtra(EditWordActivity.EXTRA_WORD_ID, -1),\n\t\t \t\t\t\tdata.getStringExtra(EditWordActivity.EXTRA_QUESTION),\n\t\t \t\t\t\tdata.getStringExtra(EditWordActivity.EXTRA_QUESTION)\n\t \t\t\t\t);\n\t \t\tbreak;\n\t\t \tcase REQUEST_VIEW :\n\t\t \t\t\tint action = data.getIntExtra(ViewWordActivity.ACTION, -1);\n\t\t \t\t\tlong wordId = data.getLongExtra(EditWordActivity.EXTRA_WORD_ID, -1);\n\t\t \t\t\tswitch(action){\n\t\t \t\t\t\tcase ViewWordActivity.EVENT_EDIT :\n\t\t \t\t\t\t\tonEditWordClicked(wordId);\n\t\t \t\t\t\tbreak;\n\t\t \t\t\t\tcase ViewWordActivity.EVENT_DELETE :\n\t\t \t\t\t\t\tonDeleteClicked(wordId);\n\t\t \t\t\t\tbreak;\n\t\t \t\t\t}\n\t \t\tbreak;\n\t \t\tdefault : \n\t \t\t\tthrow new Error(\"Unknown activity requestCode: \" + requestCode);\n\t \t}\n super.onActivityResult(requestCode, resultCode, data);\n }\n", "output": " protected void onActivityResult (int requestCode, int resultCode, Intent data){\n\t \tif(resultCode != RESULT_OK) return;\n\t \tswitch(requestCode){\n\t \t\tcase REQUEST_ADD_WORD :\n\t\t \t\tsaveNewWord(\t\n\t\t \t\t\t\tdata.getStringExtra(AddWordActivity.EXTRA_QUESTION),\n\t\t \t\t\t\tdata.getStringExtra(AddWordActivity.EXTRA_ANSWER)\n\t\t \t\t\t\t);\n\t \t\tbreak;\n\t\t \tcase REQUEST_EDIT_WORD :\n\t\t \t\tsaveEditedWord(\n\t\t \t\t\t\tdata.getLongExtra(EditWordActivity.EXTRA_WORD_ID, -1),\n\t\t \t\t\t\tdata.getStringExtra(EditWordActivity.EXTRA_QUESTION),\n\t\t \t\t\t\tdata.getStringExtra(EditWordActivity.EXTRA_ANSWER)\n\t \t\t\t\t);\n\t \t\tbreak;\n\t\t \tcase REQUEST_VIEW :\n\t\t \t\t\tint action = data.getIntExtra(ViewWordActivity.ACTION, -1);\n\t\t \t\t\tlong wordId = data.getLongExtra(EditWordActivity.EXTRA_WORD_ID, -1);\n\t\t \t\t\tswitch(action){\n\t\t \t\t\t\tcase ViewWordActivity.EVENT_EDIT :\n\t\t \t\t\t\t\tonEditWordClicked(wordId);\n\t\t \t\t\t\tbreak;\n\t\t \t\t\t\tcase ViewWordActivity.EVENT_DELETE :\n\t\t \t\t\t\t\tonDeleteClicked(wordId);\n\t\t \t\t\t\tbreak;\n\t\t \t\t\t}\n\t \t\tbreak;\n\t \t\tdefault : \n\t \t\t\tthrow new Error(\"Unknown activity requestCode: \" + requestCode);\n\t \t}\n super.onActivityResult(requestCode, resultCode, data);\n }\n"} {"input": " public static String fixPath(String path) throws WebdavException {\n if (path == null) {\n return null;\n }\n String decoded;\n try {\n decoded = URLDecoder.decode(path, \"UTF8\");\n } catch (Throwable t) {\n throw new WebdavException(t);\n }\n if (decoded == null) {\n return (null);\n }\n if (decoded.indexOf('\\\\') >= 0) {\n decoded = decoded.replace('\\\\', '/');\n }\n if (!decoded.startsWith(\"/\")) {\n decoded = \"/\" + decoded;\n }\n while (decoded.indexOf(\"//\") >= 0) {\n decoded = decoded.replaceAll(\"//\", \"/\");\n }\n if (decoded.indexOf(\"/.\") < 0) {\n return decoded;\n }\n StringTokenizer st = new StringTokenizer(decoded, \"/\");\n ArrayList al = new ArrayList();\n while (st.hasMoreTokens()) {\n String s = st.nextToken();\n if (s.equals(\".\")) {\n } else if (s.equals(\"..\")) {\n if (al.size() == 0) {\n return null;\n }\n al.remove(al.size() - 1);\n } else {\n al.add(s);\n }\n }\n StringBuffer sb = new StringBuffer();\n for (String s: al) {\n sb.append('/');\n sb.append(s);\n }\n return sb.toString();\n }\n", "output": " public static String fixPath(String path) throws WebdavException {\n if (path == null) {\n return null;\n }\n String decoded;\n try {\n decoded = URLDecoder.decode(path, \"UTF8\");\n } catch (Throwable t) {\n throw new WebdavBadRequest(\"bad path: \" + path);\n }\n if (decoded == null) {\n return (null);\n }\n if (decoded.indexOf('\\\\') >= 0) {\n decoded = decoded.replace('\\\\', '/');\n }\n if (!decoded.startsWith(\"/\")) {\n decoded = \"/\" + decoded;\n }\n while (decoded.indexOf(\"//\") >= 0) {\n decoded = decoded.replaceAll(\"//\", \"/\");\n }\n if (decoded.indexOf(\"/.\") < 0) {\n return decoded;\n }\n StringTokenizer st = new StringTokenizer(decoded, \"/\");\n ArrayList al = new ArrayList();\n while (st.hasMoreTokens()) {\n String s = st.nextToken();\n if (s.equals(\".\")) {\n } else if (s.equals(\"..\")) {\n if (al.size() == 0) {\n return null;\n }\n al.remove(al.size() - 1);\n } else {\n al.add(s);\n }\n }\n StringBuffer sb = new StringBuffer();\n for (String s: al) {\n sb.append('/');\n sb.append(s);\n }\n return sb.toString();\n }\n"} {"input": " public void processEvent(XMLSecEvent xmlSecEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {\n try {\n final String bstId;\n final X509Certificate[] x509Certificates;\n String reference = null;\n Key key = null;\n TokenType tokenType = WSSecurityTokenConstants.X509V3Token;\n XMLSecurityConstants.Action action = getAction();\n if (WSSConstants.SIGNATURE.equals(action)\n || WSSConstants.SAML_TOKEN_SIGNED.equals(action)\n || WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(action)) {\n String tokenId = \n outputProcessorChain.getSecurityContext().get(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE);\n SecurityTokenProvider signatureTokenProvider = null;\n GenericOutboundSecurityToken securityToken = null;\n if (tokenId != null && !WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(getAction())) {\n signatureTokenProvider = \n outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);\n if (signatureTokenProvider != null) {\n securityToken = \n (GenericOutboundSecurityToken)signatureTokenProvider.getSecurityToken();\n if (securityToken != null) {\n key = securityToken.getSecretKey(getSecurityProperties().getSignatureAlgorithm());\n reference = securityToken.getSha1Identifier();\n if (securityToken.getTokenType() != null) {\n tokenType = securityToken.getTokenType();\n }\n }\n }\n }\n if (key == null) {\n bstId = IDGenerator.generateID(null);\n String alias = ((WSSSecurityProperties) getSecurityProperties()).getSignatureUser();\n WSPasswordCallback pwCb = new WSPasswordCallback(alias, WSPasswordCallback.Usage.SIGNATURE);\n WSSUtils.doPasswordCallback(((WSSSecurityProperties)getSecurityProperties()).getCallbackHandler(), pwCb);\n String password = pwCb.getPassword();\n byte[] secretKey = pwCb.getKey();\n if (password == null && secretKey == null) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, \"noPassword\", alias);\n }\n if (password != null) {\n key = ((WSSSecurityProperties) getSecurityProperties()).getSignatureCrypto().getPrivateKey(alias, password);\n CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);\n cryptoType.setAlias(alias);\n x509Certificates = ((WSSSecurityProperties) getSecurityProperties()).getSignatureCrypto().getX509Certificates(cryptoType);\n if (x509Certificates == null || x509Certificates.length == 0) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, \"noUserCertsFound\", alias);\n }\n } else {\n x509Certificates = null;\n String algoFamily = JCEAlgorithmMapper.getJCEKeyAlgorithmFromURI(getSecurityProperties().getSignatureAlgorithm());\n key = new SecretKeySpec(secretKey, algoFamily);\n } \n } else {\n bstId = tokenId;\n x509Certificates = null;\n }\n } else if (WSSConstants.ENCRYPT.equals(action) ||\n WSSConstants.ENCRYPT_WITH_DERIVED_KEY.equals(action)) {\n X509Certificate x509Certificate = getReqSigCert(outputProcessorChain.getSecurityContext());\n if (((WSSSecurityProperties) getSecurityProperties()).isUseReqSigCertForEncryption()) {\n if (x509Certificate == null) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_ENCRYPTION, \"noCert\");\n }\n x509Certificates = new X509Certificate[1];\n x509Certificates[0] = x509Certificate;\n } else if (getSecurityProperties().getEncryptionUseThisCertificate() != null) {\n x509Certificate = getSecurityProperties().getEncryptionUseThisCertificate();\n x509Certificates = new X509Certificate[1];\n x509Certificates[0] = x509Certificate;\n } else {\n CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);\n WSSSecurityProperties securityProperties = ((WSSSecurityProperties) getSecurityProperties());\n cryptoType.setAlias(securityProperties.getEncryptionUser());\n Crypto crypto = securityProperties.getEncryptionCrypto();\n x509Certificates = crypto.getX509Certificates(cryptoType);\n if (x509Certificates == null || x509Certificates.length == 0) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_ENCRYPTION, \"noUserCertsFound\",\n ((WSSSecurityProperties) getSecurityProperties()).getEncryptionUser());\n }\n }\n WSSSecurityProperties securityProperties = ((WSSSecurityProperties) getSecurityProperties());\n if (securityProperties.isEnableRevocation()) {\n Crypto crypto = securityProperties.getEncryptionCrypto();\n crypto.verifyTrust(x509Certificates, true);\n }\n key = null;\n bstId = IDGenerator.generateID(null);\n } else {\n bstId = IDGenerator.generateID(null);\n x509Certificates = null;\n key = null;\n }\n final GenericOutboundSecurityToken binarySecurityToken =\n new GenericOutboundSecurityToken(bstId, tokenType, key, x509Certificates);\n binarySecurityToken.setSha1Identifier(reference);\n final SecurityTokenProvider binarySecurityTokenProvider =\n new SecurityTokenProvider() {\n @Override\n public OutboundSecurityToken getSecurityToken() throws WSSecurityException {\n return binarySecurityToken;\n }\n @Override\n public String getId() {\n return bstId;\n }\n };\n if (WSSConstants.SIGNATURE.equals(action)\n || WSSConstants.SAML_TOKEN_SIGNED.equals(action)) {\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE, bstId);\n boolean includeSignatureToken = \n ((WSSSecurityProperties) getSecurityProperties()).isIncludeSignatureToken();\n if ((includeSignatureToken \n || WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(getSecurityProperties().getSignatureKeyIdentifier()))\n && !WSSecurityTokenConstants.KerberosToken.equals(tokenType)) {\n FinalBinarySecurityTokenOutputProcessor finalBinarySecurityTokenOutputProcessor = new FinalBinarySecurityTokenOutputProcessor(binarySecurityToken);\n finalBinarySecurityTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());\n finalBinarySecurityTokenOutputProcessor.setAction(getAction());\n finalBinarySecurityTokenOutputProcessor.addBeforeProcessor(WSSSignatureOutputProcessor.class.getName());\n finalBinarySecurityTokenOutputProcessor.init(outputProcessorChain);\n binarySecurityToken.setProcessor(finalBinarySecurityTokenOutputProcessor);\n }\n } else if (WSSConstants.ENCRYPT.equals(action)) {\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTED_KEY, bstId);\n if (WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(((WSSSecurityProperties) getSecurityProperties()).getEncryptionKeyIdentifier())) {\n FinalBinarySecurityTokenOutputProcessor finalBinarySecurityTokenOutputProcessor = new FinalBinarySecurityTokenOutputProcessor(binarySecurityToken);\n finalBinarySecurityTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());\n finalBinarySecurityTokenOutputProcessor.setAction(getAction());\n finalBinarySecurityTokenOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());\n finalBinarySecurityTokenOutputProcessor.init(outputProcessorChain);\n binarySecurityToken.setProcessor(finalBinarySecurityTokenOutputProcessor);\n }\n } else if (WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(action)\n || WSSConstants.ENCRYPT_WITH_DERIVED_KEY.equals(action)) {\n WSSConstants.DerivedKeyTokenReference derivedKeyTokenReference = ((WSSSecurityProperties) getSecurityProperties()).getDerivedKeyTokenReference();\n switch (derivedKeyTokenReference) {\n case DirectReference:\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, bstId);\n break;\n case EncryptedKey:\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTED_KEY, bstId);\n break;\n case SecurityContextToken:\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SECURITYCONTEXTTOKEN, bstId);\n break;\n }\n }\n outputProcessorChain.getSecurityContext().registerSecurityTokenProvider(bstId, binarySecurityTokenProvider);\n } finally {\n outputProcessorChain.removeProcessor(this);\n }\n outputProcessorChain.processEvent(xmlSecEvent);\n }\n", "output": " public void processEvent(XMLSecEvent xmlSecEvent, OutputProcessorChain outputProcessorChain) throws XMLStreamException, XMLSecurityException {\n try {\n final String bstId;\n final X509Certificate[] x509Certificates;\n String reference = null;\n Key key = null;\n TokenType tokenType = WSSecurityTokenConstants.X509V3Token;\n XMLSecurityConstants.Action action = getAction();\n if (WSSConstants.SIGNATURE.equals(action)\n || WSSConstants.SAML_TOKEN_SIGNED.equals(action)\n || WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(action)) {\n String tokenId = \n outputProcessorChain.getSecurityContext().get(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE);\n SecurityTokenProvider signatureTokenProvider = null;\n GenericOutboundSecurityToken securityToken = null;\n if (tokenId != null && !WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(getAction())) {\n signatureTokenProvider = \n outputProcessorChain.getSecurityContext().getSecurityTokenProvider(tokenId);\n if (signatureTokenProvider != null) {\n securityToken = \n (GenericOutboundSecurityToken)signatureTokenProvider.getSecurityToken();\n if (securityToken != null) {\n key = securityToken.getSecretKey(getSecurityProperties().getSignatureAlgorithm());\n reference = securityToken.getSha1Identifier();\n tokenType = securityToken.getTokenType();\n }\n }\n }\n if (key == null) {\n bstId = IDGenerator.generateID(null);\n String alias = ((WSSSecurityProperties) getSecurityProperties()).getSignatureUser();\n WSPasswordCallback pwCb = new WSPasswordCallback(alias, WSPasswordCallback.Usage.SIGNATURE);\n WSSUtils.doPasswordCallback(((WSSSecurityProperties)getSecurityProperties()).getCallbackHandler(), pwCb);\n String password = pwCb.getPassword();\n byte[] secretKey = pwCb.getKey();\n if (password == null && secretKey == null) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, \"noPassword\", alias);\n }\n if (password != null) {\n key = ((WSSSecurityProperties) getSecurityProperties()).getSignatureCrypto().getPrivateKey(alias, password);\n CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);\n cryptoType.setAlias(alias);\n x509Certificates = ((WSSSecurityProperties) getSecurityProperties()).getSignatureCrypto().getX509Certificates(cryptoType);\n if (x509Certificates == null || x509Certificates.length == 0) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_SIGNATURE, \"noUserCertsFound\", alias);\n }\n } else {\n x509Certificates = null;\n String algoFamily = JCEAlgorithmMapper.getJCEKeyAlgorithmFromURI(getSecurityProperties().getSignatureAlgorithm());\n key = new SecretKeySpec(secretKey, algoFamily);\n }\n tokenType = null;\n } else {\n bstId = tokenId;\n x509Certificates = null;\n }\n } else if (WSSConstants.ENCRYPT.equals(action) ||\n WSSConstants.ENCRYPT_WITH_DERIVED_KEY.equals(action)) {\n X509Certificate x509Certificate = getReqSigCert(outputProcessorChain.getSecurityContext());\n if (((WSSSecurityProperties) getSecurityProperties()).isUseReqSigCertForEncryption()) {\n if (x509Certificate == null) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_ENCRYPTION, \"noCert\");\n }\n x509Certificates = new X509Certificate[1];\n x509Certificates[0] = x509Certificate;\n } else if (getSecurityProperties().getEncryptionUseThisCertificate() != null) {\n x509Certificate = getSecurityProperties().getEncryptionUseThisCertificate();\n x509Certificates = new X509Certificate[1];\n x509Certificates[0] = x509Certificate;\n } else {\n CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);\n WSSSecurityProperties securityProperties = ((WSSSecurityProperties) getSecurityProperties());\n cryptoType.setAlias(securityProperties.getEncryptionUser());\n Crypto crypto = securityProperties.getEncryptionCrypto();\n x509Certificates = crypto.getX509Certificates(cryptoType);\n if (x509Certificates == null || x509Certificates.length == 0) {\n throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_ENCRYPTION, \"noUserCertsFound\",\n ((WSSSecurityProperties) getSecurityProperties()).getEncryptionUser());\n }\n }\n WSSSecurityProperties securityProperties = ((WSSSecurityProperties) getSecurityProperties());\n if (securityProperties.isEnableRevocation()) {\n Crypto crypto = securityProperties.getEncryptionCrypto();\n crypto.verifyTrust(x509Certificates, true);\n }\n key = null;\n bstId = IDGenerator.generateID(null);\n } else {\n bstId = IDGenerator.generateID(null);\n x509Certificates = null;\n key = null;\n }\n final GenericOutboundSecurityToken binarySecurityToken =\n new GenericOutboundSecurityToken(bstId, tokenType, key, x509Certificates);\n binarySecurityToken.setSha1Identifier(reference);\n final SecurityTokenProvider binarySecurityTokenProvider =\n new SecurityTokenProvider() {\n @Override\n public OutboundSecurityToken getSecurityToken() throws WSSecurityException {\n return binarySecurityToken;\n }\n @Override\n public String getId() {\n return bstId;\n }\n };\n if (WSSConstants.SIGNATURE.equals(action)\n || WSSConstants.SAML_TOKEN_SIGNED.equals(action)) {\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SIGNATURE, bstId);\n boolean includeSignatureToken = \n ((WSSSecurityProperties) getSecurityProperties()).isIncludeSignatureToken();\n if ((includeSignatureToken \n || WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(getSecurityProperties().getSignatureKeyIdentifier()))\n && !WSSecurityTokenConstants.KerberosToken.equals(tokenType)) {\n FinalBinarySecurityTokenOutputProcessor finalBinarySecurityTokenOutputProcessor = new FinalBinarySecurityTokenOutputProcessor(binarySecurityToken);\n finalBinarySecurityTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());\n finalBinarySecurityTokenOutputProcessor.setAction(getAction());\n finalBinarySecurityTokenOutputProcessor.addBeforeProcessor(WSSSignatureOutputProcessor.class.getName());\n finalBinarySecurityTokenOutputProcessor.init(outputProcessorChain);\n binarySecurityToken.setProcessor(finalBinarySecurityTokenOutputProcessor);\n }\n } else if (WSSConstants.ENCRYPT.equals(action)) {\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTED_KEY, bstId);\n if (WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference.equals(((WSSSecurityProperties) getSecurityProperties()).getEncryptionKeyIdentifier())) {\n FinalBinarySecurityTokenOutputProcessor finalBinarySecurityTokenOutputProcessor = new FinalBinarySecurityTokenOutputProcessor(binarySecurityToken);\n finalBinarySecurityTokenOutputProcessor.setXMLSecurityProperties(getSecurityProperties());\n finalBinarySecurityTokenOutputProcessor.setAction(getAction());\n finalBinarySecurityTokenOutputProcessor.addAfterProcessor(EncryptEndingOutputProcessor.class.getName());\n finalBinarySecurityTokenOutputProcessor.init(outputProcessorChain);\n binarySecurityToken.setProcessor(finalBinarySecurityTokenOutputProcessor);\n }\n } else if (WSSConstants.SIGNATURE_WITH_DERIVED_KEY.equals(action)\n || WSSConstants.ENCRYPT_WITH_DERIVED_KEY.equals(action)) {\n WSSConstants.DerivedKeyTokenReference derivedKeyTokenReference = ((WSSSecurityProperties) getSecurityProperties()).getDerivedKeyTokenReference();\n switch (derivedKeyTokenReference) {\n case DirectReference:\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_DERIVED_KEY, bstId);\n break;\n case EncryptedKey:\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_ENCRYPTED_KEY, bstId);\n break;\n case SecurityContextToken:\n outputProcessorChain.getSecurityContext().put(WSSConstants.PROP_USE_THIS_TOKEN_ID_FOR_SECURITYCONTEXTTOKEN, bstId);\n break;\n }\n }\n outputProcessorChain.getSecurityContext().registerSecurityTokenProvider(bstId, binarySecurityTokenProvider);\n } finally {\n outputProcessorChain.removeProcessor(this);\n }\n outputProcessorChain.processEvent(xmlSecEvent);\n }\n"} {"input": " public SudokuSolverClass() {\n setContentPane(contentPane);\n setModal(true);\n getRootPane().setDefaultButton(selFileBut);\n buttonOK.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n onOK();\n }\n });\n buttonCancel.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n onCancel();\n }\n });\n setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);\n addWindowListener(new WindowAdapter() {\n public void windowClosing(WindowEvent e) {\n onCancel();\n }\n });\n contentPane.registerKeyboardAction(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n onCancel();\n }\n }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);\n this.setResizable(false);\n selFileBut.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent actionEvent) {\n JFileChooser fc = new JFileChooser();\n fc.setFileFilter(new FileFilter() {\n @Override\n public boolean accept(File file) {\n if (file.isDirectory()) return true;\n String[] filenameParts = file.getName().split(\"\\\\.\");\n return filenameParts[filenameParts.length - 1].toLowerCase().equals(\"sud\");\n }\n @Override\n public String getDescription() {\n return \"Sudoku files\";\n }\n });\n if (fc.showDialog(selFileBut, \"\") == JFileChooser.APPROVE_OPTION) {\n textField1.setText(fc.getSelectedFile().getAbsolutePath());\n try{\n fillField();\n } catch (Exception e) {\n JOptionPane.showMessageDialog(getRootPane(), \"Somewhat went wrong\", \"Error\", JOptionPane.ERROR_MESSAGE);\n }\n sudokuSolutionShow();\n getRootPane().setDefaultButton(buttonOK);\n }\n }\n });\n }\n", "output": " public SudokuSolverClass() {\n setContentPane(contentPane);\n setModal(true);\n getRootPane().setDefaultButton(selFileBut);\n buttonOK.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n onOK();\n }\n });\n buttonCancel.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent e) {\n onCancel();\n }\n });\n setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);\n addWindowListener(new WindowAdapter() {\n public void windowClosing(WindowEvent e) {\n onCancel();\n }\n });\n contentPane.registerKeyboardAction(new ActionListener() {\n public void actionPerformed(ActionEvent e) {\n onCancel();\n }\n }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);\n this.setResizable(false);\n selFileBut.addActionListener(new ActionListener() {\n @Override\n public void actionPerformed(ActionEvent actionEvent) {\n JFileChooser fc = new JFileChooser();\n fc.setFileFilter(new FileFilter() {\n @Override\n public boolean accept(File file) {\n if (file.isDirectory()) return true;\n String[] filenameParts = file.getName().split(\"\\\\.\");\n return filenameParts[filenameParts.length - 1].toLowerCase().equals(\"sud\");\n }\n @Override\n public String getDescription() {\n return \"Sudoku files\";\n }\n });\n if (fc.showDialog(selFileBut, \"\") == JFileChooser.APPROVE_OPTION) {\n textField1.setText(fc.getSelectedFile().getAbsolutePath());\n try{\n fillField();\n } catch (Exception e) {\n JOptionPane.showMessageDialog(getRootPane(), \"Something went wrong\", \"Error\", JOptionPane.ERROR_MESSAGE);\n }\n sudokuSolutionShow();\n getRootPane().setDefaultButton(buttonOK);\n }\n }\n });\n }\n"} {"input": "\tprivate void createOptionalAttributes(Composite parent) {\n\t\tfinal Composite configurationComposite = new Composite(parent, SWT.NONE);\n\t\tGridData configurationLayoutData = new GridData(\n\t\t\t\tGridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);\n\t\tconfigurationLayoutData.grabExcessHorizontalSpace = true;\n\t\tconfigurationLayoutData.verticalIndent = 3;\n\t\tconfigurationComposite.setLayoutData(configurationLayoutData);\n\t\tconfigurationComposite.setSize(configurationComposite.computeSize(\n\t\t\t\tSWT.DEFAULT, SWT.DEFAULT));\n\t\tGridLayout pronounciationLayout = new GridLayout();\n\t\tpronounciationLayout.numColumns = 2;\n\t\tpronounciationLayout.makeColumnsEqualWidth = false;\n\t\tpronounciationLayout.marginWidth = 0;\n\t\tpronounciationLayout.marginHeight = 0;\n\t\tconfigurationComposite.setLayout(pronounciationLayout);\n\t\tfinal Label nameLanguageLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnameLanguageLabel.setText(LANGUAGE_LABEL_TEXT);\n\t\tthis.nameLanguageText = new StyledText(configurationComposite,\n\t\t\t\tSWT.BORDER | SWT.SINGLE);\n\t\tthis.nameLanguageText.setLayoutData(configurationLayoutData);\n\t\tString languageCode = null;\n\t\tif (getLanguage() != null && !getLanguage().equals(\"\")) {\n\t\t\tlanguageCode = getLanguage();\n\t\t\tthis.nameLanguageText.setCaretOffset(languageCode.length());\n\t\t} else {\n\t\t\tlanguageCode = ISO_CODE_ENG;\n\t\t}\n\t\tthis.nameLanguageText.setText(languageCode);\n\t\tsetLanguage(languageCode);\n\t\tthis.nameLanguageText.setCaretOffset(languageCode.length());\n\t\tthis.nameLanguageText.setEnabled(true);\n\t\tthis.nameLanguageText.setTabs(0);\n\t\tthis.nameLanguageText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tsetLanguage(language);\n\t\t\t}\n\t\t});\n\t\tfinal Label nameSourceLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnameSourceLabel.setText(SOURCE_OF_NAME_LABEL_TEXT);\n\t\tthis.nameSourceText = new StyledText(configurationComposite, SWT.BORDER\n\t\t\t\t| SWT.SINGLE);\n\t\tthis.nameSourceText.setLayoutData(configurationLayoutData);\n\t\tString nameSource = null;\n\t\tif (getSourceOfName() != null && !getSourceOfName().equals(\"\")) {\n\t\t\tnameSource = getSourceOfName();\n\t\t} else {\n\t\t\tnameSource = SOURCE_OF_NAME_PROMT;\n\t\t}\n\t\tthis.nameSourceText.setText(nameSource);\n\t\tsetSourceOfName(nameSource);\n\t\tthis.nameSourceText.setCaretOffset(nameSource.length());\n\t\tthis.nameSourceText.setEnabled(true);\n\t\tthis.nameSourceText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif (!sourceOfName.equals(SOURCE_OF_NAME_PROMT)) {\n\t\t\t\t\tsetSourceOfName(nameSourceText.getText());\n\t\t\t\t}\n\t\t\t\tsetSourceOfName(\"uknown\");\n\t\t\t}\n\t\t});\n\t\tthis.nameSourceText.setTabs(0);\n\t\tfinal Label nameStatusLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnameStatusLabel.setText(NAME_STATUS_LABEL_TEXT);\n\t\tthis.nameStatusCombo = new Combo(configurationComposite, SWT.READ_ONLY\n\t\t\t\t| SWT.DROP_DOWN);\n\t\tthis.nameStatusCombo.setLayoutData(configurationLayoutData);\n\t\tString[] statusItems = new String[] { NameStatusValue.official.name(),\n\t\t\t\tNameStatusValue.standardised.name(),\n\t\t\t\tNameStatusValue.historical.name(), NameStatusValue.other.name() };\n\t\tthis.nameStatusCombo.setItems(statusItems);\n\t\tint index = 0;\n\t\tif (getNameStatus() != null) {\n\t\t\tString status = getNameStatus();\n\t\t\tfor (int i = 0; i < statusItems.length; i++) {\n\t\t\t\tif (status.equals(statusItems[i])) {\n\t\t\t\t\tindex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameStatusCombo.select(index);\n\t\tsetNameStatus(nameStatusCombo.getItem(index));\n\t\tthis.nameStatusCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetNameStatus(nameStatusCombo.getItem(nameStatusCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t\tfinal Label nativenessLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnativenessLabel.setText(NATIVENESS_LABEL_TEXT);\n\t\tthis.nameNativenessCombo = new Combo(configurationComposite,\n\t\t\t\tSWT.READ_ONLY | SWT.DROP_DOWN);\n\t\tthis.nameNativenessCombo.setLayoutData(configurationLayoutData);\n\t\tString[] nativenessItems = new String[] {\n\t\t\t\tNativenessValue.endonym.name(), NativenessValue.exonym.name() };\n\t\tthis.nameNativenessCombo.setItems(nativenessItems);\n\t\tint nativenessIndex = 0;\n\t\tif (getNativeness() != null) {\n\t\t\tString nativeness = getNativeness();\n\t\t\tfor (int i = 0; i < nativenessItems.length; i++) {\n\t\t\t\tif (nativeness.equals(nativenessItems[i])) {\n\t\t\t\t\tnativenessIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameNativenessCombo.select(nativenessIndex);\n\t\tsetNativeness(nameNativenessCombo.getItem(nativenessIndex));\n\t\tthis.nameNativenessCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetNativeness(nameNativenessCombo.getItem(nameNativenessCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t\tfinal Label genderLabel = new Label(configurationComposite, SWT.NONE);\n\t\tgenderLabel.setText(GRAMMATICAL_GENDER_LABEL_TEXT);\n\t\tthis.nameGenderCombo = new Combo(configurationComposite, SWT.READ_ONLY\n\t\t\t\t| SWT.DROP_DOWN);\n\t\tthis.nameGenderCombo.setLayoutData(configurationLayoutData);\n\t\tString[] genderItems = new String[] { GENDER_NULL_VAUE_MENU_ENTRY,\n\t\t\t\tGrammaticalGenderValue.feminine.name(),\n\t\t\t\tGrammaticalGenderValue.masculine.name(),\n\t\t\t\tGrammaticalGenderValue.common.name() };\n\t\tthis.nameGenderCombo.setItems(genderItems);\n\t\tint genderIndex = 0;\n\t\tif (getGender() != null) {\n\t\t\tString gender = getGender();\n\t\t\tfor (int i = 0; i < genderItems.length; i++) {\n\t\t\t\tif (gender.equals(genderItems[i])) {\n\t\t\t\t\tgenderIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameGenderCombo.select(genderIndex);\n\t\tsetGender(nameGenderCombo.getItem(genderIndex));\n\t\tthis.nameGenderCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetGender(nameGenderCombo.getItem(nameGenderCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t\tfinal Label numberLabel = new Label(configurationComposite, SWT.NONE);\n\t\tnumberLabel.setText(GRAMMATICAL_NUMBER_LABEL_TEXT);\n\t\tthis.nameNumberCombo = new Combo(configurationComposite, SWT.READ_ONLY\n\t\t\t\t| SWT.DROP_DOWN);\n\t\tthis.nameNumberCombo.setLayoutData(configurationLayoutData);\n\t\tString[] numberItems = new String[] { NUMBER_NULL_VALUE_MENU_ENTRY,\n\t\t\t\tGrammaticalNumberValue.singular.name(),\n\t\t\t\tGrammaticalNumberValue.dual.name(),\n\t\t\t\tGrammaticalNumberValue.plural.name() };\n\t\tthis.nameNumberCombo.setItems(numberItems);\n\t\tint numberIndex = 0;\n\t\tif (getNumber() != null) {\n\t\t\tString number = getNumber();\n\t\t\tfor (int i = 0; i < numberItems.length; i++) {\n\t\t\t\tif (number.equals(numberItems[i])) {\n\t\t\t\t\tnumberIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameNumberCombo.select(numberIndex);\n\t\tsetNumber(nameNumberCombo.getItem(numberIndex));\n\t\tsetNumber(nameNumberCombo.getItem(numberIndex));\n\t\tthis.nameNumberCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetNumber(nameNumberCombo.getItem(nameNumberCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t}\n", "output": "\tprivate void createOptionalAttributes(Composite parent) {\n\t\tfinal Composite configurationComposite = new Composite(parent, SWT.NONE);\n\t\tGridData configurationLayoutData = new GridData(\n\t\t\t\tGridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);\n\t\tconfigurationLayoutData.grabExcessHorizontalSpace = true;\n\t\tconfigurationLayoutData.verticalIndent = 3;\n\t\tconfigurationComposite.setLayoutData(configurationLayoutData);\n\t\tconfigurationComposite.setSize(configurationComposite.computeSize(\n\t\t\t\tSWT.DEFAULT, SWT.DEFAULT));\n\t\tGridLayout pronounciationLayout = new GridLayout();\n\t\tpronounciationLayout.numColumns = 2;\n\t\tpronounciationLayout.makeColumnsEqualWidth = false;\n\t\tpronounciationLayout.marginWidth = 0;\n\t\tpronounciationLayout.marginHeight = 0;\n\t\tconfigurationComposite.setLayout(pronounciationLayout);\n\t\tfinal Label nameLanguageLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnameLanguageLabel.setText(LANGUAGE_LABEL_TEXT);\n\t\tthis.nameLanguageText = new StyledText(configurationComposite,\n\t\t\t\tSWT.BORDER | SWT.SINGLE);\n\t\tthis.nameLanguageText.setLayoutData(configurationLayoutData);\n\t\tString languageCode = null;\n\t\tif (getLanguage() != null && !getLanguage().equals(\"\")) {\n\t\t\tlanguageCode = getLanguage();\n\t\t\tthis.nameLanguageText.setCaretOffset(languageCode.length());\n\t\t} else {\n\t\t\tlanguageCode = ISO_CODE_ENG;\n\t\t}\n\t\tthis.nameLanguageText.setText(languageCode);\n\t\tsetLanguage(languageCode);\n\t\tthis.nameLanguageText.setCaretOffset(languageCode.length());\n\t\tthis.nameLanguageText.setEnabled(true);\n\t\tthis.nameLanguageText.setTabs(0);\n\t\tthis.nameLanguageText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tsetLanguage(nameLanguageText.getText());\n\t\t\t}\n\t\t});\n\t\tfinal Label nameSourceLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnameSourceLabel.setText(SOURCE_OF_NAME_LABEL_TEXT);\n\t\tthis.nameSourceText = new StyledText(configurationComposite, SWT.BORDER\n\t\t\t\t| SWT.SINGLE);\n\t\tthis.nameSourceText.setLayoutData(configurationLayoutData);\n\t\tString nameSource = null;\n\t\tif (getSourceOfName() != null && !getSourceOfName().equals(\"\")) {\n\t\t\tnameSource = getSourceOfName();\n\t\t} else {\n\t\t\tnameSource = SOURCE_OF_NAME_PROMT;\n\t\t}\n\t\tthis.nameSourceText.setText(nameSource);\n\t\tsetSourceOfName(nameSource);\n\t\tthis.nameSourceText.setCaretOffset(nameSource.length());\n\t\tthis.nameSourceText.setEnabled(true);\n\t\tthis.nameSourceText.addModifyListener(new ModifyListener() {\n\t\t\tpublic void modifyText(ModifyEvent e) {\n\t\t\t\tif (!sourceOfName.equals(SOURCE_OF_NAME_PROMT)) {\n\t\t\t\t\tsetSourceOfName(nameSourceText.getText());\n\t\t\t\t}\n\t\t\t\tsetSourceOfName(\"uknown\");\n\t\t\t}\n\t\t});\n\t\tthis.nameSourceText.setTabs(0);\n\t\tfinal Label nameStatusLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnameStatusLabel.setText(NAME_STATUS_LABEL_TEXT);\n\t\tthis.nameStatusCombo = new Combo(configurationComposite, SWT.READ_ONLY\n\t\t\t\t| SWT.DROP_DOWN);\n\t\tthis.nameStatusCombo.setLayoutData(configurationLayoutData);\n\t\tString[] statusItems = new String[] { NameStatusValue.official.name(),\n\t\t\t\tNameStatusValue.standardised.name(),\n\t\t\t\tNameStatusValue.historical.name(), NameStatusValue.other.name() };\n\t\tthis.nameStatusCombo.setItems(statusItems);\n\t\tint index = 0;\n\t\tif (getNameStatus() != null) {\n\t\t\tString status = getNameStatus();\n\t\t\tfor (int i = 0; i < statusItems.length; i++) {\n\t\t\t\tif (status.equals(statusItems[i])) {\n\t\t\t\t\tindex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameStatusCombo.select(index);\n\t\tsetNameStatus(nameStatusCombo.getItem(index));\n\t\tthis.nameStatusCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetNameStatus(nameStatusCombo.getItem(nameStatusCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t\tfinal Label nativenessLabel = new Label(configurationComposite,\n\t\t\t\tSWT.NONE);\n\t\tnativenessLabel.setText(NATIVENESS_LABEL_TEXT);\n\t\tthis.nameNativenessCombo = new Combo(configurationComposite,\n\t\t\t\tSWT.READ_ONLY | SWT.DROP_DOWN);\n\t\tthis.nameNativenessCombo.setLayoutData(configurationLayoutData);\n\t\tString[] nativenessItems = new String[] {\n\t\t\t\tNativenessValue.endonym.name(), NativenessValue.exonym.name() };\n\t\tthis.nameNativenessCombo.setItems(nativenessItems);\n\t\tint nativenessIndex = 0;\n\t\tif (getNativeness() != null) {\n\t\t\tString nativeness = getNativeness();\n\t\t\tfor (int i = 0; i < nativenessItems.length; i++) {\n\t\t\t\tif (nativeness.equals(nativenessItems[i])) {\n\t\t\t\t\tnativenessIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameNativenessCombo.select(nativenessIndex);\n\t\tsetNativeness(nameNativenessCombo.getItem(nativenessIndex));\n\t\tthis.nameNativenessCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetNativeness(nameNativenessCombo.getItem(nameNativenessCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t\tfinal Label genderLabel = new Label(configurationComposite, SWT.NONE);\n\t\tgenderLabel.setText(GRAMMATICAL_GENDER_LABEL_TEXT);\n\t\tthis.nameGenderCombo = new Combo(configurationComposite, SWT.READ_ONLY\n\t\t\t\t| SWT.DROP_DOWN);\n\t\tthis.nameGenderCombo.setLayoutData(configurationLayoutData);\n\t\tString[] genderItems = new String[] { GENDER_NULL_VAUE_MENU_ENTRY,\n\t\t\t\tGrammaticalGenderValue.feminine.name(),\n\t\t\t\tGrammaticalGenderValue.masculine.name(),\n\t\t\t\tGrammaticalGenderValue.common.name() };\n\t\tthis.nameGenderCombo.setItems(genderItems);\n\t\tint genderIndex = 0;\n\t\tif (getGender() != null) {\n\t\t\tString gender = getGender();\n\t\t\tfor (int i = 0; i < genderItems.length; i++) {\n\t\t\t\tif (gender.equals(genderItems[i])) {\n\t\t\t\t\tgenderIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameGenderCombo.select(genderIndex);\n\t\tsetGender(nameGenderCombo.getItem(genderIndex));\n\t\tthis.nameGenderCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetGender(nameGenderCombo.getItem(nameGenderCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t\tfinal Label numberLabel = new Label(configurationComposite, SWT.NONE);\n\t\tnumberLabel.setText(GRAMMATICAL_NUMBER_LABEL_TEXT);\n\t\tthis.nameNumberCombo = new Combo(configurationComposite, SWT.READ_ONLY\n\t\t\t\t| SWT.DROP_DOWN);\n\t\tthis.nameNumberCombo.setLayoutData(configurationLayoutData);\n\t\tString[] numberItems = new String[] { NUMBER_NULL_VALUE_MENU_ENTRY,\n\t\t\t\tGrammaticalNumberValue.singular.name(),\n\t\t\t\tGrammaticalNumberValue.dual.name(),\n\t\t\t\tGrammaticalNumberValue.plural.name() };\n\t\tthis.nameNumberCombo.setItems(numberItems);\n\t\tint numberIndex = 0;\n\t\tif (getNumber() != null) {\n\t\t\tString number = getNumber();\n\t\t\tfor (int i = 0; i < numberItems.length; i++) {\n\t\t\t\tif (number.equals(numberItems[i])) {\n\t\t\t\t\tnumberIndex = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.nameNumberCombo.select(numberIndex);\n\t\tsetNumber(nameNumberCombo.getItem(numberIndex));\n\t\tsetNumber(nameNumberCombo.getItem(numberIndex));\n\t\tthis.nameNumberCombo.addSelectionListener(new SelectionAdapter() {\n\t\t\t@Override\n\t\t\tpublic void widgetSelected(SelectionEvent event) {\n\t\t\t\tsetNumber(nameNumberCombo.getItem(nameNumberCombo\n\t\t\t\t\t\t.getSelectionIndex()));\n\t\t\t}\n\t\t});\n\t}\n"} {"input": "\tpublic void perform()\n\t{\n\t\tFaction faction = this.argAsFaction(0);\n\t\tif (faction == null) return;\n\t\tFPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);\n\t\tboolean samePlayer = fplayer == fme;\n\t\tif (!samePlayer && ! Permission.JOIN_OTHERS.has(sender, false))\n\t\t{\n\t\t\tmsg(\"You do not have permission to move other players into a faction.\");\n\t\t\treturn;\n\t\t}\n\t\tif (faction == fplayer.getFaction())\n\t\t{\n\t\t\tmsg(\"%s %s already a member of %s\", fplayer.describeTo(fme, true), (samePlayer ? \"are\" : \"is\"), faction.getTag(fme));\n\t\t\treturn;\n\t\t}\n\t\tif (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit)\n\t\t{\n\t\t\tmsg(\"The faction %s is at the limit of %d members, so %s cannot currently join.\", faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false));\n\t\t\treturn;\n\t\t}\n\t\tif (fplayer.hasFaction())\n\t\t{\n\t\t\tmsg(\"%s must leave %s current faction first.\", fplayer.describeTo(fme, true), (samePlayer ? \"your\" : \"their\"));\n\t\t\treturn;\n\t\t}\n\t\tif (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0)\n\t\t{\n\t\t\tmsg(\"%s cannot join a faction with a negative power level.\", fplayer.describeTo(fme, true));\n\t\t\treturn;\n\t\t}\n\t\tif( ! (faction.getOpen() || faction.isInvited(fplayer) || fme.hasAdminMode() || Permission.JOIN_ANY.has(sender, false)))\n\t\t{\n\t\t\tmsg(\"This faction requires invitation.\");\n\t\t\tif (samePlayer)\n\t\t\t\tfaction.msg(\"%s tried to join your faction.\", fplayer.describeTo(faction, true));\n\t\t\treturn;\n\t\t}\n\t\tif (samePlayer && ! payForCommand(Conf.econCostJoin, \"to join a faction\", \"for joining a faction\")) return;\n\t\tfme.msg(\"%s successfully joined %s.\", fplayer.describeTo(fme, true), faction.getTag(fme));\n\t\tif (!samePlayer)\n\t\t\tfplayer.msg(\"%s moved you into the faction %s.\", fme.describeTo(fplayer, true), faction.getTag(fplayer));\n\t\tfaction.msg(\"%s joined your faction.\", fplayer.describeTo(faction, true));\n\t\tfplayer.resetFactionData();\n\t\tfplayer.setFaction(faction);\n\t\tfaction.deinvite(fplayer);\n\t\tif (Conf.logFactionJoin)\n\t\t{\n\t\t\tif (samePlayer)\n\t\t\t\tP.p.log(\"%s joined the faction %s.\", fplayer.getName(), faction.getTag());\n\t\t\telse\n\t\t\t\tP.p.log(\"%s moved the player %s into the faction %s.\", fme.getName(), fplayer.getName(), faction.getTag());\n\t\t}\n\t}\n", "output": "\tpublic void perform()\n\t{\n\t\tFaction faction = this.argAsFaction(0);\n\t\tif (faction == null) return;\n\t\tFPlayer fplayer = this.argAsBestFPlayerMatch(1, fme, false);\n\t\tboolean samePlayer = fplayer == fme;\n\t\tif (!samePlayer && ! Permission.JOIN_OTHERS.has(sender, false))\n\t\t{\n\t\t\tmsg(\"You do not have permission to move other players into a faction.\");\n\t\t\treturn;\n\t\t}\n\t\tif (faction == fplayer.getFaction())\n\t\t{\n\t\t\tmsg(\"%s %s already a member of %s\", fplayer.describeTo(fme, true), (samePlayer ? \"are\" : \"is\"), faction.getTag(fme));\n\t\t\treturn;\n\t\t}\n\t\tif (Conf.factionMemberLimit > 0 && faction.getFPlayers().size() >= Conf.factionMemberLimit)\n\t\t{\n\t\t\tmsg(\" ! The faction %s is at the limit of %d members, so %s cannot currently join.\", faction.getTag(fme), Conf.factionMemberLimit, fplayer.describeTo(fme, false));\n\t\t\treturn;\n\t\t}\n\t\tif (fplayer.hasFaction())\n\t\t{\n\t\t\tmsg(\"%s must leave %s current faction first.\", fplayer.describeTo(fme, true), (samePlayer ? \"your\" : \"their\"));\n\t\t\treturn;\n\t\t}\n\t\tif (!Conf.canLeaveWithNegativePower && fplayer.getPower() < 0)\n\t\t{\n\t\t\tmsg(\"%s cannot join a faction with a negative power level.\", fplayer.describeTo(fme, true));\n\t\t\treturn;\n\t\t}\n\t\tif( ! (faction.getOpen() || faction.isInvited(fplayer) || fme.hasAdminMode() || Permission.JOIN_ANY.has(sender, false)))\n\t\t{\n\t\t\tmsg(\"This faction requires invitation.\");\n\t\t\tif (samePlayer)\n\t\t\t\tfaction.msg(\"%s tried to join your faction.\", fplayer.describeTo(faction, true));\n\t\t\treturn;\n\t\t}\n\t\tif (samePlayer && ! payForCommand(Conf.econCostJoin, \"to join a faction\", \"for joining a faction\")) return;\n\t\tfme.msg(\"%s successfully joined %s.\", fplayer.describeTo(fme, true), faction.getTag(fme));\n\t\tif (!samePlayer)\n\t\t\tfplayer.msg(\"%s moved you into the faction %s.\", fme.describeTo(fplayer, true), faction.getTag(fplayer));\n\t\tfaction.msg(\"%s joined your faction.\", fplayer.describeTo(faction, true));\n\t\tfplayer.resetFactionData();\n\t\tfplayer.setFaction(faction);\n\t\tfaction.deinvite(fplayer);\n\t\tif (Conf.logFactionJoin)\n\t\t{\n\t\t\tif (samePlayer)\n\t\t\t\tP.p.log(\"%s joined the faction %s.\", fplayer.getName(), faction.getTag());\n\t\t\telse\n\t\t\t\tP.p.log(\"%s moved the player %s into the faction %s.\", fme.getName(), fplayer.getName(), faction.getTag());\n\t\t}\n\t}\n"} {"input": " public void run() {\n Database db = new Database(\"power\", \"_p55!gv{7MJ]}dIpPk7n1*0-,hq(PD\", \"code.dei.estt.ipt.pt\", \"powercomputing\");\n try {\n Thread.sleep(2000);\n } catch (InterruptedException ex) {\n Logger.getLogger(AsyncStats.class.getName()).log(Level.SEVERE, null, ex);\n }\n while (!Stop) {\n try {\n int result_count = db.ExecuteCountQuery(period, idClient, idProblem);\n int numThread = numThreads.get();\n if (result_count == 0 && numThread == 0) {\n Aplication.nodeJS.Emit(\"end\", this.period, this.idClient, this.idProblem);\n System.out.println(\"Async Stop\");\n break;\n }\n if (result_count >= numThread) {\n boolean temp = db.ExecuteMedia(period, idClient, idProblem,this);\n Aplication.nodeJS.Emit(\"run\", this.period, this.idClient, this.idProblem);\n period = period + aux;\n }\n Thread.sleep(750);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Error - Sync Class \" + e);\n }\n }\n }\n", "output": " public void run() {\n Database db = new Database(\"power\", \"_p55!gv{7MJ]}dIpPk7n1*0-,hq(PD\", \"code.dei.estt.ipt.pt\", \"powercomputing\");\n try {\n Thread.sleep(2000);\n } catch (InterruptedException ex) {\n Logger.getLogger(AsyncStats.class.getName()).log(Level.SEVERE, null, ex);\n }\n while (!Stop) {\n try {\n int result_count = db.ExecuteCountQuery(period, idClient, idProblem);\n int numThread = numThreads.get();\n if (result_count == 0 && numThread == 0) {\n Aplication.nodeJS.Emit(\"end\", this.period, this.idClient, this.idProblem);\n System.out.println(\"Async Stop\");\n break;\n }\n if (result_count >= numThread) {\n getAllUniqueIndividuals(getBestIndividual());\n boolean temp = db.ExecuteMedia(period, idClient, idProblem,this);\n Aplication.nodeJS.Emit(\"run\", this.period, this.idClient, this.idProblem);\n period = period + aux;\n }\n Thread.sleep(750);\n } catch (Exception e) {\n e.printStackTrace();\n System.out.println(\"Error - Sync Class \" + e);\n }\n }\n }\n"} {"input": " public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\n if (client.updateComponent(this, uidl, true)) {\n return;\n }\n this.client = client;\n uidlId = uidl.getId();\n maxValue = uidl.getIntAttribute(ATTR_MAX_VALUE);\n value = uidl.getDoubleAttribute(ATTR_VALUE);\n animated = uidl.getBooleanAttribute(ATTR_ANIMATED);\n immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE);\n disabled = uidl.getBooleanAttribute(ATTR_DISABLED);\n readonly = uidl.getBooleanAttribute(ATTR_READONLY);\n if (!disabled && !readonly) {\n sinkEvents(Event.ONCLICK);\n sinkEvents(Event.ONMOUSEOVER);\n sinkEvents(Event.ONMOUSEOUT);\n sinkEvents(Event.ONFOCUS);\n sinkEvents(Event.ONBLUR);\n sinkEvents(Event.ONKEYUP);\n }\n if (barDiv == null) {\n for (int i = 0; i < maxValue; i++) {\n DivElement starDiv = createStarDiv(i + 1);\n element.appendChild(starDiv);\n width += starDiv.getClientWidth();\n if (height < starDiv.getClientHeight()) {\n height = starDiv.getClientHeight();\n }\n }\n barDiv = createBarDiv(height);\n element.appendChild(barDiv);\n } else {\n setBarWidth(calcBarWidth(value));\n }\n element.getStyle().setPropertyPx(\"width\", width);\n element.getStyle().setPropertyPx(\"height\", height);\n }\n", "output": " public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\n if (client.updateComponent(this, uidl, true)) {\n return;\n }\n this.client = client;\n uidlId = uidl.getId();\n maxValue = uidl.getIntAttribute(ATTR_MAX_VALUE);\n value = uidl.getDoubleAttribute(ATTR_VALUE);\n animated = uidl.getBooleanAttribute(ATTR_ANIMATED);\n immediate = uidl.getBooleanAttribute(ATTR_IMMEDIATE);\n disabled = uidl.getBooleanAttribute(ATTR_DISABLED);\n readonly = uidl.getBooleanAttribute(ATTR_READONLY);\n if (!disabled && !readonly) {\n sinkEvents(Event.ONCLICK);\n sinkEvents(Event.ONMOUSEOVER);\n sinkEvents(Event.ONMOUSEOUT);\n sinkEvents(Event.ONFOCUS);\n sinkEvents(Event.ONBLUR);\n sinkEvents(Event.ONKEYUP);\n } else {\n \tDOM.sinkEvents(getElement(), 0);\n }\n if (barDiv == null) {\n for (int i = 0; i < maxValue; i++) {\n DivElement starDiv = createStarDiv(i + 1);\n element.appendChild(starDiv);\n width += starDiv.getClientWidth();\n if (height < starDiv.getClientHeight()) {\n height = starDiv.getClientHeight();\n }\n }\n barDiv = createBarDiv(height);\n element.appendChild(barDiv);\n } else {\n setBarWidth(calcBarWidth(value));\n }\n element.getStyle().setPropertyPx(\"width\", width);\n element.getStyle().setPropertyPx(\"height\", height);\n }\n"} {"input": " public static void main(String args[]) {\n Configuration conf = HBaseConfiguration.create();\n Properties zkProps = ZKConfig.makeZKProps(conf);\n for (Entry entry : zkProps.entrySet()) {\n String key = entry.getKey().toString().trim();\n String value = entry.getValue().toString().trim();\n if (key.startsWith(\"server.\")) {\n String[] parts = value.split(\":\");\n String host = parts[0];\n System.out.println(host);\n }\n }\n }\n", "output": " public static void main(String args[]) {\n Configuration conf = HBaseConfiguration.create();\n Properties zkProps = ZKConfig.makeZKProps(conf);\n for (Entry entry : zkProps.entrySet()) {\n String key = entry.getKey().toString().trim();\n String value = entry.getValue().toString().trim();\n if (key.startsWith(\"server.\")) {\n String[] parts = value.split(\":\");\n String host = parts[0];\n System.out.println(\"ZK host:\" + host);\n }\n }\n }\n"} {"input": "\tpublic Function compileTemplate(final Scriptable scope, CharSequence source, final String sourceName) {\n\t\tfinal Context cx=runtime.enter();\n\t\ttry {\n\t\t\tfinal Scriptable fragments=cx.newArray(scope, 0);\n\t\t\tEjsParser.Events events=new EjsParser.Events() {\n\t\t\t\tint fragmentIndex=0;\n\t\t\t\tpublic void handleLiteral(CharSequence text, LocationInfo location) {\n\t\t\t\t\tint index=fragmentIndex++;\n\t\t\t\t\tScriptableObject.putProperty(fragments, index, text.toString());\n\t\t\t\t}\n\t\t\t\tpublic void handleInterpolation(CharSequence script, LocationInfo location) {\n\t\t\t\t\tStringBuilder interpDefn=new StringBuilder(script.length()+50);\n\t\t\t\t\tinterpDefn.append(\"function(){return String(\")\n\t\t\t\t\t\t.append(script).append(\");}\");\n\t\t\t\t\tFunction interpFunction=cx.compileFunction(scope, interpDefn.toString(), \n\t\t\t\t\t\t\tsourceName, location.getLineStart(), null);\n\t\t\t\t\tint index=fragmentIndex++;\n\t\t\t\t\tScriptableObject.putProperty(fragments, index, interpFunction);\n\t\t\t\t}\n\t\t\t\tpublic void handleBlock(CharSequence script, LocationInfo location) {\n\t\t\t\t\tStringBuilder blockDefn=new StringBuilder(script.length()+50);\n\t\t\t\t\tblockDefn.append(\"function(){\").append(script)\n\t\t\t\t\t\t.append(\"; return '';}\");\n\t\t\t\t\tFunction blockFunction=cx.compileFunction(scope, blockDefn.toString(), \n\t\t\t\t\t\t\tsourceName, location.getLineStart(), null);\n\t\t\t\t\tint index=fragmentIndex++;\n\t\t\t\t\tScriptableObject.putProperty(fragments, index, blockFunction);\n\t\t\t\t}\n\t\t\t};\n\t\t\tEjsParser parser=new EjsParser(events);\n\t\t\tparser.parse(source);\n\t\t\treturn (Function) evaluatorFunction.call(cx, scope, null, new Object[] { fragments });\n\t\t} finally {\n\t\t\truntime.exit();\n\t\t}\n\t}\n", "output": "\tpublic Function compileTemplate(final Scriptable scope, CharSequence source, final String sourceName) {\n\t\tfinal Context cx=runtime.enter();\n\t\ttry {\n\t\t\tfinal Scriptable fragments=cx.newArray(scope, 0);\n\t\t\tEjsParser.Events events=new EjsParser.Events() {\n\t\t\t\tint fragmentIndex=0;\n\t\t\t\tpublic void handleLiteral(CharSequence text, LocationInfo location) {\n\t\t\t\t\tint index=fragmentIndex++;\n\t\t\t\t\tScriptableObject.putProperty(fragments, index, text.toString());\n\t\t\t\t}\n\t\t\t\tpublic void handleInterpolation(CharSequence script, LocationInfo location) {\n\t\t\t\t\tStringBuilder interpDefn=new StringBuilder(script.length()+50);\n\t\t\t\t\tinterpDefn.append(\"function(){var expr=\")\n\t\t\t\t\t\t.append(script).append(\";return (expr===null||expr===undefined) ? null : String(expr);}\");\n\t\t\t\t\tFunction interpFunction=cx.compileFunction(scope, interpDefn.toString(), \n\t\t\t\t\t\t\tsourceName, location.getLineStart(), null);\n\t\t\t\t\tint index=fragmentIndex++;\n\t\t\t\t\tScriptableObject.putProperty(fragments, index, interpFunction);\n\t\t\t\t}\n\t\t\t\tpublic void handleBlock(CharSequence script, LocationInfo location) {\n\t\t\t\t\tStringBuilder blockDefn=new StringBuilder(script.length()+50);\n\t\t\t\t\tblockDefn.append(\"function(){\").append(script)\n\t\t\t\t\t\t.append(\"; return '';}\");\n\t\t\t\t\tFunction blockFunction=cx.compileFunction(scope, blockDefn.toString(), \n\t\t\t\t\t\t\tsourceName, location.getLineStart(), null);\n\t\t\t\t\tint index=fragmentIndex++;\n\t\t\t\t\tScriptableObject.putProperty(fragments, index, blockFunction);\n\t\t\t\t}\n\t\t\t};\n\t\t\tEjsParser parser=new EjsParser(events);\n\t\t\tparser.parse(source);\n\t\t\treturn (Function) evaluatorFunction.call(cx, scope, null, new Object[] { fragments });\n\t\t} finally {\n\t\t\truntime.exit();\n\t\t}\n\t}\n"} {"input": " public void runAutomated(AutomatedInstallData idata, IXMLElement panelRoot)\n {\n final class PInfo\n {\n private boolean _selected;\n private int _index;\n private String _name = \"\";\n PInfo(boolean selected, String index, String name)\n {\n _selected = selected;\n try\n {\n _index = Integer.valueOf(index).intValue();\n }\n catch (NumberFormatException e)\n {\n _index = -100;\n }\n if (name != null)\n {\n _name = name;\n }\n }\n public boolean isSelected()\n {\n return _selected;\n }\n public boolean equals(int index)\n {\n return _index == index && _name.equals(\"\");\n }\n public boolean equals(String name)\n {\n return _name.equals(name);\n }\n @Override\n public String toString()\n {\n String retVal = \"\";\n if (!_name.equals(\"\"))\n {\n retVal = \"Name: \" + _name + \" and \";\n }\n retVal += \"Index: \" + String.valueOf(_index);\n return retVal;\n }\n }\n List autoinstallPackInfoList = new ArrayList();\n Vector packList = panelRoot.getChildrenNamed(\"pack\");\n System.out.println(\"Read pack list from xml definition.\");\n int numberOfPacks = packList.size();\n for (int packIndex = 0; packIndex < numberOfPacks; packIndex++)\n {\n IXMLElement pack = packList.get(packIndex);\n String index = pack.getAttribute(\"index\");\n String name = pack.getAttribute(\"name\");\n final String selectedString = pack.getAttribute(\"selected\");\n boolean selected = selectedString.equalsIgnoreCase(\"true\")\n || selectedString.equalsIgnoreCase(\"on\");\n final PInfo packInfo = new PInfo(selected, index, name);\n autoinstallPackInfoList.add(packInfo);\n System.out.println(\"Try to \" + (selected ? \"add to\" : \"remove from\") + \" selection [\"\n + packInfo.toString() + \"]\");\n }\n System.out.println(\"Modify pack selection.\");\n for (Pack pack : idata.availablePacks)\n {\n final int indexOfAvailablePack = idata.availablePacks.indexOf(pack);\n for (PInfo packInfo : autoinstallPackInfoList)\n {\n if ((packInfo.equals(pack.name)) || (packInfo.equals(indexOfAvailablePack)))\n {\n if (pack.required)\n {\n if (!packInfo.isSelected())\n {\n System.out.println(\"Pack [\" + packInfo.toString()\n + \"] must be installed because it is required!\");\n }\n }\n else\n {\n if (packInfo.isSelected())\n {\n if ((idata.selectedPacks.indexOf(pack) < 0)\n && (pack.id != null)\n && (!idata.getRules().canInstallPack(pack.id,\n idata.getVariables())))\n {\n idata.selectedPacks.add(pack);\n System.out.println(\"Pack [\" + packInfo.toString()\n + \"] added to selection.\");\n }\n }\n else\n {\n idata.selectedPacks.remove(pack);\n System.out.println(\"Pack [\" + packInfo.toString()\n + \"] removed from selection.\");\n }\n }\n break;\n }\n }\n }\n for (int childIndex = panelRoot.getChildrenCount(); childIndex > 0; childIndex--)\n {\n panelRoot.removeChild(panelRoot.getChildAtIndex(childIndex));\n }\n makeXMLData(idata, panelRoot);\n }\n", "output": " public void runAutomated(AutomatedInstallData idata, IXMLElement panelRoot)\n {\n final class PInfo\n {\n private boolean _selected;\n private int _index;\n private String _name = \"\";\n PInfo(boolean selected, String index, String name)\n {\n _selected = selected;\n try\n {\n _index = Integer.valueOf(index).intValue();\n }\n catch (NumberFormatException e)\n {\n _index = -100;\n }\n if (name != null)\n {\n _name = name;\n }\n }\n public boolean isSelected()\n {\n return _selected;\n }\n public boolean equals(int index)\n {\n return _index == index && _name.equals(\"\");\n }\n public boolean equals(String name)\n {\n return _name.equals(name);\n }\n @Override\n public String toString()\n {\n String retVal = \"\";\n if (!_name.equals(\"\"))\n {\n retVal = \"Name: \" + _name + \" and \";\n }\n retVal += \"Index: \" + String.valueOf(_index);\n return retVal;\n }\n }\n List autoinstallPackInfoList = new ArrayList();\n Vector packList = panelRoot.getChildrenNamed(\"pack\");\n System.out.println(\"Read pack list from xml definition.\");\n int numberOfPacks = packList.size();\n for (int packIndex = 0; packIndex < numberOfPacks; packIndex++)\n {\n IXMLElement pack = packList.get(packIndex);\n String index = pack.getAttribute(\"index\");\n String name = pack.getAttribute(\"name\");\n final String selectedString = pack.getAttribute(\"selected\");\n boolean selected = selectedString.equalsIgnoreCase(\"true\")\n || selectedString.equalsIgnoreCase(\"on\");\n final PInfo packInfo = new PInfo(selected, index, name);\n autoinstallPackInfoList.add(packInfo);\n System.out.println(\"Try to \" + (selected ? \"add to\" : \"remove from\") + \" selection [\"\n + packInfo.toString() + \"]\");\n }\n System.out.println(\"Modify pack selection.\");\n for (Pack pack : idata.availablePacks)\n {\n final int indexOfAvailablePack = idata.availablePacks.indexOf(pack);\n for (PInfo packInfo : autoinstallPackInfoList)\n {\n if ((packInfo.equals(pack.name)) || (packInfo.equals(indexOfAvailablePack)))\n {\n if (pack.required)\n {\n if (!packInfo.isSelected())\n {\n System.out.println(\"Pack [\" + packInfo.toString()\n + \"] must be installed because it is required!\");\n }\n }\n else\n {\n if (packInfo.isSelected())\n {\n if ((idata.selectedPacks.indexOf(pack) < 0)\n && (pack.id != null)\n && (!idata.getRules().canInstallPack(pack.id,\n idata.getVariables())))\n {\n idata.selectedPacks.add(pack);\n System.out.println(\"Pack [\" + packInfo.toString()\n + \"] added to selection.\");\n }\n }\n else\n {\n idata.selectedPacks.remove(pack);\n System.out.println(\"Pack [\" + packInfo.toString()\n + \"] removed from selection.\");\n }\n }\n break;\n }\n }\n }\n for (int counter = panelRoot.getChildrenCount(); counter > 0; counter--)\n {\n panelRoot.removeChild(panelRoot.getChildAtIndex(0));\n }\n makeXMLData(idata, panelRoot);\n }\n"} {"input": " private static LinkedList>\n buildMappingFromCallSiteToCallee(final CFGNode caller,\n final CFGHandle callee) {\n final LinkedList> result =\n new LinkedList>();\n if (caller.getNodeType() != CFGNode.NodeType.none) {\n Iterator opIter = caller.getOperands().iterator();\n opIter.next();\n Iterator paramIter = callee.getParams().iterator();\n while (opIter.hasNext()) {\n assert paramIter.hasNext();\n result.add(Pair.make(paramIter.next(), PassingSolver.makeArgument(opIter.next())));\n }\n assert !paramIter.hasNext();\n } else {\n final Iterator callIter =\n XMLLinearizeASTElement.functionCall(caller.getElement()).iterator();\n final Iterator calleeIter =\n XMLLinearizeASTElement.functionDeclaration(callee.getElement()).iterator();\n for (callIter.next(), calleeIter.next(); callIter.hasNext(); )\n result.add(Pair.make(PassingSolver\n .makeArgument(callIter.next()),\n PassingSolver\n .makeArgument(calleeIter.next())));\n }\n return result;\n }\n", "output": " private static LinkedList>\n buildMappingFromCallSiteToCallee(final CFGNode caller,\n final CFGHandle callee) {\n final LinkedList> result =\n new LinkedList>();\n if (caller.getNodeType() != CFGNode.NodeType.none) {\n Iterator opIter = caller.getOperands().iterator();\n opIter.next();\n Iterator paramIter = callee.getParams().iterator();\n while (opIter.hasNext()) {\n assert paramIter.hasNext();\n result.add(Pair.make(PassingSolver.makeArgument(opIter.next()), paramIter.next()));\n }\n assert !paramIter.hasNext();\n } else {\n final Iterator callIter =\n XMLLinearizeASTElement.functionCall(caller.getElement()).iterator();\n final Iterator calleeIter =\n XMLLinearizeASTElement.functionDeclaration(callee.getElement()).iterator();\n for (callIter.next(), calleeIter.next(); callIter.hasNext(); )\n result.add(Pair.make(PassingSolver\n .makeArgument(callIter.next()),\n PassingSolver\n .makeArgument(calleeIter.next())));\n }\n return result;\n }\n"} {"input": "\tpublic int run(String[] args) throws Exception {\n\t\tif (args.length < 3) {\n\t\t\tSystem.out\n\t\t\t\t\t.println(\"Usage: bin/hadoop jar HadoopGrams.jar org.jovislab.tools.hadoop.hadoopgrams.HadoopGrams [] [] []\");\n\t\t\treturn -1;\n\t\t}\n\t\tJob job = new Job();\n\t\tjob.setJarByClass(HadoopGrams.class);\n\t\tjob.setMapperClass(Map.class);\n\t\tjob.setCombinerClass(Combine.class);\n\t\tjob.setReducerClass(Reduce.class);\n\t\tjob.setOutputKeyClass(Text.class);\n\t\tjob.setOutputValueClass(LongWritable.class);\n\t\tConfiguration config = job.getConfiguration();\n\t\tconfig.setInt(\"n\", Integer.parseInt(args[2]));\n\t\tif (args.length >= 4) {\n\t\t\tconfig.setClass(\"map.filter\", Class.forName(args[3]), Filter.class);\n\t\t}\n\t\tif (args.length >= 5) {\n\t\t\tconfig.setInt(\"combine.threshold\", Integer.parseInt(args[4]));\n\t\t}\n\t\tif (args.length >= 6) {\n\t\t\tconfig.setInt(\"reduce.threshold\", Integer.parseInt(args[5]));\n\t\t}\n\t\tFileInputFormat.setInputPaths(job, new Path(args[0]));\n\t\tFileOutputFormat.setOutputPath(job, new Path(args[1]));\n\t\tjob.waitForCompletion(true);\n\t\treturn 0;\n\t}\n", "output": "\tpublic int run(String[] args) throws Exception {\n\t\tif (args.length < 3) {\n\t\t\tSystem.out.println(\"Usage: bin/hadoop jar HadoopGrams.jar org.jovislab.tools.hadoop.hadoopgrams.HadoopGrams [] [] []\");\n\t\t\treturn -1;\n\t\t}\n\t\tJob job = new Job();\n\t\tjob.setJarByClass(HadoopGrams.class);\n\t\tjob.setMapperClass(Map.class);\n\t\tjob.setCombinerClass(Combine.class);\n\t\tjob.setReducerClass(Reduce.class);\n\t\tjob.setOutputKeyClass(Text.class);\n\t\tjob.setOutputValueClass(LongWritable.class);\n\t\tConfiguration config = job.getConfiguration();\n\t\tconfig.setInt(\"n\", Integer.parseInt(args[2]));\n\t\tif (args.length >= 4) {\n\t\t\tconfig.setClass(\"map.filter\", Class.forName(args[3]), Filter.class);\n\t\t}\n\t\tif (args.length >= 5) {\n\t\t\tconfig.setInt(\"combine.threshold\", Integer.parseInt(args[4]));\n\t\t}\n\t\tif (args.length >= 6) {\n\t\t\tconfig.setInt(\"reduce.threshold\", Integer.parseInt(args[5]));\n\t\t}\n\t\tFileInputFormat.setInputPaths(job, new Path(args[0]));\n\t\tFileOutputFormat.setOutputPath(job, new Path(args[1]));\n\t\tjob.waitForCompletion(true);\n\t\treturn 0;\n\t}\n"} {"input": "\tpublic void commandAction(Command c, Displayable d) {\n\t\tupdateLastUserActionTime();\n\t\ttry {\n\t\t\tif((keyboardLocked) && (d != null)) {\n\t\t\t\tkeyPressed(0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((c == CMDS[PAN_LEFT25_CMD]) || (c == CMDS[PAN_RIGHT25_CMD])\n\t\t\t\t\t|| (c == CMDS[PAN_UP25_CMD]) || (c == CMDS[PAN_DOWN25_CMD])\n\t\t\t\t\t|| (c == CMDS[PAN_LEFT2_CMD]) || (c == CMDS[PAN_RIGHT2_CMD])\n\t\t\t\t\t|| (c == CMDS[PAN_UP2_CMD]) || (c == CMDS[PAN_DOWN2_CMD])) {\n\t\t\t\tint panX = 0; int panY = 0;\n\t\t\t\tint courseDiff = 0;\n\t\t\t\tint backLightLevelDiff = 0;\n\t\t\t\tif (c == CMDS[PAN_LEFT25_CMD]) {\n\t\t\t\t\tpanX = -25;\n\t\t\t\t} else if (c == CMDS[PAN_RIGHT25_CMD]) {\n\t\t\t\t\tpanX = 25;\n\t\t\t\t} else if (c == CMDS[PAN_UP25_CMD]) {\n\t\t\t\t\tpanY = -25;\n\t\t\t\t} else if (c == CMDS[PAN_DOWN25_CMD]) {\n\t\t\t\t\tpanY = 25;\n\t\t\t\t} else if (c == CMDS[PAN_LEFT2_CMD]) {\n\t\t\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\t\t\tTrackPlayer.slower();\n\t\t\t\t\t} else if (manualRotationMode) {\n\t\t\t\t\t\tcourseDiff=-5;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanX = -2;\n\t\t\t\t\t}\n\t\t\t\t\tbackLightLevelDiff = -25;\n\t\t\t\t} else if (c == CMDS[PAN_RIGHT2_CMD]) {\n\t\t\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\t\t\tTrackPlayer.faster();\n\t\t\t\t\t} else if (manualRotationMode) {\n\t\t\t\t\t\tcourseDiff=5;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanX = 2;\n\t\t\t\t\t}\n\t\t\t\t\tbackLightLevelDiff = 25;\n\t\t\t\t} else if (c == CMDS[PAN_UP2_CMD]) {\n\t\t\t\t\tif (route!=null && Configuration.getCfgBitState(Configuration.CFGBIT_ROUTE_BROWSING)) {\n\t\t\t\t\t\tRouteInstructions.toNextInstruction(1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanY = -2;\n\t\t\t\t\t}\n\t\t\t\t} else if (c == CMDS[PAN_DOWN2_CMD]) {\n\t\t\t\t\tif (route!=null && Configuration.getCfgBitState(Configuration.CFGBIT_ROUTE_BROWSING)) {\n\t\t\t\t\t\tRouteInstructions.toNextInstruction(-1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanY = 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (backLightLevelDiff !=0 && System.currentTimeMillis() < (lastBackLightOnTime + 2500)) {\n\t\t\t\t\tConfiguration.setCfgBitState(Configuration.CFGBIT_BACKLIGHT_ON, true, false);\n\t\t\t\t\tlastBackLightOnTime = System.currentTimeMillis();\n\t\t\t\t\tConfiguration.addToBackLightLevel(backLightLevelDiff);\n\t\t\t\t\tparent.showBackLightLevel();\n\t\t\t\t} else if (imageCollector != null) {\n\t\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\t\t\t\tif (compassDeviation == 360) {\n\t\t\t\t\t\t\tcompassDeviation = 0;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcompassDeviation += courseDiff;\n\t\t\t\t\t\t\tcompassDeviation %= 360;\n\t\t\t\t\t\t\tif (course < 0) {\n\t\t\t\t\t\t\t\tcourse += 360;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (courseDiff == 360) {\n\t\t\t\t\t\t\tcourse = 0; \n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcourse += courseDiff;\n\t\t\t\t\t\t\tcourse %= 360;\n\t\t\t\t\t\t\tif (course < 0) {\n\t\t\t\t\t\t\t\tcourse += 360;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (panX != 0 || panY != 0) {\n\t\t\t\t\t\t\tgpsRecenter = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\timageCollector.getCurrentProjection().pan(center, panX, panY);\n\t\t\t\t}\n\t\t\t\tgpsRecenter = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[EXIT_CMD]) {\n\t\t\t\tif (Legend.isValid && gpx.isRecordingTrk()) {\n\t\t\t\t\talert(Locale.get(\"trace.RecordMode\"), Locale.get(\"trace.PleaseStopRecording\") , 2500);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (Legend.isValid) {\n\t\t\t\t\tpause();\n\t\t\t\t}\n\t\t\t\tparent.exit();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[START_RECORD_CMD]) {\n\t\t\t\ttry {\n\t\t\t\t\tgpx.newTrk(false);\n\t\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.StartingToRecord\"), 1250);\n\t\t\t\t} catch (RuntimeException e) {\n\t\t\t\t\treceiveMessage(e.getMessage());\n\t\t\t\t}\n\t\t\t\trecordingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[STOP_RECORD_CMD]) {\n\t\t\t\tgpx.saveTrk(false);\n\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.StoppingToRecord\"), 1250);\n\t\t\t\trecordingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MANAGE_TRACKS_CMD]) {\n\t\t\t\tif (gpx.isRecordingTrk() && !gpx.isRecordingTrkSuspended()) {\n\t\t\t\t\talert(Locale.get(\"trace.RecordMode\"), Locale.get(\"trace.YouNeedStopRecording\") , 4000);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t GuiGpx guiGpx = new GuiGpx(this);\n\t\t\t guiGpx.show();\n\t\t\t return;\n\t\t\t}\n\t\t\tif (c == CMDS[REFRESH_CMD]) {\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[CONNECT_GPS_CMD]) {\n\t\t\t\tif (locationProducer == null) {\n\t\t\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\t\t\tTrackPlayer.getInstance().stop();\n\t\t\t\t\t\talert(Locale.get(\"trace.Trackplayer\"), Locale.get(\"trace.PlayingStopped\"), 2500);\n\t\t\t\t\t}\n\t\t\t\t\tThread thread = new Thread(this,\"LocationProducer init\");\n\t\t\t\t\tthread.start();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[DISCONNECT_GPS_CMD]) {\n\t\t\t\tif (locationProducer != null) {\n\t\t\t\t\tlocationProducer.close();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_GPS_CMD]) {\n\t\t\t\tif (isGpsConnected()) {\n\t\t\t\t\tcommandAction(DISCONNECT_GPS_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tcommandAction(CONNECT_GPS_CMD);\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SEARCH_CMD]) {\n\t\t\t\tGuiSearch guiSearch = new GuiSearch(this);\n\t\t\t\tguiSearch.show();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ENTER_WAYP_CMD]) {\n\t\t\t\tif (gpx.isLoadingWaypoints()) {\n\t\t\t\t\tshowAlertLoadingWpt();\n\t\t\t\t} else {\n\t\t\t\t\tGuiWaypointEnter gwpe = new GuiWaypointEnter(this);\n\t\t\t\t\tgwpe.show();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MAN_WAYP_CMD]) {\n\t\t\t\tif (gpx.isLoadingWaypoints()) {\n\t\t\t\t\tshowAlertLoadingWpt();\n\t\t\t\t} else {\n\t\t\t\t\tGuiWaypoint gwp = new GuiWaypoint(this);\n\t\t\t\t\tgwp.show();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MAPFEATURES_CMD]) {\n\t\t\t\tGuiMapFeatures gmf = new GuiMapFeatures(this);\n\t\t\t\tgmf.show();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[OVERVIEW_MAP_CMD]) {\n\t\t\t\tGuiOverviewElements ovEl = new GuiOverviewElements(this);\n\t\t\t\tovEl.show();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SEND_MESSAGE_CMD]) {\n\t\t\t\tGuiSendMessage sendMsg = new GuiSendMessage(this);\n\t\t\t\tsendMsg.show();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[RECORDINGS_CMD]) {\n\t\t\t\tif (recordingsMenu == null) {\n\t\t\t\t\tboolean hasJSR120 = Configuration.hasDeviceJSR120();\n\t\t\t\t\tint noElements = 3;\n\t\t\t\t\tnoElements += 2;\n\t\t\t\t\tif (hasJSR120) {\n\t\t\t\t\t\tnoElements++;\n\t\t\t\t\t}\n\t\t\t\t\tint idx = 0;\n\t\t\t\t\tString[] elements = new String[noElements];\n\t\t\t\t\tif (gpx.isRecordingTrk()) {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StopGpxTracklog\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StartGpxTracklog\");\n\t\t\t\t\t}\n\t\t\t\t\telements[idx++] = Locale.get(\"trace.SaveWaypoint\");\n\t\t\t\t\telements[idx++] = Locale.get(\"trace.EnterWaypoint\");\n\t\t\t\t\telements[idx++] = Locale.get(\"trace.TakePictures\");\n\t\t\t\t\tif (audioRec.isRecording()) {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StopAudioRecording\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StartAudioRecording\");\n\t\t\t\t\t}\n\t\t\t\t\tif (hasJSR120) {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.SendSMSMapPos\");\n\t\t\t\t\t}\n\t\t\t\t\trecordingsMenu = new List(Locale.get(\"trace.Recordings\"),Choice.IMPLICIT,elements,null);\n\t\t\t\t\trecordingsMenu.addCommand(CMDS[OK_CMD]);\n\t\t\t\t\trecordingsMenu.addCommand(CMDS[BACK_CMD]);\n\t\t\t\t\trecordingsMenu.setSelectCommand(CMDS[OK_CMD]);\n\t\t\t\t\tparent.show(recordingsMenu);\n\t\t\t\t\trecordingsMenu.setCommandListener(this);\n\t\t\t\t}\n\t\t\t\tif (recordingsMenu != null) {\n\t\t\t\t\trecordingsMenu.setSelectedIndex(0, true);\n\t\t\t\t\tparent.show(recordingsMenu);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTINGS_CMD]) {\n\t\t\t\tif (routingsMenu == null) {\n\t\t\t\t\tString[] elements = new String[4];\n\t\t\t\t\tif (routeCalc || route != null) {\n\t\t\t\t\t\telements[0] = Locale.get(\"trace.StopRouting\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\telements[0] = Locale.get(\"trace.CalculateRoute\");\n\t\t\t\t\t}\n\t\t\t\t\telements[1] = Locale.get(\"trace.SetDestination\");\n\t\t\t\t\telements[2] = Locale.get(\"trace.ShowDestination\");\n\t\t\t\t\telements[3] = Locale.get(\"trace.ClearDestination\");\n\t\t\t\t\troutingsMenu = new List(Locale.get(\"trace.Routing2\"), Choice.IMPLICIT, elements, null);\n\t\t\t\t\troutingsMenu.addCommand(CMDS[OK_CMD]);\n\t\t\t\t\troutingsMenu.addCommand(CMDS[BACK_CMD]);\n\t\t\t\t\troutingsMenu.setSelectCommand(CMDS[OK_CMD]);\n\t\t\t\t\troutingsMenu.setCommandListener(this);\n\t\t\t\t}\n\t\t\t\tif (routingsMenu != null) {\n\t\t\t\t\troutingsMenu.setSelectedIndex(0, true);\n\t\t\t\t\tparent.show(routingsMenu);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SAVE_WAYP_CMD]) {\n\t\t\t\tif (gpx.isLoadingWaypoints()) {\n\t\t\t\t\tshowAlertLoadingWpt();\n\t\t\t\t} else {\n\t\t\t\t\tPositionMark posMark = null;\n\t\t\t\t\tif (gpsRecenter) {\n\t\t\t\t\t\tposMark = new PositionMark(center.radlat, center.radlon,\n\t\t\t\t\t\t\t\t(int)pos.altitude, pos.timeMillis,\n\t\t\t\t\t\t\t\t (byte)-1, (byte)-1,\n\t\t\t\t\t\t\t\t (byte)-1, (byte)-1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tposMark = new PositionMark(center.radlat, center.radlon,\n\t\t\t\t\t\t\t\tPositionMark.INVALID_ELEVATION,\n\t\t\t\t\t\t\t\tpos.timeMillis, (byte)-1,\n\t\t\t\t\t\t\t\t (byte)-1, (byte)-1,\n\t\t\t\t\t\t\t\t (byte)-1);\n\t\t\t\t\t}\n\t\t\t\t\t\tshowGuiWaypointSave(posMark);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ONLINE_INFO_CMD]) {\n\t\t\t\t\tPosition oPos = new Position(center.radlat, center.radlon,\n\t\t\t\t\t\t\t0.0f, 0.0f, 0.0f, 0, 0);\n\t\t\t\t\tGuiWebInfo gWeb = new GuiWebInfo(this, oPos, pc);\n\t\t\t\t\tgWeb.show();\n\t\t\t\t\talert(Locale.get(\"trace.NoOnlineCapa\"),\n\t\t\t\t\t Locale.get(\"trace.SetAppGeneric\") +\n\t\t\t\t\t Locale.get(\"trace.PropertiesFile\"),\n\t\t\t\t\t\t\tAlert.FOREVER);\n\t\t\t}\n\t\t\tif (c == CMDS[BACK_CMD]) {\n\t\t\t\tshow();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[OK_CMD]) {\n\t\t\t\tif (d == recordingsMenu) {\n\t\t\t\t\t switch (recordingsMenu.getSelectedIndex()) {\n\t\t\t case 0: {\n\t\t \t\t\t\tif ( gpx.isRecordingTrk() ) {\n\t\t \t\t\t\t\tcommandAction(STOP_RECORD_CMD);\n\t\t\t\t\t\t\t\tif (! Configuration.getCfgBitState(Configuration.CFGBIT_GPX_ASK_TRACKNAME_STOP)) {\n\t\t\t\t\t\t\t \tshow();\n\t\t\t\t\t\t\t\t}\n\t\t \t\t\t\t} else {\n\t\t \t\t\t\t\tcommandAction(START_RECORD_CMD);\n\t\t\t\t\t\t\t\tif (! Configuration.getCfgBitState(Configuration.CFGBIT_GPX_ASK_TRACKNAME_START)) {\n\t\t\t\t\t\t\t \tshow();\n\t\t\t\t\t\t\t\t}\n\t\t \t\t\t\t}\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 1: {\n\t\t\t \tcommandAction(SAVE_WAYP_CMD);\n\t\t\t\t\t\t\tbreak;\n\t\t\t }\n\t\t\t case 2: {\n\t\t\t \tcommandAction(ENTER_WAYP_CMD);\n\t\t\t\t\t\t\tbreak;\n\t\t\t }\n\t\t\t case 3: {\n\t\t\t \tcommandAction(CAMERA_CMD);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 4: {\n\t\t\t \tshow();\n\t\t\t \tcommandAction(TOGGLE_AUDIO_REC);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 5: {\n\t\t\t \tcommandAction(SEND_MESSAGE_CMD);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 3: {\n\t\t\t \tcommandAction(SEND_MESSAGE_CMD);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t\tif (d == routingsMenu) {\n\t\t\t\t\tshow();\n\t\t\t\t\tswitch (routingsMenu.getSelectedIndex()) {\n\t\t\t\t\tcase 0: {\n\t\t\t\t\t\tif (routeCalc || route != null) {\n\t\t\t\t\t\t\tcommandAction(ROUTING_STOP_CMD);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcommandAction(ROUTING_START_WITH_MODE_SELECT_CMD);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 1: {\n\t\t\t\t\t\tcommandAction(SET_DEST_CMD);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 2: {\n\t\t\t\t\t\tcommandAction(SHOW_DEST_CMD);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 3: {\n\t\t\t\t\t\tcommandAction(CLEAR_DEST_CMD);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[CAMERA_CMD]) {\n\t\t\t\ttry {\n\t\t\t\t\tClass GuiCameraClass = Class.forName(\"de.ueller.midlet.gps.GuiCamera\");\n\t\t\t\t\tObject GuiCameraObject = GuiCameraClass.newInstance();\n\t\t\t\t\tGuiCameraInterface cam = (GuiCameraInterface)GuiCameraObject;\n\t\t\t\t\tcam.init(this);\n\t\t\t\t\tcam.show();\n\t\t\t\t} catch (ClassNotFoundException cnfe) {\n\t\t\t\t\tlogger.exception(Locale.get(\"trace.YourPhoneNoCamSupport\"), cnfe);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_AUDIO_REC]) {\n\t\t\t\tif (audioRec.isRecording()) {\n\t\t\t\t\taudioRec.stopRecord();\n\t\t\t\t} else {\n\t\t\t\t\taudioRec.startRecorder();\n\t\t\t\t}\n\t\t\t\trecordingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_TOGGLE_CMD]) {\n\t\t\t\tif (routeCalc || route != null) {\n\t\t\t\t\tcommandAction(ROUTING_STOP_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tcommandAction(ROUTING_START_WITH_MODE_SELECT_CMD);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_START_WITH_MODE_SELECT_CMD]) {\n\t\t\t\tgpsRecenter = true;\n\t\t\t\tgpsRecenterInvalid = true;\n\t\t\t\tgpsRecenterStale = true;\n\t\t\t\tGuiRoute guiRoute = new GuiRoute(this, false);\n\t\t\t\tif (Configuration.getCfgBitSavedState(Configuration.CFGBIT_DONT_ASK_FOR_ROUTING_OPTIONS)) {\n\t\t\t\t\tcommandAction(ROUTING_START_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tguiRoute.show();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_START_CMD]) {\n\t\t\t\tif (! routeCalc || RouteLineProducer.isRunning()) {\n\t\t\t\t\trouteCalc = true;\n\t\t\t\t\tif (Configuration.getContinueMapWhileRouteing() != Configuration.continueMap_Always ) {\n\t \t\t\t\t stopImageCollector();\n\t\t\t\t\t}\n\t\t\t\t\tRouteInstructions.resetOffRoute(route, center);\n\t\t\t\t\tRoutePositionMark routeSource = new RoutePositionMark(center.radlat, center.radlon);\n\t\t\t\t\tlogger.info(\"Routing source: \" + routeSource);\n\t\t\t\t\trouteNodes=new Vector();\n\t\t\t\t\trouteEngine = new Routing(tiles, this);\n\t\t\t\t\trouteEngine.solve(routeSource, dest);\n\t\t\t\t}\n\t\t\t\troutingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_STOP_CMD]) {\n\t\t\t\tNoiseMaker.stopPlayer();\n\t\t\t\tif (routeCalc) {\n\t\t\t\t\tif (routeEngine != null) {\n\t\t\t\t\t\trouteEngine.cancelRouting();\n\t\t\t\t\t}\n\t\t\t\t\talert(Locale.get(\"trace.RouteCalculation\"), Locale.get(\"trace.Cancelled\"), 1500);\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"trace.Routing\"), Locale.get(\"generic.Off\"), 750);\n\t\t\t\t}\n\t\t\t\tendRouting();\n\t\t\t\troutingsMenu = null; \n\t\t\t\tsynchronized (this) {\n\t\t\t\t\tif (imageCollector != null) {\n\t\t\t\t\t\timageCollector.newDataReady();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\troutingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ZOOM_IN_CMD]) {\n\t\t\t\tscale = scale / 1.5f;\n\t\t\t\tautoZoomed = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ZOOM_OUT_CMD]) {\n\t\t\t\tscale = scale * 1.5f;\n\t\t\t\tautoZoomed = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MANUAL_ROTATION_MODE_CMD]) {\n\t\t\t\tmanualRotationMode = !manualRotationMode;\n\t\t\t\tif (manualRotationMode) {\n\t\t\t\t\tif (hasPointerEvents()) {\n\t\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"trace.ChangeCourse\"), 3000);\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"trace.ChangeCourseWithLeftRightKeys\"), 3000);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"generic.Off\"), 750);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_OVERLAY_CMD]) {\n\t\t\t\tshowAddons++;\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_BACKLIGHT_CMD]) {\n\t\t\t\tConfiguration.setCfgBitState(Configuration.CFGBIT_BACKLIGHT_ON,\n\t\t\t\t\t\t\t\t\t!(Configuration.getCfgBitState(Configuration.CFGBIT_BACKLIGHT_ON)),\n\t\t\t\t\t\t\t\t\tfalse);\n\t\t\t\tlastBackLightOnTime = System.currentTimeMillis();\n\t\t\t\tparent.showBackLightLevel();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_FULLSCREEN_CMD]) {\n\t\t\t\tboolean fullScreen = !Configuration.getCfgBitState(Configuration.CFGBIT_FULLSCREEN);\n\t\t\t\tConfiguration.setCfgBitState(Configuration.CFGBIT_FULLSCREEN, fullScreen, false);\n\t\t\t\tsetFullScreenMode(fullScreen);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_MAP_PROJ_CMD]) {\n\t\t\t\tif (manualRotationMode) {\n\t\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\t\t\t\tcompassDeviation = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcourse = 0;\n\t\t\t\t\t}\n\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"trace.ManualToNorth\"), 750);\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"guidiscover.MapProjection\"), ProjFactory.nextProj(), 750);\n\t\t\t\t}\n\t\t\t\tsynchronized (this) {\n\t\t\t\t\tif (imageCollector != null) {\n\t\t\t\t\t\timageCollector.newDataReady();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_KEY_LOCK_CMD]) {\n\t\t\t\tkeyboardLocked = !keyboardLocked;\n\t\t\t\tif (keyboardLocked) {\n\t\t\t\t\tkeyPressed(0);\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"trace.GpsMid\"), hasPointerEvents() ? Locale.get(\"trace.KeysAndTouchscreenUnlocked\") : Locale.get(\"trace.KeysUnlocked\"), 1000);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_RECORDING_CMD]) {\n\t\t\t\tif ( gpx.isRecordingTrk() ) {\n\t\t\t\t\tcommandAction(STOP_RECORD_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tcommandAction(START_RECORD_CMD);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_RECORDING_SUSP_CMD]) {\n\t\t\t\tif (gpx.isRecordingTrk()) {\n\t\t\t\t\tif ( gpx.isRecordingTrkSuspended() ) {\n\t\t\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.ResumingRecording\"), 1000);\n\t\t\t\t\t\tgpx.resumeTrk();\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.SuspendingRecording\"), 1000);\n\t\t\t\t\t\tgpx.suspendTrk();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[RECENTER_GPS_CMD]) {\n\t\t\t\tgpsRecenter = true;\n\t\t\t\tgpsRecenterInvalid = true;\n\t\t\t\tgpsRecenterStale = true;\n\t\t\t\tautoZoomed = true;\n\t\t\t\tif (pos.latitude != 0.0f) {\n\t\t\t\t\treceivePosition(pos);\n\t\t\t\t}\n\t\t\t\tnewDataReady();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SHOW_DEST_CMD]) {\n\t\t\t\tif (dest != null) {\n\t\t\t\t\tgpsRecenter = false;\n\t\t\t\t\tprevPositionNode = center.copy(); \n\t\t\t\t\tcenter.setLatLonRad(dest.lat, dest.lon);\t\t\t\t\t\t\n\t\t\t\t\tmovedAwayFromDest = false;\n\t\t\t\t\tupdatePosition();\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\talert(Locale.get(\"trace.ShowDestination\"), Locale.get(\"trace.DestinationNotSpecifiedYet\"), 3000);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SHOW_PREVIOUS_POSITION_CMD]) {\n\t\t\t\tif (prevPositionNode != null) {\n\t\t\t\t\tgpsRecenter = false;\n\t\t\t\t\tcenter.setLatLon(prevPositionNode);\t\t\t\t\t\t\n\t\t\t\t\tupdatePosition();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (c == CMDS[DATASCREEN_CMD]) {\n\t\t\t\tshowNextDataScreen(DATASCREEN_NONE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ICON_MENU] && Configuration.getCfgBitState(Configuration.CFGBIT_ICONMENUS)) {\n\t\t\t\tshowIconMenu();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SETUP_CMD]) {\n\t\t\t\tnew GuiDiscover(parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ABOUT_CMD]) {\n\t\t\t\tnew Splash(parent, GpsMid.initDone);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[CELLID_LOCATION_CMD]) {\n\t\t\t\tif (Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_SECELL && locationProducer != null) {\n\t\t\t\t\t\tlocationProducer.triggerPositionUpdate();\n\t\t\t\t\t\tnewDataReady();\n\t\t\t\t} else {\n\t\t\t\t\tif (cellIDLocationProducer == null) {\n\t\t\t\t\t\tcellIDLocationProducer = new SECellID();\n\t\t\t\t\t\tif (cellIDLocationProducer != null && !cellIDLocationProducer.init(this)) {\n\t\t\t\t\t\t\tlogger.info(\"Failed to initialise CellID location producer\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (cellIDLocationProducer != null) {\n\t\t\t\t\t\tcellIDLocationProducer.triggerPositionUpdate();\n\t\t\t\t\t\tnewDataReady();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MANUAL_LOCATION_CMD]) {\n\t\t\t\tPosition setpos = new Position(center.radlat / MoreMath.FAC_DECTORAD,\n \t\t\t\t\t\t\t\tcenter.radlon / MoreMath.FAC_DECTORAD,\n\t\t\t\t\t\t\t\t PositionMark.INVALID_ELEVATION, 0.0f, 0.0f, 1,\n\t\t\t\t\t\t\t System.currentTimeMillis(), Position.TYPE_MANUAL);\n\t\t\t\tgpsRecenter = true;\n\t\t\t\tautoZoomed = true;\n\t\t\t\treceivePosition(setpos);\n\t\t\t\treceiveStatus(LocationMsgReceiver.STATUS_MANUAL, 0);\n\t\t\t\tnewDataReady();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (! routeCalc) {\n\t\t\t\tif (c == CMDS[RETRIEVE_XML]) {\n\t\t\t\t\tif (Legend.enableEdits) {\n\t\t\t\t\t\tif ((pc.actualWay != null) && (getUrl(pc.actualWay.urlIdx) != null)) {\n\t\t\t\t\t\t\tparent.alert (\"Url\", \"Url: \" + getUrl(pc.actualWay.urlIdx), Alert.FOREVER);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pc.actualWay != null) && (pc.actualWay instanceof EditableWay)) {\n\t\t\t\t\t\t\tEditableWay eway = (EditableWay)pc.actualWay;\n\t\t\t\t\t\t\tGUIosmWayDisplay guiWay = new GUIosmWayDisplay(eway, pc.actualSingleTile, this);\n\t\t\t\t\t\t\tguiWay.show();\n\t\t\t\t\t\t\tguiWay.refresh();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparent.alert(\"Editing\", \"Editing support was not enabled in Osm2GpsMid\", Alert.FOREVER);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[RETRIEVE_NODE]) {\n\t\t\t\t\tif (Legend.enableEdits) {\n\t\t\t\t\t\tGuiOSMPOIDisplay guiNode = new GuiOSMPOIDisplay(-1, null,\n\t\t\t\t\t\t\t\tcenter.radlat, center.radlon, this);\n\t\t\t\t\t\tguiNode.show();\n\t\t\t\t\t\tguiNode.refresh();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(Locale.get(\"trace.EditingIsNotEnabled\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[EDIT_ADDR_CMD]) {\n\t\t\t\t\tif (Legend.enableEdits) {\n\t\t\t\t\t\tString streetName = \"\";\n\t\t\t\t\t\tif ((pc != null) && (pc.actualWay != null)) {\n\t\t\t\t\t\t\tstreetName = getName(pc.actualWay.nameIdx);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tGuiOSMAddrDisplay guiAddr = new GuiOSMAddrDisplay(-1, streetName, null,\n\t\t\t\t\t\t\t\tcenter.radlat, center.radlon, this);\n\t\t\t\t\t\tguiAddr.show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(Locale.get(\"trace.EditingIsNotEnabled\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[RETRIEVE_XML] || c == CMDS[RETRIEVE_NODE] || c == CMDS[EDIT_ADDR_CMD]) {\n\t\t\t\t\talert(\"No online capabilites\",\n\t\t\t\t\t Locale.get(\"trace.SetAppGeneric\") +\n\t\t\t\t\t Locale.get(\"trace.PropertiesFile\"),\n\t\t\t\t\t\tAlert.FOREVER);\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[SET_DEST_CMD]) {\n\t\t\t\t\tRoutePositionMark pm1 = new RoutePositionMark(center.radlat, center.radlon);\n\t\t\t\t\tsetDestination(pm1);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[CLEAR_DEST_CMD]) {\n\t\t\t\t\tsetDestination(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\talert(Locale.get(\"trace.Error\"), Locale.get(\"trace.CurrentlyInRouteCalculation\"), 2000);\n\t\t\t}\n\t\t} catch (Exception e) {\n \t\t\tlogger.exception(Locale.get(\"trace.InTraceCommandAction\"), e);\n\t\t}\n\t}\n\tprivate void startImageCollector() throws Exception {\n\t\tlogger.info(\"Starting ImageCollector\");\n\t\tImages images = new Images();\n\t\tpc = new PaintContext(this, images);\n\t\timageCollector = new ImageCollector(tiles, this.getWidth(), this.getHeight(), this, images);\n\t\tpc.center = center.copy();\n\t\tpc.scale = scale;\n\t\tpc.xSize = this.getWidth();\n\t\tpc.ySize = this.getHeight();\n\t}\n\tprivate void stopImageCollector(){\n\t\tlogger.info(\"Stopping ImageCollector\");\n\t\tcleanup();\n\t\tif (imageCollector != null ) {\n\t\t\timageCollector.stop();\n\t\t\timageCollector=null;\n\t\t}\n\t\tSystem.gc();\n\t}\n\tpublic void startup() throws Exception {\n\t\tnamesThread = new Names();\n\t\turlsThread = new Urls();\n\t\tnew DictReader(this);\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_AUTO_START_GPS)) {\n\t\t\tThread thread = new Thread(this, \"Trace\");\n\t\t\tthread.start();\n\t\t}\n\t\ttileReader = new QueueDataReader(this);\n\t\tdictReader = new QueueDictReader(this);\n\t\tthis.gpx = new Gpx();\n\t\tthis.audioRec = new AudioRecorder();\n\t\tsetDict(gpx, (byte)5);\n\t\tstartImageCollector();\n\t\trecreateTraceLayout();\n\t}\n\tpublic void shutdown() {\n\t\tif (gpx != null) {\n\t\t\tgpx.saveTrk(true);\n\t\t}\n\t\tlogger.debug(\"Shutdown: stopImageCollector\");\n\t\tstopImageCollector();\n\t\tif (namesThread != null) {\n\t\t\tlogger.debug(\"Shutdown: namesThread\");\n\t\t\tnamesThread.stop();\n\t\t\tnamesThread = null;\n\t\t}\n\t\tif (urlsThread != null) {\n\t\t\turlsThread.stop();\n\t\t\turlsThread = null;\n\t\t}\n\t\tif (dictReader != null) {\n\t\t\tlogger.debug(\"Shutdown: dictReader\");\n\t\t\tdictReader.shutdown();\n\t\t\tdictReader = null;\n\t\t}\n\t\tif (tileReader != null) {\n\t\t\tlogger.debug(\"Shutdown: tileReader\");\n\t\t\ttileReader.shutdown();\n\t\t\ttileReader = null;\n\t\t}\n\t\tif (locationProducer != null) {\n\t\t\tlogger.debug(\"Shutdown: locationProducer\");\n\t\t\tlocationProducer.close();\n\t\t}\n\t\tif (TrackPlayer.isPlaying) {\n\t\t\tlogger.debug(\"Shutdown: TrackPlayer\");\n\t\t\tTrackPlayer.getInstance().stop();\n\t\t}\n\t}\n\tpublic void sizeChanged(int w, int h) {\n\t\tupdateLastUserActionTime();\n\t\tif (imageCollector != null) {\n\t\t\tlogger.info(\"Size of Canvas changed to \" + w + \"|\" + h);\n\t\t\tstopImageCollector();\n\t\t\ttry {\n\t\t\t\tstartImageCollector();\n\t\t\t\timageCollector.resume();\n\t\t\t\timageCollector.newDataReady();\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.exception(Locale.get(\"trace.CouldNotReinitialiseImageCollector\"), e);\n\t\t\t}\n\t\t\tupdatePosition();\n\t\t}\n\t\ttl = new TraceLayout(0, 0, w, h);\n\t}\n\tprotected void paint(Graphics g) {\n\t\tlogger.debug(\"Drawing Map screen\");\n\t\ttry {\n\t\t\tint yc = 1;\n\t\t\tint la = 18;\n\t\t\tgetPC();\n\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_BACKGROUND]);\n\t\t\tg.fillRect(0, 0, this.getWidth(), this.getHeight());\n\t\t\tpc.g = g;\n\t\t\tif (imageCollector != null) {\n\t\t\t\tNode drawnCenter = imageCollector.paint(pc);\n\t\t\t\tif (route != null && ri != null && pc.lineP2 != null) {\n\t\t\t\t\tpc.getP().forward(drawnCenter.radlat, drawnCenter.radlon, pc.lineP2);\n\t\t\t\t\tint maxAllowedMapMoveOffs = Math.min(pc.xSize/2, pc.ySize/2);\n\t\t\t\t\tif ( Math.abs(pc.lineP2.x - pc.getP().getImageCenter().x) < maxAllowedMapMoveOffs\n\t\t\t\t\t\t &&\n\t\t\t\t\t\t Math.abs(pc.lineP2.y - pc.getP().getImageCenter().y) < maxAllowedMapMoveOffs\n\t\t\t\t\t) {\n\t\t\t\t\t\tri.showRoute(pc, drawnCenter,imageCollector.xScreenOverscan,imageCollector.yScreenOverscan);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttl.ele[TraceLayout.WAYNAME].setText(\" \");\n\t\t\t}\n\t\t\tif (dest != null) {\n\t\t\t\tfloat distance = ProjMath.getDistance(dest.lat, dest.lon, center.radlat, center.radlon);\n\t\t\t\tatDest = (distance < 25);\n\t\t\t\tif (atDest) {\n\t\t\t\t\tif (movedAwayFromDest && Configuration.getCfgBitState(Configuration.CFGBIT_SND_DESTREACHED)) {\n\t\t\t\t\t\tGpsMid.mNoiseMaker.playSound(RouteSyntax.getInstance().getDestReachedSound(), (byte) 7, (byte) 1);\n\t\t\t\t\t}\n\t\t\t\t} else if (!movedAwayFromDest) {\n\t\t\t\t\tmovedAwayFromDest = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tspeeding = false;\n\t\t\tint maxSpeed = 0;\n\t\t\tif (gpsRecenter && actualSpeedLimitWay != null) {\n\t\t\t\tmaxSpeed = actualSpeedLimitWay.getMaxSpeed();\n\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_MAXSPEED_WINTER)\n \t\t&& (actualSpeedLimitWay.getMaxSpeedWinter() > 0)) {\n\t\t\t\t\tmaxSpeed = actualSpeedLimitWay.getMaxSpeedWinter();\n }\n\t\t\t\tif (maxSpeed != 0 && speed > (maxSpeed + Configuration.getSpeedTolerance()) ) {\n\t\t\t\t\tspeeding = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (speeding && Configuration.getCfgBitState(Configuration.CFGBIT_SPEEDALERT_SND)) {\n\t\t\t\tif ( (System.currentTimeMillis() - lastTimeOfSpeedingSound) > 10000 ) {\n\t\t\t\t\tlastTimeOfSpeedingSound = System.currentTimeMillis();\n\t\t\t\t\tGpsMid.mNoiseMaker.immediateSound(RouteSyntax.getInstance().getSpeedLimitSound());\n\t\t\t\t}\n\t\t\t}\n\t\t\tg.setColor(Legend.COLOR_MAP_TEXT);\n\t\t\tswitch (showAddons) {\n\t\t\tcase 1:\n\t\t\t\tyc = showMemory(g, yc, la);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tyc = showConnectStatistics(g, yc, la);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tshowAddons = 0;\n\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_SCALE_BAR)) {\n\t\t\t\t\tif (pc != null) {\n\t\t\t\t\t\ttl.calcScaleBarWidth(pc);\n\t\t\t\t\t\ttl.ele[TraceLayout.SCALEBAR].setText(\" \");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetPointOfTheCompass();\n\t\t\t}\n\t\t\tshowMovement(g);\n\t\t\tLayoutElement eSolution = tl.ele[TraceLayout.SOLUTION];\n\t\t\tLayoutElement eRecorded = tl.ele[TraceLayout.RECORDED_COUNT];\n\t\t\tif (gpx.isRecordingTrk()) {\n\t\t\t\tif (gpx.isRecordingTrkSuspended()) {\n\t\t\t\t\teRecorded.setColor(Legend.COLORS[Legend.COLOR_RECORDING_SUSPENDED_TEXT]); \n\t\t\t\t} else {\n\t\t\t\t\teRecorded.setColor(Legend.COLORS[Legend.COLOR_RECORDING_ON_TEXT]); \n\t\t\t\t}\n\t\t\t\teRecorded.setText(gpx.getTrkPointCount() + Locale.get(\"trace.r\"));\n\t\t\t}\n\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\teSolution.setText(Locale.get(\"trace.Replay\"));\n\t\t\t} else {\n\t\t\t\tif (locationProducer == null && !(solution == LocationMsgReceiver.STATUS_CELLID ||\n\t\t\t\t\t\t\t\t\t\t solution == LocationMsgReceiver.STATUS_MANUAL)) {\n\t\t\t\t\teSolution.setText(Locale.get(\"solution.Off\"));\n\t\t\t\t} else {\n\t\t\t\t\teSolution.setText(solutionStr);\n\t\t\t\t}\n\t\t\t}\n\t\t\tLayoutElement e = tl.ele[TraceLayout.CELLID];\n\t\t\tif (SECellLocLogger.isCellIDLogging() > 0) {\n\t\t\t\tif (SECellLocLogger.isCellIDLogging() == 2) {\n\t\t\t\t\te.setColor(Legend.COLORS[Legend.COLOR_CELLID_LOG_ON_TEXT]); \n\t\t\t\t} else {\n\t\t\t\t\te.setColor(Legend.COLORS[Legend.COLOR_CELLID_LOG_ON_ATTEMPTING_TEXT]); \n\t\t\t\t}\n\t\t\t\te.setText(Locale.get(\"trace.cellIDs\"));\n\t\t\t}\n\t\t\te = tl.ele[TraceLayout.AUDIOREC];\n\t\t\tif (audioRec.isRecording()) {\n\t\t\t\te.setColor(Legend.COLORS[Legend.COLOR_AUDIOREC_TEXT]); \n\t\t\t\te.setText(Locale.get(\"trace.AudioRec\"));\n\t\t\t}\n\t\t\tif (pc != null) {\n\t\t\t\tshowDestination(pc);\n\t\t\t}\n\t\t\tif (speed > 0 &&\n\t\t\t\t\tConfiguration.getCfgBitState(Configuration.CFGBIT_SHOW_SPEED_IN_MAP)) {\n\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_METRIC)) {\n\t\t\t\t\ttl.ele[TraceLayout.SPEED_CURRENT].setText(\" \" + Integer.toString(speed) + Locale.get(\"trace.kmh\"));\n\t\t\t\t} else {\n\t\t\t\t\ttl.ele[TraceLayout.SPEED_CURRENT].setText(\" \" + Integer.toString((int)(speed / 1.609344f)) + \" mph\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_ALTITUDE_IN_MAP)\n\t\t\t\t&& locationProducer != null\n\t\t\t\t&& LocationMsgReceiverList.isPosValid(solution)\n\t\t\t) {\n\t\t\t\ttl.ele[TraceLayout.ALTITUDE].setText(showDistance(altitude, DISTANCE_ALTITUDE));\n\t\t\t}\n\t\t\tif (dest != null && (route == null || (!RouteLineProducer.isRouteLineProduced() && !RouteLineProducer.isRunning()) ) \n\t\t\t\t&& Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_AIR_DISTANCE_IN_MAP)) {\n\t\t\t\te = Trace.tl.ele[TraceLayout.ROUTE_DISTANCE];\n\t\t\t\te.setBackgroundColor(Legend.COLORS[Legend.COLOR_RI_DISTANCE_BACKGROUND]);\n\t\t\t\tdouble distLine = ProjMath.getDistance(center.radlat, center.radlon, dest.lat, dest.lon);\n\t\t\t\te.setText(Locale.get(\"trace.Air\") + showDistance((int) distLine, DISTANCE_AIR));\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_CLOCK_IN_MAP)) {\n\t\t\t\te = tl.ele[TraceLayout.CURRENT_TIME]; \n\t\t\t\te.setText(DateTimeTools.getClock(System.currentTimeMillis(), true));\n\t\t\t\ttl.ele[TraceLayout.ROUTE_OFFROUTE].setVRelative(e);\n\t\t\t}\n\t\t\tsetSpeedingSign(maxSpeed);\n\t\t\tif (hasPointerEvents()) {\n\t\t\t\ttl.ele[TraceLayout.ZOOM_IN].setText(\"+\");\n\t\t\t\ttl.ele[TraceLayout.ZOOM_OUT].setText(\"-\");\n\t\t\t\ttl.ele[TraceLayout.RECENTER_GPS].setText(\"|\");\n\t\t\t\te = tl.ele[TraceLayout.SHOW_DEST];\n\t\t\t\tif (atDest && prevPositionNode != null) {\n\t\t\t\t\te.setText(\"<\");\n\t\t\t\t\te.setActionID(SHOW_PREVIOUS_POSITION_CMD);\n\t\t\t\t} else {\n\t\t\t\t\te.setText(\">\");\n\t\t\t\t\te.setActionID(SHOW_DEST_CMD + (Trace.SET_DEST_CMD << 16) );\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\te = tl.ele[TraceLayout.TITLEBAR];\n\t\t\tif (currentTitleMsgOpenCount != 0) {\n\t\t\t\te.setText(currentTitleMsg);\n\t\t\t\tsynchronized (this) {\n\t\t\t\t\tif (setTitleMsgTimeout != 0) {\n\t\t\t\t\t\tTimerTask timerT = new TimerTask() {\n\t\t\t\t\t\t\tpublic synchronized void run() {\n\t\t\t\t\t\t\t\tcurrentTitleMsgOpenCount--;\n\t\t\t\t\t\t\t\tlastTitleMsg = currentTitleMsg;\n\t\t\t\t\t\t\t\tif (currentTitleMsgOpenCount == 0) {\n\t\t\t\t\t\t\t\t\tlogger.debug(\"clearing title\");\n\t\t\t\t\t\t\t\t\trepaint();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tGpsMid.getTimer().schedule(timerT, setTitleMsgTimeout);\n\t\t\t\t\t\tsetTitleMsgTimeout = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttl.paint(g);\n\t\t\tif (currentAlertsOpenCount > 0) {\n\t\t\t\tshowCurrentAlert(g);\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tlogger.silentexception(\"Unhandled exception in the paint code\", e);\n\t\t}\n\t}\n\tpublic void showGuiWaypointSave(PositionMark posMark) {\n \tif (guiWaypointSave == null) {\n \t\tguiWaypointSave = new GuiWaypointSave(this);\n \t}\n \tif (guiWaypointSave != null) {\n \t\tguiWaypointSave.setData(posMark);\n \t\tguiWaypointSave.show();\n \t}\n\t}\n\tprivate void showAlertLoadingWpt() {\n\t\talert(\"Way points\", \"Way points are not ready yet.\", 3000);\n\t}\n\tprivate void showCurrentAlert(Graphics g) {\n\t\tFont font = g.getFont();\n\t\tFont titleFont = Font.getFont(font.getFace(), Font.STYLE_BOLD, font.getSize());\n\t\tint fontHeight = font.getHeight();\n\t\tint y = titleFont.getHeight() + 2 + fontHeight;\n\t\tint extraWidth = font.charWidth('W');\n\t\tint alertWidth = titleFont.stringWidth(currentAlertTitle);\n\t\tint maxWidth = getWidth() - extraWidth;\n\t\tfor (int i = 0; i <= 1; i++) {\n\t\t\tint nextSpaceAt = 0;\n\t\t\tint prevSpaceAt = 0;\n\t\t\tint start = 0;\n\t\t\tdo {\n\t\t\t\tint width = 0;\n\t\t\t\twhile (width < maxWidth && nextSpaceAt <= currentAlertMessage.length() ) {\n\t\t\t\t\tprevSpaceAt = nextSpaceAt;\n\t\t\t\t\tnextSpaceAt = currentAlertMessage.indexOf(' ', nextSpaceAt);\n\t\t\t\t\tif (nextSpaceAt == -1) {\n\t\t\t\t\t\tnextSpaceAt = currentAlertMessage.length();\n\t\t\t\t\t}\n\t\t\t\t\twidth = font.substringWidth(currentAlertMessage, start, nextSpaceAt - start);\n\t\t\t\t\tnextSpaceAt++;\n\t\t\t\t}\n\t\t\t\tnextSpaceAt--;\n\t\t\t\twhile (width > maxWidth) {\n\t\t\t\t\tif (prevSpaceAt > start && nextSpaceAt > prevSpaceAt) {\n\t\t\t\t\t\tnextSpaceAt = prevSpaceAt;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextSpaceAt--;\n\t\t\t\t\t}\n\t\t\t\t\twidth = font.substringWidth(currentAlertMessage, start, nextSpaceAt - start);\n\t\t\t\t}\n\t\t\t\tif (alertWidth < width ) {\n\t\t\t\t\talertWidth = width;\n\t\t\t\t}\n\t\t\t\tif (i==1) {\n\t\t\t\t\tg.drawSubstring(currentAlertMessage, start, nextSpaceAt - start,\n\t\t\t\t\t\t\tgetWidth()/2, y, Graphics.TOP|Graphics.HCENTER);\n\t\t\t\t}\n\t\t\t\ty += fontHeight;\n\t\t\t\tstart = nextSpaceAt;\n\t\t\t} while (nextSpaceAt < currentAlertMessage.length() );\n\t\t\tif (i == 0) {\n\t\t\t\talertWidth += extraWidth;\n\t\t\t\tint alertHeight = y;\n\t\t\t\tint alertTop = (getHeight() - alertHeight) /2;\n\t\t\t\tint alertLeft = (getWidth() - alertWidth) / 2;\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_BACKGROUND]);\n\t\t\t\tg.fillRect(alertLeft, alertTop, alertWidth, alertHeight);\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_TITLE_BACKGROUND]);\n\t\t\t\tg.fillRect(alertLeft, alertTop, alertWidth, fontHeight + 3);\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_BORDER]);\n\t\t\t\tg.setStrokeStyle(Graphics.SOLID);\n\t\t\t\tg.drawRect(alertLeft, alertTop, alertWidth, fontHeight + 3); \n\t\t\t\tg.drawRect(alertLeft, alertTop, alertWidth, alertHeight); \n\t\t\t\ty = alertTop + 2; \n\t\t\t\tg.setFont(titleFont);\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_TEXT]);\n\t\t\t\tg.drawString(currentAlertTitle, getWidth()/2, y , Graphics.TOP|Graphics.HCENTER);\n\t\t\t\tg.setFont(font);\n\t\t\t\ty += (fontHeight * 3 / 2);\n\t\t\t}\n\t\t} \n\t\tsynchronized (this) {\n\t\t\tif (setAlertTimeout != 0) {\n\t\t\t\tTimerTask timerT = new TimerTask() {\n\t\t\t\t\tpublic synchronized void run() {\n\t\t\t\t\t\tcurrentAlertsOpenCount--;\n\t\t\t\t\t\tif (currentAlertsOpenCount == 0) {\n\t\t\t\t\t\t\tlogger.debug(\"clearing alert\");\n\t\t\t\t\t\t\trepaint();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tGpsMid.getTimer().schedule(timerT, setAlertTimeout);\n\t\t\t\tsetAlertTimeout = 0;\n\t\t\t}\n\t\t}\n\t}\n\tprivate void setSpeedingSign(int maxSpeed) {\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SPEEDALERT_VISUAL)\n\t\t\t&&\n\t\t\t(\n\t\t\t\tspeeding\n\t\t\t\t||\n\t\t\t\t(System.currentTimeMillis() - startTimeOfSpeedingSign) < 3000\n\t\t\t)\n\t\t) {\n\t\t\tif (speeding) {\n\t\t\t\tspeedingSpeedLimit = maxSpeed;\n\t\t\t\tstartTimeOfSpeedingSign = System.currentTimeMillis();\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_METRIC)) {\n\t\t\t\ttl.ele[TraceLayout.SPEEDING_SIGN].setText(Integer.toString(speedingSpeedLimit));\n\t\t\t} else {\n\t\t\t\ttl.ele[TraceLayout.SPEEDING_SIGN].setText(Integer.toString((int)(speedingSpeedLimit / 1.609344f)));\n\t\t\t}\n\t\t} else {\n\t\t\tstartTimeOfSpeedingSign = 0;\n\t\t}\n\t}\n\tprivate void getPC() {\n\t\t\tpc.course = course;\n\t\t\tpc.scale = scale;\n\t\t\tpc.center = center.copy();\n\t\t\tpc.dest = dest;\n\t}\n\tpublic void cleanup() {\n\t\tnamesThread.cleanup();\n\t\turlsThread.cleanup();\n\t\ttileReader.incUnusedCounter();\n\t\tdictReader.incUnusedCounter();\n\t}\n\tpublic void searchNextRoutableWay(RoutePositionMark pm) throws Exception {\n\t\tPaintContext pc = new PaintContext(this, null);\n\t\tpc.squareDstToActualRoutableWay = Float.MAX_VALUE;\n\t\tpc.xSize = 100;\n\t\tpc.ySize = 100;\n\t\tProjection p;\n\t\tdo {\n\t\t\tp = new Proj2D(new Node(pm.lat,pm.lon, true),5000,pc.xSize,pc.ySize);\n\t\t\tpc.setP(p);\n\t\t\tfor (int i=0; i<4; i++) {\n\t\t\t\ttiles[i].walk(pc, Tile.OPT_WAIT_FOR_LOAD | Tile.OPT_FIND_CURRENT);\n\t\t\t}\n\t\t\tif (pc.actualRoutableWay != null) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpc.xSize += 100;\n\t\t\tpc.ySize += 100;\n\t\t} while(MoreMath.dist(p.getMinLat(), p.getMinLon(), p.getMinLat(), p.getMaxLon()) < 500); \n\t\tWay w = pc.actualRoutableWay;\n\t\tpm.setEntity(w, pc.currentPos.nodeLat, pc.currentPos.nodeLon);\n\t}\n\tprivate void setPointOfTheCompass() {\n\t\tString c = \"\";\n\t\tif (ProjFactory.getProj() != ProjFactory.NORTH_UP\n\t\t\t\t&& Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_POINT_OF_COMPASS)) {\n\t\t\tc = Configuration.getCompassDirection(course);\n\t\t}\n\t\tif (tl.bigOnScreenButtons && c.length() <= 1) {\n\t\t\tif (ProjFactory.getProj() == ProjFactory.NORTH_UP) {\n\t\t\t\tc = \"(\" + Configuration.getCompassDirection(0) + \")\";\n\t\t\t} else {\n\t\t\t\tc = \" \" + c + \" \";\n\t\t\t}\n\t\t}\n\t\ttl.ele[TraceLayout.POINT_OF_COMPASS].setText(c);\n\t}\n\tprivate int showConnectStatistics(Graphics g, int yc, int la) {\n\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_TEXT]);\n\t\tGSMCell cell = null;\n\t\tif (cellIDLocationProducer != null || Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_SECELL) {\n\t\t\tcell = CellIdProvider.getInstance().obtainCachedCellID();\n\t\t}\n\t\tCompass compass = null;\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION)) {\n\t\t\tcompass = CompassProvider.getInstance().obtainCachedCompass();\n\t\t}\n\t\tif (cell == null) {\n\t\t\tg.drawString(\"No Cell ID available\", 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t} else {\n\t\t\tg.drawString(\"Cell: MCC=\" + cell.mcc + \" MNC=\" + cell.mnc, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t\tg.drawString(\"LAC=\" + cell.lac, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t\tg.drawString(\"cellID=\" + cell.cellID, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t}\n\t\tif (compass == null) {\n\t\t\tg.drawString(\"No compass direction available\", 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t} else {\n\t\t\tg.drawString(\"Compass direction: \" + compass.direction, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t}\n\t\tif (statRecord == null) {\n\t\t\tg.drawString(\"No stats yet\", 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\treturn yc+la;\n\t\t}\n\t\tfor (byte i = 0; i < LocationMsgReceiver.SIRF_FAIL_COUNT; i++) {\n\t\t\tg.drawString(statMsg[i] + statRecord[i], 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t}\n\t\tg.drawString(\"BtQual : \" + btquality, 0, yc, Graphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(\"Count : \" + collected, 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\treturn yc;\n\t}\n\tpublic void showDestination(PaintContext pc) {\n\t\ttry {\n\t\tif (dest != null) {\n\t\t\tpc.getP().forward(dest.lat, dest.lon, pc.lineP2);\n\t\t\tint x = pc.lineP2.x - imageCollector.xScreenOverscan;\n\t\t\tint y = pc.lineP2.y - imageCollector.yScreenOverscan;\n\t\t\tpc.g.drawImage(pc.images.IMG_DEST, x, y, CENTERPOS);\n\t\t\tpc.g.setColor(Legend.COLORS[Legend.COLOR_DEST_TEXT]);\n\t\t\tif (dest.displayName != null) {\n\t\t\t\tpc.g.drawString(dest.displayName, x, y+8,\n\t\t\t\t\tGraphics.TOP | Graphics.HCENTER);\n\t\t\t}\n\t\t\tpc.g.setColor(Legend.COLORS[Legend.COLOR_DEST_LINE]);\n\t\t\tpc.g.setStrokeStyle(Graphics.SOLID);\n\t\t\tpc.g.drawLine(x, y, pc.getP().getImageCenter().x - imageCollector.xScreenOverscan, \n\t\t\t\t\tpc.getP().getImageCenter().y - imageCollector.yScreenOverscan);\n\t\t}\n\t\t} catch (Exception e) {\n\t\t\tif (imageCollector == null) {\n\t\t\t\tlogger.silentexception(\"No ImageCollector\", e);\n\t\t\t}\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\tpublic void showMovement(Graphics g) {\n\t\tIntPoint centerP = null;\n\t\ttry {\n\t\t\tif (imageCollector != null) {\n\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_CURSOR]);\n\t\t\tcenterP = pc.getP().getImageCenter();\n\t\t\tint centerX = centerP.x - imageCollector.xScreenOverscan;\n\t\t\tint centerY = centerP.y - imageCollector.yScreenOverscan;\n\t\t\tint posX, posY;\n\t\t\tif (!gpsRecenter) {\n\t\t\t\tIntPoint p1 = new IntPoint(0, 0);\n\t\t\t\tpc.getP().forward((pos.latitude * MoreMath.FAC_DECTORAD),\n\t\t\t\t\t\t\t\t (pos.longitude * MoreMath.FAC_DECTORAD), p1);\n\t\t\t\tposX = p1.getX()-imageCollector.xScreenOverscan;\n\t\t\t\tposY = p1.getY()-imageCollector.yScreenOverscan;\n\t\t\t} else {\n\t\t\t\tposX = centerX;\n\t\t\t\tposY = centerY;\n\t\t\t}\n\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_POSINDICATOR]);\n\t\t\tfloat radc = course * MoreMath.FAC_DECTORAD;\n\t\t\tint px = posX + (int) (Math.sin(radc) * 20);\n\t\t\tint py = posY - (int) (Math.cos(radc) * 20);\n\t\t\tif (!gpsRecenter || gpsRecenterInvalid) {\n\t\t\t\tg.drawLine(centerX, centerY - 12, centerX, centerY + 12);\n\t\t\t\tg.drawLine(centerX - 12, centerY, centerX + 12, centerY);\n\t\t\t\tg.drawArc(centerX - 5, centerY - 5, 10, 10, 0, 360);\n\t\t\t}\n\t\t\tif (! gpsRecenterInvalid) {\n\t\t\t\tpc.g.drawImage(gpsRecenterStale ? pc.images.IMG_POS_BG_STALE : pc.images.IMG_POS_BG, posX, posY, CENTERPOS);\n\t\t\t\tg.drawRect(posX - 4, posY - 4, 8, 8);\n\t\t\t\tg.drawLine(posX, posY, px, py);\n\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tif (imageCollector == null) {\n\t\t\t\tlogger.silentexception(\"No ImageCollector\", e);\n\t\t\t}\n\t\t\tif (centerP == null) {\n\t\t\t\tlogger.silentexception(\"No centerP\", e);\n\t\t\t}\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\tpublic void showNextDataScreen(int currentScreen) {\n\t\tswitch (currentScreen)\n\t\t{\n\t\t\tcase DATASCREEN_TACHO:\n\t\t\t\tif (guiTrip == null) {\n\t\t\t\t\tguiTrip = new GuiTrip(this);\n\t\t\t\t}\n\t\t\t\tif (guiTrip != null) {\n\t\t\t\t\tguiTrip.show();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase DATASCREEN_TRIP:\n\t\t\t\tif (guiSatellites == null) {\n\t\t\t\t\tguiSatellites = new GuiSatellites(this, locationProducer);\n\t\t\t\t}\n\t\t\t\tif (guiSatellites != null) {\n\t\t\t\t\tguiSatellites.show();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase DATASCREEN_SATS:\n\t\t\t\tthis.show();\n\t\t\t\tbreak;\n\t\t\tcase DATASCREEN_NONE:\n\t\t\tdefault:\n\t\t\t\tif (guiTacho == null) {\n\t\t\t\t\tguiTacho = new GuiTacho(this);\n\t\t\t\t}\n\t\t\t\tif (guiTacho != null) {\n\t\t\t\t\tguiTacho.show();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tpublic int showMemory(Graphics g, int yc, int la) {\n\t\tg.setColor(0);\n\t\tg.drawString(Locale.get(\"trace.Freemem\") + runtime.freeMemory(), 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.Totmem\") + runtime.totalMemory(), 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.Percent\")\n\t\t\t\t+ (100f * runtime.freeMemory() / runtime.totalMemory()), 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.ThreadsRunning\")\n\t\t\t\t+ Thread.activeCount(), 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.Names\") + namesThread.getNameCount(), 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.SingleT\") + tileReader.getLivingTilesCount() + \"/\"\n\t\t\t\t+ tileReader.getRequestQueueSize(), 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.FileT\") + dictReader.getLivingTilesCount() + \"/\"\n\t\t\t\t+ dictReader.getRequestQueueSize() + \" Map: \" + ImageCollector.icDuration + \" ms\", 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.LastMsg\") + lastTitleMsg, 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString( Locale.get(\"trace.at\") + lastTitleMsgClock, 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT );\n\t\treturn (yc);\n\t}\n\tprivate void updatePosition() {\n\t\tif (pc != null) {\n\t\t\tpc.center = center.copy();\n\t\t\tpc.scale = scale;\n\t\t\tpc.course=course;\n\t\t\trepaint();\n\t\t\tif (locationUpdateListeners != null && !TrackPlayer.isPlaying) {\n\t\t\t\tsynchronized (locationUpdateListeners) {\n\t\t\t\t\tfor (int i = 0; i < locationUpdateListeners.size(); i++) {\n\t\t\t\t\t\t((LocationUpdateListener)locationUpdateListeners.elementAt(i)).loctionUpdated();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic synchronized void receivePosition(float lat, float lon, float scale) {\n\t\tlogger.debug(\"Now displaying: \" + (lat * MoreMath.FAC_RADTODEC) + \" | \" +\n\t\t\t (lon * MoreMath.FAC_RADTODEC));\n\t\tgpsRecenter = false;\n\t\tcenter.setLatLonRad(lat, lon);\n\t\tthis.scale = scale;\n\t\tupdatePosition();\n\t}\n\tpublic synchronized void receiveCompassStatus(int status) {\n\t}\n\tpublic synchronized void receiveCompass(float direction) {\n\t\tlogger.debug(\"Got compass reading: \" + direction);\n\t\tcompassDirection = (int) direction;\n\t\tcompassDeviated = ((int) direction + compassDeviation + 360) % 360;\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null && gpsRecenter) {\n\t\t\tupdateCourse(compassDeviated);\n\t\t}\n\t}\n\tpublic static void updateLastUserActionTime() {\n\t\tlastUserActionTime = System.currentTimeMillis();\n\t}\n\tpublic static long getDurationSinceLastUserActionTime() {\n\t\treturn System.currentTimeMillis() - lastUserActionTime;\n\t}\n\tpublic void updateCourse(int newcourse) {\n\t\tcoursegps = newcourse;\n\t\tif ((newcourse - course)> 180) {\n\t\t\tcourse = course + 360;\n\t\t}\n\t\tif ((course-newcourse)> 180) {\n\t\t\tnewcourse = newcourse + 360;\n\t\t}\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\tcourse = newcourse;\n\t\t} else {\n\t\t\tcourse = course + ((newcourse - course)*1)/4 + 360;\n\t\t}\n\t\twhile (course > 360) {\n\t\t\tcourse -= 360;\n\t\t}\n\t}\n\tpublic synchronized void receivePosition(Position pos) {\n\t\tlogger.info(\"New position: \" + pos);\n\t\tcollected++;\n\t\tif (Configuration.getAutoRecenterToGpsMilliSecs() !=0 &&\n\t\t\tgetDurationSinceLastUserActionTime() > Configuration.getAutoRecenterToGpsMilliSecs()\n\t\t\t&& isShown()\n\t\t) {\n\t\t\tgpsRecenter = true;\n\t\t}\n\t\tif (Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_JSR179) {\n\t\t\tif (pos.type == Position.TYPE_GPS_LASTKNOWN) {\n\t\t\t\tif (this.pos.type == Position.TYPE_CELLID) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgpsRecenterInvalid = false;\n\t\t\t\tgpsRecenterStale = true;\n\t\t\t}\n\t\t}\n\t\tthis.pos = pos;\n\t\tif (pos.type == Position.TYPE_GPS || pos.type == Position.TYPE_CELLID || pos.type == Position.TYPE_MANUAL) {\n\t\t\tgpsRecenterInvalid = false;\n\t\t\tgpsRecenterStale = false;\n\t\t}\n\t\tif (gpsRecenter) {\n\t\t\tcenter.setLatLonDeg(pos.latitude, pos.longitude);\n\t\t\tspeed = (int) (pos.speed * 3.6f);\n\t\t\tfspeed = pos.speed * 3.6f;\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\t\tupdateCourse(compassDeviated);\n } else if (fspeed >= courseMinSpeed && pos.course != Float.NaN ) {\n if (thirdPrevCourse != -1) {\n updateCourse((int) pos.course);\n } else if (prevCourse == -1) {\n prevCourse = (int) pos.course;\n } else if (secondPrevCourse == -1) {\n if (Math.abs(prevCourse - (int)pos.course) < 30 || Math.abs(prevCourse - (int)pos.course) > 330) {\n secondPrevCourse = prevCourse;\n }\n prevCourse = (int) pos.course;\n } else {\n if (Math.abs(prevCourse - (int)pos.course) < 30 || Math.abs(prevCourse - (int)pos.course) > 330) {\n thirdPrevCourse = secondPrevCourse;\n updateCourse((int) pos.course);\n } else {\n prevCourse = (int) pos.course;\n secondPrevCourse = -1;\n }\n }\n } else {\n prevCourse = -1;\n secondPrevCourse = -1;\n thirdPrevCourse = -1;\n\t\t\t}\n\t\t}\n\t\tif (gpx.isRecordingTrk()) {\n\t\t\ttry {\n\t\t\t\tif ((Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_JSR179\n\t\t\t\t && pos.type == Position.TYPE_CELLID) || pos.type == Position.TYPE_GPS_LASTKNOWN) {\n\t\t\t\t} else {\n\t\t\t\t\tgpx.addTrkPt(pos);\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\treceiveMessage(e.getMessage());\n\t\t\t}\n\t\t}\n\t\taltitude = (int) (pos.altitude);\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_AUTOZOOM)\n\t\t\t\t&& gpsRecenter\n\t\t\t\t&& (isGpsConnected() || TrackPlayer.isPlaying)\n\t\t\t\t&& autoZoomed\n\t\t\t\t&& pc.getP() != null\n\t\t\t\t&& pos.speed != Float.NaN \n\t\t) {\n\t\t\tfinal float minimumScale = Configuration.getRealBaseScale() / 1.5f;\n\t\t\tfinal int minimumSpeed = 20;\n\t\t\tfinal float maximumScale = Configuration.getRealBaseScale() * 1.5f;\n\t\t\tfinal int maximumSpeed = 160;\n\t\t\tint speedForScale = speed;\n\t\t\tfloat newScale = minimumScale + (maximumScale - minimumScale) * (speedForScale - minimumSpeed) / (maximumSpeed - minimumSpeed);\n\t\t\tif (newScale < minimumScale) {\n\t\t\t\tnewScale = minimumScale;\n\t\t\t} else if (newScale > maximumScale) {\n\t\t\t\tnewScale = maximumScale;\n\t\t\t}\n\t\t\tscale = newScale;\n\t\t}\n\t\tupdatePosition();\n\t}\n\tpublic synchronized Position getCurrentPosition() {\n\t\treturn this.pos;\n\t}\n\tpublic synchronized void receiveMessage(String s) {\n\t\tlogger.info(\"Setting title: \" + s);\n\t\tcurrentTitleMsg = s;\n\t\tsynchronized (this) {\n\t\t\tif (setTitleMsgTimeout == 0) {\n\t\t\t\tcurrentTitleMsgOpenCount++;\n\t\t\t}\n\t\t\tsetTitleMsgTimeout = 3000;\n\t\t}\n\t\tlastTitleMsgClock = DateTimeTools.getClock(System.currentTimeMillis(), false);\n\t\trepaint();\n\t}\n\tpublic void receiveSatellites(Satellite[] sats) {\n\t}\n\tpublic synchronized void alert(String title, String message, int timeout) {\n\t\tlogger.info(\"Showing trace alert: \" + title + \": \" + message);\n\t\tif (timeout == Alert.FOREVER) {\n\t\t\ttimeout = 10000;\n\t\t}\n\t\tcurrentAlertTitle = title;\n\t\tcurrentAlertMessage = message;\n\t\tsynchronized (this) {\n\t\t\tif (setAlertTimeout == 0) {\n\t\t\t\tcurrentAlertsOpenCount++;\n\t\t\t}\n\t\t\tsetAlertTimeout = timeout;\n\t\t}\n\t\trepaint();\n\t}\n\tpublic MIDlet getParent() {\n\t\treturn parent;\n\t}\n\tprotected void pointerPressed(int x, int y) {\n\t\tupdateLastUserActionTime();\n\t\tlong currTime = System.currentTimeMillis();\n\t\tpointerDragged = false;\n\t\tpointerDraggedMuch = false;\n\t\tpointerActionDone = false;\n\t\tcenterPointerPressedN = center.copy();\n\t\tif (imageCollector != null) {\n\t\t\tpanProjection=imageCollector.getCurrentProjection();\n\t\t\tpickPointStart=panProjection.inverse(x,y, pickPointStart);\n\t\t} else {\n\t\t\tpanProjection = null;\n\t\t}\n\t\tint touchedElementId = tl.getElementIdAtPointer(x, y);\n\t\tif (touchedElementId >= 0 && (!keyboardLocked || tl.getActionIdAtPointer(x, y) == Trace.ICON_MENU)\n\t\t\t\t&&\n\t\t\ttl.isAnyActionIdAtPointer(x, y)\n\t\t) {\n\t\t\ttl.setTouchedElement((LayoutElement) tl.elementAt(touchedElementId));\n\t\t\trepaint();\n\t\t}\n\t\tif (!keyboardLocked && currTime - pressedPointerTime < DOUBLETAP_MAXDELAY) {\n\t\t\tdoubleTap(x, y);\n\t\t\treturn;\n\t\t}\n\t\tpressedPointerTime = currTime;\n\t\tTrace.touchX = x;\n\t\tTrace.touchY = y;\n\t\tif (keyboardLocked) {\n\t\t\tkeyPressed(0);\n\t\t\treturn;\n\t\t}\t\t\n\t\tlongTapTimerTask = new TimerTask() {\n\t\t\tpublic void run() {\n\t\t\t\tif (!pointerActionDone) {\n\t\t\t\t\tif (System.currentTimeMillis() - pressedPointerTime >= LONGTAP_DELAY){\n\t\t\t\t\t\tlongTap();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\tGpsMid.getTimer().schedule(longTapTimerTask, LONGTAP_DELAY);\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(Locale.get(\"trace.NoLongTapTimerTask\") + e.toString());\n\t\t}\n\t}\n\tprotected void pointerReleased(int x, int y) {\t\n\t\tif (longTapTimerTask != null) {\n\t\t\tlongTapTimerTask.cancel();\n\t\t}\n\t\tif (tl.getTouchedElement() != null) {\n\t\t\ttl.clearTouchedElement();\n\t\t\trepaint();\n\t\t}\n\t\tif (!pointerActionDone && !keyboardLocked) {\n\t\t\ttouchReleaseX = x;\n\t\t\ttouchReleaseY = y;\n\t\t\tsingleTapTimerTask = new TimerTask() {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tif (!keyboardLocked) {\n\t\t\t\t\t\tsingleTap(touchReleaseX, touchReleaseY);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tGpsMid.getTimer().schedule(singleTapTimerTask, DOUBLETAP_MAXDELAY);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(Locale.get(\"trace.NoSingleTapTimerTask\") + e.toString());\n\t\t\t}\n\t\t\tif (pointerDragged) {\n\t\t\t\tpointerDragged(x , y);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tprotected void pointerDragged (int x, int y) {\n\t\tupdateLastUserActionTime();\n\t\tLayoutElement e = tl.getElementAtPointer(x, y);\n\t\tif (tl.getTouchedElement() != e) {\n\t\t\tif (longTapTimerTask != null) {\n\t\t\t\tlongTapTimerTask.cancel();\n\t\t\t}\t\t\t\n\t\t\ttl.clearTouchedElement();\n\t\t\trepaint();\n\t\t}\n\t\tif (tl.getElementAtPointer(touchX, touchY) == e && tl.isAnyActionIdAtPointer(x, y)) {\n\t\t\ttl.setTouchedElement(e);\n\t\t\trepaint();\n\t\t}\n\t\tif (pointerActionDone) {\n\t\t\treturn;\n\t\t}\t\t\n\t\tif (Math.abs(x - Trace.touchX) > 8\n\t\t\t\t|| \n\t\t\tMath.abs(y - Trace.touchY) > 8\n\t\t) {\n\t\t\tpointerDraggedMuch = true;\n\t\t\tpressedPointerTime = 0; \n\t\t}\n\t\tif (tl.getActionIdAtPointer(touchX, touchY) == Trace.ICON_MENU) {\n\t\t\tif ( tl.getActionIdAtPointer(x, y) == Trace.ICON_MENU\n\t\t\t\t\t&&\n\t\t\t\tx - touchX > getWidth() / 4\n\t\t\t) {\n\t\t\t\tcommandAction(TOGGLE_KEY_LOCK_CMD);\n\t\t\t\tpointerActionDone = true;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (keyboardLocked) {\n\t\t\treturn;\n\t\t}\n\t\tpointerDragged = true;\n\t\tif (!pointerDraggedMuch && tl.getElementIdAtPointer(touchX, touchY) >= 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0 && imageCollector != null && panProjection != null) {\n\t\t\tpickPointEnd=panProjection.inverse(x,y, pickPointEnd);\n\t\t\tcenter.radlat=centerPointerPressedN.radlat-(pickPointEnd.radlat-pickPointStart.radlat);\n\t\t\tcenter.radlon=centerPointerPressedN.radlon-(pickPointEnd.radlon-pickPointStart.radlon);\n\t\t\timageCollector.newDataReady();\n\t\t\tgpsRecenter = false;\n\t\t}\n\t}\n\tprivate void singleTap(int x, int y) {\n\t\tpointerActionDone = true;\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0) {\t\t\t\t\t\t\t\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_SINGLE)) {\n\t\t\t\tif (pointerDraggedMuch) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.debug(\"single tap map\");\n\t\t\t\tif (!tl.bigOnScreenButtons) {\n\t\t\t\t\ttl.setOnScreenButtonSize(true);\n\t\t\t\t\tfinal long BIGBUTTON_DURATION = 5000;\n\t\t\t\t\tbigButtonTimerTask = new TimerTask() {\n\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\tif (System.currentTimeMillis() - lastUserActionTime > BIGBUTTON_DURATION ) {\n\t\t\t\t\t\t\t\ttl.setOnScreenButtonSize(false);\n\t\t\t\t\t\t\t\trequestRedraw();\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tbigButtonTimerTask.cancel();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\ttry {\n\t\t\t\t\t\tGpsMid.getTimer().schedule(bigButtonTimerTask, BIGBUTTON_DURATION, 500);\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tlogger.error(\"Error scheduling bigButtonTimerTask: \" + e.toString());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t} else if (tl.getElementIdAtPointer(x, y) == tl.getElementIdAtPointer(touchX, touchY)) {\n\t\t\ttl.clearTouchedElement();\n\t\t\tint actionId = tl.getActionIdAtPointer(x, y);\n\t\t\tif (actionId > 0) {\n\t\t\t\tlogger.debug(\"single tap button: \" + actionId + \" x: \" + touchX + \" y: \" + touchY);\n\t\t\t\tif (System.currentTimeMillis() < (lastBackLightOnTime + 2500)) {\n\t\t\t\t\tif (actionId == ZOOM_IN_CMD) {\n\t\t\t\t\t\tactionId = PAN_RIGHT2_CMD;\n\t\t\t\t\t} else if (actionId == ZOOM_OUT_CMD) {\n\t\t\t\t\t\tactionId = PAN_LEFT2_CMD;\n\t\t\t\t\t}\n\t\t\t\t} else if (manualRotationMode) {\n\t\t\t\t\tif (actionId == ZOOM_IN_CMD) {\n\t\t\t\t\t\tactionId = PAN_LEFT2_CMD;\n\t\t\t\t\t} else if (actionId == ZOOM_OUT_CMD) {\n\t\t\t\t\t\tactionId = PAN_RIGHT2_CMD;\n\t\t\t\t\t}\n\t\t\t\t} else if (TrackPlayer.isPlaying) {\n\t\t\t\t\tif (actionId == ZOOM_IN_CMD) {\n\t\t\t\t\t\tactionId = PAN_RIGHT2_CMD;\n\t\t\t\t\t} else if (actionId == ZOOM_OUT_CMD) {\n\t\t\t\t\t\tactionId = PAN_LEFT2_CMD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcommandAction(actionId);\n\t\t\t\trepaint();\n\t\t\t}\n\t\t}\n\t}\n\tprivate void doubleTap(int x, int y) {\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0) {\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_DOUBLE)) {\n\t\t\t\tif (singleTapTimerTask != null) {\n\t\t\t\t\tsingleTapTimerTask.cancel();\n\t\t\t\t}\n\t\t\t\tif (pointerDraggedMuch) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.debug(\"double tap map\");\n\t\t\t\tpointerActionDone = true;\n\t\t\t\tcommandAction(ZOOM_IN_CMD);\n\t\t\t}\n\t\t\trepaint();\n\t\t\treturn;\n\t\t} else if (tl.getTouchedElement() == tl.getElementAtPointer(x, y) ){\n\t\t\tint actionId = tl.getActionIdDoubleAtPointer(x, y);\n\t\t\tlogger.debug(\"double tap button: \" + actionId + \" x: \" + x + \" y: \" + x);\n\t\t\tif (actionId > 0) {\n\t\t\t\tif (singleTapTimerTask != null) {\n\t\t\t\t\tsingleTapTimerTask.cancel();\n\t\t\t\t}\n\t\t\t\tpointerActionDone = true;\n\t\t\t\tcommandAction(actionId);\n\t\t\t\ttl.clearTouchedElement();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tsingleTap(x, y);\n\t\t\t}\n\t\t}\n\t}\n\tprivate void longTap() {\n\t\tpointerActionDone = true;\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0 && panProjection != null) {\t\t\t\t\t\t\t\n\t\t\tif (!pointerDraggedMuch && Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_LONG)) {\n\t\t\t\tlogger.debug(\"long tap map\");\t\t\t\t\t\t\t\t\t\t\n\t\t\t\tpickPointEnd=panProjection.inverse(touchX,touchY, pickPointEnd);\n\t\t\t\tcenter.radlat=centerPointerPressedN.radlat-(pickPointEnd.radlat-pickPointStart.radlat);\n\t\t\t\tcenter.radlon=centerPointerPressedN.radlon-(pickPointEnd.radlon-pickPointStart.radlon);\n\t\t\t\tPosition oPos = new Position(center.radlat, center.radlon,\n\t\t\t\t\t\t\t 0.0f, 0.0f, 0.0f, 0, 0);\n\t\t\t\timageCollector.newDataReady();\n\t\t\t\tgpsRecenter = false;\n\t\t\t\tcommandAction(ONLINE_INFO_CMD);\n\t\t\t}\n\t\t\treturn;\n\t\t} else {\n\t\t\tint actionId = tl.getActionIdLongAtPointer(touchX, touchY);\n\t\t\tif (actionId > 0 && tl.getElementAtPointer(touchX, touchY) == tl.getTouchedElement()) {\n\t\t\t\tlogger.debug(\"long tap button: \" + actionId + \" x: \" + touchX + \" y: \" + touchY);\n\t\t\t\tcommandAction(actionId);\n\t\t\t\trepaint();\n\t\t\t}\n\t\t}\n\t\ttl.clearTouchedElement();\n\t}\n\tpublic Command getDataScreenCommand() {\n\t\treturn CMDS[DATASCREEN_CMD];\n\t}\n\tpublic Tile getDict(byte zl) {\n\t\treturn tiles[zl];\n\t}\n\tpublic void setDict(Tile dict, byte zl) {\n\t\ttiles[zl] = dict;\n\t\tif (zl == 0) {\n\t\t\tConfiguration.getStartupPos(center);\n\t\t\tif (center.radlat == 0.0f && center.radlon == 0.0f) {\n\t\t\t\tdict.getCenter(center);\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SAVED_DESTPOS_VALID)) {\n\t\t\t\tNode destNode = new Node();\n\t\t\t\tConfiguration.getDestPos(destNode);\n\t\t\t\tsetDestination(new RoutePositionMark(destNode.radlat, destNode.radlon));\n\t\t\t}\n\t\t\tif (pc != null) {\n\t\t\t\tpc.center = center.copy();\n\t\t\t\tpc.scale = scale;\n\t\t\t\tpc.course = course;\n\t\t\t}\n\t\t}\n\t\tupdatePosition();\n\t}\n\tpublic void receiveStatistics(int[] statRecord, byte quality) {\n\t\tthis.btquality = quality;\n\t\tthis.statRecord = statRecord;\n\t\trepaint();\n\t}\n\tpublic synchronized void locationDecoderEnd() {\n\t\tlogger.info(\"enter locationDecoderEnd\");\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SND_DISCONNECT)) {\n\t\t\tif (Legend.isValid) {\n\t\t\t\tGpsMid.mNoiseMaker.playSound(\"DISCONNECT\");\n\t\t\t}\n\t\t}\n\t\tremoveCommand(CMDS[DISCONNECT_GPS_CMD]);\n\t\tif (locationProducer == null) {\n\t\t\tlogger.info(\"leave locationDecoderEnd no producer\");\n\t\t\treturn;\n\t\t}\n\t\tlocationProducer = null;\n\t\tnotify();\n\t\taddCommand(CMDS[CONNECT_GPS_CMD]);\n\t\tlogger.info(\"end locationDecoderEnd\");\n\t}\n\tpublic void receiveStatus(byte status, int satsReceived) {\n\t\tsolution = status;\n\t\tsolutionStr = LocationMsgReceiverList.getCurrentStatusString(status, satsReceived);\n\t\trepaint();\n\t}\n\tpublic String getName(int idx) {\n\t\tif (idx < 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn namesThread.getName(idx);\n\t}\n\tpublic String getUrl(int idx) {\n\t\tif (idx < 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn urlsThread.getUrl(idx);\n\t}\n\tpublic Vector fulltextSearch (String snippet, CancelMonitorInterface cmi) {\n\t\treturn namesThread.fulltextSearch(snippet, cmi);\n\t}\n\tpublic void requestRedraw() {\n\t\trepaint();\n\t}\n\tpublic void newDataReady() {\n\t\tif (imageCollector != null) {\n\t\t\timageCollector.newDataReady();\n\t\t}\n\t}\n\tpublic void show() {\n\t\tLegend.freeDrawnWayAndAreaSearchImages();\n\t\tGpsMid.getInstance().show(this);\n\t\tsetFullScreenMode(Configuration.getCfgBitState(Configuration.CFGBIT_FULLSCREEN));\n\t\tupdateLastUserActionTime();\n\t\trepaint();\n\t}\n\tpublic void recreateTraceLayout() {\n\t\ttl = new TraceLayout(0, 0, getWidth(), getHeight());\n\t}\n\tpublic void resetSize() {\n\t\tsizeChanged(getWidth(), getHeight());\n\t}\n\tpublic void locationDecoderEnd(String msg) {\n\t\treceiveMessage(msg);\n\t\tlocationDecoderEnd();\n\t}\n\tpublic PositionMark getDestination() {\n\t\treturn dest;\n\t}\n\tpublic void setDestination(RoutePositionMark dest) {\n\t\tendRouting();\n\t\tthis.dest = dest;\n\t\tpc.dest = dest;\n\t\tif (dest != null) {\n\t\t\tlogger.info(\"Setting destination to \" + dest.toString());\n\t\t\tif (! Configuration.getCfgBitState(Configuration.CFGBIT_ICONMENUS_ROUTING_OPTIMIZED)) {\n\t\t\t\tcommandAction(SHOW_DEST_CMD);\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_AUTOSAVE_DESTPOS)) {\n\t\t\t\tConfiguration.setDestPos(new Node(dest.lat, dest.lon, true));\n\t\t\t\tConfiguration.setCfgBitSavedState(Configuration.CFGBIT_SAVED_DESTPOS_VALID, true);\n\t\t\t}\n\t\t\tmovedAwayFromDest = false;\n\t\t} else {\n\t\t\tConfiguration.setCfgBitSavedState(Configuration.CFGBIT_SAVED_DESTPOS_VALID, false);\n\t\t\tlogger.info(\"Setting destination to null\");\n\t\t}\n\t}\n\tpublic void endRouting() {\n\t\tRouteInstructions.initialRecalcDone = false;\n\t\tRouteInstructions.icCountOffRouteDetected = 0;\n\t\tRouteInstructions.routeInstructionsHeight = 0;\n\t\tRouteInstructions.abortRouteLineProduction();\n\t\tsetRoute(null);\n\t\tsetRouteNodes(null);\n\t}\n\tpublic void setRoute(Vector route) {\n\t\tsynchronized(this) {\n\t\t\tthis.route = route;\n\t\t}\n\t\tif (this.route != null) {\n\t\t\tRouteInstructions.resetOffRoute(this.route, center);\n\t\t\tif (ri == null) {\n\t\t\t\tri = new RouteInstructions(this);\n\t\t\t}\n\t\t\tif (Configuration.getContinueMapWhileRouteing() == Configuration.continueMap_At_Route_Line_Creation) {\n\t\t\t\tresumeImageCollectorAfterRouteCalc();\n\t\t\t}\n\t\t\tri.newRoute(this.route);\n\t\t\toldRecalculationTime = System.currentTimeMillis();\n\t\t}\n\t\tresumeImageCollectorAfterRouteCalc();\n\t\trouteCalc=false;\n\t\trouteEngine=null;\n\t}\n\tprivate void resumeImageCollectorAfterRouteCalc() {\n\t\ttry {\n\t\t\tif (imageCollector == null) {\n\t\t\t\tstartImageCollector();\n\t\t\t\timageCollector.resume();\n\t\t\t} else if (imageCollector != null) {\n\t\t\t\timageCollector.newDataReady();\n\t\t\t}\n\t\t\trepaint();\n\t\t} catch (Exception e) {\n\t\t\tlogger.exception(Locale.get(\"trace.InTraceResumeImageCollector\"), e);\n\t\t}\n\t}\n\tpublic void dropCache() {\n\t\ttileReader.dropCache();\n\t\tdictReader.dropCache();\n\t\tSystem.gc();\n\t\tnamesThread.dropCache();\n\t\turlsThread.dropCache(); \n\t\tSystem.gc();\n\t\tif (gpx != null) {\n\t\t\tgpx.dropCache();\n\t\t}\n\t}\n\tpublic QueueDataReader getDataReader() {\n\t\treturn tileReader;\n\t}\n\tpublic QueueDictReader getDictReader() {\n\t\treturn dictReader;\n\t}\n\tpublic Vector getRouteNodes() {\n\t\treturn routeNodes;\n\t}\n\tpublic void setRouteNodes(Vector routeNodes) {\n\t\tthis.routeNodes = routeNodes;\n\t}\n\tprotected void hideNotify() {\n\t\tlogger.debug(\"Hide notify has been called, screen will no longer be updated\");\n\t\tif (imageCollector != null) {\n\t\t\timageCollector.suspend();\n\t\t}\n\t}\n\tprotected void showNotify() {\n\t\tlogger.debug(\"Show notify has been called, screen will be updated again\");\n\t\tif (imageCollector != null) {\n\t\t\timageCollector.resume();\n\t\t\timageCollector.newDataReady();\n\t\t}\n\t}\n\tpublic Vector getRoute() {\n\t\treturn route;\n\t}\n\tpublic void actionCompleted() {\n\t\tboolean reAddCommands = true;\n\t\tif (reAddCommands && Configuration.getCfgBitState(Configuration.CFGBIT_FULLSCREEN)) {\n\t\t\taddAllCommands();\n\t\t}\n\t}\n\tpublic void showIconMenu() {\n\t\tif (traceIconMenu == null) {\n\t\t\ttraceIconMenu = new TraceIconMenu(this, this);\n\t\t}\n\t\ttraceIconMenu.show();\n\t}\n\tpublic static void uncacheIconMenu() {\n\t\tif (traceIconMenu != null) {\n\t\t\tlogger.trace(\"uncaching TraceIconMenu\");\n\t\t}\n\t\ttraceIconMenu = null;\n\t}\n\tpublic void recreateAndShowIconMenu() {\n\t\tuncacheIconMenu();\n\t\tshowIconMenu();\n\t}\n\tpublic void performIconAction(int actionId) {\n\t\tupdateLastUserActionTime();\n\t\tif (routeCalc || GpsMid.getInstance().needsFreeingMemory()) {\n\t\t\tlogger.info(\"low mem: Uncaching traceIconMenu\");\n\t\t\tuncacheIconMenu();\n\t\t}\n\t\tif (actionId != IconActionPerformer.BACK_ACTIONID) {\n\t\t\tcommandAction(actionId);\n\t\t}\n\t}\n\tpublic static String showDistance(int meters) {\n\t\treturn showDistance(meters, DISTANCE_GENERIC);\n\t}\n\tpublic static String showDistance(int meters, int type) {\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_METRIC)) {\n\t\t\tif (type == DISTANCE_UNKNOWN) {\n\t\t\t\treturn \"???m\";\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_DISTANCE_VIEW) && (type != DISTANCE_ALTITUDE)) {\n\t\t\t\tif (meters >= 10000) {\n\t\t\t\t\treturn meters / 1000 + \"km\";\n\t\t\t\t} else if (meters < 1000) {\n\t\t\t\t\treturn meters + \"m\";\n\t\t\t\t} else {\n\t\t\t\t\treturn meters / 1000 + \".\" + (meters % 1000) / 100 + \"km\";\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn meters + \"m\";\n\t\t\t}\n\t\t} else {\n\t\t\tif (type == DISTANCE_UNKNOWN) {\n\t\t\t\treturn \"???yd\";\n\t\t\t} else if (type == DISTANCE_ALTITUDE) {\n\t\t\t\treturn Integer.toString((int)(meters / 0.30480 + 0.5)) + \"ft\";\n\t\t\t} else {\n\t\t\t\treturn Integer.toString((int)(meters / 0.9144 + 0.5)) + \"yd\";\n\t\t\t}\n\t\t}\n\t}\n}\n", "output": "\tpublic void commandAction(Command c, Displayable d) {\n\t\tupdateLastUserActionTime();\n\t\ttry {\n\t\t\tif((keyboardLocked) && (d != null)) {\n\t\t\t\tkeyPressed(0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((c == CMDS[PAN_LEFT25_CMD]) || (c == CMDS[PAN_RIGHT25_CMD])\n\t\t\t\t\t|| (c == CMDS[PAN_UP25_CMD]) || (c == CMDS[PAN_DOWN25_CMD])\n\t\t\t\t\t|| (c == CMDS[PAN_LEFT2_CMD]) || (c == CMDS[PAN_RIGHT2_CMD])\n\t\t\t\t\t|| (c == CMDS[PAN_UP2_CMD]) || (c == CMDS[PAN_DOWN2_CMD])) {\n\t\t\t\tint panX = 0; int panY = 0;\n\t\t\t\tint courseDiff = 0;\n\t\t\t\tint backLightLevelDiff = 0;\n\t\t\t\tif (c == CMDS[PAN_LEFT25_CMD]) {\n\t\t\t\t\tpanX = -25;\n\t\t\t\t} else if (c == CMDS[PAN_RIGHT25_CMD]) {\n\t\t\t\t\tpanX = 25;\n\t\t\t\t} else if (c == CMDS[PAN_UP25_CMD]) {\n\t\t\t\t\tpanY = -25;\n\t\t\t\t} else if (c == CMDS[PAN_DOWN25_CMD]) {\n\t\t\t\t\tpanY = 25;\n\t\t\t\t} else if (c == CMDS[PAN_LEFT2_CMD]) {\n\t\t\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\t\t\tTrackPlayer.slower();\n\t\t\t\t\t} else if (manualRotationMode) {\n\t\t\t\t\t\tcourseDiff=-5;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanX = -2;\n\t\t\t\t\t}\n\t\t\t\t\tbackLightLevelDiff = -25;\n\t\t\t\t} else if (c == CMDS[PAN_RIGHT2_CMD]) {\n\t\t\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\t\t\tTrackPlayer.faster();\n\t\t\t\t\t} else if (manualRotationMode) {\n\t\t\t\t\t\tcourseDiff=5;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanX = 2;\n\t\t\t\t\t}\n\t\t\t\t\tbackLightLevelDiff = 25;\n\t\t\t\t} else if (c == CMDS[PAN_UP2_CMD]) {\n\t\t\t\t\tif (route!=null && Configuration.getCfgBitState(Configuration.CFGBIT_ROUTE_BROWSING)) {\n\t\t\t\t\t\tRouteInstructions.toNextInstruction(1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanY = -2;\n\t\t\t\t\t}\n\t\t\t\t} else if (c == CMDS[PAN_DOWN2_CMD]) {\n\t\t\t\t\tif (route!=null && Configuration.getCfgBitState(Configuration.CFGBIT_ROUTE_BROWSING)) {\n\t\t\t\t\t\tRouteInstructions.toNextInstruction(-1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpanY = 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (backLightLevelDiff !=0 && System.currentTimeMillis() < (lastBackLightOnTime + 2500)) {\n\t\t\t\t\tConfiguration.setCfgBitState(Configuration.CFGBIT_BACKLIGHT_ON, true, false);\n\t\t\t\t\tlastBackLightOnTime = System.currentTimeMillis();\n\t\t\t\t\tConfiguration.addToBackLightLevel(backLightLevelDiff);\n\t\t\t\t\tparent.showBackLightLevel();\n\t\t\t\t} else if (imageCollector != null) {\n\t\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\t\t\t\tif (compassDeviation == 360) {\n\t\t\t\t\t\t\tcompassDeviation = 0;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcompassDeviation += courseDiff;\n\t\t\t\t\t\t\tcompassDeviation %= 360;\n\t\t\t\t\t\t\tif (course < 0) {\n\t\t\t\t\t\t\t\tcourse += 360;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (courseDiff == 360) {\n\t\t\t\t\t\t\tcourse = 0; \n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcourse += courseDiff;\n\t\t\t\t\t\t\tcourse %= 360;\n\t\t\t\t\t\t\tif (course < 0) {\n\t\t\t\t\t\t\t\tcourse += 360;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (panX != 0 || panY != 0) {\n\t\t\t\t\t\t\tgpsRecenter = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\timageCollector.getCurrentProjection().pan(center, panX, panY);\n\t\t\t\t}\n\t\t\t\tgpsRecenter = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[EXIT_CMD]) {\n\t\t\t\tif (Legend.isValid && gpx.isRecordingTrk()) {\n\t\t\t\t\talert(Locale.get(\"trace.RecordMode\"), Locale.get(\"trace.PleaseStopRecording\") , 2500);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (Legend.isValid) {\n\t\t\t\t\tpause();\n\t\t\t\t}\n\t\t\t\tparent.exit();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[START_RECORD_CMD]) {\n\t\t\t\ttry {\n\t\t\t\t\tgpx.newTrk(false);\n\t\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.StartingToRecord\"), 1250);\n\t\t\t\t} catch (RuntimeException e) {\n\t\t\t\t\treceiveMessage(e.getMessage());\n\t\t\t\t}\n\t\t\t\trecordingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[STOP_RECORD_CMD]) {\n\t\t\t\tgpx.saveTrk(false);\n\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.StoppingToRecord\"), 1250);\n\t\t\t\trecordingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MANAGE_TRACKS_CMD]) {\n\t\t\t\tif (gpx.isRecordingTrk() && !gpx.isRecordingTrkSuspended()) {\n\t\t\t\t\talert(Locale.get(\"trace.RecordMode\"), Locale.get(\"trace.YouNeedStopRecording\") , 4000);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t GuiGpx guiGpx = new GuiGpx(this);\n\t\t\t guiGpx.show();\n\t\t\t return;\n\t\t\t}\n\t\t\tif (c == CMDS[REFRESH_CMD]) {\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[CONNECT_GPS_CMD]) {\n\t\t\t\tif (locationProducer == null) {\n\t\t\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\t\t\tTrackPlayer.getInstance().stop();\n\t\t\t\t\t\talert(Locale.get(\"trace.Trackplayer\"), Locale.get(\"trace.PlayingStopped\"), 2500);\n\t\t\t\t\t}\n\t\t\t\t\tThread thread = new Thread(this,\"LocationProducer init\");\n\t\t\t\t\tthread.start();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[DISCONNECT_GPS_CMD]) {\n\t\t\t\tif (locationProducer != null) {\n\t\t\t\t\tlocationProducer.close();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_GPS_CMD]) {\n\t\t\t\tif (isGpsConnected()) {\n\t\t\t\t\tcommandAction(DISCONNECT_GPS_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tcommandAction(CONNECT_GPS_CMD);\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SEARCH_CMD]) {\n\t\t\t\tGuiSearch guiSearch = new GuiSearch(this);\n\t\t\t\tguiSearch.show();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ENTER_WAYP_CMD]) {\n\t\t\t\tif (gpx.isLoadingWaypoints()) {\n\t\t\t\t\tshowAlertLoadingWpt();\n\t\t\t\t} else {\n\t\t\t\t\tGuiWaypointEnter gwpe = new GuiWaypointEnter(this);\n\t\t\t\t\tgwpe.show();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MAN_WAYP_CMD]) {\n\t\t\t\tif (gpx.isLoadingWaypoints()) {\n\t\t\t\t\tshowAlertLoadingWpt();\n\t\t\t\t} else {\n\t\t\t\t\tGuiWaypoint gwp = new GuiWaypoint(this);\n\t\t\t\t\tgwp.show();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MAPFEATURES_CMD]) {\n\t\t\t\tGuiMapFeatures gmf = new GuiMapFeatures(this);\n\t\t\t\tgmf.show();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[OVERVIEW_MAP_CMD]) {\n\t\t\t\tGuiOverviewElements ovEl = new GuiOverviewElements(this);\n\t\t\t\tovEl.show();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SEND_MESSAGE_CMD]) {\n\t\t\t\tGuiSendMessage sendMsg = new GuiSendMessage(this);\n\t\t\t\tsendMsg.show();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[RECORDINGS_CMD]) {\n\t\t\t\tif (recordingsMenu == null) {\n\t\t\t\t\tboolean hasJSR120 = Configuration.hasDeviceJSR120();\n\t\t\t\t\tint noElements = 3;\n\t\t\t\t\tnoElements += 2;\n\t\t\t\t\tif (hasJSR120) {\n\t\t\t\t\t\tnoElements++;\n\t\t\t\t\t}\n\t\t\t\t\tint idx = 0;\n\t\t\t\t\tString[] elements = new String[noElements];\n\t\t\t\t\tif (gpx.isRecordingTrk()) {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StopGpxTracklog\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StartGpxTracklog\");\n\t\t\t\t\t}\n\t\t\t\t\telements[idx++] = Locale.get(\"trace.SaveWaypoint\");\n\t\t\t\t\telements[idx++] = Locale.get(\"trace.EnterWaypoint\");\n\t\t\t\t\telements[idx++] = Locale.get(\"trace.TakePictures\");\n\t\t\t\t\tif (audioRec.isRecording()) {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StopAudioRecording\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.StartAudioRecording\");\n\t\t\t\t\t}\n\t\t\t\t\tif (hasJSR120) {\n\t\t\t\t\t\telements[idx++] = Locale.get(\"trace.SendSMSMapPos\");\n\t\t\t\t\t}\n\t\t\t\t\trecordingsMenu = new List(Locale.get(\"trace.Recordings\"),Choice.IMPLICIT,elements,null);\n\t\t\t\t\trecordingsMenu.addCommand(CMDS[OK_CMD]);\n\t\t\t\t\trecordingsMenu.addCommand(CMDS[BACK_CMD]);\n\t\t\t\t\trecordingsMenu.setSelectCommand(CMDS[OK_CMD]);\n\t\t\t\t\tparent.show(recordingsMenu);\n\t\t\t\t\trecordingsMenu.setCommandListener(this);\n\t\t\t\t}\n\t\t\t\tif (recordingsMenu != null) {\n\t\t\t\t\trecordingsMenu.setSelectedIndex(0, true);\n\t\t\t\t\tparent.show(recordingsMenu);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTINGS_CMD]) {\n\t\t\t\tif (routingsMenu == null) {\n\t\t\t\t\tString[] elements = new String[4];\n\t\t\t\t\tif (routeCalc || route != null) {\n\t\t\t\t\t\telements[0] = Locale.get(\"trace.StopRouting\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\telements[0] = Locale.get(\"trace.CalculateRoute\");\n\t\t\t\t\t}\n\t\t\t\t\telements[1] = Locale.get(\"trace.SetDestination\");\n\t\t\t\t\telements[2] = Locale.get(\"trace.ShowDestination\");\n\t\t\t\t\telements[3] = Locale.get(\"trace.ClearDestination\");\n\t\t\t\t\troutingsMenu = new List(Locale.get(\"trace.Routing2\"), Choice.IMPLICIT, elements, null);\n\t\t\t\t\troutingsMenu.addCommand(CMDS[OK_CMD]);\n\t\t\t\t\troutingsMenu.addCommand(CMDS[BACK_CMD]);\n\t\t\t\t\troutingsMenu.setSelectCommand(CMDS[OK_CMD]);\n\t\t\t\t\troutingsMenu.setCommandListener(this);\n\t\t\t\t}\n\t\t\t\tif (routingsMenu != null) {\n\t\t\t\t\troutingsMenu.setSelectedIndex(0, true);\n\t\t\t\t\tparent.show(routingsMenu);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SAVE_WAYP_CMD]) {\n\t\t\t\tif (gpx.isLoadingWaypoints()) {\n\t\t\t\t\tshowAlertLoadingWpt();\n\t\t\t\t} else {\n\t\t\t\t\tPositionMark posMark = null;\n\t\t\t\t\tif (gpsRecenter) {\n\t\t\t\t\t\tposMark = new PositionMark(center.radlat, center.radlon,\n\t\t\t\t\t\t\t\t(int)pos.altitude, pos.timeMillis,\n\t\t\t\t\t\t\t\t (byte)-1, (byte)-1,\n\t\t\t\t\t\t\t\t (byte)-1, (byte)-1);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tposMark = new PositionMark(center.radlat, center.radlon,\n\t\t\t\t\t\t\t\tPositionMark.INVALID_ELEVATION,\n\t\t\t\t\t\t\t\tpos.timeMillis, (byte)-1,\n\t\t\t\t\t\t\t\t (byte)-1, (byte)-1,\n\t\t\t\t\t\t\t\t (byte)-1);\n\t\t\t\t\t}\n\t\t\t\t\t\tshowGuiWaypointSave(posMark);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ONLINE_INFO_CMD]) {\n\t\t\t\t\tPosition oPos = new Position(center.radlat, center.radlon,\n\t\t\t\t\t\t\t0.0f, 0.0f, 0.0f, 0, 0);\n\t\t\t\t\tGuiWebInfo gWeb = new GuiWebInfo(this, oPos, pc);\n\t\t\t\t\tgWeb.show();\n\t\t\t\t\talert(Locale.get(\"trace.NoOnlineCapa\"),\n\t\t\t\t\t Locale.get(\"trace.SetAppGeneric\") +\n\t\t\t\t\t Locale.get(\"trace.PropertiesFile\"),\n\t\t\t\t\t\t\tAlert.FOREVER);\n\t\t\t}\n\t\t\tif (c == CMDS[BACK_CMD]) {\n\t\t\t\tshow();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[OK_CMD]) {\n\t\t\t\tif (d == recordingsMenu) {\n\t\t\t\t\t switch (recordingsMenu.getSelectedIndex()) {\n\t\t\t case 0: {\n\t\t \t\t\t\tif ( gpx.isRecordingTrk() ) {\n\t\t \t\t\t\t\tcommandAction(STOP_RECORD_CMD);\n\t\t\t\t\t\t\t\tif (! Configuration.getCfgBitState(Configuration.CFGBIT_GPX_ASK_TRACKNAME_STOP)) {\n\t\t\t\t\t\t\t \tshow();\n\t\t\t\t\t\t\t\t}\n\t\t \t\t\t\t} else {\n\t\t \t\t\t\t\tcommandAction(START_RECORD_CMD);\n\t\t\t\t\t\t\t\tif (! Configuration.getCfgBitState(Configuration.CFGBIT_GPX_ASK_TRACKNAME_START)) {\n\t\t\t\t\t\t\t \tshow();\n\t\t\t\t\t\t\t\t}\n\t\t \t\t\t\t}\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 1: {\n\t\t\t \tcommandAction(SAVE_WAYP_CMD);\n\t\t\t\t\t\t\tbreak;\n\t\t\t }\n\t\t\t case 2: {\n\t\t\t \tcommandAction(ENTER_WAYP_CMD);\n\t\t\t\t\t\t\tbreak;\n\t\t\t }\n\t\t\t case 3: {\n\t\t\t \tcommandAction(CAMERA_CMD);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 4: {\n\t\t\t \tshow();\n\t\t\t \tcommandAction(TOGGLE_AUDIO_REC);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 5: {\n\t\t\t \tcommandAction(SEND_MESSAGE_CMD);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t case 3: {\n\t\t\t \tcommandAction(SEND_MESSAGE_CMD);\n\t\t\t \tbreak;\n\t\t\t }\n\t\t\t\t\t }\n\t\t\t\t}\n\t\t\t\tif (d == routingsMenu) {\n\t\t\t\t\tshow();\n\t\t\t\t\tswitch (routingsMenu.getSelectedIndex()) {\n\t\t\t\t\tcase 0: {\n\t\t\t\t\t\tif (routeCalc || route != null) {\n\t\t\t\t\t\t\tcommandAction(ROUTING_STOP_CMD);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcommandAction(ROUTING_START_WITH_MODE_SELECT_CMD);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 1: {\n\t\t\t\t\t\tcommandAction(SET_DEST_CMD);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 2: {\n\t\t\t\t\t\tcommandAction(SHOW_DEST_CMD);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 3: {\n\t\t\t\t\t\tcommandAction(CLEAR_DEST_CMD);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[CAMERA_CMD]) {\n\t\t\t\ttry {\n\t\t\t\t\tClass GuiCameraClass = Class.forName(\"de.ueller.midlet.gps.GuiCamera\");\n\t\t\t\t\tObject GuiCameraObject = GuiCameraClass.newInstance();\n\t\t\t\t\tGuiCameraInterface cam = (GuiCameraInterface)GuiCameraObject;\n\t\t\t\t\tcam.init(this);\n\t\t\t\t\tcam.show();\n\t\t\t\t} catch (ClassNotFoundException cnfe) {\n\t\t\t\t\tlogger.exception(Locale.get(\"trace.YourPhoneNoCamSupport\"), cnfe);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_AUDIO_REC]) {\n\t\t\t\tif (audioRec.isRecording()) {\n\t\t\t\t\taudioRec.stopRecord();\n\t\t\t\t} else {\n\t\t\t\t\taudioRec.startRecorder();\n\t\t\t\t}\n\t\t\t\trecordingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_TOGGLE_CMD]) {\n\t\t\t\tif (routeCalc || route != null) {\n\t\t\t\t\tcommandAction(ROUTING_STOP_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tcommandAction(ROUTING_START_WITH_MODE_SELECT_CMD);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_START_WITH_MODE_SELECT_CMD]) {\n\t\t\t\tgpsRecenter = true;\n\t\t\t\tgpsRecenterInvalid = true;\n\t\t\t\tgpsRecenterStale = true;\n\t\t\t\tGuiRoute guiRoute = new GuiRoute(this, false);\n\t\t\t\tif (Configuration.getCfgBitSavedState(Configuration.CFGBIT_DONT_ASK_FOR_ROUTING_OPTIONS)) {\n\t\t\t\t\tcommandAction(ROUTING_START_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tguiRoute.show();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_START_CMD]) {\n\t\t\t\tif (! routeCalc || RouteLineProducer.isRunning()) {\n\t\t\t\t\trouteCalc = true;\n\t\t\t\t\tif (Configuration.getContinueMapWhileRouteing() != Configuration.continueMap_Always ) {\n\t \t\t\t\t stopImageCollector();\n\t\t\t\t\t}\n\t\t\t\t\tRouteInstructions.resetOffRoute(route, center);\n\t\t\t\t\tRoutePositionMark routeSource = new RoutePositionMark(center.radlat, center.radlon);\n\t\t\t\t\tlogger.info(\"Routing source: \" + routeSource);\n\t\t\t\t\trouteNodes=new Vector();\n\t\t\t\t\trouteEngine = new Routing(tiles, this);\n\t\t\t\t\trouteEngine.solve(routeSource, dest);\n\t\t\t\t}\n\t\t\t\troutingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ROUTING_STOP_CMD]) {\n\t\t\t\tNoiseMaker.stopPlayer();\n\t\t\t\tif (routeCalc) {\n\t\t\t\t\tif (routeEngine != null) {\n\t\t\t\t\t\trouteEngine.cancelRouting();\n\t\t\t\t\t}\n\t\t\t\t\talert(Locale.get(\"trace.RouteCalculation\"), Locale.get(\"trace.Cancelled\"), 1500);\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"trace.Routing\"), Locale.get(\"generic.Off\"), 750);\n\t\t\t\t}\n\t\t\t\tendRouting();\n\t\t\t\troutingsMenu = null; \n\t\t\t\tsynchronized (this) {\n\t\t\t\t\tif (imageCollector != null) {\n\t\t\t\t\t\timageCollector.newDataReady();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\troutingsMenu = null; \n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ZOOM_IN_CMD]) {\n\t\t\t\tscale = scale / 1.5f;\n\t\t\t\tautoZoomed = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ZOOM_OUT_CMD]) {\n\t\t\t\tscale = scale * 1.5f;\n\t\t\t\tautoZoomed = false;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MANUAL_ROTATION_MODE_CMD]) {\n\t\t\t\tmanualRotationMode = !manualRotationMode;\n\t\t\t\tif (manualRotationMode) {\n\t\t\t\t\tif (hasPointerEvents()) {\n\t\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"trace.ChangeCourse\"), 3000);\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"trace.ChangeCourseWithLeftRightKeys\"), 3000);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"generic.Off\"), 750);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_OVERLAY_CMD]) {\n\t\t\t\tshowAddons++;\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_BACKLIGHT_CMD]) {\n\t\t\t\tConfiguration.setCfgBitState(Configuration.CFGBIT_BACKLIGHT_ON,\n\t\t\t\t\t\t\t\t\t!(Configuration.getCfgBitState(Configuration.CFGBIT_BACKLIGHT_ON)),\n\t\t\t\t\t\t\t\t\tfalse);\n\t\t\t\tlastBackLightOnTime = System.currentTimeMillis();\n\t\t\t\tparent.showBackLightLevel();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_FULLSCREEN_CMD]) {\n\t\t\t\tboolean fullScreen = !Configuration.getCfgBitState(Configuration.CFGBIT_FULLSCREEN);\n\t\t\t\tConfiguration.setCfgBitState(Configuration.CFGBIT_FULLSCREEN, fullScreen, false);\n\t\t\t\tsetFullScreenMode(fullScreen);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_MAP_PROJ_CMD]) {\n\t\t\t\tif (manualRotationMode) {\n\t\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\t\t\t\tcompassDeviation = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcourse = 0;\n\t\t\t\t\t}\n\t\t\t\t\talert(Locale.get(\"trace.ManualRotation\"), Locale.get(\"trace.ManualToNorth\"), 750);\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"guidiscover.MapProjection\"), ProjFactory.nextProj(), 750);\n\t\t\t\t}\n\t\t\t\tsynchronized (this) {\n\t\t\t\t\tif (imageCollector != null) {\n\t\t\t\t\t\timageCollector.newDataReady();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_KEY_LOCK_CMD]) {\n\t\t\t\tkeyboardLocked = !keyboardLocked;\n\t\t\t\tif (keyboardLocked) {\n\t\t\t\t\tkeyPressed(0);\n\t\t\t\t} else {\n\t\t\t\t\talert(Locale.get(\"trace.GpsMid\"), hasPointerEvents() ? Locale.get(\"trace.KeysAndTouchscreenUnlocked\") : Locale.get(\"trace.KeysUnlocked\"), 1000);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_RECORDING_CMD]) {\n\t\t\t\tif ( gpx.isRecordingTrk() ) {\n\t\t\t\t\tcommandAction(STOP_RECORD_CMD);\n\t\t\t\t} else {\n\t\t\t\t\tcommandAction(START_RECORD_CMD);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[TOGGLE_RECORDING_SUSP_CMD]) {\n\t\t\t\tif (gpx.isRecordingTrk()) {\n\t\t\t\t\tif ( gpx.isRecordingTrkSuspended() ) {\n\t\t\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.ResumingRecording\"), 1000);\n\t\t\t\t\t\tgpx.resumeTrk();\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert(Locale.get(\"trace.GpsRecording\"), Locale.get(\"trace.SuspendingRecording\"), 1000);\n\t\t\t\t\t\tgpx.suspendTrk();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[RECENTER_GPS_CMD]) {\n\t\t\t\tgpsRecenter = true;\n\t\t\t\tgpsRecenterInvalid = true;\n\t\t\t\tgpsRecenterStale = true;\n\t\t\t\tautoZoomed = true;\n\t\t\t\tif (pos.latitude != 0.0f) {\n\t\t\t\t\treceivePosition(pos);\n\t\t\t\t}\n\t\t\t\tnewDataReady();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SHOW_DEST_CMD]) {\n\t\t\t\tif (dest != null) {\n\t\t\t\t\tgpsRecenter = false;\n\t\t\t\t\tprevPositionNode = center.copy(); \n\t\t\t\t\tcenter.setLatLonRad(dest.lat, dest.lon);\t\t\t\t\t\t\n\t\t\t\t\tmovedAwayFromDest = false;\n\t\t\t\t\tupdatePosition();\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\talert(Locale.get(\"trace.ShowDestination\"), Locale.get(\"trace.DestinationNotSpecifiedYet\"), 3000);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SHOW_PREVIOUS_POSITION_CMD]) {\n\t\t\t\tif (prevPositionNode != null) {\n\t\t\t\t\tgpsRecenter = false;\n\t\t\t\t\tcenter.setLatLon(prevPositionNode);\t\t\t\t\t\t\n\t\t\t\t\tupdatePosition();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (c == CMDS[DATASCREEN_CMD]) {\n\t\t\t\tshowNextDataScreen(DATASCREEN_NONE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ICON_MENU] && Configuration.getCfgBitState(Configuration.CFGBIT_ICONMENUS)) {\n\t\t\t\tshowIconMenu();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[SETUP_CMD]) {\n\t\t\t\tnew GuiDiscover(parent);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[ABOUT_CMD]) {\n\t\t\t\tnew Splash(parent, GpsMid.initDone);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[CELLID_LOCATION_CMD]) {\n\t\t\t\tif (Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_SECELL && locationProducer != null) {\n\t\t\t\t\t\tlocationProducer.triggerPositionUpdate();\n\t\t\t\t\t\tnewDataReady();\n\t\t\t\t} else {\n\t\t\t\t\tif (cellIDLocationProducer == null) {\n\t\t\t\t\t\tcellIDLocationProducer = new SECellID();\n\t\t\t\t\t\tif (cellIDLocationProducer != null && !cellIDLocationProducer.init(this)) {\n\t\t\t\t\t\t\tlogger.info(\"Failed to initialise CellID location producer\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (cellIDLocationProducer != null) {\n\t\t\t\t\t\tcellIDLocationProducer.triggerPositionUpdate();\n\t\t\t\t\t\tnewDataReady();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (c == CMDS[MANUAL_LOCATION_CMD]) {\n\t\t\t\tPosition setpos = new Position(center.radlat / MoreMath.FAC_DECTORAD,\n \t\t\t\t\t\t\t\tcenter.radlon / MoreMath.FAC_DECTORAD,\n\t\t\t\t\t\t\t\t PositionMark.INVALID_ELEVATION, 0.0f, 0.0f, 1,\n\t\t\t\t\t\t\t System.currentTimeMillis(), Position.TYPE_MANUAL);\n\t\t\t\tgpsRecenter = true;\n\t\t\t\tautoZoomed = true;\n\t\t\t\treceivePosition(setpos);\n\t\t\t\treceiveStatus(LocationMsgReceiver.STATUS_MANUAL, 0);\n\t\t\t\tnewDataReady();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (! routeCalc) {\n\t\t\t\tif (c == CMDS[RETRIEVE_XML]) {\n\t\t\t\t\tif (Legend.enableEdits) {\n\t\t\t\t\t\tif ((pc.actualWay != null) && (getUrl(pc.actualWay.urlIdx) != null)) {\n\t\t\t\t\t\t\tparent.alert (\"Url\", \"Url: \" + getUrl(pc.actualWay.urlIdx), Alert.FOREVER);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ((pc.actualWay != null) && (pc.actualWay instanceof EditableWay)) {\n\t\t\t\t\t\t\tEditableWay eway = (EditableWay)pc.actualWay;\n\t\t\t\t\t\t\tGUIosmWayDisplay guiWay = new GUIosmWayDisplay(eway, pc.actualSingleTile, this);\n\t\t\t\t\t\t\tguiWay.show();\n\t\t\t\t\t\t\tguiWay.refresh();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparent.alert(\"Editing\", \"Editing support was not enabled in Osm2GpsMid\", Alert.FOREVER);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[RETRIEVE_NODE]) {\n\t\t\t\t\tif (Legend.enableEdits) {\n\t\t\t\t\t\tGuiOSMPOIDisplay guiNode = new GuiOSMPOIDisplay(-1, null,\n\t\t\t\t\t\t\t\tcenter.radlat, center.radlon, this);\n\t\t\t\t\t\tguiNode.show();\n\t\t\t\t\t\tguiNode.refresh();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(Locale.get(\"trace.EditingIsNotEnabled\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[EDIT_ADDR_CMD]) {\n\t\t\t\t\tif (Legend.enableEdits) {\n\t\t\t\t\t\tString streetName = \"\";\n\t\t\t\t\t\tif ((pc != null) && (pc.actualWay != null)) {\n\t\t\t\t\t\t\tstreetName = getName(pc.actualWay.nameIdx);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tGuiOSMAddrDisplay guiAddr = new GuiOSMAddrDisplay(-1, streetName, null,\n\t\t\t\t\t\t\t\tcenter.radlat, center.radlon, this);\n\t\t\t\t\t\tguiAddr.show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(Locale.get(\"trace.EditingIsNotEnabled\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[RETRIEVE_XML] || c == CMDS[RETRIEVE_NODE] || c == CMDS[EDIT_ADDR_CMD]) {\n\t\t\t\t\talert(\"No online capabilites\",\n\t\t\t\t\t Locale.get(\"trace.SetAppGeneric\") +\n\t\t\t\t\t Locale.get(\"trace.PropertiesFile\"),\n\t\t\t\t\t\tAlert.FOREVER);\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[SET_DEST_CMD]) {\n\t\t\t\t\tRoutePositionMark pm1 = new RoutePositionMark(center.radlat, center.radlon);\n\t\t\t\t\tsetDestination(pm1);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (c == CMDS[CLEAR_DEST_CMD]) {\n\t\t\t\t\tsetDestination(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\talert(Locale.get(\"trace.Error\"), Locale.get(\"trace.CurrentlyInRouteCalculation\"), 2000);\n\t\t\t}\n\t\t} catch (Exception e) {\n \t\t\tlogger.exception(Locale.get(\"trace.InTraceCommandAction\"), e);\n\t\t}\n\t}\n\tprivate void startImageCollector() throws Exception {\n\t\tlogger.info(\"Starting ImageCollector\");\n\t\tImages images = new Images();\n\t\tpc = new PaintContext(this, images);\n\t\timageCollector = new ImageCollector(tiles, this.getWidth(), this.getHeight(), this, images);\n\t\tpc.center = center.copy();\n\t\tpc.scale = scale;\n\t\tpc.xSize = this.getWidth();\n\t\tpc.ySize = this.getHeight();\n\t}\n\tprivate void stopImageCollector(){\n\t\tlogger.info(\"Stopping ImageCollector\");\n\t\tcleanup();\n\t\tif (imageCollector != null ) {\n\t\t\timageCollector.stop();\n\t\t\timageCollector=null;\n\t\t}\n\t\tSystem.gc();\n\t}\n\tpublic void startup() throws Exception {\n\t\tnamesThread = new Names();\n\t\turlsThread = new Urls();\n\t\tnew DictReader(this);\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_AUTO_START_GPS)) {\n\t\t\tThread thread = new Thread(this, \"Trace\");\n\t\t\tthread.start();\n\t\t}\n\t\ttileReader = new QueueDataReader(this);\n\t\tdictReader = new QueueDictReader(this);\n\t\tthis.gpx = new Gpx();\n\t\tthis.audioRec = new AudioRecorder();\n\t\tsetDict(gpx, (byte)5);\n\t\tstartImageCollector();\n\t\trecreateTraceLayout();\n\t}\n\tpublic void shutdown() {\n\t\tif (gpx != null) {\n\t\t\tgpx.saveTrk(true);\n\t\t}\n\t\tlogger.debug(\"Shutdown: stopImageCollector\");\n\t\tstopImageCollector();\n\t\tif (namesThread != null) {\n\t\t\tlogger.debug(\"Shutdown: namesThread\");\n\t\t\tnamesThread.stop();\n\t\t\tnamesThread = null;\n\t\t}\n\t\tif (urlsThread != null) {\n\t\t\turlsThread.stop();\n\t\t\turlsThread = null;\n\t\t}\n\t\tif (dictReader != null) {\n\t\t\tlogger.debug(\"Shutdown: dictReader\");\n\t\t\tdictReader.shutdown();\n\t\t\tdictReader = null;\n\t\t}\n\t\tif (tileReader != null) {\n\t\t\tlogger.debug(\"Shutdown: tileReader\");\n\t\t\ttileReader.shutdown();\n\t\t\ttileReader = null;\n\t\t}\n\t\tif (locationProducer != null) {\n\t\t\tlogger.debug(\"Shutdown: locationProducer\");\n\t\t\tlocationProducer.close();\n\t\t}\n\t\tif (TrackPlayer.isPlaying) {\n\t\t\tlogger.debug(\"Shutdown: TrackPlayer\");\n\t\t\tTrackPlayer.getInstance().stop();\n\t\t}\n\t}\n\tpublic void sizeChanged(int w, int h) {\n\t\tupdateLastUserActionTime();\n\t\tif (imageCollector != null) {\n\t\t\tlogger.info(\"Size of Canvas changed to \" + w + \"|\" + h);\n\t\t\tstopImageCollector();\n\t\t\ttry {\n\t\t\t\tstartImageCollector();\n\t\t\t\timageCollector.resume();\n\t\t\t\timageCollector.newDataReady();\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.exception(Locale.get(\"trace.CouldNotReinitialiseImageCollector\"), e);\n\t\t\t}\n\t\t\tupdatePosition();\n\t\t}\n\t\ttl = new TraceLayout(0, 0, w, h);\n\t}\n\tprotected void paint(Graphics g) {\n\t\tlogger.debug(\"Drawing Map screen\");\n\t\ttry {\n\t\t\tint yc = 1;\n\t\t\tint la = 18;\n\t\t\tgetPC();\n\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_BACKGROUND]);\n\t\t\tg.fillRect(0, 0, this.getWidth(), this.getHeight());\n\t\t\tpc.g = g;\n\t\t\tif (imageCollector != null) {\n\t\t\t\tNode drawnCenter = imageCollector.paint(pc);\n\t\t\t\tif (route != null && ri != null && pc.lineP2 != null) {\n\t\t\t\t\tpc.getP().forward(drawnCenter.radlat, drawnCenter.radlon, pc.lineP2);\n\t\t\t\t\tint maxAllowedMapMoveOffs = Math.min(pc.xSize/2, pc.ySize/2);\n\t\t\t\t\tif ( Math.abs(pc.lineP2.x - pc.getP().getImageCenter().x) < maxAllowedMapMoveOffs\n\t\t\t\t\t\t &&\n\t\t\t\t\t\t Math.abs(pc.lineP2.y - pc.getP().getImageCenter().y) < maxAllowedMapMoveOffs\n\t\t\t\t\t) {\n\t\t\t\t\t\tri.showRoute(pc, drawnCenter,imageCollector.xScreenOverscan,imageCollector.yScreenOverscan);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttl.ele[TraceLayout.WAYNAME].setText(\" \");\n\t\t\t}\n\t\t\tif (dest != null) {\n\t\t\t\tfloat distance = ProjMath.getDistance(dest.lat, dest.lon, center.radlat, center.radlon);\n\t\t\t\tatDest = (distance < 25);\n\t\t\t\tif (atDest) {\n\t\t\t\t\tif (movedAwayFromDest && Configuration.getCfgBitState(Configuration.CFGBIT_SND_DESTREACHED)) {\n\t\t\t\t\t\tGpsMid.mNoiseMaker.playSound(RouteSyntax.getInstance().getDestReachedSound(), (byte) 7, (byte) 1);\n\t\t\t\t\t}\n\t\t\t\t} else if (!movedAwayFromDest) {\n\t\t\t\t\tmovedAwayFromDest = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tspeeding = false;\n\t\t\tint maxSpeed = 0;\n\t\t\tif (gpsRecenter && actualSpeedLimitWay != null) {\n\t\t\t\tmaxSpeed = actualSpeedLimitWay.getMaxSpeed();\n\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_MAXSPEED_WINTER)\n \t\t&& (actualSpeedLimitWay.getMaxSpeedWinter() > 0)) {\n\t\t\t\t\tmaxSpeed = actualSpeedLimitWay.getMaxSpeedWinter();\n }\n\t\t\t\tif (maxSpeed != 0 && speed > (maxSpeed + Configuration.getSpeedTolerance()) ) {\n\t\t\t\t\tspeeding = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (speeding && Configuration.getCfgBitState(Configuration.CFGBIT_SPEEDALERT_SND)) {\n\t\t\t\tif ( (System.currentTimeMillis() - lastTimeOfSpeedingSound) > 10000 ) {\n\t\t\t\t\tlastTimeOfSpeedingSound = System.currentTimeMillis();\n\t\t\t\t\tGpsMid.mNoiseMaker.immediateSound(RouteSyntax.getInstance().getSpeedLimitSound());\n\t\t\t\t}\n\t\t\t}\n\t\t\tg.setColor(Legend.COLOR_MAP_TEXT);\n\t\t\tswitch (showAddons) {\n\t\t\tcase 1:\n\t\t\t\tyc = showMemory(g, yc, la);\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tyc = showConnectStatistics(g, yc, la);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tshowAddons = 0;\n\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_SCALE_BAR)) {\n\t\t\t\t\tif (pc != null) {\n\t\t\t\t\t\ttl.calcScaleBarWidth(pc);\n\t\t\t\t\t\ttl.ele[TraceLayout.SCALEBAR].setText(\" \");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsetPointOfTheCompass();\n\t\t\t}\n\t\t\tshowMovement(g);\n\t\t\tLayoutElement eSolution = tl.ele[TraceLayout.SOLUTION];\n\t\t\tLayoutElement eRecorded = tl.ele[TraceLayout.RECORDED_COUNT];\n\t\t\tif (gpx.isRecordingTrk()) {\n\t\t\t\tif (gpx.isRecordingTrkSuspended()) {\n\t\t\t\t\teRecorded.setColor(Legend.COLORS[Legend.COLOR_RECORDING_SUSPENDED_TEXT]); \n\t\t\t\t} else {\n\t\t\t\t\teRecorded.setColor(Legend.COLORS[Legend.COLOR_RECORDING_ON_TEXT]); \n\t\t\t\t}\n\t\t\t\teRecorded.setText(gpx.getTrkPointCount() + Locale.get(\"trace.r\"));\n\t\t\t}\n\t\t\tif (TrackPlayer.isPlaying) {\n\t\t\t\teSolution.setText(Locale.get(\"trace.Replay\"));\n\t\t\t} else {\n\t\t\t\tif (locationProducer == null && !(solution == LocationMsgReceiver.STATUS_CELLID ||\n\t\t\t\t\t\t\t\t\t\t solution == LocationMsgReceiver.STATUS_MANUAL)) {\n\t\t\t\t\teSolution.setText(Locale.get(\"solution.Off\"));\n\t\t\t\t} else {\n\t\t\t\t\teSolution.setText(solutionStr);\n\t\t\t\t}\n\t\t\t}\n\t\t\tLayoutElement e = tl.ele[TraceLayout.CELLID];\n\t\t\tif (SECellLocLogger.isCellIDLogging() > 0) {\n\t\t\t\tif (SECellLocLogger.isCellIDLogging() == 2) {\n\t\t\t\t\te.setColor(Legend.COLORS[Legend.COLOR_CELLID_LOG_ON_TEXT]); \n\t\t\t\t} else {\n\t\t\t\t\te.setColor(Legend.COLORS[Legend.COLOR_CELLID_LOG_ON_ATTEMPTING_TEXT]); \n\t\t\t\t}\n\t\t\t\te.setText(Locale.get(\"trace.cellIDs\"));\n\t\t\t}\n\t\t\te = tl.ele[TraceLayout.AUDIOREC];\n\t\t\tif (audioRec.isRecording()) {\n\t\t\t\te.setColor(Legend.COLORS[Legend.COLOR_AUDIOREC_TEXT]); \n\t\t\t\te.setText(Locale.get(\"trace.AudioRec\"));\n\t\t\t}\n\t\t\tif (pc != null) {\n\t\t\t\tshowDestination(pc);\n\t\t\t}\n\t\t\tif (speed > 0 &&\n\t\t\t\t\tConfiguration.getCfgBitState(Configuration.CFGBIT_SHOW_SPEED_IN_MAP)) {\n\t\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_METRIC)) {\n\t\t\t\t\ttl.ele[TraceLayout.SPEED_CURRENT].setText(\" \" + Integer.toString(speed) + Locale.get(\"trace.kmh\"));\n\t\t\t\t} else {\n\t\t\t\t\ttl.ele[TraceLayout.SPEED_CURRENT].setText(\" \" + Integer.toString((int)(speed / 1.609344f)) + \" mph\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_ALTITUDE_IN_MAP)\n\t\t\t\t&& locationProducer != null\n\t\t\t\t&& LocationMsgReceiverList.isPosValid(solution)\n\t\t\t) {\n\t\t\t\ttl.ele[TraceLayout.ALTITUDE].setText(showDistance(altitude, DISTANCE_ALTITUDE));\n\t\t\t}\n\t\t\tif (dest != null && (route == null || (!RouteLineProducer.isRouteLineProduced() && !RouteLineProducer.isRunning()) ) \n\t\t\t\t&& Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_AIR_DISTANCE_IN_MAP)) {\n\t\t\t\te = Trace.tl.ele[TraceLayout.ROUTE_DISTANCE];\n\t\t\t\te.setBackgroundColor(Legend.COLORS[Legend.COLOR_RI_DISTANCE_BACKGROUND]);\n\t\t\t\tdouble distLine = ProjMath.getDistance(center.radlat, center.radlon, dest.lat, dest.lon);\n\t\t\t\te.setText(Locale.get(\"trace.Air\") + showDistance((int) distLine, DISTANCE_AIR));\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_CLOCK_IN_MAP)) {\n\t\t\t\te = tl.ele[TraceLayout.CURRENT_TIME]; \n\t\t\t\te.setText(DateTimeTools.getClock(System.currentTimeMillis(), true));\n\t\t\t\ttl.ele[TraceLayout.ROUTE_OFFROUTE].setVRelative(e);\n\t\t\t}\n\t\t\tsetSpeedingSign(maxSpeed);\n\t\t\tif (hasPointerEvents()) {\n\t\t\t\ttl.ele[TraceLayout.ZOOM_IN].setText(\"+\");\n\t\t\t\ttl.ele[TraceLayout.ZOOM_OUT].setText(\"-\");\n\t\t\t\ttl.ele[TraceLayout.RECENTER_GPS].setText(\"|\");\n\t\t\t\te = tl.ele[TraceLayout.SHOW_DEST];\n\t\t\t\tif (atDest && prevPositionNode != null) {\n\t\t\t\t\te.setText(\"<\");\n\t\t\t\t\te.setActionID(SHOW_PREVIOUS_POSITION_CMD);\n\t\t\t\t} else {\n\t\t\t\t\te.setText(\">\");\n\t\t\t\t\te.setActionID(SHOW_DEST_CMD + (Trace.SET_DEST_CMD << 16) );\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\te = tl.ele[TraceLayout.TITLEBAR];\n\t\t\tif (currentTitleMsgOpenCount != 0) {\n\t\t\t\te.setText(currentTitleMsg);\n\t\t\t\tsynchronized (this) {\n\t\t\t\t\tif (setTitleMsgTimeout != 0) {\n\t\t\t\t\t\tTimerTask timerT = new TimerTask() {\n\t\t\t\t\t\t\tpublic synchronized void run() {\n\t\t\t\t\t\t\t\tcurrentTitleMsgOpenCount--;\n\t\t\t\t\t\t\t\tlastTitleMsg = currentTitleMsg;\n\t\t\t\t\t\t\t\tif (currentTitleMsgOpenCount == 0) {\n\t\t\t\t\t\t\t\t\tlogger.debug(\"clearing title\");\n\t\t\t\t\t\t\t\t\trepaint();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tGpsMid.getTimer().schedule(timerT, setTitleMsgTimeout);\n\t\t\t\t\t\tsetTitleMsgTimeout = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttl.paint(g);\n\t\t\tif (currentAlertsOpenCount > 0) {\n\t\t\t\tshowCurrentAlert(g);\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tlogger.silentexception(\"Unhandled exception in the paint code\", e);\n\t\t}\n\t}\n\tpublic void showGuiWaypointSave(PositionMark posMark) {\n \tif (guiWaypointSave == null) {\n \t\tguiWaypointSave = new GuiWaypointSave(this);\n \t}\n \tif (guiWaypointSave != null) {\n \t\tguiWaypointSave.setData(posMark);\n \t\tguiWaypointSave.show();\n \t}\n\t}\n\tprivate void showAlertLoadingWpt() {\n\t\talert(\"Way points\", \"Way points are not ready yet.\", 3000);\n\t}\n\tprivate void showCurrentAlert(Graphics g) {\n\t\tFont font = g.getFont();\n\t\tFont titleFont = Font.getFont(font.getFace(), Font.STYLE_BOLD, font.getSize());\n\t\tint fontHeight = font.getHeight();\n\t\tint y = titleFont.getHeight() + 2 + fontHeight;\n\t\tint extraWidth = font.charWidth('W');\n\t\tint alertWidth = titleFont.stringWidth(currentAlertTitle);\n\t\tint maxWidth = getWidth() - extraWidth;\n\t\tfor (int i = 0; i <= 1; i++) {\n\t\t\tint nextSpaceAt = 0;\n\t\t\tint prevSpaceAt = 0;\n\t\t\tint start = 0;\n\t\t\tdo {\n\t\t\t\tint width = 0;\n\t\t\t\twhile (width < maxWidth && nextSpaceAt <= currentAlertMessage.length() ) {\n\t\t\t\t\tprevSpaceAt = nextSpaceAt;\n\t\t\t\t\tnextSpaceAt = currentAlertMessage.indexOf(' ', nextSpaceAt);\n\t\t\t\t\tif (nextSpaceAt == -1) {\n\t\t\t\t\t\tnextSpaceAt = currentAlertMessage.length();\n\t\t\t\t\t}\n\t\t\t\t\twidth = font.substringWidth(currentAlertMessage, start, nextSpaceAt - start);\n\t\t\t\t\tnextSpaceAt++;\n\t\t\t\t}\n\t\t\t\tnextSpaceAt--;\n\t\t\t\twhile (width > maxWidth) {\n\t\t\t\t\tif (prevSpaceAt > start && nextSpaceAt > prevSpaceAt) {\n\t\t\t\t\t\tnextSpaceAt = prevSpaceAt;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextSpaceAt--;\n\t\t\t\t\t}\n\t\t\t\t\twidth = font.substringWidth(currentAlertMessage, start, nextSpaceAt - start);\n\t\t\t\t}\n\t\t\t\tif (alertWidth < width ) {\n\t\t\t\t\talertWidth = width;\n\t\t\t\t}\n\t\t\t\tif (i==1) {\n\t\t\t\t\tg.drawSubstring(currentAlertMessage, start, nextSpaceAt - start,\n\t\t\t\t\t\t\tgetWidth()/2, y, Graphics.TOP|Graphics.HCENTER);\n\t\t\t\t}\n\t\t\t\ty += fontHeight;\n\t\t\t\tstart = nextSpaceAt;\n\t\t\t} while (nextSpaceAt < currentAlertMessage.length() );\n\t\t\tif (i == 0) {\n\t\t\t\talertWidth += extraWidth;\n\t\t\t\tint alertHeight = y;\n\t\t\t\tint alertTop = (getHeight() - alertHeight) /2;\n\t\t\t\tint alertLeft = (getWidth() - alertWidth) / 2;\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_BACKGROUND]);\n\t\t\t\tg.fillRect(alertLeft, alertTop, alertWidth, alertHeight);\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_TITLE_BACKGROUND]);\n\t\t\t\tg.fillRect(alertLeft, alertTop, alertWidth, fontHeight + 3);\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_BORDER]);\n\t\t\t\tg.setStrokeStyle(Graphics.SOLID);\n\t\t\t\tg.drawRect(alertLeft, alertTop, alertWidth, fontHeight + 3); \n\t\t\t\tg.drawRect(alertLeft, alertTop, alertWidth, alertHeight); \n\t\t\t\ty = alertTop + 2; \n\t\t\t\tg.setFont(titleFont);\n\t\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_ALERT_TEXT]);\n\t\t\t\tg.drawString(currentAlertTitle, getWidth()/2, y , Graphics.TOP|Graphics.HCENTER);\n\t\t\t\tg.setFont(font);\n\t\t\t\ty += (fontHeight * 3 / 2);\n\t\t\t}\n\t\t} \n\t\tsynchronized (this) {\n\t\t\tif (setAlertTimeout != 0) {\n\t\t\t\tTimerTask timerT = new TimerTask() {\n\t\t\t\t\tpublic synchronized void run() {\n\t\t\t\t\t\tcurrentAlertsOpenCount--;\n\t\t\t\t\t\tif (currentAlertsOpenCount == 0) {\n\t\t\t\t\t\t\tlogger.debug(\"clearing alert\");\n\t\t\t\t\t\t\trepaint();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tGpsMid.getTimer().schedule(timerT, setAlertTimeout);\n\t\t\t\tsetAlertTimeout = 0;\n\t\t\t}\n\t\t}\n\t}\n\tprivate void setSpeedingSign(int maxSpeed) {\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SPEEDALERT_VISUAL)\n\t\t\t&&\n\t\t\t(\n\t\t\t\tspeeding\n\t\t\t\t||\n\t\t\t\t(System.currentTimeMillis() - startTimeOfSpeedingSign) < 3000\n\t\t\t)\n\t\t) {\n\t\t\tif (speeding) {\n\t\t\t\tspeedingSpeedLimit = maxSpeed;\n\t\t\t\tstartTimeOfSpeedingSign = System.currentTimeMillis();\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_METRIC)) {\n\t\t\t\ttl.ele[TraceLayout.SPEEDING_SIGN].setText(Integer.toString(speedingSpeedLimit));\n\t\t\t} else {\n\t\t\t\ttl.ele[TraceLayout.SPEEDING_SIGN].setText(Integer.toString((int)(speedingSpeedLimit / 1.609344f)));\n\t\t\t}\n\t\t} else {\n\t\t\tstartTimeOfSpeedingSign = 0;\n\t\t}\n\t}\n\tprivate void getPC() {\n\t\t\tpc.course = course;\n\t\t\tpc.scale = scale;\n\t\t\tpc.center = center.copy();\n\t\t\tpc.dest = dest;\n\t}\n\tpublic void cleanup() {\n\t\tnamesThread.cleanup();\n\t\turlsThread.cleanup();\n\t\ttileReader.incUnusedCounter();\n\t\tdictReader.incUnusedCounter();\n\t}\n\tpublic void searchNextRoutableWay(RoutePositionMark pm) throws Exception {\n\t\tPaintContext pc = new PaintContext(this, null);\n\t\tpc.squareDstToActualRoutableWay = Float.MAX_VALUE;\n\t\tpc.xSize = 100;\n\t\tpc.ySize = 100;\n\t\tProjection p;\n\t\tdo {\n\t\t\tp = new Proj2D(new Node(pm.lat,pm.lon, true),5000,pc.xSize,pc.ySize);\n\t\t\tpc.setP(p);\n\t\t\tfor (int i=0; i<4; i++) {\n\t\t\t\ttiles[i].walk(pc, Tile.OPT_WAIT_FOR_LOAD | Tile.OPT_FIND_CURRENT);\n\t\t\t}\n\t\t\tif (pc.actualRoutableWay != null) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpc.xSize += 100;\n\t\t\tpc.ySize += 100;\n\t\t} while(MoreMath.dist(p.getMinLat(), p.getMinLon(), p.getMinLat(), p.getMaxLon()) < 500); \n\t\tWay w = pc.actualRoutableWay;\n\t\tpm.setEntity(w, pc.currentPos.nodeLat, pc.currentPos.nodeLon);\n\t}\n\tprivate void setPointOfTheCompass() {\n\t\tString c = \"\";\n\t\tif (ProjFactory.getProj() != ProjFactory.NORTH_UP\n\t\t\t\t&& Configuration.getCfgBitState(Configuration.CFGBIT_SHOW_POINT_OF_COMPASS)) {\n\t\t\tc = Configuration.getCompassDirection(course);\n\t\t}\n\t\tif (tl.bigOnScreenButtons && c.length() <= 1) {\n\t\t\tif (ProjFactory.getProj() == ProjFactory.NORTH_UP) {\n\t\t\t\tc = \"(\" + Configuration.getCompassDirection(0) + \")\";\n\t\t\t} else {\n\t\t\t\tc = \" \" + c + \" \";\n\t\t\t}\n\t\t}\n\t\ttl.ele[TraceLayout.POINT_OF_COMPASS].setText(c);\n\t}\n\tprivate int showConnectStatistics(Graphics g, int yc, int la) {\n\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_TEXT]);\n\t\tGSMCell cell = null;\n\t\tif (cellIDLocationProducer != null || Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_SECELL) {\n\t\t\tcell = CellIdProvider.getInstance().obtainCachedCellID();\n\t\t}\n\t\tCompass compass = null;\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION)) {\n\t\t\tcompass = CompassProvider.getInstance().obtainCachedCompass();\n\t\t}\n\t\tif (cell == null) {\n\t\t\tg.drawString(\"No Cell ID available\", 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t} else {\n\t\t\tg.drawString(\"Cell: MCC=\" + cell.mcc + \" MNC=\" + cell.mnc, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t\tg.drawString(\"LAC=\" + cell.lac, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t\tg.drawString(\"cellID=\" + cell.cellID, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t}\n\t\tif (compass == null) {\n\t\t\tg.drawString(\"No compass direction available\", 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t} else {\n\t\t\tg.drawString(\"Compass direction: \" + compass.direction, 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t}\n\t\tif (statRecord == null) {\n\t\t\tg.drawString(\"No stats yet\", 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\treturn yc+la;\n\t\t}\n\t\tfor (byte i = 0; i < LocationMsgReceiver.SIRF_FAIL_COUNT; i++) {\n\t\t\tg.drawString(statMsg[i] + statRecord[i], 0, yc, Graphics.TOP\n\t\t\t\t\t| Graphics.LEFT);\n\t\t\tyc += la;\n\t\t}\n\t\tg.drawString(\"BtQual : \" + btquality, 0, yc, Graphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(\"Count : \" + collected, 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\treturn yc;\n\t}\n\tpublic void showDestination(PaintContext pc) {\n\t\ttry {\n\t\tif (dest != null) {\n\t\t\tpc.getP().forward(dest.lat, dest.lon, pc.lineP2);\n\t\t\tint x = pc.lineP2.x - imageCollector.xScreenOverscan;\n\t\t\tint y = pc.lineP2.y - imageCollector.yScreenOverscan;\n\t\t\tpc.g.drawImage(pc.images.IMG_DEST, x, y, CENTERPOS);\n\t\t\tpc.g.setColor(Legend.COLORS[Legend.COLOR_DEST_TEXT]);\n\t\t\tif (dest.displayName != null) {\n\t\t\t\tpc.g.drawString(dest.displayName, x, y+8,\n\t\t\t\t\tGraphics.TOP | Graphics.HCENTER);\n\t\t\t}\n\t\t\tpc.g.setColor(Legend.COLORS[Legend.COLOR_DEST_LINE]);\n\t\t\tpc.g.setStrokeStyle(Graphics.SOLID);\n\t\t\tpc.g.drawLine(x, y, pc.getP().getImageCenter().x - imageCollector.xScreenOverscan, \n\t\t\t\t\tpc.getP().getImageCenter().y - imageCollector.yScreenOverscan);\n\t\t}\n\t\t} catch (Exception e) {\n\t\t\tif (imageCollector == null) {\n\t\t\t\tlogger.silentexception(\"No ImageCollector\", e);\n\t\t\t}\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\tpublic void showMovement(Graphics g) {\n\t\tIntPoint centerP = null;\n\t\ttry {\n\t\t\tif (imageCollector != null) {\n\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_CURSOR]);\n\t\t\tcenterP = pc.getP().getImageCenter();\n\t\t\tint centerX = centerP.x - imageCollector.xScreenOverscan;\n\t\t\tint centerY = centerP.y - imageCollector.yScreenOverscan;\n\t\t\tint posX, posY;\n\t\t\tif (!gpsRecenter) {\n\t\t\t\tIntPoint p1 = new IntPoint(0, 0);\n\t\t\t\tpc.getP().forward((pos.latitude * MoreMath.FAC_DECTORAD),\n\t\t\t\t\t\t\t\t (pos.longitude * MoreMath.FAC_DECTORAD), p1);\n\t\t\t\tposX = p1.getX()-imageCollector.xScreenOverscan;\n\t\t\t\tposY = p1.getY()-imageCollector.yScreenOverscan;\n\t\t\t} else {\n\t\t\t\tposX = centerX;\n\t\t\t\tposY = centerY;\n\t\t\t}\n\t\t\tg.setColor(Legend.COLORS[Legend.COLOR_MAP_POSINDICATOR]);\n\t\t\tfloat radc = course * MoreMath.FAC_DECTORAD;\n\t\t\tint px = posX + (int) (Math.sin(radc) * 20);\n\t\t\tint py = posY - (int) (Math.cos(radc) * 20);\n\t\t\tif (!gpsRecenter || gpsRecenterInvalid) {\n\t\t\t\tg.drawLine(centerX, centerY - 12, centerX, centerY + 12);\n\t\t\t\tg.drawLine(centerX - 12, centerY, centerX + 12, centerY);\n\t\t\t\tg.drawArc(centerX - 5, centerY - 5, 10, 10, 0, 360);\n\t\t\t}\n\t\t\tif (! gpsRecenterInvalid) {\n\t\t\t\tpc.g.drawImage(gpsRecenterStale ? pc.images.IMG_POS_BG_STALE : pc.images.IMG_POS_BG, posX, posY, CENTERPOS);\n\t\t\t\tg.drawRect(posX - 4, posY - 4, 8, 8);\n\t\t\t\tg.drawLine(posX, posY, px, py);\n\t\t\t}\n\t\t\t}\n\t\t} catch (Exception e) {\n\t\t\tif (imageCollector == null) {\n\t\t\t\tlogger.silentexception(\"No ImageCollector\", e);\n\t\t\t}\n\t\t\tif (centerP == null) {\n\t\t\t\tlogger.silentexception(\"No centerP\", e);\n\t\t\t}\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\tpublic void showNextDataScreen(int currentScreen) {\n\t\tswitch (currentScreen)\n\t\t{\n\t\t\tcase DATASCREEN_TACHO:\n\t\t\t\tif (guiTrip == null) {\n\t\t\t\t\tguiTrip = new GuiTrip(this);\n\t\t\t\t}\n\t\t\t\tif (guiTrip != null) {\n\t\t\t\t\tguiTrip.show();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase DATASCREEN_TRIP:\n\t\t\t\tif (guiSatellites == null) {\n\t\t\t\t\tguiSatellites = new GuiSatellites(this, locationProducer);\n\t\t\t\t}\n\t\t\t\tif (guiSatellites != null) {\n\t\t\t\t\tguiSatellites.show();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase DATASCREEN_SATS:\n\t\t\t\tthis.show();\n\t\t\t\tbreak;\n\t\t\tcase DATASCREEN_NONE:\n\t\t\tdefault:\n\t\t\t\tif (guiTacho == null) {\n\t\t\t\t\tguiTacho = new GuiTacho(this);\n\t\t\t\t}\n\t\t\t\tif (guiTacho != null) {\n\t\t\t\t\tguiTacho.show();\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tpublic int showMemory(Graphics g, int yc, int la) {\n\t\tg.setColor(0);\n\t\tg.drawString(Locale.get(\"trace.Freemem\") + runtime.freeMemory(), 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.Totmem\") + runtime.totalMemory(), 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.Percent\")\n\t\t\t\t+ (100f * runtime.freeMemory() / runtime.totalMemory()), 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.ThreadsRunning\")\n\t\t\t\t+ Thread.activeCount(), 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.Names\") + namesThread.getNameCount(), 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.SingleT\") + tileReader.getLivingTilesCount() + \"/\"\n\t\t\t\t+ tileReader.getRequestQueueSize(), 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.FileT\") + dictReader.getLivingTilesCount() + \"/\"\n\t\t\t\t+ dictReader.getRequestQueueSize() + \" Map: \" + ImageCollector.icDuration + \" ms\", 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString(Locale.get(\"trace.LastMsg\") + lastTitleMsg, 0, yc, Graphics.TOP\n\t\t\t\t| Graphics.LEFT);\n\t\tyc += la;\n\t\tg.drawString( Locale.get(\"trace.at\") + lastTitleMsgClock, 0, yc,\n\t\t\t\tGraphics.TOP | Graphics.LEFT );\n\t\treturn (yc);\n\t}\n\tprivate void updatePosition() {\n\t\tif (pc != null) {\n\t\t\tpc.center = center.copy();\n\t\t\tpc.scale = scale;\n\t\t\tpc.course=course;\n\t\t\trepaint();\n\t\t\tif (locationUpdateListeners != null && !TrackPlayer.isPlaying) {\n\t\t\t\tsynchronized (locationUpdateListeners) {\n\t\t\t\t\tfor (int i = 0; i < locationUpdateListeners.size(); i++) {\n\t\t\t\t\t\t((LocationUpdateListener)locationUpdateListeners.elementAt(i)).loctionUpdated();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tpublic synchronized void receivePosition(float lat, float lon, float scale) {\n\t\tlogger.debug(\"Now displaying: \" + (lat * MoreMath.FAC_RADTODEC) + \" | \" +\n\t\t\t (lon * MoreMath.FAC_RADTODEC));\n\t\tgpsRecenter = false;\n\t\tcenter.setLatLonRad(lat, lon);\n\t\tthis.scale = scale;\n\t\tupdatePosition();\n\t}\n\tpublic synchronized void receiveCompassStatus(int status) {\n\t}\n\tpublic synchronized void receiveCompass(float direction) {\n\t\tlogger.debug(\"Got compass reading: \" + direction);\n\t\tcompassDirection = (int) direction;\n\t\tcompassDeviated = ((int) direction + compassDeviation + 360) % 360;\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null && gpsRecenter) {\n\t\t\tupdateCourse(compassDeviated);\n\t\t}\n\t}\n\tpublic static void updateLastUserActionTime() {\n\t\tlastUserActionTime = System.currentTimeMillis();\n\t}\n\tpublic static long getDurationSinceLastUserActionTime() {\n\t\treturn System.currentTimeMillis() - lastUserActionTime;\n\t}\n\tpublic void updateCourse(int newcourse) {\n\t\tcoursegps = newcourse;\n\t\tif ((newcourse - course)> 180) {\n\t\t\tcourse = course + 360;\n\t\t}\n\t\tif ((course-newcourse)> 180) {\n\t\t\tnewcourse = newcourse + 360;\n\t\t}\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\tcourse = newcourse;\n\t\t} else {\n\t\t\tcourse = course + ((newcourse - course)*1)/4 + 360;\n\t\t}\n\t\twhile (course > 360) {\n\t\t\tcourse -= 360;\n\t\t}\n\t}\n\tpublic synchronized void receivePosition(Position pos) {\n\t\tlogger.info(\"New position: \" + pos);\n\t\tcollected++;\n\t\tif (Configuration.getAutoRecenterToGpsMilliSecs() !=0 &&\n\t\t\tgetDurationSinceLastUserActionTime() > Configuration.getAutoRecenterToGpsMilliSecs()\n\t\t\t&& isShown()\n\t\t) {\n\t\t\tgpsRecenter = true;\n\t\t}\n\t\tif (Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_JSR179) {\n\t\t\tif (pos.type == Position.TYPE_GPS_LASTKNOWN) {\n\t\t\t\tif (this.pos.type == Position.TYPE_CELLID) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tgpsRecenterInvalid = false;\n\t\t\t\tgpsRecenterStale = true;\n\t\t\t}\n\t\t}\n\t\tthis.pos = pos;\n\t\tif (pos.type == Position.TYPE_GPS || pos.type == Position.TYPE_CELLID || pos.type == Position.TYPE_MANUAL) {\n\t\t\tgpsRecenterInvalid = false;\n\t\t\tgpsRecenterStale = false;\n\t\t}\n\t\tif (gpsRecenter) {\n\t\t\tcenter.setLatLonDeg(pos.latitude, pos.longitude);\n\t\t\tspeed = (int) (pos.speed * 3.6f);\n\t\t\tfspeed = pos.speed * 3.6f;\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_COMPASS_DIRECTION) && compassProducer != null) {\n\t\t\t\tupdateCourse(compassDeviated);\n } else if (fspeed >= courseMinSpeed && pos.course != Float.NaN ) {\n if (thirdPrevCourse != -1) {\n updateCourse((int) pos.course);\n } else if (prevCourse == -1) {\n prevCourse = (int) pos.course;\n } else if (secondPrevCourse == -1) {\n if (Math.abs(prevCourse - (int)pos.course) < 30 || Math.abs(prevCourse - (int)pos.course) > 330) {\n secondPrevCourse = prevCourse;\n }\n prevCourse = (int) pos.course;\n } else {\n if (Math.abs(prevCourse - (int)pos.course) < 30 || Math.abs(prevCourse - (int)pos.course) > 330) {\n thirdPrevCourse = secondPrevCourse;\n updateCourse((int) pos.course);\n } else {\n prevCourse = (int) pos.course;\n secondPrevCourse = -1;\n }\n }\n } else {\n prevCourse = -1;\n secondPrevCourse = -1;\n thirdPrevCourse = -1;\n\t\t\t}\n\t\t}\n\t\tif (gpx.isRecordingTrk()) {\n\t\t\ttry {\n\t\t\t\tif ((Configuration.getLocationProvider() == Configuration.LOCATIONPROVIDER_JSR179\n\t\t\t\t && pos.type == Position.TYPE_CELLID) || pos.type == Position.TYPE_GPS_LASTKNOWN) {\n\t\t\t\t} else {\n\t\t\t\t\tgpx.addTrkPt(pos);\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\treceiveMessage(e.getMessage());\n\t\t\t}\n\t\t}\n\t\taltitude = (int) (pos.altitude);\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_AUTOZOOM)\n\t\t\t\t&& gpsRecenter\n\t\t\t\t&& (isGpsConnected() || TrackPlayer.isPlaying)\n\t\t\t\t&& autoZoomed\n\t\t\t\t&& pc.getP() != null\n\t\t\t\t&& pos.speed != Float.NaN \n\t\t) {\n\t\t\tfinal float minimumScale = Configuration.getRealBaseScale() / 1.5f;\n\t\t\tfinal int minimumSpeed = 20;\n\t\t\tfinal float maximumScale = Configuration.getRealBaseScale() * 1.5f;\n\t\t\tfinal int maximumSpeed = 160;\n\t\t\tint speedForScale = speed;\n\t\t\tfloat newScale = minimumScale + (maximumScale - minimumScale) * (speedForScale - minimumSpeed) / (maximumSpeed - minimumSpeed);\n\t\t\tif (newScale < minimumScale) {\n\t\t\t\tnewScale = minimumScale;\n\t\t\t} else if (newScale > maximumScale) {\n\t\t\t\tnewScale = maximumScale;\n\t\t\t}\n\t\t\tscale = newScale;\n\t\t}\n\t\tupdatePosition();\n\t}\n\tpublic synchronized Position getCurrentPosition() {\n\t\treturn this.pos;\n\t}\n\tpublic synchronized void receiveMessage(String s) {\n\t\tlogger.info(\"Setting title: \" + s);\n\t\tcurrentTitleMsg = s;\n\t\tsynchronized (this) {\n\t\t\tif (setTitleMsgTimeout == 0) {\n\t\t\t\tcurrentTitleMsgOpenCount++;\n\t\t\t}\n\t\t\tsetTitleMsgTimeout = 3000;\n\t\t}\n\t\tlastTitleMsgClock = DateTimeTools.getClock(System.currentTimeMillis(), false);\n\t\trepaint();\n\t}\n\tpublic void receiveSatellites(Satellite[] sats) {\n\t}\n\tpublic synchronized void alert(String title, String message, int timeout) {\n\t\tlogger.info(\"Showing trace alert: \" + title + \": \" + message);\n\t\tif (timeout == Alert.FOREVER) {\n\t\t\ttimeout = 10000;\n\t\t}\n\t\tcurrentAlertTitle = title;\n\t\tcurrentAlertMessage = message;\n\t\tsynchronized (this) {\n\t\t\tif (setAlertTimeout == 0) {\n\t\t\t\tcurrentAlertsOpenCount++;\n\t\t\t}\n\t\t\tsetAlertTimeout = timeout;\n\t\t}\n\t\trepaint();\n\t}\n\tpublic MIDlet getParent() {\n\t\treturn parent;\n\t}\n\tprotected void pointerPressed(int x, int y) {\n\t\tupdateLastUserActionTime();\n\t\tlong currTime = System.currentTimeMillis();\n\t\tpointerDragged = false;\n\t\tpointerDraggedMuch = false;\n\t\tpointerActionDone = false;\n\t\tcenterPointerPressedN = center.copy();\n\t\tif (imageCollector != null) {\n\t\t\tpanProjection=imageCollector.getCurrentProjection();\n\t\t\tpickPointStart=panProjection.inverse(x,y, pickPointStart);\n\t\t} else {\n\t\t\tpanProjection = null;\n\t\t}\n\t\tint touchedElementId = tl.getElementIdAtPointer(x, y);\n\t\tif (touchedElementId >= 0 && (!keyboardLocked || tl.getActionIdAtPointer(x, y) == Trace.ICON_MENU)\n\t\t\t\t&&\n\t\t\ttl.isAnyActionIdAtPointer(x, y)\n\t\t) {\n\t\t\ttl.setTouchedElement((LayoutElement) tl.elementAt(touchedElementId));\n\t\t\trepaint();\n\t\t}\n\t\tif (!keyboardLocked && currTime - pressedPointerTime < DOUBLETAP_MAXDELAY) {\n\t\t\tdoubleTap(x, y);\n\t\t\treturn;\n\t\t}\n\t\tpressedPointerTime = currTime;\n\t\tTrace.touchX = x;\n\t\tTrace.touchY = y;\n\t\tif (keyboardLocked) {\n\t\t\tkeyPressed(0);\n\t\t\treturn;\n\t\t}\t\t\n\t\tlongTapTimerTask = new TimerTask() {\n\t\t\tpublic void run() {\n\t\t\t\tif (!pointerActionDone) {\n\t\t\t\t\tif (System.currentTimeMillis() - pressedPointerTime >= LONGTAP_DELAY){\n\t\t\t\t\t\tlongTap();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\ttry {\n\t\t\tGpsMid.getTimer().schedule(longTapTimerTask, LONGTAP_DELAY);\n\t\t} catch (Exception e) {\n\t\t\tlogger.error(Locale.get(\"trace.NoLongTapTimerTask\") + e.toString());\n\t\t}\n\t}\n\tprotected void pointerReleased(int x, int y) {\t\n\t\tif (longTapTimerTask != null) {\n\t\t\tlongTapTimerTask.cancel();\n\t\t}\n\t\tif (tl.getTouchedElement() != null) {\n\t\t\ttl.clearTouchedElement();\n\t\t\trepaint();\n\t\t}\n\t\tif (!pointerActionDone && !keyboardLocked) {\n\t\t\ttouchReleaseX = x;\n\t\t\ttouchReleaseY = y;\n\t\t\tsingleTapTimerTask = new TimerTask() {\n\t\t\t\tpublic void run() {\n\t\t\t\t\tif (!keyboardLocked) {\n\t\t\t\t\t\tsingleTap(touchReleaseX, touchReleaseY);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tGpsMid.getTimer().schedule(singleTapTimerTask, DOUBLETAP_MAXDELAY);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlogger.error(Locale.get(\"trace.NoSingleTapTimerTask\") + e.toString());\n\t\t\t}\n\t\t\tif (pointerDragged) {\n\t\t\t\tpointerDragged(x , y);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tprotected void pointerDragged (int x, int y) {\n\t\tupdateLastUserActionTime();\n\t\tLayoutElement e = tl.getElementAtPointer(x, y);\n\t\tif (tl.getTouchedElement() != e) {\n\t\t\tif (longTapTimerTask != null) {\n\t\t\t\tlongTapTimerTask.cancel();\n\t\t\t}\t\t\t\n\t\t\ttl.clearTouchedElement();\n\t\t\trepaint();\n\t\t}\n\t\tif (tl.getElementAtPointer(touchX, touchY) == e && tl.isAnyActionIdAtPointer(x, y)) {\n\t\t\ttl.setTouchedElement(e);\n\t\t\trepaint();\n\t\t}\n\t\tif (pointerActionDone) {\n\t\t\treturn;\n\t\t}\t\t\n\t\tif (Math.abs(x - Trace.touchX) > 8\n\t\t\t\t|| \n\t\t\tMath.abs(y - Trace.touchY) > 8\n\t\t) {\n\t\t\tpointerDraggedMuch = true;\n\t\t\tpressedPointerTime = 0; \n\t\t}\n\t\tif (tl.getActionIdAtPointer(touchX, touchY) == Trace.ICON_MENU) {\n\t\t\tif ( tl.getActionIdAtPointer(x, y) == Trace.ICON_MENU\n\t\t\t\t\t&&\n\t\t\t\tx - touchX > getWidth() / 4\n\t\t\t) {\n\t\t\t\tcommandAction(TOGGLE_KEY_LOCK_CMD);\n\t\t\t\tpointerActionDone = true;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (keyboardLocked) {\n\t\t\treturn;\n\t\t}\n\t\tpointerDragged = true;\n\t\tif (!pointerDraggedMuch && tl.getElementIdAtPointer(touchX, touchY) >= 0) {\n\t\t\treturn;\n\t\t}\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0 && imageCollector != null && panProjection != null) {\n\t\t\tpickPointEnd=panProjection.inverse(x,y, pickPointEnd);\n\t\t\tcenter.radlat=centerPointerPressedN.radlat-(pickPointEnd.radlat-pickPointStart.radlat);\n\t\t\tcenter.radlon=centerPointerPressedN.radlon-(pickPointEnd.radlon-pickPointStart.radlon);\n\t\t\timageCollector.newDataReady();\n\t\t\tgpsRecenter = false;\n\t\t}\n\t}\n\tprivate void singleTap(int x, int y) {\n\t\tpointerActionDone = true;\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0) {\t\t\t\t\t\t\t\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_SINGLE)) {\n\t\t\t\tif (pointerDraggedMuch) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.debug(\"single tap map\");\n\t\t\t\tif (!tl.bigOnScreenButtons) {\n\t\t\t\t\ttl.setOnScreenButtonSize(true);\n\t\t\t\t\tfinal long BIGBUTTON_DURATION = 5000;\n\t\t\t\t\tbigButtonTimerTask = new TimerTask() {\n\t\t\t\t\t\tpublic void run() {\n\t\t\t\t\t\t\tif (System.currentTimeMillis() - lastUserActionTime > BIGBUTTON_DURATION ) {\n\t\t\t\t\t\t\t\ttl.setOnScreenButtonSize(false);\n\t\t\t\t\t\t\t\trequestRedraw();\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tbigButtonTimerTask.cancel();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\ttry {\n\t\t\t\t\t\tGpsMid.getTimer().schedule(bigButtonTimerTask, BIGBUTTON_DURATION, 500);\n\t\t\t\t\t} catch (Exception e) {\n\t\t\t\t\t\tlogger.error(\"Error scheduling bigButtonTimerTask: \" + e.toString());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t} else if (tl.getElementIdAtPointer(x, y) == tl.getElementIdAtPointer(touchX, touchY)) {\n\t\t\ttl.clearTouchedElement();\n\t\t\tint actionId = tl.getActionIdAtPointer(x, y);\n\t\t\tif (actionId > 0) {\n\t\t\t\tlogger.debug(\"single tap button: \" + actionId + \" x: \" + touchX + \" y: \" + touchY);\n\t\t\t\tif (System.currentTimeMillis() < (lastBackLightOnTime + 2500)) {\n\t\t\t\t\tif (actionId == ZOOM_IN_CMD) {\n\t\t\t\t\t\tactionId = PAN_RIGHT2_CMD;\n\t\t\t\t\t} else if (actionId == ZOOM_OUT_CMD) {\n\t\t\t\t\t\tactionId = PAN_LEFT2_CMD;\n\t\t\t\t\t}\n\t\t\t\t} else if (manualRotationMode) {\n\t\t\t\t\tif (actionId == ZOOM_IN_CMD) {\n\t\t\t\t\t\tactionId = PAN_LEFT2_CMD;\n\t\t\t\t\t} else if (actionId == ZOOM_OUT_CMD) {\n\t\t\t\t\t\tactionId = PAN_RIGHT2_CMD;\n\t\t\t\t\t}\n\t\t\t\t} else if (TrackPlayer.isPlaying) {\n\t\t\t\t\tif (actionId == ZOOM_IN_CMD) {\n\t\t\t\t\t\tactionId = PAN_RIGHT2_CMD;\n\t\t\t\t\t} else if (actionId == ZOOM_OUT_CMD) {\n\t\t\t\t\t\tactionId = PAN_LEFT2_CMD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcommandAction(actionId);\n\t\t\t\trepaint();\n\t\t\t}\n\t\t}\n\t}\n\tprivate void doubleTap(int x, int y) {\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0) {\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_DOUBLE)) {\n\t\t\t\tif (singleTapTimerTask != null) {\n\t\t\t\t\tsingleTapTimerTask.cancel();\n\t\t\t\t}\n\t\t\t\tif (pointerDraggedMuch) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tlogger.debug(\"double tap map\");\n\t\t\t\tpointerActionDone = true;\n\t\t\t\tcommandAction(ZOOM_IN_CMD);\n\t\t\t}\n\t\t\trepaint();\n\t\t\treturn;\n\t\t} else if (tl.getTouchedElement() == tl.getElementAtPointer(x, y) ){\n\t\t\tint actionId = tl.getActionIdDoubleAtPointer(x, y);\n\t\t\tlogger.debug(\"double tap button: \" + actionId + \" x: \" + x + \" y: \" + x);\n\t\t\tif (actionId > 0) {\n\t\t\t\tif (singleTapTimerTask != null) {\n\t\t\t\t\tsingleTapTimerTask.cancel();\n\t\t\t\t}\n\t\t\t\tpointerActionDone = true;\n\t\t\t\tcommandAction(actionId);\n\t\t\t\ttl.clearTouchedElement();\n\t\t\t\trepaint();\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tsingleTap(x, y);\n\t\t\t}\n\t\t}\n\t}\n\tprivate void longTap() {\n\t\tif (tl.getElementIdAtPointer(touchX, touchY) < 0 && panProjection != null) {\t\t\t\t\t\t\t\n\t\t\tif (!pointerDraggedMuch && Configuration.getCfgBitState(Configuration.CFGBIT_MAPTAP_LONG)) {\n\t\t\t\tpointerActionDone = true;\n\t\t\t\tlogger.debug(\"long tap map\");\t\t\t\t\t\t\t\t\t\t\n\t\t\t\tpickPointEnd=panProjection.inverse(touchX,touchY, pickPointEnd);\n\t\t\t\tcenter.radlat=centerPointerPressedN.radlat-(pickPointEnd.radlat-pickPointStart.radlat);\n\t\t\t\tcenter.radlon=centerPointerPressedN.radlon-(pickPointEnd.radlon-pickPointStart.radlon);\n\t\t\t\tPosition oPos = new Position(center.radlat, center.radlon,\n\t\t\t\t\t\t\t 0.0f, 0.0f, 0.0f, 0, 0);\n\t\t\t\timageCollector.newDataReady();\n\t\t\t\tgpsRecenter = false;\n\t\t\t\tcommandAction(ONLINE_INFO_CMD);\n\t\t\t}\n\t\t\treturn;\n\t\t} else {\n\t\t\tint actionId = tl.getActionIdLongAtPointer(touchX, touchY);\n\t\t\tif (actionId > 0 && tl.getElementAtPointer(touchX, touchY) == tl.getTouchedElement()) {\n\t\t\t\tpointerActionDone = true;\n\t\t\t\tlogger.debug(\"long tap button: \" + actionId + \" x: \" + touchX + \" y: \" + touchY);\n\t\t\t\tcommandAction(actionId);\n\t\t\t\trepaint();\n\t\t\t}\n\t\t}\n\t\ttl.clearTouchedElement();\n\t}\n\tpublic Command getDataScreenCommand() {\n\t\treturn CMDS[DATASCREEN_CMD];\n\t}\n\tpublic Tile getDict(byte zl) {\n\t\treturn tiles[zl];\n\t}\n\tpublic void setDict(Tile dict, byte zl) {\n\t\ttiles[zl] = dict;\n\t\tif (zl == 0) {\n\t\t\tConfiguration.getStartupPos(center);\n\t\t\tif (center.radlat == 0.0f && center.radlon == 0.0f) {\n\t\t\t\tdict.getCenter(center);\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SAVED_DESTPOS_VALID)) {\n\t\t\t\tNode destNode = new Node();\n\t\t\t\tConfiguration.getDestPos(destNode);\n\t\t\t\tsetDestination(new RoutePositionMark(destNode.radlat, destNode.radlon));\n\t\t\t}\n\t\t\tif (pc != null) {\n\t\t\t\tpc.center = center.copy();\n\t\t\t\tpc.scale = scale;\n\t\t\t\tpc.course = course;\n\t\t\t}\n\t\t}\n\t\tupdatePosition();\n\t}\n\tpublic void receiveStatistics(int[] statRecord, byte quality) {\n\t\tthis.btquality = quality;\n\t\tthis.statRecord = statRecord;\n\t\trepaint();\n\t}\n\tpublic synchronized void locationDecoderEnd() {\n\t\tlogger.info(\"enter locationDecoderEnd\");\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_SND_DISCONNECT)) {\n\t\t\tif (Legend.isValid) {\n\t\t\t\tGpsMid.mNoiseMaker.playSound(\"DISCONNECT\");\n\t\t\t}\n\t\t}\n\t\tremoveCommand(CMDS[DISCONNECT_GPS_CMD]);\n\t\tif (locationProducer == null) {\n\t\t\tlogger.info(\"leave locationDecoderEnd no producer\");\n\t\t\treturn;\n\t\t}\n\t\tlocationProducer = null;\n\t\tnotify();\n\t\taddCommand(CMDS[CONNECT_GPS_CMD]);\n\t\tlogger.info(\"end locationDecoderEnd\");\n\t}\n\tpublic void receiveStatus(byte status, int satsReceived) {\n\t\tsolution = status;\n\t\tsolutionStr = LocationMsgReceiverList.getCurrentStatusString(status, satsReceived);\n\t\trepaint();\n\t}\n\tpublic String getName(int idx) {\n\t\tif (idx < 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn namesThread.getName(idx);\n\t}\n\tpublic String getUrl(int idx) {\n\t\tif (idx < 0) {\n\t\t\treturn null;\n\t\t}\n\t\treturn urlsThread.getUrl(idx);\n\t}\n\tpublic Vector fulltextSearch (String snippet, CancelMonitorInterface cmi) {\n\t\treturn namesThread.fulltextSearch(snippet, cmi);\n\t}\n\tpublic void requestRedraw() {\n\t\trepaint();\n\t}\n\tpublic void newDataReady() {\n\t\tif (imageCollector != null) {\n\t\t\timageCollector.newDataReady();\n\t\t}\n\t}\n\tpublic void show() {\n\t\tLegend.freeDrawnWayAndAreaSearchImages();\n\t\tGpsMid.getInstance().show(this);\n\t\tsetFullScreenMode(Configuration.getCfgBitState(Configuration.CFGBIT_FULLSCREEN));\n\t\tupdateLastUserActionTime();\n\t\trepaint();\n\t}\n\tpublic void recreateTraceLayout() {\n\t\ttl = new TraceLayout(0, 0, getWidth(), getHeight());\n\t}\n\tpublic void resetSize() {\n\t\tsizeChanged(getWidth(), getHeight());\n\t}\n\tpublic void locationDecoderEnd(String msg) {\n\t\treceiveMessage(msg);\n\t\tlocationDecoderEnd();\n\t}\n\tpublic PositionMark getDestination() {\n\t\treturn dest;\n\t}\n\tpublic void setDestination(RoutePositionMark dest) {\n\t\tendRouting();\n\t\tthis.dest = dest;\n\t\tpc.dest = dest;\n\t\tif (dest != null) {\n\t\t\tlogger.info(\"Setting destination to \" + dest.toString());\n\t\t\tif (! Configuration.getCfgBitState(Configuration.CFGBIT_ICONMENUS_ROUTING_OPTIMIZED)) {\n\t\t\t\tcommandAction(SHOW_DEST_CMD);\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_AUTOSAVE_DESTPOS)) {\n\t\t\t\tConfiguration.setDestPos(new Node(dest.lat, dest.lon, true));\n\t\t\t\tConfiguration.setCfgBitSavedState(Configuration.CFGBIT_SAVED_DESTPOS_VALID, true);\n\t\t\t}\n\t\t\tmovedAwayFromDest = false;\n\t\t} else {\n\t\t\tConfiguration.setCfgBitSavedState(Configuration.CFGBIT_SAVED_DESTPOS_VALID, false);\n\t\t\tlogger.info(\"Setting destination to null\");\n\t\t}\n\t}\n\tpublic void endRouting() {\n\t\tRouteInstructions.initialRecalcDone = false;\n\t\tRouteInstructions.icCountOffRouteDetected = 0;\n\t\tRouteInstructions.routeInstructionsHeight = 0;\n\t\tRouteInstructions.abortRouteLineProduction();\n\t\tsetRoute(null);\n\t\tsetRouteNodes(null);\n\t}\n\tpublic void setRoute(Vector route) {\n\t\tsynchronized(this) {\n\t\t\tthis.route = route;\n\t\t}\n\t\tif (this.route != null) {\n\t\t\tRouteInstructions.resetOffRoute(this.route, center);\n\t\t\tif (ri == null) {\n\t\t\t\tri = new RouteInstructions(this);\n\t\t\t}\n\t\t\tif (Configuration.getContinueMapWhileRouteing() == Configuration.continueMap_At_Route_Line_Creation) {\n\t\t\t\tresumeImageCollectorAfterRouteCalc();\n\t\t\t}\n\t\t\tri.newRoute(this.route);\n\t\t\toldRecalculationTime = System.currentTimeMillis();\n\t\t}\n\t\tresumeImageCollectorAfterRouteCalc();\n\t\trouteCalc=false;\n\t\trouteEngine=null;\n\t}\n\tprivate void resumeImageCollectorAfterRouteCalc() {\n\t\ttry {\n\t\t\tif (imageCollector == null) {\n\t\t\t\tstartImageCollector();\n\t\t\t\timageCollector.resume();\n\t\t\t} else if (imageCollector != null) {\n\t\t\t\timageCollector.newDataReady();\n\t\t\t}\n\t\t\trepaint();\n\t\t} catch (Exception e) {\n\t\t\tlogger.exception(Locale.get(\"trace.InTraceResumeImageCollector\"), e);\n\t\t}\n\t}\n\tpublic void dropCache() {\n\t\ttileReader.dropCache();\n\t\tdictReader.dropCache();\n\t\tSystem.gc();\n\t\tnamesThread.dropCache();\n\t\turlsThread.dropCache(); \n\t\tSystem.gc();\n\t\tif (gpx != null) {\n\t\t\tgpx.dropCache();\n\t\t}\n\t}\n\tpublic QueueDataReader getDataReader() {\n\t\treturn tileReader;\n\t}\n\tpublic QueueDictReader getDictReader() {\n\t\treturn dictReader;\n\t}\n\tpublic Vector getRouteNodes() {\n\t\treturn routeNodes;\n\t}\n\tpublic void setRouteNodes(Vector routeNodes) {\n\t\tthis.routeNodes = routeNodes;\n\t}\n\tprotected void hideNotify() {\n\t\tlogger.debug(\"Hide notify has been called, screen will no longer be updated\");\n\t\tif (imageCollector != null) {\n\t\t\timageCollector.suspend();\n\t\t}\n\t}\n\tprotected void showNotify() {\n\t\tlogger.debug(\"Show notify has been called, screen will be updated again\");\n\t\tif (imageCollector != null) {\n\t\t\timageCollector.resume();\n\t\t\timageCollector.newDataReady();\n\t\t}\n\t}\n\tpublic Vector getRoute() {\n\t\treturn route;\n\t}\n\tpublic void actionCompleted() {\n\t\tboolean reAddCommands = true;\n\t\tif (reAddCommands && Configuration.getCfgBitState(Configuration.CFGBIT_FULLSCREEN)) {\n\t\t\taddAllCommands();\n\t\t}\n\t}\n\tpublic void showIconMenu() {\n\t\tif (traceIconMenu == null) {\n\t\t\ttraceIconMenu = new TraceIconMenu(this, this);\n\t\t}\n\t\ttraceIconMenu.show();\n\t}\n\tpublic static void uncacheIconMenu() {\n\t\tif (traceIconMenu != null) {\n\t\t\tlogger.trace(\"uncaching TraceIconMenu\");\n\t\t}\n\t\ttraceIconMenu = null;\n\t}\n\tpublic void recreateAndShowIconMenu() {\n\t\tuncacheIconMenu();\n\t\tshowIconMenu();\n\t}\n\tpublic void performIconAction(int actionId) {\n\t\tupdateLastUserActionTime();\n\t\tif (routeCalc || GpsMid.getInstance().needsFreeingMemory()) {\n\t\t\tlogger.info(\"low mem: Uncaching traceIconMenu\");\n\t\t\tuncacheIconMenu();\n\t\t}\n\t\tif (actionId != IconActionPerformer.BACK_ACTIONID) {\n\t\t\tcommandAction(actionId);\n\t\t}\n\t}\n\tpublic static String showDistance(int meters) {\n\t\treturn showDistance(meters, DISTANCE_GENERIC);\n\t}\n\tpublic static String showDistance(int meters, int type) {\n\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_METRIC)) {\n\t\t\tif (type == DISTANCE_UNKNOWN) {\n\t\t\t\treturn \"???m\";\n\t\t\t}\n\t\t\tif (Configuration.getCfgBitState(Configuration.CFGBIT_DISTANCE_VIEW) && (type != DISTANCE_ALTITUDE)) {\n\t\t\t\tif (meters >= 10000) {\n\t\t\t\t\treturn meters / 1000 + \"km\";\n\t\t\t\t} else if (meters < 1000) {\n\t\t\t\t\treturn meters + \"m\";\n\t\t\t\t} else {\n\t\t\t\t\treturn meters / 1000 + \".\" + (meters % 1000) / 100 + \"km\";\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn meters + \"m\";\n\t\t\t}\n\t\t} else {\n\t\t\tif (type == DISTANCE_UNKNOWN) {\n\t\t\t\treturn \"???yd\";\n\t\t\t} else if (type == DISTANCE_ALTITUDE) {\n\t\t\t\treturn Integer.toString((int)(meters / 0.30480 + 0.5)) + \"ft\";\n\t\t\t} else {\n\t\t\t\treturn Integer.toString((int)(meters / 0.9144 + 0.5)) + \"yd\";\n\t\t\t}\n\t\t}\n\t}\n}\n"} {"input": " public int read(byte[] b, int off, int len) throws IOException {\n int nSamples = len/frameSize;\n int totalRead = 0;\n int currentPos = off;\n do {\n int toRead = nSamples-totalRead;\n if (toRead > sampleBuf.length) toRead = sampleBuf.length;\n int nRead = source.getData(sampleBuf, 0, toRead);\n if (frameSize == 1) { \n for (int i=0; i>8)&0xFF);\n }\n } else if (frameSize == 2){ \n boolean bigEndian = format.isBigEndian();\n for (int i=0; i MAX_AMPLITUDE || sample < -MAX_AMPLITUDE) {\n System.err.println(\"Warning: signal amplitude out of range: \"+sample);\n }\n byte hibyte = (byte) (sample>>8);\n byte lobyte = (byte) (sample&0xFF);\n if (!bigEndian) {\n b[currentPos] = lobyte;\n b[currentPos+1] = hibyte;\n } else {\n b[currentPos] = hibyte;\n b[currentPos+1] = lobyte;\n }\n }\n } else { \n boolean bigEndian = format.isBigEndian();\n for (int i=0; i>16);\n byte midbyte = (byte) ((sample>>8) & 0xFF);\n byte lobyte = (byte) (sample&0xFF);\n if (!bigEndian) {\n b[currentPos] = lobyte;\n b[currentPos+1] = midbyte;\n b[currentPos+2] = hibyte;\n } else {\n b[currentPos] = hibyte;\n b[currentPos+1] = midbyte;\n b[currentPos+2] = lobyte;\n }\n }\n }\n totalRead += nRead;\n assert currentPos <= off+len;\n } while (source.hasMoreData() && totalRead < nSamples);\n if (totalRead == 0) return -1;\n else return totalRead*frameSize;\n }\n", "output": " public int read(byte[] b, int off, int len) throws IOException {\n int nSamples = len/frameSize;\n int totalRead = 0;\n int currentPos = off;\n do {\n int toRead = nSamples-totalRead;\n if (toRead > sampleBuf.length) toRead = sampleBuf.length;\n int nRead = source.getData(sampleBuf, 0, toRead);\n if (frameSize == 1) { \n for (int i=0; i>8)&0xFF);\n }\n } else if (frameSize == 2){ \n boolean bigEndian = format.isBigEndian();\n for (int i=0; i MAX_AMPLITUDE || sample < -MAX_AMPLITUDE) {\n System.err.println(\"Warning: signal amplitude out of range: \"+sample);\n }\n byte hibyte = (byte) (sample>>8);\n byte lobyte = (byte) (sample&0xFF);\n if (!bigEndian) {\n b[currentPos] = lobyte;\n b[currentPos+1] = hibyte;\n } else {\n b[currentPos] = hibyte;\n b[currentPos+1] = lobyte;\n }\n }\n } else { \n boolean bigEndian = format.isBigEndian();\n for (int i=0; i>16);\n byte midbyte = (byte) ((sample>>8) & 0xFF);\n byte lobyte = (byte) (sample&0xFF);\n if (!bigEndian) {\n b[currentPos] = lobyte;\n b[currentPos+1] = midbyte;\n b[currentPos+2] = hibyte;\n } else {\n b[currentPos] = hibyte;\n b[currentPos+1] = midbyte;\n b[currentPos+2] = lobyte;\n }\n }\n }\n totalRead += nRead;\n assert currentPos <= off+len;\n } while (source.hasMoreData() && totalRead < nSamples);\n if (totalRead == 0) return -1;\n else return totalRead*frameSize;\n }\n"} {"input": "\tpublic void StartClient(int SERVERpassedPort, String SERVERpassedTarget, int DROPOFFpassedPort,\n\t\t\tString DROPOFFpassedTarget) {\n\t\tServerNetwork = new Networking(mylog, SERVERpassedPort, SERVERpassedTarget);\n\t\tSocket ServerSock = ServerNetwork.PassBackClient();\n\t\tServerNetwork.BringUp(ServerSock);\n\t\tDropOffNetwork = new Networking(mylog, SERVERpassedPort, SERVERpassedTarget);\n\t\tSocket DropOffSock = DropOffNetwork.PassBackClient();\n\t\tDropOffNetwork.BringUp(DropOffSock);\n\t\tString UserInput = null;\n\t\tString ServerResponse = null;\n\t\tString OS = (String) clientSession.getAttribute(\"OS\");\n\t\tString SecLev = (String) clientSession.getAttribute(\"SecurityLevel\");\n\t\tString ClientID = (String) clientSession.getAttribute(\"ID\");\n\t\tDisplayMenu();\n\t\tSystem.out.println(\"Connected to server [\" + SERVERpassedTarget + \"] on port [\" + SERVERpassedPort + \"]\");\n\t\tcrypt = new Crypto(mylog, subject.GetPSK());\n\t\tString rawTest = \"Testing!!!12345\";\n\t\tbyte[] testdata = crypt.encrypt(rawTest); \n\t\tServerNetwork.Send(testdata); \n\t\tbyte[] fetched = ServerNetwork.ReceiveByte(); \n\t\tString dec = crypt.decrypt(fetched); \n\t\tif (dec.equals(rawTest + \"\")) {\n\t\t\tmylog.out(\"INFO\", \"Functional bi-directional encryption established. (Server)\");\n\t\t} else {\n\t\t\tmylog.out(\"ERROR\", \"Failed to establish a functional encrypted channel! (Server)\");\n\t\t\tmylog.out(\"ERROR\", \"Expected [\" + rawTest + \"\" + \"] but recieved [\" + dec + \"] (Server)\");\n\t\t\tServerNetwork.BringDown();\n\t\t\ttry {\n\t\t\t\tServerSock.close();\n\t\t\t} catch (IOException e) {\n\t\t\t\tmylog.out(\"ERROR\", \"Failed to close client socket (Server)\");\n\t\t\t}\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tDropOffNetwork.Send(testdata); \n\t\tfetched = DropOffNetwork.ReceiveByte(); \n\t\tdec = crypt.decrypt(fetched); \n\t\tif (dec.equals(rawTest + \"\")) {\n\t\t\tmylog.out(\"INFO\", \"Functional bi-directional encryption established. (Drop Off)\");\n\t\t} else {\n\t\t\tmylog.out(\"ERROR\", \"Failed to establish a functional encrypted channel! (Drop Off)\");\n\t\t\tmylog.out(\"ERROR\", \"Expected [\" + rawTest + \"\" + \"] but recieved [\" + dec + \"] (Drop Off)\");\n\t\t\tDropOffNetwork.BringDown();\n\t\t\ttry {\n\t\t\t\tServerSock.close();\n\t\t\t} catch (IOException e) {\n\t\t\t\tmylog.out(\"ERROR\", \"Failed to close client socket (Drop Off)\");\n\t\t\t}\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tDHrekey(ServerNetwork);\n\t\tDHrekey(DropOffNetwork);\n\t\tUserInput = readUI();\n\t\tint MaxBeforeREKEY = 100;\n\t\tint Current = 0;\n\t\tboolean serverUp = true;\n\t\tboolean flagJob = false;\n\t\tboolean noSend = false;\n\t\twhile ((UserInput != null) && (UserInput.compareToIgnoreCase(\"quit\") != 0) && (ServerSock.isConnected())\n\t\t\t\t&& (DropOffSock.isConnected())) {\n\t\t\tif (!noSend) {\n\t\t\t\tServerNetwork.Send(crypt.encrypt(UserInput));\n\t\t\t\tfetched = ServerNetwork.ReceiveByte();\n\t\t\t\tServerResponse = crypt.decrypt(fetched);\n\t\t\t\tif (ServerResponse == null) {\n\t\t\t\t\tmylog.out(\"WARN\", \"Server disconected\");\n\t\t\t\t\tserverUp = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnoSend = false;\n\t\t\t}\n\t\t\tif (flagJob) {\n\t\t\t\tif (ServerResponse.length() > 0) {\n\t\t\t\t\tSystem.out.println(\"JobIn:[\" + ServerResponse + \"]\");\n\t\t\t\t\tif (OS.contains(\"Windows\")) {\n\t\t\t\t\t\tServerResponse = \"cmd /C \" + ServerResponse;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tRuntime rt = Runtime.getRuntime();\n\t\t\t\t\t\tProcess proc = rt.exec(ServerResponse);\n\t\t\t\t\t\tStreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), \"ERROR\");\n\t\t\t\t\t\tStreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), \"OUTPUT\");\n\t\t\t\t\t\terrorGobbler.start();\n\t\t\t\t\t\toutputGobbler.start();\n\t\t\t\t\t\tint exitVal = 0;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\texitVal = proc.waitFor();\n\t\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSystem.out.println(\"ExitValue: \" + exitVal);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t\tSystem.out.println(\"JobOut:[\" + ServerResponse + \"]\");\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(\"Job:[No jobs available]\");\n\t\t\t\t}\n\t\t\t\tflagJob = false;\n\t\t\t} else {\n\t\t\t\tSystem.out.println(ServerResponse);\n\t\t\t}\n\t\t\tUserInput = readUI().toLowerCase();\n\t\t\tif ((UserInput.contains(\"rekey\")) && serverUp) {\n\t\t\t\tUserInput = \"Rekey executed.\";\n\t\t\t\tDHrekey(ServerNetwork);\n\t\t\t\tDHrekey(DropOffNetwork);\n\t\t\t\tCurrent = 0;\n\t\t\t} else if (UserInput.contains(\"job\")) {\n\t\t\t\tflagJob = true; \n\t\t\t\tUserInput = UserInput + \":\" + ClientID + \":\" + OS + \":\" + SecLev;\n\t\t\t} else if (UserInput.contains(\"help\")) {\n\t\t\t\tnoSend = true; \n\t\t\t\tDisplayMenu();\n\t\t\t}\n\t\t\tif (Current == MaxBeforeREKEY) {\n\t\t\t\tDHrekey(ServerNetwork);\n\t\t\t\tDHrekey(DropOffNetwork);\n\t\t\t\tCurrent = 0;\n\t\t\t} else {\n\t\t\t\tCurrent++;\n\t\t\t}\n\t\t}\n\t\tif ((UserInput.compareToIgnoreCase(\"quit\") == 0) && serverUp) {\n\t\t\tServerNetwork.Send(crypt.encrypt(\"quit\"));\n\t\t\tDropOffNetwork.Send(crypt.encrypt(\"quit\"));\n\t\t}\n\t\tServerNetwork.BringDown();\n\t\tDropOffNetwork.BringDown();\n\t\ttry {\n\t\t\tServerSock.close();\n\t\t\tDropOffSock.close();\n\t\t} catch (IOException e) {\n\t\t\tmylog.out(\"ERROR\", \"Failed to close client socket\");\n\t\t}\n\t}\n", "output": "\tpublic void StartClient(int SERVERpassedPort, String SERVERpassedTarget, int DROPOFFpassedPort,\n\t\t\tString DROPOFFpassedTarget) {\n\t\tServerNetwork = new Networking(mylog, SERVERpassedPort, SERVERpassedTarget);\n\t\tSocket ServerSock = ServerNetwork.PassBackClient();\n\t\tServerNetwork.BringUp(ServerSock);\n\t\tSystem.out.println(\"Connected to Server [\" + SERVERpassedTarget + \"] on port [\" + SERVERpassedPort + \"]\");\n\t\tDropOffNetwork = new Networking(mylog, DROPOFFpassedPort, DROPOFFpassedTarget);\n\t\tSocket DropOffSock = DropOffNetwork.PassBackClient();\n\t\tDropOffNetwork.BringUp(DropOffSock);\n\t\tSystem.out.println(\"Connected to Drop Off [\" + DROPOFFpassedTarget + \"] on port [\" + DROPOFFpassedPort + \"]\");\n\t\tString UserInput = null;\n\t\tString ServerResponse = null;\n\t\tString OS = (String) clientSession.getAttribute(\"OS\");\n\t\tString SecLev = (String) clientSession.getAttribute(\"SecurityLevel\");\n\t\tString ClientID = (String) clientSession.getAttribute(\"ID\");\n\t\tDisplayMenu();\t\t\n\t\tcrypt = new Crypto(mylog, subject.GetPSK());\n\t\tString rawTest = \"Testing!!!12345\";\n\t\tbyte[] testdata = crypt.encrypt(rawTest); \n\t\tServerNetwork.Send(testdata); \n\t\tbyte[] fetched = ServerNetwork.ReceiveByte(); \n\t\tString dec = crypt.decrypt(fetched); \n\t\tif (dec.equals(rawTest + \"\")) {\n\t\t\tmylog.out(\"INFO\", \"Functional bi-directional encryption established. (Server)\");\n\t\t} else {\n\t\t\tmylog.out(\"ERROR\", \"Failed to establish a functional encrypted channel! (Server)\");\n\t\t\tmylog.out(\"ERROR\", \"Expected [\" + rawTest + \"\" + \"] but recieved [\" + dec + \"] (Server)\");\n\t\t\tServerNetwork.BringDown();\n\t\t\ttry {\n\t\t\t\tServerSock.close();\n\t\t\t} catch (IOException e) {\n\t\t\t\tmylog.out(\"ERROR\", \"Failed to close client socket (Server)\");\n\t\t\t}\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tDropOffNetwork.Send(testdata); \n\t\tfetched = DropOffNetwork.ReceiveByte(); \n\t\tdec = crypt.decrypt(fetched); \n\t\tif (dec.equals(rawTest + \"\")) {\n\t\t\tmylog.out(\"INFO\", \"Functional bi-directional encryption established. (Drop Off)\");\n\t\t} else {\n\t\t\tmylog.out(\"ERROR\", \"Failed to establish a functional encrypted channel! (Drop Off)\");\n\t\t\tmylog.out(\"ERROR\", \"Expected [\" + rawTest + \"\" + \"] but recieved [\" + dec + \"] (Drop Off)\");\n\t\t\tDropOffNetwork.BringDown();\n\t\t\ttry {\n\t\t\t\tServerSock.close();\n\t\t\t} catch (IOException e) {\n\t\t\t\tmylog.out(\"ERROR\", \"Failed to close client socket (Drop Off)\");\n\t\t\t}\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tDHrekey(ServerNetwork);\n\t\tDHrekey(DropOffNetwork);\n\t\tUserInput = readUI();\n\t\tint MaxBeforeREKEY = 100;\n\t\tint Current = 0;\n\t\tboolean serverUp = true;\n\t\tboolean flagJob = false;\n\t\tboolean noSend = false;\n\t\twhile ((UserInput != null) && (UserInput.compareToIgnoreCase(\"quit\") != 0) && (ServerSock.isConnected())\n\t\t\t\t&& (DropOffSock.isConnected())) {\n\t\t\tif (!noSend) {\n\t\t\t\tServerNetwork.Send(crypt.encrypt(UserInput));\n\t\t\t\tfetched = ServerNetwork.ReceiveByte();\n\t\t\t\tServerResponse = crypt.decrypt(fetched);\n\t\t\t\tif (ServerResponse == null) {\n\t\t\t\t\tmylog.out(\"WARN\", \"Server disconected\");\n\t\t\t\t\tserverUp = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnoSend = false;\n\t\t\t}\n\t\t\tif (flagJob) {\n\t\t\t\tif (ServerResponse.length() > 0) {\n\t\t\t\t\tSystem.out.println(\"JobIn:[\" + ServerResponse + \"]\");\n\t\t\t\t\tif (OS.contains(\"Windows\")) {\n\t\t\t\t\t\tServerResponse = \"cmd /C \" + ServerResponse;\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tRuntime rt = Runtime.getRuntime();\n\t\t\t\t\t\tProcess proc = rt.exec(ServerResponse);\n\t\t\t\t\t\tStreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), \"ERROR\");\n\t\t\t\t\t\tStreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), \"OUTPUT\");\n\t\t\t\t\t\terrorGobbler.start();\n\t\t\t\t\t\toutputGobbler.start();\n\t\t\t\t\t\tint exitVal = 0;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\texitVal = proc.waitFor();\n\t\t\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tSystem.out.println(\"ExitValue: \" + exitVal);\n\t\t\t\t\t} catch (IOException e) {\n\t\t\t\t\t\te.printStackTrace();\n\t\t\t\t\t}\n\t\t\t\t\tSystem.out.println(\"JobOut:[\" + ServerResponse + \"]\");\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(\"Job:[No jobs available]\");\n\t\t\t\t}\n\t\t\t\tflagJob = false;\n\t\t\t} else {\n\t\t\t\tSystem.out.println(ServerResponse);\n\t\t\t}\n\t\t\tUserInput = readUI().toLowerCase();\n\t\t\tif ((UserInput.contains(\"rekey\")) && serverUp) {\n\t\t\t\tUserInput = \"Rekey executed.\";\n\t\t\t\tDHrekey(ServerNetwork);\n\t\t\t\tDHrekey(DropOffNetwork);\n\t\t\t\tCurrent = 0;\n\t\t\t} else if (UserInput.contains(\"job\")) {\n\t\t\t\tflagJob = true; \n\t\t\t\tUserInput = UserInput + \":\" + ClientID + \":\" + OS + \":\" + SecLev;\n\t\t\t} else if (UserInput.contains(\"help\")) {\n\t\t\t\tnoSend = true; \n\t\t\t\tDisplayMenu();\n\t\t\t}\n\t\t\tif (Current == MaxBeforeREKEY) {\n\t\t\t\tDHrekey(ServerNetwork);\n\t\t\t\tDHrekey(DropOffNetwork);\n\t\t\t\tCurrent = 0;\n\t\t\t} else {\n\t\t\t\tCurrent++;\n\t\t\t}\n\t\t}\n\t\tif ((UserInput.compareToIgnoreCase(\"quit\") == 0) && serverUp) {\n\t\t\tServerNetwork.Send(crypt.encrypt(\"quit\"));\n\t\t\tDropOffNetwork.Send(crypt.encrypt(\"quit\"));\n\t\t}\n\t\tServerNetwork.BringDown();\n\t\tDropOffNetwork.BringDown();\n\t\ttry {\n\t\t\tServerSock.close();\n\t\t\tDropOffSock.close();\n\t\t} catch (IOException e) {\n\t\t\tmylog.out(\"ERROR\", \"Failed to close client socket\");\n\t\t}\n\t}\n"} {"input": " public void readConfig(Configuration aStorageConfig, File aRepoConfigFile) throws RepositoryException {\n Boolean createPrefix;\n Configuration repositoryConfig;\n Configuration credentialsConfig;\n Database database;\n File databaseHomeDir;\n Service collectionService;\n String driverName;\n String databaseHome;\n String rootCollection;\n String pathPrefix;\n String databaseAddress;\n String databaseName;\n String databaseURIPrefix;\n if (aStorageConfig == null || aRepoConfigFile == null)\n throw new RepositoryException(\"No storage/repository configuration available.\");\n try {\n driverName = aStorageConfig.getChild(\"driver\").getValue(\"\");\n mLog.error(\"Specified driver name = \\\"\" + driverName + \"\\\".\");\n databaseHome = aStorageConfig.getChild(\"db-home\").getValue(null);\n mLog.error(\"Specified database home = \\\"\" + databaseHome + \"\\\".\");\n rootCollection = aStorageConfig.getChild(\"root\").getValue(\"\");\n mLog.error(\"Specified root collection = \\\"\" + rootCollection + \"\\\".\");\n pathPrefix = aStorageConfig.getChild(\"prefix\").getValue(\"\");\n createPrefix = aStorageConfig.getChild(\"prefix\").getAttributeAsBoolean(\"createIfNotExists\", false);\n mLog.error(\"Specified collection prefix = \\\"\" + pathPrefix + \"\\\" (create if not exists: \\\"\" + createPrefix + \"\\\").\");\n databaseAddress = aStorageConfig.getChild(\"address\").getValue(\"\");\n mLog.error(\"Specified database address = \\\"\" + databaseAddress + \"\\\".\");\n credentialsConfig = aStorageConfig.getChild(\"credentials\", false);\n if (credentialsConfig != null) {\n mCredentials = new Credentials(credentialsConfig.getChild(\"username\").getValue(\"\"),\n credentialsConfig.getChild(\"password\").getValue(\"\"));\n mLog.error(\"Specified credentials read.\");\n }\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(exception.getMessage(), exception);\n }\n if (driverName.equals(\"\"))\n throw new RepositoryException(\"Database driver not specified.\");\n if (rootCollection.equals(\"\"))\n throw new RepositoryException(\"Database root collection not specified.\");\n try {\n database = (Database) Class.forName(driverName).newInstance();\n if (databaseHome != null) {\n databaseHomeDir = new File(databaseHome);\n if (!databaseHomeDir.isAbsolute()) {\n databaseHomeDir = FileUtil.file(aRepoConfigFile.getParent(), databaseHomeDir.toString());\n }\n mLog.error(\"Resolved database home directory = \\\"\" + databaseHomeDir + \"\\\"\");\n database.setProperty(\"db-home\", databaseHomeDir.toString());\n }\n DatabaseManager.registerDatabase(database);\n databaseName = database.getName();\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(exception.getMessage(), exception);\n }\n databaseURIPrefix = \"xmldb:\" + databaseName + \"://\" + databaseAddress + \"/\" + rootCollection + \"/\";\n if (pathPrefix.equals(\"\")) {\n mDatabaseURIPrefix = databaseURIPrefix;\n } else {\n mDatabaseURIPrefix = databaseURIPrefix + \"/\" + pathPrefix + \"/\";\n }\n mLog.error(\"Collection base path = \\\"\" + databaseURIPrefix + \"\\\".\");\n mLog.error(\"Complete collection base path = \\\"\" + mDatabaseURIPrefix + \"\\\".\");\n try {\n database.acceptsURI(mDatabaseURIPrefix);\n } catch (XMLDBException exception) {\n mLog.error(exception);\n if (exception.errorCode == org.xmldb.api.base.ErrorCodes.INVALID_URI) {\n throw new RepositoryException(\"The database does not accept the URI prefix \\\"\" + mDatabaseURIPrefix + \"\\\" as valid. Please make sure that the database host address (\\\"\" + databaseAddress + \"\\\") is correct. Original message: \" + exception.getMessage(), exception);\n } else {\n throw new RepositoryException(exception.getMessage(), exception);\n }\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(exception.getMessage(), exception);\n }\n try {\n if (getCollection(databaseURIPrefix) == null)\n throw new RepositoryException(\"Specified root collection (\\\"\" + rootCollection + \"\\\") does not exist.\");\n if (getCollectionRelative(null) == null) {\n if (createPrefix) {\n try {\n collectionService = getCollection(databaseURIPrefix).getService(\"CollectionManagementService\", \"1.0\");\n ((CollectionManagementService) collectionService).createCollection(pathPrefix);\n if (getCollectionRelative(null) == null)\n throw new RepositoryException(\"Specified collection prefix (\\\"\" + pathPrefix + \"\\\") does not exist.\");\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(\"Failed to create prefix collection (\\\"\" + pathPrefix + \"\\\"). Original message: \" + exception.getMessage(), exception);\n }\n mLog.error(\"Created new collection \\\"\" + pathPrefix + \"\\\".\");\n } else {\n throw new RepositoryException(\"Specified collection prefix (\\\"\" + pathPrefix + \"\\\") does not exist.\");\n }\n }\n } catch (Exception exception) {\n try {\n DatabaseManager.deregisterDatabase(database);\n } catch (Exception databaseException) {\n mLog.error(databaseException);\n throw new RepositoryException(databaseException.getMessage(), databaseException);\n }\n throw new RepositoryException(exception.getMessage(), exception);\n }\n }\n", "output": " public void readConfig(Configuration aStorageConfig, File aRepoConfigFile) throws RepositoryException {\n boolean createPrefix;\n Configuration repositoryConfig;\n Configuration credentialsConfig;\n Database database;\n File databaseHomeDir;\n Service collectionService;\n String driverName;\n String databaseHome;\n String rootCollection;\n String pathPrefix;\n String databaseAddress;\n String databaseName;\n String databaseURIPrefix;\n if (aStorageConfig == null || aRepoConfigFile == null)\n throw new RepositoryException(\"No storage/repository configuration available.\");\n try {\n driverName = aStorageConfig.getChild(\"driver\").getValue(\"\");\n mLog.error(\"Specified driver name = \\\"\" + driverName + \"\\\".\");\n databaseHome = aStorageConfig.getChild(\"db-home\").getValue(null);\n mLog.error(\"Specified database home = \\\"\" + databaseHome + \"\\\".\");\n rootCollection = aStorageConfig.getChild(\"root\").getValue(\"\");\n mLog.error(\"Specified root collection = \\\"\" + rootCollection + \"\\\".\");\n pathPrefix = aStorageConfig.getChild(\"prefix\").getValue(\"\");\n createPrefix = aStorageConfig.getChild(\"prefix\").getAttributeAsBoolean(\"createIfNotExists\", false);\n mLog.error(\"Specified collection prefix = \\\"\" + pathPrefix + \"\\\" (create if not exists: \\\"\" + createPrefix + \"\\\").\");\n databaseAddress = aStorageConfig.getChild(\"address\").getValue(\"\");\n mLog.error(\"Specified database address = \\\"\" + databaseAddress + \"\\\".\");\n credentialsConfig = aStorageConfig.getChild(\"credentials\", false);\n if (credentialsConfig != null) {\n mCredentials = new Credentials(credentialsConfig.getChild(\"username\").getValue(\"\"),\n credentialsConfig.getChild(\"password\").getValue(\"\"));\n mLog.error(\"Specified credentials read.\");\n }\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(exception.getMessage(), exception);\n }\n if (driverName.equals(\"\"))\n throw new RepositoryException(\"Database driver not specified.\");\n if (rootCollection.equals(\"\"))\n throw new RepositoryException(\"Database root collection not specified.\");\n try {\n database = (Database) Class.forName(driverName).newInstance();\n if (databaseHome != null) {\n databaseHomeDir = new File(databaseHome);\n if (!databaseHomeDir.isAbsolute()) {\n databaseHomeDir = FileUtil.file(aRepoConfigFile.getParent(), databaseHomeDir.toString());\n }\n mLog.error(\"Resolved database home directory = \\\"\" + databaseHomeDir + \"\\\"\");\n database.setProperty(\"db-home\", databaseHomeDir.toString());\n }\n DatabaseManager.registerDatabase(database);\n databaseName = database.getName();\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(exception.getMessage(), exception);\n }\n databaseURIPrefix = \"xmldb:\" + databaseName + \"://\" + databaseAddress + \"/\" + rootCollection + \"/\";\n if (pathPrefix.equals(\"\")) {\n mDatabaseURIPrefix = databaseURIPrefix;\n } else {\n mDatabaseURIPrefix = databaseURIPrefix + \"/\" + pathPrefix + \"/\";\n }\n mLog.error(\"Collection base path = \\\"\" + databaseURIPrefix + \"\\\".\");\n mLog.error(\"Complete collection base path = \\\"\" + mDatabaseURIPrefix + \"\\\".\");\n try {\n database.acceptsURI(mDatabaseURIPrefix);\n } catch (XMLDBException exception) {\n mLog.error(exception);\n if (exception.errorCode == org.xmldb.api.base.ErrorCodes.INVALID_URI) {\n throw new RepositoryException(\"The database does not accept the URI prefix \\\"\" + mDatabaseURIPrefix + \"\\\" as valid. Please make sure that the database host address (\\\"\" + databaseAddress + \"\\\") is correct. Original message: \" + exception.getMessage(), exception);\n } else {\n throw new RepositoryException(exception.getMessage(), exception);\n }\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(exception.getMessage(), exception);\n }\n try {\n if (getCollection(databaseURIPrefix) == null)\n throw new RepositoryException(\"Specified root collection (\\\"\" + rootCollection + \"\\\") does not exist.\");\n if (getCollectionRelative(null) == null) {\n if (createPrefix) {\n try {\n collectionService = getCollection(databaseURIPrefix).getService(\"CollectionManagementService\", \"1.0\");\n ((CollectionManagementService) collectionService).createCollection(pathPrefix);\n if (getCollectionRelative(null) == null)\n throw new RepositoryException(\"Specified collection prefix (\\\"\" + pathPrefix + \"\\\") does not exist.\");\n } catch (Exception exception) {\n mLog.error(exception);\n throw new RepositoryException(\"Failed to create prefix collection (\\\"\" + pathPrefix + \"\\\"). Original message: \" + exception.getMessage(), exception);\n }\n mLog.error(\"Created new collection \\\"\" + pathPrefix + \"\\\".\");\n } else {\n throw new RepositoryException(\"Specified collection prefix (\\\"\" + pathPrefix + \"\\\") does not exist.\");\n }\n }\n } catch (Exception exception) {\n try {\n DatabaseManager.deregisterDatabase(database);\n } catch (Exception databaseException) {\n mLog.error(databaseException);\n throw new RepositoryException(databaseException.getMessage(), databaseException);\n }\n throw new RepositoryException(exception.getMessage(), exception);\n }\n }\n"} {"input": " private void initComponents() {\n jSlider1 = new javax.swing.JSlider();\n jPanel1 = new javax.swing.JPanel();\n forwardB = new javax.swing.JButton();\n backwardB = new javax.swing.JButton();\n leftB = new javax.swing.JButton();\n rightB = new javax.swing.JButton();\n jLabel4 = new javax.swing.JLabel();\n locationTF = new javax.swing.JTextField();\n homeB = new javax.swing.JButton();\n jLabel1 = new javax.swing.JLabel();\n actionCB = new javax.swing.JComboBox();\n runActionB = new javax.swing.JButton();\n jLabel2 = new javax.swing.JLabel();\n expressionCB = new javax.swing.JComboBox();\n jLabel3 = new javax.swing.JLabel();\n renderQuality = new javax.swing.JComboBox();\n winkB = new javax.swing.JButton();\n eyeSelectionCB = new javax.swing.JComboBox();\n closeButton = new javax.swing.JButton();\n jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Movement\"));\n java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(\"org/jdesktop/wonderland/modules/avatarbase/client/resources/Bundle_en_US\"); \n forwardB.setText(bundle.getString(\"Forward\")); \n forwardB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n backwardB.setText(bundle.getString(\"Backward\")); \n backwardB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n leftB.setText(bundle.getString(\"Left\")); \n leftB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n rightB.setText(bundle.getString(\"Right\")); \n rightB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);\n jPanel1.setLayout(jPanel1Layout);\n jPanel1Layout.setHorizontalGroup(\n jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(jPanel1Layout.createSequentialGroup()\n .add(44, 44, 44)\n .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(jPanel1Layout.createSequentialGroup()\n .add(69, 69, 69)\n .add(forwardB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()\n .add(leftB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 83, Short.MAX_VALUE)\n .add(rightB))\n .add(jPanel1Layout.createSequentialGroup()\n .add(69, 69, 69)\n .add(backwardB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))\n .add(57, 57, 57))\n );\n jPanel1Layout.linkSize(new java.awt.Component[] {backwardB, forwardB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n jPanel1Layout.linkSize(new java.awt.Component[] {leftB, rightB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n jPanel1Layout.setVerticalGroup(\n jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(jPanel1Layout.createSequentialGroup()\n .add(forwardB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(rightB)\n .add(leftB))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(backwardB)\n .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n );\n jLabel4.setText(bundle.getString(\"Location:\")); \n locationTF.setEditable(false);\n homeB.setText(bundle.getString(\"Go_home\")); \n homeB.setToolTipText(bundle.getString(\"Go_to_0,0,0\")); \n homeB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n homeBActionPerformed(evt);\n }\n });\n jLabel1.setText(bundle.getString(\"Action:\")); \n actionCB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n actionCBActionPerformed(evt);\n }\n });\n runActionB.setText(bundle.getString(\"Run\")); \n runActionB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n runActionBActionPerformed(evt);\n }\n });\n jLabel2.setText(bundle.getString(\"Expression:\")); \n expressionCB.setEnabled(false);\n expressionCB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n expressionCBActionPerformed(evt);\n }\n });\n jLabel3.setText(bundle.getString(\"Render_Quality:\")); \n renderQuality.setModel(new javax.swing.DefaultComboBoxModel(new String[] { \"High\", \"Medium\", \"Low\" }));\n renderQuality.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n renderQualityActionPerformed(evt);\n }\n });\n winkB.setText(bundle.getString(\"Wink\")); \n winkB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n winkBActionPerformed(evt);\n }\n });\n eyeSelectionCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { \"Left Eye\", \"Right Eye\" }));\n closeButton.setText(bundle.getString(\"Close\")); \n closeButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n closeButtonActionPerformed(evt);\n }\n });\n org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);\n this.setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .addContainerGap()\n .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .addContainerGap(6, Short.MAX_VALUE))\n .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()\n .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .add(6, 6, 6)\n .add(closeButton))\n .add(layout.createSequentialGroup()\n .add(renderQuality, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(124, 124, 124))\n .add(layout.createSequentialGroup()\n .add(eyeSelectionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(winkB))\n .add(layout.createSequentialGroup()\n .add(expressionCB, 0, 144, Short.MAX_VALUE)\n .add(81, 81, 81))\n .add(layout.createSequentialGroup()\n .add(actionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(runActionB))\n .add(layout.createSequentialGroup()\n .add(homeB)\n .add(125, 125, 125))\n .add(locationTF, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))\n .addContainerGap())\n );\n layout.linkSize(new java.awt.Component[] {runActionB, winkB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n layout.linkSize(new java.awt.Component[] {actionCB, expressionCB, eyeSelectionCB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n layout.setVerticalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .addContainerGap()\n .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(locationTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(jLabel4))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(homeB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(jLabel1)\n .add(actionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(runActionB))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(jLabel2)\n .add(expressionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(eyeSelectionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(winkB))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(renderQuality, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(jLabel3))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(closeButton)\n .addContainerGap())\n );\n }\n", "output": " private void initComponents() {\n jSlider1 = new javax.swing.JSlider();\n jPanel1 = new javax.swing.JPanel();\n forwardB = new javax.swing.JButton();\n backwardB = new javax.swing.JButton();\n leftB = new javax.swing.JButton();\n rightB = new javax.swing.JButton();\n jLabel4 = new javax.swing.JLabel();\n locationTF = new javax.swing.JTextField();\n homeB = new javax.swing.JButton();\n jLabel1 = new javax.swing.JLabel();\n actionCB = new javax.swing.JComboBox();\n runActionB = new javax.swing.JButton();\n jLabel2 = new javax.swing.JLabel();\n expressionCB = new javax.swing.JComboBox();\n jLabel3 = new javax.swing.JLabel();\n renderQuality = new javax.swing.JComboBox();\n winkB = new javax.swing.JButton();\n eyeSelectionCB = new javax.swing.JComboBox();\n closeButton = new javax.swing.JButton();\n jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(\"Movement\"));\n java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(\"org/jdesktop/wonderland/modules/avatarbase/client/resources/Bundle\"); \n forwardB.setText(bundle.getString(\"Forward\")); \n forwardB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n backwardB.setText(bundle.getString(\"Backward\")); \n backwardB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n leftB.setText(bundle.getString(\"Left\")); \n leftB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n rightB.setText(bundle.getString(\"Right\")); \n rightB.addMouseListener(new java.awt.event.MouseAdapter() {\n public void mousePressed(java.awt.event.MouseEvent evt) {\n directionBMousePressed(evt);\n }\n public void mouseReleased(java.awt.event.MouseEvent evt) {\n directionBMouseReleased(evt);\n }\n });\n org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);\n jPanel1.setLayout(jPanel1Layout);\n jPanel1Layout.setHorizontalGroup(\n jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(jPanel1Layout.createSequentialGroup()\n .add(44, 44, 44)\n .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(jPanel1Layout.createSequentialGroup()\n .add(69, 69, 69)\n .add(forwardB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()\n .add(leftB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 83, Short.MAX_VALUE)\n .add(rightB))\n .add(jPanel1Layout.createSequentialGroup()\n .add(69, 69, 69)\n .add(backwardB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))\n .add(57, 57, 57))\n );\n jPanel1Layout.linkSize(new java.awt.Component[] {backwardB, forwardB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n jPanel1Layout.linkSize(new java.awt.Component[] {leftB, rightB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n jPanel1Layout.setVerticalGroup(\n jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(jPanel1Layout.createSequentialGroup()\n .add(forwardB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(rightB)\n .add(leftB))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(backwardB)\n .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))\n );\n jLabel4.setText(bundle.getString(\"Location:\")); \n locationTF.setEditable(false);\n homeB.setText(bundle.getString(\"Go_home\")); \n homeB.setToolTipText(bundle.getString(\"Go_to_0,0,0\")); \n homeB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n homeBActionPerformed(evt);\n }\n });\n jLabel1.setText(bundle.getString(\"Action:\")); \n actionCB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n actionCBActionPerformed(evt);\n }\n });\n runActionB.setText(bundle.getString(\"Run\")); \n runActionB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n runActionBActionPerformed(evt);\n }\n });\n jLabel2.setText(bundle.getString(\"Expression:\")); \n expressionCB.setEnabled(false);\n expressionCB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n expressionCBActionPerformed(evt);\n }\n });\n jLabel3.setText(bundle.getString(\"Render_Quality:\")); \n renderQuality.setModel(new javax.swing.DefaultComboBoxModel(new String[] { \"High\", \"Medium\", \"Low\" }));\n renderQuality.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n renderQualityActionPerformed(evt);\n }\n });\n winkB.setText(bundle.getString(\"Wink\")); \n winkB.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n winkBActionPerformed(evt);\n }\n });\n eyeSelectionCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { \"Left Eye\", \"Right Eye\" }));\n closeButton.setText(bundle.getString(\"Close\")); \n closeButton.addActionListener(new java.awt.event.ActionListener() {\n public void actionPerformed(java.awt.event.ActionEvent evt) {\n closeButtonActionPerformed(evt);\n }\n });\n org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);\n this.setLayout(layout);\n layout.setHorizontalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .addContainerGap()\n .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .addContainerGap(6, Short.MAX_VALUE))\n .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()\n .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2)\n .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .add(6, 6, 6)\n .add(closeButton))\n .add(layout.createSequentialGroup()\n .add(renderQuality, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(124, 124, 124))\n .add(layout.createSequentialGroup()\n .add(eyeSelectionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(winkB))\n .add(layout.createSequentialGroup()\n .add(expressionCB, 0, 144, Short.MAX_VALUE)\n .add(81, 81, 81))\n .add(layout.createSequentialGroup()\n .add(actionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(runActionB))\n .add(layout.createSequentialGroup()\n .add(homeB)\n .add(125, 125, 125))\n .add(locationTF, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))\n .addContainerGap())\n );\n layout.linkSize(new java.awt.Component[] {runActionB, winkB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n layout.linkSize(new java.awt.Component[] {actionCB, expressionCB, eyeSelectionCB}, org.jdesktop.layout.GroupLayout.HORIZONTAL);\n layout.setVerticalGroup(\n layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)\n .add(layout.createSequentialGroup()\n .addContainerGap()\n .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(locationTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(jLabel4))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(homeB)\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(jLabel1)\n .add(actionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(runActionB))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(jLabel2)\n .add(expressionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(eyeSelectionCB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(winkB))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)\n .add(renderQuality, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)\n .add(jLabel3))\n .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)\n .add(closeButton)\n .addContainerGap())\n );\n }\n"} {"input": " public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {\n CommandHandler.checkArgs(args, 3, 4, \"/region flag () \");\n try {\n String id = args[0].toLowerCase();\n String nameStr = args[1];\n String subnameStr = null;\n String valueStr = null;\n if (args.length < 4) {\n valueStr = args[2];\n } else {\n subnameStr = args[2];\n valueStr = args[3];\n }\n RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());\n ProtectedRegion region = mgr.getRegion(id);\n if (region == null) {\n sender.sendMessage(ChatColor.RED + \"Could not find a region by that ID.\");\n return true;\n }\n if (sender instanceof Player) {\n Player player = (Player) sender;\n if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {\n cfg.checkRegionPermission(sender, \"region.flag.ownregions\");\n } else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {\n cfg.checkRegionPermission(sender, \"region.flag.memberregions\");\n } else {\n cfg.checkRegionPermission(sender, \"region.flag.foreignregions\");\n }\n } else {\n cfg.checkRegionPermission(sender, \"region.flag.foreignregions\");\n }\n FlagInfo nfo = FlagInfo.getFlagInfo(nameStr, subnameStr);\n if (nfo == null) {\n sender.sendMessage(ChatColor.RED + \"Unknown flag specified.\");\n return true;\n } else if (nfo.subName != null && args.length < 4) {\n sender.sendMessage(ChatColor.RED + \"Name a subflag to set this flag.\");\n return true;\n }\n boolean validValue = false;\n switch (nfo.type) {\n case STRING: {\n validValue = true;\n break;\n }\n case INT: {\n validValue = true;\n try {\n Integer val = Integer.valueOf(valueStr);\n } catch (Exception e) {\n validValue = false;\n }\n break;\n }\n case BOOLEAN: {\n valueStr = valueStr.toLowerCase();\n if (valueStr.equals(\"on\")) {\n valueStr = \"true\";\n } else if (valueStr.equals(\"allow\")) {\n valueStr = \"true\";\n } else if (valueStr.equals(\"1\")) {\n valueStr = \"true\";\n }\n validValue = true;\n break;\n }\n case FLOAT: {\n validValue = true;\n try {\n Float val = Float.valueOf(valueStr);\n } catch (Exception e) {\n validValue = false;\n }\n break;\n }\n case DOUBLE: {\n validValue = true;\n try {\n Double val = Double.valueOf(valueStr);\n } catch (Exception e) {\n validValue = false;\n }\n break;\n }\n case STATE: {\n validValue = true;\n if (valueStr.equalsIgnoreCase(\"allow\")) {\n valueStr = AreaFlags.State.ALLOW.toString();\n } else if (valueStr.equalsIgnoreCase(\"deny\")) {\n valueStr = AreaFlags.State.DENY.toString();\n } else if (valueStr.equalsIgnoreCase(\"none\")) {\n valueStr = AreaFlags.State.NONE.toString();\n } else {\n validValue = false;\n }\n break;\n }\n case LOCATION: {\n if (!(sender instanceof Player)) {\n sender.sendMessage(ChatColor.RED + \"Flag not supported in console mode.\");\n return true;\n }\n Player player = (Player) sender;\n Location l = player.getLocation();\n if (valueStr.equals(\"set\")) {\n if (region.contains(BukkitUtil.toVector(l))) {\n region.getFlags().setLocationFlag(nfo.flagName, l);\n validValue = true;\n sender.sendMessage(ChatColor.YELLOW + \"Region '\" + id + \"' updated. Flag \" + nameStr + \" set to current location\");\n } else {\n player.sendMessage(ChatColor.RED + \"You must set the \" + nameStr + \" location inside the region it belongs to.\");\n return true;\n }\n } else if (valueStr.equals(\"delete\")) {\n region.getFlags().setLocationFlag(nfo.flagName, null);\n validValue = true;\n sender.sendMessage(ChatColor.YELLOW + \"Region '\" + id + \"' updated. Flag \" + nameStr + \" removed.\");\n }\n if (validValue) {\n mgr.save();\n return true;\n }\n break;\n }\n default: {\n validValue = false;\n break;\n }\n }\n String fullFlagname = nameStr;\n if (subnameStr != null) {\n fullFlagname += \" \" + subnameStr;\n }\n if (!validValue) {\n sender.sendMessage(ChatColor.RED + \"Invalid value '\" + valueStr + \"' for flag \" + fullFlagname);\n return true;\n }\n if (nfo.subName != null && nfo.subName.equals(\"*\")) {\n region.getFlags().setFlag(nfo.flagName, subnameStr, valueStr);\n } else {\n region.getFlags().setFlag(nfo.flagName, nfo.flagSubName, valueStr);\n }\n mgr.save();\n sender.sendMessage(ChatColor.YELLOW + \"Region '\" + id + \"' updated. Flag \" + fullFlagname + \" set to \" + valueStr);\n } catch (IOException e) {\n sender.sendMessage(ChatColor.RED + \"Region database failed to save: \"\n + e.getMessage());\n }\n return true;\n }\n", "output": " public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {\n CommandHandler.checkArgs(args, 3, 4, \"/region flag () \");\n try {\n String id = args[0].toLowerCase();\n String nameStr = args[1];\n String subnameStr = null;\n String valueStr = null;\n if (args.length < 4) {\n valueStr = args[2];\n } else {\n subnameStr = args[2];\n valueStr = args[3];\n }\n RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());\n ProtectedRegion region = mgr.getRegion(id);\n if (region == null) {\n sender.sendMessage(ChatColor.RED + \"Could not find a region by that ID.\");\n return true;\n }\n if (sender instanceof Player) {\n Player player = (Player) sender;\n if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {\n cfg.checkRegionPermission(sender, \"region.flag.ownregions\");\n } else if (region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {\n cfg.checkRegionPermission(sender, \"region.flag.memberregions\");\n } else {\n cfg.checkRegionPermission(sender, \"region.flag.foreignregions\");\n }\n } else {\n cfg.checkRegionPermission(sender, \"region.flag.foreignregions\");\n }\n FlagInfo nfo = FlagInfo.getFlagInfo(nameStr, subnameStr);\n if (nfo == null) {\n sender.sendMessage(ChatColor.RED + \"Unknown flag specified.\");\n return true;\n } else if (nfo.subName != null && args.length < 4) {\n sender.sendMessage(ChatColor.RED + \"Name a subflag and a value to set this flag.\");\n return true;\n }\n boolean validValue = false;\n switch (nfo.type) {\n case STRING: {\n validValue = true;\n break;\n }\n case INT: {\n validValue = true;\n try {\n Integer val = Integer.valueOf(valueStr);\n } catch (Exception e) {\n validValue = false;\n }\n break;\n }\n case BOOLEAN: {\n valueStr = valueStr.toLowerCase();\n if (valueStr.equals(\"on\")) {\n valueStr = \"true\";\n } else if (valueStr.equals(\"allow\")) {\n valueStr = \"true\";\n } else if (valueStr.equals(\"1\")) {\n valueStr = \"true\";\n }\n validValue = true;\n break;\n }\n case FLOAT: {\n validValue = true;\n try {\n Float val = Float.valueOf(valueStr);\n } catch (Exception e) {\n validValue = false;\n }\n break;\n }\n case DOUBLE: {\n validValue = true;\n try {\n Double val = Double.valueOf(valueStr);\n } catch (Exception e) {\n validValue = false;\n }\n break;\n }\n case STATE: {\n validValue = true;\n if (valueStr.equalsIgnoreCase(\"allow\")) {\n valueStr = AreaFlags.State.ALLOW.toString();\n } else if (valueStr.equalsIgnoreCase(\"deny\")) {\n valueStr = AreaFlags.State.DENY.toString();\n } else if (valueStr.equalsIgnoreCase(\"none\")) {\n valueStr = AreaFlags.State.NONE.toString();\n } else {\n validValue = false;\n }\n break;\n }\n case LOCATION: {\n if (!(sender instanceof Player)) {\n sender.sendMessage(ChatColor.RED + \"Flag not supported in console mode.\");\n return true;\n }\n Player player = (Player) sender;\n Location l = player.getLocation();\n if (valueStr.equals(\"set\")) {\n if (region.contains(BukkitUtil.toVector(l))) {\n region.getFlags().setLocationFlag(nfo.flagName, l);\n validValue = true;\n sender.sendMessage(ChatColor.YELLOW + \"Region '\" + id + \"' updated. Flag \" + nameStr + \" set to current location\");\n } else {\n player.sendMessage(ChatColor.RED + \"You must set the \" + nameStr + \" location inside the region it belongs to.\");\n return true;\n }\n } else if (valueStr.equals(\"delete\")) {\n region.getFlags().setLocationFlag(nfo.flagName, null);\n validValue = true;\n sender.sendMessage(ChatColor.YELLOW + \"Region '\" + id + \"' updated. Flag \" + nameStr + \" removed.\");\n }\n if (validValue) {\n mgr.save();\n return true;\n }\n break;\n }\n default: {\n validValue = false;\n break;\n }\n }\n String fullFlagname = nameStr;\n if (subnameStr != null) {\n fullFlagname += \" \" + subnameStr;\n }\n if (!validValue) {\n sender.sendMessage(ChatColor.RED + \"Invalid value '\" + valueStr + \"' for flag \" + fullFlagname);\n return true;\n }\n if (nfo.subName != null && nfo.subName.equals(\"*\")) {\n region.getFlags().setFlag(nfo.flagName, subnameStr, valueStr);\n } else {\n region.getFlags().setFlag(nfo.flagName, nfo.flagSubName, valueStr);\n }\n mgr.save();\n sender.sendMessage(ChatColor.YELLOW + \"Region '\" + id + \"' updated. Flag \" + fullFlagname + \" set to \" + valueStr);\n } catch (IOException e) {\n sender.sendMessage(ChatColor.RED + \"Region database failed to save: \"\n + e.getMessage());\n }\n return true;\n }\n"} {"input": "\tpublic Domain generateDomain(DatabaseMeta databaseMeta, List joinTemplates) {\n\t\tDomain domain = null;\n\t\ttry {\n\t\t\tString locale = LocalizedString.DEFAULT_LOCALE;\n\t\t\tthis.generator.setLocale(locale);\n\t\t\tthis.generator.setDatabaseMeta(databaseMeta);\n\t\t\tthis.generator.setModelName(datasourceName);\n\t\t\tList schemas = new ArrayList();\n\t\t\tfor (LogicalRelationship joinTemplate : joinTemplates) {\n\t\t\t\tschemas.add(new SchemaTable(\"\", joinTemplate.getFromTable().getName(locale)));\n\t\t\t\tschemas.add(new SchemaTable(\"\", joinTemplate.getToTable().getName(locale)));\n\t\t\t}\n\t\t\tSchemaTable tableNames[] = new SchemaTable[schemas.size()];\n\t\t\ttableNames = schemas.toArray(tableNames);\n\t\t\tthis.generator.setTableNames(tableNames);\n\t\t\tdomain = this.generator.generateDomain();\n\t\t\tdomain.setId(datasourceName);\n\t\t\tModelerWorkspaceHelper helper = new ModelerWorkspaceHelper(locale);\n\t\t\tModelerWorkspace workspace = new ModelerWorkspace(helper);\n\t\t\tworkspace.setModelName(datasourceName);\n\t\t\tworkspace.setDomain(domain);\n\t\t\tLogicalModel logicalModel = domain.getLogicalModels().get(0);\n\t\t\tlogicalModel.setName(new LocalizedString(locale, datasourceName));\n\t\t\tlogicalModel.setDescription(new LocalizedString(locale, \"This is the data model for \"\n\t\t + datasourceName));\n\t\t LogicalTable businessTable = logicalModel.getLogicalTables().get(0);\n\t\t businessTable.setName(new LocalizedString(locale, datasourceName));\n\t\t\tfor (LogicalRelationship joinTemplate : joinTemplates) {\n\t\t\t\tString lTable = joinTemplate.getFromTable().getName(locale);\n\t\t\t\tString rTable = joinTemplate.getToTable().getName(locale);\n\t\t\t\tLogicalTable fromTable = null;\n\t\t\t\tLogicalColumn fromColumn = null;\n\t\t\t\tLogicalTable toTable = null;\n\t\t\t\tLogicalColumn toColumn = null;\n\t\t\t\tfor (LogicalTable logicalTable : logicalModel.getLogicalTables()) {\n\t\t\t\t\tif (logicalTable.getName(locale).equals(lTable)) {\n\t\t\t\t\t\tfromTable = logicalTable;\n\t\t\t\t\t\tfor (LogicalColumn logicalColumn : fromTable.getLogicalColumns()) {\n\t\t\t\t\t\t\tif (logicalColumn.getName(locale).equals(joinTemplate.getFromColumn().getName(locale))) {\n\t\t\t\t\t\t\t\tfromColumn = logicalColumn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (logicalTable.getName(locale).equals(rTable)) {\n\t\t\t\t\t\ttoTable = logicalTable;\n\t\t\t\t\t\tfor (LogicalColumn logicalColumn : toTable.getLogicalColumns()) {\n\t\t\t\t\t\t\tif (logicalColumn.getName(locale).equals(joinTemplate.getToColumn().getName(locale))) {\n\t\t\t\t\t\t\t\ttoColumn = logicalColumn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tLogicalRelationship logicalRelationship = new LogicalRelationship();\n\t\t\t\tlogicalRelationship.setRelationshipType(RelationshipType._1_1);\n\t\t\t\tlogicalRelationship.setFromTable(fromTable);\n\t\t\t\tlogicalRelationship.setFromColumn(fromColumn);\n\t\t\t\tlogicalRelationship.setToTable(toTable);\n\t\t\t\tlogicalRelationship.setToColumn(toColumn);\n\t\t\t\tlogicalModel.addLogicalRelationship(logicalRelationship);\n\t\t\t}\n\t\t\thelper.autoModelMultiTableRelational(workspace);\n\t\t\thelper.populateDomain(workspace);\t\t\t\n\t\t} catch (PentahoMetadataException e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.info(e.getLocalizedMessage());\n\t\t} catch (ModelerException e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.info(e.getLocalizedMessage());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.info(e.getLocalizedMessage());\n\t\t}\n\t\treturn domain;\n\t}\n", "output": "\tpublic Domain generateDomain(DatabaseMeta databaseMeta, List joinTemplates) {\n\t\tDomain domain = null;\n\t\ttry {\n\t\t\tString locale = LocalizedString.DEFAULT_LOCALE;\n\t\t\tthis.generator.setLocale(locale);\n\t\t\tthis.generator.setDatabaseMeta(databaseMeta);\n\t\t\tthis.generator.setModelName(datasourceName);\n\t\t\tList schemas = new ArrayList();\n\t\t\tfor (LogicalRelationship joinTemplate : joinTemplates) {\n\t\t\t\tschemas.add(new SchemaTable(\"\", joinTemplate.getFromTable().getName(locale)));\n\t\t\t\tschemas.add(new SchemaTable(\"\", joinTemplate.getToTable().getName(locale)));\n\t\t\t}\n\t\t\tSchemaTable tableNames[] = new SchemaTable[schemas.size()];\n\t\t\ttableNames = schemas.toArray(tableNames);\n\t\t\tthis.generator.setTableNames(tableNames);\n\t\t\tdomain = this.generator.generateDomain();\n\t\t\tdomain.setId(datasourceName);\n\t\t\tModelerWorkspaceHelper helper = new ModelerWorkspaceHelper(locale);\n\t\t\tModelerWorkspace workspace = new ModelerWorkspace(helper);\n\t\t\tworkspace.setModelName(datasourceName);\n\t\t\tworkspace.setDomain(domain);\n\t\t\tLogicalModel logicalModel = domain.getLogicalModels().get(0);\n\t\t\tlogicalModel.setName(new LocalizedString(locale, datasourceName));\n\t\t\tlogicalModel.setDescription(new LocalizedString(locale, \"This is the data model for \"\n\t\t + datasourceName));\n\t\t LogicalTable businessTable = logicalModel.getLogicalTables().get(0);\n\t\t businessTable.setName(new LocalizedString(locale, datasourceName));\n\t\t\tfor (LogicalRelationship joinTemplate : joinTemplates) {\n\t\t\t\tString lTable = joinTemplate.getFromTable().getName(locale);\n\t\t\t\tString rTable = joinTemplate.getToTable().getName(locale);\n\t\t\t\tLogicalTable fromTable = null;\n\t\t\t\tLogicalColumn fromColumn = null;\n\t\t\t\tLogicalTable toTable = null;\n\t\t\t\tLogicalColumn toColumn = null;\n\t\t\t\tfor (LogicalTable logicalTable : logicalModel.getLogicalTables()) {\n\t\t\t\t\tif (logicalTable.getName(locale).equals(lTable)) {\n\t\t\t\t\t\tfromTable = logicalTable;\n\t\t\t\t\t\tfor (LogicalColumn logicalColumn : fromTable.getLogicalColumns()) {\n\t\t\t\t\t\t\tif (logicalColumn.getName(locale).equals(joinTemplate.getFromColumn().getName(locale))) {\n\t\t\t\t\t\t\t\tfromColumn = logicalColumn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (logicalTable.getName(locale).equals(rTable)) {\n\t\t\t\t\t\ttoTable = logicalTable;\n\t\t\t\t\t\tfor (LogicalColumn logicalColumn : toTable.getLogicalColumns()) {\n\t\t\t\t\t\t\tif (logicalColumn.getName(locale).equals(joinTemplate.getToColumn().getName(locale))) {\n\t\t\t\t\t\t\t\ttoColumn = logicalColumn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tLogicalRelationship logicalRelationship = new LogicalRelationship();\n\t\t\t\tlogicalRelationship.setRelationshipType(RelationshipType._1_1);\n\t\t\t\tlogicalRelationship.setFromTable(fromTable);\n\t\t\t\tlogicalRelationship.setFromColumn(fromColumn);\n\t\t\t\tlogicalRelationship.setToTable(toTable);\n\t\t\t\tlogicalRelationship.setToColumn(toColumn);\n\t\t\t\tlogicalModel.addLogicalRelationship(logicalRelationship);\n\t\t\t}\n\t\t\thelper.autoModelMultiTableRelational(workspace);\n\t\t\tworkspace.setModelName(datasourceName);\n\t\t\thelper.populateDomain(workspace);\t\t\t\n\t\t} catch (PentahoMetadataException e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.info(e.getLocalizedMessage());\n\t\t} catch (ModelerException e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.info(e.getLocalizedMessage());\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t\tlogger.info(e.getLocalizedMessage());\n\t\t}\n\t\treturn domain;\n\t}\n"} {"input": " public boolean evaluate(BillingState state, DateTime now) {\n\t DateTime unpaidInvoiceTriggerDate = null;\n\t if( timeSinceEarliestUnpaidInvoiceEqualsOrExceeds != null && state.getDateOfEarliestUnpaidInvoice() != null) { \n\t unpaidInvoiceTriggerDate = state.getDateOfEarliestUnpaidInvoice().plus(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds.toJodaPeriod());\n\t }\n\t\treturn \n\t\t\t\t(numberOfUnpaidInvoicesEqualsOrExceeds == null || state.getNumberOfUnpaidInvoices() >= numberOfUnpaidInvoicesEqualsOrExceeds.intValue() ) &&\n\t\t\t\t(totalUnpaidInvoiceBalanceEqualsOrExceeds == null || totalUnpaidInvoiceBalanceEqualsOrExceeds.compareTo(state.getBalanceOfUnpaidInvoices()) <= 0) &&\n\t\t\t\t(unpaidInvoiceTriggerDate == null ||\n\t\t\t\t (state.getDateOfEarliestUnpaidInvoice() != null && !unpaidInvoiceTriggerDate.isAfter(now))) &&\n\t\t\t\t(responseForLastFailedPayment == null || responseIsIn(state.getResponseForLastFailedPayment(), responseForLastFailedPayment)) &&\n\t\t\t\t(controlTag == null || isTagIn(controlTag, state.getTags()));\n\t}\n", "output": " public boolean evaluate(BillingState state, DateTime now) {\n\t DateTime unpaidInvoiceTriggerDate = null;\n\t if( timeSinceEarliestUnpaidInvoiceEqualsOrExceeds != null && state.getDateOfEarliestUnpaidInvoice() != null) { \n\t unpaidInvoiceTriggerDate = state.getDateOfEarliestUnpaidInvoice().plus(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds.toJodaPeriod());\n\t }\n\t\treturn \n\t\t\t\t(numberOfUnpaidInvoicesEqualsOrExceeds == null || state.getNumberOfUnpaidInvoices() >= numberOfUnpaidInvoicesEqualsOrExceeds.intValue() ) &&\n\t\t\t\t(totalUnpaidInvoiceBalanceEqualsOrExceeds == null || totalUnpaidInvoiceBalanceEqualsOrExceeds.compareTo(state.getBalanceOfUnpaidInvoices()) <= 0) &&\n\t\t\t\t(timeSinceEarliestUnpaidInvoiceEqualsOrExceeds == null ||\n\t\t\t\t (unpaidInvoiceTriggerDate != null && !unpaidInvoiceTriggerDate.isAfter(now))) &&\n\t\t\t\t(responseForLastFailedPayment == null || responseIsIn(state.getResponseForLastFailedPayment(), responseForLastFailedPayment)) &&\n\t\t\t\t(controlTag == null || isTagIn(controlTag, state.getTags()));\n\t}\n"} {"input": " private List>\n makeMergedAlgoNodes(ExperimentSuite experiments, MeasurementSuite measurements, TTDataSet dataset, ExperimentOutputs outputs,\n DAGNode commonDep) throws RecommenderConfigurationException {\n List> nodes = Lists.newArrayList();\n MergePool mergePool = MergePool.create();\n List> graphs = Lists.newArrayList();\n Set> allNodes = Sets.newHashSet();\n ComponentCache cache = new ComponentCache(cacheDir);\n for (AlgorithmInstance algo: experiments.getAlgorithms()) {\n logger.debug(\"building graph for algorithm {}\", algo);\n DAGNode graph =\n algo.buildRecommenderGraph(dataset.getTrainingData().getConfiguration());\n graph = mergePool.merge(graph);\n logger.debug(\"algorithm {} has {} new configuration nodes\", algo,\n Sets.difference(allNodes, graph.getReachableNodes()).size());\n allNodes.addAll(graph.getReachableNodes());\n LenskitEvalJob job = new LenskitEvalJob(algo, dataset, measurements,\n outputs.getPrefixed(algo, dataset),\n graph, cache);\n DAGNodeBuilder nb = DAGNode.newBuilder();\n nb.setLabel(TaskGraph.jobNode(job));\n if (commonDep != null) {\n nb.addEdge(commonDep, TaskGraph.edge());\n }\n assert nodes.size() == graphs.size();\n Set> seen = Sets.newHashSet();\n logger.debug(\"finding dependencies of {}\", job);\n for (int i = 0; i < nodes.size(); i++) {\n DAGNode other = graphs.get(i);\n Set> freshCommon = Sets.newHashSet();\n freshCommon.addAll(other.getReachableNodes());\n freshCommon.addAll(graph.getReachableNodes());\n freshCommon.removeAll(seen);\n if (!freshCommon.isEmpty()) {\n logger.debug(\"{} depends on {} for {} nodes\",\n job, nodes.get(i).getLabel(),\n freshCommon.size());\n for (DAGNode shared: freshCommon) {\n logger.debug(\"it will reuse {}\",\n shared.getLabel().getSatisfaction());\n }\n nb.addEdge(nodes.get(i), TaskGraph.edge());\n }\n seen.addAll(freshCommon);\n }\n graphs.add(graph);\n DAGNode jobNode = nb.build();\n logger.debug(\"{} has {} dependencies\", job, jobNode.getAdjacentNodes().size());\n nodes.add(jobNode);\n }\n return nodes;\n }\n", "output": " private List>\n makeMergedAlgoNodes(ExperimentSuite experiments, MeasurementSuite measurements, TTDataSet dataset, ExperimentOutputs outputs,\n DAGNode commonDep) throws RecommenderConfigurationException {\n List> nodes = Lists.newArrayList();\n MergePool mergePool = MergePool.create();\n List> graphs = Lists.newArrayList();\n Set> allNodes = Sets.newHashSet();\n ComponentCache cache = new ComponentCache(cacheDir);\n for (AlgorithmInstance algo: experiments.getAlgorithms()) {\n logger.debug(\"building graph for algorithm {}\", algo);\n DAGNode graph =\n algo.buildRecommenderGraph(dataset.getTrainingData().getConfiguration());\n graph = mergePool.merge(graph);\n logger.debug(\"algorithm {} has {} new configuration nodes\", algo,\n Sets.difference(graph.getReachableNodes(), allNodes).size());\n allNodes.addAll(graph.getReachableNodes());\n LenskitEvalJob job = new LenskitEvalJob(algo, dataset, measurements,\n outputs.getPrefixed(algo, dataset),\n graph, cache);\n DAGNodeBuilder nb = DAGNode.newBuilder();\n nb.setLabel(TaskGraph.jobNode(job));\n if (commonDep != null) {\n nb.addEdge(commonDep, TaskGraph.edge());\n }\n assert nodes.size() == graphs.size();\n Set> seen = Sets.newHashSet();\n logger.debug(\"finding dependencies of {}\", job);\n for (int i = 0; i < nodes.size(); i++) {\n DAGNode other = graphs.get(i);\n Set> freshCommon = Sets.newHashSet();\n freshCommon.addAll(graph.getReachableNodes());\n freshCommon.retainAll(other.getReachableNodes());\n freshCommon.removeAll(seen);\n if (!freshCommon.isEmpty()) {\n logger.debug(\"{} depends on {} for {} nodes\",\n job, nodes.get(i).getLabel(),\n freshCommon.size());\n for (DAGNode shared: freshCommon) {\n logger.debug(\"it will reuse {}\",\n shared.getLabel().getSatisfaction());\n }\n nb.addEdge(nodes.get(i), TaskGraph.edge());\n }\n seen.addAll(freshCommon);\n }\n graphs.add(graph);\n DAGNode jobNode = nb.build();\n logger.debug(\"{} has {} dependencies\", job, jobNode.getAdjacentNodes().size());\n nodes.add(jobNode);\n }\n return nodes;\n }\n"} {"input": " private Cursor queryLocal(Uri uri, String[] projection, String selection,\n String[] selectionArgs, String sortOrder, long directoryId,\n final boolean suppressProfileCheck) {\n if (VERBOSE_LOGGING) {\n Log.v(TAG, \"query: \" + uri);\n }\n final SQLiteDatabase db = mDbHelper.getReadableDatabase();\n SQLiteQueryBuilder qb = new SQLiteQueryBuilder();\n String groupBy = null;\n String limit = getLimit(uri);\n String profileRestrictionColumnName = null;\n final int match = sUriMatcher.match(uri);\n switch (match) {\n case SYNCSTATE:\n return mDbHelper.getSyncState().query(db, projection, selection, selectionArgs,\n sortOrder);\n case CONTACTS: {\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n appendLocalDirectorySelectionIfNeeded(qb, directoryId);\n profileRestrictionColumnName = Contacts.IS_USER_PROFILE;\n sortOrder = prependProfileSortIfNeeded(uri, sortOrder, suppressProfileCheck);\n break;\n }\n case CONTACTS_ID: {\n long contactId = ContentUris.parseId(uri);\n enforceProfilePermissionForContact(db, contactId, false);\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(Contacts._ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP:\n case CONTACTS_LOOKUP_ID: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 3) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 4) {\n long contactId = Long.parseLong(pathSegments.get(3));\n enforceProfilePermissionForContact(db, contactId, false);\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForContacts(lookupQb, uri, projection);\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n Contacts._ID, contactId, Contacts.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(lookupContactIdByLookupKey(db, lookupKey)));\n qb.appendWhere(Contacts._ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP_DATA:\n case CONTACTS_LOOKUP_ID_DATA: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 4) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 5) {\n long contactId = Long.parseLong(pathSegments.get(3));\n enforceProfilePermissionForContact(db, contactId, false);\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForData(lookupQb, uri, projection, false);\n lookupQb.appendWhere(\" AND \");\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n Data.CONTACT_ID, contactId, Data.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n long contactId = lookupContactIdByLookupKey(db, lookupKey);\n enforceProfilePermissionForContact(db, contactId, false);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(contactId));\n qb.appendWhere(\" AND \" + Data.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_ID_STREAM_ITEMS: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n enforceProfilePermissionForContact(db, contactId, false);\n setTablesAndProjectionMapForStreamItems(qb);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(RawContactsColumns.CONCRETE_CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP_STREAM_ITEMS:\n case CONTACTS_LOOKUP_ID_STREAM_ITEMS: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 4) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 5) {\n long contactId = Long.parseLong(pathSegments.get(3));\n enforceProfilePermissionForContact(db, contactId, false);\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForStreamItems(lookupQb);\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n RawContacts.CONTACT_ID, contactId, Contacts.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForStreamItems(qb);\n long contactId = lookupContactIdByLookupKey(db, lookupKey);\n enforceProfilePermissionForContact(db, contactId, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(RawContacts.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_AS_VCARD: {\n final String lookupKey = Uri.encode(uri.getPathSegments().get(2));\n long contactId = lookupContactIdByLookupKey(db, lookupKey);\n enforceProfilePermissionForContact(db, contactId, false);\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sContactsVCardProjectionMap);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(contactId));\n qb.appendWhere(Contacts._ID + \"=?\");\n break;\n }\n case CONTACTS_AS_MULTI_VCARD: {\n SimpleDateFormat dateFormat = new SimpleDateFormat(\"yyyyMMdd_HHmmss\");\n String currentDateString = dateFormat.format(new Date()).toString();\n return db.rawQuery(\n \"SELECT\" +\n \" 'vcards_' || ? || '.vcf' AS \" + OpenableColumns.DISPLAY_NAME + \",\" +\n \" NULL AS \" + OpenableColumns.SIZE,\n new String[] { currentDateString });\n }\n case CONTACTS_FILTER: {\n String filterParam = \"\";\n if (uri.getPathSegments().size() > 2) {\n filterParam = uri.getLastPathSegment();\n }\n setTablesAndProjectionMapForContactsWithSnippet(\n qb, uri, projection, filterParam, directoryId);\n profileRestrictionColumnName = Contacts.IS_USER_PROFILE;\n sortOrder = prependProfileSortIfNeeded(uri, sortOrder, suppressProfileCheck);\n break;\n }\n case CONTACTS_STREQUENT_FILTER:\n case CONTACTS_STREQUENT: {\n final boolean phoneOnly = readBooleanQueryParameter(\n uri, ContactsContract.STREQUENT_PHONE_ONLY, false);\n if (match == CONTACTS_STREQUENT_FILTER && uri.getPathSegments().size() > 3) {\n String filterParam = uri.getLastPathSegment();\n StringBuilder sb = new StringBuilder();\n sb.append(Contacts._ID + \" IN \");\n appendContactFilterAsNestedQuery(sb, filterParam);\n selection = DbQueryUtils.concatenateClauses(selection, sb.toString());\n }\n String[] subProjection = null;\n if (projection != null) {\n subProjection = appendProjectionArg(projection, TIMES_USED_SORT_COLUMN);\n }\n setTablesAndProjectionMapForContacts(qb, uri, projection, false);\n qb.setProjectionMap(phoneOnly ?\n sStrequentPhoneOnlyStarredProjectionMap\n : sStrequentStarredProjectionMap);\n qb.appendWhere(DbQueryUtils.concatenateClauses(\n selection, Contacts.IS_USER_PROFILE + \"=0\"));\n if (phoneOnly) {\n qb.appendWhere(\" AND \" + Contacts.HAS_PHONE_NUMBER + \"=1\");\n }\n qb.setStrict(true);\n final String starredQuery = qb.buildQuery(subProjection,\n Contacts.STARRED + \"=1\", Contacts._ID, null, null, null);\n qb = new SQLiteQueryBuilder();\n qb.setStrict(true);\n final String frequentQuery;\n if (phoneOnly) {\n final StringBuilder tableBuilder = new StringBuilder();\n tableBuilder.append(Tables.DATA_USAGE_STAT\n + \" INNER JOIN \" + Views.DATA + \" \" + Tables.DATA\n + \" ON (\" + DataUsageStatColumns.CONCRETE_DATA_ID + \"=\"\n + DataColumns.CONCRETE_ID + \" AND \"\n + DataUsageStatColumns.CONCRETE_USAGE_TYPE + \"=\"\n + DataUsageStatColumns.USAGE_TYPE_INT_CALL + \")\");\n appendContactPresenceJoin(tableBuilder, projection, RawContacts.CONTACT_ID);\n appendContactStatusUpdateJoin(tableBuilder, projection,\n ContactsColumns.LAST_STATUS_UPDATE_ID);\n qb.setTables(tableBuilder.toString());\n qb.setProjectionMap(sStrequentPhoneOnlyFrequentProjectionMap);\n qb.appendWhere(DbQueryUtils.concatenateClauses(\n selection,\n Contacts.STARRED + \"=0 OR \" + Contacts.STARRED + \" IS NULL\",\n MimetypesColumns.MIMETYPE + \" IN (\"\n + \"'\" + Phone.CONTENT_ITEM_TYPE + \"', \"\n + \"'\" + SipAddress.CONTENT_ITEM_TYPE + \"')\"));\n frequentQuery = qb.buildQuery(subProjection, null, null, null, null, null);\n } else {\n setTablesAndProjectionMapForContacts(qb, uri, projection, true);\n qb.setProjectionMap(sStrequentFrequentProjectionMap);\n qb.appendWhere(DbQueryUtils.concatenateClauses(\n selection,\n \"(\" + Contacts.STARRED + \" =0 OR \" + Contacts.STARRED + \" IS NULL)\",\n Contacts.IS_USER_PROFILE + \"=0\"));\n frequentQuery = qb.buildQuery(subProjection,\n null, Contacts._ID, null, null, null);\n }\n final String unionQuery =\n qb.buildUnionQuery(new String[] {starredQuery, frequentQuery},\n STREQUENT_ORDER_BY, STREQUENT_LIMIT);\n String[] doubledSelectionArgs = null;\n if (selectionArgs != null) {\n final int length = selectionArgs.length;\n doubledSelectionArgs = new String[length * 2];\n System.arraycopy(selectionArgs, 0, doubledSelectionArgs, 0, length);\n System.arraycopy(selectionArgs, 0, doubledSelectionArgs, length, length);\n }\n Cursor cursor = db.rawQuery(unionQuery, doubledSelectionArgs);\n if (cursor != null) {\n cursor.setNotificationUri(getContext().getContentResolver(),\n ContactsContract.AUTHORITY_URI);\n }\n return cursor;\n }\n case CONTACTS_FREQUENT: {\n setTablesAndProjectionMapForContacts(qb, uri, projection, true);\n qb.setProjectionMap(sStrequentFrequentProjectionMap);\n qb.appendWhere(Contacts.IS_USER_PROFILE + \"=0\");\n groupBy = Contacts._ID;\n if (!TextUtils.isEmpty(sortOrder)) {\n sortOrder = FREQUENT_ORDER_BY + \", \" + sortOrder;\n } else {\n sortOrder = FREQUENT_ORDER_BY;\n }\n break;\n }\n case CONTACTS_GROUP: {\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n if (uri.getPathSegments().size() > 2) {\n qb.appendWhere(CONTACTS_IN_GROUP_SELECT);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n }\n break;\n }\n case PROFILE: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n qb.appendWhere(Contacts.IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_ENTITIES: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForEntities(qb, uri, projection);\n qb.appendWhere(\" AND \" + Contacts.IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_DATA: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_DATA_ID: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data._ID + \"=? AND \"\n + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_AS_VCARD: {\n enforceProfilePermission(false);\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sContactsVCardProjectionMap);\n qb.appendWhere(Contacts.IS_USER_PROFILE + \"=1\");\n break;\n }\n case CONTACTS_ID_DATA: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(\" AND \" + RawContacts.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_ID_PHOTO: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n enforceProfilePermissionForContact(db, contactId, false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(\" AND \" + RawContacts.CONTACT_ID + \"=?\");\n qb.appendWhere(\" AND \" + Data._ID + \"=\" + Contacts.PHOTO_ID);\n break;\n }\n case CONTACTS_ID_ENTITIES: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForEntities(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(\" AND \" + RawContacts.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP_ENTITIES:\n case CONTACTS_LOOKUP_ID_ENTITIES: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 4) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 5) {\n long contactId = Long.parseLong(pathSegments.get(3));\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForEntities(lookupQb, uri, projection);\n lookupQb.appendWhere(\" AND \");\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n Contacts.Entity.CONTACT_ID, contactId,\n Contacts.Entity.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForEntities(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(lookupContactIdByLookupKey(db, lookupKey)));\n qb.appendWhere(\" AND \" + Contacts.Entity.CONTACT_ID + \"=?\");\n break;\n }\n case STREAM_ITEMS: {\n setTablesAndProjectionMapForStreamItems(qb);\n break;\n }\n case STREAM_ITEMS_ID: {\n setTablesAndProjectionMapForStreamItems(qb);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(StreamItemsColumns.CONCRETE_ID + \"=?\");\n break;\n }\n case STREAM_ITEMS_LIMIT: {\n MatrixCursor cursor = new MatrixCursor(new String[]{StreamItems.MAX_ITEMS}, 1);\n cursor.addRow(new Object[]{MAX_STREAM_ITEMS_PER_RAW_CONTACT});\n return cursor;\n }\n case STREAM_ITEMS_PHOTOS: {\n setTablesAndProjectionMapForStreamItemPhotos(qb);\n break;\n }\n case STREAM_ITEMS_ID_PHOTOS: {\n setTablesAndProjectionMapForStreamItemPhotos(qb);\n String streamItemId = uri.getPathSegments().get(1);\n selectionArgs = insertSelectionArg(selectionArgs, streamItemId);\n qb.appendWhere(StreamItemPhotosColumns.CONCRETE_STREAM_ITEM_ID + \"=?\");\n break;\n }\n case STREAM_ITEMS_ID_PHOTOS_ID: {\n setTablesAndProjectionMapForStreamItemPhotos(qb);\n String streamItemId = uri.getPathSegments().get(1);\n String streamItemPhotoId = uri.getPathSegments().get(3);\n selectionArgs = insertSelectionArg(selectionArgs, streamItemPhotoId);\n selectionArgs = insertSelectionArg(selectionArgs, streamItemId);\n qb.appendWhere(StreamItemPhotosColumns.CONCRETE_STREAM_ITEM_ID + \"=? AND \" +\n StreamItemPhotosColumns.CONCRETE_ID + \"=?\");\n break;\n }\n case PHOTO_DIMENSIONS: {\n MatrixCursor cursor = new MatrixCursor(\n new String[]{DisplayPhoto.DISPLAY_MAX_DIM, DisplayPhoto.THUMBNAIL_MAX_DIM},\n 1);\n cursor.addRow(new Object[]{mMaxDisplayPhotoDim, mMaxThumbnailPhotoDim});\n return cursor;\n }\n case PHONES: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Phone.CONTENT_ITEM_TYPE + \"'\");\n break;\n }\n case PHONES_ID: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Phone.CONTENT_ITEM_TYPE + \"'\");\n qb.appendWhere(\" AND \" + Data._ID + \"=?\");\n break;\n }\n case PHONES_FILTER: {\n String typeParam = uri.getQueryParameter(DataUsageFeedback.USAGE_TYPE);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n Integer typeInt = sDataUsageTypeMap.get(typeParam);\n if (typeInt == null) {\n typeInt = DataUsageStatColumns.USAGE_TYPE_INT_CALL;\n }\n setTablesAndProjectionMapForData(qb, uri, projection, true, typeInt);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Phone.CONTENT_ITEM_TYPE + \"'\");\n if (uri.getPathSegments().size() > 2) {\n String filterParam = uri.getLastPathSegment();\n StringBuilder sb = new StringBuilder();\n sb.append(\" AND (\");\n boolean hasCondition = false;\n boolean orNeeded = false;\n String normalizedName = NameNormalizer.normalize(filterParam);\n if (normalizedName.length() > 0) {\n sb.append(Data.RAW_CONTACT_ID + \" IN \" +\n \"(SELECT \" + RawContactsColumns.CONCRETE_ID +\n \" FROM \" + Tables.SEARCH_INDEX +\n \" JOIN \" + Tables.RAW_CONTACTS +\n \" ON (\" + Tables.SEARCH_INDEX + \".\" + SearchIndexColumns.CONTACT_ID\n + \"=\" + RawContactsColumns.CONCRETE_CONTACT_ID + \")\" +\n \" WHERE \" + SearchIndexColumns.NAME + \" MATCH \");\n DatabaseUtils.appendEscapedSQLString(sb, sanitizeMatch(filterParam) + \"*\");\n sb.append(\")\");\n orNeeded = true;\n hasCondition = true;\n }\n String number = PhoneNumberUtils.normalizeNumber(filterParam);\n if (!TextUtils.isEmpty(number)) {\n if (orNeeded) {\n sb.append(\" OR \");\n }\n sb.append(Data._ID +\n \" IN (SELECT DISTINCT \" + PhoneLookupColumns.DATA_ID\n + \" FROM \" + Tables.PHONE_LOOKUP\n + \" WHERE \" + PhoneLookupColumns.NORMALIZED_NUMBER + \" LIKE '\");\n sb.append(number);\n sb.append(\"%')\");\n hasCondition = true;\n }\n if (!hasCondition) {\n sb.append(\"0\");\n }\n sb.append(\")\");\n qb.appendWhere(sb);\n }\n groupBy = PhoneColumns.NORMALIZED_NUMBER + \",\" + RawContacts.CONTACT_ID;\n if (sortOrder == null) {\n final String accountPromotionSortOrder = getAccountPromotionSortOrder(uri);\n if (!TextUtils.isEmpty(accountPromotionSortOrder)) {\n sortOrder = accountPromotionSortOrder + \", \" + PHONE_FILTER_SORT_ORDER;\n } else {\n sortOrder = PHONE_FILTER_SORT_ORDER;\n }\n }\n break;\n }\n case EMAILS: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Email.CONTENT_ITEM_TYPE + \"'\");\n break;\n }\n case EMAILS_ID: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Email.CONTENT_ITEM_TYPE + \"'\"\n + \" AND \" + Data._ID + \"=?\");\n break;\n }\n case EMAILS_LOOKUP: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Email.CONTENT_ITEM_TYPE + \"'\");\n if (uri.getPathSegments().size() > 2) {\n String email = uri.getLastPathSegment();\n String address = mDbHelper.extractAddressFromEmailAddress(email);\n selectionArgs = insertSelectionArg(selectionArgs, address);\n qb.appendWhere(\" AND UPPER(\" + Email.DATA + \")=UPPER(?)\");\n }\n break;\n }\n case EMAILS_FILTER: {\n String typeParam = uri.getQueryParameter(DataUsageFeedback.USAGE_TYPE);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n Integer typeInt = sDataUsageTypeMap.get(typeParam);\n if (typeInt == null) {\n typeInt = DataUsageStatColumns.USAGE_TYPE_INT_LONG_TEXT;\n }\n setTablesAndProjectionMapForData(qb, uri, projection, true, typeInt);\n String filterParam = null;\n if (uri.getPathSegments().size() > 3) {\n filterParam = uri.getLastPathSegment();\n if (TextUtils.isEmpty(filterParam)) {\n filterParam = null;\n }\n }\n if (filterParam == null) {\n qb.appendWhere(\" AND 0\");\n } else {\n StringBuilder sb = new StringBuilder();\n sb.append(\" AND \" + Data._ID + \" IN (\");\n sb.append(\n \"SELECT \" + Data._ID +\n \" FROM \" + Tables.DATA +\n \" WHERE \" + DataColumns.MIMETYPE_ID + \"=\");\n sb.append(mDbHelper.getMimeTypeIdForEmail());\n sb.append(\" AND \" + Data.DATA1 + \" LIKE \");\n DatabaseUtils.appendEscapedSQLString(sb, filterParam + '%');\n if (!filterParam.contains(\"@\")) {\n sb.append(\n \" UNION SELECT \" + Data._ID +\n \" FROM \" + Tables.DATA +\n \" WHERE +\" + DataColumns.MIMETYPE_ID + \"=\");\n sb.append(mDbHelper.getMimeTypeIdForEmail());\n sb.append(\" AND \" + Data.RAW_CONTACT_ID + \" IN \" +\n \"(SELECT \" + RawContactsColumns.CONCRETE_ID +\n \" FROM \" + Tables.SEARCH_INDEX +\n \" JOIN \" + Tables.RAW_CONTACTS +\n \" ON (\" + Tables.SEARCH_INDEX + \".\" + SearchIndexColumns.CONTACT_ID\n + \"=\" + RawContactsColumns.CONCRETE_CONTACT_ID + \")\" +\n \" WHERE \" + SearchIndexColumns.NAME + \" MATCH \");\n DatabaseUtils.appendEscapedSQLString(sb, sanitizeMatch(filterParam) + \"*\");\n sb.append(\")\");\n }\n sb.append(\")\");\n qb.appendWhere(sb);\n }\n groupBy = Email.DATA + \",\" + RawContacts.CONTACT_ID;\n if (sortOrder == null) {\n final String accountPromotionSortOrder = getAccountPromotionSortOrder(uri);\n if (!TextUtils.isEmpty(accountPromotionSortOrder)) {\n sortOrder = accountPromotionSortOrder + \", \" + EMAIL_FILTER_SORT_ORDER;\n } else {\n sortOrder = EMAIL_FILTER_SORT_ORDER;\n }\n }\n break;\n }\n case POSTALS: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\"\n + StructuredPostal.CONTENT_ITEM_TYPE + \"'\");\n break;\n }\n case POSTALS_ID: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\"\n + StructuredPostal.CONTENT_ITEM_TYPE + \"'\");\n qb.appendWhere(\" AND \" + Data._ID + \"=?\");\n break;\n }\n case RAW_CONTACTS: {\n setTablesAndProjectionMapForRawContacts(qb, uri);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n break;\n }\n case RAW_CONTACTS_ID: {\n long rawContactId = ContentUris.parseId(uri);\n enforceProfilePermissionForRawContact(db, rawContactId, false);\n setTablesAndProjectionMapForRawContacts(qb, uri);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(\" AND \" + RawContacts._ID + \"=?\");\n break;\n }\n case RAW_CONTACTS_DATA: {\n long rawContactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(\" AND \" + Data.RAW_CONTACT_ID + \"=?\");\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n break;\n }\n case RAW_CONTACTS_ID_STREAM_ITEMS: {\n long rawContactId = Long.parseLong(uri.getPathSegments().get(1));\n enforceProfilePermissionForRawContact(db, rawContactId, false);\n setTablesAndProjectionMapForStreamItems(qb);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(StreamItems.RAW_CONTACT_ID + \"=?\");\n break;\n }\n case PROFILE_RAW_CONTACTS: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForRawContacts(qb, uri);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_RAW_CONTACTS_ID: {\n enforceProfilePermission(false);\n long rawContactId = ContentUris.parseId(uri);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n setTablesAndProjectionMapForRawContacts(qb, uri);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1 AND \"\n + RawContacts._ID + \"=?\");\n break;\n }\n case PROFILE_RAW_CONTACTS_ID_DATA: {\n enforceProfilePermission(false);\n long rawContactId = Long.parseLong(uri.getPathSegments().get(2));\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1 AND \"\n + Data.RAW_CONTACT_ID + \"=?\");\n break;\n }\n case PROFILE_RAW_CONTACTS_ID_ENTITIES: {\n enforceProfilePermission(false);\n long rawContactId = Long.parseLong(uri.getPathSegments().get(2));\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n setTablesAndProjectionMapForRawEntities(qb, uri);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1 AND \"\n + RawContacts._ID + \"=?\");\n break;\n }\n case DATA: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n break;\n }\n case DATA_ID: {\n long dataId = ContentUris.parseId(uri);\n enforceProfilePermissionForData(db, dataId, false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data._ID + \"=?\");\n break;\n }\n case PHONE_LOOKUP: {\n if (TextUtils.isEmpty(sortOrder)) {\n sortOrder = \" length(lookup.normalized_number) DESC\";\n }\n String number = uri.getPathSegments().size() > 1 ? uri.getLastPathSegment() : \"\";\n String numberE164 = PhoneNumberUtils.formatNumberToE164(number,\n mDbHelper.getCurrentCountryIso());\n String normalizedNumber =\n PhoneNumberUtils.normalizeNumber(number);\n mDbHelper.buildPhoneLookupAndContactQuery(qb, normalizedNumber, numberE164);\n qb.setProjectionMap(sPhoneLookupProjectionMap);\n selection = null;\n selectionArgs = null;\n break;\n }\n case GROUPS: {\n qb.setTables(Views.GROUPS);\n qb.setProjectionMap(sGroupsProjectionMap);\n appendAccountFromParameter(qb, uri, true);\n break;\n }\n case GROUPS_ID: {\n qb.setTables(Views.GROUPS);\n qb.setProjectionMap(sGroupsProjectionMap);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(Groups._ID + \"=?\");\n break;\n }\n case GROUPS_SUMMARY: {\n final boolean returnGroupCountPerAccount =\n readBooleanQueryParameter(uri, Groups.PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT,\n false);\n qb.setTables(Views.GROUPS + \" AS \" + Tables.GROUPS);\n qb.setProjectionMap(returnGroupCountPerAccount ?\n sGroupsSummaryProjectionMapWithGroupCountPerAccount\n : sGroupsSummaryProjectionMap);\n appendAccountFromParameter(qb, uri, true);\n groupBy = GroupsColumns.CONCRETE_ID;\n break;\n }\n case AGGREGATION_EXCEPTIONS: {\n qb.setTables(Tables.AGGREGATION_EXCEPTIONS);\n qb.setProjectionMap(sAggregationExceptionsProjectionMap);\n break;\n }\n case AGGREGATION_SUGGESTIONS: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n String filter = null;\n if (uri.getPathSegments().size() > 3) {\n filter = uri.getPathSegments().get(3);\n }\n final int maxSuggestions;\n if (limit != null) {\n maxSuggestions = Integer.parseInt(limit);\n } else {\n maxSuggestions = DEFAULT_MAX_SUGGESTIONS;\n }\n ArrayList parameters = null;\n List query = uri.getQueryParameters(\"query\");\n if (query != null && !query.isEmpty()) {\n parameters = new ArrayList(query.size());\n for (String parameter : query) {\n int offset = parameter.indexOf(':');\n parameters.add(offset == -1\n ? new AggregationSuggestionParameter(\n AggregationSuggestions.PARAMETER_MATCH_NAME,\n parameter)\n : new AggregationSuggestionParameter(\n parameter.substring(0, offset),\n parameter.substring(offset + 1)));\n }\n }\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n return mContactAggregator.queryAggregationSuggestions(qb, projection, contactId,\n maxSuggestions, filter, parameters);\n }\n case SETTINGS: {\n qb.setTables(Tables.SETTINGS);\n qb.setProjectionMap(sSettingsProjectionMap);\n appendAccountFromParameter(qb, uri, false);\n final String groupMembershipMimetypeId = Long.toString(mDbHelper\n .getMimeTypeId(GroupMembership.CONTENT_ITEM_TYPE));\n if (projection != null && projection.length != 0 &&\n mDbHelper.isInProjection(projection, Settings.UNGROUPED_COUNT)) {\n selectionArgs = insertSelectionArg(selectionArgs, groupMembershipMimetypeId);\n }\n if (projection != null && projection.length != 0 &&\n mDbHelper.isInProjection(projection, Settings.UNGROUPED_WITH_PHONES)) {\n selectionArgs = insertSelectionArg(selectionArgs, groupMembershipMimetypeId);\n }\n break;\n }\n case STATUS_UPDATES: {\n setTableAndProjectionMapForStatusUpdates(qb, projection);\n break;\n }\n case STATUS_UPDATES_ID: {\n setTableAndProjectionMapForStatusUpdates(qb, projection);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(DataColumns.CONCRETE_ID + \"=?\");\n break;\n }\n case SEARCH_SUGGESTIONS: {\n return mGlobalSearchSupport.handleSearchSuggestionsQuery(\n db, uri, projection, limit);\n }\n case SEARCH_SHORTCUT: {\n String lookupKey = uri.getLastPathSegment();\n String filter = getQueryParameter(\n uri, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);\n return mGlobalSearchSupport.handleSearchShortcutRefresh(\n db, projection, lookupKey, filter);\n }\n case LIVE_FOLDERS_CONTACTS:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n break;\n case LIVE_FOLDERS_CONTACTS_WITH_PHONES:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n qb.appendWhere(Contacts.HAS_PHONE_NUMBER + \"=1\");\n break;\n case LIVE_FOLDERS_CONTACTS_FAVORITES:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n qb.appendWhere(Contacts.STARRED + \"=1\");\n break;\n case LIVE_FOLDERS_CONTACTS_GROUP_NAME:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n qb.appendWhere(CONTACTS_IN_GROUP_SELECT);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n break;\n case RAW_CONTACT_ENTITIES: {\n setTablesAndProjectionMapForRawEntities(qb, uri);\n break;\n }\n case RAW_CONTACT_ENTITY_ID: {\n long rawContactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForRawEntities(qb, uri);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(\" AND \" + RawContacts._ID + \"=?\");\n break;\n }\n case PROVIDER_STATUS: {\n return queryProviderStatus(uri, projection);\n }\n case DIRECTORIES : {\n qb.setTables(Tables.DIRECTORIES);\n qb.setProjectionMap(sDirectoryProjectionMap);\n break;\n }\n case DIRECTORIES_ID : {\n long id = ContentUris.parseId(uri);\n qb.setTables(Tables.DIRECTORIES);\n qb.setProjectionMap(sDirectoryProjectionMap);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(id));\n qb.appendWhere(Directory._ID + \"=?\");\n break;\n }\n case COMPLETE_NAME: {\n return completeName(uri, projection);\n }\n default:\n return mLegacyApiSupport.query(uri, projection, selection, selectionArgs,\n sortOrder, limit);\n }\n qb.setStrict(true);\n if (profileRestrictionColumnName != null) {\n selection = appendProfileRestriction(uri, profileRestrictionColumnName,\n suppressProfileCheck, selection);\n }\n Cursor cursor =\n query(db, qb, projection, selection, selectionArgs, sortOrder, groupBy, limit);\n if (readBooleanQueryParameter(uri, ContactCounts.ADDRESS_BOOK_INDEX_EXTRAS, false)) {\n cursor = bundleLetterCountExtras(cursor, db, qb, selection, selectionArgs, sortOrder);\n }\n return cursor;\n }\n", "output": " private Cursor queryLocal(Uri uri, String[] projection, String selection,\n String[] selectionArgs, String sortOrder, long directoryId,\n final boolean suppressProfileCheck) {\n if (VERBOSE_LOGGING) {\n Log.v(TAG, \"query: \" + uri);\n }\n final SQLiteDatabase db = mDbHelper.getReadableDatabase();\n SQLiteQueryBuilder qb = new SQLiteQueryBuilder();\n String groupBy = null;\n String limit = getLimit(uri);\n String profileRestrictionColumnName = null;\n final int match = sUriMatcher.match(uri);\n switch (match) {\n case SYNCSTATE:\n return mDbHelper.getSyncState().query(db, projection, selection, selectionArgs,\n sortOrder);\n case CONTACTS: {\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n appendLocalDirectorySelectionIfNeeded(qb, directoryId);\n profileRestrictionColumnName = Contacts.IS_USER_PROFILE;\n sortOrder = prependProfileSortIfNeeded(uri, sortOrder, suppressProfileCheck);\n break;\n }\n case CONTACTS_ID: {\n long contactId = ContentUris.parseId(uri);\n enforceProfilePermissionForContact(db, contactId, false);\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(Contacts._ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP:\n case CONTACTS_LOOKUP_ID: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 3) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 4) {\n long contactId = Long.parseLong(pathSegments.get(3));\n enforceProfilePermissionForContact(db, contactId, false);\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForContacts(lookupQb, uri, projection);\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n Contacts._ID, contactId, Contacts.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(lookupContactIdByLookupKey(db, lookupKey)));\n qb.appendWhere(Contacts._ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP_DATA:\n case CONTACTS_LOOKUP_ID_DATA: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 4) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 5) {\n long contactId = Long.parseLong(pathSegments.get(3));\n enforceProfilePermissionForContact(db, contactId, false);\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForData(lookupQb, uri, projection, false);\n lookupQb.appendWhere(\" AND \");\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n Data.CONTACT_ID, contactId, Data.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n long contactId = lookupContactIdByLookupKey(db, lookupKey);\n enforceProfilePermissionForContact(db, contactId, false);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(contactId));\n qb.appendWhere(\" AND \" + Data.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_ID_STREAM_ITEMS: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n enforceProfilePermissionForContact(db, contactId, false);\n setTablesAndProjectionMapForStreamItems(qb);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(RawContactsColumns.CONCRETE_CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP_STREAM_ITEMS:\n case CONTACTS_LOOKUP_ID_STREAM_ITEMS: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 4) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 5) {\n long contactId = Long.parseLong(pathSegments.get(3));\n enforceProfilePermissionForContact(db, contactId, false);\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForStreamItems(lookupQb);\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n RawContacts.CONTACT_ID, contactId, Contacts.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForStreamItems(qb);\n long contactId = lookupContactIdByLookupKey(db, lookupKey);\n enforceProfilePermissionForContact(db, contactId, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(RawContacts.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_AS_VCARD: {\n final String lookupKey = Uri.encode(uri.getPathSegments().get(2));\n long contactId = lookupContactIdByLookupKey(db, lookupKey);\n enforceProfilePermissionForContact(db, contactId, false);\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sContactsVCardProjectionMap);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(contactId));\n qb.appendWhere(Contacts._ID + \"=?\");\n break;\n }\n case CONTACTS_AS_MULTI_VCARD: {\n SimpleDateFormat dateFormat = new SimpleDateFormat(\"yyyyMMdd_HHmmss\");\n String currentDateString = dateFormat.format(new Date()).toString();\n return db.rawQuery(\n \"SELECT\" +\n \" 'vcards_' || ? || '.vcf' AS \" + OpenableColumns.DISPLAY_NAME + \",\" +\n \" NULL AS \" + OpenableColumns.SIZE,\n new String[] { currentDateString });\n }\n case CONTACTS_FILTER: {\n String filterParam = \"\";\n if (uri.getPathSegments().size() > 2) {\n filterParam = uri.getLastPathSegment();\n }\n setTablesAndProjectionMapForContactsWithSnippet(\n qb, uri, projection, filterParam, directoryId);\n profileRestrictionColumnName = Contacts.IS_USER_PROFILE;\n sortOrder = prependProfileSortIfNeeded(uri, sortOrder, suppressProfileCheck);\n break;\n }\n case CONTACTS_STREQUENT_FILTER:\n case CONTACTS_STREQUENT: {\n final boolean phoneOnly = readBooleanQueryParameter(\n uri, ContactsContract.STREQUENT_PHONE_ONLY, false);\n if (match == CONTACTS_STREQUENT_FILTER && uri.getPathSegments().size() > 3) {\n String filterParam = uri.getLastPathSegment();\n StringBuilder sb = new StringBuilder();\n sb.append(Contacts._ID + \" IN \");\n appendContactFilterAsNestedQuery(sb, filterParam);\n selection = DbQueryUtils.concatenateClauses(selection, sb.toString());\n }\n String[] subProjection = null;\n if (projection != null) {\n subProjection = appendProjectionArg(projection, TIMES_USED_SORT_COLUMN);\n }\n setTablesAndProjectionMapForContacts(qb, uri, projection, false);\n qb.setProjectionMap(phoneOnly ?\n sStrequentPhoneOnlyStarredProjectionMap\n : sStrequentStarredProjectionMap);\n qb.appendWhere(DbQueryUtils.concatenateClauses(\n selection, Contacts.IS_USER_PROFILE + \"=0\"));\n if (phoneOnly) {\n qb.appendWhere(\" AND \" + Contacts.HAS_PHONE_NUMBER + \"=1\");\n }\n qb.setStrict(true);\n final String starredQuery = qb.buildQuery(subProjection,\n Contacts.STARRED + \"=1\", Contacts._ID, null, null, null);\n qb = new SQLiteQueryBuilder();\n qb.setStrict(true);\n final String frequentQuery;\n if (phoneOnly) {\n final StringBuilder tableBuilder = new StringBuilder();\n tableBuilder.append(Tables.DATA_USAGE_STAT\n + \" INNER JOIN \" + Views.DATA + \" \" + Tables.DATA\n + \" ON (\" + DataUsageStatColumns.CONCRETE_DATA_ID + \"=\"\n + DataColumns.CONCRETE_ID + \" AND \"\n + DataUsageStatColumns.CONCRETE_USAGE_TYPE + \"=\"\n + DataUsageStatColumns.USAGE_TYPE_INT_CALL + \")\");\n appendContactPresenceJoin(tableBuilder, projection, RawContacts.CONTACT_ID);\n appendContactStatusUpdateJoin(tableBuilder, projection,\n ContactsColumns.LAST_STATUS_UPDATE_ID);\n qb.setTables(tableBuilder.toString());\n qb.setProjectionMap(sStrequentPhoneOnlyFrequentProjectionMap);\n qb.appendWhere(DbQueryUtils.concatenateClauses(\n selection,\n Contacts.STARRED + \"=0 OR \" + Contacts.STARRED + \" IS NULL\",\n MimetypesColumns.MIMETYPE + \" IN (\"\n + \"'\" + Phone.CONTENT_ITEM_TYPE + \"', \"\n + \"'\" + SipAddress.CONTENT_ITEM_TYPE + \"')\"));\n frequentQuery = qb.buildQuery(subProjection, null, null, null, null, null);\n } else {\n setTablesAndProjectionMapForContacts(qb, uri, projection, true);\n qb.setProjectionMap(sStrequentFrequentProjectionMap);\n qb.appendWhere(DbQueryUtils.concatenateClauses(\n selection,\n \"(\" + Contacts.STARRED + \" =0 OR \" + Contacts.STARRED + \" IS NULL)\",\n Contacts.IS_USER_PROFILE + \"=0\"));\n frequentQuery = qb.buildQuery(subProjection,\n null, Contacts._ID, null, null, null);\n }\n final String unionQuery =\n qb.buildUnionQuery(new String[] {starredQuery, frequentQuery},\n STREQUENT_ORDER_BY, STREQUENT_LIMIT);\n String[] doubledSelectionArgs = null;\n if (selectionArgs != null) {\n final int length = selectionArgs.length;\n doubledSelectionArgs = new String[length * 2];\n System.arraycopy(selectionArgs, 0, doubledSelectionArgs, 0, length);\n System.arraycopy(selectionArgs, 0, doubledSelectionArgs, length, length);\n }\n Cursor cursor = db.rawQuery(unionQuery, doubledSelectionArgs);\n if (cursor != null) {\n cursor.setNotificationUri(getContext().getContentResolver(),\n ContactsContract.AUTHORITY_URI);\n }\n return cursor;\n }\n case CONTACTS_FREQUENT: {\n setTablesAndProjectionMapForContacts(qb, uri, projection, true);\n qb.setProjectionMap(sStrequentFrequentProjectionMap);\n qb.appendWhere(Contacts.IS_USER_PROFILE + \"=0\");\n groupBy = Contacts._ID;\n if (!TextUtils.isEmpty(sortOrder)) {\n sortOrder = FREQUENT_ORDER_BY + \", \" + sortOrder;\n } else {\n sortOrder = FREQUENT_ORDER_BY;\n }\n break;\n }\n case CONTACTS_GROUP: {\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n if (uri.getPathSegments().size() > 2) {\n qb.appendWhere(CONTACTS_IN_GROUP_SELECT);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n }\n break;\n }\n case PROFILE: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n qb.appendWhere(Contacts.IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_ENTITIES: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForEntities(qb, uri, projection);\n qb.appendWhere(\" AND \" + Contacts.IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_DATA: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_DATA_ID: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data._ID + \"=? AND \"\n + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_AS_VCARD: {\n enforceProfilePermission(false);\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sContactsVCardProjectionMap);\n qb.appendWhere(Contacts.IS_USER_PROFILE + \"=1\");\n break;\n }\n case CONTACTS_ID_DATA: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(\" AND \" + RawContacts.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_ID_PHOTO: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n enforceProfilePermissionForContact(db, contactId, false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(\" AND \" + RawContacts.CONTACT_ID + \"=?\");\n qb.appendWhere(\" AND \" + Data._ID + \"=\" + Contacts.PHOTO_ID);\n break;\n }\n case CONTACTS_ID_ENTITIES: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForEntities(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(contactId));\n qb.appendWhere(\" AND \" + RawContacts.CONTACT_ID + \"=?\");\n break;\n }\n case CONTACTS_LOOKUP_ENTITIES:\n case CONTACTS_LOOKUP_ID_ENTITIES: {\n List pathSegments = uri.getPathSegments();\n int segmentCount = pathSegments.size();\n if (segmentCount < 4) {\n throw new IllegalArgumentException(mDbHelper.exceptionMessage(\n \"Missing a lookup key\", uri));\n }\n String lookupKey = pathSegments.get(2);\n if (segmentCount == 5) {\n long contactId = Long.parseLong(pathSegments.get(3));\n SQLiteQueryBuilder lookupQb = new SQLiteQueryBuilder();\n setTablesAndProjectionMapForEntities(lookupQb, uri, projection);\n lookupQb.appendWhere(\" AND \");\n Cursor c = queryWithContactIdAndLookupKey(lookupQb, db, uri,\n projection, selection, selectionArgs, sortOrder, groupBy, limit,\n Contacts.Entity.CONTACT_ID, contactId,\n Contacts.Entity.LOOKUP_KEY, lookupKey);\n if (c != null) {\n return c;\n }\n }\n setTablesAndProjectionMapForEntities(qb, uri, projection);\n selectionArgs = insertSelectionArg(selectionArgs,\n String.valueOf(lookupContactIdByLookupKey(db, lookupKey)));\n qb.appendWhere(\" AND \" + Contacts.Entity.CONTACT_ID + \"=?\");\n break;\n }\n case STREAM_ITEMS: {\n setTablesAndProjectionMapForStreamItems(qb);\n break;\n }\n case STREAM_ITEMS_ID: {\n setTablesAndProjectionMapForStreamItems(qb);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(StreamItemsColumns.CONCRETE_ID + \"=?\");\n break;\n }\n case STREAM_ITEMS_LIMIT: {\n MatrixCursor cursor = new MatrixCursor(new String[]{StreamItems.MAX_ITEMS}, 1);\n cursor.addRow(new Object[]{MAX_STREAM_ITEMS_PER_RAW_CONTACT});\n return cursor;\n }\n case STREAM_ITEMS_PHOTOS: {\n setTablesAndProjectionMapForStreamItemPhotos(qb);\n break;\n }\n case STREAM_ITEMS_ID_PHOTOS: {\n setTablesAndProjectionMapForStreamItemPhotos(qb);\n String streamItemId = uri.getPathSegments().get(1);\n selectionArgs = insertSelectionArg(selectionArgs, streamItemId);\n qb.appendWhere(StreamItemPhotosColumns.CONCRETE_STREAM_ITEM_ID + \"=?\");\n break;\n }\n case STREAM_ITEMS_ID_PHOTOS_ID: {\n setTablesAndProjectionMapForStreamItemPhotos(qb);\n String streamItemId = uri.getPathSegments().get(1);\n String streamItemPhotoId = uri.getPathSegments().get(3);\n selectionArgs = insertSelectionArg(selectionArgs, streamItemPhotoId);\n selectionArgs = insertSelectionArg(selectionArgs, streamItemId);\n qb.appendWhere(StreamItemPhotosColumns.CONCRETE_STREAM_ITEM_ID + \"=? AND \" +\n StreamItemPhotosColumns.CONCRETE_ID + \"=?\");\n break;\n }\n case PHOTO_DIMENSIONS: {\n MatrixCursor cursor = new MatrixCursor(\n new String[]{DisplayPhoto.DISPLAY_MAX_DIM, DisplayPhoto.THUMBNAIL_MAX_DIM},\n 1);\n cursor.addRow(new Object[]{mMaxDisplayPhotoDim, mMaxThumbnailPhotoDim});\n return cursor;\n }\n case PHONES: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Phone.CONTENT_ITEM_TYPE + \"'\");\n break;\n }\n case PHONES_ID: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Phone.CONTENT_ITEM_TYPE + \"'\");\n qb.appendWhere(\" AND \" + Data._ID + \"=?\");\n break;\n }\n case PHONES_FILTER: {\n String typeParam = uri.getQueryParameter(DataUsageFeedback.USAGE_TYPE);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n Integer typeInt = sDataUsageTypeMap.get(typeParam);\n if (typeInt == null) {\n typeInt = DataUsageStatColumns.USAGE_TYPE_INT_CALL;\n }\n setTablesAndProjectionMapForData(qb, uri, projection, true, typeInt);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Phone.CONTENT_ITEM_TYPE + \"'\");\n if (uri.getPathSegments().size() > 2) {\n String filterParam = uri.getLastPathSegment();\n StringBuilder sb = new StringBuilder();\n sb.append(\" AND (\");\n boolean hasCondition = false;\n boolean orNeeded = false;\n String normalizedName = NameNormalizer.normalize(filterParam);\n if (normalizedName.length() > 0) {\n sb.append(Data.RAW_CONTACT_ID + \" IN \" +\n \"(SELECT \" + RawContactsColumns.CONCRETE_ID +\n \" FROM \" + Tables.SEARCH_INDEX +\n \" JOIN \" + Tables.RAW_CONTACTS +\n \" ON (\" + Tables.SEARCH_INDEX + \".\" + SearchIndexColumns.CONTACT_ID\n + \"=\" + RawContactsColumns.CONCRETE_CONTACT_ID + \")\" +\n \" WHERE \" + SearchIndexColumns.NAME + \" MATCH \");\n DatabaseUtils.appendEscapedSQLString(sb, sanitizeMatch(filterParam) + \"*\");\n sb.append(\")\");\n orNeeded = true;\n hasCondition = true;\n }\n String number = PhoneNumberUtils.normalizeNumber(filterParam);\n if (!TextUtils.isEmpty(number)) {\n if (orNeeded) {\n sb.append(\" OR \");\n }\n sb.append(Data._ID +\n \" IN (SELECT DISTINCT \" + PhoneLookupColumns.DATA_ID\n + \" FROM \" + Tables.PHONE_LOOKUP\n + \" WHERE \" + PhoneLookupColumns.NORMALIZED_NUMBER + \" LIKE '\");\n sb.append(number);\n sb.append(\"%')\");\n hasCondition = true;\n }\n if (!hasCondition) {\n sb.append(\"0\");\n }\n sb.append(\")\");\n qb.appendWhere(sb);\n }\n groupBy = PhoneColumns.NORMALIZED_NUMBER + \",\" + RawContacts.CONTACT_ID;\n if (sortOrder == null) {\n final String accountPromotionSortOrder = getAccountPromotionSortOrder(uri);\n if (!TextUtils.isEmpty(accountPromotionSortOrder)) {\n sortOrder = accountPromotionSortOrder + \", \" + PHONE_FILTER_SORT_ORDER;\n } else {\n sortOrder = PHONE_FILTER_SORT_ORDER;\n }\n }\n break;\n }\n case EMAILS: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Email.CONTENT_ITEM_TYPE + \"'\");\n break;\n }\n case EMAILS_ID: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Email.CONTENT_ITEM_TYPE + \"'\"\n + \" AND \" + Data._ID + \"=?\");\n break;\n }\n case EMAILS_LOOKUP: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\" + Email.CONTENT_ITEM_TYPE + \"'\");\n if (uri.getPathSegments().size() > 2) {\n String email = uri.getLastPathSegment();\n String address = mDbHelper.extractAddressFromEmailAddress(email);\n selectionArgs = insertSelectionArg(selectionArgs, address);\n qb.appendWhere(\" AND UPPER(\" + Email.DATA + \")=UPPER(?)\");\n }\n break;\n }\n case EMAILS_FILTER: {\n String typeParam = uri.getQueryParameter(DataUsageFeedback.USAGE_TYPE);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n Integer typeInt = sDataUsageTypeMap.get(typeParam);\n if (typeInt == null) {\n typeInt = DataUsageStatColumns.USAGE_TYPE_INT_LONG_TEXT;\n }\n setTablesAndProjectionMapForData(qb, uri, projection, true, typeInt);\n String filterParam = null;\n if (uri.getPathSegments().size() > 3) {\n filterParam = uri.getLastPathSegment();\n if (TextUtils.isEmpty(filterParam)) {\n filterParam = null;\n }\n }\n if (filterParam == null) {\n qb.appendWhere(\" AND 0\");\n } else {\n StringBuilder sb = new StringBuilder();\n sb.append(\" AND \" + Data._ID + \" IN (\");\n sb.append(\n \"SELECT \" + Data._ID +\n \" FROM \" + Tables.DATA +\n \" WHERE \" + DataColumns.MIMETYPE_ID + \"=\");\n sb.append(mDbHelper.getMimeTypeIdForEmail());\n sb.append(\" AND \" + Data.DATA1 + \" LIKE \");\n DatabaseUtils.appendEscapedSQLString(sb, filterParam + '%');\n if (!filterParam.contains(\"@\")) {\n sb.append(\n \" UNION SELECT \" + Data._ID +\n \" FROM \" + Tables.DATA +\n \" WHERE +\" + DataColumns.MIMETYPE_ID + \"=\");\n sb.append(mDbHelper.getMimeTypeIdForEmail());\n sb.append(\" AND \" + Data.RAW_CONTACT_ID + \" IN \" +\n \"(SELECT \" + RawContactsColumns.CONCRETE_ID +\n \" FROM \" + Tables.SEARCH_INDEX +\n \" JOIN \" + Tables.RAW_CONTACTS +\n \" ON (\" + Tables.SEARCH_INDEX + \".\" + SearchIndexColumns.CONTACT_ID\n + \"=\" + RawContactsColumns.CONCRETE_CONTACT_ID + \")\" +\n \" WHERE \" + SearchIndexColumns.NAME + \" MATCH \");\n DatabaseUtils.appendEscapedSQLString(sb, sanitizeMatch(filterParam) + \"*\");\n sb.append(\")\");\n }\n sb.append(\")\");\n qb.appendWhere(sb);\n }\n groupBy = Email.DATA + \",\" + RawContacts.CONTACT_ID;\n if (sortOrder == null) {\n final String accountPromotionSortOrder = getAccountPromotionSortOrder(uri);\n if (!TextUtils.isEmpty(accountPromotionSortOrder)) {\n sortOrder = accountPromotionSortOrder + \", \" + EMAIL_FILTER_SORT_ORDER;\n } else {\n sortOrder = EMAIL_FILTER_SORT_ORDER;\n }\n }\n break;\n }\n case POSTALS: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\"\n + StructuredPostal.CONTENT_ITEM_TYPE + \"'\");\n break;\n }\n case POSTALS_ID: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data.MIMETYPE + \" = '\"\n + StructuredPostal.CONTENT_ITEM_TYPE + \"'\");\n qb.appendWhere(\" AND \" + Data._ID + \"=?\");\n break;\n }\n case RAW_CONTACTS: {\n setTablesAndProjectionMapForRawContacts(qb, uri);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n break;\n }\n case RAW_CONTACTS_ID: {\n long rawContactId = ContentUris.parseId(uri);\n enforceProfilePermissionForRawContact(db, rawContactId, false);\n setTablesAndProjectionMapForRawContacts(qb, uri);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(\" AND \" + RawContacts._ID + \"=?\");\n break;\n }\n case RAW_CONTACTS_DATA: {\n long rawContactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(\" AND \" + Data.RAW_CONTACT_ID + \"=?\");\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n break;\n }\n case RAW_CONTACTS_ID_STREAM_ITEMS: {\n long rawContactId = Long.parseLong(uri.getPathSegments().get(1));\n enforceProfilePermissionForRawContact(db, rawContactId, false);\n setTablesAndProjectionMapForStreamItems(qb);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(StreamItems.RAW_CONTACT_ID + \"=?\");\n break;\n }\n case PROFILE_RAW_CONTACTS: {\n enforceProfilePermission(false);\n setTablesAndProjectionMapForRawContacts(qb, uri);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1\");\n break;\n }\n case PROFILE_RAW_CONTACTS_ID: {\n enforceProfilePermission(false);\n long rawContactId = ContentUris.parseId(uri);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n setTablesAndProjectionMapForRawContacts(qb, uri);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1 AND \"\n + RawContacts._ID + \"=?\");\n break;\n }\n case PROFILE_RAW_CONTACTS_ID_DATA: {\n enforceProfilePermission(false);\n long rawContactId = Long.parseLong(uri.getPathSegments().get(2));\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1 AND \"\n + Data.RAW_CONTACT_ID + \"=?\");\n break;\n }\n case PROFILE_RAW_CONTACTS_ID_ENTITIES: {\n enforceProfilePermission(false);\n long rawContactId = Long.parseLong(uri.getPathSegments().get(2));\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n setTablesAndProjectionMapForRawEntities(qb, uri);\n qb.appendWhere(\" AND \" + RawContacts.RAW_CONTACT_IS_USER_PROFILE + \"=1 AND \"\n + RawContacts._ID + \"=?\");\n break;\n }\n case DATA: {\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n profileRestrictionColumnName = RawContacts.RAW_CONTACT_IS_USER_PROFILE;\n break;\n }\n case DATA_ID: {\n long dataId = ContentUris.parseId(uri);\n enforceProfilePermissionForData(db, dataId, false);\n setTablesAndProjectionMapForData(qb, uri, projection, false);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(\" AND \" + Data._ID + \"=?\");\n break;\n }\n case PHONE_LOOKUP: {\n if (TextUtils.isEmpty(sortOrder)) {\n sortOrder = \" length(lookup.normalized_number) DESC\";\n }\n String number = uri.getPathSegments().size() > 1 ? uri.getLastPathSegment() : \"\";\n String numberE164 = PhoneNumberUtils.formatNumberToE164(number,\n mDbHelper.getCurrentCountryIso());\n String normalizedNumber =\n PhoneNumberUtils.normalizeNumber(number);\n profileRestrictionColumnName = Contacts.IS_USER_PROFILE;\n mDbHelper.buildPhoneLookupAndContactQuery(qb, normalizedNumber, numberE164);\n qb.setProjectionMap(sPhoneLookupProjectionMap);\n selection = null;\n selectionArgs = null;\n break;\n }\n case GROUPS: {\n qb.setTables(Views.GROUPS);\n qb.setProjectionMap(sGroupsProjectionMap);\n appendAccountFromParameter(qb, uri, true);\n break;\n }\n case GROUPS_ID: {\n qb.setTables(Views.GROUPS);\n qb.setProjectionMap(sGroupsProjectionMap);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(Groups._ID + \"=?\");\n break;\n }\n case GROUPS_SUMMARY: {\n final boolean returnGroupCountPerAccount =\n readBooleanQueryParameter(uri, Groups.PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT,\n false);\n qb.setTables(Views.GROUPS + \" AS \" + Tables.GROUPS);\n qb.setProjectionMap(returnGroupCountPerAccount ?\n sGroupsSummaryProjectionMapWithGroupCountPerAccount\n : sGroupsSummaryProjectionMap);\n appendAccountFromParameter(qb, uri, true);\n groupBy = GroupsColumns.CONCRETE_ID;\n break;\n }\n case AGGREGATION_EXCEPTIONS: {\n qb.setTables(Tables.AGGREGATION_EXCEPTIONS);\n qb.setProjectionMap(sAggregationExceptionsProjectionMap);\n break;\n }\n case AGGREGATION_SUGGESTIONS: {\n long contactId = Long.parseLong(uri.getPathSegments().get(1));\n String filter = null;\n if (uri.getPathSegments().size() > 3) {\n filter = uri.getPathSegments().get(3);\n }\n final int maxSuggestions;\n if (limit != null) {\n maxSuggestions = Integer.parseInt(limit);\n } else {\n maxSuggestions = DEFAULT_MAX_SUGGESTIONS;\n }\n ArrayList parameters = null;\n List query = uri.getQueryParameters(\"query\");\n if (query != null && !query.isEmpty()) {\n parameters = new ArrayList(query.size());\n for (String parameter : query) {\n int offset = parameter.indexOf(':');\n parameters.add(offset == -1\n ? new AggregationSuggestionParameter(\n AggregationSuggestions.PARAMETER_MATCH_NAME,\n parameter)\n : new AggregationSuggestionParameter(\n parameter.substring(0, offset),\n parameter.substring(offset + 1)));\n }\n }\n setTablesAndProjectionMapForContacts(qb, uri, projection);\n return mContactAggregator.queryAggregationSuggestions(qb, projection, contactId,\n maxSuggestions, filter, parameters);\n }\n case SETTINGS: {\n qb.setTables(Tables.SETTINGS);\n qb.setProjectionMap(sSettingsProjectionMap);\n appendAccountFromParameter(qb, uri, false);\n final String groupMembershipMimetypeId = Long.toString(mDbHelper\n .getMimeTypeId(GroupMembership.CONTENT_ITEM_TYPE));\n if (projection != null && projection.length != 0 &&\n mDbHelper.isInProjection(projection, Settings.UNGROUPED_COUNT)) {\n selectionArgs = insertSelectionArg(selectionArgs, groupMembershipMimetypeId);\n }\n if (projection != null && projection.length != 0 &&\n mDbHelper.isInProjection(projection, Settings.UNGROUPED_WITH_PHONES)) {\n selectionArgs = insertSelectionArg(selectionArgs, groupMembershipMimetypeId);\n }\n break;\n }\n case STATUS_UPDATES: {\n setTableAndProjectionMapForStatusUpdates(qb, projection);\n break;\n }\n case STATUS_UPDATES_ID: {\n setTableAndProjectionMapForStatusUpdates(qb, projection);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n qb.appendWhere(DataColumns.CONCRETE_ID + \"=?\");\n break;\n }\n case SEARCH_SUGGESTIONS: {\n return mGlobalSearchSupport.handleSearchSuggestionsQuery(\n db, uri, projection, limit);\n }\n case SEARCH_SHORTCUT: {\n String lookupKey = uri.getLastPathSegment();\n String filter = getQueryParameter(\n uri, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);\n return mGlobalSearchSupport.handleSearchShortcutRefresh(\n db, projection, lookupKey, filter);\n }\n case LIVE_FOLDERS_CONTACTS:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n break;\n case LIVE_FOLDERS_CONTACTS_WITH_PHONES:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n qb.appendWhere(Contacts.HAS_PHONE_NUMBER + \"=1\");\n break;\n case LIVE_FOLDERS_CONTACTS_FAVORITES:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n qb.appendWhere(Contacts.STARRED + \"=1\");\n break;\n case LIVE_FOLDERS_CONTACTS_GROUP_NAME:\n qb.setTables(Views.CONTACTS);\n qb.setProjectionMap(sLiveFoldersProjectionMap);\n qb.appendWhere(CONTACTS_IN_GROUP_SELECT);\n selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());\n break;\n case RAW_CONTACT_ENTITIES: {\n setTablesAndProjectionMapForRawEntities(qb, uri);\n break;\n }\n case RAW_CONTACT_ENTITY_ID: {\n long rawContactId = Long.parseLong(uri.getPathSegments().get(1));\n setTablesAndProjectionMapForRawEntities(qb, uri);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(rawContactId));\n qb.appendWhere(\" AND \" + RawContacts._ID + \"=?\");\n break;\n }\n case PROVIDER_STATUS: {\n return queryProviderStatus(uri, projection);\n }\n case DIRECTORIES : {\n qb.setTables(Tables.DIRECTORIES);\n qb.setProjectionMap(sDirectoryProjectionMap);\n break;\n }\n case DIRECTORIES_ID : {\n long id = ContentUris.parseId(uri);\n qb.setTables(Tables.DIRECTORIES);\n qb.setProjectionMap(sDirectoryProjectionMap);\n selectionArgs = insertSelectionArg(selectionArgs, String.valueOf(id));\n qb.appendWhere(Directory._ID + \"=?\");\n break;\n }\n case COMPLETE_NAME: {\n return completeName(uri, projection);\n }\n default:\n return mLegacyApiSupport.query(uri, projection, selection, selectionArgs,\n sortOrder, limit);\n }\n qb.setStrict(true);\n if (profileRestrictionColumnName != null) {\n selection = appendProfileRestriction(uri, profileRestrictionColumnName,\n suppressProfileCheck, selection);\n }\n Cursor cursor =\n query(db, qb, projection, selection, selectionArgs, sortOrder, groupBy, limit);\n if (readBooleanQueryParameter(uri, ContactCounts.ADDRESS_BOOK_INDEX_EXTRAS, false)) {\n cursor = bundleLetterCountExtras(cursor, db, qb, selection, selectionArgs, sortOrder);\n }\n return cursor;\n }\n"} {"input": "\tpublic void openSource(ISource source, IDataSet dataSet) throws ETLException {\n\t\tthis.dataSet = dataSet;\n\t\tif (!(source instanceof FileSource)) {\n\t\t\tthrow new ETLException(\"Can not handle a source of this type - FileSource type required.\");\n\t\t}\n\t\tFileSource fsrc = (FileSource)source;\n\t\ttry {\n\t\t\trecordNumber = 0;\n\t\t\treachedEnd = false;\n\t\t\tInputStream in = new FileInputStream(fsrc.getFile());\n\t\t\tif (fsrc.getEncoding() == null) {\n\t\t\t\tString encoding = null; \n\t\t\t\tbyte[] encoding_tag = new byte[2];\n\t\t\t\tif (in.read(encoding_tag, 0, 2) == 2 && encoding_tag[0] == -1 && encoding_tag[1] == -2) {\n\t\t\t\t\tencoding = \"UTF-16LE\";\n\t\t\t\t} else {\n\t\t\t\t\tin.reset();\n\t\t\t\t}\n\t\t\t\tfsrc.setEncoding(encoding);\n\t\t\t}\n\t\t\treader = new CSVReader(new BufferedReader(StreamDecoder.forInputStreamReader(in, fsrc.getFile(), fsrc.getEncoding())), separator, quoteChar, skipLines);\n\t\t\tif (containsHeader) {\n\t\t\t\tString[] header = reader.readNext();\n\t\t\t\tif (header == null) {\n\t\t\t\t\treachedEnd = true;\n\t\t\t\t} else {\n\t\t\t\t\texpectedColumns = header.length;\n\t\t\t\t\tint idx = 0;\n\t\t\t\t\tfor (String colName : header) {\n\t\t\t\t\t\tdataSet.addColumn(colName, idx++);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (FileNotFoundException e) {\n\t\t\tthrow new ETLException(\"Source file not found (\" + source.getName() + \") : \" + e, e);\n\t\t} catch (IOException e) {\n\t\t\tthrow new ETLException(\"Error reading file (\" + source.getName() + \") : \" + e, e);\n\t\t}\n\t}\n", "output": "\tpublic void openSource(ISource source, IDataSet dataSet) throws ETLException {\n\t\tthis.dataSet = dataSet;\n\t\tif (!(source instanceof FileSource)) {\n\t\t\tthrow new ETLException(\"Can not handle a source of this type - FileSource type required.\");\n\t\t}\n\t\tFileSource fsrc = (FileSource)source;\n\t\ttry {\n\t\t\trecordNumber = 0;\n\t\t\treachedEnd = false;\n\t\t\tInputStream in = new FileInputStream(fsrc.getFile());\n\t\t\tif (fsrc.getEncoding() == null) {\n\t\t\t\tString encoding = null; \n\t\t\t\tbyte[] encoding_tag = new byte[2];\n\t\t\t\tif (in.read(encoding_tag, 0, 2) == 2 && encoding_tag[0] == -1 && encoding_tag[1] == -2) {\n\t\t\t\t\tencoding = \"UTF-16LE\";\n\t\t\t\t} else {\n\t\t\t\t\tin.close();\n\t\t\t\t\tin = new FileInputStream(fsrc.getFile());\n\t\t\t\t}\n\t\t\t\tfsrc.setEncoding(encoding);\n\t\t\t}\n\t\t\treader = new CSVReader(new BufferedReader(StreamDecoder.forInputStreamReader(in, fsrc.getFile(), fsrc.getEncoding())), separator, quoteChar, skipLines);\n\t\t\tif (containsHeader) {\n\t\t\t\tString[] header = reader.readNext();\n\t\t\t\tif (header == null) {\n\t\t\t\t\treachedEnd = true;\n\t\t\t\t} else {\n\t\t\t\t\texpectedColumns = header.length;\n\t\t\t\t\tint idx = 0;\n\t\t\t\t\tfor (String colName : header) {\n\t\t\t\t\t\tdataSet.addColumn(colName, idx++);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (FileNotFoundException e) {\n\t\t\tthrow new ETLException(\"Source file not found (\" + source.getName() + \") : \" + e, e);\n\t\t} catch (IOException e) {\n\t\t\tthrow new ETLException(\"Error reading file (\" + source.getName() + \") : \" + e, e);\n\t\t}\n\t}\n"} {"input": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.roster);\n ImageView myImage = (ImageView) findViewById(R.id.Roster_myimage);\n attachIcon(myImage);\n TextView textView = (TextView) findViewById(R.id.Roster_myjid);\n textView.setText(JID.jid);\n TextView textView2 = (TextView) findViewById(R.id.Roster_mystatus);\n textView2.setText(MyProfile.getInstance().getStatus());\n Spinner spinner = (Spinner) findViewById(R.id.roster_availability_spinner);\n spinner.setOnItemSelectedListener(new RosterAvailSpinnerHandler(this));\n Button button = (Button) findViewById(R.id.roster_availability_launch_spinner_button);\n button.setBackgroundColor(Color.GREEN);\n Log.d(\"XXXX\", \"oncreate roster : \" + MyProfile.getInstance().getStatus());\n ListView rosterList = (ListView) findViewById(R.id.rosterlist);\n requestForRosters();\n sendInitialPresence();\n adapter = new RosterItemAdapter(context);\n rosterList.setAdapter(adapter);\n rosterList.setTextFilterEnabled(true);\n }\n", "output": " public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.roster);\n ImageView myImage = (ImageView) findViewById(R.id.Roster_myimage);\n attachIcon(myImage);\n TextView textView = (TextView) findViewById(R.id.Roster_myjid);\n textView.setText(JID.jid);\n TextView textView2 = (TextView) findViewById(R.id.Roster_mystatus);\n textView2.setText(MyProfile.getInstance().getStatus());\n Spinner spinner = (Spinner) findViewById(R.id.roster_availability_spinner);\n spinner.setOnItemSelectedListener(new RosterAvailSpinnerHandler(this));\n Button button = (Button) findViewById(R.id.roster_availability_launch_spinner_button);\n button.setBackgroundColor(Color.GREEN);\n Log.d(\"XXXX\", \"oncreate roster : \" + MyProfile.getInstance().getStatus());\n ListView rosterList = (ListView) findViewById(R.id.rosterlist);\n rosterList.setOnItemClickListener(new rosterListClickHandler(rosterList,this));\n requestForRosters();\n sendInitialPresence();\n adapter = new RosterItemAdapter(context);\n rosterList.setAdapter(adapter);\n rosterList.setTextFilterEnabled(true);\n }\n"} {"input": "\tprivate void setupStoryTitleAndSlideoutMenuState() {\n\t\tint titleResId = -1;\n\t\tint menuItemResId = -1;\n\t\tswitch (mPage) {\n\t\tcase FRONT:\n\t\t\ttitleResId = R.string.front_page;\n\t\t\tmenuItemResId = R.id.front_page_button;\n\t\t\tbreak;\n\t\tcase ASK:\n\t\t\ttitleResId = R.string.ask;\n\t\t\tmenuItemResId = R.id.ask_button;\n\t\t\tbreak;\n\t\tcase BEST:\n\t\t\ttitleResId = R.string.best;\n\t\t\tmenuItemResId = R.id.best_button;\n\t\t\tbreak;\n\t\tcase NEW:\n\t\t\ttitleResId = R.string.new_page;\n\t\t\tmenuItemResId = R.id.new_button;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tActionBarController controller = getActionBarView().getController();\n\t\tcontroller.setTitleText(getString(titleResId));\n\t\tsetActiveMenuItem(menuItemResId);\n\t}\n", "output": "\tprivate void setupStoryTitleAndSlideoutMenuState() {\n\t\tint titleResId = -1;\n\t\tint menuItemResId = -1;\n\t\tswitch (mPage) {\n\t\tcase FRONT:\n\t\t\ttitleResId = R.string.front_page;\n\t\t\tmenuItemResId = R.id.front_page_button;\n\t\t\tbreak;\n\t\tcase ASK:\n\t\t\ttitleResId = R.string.ask;\n\t\t\tmenuItemResId = R.id.ask_button;\n\t\t\tbreak;\n\t\tcase BEST:\n\t\t\ttitleResId = R.string.best;\n\t\t\tmenuItemResId = R.id.best_button;\n\t\t\tbreak;\n\t\tcase ACTIVE:\n\t\t\ttitleResId = R.string.active;\n\t\t\tmenuItemResId = R.id.active_button;\n\t\t\tbreak;\n\t\tcase NEW:\n\t\t\ttitleResId = R.string.new_page;\n\t\t\tmenuItemResId = R.id.new_button;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tActionBarController controller = getActionBarView().getController();\n\t\tcontroller.setTitleText(getString(titleResId));\n\t\tsetActiveMenuItem(menuItemResId);\n\t}\n"} {"input": " public FileSystemProvider(CollectorConfig collectorConfig) throws IOException\n {\n String hfsHost = collectorConfig.getHfsHost();\n Configuration hadoopConfig = new Configuration();\n if (hfsHost.isEmpty()) {\n hadoopConfig.set(\"fs.default.name\", \"file:///\");\n }\n else {\n hadoopConfig.set(\"fs.default.name\", hfsHost);\n }\n hadoopConfig.setLong(\"dfs.block.size\", collectorConfig.getHadoopBlockSize());\n hadoopConfig.set(\"serialization.job.ugi\", collectorConfig.getHadoopUgi());\n hadoopConfig.setStrings(\"io.serializations\", HadoopThriftWritableSerialization.class.getName(), HadoopThriftEnvelopeSerialization.class.getName(), \"org.apache.hadoop.io.serializer.WritableSerialization\");\n fileSystem = FileSystem.get(hadoopConfig);\n }\n", "output": " public FileSystemProvider(CollectorConfig collectorConfig) throws IOException\n {\n String hfsHost = collectorConfig.getHfsHost();\n Configuration hadoopConfig = new Configuration();\n if (hfsHost.isEmpty()) {\n hadoopConfig.set(\"fs.default.name\", \"file:///\");\n }\n else {\n hadoopConfig.set(\"fs.default.name\", hfsHost);\n }\n hadoopConfig.setLong(\"dfs.block.size\", collectorConfig.getHadoopBlockSize());\n hadoopConfig.set(\"hadoop.job.ugi\", collectorConfig.getHadoopUgi());\n hadoopConfig.setStrings(\"io.serializations\", HadoopThriftWritableSerialization.class.getName(), HadoopThriftEnvelopeSerialization.class.getName(), \"org.apache.hadoop.io.serializer.WritableSerialization\");\n fileSystem = FileSystem.get(hadoopConfig);\n }\n"} {"input": "\tpublic ObjectStatus reqObjectStatus(int objectType, int startObject, int endObject, boolean extended) throws IOException, OmniNotConnectedException, OmniInvalidResponseException, OmniUnknownMessageTypeException {\n\t\tStatus []s = null;\n\t\tswitch (objectType) {\n\t\tcase Message.OBJ_TYPE_AREA:{\n\t\t\ts = new AreaStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_AUDIO_ZONE:{\n\t\t\ts = new AudioZoneStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_AUX_SENSOR:{\n\t\t\ts = new AuxSensorStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_EXP:{\n\t\t\ts = new ExpansionStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_MESG:{\n\t\t\ts = new MessageStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_THERMO:{\n\t\t\tif(extended)\n\t\t\t\ts = new ExtendedThermostatStatus[endObject - startObject + 1];\n\t\t\telse\n\t\t\t\ts = new ThermostatStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_UNIT: {\n\t\t\ts = new UnitStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_ZONE: {\n\t\t\ts = new ZoneStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_USER_SETTING: {\n\t\t\ts = new UserSettingStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_CONTROL_READER: {\n\t\t\ts = new AccessControlReaderStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_CONTROL_LOCK: {\n\t\t\ts = new AccessControlReaderLockStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tint current = startObject;\n\t\tint next = 0;\n\t\twhile(current < endObject){\n\t\t\tnext += 25;\n\t\t\tif(next > endObject)\n\t\t\t\tnext = endObject;\n\t\t\tMessage msg = null;\n\t\t\tif(extended)\n\t\t\t\tmsg = sendAndReceive(new ReqObjectStatus(objectType,current,next));\n\t\t\telse\n\t\t\t\tmsg = sendAndReceive(new ReqExtenedObjectStatus(objectType,current,next));\n\t\t\tint curMsgType = msg.getMessageType();\n\t\t\tswitch (curMsgType) {\n\t\t\tcase Message.MESG_TYPE_OBJ_STATUS: \n\t\t\tcase Message.MESG_TYPE_EXT_OBJ_STATUS: {\n\t\t\t\tSystem.arraycopy(((ObjectStatus)msg).getStatuses(), 0, s, current -1, next - current + 1 );\n\t\t\t}\n\t\t\tbreak;\n\t\t\tcase Message.MESG_TYPE_NEG_ACK:\n\t\t\t\tthrow new OmniInvalidResponseException(msg);\n\t\t\tdefault:\n\t\t\t\tthrow new OmniInvalidResponseException(msg);\n\t\t\t}\n\t\t\tcurrent = next;\n\t\t}\n\t\treturn new ObjectStatus(objectType,s);\n\t}\n", "output": "\tpublic ObjectStatus reqObjectStatus(int objectType, int startObject, int endObject, boolean extended) throws IOException, OmniNotConnectedException, OmniInvalidResponseException, OmniUnknownMessageTypeException {\n\t\tStatus []s = null;\n\t\tswitch (objectType) {\n\t\tcase Message.OBJ_TYPE_AREA:{\n\t\t\ts = new AreaStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_AUDIO_ZONE:{\n\t\t\ts = new AudioZoneStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_AUX_SENSOR:{\n\t\t\ts = new AuxSensorStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_EXP:{\n\t\t\ts = new ExpansionStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_MESG:{\n\t\t\ts = new MessageStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_THERMO:{\n\t\t\tif(extended)\n\t\t\t\ts = new ExtendedThermostatStatus[endObject - startObject + 1];\n\t\t\telse\n\t\t\t\ts = new ThermostatStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_UNIT: {\n\t\t\ts = new UnitStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_ZONE: {\n\t\t\ts = new ZoneStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_USER_SETTING: {\n\t\t\ts = new UserSettingStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_CONTROL_READER: {\n\t\t\ts = new AccessControlReaderStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tcase Message.OBJ_TYPE_CONTROL_LOCK: {\n\t\t\ts = new AccessControlReaderLockStatus[endObject - startObject + 1];\n\t\t}\n\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t\t}\n\t\tint current = startObject;\n\t\twhile(current <= endObject){\n\t\t\tint last = current + 24; \n\t\t\tif(last > endObject)\n\t\t\t\tlast = endObject;\n\t\t\tMessage msg = null;\n\t\t\tif(extended)\n\t\t\t\tmsg = sendAndReceive(new ReqObjectStatus(objectType,current,last));\n\t\t\telse\n\t\t\t\tmsg = sendAndReceive(new ReqExtenedObjectStatus(objectType,current,last));\n\t\t\tint curMsgType = msg.getMessageType();\n\t\t\tswitch (curMsgType) {\n\t\t\tcase Message.MESG_TYPE_OBJ_STATUS: \n\t\t\tcase Message.MESG_TYPE_EXT_OBJ_STATUS: {\n\t\t\t\tSystem.arraycopy(((ObjectStatus)msg).getStatuses(), 0, s, current -startObject, last - current + 1 );\n\t\t\t}\n\t\t\tbreak;\n\t\t\tcase Message.MESG_TYPE_NEG_ACK:\n\t\t\t\tthrow new OmniInvalidResponseException(msg);\n\t\t\tdefault:\n\t\t\t\tthrow new OmniInvalidResponseException(msg);\n\t\t\t}\n\t\t\tcurrent = last+1;\n\t\t}\n\t\treturn new ObjectStatus(objectType,s);\n\t}\n"} {"input": "\tpublic void run(String arg0) \n\t{\n\t\tint nbima = WindowManager.getImageCount();\n\t\tif( nbima == 0 )\n\t\t{\n\t\t\tIJ.error( \"Watershed 3D\", \n\t\t\t\t\t\"At least one image needs to be open to run waterhsed in 3D\");\n\t\t\treturn;\n\t\t}\n String[] names = new String[ nbima ];\n String[] namesMask = new String[ nbima + 1 ];\n namesMask[ 0 ] = \"None\";\n for (int i = 0; i < nbima; i++) \n {\n names[ i ] = WindowManager.getImage(i + 1).getShortTitle();\n namesMask[ i + 1 ] = WindowManager.getImage(i + 1).getShortTitle();\n }\n GenericDialog gd = new GenericDialog(\"Watershed 3D\");\n int spot = 0;\n int seed = nbima > 1 ? 1 : 0;\n gd.addChoice( \"Input image\", names, names[spot] );\n gd.addChoice( \"Image to seed from\", names, names[seed] );\n gd.addChoice( \"Mask\", namesMask, namesMask[ nbima > 2 ? 3 : 0 ] );\n gd.addCheckbox( \"Use priority queue\", usePriorityQueue );\n gd.showDialog();\n if (gd.wasOKed()) \n {\n spot = gd.getNextChoiceIndex();\n seed = gd.getNextChoiceIndex();\n int maskIndex = gd.getNextChoiceIndex();\n usePriorityQueue = gd.getNextBoolean();\n ImagePlus inputImage = WindowManager.getImage(spot + 1);\n ImagePlus seedImage = WindowManager.getImage(seed + 1);\n ImagePlus maskImage = maskIndex > 0 ? WindowManager.getImage( maskIndex ) : null;\n ImagePlus result = process( inputImage, seedImage, maskImage );\n ImageProcessor ip = result.getProcessor();\n ip.resetMinAndMax();\n result.setDisplayRange(ip.getMin(),ip.getMax());\n result.show();\n }\n\t}\n", "output": "\tpublic void run(String arg0) \n\t{\n\t\tint nbima = WindowManager.getImageCount();\n\t\tif( nbima == 0 )\n\t\t{\n\t\t\tIJ.error( \"Watershed 3D\", \n\t\t\t\t\t\"ERROR: At least one image needs to be open to run watershed in 3D\");\n\t\t\treturn;\n\t\t}\n String[] names = new String[ nbima ];\n String[] namesMask = new String[ nbima + 1 ];\n namesMask[ 0 ] = \"None\";\n for (int i = 0; i < nbima; i++) \n {\n names[ i ] = WindowManager.getImage(i + 1).getShortTitle();\n namesMask[ i + 1 ] = WindowManager.getImage(i + 1).getShortTitle();\n }\n GenericDialog gd = new GenericDialog(\"Watershed 3D\");\n int spot = 0;\n int seed = nbima > 1 ? 1 : 0;\n gd.addChoice( \"Input image\", names, names[spot] );\n gd.addChoice( \"Image to seed from\", names, names[seed] );\n gd.addChoice( \"Mask\", namesMask, namesMask[ nbima > 2 ? 3 : 0 ] );\n gd.addCheckbox( \"Use priority queue\", usePriorityQueue );\n gd.showDialog();\n if (gd.wasOKed()) \n {\n spot = gd.getNextChoiceIndex();\n seed = gd.getNextChoiceIndex();\n int maskIndex = gd.getNextChoiceIndex();\n usePriorityQueue = gd.getNextBoolean();\n ImagePlus inputImage = WindowManager.getImage(spot + 1);\n ImagePlus seedImage = WindowManager.getImage(seed + 1);\n ImagePlus maskImage = maskIndex > 0 ? WindowManager.getImage( maskIndex ) : null;\n ImagePlus result = process( inputImage, seedImage, maskImage );\n ImageProcessor ip = result.getProcessor();\n ip.resetMinAndMax();\n result.setDisplayRange(ip.getMin(),ip.getMax());\n result.show();\n }\n\t}\n"} {"input": "\tpublic void getFrames(int frame, float[][] frameData)\n\t{\n\t\tif (frame >= nFrames) return;\n\t\tif (isTotal())\n\t\t{\n\t\t\tint numFloats = Math.min(frameData[0].length,(int)(nFrames-frame))*nChannels;\t\t\t\n\t\t\tif (storeInNativeBitDepth)\n\t\t\t{\n\t\t\t\tint startIndex = frame * 2 * nChannels;\t\t\t\n\t\t\t\tfloat[] floatdata = new float[numFloats];\n\t\t\t\tAudioUtils.byteToFloat(floatdata, sampleData, isBigEndian, startIndex, numFloats);\n\t\t\t\tAudioUtils.deinterleave(floatdata,nChannels,frameData[0].length,frameData);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor(int i=0;i0)\n\t\t\t{\n\t\t\t\ttry {\n\t\t\t\t\twhile (!regionLocks[whichregion].tryLock(10, TimeUnit.MILLISECONDS)){}\n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (storeInNativeBitDepth)\n\t\t\t\t\t{\t\t\t\t\t\n\t\t\t\t\t\tbyte[] regionData = getRegion(whichregion);\n\t\t\t\t\t\tif (regionData!=null)\n\t\t\t\t\t\t\tAudioUtils.byteToFloat(floatdata, regionData, isBigEndian, regionindex*2*nChannels, floatdataindex*nChannels, numfloatstocopy*nChannels);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tfloat[][] regionData = getRegionF(whichregion);\n\t\t\t\t\t\tif (regionData!=null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor(int i=0;i= nFrames) return;\n\t\tif (isTotal())\n\t\t{\n\t\t\tint numFloats = Math.min(frameData[0].length,(int)(nFrames-frame));\t\t\t\n\t\t\tif (storeInNativeBitDepth)\n\t\t\t{\n\t\t\t\tint startIndex = frame * 2 * nChannels;\t\t\t\n\t\t\t\tfloat[] floatdata = new float[numFloats*nChannels];\n\t\t\t\tAudioUtils.byteToFloat(floatdata, sampleData, isBigEndian, startIndex, numFloats*nChannels);\n\t\t\t\tAudioUtils.deinterleave(floatdata,nChannels,frameData[0].length,frameData);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor(int i=0;i0)\n\t\t\t{\n\t\t\t\ttry {\n\t\t\t\t\twhile (!regionLocks[whichregion].tryLock(10, TimeUnit.MILLISECONDS)){}\n\t\t\t\t} catch (InterruptedException e) {\n\t\t\t\t\te.printStackTrace();\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tif (storeInNativeBitDepth)\n\t\t\t\t\t{\t\t\t\t\t\n\t\t\t\t\t\tbyte[] regionData = getRegion(whichregion);\n\t\t\t\t\t\tif (regionData!=null)\n\t\t\t\t\t\t\tAudioUtils.byteToFloat(floatdata, regionData, isBigEndian, regionindex*2*nChannels, floatdataindex*nChannels, numfloatstocopy*nChannels);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tfloat[][] regionData = getRegionF(whichregion);\n\t\t\t\t\t\tif (regionData!=null)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfor(int i=0;i childrenTypesList = new ArrayList();\n\t\tchildrenTypesList.add(ATTRIBUTES_NODE);\n\t\tchildrenTypesList.add(STRING_TYPE);\n\t\tList childrenList = new ArrayList();\n\t\tchildrenList.add(getAttributes(e));\n\t\tchildrenList.add(DEFAULT_TEXT_CONTENT);\n\t\tfor(int i = 0; i < nrOfChildNodes; i++){\n\t\t\tNode childNode = childNodesList.item(i);\n\t\t\tif(childNode instanceof Element){ \n\t\t\t\tElement c = (Element) childNode;\n\t\t\t\tIConstructor child = visitElement(c);\n\t\t\t\tchildrenTypesList.add(child.getType());\n\t\t\t\tchildrenList.add(child);\n\t\t\t}else{ \n\t\t\t\tjava.lang.String textContent = childNode.getNodeValue().trim();\n\t\t\t\tif(textContent.length() > 0){\n\t\t\t\t\tchildrenList.set(1, vf.string(textContent));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint nrOfChildren = childrenTypesList.size();\n\t\tType[] types = new Type[nrOfChildren];\n\t\ttypes = childrenTypesList.toArray(types);\n\t\tIValue[] children = new IValue[nrOfChildren];\n\t\tchildren = childrenList.toArray(children);\n\t\tjava.lang.String name = e.getNodeName();\n\t\tType consType = tf.constructor(typeStore, adt, name, types);\n\t\treturn vf.constructor(consType, children);\n\t}\n", "output": "\tprivate IConstructor visitElement(Element e){\n\t\tTypeInfo typeInfo = e.getSchemaTypeInfo();\n\t\tjava.lang.String typeName = typeInfo.getTypeName();\n\t\tType adt = anonymousType;\n\t\tif(typeName != null){\n\t\t\tadt = tf.abstractDataType(typeStore, typeName);\n\t\t}\n\t\tNodeList childNodesList = e.getChildNodes();\n\t\tint nrOfChildNodes = childNodesList.getLength();\n\t\tList childrenTypesList = new ArrayList();\n\t\tchildrenTypesList.add(ATTRIBUTES_NODE);\n\t\tList childrenList = new ArrayList();\n\t\tchildrenList.add(getAttributes(e));\n\t\tfor(int i = 0; i < nrOfChildNodes; i++){\n\t\t\tNode childNode = childNodesList.item(i);\n\t\t\tif(childNode instanceof Element){ \n\t\t\t\tElement c = (Element) childNode;\n\t\t\t\tIConstructor child = visitElement(c);\n\t\t\t\tchildrenTypesList.add(child.getType());\n\t\t\t\tchildrenList.add(child);\n\t\t\t}else{ \n\t\t\t\tjava.lang.String textContent = childNode.getNodeValue();\n\t\t\t\tchildrenTypesList.add(STRING_TYPE);\n\t\t\t\tchildrenList.add(vf.string(textContent));\n\t\t\t}\n\t\t}\n\t\tint nrOfChildren = childrenTypesList.size();\n\t\tType[] types = new Type[nrOfChildren];\n\t\ttypes = childrenTypesList.toArray(types);\n\t\tIValue[] children = new IValue[nrOfChildren];\n\t\tchildren = childrenList.toArray(children);\n\t\tjava.lang.String name = e.getNodeName();\n\t\tType consType = tf.constructor(typeStore, adt, name, types);\n\t\treturn vf.constructor(consType, children);\n\t}\n"} {"input": " public void testExtractLeadingNumericText() {\n assertThat(extractLeadingNumericText(\"abc def\"), is(\"\"));\n assertThat(extractLeadingNumericText(\"5 abc def ds\"), is(\"5\"));\n assertThat(extractLeadingNumericText(\"5.0 abc def ds\"), is(\"5.0\"));\n assertThat(extractLeadingNumericText(\"abc\"), is(\"0\"));\n }\n", "output": " public void testExtractLeadingNumericText() {\n assertThat(extractLeadingNumericText(\"abc def\"), is(\"\"));\n assertThat(extractLeadingNumericText(\"5 abc def ds\"), is(\"5\"));\n assertThat(extractLeadingNumericText(\"5.0 abc def ds\"), is(\"5.0\"));\n assertThat(extractLeadingNumericText(\"abc\"), is(\"\"));\n }\n"} {"input": " public static String getServerString(HttpServletRequest request) {\n String scheme = request.getScheme();\n int serverPort = request.getServerPort();\n String serverName = request.getServerName();\n StringBuilder sb = new StringBuilder();\n sb.append(scheme);\n sb.append(\"://\");\n sb.append(serverName);\n sb.append(((\"https\".equalsIgnoreCase(scheme) && serverPort == 443) || (\"http\".equalsIgnoreCase(scheme) && serverPort == 80)) ? \"\" : \":\" + serverPort);\n return sb.toString();\n }\n", "output": " public static String getServerString(HttpServletRequest request) {\n String forwardedProto = request.getHeader(\"X-Forwarded-Proto\");\n String scheme = forwardedProto != null ? forwardedProto : request.getScheme();\n int serverPort = request.getServerPort();\n String serverName = request.getServerName();\n StringBuilder sb = new StringBuilder();\n sb.append(scheme);\n sb.append(\"://\");\n sb.append(serverName);\n sb.append(((\"https\".equalsIgnoreCase(scheme) && serverPort == 443) || (\"http\".equalsIgnoreCase(scheme) && serverPort == 80)) ? \"\" : \":\" + serverPort);\n return sb.toString();\n }\n"} {"input": " public void exportPony(Pony pony) throws IOException\n {\n\tColor[] colours = new Color[256];\n\tboolean[] format = new boolean[9];\n\tColor background = null, foreground = null;\n\tfor (int i = 0; i < 256; i++)\n\t{ Colour colour = new Colour(i);\n\t colours[i] = new Color(colour.red, colour.green, colour.blue);\n\t}\n\tif (this.palette != null)\n\t System.arraycopy(this.palette, 0, colours, 0, 16);\n\tStringBuilder resetpalette = null;\n\tif (this.tty)\n\t if (this.colourful)\n\t { resetpalette = new StringBuilder();\n\t\tfor (int i = 0; i < 16; i++)\n\t\t{ Colour colour = new Colour(i);\n\t\t resetpalette.append(\"\\033]P\");\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(i));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue & 15));\n\t } }\n\t else\n\t { resetpalette = new StringBuilder();\n\t\tfor (int i : new int[] { 7, 15 })\n\t\t{ Colour colour = new Colour(i);\n\t\t resetpalette.append(\"\\033]P\");\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(i));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue & 15));\n\t } }\n\telse if (this.fullcolour)\n\t{ resetpalette = new StringBuilder();\n\t for (int i = 0; i < 16; i++)\n\t { Colour colour = new Colour(i);\n\t\tresetpalette.append(\"\\033]4;\");\n\t\tresetpalette.append(i);\n\t\tresetpalette.append(\";rgb:\");\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.red >>> 4));\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.red & 15));\n\t\tresetpalette.append('/');\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.green >>> 4));\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.green & 15));\n\t\tresetpalette.append('/');\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue >>> 4));\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue & 15));\n\t\tresetpalette.append(\"\\033\\\\\");\n\t} }\n\tStringBuilder databuf = new StringBuilder();\n\tint curleft = 0, curright = 0, curtop = 0, curbottom = 0;\n\tPony.Cell[][] matrix = pony.matrix;\n\tPony.Meta[][][] metamatrix = pony.metamatrix;\n\tboolean[] PLAIN = new boolean[9];\n\tif ((pony.tags != null) || (pony.comment != null))\n\t databuf.append(\"$$$\\n\");\n\tif (pony.tags != null)\n\t for (String[] tag : pony.tags)\n\t {\n\t\tdatabuf.append(tag[0].toUpperCase());\n\t\tdatabuf.append(\": \");\n\t\tdatabuf.append(tag[1]);\n\t\tdatabuf.append(\"\\n\");\n\t }\n\tif (pony.comment != null)\n\t{\n\t if ((pony.tags != null) && (pony.tags.length != 0))\n\t\tdatabuf.append('\\n');\n\t String comment = '\\n' + pony.comment.trim() + '\\n';\n\t while (comment.contains(\"\\n$$$\\n\"))\n\t\tcomment = comment.replace(\"\\n$$$\\n\", \"\\n$$$(!)\\n\");\n\t comment = comment.substring(1, comment.length() - 1);\n\t databuf.append(comment);\n\t}\n\tif ((pony.tags != null) || (pony.comment != null))\n\t databuf.append(\"\\n$$$\\n\");\n\tif (this.ignoreballoon)\n\t for (Pony.Meta[][] row : metamatrix)\n\t\tfor (Pony.Meta[] cell : row)\n\t\t if (cell != null)\n\t\t\tfor (int i = 0, n = cell.length; i < n; i++)\n\t\t\t if ((cell[i] != null) && (cell[i] instanceof Pony.Balloon))\n\t\t\t\trow[i] = null;\n\tif (this.ignorelink)\n\t for (Pony.Cell[] row : matrix)\n\t\tfor (int i = 0, n = row.length; i < n; i++)\n\t\t{ Pony.Cell cell;\n\t\t if ((cell = row[i]) != null)\n\t\t\tif (this.ignorelink && ((cell.character == Pony.Cell.NNE_SSW) || (cell.character == Pony.Cell.NNW_SSE)))\n\t\t\t row[i] = new Pony.Cell(' ', null, null, PLAIN);\n\t\t\telse\n\t\t\t{ Color back = ((cell.lowerColour == null) || (cell.lowerColour.getAlpha() < 112)) ? null : cell.lowerColour;\n\t\t\t Color fore = ((cell.upperColour == null) || (cell.upperColour.getAlpha() < 112)) ? null : cell.upperColour;\n\t\t\t row[i] = new Pony.Cell(cell.character, back, fore, cell.format); \n\t\t\t}\n\t }\n\tif (this.left >= 0)\n\t{\n\t int cur = 0;\n\t outer:\n\t for (int n = matrix[0].length; cur < n; cur++)\n\t\t for (int j = 0, m = matrix.length; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = matrix[j][cur];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metamatrix[j][cur];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t }\n\t this.left -= cur;\n\t if (this.left < 0)\n\t\t{\n\t\t int w = matrix[0].length;\n\t\t for (int j = 0, n = matrix.length; j < n; j++)\n\t\t {\tSystem.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.left], -this.left, w);\n\t\t\tSystem.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.left][], -this.left, w + 1);\n\t\t }\n\t\t this.left = 0;\n\t\t}\n\t}\n\telse\n\t this.left = 0;\n\tif (this.right >= 0)\n\t{\n\t int cur = 0;\n\t outer:\n\t for (int n = matrix[0].length - 1; cur <= n; cur++)\n\t\t for (int j = 0, m = matrix.length; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = matrix[j][n - cur];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metamatrix[j][n - cur];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t }\n\t this.right -= cur;\n\t if (this.right < 0)\n\t\t{\n\t\t int w = matrix[0].length;\n\t\t for (int j = 0, n = matrix.length; j < n; j++)\n\t\t {\tSystem.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.right], 0, w);\n\t\t\tSystem.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.right][], 0, w + 1);\n\t\t }\n\t\t this.right = 0;\n\t\t}\n\t}\n\telse\n\t this.right = 0;\n\tif (this.top >= 0)\n\t{\n\t int cur = 0, m = matrix[0].length - this.right;\n\t outer:\n\t for (int n = matrix.length; cur < n; cur++)\n\t\t{ Pony.Cell[] row = matrix[cur];\n\t\t Pony.Meta[][] metarow = metamatrix[cur];\n\t\t for (int j = this.left; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = row[j];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metarow[j];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t} }\n\t this.top -= cur;\n\t if (this.top < 0)\n\t\t{\n\t\t int w = matrix[0].length;\n\t\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.top][], -this.top, matrix.length);\n\t\t System.arraycopy(new Pony.Cell[-this.top][w], 0, matrix, 0, -this.top);\n\t\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.top][][], -this.top, metamatrix.length);\n\t\t System.arraycopy(new Pony.Meta[-this.top][w + 1][], 0, metamatrix, 0, -this.top);\n\t\t this.top = 0;\n\t\t}\n\t}\n\telse\n\t this.top = 0;\n\tif (this.bottom >= 0)\n\t{\n\t int cur = 0, m = matrix[0].length - this.right;\n\t outer:\n\t for (int n = matrix.length - 1 - this.top; cur <= n; cur++)\n\t\t{ Pony.Cell[] row = matrix[n - cur];\n\t\t Pony.Meta[][] metarow = metamatrix[n - cur];\n\t\t for (int j = this.left; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = row[j];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metarow[j];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t} }\n\t this.bottom -= cur;\n\t if (this.bottom < 0)\n\t\t{\n\t\t int h = matrix.length;\n\t\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.bottom][], 0, matrix.length);\n\t\t System.arraycopy(new Pony.Cell[-this.bottom][matrix[0].length], 0, matrix, h, -this.bottom);\n\t\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.bottom][][], 0, metamatrix.length);\n\t\t System.arraycopy(new Pony.Meta[-this.bottom][metamatrix[0].length][], 0, metamatrix, h, -this.bottom);\n\t\t this.bottom = 0;\n\t\t}\n\t}\n\telse\n\t this.bottom = 0;\n\tif (this.left > 0)\n\t{ int w = matrix[0].length;\n\t for (int y = 0, h = matrix.length; y < h; y++)\n\t {\n\t\tSystem.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.left], this.left, w);\n\t\tSystem.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.left][], this.left, w + 1);\n\t }\n\t this.left = 0;\n\t}\n\telse\n\t this.left = -this.left;\n\tif (this.right > 0)\n\t{ int w = matrix[0].length;\n\t for (int y = 0, h = matrix.length; y < h; y++)\n\t {\n\t\tSystem.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.right], 0, w);\n\t\tSystem.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.right][], 0, w + 1);\n\t }\n\t this.right = 0;\n\t}\n\telse\n\t this.right = -this.right;\n\tif (this.top > 0)\n\t{\n\t int h = matrix.length, w = matrix[0].length;\n\t Pony.Cell[][] appendix = new Pony.Cell[this.top][w];\n\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.top][], this.top, h);\n\t System.arraycopy(appendix, 0, matrix, 0, this.top);\n\t Pony.Meta[][][] metaappendix = new Pony.Meta[this.top][w + 1][];\n\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.top][w + 1][], this.top, h);\n\t System.arraycopy(metaappendix, 0, metamatrix, 0, this.top);\n\t this.top = 0;\n\t}\n\telse\n\t this.top = -this.top;\n\tif (this.bottom > 0)\n\t{\n\t int h = matrix.length, w = matrix[0].length;\n\t Pony.Cell[][] appendix = new Pony.Cell[this.bottom][w];\n\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.bottom][], 0, h);\n\t System.arraycopy(appendix, 0, matrix, h, this.bottom);\n\t Pony.Meta[][][] metaappendix = new Pony.Meta[this.bottom][w + 1][];\n\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.bottom][][], 0, h);\n\t System.arraycopy(metaappendix, 0, metamatrix, h, this.bottom);\n\t this.bottom = 0;\n\t}\n\telse\n\t this.bottom = -this.bottom;\n\tfor (int y = 0; y < this.top; y++)\n\t{ Pony.Meta[][] metarow = metamatrix[y];\n\t for (int x = 0, w = metarow.length; x < w; x++)\n\t { Pony.Meta[] metacell = metarow[x];\n\t\tfor (int z = 0, d = metacell.length; z < d; z++)\n\t\t{ Pony.Meta metaelem;\n\t\t if (((metaelem = metacell[z]) != null) && (metaelem instanceof Pony.Store))\n\t\t\tdatabuf.append(\"$\" + (((Pony.Store)(metaelem)).name + \"=\" + ((Pony.Store)(metaelem)).value).replace(\"$\", \"\\033$\") + \"$\");\n\t} } }\n\tif (this.right != 0)\n\t{ int w = matrix[0].length, r = metamatrix[0].length - this.right;\n\t Pony.Meta[] leftovers = new Pony.Meta[32];\n\t for (int y = this.top, h = matrix.length - this.bottom; y < h; y++)\n\t {\n\t\tint ptr = 0;\n\t\tPony.Meta[][] metarow = metamatrix[y];\n\t\tfor (int x = r; x <= w; x++)\n\t\t if (metarow[x] != null)\n\t\t\tfor (Pony.Meta meta : metarow[x])\n\t\t\t if ((meta != null) && (meta instanceof Pony.Store))\n\t\t\t { if (ptr == leftovers.length)\n\t\t\t\t System.arraycopy(leftovers, 0, leftovers = new Pony.Meta[ptr << 1], 0, ptr);\n\t\t\t\tleftovers[ptr++] = meta;\n\t\t\t }\n\t\tif (ptr != 0)\n\t\t{ Pony.Meta[] metacell = metarow[r];\n\t\t System.arraycopy(metacell, 0, metarow[r] = metacell = new Pony.Meta[metacell.length + ptr], 0, metacell.length - ptr);\n\t\t System.arraycopy(leftovers, 0, metacell, metacell.length - ptr, ptr);\n\t\t}\n\t\tSystem.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w - this.right], 0, w - this.right);\n\t\tSystem.arraycopy(metarow, 0, metamatrix[y] = new Pony.Meta[w - this.right + 1][], 0, w - this.right + 1);\n\t }\n\t}\n\tint[] endings = null;\n\tif (this.even == false)\n\t{\n\t int w = matrix[0].length;\n\t endings = new int[matrix.length];\n\t for (int y = 0, h = matrix.length; y < h; y++)\n\t {\n\t\tPony.Cell[] row = matrix[y];\n\t\tPony.Meta[][] metarow = metamatrix[y];\n\t\tint cur = 0;\n\t\tmid:\n\t\t for (int n = w - 1; cur <= n; cur++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = row[n - cur];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metarow[n - cur];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak mid;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak mid;\n\t\t\t}\n\t\t }\n\t\tendings[y] = w - cur;\n\t }\n\t}\n\tPony.Cell defaultcell = new Pony.Cell(' ', null, null, PLAIN);\n\tfor (int y = this.top, h = matrix.length - this.bottom; y < h; y++)\n\t{\n\t Pony.Cell[] row = matrix[y];\n\t Pony.Meta[][] metarow = metamatrix[y];\n\t int ending = endings == null ? row.length : endings[y];\n\t for (int x = 0, w = row.length; x <= w; x++)\n\t { Pony.Meta[] metacell = metarow[x];\n\t\tif (metacell != null)\n\t\t for (int z = 0, d = metacell.length; z < d; z++)\n\t\t { Pony.Meta meta = metacell[z];\n\t\t\tif ((meta != null) && ((x >= this.left) || (meta instanceof Pony.Store)))\n\t\t\t{ Class metaclass = meta.getClass();\n\t\t\t if (metaclass == Pony.Store.class)\n\t\t\t\tdatabuf.append(\"$\" + (((Pony.Store)meta).name + \"=\" + ((Pony.Store)meta).value).replace(\"$\", \"\\033$\") + \"$\");\n\t\t\t else if (metaclass == Pony.Recall.class)\n\t\t\t { Pony.Recall recall = (Pony.Recall)meta;\n\t\t\t\tColor back = ((recall.backgroundColour == null) || (recall.backgroundColour.getAlpha() < 112)) ? null : recall.backgroundColour;\n\t\t\t\tColor fore = ((recall.foregroundColour == null) || (recall.foregroundColour.getAlpha() < 112)) ? null : recall.foregroundColour;\n\t\t\t\tdatabuf.append(applyColour(colours, background, foreground, format, background = back, foreground = fore, recall.format));\n\t\t\t\tdatabuf.append(\"$\" + recall.name.replace(\"$\", \"\\033$\") + \"$\");\n\t\t\t }\n\t\t\t else if (metaclass == Pony.Balloon.class)\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));\n\t\t\t\tPony.Balloon balloon = (Pony.Balloon)meta;\n\t\t\t\tif (balloon.left != null)\n\t\t\t\t{ int justification = balloon.minWidth != null ? balloon.justification & (Pony.Balloon.LEFT | Pony.Balloon.RIGHT) : Pony.Balloon.NONE;\n\t\t\t\t switch (justification)\n\t\t\t\t {\tcase Pony.Balloon.NONE:\n\t\t\t\t\t char[] spaces = new char[balloon.left.intValue()];\n\t\t\t\t\t Arrays.fill(spaces, ' ');\n\t\t\t\t\t databuf.append(new String(spaces));\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue());\n\t\t\t\t\t break;\n\t\t\t\t\tcase Pony.Balloon.LEFT:\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue() + \"l\");\n\t\t\t\t\t databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);\n\t\t\t\t\t break;\n\t\t\t\t\tcase Pony.Balloon.RIGHT:\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue() + \"r\");\n\t\t\t\t\t databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);\n\t\t\t\t\t break;\n\t\t\t\t\tdefault:\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue() + \"c\");\n\t\t\t\t\t databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);\n\t\t\t\t\t break;\n\t\t\t\t} }\n\t\t\t\telse if (balloon.minWidth != null)\n\t\t\t\t databuf.append(\"$balloon\" + balloon.minWidth.toString());\n\t\t\t\tif (balloon.minHeight != null)\n\t\t\t\t databuf.append(\",\" + balloon.minHeight.toString());\n\t\t\t\tdatabuf.append(\"$\\n\");\n\t\t }\t} }\n\t\tif ((x != w) && (x >= this.left) && (x < ending))\n\t\t{ Pony.Cell cell = row[x];\n\t\t if (cell == null)\n\t\t\tcell = defaultcell;\n\t\t if (cell.character >= 0)\n\t\t { databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = cell.format));\n\t\t\tdatabuf.append(utf32to16(cell.character));\n\t\t }\n\t\t else if (cell.character == Pony.Cell.NNE_SSW)\n\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));\n\t\t\tdatabuf.append(\"$\\\\$\");\n\t\t }\n\t\t else if (cell.character == Pony.Cell.NNW_SSE)\n\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));\n\t\t\tdatabuf.append(\"$/$\");\n\t\t }\n\t\t else if (cell.character == Pony.Cell.PIXELS)\n\t\t\tif (cell.lowerColour == null)\n\t\t\t if (cell.upperColour == null)\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = this.spacesave ? foreground : null, format = PLAIN));\n\t\t\t\tdatabuf.append(' ');\n\t\t\t }\n\t\t\t else\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = cell.upperColour, format = PLAIN));\n\t\t\t\tdatabuf.append('\u2580');\n\t\t\t }\n\t\t\telse\n\t\t\t if (cell.upperColour == null)\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = null, format = PLAIN));\n\t\t\t\tdatabuf.append('\u2580');\n\t\t\t }\n\t\t\t else if (cell.upperColour.equals(cell.lowerColour))\n\t\t\t\tif (this.zebra)\n\t\t\t\t{ databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));\n\t\t\t\t databuf.append('\u2584');\n\t\t\t\t}\n\t\t\t\telse if (this.fullblocks )\n\t\t\t\t{ databuf.append(applyColour(colours, background, foreground, format, background = this.spacesave ? background : cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));\n\t\t\t\t databuf.append('\u2588');\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{ databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = this.spacesave ? foreground : cell.lowerColour, format = PLAIN));\n\t\t\t\t databuf.append(' ');\n\t\t\t\t}\n\t\t\t else \n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = PLAIN));\n\t\t\t\tdatabuf.append('\u2584');\n\t\t\t }\n\t\t}\n\t }\n\t background = foreground = null;\n\t format = PLAIN;\n\t databuf.append(\"\\033[0m\\n\");\n\t}\n\tString data = databuf.toString();\n\tif (this.version == VERSION_COWSAY)\n\t{\n\t String metadata = null;\n\t if (data.startsWith(\"$$$\\n\"))\n\t {\n\t\tmetadata = data.substring(4);\n\t\tif (metadata.startsWith(\"$$$\\n\"))\n\t\t metadata = null;\n\t\telse\n\t\t{ metadata = metadata.substring(0, metadata.indexOf(\"\\n$$$\\n\") + 5);\n\t\t data = data.substring(data.indexOf(\"\\n$$$\\n\") + 5);\n\t\t metadata = '#' + metadata.replace(\"\\n\", \"\\n#\");\n\t\t}\n\t }\n\t String eop = \"\\nEOP\";\n\t while (data.contains(eop + '\\n'))\n\t\teop += 'P';\n\t data = data.replace(\"$/$\", \"/\").replace(\"$\\\\$\", \"${thoughts}\");\n\t while (data.contains(\"$balloon\"))\n\t {\n\t\tint start = data.indexOf(\"$balloon\");\n\t\tint end = data.indexOf(\"$\", start + 8);\n\t\tdata = data.substring(0, start) + data.substring(end + 1);\n\t }\n\t data = \"$the_cow = <<\" + eop + \";\\n\" + data;\n\t data += eop + '\\n';\n\t if (metadata != null)\n\t\tdata = metadata + data;\n\t if (this.utf8 == false)\n\t\tdata = data.replace(\"\u2580\", \"\\\\N{U+2580}\").replace(\"\u2584\", \"\\\\N{U+2584}\");\n\t}\n\telse\n\t{ if (this.version < VERSION_METADATA)\n\t {\n\t\tif (data.startsWith(\"$$$\\n\"))\n\t\t data = data.substring(data.indexOf(\"\\n$$$\\n\") + 5);\n\t }\n\t if (this.version < VERSION_HORIZONTAL_JUSTIFICATION)\n\t {\n\t\tdatabuf = new StringBuilder();\n\t\tint pos = data.indexOf(\"\\n$$$\\n\");\n\t\tpos += pos < 0 ? 1 : 5;\n\t\tdatabuf.append(data.substring(0, pos));\n\t\tStringBuilder dollarbuf = null;\n\t\tboolean esc = false;\n\t\tfor (int i = 0, n = data.length(); i < n;)\n\t\t{\n\t\t char c = data.charAt(i++);\n\t\t if (dollarbuf != null)\n\t\t {\n\t\t\tdollarbuf.append(c);\n\t\t\tif (esc || (c == '\\033'))\n\t\t\t esc ^= true;\n\t\t\telse if (c == '$')\n\t\t\t{\n\t\t\t String dollar = dollarbuf.toString();\n\t\t\t dollarbuf = null;\n\t\t\t if (dollar.startsWith(\"$balloon\") == false)\n\t\t\t\tdatabuf.append(dollar);\n\t\t\t else\n\t\t\t { databuf.append(\"$balloon\");\n\t\t\t\tdollar = dollar.substring(8);\n\t\t\t\tif (dollar.contains(\"l\")) dollar = dollar.substring(dollar.indexOf('l') + 1);\n\t\t\t\telse if (dollar.contains(\"r\")) dollar = dollar.substring(dollar.indexOf('r') + 1);\n\t\t\t\telse if (dollar.contains(\"c\")) dollar = dollar.substring(dollar.indexOf('c') + 1);\n\t\t\t\tdatabuf.append(dollar);\n\t\t\t} }\n\t\t }\n\t\t else if (c == '$')\n\t\t\tdollarbuf = new StringBuilder(\"$\");\n\t\t else\n\t\t\tdatabuf.append(c);\n\t\t}\n\t\tdata = databuf.toString();\n\t }\n\t}\n\tif (resetpalette != null)\n\t data += resetpalette.toString();\n\tif (this.escesc)\n\t data = data.replace(\"\\033\", \"\\\\e\");\n\tOutputStream out = System.out;\n\tif (this.file != null)\n\t out = new FileOutputStream(this.file); \n\tout.write(data.getBytes(\"UTF-8\"));\n\tout.flush();\n\tif (out != System.out)\n\t out.close();\n }\n", "output": " public void exportPony(Pony pony) throws IOException\n {\n\tColor[] colours = new Color[256];\n\tboolean[] format = new boolean[9];\n\tColor background = null, foreground = null;\n\tfor (int i = 0; i < 256; i++)\n\t{ Colour colour = new Colour(i);\n\t colours[i] = new Color(colour.red, colour.green, colour.blue);\n\t}\n\tif (this.palette != null)\n\t System.arraycopy(this.palette, 0, colours, 0, 16);\n\tStringBuilder resetpalette = null;\n\tif (this.tty)\n\t if (this.colourful)\n\t { resetpalette = new StringBuilder();\n\t\tfor (int i = 0; i < 16; i++)\n\t\t{ Colour colour = new Colour(i);\n\t\t resetpalette.append(\"\\033]P\");\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(i));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue & 15));\n\t } }\n\t else\n\t { resetpalette = new StringBuilder();\n\t\tfor (int i : new int[] { 7, 15 })\n\t\t{ Colour colour = new Colour(i);\n\t\t resetpalette.append(\"\\033]P\");\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(i));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.red & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.green & 15));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue >>> 4));\n\t\t resetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue & 15));\n\t } }\n\telse if (this.fullcolour)\n\t{ resetpalette = new StringBuilder();\n\t for (int i = 0; i < 16; i++)\n\t { Colour colour = new Colour(i);\n\t\tresetpalette.append(\"\\033]4;\");\n\t\tresetpalette.append(i);\n\t\tresetpalette.append(\";rgb:\");\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.red >>> 4));\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.red & 15));\n\t\tresetpalette.append('/');\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.green >>> 4));\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.green & 15));\n\t\tresetpalette.append('/');\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue >>> 4));\n\t\tresetpalette.append(\"0123456789ABCDEF\".charAt(colour.blue & 15));\n\t\tresetpalette.append(\"\\033\\\\\");\n\t} }\n\tStringBuilder databuf = new StringBuilder();\n\tint curleft = 0, curright = 0, curtop = 0, curbottom = 0;\n\tPony.Cell[][] matrix = pony.matrix;\n\tPony.Meta[][][] metamatrix = pony.metamatrix;\n\tboolean[] PLAIN = new boolean[9];\n\tif ((pony.tags != null) || (pony.comment != null))\n\t databuf.append(\"$$$\\n\");\n\tif (pony.tags != null)\n\t for (String[] tag : pony.tags)\n\t {\n\t\tdatabuf.append(tag[0].toUpperCase());\n\t\tdatabuf.append(\": \");\n\t\tdatabuf.append(tag[1]);\n\t\tdatabuf.append(\"\\n\");\n\t }\n\tif (pony.comment != null)\n\t{\n\t if ((pony.tags != null) && (pony.tags.length != 0))\n\t\tdatabuf.append('\\n');\n\t String comment = '\\n' + pony.comment.trim() + '\\n';\n\t while (comment.contains(\"\\n$$$\\n\"))\n\t\tcomment = comment.replace(\"\\n$$$\\n\", \"\\n$$$(!)\\n\");\n\t comment = comment.substring(1, comment.length() - 1);\n\t databuf.append(comment);\n\t}\n\tif ((pony.tags != null) || (pony.comment != null))\n\t databuf.append(\"\\n$$$\\n\");\n\tif (this.ignoreballoon)\n\t for (Pony.Meta[][] row : metamatrix)\n\t\tfor (Pony.Meta[] cell : row)\n\t\t if (cell != null)\n\t\t\tfor (int i = 0, n = cell.length; i < n; i++)\n\t\t\t if ((cell[i] != null) && (cell[i] instanceof Pony.Balloon))\n\t\t\t\trow[i] = null;\n\tif (this.ignorelink)\n\t for (Pony.Cell[] row : matrix)\n\t\tfor (int i = 0, n = row.length; i < n; i++)\n\t\t{ Pony.Cell cell;\n\t\t if ((cell = row[i]) != null)\n\t\t\tif (this.ignorelink && ((cell.character == Pony.Cell.NNE_SSW) || (cell.character == Pony.Cell.NNW_SSE)))\n\t\t\t row[i] = new Pony.Cell(' ', null, null, PLAIN);\n\t\t\telse\n\t\t\t{ Color back = ((cell.lowerColour == null) || (cell.lowerColour.getAlpha() < 112)) ? null : cell.lowerColour;\n\t\t\t Color fore = ((cell.upperColour == null) || (cell.upperColour.getAlpha() < 112)) ? null : cell.upperColour;\n\t\t\t row[i] = new Pony.Cell(cell.character, back, fore, cell.format); \n\t\t\t}\n\t }\n\tif (this.left >= 0)\n\t{\n\t int cur = 0;\n\t outer:\n\t for (int n = matrix[0].length; cur < n; cur++)\n\t\t for (int j = 0, m = matrix.length; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = matrix[j][cur];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metamatrix[j][cur];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t }\n\t this.left -= cur;\n\t if (this.left < 0)\n\t\t{\n\t\t int w = matrix[0].length;\n\t\t for (int j = 0, n = matrix.length; j < n; j++)\n\t\t {\tSystem.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.left], -this.left, w);\n\t\t\tSystem.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.left][], -this.left, w + 1);\n\t\t }\n\t\t this.left = 0;\n\t\t}\n\t}\n\telse\n\t this.left = 0;\n\tif (this.right >= 0)\n\t{\n\t int cur = 0;\n\t outer:\n\t for (int n = matrix[0].length - 1; cur <= n; cur++)\n\t\t for (int j = 0, m = matrix.length; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = matrix[j][n - cur];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metamatrix[j][n - cur];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t }\n\t this.right -= cur;\n\t if (this.right < 0)\n\t\t{\n\t\t int w = matrix[0].length;\n\t\t for (int j = 0, n = matrix.length; j < n; j++)\n\t\t {\tSystem.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.right], 0, w);\n\t\t\tSystem.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.right][], 0, w + 1);\n\t\t }\n\t\t this.right = 0;\n\t\t}\n\t}\n\telse\n\t this.right = 0;\n\tif (this.top >= 0)\n\t{\n\t int cur = 0, m = matrix[0].length - this.right;\n\t outer:\n\t for (int n = matrix.length; cur < n; cur++)\n\t\t{ Pony.Cell[] row = matrix[cur];\n\t\t Pony.Meta[][] metarow = metamatrix[cur];\n\t\t for (int j = this.left; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = row[j];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metarow[j];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t} }\n\t this.top -= cur;\n\t if (this.top < 0)\n\t\t{\n\t\t int w = matrix[0].length;\n\t\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.top][], -this.top, matrix.length);\n\t\t System.arraycopy(new Pony.Cell[-this.top][w], 0, matrix, 0, -this.top);\n\t\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.top][][], -this.top, metamatrix.length);\n\t\t System.arraycopy(new Pony.Meta[-this.top][w + 1][], 0, metamatrix, 0, -this.top);\n\t\t this.top = 0;\n\t\t}\n\t}\n\telse\n\t this.top = 0;\n\tif (this.bottom >= 0)\n\t{\n\t int cur = 0, m = matrix[0].length - this.right;\n\t outer:\n\t for (int n = matrix.length - 1 - this.top; cur <= n; cur++)\n\t\t{ Pony.Cell[] row = matrix[n - cur];\n\t\t Pony.Meta[][] metarow = metamatrix[n - cur];\n\t\t for (int j = this.left; j < m; j++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = row[j];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metarow[j];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak outer;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak outer;\n\t\t\t}\n\t\t} }\n\t this.bottom -= cur;\n\t if (this.bottom < 0)\n\t\t{\n\t\t int h = matrix.length;\n\t\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.bottom][], 0, matrix.length);\n\t\t System.arraycopy(new Pony.Cell[-this.bottom][matrix[0].length], 0, matrix, h, -this.bottom);\n\t\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.bottom][][], 0, metamatrix.length);\n\t\t System.arraycopy(new Pony.Meta[-this.bottom][metamatrix[0].length][], 0, metamatrix, h, -this.bottom);\n\t\t this.bottom = 0;\n\t\t}\n\t}\n\telse\n\t this.bottom = 0;\n\tif (this.left > 0)\n\t{ int w = matrix[0].length;\n\t for (int y = 0, h = matrix.length; y < h; y++)\n\t {\n\t\tSystem.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.left], this.left, w);\n\t\tSystem.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.left][], this.left, w + 1);\n\t }\n\t this.left = 0;\n\t}\n\telse\n\t this.left = -this.left;\n\tif (this.right > 0)\n\t{ int w = matrix[0].length;\n\t for (int y = 0, h = matrix.length; y < h; y++)\n\t {\n\t\tSystem.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.right], 0, w);\n\t\tSystem.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.right][], 0, w + 1);\n\t }\n\t this.right = 0;\n\t}\n\telse\n\t this.right = -this.right;\n\tif (this.top > 0)\n\t{\n\t int h = matrix.length, w = matrix[0].length;\n\t Pony.Cell[][] appendix = new Pony.Cell[this.top][w];\n\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.top][], this.top, h);\n\t System.arraycopy(appendix, 0, matrix, 0, this.top);\n\t Pony.Meta[][][] metaappendix = new Pony.Meta[this.top][w + 1][];\n\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.top][w + 1][], this.top, h);\n\t System.arraycopy(metaappendix, 0, metamatrix, 0, this.top);\n\t this.top = 0;\n\t}\n\telse\n\t this.top = -this.top;\n\tif (this.bottom > 0)\n\t{\n\t int h = matrix.length, w = matrix[0].length;\n\t Pony.Cell[][] appendix = new Pony.Cell[this.bottom][w];\n\t System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.bottom][], 0, h);\n\t System.arraycopy(appendix, 0, matrix, h, this.bottom);\n\t Pony.Meta[][][] metaappendix = new Pony.Meta[this.bottom][w + 1][];\n\t System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.bottom][][], 0, h);\n\t System.arraycopy(metaappendix, 0, metamatrix, h, this.bottom);\n\t this.bottom = 0;\n\t}\n\telse\n\t this.bottom = -this.bottom;\n\tfor (int y = 0; y < this.top; y++)\n\t{ Pony.Meta[][] metarow = metamatrix[y];\n\t for (int x = 0, w = metarow.length; x < w; x++)\n\t { Pony.Meta[] metacell = metarow[x];\n\t\tfor (int z = 0, d = metacell.length; z < d; z++)\n\t\t{ Pony.Meta metaelem;\n\t\t if (((metaelem = metacell[z]) != null) && (metaelem instanceof Pony.Store))\n\t\t\tdatabuf.append(\"$\" + (((Pony.Store)(metaelem)).name + \"=\" + ((Pony.Store)(metaelem)).value).replace(\"$\", \"\\033$\") + \"$\");\n\t} } }\n\tif (this.right != 0)\n\t{ int w = matrix[0].length, r = metamatrix[0].length - this.right;\n\t Pony.Meta[] leftovers = new Pony.Meta[32];\n\t for (int y = this.top, h = matrix.length - this.bottom; y < h; y++)\n\t {\n\t\tint ptr = 0;\n\t\tPony.Meta[][] metarow = metamatrix[y];\n\t\tfor (int x = r; x <= w; x++)\n\t\t if (metarow[x] != null)\n\t\t\tfor (Pony.Meta meta : metarow[x])\n\t\t\t if ((meta != null) && (meta instanceof Pony.Store))\n\t\t\t { if (ptr == leftovers.length)\n\t\t\t\t System.arraycopy(leftovers, 0, leftovers = new Pony.Meta[ptr << 1], 0, ptr);\n\t\t\t\tleftovers[ptr++] = meta;\n\t\t\t }\n\t\tif (ptr != 0)\n\t\t{ Pony.Meta[] metacell = metarow[r];\n\t\t System.arraycopy(metacell, 0, metarow[r] = metacell = new Pony.Meta[metacell.length + ptr], 0, metacell.length - ptr);\n\t\t System.arraycopy(leftovers, 0, metacell, metacell.length - ptr, ptr);\n\t\t}\n\t\tSystem.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w - this.right], 0, w - this.right);\n\t\tSystem.arraycopy(metarow, 0, metamatrix[y] = new Pony.Meta[w - this.right + 1][], 0, w - this.right + 1);\n\t }\n\t}\n\tint[] endings = null;\n\tif (this.even == false)\n\t{\n\t int w = matrix[0].length;\n\t endings = new int[matrix.length];\n\t for (int y = 0, h = matrix.length; y < h; y++)\n\t {\n\t\tPony.Cell[] row = matrix[y];\n\t\tPony.Meta[][] metarow = metamatrix[y];\n\t\tint cur = 0;\n\t\tmid:\n\t\t for (int n = w - 1; cur <= n; cur++)\n\t\t {\n\t\t\tboolean cellpass = true;\n\t\t\tPony.Cell cell = row[n - cur];\n\t\t\tif (cell != null)\n\t\t\t if ((cell.character != ' ') || (cell.lowerColour != null))\n\t\t\t\tif ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))\n\t\t\t\t cellpass = false;\n\t\t\tif (cellpass == false)\n\t\t\t{ Pony.Meta[] meta = metarow[n - cur];\n\t\t\t if ((meta != null) && (meta.length != 0))\n\t\t\t {\tfor (int k = 0, l = meta.length; k < l; k++)\n\t\t\t\t if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))\n\t\t\t\t\tbreak mid;\n\t\t\t }\n\t\t\t else\n\t\t\t\tbreak mid;\n\t\t\t}\n\t\t }\n\t\tendings[y] = w - cur;\n\t }\n\t}\n\tPony.Cell defaultcell = new Pony.Cell(' ', null, null, PLAIN);\n\tfor (int y = this.top, h = matrix.length - this.bottom; y < h; y++)\n\t{\n\t Pony.Cell[] row = matrix[y];\n\t Pony.Meta[][] metarow = metamatrix[y];\n\t int ending = endings == null ? row.length : endings[y];\n\t for (int x = 0, w = row.length; x <= w; x++)\n\t { Pony.Meta[] metacell = metarow[x];\n\t\tif (metacell != null)\n\t\t for (int z = 0, d = metacell.length; z < d; z++)\n\t\t { Pony.Meta meta = metacell[z];\n\t\t\tif ((meta != null) && ((x >= this.left) || (meta instanceof Pony.Store)))\n\t\t\t{ Class metaclass = meta.getClass();\n\t\t\t if (metaclass == Pony.Store.class)\n\t\t\t\tdatabuf.append(\"$\" + (((Pony.Store)meta).name + \"=\" + ((Pony.Store)meta).value).replace(\"$\", \"\\033$\") + \"$\");\n\t\t\t else if (metaclass == Pony.Recall.class)\n\t\t\t { Pony.Recall recall = (Pony.Recall)meta;\n\t\t\t\tColor back = ((recall.backgroundColour == null) || (recall.backgroundColour.getAlpha() < 112)) ? null : recall.backgroundColour;\n\t\t\t\tColor fore = ((recall.foregroundColour == null) || (recall.foregroundColour.getAlpha() < 112)) ? null : recall.foregroundColour;\n\t\t\t\tdatabuf.append(applyColour(colours, background, foreground, format, background = back, foreground = fore, recall.format));\n\t\t\t\tdatabuf.append(\"$\" + recall.name.replace(\"$\", \"\\033$\") + \"$\");\n\t\t\t }\n\t\t\t else if (metaclass == Pony.Balloon.class)\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));\n\t\t\t\tPony.Balloon balloon = (Pony.Balloon)meta;\n\t\t\t\tif (balloon.left != null)\n\t\t\t\t{ int justification = balloon.minWidth != null ? balloon.justification & (Pony.Balloon.LEFT | Pony.Balloon.RIGHT) : Pony.Balloon.NONE;\n\t\t\t\t switch (justification)\n\t\t\t\t {\tcase Pony.Balloon.NONE:\n\t\t\t\t\t char[] spaces = new char[balloon.left.intValue()];\n\t\t\t\t\t Arrays.fill(spaces, ' ');\n\t\t\t\t\t databuf.append(new String(spaces));\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue());\n\t\t\t\t\t break;\n\t\t\t\t\tcase Pony.Balloon.LEFT:\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue() + \"l\");\n\t\t\t\t\t databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);\n\t\t\t\t\t break;\n\t\t\t\t\tcase Pony.Balloon.RIGHT:\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue() + \"r\");\n\t\t\t\t\t databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);\n\t\t\t\t\t break;\n\t\t\t\t\tdefault:\n\t\t\t\t\t databuf.append(\"$balloon\" + balloon.left.intValue() + \"c\");\n\t\t\t\t\t databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);\n\t\t\t\t\t break;\n\t\t\t\t} }\n\t\t\t\telse if (balloon.minWidth != null)\n\t\t\t\t databuf.append(\"$balloon\" + balloon.minWidth.toString());\n\t\t\t\tif (balloon.minHeight != null)\n\t\t\t\t databuf.append(\",\" + balloon.minHeight.toString());\n\t\t\t\tdatabuf.append(\"$\");\n\t\t }\t} }\n\t\tif ((x != w) && (x >= this.left) && (x < ending))\n\t\t{ Pony.Cell cell = row[x];\n\t\t if (cell == null)\n\t\t\tcell = defaultcell;\n\t\t if (cell.character >= 0)\n\t\t { databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = cell.format));\n\t\t\tdatabuf.append(utf32to16(cell.character));\n\t\t }\n\t\t else if (cell.character == Pony.Cell.NNE_SSW)\n\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));\n\t\t\tdatabuf.append(\"$\\\\$\");\n\t\t }\n\t\t else if (cell.character == Pony.Cell.NNW_SSE)\n\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));\n\t\t\tdatabuf.append(\"$/$\");\n\t\t }\n\t\t else if (cell.character == Pony.Cell.PIXELS)\n\t\t\tif (cell.lowerColour == null)\n\t\t\t if (cell.upperColour == null)\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = this.spacesave ? foreground : null, format = PLAIN));\n\t\t\t\tdatabuf.append(' ');\n\t\t\t }\n\t\t\t else\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = cell.upperColour, format = PLAIN));\n\t\t\t\tdatabuf.append('\u2580');\n\t\t\t }\n\t\t\telse\n\t\t\t if (cell.upperColour == null)\n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = null, format = PLAIN));\n\t\t\t\tdatabuf.append('\u2580');\n\t\t\t }\n\t\t\t else if (cell.upperColour.equals(cell.lowerColour))\n\t\t\t\tif (this.zebra)\n\t\t\t\t{ databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));\n\t\t\t\t databuf.append('\u2584');\n\t\t\t\t}\n\t\t\t\telse if (this.fullblocks )\n\t\t\t\t{ databuf.append(applyColour(colours, background, foreground, format, background = this.spacesave ? background : cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));\n\t\t\t\t databuf.append('\u2588');\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{ databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = this.spacesave ? foreground : cell.lowerColour, format = PLAIN));\n\t\t\t\t databuf.append(' ');\n\t\t\t\t}\n\t\t\t else \n\t\t\t { databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = PLAIN));\n\t\t\t\tdatabuf.append('\u2584');\n\t\t\t }\n\t\t}\n\t }\n\t background = foreground = null;\n\t format = PLAIN;\n\t databuf.append(\"\\033[0m\\n\");\n\t}\n\tString data = databuf.toString();\n\tif (this.version == VERSION_COWSAY)\n\t{\n\t String metadata = null;\n\t if (data.startsWith(\"$$$\\n\"))\n\t {\n\t\tmetadata = data.substring(4);\n\t\tif (metadata.startsWith(\"$$$\\n\"))\n\t\t metadata = null;\n\t\telse\n\t\t{ metadata = metadata.substring(0, metadata.indexOf(\"\\n$$$\\n\") + 5);\n\t\t data = data.substring(data.indexOf(\"\\n$$$\\n\") + 5);\n\t\t metadata = '#' + metadata.replace(\"\\n\", \"\\n#\");\n\t\t}\n\t }\n\t String eop = \"\\nEOP\";\n\t while (data.contains(eop + '\\n'))\n\t\teop += 'P';\n\t data = data.replace(\"$/$\", \"/\").replace(\"$\\\\$\", \"${thoughts}\");\n\t while (data.contains(\"$balloon\"))\n\t {\n\t\tint start = data.indexOf(\"$balloon\");\n\t\tint end = data.indexOf(\"$\", start + 8);\n\t\tdata = data.substring(0, start) + data.substring(end + 1);\n\t }\n\t data = \"$the_cow = <<\" + eop + \";\\n\" + data;\n\t data += eop + '\\n';\n\t if (metadata != null)\n\t\tdata = metadata + data;\n\t if (this.utf8 == false)\n\t\tdata = data.replace(\"\u2580\", \"\\\\N{U+2580}\").replace(\"\u2584\", \"\\\\N{U+2584}\");\n\t}\n\telse\n\t{ if (this.version < VERSION_METADATA)\n\t {\n\t\tif (data.startsWith(\"$$$\\n\"))\n\t\t data = data.substring(data.indexOf(\"\\n$$$\\n\") + 5);\n\t }\n\t if (this.version < VERSION_HORIZONTAL_JUSTIFICATION)\n\t {\n\t\tdatabuf = new StringBuilder();\n\t\tint pos = data.indexOf(\"\\n$$$\\n\");\n\t\tpos += pos < 0 ? 1 : 5;\n\t\tdatabuf.append(data.substring(0, pos));\n\t\tStringBuilder dollarbuf = null;\n\t\tboolean esc = false;\n\t\tfor (int i = 0, n = data.length(); i < n;)\n\t\t{\n\t\t char c = data.charAt(i++);\n\t\t if (dollarbuf != null)\n\t\t {\n\t\t\tdollarbuf.append(c);\n\t\t\tif (esc || (c == '\\033'))\n\t\t\t esc ^= true;\n\t\t\telse if (c == '$')\n\t\t\t{\n\t\t\t String dollar = dollarbuf.toString();\n\t\t\t dollarbuf = null;\n\t\t\t if (dollar.startsWith(\"$balloon\") == false)\n\t\t\t\tdatabuf.append(dollar);\n\t\t\t else\n\t\t\t { databuf.append(\"$balloon\");\n\t\t\t\tdollar = dollar.substring(8);\n\t\t\t\tif (dollar.contains(\"l\")) dollar = dollar.substring(dollar.indexOf('l') + 1);\n\t\t\t\telse if (dollar.contains(\"r\")) dollar = dollar.substring(dollar.indexOf('r') + 1);\n\t\t\t\telse if (dollar.contains(\"c\")) dollar = dollar.substring(dollar.indexOf('c') + 1);\n\t\t\t\tdatabuf.append(dollar);\n\t\t\t} }\n\t\t }\n\t\t else if (c == '$')\n\t\t\tdollarbuf = new StringBuilder(\"$\");\n\t\t else\n\t\t\tdatabuf.append(c);\n\t\t}\n\t\tdata = databuf.toString();\n\t }\n\t}\n\tif (resetpalette != null)\n\t data += resetpalette.toString();\n\tif (this.escesc)\n\t data = data.replace(\"\\033\", \"\\\\e\");\n\tOutputStream out = System.out;\n\tif (this.file != null)\n\t out = new FileOutputStream(this.file); \n\tout.write(data.getBytes(\"UTF-8\"));\n\tout.flush();\n\tif (out != System.out)\n\t out.close();\n }\n"} {"input": " public Element processTag(Element ele, Attributes attrs)\n {\n String typeAttr = attrs.getValue(\"type\"); \n if (\"variant\".equals(typeAttr)) \n {\n Element seg = OSISUtil.factory().createSeg();\n seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.VARIANT_TYPE);\n String classAttr = attrs.getValue(\"class\"); \n if (classAttr != null)\n {\n seg.setAttribute(OSISUtil.OSIS_ATTR_SUBTYPE, OSISUtil.VARIANT_CLASS + classAttr);\n }\n if (ele != null)\n {\n ele.addContent(seg);\n }\n return seg;\n }\n Element div = OSISUtil.factory().createDiv();\n if (ele != null)\n {\n ele.addContent(div);\n }\n return div;\n }\n", "output": " public Element processTag(Element ele, Attributes attrs)\n {\n String typeAttr = attrs.getValue(\"type\"); \n if (\"variant\".equals(typeAttr)) \n {\n Element seg = OSISUtil.factory().createSeg();\n seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.VARIANT_TYPE);\n String classAttr = attrs.getValue(\"class\"); \n if (classAttr != null)\n {\n seg.setAttribute(OSISUtil.OSIS_ATTR_SUBTYPE, OSISUtil.VARIANT_CLASS + '-' + classAttr);\n }\n if (ele != null)\n {\n ele.addContent(seg);\n }\n return seg;\n }\n Element div = OSISUtil.factory().createDiv();\n if (ele != null)\n {\n ele.addContent(div);\n }\n return div;\n }\n"} {"input": " public void configure(final IOCProcessingContext context, final InjectorFactory injectorFactory,\n final IOCProcessorFactory procFactory) {\n context.addSingletonScopeAnnotation(ApplicationScoped.class);\n procFactory.registerHandler(Produces.class, new JSR330AnnotationHandler() {\n @Override\n public Set checkDependencies(DependencyControl control, final InjectableInstance instance, Produces annotation,\n final IOCProcessingContext context) {\n switch (instance.getTaskType()) {\n case Type:\n break;\n case PrivateField:\n case PrivateMethod:\n instance.ensureMemberExposed(PrivateAccessType.Write);\n }\n injectorFactory.addInjector(new Injector() {\n {\n super.qualifyingMetadata = JSR299QualifyingMetadata.createFromAnnotations(instance.getQualifiers());\n this.provider = true;\n this.enclosingType = instance.getEnclosingType();\n if (injectorFactory.getInjectionContext().isInjectorRegistered(enclosingType, qualifyingMetadata)) {\n setInjected(true);\n }\n else {\n context.registerTypeDiscoveryListener(new TypeDiscoveryListener() {\n @Override\n public void onDiscovery(IOCProcessingContext context, InjectionPoint injectionPoint) {\n if (injectionPoint.getEnclosingType().equals(enclosingType)) {\n setInjected(true);\n }\n }\n });\n }\n }\n @Override\n public Statement instantiateOnly(InjectionContext injectContext, InjectableInstance injectableInstance) {\n return instance.getValueStatement();\n }\n @Override\n public Statement getType(InjectionContext injectContext, InjectableInstance injectableInstance) {\n return instance.getValueStatement();\n }\n @Override\n public boolean isSingleton() {\n return false;\n }\n @Override\n public boolean isPseudo() {\n return false;\n }\n @Override\n public String getVarName() {\n return null;\n }\n @Override\n public MetaClass getInjectedType() {\n switch (instance.getTaskType()) {\n case StaticMethod:\n case PrivateMethod:\n case Method:\n return instance.getMethod().getReturnType();\n case PrivateField:\n case Field:\n return instance.getField().getType();\n default:\n return null;\n }\n }\n });\n control.masqueradeAs(instance.getElementTypeOrMethodReturnType());\n return Collections.singleton(new SortUnit(instance.getEnclosingType(), true));\n }\n @Override\n public boolean handle(final InjectableInstance instance, final Produces annotation,\n final IOCProcessingContext context) {\n return true;\n }\n }, Rule.before(EntryPoint.class, ApplicationScoped.class, Singleton.class));\n procFactory.registerHandler(ApplicationScoped.class, new JSR330AnnotationHandler() {\n public boolean handle(InjectableInstance instance, ApplicationScoped annotation, IOCProcessingContext context) {\n InjectionContext injectionContext = injectorFactory.getInjectionContext();\n TypeInjector i = (TypeInjector) instance.getInjector();\n i.setSingleton(true);\n i.getType(injectionContext, null);\n return true;\n }\n });\n procFactory.registerHandler(Dependent.class, new JSR330AnnotationHandler() {\n public boolean handle(InjectableInstance instance, Dependent annotation, IOCProcessingContext context) {\n InjectionContext injectionContext = injectorFactory.getInjectionContext();\n TypeInjector i = (TypeInjector) instance.getInjector();\n i.getType(injectionContext, null);\n return true;\n }\n });\n if (context.getGeneratorContext() != null && context.getGeneratorContext().getTypeOracle() != null) {\n for (JPackage pkg : context.getGeneratorContext().getTypeOracle().getPackages()) {\n TypeScan:\n for (JClassType type : pkg.getTypes()) {\n if (type.isAbstract() || type.isInterface() != null\n || type.getQualifiedSourceName().startsWith(\"java.\")) continue;\n if (!type.isDefaultInstantiable()) {\n boolean hasInjectableConstructor = false;\n for (JConstructor c : type.getConstructors()) {\n if (c.isAnnotationPresent(Inject.class)) {\n hasInjectableConstructor = true;\n break;\n }\n }\n if (!hasInjectableConstructor) {\n continue;\n }\n }\n for (Annotation a : type.getAnnotations()) {\n Class annoClass = a.annotationType();\n if (annoClass.isAnnotationPresent(Scope.class)\n || annoClass.isAnnotationPresent(NormalScope.class)) {\n continue TypeScan;\n }\n }\n MetaClass metaClass = GWTClass.newInstance(type.getOracle(), type);\n if (injectorFactory.hasType(metaClass)) {\n continue;\n }\n injectorFactory.addPsuedoScopeForType(metaClass);\n }\n }\n }\n }\n", "output": " public void configure(final IOCProcessingContext context, final InjectorFactory injectorFactory,\n final IOCProcessorFactory procFactory) {\n context.addSingletonScopeAnnotation(ApplicationScoped.class);\n procFactory.registerHandler(Produces.class, new JSR330AnnotationHandler() {\n @Override\n public Set checkDependencies(DependencyControl control, final InjectableInstance instance, Produces annotation,\n final IOCProcessingContext context) {\n switch (instance.getTaskType()) {\n case Type:\n break;\n case PrivateField:\n case PrivateMethod:\n instance.ensureMemberExposed(PrivateAccessType.Read);\n }\n injectorFactory.addInjector(new Injector() {\n {\n super.qualifyingMetadata = JSR299QualifyingMetadata.createFromAnnotations(instance.getQualifiers());\n this.provider = true;\n this.enclosingType = instance.getEnclosingType();\n if (injectorFactory.getInjectionContext().isInjectorRegistered(enclosingType, qualifyingMetadata)) {\n setInjected(true);\n }\n else {\n context.registerTypeDiscoveryListener(new TypeDiscoveryListener() {\n @Override\n public void onDiscovery(IOCProcessingContext context, InjectionPoint injectionPoint) {\n if (injectionPoint.getEnclosingType().equals(enclosingType)) {\n setInjected(true);\n }\n }\n });\n }\n }\n @Override\n public Statement instantiateOnly(InjectionContext injectContext, InjectableInstance injectableInstance) {\n return instance.getValueStatement();\n }\n @Override\n public Statement getType(InjectionContext injectContext, InjectableInstance injectableInstance) {\n return instance.getValueStatement();\n }\n @Override\n public boolean isSingleton() {\n return false;\n }\n @Override\n public boolean isPseudo() {\n return false;\n }\n @Override\n public String getVarName() {\n return null;\n }\n @Override\n public MetaClass getInjectedType() {\n switch (instance.getTaskType()) {\n case StaticMethod:\n case PrivateMethod:\n case Method:\n return instance.getMethod().getReturnType();\n case PrivateField:\n case Field:\n return instance.getField().getType();\n default:\n return null;\n }\n }\n });\n control.masqueradeAs(instance.getElementTypeOrMethodReturnType());\n return Collections.singleton(new SortUnit(instance.getEnclosingType(), true));\n }\n @Override\n public boolean handle(final InjectableInstance instance, final Produces annotation,\n final IOCProcessingContext context) {\n return true;\n }\n }, Rule.before(EntryPoint.class, ApplicationScoped.class, Singleton.class));\n procFactory.registerHandler(ApplicationScoped.class, new JSR330AnnotationHandler() {\n public boolean handle(InjectableInstance instance, ApplicationScoped annotation, IOCProcessingContext context) {\n InjectionContext injectionContext = injectorFactory.getInjectionContext();\n TypeInjector i = (TypeInjector) instance.getInjector();\n i.setSingleton(true);\n i.getType(injectionContext, null);\n return true;\n }\n });\n procFactory.registerHandler(Dependent.class, new JSR330AnnotationHandler() {\n public boolean handle(InjectableInstance instance, Dependent annotation, IOCProcessingContext context) {\n InjectionContext injectionContext = injectorFactory.getInjectionContext();\n TypeInjector i = (TypeInjector) instance.getInjector();\n i.getType(injectionContext, null);\n return true;\n }\n });\n if (context.getGeneratorContext() != null && context.getGeneratorContext().getTypeOracle() != null) {\n for (JPackage pkg : context.getGeneratorContext().getTypeOracle().getPackages()) {\n TypeScan:\n for (JClassType type : pkg.getTypes()) {\n if (type.isAbstract() || type.isInterface() != null\n || type.getQualifiedSourceName().startsWith(\"java.\")) continue;\n if (!type.isDefaultInstantiable()) {\n boolean hasInjectableConstructor = false;\n for (JConstructor c : type.getConstructors()) {\n if (c.isAnnotationPresent(Inject.class)) {\n hasInjectableConstructor = true;\n break;\n }\n }\n if (!hasInjectableConstructor) {\n continue;\n }\n }\n for (Annotation a : type.getAnnotations()) {\n Class annoClass = a.annotationType();\n if (annoClass.isAnnotationPresent(Scope.class)\n || annoClass.isAnnotationPresent(NormalScope.class)) {\n continue TypeScan;\n }\n }\n MetaClass metaClass = GWTClass.newInstance(type.getOracle(), type);\n if (injectorFactory.hasType(metaClass)) {\n continue;\n }\n injectorFactory.addPsuedoScopeForType(metaClass);\n }\n }\n }\n }\n"} {"input": "\tpublic void actionPerformed(ActionEvent e) {\n\t\tif(e.getSource() == nameSort)\n\t\t{\n\t\t\tString temp;\n\t\t\tfor(int i = 0; i < lists.size(); i++)\n\t\t\t{\n\t\t\t\tfor(int j = 1; j < lists.size()-i; j++)\n\t\t\t\t{\n\t\t\t\t\tif(lists.get(j-1).getText().compareTo(lists.get(j).getText()) > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp = lists.get(j-1).getText();\n\t\t\t\t\t\tlists.get(j-1).setText(lists.get(j).getText());\n\t\t\t\t\t\tlists.get(j).setText(temp);\n\t\t\t\t\t\ttemp = amounts.get(j-1).getText();\n\t\t\t\t\t\tamounts.get(j-1).setText(amounts.get(j).getText());\n\t\t\t\t\t\tamounts.get(j).setText(temp);\n\t\t\t\t\t\ttemp = dates.get(j-1).getText();\n\t\t\t\t\t\tdates.get(j-1).setText(dates.get(j).getText());\n\t\t\t\t\t\tdates.get(j).setText(temp);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t}\n\t\tif(e.getSource() == dateSort)\n\t\t{\n\t\t\tString temp;\n\t\t\tfor(int i = 0; i < lists.size(); i++)\n\t\t\t{\n\t\t\t\tfor(int j = 1; j < lists.size()-i; j++)\n\t\t\t\t{\n\t\t\t\t\tString first = dates.get(j-1).getText();\n\t\t\t\t\tString second = dates.get(j).getText();\n\t\t\t\t\tif(first.substring(first.length()-4).compareTo(second.substring(second.length()-4)) > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tInteger monthOne = new Integer(first.substring(0, first.indexOf('/')));\n\t\t\t\t\t\tInteger monthTwo = new Integer(second.substring(0, second.indexOf('/')));\n\t\t\t\t\t\tif(monthOne.compareTo(monthTwo) > 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint diff = monthTwo.intValue() - monthOne.intValue();\n\t\t\t\t\t\t\tboolean doSwitch = false;\n\t\t\t\t\t\t\tInteger dayOne = new Integer(first.substring(first.indexOf('/')+1, first.indexOf('/', first.indexOf('/')+1)));\n\t\t\t\t\t\t\tInteger dayTwo = new Integer(second.substring(second.indexOf('/')+1, second.indexOf('/', second.indexOf('/')+1)));\n\t\t\t\t\t\t\tif(diff > 0)\n\t\t\t\t\t\t\t\tdoSwitch = true;\n\t\t\t\t\t\t\telse if(dayOne < dayTwo)\n\t\t\t\t\t\t\t\tdoSwitch = true;\n\t\t\t\t\t\t\tif(doSwitch)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttemp = lists.get(j-1).getText();\n\t\t\t\t\t\t\t\tlists.get(j-1).setText(lists.get(j).getText());\n\t\t\t\t\t\t\t\tlists.get(j).setText(temp);\n\t\t\t\t\t\t\t\ttemp = amounts.get(j-1).getText();\n\t\t\t\t\t\t\t\tamounts.get(j-1).setText(amounts.get(j).getText());\n\t\t\t\t\t\t\t\tamounts.get(j).setText(temp);\n\t\t\t\t\t\t\t\ttemp = dates.get(j-1).getText();\n\t\t\t\t\t\t\t\tdates.get(j-1).setText(dates.get(j).getText());\n\t\t\t\t\t\t\t\tdates.get(j).setText(temp);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t}\n\t\tif(e.getSource() == amountSort)\n\t\t{\n\t\t\tString temp;\n\t\t\tfor(int i = 0; i < lists.size(); i++)\n\t\t\t{\n\t\t\t\tfor(int j = 1; j < lists.size()-i; j++)\n\t\t\t\t{\n\t\t\t\t\tDouble d1 = new Double(amounts.get(j-1).getText().substring(1));\n\t\t\t\t\tDouble d2 = new Double(amounts.get(j).getText().substring(1));\n\t\t\t\t\tif(d1.doubleValue() > d2.doubleValue())\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp = lists.get(j-1).getText();\n\t\t\t\t\t\tlists.get(j-1).setText(lists.get(j).getText());\n\t\t\t\t\t\tlists.get(j).setText(temp);\n\t\t\t\t\t\ttemp = amounts.get(j-1).getText();\n\t\t\t\t\t\tamounts.get(j-1).setText(amounts.get(j).getText());\n\t\t\t\t\t\tamounts.get(j).setText(temp);\n\t\t\t\t\t\ttemp = dates.get(j-1).getText();\n\t\t\t\t\t\tdates.get(j-1).setText(dates.get(j).getText());\n\t\t\t\t\t\tdates.get(j).setText(temp);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t}\n\t}\n", "output": "\tpublic void actionPerformed(ActionEvent e) {\n\t\tif(e.getSource() == nameSort)\n\t\t{\n\t\t\tString temp;\n\t\t\tfor(int i = 0; i < lists.size(); i++)\n\t\t\t{\n\t\t\t\tfor(int j = 1; j < lists.size()-i; j++)\n\t\t\t\t{\n\t\t\t\t\tif(lists.get(j-1).getText().compareTo(lists.get(j).getText()) > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp = lists.get(j-1).getText();\n\t\t\t\t\t\tlists.get(j-1).setText(lists.get(j).getText());\n\t\t\t\t\t\tlists.get(j).setText(temp);\n\t\t\t\t\t\ttemp = amounts.get(j-1).getText();\n\t\t\t\t\t\tamounts.get(j-1).setText(amounts.get(j).getText());\n\t\t\t\t\t\tamounts.get(j).setText(temp);\n\t\t\t\t\t\ttemp = dates.get(j-1).getText();\n\t\t\t\t\t\tdates.get(j-1).setText(dates.get(j).getText());\n\t\t\t\t\t\tdates.get(j).setText(temp);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t}\n\t\tif(e.getSource() == dateSort)\n\t\t{\n\t\t\tString temp;\n\t\t\tfor(int i = 0; i < lists.size(); i++)\n\t\t\t{\n\t\t\t\tfor(int j = 1; j < lists.size()-i; j++)\n\t\t\t\t{\n\t\t\t\t\tString first = dates.get(j-1).getText();\n\t\t\t\t\tString second = dates.get(j).getText();\n\t\t\t\t\tif(first.substring(first.length()-4).compareTo(second.substring(second.length()-4)) >= 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tInteger monthOne = new Integer(first.substring(0, first.indexOf('/')));\n\t\t\t\t\t\tInteger monthTwo = new Integer(second.substring(0, second.indexOf('/')));\n\t\t\t\t\t\tif(monthOne.compareTo(monthTwo) >= 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint diff = monthTwo.intValue() - monthOne.intValue();\n\t\t\t\t\t\t\tboolean doSwitch = false;\n\t\t\t\t\t\t\tInteger dayOne = new Integer(first.substring(first.indexOf('/')+1, first.indexOf('/', first.indexOf('/')+1)));\n\t\t\t\t\t\t\tInteger dayTwo = new Integer(second.substring(second.indexOf('/')+1, second.indexOf('/', second.indexOf('/')+1)));\n\t\t\t\t\t\t\tif(diff > 0)\n\t\t\t\t\t\t\t\tdoSwitch = true;\n\t\t\t\t\t\t\telse if(dayOne < dayTwo)\n\t\t\t\t\t\t\t\tdoSwitch = true;\n\t\t\t\t\t\t\tif(doSwitch)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttemp = lists.get(j-1).getText();\n\t\t\t\t\t\t\t\tlists.get(j-1).setText(lists.get(j).getText());\n\t\t\t\t\t\t\t\tlists.get(j).setText(temp);\n\t\t\t\t\t\t\t\ttemp = amounts.get(j-1).getText();\n\t\t\t\t\t\t\t\tamounts.get(j-1).setText(amounts.get(j).getText());\n\t\t\t\t\t\t\t\tamounts.get(j).setText(temp);\n\t\t\t\t\t\t\t\ttemp = dates.get(j-1).getText();\n\t\t\t\t\t\t\t\tdates.get(j-1).setText(dates.get(j).getText());\n\t\t\t\t\t\t\t\tdates.get(j).setText(temp);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t}\n\t\tif(e.getSource() == amountSort)\n\t\t{\n\t\t\tString temp;\n\t\t\tfor(int i = 0; i < lists.size(); i++)\n\t\t\t{\n\t\t\t\tfor(int j = 1; j < lists.size()-i; j++)\n\t\t\t\t{\n\t\t\t\t\tDouble d1 = new Double(amounts.get(j-1).getText().substring(1));\n\t\t\t\t\tDouble d2 = new Double(amounts.get(j).getText().substring(1));\n\t\t\t\t\tif(d1.doubleValue() > d2.doubleValue())\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp = lists.get(j-1).getText();\n\t\t\t\t\t\tlists.get(j-1).setText(lists.get(j).getText());\n\t\t\t\t\t\tlists.get(j).setText(temp);\n\t\t\t\t\t\ttemp = amounts.get(j-1).getText();\n\t\t\t\t\t\tamounts.get(j-1).setText(amounts.get(j).getText());\n\t\t\t\t\t\tamounts.get(j).setText(temp);\n\t\t\t\t\t\ttemp = dates.get(j-1).getText();\n\t\t\t\t\t\tdates.get(j-1).setText(dates.get(j).getText());\n\t\t\t\t\t\tdates.get(j).setText(temp);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\trepaint();\n\t\t}\n\t}\n"} {"input": " public MakefileHolder createMakefileFromArtifacts( File outputDir, Set artifacts,\n String ndkArchitecture, String defaultNDKArchitecture,\n boolean useHeaderArchives )\n throws IOException, MojoExecutionException\n {\n final StringBuilder makeFile = new StringBuilder( \"# Generated by Android Maven Plugin\\n\" );\n final List includeDirectories = new ArrayList();\n makeFile.append( \"$(shell echo \\\"LOCAL_C_INCLUDES=$(LOCAL_C_INCLUDES)\\\" > $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_PATH=$(LOCAL_PATH)\\\" >> $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_MODULE_FILENAME=$(LOCAL_MODULE_FILENAME)\\\" >> $(\"\n + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_MODULE=$(LOCAL_MODULE)\\\" >> $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_CFLAGS=$(LOCAL_CFLAGS)\\\" >> $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n if ( ! artifacts.isEmpty() )\n {\n for ( Artifact artifact : artifacts )\n {\n final String architecture = NativeHelper.extractArchitectureFromArtifact( artifact,\n defaultNDKArchitecture );\n makeFile.append( '\\n' );\n makeFile.append( \"ifeq ($(TARGET_ARCH_ABI),\" ).append( architecture ).append( \")\\n\" );\n makeFile.append( \"#\\n\" );\n makeFile.append( \"# Group ID: \" );\n makeFile.append( artifact.getGroupId() );\n makeFile.append( '\\n' );\n makeFile.append( \"# Artifact ID: \" );\n makeFile.append( artifact.getArtifactId() );\n makeFile.append( '\\n' );\n makeFile.append( \"# Artifact Type: \" );\n makeFile.append( artifact.getType() );\n makeFile.append( '\\n' );\n makeFile.append( \"# Version: \" );\n makeFile.append( artifact.getVersion() );\n makeFile.append( '\\n' );\n makeFile.append( \"include $(CLEAR_VARS)\" );\n makeFile.append( '\\n' );\n makeFile.append( \"LOCAL_MODULE := \" );\n makeFile.append( artifact.getArtifactId() );\n makeFile.append( '\\n' );\n final boolean apklibStatic = addLibraryDetails( makeFile, outputDir, artifact, ndkArchitecture );\n if ( useHeaderArchives )\n {\n try\n {\n Artifact harArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),\n artifact.getVersion(), artifact.getScope(), \"har\", artifact.getClassifier(),\n artifact.getArtifactHandler() );\n final Artifact resolvedHarArtifact = AetherHelper\n .resolveArtifact( harArtifact, repoSystem, repoSession, projectRepos );\n File includeDir = new File( System.getProperty( \"java.io.tmpdir\" ),\n \"android_maven_plugin_native_includes\" + System.currentTimeMillis() + \"_\"\n + resolvedHarArtifact.getArtifactId() );\n includeDir.deleteOnExit();\n includeDirectories.add( includeDir );\n JarHelper.unjar( new JarFile( resolvedHarArtifact.getFile() ), includeDir,\n new JarHelper.UnjarListener()\n {\n @Override\n public boolean include( JarEntry jarEntry )\n {\n return ! jarEntry.getName().startsWith( \"META-INF\" );\n }\n } );\n makeFile.append( \"LOCAL_EXPORT_C_INCLUDES := \" );\n final String str = includeDir.getAbsolutePath();\n makeFile.append( str );\n makeFile.append( '\\n' );\n if ( log.isDebugEnabled() )\n {\n Collection includes = FileUtils.listFiles( includeDir,\n TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE );\n log.debug( \"Listing LOCAL_EXPORT_C_INCLUDES for \" + artifact.getId() + \": \" + includes );\n }\n }\n catch ( Exception e )\n {\n throw new MojoExecutionException(\n \"Error while resolving header archive file for: \" + artifact.getArtifactId(), e );\n }\n }\n if ( \"a\".equals( artifact.getType() ) || apklibStatic )\n {\n makeFile.append( \"include $(PREBUILT_STATIC_LIBRARY)\\n\" );\n }\n else\n {\n makeFile.append( \"include $(PREBUILT_SHARED_LIBRARY)\\n\" );\n }\n makeFile.append( \"endif #\" ).append( artifact.getClassifier() ).append( '\\n' );\n makeFile.append( '\\n' );\n }\n }\n return new MakefileHolder( includeDirectories, makeFile.toString() );\n }\n", "output": " public MakefileHolder createMakefileFromArtifacts( File outputDir, Set artifacts,\n String ndkArchitecture, String defaultNDKArchitecture,\n boolean useHeaderArchives )\n throws IOException, MojoExecutionException\n {\n final StringBuilder makeFile = new StringBuilder( \"# Generated by Android Maven Plugin\\n\" );\n final List includeDirectories = new ArrayList();\n makeFile.append( \"$(shell echo \\\"LOCAL_C_INCLUDES=$(LOCAL_C_INCLUDES)\\\" > $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_PATH=$(LOCAL_PATH)\\\" >> $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_MODULE_FILENAME=$(LOCAL_MODULE_FILENAME)\\\" >> $(\"\n + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_MODULE=$(LOCAL_MODULE)\\\" >> $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n makeFile.append( \"$(shell echo \\\"LOCAL_CFLAGS=$(LOCAL_CFLAGS)\\\" >> $(\" + MAKEFILE_CAPTURE_FILE + \"))\" );\n makeFile.append( '\\n' );\n if ( ! artifacts.isEmpty() )\n {\n for ( Artifact artifact : artifacts )\n {\n final String architecture = NativeHelper.extractArchitectureFromArtifact( artifact,\n defaultNDKArchitecture );\n makeFile.append( '\\n' );\n makeFile.append( \"ifeq ($(TARGET_ARCH_ABI),\" ).append( architecture ).append( \")\\n\" );\n makeFile.append( \"#\\n\" );\n makeFile.append( \"# Group ID: \" );\n makeFile.append( artifact.getGroupId() );\n makeFile.append( '\\n' );\n makeFile.append( \"# Artifact ID: \" );\n makeFile.append( artifact.getArtifactId() );\n makeFile.append( '\\n' );\n makeFile.append( \"# Artifact Type: \" );\n makeFile.append( artifact.getType() );\n makeFile.append( '\\n' );\n makeFile.append( \"# Version: \" );\n makeFile.append( artifact.getVersion() );\n makeFile.append( '\\n' );\n makeFile.append( \"include $(CLEAR_VARS)\" );\n makeFile.append( '\\n' );\n makeFile.append( \"LOCAL_MODULE := \" );\n makeFile.append( artifact.getArtifactId() );\n makeFile.append( '\\n' );\n final boolean apklibStatic = addLibraryDetails( makeFile, outputDir, artifact, ndkArchitecture );\n if ( useHeaderArchives )\n {\n try\n {\n Artifact harArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),\n artifact.getVersion(), artifact.getScope(), \"har\", architecture,\n artifact.getArtifactHandler() );\n final Artifact resolvedHarArtifact = AetherHelper\n .resolveArtifact( harArtifact, repoSystem, repoSession, projectRepos );\n File includeDir = new File( System.getProperty( \"java.io.tmpdir\" ),\n \"android_maven_plugin_native_includes\" + System.currentTimeMillis() + \"_\"\n + resolvedHarArtifact.getArtifactId() );\n includeDir.deleteOnExit();\n includeDirectories.add( includeDir );\n JarHelper.unjar( new JarFile( resolvedHarArtifact.getFile() ), includeDir,\n new JarHelper.UnjarListener()\n {\n @Override\n public boolean include( JarEntry jarEntry )\n {\n return ! jarEntry.getName().startsWith( \"META-INF\" );\n }\n } );\n makeFile.append( \"LOCAL_EXPORT_C_INCLUDES := \" );\n final String str = includeDir.getAbsolutePath();\n makeFile.append( str );\n makeFile.append( '\\n' );\n if ( log.isDebugEnabled() )\n {\n Collection includes = FileUtils.listFiles( includeDir,\n TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE );\n log.debug( \"Listing LOCAL_EXPORT_C_INCLUDES for \" + artifact.getId() + \": \" + includes );\n }\n }\n catch ( Exception e )\n {\n throw new MojoExecutionException(\n \"Error while resolving header archive file for: \" + artifact.getArtifactId(), e );\n }\n }\n if ( \"a\".equals( artifact.getType() ) || apklibStatic )\n {\n makeFile.append( \"include $(PREBUILT_STATIC_LIBRARY)\\n\" );\n }\n else\n {\n makeFile.append( \"include $(PREBUILT_SHARED_LIBRARY)\\n\" );\n }\n makeFile.append( \"endif #\" ).append( artifact.getClassifier() ).append( '\\n' );\n makeFile.append( '\\n' );\n }\n }\n return new MakefileHolder( includeDirectories, makeFile.toString() );\n }\n"} {"input": "\tpublic PElementPropertySource(IPElement pelement) {\n\t\tthis.pelement = pelement;\n\t\tIAttributeDefinition[] attrDefs = pelement.getAttributeKeys();\n String[] keys = new String[attrDefs.length];\n for (int i = 0; i < attrDefs.length; i++) {\n \tif (attrDefs[i].getDisplay()) {\n \t\tkeys[i] = attrDefs[i].getId();\n \t}\n }\n for (int i = 0; i < keys.length; ++i) {\n addDescriptor(new PropertyDescriptor(keys[i], attrDefs[i].getName()));\n }\n\t}\n", "output": "\tpublic PElementPropertySource(IPElement pelement) {\n\t\tthis.pelement = pelement;\n\t\tIAttributeDefinition[] attrDefs = pelement.getAttributeKeys();\n String[] keys = new String[attrDefs.length];\n for (int i = 0; i < attrDefs.length; i++) {\n \tif (attrDefs[i].getDisplay()) {\n \t\tkeys[i] = attrDefs[i].getId();\n addDescriptor(new PropertyDescriptor(keys[i], attrDefs[i].getName()));\n \t}\n }\n\t}\n"} {"input": " public void initialize() {\n Player player = getCanvas().getClient().getMyPlayer();\n colonies = player.getColonies();\n Collections.sort(colonies, getCanvas().getClient().getClientOptions().getColonyComparator());\n reportPanel.setLayout(new HIGLayout(new int[] {780}, new int[] {0}));\n JTextPane textPane = new JTextPane();\n textPane.setOpaque(false);\n\ttextPane.setEditable(false);\n StyledDocument doc = textPane.getStyledDocument();\n defineStyles(doc);\n int numberUnitTypes = FreeCol.getSpecification().numberOfUnitTypes();\n int numberGoodsTypes = FreeCol.getSpecification().numberOfGoodsTypes();\n unitCount = new int[colonies.size()][numberUnitTypes];\n canTrain = new boolean[colonies.size()][numberUnitTypes];\n surplus = new int[colonies.size()][numberGoodsTypes];\n List goodsTypes = FreeCol.getSpecification().getGoodsTypeList();\n for (int index = 0; index < colonies.size(); index++) {\n Colony colony = colonies.get(index);\n for (Unit unit : colony.getUnitList()) {\n unitCount[index][unit.getType()]++;\n canTrain[index][unit.getType()] = colony.canTrain(unit.getUnitType());\n }\n for (GoodsType goodsType : goodsTypes) {\n surplus[index][goodsType.getIndex()] = colony.getProductionNetOf(goodsType);\n }\n }\n for (int index = 0; index < colonies.size(); index++) {\n Colony colony = colonies.get(index);\n try {\n StyleConstants.setComponent(doc.getStyle(\"button\"), createColonyButton(colony, true));\n doc.insertString(doc.getLength(), \" \", doc.getStyle(\"button\"));\n doc.insertString(doc.getLength(), \"\\n\\n\", doc.getStyle(\"regular\"));\n } catch(Exception e) {\n logger.warning(e.toString());\n }\n boolean[] expertWarning = new boolean[numberUnitTypes];\n boolean[] productionWarning = new boolean[numberGoodsTypes];\n boolean hasWarning = false;\n Iterator workLocationIterator = colony.getWorkLocationIterator();\n while (workLocationIterator.hasNext()) {\n WorkLocation workLocation = workLocationIterator.next();\n if (workLocation instanceof ColonyTile) {\n Unit unit = ((ColonyTile) workLocation).getUnit();\n if (unit != null) {\n GoodsType workType = unit.getWorkType();\n UnitType expert = FreeCol.getSpecification().getExpertForProducing(workType);\n int expertIndex = expert.getIndex();\n if (unitCount[index][expertIndex] == 0 && !expertWarning[expertIndex]) {\n addExpertWarning(doc, index, workType.getName(), expert);\n expertWarning[expertIndex] = true;\n hasWarning = true;\n }\n }\n } else {\n Building building = (Building) workLocation;\n GoodsType goodsType = building.getGoodsOutputType();\n UnitType expert = building.getExpertUnitType();\n int expertIndex = expert.getIndex();\n int goodsIndex = goodsType.getIndex();\n if (goodsType != null) {\n if (building.getFirstUnit() != null &&\n !expertWarning[expertIndex] &&\n unitCount[index][expertIndex] == 0) {\n addExpertWarning(doc, index, goodsType.getName(), expert);\n expertWarning[expertIndex] = true;\n hasWarning = true;\n }\n if (building.getProductionNextTurn() < building.getMaximumProduction() &&\n !productionWarning[goodsIndex]) {\n addProductionWarning(doc, index, goodsType, building.getGoodsInputType());\n productionWarning[goodsIndex] = true;\n hasWarning = true;\n }\n }\n }\n }\n if (!hasWarning) {\n try {\n doc.insertString(doc.getLength(), Messages.message(\"report.requirements.met\") + \"\\n\\n\",\n doc.getStyle(\"regular\"));\n } catch(Exception e) {\n logger.warning(e.toString());\n }\n }\n reportPanel.add(textPane, higConst.rc(1, 1));\n }\n textPane.setCaretPosition(0);\n }\n", "output": " public void initialize() {\n Player player = getCanvas().getClient().getMyPlayer();\n colonies = player.getColonies();\n Collections.sort(colonies, getCanvas().getClient().getClientOptions().getColonyComparator());\n reportPanel.setLayout(new HIGLayout(new int[] {780}, new int[] {0}));\n JTextPane textPane = new JTextPane();\n textPane.setOpaque(false);\n textPane.setEditable(false);\n StyledDocument doc = textPane.getStyledDocument();\n defineStyles(doc);\n int numberUnitTypes = FreeCol.getSpecification().numberOfUnitTypes();\n int numberGoodsTypes = FreeCol.getSpecification().numberOfGoodsTypes();\n unitCount = new int[colonies.size()][numberUnitTypes];\n canTrain = new boolean[colonies.size()][numberUnitTypes];\n surplus = new int[colonies.size()][numberGoodsTypes];\n List goodsTypes = FreeCol.getSpecification().getGoodsTypeList();\n for (int index = 0; index < colonies.size(); index++) {\n Colony colony = colonies.get(index);\n for (Unit unit : colony.getUnitList()) {\n unitCount[index][unit.getType()]++;\n canTrain[index][unit.getType()] = colony.canTrain(unit.getUnitType());\n }\n for (GoodsType goodsType : goodsTypes) {\n surplus[index][goodsType.getIndex()] = colony.getProductionNetOf(goodsType);\n }\n }\n for (int index = 0; index < colonies.size(); index++) {\n Colony colony = colonies.get(index);\n try {\n StyleConstants.setComponent(doc.getStyle(\"button\"), createColonyButton(colony, true));\n doc.insertString(doc.getLength(), \" \", doc.getStyle(\"button\"));\n doc.insertString(doc.getLength(), \"\\n\\n\", doc.getStyle(\"regular\"));\n } catch(Exception e) {\n logger.warning(e.toString());\n }\n boolean[] expertWarning = new boolean[numberUnitTypes];\n boolean[] productionWarning = new boolean[numberGoodsTypes];\n boolean hasWarning = false;\n Iterator workLocationIterator = colony.getWorkLocationIterator();\n while (workLocationIterator.hasNext()) {\n WorkLocation workLocation = workLocationIterator.next();\n if (workLocation instanceof ColonyTile) {\n Unit unit = ((ColonyTile) workLocation).getUnit();\n if (unit != null) {\n GoodsType workType = unit.getWorkType();\n UnitType expert = FreeCol.getSpecification().getExpertForProducing(workType);\n int expertIndex = expert.getIndex();\n if (unitCount[index][expertIndex] == 0 && !expertWarning[expertIndex]) {\n addExpertWarning(doc, index, workType.getName(), expert);\n expertWarning[expertIndex] = true;\n hasWarning = true;\n }\n }\n } else {\n Building building = (Building) workLocation;\n GoodsType goodsType = building.getGoodsOutputType();\n UnitType expert = building.getExpertUnitType();\n if (goodsType != null && expert!=null) {\n int expertIndex = expert.getIndex();\n if (building.getFirstUnit() != null &&\n !expertWarning[expertIndex] &&\n unitCount[index][expertIndex] == 0) {\n addExpertWarning(doc, index, goodsType.getName(), expert);\n expertWarning[expertIndex] = true;\n hasWarning = true;\n }\n }\n if (goodsType != null) {\n int goodsIndex = goodsType.getIndex();\n if (building.getProductionNextTurn() < building.getMaximumProduction() &&\n !productionWarning[goodsIndex]) {\n addProductionWarning(doc, index, goodsType, building.getGoodsInputType());\n productionWarning[goodsIndex] = true;\n hasWarning = true;\n }\n }\n }\n }\n if (!hasWarning) {\n try {\n doc.insertString(doc.getLength(), Messages.message(\"report.requirements.met\") + \"\\n\\n\",\n doc.getStyle(\"regular\"));\n } catch(Exception e) {\n logger.warning(e.toString());\n }\n }\n reportPanel.add(textPane, higConst.rc(1, 1));\n }\n textPane.setCaretPosition(0);\n }\n"} {"input": " private Modifications createModifications(TreeWalk treeWalk, RevCommit commit)\n throws IOException\n {\n Modifications modifications = null;\n treeWalk.reset();\n treeWalk.setRecursive(true);\n if (commit.getParentCount() > 0)\n {\n RevCommit parent = commit.getParent(0);\n RevTree tree = parent.getTree();\n if ((tree == null) && (revWalk != null))\n {\n revWalk.parseHeaders(parent);\n tree = parent.getTree();\n }\n if (tree != null)\n {\n treeWalk.addTree(tree);\n }\n else\n {\n if (logger.isTraceEnabled())\n {\n logger.trace(\"no parent tree at position 0 for commit {}\", commit);\n }\n treeWalk.addTree(new EmptyTreeIterator());\n }\n }\n else\n {\n if (logger.isTraceEnabled())\n {\n logger.trace(\"no parent available for commit {}\", commit);\n }\n treeWalk.addTree(new EmptyTreeIterator());\n }\n treeWalk.addTree(commit.getTree());\n List entries = DiffEntry.scan(treeWalk);\n for (DiffEntry e : entries)\n {\n if (!e.getOldId().equals(e.getNewId()))\n {\n if (modifications == null)\n {\n modifications = new Modifications();\n }\n appendModification(modifications, e);\n }\n }\n return modifications;\n }\n", "output": " private Modifications createModifications(TreeWalk treeWalk, RevCommit commit)\n throws IOException\n {\n Modifications modifications = null;\n treeWalk.reset();\n treeWalk.setRecursive(true);\n if (commit.getParentCount() > 0)\n {\n RevCommit parent = commit.getParent(0);\n RevTree tree = parent.getTree();\n if ((tree == null) && (revWalk != null))\n {\n revWalk.parseHeaders(parent);\n tree = parent.getTree();\n }\n if (tree != null)\n {\n treeWalk.addTree(tree);\n }\n else\n {\n if (logger.isTraceEnabled())\n {\n logger.trace(\"no parent tree at position 0 for commit {}\",\n commit.getName());\n }\n treeWalk.addTree(new EmptyTreeIterator());\n }\n }\n else\n {\n if (logger.isTraceEnabled())\n {\n logger.trace(\"no parent available for commit {}\", commit.getName());\n }\n treeWalk.addTree(new EmptyTreeIterator());\n }\n treeWalk.addTree(commit.getTree());\n List entries = DiffEntry.scan(treeWalk);\n for (DiffEntry e : entries)\n {\n if (!e.getOldId().equals(e.getNewId()))\n {\n if (modifications == null)\n {\n modifications = new Modifications();\n }\n appendModification(modifications, e);\n }\n }\n return modifications;\n }\n"} {"input": " protected void execute(\n ByteBuffer buffer,\n int blockLength,\n TargetTransportPort targetPort,\n Command command,\n ModePageRegistry modePageRegistry,\n InquiryDataRegistry inquiryDataRegistry) throws InterruptedException, SenseException\n {\n _logger.debug(\">>> executing task: \" + this);\n long capacity = this.getFileCapacity();\n TransferCDB cdb = (TransferCDB)command.getCommandDescriptorBlock();\n long lba = cdb.getLogicalBlockAddress();\n long transferLength = cdb.getTransferLength();\n if ( lba < 0 || transferLength < 0 || lba > capacity || (lba + transferLength) > capacity)\n {\n switch (cdb.getOperationCode())\n {\n case Read6.OPERATION_CODE:\n throw new LogicalBlockAddressOutOfRangeException(true, true, (byte)4, 1);\n default:\n throw new LogicalBlockAddressOutOfRangeException(true, true, 2);\n }\n }\n buffer = buffer.duplicate();\n buffer.position((int)(lba * blockLength));\n buffer.limit((int)(transferLength * blockLength));\n if ( ! this.writeData(buffer) )\n {\n throw new SynchronousDataTransferErrorException();\n }\n this.writeResponse(Status.GOOD, null);\n }\n", "output": " protected void execute(\n ByteBuffer buffer,\n int blockLength,\n TargetTransportPort targetPort,\n Command command,\n ModePageRegistry modePageRegistry,\n InquiryDataRegistry inquiryDataRegistry) throws InterruptedException, SenseException\n {\n _logger.debug(\">>> executing task: \" + this);\n long capacity = this.getFileCapacity();\n TransferCDB cdb = (TransferCDB)command.getCommandDescriptorBlock();\n long lba = cdb.getLogicalBlockAddress();\n long transferLength = cdb.getTransferLength();\n if ( lba < 0 || transferLength < 0 || lba > capacity || (lba + transferLength) > capacity)\n {\n switch (cdb.getOperationCode())\n {\n case Read6.OPERATION_CODE:\n throw new LogicalBlockAddressOutOfRangeException(true, true, (byte)4, 1);\n default:\n throw new LogicalBlockAddressOutOfRangeException(true, true, 2);\n }\n }\n buffer = buffer.duplicate();\n buffer.position((int)(lba * blockLength));\n buffer.limit((int)(transferLength * blockLength) + (int)(lba * blockLength));\n if ( ! this.writeData(buffer) )\n {\n throw new SynchronousDataTransferErrorException();\n }\n this.writeResponse(Status.GOOD, null);\n }\n"} {"input": "\tpublic PtuSettingsView(ClientFactory clientFactory, Arguments args) {\n\t\tfinal RemoteEventBus eventBus = clientFactory.getRemoteEventBus();\n\t\tadd(table);\n\t\tColumn active = new Column(\n\t\t\t\tnew ActiveCheckboxCell()) {\n\t\t\t@Override\n\t\t\tpublic Boolean getValue(String object) {\n\t\t\t\treturn activePtuIds.contains(object);\n\t\t\t}\t\t\t\n\t\t};\n\t\tactive.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\n\t\tactive.setSortable(true);\n\t\ttable.addColumn(active, \"Active\");\n\t\tColumn enabled = new Column(\n\t\t\t\tnew CheckboxCell()) {\n\t\t\t@Override\n\t\t\tpublic Boolean getValue(String object) {\n\t\t\t\treturn settings.isEnabled(object);\n\t\t\t}\n\t\t};\n\t\tenabled.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, Boolean value) {\n\t\t\t\tsettings.setEnabled(object, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\tenabled.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\n\t\tenabled.setSortable(true);\n\t\ttable.addColumn(enabled, \"Enabled\");\n\t\tColumn ptuId = new Column(\n\t\t\t\tnew TextCell()) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn object;\n\t\t\t}\n\t\t};\n\t\tptuId.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);\n\t\tptuId.setSortable(true);\n\t\ttable.addColumn(ptuId, \"PTU ID\");\n\t\tColumn name = new Column(\n\t\t\t\tnew TextInputSizeCell(30)) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getName(object);\n\t\t\t}\n\t\t};\n\t\tname.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setName(object, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\tname.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tname.setSortable(true);\n\t\ttable.addColumn(name, \"Name\");\n\t\tColumn dosimeter = new Column(\n\t\t\t\tnew DynamicSelectionCell(new StringList(\n\t\t\t\t\t\tdosimeterSerialNumbers))) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getDosimeterSerialNumber(object).toString();\n\t\t\t}\n\t\t};\n\t\tdosimeter.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setDosimeterSerialNumber(object,\n\t\t\t\t\t\tInteger.parseInt(value));\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\tdosimeter.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tdosimeter.setSortable(true);\n\t\ttable.addColumn(dosimeter, \"Dosimeter #\");\n\t\tColumn helmetUrl = new Column(\n\t\t\t\tnew TextInputSizeCell(50)) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getCameraUrl(object, CameraView.HELMET);\n\t\t\t}\n\t\t};\n\t\thelmetUrl.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setCameraUrl(object, CameraView.HELMET, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\thelmetUrl.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\thelmetUrl.setSortable(true);\n\t\ttable.addColumn(helmetUrl, \"Helmet Camera URL\");\n\t\tColumn handUrl = new Column(\n\t\t\t\tnew TextInputSizeCell(50)) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getCameraUrl(object, CameraView.HAND);\n\t\t\t}\n\t\t};\n\t\thandUrl.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setCameraUrl(object, CameraView.HAND, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\thandUrl.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\thandUrl.setSortable(true);\n\t\ttable.addColumn(handUrl, \"Hand Camera URL\");\n\t\tdataProvider.addDataDisplay(table);\n\t\tdataProvider.setList(new ArrayList());\n\t\tcolumnSortHandler = new ListHandler(dataProvider.getList());\n\t\tcolumnSortHandler.setComparator(ptuId, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn o1 != null ? o1.compareTo(o2) : -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(active, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn activePtuIds.contains(o1) ? activePtuIds.contains(o2) ? 0 : 1 : -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(enabled, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.isEnabled(o1).compareTo(settings.isEnabled(o2));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(name, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getName(o1).compareTo(settings.getName(o2));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(dosimeter, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getDosimeterSerialNumber(o1).compareTo(\n\t\t\t\t\t\tsettings.getDosimeterSerialNumber(o2));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(helmetUrl, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getCameraUrl(o1, CameraView.HELMET).compareTo(\n\t\t\t\t\t\tsettings.getCameraUrl(o2, CameraView.HELMET));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(handUrl, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getCameraUrl(o1, CameraView.HAND).compareTo(\n\t\t\t\t\t\tsettings.getCameraUrl(o2, CameraView.HAND));\n\t\t\t}\n\t\t});\n\t\ttable.addColumnSortHandler(columnSortHandler);\n\t\ttable.getColumnSortList().push(ptuId);\n\t\tPtuSettingsChangedEvent.subscribe(eventBus,\n\t\t\t\tnew PtuSettingsChangedEvent.Handler() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onPtuSettingsChanged(\n\t\t\t\t\t\t\tPtuSettingsChangedEvent event) {\n\t\t\t\t\t\tSystem.err.println(\"PTU Settings changed\");\n\t\t\t\t\t\tsettings = event.getPtuSettings();\n\t\t\t\t\t\tdataProvider.getList().clear();\n\t\t\t\t\t\tdataProvider.getList().addAll(settings.getPtuIds());\n\t\t\t\t\t\tupdate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\tPtuIdsChangedEvent.subscribe(eventBus,\n\t\t\t\tnew PtuIdsChangedEvent.Handler() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onPtuIdsChanged(PtuIdsChangedEvent event) {\n\t\t\t\t\t\tSystem.err.println(\"PTU IDS changed\");\n\t\t\t\t\t\tactivePtuIds = event.getPtuIds();\n\t\t\t\t\t\tupdate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\tDosimeterSerialNumbersChangedEvent.subscribe(eventBus,\n\t\t\t\tnew DosimeterSerialNumbersChangedEvent.Handler() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onDosimeterSerialNumbersChanged(\n\t\t\t\t\t\t\tDosimeterSerialNumbersChangedEvent event) {\n\t\t\t\t\t\tdosimeterSerialNumbers.clear();\n\t\t\t\t\t\tdosimeterSerialNumbers.addAll(event\n\t\t\t\t\t\t\t\t.getDosimeterSerialNumbers());\n\t\t\t\t\t\tSystem.err.println(\"DOSI changed \"\n\t\t\t\t\t\t\t\t+ dosimeterSerialNumbers.size());\n\t\t\t\t\t\tupdate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\tupdate();\n\t}\n", "output": "\tpublic PtuSettingsView(ClientFactory clientFactory, Arguments args) {\n\t\tfinal RemoteEventBus eventBus = clientFactory.getRemoteEventBus();\n\t\tadd(table);\n\t\tColumn active = new Column(\n\t\t\t\tnew ActiveCheckboxCell()) {\n\t\t\t@Override\n\t\t\tpublic Boolean getValue(String object) {\n\t\t\t\treturn activePtuIds.contains(object);\n\t\t\t}\t\t\t\n\t\t};\n\t\tactive.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\n\t\tactive.setSortable(true);\n\t\ttable.addColumn(active, \"Active\");\n\t\tColumn enabled = new Column(\n\t\t\t\tnew CheckboxCell()) {\n\t\t\t@Override\n\t\t\tpublic Boolean getValue(String object) {\n\t\t\t\treturn settings.isEnabled(object);\n\t\t\t}\n\t\t};\n\t\tenabled.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, Boolean value) {\n\t\t\t\tsettings.setEnabled(object, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\tenabled.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);\n\t\tenabled.setSortable(true);\n\t\ttable.addColumn(enabled, \"Enabled\");\n\t\tColumn ptuId = new Column(\n\t\t\t\tnew TextCell()) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn object;\n\t\t\t}\n\t\t};\n\t\tptuId.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tptuId.setSortable(true);\n\t\ttable.addColumn(ptuId, \"PTU ID\");\n\t\tColumn name = new Column(\n\t\t\t\tnew TextInputSizeCell(30)) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getName(object);\n\t\t\t}\n\t\t};\n\t\tname.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setName(object, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\tname.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tname.setSortable(true);\n\t\ttable.addColumn(name, \"Name\");\n\t\tColumn dosimeter = new Column(\n\t\t\t\tnew DynamicSelectionCell(new StringList(\n\t\t\t\t\t\tdosimeterSerialNumbers))) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getDosimeterSerialNumber(object).toString();\n\t\t\t}\n\t\t};\n\t\tdosimeter.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setDosimeterSerialNumber(object,\n\t\t\t\t\t\tInteger.parseInt(value));\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\tdosimeter.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\tdosimeter.setSortable(true);\n\t\ttable.addColumn(dosimeter, \"Dosimeter #\");\n\t\tColumn helmetUrl = new Column(\n\t\t\t\tnew TextInputSizeCell(50)) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getCameraUrl(object, CameraView.HELMET);\n\t\t\t}\n\t\t};\n\t\thelmetUrl.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setCameraUrl(object, CameraView.HELMET, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\thelmetUrl.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\thelmetUrl.setSortable(true);\n\t\ttable.addColumn(helmetUrl, \"Helmet Camera URL\");\n\t\tColumn handUrl = new Column(\n\t\t\t\tnew TextInputSizeCell(50)) {\n\t\t\t@Override\n\t\t\tpublic String getValue(String object) {\n\t\t\t\treturn settings.getCameraUrl(object, CameraView.HAND);\n\t\t\t}\n\t\t};\n\t\thandUrl.setFieldUpdater(new FieldUpdater() {\n\t\t\t@Override\n\t\t\tpublic void update(int index, String object, String value) {\n\t\t\t\tsettings.setCameraUrl(object, CameraView.HAND, value);\n\t\t\t\tfireSettingsChangedEvent(eventBus, settings);\n\t\t\t}\n\t\t});\n\t\thandUrl.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\n\t\thandUrl.setSortable(true);\n\t\ttable.addColumn(handUrl, \"Hand Camera URL\");\n\t\tdataProvider.addDataDisplay(table);\n\t\tdataProvider.setList(new ArrayList());\n\t\tcolumnSortHandler = new ListHandler(dataProvider.getList());\n\t\tcolumnSortHandler.setComparator(ptuId, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn o1 != null ? o1.compareTo(o2) : -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(active, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn activePtuIds.contains(o1) ? activePtuIds.contains(o2) ? 0 : 1 : -1;\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(enabled, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.isEnabled(o1).compareTo(settings.isEnabled(o2));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(name, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getName(o1).compareTo(settings.getName(o2));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(dosimeter, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getDosimeterSerialNumber(o1).compareTo(\n\t\t\t\t\t\tsettings.getDosimeterSerialNumber(o2));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(helmetUrl, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getCameraUrl(o1, CameraView.HELMET).compareTo(\n\t\t\t\t\t\tsettings.getCameraUrl(o2, CameraView.HELMET));\n\t\t\t}\n\t\t});\n\t\tcolumnSortHandler.setComparator(handUrl, new Comparator() {\n\t\t\tpublic int compare(String o1, String o2) {\n\t\t\t\treturn settings.getCameraUrl(o1, CameraView.HAND).compareTo(\n\t\t\t\t\t\tsettings.getCameraUrl(o2, CameraView.HAND));\n\t\t\t}\n\t\t});\n\t\ttable.addColumnSortHandler(columnSortHandler);\n\t\ttable.getColumnSortList().push(ptuId);\n\t\tPtuSettingsChangedEvent.subscribe(eventBus,\n\t\t\t\tnew PtuSettingsChangedEvent.Handler() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onPtuSettingsChanged(\n\t\t\t\t\t\t\tPtuSettingsChangedEvent event) {\n\t\t\t\t\t\tSystem.err.println(\"PTU Settings changed\");\n\t\t\t\t\t\tsettings = event.getPtuSettings();\n\t\t\t\t\t\tdataProvider.getList().clear();\n\t\t\t\t\t\tdataProvider.getList().addAll(settings.getPtuIds());\n\t\t\t\t\t\tupdate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\tPtuIdsChangedEvent.subscribe(eventBus,\n\t\t\t\tnew PtuIdsChangedEvent.Handler() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onPtuIdsChanged(PtuIdsChangedEvent event) {\n\t\t\t\t\t\tSystem.err.println(\"PTU IDS changed\");\n\t\t\t\t\t\tactivePtuIds = event.getPtuIds();\n\t\t\t\t\t\tupdate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\tDosimeterSerialNumbersChangedEvent.subscribe(eventBus,\n\t\t\t\tnew DosimeterSerialNumbersChangedEvent.Handler() {\n\t\t\t\t\t@Override\n\t\t\t\t\tpublic void onDosimeterSerialNumbersChanged(\n\t\t\t\t\t\t\tDosimeterSerialNumbersChangedEvent event) {\n\t\t\t\t\t\tdosimeterSerialNumbers.clear();\n\t\t\t\t\t\tdosimeterSerialNumbers.addAll(event\n\t\t\t\t\t\t\t\t.getDosimeterSerialNumbers());\n\t\t\t\t\t\tSystem.err.println(\"DOSI changed \"\n\t\t\t\t\t\t\t\t+ dosimeterSerialNumbers.size());\n\t\t\t\t\t\tupdate();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\tupdate();\n\t}\n"} {"input": " public int execute(ExecutionContext context) {\n JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();\n StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);\n DiagnosticCollector diagnostics = new DiagnosticCollector();\n List options = getOptions(context);\n List classNamesForAnnotationProcessing = ImmutableList.of();\n Iterable compilationUnits =\n fileManager.getJavaFileObjectsFromStrings(javaSourceFilePaths);\n Writer compilerOutputWriter = new PrintWriter(context.getStdErr());\n JavaCompiler.CompilationTask compilationTask = compiler.getTask(\n compilerOutputWriter,\n fileManager,\n diagnostics,\n options,\n classNamesForAnnotationProcessing,\n compilationUnits);\n boolean isSuccess = compilationTask.call();\n if (isSuccess) {\n return 0;\n } else {\n if (context.getVerbosity().shouldPrintStandardInformation()) {\n for (Diagnostic diagnostic : diagnostics.getDiagnostics()) {\n context.getStdErr().println(diagnostic);\n }\n }\n return 1;\n }\n }\n", "output": " public int execute(ExecutionContext context) {\n JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();\n Preconditions.checkNotNull(compiler,\n \"If using JRE instead of JDK, ToolProvider.getSystemJavaCompiler() may be null.\");\n StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);\n DiagnosticCollector diagnostics = new DiagnosticCollector();\n List options = getOptions(context);\n List classNamesForAnnotationProcessing = ImmutableList.of();\n Iterable compilationUnits =\n fileManager.getJavaFileObjectsFromStrings(javaSourceFilePaths);\n Writer compilerOutputWriter = new PrintWriter(context.getStdErr());\n JavaCompiler.CompilationTask compilationTask = compiler.getTask(\n compilerOutputWriter,\n fileManager,\n diagnostics,\n options,\n classNamesForAnnotationProcessing,\n compilationUnits);\n boolean isSuccess = compilationTask.call();\n if (isSuccess) {\n return 0;\n } else {\n if (context.getVerbosity().shouldPrintStandardInformation()) {\n for (Diagnostic diagnostic : diagnostics.getDiagnostics()) {\n context.getStdErr().println(diagnostic);\n }\n }\n return 1;\n }\n }\n"} {"input": " protected void doWriteObject(final Object original, final boolean unshared) throws IOException {\n final ClassExternalizerFactory classExternalizerFactory = this.classExternalizerFactory;\n final ObjectResolver objectResolver = this.objectResolver;\n Object obj = original;\n Class objClass;\n int id;\n boolean isArray, isEnum;\n SerializableClass info;\n boolean unreplaced = true;\n final int configuredVersion = this.configuredVersion;\n try {\n for (;;) {\n if (obj == null) {\n write(ID_NULL);\n return;\n }\n final int rid;\n if (! unshared && (rid = instanceCache.get(obj, -1)) != -1) {\n final int diff = rid - instanceSeq;\n if (diff >= -256) {\n write(ID_REPEAT_OBJECT_NEAR);\n write(diff);\n } else if (diff >= -65536) {\n write(ID_REPEAT_OBJECT_NEARISH);\n writeShort(diff);\n } else {\n write(ID_REPEAT_OBJECT_FAR);\n writeInt(rid);\n }\n return;\n }\n final ObjectTable.Writer objectTableWriter;\n if (! unshared && (objectTableWriter = objectTable.getObjectWriter(obj)) != null) {\n write(ID_PREDEFINED_OBJECT);\n if (configuredVersion == 1) {\n objectTableWriter.writeObject(getBlockMarshaller(), obj);\n writeEndBlock();\n } else {\n objectTableWriter.writeObject(this, obj);\n }\n return;\n }\n objClass = obj.getClass();\n id = getBasicClasses(configuredVersion).get(objClass, -1);\n if (id == ID_CLASS_CLASS) {\n final Class classObj = (Class) obj;\n final int cid = BASIC_CLASSES_V2.get(classObj, -1);\n switch (cid) {\n case -1:\n case ID_SINGLETON_MAP_OBJECT:\n case ID_SINGLETON_SET_OBJECT:\n case ID_SINGLETON_LIST_OBJECT:\n case ID_EMPTY_MAP_OBJECT:\n case ID_EMPTY_SET_OBJECT:\n case ID_EMPTY_LIST_OBJECT: {\n write(ID_NEW_OBJECT);\n writeClassClass(classObj);\n return;\n }\n default: {\n write(cid);\n return;\n }\n }\n }\n isEnum = obj instanceof Enum;\n isArray = objClass.isArray();\n info = isArray || isEnum || id != -1 ? null : registry.lookup(objClass);\n if (unreplaced) {\n if (info != null) {\n if (info.hasWriteReplace()) {\n obj = info.callWriteReplace(obj);\n }\n }\n obj = objectResolver.writeReplace(obj);\n if (obj != original) {\n unreplaced = false;\n continue;\n } else {\n break;\n }\n } else {\n break;\n }\n }\n if (isEnum) {\n final Enum theEnum = (Enum) obj;\n write(ID_NEW_OBJECT);\n writeEnumClass(theEnum.getDeclaringClass());\n writeString(theEnum.name());\n instanceCache.put(obj, instanceSeq++);\n return;\n }\n switch (id) {\n case ID_BYTE_CLASS: {\n write(ID_BYTE_OBJECT);\n writeByte(((Byte) obj).byteValue());\n return;\n }\n case ID_BOOLEAN_CLASS: {\n write(((Boolean) obj).booleanValue() ? ID_BOOLEAN_OBJECT_TRUE : ID_BOOLEAN_OBJECT_FALSE);\n return;\n }\n case ID_CHARACTER_CLASS: {\n write(ID_CHARACTER_OBJECT);\n writeChar(((Character) obj).charValue());\n return;\n }\n case ID_DOUBLE_CLASS: {\n write(ID_DOUBLE_OBJECT);\n writeDouble(((Double) obj).doubleValue());\n return;\n }\n case ID_FLOAT_CLASS: {\n write(ID_FLOAT_OBJECT);\n writeFloat(((Float) obj).floatValue());\n return;\n }\n case ID_INTEGER_CLASS: {\n write(ID_INTEGER_OBJECT);\n writeInt(((Integer) obj).intValue());\n return;\n }\n case ID_LONG_CLASS: {\n write(ID_LONG_OBJECT);\n writeLong(((Long) obj).longValue());\n return;\n }\n case ID_SHORT_CLASS: {\n write(ID_SHORT_OBJECT);\n writeShort(((Short) obj).shortValue());\n return;\n }\n case ID_STRING_CLASS: {\n final String string = (String) obj;\n final int len = string.length();\n if (len == 0) {\n write(ID_STRING_EMPTY);\n return;\n } else if (len <= 0x100) {\n write(ID_STRING_SMALL);\n write(len);\n } else if (len <= 0x10000) {\n write(ID_STRING_MEDIUM);\n writeShort(len);\n } else {\n write(ID_STRING_LARGE);\n writeInt(len);\n }\n shallowFlush();\n UTFUtils.writeUTFBytes(byteOutput, string);\n if (unshared) {\n instanceCache.put(obj, -1);\n instanceSeq++;\n } else {\n instanceCache.put(obj, instanceSeq++);\n }\n return;\n }\n case ID_BYTE_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final byte[] bytes = (byte[]) obj;\n final int len = bytes.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_BYTE);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_BYTE);\n write(bytes, 0, len);\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_BYTE);\n write(bytes, 0, len);\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_BYTE);\n write(bytes, 0, len);\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_BOOLEAN_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final boolean[] booleans = (boolean[]) obj;\n final int len = booleans.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_BOOLEAN);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_BOOLEAN);\n writeBooleanArray(booleans);\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_BOOLEAN);\n writeBooleanArray(booleans);\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_BOOLEAN);\n writeBooleanArray(booleans);\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CHAR_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final char[] chars = (char[]) obj;\n final int len = chars.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_CHAR);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_CHAR);\n for (int i = 0; i < len; i ++) {\n writeChar(chars[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_CHAR);\n for (int i = 0; i < len; i ++) {\n writeChar(chars[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_CHAR);\n for (int i = 0; i < len; i ++) {\n writeChar(chars[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_SHORT_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final short[] shorts = (short[]) obj;\n final int len = shorts.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_SHORT);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_SHORT);\n for (int i = 0; i < len; i ++) {\n writeShort(shorts[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_SHORT);\n for (int i = 0; i < len; i ++) {\n writeShort(shorts[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_SHORT);\n for (int i = 0; i < len; i ++) {\n writeShort(shorts[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_INT_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final int[] ints = (int[]) obj;\n final int len = ints.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_INT);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_INT);\n for (int i = 0; i < len; i ++) {\n writeInt(ints[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_INT);\n for (int i = 0; i < len; i ++) {\n writeInt(ints[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_INT);\n for (int i = 0; i < len; i ++) {\n writeInt(ints[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_LONG_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final long[] longs = (long[]) obj;\n final int len = longs.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_LONG);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_LONG);\n for (int i = 0; i < len; i ++) {\n writeLong(longs[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_LONG);\n for (int i = 0; i < len; i ++) {\n writeLong(longs[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_LONG);\n for (int i = 0; i < len; i ++) {\n writeLong(longs[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_FLOAT_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final float[] floats = (float[]) obj;\n final int len = floats.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_FLOAT);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_FLOAT);\n for (int i = 0; i < len; i ++) {\n writeFloat(floats[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_FLOAT);\n for (int i = 0; i < len; i ++) {\n writeFloat(floats[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_FLOAT);\n for (int i = 0; i < len; i ++) {\n writeFloat(floats[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_DOUBLE_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final double[] doubles = (double[]) obj;\n final int len = doubles.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_DOUBLE);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_DOUBLE);\n for (int i = 0; i < len; i ++) {\n writeDouble(doubles[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_DOUBLE);\n for (int i = 0; i < len; i ++) {\n writeDouble(doubles[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_DOUBLE);\n for (int i = 0; i < len; i ++) {\n writeDouble(doubles[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_HASH_SET:\n case ID_CC_LINKED_HASH_SET:\n case ID_CC_TREE_SET:\n case ID_CC_ARRAY_LIST:\n case ID_CC_LINKED_LIST:\n case ID_CC_VECTOR:\n case ID_CC_STACK:\n case ID_CC_ARRAY_DEQUE: {\n instanceCache.put(obj, instanceSeq++);\n final Collection collection = (Collection) obj;\n final int len = collection.size();\n if (len == 0) {\n write(unshared ? ID_COLLECTION_EMPTY_UNSHARED : ID_COLLECTION_EMPTY);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n } else if (len <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(len);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n for (Object o : collection) {\n doWriteObject(o, false);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(len);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n for (Object o : collection) {\n doWriteObject(o, false);\n }\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(len);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n for (Object o : collection) {\n doWriteObject(o, false);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_ENUM_SET_PROXY: {\n instanceCache.put(obj, instanceSeq++);\n final Enum[] elements = getEnumSetElements(obj);\n final int len = elements.length;\n if (len == 0) {\n write(unshared ? ID_COLLECTION_EMPTY_UNSHARED : ID_COLLECTION_EMPTY);\n write(id);\n writeClass(getEnumSetElementType(obj));\n } else if (len <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(len);\n write(id);\n writeClass(getEnumSetElementType(obj));\n for (Object o : elements) {\n doWriteObject(o, false);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(len);\n write(id);\n writeClass(getEnumSetElementType(obj));\n for (Object o : elements) {\n doWriteObject(o, false);\n }\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(len);\n write(id);\n writeClass(getEnumSetElementType(obj));\n for (Object o : elements) {\n doWriteObject(o, false);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_HASH_MAP:\n case ID_CC_HASHTABLE:\n case ID_CC_IDENTITY_HASH_MAP:\n case ID_CC_LINKED_HASH_MAP:\n case ID_CC_TREE_MAP:\n case ID_CC_ENUM_MAP: {\n instanceCache.put(obj, instanceSeq++);\n final Map map = (Map) obj;\n final int len = map.size();\n if (len == 0) {\n write(unshared ? ID_COLLECTION_EMPTY_UNSHARED : ID_COLLECTION_EMPTY);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n } else if (len <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(len);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n for (Map.Entry entry : map.entrySet()) {\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(len);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n for (Map.Entry entry : map.entrySet()) {\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n }\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(len);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n for (Map.Entry entry : map.entrySet()) {\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_EMPTY_MAP_OBJECT:\n case ID_EMPTY_SET_OBJECT:\n case ID_EMPTY_LIST_OBJECT:\n case ID_REVERSE_ORDER_OBJECT: {\n write(id);\n return;\n }\n case ID_SINGLETON_MAP_OBJECT: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n final Map.Entry entry = (Map.Entry) ((Map) obj).entrySet().iterator().next();\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_SINGLETON_LIST_OBJECT:\n case ID_SINGLETON_SET_OBJECT: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n doWriteObject(((Collection)obj).iterator().next(), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_REVERSE_ORDER2_OBJECT: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n try {\n doWriteObject(Protocol.reverseOrder2Field.get(obj), false);\n } catch (IllegalAccessException e) {\n throw new InvalidObjectException(\"Cannot access standard field for reverse-order comparator\");\n }\n return;\n }\n case ID_CC_CONCURRENT_HASH_MAP:\n case ID_CC_COPY_ON_WRITE_ARRAY_LIST:\n case ID_CC_COPY_ON_WRITE_ARRAY_SET: {\n info = registry.lookup(objClass);\n break;\n }\n case ID_PAIR: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n Pair pair = (Pair) obj;\n doWriteObject(pair.getA(), unshared);\n doWriteObject(pair.getB(), unshared);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_NCOPIES: {\n List list = (List) obj;\n int size = list.size();\n if (size == 0) {\n write(ID_EMPTY_LIST_OBJECT);\n return;\n }\n instanceCache.put(obj, instanceSeq++);\n if (size <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(size);\n } else if (size <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(size);\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(size);\n }\n write(id);\n doWriteObject(list.iterator().next(), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case -1: break;\n default: throw new NotSerializableException(objClass.getName());\n }\n if (isArray) {\n instanceCache.put(obj, instanceSeq++);\n final Object[] objects = (Object[]) obj;\n final int len = objects.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n writeClass(objClass.getComponentType());\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n writeClass(objClass.getComponentType());\n for (int i = 0; i < len; i++) {\n doWriteObject(objects[i], unshared);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n writeClass(objClass.getComponentType());\n for (int i = 0; i < len; i++) {\n doWriteObject(objects[i], unshared);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n writeClass(objClass.getComponentType());\n for (int i = 0; i < len; i++) {\n doWriteObject(objects[i], unshared);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n if (Proxy.isProxyClass(objClass)) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n instanceCache.put(obj, instanceSeq++);\n writeProxyClass(objClass);\n doWriteObject(Proxy.getInvocationHandler(obj), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n Externalizer externalizer;\n if (externalizers.containsKey(objClass)) {\n externalizer = externalizers.get(objClass);\n } else {\n externalizer = classExternalizerFactory.getExternalizer(objClass);\n externalizers.put(objClass, externalizer);\n }\n if (externalizer != null) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n writeExternalizerClass(objClass, externalizer);\n instanceCache.put(obj, instanceSeq++);\n final ObjectOutput objectOutput;\n objectOutput = getObjectOutput();\n externalizer.writeExternal(obj, objectOutput);\n writeEndBlock();\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n if (obj instanceof Externalizable) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n instanceCache.put(obj, instanceSeq++);\n final Externalizable ext = (Externalizable) obj;\n final ObjectOutput objectOutput = getObjectOutput();\n writeExternalizableClass(objClass);\n ext.writeExternal(objectOutput);\n writeEndBlock();\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n if (serializabilityChecker.isSerializable(objClass)) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n writeSerializableClass(objClass);\n instanceCache.put(obj, instanceSeq++);\n doWriteSerializableObject(info, obj, objClass);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n throw new NotSerializableException(objClass.getName());\n } finally {\n if (! unreplaced && obj != original) {\n final int replId = instanceCache.get(obj, -1);\n if (replId != -1) {\n instanceCache.put(original, replId);\n }\n }\n }\n }\n", "output": " protected void doWriteObject(final Object original, final boolean unshared) throws IOException {\n final ClassExternalizerFactory classExternalizerFactory = this.classExternalizerFactory;\n final ObjectResolver objectResolver = this.objectResolver;\n Object obj = original;\n Class objClass;\n int id;\n boolean isArray, isEnum;\n SerializableClass info;\n boolean unreplaced = true;\n final int configuredVersion = this.configuredVersion;\n try {\n for (;;) {\n if (obj == null) {\n write(ID_NULL);\n return;\n }\n final int rid;\n if (! unshared && (rid = instanceCache.get(obj, -1)) != -1) {\n final int diff = rid - instanceSeq;\n if (diff >= -256) {\n write(ID_REPEAT_OBJECT_NEAR);\n write(diff);\n } else if (diff >= -65536) {\n write(ID_REPEAT_OBJECT_NEARISH);\n writeShort(diff);\n } else {\n write(ID_REPEAT_OBJECT_FAR);\n writeInt(rid);\n }\n return;\n }\n final ObjectTable.Writer objectTableWriter;\n if (! unshared && (objectTableWriter = objectTable.getObjectWriter(obj)) != null) {\n write(ID_PREDEFINED_OBJECT);\n if (configuredVersion == 1) {\n objectTableWriter.writeObject(getBlockMarshaller(), obj);\n writeEndBlock();\n } else {\n objectTableWriter.writeObject(this, obj);\n }\n return;\n }\n objClass = obj.getClass();\n id = getBasicClasses(configuredVersion).get(objClass, -1);\n if (id == ID_CLASS_CLASS) {\n final Class classObj = (Class) obj;\n final int cid = BASIC_CLASSES_V2.get(classObj, -1);\n switch (cid) {\n case -1:\n case ID_SINGLETON_MAP_OBJECT:\n case ID_SINGLETON_SET_OBJECT:\n case ID_SINGLETON_LIST_OBJECT:\n case ID_EMPTY_MAP_OBJECT:\n case ID_EMPTY_SET_OBJECT:\n case ID_EMPTY_LIST_OBJECT: {\n write(ID_NEW_OBJECT);\n writeClassClass(classObj);\n return;\n }\n default: {\n write(cid);\n return;\n }\n }\n }\n isEnum = obj instanceof Enum;\n isArray = objClass.isArray();\n info = isArray || isEnum || id != -1 ? null : registry.lookup(objClass);\n if (unreplaced) {\n if (info != null) {\n if (info.hasWriteReplace()) {\n obj = info.callWriteReplace(obj);\n }\n }\n obj = objectResolver.writeReplace(obj);\n if (obj != original) {\n unreplaced = false;\n continue;\n } else {\n break;\n }\n } else {\n break;\n }\n }\n if (isEnum) {\n final Enum theEnum = (Enum) obj;\n write(ID_NEW_OBJECT);\n writeEnumClass(theEnum.getDeclaringClass());\n writeString(theEnum.name());\n instanceCache.put(obj, instanceSeq++);\n return;\n }\n switch (id) {\n case ID_BYTE_CLASS: {\n write(ID_BYTE_OBJECT);\n writeByte(((Byte) obj).byteValue());\n return;\n }\n case ID_BOOLEAN_CLASS: {\n write(((Boolean) obj).booleanValue() ? ID_BOOLEAN_OBJECT_TRUE : ID_BOOLEAN_OBJECT_FALSE);\n return;\n }\n case ID_CHARACTER_CLASS: {\n write(ID_CHARACTER_OBJECT);\n writeChar(((Character) obj).charValue());\n return;\n }\n case ID_DOUBLE_CLASS: {\n write(ID_DOUBLE_OBJECT);\n writeDouble(((Double) obj).doubleValue());\n return;\n }\n case ID_FLOAT_CLASS: {\n write(ID_FLOAT_OBJECT);\n writeFloat(((Float) obj).floatValue());\n return;\n }\n case ID_INTEGER_CLASS: {\n write(ID_INTEGER_OBJECT);\n writeInt(((Integer) obj).intValue());\n return;\n }\n case ID_LONG_CLASS: {\n write(ID_LONG_OBJECT);\n writeLong(((Long) obj).longValue());\n return;\n }\n case ID_SHORT_CLASS: {\n write(ID_SHORT_OBJECT);\n writeShort(((Short) obj).shortValue());\n return;\n }\n case ID_STRING_CLASS: {\n final String string = (String) obj;\n final int len = string.length();\n if (len == 0) {\n write(ID_STRING_EMPTY);\n return;\n } else if (len <= 0x100) {\n write(ID_STRING_SMALL);\n write(len);\n } else if (len <= 0x10000) {\n write(ID_STRING_MEDIUM);\n writeShort(len);\n } else {\n write(ID_STRING_LARGE);\n writeInt(len);\n }\n shallowFlush();\n UTFUtils.writeUTFBytes(byteOutput, string);\n if (unshared) {\n instanceCache.put(obj, -1);\n instanceSeq++;\n } else {\n instanceCache.put(obj, instanceSeq++);\n }\n return;\n }\n case ID_BYTE_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final byte[] bytes = (byte[]) obj;\n final int len = bytes.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_BYTE);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_BYTE);\n write(bytes, 0, len);\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_BYTE);\n write(bytes, 0, len);\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_BYTE);\n write(bytes, 0, len);\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_BOOLEAN_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final boolean[] booleans = (boolean[]) obj;\n final int len = booleans.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_BOOLEAN);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_BOOLEAN);\n writeBooleanArray(booleans);\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_BOOLEAN);\n writeBooleanArray(booleans);\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_BOOLEAN);\n writeBooleanArray(booleans);\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CHAR_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final char[] chars = (char[]) obj;\n final int len = chars.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_CHAR);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_CHAR);\n for (int i = 0; i < len; i ++) {\n writeChar(chars[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_CHAR);\n for (int i = 0; i < len; i ++) {\n writeChar(chars[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_CHAR);\n for (int i = 0; i < len; i ++) {\n writeChar(chars[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_SHORT_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final short[] shorts = (short[]) obj;\n final int len = shorts.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_SHORT);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_SHORT);\n for (int i = 0; i < len; i ++) {\n writeShort(shorts[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_SHORT);\n for (int i = 0; i < len; i ++) {\n writeShort(shorts[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_SHORT);\n for (int i = 0; i < len; i ++) {\n writeShort(shorts[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_INT_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final int[] ints = (int[]) obj;\n final int len = ints.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_INT);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_INT);\n for (int i = 0; i < len; i ++) {\n writeInt(ints[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_INT);\n for (int i = 0; i < len; i ++) {\n writeInt(ints[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_INT);\n for (int i = 0; i < len; i ++) {\n writeInt(ints[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_LONG_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final long[] longs = (long[]) obj;\n final int len = longs.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_LONG);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_LONG);\n for (int i = 0; i < len; i ++) {\n writeLong(longs[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_LONG);\n for (int i = 0; i < len; i ++) {\n writeLong(longs[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_LONG);\n for (int i = 0; i < len; i ++) {\n writeLong(longs[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_FLOAT_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final float[] floats = (float[]) obj;\n final int len = floats.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_FLOAT);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_FLOAT);\n for (int i = 0; i < len; i ++) {\n writeFloat(floats[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_FLOAT);\n for (int i = 0; i < len; i ++) {\n writeFloat(floats[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_FLOAT);\n for (int i = 0; i < len; i ++) {\n writeFloat(floats[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_DOUBLE_ARRAY_CLASS: {\n if (! unshared) {\n instanceCache.put(obj, instanceSeq++);\n }\n final double[] doubles = (double[]) obj;\n final int len = doubles.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n write(ID_PRIM_DOUBLE);\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n write(ID_PRIM_DOUBLE);\n for (int i = 0; i < len; i ++) {\n writeDouble(doubles[i]);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n write(ID_PRIM_DOUBLE);\n for (int i = 0; i < len; i ++) {\n writeDouble(doubles[i]);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n write(ID_PRIM_DOUBLE);\n for (int i = 0; i < len; i ++) {\n writeDouble(doubles[i]);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_HASH_SET:\n case ID_CC_LINKED_HASH_SET:\n case ID_CC_TREE_SET:\n case ID_CC_ARRAY_LIST:\n case ID_CC_LINKED_LIST:\n case ID_CC_VECTOR:\n case ID_CC_STACK:\n case ID_CC_ARRAY_DEQUE: {\n instanceCache.put(obj, instanceSeq++);\n final Collection collection = (Collection) obj;\n final int len = collection.size();\n if (len == 0) {\n write(unshared ? ID_COLLECTION_EMPTY_UNSHARED : ID_COLLECTION_EMPTY);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n } else if (len <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(len);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n for (Object o : collection) {\n doWriteObject(o, false);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(len);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n for (Object o : collection) {\n doWriteObject(o, false);\n }\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(len);\n write(id);\n if (id == ID_CC_TREE_SET) {\n doWriteObject(((TreeSet)collection).comparator(), false);\n }\n for (Object o : collection) {\n doWriteObject(o, false);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_ENUM_SET_PROXY: {\n instanceCache.put(obj, instanceSeq++);\n final Enum[] elements = getEnumSetElements(obj);\n final int len = elements.length;\n if (len == 0) {\n write(unshared ? ID_COLLECTION_EMPTY_UNSHARED : ID_COLLECTION_EMPTY);\n write(id);\n writeClass(getEnumSetElementType(obj));\n } else if (len <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(len);\n write(id);\n writeClass(getEnumSetElementType(obj));\n for (Object o : elements) {\n doWriteObject(o, false);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(len);\n write(id);\n writeClass(getEnumSetElementType(obj));\n for (Object o : elements) {\n doWriteObject(o, false);\n }\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(len);\n write(id);\n writeClass(getEnumSetElementType(obj));\n for (Object o : elements) {\n doWriteObject(o, false);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_HASH_MAP:\n case ID_CC_HASHTABLE:\n case ID_CC_IDENTITY_HASH_MAP:\n case ID_CC_LINKED_HASH_MAP:\n case ID_CC_TREE_MAP:\n case ID_CC_ENUM_MAP: {\n instanceCache.put(obj, instanceSeq++);\n final Map map = (Map) obj;\n final int len = map.size();\n if (len == 0) {\n write(unshared ? ID_COLLECTION_EMPTY_UNSHARED : ID_COLLECTION_EMPTY);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n } else if (len <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(len);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n for (Map.Entry entry : map.entrySet()) {\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(len);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n for (Map.Entry entry : map.entrySet()) {\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n }\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(len);\n write(id);\n switch (id) {\n case ID_CC_TREE_MAP: doWriteObject(((TreeMap)map).comparator(), false); break;\n case ID_CC_ENUM_MAP: writeClass(getEnumMapKeyType(obj)); break;\n }\n for (Map.Entry entry : map.entrySet()) {\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_EMPTY_MAP_OBJECT:\n case ID_EMPTY_SET_OBJECT:\n case ID_EMPTY_LIST_OBJECT:\n case ID_REVERSE_ORDER_OBJECT: {\n write(id);\n return;\n }\n case ID_SINGLETON_MAP_OBJECT: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n final Map.Entry entry = (Map.Entry) ((Map) obj).entrySet().iterator().next();\n doWriteObject(entry.getKey(), false);\n doWriteObject(entry.getValue(), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_SINGLETON_LIST_OBJECT:\n case ID_SINGLETON_SET_OBJECT: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n doWriteObject(((Collection)obj).iterator().next(), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_REVERSE_ORDER2_OBJECT: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n try {\n doWriteObject(Protocol.reverseOrder2Field.get(obj), false);\n } catch (IllegalAccessException e) {\n throw new InvalidObjectException(\"Cannot access standard field for reverse-order comparator\");\n }\n return;\n }\n case ID_CC_CONCURRENT_HASH_MAP:\n case ID_CC_COPY_ON_WRITE_ARRAY_LIST:\n case ID_CC_COPY_ON_WRITE_ARRAY_SET: {\n info = registry.lookup(objClass);\n break;\n }\n case ID_PAIR: {\n instanceCache.put(obj, instanceSeq++);\n write(id);\n Pair pair = (Pair) obj;\n doWriteObject(pair.getA(), unshared);\n doWriteObject(pair.getB(), unshared);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case ID_CC_NCOPIES: {\n List list = (List) obj;\n int size = list.size();\n if (size == 0) {\n write(ID_EMPTY_LIST_OBJECT);\n return;\n }\n instanceCache.put(obj, instanceSeq++);\n if (size <= 256) {\n write(unshared ? ID_COLLECTION_SMALL_UNSHARED : ID_COLLECTION_SMALL);\n write(size);\n } else if (size <= 65536) {\n write(unshared ? ID_COLLECTION_MEDIUM_UNSHARED : ID_COLLECTION_MEDIUM);\n writeShort(size);\n } else {\n write(unshared ? ID_COLLECTION_LARGE_UNSHARED : ID_COLLECTION_LARGE);\n writeInt(size);\n }\n write(id);\n doWriteObject(list.iterator().next(), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n case -1: break;\n default: throw new NotSerializableException(objClass.getName());\n }\n if (isArray) {\n instanceCache.put(obj, instanceSeq++);\n final Object[] objects = (Object[]) obj;\n final int len = objects.length;\n if (len == 0) {\n write(unshared ? ID_ARRAY_EMPTY_UNSHARED : ID_ARRAY_EMPTY);\n writeClass(objClass.getComponentType());\n } else if (len <= 256) {\n write(unshared ? ID_ARRAY_SMALL_UNSHARED : ID_ARRAY_SMALL);\n write(len);\n writeClass(objClass.getComponentType());\n for (int i = 0; i < len; i++) {\n doWriteObject(objects[i], unshared);\n }\n } else if (len <= 65536) {\n write(unshared ? ID_ARRAY_MEDIUM_UNSHARED : ID_ARRAY_MEDIUM);\n writeShort(len);\n writeClass(objClass.getComponentType());\n for (int i = 0; i < len; i++) {\n doWriteObject(objects[i], unshared);\n }\n } else {\n write(unshared ? ID_ARRAY_LARGE_UNSHARED : ID_ARRAY_LARGE);\n writeInt(len);\n writeClass(objClass.getComponentType());\n for (int i = 0; i < len; i++) {\n doWriteObject(objects[i], unshared);\n }\n }\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n if (Proxy.isProxyClass(objClass)) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n instanceCache.put(obj, instanceSeq++);\n writeProxyClass(objClass);\n doWriteObject(Proxy.getInvocationHandler(obj), false);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n Externalizer externalizer;\n if (externalizers.containsKey(objClass)) {\n externalizer = externalizers.get(objClass);\n } else {\n externalizer = classExternalizerFactory.getExternalizer(objClass);\n externalizers.put(objClass, externalizer);\n }\n if (externalizer != null) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n writeExternalizerClass(objClass, externalizer);\n instanceCache.put(obj, instanceSeq++);\n final ObjectOutput objectOutput;\n objectOutput = getObjectOutput();\n externalizer.writeExternal(obj, objectOutput);\n writeEndBlock();\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n if (obj instanceof Externalizable) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n final Externalizable ext = (Externalizable) obj;\n final ObjectOutput objectOutput = getObjectOutput();\n writeExternalizableClass(objClass);\n instanceCache.put(obj, instanceSeq++);\n ext.writeExternal(objectOutput);\n writeEndBlock();\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n if (serializabilityChecker.isSerializable(objClass)) {\n write(unshared ? ID_NEW_OBJECT_UNSHARED : ID_NEW_OBJECT);\n writeSerializableClass(objClass);\n instanceCache.put(obj, instanceSeq++);\n doWriteSerializableObject(info, obj, objClass);\n if (unshared) {\n instanceCache.put(obj, -1);\n }\n return;\n }\n throw new NotSerializableException(objClass.getName());\n } finally {\n if (! unreplaced && obj != original) {\n final int replId = instanceCache.get(obj, -1);\n if (replId != -1) {\n instanceCache.put(original, replId);\n }\n }\n }\n }\n"} {"input": "\tpublic void buildContextMenu(IMenuManager menu) {\n\t\tIAction action;\n\t\tGEFActionConstants.addStandardActionGroups(menu);\n\t\taction = getActionRegistry().getAction(ActionFactory.UNDO.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);\n\t\taction = getActionRegistry().getAction(ActionFactory.REDO.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);\n\t\taction = actionRegistry.getAction(ActionFactory.COPY.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t\taction = actionRegistry.getAction(ActionFactory.PASTE.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t\taction = getActionRegistry().getAction(ActionFactory.DELETE.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t\taction = getActionRegistry().getAction(ActionFactory.RENAME.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t}\n", "output": "\tpublic void buildContextMenu(IMenuManager menu) {\n\t\tIAction action;\n\t\tGEFActionConstants.addStandardActionGroups(menu);\n\t\taction = getActionRegistry().getAction(ActionFactory.UNDO.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);\n\t\taction = getActionRegistry().getAction(ActionFactory.REDO.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);\n\t\taction = actionRegistry.getAction(ActionFactory.COPY.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t\taction = actionRegistry.getAction(ActionFactory.PASTE.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t\taction = getActionRegistry().getAction(ActionFactory.DELETE.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t\taction = getActionRegistry()\n\t\t\t\t.getAction(ActionFactory.SELECT_ALL.getId());\n\t\tmenu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);\n\t}\n"} {"input": "\tpublic IGenPackageFinderResult findGenPackage(String nsURI,\n\t\t\tString locationHint, GenPackageDependentElement container, ITextResource resource) {\n\t\tResourceSet rs = resource.getResourceSet();\n\t\tif (rs == null) {\n\t\t\treturn null;\n\t\t}\n\t\tURI resourceURI = resource.getURI();\n\t\tresourceURI = resourceURI.trimFileExtension();\n\t\tURI genModelURI = resourceURI.appendFileExtension(\"genmodel\");\n\t\ttry {\n\t\t\treturn findGenPackage(getSyntax(container), nsURI, rs, genModelURI);\n\t\t} catch (Exception e) {\n \t\tEMFTextRuntimePlugin.logError(\"Error searching for generator model \" + nsURI, e);\n\t\t}\n\t\treturn null;\n\t}\n", "output": "\tpublic IGenPackageFinderResult findGenPackage(String nsURI,\n\t\t\tString locationHint, GenPackageDependentElement container, ITextResource resource) {\n\t\tif (resource == null) {\n\t\t\treturn null;\n\t\t}\n\t\tResourceSet rs = resource.getResourceSet();\n\t\tif (rs == null) {\n\t\t\treturn null;\n\t\t}\n\t\tURI resourceURI = resource.getURI();\n\t\tresourceURI = resourceURI.trimFileExtension();\n\t\tURI genModelURI = resourceURI.appendFileExtension(\"genmodel\");\n\t\ttry {\n\t\t\treturn findGenPackage(getSyntax(container), nsURI, rs, genModelURI);\n\t\t} catch (Exception e) {\n \t\tEMFTextRuntimePlugin.logError(\"Error searching for generator model \" + nsURI, e);\n\t\t}\n\t\treturn null;\n\t}\n"} {"input": "\tprotected Question parseGroups(String[] groups) {\n\t\tQuestion q = new Question(new User(\"bot1000\"));\n\t\tq.setContent(new Data(DataType.PLAIN_TEXT, \"http://www.cl.cam.ac.uk/teaching/exams/pastpapers/\"+groups[1]));\n\t\tq.addTag(TagQuery.get(topic.getName()));\n\t\tq.setTimeStamp(parseDate(groups[1]));\n\t\tq.setExpectedDuration(30);\n\t\tif (groups[4] != null) {\n\t\t\tq.setNotes(new Data(DataType.PLAIN_TEXT, groups[4]));\n\t\t}\n\t\treturn q;\n\t}\n", "output": "\tprotected Question parseGroups(String[] groups) {\n\t\tQuestion q = new Question(new User(\"bot1000\"));\n\t\tq.setContent(new Data(DataType.PLAIN_TEXT, \"http://www.cl.cam.ac.uk/teaching/exams/pastpapers/\"+groups[1]));\n\t\tq.addTag(TagQuery.get(topic.getName()));\n\t\tq.addTag(TagQuery.get(\"Past papers\"));\n\t\tq.setTimeStamp(parseDate(groups[1]));\n\t\tq.setExpectedDuration(30);\n\t\tif (groups[4] != null) {\n\t\t\tq.setNotes(new Data(DataType.PLAIN_TEXT, groups[4]));\n\t\t}\n\t\treturn q;\n\t}\n"} {"input": "\tprotected Dialog onCreateDialog(final int id) {\n\t\tAlertDialog.Builder builder = new AlertDialog.Builder(this);\n\t\tLayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);\n\t\tswitch (ChatDialog.values()[id]) {\n\t\tcase Challenge: {\n\t\t\tif (netServ == null) {\n\t\t\t\tremoveDialog(id);\n\t\t\t\tdismissDialog(id);\n\t\t\t}\n\t\t\tfinal IncomingChallenge challenge = netServ.challenges.poll();\n\t\t\tView challengedLayout = inflater.inflate(R.layout.player_info_dialog, (LinearLayout)findViewById(R.id.player_info_dialog));\n\t\t\tPlayerInfo opp = netServ.players.get(challenge.opponent);\n\t\t\tImageView[] oppPokeIcons = new ImageView[6];\n\t\t\tTextView oppInfo, oppTeam, oppName, oppTier, oppRating; \n\t\t\tbuilder.setView(challengedLayout)\n\t\t\t.setCancelable(false)\n\t\t\t.setNegativeButton(this.getString(R.string.decline), new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ.socket.isConnected())\n\t\t\t\t\t\tnetServ.socket.sendMessage(\n\t\t\t\t\t\t\t\tconstructChallenge(ChallengeDesc.Refused.ordinal(),\n\t\t\t\t\t\t\t\t\t\tchallenge.opponent,\n\t\t\t\t\t\t\t\t\t\tchallenge.clauses,\n\t\t\t\t\t\t\t\t\t\tchallenge.mode),\n\t\t\t\t\t\t\t\t\t\tCommand.ChallengeStuff);\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t\tcheckChallenges();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setPositiveButton(this.getString(R.string.accept), new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ.socket.isConnected())\n\t\t\t\t\t\tnetServ.socket.sendMessage(\n\t\t\t\t\t\t\t\tconstructChallenge(ChallengeDesc.Accepted.ordinal(),\n\t\t\t\t\t\t\t\t\t\tchallenge.opponent,\n\t\t\t\t\t\t\t\t\t\tchallenge.clauses,\n\t\t\t\t\t\t\t\t\t\tchallenge.mode),\n\t\t\t\t\t\t\t\t\t\tCommand.ChallengeStuff);\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t\tcheckChallenges();\n\t\t\t\t}\n\t\t\t});\n\t\t\tfinal AlertDialog oppInfoDialog = builder.create();\n\t\t\tfor(int i = 0; i < 6; i++){\n\t\t\t\toppPokeIcons[i] = (ImageView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_poke\" + \n\t\t\t\t\t\t(i+1), \"id\", packName));\n\t\t\t}\n\t\t\toppInfo = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info\", \"id\", packName));\n\t\t\toppInfo.setText(Html.fromHtml(\"Info: \" + StringUtilities.escapeHtml(opp.info())));\n\t\t\toppTeam = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_team\", \"id\", packName));\n\t\t\toppTeam.setText(opp.nick() + \"'s team:\");\n\t\t\toppName = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_name\", \"id\", packName));\n\t\t\toppName.setText(this.getString(R.string.accept_challenge) + \" \" + opp.nick() + \"?\");\n\t\t\toppName.setTextSize(18);\n\t\t\toppTier = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_tier\", \"id\", packName));\n\t\t\toppRating = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_rating\", \"id\", packName));\n\t\t\treturn oppInfoDialog;\n\t\t} case AskForPass: {\n \tfinal EditText passField = new EditText(this);\n \tpassField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);\n\t\t\tbuilder.setMessage(\"Please enter your password \" + netServ.mePlayer.nick() + \".\")\n\t\t\t.setCancelable(true)\n\t\t\t.setView(passField)\n\t\t\t.setPositiveButton(\"Done\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ != null) {\n\t\t\t\t\t\tnetServ.sendPass(passField.getText().toString());\n\t\t\t\t\t}\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setOnCancelListener(new OnCancelListener() {\n\t\t\t\tpublic void onCancel(DialogInterface dialog) {\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t\tdisconnect();\n\t\t\t\t}\n\t\t\t});\n\t\t\tfinal AlertDialog dialog = builder.create();\n \tpassField.setOnFocusChangeListener(new View.OnFocusChangeListener() {\n\t\t\t\tpublic void onFocusChange(View v, boolean hasFocus) {\n\t\t\t\t\tif (hasFocus) {\n\t\t\t\t\t\tdialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn dialog;\n\t\t} case ConfirmDisconnect: {\n\t\t\tbuilder.setMessage(\"Really disconnect?\")\n\t\t\t.setCancelable(true)\n\t\t\t.setPositiveButton(\"Disconnect\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tdisconnect();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setNegativeButton(\"Cancel\", null);\n\t\t\treturn builder.create();\n\t\t} case FindBattle: {\n\t\t\tfinal EditText range = new EditText(this);\n\t\t\trange.append(\"\" + (prefs.contains(\"range\") ? prefs.getInt(\"range\", 0) : \"\"));\n\t\t\trange.setInputType(InputType.TYPE_CLASS_NUMBER);\n\t\t\trange.setHint(\"Range\");\n\t\t\tbuilder.setTitle(R.string.find_a_battle)\n\t\t\t.setMultiChoiceItems(new CharSequence[]{\"Force Rated\", \"Force Same Tier\", \"Only within range\"}, new boolean[]{prefs.getBoolean(\"findOption0\", false), prefs.getBoolean(\"findOption1\", false), prefs.getBoolean(\"findOption2\", false)}, new DialogInterface.OnMultiChoiceClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which, boolean isChecked) {\n\t\t\t\t\tprefs.edit().putBoolean(\"findOption\" + which, isChecked).commit();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setView(range)\n\t\t\t.setPositiveButton(\"Find\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ != null && netServ.socket.isConnected()) {\n\t\t\t\t\t\tnetServ.findingBattle = true;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tprefs.edit().putInt(\"range\", Integer.valueOf(range.getText().toString())).commit();\n\t\t\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\t\t\tprefs.edit().remove(\"range\").commit();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnetServ.socket.sendMessage(\n\t\t\t\t\t\t\t\tconstructFindBattle(prefs.getBoolean(\"findOption0\", false), prefs.getBoolean(\"findOption1\", false), prefs.getBoolean(\"findOption2\", false), prefs.getInt(\"range\", 200), (byte) 0),\n\t\t\t\t\t\t\t\tCommand.FindBattle);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn builder.create();\n\t\t} case TierSelection: {\n\t\t\tif (netServ == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn new TierAlertDialog(this, netServ.superTier);\n\t\t} case PlayerInfo: {\n\t\t\tView layout = inflater.inflate(R.layout.player_info_dialog, (LinearLayout)findViewById(R.id.player_info_dialog));\n ImageView[] pPokeIcons = new ImageView[6];\n TextView pInfo, pName;\n ListView ratings;\n\t\t\tbuilder.setView(layout)\n .setNegativeButton(\"Back\", new DialogInterface.OnClickListener(){\n \tpublic void onClick(DialogInterface dialog, int which) {\n \t\tremoveDialog(id);\n \t}\n })\n .setOnCancelListener(new DialogInterface.OnCancelListener(){\n \tpublic void onCancel(DialogInterface dialog) {\n \t\tremoveDialog(id);\n \t}\n })\n .setPositiveButton(\"Challenge\", new DialogInterface.OnClickListener(){\n \tpublic void onClick(DialogInterface dialog, int which) {\n \t\t\tshowDialog(ChatDialog.ChallengeMode.ordinal());\n \t\tremoveDialog(id);\n \t}});\n final AlertDialog pInfoDialog = builder.create();\n for(int i = 0; i < 6; i++){\n \tpPokeIcons[i] = (ImageView)layout.findViewById(getResources().getIdentifier(\"player_info_poke\" + \n \t\t\t(i+1), \"id\", packName));\n }\n \tpInfo = (TextView)layout.findViewById(R.id.player_info);\n \tpInfo.setText(Html.fromHtml(\"Info: \" + StringUtilities.escapeHtml(lastClickedPlayer.info())));\n \tpName = (TextView)layout.findViewById(R.id.player_info_name);\n \tpName.setText(lastClickedPlayer.nick());\n \tratings = (ListView)layout.findViewById(R.id.player_info_tiers);\n \tratings.setAdapter(new TwoViewsArrayAdapter(this, android.R.layout.simple_list_item_2, \n \t\t\tandroid.R.id.text1, android.R.id.text2, lastClickedPlayer.tierStandings, PlayerInfo.tierGetter));\n return pInfoDialog;\n\t\t} case ChallengeMode: {\n final Clauses[] clauses = Clauses.values();\n final int numClauses = clauses.length;\n\t\t\tfinal String[] clauseNames = new String[numClauses];\n\t\t\tfinal boolean[] checked = new boolean[numClauses];\n\t\t\tfor (int i=0; i < numClauses; i++) {\n\t\t\t\tclauseNames[i] = clauses[i].toString();\n\t\t\t\tchecked[i] = prefs.getBoolean(\"challengeOption\" + i, false);\n\t\t\t}\n builder.setMultiChoiceItems(clauseNames, checked, new DialogInterface.OnMultiChoiceClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which, boolean isChecked) {\n\t\t\t\t\tprefs.edit().putBoolean(\"challengeOption\" + which, isChecked).commit();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setPositiveButton(\"Challenge\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tint clauses = 0;\n\t\t\t\t\tfor (int i = 0; i < numClauses; i++)\n\t\t\t\t\t\tclauses |= (prefs.getBoolean(\"challengeOption\" + i, false) ? Clauses.values()[i].mask() : 0);\n\t\t\t\t\tif (netServ != null && netServ.socket != null && netServ.socket.isConnected())\n\t\t\t\t\t\tnetServ.socket.sendMessage(constructChallenge(ChallengeDesc.Sent.ordinal(), lastClickedPlayer.id, clauses, Mode.Singles.ordinal()), Command.ChallengeStuff);\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t}\n\t\t\t})\n .setNegativeButton(\"Back\", new DialogInterface.OnClickListener(){\n \tpublic void onClick(DialogInterface dialog, int which) {\n \t\tremoveDialog(id);\n \t}\n })\n .setOnCancelListener(new DialogInterface.OnCancelListener(){\n \tpublic void onCancel(DialogInterface dialog) {\n \t\tremoveDialog(id);\n \t}\n })\n .setTitle(\"Select clauses\");\n return builder.create();\n\t\t} default: {\n\t\t\treturn new Dialog(this);\n\t\t}\n\t\t}\n\t}\n", "output": "\tprotected Dialog onCreateDialog(final int id) {\n\t\tAlertDialog.Builder builder = new AlertDialog.Builder(this);\n\t\tLayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);\n\t\tswitch (ChatDialog.values()[id]) {\n\t\tcase Challenge: {\n\t\t\tif (netServ == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tfinal IncomingChallenge challenge = netServ.challenges.poll();\n\t\t\tView challengedLayout = inflater.inflate(R.layout.player_info_dialog, (LinearLayout)findViewById(R.id.player_info_dialog));\n\t\t\tPlayerInfo opp = netServ.players.get(challenge.opponent);\n\t\t\tImageView[] oppPokeIcons = new ImageView[6];\n\t\t\tTextView oppInfo, oppTeam, oppName, oppTier, oppRating; \n\t\t\tbuilder.setView(challengedLayout)\n\t\t\t.setCancelable(false)\n\t\t\t.setNegativeButton(this.getString(R.string.decline), new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ.socket.isConnected())\n\t\t\t\t\t\tnetServ.socket.sendMessage(\n\t\t\t\t\t\t\t\tconstructChallenge(ChallengeDesc.Refused.ordinal(),\n\t\t\t\t\t\t\t\t\t\tchallenge.opponent,\n\t\t\t\t\t\t\t\t\t\tchallenge.clauses,\n\t\t\t\t\t\t\t\t\t\tchallenge.mode),\n\t\t\t\t\t\t\t\t\t\tCommand.ChallengeStuff);\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t\tcheckChallenges();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setPositiveButton(this.getString(R.string.accept), new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ.socket.isConnected())\n\t\t\t\t\t\tnetServ.socket.sendMessage(\n\t\t\t\t\t\t\t\tconstructChallenge(ChallengeDesc.Accepted.ordinal(),\n\t\t\t\t\t\t\t\t\t\tchallenge.opponent,\n\t\t\t\t\t\t\t\t\t\tchallenge.clauses,\n\t\t\t\t\t\t\t\t\t\tchallenge.mode),\n\t\t\t\t\t\t\t\t\t\tCommand.ChallengeStuff);\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t\tcheckChallenges();\n\t\t\t\t}\n\t\t\t});\n\t\t\tfinal AlertDialog oppInfoDialog = builder.create();\n\t\t\tfor(int i = 0; i < 6; i++){\n\t\t\t\toppPokeIcons[i] = (ImageView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_poke\" + \n\t\t\t\t\t\t(i+1), \"id\", packName));\n\t\t\t}\n\t\t\toppInfo = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info\", \"id\", packName));\n\t\t\toppInfo.setText(Html.fromHtml(\"Info: \" + StringUtilities.escapeHtml(opp.info())));\n\t\t\toppTeam = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_team\", \"id\", packName));\n\t\t\toppTeam.setText(opp.nick() + \"'s team:\");\n\t\t\toppName = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_name\", \"id\", packName));\n\t\t\toppName.setText(this.getString(R.string.accept_challenge) + \" \" + opp.nick() + \"?\");\n\t\t\toppName.setTextSize(18);\n\t\t\toppTier = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_tier\", \"id\", packName));\n\t\t\toppRating = (TextView)challengedLayout.findViewById(getResources().getIdentifier(\"player_info_rating\", \"id\", packName));\n\t\t\treturn oppInfoDialog;\n\t\t} case AskForPass: {\n \tfinal EditText passField = new EditText(this);\n \tpassField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);\n\t\t\tbuilder.setMessage(\"Please enter your password \" + netServ.mePlayer.nick() + \".\")\n\t\t\t.setCancelable(true)\n\t\t\t.setView(passField)\n\t\t\t.setPositiveButton(\"Done\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ != null) {\n\t\t\t\t\t\tnetServ.sendPass(passField.getText().toString());\n\t\t\t\t\t}\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setOnCancelListener(new OnCancelListener() {\n\t\t\t\tpublic void onCancel(DialogInterface dialog) {\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t\tdisconnect();\n\t\t\t\t}\n\t\t\t});\n\t\t\tfinal AlertDialog dialog = builder.create();\n \tpassField.setOnFocusChangeListener(new View.OnFocusChangeListener() {\n\t\t\t\tpublic void onFocusChange(View v, boolean hasFocus) {\n\t\t\t\t\tif (hasFocus) {\n\t\t\t\t\t\tdialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn dialog;\n\t\t} case ConfirmDisconnect: {\n\t\t\tbuilder.setMessage(\"Really disconnect?\")\n\t\t\t.setCancelable(true)\n\t\t\t.setPositiveButton(\"Disconnect\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tdisconnect();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setNegativeButton(\"Cancel\", null);\n\t\t\treturn builder.create();\n\t\t} case FindBattle: {\n\t\t\tfinal EditText range = new EditText(this);\n\t\t\trange.append(\"\" + (prefs.contains(\"range\") ? prefs.getInt(\"range\", 0) : \"\"));\n\t\t\trange.setInputType(InputType.TYPE_CLASS_NUMBER);\n\t\t\trange.setHint(\"Range\");\n\t\t\tbuilder.setTitle(R.string.find_a_battle)\n\t\t\t.setMultiChoiceItems(new CharSequence[]{\"Force Rated\", \"Force Same Tier\", \"Only within range\"}, new boolean[]{prefs.getBoolean(\"findOption0\", false), prefs.getBoolean(\"findOption1\", false), prefs.getBoolean(\"findOption2\", false)}, new DialogInterface.OnMultiChoiceClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which, boolean isChecked) {\n\t\t\t\t\tprefs.edit().putBoolean(\"findOption\" + which, isChecked).commit();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setView(range)\n\t\t\t.setPositiveButton(\"Find\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tif (netServ != null && netServ.socket.isConnected()) {\n\t\t\t\t\t\tnetServ.findingBattle = true;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tprefs.edit().putInt(\"range\", Integer.valueOf(range.getText().toString())).commit();\n\t\t\t\t\t\t} catch (NumberFormatException e) {\n\t\t\t\t\t\t\tprefs.edit().remove(\"range\").commit();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnetServ.socket.sendMessage(\n\t\t\t\t\t\t\t\tconstructFindBattle(prefs.getBoolean(\"findOption0\", false), prefs.getBoolean(\"findOption1\", false), prefs.getBoolean(\"findOption2\", false), prefs.getInt(\"range\", 200), (byte) 0),\n\t\t\t\t\t\t\t\tCommand.FindBattle);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn builder.create();\n\t\t} case TierSelection: {\n\t\t\tif (netServ == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn new TierAlertDialog(this, netServ.superTier);\n\t\t} case PlayerInfo: {\n\t\t\tView layout = inflater.inflate(R.layout.player_info_dialog, (LinearLayout)findViewById(R.id.player_info_dialog));\n ImageView[] pPokeIcons = new ImageView[6];\n TextView pInfo, pName;\n ListView ratings;\n\t\t\tbuilder.setView(layout)\n .setNegativeButton(\"Back\", new DialogInterface.OnClickListener(){\n \tpublic void onClick(DialogInterface dialog, int which) {\n \t\tremoveDialog(id);\n \t}\n })\n .setOnCancelListener(new DialogInterface.OnCancelListener(){\n \tpublic void onCancel(DialogInterface dialog) {\n \t\tremoveDialog(id);\n \t}\n })\n .setPositiveButton(\"Challenge\", new DialogInterface.OnClickListener(){\n \tpublic void onClick(DialogInterface dialog, int which) {\n \t\t\tshowDialog(ChatDialog.ChallengeMode.ordinal());\n \t\tremoveDialog(id);\n \t}});\n final AlertDialog pInfoDialog = builder.create();\n for(int i = 0; i < 6; i++){\n \tpPokeIcons[i] = (ImageView)layout.findViewById(getResources().getIdentifier(\"player_info_poke\" + \n \t\t\t(i+1), \"id\", packName));\n }\n \tpInfo = (TextView)layout.findViewById(R.id.player_info);\n \tpInfo.setText(Html.fromHtml(\"Info: \" + StringUtilities.escapeHtml(lastClickedPlayer.info())));\n \tpName = (TextView)layout.findViewById(R.id.player_info_name);\n \tpName.setText(lastClickedPlayer.nick());\n \tratings = (ListView)layout.findViewById(R.id.player_info_tiers);\n \tratings.setAdapter(new TwoViewsArrayAdapter(this, android.R.layout.simple_list_item_2, \n \t\t\tandroid.R.id.text1, android.R.id.text2, lastClickedPlayer.tierStandings, PlayerInfo.tierGetter));\n return pInfoDialog;\n\t\t} case ChallengeMode: {\n final Clauses[] clauses = Clauses.values();\n final int numClauses = clauses.length;\n\t\t\tfinal String[] clauseNames = new String[numClauses];\n\t\t\tfinal boolean[] checked = new boolean[numClauses];\n\t\t\tfor (int i=0; i < numClauses; i++) {\n\t\t\t\tclauseNames[i] = clauses[i].toString();\n\t\t\t\tchecked[i] = prefs.getBoolean(\"challengeOption\" + i, false);\n\t\t\t}\n builder.setMultiChoiceItems(clauseNames, checked, new DialogInterface.OnMultiChoiceClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which, boolean isChecked) {\n\t\t\t\t\tprefs.edit().putBoolean(\"challengeOption\" + which, isChecked).commit();\n\t\t\t\t}\n\t\t\t})\n\t\t\t.setPositiveButton(\"Challenge\", new DialogInterface.OnClickListener() {\n\t\t\t\tpublic void onClick(DialogInterface dialog, int which) {\n\t\t\t\t\tint clauses = 0;\n\t\t\t\t\tfor (int i = 0; i < numClauses; i++)\n\t\t\t\t\t\tclauses |= (prefs.getBoolean(\"challengeOption\" + i, false) ? Clauses.values()[i].mask() : 0);\n\t\t\t\t\tif (netServ != null && netServ.socket != null && netServ.socket.isConnected())\n\t\t\t\t\t\tnetServ.socket.sendMessage(constructChallenge(ChallengeDesc.Sent.ordinal(), lastClickedPlayer.id, clauses, Mode.Singles.ordinal()), Command.ChallengeStuff);\n\t\t\t\t\tremoveDialog(id);\n\t\t\t\t}\n\t\t\t})\n .setNegativeButton(\"Back\", new DialogInterface.OnClickListener(){\n \tpublic void onClick(DialogInterface dialog, int which) {\n \t\tremoveDialog(id);\n \t}\n })\n .setOnCancelListener(new DialogInterface.OnCancelListener(){\n \tpublic void onCancel(DialogInterface dialog) {\n \t\tremoveDialog(id);\n \t}\n })\n .setTitle(\"Select clauses\");\n return builder.create();\n\t\t} default: {\n\t\t\treturn new Dialog(this);\n\t\t}\n\t\t}\n\t}\n"} {"input": "\tpublic String getRemoteAddr(HttpServletRequest req) {\n\t\tString ip = req.getHeader(\"X-Forwarded-For\");\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"Proxy-Client-IP\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"WL-Proxy-Client-IP\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"HTTP_CLIENT_IP\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"HTTP_X_FORWARDED_FOR\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getRemoteAddr();\n\t\t\tif(ip.equals(\"127.0.0.1\")){\n\t\t\t\tip = IPUtils.getFirstNoLoopbackIP4Address();\n\t\t\t}\n\t\t}\n\t\treturn ip;\n\t}\n", "output": "\tpublic String getRemoteAddr(HttpServletRequest req) {\n\t\tString ip = req.getHeader(\"X-Forwarded-For\");\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"Proxy-Client-IP\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"WL-Proxy-Client-IP\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"HTTP_CLIENT_IP\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getHeader(\"HTTP_X_FORWARDED_FOR\");\n\t\t}\n\t\tif (StringUtils.isEmpty(ip) || \"unknown\".equalsIgnoreCase(ip)) {\n\t\t\tip = req.getRemoteAddr();\n\t\t\tif(ip.equals(\"127.0.0.1\") && ip.startsWith(\"0:0:0:0:0:0:0:1\")){\n\t\t\t\tip = IPUtils.getFirstNoLoopbackIP4Address();\n\t\t\t}\n\t\t}\n\t\treturn ip;\n\t}\n"} {"input": "\tpublic boolean parseDataXML(Reader reader) {\n\t\tboolean success = false;\n\t\tXmlPullParserFactory factory;\n\t\ttry {\n\t\t\tfactory = XmlPullParserFactory.newInstance();\n\t\t\tXmlPullParser parser = factory.newPullParser();\n\t\t\tparser.setInput(reader);\n\t\t\tboolean done = false;\n\t\t\tdo {\n\t\t\t\tswitch (parser.getEventType()){\n\t\t\t\t\tcase XmlPullParser.START_TAG:\n\t\t\t\t\t\tString tagName = parser.getName();\n\t\t\t\t\t\tif (tagName.equals(\"area\")){\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"id\")) {\n\t\t\t\t\t\t\tthis.mAreaId = Integer.valueOf(parser.nextText()).intValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"name\")) {\n\t\t\t\t\t\t\tthis.mAreaName = parser.nextText();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"desc\")) {\n\t\t\t\t\t\t\tthis.mAreaDescription = parser.nextText();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"version\")) {\n\t\t\t\t\t\t\tthis.mAreaVersion = Integer.valueOf(parser.nextText()).intValue();\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t\telse if (tagName.equals(\"Ticket\")) {\n\t\t\t\t\t\t\tTicket t = getTicketFromAttributes(parser);\n\t\t\t\t\t\t\tthis.mAreaTickets.put(t.getId(), t);\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"Station\")) {\n\t\t\t\t\t\t\tStation s = getStationFromAttributes(parser);\n\t\t\t\t\t\t\tthis.mAreaStations.put(s.getId(), s);\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"Route\")) {\n\t\t\t\t\t\t\tRoute r = getRouteFromAttributes(parser);\n\t\t\t\t\t\t\tthis.mAreaRoutes.put(r.getId(), r);\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase XmlPullParser.END_TAG:\n\t\t\t\t\t\tif (parser.getName().equals(\"area\")){\n\t\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase XmlPullParser.END_DOCUMENT:\n\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tparser.next();\n\t\t\t\t}\n\t\t\t} while (!done);\n\t\t\tsuccess = true;\n\t\t} catch (XmlPullParserException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (FileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tint counter = 0;\n\t\tfor(Ticket ticket : mAreaTickets.values()){\n\t\t\tif(!ticket.isSuperior()){\n\t\t\t\tfor(Route route : mAreaRoutes.values()){\n\t\t\t\t\tif(route.getTicketId() == ticket.getId()\n\t\t\t\t\t\t\t&& counter < mPathPaints.size())\n\t\t\t\t\t\troute.setPathPaint(mPathPaints.get(counter));\n\t\t\t\t}\n\t\t\t\tcounter++;\n\t\t\t}\n\t\t}\n\t\treturn success;\n\t}\n", "output": "\tpublic boolean parseDataXML(Reader reader) {\n\t\tboolean success = false;\n\t\tXmlPullParserFactory factory;\n\t\ttry {\n\t\t\tfactory = XmlPullParserFactory.newInstance();\n\t\t\tXmlPullParser parser = factory.newPullParser();\n\t\t\tparser.setInput(reader);\n\t\t\tboolean done = false;\n\t\t\tdo {\n\t\t\t\tswitch (parser.getEventType()){\n\t\t\t\t\tcase XmlPullParser.START_TAG:\n\t\t\t\t\t\tString tagName = parser.getName();\n\t\t\t\t\t\tif (tagName.equals(\"area\")){\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"id\")) {\n\t\t\t\t\t\t\tthis.mAreaId = Integer.valueOf(parser.nextText()).intValue();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"name\")) {\n\t\t\t\t\t\t\tthis.mAreaName = parser.nextText();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"desc\")) {\n\t\t\t\t\t\t\tthis.mAreaDescription = parser.nextText();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"version\")) {\n\t\t\t\t\t\t\tthis.mAreaVersion = Integer.valueOf(parser.nextText()).intValue();\n\t\t\t\t\t\t}\t\t\t\t\t\t\n\t\t\t\t\t\telse if (tagName.equals(\"Ticket\")) {\n\t\t\t\t\t\t\tTicket t = getTicketFromAttributes(parser);\n\t\t\t\t\t\t\tthis.mAreaTickets.put(t.getId(), t);\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"Station\")) {\n\t\t\t\t\t\t\tStation s = getStationFromAttributes(parser);\n\t\t\t\t\t\t\tthis.mAreaStations.put(s.getId(), s);\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (tagName.equals(\"Route\")) {\n\t\t\t\t\t\t\tRoute r = getRouteFromAttributes(parser);\n\t\t\t\t\t\t\tint stationCount = r.getStationIds().size();\n\t\t\t\t\t\t\tif (stationCount > 1) {\n\t\t\t\t\t\t\t\tthis.mAreaRoutes.put(r.getId(), r);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase XmlPullParser.END_TAG:\n\t\t\t\t\t\tif (parser.getName().equals(\"area\")){\n\t\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tparser.next();\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase XmlPullParser.END_DOCUMENT:\n\t\t\t\t\t\tdone = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tparser.next();\n\t\t\t\t}\n\t\t\t} while (!done);\n\t\t\tsuccess = true;\n\t\t} catch (XmlPullParserException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (FileNotFoundException e) {\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\tint counter = 0;\n\t\tfor(Ticket ticket : mAreaTickets.values()){\n\t\t\tif(!ticket.isSuperior()){\n\t\t\t\tfor(Route route : mAreaRoutes.values()){\n\t\t\t\t\tif(route.getTicketId() == ticket.getId()\n\t\t\t\t\t\t\t&& counter < mPathPaints.size())\n\t\t\t\t\t\troute.setPathPaint(mPathPaints.get(counter));\n\t\t\t\t}\n\t\t\t\tcounter++;\n\t\t\t}\n\t\t}\n\t\treturn success;\n\t}\n"} {"input": " public void testParsing() throws IOException {\n String base = \"http://a/b/c/d;p?q\";\n String uri01 = \"g:h\";\n String uri02 = \"g\";\n String uri03 = \"./g\";\n String uri04 = \"g/\";\n String uri05 = \"/g\";\n String uri06 = \"//g\";\n String uri07 = \"?y\";\n String uri08 = \"g?y\";\n String uri09 = \"#s\";\n String uri10 = \"g#s\";\n String uri11 = \"g?y#s\";\n String uri12 = \";x\";\n String uri13 = \"g;x\";\n String uri14 = \"g;x?y#s\";\n String uri15 = \"\";\n String uri16 = \".\";\n String uri17 = \"./\";\n String uri18 = \"..\";\n String uri19 = \"../\";\n String uri20 = \"../g\";\n String uri21 = \"../..\";\n String uri22 = \"../../\";\n String uri23 = \"../../g\";\n String uri24 = \"../../../g\";\n String uri25 = \"../../../../g\";\n String uri26 = \"/./g\";\n String uri27 = \"/../g\";\n String uri28 = \"g.\";\n String uri29 = \".g\";\n String uri30 = \"g..\";\n String uri31 = \"..g\";\n String uri32 = \"./../g\";\n String uri33 = \"./g/.\";\n String uri34 = \"g/./h\";\n String uri35 = \"g/../h\";\n String uri36 = \"g;x=1/./y\";\n String uri37 = \"g;x=1/../y\";\n String uri101 = \"g:h\";\n String uri102 = \"http://a/b/c/g\";\n String uri103 = \"http://a/b/c/g\";\n String uri104 = \"http://a/b/c/g/\";\n String uri105 = \"http://a/g\";\n String uri106 = \"http://g\";\n String uri107 = \"http://a/b/c/d;p?y\";\n String uri108 = \"http://a/b/c/g?y\";\n String uri109 = \"http://a/b/c/d;p?q#s\";\n String uri110 = \"http://a/b/c/g#s\";\n String uri111 = \"http://a/b/c/g?y#s\";\n String uri112 = \"http://a/b/c/;x\";\n String uri113 = \"http://a/b/c/g;x\";\n String uri114 = \"http://a/b/c/g;x?y#s\";\n String uri115 = \"http://a/b/c/d;p?q\";\n String uri116 = \"http://a/b/c/\";\n String uri117 = \"http://a/b/c/\";\n String uri118 = \"http://a/b/\";\n String uri119 = \"http://a/b/\";\n String uri120 = \"http://a/b/g\";\n String uri121 = \"http://a/\";\n String uri122 = \"http://a/\";\n String uri123 = \"http://a/g\";\n String uri124 = \"http://a/g\";\n String uri125 = \"http://a/g\";\n String uri126 = \"http://a/g\";\n String uri127 = \"http://a/g\";\n String uri128 = \"http://a/b/c/g.\";\n String uri129 = \"http://a/b/c/.g\";\n String uri130 = \"http://a/b/c/g..\";\n String uri131 = \"http://a/b/c/..g\";\n String uri132 = \"http://a/b/g\";\n String uri133 = \"http://a/b/c/g/\";\n String uri134 = \"http://a/b/c/g/h\";\n String uri135 = \"http://a/b/c/h\";\n String uri136 = \"http://a/b/c/g;x=1/y\";\n String uri137 = \"http://a/b/c/y\";\n testRef0(\"foo://example.com:8042/over/there?name=ferret#nose\", \"foo\",\n \"example.com:8042\", \"/over/there\", \"name=ferret\", \"nose\");\n testRef0(\"urn:example:animal:ferret:nose\", \"urn\", null,\n \"example:animal:ferret:nose\", null, null);\n testRef0(\"mailto:fred@example.com\", \"mailto\", null, \"fred@example.com\",\n null, null);\n testRef0(\"foo://info.example.com?fred\", \"foo\", \"info.example.com\",\n null, \"fred\", null);\n testRef0(\"*\", null, null, \"*\", null, null);\n testRef1(base, uri01, uri101);\n testRef1(base, uri02, uri102);\n testRef1(base, uri03, uri103);\n testRef1(base, uri04, uri104);\n testRef1(base, uri05, uri105);\n testRef1(base, uri06, uri106);\n testRef1(base, uri07, uri107);\n testRef1(base, uri08, uri108);\n testRef1(base, uri09, uri109);\n testRef1(base, uri10, uri110);\n testRef1(base, uri11, uri111);\n testRef1(base, uri12, uri112);\n testRef1(base, uri13, uri113);\n testRef1(base, uri14, uri114);\n testRef1(base, uri15, uri115);\n testRef1(base, uri16, uri116);\n testRef1(base, uri17, uri117);\n testRef1(base, uri18, uri118);\n testRef1(base, uri19, uri119);\n testRef1(base, uri20, uri120);\n testRef1(base, uri21, uri121);\n testRef1(base, uri22, uri122);\n testRef1(base, uri23, uri123);\n testRef1(base, uri24, uri124);\n testRef1(base, uri25, uri125);\n testRef1(base, uri26, uri126);\n testRef1(base, uri27, uri127);\n testRef1(base, uri28, uri128);\n testRef1(base, uri29, uri129);\n testRef1(base, uri30, uri130);\n testRef1(base, uri31, uri131);\n testRef1(base, uri32, uri132);\n testRef1(base, uri33, uri133);\n testRef1(base, uri34, uri134);\n testRef1(base, uri35, uri135);\n testRef1(base, uri36, uri136);\n testRef1(base, uri37, uri137);\n testRef2(base, uri102, uri02);\n testRef2(base, uri104, uri04);\n testRef2(base, uri107, uri07);\n testRef2(base, uri108, uri08);\n testRef2(base, uri109, uri09);\n testRef2(base, uri110, uri10);\n testRef2(base, uri111, uri11);\n testRef2(base, uri112, uri12);\n testRef2(base, uri113, uri13);\n testRef2(base, uri114, uri14);\n testRef2(base, uri116, uri16);\n testRef2(base, uri118, uri18);\n testRef2(base, uri120, uri20);\n testRef2(base, uri121, uri21);\n testRef2(base, uri123, uri23);\n }\n", "output": " public void testParsing() throws IOException {\n String base = \"http://a/b/c/d;p?q\";\n String uri01 = \"g:h\";\n String uri02 = \"g\";\n String uri03 = \"./g\";\n String uri04 = \"g/\";\n String uri05 = \"/g\";\n String uri06 = \"//g\";\n String uri07 = \"?y\";\n String uri08 = \"g?y\";\n String uri09 = \"#s\";\n String uri10 = \"g#s\";\n String uri11 = \"g?y#s\";\n String uri12 = \";x\";\n String uri13 = \"g;x\";\n String uri14 = \"g;x?y#s\";\n String uri15 = \"\";\n String uri16 = \".\";\n String uri17 = \"./\";\n String uri18 = \"..\";\n String uri19 = \"../\";\n String uri20 = \"../g\";\n String uri21 = \"../..\";\n String uri22 = \"../../\";\n String uri23 = \"../../g\";\n String uri24 = \"../../../g\";\n String uri25 = \"../../../../g\";\n String uri26 = \"/./g\";\n String uri27 = \"/../g\";\n String uri28 = \"g.\";\n String uri29 = \".g\";\n String uri30 = \"g..\";\n String uri31 = \"..g\";\n String uri32 = \"./../g\";\n String uri33 = \"./g/.\";\n String uri34 = \"g/./h\";\n String uri35 = \"g/../h\";\n String uri36 = \"g;x=1/./y\";\n String uri37 = \"g;x=1/../y\";\n String uri101 = \"g:h\";\n String uri102 = \"http://a/b/c/g\";\n String uri103 = \"http://a/b/c/g\";\n String uri104 = \"http://a/b/c/g/\";\n String uri105 = \"http://a/g\";\n String uri106 = \"http://g\";\n String uri107 = \"http://a/b/c/d;p?y\";\n String uri108 = \"http://a/b/c/g?y\";\n String uri109 = \"http://a/b/c/d;p?q#s\";\n String uri110 = \"http://a/b/c/g#s\";\n String uri111 = \"http://a/b/c/g?y#s\";\n String uri112 = \"http://a/b/c/;x\";\n String uri113 = \"http://a/b/c/g;x\";\n String uri114 = \"http://a/b/c/g;x?y#s\";\n String uri115 = \"http://a/b/c/d;p?q\";\n String uri116 = \"http://a/b/c/\";\n String uri117 = \"http://a/b/c/\";\n String uri118 = \"http://a/b/\";\n String uri119 = \"http://a/b/\";\n String uri120 = \"http://a/b/g\";\n String uri121 = \"http://a/\";\n String uri122 = \"http://a/\";\n String uri123 = \"http://a/g\";\n String uri124 = \"http://a/g\";\n String uri125 = \"http://a/g\";\n String uri126 = \"http://a/g\";\n String uri127 = \"http://a/g\";\n String uri128 = \"http://a/b/c/g.\";\n String uri129 = \"http://a/b/c/.g\";\n String uri130 = \"http://a/b/c/g..\";\n String uri131 = \"http://a/b/c/..g\";\n String uri132 = \"http://a/b/g\";\n String uri133 = \"http://a/b/c/g/\";\n String uri134 = \"http://a/b/c/g/h\";\n String uri135 = \"http://a/b/c/h\";\n String uri136 = \"http://a/b/c/g;x=1/y\";\n String uri137 = \"http://a/b/c/y\";\n testRef0(\"foo://example.com:8042/over/there?name=ferret#nose\", \"foo\",\n \"example.com:8042\", \"/over/there\", \"name=ferret\", \"nose\");\n testRef0(\"urn:example:animal:ferret:nose\", \"urn\", null,\n \"example:animal:ferret:nose\", null, null);\n testRef0(\"mailto:fred@example.com\", \"mailto\", null, \"fred@example.com\",\n null, null);\n testRef0(\"foo://info.example.com?fred\", \"foo\", \"info.example.com\",\n null, \"fred\", null);\n testRef0(\"*\", null, null, \"*\", null, null);\n testRef0(\"http://localhost?query\", \"http\", \"localhost\", null, \"query\", null);\n testRef0(\"http://localhost#?query\", \"http\", \"localhost\", null, null, \"?query\");\n testRef0(\"http://localhost/?query\", \"http\", \"localhost\", \"/\", \"query\", null);\n testRef0(\"http://localhost/#?query\", \"http\", \"localhost\", \"/\", null, \"?query\");\n testRef1(base, uri01, uri101);\n testRef1(base, uri02, uri102);\n testRef1(base, uri03, uri103);\n testRef1(base, uri04, uri104);\n testRef1(base, uri05, uri105);\n testRef1(base, uri06, uri106);\n testRef1(base, uri07, uri107);\n testRef1(base, uri08, uri108);\n testRef1(base, uri09, uri109);\n testRef1(base, uri10, uri110);\n testRef1(base, uri11, uri111);\n testRef1(base, uri12, uri112);\n testRef1(base, uri13, uri113);\n testRef1(base, uri14, uri114);\n testRef1(base, uri15, uri115);\n testRef1(base, uri16, uri116);\n testRef1(base, uri17, uri117);\n testRef1(base, uri18, uri118);\n testRef1(base, uri19, uri119);\n testRef1(base, uri20, uri120);\n testRef1(base, uri21, uri121);\n testRef1(base, uri22, uri122);\n testRef1(base, uri23, uri123);\n testRef1(base, uri24, uri124);\n testRef1(base, uri25, uri125);\n testRef1(base, uri26, uri126);\n testRef1(base, uri27, uri127);\n testRef1(base, uri28, uri128);\n testRef1(base, uri29, uri129);\n testRef1(base, uri30, uri130);\n testRef1(base, uri31, uri131);\n testRef1(base, uri32, uri132);\n testRef1(base, uri33, uri133);\n testRef1(base, uri34, uri134);\n testRef1(base, uri35, uri135);\n testRef1(base, uri36, uri136);\n testRef1(base, uri37, uri137);\n testRef2(base, uri102, uri02);\n testRef2(base, uri104, uri04);\n testRef2(base, uri107, uri07);\n testRef2(base, uri108, uri08);\n testRef2(base, uri109, uri09);\n testRef2(base, uri110, uri10);\n testRef2(base, uri111, uri11);\n testRef2(base, uri112, uri12);\n testRef2(base, uri113, uri13);\n testRef2(base, uri114, uri14);\n testRef2(base, uri116, uri16);\n testRef2(base, uri118, uri18);\n testRef2(base, uri120, uri20);\n testRef2(base, uri121, uri21);\n testRef2(base, uri123, uri23);\n }\n"} {"input": " public void testMethodCheck()\n {\n ApiDifference[] expected = new ApiDifference[] {\n new ApiDifference(\"Method 'public void removedMethod(java.lang.String)' has been removed in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void removedMethod(java.lang.String)\", null),\n new ApiDifference(\"Method 'public int getPriv2()' has been removed in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public int getPriv2()\", null),\n new ApiDifference(\"Method 'public java.lang.Long getPrivSquare()' has been added in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"public java.lang.Long getPrivSquare()\", null),\n new ApiDifference(\"Method 'public void moveToSuper()' has been added in testlib.ComplexMethodMoveBase\",\n Severity.INFO, \"testlib.ComplexMethodMoveBase\", \"public void moveToSuper()\", null),\n new ApiDifference(\"Method 'public void moveToSuper()' is now implemented in superclass testlib.ComplexMethodMoveBase in testlib.ComplexMethodMoveSub\",\n Severity.INFO, \"testlib.ComplexMethodMoveSub\", \"public void moveToSuper()\", null),\n new ApiDifference(\"Abstract method 'public void method()' is now specified by implemented interface testlib.BaseInterface in testlib.AbstractImpl\",\n Severity.INFO, \"testlib.AbstractImpl\", \"public void method()\", null),\n new ApiDifference(\"Parameter 1 of 'protected MethodsChange(int)' has changed it's type to java.lang.Integer in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"protected MethodsChange(int)\", null),\n new ApiDifference(\"Return type of Method 'public java.lang.Number getPrivAsNumber()' has been changed to java.lang.Integer in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public java.lang.Number getPrivAsNumber()\", null),\n new ApiDifference(\"Return type of Method 'public java.lang.Integer getPrivAsInteger()' has been changed to java.lang.Number in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public java.lang.Integer getPrivAsInteger()\", null),\n new ApiDifference(\"In Method 'public void printPriv()' the number of arguments has changed in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void printPriv()\", null),\n new ApiDifference(\"Parameter 1 of 'public void strengthenParamType(java.lang.Object)' has changed it's type to java.lang.String in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void strengthenParamType(java.lang.Object)\", null),\n new ApiDifference(\"Parameter 1 of 'public void weakenParamType(java.lang.String)' has changed it's type to java.lang.Object in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void weakenParamType(java.lang.String)\", null),\n new ApiDifference(\"Parameter 1 of 'public void changeParamType(java.lang.String)' has changed it's type to java.lang.Integer in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void changeParamType(java.lang.String)\", null),\n new ApiDifference(\"Method 'public void becomesDeprecated()' has been deprecated in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"public void becomesDeprecated()\", null),\n new ApiDifference(\"Method 'public void becomesUndeprecated()' is no longer deprecated in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"public void becomesUndeprecated()\", null),\n };\n verify(expected);\n }\n", "output": " public void testMethodCheck()\n {\n ApiDifference[] expected = new ApiDifference[] {\n new ApiDifference(\"Method 'public void removedMethod(java.lang.String)' has been removed in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void removedMethod(java.lang.String)\", null),\n new ApiDifference(\"Method 'public int getPriv2()' has been removed in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public int getPriv2()\", null),\n new ApiDifference(\"Method 'protected MethodsChange(int, boolean)' has been added in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"protected MethodsChange(int, boolean)\", null),\n new ApiDifference(\"Method 'public java.lang.Long getPrivSquare()' has been added in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"public java.lang.Long getPrivSquare()\", null),\n new ApiDifference(\"Method 'public void moveToSuper()' has been added in testlib.ComplexMethodMoveBase\",\n Severity.INFO, \"testlib.ComplexMethodMoveBase\", \"public void moveToSuper()\", null),\n new ApiDifference(\"Method 'public void moveToSuper()' is now implemented in superclass testlib.ComplexMethodMoveBase in testlib.ComplexMethodMoveSub\",\n Severity.INFO, \"testlib.ComplexMethodMoveSub\", \"public void moveToSuper()\", null),\n new ApiDifference(\"Abstract method 'public void method()' is now specified by implemented interface testlib.BaseInterface in testlib.AbstractImpl\",\n Severity.INFO, \"testlib.AbstractImpl\", \"public void method()\", null),\n new ApiDifference(\"Parameter 1 of 'protected MethodsChange(int)' has changed it's type to java.lang.Integer in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"protected MethodsChange(int)\", null),\n new ApiDifference(\"Return type of Method 'public java.lang.Number getPrivAsNumber()' has been changed to java.lang.Integer in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public java.lang.Number getPrivAsNumber()\", null),\n new ApiDifference(\"Return type of Method 'public java.lang.Integer getPrivAsInteger()' has been changed to java.lang.Number in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public java.lang.Integer getPrivAsInteger()\", null),\n new ApiDifference(\"In Method 'public void printPriv()' the number of arguments has changed in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void printPriv()\", null),\n new ApiDifference(\"Parameter 1 of 'public void strengthenParamType(java.lang.Object)' has changed it's type to java.lang.String in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void strengthenParamType(java.lang.Object)\", null),\n new ApiDifference(\"Parameter 1 of 'public void weakenParamType(java.lang.String)' has changed it's type to java.lang.Object in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void weakenParamType(java.lang.String)\", null),\n new ApiDifference(\"Parameter 1 of 'public void changeParamType(java.lang.String)' has changed it's type to java.lang.Integer in testlib.MethodsChange\",\n Severity.ERROR, \"testlib.MethodsChange\", \"public void changeParamType(java.lang.String)\", null),\n new ApiDifference(\"Method 'public void becomesDeprecated()' has been deprecated in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"public void becomesDeprecated()\", null),\n new ApiDifference(\"Method 'public void becomesUndeprecated()' is no longer deprecated in testlib.MethodsChange\",\n Severity.INFO, \"testlib.MethodsChange\", \"public void becomesUndeprecated()\", null),\n };\n verify(expected);\n }\n"} {"input": " protected MongoCollection collection(Class entityClass) {\n class TAtomicOperation extends AtomicOperation {\n public TAtomicOperation(Datastore ds, Query query, boolean multiple) {\n super(ds, query, multiple);\n }\n }\n class TMongoCollection extends MongoCollection {\n public TMongoCollection(Class entityClass, Datastore ds) {\n super(entityClass, ds);\n }\n @Override\n public AtomicOperation atomic(Filter... filters) {\n return new TAtomicOperation(ds, query(filters), false);\n }\n @Override\n public AtomicOperation atomicAll(Filter... filters) {\n return new TAtomicOperation(ds, query(filters), true);\n }\n }\n if (collectionCache.contains(entityClass, ds())) {\n return collectionCache.get(entityClass, ds(), TMongoCollection.class);\n }\n return collectionCache.add(entityClass, ds(), new TMongoCollection(entityClass, ds()));\n }\n", "output": " public MongoCollection collection(Class entityClass) {\n class TAtomicOperation extends AtomicOperation {\n public TAtomicOperation(Datastore ds, Query query, boolean multiple) {\n super(ds, query, multiple);\n }\n }\n class TMongoCollection extends MongoCollection {\n public TMongoCollection(Class entityClass, Datastore ds) {\n super(entityClass, ds);\n }\n @Override\n public AtomicOperation atomic(Filter... filters) {\n return new TAtomicOperation(ds, query(filters), false);\n }\n @Override\n public AtomicOperation atomicAll(Filter... filters) {\n return new TAtomicOperation(ds, query(filters), true);\n }\n }\n if (collectionCache.contains(entityClass, ds())) {\n return collectionCache.get(entityClass, ds(), TMongoCollection.class);\n }\n return collectionCache.add(entityClass, ds(), new TMongoCollection(entityClass, ds()));\n }\n"} {"input": " public static String mergePaths(String ...items) {\n StringBuilder result = new StringBuilder();\n for (String item: items) {\n boolean trimThisMerge = result.length()>0 && !result.toString().endsWith(\"://\") && !result.toString().endsWith(\":///\") && !result.toString().endsWith(\":\");\n if (trimThisMerge) {\n while (result.charAt(result.length()-1)=='/')\n result.deleteCharAt(result.length()-1);\n result.append('/');\n }\n int i = result.length();\n result.append(item);\n if (trimThisMerge) {\n while (result.charAt(i)=='/')\n result.deleteCharAt(i);\n }\n }\n return result.toString();\n }\n", "output": " public static String mergePaths(String ...items) {\n StringBuilder result = new StringBuilder();\n for (String item: items) {\n boolean trimThisMerge = result.length()>0 && !result.toString().endsWith(\"://\") && !result.toString().endsWith(\":///\") && !result.toString().endsWith(\":\");\n if (trimThisMerge) {\n while (result.charAt(result.length()-1)=='/')\n result.deleteCharAt(result.length()-1);\n result.append('/');\n }\n int i = result.length();\n result.append(item);\n if (trimThisMerge) {\n while (result.length()>i && result.charAt(i)=='/')\n result.deleteCharAt(i);\n }\n }\n return result.toString();\n }\n"} {"input": "\tprotected void handleSearchButtonSelected() {\n\t\tIJavaElement[] scope= null;\n\t\tIJavaProject project = getJavaProject();\n\t\tif (scope == null) {\n\t\t\ttry {\n\t\t\t\tscope = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();\n\t\t\t}\n\t\t\tcatch (JavaModelException e) {\n\t\t\t\tsetErrorMessage(e.getMessage());\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tscope = new IJavaElement[]{project};\n\t\t}\n\t\tIType[] types = null;\n\t\ttry {\n\t\t\ttypes = AppletLaunchConfigurationUtils.findApplets(getLaunchConfigurationDialog(), scope);\n\t\t} \n\t\tcatch (InterruptedException e) {return;} \n\t\tcatch (InvocationTargetException e) {\n\t\t\tsetErrorMessage(e.getTargetException().getMessage());\n\t\t\treturn;\n\t\t}\n\t\tSelectionDialog dialog = null;\n\t\ttry {\n\t\t\tdialog = JavaUI.createTypeDialog(\n\t\t\t\t\tgetShell(),\n\t\t\t\t\tgetLaunchConfigurationDialog(),\n\t\t\t\t\tSearchEngine.createJavaSearchScope(types),\n\t\t\t\t\tIJavaElementSearchConstants.CONSIDER_CLASSES, \n\t\t\t\t\tfalse,\n\t\t\t\t\t\"**\"); \n\t\t}\n\t\tcatch (JavaModelException e) {\n\t\t\tsetErrorMessage(e.getMessage());\n\t\t\treturn;\n\t\t}\n\t\tdialog.setTitle(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_title); \n \t\tdialog.setMessage(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_message); \n\t\tif (dialog.open() == Window.CANCEL) {\n\t\t\treturn;\n\t\t}\n\t\tObject[] results= dialog.getResult();\t\n\t\tIType type= (IType)results[0];\n\t\tif (type != null) {\n\t\t\tfMainText.setText(type.getFullyQualifiedName());\n\t\t\tfProjText.setText(type.getJavaProject().getElementName());\n\t\t}\n\t}\n", "output": "\tprotected void handleSearchButtonSelected() {\n\t\tIJavaElement[] scope= null;\n\t\tIJavaProject project = getJavaProject();\n\t\tif (project == null) {\n\t\t\ttry {\n\t\t\t\tscope = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();\n\t\t\t}\n\t\t\tcatch (JavaModelException e) {\n\t\t\t\tsetErrorMessage(e.getMessage());\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tscope = new IJavaElement[]{project};\n\t\t}\n\t\tIType[] types = null;\n\t\ttry {\n\t\t\ttypes = AppletLaunchConfigurationUtils.findApplets(getLaunchConfigurationDialog(), scope);\n\t\t} \n\t\tcatch (InterruptedException e) {return;} \n\t\tcatch (InvocationTargetException e) {\n\t\t\tsetErrorMessage(e.getTargetException().getMessage());\n\t\t\treturn;\n\t\t}\n\t\tSelectionDialog dialog = null;\n\t\ttry {\n\t\t\tdialog = JavaUI.createTypeDialog(\n\t\t\t\t\tgetShell(),\n\t\t\t\t\tgetLaunchConfigurationDialog(),\n\t\t\t\t\tSearchEngine.createJavaSearchScope(types),\n\t\t\t\t\tIJavaElementSearchConstants.CONSIDER_CLASSES, \n\t\t\t\t\tfalse,\n\t\t\t\t\t\"**\"); \n\t\t}\n\t\tcatch (JavaModelException e) {\n\t\t\tsetErrorMessage(e.getMessage());\n\t\t\treturn;\n\t\t}\n\t\tdialog.setTitle(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_title); \n \t\tdialog.setMessage(LauncherMessages.appletlauncher_maintab_selection_applet_dialog_message); \n\t\tif (dialog.open() == Window.CANCEL) {\n\t\t\treturn;\n\t\t}\n\t\tObject[] results= dialog.getResult();\t\n\t\tIType type= (IType)results[0];\n\t\tif (type != null) {\n\t\t\tfMainText.setText(type.getFullyQualifiedName());\n\t\t\tfProjText.setText(type.getJavaProject().getElementName());\n\t\t}\n\t}\n"} {"input": "\tpublic int update(Uri uri, ContentValues values, String where,\n\t\t\tString[] whereArgs) {\n\t\tint count = 0;\n\t\tString podcastId;\n\t\tSharedPreferences prefs = getContext().getSharedPreferences(\"internals\", Context.MODE_WORLD_READABLE);\n\t\tLong activePodcastId = prefs.getLong(PREF_ACTIVE, -1);\n\t\tswitch (uriMatcher.match(uri)) {\n\t\tcase PODCAST_ID:\n\t\t\tpodcastId = uri.getLastPathSegment();\n\t\t\tbreak;\n\t\tcase PODCASTS_ACTIVE:\n\t\t\tif (values.containsKey(COLUMN_ID)) {\n\t\t\t\tactivePodcastId = values.getAsLong(COLUMN_ID);\n\t\t\t\tEditor editor = prefs.edit();\n\t\t\t\tif (activePodcastId != null)\n\t\t\t\t\teditor.putLong(PREF_ACTIVE, values.getAsLong(COLUMN_ID));\n\t\t\t\telse\n\t\t\t\t\teditor.remove(PREF_ACTIVE);\n\t\t\t\teditor.commit();\n\t\t\t\tif (activePodcastId == null || values.size() == 1)\n\t\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (activePodcastId == -1)\n\t\t\t\treturn 0;\n\t\t\tpodcastId = String.valueOf(activePodcastId);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new IllegalArgumentException(\"Unknown URI\");\n\t\t}\n\t\tString extraWhere = COLUMN_ID + \" = \" + podcastId;\n\t\tif (where != null)\n\t\t\twhere = extraWhere + \" AND \" + where;\n\t\telse\n\t\t\twhere = extraWhere;\n\t\tvalues.remove(COLUMN_SUBSCRIPTION_TITLE);\n\t\tif (values.containsKey(COLUMN_QUEUE_POSITION)) {\n\t\t\tInteger newPosition = values.getAsInteger(COLUMN_QUEUE_POSITION);\n\t\t\tvalues.remove(COLUMN_QUEUE_POSITION);\n\t\t\tupdateQueuePosition(podcastId, newPosition);\n\t\t}\n\t\tSQLiteDatabase db = _dbAdapter.getWritableDatabase();\n\t\tif (values.size() > 0)\n\t\t\tcount += db.update(\"podcasts\", values, where, whereArgs);\n\t\tgetContext().getContentResolver().notifyChange(Uri.withAppendedPath(URI, podcastId), null);\n\t\tif (values.containsKey(COLUMN_FILE_SIZE))\n\t\t\tgetContext().getContentResolver().notifyChange(\n\t\t\t\t\tUri.withAppendedPath(URI, \"to_download\"), null);\n\t\tif (podcastId.equals(activePodcastId))\n\t\t\tgetContext().getContentResolver().notifyChange(\n\t\t\t\t\tUri.withAppendedPath(URI, \"active\"), null);\n\t\treturn count;\n\t}\n", "output": "\tpublic int update(Uri uri, ContentValues values, String where,\n\t\t\tString[] whereArgs) {\n\t\tint count = 0;\n\t\tString podcastId;\n\t\tSharedPreferences prefs = getContext().getSharedPreferences(\"internals\", Context.MODE_WORLD_READABLE);\n\t\tLong activePodcastId = prefs.getLong(PREF_ACTIVE, -1);\n\t\tswitch (uriMatcher.match(uri)) {\n\t\tcase PODCAST_ID:\n\t\t\tpodcastId = uri.getLastPathSegment();\n\t\t\tbreak;\n\t\tcase PODCASTS_ACTIVE:\n\t\t\tif (values.containsKey(COLUMN_ID)) {\n\t\t\t\tactivePodcastId = values.getAsLong(COLUMN_ID);\n\t\t\t\tEditor editor = prefs.edit();\n\t\t\t\tif (activePodcastId != null)\n\t\t\t\t\teditor.putLong(PREF_ACTIVE, values.getAsLong(COLUMN_ID));\n\t\t\t\telse\n\t\t\t\t\teditor.remove(PREF_ACTIVE);\n\t\t\t\teditor.commit();\n\t\t\t\tif (activePodcastId == null || values.size() == 1)\n\t\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (activePodcastId == -1)\n\t\t\t\treturn 0;\n\t\t\tpodcastId = String.valueOf(activePodcastId);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new IllegalArgumentException(\"Unknown URI\");\n\t\t}\n\t\tString extraWhere = COLUMN_ID + \" = \" + podcastId;\n\t\tif (where != null)\n\t\t\twhere = extraWhere + \" AND \" + where;\n\t\telse\n\t\t\twhere = extraWhere;\n\t\tvalues.remove(COLUMN_SUBSCRIPTION_TITLE);\n\t\tif (values.containsKey(COLUMN_QUEUE_POSITION)) {\n\t\t\tInteger newPosition = values.getAsInteger(COLUMN_QUEUE_POSITION);\n\t\t\tvalues.remove(COLUMN_QUEUE_POSITION);\n\t\t\tupdateQueuePosition(podcastId, newPosition);\n\t\t}\n\t\tSQLiteDatabase db = _dbAdapter.getWritableDatabase();\n\t\tif (values.size() > 0)\n\t\t\tcount += db.update(\"podcasts\", values, where, whereArgs);\n\t\tgetContext().getContentResolver().notifyChange(Uri.withAppendedPath(URI, podcastId), null);\n\t\tif (values.containsKey(COLUMN_FILE_SIZE))\n\t\t\tgetContext().getContentResolver().notifyChange(Uri.withAppendedPath(URI, \"to_download\"), null);\n\t\tif (new Long(podcastId).equals(activePodcastId))\n\t\t\tgetContext().getContentResolver().notifyChange(Uri.withAppendedPath(URI, \"active\"), null);\n\t\treturn count;\n\t}\n"} {"input": " private void load(File file) throws IOException, BlockStoreException {\n LOG(\"Reading block store from \" + file.getAbsolutePath());\n FileInputStream input = new FileInputStream(file);\n int version = input.read();\n if (version == -1) {\n throw new FileNotFoundException(file.getName() + \" does not exist or is empty\");\n }\n if (version != 1) {\n throw new BlockStoreException(\"Bad version number: \" + version);\n }\n byte[] chainHeadHash = new byte[32];\n input.read(chainHeadHash);\n this.chainHead = new Sha256Hash(chainHeadHash);\n LOG(\"Read chain head from disk: \" + this.chainHead);\n long now = System.currentTimeMillis();\n byte[] headerBytes = new byte[Block.HEADER_SIZE];\n try {\n while (true) {\n if (input.read(headerBytes) < 80) {\n break;\n }\n Block b = new Block(params, headerBytes);\n StoredBlock prev = get(b.getPrevBlockHash());\n StoredBlock s;\n if (prev == null) {\n if (b.equals(params.genesisBlock)) {\n s = new StoredBlock(params.genesisBlock.cloneAsHeader(), params.genesisBlock.getWork(), 0);\n } else {\n throw new BlockStoreException(\"Could not connect \" + Utils.bytesToHexString(b.getHash()) + \" to \"\n + Utils.bytesToHexString(b.getPrevBlockHash()));\n }\n } else {\n b.verify();\n s = prev.build(b);\n }\n blockMap.put(new Sha256Hash(b.getHash()), s);\n }\n } catch (ProtocolException e) {\n throw new BlockStoreException(e);\n } catch (VerificationException e) {\n throw new BlockStoreException(e);\n }\n long elapsed = System.currentTimeMillis() - now;\n LOG(\"Block chain read complete in \" + elapsed + \"ms\");\n }\n", "output": " private void load(File file) throws IOException, BlockStoreException {\n LOG(\"Reading block store from \" + file.getAbsolutePath());\n InputStream input = new BufferedInputStream(new FileInputStream(file));\n int version = input.read();\n if (version == -1) {\n throw new FileNotFoundException(file.getName() + \" does not exist or is empty\");\n }\n if (version != 1) {\n throw new BlockStoreException(\"Bad version number: \" + version);\n }\n byte[] chainHeadHash = new byte[32];\n input.read(chainHeadHash);\n this.chainHead = new Sha256Hash(chainHeadHash);\n LOG(\"Read chain head from disk: \" + this.chainHead);\n long now = System.currentTimeMillis();\n byte[] headerBytes = new byte[Block.HEADER_SIZE];\n try {\n while (true) {\n if (input.read(headerBytes) < 80) {\n break;\n }\n Block b = new Block(params, headerBytes);\n StoredBlock prev = get(b.getPrevBlockHash());\n StoredBlock s;\n if (prev == null) {\n if (b.equals(params.genesisBlock)) {\n s = new StoredBlock(params.genesisBlock.cloneAsHeader(), params.genesisBlock.getWork(), 0);\n } else {\n throw new BlockStoreException(\"Could not connect \" + Utils.bytesToHexString(b.getHash()) + \" to \"\n + Utils.bytesToHexString(b.getPrevBlockHash()));\n }\n } else {\n b.verify();\n s = prev.build(b);\n }\n blockMap.put(new Sha256Hash(b.getHash()), s);\n }\n } catch (ProtocolException e) {\n throw new BlockStoreException(e);\n } catch (VerificationException e) {\n throw new BlockStoreException(e);\n }\n long elapsed = System.currentTimeMillis() - now;\n LOG(\"Block chain read complete in \" + elapsed + \"ms\");\n }\n"} {"input": " public void init() throws RowSpaceExceededException {\n current = null;\n this.tables = new HashMap();\n if (!(path.exists())) path.mkdirs();\n String[] tablefile = path.list();\n File f;\n Random r = new Random(System.currentTimeMillis());\n for (int i = 0; i < tablefile.length; i++) {\n if ((tablefile[i].startsWith(prefix)) &&\n (tablefile[i].charAt(prefix.length()) == '.') &&\n (tablefile[i].length() == prefix.length() + 7)) {\n f = new File(path, tablefile[i]);\n String newname = tablefile[i] + \"0100000\" + (Long.toString(r.nextLong())+\"00000\").substring(1,5) + \".table\";\n f.renameTo(new File(path, newname));\n }\n }\n tablefile = path.list();\n final HashMap t = new HashMap();\n long ram, time, maxtime = 0;\n Date d;\n for (int i = 0; i < tablefile.length; i++) {\n if ((tablefile[i].startsWith(prefix)) &&\n (tablefile[i].charAt(prefix.length()) == '.') &&\n (tablefile[i].length() == prefix.length() + 24)) {\n f = new File(path, tablefile[i]);\n try {\n d = DateFormatter.parseShortMilliSecond(tablefile[i].substring(prefix.length() + 1, prefix.length() + 18));\n } catch (ParseException e) {\n Log.logSevere(\"SplitTable\", \"\", e);\n continue;\n }\n time = d.getTime();\n if (time > maxtime) {\n current = tablefile[i];\n maxtime = time;\n }\n try {\n t.put(tablefile[i], Table.staticRAMIndexNeed(f, rowdef));\n } catch (IOException e) {\n Log.logWarning(\"SplitTable\", \"file \" + f.toString() + \" appears to be corrupted: \" + e.getMessage());\n }\n }\n }\n Iterator> i;\n Map.Entry entry;\n String maxf;\n long maxram;\n ObjectIndex table;\n while (!t.isEmpty()) {\n maxram = 0;\n maxf = null;\n i = t.entrySet().iterator();\n while (i.hasNext()) {\n entry = i.next();\n ram = entry.getValue().longValue();\n if (ram > maxram) {\n maxf = entry.getKey();\n maxram = ram;\n }\n }\n t.remove(maxf);\n if (maxf != null) {\n f = new File(path, maxf);\n Log.logInfo(\"kelondroSplitTable\", \"opening partial eco table \" + f);\n try {\n table = new Table(f, rowdef, EcoFSBufferSize, 0, this.useTailCache, this.exceed134217727);\n } catch (RowSpaceExceededException e) {\n table = new Table(f, rowdef, 0, 0, false, this.exceed134217727);\n }\n tables.put(maxf, table);\n }\n }\n this.executor = new ThreadPoolExecutor(\n Math.max(tables.size(), Runtime.getRuntime().availableProcessors()) + 1, \n Math.max(tables.size(), Runtime.getRuntime().availableProcessors()) + 1, 10, \n TimeUnit.SECONDS, \n new LinkedBlockingQueue(), \n new NamePrefixThreadFactory(prefix));\n }\n", "output": " public void init() throws RowSpaceExceededException {\n current = null;\n this.tables = new HashMap();\n if (!(path.exists())) path.mkdirs();\n String[] tablefile = path.list();\n File f;\n Random r = new Random(System.currentTimeMillis());\n for (int i = 0; i < tablefile.length; i++) {\n if ((tablefile[i].startsWith(prefix)) &&\n (tablefile[i].charAt(prefix.length()) == '.') &&\n (tablefile[i].length() == prefix.length() + 7)) {\n f = new File(path, tablefile[i]);\n String newname = tablefile[i] + \"0100000\" + (Long.toString(r.nextLong())+\"00000\").substring(1,5) + \".table\";\n f.renameTo(new File(path, newname));\n }\n }\n tablefile = path.list();\n final HashMap t = new HashMap();\n long ram, time, maxtime = 0;\n Date d;\n for (int i = 0; i < tablefile.length; i++) {\n if ((tablefile[i].startsWith(prefix)) &&\n (tablefile[i].charAt(prefix.length()) == '.') &&\n (tablefile[i].length() == prefix.length() + 24)) {\n f = new File(path, tablefile[i]);\n try {\n d = DateFormatter.parseShortMilliSecond(tablefile[i].substring(prefix.length() + 1, prefix.length() + 18));\n } catch (ParseException e) {\n Log.logSevere(\"SplitTable\", \"\", e);\n continue;\n }\n time = d.getTime();\n if (time > maxtime) {\n current = tablefile[i];\n maxtime = time;\n }\n try {\n t.put(tablefile[i], Table.staticRAMIndexNeed(f, rowdef));\n } catch (IOException e) {\n Log.logWarning(\"SplitTable\", \"file \" + f.toString() + \" appears to be corrupted: \" + e.getMessage());\n }\n }\n }\n Iterator> i;\n Map.Entry entry;\n String maxf;\n long maxram;\n ObjectIndex table;\n while (!t.isEmpty()) {\n maxram = 0;\n maxf = null;\n i = t.entrySet().iterator();\n while (i.hasNext()) {\n entry = i.next();\n ram = entry.getValue().longValue();\n if (maxf == null || ram > maxram) {\n maxf = entry.getKey();\n maxram = ram;\n }\n }\n t.remove(maxf);\n f = new File(path, maxf);\n Log.logInfo(\"kelondroSplitTable\", \"opening partial eco table \" + f);\n try {\n table = new Table(f, rowdef, EcoFSBufferSize, 0, this.useTailCache, this.exceed134217727);\n } catch (RowSpaceExceededException e) {\n table = new Table(f, rowdef, 0, 0, false, this.exceed134217727);\n }\n tables.put(maxf, table);\n }\n this.executor = new ThreadPoolExecutor(\n Math.max(tables.size(), Runtime.getRuntime().availableProcessors()) + 1, \n Math.max(tables.size(), Runtime.getRuntime().availableProcessors()) + 1, 10, \n TimeUnit.SECONDS, \n new LinkedBlockingQueue(), \n new NamePrefixThreadFactory(prefix));\n }\n"}