List of usage examples for java.util Locale ENGLISH
Locale ENGLISH
To view the source code for java.util Locale ENGLISH.
Click Source Link
From source file:de.egore911.opengate.FileuploadServletRequest.java
public static FileuploadServletRequest wrap(HttpServletRequest req, User user) throws ServletException, IOException { if (req.getContentType().toLowerCase(Locale.ENGLISH).startsWith(FileUploadBase.MULTIPART)) { Map<String, Object> parameters = new HashMap<String, Object>(); Map<String, List<String>> parameterValues = new HashMap<String, List<String>>(); ServletFileUpload upload = new ServletFileUpload(); try {/*from www . ja va2 s . com*/ FileItemIterator iter = upload.getItemIterator(req); while (iter.hasNext()) { FileItemStream stream = iter.next(); InputStream s = stream.openStream(); try { String fieldName = stream.getFieldName(); if (stream.isFormField()) { if (parameters.containsKey(fieldName)) { if (!parameterValues.containsKey(fieldName)) { parameterValues.put(fieldName, new ArrayList<String>()); parameterValues.get(fieldName).add((String) parameters.get(fieldName)); } parameterValues.get(fieldName).add(IOUtils.toString(s)); } else { parameters.put(fieldName, IOUtils.toString(s)); } } else { byte[] byteArray = IOUtils.toByteArray(s); if (byteArray.length > 0) { BinaryData binaryData = new BinaryData(); binaryData.setData(new Blob(byteArray)); binaryData.setMimetype(stream.getContentType()); binaryData.setFilename(stream.getName()); binaryData.setSize(byteArray.length); AbstractEntity.setCreated(binaryData, user); parameters.put(fieldName, binaryData); } } } finally { s.close(); } } } catch (FileUploadException e) { throw new ServletException(e); } return new FileuploadServletRequest(parameters, parameterValues); } else { return new FileuploadServletRequest(req); } }
From source file:fi.helsinki.opintoni.service.UserNotificationServiceTest.java
@Test public void thatUserNotificationsAreReturned() { defaultTeacherRequestChain().defaultCoursesWithImplementationsAndRealisations() .activity("teachernotifications.json"); List<UserNotificationDto> userNotifications = userNotificationService.getUserNotifications(1L, Optional.empty(), Optional.of(TestConstants.TEACHER_NUMBER), Locale.ENGLISH); assertThat(userNotifications).hasSize(2); UserNotificationDto userNotificationDto = userNotifications.get(0); assertThat(userNotificationDto.notificationId).isEqualTo("3"); assertThat(userNotificationDto.message).isEqualTo("has written a message"); assertThat(userNotificationDto.read).isTrue(); userNotificationDto = userNotifications.get(1); assertThat(userNotificationDto.notificationId).isEqualTo("4"); assertThat(userNotificationDto.message).isEqualTo("has removed an event"); assertThat(userNotificationDto.read).isFalse(); }
From source file:net.geoprism.JavascriptFileWriter.java
@Request public void write() { String sessionId = SessionFacade.logIn("SYSTEM", "SYSTEM", new Locale[] { Locale.ENGLISH }); try {/*w w w . j a v a2 s. c o m*/ write(sessionId); } finally { SessionFacade.closeSession(sessionId); } }
From source file:httpscheduler.LateBindingRequestHandler.java
@Override public void handle(final HttpRequest request, final HttpResponse response, final HttpContext context) throws HttpException, IOException { //System.out.println("request received"); String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH); if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) { throw new MethodNotSupportedException(method + " method not supported"); }// ww w .j a v a 2s . com if (request instanceof HttpEntityEnclosingRequest) { HttpEntity httpEntity = ((HttpEntityEnclosingRequest) request).getEntity(); String entity = EntityUtils.toString(httpEntity); // Parse HTTP request String parseResult = parseLateBindingRequest(entity, jobMap); StringEntity stringEntity = new StringEntity(""); // if new job received from a client, start executing late binding policy if (parseResult.contains("new-job")) { response.setStatusCode(HttpStatus.SC_OK); String pieces[] = parseResult.split(":"); taskCommExecutor.execute( new LateBindingProbeThread(Integer.parseInt(pieces[1]), Integer.parseInt(pieces[2]))); response.setEntity(new StringEntity("result:success")); } // else if probe response from worker, handle it accordingly else if (parseResult.contains("probe-response")) { //StatsLog.writeToLog("received probe-response"); response.setStatusCode(HttpStatus.SC_OK); String[] pieces = parseResult.split(":"); int jobID = Integer.parseInt(pieces[1]); Task task = jobMap.getTask(jobID); // send NOOP if task queue empty for specified job if (task == null) { response.setStatusCode(HttpStatus.SC_OK); try { stringEntity = new StringEntity("NOOP"); } catch (UnsupportedEncodingException ex) { Logger.getLogger(LateBindingTaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("Responding with NOOP"); } // else send job id, task id and task commmand to worker else { try { stringEntity = new StringEntity(String.valueOf(task.getDuration())); } catch (UnsupportedEncodingException ex) { Logger.getLogger(LateBindingTaskSubmitThread.class.getName()).log(Level.SEVERE, null, ex); } //System.out.println("Responding with task duration: " + task.getDuration()); } response.setEntity(stringEntity); } } }
From source file:org.shredzone.cilla.admin.TimeZoneBean.java
@PostConstruct public void setup() { for (String id : TimeZone.getAvailableIDs()) { TimeZone tz = TimeZone.getTimeZone(id); timeZoneMap.put(id, tz);/* w w w. ja v a2 s .com*/ timeZoneMap.put(tz.getDisplayName(Locale.ENGLISH).toLowerCase(), tz); } }
From source file:inti.util.DateFormatterPerformanceTest.java
public void format(int count) throws Exception { Date date = new Date(); DateFormatter dateFormatter = new DateFormatter(); FastDateFormat fastDateFormat = FastDateFormat.getInstance("EEE, dd-MMM-yyyy hh:mm:ss 'GMT'"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm:ss 'GMT'"); StringBuilder builder = new StringBuilder(); long start, end; Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { dateFormatter.formatDate(date.getTime(), Format.RFC1123, builder, cal); builder.delete(0, builder.length()); }/*from w ww. ja v a2s .co m*/ Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { dateFormatter.formatDate(date.getTime(), Format.RFC1123, builder, cal); builder.delete(0, builder.length()); } end = System.currentTimeMillis(); System.out.format("format(DateFormatter-special) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { dateFormatter.formatDate(date.getTime()); } Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { dateFormatter.formatDate(date.getTime()); } end = System.currentTimeMillis(); System.out.format("format(DateFormatter-simple) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { fastDateFormat.format(date); } Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { fastDateFormat.format(date); } end = System.currentTimeMillis(); System.out.format("format(FastDateFormat) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); for (int i = 0; i < 100; i++) { for (int j = 0; j < 10; j++) { simpleDateFormat.format(date); } Thread.sleep(10); } start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { simpleDateFormat.format(date); } end = System.currentTimeMillis(); System.out.format("format(SimpleDateFormat) - count: %d, duration: %dms, ratio: %#.4f", count, end - start, count / ((end - start) / 1000.0)); System.out.println(); }
From source file:com.benfante.minimark.blo.AssessmentXMLFOBuilderTest.java
/** * Test of makeXMLFO method, of class AssessmentXMLFOBuilder. *//*from w w w . j a v a2 s . c o m*/ public void testMakeXMLFO() { List<AssessmentFilling> assessments = assessmentFillingDao.findAll(); assertNotEmpty(assessments); final AssessmentFilling assessment = assessments.get(0); assertNotNull(assessment.getStartDate()); assertSize(4, assessment.getQuestions()); String xmlfo = assessmentXMLFOBuilder.makeXMLFO(assessment, Locale.ENGLISH); assertTrue("XMLFO is empty", StringUtils.isNotEmpty(xmlfo)); }
From source file:org.openmrs.module.emrapi.web.controller.EmrConceptSearchController.java
@RequestMapping(method = RequestMethod.GET) @ResponseBody/*from w ww . j a v a 2s.c om*/ public Object search(@RequestParam("term") String query, @RequestParam Integer limit) throws Exception { Collection<Concept> diagnosisSets = emrApiProperties.getDiagnosisSets(); Locale locale = Locale.ENGLISH; List<ConceptSearchResult> conceptSearchResults = emrService.conceptSearch(query, locale, null, diagnosisSets, null, limit); List<ConceptName> matchingConceptNames = new ArrayList<ConceptName>(); for (ConceptSearchResult searchResult : conceptSearchResults) { matchingConceptNames.add(searchResult.getConceptName()); } return createListResponse(matchingConceptNames); }
From source file:com.japp.FileCompressor.java
/** * Actual Spring Integration transformation handler. * * @param inputMessage Spring Integration input message * @return New Spring Integration message with updated headers *///from ww w . j a v a 2 s. c o m @Transformer public Message<String> handleFile(final Message<File> inputMessage) { final File inputFile = inputMessage.getPayload(); final String filename = inputFile.getName(); final String fileExtension = FilenameUtils.getExtension(filename); final String inputAsString; try { inputAsString = FileUtils.readFileToString(inputFile); } catch (IOException e) { throw new IllegalStateException(e); } final Message<String> message = MessageBuilder.withPayload(inputAsString.toUpperCase(Locale.ENGLISH)) .setHeader(FileHeaders.FILENAME, filename).setHeader(FileHeaders.ORIGINAL_FILE, inputFile) .setHeader("file_size", inputFile.length()).setHeader("file_extension", fileExtension).build(); return message; }
From source file:de.hybris.platform.b2b.services.impl.DefaultB2BCustomerServiceTest.java
@Before public void before() throws Exception { B2BIntegrationTest.loadTestData();//from ww w . j av a 2 s . c om importCsv("/b2bapprovalprocess/test/b2borganizations.csv", "UTF-8"); sessionService.getCurrentSession().setAttribute("user", this.modelService.<Object>toPersistenceLayer(userService.getAdminUser())); i18nService.setCurrentLocale(Locale.ENGLISH); commonI18NService.setCurrentLanguage(commonI18NService.getLanguage("en")); commonI18NService.setCurrentCurrency(commonI18NService.getCurrency("USD")); }