1 11 12 package org.eclipse.ui.internal.activities; 13 14 import org.eclipse.ui.IMemento; 15 16 final class Persistence { 17 final static String PACKAGE_BASE = "activities"; 19 final static String PACKAGE_FULL = "org.eclipse.ui.activities"; 21 final static String PACKAGE_PREFIX = "org.eclipse.ui"; 23 final static String TAG_ACTIVITY = "activity"; 25 final static String TAG_ACTIVITY_REQUIREMENT_BINDING = "activityRequirementBinding"; 27 final static String TAG_DEFAULT_ENABLEMENT = "defaultEnablement"; 29 final static String TAG_ACTIVITY_ID = "activityId"; 31 final static String TAG_ACTIVITY_PATTERN_BINDING = "activityPatternBinding"; 33 final static String TAG_CATEGORY = "category"; 35 final static String TAG_CATEGORY_ACTIVITY_BINDING = "categoryActivityBinding"; 37 final static String TAG_CATEGORY_ID = "categoryId"; 39 final static String TAG_REQUIRED_ACTIVITY_ID = "requiredActivityId"; 41 final static String TAG_ID = "id"; 43 final static String TAG_NAME = "name"; 45 final static String TAG_PATTERN = "pattern"; 47 final static String TAG_SOURCE_ID = "sourceId"; 49 final static String TAG_DESCRIPTION = "description"; 51 static ActivityRequirementBindingDefinition readActivityRequirementBindingDefinition( 52 IMemento memento, String sourceIdOverride) { 53 if (memento == null) { 54 throw new NullPointerException (); 55 } 56 57 String childActivityId = memento.getString(TAG_REQUIRED_ACTIVITY_ID); 58 String parentActivityId = memento.getString(TAG_ACTIVITY_ID); 59 if (childActivityId == null || parentActivityId == null) { 60 return null; 61 } 62 String sourceId = sourceIdOverride != null ? sourceIdOverride : memento 63 .getString(TAG_SOURCE_ID); 64 return new ActivityRequirementBindingDefinition(childActivityId, 65 parentActivityId, sourceId); 66 } 67 68 static String readDefaultEnablement(IMemento memento) { 69 if (memento == null) { 70 throw new NullPointerException (); 71 } 72 73 return memento.getString(TAG_ID); 74 } 75 76 static ActivityDefinition readActivityDefinition(IMemento memento, 77 String sourceIdOverride) { 78 if (memento == null) { 79 throw new NullPointerException (); 80 } 81 82 String id = memento.getString(TAG_ID); 83 if (id == null) { 84 return null; 85 } 86 String name = memento.getString(TAG_NAME); 87 if (name == null) { 88 return null; 89 } 90 String description = memento.getString(TAG_DESCRIPTION); 91 if (description == null) { 92 description = ""; } 94 String 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 sourceIdOverride) { 101 if (memento == null) { 102 throw new NullPointerException (); 103 } 104 105 String activityId = memento.getString(TAG_ACTIVITY_ID); 106 if (activityId == null) { 107 return null; 108 } 109 String pattern = memento.getString(TAG_PATTERN); 110 if (pattern == null) { 111 return null; 112 } 113 String 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 sourceIdOverride) { 121 if (memento == null) { 122 throw new NullPointerException (); 123 } 124 125 String activityId = memento.getString(TAG_ACTIVITY_ID); 126 if (activityId == null) { 127 return null; 128 } 129 String categoryId = memento.getString(TAG_CATEGORY_ID); 130 if (categoryId == null) { 131 return null; 132 } 133 String 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 sourceIdOverride) { 141 if (memento == null) { 142 throw new NullPointerException (); 143 } 144 145 String id = memento.getString(TAG_ID); 146 if (id == null) { 147 return null; 148 } 149 String name = memento.getString(TAG_NAME); 150 if (name == null) { 151 return null; 152 } 153 String description = memento.getString(TAG_DESCRIPTION); 154 if (description == null) { 155 description = ""; } 157 String sourceId = sourceIdOverride != null ? sourceIdOverride : memento 158 .getString(TAG_SOURCE_ID); 159 return new CategoryDefinition(id, name, sourceId, description); 160 } 161 162 private Persistence() { 163 } 165 } 166 | Popular Tags |