List of usage examples for org.apache.commons.lang StringUtils isAlphaSpace
public static boolean isAlphaSpace(String str)
Checks if the String contains only unicode letters and space (' ').
From source file:eu.annocultor.analyzers.SolrPropertyHitsAnalyzer.java
static boolean isLongEnoughToCount(String word) { return StringUtils.length(word) > 3 && StringUtils.isAlphaSpace(word); }
From source file:net.bible.service.format.osistohtml.ReferenceHandler.java
/** create a link tag from an OSISref and the content of the tag *//*from w w w . j av a 2 s . co m*/ private String getReferenceTag(String reference, String content) { log.debug("Ref:" + reference + " Content:" + content); StringBuilder result = new StringBuilder(); try { //JSword does not know the basis (default book) so prepend it if it looks like JSword failed to work it out //We only need to worry about the first ref because JSword uses the first ref as the basis for the subsequent refs // if content starts with a number and is not followed directly by an alpha char e.g. 1Sa if (reference == null && content != null && content.length() > 0 && StringUtils.isNumeric(content.subSequence(0, 1)) && (content.length() < 2 || !StringUtils.isAlphaSpace(content.subSequence(1, 2)))) { // maybe should use VerseRangeFactory.fromstring(orig, basis) // this check for a colon to see if the first ref is verse:chap is not perfect but it will do until JSword adds a fix int firstColonPos = content.indexOf(":"); boolean isVerseAndChapter = firstColonPos > 0 && firstColonPos < 4; if (isVerseAndChapter) { reference = parameters.getBasisRef().getBook().getOSIS() + " " + content; } else { reference = parameters.getBasisRef().getBook().getOSIS() + " " + parameters.getBasisRef().getChapter() + ":" + content; } log.debug("Patched reference:" + reference); } else if (reference == null) { reference = content; } // convert urns of type book:key to sword://book/key to simplify urn parsing (1 fewer case to check for). // Avoid urls of type 'matt 3:14' by excludng urns with a space if (reference.contains(":") && !reference.contains(" ") && !reference.startsWith("sword://")) { reference = "sword://" + reference.replace(":", "/"); } boolean isFullSwordUrn = reference.contains("/") && reference.contains(":"); if (isFullSwordUrn) { // e.g. sword://StrongsRealGreek/01909 // don't play with the reference - just assume it is correct result.append("<a href='").append(reference).append("'>"); result.append(content); result.append("</a>"); } else { Passage ref = (Passage) PassageKeyFactory.instance().getKey(parameters.getDocumentVersification(), reference); boolean isSingleVerse = ref.countVerses() == 1; boolean isSimpleContent = content.length() < 3 && content.length() > 0; Iterator<VerseRange> it = ref.rangeIterator(RestrictionType.CHAPTER); if (isSingleVerse && isSimpleContent) { // simple verse no e.g. 1 or 2 preceding the actual verse in TSK result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":") .append(it.next().getOsisRef()).append("'>"); result.append(content); result.append("</a>"); } else { // multiple complex references boolean isFirst = true; while (it.hasNext()) { Key key = it.next(); if (!isFirst) { result.append(" "); } result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":") .append(key.iterator().next().getOsisRef()).append("'>"); result.append(key); result.append("</a>"); isFirst = false; } } } } catch (Exception e) { log.error("Error parsing OSIS reference:" + reference); // just return the content with no html markup result.append(content); } return result.toString(); }
From source file:net.bible.service.format.osistohtml.taghandler.ReferenceHandler.java
/** create a link tag from an OSISref and the content of the tag *//*from w ww. jav a2 s . c om*/ private String getReferenceTag(String reference, String content) { log.debug("Ref:" + reference + " Content:" + content); StringBuilder result = new StringBuilder(); try { //JSword does not know the basis (default book) so prepend it if it looks like JSword failed to work it out //We only need to worry about the first ref because JSword uses the first ref as the basis for the subsequent refs // if content starts with a number and is not followed directly by an alpha char e.g. 1Sa if (reference == null && content != null && content.length() > 0 && StringUtils.isNumeric(content.subSequence(0, 1)) && (content.length() < 2 || !StringUtils.isAlphaSpace(content.subSequence(1, 2)))) { // maybe should use VerseRangeFactory.fromstring(orig, basis) // this check for a colon to see if the first ref is verse:chap is not perfect but it will do until JSword adds a fix int firstColonPos = content.indexOf(":"); boolean isVerseAndChapter = firstColonPos > 0 && firstColonPos < 4; if (isVerseAndChapter) { reference = parameters.getBasisRef().getBook().getOSIS() + " " + content; } else { reference = parameters.getBasisRef().getBook().getOSIS() + " " + parameters.getBasisRef().getChapter() + ":" + content; } log.debug("Patched reference:" + reference); } else if (reference == null) { reference = content; } // convert urns of type book:key to sword://book/key to simplify urn parsing (1 fewer case to check for). // Avoid urls of type 'matt 3:14' by excludng urns with a space if (reference.contains(":") && !reference.contains(" ") && !reference.startsWith("sword://")) { reference = "sword://" + reference.replace(":", "/"); } boolean isFullSwordUrn = reference.contains("/") && reference.contains(":"); if (isFullSwordUrn) { // e.g. sword://StrongsRealGreek/01909 // don't play with the reference - just assume it is correct result.append("<a href='").append(reference).append("'>"); result.append(content); result.append("</a>"); } else { Passage ref = (Passage) PassageKeyFactory.instance().getKey(parameters.getDocumentVersification(), reference); boolean isSingleVerse = ref.countVerses() == 1; boolean isSimpleContent = content.length() < 3 && content.length() > 0; Iterator<VerseRange> it = ref.rangeIterator(RestrictionType.CHAPTER); if (isSingleVerse && isSimpleContent) { // simple verse no e.g. 1 or 2 preceding the actual verse in TSK result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":") .append(it.next().getOsisRef()).append("'>"); result.append(content); result.append("</a>"); } else { // multiple complex references boolean isFirst = true; while (it.hasNext()) { Key key = it.next(); if (!isFirst) { result.append(" "); } // we just references the first verse in each range because that is the verse you would jump to. It might be more correct to reference the while range i.e. key.getOsisRef() result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":") .append(key.iterator().next().getOsisRef()).append("'>"); result.append(key); result.append("</a>"); isFirst = false; } } } } catch (Exception e) { log.error("Error parsing OSIS reference:" + reference); // just return the content with no html markup result.append(content); } return result.toString(); }
From source file:net.bible.service.format.osistohtml.NoteAndReferenceHandler.java
/** create a link tag from an OSISref and the content of the tag *///from www . ja v a 2 s . c o m private String getReferenceTag(String reference, String content) { StringBuilder result = new StringBuilder(); try { //JSword does not know the basis (default book) so prepend it if it looks like JSword failed to work it out //We only need to worry about the first ref because JSword uses the first ref as the basis for the subsequent refs // if content starts with a number and is not followed directly by an alpha char e.g. 1Sa if (reference == null && content != null && content.length() > 0 && StringUtils.isNumeric(content.subSequence(0, 1)) && (content.length() < 2 || !StringUtils.isAlphaSpace(content.subSequence(1, 2)))) { // maybe should use VerseRangeFactory.fromstring(orig, basis) // this check for a colon to see if the first ref is verse:chap is not perfect but it will do until JSword adds a fix int firstColonPos = content.indexOf(":"); boolean isVerseAndChapter = firstColonPos > 0 && firstColonPos < 4; if (isVerseAndChapter) { reference = parameters.getBasisRef().getBook().getOSIS() + " " + content; } else { reference = parameters.getBasisRef().getBook().getOSIS() + " " + parameters.getBasisRef().getChapter() + ":" + content; } log.debug("Patched reference:" + reference); } else if (reference == null) { reference = content; } Passage ref = (Passage) PassageKeyFactory.instance().getKey(reference); boolean isSingleVerse = ref.countVerses() == 1; boolean isSimpleContent = content.length() < 3 && content.length() > 0; Iterator<Key> it = ref.rangeIterator(RestrictionType.CHAPTER); if (isSingleVerse && isSimpleContent) { // simple verse no e.g. 1 or 2 preceding the actual verse in TSK result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":") .append(it.next().getOsisRef()).append("'>"); result.append(content); result.append("</a>"); } else { // multiple complex references boolean isFirst = true; while (it.hasNext()) { Key key = it.next(); if (!isFirst) { result.append(" "); } result.append("<a href='").append(Constants.BIBLE_PROTOCOL).append(":") .append(key.iterator().next().getOsisRef()).append("'>"); result.append(key); result.append("</a> "); isFirst = false; } } } catch (Exception e) { log.error("Error parsing OSIS reference:" + reference, e); // just return the content with no html markup result.append(content); } return result.toString(); }
From source file:org.fenixedu.idcards.domain.SantanderBatch.java
private String purgeString(final String name) { if (!StringUtils.isAlphaSpace(name)) { final char[] ca = new char[name.length()]; int j = 0; for (int i = 0; i < name.length(); i++) { final char c = name.charAt(i); if (Character.isLetter(c) || c == ' ') { ca[j++] = c;//from w w w . ja v a 2 s. co m } } return new String(ca); } return name; }