List of usage examples for java.util Locale ROOT
Locale ROOT
To view the source code for java.util Locale ROOT.
Click Source Link
From source file:in.bbat.license.LicenseClient.java
public JSONObject logProfileStart(String paramString1, String paramString2) throws WebServiceException { if ((paramString2 == null) || (paramString2.trim().isEmpty())) paramString2 = new SimpleDateFormat(LicenseManager.getLogDateFormat(), Locale.ROOT).format(new Date()); JSONObject localJSONObject1 = new JSONObject(); try {//from w ww.jav a 2 s. co m localJSONObject1.put("activationCode", paramString1); localJSONObject1.put("timestamp", paramString2); addStandardProperties(localJSONObject1); } catch (JSONException localJSONException) { throw new WebServiceException("Error building JSON:" + localJSONException.getMessage(), localJSONException); } JSONObject localJSONObject2 = WebServiceHelper.makeRequest(getURL("/activation/license/profilestart"), localJSONObject1.toString()); return localJSONObject2; }
From source file:com.puppycrawl.tools.checkstyle.AllChecksTest.java
@Test public void testRequiredTokensAreSubsetOfDefaultTokens() throws Exception { Set<Class<?>> checkstyleChecks = getCheckstyleChecks(); for (Class<?> check : checkstyleChecks) { if (Check.class.isAssignableFrom(check)) { final Check testedCheck = (Check) check.getDeclaredConstructor().newInstance(); final int[] defaultTokens = testedCheck.getDefaultTokens(); final int[] requiredTokens = testedCheck.getRequiredTokens(); if (!isSubset(requiredTokens, defaultTokens)) { String errorMessage = String.format(Locale.ROOT, "%s's required tokens must be a subset" + " of default tokens.", check.getName()); Assert.fail(errorMessage); }// w w w. ja v a 2 s . co m } } }
From source file:com.gargoylesoftware.htmlunit.javascript.host.event.EventListenersContainer.java
/** * Returns the relevant handlers.// www . jav a 2 s . c o m * @param eventType the event type * @param useCapture whether to use capture of not * @return the handlers list */ public List<Scriptable> getHandlers(final String eventType, final boolean useCapture) { final Handlers handlers = eventHandlers_.get(eventType.toLowerCase(Locale.ROOT)); if (handlers != null) { return handlers.getHandlers(useCapture); } return null; }
From source file:com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfigurationTest.java
/** * Return the classes inside the specified package and its sub-packages. * @param klass a class inside that package * @return a list of class names//from w ww . j a v a2 s. co m */ public static List<String> getClassesForPackage(final Class<?> klass) { final List<String> list = new ArrayList<>(); File directory = null; final String relPath = klass.getName().replace('.', '/') + ".class"; final URL resource = JavaScriptConfiguration.class.getClassLoader().getResource(relPath); if (resource == null) { throw new RuntimeException("No resource for " + relPath); } final String fullPath = resource.getFile(); try { directory = new File(resource.toURI()).getParentFile(); } catch (final URISyntaxException e) { throw new RuntimeException(klass.getName() + " (" + resource + ") does not appear to be a valid URL", e); } catch (final IllegalArgumentException e) { directory = null; } if (directory != null && directory.exists()) { addClasses(directory, klass.getPackage().getName(), list); } else { try { String jarPath = fullPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", ""); if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("win")) { jarPath = jarPath.replace("%20", " "); } final JarFile jarFile = new JarFile(jarPath); for (final Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) { final String entryName = entries.nextElement().getName(); if (entryName.endsWith(".class")) { list.add(entryName.replace('/', '.').replace('\\', '.').replace(".class", "")); } } jarFile.close(); } catch (final IOException e) { throw new RuntimeException(klass.getPackage().getName() + " does not appear to be a valid package", e); } } return list; }
From source file:com.useekm.indexing.postgis.IndexedStatement.java
static String normalizeLang(String language) { return language == null ? NULL : language.toLowerCase(Locale.ROOT); }
From source file:com.onedrive.sdk.http.OneDriveServiceException.java
/** * Gets the message for this exception.//from w ww . ja v a 2 s .c o m * @param verbose If the message should be brief or more verbose. * @return The message. */ public String getMessage(final boolean verbose) { final StringBuilder sb = new StringBuilder(); if (mError != null && mError.error != null) { sb.append("Error code: ").append(mError.error.code).append(NEW_LINE); sb.append("Error message: ").append(mError.error.message).append(NEW_LINE); sb.append(NEW_LINE); } // Request information sb.append(mMethod).append(' ').append(mUrl).append(NEW_LINE); for (final String header : mRequestHeaders) { if (verbose) { sb.append(header); } else { final String truncatedHeader = header.substring(0, Math.min(MAX_BREVITY_LENGTH, header.length())); sb.append(truncatedHeader); if (truncatedHeader.length() == MAX_BREVITY_LENGTH) { sb.append(TRUNCATION_MARKER); } } sb.append(NEW_LINE); } if (mRequestBody != null) { if (verbose) { sb.append(mRequestBody); } else { final int bodyLength = Math.min(MAX_BREVITY_LENGTH, mRequestBody.length()); final String truncatedBody = mRequestBody.substring(0, bodyLength); sb.append(truncatedBody); if (truncatedBody.length() == MAX_BREVITY_LENGTH) { sb.append(TRUNCATION_MARKER); } } } sb.append(NEW_LINE).append(NEW_LINE); // Response information sb.append(mResponseCode).append(" : ").append(mResponseMessage).append(NEW_LINE); for (final String header : mResponseHeaders) { if (verbose) { sb.append(header).append(NEW_LINE); } else { if (header.toLowerCase(Locale.ROOT).startsWith("x-throwsite")) { sb.append(header).append(NEW_LINE); } } } if (verbose && mError != null && mError.rawObject != null) { try { final JSONObject jsonObject = new JSONObject(mError.rawObject.toString()); sb.append(jsonObject.toString(INDENT_SPACES)).append(NEW_LINE); } catch (final JSONException ignored) { sb.append("[Warning: Unable to parse error message body]").append(NEW_LINE); } } else { sb.append(TRUNCATION_MARKER).append(NEW_LINE).append(NEW_LINE); sb.append("[Some information was truncated for brevity, enable debug logging for more details]"); } return sb.toString(); }
From source file:com.netflix.discovery.shared.Applications.java
/** * Gets the list of all registered <em>applications</em> for the given * application name.//from w w w . j av a2 s . c om * * @param appName * the application name for which the result need to be fetched. * @return the list of registered applications for the given application * name. */ public Application getRegisteredApplications(String appName) { return appNameApplicationMap.get(appName.toUpperCase(Locale.ROOT)); }
From source file:net.hasor.search.utils.DateUtil.java
/** Formats the date and returns the calendar instance that was used (which may be reused) */ public static Calendar formatDate(Date date, Calendar cal, Appendable out) throws IOException { // using a stringBuilder for numbers can be nice since // a temporary string isn't used (it's added directly to the // builder's buffer. StringBuilder sb = out instanceof StringBuilder ? (StringBuilder) out : new StringBuilder(); if (cal == null) cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ROOT); cal.setTime(date);/*w w w .j a v a 2 s .c om*/ int i = cal.get(Calendar.YEAR); sb.append(i); sb.append('-'); i = cal.get(Calendar.MONTH) + 1; // 0 based, so add 1 if (i < 10) sb.append('0'); sb.append(i); sb.append('-'); i = cal.get(Calendar.DAY_OF_MONTH); if (i < 10) sb.append('0'); sb.append(i); sb.append('T'); i = cal.get(Calendar.HOUR_OF_DAY); // 24 hour time format if (i < 10) sb.append('0'); sb.append(i); sb.append(':'); i = cal.get(Calendar.MINUTE); if (i < 10) sb.append('0'); sb.append(i); sb.append(':'); i = cal.get(Calendar.SECOND); if (i < 10) sb.append('0'); sb.append(i); i = cal.get(Calendar.MILLISECOND); if (i != 0) { sb.append('.'); if (i < 100) sb.append('0'); if (i < 10) sb.append('0'); sb.append(i); // handle canonical format specifying fractional // seconds shall not end in '0'. Given the slowness of // integer div/mod, simply checking the last character // is probably the fastest way to check. int lastIdx = sb.length() - 1; if (sb.charAt(lastIdx) == '0') { lastIdx--; if (sb.charAt(lastIdx) == '0') { lastIdx--; } sb.setLength(lastIdx + 1); } } sb.append('Z'); if (out != sb) out.append(sb); return cal; }
From source file:com.android.talkback.labeling.LabelProvider.java
/** * Queries for a label or multiple labels in the labels database. * * @param uri The URI representing the type of query to perform: * {@code LABELS_CONTENT_URI} for a subset of all labels, * {@code LABELS_ID_CONTENT_URI} for a specific label, or * {@code PACKAGE_SUMMARY} for a label count per package. * @param projection The columns to return. * @param selection The WHERE clause for the query. * @param selectionArgs The arguments for the WHERE clause of the query. * @param sortOrder the ORDER BY clause for the query. * @return A cursor representing the data resulting from the query, or] * {@code null} if the query failed to execute. *//*from w w w . j av a 2s.c o m*/ @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { if (uri == null) { LogUtils.log(this, Log.WARN, NULL_URI_FORMAT_STRING); return null; } if (!UserManagerCompat.isUserUnlocked(getContext())) { return null; } final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder(); queryBuilder.setTables(LabelsTable.TABLE_NAME); String groupBy = null; switch (sUriMatcher.match(uri)) { case LABELS: if (TextUtils.isEmpty(sortOrder)) { sortOrder = LabelsTable.KEY_ID; } break; case LABELS_ID: final String labelIdString = uri.getLastPathSegment(); final int labelId; try { labelId = Integer.parseInt(labelIdString); } catch (NumberFormatException e) { LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri); return null; } final String where = String.format(Locale.ROOT, "%s = %d", LabelsTable.KEY_ID, labelId); queryBuilder.appendWhere(where); break; case PACKAGE_SUMMARY: projection = new String[] { LabelsTable.KEY_PACKAGE_NAME, "COUNT(*)" }; groupBy = LabelsTable.KEY_PACKAGE_NAME; sortOrder = LabelsTable.KEY_PACKAGE_NAME; break; default: LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri); return null; } initializeDatabaseIfNull(); return queryBuilder.query(mDatabase, projection, selection, selectionArgs, groupBy, null /* having */, sortOrder); }
From source file:ch.cyberduck.core.b2.B2ObjectListService.java
/** * @param response List filenames response from server * @return Null when respone filename is not child of working directory directory */// w w w . jav a 2 s . co m protected PathAttributes parse(final B2FileInfoResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setChecksum(Checksum.parse(StringUtils .removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:"))); final long timestamp = response.getUploadTimestamp(); if (response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate( Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } else { attributes.setModificationDate(timestamp); } attributes.setVersionId(response.getFileId()); switch (response.getAction()) { case hide: // File version marking the file as hidden, so that it will not show up in b2_list_file_names case start: // Large file has been started, but not finished or canceled attributes.setDuplicate(true); attributes.setSize(-1L); break; default: attributes.setSize(response.getSize()); } return attributes; }