/** * Generates the minimum {@link JDefinedClass} skeleton * without filling in its body. */ private ClassOutlineImpl generateClassDef(CClassInfo bean) { ImplStructureStrategy.Result r = model.strategy.createClasses(this, bean); JClass implRef; if (bean.getUserSpecifiedImplClass() != null) { // create a place holder for a user-specified class. JDefinedClass usr; try { usr = codeModel._class(bean.getUserSpecifiedImplClass()); // but hide that file so that it won't be generated. usr.hide(); } catch (JClassAlreadyExistsException e) { // it's OK for this to collide. usr = e.getExistingClass(); } usr._extends(r.implementation); implRef = usr; } else { implRef = r.implementation; } return new ClassOutlineImpl(this, bean, r.exposed, r.implementation, implRef); }
public TypeUse getTypeUse(XSSimpleType owner) { if(typeUse!=null) return typeUse; JCodeModel cm = getCodeModel(); JDefinedClass a; try { a = cm._class(adapter); a.hide(); // we assume this is given by the user a._extends(cm.ref(XmlAdapter.class).narrow(String.class).narrow( cm.ref(type))); } catch (JClassAlreadyExistsException e) { a = e.getExistingClass(); } // TODO: it's not correct to say that it adapts from String, // but OTOH I don't think we can compute that. typeUse = TypeUseFactory.adapt( CBuiltinLeafInfo.STRING, new CAdapter(a)); return typeUse; }
/** Gets the xjc:superClass customization if it's turned on. */ public JClass getSuperClass() { Element sc = DOMUtil.getElement(dom,XJC_NS,"superClass"); if (sc == null) return null; JDefinedClass c; try { String v = DOMUtil.getAttribute(sc,"name"); if(v==null) return null; c = codeModel._class(v); c.hide(); } catch (JClassAlreadyExistsException e) { c = e.getExistingClass(); } return c; }
/** Gets the xjc:superInterface customization if it's turned on. */ public JClass getSuperInterface() { Element sc = DOMUtil.getElement(dom,XJC_NS,"superInterface"); if (sc == null) return null; String name = DOMUtil.getAttribute(sc,"name"); if (name == null) return null; JDefinedClass c; try { c = codeModel._class(name, ClassType.INTERFACE); c.hide(); } catch (JClassAlreadyExistsException e) { c = e.getExistingClass(); } return c; }
private void registerFault(Fault fault) { try { write(fault); faults.put(fault.getJavaException().getName(), fault.getExceptionClass()); } catch (JClassAlreadyExistsException e) { throw new GeneratorException("generator.nestedGeneratorError",e); } }
protected JDefinedClass getClass(String className, ClassType type) throws JClassAlreadyExistsException { JDefinedClass cls; try { cls = cm._class(className, type); } catch (JClassAlreadyExistsException e){ cls = cm._getClass(className); if (cls == null) { throw e; } } return cls; }
JDefinedClass getClazz(ClassType t) { if (clazz != null) return clazz; try { JCodeModel codeModel = Ring.get(JCodeModel.class); clazz = codeModel._class(name, t); clazz.hide(); return clazz; } catch (JClassAlreadyExistsException e) { return e.getExistingClass(); } }
/** * Create a dummy class to recover from an error. * * We won't generate the code, so the client will never see this class * getting generated. */ private JDefinedClass createDummyClass(JClassContainer parent) { try { return parent._class("$$$garbage$$$"+(ticketMaster++)); } catch( JClassAlreadyExistsException ee ) { return ee.getExistingClass(); } }