ResetGroupRegistry.java

mudlibs/tinylib/src/net/sourceforge/pain/tinylib/data/ResetGroupRegistry.java · 1.3 KB

From the archive pain_0_45.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.tinylib.data;

import net.sourceforge.pain.db.*;
import net.sourceforge.pain.tinylib.data.type.*;

import java.util.*;

public final class ResetGroupRegistry extends DbObject {
    private static final int RESET_GROUPS = 0;
    private static final int NFIELDS = 1;

    public ResetGroupRegistry() {
    }

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

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

        types[RESET_GROUPS] = DbType.STRING_KEY_MAP;
        names[RESET_GROUPS] = "resets_groups";

        return new DbClassSchema(types, names);

    }

    public ResetGroup getResetGroup(String id) {
        return (ResetGroup) groups().get(id);
    }

    public Collection getResetGroups() {
        return groups().values();
    }


    private DbStringKeyMap groups() {
        return getStringKeyMap(RESET_GROUPS);
    }

    public void changeGroupId(ResetGroup resetGroup, String newId) {
        Map groups = groups();
        final String oldId = resetGroup.getGroupId();
        if (oldId != null) {
            groups.remove(resetGroup.getGroupId());
        }
        resetGroup.__setGroupId(newId);
        groups.put(newId, resetGroup);

    }


}

Site Stats

Snippets: 1791
Codebases: 571