Class MaapiSchemas
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
findCSNode(String,String,Object...)
,
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:
stringToHash(String)
and 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); } } }
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
class
Class representing a Case for a Choiceclass
Class representing a Schema Choiceclass
class
class
class
Class representing a named type.class
Class representing a Schema node, having references to parent and children as well as siblingsclass
Class representing node information for a Schema nodeclass
The Schema Container class.static enum
Enum containing all possible node values.class
class
class
Class representing a typeclass
class
Class which contains type specific conversion and validation methods Has to be extended for aggregated and user types.class
class
class
class
class
class
class
class
class
class
class
class
-
Method Summary
Modifier and TypeMethodDescriptionvoid
convertMountId
(ConfEObject eObj) int
findCSMNsMap
(List<String> mountId) findCSNode
(MountIdInterface mountGetter, String nsName, String fmt, Object... arguments) Find and retrieves specific node in the schema information tree.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 formatfindCSNode
(MaapiSchemas.CSNode parent, int xmltagNShash, int xmltaghash) Find and retrieves specific node in the schema information tree.findCSNode
(MaapiSchemas.CSNode parent, long xmltagNShash, long xmltaghash) Deprecated.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 tagnamefindCSNode
(MaapiSchemas.CSNode parent, String xmltagNSName, String xmltagName) Retrieve a specific node with a given parent node identified by xmltag namespace and tagnamefindCSNode
(String nsName, String fmt, Object... arguments) findCSRoot
(int nshash) Retrieve a specific root node identified by an hash valuefindCSRoot
(long nshash) Deprecated.findCSRoot
(String nsName) Retrieve a specific root node identified by an namespace stringfindCSSchema
(int nshash) Retrieve a specified schema identified by an hash valuefindCSSchema
(long nshash) Deprecated.findCSSchema
(String nsName) Retrieve a specific schema identified by an namespace stringfindCSSchemaByPrefix
(String prefix) findCSSchemaFromUniqueRoot
(int rootHash) Returns schema for root node.findCSSchemaFromUniqueRoot
(long rootHash) Deprecated.findCSSchemaFromUniqueRoot
(String rootTagName) Returns schema for root node.get all loaded schemas as a Collection of CSSchema objectsgetMountId
(MountIdInterface midif, ConfPath path) hashToString
(int tagHash) Convert from hash value to String value for a specified tag.hashToString
(long tagHash) Deprecated.void
static void
setThreadDefaultMountId
(List<String> mountId) int
stringToHash
(String tagString) Convert from String value to hash value for a specified tag.stringToValue
(MaapiSchemas.CSType type, String str) parse value located in str and convert to ConfValue, the value is validated.toString()
valueToString
(MaapiSchemas.CSType type, ConfValue val) convert to string representation for the corresponding ConfValue
-
Method Details
-
getLoadedSchemas
get all loaded schemas as a Collection of CSSchema objects- Returns:
- Collection of CSSchema objects
-
getLoadedMNsMaps
-
getRootMountId
-
findCSMNsMap
-
findCSSchema
Retrieve a specified schema identified by an hash value- Parameters:
nshash
- integer hash value representing the namespace- Returns:
- CSSchemaobject for the identified Namespace of null if not found
-
findCSSchema
Deprecated.UsefindCSSchema(int)
instead. -
findCSSchema
Retrieve a specific schema identified by an namespace string- Parameters:
nsName
- a string contain the full namespace name- Returns:
- CSSchema object for the identified namespace or null if not found.
-
findCSSchemaByPrefix
-
findCSSchemaFromUniqueRoot
Returns schema for root node. This requires the root node to be unique in all known schemas. Otherwise null is returned.- Parameters:
rootTagName
- root tagname as string- Returns:
- CSSchema the schema having the tag as root
-
findCSSchemaFromUniqueRoot
Returns schema for root node. This requires the root node to be unique in all known schemas. Otherwise null is returned.- Parameters:
rootHash
- hash for root node- Returns:
- CSSchema the schema having the tag as root
-
findCSSchemaFromUniqueRoot
Deprecated.UsefindCSSchemaFromUniqueRoot(int)
instead. -
findCSRoot
Retrieve a specific root node identified by an hash value- Parameters:
nshash
- integer hash value representing the root node- Returns:
- CSNode root node or null if not found
-
findCSRoot
Deprecated.UsefindCSRoot(int)
instead. -
findCSRoot
Retrieve a specific root node identified by an namespace string- Parameters:
nsName
- a string contain the full namespace name- Returns:
- CSNode root node or null if not found
-
findCSNode
public 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- Parameters:
parent
- parent nodexmltagNSName
-xmltagName
-- Returns:
- CSNode or null if not found
-
findCSNode
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 hash- Parameters:
parent
- parent nodexmltagNShash
- namespace hash valuexmltaghash
- tag hash which value- Returns:
- CSNode or null if not found
-
findCSNode
public 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- Parameters:
parent
- parent nodemnsMap
-xmltagName
-- Returns:
- CSNode or null if not found
-
findCSNode
@Deprecated public MaapiSchemas.CSNode findCSNode(MaapiSchemas.CSNode parent, long xmltagNShash, long xmltaghash) Deprecated.UsefindCSNode(CSNode, int, int)
instead -
findCSNode
public MaapiSchemas.CSNode findCSNode(String nsName, String fmt, Object... arguments) throws MaapiException - Throws:
MaapiException
-
findCSNode
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).- Parameters:
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 fmt- Returns:
- MaapiSchemas.CSNode the node identified by the path or null if not found
- Throws:
MaapiException
-
findCSNode
public MaapiSchemas.CSNode findCSNode(MountIdInterface mountGetter, String nsName, List<com.tailf.conf.gen.PathParser.PathElement> pl) throws MaapiException Internally used method to find a node defined by an internal path format- Parameters:
mountGetter
- if such exists or else nullnsName
-pl
-- Returns:
- CSNode the found schema node or null if not found
- Throws:
MaapiException
-
stringToHash
Convert from String value to hash value for a specified tag.- Parameters:
tagString
-- Returns:
- integer hash value or zero if not found.
-
hashToString
Convert from hash value to String value for a specified tag.- Parameters:
tagHash
- hash value for tag- Returns:
- String value or null if not found
-
hashToString
Deprecated.UsehashToString(int)
instead. -
stringToValue
parse value located in str and convert to ConfValue, the value is validated.- Parameters:
type
- - type for the converted valuestr
- - string representation of the value- Returns:
- ConfValue for the corresponding type
- Throws:
MaapiException
-
valueToString
convert to string representation for the corresponding ConfValue- Parameters:
type
- - type for the converted valueval
- - ConfValue- Returns:
- String representation of the value
-
convertMountId
-
setThreadDefaultMountId
-
getThreadDefaultMountId
-
getMountId
public List<String> getMountId(MountIdInterface midif, ConfPath path) throws IOException, ConfException - Throws:
IOException
ConfException
-
toString
-
clearMountIdCache
public void clearMountIdCache() -
removeMountIdCachePath
-
currentMountIdCacheSize
public int currentMountIdCacheSize()
-