alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (XmlJavaTypeAdapter.java)

This example Java source code file (XmlJavaTypeAdapter.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

annotation, class, default, package\,field\,method\,type\,parameter, retention, target, xmladapter, xmljavatypeadapter

The XmlJavaTypeAdapter.java Java example source code

/*
 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package javax.xml.bind.annotation.adapters;

import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlSchemaTypes;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.PACKAGE;


/**
 * Use an adapter that implements {@link XmlAdapter} for custom marshaling.
 *
 * <p>  Usage:  

* * <p> The @XmlJavaTypeAdapter annotation can be used with the * following program elements: * <ul> * <li> a JavaBean property * <li> field * <li> parameter * <li> package * <li> from within {@link XmlJavaTypeAdapters} * </ul> * * <p> When @XmlJavaTypeAdapter annotation is defined on a * class, it applies to all references to the class. * <p> When @XmlJavaTypeAdapter annotation is defined at the * package level it applies to all references from within the package * to <tt>@XmlJavaTypeAdapter.type(). * <p> When @XmlJavaTypeAdapter annotation is defined on the * field, property or parameter, then the annotation applies to the * field, property or the parameter only. * <p> A @XmlJavaTypeAdapter annotation on a field, property * or parameter overrides the <tt>@XmlJavaTypeAdapter annotation * associated with the class being referenced by the field, property * or parameter. * <p> A @XmlJavaTypeAdapter annotation on a class overrides * the <tt>@XmlJavaTypeAdapter annotation specified at the * package level for that class. * * <p>This annotation can be used with the following other annotations: * {@link XmlElement}, {@link XmlAttribute}, {@link XmlElementRef}, * {@link XmlElementRefs}, {@link XmlAnyElement}. This can also be * used at the package level with the following annotations: * {@link XmlAccessorType}, {@link XmlSchema}, {@link XmlSchemaType}, * {@link XmlSchemaTypes}. * * <p> Example: See example in {@link XmlAdapter} * * @author <ul>
  • Sekhar Vajjhala, Sun Microsystems Inc.
  • Kohsuke Kawaguchi, Sun Microsystems Inc.
  • * @since JAXB2.0 * @see XmlAdapter */ @Retention(RUNTIME) @Target({PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) public @interface XmlJavaTypeAdapter { /** * Points to the class that converts a value type to a bound type or vice versa. * See {@link XmlAdapter} for more details. */ Class<? extends XmlAdapter> value(); /** * If this annotation is used at the package level, then value of * the type() must be specified. */ Class type() default DEFAULT.class; /** * Used in {@link XmlJavaTypeAdapter#type()} to * signal that the type be inferred from the signature * of the field, property, parameter or the class. */ static final class DEFAULT {} }

    Other Java examples (source code examples)

    Here is a short list of links related to this Java XmlJavaTypeAdapter.java source code file:

    ... this post is sponsored by my books ...

    #1 New Release!

    FP Best Seller

     

    new blog posts

     

    Copyright 1998-2021 Alvin Alexander, alvinalexander.com
    All Rights Reserved.

    A percentage of advertising revenue from
    pages under the /java/jwarehouse URI on this website is
    paid back to open source projects.