public class MaapiSchemas extends Object
Handles the schema information from the data models loaded.
It holds an offline tree structure where each node is represented by an
instance of MaapiSchemas.CSNode
which in turn contains connections
to other nodes.
Methods exist to retrieve a specified schema MaapiSchemas.CSSchema
or a specified schema node
MaapiSchemas.findCSNode(String,String,Object...)
,
MaapiSchemas.findCSNode(MaapiSchemas.CSNode,String,String)
.
All entities, including Schemas, Nodes, Types, Choices etc are
represented as inner classes of MaapiSchemas
and are stored
in its offline tree hierarchy.
These inner classes have methods to retrieve all information about the entity.
Note that this class is self-contained in the sense that it does not use any locally compiled schemas i.e. ConfNamespace classes.
There are methods for converting between hashes and strings:
MaapiSchemas.stringToHash(String)
and MaapiSchemas.hashToString(long)
Example:
// int port = Conf.PORT for ConfD or Conf.NCS_PORT for NCS // Setup socket to server Socket s = new Socket("localhost", port); // Start MAAPI session for admin user, originating from localhost Maapi maapi = new Maapi(s); s.close(); Iterator<MaapiSchemas.CSSchema> iter = Maapi.getSchemas().getLoadedSchemas().iterator(); while (iter.hasNext()) { MaapiSchemas.CSSchema sch = iter.next(); System.out.println(sch); System.out.println("--- Named Types ---"); Enumeration<MaapiSchemas.CSNamedType> typenum = sch.getNamedTypes().elements(); while (typenum.hasMoreElements()) { MaapiSchemas.CSNamedType namedType = typenum.nextElement(); System.out.println(namedType); } MaapiSchemas.CSNode root = sch.getRootNode(); System.out.println("--- Root Node ---"); System.out.println(root); if (root != null) { System.out.println("--- Node Tree ---"); Iterator<MaapiSchemas.CSNode> iter2 = root.getSiblings().iterator(); int offset = 0; while (iter2.hasNext()) { MaapiSchemas.CSNode n = iter2.next(); System.out.print(n.getTag()); MaapiSchemasUtil.printNodeInfo(offset, n); MaapiSchemasUtil.printChildren(offset, n); } } }
Modifier and Type | Method and Description |
---|---|
void |
clearMountIdCache() |
String |
convertMountId(ConfEObject eObj) |
int |
currentMountIdCacheSize() |
MaapiSchemas.CSMNsMap |
findCSMNsMap(List<String> mountId) |
MaapiSchemas.CSNode |
findCSNode(MaapiSchemas.CSNode parent,
int xmltagNShash,
int xmltaghash)
Find and retrieves specific node in the schema information tree.
|
MaapiSchemas.CSNode |
findCSNode(MaapiSchemas.CSNode parent,
long xmltagNShash,
long xmltaghash)
Deprecated.
|
MaapiSchemas.CSNode |
findCSNode(MaapiSchemas.CSNode parent,
MaapiSchemas.CSMNsMap mnsMap,
String xmltagName)
Retrieve a specific node with a given parent node identified by xmltag
all namespaces in a mnsmap and tagname
|
MaapiSchemas.CSNode |
findCSNode(MaapiSchemas.CSNode parent,
String xmltagNSName,
String xmltagName)
Retrieve a specific node with a given parent node identified by xmltag
namespace and tagname
|
MaapiSchemas.CSNode |
findCSNode(MountIdInterface mountGetter,
String nsName,
List<com.tailf.conf.gen.PathParser.PathElement> pl)
Internally used method to find a node defined by an internal path format
|
MaapiSchemas.CSNode |
findCSNode(MountIdInterface mountGetter,
String nsName,
String fmt,
Object... arguments)
Find and retrieves specific node in the schema information tree.
|
MaapiSchemas.CSNode |
findCSNode(String nsName,
String fmt,
Object... arguments) |
MaapiSchemas.CSNode |
findCSRoot(int nshash)
Retrieve a specific root node identified by an hash value
|
MaapiSchemas.CSNode |
findCSRoot(long nshash)
Deprecated.
|
MaapiSchemas.CSNode |
findCSRoot(String nsName)
Retrieve a specific root node identified by an namespace string
|
MaapiSchemas.CSSchema |
findCSSchema(int nshash)
Retrieve a specified schema identified by an hash value
|
MaapiSchemas.CSSchema |
findCSSchema(long nshash)
Deprecated.
|
MaapiSchemas.CSSchema |
findCSSchema(String nsName)
Retrieve a specific schema identified by an namespace string
|
MaapiSchemas.CSSchema |
findCSSchemaByPrefix(String prefix) |
MaapiSchemas.CSSchema |
findCSSchemaFromUniqueRoot(int rootHash)
Returns schema for root node.
|
MaapiSchemas.CSSchema |
findCSSchemaFromUniqueRoot(long rootHash)
Deprecated.
|
MaapiSchemas.CSSchema |
findCSSchemaFromUniqueRoot(String rootTagName)
Returns schema for root node.
|
Collection<MaapiSchemas.CSMNsMap> |
getLoadedMNsMaps() |
Collection<MaapiSchemas.CSSchema> |
getLoadedSchemas()
get all loaded schemas as a Collection of CSSchema objects
|
List<String> |
getMountId(MountIdInterface midif,
ConfPath path) |
static List<String> |
getRootMountId() |
static List<String> |
getThreadDefaultMountId() |
String |
hashToString(int tagHash)
Convert from hash value to String value for a specified tag.
|
String |
hashToString(long tagHash)
Deprecated.
|
void |
removeMountIdCachePath(ConfPath path) |
static void |
setThreadDefaultMountId(List<String> mountId) |
int |
stringToHash(String tagString)
Convert from String value to hash value for a specified tag.
|
ConfValue |
stringToValue(MaapiSchemas.CSType type,
String str)
parse value located in str and convert to ConfValue, the value is
validated.
|
String |
toString() |
String |
valueToString(MaapiSchemas.CSType type,
ConfValue val)
convert to string representation for the corresponding ConfValue
|
public Collection<MaapiSchemas.CSSchema> getLoadedSchemas()
public Collection<MaapiSchemas.CSMNsMap> getLoadedMNsMaps()
public MaapiSchemas.CSMNsMap findCSMNsMap(List<String> mountId)
public MaapiSchemas.CSSchema findCSSchema(int nshash)
nshash
- integer hash value representing the namespace@Deprecated public MaapiSchemas.CSSchema findCSSchema(long nshash)
MaapiSchemas.findCSSchema(int)
instead.public MaapiSchemas.CSSchema findCSSchema(String nsName)
nsName
- a string contain the full namespace namepublic MaapiSchemas.CSSchema findCSSchemaByPrefix(String prefix)
public MaapiSchemas.CSSchema findCSSchemaFromUniqueRoot(String rootTagName)
rootTagName
- root tagname as stringpublic MaapiSchemas.CSSchema findCSSchemaFromUniqueRoot(int rootHash)
rootHash
- hash for root node@Deprecated public MaapiSchemas.CSSchema findCSSchemaFromUniqueRoot(long rootHash)
MaapiSchemas.findCSSchemaFromUniqueRoot(int)
instead.public MaapiSchemas.CSNode findCSRoot(int nshash)
nshash
- integer hash value representing the root node@Deprecated public MaapiSchemas.CSNode findCSRoot(long nshash)
MaapiSchemas.findCSRoot(int)
instead.public MaapiSchemas.CSNode findCSRoot(String nsName)
nsName
- a string contain the full namespace namepublic MaapiSchemas.CSNode findCSNode(MaapiSchemas.CSNode parent, String xmltagNSName, String xmltagName)
parent
- parent nodexmltagNSName
- xmltagName
- public MaapiSchemas.CSNode findCSNode(MaapiSchemas.CSNode parent, int xmltagNShash, int xmltaghash)
Find and retrieves specific node in the schema information tree.
Retrieve a specific node with a given parent node identified by xmltag namespace hash and tagname hashparent
- parent nodexmltagNShash
- namespace hash valuexmltaghash
- tag hash which valuepublic MaapiSchemas.CSNode findCSNode(MaapiSchemas.CSNode parent, MaapiSchemas.CSMNsMap mnsMap, String xmltagName)
parent
- parent nodemnsMap
- xmltagName
- @Deprecated public MaapiSchemas.CSNode findCSNode(MaapiSchemas.CSNode parent, long xmltagNShash, long xmltaghash)
MaapiSchemas.findCSNode(CSNode, int, int)
insteadpublic MaapiSchemas.CSNode findCSNode(String nsName, String fmt, Object... arguments) throws MaapiException
MaapiException
public MaapiSchemas.CSNode findCSNode(MountIdInterface mountGetter, String nsName, String fmt, Object... arguments) throws MaapiException
Find and retrieves specific node in the schema information tree.
Get a node identified by an namespace string which is the string that appears in the yang models namespace statement.
If a yang model extends another yang model, through the augment statement then then the namespace string should be the string present in the the top yang model, (the yang model which contains the augment statement).
The fmt
is either a keypath or tagpath (path not
containing keys).
mountGetter
- if such exists or else nullnsName
- namespace string that appears in a yang model.fmt
- keypath or tagpath that leads to the nodearguments
- for % substitution in fmtMaapiException
public MaapiSchemas.CSNode findCSNode(MountIdInterface mountGetter, String nsName, List<com.tailf.conf.gen.PathParser.PathElement> pl) throws MaapiException
mountGetter
- if such exists or else nullnsName
- pl
- MaapiException
public int stringToHash(String tagString)
tagString
- public String hashToString(int tagHash)
tagHash
- hash value for tag@Deprecated public String hashToString(long tagHash)
MaapiSchemas.hashToString(int)
instead.public ConfValue stringToValue(MaapiSchemas.CSType type, String str) throws MaapiException
type
- - type for the converted valuestr
- - string representation of the valueMaapiException
public String valueToString(MaapiSchemas.CSType type, ConfValue val)
type
- - type for the converted valueval
- - ConfValuepublic String convertMountId(ConfEObject eObj)
public List<String> getMountId(MountIdInterface midif, ConfPath path) throws IOException, ConfException
IOException
ConfException
public void clearMountIdCache()
public void removeMountIdCachePath(ConfPath path)
public int currentMountIdCacheSize()