Package org.opensaml.core.xml

# Class Namespace

java.lang.Object
org.opensaml.core.xml.Namespace

public class Namespace extends Object
Data structure for representing XML namespace attributes.

## Field Summary

Fields
Modifier and Type
Field
Description
`private String`
`namespacePrefix`
Prefix of the namespace.
`private String`
`namespaceURI`
URI of the namespace.
`private String`
`nsStr`
String representation of this namespace.

## Constructor Summary

Constructors
Constructor
Description
`Namespace(String uri, String prefix)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`constructStringRepresentation()`
Constructs an XML namespace declaration string representing this namespace.
`String`
`ensureNamespaceURI()`
Get the URI of the namespace, raising an `IllegalStateException` if null.
`boolean`
`equals(Object obj)`
Checks if the given object is the same as this Namespace.
`String`
`getNamespacePrefix()`
Gets the prefix of the namespace.
`String`
`getNamespaceURI()`
Gets the URI of the namespace.
`int`
`hashCode()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### namespaceURI

@Nullable private String namespaceURI
URI of the namespace.

### namespacePrefix

@Nullable private String namespacePrefix
Prefix of the namespace.

### nsStr

@Nullable private String nsStr
String representation of this namespace.

## Constructor Details

### Namespace

public Namespace(@Nullable String uri, @Nullable String prefix)
Constructor.

Parameters:
  `uri` - the URI of the namespace
  `prefix` - the prefix of the namespace

## Method Details

### getNamespacePrefix

@Nullable public String getNamespacePrefix()
Gets the prefix of the namespace.

Returns:
  the prefix of the namespace, may be null if this is a default namespace

### getNamespaceURI

@Nullable public String getNamespaceURI()
Gets the URI of the namespace.

Returns:
  the URI of the namespace

### ensureNamespaceURI

@Nonnull public String ensureNamespaceURI()
Get the URI of the namespace, raising an `IllegalStateException` if null.

Returns:
  namespace URI
Since:
  5.0.0

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)
Checks if the given object is the same as this Namespace. This is true if:

- The given object is of type `Namespace`
- The given object's namespace URI is the same as this object's namespace URI
- The given object's namespace prefix is the same as this object's namespace prefix

Overrides:
  `equals` in class `Object`
Parameters:
  `obj` -
Returns:

### constructStringRepresentation

protected void constructStringRepresentation()
Constructs an XML namespace declaration string representing this namespace.