public class BSONNode extends Object
Constructor and Description |
---|
BSONNode(String name)
Creates a node with given "code" name.
|
Modifier and Type | Method and Description |
---|---|
BSONNode |
addChildNode(String name)
Adds a child node to the current node.
|
com.mongodb.DBObject |
asDBObject()
Returns the current BSON structure as DBObject.
|
Map<String,String> |
attributes()
Returns a map containing the attributes of the current node.
|
Iterator<BSONNode> |
children()
Returns an iterator providing access to the child nodes of the current node.
|
static BSONNode |
fromDBObject(com.mongodb.DBObject node)
Constructrs a BSONNode structure from the given DBObject structure.
|
String |
getAttribute(String name)
Returns the value of the attribute with given
name . |
String |
getName()
Returns the name of the current node
|
String |
getValue()
Returns the value of the current node
|
void |
setAttribute(String attributeName,
String attributeValue)
Sets an attribute to this node.
|
void |
setValue(String value)
Sets the value of this node.
|
public BSONNode(String name)
addChildNode(String)
.
Note that the given name
is encoded in a BSON compatible way. That means that periods (".") are
replaced by forward slashes "/", and any slashes are prefixes with additional slash. For example, the String
"some.period/slash" would become "some/period//slash". This is only imporant when querying BSON structures
directly.name
- The name of this nodepublic static BSONNode fromDBObject(com.mongodb.DBObject node)
node
- The root DBObject node containing the BSON Structurepublic com.mongodb.DBObject asDBObject()
public void setValue(String value)
value
- The value to set for this nodepublic void setAttribute(String attributeName, String attributeValue)
attributeName
- The name of the attribute to addattributeValue
- The value of the attributepublic BSONNode addChildNode(String name)
null
and may
not start with "attr_", in order to differentiate between child nodes and attributes.name
- The name of the child nodepublic Iterator<BSONNode> children()
public Map<String,String> attributes()
public String getAttribute(String name)
name
.name
- The name of the attribute to get the value fornull
if the attribute was not foundpublic String getValue()
null
if this node has no value.public String getName()
Copyright © 2010–2018. All rights reserved.