com.sun.xml.internal.bind.api.impl.NameConverter Java Examples
The following examples show how to use
com.sun.xml.internal.bind.api.impl.NameConverter.
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: CPropertyInfo.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example #2
Source File: CPropertyInfo.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example #3
Source File: Model.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * @param nc * Usually this should be set in the constructor, but we do allow this parameter * to be initially null, and then set later. * @param schemaComponent * The source schema model, if this is built from XSD. */ public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) { this.options = opts; this.codeModel = cm; this.nameConverter = nc; this.defaultSymbolSpace = new SymbolSpace(codeModel); defaultSymbolSpace.setType(codeModel.ref(Object.class)); elementMappings.put(null,new HashMap<QName,CElementInfo>()); if(opts.automaticNameConflictResolution) allocator = new AutoClassNameAllocator(allocator); this.allocator = new ClassNameAllocatorWrapper(allocator); this.schemaComponent = schemaComponent; this.gloablCustomizations.setParent(this,this); }
Example #4
Source File: Model.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * @param nc * Usually this should be set in the constructor, but we do allow this parameter * to be initially null, and then set later. * @param schemaComponent * The source schema model, if this is built from XSD. */ public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) { this.options = opts; this.codeModel = cm; this.nameConverter = nc; this.defaultSymbolSpace = new SymbolSpace(codeModel); defaultSymbolSpace.setType(codeModel.ref(Object.class)); elementMappings.put(null,new HashMap<QName,CElementInfo>()); if(opts.automaticNameConflictResolution) allocator = new AutoClassNameAllocator(allocator); this.allocator = new ClassNameAllocatorWrapper(allocator); this.schemaComponent = schemaComponent; this.gloablCustomizations.setParent(this,this); }
Example #5
Source File: BIProperty.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
Example #6
Source File: RELAXNGCompiler.java From hottub with GNU General Public License v2.0 | 6 votes |
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) { this.grammar = grammar; this.opts = opts; this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null); datatypes.put("",DatatypeLib.BUILTIN); datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA); // find all defines DefineFinder deff = new DefineFinder(); grammar.accept(deff); this.defs = deff.defs; if(opts.defaultPackage2!=null) pkg = codeModel._package(opts.defaultPackage2); else if(opts.defaultPackage!=null) pkg = codeModel._package(opts.defaultPackage); else pkg = codeModel.rootPackage(); }
Example #7
Source File: BIProperty.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
Example #8
Source File: BIProperty.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
Example #9
Source File: CPropertyInfo.java From hottub with GNU General Public License v2.0 | 6 votes |
protected CPropertyInfo(String name, boolean collection, XSComponent source, CCustomizations customizations, Locator locator) { this.publicName = name; String n = null; Model m = Ring.get(Model.class); if (m != null) { n = m.getNameConverter().toVariableName(name); } else { n = NameConverter.standard.toVariableName(name); } if(!JJavaName.isJavaIdentifier(n)) n = '_'+n; // avoid colliding with the reserved names like 'abstract'. this.privateName = n; this.isCollection = collection; this.locator = locator; if(customizations==null) this.customizations = CCustomizations.EMPTY; else this.customizations = customizations; this.source = source; }
Example #10
Source File: BIProperty.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public CAttributePropertyInfo createAttributeProperty( XSAttributeUse use, TypeUse tu ) { boolean forConstant = getCustomization(use).isConstantProperty() && use.getFixedValue()!=null; String name = getPropertyName(forConstant); if(name==null) { NameConverter conv = getBuilder().getNameConverter(); if(forConstant) name = conv.toConstantName(use.getDecl().getName()); else name = conv.toPropertyName(use.getDecl().getName()); if(tu.isCollection() && getBuilder().getGlobalBinding().isSimpleMode()) name = JJavaName.getPluralForm(name); } markAsAcknowledged(); constantPropertyErrorCheck(); return wrapUp(new CAttributePropertyInfo(name,use,getCustomizations(use),use.getLocator(), BGMBuilder.getName(use.getDecl()), tu, BGMBuilder.getName(use.getDecl().getType()), use.isRequired() ),use); }
Example #11
Source File: TypeInfoImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Parses an {@link XmlRootElement} annotation on a class * and determine the element name. * * @return null * if none was found. */ protected final QName parseElementName(ClassDeclT clazz) { XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this); if(e==null) return null; String local = e.name(); if(local.equals("##default")) { // if defaulted... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); } String nsUri = e.namespace(); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example #12
Source File: Model.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * @param nc * Usually this should be set in the constructor, but we do allow this parameter * to be initially null, and then set later. * @param schemaComponent * The source schema model, if this is built from XSD. */ public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) { this.options = opts; this.codeModel = cm; this.nameConverter = nc; this.defaultSymbolSpace = new SymbolSpace(codeModel); defaultSymbolSpace.setType(codeModel.ref(Object.class)); elementMappings.put(null,new HashMap<QName,CElementInfo>()); if(opts.automaticNameConflictResolution) allocator = new AutoClassNameAllocator(allocator); this.allocator = new ClassNameAllocatorWrapper(allocator); this.schemaComponent = schemaComponent; this.gloablCustomizations.setParent(this,this); }
Example #13
Source File: RELAXNGCompiler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) { this.grammar = grammar; this.opts = opts; this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null); datatypes.put("",DatatypeLib.BUILTIN); datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA); // find all defines DefineFinder deff = new DefineFinder(); grammar.accept(deff); this.defs = deff.defs; if(opts.defaultPackage2!=null) pkg = codeModel._package(opts.defaultPackage2); else if(opts.defaultPackage!=null) pkg = codeModel._package(opts.defaultPackage); else pkg = codeModel.rootPackage(); }
Example #14
Source File: RELAXNGCompiler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) { this.grammar = grammar; this.opts = opts; this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null); datatypes.put("",DatatypeLib.BUILTIN); datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA); // find all defines DefineFinder deff = new DefineFinder(); grammar.accept(deff); this.defs = deff.defs; if(opts.defaultPackage2!=null) pkg = codeModel._package(opts.defaultPackage2); else if(opts.defaultPackage!=null) pkg = codeModel._package(opts.defaultPackage); else pkg = codeModel.rootPackage(); }
Example #15
Source File: RELAXNGCompiler.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) { this.grammar = grammar; this.opts = opts; this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null); datatypes.put("",DatatypeLib.BUILTIN); datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA); // find all defines DefineFinder deff = new DefineFinder(); grammar.accept(deff); this.defs = deff.defs; if(opts.defaultPackage2!=null) pkg = codeModel._package(opts.defaultPackage2); else if(opts.defaultPackage!=null) pkg = codeModel._package(opts.defaultPackage); else pkg = codeModel.rootPackage(); }
Example #16
Source File: RELAXNGCompiler.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) { this.grammar = grammar; this.opts = opts; this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null); datatypes.put("",DatatypeLib.BUILTIN); datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA); // find all defines DefineFinder deff = new DefineFinder(); grammar.accept(deff); this.defs = deff.defs; if(opts.defaultPackage2!=null) pkg = codeModel._package(opts.defaultPackage2); else if(opts.defaultPackage!=null) pkg = codeModel._package(opts.defaultPackage); else pkg = codeModel.rootPackage(); }
Example #17
Source File: UntypedListField.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void generateAccessors() { final MethodWriter writer = outline.createMethodWriter(); final Accessor acc = create(JExpr._this()); // [RESULT] // List getXXX() { // return <ref>; // } $get = writer.declareMethod(listT,"get"+prop.getName(true)); writer.javadoc().append(prop.javadoc); JBlock block = $get.body(); fixNullRef(block); // avoid using an internal getter block._return(acc.ref(true)); String pname = NameConverter.standard.toVariableName(prop.getName(true)); writer.javadoc().append( "Gets the value of the "+pname+" property.\n\n"+ "<p>\n" + "This accessor method returns a reference to the live list,\n" + "not a snapshot. Therefore any modification you make to the\n" + "returned list will be present inside the JAXB object.\n" + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + "\n"+ "<p>\n" + "For example, to add a new item, do as follows:\n"+ "<pre>\n"+ " get"+prop.getName(true)+"().add(newItem);\n"+ "</pre>\n"+ "\n\n" ); writer.javadoc().append( "<p>\n" + "Objects of the following type(s) are allowed in the list\n") .append(listPossibleTypes(prop)); }
Example #18
Source File: BIClass.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Gets the specified class name, or null if not specified. * (Not a fully qualified name.) * * @return * Returns a class name. The caller should <em>NOT</em> * apply XML-to-Java name conversion to the name * returned from this method. */ public @Nullable String getClassName() { if( className==null ) return null; BIGlobalBinding gb = getBuilder().getGlobalBinding(); NameConverter nc = getBuilder().model.getNameConverter(); if(gb.isJavaNamingConventionEnabled()) return nc.toClassName(className); else // don't change it return className; }
Example #19
Source File: BIGlobalBinding.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void onSetOwner() { super.onSetOwner(); // if one is given by options, use that NameConverter nc = Ring.get(Model.class).options.getNameConverter(); if(nc!=null) nameConverter = nc; }
Example #20
Source File: NoExtendedContentField.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void generateAccessors() { final MethodWriter writer = outline.createMethodWriter(); final Accessor acc = create(JExpr._this()); // [RESULT] // List getXXX() { // return <ref>; // } $get = writer.declareMethod(listT,"get"+prop.getName(true)); writer.javadoc().append(prop.javadoc); JBlock block = $get.body(); fixNullRef(block); // avoid using an internal getter block._return(acc.ref(true)); String pname = NameConverter.standard.toVariableName(prop.getName(true)); writer.javadoc().append( "Gets the value of the "+pname+" property.\n\n"+ "<p>\n" + "This accessor method returns a reference to the live list,\n" + "not a snapshot. Therefore any modification you make to the\n" + "returned list will be present inside the JAXB object.\n" + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + "\n"+ "<p>\n" + "For example, to add a new item, do as follows:\n"+ "<pre>\n"+ " get"+prop.getName(true)+"().add(newItem);\n"+ "</pre>\n"+ "\n\n" ); writer.javadoc().append( "<p>\n" + "Objects of the following type(s) are allowed in the list\n") .append(listPossibleTypes(prop)); }
Example #21
Source File: AbstractField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Annotate the attribute property 'field' */ private void annotateAttribute(JAnnotatable field) { CAttributePropertyInfo ap = (CAttributePropertyInfo) prop; QName attName = ap.getXmlName(); // [RESULT] // @XmlAttribute(name="foo", required=true, namespace="bar://baz") XmlAttributeWriter xaw = field.annotate2(XmlAttributeWriter.class); final String generatedName = attName.getLocalPart(); final String generatedNS = attName.getNamespaceURI(); // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value // generate name property? if(!generatedName.equals(ap.getName(false)) || !generatedName.equals(ap.getName(true)) || (outline.parent().getModel().getNameConverter() != NameConverter.standard)) { xaw.name(generatedName); } // generate namespace property? if(!generatedNS.equals("")) { // assume attributeFormDefault == unqualified xaw.namespace(generatedNS); } // generate required property? if(ap.isRequired()) { xaw.required(true); } }
Example #22
Source File: NoExtendedContentField.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void generateAccessors() { final MethodWriter writer = outline.createMethodWriter(); final Accessor acc = create(JExpr._this()); // [RESULT] // List getXXX() { // return <ref>; // } $get = writer.declareMethod(listT,"get"+prop.getName(true)); writer.javadoc().append(prop.javadoc); JBlock block = $get.body(); fixNullRef(block); // avoid using an internal getter block._return(acc.ref(true)); String pname = NameConverter.standard.toVariableName(prop.getName(true)); writer.javadoc().append( "Gets the value of the "+pname+" property.\n\n"+ "<p>\n" + "This accessor method returns a reference to the live list,\n" + "not a snapshot. Therefore any modification you make to the\n" + "returned list will be present inside the JAXB object.\n" + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + "\n"+ "<p>\n" + "For example, to add a new item, do as follows:\n"+ "<pre>\n"+ " get"+prop.getName(true)+"().add(newItem);\n"+ "</pre>\n"+ "\n\n" ); writer.javadoc().append( "<p>\n" + "Objects of the following type(s) are allowed in the list\n") .append(listPossibleTypes(prop)); }
Example #23
Source File: AbstractField.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Annotate the attribute property 'field' */ private void annotateAttribute(JAnnotatable field) { CAttributePropertyInfo ap = (CAttributePropertyInfo) prop; QName attName = ap.getXmlName(); // [RESULT] // @XmlAttribute(name="foo", required=true, namespace="bar://baz") XmlAttributeWriter xaw = field.annotate2(XmlAttributeWriter.class); final String generatedName = attName.getLocalPart(); final String generatedNS = attName.getNamespaceURI(); // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value // generate name property? if(!generatedName.equals(ap.getName(false)) || !generatedName.equals(ap.getName(true)) || (outline.parent().getModel().getNameConverter() != NameConverter.standard)) { xaw.name(generatedName); } // generate namespace property? if(!generatedNS.equals("")) { // assume attributeFormDefault == unqualified xaw.namespace(generatedNS); } // generate required property? if(ap.isRequired()) { xaw.required(true); } }
Example #24
Source File: UntypedListField.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public void generateAccessors() { final MethodWriter writer = outline.createMethodWriter(); final Accessor acc = create(JExpr._this()); // [RESULT] // List getXXX() { // return <ref>; // } $get = writer.declareMethod(listT,"get"+prop.getName(true)); writer.javadoc().append(prop.javadoc); JBlock block = $get.body(); fixNullRef(block); // avoid using an internal getter block._return(acc.ref(true)); String pname = NameConverter.standard.toVariableName(prop.getName(true)); writer.javadoc().append( "Gets the value of the "+pname+" property.\n\n"+ "<p>\n" + "This accessor method returns a reference to the live list,\n" + "not a snapshot. Therefore any modification you make to the\n" + "returned list will be present inside the JAXB object.\n" + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + "\n"+ "<p>\n" + "For example, to add a new item, do as follows:\n"+ "<pre>\n"+ " get"+prop.getName(true)+"().add(newItem);\n"+ "</pre>\n"+ "\n\n" ); writer.javadoc().append( "<p>\n" + "Objects of the following type(s) are allowed in the list\n") .append(listPossibleTypes(prop)); }
Example #25
Source File: AttributePropertyInfoImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private QName calcXmlName(XmlAttribute att) { String uri; String local; uri = att.namespace(); local = att.name(); // compute the default if(local.equals("##default")) local = NameConverter.standard.toVariableName(getName()); if(uri.equals("##default")) { XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this ); // JAX-RPC doesn't want the default namespace URI swapping to take effect to // local "unqualified" elements. UGLY. if(xs!=null) { switch(xs.attributeFormDefault()) { case QUALIFIED: uri = parent.getTypeName().getNamespaceURI(); if(uri.length()==0) uri = parent.builder.defaultNsUri; break; case UNQUALIFIED: case UNSET: uri = ""; } } else uri = ""; } return new QName(uri.intern(),local.intern()); }
Example #26
Source File: UntypedListField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void generateAccessors() { final MethodWriter writer = outline.createMethodWriter(); final Accessor acc = create(JExpr._this()); // [RESULT] // List getXXX() { // return <ref>; // } $get = writer.declareMethod(listT,"get"+prop.getName(true)); writer.javadoc().append(prop.javadoc); JBlock block = $get.body(); fixNullRef(block); // avoid using an internal getter block._return(acc.ref(true)); String pname = NameConverter.standard.toVariableName(prop.getName(true)); writer.javadoc().append( "Gets the value of the "+pname+" property.\n\n"+ "<p>\n" + "This accessor method returns a reference to the live list,\n" + "not a snapshot. Therefore any modification you make to the\n" + "returned list will be present inside the JAXB object.\n" + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + "\n"+ "<p>\n" + "For example, to add a new item, do as follows:\n"+ "<pre>\n"+ " get"+prop.getName(true)+"().add(newItem);\n"+ "</pre>\n"+ "\n\n" ); writer.javadoc().append( "<p>\n" + "Objects of the following type(s) are allowed in the list\n") .append(listPossibleTypes(prop)); }
Example #27
Source File: NoExtendedContentField.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public void generateAccessors() { final MethodWriter writer = outline.createMethodWriter(); final Accessor acc = create(JExpr._this()); // [RESULT] // List getXXX() { // return <ref>; // } $get = writer.declareMethod(listT,"get"+prop.getName(true)); writer.javadoc().append(prop.javadoc); JBlock block = $get.body(); fixNullRef(block); // avoid using an internal getter block._return(acc.ref(true)); String pname = NameConverter.standard.toVariableName(prop.getName(true)); writer.javadoc().append( "Gets the value of the "+pname+" property.\n\n"+ "<p>\n" + "This accessor method returns a reference to the live list,\n" + "not a snapshot. Therefore any modification you make to the\n" + "returned list will be present inside the JAXB object.\n" + "This is why there is not a <CODE>set</CODE> method for the " +pname+ " property.\n" + "\n"+ "<p>\n" + "For example, to add a new item, do as follows:\n"+ "<pre>\n"+ " get"+prop.getName(true)+"().add(newItem);\n"+ "</pre>\n"+ "\n\n" ); writer.javadoc().append( "<p>\n" + "Objects of the following type(s) are allowed in the list\n") .append(listPossibleTypes(prop)); }
Example #28
Source File: TypeInfoImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }
Example #29
Source File: AttributePropertyInfoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private QName calcXmlName(XmlAttribute att) { String uri; String local; uri = att.namespace(); local = att.name(); // compute the default if(local.equals("##default")) local = NameConverter.standard.toVariableName(getName()); if(uri.equals("##default")) { XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this ); // JAX-RPC doesn't want the default namespace URI swapping to take effect to // local "unqualified" elements. UGLY. if(xs!=null) { switch(xs.attributeFormDefault()) { case QUALIFIED: uri = parent.getTypeName().getNamespaceURI(); if(uri.length()==0) uri = parent.builder.defaultNsUri; break; case UNQUALIFIED: case UNSET: uri = ""; } } else uri = ""; } return new QName(uri.intern(),local.intern()); }
Example #30
Source File: TypeInfoImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Parses a (potentially-null) {@link XmlType} annotation on a class * and determine the actual value. * * @param clazz * The class on which the XmlType annotation is checked. * @param t * The {@link XmlType} annotation on the clazz. This value * is taken as a parameter to improve the performance for the case where * 't' is pre-computed. */ protected final QName parseTypeName(ClassDeclT clazz, XmlType t) { String nsUri="##default"; String local="##default"; if(t!=null) { nsUri = t.namespace(); local = t.name(); } if(local.length()==0) return null; // anonymous if(local.equals("##default")) // if defaulted ... local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz)); if(nsUri.equals("##default")) { // if defaulted ... XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this); if(xs!=null) nsUri = xs.namespace(); else { nsUri = builder.defaultNsUri; } } return new QName(nsUri.intern(),local.intern()); }