Class NamespacePrefixMapper

  extended by com.sun.xml.bind.marshaller.NamespacePrefixMapper
      extended by org.openprovenance.model.NamespacePrefixMapper

public class NamespacePrefixMapper
extends com.sun.xml.bind.marshaller.NamespacePrefixMapper

Prefix definition for OPM serialisations.

Constructor Summary
NamespacePrefixMapper(String defaultNamespace)
Method Summary
 String[] getPreDeclaredNamespaceUris()
          Returns a list of namespace URIs that should be declared at the root element.
 String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix)
          Returns a preferred prefix for the given namespace URI.
Methods inherited from class com.sun.xml.bind.marshaller.NamespacePrefixMapper
getContextualNamespaceDecls, getPreDeclaredNamespaceUris2
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public NamespacePrefixMapper(String defaultNamespace)
Method Detail


public String getPreferredPrefix(String namespaceUri,
                                 String suggestion,
                                 boolean requirePrefix)
Returns a preferred prefix for the given namespace URI. This method is intended to be overrided by a derived class.

Specified by:
getPreferredPrefix in class com.sun.xml.bind.marshaller.NamespacePrefixMapper
namespaceUri - The namespace URI for which the prefix needs to be found. Never be null. "" is used to denote the default namespace.
suggestion - When the content tree has a suggestion for the prefix to the given namespaceUri, that suggestion is passed as a parameter. Typically this value comes from QName.getPrefix() to show the preference of the content tree. This parameter may be null, and this parameter may represent an already occupied prefix.
requirePrefix - If this method is expected to return non-empty prefix. When this flag is true, it means that the given namespace URI cannot be set as the default namespace.
null if there's no preferred prefix for the namespace URI. In this case, the system will generate a prefix for you. Otherwise the system will try to use the returned prefix, but generally there's no guarantee if the prefix will be actually used or not. return "" to map this namespace URI to the default namespace. Again, there's no guarantee that this preference will be honored. If this method returns "" when requirePrefix=true, the return value will be ignored and the system will generate one.


public String[] getPreDeclaredNamespaceUris()
Returns a list of namespace URIs that should be declared at the root element.

By default, the JAXB RI produces namespace declarations only when they are necessary, only at where they are used. Because of this lack of look-ahead, sometimes the marshaller produces a lot of namespace declarations that look redundant to human eyes. For example,

 <?xml version="1.0"?>
   <ns1:child xmlns:ns1="urn:foo"> ... </ns1:child>
   <ns2:child xmlns:ns2="urn:foo"> ... </ns2:child>
   <ns3:child xmlns:ns3="urn:foo"> ... </ns3:child>
 If you know in advance that you are going to use a certain set of
 namespace URIs, you can override this method and have the marshaller
 declare those namespace URIs at the root element.
 For example, by returning <code>new String[]{"urn:foo"}</code>,
 the marshaller will produce:
 <?xml version="1.0"?>
 <root xmlns:ns1="urn:foo">
   <ns1:child> ... </ns1:child>
   <ns1:child> ... </ns1:child>
   <ns1:child> ... </ns1:child>
 To control prefixes assigned to those namespace URIs, use the
 <A HREF="../../../org/openprovenance/model/NamespacePrefixMapper.html#getPreferredPrefix(java.lang.String, java.lang.String, boolean)"><CODE>getPreferredPrefix(java.lang.String, java.lang.String, boolean)</CODE></A> method.
<DT><B>Overrides:</B><DD><CODE>getPreDeclaredNamespaceUris</CODE> in class <CODE>com.sun.xml.bind.marshaller.NamespacePrefixMapper</CODE></DL>

<DT><B>Returns:</B><DD>A list of namespace URIs as an array of <A HREF="" title="class or interface in java.lang"><CODE>String</CODE></A>s.
      This method can return a length-zero array but not null.
      None of the array component can be null. To represent
      the empty namespace, use the empty string <code>""</code>.<DT><B>Since:</B></DT>
  <DD>JAXB RI 1.0.2</DD>
<!-- ========= END OF CLASS DATA ========= -->

<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<A NAME="navbar_bottom_firstrow"><!-- --></A>
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/NamespacePrefixMapper.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>

<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../org/openprovenance/model/Label.html" title="class in org.openprovenance.model"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../org/openprovenance/model/Node.html" title="interface in org.openprovenance.model"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../index.html?org/openprovenance/model/NamespacePrefixMapper.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="NamespacePrefixMapper.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  if(window==top) {
    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>

<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

Copyright © 2011. All Rights Reserved.