it.haefelinger.flaka.util
Class Static

java.lang.Object
  extended by it.haefelinger.flaka.util.Static

public final class Static
extends Object

From the basis of an XML source, creates a list of dependencies.


Field Summary
static String EL
           
static int PROPTY
           
static int VARREF
           
static int WRITEPROPTY
           
 
Constructor Summary
Static()
           
 
Method Summary
static void _log_(Project P, String msg, int type)
           
static Project assign(Project project, String key, Object obj, int type)
          Assign an object either as variable or as property to a given project.
static int bitset(int bitset, int bit, boolean on)
           
static String[] bufread(File fname)
           
static String[] bufread(String buf)
           
static String cat(Project P, File file)
           
static String center(String S, int width, String chr)
           
static void close(InputStream is)
           
static void close(OutputStream os)
           
static void close(Reader r)
           
static void close(Writer w)
           
static AntTypeDefinition compdef(Project project, String property)
           
static ComponentHelper comphelper(Project P)
           
static int contains(String v, char c)
           
static void copy(InputStream src, OutputStream dst)
           
static void debug(Project P, String msg)
           
static void debug(Project P, String msg, Exception e)
           
static boolean el2bool(Project project, String expr)
          Evaluate a EL expression in a boolean context.
static File el2file(Project project, String expr)
           
static Object el2obj(Project project, String expr)
          Evaluate EL expression.
static String el2str(Project project, String expr)
          Evaluate EL expression in a string context.
static String elresolve(Project project, String text)
          Resolve embedded EL references in text.
static boolean empty(String s)
           
static void error(Project P, String msg)
           
static void error(Project P, String msg, Exception e)
           
protected static String escape(char c, char esc)
          escape non-alphanumeric character c by escape character esc.
protected static String escape(String s, char esc)
          escape all non-alphanumeric characters in s by escape character esc.
static void fcopy(File src, File dst)
           
static Field fieldbyname(Class clazz, String name)
           
static Object filter(Project project, String property)
           
static String flushxml(Project P, Element root, File file)
           
static String flushxml(Project P, Element root, StringBuffer buf)
           
static Object getattr(Object obj, String name)
           
static Class getclass(Project P, String s)
          shortcut to get a component's class
static String getstem(String S)
           
static Document getxmldoc(InputStream stream)
           
static String[] grep(Project project, String regexpr)
           
static boolean htabremove(Object obj, String att, String key)
          Removes a Hashtable entry.
static void info(Project P, String msg)
           
static void info(Project P, String msg, Exception e)
           
static Object invoke(Object obj, String name, Class[] type, Object[] args)
           
static boolean isbinary(char c)
          * test whether a character is a 'textual' character, i.e.
static boolean isEmpty(String s)
           
static boolean ismacrodef(Project P, String s)
           
static boolean ispatternchar(char c)
           
static boolean isprintable(char c)
          * test whether a character is printable.
static boolean isproperty(Project P, String property)
           
static boolean isreference(Project P, String id)
           
static boolean isregexchar(char c)
           
static boolean issubclass(Class clazz, Class base)
          tests whether class obj is a subclass of base.
static boolean istarget(Project P, String s)
           
static boolean istask(Project P, String s)
           
static boolean istaskdef(Project P, String s)
           
static boolean istext(char c)
          * test whether a character is a 'textual' character, i.e.
static String jar2var(String V)
          Translates a given loc name in it's official dependency name.
static Element loadxml(Project P, File file)
           
static void log(Project P, String msg)
           
static void log(Project P, String msg, Exception e)
           
static String logo(String msg)
           
static String logo(String msg, int width)
           
static AntTypeDefinition macrodef(Project project, String property)
           
static Object makecomp(Project P, String s)
          shortcut to create a component
static Method methodbyname(Class C, String name, Class[] type)
           
static String mkchrseq(String c, int n)
           
static String nodeattribute(Node node, String name, String otherwise)
           
static String patternAsRegex(String glob)
           
