KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > api > cintoo > messages > context > Contexts


1 /*
2  * Copyright 2006 cintoo, Berlin, Germany
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package api.cintoo.messages.context;
17
18 import cintoo.messages.context.IdContext;
19 import cintoo.messages.context.PackageContext;
20
21 /**
22  * Factory to create contexts and hide knowlege
23  * about specific contexts
24  *
25  * @author Stephan J. Schmidt
26  * @version $id$
27  * @since 1.0
28  */

29 public class Contexts {
30     /**
31      * Create context for object
32      *
33      * @param contextObject object for which to create context
34      * @return new context
35      */

36     public static Context create(Object JavaDoc contextObject) {
37         return new PackageContext(contextObject);
38     }
39
40     /**
41      * Create context object from string representation
42      *
43      * @param contextString string from which the context should be created
44      * @return new context
45      */

46     public static Context createFromString(String JavaDoc contextString) {
47         return PackageContext.string(contextString);
48     }
49
50     /**
51      * Create default context
52      *
53      * @return default context
54      */

55     public static Context create() {
56         return new PackageContext();
57     }
58
59     public static Context id(String JavaDoc id) {
60         return IdContext.id(id);
61     }
62
63     public static Context string(String JavaDoc bundleName) {
64         return PackageContext.string(bundleName);
65     }
66 }
67
Popular Tags