| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Welcome to the Java-Parser wiki!
first of all instantiate the parser object
File file = new File("BubbleSort.java");
parser p = new parser(file); String s = "public class BubbleSort {}";
parser p = new parser(p);String imports = "import java.io.BufferedReader;\r\n" +
"import java.io.File;\r\n"+
"import java.io.FileNotFoundException;\r\n" +
"import java.io.FileReader;\r\n";
p.addImportStatment(imports);String x = "public class BubbleSort{" +
" public static void main(String[] args) {"+
" }" +
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
//returns --> [public class BubbleSort{, class InsertionSort{]*/String x = "public class BubbleSort{" +
" public static void main(String[] args) {"+
" }" +
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.getClassBody(0);
/*
returns:
public static void main
(
String[] args
)
{
}
*/String x = "public class BubbleSort{" +
" public static void main(String[] args) {"+
" }" +
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.refactorClassBody(1, "String x=\"NEW CODE\";"+p.getClassBody(1));
/*
returns:
public class BubbleSort
{
String x
=
"NEW CODE"
;
public static void main
(
String[] args
)
{
}
}
class InsertionSort
{
}
*/p.getConstructorDecleration();String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" }" +
" public static int m1(String s) {return 0;}" +
" public static void m2(ArrayList<Integer> a) {return}" +
" public static int m3(int n1, int n2) {return 0;}"+
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.getMethodDeclerations();
/*
returns:
[public static void main
(
String[] args
)
{, public static int m1
(
String s
)
{, public static void m2
(
ArrayList
<
Integer
>
a
)
{, public static int m3
(
int n1
,
int n2
)
{]
*/String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" }" +
" public static int m1(String s) {return 0;}" +
" public static void m2(ArrayList<Integer> a) {return}" +
" public static int m3(int n1, int n2) {return 0;}"+
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.getMethodBody(2);
/*
returns:
return 0
;
*/String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" }" +
" public static int m1(String s) {return 0;}" +
" public static void m2(ArrayList<Integer> a) {return}" +
" public static int m3(int n1, int n2) {return 0;}"+
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.refactorMethodBody(2, "String x = \"NEW CODE\";"+p.getMethodBody(2));
/*
returns:
public class BubbleSort
{
public static void main
(
String[] args
)
{
}
public static int m1
(
String s
)
{
String x
=
"NEW CODE"
;
return 0
;
}
public static void m2
(
ArrayList
<
Integer
>
a
)
{
return
}
public static int m3
(
int n1
,
int n2
)
{
return 0
;
}
}
class InsertionSort
{
}
*/String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" }" +
" public static int m1(String s) {return 0;}" +
" public static void m2(ArrayList<Integer> a) {return}" +
" public static int m3(int n1, int n2) {return 0;}"+
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.getMainMethodBody();
/*
returns:
String s
=
"HELLO WORLD"
;
*/String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" }" +
" public static int m1(String s) {return 0;}" +
" public static void m2(ArrayList<Integer> a) {return}" +
" public static int m3(int n1, int n2) {return 0;}"+
"}" +
"class InsertionSort{}" ;
parser p = new parser(x);
p.refactorMainMethodBody("String x = \"HELLO WORLD\";" + p.getMainMethodBody());
/*
returns:
public class BubbleSort
{
public static void main
(
String[] args
)
{
String x
=
"HELLO WORLD"
;
String s
=
"HELLO WORLD"
;
}
public static int m1
(
String s
)
{
return 0
;
}
public static void m2
(
ArrayList
<
Integer
>
a
)
{
return
}
public static int m3
(
int n1
,
int n2
)
{
return 0
;
}
}
class InsertionSort
{
}
*/String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" int arr [] = new int [3];"+
" arr[0] = 0;"+
" arr[1] = 1;"+
" arr[2] = 2;"+
" }" +
"}" ;
parser p = new parser(x);
p.getArrayAssignment();
/*
returns:
[arr[0]
=
0
;, arr[1]
=
1
;, arr[2]
=
2
;]
*/String x = "public class BubbleSort {" +
" public static void main(String[] args) {"+
" }" +
"}" ;
parser p = new parser(x);
p.refactorMainMethodBody("String x = \"HELLO WORLD\";");
/*
returns:
public class BubbleSort
{
public static void main
(
String[] args
)
{
String x
=
"HELLO WORLD"
;
}
}
*/| Back | FazBrowse Home | New Git URL |