You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/03/06 11:26:56 UTC

svn commit: r634208 - in /xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java: META-INF/services/ org/apache/fop/fo/

Author: jeremias
Date: Thu Mar  6 02:26:52 2008
New Revision: 634208

URL: http://svn.apache.org/viewvc?rev=634208&view=rev
Log:
Improved context gathering.
Moved GatherContextInfoFunction to an inner class of FONode to reduce visibilities.

Removed:
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java
Modified:
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONode.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat%24Function?rev=634208&r1=634207&r2=634208&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function Thu Mar  6 02:26:52 2008
@@ -1 +1 @@
-org.apache.fop.fo.FONodeGatherContextInfoFunction
+org.apache.fop.fo.FONode$GatherContextInfoFunction

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONode.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONode.java?rev=634208&r1=634207&r2=634208&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONode.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONode.java Thu Mar  6 02:26:52 2008
@@ -21,6 +21,7 @@
 
 // Java
 import java.util.ListIterator;
+import java.util.Map;
 import java.util.NoSuchElementException;
 
 import org.xml.sax.Attributes;
@@ -40,6 +41,7 @@
 import org.apache.fop.fo.pagination.Root;
 import org.apache.fop.util.CharUtilities;
 import org.apache.fop.util.ContentHandlerFactory;
+import org.apache.fop.util.text.AdvancedMessageFormat.Function;
 
 /**
  * Base class for nodes in the XML tree
@@ -600,10 +602,11 @@
      * Returns a String containing as some context information about a node. It does not take the
      * locator into consideration and returns null if no useful context information can be found.
      * Call this method only in exceptional conditions because this method may perform quite
-     * extensive information gathering inside the FO tree.
-     * @return a String containing 
+     * extensive information gathering inside the FO tree. All text returned by this method that
+     * is not extracted from document content needs to be locale-independent.
+     * @return a String containing context information
      */
-    public String getContextInfoAlt() {
+    protected String getContextInfoAlt() {
         String s = gatherContextInfo();
         if (s != null) {
             StringBuffer sb = new StringBuffer();
@@ -617,6 +620,29 @@
             return sb.toString();
         } else {
             return null;
+        }
+    }
+    
+    /** Function for AdvancedMessageFormat to retrieve context info from an FONode. */
+    public static class GatherContextInfoFunction implements Function {
+
+        /** {@inheritDoc} */
+        public Object evaluate(Map params) {
+            Object obj = params.get("source");
+            if (obj instanceof PropertyList) {
+                PropertyList propList = (PropertyList)obj;
+                obj = propList.getFObj();
+            }
+            if (obj instanceof FONode) {
+                FONode node = (FONode)obj;
+                return node.getContextInfoAlt();
+            }
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        public Object getName() {
+            return "gatherContextInfo";
         }
     }
     

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java?rev=634208&r1=634207&r2=634208&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FObj.java Thu Mar  6 02:26:52 2008
@@ -373,6 +373,33 @@
     }
 
     /** {@inheritDoc} */
+    protected String getContextInfoAlt() {
+        StringBuffer sb = new StringBuffer();
+        if (getLocalName() != null) {
+            sb.append(getName());
+            sb.append(", ");
+        }
+        if (hasId()) {
+            sb.append("id=").append(getId());
+            return sb.toString();
+        }
+        String s = gatherContextInfo();
+        if (s != null) {
+            sb.append("\"");
+            if (s.length() < 32) {
+                sb.append(s);
+            } else {
+                sb.append(s.substring(0, 32));
+                sb.append("...");
+            }
+            sb.append("\"");
+            return sb.toString();
+        } else {
+            return null;
+        }
+    }
+    
+    /** {@inheritDoc} */
     protected String gatherContextInfo() {
         if (getLocator() != null) {
             return super.gatherContextInfo();



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org