www.element4solution.com

e4s.html
Class E4Method

java.lang.Object
  extended by e4s.util.E4Object
      extended by e4s.html.E4Method
All Implemented Interfaces:
E4Method_Intf
Direct Known Subclasses:
E4MethodPickup, E4MethodSilent

public class E4Method
extends E4Object
implements E4Method_Intf

Stands as placeholder for function within the application that are called via the CGI interface.

Example_A.java

Since:
JDK 1.4
See Also:
A.A(e4s.html.E4Method), E4CgiParams, E4ModuleMethodStatistics, E4MethodSilent, E4ServletImplementation_Intf.PARAM_FUNCTION

Nested Class Summary
static class E4Method.E4MethodStatistics
          Statistical information about E4Method calls.
 
Field Summary
static int SYSTEM_ALIAS
          Adress room for e4s relevant defined (external accessible) aliases codes from , including, this value upwards.
static int USERDEF_ALIAS
          Adress room for user defined (external accessible) aliases codes from , including, this value upwards.
 
Fields inherited from class e4s.util.E4Object
CRLF, E4S_CORE_SYSTEM_LANGUAGE, NBSP, NULLSTR, URL_ENCODING_CHARSET
 
Constructor Summary
E4Method()
          When you create a E4Method, just set it to null.
E4Method(boolean requires_session)
          Create a E4Method object for later reference.
E4Method(E4Method mref)
           
E4Method(int external_alias, java.lang.String description)
          In some cases, you might need a E4Method that can be referenced from outside (e.g. a Web-Page, a menu that comes out of a database).
E4Method(int external_alias, java.lang.String description, boolean requires_session)
          In some cases, you might need a E4Method that can be referenced from outside (e.g. a Web-Page, a menu that comes out of a database).
E4Method(java.lang.reflect.Method method, int aliasUserDef, java.lang.String description, boolean has_class_HTML_as_parameter, boolean has_class_E4CgiParams_as_parameter, boolean requires_session)
          Do not use this constructor, it is intended to be used by the E4S framework internally, to declare all E4Methods and set their apropriate objects.
 
Method Summary
static java.lang.String _getSVNVersionString()
          Get version info string from subversion.
 java.lang.String constructUrl(E4ServletImplementation_Intf servlet)
          Construct a URL in the form: E4ServletImplementation_Intf.getUrl() + "?"
 java.lang.String constructUrl(E4ServletImplementation_Intf servlet, boolean timestamp)
          Construct a URL in the form: E4ServletImplementation_Intf.getUrl() + "?"
 java.lang.String constructUrl(E4ServletImplementation_Intf servlet, E4CgiParams params)
          Construct a URL in the form: E4ServletImplementation_Intf.getUrl() + "?"
static java.lang.String constructUrl(E4ServletImplementation_Intf servlet, int alias)
           
static java.lang.String constructUrl(E4ServletImplementation_Intf servlet, int alias, boolean timestamp)
           
static java.lang.String constructUrl(E4ServletImplementation_Intf servlet, int alias, E4CgiParams params, boolean timestamp)
           
static void dumpStatistics(boolean force)
           
static E4Method_Intf findMethod(int alias)
          Find the E4Method that is associated with a particular alias.
static int findUserDef(int internal_alias)
          Find a user defined alias to an internal ("real") alias identification.
static void forceAlias(E4Method mref, int alias)
          Internal use only
 int getAlias()
          Return the alias code of the function.
 long getAvgBufferSize()
           
 long getAvgDuration()
          Get the average duration in ms.
 long getAvgDurationApp()
          Get the average duration (application only) in ms.
 long getAvgDurationE4S()
          Get the average duration (E4S only) in ms.
 long getCallCounter()
           
 long getCallCounter(int hour)
           
 java.lang.Class getDeclaringClass()
          Get the declaring class for this E4Method object.
 java.lang.String getDescription()
           
static java.lang.String getE4MethodName(int alias)
          Look for a E4Method in the list of registered method, and get the name for it.
 int getExternalAlias()
           
 java.util.Date getFirstCall()
          Get the last call this function was called
 long getFirstCallLng()
           
static int getHighestAlias()
          Find the highest internally alias number.
 java.util.Date getLastCall()
          Get the last call this function was called
 long getLastCallLng()
           
 java.lang.reflect.Method getMethod()
          The method invoved.
 java.lang.String getMethodName()
          Get the full qualified name (package.module.function) for that E4Method
 E4Method.E4MethodStatistics getStats()
           
 long getSumBufferSize()
          Get the size of the HTML output buffer sent to the client.
 long getSumDuration()
          Get the total duration in ms over all calls since the servlet was started.
 long getSumDurationApp()
          Get the total duration (application only) in ms over all calls since the servlet was started.
 long getSumDurationE4S()
          Get the total duration (E4S output only) in ms over all calls since the servlet was started.
