-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parse.java
133 lines (124 loc) · 3.34 KB
/
Parse.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* Copyright (C) 2010 WeaveBytes, Inc.,
*
* Confidential, all rights reserved. No distribution is permitted.
___ _______ ____ ________
\ \ __ / __| / \ / ___|
\ \ / \ / |_ / /\ \ / |_
\ \/ \/ /| _| / /__\ \/ /| _|
\ /\ / | |__/ ______ / | |___
\__/ \__/ |_______/ \ _/ |______|
___ __
______ | | ________ __ __ | |
/ ___| | | / __ \ | | | | _______| |
| | | | | | | | | | | | / ____| |
| |____| |__ | |__| |__| \____/ | \ \____| |
\_______|______\________/__ \________/__ \_________|
*/
//Description: Parser.java is the class for parsing string in weavecloud
//Creation Date: July 27, 2011
//Authors : Simranpal Singh, Varinder Pal Singh
import java.util.*;
class Parse {
String msg = "GLIDnavjot:weavebytes&simran:java&varinder:cloud&";
String msg1 = "ULIDnavjot:weavebytes&simran:java&varinder:cloud&";
String msgUFLR = "UFLRsimran/java/navi/";
String msgUFLD = "UFLDd*java:d*songs:f*xyz.doc:f*abc.txt";
//GLIDnavjot:weavebytes&simran:java&varinder:cloud&
public void parseGLID(String m) {
StringTokenizer st = new StringTokenizer(m.substring(4), "&");
while (st.hasMoreTokens()) {
int i = m.indexOf(":");
int j = m.indexOf("&");
if( i == -1)
break;
String s = m.substring(i+1,j);
m = m.substring(j+1);
if(i>0&&j>0)
System.out.println(s);
}
}
//ULIDnavjot:weavebytes&simran:java&varinder:cloud&
public void ULID(String m) {
StringTokenizer st = new StringTokenizer(m.substring(4), ":");
int i = m.indexOf(":");
String s = m.substring(4,i);
System.out.println(s);
while (m.length()>1) {
int j = m.indexOf("&");
if (j==-1)
{
break;
}
m = m.substring(j+1);
int k = m.indexOf(":");
if (k==-1)
{
break;
}
String sb = m.substring(0,k);
System.out.println(sb);
}
}
//ULFRsimran/java/navi/
public void UFLR(String m) {
StringTokenizer st = new StringTokenizer(m.substring(4), "/");
int i = m.indexOf("/");
String s = m.substring(4,i);
System.out.println(s);
while (m.length()>1) {
int k = m.indexOf("/");
if (k==-1)
{
break;
}
m = m.substring(k+1);
int j = m.indexOf("/");
if (j==-1)
{
break;
}
String sb = m.substring(0,j);
System.out.println(sb);
}
}
//UFLDd*java:d*songs:f*xyz.doc:f*abc.txt
public void UFLD(String m) {
Hashtable group = new Hashtable();
m = m.substring(4);
while (m.length()>1) {
int k = m.indexOf(":");
if (k==-1)
{
break;
}
String sb = m.substring(0,k);
m = m.substring(k+1);
//System.out.println("sb is "+sb);
int star = sb.indexOf("*");
String fType = sb.substring(0,star);
String fName = sb.substring(star+1);
System.out.println("Name : "+fName);
System.out.println("Type : "+fType);
group.put(fName,fType);
}
Enumeration list;
list = group.keys();
while(list.hasMoreElements())
{
String str = (String)list.nextElement();
System.out.println(group.get(str));
}
}
public static void main(String[] args)
{
Parse g = new Parse();
//g.parseGLID(g.msg);
Parse u = new Parse();
//u.ULID(u.msg1);
Parse f = new Parse();
//f.UFLR(f.msgUFLR);
Parse f1 = new Parse();
f1.UFLD(f.msgUFLD);
}
}