Skip to main content

Browse

browse(String nodeId, Enums.NodeClass filter) — Lists the direct child nodes (first level) of the specified node.

Prerequisite Reading / Supplementary Materials

Signature​

public List<Reference> browse(String nodeId);
public List<Reference> browse(String nodeId, Enums.NodeClass filter);

public List<List<Reference>> browseMany(List<String> nodeIds, Enums.NodeClass filter);

"Reference" Field​

MethodsReturnNote
getNodeId()StringChild node NodeId
getBrowseName()StringView Name (including NamespaceIndex prefix, e.g., 2:Temperature)
getDisplayName()StringDisplay Name
getNodeClass()Enums.NodeClassChild Node Categories
toNode(OpcUaSession)OpcUaNodeConvert to actionable OpcUaNode

Examples​

// List all child nodes Boiler1 under this node
List<Reference> children = ua.browse("ns=2;s=Boiler1");
for (Reference c : children) {
System.out.printf(" %s %s -> %s%n",
c.getNodeClass(), c.getBrowseName(), c.getNodeId());
}

// Show only Variable types
List<Reference> vars = ua.browse("ns=2;s=Boiler1", Enums.NodeClass.Variable);

// View Only Method
List<Reference> methods = ua.browse("ns=2;s=Calculator", Enums.NodeClass.Method);

Batch View (browseMany)​

If you want to view multiple nodes at the same time (for example, when expanding the tree for the first GUI time), do it in one browseMany go RPC:

List<String> roots = Arrays.asList(
"i=85" /* Objects */,
"i=86" /* Types */);
List<List<Reference>> results = ua.browseMany(roots, Enums.NodeClass.Unspecified);
for (int i = 0; i < roots.size(); i++) {
System.out.println(roots.get(i) + ":");
for (Reference c : results.get(i)) {
System.out.println(" " + c.getBrowseName());
}
}

If a node fails to be browsed (NodeId error), the corresponding slot returns an empty list, Do not throw exceptions.

NodeClass filter​

ValueIncludes
Unspecified (0)All
Object (1)Object Only
Variable (2)Variable Only
Method (4)Method Only

Java does not support bitwise OR operations on enums. To achieve an "Object + Variable" combination, perform the operations in two separate steps and browse then merge the results, or use a loop to filter the results.

Exception​

OpcUaException(BadNodeIdUnknown) / OpcUaException(BadCommunicationError) etc. A transport failure triggers an exception; a failure in a single child node does not.

Pagination for Large Nodes (ContinuationPoint)​

The number of references browse returned in a single request is determined by the server; if the limit set by the server is exceeded, the response will be truncated. When truncated, browse only the first page is returned, and subsequent pages are discarded.

To view the entire content, use browseWithPaging + browseNext, or simply browseAll:

List<Reference> all = ua.browseAll("ns=2;s=BigFolder");  // Automatic Pagination
System.out.println("Total " + all.size() + " children");

Performance​

  • Single request browse: One round trip over the network + server-side processing; the time taken varies depending on the network and server, so test it in your actual environment.
  • browseMany Batch: Total time ~ Single run (saves N-1 round trips)
  • If the number of child nodes exceeds the server's limit for a single response, the results will be paginated; use browseAll or do it manually. browseNext

browseFiltered — Direction + Reference Type Filter (parameter exists, currently inactive)​

The signature of browseFiltered adds four parameters on top of browse — BrowseDirection + referenceTypeId + includeSubtypes + resultMask (Part 4 §5.8.2.2) — but none of these four parameters are currently active: see “Behavior Description” below. Only nodeClassFilter actually takes effect.

public List<Reference> browseFiltered(
String nid,
Enums.NodeClass nodeClassFilter,
BrowseDirection direction, // Currently discarded
String referenceTypeId, // Currently discarded
boolean includeSubtypes, // Currently discarded
int resultMask); // Currently discarded

Related Structures:

public enum BrowseDirection {
FORWARD, // Forward-only, parent→child
INVERSE, // Reverse only: child → parent
BOTH // Returns results in both directions
}
I can't get reverse references (who links to me) right now.

Requests are always forward (browseDirection is fixed to Forward). In the example below, / INVERSE BOTH Will not change the return result —— It appears that we still only get INVERSE the direct child nodes, not the parent node. To find the parent node, we can only work our way down from a known parent node browse.

Example​

// 1) Filter NodeClass by only — this is the only dimension that actually works
List<Reference> children = ua.browseFiltered("ns=2;s=Boiler1",
Enums.NodeClass.Variable, BrowseDirection.FORWARD, "i=33", true, 0x3F);

// 2) The following three parameters are currently inactive; they are placeholders only. Do not use them to evaluate results.
List<Reference> sameAsAbove = ua.browseFiltered("ns=2;s=Tank.Level",
Enums.NodeClass.Unspecified, BrowseDirection.INVERSE, null, true, 0x3F);
// ↑ The function also does not INVERSE return the parent node; the result is still a direct child Tank.Level of .

If you really need to filter by direction or reference type, retrieve the full dataset and Reference then filter it yourself on the client side.

Behavior Description​

  • Returns a result equivalent to browse(nid, classFilter), Only NodeClass the filter is active
  • direction / refTypeId / includeSubtypes / resultMask Four parameters wereDiscard immediately, Do not include in the results filter
  • direction Constantly Forward, referenceTypeId Constantly all reference types (References i=31, including subtypes), resultMask Constantly all fields 0x3F
  • Each time it is called Make a note of this Debug Level diagnostic event (category Browse), making it easy to identify such calls from the event channel; does not throw an exception
  • The behavior is consistent across other languages in the same context (C# BrowseFiltered, Python, and browse_filtered Rust all exhibit the same browse_filtered degradation), with only slight differences in the severity and frequency of diagnostic events.

Next Step​