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