KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > activities > Persistence


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.activities;
13
14 import org.eclipse.ui.IMemento;
15
16 final class Persistence {
17     final static String JavaDoc PACKAGE_BASE = "activities"; //$NON-NLS-1$
18

19     final static String JavaDoc PACKAGE_FULL = "org.eclipse.ui.activities"; //$NON-NLS-1$
20

21     final static String JavaDoc PACKAGE_PREFIX = "org.eclipse.ui"; //$NON-NLS-1$
22

23     final static String JavaDoc TAG_ACTIVITY = "activity"; //$NON-NLS-1$
24

25     final static String JavaDoc TAG_ACTIVITY_REQUIREMENT_BINDING = "activityRequirementBinding"; //$NON-NLS-1$
26

27     final static String JavaDoc TAG_DEFAULT_ENABLEMENT = "defaultEnablement"; //$NON-NLS-1$
28

29     final static String JavaDoc TAG_ACTIVITY_ID = "activityId"; //$NON-NLS-1$
30

31     final static String JavaDoc TAG_ACTIVITY_PATTERN_BINDING = "activityPatternBinding"; //$NON-NLS-1$
32

33     final static String JavaDoc TAG_CATEGORY = "category"; //$NON-NLS-1$
34

35     final static String JavaDoc TAG_CATEGORY_ACTIVITY_BINDING = "categoryActivityBinding"; //$NON-NLS-1$
36

37     final static String JavaDoc TAG_CATEGORY_ID = "categoryId"; //$NON-NLS-1$
38

39     final static String JavaDoc TAG_REQUIRED_ACTIVITY_ID = "requiredActivityId"; //$NON-NLS-1$
40

41     final static String JavaDoc TAG_ID = "id"; //$NON-NLS-1$
42

43     final static String JavaDoc TAG_NAME = "name"; //$NON-NLS-1$
44

45     final static String JavaDoc TAG_PATTERN = "pattern"; //$NON-NLS-1$
46

47     final static String JavaDoc TAG_SOURCE_ID = "sourceId"; //$NON-NLS-1$
48

49     final static String JavaDoc TAG_DESCRIPTION = "description"; //$NON-NLS-1$
50

51     static ActivityRequirementBindingDefinition readActivityRequirementBindingDefinition(
52             IMemento memento, String JavaDoc sourceIdOverride) {
53         if (memento == null) {
54             throw new NullPointerException JavaDoc();
55         }
56
57         String JavaDoc childActivityId = memento.getString(TAG_REQUIRED_ACTIVITY_ID);
58         String JavaDoc parentActivityId = memento.getString(TAG_ACTIVITY_ID);
59         if (childActivityId == null || parentActivityId == null) {
60             return null;
61         }
62         String JavaDoc sourceId = sourceIdOverride != null ? sourceIdOverride : memento
63                 .getString(TAG_SOURCE_ID);
64         return new ActivityRequirementBindingDefinition(childActivityId,
65                 parentActivityId, sourceId);
66     }
67
68     static String JavaDoc readDefaultEnablement(IMemento memento) {
69         if (memento == null) {
70             throw new NullPointerException JavaDoc();
71         }
72
73         return memento.getString(TAG_ID);
74     }
75
76     static ActivityDefinition readActivityDefinition(IMemento memento,
77             String JavaDoc sourceIdOverride) {
78         if (memento == null) {
79             throw new NullPointerException JavaDoc();
80         }
81
82         String JavaDoc id = memento.getString(TAG_ID);
83         if (id == null) {
84             return null;
85         }
86         String JavaDoc name = memento.getString(TAG_NAME);
87         if (name == null) {
88             return null;
89         }
90         String JavaDoc description = memento.getString(TAG_DESCRIPTION);
91         if (description == null) {
92             description = ""; //$NON-NLS-1$
93
}
94         String JavaDoc sourceId = sourceIdOverride != null ? sourceIdOverride : memento
95                 .getString(TAG_SOURCE_ID);
96         return new ActivityDefinition(id, name, sourceId, description);
97     }
98
99     static ActivityPatternBindingDefinition readActivityPatternBindingDefinition(
100             IMemento memento, String JavaDoc sourceIdOverride) {
101         if (memento == null) {
102             throw new NullPointerException JavaDoc();
103         }
104
105         String JavaDoc activityId = memento.getString(TAG_ACTIVITY_ID);
106         if (activityId == null) {
107             return null;
108         }
109         String JavaDoc pattern = memento.getString(TAG_PATTERN);
110         if (pattern == null) {
111             return null;
112         }
113         String JavaDoc sourceId = sourceIdOverride != null ? sourceIdOverride : memento
114                 .getString(TAG_SOURCE_ID);
115         return new ActivityPatternBindingDefinition(activityId, pattern,
116                 sourceId);
117     }
118
119     static CategoryActivityBindingDefinition readCategoryActivityBindingDefinition(
120             IMemento memento, String JavaDoc sourceIdOverride) {
121         if (memento == null) {
122             throw new NullPointerException JavaDoc();
123         }
124
125         String JavaDoc activityId = memento.getString(TAG_ACTIVITY_ID);
126         if (activityId == null) {
127             return null;
128         }
129         String JavaDoc categoryId = memento.getString(TAG_CATEGORY_ID);
130         if (categoryId == null) {
131             return null;
132         }
133         String JavaDoc sourceId = sourceIdOverride != null ? sourceIdOverride : memento
134                 .getString(TAG_SOURCE_ID);
135         return new CategoryActivityBindingDefinition(activityId, categoryId,
136                 sourceId);
137     }
138
139     static CategoryDefinition readCategoryDefinition(IMemento memento,
140             String JavaDoc sourceIdOverride) {
141         if (memento == null) {
142             throw new NullPointerException JavaDoc();
143         }
144
145         String JavaDoc id = memento.getString(TAG_ID);
146         if (id == null) {
147             return null;
148         }
149         String JavaDoc name = memento.getString(TAG_NAME);
150         if (name == null) {
151             return null;
152         }
153         String JavaDoc description = memento.getString(TAG_DESCRIPTION);
154         if (description == null) {
155             description = ""; //$NON-NLS-1$
156
}
157         String JavaDoc sourceId = sourceIdOverride != null ? sourceIdOverride : memento
158                 .getString(TAG_SOURCE_ID);
159         return new CategoryDefinition(id, name, sourceId, description);
160     }
161
162     private Persistence() {
163         //no-op
164
}
165 }
166
Popular Tags