public final class DomUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
DomUtil.IPerNode
Functor interface to handle tree walking.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DOCROOT |
static org.slf4j.Logger |
USERLOG |
| Modifier and Type | Method and Description |
|---|---|
static List<UIMessage> |
addSingleShotMessage(NodeBase node,
UIMessage message) |
static void |
addUrlParameters(StringBuilder sb,
IPageParameters ctx,
boolean first) |
static void |
addUrlParameters(StringBuilder sb,
IPageParameters ctx,
boolean first,
Set<String> skipset) |
static void |
addUrlParameters(StringBuilder sb,
IRequestContext ctx,
boolean first) |
static void |
adjustTableColspans(Table table)
Walks the entire table and adjusts it's colspans.
|
static List<NodeContainer> |
appendContainer(List<NodeContainer> stack,
NodeContainer it) |
static <T> T |
badCheck(T in)
Deprecated.
|
static void |
balanceTable(Table t)
This balances tables to ensure that all rows have an equal number of rows and
columns, taking rowspans and colspans into effect.
|
static void |
buildTree(NodeBase p)
Ensures that all of a node tree has been built.
|
static String |
calcNodeText(NodeContainer nc)
Try to get some content text from this node, for displaying what the node "is".
|
static String |
calcPageLabel(Class<?> clz)
Lookup a page Title bar text..
|
static String |
calcPageTitle(Class<?> clz)
Lookup a page Title bar text..
|
static String |
calculateURL(IRequestContext ci,
String rurl)
Calculate a full URL from a rurl.
|
static boolean |
classResourceExists(Class<?> clz,
String name)
Returns T if the given Java Resource exists.
|
static void |
clearModifiedFlag(NodeBase root)
This clears the 'modified' flag for all nodes in the subtree that implement
IHasModifiedIndication. |
static <T> boolean |
contains(T[] array,
T lookingFor)
Util that returns T if lookingFor object is contained in specified array
|
static <V,T extends IIdentifyable<V>> |
containsLongIdentifyable(Collection<T> set,
T lookingFor)
Util can be used to check if list contains item that has equal Long Id as specified one, while instanies itself does not need to be equal.
|
static String |
convertToID(String id) |
static String |
createOpenWindowJS(Class<?> targetClass,
IPageParameters targetParameters,
WindowParameters newWindowParameters)
This opens a new DomUI page, immediately creating a session for it.
|
static String |
createOpenWindowJS(String url,
WindowParameters newWindowParameters) |
static String |
createPageRURL(Class<? extends UrlPage> clz,
IPageParameters pp)
Create a relative URL for the specified page (an URL that is relative to the application's context, i.e.
|
static String |
createPageURL(Class<? extends UrlPage> clz,
IPageParameters pp)
IMPORTANT: This method MUST be used only within UI threads, when UIContext.getRequestContext() != null!
In all other, usually background running threads, other alternatives that are using stored appURL must be used!
|
static String |
createPageURL(String webAppUrl,
Class<? extends UrlPage> clz,
IPageParameters pp)
IMPORTANT: This method MUST be used for non UI threads, when UIContext.getRequestContext() == null!
In all other, usually UI running threads, use other alternatives that is using appURL from UIContext.getRequestContext()!
|
static String |
createPageURL(String rurl,
IPageParameters pageParameters)
Generate an URL to some page with parameters.
|
static String |
createRandomColor() |
static void |
dumpException(Exception x) |
static void |
dumpException(StringBuilder sb,
Throwable x) |
static void |
dumpExceptionIfSevere(Exception x)
This method will first determine whether the exception is considered severe.
|
static void |
dumpRequest(javax.servlet.http.HttpServletRequest req) |
static BundleRef |
findBundle(UIMenu ma,
Class<?> clz) |
static Class<?> |
findClass(ClassLoader cl,
String name) |
static <T extends NodeBase> |
findComponentInTree(NodeBase p,
Class<T> clz)
Walks the tree starting at the node passed and returns the first instance of the given class
that is found in a normal walk of the tree.
|
static BundleRef |
findPageBundle(UrlPage urlPage)
Locates the default page bundle for a page.
|
static String |
generateGUID()
Generate an unique identifier with reasonable expectations that it will be globally unique.
|
static String |
getAdjustedComponentUrl(NodeBase component,
String command,
IPageParameters pp) |
static String |
getAdjustedPageUrl(Page page,
IPageParameters pp) |
static String |
getApplicationContext()
Returns application context part from current request.
|
static String |
getApplicationURL()
Returns application url part from current request.
|
static BundleRef |
getClassBundle(Class<?> clz)
Returns the bundle for the specified class, defined as classname[nls].properties.
|
static String |
getClassNameOnly(Class<?> clz) |
static Object |
getClassValue(Object inst,
String name)
Retrieves a value from an object using introspection.
|
static String |
getComponentDetails(NodeBase n) |
static String |
getHintValue(String componentTypeHint,
String name)
Decode a
PropertyMetaModel.getComponentTypeHint() hint. |
static String |
getJavaResourceRURL(Class<?> resourceBase,
String name) |
static Long |
getLongParameter(IPageParameters pp,
String name,
Long def)
Deprecated.
|
static String |
getLorem()
Return a large string containing lorum ipsum text, for testing purposes.
|
static IErrorFence |
getMessageFence(NodeBase in) |
static BundleRef |
getPackageBundle(Class<?> base) |
static Object |
getPropertyValue(Object base,
String path)
Resolve the property's value
|
static String |
getRelativeApplicationResourceURL(String resource)
Returns relative path for specified resource (without host name, like '/APP_CONTEXT/resource').
|
static Object |
getSessionAttribute(String attribute,
boolean doReset)
Returns specified session attribute value if exists.
|
static StackTraceElement[] |
getTracepoint() |
static <T> T |
getValueSafe(IControl<T> node) |
static boolean |
hasResource(Class<? extends UrlPage> clz,
String cn)
Returns T if the specified resource exists.
|
static String |
htmlRemoveAll(String html,
boolean lf) |
static void |
htmlRemoveAll(StringBuilder outsb,
String text,
boolean lf) |
static String |
htmlRemoveUnsafe(String html) |
static void |
htmlRemoveUnsafe(StringBuilder outsb,
String text)
This scans the input, and only copies "safe" html, which is HTML with only
simple constructs.
|
static void |
ie8Capable(javax.servlet.http.HttpServletResponse req)
Deprecated.
|
static <T> int |
indexOf(T[] array,
T lookingFor)
Util that returns index of lookingFor object inside specified array
|
static <V,T extends IIdentifyable<V>> |
indexOfLongIdentifyable(List<T> list,
T lookingFor)
Util that returns index of member in specified list that has same Long Id as specified member.
|
static boolean |
isBasicType(Class<?> t)
Returns T if this is one of the basic types: any numeric including BigDecimal and BigInteger; string, or date.
|
static boolean |
isBlank(String s)
Deprecated.
|
static boolean |
isBooleanOrWrapper(Class<?> clz) |
static boolean |
isByteOrWrapper(Class<?> clz) |
static boolean |
isDoubleOrWrapper(Class<?> clz) |
static boolean |
isEqual(Object... ar) |
static boolean |
isEqual(Object a,
Object b) |
static boolean |
isEqualIgnoreCase(String a,
String b)
Deprecated.
|
static boolean |
isEqualOLD(Object a,
Object b) |
static boolean |
isFloatOrWrapper(Class<?> clz) |
static <T> boolean |
isIn(T value,
T... values)
EXPENSIVE - USE WITH CARE
Check if first primitive type paramater is equal to some from others.
|
static boolean |
isIntegerOrWrapper(Class<?> clz) |
static boolean |
isIntegerType(Class<?> clz)
Returns T if the class represents an integer numeric type.
|
static boolean |
isLongOrWrapper(Class<?> clz) |
static boolean |
isModified(NodeBase root)
Walks the subtree and asks any node implementing
IHasModifiedIndication whether it has been
modified; return as soon as one node tells us it has been modified. |
static boolean |
isRealType(Class<?> clz)
Return T if the class represents a real (double or float) type.
|
static boolean |
isRelativeURL(String in) |
static boolean |
isShortOrWrapper(Class<?> clz) |
static boolean |
isWhitespace(char c) |
static void |
main(String[] args) |
static <V,T extends IIdentifyable<V>> |
merge(List<T> mergeSource,
List<T> toJoinItems)
Appends non contained items from toJoinItems into mergeSource.
|
static <V,T extends IIdentifyable<V>> |
merge(List<T> mergeSource,
T item)
Add item to mergeSource if it is not already contained.
|
static String |
nlsLabel(String label) |
static <T> T |
nullChecked(T in)
NULL CHECKING BELONGS IN THE LANGUAGE, NOT IN ANNOTATIONS, damnit! This fine idiocy is needed to
handle null checking because the pathetic losers that make up the Java JSR board are so incredible
stupid it boggles the mind.
|
static int |
percentSize(String css)
Convert a CSS percentage size string like '90%' into the 90...
|
static int |
pixelSize(String css)
Convert a CSS size string like '200px' into the 200...
|
static int |
pixelSize(String css,
int defaultVal)
Convert a CSS size string like '200px' into the 200...
|
static void |
renderErrorMessage(NodeContainer d,
UIMessage m)
This scans an error messages for simple HTML and renders that as DomUI nodes.
|
static void |
renderHtmlString(NodeContainer d,
String text)
Render a text string that possibly contains some simple HTML constructs as a DomUI
node set into the container passed.
|
static void |
setModifiedFlag(NodeBase node)
Update modified flag of node.
|
static void |
setPageCompatibility(javax.servlet.http.HttpServletResponse req,
String comp)
Define (or clear) the x-ua-compatible value sent for this page.
|
static void |
setSessionAttribute(String attribute,
Object value)
Set specified session attribute value.
|
static void |
stripHtml(StringBuilder sb,
String in)
Remove all HTML tags from the input and keep only the text content.
|
static void |
time(String what,
IExecute exec) |
static Object |
walkTree(NodeBase root,
DomUtil.IPerNode handler)
Walks a node tree, calling the handler for every node in the tree.
|
public static final org.slf4j.Logger USERLOG
public static final String DOCROOT
@Nonnull public static <T> T nullChecked(@Nullable T in)
in - @Deprecated @Nonnull public static <T> T badCheck(T in)
in - public static final void setPageCompatibility(@Nonnull javax.servlet.http.HttpServletResponse req, @Nullable String comp) throws IOException
comp - IOException@Deprecated public static final void ie8Capable(javax.servlet.http.HttpServletResponse req) throws IOException
req - IOException@Deprecated public static final boolean isEqualIgnoreCase(@Nullable String a, @Nullable String b)
StringTool.isEqualIgnoreCase(String, String) please.a - b - public static final boolean isEqual(Object... ar)
public static <T> T getValueSafe(IControl<T> node)
public static boolean classResourceExists(Class<?> clz, String name)
clz - name - public static final Class<?> findClass(@Nonnull ClassLoader cl, @Nonnull String name)
public static boolean isIntegerType(Class<?> clz)
clz - public static boolean isDoubleOrWrapper(Class<?> clz)
public static boolean isFloatOrWrapper(Class<?> clz)
public static boolean isIntegerOrWrapper(Class<?> clz)
public static boolean isShortOrWrapper(Class<?> clz)
public static boolean isByteOrWrapper(Class<?> clz)
public static boolean isLongOrWrapper(Class<?> clz)
public static boolean isBooleanOrWrapper(Class<?> clz)
public static boolean isRealType(Class<?> clz)
clz - public static boolean isBasicType(Class<?> t)
t - public static final Object getClassValue(@Nonnull Object inst, @Nonnull String name) throws Exception
inst - name - Exceptionpublic static Object getPropertyValue(@Nonnull Object base, @Nonnull String path)
base - path - public static String createRandomColor()
@Nonnull public static IErrorFence getMessageFence(@Nonnull NodeBase in)
@Nonnull public static String generateGUID()
public static void addUrlParameters(StringBuilder sb, IRequestContext ctx, boolean first)
public static void addUrlParameters(@Nonnull StringBuilder sb, @Nonnull IPageParameters ctx, boolean first)
public static void addUrlParameters(@Nonnull StringBuilder sb, @Nonnull IPageParameters ctx, boolean first, @Nonnull Set<String> skipset)
public static String getApplicationURL()
public static String getApplicationContext()
public static String getRelativeApplicationResourceURL(String resource)
resource - public static String createPageURL(Class<? extends UrlPage> clz, IPageParameters pp)
clz - pp - @Nonnull public static String createPageRURL(@Nonnull Class<? extends UrlPage> clz, @Nullable IPageParameters pp)
clz - pp - public static String createPageURL(@Nonnull String webAppUrl, @Nonnull Class<? extends UrlPage> clz, @Nullable IPageParameters pp)
webAppUrl - web app url, must be ended with '/'clz - pp - public static String createPageURL(String rurl, IPageParameters pageParameters)
rurl - The absolute or relative URL to whatever resource.pageParameters - @Nonnull public static String getAdjustedPageUrl(@Nonnull Page page, @Nullable IPageParameters pp)
@Nonnull public static String getAdjustedComponentUrl(@Nonnull NodeBase component, @Nonnull String command, @Nullable IPageParameters pp)
public static String calculateURL(IRequestContext ci, String rurl)
ci - rurl - public static void buildTree(NodeBase p) throws Exception
p - Exceptionpublic static <T extends NodeBase> T findComponentInTree(NodeBase p, Class<T> clz) throws Exception
T - p - clz - Exceptionpublic static void adjustTableColspans(Table table)
t - public static void balanceTable(Table t)
t - public static void stripHtml(StringBuilder sb, String in)
sb - in - public static void dumpException(Exception x)
public static void dumpExceptionIfSevere(@Nonnull Exception x)
x - public static void dumpException(@Nonnull StringBuilder sb, Throwable x)
public static void dumpRequest(javax.servlet.http.HttpServletRequest req)
public static boolean hasResource(Class<? extends UrlPage> clz, String cn)
clz - cn - public static BundleRef findBundle(UIMenu ma, Class<?> clz)
ma - clz - public static BundleRef getClassBundle(Class<?> clz)
clz - @Nonnull public static String calcPageTitle(Class<?> clz)
clz - public static String calcPageLabel(Class<?> clz)
clz - public static BundleRef findPageBundle(UrlPage urlPage)
urlPage - public static void renderHtmlString(NodeContainer d, String text)
public static void htmlRemoveUnsafe(StringBuilder outsb, String text)
sb - html - public static void htmlRemoveAll(StringBuilder outsb, String text, boolean lf)
public static List<NodeContainer> appendContainer(List<NodeContainer> stack, NodeContainer it)
public static void renderErrorMessage(NodeContainer d, UIMessage m)
@Deprecated public static Long getLongParameter(IPageParameters pp, String name, Long def)
pp - name - def - public static int pixelSize(String css)
css - public static int pixelSize(String css, int defaultVal)
css - defaultVal - public static int percentSize(String css)
css - public static Object walkTree(NodeBase root, DomUtil.IPerNode handler) throws Exception
handler - Exceptionpublic static void clearModifiedFlag(NodeBase root)
IHasModifiedIndication.root - The subtree to traversepublic static boolean isModified(NodeBase root)
IHasModifiedIndication whether it has been
modified; return as soon as one node tells us it has been modified.root - public static void setModifiedFlag(NodeBase node)
node - @Deprecated public static boolean isBlank(String s)
Checks if string is blank.
s - String to be validated.public static boolean isRelativeURL(String in)
public static <T> boolean isIn(T value,
T... values)
MetaManager.areObjectsEqual(Object, Object, ClassMetaModel).value - values - @Nonnull public static String createOpenWindowJS(@Nonnull Class<?> targetClass, @Nullable IPageParameters targetParameters, @Nullable WindowParameters newWindowParameters)
targetClass - targetParameters - newWindowParameters - @Nonnull public static String createOpenWindowJS(@Nonnull String url, @Nullable WindowParameters newWindowParameters)
public static boolean isWhitespace(char c)
public static StackTraceElement[] getTracepoint()
public static String getLorem() throws Exception
Exceptionpublic static <V,T extends IIdentifyable<V>> boolean containsLongIdentifyable(@Nonnull Collection<T> set, @Nonnull T lookingFor)
T - set - lookingFor - public static <V,T extends IIdentifyable<V>> int indexOfLongIdentifyable(@Nonnull List<T> list, @Nonnull T lookingFor)
T - list - member - @Nonnull public static <V,T extends IIdentifyable<V>> List<T> merge(@Nonnull List<T> mergeSource, @Nonnull T item)
T - mergeSource - item - public static <V,T extends IIdentifyable<V>> List<T> merge(@Nonnull List<T> mergeSource, @Nonnull List<T> toJoinItems)
T - mergeSource - toJoinItems - public static <T> boolean contains(T[] array,
T lookingFor)
T - array - lookingFor - public static <T> int indexOf(T[] array,
T lookingFor)
T - array - lookingFor - @Nullable public static Object getSessionAttribute(@Nonnull String attribute, boolean doReset)
attribute - doReset - if T attribute value is set to null after reading.public static void setSessionAttribute(@Nonnull String attribute, @Nullable Object value)
attribute - value - @Nullable public static String getHintValue(String componentTypeHint, String name)
PropertyMetaModel.getComponentTypeHint() hint.componentTypeHint - string - public static void main(String[] args)
@Nonnull public static List<UIMessage> addSingleShotMessage(@Nonnull NodeBase node, @Nonnull UIMessage message)
public static String calcNodeText(@Nonnull NodeContainer nc)
nc - Copyright © 2017 etc.to. All rights reserved.