Java Code Examples for org.apache.commons.lang.StringUtils#uncapitalize()

The following examples show how to use org.apache.commons.lang.StringUtils#uncapitalize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperatorValidatePartyContactsDA.java    From fenixedu-academic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Atomic
private void sendPhysicalAddressValidationEmail(PhysicalAddressValidation physicalAddressValidation) {
    final Person person = (Person) physicalAddressValidation.getPartyContact().getParty();
    final String subject =
            BundleUtil.getString(Bundle.MANAGER, "label.contacts.validation.operator.email.subject",
                    Unit.getInstitutionAcronym());
    final String state = StringUtils.uncapitalize(physicalAddressValidation.getState().getPresentationName());
    String body =
            BundleUtil.getString(Bundle.MANAGER, "label.contacts.validation.operator.email.body", physicalAddressValidation
                    .getPartyContact().getPresentationValue(), state);
    final String description = physicalAddressValidation.getDescription();
    if (!StringUtils.isEmpty(description)) {
        body += "\n" + description;
    }
    final String sendingEmail = person.getEmailForSendingEmails();
    if (!StringUtils.isEmpty(sendingEmail)) {
        Message.fromSystem()
                .singleBcc(sendingEmail)
                .subject(subject)
                .textBody(body)
                .send();
    }
}
 
Example 2
Source File: ScriptDao.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Adds all registered dao's and other variables, such as appId, appVersion and task-tree. These variables are available in Groovy scripts
 * @param scriptVariables
 */
public void addScriptVariables(final Map<String, Object> scriptVariables)
{
  scriptVariables.put("appId", AppVersion.APP_ID);
  scriptVariables.put("appVersion", AppVersion.NUMBER);
  scriptVariables.put("appRelease", AppVersion.RELEASE_DATE);
  scriptVariables.put("reportList", null);
  scriptVariables.put("taskTree", new ScriptingTaskTree(taskTree));
  for (final RegistryEntry entry : Registry.instance().getOrderedList()) {
    final ScriptingDao< ? > scriptingDao = entry.getScriptingDao();
    if (scriptingDao != null) {
      final String varName = StringUtils.uncapitalize(entry.getId());
      scriptVariables.put(varName + "Dao", scriptingDao);
    }
  }
}
 
Example 3
Source File: BuildConfigurationRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(String taskName) {
    if (taskName.startsWith(PREFIX)) {
        String configurationName = StringUtils.uncapitalize(taskName.substring(PREFIX.length()));
        Configuration configuration = configurations.findByName(configurationName);

        if (configuration != null) {
            Task task = tasks.create(taskName);
            task.dependsOn(configuration.getAllArtifacts());
            task.setDescription(String.format("Builds the artifacts belonging to %s.", configuration));
        }
    }
}
 
Example 4
Source File: SepStringHelper.java    From sep4j with Apache License 2.0 5 votes vote down vote up
/**
 * First Name => firstName
 * @param words
 * @return
 */
public static String wordsToUncapitalizedCamelCase(String words) {
	if (StringUtils.isBlank(words)) {
		return words;
	}		
	String[] wordArray = StringUtils.split(words);
	List<String> capitalizedList = Arrays.stream(wordArray).map(w -> StringUtils.capitalize(w))
			.collect(Collectors.toList());
	String camel = StringUtils.join(capitalizedList, "");
	return StringUtils.uncapitalize(camel);
}
 
Example 5
Source File: XmlHelper.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public static org.w3c.dom.Element propertiesToXml(org.w3c.dom.Document doc, Object o, String elementName) throws Exception {
    Class<?> c = o.getClass();
    org.w3c.dom.Element wrapper = doc.createElement(elementName);
    Method[] methods = c.getMethods();
    for (Method method : methods) {
        String name = method.getName();
        if ("getClass".equals(name)) {
            continue;
        }
        // The post processor could be in another server and we would be unable to retrieve it.
        if ("getPostProcessor".equals(name)) {
            continue;
        }
        if (!name.startsWith("get") || method.getParameterTypes().length > 0) {
            continue;
        }
        name = name.substring("get".length());
        name = StringUtils.uncapitalize(name);
        try {
            Object result = method.invoke(o);
            final String value;
            if (result == null) {
                LOG.debug("value of " + name + " method on object " + o.getClass() + " is null");
                value = "";
            } else {
                value = result.toString();
            }
            org.w3c.dom.Element fieldE = doc.createElement(name);
            fieldE.appendChild(doc.createTextNode(value));
            wrapper.appendChild(fieldE);
        } catch (Exception e) {
            throw new XmlException("Error accessing method '" + method.getName() + "' of instance of " + c, e);
        }
    }
    return wrapper;
}
 
Example 6
Source File: Configurator.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@NonNull
static String normalize(@NonNull String name) {
    String result = name;
    if (result.toUpperCase().equals(name)) {
        result = result.toLowerCase();
    } else {
        result = StringUtils.uncapitalize(name);
    }
    return result;
}
 
