Top Description Fields Constructors Methods
com.sun.tools.xjc.reader.internalizer

pack-priv Class Internalizer

extends Object
Class Inheritance
Imports
java.net.MalformedURLException, .URL, java.util.ArrayList, .HashMap, .HashSet, .List, .Map, .Set, java.text.ParseException, javax.xml.xpath.XPath, .XPathConstants, .XPathExpressionException, com.sun.istack.SAXParseException2, .NotNull, .Nullable, com.sun.tools.xjc.ErrorReceiver, com.sun.tools.xjc.reader.Const, com.sun.tools.xjc.util.DOMUtils, org.glassfish.jaxb.core.v2.util.EditDistance, .XmlFactory, com.sun.xml.xsom.SCD, java.io.File, .IOException, java.util.logging.Level, .Logger, javax.xml.XMLConstants, org.w3c.dom.Attr, .Document, .Element, .NamedNodeMap, .Node, .NodeList, org.xml.sax.SAXParseException

Internalizes external binding declarations.

The transform(DOMForest, boolean, boolean) method is the entry point.

Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
private boolean
enableSCD

If true, the SCD-based target selection is supported.

private ErrorReceiver
errorHandler

All errors found during the transformation is sent to this object.

private static final String
EXTENSION_PREFIXES

Attribute name.

private final DOMForest
forest

DOMForest object currently being processed.

private static final String
private final XPath

Constructor Summary

AccessConstructor and Description
private
Internalizer(DOMForest forest, boolean enableSCD, boolean disableSecureProcessing)

Method Summary

Modifier and TypeMethod and Description
private String
allocatePrefix(Element e, String nsUri)

Declares a new prefix on the given element and associates it with the specified namespace URI.

private void
buildTargetNodeMap(Element bindings, Node
The current target node. This always exists, even if the user starts specifying targets via SCD (in that case this inherited target is just not going to be used.)
inheritedTarget
,
SCDBasedBindingSet.Target
If the ancestor <bindings> node specifies @scd to specify the target via SCD, then this parameter represents that context.
inheritedSCD
,
Map<Element, List<Node>> result, SCDBasedBindingSet scdResult)

Determines the target node of the "bindings" element by using the inherited target node, then put the result into the "result" map and the "scd" map.

private void
copyLocators(Element src, Element dst)

Copies location information attached to the "src" node to the "dst" node.

private void
declareExtensionNamespace(Element target, String nsUri)

Adds the specified namespace URI to the jaxb:extensionBindingPrefixes attribute of the target document.

private void
declExtensionNamespace(Element decl, Element target)

Recursively visits sub-elements and declare all used namespaces.

private void
move(Element bindings, Map<Element, List<Node>> targetNodes)

Moves JAXB customizations under their respective target nodes.

private void
moveUnder(Element
A JAXB customization element (e.g., <jaxb:class>)
decl
,
Element
XML Schema element under which the declaration should move. For example, <xs:element>
target
)

Moves the "decl" node under the "target" node.

private void
reportError(Element errorSource, String formattedMsg)

private void
reportError(Element errorSource, String formattedMsg, Exception nestedException)

pack-priv static SCDBasedBindingSet

Returns:

if the SCD support is enabled, the return bindings need to be applied after schema components are parsed. If disabled, the returned binding set will be empty. SCDs are only for XML Schema, and doesn't make any sense for other schema languages.
transform
(DOMForest forest, boolean enableSCD, boolean disableSecureProcessing)

Internalize all <jaxb:bindings> customizations in the given forest.

private SCDBasedBindingSet
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enableSCDback to summary
private boolean enableSCD

If true, the SCD-based target selection is supported.

errorHandlerback to summary
private ErrorReceiver errorHandler

All errors found during the transformation is sent to this object.

EXTENSION_PREFIXESback to summary
private static final String EXTENSION_PREFIXES

Attribute name.

forestback to summary
private final DOMForest forest

DOMForest object currently being processed.

WSDL_NSback to summary
private static final String WSDL_NS
xpathback to summary
private final XPath xpath

Constructor Detail

Internalizerback to summary
private Internalizer(DOMForest forest, boolean enableSCD, boolean disableSecureProcessing)

Method Detail

allocatePrefixback to summary
private String allocatePrefix(Element e, String nsUri)

Declares a new prefix on the given element and associates it with the specified namespace URI.

Note that this method doesn't use the default namespace even if it can.

buildTargetNodeMapback to summary
private void buildTargetNodeMap(Element bindings, Node inheritedTarget, SCDBasedBindingSet.Target inheritedSCD, Map<Element, List<Node>> result, SCDBasedBindingSet scdResult)

Determines the target node of the "bindings" element by using the inherited target node, then put the result into the "result" map and the "scd" map.

Parameters
inheritedTarget:Node

The current target node. This always exists, even if the user starts specifying targets via SCD (in that case this inherited target is just not going to be used.)

inheritedSCD:SCDBasedBindingSet.Target

If the ancestor <bindings> node specifies @scd to specify the target via SCD, then this parameter represents that context.

copyLocatorsback to summary
private void copyLocators(Element src, Element dst)

Copies location information attached to the "src" node to the "dst" node.

declareExtensionNamespaceback to summary
private void declareExtensionNamespace(Element target, String nsUri)

Adds the specified namespace URI to the jaxb:extensionBindingPrefixes attribute of the target document.

declExtensionNamespaceback to summary
private void declExtensionNamespace(Element decl, Element target)

Recursively visits sub-elements and declare all used namespaces.

Todo

the fact that we recognize all namespaces in the extension is a bad design.

moveback to summary
private void move(Element bindings, Map<Element, List<Node>> targetNodes)

Moves JAXB customizations under their respective target nodes.

moveUnderback to summary
private void moveUnder(Element decl, Element target)

Moves the "decl" node under the "target" node.

Parameters
decl:Element

A JAXB customization element (e.g., <jaxb:class>)

target:Element

XML Schema element under which the declaration should move. For example, <xs:element>

reportErrorback to summary
private void reportError(Element errorSource, String formattedMsg)
reportErrorback to summary
private void reportError(Element errorSource, String formattedMsg, Exception nestedException)
transformback to summary
pack-priv static SCDBasedBindingSet transform(DOMForest forest, boolean enableSCD, boolean disableSecureProcessing)

Internalize all <jaxb:bindings> customizations in the given forest.

Returns:SCDBasedBindingSet

if the SCD support is enabled, the return bindings need to be applied after schema components are parsed. If disabled, the returned binding set will be empty. SCDs are only for XML Schema, and doesn't make any sense for other schema languages.

transformback to summary
private SCDBasedBindingSet transform()