static Pattern patterncompile(String S, int f)
          A standard way to compile a given pattern into a RE Pattern.
static String property(Project P, String property)
           
static String q(String s)
           
static String readlines(File src)
           
static String readlines(InputStream src)
           
static String readlines(Reader reader)
           
static String readlines(String src)
           
static Object reference(Project P, String id)
           
protected static String replace(String s, char c, String sub)
          replace all c characters in s with string sub.
static void setattr(Object obj, String name, Object val)
           
static String[] split(String v, String c)
           
static String stripEmptyLines(String buf)
           
protected static String substring(String s, int i, int J)
          similar as s.substring(i,j) except that j is allowed to be larger than s.length().
static String tag2ver(String V)
           
static Object target(Project project, String property)
           
static AntTypeDefinition task(Project project, String property)
           
static AntTypeDefinition taskdef(Project project, String property)
           
static void throwbx(String S)
           
static void throwbx(String S, Exception e)
           
protected static void tidyxml(DOMSource source)
          Cleans up the empty lines and tab after removing the nodes
static File toFile(Project project, String s)
           
static String trim2(String s, String otherwise)
          Trim a given string.
static String trim3(Project project, String s, String otherwise)
           
static String trimNonDigit(String V)
           
static Object type(Project project, String property)
           
static Project unset(Project project, String... properties)
           
static Object valueof(Object obj, String name)
           
static void verbose(Project P, String msg)
           
static void verbose(Project P, String msg, Exception e)
           
static int vercmp(String va, String vb)
           
static void warning(Project P, String msg)
           
static void warning(Project P, String msg, Exception e)
           
static int write(File name, String s, boolean mode)
           
static void writex(File f, String buf, boolean append)
           
static void writex(InputStream cin, String fname, boolean mode)
           
