List of usage examples for java.lang String contentEquals
public boolean contentEquals(CharSequence cs)
From source file:se.inera.certificate.proxy.mappings.remote.RemoteDispatcher.java
private HttpResponse makeRequest(HttpServletRequest request, URI newUrl) throws IOException { log.debug("CALLING: {}", newUrl); String method = request.getMethod(); if (method.equalsIgnoreCase("GET")) { return makeGetRequest(request, new HttpGet(newUrl)); } else if (method.contentEquals("POST")) { return makePostRequest(request, new HttpPost(newUrl)); } else if (method.contentEquals("PUT")) { return makePutRequest(request, new HttpPut(newUrl)); } else if (method.contentEquals("OPTIONS")) { return makeOptionsRequest(request, new HttpOptions(newUrl)); }/* www . j a v a 2 s . co m*/ return new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_FORBIDDEN, "Unknown method:" + method); }
From source file:org.lockss.plugin.atypon.EncodingRisMetadataExtractor.java
/** * Extract metadata from the content of the cu, which should be an RIS file. * Reads line by line inserting the 2 character code and value into the raw map. * The first line should be a material type witch if it is book or journal will * determine if we interpret the SN tag as IS beltSN or ISBN. * @param target//w w w . j av a2s . c om * @param cu */ public final ArticleMetadata extract(MetadataTarget target, CachedUrl cu) throws IOException, PluginException { if (cu == null) { throw new IllegalArgumentException(); } ArticleMetadata md = new ArticleMetadata(); // This call will correctly guess the encoding Pair<Reader, String> retInfoPair = CharsetUtil.getCharsetReader(cu.getUnfilteredInputStream()); BufferedReader bReader = new BufferedReader(retInfoPair.getLeft()); //BufferedReader bReader = new BufferedReader(cu.openForReading()); String line; String refType = null; try { if (!containsRisTag("TY")) { while (refType == null && (line = bReader.readLine()) != null) { if (line.trim().toUpperCase().startsWith("TY") && line.contains(delimiter) && !line.endsWith(delimiter)) { String value = line.substring(line.indexOf(delimiter) + 1).trim().toUpperCase(); if (value.contentEquals("JOUR")) { refType = REFTYPE_JOURNAL; } else if (value.contentEquals("BOOK")) { refType = REFTYPE_BOOK; } else { refType = REFTYPE_OTHER; } } } if (refType == null) { return md; } } while ((line = bReader.readLine()) != null) { line = line.trim(); if (!line.contentEquals("") && line.contains(delimiter) && !line.endsWith(delimiter)) { String value = line.substring(line.indexOf(delimiter) + 1); String key = line.substring(0, line.indexOf(delimiter) - 1); key = key.trim().toUpperCase(); md.putRaw(key, value.trim()); if (!containsRisTag("SN") && key.contentEquals("SN")) { if (refType.contentEquals(REFTYPE_BOOK)) { addRisTag("SN", MetadataField.FIELD_ISBN); } else { addRisTag("SN", MetadataField.FIELD_ISSN); } } } } } finally { IOUtil.safeClose(bReader); } md.cook(risTagToMetadataField); return md; }
From source file:com.michaeljones.hellohadoop.restclient.HadoopHdfsRestClientTest.java
/** * Test of ListDirectorySimple method, of class HadoopHdfsRestClient. *//*from w w w . j a v a2s . c om*/ @Test public void testListDirectorySimple() { System.out.println("ListDirectory"); // First test the Jersey back end implementation. HadoopHdfsRestClient instance = HadoopHdfsRestClient.JerseyClientFactory(NAMENODE_HOST, USERNAME); // Home directory. String relativePath = ""; String[] directoryListing = instance.ListDirectorySimple(relativePath); assertTrue(directoryListing != null); assertTrue(directoryListing.length > 0); boolean foundHelloFile = false; for (String listing : directoryListing) { if (listing.contentEquals("hello.txt")) { foundHelloFile = true; } } // The file is expected to have been created by the HDFS tests. assertTrue(foundHelloFile); // Now test the Apache back end implementation. It should behave the same. instance = HadoopHdfsRestClient.ApacheClientFactory(NAMENODE_HOST, USERNAME); directoryListing = instance.ListDirectorySimple(relativePath); assertTrue(directoryListing != null); assertTrue(directoryListing.length > 0); foundHelloFile = false; for (String listing : directoryListing) { if (listing.contentEquals("hello.txt")) { foundHelloFile = true; } } // The file is expected to have been created by the HDFS tests. assertTrue(foundHelloFile); }
From source file:se.lu.nateko.edca.svc.GetMap.java
/** * Method that calls a geospatial server using a GetMap request and, * if successful, stores the resulting InputStream in a reusable version. * @return Returns true if successful, otherwise false. *///from w w w .j a v a 2s .c om protected int getMapRequest() { // Log.d(TAG, "getMapRequest() called"); /* Check if any layers should be requested. If not, cancel the GetMap request. */ String layers = fetchLayerNames(); if (layers.contentEquals("")) return RESULT_NOLAYERS; /* Try to form an URI from the supplied ServerConnection info and the list of * layers set to display in the local SQLite database. */ String uriString = ""; try { uriString = mServerConnection.getAddress() + "/wms?service=wms&version=1.1.0&request=GetMap&layers=" + layers + "&bbox=" + Utilities.latLngBoundsToString(mBounds) + "&styles=" + "&transparent=true" + "&srs=epsg:3857" + "&format=image/png" + "&width=" + String.valueOf(mWidth) + "&height=" + String.valueOf(mHeight); mServerURI = new URI(uriString); } catch (NullPointerException e) { Log.e(TAG, e.toString()); return RESULT_FAILURE; } catch (URISyntaxException e) { Log.e(TAG, e.toString() + ": " + uriString); return RESULT_FAILURE; } /* Execute the HTTP request. */ HttpGet httpGetMethod = new HttpGet(mServerURI); HttpResponse response; try { final HttpParams httpParameters = mHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, TIME_OUT * 1000); HttpConnectionParams.setSoTimeout(httpParameters, TIME_OUT * 1000); response = mHttpClient.execute(httpGetMethod); Log.i(TAG, "getMap request made to database: " + httpGetMethod.getURI().toString()); InputStream imageStream = response.getEntity().getContent(); try { // Log.v(TAG, "Saving response as a Bitmap."); setImage(BitmapFactory.decodeStream(imageStream)); // Save the HttpResponse as a Bitmap image to be displayed. } finally { imageStream.close(); } return RESULT_SUCCESS; } catch (MalformedURLException e) { Log.e(TAG, e.toString()); return RESULT_FAILURE; } catch (IOException e) { Log.e(TAG, e.toString()); return RESULT_FAILURE; } }
From source file:org.openmrs.module.DeIdentifiedPatientDataExportModule.web.controller.DeIdentifiedPatientDataExportModuleManageController.java
@RequestMapping(value = "/module/DeIdentifiedPatientDataExportModule/new", method = RequestMethod.GET) public void new_manage(HttpServletResponse response, HttpServletRequest request) { String ids = ""; String ab = request.getParameter("patientId"); System.out.println("ids" + ids); DeIdentifiedExportService d = Context.getService(DeIdentifiedExportService.class); ids = request.getParameter("listPatientIds"); int flag = 0; String a = request.getParameter("format"); String c = request.getParameter("cohort"); String pn = request.getParameter("profileName"); int idP = d.getProfileIdByName(pn); List<String> list = d.getConceptsByCategoryByPid("PersonAttribute", idP); String b = request.getParameter("patientInput"); List<Integer> idList = new ArrayList<Integer>(); StringBuffer sb = new StringBuffer(""); //d.exportCohort(); if (b.contentEquals("single")) { ids = request.getParameter("patientId"); } else if (b.contentEquals("multiple")) { ids = request.getParameter("listPatientIds"); }//w w w .ja va2 s .c o m else if (b.contentEquals("cohort")) { flag = 1; int id = Integer.parseInt(c); CohortService cs = Context.getCohortService(); Cohort cohort = cs.getCohort(id); Set<Integer> cohortSet = cohort.getMemberIds(); for (Integer i : cohortSet) { sb.append(i.toString()); sb.append(","); } } if (a.contentEquals("json")) { if (flag == 1) ids = sb.toString(); d.exportJson(response, ids, idP); } else if (a.contentEquals("sql")) { if (flag == 1) ids = sb.toString(); d.generatePatientSQL(response, ids, idP); } else { if (flag == 1) ids = sb.toString(); d.extractPatientData(response, ids, idP); } }
From source file:eu.trentorise.smartcampus.jp.notifications.BroadcastNotificationsFragment.java
@Override public void onStart() { super.onStart(); ListView list = (ListView) getSherlockActivity().findViewById(R.id.bn_options_list); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getSherlockActivity(), android.R.layout.simple_list_item_1, JPParamsHelper.getBroadcastNotificationsOptions()); list.setAdapter(adapter);//w ww. j a v a2s. c om list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String itemtext = ((TextView) view).getText().toString(); Bundle bundle = new Bundle(); bundle.putString("itemtext", itemtext); SherlockFragment fragment = null; if (itemtext.contentEquals(getString(R.string.broadcast_notifications_bus_trento_delay))) { bundle.putStringArray(BT_DelayFormFragment.ARG_AGENCYIDS, new String[] { RoutesHelper.AGENCYID_BUS_TRENTO }); fragment = new BT_DelayFormFragment(); } else if (itemtext.contentEquals(getString(R.string.broadcast_notifications_bus_rovereto_delay))) { bundle.putStringArray(BT_DelayFormFragment.ARG_AGENCYIDS, new String[] { RoutesHelper.AGENCYID_BUS_ROVERETO }); fragment = new BT_DelayFormFragment(); } else if (itemtext.contentEquals(getString(R.string.broadcast_notifications_bus_suburban_delay))) { bundle.putStringArray(BT_DelayFormFragment.ARG_AGENCYIDS, new String[] { RoutesHelper.AGENCYID_BUS_SUBURBAN }); fragment = new BT_DelayFormFragment(); } else if (itemtext.contentEquals(getString(R.string.broadcast_notifications_train_delay))) { bundle.putStringArray(BT_DelayFormFragment.ARG_AGENCYIDS, new String[] { RoutesHelper.AGENCYID_TRAIN_BZVR, RoutesHelper.AGENCYID_TRAIN_TM, RoutesHelper.AGENCYID_TRAIN_TNBDG }); fragment = new BT_DelayFormFragment(); } else { // fragment = new FormFragment(); Toast.makeText(getSherlockActivity().getApplicationContext(), R.string.tmp, Toast.LENGTH_SHORT) .show(); } if (JPHelper.isUserAnonymous(getSherlockActivity())) { // show dialog box //Toast // Toast.makeText(getSherlockActivity(), "dialog upgrade", Toast.LENGTH_LONG).show(); UserRegistration.upgradeuser(getSherlockActivity()); } else if (fragment != null) { fragment.setArguments(bundle); FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager() .beginTransaction(); // fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); // fragmentTransaction.detach(self); fragmentTransaction.replace(Config.mainlayout, fragment, Config.NOTIFICATIONS); fragmentTransaction.addToBackStack(fragment.getTag()); fragmentTransaction.commit(); } } }); }
From source file:org.jboss.forge.navigation.GoTest.java
@Test public void globalGoTest() throws Exception { String marktest = "forge" + RandomStringUtils.randomAlphanumeric(8); String path = shell.getCurrentDirectory().getFullyQualifiedName(); globalBookmarkCache.addBookmark(marktest, path); shell.execute("cd .."); String path2 = shell.getCurrentDirectory().getFullyQualifiedName(); assert !path.contentEquals(path2); shell.execute("go " + marktest); String path3 = shell.getCurrentDirectory().getFullyQualifiedName(); assert path.contains(path3); globalBookmarkCache.delBookmark(marktest); }
From source file:org.jboss.forge.navigation.GoTest.java
@Test public void projectGoTest() throws Exception { String marktest = "forge" + RandomStringUtils.randomAlphanumeric(8); String path = shell.getCurrentDirectory().getFullyQualifiedName(); projectBookmarkCache.addBookmark(marktest, path); shell.execute("cd .."); String path2 = shell.getCurrentDirectory().getFullyQualifiedName(); assert !path.contentEquals(path2); shell.execute("go " + marktest); String path3 = shell.getCurrentDirectory().getFullyQualifiedName(); assert path2.contains(path3); shell.execute("cd " + path); projectBookmarkCache.delBookmark(marktest); }
From source file:graphql.servlet.GraphQLServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { GraphQLContext context = createContext(Optional.of(req), Optional.of(resp)); String path = req.getPathInfo(); if (path == null) { path = req.getServletPath();/*from w ww .j av a2 s . c o m*/ } if (path.contentEquals("/schema.json")) { query(CharStreams.toString( new InputStreamReader(GraphQLServlet.class.getResourceAsStream("introspectionQuery"))), null, new HashMap<>(), getSchema(), req, resp, context); } else { if (req.getParameter("q") != null) { query(req.getParameter("q"), null, new HashMap<>(), getReadOnlySchema(), req, resp, context); } else if (req.getParameter("query") != null) { Map<String, Object> variables = new HashMap<>(); if (req.getParameter("variables") != null) { variables.putAll(new ObjectMapper().readValue(req.getParameter("variables"), new TypeReference<Map<String, Object>>() { })); } String operationName = null; if (req.getParameter("operationName") != null) { operationName = req.getParameter("operationName"); } query(req.getParameter("query"), operationName, variables, getReadOnlySchema(), req, resp, context); } } }
From source file:org.jboss.forge.navigation.MarkTest.java
@Test public void testAddProjectOverwriteMark() throws Exception { String marktest = "forge" + RandomStringUtils.randomAlphanumeric(8); queueInputLines("y"); getShell().execute("mark add " + marktest); String path1 = projectBookmarkCache.getBookmark(marktest); getShell().execute("mark add " + marktest); String path2 = projectBookmarkCache.getBookmark(marktest); assert path1.contentEquals(path2); projectBookmarkCache.delBookmark(marktest); }