List of usage examples for org.apache.commons.lang3 StringUtils isWhitespace
public static boolean isWhitespace(final CharSequence cs)
Checks if the CharSequence contains only whitespace.
null will return false .
From source file:de.decoit.simu.cbor.ifmap.metadata.multivalue.CBORRequestForInvestigation.java
/** * Set a qualifier for this request-for-investigation metadata. * * @param qualifier name value, may be null *///from w ww . j av a 2 s . c om public void setQualifier(String qualifier) { if (StringUtils.isWhitespace(qualifier)) { throw new IllegalArgumentException("Qualifier must not be empty or whitespace only"); } this.qualifier = qualifier; }
From source file:de.decoit.simu.cbor.ifmap.simu.identifier.CBORImplementation.java
/** * Set the platform string for this identifier. * The platform may be null to remove this attribute from the identifier. * If not null, the platform MUST NOT be empty or whitespace only. * * @param platform Platform string/*from w w w .j av a 2 s . co m*/ */ public void setPlatform(String platform) { if (StringUtils.isWhitespace(platform)) { throw new IllegalArgumentException("Platform must not be empty or whitespace only"); } if (platform != null) { DataItem platformDi = new UnicodeString(platform); this.attributes.put(PLATFORM, platformDi); } else { this.attributes.remove(PLATFORM); } }
From source file:de.decoit.simu.cbor.ifmap.attributegroup.SearchTypeAttributeGroup.java
/** * Set a result filter for this search./*from ww w.j a v a 2s . co m*/ * The string may be null to remove this attribute from the search. If not null, * the filter string MUST NOT be empty or whitespace only. * * @param resultFilter Filter string */ public void setResultFilter(String resultFilter) { if (StringUtils.isWhitespace(resultFilter)) { throw new IllegalArgumentException("Result filter must not be empty or whitespace only"); } this.resultFilter = resultFilter; }
From source file:de.decoit.simu.cbor.ifmap.metadata.multivalue.CBORCapability.java
/** * Set the administrative-domain for this metadata. * The administrative-domain may be null to remove this value from the metadata. If not null, * the administrative-domain MUST NOT be an empty string or whitespace only. * * @param administrativeDomain administrative-domain for this metadata *///w w w .j a va 2 s .co m public void setAdministrativeDomain(String administrativeDomain) { if (StringUtils.isWhitespace(administrativeDomain)) { throw new IllegalArgumentException("administrative-domain must not be empty or whitespace only"); } this.administrativeDomain = administrativeDomain; }
From source file:de.decoit.simu.cbor.ifmap.identifier.CBORIdentity.java
/** * Set an administrative-domain for this identity identifier. * The administrative-domain may be null to remove this value from the metadata. If not null, * the administrative-domain MUST NOT be an empty string or whitespace only. * * @param administrativeDomain administrative-domain value, may be null *///w ww . j a va 2s . c om public void setAdministrativeDomain(String administrativeDomain) { if (StringUtils.isWhitespace(administrativeDomain)) { throw new IllegalArgumentException("Administrative domain must not be empty or whitespace only"); } this.administrativeDomain = administrativeDomain; }
From source file:de.decoit.simu.cbor.ifmap.attributegroup.SearchTypeAttributeGroup.java
/** * Add the identifier type which terminates the search. * The string may be null to remove this attribute from the search. If not null, * the identifier type MUST NOT be empty or whitespace only. * * @param terminalIdentifierType/*w w w . j a v a 2s .co m*/ */ public void setTerminalIdentifierType(String terminalIdentifierType) { if (StringUtils.isWhitespace(terminalIdentifierType)) { throw new IllegalArgumentException("Terminal identifier type must not be empty or whitespace only"); } this.terminalIdentifierType = terminalIdentifierType; }
From source file:de.decoit.simu.cbor.ifmap.identifier.extended.AbstractComplexType.java
/** * Set the value that is contained by this element. * This will clear any simple or complex element added to this element. * //from w ww . ja v a2s.c o m * @param value Value to set */ public void setValue(String value) { if (StringUtils.isWhitespace(value)) { throw new IllegalArgumentException("Value string must not be empty or whitespace only"); } if (value == null) { setValue((DataItem) null); } else { setValue(new UnicodeString(value)); } }
From source file:com.adguard.android.db.DbHelper.java
private void executeSql(SQLiteDatabase db, String script) { for (String sql : StringUtils.split(script, ";")) { if (!StringUtils.isWhitespace(sql)) { LOG.info("Execute sql: {}", sql); db.execSQL(sql);//from w w w . j a v a 2s .c o m } } }
From source file:com.bellman.bible.service.format.OSISInputStream.java
/** load the next verse, or opening or closing <div> into the verse buffer * //w w w. j a va 2 s. c o m * @throws UnsupportedEncodingException */ private void loadNextVerse() throws UnsupportedEncodingException { try { if (isFirstVerse) { putInVerseBuffer(DOC_START); isFirstVerse = false; return; } boolean isNextVerseLoaded = false; while (keyIterator.hasNext() && !isNextVerseLoaded) { Key currentVerse = keyIterator.next(); //get the actual verse text and tidy it up, String rawText = book.getRawText(currentVerse); // do not output empty verses (commonly verse 0 is empty) if (!StringUtils.isWhitespace(rawText)) { // merged verses can cause duplicates so if dup then skip immediately to next verse if (!previousVerseRawText.equals(rawText)) { String tidyText = osisVerseTidy.tidy(currentVerse, rawText); putInVerseBuffer(tidyText); previousVerseRawText = rawText; isNextVerseLoaded = true; return; } else { log.debug("Duplicate verse:" + currentVerse); } } else { log.debug("Empty or missing verse:" + currentVerse); } } if (!isClosingTagWritten) { putInVerseBuffer(DOC_END); isClosingTagWritten = true; } } catch (UnsupportedEncodingException usc) { usc.printStackTrace(); } catch (BookException be) { be.printStackTrace(); } }
From source file:jp.mathes.databaseWiki.dav.TableResource.java
@Override @SuppressWarnings("unchecked") public Resource createNew(String newName, InputStream inputStream, Long length, String contentType) throws IOException, ConflictException, NotAuthorizedException, BadRequestException { try {/*from ww w . j av a 2s. c om*/ Document doc = DbwConfiguration.getInstance().getBackend().getDocument(this.user, this.password, this.dbName, this.name, name, true); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String line = reader.readLine(); while (line != null) { if (StringUtils.isEmpty(line) || StringUtils.isWhitespace(line)) { // everything after this line is field content StringBuffer content = new StringBuffer(); while ((line = reader.readLine()) != null) { if (content.length() > 0) { content.append("\n"); } content.append(line); } if (doc.getAllFields().containsKey("content")) { doc.getAllFields().get("content").setValue(content.toString()); } else { DbwConfiguration.getInstance().davLog("Parse error, could not set field 'content'."); throw new BadRequestException(this, "Parse error, could not set field 'content'."); } } else if (line.startsWith("\t")) { // if the line starts with a tab it has to be the continuation of // another line (which is handled in the else path) or is a mistake DbwConfiguration.getInstance() .davLog("Line starts with tab although it is not a continuation."); throw new BadRequestException(this, "Line starts with tab although it is not a continuation."); } else { // this is a regular field, potentially with continuation String[] split = StringUtils.split(line, ":", 2); String fieldName = split[0].trim(); StringBuffer fieldValue = new StringBuffer(split[1].trim()); String nextLine = reader.readLine(); while (nextLine != null && nextLine.startsWith("\t")) { fieldValue.append("\n").append(StringUtils.substring(nextLine, 1)); } line = nextLine; if (doc.getAllFields().containsKey(fieldName)) { doc.getAllFields().get(fieldName).setValue(fieldValue.toString()); } else { DbwConfiguration.getInstance() .davLog(String.format("Parse error, could not set field '%s'.", fieldName)); throw new BadRequestException(this, String.format("Parse error, could not set field '%s'.", fieldName)); } } } DbwConfiguration.getInstance().getBackend().saveDocument(this.user, this.password, this.dbName, this.name, name, doc); } catch (DocumentNotFoundException e) { DbwConfiguration.getInstance().davLog("Impossible DocumentNotFoundException in createNew()", e); throw new BadRequestException(this, "This cannot happen with allowEmpty=true (getDocument)."); } catch (BackendException e) { DbwConfiguration.getInstance().davLog("BackendException in createNew()", e); throw new BadRequestException(this, e.getMessage()); } return null; }