OakJava7 Advanced Samples
=========================================================================
Sample 28: OAKJAVA7(JAVA7.0) Security
=========================================================================
Oakjava7 Security
Oakjava7 provides high security when compared to all the programming languages
We can see this medium security in detail, which is invented at year 2020.
Write a Scroll java7 program maintaining security for the next page:-
j7prog.java7
<JAVA7>
public <CLASS> j7prog {
<MAIN>
{
HTML.displayhtml("Registermem.html");
}
}
Registermem.html
<html>
<form action="http://localhost:9000/Jquerytest7.exe" method="post" >
<tr> <h2><td><a href="#chapter1"> Enter your Details </a></td></h2></tr>
<tr>
<td><p>Enter Your Name: <input type="text" name="name" size="25" /></td></p></tr>
<tr><td><p>Enter your Username : <input type="text" name="uname" size="15"/></td></p></tr>
<tr><td><p>Enter the password : <input type="password" name="password" size="25" /></td></p></tr>
<tr><td><p>Choose your state : <input type="text" name="state" size="15"/></td></p></tr>
<tr><td><p>Choose your Country : <input type="text" name="country" size="15"/></td></p></tr>
<tr><td><p>Enter the password : <input type="password" name="spwd" size="25" /></td></p></tr>
<tr><td><p>Enter your secret password text : <input type="text" name="stext" sixe="15"/></td></p></tr>
<tr><td><p>Enter your family details : <input type="text" name="familydet" size="25" /></td></p></tr>
<tr><td><p> Enter Percentage of marks scored <input type="text" name="Indent" sixe="5"/></td></p></tr>
<tr><td><p>Enter Your Favourite subject <input type="text" name="CIndent" size="15"/></td></p></tr>
<td><h2><a href="#chapter2">REGISTER</a></td></h2></tr>
<div>
<td> <input type="submit" name="Click"></td></tr>
<td><input type="reset" name="Clear"></td></tr>
</div>
</form>
</body>
</html>
Explanation:
We found that form action =="http://localhost:9000/Jquerytest7.exe"
This Jquerytest7.exe is generated by Jquerytest7.java7
We will look more brief about Jquerytest7.java7 in next chapters.
So when we run the Scroll server then a scroll webpage is generated
which is given below in the screenshot..
So when we submit the data at j7prog.java7 form it will goes to another url which is
http://localhost:9000/Jquerytest7.exe. It will display the webpage as
invalid username. which are given below in the screenshot..
So inorder to provide medium security for the
oakjava7 webpage , you must enter the security details
at scroll.txt, which is the configuration file
for Oakjava7 security. But <- this backward arrow indicates
for eg) nosniff is assigned to X-Content-Type-Options.
Once you run the scroll server , oakjava7 security is
enabled because you enter security details in
scroll.txt configuration file.
scroll.txt
X-Content-Type-Options <- nosniff
Strict-Transport-Security <- max-age=31536000 ; includeSubDomains
X-Frame-Options <- SAMEORIGIN
X-XSS-Protection <- 1; mode=block
Content-Security-Policy <- default-src 'self' 'unsafe-inline' http://localhost:8082/
Explanation
So when you inspect the http://localhost:9000/Jquerytest7.exe form
you will get the output, which is given below....
Note:
This is about medium security. But it is free for the oakjava7 developers to focus. But Oakjava7 has advanced security that will be mention in Enterprise edition and not at professional edition.
=========================================================================================
Sample 29: OAKJAVA7(JAVA7.0) Logs
=========================================================================================
About OakJava7 Logs
In Oakjava7(JAVA7.0) when your application faces any error, it is
updated in <Filename>Oj7.log. All default logs are stored in
C:\ojava7\Ojava7log\ directory. For example ojindex1.java7
is the oakjava7 program when it is compiled and deployed
in Scroll server , if Oakjava7 program contains errors
and when you stop the Scroll server it will update the errors in file
ojindex1Oj7.log found in C:\ojava7\Ojava7log\ directory.
Let Us see the Log Example....
We create a Oakjava7 program it will retrieve the contents of Html contains
forms. But we did not include the html name correctly ie) at file ojindex1.java7.
Which is given below...
ojindex1.java7
<JAVA7>
public <CLASS> ojindex1 {
<MAIN>
{
//invalid filename wRegiter87.html
HTML.displayhtml("wRegister87.html");
}
}
Explanation
So when the errors come it will display in oakjava7 webpage
and in Logs file. So the Log file contains...
ojindex1Oj7.log
================
May 11, 2023 8:02:31 PM RuntimeExec logOutput
INFO: Oakjava7(JAVA7.0) Log messages
May 11, 2023 8:02:31 PM RuntimeExec logMessage
INFO: Exception in thread "main" Invalid Statements.lang.NullPointerException at HTML.retrieve(HTML.Invalid Statements:28) at HTML.displayhtml(HTML.Invalid Statements:256) at ojindex1.main(ojindex1.Invalid Statements:1) at Invalid Statements.lang.reflect.Method.invoke(Method.Invalid Statements:597) at cli.Starter.Main(Unknown Source)
This NullPointerException indicates that the HTML file is not found.
So when the errors come it will display it in ojindex1.java7, because this
ojindex1.java7 contain errors. So advantages of Oakjava7 logs is
we can history of errors that can be used for future reference , that we
meet the same error. So Logs are userfriendly for us. See the output
for oakjava7 file -> ojindex1.java7 which is given below..if you type the url
http://localhost:9000/ojindex1.java7 it will show the errors in ojindex1.java7
which is given below...
Error Page (ojindex1.java7) Output:
The database file or folder wRegister87.html could not be found! Could not find file 'C:\wilmixjeminfiles\sprogramfiles\jrrr\scrollserver\scroll\wRegister87.html'.Exception in thread "main" Invalid Statements.lang.NullPointerException at HTML.retrieve(HTML.Invalid Statements:28) at HTML.displayhtml(HTML.Invalid Statements:256) at ojindex1.main(ojindex1.Invalid Statements:1) at Invalid Statements.lang.reflect.Method.invoke(Method.Invalid Statements:597) at cli.Starter.Main(Unknown Source)
=========================================================================================
SAMPLE 30 : DELEGATE IN OAKJAVA7
=========================================================================================
DELEGATE
OakJava7(JAVA7.0) delegates are similar to pointers to functions, in C or C++. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.
Declaring Delegates
Delegate declaration determines the methods that can be referenced by the delegate. A delegate can refer to a method, which has the same signature as that of the delegate. In given below syntax @D is the Delegate.
Syntax for Delegate
@D <return type> <delegate-name> <parameter list>
delegate is represented as @D
Instantiating Delegates
Once a delegate type is declared, a delegate object must be created with the new keyword and be associated with a particular method. When creating a delegate, the argument passed to the new expression is written similar to a method call, but without the arguments to the method.
Following example demonstrates declaration, instantiation, and use of a delegate that can be used to reference methods that take an integer parameter and returns an integer value.
Delegateexample1.web
<WEB>
@D int Delegatenochange(int n);
<PACK> DelegateApp1 {
<CLASS> TestDelegate {
static int num = 10;
public static int AddNum(int p) {
num += p;
return num;
}
public static int MultNum(int q) {
num *= q;
return num;
}
public static int DivideNum(int r) {
num /= r;
return num;
}
public static int getNum() {
return num;
}
public void main()
{
//create delegate instances
Delegatenochange noc1 = new Delegatenochange(AddNum);
Delegatenochange noc2 = new Delegatenochange(MultNum);
Delegatenochange noc3 = new Delegatenochange(DivideNum);
//calling the methods using the delegate objects
noc1(25);
<PRINTLN>("Value of Num: {0}", getNum());
noc2(5);
<PRINTLN>("Value of Num: {0}", getNum());
noc3(10);
<PRINTLN>("Value of Num: {0}", getNum());
Console.ReadKey();
}
}
}
Explanation
Using @D int Delegatenochange(int n); we create a delegate for
a method. It means we can pass method as parameters.
consider the example it is given below...
//num value is assigned to 10
static int num = 10;
public static int AddNum(int p) {
num += p;
return num;
}
After that we are creating Delegate instance ie)
Delegatenochange noc1 = new Delegatenochange(AddNum);
Once you have created it ,then pass the value as a parameter to delegate instance eg) noc1(25).
So 10+25 => 35, here 10 is the num value and 25 is the parameter value passed to AddNum method using Delegate, so we get the output as 35. Similarly you do as a exercises for the rest of the them.
Output
Value of Num: 35
Value of Num: 175
Value of Num: 17
=========================================================================================
SAMPLE 31 : PREDICATE and Predicate with DELEGATE in OakJava7
=========================================================================================
Predicate and Predicate with Delegate in OakJava7
Predicate is represented as @P
Predicate is the delegate like Func and Action delegates. It represents a method containing a set of criteria and checks whether the passed parameter meets those criteria. A predicate delegate methods must take one input parameter and return a boolean - true or false.
The Predicate delegate is defined in the Oakjava7 Package(namespace) , as shown below:
Predicate signature
public @D bool @P <in T>(T obj);
Same as other delegate types, Predicate can also be used with any method, anonymous method, or lambda expression.
j7Pr8.web
<WEB>
<PACK> j7Prsample2
{
<CLASS> J7Pr8
{
public void main()
{
@P < string > CheckIfNokia = @D(string modelName) {
if (modelName == "Nokia") return true;
else return false;
};
bool result = CheckIfNokia("Nokia");
if (result) <PRINTLN>("Nokia is a olden cellphone");
}
}
}
Explanation
For this given example..
@P < string > CheckIfNokia = @D(string modelName) {
if (modelName == "Nokia") return true;
else return false;
};
Here @P is the predicate and @D is the delegate. Predicate represents a method containing a set of criteria ( eg) if modelName=Nokia or not) and check whether the passed parameter meets those criteria.
eg) bool result = CheckIfNokia("Nokia");
if (result) <PRINTLN>("Nokia is a olden cellphone"). For this oakjava7 program it displays Nokia is a olden cellphone. Because the given modelName parameter value is equal to "Nokia".
Output
Nokia is a olden cellphone
==================================================================================
Sample 32: Predicate and Delegate examples
==================================================================================
Question: Find the Factorial , Sin,Exp, value of the given expression ie) y,y1
and asinh,acosh ,atanh,String using delegate
and Count no of Books,Count no of Negative numbers,Count no of empty book title
and find factorial (0! to 9!) and 6! (6 factorial) ?
j7Pr111.web
<WEB>
<PACK> j7rsample112
{
public <CLASS> J7r111
{
static int Factorial(int n)
{
return n < 1 ? 1 : n * Factorial(n - 1);
}
static Func<int, int> Factorial()
{
Func<int, int> factorial = null;
factorial = n => n < 1 ? 1 : n * factorial(n - 1);
return factorial;
}
public static int Count<T>(T[] arr, @P <T> condition)
{
int counter = 0;
for (int i = 0; i < arr.Length; i++)
if (condition(arr[i]))
counter++;
return counter;
}
public void main()
{
Func<double, double> f1 = Math.Sin;
Func<double, double> f2 = Math.Exp;
double y = f1(2) + f2(3); //y=sin(2) + exp(3)
f2 = f1;
y = f2(9); //y=sin(9)
<PRINTLN>("fx result1="+y);
Func<double, double> f4 = @D (double x1) { return 8*x1+1; };
double y1 = f4(3);
f4 = x1 => 32*x1+1;
y1 = f4(6);
<PRINTLN>("fx result2 with @D ="+y1);
Func<double, double> asinh1 = @D (double x1) { return Math.Log( x1 + Math.Sqrt(x1*x1+1) );} ;
Func<double, double> acosh1 = x => Math.Log( x + Math.Sqrt(x*x-1) ) ;
Func<double, double> atanh1 = x2 => 0.2*( Math.Log( 1 + x2 ) - Math.Log( 1 -x2 ) ) ;
double y5 = asinh1(3);
double y6 = acosh1(4);
double y7 = atanh1(0.6);
<PRINTLN>("asinh with @D ="+y5);
<PRINTLN>("acosh with @D ="+y6);
<PRINTLN>("atanh with @D ="+y7);
@P <string> longWords = @D (string word) { return word.Length < 10; };
bool y8 = longWords("Madam");
string[] words = {"Madam","jackie",""};
int[] books = {456,789};
int book=0;
<PRINTLN>("String with @D ="+y8);
int Names = Count(words, longWords);
<PRINTLN>("Count names="+Names);
book = Count(books, @D (int ip) { return ip > 20; });
<PRINTLN>("Count no of Books="+book);
int[] numbers = {-1,-45,1,4,100,-200,-20000,567};
int NegativeNumbers = Count(numbers, x => x < 0);
<PRINTLN>("NegativeNumbers count="+NegativeNumbers);
int EmptyBookTitles = Count(words, String.IsNullOrEmpty);
<PRINTLN>("Empty book title count="+EmptyBookTitles);
var fl = Factorial();
for(int i=0; i<10; i++)
<PRINTLN>("{0}! = {1}", i, fl(i));
int[] numbers1 = new[] { 5,1,3,7,2,6,4};
Func<int, int> factorial = @D (int num) {
Func<int, int> locFactorial = null;
locFactorial = n => n == 1 ? 1 : n * locFactorial(n - 1);
return locFactorial(num);
};
int s=factorial(6);
<PRINTLN>("Factorial Result ="+ s);
}
}
}
Explanation
Now here we are adding data 256 and "Bill" to the ArrayList
ArrayList list <NEW> ArrayList();
list.Add(256); // boxing
list.Add("Bill");
and it will print [256,Bill] as output.
==============================================
object o = 1010;
int i = (int)o; //performs unboxing
<PRINTLN>("UnBoxing result ="+i);
we know that the process of converting a Reference Type variable into a Value Type variable. This can be done by casting, eg) (int) of object instance o. ie) int i=(int)o; This gives a Unboxing value which is stored in variable i.
=========================================================================
Func<double, double> f4 = @D (double x1) { return 8*x1+1; };
double y1 = f4(3);
f4 = x1 => 32*x1+1;
y1 = f4(6);
So when you use y1=f4(6), that means
6 is assigned to x1 , ie) 32 *6 +1=> 193
=============================================================
Here in this given statement
@P <string> longWords = @D (string word) { return word.Length < 10; };
bool y8 = longWords("Madam");
The "Madam" string is passed to LongWords method , it
will check when word.Length < 10 or not. If it is
less than 10 then return the boolean value as true.
==========================================================
simillarly when longwords = madam is passed at Count
(words,longwords) when the Word.length < 10 then the
counter value gets incremented ie) in this sample ....
string[] words = {"Madam","jackie",""};
here "madam" string length is 5 , jackie=6 , ""=0
which are less than 10 ; so the counter value becomes 3.
int Names = Count(words, longWords);
so we get the output Count names=3
==========================================================
books = {456,789}
book = Count(books, @D (int ip) { return ip > 20; });
<PRINTLN>("Count no of Books="+book);
here we see in the given above statement that
456 > 20, 789> 20 ; So the counter value =2.
so we get the output Count no of Books=2.
==============================================================
int[] numbers = {-1,-45,1,4,100,-200,-20000,567};
int NegativeNumbers = Count(numbers, x => x < 0);
<PRINTLN>("NegativeNumbers count="+NegativeNumbers);
here in this given above statement integer numbers array
is passed which contain 4 positive numbers.we have passed
predicate condition as x => x < 0 in the count function.
This conditions will check all the numbers in the numbers array.
so there are 4 positive numbers in that numbers array
so the counter is incremented 4 times.so we get the
output NegativeNumbers count=4.
==============================================================
int EmptyBookTitles = Count(words, String.IsNullOrEmpty);
here the words array contain 2 elements and 1 empty string
so when we pass String.IsNullOrEmpty in Count function
this match with the 3rd element that is 1 empty string
present in words array. So the counter is incremented 1
time.so we get the output Empty book title count=1
===============================================================
var fl = Factorial();
for(int i=0; i<10; i++)
<PRINTLN>("{0}! = {1}", i, fl(i));
This i represent ith element ie from ( 0 to 9)
f1(i) =>f1(0),f1(1),f1(2),f1(3),f1(4),f1(5),f1(6),f1(7),f1(8),f1(9)
Here f1 is the factorial function, For loop is repeated 10 times
from (0 to 9).
So we get the output as given below
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
====================================================================
We are finding the factorial of 6 ie) 6!
int s=factorial(6);
<PRINTLN>("Factorial Result ="+ s);
when we pass the value 6 to factorial recursion function.
it will multiply the value = 6 *5 * 4* 3* 2 * 1 = 720.
eg)
static int Factorial(int n)
{
return n < 1 ? 1 : n * Factorial(n - 1);
}
until n < 1 the recursion take place.
So we get the output as given below
Factorial Result =720
====================================================
Output
fx result1=0.412118485241757
fx result2 with delegate =193
asinh with delegate =1.81844645923207
acosh with delegate =2.06343706889556
atanh with delegate =0.277258872223978
String with delegate =True
Count names=3
Count no of Books=2
NegativeNumbers count=4
Empty book title count=1
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
Factorial Result =720
==================================================================================
Sample 33 : AutoBoxing and UnBoxing
==================================================================================
Boxing In OAKJAVA7
The process of converting a Value Type variable (char, int etc.) to a Reference Type variable (object) is called Boxing.
Boxing is an implicit conversion process in which object type (super type) is used.
Value Type variables are always stored in Stack memory, while Reference Type variables are stored in Heap memory.
UnBoxing in OAKJAVA7
The process of converting a Reference Type variable into a Value Type variable is known as Unboxing. It is an explicit conversion process.
J7Pr10.web
<WEB>
// Load oakjava7 util package.
<USE> <OJ7UTIL>
<PACK> j7Prsample10
{
<CLASS> J7Pr10
{
//Boxing in Oakjava7
public void main()
{
ArrayList list <NEW> ArrayList();
list.Add(256); // boxing
list.Add("Bill");
<PRINTLN>("Boxing result ="+list);
object o = 1010;
int i = (int)o; //performs unboxing
<PRINTLN>("UnBoxing result ="+i);
}
}
}
Explanation
Now here we are adding data 256 and "Bill" to the ArrayList
ArrayList list <NEW> ArrayList();
list.Add(256); // boxing
list.Add("Bill");
and it will print [256,Bill] as output.
object o = 1010;
int i = (int)o; //performs unboxing
<PRINTLN>("UnBoxing result ="+i);
we know that the process of converting a Reference Type variable into a Value Type variable. This
can be done by casting, eg) (int) of object instance o.
ie) int i=(int)o; This gives a Unboxing value which is stored in variable i.
Output:
Boxing result =[256, Bill]
UnBoxing result =1010
=========================================================================================
Sample 34:Lambdaj7 in Oakjava7
=========================================================================================
What is Lambdaj7 expression?
Lambda expressions are anonymous functions that contain expressions or sequence of operators.
All lambda expressions use the lambda operator @L, that can be read as “goes to” or “becomes”.
The left side of the lambda operator specifies the input parameters and the right side holds
an expression or a code block that works with the entry parameters.
Here we can see about Lambda Pass by value, Lambda function condition check all the numbers which is Odd or not, Perform ADD operations by passing 10,10 value in add method, Action , Delegate, Predicate, anonymous function to print the given value.
lamdaj7.web
<WEB>
<PACK> Program8
{
<CLASS> Prog
{
static int Sum(int x, int y)
{
return x + y;
}
static bool IsUpperCase(string str)
{
return str.Equals(str.ToUpper());
}
public @D void Print(int value);
public void main()
{
// statement lambda that takes two int inputs and returns the sum
@A<string> greet = name @L
{
string greeting = "Hello";
<PRINTLN>(greeting+name);
};
greet("World");
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
Func <int,bool> oddNumbers = n @L n % 2 == 1;
<PRINTLN>("There are "+oddNumbers(5)+" odd numbers in "+ string.Join(" ", numbers));
//streams
Func<int,int, int> add = Sum;
int result = add(10, 10);
<PRINTLN>(result);
@A<int> printActionDel = @D(int i)
{
<PRINTLN>(i);
};
printActionDel(10);
//predicate
@P <string> isUpper = IsUpperCase;
bool result1 = isUpper("hello world!!");
<PRINTLN>(result1);
//anonymous
Print print = @D(int val) {
<PRINTLN>("Inside Anonymous method. Value: {0}", val);
};
print(100);
}
}
}
Output
HelloWorld
There are True odd numbers in 5 4 1 3 9 8 6 7 2 0
20
10
False
Inside Anonymous method. Value: 100
Explanation
i) Lambda Pass by value and concat the strings greeting and
name.
@A<string> greet = name @L
{
string greeting = "Hello";
<PRINTLN>(greeting+name);
};
greet("World");
Here "@L" says that it is a lambda function.
when greet function is called and string "World" is
passed to the Lambda function. In the Lambda function
when greeting ="Hello" and greeting and name value is
passed to the print statement.Here name variable is
assigned as "World". So we will get output as "HelloWorld".
ii) Lambda function condition check all the numbers which is Odd or not?
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
Func <int,bool> oddNumbers = n @L n % 2 == 1;
<PRINTLN>("There are "+oddNumbers(5)+" odd numbers in "+ string.Join(" ", numbers));
Here "@L" says that it is a lamda function.And we are assigning the
return type in Func function as int,boolean(bool).
ie) Func <int,bool> . Where n @L n % 2 == 1 is the lamda function condition.
It will check whether integers in numbers array is odd number or not.
so When the OddNumbers(5) is invoked and the print statement
will print boolean value as true. So this string.Join(" ",numbers) will
print numbers array complete contents. So we will get output as given below
There are True odd numbers in 5 4 1 3 9 8 6 7 2 0
iii) Perform ADD operations by passing 10,10 value in add method.
Func<int,int, int> add = Sum;
int result = add(10, 10);
<PRINTLN>(result);
static int Sum(int x, int y)
{
return x + y;
}
Here we are using 3 integers datatype in Func<int,int,int> and
we are assuming Sum method to add function; so it will perform
Sum operations using method Sum(int x, int y). When we pass the value
in add function which is given below..
add(10, 10) and we use <PRINTLN> statement to print the result value.
So we will get output as 20.
iv) Use Action Delegate to print the value which you passed
in printActionDel(10) method.
@A<int> printActionDel = @D(int i)
{
<PRINTLN>(i);
};
printActionDel(10);
What is Action Delegate ?
Action type delegate is the same as Func delegate except that
the Action delegate doesn't return a value. In other words, an
Action delegate can be used with a method that has a void return type.
Action Delegate is represented as @A in oakjava7 program.
Using object of Action delegate printActionDel(10) will print the value
as 10 as the output. Because we use <PRINTLN>(i) statement inside
Action Delegate block.
v) Check whether the given string is UpperCase or not. and print that boolean value
@P<string> isUpper = IsUpperCase;
bool result1 = isUpper("hello world!!");
<PRINTLN>(result1);
Predicate is the delegate like Func and Action delegates.
It represents a method containing a set of criteria and checks whether the
passed parameter meets those criteria. A predicate delegate methods must take one
input parameter and return a boolean - true or false.
Predicate Syntax
public @D bool @P<in T>(T obj);
Here at Predicate object isUpper is assigned a IsUpperCase functions.
so when we pass the value "hello world!!" to the Predicate object
isUpper will return the boolean value as false.Because it will check
whether the value "hello world!!" is UpperCase or not. But here it
is Lowercase so it return a value false as the output when we
print the result value.
vi) use anonymous function to print the given value.
//anonymous
Print print = @D(int val) {
<PRINTLN>("Inside Anonymous method. Value: {0}", val);
};
print(100);
Here in this Anonymous function object print(100)
means value 100 is passed to print Anonymous method.
val is assigned 100 as a value.
So <PRINTLN> will print the output which is given
below ...
Inside Anonymous method. Value: 100
=========================================================================
Sample 35: Define and Explain forward , include , visitor count,ip address and hostname internationalization with an example
=========================================================================================
1) Forward Action
==================
Syntax
======
public static forward list=new forward("{key}",arraylistobject);
It is used to forward a request or a list or set of data to another page.
Here {key} indicates the key , arraylistObject indicates arraylist object.
2) Include Action
==================
Syntax-1
=========
Java7request.include("<htmlfilename>",choice,"html");
It is used to insert a file into the same page.
Here <filename> given is html file name.
eg) Java7request.include("test.html",0,"html");
And "html" indicates it is html type file.
So choice =0 indicates that the filename belong to html file or
any other type filename.
Syntax-2
=========
Java7request.include("<otherfilename>",choice,"exe");
Here when we don't give htmlfilename and give as other filename and choice =1
and "exe" indicates that it is a executable file name. Then it will include
executable filename and it is called as assembly file.
eg) Java7request.include("autocomplete",1,"exe");
Syntax-3
========
Java7request.include("<otherfilename>",choice,"ojava7");
Here when we don't give htmlfilename and give as other filename and choice =2
and "ojava7" indicates that it is a oakjava7 file name and it is also an executable filename.
Then it will include oakjava7 executable filename and it is called as Oakjava7 assembly file.
eg) Java7request.include("jarray",2,"ojava7");
3) Visitor Count
================
Syntax:
=======
Java7request.Visitorscount("visitorname");
Visitor count will be incremented every time a person visit the page
and it's return value is always an integer.
eg) int count =Java7request.Visitorscount("visitor1");
Here visitor1 is the Visitorscount name.
4) Visitor clear count
=======================
Syntax
=======
Java7request.Clearcount("visitorname");
Visitor count will be cleared when the person visit the page 5 times
ie) if count > 5 then count =0;
and it's return value is always an void.
eg)
if (count >5)
Java7request.Clearcount("visitor1");
5) Date in Oakjava7
===================
Date d=new Date();
=> It is used to create date object d.
<PRINTLN>("Second of the minute is : "+d.getSeconds());
=> It is used to get seconds from our current date hour.
6) OakJava7 - internationalization i18n
=======================================
Locale[] locales = { new Locale("en", "US"),
new Locale("es", "ES"), new Locale("it", "IT") };
=> Locale[] contains array of US english, es Spanish, it Itally locale objects.
for (int i=0; i<3; i++)
{
String displayLanguage = locales[i].getDisplayLanguage(locales[i]);
<PRINTLN>(" "+locales[i].ToString() + " = " + displayLanguage);
<PRINTLN>("<BR>");
}
=> Here locales[i].getDisplayLanguage(locales[i]);
is to display languages as English, español, italiano
=> Here locales[i].ToString() will display as en_US, es_ES, it_IT repectively
for display languages as English, español, italiano
7) IP Address and Hostname
===========================
Syntax
======
Java7request.FindIPandHostname();
It is used to display IP address and Hostname for your machine
8) AutoRefresh Page
===================
Syntax
======
Java7request.AutoRefresh(n);
It will automatically refresh the page every n seconds
eg) Java7request.AutoRefresh(3000);
In this given example it will refresh the page
every 3 seconds.
Sample35.web
<WEB>
<USE> ScrollLib;//load ScrollLib packages
<USE> <OJ7UTIL> //load oakjava7 util packages
<PACK> example1
{
public <CLASS> Java7eg1
{
public static forward list= null;
public static void Java7eg1t2()
{
ArrayList ar = new ArrayList();
ArrayList ar1 = new ArrayList();
for(int i=0;i<100;i++)
ar.add(i);
for(int i=100;i<200;i++)
ar1.add(i);
list=new forward("language0",ar);
list.setValue("language1",ar1);
}
public void main()
{
<TRY>
{
Java7request.include("test.html",0,"html");
// Java7request.include("autocomplete",1,"exe");
// Java7request.include("jarray",2,"ojava7");
// Java7request.AutoRefresh(3000);
int count=Java7request.Visitorscount("visitor1");
Java7request.FindIPandHostname();
<PRINTLN>("visitor count="+count);
<PRINTLN>("<BR>");
if (count >5)
Java7request.Clearcount("visitor1");
Date d=new Date();
<PRINTLN>("Second of the minute is : "+d.getSeconds());
<PRINTLN>("<BR>");
Locale[] locales = { new Locale("en", "US"),
new Locale("es", "ES"), new Locale("it", "IT") };
for (int i=0; i<3; i++)
{
String displayLanguage = locales[i].getDisplayLanguage(locales[i]);
<PRINTLN>(" "+locales[i].ToString() + " = " + displayLanguage);
<PRINTLN>("<BR>");
}
<PRINTLN>("<BR>");
<PRINTLN>("<BR>");
HTML.displayhtml("Register100.html");
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
}
}
}
}
Note: It will display test.html form and the given below output and
after that it will display Register100.html form.
Output
Your current IP address : DESKTOP-H7QSQP2/192.162.67.5
Your current Hostname : DESKTOP-H7QSQP2
visitor count=6
<BR>
Second of the minute is : 47
<BR>
en_US = English
<BR>
es_ES = español
<BR>
it_IT = italiano
<BR>
=========================================================================================
Sample 36: Define and Explain first Page for forward action and Next page for forward action output.
=======================================================================================
Sample35.web contains static method Java7eg1t2().
Sample35.web
public static void Java7eg1t2()
{
ArrayList ar = new ArrayList();
ArrayList ar1 = new ArrayList();
for(int i=0;i<100;i++)
ar.add(i);
for(int i=100;i<200;i++)
ar1.add(i);
list=new forward("language0",ar);
//This statement will set arraylist value to ar1
list.setValue("language1",ar1);
}
Explanation
Arraylist ar contains 100 elements from 0 to 99
and Arraylist ar1 contains 100 elements from 100 to 199.
and Forward Action assumes two Arraylist objects ar and ar1.
Now see the second page program...
Sample36.web
<WEB>
<USE> ScrollLib;// load the ScrollLib util package
<USE> <OJ7UTIL>//load oakjava7 util packages
<USE> example1; // load the firstpage package example1
<PACK> example2
{
<CLASS> Java7eg2
{
public void main()
{
<TRY>
{
//Call the public static method Java7eg1t()
Java7eg1.Java7eg1t();
//ar1
ArrayList ars = Java7eg1.list.getForwardValue("language1");
<PRINTLN>(ars.get(90));
//ar
ArrayList ars1 = Java7eg1.list.getForwardValue("language0");
<PRINTLN>(" ");
<PRINTLN>(ars1.get(80));
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
}
}
}
}
Explanation
After calling the public static method Java7eg1t() method which is
Java7eg1.Java7eg1t(),Java7eg1 represent the name of class and Java7eg1t() is the method name for Java7eg1.
which is called in Sample36.web and it will intialize the array list ars and ars2 values
of forward action values which are language1,language0 respectively which can be done which are given below....
ArrayList ars = Java7eg1.list.getForwardValue("language1");
// Note this Java7eg1.list.getForwardValue("language1") will return the Arraylist object Forward action "language1" value and which is assign to arraylist ars
<PRINTLN>(ars.get(90));
ArrayList ars1 = Java7eg1.list.getForwardValue("language0");
// Note this Java7eg1.list.getForwardValue("language0") will return the Arraylist object Forward action "language0" value
and which is assign to arraylist ars1
<PRINTLN>(" ");
<PRINTLN>(ars1.get(80));
So ars.get(90) arraylist contains 190 as value because we assigned the values of For loop from
100 to 199 and we add this to ar1 arraylist in sample35 program which is given below ...
for(int i=100;i<200;i++)
ar1.add(i);
and ars1.get(80) will contain 80 value because we assigned the values of For loop from
1 to 99.
We know finally block will execute whether error happens or not.
So it display the value with String "190 80The Finally block is executed..."
as output. So the output will be given below..
Output:
190 80The Finally block is executed...
==================================================================================
Sample 37: Define and Explain OakJava7 Context,OakJava7 Session, OakJava7 Config
==================================================================================
OakJava7 Context
OakJava7 Context will have constant Oakjava7 context values and it reduces the need of
xml file. So it will carry to be used with in the OakJava7 Web Application and
at the next OakJava7 Web application. Syntax is given below..
public static Java7Context <contextobject> = new Java7Context("Key=Value");
Java7 Context should be used outside any methods or main method. When you store
the values using this given above syntax. and when you use this given below syntax.
<Classname first program>.<contextobject>.get(Index).ToString();
we can retreive the value and we can print it by using the syntax which is given above...
example)
public static Java7Context list = new Java7Context("Secretno=1089678");
Program.list.get(0).ToString();
[where Program indicates Sessiontracking classname and list is the context object,
and we can get the first value by using get(0).ToString().]
OakJava7 Session
OakJava7 Session is created using the given below syntax...
public static Java7Session <sessionobject> = new Java7Session("<key>","<value>");
This is used to create OakJava7 Session, with key and value.
OakJava7 Session is used to carry data or array list of data to the page(filename.exe) that you have mentioned in html file.
OakJava7 Session can retrieve the value by using the given below Syntax.
<classname>.<sessionobject>.getSessionValue("<key>");
example)
public static Java7Session list1 = new Java7Session("No of employees","1000 employees");
public static void p()
{
list1.setValue("seqno1","2000 values");
list1.setValue("seqno2","2001 values");
list1.setValue("seqno3","2005 values");
}
so using <sessionobject>.setValue(....) function we can store many keys and value needed for the next page.
OakJava7 Config
OakJava7 Config is used to retrieve the configuration information. Example
using Java7Config.getParameter("Driver").
Syntax
Java7Config.getParameter("<configuration key name>");
J7Config.config file is a global Oakjava7Config file which is used to store all the configuration
information and such configuration will be used by the Oakjava7 programs.
eg) This <- arrow indicates that sun.jdbc.Driver is assigned to a key Driver.
This given below example indicates how to store the information with key and value parameters.
J7Config.config
Driver <- sun.jdbc.Driver
First Program
Sample37.web
<WEB>
<USE> ScrollLib;
<PACK> example11
{
public <CLASS> Program
{
public static Java7Session list1 = new Java7Session("No of employees","1000 employees");
public static Java7Context list = new Java7Context("Secretno=1089678");
public static void p()
{
list1.setValue("seqno1","2000 values");
list1.setValue("seqno2","2001 values");
list1.setValue("seqno3","2005 values");
}
}
}
Note: This program will generate a .dll file when you compile using javac7 <filename.web>.Put that filename.web.dll in oakjava7 properties file and after that copy that generated .dll file from outputs directory to d:\ or c:\oakjava7\src directory.
Second Program
Sample371.web
<WEB>
<USE> ScrollLib;
<USE> example11;
<PACK> Sessiontracks1
{
<CLASS> Program1
{
public void main()
{
<TRY>
{
<PRINTLN>(" <BR> ");
//intialize and add the session data or session Arraylist data.
Program.p();
<PRINTLN>(" <BR> ");
<PRINTLN>("Session value of seqno1 ="+Program.list1.getSessionValue("seqno1"));
<PRINTLN>(" <BR> ");
<PRINTLN>("OakJava7Context ="+Program.list.get(0).ToString());
<PRINTLN>(" <BR> ");
<PRINTLN>("Java7config="+Java7Config.getParameter("Driver"));
<PRINTLN>(" <BR> ");
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
}
}
}
}
Final Output:-
Session value of seqno1 =2000 values
OakJava7Context =Secretno=1089678
Java7config=sun.jdbc.Driver
The Finally block is executed...
==================================================================================================================================================================================================
OAKJava7(JAVA7.0) Advanced Concepts : OakJava7 Streams
=======================================================================================
==================================================================================
Sample 38: OakJava7 Streams Introduction
==================================================================================
OakJava7 Streams
OakJava7 stream is invented by J. Wilmix jemin at year 2023. This project
takes the time for me around 1 month to build the OakJava7 Streams.
Streams are more important for the development to do
any program. OakJava7 stream is learnable.
In Java (Jdk1.8) streams are not learnable.So
Oakjava7 stream is nothing but it is same as
Jdk1.8 stream.So if you know Jdk1.8 then
you can easily learn OakJava7 Stream.
OakJava7 Streams represent a pipeline through which data will flow and the functions to
operate on the data. A pipeline in this instance consists of a stream source, followed by
zero or more intermediate operations, and a terminal operation.
OakJava7 Streams are used to optimize the oakjava7 source code.
But there are 8 blocks of streams which are given below....
Stream() block ,Read Ln block ,Display block,Streamagg() block,Streamfx() block,
Stream.Generate block,LOGIC block, and ParallelStream() block.
When these types of Block are used ? Explain it briefly ?
Mostly it is not to memorize all the blocks ,but you
have to say only the types of block during the oakjava7 interview.
Even if you don't use Read Ln block ,Display block,
Stream.Generate block,LOGIC block the oakjava7 compiler
will not throw error.
Stream() block
Stream block are the streams which contains
stream objects that can call any functions.
that is represented as
Stream()->
................
})->
where ...... represents Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block.
Stream()-> block is represented with Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block, Streams() are like pipeline.
Other Streams Block
Like Stream() block other Stream block like
Streamagg() block,Streamfx() block, and ParallelStream() block
functions the same things but the syntax may differ.
Streamfx() Block
Streamfx()->
......
Functions....
})->
where ...... represents Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block.
Where Functions represents Oakjava7 functions...
So only Oakjava7 functions should be mentioned in this
block.
Streamagg() block
========================
Streamagg()->
......
Agg f(x) in oj7stream
....
})->
where ...... represents Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block.
Where Functions represents Oakjava7 Aggregate functions...
So only Oakjava7 aggregate functions should be mentioned in this
block.
ParallelStream() block
In ParallelStream() Block stream
will display the data in a non sequence random order.
But Streams() block data will display the
datas in a sequence order. This is the
major difference between Stream() block
and Parallel stream block.. Parallel stream block
syntax is given below...
ParallelStream()
Read Ln block , LOGIC block, and Display block
The Read Ln block syntax is given below...
READLN(I->{
.........
Input statements...
})->
where ...... represents Read Ln block statements should be mentioned .So only
Input data should be mentioned according to the
rules of OakJava7 Stream. So it is good for
the client to read your program and analyze the Input
functionality which is mentioned in the
ReadLn block.
The Display block syntax is given below...
DISPLAY(O->{
.........
Output statements...
})->
where ...... represents Display block,
and ,LOGIC block.So only
Display statements(eg is Print statements and it's related statements) should be mentioned according to the rules of OakJava7 Stream. So it is good for
the client to read your program and analyze the output
functionality which is mentioned in the
DISPLAY block.
The Logic Block syntax is given below...
LOGIC(L->{
......... Logical statements...
})->
where ...... represents LOGICAL block statements should be represented in this Logic Block.Ie) only
Display statements(eg is Print statements and it's related statements) should be mentioned according to the rules of OakJava7 Stream. So it is good for the client to read your program and analyze the
functionality which is mentioned in the Logic block.
Stream.Generate block
When the business requirement became very complex or
hard or medium we must focus on Stream.Generate block.
It is same as Stream.Generate block followed by
limit() and skip functions or foreach functions.
So the Syntax for Stream.Generate block is given below...
Stream.Generate(()->{
......... Stream.Generate releated Logical statements.. or double for..loop or
double while -- loop or complex ,hard or medium statements..
})->
Where Stream.Generate releated Logical statements . or double for..loop or
double while -- loop or complex ,hard or medium statements..
example for Stream.Generate() is given below...
Medium problem : Ascending or descending order...
Stream.Generate(()->{
for (int i=0;i<n ;i++)
{
for (int j=0;j<n ;j++)
{
if (a[i] > a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
})->
Note: We can see more detail about this 8 blocks like
Stream() block ,Read Ln block ,Display block,Streamagg() block,Streamfx() block,
Stream.Generate block,LOGIC block, and ParallelStream() block.
=============================================================================================
==============================================================================================
Sample 39: OakJava7 Streams :Sample -1 : Use of J7Filter and list array containing numbers.
==========================================================================================
Write a OakJava7 stream program using J7Filter (OakJava7 Filter) and Print the List array containing numbers present in the List.
oj7stream.web
<WEB> // Start point of oakjava7 program,it is mandatory.
// All the Oakjava7(JAVA7.0) namespace <PACK> should be used,
// so without namespace <PACK> will result in error and your oakjava7 program
// will not work correctly.
<PACK> sample1
{
public <CLASS> Programn
{
public void main()
{
// starting point of oakjava7 stream
Stream()->
// Input data stream -> READLN
READLN(I->{
int a=5;
int b=3;
int salary = 200000;
float f=123;
// letters arranged and oakjava7 array dimension should be focus on left side.
char []letters= { 'W', 'e', 'b'};
String a1="Madam";
String a2=a1+"1";
// pass the letter character array to string
string s1 <NEW> string(letters);
string s2 <NEW> string(letters);
})->
// Printing all the oakJava7 filter values using J7Print ie) Oakjava7Print statement.
DISPLAY(O->{
// J7Filter (Oakjava7 filter) returns boolean value only; and that J7filter value is passed to oakjava7 Print statement.
//check the condition if the salary is greater than 10000 value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( salary > 10000));
//check the condition if the salary is greater than 10000 value ,if f value is greater than 121.0 or not or a1 value is "Madam" or not.
// If both conditions return true then the result will be the true value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( (salary > 10000)&& (f>121.0)&&(a1=="Madam" ) ));
//check if a value is equal to 5 or not. if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( a ==5));
//check if a a value is greater than b or not. if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( a >b));
//check if a a value is less than b or not. if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( a < b));
//check if a a value is greater than b or not. and b value is equal to zero or not.
//If both conditions return true then the result will be the true value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( (a >b) && (b==0)));
//check if a a value is greater than b or not. and b value is equal to zero or not.
//If any of the conditions return true then the result will be the true value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( (a >b)|| (b==0)));
//if (a!=0) then J7Filter return true. otherwise return false...
obj->J7Print(obj->J7Filter(a!=0));
//if (a==a2) then J7Filter return true. otherwise return false...
obj->J7Print(obj->J7Filter(a1==a2));
//if (s1 equals s2) then J7Filter return true. otherwise return false...
// ie) Equals is used for string object comparison
obj->J7Print(obj->J7Filter(s1.Equals(s2) ));
// Assign numbers like (11,17,19,30,48,53,19) to the List
// <OJ7UTIL> is the oakjava7 util package.
<OJ7UTIL>.List lop= <OJ7UTIL>.Arrays.asList(11,17,19,30,48,53,19);
// Print the lop array List using J7Print by passing lop to J7Print function.
obj->J7Print(lop);
})->
<PRINTLN>("--------------------");
}
}
}
Explanation
I have already explained by giving comments above the Oakjava7 statements. J7Filter is for checking the condition. If the condition matches it will return a boolean value true or it will return false.
Note:
In the OakJava7 properties file you must use OJ7Stream.dll file. Go to
c:\ wilmix or create a directory in C or d drive or which directory you have created , start Visual studio
and type the command which is given below...
Use PS C:\wilmix> ./oj7stream
to run the program in visual studio code Editor.
Output
==============================================================================================
Note: This Oakjava7 Advanced Samples webpage is under construction for text alignment.
Here we covered 30% of Advanced samples , but remaining 70% of Advanced samples
will be found at Oakjava7 Enterprise Edition., and it is not found at Professional Edition.
But in Professional edition you can't learn about Oakjava7 templates. In Enterprise Edition
you can study more about OakJava7 Templates ,Security , Oakjava7 Advanced topics ,etc.
Note:
This is about medium security. But it is free for the oakjava7 developers to focus. But Oakjava7 has advanced security that will be mention in Enterprise edition and not at professional edition.
=========================================================================================
Sample 29: OAKJAVA7(JAVA7.0) Logs
=========================================================================================
About OakJava7 Logs
In Oakjava7(JAVA7.0) when your application faces any error, it is
updated in <Filename>Oj7.log. All default logs are stored in
C:\ojava7\Ojava7log\ directory. For example ojindex1.java7
is the oakjava7 program when it is compiled and deployed
in Scroll server , if Oakjava7 program contains errors
and when you stop the Scroll server it will update the errors in file
ojindex1Oj7.log found in C:\ojava7\Ojava7log\ directory.
Let Us see the Log Example....
We create a Oakjava7 program it will retrieve the contents of Html contains
forms. But we did not include the html name correctly ie) at file ojindex1.java7.
Which is given below...
ojindex1.java7
<JAVA7>
public <CLASS> ojindex1 {
<MAIN>
{
//invalid filename wRegiter87.html
HTML.displayhtml("wRegister87.html");
}
}
Explanation
So when the errors come it will display in oakjava7 webpage
and in Logs file. So the Log file contains...
ojindex1Oj7.log
================
May 11, 2023 8:02:31 PM RuntimeExec logOutput
INFO: Oakjava7(JAVA7.0) Log messages
May 11, 2023 8:02:31 PM RuntimeExec logMessage
INFO: Exception in thread "main" Invalid Statements.lang.NullPointerException at HTML.retrieve(HTML.Invalid Statements:28) at HTML.displayhtml(HTML.Invalid Statements:256) at ojindex1.main(ojindex1.Invalid Statements:1) at Invalid Statements.lang.reflect.Method.invoke(Method.Invalid Statements:597) at cli.Starter.Main(Unknown Source)
This NullPointerException indicates that the HTML file is not found.
So when the errors come it will display it in ojindex1.java7, because this
ojindex1.java7 contain errors. So advantages of Oakjava7 logs is
we can history of errors that can be used for future reference , that we
meet the same error. So Logs are userfriendly for us. See the output
for oakjava7 file -> ojindex1.java7 which is given below..if you type the url
http://localhost:9000/ojindex1.java7 it will show the errors in ojindex1.java7
which is given below...
Error Page (ojindex1.java7) Output:
The database file or folder wRegister87.html could not be found! Could not find file 'C:\wilmixjeminfiles\sprogramfiles\jrrr\scrollserver\scroll\wRegister87.html'.Exception in thread "main" Invalid Statements.lang.NullPointerException at HTML.retrieve(HTML.Invalid Statements:28) at HTML.displayhtml(HTML.Invalid Statements:256) at ojindex1.main(ojindex1.Invalid Statements:1) at Invalid Statements.lang.reflect.Method.invoke(Method.Invalid Statements:597) at cli.Starter.Main(Unknown Source)
=========================================================================================
SAMPLE 30 : DELEGATE IN OAKJAVA7
=========================================================================================
DELEGATE
OakJava7(JAVA7.0) delegates are similar to pointers to functions, in C or C++. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.
Declaring Delegates
Delegate declaration determines the methods that can be referenced by the delegate. A delegate can refer to a method, which has the same signature as that of the delegate. In given below syntax @D is the Delegate.
Syntax for Delegate
@D <return type> <delegate-name> <parameter list>
delegate is represented as @D
Instantiating Delegates
Once a delegate type is declared, a delegate object must be created with the new keyword and be associated with a particular method. When creating a delegate, the argument passed to the new expression is written similar to a method call, but without the arguments to the method.
Following example demonstrates declaration, instantiation, and use of a delegate that can be used to reference methods that take an integer parameter and returns an integer value.
Delegateexample1.web
<WEB>
@D int Delegatenochange(int n);
<PACK> DelegateApp1 {
<CLASS> TestDelegate {
static int num = 10;
public static int AddNum(int p) {
num += p;
return num;
}
public static int MultNum(int q) {
num *= q;
return num;
}
public static int DivideNum(int r) {
num /= r;
return num;
}
public static int getNum() {
return num;
}
public void main()
{
//create delegate instances
Delegatenochange noc1 = new Delegatenochange(AddNum);
Delegatenochange noc2 = new Delegatenochange(MultNum);
Delegatenochange noc3 = new Delegatenochange(DivideNum);
//calling the methods using the delegate objects
noc1(25);
<PRINTLN>("Value of Num: {0}", getNum());
noc2(5);
<PRINTLN>("Value of Num: {0}", getNum());
noc3(10);
<PRINTLN>("Value of Num: {0}", getNum());
Console.ReadKey();
}
}
}
Explanation
Using @D int Delegatenochange(int n); we create a delegate for
a method. It means we can pass method as parameters.
consider the example it is given below...
//num value is assigned to 10
static int num = 10;
public static int AddNum(int p) {
num += p;
return num;
}
After that we are creating Delegate instance ie)
Delegatenochange noc1 = new Delegatenochange(AddNum);
Once you have created it ,then pass the value as a parameter to delegate instance eg) noc1(25).
So 10+25 => 35, here 10 is the num value and 25 is the parameter value passed to AddNum method using Delegate, so we get the output as 35. Similarly you do as a exercises for the rest of the them.
Output
Value of Num: 35
Value of Num: 175
Value of Num: 17
=========================================================================================
SAMPLE 31 : PREDICATE and Predicate with DELEGATE in OakJava7
=========================================================================================
Predicate and Predicate with Delegate in OakJava7
Predicate is represented as @P
Predicate is the delegate like Func and Action delegates. It represents a method containing a set of criteria and checks whether the passed parameter meets those criteria. A predicate delegate methods must take one input parameter and return a boolean - true or false.
The Predicate delegate is defined in the Oakjava7 Package(namespace) , as shown below:
Predicate signature
public @D bool @P <in T>(T obj);
Same as other delegate types, Predicate can also be used with any method, anonymous method, or lambda expression.
j7Pr8.web
<WEB>
<PACK> j7Prsample2
{
<CLASS> J7Pr8
{
public void main()
{
@P < string > CheckIfNokia = @D(string modelName) {
if (modelName == "Nokia") return true;
else return false;
};
bool result = CheckIfNokia("Nokia");
if (result) <PRINTLN>("Nokia is a olden cellphone");
}
}
}
Explanation
For this given example..
@P < string > CheckIfNokia = @D(string modelName) {
if (modelName == "Nokia") return true;
else return false;
};
Here @P is the predicate and @D is the delegate. Predicate represents a method containing a set of criteria ( eg) if modelName=Nokia or not) and check whether the passed parameter meets those criteria.
eg) bool result = CheckIfNokia("Nokia");
if (result) <PRINTLN>("Nokia is a olden cellphone"). For this oakjava7 program it displays Nokia is a olden cellphone. Because the given modelName parameter value is equal to "Nokia".
Output
Nokia is a olden cellphone
==================================================================================
Sample 32: Predicate and Delegate examples
==================================================================================
Question: Find the Factorial , Sin,Exp, value of the given expression ie) y,y1
and asinh,acosh ,atanh,String using delegate
and Count no of Books,Count no of Negative numbers,Count no of empty book title
and find factorial (0! to 9!) and 6! (6 factorial) ?
j7Pr111.web
<WEB>
<PACK> j7rsample112
{
public <CLASS> J7r111
{
static int Factorial(int n)
{
return n < 1 ? 1 : n * Factorial(n - 1);
}
static Func<int, int> Factorial()
{
Func<int, int> factorial = null;
factorial = n => n < 1 ? 1 : n * factorial(n - 1);
return factorial;
}
public static int Count<T>(T[] arr, @P <T> condition)
{
int counter = 0;
for (int i = 0; i < arr.Length; i++)
if (condition(arr[i]))
counter++;
return counter;
}
public void main()
{
Func<double, double> f1 = Math.Sin;
Func<double, double> f2 = Math.Exp;
double y = f1(2) + f2(3); //y=sin(2) + exp(3)
f2 = f1;
y = f2(9); //y=sin(9)
<PRINTLN>("fx result1="+y);
Func<double, double> f4 = @D (double x1) { return 8*x1+1; };
double y1 = f4(3);
f4 = x1 => 32*x1+1;
y1 = f4(6);
<PRINTLN>("fx result2 with @D ="+y1);
Func<double, double> asinh1 = @D (double x1) { return Math.Log( x1 + Math.Sqrt(x1*x1+1) );} ;
Func<double, double> acosh1 = x => Math.Log( x + Math.Sqrt(x*x-1) ) ;
Func<double, double> atanh1 = x2 => 0.2*( Math.Log( 1 + x2 ) - Math.Log( 1 -x2 ) ) ;
double y5 = asinh1(3);
double y6 = acosh1(4);
double y7 = atanh1(0.6);
<PRINTLN>("asinh with @D ="+y5);
<PRINTLN>("acosh with @D ="+y6);
<PRINTLN>("atanh with @D ="+y7);
@P <string> longWords = @D (string word) { return word.Length < 10; };
bool y8 = longWords("Madam");
string[] words = {"Madam","jackie",""};
int[] books = {456,789};
int book=0;
<PRINTLN>("String with @D ="+y8);
int Names = Count(words, longWords);
<PRINTLN>("Count names="+Names);
book = Count(books, @D (int ip) { return ip > 20; });
<PRINTLN>("Count no of Books="+book);
int[] numbers = {-1,-45,1,4,100,-200,-20000,567};
int NegativeNumbers = Count(numbers, x => x < 0);
<PRINTLN>("NegativeNumbers count="+NegativeNumbers);
int EmptyBookTitles = Count(words, String.IsNullOrEmpty);
<PRINTLN>("Empty book title count="+EmptyBookTitles);
var fl = Factorial();
for(int i=0; i<10; i++)
<PRINTLN>("{0}! = {1}", i, fl(i));
int[] numbers1 = new[] { 5,1,3,7,2,6,4};
Func<int, int> factorial = @D (int num) {
Func<int, int> locFactorial = null;
locFactorial = n => n == 1 ? 1 : n * locFactorial(n - 1);
return locFactorial(num);
};
int s=factorial(6);
<PRINTLN>("Factorial Result ="+ s);
}
}
}
Explanation
Now here we are adding data 256 and "Bill" to the ArrayList
ArrayList list <NEW> ArrayList();
list.Add(256); // boxing
list.Add("Bill");
and it will print [256,Bill] as output.
==============================================
object o = 1010;
int i = (int)o; //performs unboxing
<PRINTLN>("UnBoxing result ="+i);
we know that the process of converting a Reference Type variable into a Value Type variable. This can be done by casting, eg) (int) of object instance o. ie) int i=(int)o; This gives a Unboxing value which is stored in variable i.
=========================================================================
Func<double, double> f4 = @D (double x1) { return 8*x1+1; };
double y1 = f4(3);
f4 = x1 => 32*x1+1;
y1 = f4(6);
So when you use y1=f4(6), that means
6 is assigned to x1 , ie) 32 *6 +1=> 193
=============================================================
Here in this given statement
@P <string> longWords = @D (string word) { return word.Length < 10; };
bool y8 = longWords("Madam");
The "Madam" string is passed to LongWords method , it
will check when word.Length < 10 or not. If it is
less than 10 then return the boolean value as true.
==========================================================
simillarly when longwords = madam is passed at Count
(words,longwords) when the Word.length < 10 then the
counter value gets incremented ie) in this sample ....
string[] words = {"Madam","jackie",""};
here "madam" string length is 5 , jackie=6 , ""=0
which are less than 10 ; so the counter value becomes 3.
int Names = Count(words, longWords);
so we get the output Count names=3
==========================================================
books = {456,789}
book = Count(books, @D (int ip) { return ip > 20; });
<PRINTLN>("Count no of Books="+book);
here we see in the given above statement that
456 > 20, 789> 20 ; So the counter value =2.
so we get the output Count no of Books=2.
==============================================================
int[] numbers = {-1,-45,1,4,100,-200,-20000,567};
int NegativeNumbers = Count(numbers, x => x < 0);
<PRINTLN>("NegativeNumbers count="+NegativeNumbers);
here in this given above statement integer numbers array
is passed which contain 4 positive numbers.we have passed
predicate condition as x => x < 0 in the count function.
This conditions will check all the numbers in the numbers array.
so there are 4 positive numbers in that numbers array
so the counter is incremented 4 times.so we get the
output NegativeNumbers count=4.
==============================================================
int EmptyBookTitles = Count(words, String.IsNullOrEmpty);
here the words array contain 2 elements and 1 empty string
so when we pass String.IsNullOrEmpty in Count function
this match with the 3rd element that is 1 empty string
present in words array. So the counter is incremented 1
time.so we get the output Empty book title count=1
===============================================================
var fl = Factorial();
for(int i=0; i<10; i++)
<PRINTLN>("{0}! = {1}", i, fl(i));
This i represent ith element ie from ( 0 to 9)
f1(i) =>f1(0),f1(1),f1(2),f1(3),f1(4),f1(5),f1(6),f1(7),f1(8),f1(9)
Here f1 is the factorial function, For loop is repeated 10 times
from (0 to 9).
So we get the output as given below
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
====================================================================
We are finding the factorial of 6 ie) 6!
int s=factorial(6);
<PRINTLN>("Factorial Result ="+ s);
when we pass the value 6 to factorial recursion function.
it will multiply the value = 6 *5 * 4* 3* 2 * 1 = 720.
eg)
static int Factorial(int n)
{
return n < 1 ? 1 : n * Factorial(n - 1);
}
until n < 1 the recursion take place.
So we get the output as given below
Factorial Result =720
====================================================
Output
fx result1=0.412118485241757
fx result2 with delegate =193
asinh with delegate =1.81844645923207
acosh with delegate =2.06343706889556
atanh with delegate =0.277258872223978
String with delegate =True
Count names=3
Count no of Books=2
NegativeNumbers count=4
Empty book title count=1
0! = 1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
Factorial Result =720
==================================================================================
Sample 33 : AutoBoxing and UnBoxing
==================================================================================
Boxing In OAKJAVA7
The process of converting a Value Type variable (char, int etc.) to a Reference Type variable (object) is called Boxing.
Boxing is an implicit conversion process in which object type (super type) is used.
Value Type variables are always stored in Stack memory, while Reference Type variables are stored in Heap memory.
UnBoxing in OAKJAVA7
The process of converting a Reference Type variable into a Value Type variable is known as Unboxing. It is an explicit conversion process.
J7Pr10.web
<WEB>
// Load oakjava7 util packages
<USE> <OJ7UTIL>;
<PACK> j7Prsample10
{
<CLASS> J7Pr10
{
//Boxing in Oakjava7
public void main()
{
ArrayList list <NEW> ArrayList();
list.Add(256); // boxing
list.Add("Bill");
<PRINTLN>("Boxing result ="+list);
object o = 1010;
int i = (int)o; //performs unboxing
<PRINTLN>("UnBoxing result ="+i);
}
}
}
Explanation
Now here we are adding data 256 and "Bill" to the ArrayList
ArrayList list <NEW> ArrayList();
list.Add(256); // boxing
list.Add("Bill");
and it will print [256,Bill] as output.
object o = 1010;
int i = (int)o; //performs unboxing
<PRINTLN>("UnBoxing result ="+i);
we know that the process of converting a Reference Type variable into a Value Type variable. This
can be done by casting, eg) (int) of object instance o.
ie) int i=(int)o; This gives a Unboxing value which is stored in variable i.
Output:
Boxing result =[256, Bill]
UnBoxing result =1010
=========================================================================================
Sample 34:Lambdaj7 in Oakjava7
=========================================================================================
What is Lambdaj7 expression?
Lambda expressions are anonymous functions that contain expressions or sequence of operators.
All lambda expressions use the lambda operator @L, that can be read as “goes to” or “becomes”.
The left side of the lambda operator specifies the input parameters and the right side holds
an expression or a code block that works with the entry parameters.
Here we can see about Lambda Pass by value, Lambda function condition check all the numbers which is Odd or not, Perform ADD operations by passing 10,10 value in add method, Action , Delegate, Predicate, anonymous function to print the given value.
lamdaj7.web
<WEB>
<PACK> Program8
{
<CLASS> Prog
{
static int Sum(int x, int y)
{
return x + y;
}
static bool IsUpperCase(string str)
{
return str.Equals(str.ToUpper());
}
public @D void Print(int value);
public void main()
{
// statement lambda that takes two int inputs and returns the sum
@A<string> greet = name @L
{
string greeting = "Hello";
<PRINTLN>(greeting+name);
};
greet("World");
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
Func <int,bool> oddNumbers = n @L n % 2 == 1;
<PRINTLN>("There are "+oddNumbers(5)+" odd numbers in "+ string.Join(" ", numbers));
//streams
Func<int,int, int> add = Sum;
int result = add(10, 10);
<PRINTLN>(result);
@A<int> printActionDel = @D(int i)
{
<PRINTLN>(i);
};
printActionDel(10);
//predicate
@P <string> isUpper = IsUpperCase;
bool result1 = isUpper("hello world!!");
<PRINTLN>(result1);
//anonymous
Print print = @D(int val) {
<PRINTLN>("Inside Anonymous method. Value: {0}", val);
};
print(100);
}
}
}
Output
HelloWorld
There are True odd numbers in 5 4 1 3 9 8 6 7 2 0
20
10
False
Inside Anonymous method. Value: 100
Explanation
i) Lambda Pass by value and concat the strings greeting and
name.
@A<string> greet = name @L
{
string greeting = "Hello";
<PRINTLN>(greeting+name);
};
greet("World");
Here "@L" says that it is a lambda function.
when greet function is called and string "World" is
passed to the Lambda function. In the Lambda function
when greeting ="Hello" and greeting and name value is
passed to the print statement.Here name variable is
assigned as "World". So we will get output as "HelloWorld".
ii) Lambda function condition check all the numbers which is Odd or not?
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
Func <int,bool> oddNumbers = n @L n % 2 == 1;
<PRINTLN>("There are "+oddNumbers(5)+" odd numbers in "+ string.Join(" ", numbers));
Here "@L" says that it is a lamda function.And we are assigning the
return type in Func function as int,boolean(bool).
ie) Func <int,bool> . Where n @L n % 2 == 1 is the lamda function condition.
It will check whether integers in numbers array is odd number or not.
so When the OddNumbers(5) is invoked and the print statement
will print boolean value as true. So this string.Join(" ",numbers) will
print numbers array complete contents. So we will get output as given below
There are True odd numbers in 5 4 1 3 9 8 6 7 2 0
iii) Perform ADD operations by passing 10,10 value in add method.
Func<int,int, int> add = Sum;
int result = add(10, 10);
<PRINTLN>(result);
static int Sum(int x, int y)
{
return x + y;
}
Here we are using 3 integers datatype in Func<int,int,int> and
we are assuming Sum method to add function; so it will perform
Sum operations using method Sum(int x, int y). When we pass the value
in add function which is given below..
add(10, 10) and we use <PRINTLN> statement to print the result value.
So we will get output as 20.
iv) Use Action Delegate to print the value which you passed
in printActionDel(10) method.
@A<int> printActionDel = @D(int i)
{
<PRINTLN>(i);
};
printActionDel(10);
What is Action Delegate ?
Action type delegate is the same as Func delegate except that
the Action delegate doesn't return a value. In other words, an
Action delegate can be used with a method that has a void return type.
Action Delegate is represented as @A in oakjava7 program.
Using object of Action delegate printActionDel(10) will print the value
as 10 as the output. Because we use <PRINTLN>(i) statement inside
Action Delegate block.
v) Check whether the given string is UpperCase or not. and print that boolean value
@P<string> isUpper = IsUpperCase;
bool result1 = isUpper("hello world!!");
<PRINTLN>(result1);
Predicate is the delegate like Func and Action delegates.
It represents a method containing a set of criteria and checks whether the
passed parameter meets those criteria. A predicate delegate methods must take one
input parameter and return a boolean - true or false.
Predicate Syntax
public @D bool @P<in T>(T obj);
Here at Predicate object isUpper is assigned a IsUpperCase functions.
so when we pass the value "hello world!!" to the Predicate object
isUpper will return the boolean value as false.Because it will check
whether the value "hello world!!" is UpperCase or not. But here it
is Lowercase so it return a value false as the output when we
print the result value.
vi) use anonymous function to print the given value.
//anonymous
Print print = @D(int val) {
<PRINTLN>("Inside Anonymous method. Value: {0}", val);
};
print(100);
Here in this Anonymous function object print(100)
means value 100 is passed to print Anonymous method.
val is assigned 100 as a value.
So <PRINTLN> will print the output which is given
below ...
Inside Anonymous method. Value: 100
=========================================================================
Sample 35: Define and Explain forward , include , visitor count,ip address and hostname internationalization with an example
=========================================================================================
1) Forward Action
==================
Syntax
======
public static forward list=new forward("{key}",arraylistobject);
It is used to forward a request or a list or set of data to another page.
Here {key} indicates the key , arraylistObject indicates arraylist object.
2) Include Action
==================
Syntax-1
=========
Java7request.include("<htmlfilename>",choice,"html");
It is used to insert a file into the same page.
Here <filename> given is html file name.
eg) Java7request.include("test.html",0,"html");
And "html" indicates it is html type file.
So choice =0 indicates that the filename belong to html file or
any other type filename.
Syntax-2
=========
Java7request.include("<otherfilename>",choice,"exe");
Here when we don't give htmlfilename and give as other filename and choice =1
and "exe" indicates that it is a executable file name. Then it will include
executable filename and it is called as assembly file.
eg) Java7request.include("autocomplete",1,"exe");
Syntax-3
========
Java7request.include("<otherfilename>",choice,"ojava7");
Here when we don't give htmlfilename and give as other filename and choice =2
and "ojava7" indicates that it is a oakjava7 file name and it is also an executable filename.
Then it will include oakjava7 executable filename and it is called as Oakjava7 assembly file.
eg) Java7request.include("jarray",2,"ojava7");
3) Visitor Count
================
Syntax:
=======
Java7request.Visitorscount("visitorname");
Visitor count will be incremented every time a person visit the page
and it's return value is always an integer.
eg) int count =Java7request.Visitorscount("visitor1");
Here visitor1 is the Visitorscount name.
4) Visitor clear count
=======================
Syntax
=======
Java7request.Clearcount("visitorname");
Visitor count will be cleared when the person visit the page 5 times
ie) if count > 5 then count =0;
and it's return value is always an void.
eg)
if (count >5)
Java7request.Clearcount("visitor1");
5) Date in Oakjava7
===================
Date d=new Date();
=> It is used to create date object d.
<PRINTLN>("Second of the minute is : "+d.getSeconds());
=> It is used to get seconds from our current date hour.
6) OakJava7 - internationalization i18n
=======================================
Locale[] locales = { new Locale("en", "US"),
new Locale("es", "ES"), new Locale("it", "IT") };
=> Locale[] contains array of US english, es Spanish, it Itally locale objects.
for (int i=0; i<3; i++)
{
String displayLanguage = locales[i].getDisplayLanguage(locales[i]);
<PRINTLN>(" "+locales[i].ToString() + " = " + displayLanguage);
<PRINTLN>("<BR>");
}
=> Here locales[i].getDisplayLanguage(locales[i]);
is to display languages as English, español, italiano
=> Here locales[i].ToString() will display as en_US, es_ES, it_IT repectively
for display languages as English, español, italiano
7) IP Address and Hostname
===========================
Syntax
======
Java7request.FindIPandHostname();
It is used to display IP address and Hostname for your machine
8) AutoRefresh Page
===================
Syntax
======
Java7request.AutoRefresh(n);
It will automatically refresh the page every n seconds
eg) Java7request.AutoRefresh(3000);
In this given example it will refresh the page
every 3 seconds.
Sample35.web
<WEB>
<USE> ScrollLib;//load ScrollLib packages
<USE> <OJ7UTIL>; //load oakjava7 util packages
<PACK> example1
{
public <CLASS> Java7eg1
{
public static forward list= null;
public static void Java7eg1t2()
{
ArrayList ar = new ArrayList();
ArrayList ar1 = new ArrayList();
for(int i=0;i<100;i++)
ar.add(i);
for(int i=100;i<200;i++)
ar1.add(i);
list=new forward("language0",ar);
list.setValue("language1",ar1);
}
public void main()
{
<TRY>
{
Java7request.include("test.html",0,"html");
// Java7request.include("autocomplete",1,"exe");
// Java7request.include("jarray",2,"ojava7");
// Java7request.AutoRefresh(3000);
int count=Java7request.Visitorscount("visitor1");
Java7request.FindIPandHostname();
<PRINTLN>("visitor count="+count);
<PRINTLN>("<BR>");
if (count >5)
Java7request.Clearcount("visitor1");
Date d=new Date();
<PRINTLN>("Second of the minute is : "+d.getSeconds());
<PRINTLN>("<BR>");
Locale[] locales = { new Locale("en", "US"),
new Locale("es", "ES"), new Locale("it", "IT") };
for (int i=0; i<3; i++)
{
String displayLanguage = locales[i].getDisplayLanguage(locales[i]);
<PRINTLN>(" "+locales[i].ToString() + " = " + displayLanguage);
<PRINTLN>("<BR>");
}
<PRINTLN>("<BR>");
<PRINTLN>("<BR>");
HTML.displayhtml("Register100.html");
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
}
}
}
}
Note: It will display test.html form and the given below output and
after that it will display Register100.html form.
Output
Your current IP address : DESKTOP-H7QSQP2/192.162.67.5
Your current Hostname : DESKTOP-H7QSQP2
visitor count=6
<BR>
Second of the minute is : 47
<BR>
en_US = English
<BR>
es_ES = español
<BR>
it_IT = italiano
<BR>
=========================================================================================
Sample 36: Define and Explain first Page for forward action and Next page for forward action output.
=======================================================================================
Sample35.web contains static method Java7eg1t2().
Sample35.web
public static void Java7eg1t2()
{
ArrayList ar = new ArrayList();
ArrayList ar1 = new ArrayList();
for(int i=0;i<100;i++)
ar.add(i);
for(int i=100;i<200;i++)
ar1.add(i);
list=new forward("language0",ar);
//This statement will set arraylist value to ar1
list.setValue("language1",ar1);
}
Explanation
Arraylist ar contains 100 elements from 0 to 99
and Arraylist ar1 contains 100 elements from 100 to 199.
and Forward Action assumes two Arraylist objects ar and ar1.
Now see the second page program...
Sample36.web
<WEB>
<USE> ScrollLib;// load the ScrollLib util package
<USE> <OJ7UTIL>;//load util packages
<USE> example1; // load the firstpage package example1
<PACK> example2
{
<CLASS> Java7eg2
{
public void main()
{
<TRY>
{
//Call the public static method Java7eg1t()
Java7eg1.Java7eg1t();
//ar1
ArrayList ars = Java7eg1.list.getForwardValue("language1");
<PRINTLN>(ars.get(90));
//ar
ArrayList ars1 = Java7eg1.list.getForwardValue("language0");
<PRINTLN>(" ");
<PRINTLN>(ars1.get(80));
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
}
}
}
}
Explanation
After calling the public static method Java7eg1t() method which is
Java7eg1.Java7eg1t(),Java7eg1 represent the name of class and Java7eg1t() is the method name for Java7eg1.
which is called in Sample36.web and it will intialize the array list ars and ars2 values
of forward action values which are language1,language0 respectively which can be done which are given below....
ArrayList ars = Java7eg1.list.getForwardValue("language1");
// Note this Java7eg1.list.getForwardValue("language1") will return the Arraylist object Forward action "language1" value and which is assign to arraylist ars
<PRINTLN>(ars.get(90));
ArrayList ars1 = Java7eg1.list.getForwardValue("language0");
// Note this Java7eg1.list.getForwardValue("language0") will return the Arraylist object Forward action "language0" value
and which is assign to arraylist ars1
<PRINTLN>(" ");
<PRINTLN>(ars1.get(80));
So ars.get(90) arraylist contains 190 as value because we assigned the values of For loop from
100 to 199 and we add this to ar1 arraylist in sample35 program which is given below ...
for(int i=100;i<200;i++)
ar1.add(i);
and ars1.get(80) will contain 80 value because we assigned the values of For loop from
1 to 99.
We know finally block will execute whether error happens or not.
So it display the value with String "190 80The Finally block is executed..."
as output. So the output will be given below..
Output:
190 80The Finally block is executed...
==================================================================================
Sample 37: Define and Explain OakJava7 Context,OakJava7 Session, OakJava7 Config
==================================================================================
OakJava7 Context
OakJava7 Context will have constant Oakjava7 context values and it reduces the need of
xml file. So it will carry to be used with in the OakJava7 Web Application and
at the next OakJava7 Web application. Syntax is given below..
public static Java7Context <contextobject> = new Java7Context("Key=Value");
Java7 Context should be used outside any methods or main method. When you store
the values using this given above syntax. and when you use this given below syntax.
<Classname first program>.<contextobject>.get(Index).ToString();
we can retreive the value and we can print it by using the syntax which is given above...
example)
public static Java7Context list = new Java7Context("Secretno=1089678");
Program.list.get(0).ToString();
[where Program indicates Sessiontracking classname and list is the context object,
and we can get the first value by using get(0).ToString().]
OakJava7 Session
OakJava7 Session is created using the given below syntax...
public static Java7Session <sessionobject> = new Java7Session("<key>","<value>");
This is used to create OakJava7 Session, with key and value.
OakJava7 Session is used to carry data or array list of data to the page(filename.exe) that you have mentioned in html file.
OakJava7 Session can retrieve the value by using the given below Syntax.
<classname>.<sessionobject>.getSessionValue("<key>");
example)
public static Java7Session list1 = new Java7Session("No of employees","1000 employees");
public static void p()
{
list1.setValue("seqno1","2000 values");
list1.setValue("seqno2","2001 values");
list1.setValue("seqno3","2005 values");
}
so using <sessionobject>.setValue(....) function we can store many keys and value needed for the next page.
OakJava7 Config
OakJava7 Config is used to retrieve the configuration information. Example
using Java7Config.getParameter("Driver").
Syntax
Java7Config.getParameter("<configuration key name>");
J7Config.config file is a global Oakjava7Config file which is used to store all the configuration
information and such configuration will be used by the Oakjava7 programs.
eg) This <- arrow indicates that sun.jdbc.Driver is assigned to a key Driver.
This given below example indicates how to store the information with key and value parameters.
J7Config.config
Driver <- sun.jdbc.Driver
First Program
Sample37.web
<WEB>
<USE> ScrollLib;
<PACK> example11
{
public <CLASS> Program
{
public static Java7Session list1 = new Java7Session("No of employees","1000 employees");
public static Java7Context list = new Java7Context("Secretno=1089678");
public static void p()
{
list1.setValue("seqno1","2000 values");
list1.setValue("seqno2","2001 values");
list1.setValue("seqno3","2005 values");
}
}
}
Note: This program will generate a .dll file when you compile using javac7 <filename.web>.Put that filename.web.dll in oakjava7 properties file and after that copy that generated .dll file from outputs directory to d:\ or c:\oakjava7\src directory.
Second Program
Sample371.web
<WEB>
<USE> ScrollLib;
<USE> example11;
<PACK> Sessiontracks1
{
<CLASS> Program1
{
public void main()
{
<TRY>
{
<PRINTLN>(" <BR> ");
//intialize and add the session data or session Arraylist data.
Program.p();
<PRINTLN>(" <BR> ");
<PRINTLN>("Session value of seqno1 ="+Program.list1.getSessionValue("seqno1"));
<PRINTLN>(" <BR> ");
<PRINTLN>("OakJava7Context ="+Program.list.get(0).ToString());
<PRINTLN>(" <BR> ");
<PRINTLN>("Java7config="+Java7Config.getParameter("Driver"));
<PRINTLN>(" <BR> ");
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
}
}
}
}
Final Output:-
Session value of seqno1 =2000 values
OakJava7Context =Secretno=1089678
Java7config=sun.jdbc.Driver
The Finally block is executed...
==================================================================================================================================================================================================
OAKJava7(JAVA7.0) Advanced Concepts : OakJava7 Streams
=======================================================================================
==================================================================================
Sample 38: OakJava7 Streams Introduction
==================================================================================
OakJava7 Streams
OakJava7 stream is invented by J. Wilmix jemin at year 2023. This project
takes the time for me around 1 month to build the OakJava7 Streams.
Streams are more important for the development to do
any program. OakJava7 stream is learnable.
In Java (Jdk1.8) streams are not learnable.So
Oakjava7 stream is nothing but it is same as
Jdk1.8 stream.So if you know Jdk1.8 then
you can easily learn OakJava7 Stream.
OakJava7 Streams represent a pipeline through which data will flow and the functions to
operate on the data. A pipeline in this instance consists of a stream source, followed by
zero or more intermediate operations, and a terminal operation.
OakJava7 Streams are used to optimize the oakjava7 source code.
But there are 8 blocks of streams which are given below....
Stream() block ,Read Ln block ,Display block,Streamagg() block,Streamfx() block,
Stream.Generate block,LOGIC block, and ParallelStream() block.
When these types of Block are used ? Explain it briefly ?
Mostly it is not to memorize all the blocks ,but you
have to say only the types of block during the oakjava7 interview.
Even if you don't use Read Ln block ,Display block,
Stream.Generate block,LOGIC block the oakjava7 compiler
will not throw error.
Stream() block
Stream block are the streams which contains
stream objects that can call any functions.
that is represented as
Stream()->
................
})->
where ...... represents Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block.
Stream()-> block is represented with Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block, Streams() are like pipeline.
Other Streams Block
Like Stream() block other Stream block like
Streamagg() block,Streamfx() block, and ParallelStream() block
functions the same things but the syntax may differ.
Streamfx() Block
Streamfx()->
......
Functions....
})->
where ...... represents Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block.
Where Functions represents Oakjava7 functions...
So only Oakjava7 functions should be mentioned in this
block.
Streamagg() block
========================
Streamagg()->
......
Agg f(x) in oj7stream
....
})->
where ...... represents Read Ln block ,Display block,
Stream.Generate block,and ,LOGIC block.
Where Functions represents Oakjava7 Aggregate functions...
So only Oakjava7 aggregate functions should be mentioned in this
block.
ParallelStream() block
In ParallelStream() Block stream
will display the data in a non sequence random order.
But Streams() block data will display the
datas in a sequence order. This is the
major difference between Stream() block
and Parallel stream block.. Parallel stream block
syntax is given below...
ParallelStream()
Read Ln block , LOGIC block, and Display block
The Read Ln block syntax is given below...
READLN(I->{
.........
Input statements...
})->
where ...... represents Read Ln block statements should be mentioned .So only
Input data should be mentioned according to the
rules of OakJava7 Stream. So it is good for
the client to read your program and analyze the Input
functionality which is mentioned in the
ReadLn block.
The Display block syntax is given below...
DISPLAY(O->{
.........
Output statements...
})->
where ...... represents Display block,
and ,LOGIC block.So only
Display statements(eg is Print statements and it's related statements) should be mentioned according to the rules of OakJava7 Stream. So it is good for
the client to read your program and analyze the output
functionality which is mentioned in the
DISPLAY block.
The Logic Block syntax is given below...
LOGIC(L->{
......... Logical statements...
})->
where ...... represents LOGICAL block statements should be represented in this Logic Block.Ie) only
Display statements(eg is Print statements and it's related statements) should be mentioned according to the rules of OakJava7 Stream. So it is good for the client to read your program and analyze the
functionality which is mentioned in the Logic block.
Stream.Generate block
When the business requirement became very complex or
hard or medium we must focus on Stream.Generate block.
It is same as Stream.Generate block followed by
limit() and skip functions or foreach functions.
So the Syntax for Stream.Generate block is given below...
Stream.Generate(()->{
......... Stream.Generate releated Logical statements.. or double for..loop or
double while -- loop or complex ,hard or medium statements..
})->
Where Stream.Generate releated Logical statements . or double for..loop or
double while -- loop or complex ,hard or medium statements..
example for Stream.Generate() is given below...
Medium problem : Ascending or descending order...
Stream.Generate(()->{
for (int i=0;i<n ;i++)
{
for (int j=0;j<n ;j++)
{
if (a[i] > a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
})->
Note: We can see more detail about this 8 blocks like
Stream() block ,Read Ln block ,Display block,Streamagg() block,Streamfx() block,
Stream.Generate block,LOGIC block, and ParallelStream() block.
=============================================================================================
==============================================================================================
Sample 39: OakJava7 Streams :Sample -1 : Use of J7Filter and list array containing numbers.
==========================================================================================
Write a OakJava7 stream program using J7Filter (OakJava7 Filter) and Print the List array containing numbers present in the List.
oj7stream.web
<WEB> // Start point of oakjava7 program,it is mandatory.
// All the Oakjava7(JAVA7.0) namespace <PACK> should be used,
// so without namespace <PACK> will result in error and your oakjava7 program
// will not work correctly.
<PACK> sample1
{
public <CLASS> Programn
{
public void main()
{
// starting point of oakjava7 stream
Stream()->
// Input data stream -> READLN
READLN(I->{
int a=5;
int b=3;
int salary = 200000;
float f=123;
// letters arranged and oakjava7 array dimension should be focus on left side.
char []letters= { 'W', 'e', 'b'};
String a1="Madam";
String a2=a1+"1";
// pass the letter character array to string
string s1 <NEW> string(letters);
string s2 <NEW> string(letters);
})->
// Printing all the oakJava7 filter values using J7Print ie) Oakjava7Print statement.
DISPLAY(O->{
// J7Filter (Oakjava7 filter) returns boolean value only; and that J7filter value is passed to oakjava7 Print statement.
//check the condition if the salary is greater than 10000 value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( salary > 10000));
//check the condition if the salary is greater than 10000 value ,if f value is greater than 121.0 or not or a1 value is "Madam" or not.
// If both conditions return true then the result will be the true value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( (salary > 10000)&& (f>121.0)&&(a1=="Madam" ) ));
//check if a value is equal to 5 or not. if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( a ==5));
//check if a a value is greater than b or not. if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( a >b));
//check if a a value is less than b or not. if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( a < b));
//check if a a value is greater than b or not. and b value is equal to zero or not.
//If both conditions return true then the result will be the true value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( (a >b) && (b==0)));
//check if a a value is greater than b or not. and b value is equal to zero or not.
//If any of the conditions return true then the result will be the true value
// if not return false other wise J7Filter return true.
obj->J7Print(obj->J7Filter( (a >b)|| (b==0)));
//if (a!=0) then J7Filter return true. otherwise return false...
obj->J7Print(obj->J7Filter(a!=0));
//if (a==a2) then J7Filter return true. otherwise return false...
obj->J7Print(obj->J7Filter(a1==a2));
//if (s1 equals s2) then J7Filter return true. otherwise return false...
// ie) Equals is used for string object comparison
obj->J7Print(obj->J7Filter(s1.Equals(s2) ));
// Assign numbers like (11,17,19,30,48,53,19) to the List
//<OJ7UTIL>.List lop= <OJ7UTIL>.Arrays.asList(11,17,19,30,48,53,19);
string data="11,17,19,30,48,53,19";
<OJ7UTIL>.List lop= <AUTOBOX_ARRAY>(data);
// Print the lop array List using J7Print by passing lop to J7Print function.
obj->J7Print(lop);
})->
<PRINTLN>("--------------------");
}
}
}
Explanation
I have already explained by giving comments above the Oakjava7 statements. J7Filter is for checking the condition. If the condition matches it will return a boolean value true or it will return false.
Note:
In the OakJava7 properties file you must use OJ7Stream.dll file. Go to
c:\ wilmix or create a directory in C or d drive or which directory you have created , start Visual studio code editor and type the command which is given below...
Use PS C:\wilmix> ./oj7stream
to run the program in visual studio code Editor.
For the compilation of oakjava7 program you have to use the given below command as shown below...
javac7 oj7stream.web
it will generate oj7stream.exe and oj7stream.ojava7 executable file. In order to run oj7stream.ojava7 file , you must go for OakJava7 Shell (Java7 Shell). As i already explained in the oakjava7 tutorial.
Input
Output
==============================================================================================
Sample 40: OakJava7 Streams: Sample 2: Method Reference using map
==============================================================================================
Write a oakjava7 program for Method Reference using map using oakjava7 stream ?
=========================================================================================
oj7stream1.web
<WEB>
<PACK> sample2
{
public <CLASS> Programn
{
// Write a method display returning string value pass
public String display()
{
<PRINTLN>("printing display method");
return("pass");
}
public void main()
{
Stream()->
READLN(I->{
// create instance for Programn class
Programn sorted <NEW> Programn();
})->
DISPLAY(O->{
// Obj is nothing but oakjava7 Stream object.
// so pass the class object to the Oakjava7 Map
// ie) J7Map function as a first parameter
// and use "::" method reference operator.
// Also pass the name of the method display method which contain
// pass as the string value, so what happens it return
// the value and stored in Object s11.
// so here in this case no need to call the method by creating the instance
// of the method...
// you can call the display method dynamically as we see the same
// concept in Jdk1.8.
Object s11= obj->J7Map(sorted :: "display");
// Pass the s11 value to J7Print statement it will
//print the value at the Console.
obj->J7Print(s11);
})->
<PRINTLN>("--------------------");
}
}
}
Output:
C:\java7prog>oj7stream1
printing display method
pass
=========================================================
Sample 41: OakJava7 Streams: Sample 2: Filter the integers starts with 1 and Merge the given data with list of boolean values
=========================================================
Write the oakjava7 program to list all the nos starts with "1" and return true for those given values starts with 1 from given list (11,17,19,30,48,53,19) and finally merge the given data with list of boolean values?
oj7stream2.web
===============
<WEB>
<PACK> sample1
{
public <CLASS> Programn
{
public void main()
{
Stream()->
READLN(I->{
<OJ7UTIL>.List lop3= new <OJ7UTIL>.ArrayList();
string data67="11,17,19,30,48,53,19";
<OJ7UTIL>.ArrayList lop=<AUTOBOX_ARRAY>(data67);
<OJ7UTIL>.List lop2= new <OJ7UTIL>.ArrayList();
int j=0;
int[] vals = {11,17,19,30,48,53,19};
// This Foreach loop will get the values
//from int array and when val variable refer
// to vals array. Values will be transfered
// to val variable.
foreach (var val in vals)
{
<PRINTLN>(val);
}
foreach (int data in vals)
{
// This given data is checked whether the values start by one
// or not using StartsWith method, so the numbers start by
// "1" is filtered using J7Filter...
Object sp=obj->J7Filter((""+data).StartsWith("1"));
//pass obj to J7Assign to assign the filtered data ie the no starts with 1
// and boolean values will be stored in lop5 list.
<OJ7UTIL>.List lop5 = obj->J7Assign(sp);
// Boolean values like True or False will be present
// in List lop5. we should remove all the invalid data
// Which is [ or ] .
// After that at lop5 list is convert to replace invalid datas "[", "]"
// by space.
if (lop5.get(j).ToString().Replace("[","").Replace("]","")=="True")
// after that data which start with "1" is passed to the Oakjava7 filter (J7Filter)
// and such data is passed to lop3 is stored in lop3 using add method.
lop3.add(obj->J7Filter((""+data)));
j++;
}
})->
DISPLAY(O->{
// Print the array list lop3 values
//using J7Print (oakJava7 print statement).
obj->J7Print(lop3);
<PRINTLN>("--------------------");
// J7Assign statement will store the value in
// lop511 list.
<OJ7UTIL>.List lop511 = obj->J7Assign(lop);
// Print the array list lop511 values
//using J7Print (oakJava7 print statement).
obj->J7Print(lop511);
})->
}
}
}
Output:
C:\java7prog>oj7stream2
11
17
19
30
48
53
19
[11, 17, 19, 19]
--------------------
[True, True, True, False, False, False, True, [11, 17, 19, 30, 48, 53, 19]]
=============================================================================================
Sample 42: OakJava7 Streams: Sample 3 : Using AnyMatchfx functions.
==============================================================================================
Q) Use AnyMatchfx functions, it returns a boolean value true when 5 is present in the list n1.
Oj7Stream4.web
<WEB>
<PACK> sample4
{
public <CLASS> Programn
{
public void main()
{
<PRINTLN>(" Any match using list are ...");
Stream()->
//READLN is optional
READLN(I->{
// List contains 3, 4, 6, 12, 20 elements..
string data="3, 4, 6, 12, 20";
<OJ7UTIL>.ArrayList list5=<AUTOBOX_ARRAY>(data);
int n=0;
bool exp=false;
int exp11=0;
bool result=false;
//pass obj list5 to J7Assignfx function to assign the list5 data
<OJ7UTIL>.List list6= obj->J7Assignfx(list5);
<OJ7UTIL>.List n1=new <OJ7UTIL>.ArrayList();
for (int i=0;i<list6.size();i++)
{
// Convert the List6 string to int format.
n= int.Parse((list6.get(i).ToString()));
// provide expression for that.
exp11=(n * (n + 1))/4;
// Again add it to n1 list size.
n1.add(exp11);
}
})->
DISPLAY(O->{
// In case of AnyMatchfx functions, it returns a boolean value true when 5 is present in the list n1
bool sop=obj->AnyMatchfx(n1,5);
obj->J7Print(sop);
})->
}
}
}
Output
Any match using list are ...
True
==================================================================================
Sample 43: OakJava7 Streams: Sample 4 : Using AllMatchfx functions.
===================================================================================
Q) Use AllMatchfx functions, it returns a boolean value true when 5 is present in the list n2.
Oj7Stream5.web
<WEB>
<PACK> sample4
{
public <CLASS> Programn
{
public void main()
{
<PRINTLN>(" All match using list are ...");
Stream()->
READLN(I->{
string data="4, 4, 4, 4, 4";
<OJ7UTIL>.ArrayList list51=<AUTOBOX_ARRAY>(data);
<PRINTLN>("The given data ..."+list51);
//<OJ7UTIL>.List list51 = <OJ7UTIL>.Arrays.asList(4, 4, 4, 4, 4);
<OJ7UTIL>.List list61= obj->J7Assignfx(list51);
int n12=0;int exp112=0;
bool exp1=false;
<OJ7UTIL>.List n2=new <OJ7UTIL>.ArrayList();
for (int i=0;i<list61.size();i++)
{
n12= int.Parse(list61.get(i).ToString());
exp112=(n12 * (n12 + 1))/4;
n2.add(exp112);
}
})->
//About Display you can see at Chapter 1
DISPLAY(O->{
// AllMatchfx functions, it returns a boolean value true when all data is 5 and it is present in the list n2
bool sop1=obj->AllMatchfx(n2,5);
<PRINTLN>(" All match using list are ...");
obj->J7Print(sop1);
})->
}
}
}
Output
C:\java7prog>oj7stream5
All match using list are ...
All match ...[5, 5, 5, 5, 5]
All match using list are ...
True
==================================================================================
Sample 44: OakJava7 Streams: Sample 5 : Using NoneMatchfx functions.
===================================================================================
Q) Use NoneMatchfx functions, it returns a boolean value true when 5 is not present in the list n3.
Oj7Stream6.web
<WEB>
<PACK> sample4
{
public <CLASS> Programn
{
public void main()
{
<PRINTLN>("None match using list are ...");
Stream()->
READLN(I->{
string data="41, 41, 41, 41, 41";
<OJ7UTIL>.ArrayList list52=<AUTOBOX_ARRAY>(data);
//<OJ7UTIL>.List list52 = <OJ7UTIL>.Arrays.asList(41, 41, 41, 41, 41);;
//None match
<OJ7UTIL>.List list62= obj->J7Assignfx(list52);
int n122=0;int n22=0;
bool exp12=false;
int exp1122=0;
<OJ7UTIL>.List n3 <NEW> <OJ7UTIL>.ArrayList();
for (int i=0;i<list62.size();i++)
{
n122= int.Parse(list62.get(i).ToString());
exp1122=(n122 * (n122 + 1))/4;
n3.add(exp1122);
}
})->
DISPLAY(O->{
//Use NoneMatchfx functions, it returns a boolean value true when 5 is not present in the list n3.
bool sop2=obj->NoneMatchfx(n3,5);
obj->J7Print(sop2);
})->
}
}
}
Output:
C:\java7prog>oj7stream6.exe
None match using list are ...
True
============================================================================================
Sample 45: OakJava7 Streams: Sample 6 : Using Aggregate functions like Minimum,Maximum,Nth minimum,Nth maximum, and use Oakjava7 Streams for forLoop.
===================================================================================
Q: Using Aggregate functions like Minimum, Maximum,Nth minimum,Nth maximum, and use Oakjava7 Streams for forLoop.
Sample6.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn7
{
public void main()
{
// This stream is used for Aggregate functions.
Streamagg()->
<PRINTLN>("Agg f(x) in oj7stream are ...");
// max ,minimum,Average
Stream.Generate(()->{
int[] arr = {25, 11, 7, 75, 56 };
// Pass the array (arr) values in the oakjava7 streams forLoop
//and it will print the contents of integer array.
AGG->forLoop(arr);
// maximum element in the given arrayList
// j7Lib indicated Oakjava7 library
// This -> indicates oakjava7 functional pointer to array arr
int maimum= j7Lib->maximum(arr);
<PRINTLN>("Maximum element in the given array is:");
AGG->J7Print(maimum);
// minimum element in the given arrayList
int miimum= j7Lib->minimum(arr);
<PRINTLN>("Minimum element in the given array is:");
AGG->J7Print(miimum);
// 2nd Maximum element in the given array is:
<PRINTLN>("2nd Maximum element in the given array is:");
// To find the Second highest in a given array, you much
//choose the index as 1. Because the Array index is 1
// NMax means Nth element in the given array.
int Nmaz= j7Lib->NMax(arr,1);
AGG->J7Print(Nmaz);
// For finding third minimum element you must choose arry index as 2.
<PRINTLN>("3rd Minimum element in the given array is:");
int Nmiz= j7Lib->NMin(arr,2);
AGG->J7Print(Nmiz);
<PRINTLN>("Average for the given elements in the given array is:");
double[] arr22= {25.0,25.0,25.0,25.0,31.0};
// Find the average for the given double array.
double di=AGG->avg(arr22);
// Print the double value in this format.
AGG->J7Printf( di,"AGG =.00");
<PRINTLN>(" ");
})->
}
}
}
Output
C:\java7prog>oj7stream7
Agg f(x) in oj7stream are ...
25
11
7
75
56
Maximum element in the given array is:
75
Minimum element in the given array is:
7
2nd Maximum element in the given array is:
56
3rd Minimum element in the given array is:
25
Average for the given elements in the given array is:
AGG =26.20
==================================================================================
Sample 46: OakJava7 Streams: Sample 7 : Using Streamfx() Reduce functions like Reducefx,Reducefxsum,Reducefxproduct,ReduceIntfxmaxmin
===================================================================================
Q) Write Oakjava7 program for Streamfx() functions like
Reducefx,Reducefxsum,Reducefxproduct,ReduceIntfxmaxmin.
oj7stream8.web
public <CLASS> Programn8
{
public void main()
{
Streamfx()->
<PRINTLN>("----------------------------------------------");
<PRINTLN>("Use Of Reduce Functions:");
Stream.Generate(()->{
//<OJ7UTIL>.List words = <OJ7UTIL>.Arrays.asList("GFG", "Geeks", "for", "GeeksQuiz", "GeeksforGeeks");
string data="'GFG', 'Geeks', 'for', 'GeeksQuiz', 'GeeksforGeeks'";
<OJ7UTIL>.ArrayList words=<AUTOBOX_ARRAY>(data);
// Use of Reducefx function is to reduce
// contents of the stream to a single value
// Here fx represent object of Streamfunctions
String sop5=fx->Reducefx(words);
fx->J7Print(sop5);
String[] array = { "Geeks", "for", "Geeks" };
//When you pass string array values and "-"
// So instead of space "-" value is used so "-" Value also get
//Appended , so the output is "Geeks-for-Geeks"
String rop=fx->Reducefx(array,"-");
fx->J7Print(rop);
// <OJ7UTIL>..List array1 = <OJ7UTIL>.Arrays.asList(-2, 0, 4, 6, 8);
string arraynos="-2, 0, 4, 6, 8";
<OJ7UTIL>.ArrayList array1=<AUTOBOX_ARRAY>(arraynos);
// This given below reduce function finds sum of the numbers which is present in Arrays.asList
int rop1= fx->Reducefxsum(array1);
fx->J7Print("Reducesum="+rop1);
// Reducefxproduct is to multiply the given range nos between 2 and 8
// Which is passed as the argument to Reducefxproduct function
//eg) for(int i=2;i<8;i++) loop has taken given range nos 2 and 8
// so the product output is 2*3*4*5*6*7*8 = 5040
int p=fx->Reducefxproduct(2,8);
fx->J7Print(" ForLoopRange ReduceProduct="+p);
//<OJ7UTIL>.List lsop = <OJ7UTIL>.Arrays.asList(2,2,3,4,8,100,-2,300);
string arraynos1="2,2,3,4,8,100,-2,300";
<OJ7UTIL>.List lsop = <AUTOBOX_ARRAY>(arraynos1);
// This ReduceIntfxmaxmin(lsop,1) , so in this case
// 1 value return a maximum value
// 0 value return a minimum value
int aop= fx->ReduceIntfxmaxmin(lsop,1);
fx->J7Print(aop);
String[] letters1 = {"u","d","e","m","y",".","c","o","m"};
// At here we pass the string array(letters1) value
//with empty string as another parameter , so the
//output value is udemy.com
String sop51=fx->Reducefx(letters1,"");
fx->J7Print(sop51);
})->
}
}
}
Output
Use Of Reduce Functions:
GeeksforGeeks
Geeks-for-Geeks
Reducesum=16
ForLoopRange ReduceProduct=5040
300
udemy.com
==================================================================================
Sample 47: OakJava7 Streams: Sample 7 : Using Streamfx() functions like
ConvertfxArrayList, Joining functions.
===================================================================================
Q) Write a Oakjava7 program to Convert string array to List format,
, use Joining functions.
oj7stream9.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn9
{
public void main()
{
Streamfx()->
<PRINTLN>("----------------------------------------------");
READLN(I->{
//String array to List conversion
String [] arr5 = { "SanJose", "Dallas", "Chicago","SanAntonio", "LosAngeles", "Portland", "Tucson" };
})->
DISPLAY(O->{
// j7Lib is the object of Streamfx function and
// we pass the values of String array arr5 to
//ConvertfxArrayList function is used to
// convert the array to List.
<OJ7UTIL>.List lopc= j7Lib->ConvertfxArrayList(arr5);
fx->J7Print(lopc);
//Joining function is used to append the value "->" with the
// String present in the arr5 array. so the
//output will be SanJose->Dallas->Chicago->SanAntonio->LosAngeles->Portland->Tucson
<PRINTLN>();
String join=fx->Joining(arr5,"->");
fx->J7Print(join);
})->
}
}
}
Output
C:\java7prog>oj7stream9
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson]
SanJose->Dallas->Chicago->SanAntonio->LosAngeles->Portland->Tucson
========================================================================================
Sample 48: OakJava7 Streams: Sample 8 : Using Stream.generate functions like
maptoobj,mapstring,maptolong,maptodouble to assign a value.
========================================================================================
Write a oakjava7 program using Stream.generate functions like
maptoobj,mapstring,maptolong,maptodouble to assign a value:-
oj7stream10.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn10
{
public void main()
{
Stream()->
<PRINTLN>("----------------------------------------------");
Stream.Generate(()->{
// Assign value maptoobj,mapstring,maptolong,mapto double
// Assign value to object using J7Map and print it using J7Print
Object asgn= obj->J7Map("abc");
obj->J7Print(asgn);
<PRINTLN>();
<PRINTLN>("Integer For Loop");
// Assign Integer value to object using J7Map and print it using J7Print
Object[] arg12={1,5,3,89,45};
Object[] asgn1= obj->J7Map(arg12);
// This forfxloop methods will convert the object array to the List format.
<OJ7UTIL>.List ans= obj->forfxLoop(asgn1);
obj->J7Print(ans);
<PRINTLN>();
// Assign Double value to object using J7Map and print it using J7Print
Object[] arg13={1.2,5.5,3.7,89.9,45.6};
Object[] asgn2=obj->J7Map(arg13);
// This forfxloop methods will convert the object array to the List format.
<OJ7UTIL>.List ans1= obj->forfxLoop(asgn2);
obj->J7Print(ans1);
<PRINTLN>();
// Assign long value to object using J7Map and print it using J7Print
Object[] arg14={199999999.2,999999995.5,999999993.7,9999999989.9,9999999945.6};
Object[] asgn3 = obj->J7Map(arg14);
// This forfxloop methods will convert the object array to the List format.
<OJ7UTIL>.List ans3 = obj->forfxLoop(asgn3);
obj->J7Print(ans3);
<PRINTLN>();
// Assign String value to object using J7Map and print it using J7Print
Object[] arg15={"SanJose", "Dallas", "Chicago","SanAntonio", "LosAngeles", "Portland", "Tucson"};
Object[] asgn4= obj->J7Map(arg15);
// This forfxloop methods will convert the object array to the List format.
<OJ7UTIL>.List ans4= obj->forfxLoop(asgn4);
obj->J7Print(ans4);
<PRINTLN>();
})->
}
}
}
Note: We notice that we can pass any data type to
the J7Map function , so OakJava7 using Stream.generate functions
are loosely coupled.
Output
C:\java7prog>oj7stream10
----------------------------------------------
abc
Integer For Loop
[1, 5, 3, 89, 45]
[1.2, 5.5, 3.7, 89.9, 45.6]
[199999999.2, 999999995.5, 999999993.7, 9999999989.9, 9999999945.6]
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson]
========================================================================================
Sample 49: OakJava7 Streams: Sample 9 : Using FlatMap Streams
========================================================================================
Write the Oakjava7 Program using FlatMap Streams:-
================================================
oj7stream11.web
===============
<WEB>
<PACK> sample47
{
public <CLASS> Programn11
{
public void main()
{
Stream()->
Stream.Generate(()->{
<PRINTLN>("----------------------------------------------");
// Assign Double value to object using J7Map and print it using J7Print
Object[] arg13={1.2,5.5,3.7,89.9,45.6};
Object[] asgn2=obj->J7Map(arg13);
<OJ7UTIL> .List ans1=obj->forfxLoop(asgn2);
obj->J7Print(ans1);
<PRINTLN>();
// Assign long value to object using J7Map and print it using J7Print
Object[] arg14={199999999.2,999999995.5,999999993.7,9999999989.9,9999999945.6};
Object[] asgn3=obj->J7Map(arg14);
<OJ7UTIL>.List ans3=obj->forfxLoop(asgn3);
obj->J7Print(ans3);
<PRINTLN>();
// Assign String value to object using J7Map and print it using J7Print
Object[] arg15={"SanJose", "Dallas", "Chicago","SanAntonio", "LosAngeles", "Portland", "Tucson"};
Object[] asgn4=obj->J7Map(arg15);
<OJ7UTIL>.List ans4=obj->forfxLoop(asgn4);
obj->J7Print(ans4);
<PRINTLN>();
// assign the objects like objects,string,long,double to diff object array and pass the Object
// Array to FlatMap. For eg) FlatMap supports list of list ,etc.
// But here FlatMap Supports Array of Object Array
Object[] diff={ans4,ans3,ans1};
Object[] asgn5=obj->FlatMap(diff);
<OJ7UTIL> .List ans5=obj->forfxLoop(asgn5);
// But here Flat Map will Print the Object array of Object Array in a combine Arraylist format.
obj->FlatMapPrint(ans5);
<PRINTLN>();
})->
}
}
}
Output
C:\java7prog> oj7stream11
----------------------------------------------
[1.2, 5.5, 3.7, 89.9, 45.6]
[199999999.2, 999999995.5, 999999993.7, 9999999989.9, 9999999945.6]
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson]
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson, 199999999.2, 999999995.5, 999999993.7, 9999999989.9,
9999999945.6, 1.2, 5.5, 3.7, 89.9, 45.6]
======================================================================================
Sample 50: OakJava7 Streams: Sample 10 : Using FlatMap Streams
=====================================================================================
Write the Oakjava7 Program to print 2nd Character from the given Array of strings
and Merging 3 object array and print it. List After flattening list of objects
and list After flattening list of List .Use FlatMap Streams:-
oj7stream12.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn11
{
public void main()
{
Stream()->
Stream.Generate(()->{
<PRINTLN>("----------------------------------------------");
Object[] arg13={1.2,5.5,3.7,89.9,45.6};
Object[] asgn2=obj->J7Map(arg13);
<OJ7UTIL>.List ans1=obj->forfxLoop(asgn2);
obj->J7Print(ans1);
<PRINTLN>();
Object[] arg14={199999999.2,999999995.5,999999993.7,9999999989.9,9999999945.6};
Object[] asgn3=obj->J7Map(arg14);
<OJ7UTIL>.List ans3=obj->forfxLoop(asgn3);
obj->J7Print(ans3);
<PRINTLN>();
Object[] arg15={"SanJose", "Dallas", "Chicago","SanAntonio", "LosAngeles", "Portland", "Tucson"};
Object[] asgn4=obj->J7Map(arg15);
<OJ7UTIL>.List ans4=obj->forfxLoop(asgn4);
obj->J7Print(ans4);
<PRINTLN>();
<PRINTLN>("Using Flatmap to print 2nd Character from the given Array of strings:");
//<OJ7UTIL>.List list = <OJ7UTIL>.Arrays.asList("SanJose", "Dallas", "Chicago","SanAntonio", //"LosAngeles", "Portland", "Tucson");
string usstates= "'SanJose', 'Dallas', 'Chicago','SanAntonio', 'LosAngeles', 'Portland', 'Tucson'";
<OJ7UTIL>.List list = <AUTOBOX_ARRAY>(usstates);
obj->FlatMapPrint(list);
// print the 2nd Character from the given Array of strings
<OJ7UTIL>.List asgn6=obj->FlatMapChar( list,1);
obj->FlatMapPrint(asgn6);
//Passing the Objects array like ans4,ans3,ans1 to list7@Arrays.asList
<PRINTLN>("The list After flattening list of objects :");
//Merging 3 object array and print it.
//<OJ7UTIL>.List list7 = <OJ7UTIL>.Arrays.asList(ans4,ans3,ans1);
//Merging 3 object array and print it.
Object [] input={ ans4,ans3,ans1 };
<OJ7UTIL>.List list7 =<AUTOBOX_OBJ_ARRAY>(input);
// passing list to FlatMapfx method will convert them into 1 List format and print it.
<PRINTLN>("The list After flattening list of List :");
<OJ7UTIL>.List list8 =obj->FlatMapfx( list7);
obj->FlatMapPrint(list8);
<PRINTLN>("----------------------------------------------");
})->
}
}
}
Output
C:\java7prog> oj7stream12
----------------------------------------------
[1.2, 5.5, 3.7, 89.9, 45.6]
[199999999.2, 999999995.5, 999999993.7, 9999999989.9, 9999999945.6]
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson]
Using Flatmap to print 2nd Character from the given Array of strings:
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson]
[a, a, h, a, o, o, u]
The list After flattening list of objects :
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson, 199999999.2, 999999995.5, 999999993.7, 9999999989.9, 9999999945.6, 1.2, 5.5, 3.7, 89.9, 45.6]
The list After flattening list of List :
[SanJose, Dallas, Chicago, SanAntonio, LosAngeles, Portland, Tucson, 199999999.2, 999999995.5, 999999993.7, 9999999989.9, 9999999945.6, 1.2, 5.5, 3.7, 89.9, 45.6]
----------------------------------------------
======================================================================================
Sample 51: OakJava7(JAVA7.0) Streams: Sample 11 : i) AndThen operation ii) Compose operation iii) Identity in oakjava7
======================================================================================
Q) Write the Oakjava7(JAVA7.0) program with examples about
i) AndThen operation ii) Compose operation iii) Identity in oakjava7
oj7stream13.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn13
{
public void main()
{
Stream()->
Stream.Generate(()->{
<PRINTLN>("----------------------------------------------");
LOGIC(L->{
<PRINTLN>();
<PRINTLN>("After using AndThen operation :");
//AndThen operation in oakjava7
// In this example we first multiply value by 2 and add 3.
int value=3;int multiply=0; int add=0;String s="i like it";
multiply=obj->andThen(value *2);
// add 3 with the multiply result
add=obj->andThen(multiply+3);
// Concat the s value 'i like it' with add values and print add value and s value using J7Print
s=obj->andThen(s)+" "+add;
obj->J7Print(add);
obj->J7Print(s);
<PRINTLN>("----------------------------------------------");
<PRINTLN>("After using Compose operation :");
int value1=3;int multiply1=0; int add1=0;
// At first adding value1 with 3 and assign to add1 int variable.
add1=obj->Compose(value1 +3);
// Multiply add1 value with 2
multiply1=obj->Compose(add1 *2);
// Convert 'wilmix place' to upper case using ToUpper
String str56=" = wilmix place".ToUpper();
//add Multiply1 result with str56 and print it
str56=multiply1+str56;
obj->J7Print(str56);
String add2="";
// Concat the String 'Hiram like it' with multiply1 with add1 value
add2=obj->Compose("Hiram like it "+multiply1+add1);
obj->J7Print(add2);
<PRINTLN>("----------------------------------------------");
// Identity
<PRINTLN>();
<PRINTLN>("Identity in oakjava7:");
//Identity means we pass the value 100 and we will get the same number you have passed.
int results=obj->Identity(100);
<PRINTLN>("----------------------------------------------");
// assign jh=100
int jh=100;
// Now check jh = results value or not, if it is equal then it return a boolean value true and if not it will return false.
bool abcf1=obj->J7Filter( (jh==results)?true:false);
//check if abcf1==true or not , if it is true it will assign true to the boolean status variable if not assign false to the
// boolean value.
bool status= (abcf1==true)? true:false;
//Print the Status using J7Print
obj->J7Print(status);
<PRINTLN>("----------------------------------------------");
//Assign jh1=100 and results1=100
int jh1=100;int results1=100;
// simillarly check if jh1 == results1 value or not , if it is equal it will assign 1 to abcf11 otherwise it will assign 0
// to the abcf11
int abcf11=obj->J7Filter( (jh1==results1)?1:0);
// If abcf11 == 1 then assign true to the status1 boolean variable
// Otherwise assign false to the status1 boolean variable
bool status1= (abcf11==1)?true:false;
//and Print the status1 value using J7Print
obj->J7Print(status1);
<PRINTLN>();
<PRINTLN>("----------------------------------------------");
})->
})->
}
}
}
Output
C:\java7prog> oj7stream13
----------------------------------------------
After using AndThen operation :
9
i like it9
----------------------------------------------
After using Compose operation :
12 = WILMIX PLACE
Hiram like it 126
----------------------------------------------
Identity in oakjava7:
----------------------------------------------
True
----------------------------------------------
True
----------------------------------------------
FAQS
1)What is the difference between andthen operation
and Compose ?
Ans) andthen will evaluate the expression value and do concat operation in
a sequence order. But Compose will evaluate the expression value
and convert the string to uppercase or lowercase and concat the expression value
in non sequence order.
2) What is Identity?
Identity means we pass the value 100 or any datatype to the Identity method and we will get the same number you have passed.
You can pass datatype like int,float,double,String,char to the Identity method.
eg) int results=obj->Identity(100);
Simillarly you can pass the datatype as value like int,float,double,String,char to the
Compose method.
eg) add2=obj->Compose("Hiram like it "+multiply1+add1);
3) What is the difference between Identity and Compose ?
The difference between Identity is Identity will return the same value
you have passed , but Compose will not return the same value
you have passed.
================================================================================
Sample 52: OakJava7(JAVA7.0) Streams: Sample 12 : i) findFirstInt ii) findAnyInt iii) findAnynoOrString
================================================================================
Q) Write a Oakjava7 program for i) findFirstInt ii) findAnyInt iii) findAnynoOrString using .web only?
oj7stream14.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn14
{
public void main()
{
Stream()->
Stream.Generate(()->{
<PRINTLN>("----------------------------------------------");
LOGIC(L->{
<PRINTLN>("findFirst and findAny in oakjava7:");
// Find First
string w1="3,5,7,9,11";
//<OJ7UTIL>.List list23 = <OJ7UTIL>.Arrays.asList(3, 5, 7, 9, 11);
//<AUTOBOX_ARRAY> will convert Object obj (Object / String) to <OJ7UTIL> ArrayList format
<OJ7UTIL>.ArrayList list23=<AUTOBOX_ARRAY>(w1);
// Pass the list23 to findFirstInt method...
int find=obj->findFirstInt(list23);
// Print it.
obj->J7Print(find);
string w12="2, 4, 6, 8, 10";
<OJ7UTIL>.List list24 = <AUTOBOX_ARRAY>(w12);
// Pass the list24 to findAnyInt method...
int find1=obj->findAnyInt(list24);
obj->J7Print(find1);
})->
LOGIC(L->{
<PRINTLN>("findFirst and findAny in oakjava7 using Emptyset:");
// Here <AUTOBOX_ARRAY>(0) is the empty set
<OJ7UTIL>.List list231 = <AUTOBOX_ARRAY>(0);
int find2=obj->findFirstInt(list231);
obj->J7Print(find2);
<OJ7UTIL>.List list232 = <AUTOBOX_ARRAY>(0);
int find3=obj->findAnyInt(list232);
obj->J7Print(find3);
<PRINTLN>();
<PRINTLN>("findAnytypeofelement ?:");
string w2="3, 5, 7, 9, 11,15,21,23";
<OJ7UTIL>.ArrayList list235=<AUTOBOX_ARRAY>(w2);
// Pass the list235 to findAnynoOrString method...
int findanytype=Int32.Parse(obj->findAnynoOrString(list235,2).ToString());
obj->J7Print(findanytype);
<PRINTLN>();
<PRINTLN>("----------------------------------------------");
})->
})->
}
}
}
Output
----------------------------------------------
findFirst and findAny in oakjava7:
3
2
findFirst and findAny in oakjava7 using Emptyset:
0
0
findAnytypeofelement ?:
7
----------------------------------------------
================================================================================
Sample 53: OakJava7(JAVA7.0) Streams: Sample 13 : i) Oakjava7 Stream Generate with limit ( Hold the arrdata , Copy from one list to another list) iv) Oakjava7 Stream Generate with skip (pass List data to the J7Collect method).
vi) Oakjava7 Stream Generate with collect type Treeset or List or Hashmap
================================================================================
Q) Write the OakJava7(JAVA7.0) Streams program for
i) Oakjava7 Stream Generate with limit ( Hold the arrdata,
Copy from one list to another list) iv) Oakjava7 Stream Generate with skip (pass List data to the J7Collect method).
vi) Oakjava7 Stream Generate with collect type Treeset or List or Hashmap
oj7stream15.web
<WEB>
<PACK> sample4715
{
public <CLASS> Programn15
{
public void main()
{
Stream()->
<PRINTLN>("----------------------------------------------");
<PRINTLN>("Oakjava7 Stream Generate ...");
Stream.Generate(()->{
// given data
<OJ7UTIL>.List arrdata = new <OJ7UTIL>.ArrayList();
arrdata.add("geeks");
arrdata.add("for");
arrdata.add("geeks");
arrdata.add("computer");
arrdata.add("science");
// given data
<PRINTLN>("Oakjava7 Stream Generate with limit ...");
//Generate method will hold the arrdata ie) List data
<OJ7UTIL>.List arrdatas = obj->Generate(arrdata);
//Copy the arrdatas to result23
<OJ7UTIL>.List result23 =arrdatas;
// Choose only 3 datas from result23 list.
<OJ7UTIL>.List strop= obj->limit(result23,3);
obj->J7Print(strop);
<PRINTLN>("Oakjava7 Stream Generate with skip ...");
// Skip first 3 datas and Choose only 2 datas from result23 list.
<OJ7UTIL>.List strop1= obj->skip(result23,3);
obj->J7Print(strop1);
<PRINTLN>("Oakjava7 Stream Generate with collect type Treeset or List or Hashmap ...");
// As in Jdk1.8 , here finally we pass List strop1 data to the J7Collect method.
<OJ7UTIL>.List collect1=obj->J7Collect(strop1);
// print the data from collect1
obj->J7Print(collect1);
<OJ7UTIL>.HashMap hp= new <OJ7UTIL>.HashMap();
for (int i=0;i<10;i++)
{
hp.put("A"+i,"A");
hp.put("B"+i,"B");
hp.put("C"+i,"C");
hp.put("D"+i,"D");
hp.put("E"+i,"E");
hp.put("F"+i,"F");
hp.put("G"+i,"G");
hp.put("H"+i,"H");
hp.put("I"+i,"I");
hp.put("J"+i,"J");
}
// Pass hashmap object hp to J7Collectfx5
<OJ7UTIL>.HashMap collect1t= obj->J7Collectfx5(hp);
// finally print it
obj->J7Print(collect1t);
// Add some values in LinkedHashMap and print it.
<OJ7UTIL>.LinkedHashMap hm=new <OJ7UTIL>.LinkedHashMap();
hm.put(100,"Amit");
hm.put(101,"Vijay");
hm.put(102,"Rahul");
<PRINTLN>("hm="+hm);
// Add some values in TreeSet and print it. it will list the data in Ascending order.
<OJ7UTIL>.TreeSet tst = new <OJ7UTIL>.TreeSet();
tst.add("geeks");
tst.add("for");
tst.add("geeks");
tst.add("computer");
tst.add("science");
obj->J7Print(tst);
<PRINTLN>();
<PRINTLN>("----------------------------------------------");
})->
}
}
}
Output
----------------------------------------------
Oakjava7 Stream Generate ...
Oakjava7 Stream Generate with limit ...
[geeks, for, geeks]
Oakjava7 Stream Generate with skip ...
[computer, science]
Oakjava7 Stream Generate with collect type Treeset or List or Hashmap ...
[computer, science]
{A2=A, A1=A, A4=A, A3=A, A6=A, A5=A, I0=I, A8=A, A7=A, E5=E, I3=I, A9=A, E6=E, I4=I, E7=E, I1=I, E8=E, I2=I, E9=E, I7=I, I8=I, I5=I, I6=I, E0=E, I9=I, E2=E, E1=E, E4=E, E3=E, A0=A, B5=B, B4=B, B3=B, B2=B, B9=B, B8=B, B7=B, J0=J, B6=B, J1=J, F8=F, J2=J, F9=F, J3=J, F6=F, J4=J, F7=F, J5=J, J6=J, J7=J, J8=J, J9=J, F1=F, F0=F, F5=F, F4=F, F3=F, F2=F, B0=B, B1=B, C8=C, C7=C, C9=C, C4=C, C3=C, C6=C, C5=C, G7=G, G8=G, G9=G, G4=G, G3=G, G6=G, G5=G, G0=G, G2=G, G1=G, C0=C, C1=C, C2=C, D9=D, D8=D, D7=D, D6=D, D5=D, D4=D, H8=H, H9=H, H7=H, H6=H, H5=H, H4=H, H3=H, H2=H, H1=H, H0=H, D2=D, D3=D, D0=D, D1=D}
hm={100=Amit, 101=Vijay, 102=Rahul}
[computer, for, geeks, science]
================================================================================
Sample 54: OakJava7(JAVA7.0) Streams: Sample 14 :Optional Type 1) i) Replace the empty arraylist by 0.
ii) If null value is found in arraylist then replace the null value by 0.
Optional Type 2) i) Add some datas to arraylist and check whether the given data
is present in ArrayList or not.
Optional Type -3: i) Find whether the given value exists in ArrayList
arrdata771 or not if found then square it.
================================================================================
Q) Write the OakJava7(JAVA7.0) Streams program for
Optional Type 1) i) Replace the empty arraylist by 0.
ii) If null value is found in arraylist then replace the null value by 0.
Optional Type 2) i) Add some datas to arraylist and check whether the given data
is present in ArrayList or not.
Optional Type -3: i) Find whether the given value exists in ArrayList
arrdata771 or not if found then square it.
Oj7Stream16.web
<WEB>
<PACK> sample4716
{
public <CLASS> Programn16
{
public void main()
{
Stream()->
Streamfx()->
Stream.Generate(()->{
<PRINTLN>("----------------------------------------------");
LOGIC(L->{
// Optional f(x)
<PRINTLN>("Oakjava7 Optional NULL with an absent value ...");
//ArrayList with empty set is defined
<OJ7UTIL>.ArrayList datanull = new <OJ7UTIL>.ArrayList ();
// The Arraylist contains nothing (empty set) that is replaced by 0.
<OJ7UTIL>.ArrayList res11= obj->OptionalNullOf(datanull,"0");
obj->J7Print(res11);
// Here null value is added to the arraylist arrdata24
<OJ7UTIL>.ArrayList arrdata24 = new <OJ7UTIL>.ArrayList();
arrdata24.add("geeks");
arrdata24.add("for");
arrdata24.add(null);
arrdata24.add("computer");
arrdata24.add("science");
// The Arraylist contains null data is replaced by 0.
<OJ7UTIL>.ArrayList res112= obj->OptionalNullOf(arrdata24,"0");
// Print it
obj->J7Print(res112);
})->
LOGIC(L->{
// optional type 2
<OJ7UTIL>.ArrayList arrdata77 = new <OJ7UTIL>.ArrayList();
arrdata77.add("geeks");
arrdata77.add("for");
arrdata77.add("geeks");
arrdata77.add("computer");
arrdata77.add("science");
<OJ7UTIL>.ArrayList res1123 =obj->OptionalOf(arrdata77);
obj->J7Print(res1123);
//Is Present will check whether the data computer is present in
// in arraylist arrdata77 or not
bool bb= obj->IsPresent(arrdata77,"computer");
obj->J7Print(bb);
// If present
int value80= 14;
})->
LOGIC(L->{
// optional type 3
<OJ7UTIL>.ArrayList arrdata771 = new <OJ7UTIL>.ArrayList();
arrdata771.add(12);
arrdata771.add(14);
arrdata771.add(15);
arrdata771.add(16);
arrdata771.add(20);
// Given value80=14 we have to find such value exists in ArrayList arrdata771 or not
// if found then then square it.
<OJ7UTIL>.ArrayList aops= fx-> IfPresent(arrdata771,value80 *value80,value80);
fx-> J7Print(aops);
<PRINTLN>("----------------------------------------------");
})->
})->
}
}
}
Output
----------------------------------------------
Oakjava7 Optional NULL with an absent value ...
[0]
[geeks, for, 0, computer, science]
[geeks, for, geeks, computer, science]
True
[12, 196, 15, 16, 20]
----------------------------------------------
================================================================================
Sample 55: OakJava7(JAVA7.0) Streams: Sample 15 : i) Check whether the
given first character is in upper case or not ,if found then return true
otherwise false.
ii) Check whether the given first character is in Lower case or not ,if found then return true
otherwise false.
===================================================================================
Q) Write the OakJava7(JAVA7.0) Streams program to
i) Check whether the given first character is in upper case or not ,if found then return true
otherwise false.
ii) Check whether the given first character is in Lower case or not ,if found then return true
otherwise false.
oj7stream20.web
<WEB>
<PACK> sample4
{
public <CLASS> Programn20
{
public void main()
{
<PRINTLN>(" Any match using list are ...");
Stream()->
LOGIC(L->{
string w2="'Wilmix','jEmin'";
<OJ7UTIL>.ArrayList list505=<AUTOBOX_ARRAY>(w2);
//Check whether the given w2 data first character is in Uppercase or not
//If it is uppercase then return true otherwise it will return false
bool match=obj->IsAnyCharPresent(list505 ,1,"UpperCase");
obj->J7Print(match);
//Check whether the given w2 data first character is in Lowercase or not
//If it is Lowercase then return true otherwise it will return false
match=obj->IsAnyCharPresent(list505 ,1,"LowerCase");
obj->J7Print(match);
})->
})->
}
}
}
Output
Any match using list are ...
True
True
=================================================================================================================================
Sample 56: OakJava7(JAVA7.0) Streams: Sample 16 :
i) Check two arraylist soap and soap1 are equal or not using oakjava7 biPredicate.
ii) Check the arraylist soap2 is greater than soap3 or not. iii) Check the arraylist
soap2 is less than soap3 or not.iv) check both boolean values ful and ful1 result is
same or not using and operator.v) check anyone boolean values ful or ful2 result is
same or not using or operator.vi) Do negative operation at boolean values ful and ful2
using not operator and check the result is same or not.
================================================================================================================================
Q) Write the OakJava7 Program for the given conditional streams
i) Check two arraylist soap and soap1 are equal or not using oakjava7 biPredicate.
ii) Check the arraylist soap2 is greater than soap3 or not. iii) Check the arraylist
soap2 is less than soap3 or not.iv) check both boolean values ful and ful1 result is
same or not using and operator.v) check anyone boolean values ful or ful2 result is
same or not using or operator.vi) Do negative operation at boolean values ful and ful2
using not operator and check the result is same or not.
oj7stream20.web
<WEB>
<PACK> sample4
{
public <CLASS> Programn21
{
public void main()
{
<PRINTLN>(" Any match using list are ...");
Stream()->
READLN(I->{
// Give two input valeus say w1,w2
string w1="-1,-1";string w2="1,-1";
<OJ7UTIL>.ArrayList soap=<AUTOBOX_ARRAY>(w1);
<OJ7UTIL>.ArrayList soap1=<AUTOBOX_ARRAY>(w1);
<OJ7UTIL>.ArrayList soap2=<AUTOBOX_ARRAY>(w2);
<OJ7UTIL>.ArrayList soap3=<AUTOBOX_ARRAY>(w1);
// example
// Get soap3 arraylist contents and pass to arsd arraylist and print it.
OJ7UTIL.ArrayList arsd= <AUTOBOX_J7ARRAY>(soap3);
<PRINTLN> ("Print OJ7UTIL contents");
obj->J7Print(arsd);
<PRINTLN>(" ");
})->
LOGIC(L->{
// Check two arraylist soap and soap1 are equal or not using oakjava7 biPredicate
bool ful = obj->J7Bi@P(soap, soap1, "EQ");
// Print the boolean value
obj->J7Print("@P Equal matches :"+ful);
// Check the arraylist soap2 is greater than soap3 or not.
bool ful1 =obj->J7Bi@P(soap2,soap3,"GT"); //true
obj->J7Print(""+ful1);
// Check the arraylist soap2 is less than soap3 or not.
bool ful2 =obj->J7Bi@P(soap2,soap3,"LS");//false
obj->J7Print(""+ful2);
// check both boolean values ful and ful1 result is same or not.
bool tthop= obj->J7Bi@PCompare(ful,ful1,"and");
obj->J7Print(tthop);
// check anyone boolean values ful or ful2 result is same or not.
bool tthop1= obj->J7Bi@PCompare(ful,ful2,"or");
obj->J7Print(tthop1);
// Do negative operation at boolean values ful and ful2 using not operator and check the result is same or not.
bool tthop2= obj->J7Bi@PCompare(ful,ful2,"not");
obj->J7Print(tthop2);
})->
}
}
}
Output
============
Any match using list are ...
Print OJ7UTIL contents
[-1, -1]
Predicate Equal matches :True
True
False
True
True
False
==============================================================================================================
Sample 57: OakJava7(JAVA7.0) Streams: Sample 17 :
i)Consumer must get the values and print the values.
ii) Pass consumer data 'consdata' to andThen operator which return arraylist format and print it.
iii) Count the no of data in the stream iv) Check whether the product length equals to 10 or not,
return the boolean value as false if the length is different. v) Given product length is 7 , so 7-2 =5,
which is assigned to the supplier. vi) Get the value from the supplier and print it,supplier will return the value.
vii) Assign datetime and print the supplier viii) Assign Product = uppercase of the given data (Android).
======================================================================================
Q) Write the OakJava7 Program for the supplier and consumer...
i)Consumer must get the values and print the values.
ii) Pass consumer data 'consdata' to andThen operator which return arraylist format and print it.
iii) Count the no of data in the stream iv) Check whether the product length equals to 10 or not,
return the boolean value as false if the length is different. v) Given product length is 7 , so 7-2 =5,
which is assigned to the supplier. vi) Get the value from the supplier and print it,supplier will return the value.
vii) Assign datetime and print the supplier viii) Assign Product = uppercase of the given data (Android).
oj7stream22.web
<WEB>
<PACK> consumersupplier
{
public <CLASS> Programn21
{
public void main()
{
Stream()->
READLN(I->{
//Consumer with respect to Custom defined
<PRINTLN>();
<PRINTLN>("Oakjava7 Consumer for Custum...");
<OJ7UTIL>.List conslist= new <OJ7UTIL>.ArrayList();
conslist.add(2);
conslist.add(1);
conslist.add(3);
<OJ7UTIL>.List conslist19= new <OJ7UTIL>.ArrayList();
for (int i = 0; i < conslist.size(); i++)
{
conslist19.add(i,2 * Convert.ToInt32(conslist.get(i).ToString()));
}
obj->Consumer(conslist19);
obj->accept(10);
<OJ7UTIL>.List consdata=new <OJ7UTIL>.ArrayList();
consdata.add(1);consdata.add(21);consdata.add(31);consdata.add(41);consdata.add(51);consdata.add(61);consdata.add(71);
consdata.add(81);consdata.add(91);consdata.add(101);consdata.add(102);consdata.add(103);consdata.add(104);consdata.add(105);
consdata.add(106);consdata.add(107);consdata.add(108);consdata.add(109);consdata.add(110);consdata.add(111);consdata.add(112);
})->
LOGIC(L->{
// pass consumer data 'consdata' to andThen operator which return arraylist format and print it.
<OJ7UTIL>.List conslist1=obj->andThen(consdata);
obj->J7Print(conslist1);
// count the data present in a stream
<PRINTLN>();
<PRINTLN>("Oakjava7 Count the no of data in the stream...");
Streamoj1()->
//Count the no of data in the stream
long lg= oj1->count();
oj1->J7Print(lg);
<PRINTLN>();
<PRINTLN>("Oakjava7 Supplier.");
String product = "Android";
double price = 659.50;
Streamfx()->
// check whether the product length equals to 10 or not,
// return the boolean value as false if the length is different.
fx->Assign(product.Length ==10);
//return data from the supplier
obj->J7Print(fx->getSupplier());
// Here product length is 7 , so 7-2 =5, which is assigned to the supplier
fx->Assign(product.Length -2);
// get the value from the supplier and print it,supplier will return the value.
obj->J7Print(fx->getSupplier());
fx->Assign(price-20);
obj->J7Print(fx->getSupplier());
string times = DateTime.Now.ToString("h:mm:ss tt");
// assign the time
fx->Assign(times);
// print the supplier
obj->J7Print(fx->getSupplier());
//assign Product = uppercase of the given data (Android)
fx->Assign(product.ToUpper());
// print the supplier
obj->J7Print(fx->getSupplier());
})->
}
}
}
Output
Oakjava7 Consumer for Custum...
[4, 2, 6]
10
[1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112]
Oakjava7 Count the no of data in the stream...
21
Oakjava7 Supplier.
False
5
639.5
7:52:16 PM
ANDROID
==============================================================================================================
Sample 58: OakJava7(JAVA7.0) Streams: Sample 18 :
i) Convert array 'stringarr' to arraylist ii) Print only the first value ie) lstra.get(0)
from arraylist iii) Use allMatch function is used to check whether the given arraylist 'lstr'
datas length is greater than 100 or not, if it is greater then return true..
iv) Oakjava7 all match with String V) Check all the second character for a given strings
are uppercase or not. vi) Check all the second character for a given strings are Lowercase or not.
vii) Oakjava7 all match in a sentence ...
viii) Convert all the ascii value to integer format..
a) Check if all the integer value of ascii value is greater than 700 or not.
b) Check if all the integer value of ascii value is greater than 30 or not.
ix) Check if none of the given values in list2351 (List) did not matches 2 or not,
if it matches 2 then return false.
======================================================================================
Q) Write the OakJava7 program for the given ...
i) Convert array 'stringarr' to arraylist ii) Print only the first value ie) lstra.get(0)
from arraylist iii) Use allMatch function is used to check whether the given arraylist 'lstr'
datas length is greater than 100 or not, if it is greater then return true..
iv) Oakjava7 all match with String V) Check all the second character for a given strings
are uppercase or not. vi) Check all the second character for a given strings are Lowercase or not.
vii) Oakjava7 all match in a sentence ...
viii) Convert all the ascii value to integer format..
a) Check if all the integer value of ascii value is greater than 700 or not.
b) Check if all the integer value of ascii value is greater than 30 or not.
ix) Check if none of the given values in list2351 (List) did not matches 2 or not,
if it matches 2 then return false.
oj7stream23.web
<WEB>
// load CUTIL packages
<USE> CUTIL;
//Load Oakjava7Util packages
<USE> <OJ7UTIL>;
<PACK> sample4
{
public <CLASS> Programn20
{
public void main()
{
<PRINTLN>(" Any match using list are ...");
Stream()->
LOGIC(L->{
// Step 1: Array Declaration
string[] stringarr;
// Step 2:Array Initialization
stringarr = new string[3] {"Element 1", "Element 2", "Element 3"};
CUTIL.ArrayList lstra= new CUTIL.ArrayList();
//convert array 'stringarr' to arraylist
lstra.add(0,J7ALOGIC.J7ALOGIC.ConvertArraytoArrayList(stringarr));
String obj6=lstra.get(0).ToString();
// print only the first value ie) lstra.get(0) from arraylist
obj.J7Print("Obj6="+obj6);
obj.J7Print("DATA="+J7ALOGIC.J7ALOGIC.Manipulation(obj6).get(0));
//All match
string[] datan={"wilmix","jEmin"};
// This <AUTOBOX_ARRAY> is nothing but Arrays.asList function in java
<OAKJAVA7>.util.List lstr=<AUTOBOX_ARRAY>(datan);
bool bbbb=false;
for (int i=0;i<lstr.size();i++)
{
// This allMatch function is used to check whether the given
// arraylist 'lstr' datas length is greater than 100 or not,
//if it is greater then return true..
bbbb=obj->allMatch(lstr.get(i).ToString().Length > 100);
if (bbbb==false)
break;
}
obj->J7Print("All Matchcnd1="+bbbb);
// wcode All match type-2 geeks
bool match5=false;
<PRINTLN>();
<PRINTLN>("Oakjava7 all match with String...");
//OakJ7Stream.OJ7Stream wstrr11= new OakJ7Stream.OJ7Stream();
string datan1="wIlmix,jEmin,mHttilda,cHristi";
string datan2="wilmix,jemin,mhttilda,christi";
Streamfx()->
<OJ7UTIL>.List lstr5=<AUTOBOX_ARRAY>(datan1);
//("wIlmix","jEmin","mHttilda","cHristi");
<OJ7UTIL>.List lstr51=<AUTOBOX_ARRAY>(datan2);
// check all the second character for a given strings are uppercase or not
match5=fx->IsAllCharPresent(lstr5,1,"UpperCase");
fx->J7Print("MatchAllUp="+match5);
// check all the second character for a given strings are Lowercase or not
match5=fx->IsAllCharPresent(lstr51,1,"LowerCase");
fx->J7Print("MatchAllLower="+match5);
//wcode start
<PRINTLN>();
<PRINTLN>("Oakjava7 all match in a sentence ...");
String sample = "Om Sarve Bhavantu Sukhinah";
String[] s5=sample.Split(' ');
for (int i=0;i<s5.Length;i++)
{
bool aaaa=false;
// Convert all the ascii value to integer format
int res1 =fx->AsciitoInt(s5[i]);
<PRINTLN>("ascii value="+res1);
//check if all the integer value of ascii value is greater than 700 or not.
aaaa=obj->allMatch(res1 > 700);
fx->J7Print("MatchAllwithcnd1="+aaaa);
//check if all the integer value of ascii value is greater than 30 or not.
aaaa=obj->allMatch(res1 > 30);
fx->J7Print("MatchAllwithcnd1="+aaaa);
}
//none match
//given integer values in String format
//string ary="3,3,3,3,3,3,3,1,3";
//Here value 2 is present so it return false
string ary="3,3,3,3,3,3,3,2,3";
<OAKJAVA7>.util.List list2351 = <AUTOBOX_ARRAY>(ary);
//<OAKJAVA7>.util.Arrays.asList(3,3,3,3,3,3,3,3,3);
bool sop244=false;
//OakJ7Stream.OJ7Stream conos= new OakJ7Stream.OJ7Stream();
Streamagg()->
bool[] arrayd= new bool[list2351.size()];
for (int i=0;i<list2351.size();i++)
{
bool iop345=Convert.ToInt32(list2351.get(i).ToString()) ==2;
//Check if none of the given values in list2351 (List) did not matches 2 or not,
// if it matches 2 then return false
arrayd[i]=AGG->NoneMatchfx(list2351,iop345);
}
for (int i=0;i<arrayd.Length;i++)
{
if (arrayd[i]==true)
sop244=true;
else
{
sop244=false;
break;
}
}
AGG->J7Print("Check if none of the given values in list2351 (List) did not matches 2 or not = "+sop244);
})->
}
}
}
Output
Any match using list are ...
Obj6=[Element 1, Element 2, Element 3]
DATA=Element 1
All Matchcnd1=False
Oakjava7 all match with String...
MatchAllUp=True
MatchAllLower=True
Oakjava7 all match in a sentence ...
ascii value=188
MatchAllwithcnd1=False
MatchAllwithcnd1=True
ascii value=513
MatchAllwithcnd1=False
MatchAllwithcnd1=True
ascii value=825
MatchAllwithcnd1=True
MatchAllwithcnd1=True
ascii value=827
MatchAllwithcnd1=True
MatchAllwithcnd1=True
Check if none of the given values in list2351 (List) did not matches 2 or not = False
======================================================================================
Sample 59: OakJava7(JAVA7.0) Streams:Sample 19 :Remove duplicates from arrayList and using set
======================================================================================
Q) Write the OakJava7 Program to Remove duplicates from arrayList using Distinct and
using Distinct set..
Oj7stream24.web
<WEB>
<PACK> oj7example24
{
public <CLASS> Program4
{
public void main()
{
//Consumer with respect to Custom defined
<PRINTLN>();
<PRINTLN>("Remove duplicates from arrayList and using set ..");
Stream()->
//OakJ7Stream.OJ7Stream obj11= new OakJ7Stream.OJ7Stream();
READLN(I->{
<PRINTLN>(" Remove duplicates list using arraylist are :");
<OJ7UTIL>.ArrayList lop5= new <OJ7UTIL>.ArrayList();
lop5.add(100);
lop5.add(1);
lop5.add(12);lop5.add(12);lop5.add(100);lop5.add(13);lop5.add(14);lop5.add(15);lop5.add(16);lop5.add(100);
lop5.add(100);
lop5.add(14);lop5.add(16);lop5.add(19);lop5.add(100);lop5.add(1);lop5.add(100);
})->
DISPLAY(O->{
lop5=j7Lib->Distinct(lop5);
obj->J7Print(lop5);
<PRINTLN>(" Remove duplicates list using Set are :");
lop5=j7Lib->DistinctSet(lop5);
obj->J7Print(lop5);
})->
}
}
}
Output
Remove duplicates from arrayList and using set ..
Remove duplicates list using arraylist are :
[100, 1, 12, 13, 14, 15, 16, 19]
Remove duplicates list using Set are :
[100, 1, 12, 13, 14, 15, 16, 19]
======================================================================================
Sample 60: OakJava7(JAVA7.0) Streams: Sample 20 :
i) Print the data and print stmt will return the value as Success with condition.
ii) Oakjava7forloopType1 using Object Array
iii) Print all the object array contents line by line
iv) Print all the object array contents in one line itself.
v) Use OakJava7 Iterator to iterate the List ar99 and ar991 contents only in forward directions
using <OJ7Displayt2> (Forward direction of the Iterator) and <OJ7Displayt1>(Forward direction of the Iterator) where 1 and 2 nos in this function indicates backward directions.
vi) Use OakJava7 Iterator to iterate the List ar99 and ar991 contents only in backward(reverse) directions, using <J7ITERATOR>(list235,3,list235.size()); where 3 no in this function indicates backward directions.
============================================================================================
Q) Write the OakJava7 Program to print the values in forward and backward directions using
iterators.Solve the given below....
i) Print the data and print stmt will return the value as Success with condition.
ii) Oakjava7forloopType1 using Object Array
iii) Print all the object array contents line by line
iv) Print all the object array contents in one line itself.
v) Use OakJava7 Iterator to iterate the List ar99 and ar991 contents only in forward directions
using <OJ7Displayt2> (Forward direction of the Iterator) and <OJ7Displayt1>(Forward direction of the Iterator)
where 1 and 2 nos in this function indicates backward directions.
vi) Use OakJava7 Iterator to iterate the List ar99 and ar991 contents only in backward(reverse) directions,
using <J7ITERATOR>(list235,3,list235.size()); where 3 no in this function indicates backward directions.
Ojstream25.web
<WEB>
<PACK> sample47
{
public <CLASS> Programn14
{
public void main()
{
Stream()->
Stream.Generate(()->{
<PRINTLN>("----------------------------------------------");
<PRINTLN>("");
<PRINTLN>("----------------------------------------------");
// autobox print the data and print stmt will return the value as Success with condition.
<PRINTLN>("");
<J7PRINT>("welcome");
<PRINTLN>("");
object[] arg12={1,5,3,89,45};
<PRINTLN>("----------------------------------------------");
//Print all the object array contents line by line
<J7ForLoopDisplayt1>(arg12);
//Print all the object array contents in one line itself
<J7ForLoopDisplayt2>(arg12);
<PRINTLN>("");
OJ7UTIL.ArrayList ar99t1 =
// Use OakJava7 Iterator to iterate the List ar99 contents
<J7ITERATOR> ( list235,1,0);
<OJ7Displayt2>(ar99t1);
<PRINTLN>("");
OJ7UTIL.ArrayList ar991 = <J7ITERATOR>( list235,2,0);
<OJ7Displayt1>(ar991);
<PRINTLN>("");
<PRINTLN>("");
OJ7UTIL.ArrayList ar992 =<J7ITERATOR>(list235,3,list235.size());
<PRINTLN>(ar992);
<PRINTLN>("");
<PRINTLN>();
<PRINTLN>("----------------------------------------------");
})->
})->
}
}
}
Output
----------------------------------------------
welcome
----------------------------------------------
1
5
3
89
45
1 5 3 89 45
[3, 5, 7, 9, 11, 15, 21, 23]
[3, 5, 7, 9, 11, 15, 21, 23]
[23, 21, 15, 11, 9, 7, 5, 3]
----------------------------------------------
======================================================================================
Sample 61: OakJava7(JAVA7.0) Parallel Stream: Sample 21 :
a) Write a OakJava7 Program to print all the String in a
non sequence order..
======================================================================================
Q) Write a OakJava7 Program to print all the String in a
non sequence order..
Parallelth.web
<WEB>
<PACK> sample4
{
public <CLASS> ParallelThreads
{
public void main()
{
<PRINTLN>("P A R A L L E L T H R E A D");
/* This is about String Parallel Stream
*/
// assign the lines in string
String line1="Wilmix is a computer scientist. ";
String line2="Jacob is a friend for him. ";
String line3="Guido is a computer scientist and friend of wilmix. ";
String line4="Garouv is hr and friend of wilmix. ";
String line5="Orange plant is grown at wilmix home. ";
<TRY>
{
//OakJ7Stream.OJ7Stream oj1= new OakJ7Stream.OJ7Stream();
//define a Parallel stream, Parallel stream means it will display the line in a non-sequence order using threads.
ParallelStream()
// For achieving the parallel stream first pass the String line to oj.Parallel method..
OakJ7Stream.j7TH a1 = oj1.Parallel (line1);
OakJ7Stream.j7TH a2 = oj1.Parallel (line2);
OakJ7Stream.j7TH a3 = oj1.Parallel (line3);
OakJ7Stream.j7TH a4 = oj1.Parallel (line4);
OakJ7Stream.j7TH a5 = oj1.Parallel (line5);
// For achieving with thread pass the OakJ7stream objects to thread.
// TH in this given example means thread...
<java>.lang.TH t1 = new <java>.lang.TH(a1);
<java>.lang.TH t2 = new <java>.lang.TH(a2);
<java>.lang.TH t3 = new <java>.lang.TH(a3);
<java>.lang.TH t4 = new <java>.lang.TH(a4);
<java>.lang.TH t5 = new <java>.lang.TH(a5);
// Set the name for the threads...
t1.setName ("t1");
t2.setName ("t2");
t3.setName ("t3");
t4.setName ("t4");
t5.setName ("t5");
//Start the threads like t1,t2,t3,t4,t5
t1.start ();
t2.start ();
t3.start ();
t4.start ();
t5.start ();
//List with Parallel stream
bool activate=false;
// Add the lines like line1,line2,line3,line4,line5 to Oakjava7 List
//simillarly do the same procedure as we done before...
<OJ7UTIL>.List pal1= new <OJ7UTIL>.ArrayList();
pal1.add(line1);
pal1.add(line2);
pal1.add(line3);
pal1.add(line4);
pal1.add(line5);
OakJ7Stream.j7TH a11 = oj1.Parallel (pal1.get(0).ToString());
OakJ7Stream.j7TH a12 = oj1.Parallel (pal1.get(2).ToString());
OakJ7Stream.j7TH a13 = oj1.Parallel (pal1.get(4).ToString());
<java>.lang.TH t11 = new <java>.lang.TH (a11);
<java>.lang.TH t21 = new <java>.lang.TH (a12);
<java>.lang.TH t31 = new <java>.lang.TH (a13);
// Set the name for the threads...
t11.setName ("t1");
t21.setName ("t2");
t31.setName ("t3");
<PRINTLN>();
<PRINTLN>("Oakjava7 Parallel stream with List...");
//Start the threads
t11.start ();
t21.start ();
t31.start ();
<PRINTLN>();
<PRINTLN>("Oakjava7 Check stream is working in parallel or not ?..");
activate=true;
// Check if it is parallel or not then print the stream is running parallelly.
if (oj1.isParallel(activate))
{
<PRINTLN>("The stream is running parallelly.");
}
else
{
<PRINTLN>("The stream is not running parallelly.");
}
//Write the result to j7streamvalue.ojs7 files.
<PRINTLN>("Access=" + fx.FileSequentialAccess.Read("j7streamvalues.ojs7"));
// Clear the j7streamvalue.ojs7 contents...
OakJ7Stream.j7TH.clearoj7file("j7streamvalues.ojs7");
}
<CATCH>(<EXE> e)
{
<PRINTLN>(""+e);
}
}
}
}
Output
Note: Each time we run this program will display in a non sequence order;
so each time you run this program , order of the parallel streams will change
P A R A L L E L T H R E A D
Oakjava7 Parallel stream with List...
Oakjava7 Check stream is working in parallel or not ?..
The stream is running parallelly.
Access= Wilmix is a computer scientist. Orange plant is grown at wilmix home. Garouv is hr and friend of wilmix.
Orange plant is grown at wilmix home. Wilmix is a computer scientist. Jacob is a friend for him.
Guido is a computer scientist and friend of wilmix. Guido is a computer scientist and friend of wilmix.
=====================================================================================
Sample 62: OakJava7(JAVA7.0) Parallel Stream: Sample 22 :
a) Write a OakJava7 Program to print all the numbers in a
non sequence order..
=================================================================================================================================
Q) Write a OakJava7 Program to print all the numbers in a
non sequence order..
parallelph2.web
<WEB>
<PACK> finlThread
{
public <CLASS> ParallelThre
{
public void main()
{
<PRINTLN>("P A R A L L E L T H R E A D");
/*
This is about Integer Parallel Stream
*/
<TRY>
{
//OakJ7Stream.OJ7Stream oj1= new OakJ7Stream.OJ7Stream();
ParallelStream()
// Add integers to List
<OJ7UTIL>.List ars = new <OJ7UTIL>.ArrayList();
ars.add(100);
ars.add(101);
ars.add(102);
ars.add(10);
ars.add(1000);
ars.add(84);
// Add integers to List
<OJ7UTIL>.List ars1 = new <OJ7UTIL>.ArrayList();
ars1.add(1020);
ars1.add(1011);
ars1.add(1062);
ars1.add(170);
ars1.add(10080);
ars1.add(844);
// Pass ars to OakJ7Stream.ParallelThreadA (thread A)
OakJ7Stream.ParallelThreadA.Apply(ars);
// Pass ars1 to OakJ7Stream.ParallelThreadA (thread B)
OakJ7Stream.ParallelThreadB.Apply(ars1);
// Write all the integer data in file j7streamvalues.ojs7
// So all the integer data will be in a non sequence order...
//Write the result to j7streamvalue.ojs7 files.
<PRINTLN>("Access=" + fx.FileSequentialAccess.Read("j7streamvalues.ojs7"));
// Clear the j7streamvalue.ojs7 contents...
OakJ7Stream.j7TH.clearoj7file("j7streamvalues.ojs7");
}
<CATCH>(<EXE> e)
{
<PRINTLN>(""+e);
}
}
}
}
Output
P A R A L L E L T H R E A D
Access= 1020 1011 1062 170 10080 844 100 101 102 10 1000 84
======================================================================================
Sample 63: OakJava7(JAVA7.0) Parallel Stream: Sample 23 : Parallel Stream with Boolean value and Apply J7Filter condition.
================================================================================================================================
Q) Parallel Stream with Boolean value and Apply J7Filter condition.
parallelstreameg1.web
<WEB>
<PACK> finlThread
{
public <CLASS> ParallelThre
{
public void main()
{
<PRINTLN>("P A R A L L E L T H R E A D");
<TRY>
{
ParallelStream()
<OJ7UTIL>.List ars = new <OJ7UTIL>.ArrayList();
ars.add(100);
ars.add(101);
ars.add(102);
ars.add(10);
ars.add(1000);
ars.add(84);
string s1= "Abc";
string s2="Abc";
// Here apply J7Filter condition like
// s1 equals s2 or not
// If it is Equal then print the values
oj1.J7Print(oj1.J7Filter(s1.Equals(s2) ));
}
<CATCH>(<EXE> e)
{
<PRINTLN>(""+e);
}
}
}
}
Output
P A R A L L E L T H R E A D
True
============================================================================================================================================
Sample 64: OakJava7(JAVA7.0) Work Samples : Work Exercises for OakJava7 Professionals.
============================================================================================================================================
A) OakJava7(JAVA7.0) Work Samples : Work Exercises for OakJava7 Porfessionals.
=================================================================================================================
1)Exchange two given number, not using temporary variable using OakJava7 only.
2) Reverse the given no and check whether the given number is palindrome or not using OakJava7 only?
3) Generate the Marksheet for each the Student in Class A using OakJava7 only ?
4) Pascal Triangle using OakJava7 only.
5) Perimeter for circle and rectangle using OakJava7 only.
6) OakJava7Program to perform operations like credit ,debit ,Display how many amount is
remaining, how many amount is credited and debited for the particular person.(Banking choice)
using OakJava7 only.
7) Multiplicaton of two matrix. and Addition and substraction for the given matrix using OakJava7 only.
8) Inheritance in Oakjava7 using OakJava7 only.
9) Write a OakJava7 Program to Find the Roots of Quadratic Equation using OakJava7 only.
10) Check Anagram or not for the given number using OakJava7 only.
11) Practice all oakjava7 programs from the website.
12) Practice all C# programs like oakjava7 programs from the website.
Note : All Oakjava7(Java7.0) professionals should write their own logic for Oakjava7(JAVA7.0) programs. This is your Home work.
======================================================================================
Sample 65: OakJava7(JAVA7.0) : Sample 1 : Write OakJava7 Program for the Elevator.
======================================================================================
Q) Write OakJava7 Program for the Elevator to go up to 4th floor and give a sound.
Elevator.web
<WEB>
<USE> Java7sound; // This package is nothing but when the Elevator drops a person the Sound appears
<PACK> Elevator
{
<CLASS> Lifts
{
public void main()
{
int floorno=0;
floorno=4;
if (floorno==1)
{
<PRINTLN>("first floor door open");
Program.java7sound();
for (int i = 0; i < 5; i++)
{
<PRINTLN>("Door open for 2 seconds.");
}
<PRINTLN>("first floor door closed");
}
if (floorno==2)
{
<PRINTLN>("second floor door open");
Program.java7sound();
for (int i = 0; i < 5; i++)
{
<PRINTLN>("Door open for 2 seconds.");
}
<PRINTLN>("second floor door closed");
}
if (floorno==3)
{
<PRINTLN>("third floor door open");
Program.java7sound();
for (int i = 0; i < 5; i++)
{
<PRINTLN>("Door open for 2 seconds.");
}
<PRINTLN>("third floor door closed");
}
if (floorno==4)
{
<PRINTLN>("Fourth floor door open");
Program.java7sound();
for (int i = 0; i < 5; i++)
{
<PRINTLN>("Door open for 2 seconds.");
}
<PRINTLN>("Fourth floor door closed");
}
if (floorno==5)
{
<PRINTLN>("Fifth floor door open");
Program.java7sound();
for (int i = 0; i < 5; i++)
{
<PRINTLN>("Door open for 2 seconds.");
}
<PRINTLN>("Fifth floor door closed");
}
}
}
}
Output
Fourth floor door open
Door open for 2 seconds.
Door open for 2 seconds.
Door open for 2 seconds.
Door open for 2 seconds.
Door open for 2 seconds.
Fourth floor door closed
Note: For the sound ,use java7sound.dll in oakjava7 properties file (properties.txt).
=====================================================================================
Sample: 66 : Sample 2 : Write the OakJava7 Program to perform Login credentials with Username and Password.
======================================================================================
Q) Write the OakJava7 Program by verifying username and password in wnosql db is equal or not.
If it equals it will print the message "user login succesfully". If there is runtime error it should
print the message "user not login successfuly".Or if the username and password is not correct then it should print the message "user not login successfuly".
loginuser.web
==============
<WEB>
<USE> Security;//load security packages
<WNOSQL> //load wnosql db packages
<PACK> Program8
{
<CLASS> Prog
{
public void main()
{
// Like servlet we embed the html and css in OakJava7 program, So it is called as Oakjava7 //Servlet.
<PRINTLN>("<HTML>");
<PRINTLN>("<head> <style>");
<PRINTLN>("table {");
<PRINTLN>(" width:100%;");
<PRINTLN>("}");
<PRINTLN>("table, th, td {");
<PRINTLN>("border: 1px solid black;");
<PRINTLN>(" border-collapse: collapse;");
<PRINTLN>("}");
<PRINTLN>("th, td {");
<PRINTLN>(" padding: 5px;");
<PRINTLN>(" text-align: left;");
<PRINTLN>("}");
<PRINTLN>("table#t01 tr:nth-child(even) {");
<PRINTLN>(" background-color: grey;");
<PRINTLN>("}");
<PRINTLN>("table#t01 tr:nth-child(odd) {");
<PRINTLN>("background-color:yellow;");
<PRINTLN>("}");
<PRINTLN>("table#t01 th {");
<PRINTLN>(" background-color: black;");
<PRINTLN>("color: white;");
<PRINTLN>("}");
<PRINTLN>("</style>");
<PRINTLN>("</head>");
<PRINTLN>("<BODY >");
<PRINTLN>("<form>");
// This @nbsp represent the spce and it is used to print space in the browser eg) Firefox or google
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("</body>");
<PRINTLN>("</html>");
<OJ7UTIL>.ArrayList arm1 = new <OJ7UTIL>.ArrayList();
//Add the fields in arraylist arm1
arm1.add("uname");
arm1.add("pwd");
arm1.add("!");
// Use Request.Query to get the data from the login form; here 2 in the given below statements indicates 2 fields of the login form
ArrayList armg= Request.Query(arm1,"index4.dsn",2,1);
String g = WDBASQL.WDBASQLS("datastores", "USEDATABASE", "dbpwds", "c:\\Programs\\WNOSQL\\WNOSQLProgramfiles\\WNOSQdb");
String t = WDBASQL.WDBASQLS("dbuser", "dbpwds", 1, "wilmix78", "wilmix78", 1, 5, g);
String t1="";
// get the username from the arraylist armg
t1=armg.get(0).ToString();
String t2="";
// get the password from the arraylist armg
t2=armg.get(1).ToString();
<TRY>
{
// The given below SelectIN Query will check the username we have
//given from the login form matches the username data in the wnosql table EMP1 or not.
String qh2="SelectIN from EMP1 0 to 6 , 1 to 7 ?= "+t1+" By 1 1 : {0} : {0} :{0}";
wdbaconn.WDBAQUERY(qh2);
// Execute the Query and store the value in ArrayList ar.
<OJ7UTIL>.ArrayList ar=WDBALIB.WDBAQUERY(qh2, t);
<PRINTLN>("jm="+ar);
// The given below SelectIN Query will check the Password we have
//given from the login form matches the password data in the wnosql table EMP1 or not.
String qh21="SelectIN from EMP1 0 to 6 , 1 to 7 ?= "+t2+" By 1 1 : {0} : {0} :{0}";
wdbaconn.WDBAQUERY(qh2);
<OJ7UTIL>.ArrayList ar1=WDBALIB.WDBAQUERY(qh21, t);
//If both username or password is right then print the message 'user login succesfully'.
if ((ar.get(0).ToString()==t1) && (ar1.get(0).ToString()==t2))
<PRINTLN>("user login succesfully");
else
//If both username or password is wrong or any of the credentials (username or password) is wrong
// then print the message 'user not login succesfully'.
<PRINTLN>("user not login succesfully");
<PRINTLN>(" </table>");
<PRINTLN>("<input type=submit name=Click>");
<PRINTLN>(" </form>");
<PRINTLN>(" </html>");
}
<CATCH>(<EXE> e)
{
// If there is runtime error it should print the message 'user not login succesfully'.
<PRINTLN>("user not login succesfully");
}
}
}
}
Input
=====
Oakjava7 professionals should design the login form and the fields present in the form
should be uname,pwd. use .web type oakjava7 with Html.displayhtml to print the contents of
html login page eg) login.html
HTML.displayhtml("login.html");
So this login.html should have post method and action="/loginuser.web".
After you have designed it then provide username and password data from the browser.
Output
If username and password matches with wnosql EMP1 table credentials then it will print
"user login succesfully" in the browser.
If username and password did not matches with wnosql EMP1 table credentials then it will print
"user not login succesfully" in the browser.
Note: Here you must Request.dll,wdbaconn.dll,WDBASQL.dll,WDBALIB.WNOSQL.dll in the Oakjava7 Properties file ie) properties.txt
======================================================================================
Sample: 67 : Sample 3 : Write the OakJava7 Program to convert array elements to upper case and
lowercase using Var and print it.
======================================================================================
Q) Write the OakJava7 Program to convert array elements to upper case and lowercase using Var and print it.
convertformat.web
==================
<WEB>
<PACK> j7Prsample2
{
<CLASS> vartype
{
public void main()
{
string[] words = { "aPPLE", "BlUeBeRrY", "cHeRry" };
// If a query produces a sequence of anonymous types,
// then use var in the foreach statement to access the properties.
var upperLowerWords = "";
for (int i=0;i<words.Length;i++)
words[i] = words[i].ToUpper();//Convert the data from words array to uppercase
//The values present in words array is mapped to var ul. This var keyword is used for loosely coupled variable.
foreach (var ul in words)
{
<PRINTLN>("Uppercase: {0}",ul);
}
for (int i=0;i<words.Length;i++)
words[i] = words[i].ToLower();
//The values present in words array is mapped to var ul1.
foreach (var ul1 in words)
{
<PRINTLN>("Lowercase: {0}", ul1);//Convert the data from words array to lowercase.
}
}
}
}
Output
Uppercase: APPLE
Uppercase: BLUEBERRY
Uppercase: CHERRY
Lowercase: apple
Lowercase: blueberry
Lowercase: cherry
==============================================================================================================
Sample: 68 : Sample 4 : OakJava7 Networking using client and server concepts
==============================================================================================================
Q) Write a short oakjava7 program for creating a Client and Server and let the client send messages to Server..And the server will receive the messages and print it.
Oakjava7 Client program
j7client.web
<WEB>
<USE> j7network;// use oakjava7 network package j7network
<PACK> sample31
{
public <CLASS> j7client
{
public void main()
{
<PRINTLN>("OakJava7 Networks");
Stream()->
LOGIC(L->{
// pass port 6677 and message and the localhost / ipaddress
Oj7Network.J7Client(6677,"tomorrow meeting starts at 5:AM","localhost");
})->
}
}
}
Output
After that type j7client in the command prompt
C:\terminal1>j7client
OakJava7 Networks
We can see the message "tomorrow meeting starts at 5:AM" send by j7client is
received by j7Server and the j7Server will print that message.
OakJava7 Server Program
j7server.web
<WEB>
<USE> j7network; // Use oakjava7 network package j7network
<PACK> sample31
{
public <CLASS> j7server
{
public void main()
{
<PRINTLN>("OakJava7 Networks");
Stream()->
LOGIC(L->{
//Pass port 6677 only to J7Socket.
Oj7Network.J7Socket(6677);
})->
}
}
}
Outputs
O/P=> Start the Server by using j7server and after that use j7server in the command prompt
Final Output
C:\terminal1>j7server
OakJava7 Networks
J7Message= tomorrow meeting starts at 5:AM
Note: Here we notice that the message sent by oakjava7client is received by Oakjava7Server
and finally it print the message.
==============================================================================================================
Sample: 69 : Sample 5 : OakJava7 Encrypt and Decrypting the given text
==============================================================================================================
Q) Write the OakJava7 Program to Encrypt and Decrypting the text.
EncryptDecrypt.web
<WEB>
<PACK> j7security1
{
<CLASS> Prog
{
public void main()
{
//Pass the text to oakjava7 encrypt function
string sop=j7security.Ojava7Process.j7Encrypt("wilmix is going1 , cat is going , dog is chasing cat");
//Print the encrypted format
<PRINTLN>("Encrypt="+sop);
//Pass the text to oakjava7 encrypt function
string sop1=j7security.Ojava7Process.j7Encrypt("wilmix is going , cat is going , dog is chasing cat");
//Print the encrypted format
<PRINTLN>("Encrypt="+sop1);
// Decrypting the text call the oakjava7 function j7security.Ojava7Process.Decrypt()
<PRINTLN>("Decrypt="+j7security.Ojava7Process.Decrypt());
}
}
}
Output
F:\wilmix>j7security
?\??S??b!B"??.H??o??q?be\N?&?F???=??,??g�??ix????&V?~?B??s???????
E?�??&?[n6BF?6??3z?????E??Kx????e?1
P???sKi??+?Ys???s?Pz_??W?t?1??g??\?%t???Q??B???\??.{h i%??~?
R9O???|v???A??(N?N?(>??
????%<7???_?.}???
e????KD?&??|@?R??\E?}?[p?D??k?/?p?}4??B?p?n??!?E??????x???o?3R?6?g?9y?}?[?i??"Q#2R?<2D e??$St{??=?x??0??7?d?? ??,b??X?
?S??????1u???XI??.?
Decrypt=wilmix is going , cat is going , dog is chasing cat
Note: Use Ojava7Process.dll file in the OakJava7 (properties.txt) for encrypt and Decrypting the text.
==============================================================================================================
Sample: 70 : Sample 6 : OakJava7 Exercises for the OakJava7 professionals
=============================================================================================================
Q) OakJava7 Exercises for the OakJava7 professionals
Assignment A
Problem -A
Assignment -1 :Console based application
Write the OakJava7 Program to prepare the Marklist for all the students in Class A,Class B,Class C use correct collections
in OakJava7 to achieve it. So the result should be powerful insertion and search mechanism....
Calculate the Total marks scored , Percentage , and Rank for each students.
The Fields should be Stud id,Studname,Subject ,Marks Total, Percentage,rank.Finally print
the result in OakJava7 console.
Problem -B
Assignment -2: Webapplication
Create a Login and Registeration page for the training online institute.
Use only .web (OakJava7) program. And the output should print
all the details of the students attending course like OakJava7,java,Python ,etc.
as well as each course details and duration and print them in a web page
not in console format.(when oakJava7 is released all oakjava7 professionals may practice it).
==========================================================================
Sample 71: OakJava7 Webapplication Samples: Sample 1 : OakJava7 Program to retrieve the json values from example231.WS (web1.0 Webservice file).
==========================================================================
Q) Write a oakjava7 program to retrieve the json values from example231.WS (web1.0 Webservice file).
jsondisplay.web
<WEB>
//use java7displayurl package for retrieving the web1.0 webservice contents
<USE> java7displayurl;
<PACK> Program121
{
<CLASS> Prog
{
public void main()
{
String s="";
// using .Web1.0 programming language create example231.WS file for the given json value
//and remove <HTML> tags and retrieve the json values by using java7UrlConnectionReader.getUrlContents function
// and Store it in a String "s" variable
s= java7UrlConnectionReader.getUrlContents("http://localhost:8082/example231.WS").Replace("<HTML>","").Replace("</html>","");
// Print the s value ie) Json contents
<PRINTLN>(""+s);
}
}
}
Output in webpage
[{"Name":"wilmix","Category":1,"Id":11111},{"Name":"wilmix2","Category":2,"Id":11112},{"Name":"wilmix3","Category":3,"Id":11113},{"Name":"wilmix4","Category":4,"Id":11114},{"Name":"wilmix5","Category":5,"Id":11115}]
==========================================================================
Sample 72: OakJava7 Webapplication Samples: Sample 2 : OakJava7 Program to a) Create Employeen2 bean class with set and get methods for id,name,salary b) Sorted Employee List by Names
c) Sorted Employee List by salary d) Sorted Employee List by descending order
==========================================================================
Q) Write the OakJava7 Program to a) Create Employeen2 bean
class with set and get methods for id,name,salary b) Sorted Employee List by Names
c) Sorted Employee List by salary d) Sorted Employee List by descending order
SortingProgrambyASCDESC.web
<WEB>
<PACK> exceptionexample
{
// Create Employeen2 bean class with set and get methods for id,name,salary
// Here you must use only Compare method with IComparer to compare the two objects
// for sorting purpose ...
public <CLASS> Employeen2
{
public int id {get;set;}
public string name{get;set;}
public double salary{get;set;}
}
//Sorted Employee List by Names
public <CLASS> SortByName : IComparer<Employeen2>
{
public int Compare(Employeen2 e1, Employeen2 e2)
{
return e1.name.CompareTo(e2.name);
}
}
//Sorted Employee List by Salary
public <CLASS> SortBySalary : IComparer<Employeen2>
{
public int Compare(Employeen2 e1, Employeen2 e2)
{
return e1.salary.CompareTo(e2.salary);
}
}
//Sorted Employee List by descending order
public <CLASS> SortBySalaryDESC : IComparer<Employeen2>
{
public int Compare(Employeen2 e1, Employeen2 e2)
{
return e2.salary.CompareTo(e1.salary);
}
}
public <CLASS> SortingProgram
{
public void main()
{
SortByName sbn <NEW> SortByName();
SortBySalary sbs <NEW> SortBySalary();
SortBySalaryDESC sbsdesc <NEW> SortBySalaryDESC();
List<Employeen2> emps <NEW> List<Employeen2>();
emps.Add(new Employeen2()
{id = 123, name = "Rajesh", salary = 50000.00});
emps.Add(new Employeen2()
{id = 897, name = "Jackson", salary = 50000.50});
emps.Add(new Employeen2()
{id = 342, name = "Brito", salary = 40030.89});
emps.Add(new Employeen2()
{id = 219, name = "Daniel", salary = 86633.66});
emps.Add(new Employeen2()
{id = 642, name = "Golden", salary = 30505.05});
emps.Add(new Employeen2()
{id = 923, name = "preeti", salary = 106543.21});
emps.Sort(sbn);
<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");
<PRINTLN>("<BR>---------------------------</br>");
<PRINTLN>("Sorted Employee List by Names:\n");
DisplayList(emps);
<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");
emps.Sort(sbs);
<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");
<PRINTLN>("<BR>---------------------------</br>");
<PRINTLN>("\n\nSorted Employee List by Salaries:\n");
DisplayList(emps);
<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");
<PRINTLN>("<BR>---------------------------</br>");
emps.Sort(sbsdesc);
<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");
<PRINTLN>("<BR>---------------------------</br>");
<PRINTLN>("\n\nSorted Employee List by Salaries in Descending order:\n");
DisplayList(emps);
<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");<PRINTLN>("<BR>");
<PRINTLN>("<BR>---------------------------</br>");
}
static void DisplayList(List<Employeen2> emp)
{
foreach (Employeen2 e in emp)
{
<PRINTLN>("Id: " + e.id + ", Name: " + e.name + ", Salary: " + e.salary);
}
}
}
}
Output in webpage
---------------------------
Sorted Employee List by Names:Id: 342, Name: Brito, Salary: 40030.89Id: 219, Name: Daniel, Salary: 86633.66Id: 642, Name: Golden, Salary: 30505.05Id: 897, Name: Jackson, Salary: 50000.5Id: 923, Name: preeti, Salary: 106543.21Id: 123, Name: Rajesh, Salary: 50000
---------------------------
Sorted Employee List by Salaries:Id: 642, Name: Golden, Salary: 30505.05Id: 342, Name: Brito, Salary: 40030.89Id: 123, Name: Rajesh, Salary: 50000Id: 897, Name: Jackson, Salary: 50000.5Id: 219, Name: Daniel, Salary: 86633.66Id: 923, Name: preeti, Salary: 106543.21
---------------------------
---------------------------
Sorted Employee List by Salaries in Descending order:Id: 923, Name: preeti, Salary: 106543.21Id: 219, Name: Daniel, Salary: 86633.66Id: 897, Name: Jackson, Salary: 50000.5Id: 123, Name: Rajesh, Salary: 50000Id: 342, Name: Brito, Salary: 40030.89Id: 642, Name: Golden, Salary: 30505.05
---------------------------
=========================================================================
Sample 73: OakJava7 Webapplication Samples: Sample 3 : OakJava7 Program to Display the car names when users (Business People and IT guys in US) choose the drop down contains list like Nissan,Hundai,Ford Mustang.Use Angular only for Frontend technology.
==========================================================================
Q) Write the OakJava7 Program to Display the car names when users (Business People and IT guys in US) choose the drop down contains list like Nissan,Hundai,Ford Mustang. Use angular only for frontend technology.
jsonarrays.web
<WEB>
<PACK> exceptionexample
{
<CLASS> Program
{
public void main()
{
<TRY>
{
HTML.displayhtml("angularexample.html");
}
<CATCH> (Exception e)
{
<PRINTLN>("Error.... "+e);
}
<Finally>
{
<PRINTLN>("The Finally block is executed...");
for(int i=0;i<10;i++)
{
<PRINTLN>("i="+i);
<PRINTLN>("");
}
}
}
}
}
angularexample.html
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p>Select a car:</p>
<select ng-model="selectedCar">
<option ng-repeat="x in cars" value="{{x.model}}">{{x.model}}</option>
</select>
<h1>You selected: {{selectedCar}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.cars = [
{model : "Ford Mustang", color : "red"},
{model : "Nissan", color : "violet"},
{model : "Hundai", color : "lightred"}
];
});
</script>
<p>Cars Choosen</p>
<p>The costly and best cars for Business People and IT guys in US</p>
</body>
</html>
Output in webpage
Select a car
(Note: Select Nissan from the drop down contains values as Nissan,angular will display the values on the
same page.)
You Selected: Nissan
Cars choosen
The costly and best cars for Business people and IT guys in U.S
The Finally block is executed...i=0i=1i=2i=3i=4i=5i=6i=7i=8i=9
======================================================================
Sample 74: OakJava7 Webapplication Samples:Mini Project1:
Invoice Bill With Angular UI using WNOSQL DB
=======================================================================
Write the Oakjava7 Program using securable database WNOSQL to Store
the data for Invoice Bill.Use Angular with html as Frontend Technology for
Invoice bill. Use Invoice bill form to get the data and
Generate the Invoice Bill and Invoice Bill forms at same
webpage. ie) Create a Single Page application for the Invoice bill :-
Use only oakjava7 .jclass file,Don't use .exe or .scroll ,etc.
Program-1
Invoicebill.html
<!DOCTYPE html>
<html>
<head>
<title> Invoice Bill Entry </title>
</head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<div ng-app="">
<body>
<form action="http://localhost:9000/InvoiceBill.jclass" method="post" >
<table align="center" border="3" width=500 height=500 bgcolor=lightgreen >
<tr> <h2><td><a href="#chapter1"><center> Enter your Invoice Bill Customer Details </center> </a></td></h2></tr>
<tr>
<td><p>Enter the Customer Address : <input type="text" name="CADDRESS" ng-model="caddress" size="25" /></td></p></tr>
<td><p>Enter the Invoice number : <input type="number" name="invoiceno" ng-model="invoiceno" size="25" /></td></p></tr>
<td><p>Enter the Invoice Date : <input type="text" name="invoicedate" ng-model="invoicedate" size="20" /></td></p></tr>
<td><p>Enter the Reverse Charge : <input type="text" name="reversecharge" ng-model="reversecharge" size="2" /></td></p></tr>
<td><p>Enter the State: <input type="text" name="state" ng-model="state" size="20" /></td></p></tr>
<td><p>Enter the Code : <input type="text" name="code" ng-model="code" size="10" /></td></p></tr>
<td><p>Enter the Name : <input type="text" name="name" ng-model="name" size="25" /></td></p></tr>
<td><p>Enter Your Address : <input type="text" name="BADDRESS" ng-model="BADDRESS" size="25" /></td></p></tr>
<td><p>Enter the GSTIN : <input type="text" name="gstin" ng-model="gstin" size="20" /></td></p></tr>
<td><p>Enter the State: <input type="text" name="state1" ng-model="state1" size="20" /></td></p></tr>
<td><p>Enter the Code : <input type="text" name="code1" ng-model="code1" size="15" /></td></p></tr>
<td><p>Enter the Sno : <input type="text" name="sno" ng-model="sno" size="20" /></td></p></tr>
<td><p>Enter Your Product Description : <input type="text" name="productdescription" ng-model="productdescription" size="200" /></td></p></tr>
<td><p>Enter Your HSNCODE : <input type="number" name="hsncode" ng-model="hsncode" size="25" /></td></p></tr>
<td><p>Enter Your Quanity : <input type="number" name="qty" ng-model="qty" size="25" /></td></p></tr>
<td><p>Enter Your Rate : <input type="number" name="rate" ng-model="rate" size="25" /></td></p></tr>
<td><p>Enter Your Discount : <input type="number" name="discount" ng-model="discount" size="25" /></td></p></tr>
<td><p>Enter Your Rate1 : <input type="number" name="rate1" ng-model="rate1" size="25" /></td></p></tr>
<td><p>Enter Your Rate2 : <input type="number" name="rate2" ng-model="rate2" size="25" /></td></p></tr>
<td><p>Enter Your Amount in words : <input type="text" name="Amountinwords" ng-model="Amountinwords" size="35" /></td></p></tr>
<td><p>Enter Your BankName : <input type="text" name="bname" ng-model="bname" size="30" /></td></p></tr>
<td><p>Enter Your BankAccount : <input type="text" name="bankaccount" ng-model="bankaccount" size="25" /></td></p></tr>
<td><p>Enter Your BankIFSC code : <input type="text" name="bankifsc" ng-model="bankifsc" size="30" /></td></p></tr>
<TR> <td><h2><a href="#chapter2">REGISTER</a></h2></td></tr>
<div>
<TR> <td><input type="submit" name="ClickMe"></td>
<td><input type="reset" name="Clear"></td></tr>
</div>
</TABLE>
</form>
</body>
</html>
Program 2:
InvoiceBill.web
<WEB>
// use Oakjava7 util packages and Oakjava7 security packages
<USE> <OJ7UTIL>;
<USE> Security;
// Use Wnosql packages
<WNOSQL>
<PACK> Program8
{
<CLASS> Prog
{
public void main()
{
// Design Invoice Bill form
HTML.displayhtml("Invoicebill.html");
// Add what are the fields you want for preparing Invoice bill
ArrayList arm1= new ArrayList();
arm1.add("CADDRESS");
arm1.add("invoiceno");
arm1.add("invoicedate");
arm1.add("reversecharge");
arm1.add("state");
arm1.add("code");
arm1.add("name");
arm1.add("BADDRESS");
arm1.add("gstin");
arm1.add("state1");
arm1.add("code1");
arm1.add("sno");
arm1.add("productdescription");
arm1.add("hsncode");
arm1.add("qty");
arm1.add("rate");
arm1.add("discount");
arm1.add("rate1");
//arm1.add("amt1");
arm1.add("rate2");
//arm1.add("amt2");
arm1.add("Amountinwords");
arm1.add("bname");
arm1.add("bankaccount");
arm1.add("bankifsc");
arm1.add("NOT");
<PRINTLN>("<HTML>");
<PRINTLN>("<head> <style>");
<PRINTLN>("table {");
<PRINTLN>(" width:100%;");
<PRINTLN>("}");
<PRINTLN>("table, th, td {");
<PRINTLN>("border: 1px solid black;");
<PRINTLN>(" border-collapse: collapse;");
<PRINTLN>("}");
<PRINTLN>("th, td {");
<PRINTLN>(" padding: 5px;");
<PRINTLN>(" text-align: left;");
<PRINTLN>("}");
<PRINTLN>("table#t01 tr:nth-child(even) {");
<PRINTLN>(" background-color: grey;");
<PRINTLN>("}");
<PRINTLN>("table#t01 tr:nth-child(odd) {");
<PRINTLN>("background-color:yellow;");
<PRINTLN>("}");
<PRINTLN>("table#t01 th {");
<PRINTLN>(" background-color: black;");
<PRINTLN>("color: white;");
<PRINTLN>("}");
<PRINTLN>("</style>");
<PRINTLN>("</head>");
<PRINTLN>("<BODY >");
<PRINTLN>("<form>");
// mention 23 fields in Request.Query method
ArrayList armg= Request.Query(arm1,"InvoiceBilloj7.dsn",23,1);
//Design a html page for submiting all the 23 fields data ...
string CADDRESS=armg.get(0).ToString();
string invoiceno=armg.get(1).ToString();
string invoicedate=armg.get(2).ToString();
string reversecharge=armg.get(3).ToString();
string state=armg.get(4).ToString();
string code=armg.get(5).ToString();
string name=armg.get(6).ToString();
string BADDRESS=armg.get(7).ToString();
string gstin=armg.get(8).ToString();
string state1=armg.get(9).ToString();
string code1=armg.get(10).ToString();
string sno=armg.get(11).ToString();
string productdescription=armg.get(12).ToString();
string hsncode=armg.get(13).ToString();
string qty=armg.get(14).ToString();
string rate=armg.get(15).ToString();
//string amt=armg.get(16).ToString();
string discount=armg.get(16).ToString();
string rate1=armg.get(17).ToString();
//string amt1=armg.get(19).ToString();
string rate2=armg.get(18).ToString();
//string amt2=armg.get(21).ToString();
string Amountinwords=armg.get(19).ToString();
string bname=armg.get(20).ToString();
string bankaccount=armg.get(21).ToString();
string bankifsc=armg.get(22).ToString();
// Use OakJava7 Servlet to print the form in webpage
<PRINTLN>("<table id=t01 width=1027 height=210 border=1 bgcolor=#fff >");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td height=135><div align=center><strong><address> ");
<PRINTLN>(""+CADDRESS);
<PRINTLN>("</address></strong></div></p> <p align=right><strong>Triplicate for</strong></p>");
<PRINTLN>(" <p align=right><strong>Supplier</strong></p></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("<tr> ");
<PRINTLN>(" <td><div align=center><span <CLASS>=style12>Tax Invoice</span></div></td>");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>(" <td width=506><strong>Invoice No: </strong>"+invoiceno+"</td> ");
<PRINTLN>("<td width=503></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>("<td><strong>Invoice date: </strong>"+invoicedate+"</td> ");
<PRINTLN>("<td> </td> ");
<PRINTLN>("</tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td width=436><strong>Reverse Charge(Y/N):</strong>"+reversecharge+"</td> ");
<PRINTLN>(" <td width=63> </td> ");
<PRINTLN>(" <td width=505> </td> ");
<PRINTLN>("</tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td width=337><strong>State:</strong>"+ state+"</td> ");
<PRINTLN>("<td width=94><strong>Code </strong></td> ");
<PRINTLN>(" <td width=63> "+code+"</td> ");
<PRINTLN>(" <td width=504> </td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff>");
<PRINTLN>("<tr> ");
<PRINTLN>("<td width=506><div align=center <CLASS>=style13>Bill to Party </div></td> ");
<PRINTLN>(" <td width=503><div align=center><span <CLASS>=style13>Ship to party </span></div></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td width=506><strong>Name:</strong>"+name+"</td> ");
<PRINTLN>(" <td width=505><strong>Name:</strong>"+name+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td><strong>Address:</strong>"+ BADDRESS+"</td> ");
<PRINTLN>(" <td><strong>Address:</strong>"+ BADDRESS+"</td> ");
<PRINTLN>("</tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td><strong>GSTIN:</strong>"+gstin+"</td> ");
<PRINTLN>(" <td><strong>GSTIN:</strong>"+gstin+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>(" <td width=340><strong>State:</strong>"+state1+"</td> ");
<PRINTLN>(" <td width=98><strong>Code:</strong></td> ");
<PRINTLN>(" <td width=54> "+code1+"</td> ");
<PRINTLN>(" <td width=380><strong>State:</strong>"+state1+"</td> ");
<PRINTLN>(" <td width=76><strong>Code:</strong></td> ");
<PRINTLN>(" <td width=39> "+code1+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>(" <td width=24 height=68><span <CLASS>=style8>S.NO</span></td> ");
<PRINTLN>(" <td width=130> <div align=center <CLASS>=style7>Product Description </div></td> ");
<PRINTLN>(" <td width=41><p <CLASS>=style6>HSNCode</p> </td> ");
<PRINTLN>(" <td width=49><div align=center <CLASS>=style6>Qty</div></td> ");
<PRINTLN>("<td width=73><div align=center <CLASS>=style6>Rate</div></td> ");
<PRINTLN>(" <td width=97><div align=center <CLASS>=style6>Amt</div></td> ");
<PRINTLN>(" <td width=54><div align=center><span <CLASS>=style1><strong>Discount</strong></span></div></td> ");
<PRINTLN>(" <td width=75><span <CLASS>=style6>TaxableValue</span></td> ");
<PRINTLN>(" <td width=134><table id=t01 width=210 border=1> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td width=200><div align=center <CLASS>=style4>CGST</div></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td><table id=t01 width=200 border=1 bgcolor=#fff> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td><div align=center <CLASS>=style7>Rate</div></td> ");
<PRINTLN>(" <td><span <CLASS>=style7>Amt</span></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" </table></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" </table></td> ");
<PRINTLN>("<td width=160><table id=t01 width=200 border=1> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td><div align=center <CLASS>=style4>SGST</div></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>("<td><table id=t01 width=200 border=1 bgcolor=#fff> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td><div align=center <CLASS>=style6>Rate</div></td> ");
<PRINTLN>(" <td><span <CLASS>=style6>Amt</span></td> ");
<PRINTLN>("</tr> ");
<PRINTLN>(" </table></td> ");
<PRINTLN>("</tr> ");
<PRINTLN>(" </table></td> ");
<PRINTLN>(" <td width=110><div align=center <CLASS>=style4>TOTAL</div></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td align=right width=24><p> "+sno+"</p> ");
<PRINTLN>("<td align=right width=93> "+productdescription+"</td> ");
<PRINTLN>(" <td align=right width=54 > "+hsncode+"</td> ");
<PRINTLN>(" <td align=right width=38 > "+qty+"</td> ");
<PRINTLN>(" <td align=right width=50 > "+rate+"</td> ");
//double tax2 = 0.0;
//double totalamount = 0.0;
//Write the business logic for InvoiceBill
double amount =(Convert.ToDouble(qty)) * (Convert.ToDouble(rate));
double amount1= ((Convert.ToDouble(rate1)/100) * Convert.ToDouble(amount));
double amount2= ((Convert.ToDouble(rate2)/100) * Convert.ToDouble(amount));
<PRINTLN>(" <td align=right width=65 > "+amount+"</td> ");
<PRINTLN>(" <td align=right width=49 > "+discount+"</td> ");
<PRINTLN>(" <td align=right width=74 > "+amount+"</td> ");
<PRINTLN>("<td align=right width=85> "+rate1+"</td> ");
<PRINTLN>("<td align=right width=99> "+amount1+"</td> ");
<PRINTLN>(" <td align=right width=85 > "+rate2+"</td> ");
<PRINTLN>(" <td align=right width=85> "+amount2+"</td> ");
//Business logic
double totalamount= amount+amount1+amount2;
<PRINTLN>(" <td align=right width=85> "+totalamount+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 height=65 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>("<td width=134><div align=center <CLASS>=style9><strong>TOTAL</strong></div></td> ");
<PRINTLN>(" <td width=47> </td> ");
<PRINTLN>(" <td width=37>"+qty+"</td> ");
<PRINTLN>(" <td width=51> </td> ");
<PRINTLN>(" <td width=74><div align=center>"+amount+"</div></td> ");
<PRINTLN>("<td width=65><div align=right>"+discount+"</div></td> ");
<PRINTLN>(" <td width=43><div align=right>"+amount+"</div></td> ");
<PRINTLN>("<td width=103> </td> ");
<PRINTLN>("<td width=101><div align=right>"+amount1+"</div></td> ");
<PRINTLN>(" <td width=205><div align=right>"+amount2+"</div></td> ");
<PRINTLN>(" <td width=95><div align=right>"+totalamount+"</div></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>(" <td width=487><div align=center><strong>Total Invoice amount in words </strong></div></td> ");
<PRINTLN>("<td width=88 <CLASS>=style15><span <CLASS>=style21>Total Amount Before Tax: </span></td> ");
<PRINTLN>(" <td <CLASS>=style15> "+amount+"</td> ");
<PRINTLN>("</tr> ");
<PRINTLN>(" <tr> ");
// note Amountinwords default is NIL
<PRINTLN>("<td><div align=center><input type=text name=Amountinwords value =NIL > </div></td> ");
<PRINTLN>("<td><table id=t01 width=544 border=1 bgcolor=#fff> ");
<PRINTLN>("<tr> ");
<PRINTLN>(" <td width=420 <CLASS>=style15><strong>Add: CGST </strong></td> ");
<PRINTLN>(" <td width=88 <CLASS>=style15> "+amount1+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>("<td <CLASS>=style15><strong>Add:SGST</strong></td> ");
<PRINTLN>(" <td <CLASS>=style15> "+amount2+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td <CLASS>=style15><strong>Total Tax Amount: </strong></td> ");
<PRINTLN>(" <td <CLASS>=style15> "+(amount1+amount2)+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td <CLASS>=style15><strong>Total Amount After Tax: </strong></td> ");
<PRINTLN>(" <td <CLASS>=style15> "+totalamount+"</td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>(" <tr> ");
<PRINTLN>(" <td width=196><strong>GST on Reverse Charge </strong></td> ");
<PRINTLN>(" <td width=254> "+reversecharge+"</td>");
<PRINTLN>(" </tr> ");
<PRINTLN>(" </table></td> ");
<PRINTLN>(" </tr> ");
<PRINTLN>("</table> ");
<PRINTLN>("<table id=t01 width=1027 border=1 bgcolor=#fff> ");
<PRINTLN>("<table width=1027 border=1 bgcolor=#fff>");
<PRINTLN>("<tr>");
<PRINTLN>("<td width=294 height=203><table width=296 height=216 border=1 bgcolor=#fff>");
<PRINTLN>("<tr>");
<PRINTLN>(" <td width=238><div align=center><strong>Bank Details </strong></div></td>");
<PRINTLN>(" </tr>");
<PRINTLN>(" <tr>");
<PRINTLN>(" <td><strong>Name:</strong>"+bname+"</td>");
<PRINTLN>("</tr>");
<PRINTLN>("<tr>");
<PRINTLN>("<td><strong>Bank A/C: </strong>"+bankaccount+"</td>");
<PRINTLN>("</tr>");
<PRINTLN>("<tr>");
<PRINTLN>(" <td><strong>Bank IFSC: </strong>"+bankifsc+"</td>");
<PRINTLN>("</tr>");
<PRINTLN>("<tr>");
<PRINTLN>(" <td height=61> </td>");
<PRINTLN>("</tr>");
<PRINTLN>("</table></td>");
<PRINTLN>("<td width=163><table width=200 height=231 border=1 bgcolor=#fff>");
<PRINTLN>("<tr>");
<PRINTLN>(" <td height=121> </td>");
<PRINTLN>("</tr>");
<PRINTLN>("<tr>");
<PRINTLN>("<td height=102><div align=center class=style22>Common Seal </div></td>");
<PRINTLN>(" </tr>");
<PRINTLN>("</table></td>");
<PRINTLN>("<td width=551><table width=514 height=224 border=1 bgcolor=#fff>");
<PRINTLN>("<tr>");
<PRINTLN>(" <td><div align=center><em>Certified that the particulars given above are true and correct </em></div></td>");
<PRINTLN>("</tr>");
<PRINTLN>("<tr>");
<PRINTLN>("<td><div align=center><strong>For XXXXX (p) Ltd </strong></div>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p align=center class=style13>Authorised signatory </p></td>");
<PRINTLN>("</tr>");
<PRINTLN>("</table></td>");
<PRINTLN>("</tr>");
<PRINTLN>("</table>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("<p> </p>");
<PRINTLN>("</body>");
<PRINTLN>("</html>");
//Mention the path where Invoice bill details are stored ....
String g = WDBASQL.WDBASQLS("datastores", "USEDATABASE", "dbpwds", "C:\\Programs\\WNOSQL\\WNOSQLProgramfiles\\WNOSQL-cod");
//Give Proper credentials like username ,password ,table...
String t = WDBASQL.WDBASQLS("dbuser", "dbpwds", 1, "wilmix78", "wilmix78", 1, 5, g);
//Divide the InvoiceBill table in to 2 tables ie) Invoicebill and other one is Invoicebill2
//Mentions the fields like CADDRESS ,etc to be created
String q = "CREATETABLE from Invoicebill 0 to 0 , 1 to 5 ?= 6639 By 6639 f(x) : {CADDRESS,INO,IDATE,Charge,State,code1,Name,Address,GSTIN,State,code2,sno,productdesc,hsncode,qty}: {} :{2,4}";
//Mentions the fields like rate ,etc to be created
String q1 ="CREATETABLE from Invoicebill2 0 to 0 , 1 to 5 ?= 6639 By 6639 f(x) : {rate,Amt,discount,Rate1,Amt1,Rate2,Amt2,total,ReverseCharge,Bankname,BankAccount,BankIFSC}: {} :{2,4}";
//Excecute the InvoiceTable querys
wdbaconn.WDBAQUERY(q);
wdbaconn.WDBAQUERY(q1);
Char c= ' ';
// Calculate the size of the InvoiceBill tables using Wnosql PLSQL methods
ArrayList datas1=WDBASQL.Query("TABLESIZE()","Invoicebill","0",null,27,"","", null,"",0,"","",c,null,t,1,5);
ArrayList datas11=WDBASQL.Query("TABLESIZE()","Invoicebill2","0",null,27,"","", null,"",0,"","",c,null,t,1,5);
// Make all data as string t1, and String t2 for two invoice bill tables respectively.
String t1="";String t2="";
t1=CADDRESS+","+invoiceno+","+invoicedate+","+reversecharge+","+state+","+code+","+name+","+BADDRESS+","+gstin+","+state1+","+code1+","+sno+","+productdescription+","+hsncode+","+qty;
t2=rate+","+amount+","+discount+","+rate1+","+amount1+","+rate2+","+amount2+","+totalamount+","+reversecharge+","+bname+","+bankaccount+","+bankifsc;
// Insert all the t1 data into Invoicebill table
String s12 ="INSERTINTO from Invoicebill 0 to "+datas1.size()+" , 1 to 5 ?= A By 1 1 : {0} : {"+t1+"} : {0}";
//Excecute the InvoiceTable insert query
wdbaconn.WDBAQUERY(s12);
// Insert all the t1 data into Invoicebill table
String s121 ="INSERTINTO from Invoicebill2 0 to "+datas11.size()+" , 1 to 5 ?= A By 1 1 : {0} : {"+t2+"} : {0}";
//Excecute the InvoiceTable insert querys
wdbaconn.WDBAQUERY(s121);
}
}
}
Output in Webpage
This Oakjava7 program will display Invoice Form and
Invoice Bill in a single page . So it is called as Single webpage application in
OakJava7. Here .jclass is an obfuscated file with good security. The main advantage
Hackers can't use any decompiler like JAD, etc to steal the Oakjava7 source code . Thus it is Good for security side. And the .jclass provides good security like C/C++ programming language.
===========================
Note: We have problem in attaching the output image in this google site . So i will provide OakJava7 EBOOK pdf file mentioning all the OakJava7 programs, sample used in this Tutorial website...
==========================================================================
Sample: 75 : Sample 6 :Final OakJava7 Webapplication Exercises for the OakJava7 professionals Mini Project1 and Mini Project2.
==========================================================================
Q) OakJava7 WebApplication Exercises for the OakJava7 professionals (1 *100=100 Marks)
Assignment A
Problem -A ( 1* 40 = 40 Marks) (choose any one)
Assignment -1 :OakJava7 Single Web application
1) Design a Library miniproject using OakJava7 P.L with Angular with wnosql db.
OR
2) Design a electricity bill using OakJava7 P.L with Angular with wnosql db.
Problem -B ( 1* 60 = 60 Marks) (choose any one)
Assignment -2 :Streams with Banking or Insurance application
3) Design OakJava7 Web application using Oakjava7 Streams
and Design a Banking project providing credentials like
Username and password for Login page. And Design a registration page.
and List all the transactions in second page.
and the customer name should be mentioned in second page
and provide the facility to Logout from the web page.
and Provide credit and debit transcations.use only WNOSQLdb
with angular.
OR
4) Design OakJava7 Web application for insurance domain.
Design a vehicle Insurance project providing credentials like
Username and password for Login page. And Design a registration page.
and Develop the Premium Insurance bill , Insurance Reports,
Insurance Forms. Perform only insertion operations.
use only WNOSQLdb with angular.(Here choose only 4 modules
for Vehicle Insurance project).
==========================================================================
Sample 76: OakJava7 Exception Handling : Sample 1 : Type 1:
Oakjava7(.web or .java7) other Exception /Error
==========================================================================
A) Oakjava7(.web or .java7) other Exception /Error
i) When file.web or file.java7 is not found when you compile the program
using javac7 <filename>.web or javac7 <filename>.java7 at Java7Shell then
File not found exception will be displayed at Java7Shell or
at command prompt or at Visual studio code.
ii) If you store 1 million data in ArrayList /LArray/HashMap
result in OutOfMemmory Error.and if you compile and when you use
.exe from .web or .java7 file in scroll server, when you execute it
will show the result which is given below..
Fix "Aw, Snap!" page crashes and other page loading errors.
So solution to this issue is in that case is make a partition by using TreeSet or
use J7JVM2.0.exe which will provide extra memmory and it display 1 crore data in
console.
So in this case don't run this kind of programs in Java7Shell , run only at VisualStudio code command prompt other wise Java7Shell will hang and this will create program object in Taskbar and it will take 90% of your System memmory. So Don't run this kind of programs in Java7Shell.
iii) The same case if you use Heap7 Datastructure for vast storage management
this will display 1 crore data at a time.But to display millions of data
you have to change arraylist or declare like Heap7 dataobj = new Heap7("");
This will solve your problem.And using J7JVM2.0.exe with Heap7, TreeSet,ArrayList will provide extra memory and it will display 1 crore data in console. So in this case don't run this kind of programs in Java7Shell , run only at VisualStudio code command prompt
other wise Java7Shell will hang and this will create program object
in Taskbar and it will take 90% of your System memmory.So Don't
run this kind of programs in Java7Shell.
iv) Always see logs to determine the Error or exception.
This kind of error or exception is found at directory
C:\ojava7\Ojava7log.
v) If oakjava7 developer print 1 crore data in the single webpage
will not display "Fix "Aw, Snap!" page crashes and other page loading errors".
But if he print 2 crore data will result in the error which is
"Fix "Aw, Snap!" page crashes and other page loading errors".
So when you compile using J7JVM2.0 will generate a .jclass ie) oakjava7
final file. So run the .jclass file in google or any browser
it will display 1 crore data with in few seconds..
Thus Oakjava7 take care of Big data.
Note:
OakJava7 Type -2 and Oakjava7 Type -3 is a
big document , when i show in google site will make
google site very slow. That's why, i will provide the Document with screenshots
with Oakjava7 software ,when i release it.
==========================================================================
Sample 77: OakJava7 Samples : Sample 1 :
Q) Steps for running oakjava7(JAVA7.0) in Jshell instead of command prompt
==========================================================================
Q) Steps for running oakjava7(JAVA7.0) in Jshell instead of command prompt
i) Click the Jshell.bat file in your folder ; in my case
i store all the .web or .java7 file in wilmix directory.
or create .bat file containing Java7Shell.exe including c:/oakjava7/src directory.
go to your directory that is in my case i will goto c:/wilmix directory.
ii) After that go to Jshell and to compile the .web files
or Run and compile the .web files at same time using javap7 <filename>.
Oakjava7 also compile and run the .web files at same time and produces the .exe files.
Which can be used for scroll webpages(webapplications).Better you
compile .web files in Visualstudio command prompt if you print large
amount of data.
=====================================================================
Section A: Loosely Coupling in OakJava7
====================================================================
The Syntax for Loosely Coupling in OakJava7
$ <Object> :(data);
Note:
Here $ -> indicates loosely coupling for oakjava7 program.
How to get the value of loosely coupled variable ?
That can be achieved by using <Object>.Val().
Q) Write a OakJava7 Program for Loosely coupled variable
in Oakjava7 ?
Looselycoupled.java7
<JAVA>
//Load j7utils package for Oakjava7 Loosely coupling
<USE> j7utils;
<PACK> oakj7utilsp1
{
public <CLASS> Program1
{
public void main()
{
// Here $ is the symbol for loosely coupling, Here loosely couple variable contains 10 as the value.
$ iObj :(10);
//loosely couple variable contains String as the value.
$ iObj1 :("wilmix");
//Display the loosely coupled int value
<PRINTLN> (iObj.Val());
//Display the loosely coupled String value
<PRINTLN> (iObj1.Val());
//loosely couple variable contains String as the value.
$ sObj :("intelligentmans");
//Display the loosely coupled String value
<PRINTLN> (sObj.Val());
<PRINTLN> ("");
$.Display(iObj.Val());
// passing String value to display method of loosely coupled class.
$.Display(sObj.Val());
// passing double value to display method of loosely coupled class.
$.Display(231.0);
<PRINTLN> ("");
int[] a = { 100, 22, 58, 41, 6, 50 };
$ iObj7 :("wilmix");
int[] a33=iObj7.J7AutoBoxing (a);
String[] c = { "v", "g", "a", "c", "x", "d", "t" };
String[] s = { "Virat", "Rohit", "Abhinay", "Chandu","Sam", "Bharat", "Kalam" };
<PRINTLN>("Sorted Integer array = ");
// Sort the int array by using Loosely coupled class method OJ7Sort
$.OJ7Sort(a);
<PRINTLN>("");
<PRINTLN>("Sorted Character array = ");
// Sort the char array by using Loosely coupled class method J7Sort
$.J7Sort(c);
<PRINTLN>("");
// Sort the String array by using Loosely coupled class method J7Sort
<PRINTLN>("Sorted String array = ");
$.J7Sort(s);
<PRINTLN>("");
<PRINTLN>("");
}
}
}
Output
10
wilmix
intelligentmans
cli.System.Int32 = 10
java.lang.String = GeeksForGeeks
cli.System.Double = 231
Sorted Integer array =
6, 22, 41, 50, 58, 100,
Sorted Character array =
a, c, d, g, t, v, x,
Sorted String array =
Abhinay, Bharat, Chandu, Kalam, Rohit, Sam, Virat,
Note: Here You must use OakJava7Utils.dll files at the Oakjava7 Properties file
=====================================================================
Section B : Using OakJAVA7 List
====================================================================
Oakjava7 list will allow duplicate values and
it is ordered and changeable.
Programj7list.java7
<JAVA>
<USE> j7utils;
/* J7List collections util package */
<PACK> oakj7utilsp1
{
public <CLASS> Program1
{
public void main()
{
//wilmix code
<TRY>
{
//intialize the J7List collection class and pass initial value 15
j7utils.J7List listr <NEW> j7utils.J7List("15");
// Add C, ADollar,etc to J7List using listr instance with add method in J7List method.
listr.add(0,"C");
listr.add(1,"ADOLLAR");
listr.add(2,"JAVA");
listr.add(3,"OAKJAVA7");
listr.add(4,"JSAUCER");
listr.add(5,"GDOLLAR");
listr.add(6,"GDOLLAR1");
listr.add(7,"JDOLLAR");
listr.add(8,"JAVA1");
listr.add(9,"JSTAR");
listr.add(10,"JSAUCER");
listr.add(11,"Csharp");
listr.add(12,"Csharp1");
// Now remove JSTAR using removeItem method
listr.removeItem("JSTAR");
// replace JDOLLAR with datascience at 7th location of j7list
listr.SetLoc(7,"datascience");
// Now remove the data C in the J7list by using j7RemoveDuplicateItems method.
<OJ7UTIL>.LinkedList list1= j7utils.J7List.j7RemoveDuplicateItems("C");
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
//Print that list.
<PRINTLN>("list1= "+list1);
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("display forward items ");
// Display the forward items in forward direction
String sop1=j7utils.J7List.DisplayLoop(list1,7);
<PRINTLN>("Sop= "+sop1);<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("display backward items ");
//Display the backward items in backward direction here [-1*list1.size()] indicates //the last element in backward direction
String sop11=j7utils.J7List.DisplayLoop(list1,(-1*list1.size()));
<PRINTLN>("sop1="+sop11);<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>("Searching the data in List by String");
String[] sentence1={"apple", "banana", "cherry", "kiwi", "mango"};
String[] sentence2=sentence1;
//Search the item "kiwi" if it is found then print it using J7Search
j7utils.J7List.J7Search(sentence1,"kiwi");
//Search the item by character 'e' if it is found then print it using J7SearchChar method.
<PRINTLN>("Searching the data in List by character");
j7utils.J7List.J7SearchChar(sentence1,'e');
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
string text1="apple";
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
// this J7List function fxLucase convert lowercase to upper case when you pass sentence1 , sentence1.Length
// and "Upper" as the arguments in function fxLucase
sentence2=j7utils.J7List.fxLucase(sentence1,0,sentence1.Length,"Upper");
<PRINTLN>("Uppercase---");
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
for (int i=0;i<sentence2.Length;i++)
{
<PRINTLN>(" "+sentence2[i]);
}
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
String [] sentence3=sentence1;
// Replace all the words in the sentence3 by Hello using function ReplaceAllString
// and pass sentence3 and "Hello" as the argument
String [] sentence4=j7utils.J7List.ReplaceAllString(sentence3,"Hello");
for (int i=0;i<sentence4.Length;i++)
{
<PRINTLN>(" "+sentence4[i]);
}
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" Sentence6= ");
String [] sentence5={"apple", "banana", "cherry", "kiwi", "mango"};
//Replace only the word "banana" with "orange" using function ReplaceString
// and pass sentence5 , word to be replaced "banana" with "Orange" as the next argument
String [] sentence6=j7utils.J7List.ReplaceString(sentence5,"banana","Orange");
for (int i=0;i<sentence6.Length;i++)
{
<PRINTLN>(" "+sentence6[i]);
}
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<OJ7UTIL>.ArrayList nos <NEW> <OJ7UTIL>.ArrayList();
// add 100,50,65,82,23 in ArrayList nos
nos.add(100);
nos.add(50);
nos.add(65);
nos.add(82);nos.add(23);
// if elements in ArrayList greater than 50 is choosen option 2 for sort it in //descending order,or if you want the numbers to be sorted by ascending order //means use choice 1 use the SortList method containing parameters nos,50,2 as //the parameter.
<OJ7UTIL>.ArrayList lsort=j7utils.J7List.SortList (nos, 50,2);
<PRINTLN>(""+lsort);
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<OJ7UTIL>.List item=<OJ7UTIL>.Arrays.asList("a","B","C","A","i","c","D","e");
//This SortListUL function will sort or arrange the Capital characters in ascending order and Lowercase letters in ascending order
<OJ7UTIL>.List items=j7utils.J7List.SortListUL (item);
//print those sorted items
<PRINTLN>(""+items);
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
String[] datum1={"dell","Hp","sony","HCL"};
// Display all the string in datum1 to uppercase by passing string array datum1 and // "Upper" as a parameter using SortbyUL method.
<OJ7UTIL>.List citems=j7utils.J7List.SortbyUL(datum1,"Upper");
<PRINTLN>(""+citems);
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
String[] datum3={"apple", "banana", "cherry", "kiwi", "mango"};
//Arrange and display all the strings found in datum3 string array in reverse order //using ReverseList function present in J7List
<OJ7UTIL>.List lop44= j7utils.J7List.ReverseList(datum3);
<PRINTLN>(""+lop44);
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
}
<CATCH> (<EXE> e) {
<PRINTLN>("DuplicateException="+e);
}
//wilmixcode
}
}
}
Output:
list1= [ADOLLAR, JAVA, OAKJAVA7, JSAUCER, GDOLLAR, GDOLLAR1, datascience, JAVA1, JSAUCER, Csharp, Csharp1]
display forward items
Sop= JAVA1
display backward items
sop1=ADOLLAR
Searching the data in List by String
kiwi
Searching the data in List by character
[
apple,
cherry,
]
Uppercase---
APPLE
BANANA
CHERRY
KIWI
MANGO
Hello
Hello
Hello
Hello
Hello
Sentence6=
apple
Orange
cherry
kiwi
mango
[100, 50, 65, 82]
[A, B, C, D, a, c, e, i]
[DELL, HCL, HP, SONY]
[mango, kiwi, cherry, banana, apple]
=====================================================================
Section C : Using OakJAVA7 Dictionary
=====================================================================
What is Oakjava7 Dictionary?
OakJava7Dictionary is a collection which is ordered and changeable. duplicate key members are not allowed. Here Key should be integer or double datatype, values may be string or integer or double. For removing the key we can easily remove the data from Dictionary using Index. eg) Index may be 1 or 1.0 means the first element in the oakjava7 dictionary. Oakjava7 Dictionary has IsEmpty function to check whether the given Dictionary is empty or not.And oakjava7 contains Popitem function to remove the last element from the Dictionary.
Dictsample.java7
<JAVA>
//load j7utils package.
<USE> j7utils;
<OAKJAVA7SECURITY>
<PACK> oakj7utilsp61
{
public <CLASS> Program7
{
public void main()
{
//Always put the statements, business logic in <TRY> and <CATCH> block ....
<TRY>
{
// choose OakJava7 Dictionary and create a instance for that , and let that object name be list
j7utils.Oakj7Dictionary list <NEW> j7utils.Oakj7Dictionary ("0", "languages");
// Add ADOLLAR,GDOLLAR,JDOLLAR datas ,etc to the Dictionary list
list.add("1","ADOLLAR");
list.add("2","GDOLLAR");
list.add("3", "GDOLLAR");
list.add("4","JDOLLAR");
list.add("5","JAVA");
list.add("6","JSTAR");
list.add("7","JSAUCER");
list.add("8","Csharp");
list.add("8","Csharp");
// print space
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
// to compute size of dictionary list by using list.size()
<PRINTLN>("list size="+list.size());
for (int i=0;i<list.size();i++)
{
<PRINTLN>(" ");
// Filter 0's and print the keys and value pairs using J7Print
//with key and values of dictionary list to be passed to J7Print function arguments
J7Str.Filter.J7Print(list.getKey(i),list.getValue(i));
<PRINTLN>(" ");
<PRINTLN>(" ");
}
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>("Display all Keys in dictionary ");
for (int i=0;i<list.size();i++)
{
//list is the instance for Dictionary list and we can
// the value of key using list.getKey(i)
<PRINTLN>(" "+list.getKey(i));
}
// Removing item no 6 having key and value from dictionary list and assign/copy to another Oakjava7Dictionary list2
j7utils.Oakj7Dictionary list2=list.remove(list,6,1);
// print all the elements like keys and values from Dictionary list2
for (int i=0;i<list2.size();i++)
{
// Filter 0's and print the keys and value pairs using J7Print
//with key and values to be passed to J7Print function arguments
J7Str.Filter.J7Print(list2.getKey(i),list2.getValue(i));
}
//print 3 space lines using <PRINTLN>(" "); function.
<PRINTLN>(" ");
<PRINTLN>(" ");
<PRINTLN>(" ");
// Remove duplicate items in Dictionary list2 by using list2.Display(list2) function
<PRINTLN>("Remove Duplicates.... ");
list2=list2.Display(list2);
// Remove the last item in dictionary list3 by using list2.Popitem(list2,1) function
// here list2 represent the values stored in another dictionary.
// And 1 indicates the key must be integer datatype
<PRINTLN>("Remove the last element.... ");
Oakj7Dictionary list3=list2.Popitem(list2,1);
//Remove the 3rd element from Dictionary list3
list3=list3.remove(list3,3,1);
//list3=list3.remove(list3,4,1);
//Remove the 5th element from Dictionary list3
list3=list3.remove(list3,5,1);
// print all the elements like keys and values from Dictionary list3
for (int i=0;i<list3.size();i++)
{
// Filter 0's and print the keys and value pairs using J7Print
//with key and values to be passed to J7Print function arguments
J7Str.Filter.J7Print(list3.getKey(i),list3.getValue(i));
}
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("Remove all elements from Oakj7Dictionary-first ");
// Remove all elements from Oakj7Dictionary list3,
// now the list3 dictionary is Empty due to RemoveAll function
list3=list3.RemoveAll(list3,1);
// Now add 1,JAVA; 2,OAKJAVA7 to the empty Dictionary list3
list3.add("1","JAVA");
list3.add("2","OAKJAVA7");
<PRINTLN>("Key=value pairs = ");
// print all the elements like keys and values from Dictionary list3
for (int i=0;i<list3.size();i++)
{
// Filter 0's and print the keys and value pairs using J7Print
//with key and values to be passed to J7Print function arguments
J7Str.Filter.J7Print(list3.getKey(i),list3.getValue(i));
}
//Check if the Given Dictionary list3 is empty or not using IsEmpty function
<PRINTLN>("Is Empty first= "+list3.IsEmpty(list3,1));
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("==================================================== ");
<PRINTLN>(" Using Double as Key and string as value");
// Create a Dictionary name list33 and intialize key and values as 0,0 respectively.
j7utils.Oakj7Dictionary list33 <NEW> j7utils.Oakj7Dictionary ("0", "0");
// Add Double as Key and String as value to the Dictionary list33
list33.add("1.0","ADOLLAR");
list33.add("2.0","GDOLLAR");
list33.add("3.0", "GDOLLAR");
list33.add("4.0","JDOLLAR");
list33.add("5.0","JAVA");
list33.add("6.0","JSTAR");
list33.add("7.0","JSAUCER");
list33.add("8.0","Csharp");
list33.add("8.0","Csharp");
list33.add("9.0","C");
list33.add("10.0","C++");
//remove the key= 7.0 and it's value from dictionary list33
list33=list33.remove(list33,"7.0",2);
// here list33 represent the values stored in another dictionary.
// And 2 indicates the key must be double datatype
// last element can be removed by using Popitem function and
// 2 indicates that the key datatype should be double.
j7utils.Oakj7Dictionary list231=list33.Popitem(list33,2);
// print all the elements like keys and values from Dictionary list231
for (int i=0;i<list231.size();i++)
{
// Filter 0's and print the keys and value pairs using J7Print
//with key and values to be passed to J7Print function arguments
J7Str.Filter.J7Print(list231.getKey(i),list231.getValue(i));
}
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("Remove all elements from Oakj7Dictionary second for double");
//Copy Dictionary list231 to list2311, that can be achieved by using list2311=list231
j7utils.Oakj7Dictionary list2311=list231;
// add additional data with key and values pairs starting from 10.0 and ends at 14.0.
list2311.add("10.0","Cdollar");
list2311.add("10.0","Cdollar");
list2311.add("11.0","Adollar");
list2311.add("12.0","Bdollar");
list2311.add("13.0","dollar");
list2311.add("14.0","Asdollar1");
//wilmixcode
//Remove 2.0 data(key and value pairs) from dictionary list2311 and copy to list2312
// Here 2 indicates Double Datatype.
j7utils.Oakj7Dictionary list2312=list2311.remove(list2311,"2.0",2);
// Check list2312 is empty or not and the result will be true or false using IsEmpty function
<PRINTLN>("Is Empty= "+list2312.IsEmpty(list2312,2));
<PRINTLN>("Elements present from Oakj7Dictionary before removing ");
// print all the elements like keys and values from Dictionary list2312
for (int i=0;i<list2312.size();i++)
{
// Filter 0's and print the keys and value pairs using J7Print
//with key and values to be passed to J7Print function arguments
J7Str.Filter.J7Print(list2312.getKey(i),list2312.getValue(i));
}
//remove all elements by using RemoveAll function,In case of double datatype
// choice 2 value should be passed as a argument to RemoveAll function.
//list2312=list2311.RemoveAll(list2311,2);
// Add elements like 0.0 and 10.0 to 13.0 (keys and value pairs) values to the dictionary list2312
list2312.add("0.0","Language");
list2312.add("10.0","Cdollar");
list2312.add("11.0","Adollar");
list2312.add("11.0","Adollar");
list2312.add("12.6","dollar");
list2312.add("13.0","Asdollar");
//Remove 13.0 key and it's value pairs using list2312.remove function and
// choice 2 (reprsent double value) value should be passed as a argument to remove function.
j7utils.Oakj7Dictionary list23123=list2312.remove(list2312,"13.0",2);
// Remove duplicates from Oakjava7Dictionary using j7utils.Oakj7Dictionary.process function
// and pass the list23123 as a dictionary object to the process function
//finally this process function will remove duplicates for Double key Datatypes and
// finally copy to flist dictionary.
j7utils.Oakj7Dictionary flist=j7utils.Oakj7Dictionary.process(list23123);
// print the size of the dictionary using list23123 instance with size() function
<PRINTLN>("Elements present from Oakj7Dictionary after removing ="+list23123.size());
// print all the elements like keys and values from Dictionary flist
for (int i=0;i<flist.size();i++)
{
// Filter 0's and print the keys and value pairs using J7Print
//with key and values to be passed to J7Print function arguments
J7Str.Filter.J7Print(flist.getKey(i),flist.getValue(i));
}
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("==================================================== ");
<PRINTLN>(" Using String as Key and string as value");
//call this UsingStrJ7Dict method for Key and value to be string -method type -3
UsingStrJ7Dict();
<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");<PRINTLN>(" ");
}
<CATCH> (<EXE> e) {<PRINTLN>("DuplicateException="+e);}
//wcode
}
//wilmixjemin code
//Shared means static in OakJava7
public Shared void UsingStrJ7Dict()
{
j7utils.Oakj7Dictionary list33 <NEW> j7utils.Oakj7Dictionary ("zero", "0");
list33.add("One","ADOLLAR");
list33.add("two","GDOLLAR");
list33.add("three", "GDOLLAR");
list33.add("four","JDOLLAR");
list33.add("five","JAVA");
list33.add("six","JSTAR");
list33.add("seven","JSAUCER");
list33.add("eight","Csharp");
list33.add("eight","Csharp");
list33.add("nine","C");
list33.add("ten","C++");
// pass the String value "seven" to the remove function.
list33=list33.remove(list33,"seven",2);
//Delete the Last item using Popitem function
j7utils.Oakj7Dictionary list231=list33.Popitem(list33,2);
for (int i=0;i<list231.size();i++)
{
J7Str.Filter.J7Print(list231.getKey(i),list231.getValue(i));
}
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("Remove elements from Oakj7Dictionary third for string");
j7utils.Oakj7Dictionary list2311=list231;
list2311.add("ten","Cdollarc");
list2311.add("ten","Cdollar");
list2311.add("eleven","Adollar");
list2311.add("twele","Bdollar");
list2311.add("thirteen","dollar");
list2311.add("thirteen","Asdollar");
list2311.add("fourteen","Asdollar1");
//wilmixcode
j7utils.Oakj7Dictionary list2312=list2311.remove(list2311,"zero",2);
<PRINTLN>("Is Empty= "+list2312.IsEmpty(list2312,2));
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("Elements present from Oakj7Dictionary before removing.... ");
<PRINTLN>(" ");<PRINTLN>(" ");
for (int i=0;i<list2312.size();i++)
{
J7Str.Filter.J7Print(list2312.getKey(i),list2312.getValue(i));
}
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
list2312.add("0.0","Language");
list2312.add("ten","Cdollar");
list2312.add("eleven","Adollar");
list2312.add("eleven","Adollar");
list2312.add("twele","dollar");
list2312.add("twele","dollar");
// important wcode
j7utils.Oakj7Dictionary list23123=list2312.remove(list2312,"eleven",2);
// Use StrProcess function and pass the instance of the dictionary ie) list23123
// Use StrProcess function to remove duplicates in the Oakjava7- Dictionary //containing same keys in case of key and value pairs of dictionary
// be type of String
j7utils.Oakj7Dictionary flist=j7utils.Oakj7Dictionary.StrProcess(list23123);
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
//Print the size of flist dictionary.
<PRINTLN>("Elements present from Oakj7Dictionary after removing.. ="+flist.size());
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
for (int i=0;i<flist.size();i++)
{
J7Str.Filter.J7Print(flist.getKey(i),flist.getValue(i));
}
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>(" ");<PRINTLN>(" ");
<PRINTLN>("Elements present from Oakj7Dictionary after removing every elements="+flist.size());
//remove all elements from flist dictionary
flist=flist.RemoveAll(flist,2);
for (int i=0;i<flist.size();i++)
{
J7Str.Filter.J7Print(flist.getKey(i),flist.getValue(i));
}
}
//wilmixjemin code
}
}
OUTPUT
list size=10
{1=ADOLLAR}
{2=GDOLLAR}
{3=GDOLLAR}
{4=JDOLLAR}
{5=JAVA}
{6=JSTAR}
{7=JSAUCER}
{8=Csharp}
{8=Csharp}
Display all Keys in dictionary
0
1
2
3
4
5
6
7
8
8
{1=ADOLLAR}{2=GDOLLAR}{3=GDOLLAR}{4=JDOLLAR}{5=JAVA}{7=JSAUCER}{8=Csharp}{8=Csharp}
Remove Duplicates....
{1=ADOLLAR}
{2=GDOLLAR}
{3=GDOLLAR}
{4=JDOLLAR}
{5=JAVA}
{7=JSAUCER}
{8=Csharp}
Remove the lastElement element....
{1=ADOLLAR}{2=GDOLLAR}{4=JDOLLAR}{7=JSAUCER}
Remove all elements from Oakj7Dictionary-firstElement
Key=value pairs =
{1=JAVA}{2=OAKJAVA7}
Is Empty firstElement= False
====================================================
Using Double as Key and string as value
{1.0=ADOLLAR}{2.0=GDOLLAR}{3.0=GDOLLAR}{4.0=JDOLLAR}{5.0=JAVA}{6.0=JSTAR}{8.0=Csharp}{8.0=Csharp}{9.0=C}
Remove all elements from Oakj7Dictionary second for double
Is Empty= False
Elements present from Oakj7Dictionary before removing
{1.0=ADOLLAR}{3.0=GDOLLAR}{4.0=JDOLLAR}{5.0=JAVA}{6.0=JSTAR}{8.0=Csharp}{8.0=Csharp}{9.0=C}{10.0=Cdollar}{10.0=Cdollar}
{11.0=Adollar}{12.0=Bdollar}{13.0=dollar}{14.0=Asdollar1}
Elements present from Oakj7Dictionary after removing =25
{0=Language}{1=ADOLLAR}{3=GDOLLAR}{4=JDOLLAR}{5=JAVA}{6=JSTAR}{8=Csharp}{9=C}{10=Cdollar}{11=Adollar}{12=Bdollar}
{14=Asdollar1}{12.6=dollar}{13=Asdollar}
====================================================
Using String as Key and string as value
{zero=0}{One=ADOLLAR}{two=GDOLLAR}{three=GDOLLAR}{four=JDOLLAR}{five=JAVA}{six=JSTAR}{eight=Csharp}{eight=Csharp}{nine=C}{ten=C++}
Remove elements from Oakj7Dictionary third for string
Is Empty= False
Elements present from Oakj7Dictionary before removing....
{One=ADOLLAR}{two=GDOLLAR}{three=GDOLLAR}{four=JDOLLAR}{five=JAVA}{six=JSTAR}{eight=Csharp}{eight=Csharp}{nine=C}{ten=C++}{ten=Cdollarc}
{ten=Cdollar}{eleven=Adollar}{twele=Bdollar}{thirteen=dollar}{thirteen=Asdollar}{fourteen=Asdollar1}
Elements present from Oakj7Dictionary after removing.. =15
{One=ADOLLAR}{two=GDOLLAR}{three=GDOLLAR}{four=JDOLLAR}{five=JAVA}{six=JSTAR}{eight=Csharp}{nine=C}{ten=Cdollar}{twele=dollar}{thirteen=Asdollar}{fourteen=Asdollar1}
Elements present from Oakj7Dictionary after removing every elements=15
=====================================================================
====================================================================
Note: I will attach the screen shot in the OakJava7 with ScrollServer EBook.
Note: In Enterprise Edition it contains remaining 55% Advanced samples...
=========================================================
Note for OakJava7 version 1:
There are 4 kinds of OakJava7 Util Packages
which are given below..
i) <OJ7UTIL>, <OAKJAVA7>
ii) CUTIL,OJ7UTIL
iii) J7UTIL -> oakjava7 library packages
So for converting from <OJ7UTIL> to OJ7UTIL
results in Autoboxing concept. Because these
two OakJava7 Util Packages are of different types. But in
OakJava7 next version (OakJava7 version 2) , i will combine this
to a one Datastructures. This is the demerits of OakJava7 version 1.
<OAKJAVA7> is just the library package for OakJava7 Programming package .
===========================================================
Note:
I have to include OakJava7 webapplication samples in OakJava7 Advanced samples section. So that all Oakjava7 professionals will learn and practice oakjava7(JAVA7.0) web application .
That's why Oakjava7 (Java7.0) is not released at January 2024.
----- Wilmix Jemin J
Note: This Oakjava7 Advanced Samples webpage is under construction for text alignment.
Here we covered only 40% of Advanced samples , but remaining 60% of Advanced samples will be found only at Oakjava7 Enterprise Edition., and it is not found at Professional Edition.
But in Professional edition you can't learn about Oakjava7 templates. In Enterprise Edition you can study more about OakJava7 Templates ,Security , Oakjava7 Advanced topics , OakJava7 Single Webapplication , OakJava7 with High Security etc.
Note: I request all OakJava7 professionals must learn it and don't forget to practice it when i publish the Oakjava7 Software and OakJava7 Ebook in GIT repository. If you study then it more easy to study JDollar(j$) and Advanced Business. Because what ever you learn oakjava7 , the same oops concepts will be found in JDollar(J$),Advanced business only the syntax and the advantages
will differ. So Oakjava7 is considered as a most important .
So Practice all the Assignments which i have given.
"Remaining 60% concept is based on high security, OakJava7 Templates, Oakjava7 Advanced topics, remaining Webapplication samples, Remote -X application.You can find remaining features in oakJava7(JAVA7.0) Enterprise Ediition. This is my plan to Protect oakJava7(JAVA7.0) from hackers/competitors in copying my features." - wilmix jemin.
==============================================================================================