method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
1986d3b5-f294-4412-bdba-dedebbf00a8a | 5 | public void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
PrintStream out = new PrintStream(response.getOutputStream());
out.println("<capabilities>");
out.println("<peers path=\"community/\"/>");
// always give publish -- if clients don't have perms, they will see an error (and can fix) vs. the pain
// of not having publish
// if( request.getUserPrincipal() != null ) {
out.println("<publish path=\"publish/\"/>");
// }
out.println("<splash path=\"files.jsp\"/>");
out.println("<id name=\"" + System.getProperty(EmbeddedServer.Setting.SERVER_NAME.getKey()) + "\"/>");
if( System.getProperty(EmbeddedServer.Setting.RSS_BASE_URL.getKey()) != null ) {
out.println("<rss path=\"/rss\"/>");
}
if( System.getProperty(EmbeddedServer.StartupSetting.UNENCRYPTED_PORT.getKey()) != null ) {
int alt_port = Integer.parseInt(System.getProperty(StartupSetting.UNENCRYPTED_PORT.getKey()));
out.println("<nossl port=\"" + alt_port + "\"/>");
}
if( filterKeywords != null ) {
out.println("<searchfilter>");
for( String keyword : filterKeywords ) {
out.println("<keyword>" + keyword + "</keyword>");
}
out.println("</searchfilter>");
}
out.println("</capabilities>");
out.flush();
out.close();
} catch( IOException e ) {
logger.warning(e.toString());
e.printStackTrace();
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} |
39f16230-e3ac-42fa-b21d-6c3712b58f0d | 4 | @SuppressWarnings("unchecked")
@Override
public <Native, Hosted extends JOSObject<Native, Hosted>> JOSObject<Native, Hosted> _get(String name, Class<Native> NativeType, Class<Hosted> ReturnType) {
JOSObject<? , ?> raw = this.get(name, JOSObject.class);
if(raw == null) return null;
try{
return (JOSObject<Native , Hosted>) raw;
}catch(ClassCastException e){
return null;
}
} |
efb073f1-fa8e-4da3-b7e0-34763d984817 | 7 | public LinkedHashMap<String, Object> getData() {
LinkedHashMap<String, Object> data = Maps.newLinkedHashMap();
if (type == Type.BOOLEAN) {
enumeration.clear();
enumeration.add("true");
enumeration.add("false");
enumDescriptions.clear();
enumDescriptions.add("True");
enumDescriptions.add("False");
}
if (location == Location.body) {
data.put("type", "textarea");
} else {
data.put("type", type.name);
}
data.put("location", location + "");
data.put("description", description);
data.put("default", defaultValue);
if (required) data.put("required", true);
if (!enumDescriptions.isEmpty() && enumeration.size() != enumDescriptions.size()) {
data.put("warning", "Enumeration size ("
+ enumeration.size()
+ ") is not equal to enumeration description size ("
+ enumDescriptions.size() + ")");
}
if (!enumeration.isEmpty()) {
data.put("enum", enumeration);
if (!enumDescriptions.isEmpty()) {
data.put("enumDescriptions", enumDescriptions);
}
}
return data;
} |
4f67c361-674d-4de5-883f-2664fc2d94b7 | 9 | private Boolean uploadFileIntern(File file, String graphURI){
if(!file.exists()){
try{
throw new FileNotFoundException();
}
catch(FileNotFoundException e){
LogHandler.writeStackTrace(log, e, Level.SEVERE);
return false;
}
}
String absFile = file.getAbsolutePath();
String contentType = RDFLanguages.guessContentType(absFile).getContentType();
if(!this.autoCommit){
Model input = ModelFactory.createModelForGraph(transactionInput);
Model add = ModelFactory.createDefaultModel();
try {
add.read(new FileInputStream(file), null, FileExtensionToRDFContentTypeMapper.guessFileFormat(contentType));
switch(this.mut){
case add:
input.add(add);
break;
case union:
input.union(add);
break;
default:
input.add(add);
}
this.transactionInput = input.getGraph();
} catch (FileNotFoundException e) {
LogHandler.writeStackTrace(log, e, Level.SEVERE);
return false;
}
return null;
}
//Is there a difference??
String mimeType = contentType;
String urlEncoded;
try {
urlEncoded = URLEncoder.encode(graphURI, "UTF-8");
} catch (UnsupportedEncodingException e) {
urlEncoded=graphURI;
}
String command=this.curlCommand.replace("$GRAPH-URI", urlEncoded)
.replace("$FILE", absFile)
.replace("$CONTENT-TYPE", contentType)
.replace("$MIME-TYPE", mimeType)
.replace("$CURL-URL", this.curlURL);
if(this.type.equals(UploadType.POST)){
command = command.replace("$UPLOAD-TYPE", "-X POST");
}
else if(this.type.equals(UploadType.PUT)){
command = command.replace("$UPLOAD-TYPE", " ");
}
return this.process(command);
} |
a8db832a-4e48-4fe4-a2da-ce55df1244c4 | 3 | @Override
public void deleteIllness(IllnessDTO illness) throws SQLException {
Session session = null;
try {
session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.delete(illness);
session.getTransaction().commit();
} catch (Exception e) {
System.err.println("Error while deleting medType!");
} finally {
if (session != null && session.isOpen()) {
session.close();
}
}
} |
c1b111c0-5b98-4868-a279-ee11de0789fc | 7 | public boolean interact(Widget w, Coord c) {
for (Widget wdg = w.lchild; wdg != null; wdg = wdg.prev) {
if (wdg == this)
continue;
Coord cc = w.xlate(wdg.c, true);
if (c.isect(cc, (wdg.hsz == null) ? wdg.sz : wdg.hsz)) {
if (interact(wdg, c.add(cc.inv())))
return (true);
}
}
if (w instanceof DTarget) {
if (((DTarget) w).iteminteract(c, c.add(doff.inv())))
return (true);
}
return (false);
} |
ca316c81-0b94-468a-ab07-416aa68a3ee6 | 9 | public void run() {
// XXX: Is this not the same as screen?
while (true) {
try {
while (! request_queue.isEmpty()) {
// XXX: request_queue is a queue of HTTPMessages, not
// HttpRequests.
HttpRequest next = (HttpRequest) request_queue.take();
if (next == null) {
continue;
}
if (GizmoView.getView().intercepting() && GizmoView.getView().matchRequest(next.contents())) {
screen.addIntercept(next, next.getURL() + "\n");
} else {
if (! next.isSent()) {
synchronized (next) {
next.notifyAll();
}
next.fetchResponse(true);
} else {
screen.append(next, "\n", next.getURL() + "\n");
screen.append(next.getResponse(), "\n\n");
}
}
}
} catch (Exception e) {
System.out.println(e);
}
while (request_queue.isEmpty()) {
synchronized (lock) {
try {
lock.wait();
} catch (Exception e) {
System.out.println(e);
}
}
}
}
} |
4a65f785-1c1d-4c8a-91b5-b0174971b17c | 3 | private boolean readTrue( StringBuffer b )
throws IOException,
JSONSyntaxException {
if( !readExpected('r',b) || !readExpected('u',b) || !readExpected('e',b) )
throwJSONException( "Unexpected token: " + this.describeCurrentToken() + "; expected true." );
this.fireTrueRead( b.toString() );
return true;
} |
9d7644fd-05ef-456b-993f-42bd9adfe0d6 | 3 | private void clean_pipes()
{
if (pipe != null) {
// Get rid of half-processed messages in the out pipe. Flush any
// unflushed messages upstream.
pipe.rollback ();
pipe.flush ();
// Remove any half-read message from the in pipe.
while (incomplete_in) {
Msg msg = pull_msg ();
if (msg == null) {
assert (!incomplete_in);
break;
}
msg.close ();
}
}
} |
08a7214f-3799-47d8-a335-17eafd680051 | 4 | private void createPageRangeFields(PrintRequestAttributeSet set) {
PrintService service = getService();
if (service.isAttributeCategorySupported(PageRanges.class)) {
ButtonGroup group = new ButtonGroup();
int start = 1;
int end = 9999;
PageRanges pageRanges = (PageRanges) set.get(PageRanges.class);
if (pageRanges != null) {
int[][] ranges = pageRanges.getMembers();
if (ranges.length > 0 && ranges[0].length > 1) {
start = ranges[0][0];
end = ranges[0][1];
} else {
pageRanges = null;
}
}
JLabel label = new JLabel(PAGE_RANGE, SwingConstants.CENTER);
add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
JPanel wrapper = new JPanel(new PrecisionLayout().setMargins(0).setColumns(5));
mPageRangeAll = new JRadioButton(ALL, pageRanges == null);
wrapper.add(mPageRangeAll);
mPageRangeSome = new JRadioButton(PAGES, pageRanges != null);
wrapper.add(mPageRangeSome);
mPageRangeStart = createPageRangeField(start, wrapper);
wrapper.add(new JLabel(TO, SwingConstants.CENTER));
mPageRangeEnd = createPageRangeField(end, wrapper);
add(wrapper);
group.add(mPageRangeAll);
group.add(mPageRangeSome);
adjustPageRanges();
mPageRangeAll.addActionListener(this);
mPageRangeSome.addActionListener(this);
} else {
mPageRangeAll = null;
mPageRangeSome = null;
mPageRangeStart = null;
mPageRangeEnd = null;
}
} |
a25abf1f-c274-49a4-a06b-9405c22674b9 | 3 | private ResGridlet cancel(int gridletId, int userId)
{
ResGridlet rgl = null;
// Check whether the Gridlet is in execution list or not
int found = gridletInExecList_.indexOf(gridletId, userId);
// if a Gridlet is in execution list
if (found >= 0)
{
// update the gridlets in execution list up to this point in time
updateGridletProcessing();
// Get the Gridlet from the execution list
rgl = (ResGridlet) gridletInExecList_.remove(found);
// if a Gridlet is finished upon cancelling, then set it to success
if (rgl.getRemainingGridletLength() == 0.0) {
rgl.setGridletStatus(Gridlet.SUCCESS);
}
else {
rgl.setGridletStatus(Gridlet.CANCELED);
}
// then forecast the next Gridlet to complete
forecastGridlet();
}
// if a Gridlet is not in exec list, then find it in the paused list
else
{
found = gridletPausedList_.indexOf(gridletId, userId);
// if a Gridlet is found in the paused list then remove it
if (found >= 0)
{
rgl = (ResGridlet) gridletPausedList_.remove(found);
rgl.setGridletStatus(Gridlet.CANCELED);
}
}
return rgl;
} |
dcb5414a-3b72-4187-bfff-f257db6ace92 | 7 | public double classify(svm_problem _prob){
int[] countClass = new int[_prob.l];
double[] result = null;
for (SVMHelper aSVM : ensembler){
result = aSVM.predict(_prob);
for (int i = 0; i < result.length; i++){
if (result[i] == 1){
countClass[i] += 1;
}
}
}
// return the majority vote for each item in _prob
double decision = 1;
double acc = 0.0;
int decisionPlane = ensembler.size()/2;
if (decisionPlane*2 < ensembler.size()){
decisionPlane += 1;
}
for (int i = 0; i < _prob.l; i++){
decision = countClass[i] >= decisionPlane ? 1:-1;
if (decision == _prob.y[i]){
acc += 1;
}
}
return acc/_prob.l;
} |
c20b2ca5-12d4-453b-b069-02f373171ed3 | 2 | public void end() {
if(z==null)
return;
if(compress){ z.deflateEnd(); }
else{ z.inflateEnd(); }
z.free();
z=null;
} |
7d934204-9b2b-487d-932f-bd73c2d2d7a3 | 9 | public void tick()
{
if (this.getWorldInfo().isHardcoreModeEnabled() && this.difficultySetting < 3)
{
this.difficultySetting = 3;
}
this.worldProvider.worldChunkMgr.cleanupCache();
this.updateWeather();
long var2;
if (this.isAllPlayersFullyAsleep())
{
boolean var1 = false;
if (this.spawnHostileMobs && this.difficultySetting >= 1)
{
;
}
if (!var1)
{
var2 = this.worldInfo.getWorldTime() + 24000L;
this.worldInfo.setWorldTime(var2 - var2 % 24000L);
this.wakeUpAllPlayers();
}
}
Profiler.startSection("mobSpawner");
SpawnerAnimals.performSpawning(this, this.spawnHostileMobs, this.spawnPeacefulMobs && this.worldInfo.getWorldTime() % 400L == 0L);
Profiler.endStartSection("chunkSource");
this.chunkProvider.unload100OldestChunks();
int var4 = this.calculateSkylightSubtracted(1.0F);
if (var4 != this.skylightSubtracted)
{
this.skylightSubtracted = var4;
}
var2 = this.worldInfo.getWorldTime() + 1L;
if (var2 % (long)this.autosavePeriod == 0L)
{
Profiler.endStartSection("save");
this.saveWorld(false, (IProgressUpdate)null);
}
this.worldInfo.setWorldTime(var2);
Profiler.endStartSection("tickPending");
this.tickUpdates(false);
Profiler.endStartSection("tickTiles");
this.tickBlocksAndAmbiance();
Profiler.endStartSection("village");
this.villageCollectionObj.tick();
this.villageSiegeObj.tick();
Profiler.endSection();
} |
132839e7-4d22-464e-a020-cdd92681de57 | 4 | public static boolean forwardToPrevious(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException
{
final String referrer = request.getHeader(REFERRER);
if (null == referrer)
{
return false;
}
final String contextPath = request.getContextPath();
if (referrer.contains(contextPath))
{
/* @formatter:off */
final String previousPage = referrer.substring(referrer
.indexOf(contextPath) +
contextPath.length());
final String requestUri = request.getRequestURI();
final String requestUriWithoutContextPath =
requestUri.contains(contextPath) ?
requestUri.substring(requestUri
.indexOf(contextPath) +
contextPath.length()) :
requestUri;
/* @formatter:on */
if (requestUriWithoutContextPath.equals(previousPage))
{
return false;
}
request.getRequestDispatcher(previousPage)
.forward(request, response);
return true;
}
return false;
} |
4044aee1-b0db-44ee-b00f-cf6990520a28 | 5 | public static void main(String[] args) {
ApplicationContext applicationContext = new FileSystemXmlApplicationContext("classpath:client.xml");
WebCrafterService service = (WebCrafterService) applicationContext.getBean("rmiProxy");
try {
ItemTemplate wood = service.getItemTemplate("Wood");
if (wood == null) {
wood = new ItemTemplate("Wood");
service.addItemTemplate(wood);
}
ItemTemplate fire = service.getItemTemplate("Fire");
if (fire == null) {
fire = new ItemTemplate("Fire");
service.addItemTemplate(fire);
}
ItemTemplate coal = service.getItemTemplate("Coal");
if (coal == null) {
coal = new ItemTemplate("Coal");
service.addItemTemplate(coal);
}
Recipe makeWoodCoal = service.getRecipe("Coal");
if (makeWoodCoal == null) {
List<ItemTemplate> ingredients = new ArrayList<ItemTemplate>();
ingredients.add(wood);
ingredients.add(fire);
makeWoodCoal = new Recipe("Coal", ingredients, coal);
service.addRecipe(makeWoodCoal);
}
System.out.println(makeWoodCoal.getId());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
} |
349d1a51-dbf1-4ea2-bf02-b7984eb6a64b | 3 | void search() {
Logger.getLogger(Search.class.getName()).entering(Search.class.getName(), "search");
String text = searchField.getText();
tableRowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
Pattern pattern = Pattern.compile("(?i)" + text);
for (int row = 0; row < table.getRowCount(); row++) {
String value = table.getValueAt(row, 0).toString().toLowerCase();
Matcher matcher = pattern.matcher(value.toLowerCase());
if (matcher.find()) {
searchField.setForeground(Color.BLACK);
table.changeSelection(row, 0, false, false);
Logger.getLogger(Search.class.getName()).exiting(Search.class.getName(), "search");
return;
}
}
if (table.getRowCount() == 0) {
searchField.setForeground(Color.RED);
}
Logger.getLogger(Search.class.getName()).exiting(Search.class.getName(), "search");
} |
0526d85d-9c9d-4d62-8162-83d789ffaf61 | 7 | public static void initializeStreets(Gameboard board)
{
try
{
for (final StreetColor color : StreetColor.values())
{
final List<PlaceProperty> places = new ArrayList<PlaceProperty>();
for (final Place place : board.places)
{
if (place instanceof PlaceProperty && ((PlaceProperty) place).getColor().equals(color))
{
places.add((PlaceProperty) place);
}
}
if (!places.isEmpty())
{
final PlaceProperty[] pps = new PlaceProperty[places.size()];
for (int i = 0; i < places.size(); i++)
{
pps[i] = places.get(i);
}
final Field street = Street.class.getField(color.toString().toUpperCase());
street.set(null, new Street(pps, color));
}
}
}
catch (final Exception e)
{
throw new RuntimeException(e);
}
} |
49a64c73-3c4f-4478-a955-3587b0b33ea2 | 2 | private static boolean isServerChannel( Channel c ) {
if ( c.isDefault() && BungeeSuite.proxy.getServers().containsKey( c.getName() ) ) {
return true;
}
return false;
} |
ef816059-6512-4a23-b680-0eb06dd1f680 | 6 | protected boolean extractNatives() {
setStatus("Extracting natives...");
File nativesJar = new File(binDir, getFilename(jarURLs[jarURLs.length - 1]));
File nativesDir = new File(binDir, "natives");
if(!nativesDir.isDirectory()) {
nativesDir.mkdirs();
}
FileInputStream input = null;
ZipInputStream zipIn = null;
try {
input = new FileInputStream(nativesJar);
zipIn = new ZipInputStream(input);
ZipEntry currentEntry = zipIn.getNextEntry();
while(currentEntry != null) {
if(currentEntry.getName().contains("META-INF")) {
currentEntry = zipIn.getNextEntry();
continue;
}
setStatus("Extracting " + currentEntry + "...");
FileOutputStream outStream = new FileOutputStream(new File(nativesDir, currentEntry.getName()));
int readLen;
byte[] buffer = new byte[1024];
while((readLen = zipIn.read(buffer, 0, buffer.length)) > 0) {
outStream.write(buffer, 0, readLen);
}
outStream.close();
currentEntry = zipIn.getNextEntry();
}
} catch (IOException e) {
Logger.logError(e.getMessage(), e);
return false;
} finally {
try {
zipIn.close();
input.close();
} catch (IOException e) {
Logger.logError(e.getMessage(), e);
}
}
nativesJar.delete();
return true;
} |
4a107d31-d93c-4691-85f0-d762101d9533 | 6 | public static Double nernst(Double freeEnergy, Double moles, Double cellPotential)
{
//G = -nFE
boolean[] nulls = new boolean[4];
nulls[0] = (freeEnergy == null);
nulls[1] = (moles == null);
nulls[2] = (cellPotential == null);
int nullCount = 0;
for(int k = 0; k < nulls.length; k++)
{
if(nulls[k])
nullCount++;
}
if(nullCount != 1)
return null;
double result = 0;
if(nulls[0])
{
// freeEnergy is unknown
result = -moles*F*cellPotential;
}
else if(nulls[1])
{
// moles is unknown
result = -freeEnergy/(F*cellPotential);
}
else if(nulls[2])
{
// cellPotential is unknown
result = -freeEnergy/(F*moles);
}
return result;
} |
9727f47b-ab0b-49cf-b121-0027db839897 | 5 | @Override
public ParserResult specialCheckAndGetParserResult(ParserResult result,
SyntaxAnalyser analyser) throws GrammarCheckException {
boolean theOtherInfoIsEmpty = result.getAggregateFunctionName() == null
&& result.getConditions().size() == 0
&& result.getDimensionLevelInfo().size() == 0
&& result.getDimensionNicknames().size() == 0
&& result.getResultCube() == null;
if (!theOtherInfoIsEmpty) {
this.throwException(result.getOperationName(), null, analyser);
}
return result;
} |
afa697f6-a779-4e21-b9e3-777abe9a103e | 6 | private static int rankHands(Cards[] hands, Cards board, int numhands, int[] wins, int[] ties, int total) {
List<HandRank> ranks = new ArrayList<HandRank>(numhands);
HandRank highest = null;
for (Cards hand : hands) {
HandRank rank = holdem(hand, board);
if (highest == null) {
highest = rank;
} else {
if (rank.compareTo(highest) > 0) {
highest = rank;
}
}
ranks.add(rank);
}
int handnum = 0;
int tied = 0;
for (HandRank rank : ranks) {
if (rank.equals(highest)) {
if (tied > 0) {
ties[handnum]++;
} else {
wins[handnum]++;
}
tied++;
}
handnum++;
}
total++;
return total;
} |
7ba0174a-9bb0-4993-9551-93a73a21b3cf | 1 | public void skipCurrentTurn() {
remainingActions = (remainingActions > 0) ? 0 : remainingActions;
} |
e6428999-8647-4505-a090-1ee46a4f55a5 | 4 | public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case ID:
return isSetId();
case NAME:
return isSetName();
case PRICE:
return isSetPrice();
}
throw new IllegalStateException();
} |
539c6138-5954-4e16-983c-b48576006d41 | 0 | public TwitterModel getTwitterModel() {
return twitterModel;
} |
3f27bb0e-39f0-4c3f-b65b-15930b5210e1 | 8 | public void buttonClick(ActionEvent e) {
String bv = e.getActionCommand().toString();
switch (bv) {
case "New":
NewMapDialog mapDialog = new NewMapDialog();
int mapDialogResult = JOptionPane.showConfirmDialog(null, mapDialog, "Select", JOptionPane.OK_CANCEL_OPTION);
if (mapDialogResult == JOptionPane.OK_OPTION) {
mapScrollPane.createMap(mapDialog.getWSelectorValue(),mapDialog.getHSelectorValue());
}
break;
case "Remove":
mapScrollPane.removeMap();
break;
case "Show Grid":
mapScrollPane.showGrid();
break;
case "Zoom In":
mapScrollPane.zoomIn();
break;
case "Zoom Out":
mapScrollPane.zoomOut();
break;
case "Optimise":
actionOptimise();
break;
case "help":
mapScrollPane.printGrid();
break;
default:
break;
}
} |
cba4238d-4a65-4f81-b73a-a1b396205762 | 5 | public static void main(String[] _args) {
Random rand = new Random(0);
final int HOLDERSIZE = 1000;
TestObj[] holder = new TestObj[HOLDERSIZE];
TestObj testobj = new TestObj(0x12345678);
if (!OkraUtil.okraLibExists()) {
System.out.println("...unable to create context, using fake references");
for (int i=0; i<4; i++) {
System.out.println("Fake Reference " + OkraUtil.getRefHandle(testobj));
}
System.exit(0);
}
context = new OkraContext();
context.setVerbose(true);
for (int i=0; i<3; i++) {
refHandles[i] = OkraUtil.getRefHandle(new TestObj(0x12345678+i));
}
testRefHandles();
for (int i=0; i<3; i++) {
for (int j=0; j<100000; j++) {
holder[rand.nextInt(HOLDERSIZE)] = new TestObj(j);
}
System.gc();
testRefHandles();
}
} |
2577e07f-e57e-4c03-9e36-1598ac7fc7bb | 4 | public void keyReleased(KeyEvent e) {
int key = e.getKeyCode();
switch(key) {
case KeyEvent.VK_W:
p.setMoveUp(false);
break;
case KeyEvent.VK_S:
p.setMoveDown(false);
break;
case KeyEvent.VK_A:
p.setMoveLeft(false);
break;
case KeyEvent.VK_D:
p.setMoveRight(false);
break;
}
} |
93ba664a-f5ab-4e2b-96e1-147206bd3432 | 0 | @Override
public boolean isDefault() {
return defaultGroup;
} |
0825782a-011a-477b-9fe3-1753a3b95b94 | 5 | @Override
public void onDisable() {
FileOutputStream fos = null;
ObjectOutputStream oos = null;
try {
File data = new File(this.getDataFolder(), "arenadata.bin");
data.mkdirs();
data.createNewFile();
fos = new FileOutputStream(data);
oos = new ObjectOutputStream(fos);
oos.writeObject(mm);
} catch(FileNotFoundException ex) {
this.getLogger().log(Level.SEVERE, "Impossible exception!", ex);
} catch(IOException ex) {
this.getLogger().log(Level.SEVERE, "Couldn't write arena data!", ex);
} finally {
try {
if(fos != null) {
fos.close();
}
if(oos != null) {
oos.close();
}
} catch(IOException ex) {
}
}
} |
8ea5af3e-96ca-4517-8930-dbe5971c5c9d | 2 | public Fornecedor getFornecedor(String razao) throws ExceptionGerentePessoa{
for (Fornecedor f : fornecedores) {
if (f.getNome().equalsIgnoreCase(razao)) {
return f;
}
}
throw new ExceptionGerentePessoa ("Fornecedor n��o cadastrado");
} |
58058cbf-499f-472c-a655-3447d9b17a90 | 3 | @Override
public void drawUp(Point p, Node node) {
this.node = node;
// Adjust color when we are selected
updateColors();
// Update the button
updateButton();
// Update font
updateFont();
// Draw the TextArea
setText(node.getValue());
int indent = node.getDepth() * pIndent;
int width = textAreaWidth - indent;
// Size needs to be set twice. The first time forces the lines to flow. The second then sets the correct height.
setSize(width,32);
height = getBestHeight();
p.y -= (height + pVerticalSpacing);
setBounds(p.x + indent + OutlineButton.BUTTON_WIDTH, p.y, width, height);
// Draw the Button
button.setBounds(p.x + indent, p.y, OutlineButton.BUTTON_WIDTH, height);
// Draw the LineNumber
if (pShowLineNumbers) {
if (node.getTree().getDocument().hoistStack.isHoisted()) {
// TODO: This value should be pre-calculated.
int offset = node.getTree().getDocument().hoistStack.getLineCountOffset() + node.getLineNumber(node.getTree().getLineCountKey());
lineNumber.setText("" + offset);
} else {
lineNumber.setText("" + node.getLineNumber(node.getTree().getLineCountKey()));
}
}
lineNumber.setBounds(
lineNumberOffset,
p.y,
OutlineLineNumber.LINE_NUMBER_WIDTH + indent,
height
);
// Draw Indicators
if (pShowIndicators) {
// Update the Indicators
updateCommentIndicator();
updateEditableIndicator();
updateMoveableIndicator();
iComment.setBounds(
commentOffset,
p.y,
OutlineCommentIndicator.BUTTON_WIDTH,
height
);
iEditable.setBounds(
editableOffset,
p.y,
OutlineEditableIndicator.BUTTON_WIDTH,
height
);
iMoveable.setBounds(
moveableOffset,
p.y,
OutlineMoveableIndicator.BUTTON_WIDTH,
height
);
}
} |
485bd074-fac5-4419-b4ee-21393e9cea37 | 4 | public ListNode deleteDuplicates(ListNode head) {
ArrayList<Integer> visited = new ArrayList<Integer>();
if(head == null) return null;
ListNode p = head;
visited.add(new Integer(head.val));
while(p != null && p.next != null) {
if(visited.contains(new Integer(p.next.val))){
//remove p.next
p.next = p.next.next;
}else {
visited.add(new Integer(p.next.val));
p = p.next;
}
}
return head;
} |
00910232-257e-4eb3-9f2a-abcf864fe2bd | 7 | public void addNewPastMeeting(Set<Contact> contacts, Calendar date, String text)
{
try
{
if(contacts.equals(null) || date.equals(null) || text.equals(null))
{
throw new NullPointerException();
}
if(contacts.isEmpty() || !contactList.containsAll(contacts))
{
throw new IllegalArgumentException();
}
Meeting newMeeting = this.addNewMeeting(date, contacts, text);
this.meetingList.add
(newMeeting);
}catch(NullPointerException ex){
System.out.println("One of the arguments is null");
}catch(IllegalArgumentException ex){
System.out.println("Invalid set of contacts");
}
} |
04e7e5ca-f497-422a-8f69-759212d1bac4 | 9 | public static void main(String[] args) {
t = new TreeMap<Integer, Integer>();
int n = 201;
sol = new ArrayList[n];
for (int i = 0; i < n; i++) {
t.put( (i*i*i) , i );
}
for (int i = 2; i < n; i++) {
for (int j = i+1; j < n; j++) {
for (int k = j+1; k < n; k++) {
int m = i*i*i + j*j*j + k*k*k;
if( t.containsKey(m) ){
ArrayList<String> num;
if(sol[t.get(m)]!=null){
num = sol[t.get(m)] ;
}else num = new ArrayList<String>();
num.add("("+i+","+j+","+k+")");
sol[t.get(m)] = num;
}
}
}
}
for (int i = 6; i < n; i++) {
if(sol[i]!=null){
for (int j = 0; j < sol[i].size(); j++) {
System.out.println("Cube = "+i+", Triple = "+sol[i].get(j));
}
}
}
} |
9d247d6f-ff55-4275-a64d-1a4d8920bf3a | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Swear))
return false;
Swear other = (Swear) obj;
if (swearword == null) {
if (other.swearword != null)
return false;
} else if (!swearword.equals(other.swearword))
return false;
return true;
} |
5f2ccf6e-aaed-4c90-8b49-c5751f913de2 | 0 | @Transient
public String getFunUnidad() {
return funUnidad;
} |
dadfa0b5-7af0-46ef-a7ff-dd4fb2374258 | 6 | @Override
public void showGiveOptions(ResourceType[] enabledResources) {
giveAvailables = enabledResources;
givereload.setVisible(false);
giveAmount.setVisible(false);
//Show them all
givewood.setVisible(true);
givebrick.setVisible(true);
givesheep.setVisible(true);
givewheat.setVisible(true);
giveore.setVisible(true);
//Disable all
givewood.setEnabled(false);
givebrick.setEnabled(false);
givesheep.setEnabled(false);
givewheat.setEnabled(false);
giveore.setEnabled(false);
//Re-enable the available ones
for (ResourceType res : enabledResources) {
if (res == ResourceType.WOOD) { givewood.setEnabled(true);}
else if (res == ResourceType.BRICK) {givebrick.setEnabled(true);}
else if (res == ResourceType.SHEEP) {givesheep.setEnabled(true);}
else if (res == ResourceType.WHEAT) {givewheat.setEnabled(true);}
else if (res == ResourceType.ORE) { giveore.setEnabled(true);}
}
} |
470d3db3-92db-43b5-b567-b5dafe7be8d1 | 6 | public static void generateDataSet(String path, Connection connection) {
try {
IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
IDataSet dataSet = dbUnitConnection.createDataSet();
File file = new File(path);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
FlatXmlDataSet.write(dataSet, new FileOutputStream(file));
} catch (SQLException e) {
throw new JStrykerException(e.getMessage(), e);
} catch (DataSetException e) {
throw new JStrykerException(e.getMessage(), e);
} catch (FileNotFoundException e) {
throw new JStrykerException(e.getMessage(), e);
} catch (IOException e) {
throw new JStrykerException(e.getMessage(), e);
} catch (DatabaseUnitException e) {
throw new JStrykerException(e.getMessage(), e);
}
} |
6ddfc602-16f5-4cd2-91b2-9cb41b8ecc45 | 9 | public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PersonInfo other = (PersonInfo) obj;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
return true;
} |
59dfa576-e8c3-4c64-8afa-55393999daa0 | 8 | private CommandExecutionResult executeInternal(Map<String, RegexPartialMatch> line0, AbstractEntityDiagram system,
Url url, List<? extends CharSequence> s) {
final String pos = line0.get("POSITION").get(0);
final String code = line0.get("ENTITY").get(0);
final IEntity cl1;
if (code == null) {
cl1 = system.getLastEntity();
if (cl1 == null) {
return CommandExecutionResult.error("Nothing to note to");
}
} else {
cl1 = system.getOrCreateClass(code);
}
final IEntity note = system.createLeaf("GMN" + UniqueSequence.getValue(), s, LeafType.NOTE);
note.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get("COLOR").get(0)));
if (url != null) {
note.addUrl(url);
}
final Position position = Position.valueOf(pos.toUpperCase()).withRankdir(system.getRankdir());
final Link link;
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();
if (position == Position.RIGHT) {
link = new Link(cl1, note, type, null, 1);
link.setHorizontalSolitary(true);
} else if (position == Position.LEFT) {
link = new Link(note, cl1, type, null, 1);
link.setHorizontalSolitary(true);
} else if (position == Position.BOTTOM) {
link = new Link(cl1, note, type, null, 2);
} else if (position == Position.TOP) {
link = new Link(note, cl1, type, null, 2);
} else {
throw new IllegalArgumentException();
}
system.addLink(link);
return CommandExecutionResult.ok();
} |
1c0f2421-e776-4e6e-9f06-d8636e5b98b6 | 0 | public MandelbrotPanelDouble()
{
setLayout(new BorderLayout());
setUpFractalPanel();
setUpInfoPanel();
} |
528e6f3f-c753-4732-90cb-300dccfe58ac | 2 | public String loadExame() {
Map parametros = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String idExa = parametros.get("idExame").toString();
Integer id = Integer.parseInt(idExa);
int i;
for (i = 0; i < examesBean.size(); i++) {
if (examesBean.get(i).getIdExame().equals(id)) {
break;
}
}
this.idExame = id;
this.nome = examesBean.get(i).getNome();
this.valor = examesBean.get(i).getValor();
return "carrega";
} |
efdaa28a-19de-49bd-9550-4758c163f5a3 | 1 | private void endArguments() {
if (argumentStack % 2 != 0) {
buf.append('>');
}
argumentStack /= 2;
} |
439b13ab-f717-46c1-91a9-1f38340add78 | 1 | @Override
public void drawImage(Function f, MyPanel image, double x, double y) {
Graphics g = image.getGraphics();
Graphics2D g2 = (Graphics2D) g;
g2.translate(150, 150);
g2.scale(x, y);
Complex tmp1 = f.evaluate(this.c1);
int p = 10;
for (int t = 0; t <= p; t++) {
double re = ((p - t) * this.c1.getRe() / p + t * this.c2.getRe() / p);
double im = ((p - t) * this.c1.getIm() / p + t * this.c2.getIm() / p);
Complex tmp2 = f.evaluate(new Complex(re, im));
Line tmpLine = new Line(tmp1, tmp2);
tmpLine.paint(g2);
tmp1 = tmp2;
}
} |
e98552ac-73e0-40d6-a3ec-f06b6bed57a8 | 0 | private Set<Card> twoKingsTwoQueensTwoJacksSix() {
return convertToCardSet("KS,6S,KD,JS,QD,QC,JH");
} |
0b89ac2f-e936-4b21-a671-19dc4338e0fb | 4 | @Override
public Icon getIcon() {
Icon retVal = null;
if (fRating == null || fRating == Rating.NO_RATING) {
retVal = null;
} else if (fPosition < fRating.ordinal()) {
retVal = getStarIcon();
} else if (fSelected) {
retVal = getDotIcon();
}
return retVal;
} |
703fd522-4e15-4906-995b-9fb140bc3317 | 0 | public Person5(String pname) {
name = pname;
} |
9340fe9a-2e5e-47e7-9006-4199b6dae580 | 5 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(args.length != 3) {
printArgsError(args);
printHelp(sender, label);
return true;
}
String target = findTarget(args[1]);
int chargeId = -1;
try {
chargeId = Integer.valueOf(args[2]);
} catch (NumberFormatException ex) {
printHelp(sender, label);
return true;
}
Record found = Rapsheet.getManager().getCharge(target, chargeId);
if(found == null) {
sender.sendMessage(COULD_NOT_FIND_CHARGE.replace("<PLAYER>", target));
return true;
}
if(!found.isSealed()) {
sender.sendMessage(ChatColor.RED + "You cannot unseal a charge that isn't sealed!");
return true;
}
boolean success = Rapsheet.getManager().unsealPlayerCharge(target, sender.getName(), chargeId, NotifyChanges.BOTH);
if(!success) {
plugin.getLogger().severe("Error trying to unseal player " + target + "'s chargeId: " + chargeId);
}
return true;
} |
4db7fc20-97c1-4eee-a260-d817e1a808f4 | 6 | private static void DoMerge(Object[] numbers, int left, int mid, int right,
int sortColumn) {
int i, left_end, num_elements, tmp_pos;
left_end = (mid - 1);
tmp_pos = left;
num_elements = (right - left + 1);
Object[] temp = new Object[numbers.length];
while ((left <= left_end) && (mid <= right)) {
if (((Number) (((Object[]) numbers[left])[sortColumn])).intValue() <= ((Number) (((Object[]) numbers[mid])[sortColumn]))
.intValue())
temp[tmp_pos++] = numbers[left++];
else
temp[tmp_pos++] = numbers[mid++];
}
while (left <= left_end)
temp[tmp_pos++] = numbers[left++];
while (mid <= right)
temp[tmp_pos++] = numbers[mid++];
for (i = 0; i < num_elements; i++) {
numbers[right] = temp[right];
right--;
}
} |
d510e656-8931-4854-bd1d-ab229be99302 | 5 | private File downloadBackupToFile(String backupName, String outputDirectory, long totalFileBytes) {
final PipedInputStream ftpDataInStream = new PipedInputStream();
File outFile = null;
try {
PipedOutputStream ftpDataOutStream = new PipedOutputStream(ftpDataInStream);
outFile = new File(outputDirectory, backupName);
if (outFile.createNewFile()){
final FileOutputStream fileOutputStream = new FileOutputStream(outFile);
new Thread(
new Runnable() {
public void run() {
try {
synchronized (asyncThreadMonitor) {
bytesDownloaded = IOUtils.copy(ftpDataInStream, fileOutputStream);
if (bytesDownloaded > 0) bytesDownloaded += 0;
}
} catch (IOException e) {
throw new RuntimeException("Exception in copy thread", e);
}
}
}
).start();
} else {
com.unispezi.cpanelremotebackup.tools.Console.println("ERROR: Cannot create \"" + outFile + "\", file already exists.");
}
com.unispezi.cpanelremotebackup.tools.Console.println("Downloading " + backupName + " to " + outFile.getPath() + " :");
com.unispezi.cpanelremotebackup.tools.Console.print("0% ");
FTPClient.ProgressListener listener = new FTPClient.ProgressListener() {
int lastPrintedPercentage = 0;
@Override
public void progressPercentageReached(int percentage) {
int percentageRounded = percentage / 10;
if ( percentageRounded > lastPrintedPercentage){
lastPrintedPercentage = percentageRounded;
com.unispezi.cpanelremotebackup.tools.Console.print(percentageRounded * 10 + "% ");
}
}
};
ftp.downloadFile(backupName, ftpDataOutStream, listener, totalFileBytes);
synchronized (asyncThreadMonitor) {
com.unispezi.cpanelremotebackup.tools.Console.println("\nDownloaded " + bytesDownloaded + " bytes successfully");
}
} catch (IOException e) {
com.unispezi.cpanelremotebackup.tools.Console.println("ERROR: Cannot download backup: " + e);
}
return outFile;
} |
46966352-0091-469f-bee1-a466732fcd2d | 7 | final int[] method1046(int i, int i_8_) {
anInt1719++;
if (i < 0
|| (i ^ 0xffffffff) <= (anIntArrayArray1724.length ^ 0xffffffff)) {
if (anInt1715 == -1)
return new int[0];
return new int[] { anInt1715 };
}
if (!aBooleanArray1725[i]
|| (anIntArrayArray1724[i].length ^ 0xffffffff) >= -2)
return anIntArrayArray1724[i];
int i_9_ = i_8_ == (anInt1715 ^ 0xffffffff) ? 0 : 1;
Random random = new Random();
int[] is = new int[anIntArrayArray1724[i].length];
ArrayUtils.arrayCopy(anIntArrayArray1724[i], 0, is, 0, is.length);
for (int i_10_ = i_9_; is.length > i_10_; i_10_++) {
int i_11_ = i_9_ + Model.method1097((byte) 80, is.length - i_9_,
random);
int i_12_ = is[i_10_];
is[i_10_] = is[i_11_];
is[i_11_] = i_12_;
}
return is;
} |
26014b28-a0d3-4d82-9d58-3415b8e69761 | 2 | public void countFiftyMoveRule(Move lastMove) {
if (lastMove instanceof CaptureMove || lastMove.piece instanceof Pawn) {
this.fiftyMoveRuleCount = 0;
} else {
this.fiftyMoveRuleCount++;
}
} |
bc402f1d-4b5a-40c4-b3af-d0a3d646c74d | 8 | private int getIndex(char letter) {
switch (letter) {
case 'I':
return 0;
case 'V':
return 1;
case 'X':
return 2;
case 'L':
return 3;
case 'C':
return 4;
case 'D':
return 5;
case 'M':
return 6;
case 'E':
return 7;
}
return -1;
} |
50c89f38-35d2-497c-a2c7-34deb3cb1f29 | 0 | @Override
public void mouseExited(MouseEvent e) {} |
8c76e123-436b-4d38-9eda-d99f79e6c5f8 | 7 | Class348_Sub33(int i, byte[] is) {
((Class348_Sub33) this).anInt6958 = i;
ByteBuffer class348_sub49 = new ByteBuffer(is);
((Class348_Sub33) this).anInt6965 = class348_sub49.getUByte();
((Class348_Sub33) this).anIntArrayArray6959
= new int[((Class348_Sub33) this).anInt6965][];
((Class348_Sub33) this).anIntArray6957
= new int[((Class348_Sub33) this).anInt6965];
((Class348_Sub33) this).anIntArray6960
= new int[((Class348_Sub33) this).anInt6965];
((Class348_Sub33) this).aBooleanArray6954
= new boolean[((Class348_Sub33) this).anInt6965];
for (int i_8_ = 0; ((((Class348_Sub33) this).anInt6965 ^ 0xffffffff)
< (i_8_ ^ 0xffffffff)); i_8_++) {
((Class348_Sub33) this).anIntArray6957[i_8_]
= class348_sub49.getUByte();
if (((Class348_Sub33) this).anIntArray6957[i_8_] == 6)
((Class348_Sub33) this).anIntArray6957[i_8_] = 2;
}
for (int i_9_ = 0; ((((Class348_Sub33) this).anInt6965 ^ 0xffffffff)
< (i_9_ ^ 0xffffffff)); i_9_++)
((Class348_Sub33) this).aBooleanArray6954[i_9_]
= (class348_sub49.getUByte() ^ 0xffffffff) == -2;
for (int i_10_ = 0; ((((Class348_Sub33) this).anInt6965 ^ 0xffffffff)
< (i_10_ ^ 0xffffffff)); i_10_++)
((Class348_Sub33) this).anIntArray6960[i_10_]
= class348_sub49.getShort();
for (int i_11_ = 0;
((i_11_ ^ 0xffffffff)
> (((Class348_Sub33) this).anInt6965 ^ 0xffffffff));
i_11_++)
((Class348_Sub33) this).anIntArrayArray6959[i_11_]
= new int[class348_sub49.getUByte()];
for (int i_12_ = 0; i_12_ < ((Class348_Sub33) this).anInt6965;
i_12_++) {
for (int i_13_ = 0;
(i_13_
< ((Class348_Sub33) this).anIntArrayArray6959[i_12_].length);
i_13_++)
((Class348_Sub33) this).anIntArrayArray6959[i_12_][i_13_]
= class348_sub49.getUByte();
}
} |
5e7eb844-2cfb-4c35-a38b-3ea47d4b2d82 | 1 | public final void relocate(String target, String... patterns) {
for (String path : patterns) {
pages.relocate(target, path);
}
} |
a1f60fef-5ff5-47f7-90af-b8e2fc851656 | 8 | public void setEditValue(int n, EditInfo ei) {
if (ei.value > 0 && n == 0) {
onresistance = ei.value;
}
if (ei.value > 0 && n == 1) {
offresistance = ei.value;
}
if (ei.value > 0 && n == 2) {
breakdown = ei.value;
}
if (ei.value > 0 && n == 3) {
holdcurrent = ei.value;
}
} |
37d3acc1-c979-4121-9595-27da88588120 | 6 | public static Rectangle position(Rectangle outer, Rectangle inner, Alignment horizontalAlignment, Alignment verticalAlignment) {
switch (horizontalAlignment) {
case LEFT_TOP:
default:
inner.x = outer.x;
break;
case CENTER:
inner.x = outer.x + (outer.width - inner.width) / 2;
break;
case RIGHT_BOTTOM:
inner.x = outer.x + outer.width - inner.width;
break;
}
switch (verticalAlignment) {
case LEFT_TOP:
default:
inner.y = outer.y;
break;
case CENTER:
inner.y = outer.y + (outer.height - inner.height) / 2;
break;
case RIGHT_BOTTOM:
inner.y = outer.y + outer.height - inner.height;
break;
}
return inner;
} |
397d573d-79fc-4e35-a34b-2522e4bcf599 | 2 | private void dump (Document doc)
throws IOException, FileNotFoundException, XPathExpressionException,
ProtocolException, TransformerException {
long startMillis = System.currentTimeMillis();
String strFileName = null;
NodeList nl = (NodeList) xp.evaluate("//processing-instruction()",
doc, XPathConstants.NODESET);
for (int i = 0; i < nl.getLength(); i++) {
String strTarget = ((ProcessingInstruction) nl.item(i)).getTarget();
if (strTarget.equals("file-name"))
strFileName = ((ProcessingInstruction) nl.item(i)).getData();
nl.item(i).getParentNode().removeChild(nl.item(i));
}
write(url, strFileName, doc, outputProperties);
long endMillis = System.currentTimeMillis();
logger.info("Document " + strFileName + " dumped in " + (endMillis - startMillis) + "ms.");
} |
27172b27-2f3b-4901-b94e-3e15863dd682 | 8 | public void mouseClicked(int par1, int par2, int par3)
{
boolean flag = par1 >= xPos && par1 < xPos + width && par2 >= yPos && par2 < yPos + height;
if (canLoseFocus)
{
setFocused(isEnabled && flag);
}
if (isFocused && par3 == 0)
{
int i = par1 - xPos;
if (enableBackgroundDrawing)
{
i -= 4;
}
String s = fontRenderer.trimStringToWidth(text.substring(field_73816_n), getWidth());
setCursorPosition(fontRenderer.trimStringToWidth(s, i).length() + field_73816_n);
}
} |
889bb39b-8b44-4b0f-9e0b-3e90b9b45615 | 9 | public double powHelper(double x, int n, Hashtable<Integer, Double> ht) {
if(x==0)
if(n<0) return Double.MAX_VALUE;
else if(n==0) return 1.0;
else return 0.0;
if(n==0) return 1.0;
if(n==1) return x;
if(n==-1) return 1.0/x;
if(ht.containsKey(n)) return ht.get(n);
else {
if(n%2==0) {
ht.put(n, powHelper(x, n/2, ht)*powHelper(x, n/2, ht));
return ht.get(n);
} else {
ht.put(n, powHelper(x, n/2, ht)*powHelper(x, n/2+((n>0)?1:(-1)), ht));
return ht.get(n);
}
}
} |
d23b919f-33f6-4c2b-b4be-391a79d25b3c | 9 | public void switchUser(String pUsername)
throws SQLException {
pUsername = pUsername.toUpperCase();
//Validate not attempting to CONNECT as the main user
if(mPromoteUserName.equals(pUsername)){
throw new ExFatalError("Illegal attempt to CONNECT as promotion control user " + pUsername + "; use DISCONNECT instead");
}
//If we're already connected as the requested user, short-circuit out
if(mProxyUserName.equals(pUsername) || (SYSDBA_USER.equals(pUsername) && mIsSysDBAConnectionActive)){
Logger.logDebug("Connect as " + pUsername + " requested but already connected as that user");
return;
}
//Validate that there is no active transaction before attempting to CONNECT
if(isTransactionActive()){
safelyRollback();
throw new ExFatalError("Attempted to switch user from " + currentUserName() + " to " + pUsername + " but a transaction is still active");
}
//Disconnect from the current proxy user first
if(mIsProxyConnectionActive || mIsSysDBAConnectionActive){
disconnectProxyUser();
}
if(SYSDBA_USER.equals(pUsername)){
//Switch the connection to be SYSDBA
//Create a connection just in time if necessary
if(mSysDBAPromoteConnection == null){
mSysDBAPromoteConnection = createOracleConnection(mJDBCConnectString, mPromoteUserName, mPromoteUserPassword, true);
}
mIsSysDBAConnectionActive = true;
}
else {
//Switch to a proxy connection
//Allow the target user to connect through the promotion user
grantProxyConnectToUser(pUsername);
//Switch the session
Properties lProps = new Properties();
lProps.put(OracleConnection.PROXY_USER_NAME, pUsername);
mPromoteConnection.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, lProps);
mProxyUserName = pUsername;
mIsProxyConnectionActive = true;
}
} |
1aa8492a-abe3-477f-a7d0-3af5f0596c7a | 6 | /* */ public void keyReleased(KeyEvent e)
/* */ {
/* 323 */ if (activeClass != null)
/* 324 */ switch (e.getKeyCode()) {
/* */ case 87:
/* 326 */ activeClass.setGoingUp(false);
/* 327 */ activeClass.stop();
/* 328 */ break;
/* */ case 83:
/* 330 */ activeClass.setGoingDown(false);
/* 331 */ activeClass.stop();
/* 332 */ break;
/* */ case 68:
/* 334 */ activeClass.setGoingRight(false);
/* 335 */ activeClass.stop();
/* 336 */ break;
/* */ case 65:
/* 338 */ activeClass.setGoingLeft(false);
/* 339 */ activeClass.stop();
/* 340 */ break;
/* */ case 96:
/* */ }
/* */ } |
989dbac3-4f3f-49c5-bc2b-4030137e0fb7 | 7 | public static boolean isStandardDeviationParam(String accession) {
return INTENSITY_STD_SUBSAMPLE1.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE2.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE3.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE4.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE5.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE6.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE7.getAccession().equals(accession) ||
INTENSITY_STD_SUBSAMPLE8.getAccession().equals(accession);
} |
792f95c0-db43-44df-b746-a78a58d6fd87 | 2 | public static void setLowInventoryWarning(DrugInventoryPage drugInv){
clearLowInventoryTable(Gui.getDrugPage());
String drugName="";
String drugCount="";
ArrayList<String> drug= null;
drug=DatabaseProcess.getDrugCount();
int i=0;
int j=0;
while(i<drug.size()){
drugName=drug.get(i);
drugCount=drug.get(i+1);
if(Integer.parseInt(drugCount)<1000){
drugInv.getLowInventoryTable().setValueAt(drugName,j,0);j++;
}i=i+2;
}
} |
1589f508-de65-4332-878e-df1afd8be07a | 5 | private Initializable replaceSceneContent(String fxml) throws Exception {
FXMLLoader loader = new FXMLLoader();
InputStream in = getClass().getResourceAsStream(fxml);
loader.setBuilderFactory(new JavaFXBuilderFactory());
loader.setLocation(getClass().getResource(fxml));
AnchorPane page;
try {
page = (AnchorPane) loader.load(in);
} finally {
in.close();
}
Scene scene = new Scene(page, 600, 400);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
ScreenController ctrl;
switch (fxml){
case "Welcome":
loader.setController(welcomeController);
break;
case "Configuration":
loader.setController(configurationController);
break;
case "Universe":
loader.setController(universeController);
break;
case "SolarSystem":
loader.setController(solarSystemController);
break;
case "Planet":
loader.setController(planetController);
break;
}
return loader.getController();
} |
eee14306-1866-4216-82e8-17eecccc1d6a | 4 | public static char determineGrade(double s) // s is for score, I reused my way to find the grade from the earlier assignment TestScore
{
if(s < 60)
return 'F';
else if(s < 70)
return 'D';
else if(s < 80)
return 'C';
else if(s < 90)
return 'B';
else
return 'A';
} |
6aeef04b-c38d-4722-9fec-a9795a5f1262 | 5 | public List<Movie> getMoviesByCineplex(Cineplex cineplex) {
moviesByCineplex = new ArrayList<Movie>();
for(Cinema c : cineplex.getCinemas()) {
for(ShowTime st : c.getShowTimes()) {
int month;
calendar.setTime(st.getTime());
month = calendar.get(Calendar.MONTH);
if(st.getMovieTickets().size() > 0 && !moviesByCineplex.contains(st.getMovie()) && currentMonth == month) {
moviesByCineplex.add(st.getMovie());
}
}
}
return moviesByCineplex;
} |
0cee7eef-8ec7-4c6d-9559-12ec8e91c81b | 6 | public ArrayList<Noeud> includedInto(int deb_x, int deb_y, int fin_x,
int fin_y) {
if (plan == null)
return null;
List<Noeud> noeuds = plan.getNoeuds();
ArrayList<Noeud> selection = new ArrayList<Noeud>();
// Pour tous les noeuds
for (Noeud n : noeuds) {
int x = screenX(n.getX());
int y = screenY(n.getY());
// on regarde si le click de la souris est contenu dans la zone de
// dessin
// (attention : l'origine est en haut � droite)
if (deb_x <= x && fin_x >= x + taille_noeud && deb_y <= y
&& fin_y >= y + taille_noeud) {
selection.add(n);
}
}
return selection;
} |
566ba4e1-e42a-4d04-9372-f90ae82e6ad2 | 4 | private Clip initClip(String strIn, String strDefault)
{
Clip clipOut = null;
try
{
clipOut = AudioSystem.getClip();
try
{
clipOut.open
(
AudioSystem.getAudioInputStream
(
new java.io.File(strIn)
)
);
}
catch(Exception e)
{
if (null != strIn && 0 < strIn.length())
EzimLogger.getInstance().warning(e.getMessage(), e);
clipOut.open
(
AudioSystem.getAudioInputStream
(
ClassLoader.getSystemResource(strDefault)
)
);
}
}
catch(Exception e)
{
EzimLogger.getInstance().warning(e.getMessage(), e);
}
return clipOut;
} |
0b138ba8-3a43-4da8-aa3d-64d7e4f7b88d | 1 | public String getValue() {
if (isSortable()) {
WebElement el = element.findElement(By.tagName("div"));
return el.getText();
}
return element.getText();
} |
b4e7e609-1309-4a22-b362-3efa750370ff | 5 | public void setWapSignal(int i)
{
switch (i)
{
case WAP_SIGNAL_NONE:
case WAP_SIGNAL_LOW:
case WAP_SIGNAL_MEDIUM:
case WAP_SIGNAL_HIGH:
case WAP_SIGNAL_DELETE:
wapSignal = i;
break;
default:
throw new RuntimeException("Invalid wap signal value: " + i);
}
} |
5d6f3420-9d96-43cb-909d-34ce8fcbd227 | 3 | private void calcFEP() {
Map<String, Float> fep;
String name = name();
if ((name != null) && (fep = Config.FEPMap.get(name().toLowerCase())) != null) {
FEP = "\n";
for (String key : fep.keySet()) {
FEP += String.format("%s:%.1f ", key, (float) fep.get(key)
* qmult);
}
}
} |
59b2c0eb-dd5b-4a9b-a6a4-c902c84374b7 | 3 | final public void Unary_logical_operator() throws ParseException {
/*@bgen(jjtree) Unary_logical_operator */
SimpleNode jjtn000 = new SimpleNode(JJTUNARY_LOGICAL_OPERATOR);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
jjtn000.jjtSetFirstToken(getToken(1));
try {
if (jj_2_75(3)) {
jj_consume_token(NOT);
} else if (jj_2_76(3)) {
jj_consume_token(EXCLAM);
} else {
jj_consume_token(-1);
throw new ParseException();
}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
jjtn000.jjtSetLastToken(getToken(0));
}
}
} |
9a71ab52-ffb5-40a6-b3c8-ecf7d8ee7970 | 3 | public ArrayList<DBSong> getSongsById(ArrayList<Integer> ids){
StringBuilder sb = new StringBuilder();
for(Integer id : ids){
sb.append(id).append(',');
}
sb.deleteCharAt(sb.lastIndexOf(","));
HashMap<String, String> params = new HashMap<String, String>();
params.put("songids", sb.toString());
ArrayList<DBSong> songs = new ArrayList<DBSong>();
String completeSql = DatabaseHelper.SQLBuilder(
selectSongsByIdSQLTemplate, params);
try {
Statement stmt = dbConn.getDBConnection().createStatement();
ResultSet result = stmt.executeQuery(completeSql);
while(result.next()){
songs.add(dbsongFromResultSet(result));
}
stmt.close();
} catch (SQLException e) {
System.err.println("Could not select the songs from the database.");
e.printStackTrace();
return songs;
}
return songs;
} |
c783c0d7-2427-47e2-bd31-f50d2c03ed16 | 1 | public static void outTrace(String data){
if (trace != null) trace.println(data);
} |
f02e0ca6-e6db-4dd8-affd-fc6f46c9a9d7 | 4 | public boolean ReceivedGiftToday(BirthdayRecord birthday) {
// Is there a birthday record for this player?
if (birthday != null) {
if (birthday.lastGiftDate == null) {
// Player has never received birthday gifts
Debug("Never received a gift");
return false;
}
// Get current date without time (annoying, right?)
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date today;
try {
today = sdf.parse(sdf.format(new Date()));
} catch (ParseException e) {
// This should never happen!
Warn("Unable to parse current date!");
e.printStackTrace();
return false;
}
// Check if player has received a gift today
if (birthday.lastGiftDate.equals(today)) {
Debug("Already receieved a gift today");
return true;
} else {
Debug("Hasn't received a gift today");
return false;
}
}
return false;
} |
b4ff99c7-3c4a-4c2e-83bd-39a980a5e8db | 6 | public static int findNumCommentsMentionedCodeReviews(String content) {
if (content != null && !content.equals(""))
if (content.contains("Code Review")
|| content.contains("code review")
|| content.contains("review")
|| content.contains("reviewed"))
return 1;
return 0;
} |
7f3af4bd-e2e6-47b1-b92b-f9b116f93639 | 9 | public void filterDocument(Dictionary dictionary, int docId, Map<Integer, String> docTable){
String line = "";
String []splitString;
String totalString = "";
StringBuilder sb = new StringBuilder();
while( true){
line = fileProcessor.readLineFromFile();
if( line == null)
break;
// sb.append(line);
splitString = line.split(" ");
for( String temp : splitString){
tokens.add(temp);
}
}
//System.out.println("Title is : " + getTitle(tokens));
docTable.put( docId, getTitle(tokens).replace(',',' '));
removeTags( tokens);
totalString = tokens.toString();
// System.out.println( sb.toString().replaceAll(" ,","").replaceAll("[a-zA-Z]*[-]+[^a-z]*",""));
totalString = totalString.replaceAll(" ,","");
totalString = totalString.replaceAll("\\<.*?>","");
totalString = totalString.replaceAll(",","");
totalString = totalString.replaceAll("\\[","");
totalString = totalString.replaceAll("\\]","");
totalString = totalString.replaceAll("\"","");
totalString = totalString.replaceAll("\\*","");
totalString = totalString.replaceAll(":"," ");
totalString = totalString.replaceAll("\\("," ");
totalString = totalString.replaceAll("\\)"," ");
totalString = totalString.replaceAll("!"," ");
totalString = totalString.replaceAll("/"," ");
totalString = totalString.replaceAll("\\?","");
totalString = totalString.replaceAll("\\$[^0-9]"," ");
//totalString = totalString.replaceAll("\\.[^0-9^a-z]*","");
totalString = totalString.replace("\'","");
totalString = totalString.replace("\"","");
totalString = totalString.replace("\\{","");
totalString = totalString.replace("\\}","");
totalString = totalString.replace("...","");
totalString = totalString.replace("\\`","");
totalString = totalString.replace("&","");
totalString = totalString.replace(";","");
//totalString = totalString.replace("[^0-9][*a-z]@[^0-9][*a-z]","");
StringBuilder stringBuilder = new StringBuilder( totalString);
//stringBuilder = checkFirstDots(stringBuilder);
for( int i =0; i< stringBuilder.length(); i++){
char tempChar = stringBuilder.charAt(i);
if( i+1 == stringBuilder.length()) {
if( tempChar == '-' && tempChar == '-')
stringBuilder.setCharAt(i,' ');
break;
}
char nextChar = stringBuilder.charAt(i + 1);
if( tempChar =='-' && !Character.isDigit(nextChar) ){
stringBuilder.setCharAt(i,' ');
}
}
removeDots( stringBuilder, dictionary, docId);
} |
ab5d718f-340f-44a4-aa96-b3d942647cae | 1 | public void deleteGroup( int id )
{
try
{
PreparedStatement ps = con.prepareStatement( "DELETE FROM groups WHERE id=?" );
ps.setInt( 1, id );
ps.executeUpdate();
ps.close();
}
catch( SQLException e )
{
e.printStackTrace();
}
} |
3303464d-b6e6-4d2a-91a2-682ca8548fc8 | 6 | public void init()
{
boolean debug = CommandLine.booleanVariable("debug");
if (debug)
{
// Enable debug logging
Logger logger = Logger.getLogger("com.reuters.rfa");
logger.setLevel(Level.FINE);
Handler[] handlers = logger.getHandlers();
if (handlers.length == 0)
{
Handler handler = new ConsoleHandler();
handler.setLevel(Level.FINE);
logger.addHandler(handler);
}
for (int index = 0; index < handlers.length; index++)
handlers[index].setLevel(Level.FINE);
}
Context.initialize();
// Create a Session
String sessionName = CommandLine.variable("session");
_session = Session.acquire(sessionName);
if (_session == null)
{
System.out.println("Could not acquire session.");
Context.uninitialize();
System.exit(1);
}
System.out.println("RFA Version: " + Context.getRFAVersionInfo().getProductVersion());
// Create an Event Queue
_eventQueue = EventQueue.create("myEventQueue");
// Create a OMMPool.
_pool = OMMPool.create();
// Create an OMMEncoder
_encoder = _pool.acquireEncoder();
_encoder.initialize(OMMTypes.MSG, 5000);
// Initialize client for login domain.
_loginClient = new LoginClient(this);
// Initialize item manager for item domains
_itemManager = new ItemManager(this);
// Create an OMMConsumer event source
_ommConsumer = (OMMConsumer)_session.createEventSource(EventSource.OMM_CONSUMER,
"myOMMConsumer", true);
// Application may choose to down-load the enumtype.def and RWFFldDictionary
// This example program loads the dictionaries from file only.
String fieldDictionaryFilename = CommandLine.variable("rdmFieldDictionary");
String enumDictionaryFilename = CommandLine.variable("enumType");
try
{
GenericOMMParser.initializeDictionary(fieldDictionaryFilename, enumDictionaryFilename);
}
catch (DictionaryException ex)
{
System.out.println("ERROR: Unable to initialize dictionaries.");
System.out.println(ex.getMessage());
if (ex.getCause() != null)
System.err.println(": " + ex.getCause().getMessage());
cleanup(-1);
return;
}
// Send login request
// Application must send login request first
_loginClient.sendRequest();
} |
025610d2-673d-42a2-950c-2f5dfa627ef6 | 7 | @Override
public String toString() {
// Prometheus (2012), USA, 124 min, csfd: 70%, imdb: 7.5, http://csfd.cz/film/290958
String result = title + " ";
if (year != null)
result += "(" + year + ")";
result += ", ";
if (country != null)
result += country + ", ";
if (length != null)
result += length + ", ";
if (rating_csfd != null || rating_imdb != null) {
result += "Rating: ";
if (rating_csfd != null)
result += rating_csfd + " (csfd.cz), ";
if (rating_imdb != null)
result += rating_imdb + " (imdb.com), ";
}
result += link_csfd;
return result;
} |
33308040-176c-49b7-9d15-2f119475cb37 | 3 | public void run()
{
try
{
this.MReading.acquire();
if(this.counter == 0)
this.MWriting.acquire();
this.counter++;
this.MReading.release();
System.out.println("Lecture");
Thread.sleep(1000);
this.MReading.acquire();
this.counter--;
if(this.counter == 0)
this.MWriting.release();
this.MReading.release();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
} |
ebad640c-9306-44ba-b844-7fa142796f1a | 1 | public static Class[] getParams(String desc) {
if (desc.charAt(0) != '(')
throw new RuntimeException("$sig: internal error");
return getType(desc, desc.length(), 1, 0);
} |
2749e618-fa51-44af-9632-7f376a2ef0eb | 0 | private String extractAnnotationNameFromMethod(Annotation antFromMethod) {
int endOfAnnotationName = antFromMethod.toString().indexOf("(");
String upToAnnotationName = antFromMethod.toString().substring(0,endOfAnnotationName);
return upToAnnotationName.substring(upToAnnotationName.lastIndexOf(".") + 1);
} |
d413b029-1ae5-41f0-bbd4-6776db964c2b | 5 | private void computeError()
{
for(int i = 0; i < targetMacroBlocks.size();i++)
{
RGB[][] t = targetMacroBlocks.get(i);
RGB[][] r = bestBlocks.get(i);
RGB[][] e = new RGB[16][16];
for(int j = 0; j < 16; j++)
for(int k = 0; k < 16; k++)
e[k][j] = new RGB(0,0,0);
for(int y = 0; y < 16; y++)
{
for(int x = 0; x < 16; x++)
{
e[x][y].setRGB( t[x][y].getR() - r[x][y].getR(),
t[x][y].getG() - r[x][y].getG(),
t[x][y].getB() - r[x][y].getB());
}
}
errorBlocks.add(e);
}
} |
1ad14d35-e36e-4ea5-960c-f3b8e128bed5 | 2 | public void heal(int heal) {
if (hurtTime > 0) return;
//level.add(new TextParticle("" + heal, x, y, Color.get(-1, 50, 50, 50)));
health += heal;
if (health > maxHealth) health = maxHealth;
} |
8be5639f-c134-4933-945f-97304d584a94 | 1 | public void addPlayer(Player player)
{
if (playersNo < maxPlayers) {
players[playersNo] = player;
player.prepareToMission();
++playersNo;
wmap.removeShadow(player);
}
} |
d3217ba4-c1c1-4d1d-b24f-0f2ef8c838e0 | 7 | public static boolean func_46154_a(ItemStack par0ItemStack, ItemStack par1ItemStack)
{
return par0ItemStack == null && par1ItemStack == null ? true : (par0ItemStack != null && par1ItemStack != null ? (par0ItemStack.stackTagCompound == null && par1ItemStack.stackTagCompound != null ? false : par0ItemStack.stackTagCompound == null || par0ItemStack.stackTagCompound.equals(par1ItemStack.stackTagCompound)) : false);
} |
acde150b-1116-477c-b0f6-3174115d962a | 4 | public Set<Tile> getTileArray() {
if (tiles != null) {
return tiles;
}
final Polygon polygon = getPolygon();
final Rectangle bounds = polygon.getBounds();
final Set<Tile> set = new HashSet<Tile>();
int x = 0;
while (x < bounds.width) {
int y = 0;
while (y < bounds.height) {
final int tempX = bounds.x + x;
final int tempY = bounds.y + y;
if (polygon.contains(tempX, tempY)) {
set.add(new Tile(tempX, tempY, plane));
}
++y;
}
++x;
}
return this.tiles = set;
} |
3eff476b-e7e5-4235-9253-71a13ad04a04 | 5 | public void draw(Graphics2D g) {
final int s = 30; // size of a cell
g.setColor(BACKGROUND);
g.fillRect(x * s, y * s, s, s);
g.setFont(FONT);
if (state == State.OPEN) {
g.setColor(OPENED);
g.fillRect(x * s, y * s, s, s);
if (type == Type.MINE) {
g.setColor(Color.BLACK);
g.fillOval((x * s) + 8, ((y * s) + 9), s / 2, s / 2);
g.setColor(Color.WHITE);
g.fillOval((x * s) + 10, ((y * s) + 12), 5, 5);
} else if (surroundingBombs > 0) {
g.setColor(CELL_COLOURS[surroundingBombs]);
g.drawString(String.valueOf(surroundingBombs), (x * s) + 8,
((y * s) + s) - 4);
}
}
if (type == Type.FLAGGED || type == Type.FLAGGED_MINE) {
g.setColor(Color.RED);
g.fillRect((x * s) + 8, ((y * s) + 6), 15, 5);
g.setColor(Color.BLACK);
g.fillRect((x * s) + 14, ((y * s) + 11), 3, 15);
}
g.setColor(Color.GRAY); // outline
g.drawRect(x * s, y * s, s, s); // outline
} |
f2da41e3-4927-4fe8-b967-3ef05421734b | 4 | public static void main(String[] args){
Conn con = PoolManager.getInstance().getConnection();
Connection conn = con.getConn();
Statement stmt = null;
ResultSet rs = null;
try {
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from article ");
int c = rs.getMetaData().getColumnCount();
for(int i = 1; i <= c; ++i){
System.out.println(rs.getMetaData().getColumnName(i));
}
while (rs.next()) {
System.out.print(rs.getString("title"));
System.out.print(rs.getString("author"));
//System.out.print(rs.getObject("abc"));
System.out.println();
}
}catch(SQLException e){
e.printStackTrace();
}finally{
/*this.closeDB(stmt, rs);
dbConns.freeConnection("mcms", conn);*/
try{
stmt.close();
}catch(SQLException e){
e.printStackTrace();
}
PoolManager.getInstance().releaseConnection(con);// 释放链接
}
} |
0aa38044-fb54-4378-9023-668501b604cf | 2 | private void addVideo(Video video){
VideoPlayer videoPlayer;
if(scalingFactorX!= 1 || scalingFactorY != 1){
videoPlayer = new VideoPlayer(video,videoListener);
videoPlayer.resizeVideo(scalingFactorX, scalingFactorY);
}
else{
videoPlayer = new VideoPlayer(video,videoListener);
}
layeredPane.add(videoPlayer,video.getLayer());
} |
c9ccd411-320e-4f70-8895-392f978e8600 | 3 | final synchronized public String getString() throws Exception
{
if (type != Type.STRUCT)
throw new Exception("Type " + type + " does not contain string");
final short code = data.getShort(0);
final Type el_type = Type.forCode(code);
if (el_type != Type.STRUCT_STRING)
throw new Exception("No string, structure element is of type " + type);
final int len = data.getInt(2);
final byte[] chars = new byte[len];
for (int i=0; i<len; ++i)
chars[i] = data.get(6 + i);
return new String(chars);
} |
eec33036-e97c-450c-99b7-637a5f4f3aac | 8 | public void saveToFile(String fileName) throws IOException {
/*
* This method writes the XML document in the following format:
*
* <?xml version="1.0" encoding="UTF-8" ?>
* <macro>
* <macroName>test</macroName>
* <action id="default-typed">abcdefg</action>
* [<action id=...>...</action>]
* ...
* </macro>
*
*/
try {
DocumentBuilder db = DocumentBuilderFactory.newInstance().
newDocumentBuilder();
DOMImplementation impl = db.getDOMImplementation();
Document doc = impl.createDocument(null, ROOT_ELEMENT, null);
Element rootElement = doc.getDocumentElement();
// Write the name of the macro.
Element nameElement = doc.createElement(MACRO_NAME);
rootElement.appendChild(nameElement);
// Write all actions (the meat) in the macro.
int numActions = macroRecords.size();
for (int i=0; i<numActions; i++) {
MacroRecord record = (MacroRecord)macroRecords.get(i);
Element actionElement = doc.createElement(ACTION);
actionElement.setAttribute(ID, record.id);
if (record.actionCommand!=null &&
record.actionCommand.length()>0) {
// Remove illegal characters. I'm no XML expert, but
// I'm not sure what I'm doing wrong. If we don't
// strip out chars with Unicode value < 32, our
// generator will insert '&#<value>', which will cause
// our parser to barf when reading the macro back in
// (it says "Invalid XML character"). But why doesn't
// our generator tell us the character is invalid too?
String command = record.actionCommand;
for (int j=0; j<command.length(); j++) {
if (command.charAt(j)<32) {
command = command.substring(0,j);
if (j<command.length()-1)
command += command.substring(j+1);
}
}
Node n = doc.createCDATASection(command);
actionElement.appendChild(n);
}
rootElement.appendChild(actionElement);
}
// Dump the XML out to the file.
StreamResult result = new StreamResult(new File(fileName));
DOMSource source = new DOMSource(doc);
TransformerFactory transFac = TransformerFactory.newInstance();
Transformer transformer = transFac.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, FILE_ENCODING);
transformer.transform(source, result);
} catch (RuntimeException re) {
throw re; // Keep FindBugs happy.
} catch (Exception e) {
throw new IOException("Error generating XML!");
}
} |
ff0640b6-6097-41cb-af2f-50829666a07d | 6 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BookstoreArtistEntity that = (BookstoreArtistEntity) o;
if (artistid != that.artistid) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
return true;
} |
fe7a36d3-3180-442a-83a3-f4b6a9402a59 | 2 | private void startField(){
if (field == null || !running)
{
field = new Thread(this);
field.start();
running = true;
}
} |
8b449db1-12bd-4329-afb0-7bd0b1f1c92d | 2 | public static boolean isParameter(String line){
if(line.contains("=") == false){
return false;
}
String[] split = line.split("=");
if(split.length == 2){
return true;
}
return false;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.