List of usage examples for org.apache.commons.lang3 StringUtils EMPTY
String EMPTY
To view the source code for org.apache.commons.lang3 StringUtils EMPTY.
Click Source Link
From source file:de.blizzy.documentr.util.Util.java
/** Deletes a file ignoring exceptions. If <code>f</code> is a directory, it is deleted recursively. */ public static void deleteQuietly(File f) { if ((f != null) && f.exists()) { try {//from ww w . j a v a2 s .c o m FileUtils.forceDelete(f); } catch (IOException e) { log.warn(StringUtils.EMPTY, e); } } }
From source file:ch.cyberduck.core.openstack.SwiftObjectListService.java
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try {/*from www. j a v a 2 s .co m*/ final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; List<StorageObject> list; do { final Path container = containerService.getContainer(directory); list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER); for (StorageObject object : list) { final PathAttributes attributes = new PathAttributes(); attributes.setOwner(container.attributes().getOwner()); attributes.setRegion(container.attributes().getRegion()); if (StringUtils.isNotBlank(object.getMd5sum())) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.parse(object.getMd5sum())); } attributes.setSize(object.getSize()); final String lastModified = object.getLastModified(); if (lastModified != null) { try { attributes.setModificationDate(dateParser.parse(lastModified).getTime()); } catch (InvalidDateException e) { log.warn(String.format("%s is not ISO 8601 format %s", lastModified, e.getMessage())); } } final EnumSet<AbstractPath.Type> types = "application/directory".equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if (StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if (children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attributes))) { // There is already a real placeholder file with application/directory MIME type. Only // add virtual directory if the placeholder object is missing continue; } } children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attributes)); marker = object.getName(); } listener.chunk(directory, children); } while (list.size() == limit); return children; } catch (GenericException e) { throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch (IOException e) { throw new DefaultIOExceptionMappingService().map(e, directory); } }
From source file:com.stefanbrenner.droplet.ui.ActionPanel.java
/** * Create the panel./*w w w . java2s. com*/ */ public ActionPanel(final IActionDevice device, final T action) { setDevice(device); setAction(action); setLayout(new GridBagLayout()); setBackground(DropletColors.getBackgroundColor(getDevice())); GridBagConstraints gbc = UiUtils.createGridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(2, 2, 2, 2); BeanAdapter<IAction> adapter = new BeanAdapter<IAction>(action, true); // enabled checkbox cbEnable = BasicComponentFactory.createCheckBox(adapter.getValueModel(IAction.PROPERTY_ENABLED), StringUtils.EMPTY); cbEnable.setToolTipText(Messages.getString("ActionPanel.enableAction.tooltip")); //$NON-NLS-1$ cbEnable.setFocusable(false); UiUtils.editGridBagConstraints(gbc, 0, 0, 0, 0); add(cbEnable, gbc); // offset spinner spOffset = new MouseWheelSpinner(true); spOffset.setToolTipText(Messages.getString("ActionPanel.Offset.Tooltip")); //$NON-NLS-1$ spOffset.setModel(SpinnerAdapterFactory.createNumberAdapter(adapter.getValueModel(IAction.PROPERTY_OFFSET), 0, 0, ActionPanel.MAX_TIME_INPUT, 1)); ((JSpinner.DefaultEditor) spOffset.getEditor()).getTextField().setColumns(4); UiUtils.editGridBagConstraints(gbc, 1, 0, 0, 0); add(spOffset, gbc); // duration spinner spDuration = new MouseWheelSpinner(true); spDuration.setToolTipText(Messages.getString("ActionPanel.Duration.Tooltip")); //$NON-NLS-1$ if (action instanceof IDurationAction) { spDuration.setModel(SpinnerAdapterFactory.createNumberAdapter( adapter.getValueModel(IDurationAction.PROPERTY_DURATION), 0, 0, ActionPanel.MAX_TIME_INPUT, 1)); ((JSpinner.DefaultEditor) spDuration.getEditor()).getTextField().setColumns(4); UiUtils.editGridBagConstraints(gbc, 2, 0, 0, 0); add(spDuration, gbc); } // remove button btnRemove = new JButton(Messages.getString("ActionPanel.removeAction")); //$NON-NLS-1$ btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { remove(); } }); btnRemove.setToolTipText(Messages.getString("ActionPanel.removeAction.tooltip")); //$NON-NLS-1$ btnRemove.setFocusable(false); UiUtils.editGridBagConstraints(gbc, 3, 0, 0, 0); add(btnRemove, gbc); }
From source file:com.shenit.commons.utils.CollectionUtils.java
/** * /*ww w . ja v a 2s . c o m*/ * @param targets * @param string * @return */ public static <T> String join(T[] targets, String delimiter) { if (ValidationUtils.isEmpty(targets)) return StringUtils.EMPTY; StringBuilder builder = new StringBuilder(); for (T target : targets) { builder.append(target).append(delimiter); } //? if (builder.indexOf(delimiter) > 0) builder.deleteCharAt(builder.lastIndexOf(delimiter)); return builder.toString(); }
From source file:ch.cyberduck.core.irods.IRODSCopyFeature.java
@Override public Path copy(final Path source, final Path target, final ch.cyberduck.core.transfer.TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try {//from w w w .j av a 2 s . c o m final IRODSFileSystemAO fs = session.getClient(); final DataTransferOperations transfer = fs.getIRODSAccessObjectFactory() .getDataTransferOperations(fs.getIRODSAccount()); transfer.copy(fs.getIRODSFileFactory().instanceIRODSFile(source.getAbsolute()), fs.getIRODSFileFactory().instanceIRODSFile(target.getAbsolute()), new TransferStatusCallbackListener() { @Override public FileStatusCallbackResponse statusCallback(final TransferStatus transferStatus) throws JargonException { return FileStatusCallbackResponse.CONTINUE; } @Override public void overallStatusCallback(final TransferStatus transferStatus) throws JargonException { // } @Override public CallbackResponse transferAsksWhetherToForceOperation(final String irodsAbsolutePath, final boolean isCollection) { return CallbackResponse.YES_THIS_FILE; } }, DefaultTransferControlBlock.instance(StringUtils.EMPTY, PreferencesFactory.get().getInteger("connection.retry"))); return target; } catch (JargonException e) { throw new IRODSExceptionMappingService().map("Cannot copy {0}", e, source); } }
From source file:com.smartling.api.sdk.file.commandline.RetrieveFile.java
private static String getTranslatedFilePath(File file, String localeString, String pathToStoreFile) { StringBuilder stringBuilder = new StringBuilder(pathToStoreFile); String locale = StringUtils.isNotBlank(localeString) ? localeString.replace(LOCALE_SEPERATOR, LOCALE_FILENAME_SEPERATOR) : StringUtils.EMPTY; stringBuilder.append(// w w w . j a v a 2s . com file.getName().replace(PROPERTY_FILE_EXT, LOCALE_FILENAME_SEPERATOR + locale + PROPERTY_FILE_EXT)); return stringBuilder.toString(); }
From source file:eu.europa.ec.fisheries.uvms.rules.service.mapper.xpath.util.XPathStringWrapper.java
/** * Return the string value appended so far and clears the buffer. * * @return//w w w . j a v a 2 s . c om */ public String getValue() { if (strBuff.length() == 0) { return StringUtils.EMPTY; } String resultingString = strBuff.toString(); clear(); return resultingString; }
From source file:com.qwazr.utils.cassandra.CassandraSession.java
private Session checkSession() { rwl.r.lock();/*from w w w. j av a 2s .c om*/ try { lastUse = System.currentTimeMillis(); if (session != null && !session.isClosed()) return session; } finally { rwl.r.unlock(); } rwl.w.lock(); try { if (session != null && !session.isClosed()) return session; if (cluster == null || cluster.isClosed()) throw new DriverException("The cluster is closed"); if (logger.isDebugEnabled()) logger.debug("Create session " + keySpace == null ? StringUtils.EMPTY : keySpace); session = keySpace == null ? cluster.connect() : cluster.connect(keySpace); return session; } finally { rwl.w.unlock(); } }
From source file:de.micromata.genome.logging.spi.ifiles.IndexFileLoggingImpl.java
@Override public String formatLogId(Object logId) { return Objects.toString(logId, StringUtils.EMPTY); }
From source file:com.msopentech.odatajclient.engine.data.json.DOMTreeUtilsV4.java
public static void writeSubtree(final ODataClient client, final JsonGenerator jgen, final Node content, final boolean propType) throws IOException { for (Node child : XMLUtils.getChildNodes(content, Node.ELEMENT_NODE)) { final String childName = XMLUtils.getSimpleName(child); final Node typeAttr = child.getAttributes().getNamedItem(ODataConstants.ATTR_M_TYPE); if (typeAttr != null && EdmSimpleType.isGeospatial(typeAttr.getTextContent())) { jgen.writeStringField(/* ww w .j av a 2 s. c o m*/ propType ? ODataConstants.JSON_TYPE : childName + "@" + ODataConstants.JSON_TYPE, typeAttr.getTextContent()); jgen.writeObjectFieldStart(childName); GeospatialJSONHandler.serialize(jgen, (Element) child, typeAttr.getTextContent()); jgen.writeEndObject(); } else if (XMLUtils.hasOnlyTextChildNodes(child)) { if (child.hasChildNodes()) { final String out; if (typeAttr == null) { out = child.getChildNodes().item(0).getNodeValue(); } else { if (typeAttr.getTextContent().startsWith("Edm.")) { final EdmSimpleType type = EdmSimpleType.fromValue(typeAttr.getTextContent()); final ODataPrimitiveValue value = client.getPrimitiveValueBuilder().setType(type) .setText(child.getChildNodes().item(0).getNodeValue()).build(); out = value.toString(); jgen.writeStringField(childName + "@" + ODataConstants.JSON_TYPE, type.toString()); } else { // enum out = child.getTextContent(); jgen.writeStringField(childName + "@" + ODataConstants.JSON_TYPE, typeAttr.getTextContent()); } } jgen.writeStringField(childName, out); } else { if (child.getAttributes().getNamedItem(ODataConstants.ATTR_NULL) == null) { if (typeAttr != null && EdmSimpleType.String.toString().equals(typeAttr.getTextContent())) { jgen.writeStringField(childName + "@" + ODataConstants.JSON_TYPE, typeAttr.getTextContent()); jgen.writeStringField(childName, StringUtils.EMPTY); } else { jgen.writeArrayFieldStart(childName); jgen.writeEndArray(); } } else { jgen.writeNullField(childName); } } } else { if (XMLUtils.hasElementsChildNode(child)) { jgen.writeArrayFieldStart(childName); for (Node nephew : XMLUtils.getChildNodes(child, Node.ELEMENT_NODE)) { if (XMLUtils.hasOnlyTextChildNodes(nephew)) { jgen.writeString(nephew.getChildNodes().item(0).getNodeValue()); } else { jgen.writeStartObject(); DOMTreeUtils.writeSubtree(client, jgen, nephew); jgen.writeEndObject(); } } jgen.writeEndArray(); } else { jgen.writeObjectFieldStart(childName); if (typeAttr != null) { jgen.writeStringField("@" + ODataConstants.JSON_TYPE, typeAttr.getTextContent()); } DOMTreeUtils.writeSubtree(client, jgen, child); jgen.writeEndObject(); } } } }