com.sun.tools.internal.xjc.outline.Outline Java Examples
The following examples show how to use
com.sun.tools.internal.xjc.outline.Outline.
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: TypeUseImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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 = adapter.getAdapterIfKnown(); // try to run the adapter now rather than later. if(cons instanceof JStringLiteral && atype!=null) { JStringLiteral scons = (JStringLiteral) cons; XmlAdapter a = ClassFactory.create(atype); 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").arg(cons); }
Example #2
Source File: TypeUseImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 = adapter.getAdapterIfKnown(); // try to run the adapter now rather than later. if(cons instanceof JStringLiteral && atype!=null) { JStringLiteral scons = (JStringLiteral) cons; XmlAdapter a = ClassFactory.create(atype); 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").arg(cons); }
Example #3
Source File: TypeUseImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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 = adapter.getAdapterIfKnown(); // try to run the adapter now rather than later. if(cons instanceof JStringLiteral && atype!=null) { JStringLiteral scons = (JStringLiteral) cons; XmlAdapter a = ClassFactory.create(atype); 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").arg(cons); }
Example #4
Source File: BeanGenerator.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED), e.shortName, e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
Example #5
Source File: BeanGenerator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED), e.shortName, e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
Example #6
Source File: BeanGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED), e.shortName, e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
Example #7
Source File: BeanGenerator.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private EnumOutline generateEnumDef(CEnumLeafInfo e) { JDefinedClass type; type = getClassFactory().createClass( getContainer(e.parent, EXPOSED), e.shortName, e.getLocator(), ClassType.ENUM); type.javadoc().append(e.javadoc); return new EnumOutline(e, type) { @Override public @NotNull Outline parent() { return BeanGenerator.this; } }; }
Example #8
Source File: SourceLocationAddOn.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public boolean run( Outline outline, Options opt, ErrorHandler errorHandler ) { for( ClassOutline ci : outline.getClasses() ) { JDefinedClass impl = ci.implClass; if (ci.getSuperClass() == null) { JVar $loc = impl.field(JMod.PROTECTED, Locator.class, fieldName); $loc.annotate(XmlLocation.class); $loc.annotate(XmlTransient.class); impl._implements(Locatable.class); impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc); JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation"); JVar $newLoc = setter.param(Locator.class, "newLocator"); setter.body().assign($loc, $newLoc); } } return true; }
Example #9
Source File: CAdapter.java From openjdk-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 #10
Source File: SourceLocationAddOn.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public boolean run( Outline outline, Options opt, ErrorHandler errorHandler ) { for( ClassOutline ci : outline.getClasses() ) { JDefinedClass impl = ci.implClass; if (ci.getSuperClass() == null) { JVar $loc = impl.field(JMod.PROTECTED, Locator.class, fieldName); $loc.annotate(XmlLocation.class); $loc.annotate(XmlTransient.class); impl._implements(Locatable.class); impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc); JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation"); JVar $newLoc = setter.param(Locator.class, "newLocator"); setter.body().assign($loc, $newLoc); } } return true; }
Example #11
Source File: PluginImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public boolean run(Outline model, Options opt, ErrorHandler errorHandler) { for( ClassOutline co : model.getClasses() ) { CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code"); if(c==null) continue; // no customization --- nothing to inject here c.markAsAcknowledged(); // TODO: ideally you should validate this DOM element to make sure // that there's no typo/etc. JAXP 1.3 can do this very easily. String codeFragment = DOMUtils.getElementText(c.element); // inject the specified code fragment into the implementation class. co.implClass.direct(codeFragment); } return true; }
Example #12
Source File: CEnumLeafInfo.java From hottub 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 #13
Source File: CDefaultValue.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a new {@link CDefaultValue} that computes the default value * by applying a lexical representation to a {@link TypeUse}. */ public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) { return new CDefaultValue() { public JExpression compute(Outline outline) { return typeUse.createConstant(outline,defaultValue); } }; }
Example #14
Source File: CBuiltinLeafInfo.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical)); return JExpr._new(outline.getCodeModel().ref(QName.class)) .arg(qn.getNamespaceURI()) .arg(qn.getLocalPart()) .arg(qn.getPrefix()); }
Example #15
Source File: JAXBModelImpl.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
JAXBModelImpl(Outline outline) { this.model = outline.getModel(); this.outline = outline; for (CClassInfo ci : model.beans().values()) { if(!ci.isElement()) continue; byXmlName.put(ci.getElementName(),new BeanMappingImpl(this,ci)); } for (CElementInfo ei : model.getElementMappings(null).values()) { byXmlName.put(ei.getElementName(),new ElementMappingImpl(this,ei)); } }
Example #16
Source File: SignatureWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private SignatureWriter( Outline model, Writer out ) { this.out = out; this.classes = model.getClasses(); for( ClassOutline ci : classes ) classSet.put( ci.ref, ci ); }
Example #17
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 #18
Source File: CDefaultValue.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Creates a new {@link CDefaultValue} that computes the default value * by applying a lexical representation to a {@link TypeUse}. */ public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) { return new CDefaultValue() { public JExpression compute(Outline outline) { return typeUse.createConstant(outline,defaultValue); } }; }
Example #19
Source File: CBuiltinLeafInfo.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical)); return JExpr._new(outline.getCodeModel().ref(QName.class)) .arg(qn.getNamespaceURI()) .arg(qn.getLocalPart()) .arg(qn.getPrefix()); }
Example #20
Source File: CDefaultValue.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Creates a new {@link CDefaultValue} that computes the default value * by applying a lexical representation to a {@link TypeUse}. */ public static CDefaultValue create(final TypeUse typeUse, final XmlString defaultValue) { return new CDefaultValue() { public JExpression compute(Outline outline) { return typeUse.createConstant(outline,defaultValue); } }; }
Example #21
Source File: CBuiltinLeafInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical)); return JExpr._new(outline.getCodeModel().ref(QName.class)) .arg(qn.getNamespaceURI()) .arg(qn.getLocalPart()) .arg(qn.getPrefix()); }
Example #22
Source File: CBuiltinLeafInfo.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical)); return JExpr._new(outline.getCodeModel().ref(QName.class)) .arg(qn.getNamespaceURI()) .arg(qn.getLocalPart()) .arg(qn.getPrefix()); }
Example #23
Source File: CBuiltinLeafInfo.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical)); return JExpr._new(outline.getCodeModel().ref(QName.class)) .arg(qn.getNamespaceURI()) .arg(qn.getLocalPart()) .arg(qn.getPrefix()); }
Example #24
Source File: CWildcardTypeInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public JType toType(Outline o, Aspect aspect) { return o.getCodeModel().ref(Element.class); }
Example #25
Source File: CEnumLeafInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public JClass toType(Outline o, Aspect aspect) { return o.getEnum(this).clazz; }
Example #26
Source File: Model.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Fully-generate the source code into the given model. * * @return * null if there was any errors. Otherwise it returns a valid * {@link Outline} object, which captures how the model objects * are mapped to the generated source code. * <p> * Add-ons can use those information to further augment the generated * source code. */ public Outline generateCode(Options opt,ErrorReceiver receiver) { ErrorReceiverFilter ehf = new ErrorReceiverFilter(receiver); // run extensions // moved to BGMBuilder._build() - issue with hyperjaxb3 // for( Plugin ma : opt.activePlugins ) // ma.postProcessModel(this,ehf); Outline o = BeanGenerator.generate(this, ehf); try {// run extensions for( Plugin ma : opt.activePlugins ) ma.run(o,opt,ehf); } catch (SAXException e) { // fatal error. error should have been reported return null; } // check for unused plug-in customizations. // these can be only checked after the plug-ins run, so it's here. // the JAXB bindings are checked by XMLSchema's builder. Set<CCustomizations> check = new HashSet<CCustomizations>(); for( CCustomizations c=customizations; c!=null; c=c.next ) { if(!check.add(c)) { throw new AssertionError(); // detect a loop } for (CPluginCustomization p : c) { if(!p.isAcknowledged()) { ehf.error( p.locator, Messages.format( Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION, p.element.getNodeName() )); ehf.error( c.getOwner().getLocator(), Messages.format( Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION_LOCATION)); } } } if(ehf.hadError()) o = null; return o; }
Example #27
Source File: CArrayInfo.java From hottub with GNU General Public License v2.0 | 4 votes |
public JType toType(Outline o, Aspect aspect) { return itemType.toType(o,aspect).array(); }
Example #28
Source File: CElementInfo.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public JType toType(Outline o, Aspect aspect) { if(className==null) return type.toType(o,aspect); else return o.getElement(this).implClass; }
Example #29
Source File: CBuiltinLeafInfo.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public JExpression createConstant(Outline outline, XmlString lexical) { return JExpr.lit(DatatypeConverter.parseBoolean(lexical.value)); }
Example #30
Source File: CClassRef.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public JClass toType(Outline o, Aspect aspect) { if(clazz==null) clazz = o.getCodeModel().ref(fullyQualifiedClassName); return clazz; }