[richfaces-svn-commits] JBoss Rich Faces SVN: r15249 - in branches/community/3.3.X/test-applications: jsp/src/main/java/util/parser and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Aug 21 08:50:18 EDT 2009


Author: mvitenkov
Date: 2009-08-21 08:50:18 -0400 (Fri, 21 Aug 2009)
New Revision: 15249

Modified:
   branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
   branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java
   branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java
Log:


Modified: branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java	2009-08-21 12:06:49 UTC (rev 15248)
+++ branches/community/3.3.X/test-applications/facelets/src/main/java/util/parser/TLDParser.java	2009-08-21 12:50:18 UTC (rev 15249)
@@ -16,6 +16,7 @@
 	}
 
 	public AttributesList getAllAttributes() {
+		allAttributes.clear();
 		try {
 			
 			Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());

Modified: branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java	2009-08-21 12:06:49 UTC (rev 15248)
+++ branches/community/3.3.X/test-applications/jsp/src/main/java/util/parser/TLDParser.java	2009-08-21 12:50:18 UTC (rev 15249)
@@ -16,7 +16,7 @@
 	}
 
 	public AttributesList getAllAttributes() {
-
+		allAttributes.clear();
 		try {
 
 			Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
@@ -116,4 +116,4 @@
 		this.component = component;
 	}
 	
-}
+}
\ No newline at end of file

Modified: branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java	2009-08-21 12:06:49 UTC (rev 15248)
+++ branches/community/3.3.X/test-applications/test-jsp/src/main/java/util/parser/TLDParser.java	2009-08-21 12:50:18 UTC (rev 15249)
@@ -21,56 +21,27 @@
 
 package util.parser;
 
+
 import java.io.BufferedReader;
 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;
+import java.io.Reader;
 
-/**
- * The Class TLDParser parses richfaces.tld file to provide AttributeList object
- * for selected component.
- */
 public class TLDParser {
 
-	/** The component's name. */
-	protected String component;
+	protected String component;	
+	protected AttributesList allAttributes;	
 
-	/** The tld object represents a richfaces.tld file. */
-	protected JarEntry tld;
-
-	/** The richfacesUI object represents a richfaces-ui.jar file. */
-	protected JarFile richfacesUI;
-
-	/** The all attributes. */
-	protected AttributesList allAttributes;
-
-	/**
-	 * Instantiates a new tLD parser.
-	 * 
-	 * @param str
-	 *            the component's name
-	 */
 	public TLDParser(String str) {
 		this.component = str;
 		allAttributes = new AttributesList();
 	}
 
-	/**
-	 * Gets the all attributes from richfaces.tld file for selected component.
-	 * 
-	 * @return the all attributes
-	 */
 	public AttributesList getAllAttributes() {
 		allAttributes.clear();
-		tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
-		InputStream input = null;
 		try {
-			input = richfacesUI.getInputStream(tld);
-
-			InputStreamReader isr = new InputStreamReader(input);
+			
+			Reader isr = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource("META-INF/richfaces.tld").openStream());
 			BufferedReader reader = new BufferedReader(isr);
 			String line, attr;
 			Attribute attribute = new Attribute();
@@ -92,56 +63,36 @@
 												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>")));
-								// define initial attribute status
+								// define attribute status
 								attribute.setStatus(Status.NOT_TESTED);
 								allAttributes.add(attribute);
 								attribute = new Attribute();
@@ -157,90 +108,12 @@
 		}
 		return allAttributes;
 	}
-
-	/**
-	 * Gets the richfaces.tld resource.
-	 * 
-	 * @return the richfaces.tld resource
-	 */
-	public String getExtPath() {
-		ClassLoader loader = Thread.currentThread().getContextClassLoader();
-		String resource = "META-INF/richfaces.tld";
-		return loader.getResource(resource).toString();
-	}
-
-	/**
-	 * Gets the component's name.
-	 * 
-	 * @return the component's name
-	 */
+	
 	public String getComponent() {
 		return component;
 	}
 
-	/**
-	 * Sets the component's name.
-	 * 
-	 * @param component
-	 *            the new component's name
-	 */
 	public void setComponent(String component) {
 		this.component = component;
-	}
-
-	/**
-	 * Gets the richfacesUI object representing a richfaces-ui.jar file.
-	 * 
-	 * @return the richfaces ui
-	 */
-	public JarFile getRichfacesUI() {
-		String temp = null;
-		int position;
-		try {
-			if ((position = getExtPath().indexOf('!')) != -1) {
-				if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
-					temp = getExtPath().substring("jar:file:\\".length(), position);
-				} else {
-					temp = "/"	+ getExtPath().substring("jar:file:/".length(),	position);
-				}
-			}
-			richfacesUI = new JarFile(temp);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return richfacesUI;
-	}
-
-	/**
-	 * Gets the all possible handlers from richfaces.tld file.
-	 * 
-	 * @return the all possible handlers
-	 */
-	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;
-	}
-}
+	}	
+}
\ No newline at end of file



More information about the richfaces-svn-commits mailing list