List of usage examples for java.util LinkedList get
public E get(int index)
From source file:org.zeroxlab.benchmark.Benchmark.java
public void runCase(LinkedList<Case> list) { Case pointer = null;/*from ww w. j a va 2 s. com*/ boolean finish = true; for (int i = 0; i < list.size(); i++) { pointer = list.get(i); if (!pointer.isFinish()) { finish = false; break; } } if (finish) { // mBannerInfo.setText("Benchmarking complete.\nClick Show to upload.\nUploaded results:\nhttp://0xbenchmark.appspot.com"); String result = getResult(); writeResult(mOutputFile, result); final ProgressDialog dialogGetXml = ProgressDialog.show(this, "Generating XML Report", "Please wait...", true, false); new Thread() { public void run() { mJSONResult = getJSONResult(); mXMLResult = getXMLResult(); Log.d(TAG, "XML: " + mXMLResult); writeResult(mOutputXMLFile, mXMLResult); Log.d(TAG, "JSON: " + mJSONResult); writeResult(mOutputJSONFile, mJSONResult); mShow.setClickable(true); onClick(mShow); mTouchable = true; dialogGetXml.dismiss(); } }.start(); } else { Intent intent = pointer.generateIntent(); if (intent != null) { startActivityForResult(intent, 0); } } }
From source file:analysis.postRun.PostRunWindow.java
/** * Method which writes the text passed to the file specified. * @param fileName/*from w w w. j a v a 2s .co m*/ * Which file to write to. * text * List of string arrays to write. */ private void writeToFile(String fileName, LinkedList<String[]> text) { //append text to file fileName try { BufferedWriter b = new BufferedWriter(new FileWriter(fileName)); for (int k = 0; k < text.size(); k++) { for (int l = 0; l < text.get(0).length; l++) { b.append(text.get(k)[l]); } if (k != (text.size() - 1)) { b.append('\n'); } } b.close(); } catch (IOException e) { System.err.println(e.getMessage()); } }
From source file:nl.strohalm.cyclos.services.transfertypes.AuthorizationLevelServiceImpl.java
private AuthorizationLevel getHigherLevel(final AuthorizationLevel authorizationLevel) { final TransferType transferType = authorizationLevel.getTransferType(); final LinkedList<AuthorizationLevel> authorizationLevels = new LinkedList<AuthorizationLevel>( transferType.getAuthorizationLevels()); if (CollectionUtils.isEmpty(authorizationLevels)) { return null; }//from w w w .j av a2 s . c o m final Integer currentLevel = authorizationLevel.getLevel(); if (currentLevel == null) { // We are inserting a new authorization level, so there isn't a higher level return null; } else { // We are updating a saved authorization level if (currentLevel == authorizationLevels.size() || authorizationLevels.size() == 1) { // This level is already the highest or the only one return null; } // List indexes start with 0 return authorizationLevels.get(currentLevel); } }
From source file:com.commander4j.thread.OutboundMessageThread.java
public void run() { logger.debug("OutboundMessageThread running"); setSessionID(JUnique.getUniqueID()); JDBUser user = new JDBUser(getHostID(), getSessionID()); user.setUserId("interface"); user.setPassword("interface"); user.setLoginPassword("interface"); Common.userList.addUser(getSessionID(), user); Common.sd.setData(getSessionID(), "silentExceptions", "Yes", true); Boolean dbconnected = false;//from w w w.j av a2 s . c o m if (Common.hostList.getHost(hostID).isConnected(sessionID) == false) { dbconnected = Common.hostList.getHost(hostID).connect(sessionID, hostID); } else { dbconnected = true; } if (dbconnected) { JeMail mail = new JeMail(getHostID(), getSessionID()); JDBInterfaceRequest ir = new JDBInterfaceRequest(getHostID(), getSessionID()); JDBInterface inter = new JDBInterface(getHostID(), getSessionID()); OutgoingProductionDeclarationConfirmation opdc = new OutgoingProductionDeclarationConfirmation( getHostID(), getSessionID()); OutgoingDespatchConfirmation odc = new OutgoingDespatchConfirmation(getHostID(), getSessionID()); OutgoingDespatchPreAdvice opa = new OutgoingDespatchPreAdvice(getHostID(), getSessionID()); OutgoingDespatchEmail ode = new OutgoingDespatchEmail(getHostID(), getSessionID()); OutgoingEquipmentTracking oet = new OutgoingEquipmentTracking(getHostID(), getSessionID()); OutgoingPalletStatusChange psc = new OutgoingPalletStatusChange(getHostID(), getSessionID()); OutgoingPalletSplit ops = new OutgoingPalletSplit(getHostID(), getSessionID()); OutgoingPalletDelete opd = new OutgoingPalletDelete(getHostID(), getSessionID()); LinkedList<Long> irqList = new LinkedList<Long>(); int noOfMessages = 0; while (true) { JWait.milliSec(500); if (allDone) { if (dbconnected) { Common.hostList.getHost(hostID).disconnect(getSessionID()); } return; } irqList.clear(); irqList = ir.getInterfaceRequestIDs(); noOfMessages = irqList.size(); if (noOfMessages > 0) { for (int x = 0; x < noOfMessages; x++) { JWait.milliSec(100); ir.setInterfaceRequestID(irqList.get(x)); ir.getInterfaceRequestProperties(); if (ir.getMode().equals("Inbound File Re-Submit")) { if (inter.getInterfaceProperties(ir.getInterfaceType(), "Input") == true) { String sourceFile = Common.base_dir + java.io.File.separator + "xml" + java.io.File.separator + "interface" + java.io.File.separator + "error" + java.io.File.separator + ir.getInterfaceType() + java.io.File.separator + ir.getFilename(); destinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename(); renamedDestinationFile = inter.getRealPath() + java.io.File.separator + ir.getFilename().replaceAll(".xml", ".lmx"); mover.move_File(sourceFile, renamedDestinationFile); mover.move_File(renamedDestinationFile, destinationFile); ir.delete(); } } if (ir.getMode().equals("Normal")) { errorMessage = "Unknown Outbound Interface Type :" + ir.getInterfaceType(); messageProcessedOK = false; if (ir.getInterfaceType().equals("Production Declaration")) { messageProcessedOK = opdc.processMessage(ir.getTransactionRef()); errorMessage = opdc.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Production Declaration", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Pallet Status Change")) { messageProcessedOK = psc.processMessage(ir.getTransactionRef()); errorMessage = psc.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Pallet Status Change", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Pallet Split")) { messageProcessedOK = ops.processMessage(ir.getTransactionRef()); errorMessage = ops.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Pallet Split", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Pallet Delete")) { messageProcessedOK = opd.processMessage(ir.getTransactionRef()); errorMessage = opd.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Pallet Delete", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Despatch Confirmation")) { messageProcessedOK = odc.processMessage(ir.getTransactionRef()); errorMessage = odc.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Despatch Confirmation", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Despatch Pre Advice")) { messageProcessedOK = opa.processMessage(ir.getTransactionRef()); errorMessage = opa.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Despatch Pre Advice", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Despatch Email")) { messageProcessedOK = ode.processMessage(ir.getTransactionRef()); errorMessage = ode.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Despatch Email", messageProcessedOK.toString()); } if (ir.getInterfaceType().equals("Equipment Tracking")) { messageProcessedOK = oet.processMessage(ir.getTransactionRef()); errorMessage = oet.getErrorMessage(); GenericMessageHeader.updateStats("Output", "Equipment Tracking", messageProcessedOK.toString()); } if (messageProcessedOK == true) { ir.delete(); } else { ir.update(irqList.get(x), "Error"); if (inter.getInterfaceProperties(ir.getInterfaceType(), "Output") == true) { if (inter.getEmailError() == true) { String emailaddresses = inter.getEmailAddresses(); StringConverter stringConverter = new StringConverter(); ArrayConverter arrayConverter = new ArrayConverter(String[].class, stringConverter); arrayConverter.setDelimiter(';'); arrayConverter.setAllowedChars(new char[] { '@' }); String[] emailList = (String[]) arrayConverter.convert(String[].class, emailaddresses); if (emailList.length > 0) { try { String siteName = Common.hostList.getHost(getHostID()) .getSiteDescription(); mail.postMail(emailList, "Error Processing Outgoing " + ir.getInterfaceType() + " for [" + siteName + "] on " + JUtility.getClientName(), errorMessage, "", ""); } catch (MessagingException e) { } } } } } } } } } } }
From source file:controllers.controller.java
private double calculaAvanceEtapa(LinkedList data, double advanceToActivity) { int numeroActividades = Integer.parseInt(data.get(0).toString()); double PAT = Double.parseDouble(data.get(1).toString()); double PATaux = 0; double PA = 0; PA = 100 / numeroActividades;//from ww w . j av a 2s . co m PATaux = (advanceToActivity * PA) / 100; PAT += PATaux; return PAT; }
From source file:com.github.riotopsys.malforandroid2.fragment.AnimeDetailFragment.java
private Dialog createAnimePickerDialog(final LinkedList<AnimeCrossReferance> crefs) { List<CharSequence> titles = new LinkedList<CharSequence>(); for (AnimeCrossReferance cr : crefs) { titles.add(Html.fromHtml(cr.title)); }/*from www. j a v a2 s . c o m*/ return new AlertDialog.Builder(getActivity()) .setItems(titles.toArray(new CharSequence[0]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { bus.post(new AnimeChangeDetailViewRequest(crefs.get(which).anime_id)); } }).create(); }
From source file:com.github.riotopsys.malforandroid2.fragment.AnimeDetailFragment.java
private Dialog createMangaPickerDialog(final LinkedList<MangaCrossReferance> crefs) { List<CharSequence> titles = new LinkedList<CharSequence>(); for (MangaCrossReferance cr : crefs) { titles.add(Html.fromHtml(cr.title)); }/*w ww.ja v a 2 s . c o m*/ return new AlertDialog.Builder(getActivity()) .setItems(titles.toArray(new CharSequence[0]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { bus.post(new MangaChangeDetailViewRequest(crefs.get(which).manga_id)); } }).create(); }
From source file:fi.helsinki.lib.simplerest.BundleResource.java
@Put public Representation editBundle(InputRepresentation rep) { Context c = null;/*from w w w.j ava2 s.com*/ Bundle bundle = null; try { c = getAuthenticatedContext(); bundle = Bundle.find(c, this.bundleId); if (bundle == null) { return errorNotFound(c, "Could not find the bundle."); } } catch (SQLException e) { return errorInternal(c, "SQLException"); } DomRepresentation dom = new DomRepresentation(rep); Node attributesNode = dom.getNode("//dl[@id='attributes']"); if (attributesNode == null) { return error(c, "Did not find dl tag with a id 'attributes'.", Status.CLIENT_ERROR_BAD_REQUEST); } int nameFound = 0; int primarybitstreamidFound = 0; NodeList nodes = attributesNode.getChildNodes(); LinkedList<String> dtList = new LinkedList(); LinkedList<String> ddList = new LinkedList(); int nNodes = nodes.getLength(); for (int i = 0; i < nNodes; i++) { Node node = nodes.item(i); String nodeName = node.getNodeName(); if (nodeName.equals("dt")) { dtList.add(node.getTextContent()); } else if (nodeName.equals("dd")) { ddList.add(node.getTextContent()); } } if (dtList.size() != ddList.size()) { return error(c, "The number of <dt> and <dd> elements do not match.", Status.CLIENT_ERROR_BAD_REQUEST); } int size = dtList.size(); for (int i = 0; i < size; i++) { String dt = dtList.get(i); String dd = ddList.get(i); if (dt.equals("name")) { nameFound = 1; bundle.setName(dd); } else if (dt.equals("primarybitstreamid")) { primarybitstreamidFound = 1; Integer id = Integer.parseInt(dd); boolean validBitstreamId = false; Bitstream[] bitstreams = bundle.getBitstreams(); if (id == -1) { // -1 means that we do not want to validBitstreamId = true; // specify the primary bitstream. } else { for (Bitstream bitstream : bitstreams) { if (id == bitstream.getID()) { validBitstreamId = true; break; } } } if (!validBitstreamId) { return error(c, "Invalid primarybitstreamid.", Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY); } if (id == -1) { bundle.unsetPrimaryBitstreamID(); } else { bundle.setPrimaryBitstreamID(id); } } else { return error(c, "Unexpected data in attributes: " + dt, Status.CLIENT_ERROR_BAD_REQUEST); } } // If the was data missing, report it: String[] problems = { "'nameFound' and 'primarybitstreamid'", "'nameFound'", "'primarybitstreamid'", "" }; String problem = problems[primarybitstreamidFound + 2 * nameFound]; if (!problem.equals("")) { return error(c, problem + " was not found from the request.", Status.CLIENT_ERROR_BAD_REQUEST); } try { bundle.update(); c.complete(); } catch (AuthorizeException ae) { return error(c, "Unauthorized", Status.CLIENT_ERROR_UNAUTHORIZED); } catch (Exception e) { return errorInternal(c, e.toString()); } return successOk("Bundle updated."); }
From source file:de.qspool.clementineremote.ui.fragments.PlaylistFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_playlist, container, false); mPlaylists = mPlaylistManager.getAllPlaylists(); mList = (ListView) view.findViewById(R.id.songs); mEmptyPlaylist = view.findViewById(R.id.playlist_empty); // Add Spinner to toolbar mPlaylistsSpinner = (Spinner) getActivity().findViewById(R.id.toolbar_spinner); mPlaylistsSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override//from w w w. j a v a 2 s.co m public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { updateSongList(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); updatePlaylistSpinner(); // Create the adapter mAdapter = new PlaylistSongAdapter(getActivity(), R.layout.item_playlist, getSelectedPlaylistSongs()); mList.setOnItemClickListener(oiclSong); mList.setAdapter(mAdapter); mList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); mList.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override public boolean onActionItemClicked(ActionMode mode, android.view.MenuItem item) { SparseBooleanArray checkedPositions = mList.getCheckedItemPositions(); LinkedList<MySong> selectedSongs = new LinkedList<>(); for (int i = 0; i < checkedPositions.size(); ++i) { int position = checkedPositions.keyAt(i); if (checkedPositions.valueAt(i)) { selectedSongs.add(getSelectedPlaylistSongs().get(position)); } } if (!selectedSongs.isEmpty()) { switch (item.getItemId()) { case R.id.playlist_context_play: playSong(selectedSongs.get(0)); mode.finish(); return true; case R.id.playlist_context_download: LinkedList<String> urls = new LinkedList<>(); for (MySong s : selectedSongs) { urls.add(s.getUrl()); } if (!urls.isEmpty()) { DownloadManager.getInstance().addJob( ClementineMessageFactory.buildDownloadSongsMessage(DownloadItem.Urls, urls)); } mode.finish(); return true; case R.id.playlist_context_remove: Message msg = Message.obtain(); msg.obj = ClementineMessageFactory.buildRemoveMultipleSongsFromPlaylist(getPlaylistId(), selectedSongs); App.ClementineConnection.mHandler.sendMessage(msg); mode.finish(); return true; default: return false; } } return false; } @Override public boolean onCreateActionMode(ActionMode mode, android.view.Menu menu) { android.view.MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.playlist_context_menu, menu); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getActivity().getWindow() .setStatusBarColor(ContextCompat.getColor(getActivity(), R.color.grey_cab_status)); return true; } @Override public boolean onPrepareActionMode(ActionMode mode, android.view.Menu menu) { return false; } @Override public void onDestroyActionMode(ActionMode mode) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getActivity().getWindow() .setStatusBarColor(ContextCompat.getColor(getActivity(), R.color.actionbar_dark)); } @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { } }); // Filter the results mAdapter.getFilter().filter(mFilterText); mActionBar.setTitle(""); mActionBar.setSubtitle(""); return view; }
From source file:com.evolveum.midpoint.test.ldap.OpenDJController.java
public Entry searchByEntryUuid(String entryUuid) throws DirectoryException { InternalSearchOperation op = getInternalConnection().processSearch("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, DereferencePolicy.NEVER_DEREF_ALIASES, 100, 100, false, "(entryUUID=" + entryUuid + ")", getSearchAttributes()); LinkedList<SearchResultEntry> searchEntries = op.getSearchEntries(); if (searchEntries == null || searchEntries.isEmpty()) { return null; }// w w w .j a va 2 s . co m if (searchEntries.size() > 1) { AssertJUnit.fail("Multiple matches for Entry UUID " + entryUuid + ": " + searchEntries); } return searchEntries.get(0); }