KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > tools > OPP > srcgen > resolve > UpdateMethodBagMapAdapter


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id$
8
package org.ozoneDB.tools.OPP.srcgen.resolve;
9
10 import org.ozoneDB.tools.OPP.srcgen.MethodResolver;
11
12 import java.util.Map JavaDoc;
13
14 /**
15  * User: Jocke
16  * Date: 2003-dec-30
17  * Time: 00:57:22
18  */

19 public class UpdateMethodBagMapAdapter implements MethodResolver.UpdateMethodBag {
20     private Map JavaDoc methods;
21
22     public UpdateMethodBagMapAdapter(Map JavaDoc methods) {
23         this.methods = methods;
24     }
25
26     /**
27      * Add a method to the bag, if the method exists with a "lower" lockLevel (read < write) it will be upgraded.
28      * if the method exists with a "higher" lockLevel it will be left as is.
29      * @param methodName The method to add
30      * @param lockLevel The locklevel to assign to the method
31      */

32     public void addMethod(String JavaDoc methodName, int lockLevel) {
33         if (methods.containsKey(methodName)) {
34             int oldLevel = ((Integer JavaDoc) methods.get(methodName)).intValue();
35             if (oldLevel >= lockLevel) {
36                 return;
37             }
38         }
39         methods.put(methodName, new Integer JavaDoc(lockLevel));
40     }
41
42     public boolean contains(String JavaDoc methodName) {
43         return methods.keySet().contains(methodName);
44     }
45 }
46
Popular Tags