feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Built-in {@link XmlAdapter} to handle <tt>xs:token</tt> and its derived types.
|
||||
*
|
||||
* <p>
|
||||
* This adapter removes leading and trailing whitespaces, then truncate any
|
||||
* sequnce of tab, CR, LF, and SP by a single whitespace character ' '.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since JAXB 2.0
|
||||
*/
|
||||
public class CollapsedStringAdapter extends XmlAdapter<String,String> {
|
||||
/**
|
||||
* Removes leading and trailing whitespaces of the string
|
||||
* given as the parameter, then truncate any
|
||||
* sequnce of tab, CR, LF, and SP by a single whitespace character ' '.
|
||||
*/
|
||||
public String unmarshal(String text) {
|
||||
if(text==null) return null; // be defensive
|
||||
|
||||
int len = text.length();
|
||||
|
||||
// most of the texts are already in the collapsed form.
|
||||
// so look for the first whitespace in the hope that we will
|
||||
// never see it.
|
||||
int s=0;
|
||||
while(s<len) {
|
||||
if(isWhiteSpace(text.charAt(s)))
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
if(s==len)
|
||||
// the input happens to be already collapsed.
|
||||
return text;
|
||||
|
||||
// we now know that the input contains spaces.
|
||||
// let's sit down and do the collapsing normally.
|
||||
|
||||
StringBuilder result = new StringBuilder(len /*allocate enough size to avoid re-allocation*/ );
|
||||
|
||||
if(s!=0) {
|
||||
for( int i=0; i<s; i++ )
|
||||
result.append(text.charAt(i));
|
||||
result.append(' ');
|
||||
}
|
||||
|
||||
boolean inStripMode = true;
|
||||
for (int i = s+1; i < len; i++) {
|
||||
char ch = text.charAt(i);
|
||||
boolean b = isWhiteSpace(ch);
|
||||
if (inStripMode && b)
|
||||
continue; // skip this character
|
||||
|
||||
inStripMode = b;
|
||||
if (inStripMode)
|
||||
result.append(' ');
|
||||
else
|
||||
result.append(ch);
|
||||
}
|
||||
|
||||
// remove trailing whitespaces
|
||||
len = result.length();
|
||||
if (len > 0 && result.charAt(len - 1) == ' ')
|
||||
result.setLength(len - 1);
|
||||
// whitespaces are already collapsed,
|
||||
// so all we have to do is to remove the last one character
|
||||
// if it's a whitespace.
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*
|
||||
* Just return the same string given as the parameter.
|
||||
*/
|
||||
public String marshal(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/** returns true if the specified char is a white space character. */
|
||||
protected static boolean isWhiteSpace(char ch) {
|
||||
// most of the characters are non-control characters.
|
||||
// so check that first to quickly return false for most of the cases.
|
||||
if( ch>0x20 ) return false;
|
||||
|
||||
// other than we have to do four comparisons.
|
||||
return ch == 0x9 || ch == 0xA || ch == 0xD || ch == 0x20;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.DatatypeConverter;
|
||||
|
||||
/**
|
||||
* {@link XmlAdapter} for <tt>xs:hexBinary</tt>.
|
||||
*
|
||||
* <p>
|
||||
* This {@link XmlAdapter} binds <tt>byte[]</tt> to the hexBinary representation in XML.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since JAXB 2.0
|
||||
*/
|
||||
public final class HexBinaryAdapter extends XmlAdapter<String,byte[]> {
|
||||
public byte[] unmarshal(String s) {
|
||||
if(s==null) return null;
|
||||
return DatatypeConverter.parseHexBinary(s);
|
||||
}
|
||||
|
||||
public String marshal(byte[] bytes) {
|
||||
if(bytes==null) return null;
|
||||
return DatatypeConverter.printHexBinary(bytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* {@link XmlAdapter} to handle <tt>xs:normalizedString</tt>.
|
||||
*
|
||||
* <p>
|
||||
* Replaces any tab, CR, and LF by a whitespace character ' ',
|
||||
* as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a>
|
||||
*
|
||||
* @author Kohsuke Kawaguchi, Martin Grebac
|
||||
* @since JAXB 2.0
|
||||
*/
|
||||
public final class NormalizedStringAdapter extends XmlAdapter<String,String> {
|
||||
/**
|
||||
* Replace any tab, CR, and LF by a whitespace character ' ',
|
||||
* as specified in <a href="http://www.w3.org/TR/xmlschema-2/#rf-whiteSpace">the whitespace facet 'replace'</a>
|
||||
*/
|
||||
public String unmarshal(String text) {
|
||||
if(text==null) return null; // be defensive
|
||||
|
||||
int i=text.length()-1;
|
||||
|
||||
// look for the first whitespace char.
|
||||
while( i>=0 && !isWhiteSpaceExceptSpace(text.charAt(i)) )
|
||||
i--;
|
||||
|
||||
if( i<0 )
|
||||
// no such whitespace. replace(text)==text.
|
||||
return text;
|
||||
|
||||
// we now know that we need to modify the text.
|
||||
// allocate a char array to do it.
|
||||
char[] buf = text.toCharArray();
|
||||
|
||||
buf[i--] = ' ';
|
||||
for( ; i>=0; i-- )
|
||||
if( isWhiteSpaceExceptSpace(buf[i]))
|
||||
buf[i] = ' ';
|
||||
|
||||
return new String(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op.
|
||||
*
|
||||
* Just return the same string given as the parameter.
|
||||
*/
|
||||
public String marshal(String s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the specified char is a white space character
|
||||
* but not 0x20.
|
||||
*/
|
||||
protected static boolean isWhiteSpaceExceptSpace(char ch) {
|
||||
// most of the characters are non-control characters.
|
||||
// so check that first to quickly return false for most of the cases.
|
||||
if( ch>=0x20 ) return false;
|
||||
|
||||
// other than we have to do four comparisons.
|
||||
return ch == 0x9 || ch == 0xA || ch == 0xD;
|
||||
}
|
||||
}
|
||||
193
jdkSrc/jdk8/javax/xml/bind/annotation/adapters/XmlAdapter.java
Normal file
193
jdkSrc/jdk8/javax/xml/bind/annotation/adapters/XmlAdapter.java
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Adapts a Java type for custom marshaling.
|
||||
*
|
||||
* <p> <b> Usage: </b> </p>
|
||||
*
|
||||
* <p>
|
||||
* Some Java types do not map naturally to a XML representation, for
|
||||
* example <tt>HashMap</tt> or other non JavaBean classes. Conversely,
|
||||
* a XML repsentation may map to a Java type but an application may
|
||||
* choose to accesss the XML representation using another Java
|
||||
* type. For example, the schema to Java binding rules bind
|
||||
* xs:DateTime by default to XmlGregorianCalendar. But an application
|
||||
* may desire to bind xs:DateTime to a custom type,
|
||||
* MyXmlGregorianCalendar, for example. In both cases, there is a
|
||||
* mismatch between <i> bound type </i>, used by an application to
|
||||
* access XML content and the <i> value type</i>, that is mapped to an
|
||||
* XML representation.
|
||||
*
|
||||
* <p>
|
||||
* This abstract class defines methods for adapting a bound type to a value
|
||||
* type or vice versa. The methods are invoked by the JAXB binding
|
||||
* framework during marshaling and unmarshalling:
|
||||
*
|
||||
* <ul>
|
||||
* <li> <b> XmlAdapter.marshal(...): </b> During marshalling, JAXB
|
||||
* binding framework invokes XmlAdapter.marshal(..) to adapt a
|
||||
* bound type to value type, which is then marshaled to XML
|
||||
* representation. </li>
|
||||
*
|
||||
* <li> <b> XmlAdapter.unmarshal(...): </b> During unmarshalling,
|
||||
* JAXB binding framework first unmarshals XML representation
|
||||
* to a value type and then invokes XmlAdapter.unmarshal(..) to
|
||||
* adapt the value type to a bound type. </li>
|
||||
* </ul>
|
||||
*
|
||||
* Writing an adapter therefore involves the following steps:
|
||||
*
|
||||
* <ul>
|
||||
* <li> Write an adapter that implements this abstract class. </li>
|
||||
* <li> Install the adapter using the annotation {@link
|
||||
* XmlJavaTypeAdapter} </li>
|
||||
* </ul>
|
||||
*
|
||||
* <p><b>Example:</b> Customized mapping of <tt>HashMap</tt></p>
|
||||
* <p> The following example illustrates the use of
|
||||
* <tt>@XmlAdapter</tt> and <tt>@XmlJavaTypeAdapter</tt> to
|
||||
* customize the mapping of a <tt>HashMap</tt>.
|
||||
*
|
||||
* <p> <b> Step 1: </b> Determine the desired XML representation for HashMap.
|
||||
*
|
||||
* <pre>
|
||||
* <hashmap>
|
||||
* <entry key="id123">this is a value</entry>
|
||||
* <entry key="id312">this is another value</entry>
|
||||
* ...
|
||||
* </hashmap>
|
||||
* </pre>
|
||||
*
|
||||
* <p> <b> Step 2: </b> Determine the schema definition that the
|
||||
* desired XML representation shown above should follow.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* <xs:complexType name="myHashMapType">
|
||||
* <xs:sequence>
|
||||
* <xs:element name="entry" type="myHashMapEntryType"
|
||||
* minOccurs = "0" maxOccurs="unbounded"/>
|
||||
* </xs:sequence>
|
||||
* </xs:complexType>
|
||||
*
|
||||
* <xs:complexType name="myHashMapEntryType">
|
||||
* <xs:simpleContent>
|
||||
* <xs:extension base="xs:string">
|
||||
* <xs:attribute name="key" type="xs:int"/>
|
||||
* </xs:extension>
|
||||
* </xs:simpleContent>
|
||||
* </xs:complexType>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* <p> <b> Step 3: </b> Write value types that can generate the above
|
||||
* schema definition.
|
||||
*
|
||||
* <pre>
|
||||
* public class MyHashMapType {
|
||||
* List<MyHashMapEntryType> entry;
|
||||
* }
|
||||
*
|
||||
* public class MyHashMapEntryType {
|
||||
* @XmlAttribute
|
||||
* public Integer key;
|
||||
*
|
||||
* @XmlValue
|
||||
* public String value;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p> <b> Step 4: </b> Write the adapter that adapts the value type,
|
||||
* MyHashMapType to a bound type, HashMap, used by the application.
|
||||
*
|
||||
* <pre>
|
||||
* public final class MyHashMapAdapter extends
|
||||
* XmlAdapter<MyHashMapType,HashMap> { ... }
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* <p> <b> Step 5: </b> Use the adapter.
|
||||
*
|
||||
* <pre>
|
||||
* public class Foo {
|
||||
* @XmlJavaTypeAdapter(MyHashMapAdapter.class)
|
||||
* HashMap hashmap;
|
||||
* ...
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* The above code fragment will map to the following schema:
|
||||
*
|
||||
* <pre>
|
||||
* <xs:complexType name="Foo">
|
||||
* <xs:sequence>
|
||||
* <xs:element name="hashmap" type="myHashMapType"
|
||||
* </xs:sequence>
|
||||
* </xs:complexType>
|
||||
* </pre>
|
||||
*
|
||||
* @param <BoundType>
|
||||
* The type that JAXB doesn't know how to handle. An adapter is written
|
||||
* to allow this type to be used as an in-memory representation through
|
||||
* the <tt>ValueType</tt>.
|
||||
* @param <ValueType>
|
||||
* The type that JAXB knows how to handle out of the box.
|
||||
*
|
||||
* @author <ul><li>Sekhar Vajjhala, Sun Microsystems Inc.</li> <li> Kohsuke Kawaguchi, Sun Microsystems Inc.</li></ul>
|
||||
* @see XmlJavaTypeAdapter
|
||||
* @since JAXB 2.0
|
||||
*/
|
||||
public abstract class XmlAdapter<ValueType,BoundType> {
|
||||
|
||||
/**
|
||||
* Do-nothing constructor for the derived classes.
|
||||
*/
|
||||
protected XmlAdapter() {}
|
||||
|
||||
/**
|
||||
* Convert a value type to a bound type.
|
||||
*
|
||||
* @param v
|
||||
* The value to be converted. Can be null.
|
||||
* @throws Exception
|
||||
* if there's an error during the conversion. The caller is responsible for
|
||||
* reporting the error to the user through {@link javax.xml.bind.ValidationEventHandler}.
|
||||
*/
|
||||
public abstract BoundType unmarshal(ValueType v) throws Exception;
|
||||
|
||||
/**
|
||||
* Convert a bound type to a value type.
|
||||
*
|
||||
* @param v
|
||||
* The value to be convereted. Can be null.
|
||||
* @throws Exception
|
||||
* if there's an error during the conversion. The caller is responsible for
|
||||
* reporting the error to the user through {@link javax.xml.bind.ValidationEventHandler}.
|
||||
*/
|
||||
public abstract ValueType marshal(BoundType v) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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> <b> Usage: </b> </p>
|
||||
*
|
||||
* <p> The <tt>@XmlJavaTypeAdapter</tt> annotation can be used with the
|
||||
* following program elements:
|
||||
* <ul>
|
||||
* <li> a JavaBean property </li>
|
||||
* <li> field </li>
|
||||
* <li> parameter </li>
|
||||
* <li> package </li>
|
||||
* <li> from within {@link XmlJavaTypeAdapters} </li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on a
|
||||
* class, it applies to all references to the class.
|
||||
* <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined at the
|
||||
* package level it applies to all references from within the package
|
||||
* to <tt>@XmlJavaTypeAdapter.type()</tt>.
|
||||
* <p> When <tt>@XmlJavaTypeAdapter</tt> annotation is defined on the
|
||||
* field, property or parameter, then the annotation applies to the
|
||||
* field, property or the parameter only.
|
||||
* <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a field, property
|
||||
* or parameter overrides the <tt>@XmlJavaTypeAdapter</tt> annotation
|
||||
* associated with the class being referenced by the field, property
|
||||
* or parameter.
|
||||
* <p> A <tt>@XmlJavaTypeAdapter</tt> annotation on a class overrides
|
||||
* the <tt>@XmlJavaTypeAdapter</tt> 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><b> Example: </b> See example in {@link XmlAdapter}
|
||||
*
|
||||
* @author <ul><li>Sekhar Vajjhala, Sun Microsystems Inc.</li> <li> Kohsuke Kawaguchi, Sun Microsystems Inc.</li></ul>
|
||||
* @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 {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 static java.lang.annotation.ElementType.PACKAGE;
|
||||
import java.lang.annotation.Retention;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A container for multiple @{@link XmlJavaTypeAdapter} annotations.
|
||||
*
|
||||
* <p> Multiple annotations of the same type are not allowed on a program
|
||||
* element. This annotation therefore serves as a container annotation
|
||||
* for multiple @XmlJavaTypeAdapter as follows:
|
||||
*
|
||||
* <pre>
|
||||
* @XmlJavaTypeAdapters ({ @XmlJavaTypeAdapter(...),@XmlJavaTypeAdapter(...) })
|
||||
* </pre>
|
||||
*
|
||||
* <p>The <tt>@XmlJavaTypeAdapters</tt> annnotation is useful for
|
||||
* defining {@link XmlJavaTypeAdapter} annotations for different types
|
||||
* at the package level.
|
||||
*
|
||||
* <p>See "Package Specification" in javax.xml.bind.package javadoc for
|
||||
* additional common information.</p>
|
||||
*
|
||||
* @author <ul><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul>
|
||||
* @see XmlJavaTypeAdapter
|
||||
* @since JAXB2.0
|
||||
*/
|
||||
@Retention(RUNTIME) @Target({PACKAGE})
|
||||
public @interface XmlJavaTypeAdapters {
|
||||
/**
|
||||
* Collection of @{@link XmlJavaTypeAdapter} annotations
|
||||
*/
|
||||
XmlJavaTypeAdapter[] value();
|
||||
}
|
||||
Reference in New Issue
Block a user