static int[] getUserDefinitions()
           
static java.util.Enumeration getVector()
           
 boolean is_E4CgiParams_a_parameter()
          Defines, if E4CgiParams is used as second parameter.
 boolean is_HTML_a_parameter()
          Defines, if HTML is used as first parameter.
 boolean isSilent()
          Check, if a E4Method is silent.
 boolean requiresSession()
          Does this E4Method requires a Session?
 void resetStatistics()
           
 java.lang.String toString()
           
 void updateStatistics(long duration_application, long duration_e4s_output, long buffer_size)
          Increment the call counter by 1 and store statistical values.
 
Methods inherited from class e4s.util.E4Object
Calendar, CName, CName, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelApp, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelNone, E4LabelSys, E4LabelSys, e4sCopyright, e4sVersion, encode, encode, encode, encodeHtml, encodeHtml, encodeHtml, encodeURL, encodeURL, encodeURL, finalize, getLINE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTRACE, getTraceMemory, HtmlEncode, HtmlEncode, HtmlEncode, isdecimal, isdigit, isnotok, isnotok, isnumeric, isok, isok, isok, isok, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingFunction, lastCallingStack, mkdirs, null2nbsp, null2nbsp, null2nbsp, ok, ok, ok, ok, outPrintln, setLogFile4Trace, setTraceMemory, STACKTRACE, toDebug, toDouble, toFloat, toFloat, TRACE_CALLS, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, TRACE, wait
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USERDEF_ALIAS

public static int USERDEF_ALIAS
Adress room for user defined (external accessible) aliases codes from , including, this value upwards.


SYSTEM_ALIAS

public static int SYSTEM_ALIAS
Adress room for e4s relevant defined (external accessible) aliases codes from , including, this value upwards. Not recommended for user and application functions, instead use USERDEF_ALIAS.

See Also:
USERDEF_ALIAS
Constructor Detail

E4Method

public E4Method()
When you create a E4Method, just set it to null. The E4S framework will do the rest for you. So the normal definition should look like:
         public class MyClass extends E4ModuleImplementation
         {
                 public E4Method functionOne = null;
                 public E4Method functionTwo = null;

                 public MyClass(E4ServletImplementation_Intf servlet)
                 {
                         super(servlet);   
                 }

                 public functionOne( HTML html, E4CgiParams params )
                 {
                 }

                 public functionTwo( HTML html, E4CgiParams params )
                 {
                 }
         }   
         


E4Method

public E4Method(E4Method mref)

E4Method

public E4Method(int external_alias,
                java.lang.String description)
In some cases, you might need a E4Method that can be referenced from outside (e.g. a Web-Page, a menu that comes out of a database). For this cases, you can force an alias code. We strongly recommend, that you use alias codes upwards from USERDEF_ALIAS to have room for the automaticaly incremental alias coding schema below and some features to be built in the next release which needs codes above.

Parameters:
alias - the alias code
description - the description of the function - when it shall be listed for default startup, may be null. #see #USERDEF_ALIAS

E4Method

public E4Method(int external_alias,
                java.lang.String description,
                boolean requires_session)
In some cases, you might need a E4Method that can be referenced from outside (e.g. a Web-Page, a menu that comes out of a database). For this cases, you can force an alias code. We strongly recommend, that you use alias codes upwards from USERDEF_ALIAS to have room for the automaticaly incremental alias coding schema below and some features to be built in the next release which needs codes above.

Parameters:
alias - the alias code
description - the description of the function - when it shall be listed for default startup, may be null.
requires_session - true: a session (login) is required #see #USERDEF_ALIAS

E4Method

public E4Method(boolean requires_session)
Create a E4Method object for later reference.

Parameters:
requires_session - true: a session (login) is required

E4Method

public E4Method(java.lang.reflect.Method method,
                int aliasUserDef,
                java.lang.String description,
                boolean has_class_HTML_as_parameter,
                boolean has_class_E4CgiParams_as_parameter,
                boolean requires_session)
Do not use this constructor, it is intended to be used by the E4S framework internally, to declare all E4Methods and set their apropriate objects. Never use this function, unless you are very familary with the internal architecture of the e4s!

See Also:
E4Method()
Method Detail

getVector

public static java.util.Enumeration getVector()

getMethod

public java.lang.reflect.Method getMethod()
Description copied from interface: E4Method_Intf
The method invoved.

Specified by:
getMethod in interface E4Method_Intf
Returns:
a Method used in your application as some kind of a "callback" function.

is_HTML_a_parameter

