00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 package gov.lanl.isr.sensix.discovery;
00036
00037 import gov.lanl.isr.sensix.*;
00038
00039
00040 public class OthersImpl extends _OthersStub
00041 {
00042 private AncestorsImpl parents;
00043 private SiblingsImpl sisters;
00044 private DescendantsImpl children;
00045
00046
00047 public OthersImpl(DiscoveryService ds) {
00048 parents = new AncestorsImpl(ds);
00049 sisters = new SiblingsImpl(ds);
00050 children = new DescendantsImpl(ds);
00051 }
00052
00053
00054 public Ancestors ancestors() {
00055 return (Ancestors)parents;
00056 }
00057
00058
00059 public Siblings siblings() {
00060 return (Siblings)sisters;
00061 }
00062
00063
00064 public Descendants descendants() {
00065 return (Descendants)children;
00066 }
00067
00068
00069 public boolean findNode(int id) {
00070 return (parents.findNode(id) || sisters.findNode(id) ||
00071 children.findNode(id));
00072 }
00073
00074
00075 private Request[] combine(Request[] a, Request[] b) {
00076 Request[] ret_objs = new Request[a.length + b.length];
00077
00078 System.arraycopy(a, 0, ret_objs, 0, a.length);
00079 System.arraycopy(b, 0, ret_objs, a.length, b.length);
00080 return ret_objs;
00081 }
00082
00083
00084 public Request[] queryNetwork(byte capability) throws DiscoveryException {
00085 boolean hit_exception = false;
00086 String prev_exception = null;
00087 Request[] sis_objs = null;
00088 Request[] kid_objs = null;
00089
00090 try {
00091 sis_objs = sisters.queryNetwork(capability);
00092 } catch (DiscoveryException de) {
00093 hit_exception = true;
00094 prev_exception = de.description;
00095 }
00096 try {
00097 kid_objs = children.queryNetwork(capability);
00098 } catch (DiscoveryException de) {
00099 if (hit_exception) {
00100 de.description += " and " + prev_exception;
00101 throw de;
00102 }
00103 }
00104
00105 if (sis_objs == null)
00106 return kid_objs;
00107 if (kid_objs == null)
00108 return sis_objs;
00109 return combine(sis_objs, kid_objs);
00110 }
00111
00112
00113 public Request queryNode(int id, byte capability)
00114 throws DiscoveryException {
00115 Request obj = null;
00116 obj = sisters.queryNode(id, capability);
00117 if (obj != null)
00118 return obj;
00119 obj = children.queryNode(id, capability);
00120 return obj;
00121 }
00122 }