List of usage examples for org.apache.commons.lang WordUtils capitalize
public static String capitalize(String str)
Capitalizes all the whitespace separated words in a String.
From source file:eu.carrade.amaury.MinecraftChatModerator.managers.core.ConfigurationBasedManager.java
/** * Loads the classes registered by {@link #loadAfterFollowingConfig(Class)}, if enabled in the * configuration file.//from ww w . j a va 2 s . co m * * <p> * Here, the suffix (see {@link #load(ConfigurationSection, String)}) is the capitalized name of * the configuration section without the last character (usually the s? of the plural form, * that's why). * </p> * * @param config The configuration section containing the whole config for this kind of managed * things. * * @see {@link #load(ConfigurationSection, String)} for detailed informations about the configuration * format. */ protected void load(ConfigurationSection config) { final String suffix = WordUtils.capitalize(config.getName()); load(config, suffix.substring(0, suffix.length() - 1)); }
From source file:adalid.core.Instance.java
private void finaliseInstanceMissingFields() { Entity declaringEntity = getDeclaringEntity(); if (declaringEntity instanceof PersistentEntity) { if (depth() == 0 && round() == 0) { Class<?> dataType; boolean keyField; Integer number;// w w w .jav a2s . c om String string; Date date; Time time; Timestamp timestamp; PersistentEntity pent = (PersistentEntity) declaringEntity; String name = WordUtils.capitalize(StrUtils.getWordyString(getName())); String code = pent instanceof PersistentEnumerationEntity ? name : getName(); Date currentDate = TimeUtils.currentDate(); Time currentTime = TimeUtils.currentTime(); Timestamp currentTimestamp = TimeUtils.currentTimestamp(); List<Property> columnsList = pent.getColumnsList(); for (Property property : columnsList) { if (property.isNullable() || property.getDefaultValue() != null || propertyAlreadyAdded(property)) { continue; } dataType = property.getDataType(); keyField = property.isKeyField(); if (Boolean.class.isAssignableFrom(dataType)) { InstanceField instanceField = new InstanceField(property, false); _instanceFieldsList.add(instanceField); } else if (Number.class.isAssignableFrom(dataType)) { number = keyField ? _index : 0; InstanceField instanceField = new InstanceField(property, number); _instanceFieldsList.add(instanceField); } else if (String.class.isAssignableFrom(dataType)) { string = keyField ? code : name; InstanceField instanceField = new InstanceField(property, string); _instanceFieldsList.add(instanceField); } else if (Date.class.isAssignableFrom(dataType)) { date = keyField ? TimeUtils.currentDate() : currentDate; InstanceField instanceField = new InstanceField(property, date); _instanceFieldsList.add(instanceField); } else if (Time.class.isAssignableFrom(dataType)) { time = keyField ? TimeUtils.currentTime() : currentTime; InstanceField instanceField = new InstanceField(property, time); _instanceFieldsList.add(instanceField); } else if (Timestamp.class.isAssignableFrom(dataType)) { timestamp = keyField ? TimeUtils.currentTimestamp() : currentTimestamp; InstanceField instanceField = new InstanceField(property, timestamp); _instanceFieldsList.add(instanceField); } } if (!_instanceFieldsList.isEmpty()) { finaliseInstanceFieldArray(); } } } }
From source file:com.boundlessgeo.geoserver.api.controllers.LayerController.java
/** * API endpoint to create a new layer/* w w w. ja v a 2s .c om*/ * @param wsName The workspace to create the layer in * @param obj description of the layer * @param req HTTP request * @return The description of the newly created layer */ @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public @ResponseBody JSONObj create(@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req) { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); String name = obj.str("name"); if (name == null) { throw new BadRequestException("Layer object requires name"); } try { @SuppressWarnings("unused") LayerInfo l = findLayer(wsName, name, cat); throw new BadRequestException("Layer named '" + wsName + ":" + name + "' already exists"); } catch (NotFoundException good) { } LayerInfo l = null; try { if (obj.has("layer")) { l = createLayerFromLayer(obj.object("layer"), ws, cat); } else if (obj.has("resource")) { l = createLayerFromResource(obj.object("resource"), ws, cat); } else { throw new BadRequestException( "Layer create requires from (to create from existing layer) or resource " + "(to create from store data)"); } } catch (IOException e) { throw new RuntimeException("Failed to create layer: " + e.getMessage(), e); } ResourceInfo r = l.getResource(); // proj specified? JSONObj proj = obj.object("proj"); if (proj != null) { String srs = null; try { srs = IO.srs(proj); } catch (IllegalArgumentException e) { throw new BadRequestException(e.getMessage(), e); } r.setSRS(srs); try { new CatalogBuilder(cat).setupBounds(r); } catch (IOException e) { throw new RuntimeException("Unable to set projection on resource: " + e.getMessage(), e); } } // bbox specified? if (obj.has("bbox")) { JSONObj bbox = obj.object("bbox"); if (bbox.has("native")) { r.setNativeBoundingBox(new ReferencedEnvelope(IO.bounds(bbox.object("native")), r.getCRS())); } if (bbox.has("lonlat")) { r.setNativeBoundingBox( new ReferencedEnvelope(IO.bounds(bbox.object("lonlat")), DefaultGeographicCRS.WGS84)); } } if (r.getSRS() == null) { throw new IncompleteRequestException("Resource SRS unavailable, proj required for layer " + name); } if (r.getLatLonBoundingBox() == null) { throw new IncompleteRequestException("Resource bounds unavailable, bbox required for layer " + name); } if (r.getLatLonBoundingBox() == null) { throw new IncompleteRequestException("Resource bounds unavailable, bbox required for layer " + name); } // restore name in case it was replaced by duplicate l.getResource().setName(name); l.setName(name); // title String title = obj.str("title"); if (title == null) { title = WordUtils.capitalize(name); } l.getResource().setTitle(title); l.setTitle(title); // description String desc = obj.str("description"); if (desc != null) { l.getResource().setAbstract(desc); l.setAbstract(desc); } // copy the style into it's own unique try { l.setDefaultStyle(copyStyle(l, ws, cat)); } catch (IOException e) { throw new RuntimeException("Error copying style: " + e.getMessage(), e); } Date created = new Date(); Metadata.created(l, created); cat.add(l.getDefaultStyle()); cat.add(l.getResource()); cat.add(l); Metadata.modified(ws, created); cat.save(ws); return IO.layerDetails(new JSONObj(), l, req); }
From source file:com.siberhus.web.ckeditor.CkeditorTagConfig.java
public StringBuilder getConfiguration() { CkeditorConfig ckconfig = CkeditorConfigurationHolder.config(); String customConfig = ckconfig.config(); if (customConfig != null && (this.config.get("customConfig") == null)) { customConfig = PathUtils.checkSlashes(customConfig, "L- R-", true); this.config.put("customConfig", "'" + this.contextPath + "/" + customConfig + "'"); }//w ww .ja va 2s .c om // Collect browser settings per media type for (String t : CkeditorTagConfig.getResourceTypes()) { String type = WordUtils.capitalize(t); String typeForConnector = "Link".equals(type) ? "File" : type; if (("link".equals(t) && ckconfig.upload().link().browser()) || ("image".equals(t) && ckconfig.upload().image().browser()) || ("flash".equals(t) && ckconfig.upload().flash().browser())) { this.config.put("filebrowser" + type + "BrowseUrl", "'" + getBrowseUrl(typeForConnector, this.userSpace, this.fileBrowser, this.showThumbs) + "'"); } if (("link".equals(t) && ckconfig.upload().link().upload()) || ("image".equals(t) && ckconfig.upload().image().upload()) || ("flash".equals(t) && ckconfig.upload().flash().upload())) { this.config.put("filebrowser" + type + "UploadUrl", "'" + getUploadUrl(typeForConnector, this.userSpace) + "'"); } } // Config options List<String> configs = new ArrayList<String>(); for (Map.Entry<String, String> entry : this.config.entrySet()) { if (localConfig.get(entry.getKey()) == null) { configs.add(entry.getKey() + ": " + entry.getValue()); } } for (Map.Entry<String, String> entry : this.localConfig.entrySet()) { configs.add(entry.getKey() + ": " + entry.getValue()); } StringBuilder configuration = new StringBuilder(); if (configs.size() > 0) { // onfiguration << """, {\n""" configuration.append(", {\n"); configuration.append(StringUtils.join(configs, ",\n")); // configuration << """}\n""" configuration.append("}\n"); } return configuration; }
From source file:br.com.diegosilva.jsfcomponents.util.Utils.java
public static String lower(String value) { return WordUtils.capitalize(StringUtils.lowerCase(value)); }
From source file:com.searchbox.collection.oppfin.EENCollection.java
private static void getFieldValues(Object target, String path, FieldMap fields) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IntrospectionException { if (JAXBElement.class.isAssignableFrom(target.getClass())) { target = ((JAXBElement) target).getValue(); }/*from w w w . ja va2s. c o m*/ if (Date.class.isAssignableFrom(target.getClass())) { LOGGER.debug("put Date:" + target); fields.put(path, target); } else if (Calendar.class.isAssignableFrom(target.getClass())) { fields.put(path, ((Calendar) target).getTime()); } else if (XMLGregorianCalendar.class.isAssignableFrom(target.getClass())) { fields.put(path, ((XMLGregorianCalendar) target).toGregorianCalendar().getTime()); } else if (!target.getClass().isArray() && target.getClass().getName().startsWith("java.")) { if (!target.toString().isEmpty()) { fields.put(path, target.toString()); } } else { for (java.lang.reflect.Field field : target.getClass().getDeclaredFields()) { if (field.getName().startsWith("_") || Modifier.isStatic(field.getModifiers())) { continue; } field.setAccessible(true); Method reader = new PropertyDescriptor(field.getName(), target.getClass()).getReadMethod(); try { if (reader != null) { Object obj = reader.invoke(target); if (field.getType().isArray()) { for (Object object : (Object[]) obj) { getFieldValues(object, path + WordUtils.capitalize(field.getName().toLowerCase()), fields); } } else if (java.util.Collection.class.isAssignableFrom(obj.getClass())) { for (Object object : (java.util.Collection) obj) { getFieldValues(object, path + WordUtils.capitalize(field.getName().toLowerCase()), fields); } } else { getFieldValues(obj, path + WordUtils.capitalize(field.getName().toLowerCase()), fields); } } } catch (Exception e) { ; } } } }
From source file:com.google.flatbuffers.Table.java
@SuppressWarnings("unchecked") @Override/*from w w w. ja va2 s . c om*/ public int clone(FlatBufferBuilder builder, Map<String, Object> mutate) throws Exception { int root_table = -1; Class<?> cls = this.getClass(); HashMap<String, Object> v = new HashMap<String, Object>(); try { //b0. phan loai method List<Method> msAdd = new ArrayList<Method>(); List<Method> msGet = new ArrayList<Method>(); HashMap<String, Method> msCreateVector = new HashMap<String, Method>(); Method[] ms = this.getClass().getDeclaredMethods(); for (Method m : ms) { String sMethodName = m.getName(); if (m.getParameterTypes().length == 0 && !sMethodName.endsWith("AsByteBuffer")) msGet.add(m); else if (m.getParameterTypes().length == 2 && sMethodName.startsWith("add")) msAdd.add(m); else if (m.getParameterTypes().length == 2 && sMethodName.startsWith("create") && sMethodName.endsWith("Vector")) msCreateVector.put(sMethodName, m); } //b1. lay ds thuoc tinh va gia tri for (Method m : msGet) { String sMethodName = m.getName(); if (sMethodName.endsWith("Length")) { int ii = sMethodName.lastIndexOf("Length"); String sMethodName1 = sMethodName.substring(0, ii); int iLength = 0; try { iLength = (int) m.invoke(this, new Object[] {}); } catch (Exception e) { } List<Object> l = new ArrayList<>(); for (int i = 0; i < iLength; i++) { Method m1 = this.getClass().getDeclaredMethod(sMethodName1, new Class<?>[] { Integer.TYPE }); Object oKq = m1.invoke(this, new Object[] { i }); l.add(oKq); } v.put(sMethodName1, l); } else { Object oKq = m.invoke(this, new Object[] {}); v.put(sMethodName, oKq); } } //b2. khoi tao gia tri cho builder for (Entry<String, Object> e : v.entrySet()) { String sKey = e.getKey(); Object oValue = e.getValue(); Object oNewValue = mutate != null ? mutate.get(sKey) : null; if (oValue instanceof String || oNewValue instanceof String) { int keyOffset = builder .createString(oNewValue == null ? oValue.toString() : oNewValue.toString()); v.put(sKey, keyOffset); } else if (oValue instanceof List || oNewValue instanceof List) { List<?> oV = (List<?>) (oNewValue == null ? oValue : oNewValue); int iLen = ((List<?>) oV).size(); if (iLen <= 0) v.put(sKey, null); else { Object obj = ((List<?>) oV).get(0); if (obj instanceof Table || obj instanceof Struct) { int[] keyOffsetList = new int[iLen]; boolean isHasValue = false; for (int i = 0; i < iLen; i++) { obj = ((List<?>) oV).get(i); int offset = ((IFlatBuffer) obj).clone(builder, null); if (offset != -1) { keyOffsetList[i] = offset; isHasValue = true; } } if (isHasValue) { int keyOffset = -1; Method m = cls.getDeclaredMethod("create" + WordUtils.capitalize(sKey) + "Vector", new Class<?>[] { FlatBufferBuilder.class, int[].class }); keyOffset = (int) m.invoke(null, new Object[] { builder, keyOffsetList }); if (keyOffset != -1) v.put(sKey, keyOffset); } } else if (obj instanceof String) { int[] keyOffsetList = new int[iLen]; boolean isHasValue = false; for (int i = 0; i < iLen; i++) { obj = ((List<String>) oV).get(i); int offset = builder.createString((CharSequence) obj); if (offset != -1) { keyOffsetList[i] = offset; isHasValue = true; } } if (isHasValue) { int keyOffset = -1; Method m = cls.getDeclaredMethod("create" + WordUtils.capitalize(sKey) + "Vector", new Class<?>[] { FlatBufferBuilder.class, int[].class }); keyOffset = (int) m.invoke(null, new Object[] { builder, keyOffsetList }); if (keyOffset != -1) v.put(sKey, keyOffset); } } else { int keyOffset = -1; Method m = msCreateVector.get("create" + WordUtils.capitalize(sKey) + "Vector"); Class<?> subCls = Class.forName(m.getParameterTypes()[1].getName()); Class<?> objType = subCls.getComponentType(); String objTypeName = objType.getSimpleName(); Method mo = Number.class.getDeclaredMethod(objTypeName + "Value", new Class<?>[] {}); Object aObject = Array.newInstance(objType, iLen); for (int i = 0; i < iLen; i++) Array.set(aObject, i, mo.invoke(((List<Number>) oV).get(i), new Object[] {})); keyOffset = (int) m.invoke(null, new Object[] { builder, aObject }); if (keyOffset != -1) v.put(sKey, keyOffset); } } } else if (oValue instanceof Table || oValue instanceof Struct || oNewValue instanceof Table || oNewValue instanceof Struct) { int keyOffset = -1; if (oNewValue != null) keyOffset = ((IFlatBuffer) oNewValue).clone(builder, mutate); else keyOffset = ((IFlatBuffer) oValue).clone(builder, mutate); if (keyOffset != -1) v.put(sKey, keyOffset); } else { if (oNewValue != null) v.put(sKey, oNewValue); } } //b3. gan gia tri cho clone object Method m = cls.getDeclaredMethod("start" + cls.getSimpleName(), new Class<?>[] { FlatBufferBuilder.class }); m.invoke(null, new Object[] { builder }); for (Method mAdd : msAdd) { String sFieldName = mAdd.getName().replace("add", ""); sFieldName = WordUtils.uncapitalize(sFieldName); Object oFieldValue = v.get(sFieldName); if (oFieldValue != null && !(oFieldValue instanceof Table || oFieldValue instanceof Struct)) { mAdd.invoke(null, new Object[] { builder, oFieldValue }); } } m = cls.getDeclaredMethod("end" + cls.getSimpleName(), new Class<?>[] { FlatBufferBuilder.class }); root_table = (int) m.invoke(null, new Object[] { builder }); } catch (Exception e) { e.printStackTrace(); throw e; } return root_table; }
From source file:edu.utah.further.i2b2.hook.further.service.FurtherServicesImpl.java
/** * Adapt a query context to an i2b2 TO graph. * //from w w w. j a va 2 s.c o m * @param queryContext * FQC * @return i2b2 TO graph ready to be marshaled and inserted into an I2b2 * query response message */ @SuppressWarnings("boxing") public I2b2FurtherQueryResultTo toI2b2FurtherQueryResultTo(final QueryContextTo queryContext) { boolean isMasked = false; long maskedRecords = 0; if (log.isDebugEnabled()) { log.debug("Converting query ID " + queryContext.getId() + " to an i2b2 TO"); } final I2b2FurtherQueryResultTo queryResult = new I2b2FurtherQueryResultTo(); // Copy DQC list to data source result list final List<I2b2FurtherDataSourceResult> dataSourceResults = queryResult.getDataSources(); final int numDataSources = queryContext.getNumChildren(); if (log.isDebugEnabled()) { log.debug("# data sources = " + numDataSources); } for (final QueryContext childQc : queryContext.getChildren()) { if (childQc.getNumRecords() > 0 && childQc.getNumRecords() <= resultMaskBoundary) { isMasked = true; maskedRecords += childQc.getNumRecords(); } dataSourceResults.add(new I2b2FurtherDataSourceResult(childQc.getDataSourceId(), (childQc.getNumRecords() > 0 && childQc.getNumRecords() <= resultMaskBoundary ? I2b2FurtherQueryResultTo.COUNT_SCRUBBED : childQc.getNumRecords()))); if (log.isDebugEnabled()) { log.debug("Added data source result " + childQc); } } // Copy result context list to join result list. Not needed if there's // only one // data source. if (numDataSources > 1) { final List<I2b2FurtherJoinResult> joinResults = queryResult.getJoins(); final SortedMap<ResultType, ResultContext> resultViews = CollectionUtil.newSortedMap(); resultViews.putAll(queryContext.getResultViews()); for (final Map.Entry<ResultType, ResultContext> entry : resultViews.entrySet()) { final ResultContext resultContext = entry.getValue(); joinResults.add(new I2b2FurtherJoinResult(WordUtils.capitalize(entry.getKey().name().toLowerCase()), isMasked ? (entry.getKey().equals(ResultType.SUM) ? resultContext.getNumRecords() - maskedRecords : I2b2FurtherQueryResultTo.COUNT_SCRUBBED) : resultContext.getNumRecords())); if (log.isDebugEnabled()) { log.debug("Added join result " + resultContext); } } } if (log.isDebugEnabled()) { log.debug("I2b2 TO = " + queryResult); } return queryResult; }
From source file:net.PlayFriik.Annihilation.Annihilation.java
public void startGame() { for (Player p : Bukkit.getOnlinePlayers()) { for (Player pp : Bukkit.getOnlinePlayers()) { p.showPlayer(pp);//ww w . j a va 2 s .co m pp.showPlayer(p); } } Bukkit.getPluginManager().callEvent(new GameStartEvent(maps.getCurrentMap())); sb.scores.clear(); for (String score : sb.sb.getEntries()) { sb.sb.resetScores(score); } sb.obj.setDisplayName(ChatColor.DARK_AQUA + "Map: " + WordUtils.capitalize(voting.getWinner())); for (GameTeam t : GameTeam.teams()) { sb.scores.put(t.name(), sb.obj.getScore(WordUtils.capitalize(t.name().toLowerCase() + " Nexus"))); sb.scores.get(t.name()).setScore(t.getNexus().getHealth()); Team sbt = sb.sb.registerNewTeam(t.name() + "SB"); sbt.addEntry(WordUtils.capitalize(WordUtils.capitalize(t.name().toLowerCase() + " Nexus"))); sbt.setPrefix(t.color().toString()); } sb.obj.setDisplayName(ChatColor.DARK_AQUA + "Map: " + WordUtils.capitalize(voting.getWinner())); for (Player p : getServer().getOnlinePlayers()) { if (PlayerMeta.getMeta(p).getTeam() != GameTeam.NONE) { Util.sendPlayerToGame(p, this); } } sb.update(); getServer().getScheduler().runTaskTimer(this, new Runnable() { public void run() { for (Player p : getServer().getOnlinePlayers()) { if (PlayerMeta.getMeta(p).getKit() == Kit.SCOUT) { PlayerMeta.getMeta(p).getKit().addScoutParticles(p); } } } }, 0L, 1200L); getServer().getScheduler().runTaskTimer(this, new Runnable() { public void run() { for (GameTeam t : GameTeam.values()) { if (t != GameTeam.NONE && t.getNexus().isAlive()) { Location nexus = t.getNexus().getLocation().clone(); nexus.add(0.5, 0, 0.5); ParticleEffects.sendToLocation(ParticleEffects.ENDER, nexus, 1F, 1F, 1F, 0, 20); ParticleEffects.sendToLocation(ParticleEffects.ENCHANTMENT_TABLE, nexus, 1F, 1F, 1F, 0, 20); } } } }, 100L, 5L); }
From source file:net.firejack.platform.model.service.reverse.ReverseEngineeringService.java
private EntityModel convertToEntity(Table table, RegistryNodeModel registryNodeModel) { EntityModel entityModel = new EntityModel(); String entityName = table.getName().replaceAll("\\p{Punct}", " ").replaceAll("\\s+", " ").trim(); if (entityName.matches("^\\d.*?")) { entityName = "Fix" + entityName; }//w ww . j av a 2 s .c om entityName = WordUtils.capitalize(entityName.toLowerCase()); entityModel.setName(entityName); entityModel.setLookup(registryNodeModel.getLookup() + "." + StringUtils.normalize(entityName)); entityModel.setPath(registryNodeModel.getLookup()); entityModel.setAbstractEntity(false); entityModel.setTypeEntity(false); entityModel.setProtocol(EntityProtocol.HTTP); entityModel.setDescription(table.getComment()); entityModel.setParent(registryNodeModel); entityModel.setDatabaseRefName(table.getName()); return entityModel; }