Changeset 4366 for trunk/gli/src/org/greenstone/gatherer/cdm/Format.java
- Timestamp:
- 2003-05-27T15:57:37+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Format.java
r4293 r4366 56 56 */ 57 57 public class Format { 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 58 /** If this format is of a true/false type, the current state. */ 59 private boolean state = false; 60 /** The type of this format command, either FLAG, FORMAT or PARAM. */ 61 private int type = -1; 62 /** The feature this format command affects. */ 63 private Object feature = null; 64 /** If this format refers to a specific part of a feature, this indicates the part. */ 65 private String part = null; 66 /** A command string, which may include a specific HTML chunk used to format a control. */ 67 private String value = null; 68 /** An element of the format type enumeration. A true/false option. */ 69 static final public int FLAG = 0; 70 /** An element of the format type enumeration. A string parameter. */ 71 static final public int VALUE = 1; 72 /** The default features as specified by the Greenstone Developers manual. */ 73 static final public String DEFAULT_FEATURES[] = {"", "DocumentArrowsBottom","DocumentButtons","DocumentContents","DocumentHeading","DocumentImages","DocumentText","DocumentUseHTML","Search"}; 74 /** The list of known feature parts. */ 75 static final public String DEFAULT_PARTS[] = {"","DateList","HList","Invisible","VList"}; 76 /** Constructor for a flag format command. 77 * @param feature The <Strong>Object</strong> this format affects. 78 * @param part The specific part of the control to format as a <strong>String</strong>. 79 * @param state A <i>boolean</i> indicating this formats state. 80 */ 81 public Format(Object feature, String part, boolean state) { 82 this.feature = feature; 83 this.part = part; 84 this.state = state; 85 this.type = FLAG; 86 } 87 /** Constructor for a format-string format command. 88 * @param feature The <Strong>Object</strong> this format affects. 89 * @param part The specific part of the control to format as a <strong>String</strong>. 90 * @param value The format <strong>String</strong> which may be a label name, or a piece of HTML formatting. 91 */ 92 public Format(Object feature, String part, String value) { 93 this.feature = feature; 94 this.part = part; 95 this.type = VALUE; 96 this.value = value; 97 } 98 /** Method to retrieve the value of feature, which may either be a String or a Classifier. 99 * @return The value of feature as an <strong>Object</strong>. 100 */ 101 public Object getFeature() { 102 return feature; 103 } 104 /** Method to retrieve the value of part. 105 * @return The value of part as a <Strong>String</strong>. 106 */ 107 public String getPart() { 108 return part; 109 } 110 /** Method to retrieve this formats special Greenstone position code. 111 * @return A <strong>String</strong> which distinctly indicates this classifiers position. 112 * @see org.greenstone.gatherer.cdm.Classifier 113 */ 114 public String getPosition() { 115 ///ystem.err.println("Retrieving the name of feature " + feature); 116 String position = null; 117 if(feature instanceof Classifier) { 118 position = ((Classifier)feature).getPositionString(); 119 } 120 else { 121 position = feature.toString(); 122 } 123 ///ystem.err.println("Result: " + position + part); 124 return position + part; 125 } 126 /** Method to retrieve the value of state. 127 * @param The value of state as a <i>boolean</i>. 128 */ 129 public boolean getState() { 130 return state; 131 } 132 /** Method to retrieve the value of type. 133 * @param The value of type as an <i>int</i>. 134 */ 135 public int getType() { 136 return type; 137 } 138 /** Retrieve the value of value. 139 * @return A <strong>String</strong> which is the value of value. 140 */ 141 public String getValue() { 142 return value; 143 } 144 /** Set the value of state. 145 * @param state The new value for state as a <i>boolean</i>. 146 */ 147 public void setState(boolean state) { 148 this.state = state; 149 } 150 /** Set the value of type. 151 * @param type The new value for type as an <i>int</i>. 152 */ 153 public void setType(int type) { 154 this.type = type; 155 } 156 /** Set the value of value. Hmmm. 157 * @param value The new value from value as a <strong>String</strong>. 158 */ 159 public void setValue(String value) { 160 this.value = value; 161 } 162 /** Method to translate this classes information into a line of text as you would expect in the collection configuration file. 163 * @return A <strong>String</strong> containing the format command. 164 */ 165 public String toString() { 166 String text = "format "; 167 text = text + getPosition() + " "; 168 switch(type) { 169 case FLAG: 170 if(state) { 171 text = text + "true"; 172 } 173 else { 174 text = text + "false"; 175 } 176 break; 177 default: 178 text = text + "\"" + value + "\""; 179 } 180 return text; 181 } 182 /** Retrieve the type of a certain named feature. 183 * @param name The name of the feature as a <strong>String</strong>. 184 * @return An <i>int</i> indicating the type, and hence the controls needed to edit this type. 185 */ 186 static public int getType(String name) { 187 int index = -1; 188 for(int i = 1; i < DEFAULT_FEATURES.length; i++) { 189 if(name.equalsIgnoreCase(DEFAULT_FEATURES[i])) { 190 index = i; 191 } 192 } 193 if(index == 1 || index == 3 || index == 5 || index == 7) { 194 return FLAG; 195 } 196 return VALUE; 197 } 198 198 }
Note:
See TracChangeset
for help on using the changeset viewer.