public class MaapiSchemas extends Object
Handles the schema information from the data models loaded.
It holds a offline tree structure where a node represents a instance ofMaapiSchemas.CSNode
and it is connected through
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 for MaapiSchemas
and stored
in its offline tree hierarchy.
These inner classes has methods to retrieve all information about the entity.
Note that this class is selfcontained in the sense that it does not use any locally compiled schemas i.e. ConfNamespace classes.
There exists has methods for converting between hashes and strings
stringToHash(String)
and hashToString(long)
Example:
// Setup socket to server Socket s = new Socket("localhost", Conf.PORT); // Start MAAPI session for admin user, originating from localhost Maapi maapi = new Maapi(s); // get Maapi schema object //MaapiSchemas are ex 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 | Class and Description |
---|---|
class |
MaapiSchemas.BitsTypeMethodsImpl |
class |
MaapiSchemas.CSBit |
class |
MaapiSchemas.CSCase
Class representing a Case for a Choice
|
class |
MaapiSchemas.CSChoice
Class representing a Schema Choice
|
class |
MaapiSchemas.CSEnum |
class |
MaapiSchemas.CSIdref |
class |
MaapiSchemas.CSNamedType
Class representing a named type.
|
class |
MaapiSchemas.CSNode
Class representing a Schema node, having references to parent and
children as well as siblings
|
class |
MaapiSchemas.CSNodeInfo
Class representing node information for a Schema node
|
class |
MaapiSchemas.CSSchema
The Schema Container class.
|
static class |
MaapiSchemas.CSShallowType
Enum containing all possible node values.
|
class |
MaapiSchemas.CSStringLength |
class |
MaapiSchemas.CSStringRestriction |
class |
MaapiSchemas.CSType
Class representing a type
|
class |
MaapiSchemas.CSTypeBits |
class |
MaapiSchemas.CSTypeMethods
Class which contains type specific conversion and validation
methods Has
to be extended for aggregated and user types.
|
class |
MaapiSchemas.CSTypeRange |
class |
MaapiSchemas.Decimal64TypeMethodsImpl |
class |
MaapiSchemas.EnumTypeMethodsImpl |
class |
MaapiSchemas.IdentityTypeMethodsImpl |
class |
MaapiSchemas.ListRestrictionTypeMethodsImpl |
class |
MaapiSchemas.ListTypeMethodsImpl |
class |
MaapiSchemas.RetrictedNumberTypeMethodsImpl |
class |
MaapiSchemas.StringTypeMethodsImpl |
class |
MaapiSchemas.UnionTypeMethodsImpl |
Modifier and Type | Method and Description |
---|---|
MaapiSchemas.CSNode |
findCSNode(MaapiSchemas.CSNode parent,
long xmltagNShash,
long xmltaghash)
Find and retrieves specific node in the schema information tree.
|
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(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(String nsName,
String fmt,
Object... arguments)
Find and retrieves specific node in the schema information tree.
|
MaapiSchemas.CSNode |
findCSRoot(long nshash)
Retrieve a specific root node identified by an hash value
|
MaapiSchemas.CSNode |
findCSRoot(String nsName)
Retrieve a specific root node identified by an namespace string
|
MaapiSchemas.CSSchema |
findCSSchema(long nshash)
Retrieve a specified schema identified by an hash value
|
MaapiSchemas.CSSchema |
findCSSchema(String nsName)
Retrieve a specific schema identified by an namespace string
|
MaapiSchemas.CSSchema |
findCSSchemaByPrefix(String prefix) |
MaapiSchemas.CSSchema |
findCSSchemaFromUniqueRoot(long rootHash)
Returns schema for root node.
|
MaapiSchemas.CSSchema |
findCSSchemaFromUniqueRoot(String rootTagName)
Returns schema for root node.
|
Collection<MaapiSchemas.CSSchema> |
getLoadedSchemas()
get all loaded schemas as a Collection of CSSchema objects
|
String |
hashToString(long tagHash)
Convert from hash value to String value for a specified tag.
|
long |
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 MaapiSchemas.CSNode findCSNode(MaapiSchemas.CSNode parent, long xmltagNShash, long 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, String xmltagNSName, String xmltagName)
parent
- parent nodexmltagNSName
- xmltagName
- public MaapiSchemas.CSNode findCSNode(String nsName, List<com.tailf.conf.gen.PathParser.PathElement> pl) throws MaapiException
nsName
- pl
- MaapiException
public MaapiSchemas.CSNode findCSNode(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).
nsName
- namespace string that appears in a yang model.fmt
- keypath or tagpath that leads to the nodearguments
- for % substitution in fmtMaapiException
public MaapiSchemas.CSNode findCSRoot(long nshash)
nshash
- long hash value representing the root nodepublic MaapiSchemas.CSNode findCSRoot(String nsName)
nsName
- a string contain the full namespace namepublic MaapiSchemas.CSSchema findCSSchema(long nshash)
nshash
- long hash value representing the namespacepublic MaapiSchemas.CSSchema findCSSchema(String nsName)
nsName
- a string contain the full namespace namepublic MaapiSchemas.CSSchema findCSSchemaByPrefix(String prefix)
public MaapiSchemas.CSSchema findCSSchemaFromUniqueRoot(long rootHash)
rootHash
- hash for root nodepublic MaapiSchemas.CSSchema findCSSchemaFromUniqueRoot(String rootTagName)
rootTagName
- root tagname as stringpublic Collection<MaapiSchemas.CSSchema> getLoadedSchemas()
public String hashToString(long tagHash)
tagHash
- hash value for tagpublic long stringToHash(String tagString)
tagString
- 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
- - ConfValue