View Javadoc

1   /*
2    * Copyright (c) 2005, Mike Heath
3    * All rights reserved.
4    * 
5    * Redistribution and use in source and binary forms, with or without modification, are permitted
6    * provided that the following conditions are met:
7    * 
8    *     * Redistributions of source code must retain the above copyright notice, this list of conditions
9    *       and the following disclaimer.
10   *     * Redistributions in binary form must reproduce the above copyright notice, this list of
11   *       conditions and the following disclaimer in the documentation and/or other materials provided
12   *       with the distribution.
13   *     * The names of its contributors may not be used to endorse or promote products derived from this
14   *       software without specific prior written permission.
15   * 
16   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27   */
28  package net.sf.cssbean;
29  
30  import java.net.URI;
31  import java.net.URISyntaxException;
32  import java.util.Arrays;
33  import java.util.Collections;
34  import java.util.HashSet;
35  import java.util.Set;
36  import java.util.regex.Matcher;
37  import java.util.regex.Pattern;
38  
39  /***
40   * @author Mike Heath <elcapo@gmail.com>
41   * 
42   * TODO Add BSD license to Maven build.
43   * TODO Add cursor field
44   * TODO Add List and Marker styles
45   * TODO Add Margin styles
46   * TODO Add Outlines styles
47   * TODO Add Padding styles
48   * TODO Add Positioning styles
49   * TODO Add Table styles
50   */
51  public class CSSBean {
52  
53  	// Background styles
54  	public static final String STYLE_BACKGROUND =            "background";
55  	public static final String STYLE_BACKGROUND_ATTACHMENT = "background-attachment";
56  	public static final String STYLE_BACKGROUND_COLOR =      "background-color";
57  	public static final String STYLE_BACKGROUND_IMAGE =      "background-image";
58  	public static final String STYLE_BACKGROUND_POSITION =   "background-position";
59  	public static final String STYLE_BACKGROUND_REPEAT =     "background-repeat";
60  	
61  	// Border styles
62  	public static final String STYLE_BORDER =              "border";
63  	public static final String STYLE_BORDER_BOTTOM =       "border-bottom";
64  	public static final String STYLE_BORDER_LEFT =         "border-left";
65  	public static final String STYLE_BORDER_RIGHT =        "border-right";
66  	public static final String STYLE_BORDER_TOP =          "border-top";
67  	public static final String STYLE_BORDER_COLOR =        "border-color";
68  	public static final String STYLE_BORDER_STYLE =        "border-style";
69  	public static final String STYLE_BORDER_WIDTH =        "border-width";
70  	public static final String STYLE_BORDER_BOTTOM_COLOR = "border-bottom-color";
71  	public static final String STYLE_BORDER_BOTTOM_STYLE = "border-bottom-style";
72  	public static final String STYLE_BORDER_BOTTOM_WIDTH = "border-bottom-width";
73  	public static final String STYLE_BORDER_LEFT_COLOR =   "border-left-color";
74  	public static final String STYLE_BORDER_LEFT_STYLE =   "border-left-style";
75  	public static final String STYLE_BORDER_LEFT_WIDTH =   "border-left-width";
76  	public static final String STYLE_BORDER_RIGHT_COLOR =  "border-right-color";
77  	public static final String STYLE_BORDER_RIGHT_STYLE =  "border-right-style";
78  	public static final String STYLE_BORDER_RIGHT_WIDTH =  "border-right-width";
79  	public static final String STYLE_BORDER_TOP_COLOR =    "border-top-color";
80  	public static final String STYLE_BORDER_TOP_STYLE =    "border-top-style";
81  	public static final String STYLE_BORDER_TOP_WIDTH =    "border-top-width";
82  
83  	// Classification Styles
84  	public static final String STYLE_CLEAR = "clear";
85  	public static final String STYLE_DISPLAY = "display";
86  	public static final String STYLE_FLOAT = "float";
87  	public static final String STYLE_POSITION = "position";
88  	public static final String STYLE_VISIBILITY = "visibility";
89  	
90  	// Dimension Styles
91  	public static final String STYLE_HEIGHT      = "height";
92  	public static final String STYLE_LINE_HEIGHT = "line-height";
93  	public static final String STYLE_MAX_HEIGHT  = "max-height";
94  	public static final String STYLE_MAX_WIDTH   = "max-width";
95  	public static final String STYLE_MIN_HEIGHT  = "min-height";
96  	public static final String STYLE_MIN_WIDTH   = "min-width";
97  	public static final String STYLE_WIDTH       = "width";
98  	
99  	// Font Styles
100 	public static final String STYLE_FONT = "font";
101 	public static final String STYLE_FONT_FAMILY = "font-family";
102 	public static final String STYLE_FONT_SIZE = "font-size";
103 	public static final String STYLE_FONT_SIZE_ADJUST = "font-size-adjust";
104 	public static final String STYLE_FONT_STRETCH = "font-stretch";
105 	public static final String STYLE_FONT_STYLE = "font-style";
106 	public static final String STYLE_FONT_VARIANT = "font-variant";
107 	public static final String STYLE_FONT_WEIGHT = "font-weight";
108 	
109 	// Text Styles
110 	public static final String STYLE_COLOR = "color";
111 	public static final String STYLE_DIRECTION = "direction";
112 	public static final String STYLE_LETTER_SPACING = "letter-spacing";
113 	public static final String STYLE_TEXT_ALIGN = "text-align";
114 	public static final String STYLE_TEXT_DECORATION = "text-decoration";
115 	public static final String STYLE_TEXT_INDENT = "text-indent";
116 	public static final String STYLE_TEXT_SHADOW = "text-shadow";
117 	public static final String STYLE_TEXT_TRANSFORM = "text-transform";
118 	public static final String STYLE_WHITE_SPACE = "white-space";
119 	public static final String STYLE_WORD_SPACING = "word-spacing";
120 	
121 	// Colors
122 	public static final String COLOR_TRANSPARENT = "transparent";
123 	// TODO Add all color strings here and add to validation
124 	
125 	// Font sizes
126 	public static final String FONT_SIZE_XX_SMALL = "xx-small";
127 	public static final String FONT_SIZE_X_SMALL = "x-small";
128 	public static final String FONT_SIZE_SMALL = "small";
129 	public static final String FONT_SIZE_MEDIUM = "medium";
130 	public static final String FONT_SIZE_LARGE = "large";
131 	public static final String FONT_SIZE_X_LARGE = "x-large";
132 	public static final String FONT_SIZE_XX_LARGE = "xx-large";
133 	public static final String FONT_SIZE_SMALLER = "smaller";
134 	public static final String FONT_SIZE_LARGER = "larger";
135 	
136 	public static final String FONT_SIZE_ADJUST_NONE = "none";
137 	
138 	// Lengths
139 	private static final String[] units = new String[] {
140 		"in",
141 		"cm",
142 		"mm",
143 		"em",
144 		"ex",
145 		"pt",
146 		"pc",
147 		"px"
148 	};
149 	public static final Set<String> LENGTH_UNITS = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(units)));
150 	public static final String LENGTH_AUTO = "auto";
151 	public static final String LENGTH_NONE = "none";
152 	public static final String LENGTH_NORMAL = "normal";
153 	
154 	// Positions
155 	public static final String POSITION_TOP_LEFT = "top left";
156 	public static final String POSITION_TOP_CENTER = "top center";
157 	public static final String POSITION_TOP_RIGHT = "top right";
158 	public static final String POSITION_CENTER_LEFT = "center left";
159 	public static final String POSITION_CENTER_CENTER = "center center";
160 	public static final String POSITION_CENTER_RIGHT = "center right";
161 	public static final String POSITION_BOTTOM_LEFT = "bottom left";
162 	public static final String POSITION_BOTTOM_CENTER = "bottom center";
163 	public static final String POSITION_BOTTOM_RIGHT = "bottom right";
164 	
165 	// Text
166 	public static final String TEXT_LETTER_SPACING_NORMAL = "normal";
167 	public static final String TEXT_SHADOW_NONE = "none";
168 	public static final String TEXT_WORD_SPACING_NORMAL = "normal";
169 	
170 	// URL
171 	public static final URI URL_NONE;
172 	
173 	// Widths
174 	public static final String WIDTH_THIN = "thin";
175 	public static final String WIDTH_MEDIUM = "medium";
176 	public static final String WIDTH_THICK = "thick";
177 	
178 	private static Pattern hashColorPattern = Pattern.compile("(^#[0-9a-fA-F]{3}$)|(^#[0-9a-fA-F]{6}$)");
179 	private static Pattern rgbColorPatter = Pattern.compile("^rgb//(//s*(.{1,10})//s*,//s*(.{1,10})//s*,//s*(.{1,10})//s*//)$");
180 	
181 	static {
182 		try {
183 			URL_NONE = new URI("____________________NONE____________");
184 		} catch (URISyntaxException e) {
185 			throw new RuntimeException(e);
186 		}
187 	}
188 	
189 	// Class properties
190 	private boolean validationEnabled = true;
191 	private boolean shortHandProperties = true;
192 	
193 	// Background
194 	private BackgroundAttachment backgroundAttachment;
195 	private String backgroundColor;
196 	private URI backgroundImage;
197 	private String backgroundPosition;
198 	private BackgroundRepeat backgroundRepeat;
199 
200 	// Border
201 	private String borderBottomColor;
202 	private BorderStyle borderBottomStyle;
203 	private String borderBottomWidth;
204 	private String borderColor;
205 	private String borderLeftColor;
206 	private BorderStyle borderLeftStyle;
207 	private String borderLeftWidth;
208 	private String borderRightColor;
209 	private BorderStyle borderRightStyle;
210 	private String borderRightWidth;
211 	private BorderStyle borderStyle;
212 	private String borderTopColor;
213 	private BorderStyle borderTopStyle;
214 	private String borderTopWidth;
215 	private String borderWidth;
216 	
217 	// Classification
218 	private SidePosition clear;
219 	private Display display;
220 	private FloatPosition float_;
221 	private Position position;
222 	private Visibility visibility;
223 	
224 	// Dimension
225 	private String height;
226 	private String lineHeight;
227 	private String maxHeight;
228 	private String maxWidth;
229 	private String minHeight;
230 	private String minWidth;
231 	private String width;
232 	
233 	// Font
234 	private String fontFamily;
235 	private String fontSize;
236 	private String fontSizeAdjust;
237 	private FontStretch fontStretch;
238 	private Style fontStyle;
239 	private Variant fontVariant;
240 	private Weight fontWeight;
241 	
242 	// List and Marker
243 	private URI listStyleImage;
244 	private ListStylePosition listStylePosition;
245 	private ListStyleType listStyleType;
246 	
247 	// Margin
248 	private String marginBottom;
249 	private String marginLeft;
250 	private String marginRight;
251 	private String marginTop;
252 	
253 	// Padding
254 	private String paddingBottom;
255 	private String paddingLeft;
256 	private String paddingRight;
257 	private String paddingTop;
258 	
259 	// Positioning
260 	private String verticalAlign;
261 	
262 	// Text
263 	private String color;
264 	private Direction direction;
265 	private String letterSpacing;
266 	private TextAlign textAlign;
267 	private TextDecoration textDecoration;
268 	private String textIndent;
269 	private String textShadow;
270 	private TextTransform textTransform;
271 	private WhiteSpace whiteSpace;
272 	private String wordSpacing;
273 	
274 	protected static boolean isColor(String color) {
275 		Matcher matcher = hashColorPattern.matcher(color);
276 		if (matcher.matches()) {
277 			return true;
278 		}
279 
280 		matcher = rgbColorPatter.matcher(color);
281 		if (matcher.matches()) {
282 			String r = matcher.group(1);
283 			String g = matcher.group(2);
284 			String b = matcher.group(3);
285 			if (
286 					(isInteger(r) && isInteger(g) && isInteger(b)) ||
287 					(isPercent(r) && isPercent(g) && isPercent(b))) {
288 				return true;
289 			}
290 		}
291 		
292 		return false;
293 	}
294 	
295 	protected static boolean isInteger(String val) {
296 		try {
297 			Integer.parseInt(val);
298 			return true;
299 		} catch (NumberFormatException e) {
300 			return false;
301 		}
302 	}
303 	
304 	protected static boolean isLength(String length) {
305 		if (length.length() < 2) {
306 			return false;
307 		}
308 		if (isPercent(length)) {
309 			return true;
310 		}
311 		length = length.trim();
312 		String unit = length.substring(length.length() - 2);
313 		if (LENGTH_UNITS.contains(unit)) {
314 			String value = length.substring(0, length.length() - 2);
315 			// If there's white-space between the value and the unit, return false
316 			if (!value.trim().equals(value)) {
317 				return false;
318 			}
319 			try {
320 				Double.parseDouble(value);
321 				return true;
322 			} catch (NumberFormatException e) {
323 				return false;
324 			}
325 		}
326 		return false;
327 	}
328 	
329 	protected static boolean isPercent(String val) {
330 		val = val.trim();
331 		if (val.endsWith("%")) {
332 			try {
333 				Double.parseDouble(val.substring(0, val.length() - 1));
334 				return true;
335 			} catch (NumberFormatException e) {
336 				return false;
337 			}
338 		}
339 		return false;
340 	}
341 
342 	protected void checkColor(String color) {
343 		if (validationEnabled && color != null && !isColor(color)) {
344 			throw new ValueException("Not a valid color: " + color);
345 		}
346 	}
347 	
348 	protected String trimString(String str) {
349 		if (str != null) {
350 			if (str.length() == 0) {
351 				return null;
352 			} else {
353 				return str.trim();
354 			}
355 		}
356 		return str;
357 	}
358 	
359 	protected void checkBorderWidth(String width) {
360 		if (
361 			validationEnabled
362 			&& width != null
363 			&& !WIDTH_THIN.equals(width)
364 			&& !WIDTH_MEDIUM.equals(width)
365 			&& !WIDTH_THICK.equals(width)
366 			&& !isLength(width)
367 			) {
368 			throw new ValueException("Not a valid border width: " + width);
369 		}
370 	}
371 	
372 	/***
373 	 * @return Returns the shortHandProperties.
374 	 */
375 	public boolean isShortHandProperties() {
376 		return shortHandProperties;
377 	}
378 	/***
379 	 * @param shortHandProperties The shortHandProperties to set.
380 	 */
381 	public void setShortHandProperties(boolean shortHandProperties) {
382 		this.shortHandProperties = shortHandProperties;
383 	}
384 	// Background getter/setters
385 	
386 	/***
387 	 * Gets whether a background image is fixed or scrolls with the rest of the page.
388 	 * 
389 	 * @return Returns the background-attachment.
390 	 */
391 	public BackgroundAttachment getBackgroundAttachment() {
392 		return backgroundAttachment;
393 	}
394 	/***
395 	 * Sets whether a background image is fixed or scrolls with the rest of the page.
396 	 * 
397 	 * @param backgroundAttachment The background-attachment to set.
398 	 */
399 	public void setBackgroundAttachment(BackgroundAttachment backgroundAttachment) {
400 		this.backgroundAttachment = backgroundAttachment;
401 	}
402 	
403 	/***
404 	 * Gets the background color of an element.
405 	 * 
406 	 * @return Returns the background-color.
407 	 */
408 	public String getBackgroundColor() {
409 		return backgroundColor;
410 	}
411 	/***
412 	 * Sets the background color of an element.
413 	 * 
414 	 * @param backgroundColor The background-color to set.
415 	 */
416 	public void setBackgroundColor(String backgroundColor) {
417 		backgroundColor = trimString(backgroundColor);
418 		checkColor(backgroundColor);
419 		this.backgroundColor = backgroundColor;
420 	}
421 	
422 	/***
423 	 * Gets the background image.
424 	 * 
425 	 * @return Returns the background-image.
426 	 */
427 	public URI getBackgroundImage() {
428 		return backgroundImage;
429 	}
430 	/***
431 	 * Sets the background image.
432 	 * 
433 	 * @param backgroundImage The background-image to set.
434 	 */
435 	public void setBackgroundImage(URI backgroundImage) {
436 		this.backgroundImage = backgroundImage;
437 	}
438 	/***
439 	 * Gets the starting position of a background image.
440 	 * 
441 	 * @return Returns the background-position.
442 	 */
443 	public String getBackgroundPosition() {
444 		return backgroundPosition;
445 	}
446 	/***
447 	 * Sets the starting position of a background image.
448 	 * 
449 	 * @param backgroundPosition The background-position to set.
450 	 */
451 	public void setBackgroundPosition(String backgroundPosition) {
452 		backgroundPosition = trimString(backgroundPosition);
453 		if (
454 			validationEnabled
455 			&& backgroundPosition != null
456 			&& !POSITION_TOP_LEFT.equals(backgroundPosition)
457 			&& !POSITION_TOP_CENTER.equals(backgroundPosition)
458 			&& !POSITION_TOP_RIGHT.equals(backgroundPosition)
459 			&& !POSITION_CENTER_LEFT.equals(backgroundPosition)
460 			&& !POSITION_CENTER_CENTER.equals(backgroundPosition)
461 			&& !POSITION_CENTER_RIGHT.equals(backgroundPosition)
462 			&& !POSITION_BOTTOM_LEFT.equals(backgroundPosition)
463 			&& !POSITION_BOTTOM_CENTER.equals(backgroundPosition)
464 			&& !POSITION_BOTTOM_RIGHT.equals(backgroundPosition)
465 			) {
466 			backgroundPosition = backgroundPosition.trim();
467 			String[] xy = backgroundPosition.split("//s+");
468 			if (xy.length != 2) {
469 				throw new ValueException("backgroundPosition value '" + backgroundPosition + "'is not valid");
470 			}
471 			if (!(isLength(xy[0]) && isLength(xy[1]))) {
472 				throw new ValueException("backgroundPosition value '" + backgroundPosition + "'is not valid");
473 			}
474 		}
475 		this.backgroundPosition = backgroundPosition;
476 	}
477 	/***
478 	 * Gets if/how a background image will be repeated.
479 	 * 
480 	 * @return Returns the background-repeat.
481 	 */
482 	public BackgroundRepeat getBackgroundRepeat() {
483 		return backgroundRepeat;
484 	}
485 	/***
486 	 * Sets if/how a background image will be repeated.
487 	 * 
488 	 * @param backgroundRepeat The background-repeat to set.
489 	 */
490 	public void setBackgroundRepeat(BackgroundRepeat backgroundRepeat) {
491 		this.backgroundRepeat = backgroundRepeat;
492 	}
493 	// Border getters and setters
494 	/***
495 	 * Gets the color of the bottom border.
496 	 * 
497 	 * @return Returns the borderBottomColor.
498 	 */
499 	public String getBorderBottomColor() {
500 		return borderBottomColor;
501 	}
502 	/***
503 	 * Sets the color of the bottom border.
504 	 * 
505 	 * @param borderBottomColor The borderBottomColor to set.
506 	 */
507 	public void setBorderBottomColor(String borderBottomColor) {
508 		borderBottomColor = trimString(borderBottomColor);
509 		checkColor(borderBottomColor);
510 		this.borderBottomColor = borderBottomColor;
511 	}
512 	/***
513 	 * Gets the style of the bottom border.
514 	 * 
515 	 * @return Returns the borderBottomStyle.
516 	 */
517 	public BorderStyle getBorderBottomStyle() {
518 		return borderBottomStyle;
519 	}
520 	/***
521 	 * Sets the style of the bottom border.
522 	 * 
523 	 * @param borderBottomStyle The borderBottomStyle to set.
524 	 */
525 	public void setBorderBottomStyle(BorderStyle borderBottomStyle) {
526 		this.borderBottomStyle = borderBottomStyle;
527 	}
528 	/***
529 	 * Gets the width of the bottom border.
530 	 * 
531 	 * @return Returns the borderBottomWidth.
532 	 */
533 	public String getBorderBottomWidth() {
534 		return borderBottomWidth;
535 	}
536 	/***
537 	 * Sets the width of the bottom border.
538 	 * 
539 	 * @param borderBottomWidth The borderBottomWidth to set.
540 	 */
541 	public void setBorderBottomWidth(String borderBottomWidth) {
542 		borderBottomWidth = trimString(borderBottomWidth);
543 		checkBorderWidth(borderBottomWidth);
544 		this.borderBottomWidth = borderBottomWidth;
545 	}
546 	/***
547 	 * Gets the color of the four borders, can have from one to four colors.
548 	 * 
549 	 * @return Returns the borderColor.
550 	 */
551 	public String getBorderColor() {
552 		return borderColor;
553 	}
554 	/***
555 	 * Sets the color of the four borders, can have from one to four colors.
556 	 * 
557 	 * @param borderColor The borderColor to set.
558 	 */
559 	public void setBorderColor(String borderColor) {
560 		borderColor = trimString(borderColor);
561 		checkColor(borderColor);
562 		this.borderColor = borderColor;
563 	}
564 	/***
565 	 * Gets the color of the left border.
566 	 * 
567 	 * @return Returns the borderLeftColor.
568 	 */
569 	public String getBorderLeftColor() {
570 		return borderLeftColor;
571 	}
572 	/***
573 	 * Sets the color of the left border.
574 	 * 
575 	 * @param borderLeftColor The borderLeftColor to set.
576 	 */
577 	public void setBorderLeftColor(String borderLeftColor) {
578 		borderLeftColor = trimString(borderLeftColor);
579 		checkColor(borderLeftColor);
580 		this.borderLeftColor = borderLeftColor;
581 	}
582 	/***
583 	 * Gets the style of the left border.
584 	 * 
585 	 * @return Returns the borderLeftStyle.
586 	 */
587 	public BorderStyle getBorderLeftStyle() {
588 		return borderLeftStyle;
589 	}
590 	/***
591 	 * Sets the style of the left border.
592 	 * 
593 	 * @param borderLeftStyle The borderLeftStyle to set.
594 	 */
595 	public void setBorderLeftStyle(BorderStyle borderLeftStyle) {
596 		this.borderLeftStyle = borderLeftStyle;
597 	}
598 	/***
599 	 * Gets the width of the left border.
600 	 * 
601 	 * @return Returns the borderLeftWidth.
602 	 */
603 	public String getBorderLeftWidth() {
604 		return borderLeftWidth;
605 	}
606 	/***
607 	 * Sets the width of the left border.
608 	 * 
609 	 * @param borderLeftWidth The borderLeftWidth to set.
610 	 */
611 	public void setBorderLeftWidth(String borderLeftWidth) {
612 		borderLeftWidth = trimString(borderLeftWidth);
613 		checkBorderWidth(borderLeftWidth);
614 		this.borderLeftWidth = borderLeftWidth;
615 	}
616 	/***
617 	 * Gets the color of the right border.
618 	 * 
619 	 * @return Returns the borderRightColor.
620 	 */
621 	public String getBorderRightColor() {
622 		return borderRightColor;
623 	}
624 	/***
625 	 * Sets the color of the right border.
626 	 * 
627 	 * @param borderRightColor The borderRightColor to set.
628 	 */
629 	public void setBorderRightColor(String borderRightColor) {
630 		borderRightColor = trimString(borderRightColor);
631 		checkColor(this.borderRightColor);
632 		this.borderRightColor = borderRightColor;
633 	}
634 	/***
635 	 * Gets the style of the right border.
636 	 * 
637 	 * @return Returns the borderRightStyle.
638 	 */
639 	public BorderStyle getBorderRightStyle() {
640 		return borderRightStyle;
641 	}
642 	/***
643 	 * Sets the style of the right border.
644 	 * 
645 	 * @param borderRightStyle The borderRightStyle to set.
646 	 */
647 	public void setBorderRightStyle(BorderStyle borderRightStyle) {
648 		this.borderRightStyle = borderRightStyle;
649 	}
650 	/***
651 	 * Gets the width of the right border.
652 	 * 
653 	 * @return Returns the borderRightWidth.
654 	 */
655 	public String getBorderRightWidth() {
656 		return borderRightWidth;
657 	}
658 	/***
659 	 * Sets the width of the right border.
660 	 * 
661 	 * @param borderRightWidth The borderRightWidth to set.
662 	 */
663 	public void setBorderRightWidth(String borderRightWidth) {
664 		borderRightWidth = trimString(borderRightWidth);
665 		checkBorderWidth(borderRightWidth);
666 		this.borderRightWidth = borderRightWidth;
667 	}
668 	/***
669 	 * Gets the style of the four borders.
670 	 * 
671 	 * @return Returns the borderStyle.
672 	 */
673 	public BorderStyle getBorderStyle() {
674 		return borderStyle;
675 	}
676 	/***
677 	 * Sets the style of the four borders.
678 	 * 
679 	 * @param borderStyle The borderStyle to set.
680 	 */
681 	public void setBorderStyle(BorderStyle borderStyle) {
682 		this.borderStyle = borderStyle;
683 	}
684 	/***
685 	 * Gets the color of the top border.
686 	 * 
687 	 * @return Returns the borderTopColor.
688 	 */
689 	public String getBorderTopColor() {
690 		return borderTopColor;
691 	}
692 	/***
693 	 * Sets the color of the top border.
694 	 * 
695 	 * @param borderTopColor The borderTopColor to set.
696 	 */
697 	public void setBorderTopColor(String borderTopColor) {
698 		borderTopColor = trimString(borderTopColor);
699 		checkColor(borderTopColor);
700 		this.borderTopColor = borderTopColor;
701 	}
702 	/***
703 	 * Gets the style of the top border.
704 	 * 
705 	 * @return Returns the borderTopStyle.
706 	 */
707 	public BorderStyle getBorderTopStyle() {
708 		return borderTopStyle;
709 	}
710 	/***
711 	 * Sets the style of the top border.
712 	 * 
713 	 * @param borderTopStyle The borderTopStyle to set.
714 	 */
715 	public void setBorderTopStyle(BorderStyle borderTopStyle) {
716 		this.borderTopStyle = borderTopStyle;
717 	}
718 	/***
719 	 * Gets the width of the top border.
720 	 * 
721 	 * @return Returns the borderTopWidth.
722 	 */
723 	public String getBorderTopWidth() {
724 		return borderTopWidth;
725 	}
726 	/***
727 	 * Sets the width of the top border.
728 	 * 
729 	 * @param borderTopWidth The borderTopWidth to set.
730 	 */
731 	public void setBorderTopWidth(String borderTopWidth) {
732 		borderTopWidth = trimString(borderTopWidth);
733 		checkBorderWidth(borderTopWidth);
734 		this.borderTopWidth = borderTopWidth;
735 	}
736 	/***
737 	 * Gets the width of the four borders.
738 	 * 
739 	 * @return Returns the borderWidth.
740 	 */
741 	public String getBorderWidth() {
742 		return borderWidth;
743 	}
744 	/***
745 	 * Sets the width of the four borders.
746 	 * 
747 	 * @param borderWidth The borderWidth to set.
748 	 */
749 	public void setBorderWidth(String borderWidth) {
750 		borderWidth = trimString(borderWidth);
751 		checkBorderWidth(borderWidth);
752 		this.borderWidth = borderWidth;
753 	}
754 	// --- Classification Getters and Setters -------------------------------------------------------------------------
755 	/***
756 	 * @return Returns the clear.
757 	 */
758 	public SidePosition getClear() {
759 		return clear;
760 	}
761 	/***
762 	 * @param clear The clear to set.
763 	 */
764 	public void setClear(SidePosition clear) {
765 		this.clear = clear;
766 	}
767 	/***
768 	 * @return Returns the display.
769 	 */
770 	public Display getDisplay() {
771 		return display;
772 	}
773 	/***
774 	 * @param display The display to set.
775 	 */
776 	public void setDisplay(Display display) {
777 		this.display = display;
778 	}
779 	/***
780 	 * @return Returns the float_.
781 	 */
782 	public FloatPosition getFloat() {
783 		return float_;
784 	}
785 	/***
786 	 * @param float_ The float_ to set.
787 	 */
788 	public void setFloat(FloatPosition float_) {
789 		this.float_ = float_;
790 	}
791 	/***
792 	 * @return Returns the position.
793 	 */
794 	public Position getPosition() {
795 		return position;
796 	}
797 	/***
798 	 * @param position The position to set.
799 	 */
800 	public void setPosition(Position position) {
801 		this.position = position;
802 	}
803 	/***
804 	 * @return Returns the visibility.
805 	 */
806 	public Visibility getVisibility() {
807 		return visibility;
808 	}
809 	/***
810 	 * @param visibility The visibility to set.
811 	 */
812 	public void setVisibility(Visibility visibility) {
813 		this.visibility = visibility;
814 	}
815 	
816 	// --- Dimension getters and setters ------------------------------------------------------------------------------
817 	/***
818 	 * Gets the height of an element.
819 	 * 
820 	 * @return Returns the height.
821 	 */
822 	public String getHeight() {
823 		return height;
824 	}
825 	/***
826 	 * Sets the height of an element.
827 	 * 
828 	 * @param height The height to set.
829 	 */
830 	public void setHeight(String height) {
831 		height = trimString(height);
832 		if (validationEnabled && height != null && !LENGTH_AUTO.equals(height) && !isLength(height)) {
833 			throw new ValueException("Not a valid height: " + height);
834 		}
835 		this.height = height;
836 	}
837 	/***
838 	 * Gets the distance between lines.
839 	 * 
840 	 * @return Returns the lineHeight.
841 	 */
842 	public String getLineHeight() {
843 		return lineHeight;
844 	}
845 	/***
846 	 * Sets the distance between lines.
847 	 * 
848 	 * @param lineHeight The lineHeight to set.
849 	 */
850 	public void setLineHeight(String lineHeight) {
851 		lineHeight = trimString(lineHeight);
852 		if (validationEnabled && lineHeight != null && !LENGTH_NORMAL.equals(lineHeight) && !isLength(lineHeight)) {
853 			throw new ValueException("Not a valid height: " + lineHeight);
854 		}
855 		this.lineHeight = lineHeight;
856 	}
857 	/***
858 	 * Gets the maximum height of an element.
859 	 * 
860 	 * @return Returns the maxHeight.
861 	 */
862 	public String getMaxHeight() {
863 		return maxHeight;
864 	}
865 	/***
866 	 * Sets the maximum height of an element.
867 	 * 
868 	 * @param maxHeight The maxHeight to set.
869 	 */
870 	public void setMaxHeight(String maxHeight) {
871 		maxHeight = trimString(maxHeight);
872 		if (validationEnabled && maxHeight != null && !LENGTH_NONE.equals(maxHeight) && !isLength(maxHeight)) {
873 			throw new ValueException("Not a valid max-height: " + maxHeight);
874 		}
875 		this.maxHeight = maxHeight;
876 	}
877 	/***
878 	 * Gets the maximum width of an element.
879 	 * 
880 	 * @return Returns the maxWidth.
881 	 */
882 	public String getMaxWidth() {
883 		return maxWidth;
884 	}
885 	/***
886 	 * Sets the maximum width of an element.
887 	 * 
888 	 * @param maxWidth The maxWidth to set.
889 	 */
890 	public void setMaxWidth(String maxWidth) {
891 		maxWidth = trimString(maxWidth);
892 		if (validationEnabled && maxWidth != null && !LENGTH_NONE.equals(maxWidth) && !isLength(maxWidth)) {
893 			throw new ValueException("Not a valid max-width: " + maxWidth);
894 		}
895 		this.maxWidth = maxWidth;
896 	}
897 	/***
898 	 * Gets the minimum height of an element.
899 	 * 
900 	 * @return Returns the minHeight.
901 	 */
902 	public String getMinHeight() {
903 		return minHeight;
904 	}
905 	/***
906 	 * Sets the minimum height of an element.
907 	 * 
908 	 * @param minHeight The minHeight to set.
909 	 */
910 	public void setMinHeight(String minHeight) {
911 		minHeight = trimString(minHeight);
912 		if (validationEnabled && minHeight != null && !isLength(minHeight)) {
913 			throw new ValueException("Not a valid min-height: " + minHeight);
914 		}
915 		this.minHeight = minHeight;
916 	}
917 	/***
918 	 * Gets the minimum width of an element.
919 	 * 
920 	 * @return Returns the minWidth.
921 	 */
922 	public String getMinWidth() {
923 		return minWidth;
924 	}
925 	/***
926 	 * Sets the minimum width of an element.
927 	 * 
928 	 * @param minWidth The minWidth to set.
929 	 */
930 	public void setMinWidth(String minWidth) {
931 		minWidth = trimString(minWidth);
932 		if (validationEnabled && minWidth != null && !isLength(minWidth)) {
933 			throw new ValueException("Not a valid min-height: " + minWidth);
934 		}
935 		this.minWidth = minWidth;
936 	}
937 	/***
938 	 * Gets the width of an element.
939 	 * 
940 	 * @return Returns the width.
941 	 */
942 	public String getWidth() {
943 		return width;
944 	}
945 	/***
946 	 * Sets the width of an element.
947 	 * 
948 	 * @param width The width to set.
949 	 */
950 	public void setWidth(String width) {
951 		width = trimString(width);
952 		if (validationEnabled && width != null && !LENGTH_AUTO.equals(width) && !isLength(width)) {
953 			throw new ValueException("Not a valid width: " + width);
954 		}
955 		this.width = width;
956 	}
957 	
958 	// --- Font Getters and setters -----------------------------------------------------------------------------------
959 	
960 	/***
961 	 * Gets the prioritized list of font family names and/or generic family names for an element.
962 	 * 
963 	 * @return Returns the fontFamily.
964 	 */
965 	public String getFontFamily() {
966 		return fontFamily;
967 	}
968 
969 	/***
970 	 * Sets the prioritized list of font family names and/or generic family names for an element.
971 	 * 
972 	 * @param fontFamily The fontFamily to set.
973 	 */
974 	public void setFontFamily(String fontFamily) {
975 		fontFamily = trimString(fontFamily);
976 		this.fontFamily = fontFamily;
977 	}
978 
979 	/***
980 	 * Gets the size of a font.
981 	 * 
982 	 * @return Returns the fontSize.
983 	 */
984 	public String getFontSize() {
985 		return fontSize;
986 	}
987 
988 	/***
989 	 * Sets the size of a font.
990 	 * 
991 	 * @param fontSize The fontSize to set.
992 	 */
993 	public void setFontSize(String fontSize) {
994 		fontSize = trimString(fontSize);
995 		if (validationEnabled
996 				&& fontSize != null
997 				&& !FONT_SIZE_XX_SMALL.equals(fontSize)
998 				&& !FONT_SIZE_X_SMALL.equals(fontSize)
999 				&& !FONT_SIZE_SMALL.equals(fontSize)
1000 				&& !FONT_SIZE_MEDIUM.equals(fontSize)
1001 				&& !FONT_SIZE_LARGE.equals(fontSize)
1002 				&& !FONT_SIZE_X_LARGE.equals(fontSize)
1003 				&& !FONT_SIZE_XX_LARGE.equals(fontSize)
1004 				&& !FONT_SIZE_SMALLER.equals(fontSize)
1005 				&& !FONT_SIZE_LARGER.equals(fontSize)
1006 				&& !isLength(fontSize)
1007 				) {
1008 			throw new ValueException("'" + fontSize + "' is not a valid font size");
1009 		}
1010 		this.fontSize = fontSize;
1011 	}
1012 
1013 	/***
1014 	 * Specifies an aspect value for an element that will preserve the x-height of the first-choice font.
1015 	 * 
1016 	 * @return Returns the fontSizeAdjust.
1017 	 */
1018 	public String getFontSizeAdjust() {
1019 		return fontSizeAdjust;
1020 	}
1021 
1022 	/***
1023 	 * Specifies an aspect value for an element that will preserve the x-height of the first-choice font.
1024 	 * 
1025 	 * @param fontSizeAdjust The fontSizeAdjust to set.
1026 	 */
1027 	public void setFontSizeAdjust(String fontSizeAdjust) {
1028 		fontSizeAdjust = trimString(fontSizeAdjust);
1029 		if (validationEnabled
1030 				&& fontSizeAdjust != null
1031 				&& !FONT_SIZE_ADJUST_NONE.equals(fontSizeAdjust)
1032 				&& isInteger(fontSizeAdjust)) {
1033 			throw new ValueException("'" + fontSizeAdjust + "' is not a valid fontSize");
1034 		}
1035 		this.fontSizeAdjust = fontSizeAdjust;
1036 	}
1037 
1038 	/***
1039 	 * Condenses or expands the current font-family.
1040 	 * 
1041 	 * @return Returns the fontStretch.
1042 	 */
1043 	public FontStretch getFontStretch() {
1044 		return fontStretch;
1045 	}
1046 
1047 	/***
1048 	 * Condenses or expands the current font-family.
1049 	 * 
1050 	 * @param fontStretch The fontStretch to set.
1051 	 */
1052 	public void setFontStretch(FontStretch fontStretch) {
1053 		this.fontStretch = fontStretch;
1054 	}
1055 
1056 	/***
1057 	 * Gets the style of the font.
1058 	 * 
1059 	 * @return Returns the fontStyle.
1060 	 */
1061 	public Style getFontStyle() {
1062 		return fontStyle;
1063 	}
1064 
1065 	/***
1066 	 * Sets the style of the font.
1067 	 * 
1068 	 * @param fontStyle The fontStyle to set.
1069 	 */
1070 	public void setFontStyle(Style fontStyle) {
1071 		this.fontStyle = fontStyle;
1072 	}
1073 
1074 	/***
1075 	 * Displays text in a small-caps font or a normal font.
1076 	 * 
1077 	 * @return Returns the fontVariant.
1078 	 */
1079 	public Variant getFontVariant() {
1080 		return fontVariant;
1081 	}
1082 
1083 	/***
1084 	 * Displays text in a small-caps font or a normal font.
1085 	 * 
1086 	 * @param fontVariant The fontVariant to set.
1087 	 */
1088 	public void setFontVariant(Variant fontVariant) {
1089 		this.fontVariant = fontVariant;
1090 	}
1091 
1092 	/***
1093 	 * Sets the weight of a font.
1094 	 * 
1095 	 * @return Returns the fontWeight.
1096 	 */
1097 	public Weight getFontWeight() {
1098 		return fontWeight;
1099 	}
1100 
1101 	/***
1102 	 * Sets the weight of a font.
1103 	 * 
1104 	 * @param fontWeight The fontWeight to set.
1105 	 */
1106 	public void setFontWeight(Weight fontWeight) {
1107 		this.fontWeight = fontWeight;
1108 	}
1109 
1110 	// --- Text getters and setters -----------------------------------------------------------------------------------
1111 	
1112 	/***
1113 	 * Gets the color of a text.
1114 	 * 
1115 	 * @return Returns the color.
1116 	 */
1117 	public String getColor() {
1118 		return color;
1119 	}
1120 
1121 	/***
1122 	 * Sets the color of a text.
1123 	 * 
1124 	 * @param color The color to set.
1125 	 */
1126 	public void setColor(String color) {
1127 		color = trimString(color);
1128 		checkColor(color);
1129 		this.color = color;
1130 	}
1131 
1132 	/***
1133 	 * Gets the text direction.
1134 	 * 
1135 	 * @return Returns the direction.
1136 	 */
1137 	public Direction getDirection() {
1138 		return direction;
1139 	}
1140 
1141 	/***
1142 	 * Sets the text direction.
1143 	 * 
1144 	 * @param direction The direction to set.
1145 	 */
1146 	public void setDirection(Direction direction) {
1147 		this.direction = direction;
1148 	}
1149 
1150 	/***
1151 	 * Increase or decrease the space between characters.
1152 	 * 
1153 	 * @return Returns the letterSpacing.
1154 	 */
1155 	public String getLetterSpacing() {
1156 		return letterSpacing;
1157 	}
1158 
1159 	/***
1160 	 * Increase or decrease the space between characters.
1161 	 * 
1162 	 * @param letterSpacing The letterSpacing to set.
1163 	 */
1164 	public void setLetterSpacing(String letterSpacing) {
1165 		letterSpacing = trimString(letterSpacing);
1166 		if (validationEnabled
1167 				&& letterSpacing != null
1168 				&& !TEXT_LETTER_SPACING_NORMAL.equals(letterSpacing)
1169 				&& isLength(letterSpacing)) {
1170 			throw new ValueException("'" + letterSpacing + "' is not a valid letterSpacing");
1171 		}
1172 		this.letterSpacing = letterSpacing;
1173 	}
1174 
1175 	/***
1176 	 * Aligns the text in an element.
1177 	 * 
1178 	 * @return Returns the testAlign.
1179 	 */
1180 	public TextAlign getTextAlign() {
1181 		return textAlign;
1182 	}
1183 
1184 	/***
1185 	 * Aligns the text in an element.
1186 	 * 
1187 	 * @param testAlign The testAlign to set.
1188 	 */
1189 	public void setTextAlign(TextAlign testAlign) {
1190 		this.textAlign = testAlign;
1191 	}
1192 
1193 	/***
1194 	 * Adds decoration to text.
1195 	 * 
1196 	 * @return Returns the textDecoration.
1197 	 */
1198 	public TextDecoration getTextDecoration() {
1199 		return textDecoration;
1200 	}
1201 
1202 	/***
1203 	 * Adds decoration to text.
1204 	 * 
1205 	 * @param textDecoration The textDecoration to set.
1206 	 */
1207 	public void setTextDecoration(TextDecoration textDecoration) {
1208 		this.textDecoration = textDecoration;
1209 	}
1210 
1211 	/***
1212 	 * Indents the first line of text in an element.
1213 	 * 
1214 	 * @return Returns the textIndent.
1215 	 */
1216 	public String getTextIndent() {
1217 		return textIndent;
1218 	}
1219 
1220 	/***
1221 	 * Indents the first line of text in an element.
1222 	 * 
1223 	 * @param textIndent The textIndent to set.
1224 	 */
1225 	public void setTextIndent(String textIndent) {
1226 		textIndent = trimString(textIndent);
1227 		if (validationEnabled
1228 				&& textIndent != null
1229 				&& !isLength(textIndent)) {
1230 			throw new ValueException("'" + textIndent + "' is not a valid textIndent value.");
1231 		}
1232 		this.textIndent = textIndent;
1233 	}
1234 
1235 	/***
1236 	 * @return Returns the textShadow.
1237 	 */
1238 	public String getTextShadow() {
1239 		return textShadow;
1240 	}
1241 
1242 	/***
1243 	 * @param textShadow The textShadow to set.
1244 	 */
1245 	public void setTextShadow(String textShadow) {
1246 		textShadow = trimString(textShadow);
1247 		if (validationEnabled
1248 				&& textShadow != null
1249 				&& !TEXT_SHADOW_NONE.equals(textShadow)
1250 				&& !isLength(textShadow)) {
1251 			throw new ValueException("'" + textShadow + "' is not valid value for textShadow");
1252 		}
1253 		this.textShadow = textShadow;
1254 	}
1255 
1256 	/***
1257 	 * @return Returns the textTransform.
1258 	 */
1259 	public TextTransform getTextTransform() {
1260 		return textTransform;
1261 	}
1262 
1263 	/***
1264 	 * @param textTransform The textTransform to set.
1265 	 */
1266 	public void setTextTransform(TextTransform textTransform) {
1267 		this.textTransform = textTransform;
1268 	}
1269 
1270 	/***
1271 	 * @return Returns the whiteSpace.
1272 	 */
1273 	public WhiteSpace getWhiteSpace() {
1274 		return whiteSpace;
1275 	}
1276 
1277 	/***
1278 	 * @param whiteSpace The whiteSpace to set.
1279 	 */
1280 	public void setWhiteSpace(WhiteSpace whiteSpace) {
1281 		this.whiteSpace = whiteSpace;
1282 	}
1283 
1284 	/***
1285 	 * @return Returns the wordSpacing.
1286 	 */
1287 	public String getWordSpacing() {
1288 		return wordSpacing;
1289 	}
1290 
1291 	/***
1292 	 * @param wordSpacing The wordSpacing to set.
1293 	 */
1294 	public void setWordSpacing(String wordSpacing) {
1295 		wordSpacing = trimString(wordSpacing);
1296 		if (validationEnabled
1297 				&& wordSpacing != null
1298 				&& !TEXT_WORD_SPACING_NORMAL.equals(wordSpacing)
1299 				&& !isLength(wordSpacing)) {
1300 			throw new ValueException("'" + wordSpacing + "' is not a valid wordSpacing value.");
1301 		}
1302 		this.wordSpacing = wordSpacing;
1303 	}
1304 
1305 	// --- Appenders --------------------------------------------------------------------------------------------------
1306 	
1307 	/***
1308 	 * Appends white space to the <tt>builder</tt> parameter if the length of <tt>builder</tt> is greater than 0.
1309 	 * 
1310 	 * @param builder  The <tt>StringBuilder</tt> object used to generate the style.
1311 	 */
1312 	protected void seperateStyle(StringBuilder builder) {
1313 		if (builder.length() > 0) {
1314 			builder.append("; ");
1315 		}
1316 	}
1317 	
1318 	protected void seperateValue(StringBuilder builder) {
1319 		if (builder.length() > 0) {
1320 			builder.append(" ");
1321 		}
1322 	}
1323 	
1324 	protected void appendValue(StringBuilder builder, String value) {
1325 		if (value == null) {
1326 			return;
1327 		}
1328 		seperateValue(builder);
1329 		builder.append(value);
1330 	}
1331 	
1332 	protected void uriToString(StringBuilder builder, URI uri) {
1333 		if (uri == URL_NONE || URL_NONE.toString().equals(uri)) {
1334 			builder.append("none");
1335 		} else {
1336 			builder.append("url(").append(uri.toString()).append(")");
1337 		}
1338 	}
1339 	
1340 	protected void appendValue(StringBuilder builder, URI uri) {
1341 		if (uri == null) {
1342 			return;
1343 		}
1344 		seperateValue(builder);
1345 		uriToString(builder, uri);
1346 	}
1347 
1348 	protected void appendValue(StringBuilder builder, Value value) {
1349 		if (value == null) {
1350 			return;
1351 		}
1352 		seperateValue(builder);
1353 		builder.append(value.getValue());
1354 	}
1355 	
1356 	protected void appendStyle(StringBuilder builder, String style, String value) {
1357 		if (value == null) {
1358 			return;
1359 		}
1360 		seperateStyle(builder);
1361 		builder.append(style).append(": ").append(value);
1362 		
1363 	}
1364 	
1365 	protected void appendStyle(StringBuilder builder, String style, URI uri) {
1366 		if (uri == null) {
1367 			return;
1368 		}
1369 		seperateStyle(builder);
1370 		builder.append(style).append(": ");
1371 		uriToString(builder, uri);
1372 	}
1373 	
1374 	protected void appendStyle(StringBuilder builder, String style, Value value) {
1375 		if (value == null) {
1376 			return;
1377 		}
1378 		seperateStyle(builder);
1379 		builder.append(style).append(": ").append(value.getValue());
1380 		
1381 	}
1382 	
1383 	protected void appendShortHandStyle(StringBuilder builder, String style, StringBuilder shortHandBuilder) {
1384 		if (shortHandBuilder.length() > 0) {
1385 			seperateStyle(builder);
1386 			builder.append(style).append(": ").append(shortHandBuilder);
1387 		}
1388 	}
1389 	
1390 	public String toString() {
1391 		StringBuilder builder = new StringBuilder();
1392 		
1393 		if (shortHandProperties) {
1394 			// Background
1395 			{
1396 				StringBuilder backgroundBuilder = new StringBuilder();
1397 				appendValue(backgroundBuilder, getBackgroundAttachment());
1398 				appendValue(backgroundBuilder, getBackgroundColor());
1399 				appendValue(backgroundBuilder, getBackgroundImage());
1400 				appendValue(backgroundBuilder, getBackgroundPosition());
1401 				appendValue(backgroundBuilder, getBackgroundRepeat());
1402 				appendShortHandStyle(builder, STYLE_BACKGROUND, backgroundBuilder);
1403 			}
1404 			
1405 			// Border
1406 			{
1407 				StringBuilder borderBuilder = new StringBuilder();
1408 				appendValue(borderBuilder, getBorderWidth());
1409 				appendValue(borderBuilder, getBorderStyle());
1410 				appendValue(borderBuilder, getBorderColor());
1411 				appendShortHandStyle(builder, STYLE_BORDER, borderBuilder);
1412 			}
1413 			
1414 			{
1415 				StringBuilder borderBottomBuilder = new StringBuilder();
1416 				appendValue(borderBottomBuilder, getBorderBottomWidth());
1417 				appendValue(borderBottomBuilder, getBorderBottomStyle());
1418 				appendValue(borderBottomBuilder, getBorderBottomColor());
1419 				appendShortHandStyle(builder, STYLE_BORDER_BOTTOM, borderBottomBuilder);
1420 			}
1421 			
1422 			{
1423 				StringBuilder borderLeftBuilder = new StringBuilder();
1424 				appendValue(borderLeftBuilder, getBorderLeftWidth());
1425 				appendValue(borderLeftBuilder, getBorderLeftStyle());
1426 				appendValue(borderLeftBuilder, getBorderLeftColor());
1427 				appendShortHandStyle(builder, STYLE_BORDER_LEFT, borderLeftBuilder);
1428 			}
1429 
1430 			{
1431 				StringBuilder borderRightBuilder = new StringBuilder();
1432 				appendValue(borderRightBuilder, getBorderRightWidth());
1433 				appendValue(borderRightBuilder, getBorderRightStyle());
1434 				appendValue(borderRightBuilder, getBorderRightColor());
1435 				appendShortHandStyle(builder, STYLE_BORDER_RIGHT, borderRightBuilder);
1436 			}
1437 			
1438 			{
1439 				StringBuilder borderTopBuilder = new StringBuilder();
1440 				appendValue(borderTopBuilder, getBorderTopWidth());
1441 				appendValue(borderTopBuilder, getBorderTopStyle());
1442 				appendValue(borderTopBuilder, getBorderTopColor());
1443 				appendShortHandStyle(builder, STYLE_BORDER_TOP, borderTopBuilder);
1444 			}
1445 			
1446 			// Font
1447 			{
1448 				StringBuilder fontBuilder = new StringBuilder();
1449 				appendValue(fontBuilder, getFontStyle());
1450 				appendValue(fontBuilder, getFontVariant());
1451 				appendValue(fontBuilder, getFontWeight());
1452 				appendValue(fontBuilder, getFontSize());
1453 				appendValue(fontBuilder, getFontFamily());
1454 				appendShortHandStyle(builder, STYLE_FONT, fontBuilder);
1455 			}
1456 		} else {
1457 			// Background
1458 			appendStyle(builder, STYLE_BACKGROUND_ATTACHMENT, getBackgroundAttachment());
1459 			appendStyle(builder, STYLE_BACKGROUND_COLOR, getBackgroundColor());
1460 			appendStyle(builder, STYLE_BACKGROUND_IMAGE, getBackgroundImage());
1461 			appendStyle(builder, STYLE_BACKGROUND_POSITION, getBackgroundPosition());
1462 			appendStyle(builder, STYLE_BACKGROUND_REPEAT, getBackgroundRepeat());
1463 			
1464 			// Border
1465 			appendStyle(builder, STYLE_BORDER_COLOR, getBorderColor());
1466 			appendStyle(builder, STYLE_BORDER_STYLE, getBorderStyle());
1467 			appendStyle(builder, STYLE_BORDER_WIDTH, getBorderWidth());
1468 			appendStyle(builder, STYLE_BORDER_BOTTOM_COLOR, getBorderBottomColor());
1469 			appendStyle(builder, STYLE_BORDER_BOTTOM_STYLE, getBorderBottomStyle());
1470 			appendStyle(builder, STYLE_BORDER_BOTTOM_WIDTH, getBorderBottomWidth());
1471 			appendStyle(builder, STYLE_BORDER_LEFT_COLOR, getBorderLeftColor());
1472 			appendStyle(builder, STYLE_BORDER_LEFT_STYLE, getBorderLeftStyle());
1473 			appendStyle(builder, STYLE_BORDER_LEFT_WIDTH, getBorderLeftWidth());
1474 			appendStyle(builder, STYLE_BORDER_RIGHT_COLOR, getBorderRightColor());
1475 			appendStyle(builder, STYLE_BORDER_RIGHT_STYLE, getBorderRightStyle());
1476 			appendStyle(builder, STYLE_BORDER_RIGHT_WIDTH, getBorderRightWidth());
1477 			appendStyle(builder, STYLE_BORDER_TOP_COLOR, getBorderTopColor());
1478 			appendStyle(builder, STYLE_BORDER_TOP_STYLE, getBorderTopStyle());
1479 			appendStyle(builder, STYLE_BORDER_TOP_WIDTH, getBorderTopWidth());
1480 			
1481 			// Font
1482 			appendStyle(builder, STYLE_FONT_FAMILY, getFontFamily());
1483 			appendStyle(builder, STYLE_FONT_SIZE, getFontSize());
1484 			appendStyle(builder, STYLE_FONT_STYLE, getFontStyle());
1485 			appendStyle(builder, STYLE_FONT_VARIANT, getFontVariant());
1486 			appendStyle(builder, STYLE_FONT_WEIGHT, getFontWeight());
1487 			
1488 		}
1489 		// Classification
1490 		appendStyle(builder, STYLE_CLEAR, getClear());
1491 		appendStyle(builder, STYLE_DISPLAY, getDisplay());
1492 		appendStyle(builder, STYLE_FLOAT, getFloat());
1493 		appendStyle(builder, STYLE_POSITION, getPosition());
1494 		appendStyle(builder, STYLE_VISIBILITY, getVisibility());
1495 		
1496 		// Dimension
1497 		appendStyle(builder, STYLE_HEIGHT, getHeight());
1498 		appendStyle(builder, STYLE_LINE_HEIGHT, getLineHeight());
1499 		appendStyle(builder, STYLE_MAX_HEIGHT, getMaxHeight());
1500 		appendStyle(builder, STYLE_MAX_WIDTH, getMaxWidth());
1501 		appendStyle(builder, STYLE_MIN_HEIGHT, getMinHeight());
1502 		appendStyle(builder, STYLE_MIN_WIDTH, getMinWidth());
1503 		appendStyle(builder, STYLE_WIDTH, getWidth());
1504 		
1505 		// Font - Non-shortand styles
1506 		appendStyle(builder, STYLE_FONT_SIZE_ADJUST, getFontSizeAdjust());
1507 		appendStyle(builder, STYLE_FONT_STRETCH, getFontStretch());
1508 		
1509 		// Text
1510 		appendStyle(builder, STYLE_COLOR, getColor());
1511 		appendStyle(builder, STYLE_DIRECTION, getDirection());
1512 		appendStyle(builder, STYLE_LETTER_SPACING, getLetterSpacing());
1513 		appendStyle(builder, STYLE_TEXT_ALIGN, getTextAlign());
1514 		appendStyle(builder, STYLE_TEXT_DECORATION, getTextDecoration());
1515 		appendStyle(builder, STYLE_TEXT_INDENT, getTextIndent());
1516 		appendStyle(builder, STYLE_TEXT_SHADOW, getTextShadow());
1517 		appendStyle(builder, STYLE_TEXT_TRANSFORM, getTextTransform());
1518 		appendStyle(builder, STYLE_WHITE_SPACE, getWhiteSpace());
1519 		appendStyle(builder, STYLE_WORD_SPACING, getWordSpacing());
1520 		
1521 		return builder.toString();
1522 	}
1523 	
1524 }