W3C home > Mailing lists > Public > www-validator-cvs@w3.org > November 2007

2006/unicorn/org/w3c/unicorn/output EscapeXMLEntities.java,1.2,1.3 XHTMLize.java,1.2,1.3

From: Denis Tea via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 29 Nov 2007 14:12:01 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Ixk7V-00083X-Vw@lionel-hutz.w3.org>

Update of /sources/public/2006/unicorn/org/w3c/unicorn/output
In directory hutz:/tmp/cvs-serv30684/org/w3c/unicorn/output

Modified Files:
	EscapeXMLEntities.java XHTMLize.java 
Log Message:
Multithreading

Index: EscapeXMLEntities.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/output/EscapeXMLEntities.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- EscapeXMLEntities.java	21 Sep 2006 16:01:25 -0000	1.2
+++ EscapeXMLEntities.java	29 Nov 2007 14:11:59 -0000	1.3
@@ -1,93 +1,93 @@
-package org.w3c.unicorn.output;
-
-import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
-
-/**
- * Escape all XML Entities in the reference insertion.
- * Specifically, the following conversions are performed:
- * <DL>
- * <DT>&amp;</DT><DD>&amp;amp;</DD>
- * <DT>&lt;</DT><DD>&amp;lt;</DD>
- * <DT>&gt;</DT><DD>&amp;gt;</DD>
- * <DT>&quot;</DT><DD>&amp;quot;</DD>
- * </DL>
- *
- * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
- */
-public class EscapeXMLEntities implements ReferenceInsertionEventHandler {
-	
-	/**
-	 * Escape the XML entities for all inserted references.
-	 */
-	public Object referenceInsert (final String sUnused, final Object oValue) {
-		final String sValue = oValue.toString();
-		return EscapeXMLEntities.escapeText(sValue);
-	}
-
-	/**
-	 * Escape the provided text.
-	 * @param sValue
-	 * @return
-	 */
-	public static String escapeText (final String sValue) {
-		final StringBuffer aStringBuffer = new StringBuffer(sValue.length());
-		final int iLength = sValue.length();
-		int iPosition = 0;
-		int iNextPosition = EscapeXMLEntities.nextPosition(sValue, iPosition);
-
-		while (iNextPosition != -1) {
-			aStringBuffer.append(sValue.substring(iPosition, iNextPosition));
-			aStringBuffer.append(EscapeXMLEntities.escapeChar(sValue.charAt(iNextPosition)));
-			iPosition = iNextPosition + 1;
-			if (iPosition < iLength) {
-				iNextPosition = EscapeXMLEntities.nextPosition(sValue, iPosition);
-			} else {
-				iNextPosition = -1;
-			}
-		}
-
-		if (iPosition < iLength) {
-			aStringBuffer.append(sValue.substring(iPosition));
-		}
-
-		return aStringBuffer.toString();
-	}
-	
-	private static String escapeChar (final char c) {
-		switch (c) {
-			case '<' : return "&lt;";
-			case '>' : return "&gt;";
-			case '&' : return "&amp;";
-			case '"' : return "&quot;";
-		}
-		return null;
-	}
-	
-	private static int nextPosition (final String s, final int iCurrentPosition) {
-		final int iLT = s.indexOf('<', iCurrentPosition);
-		final int iGT = s.indexOf('>', iCurrentPosition);
-		final int iAMP = s.indexOf('&', iCurrentPosition);
-		final int iQUOT = s.indexOf('"', iCurrentPosition);
-		
-		if (
-				(iLT != -1) &&
-				((iGT == -1) || (iLT < iGT)) &&
-				((iAMP == -1) || (iLT < iAMP)) &&
-				((iQUOT == -1) || (iLT < iQUOT))) {
-			return iLT;
-		}
-		if (
-				(iGT != -1) &&
-				((iAMP == -1) || (iGT < iAMP)) &&
-				((iQUOT == -1) || (iGT < iQUOT))) {
-			return iGT;
-		}
-		if (
-				(iAMP != -1) &&
-				((iQUOT == -1) || (iAMP < iQUOT))) {
-			return iAMP;
-		}
-		return iQUOT;
-	}
-	
-}
+package org.w3c.unicorn.output;
+
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+
+/**
+ * Escape all XML Entities in the reference insertion.
+ * Specifically, the following conversions are performed:
+ * <DL>
+ * <DT>&amp;</DT><DD>&amp;amp;</DD>
+ * <DT>&lt;</DT><DD>&amp;lt;</DD>
+ * <DT>&gt;</DT><DD>&amp;gt;</DD>
+ * <DT>&quot;</DT><DD>&amp;quot;</DD>
+ * </DL>
+ *
+ * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
+ */
+public class EscapeXMLEntities implements ReferenceInsertionEventHandler {
+	
+	/**
+	 * Escape the XML entities for all inserted references.
+	 */
+	public Object referenceInsert (final String sUnused, final Object oValue) {
+		final String sValue = oValue.toString();
+		return EscapeXMLEntities.escapeText(sValue);
+	}
+
+	/**
+	 * Escape the provided text.
+	 * @param sValue
+	 * @return
+	 */
+	public static String escapeText (final String sValue) {
+		final StringBuffer aStringBuffer = new StringBuffer(sValue.length());
+		final int iLength = sValue.length();
+		int iPosition = 0;
+		int iNextPosition = EscapeXMLEntities.nextPosition(sValue, iPosition);
+
+		while (iNextPosition != -1) {
+			aStringBuffer.append(sValue.substring(iPosition, iNextPosition));
+			aStringBuffer.append(EscapeXMLEntities.escapeChar(sValue.charAt(iNextPosition)));
+			iPosition = iNextPosition + 1;
+			if (iPosition < iLength) {
+				iNextPosition = EscapeXMLEntities.nextPosition(sValue, iPosition);
+			} else {
+				iNextPosition = -1;
+			}
+		}
+
+		if (iPosition < iLength) {
+			aStringBuffer.append(sValue.substring(iPosition));
+		}
+
+		return aStringBuffer.toString();
+	}
+	
+	private static String escapeChar (final char c) {
+		switch (c) {
+			case '<' : return "&lt;";
+			case '>' : return "&gt;";
+			case '&' : return "&amp;";
+			case '"' : return "&quot;";
+		}
+		return null;
+	}
+	
+	private static int nextPosition (final String s, final int iCurrentPosition) {
+		final int iLT = s.indexOf('<', iCurrentPosition);
+		final int iGT = s.indexOf('>', iCurrentPosition);
+		final int iAMP = s.indexOf('&', iCurrentPosition);
+		final int iQUOT = s.indexOf('"', iCurrentPosition);
+		
+		if (
+				(iLT != -1) &&
+				((iGT == -1) || (iLT < iGT)) &&
+				((iAMP == -1) || (iLT < iAMP)) &&
+				((iQUOT == -1) || (iLT < iQUOT))) {
+			return iLT;
+		}
+		if (
+				(iGT != -1) &&
+				((iAMP == -1) || (iGT < iAMP)) &&
+				((iQUOT == -1) || (iGT < iQUOT))) {
+			return iGT;
+		}
+		if (
+				(iAMP != -1) &&
+				((iQUOT == -1) || (iAMP < iQUOT))) {
+			return iAMP;
+		}
+		return iQUOT;
+	}
+	
+}

