Author: mvitenkov
Date: 2008-11-04 11:02:04 -0500 (Tue, 04 Nov 2008)
New Revision: 11015
Modified:
trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java
Log:
getAllHandlers()
Modified: trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java 2008-11-04
16:01:39 UTC (rev 11014)
+++ trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java 2008-11-04
16:02:04 UTC (rev 11015)
@@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.ArrayList;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -12,7 +13,7 @@
protected String component;
protected JarEntry tld;
protected JarFile richfacesUI;
- protected AttributesList allAttributes;
+ protected AttributesList allAttributes;
public TLDParser(String str) {
this.component = str;
@@ -48,32 +49,52 @@
position + 6, end).trim());
}
// find attribute description
- if ((position = line.indexOf("<description>")) != -1) {
-
- if((end = line.indexOf("</description>")) != -1){
- attribute.setDescription(line.substring(position + 13, line.length()-14));
- }else{
- sb.append(line.substring(position + 13,
line.length()).trim().replaceAll("\t", ""));
+ if ((position = line
+ .indexOf("<description>")) != -1) {
+
+ if ((end = line
+ .indexOf("</description>")) != -1) {
+ attribute
+ .setDescription(line
+ .substring(
+ position + 13,
+ line
+ .length() - 14));
+ } else {
+ sb.append(line.substring(
+ position + 13,
+ line.length()).trim()
+ .replaceAll("\t", ""));
line = reader.readLine();
- while ((end = line.indexOf("</description>")) == -1) {
- sb.append(line.substring(0, line.length()).replaceAll("\t",
""));
+ while ((end = line
+ .indexOf("</description>")) == -1) {
+ sb.append(line.substring(0,
+ line.length())
+ .replaceAll("\t", ""));
line = reader.readLine();
}
- sb.append(line.substring(0, line.length() -
14).trim().replaceAll("\t", ""));
-
- attribute.setDescription(sb.toString());
+ sb.append(line.substring(0,
+ line.length() - 14).trim()
+ .replaceAll("\t", ""));
+
+ attribute.setDescription(sb
+ .toString());
sb.delete(0, sb.length());
- }
- }
+ }
+ }
// find attribute type
if ((position = line.indexOf("<type>")) != -1) {
end = line.indexOf("</type>");
- attribute.setType(line.substring(position + 6, end).trim());
+ attribute.setType(line.substring(
+ position + 6, end).trim());
}
// find attribute method-signature
- if ((position = line.indexOf("<method-signature>")) != -1) {
- end = line.indexOf("</method-signature>");
- attribute.setType(line.substring(position + 18, end).trim());
+ if ((position = line
+ .indexOf("<method-signature>")) != -1) {
+ end = line
+ .indexOf("</method-signature>");
+ attribute.setType(line.substring(
+ position + 18, end).trim());
}
} while (!((line = reader.readLine())
.contains("</attribute>")));
@@ -120,5 +141,33 @@
e.printStackTrace();
}
return richfacesUI;
- }
+ }
+
+ public ArrayList<String> getAllHandlers() {
+ tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
+ InputStream input = null;
+ ArrayList<String> handlers = new ArrayList<String>();
+
+ try {
+ input = richfacesUI.getInputStream(tld);
+ InputStreamReader isr = new InputStreamReader(input);
+ BufferedReader reader = new BufferedReader(isr);
+ String line, temp;
+ int start, end;
+ while ((line = reader.readLine()) != null) {
+ if ((start = line.indexOf("<name>")) != -1) {
+ end = line.indexOf("</name>");
+ temp = line.substring(start + 6, end).trim();
+ if (temp.startsWith("on") && !handlers.contains(temp)) {
+ handlers.add(temp);
+ }
+ }
+ }
+ return handlers;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
}