com.sun.tools.internal.xjc.outline.Aspect Java Examples
The following examples show how to use
com.sun.tools.internal.xjc.outline.Aspect.
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: BeanGenerator.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Returns all <i>used</i> JPackages. * * A JPackage is considered as "used" if a ClassItem or * a InterfaceItem resides in that package. * * This value is dynamically calculated every time because * one can freely remove ClassItem/InterfaceItem. * * @return * Given the same input, the order of packages in the array * is always the same regardless of the environment. */ public final JPackage[] getUsedPackages(Aspect aspect) { Set<JPackage> s = new TreeSet<JPackage>(); for (CClassInfo bean : model.beans().values()) { JClassContainer cont = getContainer(bean.parent(), aspect); if (cont.isPackage()) { s.add((JPackage) cont); } } for (CElementInfo e : model.getElementMappings(null).values()) { // at the first glance you might think we should be iterating all elements, // not just global ones, but if you think about it, local ones live inside // another class, so those packages are already enumerated when we were // walking over CClassInfos. s.add(e._package()); } return s.toArray(new JPackage[s.size()]); }
Example #2
Source File: BeanGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns all <i>used</i> JPackages. * * A JPackage is considered as "used" if a ClassItem or * a InterfaceItem resides in that package. * * This value is dynamically calculated every time because * one can freely remove ClassItem/InterfaceItem. * * @return * Given the same input, the order of packages in the array * is always the same regardless of the environment. */ public final JPackage[] getUsedPackages(Aspect aspect) { Set<JPackage> s = new TreeSet<JPackage>(); for (CClassInfo bean : model.beans().values()) { JClassContainer cont = getContainer(bean.parent(), aspect); if (cont.isPackage()) { s.add((JPackage) cont); } } for (CElementInfo e : model.getElementMappings(null).values()) { // at the first glance you might think we should be iterating all elements, // not just global ones, but if you think about it, local ones live inside // another class, so those packages are already enumerated when we were // walking over CClassInfos. s.add(e._package()); } return s.toArray(new JPackage[s.size()]); }
Example #3
Source File: CAdapter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
static NClass getRef( final Class<? extends XmlAdapter> adapter, boolean copy ) { if(copy) { // TODO: this is a hack. the code generation should be defered until // the backend. (right now constant generation happens in the front-end) return new EagerNClass(adapter) { @Override public JClass toType(Outline o, Aspect aspect) { return o.addRuntime(adapter); } public String fullName() { // TODO: implement this method later throw new UnsupportedOperationException(); } }; } else { return NavigatorImpl.theInstance.ref(adapter); } }
Example #4
Source File: CAdapter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
static NClass getRef( final Class<? extends XmlAdapter> adapter, boolean copy ) { if(copy) { // TODO: this is a hack. the code generation should be defered until // the backend. (right now constant generation happens in the front-end) return new EagerNClass(adapter) { @Override public JClass toType(Outline o, Aspect aspect) { return o.addRuntime(adapter); } public String fullName() { // TODO: implement this method later throw new UnsupportedOperationException(); } }; } else { return NavigatorImpl.theInstance.ref(adapter); } }
Example #5
Source File: BeanGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns all <i>used</i> JPackages. * * A JPackage is considered as "used" if a ClassItem or * a InterfaceItem resides in that package. * * This value is dynamically calculated every time because * one can freely remove ClassItem/InterfaceItem. * * @return * Given the same input, the order of packages in the array * is always the same regardless of the environment. */ public final JPackage[] getUsedPackages(Aspect aspect) { Set<JPackage> s = new TreeSet<JPackage>(); for (CClassInfo bean : model.beans().values()) { JClassContainer cont = getContainer(bean.parent(), aspect); if (cont.isPackage()) { s.add((JPackage) cont); } } for (CElementInfo e : model.getElementMappings(null).values()) { // at the first glance you might think we should be iterating all elements, // not just global ones, but if you think about it, local ones live inside // another class, so those packages are already enumerated when we were // walking over CClassInfos. s.add(e._package()); } return s.toArray(new JPackage[s.size()]); }
Example #6
Source File: AbstractField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected AbstractField( ClassOutlineImpl outline, CPropertyInfo prop ) { this.outline = outline; this.prop = prop; this.codeModel = outline.parent().getCodeModel(); this.implType = getType(IMPLEMENTATION); this.exposedType = getType(Aspect.EXPOSED); }
Example #7
Source File: ContentListField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected JType getType(final Aspect aspect) { if (Aspect.IMPLEMENTATION.equals(aspect)) { return super.getType(aspect); } return codeModel.ref(Serializable.class); }
Example #8
Source File: NoExtendedContentField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected JType getType(final Aspect aspect) { if (Aspect.IMPLEMENTATION.equals(aspect)) { return super.getType(aspect); } if (prop instanceof CReferencePropertyInfo) { Set<CElement> elements = ((CReferencePropertyInfo)prop).getElements(); if ((elements != null) && (elements.size() > 0)) { return codeModel.ref(Serializable.class); } } return codeModel.ref(String.class); }
Example #9
Source File: NoExtendedContentField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void toRawValue(JBlock block, JVar $var) { // [RESULT] // $<var>.addAll(bean.getLIST()); // list.toArray( array ); block.assign($var,JExpr._new(codeModel.ref(ArrayList.class).narrow(getType(Aspect.EXPOSED).boxify())).arg( $target.invoke($get) )); }
Example #10
Source File: EagerNType.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public JType toType(Outline o, Aspect aspect) { try { return o.getCodeModel().parseType(t.toString()); } catch (ClassNotFoundException e) { throw new NoClassDefFoundError(e.getMessage()); } }
Example #11
Source File: AbstractField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns contents to be added to javadoc. */ protected final List<Object> listPossibleTypes( CPropertyInfo prop ) { List<Object> r = new ArrayList<Object>(); for( CTypeInfo tt : prop.ref() ) { JType t = tt.getType().toType(outline.parent(),Aspect.EXPOSED); if( t.isPrimitive() || t.isArray() ) r.add(t.fullName()); else { r.add(t); r.add("\n"); } } return r; }
Example #12
Source File: ElementOutlineImpl.java From jdk8u60 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 #13
Source File: EagerNType.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public JType toType(Outline o, Aspect aspect) { try { return o.getCodeModel().parseType(t.toString()); } catch (ClassNotFoundException e) { throw new NoClassDefFoundError(e.getMessage()); } }
Example #14
Source File: NParameterizedType.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public JClass toType(Outline o, Aspect aspect) { JClass r = rawType.toType(o,aspect); for( NType arg : args ) r = r.narrow(arg.toType(o,aspect).boxify()); return r; }
Example #15
Source File: NParameterizedType.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public JClass toType(Outline o, Aspect aspect) { JClass r = rawType.toType(o,aspect); for( NType arg : args ) r = r.narrow(arg.toType(o,aspect).boxify()); return r; }
Example #16
Source File: ElementOutlineImpl.java From TencentKona-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 #17
Source File: ContentListField.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override protected JType getType(final Aspect aspect) { if (Aspect.IMPLEMENTATION.equals(aspect)) { return super.getType(aspect); } return codeModel.ref(Serializable.class); }
Example #18
Source File: CClassInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public final JClass toType(Outline o, Aspect aspect) { switch(aspect) { case IMPLEMENTATION: return o.getClazz(this).implRef; case EXPOSED: return o.getClazz(this).ref; default: throw new IllegalStateException(); } }
Example #19
Source File: AbstractField.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns contents to be added to javadoc. */ protected final List<Object> listPossibleTypes( CPropertyInfo prop ) { List<Object> r = new ArrayList<Object>(); for( CTypeInfo tt : prop.ref() ) { JType t = tt.getType().toType(outline.parent(),Aspect.EXPOSED); if( t.isPrimitive() || t.isArray() ) r.add(t.fullName()); else { r.add(t); r.add("\n"); } } return r; }
Example #20
Source File: CEnumLeafInfo.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString literal) { // correctly identifying which constant it maps to is hard, so // here I'm cheating JClass type = toType(outline,Aspect.EXPOSED); for (CEnumConstant mem : members) { if(mem.getLexicalValue().equals(literal.value)) return type.staticRef(mem.getName()); } return null; }
Example #21
Source File: CClassInfo.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public final JClass toType(Outline o, Aspect aspect) { switch(aspect) { case IMPLEMENTATION: return o.getClazz(this).implRef; case EXPOSED: return o.getClazz(this).ref; default: throw new IllegalStateException(); } }
Example #22
Source File: CEnumLeafInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString literal) { // correctly identifying which constant it maps to is hard, so // here I'm cheating JClass type = toType(outline,Aspect.EXPOSED); for (CEnumConstant mem : members) { if(mem.getLexicalValue().equals(literal.value)) return type.staticRef(mem.getName()); } return null; }
Example #23
Source File: EagerNType.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public JType toType(Outline o, Aspect aspect) { try { return o.getCodeModel().parseType(t.toString()); } catch (ClassNotFoundException e) { throw new NoClassDefFoundError(e.getMessage()); } }
Example #24
Source File: AbstractField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected AbstractField( ClassOutlineImpl outline, CPropertyInfo prop ) { this.outline = outline; this.prop = prop; this.codeModel = outline.parent().getCodeModel(); this.implType = getType(IMPLEMENTATION); this.exposedType = getType(Aspect.EXPOSED); }
Example #25
Source File: AbstractField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Returns contents to be added to javadoc. */ protected final List<Object> listPossibleTypes( CPropertyInfo prop ) { List<Object> r = new ArrayList<Object>(); for( CTypeInfo tt : prop.ref() ) { JType t = tt.getType().toType(outline.parent(),Aspect.EXPOSED); if( t.isPrimitive() || t.isArray() ) r.add(t.fullName()); else { r.add(t); r.add("\n"); } } return r; }
Example #26
Source File: NoExtendedContentField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void toRawValue(JBlock block, JVar $var) { // [RESULT] // $<var>.addAll(bean.getLIST()); // list.toArray( array ); block.assign($var,JExpr._new(codeModel.ref(ArrayList.class).narrow(getType(Aspect.EXPOSED).boxify())).arg( $target.invoke($get) )); }
Example #27
Source File: NoExtendedContentField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected JType getType(final Aspect aspect) { if (Aspect.IMPLEMENTATION.equals(aspect)) { return super.getType(aspect); } if (prop instanceof CReferencePropertyInfo) { Set<CElement> elements = ((CReferencePropertyInfo)prop).getElements(); if ((elements != null) && (elements.size() > 0)) { return codeModel.ref(Serializable.class); } } return codeModel.ref(String.class); }
Example #28
Source File: ContentListField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected JType getType(final Aspect aspect) { if (Aspect.IMPLEMENTATION.equals(aspect)) { return super.getType(aspect); } return codeModel.ref(Serializable.class); }
Example #29
Source File: BeanGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public final JClass addRuntime(Class clazz) { JClass g = generatedRuntime.get(clazz); if (g == null) { // put code into a separate package to avoid name conflicts. JPackage implPkg = getUsedPackages(Aspect.IMPLEMENTATION)[0].subPackage("runtime"); g = generateStaticClass(clazz, implPkg); generatedRuntime.put(clazz, g); } return g; }
Example #30
Source File: ElementOutlineImpl.java From openjdk-jdk8u 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()); } }