Index: XHTMLize.java
===================================================================
RCS file: /sources/public/2006/unicorn/org/w3c/unicorn/output/XHTMLize.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- XHTMLize.java	29 Sep 2006 09:25:11 -0000	1.2
+++ XHTMLize.java	29 Nov 2007 14:11:59 -0000	1.3
@@ -1,83 +1,83 @@
-package org.w3c.unicorn.output;
-
-import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
-import org.w3c.unicorn.generated.observationresponse.Code;
-import org.w3c.unicorn.generated.observationresponse.A;
-import org.w3c.unicorn.generated.observationresponse.Img;
-
-
-/**
- * Escape all XML Entities in the reference insertion.
- * Specifically, the following conversions are performed:
- * <DL>
- * <DT>&amp;</DT><DD>&amp;amp;</DD>
- * <DT>&lt;</DT><DD>&amp;lt;</DD>
- * <DT>&gt;</DT><DD>&amp;gt;</DD>
- * <DT>&quot;</DT><DD>&amp;quot;</DD>
- * </DL>
- *
- * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
- */
-public class XHTMLize implements ReferenceInsertionEventHandler {
-	
-	/**
-	 * Escape the XML entities for all inserted references.
-	 */
-	public Object referenceInsert (final String sUnused, final Object oValue) {
-		if (oValue instanceof A) {
-			A link = (A) oValue;
-			return insertA(link);
-		}
-		if (oValue instanceof Img) {
-			Img image = (Img) oValue;
-			return insertImg(image);
-		}
-		if (oValue instanceof Code) {
-			Code code = (Code) oValue;
-			return insertCode(code);
-		}
-		return EscapeXMLEntities.escapeText(oValue.toString());
-	}
-	
-	private Object insertA (final A aLink) {
-		String sResultat = "<a href=\"" + EscapeXMLEntities.escapeText(aLink.getHref()) + "\">";
-		for (final Object oElement : aLink.getContent()) {
-			if (oElement instanceof Img) {
-				sResultat += insertImg((Img) oElement);
-			}
-			else {				
-				sResultat += EscapeXMLEntities.escapeText(oElement.toString());
-			}
-		}
-		sResultat += "</a>";
-		return sResultat;
-	}
-	
-	private Object insertCode (final Code aCode) {
-		String sResultat = "<code>";
-		for (final Object oElement : aCode.getContent()) {			
-			if (oElement instanceof A) {
-				sResultat += insertA((A) oElement);			
-			}
-			else if(oElement instanceof Img) {
-				sResultat += insertImg((Img) oElement);
-			}
-			else {
-				sResultat += EscapeXMLEntities.escapeText(oElement.toString());
-			}
-		}
-		sResultat += "</code>";
-		return sResultat;
-	}
-
-	/**
-	 * @param img
-	 * @return
-	 */
-	private String insertImg (final Img aImage) {
-		return "<img src=\"" + EscapeXMLEntities.escapeText(aImage.getSrc())
-		+ "\" alt=\"" + EscapeXMLEntities.escapeText(aImage.getAlt())
-		+ "\"/>";
-	}
-
-}
+package org.w3c.unicorn.output;
+
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.w3c.unicorn.generated.observationresponse.Code;
+import org.w3c.unicorn.generated.observationresponse.A;
+import org.w3c.unicorn.generated.observationresponse.Img;
+
+
+/**
+ * Escape all XML Entities in the reference insertion.
+ * Specifically, the following conversions are performed:
+ * <DL>
+ * <DT>&amp;</DT><DD>&amp;amp;</DD>
+ * <DT>&lt;</DT><DD>&amp;lt;</DD>
+ * <DT>&gt;</DT><DD>&amp;gt;</DD>
+ * <DT>&quot;</DT><DD>&amp;quot;</DD>
+ * </DL>
+ *
+ * @author <a href="mailto:wglass@forio.com">Will Glass-Husain</a>
+ */
+public class XHTMLize implements ReferenceInsertionEventHandler {
+	
+	/**
+	 * Escape the XML entities for all inserted references.
+	 */
+	public Object referenceInsert (final String sUnused, final Object oValue) {
+		if (oValue instanceof A) {
+			A link = (A) oValue;
+			return insertA(link);
+		}
+		if (oValue instanceof Img) {
+			Img image = (Img) oValue;
+			return insertImg(image);
+		}
+		if (oValue instanceof Code) {
+			Code code = (Code) oValue;
+			return insertCode(code);
+		}
+		return EscapeXMLEntities.escapeText(oValue.toString());
+	}
+	
+	private Object insertA (final A aLink) {
+		String sResultat = "<a href=\"" + EscapeXMLEntities.escapeText(aLink.getHref()) + "\">";
+		for (final Object oElement : aLink.getContent()) {
+			if (oElement instanceof Img) {
+				sResultat += insertImg((Img) oElement);
+			}
+			else {				
+				sResultat += EscapeXMLEntities.escapeText(oElement.toString());
+			}
+		}
+		sResultat += "</a>";
+		return sResultat;
+	}
+	
+	private Object insertCode (final Code aCode) {
+		String sResultat = "<code>";
+		for (final Object oElement : aCode.getContent()) {			
+			if (oElement instanceof A) {
+				sResultat += insertA((A) oElement);			
+			}
+			else if(oElement instanceof Img) {
+				sResultat += insertImg((Img) oElement);
+			}
+			else {
+				sResultat += EscapeXMLEntities.escapeText(oElement.toString());
+			}
+		}
+		sResultat += "</code>";
+		return sResultat;
+	}
+
+	/**
+	 * @param img
+	 * @return
+	 */
+	private String insertImg (final Img aImage) {
+		return "<img src=\"" + EscapeXMLEntities.escapeText(aImage.getSrc())
+		+ "\" alt=\"" + EscapeXMLEntities.escapeText(aImage.getAlt())
+		+ "\"/>";
+	}
+
+}
Received on Thursday, 29 November 2007 14:12:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:54:59 GMT