01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.xerces.dom;
18:
19: /** Internal class LCount is used to track the number of
20: listeners registered for a given event name, as an entry
21: in a global hashtable. This should allow us to avoid generating,
22: or discard, events for which no listeners are registered.
23:
24: ***** There should undoubtedly be methods here to manipulate
25: this table. At the moment that code's residing in NodeImpl.
26: Move it when we have a chance to do so. Sorry; we were
27: rushed.
28:
29: ???? CONCERN: Hashtables are known to be "overserialized" in
30: current versions of Java. That may impact performance.
31:
32: ???? CONCERN: The hashtable should probably be a per-document object.
33: Finer granularity would be even better, but would cost more cycles to
34: resolve and might not save enough event traffic to be worth the investment.
35: */
36: /**
37: * @xerces.internal
38: *
39: * @version $Id: LCount.java 447266 2006-09-18 05:57:49Z mrglavas $
40: */
41:
42: class LCount {
43: static java.util.Hashtable lCounts = new java.util.Hashtable();
44: public int captures = 0, bubbles = 0, defaults, total = 0;
45:
46: static LCount lookup(String evtName) {
47: LCount lc = (LCount) lCounts.get(evtName);
48: if (lc == null)
49: lCounts.put(evtName, (lc = new LCount()));
50: return lc;
51: }
52: } // class LCount
|