org.jdom

Class Namespace


public final class Namespace
extends Object

An XML namespace representation, as well as a factory for creating XML namespace objects. Namespaces are not Serializable, however objects that use namespaces have special logic to handle serialization manually. These classes call the getNamespace() method on deserialization to ensure there is one unique Namespace object for any unique prefix/uri pair.

Field Summary

static Namespace
NO_NAMESPACE
Define a Namespace for when not in a namespace
static Namespace
XML_NAMESPACE
Define a Namespace for the standard xml prefix.

Method Summary

boolean
equals(Object ob)
This tests for equality - Two Namespaces are equal if and only if their URIs are byte-for-byte equals.
static Namespace
getNamespace(String uri)
This will retrieve (if in existence) or create (if not) a Namespace for the supplied URI, and make it usable as a default namespace, as no prefix is supplied.
static Namespace
getNamespace(String prefix, String uri)
This will retrieve (if in existence) or create (if not) a Namespace for the supplied prefix and URI.
String
getPrefix()
This returns the prefix mapped to this Namespace.
String
getURI()
This returns the namespace URI for this Namespace.
int
hashCode()
This returns a probably unique hash code for the Namespace.
String
toString()
This returns a String representation of this Namespace, suitable for use in debugging.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

NO_NAMESPACE

public static final Namespace NO_NAMESPACE
Define a Namespace for when not in a namespace
Usages and Demos :

