PrototypesRegistry.java

src/net/sourceforge/pain/data/PrototypesRegistry.java · 1.2 KB

From the archive pain_0_41.zip

Download the archive   « Back to the archive contents

package net.sourceforge.pain.data;

import net.sourceforge.pain.db.*;
import net.sourceforge.pain.data.prototype.*;

import java.util.*;

/**
 * PAiN  Date: 14.06.2003  Time: 0:58:00
 */
public final class PrototypesRegistry extends DbObject {
	private static final int PROTOTYPES_MAP = 0;
	private static final int NFIELDS = 1;

	public PrototypesRegistry() {
	}

	public PrototypesRegistry(PainDB db)  {
		super(db);
	}

	protected DbClassSchema provideSchema() {
		byte types[] = new byte[NFIELDS];
		String names[] = new String[NFIELDS];

		types[PROTOTYPES_MAP] = DbType.STRING_KEY_MAP;
		names[PROTOTYPES_MAP] = "prototypesMap";

		return new DbClassSchema(types, names);

	}

	public Map getPrototypesMap() {
		return getStringKeyMap(PROTOTYPES_MAP);
	}

	public boolean isUsedVnum(String vnum) {
		return getPrototypesMap().containsKey(vnum);
	}

	public void registerPrototype(Prototype p) {
		getPrototypesMap().put(p.getVnum(), p);
	}

	public PrototypeInfo getPrototypeByVnum(String vnum) {
		return (PrototypeInfo) getPrototypesMap().get(vnum);
	}

	public void unregisterPrototype(PrototypeInfo p) {
		getPrototypesMap().remove(p.getVnum());
	}
}

Site Stats

Snippets: 1791
Codebases: 571