
com.tailf.jnc.SchemaTree Maven / Gradle / Ivy
The newest version!
package com.tailf.jnc;
import java.util.HashMap;
import java.util.Set;
/**
* The SchemaTree class is used to represent the schemas of all namespaces
*/
public class SchemaTree {
private static HashMap> namespaces = new HashMap>();
/**
* If no hashmap exists for namespace, it is created. Used by generated
* code to populate new hashmaps for YANG modules.
*
* @param namespace The namespace of the module as a String.
* @return The HashMap associated with namespace.
*/
public static HashMap create(String namespace) {
if (namespaces.containsKey(namespace)) {
return namespaces.get(namespace);
}
final HashMap h = new HashMap();
namespaces.put(namespace, h);
return h;
}
/**
* @param namespace A YANG module namespace as a String
* @return The HashMap associated with namespace, or null.
*/
public static HashMap getHashMap(String namespace) {
return namespaces.get(namespace);
}
/**
* @return The set of all namespaces for which there currently is a HashMap
* of TagPath/SchemaNode key/value pairs.
*/
public static Set getLoadedNamespaces() {
return namespaces.keySet();
}
/**
* Searches for a SchemaNode given a namespace and a Tagpath.
*
* @param namespace The namespace of the module.
* @param tp The TagPath of the node to search for.
* @return The SchemaNode with Tagpath tp in module with specified
* namespace, or null if not found.
*/
public static SchemaNode lookup(String namespace, Tagpath tp) {
final HashMap t = getHashMap(namespace);
return t == null ? null : t.get(tp);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy