private void checkValue(String value) { if(StringUtil.isNotEmpty(value)) { if(value.indexOf((char)0)>=0) { throw new IllegalArgumentException("Value cannot contain '\\0' character"); // $NLS-Preferences.Valuecannotcontaina0character-1$ } } }
public double getDouble(String key) { String s = _properties.get(key); if(StringUtil.isNotEmpty(s)) { try { return Double.parseDouble(s); } catch(NumberFormatException ex) {} } return 0.0; }
public static boolean isContainedWithin(String s, String[] container) { if(isNotEmpty(s) && isNotEmpty(container)) { for(int i = 0; i < container.length; i++) { if(equals(s, container[i])) { return true; } } } return false; }
public int getInteger(String key) { String s = _properties.get(key); if(StringUtil.isNotEmpty(s)) { try { return Integer.parseInt(s); } catch(NumberFormatException ex) {} } return 0; }
public long getLong(String key) { String s = _properties.get(key); if(StringUtil.isNotEmpty(s)) { try { return Long.parseLong(s); } catch(NumberFormatException ex) {} } return 0; }
private String extractInviteeUuid(String uid, String communityUuid) { if (StringUtil.isNotEmpty(uid) && uid.indexOf(communityUuid) == 0) { return uid.substring(communityUuid.length()+1); } else{ return uid; } } }
private String extractInviteUuid(String uid) { if (StringUtil.isNotEmpty(uid) && StringUtil.startsWithIgnoreCase(uid, "urn:lsid:ibm.com:communities:invite-")) { return uid.substring("urn:lsid:ibm.com:communities:invite-".length()); } else { return uid; } }
private static int countMatch(String source, char match) { int count=0; if(StringUtil.isNotEmpty(source)) { for(int i=0; i<source.length(); i++) { if(StringUtil.equals(source.charAt(i), match)) { count++; } } } return count; }
/** * Returns the activity node ID. * * @return {String} activityNodeUuid */ public String getActivityNodeUuid() { String id = getId(); if (StringUtil.isNotEmpty(id) && id.startsWith(UUID_PREFIX)) { id = id.substring(UUID_PREFIX.length()); } return id; }
protected void outValue(String name, String value) { if(StringUtil.isNotEmpty(value)) { out("{0}: {1}",name, value); } } }
/** * @return the Connection Id */ public String getConnectionId() { String id = getId(); if(StringUtil.isNotEmpty(id)){ if(StringUtil.startsWithIgnoreCase(id, CONNECTIONID)){ id = id.substring(CONNECTIONID.length()); } } return id; }
public void putString(String key, String value) { checkKey(key); checkValue(value); if(StringUtil.isNotEmpty(value)) { _properties.put(key, value); } else { _properties.remove(key); } }
protected void setEntity(HttpClient httpClient, HttpRequestBase httpRequestBase, Args args, HttpEntity entity) throws ClientServicesException { String contentType = getContentType(); if (StringUtil.isNotEmpty(contentType)) { httpRequestBase.setHeader(CONTENT_TYPE, contentType); } ((HttpEntityEnclosingRequestBase) httpRequestBase).setEntity(entity); }
@Override public void initialize(DefaultHttpClient httpClient) throws ClientServicesException { String usr = getUserIdentity(); if(StringUtil.isNotEmpty(usr)) { String pwd = getPassword(); UsernamePasswordCredentials creds = new UsernamePasswordCredentials(usr,pwd); HttpRequestInterceptor basicInterceptor = new BasicInterceptor(creds); httpClient.addRequestInterceptor(basicInterceptor, 0); } }
public void outReference(JsonReference ref) throws IOException, JsonException { String s = ref.getRef(); if(StringUtil.isNotEmpty(s)) { out(s); } else { out("null"); // $NON-NLS-1$ } }
public Preferences getPreferences(String key) { Preferences p = new Preferences(); String s = getString(key); if(StringUtil.isNotEmpty(s)) { p.readFromString(s); } return p; }
@Override public void initialize(DefaultHttpClient httpClient) throws ClientServicesException { String usr = getUserIdentity(); if(StringUtil.isNotEmpty(usr)) { String pwd = getPassword(); UsernamePasswordCredentials creds = new UsernamePasswordCredentials(usr,pwd); HttpRequestInterceptor basicInterceptor = new BasicInterceptor(creds); httpClient.addRequestInterceptor(basicInterceptor, 0); } }
@Override public void initialize(DefaultHttpClient httpClient)throws ClientServicesException { if (StringUtil.isNotEmpty(getCookieCache())) { HttpRequestInterceptor basicInterceptor = new CookieInterceptor(getCookieCache()); httpClient.addRequestInterceptor(basicInterceptor, 0); } }
protected boolean isV5OrHigher() { Endpoint endpoint = getEndpoint(); String apiVersion = endpoint.getApiVersion(); if (StringUtil.isNotEmpty(apiVersion)) { Version version = Version.parse(apiVersion); return (version.getMajor() >= 5); } return false; }
protected Element inReplyTo() { String inReplyTo = entity.getInReplyTo(); return StringUtil.isNotEmpty(inReplyTo) ? element(Namespace.THR.getUrl(), IN_REPLY_TO, attribute(REF, inReplyTo), attribute(HREF, inReplyTo), attribute(TYPE, APPLICATION_ATOM_XML), attribute(SOURCE, entity.getActivityUuid())) : null; }