public boolean is_HTML_a_parameter()
Description copied from interface: E4Method_Intf
Defines, if HTML is used as first parameter.

Specified by:
is_HTML_a_parameter in interface E4Method_Intf
Returns:
true, if HTML is used as first parameter. false if not

is_E4CgiParams_a_parameter

public boolean is_E4CgiParams_a_parameter()
Description copied from interface: E4Method_Intf
Defines, if E4CgiParams is used as second parameter. This requires HTML as first parameter.

Specified by:
is_E4CgiParams_a_parameter in interface E4Method_Intf
Returns:
true, if HTML is used as first parameter. false if not

getE4MethodName

public static java.lang.String getE4MethodName(int alias)
Look for a E4Method in the list of registered method, and get the name for it.

Parameters:
alias - the ID for the method reflection.
Returns:
null if not found, or a String in the format "package.class.function"
See Also:
#findE4Method

getDeclaringClass

public java.lang.Class getDeclaringClass()
Get the declaring class for this E4Method object. This is almost used as initial E4ID for application modules initializing the first HTMLobject by the framework (done in E4ServletImplementation.invoceFunctionHTML(e4s.html.E4Method_Intf, e4s.html.E4CgiParams, e4s.servlet.E4ServletImplementation_Intf)).

Specified by:
getDeclaringClass in interface E4Method_Intf
Returns:
null if method reflection has not been initialized so far or the declaring class.

findMethod

public static E4Method_Intf findMethod(int alias)
Find the E4Method that is associated with a particular alias. The alias will be treatened as E4CgiParams names E4ServletImplementation_Intf.PARAM_FUNCTION. Even if E4Methods are not beeing initialized, E4S will renumber them and give them an internal index (called the "Alias") which by now identifies each E4Method unique and is a placeholder for the Java function associated with. When running the application, you can query a list of the E4Methods along with their alias codes.

Parameters:
alias2 - a valid internal alias code (typically this number starts at 0)
See Also:
getAlias(), E4ServletImplementation_Intf.PARAM_FUNCTION

getAlias

public int getAlias()
Description copied from interface: E4Method_Intf
Return the alias code of the function. The alias is a placeholder, that is defined by the E4ServletImplementation_Intf.PARAM_FUNCTION parameter.

Specified by:
getAlias in interface E4Method_Intf
See Also:
E4ServletImplementation_Intf.PARAM_FUNCTION, A.getAlias()

forceAlias

public static void forceAlias(E4Method mref,
                              int alias)
Internal use only


getDescription

public java.lang.String getDescription()

getHighestAlias

public static int getHighestAlias()
Find the highest internally alias number.


findUserDef

public static int findUserDef(int internal_alias)
Find a user defined alias to an internal ("real") alias identification. Note that this function is intended for debug and trace reasons almost and performance is not very well on a larger number of items.


getExternalAlias

public int getExternalAlias()

toString

public java.lang.String toString()
Overrides:
toString in class E4Object

updateStatistics

public void updateStatistics(long duration_application,
                             long duration_e4s_output,
                             long buffer_size)
Increment the call counter by 1 and store statistical values.

Specified by:
updateStatistics in interface E4Method_Intf
Parameters:
duration_application - time in ms that has been took by the business logic application (application dependent)
duration_e4s_output - time in ms that has been took to handle the HTML elements in their output (e4s dependent)
buffer_size - char's written out to the client

resetStatistics

public void resetStatistics()
Specified by:
resetStatistics in interface E4Method_Intf

getStats

public E4Method.E4MethodStatistics getStats()

getCallCounter

public long getCallCounter()
Specified by:
getCallCounter in interface E4Method_Intf
Returns:
the call counter (how often this method was called after starting up the servlet)

getCallCounter

public long getCallCounter(int hour)

getAvgBufferSize

public long getAvgBufferSize()
Specified by:
getAvgBufferSize in interface E4Method_Intf

getSumBufferSize

public long getSumBufferSize()
Description copied from interface: E4Method_Intf
Get the size of the HTML output buffer sent to the client.

Specified by:
getSumBufferSize in interface E4Method_Intf

getAvgDurationApp

public long getAvgDurationApp()
Description copied from interface: E4Method_Intf
Get the average duration (application only) in ms. Considers all calls since the servlet was started.

Specified by:
getAvgDurationApp in interface E4Method_Intf
Returns:
-1 if no statistics is available or the avarage time in ms

getAvgDurationE4S

public long getAvgDurationE4S()
Description copied from interface: E4Method_Intf
Get the average duration (E4S only) in ms. Considers all calls since the servlet was started.

Specified by:
getAvgDurationE4S in interface E4Method_Intf
Returns:
-1 if no statistics is available or the avarage time in ms

getAvgDuration