View More Examples of NO_NAMESPACE
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import org.jdom.Parent;
   4:         ...
   5: 
   6:     public IdAttribute(String name, String value, Namespace namespace) {
   7:         super(name, value, namespace);
   8:         ...
   9:     public IdAttribute(String name, String value) {
  10:         this(name, value, UNDECLARED_TYPE, Namespace.NO_NAMESPACE);
  11:     }
  12:         ...
  13:     public IdAttribute(String name, String value, int type) {
  14:         this(name, value, type, Namespace.NO_NAMESPACE);

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:             String prefix = name.getPrefix();
   6:             Namespace ns;
   7:             if (prefix != null) {
   8:         ...
   9:                 if (prefix.equals("xml")) {
  10:                     ns = Namespace.XML_NAMESPACE;
  11:                 }
  12:         ...
  13:             else {
  14:                 ns = Namespace.NO_NAMESPACE;

View Full Code Here
   1: import org.jdom.JDOMException;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:     public XmlDifferenceFinder() {
   6:         this(Namespace.NO_NAMESPACE);
   7:     }
   8:         ...
   9: 
  10:     public XmlDifferenceFinder(Namespace namespace) {
  11:         this(namespace, true);

View Full Code Here
   1: import org.jdom.JDOMException;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:     
   6:     private Namespace namespace;
   7:     
   8:         ...
   9:     public JdomDifferenceFinder() {
  10:         this(Namespace.NO_NAMESPACE);
  11:     }

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import org.jdom.output.Format;
   4:         ...
   5: 
   6:     private static final Namespace DEFAULT_NAMESPACE = Namespace.NO_NAMESPACE;
   7:     
   8:         ...
   9: 
  10:     protected static Namespace getNs() {
  11:         return DEFAULT_NAMESPACE;

View Full Code Here

XML_NAMESPACE

public static final Namespace XML_NAMESPACE
Define a Namespace for the standard xml prefix.
Usages and Demos :

View More Examples of XML_NAMESPACE
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import org.jdom.Text;
   4: import org.jdom.input.SAXBuilder;
   5: import org.jdom.output.Format;

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:             String prefix = name.getPrefix();
   6:             Namespace ns;
   7:             if (prefix != null) {
   8:         ...
   9:                 if (prefix.equals("xml")) {
  10:                     ns = Namespace.XML_NAMESPACE;
  11:                 }
  12:         ...
  13:             else {
  14:                 ns = Namespace.NO_NAMESPACE;

View Full Code Here
   1: 
   2:         String temp_lang = element.getAttributeValue("lang", org.jdom.Namespace.XML_NAMESPACE);
   3: 
   4:         if ((temp_lang != null) && ((temp_lang = temp_lang.trim()).length() != 0)) {
   5:             lang = temp_lang;

View Full Code Here
   1: import org.jdom.JDOMException;
   2: import org.jdom.Namespace;
   3: import org.jdom.Text;
   4: import org.jdom.input.SAXBuilder;
   5: import org.jdom.output.Format;

View Full Code Here
   1: import org.jdom.JDOMException;
   2: import org.jdom.Namespace;
   3: import org.jdom.input.SAXBuilder;
   4:         ...
   5: public class WCMSActionServlet extends WCMSServlet {
   6:     private static final Namespace ns = Namespace.XML_NAMESPACE;
   7: 
   8:         ...
   9: 
  10:     public Element findActElem(Element element, String attr, String value, Namespace ns) {
  11:         List elements = element.getChildren();

View Full Code Here

Method Details

equals

public boolean equals(Object ob)
This tests for equality - Two Namespaces are equal if and only if their URIs are byte-for-byte equals.
Overrides:
equals in interface Object
Parameters:
ob - Object to compare to this Namespace.
Returns:
boolean - whether the supplied object is equal to this Namespace.
Usages and Demos :

View More Examples of equals(Object ob)
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import org.jdom.ProcessingInstruction;
   4:         ...
   5:             String v2 = t2.getValue();
   6:             return v1.equals(v2);
   7:         }
   8:         ...
   9:         public static boolean equivalent(DocType d1, DocType d2) {
  10:             return (((d1.getPublicID()==d2.getPublicID()) || d1.getPublicID().equals(d2.getPublicID())) && ((d1.getSystemID()==d2.getSystemID()) || d1.getSystemID().equals(d2.getSystemID())));
  11:         }
  12:         ...
  13:             String v2 = c2.getValue();
  14:             return v1.equals(v2);

View Full Code Here

getNamespace

public static Namespace getNamespace(String uri)
This will retrieve (if in existence) or create (if not) a Namespace for the supplied URI, and make it usable as a default namespace, as no prefix is supplied.
Parameters:
uri - String URI of new Namespace.
Returns:
Namespace - ready to use namespace.
Usages and Demos :

View More Examples of getNamespace(String uri)
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:         ArrayList ts = new ArrayList();
   6:         Namespace davns = Namespace.getNamespace( "DAV:" );
   7:         
   8:         ts.add( new Element("resourcetype",davns).addContent(new Element("collection",davns)) );
   9:         

View Full Code Here
   1: 
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5: {
   6:   public static final Namespace OFFICE_NAMESPACE =
   7:   
   8:         ...
   9:   public static final Namespace DUBLIN_CORE_NAMESPACE =
  10:   

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4: public class SQIGateway implements Gateway {
   5:     final String ALL = "all", ANY = "any", PHASE = "phase",

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import ca.edusource.ecl.util.Log;
   4:         ...
   5:     Lom lom = null;
   6:     Namespace ns = null;
   7:     public Metadata(Element md) throws Exception {
   8:         ...
   9: 
  10:     public Element getMetadataElement(Namespace namespace) {
  11:         Element md = new Element("record", namespace);

View Full Code Here
   1: import org.jdom.JDOMException;
   2: import org.jdom.Namespace;
   3: import org.jdom.input.SAXBuilder;
   4:         ...
   5:         
   6:         Namespace davns = Namespace.getNamespace( "DAV:" );
   7:         Element root = new Element("multistatus", davns);
   8:         ...
   9:     {
  10:         Namespace davns = Namespace.getNamespace( "DAV:" );
  11:         

View Full Code Here

getNamespace

public static Namespace getNamespace(String prefix,
                                     String uri)
This will retrieve (if in existence) or create (if not) a Namespace for the supplied prefix and URI.
Parameters:
prefix - String prefix to map to Namespace.
uri - String URI of new Namespace.
Returns:
Namespace - ready to use namespace.
Throws:
IllegalNameException - if the given prefix and uri make up an illegal namespace name.
Usages and Demos :

View More Examples of getNamespace(String prefix,String uri)
   1:         org.jdom.Element root = new org.jdom.Element("mycoreprivilege");
   2:         root.addNamespaceDeclaration(org.jdom.Namespace.getNamespace("xsi", MCRDefaults.XSI_URL));
   3:         ...
   4:         root.addNamespaceDeclaration(org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));
   5:         ...
   6:         root.setAttribute("noNamespaceSchemaLocation", "MCRPrivilege.xsd", org.jdom.Namespace.getNamespace("xsi", MCRDefaults.XSI_URL));

View Full Code Here
   1:             if (el.getAttributeValue("inherited").equals("0")) {
   2:                 String ownerID = el.getAttributeValue("href", org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));
   3:                 if(AI.checkPermission(ownerID,"read")) {
   4:                     String dir = null;
   5:                     sendDerivate(ownerID, dir, out);    

View Full Code Here
   1:                         if (s3 != null) {
   2:                             objid = s3.getAttributeValue("href", org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));
   3:                         }
   4:         ...
   5:         org.jdom.Element root = new org.jdom.Element("mcr_workflow");
   6:         root.addNamespaceDeclaration(org.jdom.Namespace.getNamespace("xsi", MCRDefaults.XSI_URL));
   7:         root.setAttribute("type", type);
   8:         root.setAttribute("step", step);

View Full Code Here
   1: 
   2:         String temp = element.getAttributeValue("type", org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));
   3: 
   4:         ...
   5:         if (linktype.equals("locator")) {
   6:             String temp1 = element.getAttributeValue("href", org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));
   7:         ...
   8:             String temp2 = element.getAttributeValue("label", org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));
   9:         ...
  10:             String temp3 = element.getAttributeValue("title", org.jdom.Namespace.getNamespace("xlink", MCRDefaults.XLINK_URL));

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:     public IEEELom() {
   6:         super(new Element("lom", Namespace.getNamespace(LomUtil.IEEE_NS_URI)));
   7:         ...
   8:         Namespace xsi = Namespace.getNamespace("xsi", LomUtil.XSI_NS_URI);
   9:         lom.addNamespaceDeclaration(xsi);

View Full Code Here

getPrefix

public String getPrefix()
This returns the prefix mapped to this Namespace.
Returns:
String - prefix for this Namespace.
Usages and Demos :

View More Examples of getPrefix()
   1: 
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:   
   6:     public void push(Namespace ns) {
   7:         ...
   8:         prefixes.push(ns.getPrefix());
   9:         uris.push(ns.getURI());

View Full Code Here

getURI

public String getURI()
This returns the namespace URI for this Namespace.
Returns:
String - URI for this Namespace.
Usages and Demos :

View More Examples of getURI()
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:         }
   6:         Namespace ns = xmlElem.getNamespace();
   7:         if (ns != null) {
   8:         ...
   9:             return ns.getURI();
  10:         }
  11:         ...
  12:         if (xmlElem.getName().equals("lom")) {
  13:             ns = Namespace.getNamespace(IMS12_NS_URI);

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import ca.edusource.ecl.util.XmlUtil;
   4:         ...
   5:         }
   6:         Namespace ns = xmlElem.getNamespace();
   7:         if (ns != null) {
   8:         ...
   9:             return ns.getURI();
  10:         }
  11:         ...
  12:         if (xmlElem.getName().equals("lom")) {
  13:             ns = Namespace.getNamespace(IMS12_NS_URI);

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:         if (originalNS == null) {
   6:             throw new Exception("Unable to find matching namespace.");
   7:         }
   8:         ...
   9:     public static String getNamespaceURI(Element xmlElem) {
  10:         Namespace ns = xmlElem.getNamespace();
  11:         if (ns != null) {
  12:         ...
  13:             return ns.getURI();

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: 
   4:         ...
   5:     public static String getNamespaceURI(Element xmlElem) {
   6:         Namespace ns = xmlElem.getNamespace();
   7:         if (ns != null) {
   8:         ...
   9:             return ns.getURI();
  10:         }
  11:         ...
  12:         if (xmlElem.getName().equals("lom")) {
  13:             ns = Namespace.getNamespace(IMS12_NS_URI);

View Full Code Here
   1: import org.jdom.Element;
   2: import org.jdom.Namespace;
   3: import org.jdom.ProcessingInstruction;
   4:         ...
   5:             Element element = ((Document)node).getRootElement(); 
   6:             Namespace ns = element.getNamespace(prefix);
   7:             if (ns != null) {
   8:         ...
   9:                 return ns.getURI();
  10:             }
  11:         ...
  12:             Element element = (Element) node;
  13:             Namespace ns = element.getNamespace(prefix);

View Full Code Here

hashCode

public int hashCode()
This returns a probably unique hash code for the Namespace. If two namespaces have the same URI, they are equal and have the same hash code, even if they have different prefixes.
Overrides:
hashCode in interface Object
Returns:
int - hash code for this Namespace.

toString

public String toString()
This returns a String representation of this Namespace, suitable for use in debugging.
Overrides:
toString in interface Object
Returns:
String - information about this instance.