/* * Decompiled with CFR 0.152. */ package com.tridium.util; import java.util.Stack; import javax.baja.sys.Action; import javax.baja.sys.BComponent; import javax.baja.sys.BObject; import javax.baja.sys.Context; import javax.baja.sys.CursorException; import javax.baja.sys.Property; import javax.baja.sys.Slot; import javax.baja.sys.SlotCursor; import javax.baja.sys.Topic; import javax.baja.sys.Type; /* * Illegal identifiers - consider using --renameillegalidents true */ public class ComponentTreeCursor implements SlotCursor { public static final int ALL = Integer.MAX_VALUE; private boolean init; private boolean atRoot; private BComponent root; private int depth; private Type[] leafTypes; private SlotCursor current; private int currentDepth; private Stack nodeStack; private Context context; public Context getContext() { return this.context; } public BComponent root() { return this.root; } public void reset() { this.init = true; this.atRoot = false; this.current = null; this.currentDepth = 0; this.nodeStack = null; } public BObject target() { return this.current.target(); } public boolean isLeafType(Type type) { if (this.leafTypes == null) { return false; } int n = 0; while (n < this.leafTypes.length) { if (type.is(this.leafTypes[n])) { return true; } ++n; } return false; } public boolean isLeafType(BObject bObject) { if (this.leafTypes == null) { return false; } return this.isLeafType(bObject.getType()); } /* * Unable to fully structure code */ public boolean next() { if (this.root == null) { return false; } if (this.init) { this.atRoot = true; this.init = false; return true; } if (this.atRoot && this.depth == 0) { return false; } if (this.atRoot) { this.atRoot = false; this.current = this.root.getProperties(); return this.current.nextComponent(); } var1_1 = null; var2_2 = null; var3_3 = false; v0 = false; if (this.currentDepth + 1 < this.depth && !this.isLeafType(this.current.target())) { v0 = true; } if ((var4_4 = v0) && (var2_2 = (var1_1 = (BComponent)this.current.get()).getProperties()).nextComponent()) { var3_3 = true; } if (!var3_3) ** GOTO lbl33 ++this.currentDepth; if (this.nodeStack == null) { this.nodeStack = new Stack(); } this.nodeStack.push(this.current); this.current = var2_2; return true; lbl-1000: // 1 sources { if (this.nodeStack == null || this.nodeStack.empty()) { return false; } this.current = (SlotCursor)this.nodeStack.pop(); --this.currentDepth; lbl33: // 2 sources ** while (!this.current.nextComponent()) } lbl34: // 1 sources return true; } public boolean nextObject() { return this.nextComponent(); } public boolean nextComponent() { return this.next(); } public boolean next(Class clazz) { while (this.next()) { BObject bObject = this.get(); if (!clazz.isInstance(bObject)) continue; return true; } return false; } public Slot slot() { return this.current.slot(); } public Property property() { return this.current.property(); } public int getTypeAccess() { return this.current.getTypeAccess(); } public BObject get() { if (this.atRoot) { return this.root; } return this.current.get(); } public boolean getBoolean() { throw new ClassCastException(); } public int getInt() { throw new ClassCastException(); } public long getLong() { throw new ClassCastException(); } public float getFloat() { throw new ClassCastException(); } public double getDouble() { throw new ClassCastException(); } public String getString() { throw new ClassCastException(); } public Action action() { throw new CursorException("not action"); } public Topic topic() { throw new CursorException("not topic"); } private final /* synthetic */ void this() { this.init = true; this.atRoot = false; this.currentDepth = 0; } public ComponentTreeCursor(BComponent bComponent, Context context) { this(bComponent, Integer.MAX_VALUE, context); } public ComponentTreeCursor(BComponent bComponent, int n, Context context) { this.this(); this.root = bComponent; this.depth = n; this.context = context; } public ComponentTreeCursor(BComponent bComponent, Type type, Context context) { this(bComponent, new Type[]{type}, context); } public ComponentTreeCursor(BComponent bComponent, Type[] typeArray, Context context) { this.this(); this.root = bComponent; this.depth = Integer.MAX_VALUE; this.leafTypes = typeArray; this.context = context; } }