//we will parse methods only
if (aTokens[j].endsWith(")")) {
String s5;
MethodElement aMethodeElement = new MethodElement();
// at first we have to take care of the exception
if (aTokens[j].indexOf("raises") != -1) {
s5 = aTokens[j].substring(0,aTokens[j].indexOf("raises")-2);
String s5b = aTokens[j].substring(aTokens[j].indexOf("raises") + 6);
//if s5b not 0 - then we have to deal with the exceptions
if (s5b.length() != 0 ) {
String s6 = s5b.trim().substring(1);
s6 = s6.substring(0,s6.length()-1);
StringTokenizer stt6 = new StringTokenizer(s6,",");
int btokens = stt6.countTokens();
Identifier[] aExceptions = new Identifier[btokens];
for(int a=0; a < btokens;a++) {
aExceptions[a] = Identifier.create(OOTools.replaceSubStrings(stt6.nextToken().trim(),"::", "."));
}
try {
aMethodeElement.setExceptions(aExceptions);
}catch (Exception e){
System.out.println( e );
}
}
} else s5 = aTokens[j].substring(0,aTokens[j].length()-1);
// s5 contains only the methode without an exception
// it is possible the the line starts with a comment
// which was inserted at the end of the line before
StringTokenizer st5 = new StringTokenizer(s5,"(");
// if we have a methode with has no parameter - st5 will contain only one token
// it does no matter if the method raises a eception or not.
// that means we have to test the token count
// we have to care about the parameters only if the count is 2
StringTokenizer st6 = new StringTokenizer(st5.nextToken().trim()," ");
// after we have created st6 - n tokens
// n should be the name of the function
// n - 1 is definitely the return type of the function
// n - 2 could be a modifier or the keyword oneway or simply a
// word of a comment
// n-3 to 0 all stuff we do not need
int ctokens = st6.countTokens();
String returnType = null;
try {
if (ctokens > 3)
{ for(int b=0; b < ctokens-3;b++) {
st6.nextToken();
}
}
if (ctokens>=3) {
// this could be the modifier
String ModifierString = st6.nextToken();
if ((ModifierString=="public") || (ModifierString=="protected") || (ModifierString=="private")) {
if (ModifierString=="public") aMethodeElement.setModifiers(java.lang.reflect.Modifier.PUBLIC);
if (ModifierString=="protected") aMethodeElement.setModifiers(java.lang.reflect.Modifier.PROTECTED);
if (ModifierString=="private") aMethodeElement.setModifiers(java.lang.reflect.Modifier.PRIVATE);
}else{aMethodeElement.setModifiers(java.lang.reflect.Modifier.PUBLIC); }
}
if (ctokens==2) aMethodeElement.setModifiers(java.lang.reflect.Modifier.PUBLIC);
returnType = st6.nextToken();
aMethodeElement.setName(Identifier.create(st6.nextToken()));
String sss = this.mapParameterTypes(returnType);
aMethodeElement.setReturn(Type.parse(this.mapParameterTypes(returnType)));
}catch (Exception e){
System.out.println( e );
};
// test how many tokens are left over in st5
if (st5.countTokens()== 1) {
// due to the fact that st5 still contains one token, we have to take care of the parameters
st6 = new StringTokenizer(st5.nextToken(),",");
tokens = st6.countTokens();
org.openide.src.MethodParameter[] aMethodeParameters = new org.openide.src.MethodParameter[tokens];
for(int k=0; k < tokens;k++)
{ String aTypeString;
StringTokenizer st7 = new StringTokenizer(st6.nextToken().trim()," ");
// now we have the certain parameter
String Direction = st7.nextToken();
if (Direction.indexOf("out")!= -1) aTypeString = "sequence<" + st7.nextToken()+">";
else aTypeString = st7.nextToken();
String bString = st7.nextToken();
aMethodeParameters[k] = new org.openide.src.MethodParameter(bString, Type.parse(this.mapParameterTypes(aTypeString)), false);
}
try {
aMethodeElement.setParameters(aMethodeParameters);
} catch (Exception e){
System.out.println( e );
}
}
try {
// Define an empty return command.
String stringReturnCommand = "";
// Test if return type is not void.
if ( !returnType.equals( "void" ) ) {
// Get the Java type of the method.
String stringJavaType = this.mapParameterTypes(
returnType );
if ( ( stringJavaType.equals( "short" )
|| ( stringJavaType.equals( "int" ) )
|| ( stringJavaType.equals( "long" ) )
|| ( stringJavaType.equals( "float" ) )
|| ( stringJavaType.equals( "double" ) )
|| ( stringJavaType.equals( "char" ) )
|| ( stringJavaType.equals( "byte" ) ) ) ) {
stringReturnCommand = "\nreturn 0;\n";
}
else if ( stringJavaType.equals( "boolean" ) ) {
stringReturnCommand = "\nreturn false;\n";
}
else {
stringReturnCommand = "\nreturn null;\n";
}
}
aMethodeElement.setBody(
"\n\n\n// ToDo: Please insert your implementation code "
+ "here.\n\n" + stringReturnCommand );
IDLMethod aIDLMethod = new IDLMethod();
aIDLMethod.setMethod(aMethodeElement);
bIDLInterface.addIDLMethod(aIDLMethod);