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:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.java
/** * {@inheritDoc}//from w w w . j a v a 2 s . co m */ @Override public String getNodeName() { final DomNode domNode = getDomNodeOrDie(); String nodeName = domNode.getNodeName(); if (domNode.getHtmlPageOrNull() != null) { nodeName = nodeName.toUpperCase(Locale.ROOT); } return nodeName; }
From source file:ch.cyberduck.ui.cocoa.BrowserController.java
private void setBookmarkFilter(final String searchString) { if (StringUtils.isBlank(searchString)) { searchField.setStringValue(StringUtils.EMPTY); bookmarkModel.setFilter(null);//from www .j a v a 2s .co m } else { bookmarkModel.setFilter(new HostFilter() { @Override public boolean accept(Host host) { return StringUtils.lowerCase(BookmarkNameProvider.toString(host)) .contains(searchString.toLowerCase(Locale.ROOT)) || ((null != host.getComment()) && StringUtils.lowerCase(host.getComment()) .contains(searchString.toLowerCase(Locale.ROOT))) || ((null != host.getCredentials().getUsername()) && StringUtils.lowerCase(host.getCredentials().getUsername()) .contains(searchString.toLowerCase(Locale.ROOT))) || StringUtils.lowerCase(host.getHostname()) .contains(searchString.toLowerCase(Locale.ROOT)); } }); } this.reloadBookmarks(); }
From source file:org.apache.solr.SolrTestCaseJ4.java
/** * Returns a Date such that all results from this method always have the same values for * year+month+day+hour+minute but the seconds are randomized. This can be helpful for * indexing documents with random date values that are biased for a narrow window * (one day) to test collisions/overlaps * * @see #randomDate/* w w w .j ava 2 s . c o m*/ */ public static String randomSkewedDate() { return String.format(Locale.ROOT, "2010-10-31T10:31:%02d.000Z", TestUtil.nextInt(random(), 0, 59)); }
From source file:org.apache.manifoldcf.crawler.connectors.sharepoint.SharePointRepository.java
/** Method that fetches and indexes a file fetched from a SharePoint URL, with appropriate error handling * etc./* w ww . ja v a2 s .c o m*/ */ protected void fetchAndIndexFile(IProcessActivity activities, String documentIdentifier, String version, String fileUrl, String fetchUrl, String[] accessTokens, String[] denyTokens, Date createdDate, Date modifiedDate, Map<String, String> metadataValues, String guid, SystemMetadataDescription sDesc) throws ManifoldCFException, ServiceInterruption { String errorCode = null; String errorDesc = null; long startTime = System.currentTimeMillis(); Long fileLengthLong = null; try { // Before we fetch, confirm that the output connector will accept the document if (!activities.checkURLIndexable(fileUrl)) { // URL failed errorCode = activities.EXCLUDED_URL; errorDesc = "Document rejected because of URL (" + fileUrl + ")"; if (Logging.connectors.isDebugEnabled()) Logging.connectors.debug("SharePoint: Skipping document '" + documentIdentifier + "' because output connector says URL '" + fileUrl + "' is not indexable"); activities.noDocument(documentIdentifier, version); return; } // Also check mime type String contentType = mapExtensionToMimeType(documentIdentifier); if (!activities.checkMimeTypeIndexable(contentType)) { // Mime type failed errorCode = activities.EXCLUDED_MIMETYPE; errorDesc = "Document rejected because of mime type (" + contentType + ")"; if (Logging.connectors.isDebugEnabled()) Logging.connectors.debug("SharePoint: Skipping document '" + documentIdentifier + "' because output connector says mime type '" + ((contentType == null) ? "null" : contentType) + "' is not indexable"); activities.noDocument(documentIdentifier, version); return; } // Now check date stamp if (!activities.checkDateIndexable(modifiedDate)) { // Date failed errorCode = activities.EXCLUDED_DATE; errorDesc = "Document rejected because of date (" + modifiedDate + ")"; if (Logging.connectors.isDebugEnabled()) Logging.connectors.debug("SharePoint: Skipping document '" + documentIdentifier + "' because output connector says date '" + ((modifiedDate == null) ? "null" : modifiedDate) + "' is not indexable"); activities.noDocument(documentIdentifier, version); return; } // Set stuff up for fetch activity logging try { // Read the document into a local temporary file, so I get a reliable length. File tempFile = File.createTempFile("__shp__", ".tmp"); try { // Open the output stream OutputStream os = new FileOutputStream(tempFile); try { // Catch all exceptions having to do with reading the document try { ExecuteMethodThread emt = new ExecuteMethodThread(httpClient, fetchUrl, os); emt.start(); int returnCode = emt.finishUp(); if (returnCode == 404 || returnCode == 401 || returnCode == 400 || returnCode == 415) { // Well, sharepoint thought the document was there, but it really isn't, so delete it. errorCode = "DOCUMENTNOTFOUND"; errorDesc = "Document not found; HTTP code " + returnCode; if (Logging.connectors.isDebugEnabled()) Logging.connectors.debug( "SharePoint: Document at '" + fileUrl + "' failed to fetch with code " + Integer.toString(returnCode) + ", deleting"); activities.noDocument(documentIdentifier, version); return; } else if (returnCode != 200) { errorCode = "UNKNOWNHTTPCODE"; errorDesc = "Unknown HTTP return code " + returnCode; throw new ManifoldCFException("Error fetching document '" + fileUrl + "': " + Integer.toString(returnCode)); } } catch (InterruptedException e) { throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (java.net.SocketTimeoutException e) { errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT); errorDesc = e.getMessage(); Logging.connectors.warn("SharePoint: SocketTimeoutException thrown: " + e.getMessage(), e); long currentTime = System.currentTimeMillis(); throw new ServiceInterruption( "SharePoint is down attempting to read '" + fileUrl + "', retrying: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true); } catch (org.apache.http.conn.ConnectTimeoutException e) { errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT); errorDesc = e.getMessage(); Logging.connectors.warn("SharePoint: ConnectTimeoutException thrown: " + e.getMessage(), e); long currentTime = System.currentTimeMillis(); throw new ServiceInterruption( "SharePoint is down attempting to read '" + fileUrl + "', retrying: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true); } catch (InterruptedIOException e) { throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (IllegalArgumentException e) { errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT); errorDesc = e.getMessage(); Logging.connectors.error("SharePoint: Illegal argument: " + e.getMessage(), e); throw new ManifoldCFException("SharePoint: Illegal argument: " + e.getMessage(), e); } catch (org.apache.http.HttpException e) { errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT); errorDesc = e.getMessage(); Logging.connectors.warn("SharePoint: HttpException thrown: " + e.getMessage(), e); long currentTime = System.currentTimeMillis(); throw new ServiceInterruption( "SharePoint is down attempting to read '" + fileUrl + "', retrying: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true); } catch (IOException e) { errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT); errorDesc = e.getMessage(); Logging.connectors.warn("SharePoint: IOException thrown: " + e.getMessage(), e); long currentTime = System.currentTimeMillis(); throw new ServiceInterruption( "SharePoint is down attempting to read '" + fileUrl + "', retrying: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true); } } finally { os.close(); } // Ingest the document long documentLength = tempFile.length(); if (!activities.checkLengthIndexable(documentLength)) { // Document too long errorCode = activities.EXCLUDED_LENGTH; errorDesc = "Document excluded due to length (" + documentLength + ")"; if (Logging.connectors.isDebugEnabled()) Logging.connectors.debug("SharePoint: Document '" + documentIdentifier + "' was too long, according to output connector"); activities.noDocument(documentIdentifier, version); return; } InputStream is = new FileInputStream(tempFile); try { RepositoryDocument data = new RepositoryDocument(); data.setBinary(is, documentLength); data.setFileName(mapToFileName(documentIdentifier)); if (contentType != null) data.setMimeType(contentType); setDataACLs(data, accessTokens, denyTokens); setPathAttribute(data, sDesc, documentIdentifier); if (modifiedDate != null) data.setModifiedDate(modifiedDate); if (createdDate != null) data.setCreatedDate(createdDate); if (metadataValues != null) { Iterator<String> iter = metadataValues.keySet().iterator(); while (iter.hasNext()) { String fieldName = iter.next(); String fieldData = metadataValues.get(fieldName); data.addField(fieldName, fieldData); } } data.addField("GUID", guid); try { activities.ingestDocumentWithException(documentIdentifier, version, fileUrl, data); errorCode = "OK"; fileLengthLong = new Long(documentLength); } catch (IOException e) { handleIOException(e, "reading document"); } return; } finally { try { is.close(); } catch (java.net.SocketTimeoutException e) { // This is not fatal Logging.connectors.debug("SharePoint: Timeout before read could finish for '" + fileUrl + "': " + e.getMessage(), e); } catch (org.apache.http.conn.ConnectTimeoutException e) { // This is not fatal Logging.connectors.debug("SharePoint: Connect timeout before read could finish for '" + fileUrl + "': " + e.getMessage(), e); } catch (InterruptedIOException e) { throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (IOException e) { // This is not fatal Logging.connectors .debug("SharePoint: Server closed connection before read could finish for '" + fileUrl + "': " + e.getMessage(), e); } } } finally { tempFile.delete(); } } catch (java.net.SocketTimeoutException e) { throw new ManifoldCFException( "Socket timeout error writing '" + fileUrl + "' to temporary file: " + e.getMessage(), e); } catch (org.apache.http.conn.ConnectTimeoutException e) { throw new ManifoldCFException( "Connect timeout error writing '" + fileUrl + "' to temporary file: " + e.getMessage(), e); } catch (InterruptedIOException e) { throw new ManifoldCFException("Interrupted: " + e.getMessage(), e, ManifoldCFException.INTERRUPTED); } catch (IOException e) { throw new ManifoldCFException( "IO error writing '" + fileUrl + "' to temporary file: " + e.getMessage(), e); } } catch (ManifoldCFException e) { if (e.getErrorCode() == ManifoldCFException.INTERRUPTED) errorCode = null; throw e; } finally { if (errorCode != null) activities.recordActivity(new Long(startTime), ACTIVITY_FETCH, fileLengthLong, documentIdentifier, errorCode, errorDesc, null); } }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.java
/** * Sets the specified color attribute to the specified value. * @param name the color attribute's name * @param value the color attribute's value *//*from w w w . j av a 2s .com*/ protected void setColorAttribute(final String name, final String value) { String s = value; if (!s.isEmpty()) { final boolean restrict = getBrowserVersion().hasFeature(HTML_COLOR_RESTRICT); boolean isName = false; if (restrict) { for (final String key : COLORS_MAP_IE.keySet()) { if (key.equalsIgnoreCase(value)) { isName = true; break; } } } if (!isName) { if (restrict) { if (s.charAt(0) == '#') { s = s.substring(1); } final StringBuilder builder = new StringBuilder(7); for (int x = 0; x < 6 && x < s.length(); x++) { final char ch = s.charAt(x); if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')) { builder.append(ch); } else { builder.append('0'); } } builder.insert(0, '#'); s = builder.toString(); } } if (getBrowserVersion().hasFeature(HTML_COLOR_TO_LOWER)) { s = s.toLowerCase(Locale.ROOT); } } getDomNodeOrDie().setAttribute(name, s); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.java
/** * Sets the value of the {@code align} property. * @param align the value of the {@code align} property * @param ignoreIfNoError if {@code true}, the invocation will be a no-op if it does not trigger an error * (i.e., it will not actually set the align attribute) *//*from www . j av a 2 s .c o m*/ protected void setAlign(final String align, final boolean ignoreIfNoError) { final String alignLC = align.toLowerCase(Locale.ROOT); final boolean acceptArbitraryValues = getBrowserVersion().hasFeature(JS_ALIGN_ACCEPTS_ARBITRARY_VALUES); if (acceptArbitraryValues || "center".equals(alignLC) || "justify".equals(alignLC) || "left".equals(alignLC) || "right".equals(alignLC)) { if (!ignoreIfNoError) { final String newValue = acceptArbitraryValues ? align : alignLC; getDomNodeOrDie().setAttribute("align", newValue); } return; } throw Context.reportRuntimeError("Cannot set the align property to invalid value: '" + align + "'"); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement.java
/** * Sets the value of the {@code vAlign} property. * @param vAlign the value of the {@code vAlign} property * @param valid the valid values; if {@code null}, any value is valid *///from ww w.j a v a2 s.c om protected void setVAlign(final Object vAlign, final String[] valid) { final String s = Context.toString(vAlign).toLowerCase(Locale.ROOT); if (valid == null || ArrayUtils.contains(valid, s)) { getDomNodeOrDie().setAttribute("valign", s); } else { throw Context.reportRuntimeError("Cannot set the vAlign property to invalid value: " + vAlign); } }
From source file:org.thoughtland.xlocation.ActivityShare.java
public static String getFileName(Context context, boolean multiple, String packageName) { File folder = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + ".xlocation"); folder.mkdir();// w w w . j av a 2s . c om String fileName; if (multiple) { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ROOT); fileName = String.format("%s_XLocation_%s_%s%s.xml", format.format(new Date()), Util.getSelfVersionName(context), Build.DEVICE, (packageName == null ? "" : "_" + packageName)); } else fileName = "XLocation.xml"; return new File(folder + File.separator + fileName).getAbsolutePath(); }
From source file:biz.bokhorst.xprivacy.ActivityShare.java
public static String getFileName(Context context, boolean multiple, String packageName) { File folder = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + ".xprivacy"); folder.mkdir();// ww w. j a va2 s .c om String fileName; if (multiple) { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.ROOT); fileName = String.format("%s_XPrivacy_%s_%s%s.xml", format.format(new Date()), Util.getSelfVersionName(context), Build.DEVICE, (packageName == null ? "" : "_" + packageName)); } else fileName = "XPrivacy.xml"; return new File(folder + File.separator + fileName).getAbsolutePath(); }