source: trunk/src/org/expeditee/items/Justification.java@ 309

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

Added anchorRight and anchorBottom properties to items...
Fixed bugs with @i item display...
Can now inject properties into enclosed items at the same time

File size: 1.1 KB
Line 
1package org.expeditee.items;
2
3public enum Justification {
4 center, full, left, right;
5
6 /**
7 * Converts the given Expeditee justification code into a int corresponding
8 * to the constants defined in Item.
9 *
10 * @param justCode
11 * The Expeditee justification code to convert
12 * @return The resulting int corresponding to one of the constants defined
13 * in Item
14 */
15 public static Justification getJustification(String justCode) {
16 assert (justCode != null);
17 justCode = justCode.trim().toLowerCase();
18
19 // if it is a single char just match the first character
20 if (justCode.length() == 1) {
21 char code =justCode.charAt(0);
22 Justification[] values = values();
23 for(int i = 1; i < values.length; i++) {
24 Justification j = values[i];
25 if(Character.toLowerCase(j.name().charAt(0)) == code)
26 return j;
27 }
28 // Otherwise match the whole string
29 }else{
30 try{
31 return valueOf(justCode);
32 }catch (Exception e) {
33 }
34 }
35
36 // default justification
37 return left;
38 }
39
40 public char getCode() {
41 return Character.toUpperCase(this.toString().charAt(0));
42 }
43
44 public String toString() {
45 return this.name();
46 }
47}
Note: See TracBrowser for help on using the repository browser.