{"id":2602,"date":"2016-01-17T12:10:56","date_gmt":"2016-01-17T10:10:56","guid":{"rendered":"https:\/\/adrhc.go.ro\/wordpress\/?p=2602"},"modified":"2017-05-10T21:57:53","modified_gmt":"2017-05-10T19:57:53","slug":"jaxb-2-2-10","status":"publish","type":"post","link":"https:\/\/adrhc.go.ro\/blog\/jaxb-2-2-10\/","title":{"rendered":"JAXB 2.2.10"},"content":{"rendered":"<pre>\r\nsee also <a href=\"http:\/\/docs.oracle.com\/javaee\/5\/tutorial\/doc\/bnbbf.html\" target=\"_blank\">http:\/\/docs.oracle.com\/javaee\/5\/tutorial\/doc\/bnbbf.html<\/a>\r\nsee also <a href=\"https:\/\/jaxb.java.net\/tutorial\/index.html\" target=\"_blank\">https:\/\/jaxb.java.net\/tutorial\/index.html<\/a>\r\nsee also <a href=\"https:\/\/jaxb.java.net\/guide\/index.html\" target=\"_blank\">https:\/\/jaxb.java.net\/guide\/index.html<\/a> - Unofficial JAXB Guide\r\nsee also <em>How to get simple and better typed binding<\/em> in <a href=\"https:\/\/metro.java.net\/guide\/ch03.html\" target=\"_blank\">https:\/\/metro.java.net\/guide\/ch03.html<\/a>\r\n\r\n<strong>globalBindings<\/strong>\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;jxb:globalBindings\r\n     fixedAttributeAsConstantProperty=\"false\"\r\n     collectionType=\"java.util.Vector\"\r\n     typesafeEnumBase=\"xsd:string\"\r\n     choiceContentProperty=\"false\"\r\n     typesafeEnumMemberName=\"generateError\"\r\n     enableFailFastCheck=\"false\"   \r\n     generateIsSetMethod=\"false\"\r\n     underscoreBinding=\"asCharInWord\"\/>\r\n<\/pre>\n<pre>\r\n<em>fixedAttributeAsConstantProperty<\/em>\r\n<em>fixed<\/em> attributes will be generated as a java constant.\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;xs:attribute name=\"country\" type=\"xs:NMTOKEN\" fixed=\"US\"\/>\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\n@XmlSchemaType(name = \"NMTOKEN\")\r\npublic final static String COUNTRY = \"US\";\r\n<\/pre>\n<pre>\r\n<em>collectionType<\/em>\r\nSpecifies the base type used for collections.\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;xs:element name=\"item\" minOccurs=\"1\" maxOccurs=\"unbounded\">\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\n@XmlElement(required = true)\r\nprotected List&lt;Items.Item> item = new Vector&lt;Items.Item>();\r\n<\/pre>\n<pre>\r\n<em>typesafeEnumBase<\/em>\r\ntypesafeEnumBase = a list of QNames, each of which must resolve to a simple type definition\r\nSpecifies that all simple type definitions deriving directly or indirectly from e.g. xsd:string and having enumeration facets should be bound by default to a typesafe enum.\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;xs:simpleType name=\"USState\">\r\n\t&lt;xs:restriction base=\"xs:string\">\r\n\t\t&lt;xs:enumeration value=\"AK\"\/>\r\n\t\t&lt;xs:enumeration value=\"AL\"\/>\r\n\t\t&lt;xs:enumeration value=\"AR\"\/>\r\n\t\t&lt;xs:enumeration value=\"CA\"\/>\r\n\t\t&lt;xs:enumeration value=\"MA\"\/>\r\n\t\t&lt;!-- and so on ... -->\r\n\t&lt;\/xs:restriction>\r\n&lt;\/xs:simpleType>\r\n<\/pre>\n<pre>\r\n<em>choiceContentProperty<\/em>\r\nThe default value is false. choiceContentProperty is not relevant when the <em>bindingStyle<\/em> is <em>elementBinding<\/em> (see below).\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;xs:complexType name=\"fileUploadRequest\">\r\n\t&lt;xs:choice>\r\n\t\t&lt;xs:element name=\"path\" type=\"xs:string\"\/>\r\n\t\t&lt;xs:element name=\"file\" type=\"xs:base64Binary\"\/>\r\n\t&lt;\/xs:choice>\r\n&lt;\/xs:complexType>\r\n<\/pre>\n<pre>\r\nXjc with choiceContentProperty=\"false\":\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\npublic class FileUploadRequest {\r\n    protected String path;\r\n    protected byte[] file;\r\n<\/pre>\n<pre>\r\nXjc with choiceContentProperty=\"true\":\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\n@XmlElements({\r\n    @XmlElement(name = \"path\", type = String.class),\r\n    @XmlElement(name = \"file\", type = byte[].class)\r\n})\r\nprotected Object pathOrFile;\r\n<\/pre>\n<pre>\r\n<em>typesafeEnumMemberName<\/em>\r\ntypesafeEnumMemberName = \"generateName\" | \"generateError\"\r\ngenerateError specifies that the code generator generates an error when it cannot map an enumeration to a Java enum type.\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;xs:simpleType name=\"USState\">\r\n\t&lt;xs:restriction base=\"xs:string\">\r\n\t\t&lt;xs:enumeration value=\"CA\"\/>\r\n\t\t&lt;xs:enumeration value=\"MA\"\/>\r\n\t\t&lt;xs:enumeration value=\"1MA\"\/> -> 1MA is an invalid java name\r\n\t\t&lt;!-- and so on ... -->\r\n\t&lt;\/xs:restriction>\r\n&lt;\/xs:simpleType>\r\n<\/pre>\n<pre>\r\n[ERROR] Cannot generate a constant name from the enumeration value \"1MA\". Use &lt;jaxb:typesafeEnumMember name=\"...\"\/> to specify one.\r\ngenerateName specifies that member names will be generated following the pattern VALUE_N. N starts off at one, and is incremented for each member of the enumeration.\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\n    @XmlEnumValue(\"1MA\")\r\n    VALUE_6(\"1MA\");\r\n    private final String value;\r\n<\/pre>\n<pre>\r\n<em>enableFailFastCheck<\/em>\r\nType constraint checking is performed when setting a property.\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\nitem.setQuantity( new BigInteger( \"-5\" ) );\/\/ must be a positive number here\r\n<\/pre>\n<pre>\r\nIf @enableFailFastCheck was \"true\" and the optional FailFast validation method was supported by an implementation, a TypeConstraintException would be thrown here. Note that the JAXB implementation does not support the FailFast feature.\r\n\r\n<em>generateIsSetMethod<\/em>\r\nFirst see FileUploadRequest schema declaration above.\r\nCauses two additional property methods, isSetPath and isSetFile, to be generated. These methods enable a client application to distinguish between schema default values and values occurring explicitly within an instance document. Some good folks claim unsetPath and unsetFile should be generated too but it didn't happened for me (with or without a default attribute set on path element).\r\n\r\n<em>underscoreBinding<\/em>\r\nConsider this element:\r\n<\/pre>\n<pre class=\"brush:xml\" toolbar=\"false\">\r\n&lt;xs:element name=\"sOmE_PROPerty\" type=\"xs:string\"\/>\r\n<\/pre>\n<pre>\r\nJxc generation result when asWordSeparator (default value):\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\n@XmlElement(name = \"sOmE_PROPerty\")     -> it's an invisible underscore between sOmE and PROPerty\r\nprotected String sOmEPROPerty;\r\n<\/pre>\n<pre>\r\nJxc generation result when asCharInWord:\r\n<\/pre>\n<pre class=\"brush:java\" toolbar=\"false\">\r\nprotected String sOmE_PROPerty;         -> it's an invisible underscore between sOmE and PROPerty\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>see also http:\/\/docs.oracle.com\/javaee\/5\/tutorial\/doc\/bnbbf.html see also https:\/\/jaxb.java.net\/tutorial\/index.html see also https:\/\/jaxb.java.net\/guide\/index.html &#8211; Unofficial JAXB Guide see also How to get simple and better typed binding in https:\/\/metro.java.net\/guide\/ch03.html globalBindings &lt;jxb:globalBindings fixedAttributeAsConstantProperty=&#8221;false&#8221; collectionType=&#8221;java.util.Vector&#8221; typesafeEnumBase=&#8221;xsd:string&#8221; choiceContentProperty=&#8221;false&#8221; typesafeEnumMemberName=&#8221;generateError&#8221; enableFailFastCheck=&#8221;false&#8221; generateIsSetMethod=&#8221;false&#8221; underscoreBinding=&#8221;asCharInWord&#8221;\/> fixedAttributeAsConstantProperty fixed attributes will be [&hellip;]<\/p>\n<div class=\"link-more\"><a href=\"https:\/\/adrhc.go.ro\/blog\/jaxb-2-2-10\/#more-2602\" class=\"more-link\">Continue reading &#10142; <span class=\"screen-reader-text\">JAXB 2.2.10<\/span><\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36,10],"tags":[65],"class_list":["post-2602","post","type-post","status-publish","format-standard","hentry","category-java","category-programming","tag-jaxb"],"_links":{"self":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/2602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/comments?post=2602"}],"version-history":[{"count":0,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/posts\/2602\/revisions"}],"wp:attachment":[{"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/media?parent=2602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/categories?post=2602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adrhc.go.ro\/blog\/wp-json\/wp\/v2\/tags?post=2602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}