//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.6-b27-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.06.11 at 10:33:54 AM PDT
//
/**
* Implementation of the NamespaceContext2.
*
* This class also provides several utility methods for
* XMLSerializer-derived classes.
*
* The startElement method and the endElement method need to be called
* appropriately when used. See javadoc for those methods for details.
*/
{
/**
* Sequence generator. Used as the last resort to generate
* unique prefix.
*/
/**
* Used to maintain association between prefixes and URIs.
*/
/**
* A flag that indicates the current mode of this object.
*/
private boolean inCollectingMode;
/** Assigns prefixes to URIs. Can be null. */
/**
* Used during the collecting mode to sort out the namespace
* URIs we need for this element.
*
* A map from prefixes to namespace URIs.
*/
this.prefixMapper = _prefixMapper;
// declare the default namespace binding
// which are effective because of the way XML1.0 is made
// this one is taken care of by the NamespaceSupport class by default.
// nss.declarePrefix( "xml", XMLConstants.XML_NS_URI );
}
return prefixMapper;
}
//
//
// public methods of MarshallingContext
//
//
/**
* @param requirePrefix
* true if this is called for attribute name. false otherwise.
*/
public String declareNamespace( String namespaceUri, String preferedPrefix, boolean requirePrefix ) {
if( !inCollectingMode ) {
return ""; // can use the default prefix. use it whenever we can
// find a valid prefix for this namespace URI
// ASSERTION: the result is always non-null,
// since we require all the namespace URIs to be declared while
// this object is in collection mode.
if (requirePrefix)
else
} else {
return "";
// collect this new namespace URI
// this namespace URI is already taken care of,
// and it satisfies the "requirePrefix" requirement.
return prefix;
} else {
// the prefix was already allocated but it's "",
// and we specifically need non-empty prefix.
// erase the current binding
}
}
// the empty namespace URI needs to be bound to the default prefix.
prefix = "";
} else {
// see if this namespace URI is already in-scope
// if not, try to allocate a new one.
// use prefixMapper if specified. If so, just let the
// prefixMapper decide if it wants to use the suggested prefix.
// otherwise our best bet is the suggested prefix.
if( prefixMapper!=null )
else
// if the user don't care, generate one
}
}
// ASSERT: prefix!=null
// we can't map it to the default prefix. generate one.
while(true) {
if( existingUri==null ) {
// this prefix is unoccupied. use it
return prefix;
}
// we have to remap the new namespace URI to a different
// prefix because the current association of ""->"" cannot
// be changed
;
} else {
// the new one takes precedence. this is necessary
// because we might first assign "uri1"->"" and then
// later find that ""->"" needs to be added.
// so change the existing one
}
// we need to find a new prefix for URI "namespaceUri"
// generate a machine-made prefix
// go back to the loop and reassign
}
}
}
// even through the method name is "getPrefix", we
// use this method to declare prefixes if necessary.
// the only time a prefix is required is when we print
// attribute names, and in those cases we will call
// declareNamespace method directly. So it's safe to
// assume that we don't require a prefix in this case.
}
/**
* Obtains the namespace URI currently associated to the given prefix.
* If no namespace URI is associated, return null.
*/
}
// not particularly efficient implementation.
s.add("");
s.add(e.nextElement());
return s.iterator();
}
/**
* Sets the current bindings aside and starts a new element context.
*
* This method should be called at the beginning of the startElement method
* of the Serializer implementation.
*/
public void startElement() {
nss.pushContext();
inCollectingMode = true;
}
/**
* last startElement method invocation and finalizes them.
*
* This method must be called after all the necessary namespace URIs
* for this element is reported through the declareNamespace method
* or the getPrefix method.
*/
public void endNamespaceDecls() {
// most of the times decls is empty, so take advantage of it.
}
}
inCollectingMode = false;
}
/**
* Ends the current element context and gets back to the parent context.
*
* This method should be called at the end of the endElement method
* of derived classes.
*/
public void endElement() {
nss.popContext();
}
/** Iterates all newly declared namespace prefixes for this element. */
}
}
}