Thu, 31 Aug 2017 15:18:52 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.bind.api; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.io.IOException; |
aoqi@0 | 29 | import java.lang.reflect.Type; |
aoqi@0 | 30 | import java.util.Collection; |
aoqi@0 | 31 | import java.util.Collections; |
aoqi@0 | 32 | import java.util.List; |
aoqi@0 | 33 | import java.util.Map; |
aoqi@0 | 34 | |
aoqi@0 | 35 | import javax.xml.bind.JAXBContext; |
aoqi@0 | 36 | import javax.xml.bind.JAXBException; |
aoqi@0 | 37 | import javax.xml.bind.Marshaller; |
aoqi@0 | 38 | import javax.xml.bind.SchemaOutputResolver; |
aoqi@0 | 39 | import javax.xml.bind.annotation.XmlAttachmentRef; |
aoqi@0 | 40 | import javax.xml.namespace.QName; |
aoqi@0 | 41 | import javax.xml.transform.Result; |
aoqi@0 | 42 | |
aoqi@0 | 43 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 44 | import com.sun.istack.internal.Nullable; |
aoqi@0 | 45 | import com.sun.xml.internal.bind.api.impl.NameConverter; |
aoqi@0 | 46 | import com.sun.xml.internal.bind.v2.ContextFactory; |
aoqi@0 | 47 | import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader; |
aoqi@0 | 48 | import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet; |
aoqi@0 | 49 | import java.util.HashMap; |
aoqi@0 | 50 | |
aoqi@0 | 51 | /** |
aoqi@0 | 52 | * {@link JAXBContext} enhanced with JAXB RI specific functionalities. |
aoqi@0 | 53 | * |
aoqi@0 | 54 | * <p> |
aoqi@0 | 55 | * <b>Subject to change without notice</b>. |
aoqi@0 | 56 | * |
aoqi@0 | 57 | * @since 2.0 EA1 |
aoqi@0 | 58 | * @author |
aoqi@0 | 59 | * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) |
aoqi@0 | 60 | */ |
aoqi@0 | 61 | public abstract class JAXBRIContext extends JAXBContext { |
aoqi@0 | 62 | |
aoqi@0 | 63 | protected JAXBRIContext() {} |
aoqi@0 | 64 | |
aoqi@0 | 65 | /** |
aoqi@0 | 66 | * Creates a new {@link JAXBRIContext}. |
aoqi@0 | 67 | * |
aoqi@0 | 68 | * <p> |
aoqi@0 | 69 | * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may |
aoqi@0 | 70 | * return other JAXB providers that are not compatible with the JAX-RPC RI. |
aoqi@0 | 71 | * This method guarantees that the JAX-WS RI will finds the JAXB RI. |
aoqi@0 | 72 | * |
aoqi@0 | 73 | * @param classes |
aoqi@0 | 74 | * Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning. |
aoqi@0 | 75 | * @param typeRefs |
aoqi@0 | 76 | * See {@link #TYPE_REFERENCES} for the meaning of this parameter. |
aoqi@0 | 77 | * Can be null. |
aoqi@0 | 78 | * @param subclassReplacements |
aoqi@0 | 79 | * See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter. |
aoqi@0 | 80 | * Can be null. |
aoqi@0 | 81 | * @param defaultNamespaceRemap |
aoqi@0 | 82 | * See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter. |
aoqi@0 | 83 | * Can be null (and should be null for ordinary use of JAXB.) |
aoqi@0 | 84 | * @param c14nSupport |
aoqi@0 | 85 | * See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter. |
aoqi@0 | 86 | * @param ar |
aoqi@0 | 87 | * See {@link #ANNOTATION_READER} for the meaning of this parameter. |
aoqi@0 | 88 | * Can be null. |
aoqi@0 | 89 | * @since JAXB 2.1 EA2 |
aoqi@0 | 90 | */ |
aoqi@0 | 91 | public static JAXBRIContext newInstance(@NotNull Class[] classes, |
aoqi@0 | 92 | @Nullable Collection<TypeReference> typeRefs, |
aoqi@0 | 93 | @Nullable Map<Class,Class> subclassReplacements, |
aoqi@0 | 94 | @Nullable String defaultNamespaceRemap, boolean c14nSupport, |
aoqi@0 | 95 | @Nullable RuntimeAnnotationReader ar) throws JAXBException { |
aoqi@0 | 96 | return newInstance(classes, typeRefs, subclassReplacements, |
aoqi@0 | 97 | defaultNamespaceRemap, c14nSupport, ar, false, false, false, false); |
aoqi@0 | 98 | } |
aoqi@0 | 99 | |
aoqi@0 | 100 | /** |
aoqi@0 | 101 | * Creates a new {@link JAXBRIContext}. |
aoqi@0 | 102 | * |
aoqi@0 | 103 | * <p> |
aoqi@0 | 104 | * {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may |
aoqi@0 | 105 | * return other JAXB providers that are not compatible with the JAX-RPC RI. |
aoqi@0 | 106 | * This method guarantees that the JAX-WS RI will finds the JAXB RI. |
aoqi@0 | 107 | * |
aoqi@0 | 108 | * @param classes |
aoqi@0 | 109 | * Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning. |
aoqi@0 | 110 | * @param typeRefs |
aoqi@0 | 111 | * See {@link #TYPE_REFERENCES} for the meaning of this parameter. |
aoqi@0 | 112 | * Can be null. |
aoqi@0 | 113 | * @param subclassReplacements |
aoqi@0 | 114 | * See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter. |
aoqi@0 | 115 | * Can be null. |
aoqi@0 | 116 | * @param defaultNamespaceRemap |
aoqi@0 | 117 | * See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter. |
aoqi@0 | 118 | * Can be null (and should be null for ordinary use of JAXB.) |
aoqi@0 | 119 | * @param c14nSupport |
aoqi@0 | 120 | * See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter. |
aoqi@0 | 121 | * @param ar |
aoqi@0 | 122 | * See {@link #ANNOTATION_READER} for the meaning of this parameter. |
aoqi@0 | 123 | * Can be null. |
aoqi@0 | 124 | * @param xmlAccessorFactorySupport |
aoqi@0 | 125 | * See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter. |
aoqi@0 | 126 | * @param allNillable |
aoqi@0 | 127 | * See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter. |
aoqi@0 | 128 | * @param retainPropertyInfo |
aoqi@0 | 129 | * See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter. |
aoqi@0 | 130 | * @param supressAccessorWarnings |
aoqi@0 | 131 | * See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter. |
aoqi@0 | 132 | */ |
aoqi@0 | 133 | public static JAXBRIContext newInstance(@NotNull Class[] classes, |
aoqi@0 | 134 | @Nullable Collection<TypeReference> typeRefs, |
aoqi@0 | 135 | @Nullable Map<Class,Class> subclassReplacements, |
aoqi@0 | 136 | @Nullable String defaultNamespaceRemap, boolean c14nSupport, |
aoqi@0 | 137 | @Nullable RuntimeAnnotationReader ar, |
aoqi@0 | 138 | boolean xmlAccessorFactorySupport, |
aoqi@0 | 139 | boolean allNillable, |
aoqi@0 | 140 | boolean retainPropertyInfo, |
aoqi@0 | 141 | boolean supressAccessorWarnings) throws JAXBException { |
aoqi@0 | 142 | Map<String, Object> properties = new HashMap<String, Object>(); |
aoqi@0 | 143 | if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs); |
aoqi@0 | 144 | if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements); |
aoqi@0 | 145 | if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap); |
aoqi@0 | 146 | if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar); |
aoqi@0 | 147 | properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport)); |
aoqi@0 | 148 | properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport)); |
aoqi@0 | 149 | properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable)); |
aoqi@0 | 150 | properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo)); |
aoqi@0 | 151 | properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings)); |
aoqi@0 | 152 | return (JAXBRIContext) ContextFactory.createContext(classes, properties); |
aoqi@0 | 153 | } |
aoqi@0 | 154 | |
aoqi@0 | 155 | /** |
aoqi@0 | 156 | * @deprecated |
aoqi@0 | 157 | * Compatibility with older versions. |
aoqi@0 | 158 | */ |
aoqi@0 | 159 | public static JAXBRIContext newInstance(@NotNull Class[] classes, |
aoqi@0 | 160 | @Nullable Collection<TypeReference> typeRefs, |
aoqi@0 | 161 | @Nullable String defaultNamespaceRemap, boolean c14nSupport ) throws JAXBException { |
aoqi@0 | 162 | return newInstance(classes,typeRefs, Collections.<Class,Class>emptyMap(), |
aoqi@0 | 163 | defaultNamespaceRemap,c14nSupport,null); |
aoqi@0 | 164 | } |
aoqi@0 | 165 | |
aoqi@0 | 166 | /** |
aoqi@0 | 167 | * Returns true if this context includes a class |
aoqi@0 | 168 | * that has {@link XmlAttachmentRef}. |
aoqi@0 | 169 | * |
aoqi@0 | 170 | * @since 2.1 |
aoqi@0 | 171 | */ |
aoqi@0 | 172 | public abstract boolean hasSwaRef(); |
aoqi@0 | 173 | |
aoqi@0 | 174 | /** |
aoqi@0 | 175 | * If the given object is bound to an element in XML by JAXB, |
aoqi@0 | 176 | * returns the element name. |
aoqi@0 | 177 | * |
aoqi@0 | 178 | * @return null |
aoqi@0 | 179 | * if the object is not bound to an element. |
aoqi@0 | 180 | * @throws JAXBException |
aoqi@0 | 181 | * if the object is not known to this context. |
aoqi@0 | 182 | * |
aoqi@0 | 183 | * @since 2.0 EA1 |
aoqi@0 | 184 | */ |
aoqi@0 | 185 | public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException; |
aoqi@0 | 186 | |
aoqi@0 | 187 | /** |
aoqi@0 | 188 | * Allows to retrieve the element name based on Class. |
aoqi@0 | 189 | * @param o |
aoqi@0 | 190 | * @return |
aoqi@0 | 191 | * @throws javax.xml.bind.JAXBException |
aoqi@0 | 192 | * @since 2.1.10 |
aoqi@0 | 193 | */ |
aoqi@0 | 194 | public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException; |
aoqi@0 | 195 | |
aoqi@0 | 196 | /** |
aoqi@0 | 197 | * Creates a mini-marshaller/unmarshaller that can process a {@link TypeReference}. |
aoqi@0 | 198 | * |
aoqi@0 | 199 | * @return |
aoqi@0 | 200 | * null if the specified reference is not given to {@link JAXBRIContext#newInstance}. |
aoqi@0 | 201 | * |
aoqi@0 | 202 | * @since 2.0 EA1 |
aoqi@0 | 203 | */ |
aoqi@0 | 204 | public abstract Bridge createBridge(@NotNull TypeReference ref); |
aoqi@0 | 205 | |
aoqi@0 | 206 | /** |
aoqi@0 | 207 | * Creates a new {@link BridgeContext} instance. |
aoqi@0 | 208 | * |
aoqi@0 | 209 | * @return |
aoqi@0 | 210 | * always a valid non-null instance. |
aoqi@0 | 211 | * |
aoqi@0 | 212 | * @since 2.0 EA1 |
aoqi@0 | 213 | */ |
aoqi@0 | 214 | public abstract @NotNull BridgeContext createBridgeContext(); |
aoqi@0 | 215 | |
aoqi@0 | 216 | /** |
aoqi@0 | 217 | * Gets a {@link RawAccessor} for the specified element property of the specified wrapper bean class. |
aoqi@0 | 218 | * |
aoqi@0 | 219 | * <p> |
aoqi@0 | 220 | * This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.) |
aoqi@0 | 221 | * In the said mode, a wrapper bean is supposed to only have properties that match elements, |
aoqi@0 | 222 | * and for each element that appear in the content model there's one property. |
aoqi@0 | 223 | * |
aoqi@0 | 224 | * <p> |
aoqi@0 | 225 | * Therefore, this method takes a wrapper bean and a tag name that identifies a property |
aoqi@0 | 226 | * on the given wrapper bean, then returns a {@link RawAccessor} that allows the caller |
aoqi@0 | 227 | * to set/get a value from the property of the bean. |
aoqi@0 | 228 | * |
aoqi@0 | 229 | * <p> |
aoqi@0 | 230 | * This method is not designed for a performance. The caller is expected to cache the result. |
aoqi@0 | 231 | * |
aoqi@0 | 232 | * @param <B> |
aoqi@0 | 233 | * type of the wrapper bean |
aoqi@0 | 234 | * @param <V> |
aoqi@0 | 235 | * type of the property of the bean |
aoqi@0 | 236 | * @return |
aoqi@0 | 237 | * always return non-null valid accessor object. |
aoqi@0 | 238 | * @throws JAXBException |
aoqi@0 | 239 | * if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property |
aoqi@0 | 240 | * of the given name. |
aoqi@0 | 241 | * |
aoqi@0 | 242 | * @since 2.0 EA1 |
aoqi@0 | 243 | */ |
aoqi@0 | 244 | public abstract <B,V> RawAccessor<B,V> getElementPropertyAccessor( Class<B> wrapperBean, String nsUri, String localName ) |
aoqi@0 | 245 | throws JAXBException; |
aoqi@0 | 246 | |
aoqi@0 | 247 | /** |
aoqi@0 | 248 | * Gets the namespace URIs statically known to this {@link JAXBContext}. |
aoqi@0 | 249 | * |
aoqi@0 | 250 | * <p> |
aoqi@0 | 251 | * When JAXB is used to marshal into sub-trees, it declares |
aoqi@0 | 252 | * these namespace URIs at each top-level element that it marshals. |
aoqi@0 | 253 | * |
aoqi@0 | 254 | * To avoid repeated namespace declarations at sub-elements, the application |
aoqi@0 | 255 | * may declare those namespaces at a higher level. |
aoqi@0 | 256 | * |
aoqi@0 | 257 | * @return |
aoqi@0 | 258 | * always non-null. |
aoqi@0 | 259 | * |
aoqi@0 | 260 | * @since 2.0 EA2 |
aoqi@0 | 261 | */ |
aoqi@0 | 262 | public abstract @NotNull List<String> getKnownNamespaceURIs(); |
aoqi@0 | 263 | |
aoqi@0 | 264 | |
aoqi@0 | 265 | /** |
aoqi@0 | 266 | * Generates the schema documents from the model. |
aoqi@0 | 267 | * |
aoqi@0 | 268 | * <p> |
aoqi@0 | 269 | * The caller can use the additionalElementDecls parameter to |
aoqi@0 | 270 | * add element declarations to the generate schema. |
aoqi@0 | 271 | * For example, if the JAX-RPC passes in the following entry: |
aoqi@0 | 272 | * |
aoqi@0 | 273 | * {foo}bar -> DeclaredType for java.lang.String |
aoqi@0 | 274 | * |
aoqi@0 | 275 | * then JAXB generates the following element declaration (in the schema |
aoqi@0 | 276 | * document for the namespace "foo")" |
aoqi@0 | 277 | * |
aoqi@0 | 278 | * <xs:element name="bar" type="xs:string" /> |
aoqi@0 | 279 | * |
aoqi@0 | 280 | * This can be used for generating schema components necessary for WSDL. |
aoqi@0 | 281 | * |
aoqi@0 | 282 | * @param outputResolver |
aoqi@0 | 283 | * this object controls the output to which schemas |
aoqi@0 | 284 | * will be sent. |
aoqi@0 | 285 | * |
aoqi@0 | 286 | * @throws IOException |
aoqi@0 | 287 | * if {@link SchemaOutputResolver} throws an {@link IOException}. |
aoqi@0 | 288 | */ |
aoqi@0 | 289 | @Override |
aoqi@0 | 290 | public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException; |
aoqi@0 | 291 | |
aoqi@0 | 292 | /** |
aoqi@0 | 293 | * Returns the name of the XML Type bound to the |
aoqi@0 | 294 | * specified Java type. |
aoqi@0 | 295 | * |
aoqi@0 | 296 | * @param tr |
aoqi@0 | 297 | * must not be null. This must be one of the {@link TypeReference}s specified |
aoqi@0 | 298 | * in the {@link JAXBRIContext#newInstance} method. |
aoqi@0 | 299 | * |
aoqi@0 | 300 | * @throws IllegalArgumentException |
aoqi@0 | 301 | * if the parameter is null or not a part of the {@link TypeReference}s specified |
aoqi@0 | 302 | * in the {@link JAXBRIContext#newInstance} method. |
aoqi@0 | 303 | * |
aoqi@0 | 304 | * @return null |
aoqi@0 | 305 | * if the referenced type is an anonymous and therefore doesn't have a name. |
aoqi@0 | 306 | */ |
aoqi@0 | 307 | public abstract QName getTypeName(@NotNull TypeReference tr); |
aoqi@0 | 308 | |
aoqi@0 | 309 | /** |
aoqi@0 | 310 | * Gets the build information of the JAXB runtime. |
aoqi@0 | 311 | * |
aoqi@0 | 312 | * @return |
aoqi@0 | 313 | * may be null, if the runtime is loaded by a class loader that doesn't support |
aoqi@0 | 314 | * the access to the manifest informatino. |
aoqi@0 | 315 | */ |
aoqi@0 | 316 | public abstract @NotNull String getBuildId(); |
aoqi@0 | 317 | |
aoqi@0 | 318 | /** |
aoqi@0 | 319 | * Generates the episode file that represents the binding known to this {@link JAXBContext}, |
aoqi@0 | 320 | * so that XJC can later do separate compilation. |
aoqi@0 | 321 | * |
aoqi@0 | 322 | * <p> |
aoqi@0 | 323 | * Episode file is really just a JAXB customization file, except that currently |
aoqi@0 | 324 | * we use the RI-specific SCD to refer to schema components. |
aoqi@0 | 325 | * |
aoqi@0 | 326 | * @param output |
aoqi@0 | 327 | * This receives the generated episode file. |
aoqi@0 | 328 | * |
aoqi@0 | 329 | * @since 2.1 |
aoqi@0 | 330 | */ |
aoqi@0 | 331 | public abstract void generateEpisode(Result output); |
aoqi@0 | 332 | |
aoqi@0 | 333 | /** |
aoqi@0 | 334 | * Allows you to access the runtime model information of the JAXB XML/Java binding. |
aoqi@0 | 335 | * |
aoqi@0 | 336 | * <p> |
aoqi@0 | 337 | * This is useful for doing a deeper integration with the JAXB RI. |
aoqi@0 | 338 | * For more information about the model, see https://jaxb2-reflection.dev.java.net/ |
aoqi@0 | 339 | * |
aoqi@0 | 340 | * @since 2.1.10 |
aoqi@0 | 341 | */ |
aoqi@0 | 342 | public abstract RuntimeTypeInfoSet getRuntimeTypeInfoSet(); |
aoqi@0 | 343 | |
aoqi@0 | 344 | /** |
aoqi@0 | 345 | * Computes a Java identifier from a local name. |
aoqi@0 | 346 | * |
aoqi@0 | 347 | * <p> |
aoqi@0 | 348 | * This method faithfully implements the name mangling rule as specified in the JAXB spec. |
aoqi@0 | 349 | * |
aoqi@0 | 350 | * <p> |
aoqi@0 | 351 | * In JAXB, a collision with a Java reserved word (such as "return") never happens. |
aoqi@0 | 352 | * Accordingly, this method may return an identifier that collides with reserved words. |
aoqi@0 | 353 | * |
aoqi@0 | 354 | * <p> |
aoqi@0 | 355 | * Use <tt>JJavaName.isJavaIdentifier(String)</tt> to check for such collision. |
aoqi@0 | 356 | * |
aoqi@0 | 357 | * @return |
aoqi@0 | 358 | * Typically, this method returns "nameLikeThis". |
aoqi@0 | 359 | */ |
aoqi@0 | 360 | public static @NotNull String mangleNameToVariableName(@NotNull String localName) { |
aoqi@0 | 361 | return NameConverter.standard.toVariableName(localName); |
aoqi@0 | 362 | } |
aoqi@0 | 363 | |
aoqi@0 | 364 | /** |
aoqi@0 | 365 | * Computes a Java class name from a local name. |
aoqi@0 | 366 | * |
aoqi@0 | 367 | * <p> |
aoqi@0 | 368 | * This method faithfully implements the name mangling rule as specified in the JAXB spec. |
aoqi@0 | 369 | * |
aoqi@0 | 370 | * @return |
aoqi@0 | 371 | * Typically, this method returns "NameLikeThis". |
aoqi@0 | 372 | */ |
aoqi@0 | 373 | public static @NotNull String mangleNameToClassName(@NotNull String localName) { |
aoqi@0 | 374 | return NameConverter.standard.toClassName(localName); |
aoqi@0 | 375 | } |
aoqi@0 | 376 | |
aoqi@0 | 377 | /** |
aoqi@0 | 378 | * Computes a Java class name from a local name. |
aoqi@0 | 379 | * |
aoqi@0 | 380 | * <p> |
aoqi@0 | 381 | * This method faithfully implements the name mangling rule as specified in the JAXB spec. |
aoqi@0 | 382 | * This method works like {@link #mangleNameToClassName(String)} except that it looks |
aoqi@0 | 383 | * for "getClass" and returns something else. |
aoqi@0 | 384 | * |
aoqi@0 | 385 | * @return |
aoqi@0 | 386 | * Typically, this method returns "NameLikeThis". |
aoqi@0 | 387 | */ |
aoqi@0 | 388 | public static @NotNull String mangleNameToPropertyName(@NotNull String localName) { |
aoqi@0 | 389 | return NameConverter.standard.toPropertyName(localName); |
aoqi@0 | 390 | } |
aoqi@0 | 391 | |
aoqi@0 | 392 | /** |
aoqi@0 | 393 | * Gets the parameterization of the given base type. |
aoqi@0 | 394 | * |
aoqi@0 | 395 | * <p> |
aoqi@0 | 396 | * For example, given the following |
aoqi@0 | 397 | * <pre><xmp> |
aoqi@0 | 398 | * interface Foo<T> extends List<List<T>> {} |
aoqi@0 | 399 | * interface Bar extends Foo<String> {} |
aoqi@0 | 400 | * </xmp></pre> |
aoqi@0 | 401 | * This method works like this: |
aoqi@0 | 402 | * <pre><xmp> |
aoqi@0 | 403 | * getBaseClass( Bar, List ) = List<List<String> |
aoqi@0 | 404 | * getBaseClass( Bar, Foo ) = Foo<String> |
aoqi@0 | 405 | * getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>> |
aoqi@0 | 406 | * getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger> |
aoqi@0 | 407 | * </xmp></pre> |
aoqi@0 | 408 | * |
aoqi@0 | 409 | * @param type |
aoqi@0 | 410 | * The type that derives from {@code baseType} |
aoqi@0 | 411 | * @param baseType |
aoqi@0 | 412 | * The class whose parameterization we are interested in. |
aoqi@0 | 413 | * @return |
aoqi@0 | 414 | * The use of {@code baseType} in {@code type}. |
aoqi@0 | 415 | * or null if the type is not assignable to the base type. |
aoqi@0 | 416 | * @since 2.0 FCS |
aoqi@0 | 417 | */ |
aoqi@0 | 418 | public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) { |
aoqi@0 | 419 | return Utils.REFLECTION_NAVIGATOR.getBaseClass(type, baseType); |
aoqi@0 | 420 | } |
aoqi@0 | 421 | |
aoqi@0 | 422 | /** |
aoqi@0 | 423 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 424 | * to reassign the default namespace URI to something else at the runtime. |
aoqi@0 | 425 | * |
aoqi@0 | 426 | * <p> |
aoqi@0 | 427 | * The value of the property is {@link String}, and it is used as the namespace URI |
aoqi@0 | 428 | * that succeeds the default namespace URI. |
aoqi@0 | 429 | * |
aoqi@0 | 430 | * @since 2.0 EA1 |
aoqi@0 | 431 | */ |
aoqi@0 | 432 | public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap"; |
aoqi@0 | 433 | |
aoqi@0 | 434 | /** |
aoqi@0 | 435 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 436 | * to put additional JAXB type references into the {@link JAXBContext}. |
aoqi@0 | 437 | * |
aoqi@0 | 438 | * <p> |
aoqi@0 | 439 | * The value of the property is {@link Collection}<{@link TypeReference}>. |
aoqi@0 | 440 | * Those {@link TypeReference}s can then be used to create {@link Bridge}s. |
aoqi@0 | 441 | * |
aoqi@0 | 442 | * <p> |
aoqi@0 | 443 | * This mechanism allows additional element declarations that were not a part of |
aoqi@0 | 444 | * the schema into the created {@link JAXBContext}. |
aoqi@0 | 445 | * |
aoqi@0 | 446 | * @since 2.0 EA1 |
aoqi@0 | 447 | */ |
aoqi@0 | 448 | public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences"; |
aoqi@0 | 449 | |
aoqi@0 | 450 | /** |
aoqi@0 | 451 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 452 | * and {@link Marshaller#setProperty(String, Object)} |
aoqi@0 | 453 | * to enable the c14n marshalling support in the {@link JAXBContext}. |
aoqi@0 | 454 | * |
aoqi@0 | 455 | * Boolean |
aoqi@0 | 456 | * @see C14nSupport_ArchitectureDocument |
aoqi@0 | 457 | * @since 2.0 EA2 |
aoqi@0 | 458 | */ |
aoqi@0 | 459 | public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n"; |
aoqi@0 | 460 | |
aoqi@0 | 461 | /** |
aoqi@0 | 462 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 463 | * to allow unmarshaller to honor <tt>xsi:nil</tt> anywhere, even if they are |
aoqi@0 | 464 | * not specifically allowed by the schema. |
aoqi@0 | 465 | * |
aoqi@0 | 466 | * Boolean |
aoqi@0 | 467 | * @since 2.1.3 |
aoqi@0 | 468 | */ |
aoqi@0 | 469 | public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable"; |
aoqi@0 | 470 | |
aoqi@0 | 471 | /** |
aoqi@0 | 472 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 473 | * to use alternative {@link RuntimeAnnotationReader} implementation. |
aoqi@0 | 474 | * |
aoqi@0 | 475 | * @since 2.1 EA2 |
aoqi@0 | 476 | */ |
aoqi@0 | 477 | public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName(); |
aoqi@0 | 478 | |
aoqi@0 | 479 | /** |
aoqi@0 | 480 | * Marshaller/Unmarshaller property to enable XOP processing. |
aoqi@0 | 481 | * |
aoqi@0 | 482 | * @since 2.0 EA2 |
aoqi@0 | 483 | */ |
aoqi@0 | 484 | public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP"; |
aoqi@0 | 485 | |
aoqi@0 | 486 | /** |
aoqi@0 | 487 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 488 | * to specify specific classes that replace the reference to generic classes. |
aoqi@0 | 489 | * |
aoqi@0 | 490 | * <p> |
aoqi@0 | 491 | * See the release notes for more details about this feature. |
aoqi@0 | 492 | * |
aoqi@0 | 493 | * @since 2.1 EA2 |
aoqi@0 | 494 | */ |
aoqi@0 | 495 | public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements"; |
aoqi@0 | 496 | |
aoqi@0 | 497 | /** |
aoqi@0 | 498 | * The property that you can specify to {@link JAXBContext#newInstance} |
aoqi@0 | 499 | * enable support of XmlAccessorFactory annotation in the {@link JAXBContext}. |
aoqi@0 | 500 | * |
aoqi@0 | 501 | * @since 2.1 EA2 |
aoqi@0 | 502 | */ |
aoqi@0 | 503 | public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory"; |
aoqi@0 | 504 | |
aoqi@0 | 505 | /** |
aoqi@0 | 506 | * Retains references to PropertyInfos. |
aoqi@0 | 507 | * |
aoqi@0 | 508 | * Boolean |
aoqi@0 | 509 | * @since 2.1.10 |
aoqi@0 | 510 | */ |
aoqi@0 | 511 | public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo"; |
aoqi@0 | 512 | |
aoqi@0 | 513 | /** |
aoqi@0 | 514 | * Supress security warnings when trying to access fields through reflection. |
aoqi@0 | 515 | * |
aoqi@0 | 516 | * Boolean |
aoqi@0 | 517 | * @since 2.1.14, 2.2.2 |
aoqi@0 | 518 | */ |
aoqi@0 | 519 | public static final String SUPRESS_ACCESSOR_WARNINGS = "supressAccessorWarnings"; |
aoqi@0 | 520 | |
aoqi@0 | 521 | /** |
aoqi@0 | 522 | * Improves handling of xsi:type used on leaf properties. |
aoqi@0 | 523 | * |
aoqi@0 | 524 | * Boolean |
aoqi@0 | 525 | * @since 2.2.3 |
aoqi@0 | 526 | */ |
aoqi@0 | 527 | public static final String IMPROVED_XSI_TYPE_HANDLING = "com.sun.xml.internal.bind.improvedXsiTypeHandling"; |
aoqi@0 | 528 | |
aoqi@0 | 529 | /** |
aoqi@0 | 530 | * If true XML security features when parsing XML documents will be disabled. |
aoqi@0 | 531 | * The default value is false. |
aoqi@0 | 532 | * |
aoqi@0 | 533 | * Boolean |
aoqi@0 | 534 | * @since 2.2.6 |
aoqi@0 | 535 | */ |
aoqi@0 | 536 | public static final String DISABLE_XML_SECURITY = "com.sun.xml.internal.bind.disableXmlSecurity"; |
aoqi@0 | 537 | } |