feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
|
||||
/**
|
||||
* Signals an error in {@link RawAccessor}.
|
||||
*
|
||||
* <p>
|
||||
* This error is not reported to the user handler. Once reported
|
||||
* the error should be wrapped into another exception.
|
||||
*
|
||||
* <p>
|
||||
* This exception happens primarily when JAXB accesses the getter/setter
|
||||
* method and it throws a checked exception.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final class AccessorException extends Exception {
|
||||
public AccessorException() {
|
||||
}
|
||||
|
||||
public AccessorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public AccessorException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public AccessorException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
320
jdkSrc/jdk8/com/sun/xml/internal/bind/api/Bridge.java
Normal file
320
jdkSrc/jdk8/com/sun/xml/internal/bind/api/Bridge.java
Normal file
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentMarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentUnmarshaller;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.v2.runtime.BridgeContextImpl;
|
||||
import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.ContentHandler;
|
||||
|
||||
/**
|
||||
* Mini-marshaller/unmarshaller that is specialized for a particular
|
||||
* element name and a type.
|
||||
*
|
||||
* <p>
|
||||
* Instances of this class is stateless and multi-thread safe.
|
||||
* They are reentrant.
|
||||
*
|
||||
* <p>
|
||||
* All the marshal operation generates fragments.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since JAXB 2.0 EA1
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public abstract class Bridge<T> {
|
||||
protected Bridge(JAXBContextImpl context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
protected final JAXBContextImpl context;
|
||||
|
||||
/**
|
||||
* Gets the {@link JAXBRIContext} to which this object belongs.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public @NotNull JAXBRIContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while marshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final void marshal(T object,XMLStreamWriter output) throws JAXBException {
|
||||
marshal(object,output,null);
|
||||
}
|
||||
public final void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
m.setAttachmentMarshaller(am);
|
||||
marshal(m,object,output);
|
||||
m.setAttachmentMarshaller(null);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
|
||||
public final void marshal(@NotNull BridgeContext context,T object,XMLStreamWriter output) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, output );
|
||||
}
|
||||
|
||||
public abstract void marshal(@NotNull Marshaller m,T object,XMLStreamWriter output) throws JAXBException;
|
||||
|
||||
|
||||
/**
|
||||
* Marshals the specified type object with the implicit element name
|
||||
* associated with this instance of {@link Bridge}.
|
||||
*
|
||||
* @param nsContext
|
||||
* if this marshalling is done to marshal a subelement, this {@link NamespaceContext}
|
||||
* represents in-scope namespace bindings available for that element. Can be null,
|
||||
* in which case JAXB assumes no in-scope namespaces.
|
||||
* @throws JAXBException
|
||||
* if there was an error while marshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public void marshal(T object,OutputStream output, NamespaceContext nsContext) throws JAXBException {
|
||||
marshal(object,output,nsContext,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.2
|
||||
*/
|
||||
public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
m.setAttachmentMarshaller(am);
|
||||
marshal(m,object,output,nsContext);
|
||||
m.setAttachmentMarshaller(null);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
|
||||
public final void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, output, nsContext );
|
||||
}
|
||||
|
||||
public abstract void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException;
|
||||
|
||||
|
||||
public final void marshal(T object,Node output) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
marshal(m,object,output);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
|
||||
public final void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, output );
|
||||
}
|
||||
|
||||
public abstract void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException;
|
||||
|
||||
|
||||
/**
|
||||
* @since 2.0 EA4
|
||||
*/
|
||||
public final void marshal(T object, ContentHandler contentHandler) throws JAXBException {
|
||||
marshal(object,contentHandler,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.2
|
||||
*/
|
||||
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
m.setAttachmentMarshaller(am);
|
||||
marshal(m,object,contentHandler);
|
||||
m.setAttachmentMarshaller(null);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
public final void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, contentHandler );
|
||||
}
|
||||
public abstract void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException;
|
||||
|
||||
/**
|
||||
* @since 2.0 EA4
|
||||
*/
|
||||
public final void marshal(T object, Result result) throws JAXBException {
|
||||
Marshaller m = context.marshallerPool.take();
|
||||
marshal(m,object,result);
|
||||
context.marshallerPool.recycle(m);
|
||||
}
|
||||
public final void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException {
|
||||
marshal( ((BridgeContextImpl)context).marshaller, object, result );
|
||||
}
|
||||
public abstract void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException;
|
||||
|
||||
|
||||
|
||||
private T exit(T r, Unmarshaller u) {
|
||||
u.setAttachmentUnmarshaller(null);
|
||||
context.unmarshallerPool.recycle(u);
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link Bridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull XMLStreamReader in) throws JAXBException {
|
||||
return unmarshal(in,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull XMLStreamReader in, @Nullable AttachmentUnmarshaller au) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
u.setAttachmentUnmarshaller(au);
|
||||
return exit(unmarshal(u,in),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link Bridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Source in) throws JAXBException {
|
||||
return unmarshal(in,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Source in, @Nullable AttachmentUnmarshaller au) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
u.setAttachmentUnmarshaller(au);
|
||||
return exit(unmarshal(u,in),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param in
|
||||
* the parser must be pointing at a start tag
|
||||
* that encloses the XML type that this {@link Bridge} is
|
||||
* instanciated for.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull InputStream in) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
return exit(unmarshal(u,in),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, in );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Unmarshals the specified type object.
|
||||
*
|
||||
* @param n
|
||||
* Node to be unmarshalled.
|
||||
*
|
||||
* @return
|
||||
* never null.
|
||||
*
|
||||
* @throws JAXBException
|
||||
* if there was an error while unmarshalling.
|
||||
*
|
||||
* @since 2.0 FCS
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Node n) throws JAXBException {
|
||||
return unmarshal(n,null);
|
||||
}
|
||||
/**
|
||||
* @since 2.0.3
|
||||
*/
|
||||
public final @NotNull T unmarshal(@NotNull Node n, @Nullable AttachmentUnmarshaller au) throws JAXBException {
|
||||
Unmarshaller u = context.unmarshallerPool.take();
|
||||
u.setAttachmentUnmarshaller(au);
|
||||
return exit(unmarshal(u,n),u);
|
||||
}
|
||||
public final @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException {
|
||||
return unmarshal( ((BridgeContextImpl)context).unmarshaller, n );
|
||||
}
|
||||
public abstract @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Gets the {@link TypeReference} from which this bridge was created.
|
||||
*/
|
||||
public abstract TypeReference getTypeReference();
|
||||
}
|
98
jdkSrc/jdk8/com/sun/xml/internal/bind/api/BridgeContext.java
Normal file
98
jdkSrc/jdk8/com/sun/xml/internal/bind/api/BridgeContext.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import javax.xml.bind.ValidationEventHandler;
|
||||
import javax.xml.bind.attachment.AttachmentMarshaller;
|
||||
import javax.xml.bind.attachment.AttachmentUnmarshaller;
|
||||
|
||||
/**
|
||||
* Holds thread specific state information for {@link Bridge}s,
|
||||
* to make {@link Bridge} thread-safe.
|
||||
*
|
||||
* <p>
|
||||
* This object cannot be used concurrently; two threads cannot
|
||||
* use the same object with {@link Bridge}s at the same time, nor
|
||||
* a thread can use a {@link BridgeContext} with one {@link Bridge} while
|
||||
* the same context is in use by another {@link Bridge}.
|
||||
*
|
||||
* <p>
|
||||
* {@link BridgeContext} is relatively a heavy-weight object, and
|
||||
* therefore it is expected to be cached by the JAX-RPC RI.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 2.0 EA1
|
||||
* @see Bridge
|
||||
* @deprecated
|
||||
* The caller no longer needs to use this, as {@link Bridge} has
|
||||
* methods that can work without {@link BridgeContext}.
|
||||
*/
|
||||
public abstract class BridgeContext {
|
||||
protected BridgeContext() {}
|
||||
|
||||
/**
|
||||
* Registers the error handler that receives unmarshalling/marshalling errors.
|
||||
*
|
||||
* @param handler
|
||||
* can be null, in which case all errors will be considered fatal.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract void setErrorHandler(ValidationEventHandler handler);
|
||||
|
||||
/**
|
||||
* Sets the {@link AttachmentMarshaller}.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract void setAttachmentMarshaller(AttachmentMarshaller m);
|
||||
|
||||
/**
|
||||
* Sets the {@link AttachmentUnmarshaller}.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract void setAttachmentUnmarshaller(AttachmentUnmarshaller m);
|
||||
|
||||
/**
|
||||
* Gets the last {@link AttachmentMarshaller} set through
|
||||
* {@link AttachmentMarshaller}.
|
||||
*
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public abstract AttachmentMarshaller getAttachmentMarshaller();
|
||||
|
||||
/**
|
||||
* Gets the last {@link AttachmentUnmarshaller} set through
|
||||
* {@link AttachmentUnmarshaller}.
|
||||
*
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public abstract AttachmentUnmarshaller getAttachmentUnmarshaller();
|
||||
}
|
104
jdkSrc/jdk8/com/sun/xml/internal/bind/api/ClassResolver.java
Normal file
104
jdkSrc/jdk8/com/sun/xml/internal/bind/api/ClassResolver.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.ValidationEventHandler;
|
||||
import javax.xml.bind.annotation.XmlAnyElement;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
|
||||
/**
|
||||
* Dynamically locates classes to represent elements discovered during the unmarshalling.
|
||||
*
|
||||
* <p>
|
||||
* <b>THIS INTERFACE IS SUBJECT TO CHANGE WITHOUT NOTICE.</b>
|
||||
*
|
||||
* <h2>Background</h2>
|
||||
* <p>
|
||||
* {@link JAXBContext#newInstance(Class...)} requires that application informs JAXB
|
||||
* about all the classes that it may see in the instance document. While this allows
|
||||
* JAXB to take time to optimize the unmarshalling, it is sometimes inconvenient
|
||||
* for applications.
|
||||
*
|
||||
* <p>
|
||||
* This is where {@link ClassResolver} comes to resucue.
|
||||
*
|
||||
* <p>
|
||||
* A {@link ClassResolver} instance can be specified on {@link Unmarshaller} via
|
||||
* {@link Unmarshaller#setProperty(String, Object)} as follows:
|
||||
*
|
||||
* <pre>
|
||||
* unmarshaller.setProperty( ClassResolver.class.getName(), new MyClassResolverImpl() );
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* When an {@link Unmarshaller} encounters (i) an unknown root element or (ii) unknown
|
||||
* elements where unmarshaller is trying to unmarshal into {@link XmlAnyElement} with
|
||||
* <tt>lax=true</tt>, unmarshaller calls {@link #resolveElementName(String, String)}
|
||||
* method to see if the application may be able to supply a class that corresponds
|
||||
* to that class.
|
||||
*
|
||||
* <p>
|
||||
* When a {@link Class} is returned, a new {@link JAXBContext} is created with
|
||||
* all the classes known to it so far, plus a new class returned. This operation
|
||||
* may fail (for example because of some conflicting annotations.) This failure
|
||||
* is handled just like {@link Exception}s thrown from
|
||||
* {@link ClassResolver#resolveElementName(String, String)}.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract class ClassResolver {
|
||||
/**
|
||||
* JAXB calls this method when it sees an unknown element.
|
||||
*
|
||||
* <p>
|
||||
* See the class javadoc for details.
|
||||
*
|
||||
* @param nsUri
|
||||
* Namespace URI of the unknown element. Can be empty but never null.
|
||||
* @param localName
|
||||
* Local name of the unknown element. Never be empty nor null.
|
||||
*
|
||||
* @return
|
||||
* If a non-null class is returned, it will be used to unmarshal this element.
|
||||
* If null is returned, the resolution is assumed to be failed, and
|
||||
* the unmarshaller will behave as if there was no {@link ClassResolver}
|
||||
* to begin with (that is, to report it to {@link ValidationEventHandler},
|
||||
* then move on.)
|
||||
*
|
||||
* @throws Exception
|
||||
* Throwing any {@link RuntimeException} causes the unmarshaller to stop
|
||||
* immediately. The exception will be propagated up the call stack.
|
||||
* Throwing any other checked {@link Exception} results in the error
|
||||
* reproted to {@link ValidationEventHandler} (just like any other error
|
||||
* during the unmarshalling.)
|
||||
*/
|
||||
public abstract @Nullable Class<?> resolveElementName(@NotNull String nsUri, @NotNull String localName) throws Exception;
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
/**
|
||||
* A JAXB Bean that works like a DOM.
|
||||
*
|
||||
* <p>
|
||||
* This bean is bound to XML as a sequence of elements, where each
|
||||
* element[i] is from bridges[i] (which defines the tag name and the expected type)
|
||||
* and values[i] (which defines the actual value.)
|
||||
*
|
||||
* <p>
|
||||
* This object allows you to treat multiple unrelated JAXB beans as a single tree.
|
||||
* This in turn allows you to marshal this tree in one marshal method invocation,
|
||||
* which is faster than multiple invocations of the marshal method.
|
||||
*
|
||||
* <p>
|
||||
* The binding of this class is always known to {@link JAXBRIContext}, so it can be
|
||||
* used without passing anything to {@link JAXBRIContext#newInstance}.
|
||||
* This object can be only used for marshalling, not for unmarshalling.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class CompositeStructure {
|
||||
public Bridge[] bridges;
|
||||
public Object[] values;
|
||||
}
|
56
jdkSrc/jdk8/com/sun/xml/internal/bind/api/ErrorListener.java
Normal file
56
jdkSrc/jdk8/com/sun/xml/internal/bind/api/ErrorListener.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
/**
|
||||
* Implemented by the driver of the compiler engine to handle
|
||||
* errors found during the compiliation.
|
||||
*
|
||||
* <p>
|
||||
* This class implements {@link ErrorHandler} so it can be
|
||||
* passed to anywhere where {@link ErrorHandler} is expected.
|
||||
*
|
||||
* <p>
|
||||
* However, to make the error handling easy (and make it work
|
||||
* with visitor patterns nicely), this interface is not allowed
|
||||
* to abort the processing. It merely receives errors.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
public interface ErrorListener extends ErrorHandler {
|
||||
void error(SAXParseException exception);
|
||||
void fatalError(SAXParseException exception);
|
||||
void warning(SAXParseException exception);
|
||||
/**
|
||||
* Used to report possibly verbose information that
|
||||
* can be safely ignored.
|
||||
*/
|
||||
void info(SAXParseException exception);
|
||||
}
|
537
jdkSrc/jdk8/com/sun/xml/internal/bind/api/JAXBRIContext.java
Normal file
537
jdkSrc/jdk8/com/sun/xml/internal/bind/api/JAXBRIContext.java
Normal file
@@ -0,0 +1,537 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.SchemaOutputResolver;
|
||||
import javax.xml.bind.annotation.XmlAttachmentRef;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Result;
|
||||
|
||||
import com.sun.istack.internal.NotNull;
|
||||
import com.sun.istack.internal.Nullable;
|
||||
import com.sun.xml.internal.bind.api.impl.NameConverter;
|
||||
import com.sun.xml.internal.bind.v2.ContextFactory;
|
||||
import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader;
|
||||
import com.sun.xml.internal.bind.v2.model.runtime.RuntimeTypeInfoSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* {@link JAXBContext} enhanced with JAXB RI specific functionalities.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
* @author
|
||||
* Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
|
||||
*/
|
||||
public abstract class JAXBRIContext extends JAXBContext {
|
||||
|
||||
protected JAXBRIContext() {}
|
||||
|
||||
/**
|
||||
* Creates a new {@link JAXBRIContext}.
|
||||
*
|
||||
* <p>
|
||||
* {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
|
||||
* return other JAXB providers that are not compatible with the JAX-RPC RI.
|
||||
* This method guarantees that the JAX-WS RI will finds the JAXB RI.
|
||||
*
|
||||
* @param classes
|
||||
* Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
|
||||
* @param typeRefs
|
||||
* See {@link #TYPE_REFERENCES} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param subclassReplacements
|
||||
* See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param defaultNamespaceRemap
|
||||
* See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
|
||||
* Can be null (and should be null for ordinary use of JAXB.)
|
||||
* @param c14nSupport
|
||||
* See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
|
||||
* @param ar
|
||||
* See {@link #ANNOTATION_READER} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @since JAXB 2.1 EA2
|
||||
*/
|
||||
public static JAXBRIContext newInstance(@NotNull Class[] classes,
|
||||
@Nullable Collection<TypeReference> typeRefs,
|
||||
@Nullable Map<Class,Class> subclassReplacements,
|
||||
@Nullable String defaultNamespaceRemap, boolean c14nSupport,
|
||||
@Nullable RuntimeAnnotationReader ar) throws JAXBException {
|
||||
return newInstance(classes, typeRefs, subclassReplacements,
|
||||
defaultNamespaceRemap, c14nSupport, ar, false, false, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link JAXBRIContext}.
|
||||
*
|
||||
* <p>
|
||||
* {@link JAXBContext#newInstance(Class[]) JAXBContext.newInstance()} methods may
|
||||
* return other JAXB providers that are not compatible with the JAX-RPC RI.
|
||||
* This method guarantees that the JAX-WS RI will finds the JAXB RI.
|
||||
*
|
||||
* @param classes
|
||||
* Classes to be bound. See {@link JAXBContext#newInstance(Class[])} for the meaning.
|
||||
* @param typeRefs
|
||||
* See {@link #TYPE_REFERENCES} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param subclassReplacements
|
||||
* See {@link #SUBCLASS_REPLACEMENTS} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param defaultNamespaceRemap
|
||||
* See {@link #DEFAULT_NAMESPACE_REMAP} for the meaning of this parameter.
|
||||
* Can be null (and should be null for ordinary use of JAXB.)
|
||||
* @param c14nSupport
|
||||
* See {@link #CANONICALIZATION_SUPPORT} for the meaning of this parameter.
|
||||
* @param ar
|
||||
* See {@link #ANNOTATION_READER} for the meaning of this parameter.
|
||||
* Can be null.
|
||||
* @param xmlAccessorFactorySupport
|
||||
* See {@link #XMLACCESSORFACTORY_SUPPORT} for the meaning of this parameter.
|
||||
* @param allNillable
|
||||
* See {@link #TREAT_EVERYTHING_NILLABLE} for the meaning of this parameter.
|
||||
* @param retainPropertyInfo
|
||||
* See {@link #RETAIN_REFERENCE_TO_INFO} for the meaning of this parameter.
|
||||
* @param supressAccessorWarnings
|
||||
* See {@link #SUPRESS_ACCESSOR_WARNINGS} for the meaning of this parameter.
|
||||
*/
|
||||
public static JAXBRIContext newInstance(@NotNull Class[] classes,
|
||||
@Nullable Collection<TypeReference> typeRefs,
|
||||
@Nullable Map<Class,Class> subclassReplacements,
|
||||
@Nullable String defaultNamespaceRemap, boolean c14nSupport,
|
||||
@Nullable RuntimeAnnotationReader ar,
|
||||
boolean xmlAccessorFactorySupport,
|
||||
boolean allNillable,
|
||||
boolean retainPropertyInfo,
|
||||
boolean supressAccessorWarnings) throws JAXBException {
|
||||
Map<String, Object> properties = new HashMap<String, Object>();
|
||||
if (typeRefs != null) properties.put(JAXBRIContext.TYPE_REFERENCES, typeRefs);
|
||||
if (subclassReplacements != null) properties.put(JAXBRIContext.SUBCLASS_REPLACEMENTS, subclassReplacements);
|
||||
if (defaultNamespaceRemap != null) properties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, defaultNamespaceRemap);
|
||||
if (ar != null) properties.put(JAXBRIContext.ANNOTATION_READER, ar);
|
||||
properties.put(JAXBRIContext.CANONICALIZATION_SUPPORT, Boolean.valueOf(c14nSupport));
|
||||
properties.put(JAXBRIContext.XMLACCESSORFACTORY_SUPPORT, Boolean.valueOf(xmlAccessorFactorySupport));
|
||||
properties.put(JAXBRIContext.TREAT_EVERYTHING_NILLABLE, Boolean.valueOf(allNillable));
|
||||
properties.put(JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.valueOf(retainPropertyInfo));
|
||||
properties.put(JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.valueOf(supressAccessorWarnings));
|
||||
return (JAXBRIContext) ContextFactory.createContext(classes, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Compatibility with older versions.
|
||||
*/
|
||||
public static JAXBRIContext newInstance(@NotNull Class[] classes,
|
||||
@Nullable Collection<TypeReference> typeRefs,
|
||||
@Nullable String defaultNamespaceRemap, boolean c14nSupport ) throws JAXBException {
|
||||
return newInstance(classes,typeRefs, Collections.<Class,Class>emptyMap(),
|
||||
defaultNamespaceRemap,c14nSupport,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this context includes a class
|
||||
* that has {@link XmlAttachmentRef}.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract boolean hasSwaRef();
|
||||
|
||||
/**
|
||||
* If the given object is bound to an element in XML by JAXB,
|
||||
* returns the element name.
|
||||
*
|
||||
* @return null
|
||||
* if the object is not bound to an element.
|
||||
* @throws JAXBException
|
||||
* if the object is not known to this context.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract @Nullable QName getElementName(@NotNull Object o) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Allows to retrieve the element name based on Class.
|
||||
* @param o
|
||||
* @return
|
||||
* @throws javax.xml.bind.JAXBException
|
||||
* @since 2.1.10
|
||||
*/
|
||||
public abstract @Nullable QName getElementName(@NotNull Class o) throws JAXBException;
|
||||
|
||||
/**
|
||||
* Creates a mini-marshaller/unmarshaller that can process a {@link TypeReference}.
|
||||
*
|
||||
* @return
|
||||
* null if the specified reference is not given to {@link JAXBRIContext#newInstance}.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract Bridge createBridge(@NotNull TypeReference ref);
|
||||
|
||||
/**
|
||||
* Creates a new {@link BridgeContext} instance.
|
||||
*
|
||||
* @return
|
||||
* always a valid non-null instance.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract @NotNull BridgeContext createBridgeContext();
|
||||
|
||||
/**
|
||||
* Gets a {@link RawAccessor} for the specified element property of the specified wrapper bean class.
|
||||
*
|
||||
* <p>
|
||||
* This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.)
|
||||
* In the said mode, a wrapper bean is supposed to only have properties that match elements,
|
||||
* and for each element that appear in the content model there's one property.
|
||||
*
|
||||
* <p>
|
||||
* Therefore, this method takes a wrapper bean and a tag name that identifies a property
|
||||
* on the given wrapper bean, then returns a {@link RawAccessor} that allows the caller
|
||||
* to set/get a value from the property of the bean.
|
||||
*
|
||||
* <p>
|
||||
* This method is not designed for a performance. The caller is expected to cache the result.
|
||||
*
|
||||
* @param <B>
|
||||
* type of the wrapper bean
|
||||
* @param <V>
|
||||
* type of the property of the bean
|
||||
* @return
|
||||
* always return non-null valid accessor object.
|
||||
* @throws JAXBException
|
||||
* if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property
|
||||
* of the given name.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract <B,V> RawAccessor<B,V> getElementPropertyAccessor( Class<B> wrapperBean, String nsUri, String localName )
|
||||
throws JAXBException;
|
||||
|
||||
/**
|
||||
* Gets the namespace URIs statically known to this {@link JAXBContext}.
|
||||
*
|
||||
* <p>
|
||||
* When JAXB is used to marshal into sub-trees, it declares
|
||||
* these namespace URIs at each top-level element that it marshals.
|
||||
*
|
||||
* To avoid repeated namespace declarations at sub-elements, the application
|
||||
* may declare those namespaces at a higher level.
|
||||
*
|
||||
* @return
|
||||
* always non-null.
|
||||
*
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public abstract @NotNull List<String> getKnownNamespaceURIs();
|
||||
|
||||
|
||||
/**
|
||||
* Generates the schema documents from the model.
|
||||
*
|
||||
* <p>
|
||||
* The caller can use the additionalElementDecls parameter to
|
||||
* add element declarations to the generate schema.
|
||||
* For example, if the JAX-RPC passes in the following entry:
|
||||
*
|
||||
* {foo}bar -> DeclaredType for java.lang.String
|
||||
*
|
||||
* then JAXB generates the following element declaration (in the schema
|
||||
* document for the namespace "foo")"
|
||||
*
|
||||
* <xs:element name="bar" type="xs:string" />
|
||||
*
|
||||
* This can be used for generating schema components necessary for WSDL.
|
||||
*
|
||||
* @param outputResolver
|
||||
* this object controls the output to which schemas
|
||||
* will be sent.
|
||||
*
|
||||
* @throws IOException
|
||||
* if {@link SchemaOutputResolver} throws an {@link IOException}.
|
||||
*/
|
||||
@Override
|
||||
public abstract void generateSchema(@NotNull SchemaOutputResolver outputResolver) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the name of the XML Type bound to the
|
||||
* specified Java type.
|
||||
*
|
||||
* @param tr
|
||||
* must not be null. This must be one of the {@link TypeReference}s specified
|
||||
* in the {@link JAXBRIContext#newInstance} method.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the parameter is null or not a part of the {@link TypeReference}s specified
|
||||
* in the {@link JAXBRIContext#newInstance} method.
|
||||
*
|
||||
* @return null
|
||||
* if the referenced type is an anonymous and therefore doesn't have a name.
|
||||
*/
|
||||
public abstract QName getTypeName(@NotNull TypeReference tr);
|
||||
|
||||
/**
|
||||
* Gets the build information of the JAXB runtime.
|
||||
*
|
||||
* @return
|
||||
* may be null, if the runtime is loaded by a class loader that doesn't support
|
||||
* the access to the manifest informatino.
|
||||
*/
|
||||
public abstract @NotNull String getBuildId();
|
||||
|
||||
/**
|
||||
* Generates the episode file that represents the binding known to this {@link JAXBContext},
|
||||
* so that XJC can later do separate compilation.
|
||||
*
|
||||
* <p>
|
||||
* Episode file is really just a JAXB customization file, except that currently
|
||||
* we use the RI-specific SCD to refer to schema components.
|
||||
*
|
||||
* @param output
|
||||
* This receives the generated episode file.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public abstract void generateEpisode(Result output);
|
||||
|
||||
/**
|
||||
* Allows you to access the runtime model information of the JAXB XML/Java binding.
|
||||
*
|
||||
* <p>
|
||||
* This is useful for doing a deeper integration with the JAXB RI.
|
||||
* For more information about the model, see https://jaxb2-reflection.dev.java.net/
|
||||
*
|
||||
* @since 2.1.10
|
||||
*/
|
||||
public abstract RuntimeTypeInfoSet getRuntimeTypeInfoSet();
|
||||
|
||||
/**
|
||||
* Computes a Java identifier from a local name.
|
||||
*
|
||||
* <p>
|
||||
* This method faithfully implements the name mangling rule as specified in the JAXB spec.
|
||||
*
|
||||
* <p>
|
||||
* In JAXB, a collision with a Java reserved word (such as "return") never happens.
|
||||
* Accordingly, this method may return an identifier that collides with reserved words.
|
||||
*
|
||||
* <p>
|
||||
* Use <tt>JJavaName.isJavaIdentifier(String)</tt> to check for such collision.
|
||||
*
|
||||
* @return
|
||||
* Typically, this method returns "nameLikeThis".
|
||||
*/
|
||||
public static @NotNull String mangleNameToVariableName(@NotNull String localName) {
|
||||
return NameConverter.standard.toVariableName(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a Java class name from a local name.
|
||||
*
|
||||
* <p>
|
||||
* This method faithfully implements the name mangling rule as specified in the JAXB spec.
|
||||
*
|
||||
* @return
|
||||
* Typically, this method returns "NameLikeThis".
|
||||
*/
|
||||
public static @NotNull String mangleNameToClassName(@NotNull String localName) {
|
||||
return NameConverter.standard.toClassName(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a Java class name from a local name.
|
||||
*
|
||||
* <p>
|
||||
* This method faithfully implements the name mangling rule as specified in the JAXB spec.
|
||||
* This method works like {@link #mangleNameToClassName(String)} except that it looks
|
||||
* for "getClass" and returns something else.
|
||||
*
|
||||
* @return
|
||||
* Typically, this method returns "NameLikeThis".
|
||||
*/
|
||||
public static @NotNull String mangleNameToPropertyName(@NotNull String localName) {
|
||||
return NameConverter.standard.toPropertyName(localName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameterization of the given base type.
|
||||
*
|
||||
* <p>
|
||||
* For example, given the following
|
||||
* <pre><xmp>
|
||||
* interface Foo<T> extends List<List<T>> {}
|
||||
* interface Bar extends Foo<String> {}
|
||||
* </xmp></pre>
|
||||
* This method works like this:
|
||||
* <pre><xmp>
|
||||
* getBaseClass( Bar, List ) = List<List<String>
|
||||
* getBaseClass( Bar, Foo ) = Foo<String>
|
||||
* getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
|
||||
* getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
|
||||
* </xmp></pre>
|
||||
*
|
||||
* @param type
|
||||
* The type that derives from {@code baseType}
|
||||
* @param baseType
|
||||
* The class whose parameterization we are interested in.
|
||||
* @return
|
||||
* The use of {@code baseType} in {@code type}.
|
||||
* or null if the type is not assignable to the base type.
|
||||
* @since 2.0 FCS
|
||||
*/
|
||||
public static @Nullable Type getBaseType(@NotNull Type type, @NotNull Class baseType) {
|
||||
return Utils.REFLECTION_NAVIGATOR.getBaseClass(type, baseType);
|
||||
}
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to reassign the default namespace URI to something else at the runtime.
|
||||
*
|
||||
* <p>
|
||||
* The value of the property is {@link String}, and it is used as the namespace URI
|
||||
* that succeeds the default namespace URI.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public static final String DEFAULT_NAMESPACE_REMAP = "com.sun.xml.internal.bind.defaultNamespaceRemap";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to put additional JAXB type references into the {@link JAXBContext}.
|
||||
*
|
||||
* <p>
|
||||
* The value of the property is {@link Collection}<{@link TypeReference}>.
|
||||
* Those {@link TypeReference}s can then be used to create {@link Bridge}s.
|
||||
*
|
||||
* <p>
|
||||
* This mechanism allows additional element declarations that were not a part of
|
||||
* the schema into the created {@link JAXBContext}.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public static final String TYPE_REFERENCES = "com.sun.xml.internal.bind.typeReferences";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* and {@link Marshaller#setProperty(String, Object)}
|
||||
* to enable the c14n marshalling support in the {@link JAXBContext}.
|
||||
*
|
||||
* Boolean
|
||||
* @see C14nSupport_ArchitectureDocument
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public static final String CANONICALIZATION_SUPPORT = "com.sun.xml.internal.bind.c14n";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to allow unmarshaller to honor <tt>xsi:nil</tt> anywhere, even if they are
|
||||
* not specifically allowed by the schema.
|
||||
*
|
||||
* Boolean
|
||||
* @since 2.1.3
|
||||
*/
|
||||
public static final String TREAT_EVERYTHING_NILLABLE = "com.sun.xml.internal.bind.treatEverythingNillable";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to use alternative {@link RuntimeAnnotationReader} implementation.
|
||||
*
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
public static final String ANNOTATION_READER = RuntimeAnnotationReader.class.getName();
|
||||
|
||||
/**
|
||||
* Marshaller/Unmarshaller property to enable XOP processing.
|
||||
*
|
||||
* @since 2.0 EA2
|
||||
*/
|
||||
public static final String ENABLE_XOP = "com.sun.xml.internal.bind.XOP";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* to specify specific classes that replace the reference to generic classes.
|
||||
*
|
||||
* <p>
|
||||
* See the release notes for more details about this feature.
|
||||
*
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
public static final String SUBCLASS_REPLACEMENTS = "com.sun.xml.internal.bind.subclassReplacements";
|
||||
|
||||
/**
|
||||
* The property that you can specify to {@link JAXBContext#newInstance}
|
||||
* enable support of XmlAccessorFactory annotation in the {@link JAXBContext}.
|
||||
*
|
||||
* @since 2.1 EA2
|
||||
*/
|
||||
public static final String XMLACCESSORFACTORY_SUPPORT = "com.sun.xml.internal.bind.XmlAccessorFactory";
|
||||
|
||||
/**
|
||||
* Retains references to PropertyInfos.
|
||||
*
|
||||
* Boolean
|
||||
* @since 2.1.10
|
||||
*/
|
||||
public static final String RETAIN_REFERENCE_TO_INFO = "retainReferenceToInfo";
|
||||
|
||||
/**
|
||||
* Supress security warnings when trying to access fields through reflection.
|
||||
*
|
||||
* Boolean
|
||||
* @since 2.1.14, 2.2.2
|
||||
*/
|
||||
public static final String SUPRESS_ACCESSOR_WARNINGS = "supressAccessorWarnings";
|
||||
|
||||
/**
|
||||
* Improves handling of xsi:type used on leaf properties.
|
||||
*
|
||||
* Boolean
|
||||
* @since 2.2.3
|
||||
*/
|
||||
public static final String IMPROVED_XSI_TYPE_HANDLING = "com.sun.xml.internal.bind.improvedXsiTypeHandling";
|
||||
|
||||
/**
|
||||
* If true XML security features when parsing XML documents will be disabled.
|
||||
* The default value is false.
|
||||
*
|
||||
* Boolean
|
||||
* @since 2.2.6
|
||||
*/
|
||||
public static final String DISABLE_XML_SECURITY = "com.sun.xml.internal.bind.disableXmlSecurity";
|
||||
}
|
52
jdkSrc/jdk8/com/sun/xml/internal/bind/api/Messages.java
Normal file
52
jdkSrc/jdk8/com/sun/xml/internal/bind/api/Messages.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Formats error messages.
|
||||
*
|
||||
* @since JAXB2.1.10
|
||||
*/
|
||||
|
||||
enum Messages {
|
||||
// TypeReference
|
||||
ARGUMENT_CANT_BE_NULL
|
||||
;
|
||||
|
||||
private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName());
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return format();
|
||||
}
|
||||
|
||||
public String format( Object... args ) {
|
||||
return MessageFormat.format( rb.getString(name()), args );
|
||||
}
|
||||
}
|
73
jdkSrc/jdk8/com/sun/xml/internal/bind/api/RawAccessor.java
Normal file
73
jdkSrc/jdk8/com/sun/xml/internal/bind/api/RawAccessor.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Accesses a particular property of a bean.
|
||||
*
|
||||
* <p>
|
||||
* This interface allows JAX-RPC to access an element property of a JAXB bean.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract class RawAccessor<B,V> {
|
||||
|
||||
/**
|
||||
* Gets the value of the property of the given bean object.
|
||||
*
|
||||
* @param bean
|
||||
* must not be null.
|
||||
* @throws AccessorException
|
||||
* if failed to set a value. For example, the getter method
|
||||
* may throw an exception.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract V get(B bean) throws AccessorException;
|
||||
|
||||
/**
|
||||
* Sets the value of the property of the given bean object.
|
||||
*
|
||||
* @param bean
|
||||
* must not be null.
|
||||
* @param value
|
||||
* the value to be set. Setting value to null means resetting
|
||||
* to the VM default value (even for primitive properties.)
|
||||
* @throws AccessorException
|
||||
* if failed to set a value. For example, the setter method
|
||||
* may throw an exception.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
*/
|
||||
public abstract void set(B bean,V value) throws AccessorException;
|
||||
}
|
134
jdkSrc/jdk8/com/sun/xml/internal/bind/api/TypeReference.java
Normal file
134
jdkSrc/jdk8/com/sun/xml/internal/bind/api/TypeReference.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* A reference to a JAXB-bound type.
|
||||
*
|
||||
* <p>
|
||||
* <b>Subject to change without notice</b>.
|
||||
*
|
||||
* @since 2.0 EA1
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public final class TypeReference {
|
||||
|
||||
/**
|
||||
* The associated XML element name that the JAX-RPC uses with this type reference.
|
||||
*
|
||||
* Always non-null. Strings are interned.
|
||||
*/
|
||||
public final QName tagName;
|
||||
|
||||
/**
|
||||
* The Java type that's being referenced.
|
||||
*
|
||||
* Always non-null.
|
||||
*/
|
||||
public final Type type;
|
||||
|
||||
/**
|
||||
* The annotations associated with the reference of this type.
|
||||
*
|
||||
* Always non-null.
|
||||
*/
|
||||
public final Annotation[] annotations;
|
||||
|
||||
public TypeReference(QName tagName, Type type, Annotation... annotations) {
|
||||
if(tagName==null || type==null || annotations==null) {
|
||||
String nullArgs = "";
|
||||
|
||||
if(tagName == null) nullArgs = "tagName";
|
||||
if(type == null) nullArgs += (nullArgs.length() > 0 ? ", type" : "type");
|
||||
if(annotations == null) nullArgs += (nullArgs.length() > 0 ? ", annotations" : "annotations");
|
||||
|
||||
Messages.ARGUMENT_CANT_BE_NULL.format(nullArgs);
|
||||
|
||||
throw new IllegalArgumentException(Messages.ARGUMENT_CANT_BE_NULL.format(nullArgs));
|
||||
}
|
||||
|
||||
this.tagName = new QName(tagName.getNamespaceURI().intern(), tagName.getLocalPart().intern(), tagName.getPrefix());
|
||||
this.type = type;
|
||||
this.annotations = annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the specified annotation from the array and returns it.
|
||||
* Null if not found.
|
||||
*/
|
||||
public <A extends Annotation> A get( Class<A> annotationType ) {
|
||||
for (Annotation a : annotations) {
|
||||
if(a.annotationType()==annotationType)
|
||||
return annotationType.cast(a);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link TypeReference} for the item type,
|
||||
* if this {@link TypeReference} represents a collection type.
|
||||
* Otherwise returns an identical type.
|
||||
*/
|
||||
public TypeReference toItemType() {
|
||||
// if we are to reinstitute this check, check JAXB annotations only
|
||||
// assert annotations.length==0; // not designed to work with adapters.
|
||||
|
||||
Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(type, Collection.class);
|
||||
if(base==null)
|
||||
return this; // not a collection
|
||||
|
||||
return new TypeReference(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TypeReference that = (TypeReference) o;
|
||||
|
||||
if (!Arrays.equals(annotations, that.annotations)) return false;
|
||||
if (!tagName.equals(that.tagName)) return false;
|
||||
if (!type.equals(that.type)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = tagName.hashCode();
|
||||
result = 31 * result + type.hashCode();
|
||||
result = 31 * result + Arrays.hashCode(annotations);
|
||||
return result;
|
||||
}
|
||||
}
|
94
jdkSrc/jdk8/com/sun/xml/internal/bind/api/Utils.java
Normal file
94
jdkSrc/jdk8/com/sun/xml/internal/bind/api/Utils.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2014, 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 com.sun.xml.internal.bind.api;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Utils class.
|
||||
*
|
||||
* WARNING: If you are doing any changes don't forget to change other Utils classes in different packages.
|
||||
*
|
||||
* Has *package private* access to avoid inappropriate usage.
|
||||
*/
|
||||
final class Utils {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Utils.class.getName());
|
||||
|
||||
/**
|
||||
* static ReflectionNavigator field to avoid usage of reflection every time we use it.
|
||||
*/
|
||||
static final Navigator<Type, Class, Field, Method> REFLECTION_NAVIGATOR;
|
||||
|
||||
static { // we statically initializing REFLECTION_NAVIGATOR property
|
||||
try {
|
||||
final Class refNav = Class.forName("com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator");
|
||||
|
||||
// requires accessClassInPackage privilege
|
||||
final Method getInstance = AccessController.doPrivileged(
|
||||
new PrivilegedAction<Method>() {
|
||||
@Override
|
||||
public Method run() {
|
||||
try {
|
||||
Method getInstance = refNav.getDeclaredMethod("getInstance");
|
||||
getInstance.setAccessible(true);
|
||||
return getInstance;
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance can't be found");
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//noinspection unchecked
|
||||
REFLECTION_NAVIGATOR = (Navigator<Type, Class, Field, Method>) getInstance.invoke(null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalStateException("Can't find ReflectionNavigator class");
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance throws the exception");
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new IllegalStateException("ReflectionNavigator.getInstance method is inaccessible");
|
||||
} catch (SecurityException e) {
|
||||
LOGGER.log(Level.FINE, "Unable to access ReflectionNavigator.getInstance", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* private constructor to avoid util class instantiating
|
||||
*/
|
||||
private Utils() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, 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 com.sun.xml.internal.bind.api.impl;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* Converts aribitrary strings into Java identifiers.
|
||||
*
|
||||
* @author
|
||||
* <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
|
||||
*/
|
||||
public interface NameConverter
|
||||
{
|
||||
/**
|
||||
* converts a string into an identifier suitable for classes.
|
||||
*
|
||||
* In general, this operation should generate "NamesLikeThis".
|
||||
*/
|
||||
String toClassName( String token );
|
||||
|
||||
/**
|
||||
* converts a string into an identifier suitable for interfaces.
|
||||
*
|
||||
* In general, this operation should generate "NamesLikeThis".
|
||||
* But for example, it can prepend every interface with 'I'.
|
||||
*/
|
||||
String toInterfaceName( String token );
|
||||
|
||||
/**
|
||||
* converts a string into an identifier suitable for properties.
|
||||
*
|
||||
* In general, this operation should generate "NamesLikeThis",
|
||||
* which will be used with known prefixes like "get" or "set".
|
||||
*/
|
||||
String toPropertyName( String token );
|
||||
|
||||
/**
|
||||
* converts a string into an identifier suitable for constants.
|
||||
*
|
||||
* In the standard Java naming convention, this operation should
|
||||
* generate "NAMES_LIKE_THIS".
|
||||
*/
|
||||
String toConstantName( String token );
|
||||
|
||||
/**
|
||||
* Converts a string into an identifier suitable for variables.
|
||||
*
|
||||
* In general it should generate "namesLikeThis".
|
||||
*/
|
||||
String toVariableName( String token );
|
||||
|
||||
/**
|
||||
* Converts a namespace URI into a package name.
|
||||
* This method should expect strings like
|
||||
* "http://foo.bar.zot/org", "urn:abc:def:ghi" "", or even "###"
|
||||
* (basically anything) and expected to return a package name,
|
||||
* liks "org.acme.foo".
|
||||
*
|
||||
*/
|
||||
String toPackageName( String namespaceUri );
|
||||
|
||||
/**
|
||||
* The name converter implemented by Code Model.
|
||||
*
|
||||
* This is the standard name conversion for JAXB.
|
||||
*/
|
||||
public static final NameConverter standard = new Standard();
|
||||
|
||||
static class Standard extends NameUtil implements NameConverter {
|
||||
public String toClassName(String s) {
|
||||
return toMixedCaseName(toWordList(s), true);
|
||||
}
|
||||
public String toVariableName(String s) {
|
||||
return toMixedCaseName(toWordList(s), false);
|
||||
}
|
||||
public String toInterfaceName( String token ) {
|
||||
return toClassName(token);
|
||||
}
|
||||
public String toPropertyName(String s) {
|
||||
String prop = toClassName(s);
|
||||
// property name "Class" with collide with Object.getClass,
|
||||
// so escape this.
|
||||
if(prop.equals("Class"))
|
||||
prop = "Clazz";
|
||||
return prop;
|
||||
}
|
||||
public String toConstantName( String token ) {
|
||||
return super.toConstantName(token);
|
||||
}
|
||||
/**
|
||||
* Computes a Java package name from a namespace URI,
|
||||
* as specified in the spec.
|
||||
*
|
||||
* @return
|
||||
* null if it fails to derive a package name.
|
||||
*/
|
||||
public String toPackageName( String nsUri ) {
|
||||
// remove scheme and :, if present
|
||||
// spec only requires us to remove 'http' and 'urn'...
|
||||
int idx = nsUri.indexOf(':');
|
||||
String scheme = "";
|
||||
if(idx>=0) {
|
||||
scheme = nsUri.substring(0,idx);
|
||||
if( scheme.equalsIgnoreCase("http") || scheme.equalsIgnoreCase("urn") )
|
||||
nsUri = nsUri.substring(idx+1);
|
||||
}
|
||||
|
||||
// tokenize string
|
||||
ArrayList<String> tokens = tokenize( nsUri, "/: " );
|
||||
if( tokens.size() == 0 ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// remove trailing file type, if necessary
|
||||
if( tokens.size() > 1 ) {
|
||||
// for uri's like "www.foo.com" and "foo.com", there is no trailing
|
||||
// file, so there's no need to look at the last '.' and substring
|
||||
// otherwise, we loose the "com" (which would be wrong)
|
||||
String lastToken = tokens.get( tokens.size()-1 );
|
||||
idx = lastToken.lastIndexOf( '.' );
|
||||
if( idx > 0 ) {
|
||||
lastToken = lastToken.substring( 0, idx );
|
||||
tokens.set( tokens.size()-1, lastToken );
|
||||
}
|
||||
}
|
||||
|
||||
// tokenize domain name and reverse. Also remove :port if it exists
|
||||
String domain = tokens.get( 0 );
|
||||
idx = domain.indexOf(':');
|
||||
if( idx >= 0) domain = domain.substring(0, idx);
|
||||
ArrayList<String> r = reverse( tokenize( domain, scheme.equals("urn")?".-":"." ) );
|
||||
if( r.get( r.size()-1 ).equalsIgnoreCase( "www" ) ) {
|
||||
// remove leading www
|
||||
r.remove( r.size()-1 );
|
||||
}
|
||||
|
||||
// replace the domain name with tokenized items
|
||||
tokens.addAll( 1, r );
|
||||
tokens.remove( 0 );
|
||||
|
||||
// iterate through the tokens and apply xml->java name algorithm
|
||||
for( int i = 0; i < tokens.size(); i++ ) {
|
||||
|
||||
// get the token and remove illegal chars
|
||||
String token = tokens.get( i );
|
||||
token = removeIllegalIdentifierChars( token );
|
||||
|
||||
// this will check for reserved keywords
|
||||
if (SourceVersion.isKeyword(token.toLowerCase())) {
|
||||
token = '_' + token;
|
||||
}
|
||||
|
||||
tokens.set( i, token.toLowerCase() );
|
||||
}
|
||||
|
||||
// concat all the pieces and return it
|
||||
return combine( tokens, '.' );
|
||||
}
|
||||
|
||||
|
||||
private static String removeIllegalIdentifierChars(String token) {
|
||||
StringBuilder newToken = new StringBuilder(token.length() + 1); // max expected length
|
||||
for( int i = 0; i < token.length(); i++ ) {
|
||||
char c = token.charAt( i );
|
||||
if (i == 0 && !Character.isJavaIdentifierStart(c)) { // c can't be used as FIRST char
|
||||
newToken.append('_');
|
||||
}
|
||||
if (!Character.isJavaIdentifierPart(c)) { // c can't be used
|
||||
newToken.append('_');
|
||||
} else {
|
||||
newToken.append(c); // c is valid
|
||||
}
|
||||
}
|
||||
return newToken.toString();
|
||||
}
|
||||
|
||||
|
||||
private static ArrayList<String> tokenize( String str, String sep ) {
|
||||
StringTokenizer tokens = new StringTokenizer(str,sep);
|
||||
ArrayList<String> r = new ArrayList<String>();
|
||||
|
||||
while(tokens.hasMoreTokens())
|
||||
r.add( tokens.nextToken() );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static <T> ArrayList<T> reverse( List<T> a ) {
|
||||
ArrayList<T> r = new ArrayList<T>();
|
||||
|
||||
for( int i=a.size()-1; i>=0; i-- )
|
||||
r.add( a.get(i) );
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static String combine( List r, char sep ) {
|
||||
StringBuilder buf = new StringBuilder(r.get(0).toString());
|
||||
|
||||
for( int i=1; i<r.size(); i++ ) {
|
||||
buf.append(sep);
|
||||
buf.append(r.get(i));
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JAX-PRC compatible name converter implementation.
|
||||
*
|
||||
* The only difference is that we treat '_' as a valid character
|
||||
* and not as a word separator.
|
||||
*/
|
||||
public static final NameConverter jaxrpcCompatible = new Standard() {
|
||||
protected boolean isPunct(char c) {
|
||||
return (c == '.' || c == '-' || c == ';' /*|| c == '_'*/ || c == '\u00b7'
|
||||
|| c == '\u0387' || c == '\u06dd' || c == '\u06de');
|
||||
}
|
||||
protected boolean isLetter(char c) {
|
||||
return super.isLetter(c) || c=='_';
|
||||
}
|
||||
|
||||
protected int classify(char c0) {
|
||||
if(c0=='_') return NameUtil.OTHER_LETTER;
|
||||
return super.classify(c0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Smarter converter used for RELAX NG support.
|
||||
*/
|
||||
public static final NameConverter smart = new Standard() {
|
||||
public String toConstantName( String token ) {
|
||||
String name = super.toConstantName(token);
|
||||
if(!SourceVersion.isKeyword(name))
|
||||
return name;
|
||||
else
|
||||
return '_'+name;
|
||||
}
|
||||
};
|
||||
}
|
328
jdkSrc/jdk8/com/sun/xml/internal/bind/api/impl/NameUtil.java
Normal file
328
jdkSrc/jdk8/com/sun/xml/internal/bind/api/impl/NameUtil.java
Normal file
@@ -0,0 +1,328 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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 com.sun.xml.internal.bind.api.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Methods that convert strings into various formats.
|
||||
*
|
||||
* <p>
|
||||
* What JAX-RPC name binding tells us is that even such basic method
|
||||
* like "isLetter" can be different depending on the situation.
|
||||
*
|
||||
* For this reason, a whole lot of methods are made non-static,
|
||||
* even though they look like they should be static.
|
||||
*/
|
||||
class NameUtil {
|
||||
protected boolean isPunct(char c) {
|
||||
return c == '-' || c == '.' || c == ':' || c == '_' || c == '\u00b7' || c == '\u0387' || c == '\u06dd' || c == '\u06de';
|
||||
}
|
||||
|
||||
protected static boolean isDigit(char c) {
|
||||
return c >= '0' && c <= '9' || Character.isDigit(c);
|
||||
}
|
||||
|
||||
protected static boolean isUpper(char c) {
|
||||
return c >= 'A' && c <= 'Z' || Character.isUpperCase(c);
|
||||
}
|
||||
|
||||
protected static boolean isLower(char c) {
|
||||
return c >= 'a' && c <= 'z' || Character.isLowerCase(c);
|
||||
}
|
||||
|
||||
protected boolean isLetter(char c) {
|
||||
return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || Character.isLetter(c);
|
||||
}
|
||||
|
||||
private String toLowerCase(String s)
|
||||
{
|
||||
return s.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
private String toUpperCase(char c)
|
||||
{
|
||||
return String.valueOf(c).toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
private String toUpperCase(String s)
|
||||
{
|
||||
return s.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Capitalizes the first character of the specified string,
|
||||
* and de-capitalize the rest of characters.
|
||||
*/
|
||||
public String capitalize(String s) {
|
||||
if (!isLower(s.charAt(0)))
|
||||
return s;
|
||||
StringBuilder sb = new StringBuilder(s.length());
|
||||
sb.append(toUpperCase(s.charAt(0)));
|
||||
sb.append(toLowerCase(s.substring(1)));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Precondition: s[start] is not punctuation
|
||||
private int nextBreak(String s, int start) {
|
||||
int n = s.length();
|
||||
|
||||
char c1 = s.charAt(start);
|
||||
int t1 = classify(c1);
|
||||
|
||||
for (int i=start+1; i<n; i++) {
|
||||
// shift (c1,t1) into (c0,t0)
|
||||
// char c0 = c1; --- conceptually, but c0 won't be used
|
||||
int t0 = t1;
|
||||
|
||||
c1 = s.charAt(i);
|
||||
t1 = classify(c1);
|
||||
|
||||
switch(actionTable[t0*5+t1]) {
|
||||
case ACTION_CHECK_PUNCT:
|
||||
if(isPunct(c1)) return i;
|
||||
break;
|
||||
case ACTION_CHECK_C2:
|
||||
if (i < n-1) {
|
||||
char c2 = s.charAt(i+1);
|
||||
if (isLower(c2))
|
||||
return i;
|
||||
}
|
||||
break;
|
||||
case ACTION_BREAK:
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// the 5-category classification that we use in this code
|
||||
// to find work breaks
|
||||
static protected final int UPPER_LETTER = 0;
|
||||
static protected final int LOWER_LETTER = 1;
|
||||
static protected final int OTHER_LETTER = 2;
|
||||
static protected final int DIGIT = 3;
|
||||
static protected final int OTHER = 4;
|
||||
|
||||
/**
|
||||
* Look up table for actions.
|
||||
* type0*5+type1 would yield the action to be taken.
|
||||
*/
|
||||
private static final byte[] actionTable = new byte[5*5];
|
||||
|
||||
// action constants. see nextBreak for the meaning
|
||||
static private final byte ACTION_CHECK_PUNCT = 0;
|
||||
static private final byte ACTION_CHECK_C2 = 1;
|
||||
static private final byte ACTION_BREAK = 2;
|
||||
static private final byte ACTION_NOBREAK = 3;
|
||||
|
||||
/**
|
||||
* Decide the action to be taken given
|
||||
* the classification of the preceding character 't0' and
|
||||
* the classification of the next character 't1'.
|
||||
*/
|
||||
private static byte decideAction( int t0, int t1 ) {
|
||||
if(t0==OTHER && t1==OTHER) return ACTION_CHECK_PUNCT;
|
||||
if(!xor(t0==DIGIT,t1==DIGIT)) return ACTION_BREAK;
|
||||
if(t0==LOWER_LETTER && t1!=LOWER_LETTER) return ACTION_BREAK;
|
||||
if(!xor(t0<=OTHER_LETTER,t1<=OTHER_LETTER)) return ACTION_BREAK;
|
||||
if(!xor(t0==OTHER_LETTER,t1==OTHER_LETTER)) return ACTION_BREAK;
|
||||
|
||||
if(t0==UPPER_LETTER && t1==UPPER_LETTER) return ACTION_CHECK_C2;
|
||||
|
||||
return ACTION_NOBREAK;
|
||||
}
|
||||
|
||||
private static boolean xor(boolean x,boolean y) {
|
||||
return (x&&y) || (!x&&!y);
|
||||
}
|
||||
|
||||
static {
|
||||
// initialize the action table
|
||||
for( int t0=0; t0<5; t0++ )
|
||||
for( int t1=0; t1<5; t1++ )
|
||||
actionTable[t0*5+t1] = decideAction(t0,t1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify a character into 5 categories that determine the word break.
|
||||
*/
|
||||
protected int classify(char c0) {
|
||||
switch(Character.getType(c0)) {
|
||||
case Character.UPPERCASE_LETTER: return UPPER_LETTER;
|
||||
case Character.LOWERCASE_LETTER: return LOWER_LETTER;
|
||||
case Character.TITLECASE_LETTER:
|
||||
case Character.MODIFIER_LETTER:
|
||||
case Character.OTHER_LETTER: return OTHER_LETTER;
|
||||
case Character.DECIMAL_DIGIT_NUMBER: return DIGIT;
|
||||
default: return OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tokenizes a string into words and capitalizes the first
|
||||
* character of each word.
|
||||
*
|
||||
* <p>
|
||||
* This method uses a change in character type as a splitter
|
||||
* of two words. For example, "abc100ghi" will be splitted into
|
||||
* {"Abc", "100","Ghi"}.
|
||||
*/
|
||||
public List<String> toWordList(String s) {
|
||||
ArrayList<String> ss = new ArrayList<String>();
|
||||
int n = s.length();
|
||||
for (int i = 0; i < n;) {
|
||||
|
||||
// Skip punctuation
|
||||
while (i < n) {
|
||||
if (!isPunct(s.charAt(i)))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
if (i >= n) break;
|
||||
|
||||
// Find next break and collect word
|
||||
int b = nextBreak(s, i);
|
||||
String w = (b == -1) ? s.substring(i) : s.substring(i, b);
|
||||
ss.add(escape(capitalize(w)));
|
||||
if (b == -1) break;
|
||||
i = b;
|
||||
}
|
||||
|
||||
// we can't guarantee a valid Java identifier anyway,
|
||||
// so there's not much point in rejecting things in this way.
|
||||
// if (ss.size() == 0)
|
||||
// throw new IllegalArgumentException("Zero-length identifier");
|
||||
return ss;
|
||||
}
|
||||
|
||||
protected String toMixedCaseName(List<String> ss, boolean startUpper) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(!ss.isEmpty()) {
|
||||
sb.append(startUpper ? ss.get(0) : toLowerCase(ss.get(0)));
|
||||
for (int i = 1; i < ss.size(); i++)
|
||||
sb.append(ss.get(i));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String toMixedCaseVariableName(String[] ss,
|
||||
boolean startUpper,
|
||||
boolean cdrUpper) {
|
||||
if (cdrUpper)
|
||||
for (int i = 1; i < ss.length; i++)
|
||||
ss[i] = capitalize(ss[i]);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if( ss.length>0 ) {
|
||||
sb.append(startUpper ? ss[0] : toLowerCase(ss[0]));
|
||||
for (int i = 1; i < ss.length; i++)
|
||||
sb.append(ss[i]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
|
||||
*
|
||||
* @return
|
||||
* Always return a string but there's no guarantee that
|
||||
* the generated code is a valid Java identifier.
|
||||
*/
|
||||
public String toConstantName(String s) {
|
||||
return toConstantName(toWordList(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
|
||||
*
|
||||
* @return
|
||||
* Always return a string but there's no guarantee that
|
||||
* the generated code is a valid Java identifier.
|
||||
*/
|
||||
public String toConstantName(List<String> ss) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if( !ss.isEmpty() ) {
|
||||
sb.append(toUpperCase(ss.get(0)));
|
||||
for (int i = 1; i < ss.size(); i++) {
|
||||
sb.append('_');
|
||||
sb.append(toUpperCase(ss.get(i)));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Escapes characters is the given string so that they can be
|
||||
* printed by only using US-ASCII characters.
|
||||
*
|
||||
* The escaped characters will be appended to the given
|
||||
* StringBuffer.
|
||||
*
|
||||
* @param sb
|
||||
* StringBuffer that receives escaped string.
|
||||
* @param s
|
||||
* String to be escaped. <code>s.substring(start)</code>
|
||||
* will be escaped and copied to the string buffer.
|
||||
*/
|
||||
public static void escape(StringBuilder sb, String s, int start) {
|
||||
int n = s.length();
|
||||
for (int i = start; i < n; i++) {
|
||||
char c = s.charAt(i);
|
||||
if (Character.isJavaIdentifierPart(c))
|
||||
sb.append(c);
|
||||
else {
|
||||
sb.append('_');
|
||||
if (c <= '\u000f') sb.append("000");
|
||||
else if (c <= '\u00ff') sb.append("00");
|
||||
else if (c <= '\u0fff') sb.append('0');
|
||||
sb.append(Integer.toString(c, 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes characters that are unusable as Java identifiers
|
||||
* by replacing unsafe characters with safe characters.
|
||||
*/
|
||||
private static String escape(String s) {
|
||||
int n = s.length();
|
||||
for (int i = 0; i < n; i++)
|
||||
if (!Character.isJavaIdentifierPart(s.charAt(i))) {
|
||||
StringBuilder sb = new StringBuilder(s.substring(0, i));
|
||||
escape(sb, s, i);
|
||||
return sb.toString();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
40
jdkSrc/jdk8/com/sun/xml/internal/bind/api/package-info.java
Normal file
40
jdkSrc/jdk8/com/sun/xml/internal/bind/api/package-info.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* <h1>Runtime API for the JAX-WS RI</h1>.
|
||||
*
|
||||
* This API is designed for the use by the JAX-WS RI runtime. The API is is subject to
|
||||
* change without notice.
|
||||
*
|
||||
* <p>
|
||||
* In an container environment, such as in J2SE/J2EE, if a new version with
|
||||
* a modified runtime API is loaded into a child class loader, it will still be bound
|
||||
* against the old runtime API in the base class loader.
|
||||
*
|
||||
* <p>
|
||||
* So the compatibility of this API has to be managed carefully.
|
||||
*/
|
||||
package com.sun.xml.internal.bind.api;
|
Reference in New Issue
Block a user