Java Code Examples for com.sun.codemodel.internal.JExpr#cast()
The following examples show how to use
com.sun.codemodel.internal.JExpr#cast() .
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: AbstractField.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Case from {@link #exposedType} to {@link #implType} if necessary. */ protected final JExpression castToImplType( JExpression exp ) { if(implType==exposedType) return exp; else return JExpr.cast(implType,exp); }
Example 2
Source File: ElementOutlineImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) { super(ei, parent.getClassFactory().createClass( parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() )); this.parent = parent; parent.elements.put(ei,this); JCodeModel cm = parent.getCodeModel(); implClass._extends( cm.ref(JAXBElement.class).narrow( target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify())); if(ei.hasClass()) { JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION); JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast? JClass scope=null; if(ei.getScope()!=null) scope = parent.getClazz(ei.getScope()).implRef; JExpression scopeClass = scope==null?JExpr._null():scope.dotclass(); JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName())); // take this opportunity to generate a constructor in the element class JMethod cons = implClass.constructor(JMod.PUBLIC); cons.body().invoke("super") .arg(valField) .arg(declaredType) .arg(scopeClass) .arg(cons.param(implType,"value")); // generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1) JMethod noArgCons = implClass.constructor(JMod.PUBLIC); noArgCons.body().invoke("super") .arg(valField) .arg(declaredType) .arg(scopeClass) .arg(JExpr._null()); } }
Example 3
Source File: ElementOutlineImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) { super(ei, parent.getClassFactory().createClass( parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() )); this.parent = parent; parent.elements.put(ei,this); JCodeModel cm = parent.getCodeModel(); implClass._extends( cm.ref(JAXBElement.class).narrow( target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify())); if(ei.hasClass()) { JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION); JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast? JClass scope=null; if(ei.getScope()!=null) scope = parent.getClazz(ei.getScope()).implRef; JExpression scopeClass = scope==null?JExpr._null():scope.dotclass(); JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName())); // take this opportunity to generate a constructor in the element class JMethod cons = implClass.constructor(JMod.PUBLIC); cons.body().invoke("super") .arg(valField) .arg(declaredType) .arg(scopeClass) .arg(cons.param(implType,"value")); // generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1) JMethod noArgCons = implClass.constructor(JMod.PUBLIC); noArgCons.body().invoke("super") .arg(valField) .arg(declaredType) .arg(scopeClass) .arg(JExpr._null()); } }
Example 4
Source File: ElementOutlineImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) { super(ei, parent.getClassFactory().createClass( parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() )); this.parent = parent; parent.elements.put(ei,this); JCodeModel cm = parent.getCodeModel(); implClass._extends( cm.ref(JAXBElement.class).narrow( target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify())); if(ei.hasClass()) { JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION); JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast? JClass scope=null; if(ei.getScope()!=null) scope = parent.getClazz(ei.getScope()).implRef; JExpression scopeClass = scope==null?JExpr._null():scope.dotclass(); JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName())); // take this opportunity to generate a constructor in the element class JMethod cons = implClass.constructor(JMod.PUBLIC); cons.body().invoke("super") .arg(valField) .arg(declaredType) .arg(scopeClass) .arg(cons.param(implType,"value")); // generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1) JMethod noArgCons = implClass.constructor(JMod.PUBLIC); noArgCons.body().invoke("super") .arg(valField) .arg(declaredType) .arg(scopeClass) .arg(JExpr._null()); } }
Example 5
Source File: AbstractField.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Case from {@link #exposedType} to {@link #implType} if necessary. */ protected final JExpression castToImplType( JExpression exp ) { if(implType==exposedType) return exp; else return JExpr.cast(implType,exp); }
Example 6
Source File: AbstractField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Case from {@link #exposedType} to {@link #implType} if necessary. */ protected final JExpression castToImplType( JExpression exp ) { if(implType==exposedType) return exp; else return JExpr.cast(implType,exp); }
Example 7
Source File: CBuiltinLeafInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().SHORT, JExpr.lit(DatatypeConverter.parseShort(lexical.value))); }
Example 8
Source File: CBuiltinLeafInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().BYTE, JExpr.lit(DatatypeConverter.parseByte(lexical.value))); }
Example 9
Source File: CBuiltinLeafInfo.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().SHORT, JExpr.lit(DatatypeConverter.parseShort(lexical.value))); }
Example 10
Source File: CBuiltinLeafInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().SHORT, JExpr.lit(DatatypeConverter.parseShort(lexical.value))); }
Example 11
Source File: CBuiltinLeafInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().SHORT, JExpr.lit(DatatypeConverter.parseShort(lexical.value))); }
Example 12
Source File: ArrayField.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Case from {@link #exposedType} to array of {@link #implType} . */ protected final JExpression castToImplTypeArray( JExpression exp ) { return JExpr.cast(implType.array(), exp); }
Example 13
Source File: ArrayField.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Case from {@link #exposedType} to array of {@link #implType} . */ protected final JExpression castToImplTypeArray( JExpression exp ) { return JExpr.cast(implType.array(), exp); }
Example 14
Source File: CBuiltinLeafInfo.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().BYTE, JExpr.lit(DatatypeConverter.parseByte(lexical.value))); }
Example 15
Source File: ArrayField.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Case from {@link #exposedType} to array of {@link #implType} . */ protected final JExpression castToImplTypeArray( JExpression exp ) { return JExpr.cast(implType.array(), exp); }
Example 16
Source File: CBuiltinLeafInfo.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().BYTE, JExpr.lit(DatatypeConverter.parseByte(lexical.value))); }
Example 17
Source File: CBuiltinLeafInfo.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().SHORT, JExpr.lit(DatatypeConverter.parseShort(lexical.value))); }
Example 18
Source File: CBuiltinLeafInfo.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.cast( outline.getCodeModel().BYTE, JExpr.lit(DatatypeConverter.parseByte(lexical.value))); }
Example 19
Source File: ArrayField.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Case from {@link #exposedType} to array of {@link #implType} . */ protected final JExpression castToImplTypeArray( JExpression exp ) { return JExpr.cast(implType.array(), exp); }
Example 20
Source File: ArrayField.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Case from {@link #exposedType} to array of {@link #implType} . */ protected final JExpression castToImplTypeArray( JExpression exp ) { return JExpr.cast(implType.array(), exp); }