Java Code Examples for com.sun.codemodel.JStringLiteral

The following examples show how to use com.sun.codemodel.JStringLiteral. These examples are extracted from open source projects. 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 Project: springmvc-raml-plugin   Source File:    License: Apache License 2.0 5 votes vote down vote up
private void assertPatternValue(JAnnotationUse jAnnotationUse, String expectedPattern) throws Exception {
	JAnnotationValue jAnnotationValue = jAnnotationUse.getAnnotationMembers().get("pattern");
	Field value = jAnnotationValue.getClass().getDeclaredField("value");
	JStringLiteral object = (JStringLiteral) value.get(jAnnotationValue);
	assertThat(object.str, is(expectedPattern));
Example 2
Source Project: hyperjaxb3   Source File:    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JExpression createConstant(Outline outline, XmlString lexical) {
	if (isCollection())
		return null;

	if (adapter == null)
		return coreType.createConstant(outline, lexical);

	// [RESULT] new Adapter().unmarshal(CONSTANT);
	JExpression cons = coreType.createConstant(outline, lexical);
	Class<? extends XmlAdapter<?, ?>> atype = (Class<? extends XmlAdapter<?, ?>>) adapter

	// try to run the adapter now rather than later.
	if (cons instanceof JStringLiteral && atype != null) {
		JStringLiteral scons = (JStringLiteral) cons;
		XmlAdapter<Object, String> a = (XmlAdapter<Object, String>) ClassFactory
		try {
			Object value = a.unmarshal(scons.str);
			if (value instanceof String) {
				return JExpr.lit((String) value);
		} catch (Exception e) {
			// assume that we can't eagerly bind this

	return JExpr._new(adapter.getAdapterClass(outline)).invoke("unmarshal")
Example 3
public JExpression compute(Outline outline){
	JExpression expression = computeInit(outline);

	if((expression instanceof JFieldRef) || (expression instanceof JStringLiteral)){

		return expression;

	return JExpr.ref(getField());