List of usage examples for org.apache.commons.lang StringUtils isAllUpperCase
public static boolean isAllUpperCase(String str)
Checks if the String contains only uppercase characters.
From source file:org.apdplat.superword.tools.TextAnalyzer.java
/** * ?//from w ww . jav a 2s . c o m * @param sentence * @return */ public static List<String> seg(String sentence) { List<String> data = new ArrayList<>(); //?? String[] words = sentence.trim().split("[^a-zA-Z0-9]"); StringBuilder log = new StringBuilder(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("??:" + sentence); } for (String word : words) { if (StringUtils.isBlank(word) || word.length() < 2) { continue; } List<String> list = new ArrayList<>(); //?? if (word.length() < 6 //PostgreSQL || (Character.isUpperCase(word.charAt(word.length() - 1)) && Character.isUpperCase(word.charAt(0))) //P2P,Neo4j || PATTERN.matcher(word).find() || StringUtils.isAllUpperCase(word)) { word = word.toLowerCase(); } //??? int last = 0; for (int i = 1; i < word.length(); i++) { if (Character.isUpperCase(word.charAt(i)) && Character.isLowerCase(word.charAt(i - 1))) { list.add(word.substring(last, i)); last = i; } } if (last < word.length()) { list.add(word.substring(last, word.length())); } list.stream().map(w -> w.toLowerCase()).forEach(w -> { if (w.length() < 2) { return; } w = irregularity(w); if (StringUtils.isNotBlank(w)) { data.add(w); if (LOGGER.isDebugEnabled()) { log.append(w).append(" "); } } }); } LOGGER.debug("?" + log); return data; }
From source file:org.dkpro.tc.features.window.CaseExtractor.java
public static String getCasing(String text) { if (StringUtils.isNumeric(text)) return "numeric"; if (StringUtils.isAllLowerCase(text)) return "allLower"; else if (StringUtils.isAllUpperCase(text)) return "allUpper"; else if (Character.isUpperCase(text.charAt(0))) return "initialUpper"; else//from ww w . j ava2 s .com return "other"; }
From source file:org.geoserver.opensearch.eo.store.JDBCOpenSearchAccess.java
private FeatureType buildCollectionFeatureType(DataStore delegate) throws IOException { SimpleFeatureType flatSchema = delegate.getSchema(COLLECTION); TypeBuilder typeBuilder = new TypeBuilder(CommonFactoryFinder.getFeatureTypeFactory(null)); // map the source attributes for (AttributeDescriptor ad : flatSchema.getAttributeDescriptors()) { AttributeTypeBuilder ab = new AttributeTypeBuilder(); String name = ad.getLocalName(); String namespaceURI = this.namespaceURI; if (name.startsWith(EO_PREFIX)) { name = name.substring(EO_PREFIX.length()); char c[] = name.toCharArray(); c[0] = Character.toLowerCase(c[0]); name = new String(c); namespaceURI = EO_NAMESPACE; }// w w w . j a va 2 s .c o m // get a more predictable name structure (will have to do something for oracle // like names too I guess) if (StringUtils.isAllUpperCase(name)) { name = name.toLowerCase(); } // map into output type ab.init(ad); ab.name(name).namespaceURI(namespaceURI).userData(SOURCE_ATTRIBUTE, ad.getLocalName()); AttributeDescriptor mappedDescriptor; if (ad instanceof GeometryDescriptor) { GeometryType at = ab.buildGeometryType(); ab.setCRS(((GeometryDescriptor) ad).getCoordinateReferenceSystem()); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } else { AttributeType at = ab.buildType(); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } typeBuilder.add(mappedDescriptor); } // adding the metadata property AttributeDescriptor metadataDescriptor = buildSimpleDescriptor(METADATA_PROPERTY_NAME, String.class); typeBuilder.add(metadataDescriptor); // map OGC links AttributeDescriptor linksDescriptor = buildFeatureListDescriptor(OGC_LINKS_PROPERTY_NAME, delegate.getSchema("collection_ogclink")); typeBuilder.add(linksDescriptor); typeBuilder.setName(COLLECTION); typeBuilder.setNamespaceURI(namespaceURI); return typeBuilder.feature(); }
From source file:org.geoserver.opensearch.eo.store.JDBCOpenSearchAccess.java
private FeatureType buildProductFeatureType(DataStore delegate) throws IOException { SimpleFeatureType flatSchema = delegate.getSchema(PRODUCT); TypeBuilder typeBuilder = new TypeBuilder(CommonFactoryFinder.getFeatureTypeFactory(null)); // map the source attributes AttributeTypeBuilder ab = new AttributeTypeBuilder(); for (AttributeDescriptor ad : flatSchema.getAttributeDescriptors()) { String name = ad.getLocalName(); String namespaceURI = this.namespaceURI; // hack to avoid changing the whole product attributes prefixes from eo to eop if (name.startsWith(EO_PREFIX)) { name = "eop" + name.substring(2); }//from www. ja va 2 s.c om for (ProductClass pc : ProductClass.values()) { String prefix = pc.getPrefix(); if (name.startsWith(prefix)) { name = name.substring(prefix.length()); char c[] = name.toCharArray(); c[0] = Character.toLowerCase(c[0]); name = new String(c); namespaceURI = pc.getNamespace(); break; } } // get a more predictable name structure (will have to do something for oracle // like names too I guess) if (StringUtils.isAllUpperCase(name)) { name = name.toLowerCase(); } // map into output type ab.init(ad); ab.name(name).namespaceURI(namespaceURI).userData(SOURCE_ATTRIBUTE, ad.getLocalName()); AttributeDescriptor mappedDescriptor; if (ad instanceof GeometryDescriptor) { GeometryType at = ab.buildGeometryType(); ab.setCRS(((GeometryDescriptor) ad).getCoordinateReferenceSystem()); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } else { AttributeType at = ab.buildType(); mappedDescriptor = ab.buildDescriptor(new NameImpl(namespaceURI, name), at); } typeBuilder.add(mappedDescriptor); } // adding the metadata property AttributeDescriptor metadataDescriptor = buildSimpleDescriptor(METADATA_PROPERTY_NAME, String.class); typeBuilder.add(metadataDescriptor); // adding the quicklook property AttributeDescriptor quicklookDescriptor = buildSimpleDescriptor(QUICKLOOK_PROPERTY_NAME, byte[].class); typeBuilder.add(quicklookDescriptor); // map OGC links AttributeDescriptor linksDescriptor = buildFeatureListDescriptor(OGC_LINKS_PROPERTY_NAME, delegate.getSchema("product_ogclink")); typeBuilder.add(linksDescriptor); typeBuilder.setName(PRODUCT); typeBuilder.setNamespaceURI(namespaceURI); return typeBuilder.feature(); }
From source file:org.openlegacy.utils.StringUtil.java
public static String toDisplayName(String text) { if (StringUtils.isAllUpperCase(text)) { text = text.toLowerCase();/*from w w w . j a va 2s. c o m*/ } char[] chars = text.toCharArray(); StringBuilder sb = new StringBuilder(text.length()); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (Character.isLetter(c) || Character.isDigit(c) || c == ' ' || c == '\\' || c == '/' || c == '.') { if (i == 0) { sb.append(Character.toUpperCase(c)); } else { // add blank current char is upper case, previous char is blank and not upper case if (Character.isUpperCase(c) && chars[i - 1] != ' ' && Character.isLetter(chars[i - 1]) && !Character.isUpperCase(chars[i - 1])) { sb.append(' '); } sb.append(c); } } } return StringUtils.strip(sb.toString(), " ."); }
From source file:org.openlegacy.utils.StringUtil.java
public static String toPluralName(String text) { if (StringUtils.isAllUpperCase(text)) { text = text.toLowerCase();/*from ww w . j ava 2 s. c o m*/ } if (StringUtils.isBlank(text)) { return ""; } return StringUtils.capitalize(text) + "s"; }
From source file:org.sonar.core.issue.workflow.State.java
public State(String key, Transition[] outTransitions) { Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "State key must be set"); Preconditions.checkArgument(StringUtils.isAllUpperCase(key), "State key must be upper-case"); checkDuplications(outTransitions, key); this.key = key; this.outTransitions = outTransitions; }
From source file:org.vulpe.commons.util.VulpeStringUtil.java
public static String separateWords(final String value) { final StringBuilder newValue = new StringBuilder(); for (int i = 0; i < value.length(); i++) { if (i > 0 && StringUtils.isAllUpperCase(value.substring(i, i + 1))) { newValue.append(" ").append(value.charAt(i)); } else { newValue.append(value.charAt(i)); }/*www . j av a 2 s . c o m*/ } return newValue.toString(); }
From source file:org.vulpe.commons.util.VulpeStringUtil.java
public static String getAttributeName(final String value) { String attributeName = value; if (StringUtils.isAllUpperCase(value)) { attributeName = value.toLowerCase(); } else {/*from www.j a va 2 s . co m*/ attributeName = lowerCaseFirst(value); } return attributeName; }
From source file:org.xcmis.search.lucene.LuceneQueryBuilder.java
/** * @see org.xcmis.search.QueryObjectModelVisitor#visit(org.xcmis.search.model.operand.UpperCase) *//*from w w w . jav a 2s . c o m*/ public void visit(UpperCase node) throws VisitException { Validate.isTrue(queryBuilderStack.peek() instanceof Boolean, "Stack should contains caseInsensitiveSearch flag"); boolean caseInsensitiveSearch = (Boolean) queryBuilderStack.pop(); final String value = (String) queryBuilderStack.peek(); if (!caseInsensitiveSearch && !StringUtils.isAllUpperCase(value)) { // search nothing because static value in different case queryBuilderStack.push(new BooleanQuery()); } queryBuilderStack.push(new Boolean(true)); // push dynamic query to stack; Visitors.visit(node.getOperand(), this); }