Commit 5aa8b31d authored by Arpad Lovassy's avatar Arpad Lovassy
Browse files

fixed comment, removed import, indentation, removed extra ws


Signed-off-by: Arpad Lovassy's avatarzlovarp <arpad.lovassy@semcon.com>
parent 97848270
......@@ -12,7 +12,7 @@
###############################################################################
# Creates C++ header from the Java code for Java to C++ JNI function calls.
# This must run if any of the native Java methods change (in org.eclipse.titan.executor.jni.JNIMiddleWare).
# This must be run if any of the native Java methods change (in org.eclipse.titan.executor.jni.JNIMiddleWare).
# A C++ function header is generated for each native Java method.
# Native Java method: declared with native keyword without implementation
# This script generates these files into ../../JNI/ directory:
......
......@@ -20,9 +20,9 @@ import org.eclipse.titan.executorapi.exception.JniExecutorIllegalArgumentExcepti
* Contains the data describing a Host Controller.
*/
public final class HostController {
// Exception texts
/** Used by the constructor */
private static final String EXCEPTION_TEXT_ILLEGAL_ARG_WORKINGDIR_NULL = "Working directory is null";
/** Used by the constructor */
......@@ -31,17 +31,17 @@ public final class HostController {
private static final String EXCEPTION_TEXT_ILLEGAL_ARG_WORKINGDIR_NOT_EXIST = "Working directory does NOT exists";
/** Used by the constructor */
private static final String EXCEPTION_TEXT_ILLEGAL_ARG_EXECUTABLE_NOT_EXIST = "Executable does NOT exists";
/**
* The name of the host, it can be null, default: null (localhost)
*/
private String mHost = null;
/**
* The working directory to use when executing commands
*/
private String mWorkingDirectory;
/**
* The executable if the Host Controller.
* This executable is started (with 2 parameters: MC host, MC port)
......@@ -66,7 +66,7 @@ public final class HostController {
} else if ( aExecutable == null ) {
throw new JniExecutorIllegalArgumentException( EXCEPTION_TEXT_ILLEGAL_ARG_EXECUTABLE_NULL );
}
if ( isLocalhost(aHost) ) {
// if working directory directory is local, it must exist
final File workingDir = new File(aWorkingdirectory);
......@@ -81,12 +81,12 @@ public final class HostController {
throw new JniExecutorIllegalArgumentException( EXCEPTION_TEXT_ILLEGAL_ARG_EXECUTABLE_NOT_EXIST );
}
}
this.mHost = aHost;
this.mWorkingDirectory = aWorkingdirectory;
this.mExecutable = aExecutable;
}
public String getHost() {
return mHost;
}
......@@ -115,10 +115,10 @@ public final class HostController {
commandSb.append( mHost );
commandSb.append( " " );
}
// local host
// cd %Workingdirectory; %Executable %MCHost %MCPort
commandSb.append( "cd " );
commandSb.append( mWorkingDirectory );
commandSb.append( "; ./" );
......@@ -129,7 +129,7 @@ public final class HostController {
commandSb.append( aMcPort );
return commandSb.toString();
}
/**
* Checks if the host name is localhost
* @param aHostName the host name, it can be IP address, it can be null
......@@ -142,7 +142,7 @@ public final class HostController {
"localhost".equalsIgnoreCase( aHostName ) ||
"0.0.0.0".equalsIgnoreCase( aHostName ) ||
"NULL".equalsIgnoreCase( aHostName )
);
);
}
}
......@@ -12,7 +12,6 @@
******************************************************************************/
package org.eclipse.titan.executorapi;
import java.util.List;
import java.util.Map;
import org.eclipse.titan.executor.jni.McStateEnum;
......@@ -24,7 +23,7 @@ import org.eclipse.titan.executor.jni.VerdictTypeEnum;
* @see JniExecutor
*/
public interface IJniExecutorObserver {
/**
* Notification about status change. It also means, that the asynchronous request is finished successfully, if aNewState is the final state.
* @param aNewState the new MC state
......@@ -41,20 +40,20 @@ public interface IJniExecutorObserver {
/**
* Notification callback, information comes from MC
* @param aTime timestamp
* @param aSource source, the machine identifier of MC
* @param aSource source, the machine identifier of MC
* @param aSeverity message severity
* @param aMsg message text
*/
void notify(final Timeval aTime, final String aSource, final int aSeverity, final String aMsg);
/**
* Verdict notification, that comes after execution of a testcase.
* If a test control is executed, this notification is sent multiple times after each testcase.
* @param aTestcase name of the testcase
* @param aVerdictType verdict type
*/
*/
void verdict( final String aTestcase, final VerdictTypeEnum aVerdictType );
/**
* Verdict statistics notification, that comes after executing all the testcases after exit MTC.
* This notification is sent only once for a MTC session.
......
......@@ -25,7 +25,7 @@ import org.eclipse.titan.executorapi.JniExecutor;
* @see JniExecutor#init()
*/
public class JniExecutorJniLoadException extends JniExecutorException {
/**
* Generated serial version ID
* (to avoid warning)
......@@ -35,7 +35,7 @@ public class JniExecutorJniLoadException extends JniExecutorException {
public JniExecutorJniLoadException( final String aMsg ) {
super( aMsg );
}
public JniExecutorJniLoadException(String aMsg, final Throwable aCause) {
super( aMsg, aCause );
......
......@@ -52,7 +52,7 @@ import java.util.Map;
* </pre>
*/
public class Log {
/**
* Severity of the log message, log level
* @see "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html"
......@@ -60,40 +60,40 @@ public class Log {
private enum Severity {
/** The OFF has the highest possible rank and is intended to turn off logging. */
OFF,
/** The FATAL level designates very severe error events that will presumably lead the application to abort. */
FATAL,
/** The ERROR level designates error events that might still allow the application to continue running. */
ERROR,
/** The WARN level designates potentially harmful situations. */
WARN,
/** The INFO level designates informational messages that highlight the progress of the application at coarse-grained level. */
INFO,
/** The DEBUG Level designates fine-grained informational events that are most useful to debug an application. */
DEBUG,
/** The TRACE Level designates finer-grained informational events than the DEBUG */
TRACE,
/** The ALL has the lowest possible rank and is intended to turn on all logging. */
ALL;
};
/**
* Global log level.
* It effects all the projects that use Log.
*/
private static Severity sLogLevel = Severity.OFF;
/**
* Date format for function related logging functions: fi(), fo(), f()
*/
private static final SimpleDateFormat sFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
/**
* Keeps track the call level for each thread.
* Call level is a number, that is increased, when a function entry point is logged (fi() is called),
......@@ -102,13 +102,13 @@ public class Log {
* Negative call level is treated as 0.
*/
private static Map<Long, Integer> sCallLevels = new HashMap<Long, Integer>();
/**
* Logging states separately for each thread.
* Logging can be switched off separately for each thread. true: on, false: off. Default value: true.
*/
private static Map<Long, Boolean> sLoggingStates = new HashMap<Long, Boolean>();
/**
* Function in.
* Logs the entry and the given parameter(s) of the method in DEBUG level.
......@@ -120,20 +120,20 @@ public class Log {
if ( !checkLogLevel( Severity.DEBUG ) || isThreadLoggingOff() ) {
return;
}
StringBuilder sb = new StringBuilder();
logDateAndThreadId(sb);
sb.append(" -> ");
final int callLevel = getCallLevel();
setCallLevel( callLevel + 1 );
for (int i = 0; i < callLevel; i++) {
sb.append(" ");
sb.append(" ");
}
// 0: getStackTrace(), 1: logMethodName(), 2: fi(), 3: this is the caller function we want to log
logMethodName( sb, 3 );
// log parameters
sb.append("(");
if ( aParams.length > 0 ) {
......@@ -147,10 +147,10 @@ public class Log {
sb.append(" ");
}
sb.append(")");
printLog( sb );
}
/**
* Function out.
* Logs the exit and the given return value of the method in DEBUG level.
......@@ -162,20 +162,20 @@ public class Log {
if ( !checkLogLevel( Severity.DEBUG ) || isThreadLoggingOff() ) {
return;
}
StringBuilder sb = new StringBuilder();
logDateAndThreadId(sb);
sb.append( " <- " );
int callLevel = getCallLevel();
setCallLevel( --callLevel );
for (int i = 0; i < callLevel; i++) {
sb.append(" ");
}
// 0: getStackTrace(), 1: logMethodName(), 2: fo (this private), 3: fo (one of the public ones), 4: this is caller the function we want to log
logMethodName( sb, 4 );
// log return value (if any)
sb.append("()");
if ( aHasReturnValue ) {
......@@ -184,7 +184,7 @@ public class Log {
}
printLog( sb );
}
/**
* Function out.
* Logs the exit of the method (but not the return value) in DEBUG level.
......@@ -193,7 +193,7 @@ public class Log {
public static void fo() {
fo( false, null );
}
/**
* Function out.
* Logs the exit and the given return value of the method in DEBUG level.
......@@ -203,7 +203,7 @@ public class Log {
public static void fo( final Object aReturnValue ) {
fo( true, aReturnValue );
}
/**
* function log (just a general log within the function)
* @param aMsg log message
......@@ -212,16 +212,16 @@ public class Log {
if ( !checkLogLevel( Severity.TRACE ) || isThreadLoggingOff() ) {
return;
}
StringBuilder sb = new StringBuilder();
logDateAndThreadId(sb);
sb.append( " " );
final int callLevel = getCallLevel();
for (int i = 0; i < callLevel; i++) {
sb.append(" ");
sb.append(" ");
}
if ( aMsg != null && aMsg.contains( "\n" ) ) {
// in case of multiline message other lines are also indented with the same number of spaces
final int len = sb.length();
......@@ -230,9 +230,9 @@ public class Log {
StringBuilder sbSpaces = new StringBuilder( len );
sbSpaces.append("\n");
for (int i = 0; i < len; i++) {
sbSpaces.append(" ");
sbSpaces.append(" ");
}
// replace \n -> sbSpaces in sbMsg
StringUtil.replaceString( sbMsg, "\n", sbSpaces.toString() );
sb.append( sbMsg );
......@@ -240,7 +240,7 @@ public class Log {
else {
sb.append( aMsg );
}
printLog( sb );
}
......@@ -257,7 +257,7 @@ public class Log {
sb.append( " " + aMsg );
printLog( sb );
}
/**
* info unformatted (without datetime)
* @param aMsg log message
......@@ -269,7 +269,7 @@ public class Log {
StringBuilder sb = new StringBuilder( aMsg );
printLog( sb );
}
/**
* Switch on logging for the current thread
*/
......@@ -285,7 +285,7 @@ public class Log {
final long threadId = Thread.currentThread().getId();
sLoggingStates.put(threadId, false);
}
/**
* Adds full datetime and thread id to the log string.
* @param aSb [in/out] the log string, where new strings are added
......@@ -294,7 +294,7 @@ public class Log {
final long threadId = Thread.currentThread().getId();
aSb.append( sFormat.format( new Date() ) + " " + String.format( "%3d", threadId ) );
}
/**
* Checks if the global static log level reaches the minimum required log level,
* @param aMinRequired minimum required log level
......@@ -303,7 +303,7 @@ public class Log {
private static boolean checkLogLevel( final Severity aMinRequired ) {
return sLogLevel.ordinal() >= aMinRequired.ordinal();
}
/**
* Adds class and method name to the log string.
* Short class name is used without full qualification.
......@@ -318,21 +318,21 @@ public class Log {
final String methodName = ste.getMethodName();
aSb.append( shortClassName + "." + methodName );
}
/**
* @return true if logging for the current thread switched off.
* If there is no info for this thread, a new (<current thread>, true) item is added to the map
*/
private static boolean isThreadLoggingOff() {
final long threadId = Thread.currentThread().getId();
if(!sLoggingStates.containsKey(threadId)) {
sLoggingStates.put(threadId, true);
}
return !sLoggingStates.get( threadId );
}
/**
* @return Call level for the current thread.
* If there is no info for this thread, a new (<current thread>, 0) item is added to the map
......@@ -345,7 +345,7 @@ public class Log {
final int callLevel = sCallLevels.get( threadId );
return callLevel;
}
/**
* Sets the call level of the current thread.
* If sCallLevels does NOT contain current thread as key, it creates it.
......@@ -355,7 +355,7 @@ public class Log {
final long threadId = Thread.currentThread().getId();
sCallLevels.put( threadId, aNewValue );
}
/**
* prints the log string to the output
* @param aLogString the log string, it can be multiline
......
......@@ -27,7 +27,7 @@ import java.util.Map;
* replaceString(): indent(), Log.f()
*/
public class StringUtil {
/**
* Replaces all the occurrences of a given string
* @param aSb [in/out] the string to modify
......@@ -37,12 +37,12 @@ public class StringUtil {
public static void replaceString( final StringBuilder aSb, final String aFrom, final String aTo ) {
int index = aSb.indexOf( aFrom );
while (index != -1) {
aSb.replace( index, index + aFrom.length(), aTo );
index += aTo.length(); // Move to the end of the replacement
index = aSb.indexOf( aFrom, index );
}
aSb.replace( index, index + aFrom.length(), aTo );
index += aTo.length(); // Move to the end of the replacement
index = aSb.indexOf( aFrom, index );
}
}
/**
* Appends any Object to the given StringBuilder.
* <p>
......@@ -131,7 +131,7 @@ public class StringUtil {
public static void indent( final StringBuilder aSb, final String aIndentString ) {
replaceString( aSb, "\n", "\n" + aIndentString );
}
/**
* @param aPrimitiveArrayCandidate the object to check
* @return true, if aPrimitiveArrayCandidate is a primitive array, like int[], boolean[], ...
......@@ -139,10 +139,10 @@ public class StringUtil {
*/
private static boolean isPrimitiveArray( final Object aPrimitiveArrayCandidate ) {
return aPrimitiveArrayCandidate != null &&
aPrimitiveArrayCandidate.getClass().isArray() &&
aPrimitiveArrayCandidate.getClass().getComponentType().isPrimitive();
aPrimitiveArrayCandidate.getClass().isArray() &&
aPrimitiveArrayCandidate.getClass().getComponentType().isPrimitive();
}
/**
* Converts primitive array to Object array.
* <p>
......@@ -153,15 +153,15 @@ public class StringUtil {
* @see #isPrimitiveArray(Object)
*/
private static Object[] toObjectArray( final Object aPrimitiveArray ) {
if ( aPrimitiveArray instanceof Object[] ) {
return ( Object[] )aPrimitiveArray;
}
int arrlength = Array.getLength( aPrimitiveArray );
Object[] outputArray = new Object[ arrlength ];
for(int i = 0; i < arrlength; ++i) {
outputArray[i] = Array.get( aPrimitiveArray, i );
}
return outputArray;
if ( aPrimitiveArray instanceof Object[] ) {
return ( Object[] )aPrimitiveArray;
}
int arrlength = Array.getLength( aPrimitiveArray );
Object[] outputArray = new Object[ arrlength ];
for(int i = 0; i < arrlength; ++i) {
outputArray[i] = Array.get( aPrimitiveArray, i );
}
return outputArray;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment