/** * Copies all currently declared namespaces of the given XmlWriterSupport instance as new implied namespaces into this * instance. * * @param writerSupport the Xml-writer from where to copy the declared namespaces. */ public void copyNamespaces( final XmlWriterSupport writerSupport ) { if ( openTags.isEmpty() == false ) { throw new IllegalStateException( "Cannot modify the implied namespaces in the middle of the processing" ); } if ( impliedNamespaces == null ) { impliedNamespaces = new HashMap(); } if ( writerSupport.openTags.isEmpty() == false ) { final ElementLevel parent = (ElementLevel) writerSupport.openTags.peek(); impliedNamespaces.putAll( parent.getNamespaces().getNamespaces() ); } if ( writerSupport.impliedNamespaces != null ) { impliedNamespaces.putAll( writerSupport.impliedNamespaces ); } }
/** * Returns all namespaces as properties-collection. This reflects the currently defined namespaces, therefore calls to * writeOpenTag(..) might cause this method to return different collections. * * @return the defined namespaces. */ public Properties getNamespaces() { final Properties namespaces = new Properties(); if ( openTags.isEmpty() ) { if ( impliedNamespaces != null ) { //noinspection UseOfPropertiesAsHashtable namespaces.putAll( impliedNamespaces ); } return namespaces; } final ElementLevel parent = (ElementLevel) openTags.peek(); //noinspection UseOfPropertiesAsHashtable namespaces.putAll( parent.getNamespaces().getNamespaces() ); return namespaces; }
/** * Checks, whether the given URI is defined as valid namespace. * * @param uri the uri of the namespace. * @return true, if there's a namespace defined, false otherwise. */ public boolean isNamespaceDefined( final String uri ) { if ( impliedNamespaces != null ) { if ( impliedNamespaces.containsKey( uri ) ) { return true; } } if ( openTags.isEmpty() ) { return false; } final ElementLevel parent = (ElementLevel) openTags.peek(); return parent.getNamespaces().isNamespaceDefined( uri ); }
/** * Checks, whether the given namespace prefix is defined. * * @param prefix the namespace prefix. * @return true, if the prefix is defined, false otherwise. */ public boolean isNamespacePrefixDefined( final String prefix ) { if ( impliedNamespaces != null ) { if ( impliedNamespaces.containsValue( prefix ) ) { return true; } } if ( openTags.isEmpty() ) { return false; } final ElementLevel parent = (ElementLevel) openTags.peek(); return parent.getNamespaces().isPrefixDefined( prefix ); }
/** * Computes the current collection of defined namespaces. * * @return the namespaces declared at this writing position. */ protected DeclaredNamespaces computeNamespaces() { if ( openTags.isEmpty() ) { final DeclaredNamespaces namespaces = new DeclaredNamespaces(); if ( impliedNamespaces != null ) { return namespaces.add( impliedNamespaces ); } return namespaces; } final ElementLevel parent = (ElementLevel) openTags.peek(); return parent.getNamespaces(); }