Example 7
Source File: NameHelper.java    From raml-java-client-generator with Apache License 2.0 5 votes vote down vote up
public static String toCamelCase(String name, boolean startWithLowerCase) {
    char[] wordDelimiters = new char[]{'_', ' ', '-'};

    if (containsAny(name, wordDelimiters)) {
        String capitalizedNodeName = WordUtils.capitalize(name, wordDelimiters);
        name = name.charAt(0) + capitalizedNodeName.substring(1);

        for (char c : wordDelimiters) {
            name = remove(name, c);
        }
    }

    return startWithLowerCase ? StringUtils.uncapitalize(name) : StringUtils.capitalize(name);
}
 
Example 8
Source File: AbstractTagPlugin.java    From FlyCms with MIT License 5 votes vote down vote up
@Override
@PostConstruct
public void init() throws TemplateModelException {
	String className = this.getClass().getName().substring(this.getClass().getName().lastIndexOf(".") + 1);
	String beanName = StringUtils.uncapitalize(className);
	String tagName = "fly_" + StringHelperUtils.toUnderline(beanName);
	freeMarkerConfigurer.getConfiguration().setSharedVariable(tagName, this.getApplicationContext().getBean(beanName));
}
 
Example 9
Source File: AnnotationProcessingTaskFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void attachActions(PropertyInfo parent, Class<?> type) {
    Class<?> superclass = type.getSuperclass();
    if (!(superclass == null
            // Avoid reflecting on classes we know we don't need to look at
            || superclass.equals(ConventionTask.class) || superclass.equals(DefaultTask.class)
            || superclass.equals(AbstractTask.class) || superclass.equals(Object.class)
    )) {
        attachActions(parent, superclass);
    }

    for (Method method : type.getDeclaredMethods()) {
        if (!isGetter(method)) {
            continue;
        }

        String name = method.getName();
        int prefixLength = name.startsWith("is") ? 2 : 3; // it's 'get' if not 'is'.
        String fieldName = StringUtils.uncapitalize(name.substring(prefixLength));
        String propertyName = fieldName;
        if (parent != null) {
            propertyName = parent.getName() + '.' + propertyName;
        }
        PropertyInfo propertyInfo = new PropertyInfo(type, this, parent, propertyName, method);

        attachValidationActions(propertyInfo, fieldName);

        if (propertyInfo.required) {
            properties.add(propertyInfo);
        }
    }
}
 
Example 10
Source File: MutableQuantiles.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new {@link MutableQuantiles} for a metric that rolls itself
 * over on the specified time interval.
 * 
 * @param name
 *          of the metric
 * @param description
 *          long-form textual description of the metric
 * @param sampleName
 *          type of items in the stream (e.g., "Ops")
 * @param valueName
 *          type of the values
 * @param interval
 *          rollover interval (in seconds) of the estimator
 */
public MutableQuantiles(String name, String description, String sampleName,
    String valueName, int interval) {
  String ucName = StringUtils.capitalize(name);
  String usName = StringUtils.capitalize(sampleName);
  String uvName = StringUtils.capitalize(valueName);
  String desc = StringUtils.uncapitalize(description);
  String lsName = StringUtils.uncapitalize(sampleName);
  String lvName = StringUtils.uncapitalize(valueName);

  numInfo = info(ucName + "Num" + usName, String.format(
      "Number of %s for %s with %ds interval", lsName, desc, interval));
  // Construct the MetricsInfos for the quantiles, converting to percentiles
  quantileInfos = new MetricsInfo[quantiles.length];
  String nameTemplate = ucName + "%dthPercentile" + uvName;
  String descTemplate = "%d percentile " + lvName + " with " + interval
      + " second interval for " + desc;
  for (int i = 0; i < quantiles.length; i++) {
    int percentile = (int) (100 * quantiles[i].quantile);
    quantileInfos[i] = info(String.format(nameTemplate, percentile),
        String.format(descTemplate, percentile));
  }

  estimator = new SampleQuantiles(quantiles);

  this.interval = interval;
  scheduler.scheduleAtFixedRate(new RolloverSample(this), interval, interval,
      TimeUnit.SECONDS);
}
 
Example 11
Source File: AnnotationProcessingTaskFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void attachActions(PropertyInfo parent, Class<?> type) {
    Class<?> superclass = type.getSuperclass();
    if (!(superclass == null
            // Avoid reflecting on classes we know we don't need to look at
            || superclass.equals(ConventionTask.class) || superclass.equals(DefaultTask.class)
            || superclass.equals(AbstractTask.class) || superclass.equals(Object.class)
    )) {
        attachActions(parent, superclass);
    }

    for (Method method : type.getDeclaredMethods()) {
        if (!isGetter(method)) {
            continue;
        }

        String name = method.getName();
        int prefixLength = name.startsWith("is") ? 2 : 3; // it's 'get' if not 'is'.
        String fieldName = StringUtils.uncapitalize(name.substring(prefixLength));
        String propertyName = fieldName;
        if (parent != null) {
            propertyName = parent.getName() + '.' + propertyName;
        }
        PropertyInfo propertyInfo = new PropertyInfo(type, this, parent, propertyName, method);

        attachValidationActions(propertyInfo, fieldName);

        if (propertyInfo.required) {
            properties.add(propertyInfo);
        }
    }
}
 
