List of usage examples for org.apache.commons.lang StringUtils uncapitalize
public static String uncapitalize(String str)
Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .
From source file:org.apache.torque.templates.transformer.om.OMTableAndViewTransformer.java
/** * Sets the peerImplFieldName attribute of the table element if it is not * already set. The field name can be used to contain a peer object * corresponding to the table.//from ww w . j a v a2s . co m * The peerImplClassName attribute of the column must be already set * when this method is called. * * @param tableElement the table element, not null. */ protected void setPeerImplFieldNameAttribute(SourceElement tableElement) { if (tableElement.getAttribute(TableAttributeName.PEER_IMPL_FIELD_NAME) != null) { return; } String peerImplClassName = (String) tableElement.getAttribute(TableAttributeName.PEER_IMPL_CLASS_NAME); String fieldName = StringUtils.uncapitalize(peerImplClassName); fieldName = reservedJavaWordsWrapper.process(fieldName); tableElement.setAttribute(TableAttributeName.PEER_IMPL_FIELD_NAME, fieldName); }
From source file:org.artifactory.log.logback.LogbackContextHelper.java
public static LoggerContext configure(LoggerContext lc, ArtifactoryHome artifactoryHome, String contextId) { try {/* ww w .ja va2 s .c o m*/ contextId = StringUtils.trimToEmpty(contextId); contextId = "artifactory".equalsIgnoreCase(contextId) ? "" : contextId + " "; contextId = StringUtils.isBlank(contextId) ? "" : contextId; JoranConfigurator configurator = new JoranConfigurator(); lc.stop(); configurator.setContext(lc); // Set the contextId to differentiate AOLs console logger logs lc.putProperty("artifactory.contextId", StringUtils.uncapitalize(contextId)); // Set the artifactory.home so that tokens in the logback config file are extracted lc.putProperty(ArtifactoryHome.SYS_PROP, artifactoryHome.getHomeDir().getAbsolutePath()); configurator.doConfigure(artifactoryHome.getLogbackConfig()); StatusPrinter.printIfErrorsOccured(lc); } catch (JoranException je) { StatusPrinter.print(lc); } return lc; }
From source file:org.artificer.repository.jcr.JCRArtifactPersister.java
private Node persistPrimaryArtifact() throws Exception { String uuid = primaryArtifact.getUuid(); ArtifactType artifactType = ArtifactType.valueOf(primaryArtifact); String name = primaryArtifact.getName(); String artifactPath = MapToJCRPath.getArtifactPath(uuid); log.debug(Messages.i18n.format("UPLOADING_TO_JCR", name)); Node artifactNode = null;/* ww w.jav a2 s.co m*/ try { boolean isDocumentArtifact = ArtificerModelUtils.isDocumentArtifact(primaryArtifact); if (!isDocumentArtifact) { artifactNode = JCRUtils.createNode(session.getRootNode(), artifactPath, JCRConstants.NT_FOLDER, JCRConstants.SRAMP_NON_DOCUMENT_TYPE); } else { // Some versions of ModeShape do not allow 'null' Binary values, so we must give a valid IS. InputStream is = artifactContent == null ? new ByteArrayInputStream(new byte[0]) : artifactContent.getInputStream(); artifactNode = JCRUtils.uploadFile(session, artifactPath, is, false); JCRUtils.setArtifactContentMimeType(artifactNode, artifactType.getMimeType()); } } catch (ItemExistsException e) { throw ArtificerConflictException.artifactConflict(uuid); } String jcrMixinName = artifactType.getArtifactType().getApiType().value(); jcrMixinName = JCRConstants.SRAMP_ + StringUtils.uncapitalize(jcrMixinName); artifactNode.addMixin(jcrMixinName); // BaseArtifactType artifactNode.setProperty(JCRConstants.SRAMP_UUID, uuid); artifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_MODEL, artifactType.getArtifactType().getModel()); artifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_TYPE, artifactType.getArtifactType().getType()); // Extended if (ExtendedArtifactType.class.isAssignableFrom(artifactType.getArtifactType().getTypeClass())) { artifactNode.setProperty(JCRConstants.SRAMP_EXTENDED_TYPE, artifactType.getExtendedType()); } // Extended Document if (ExtendedDocument.class.isAssignableFrom(artifactType.getArtifactType().getTypeClass())) { artifactNode.setProperty(JCRConstants.SRAMP_EXTENDED_TYPE, artifactType.getExtendedType()); } persistDocumentProperties(artifactNode, artifactType); // Update the JCR node with any properties included in the meta-data ArtifactToJCRNodeVisitor visitor = new ArtifactToJCRNodeVisitor(artifactType, artifactNode, referenceFactory, classificationHelper); visitor.setProcessRelationships(false); ArtifactVisitorHelper.visitArtifact(visitor, primaryArtifact); visitor.throwError(); log.debug(Messages.i18n.format("SAVED_JCR_NODE", name, uuid)); if (ArtificerConfig.isAuditingEnabled()) { auditCreateArtifact(artifactNode); } return artifactNode; }
From source file:org.artificer.repository.jcr.JCRArtifactPersister.java
private void persistDerivedArtifacts() throws ArtificerException { try {//from w ww . j av a2s . c o m // Persist each of the derived nodes for (BaseArtifactType derivedArtifact : derivedArtifacts) { if (derivedArtifact.getUuid() == null) { throw new ArtificerServerException( Messages.i18n.format("MISSING_DERIVED_UUID", derivedArtifact.getName())); } ArtifactType derivedArtifactType = ArtifactType.valueOf(derivedArtifact); String jcrMixinName = derivedArtifactType.getArtifactType().getApiType().value(); if (derivedArtifactType.isExtendedType()) { jcrMixinName = "extendedDerivedArtifactType"; derivedArtifactType.setExtendedDerivedType(true); } jcrMixinName = JCRConstants.SRAMP_ + StringUtils.uncapitalize(jcrMixinName); // Create the JCR node and set some basic properties first. String nodeName = derivedArtifact.getUuid(); Node derivedArtifactNode = primaryArtifactNode.addNode(nodeName, JCRConstants.SRAMP_DERIVED_PRIMARY_TYPE); derivedArtifactNode.addMixin(jcrMixinName); derivedArtifactNode.setProperty(JCRConstants.SRAMP_UUID, derivedArtifact.getUuid()); derivedArtifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_MODEL, derivedArtifactType.getArtifactType().getModel()); derivedArtifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_TYPE, derivedArtifactType.getArtifactType().getType()); // Extended if (ExtendedArtifactType.class .isAssignableFrom(derivedArtifactType.getArtifactType().getTypeClass())) { // read the encoding from the header derivedArtifactNode.setProperty(JCRConstants.SRAMP_EXTENDED_TYPE, derivedArtifactType.getExtendedType()); } // It's definitely derived. derivedArtifactNode.setProperty(JCRConstants.SRAMP_DERIVED, true); // Create the visitor that will be used to write the artifact information to the JCR node ArtifactToJCRNodeVisitor visitor = new ArtifactToJCRNodeVisitor(derivedArtifactType, derivedArtifactNode, null, classificationHelper); visitor.setProcessRelationships(false); ArtifactVisitorHelper.visitArtifact(visitor, derivedArtifact); visitor.throwError(); // Audit the create event for the derived node if (ArtificerConfig.isAuditingEnabled() && ArtificerConfig.isDerivedArtifactAuditingEnabled()) { auditCreateArtifact(derivedArtifactNode); } log.debug(Messages.i18n.format("SAVED_DERIVED_ARTY_TO_JCR", derivedArtifact.getName(), derivedArtifact.getUuid())); referenceFactory.trackNode(derivedArtifact.getUuid(), derivedArtifactNode); } } catch (ArtificerException e) { throw e; } catch (Throwable t) { throw new ArtificerServerException(t); } }
From source file:org.atmosphere.samples.pubsub.config.ComponentConfiguration.java
@Bean public ObjectMapper objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() { @Override//from w w w .ja v a 2s. co m public String nameForField(MapperConfig<?> config, AnnotatedField field, String defaultName) { return StringUtils.uncapitalize(field.getName()); } }); return mapper; }
From source file:org.batoo.common.reflect.PropertyDescriptor.java
/** * @param clazz/* ww w . ja v a2 s. com*/ * the class * @param name * the name of the property * @param reader * the reader method * * @since 2.0.1 */ public PropertyDescriptor(Class<?> clazz, String name, Method reader) { super(); this.reader = reader; this.name = StringUtils.uncapitalize(name); this.writer = this.getWriter(clazz); }
From source file:org.batoo.common.reflect.ReflectHelper.java
/** * Returns the accessor for the member/* w ww . j a v a 2 s.c o m*/ * * @param javaMember * the java member * @return the accessor * * @since 2.0.1 */ public static AbstractAccessor getAccessor(Member javaMember) { if (javaMember instanceof Field) { return ReflectHelper.unsafe != null ? new UnsafeFieldAccessor((Field) javaMember) : new FieldAccessor((Field) javaMember); } else { String name = javaMember.getName().startsWith(ReflectHelper.IS_PREFIX) ? javaMember.getName().substring(2) : javaMember.getName().substring(3); name = StringUtils.uncapitalize(name); final Class<?> declaringClass = javaMember.getDeclaringClass(); final PropertyDescriptor[] properties = ReflectHelper.getProperties(declaringClass); for (final PropertyDescriptor descriptor : properties) { if (descriptor.getName().equals(name)) { return new PropertyAccessor(descriptor); } } Field field; try { field = javaMember.getDeclaringClass().getDeclaredField(StringUtils.uncapitalize(name)); return new FieldAccessor(field); } catch (final Exception e) { throw new BatooException("Cannot find instance variable field " + javaMember.getDeclaringClass().getName() + "." + name); } } }
From source file:org.batoo.jpa.common.reflect.ReflectHelper.java
/** * Returns the accessor for the member//from ww w .j a v a 2s . com * * @param javaMember * the java member * @return the accessor * * @since $version * @author hceylan */ public static AbstractAccessor getAccessor(Member javaMember) { if (javaMember instanceof Field) { return ReflectHelper.unsafe != null ? new UnsafeFieldAccessor((Field) javaMember) : new FieldAccessor((Field) javaMember); } else { final String name = javaMember.getName().startsWith(ReflectHelper.IS_PREFIX) ? javaMember.getName().substring(2) : javaMember.getName().substring(3); Field field; try { field = javaMember.getDeclaringClass().getDeclaredField(StringUtils.uncapitalize(name)); return new FieldAccessor(field); } catch (final Exception e) { throw new BatooException("Cannot find instance variable field " + javaMember.getDeclaringClass().getName() + "." + name); } } }
From source file:org.beanfuse.model.EntityUtils.java
public static String getCommandName(Class clazz) { String name = clazz.getName(); return StringUtils.uncapitalize(name.substring(name.lastIndexOf('.') + 1)); }
From source file:org.beanfuse.model.EntityUtils.java
public static String getCommandName(String entityName) { return StringUtils.uncapitalize(StringUtils.substringAfterLast(entityName, ".")); }