├── .github └── workflows │ └── maven.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── NOTICE.md ├── README.md ├── SECURITY.md ├── api ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── jakarta │ │ │ └── xml │ │ │ │ └── bind │ │ │ │ ├── Binder.java │ │ │ │ ├── ContextFinder.java │ │ │ │ ├── DataBindingException.java │ │ │ │ ├── DatatypeConverter.java │ │ │ │ ├── DatatypeConverterImpl.java │ │ │ │ ├── DatatypeConverterInterface.java │ │ │ │ ├── Element.java │ │ │ │ ├── GetPropertyAction.java │ │ │ │ ├── JAXB.java │ │ │ │ ├── JAXBContext.java │ │ │ │ ├── JAXBContextFactory.java │ │ │ │ ├── JAXBElement.java │ │ │ │ ├── JAXBException.java │ │ │ │ ├── JAXBIntrospector.java │ │ │ │ ├── JAXBPermission.java │ │ │ │ ├── MarshalException.java │ │ │ │ ├── Marshaller.java │ │ │ │ ├── Messages.java │ │ │ │ ├── ModuleUtil.java │ │ │ │ ├── NotIdentifiableEvent.java │ │ │ │ ├── ParseConversionEvent.java │ │ │ │ ├── PrintConversionEvent.java │ │ │ │ ├── PropertyException.java │ │ │ │ ├── SchemaOutputResolver.java │ │ │ │ ├── ServiceLoaderUtil.java │ │ │ │ ├── TypeConstraintException.java │ │ │ │ ├── UnmarshalException.java │ │ │ │ ├── Unmarshaller.java │ │ │ │ ├── UnmarshallerHandler.java │ │ │ │ ├── ValidationEvent.java │ │ │ │ ├── ValidationEventHandler.java │ │ │ │ ├── ValidationEventLocator.java │ │ │ │ ├── ValidationException.java │ │ │ │ ├── WhiteSpaceProcessor.java │ │ │ │ ├── annotation │ │ │ │ ├── DomHandler.java │ │ │ │ ├── W3CDomHandler.java │ │ │ │ ├── XmlAccessOrder.java │ │ │ │ ├── XmlAccessType.java │ │ │ │ ├── XmlAccessorOrder.java │ │ │ │ ├── XmlAccessorType.java │ │ │ │ ├── XmlAnyAttribute.java │ │ │ │ ├── XmlAnyElement.java │ │ │ │ ├── XmlAttachmentRef.java │ │ │ │ ├── XmlAttribute.java │ │ │ │ ├── XmlElement.java │ │ │ │ ├── XmlElementDecl.java │ │ │ │ ├── XmlElementRef.java │ │ │ │ ├── XmlElementRefs.java │ │ │ │ ├── XmlElementWrapper.java │ │ │ │ ├── XmlElements.java │ │ │ │ ├── XmlEnum.java │ │ │ │ ├── XmlEnumValue.java │ │ │ │ ├── XmlID.java │ │ │ │ ├── XmlIDREF.java │ │ │ │ ├── XmlInlineBinaryData.java │ │ │ │ ├── XmlList.java │ │ │ │ ├── XmlMimeType.java │ │ │ │ ├── XmlMixed.java │ │ │ │ ├── XmlNs.java │ │ │ │ ├── XmlNsForm.java │ │ │ │ ├── XmlRegistry.java │ │ │ │ ├── XmlRootElement.java │ │ │ │ ├── XmlSchema.java │ │ │ │ ├── XmlSchemaType.java │ │ │ │ ├── XmlSchemaTypes.java │ │ │ │ ├── XmlSeeAlso.java │ │ │ │ ├── XmlTransient.java │ │ │ │ ├── XmlType.java │ │ │ │ ├── XmlValue.java │ │ │ │ ├── adapters │ │ │ │ │ ├── CollapsedStringAdapter.java │ │ │ │ │ ├── HexBinaryAdapter.java │ │ │ │ │ ├── NormalizedStringAdapter.java │ │ │ │ │ ├── XmlAdapter.java │ │ │ │ │ ├── XmlJavaTypeAdapter.java │ │ │ │ │ ├── XmlJavaTypeAdapters.java │ │ │ │ │ └── package-info.java │ │ │ │ └── package-info.java │ │ │ │ ├── attachment │ │ │ │ ├── AttachmentMarshaller.java │ │ │ │ ├── AttachmentUnmarshaller.java │ │ │ │ └── package-info.java │ │ │ │ ├── helpers │ │ │ │ ├── AbstractMarshallerImpl.java │ │ │ │ ├── AbstractUnmarshallerImpl.java │ │ │ │ ├── DefaultValidationEventHandler.java │ │ │ │ ├── Messages.java │ │ │ │ ├── NotIdentifiableEventImpl.java │ │ │ │ ├── ParseConversionEventImpl.java │ │ │ │ ├── PrintConversionEventImpl.java │ │ │ │ ├── ValidationEventImpl.java │ │ │ │ ├── ValidationEventLocatorImpl.java │ │ │ │ └── package-info.java │ │ │ │ ├── package-info.java │ │ │ │ └── util │ │ │ │ ├── JAXBResult.java │ │ │ │ ├── JAXBSource.java │ │ │ │ ├── Messages.java │ │ │ │ ├── ValidationEventCollector.java │ │ │ │ └── package-info.java │ │ └── module-info.java │ ├── javadoc │ │ └── doc-files │ │ │ └── speclicense.html │ └── resources │ │ └── jakarta │ │ └── xml │ │ └── bind │ │ ├── Messages.properties │ │ ├── bindingschema_1_0.xsd │ │ ├── bindingschema_2_0.xsd │ │ ├── bindingschema_3_0.xsd │ │ ├── helpers │ │ └── Messages.properties │ │ └── util │ │ └── Messages.properties │ └── test │ └── java │ └── org │ └── eclipse │ └── jaxb │ └── api │ └── DatatypeConverterTest.java ├── etc ├── config │ ├── copyright-exclude │ └── edl-copyright.txt ├── jenkins │ ├── continuous.groovy │ ├── continuous.sh │ ├── release.groovy │ └── release.sh ├── scripts │ ├── maven.incl.sh │ └── nexus.incl.sh └── spotbugs-exclude.xml ├── jaxb-api-test ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── jakarta │ │ │ └── xml │ │ │ │ └── bind │ │ │ │ └── tests │ │ │ │ └── SampleTest.java │ │ └── module-info.java │ └── javadoc │ │ └── doc-files │ │ └── speclicense.html │ └── test │ ├── java │ ├── jakarta │ │ └── xml │ │ │ └── bind │ │ │ └── test │ │ │ ├── JAXBContextServiceProviderNPETest.java │ │ │ ├── JAXBContextTest.java │ │ │ └── JAXBContextWrapExceptionTest.java │ ├── jaxb │ │ ├── factory │ │ │ ├── legacy │ │ │ │ ├── Invalid.java │ │ │ │ ├── Valid.java │ │ │ │ ├── Valid2.java │ │ │ │ └── Valid3.java │ │ │ └── spi │ │ │ │ ├── Invalid.java │ │ │ │ ├── Valid.java │ │ │ │ ├── Valid2.java │ │ │ │ └── Valid3.java │ │ └── test │ │ │ └── usr │ │ │ └── A.java │ └── module-info.java │ └── resources │ ├── jakarta │ └── xml │ │ └── bind │ │ └── test.policy │ ├── jaxb │ └── test │ │ └── usr │ │ └── jaxb.index │ └── logging.properties ├── pom.xml ├── spec ├── LICENSE ├── README.md ├── pom.xml └── src │ ├── assembly │ └── assembly.xml │ ├── main │ └── asciidoc │ │ ├── XMLBinding.adoc │ │ ├── appA-references.adoc │ │ ├── appB-runtime_processing.adoc │ │ ├── appC-normative_schema.adoc │ │ ├── appD-binding_xml.adoc │ │ ├── appE-external_binding.adoc │ │ ├── appF-xml_schema.adoc │ │ ├── appH-binary_data.adoc │ │ ├── appI-changelog.adoc │ │ ├── ch01-introduction.adoc │ │ ├── ch02-requirements.adoc │ │ ├── ch03-architecture.adoc │ │ ├── ch04-binding_framework.adoc │ │ ├── ch05-java_representation.adoc │ │ ├── ch06-binding_xml_schema.adoc │ │ ├── ch07-customize_xml_schema.adoc │ │ ├── ch08-java_types.adoc │ │ ├── ch09-compatibility.adoc │ │ ├── images │ │ ├── jakarta_ee_logo_schooner_color_stacked_default.png │ │ ├── xmlb-10.svg │ │ ├── xmlb-11.svg │ │ ├── xmlb-12.svg │ │ ├── xmlb-13.svg │ │ ├── xmlb-15.png │ │ ├── xmlb-16.svg │ │ ├── xmlb-17.svg │ │ ├── xmlb-18.svg │ │ ├── xmlb-2.svg │ │ ├── xmlb-23.svg │ │ ├── xmlb-3.svg │ │ ├── xmlb-4.svg │ │ ├── xmlb-8.svg │ │ └── xmlb-9.svg │ │ ├── license-efsl.adoc │ │ ├── scope.adoc │ │ ├── xml-binding-spec.adoc │ │ └── xml-binding.adoc │ └── theme │ └── jakartaee-theme.yml └── tools └── rewrite_poms_git.sh /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Public License v. 2.0 which is available at 6 | # http://www.eclipse.org/legal/epl-2.0, 7 | # or the Eclipse Distribution License v. 1.0 which is available at 8 | # http://www.eclipse.org/org/documents/edl-v10.php. 9 | # 10 | # SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause 11 | # 12 | 13 | name: XML Binding API 14 | 15 | on: 16 | pull_request: 17 | push: 18 | 19 | jobs: 20 | build: 21 | name: Test on JDK ${{ matrix.java_version }} 22 | runs-on: ubuntu-latest 23 | 24 | strategy: 25 | matrix: 26 | java_version: [ 21 ] 27 | 28 | steps: 29 | - name: Checkout for build 30 | uses: actions/checkout@v4 31 | - name: Set up JDK 32 | uses: actions/setup-java@v4 33 | with: 34 | distribution: 'zulu' 35 | java-version: ${{ matrix.java_version }} 36 | cache: maven 37 | - name: Verify 38 | run: mvn -B -V -U -C -Poss-release -Pstaging clean verify -Dgpg.skip=true org.glassfish.copyright:glassfish-copyright-maven-plugin:check -Dcopyright.ignoreyear=true 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | **/.classpath 3 | **/.project 4 | .settings/ 5 | 6 | # IntelliJ # 7 | .idea/ 8 | *.iml 9 | 10 | # OS Files # 11 | .DS_Store -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # Contributing to Jakarta XML Binding 10 | 11 | Thanks for your interest in this project. 12 | 13 | ## Project description 14 | 15 | Jakarta XML Binding™ defines an API and tools that automate the mapping 16 | between XML documents and Java objects. 17 | 18 | * https://projects.eclipse.org/projects/ee4j.jaxb 19 | 20 | ## Terms of Use 21 | 22 | This repository is subject to the Terms of Use of the Eclipse Foundation 23 | 24 | * https://www.eclipse.org/legal/termsofuse.php 25 | 26 | ## Developer resources 27 | 28 | Information regarding source code management, builds, coding standards, and 29 | more. 30 | 31 | * https://projects.eclipse.org/projects/ee4j.jaxb/developer 32 | 33 | The project maintains the following source code repositories 34 | 35 | * https://github.com/jakartaee/jaxb-api 36 | * https://github.com/jakartaee/jaxb-tck 37 | 38 | ## Eclipse Development Process 39 | 40 | This Eclipse Foundation open project is governed by the Eclipse Foundation 41 | Development Process and operates under the terms of the Eclipse IP Policy. 42 | 43 | The Jakarta EE Specification Committee has adopted the Jakarta EE Specification 44 | Process (JESP) in accordance with the Eclipse Foundation Specification Process 45 | v1.2 (EFSP) to ensure that the specification process is complied with by all 46 | Jakarta EE specification projects. 47 | 48 | * https://eclipse.org/projects/dev_process 49 | * https://www.eclipse.org/org/documents/Eclipse_IP_Policy.pdf 50 | * https://jakarta.ee/about/jesp/ 51 | * https://www.eclipse.org/legal/efsp_non_assert.php 52 | 53 | ## Eclipse Contributor Agreement 54 | 55 | In order to be able to contribute to Eclipse Foundation projects you must 56 | electronically sign the Eclipse Contributor Agreement (ECA). 57 | 58 | * https://www.eclipse.org/legal/ECA.php 59 | 60 | The ECA provides the Eclipse Foundation with a permanent record that you agree 61 | that each of your contributions will comply with the commitments documented in 62 | the Developer Certificate of Origin (DCO). Having an ECA on file associated with 63 | the email address matching the "Author" field of your contribution's Git commits 64 | fulfills the DCO's requirement that you sign-off on your contributions. 65 | 66 | For more information, please see the Eclipse Committer Handbook: 67 | https://www.eclipse.org/projects/handbook/#resources-commit 68 | 69 | ## Contact 70 | 71 | Contact the project developers via the project's "dev" list. 72 | 73 | * https://accounts.eclipse.org/mailing-list/jaxb-dev 74 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Eclipse Foundation, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 20 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # Notices for Jakarta XML Binding 10 | 11 | This content is produced and maintained by the Jakarta XML Binding project. 12 | 13 | * Project home: https://projects.eclipse.org/projects/ee4j.jaxb 14 | 15 | ## Trademarks 16 | 17 | Jakarta XML Binding™ is a trademark of the Eclipse Foundation. 18 | 19 | ## Copyright 20 | 21 | All content is the property of the respective authors or their employers. For 22 | more information regarding authorship of content, please consult the listed 23 | source code repository logs. 24 | 25 | ## Declared Project Licenses 26 | 27 | This program and the accompanying materials are made available under the terms 28 | of the Eclipse Distribution License v1.0 which is available at 29 | https://www.eclipse.org/org/documents/edl-v10.php. 30 | 31 | SPDX-License-Identifier: BSD-3-Clause 32 | 33 | ## Source Code 34 | 35 | The project maintains the following source code repositories: 36 | 37 | * https://github.com/jakartaee/jaxb-api 38 | * https://github.com/jakartaee/jaxb-tck 39 | 40 | ## Cryptography 41 | 42 | Content may contain encryption software. The country in which you are currently 43 | may have restrictions on the import, possession, and use, and/or re-export to 44 | another country, of encryption software. BEFORE using any encryption software, 45 | please check the country's laws, regulations and policies concerning the import, 46 | possession, or use, and re-export of encryption software, to see if this is 47 | permitted. 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # Jakarta XML Binding project 10 | 11 | [![Build Status](https://github.com/jakartaee/jaxb-api/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/jakartaee/jaxb-api/actions/workflows/maven.yml?branch=master) 12 | [![Jakarta Staging (Snapshots)](https://img.shields.io/nexus/s/https/jakarta.oss.sonatype.org/jakarta.xml.bind/jakarta.xml.bind-api.svg)](https://jakarta.oss.sonatype.org/content/repositories/staging/jakarta/xml/bind/jakarta.xml.bind-api/) 13 | 14 | The Jakarta XML Binding provides an API and tools that automate the mapping 15 | between XML documents and Java objects. 16 | 17 | ## License 18 | 19 | * Most of the Jakarta XML Binding project source code is licensed 20 | under the [Eclipse Distribution License (EDL) v1.0.](https://www.eclipse.org/org/documents/edl-v10.php); 21 | see the license information at the top of each source file. 22 | * The source code for the Jakarta XML Binding Specification project 23 | is licensed under the [Eclipse Public License (EPL) v2.0](https://www.eclipse.org/legal/epl-2.0/) 24 | and [GNU General Public License (GPL) v2 with Classpath Exception](https://www.gnu.org/software/classpath/license.html); 25 | again, the license is in each source file. 26 | * The binary jar files published to the Maven repository are licensed 27 | under the same licenses as the corresponding source code; 28 | see the file `META-INF/LICENSE.txt` in each jar file. 29 | 30 | You’ll find the text of the licenses in the workspace in various `LICENSE.txt` or `LICENSE.md` files. 31 | Don’t let the presence of these license files in the workspace confuse you into thinking 32 | that they apply to all files in the workspace. 33 | 34 | You should always read the license file included with every download, and read 35 | the license text included in every source file. 36 | 37 | ## Contributing 38 | 39 | We use [contribution policy](CONTRIBUTING.md), which means we can only accept contributions under 40 | the terms of [Eclipse Contributor Agreement](http://www.eclipse.org/legal/ECA.php). 41 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | [//]: # " Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. " 2 | [//]: # " " 3 | [//]: # " This program and the accompanying materials are made available under the " 4 | [//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at " 5 | [//]: # " http://www.eclipse.org/org/documents/edl-v10.php. " 6 | [//]: # " " 7 | [//]: # " SPDX-License-Identifier: BSD-3-Clause " 8 | 9 | # Security Policy 10 | 11 | This project implements the Eclipse Foundation Security Policy 12 | 13 | * https://www.eclipse.org/security 14 | 15 | ## Supported Versions 16 | 17 | These versions of Jakarta XML Binding are currently being supported with 18 | security updates. 19 | 20 | | Version | Released | Supported | 21 | | ------- | ---------- | --------- | 22 | | 4.0 | 2022-03-30 | Yes | 23 | | 3.0.1 | 2021-03-26 | Yes | 24 | | < 3.0 | 2020-11-04 | No | 25 | 26 | ## Reporting a Vulnerability 27 | 28 | Please report vulnerabilities to the Eclipse Foundation Security Team at 29 | security@eclipse.org 30 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/DataBindingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * Exception that represents a failure in a Jakarta XML Binding operation. 15 | * 16 | *

