public final class Utils
extends java.lang.Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
annotationOptionEquals(java.lang.annotation.Annotation a1,
java.lang.annotation.Annotation a2)
Event options comparator
|
static boolean |
areEquals(java.lang.Object a,
java.lang.Object b)
Compare two objects
|
static java.lang.String |
capitalizeFirstLetter(java.lang.String original)
Utility method for generating getters name of annotated attributes.
|
static int |
codeEventOptions(java.util.Set<java.lang.annotation.Annotation> options)
Computes browser event options value
|
static void |
drawAttribute(java.lang.String attrName,
java.lang.Object attrValue,
boolean marker,
java.lang.StringBuilder sb)
Draws attribute to response output with it's value: attr=value.
|
static void |
drawAttributes(Element element,
java.lang.StringBuilder sb)
Draws all annotated fields with
Annotation of the Element. |
static void |
drawHTML(Element current,
FireWebApplication app,
java.lang.StringBuilder sb,
boolean intro)
Drawing HTML view below elements of this element in tree.
|
static java.lang.StringBuilder |
drawView(FireWebApplication app)
Redraw GUI view.
|
static java.lang.String |
encodeScript(java.lang.String script,
FireWebApplication app)
Encoding JS in order to convert extra characters to ascii
Replace + to %20 which is right decoded by JS function
"decodeURIComponent".
|
static java.lang.String |
escapeHTML(java.lang.String aTagFragment)
Replace characters having special meaning inside HTML tags with
their escaped equivalents, using character entities such as
'&'.
|
static java.lang.StringBuilder |
escapeScript(java.lang.String js)
Escapes string to right JavaScript literals.
|
static java.lang.StringBuilder |
escapeScriptWhiteSpaces(java.lang.String js)
Escapes white spaces in JavaScripts for inline scripts.
|
static <T extends java.lang.annotation.Annotation> |
eventOptionFactory(java.lang.Class<T> optionType,
java.lang.Object value)
Factory provides event option instances with given value.
|
static Element |
findElement(Element current,
java.lang.String objectId)
Finds web object in elements tree.
|
static EventListener |
findEventListener(java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
Utility method which test if annotation is a
EventListener . |
static java.lang.annotation.Annotation |
findOptionByType(java.util.Set<? extends java.lang.annotation.Annotation> options,
java.lang.Class<? extends java.lang.annotation.Annotation> type)
Utility method finding event option instance of it type.
|
static <T extends Element> |
findParent(java.lang.Class<T> c,
Element curr)
Looking in object tree parent object of given class type.
|
static java.lang.String |
getApplicationAttributeName(java.lang.String servletName)
Returns session attribute name
|
static java.util.Set<java.lang.annotation.Annotation> |
getEventOptions(java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
Finds browser event options of annotation type.
|
static java.lang.String |
getScriptPrefix(Element e)
Returns prefix of FireWeb element selector
|
static java.lang.String |
pathToDebugScript(java.lang.String orginPath)
Change path to script by add "-debug" suffix to it's name.
|
static ColorType |
rgb(int red,
int green,
int blue)
Create color from RGB
|
static java.lang.Integer |
rgbToInt(int red,
int green,
int blue)
Convert RGB to integer value.
|
public static final void drawHTML(Element current, FireWebApplication app, java.lang.StringBuilder sb, boolean intro)
current
- Element to drawapp
- Drawing contextsb
- Drawing results bufferintro
- If draw intro of HTML code form Servlet false in other casespublic static final java.lang.StringBuilder drawView(FireWebApplication app)
app
- Drawing contextpublic static final void drawAttribute(java.lang.String attrName, java.lang.Object attrValue, boolean marker, java.lang.StringBuilder sb)
attrName
- Attribute nameattrValue
- Attribute value. If is String type the value is surrounding by
quotation - Constants.JS_QUOTATION_MARK. Attribute is escaped
for HTML special and JS characters.marker
- If the attribute is type of markersb
- Buffer for drawing result.public static final void drawAttributes(Element element, java.lang.StringBuilder sb)
Annotation
of the Element.element
- to processsb
- buffer contains processing resultspublic static final java.lang.String capitalizeFirstLetter(java.lang.String original)
original
- name to capitalizepublic static final EventListener findEventListener(java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
EventListener
.eventType
- event type annotationpublic static final int codeEventOptions(java.util.Set<java.lang.annotation.Annotation> options)
options
- event options setpublic static final boolean annotationOptionEquals(java.lang.annotation.Annotation a1, java.lang.annotation.Annotation a2)
a1
- Option to compare to a2a2
- Option to compare to a1public static final java.util.Set<java.lang.annotation.Annotation> getEventOptions(java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
Constants.BROWSER_EVENT_DEFAULTS
and annotated values.eventType
- Event type annotationpublic static final java.lang.annotation.Annotation findOptionByType(java.util.Set<? extends java.lang.annotation.Annotation> options, java.lang.Class<? extends java.lang.annotation.Annotation> type)
options
- Set of event optionstype
- Option typepublic static final <T extends java.lang.annotation.Annotation> T eventOptionFactory(java.lang.Class<T> optionType, java.lang.Object value)
T
- instance of optionType classoptionType
- Event option type annotationvalue
- Event option valuepublic static final java.lang.String escapeHTML(java.lang.String aTagFragment)
The escaped characters are :
aTagFragment
- to escapepublic static final java.lang.StringBuilder escapeScript(java.lang.String js)
js
- String to escapepublic static final java.lang.StringBuilder escapeScriptWhiteSpaces(java.lang.String js)
js
- String to escapepublic static final java.lang.String encodeScript(java.lang.String script, FireWebApplication app)
script
- The script to convertapp
- context for charsetpublic static final java.lang.String getScriptPrefix(Element e)
e
- Element to build the prefixpublic static final java.lang.String getApplicationAttributeName(java.lang.String servletName)
servletName
- Servlet name of the contextpublic static final Element findElement(Element current, java.lang.String objectId)
current
- the root for searchingobjectId
- Object id to findpublic static final <T extends Element> T findParent(java.lang.Class<T> c, Element curr)
T
- type of elementc
- Class to findcurr
- The object for which we looking of root object - starting
point.public static final java.lang.Integer rgbToInt(int red, int green, int blue)
red
- color levelgreen
- color levelblue
- color levelpublic static final ColorType rgb(int red, int green, int blue)
red
- color levelgreen
- color levelblue
- color levelpublic static final boolean areEquals(java.lang.Object a, java.lang.Object b)
a
- Object to compareb
- Object to comparepublic static final java.lang.String pathToDebugScript(java.lang.String orginPath)
From script.js to script-debug.js
orginPath
- path to non debug form script (compressed)