Example 12
Source File: TaskReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected String createHeader(Project project) {
    String header = super.createHeader(project);
    return "All tasks runnable from " + StringUtils.uncapitalize(header);
}
 
Example 13
Source File: BeanFilter.java    From jdal with Apache License 2.0 4 votes vote down vote up
public BeanFilter() {
	this.filterName = StringUtils.uncapitalize(this.getClass().getSimpleName());
	init();
}
 
Example 14
Source File: ServiceBeanDefinitionParser.java    From jdal with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public AbstractBeanDefinition parse(Element element, ParserContext parserContext) {
	
	// default dao and service classes
	String daoClassName = JPA_DAO_CLASS_NAME;
	String serviceClassName = PERSISTENT_SERVICE_CLASS_NAME;
	String name = null;
	boolean declareService = false;
	
	if (element.hasAttribute(DAO_CLASS)) 
		daoClassName = element.getAttribute(DAO_CLASS);
	
	if (element.hasAttribute(SERVICE_CLASS)) {
		serviceClassName = element.getAttribute(SERVICE_CLASS);
		declareService = true;
	}
	
	if (element.hasAttribute(NAME))
		name = element.getAttribute(NAME);
		
	if (element.hasAttribute(ENTITY)) {
		String className = element.getAttribute(ENTITY);
		if (name == null) {
			name = StringUtils.uncapitalize(
				StringUtils.substringAfterLast(className, PropertyUtils.PROPERTY_SEPARATOR));
		}
		parserContext.pushContainingComponent(
				new CompositeComponentDefinition(name, parserContext.extractSource(element)));
	
		// Dao
		BeanDefinitionBuilder daoBuilder  = BeanDefinitionBuilder.genericBeanDefinition(daoClassName);
		NodeList nl = element.getElementsByTagNameNS(element.getNamespaceURI(), CRITERIA);
		if (nl.getLength() > 0) {
			ManagedMap<String, BeanReference> builders = new ManagedMap<String, BeanReference>(nl.getLength());
			for (int i = 0; i < nl.getLength(); i++) {
				Element e = (Element) nl.item(i);
				builders.put(e.getAttribute(NAME), new RuntimeBeanReference(e.getAttribute(BUILDER)));
			}
			daoBuilder.addPropertyValue(CRITERIA_BUILDER_MAP, builders);
		}
		
		daoBuilder.addConstructorArgValue(ClassUtils.resolveClassName(className, null));
		daoBuilder.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);
		String daoBeanName; 
	
		if (declareService) {
			// use dao suffix
			daoBeanName = name + DAO_SUFFIX;
			registerBeanDefinition(parserContext, daoBuilder, daoBeanName); 
			
			// register service wrapper
			String serviceBeanName = name + SERVICE_SUFFIX;
			BeanDefinitionBuilder serviceBuilder = BeanDefinitionBuilder.genericBeanDefinition(serviceClassName);
			serviceBuilder.addPropertyReference("dao", daoBeanName);
			registerBeanDefinition(parserContext, serviceBuilder, serviceBeanName); 
		}
		else {
			// use service suffix for dao and declare an alias with dao suffix for compatibility with older api.
			daoBeanName = name  + SERVICE_SUFFIX;
			String[] aliases = new String[] { name + DAO_SUFFIX };
			BeanComponentDefinition bcd = new BeanComponentDefinition(daoBuilder.getBeanDefinition(), 
					daoBeanName, aliases);
			parserContext.registerBeanComponent(bcd);
		}
	
		parserContext.popAndRegisterContainingComponent();
	}
	
	return null;
}
 
Example 15
Source File: TaskReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected String createHeader(Project project) {
    String header = super.createHeader(project);
    return "All tasks runnable from " + StringUtils.uncapitalize(header);
}
 
Example 16
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getRuntimeConfigurationName() {
    return StringUtils.uncapitalize(String.format("%sRuntime", getTaskBaseName()));
}
 
Example 17
Source File: DefaultSourceSet.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getCompileConfigurationName() {
    return StringUtils.uncapitalize(String.format("%sCompile", getTaskBaseName()));
}
 
Example 18
Source File: TaskReportRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected String createHeader(Project project) {
    String header = super.createHeader(project);
    return "All tasks runnable from " + StringUtils.uncapitalize(header);
}
 
Example 19
Source File: TaskReportRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected String createHeader(Project project) {
    String header = super.createHeader(project);
    return "All tasks runnable from " + StringUtils.uncapitalize(header);
}
 
Example 20
Source File: DefaultSourceSet.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getRuntimeConfigurationName() {
    return StringUtils.uncapitalize(String.format("%sRuntime", getTaskBaseName()));
}