public long getAvgDuration()
Description copied from interface: E4Method_Intf
Get the average duration in ms. Considers all calls since the servlet was started.

Specified by:
getAvgDuration in interface E4Method_Intf
Returns:
-1 if no statistics is available or the avarage time in ms

getSumDurationApp

public long getSumDurationApp()
Description copied from interface: E4Method_Intf
Get the total duration (application only) in ms over all calls since the servlet was started.

Specified by:
getSumDurationApp in interface E4Method_Intf
Returns:
-1 if no statistics is available or the total time in ms

getSumDurationE4S

public long getSumDurationE4S()
Description copied from interface: E4Method_Intf
Get the total duration (E4S output only) in ms over all calls since the servlet was started.

Specified by:
getSumDurationE4S in interface E4Method_Intf
Returns:
-1 if no statistics is available or the total time in ms

getSumDuration

public long getSumDuration()
Description copied from interface: E4Method_Intf
Get the total duration in ms over all calls since the servlet was started.

Specified by:
getSumDuration in interface E4Method_Intf
Returns:
-1 if no statistics is available or the total time in ms

getLastCall

public java.util.Date getLastCall()
Get the last call this function was called

Specified by:
getLastCall in interface E4Method_Intf
Returns:
the last date/time

getLastCallLng

public long getLastCallLng()
Specified by:
getLastCallLng in interface E4Method_Intf

getFirstCall

public java.util.Date getFirstCall()
Get the last call this function was called

Specified by:
getFirstCall in interface E4Method_Intf

getFirstCallLng

public long getFirstCallLng()
Specified by:
getFirstCallLng in interface E4Method_Intf

constructUrl

public java.lang.String constructUrl(E4ServletImplementation_Intf servlet)
Description copied from interface: E4Method_Intf
Construct a URL in the form: E4ServletImplementation_Intf.getUrl() + "?" + E4ServletImplementation_Intf.PARAM_FUNCTION + "=" + E4Method_Intf.getAlias()

Specified by:
constructUrl in interface E4Method_Intf
Parameters:
servlet - the servlet context
Returns:
a String representing a Url including the alias code.

constructUrl

public java.lang.String constructUrl(E4ServletImplementation_Intf servlet,
                                     E4CgiParams params)
Description copied from interface: E4Method_Intf
Construct a URL in the form: E4ServletImplementation_Intf.getUrl() + "?" + E4ServletImplementation_Intf.PARAM_FUNCTION + "=" + E4Method_Intf.getAlias()

Specified by:
constructUrl in interface E4Method_Intf
Parameters:
servlet - the servlet context
params - optional additional parameters (if not null)
Returns:
a String representing a Url including the alias code.

constructUrl

public java.lang.String constructUrl(E4ServletImplementation_Intf servlet,
                                     boolean timestamp)
Description copied from interface: E4Method_Intf
Construct a URL in the form: E4ServletImplementation_Intf.getUrl() + "?" + E4ServletImplementation_Intf.PARAM_FUNCTION + "=" + E4Method_Intf.getAlias()

Specified by:
constructUrl in interface E4Method_Intf
Parameters:
servlet - the servlet context
timestamp - if true, a variable TIM=... is appended to make each URL unique
Returns:
a String representing a Url including the alias code.

constructUrl

public static java.lang.String constructUrl(E4ServletImplementation_Intf servlet,
                                            int alias)

constructUrl

public static java.lang.String constructUrl(E4ServletImplementation_Intf servlet,
                                            int alias,
                                            boolean timestamp)

constructUrl

public static java.lang.String constructUrl(E4ServletImplementation_Intf servlet,
                                            int alias,
                                            E4CgiParams params,
                                            boolean timestamp)

isSilent

public boolean isSilent()
Check, if a E4Method is silent.

Specified by:
isSilent in interface E4Method_Intf
Returns:
false

getUserDefinitions

public static int[] getUserDefinitions()

requiresSession

public boolean requiresSession()
Does this E4Method requires a Session? This might be a differentiation at construction.

Specified by:
requiresSession in interface E4Method_Intf
Returns:
true if a session is required (which is the default behavior)
See Also:
E4ServletImplementation_Intf.getSession(), E4Method( int, String, boolean )

getMethodName

public java.lang.String getMethodName()
Get the full qualified name (package.module.function) for that E4Method

Returns:
e.g. "e4s.application.appmodule.E4ModuleMainMenu.mainMenu"

dumpStatistics

public static void dumpStatistics(boolean force)

_getSVNVersionString

public static java.lang.String _getSVNVersionString()
Get version info string from subversion.

Returns:
the version info string.
See Also:
E4Util.getRevisionCodeFromSVN(Class)

www.element4solution.com