17 | * This exception differs from {@link JAXBException} in that 18 | * this is an unchecked exception, while {@code JAXBException} 19 | * is a checked exception. 20 | * 21 | * @see JAXB 22 | * @since 1.6, JAXB 2.1 23 | */ 24 | public class DataBindingException extends RuntimeException { 25 | 26 | private static final long serialVersionUID = 4743686626270704879L; 27 | 28 | public DataBindingException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | public DataBindingException(Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/Element.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This is an element marker interface. 15 | *

16 | * Under certain circumstances, it is necessary for the binding compiler to 17 | * generate derived java content classes that implement this interface. In 18 | * those cases, client applications must supply element instances rather than 19 | * types of elements. For more detail, see section 5.7 "Element Declaration" 20 | * and 5.7.1 "Bind to Java Element Interface" of the specification. 21 | * 22 | * @author

23 | * @since 1.6, JAXB 1.0 24 | */ 25 | 26 | public interface Element { 27 | } 28 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/GetPropertyAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | import java.security.PrivilegedAction; 14 | 15 | /** 16 | * {@link PrivilegedAction} that gets the system property value. 17 | * @author Kohsuke Kawaguchi 18 | */ 19 | final class GetPropertyAction implements PrivilegedAction { 20 | private final String propertyName; 21 | 22 | public GetPropertyAction(String propertyName) { 23 | this.propertyName = propertyName; 24 | } 25 | 26 | @Override 27 | public String run() { 28 | return System.getProperty(propertyName); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/JAXBIntrospector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | import javax.xml.namespace.QName; 14 | 15 | /** 16 | * Provide access to Jakarta XML Binding xml binding data for a Jakarta XML Binding object. 17 | * 18 | *

19 | * Initially, the intent of this class is to just conceptualize how 20 | * a Jakarta XML Binding application developer can access xml binding information, 21 | * independent if binding model is java to schema or schema to java. 22 | * Since accessing the XML element name related to a Jakarta XML Binding element is 23 | * a highly requested feature, demonstrate access to this 24 | * binding information. 25 | *

26 | * The factory method to get a JAXBIntrospector instance is 27 | * {@link JAXBContext#createJAXBIntrospector()}. 28 | * 29 | * @see JAXBContext#createJAXBIntrospector() 30 | * @since 1.6, JAXB 2.0 31 | */ 32 | public abstract class JAXBIntrospector { 33 | 34 | /** 35 | * Do-nothing constructor for the derived classes. 36 | */ 37 | protected JAXBIntrospector() {} 38 | 39 | /** 40 | *

Return true if object represents a Jakarta XML Binding element.

41 | *

Parameter object is a Jakarta XML Binding element for following cases: 42 | *

    43 | *
  1. It is an instance of jakarta.xml.bind.JAXBElement.
  2. 44 | *
  3. The class of object is annotated with 45 | * @XmlRootElement. 46 | *
  4. 47 | *
48 | * 49 | * @see #getElementName(Object) 50 | */ 51 | public abstract boolean isElement(Object object); 52 | 53 | /** 54 | *

Get xml element qname for jaxbElement.

55 | * 56 | * @param jaxbElement is an object that {@link #isElement(Object)} returned true. 57 | * 58 | * @return xml element qname associated with jaxbElement; 59 | * null if jaxbElement is not a JAXBElement. 60 | */ 61 | public abstract QName getElementName(Object jaxbElement); 62 | 63 | /** 64 | *

Get the element value of a Jakarta XML Binding element.

65 | * 66 | *

Convenience method to abstract whether working with either 67 | * a jakarta.xml.bind.JAXBElement instance or an instance of 68 | * {@code @XmlRootElement} annotated Java class.

69 | * 70 | * @param jaxbElement object that #isElement(Object) returns true. 71 | * 72 | * @return The element value of the jaxbElement. 73 | */ 74 | public static Object getValue(Object jaxbElement) { 75 | if (jaxbElement instanceof JAXBElement) { 76 | return ((JAXBElement)jaxbElement).getValue(); 77 | } else { 78 | // assume that class of this instance is 79 | // annotated with @XmlRootElement. 80 | return jaxbElement; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/JAXBPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | import java.security.BasicPermission; 14 | 15 | /** 16 | * This class is for Jakarta XML Binding permissions. A {@code JAXBPermission} 17 | * contains a name (also referred to as a "target name") but 18 | * no actions list; you either have the named permission 19 | * or you don't. 20 | * 21 | *

22 | * The target name is the name of the Jakarta XML Binding permission (see below). 23 | * 24 | *

25 | * The following table lists all the possible {@code JAXBPermission} target names, 26 | * and for each provides a description of what the permission allows 27 | * and a discussion of the risks of granting code the permission. 28 | * 29 | * 30 | * 31 | * 32 | * 33 | * 34 | * 35 | * 36 | * 37 | * 38 | * 39 | * 40 | * 41 | * 42 | * 47 | * 54 | * 55 | * 56 | *
Permission target name, what the permission allows, and associated risks"
Permission Target NameWhat the Permission AllowsRisks of Allowing this Permission
setDatatypeConverter 43 | * Allows the code to set VM-wide {@link DatatypeConverterInterface} 44 | * via {@link DatatypeConverter#setDatatypeConverter(DatatypeConverterInterface) the setDatatypeConverter method} 45 | * that all the methods on {@link DatatypeConverter} uses. 46 | * 48 | * Malicious code can set {@link DatatypeConverterInterface}, which has 49 | * VM-wide singleton semantics, before a genuine Jakarta XML Binding implementation sets one. 50 | * This allows malicious code to gain access to objects that it may otherwise 51 | * not have access to, such as {@code java.awt.Frame#getFrames()} that belongs to 52 | * another application running in the same JVM. 53 | *
57 | * 58 | * @see java.security.BasicPermission 59 | * @see java.security.Permission 60 | * @see java.security.Permissions 61 | * @see java.security.PermissionCollection 62 | * @see java.lang.SecurityManager 63 | * 64 | * @author Joe Fialli 65 | * @since 1.7, JAXB 2.2 66 | */ 67 | 68 | /* code was borrowed originally from java.lang.RuntimePermission. */ 69 | public final class JAXBPermission extends BasicPermission { 70 | /** 71 | * Creates a new JAXBPermission with the specified name. 72 | * 73 | * @param name 74 | * The name of the JAXBPermission. As of 2.2 only "setDatatypeConverter" 75 | * is defined. 76 | */ 77 | public JAXBPermission(String name) { 78 | super(name); 79 | } 80 | 81 | private static final long serialVersionUID = 1L; 82 | } 83 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/MarshalException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This exception indicates that an error has occurred while performing 15 | * a marshal operation that the provider is unable to recover from. 16 | * 17 | *

18 | * The {@code ValidationEventHandler} can cause this exception to be thrown 19 | * during the marshal operations. See 20 | * {@link ValidationEventHandler#handleEvent(ValidationEvent) 21 | * ValidationEventHandler.handleEvent(ValidationEvent)}. 22 | * 23 | * @author

24 | * @see JAXBException 25 | * @see Marshaller 26 | * @since 1.6, JAXB 1.0 27 | */ 28 | public class MarshalException extends JAXBException { 29 | 30 | private static final long serialVersionUID = 1570397297836071517L; 31 | 32 | /** 33 | * Construct a MarshalException with the specified detail message. The 34 | * errorCode and linkedException will default to null. 35 | * 36 | * @param message a description of the exception 37 | */ 38 | public MarshalException( String message ) { 39 | this( message, null, null ); 40 | } 41 | 42 | /** 43 | * Construct a MarshalException with the specified detail message and vendor 44 | * specific errorCode. The linkedException will default to null. 45 | * 46 | * @param message a description of the exception 47 | * @param errorCode a string specifying the vendor specific error code 48 | */ 49 | public MarshalException( String message, String errorCode ) { 50 | this( message, errorCode, null ); 51 | } 52 | 53 | /** 54 | * Construct a MarshalException with a linkedException. The detail message and 55 | * vendor specific errorCode will default to null. 56 | * 57 | * @param exception the linked exception 58 | */ 59 | public MarshalException( Throwable exception ) { 60 | this( null, null, exception ); 61 | } 62 | 63 | /** 64 | * Construct a MarshalException with the specified detail message and 65 | * linkedException. The errorCode will default to null. 66 | * 67 | * @param message a description of the exception 68 | * @param exception the linked exception 69 | */ 70 | public MarshalException( String message, Throwable exception ) { 71 | this( message, null, exception ); 72 | } 73 | 74 | /** 75 | * Construct a MarshalException with the specified detail message, vendor 76 | * specific errorCode, and linkedException. 77 | * 78 | * @param message a description of the exception 79 | * @param errorCode a string specifying the vendor specific error code 80 | * @param exception the linked exception 81 | */ 82 | public MarshalException( String message, String errorCode, Throwable exception ) { 83 | super( message, errorCode, exception ); 84 | } 85 | 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/Messages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.ResourceBundle; 15 | 16 | /** 17 | * Formats error messages. 18 | */ 19 | class Messages 20 | { 21 | static String format( String property ) { 22 | return format( property, null ); 23 | } 24 | 25 | static String format( String property, Object arg1 ) { 26 | return format( property, new Object[]{arg1} ); 27 | } 28 | 29 | static String format( String property, Object arg1, Object arg2 ) { 30 | return format( property, new Object[]{arg1,arg2} ); 31 | } 32 | 33 | static String format( String property, Object arg1, Object arg2, Object arg3 ) { 34 | return format( property, new Object[]{arg1,arg2,arg3} ); 35 | } 36 | 37 | // add more if necessary. 38 | 39 | /** Loads a string resource and formats it with specified arguments. */ 40 | static String format( String property, Object[] args ) { 41 | String text = ResourceBundle.getBundle(Messages.class.getName()).getString(property); 42 | return MessageFormat.format(text,args); 43 | } 44 | 45 | // 46 | // 47 | // Message resources 48 | // 49 | // 50 | static final String PROVIDER_NOT_FOUND = // 1 arg 51 | "ContextFinder.ProviderNotFound"; 52 | 53 | static final String DEFAULT_PROVIDER_NOT_FOUND = // 0 args 54 | "ContextFinder.DefaultProviderNotFound"; 55 | 56 | static final String COULD_NOT_INSTANTIATE = // 2 args 57 | "ContextFinder.CouldNotInstantiate"; 58 | 59 | static final String CANT_FIND_PROPERTIES_FILE = // 1 arg 60 | "ContextFinder.CantFindPropertiesFile"; 61 | 62 | static final String CANT_MIX_PROVIDERS = // 0 args 63 | "ContextFinder.CantMixProviders"; 64 | 65 | static final String MISSING_PROPERTY = // 2 args 66 | "ContextFinder.MissingProperty"; 67 | 68 | static final String NO_PACKAGE_IN_CONTEXTPATH = // 0 args 69 | "ContextFinder.NoPackageInContextPath"; 70 | 71 | static final String NAME_VALUE = // 2 args 72 | "PropertyException.NameValue"; 73 | 74 | static final String CONVERTER_MUST_NOT_BE_NULL = // 0 args 75 | "DatatypeConverter.ConverterMustNotBeNull"; 76 | 77 | static final String ILLEGAL_CAST = // 2 args 78 | "JAXBContext.IllegalCast"; 79 | 80 | static final String ERROR_LOAD_CLASS = // 2 args 81 | "ContextFinder.ErrorLoadClass"; 82 | 83 | static final String JAXB_CLASSES_NOT_OPEN = // 1 arg 84 | "JAXBClasses.notOpen"; 85 | } 86 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/NotIdentifiableEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This event indicates that a problem was encountered resolving an ID/IDREF. 15 | * 16 | * 17 | * @author 18 | * @see ValidationEventHandler 19 | * @since 1.6, JAXB 1.0 20 | */ 21 | public interface NotIdentifiableEvent extends ValidationEvent { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/ParseConversionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This event indicates that a problem was encountered while converting a 15 | * string from the XML data into a value of the target Java data type. 16 | * 17 | * @author 18 | * @see ValidationEvent 19 | * @see ValidationEventHandler 20 | * @see Unmarshaller 21 | * @since 1.6, JAXB 1.0 22 | */ 23 | public interface ParseConversionEvent extends ValidationEvent { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/PrintConversionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This event indicates that a problem was encountered while converting data 15 | * from the Java content tree into its lexical representation. 16 | * 17 | * @author 18 | * @see ValidationEvent 19 | * @see ValidationEventHandler 20 | * @see Marshaller 21 | * @since 1.6, JAXB 1.0 22 | */ 23 | public interface PrintConversionEvent extends ValidationEvent { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/PropertyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | 14 | 15 | /** 16 | * This exception indicates that an error was encountered while getting or 17 | * setting a property. 18 | * 19 | * @author 20 | * @see JAXBContext 21 | * @see Unmarshaller 22 | * @since 1.6, JAXB 1.0 23 | */ 24 | public class PropertyException extends JAXBException { 25 | 26 | private static final long serialVersionUID = 3159963351607157477L; 27 | 28 | /** 29 | * Construct a PropertyException with the specified detail message. The 30 | * errorCode and linkedException will default to null. 31 | * 32 | * @param message a description of the exception 33 | */ 34 | public PropertyException(String message) { 35 | super(message); 36 | } 37 | 38 | /** 39 | * Construct a PropertyException with the specified detail message and 40 | * vendor specific errorCode. The linkedException will default to null. 41 | * 42 | * @param message a description of the exception 43 | * @param errorCode a string specifying the vendor specific error code 44 | */ 45 | public PropertyException(String message, String errorCode) { 46 | super(message, errorCode); 47 | } 48 | 49 | /** 50 | * Construct a PropertyException with a linkedException. The detail 51 | * message and vendor specific errorCode will default to null. 52 | * 53 | * @param exception the linked exception 54 | */ 55 | public PropertyException(Throwable exception) { 56 | super(exception); 57 | } 58 | 59 | /** 60 | * Construct a PropertyException with the specified detail message and 61 | * linkedException. The errorCode will default to null. 62 | * 63 | * @param message a description of the exception 64 | * @param exception the linked exception 65 | */ 66 | public PropertyException(String message, Throwable exception) { 67 | super(message, exception); 68 | } 69 | 70 | /** 71 | * Construct a PropertyException with the specified detail message, vendor 72 | * specific errorCode, and linkedException. 73 | * 74 | * @param message a description of the exception 75 | * @param errorCode a string specifying the vendor specific error code 76 | * @param exception the linked exception 77 | */ 78 | public PropertyException(String message, 79 | String errorCode, 80 | Throwable exception) { 81 | super(message, errorCode, exception); 82 | } 83 | 84 | /** 85 | * Construct a PropertyException whose message field is set based on the 86 | * name of the property and value.toString(). 87 | * 88 | * @param name the name of the property related to this exception 89 | * @param value the value of the property related to this exception 90 | */ 91 | public PropertyException(String name, Object value) { 92 | super( Messages.format( Messages.NAME_VALUE, 93 | name, 94 | value.toString() ) ); 95 | } 96 | 97 | 98 | } 99 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/SchemaOutputResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | import javax.xml.transform.Result; 14 | import java.io.IOException; 15 | 16 | /** 17 | * Controls where a Jakarta XML Binding implementation puts the generates 18 | * schema files. 19 | * 20 | *

21 | * An implementation of this abstract class has to be provided by the calling 22 | * application to generate schemas. 23 | * 24 | *

25 | * This is a class, not an interface to allow future versions to evolve 26 | * without breaking the compatibility. 27 | * 28 | * @author 29 | * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 30 | * @since 1.6 31 | */ 32 | public abstract class SchemaOutputResolver { 33 | 34 | /** 35 | * Do-nothing constructor for the derived classes. 36 | */ 37 | protected SchemaOutputResolver() {} 38 | 39 | /** 40 | * Decides where the schema file (of the given namespace URI) 41 | * will be written, and return it as a {@link Result} object. 42 | * 43 | *

44 | * This method is called only once for any given namespace. 45 | * IOW, all the components in one namespace is always written 46 | * into the same schema document. 47 | * 48 | * @param namespaceUri 49 | * The namespace URI that the schema declares. 50 | * Can be the empty string, but never be null. 51 | * @param suggestedFileName 52 | * A Jakarta XML Binding implementation generates a unique file name (like "schema1.xsd") 53 | * for the convenience of the callee. This name can be 54 | * used for the file name of the schema, or the callee can just 55 | * ignore this name and come up with its own name. 56 | * This is just a hint. 57 | * 58 | * @return 59 | * a {@link Result} object that encapsulates the actual destination 60 | * of the schema. 61 | *

62 | * If the {@link Result} object has a system ID, it must be an 63 | * absolute system ID. Those system IDs are relativized by the caller and used 64 | * for {@literal } statements. 65 | *

66 | * If the {@link Result} object does not have a system ID, a schema 67 | * for the namespace URI is generated but it won't be explicitly 68 | * {@literal }ed from other schemas. 69 | *

70 | * If {@code null} is returned, the schema generation for this 71 | * namespace URI will be skipped. 72 | */ 73 | public abstract Result createOutput( String namespaceUri, String suggestedFileName ) throws IOException; 74 | } 75 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/UnmarshalException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This exception indicates that an error has occurred while performing 15 | * an unmarshal operation that prevents the Jakarta XML Binding Provider from completing 16 | * the operation. 17 | * 18 | *

19 | * The {@code ValidationEventHandler} can cause this exception to be thrown 20 | * during the unmarshal operations. See 21 | * {@link ValidationEventHandler#handleEvent(ValidationEvent) 22 | * ValidationEventHandler.handleEvent(ValidationEvent)}. 23 | * 24 | * @author

25 | * @see JAXBException 26 | * @see Unmarshaller 27 | * @see ValidationEventHandler 28 | * @since 1.6, JAXB 1.0 29 | */ 30 | public class UnmarshalException extends JAXBException { 31 | 32 | private static final long serialVersionUID = 6121932693435295453L; 33 | 34 | /** 35 | * Construct an UnmarshalException with the specified detail message. The 36 | * errorCode and linkedException will default to null. 37 | * 38 | * @param message a description of the exception 39 | */ 40 | public UnmarshalException( String message ) { 41 | this( message, null, null ); 42 | } 43 | 44 | /** 45 | * Construct an UnmarshalException with the specified detail message and vendor 46 | * specific errorCode. The linkedException will default to null. 47 | * 48 | * @param message a description of the exception 49 | * @param errorCode a string specifying the vendor specific error code 50 | */ 51 | public UnmarshalException( String message, String errorCode ) { 52 | this( message, errorCode, null ); 53 | } 54 | 55 | /** 56 | * Construct an UnmarshalException with a linkedException. The detail message and 57 | * vendor specific errorCode will default to null. 58 | * 59 | * @param exception the linked exception 60 | */ 61 | public UnmarshalException( Throwable exception ) { 62 | this( null, null, exception ); 63 | } 64 | 65 | /** 66 | * Construct an UnmarshalException with the specified detail message and 67 | * linkedException. The errorCode will default to null. 68 | * 69 | * @param message a description of the exception 70 | * @param exception the linked exception 71 | */ 72 | public UnmarshalException( String message, Throwable exception ) { 73 | this( message, null, exception ); 74 | } 75 | 76 | /** 77 | * Construct an UnmarshalException with the specified detail message, vendor 78 | * specific errorCode, and linkedException. 79 | * 80 | * @param message a description of the exception 81 | * @param errorCode a string specifying the vendor specific error code 82 | * @param exception the linked exception 83 | */ 84 | public UnmarshalException( String message, String errorCode, Throwable exception ) { 85 | super( message, errorCode, exception ); 86 | } 87 | 88 | } 89 | 90 | 91 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/UnmarshallerHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | import org.xml.sax.ContentHandler; 14 | 15 | /** 16 | * Unmarshaller implemented as SAX ContentHandler. 17 | * 18 | *

19 | * Applications can use this interface to use their Jakarta XML Binding provider as a component 20 | * in an XML pipeline. For example: 21 | * 22 | * {@snippet : 23 | * JAXBContext context = JAXBContext.newInstance( "org.acme.foo" ); 24 | * 25 | * Unmarshaller unmarshaller = context.createUnmarshaller(); 26 | * 27 | * UnmarshallerHandler unmarshallerHandler = unmarshaller.getUnmarshallerHandler(); 28 | * 29 | * SAXParserFactory spf = SAXParserFactory.newInstance(); 30 | * spf.setNamespaceAware( true ); 31 | * 32 | * XMLReader xmlReader = spf.newSAXParser().getXMLReader(); 33 | * xmlReader.setContentHandler( unmarshallerHandler ); 34 | * xmlReader.parse(new InputSource( new FileInputStream( XML_FILE ) ) ); 35 | * 36 | * MyObject myObject= (MyObject)unmarshallerHandler.getResult(); 37 | * } 38 | * 39 | *

40 | * This interface is reusable: even if the user fails to unmarshal 41 | * an object, s/he can still start a new round of unmarshalling. 42 | * 43 | * @author

44 | * @see Unmarshaller#getUnmarshallerHandler() 45 | * @since 1.6, JAXB 1.0 46 | */ 47 | public interface UnmarshallerHandler extends ContentHandler 48 | { 49 | /** 50 | * Obtains the unmarshalled result. 51 | *

52 | * This method can be called only after this handler 53 | * receives the endDocument SAX event. 54 | * 55 | * @exception IllegalStateException 56 | * if this method is called before this handler 57 | * receives the endDocument event. 58 | * 59 | * @exception JAXBException 60 | * if there is any unmarshalling error. 61 | * Note that the implementation is allowed to throw SAXException 62 | * during the parsing when it finds an error. 63 | * 64 | * @return 65 | * always return a non-null valid object which was unmarshalled. 66 | */ 67 | Object getResult() throws JAXBException, IllegalStateException; 68 | } 69 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/ValidationEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This event indicates that a problem was encountered while validating the 15 | * incoming XML data during an unmarshal operation, while performing 16 | * on-demand validation of the Java content tree, or while marshalling the 17 | * Java content tree back to XML data. 18 | * 19 | * @author

20 | * @see ValidationEventHandler 21 | * @since 1.6, JAXB 1.0 22 | */ 23 | public interface ValidationEvent { 24 | 25 | /** 26 | * Conditions that are not errors or fatal errors as defined by the 27 | * XML 1.0 recommendation 28 | */ 29 | int WARNING = 0; 30 | 31 | /** 32 | * Conditions that correspond to the definition of "error" in section 33 | * 1.2 of the W3C XML 1.0 Recommendation 34 | */ 35 | int ERROR = 1; 36 | 37 | /** 38 | * Conditions that correspond to the definition of "fatal error" in section 39 | * 1.2 of the W3C XML 1.0 Recommendation 40 | */ 41 | int FATAL_ERROR = 2; 42 | 43 | /** 44 | * Retrieve the severity code for this warning/error. 45 | * 46 | *

47 | * Must be one of {@code ValidationEvent.WARNING}, 48 | * {@code ValidationEvent.ERROR}, or {@code ValidationEvent.FATAL_ERROR}. 49 | * 50 | * @return the severity code for this warning/error 51 | */ 52 | int getSeverity(); 53 | 54 | /** 55 | * Retrieve the text message for this warning/error. 56 | * 57 | * @return the text message for this warning/error or null if one wasn't set 58 | */ 59 | String getMessage(); 60 | 61 | /** 62 | * Retrieve the linked exception for this warning/error. 63 | * 64 | * @return the linked exception for this warning/error or null if one 65 | * wasn't set 66 | */ 67 | Throwable getLinkedException(); 68 | 69 | /** 70 | * Retrieve the locator for this warning/error. 71 | * 72 | * @return the locator that indicates where the warning/error occurred 73 | */ 74 | ValidationEventLocator getLocator(); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/ValidationEventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * A basic event handler interface for validation errors. 15 | * 16 | *

17 | * If an application needs to implement customized event handling, it must 18 | * implement this interface and then register it with either the 19 | * {@link Unmarshaller#setEventHandler(ValidationEventHandler) Unmarshaller}, or 20 | * the {@link Marshaller#setEventHandler(ValidationEventHandler) Marshaller}. 21 | * The Jakarta XML Binding Provider will then report validation errors and warnings encountered 22 | * during the unmarshal, marshal, and validate operations to these event 23 | * handlers. 24 | * 25 | *

26 | * If the {@code handleEvent} method throws an unchecked runtime exception, 27 | * the Jakarta XML Binding Provider must treat that as if the method returned false, effectively 28 | * terminating whatever operation was in progress at the time (unmarshal, 29 | * validate, or marshal). 30 | * 31 | *

32 | * Modifying the Java content tree within your event handler is undefined 33 | * by the specification and may result in unexpected behaviour. 34 | * 35 | *

36 | * Failing to return false from the {@code handleEvent} method after 37 | * encountering a fatal error is undefined by the specification and may result 38 | * in unexpected behavior. 39 | * 40 | *

41 | * Default Event Handler 42 | *

43 | * If the client application does not set an event handler on their 44 | * {@code Unmarshaller}, or {@code Marshaller} prior to 45 | * calling the validate, unmarshal, or marshal methods, then a default event 46 | * handler will receive notification of any errors or warnings encountered. 47 | * The default event handler will cause the current operation to halt after 48 | * encountering the first error or fatal error (but will attempt to continue 49 | * after receiving warnings). 50 | *
51 | * 52 | * @author 55 | * @see Unmarshaller 56 | * @see Marshaller 57 | * @see ValidationEvent 58 | * @see jakarta.xml.bind.util.ValidationEventCollector 59 | * @since 1.6, JAXB 1.0 60 | */ 61 | public interface ValidationEventHandler { 62 | /** 63 | * Receive notification of a validation warning or error. 64 | *

65 | * The ValidationEvent will have a 66 | * {@link ValidationEventLocator ValidationEventLocator} embedded in it that 67 | * indicates where the error or warning occurred. 68 | * 69 | *

70 | * If an unchecked runtime exception is thrown from this method, the Jakarta XML Binding 71 | * provider will treat it as if the method returned false and interrupt 72 | * the current unmarshal, validate, or marshal operation. 73 | * 74 | * @param event the encapsulated validation event information. It is a 75 | * provider error if this parameter is null. 76 | * @return true if the Jakarta XML Binding Provider should attempt to continue the current 77 | * unmarshal, validate, or marshal operation after handling this 78 | * warning/error, false if the provider should terminate the current 79 | * operation with the appropriate {@code UnmarshalException}, 80 | * {@code ValidationException}, or {@code MarshalException}. 81 | * @throws IllegalArgumentException if the event object is null. 82 | */ 83 | boolean handleEvent(ValidationEvent event); 84 | 85 | } 86 | 87 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/ValidationEventLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * Encapsulate the location of a ValidationEvent. 15 | * 16 | *

17 | * The {@code ValidationEventLocator} indicates where the {@code ValidationEvent} 18 | * occurred. Different fields will be set depending on the type of 19 | * validation that was being performed when the error or warning was detected. 20 | * For example, on-demand validation would produce locators that contained 21 | * references to objects in the Java content tree while unmarshal-time 22 | * validation would produce locators containing information appropriate to the 23 | * source of the XML data (file, url, Node, etc.). 24 | * 25 | * @author

28 | * @see ValidationEvent 29 | * @since 1.6, JAXB 1.0 30 | */ 31 | public interface ValidationEventLocator { 32 | 33 | /** 34 | * Return the name of the XML source as a URL if available 35 | * 36 | * @return the name of the XML source as a URL or null if unavailable 37 | */ 38 | java.net.URL getURL(); 39 | 40 | /** 41 | * Return the byte offset if available 42 | * 43 | * @return the byte offset into the input source or -1 if unavailable 44 | */ 45 | int getOffset(); 46 | 47 | /** 48 | * Return the line number if available 49 | * 50 | * @return the line number or -1 if unavailable 51 | */ 52 | int getLineNumber(); 53 | 54 | /** 55 | * Return the column number if available 56 | * 57 | * @return the column number or -1 if unavailable 58 | */ 59 | int getColumnNumber(); 60 | 61 | /** 62 | * Return a reference to the object in the Java content tree if available 63 | * 64 | * @return a reference to the object in the Java content tree or null if 65 | * unavailable 66 | */ 67 | java.lang.Object getObject(); 68 | 69 | /** 70 | * Return a reference to the DOM Node if available 71 | * 72 | * @return a reference to the DOM Node or null if unavailable 73 | */ 74 | org.w3c.dom.Node getNode(); 75 | 76 | } 77 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/ValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind; 12 | 13 | /** 14 | * This exception indicates that an error has occurred while performing 15 | * a validate operation. 16 | * 17 | *

18 | * The {@code ValidationEventHandler} can cause this exception to be thrown 19 | * during the validate operations. See 20 | * {@link ValidationEventHandler#handleEvent(ValidationEvent) 21 | * ValidationEventHandler.handleEvent(ValidationEvent)}. 22 | * 23 | * @author

24 | * @see JAXBException 25 | * @since 1.6, JAXB 1.0 26 | */ 27 | public class ValidationException extends JAXBException { 28 | 29 | private static final long serialVersionUID = 2206436657505193108L; 30 | 31 | /** 32 | * Construct an ValidationException with the specified detail message. The 33 | * errorCode and linkedException will default to null. 34 | * 35 | * @param message a description of the exception 36 | */ 37 | public ValidationException(String message) { 38 | this( message, null, null ); 39 | } 40 | 41 | /** 42 | * Construct an ValidationException with the specified detail message and vendor 43 | * specific errorCode. The linkedException will default to null. 44 | * 45 | * @param message a description of the exception 46 | * @param errorCode a string specifying the vendor specific error code 47 | */ 48 | public ValidationException(String message, String errorCode) { 49 | this( message, errorCode, null ); 50 | } 51 | 52 | /** 53 | * Construct an ValidationException with a linkedException. The detail message and 54 | * vendor specific errorCode will default to null. 55 | * 56 | * @param exception the linked exception 57 | */ 58 | public ValidationException(Throwable exception) { 59 | this( null, null, exception ); 60 | } 61 | 62 | /** 63 | * Construct an ValidationException with the specified detail message and 64 | * linkedException. The errorCode will default to null. 65 | * 66 | * @param message a description of the exception 67 | * @param exception the linked exception 68 | */ 69 | public ValidationException(String message, Throwable exception) { 70 | this( message, null, exception ); 71 | } 72 | 73 | /** 74 | * Construct an ValidationException with the specified detail message, vendor 75 | * specific errorCode, and linkedException. 76 | * 77 | * @param message a description of the exception 78 | * @param errorCode a string specifying the vendor specific error code 79 | * @param exception the linked exception 80 | */ 81 | public ValidationException(String message, String errorCode, Throwable exception) { 82 | super( message, errorCode, exception ); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/DomHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import jakarta.xml.bind.ValidationEventHandler; 14 | import javax.xml.transform.Result; 15 | import javax.xml.transform.Source; 16 | 17 | /** 18 | * Converts an element (and its descendants) 19 | * from/to DOM (or similar) representation. 20 | * 21 | *

22 | * Implementations of this interface will be used in conjunction with 23 | * {@link XmlAnyElement} annotation to map an element of XML into a representation 24 | * of infoset such as W3C DOM. 25 | * 26 | *

27 | * Implementations hide how a portion of XML is converted into/from such 28 | * DOM-like representation, allowing Jakarta XML Binding providers to work with arbitrary 29 | * such library. 30 | * 31 | *

32 | * This interface is intended to be implemented by library writers 33 | * and consumed by Jakarta XML Binding providers. None of those methods are intended to 34 | * be called from applications. 35 | * 36 | * @author Kohsuke Kawaguchi 37 | * @since 1.6, JAXB 2.0 38 | */ 39 | public interface DomHandler { 40 | /** 41 | * When a Jakarta XML Binding provider needs to unmarshal a part of a document into an 42 | * infoset representation, it first calls this method to create a 43 | * {@link Result} object. 44 | * 45 | *

46 | * A Jakarta XML Binding provider will then send a portion of the XML 47 | * into the given result. Such a portion always form a subtree 48 | * of the whole XML document rooted at an element. 49 | * 50 | * @param errorHandler 51 | * if any error happens between the invocation of this method 52 | * and the invocation of {@link #getElement(Result)}, they 53 | * must be reported to this handler. 54 | *

55 | * The caller must provide a non-null error handler. 56 | *

57 | * The {@link Result} object created from this method 58 | * may hold a reference to this error handler. 59 | * 60 | * @return 61 | * null if the operation fails. The error must have been reported 62 | * to the error handler. 63 | */ 64 | ResultT createUnmarshaller( ValidationEventHandler errorHandler ); 65 | 66 | /** 67 | * Once the portion is sent to the {@link Result}. This method is called 68 | * by a Jakarta XML Binding provider to obtain the unmarshalled element representation. 69 | * 70 | *

71 | * Multiple invocations of this method may return different objects. 72 | * This method can be invoked only when the whole subtree are fed 73 | * to the {@link Result} object. 74 | * 75 | * @param rt 76 | * The {@link Result} object created by {@link #createUnmarshaller(ValidationEventHandler)}. 77 | * 78 | * @return 79 | * null if the operation fails. The error must have been reported 80 | * to the error handler. 81 | */ 82 | ElementT getElement(ResultT rt); 83 | 84 | /** 85 | * This method is called when a Jakarta XML Binding provider needs to marshal an element 86 | * to XML. 87 | * 88 | *

89 | * If non-null, the returned {@link Source} must contain a whole document 90 | * rooted at one element, which will then be woven into a bigger document 91 | * that the Jakarta XML Binding provider is marshalling. 92 | * 93 | * @param errorHandler 94 | * Receives any errors happened during the process of converting 95 | * an element into a {@link Source}. 96 | *

97 | * The caller must provide a non-null error handler. 98 | * 99 | * @return 100 | * null if there was an error. The error should have been reported 101 | * to the handler. 102 | */ 103 | Source marshal( ElementT n, ValidationEventHandler errorHandler ); 104 | } 105 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/W3CDomHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import org.w3c.dom.Document; 14 | import org.w3c.dom.DocumentFragment; 15 | import org.w3c.dom.Element; 16 | import org.w3c.dom.Node; 17 | 18 | import jakarta.xml.bind.ValidationEventHandler; 19 | import javax.xml.parsers.DocumentBuilder; 20 | import javax.xml.transform.Source; 21 | import javax.xml.transform.dom.DOMResult; 22 | import javax.xml.transform.dom.DOMSource; 23 | 24 | /** 25 | * {@link DomHandler} implementation for W3C DOM (org.w3c.dom package.) 26 | * 27 | * @author Kohsuke Kawaguchi 28 | * @since 1.6, JAXB 2.0 29 | */ 30 | public class W3CDomHandler implements DomHandler { 31 | 32 | private DocumentBuilder builder; 33 | 34 | /** 35 | * Default constructor. 36 | *

37 | * It is up to a Jakarta XML Binding provider to decide which DOM implementation 38 | * to use or how that is configured. 39 | */ 40 | public W3CDomHandler() { 41 | this.builder = null; 42 | } 43 | 44 | /** 45 | * Constructor that allows applications to specify which DOM implementation 46 | * to be used. 47 | * 48 | * @param builder 49 | * must not be null. Jakarta XML Binding uses this {@link DocumentBuilder} to create 50 | * a new element. 51 | */ 52 | public W3CDomHandler(DocumentBuilder builder) { 53 | if(builder==null) 54 | throw new IllegalArgumentException(); 55 | this.builder = builder; 56 | } 57 | 58 | public DocumentBuilder getBuilder() { 59 | return builder; 60 | } 61 | 62 | public void setBuilder(DocumentBuilder builder) { 63 | this.builder = builder; 64 | } 65 | 66 | @Override 67 | public DOMResult createUnmarshaller(ValidationEventHandler errorHandler) { 68 | if(builder==null) 69 | return new DOMResult(); 70 | else 71 | return new DOMResult(builder.newDocument()); 72 | } 73 | 74 | @Override 75 | public Element getElement(DOMResult r) { 76 | // JAXP spec is ambiguous about what really happens in this case, 77 | // so work defensively 78 | Node n = r.getNode(); 79 | if( n instanceof Document ) { 80 | return ((Document)n).getDocumentElement(); 81 | } 82 | if( n instanceof Element ) 83 | return (Element)n; 84 | if( n instanceof DocumentFragment ) 85 | return (Element)n.getChildNodes().item(0); 86 | 87 | // if the result object contains something strange, 88 | // it is not a user problem, but it is a Jakarta XML Binding provider's problem. 89 | // That's why we throw a runtime exception. 90 | throw new IllegalStateException(n.toString()); 91 | } 92 | 93 | @Override 94 | public Source marshal(Element element, ValidationEventHandler errorHandler) { 95 | return new DOMSource(element); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlAccessOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | /** 14 | * Used by XmlAccessorOrder to control the ordering of properties and 15 | * fields in a Jakarta XML Binding bound class. 16 | * 17 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 18 | * @since 1.6, JAXB 2.0 19 | * @see XmlAccessorOrder 20 | */ 21 | 22 | public enum XmlAccessOrder { 23 | /** 24 | * The ordering of fields and properties in a class is undefined. 25 | */ 26 | UNDEFINED, 27 | /** 28 | * The ordering of fields and properties in a class is in 29 | * alphabetical order as determined by the 30 | * method java.lang.String.compareTo(String anotherString). 31 | */ 32 | ALPHABETICAL 33 | } 34 | 35 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlAccessType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | 14 | 15 | /** 16 | * Used by XmlAccessorType to control serialization of fields or 17 | * properties. 18 | * 19 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 20 | * @since 1.6, JAXB 2.0 21 | * @see XmlAccessorType 22 | */ 23 | 24 | public enum XmlAccessType { 25 | /** 26 | * Every getter/setter pair in a Jakarta XML Binding-bound class will be automatically 27 | * bound to XML, unless annotated by {@link XmlTransient}. 28 | *

29 | * Fields are bound to XML only when they are explicitly annotated 30 | * by some of the Jakarta XML Binding annotations. 31 | */ 32 | PROPERTY, 33 | /** 34 | * Every non-static, non-transient field in a Jakarta XML Binding-bound class will be automatically 35 | * bound to XML, unless annotated by {@link XmlTransient}. 36 | *

37 | * Getter/setter pairs are bound to XML only when they are explicitly annotated 38 | * by some of the Jakarta XML Binding annotations. 39 | */ 40 | FIELD, 41 | /** 42 | * Every public getter/setter pair and every public field will be 43 | * automatically bound to XML, unless annotated by {@link XmlTransient}. 44 | *

45 | * Fields or getter/setter pairs that are private, protected, or 46 | * defaulted to package-only access are bound to XML only when they are 47 | * explicitly annotated by the appropriate Jakarta XML Binding annotations. 48 | */ 49 | PUBLIC_MEMBER, 50 | /** 51 | * None of the fields or properties is bound to XML unless they 52 | * are specifically annotated with some of the Jakarta XML Binding annotations. 53 | */ 54 | NONE 55 | } 56 | 57 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlAccessorOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 14 | import java.lang.annotation.Target; 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.Inherited; 17 | 18 | import static java.lang.annotation.ElementType.*; 19 | import static java.lang.annotation.RetentionPolicy.*; 20 | 21 | /** 22 | *

Controls the ordering of fields and properties in a class.

23 | * 24 | *

Usage

25 | * 26 | *

{@code @XmlAccessorOrder} annotation can be used with the following 27 | * program elements:

28 | * 29 | * 33 | * 34 | *

See "Package Specification" in {@code jakarta.xml.bind} package javadoc for 35 | * additional common information.

36 | * 37 | *

The effective {@link XmlAccessOrder} on a class is determined 38 | * as follows: 39 | * 40 | *

50 | * 51 | *

This annotation can be used with the following annotations: 52 | * {@link XmlType}, {@link XmlRootElement}, {@link XmlAccessorType}, 53 | * {@link XmlSchema}, {@link XmlSchemaType}, {@link XmlSchemaTypes}, 54 | * {@link XmlJavaTypeAdapter}. It can also be used with the 55 | * following annotations at the package level: {@link XmlJavaTypeAdapter}. 56 | * 57 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 58 | * @since 1.6, JAXB 2.0 59 | * @see XmlAccessOrder 60 | */ 61 | 62 | @Inherited @Retention(RUNTIME) @Target({PACKAGE, TYPE}) 63 | public @interface XmlAccessorOrder { 64 | XmlAccessOrder value() default XmlAccessOrder.UNDEFINED; 65 | } 66 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlAccessorType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 14 | import java.lang.annotation.Target; 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.Inherited; 17 | 18 | import static java.lang.annotation.ElementType.*; 19 | import static java.lang.annotation.RetentionPolicy.*; 20 | 21 | /** 22 | *

Controls whether fields or Javabean properties are serialized by default.

23 | * 24 | *

Usage

25 | * 26 | *

{@code @XmlAccessorType} annotation can be used with the following program elements:

27 | * 28 | * 32 | * 33 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 34 | * additional common information.

35 | * 36 | *

This annotation provides control over the default serialization 37 | * of properties and fields in a class. 38 | * 39 | *

The annotation {@code @XmlAccessorType} on a package applies to 40 | * all classes in the package. The following inheritance 41 | * semantics apply: 42 | * 43 | *

51 | *

Defaulting Rules:

52 | * 53 | *

By default, if {@code @XmlAccessorType} on a package is absent, 54 | * then the following package level annotation is assumed.

55 | * {@snippet : 56 | * @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 57 | * } 58 | *

By default, if {@code @XmlAccessorType} on a class is absent, 59 | * and none of its super classes is annotated with 60 | * {@code @XmlAccessorType}, then the following default on the class 61 | * is assumed:

62 | * {@snippet : 63 | * @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 64 | * } 65 | *

This annotation can be used with the following annotations: 66 | * {@link XmlType}, {@link XmlRootElement}, {@link XmlAccessorOrder}, 67 | * {@link XmlSchema}, {@link XmlSchemaType}, {@link XmlSchemaTypes}, 68 | * , {@link XmlJavaTypeAdapter}. It can also be used with the 69 | * following annotations at the package level: {@link XmlJavaTypeAdapter}. 70 | * 71 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 72 | * @since 1.6, JAXB 2.0 73 | * @see XmlAccessType 74 | */ 75 | @Inherited @Retention(RUNTIME) @Target({PACKAGE, TYPE}) 76 | public @interface XmlAccessorType { 77 | 78 | /** 79 | * Specifies whether fields or properties are serialized. 80 | * 81 | * @see XmlAccessType 82 | */ 83 | XmlAccessType value() default XmlAccessType.PUBLIC_MEMBER; 84 | } 85 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlAnyAttribute.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import javax.xml.namespace.QName; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.Target; 16 | import java.util.Map; 17 | 18 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.METHOD; 21 | 22 | /** 23 | *

24 | * Maps a JavaBean property to a map of wildcard attributes. 25 | * 26 | *

Usage

27 | *

28 | * The {@code @XmlAnyAttribute} annotation can be used with the 29 | * following program elements: 30 | *

34 | * 35 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 36 | * additional common information.

37 | * 38 | * The usage is subject to the following constraints: 39 | * 44 | * 45 | *

46 | * While processing attributes to be unmarshalled into a value class, 47 | * each attribute that is not statically associated with another 48 | * JavaBean property, via {@link XmlAttribute}, is entered into the 49 | * wildcard attribute map represented by 50 | * {@link Map}<{@link QName},{@link Object}>. The attribute QName is the 51 | * map's key. The key's value is the String value of the attribute. 52 | * 53 | * @author Kohsuke Kawaguchi, Sun Microsystems, Inc. 54 | * @since 1.6, JAXB 2.0 55 | */ 56 | @Retention(RUNTIME) 57 | @Target({FIELD,METHOD}) 58 | public @interface XmlAnyAttribute { 59 | } 60 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlAttachmentRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import static java.lang.annotation.ElementType.FIELD; 14 | import static java.lang.annotation.ElementType.METHOD; 15 | import static java.lang.annotation.ElementType.PARAMETER; 16 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 17 | 18 | import java.lang.annotation.Retention; 19 | import java.lang.annotation.Target; 20 | 21 | import jakarta.activation.DataHandler; 22 | 23 | /** 24 | * Marks a field/property that its XML form is a URI reference to mime content. 25 | * The mime content is optimally stored out-of-line as an attachment. 26 | *

27 | * A field/property must always map to the {@link DataHandler} class. 28 | * 29 | *

Usage

30 | * {@snippet : 31 | * @XmlRootElement 32 | * class Foo { 33 | * @XmlAttachmentRef 34 | * @XmlAttribute 35 | * DataHandler data; 36 | * 37 | * @XmlAttachmentRef 38 | * @XmlElement 39 | * DataHandler body; 40 | * } 41 | * } 42 | * The above code maps to the following XML: 43 | * {@snippet lang="XML" : 44 | * 45 | * 46 | * 47 | * 48 | * 49 | * 50 | * 51 | * 52 | * } 53 | * 54 | *

55 | * The above binding supports WS-I AP 1.0 WS-I Attachments Profile Version 1.0. 56 | * 57 | * @author Kohsuke Kawaguchi 58 | * @since 1.6, JAXB 2.0 59 | */ 60 | @Retention(RUNTIME) 61 | @Target({FIELD,METHOD,PARAMETER}) 62 | public @interface XmlAttachmentRef { 63 | } 64 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlElementRefs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.Target; 16 | import static java.lang.annotation.ElementType.FIELD; 17 | import static java.lang.annotation.ElementType.METHOD; 18 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 19 | 20 | /** 21 | * Marks a property that refers to classes with {@link XmlElement} 22 | * or JAXBElement. 23 | * 24 | *

25 | * Compared to an element property (property with {@link XmlElement} 26 | * annotation), a reference property has a different substitution semantics. 27 | * When a subclass is assigned to a property, an element property produces 28 | * the same tag name with @xsi:type, whereas a reference property produces 29 | * a different tag name (the tag name that's on the subclass.) 30 | * 31 | *

This annotation can be used with the following annotations: 32 | * {@link XmlJavaTypeAdapter}, {@link XmlElementWrapper}. 33 | * 34 | * @author

35 | * 36 | * @see XmlElementWrapper 37 | * @see XmlElementRef 38 | * @since 1.6, JAXB 2.0 39 | */ 40 | @Retention(RUNTIME) 41 | @Target({FIELD,METHOD}) 42 | public @interface XmlElementRefs { 43 | XmlElementRef[] value(); 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlEnum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import static java.lang.annotation.ElementType.TYPE; 14 | import java.lang.annotation.Retention; 15 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | *

20 | * Maps an enum type {@link Enum} to XML representation. 21 | * 22 | *

This annotation, together with {@link XmlEnumValue} provides a 23 | * mapping of enum type to XML representation. 24 | * 25 | *

Usage

26 | *

27 | * The {@code @XmlEnum} annotation can be used with the 28 | * following program elements: 29 | *

32 | * 33 | *

The usage is subject to the following constraints: 34 | *

39 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 40 | * additional common information

41 | * 42 | *

An enum type is mapped to a schema simple type with enumeration 43 | * facets. The schema type is derived from the Java type to which 44 | * {@code @XmlEnum.value()}. Each enum constant {@code @XmlEnumValue} 45 | * must have a valid lexical representation for the type 46 | * {@code @XmlEnum.value()}. 47 | * 48 | *

Examples: See examples in {@link XmlEnumValue} 49 | * 50 | * @since 1.6, JAXB 2.0 51 | */ 52 | @Retention(RUNTIME) @Target({TYPE}) 53 | public @interface XmlEnum { 54 | /** 55 | * Java type that is mapped to an XML simple type. 56 | * 57 | */ 58 | Class value() default String.class; 59 | } 60 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlEnumValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.Target; 15 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 16 | import static java.lang.annotation.ElementType.FIELD; 17 | 18 | /** 19 | * Maps an enum constant in {@link Enum} type to XML representation. 20 | * 21 | *

Usage

22 | * 23 | *

The {@code @XmlEnumValue} annotation can be used with the 24 | * following program elements: 25 | *

28 | * 29 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 30 | * additional common information.

31 | * 32 | *

This annotation, together with {@link XmlEnum} provides a 33 | * mapping of enum type to XML representation. 34 | * 35 | *

An enum type is mapped to a schema simple type with enumeration 36 | * facets. The schema type is derived from the Java type specified in 37 | * {@code @XmlEnum.value()}. Each enum constant {@code @XmlEnumValue} 38 | * must have a valid lexical representation for the type 39 | * {@code @XmlEnum.value()} 40 | * 41 | *

In the absence of this annotation, {@link Enum#name()} is used 42 | * as the XML representation. 43 | * 44 | *

Example 1: Map enum constant name {@literal ->} enumeration facet

45 | * {@snippet : 46 | * //Example: Code fragment 47 | * @XmlEnum(String.class) 48 | * public enum Card { CLUBS, DIAMONDS, HEARTS, SPADES } 49 | * } 50 | * {@snippet lang="XML" : 51 | * 52 | * 53 | * 54 | * 55 | * 56 | * 57 | * 58 | 59 | * 60 | * } 61 | * 62 | *

Example 2: Map enum constant name(value) {@literal ->} enumeration facet

63 | * {@snippet : 64 | * //Example: code fragment 65 | * @XmlType 66 | * @XmlEnum(Integer.class) 67 | * public enum Coin { 68 | * @XmlEnumValue("1") PENNY(1), 69 | * @XmlEnumValue("5") NICKEL(5), 70 | * @XmlEnumValue("10") DIME(10), 71 | * @XmlEnumValue("25") QUARTER(25) 72 | * } 73 | * } 74 | * {@snippet lang="XML" : 75 | * 76 | * 77 | * 78 | * 79 | * 80 | * 81 | * 82 | * 83 | * 84 | * } 85 | * 86 | *

Example 3: Map enum constant name {@literal ->} enumeration facet

87 | * 88 | * {@snippet : 89 | * //Code fragment 90 | * @XmlType 91 | * @XmlEnum(Integer.class) 92 | * public enum Code { 93 | * @XmlEnumValue("1") ONE, 94 | * @XmlEnumValue("2") TWO 95 | * } 96 | * } 97 | * {@snippet lang="XML" : 98 | * 99 | * 100 | * 101 | * 102 | * 103 | * 104 | * 105 | * } 106 | * 107 | * @since 1.6, JAXB 2.0 108 | */ 109 | @Retention(RUNTIME) 110 | @Target({FIELD}) 111 | public @interface XmlEnumValue { 112 | String value(); 113 | } 114 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlID.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Target; 14 | import java.lang.annotation.Retention; 15 | import static java.lang.annotation.ElementType.*; 16 | import static java.lang.annotation.RetentionPolicy.*; 17 | 18 | /** 19 | *

20 | * Maps a JavaBean property to XML ID. 21 | * 22 | *

23 | * To preserve referential integrity of an object graph across XML 24 | * serialization followed by an XML deserialization, requires an object 25 | * reference to be marshalled by reference or containment 26 | * appropriately. Annotations {@code @XmlID} and {@code @XmlIDREF} 27 | * together allow a customized mapping of a JavaBean property's 28 | * type by containment or reference. 29 | * 30 | *

Usage

31 | * The {@code @XmlID} annotation can be used with the following 32 | * program elements: 33 | * 37 | * 38 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 39 | * additional common information.

40 | * 41 | * The usage is subject to the following constraints: 42 | * 50 | * 51 | *

Example: Map a JavaBean property's type to {@code xs:ID}

52 | * {@snippet : 53 | * // Example: code fragment 54 | * public class Customer { 55 | * @XmlAttribute 56 | * @XmlID 57 | * public String getCustomerID(); 58 | * public void setCustomerID(String id); 59 | * .... other properties not shown 60 | * } 61 | * } 62 | * {@snippet lang="XML" : 63 | * 64 | * 65 | * 66 | * 67 | * .... 68 | * 69 | * 70 | * 71 | * 72 | * } 73 | * 74 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 75 | * @see XmlIDREF 76 | * @since 1.6, JAXB 2.0 77 | */ 78 | @Retention(RUNTIME) @Target({FIELD, METHOD}) 79 | public @interface XmlID { } 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlInlineBinaryData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.Target; 15 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 16 | import static java.lang.annotation.ElementType.FIELD; 17 | import static java.lang.annotation.ElementType.METHOD; 18 | import static java.lang.annotation.ElementType.TYPE; 19 | 20 | import javax.xml.transform.Source; 21 | import jakarta.xml.bind.attachment.AttachmentMarshaller; 22 | import jakarta.activation.DataHandler; 23 | 24 | /** 25 | * Disable consideration of XOP encoding for datatypes that are bound to 26 | * base64-encoded binary data in XML. 27 | * 28 | *

29 | * When XOP encoding is enabled as described in {@link AttachmentMarshaller#isXOPPackage()}, 30 | * this annotation disables datatypes such as {@code java.awt.Image} or {@link Source} 31 | * or {@code byte[]} that are bound to base64-encoded binary from being considered for 32 | * XOP encoding. If a Jakarta XML Binding property is annotated with this annotation or if 33 | * the Jakarta XML Binding property's base type is annotated with this annotation, 34 | * neither 35 | * {@link AttachmentMarshaller#addMtomAttachment(DataHandler, String, String)} 36 | * nor 37 | * {@link AttachmentMarshaller#addMtomAttachment(byte[], int, int, String, String, String)} is 38 | * ever called for the property. The binary data will always be inlined. 39 | * 40 | * @author Joseph Fialli 41 | * @since 1.6, JAXB 2.0 42 | */ 43 | @Retention(RUNTIME) 44 | @Target({FIELD,METHOD,TYPE}) 45 | public @interface XmlInlineBinaryData { 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.Target; 15 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 16 | import static java.lang.annotation.ElementType.FIELD; 17 | import static java.lang.annotation.ElementType.METHOD; 18 | import static java.lang.annotation.ElementType.PARAMETER; 19 | 20 | /** 21 | * Used to map a property to a list simple type. 22 | * 23 | *

Usage

24 | *

25 | * The {@code @XmlList} annotation can be used with the 26 | * following program elements: 27 | *

31 | * 32 | *

33 | * When a collection property is annotated just with @XmlElement, 34 | * each item in the collection will be wrapped by an element. 35 | * For example, 36 | * 37 | * {@snippet : 38 | * @XmlRootElement 39 | * class Foo { 40 | * @XmlElement 41 | * List data; 42 | * } 43 | * } 44 | * 45 | * would produce XML like this: 46 | * 47 | * {@snippet lang="XML" : 48 | * 49 | * abc 50 | * def 51 | * 52 | * } 53 | * 54 | * XmlList annotation, on the other hand, allows multiple values to be 55 | * represented as whitespace-separated tokens in a single element. For example, 56 | * 57 | * {@snippet : 58 | * @XmlRootElement 59 | * class Foo { 60 | * @XmlElement 61 | * @XmlList 62 | * List data; 63 | * } 64 | * } 65 | * 66 | * the above code will produce XML like this: 67 | * 68 | * {@snippet lang="XML" : 69 | * 70 | * abc def 71 | * 72 | * } 73 | * 74 | *

This annotation can be used with the following annotations: 75 | * {@link XmlElement}, 76 | * {@link XmlAttribute}, 77 | * {@link XmlValue}, 78 | * {@link XmlIDREF}. 79 | *

90 | * 91 | * @author 92 | * @since 1.6, JAXB 2.0 93 | */ 94 | @Retention(RUNTIME) @Target({FIELD,METHOD,PARAMETER}) 95 | public @interface XmlList { 96 | } 97 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlMimeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.Target; 15 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 16 | import static java.lang.annotation.ElementType.FIELD; 17 | import static java.lang.annotation.ElementType.METHOD; 18 | import static java.lang.annotation.ElementType.PARAMETER; 19 | 20 | import javax.xml.transform.Source; 21 | 22 | /** 23 | * Associates the MIME type that controls the XML representation of the property. 24 | * 25 | *

26 | * This annotation is used in conjunction with datatypes such as 27 | * {@code java.awt.Image} or {@link Source} that are bound to base64-encoded binary in XML. 28 | * 29 | *

30 | * If a property that has this annotation has a sibling property bound to 31 | * the xmime:contentType attribute, and if in the instance the property has a value, 32 | * the value of the attribute takes precedence and that will control the marshalling. 33 | * 34 | * @author Kohsuke Kawaguchi 35 | * @since 1.6, JAXB 2.0 36 | */ 37 | @Retention(RUNTIME) 38 | @Target({FIELD,METHOD,PARAMETER}) 39 | public @interface XmlMimeType { 40 | /** 41 | * The textual representation of the MIME type, 42 | * such as "image/jpeg" "image/*", "text/xml; charset=iso-8859-1" and so on. 43 | */ 44 | String value(); 45 | } 46 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlNs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 15 | import java.lang.annotation.Target; 16 | 17 | /** 18 | *

19 | * Associates a namespace prefix with an XML namespace URI. 20 | * 21 | *

Usage

22 | *

{@code @XmlNs} annotation is intended for use from other 23 | * program annotations. 24 | * 25 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 26 | * additional common information.

27 | * 28 | *

Example:See {@code XmlSchema} annotation type for an example. 29 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 30 | * @since 1.6, JAXB 2.0 31 | */ 32 | @Retention(RUNTIME) @Target({}) 33 | public @interface XmlNs { 34 | /** 35 | * Namespace prefix 36 | */ 37 | String prefix(); 38 | 39 | /** 40 | * Namespace URI 41 | */ 42 | String namespaceURI(); 43 | } 44 | 45 | 46 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlNsForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | /** 14 | * Enumeration of XML Schema namespace qualifications. 15 | * 16 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 17 | * additional common information.

18 | * 19 | *

Usage 20 | *

21 | * The namespace qualification values are used in the annotations 22 | * defined in this package. The enumeration values are mapped as follows: 23 | * 24 | * 25 | * 26 | * 27 | * 28 | * 29 | * 30 | * 31 | * 32 | * 33 | * 34 | * 35 | * 36 | * 37 | * 38 | * 39 | * 40 | * 41 | * 42 | * 43 | * 44 | * 46 | * 47 | * 48 | *
Mapping of enumeration values
Enum ValueXML Schema Value
UNQUALIFIEDunqualified
QUALIFIEDqualified
UNSETnamespace qualification attribute is absent from the 45 | * XML Schema fragment
49 | * 50 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 51 | * @since 1.6, JAXB 2.0 52 | */ 53 | public enum XmlNsForm {UNQUALIFIED, QUALIFIED, UNSET} 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.Target; 15 | import static java.lang.annotation.ElementType.TYPE; 16 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 17 | 18 | /** 19 | * Marks a class that has {@link XmlElementDecl}s. 20 | * 21 | * @author

22 | * @since 1.6, JAXB 2.0 23 | * @see XmlElementDecl 24 | */ 25 | @Retention(RUNTIME) 26 | @Target({TYPE}) 27 | public @interface XmlRegistry { 28 | } 29 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlSchemaType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Retention; 14 | import java.lang.annotation.Target; 15 | 16 | import static java.lang.annotation.ElementType.FIELD; 17 | import static java.lang.annotation.ElementType.METHOD; 18 | import static java.lang.annotation.ElementType.PACKAGE; 19 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 | 21 | /** 22 | * Maps a Java type to a simple schema built-in type. 23 | * 24 | *

Usage

25 | *

26 | * {@code @XmlSchemaType} annotation can be used with the following program 27 | * elements: 28 | *

33 | * 34 | *

{@code @XmlSchemaType} annotation defined for Java type 35 | * applies to all references to the Java type from a property/field. 36 | * A {@code @XmlSchemaType} annotation specified on the 37 | * property/field overrides the {@code @XmlSchemaType} annotation 38 | * specified at the package level. 39 | * 40 | *

This annotation can be used with the following annotations: 41 | * {@link XmlElement}, {@link XmlAttribute}. 42 | *

43 | * Example 1: Customize mapping of XMLGregorianCalendar on the 44 | * field. 45 | * 46 | * {@snippet : 47 | * //Example: Code fragment 48 | * public class USPrice { 49 | * @XmlElement 50 | * @XmlSchemaType(name="date") 51 | * public XMLGregorianCalendar date; 52 | * } 53 | * } 54 | * {@snippet lang="XML" : 55 | * 56 | * 57 | * 58 | * 59 | * 60 | * 61 | * } 62 | * 63 | *

Example 2: Customize mapping of XMLGregorianCalendar at package 64 | * level

65 | * {@snippet : 66 | * @jakarta.xml.bind.annotation.XmlSchemaType( 67 | * name="date", type=javax.xml.datatype.XMLGregorianCalendar.class) 68 | * package foo; 69 | * } 70 | * 71 | * @since 1.6, JAXB 2.0 72 | */ 73 | @Retention(RUNTIME) @Target({FIELD,METHOD,PACKAGE}) 74 | public @interface XmlSchemaType { 75 | String name(); 76 | String namespace() default "http://www.w3.org/2001/XMLSchema"; 77 | /** 78 | * If this annotation is used at the package level, then value of 79 | * the type() must be specified. 80 | */ 81 | 82 | Class type() default DEFAULT.class; 83 | 84 | /** 85 | * Used in {@link XmlSchemaType#type()} to 86 | * signal that the type be inferred from the signature 87 | * of the property. 88 | */ 89 | 90 | final class DEFAULT { 91 | private DEFAULT() {} 92 | } 93 | 94 | } 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlSchemaTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 14 | import static java.lang.annotation.ElementType.PACKAGE; 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | *

20 | * A container for multiple {@link XmlSchemaType} annotations. 21 | * 22 | *

Multiple annotations of the same type are not allowed on a program 23 | * element. This annotation therefore serves as a container annotation 24 | * for multiple {@link XmlSchemaType} annotations as follows: 25 | * 26 | * {@snippet : 27 | * @XmlSchemaTypes({ @XmlSchemaType(...), @XmlSchemaType(...) }) 28 | * } 29 | *

The {@code @XmlSchemaTypes} annotation can be used to 30 | * define {@link XmlSchemaType} for different types at the 31 | * package level. 32 | * 33 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 34 | * additional common information.

35 | * 36 | * @author 37 | * @see XmlSchemaType 38 | * @since 1.6, JAXB 2.0 39 | */ 40 | @Retention(RUNTIME) @Target({PACKAGE}) 41 | public @interface XmlSchemaTypes { 42 | /** 43 | * Collection of @{@link XmlSchemaType} annotations 44 | */ 45 | XmlSchemaType[] value(); 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlSeeAlso.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import java.lang.annotation.ElementType; 15 | import java.lang.annotation.Retention; 16 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 17 | import java.lang.annotation.Target; 18 | 19 | /** 20 | * Instructs Jakarta XML Binding to also bind other classes when binding this class. 21 | * 22 | *

23 | * Java makes it impractical/impossible to list all subclasses of 24 | * a given class. This often gets in a way of Jakarta XML Binding users, as it Jakarta XML Binding 25 | * cannot automatically list up the classes that need to be known 26 | * to {@link JAXBContext}. 27 | * 28 | *

29 | * For example, with the following class definitions: 30 | * 31 | * {@snippet : 32 | * class Animal {} 33 | * class Dog extends Animal {} 34 | * class Cat extends Animal {} 35 | * } 36 | * 37 | *

38 | * The user would be required to create {@link JAXBContext} as 39 | * {@code JAXBContext.newInstance(Dog.class,Cat.class)} 40 | * ({@code Animal} will be automatically picked up since {@code Dog} 41 | * and {@code Cat} refers to it.) 42 | * 43 | *

44 | * {@link XmlSeeAlso} annotation would allow you to write: 45 | * {@snippet : 46 | * @XmlSeeAlso({Dog.class,Cat.class}) 47 | * class Animal {} 48 | * class Dog extends Animal {} 49 | * class Cat extends Animal {} 50 | * } 51 | * 52 | *

53 | * This would allow you to do {@code JAXBContext.newInstance(Animal.class)}. 54 | * By the help of this annotation, Jakarta XML Binding implementations will be able to 55 | * correctly bind {@code Dog} and {@code Cat}. 56 | * 57 | * @author Kohsuke Kawaguchi 58 | * @since 1.6, JAXB 2.1 59 | */ 60 | @Target({ElementType.TYPE}) 61 | @Retention(RUNTIME) 62 | public @interface XmlSeeAlso { 63 | Class[] value(); 64 | } 65 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlTransient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Target; 14 | import java.lang.annotation.Retention; 15 | import static java.lang.annotation.ElementType.*; 16 | import static java.lang.annotation.RetentionPolicy.*; 17 | 18 | /** 19 | *

20 | * Prevents the mapping of a JavaBean property/type to XML representation. 21 | *

22 | * The {@code @XmlTransient} annotation is useful for resolving name 23 | * collisions between a JavaBean property name and a field name or 24 | * preventing the mapping of a field/property. A name collision can 25 | * occur when the decapitalized JavaBean property name and a field 26 | * name are the same. If the JavaBean property refers to the field, 27 | * then the name collision can be resolved by preventing the 28 | * mapping of either the field or the JavaBean property using the 29 | * {@code @XmlTransient} annotation. 30 | * 31 | *

32 | * When placed on a class, it indicates that the class shouldn't be mapped 33 | * to XML by itself. Properties on such class will be mapped to XML along 34 | * with its derived classes, as if the class is inlined. 35 | * 36 | *

Usage

37 | *

The {@code @XmlTransient} annotation can be used with the following 38 | * program elements: 39 | *

44 | * 45 | *

{@code @XmlTransient} is mutually exclusive with all other 46 | * Jakarta XML Binding defined annotations.

47 | * 48 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 49 | * additional common information.

50 | * 51 | *

Example: Resolve name collision between JavaBean property and 52 | * field name

53 | * 54 | * {@snippet : 55 | * // Example: Code fragment 56 | * public class USAddress { 57 | * 58 | * // The field name "name" collides with the property name 59 | * // obtained by bean decapitalization of getName() below 60 | * @XmlTransient public String name; 61 | * 62 | * String getName() {..}; 63 | * String setName() {..}; 64 | * } 65 | * } 66 | * {@snippet lang="XML" : 67 | * 68 | * 69 | * 70 | * 71 | * 72 | * 73 | * } 74 | * 75 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 76 | * @since 1.6, JAXB 2.0 77 | */ 78 | @Retention(RUNTIME) @Target({FIELD, METHOD, TYPE}) 79 | public @interface XmlTransient {} 80 | 81 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/XmlValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation; 12 | 13 | import java.lang.annotation.Target; 14 | import java.lang.annotation.Retention; 15 | import static java.lang.annotation.ElementType.*; 16 | import static java.lang.annotation.RetentionPolicy.*; 17 | 18 | /** 19 | *

20 | * Enables mapping a class to a XML Schema complex type with a 21 | * simpleContent or an XML Schema simple type. 22 | *

23 | * 24 | *

25 | * Usage: 26 | *

27 | * The {@code @XmlValue} annotation can be used with the following program 28 | * elements: 29 | *

33 | * 34 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 35 | * additional common information.

36 | * 37 | * The usage is subject to the following usage constraints: 38 | * 55 | *

56 | * If the annotated JavaBean property is the sole class member being 57 | * mapped to XML Schema construct, then the class is mapped to a 58 | * simple type. 59 | *

60 | * If there are additional JavaBean properties (other than the 61 | * JavaBean property annotated with {@code @XmlValue} annotation) 62 | * that are mapped to XML attributes, then the class is mapped to a 63 | * complex type with simpleContent. 64 | *

65 | * 66 | *

Example 1: Map a class to XML Schema simpleType

67 | * 68 | * {@snippet : 69 | * // Example 1: Code fragment 70 | * public class USPrice { 71 | * @XmlValue 72 | * public java.math.BigDecimal price; 73 | * } 74 | * } 75 | * {@snippet lang="XML" : 76 | * 77 | * 78 | * 79 | * 80 | * } 81 | * 82 | *

Example 2: Map a class to XML Schema complexType with 83 | * with simpleContent.

84 | * 85 | * {@snippet : 86 | * // Example 2: Code fragment 87 | * public class InternationalPrice { 88 | * @XmlValue 89 | * public java.math.BigDecimal price; 90 | * 91 | * @XmlAttribute 92 | * public String currency; 93 | * } 94 | * } 95 | * {@snippet lang="XML" : 96 | * 97 | * 98 | * 99 | * 100 | * 101 | * 102 | * 103 | * 104 | * } 105 | * 106 | * @author Sekhar Vajjhala, Sun Microsystems, Inc. 107 | * @see XmlType 108 | * @since 1.6, JAXB 2.0 109 | */ 110 | @Retention(RUNTIME) @Target({FIELD, METHOD}) 111 | public @interface XmlValue {} 112 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/adapters/CollapsedStringAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation.adapters; 12 | 13 | /** 14 | * Built-in {@link XmlAdapter} to handle {@code xs:token} and its derived types. 15 | * 16 | *

17 | * This adapter removes leading and trailing whitespaces, then truncate any 18 | * sequence of tab, CR, LF, and SP by a single whitespace character ' '. 19 | * 20 | * @author Kohsuke Kawaguchi 21 | * @since 1.6, JAXB 2.0 22 | */ 23 | public class CollapsedStringAdapter extends XmlAdapter { 24 | 25 | public CollapsedStringAdapter() {} 26 | 27 | /** 28 | * Removes leading and trailing whitespaces of the string 29 | * given as the parameter, then truncate any 30 | * sequence of tab, CR, LF, and SP by a single whitespace character ' '. 31 | */ 32 | @Override 33 | public String unmarshal(String text) { 34 | if(text==null) return null; // be defensive 35 | 36 | int len = text.length(); 37 | 38 | // most of the texts are already in the collapsed form. 39 | // so look for the first whitespace in the hope that we will 40 | // never see it. 41 | int s=0; 42 | while(s 0 && result.charAt(len - 1) == ' ') 79 | result.setLength(len - 1); 80 | // whitespaces are already collapsed, 81 | // so all we have to do is to remove the last one character 82 | // if it's a whitespace. 83 | 84 | return result.toString(); 85 | } 86 | 87 | /** 88 | * No-op. 89 | *

90 | * Just return the same string given as the parameter. 91 | */ 92 | @Override 93 | public String marshal(String s) { 94 | return s; 95 | } 96 | 97 | 98 | /** returns true if the specified char is a white space character. */ 99 | protected static boolean isWhiteSpace(char ch) { 100 | // most of the characters are non-control characters. 101 | // so check that first to quickly return false for most of the cases. 102 | if( ch>0x20 ) return false; 103 | 104 | // other than we have to do four comparisons. 105 | return ch == 0x9 || ch == 0xA || ch == 0xD || ch == 0x20; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/adapters/HexBinaryAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation.adapters; 12 | 13 | import jakarta.xml.bind.DatatypeConverter; 14 | 15 | /** 16 | * {@link XmlAdapter} for {@code xs:hexBinary}. 17 | * 18 | *

19 | * This {@link XmlAdapter} binds {@code byte[]} to the hexBinary representation in XML. 20 | * 21 | * @author Kohsuke Kawaguchi 22 | * @since 1.6, JAXB 2.0 23 | */ 24 | public final class HexBinaryAdapter extends XmlAdapter { 25 | 26 | public HexBinaryAdapter() {} 27 | 28 | @Override 29 | public byte[] unmarshal(String s) { 30 | if(s==null) return null; 31 | return DatatypeConverter.parseHexBinary(s); 32 | } 33 | 34 | @Override 35 | public String marshal(byte[] bytes) { 36 | if(bytes==null) return null; 37 | return DatatypeConverter.printHexBinary(bytes); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/adapters/NormalizedStringAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation.adapters; 12 | 13 | /** 14 | * {@link XmlAdapter} to handle {@code xs:normalizedString}. 15 | * 16 | *

17 | * Replaces any tab, CR, and LF by a whitespace character ' ', 18 | * as specified in the whitespace facet 'replace' 19 | * 20 | * @author Kohsuke Kawaguchi, Martin Grebac 21 | * @since 1.6, JAXB 2.0 22 | */ 23 | public final class NormalizedStringAdapter extends XmlAdapter { 24 | 25 | public NormalizedStringAdapter() {} 26 | 27 | /** 28 | * Replace any tab, CR, and LF by a whitespace character ' ', 29 | * as specified in the whitespace facet 'replace' 30 | */ 31 | @Override 32 | public String unmarshal(String text) { 33 | if(text==null) return null; // be defensive 34 | 35 | int i=text.length()-1; 36 | 37 | // look for the first whitespace char. 38 | while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) ) 39 | i--; 40 | 41 | if( i<0 ) 42 | // no such whitespace. replace(text)==text. 43 | return text; 44 | 45 | // we now know that we need to modify the text. 46 | // allocate a char array to do it. 47 | char[] buf = text.toCharArray(); 48 | 49 | buf[i--] = ' '; 50 | for( ; i>=0; i-- ) 51 | if( isWhiteSpaceExceptSpace(buf[i])) 52 | buf[i] = ' '; 53 | 54 | return new String(buf); 55 | } 56 | 57 | /** 58 | * No-op. 59 | * Just return the same string given as the parameter. 60 | */ 61 | @Override 62 | public String marshal(String s) { 63 | return s; 64 | } 65 | 66 | 67 | /** 68 | * Returns true if the specified char is a white space character 69 | * but not 0x20. 70 | */ 71 | protected static boolean isWhiteSpaceExceptSpace(char ch) { 72 | // most of the characters are non-control characters. 73 | // so check that first to quickly return false for most of the cases. 74 | if( ch>=0x20 ) return false; 75 | 76 | // other than we have to do four comparisons. 77 | return ch == 0x9 || ch == 0xA || ch == 0xD; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation.adapters; 12 | 13 | import jakarta.xml.bind.annotation.XmlAnyElement; 14 | import jakarta.xml.bind.annotation.XmlElementRefs; 15 | import jakarta.xml.bind.annotation.XmlElement; 16 | import jakarta.xml.bind.annotation.XmlSchemaType; 17 | import jakarta.xml.bind.annotation.XmlElementRef; 18 | import jakarta.xml.bind.annotation.XmlAttribute; 19 | import jakarta.xml.bind.annotation.XmlSchema; 20 | import jakarta.xml.bind.annotation.XmlAccessorType; 21 | import jakarta.xml.bind.annotation.XmlSchemaTypes; 22 | import java.lang.annotation.Target; 23 | import java.lang.annotation.Retention; 24 | 25 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 26 | import static java.lang.annotation.ElementType.FIELD; 27 | import static java.lang.annotation.ElementType.METHOD; 28 | import static java.lang.annotation.ElementType.TYPE; 29 | import static java.lang.annotation.ElementType.PARAMETER; 30 | import static java.lang.annotation.ElementType.PACKAGE; 31 | 32 | 33 | /** 34 | * Use an adapter that implements {@link XmlAdapter} for custom marshaling. 35 | * 36 | *

Usage:

37 | * 38 | *

The {@code @XmlJavaTypeAdapter} annotation can be used with the 39 | * following program elements: 40 | *

47 | * 48 | *

When {@code @XmlJavaTypeAdapter} annotation is defined on a 49 | * class, it applies to all references to the class. 50 | *

When {@code @XmlJavaTypeAdapter} annotation is defined at the 51 | * package level it applies to all references from within the package 52 | * to {@code @XmlJavaTypeAdapter.type()}. 53 | *

When {@code @XmlJavaTypeAdapter} annotation is defined on the 54 | * field, property or parameter, then the annotation applies to the 55 | * field, property or the parameter only. 56 | *

A {@code @XmlJavaTypeAdapter} annotation on a field, property 57 | * or parameter overrides the {@code @XmlJavaTypeAdapter} annotation 58 | * associated with the class being referenced by the field, property 59 | * or parameter. 60 | *

A {@code @XmlJavaTypeAdapter} annotation on a class overrides 61 | * the {@code @XmlJavaTypeAdapter} annotation specified at the 62 | * package level for that class. 63 | * 64 | *

This annotation can be used with the following other annotations: 65 | * {@link XmlElement}, {@link XmlAttribute}, {@link XmlElementRef}, 66 | * {@link XmlElementRefs}, {@link XmlAnyElement}. This can also be 67 | * used at the package level with the following annotations: 68 | * {@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType}, 69 | * {@link XmlSchemaTypes}. 70 | * 71 | *

Example: See example in {@link XmlAdapter} 72 | * 73 | * @author

74 | * @since 1.6, JAXB 2.0 75 | * @see XmlAdapter 76 | */ 77 | @Retention(RUNTIME) @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) 78 | public @interface XmlJavaTypeAdapter { 79 | /** 80 | * Points to the class that converts a value type to a bound type or vice versa. 81 | * See {@link XmlAdapter} for more details. 82 | */ 83 | @SuppressWarnings({"rawtypes"}) 84 | Class value(); 85 | 86 | /** 87 | * If this annotation is used at the package level, then value of 88 | * the type() must be specified. 89 | */ 90 | 91 | Class type() default DEFAULT.class; 92 | 93 | /** 94 | * Used in {@link XmlJavaTypeAdapter#type()} to 95 | * signal that the type be inferred from the signature 96 | * of the field, property, parameter or the class. 97 | */ 98 | 99 | final class DEFAULT { 100 | private DEFAULT() {} 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.annotation.adapters; 12 | 13 | import static java.lang.annotation.ElementType.PACKAGE; 14 | import java.lang.annotation.Retention; 15 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | *

20 | * A container for multiple @{@link XmlJavaTypeAdapter} annotations. 21 | * 22 | *

Multiple annotations of the same type are not allowed on a program 23 | * element. This annotation therefore serves as a container annotation 24 | * for multiple @XmlJavaTypeAdapter as follows: 25 | * 26 | * {@snippet : 27 | * @XmlJavaTypeAdapters ({ @XmlJavaTypeAdapter(...), @XmlJavaTypeAdapter(...) }) 28 | * } 29 | * 30 | *

The {@code @XmlJavaTypeAdapters} annotation is useful for 31 | * defining {@link XmlJavaTypeAdapter} annotations for different types 32 | * at the package level. 33 | * 34 | *

See "Package Specification" in jakarta.xml.bind.package javadoc for 35 | * additional common information.

36 | * 37 | * @author 38 | * @see XmlJavaTypeAdapter 39 | * @since 1.6, JAXB 2.0 40 | */ 41 | @Retention(RUNTIME) @Target({PACKAGE}) 42 | public @interface XmlJavaTypeAdapters { 43 | /** 44 | * Collection of @{@link XmlJavaTypeAdapter} annotations 45 | */ 46 | XmlJavaTypeAdapter[] value(); 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/annotation/adapters/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2004, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * {@link jakarta.xml.bind.annotation.adapters.XmlAdapter} and its spec-defined 13 | * subclasses to allow arbitrary Java classes to be used with Jakarta XML Binding. 14 | * 15 | *

16 | * References in this document to JAXB refer to the Jakarta XML Binding unless otherwise noted. 17 | * 18 | *

Package Specification

19 | * 20 | * 23 | * 24 | *

Related Documentation

25 | * 26 | * For overviews, tutorials, examples, guides, and tool documentation, 27 | * please see: 28 | * 31 | * 32 | * @see Jakarta XML Binding Website 33 | */ 34 | package jakarta.xml.bind.annotation.adapters; 35 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/attachment/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2023 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * This package is implemented by a MIME-based package processor that 13 | * enables the interpretation and creation of optimized binary data 14 | * within an MIME-based package format. 15 | *

16 | * Soap MTOM[1], XOP([2][3]) and WS-I AP[4] standardize approaches to 17 | * optimized transmission of binary datatypes as an attachment. 18 | * To optimally support these standards within a message passing 19 | * environment, this package enables an integrated solution between 20 | * a MIME-based package processor and Jakarta XML Binding unmarshall/marshal processes. 21 | *

22 | * References in this document to JAXB refer to the Jakarta XML Binding unless otherwise noted. 23 | * 24 | *

Package Specification

25 | * 28 | *

Related Standards

29 | * 35 | * 36 | * @see [1]SOAP Message Transmission Optimization Mechanism 37 | * @see [2]XML-binary Optimized Packaging 38 | * @see [3]WS-I Attachments Profile Version 1.0. 39 | * @see [4]Describing Media Content of Binary Data in XML 40 | * @since JAXB 2.0 41 | */ 42 | package jakarta.xml.bind.attachment; 43 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/helpers/Messages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.helpers; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.ResourceBundle; 15 | 16 | /** 17 | * Formats error messages. 18 | */ 19 | class Messages 20 | { 21 | static String format( String property ) { 22 | return format( property, null ); 23 | } 24 | 25 | static String format( String property, Object arg1 ) { 26 | return format( property, new Object[]{arg1} ); 27 | } 28 | 29 | static String format( String property, Object arg1, Object arg2 ) { 30 | return format( property, new Object[]{arg1,arg2} ); 31 | } 32 | 33 | static String format( String property, Object arg1, Object arg2, Object arg3 ) { 34 | return format( property, new Object[]{arg1,arg2,arg3} ); 35 | } 36 | 37 | // add more if necessary. 38 | 39 | /** Loads a string resource and formats it with specified arguments. */ 40 | static String format( String property, Object[] args ) { 41 | String text = ResourceBundle.getBundle(Messages.class.getName()).getString(property); 42 | return MessageFormat.format(text,args); 43 | } 44 | 45 | // 46 | // 47 | // Message resources 48 | // 49 | // 50 | static final String INPUTSTREAM_NOT_NULL = // 0 args 51 | "AbstractUnmarshallerImpl.ISNotNull"; 52 | 53 | static final String MUST_BE_BOOLEAN = // 1 arg 54 | "AbstractMarshallerImpl.MustBeBoolean"; 55 | 56 | static final String MUST_BE_STRING = // 1 arg 57 | "AbstractMarshallerImpl.MustBeString"; 58 | 59 | static final String SEVERITY_MESSAGE = // 3 args 60 | "DefaultValidationEventHandler.SeverityMessage"; 61 | 62 | static final String LOCATION_UNAVAILABLE = // 0 args 63 | "DefaultValidationEventHandler.LocationUnavailable"; 64 | 65 | static final String UNRECOGNIZED_SEVERITY = // 1 arg 66 | "DefaultValidationEventHandler.UnrecognizedSeverity"; 67 | 68 | static final String WARNING = // 0 args 69 | "DefaultValidationEventHandler.Warning"; 70 | 71 | static final String ERROR = // 0 args 72 | "DefaultValidationEventHandler.Error"; 73 | 74 | static final String FATAL_ERROR = // 0 args 75 | "DefaultValidationEventHandler.FatalError"; 76 | 77 | static final String ILLEGAL_SEVERITY = // 0 args 78 | "ValidationEventImpl.IllegalSeverity"; 79 | 80 | static final String MUST_NOT_BE_NULL = // 1 arg 81 | "Shared.MustNotBeNull"; 82 | } 83 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/helpers/NotIdentifiableEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.helpers; 12 | 13 | import jakarta.xml.bind.ValidationEventLocator; 14 | 15 | /** 16 | * Default implementation of the NotIdentifiableEvent interface. 17 | * 18 | *

19 | * Jakarta XML Binding providers are allowed to use whatever class that implements 20 | * the ValidationEvent interface. This class is just provided for a 21 | * convenience. 22 | * 23 | * @author

24 | * @see jakarta.xml.bind.NotIdentifiableEvent 25 | * @see jakarta.xml.bind.ValidationEventHandler 26 | * @see jakarta.xml.bind.ValidationEvent 27 | * @see jakarta.xml.bind.ValidationEventLocator 28 | * @since 1.6, JAXB 1.0 29 | */ 30 | public class NotIdentifiableEventImpl 31 | extends ValidationEventImpl 32 | implements jakarta.xml.bind.NotIdentifiableEvent { 33 | 34 | /** 35 | * Create a new NotIdentifiableEventImpl. 36 | * 37 | * @param _severity The severity value for this event. Must be one of 38 | * ValidationEvent.WARNING, ValidationEvent.ERROR, or 39 | * ValidationEvent.FATAL_ERROR 40 | * @param _message The text message for this event - may be null. 41 | * @param _locator The locator object for this event - may be null. 42 | * @throws IllegalArgumentException if an illegal severity field is supplied 43 | */ 44 | public NotIdentifiableEventImpl( int _severity, String _message, 45 | ValidationEventLocator _locator) { 46 | 47 | super(_severity, _message, _locator); 48 | } 49 | 50 | /** 51 | * Create a new NotIdentifiableEventImpl. 52 | * 53 | * @param _severity The severity value for this event. Must be one of 54 | * ValidationEvent.WARNING, ValidationEvent.ERROR, or 55 | * ValidationEvent.FATAL_ERROR 56 | * @param _message The text message for this event - may be null. 57 | * @param _locator The locator object for this event - may be null. 58 | * @param _linkedException An optional linked exception that may provide 59 | * additional information about the event - may be null. 60 | * @throws IllegalArgumentException if an illegal severity field is supplied 61 | */ 62 | public NotIdentifiableEventImpl( int _severity, String _message, 63 | ValidationEventLocator _locator, 64 | Throwable _linkedException) { 65 | 66 | super(_severity, _message, _locator, _linkedException); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/helpers/ParseConversionEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.helpers; 12 | 13 | import jakarta.xml.bind.ParseConversionEvent; 14 | import jakarta.xml.bind.ValidationEventLocator; 15 | 16 | /** 17 | * Default implementation of the ParseConversionEvent interface. 18 | * 19 | *

20 | * Jakarta XML Binding providers are allowed to use whatever class that implements 21 | * the ValidationEvent interface. This class is just provided for a 22 | * convenience. 23 | * 24 | * @author

25 | * @see jakarta.xml.bind.ParseConversionEvent 26 | * @see jakarta.xml.bind.ValidationEventHandler 27 | * @see jakarta.xml.bind.ValidationEvent 28 | * @see jakarta.xml.bind.ValidationEventLocator 29 | * @since 1.6, JAXB 1.0 30 | */ 31 | public class ParseConversionEventImpl 32 | extends ValidationEventImpl 33 | implements ParseConversionEvent { 34 | 35 | /** 36 | * Create a new ParseConversionEventImpl. 37 | * 38 | * @param _severity The severity value for this event. Must be one of 39 | * ValidationEvent.WARNING, ValidationEvent.ERROR, or 40 | * ValidationEvent.FATAL_ERROR 41 | * @param _message The text message for this event - may be null. 42 | * @param _locator The locator object for this event - may be null. 43 | * @throws IllegalArgumentException if an illegal severity field is supplied 44 | */ 45 | public ParseConversionEventImpl( int _severity, String _message, 46 | ValidationEventLocator _locator) { 47 | 48 | super(_severity, _message, _locator); 49 | } 50 | 51 | /** 52 | * Create a new ParseConversionEventImpl. 53 | * 54 | * @param _severity The severity value for this event. Must be one of 55 | * ValidationEvent.WARNING, ValidationEvent.ERROR, or 56 | * ValidationEvent.FATAL_ERROR 57 | * @param _message The text message for this event - may be null. 58 | * @param _locator The locator object for this event - may be null. 59 | * @param _linkedException An optional linked exception that may provide 60 | * additional information about the event - may be null. 61 | * @throws IllegalArgumentException if an illegal severity field is supplied 62 | */ 63 | public ParseConversionEventImpl( int _severity, String _message, 64 | ValidationEventLocator _locator, 65 | Throwable _linkedException) { 66 | 67 | super(_severity, _message, _locator, _linkedException); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/helpers/PrintConversionEventImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.helpers; 12 | 13 | import jakarta.xml.bind.PrintConversionEvent; 14 | import jakarta.xml.bind.ValidationEventLocator; 15 | 16 | /** 17 | * Default implementation of the PrintConversionEvent interface. 18 | * 19 | *

20 | * Jakarta XML Binding providers are allowed to use whatever class that implements 21 | * the ValidationEvent interface. This class is just provided for a 22 | * convenience. 23 | * 24 | * @author

25 | * @see jakarta.xml.bind.PrintConversionEvent 26 | * @see jakarta.xml.bind.ValidationEventHandler 27 | * @see jakarta.xml.bind.ValidationEvent 28 | * @see jakarta.xml.bind.ValidationEventLocator 29 | * @since 1.6, JAXB 1.0 30 | */ 31 | public class PrintConversionEventImpl 32 | extends ValidationEventImpl 33 | implements PrintConversionEvent { 34 | 35 | /** 36 | * Create a new PrintConversionEventImpl. 37 | * 38 | * @param _severity The severity value for this event. Must be one of 39 | * ValidationEvent.WARNING, ValidationEvent.ERROR, or 40 | * ValidationEvent.FATAL_ERROR 41 | * @param _message The text message for this event - may be null. 42 | * @param _locator The locator object for this event - may be null. 43 | * @throws IllegalArgumentException if an illegal severity field is supplied 44 | */ 45 | public PrintConversionEventImpl( int _severity, String _message, 46 | ValidationEventLocator _locator) { 47 | 48 | super(_severity, _message, _locator); 49 | } 50 | 51 | /** 52 | * Create a new PrintConversionEventImpl. 53 | * 54 | * @param _severity The severity value for this event. Must be one of 55 | * ValidationEvent.WARNING, ValidationEvent.ERROR, or 56 | * ValidationEvent.FATAL_ERROR 57 | * @param _message The text message for this event - may be null. 58 | * @param _locator The locator object for this event - may be null. 59 | * @param _linkedException An optional linked exception that may provide 60 | * additional information about the event - may be null. 61 | * @throws IllegalArgumentException if an illegal severity field is supplied 62 | */ 63 | public PrintConversionEventImpl( int _severity, String _message, 64 | ValidationEventLocator _locator, 65 | Throwable _linkedException) { 66 | 67 | super(_severity, _message, _locator, _linkedException); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/helpers/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Jakarta XML Binding Provider Use Only: Provides partial default implementations for 13 | * some of the jakarta.xml.bind interfaces. 14 | * 15 | *

16 | * Jakarta XML Binding Providers can extend these classes and implement the abstract 17 | * methods. 18 | * 19 | *

20 | * References in this document to JAXB refer to the Jakarta XML Binding unless otherwise noted. 21 | * 22 | *

Package Specification

23 | * 24 | * 27 | * 28 | *

Related Documentation

29 | *

30 | * For overviews, tutorials, examples, guides, and tool documentation, 31 | * please see: 32 | *

35 | * 36 | * @see Jakarta XML Binding Website 37 | */ 38 | package jakarta.xml.bind.helpers; 39 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Provides a runtime binding framework for client applications including 13 | * unmarshalling, marshalling, and validation capabilities. 14 | *

15 | * JAXBContext is the client-entry point to the runtime binding 16 | * framework. 17 | *

18 | * References in this document to JAXB refer to the Jakarta XML Binding unless otherwise noted. 19 | * 20 | *

Package Specification

21 | * 24 | *

Related Documentation

25 | * For overviews, tutorials, examples, guides, and tool documentation, 26 | * please see: 27 | * 30 | * 31 | * @see Jakarta XML Binding Website 32 | */ 33 | package jakarta.xml.bind; 34 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/util/Messages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.util; 12 | 13 | import java.text.MessageFormat; 14 | import java.util.ResourceBundle; 15 | 16 | /** 17 | * Formats error messages. 18 | */ 19 | class Messages 20 | { 21 | static String format( String property ) { 22 | return format( property, null ); 23 | } 24 | 25 | static String format( String property, Object arg1 ) { 26 | return format( property, new Object[]{arg1} ); 27 | } 28 | 29 | static String format( String property, Object arg1, Object arg2 ) { 30 | return format( property, new Object[]{arg1,arg2} ); 31 | } 32 | 33 | static String format( String property, Object arg1, Object arg2, Object arg3 ) { 34 | return format( property, new Object[]{arg1,arg2,arg3} ); 35 | } 36 | 37 | // add more if necessary. 38 | 39 | /** Loads a string resource and formats it with specified arguments. */ 40 | static String format( String property, Object[] args ) { 41 | String text = ResourceBundle.getBundle(Messages.class.getName()).getString(property); 42 | return MessageFormat.format(text,args); 43 | } 44 | 45 | // 46 | // 47 | // Message resources 48 | // 49 | // 50 | static final String UNRECOGNIZED_SEVERITY = // 1 arg 51 | "ValidationEventCollector.UnrecognizedSeverity"; 52 | 53 | static final String RESULT_NULL_CONTEXT = // 0 args 54 | "JAXBResult.NullContext"; 55 | 56 | static final String RESULT_NULL_UNMARSHALLER = // 0 arg 57 | "JAXBResult.NullUnmarshaller"; 58 | 59 | static final String SOURCE_NULL_CONTEXT = // 0 args 60 | "JAXBSource.NullContext"; 61 | 62 | static final String SOURCE_NULL_CONTENT = // 0 arg 63 | "JAXBSource.NullContent"; 64 | 65 | static final String SOURCE_NULL_MARSHALLER = // 0 arg 66 | "JAXBSource.NullMarshaller"; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/util/ValidationEventCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2024 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.util; 12 | 13 | import jakarta.xml.bind.ValidationEvent; 14 | import jakarta.xml.bind.ValidationEventHandler; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | /** 19 | * {@link jakarta.xml.bind.ValidationEventHandler ValidationEventHandler} 20 | * implementation that collects all events. 21 | * 22 | *

23 | * To use this class, create a new instance and pass it to the setEventHandler 24 | * method of the Unmarshaller, Marshaller class. After the call to 25 | * validate or unmarshal completes, call the getEvents method to retrieve all 26 | * the reported errors and warnings. 27 | * 28 | * @author

29 | * @see jakarta.xml.bind.ValidationEventHandler 30 | * @see jakarta.xml.bind.ValidationEvent 31 | * @see jakarta.xml.bind.ValidationEventLocator 32 | * @since 1.6, JAXB 1.0 33 | */ 34 | public class ValidationEventCollector implements ValidationEventHandler 35 | { 36 | private final List events = new ArrayList<>(); 37 | 38 | public ValidationEventCollector() {} 39 | 40 | /** 41 | * Return an array of ValidationEvent objects containing a copy of each of 42 | * the collected errors and warnings. 43 | * 44 | * @return 45 | * a copy of all the collected errors and warnings or an empty array 46 | * if there weren't any 47 | */ 48 | public ValidationEvent[] getEvents() { 49 | return events.toArray(new ValidationEvent[0]); 50 | } 51 | 52 | /** 53 | * Clear all collected errors and warnings. 54 | */ 55 | public void reset() { 56 | events.clear(); 57 | } 58 | 59 | /** 60 | * Returns true if this event collector contains at least one 61 | * ValidationEvent. 62 | * 63 | * @return true if this event collector contains at least one 64 | * ValidationEvent, false otherwise 65 | */ 66 | public boolean hasEvents() { 67 | return !events.isEmpty(); 68 | } 69 | 70 | @Override 71 | public boolean handleEvent( ValidationEvent event ) { 72 | events.add(event); 73 | 74 | boolean retVal = true; 75 | switch( event.getSeverity() ) { 76 | case ValidationEvent.WARNING: 77 | case ValidationEvent.ERROR: 78 | retVal = true; // continue validation 79 | break; 80 | case ValidationEvent.FATAL_ERROR: 81 | retVal = false; // halt validation 82 | break; 83 | default: 84 | _assert( false, 85 | Messages.format( Messages.UNRECOGNIZED_SEVERITY, 86 | event.getSeverity() ) ); 87 | break; 88 | } 89 | 90 | return retVal; 91 | } 92 | 93 | private static void _assert( boolean b, String msg ) { 94 | if( !b ) { 95 | throw new InternalError( msg ); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /api/src/main/java/jakarta/xml/bind/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Useful client utility classes. 13 | * 14 | *

15 | * References in this document to JAXB refer to the Jakarta XML Binding unless otherwise noted. 16 | * 17 | *

Package Specification

18 | * 19 | * 22 | * 23 | *

Related Documentation

24 | *

25 | * For overviews, tutorials, examples, guides, and tool documentation, 26 | * please see: 27 | *

30 | * 31 | * @see Jakarta XML Binding Website 32 | */ 33 | package jakarta.xml.bind.util; 34 | -------------------------------------------------------------------------------- /api/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Jakarta XML Binding API. 13 | * 14 | *

15 | * References in this document to JAXB refer to the Jakarta XML Binding unless otherwise noted. 16 | */ 17 | module jakarta.xml.bind { 18 | requires transitive jakarta.activation; 19 | requires transitive java.xml; 20 | requires java.logging; 21 | 22 | exports jakarta.xml.bind; 23 | exports jakarta.xml.bind.annotation; 24 | exports jakarta.xml.bind.annotation.adapters; 25 | exports jakarta.xml.bind.attachment; 26 | exports jakarta.xml.bind.helpers; 27 | exports jakarta.xml.bind.util; 28 | 29 | uses jakarta.xml.bind.JAXBContextFactory; 30 | } 31 | -------------------------------------------------------------------------------- /api/src/main/javadoc/doc-files/speclicense.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Eclipse Foundation Specification License - v1.0 4 | 5 | 6 |

Eclipse Foundation Specification License - v1.0

7 |

By using and/or copying this document, or the Eclipse Foundation 8 | document from which this statement is linked, you (the licensee) agree 9 | that you have read, understood, and will comply with the following 10 | terms and conditions:

11 | 12 |

Permission to copy, and distribute the contents of this document, or 13 | the Eclipse Foundation document from which this statement is linked, in 14 | any medium for any purpose and without fee or royalty is hereby 15 | granted, provided that you include the following on ALL copies of the 16 | document, or portions thereof, that you use:

17 | 18 | 27 | 28 |

Inclusion of the full text of this NOTICE must be provided. We 29 | request that authorship attribution be provided in any software, 30 | documents, or other items or products that you create pursuant to the 31 | implementation of the contents of this document, or any portion 32 | thereof.

33 | 34 |

No right to create modifications or derivatives of Eclipse Foundation 35 | documents is granted pursuant to this license, except anyone may 36 | prepare and distribute derivative works and portions of this document 37 | in software that implements the specification, in supporting materials 38 | accompanying such software, and in documentation of such software, 39 | PROVIDED that all such works include the notice below. HOWEVER, the 40 | publication of derivative works of this document for use as a technical 41 | specification is expressly prohibited.

42 | 43 |

The notice is:

44 | 45 |

"Copyright © 2018 Eclipse Foundation. This software or 46 | document includes material copied from or derived from [title and URI 47 | of the Eclipse Foundation specification document]."

48 | 49 |

Disclaimers

50 | 51 |

THIS DOCUMENT IS PROVIDED "AS IS," AND THE COPYRIGHT 52 | HOLDERS AND THE ECLIPSE FOUNDATION MAKE NO REPRESENTATIONS OR 53 | WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 54 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 55 | NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE 56 | SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS 57 | WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR 58 | OTHER RIGHTS.

59 | 60 |

THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION WILL NOT BE LIABLE 61 | FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT 62 | OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE 63 | CONTENTS THEREOF.

64 | 65 |

The name and trademarks of the copyright holders or the Eclipse 66 | Foundation may NOT be used in advertising or publicity pertaining to 67 | this document or its contents without specific, written prior 68 | permission. Title to copyright in this document will at all times 69 | remain with copyright holders.

70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /api/src/main/resources/jakarta/xml/bind/Messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2003, 2024 Oracle and/or its affiliates. All rights reserved. 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Distribution License v. 1.0, which is available at 6 | # http://www.eclipse.org/org/documents/edl-v10.php. 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | # 10 | 11 | 12 | ContextFinder.ProviderNotFound = \ 13 | Provider {0} not found 14 | 15 | ContextFinder.DefaultProviderNotFound = \ 16 | Implementation of Jakarta XML Binding-API has not been found on module path or classpath. 17 | 18 | ContextFinder.CouldNotInstantiate = \ 19 | Provider {0} could not be instantiated: {1} 20 | 21 | ContextFinder.CantFindPropertiesFile = \ 22 | Unable to locate jaxb.properties for package {0} 23 | 24 | ContextFinder.CantMixProviders = \ 25 | You may not mix Jakarta XML Binding Providers on the context path 26 | 27 | ContextFinder.MissingProperty = \ 28 | jaxb.properties in package {0} does not contain the {1} property. 29 | 30 | ContextFinder.NoPackageInContextPath = \ 31 | No package name is given 32 | 33 | ContextFinder.ErrorLoadClass = \ 34 | Error loading class {0} listed in {1}, make sure that entries are accessible \ 35 | on CLASSPATH and of the form ClassName or OuterClass.InnerClass \ 36 | not ClassName.class or fully.qualified.ClassName 37 | 38 | PropertyException.NameValue = \ 39 | name: {0} value: {1} 40 | 41 | DatatypeConverter.ConverterMustNotBeNull = \ 42 | The DatatypeConverterInterface parameter must not be null 43 | 44 | JAXBContext.IllegalCast = \ 45 | ClassCastException: attempting to cast {0} to {1}. Please make sure that you are specifying the proper ClassLoader. 46 | 47 | JAXBClasses.notOpen = \ 48 | Package {0} with Jakarta XML Binding class {1} defined in a module {2} must be open to at least jakarta.xml.bind module. 49 | -------------------------------------------------------------------------------- /api/src/main/resources/jakarta/xml/bind/helpers/Messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Distribution License v. 1.0, which is available at 6 | # http://www.eclipse.org/org/documents/edl-v10.php. 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | # 10 | 11 | 12 | AbstractUnmarshallerImpl.ISNotNull = \ 13 | InputStream can not be null 14 | 15 | AbstractMarshallerImpl.MustBeBoolean = \ 16 | {0} must be boolean 17 | 18 | AbstractMarshallerImpl.MustBeString = \ 19 | {0} must be a String 20 | 21 | 22 | DefaultValidationEventHandler.SeverityMessage = \ 23 | DefaultValidationEventHandler: {0} {1} \n\ 24 | \ \ \ \ \ Location: {2} 25 | 26 | DefaultValidationEventHandler.LocationUnavailable = \ 27 | unavailable 28 | 29 | DefaultValidationEventHandler.UnrecognizedSeverity = \ 30 | Unrecognized event severity field "{0}" 31 | 32 | DefaultValidationEventHandler.Warning = \ 33 | [WARNING]: 34 | 35 | DefaultValidationEventHandler.Error = \ 36 | [ERROR]: 37 | 38 | DefaultValidationEventHandler.FatalError = \ 39 | [FATAL_ERROR]: 40 | 41 | ValidationEventImpl.IllegalSeverity = \ 42 | Illegal severity 43 | 44 | Shared.MustNotBeNull = \ 45 | {0} parameter must not be null 46 | 47 | 48 | -------------------------------------------------------------------------------- /api/src/main/resources/jakarta/xml/bind/util/Messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2003, 2021 Oracle and/or its affiliates. All rights reserved. 3 | # 4 | # This program and the accompanying materials are made available under the 5 | # terms of the Eclipse Distribution License v. 1.0, which is available at 6 | # http://www.eclipse.org/org/documents/edl-v10.php. 7 | # 8 | # SPDX-License-Identifier: BSD-3-Clause 9 | # 10 | 11 | 12 | ValidationEventCollector.UnrecognizedSeverity = \ 13 | Unrecognized event severity field "{0}" 14 | 15 | JAXBResult.NullContext = \ 16 | JAXBContext can not be null 17 | 18 | JAXBResult.NullUnmarshaller = \ 19 | Unmarshaller can not be null 20 | 21 | JAXBSource.NullContext = \ 22 | JAXBContext can not be null 23 | 24 | JAXBSource.NullContent = \ 25 | Content object can not be null 26 | 27 | JAXBSource.NullMarshaller = \ 28 | Marshaller can not be null 29 | 30 | -------------------------------------------------------------------------------- /etc/config/copyright-exclude: -------------------------------------------------------------------------------- 1 | .iml 2 | .ipr 3 | .txt 4 | .bat 5 | .sh 6 | etc/config/copyright-exclude 7 | javadoc/doc-files/speclicense.html 8 | jaxb-api-test/src/test/resources/logging.properties 9 | jaxb-api-test/src/test/resources/jakarta/xml/bind/test.policy 10 | jaxb-api-test/src/test/resources/jaxb/test/usr/jaxb.index 11 | /LICENSE.md 12 | -------------------------------------------------------------------------------- /etc/config/edl-copyright.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) YYYY Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | -------------------------------------------------------------------------------- /etc/jenkins/continuous.groovy: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, 2024 Oracle and/or its affiliates. All rights reserved. 2 | // 3 | // This program and the accompanying materials are made available under the 4 | // terms of the Eclipse Distribution License v. 1.0, which is available at 5 | // http://www.eclipse.org/org/documents/edl-v10.php. 6 | // 7 | // SPDX-License-Identifier: BSD-3-Clause 8 | 9 | // Job input parameters: 10 | // SPEC_VERSION - Specification version to release 11 | // NEXT_SPEC_VERSION - Next specification snapshot version to set (e.g. 1.2.4-SNAPSHOT) 12 | // API_VERSION - API version to release 13 | // NEXT_API_VERSION - Next API snapshot version to set (e.g. 1.2.4-SNAPSHOT) 14 | // BRANCH - Branch to release 15 | // DRY_RUN - Do not publish artifacts to OSSRH and code changes to GitHub 16 | // OVERWRITE - Allows to overwrite existing version in git and OSSRH staging repositories 17 | 18 | // Job internal argumets: 19 | // GIT_USER_NAME - Git user name (for commits) 20 | // GIT_USER_EMAIL - Git user e-mail (for commits) 21 | // SSH_CREDENTIALS_ID - Jenkins ID of SSH credentials 22 | // GPG_CREDENTIALS_ID - Jenkins ID of GPG credentials (stored as KEYRING variable) 23 | 24 | pipeline { 25 | 26 | agent any 27 | 28 | tools { 29 | jdk 'openjdk-jdk21-latest' 30 | maven 'apache-maven-latest' 31 | } 32 | 33 | environment { 34 | SPEC_DIR="${WORKSPACE}/spec" 35 | API_DIR="${WORKSPACE}" 36 | } 37 | 38 | stages { 39 | // Initialize build environment 40 | stage('Init') { 41 | steps { 42 | git branch: BRANCH, credentialsId: SSH_CREDENTIALS_ID, url: GIT_URL 43 | // GPG initialization 44 | withCredentials([file(credentialsId: GPG_CREDENTIALS_ID, variable: 'KEYRING')]) { 45 | sh ''' 46 | gpg --batch --import ${KEYRING} 47 | for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u); 48 | do 49 | echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust; 50 | done 51 | 52 | ''' 53 | } 54 | // Git configuration 55 | sh ''' 56 | git config --global user.name "${GIT_USER_NAME}" 57 | git config --global user.email "${GIT_USER_EMAIL}" 58 | ''' 59 | } 60 | } 61 | // Perform release 62 | stage('Build') { 63 | steps { 64 | sshagent([SSH_CREDENTIALS_ID]) { 65 | sh ''' 66 | etc/jenkins/continuous.sh 67 | ''' 68 | } 69 | junit '**/target/surefire-reports/*.xml' 70 | jacoco() 71 | recordIssues(tools: [java(), javaDoc(), spotBugs(useRankAsPriority: true)]) 72 | } 73 | } 74 | 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /etc/jenkins/continuous.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Eclipse Distribution License v. 1.0, which is available at 7 | # http://www.eclipse.org/org/documents/edl-v10.php. 8 | # 9 | # SPDX-License-Identifier: BSD-3-Clause 10 | 11 | # 12 | # Arguments: 13 | # N/A 14 | 15 | echo '-[ Jakarta XML Binding Specification Build ]------------------------------------' 16 | (cd spec && mvn -U -C -B -Dstatus='DRAFT' clean install) 17 | echo '-[ Jakarta XML Binding API Build ]----------------------------------------------' 18 | mvn -U -C -B -V -Psnapshots,oss-release clean deploy spotbugs:spotbugs 19 | -------------------------------------------------------------------------------- /etc/jenkins/release.groovy: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, 2024 Oracle and/or its affiliates. All rights reserved. 2 | // 3 | // This program and the accompanying materials are made available under the 4 | // terms of the Eclipse Distribution License v. 1.0, which is available at 5 | // http://www.eclipse.org/org/documents/edl-v10.php. 6 | // 7 | // SPDX-License-Identifier: BSD-3-Clause 8 | 9 | // Job input parameters: 10 | // API_VERSION - API version to release 11 | // NEXT_API_VERSION - Next API snapshot version to set (e.g. 1.2.4-SNAPSHOT) 12 | // BRANCH - Branch to release 13 | // DRY_RUN - Do not publish artifacts to OSSRH and code changes to GitHub 14 | // OVERWRITE - Allows to overwrite existing version in git and OSSRH staging repositories 15 | 16 | // Job internal argumets: 17 | // GIT_USER_NAME - Git user name (for commits) 18 | // GIT_USER_EMAIL - Git user e-mail (for commits) 19 | // SSH_CREDENTIALS_ID - Jenkins ID of SSH credentials 20 | // GPG_CREDENTIALS_ID - Jenkins ID of GPG credentials (stored as KEYRING variable) 21 | 22 | pipeline { 23 | 24 | agent any 25 | 26 | tools { 27 | jdk 'openjdk-jdk21-latest' 28 | maven 'apache-maven-latest' 29 | } 30 | 31 | environment { 32 | API_DIR="${WORKSPACE}" 33 | } 34 | 35 | stages { 36 | // Initialize build environment 37 | stage('Init') { 38 | steps { 39 | git branch: BRANCH, credentialsId: SSH_CREDENTIALS_ID, url: GIT_URL 40 | // GPG initialization 41 | withCredentials([file(credentialsId: GPG_CREDENTIALS_ID, variable: 'KEYRING')]) { 42 | sh ''' 43 | gpg --batch --import ${KEYRING} 44 | for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u); 45 | do 46 | echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust; 47 | done 48 | 49 | ''' 50 | } 51 | // Git configuration 52 | sh ''' 53 | git config --global user.name "${GIT_USER_NAME}" 54 | git config --global user.email "${GIT_USER_EMAIL}" 55 | ''' 56 | } 57 | } 58 | // Perform release 59 | stage('Release') { 60 | steps { 61 | sshagent([SSH_CREDENTIALS_ID]) { 62 | sh ''' 63 | etc/jenkins/release.sh "${API_VERSION}" "${NEXT_API_VERSION}" \ 64 | "${DRY_RUN}" "${OVERWRITE}" 65 | ''' 66 | } 67 | } 68 | } 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /etc/jenkins/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | # 3 | # Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved. 4 | # 5 | # This program and the accompanying materials are made available under the 6 | # terms of the Eclipse Distribution License v. 1.0, which is available at 7 | # http://www.eclipse.org/org/documents/edl-v10.php. 8 | # 9 | # SPDX-License-Identifier: BSD-3-Clause 10 | 11 | # 12 | # Arguments: 13 | # $1 - API_VERSION 14 | # $2 - NEXT_API_VERSION 15 | # $3 - DRY_RUN 16 | # $4 - OVERWRITE 17 | 18 | API_VERSION="${1}" 19 | NEXT_API_VERSION="${2}" 20 | DRY_RUN="${3}" 21 | OVERWRITE="${4}" 22 | 23 | 24 | export MAVEN_SKIP_RC="true" 25 | 26 | . etc/scripts/maven.incl.sh 27 | . etc/scripts/nexus.incl.sh 28 | 29 | read_version 'API' "${API_DIR}" 30 | 31 | if [ -z "${API_RELEASE_VERSION}" ]; then 32 | echo '-[ Missing required API release version number! ]-------------------------------' 33 | exit 1 34 | fi 35 | 36 | RELEASE_TAG="${API_RELEASE_VERSION}" 37 | RELEASE_BRANCH="${API_RELEASE_VERSION}-RELEASE" 38 | 39 | if [ ${DRY_RUN} = 'true' ]; then 40 | echo '-[ Dry run turned on ]----------------------------------------------------------' 41 | MVN_DEPLOY_ARGS='install' 42 | echo '-[ Skipping GitHub branch and tag checks ]--------------------------------------' 43 | else 44 | MVN_DEPLOY_ARGS='deploy' 45 | GIT_ORIGIN=`git remote` 46 | echo '-[ Prepare branch ]-------------------------------------------------------------' 47 | if [[ -n `git branch -r | grep "${GIT_ORIGIN}/${RELEASE_BRANCH}"` ]]; then 48 | if [ "${OVERWRITE}" = 'true' ]; then 49 | echo "${GIT_ORIGIN}/${RELEASE_BRANCH} branch already exists, deleting" 50 | git push --delete origin "${RELEASE_BRANCH}" && true 51 | else 52 | echo "Error: ${GIT_ORIGIN}/${RELEASE_BRANCH} branch already exists" 53 | exit 1 54 | fi 55 | fi 56 | echo '-[ Release tag cleanup ]--------------------------------------------------------' 57 | if [[ -n `git ls-remote --tags ${GIT_ORIGIN} | grep "${RELEASE_TAG}\$"` ]]; then 58 | if [ "${OVERWRITE}" = 'true' ]; then 59 | echo "${RELEASE_TAG} tag already exists, deleting" 60 | git push --delete origin "${RELEASE_TAG}" && true 61 | else 62 | echo "Error: ${RELEASE_TAG} tag already exists" 63 | exit 1 64 | fi 65 | fi 66 | fi 67 | 68 | # Always delete local branch if exists 69 | git branch --delete "${RELEASE_BRANCH}" && true 70 | git checkout -b ${RELEASE_BRANCH} 71 | 72 | # Always delete local tag if exists 73 | git tag --delete "${RELEASE_TAG}" && true 74 | 75 | # Read Maven identifiers 76 | read_mvn_id 'API' "${API_DIR}/jaxb-api" 77 | 78 | # Set Nexus identifiers 79 | API_STAGING_DESC="${API_GROUP_ID}:${API_ARTIFACT_ID}:${API_RELEASE_VERSION}" 80 | API_STAGING_KEY=$(echo ${API_STAGING_DESC} | sed -e 's/\./\\\./g') 81 | 82 | # Set release versions 83 | echo '-[ API release version ]--------------------------------------------------------' 84 | set_version 'API' "${API_DIR}" "${API_RELEASE_VERSION}" "${API_GROUP_ID}" "${API_ARTIFACT_ID}" '' 85 | 86 | drop_artifacts "${API_STAGING_KEY}" "${API_DIR}" 87 | 88 | echo '-[ Deploy artifacts to staging repository ]-----------------------------' 89 | # Verify, sign and deploy release 90 | (cd ${API_DIR} && \ 91 | mvn -U -C -B -V \ 92 | -Poss-release,staging -DskipTests \ 93 | -DstagingDescription="${API_STAGING_DESC}" \ 94 | clean ${MVN_DEPLOY_ARGS}) 95 | 96 | echo '-[ Tag release ]----------------------------------------------------------------' 97 | git tag "${RELEASE_TAG}" -m "JAXB-API ${API_RELEASE_VERSION} release" 98 | 99 | # Set next release cycle snapshot version 100 | echo '-[ API next snapshot version ]--------------------------------------------------' 101 | set_version 'API' "${API_DIR}" "${API_NEXT_SNAPSHOT}" "${API_GROUP_ID}" "${API_ARTIFACT_ID}" '' 102 | 103 | if [ ${DRY_RUN} = 'true' ]; then 104 | echo '-[ Skipping GitHub update ]-----------------------------------------------------' 105 | else 106 | echo '-[ Push branch and tag to GitHub ]----------------------------------------------' 107 | git push origin "${RELEASE_BRANCH}" 108 | git push origin "${RELEASE_TAG}" 109 | fi 110 | -------------------------------------------------------------------------------- /etc/scripts/maven.incl.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Eclipse Distribution License v. 1.0, which is available at 5 | # http://www.eclipse.org/org/documents/edl-v10.php. 6 | # 7 | # SPDX-License-Identifier: BSD-3-Clause 8 | 9 | # Maven plugins 10 | VERSIONS_PLUGIN='org.codehaus.mojo:versions-maven-plugin:2.7' 11 | HELP_PLUGIN='org.apache.maven.plugins:maven-help-plugin:3.2.0' 12 | 13 | # Compute version strings for next development cycle. 14 | # Version strings are set as new shell variables with provided prefix. 15 | # Arguments: 16 | # $1 - Variable prefix 17 | # $2 - Source version 18 | # Variables set: 19 | # "${1}_NEXT_VERSION" - Next version string: Source string with last component increased by 1 20 | # "${1}_NEXT_SNAPSHOT" - Next snapshot string: Next version string with '-SNAPSHOT' suffix 21 | next_version() { 22 | set -f 23 | local NEXT_COMPONENTS=(${2//\./ }) 24 | local LAST_INDEX=$((${#NEXT_COMPONENTS[@]} - 1)) 25 | local NEXT_COMPONENTS[${LAST_INDEX}]=$((${NEXT_COMPONENTS[${LAST_INDEX}]} + 1)) 26 | local COMPONENTS_STR="${NEXT_COMPONENTS[@]}" 27 | local NEXT_VERSION="${COMPONENTS_STR// /.}" 28 | local NEXT_SNAPSHOT="${NEXT_VERSION}-SNAPSHOT" 29 | echo "${1} Next Version: ${NEXT_VERSION}" 30 | echo "${1} Next Snapshot: ${NEXT_SNAPSHOT}" 31 | eval "${1}_NEXT_VERSION"="${NEXT_VERSION}" 32 | eval "${1}_NEXT_SNAPSHOT"="${NEXT_SNAPSHOT}" 33 | } 34 | 35 | # Prepare release version string and next development cycle versions. 36 | # Version strings are set as new shell variables with provided prefix. 37 | # Arguments: 38 | # $1 - Variable prefix 39 | # $2 - Build directory 40 | # Source variables: 41 | # "${1}_VERSION" - Release version override (optional) 42 | # Variables set: 43 | # "${1}_RELEASE_VERSION" - Release version 44 | read_version() { 45 | local VERSION_VAR="${1}_VERSION" 46 | local SNAPSHOT_VERSION=`(cd ${2} && mvn -B ${HELP_PLUGIN}:evaluate -Dexpression=project.version 2> /dev/null | grep -E '^[0-9]+(\.[0-9]+)+-SNAPSHOT$')` 47 | if [ -z "${!VERSION_VAR}" ]; then 48 | local RELEASE_VERSION="${SNAPSHOT_VERSION/-SNAPSHOT/}" 49 | else 50 | local RELEASE_VERSION="${!VERSION_VAR}" 51 | fi 52 | echo "${1} Release Version: ${RELEASE_VERSION}" 53 | eval "${1}_RELEASE_VERSION"="${RELEASE_VERSION}" 54 | next_version "${1}" "${RELEASE_VERSION}" 55 | } 56 | 57 | # Read Maven identifier (groupId and artifactId). 58 | # Maven identifier is set as new shell variables with provided prefix. 59 | # Arguments: 60 | # $1 - Variable prefix 61 | # $2 - Build directory 62 | # Variables set: 63 | # "${1}_GROUP_ID" - Maven groupId 64 | # "${1}_ARTIFACT_ID" - Maven artifactId 65 | read_mvn_id() { 66 | local GROUP_ID=`(cd ${2} && mvn -B ${HELP_PLUGIN}:evaluate -Dexpression=project.groupId | grep -Ev '(^\[)')` 67 | local ARTIFACT_ID=`(cd ${2} && mvn -B ${HELP_PLUGIN}:evaluate -Dexpression=project.artifactId | grep -Ev '(^\[)')` 68 | echo "${1} Group ID: ${GROUP_ID}" 69 | echo "${1} Artifact ID: ${ARTIFACT_ID}" 70 | eval "${1}_GROUP_ID"="${GROUP_ID}" 71 | eval "${1}_ARTIFACT_ID"="${ARTIFACT_ID}" 72 | } 73 | 74 | # Set Maven artifact version. 75 | # Arguments: 76 | # $1 - Artifact identifier (e.g. 'SPEC', 'API', 'RI') 77 | # $2 - Build directory 78 | # $3 - Version to set 79 | # $4 - Group ID 80 | # $5 - Artifact ID 81 | # $6 - Additional Maven arguments 82 | set_version() { 83 | echo '--[ Set version ]---------------------------------------------------------------' 84 | # Set release version 85 | (cd ${2} && \ 86 | mvn -U -C \ 87 | ${6} \ 88 | -DnewVersion="${3}" \ 89 | -DgenerateBackupPoms=false \ 90 | clean ${VERSIONS_PLUGIN}:set) 91 | echo '--[ Commit modified pom.xml files ]---------------------------------------------' 92 | local POM_FILES=`git status | grep -E 'modified:.*pom\.xml' | sed -e 's/[[:space:]][[:space:]]*modified:[[:space:]][[:space:]]*//'` 93 | git add ${POM_FILES} && \ 94 | git commit -m "Update ${1} version of ${4}:${5} to ${3}" 95 | } 96 | -------------------------------------------------------------------------------- /etc/scripts/nexus.incl.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved. 2 | # 3 | # This program and the accompanying materials are made available under the 4 | # terms of the Eclipse Distribution License v. 1.0, which is available at 5 | # http://www.eclipse.org/org/documents/edl-v10.php. 6 | # 7 | # SPDX-License-Identifier: BSD-3-Clause 8 | 9 | # Drop old artifacts from staging repository 10 | # Arguments: 11 | # $1 - Staging key value with grep REGEX prefixes 12 | # $2 - Build directory 13 | drop_artifacts() { 14 | echo '-[ Drop old staging repository deployments ]------------------------------------' 15 | for staging_key in `(cd ${2} && mvn -B nexus-staging:rc-list | egrep "^\[INFO\] [A-Z,a-z,-]+-[0-9]+\s+[A-Z]+\s+${1}\$" | awk '{print $2}')`; do 16 | echo "Repository ID: ${staging_key}" 17 | (cd ${2} && \ 18 | mvn -U -C \ 19 | -DstagingRepositoryId="${staging_key}" \ 20 | nexus-staging:rc-drop) 21 | done 22 | } 23 | -------------------------------------------------------------------------------- /etc/spotbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 | 52 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /jaxb-api-test/src/main/java/jakarta/xml/bind/tests/SampleTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2020 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | package jakarta.xml.bind.tests; 11 | 12 | /** 13 | * Sample test class 14 | */ 15 | public class SampleTest { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /jaxb-api-test/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Placeholder for 13 | */ 14 | module jakarta.xml.bind.tests.src {} 15 | -------------------------------------------------------------------------------- /jaxb-api-test/src/main/javadoc/doc-files/speclicense.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Eclipse Foundation Specification License - v1.0 4 | 5 | 6 |

Eclipse Foundation Specification License - v1.0

7 |

By using and/or copying this document, or the Eclipse Foundation 8 | document from which this statement is linked, you (the licensee) agree 9 | that you have read, understood, and will comply with the following 10 | terms and conditions:

11 | 12 |

Permission to copy, and distribute the contents of this document, or 13 | the Eclipse Foundation document from which this statement is linked, in 14 | any medium for any purpose and without fee or royalty is hereby 15 | granted, provided that you include the following on ALL copies of the 16 | document, or portions thereof, that you use:

17 | 18 | 27 | 28 |

Inclusion of the full text of this NOTICE must be provided. We 29 | request that authorship attribution be provided in any software, 30 | documents, or other items or products that you create pursuant to the 31 | implementation of the contents of this document, or any portion 32 | thereof.

33 | 34 |

No right to create modifications or derivatives of Eclipse Foundation 35 | documents is granted pursuant to this license, except anyone may 36 | prepare and distribute derivative works and portions of this document 37 | in software that implements the specification, in supporting materials 38 | accompanying such software, and in documentation of such software, 39 | PROVIDED that all such works include the notice below. HOWEVER, the 40 | publication of derivative works of this document for use as a technical 41 | specification is expressly prohibited.

42 | 43 |

The notice is:

44 | 45 |

"Copyright © 2018 Eclipse Foundation. This software or 46 | document includes material copied from or derived from [title and URI 47 | of the Eclipse Foundation specification document]."

48 | 49 |

Disclaimers

50 | 51 |

THIS DOCUMENT IS PROVIDED "AS IS," AND THE COPYRIGHT 52 | HOLDERS AND THE ECLIPSE FOUNDATION MAKE NO REPRESENTATIONS OR 53 | WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 54 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 55 | NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE 56 | SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS 57 | WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR 58 | OTHER RIGHTS.

59 | 60 |

THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION WILL NOT BE LIABLE 61 | FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT 62 | OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE 63 | CONTENTS THEREOF.

64 | 65 |

The name and trademarks of the copyright holders or the Eclipse 66 | Foundation may NOT be used in advertising or publicity pertaining to 67 | this document or its contents without specific, written prior 68 | permission. Title to copyright in this document will at all times 69 | remain with copyright holders.

70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jakarta/xml/bind/test/JAXBContextServiceProviderNPETest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.test; 12 | 13 | import org.junit.Before; 14 | import org.junit.Test; 15 | 16 | import jakarta.xml.bind.*; 17 | import java.util.Map; 18 | 19 | import static junit.framework.Assert.assertEquals; 20 | import static junit.framework.Assert.assertNotNull; 21 | import static junit.framework.TestCase.fail; 22 | 23 | /** 24 | * regression test for 25 | * JDK-8145104: NPE is thrown when JAXBContextFactory implementation is specified in system property 26 | */ 27 | public class JAXBContextServiceProviderNPETest { 28 | 29 | public static class Factory implements JAXBContextFactory { 30 | 31 | @Override 32 | public JAXBContext createContext(Class[] classesToBeBound, Map properties) throws JAXBException { 33 | return new MyContext(); 34 | } 35 | 36 | @Override 37 | public JAXBContext createContext(String contextPath, ClassLoader classLoader, Map properties) 38 | throws JAXBException { 39 | return new MyContext(); 40 | } 41 | } 42 | 43 | static class MyContext extends JAXBContext { 44 | @Override 45 | public Unmarshaller createUnmarshaller() throws JAXBException { 46 | return null; 47 | } 48 | 49 | @Override 50 | public Marshaller createMarshaller() throws JAXBException { 51 | return null; 52 | } 53 | 54 | } 55 | 56 | @Test 57 | public void testContextPath() { 58 | try { 59 | JAXBContext ctx = JAXBContext.newInstance("whatever", ClassLoader.getSystemClassLoader()); 60 | assertNotNull("Expected non-null instance to be returned from the test Factory", ctx); 61 | assertEquals("Expected MyContext instance to be returned from the test Factory", MyContext.class, ctx.getClass()); 62 | } catch (Throwable t) { 63 | t.printStackTrace(); 64 | fail("Not expected to fail!"); 65 | } 66 | } 67 | 68 | @Test 69 | public void testClasses() { 70 | try { 71 | JAXBContext ctx = JAXBContext.newInstance(new Class[0]); 72 | assertNotNull("Expected non-null instance to be returned from the test Factory", ctx); 73 | assertEquals("Expected MyContext instance to be returned from the test Factory", MyContext.class, ctx.getClass()); 74 | } catch (Throwable t) { 75 | t.printStackTrace(); 76 | fail("Not expected to fail!"); 77 | } 78 | } 79 | 80 | @Before 81 | public void setup() { 82 | System.setProperty("jakarta.xml.bind.JAXBContextFactory", "jakarta.xml.bind.test.JAXBContextServiceProviderNPETest$Factory"); 83 | } 84 | 85 | public static void main(String[] args) throws JAXBException { 86 | JAXBContextServiceProviderNPETest tst = new JAXBContextServiceProviderNPETest(); 87 | tst.setup(); 88 | tst.testContextPath(); 89 | tst.testClasses(); 90 | } 91 | 92 | } 93 | 94 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jakarta/xml/bind/test/JAXBContextWrapExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jakarta.xml.bind.test; 12 | 13 | import org.junit.Before; 14 | import org.junit.Test; 15 | 16 | import jakarta.xml.bind.JAXBContext; 17 | import jakarta.xml.bind.JAXBException; 18 | import java.util.Map; 19 | 20 | import static junit.framework.Assert.assertEquals; 21 | import static junit.framework.Assert.assertTrue; 22 | import static junit.framework.TestCase.assertNull; 23 | 24 | /** 25 | * regression test for 26 | * JDK-8145112: newInstance(String, ClassLoader): java.lang.JAXBException should not be wrapped as expected 27 | * according to spec 28 | */ 29 | public class JAXBContextWrapExceptionTest { 30 | 31 | public static class Factory { 32 | 33 | public static JAXBContext createContext(Class[] classesToBeBound, Map properties) throws JAXBException { 34 | throw new JAXBException("test"); 35 | } 36 | 37 | public static JAXBContext createContext(String contextPath, ClassLoader classLoader, Map properties) 38 | throws JAXBException { 39 | throw new JAXBException("test"); 40 | } 41 | } 42 | 43 | @Test 44 | public void testContextPath() { 45 | try { 46 | JAXBContext.newInstance("whatever", ClassLoader.getSystemClassLoader()); 47 | } catch (Throwable t) { 48 | assertEquals("test", t.getMessage()); 49 | assertNull("Root cause must be null", t.getCause()); 50 | } 51 | } 52 | 53 | @Test 54 | public void testClasses() { 55 | try { 56 | JAXBContext.newInstance(new Class[0]); 57 | assertTrue("This should fail", false); 58 | } catch (Throwable t) { 59 | assertEquals("test", t.getMessage()); 60 | assertNull("Root cause must be null", t.getCause()); 61 | } 62 | } 63 | 64 | @Before 65 | public void setup() { 66 | System.setProperty("jakarta.xml.bind.JAXBContextFactory", "jakarta.xml.bind.test.JAXBContextWrapExceptionTest$Factory"); 67 | } 68 | 69 | public static void main(String[] args) throws JAXBException { 70 | new JAXBContextWrapExceptionTest().testContextPath(); 71 | new JAXBContextWrapExceptionTest().testClasses(); 72 | } 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/legacy/Invalid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.legacy; 12 | 13 | /** 14 | * Invalid JAXBContext factory class for tests 15 | * - doesn't contain required static methods 16 | */ 17 | public class Invalid { 18 | } 19 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/legacy/Valid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.legacy; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import jakarta.xml.bind.JAXBException; 15 | import jakarta.xml.bind.Marshaller; 16 | import jakarta.xml.bind.Unmarshaller; 17 | import java.util.Map; 18 | 19 | /** 20 | * Valid JAXBContext factory class for tests 21 | * - contains required static methods and creates dummy JAXBContext 22 | */ 23 | public class Valid { 24 | 25 | public static JAXBContext createContext(java.lang.String path, java.lang.ClassLoader cl) { 26 | return new JAXBContext1(); 27 | } 28 | 29 | public static JAXBContext createContext(Class[] classes, Map properties) throws JAXBException { 30 | return new JAXBContext1(); 31 | } 32 | 33 | 34 | public static class JAXBContext1 extends JAXBContext { 35 | 36 | @Override 37 | public Unmarshaller createUnmarshaller() throws JAXBException { 38 | return null; 39 | } 40 | 41 | @Override 42 | public Marshaller createMarshaller() throws JAXBException { 43 | return null; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/legacy/Valid2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.legacy; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import jakarta.xml.bind.JAXBException; 15 | import jakarta.xml.bind.Marshaller; 16 | import jakarta.xml.bind.Unmarshaller; 17 | import java.util.Map; 18 | 19 | /** 20 | * (Another) Valid JAXBContext factory class for tests 21 | * - contains required static methods and creates dummy JAXBContext 22 | * - several implementations necessary to test different configuration approaches 23 | */ 24 | public class Valid2 { 25 | 26 | public static JAXBContext createContext(String path, ClassLoader cl) { 27 | return new JAXBContext1(); 28 | } 29 | 30 | public static JAXBContext createContext(Class[] classes, Map properties) throws JAXBException { 31 | return new JAXBContext1(); 32 | } 33 | 34 | 35 | public static class JAXBContext1 extends JAXBContext { 36 | 37 | @Override 38 | public Unmarshaller createUnmarshaller() throws JAXBException { 39 | return null; 40 | } 41 | 42 | @Override 43 | public Marshaller createMarshaller() throws JAXBException { 44 | return null; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/legacy/Valid3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.legacy; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import jakarta.xml.bind.JAXBException; 15 | import jakarta.xml.bind.Marshaller; 16 | import jakarta.xml.bind.Unmarshaller; 17 | import java.util.Map; 18 | 19 | /** 20 | * (Another) Valid JAXBContext factory class for tests 21 | * - contains required static methods and creates dummy JAXBContext 22 | * - several implementations necessary to test different configuration approaches 23 | */ 24 | public class Valid3 { 25 | 26 | public static JAXBContext createContext(String path, ClassLoader cl) { 27 | return new JAXBContext1(); 28 | } 29 | 30 | public static JAXBContext createContext(Class[] classes, Map properties) throws JAXBException { 31 | return new JAXBContext1(); 32 | } 33 | 34 | 35 | public static class JAXBContext1 extends JAXBContext { 36 | 37 | @Override 38 | public Unmarshaller createUnmarshaller() throws JAXBException { 39 | return null; 40 | } 41 | 42 | @Override 43 | public Marshaller createMarshaller() throws JAXBException { 44 | return null; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/spi/Invalid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.spi; 12 | 13 | /** 14 | * Invalid JAXBContext factory class for tests 15 | * - doesn't contain required static methods 16 | */ 17 | public class Invalid { 18 | } 19 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/spi/Valid.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2025 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.spi; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import jakarta.xml.bind.JAXBContextFactory; 15 | import jakarta.xml.bind.JAXBException; 16 | import jakarta.xml.bind.Marshaller; 17 | import jakarta.xml.bind.Unmarshaller; 18 | import java.util.Map; 19 | 20 | /** 21 | * Created by miran on 10/11/14. 22 | */ 23 | public class Valid implements JAXBContextFactory { 24 | 25 | @Override 26 | public JAXBContext createContext(Class[] classesToBeBound, Map properties) throws JAXBException { 27 | if (properties != null && properties.containsKey("jakarta.xml.bind.JAXBContextFactory")) { 28 | throw new JAXBException("property \"jakarta.xml.bind.JAXBContextFactory\" is not supported"); 29 | } 30 | return new JAXBContext1(); 31 | } 32 | 33 | @Override 34 | public JAXBContext createContext(String contextPath, ClassLoader classLoader, Map properties) throws JAXBException { 35 | if (properties != null && properties.containsKey("jakarta.xml.bind.JAXBContextFactory")) { 36 | throw new JAXBException("property \"jakarta.xml.bind.JAXBContextFactory\" is not supported"); 37 | } 38 | return new JAXBContext1(); 39 | } 40 | 41 | public static class JAXBContext1 extends JAXBContext { 42 | @Override 43 | public Unmarshaller createUnmarshaller() throws JAXBException { 44 | return null; 45 | } 46 | 47 | @Override 48 | public Marshaller createMarshaller() throws JAXBException { 49 | return null; 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/spi/Valid2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2025 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.spi; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import jakarta.xml.bind.JAXBContextFactory; 15 | import jakarta.xml.bind.JAXBException; 16 | import jakarta.xml.bind.Marshaller; 17 | import jakarta.xml.bind.Unmarshaller; 18 | import java.util.Map; 19 | 20 | /** 21 | * Created by miran on 10/11/14. 22 | */ 23 | public class Valid2 implements JAXBContextFactory { 24 | 25 | @Override 26 | public JAXBContext createContext(Class[] classesToBeBound, Map properties) throws JAXBException { 27 | if (properties != null && properties.containsKey("jakarta.xml.bind.JAXBContextFactory")) { 28 | throw new JAXBException("property \"jakarta.xml.bind.JAXBContextFactory\" is not supported"); 29 | } 30 | return new JAXBContext1(); 31 | } 32 | 33 | @Override 34 | public JAXBContext createContext(String contextPath, ClassLoader classLoader, Map properties) throws JAXBException { 35 | if (properties != null && properties.containsKey("jakarta.xml.bind.JAXBContextFactory")) { 36 | throw new JAXBException("property \"jakarta.xml.bind.JAXBContextFactory\" is not supported"); 37 | } 38 | return new JAXBContext1(); 39 | } 40 | 41 | public static class JAXBContext1 extends JAXBContext { 42 | @Override 43 | public Unmarshaller createUnmarshaller() throws JAXBException { 44 | return null; 45 | } 46 | 47 | @Override 48 | public Marshaller createMarshaller() throws JAXBException { 49 | return null; 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/factory/spi/Valid3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2025 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.factory.spi; 12 | 13 | import jakarta.xml.bind.JAXBContext; 14 | import jakarta.xml.bind.JAXBContextFactory; 15 | import jakarta.xml.bind.JAXBException; 16 | import jakarta.xml.bind.Marshaller; 17 | import jakarta.xml.bind.Unmarshaller; 18 | import java.util.Map; 19 | 20 | /** 21 | * Created by miran on 10/11/14. 22 | */ 23 | public class Valid3 implements JAXBContextFactory { 24 | 25 | @Override 26 | public JAXBContext createContext(Class[] classesToBeBound, Map properties) throws JAXBException { 27 | if (properties != null && properties.containsKey("jakarta.xml.bind.JAXBContextFactory")) { 28 | throw new JAXBException("property \"jakarta.xml.bind.JAXBContextFactory\" is not supported"); 29 | } 30 | return new JAXBContext1(); 31 | } 32 | 33 | @Override 34 | public JAXBContext createContext(String contextPath, ClassLoader classLoader, Map properties) throws JAXBException { 35 | if (properties != null && properties.containsKey("jakarta.xml.bind.JAXBContextFactory")) { 36 | throw new JAXBException("property \"jakarta.xml.bind.JAXBContextFactory\" is not supported"); 37 | } 38 | return new JAXBContext1(); 39 | } 40 | 41 | public static class JAXBContext1 extends JAXBContext { 42 | @Override 43 | public Unmarshaller createUnmarshaller() throws JAXBException { 44 | return null; 45 | } 46 | 47 | @Override 48 | public Marshaller createMarshaller() throws JAXBException { 49 | return null; 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/jaxb/test/usr/A.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | package jaxb.test.usr; 12 | 13 | import jakarta.xml.bind.annotation.XmlRootElement; 14 | import jakarta.xml.bind.annotation.XmlType; 15 | 16 | /** 17 | * Simple user class for testing creation of JAXBContext 18 | */ 19 | @XmlType 20 | @XmlRootElement 21 | public class A { 22 | 23 | String name; 24 | } 25 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. 3 | * 4 | * This program and the accompanying materials are made available under the 5 | * terms of the Eclipse Distribution License v. 1.0, which is available at 6 | * http://www.eclipse.org/org/documents/edl-v10.php. 7 | * 8 | * SPDX-License-Identifier: BSD-3-Clause 9 | */ 10 | 11 | /** 12 | * Tests for jaxb API. 13 | */ 14 | module jakarta.xml.bind.tests { 15 | requires jakarta.xml.bind; 16 | requires java.logging; 17 | requires junit; 18 | } 19 | -------------------------------------------------------------------------------- /jaxb-api-test/src/test/resources/jakarta/xml/bind/test.policy: -------------------------------------------------------------------------------- 1 | grant { 2 | // security manager 3 | permission java.lang.RuntimePermission "setSecurityManager"; 4 | 5 | permission java.lang.RuntimePermission "accessDeclaredMembers"; 6 | 7 | // writing configuration files 8 | permission java.io.FilePermission "${classesDir}/-", "read, write, delete"; 9 | 10 | permission java.util.PropertyPermission "*", "read"; 11 | permission java.lang.RuntimePermission "*"; 12 | 13 | // reading / modifying jdk/conf/jaxm.properties 14 | permission java.io.FilePermission "${java.home}${/}-", "read, write, delete"; 15 | }; -------------------------------------------------------------------------------- /jaxb-api-test/src/test/resources/jaxb/test/usr/jaxb.index: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /jaxb-api-test/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | handlers = java.util.logging.ConsoleHandler 2 | java.util.logging.ConsoleHandler.level=FINEST 3 | -------------------------------------------------------------------------------- /spec/README.md: -------------------------------------------------------------------------------- 1 | Jakarta XML Binding Specification 2 | ============================ 3 | 4 | This project generates the Jakarta XML Binding Specification. 5 | 6 | Building 7 | -------- 8 | 9 | Prerequisites: 10 | 11 | * JDK8+ 12 | * Maven 3.0.3+ 13 | 14 | Run the full build: 15 | 16 | `mvn install` 17 | 18 | Locate the html files: 19 | - `target/generated-docs/jakarta.xml.bind-spec-.html` 20 | 21 | Locate the PDF files: 22 | - `target/generated-docs/jakarta.xml.bind-spec-.pdf` 23 | -------------------------------------------------------------------------------- /spec/src/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | spec 22 | 23 | zip 24 | 25 | xml-binding-spec 26 | 27 | 28 | target/generated-docs 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /spec/src/main/asciidoc/XMLBinding.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020 Contributors to the Eclipse Foundation 3 | // 4 | 5 | include::ch01-introduction.adoc[] 6 | include::ch02-requirements.adoc[] 7 | include::ch03-architecture.adoc[] 8 | include::ch04-binding_framework.adoc[] 9 | include::ch05-java_representation.adoc[] 10 | include::ch06-binding_xml_schema.adoc[] 11 | include::ch07-customize_xml_schema.adoc[] 12 | include::ch08-java_types.adoc[] 13 | include::ch09-compatibility.adoc[] 14 | 15 | include::appA-references.adoc[] 16 | include::appB-runtime_processing.adoc[] 17 | include::appC-normative_schema.adoc[] 18 | include::appD-binding_xml.adoc[] 19 | include::appE-external_binding.adoc[] 20 | include::appF-xml_schema.adoc[] 21 | include::appH-binary_data.adoc[] 22 | include::appI-changelog.adoc[] 23 | -------------------------------------------------------------------------------- /spec/src/main/asciidoc/appA-references.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020 Contributors to the Eclipse Foundation 3 | // 4 | 5 | [appendix] 6 | == References 7 | 8 | [XSD Part 0] XML Schema Part 0: Primer, + 9 | Available at _http://www.w3.org/TR/2004/REC-xmlschema-0-20041028/_ + 10 | (schema fragments borrowed from this widely used source). 11 | 12 | [XSD Part 1] XML Schema Part 1: Structures, + 13 | Available at _http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/_. 14 | 15 | [XSD Part 2] XML Schema Part 2: Datatypes, + 16 | Available at _http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/_. 17 | 18 | [XMl-Infoset] XML Information Set, John Cowan 19 | and Richard Tobin, eds., W3C, 16 March 2001. + 20 | Available at _http://www.w3.org/TR/2001/WD-xml-infoset-20010316/_. 21 | 22 | [XML 1.0] Extensible Markup Language (XML) 23 | 1.0 (Second Edition), + 24 | W3C Recommendation 6 October 2000. + 25 | Available at _http://www.w3.org/TR/2000/REC-xml-20001006_. 26 | 27 | [Namespaces in XML] Namespaces in XML + 28 | W3C Recommendation 14 January 1999. + 29 | Available at _http://www.w3.org/TR/1999/REC-xml-names-19990114_. 30 | 31 | [XPath], XML Path Language, James Clark and 32 | Steve DeRose, eds., W3C, 16 November 1999. + 33 | Available at _http://www.w3.org/TR/1999/REC-xpath-19991116_. 34 | 35 | [XSLT 1.0] XSL Transformations (XSLT), 36 | Version 1.0, James Clark, + 37 | W3C Recommendation 16 November 1999. + 38 | Available at _http://www.w3.org/TR/1999/REC-xslt-19991116_. 39 | 40 | [BEANS] JavaBeans(TM), Version 1.01, July 24, 1997. + 41 | Available at _http://java.sun.com/beans_. 42 | 43 | [XSD Primer] XML Schema Part 0: Primer, + 44 | W3C Recommendation 2 May 2001 + 45 | Available at _http://www.w3.org/TR/xmlschema-0/_. 46 | 47 | [BLOCH] Joshua Bloch, Effective Java, + 48 | Chapter 3, Typesafe Enums + 49 | _http://developer.java.sun.com/developer/Books/shiftintojavapage1.html#replaceenum_. 50 | 51 | [BLOCH_2] Joshua Bloch, Effective Java, + 52 | Chapter 1, Item 1: Consider factory methods over constructors 53 | 54 | [RFC2396] Uniform Resource Identifiers (URI): 55 | Generic Syntax, + 56 | _http://www.ietf.org/rfc/rfc2396.txt._ 57 | 58 | [XML-RPC] Jakarta XML RPC, + 59 | _https://jakarta.ee/specifications/xml-rpc/_. 60 | 61 | [XML-WS] Jakarta XML Web Services, + 62 | _https://jakarta.ee/specifications/xml-web-services/_. 63 | 64 | [JAXB 1.0] XML Data Binding Specification, + 65 | _https://jcp.org/en/jsr/detail?id=31_ 66 | 67 | [JLS] or [JLS3] The Java Language 68 | Specification, 3rd Edition, Gosling, Joy, Steele, Bracha. + 69 | Available at 70 | _http://java.sun.com/docs/books/jls_. 71 | 72 | [NIST] NIST XML Schema Test Suite, + 73 | _http://xw2k.sdct.itl.nist.gov/xml/page4.html._ 74 | 75 | [MTOM] SOAP Message Transmission Optimization 76 | Mechanism, + 77 | _http://www.w3.org/TR/2004/WD-soap12-mtom-20040608/_. 78 | 79 | [XOP] Martin Gudgin, Noah Mendelsohn, Mark 80 | Nottingham, and Herve Ruellan. XML-binary Optimized Packaging. + 81 | Recommendation, W3C, January 2005. + _http://www.w3.org/TR/xop10/_. 82 | 83 | [MIME] Anish Karmarkar, Ümit Yalçinalp, 84 | "Describing Media Content of Binary Data in XML", + 85 | W3C note, + 86 | _http://www.w3.org/TR/2005/NOTE-xml-media-types-20050504_ 87 | 88 | [WSIAP] Chris Ferris, Anish Karmarkar, and 89 | Canyang Kevin Liu. Attachments Profile Version 1.0. Final 1 Material, 90 | WS-I, April 2006. + 91 | _http://www.ws-i.org/Profiles/AttachmentsProfile-1.0.html_. 92 | 93 | [WSIBP] WS-I Basic Profile 1.0, + 94 | _http://www.ws-i.org/Profile/Basic/2003-08/BasicProfile-1.0a.html_ 95 | 96 | [CA] Jakarta Annotations + 97 | _https://jakarta.ee/specifications/annotations/_ 98 | -------------------------------------------------------------------------------- /spec/src/main/asciidoc/ch09-compatibility.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2020, 2021 Contributors to the Eclipse Foundation 3 | // 4 | 5 | == Compatibility 6 | 7 | This section describes conformance 8 | requirements for an implementor of this specification. A JAXB 9 | implementation must implement these constraints, without exception, to 10 | provide a predictable environment for application development and 11 | deployment. 12 | 13 | This section explicitly lists the high level 14 | requirements of this specification. Additional requirements can be found 15 | in other sections of this specification and the associated javadoc for 16 | package `jakarta.xml.bind` and its subpackages. If any requirements listed 17 | here conflict with requirements listed elsewhere in the specification, 18 | the requirements here take precedence and replace the conflicting 19 | requirements. 20 | 21 | A JAXB implementation must implement the 22 | processing model specified in Appendix B, 23 | <>. 24 | 25 | A JAXB implementation included in a product 26 | that supports software development must support a schema generator. A 27 | schema generator must support all the Java Types to XML Schema mapping 28 | specified in <>. 29 | 30 | A JAXB implementation included in a product 31 | that supports software development must support a schema compiler. All 32 | operating modes of a schema compiler must support all the XML 33 | Schema-to-Java bindings described in this specification. Additionally, 34 | any operating mode must not implement a default binding for XML 35 | Schema-to-Java bindings as an alternative to those specified in 36 | <> nor alternative interpretations for the standard 37 | customizations described in <>. 38 | 39 | The default operating mode for a schema 40 | compiler MUST report an error when extension binding declaration is 41 | encountered. All operating modes for a schema compiler MUST report an 42 | error if an invalid binding customization is detected as defined in 43 | Section 7. An extension binding declaration must be introduced in the 44 | following cases: 45 | 46 | . to alter a binding customization that is 47 | allowed to be associated with a schema element as specified in 48 | <>. 49 | . to associate a binding customization with a 50 | schema element where it is disallowed as specified in 51 | <>. 52 | 53 | The default operating mode for a schema 54 | compiler MUST report an error when processing a schema that does not 55 | comply with the 2001 W3C Recommendation for XML Schema, [XSD Part 1] and 56 | [XSD Part 2]. 57 | 58 | A schema compiler MAY support non-default 59 | operating modes for binding schema languages other than XML Schema. 60 | 61 | A schema compiler MUST be able to generate 62 | Java classes that are able to run on at least one Sun's Reference 63 | Implementation of the J2SE Java Runtime Environment that is J2SE 5 or 64 | higher. 65 | 66 | A schema generator MAY support non-default 67 | operating modes for mapping Java types to schema languages other than 68 | XML Schema. 69 | -------------------------------------------------------------------------------- /spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakartaee/jaxb-api/57884ff908ac5144dd7477ffb3f7349bc22ce2b5/spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png -------------------------------------------------------------------------------- /spec/src/main/asciidoc/images/xmlb-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakartaee/jaxb-api/57884ff908ac5144dd7477ffb3f7349bc22ce2b5/spec/src/main/asciidoc/images/xmlb-15.png -------------------------------------------------------------------------------- /spec/src/main/asciidoc/license-efsl.adoc: -------------------------------------------------------------------------------- 1 | [subs="normal"] 2 | .... 3 | Specification: {doctitle} 4 | 5 | Version: {revnumber} 6 | 7 | ifeval::["{revremark}" != ""] 8 | Status: {revremark} 9 | endif::[] 10 | ifeval::["{revremark}" == ""] 11 | Status: Final Release 12 | endif::[] 13 | 14 | Release: {revdate} 15 | .... 16 | 17 | Copyright (c) 2019, 2022 Eclipse Foundation. 18 | 19 | === Eclipse Foundation Specification License 20 | 21 | By using and/or copying this document, or the Eclipse Foundation 22 | document from which this statement is linked, you (the licensee) agree 23 | that you have read, understood, and will comply with the following 24 | terms and conditions: 25 | 26 | Permission to copy, and distribute the contents of this document, or 27 | the Eclipse Foundation document from which this statement is linked, in 28 | any medium for any purpose and without fee or royalty is hereby 29 | granted, provided that you include the following on ALL copies of the 30 | document, or portions thereof, that you use: 31 | 32 | * link or URL to the original Eclipse Foundation document. 33 | * All existing copyright notices, or if one does not exist, a notice 34 | (hypertext is preferred, but a textual representation is permitted) 35 | of the form: "Copyright (c) [$date-of-document] 36 | Eclipse Foundation, Inc. <>" 37 | 38 | Inclusion of the full text of this NOTICE must be provided. We 39 | request that authorship attribution be provided in any software, 40 | documents, or other items or products that you create pursuant to the 41 | implementation of the contents of this document, or any portion 42 | thereof. 43 | 44 | No right to create modifications or derivatives of Eclipse Foundation 45 | documents is granted pursuant to this license, except anyone may 46 | prepare and distribute derivative works and portions of this document 47 | in software that implements the specification, in supporting materials 48 | accompanying such software, and in documentation of such software, 49 | PROVIDED that all such works include the notice below. HOWEVER, the 50 | publication of derivative works of this document for use as a technical 51 | specification is expressly prohibited. 52 | 53 | The notice is: 54 | 55 | "Copyright (c) 2018 Eclipse Foundation. This software or 56 | document includes material copied from or derived from [title and URI 57 | of the Eclipse Foundation specification document]." 58 | 59 | ==== Disclaimers 60 | 61 | THIS DOCUMENT IS PROVIDED "AS IS," AND THE COPYRIGHT 62 | HOLDERS AND THE ECLIPSE FOUNDATION MAKE NO REPRESENTATIONS OR 63 | WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 64 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, 65 | NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE 66 | SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS 67 | WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR 68 | OTHER RIGHTS. 69 | 70 | THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION WILL NOT BE LIABLE 71 | FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT 72 | OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE 73 | CONTENTS THEREOF. 74 | 75 | The name and trademarks of the copyright holders or the Eclipse 76 | Foundation may NOT be used in advertising or publicity pertaining to 77 | this document or its contents without specific, written prior 78 | permission. Title to copyright in this document will at all times 79 | remain with copyright holders. -------------------------------------------------------------------------------- /spec/src/main/asciidoc/scope.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017, 2020 Contributors to the Eclipse Foundation 3 | // 4 | == Scope 5 | 6 | The Jakarta XML Binding provides an API and tools that automate the mapping 7 | between XML documents and Java objects. -------------------------------------------------------------------------------- /spec/src/main/asciidoc/xml-binding-spec.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017, 2023 Contributors to the Eclipse Foundation 3 | // 4 | 5 | = Jakarta XML Binding 6 | :authors: Jakarta XML Binding Team, https://projects.eclipse.org/projects/ee4j.jaxb 7 | :email: https://dev.eclipse.org/mailman/listinfo/jaxb-dev 8 | :version-label!: 9 | :doctype: book 10 | :license: Eclipse Foundation Specification License v1.0 11 | :source-highlighter: coderay 12 | :toc: left 13 | :toclevels: 4 14 | :sectnumlevels: 4 15 | :sectanchors: 16 | ifdef::backend-pdf[] 17 | :pagenums: 18 | :numbered: 19 | :title-logo-image: image:jakarta_ee_logo_schooner_color_stacked_default.png[pdfwidth=4.25in,align=right] 20 | endif::[] 21 | 22 | // == License 23 | :sectnums!: 24 | include::license-efsl.adoc[] 25 | 26 | // == Scope 27 | :sectnums!: 28 | include::scope.adoc[] 29 | 30 | // == Jakarta XML Binding 31 | :sectnums: 32 | include::XMLBinding.adoc[] 33 | -------------------------------------------------------------------------------- /spec/src/main/asciidoc/xml-binding.adoc: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2017, 2020 Contributors to the Eclipse Foundation 3 | // 4 | == Scope 5 | 6 | The Jakarta XML Binding provides an API and tools that automate the mapping 7 | between XML documents and Java objects. --------------------------------------------------------------------------------