001 /* 002 * LAPIS lightweight structured text processing system 003 * 004 * Copyright (C) 1998-2002 Carnegie Mellon University, 005 * Copyright (C) 2003 Massachusetts Institute of Technology. 006 * All rights reserved. 007 * 008 * This library is free software; you can redistribute it 009 * and/or modify it under the terms of the GNU General 010 * Public License as published by the Free Software 011 * Foundation, version 2. 012 * 013 * LAPIS homepage: http://graphics.lcs.mit.edu/lapis/ 014 */ 015 016 017 package lapisx.util; 018 019 import java.util.Hashtable; 020 021 /** 022 * Subclass of Hashtable that supports merging the existing object 023 * stored in the hashtable with a new object. 024 */ 025 public abstract class MergingHashtable extends Hashtable { 026 027 public Object add (Object key, Object value) { 028 Object curr = get (key); 029 if (curr != null) 030 value = merge (curr, value); 031 return put (key, value); 032 } 033 034 protected abstract Object merge (Object current, Object addition); 035 036 }