source: trunk/src/org/expeditee/gui/AttributeUtils.java@ 108

Last change on this file since 108 was 108, checked in by ra33, 16 years ago

Heaps of changes!!!!
Added circles...
Better drawing of lines etc etc

File size: 22.7 KB
Line 
1package org.expeditee.gui;
2
3import java.awt.Color;
4import java.awt.Font;
5import java.awt.Point;
6import java.lang.reflect.InvocationTargetException;
7import java.lang.reflect.Method;
8import java.util.HashMap;
9import java.util.LinkedList;
10import java.util.List;
11
12import org.expeditee.io.Conversion;
13import org.expeditee.items.Item;
14import org.expeditee.items.Justification;
15import org.expeditee.items.Permission;
16import org.expeditee.items.Text;
17
18/**
19 * This class provides the methods to extract and set attributes of Items and
20 * Frames. These methods are called when a user merges a text item with
21 * <code>Attribute: Value</code> pairs.
22 *
23 * @author jdm18
24 *
25 */
26public class AttributeUtils {
27
28 public static final char SEPARATOR_CHAR = ':';
29
30 private static final String SEPARATOR_STRING = SEPARATOR_CHAR + " ";
31
32 private static final int GET_LENGTH = "get".length();
33
34 private static int SET_LENGTH = "set".length();
35
36 // List of method names to ignore when searching for a match
37 private static List<Method> _GetMethods = null;
38
39 private static HashMap<String, Method> _SetMethods = null;
40
41 // List of attributes which are ignored when copying.
42 private static List<String> _Ignore = null;
43
44 // List of method names to show in extraced lists even when they return
45 // null
46 // (Null is often used to indicate the default value is used)
47 private static List<Method> _AllowNull = null;
48
49 private static List<String> _ExtractIgnore = null;
50
51 // private static HashMap<String, String> _Abbreviations = null;
52
53 /**
54 * Initialises the _Ignore and _AllowNull lists.
55 */
56 private static void initLists() {
57
58 Class[] param = {};
59
60 try {
61 // TODO load these in with reflection...
62 // Set the shortcuts with annotation tags on the methods
63 _Ignore = new LinkedList<String>();
64 _Ignore.add("date");
65 _Ignore.add("datecreated");
66 _Ignore.add("d");
67 _Ignore.add("link");
68 _Ignore.add("l");
69 _Ignore.add("action");
70 _Ignore.add("a");
71 _Ignore.add("position");
72 _Ignore.add("pos");
73 _Ignore.add("p");
74 _Ignore.add("x");
75 _Ignore.add("y");
76
77 _ExtractIgnore = new LinkedList<String>();
78 _ExtractIgnore.add("x");
79 _ExtractIgnore.add("y");
80
81 _AllowNull = new LinkedList<Method>();
82 _AllowNull.add(Item.class.getMethod("getColor", param));
83 _AllowNull.add(Item.class.getMethod("getBackgroundColor", param));
84
85 _AllowNull.add(Frame.class.getMethod("getBackgroundColor", param));
86 _AllowNull.add(Frame.class.getMethod("getForegroundColor", param));
87
88 _GetMethods = new LinkedList<Method>();
89 _GetMethods.add(Item.class.getMethod("getDateCreated", param));
90
91 _GetMethods.add(Item.class.getMethod("getColor", param));
92 _GetMethods.add(Item.class.getMethod("getBackgroundColor", param));
93 _GetMethods.add(Item.class.getMethod("getAction", param));
94 _GetMethods.add(Item.class.getMethod("getData", param));
95 _GetMethods.add(Item.class.getMethod("getLink", param));
96 _GetMethods.add(Item.class.getMethod("getFillColor", param));
97 _GetMethods.add(Item.class.getMethod("getFillPattern", param));
98 _GetMethods.add(Item.class.getMethod("getThickness", param));
99
100 _GetMethods.add(Item.class.getMethod("getOwner", param));
101 _GetMethods.add(Item.class.getMethod("getLinkMark", param));
102 _GetMethods.add(Item.class.getMethod("getActionMark", param));
103
104 _GetMethods
105 .add(Item.class.getMethod("getActionCursorEnter", param));
106 _GetMethods
107 .add(Item.class.getMethod("getActionCursorLeave", param));
108 _GetMethods.add(Item.class.getMethod("getActionEnterFrame", param));
109 _GetMethods.add(Item.class.getMethod("getActionLeaveFrame", param));
110
111 _GetMethods.add(Item.class.getMethod("getTopShadowColor", param));
112 _GetMethods
113 .add(Item.class.getMethod("getBottomShadowColor", param));
114 _GetMethods.add(Item.class.getMethod("getArrow", param));
115
116 _GetMethods.add(Item.class.getMethod("getLinePattern", param));
117 _GetMethods.add(Item.class.getMethod("getLinkFrameset", param));
118 _GetMethods.add(Item.class.getMethod("getLinkTemplate", param));
119 _GetMethods.add(Item.class.getMethod("getPosition", param));
120 _GetMethods.add(Item.class.getMethod("getX", param));
121 _GetMethods.add(Item.class.getMethod("getY", param));
122
123 _GetMethods.add(Text.class.getMethod("getFamily", param));
124 _GetMethods.add(Text.class.getMethod("getFontStyle", param));
125 _GetMethods.add(Text.class.getMethod("getJustification", param));
126 _GetMethods.add(Text.class.getMethod("getWidth", param));
127 _GetMethods.add(Item.class.getMethod("getSize", param));
128
129 _GetMethods.add(Frame.class.getMethod("getOwner", param));
130 _GetMethods.add(Frame.class.getMethod("getPermission", param));
131 _GetMethods.add(Frame.class.getMethod("getDateCreated", param));
132 _GetMethods.add(Frame.class.getMethod("getLastModifyUser", param));
133 _GetMethods.add(Frame.class.getMethod("getLastModifyDate", param));
134 _GetMethods.add(Frame.class.getMethod("getForegroundColor", param));
135 _GetMethods.add(Frame.class.getMethod("getBackgroundColor", param));
136
137 Class[] pPoint = { Point.class };
138 Class[] pString = { String.class };
139 Class[] pInt = { int.class };
140 Class[] pFloat = { float.class };
141 Class[] pColor = { Color.class };
142 Class[] pBool = { boolean.class };
143 Class[] pArrow = { float.class, double.class };
144 Class[] pList = { List.class };
145 Class[] pIntArray = { int[].class };
146 Class[] pJustification = { Justification.class };
147 Class[] pPermission = { Permission.class };
148
149 _SetMethods = new HashMap<String, Method>();
150 _SetMethods.put("x", Item.class.getMethod("setX", pFloat));
151 _SetMethods.put("y", Item.class.getMethod("setY", pFloat));
152 _SetMethods.put("position", Item.class.getMethod("setPosition",
153 pPoint));
154 _SetMethods.put("p", Item.class.getMethod("setPosition", pPoint));
155 _SetMethods.put("pos", Item.class.getMethod("setPosition", pPoint));
156 _SetMethods.put("thickness", Item.class.getMethod("setThickness",
157 pFloat));
158 _SetMethods.put("t", Item.class.getMethod("setThickness", pFloat));
159
160 _SetMethods.put("color", Item.class.getMethod("setColor", pColor));
161 _SetMethods.put("c", Item.class.getMethod("setColor", pColor));
162
163 _SetMethods.put("backgroundcolor", Item.class.getMethod(
164 "setBackgroundColor", pColor));
165 _SetMethods.put("bgc", Item.class.getMethod("setBackgroundColor",
166 pColor));
167
168 _SetMethods
169 .put("action", Item.class.getMethod("setActions", pList));
170 _SetMethods.put("a", Item.class.getMethod("setActions", pList));
171 _SetMethods.put("d", Item.class.getMethod("setData", pList));
172 _SetMethods.put("data", Item.class.getMethod("setData", pList));
173
174 _SetMethods.put("link", Item.class.getMethod("setLink", pString));
175 _SetMethods.put("l", Item.class.getMethod("setLink", pString));
176
177 _SetMethods.put("fillcolor", Item.class.getMethod("setFillColor",
178 pColor));
179 _SetMethods.put("fc", Item.class.getMethod("setFillColor", pColor));
180
181 _SetMethods.put("fillpattern", Item.class.getMethod(
182 "setFillPattern", pString));
183 _SetMethods.put("fp", Item.class.getMethod("setFillPattern",
184 pString));
185
186 _SetMethods.put("owner", Item.class.getMethod("setOwner", pString));
187 _SetMethods.put("linkmark", Item.class.getMethod("setLinkMark",
188 pBool));
189 _SetMethods.put("lm", Item.class.getMethod("setLinkMark", pBool));
190 _SetMethods.put("actionmark", Item.class.getMethod("setActionMark",
191 pBool));
192 _SetMethods.put("am", Item.class.getMethod("setActionMark", pBool));
193
194 _SetMethods.put("actioncursorenter", Item.class.getMethod(
195 "setActionCursorEnter", pList));
196 _SetMethods.put("actioncursorleave", Item.class.getMethod(
197 "setActionCursorLeave", pList));
198 _SetMethods.put("actionenterframe", Item.class.getMethod(
199 "setActionEnterFrame", pList));
200 _SetMethods.put("actionleaveframe", Item.class.getMethod(
201 "setActionLeaveFrame", pList));
202
203 _SetMethods.put("topshadow", Item.class.getMethod(
204 "setTopShadowColor", pColor));
205 _SetMethods.put("bottomshadow", Item.class.getMethod(
206 "setBottomShadowColor", pColor));
207 _SetMethods.put("arrow", Item.class.getMethod("setArrow", pArrow));
208
209 _SetMethods.put("linepattern", Item.class.getMethod(
210 "setLinePattern", pIntArray));
211 _SetMethods.put("lp", Item.class.getMethod("setLinePattern",
212 pIntArray));
213
214 _SetMethods.put("linkframeset", Item.class.getMethod(
215 "setLinkFrameset", pString));
216 _SetMethods.put("lf", Item.class.getMethod("setLinkFrameset",
217 pString));
218 _SetMethods.put("linktemplate", Item.class.getMethod(
219 "setLinkTemplate", pString));
220 _SetMethods.put("lt", Item.class.getMethod("setLinkTemplate",
221 pString));
222
223 _SetMethods.put("family", Text.class
224 .getMethod("setFamily", pString));
225 _SetMethods.put("face", Text.class.getMethod("setFontStyle",
226 pString));
227 _SetMethods.put("fontstyle", Text.class.getMethod("setFontStyle",
228 pString));
229 _SetMethods.put("justification", Text.class.getMethod(
230 "setJustification", pJustification));
231 _SetMethods.put("width", Text.class.getMethod("setWidth", pInt));
232 _SetMethods.put("size", Item.class.getMethod("setSize", pFloat));
233 _SetMethods.put("s", Item.class.getMethod("setSize", pFloat));
234
235 _SetMethods.put("foregroundcolor", Frame.class.getMethod(
236 "setForegroundColor", pColor));
237 _SetMethods.put("fgc", Frame.class.getMethod("setForegroundColor",
238 pColor));
239 _SetMethods.put("backgroundcolor0", Frame.class.getMethod(
240 "setBackgroundColor", pColor));
241 _SetMethods.put("bgc0", Frame.class.getMethod("setBackgroundColor",
242 pColor));
243 _SetMethods.put("permission", Frame.class.getMethod(
244 "setPermission", pPermission));
245
246 } catch (SecurityException e) {
247 // TODO Auto-generated catch block
248 e.printStackTrace();
249 } catch (NoSuchMethodException e) {
250 // TODO Auto-generated catch block
251 e.printStackTrace();
252 }
253 }
254
255 /**
256 * Extracts a list of attributes from the given Object. Any method that
257 * starts with <code>get</code>, takes no arguments and is not found in
258 * the Ignore list will be run, All the attributes are then put into a Text
259 * Item of the form <Name>:<Value> If the value returned by the get method
260 * is null, then the attribute will not be included, unless the name of the
261 * method is found in the AllowNull list.
262 *
263 * @param toExtract
264 * The Object from which to extract the attributes
265 * @return A Text Item containing the extracted Attributes.
266 */
267 public static Item extractAttributes(Object toExtract) {
268 if (toExtract == null)
269 return null;
270
271 // ensure the lists are populated
272 if (_Ignore == null)
273 initLists();
274
275 // StringBuffer to store all the extracted Attribute:Value pairs
276 StringBuffer attributes = new StringBuffer();
277
278 // iterate through the list of methods
279 for (Method m : _GetMethods) {
280
281 // Make sure the classes of the methods match the item
282 if (m.getDeclaringClass().isAssignableFrom(toExtract.getClass())) {
283 try {
284 Object o = m.invoke(toExtract, (Object[]) null);
285
286 if (o == null) {
287 // methods that return null are only included if they
288 // are in the AllowNull list
289 if (_AllowNull.contains(m)) {
290 String name = m.getName().substring(GET_LENGTH)
291 .toLowerCase();
292 if (name.equals("color"))
293 o = "default";
294 else if (name.equals("backgroundcolor"))
295 o = "transparent";
296 else if (name.equals("foregroundcolor"))
297 o = "auto";
298 else
299 o = "";
300 } else {
301 continue;
302 }
303 }
304 // skip methods that are in the ignore lists
305 if (_ExtractIgnore.contains(m.getName().substring(
306 GET_LENGTH).toLowerCase())) {
307 continue;
308 }
309
310 if (o instanceof Integer) {
311 Integer i = (Integer) o;
312 if (i == Item.DEFAULT_INTEGER)
313 continue;
314 if (m.getName().endsWith("Justification")
315 && ((Justification) o).toString() != null)
316 o = ((Justification) o).toString();
317 // -1 indicates default value
318 else
319 o = i;
320 } else if (o instanceof Float) {
321 // -1 indicates default value
322 if (((Float) o) < 0.0001)
323 continue;
324 } else if (o instanceof Double) {
325 // -1 indicates default value
326 if (((Double) o) < 0.0001)
327 continue;
328 } else if (o instanceof Color) {
329 // converts the color to the Expeditee code
330 o = Conversion.getExpediteeColorCode((Color) o);
331 if (o == null)
332 continue;
333 } else if (o instanceof Point) {
334 Point p = (Point) o;
335 o = (int) p.getX() + " " + (int) p.getY();
336 } else if (o instanceof Font) {
337 Font f = (Font) o;
338
339 String s = f.getName() + "-";
340 if (f.isPlain())
341 s += "Plain";
342
343 if (f.isBold())
344 s += "Bold";
345
346 if (f.isItalic())
347 s += "Italic";
348
349 s += "-" + f.getSize();
350 o = s;
351 } else if (o instanceof Text) {
352 o = ((Text) o).getFirstLine();
353 } else if (o instanceof List) {
354 List list = (List) o;
355 for (Object ob : list)
356 attributes
357 .append(m.getName().substring(GET_LENGTH))
358 .append(SEPARATOR_STRING).append(ob)
359 .append("\n");
360 continue;
361 } else if (o instanceof int[]) {
362 StringBuffer sb = new StringBuffer();
363 int[] values = (int[]) o;
364 for (int i = 0; i < values.length; i++) {
365 sb.append(values[i]).append(' ');
366 }
367 sb.deleteCharAt(attributes.length() - 1);
368 o = sb.toString();
369 } else if (o instanceof Boolean) {
370 // true is the default for boolean values
371 if (((Boolean) o).booleanValue())
372 continue;
373 }
374 // Append the attributes
375 attributes.append(m.getName().substring(GET_LENGTH))
376 .append(SEPARATOR_STRING).append(o).append("\n");
377 } catch (Exception e) {
378 // TODO Auto-generated catch block
379 e.printStackTrace();
380 }
381 }
382 }
383
384 // if no attributes were extracted
385 if (attributes.length() <= 0)
386 return null;
387
388 while (attributes.charAt(attributes.length() - 1) == '\n')
389 attributes.delete(attributes.length() - 1, attributes.length());
390
391 // create the text Item
392 Frame current = DisplayIO.getCurrentFrame();
393 Item attribs = current.getStatsTextItem(attributes.toString());
394 return attribs;
395 }
396
397 /**
398 * Attempts to set the attribute in the given attribute: value pair. The
399 * value string should be formatted as follows:
400 * <code> Attribute: Value </code> Multiple values can be used if they are
401 * separated by spaces
402 *
403 * @param toSet
404 * The Item or Frame to set the attribute of
405 * @param attribs
406 * The Text item that contains the list of attributes to set
407 * @return True if the attribute(s) were sucessfully set, false otherwise
408 */
409 public static boolean setAttribute(Object toSet, Text attribs) {
410 // error checking
411 if (toSet == null || attribs == null)
412 return false;
413
414 if (_Ignore == null)
415 initLists();
416
417 // get the list of attribute: value pairs
418 List<String> values = attribs.getTextList();
419 // if no pairs exist, we are done
420 if (values.size() == 0
421 || (values.size() == 1 && values.get(0).length() == 0)) {
422 return false;
423 }
424
425 // loop through all attribute: value pairs
426 for (int i = 0; i < values.size(); i++) {
427 StringBuffer v = new StringBuffer(values.get(i));
428
429 // remove the annotation mark (if applicable)
430 if (v.indexOf("@") == 0)
431 v = v.deleteCharAt(0);
432
433 // check if the next string is another attribute to merge or a
434 // continuation
435 while (i < values.size() - 1) {
436 StringBuffer next = new StringBuffer(values.get(i + 1));
437
438 // if the next String has a colon, then it may be another
439 // attribute
440 if (next.indexOf("" + SEPARATOR_CHAR) >= 0) {
441 // if the attribute is the same as v, then it is a
442 // continuation
443 if (v.indexOf(getAttribute(next.toString())) == 0) {
444 // strip the attribute from next
445 next = new StringBuffer(getValue(next.toString()));
446 // if the attribute is not the same, then it may be a
447 // new method
448 } else {
449 // if this is indeed a method, then leave the while loop
450 // if(_SetMethods.containsKey(StripFromColon(next.toString()).toLowerCase())){
451 break;
452 // }
453 }
454 }
455
456 v.append("\n").append(next);
457 i++;
458 }
459
460 if (v.length() > 0
461 && !setAttribute(toSet, v.toString(), values.size() > 1)) {
462 // if no other attributes have been set
463 if (i == 0)
464 return false;
465 // otherwise, this is a list of attributes, so continue
466 else {
467 String stripped = getAttribute(v.toString());
468 if (stripped == null) {
469 // This happens when there is an attribute at the start
470 // Then a bunch of plain text
471 return false;
472 } else if (_Ignore.contains(stripped)) {
473 return false;
474 } else if (!(_SetMethods.containsKey(stripped))) {
475 // Display an error message if its not in our list of
476 // attributes to ignore when copying
477 FrameGraphics.WarningMessage("Attribute: '"
478 + getAttribute(v.toString())
479 + "' does not exist.");
480 } else {
481 String types = "";
482 for (Class c : _SetMethods.get(stripped)
483 .getParameterTypes())
484 types += c.getSimpleName() + " ";
485 FrameGraphics.WarningMessage("Wrong arguments for: '"
486 + getAttribute(v.toString()) + "' expecting "
487 + types.trim() + " found '"
488 + getValue(v.toString()) + "'");
489 }
490 }
491 } else if (v.length() == 0)
492 return false;
493 }
494
495 return true;
496 }
497
498 private static boolean setAttribute(Object toSet, String value,
499 boolean isAttributeList) {
500 // separate attribute and value from string
501 String attribute = getAttribute(value);
502 //Check that an attribute was found
503 if(attribute == null)
504 return false;
505 attribute = attribute.toLowerCase();
506
507 value = getValue(value);
508 assert(value != null);
509
510 // Some properties are ignored when multiple attributes are being set on
511 // an item at the same time
512 if (isAttributeList && _Ignore.contains(attribute)) {
513 // System.out.println("Attribute ignored: " + attribute);
514 return true;
515 }
516
517 // Separate multiple values if required
518 Method toRun = _SetMethods.get( attribute);
519
520 // if this is not the name of a method, it may be the name of an agent
521 if (toRun == null) {
522 // System.out.println("Attrib not found for: " + attribute);
523 return false;
524 }
525
526 // if there are duplicate methods with the same name
527 List<Method> possibles = new LinkedList<Method>();
528 if (toRun.getDeclaringClass().isInstance(toSet))
529 possibles.add(toRun);
530 int i = 0;
531 while (_SetMethods.containsKey(attribute + i)) {
532 if (_SetMethods.get(attribute + i).getDeclaringClass()
533 .isAssignableFrom(toSet.getClass()))
534 possibles.add(_SetMethods.get(attribute + i));
535 i++;
536 }
537
538 for (Method possible : possibles) {
539 Object current = null;
540 Object[] param = {};
541 // find the corresponding get method for this set method
542 // and get the current value of the attribute
543 for (Method m : _GetMethods) {
544 if (m.getDeclaringClass().isAssignableFrom(toSet.getClass())
545 && m.getName().substring(GET_LENGTH).equals(
546 possible.getName().substring(SET_LENGTH))) {
547 try {
548 current = m.invoke(toSet, param);
549 } catch (IllegalArgumentException e) {
550 // TODO Auto-generated catch block
551 e.printStackTrace();
552 } catch (IllegalAccessException e) {
553 // TODO Auto-generated catch block
554 e.printStackTrace();
555 } catch (InvocationTargetException e) {
556 // TODO Auto-generated catch block
557 e.printStackTrace();
558 }
559 break;
560 }
561
562 }
563
564 try {
565 Object[] params = Conversion.Convert(possible, value, current);
566
567 try {
568 possible.invoke(toSet, params);
569 return true;
570 } catch (IllegalArgumentException e) {
571 // TODO Auto-generated catch block
572 e.printStackTrace();
573 } catch (IllegalAccessException e) {
574 // TODO Auto-generated catch block
575 e.printStackTrace();
576 } catch (InvocationTargetException e) {
577 FrameGraphics.DisplayMessage(toSet.getClass()
578 .getSimpleName()
579 + " type does not support that attribute.");
580 // e.printStackTrace();
581 }
582 } catch (NumberFormatException e) {
583
584 }
585 }
586
587 return false;
588 }
589
590 /**
591 * Returns the part of the given string that is after the attribute value
592 * pair separator. If that character is not there it returns empty
593 * if it is an annotation item or the entire string if it is not.
594 *
595 * @param attributeValuePair
596 * the string to get the value from.
597 * @return the value from the attribute value pair.
598 */
599 public static String getValue(String toStrip) {
600 assert (toStrip != null);
601
602 toStrip = toStrip.trim();
603 if (toStrip.length() == 0)
604 return "";
605
606 int ind = toStrip.lastIndexOf(SEPARATOR_CHAR);
607 int lineSeparator = toStrip.indexOf(Character.LINE_SEPARATOR, ind);
608 // If it is an annotation item return the empty string
609 // Annotation items can not be values only
610 if (ind < 0 && toStrip.charAt(0) == '@') {
611 return "";
612 }
613 //If its one line then our value goes to the end of the string
614 if(lineSeparator < 0)
615 lineSeparator = toStrip.length();
616
617 return toStrip.substring(ind + 1, lineSeparator).trim();
618 }
619
620 /**
621 * Returns the part of the given string that is before the attribute value
622 * pair separator, or null if the given String does not include the
623 * separator.
624 *
625 * @param attributeValuePair
626 * The String to strip
627 * @return the attribute if there is one or null if there is not
628 */
629 public static String getAttribute(String attributeValuePair) {
630 if(attributeValuePair.length() <= 1)
631 return null;
632
633 attributeValuePair = attributeValuePair.trim();
634
635 int ind = attributeValuePair.indexOf(SEPARATOR_CHAR);
636 // If its an annotation there must be no space between the @ and colon
637 // and the first character after the annotation must be a letter
638 if (attributeValuePair.charAt(0) == '@') {
639 if (!Character.isLetter(attributeValuePair.charAt(1)))
640 return null;
641 for (int i = 2; i < ind; i++) {
642 if (!Character.isLetterOrDigit(attributeValuePair.charAt(i)))
643 return null;
644 }
645 if (ind < 1)
646 return attributeValuePair.substring(0);
647 }else if (ind < 1){
648 return null;
649 }
650
651 return attributeValuePair.substring(0, ind).trim();
652 }
653
654 /**
655 * Replaces the current value for the text item with the new value.
656 *
657 * @param text
658 * the item whos value is to be changed
659 * @param newValue
660 * the new value for the item
661 */
662 public static void replaceValue(Text text, String newValue) {
663 assert (newValue != null);
664
665 String oldText = text.getFirstLine();
666 String restOfText = text.getText().substring(oldText.length());
667 String attribute = getAttribute(oldText);
668
669 if (attribute == null)
670 attribute = text.getText().trim();
671
672 text.setText(attribute + SEPARATOR_STRING + newValue + restOfText);
673 }
674
675 /**
676 * Gets the value from an attribute value pair as a double.
677 *
678 * @param attributeValuePair
679 * the text to get the value from
680 * @return the double value or null if there is none
681 */
682 public static Double getDoubleValue(String attributeValuePair) {
683 String value = getValue(attributeValuePair);
684
685 assert (value != null);
686
687 try {
688 return Double.parseDouble(value);
689 } catch (Exception e) {
690 }
691 return null;
692 }
693}
Note: See TracBrowser for help on using the repository browser.