| 1 |
package ezvcard.io.xml; |
| 2 |
|
| 3 |
import java.util.Collections; |
| 4 |
import java.util.Iterator; |
| 5 |
|
| 6 |
import javax.xml.namespace.NamespaceContext; |
| 7 |
import javax.xml.xpath.XPath; |
| 8 |
|
| 9 |
import ezvcard.VCardVersion; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
public class XCardNamespaceContext implements NamespaceContext { |
| 17 |
private final String ns; |
| 18 |
private final String prefix; |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
public XCardNamespaceContext(VCardVersion version, String prefix) { |
| 25 |
this.ns = version.getXmlNamespace(); |
| 26 |
this.prefix = prefix; |
| 27 |
} |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public String getPrefix() { |
| 34 |
return prefix; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
public String getNamespaceURI(String prefix) { |
| 39 |
if (this.prefix.equals(prefix)) { |
| 40 |
return ns; |
| 41 |
} |
| 42 |
return null; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
public String getPrefix(String ns) { |
| 47 |
if (this.ns.equals(ns)) { |
| 48 |
return prefix; |
| 49 |
} |
| 50 |
return null; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
public Iterator<String> getPrefixes(String ns) { |
| 55 |
if (this.ns.equals(ns)) { |
| 56 |
return Collections.singletonList(prefix).iterator(); |
| 57 |
} |
| 58 |
return null; |
| 59 |
} |
| 60 |
} |