static Document xmldoc(File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EL

public static final String EL
See Also:
Constant Field Values

VARREF

public static final int VARREF
See Also:
Constant Field Values

PROPTY

public static final int PROPTY
See Also:
Constant Field Values

WRITEPROPTY

public static final int WRITEPROPTY
See Also:
Constant Field Values
Constructor Detail

Static

public Static()
Method Detail

assign

public static final Project assign(Project project,
                                   String key,
                                   Object obj,
                                   int type)
Assign an object either as variable or as property to a given project.

Parameters:
project - not null
key - not null
obj - null allowed
type - must be either Static.VARREF, Static.PROPTY or Static.WRITEPROPTY
Returns:
project

_log_

public static final void _log_(Project P,
                               String msg,
                               int type)

log

public static final void log(Project P,
                             String msg,
                             Exception e)

log

public static final void log(Project P,
                             String msg)

info

public static final void info(Project P,
                              String msg,
                              Exception e)

info

public static final void info(Project P,
                              String msg)

verbose

public static final void verbose(Project P,
                                 String msg,
                                 Exception e)

verbose

public static final void verbose(Project P,
                                 String msg)

debug

public static final void debug(Project P,
                               String msg,
                               Exception e)

debug

public static final void debug(Project P,
                               String msg)

error

public static final void error(Project P,
                               String msg,
                               Exception e)

error

public static final void error(Project P,
                               String msg)

warning

public static final void warning(Project P,
                                 String msg,
                                 Exception e)

warning

public static final void warning(Project P,
                                 String msg)

writex

public static final void writex(File f,
                                String buf,
                                boolean append)
                         throws IOException
Throws:
IOException

close

public static final void close(Writer w)

close

public static final void close(OutputStream os)

close

public static final void close(InputStream is)

close

public static final void close(Reader r)

write

public static final int write(File name,
                              String s,
                              boolean mode)

writex

public static final void writex(InputStream cin,
                                String fname,
                                boolean mode)
                         throws IOException
Throws:
IOException

readlines

public static String readlines(Reader reader)

readlines

public static final String readlines(InputStream src)

readlines

public static final String readlines(String src)

readlines

public static final String readlines(File src)

bufread

public static final String[] bufread(String buf)

bufread

public static final String[] bufread(File fname)

split

public static final String[] split(String v,
                                   String c)

trimNonDigit

public static final String trimNonDigit(String V)

contains

public static final int contains(String v,
                                 char c)

tag2ver

public static final String tag2ver(String V)

jar2var

public static final String jar2var(String V)
Translates a given loc name in it's official dependency name.


mkchrseq

public static final String mkchrseq(String c,
                                    int n)

center

public static final String center(String S,
                                  int width,
                                  String chr)

logo

public static final String logo(String msg,
                                int width)

logo

public static final String logo(String msg)

throwbx

public static final void throwbx(String S)

throwbx

public static final void throwbx(String S,
                                 Exception e)

vercmp

public static final int vercmp(String va,
                               String vb)

getstem

public static final String getstem(String S)
                            throws BuildException
Throws:
BuildException

fcopy

public static final void fcopy(File src,
                               File dst)
                        throws Exception
Throws:
Exception

copy

public static final void copy(InputStream src,
                              OutputStream dst)
                       throws Exception
Throws:
Exception

grep

public static final String[] grep(Project project,
                                  String regexpr)
                           throws Exception
Throws:
Exception

methodbyname

public static final Method methodbyname(Class C,
                                        String name,
                                        Class[] type)
                                 throws NoSuchMethodException,
                                        SecurityException
Throws:
NoSuchMethodException
SecurityException

invoke

public static final Object invoke(Object obj,
                                  String name,
                                  Class[] type,
                                  Object[] args)
                           throws Exception
Throws:
Exception

fieldbyname

public static final Field fieldbyname(Class clazz,
                                      String name)

getattr

public static final Object getattr(Object obj,
                                   String name)
                            throws IllegalAccessException
Throws:
IllegalAccessException

setattr

public static final void setattr(Object obj,
                                 String name,
                                 Object val)
                          throws IllegalAccessException
Throws:
IllegalAccessException

valueof

public static final Object valueof(Object obj,
                                   String name)
                            throws IllegalAccessException
Throws:
IllegalAccessException

htabremove

public static final boolean htabremove(Object obj,
                                       String att,
                                       String key)
Removes a Hashtable entry. The hashtable must be available as * attribute att of object instance obj. * The entry to remove is given by key key. Note that * this method does not care about accessability, i.e. it allows * to remove a key from a private Hashtable. * *

Parameters:
obj - might be null *
att - might be null *
key - might be null * *
Returns:
true in case key could be removed from Hashtable denoted * by attribute att.

issubclass

public static final boolean issubclass(Class clazz,
                                       Class base)
tests whether class obj is a subclass of base. * *

Returns:
true if clazz is a subclass of base (or equals base).

comphelper

public static final ComponentHelper comphelper(Project P)

compdef

public static final AntTypeDefinition compdef(Project project,
                                              String property)

makecomp

public static final Object makecomp(Project P,
                                    String s)
shortcut to create a component


getclass

public static final Class getclass(Project P,
                                   String s)
shortcut to get a component's class


isproperty

public static final boolean isproperty(Project P,
                                       String property)

isreference

public static final boolean isreference(Project P,
                                        String id)

istarget

public static final boolean istarget(Project P,
                                     String s)

istask

public static final boolean istask(Project P,
                                   String s)

istaskdef

public static final boolean istaskdef(Project P,
                                      String s)

ismacrodef

public static final boolean ismacrodef(Project P,
                                       String s)

property

public static final String property(Project P,
                                    String property)

reference

public static final Object reference(Project P,
                                     String id)

target

public static final Object target(Project project,
                                  String property)

taskdef

public static final AntTypeDefinition taskdef(Project project,
                                              String property)

macrodef

public static final AntTypeDefinition macrodef(Project project,
                                               String property)

task

public static final AntTypeDefinition task(Project project,
                                           String property)

type

public static final Object type(Project project,
                                String property)

filter

public static final Object filter(Project project,
                                  String property)

patternAsRegex

public static final String patternAsRegex(String glob)

escape

protected static final String escape(String s,
                                     char esc)
escape all non-alphanumeric characters in s by escape character esc.

Parameters:
s - not null

escape

protected static final String escape(char c,
                                     char esc)
escape non-alphanumeric character c by escape character esc.

Parameters:
c - character in question
esc - the escape character
Returns:
c if c is alpanumeric character otherwise return esc.

replace

protected static final String replace(String s,
                                      char c,
                                      String sub)
replace all c characters in s with string sub.

Parameters:
s - not null

substring

protected static final String substring(String s,
                                        int i,
                                        int J)
similar as s.substring(i,j) except that j is allowed to be larger than s.length(). If j is less then i, the empty string is returned. Otherwise function behaves as s.substring(i,j).

Parameters:
s - not null

isprintable

public static final boolean isprintable(char c)
* test whether a character is printable. * *

Parameters:
c - character to test *
Returns:
true if printable

istext

public static final boolean istext(char c)
* test whether a character is a 'textual' character, i.e. * not a binary character. * *

Parameters:
c - character to test *
Returns:
true if non-binary character.

isbinary

public static final boolean isbinary(char c)
* test whether a character is a 'textual' character, i.e. * not a binary character. * *

Parameters:
c - character to test *
Returns:
true if non-binary character.

trim3

public static final String trim3(Project project,
                                 String s,
                                 String otherwise)

trim2

public static final String trim2(String s,
                                 String otherwise)
Trim a given string. This version of trim ensures that the result value is not an empty string, i.e. a string consisting only of whitespace characters. If an empty string would be returned after trimming down, the alternative


empty

public static final boolean empty(String s)

isEmpty

public static final boolean isEmpty(String s)

cat

public static final String cat(Project P,
                               File file)

xmldoc

public static final Document xmldoc(File file)
                             throws Exception
Throws:
Exception

loadxml

public static final Element loadxml(Project P,
                                    File file)

stripEmptyLines

public static final String stripEmptyLines(String buf)

tidyxml

protected static final void tidyxml(DOMSource source)
Cleans up the empty lines and tab after removing the nodes

Parameters:
source -

flushxml

public static final String flushxml(Project P,
                                    Element root,
                                    StringBuffer buf)

flushxml

public static final String flushxml(Project P,
                                    Element root,
                                    File file)

nodeattribute

public static final String nodeattribute(Node node,
                                         String name,
                                         String otherwise)

getxmldoc

public static final Document getxmldoc(InputStream stream)
                                throws Exception
Throws:
Exception

isregexchar

public static final boolean isregexchar(char c)

ispatternchar

public static final boolean ispatternchar(char c)

patterncompile

public static final Pattern patterncompile(String S,
                                           int f)
A standard way to compile a given pattern into a RE Pattern. The interpretation of the given string depends on the first and last character:


elresolve

public static final String elresolve(Project project,
                                     String text)
Resolve embedded EL references in text. Text can be an arbitrary text containing one or more references to EL expressions #{..}. Resolving a reference means that the embedded EL expression is evaluated into an object and stringized in a second step.


el2str

public static final String el2str(Project project,
                                  String expr)
Evaluate EL expression in a string context. The given expression is evaluated and in a second step stringized.


el2obj

public static final Object el2obj(Project project,
                                  String expr)
Evaluate EL expression. The expression given must be a native EL expression not containing any embedded #{} references. The expression is simply evaluated and not coerced.


el2file

public static final File el2file(Project project,
                                 String expr)

el2bool

public static final boolean el2bool(Project project,
                                    String expr)
Evaluate a EL expression in a boolean context. Important: The expr given is evaluated as true EL expression. Thus it may not contain EL references like #{..}.


q

public static final String q(String s)

toFile

public static final File toFile(Project project,
                                String s)

unset

public static final Project unset(Project project,
                                  String... properties)

bitset

public static final int bitset(int bitset,
                               int bit,
                               boolean on)