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:com.shenit.commons.utils.ShenStrings.java
/** * ?// w w w.jav a 2 s .c o m * @param val * @return */ public static String str(Object val) { return val == null ? StringUtils.EMPTY : val.toString(); }
From source file:io.github.swagger2markup.spi.MarkupComponent.java
protected String markupDescription(MarkupDocBuilder markupDocBuilder, String markupText) { if (StringUtils.isBlank(markupText)) { return StringUtils.EMPTY; }//from w w w . j a v a 2 s. c o m return copyMarkupDocBuilder(markupDocBuilder) .importMarkup(new StringReader(markupText), config.getSwaggerMarkupLanguage()).toString().trim(); }
From source file:com.mirth.connect.plugins.datatypes.ncpdp.NCPDPReference.java
public String getDescription(String key, String version) { if (StringUtils.equals(version, VERSION_D0)) { return MapUtils.getString(NCPDPD0map, key, StringUtils.EMPTY); } else {/*w ww .ja va 2s .c om*/ return MapUtils.getString(NCPDP51map, key, StringUtils.EMPTY); } }
From source file:ch.cyberduck.core.irods.IRODSUploadFeature.java
@Override public Checksum upload(final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try {/*ww w. ja v a 2 s . c o m*/ final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); final TransferControlBlock block = DefaultTransferControlBlock.instance(StringUtils.EMPTY, preferences.getInteger("connection.retry")); final TransferOptions options = new DefaultTransferOptionsConfigurer().configure(new TransferOptions()); options.setUseParallelTransfer( session.getHost().getTransferType().equals(Host.TransferType.concurrent)); block.setTransferOptions(options); final DataTransferOperations transfer = fs.getIRODSAccessObjectFactory() .getDataTransferOperations(fs.getIRODSAccount()); transfer.putOperation(new File(local.getAbsolute()), f, new DefaultTransferStatusCallbackListener(status, listener, block), block); if (status.isComplete()) { final DataObjectChecksumUtilitiesAO checksum = fs.getIRODSAccessObjectFactory() .getDataObjectChecksumUtilitiesAO(fs.getIRODSAccount()); final ChecksumValue value = checksum.computeChecksumOnDataObject(f); final Checksum fingerprint = Checksum.parse(value.getChecksumStringValue()); if (null == fingerprint) { log.warn(String.format("Unsupported checksum algorithm %s", value.getChecksumEncoding())); } else { if (file.getType().contains(Path.Type.encrypted)) { log.warn(String.format( "Skip checksum verification for %s with client side encryption enabled", file)); } else { final Checksum expected = ChecksumComputeFactory.get(fingerprint.algorithm) .compute(local.getInputStream(), status); if (!expected.equals(fingerprint)) { throw new ChecksumException(MessageFormat.format( LocaleFactory.localizedString("Upload {0} failed", "Error"), file.getName()), MessageFormat.format( "Mismatch between {0} hash {1} of uploaded data and ETag {2} returned by the server", fingerprint.algorithm.toString(), expected, fingerprint.hash)); } } } return fingerprint; } return null; } catch (JargonException e) { throw new IRODSExceptionMappingService().map(e); } }
From source file:com.jaeksoft.searchlib.filter.AuthFilter.java
private Query getQuery(AbstractSearchRequest request) throws ParseException, IOException { if (query != null) return query; AuthManager auth = request.getConfig().getAuthManager(); String user = request.getUser(); if (user == null) user = StringUtils.EMPTY; Collection<String> groups = request.getGroups(); BooleanQuery booleanQuery = new BooleanQuery(true); String field = auth.getUserAllowField(); if (!StringUtils.isEmpty(field)) booleanQuery.add(new TermQuery(new Term(field, user)), Occur.SHOULD); field = auth.getUserDenyField();// w w w.j a v a2 s . c o m if (!StringUtils.isEmpty(field)) booleanQuery.add(new TermQuery(new Term(field, user)), Occur.MUST_NOT); if (groups != null) { field = auth.getGroupAllowField(); if (!StringUtils.isEmpty(field)) for (String group : groups) booleanQuery.add(new TermQuery(new Term(field, group)), Occur.SHOULD); field = auth.getGroupDenyField(); if (!StringUtils.isEmpty(field)) for (String group : groups) booleanQuery.add(new TermQuery(new Term(field, group)), Occur.MUST_NOT); } query = booleanQuery; return query; }
From source file:dwo.gameserver.network.game.serverpackets.packet.ex.ExSendUIEvent.java
@Override protected void writeImpl() { if (isPointUI) { writeD(_player.getObjectId());/*w ww. j a v a 2 s .c om*/ writeD(_isHide); writeD(0x00); writeD(0x00); writeS(String.valueOf(_isIncrease)); writeS(String.valueOf(_points)); writeS(String.valueOf(_endTime)); writeS(StringUtils.EMPTY); writeS(StringUtils.EMPTY); writeD(_npcStringId); } else { writeD(_player.getObjectId()); writeD(_isHide); // 0: show timer, 1: hide timer writeD(0x00); // unknown writeD(0x00); // unknown writeS(String.valueOf(_isIncrease)); // "0": count negative, "1": count positive writeS(String.valueOf(_startTime / 60)); // timer starting minute(s) writeS(String.valueOf(_startTime % 60)); // timer starting second(s) writeS(String.valueOf(_endTime / 60)); // timer length minute(s) (timer will disappear 10 seconds before it ends) writeS(String.valueOf(_endTime % 60)); // timer length second(s) (timer will disappear 10 seconds before it ends) writeD(_npcStringId); if (_npcStringId == -1) { writeS(_text); // text above timer } else if (_parameters != null) { for (String s : _parameters) { writeS(s); } } } }
From source file:ch.cyberduck.core.sftp.SFTPChallengeResponseAuthentication.java
public boolean authenticate(final Host host, final Credentials credentials, final LoginCallback controller) throws BackgroundException { if (StringUtils.isBlank(host.getCredentials().getPassword())) { return false; }//from w w w . j a va 2s .c om if (log.isDebugEnabled()) { log.debug(String.format("Login using challenge response authentication with credentials %s", credentials)); } try { session.getClient().auth(credentials.getUsername(), new AuthKeyboardInteractive(new ChallengeResponseProvider() { /** * Password sent flag */ private final AtomicBoolean password = new AtomicBoolean(); private String name = StringUtils.EMPTY; private String instruction = StringUtils.EMPTY; @Override public List<String> getSubmethods() { return Collections.emptyList(); } @Override public void init(final Resource resource, final String name, final String instruction) { if (StringUtils.isNoneBlank(instruction)) { this.instruction = instruction; } if (StringUtils.isNoneBlank(name)) { this.name = name; } } @Override public char[] getResponse(final String prompt, final boolean echo) { if (log.isDebugEnabled()) { log.debug(String.format("Reply to challenge name %s with instruction %s", name, instruction)); } final String response; // For each prompt, the corresponding echo field indicates whether the user input should // be echoed as characters are typed if (!password.get() // Some servers ask for one-time passcode first && !StringUtils.contains(prompt, "Verification code")) { // In its first callback the server prompts for the password if (log.isDebugEnabled()) { log.debug("First callback returning provided credentials"); } response = credentials.getPassword(); password.set(true); } else { final StringAppender message = new StringAppender().append(instruction) .append(prompt); // Properly handle an instruction field with embedded newlines. They should also // be able to display at least 30 characters for the name and prompts. final Credentials additional = new Credentials(credentials.getUsername()) { @Override public String getPasswordPlaceholder() { return StringUtils.removeEnd(StringUtils.strip(prompt), ":"); } }; try { final StringAppender title = new StringAppender().append(name).append( LocaleFactory.localizedString("Provide additional login credentials", "Credentials")); controller.prompt(host, additional, title.toString(), message.toString(), new LoginOptions().user(false).keychain(false)); } catch (LoginCanceledException e) { return EMPTY_RESPONSE; } response = additional.getPassword(); } // Responses are encoded in ISO-10646 UTF-8. return response.toCharArray(); } @Override public boolean shouldRetry() { return false; } })); } catch (IOException e) { throw new SFTPExceptionMappingService().map(e); } return session.getClient().isAuthenticated(); }
From source file:com.google.gwt.editor.client.impl.AbstractExtendedBaseEditorDriver.java
protected void configureDelegate(final AbstractEditorDelegate<T, E> rootDelegate) { rootDelegate.initialize(StringUtils.EMPTY, this.getEditor()); }
From source file:com.vrem.wifianalyzer.wifi.timegraph.TimeGraphCacheTest.java
private WiFiDetail withWiFiDetail(String SSID) { return new WiFiDetail(SSID, "BSSID", StringUtils.EMPTY, new WiFiSignal(100, 100, WiFiWidth.MHZ_20, 5)); }
From source file:com.msopentech.odatajclient.engine.data.json.DOMTreeUtilsV3.java
/** * Serializes DOM content as JSON.//from w w w .j a va 2s .c o m * * @param client OData client. * @param jgen JSON generator. * @param content content. * @param propType whether to output type information in the way needed for property values or not. * @throws IOException in case of write error. */ 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( 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 { 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()); } 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(); } } } }