Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Validate.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Validate.java?rev=1877931&r1=1877930&r2=1877931&view=diff ============================================================================== --- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Validate.java (original) +++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Validate.java Tue May 19 20:10:55 2020 @@ -42,9 +42,9 @@ final class Validate implements Validato { _cur.pop(); _cur = null; - + _sink = null; - + _textCur.release(); } } @@ -57,7 +57,7 @@ final class Validate implements Validato { // If validating an attr, I'm really validating the contents of that attr. So, go to // any text value and shove it thru the validator. - + _cur.next(); if (_cur.isText()) @@ -68,7 +68,7 @@ final class Validate implements Validato assert _cur.isContainer(); // Do the attrs of the top container - + doAttrs(); for ( _cur.next() ; ! _cur.isAtEndOfLastPush() ; _cur.next() ) @@ -79,15 +79,15 @@ final class Validate implements Validato emitEvent( ValidatorListener.BEGIN ); doAttrs(); break; - + case - Cur.ELEM : emitEvent( ValidatorListener.END ); break; - + case Cur.TEXT : emitText(); break; - + case Cur.COMMENT : case Cur.PROCINST : _cur.toEnd(); @@ -98,7 +98,7 @@ final class Validate implements Validato } } } - + emitEvent( ValidatorListener.END ); } @@ -106,9 +106,9 @@ final class Validate implements Validato { // When processing attrs, there can be no accumulated text because there would have been // a preceeding event which would have flushged the text. - + assert !_hasText; - + if (_cur.toFirstAttr()) { do @@ -120,7 +120,7 @@ final class Validate implements Validato _cur.toParent(); } - + _sink.nextEvent( ValidatorListener.ENDATTRS, this ); } @@ -144,9 +144,9 @@ final class Validate implements Validato _oneChunk = false; } - + assert _textSb != null && _textSb.length() > 0; - + CharUtil.getString( _textSb, _cur.getChars( -1 ), _cur._offSrc, _cur._cchSrc ); } else @@ -181,7 +181,7 @@ final class Validate implements Validato assert _oneChunk || (_textSb != null && _textSb.length() > 0); assert !_oneChunk || _textCur.isText(); - return _oneChunk ? _textCur.getCharsAsString( -1 ) : _textSb.toString(); + return _oneChunk ? _textCur.getCharsAsString() : _textSb.toString(); } public String getText ( int wsr ) @@ -194,7 +194,7 @@ final class Validate implements Validato assert !_oneChunk || _textCur.isText(); if (_oneChunk) - return _textCur.getCharsAsString( -1, wsr ); + return _textCur.getCharsAsString( wsr ); return Locale.applyWhiteSpaceRule( _textSb.toString(), wsr ); } @@ -207,7 +207,7 @@ final class Validate implements Validato _cur._locale.getCharUtil().isWhiteSpace( _cur.getFirstChars(), _cur._offSrc, _cur._cchSrc ); } - + assert _hasText; if (_oneChunk) @@ -218,7 +218,7 @@ final class Validate implements Validato } String s = _textSb.toString(); - + return _cur._locale.getCharUtil().isWhiteSpace( s, 0, s.length() ); } @@ -275,7 +275,7 @@ final class Validate implements Validato // This way, when I turn the text into a String, I can cache the string. If multiple chunks // of text exists for one event, then I accumulate all the text into a string buffer and I, // then, don't care about caching Strings. - + private boolean _hasText; private boolean _oneChunk;
Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java?rev=1877931&r1=1877930&r2=1877931&view=diff ============================================================================== --- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java (original) +++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Xobj.java Tue May 19 20:10:55 2020 @@ -15,86 +15,23 @@ package org.apache.xmlbeans.impl.store; -import org.apache.xmlbeans.CDataBookmark; -import org.w3c.dom.Attr; -import org.w3c.dom.CDATASection; -import org.w3c.dom.CharacterData; -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.DocumentFragment; -import org.w3c.dom.DocumentType; -import org.w3c.dom.DOMException; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Element; -import org.w3c.dom.EntityReference; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.ProcessingInstruction; -import org.w3c.dom.Text; -import org.w3c.dom.DOMImplementation; - -// DOM Level 3 -import org.w3c.dom.UserDataHandler; -import org.w3c.dom.DOMConfiguration; -import org.w3c.dom.TypeInfo; - - -import javax.xml.transform.Source; - -import java.io.PrintStream; - -import java.util.Iterator; -import java.util.Map; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import org.apache.xmlbeans.impl.soap.Detail; -import org.apache.xmlbeans.impl.soap.DetailEntry; -import org.apache.xmlbeans.impl.soap.MimeHeaders; -import org.apache.xmlbeans.impl.soap.Name; -import org.apache.xmlbeans.impl.soap.SOAPBody; -import org.apache.xmlbeans.impl.soap.SOAPBodyElement; -import org.apache.xmlbeans.impl.soap.SOAPElement; -import org.apache.xmlbeans.impl.soap.SOAPEnvelope; -import org.apache.xmlbeans.impl.soap.SOAPException; -import org.apache.xmlbeans.impl.soap.SOAPFactory; -import org.apache.xmlbeans.impl.soap.SOAPFault; -import org.apache.xmlbeans.impl.soap.SOAPFaultElement; -import org.apache.xmlbeans.impl.soap.SOAPHeader; -import org.apache.xmlbeans.impl.soap.SOAPHeaderElement; -import org.apache.xmlbeans.impl.soap.SOAPPart; -import org.apache.xmlbeans.impl.store.Locale.LoadContext; - +import org.apache.xmlbeans.*; +import org.apache.xmlbeans.impl.common.QNameHelper; +import org.apache.xmlbeans.impl.common.ValidatorListener; +import org.apache.xmlbeans.impl.common.XmlLocale; import org.apache.xmlbeans.impl.store.DomImpl.Dom; -import org.apache.xmlbeans.impl.store.DomImpl.CharNode; -import org.apache.xmlbeans.impl.store.DomImpl.TextNode; -import org.apache.xmlbeans.impl.store.DomImpl.CdataNode; -import org.apache.xmlbeans.impl.store.DomImpl.SaajTextNode; -import org.apache.xmlbeans.impl.store.DomImpl.SaajCdataNode; - -import org.apache.xmlbeans.XmlBeans; -import org.apache.xmlbeans.SchemaField; -import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.SchemaTypeLoader; -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlCursor.XmlMark; -import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.QNameSet; - import org.apache.xmlbeans.impl.values.TypeStore; import org.apache.xmlbeans.impl.values.TypeStoreUser; -import org.apache.xmlbeans.impl.values.TypeStoreVisitor; import org.apache.xmlbeans.impl.values.TypeStoreUserFactory; +import org.apache.xmlbeans.impl.values.TypeStoreVisitor; import javax.xml.namespace.QName; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; -import org.apache.xmlbeans.impl.common.ValidatorListener; -import org.apache.xmlbeans.impl.common.XmlLocale; -import org.apache.xmlbeans.impl.common.QNameHelper; +// DOM Level 3 abstract class Xobj implements TypeStore { @@ -232,7 +169,7 @@ abstract class Xobj implements TypeStore _srcValue == null && _charNodesValue == null) { - assert (_firstChild instanceof Xobj.NodeXobj): + assert (_firstChild instanceof NodeXobj): "wrong node type"; return true; } @@ -250,7 +187,7 @@ abstract class Xobj implements TypeStore _srcAfter == null) { assert (_nextSibling == null || - _nextSibling instanceof Xobj.NodeXobj): + _nextSibling instanceof NodeXobj): "wrong node type"; return true; } @@ -581,7 +518,7 @@ abstract class Xobj implements TypeStore QName oldName = _name; _name = newName; - if (this instanceof Xobj.NamedNodeXobj) + if (this instanceof NamedNodeXobj) { NamedNodeXobj me = (NamedNodeXobj)this; me._canHavePrefixUri = true; @@ -1909,7 +1846,7 @@ abstract class Xobj implements TypeStore try { Cur c = tempCur(); - c.setSubstitution( name, type, false ); + c.setSubstitution( name, type ); c.release(); } finally @@ -2390,7 +2327,7 @@ abstract class Xobj implements TypeStore if ( Boolean.TRUE.equals(options.get(XmlOptions.COPY_USE_NEW_SYNC_DOMAIN)) ) locale = Locale.getLocale(stl, options); - if (sType.isDocumentType() || (sType.isNoType() && (this instanceof Xobj.DocumentXobj))) + if (sType.isDocumentType() || (sType.isNoType() && (this instanceof DocumentXobj))) destination = Cur.createDomDocumentRootXobj(locale, false); else destination = Cur.createDomDocumentRootXobj(locale, true); @@ -2553,676 +2490,6 @@ abstract class Xobj implements TypeStore return namespaceForPrefix( prefix, true ); } - // - // - // - - abstract static class NodeXobj extends Xobj implements Dom, Node, NodeList - { - NodeXobj ( Locale l, int kind, int domType ) - { - super( l, kind, domType ); - } - - Dom getDom ( ) { return this; } - - // - // - // - - public int getLength ( ) { return DomImpl._childNodes_getLength( this ); } - public Node item ( int i ) { return DomImpl._childNodes_item( this, i ); } - - public Node appendChild ( Node newChild ) { return DomImpl._node_appendChild( this, newChild ); } - public Node cloneNode ( boolean deep ) { return DomImpl._node_cloneNode( this, deep ); } - public NamedNodeMap getAttributes ( ) { return null; } - public NodeList getChildNodes ( ) { return this; } - public Node getParentNode ( ) { return DomImpl._node_getParentNode( this ); } - public Node removeChild ( Node oldChild ) { return DomImpl._node_removeChild( this, oldChild ); } - public Node getFirstChild ( ) { return DomImpl._node_getFirstChild( this ); } - public Node getLastChild ( ) { return DomImpl._node_getLastChild( this ); } - public String getLocalName ( ) { return DomImpl._node_getLocalName( this ); } - public String getNamespaceURI ( ) { return DomImpl._node_getNamespaceURI( this ); } - public Node getNextSibling ( ) { return DomImpl._node_getNextSibling( this ); } - public String getNodeName ( ) { return DomImpl._node_getNodeName( this ); } - public short getNodeType ( ) { return DomImpl._node_getNodeType( this ); } - public String getNodeValue ( ) { return DomImpl._node_getNodeValue( this ); } - public Document getOwnerDocument ( ) { return DomImpl._node_getOwnerDocument( this ); } - public String getPrefix ( ) { return DomImpl._node_getPrefix( this ); } - public Node getPreviousSibling ( ) { return DomImpl._node_getPreviousSibling( this ); } - public boolean hasAttributes ( ) { return DomImpl._node_hasAttributes( this ); } - public boolean hasChildNodes ( ) { return DomImpl._node_hasChildNodes( this ); } - public Node insertBefore ( Node newChild, Node refChild ) { return DomImpl._node_insertBefore( this, newChild, refChild ); } - public boolean isSupported ( String feature, String version ) { return DomImpl._node_isSupported( this, feature, version ); } - public void normalize ( ) { DomImpl._node_normalize( this ); } - public Node replaceChild ( Node newChild, Node oldChild ) { return DomImpl._node_replaceChild( this, newChild, oldChild ); } - public void setNodeValue ( String nodeValue ) { DomImpl._node_setNodeValue( this, nodeValue ); } - public void setPrefix ( String prefix ) { DomImpl._node_setPrefix( this, prefix ); } - public boolean nodeCanHavePrefixUri( ){ return false; } - - // DOM Level 3 - public Object getUserData ( String key ) { return DomImpl._node_getUserData( this, key ); } - public Object setUserData ( String key, Object data, UserDataHandler handler ) { return DomImpl._node_setUserData( this, key, data, handler ); } - public Object getFeature ( String feature, String version ) { return DomImpl._node_getFeature( this, feature, version ); } - public boolean isEqualNode ( Node arg ) { return DomImpl._node_isEqualNode( this, arg ); } - public boolean isSameNode ( Node arg ) { return DomImpl._node_isSameNode( this, arg ); } - public String lookupNamespaceURI ( String prefix ) { return DomImpl._node_lookupNamespaceURI( this, prefix ); } - public String lookupPrefix ( String namespaceURI ) { return DomImpl._node_lookupPrefix( this, namespaceURI ); } - public boolean isDefaultNamespace ( String namespaceURI ) { return DomImpl._node_isDefaultNamespace( this, namespaceURI ); } - public void setTextContent ( String textContent ) { DomImpl._node_setTextContent( this, textContent ); } - public String getTextContent ( ) { return DomImpl._node_getTextContent( this ); } - public short compareDocumentPosition ( Node other ) { return DomImpl._node_compareDocumentPosition( this, other ); } - public String getBaseURI ( ) { return DomImpl._node_getBaseURI( this ); } - } - - static class DocumentXobj extends NodeXobj implements Document - { - DocumentXobj ( Locale l ) - { - super( l, ROOT, DomImpl.DOCUMENT ); - } - - Xobj newNode ( Locale l ) { return new DocumentXobj( l ); } - - // - // - // - - public Attr createAttribute ( String name ) { return DomImpl._document_createAttribute( this, name ); } - public Attr createAttributeNS ( String namespaceURI, String qualifiedName ) { return DomImpl._document_createAttributeNS( this, namespaceURI, qualifiedName ); } - public CDATASection createCDATASection ( String data ) { return DomImpl._document_createCDATASection( this, data ); } - public Comment createComment ( String data ) { return DomImpl._document_createComment( this, data ); } - public DocumentFragment createDocumentFragment ( ) { return DomImpl._document_createDocumentFragment( this ); } - public Element createElement ( String tagName ) { return DomImpl._document_createElement( this, tagName ); } - public Element createElementNS ( String namespaceURI, String qualifiedName ) { return DomImpl._document_createElementNS( this, namespaceURI, qualifiedName ); } - public EntityReference createEntityReference ( String name ) { return DomImpl._document_createEntityReference( this, name ); } - public ProcessingInstruction createProcessingInstruction ( String target, String data ) { return DomImpl._document_createProcessingInstruction( this, target, data ); } - public Text createTextNode ( String data ) { return DomImpl._document_createTextNode( this, data ); } - public DocumentType getDoctype ( ) { return DomImpl._document_getDoctype( this ); } - public Element getDocumentElement ( ) { return DomImpl._document_getDocumentElement( this ); } - public Element getElementById ( String elementId ) { - if ( _idToElement == null )return null; - Xobj o = (Xobj) _idToElement.get(elementId); - if (o == null) return null; - if (!isInSameTree(o)) - { - _idToElement.remove(elementId); - } - return (Element)o; - } - public NodeList getElementsByTagName ( String tagname ) { return DomImpl._document_getElementsByTagName( this, tagname ); } - public NodeList getElementsByTagNameNS ( String namespaceURI, String localName ) { return DomImpl._document_getElementsByTagNameNS( this, namespaceURI, localName ); } - public DOMImplementation getImplementation ( ) { return DomImpl._document_getImplementation( this ); } - public Node importNode ( Node importedNode, boolean deep ) { return DomImpl._document_importNode( this, importedNode, deep ); } - - // DOM Level 3 - public Node adoptNode ( Node source ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getDocumentURI ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public DOMConfiguration getDomConfig ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getInputEncoding ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public boolean getStrictErrorChecking ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getXmlEncoding ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public boolean getXmlStandalone ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getXmlVersion ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void normalizeDocument ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public Node renameNode ( Node n, String namespaceURI, String qualifiedName ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setDocumentURI ( String documentURI ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setStrictErrorChecking ( boolean strictErrorChecking ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setXmlStandalone ( boolean xmlStandalone ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setXmlVersion ( String xmlVersion ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - - protected void addIdElement( String idVal, Dom e){ - if ( _idToElement == null) - _idToElement = new java.util.Hashtable(); - _idToElement.put(idVal,e); - } - void removeIdElement( String idVal ){ - if (_idToElement != null) - _idToElement.remove(idVal); - } - private java.util.Hashtable _idToElement; - } - static class DocumentFragXobj extends NodeXobj implements DocumentFragment - { - DocumentFragXobj ( Locale l ) { super( l, ROOT, DomImpl.DOCFRAG ); } - - Xobj newNode ( Locale l ) { return new DocumentFragXobj( l ); } - } - - final static class ElementAttributes implements NamedNodeMap - { - ElementAttributes ( ElementXobj elementXobj ) - { - _elementXobj = elementXobj; - } - - public int getLength ( ) { return DomImpl._attributes_getLength( _elementXobj ); } - public Node getNamedItem ( String name ) { return DomImpl._attributes_getNamedItem ( _elementXobj, name ); } - public Node getNamedItemNS ( String namespaceURI, String localName ) { return DomImpl._attributes_getNamedItemNS ( _elementXobj, namespaceURI, localName ); } - public Node item ( int index ) { return DomImpl._attributes_item ( _elementXobj, index ); } - public Node removeNamedItem ( String name ) { return DomImpl._attributes_removeNamedItem ( _elementXobj, name ); } - public Node removeNamedItemNS ( String namespaceURI, String localName ) { return DomImpl._attributes_removeNamedItemNS ( _elementXobj, namespaceURI, localName ); } - public Node setNamedItem ( Node arg ) { return DomImpl._attributes_setNamedItem ( _elementXobj, arg ); } - public Node setNamedItemNS ( Node arg ) { return DomImpl._attributes_setNamedItemNS ( _elementXobj, arg ); } - - private ElementXobj _elementXobj; - } - - static abstract class NamedNodeXobj extends NodeXobj - { - NamedNodeXobj ( Locale l, int kind, int domType ) - { - super( l, kind, domType ); - _canHavePrefixUri = true; - } - - public boolean nodeCanHavePrefixUri( ){ return _canHavePrefixUri; } - - boolean _canHavePrefixUri; - } - - static class ElementXobj extends NamedNodeXobj implements Element - { - ElementXobj ( Locale l, QName name ) - { - super( l, ELEM, DomImpl.ELEMENT ); - _name = name; - } - - Xobj newNode ( Locale l ) { return new ElementXobj( l, _name ); } - - // - // - // - - public NamedNodeMap getAttributes ( ) - { - if (_attributes == null) - _attributes = new ElementAttributes( this ); - - return _attributes; - } - - public String getAttribute ( String name ) { return DomImpl._element_getAttribute( this, name ); } - public Attr getAttributeNode ( String name ) { return DomImpl._element_getAttributeNode( this, name ); } - public Attr getAttributeNodeNS ( String namespaceURI, String localName ) { return DomImpl._element_getAttributeNodeNS( this, namespaceURI, localName ); } - public String getAttributeNS ( String namespaceURI, String localName ) { return DomImpl._element_getAttributeNS( this, namespaceURI, localName ); } - public NodeList getElementsByTagName ( String name ) { return DomImpl._element_getElementsByTagName( this, name ); } - public NodeList getElementsByTagNameNS ( String namespaceURI, String localName ) { return DomImpl._element_getElementsByTagNameNS( this, namespaceURI, localName ); } - public String getTagName ( ) { return DomImpl._element_getTagName( this ); } - public boolean hasAttribute ( String name ) { return DomImpl._element_hasAttribute( this, name ); } - public boolean hasAttributeNS ( String namespaceURI, String localName ) { return DomImpl._element_hasAttributeNS( this, namespaceURI, localName ); } - public void removeAttribute ( String name ) { DomImpl._element_removeAttribute( this, name ); } - public Attr removeAttributeNode ( Attr oldAttr ) { return DomImpl._element_removeAttributeNode( this, oldAttr ); } - public void removeAttributeNS ( String namespaceURI, String localName ) { DomImpl._element_removeAttributeNS( this, namespaceURI, localName ); } - public void setAttribute ( String name, String value ) { DomImpl._element_setAttribute( this, name, value ); } - public Attr setAttributeNode ( Attr newAttr ) { return DomImpl._element_setAttributeNode( this, newAttr ); } - public Attr setAttributeNodeNS ( Attr newAttr ) { return DomImpl._element_setAttributeNodeNS( this, newAttr ); } - public void setAttributeNS ( String namespaceURI, String qualifiedName, String value ) { DomImpl._element_setAttributeNS( this, namespaceURI, qualifiedName, value ); } - - // DOM Level 3 - public TypeInfo getSchemaTypeInfo ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setIdAttribute ( String name, boolean isId ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setIdAttributeNS ( String namespaceURI, String localName, boolean isId ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setIdAttributeNode ( Attr idAttr, boolean isId ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - - private ElementAttributes _attributes; - } - - static class AttrXobj extends NamedNodeXobj implements Attr - { - AttrXobj ( Locale l, QName name ) - { - super( l, ATTR, DomImpl.ATTR ); - _name = name; - } - - Xobj newNode ( Locale l ) { return new AttrXobj( l, _name ); } - - // - public Node getNextSibling ( ) { return null; } - // - - public String getName ( ) { return DomImpl._node_getNodeName( this ); } - public Element getOwnerElement ( ) { return DomImpl._attr_getOwnerElement( this ); } - public boolean getSpecified ( ) { return DomImpl._attr_getSpecified( this ); } - public String getValue ( ) { return DomImpl._node_getNodeValue( this ); } - public void setValue ( String value ) { DomImpl._node_setNodeValue( this, value ); } - - // DOM Level 3 - public TypeInfo getSchemaTypeInfo ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public boolean isId ( ) { return false; } - } - - static class AttrIdXobj - extends AttrXobj - { - AttrIdXobj ( Locale l, QName name ) - { - super( l, name ); - } - public boolean isId() - { - return true; - } - } - static class CommentXobj extends NodeXobj implements Comment - { - CommentXobj ( Locale l ) { super( l, COMMENT, DomImpl.COMMENT ); } - - Xobj newNode ( Locale l ) { return new CommentXobj( l ); } - - public NodeList getChildNodes ( ) { return DomImpl._emptyNodeList; } - - public void appendData ( String arg ) { DomImpl._characterData_appendData( this, arg ); } - public void deleteData ( int offset, int count ) { DomImpl._characterData_deleteData( this, offset, count ); } - public String getData ( ) { return DomImpl._characterData_getData( this ); } - public int getLength ( ) { return DomImpl._characterData_getLength( this ); } - public Node getFirstChild ( ) { return null; } - public void insertData ( int offset, String arg ) { DomImpl._characterData_insertData( this, offset, arg ); } - public void replaceData ( int offset, int count, String arg ) { DomImpl._characterData_replaceData( this, offset, count, arg ); } - public void setData ( String data ) { DomImpl._characterData_setData( this, data ); } - public String substringData ( int offset, int count ) { return DomImpl._characterData_substringData( this, offset, count ); } - } - - static class ProcInstXobj extends NodeXobj implements ProcessingInstruction - { - ProcInstXobj ( Locale l, String target ) - { - super( l, PROCINST, DomImpl.PROCINST ); - _name = _locale.makeQName( null, target ); - } - - Xobj newNode ( Locale l ) { return new ProcInstXobj( l, _name.getLocalPart() ); } - - public int getLength ( ) { return 0; } - public Node getFirstChild ( ) { return null; } - - public String getData ( ) { return DomImpl._processingInstruction_getData( this ); } - public String getTarget ( ) { return DomImpl._processingInstruction_getTarget( this ); } - public void setData ( String data ) { DomImpl._processingInstruction_setData( this, data ); } - } - - // - // SAAJ objects - // - - static class SoapPartDocXobj extends DocumentXobj - { - SoapPartDocXobj ( Locale l ) - { - super(l); - //super( l, ROOT, DomImpl.DOCUMENT ); - _soapPartDom = new SoapPartDom( this ); - } - - Dom getDom ( ) { return _soapPartDom; } - - Xobj newNode ( Locale l ) { return new SoapPartDocXobj( l ); } - - SoapPartDom _soapPartDom; - } - - static class SoapPartDom extends SOAPPart implements Dom, Document, NodeList - { - SoapPartDom ( SoapPartDocXobj docXobj ) - { - _docXobj = docXobj; - } - - public int nodeType ( ) { return DomImpl.DOCUMENT; } - public Locale locale ( ) { return _docXobj._locale; } - public Cur tempCur ( ) { return _docXobj.tempCur(); } - public QName getQName ( ) { return _docXobj._name; } - - public void dump ( ) { dump( System.out ); } - public void dump ( PrintStream o ) { _docXobj.dump( o ); } - public void dump ( PrintStream o, Object ref ) { _docXobj.dump( o, ref ); } - - public String name ( ) { return "#document"; } - - public Node appendChild ( Node newChild ) { return DomImpl._node_appendChild( this, newChild ); } - public Node cloneNode ( boolean deep ) { return DomImpl._node_cloneNode( this, deep ); } - public NamedNodeMap getAttributes ( ) { return null; } - public NodeList getChildNodes ( ) { return this; } - public Node getParentNode ( ) { return DomImpl._node_getParentNode( this ); } - public Node removeChild ( Node oldChild ) { return DomImpl._node_removeChild( this, oldChild ); } - public Node getFirstChild ( ) { return DomImpl._node_getFirstChild( this ); } - public Node getLastChild ( ) { return DomImpl._node_getLastChild( this ); } - public String getLocalName ( ) { return DomImpl._node_getLocalName( this ); } - public String getNamespaceURI ( ) { return DomImpl._node_getNamespaceURI( this ); } - public Node getNextSibling ( ) { return DomImpl._node_getNextSibling( this ); } - public String getNodeName ( ) { return DomImpl._node_getNodeName( this ); } - public short getNodeType ( ) { return DomImpl._node_getNodeType( this ); } - public String getNodeValue ( ) { return DomImpl._node_getNodeValue( this ); } - public Document getOwnerDocument ( ) { return DomImpl._node_getOwnerDocument( this ); } - public String getPrefix ( ) { return DomImpl._node_getPrefix( this ); } - public Node getPreviousSibling ( ) { return DomImpl._node_getPreviousSibling( this ); } - public boolean hasAttributes ( ) { return DomImpl._node_hasAttributes( this ); } - public boolean hasChildNodes ( ) { return DomImpl._node_hasChildNodes( this ); } - public Node insertBefore ( Node newChild, Node refChild ) { return DomImpl._node_insertBefore( this, newChild, refChild ); } - public boolean isSupported ( String feature, String version ) { return DomImpl._node_isSupported( this, feature, version ); } - public void normalize ( ) { DomImpl._node_normalize( this ); } - public Node replaceChild ( Node newChild, Node oldChild ) { return DomImpl._node_replaceChild( this, newChild, oldChild ); } - public void setNodeValue ( String nodeValue ) { DomImpl._node_setNodeValue( this, nodeValue ); } - public void setPrefix ( String prefix ) { DomImpl._node_setPrefix( this, prefix ); } - - // DOM Level 3 - public Object getUserData ( String key ) { return DomImpl._node_getUserData( this, key ); } - public Object setUserData ( String key, Object data, UserDataHandler handler ) { return DomImpl._node_setUserData( this, key, data, handler ); } - public Object getFeature ( String feature, String version ) { return DomImpl._node_getFeature( this, feature, version ); } - public boolean isEqualNode ( Node arg ) { return DomImpl._node_isEqualNode( this, arg ); } - public boolean isSameNode ( Node arg ) { return DomImpl._node_isSameNode( this, arg ); } - public String lookupNamespaceURI ( String prefix ) { return DomImpl._node_lookupNamespaceURI( this, prefix ); } - public String lookupPrefix ( String namespaceURI ) { return DomImpl._node_lookupPrefix( this, namespaceURI ); } - public boolean isDefaultNamespace ( String namespaceURI ) { return DomImpl._node_isDefaultNamespace( this, namespaceURI ); } - public void setTextContent ( String textContent ) { DomImpl._node_setTextContent( this, textContent ); } - public String getTextContent ( ) { return DomImpl._node_getTextContent( this ); } - public short compareDocumentPosition ( Node other ) { return DomImpl._node_compareDocumentPosition( this, other ); } - public String getBaseURI ( ) { return DomImpl._node_getBaseURI( this ); } - public Node adoptNode ( Node source ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getDocumentURI ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public DOMConfiguration getDomConfig ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getInputEncoding ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public boolean getStrictErrorChecking ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getXmlEncoding ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public boolean getXmlStandalone ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public String getXmlVersion ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void normalizeDocument ( ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public Node renameNode ( Node n, String namespaceURI, String qualifiedName ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setDocumentURI ( String documentURI ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setStrictErrorChecking ( boolean strictErrorChecking ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setXmlStandalone ( boolean xmlStandalone ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - public void setXmlVersion ( String xmlVersion ) { throw new RuntimeException( "DOM Level 3 Not implemented" ); } - - public Attr createAttribute ( String name ) { return DomImpl._document_createAttribute( this, name ); } - public Attr createAttributeNS ( String namespaceURI, String qualifiedName ) { return DomImpl._document_createAttributeNS( this, namespaceURI, qualifiedName ); } - public CDATASection createCDATASection ( String data ) { return DomImpl._document_createCDATASection( this, data ); } - public Comment createComment ( String data ) { return DomImpl._document_createComment( this, data ); } - public DocumentFragment createDocumentFragment ( ) { return DomImpl._document_createDocumentFragment( this ); } - public Element createElement ( String tagName ) { return DomImpl._document_createElement( this, tagName ); } - public Element createElementNS ( String namespaceURI, String qualifiedName ) { return DomImpl._document_createElementNS( this, namespaceURI, qualifiedName ); } - public EntityReference createEntityReference ( String name ) { return DomImpl._document_createEntityReference( this, name ); } - public ProcessingInstruction createProcessingInstruction ( String target, String data ) { return DomImpl._document_createProcessingInstruction( this, target, data ); } - public Text createTextNode ( String data ) { return DomImpl._document_createTextNode( this, data ); } - public DocumentType getDoctype ( ) { return DomImpl._document_getDoctype( this ); } - public Element getDocumentElement ( ) { return DomImpl._document_getDocumentElement( this ); } - public Element getElementById ( String elementId ) { return DomImpl._document_getElementById( this, elementId ); } - public NodeList getElementsByTagName ( String tagname ) { return DomImpl._document_getElementsByTagName( this, tagname ); } - public NodeList getElementsByTagNameNS ( String namespaceURI, String localName ) { return DomImpl._document_getElementsByTagNameNS( this, namespaceURI, localName ); } - public DOMImplementation getImplementation ( ) { return DomImpl._document_getImplementation( this ); } - public Node importNode ( Node importedNode, boolean deep ) { return DomImpl._document_importNode( this, importedNode, deep ); } - - public int getLength ( ) { return DomImpl._childNodes_getLength( this ); } - public Node item ( int i ) { return DomImpl._childNodes_item( this, i ); } - - public void removeAllMimeHeaders ( ) { DomImpl._soapPart_removeAllMimeHeaders( this ); } - public void removeMimeHeader ( String name ) { DomImpl._soapPart_removeMimeHeader( this, name ); } - public Iterator getAllMimeHeaders ( ) { return DomImpl._soapPart_getAllMimeHeaders( this ); } - public SOAPEnvelope getEnvelope ( ) { return DomImpl._soapPart_getEnvelope( this ); } - public Source getContent ( ) { return DomImpl._soapPart_getContent( this ); } - public void setContent ( Source source ) { DomImpl._soapPart_setContent( this, source ); } - public String[] getMimeHeader ( String name ) { return DomImpl._soapPart_getMimeHeader( this, name ); } - public void addMimeHeader ( String name, String value ) { DomImpl._soapPart_addMimeHeader( this, name,value ); } - public void setMimeHeader ( String name, String value ) { DomImpl._soapPart_setMimeHeader( this, name, value ); } - public Iterator getMatchingMimeHeaders ( String[] names ) { return DomImpl._soapPart_getMatchingMimeHeaders( this, names ); } - public Iterator getNonMatchingMimeHeaders ( String[] names ) { return DomImpl._soapPart_getNonMatchingMimeHeaders( this, names ); } - - public boolean nodeCanHavePrefixUri( ){ return true; } - - SoapPartDocXobj _docXobj; - } - - static class SoapElementXobj - extends ElementXobj implements SOAPElement, org.apache.xmlbeans.impl.soap.Node - { - SoapElementXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapElementXobj( l, _name ); } - - public void detachNode ( ) { DomImpl._soapNode_detachNode( this ); } - public void recycleNode ( ) { DomImpl._soapNode_recycleNode( this ); } - public String getValue ( ) { return DomImpl._soapNode_getValue( this ); } - public void setValue ( String value ) { DomImpl._soapNode_setValue( this, value ); } - public SOAPElement getParentElement ( ) { return DomImpl._soapNode_getParentElement( this ); } - public void setParentElement ( SOAPElement p ) { DomImpl._soapNode_setParentElement( this, p ); } - - public void removeContents ( ) { DomImpl._soapElement_removeContents( this ); } - public String getEncodingStyle ( ) { return DomImpl._soapElement_getEncodingStyle( this ); } - public void setEncodingStyle ( String encodingStyle ) { DomImpl._soapElement_setEncodingStyle( this, encodingStyle ); } - public boolean removeNamespaceDeclaration ( String prefix ) { return DomImpl._soapElement_removeNamespaceDeclaration( this, prefix ); } - public Iterator getAllAttributes ( ) { return DomImpl._soapElement_getAllAttributes( this ); } - public Iterator getChildElements ( ) { return DomImpl._soapElement_getChildElements( this ); } - public Iterator getNamespacePrefixes ( ) { return DomImpl._soapElement_getNamespacePrefixes( this ); } - public SOAPElement addAttribute ( Name name, String value ) throws SOAPException { return DomImpl._soapElement_addAttribute( this, name, value ); } - public SOAPElement addChildElement ( SOAPElement oldChild ) throws SOAPException { return DomImpl._soapElement_addChildElement( this, oldChild ); } - public SOAPElement addChildElement ( Name name ) throws SOAPException { return DomImpl._soapElement_addChildElement( this, name ); } - public SOAPElement addChildElement ( String localName ) throws SOAPException { return DomImpl._soapElement_addChildElement( this, localName ); } - public SOAPElement addChildElement ( String localName, String prefix ) throws SOAPException { return DomImpl._soapElement_addChildElement( this, localName, prefix ); } - public SOAPElement addChildElement ( String localName, String prefix, String uri ) throws SOAPException { return DomImpl._soapElement_addChildElement( this, localName, prefix, uri ); } - public SOAPElement addNamespaceDeclaration ( String prefix, String uri ) { return DomImpl._soapElement_addNamespaceDeclaration( this, prefix, uri ); } - public SOAPElement addTextNode ( String data ) { return DomImpl._soapElement_addTextNode( this, data ); } - public String getAttributeValue ( Name name ) { return DomImpl._soapElement_getAttributeValue( this, name ); } - public Iterator getChildElements ( Name name ) { return DomImpl._soapElement_getChildElements( this, name ); } - public Name getElementName ( ) { return DomImpl._soapElement_getElementName( this ); } - public String getNamespaceURI ( String prefix ) { return DomImpl._soapElement_getNamespaceURI( this, prefix ); } - public Iterator getVisibleNamespacePrefixes ( ) { return DomImpl._soapElement_getVisibleNamespacePrefixes( this ); } - public boolean removeAttribute ( Name name ) { return DomImpl._soapElement_removeAttribute( this, name ); } - } - - static class SoapBodyXobj extends SoapElementXobj implements SOAPBody - { - SoapBodyXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapBodyXobj( l, _name ); } - - public boolean hasFault ( ) { return DomImpl.soapBody_hasFault( this ); } - public SOAPFault addFault ( ) throws SOAPException { return DomImpl.soapBody_addFault( this ); } - public SOAPFault getFault ( ) { return DomImpl.soapBody_getFault( this ); } - public SOAPBodyElement addBodyElement ( Name name ) { return DomImpl.soapBody_addBodyElement( this, name ); } - public SOAPBodyElement addDocument ( Document document ) { return DomImpl.soapBody_addDocument( this, document ); } - public SOAPFault addFault ( Name name, String s ) throws SOAPException { return DomImpl.soapBody_addFault( this, name, s ); } - public SOAPFault addFault ( Name faultCode, String faultString, java.util.Locale locale ) throws SOAPException { return DomImpl.soapBody_addFault( this, faultCode, faultString, locale ); } - } - - static class SoapBodyElementXobj extends SoapElementXobj implements SOAPBodyElement - { - SoapBodyElementXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapBodyElementXobj( l, _name ); } - } - - static class SoapEnvelopeXobj extends SoapElementXobj implements SOAPEnvelope - { - SoapEnvelopeXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapEnvelopeXobj( l, _name ); } - - public SOAPBody addBody ( ) throws SOAPException { return DomImpl._soapEnvelope_addBody( this ); } - public SOAPBody getBody ( ) throws SOAPException { return DomImpl._soapEnvelope_getBody( this ); } - public SOAPHeader getHeader ( ) throws SOAPException { return DomImpl._soapEnvelope_getHeader( this ); } - public SOAPHeader addHeader ( ) throws SOAPException { return DomImpl._soapEnvelope_addHeader( this ); } - public Name createName ( String localName ) { return DomImpl._soapEnvelope_createName( this, localName ); } - public Name createName ( String localName, String prefix, String namespaceURI ) { return DomImpl._soapEnvelope_createName( this, localName, prefix, namespaceURI ); } - } - - static class SoapHeaderXobj extends SoapElementXobj implements SOAPHeader - { - SoapHeaderXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapHeaderXobj( l, _name ); } - - public Iterator examineAllHeaderElements ( ) { return DomImpl.soapHeader_examineAllHeaderElements( this ); } - public Iterator extractAllHeaderElements ( ) { return DomImpl.soapHeader_extractAllHeaderElements( this ); } - public Iterator examineHeaderElements ( String actor ) { return DomImpl.soapHeader_examineHeaderElements( this, actor ); } - public Iterator examineMustUnderstandHeaderElements ( String mustUnderstandString ) { return DomImpl.soapHeader_examineMustUnderstandHeaderElements( this, mustUnderstandString ); } - public Iterator extractHeaderElements ( String actor ) { return DomImpl.soapHeader_extractHeaderElements( this, actor ); } - public SOAPHeaderElement addHeaderElement ( Name name ) { return DomImpl.soapHeader_addHeaderElement( this, name ); } - } - - static class SoapHeaderElementXobj extends SoapElementXobj implements SOAPHeaderElement - { - SoapHeaderElementXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapHeaderElementXobj( l, _name ); } - - public void setMustUnderstand ( boolean mustUnderstand ) { DomImpl.soapHeaderElement_setMustUnderstand( this, mustUnderstand ); } - public boolean getMustUnderstand ( ) { return DomImpl.soapHeaderElement_getMustUnderstand( this ); } - public void setActor ( String actor ) { DomImpl.soapHeaderElement_setActor( this, actor ); } - public String getActor ( ) { return DomImpl.soapHeaderElement_getActor( this ); } - } - - static class SoapFaultXobj extends SoapBodyElementXobj implements SOAPFault - { - SoapFaultXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapFaultXobj( l, _name ); } - - public void setFaultString ( String faultString ) { DomImpl.soapFault_setFaultString( this, faultString ); } - public void setFaultString ( String faultString, java.util.Locale locale ) { DomImpl.soapFault_setFaultString( this, faultString, locale ); } - public void setFaultCode ( Name faultCodeName ) throws SOAPException { DomImpl.soapFault_setFaultCode( this, faultCodeName ); } - public void setFaultActor ( String faultActorString ) { DomImpl.soapFault_setFaultActor( this, faultActorString ); } - public String getFaultActor ( ) { return DomImpl.soapFault_getFaultActor( this ); } - public String getFaultCode ( ) { return DomImpl.soapFault_getFaultCode( this ); } - public void setFaultCode ( String faultCode ) throws SOAPException { DomImpl.soapFault_setFaultCode( this, faultCode ); } - public java.util.Locale getFaultStringLocale ( ) { return DomImpl.soapFault_getFaultStringLocale( this ); } - public Name getFaultCodeAsName ( ) { return DomImpl.soapFault_getFaultCodeAsName( this ); } - public String getFaultString ( ) { return DomImpl.soapFault_getFaultString( this ); } - public Detail addDetail ( ) throws SOAPException { return DomImpl.soapFault_addDetail( this ); } - public Detail getDetail ( ) { return DomImpl.soapFault_getDetail( this ); } - } - - static class SoapFaultElementXobj extends SoapElementXobj implements SOAPFaultElement - { - SoapFaultElementXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new SoapFaultElementXobj( l, _name ); } - } - - static class DetailXobj extends SoapFaultElementXobj implements Detail - { - DetailXobj ( Locale l, QName name ) { super( l, name ); } - - Xobj newNode ( Locale l ) { return new DetailXobj( l, _name ); } - - public DetailEntry addDetailEntry ( Name name ) { return DomImpl.detail_addDetailEntry( this, name ); } - public Iterator getDetailEntries ( ) { return DomImpl.detail_getDetailEntries( this ); } - } - - static class DetailEntryXobj extends SoapElementXobj implements DetailEntry - { - Xobj newNode ( Locale l ) { return new DetailEntryXobj( l, _name ); } - - DetailEntryXobj ( Locale l, QName name ) { super( l, name ); } - } - - // - // - // - - static class Bookmark implements XmlMark - { - boolean isOnList ( Bookmark head ) - { - for ( ; head != null ; head = head._next ) - if (head == this) - return true; - - return false; - } - - Bookmark listInsert ( Bookmark head ) - { - assert _next == null && _prev == null; - - if (head == null) - head = _prev = this; - else - { - _prev = head._prev; - head._prev = head._prev._next = this; - } - - return head; - } - - Bookmark listRemove ( Bookmark head ) - { - assert _prev != null && isOnList( head ); - - if (_prev == this) - head = null; - else - { - if (head == this) - head = _next; - else - _prev._next = _next; - - if (_next == null) - head._prev = _prev; - else - { - _next._prev = _prev; - _next = null; - } - } - - _prev = null; - assert _next == null; - - return head; - } - - void moveTo ( Xobj x, int p ) - { - assert isOnList( _xobj._bookmarks ); - - if (_xobj != x) - { - _xobj._bookmarks = listRemove( _xobj._bookmarks ); - x._bookmarks = listInsert( x._bookmarks ); - - _xobj = x; - } - - _pos = p; - } - - // - // XmlCursor.XmlMark method - // - - public XmlCursor createCursor ( ) - { - if (_xobj == null) - { - throw new IllegalStateException( - "Attempting to create a cursor on a bookmark that " + - "has been cleared or replaced."); - } - - return Cursor.newCursor( _xobj, _pos ); - } - - // - // - // - - Xobj _xobj; - int _pos; - - Bookmark _next; - Bookmark _prev; - - Object _key; - Object _value; - } - - // - // - // - Locale _locale; QName _name; Modified: xmlbeans/trunk/src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java?rev=1877931&r1=1877930&r2=1877931&view=diff ============================================================================== --- xmlbeans/trunk/src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java (original) +++ xmlbeans/trunk/src/xmlconfig/org/apache/xmlbeans/impl/config/BindingConfigImpl.java Tue May 19 20:10:55 2020 @@ -15,138 +15,85 @@ package org.apache.xmlbeans.impl.config; -import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument.Config; -import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig; -import org.apache.xmlbeans.impl.xb.xmlconfig.Nsconfig; -import org.apache.xmlbeans.impl.xb.xmlconfig.Qnameconfig; -import org.apache.xmlbeans.impl.xb.xmlconfig.Qnametargetenum; -import org.apache.xmlbeans.impl.xb.xmlconfig.Usertypeconfig; -import org.apache.xmlbeans.BindingConfig; -import org.apache.xmlbeans.UserType; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlError; -import org.apache.xmlbeans.InterfaceExtension; -import org.apache.xmlbeans.PrePostExtension; -import org.apache.xmlbeans.impl.jam.JamClassLoader; -import org.apache.xmlbeans.impl.jam.JamService; -import org.apache.xmlbeans.impl.jam.JamServiceFactory; -import org.apache.xmlbeans.impl.jam.JamServiceParams; +import org.apache.xmlbeans.*; import org.apache.xmlbeans.impl.schema.StscState; +import org.apache.xmlbeans.impl.xb.xmlconfig.ConfigDocument.Config; +import org.apache.xmlbeans.impl.xb.xmlconfig.*; import javax.xml.namespace.QName; import java.io.File; -import java.io.IOException; import java.util.*; /** * An implementation of BindingConfig */ -public class BindingConfigImpl extends BindingConfig -{ - private Map _packageMap; - private Map _prefixMap; - private Map _suffixMap; - private Map _packageMapByUriPrefix; // uri prefix -> package - private Map _prefixMapByUriPrefix; // uri prefix -> name prefix - private Map _suffixMapByUriPrefix; // uri prefix -> name suffix - private Map _qnameTypeMap; - private Map _qnameDocTypeMap; - private Map _qnameElemMap; - private Map _qnameAttMap; - - private List _interfaceExtensions; - private List _prePostExtensions; - private Map _userTypes; - - private BindingConfigImpl() - { - _packageMap = Collections.EMPTY_MAP; - _prefixMap = Collections.EMPTY_MAP; - _suffixMap = Collections.EMPTY_MAP; - _packageMapByUriPrefix = Collections.EMPTY_MAP; - _prefixMapByUriPrefix = Collections.EMPTY_MAP; - _suffixMapByUriPrefix = Collections.EMPTY_MAP; - _qnameTypeMap = Collections.EMPTY_MAP; - _qnameDocTypeMap = Collections.EMPTY_MAP; - _qnameElemMap = Collections.EMPTY_MAP; - _qnameAttMap = Collections.EMPTY_MAP; - _interfaceExtensions = new ArrayList(); - _prePostExtensions = new ArrayList(); - _userTypes = Collections.EMPTY_MAP; - } +public class BindingConfigImpl extends BindingConfig { + private final Map _packageMap = new LinkedHashMap(); + private final Map _prefixMap = new LinkedHashMap(); + private final Map _suffixMap = new LinkedHashMap(); + // uri prefix -> package + private final Map<Object,String> _packageMapByUriPrefix = new LinkedHashMap<>(); + // uri prefix -> name prefix + private final Map<Object,String> _prefixMapByUriPrefix = new LinkedHashMap<>(); + // uri prefix -> name suffix + private final Map<Object,String> _suffixMapByUriPrefix = new LinkedHashMap<>(); + private final Map<QName,String> _qnameTypeMap = new LinkedHashMap<>(); + private final Map<QName,String> _qnameDocTypeMap = new LinkedHashMap<>(); + private final Map<QName,String> _qnameElemMap = new LinkedHashMap<>(); + private final Map<QName,String> _qnameAttMap = new LinkedHashMap<>(); + + private final List<InterfaceExtensionImpl> _interfaceExtensions = new ArrayList<>(); + private final List<PrePostExtensionImpl> _prePostExtensions = new ArrayList<>(); + private final Map<QName,UserTypeImpl> _userTypes = new LinkedHashMap<>(); - public static BindingConfig forConfigDocuments(Config[] configs, File[] javaFiles, File[] classpath) - { + public static BindingConfig forConfigDocuments(Config[] configs, File[] javaFiles, File[] classpath) { return new BindingConfigImpl(configs, javaFiles, classpath); } - private BindingConfigImpl(Config[] configs, File[] javaFiles, File[] classpath) - { - _packageMap = new LinkedHashMap(); - _prefixMap = new LinkedHashMap(); - _suffixMap = new LinkedHashMap(); - _packageMapByUriPrefix = new LinkedHashMap(); - _prefixMapByUriPrefix = new LinkedHashMap(); - _suffixMapByUriPrefix = new LinkedHashMap(); - _qnameTypeMap = new LinkedHashMap(); - _qnameDocTypeMap = new LinkedHashMap(); - _qnameElemMap = new LinkedHashMap(); - _qnameAttMap = new LinkedHashMap(); - _interfaceExtensions = new ArrayList(); - _prePostExtensions = new ArrayList(); - _userTypes = new LinkedHashMap(); - - for (int i = 0; i < configs.length; i++) - { - Config config = configs[i]; + private BindingConfigImpl(Config[] configs, File[] javaFiles, File[] classpath) { + for (Config config : configs) { Nsconfig[] nsa = config.getNamespaceArray(); - for (int j = 0; j < nsa.length; j++) - { - recordNamespaceSetting(nsa[j].getUri(), nsa[j].getPackage(), _packageMap); - recordNamespaceSetting(nsa[j].getUri(), nsa[j].getPrefix(), _prefixMap); - recordNamespaceSetting(nsa[j].getUri(), nsa[j].getSuffix(), _suffixMap); - recordNamespacePrefixSetting(nsa[j].getUriprefix(), nsa[j].getPackage(), _packageMapByUriPrefix); - recordNamespacePrefixSetting(nsa[j].getUriprefix(), nsa[j].getPrefix(), _prefixMapByUriPrefix); - recordNamespacePrefixSetting(nsa[j].getUriprefix(), nsa[j].getSuffix(), _suffixMapByUriPrefix); + for (Nsconfig nsconfig : nsa) { + recordNamespaceSetting(nsconfig.getUri(), nsconfig.getPackage(), _packageMap); + recordNamespaceSetting(nsconfig.getUri(), nsconfig.getPrefix(), _prefixMap); + recordNamespaceSetting(nsconfig.getUri(), nsconfig.getSuffix(), _suffixMap); + recordNamespacePrefixSetting(nsconfig.getUriprefix(), nsconfig.getPackage(), _packageMapByUriPrefix); + recordNamespacePrefixSetting(nsconfig.getUriprefix(), nsconfig.getPrefix(), _prefixMapByUriPrefix); + recordNamespacePrefixSetting(nsconfig.getUriprefix(), nsconfig.getSuffix(), _suffixMapByUriPrefix); } Qnameconfig[] qnc = config.getQnameArray(); - for (int j = 0; j < qnc.length; j++) - { - List applyto = qnc[j].xgetTarget().xgetListValue(); - QName name = qnc[j].getName(); - String javaname = qnc[j].getJavaname(); - for (int k = 0; k < applyto.size(); k++) - { - Qnametargetenum a = (Qnametargetenum) applyto.get(k); - switch (a.enumValue().intValue()) - { - case Qnametargetenum.INT_TYPE: - _qnameTypeMap.put(name, javaname); - break; - case Qnametargetenum.INT_DOCUMENT_TYPE: - _qnameDocTypeMap.put(name, javaname); - break; - case Qnametargetenum.INT_ACCESSOR_ELEMENT: - _qnameElemMap.put(name, javaname); - break; - case Qnametargetenum.INT_ACCESSOR_ATTRIBUTE: - _qnameAttMap.put(name, javaname); - break; + for (Qnameconfig qnameconfig : qnc) { + List applyto = qnameconfig.xgetTarget().xgetListValue(); + QName name = qnameconfig.getName(); + String javaname = qnameconfig.getJavaname(); + for (Object o : applyto) { + Qnametargetenum a = (Qnametargetenum) o; + switch (a.enumValue().intValue()) { + case Qnametargetenum.INT_TYPE: + _qnameTypeMap.put(name, javaname); + break; + case Qnametargetenum.INT_DOCUMENT_TYPE: + _qnameDocTypeMap.put(name, javaname); + break; + case Qnametargetenum.INT_ACCESSOR_ELEMENT: + _qnameElemMap.put(name, javaname); + break; + case Qnametargetenum.INT_ACCESSOR_ATTRIBUTE: + _qnameAttMap.put(name, javaname); + break; } } } Extensionconfig[] ext = config.getExtensionArray(); - for (int j = 0; j < ext.length; j++) - { - recordExtensionSetting(javaFiles, classpath, ext[j]); + for (Extensionconfig extensionconfig : ext) { + recordExtensionSetting(javaFiles, classpath, extensionconfig); } - + Usertypeconfig[] utypes = config.getUsertypeArray(); - for (int j = 0; j < utypes.length; j++) - { - recordUserTypeSetting(javaFiles, classpath, utypes[j]); + for (Usertypeconfig utype : utypes) { + recordUserTypeSetting(javaFiles, classpath, utype); } } @@ -154,102 +101,84 @@ public class BindingConfigImpl extends B //todo normalize(); } - void addInterfaceExtension(InterfaceExtensionImpl ext) - { - if (ext==null) + void addInterfaceExtension(InterfaceExtensionImpl ext) { + if (ext==null) { return; + } _interfaceExtensions.add(ext); } - void addPrePostExtension(PrePostExtensionImpl ext) - { - if (ext==null) + void addPrePostExtension(PrePostExtensionImpl ext) { + if (ext==null) { return; + } _prePostExtensions.add(ext); } - void secondPhaseValidation() - { + void secondPhaseValidation() { // validate interface methods collisions - Map methodSignatures = new HashMap(); + Map<InterfaceExtension.MethodSignature,InterfaceExtension.MethodSignature> methodSignatures = new HashMap<>(); - for (int i = 0; i < _interfaceExtensions.size(); i++) - { - InterfaceExtensionImpl interfaceExtension = (InterfaceExtensionImpl) _interfaceExtensions.get(i); + for (InterfaceExtensionImpl extension : _interfaceExtensions) { - InterfaceExtensionImpl.MethodSignatureImpl[] methods = (InterfaceExtensionImpl.MethodSignatureImpl[])interfaceExtension.getMethods(); - for (int j = 0; j < methods.length; j++) - { - InterfaceExtensionImpl.MethodSignatureImpl ms = methods[j]; - - if (methodSignatures.containsKey(methods[j])) - { - - InterfaceExtensionImpl.MethodSignatureImpl ms2 = (InterfaceExtensionImpl.MethodSignatureImpl) methodSignatures.get(methods[j]); - if (!ms.getReturnType().equals(ms2.getReturnType())) - { + InterfaceExtensionImpl.MethodSignatureImpl[] methods = (InterfaceExtensionImpl.MethodSignatureImpl[]) extension.getMethods(); + for (InterfaceExtensionImpl.MethodSignatureImpl ms : methods) { + if (methodSignatures.containsKey(ms)) { + + InterfaceExtensionImpl.MethodSignatureImpl ms2 = (InterfaceExtensionImpl.MethodSignatureImpl) methodSignatures.get(ms); + if (!ms.getReturnType().equals(ms2.getReturnType())) { BindingConfigImpl.error("Colliding methods '" + ms.getSignature() + "' in interfaces " + - ms.getInterfaceName() + " and " + ms2.getInterfaceName() + ".", null); + ms.getInterfaceName() + " and " + ms2.getInterfaceName() + ".", null); } return; } // store it into hashmap - methodSignatures.put(methods[j], methods[j]); + methodSignatures.put(ms, ms); } } // validate that PrePostExtension-s do not intersect - for (int i = 0; i < _prePostExtensions.size() - 1; i++) - { - PrePostExtensionImpl a = (PrePostExtensionImpl) _prePostExtensions.get(i); - for (int j = 1; j < _prePostExtensions.size(); j++) - { - PrePostExtensionImpl b = (PrePostExtensionImpl) _prePostExtensions.get(j); - if (a.hasNameSetIntersection(b)) + for (int i = 0; i < _prePostExtensions.size() - 1; i++) { + PrePostExtensionImpl a = _prePostExtensions.get(i); + for (int j = 1; j < _prePostExtensions.size(); j++) { + PrePostExtensionImpl b = _prePostExtensions.get(j); + if (a.hasNameSetIntersection(b)) { BindingConfigImpl.error("The applicable domain for handler '" + a.getHandlerNameForJavaSource() + - "' intersects with the one for '" + b.getHandlerNameForJavaSource() + "'.", null); + "' intersects with the one for '" + b.getHandlerNameForJavaSource() + "'.", null); + } } } } - private static void recordNamespaceSetting(Object key, String value, Map result) - { - if (value == null) + private static void recordNamespaceSetting(Object key, String value, Map<Object,String> result) { + if (value == null) { return; - else if (key == null) + } + if (key == null) { result.put("", value); - else if (key instanceof String && "##any".equals(key)) + } else if (key instanceof String && "##any".equals(key)) { result.put(key, value); - else if (key instanceof List) - { - for (Iterator i = ((List)key).iterator(); i.hasNext(); ) - { - String uri = (String)i.next(); - if ("##local".equals(uri)) - uri = ""; - result.put(uri, value); - } + } else if (key instanceof List) { + // map uris to value + ((List<?>)key).forEach(o -> result.put("##local".equals(o) ? "" : o, value)); } } - private static void recordNamespacePrefixSetting(List list, String value, Map result) - { - if (value == null) + private static void recordNamespacePrefixSetting(List list, String value, Map<Object,String> result) { + if (value == null) { return; - else if (list == null) + } + if (list == null) { return; - for (Iterator i = list.iterator(); i.hasNext(); ) - { - result.put(i.next(), value); } + list.forEach(o -> result.put(o, value)); } - private void recordExtensionSetting(File[] javaFiles, File[] classpath, Extensionconfig ext) - { + private void recordExtensionSetting(File[] javaFiles, File[] classpath, Extensionconfig ext) { NameSet xbeanSet = null; Object key = ext.getFor(); @@ -259,9 +188,8 @@ public class BindingConfigImpl extends B else if (key instanceof List) { NameSetBuilder xbeanSetBuilder = new NameSetBuilder(); - for (Iterator i = ((List) key).iterator(); i.hasNext();) - { - String xbeanName = (String) i.next(); + for (Object o : (List) key) { + String xbeanName = (String) o; xbeanSetBuilder.add(xbeanName); } xbeanSet = xbeanSetBuilder.toNameSet(); @@ -271,210 +199,131 @@ public class BindingConfigImpl extends B error("Invalid value of attribute 'for' : '" + key + "'.", ext); Extensionconfig.Interface[] intfXO = ext.getInterfaceArray(); - Extensionconfig.PrePostSet ppXO = ext.getPrePostSet(); + Extensionconfig.PrePostSet ppXO = ext.getPrePostSet(); - if (intfXO.length > 0 || ppXO != null) - { - JamClassLoader jamLoader = getJamLoader(javaFiles, classpath); - for (int i = 0; i < intfXO.length; i++) - { - addInterfaceExtension(InterfaceExtensionImpl.newInstance(jamLoader, xbeanSet, intfXO[i])); + Parser loader = new Parser(javaFiles, classpath); + + if (intfXO.length > 0 || ppXO != null) { + for (Extensionconfig.Interface anInterface : intfXO) { + addInterfaceExtension(InterfaceExtensionImpl.newInstance(loader, xbeanSet, anInterface)); } - addPrePostExtension(PrePostExtensionImpl.newInstance(jamLoader, xbeanSet, ppXO)); + addPrePostExtension(PrePostExtensionImpl.newInstance(loader, xbeanSet, ppXO)); } } - private void recordUserTypeSetting(File[] javaFiles, File[] classpath, - Usertypeconfig usertypeconfig) - { - JamClassLoader jamLoader = getJamLoader(javaFiles, classpath); - UserTypeImpl userType = UserTypeImpl.newInstance(jamLoader, usertypeconfig); + private void recordUserTypeSetting(File[] javaFiles, File[] classpath, Usertypeconfig usertypeconfig) { + Parser loader = new Parser(javaFiles, classpath); + UserTypeImpl userType = UserTypeImpl.newInstance(loader, usertypeconfig); _userTypes.put(userType.getName(), userType); } - private String lookup(Map map, Map mapByUriPrefix, String uri) - { - if (uri == null) + private String lookup(Map map, Map mapByUriPrefix, String uri) { + if (uri == null) { uri = ""; + } String result = (String)map.get(uri); - if (result != null) + if (result != null) { return result; - if (mapByUriPrefix != null) - { + } + if (mapByUriPrefix != null) { result = lookupByUriPrefix(mapByUriPrefix, uri); - if (result != null) + if (result != null) { return result; + } } return (String)map.get("##any"); } - private String lookupByUriPrefix(Map mapByUriPrefix, String uri) - { - if (uri == null) + private String lookupByUriPrefix(Map mapByUriPrefix, String uri) { + if (uri == null) { return null; - if (!mapByUriPrefix.isEmpty()) - { + } + if (!mapByUriPrefix.isEmpty()) { String uriprefix = null; - Iterator i = mapByUriPrefix.keySet().iterator(); - while (i.hasNext()) - { - String nextprefix = (String)i.next(); - if (uriprefix != null && nextprefix.length() < uriprefix.length()) + for (Object o : mapByUriPrefix.keySet()) { + String nextprefix = (String) o; + if (uriprefix != null && nextprefix.length() < uriprefix.length()) { continue; - if (uri.startsWith(nextprefix)) + } + if (uri.startsWith(nextprefix)) { uriprefix = nextprefix; + } } - if (uriprefix != null) - return (String)mapByUriPrefix.get(uriprefix); + if (uriprefix != null) { + return (String) mapByUriPrefix.get(uriprefix); + } } return null; } //package methods - static void warning(String s, XmlObject xo) - { + static void warning(String s, XmlObject xo) { StscState.get().error(s, XmlError.SEVERITY_WARNING, xo); } - static void error(String s, XmlObject xo) - { + static void error(String s, XmlObject xo) { StscState.get().error(s, XmlError.SEVERITY_ERROR, xo); } //public methods - public String lookupPackageForNamespace(String uri) - { + public String lookupPackageForNamespace(String uri) { return lookup(_packageMap, _packageMapByUriPrefix, uri); } - public String lookupPrefixForNamespace(String uri) - { + public String lookupPrefixForNamespace(String uri) { return lookup(_prefixMap, _prefixMapByUriPrefix, uri); } - public String lookupSuffixForNamespace(String uri) - { + public String lookupSuffixForNamespace(String uri) { return lookup(_suffixMap, _suffixMapByUriPrefix, uri); } /** @deprecated replaced with {@link #lookupJavanameForQName(QName, int)} */ - public String lookupJavanameForQName(QName qname) - { - String result = (String)_qnameTypeMap.get(qname); - if (result != null) - return result; - return (String)_qnameDocTypeMap.get(qname); + public String lookupJavanameForQName(QName qname) { + String result = _qnameTypeMap.get(qname); + return result != null ? result : _qnameDocTypeMap.get(qname); } - public String lookupJavanameForQName(QName qname, int kind) - { - switch (kind) - { + public String lookupJavanameForQName(QName qname, int kind) { + switch (kind) { case QNAME_TYPE: - return (String)_qnameTypeMap.get(qname); + return _qnameTypeMap.get(qname); case QNAME_DOCUMENT_TYPE: - return (String)_qnameDocTypeMap.get(qname); + return _qnameDocTypeMap.get(qname); case QNAME_ACCESSOR_ELEMENT: - return (String)_qnameElemMap.get(qname); + return _qnameElemMap.get(qname); case QNAME_ACCESSOR_ATTRIBUTE: - return (String)_qnameAttMap.get(qname); + return _qnameAttMap.get(qname); } return null; } - public UserType lookupUserTypeForQName(QName qname) - { - if (qname == null) - return null; - - return (UserType) _userTypes.get(qname); - } - - public InterfaceExtension[] getInterfaceExtensions() - { - return (InterfaceExtension[])_interfaceExtensions.toArray(new InterfaceExtension[_interfaceExtensions.size()]); + public UserType lookupUserTypeForQName(QName qname) { + return qname == null ? null : _userTypes.get(qname); } - public InterfaceExtension[] getInterfaceExtensions(String fullJavaName) - { - List result = new ArrayList(); - for (int i = 0; i < _interfaceExtensions.size(); i++) - { - InterfaceExtensionImpl intfExt = (InterfaceExtensionImpl) _interfaceExtensions.get(i); - if (intfExt.contains(fullJavaName)) - result.add(intfExt); - } - - return (InterfaceExtension[])result.toArray(new InterfaceExtension[result.size()]); + public InterfaceExtension[] getInterfaceExtensions() { + return _interfaceExtensions.toArray(new InterfaceExtension[0]); } - public PrePostExtension[] getPrePostExtensions() - { - return (PrePostExtension[])_prePostExtensions.toArray(new PrePostExtension[_prePostExtensions.size()]); + public InterfaceExtension[] getInterfaceExtensions(String fullJavaName) { + return _interfaceExtensions.stream(). + filter(i -> i.contains(fullJavaName)). + toArray(InterfaceExtension[]::new); } - public PrePostExtension getPrePostExtension(String fullJavaName) - { - for (int i = 0; i < _prePostExtensions.size(); i++) - { - PrePostExtensionImpl prePostExt = (PrePostExtensionImpl) _prePostExtensions.get(i); - if (prePostExt.contains(fullJavaName)) - return prePostExt; - } - return null; + public PrePostExtension[] getPrePostExtensions() { + return _prePostExtensions.toArray(new PrePostExtension[0]); } - private JamClassLoader getJamLoader(File[] javaFiles, File[] classpath) - { - JamServiceFactory jf = JamServiceFactory.getInstance(); - JamServiceParams params = jf.createServiceParams(); - params.set14WarningsEnabled(false); - // BUGBUG(radup) This is here because the above doesn't do the trick - params.setShowWarnings(false); - - // process the included sources - if (javaFiles!=null) - for (int i = 0; i < javaFiles.length; i++) - params.includeSourceFile(javaFiles[i]); - - //params.setVerbose(DirectoryScanner.class); - - // add the sourcepath and classpath, if specified - params.addClassLoader(this.getClass().getClassLoader()); - if (classpath != null) - for (int i = 0; i < classpath.length; i++) - params.addClasspath(classpath[i]); - - // create service, get classes, return compiler - JamService service; - try - { - service = jf.createService(params); - } - catch (IOException ioe) - { - error("Error when accessing .java files.", null); - return null; - } - -// JClass[] cls = service.getAllClasses(); -// for (int i = 0; i < cls.length; i++) -// { -// JClass cl = cls[i]; -// System.out.println("CL: " + cl + " " + cl.getQualifiedName()); -// JMethod[] methods = cl.getMethods(); -// for (int j = 0; j < methods.length; j++) -// { -// JMethod method = methods[j]; -// System.out.println(" " + method.getQualifiedName()); -// } -// } - - return service.getClassLoader(); + public PrePostExtension getPrePostExtension(String fullJavaName) { + return _prePostExtensions.stream(). + filter(p -> p.contains(fullJavaName)). + findFirst().orElse(null); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
