Source code: echopoint/stylesheet/CssStyleSheetHandler.java
1 package echopoint.stylesheet;
2
3 /*
4 * This file is part of the Echo Point Project. This project is a collection
5 * of Components that have extended the Echo Web Application Framework.
6 *
7 * EchoPoint is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * EchoPoint is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with Echo Point; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22 import nextapp.echo.Style;
23 /**
24 * This interface is used to create CssStyleSheetHandler that can be called upon by
25 * a CssStyleSheet when parsing style sheet data.
26 * <p>
27 * The CssStyleSheetHandler is responsible for indicating whether a given attribute name
28 * and value is known and valid to set in a Style for a Component class and also
29 * providing the fully qualified class name of a Component.
30 * <p>
31 * In general you will not need to provide a CssStyleSheetHandler implementation
32 * if your Component classes have support for the StyleInfo interface either via a
33 * xxxStyleInfo support class or a nested public static class that implements
34 * StyleInfo.
35 * <p>
36 * The unknown style attribute name and value parsing is done in the following
37 * order :<br>
38 * <ol>
39 * <li>The getStyleInfo() method is called to retreive StyleInfo about a Component class.</li>
40 * <li>Then the setKnownStyleAttribute() method is called when the style attribute name is known but the value type
41 * cannot be parsed.</li>
42 * <li>If no StyleInfo is available for the Component, then the setUnknownStyleAttribute() method is called for a given
43 * Component class.</li>
44 * <li>If this fails, then the parseUnknownStyleValue() method will be called to parse a Object value given a Component
45 * class and a style attribute name and value context.</li>
46 * <li>Failing all of this the parseUnknownStyleValue() method will be called to parse a Object value given a
47 * value string context.</li>
48 * </ol>
49 * <p>
50 */
51 public interface CssStyleSheetHandler {
52
53 /**
54 * This method is called to ask the StyleSheetHandler to make a name into
55 * a fully qualified Java class name. For example "Component" might become
56 * "nextapp.echo.Component".
57 * <p>
58 * If the StyleSheetHandler does in fact handle a class called <i>partialClassName</i>
59 * then it should make it into a fully qualified class name.
60 * <p>
61 * If the StyleSheetHandler doesnt have a class called <i>partialClassName</i>, then it
62 * must return null.
63 */
64 public String getFullQualifiedClassName(String partialClassName);
65
66
67 /**
68 * Called to return an array of the classes that a CssStyleSheetHandler manages.
69 * @return a Class array
70 */
71 public Class[] getHandledClasses();
72
73 /**
74 * This method can be called to retrieve a StyleInfo object for
75 * the specified component class. If the handler does not
76 * know about the componentClass it should return null
77 *
78 * @param componentClazz - the component class
79 * @return - the StyleInfo for that component class or null
80 */
81 public StyleInfo getStyleInfo(Class componentClazz);
82
83 /**
84 * This method is called to set a specific attribute and value into a style, when the
85 * Class of the attribute value is known.
86 * <p>
87 * The CssStyleSheetHandler must perform the Style.setAttribute and return a true indicating
88 * this was successful.
89 * <p>
90 */
91 public boolean setKnownStyleAttribute(Class componentClazz, Class attrValueClass, Style style, String attrName, String attrValue);
92 /**
93 * This method is called to set a specific attribute and value into a style, when the
94 * Class of the attribute value is NOT known.
95 * <p>
96 * The CssStyleSheetHandler must perform the Style.setAttribute and return a true indicating
97 * this was successful.
98 * <p>
99 */
100 public boolean setUnknownStyleAttribute(Class componentClazz, Style style, String attrName, String attrValue);
101
102 /**
103 * This method is called to set a parse a style attribute value into its object form. This is called
104 * after the <code>setUnknownStyleAttribute</code> method is called and the style attribute
105 * value still cannot be determined.
106 * <p>
107 * The CssStyleSheetHandler must perform parse the <code>attrValue</code> string into an object or
108 * return <code>null</code> indicating that the value string form is not known, given the current
109 * context of <code>componentClazz</code> and <code>attrName</code>.
110 * <p>
111 */
112 public Object parseUnknownStyleValue(Class componentClazz, String attrName, String attrValue);
113
114 /**
115 * This method is called to set a parse a style attribute value into its object form. This is called
116 * after the <code>parseUnknownStyleValue</code> method is called and the style attribute
117 * value still cannot be determined.
118 * <p>
119 * The CssStyleSheetHandler must perform parse the <code>attrValue</code> string into an object or
120 * return <code>null</code> indicating that the value string form is not known.
121 * <p>
122 */
123 public Object parseUnknownStyleValue(String attrValue);
124
125 }