* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.util.xml;
+package org.opendaylight.netconf.client;
-import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import javax.xml.namespace.NamespaceContext;
// http://www.ibm.com/developerworks/library/x-nmspccontext/
-public class HardcodedNamespaceResolver implements NamespaceContext {
- private final Map<String/* prefix */, String/* namespace */> prefixesToNamespaces;
+final class HardcodedNamespaceResolver implements NamespaceContext {
+ private final Map<String, String> prefixesToNamespaces;
- public HardcodedNamespaceResolver(final String prefix, final String namespace) {
- this(ImmutableMap.of(prefix, namespace));
- }
-
- public HardcodedNamespaceResolver(final Map<String, String> prefixesToNamespaces) {
- this.prefixesToNamespaces = Collections.unmodifiableMap(prefixesToNamespaces);
+ HardcodedNamespaceResolver(final String prefix, final String namespace) {
+ prefixesToNamespaces = Map.of(prefix, namespace);
}
/**
*/
@Override
public String getNamespaceURI(final String prefix) {
- if (prefixesToNamespaces.containsKey(prefix)) {
- return prefixesToNamespaces.get(prefix);
+ final var namespace = prefixesToNamespaces.get(prefix);
+ if (namespace == null) {
+ throw new IllegalStateException("Prefix mapping not found for " + prefix);
}
-
- throw new IllegalStateException("Prefix mapping not found for " + prefix);
+ return namespace;
}
@Override
import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
import org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator;
import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessage;
-import org.opendaylight.netconf.util.xml.XMLNetconfUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.util.xml;
+package org.opendaylight.netconf.client;
import javax.xml.namespace.NamespaceContext;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
-public final class XMLNetconfUtil {
+final class XMLNetconfUtil {
private static final XPathFactory FACTORY = XPathFactory.newInstance();
private static final NamespaceContext NS_CONTEXT = new HardcodedNamespaceResolver("netconf",
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
// Hidden on purpose
}
- public static XPathExpression compileXPath(final String xpath) {
+ static XPathExpression compileXPath(final String xpath) {
final XPath newXPath = FACTORY.newXPath();
newXPath.setNamespaceContext(NS_CONTEXT);
try {
throw new IllegalStateException("Error while compiling xpath expression " + xpath, e);
}
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.util.xml;
+package org.opendaylight.netconf.client;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.util.xml;
+package org.opendaylight.netconf.client;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;