@Test public void testGetScope() { Scopes instance = new Scopes(); Scope globalScope = instance.getScope(0); instance.addScope(new Scope(10, 20, "scope1", "ns")); instance.addScope(new Scope(25, 30, "scope2", "ns")); instance.addScope(new Scope(40, 40, "scope3", "ns")); instance.addScope(new Scope(60, 70, "scope4", "ns")); instance.addScope(new Scope(80, 90, "scope5", "ns")); instance.addScope(new Scope(91, 100, "scope6", "ns")); assertEquals(instance.size(), 6); assertEquals(instance.getScope(1), globalScope); assertEquals(instance.getScope(10).getName(), "scope1"); assertEquals(instance.getScope(15).getName(), "scope1"); assertEquals(instance.getScope(20).getName(), "scope1"); assertEquals(instance.getScope(21), globalScope); assertEquals(instance.getScope(24), globalScope); assertEquals(instance.getScope(39), globalScope); assertEquals(instance.getScope(40).getName(), "scope3"); assertEquals(instance.getScope(41), globalScope); assertEquals(instance.getScope(90).getName(), "scope5"); assertEquals(instance.getScope(100).getName(), "scope6"); assertEquals(instance.getScope(101), globalScope); assertEquals(instance.getScope(500), globalScope); }
public Scope getScope(int line) { Scope s = scopes.floor(new Scope(line)); return (s != null && s.matches(line)) ? s : GLOBAL_SCOPE; }
Scopes implements Serializable { public Scope getScope(int line) { Scope s = scopes.floor(new Scope(line)); return (s != null && s.matches(line)) ? s : GLOBAL_SCOPE; } }
Scopes implements Serializable { public Scope getScope(int line) { Scope s = scopes.floor(new Scope(line)); return (s != null && s.matches(line)) ? s : GLOBAL_SCOPE; } Scopes(); }
Scopes implements Serializable { public Scope getScope(int line) { Scope s = scopes.floor(new Scope(line)); return (s != null && s.matches(line)) ? s : GLOBAL_SCOPE; } Scopes(); int size(); void addScope(Scope scope); Scope getScope(int line); byte[] serialize(); static Scopes deserialize(byte[] bytes); }
Scopes implements Serializable { public Scope getScope(int line) { Scope s = scopes.floor(new Scope(line)); return (s != null && s.matches(line)) ? s : GLOBAL_SCOPE; } Scopes(); int size(); void addScope(Scope scope); Scope getScope(int line); byte[] serialize(); static Scopes deserialize(byte[] bytes); static final Scope GLOBAL_SCOPE; }