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/05 21:58:51 UTC
svn commit: r634027 - in /xmlgraphics/fop/branches/Temp_ProcessingFeedback:
src/java/META-INF/services/ src/java/org/apache/fop/events/
src/java/org/apache/fop/fo/ src/java/org/apache/fop/fo/flow/table/
src/java/org/apache/fop/util/ src/java/org/apache...
Author: jeremias
Date: Wed Mar 5 12:58:35 2008
New Revision: 634027
URL: http://svn.apache.org/viewvc?rev=634027&view=rev
Log:
Moved AdvancedMessageFormat into its own package.
AdvancedMessageFormat got the following added functionality:
- Alternative conditional regions [ bla {field}] -> [ bla {field1}| even more bla {field2}]
- Functions: functions get access to the parameters and they can produce an object that is then formatted ({#gatherContextInfo})
- "if" and "equals" format moved to top-level classes and added by dynamic registration.
EventFormatter now supports includes in the form {{includeName}} so you can include other entries from the resource bundle for better reuse.
Some more events in table code.
Added:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java (with props)
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
- copied, changed from r633855, xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/AdvancedMessageFormat.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java (with props)
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java (with props)
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java (with props)
Removed:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/AdvancedMessageFormat.java
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONode.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/Table.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCaption.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCell.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java
Added: 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=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$Function Wed Mar 5 12:58:35 2008
@@ -0,0 +1 @@
+org.apache.fop.fo.FONodeGatherContextInfoFunction
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat%24ObjectFormatter?rev=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$ObjectFormatter Wed Mar 5 12:58:35 2008
@@ -0,0 +1 @@
+org.apache.fop.util.text.LocatorFormatter
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat%24PartFactory?rev=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.util.text.AdvancedMessageFormat$PartFactory Wed Mar 5 12:58:35 2008
@@ -0,0 +1,2 @@
+org.apache.fop.util.text.IfFieldPart$Factory
+org.apache.fop.util.text.EqualsFieldPart$Factory
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.java Wed Mar 5 12:58:35 2008
@@ -22,15 +22,19 @@
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
-import org.apache.fop.util.AdvancedMessageFormat;
import org.apache.fop.util.XMLResourceBundle;
+import org.apache.fop.util.text.AdvancedMessageFormat;
/**
* Converts events into human-readable, localized messages.
*/
public class EventFormatter {
+ private static final Pattern INCLUDES_PATTERN = Pattern.compile("\\{\\{.+\\}\\}");
+
private static ResourceBundle defaultBundle = XMLResourceBundle.getXMLBundle(
EventFormatter.class.getName(), EventFormatter.class.getClassLoader());
@@ -48,14 +52,42 @@
private static String format(Event event, ResourceBundle bundle) {
String template = bundle.getString(event.getEventID());
- return format(event, template);
+ return format(event, processIncludes(template, bundle));
+ }
+
+ private static String processIncludes(String template, ResourceBundle bundle) {
+ CharSequence input = template;
+ int replacements;
+ StringBuffer sb;
+ do {
+ sb = new StringBuffer(Math.max(16, input.length()));
+ replacements = processIncludesInner(input, sb, bundle);
+ input = sb;
+ } while (replacements > 0);
+ String s = sb.toString();
+ return s;
+ }
+
+ private static int processIncludesInner(CharSequence template, StringBuffer sb,
+ ResourceBundle bundle) {
+ int replacements = 0;
+ Matcher m = INCLUDES_PATTERN.matcher(template);
+ while (m.find()) {
+ String include = m.group();
+ include = include.substring(2, include.length() - 2);
+ m.appendReplacement(sb, bundle.getString(include));
+ replacements++;
+ }
+ m.appendTail(sb);
+ return replacements;
}
public static String format(Event event, String pattern) {
AdvancedMessageFormat format = new AdvancedMessageFormat(pattern);
Map params = new java.util.HashMap(event.getParams());
+ params.put("source", event.getSource());
params.put("severity", event.getSeverity());
- return format.format(event.getParams());
+ return format.format(params);
}
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml Wed Mar 5 12:58:35 2008
@@ -17,20 +17,23 @@
-->
<!-- $Id$ -->
<catalogue xml:lang="en">
- <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.[ See position {loc}.]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"![ See position {loc}.]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child element of "{elementName}"![ {ruleViolated}][ See position {loc}.]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.missingChildElement">"{elementName}" is missing child elements.
-Required content model: {contentModel}[ See position {loc}.]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.missingProperty">Element "{elementName}" is missing required property "{propertyName}"![ See position {loc}.]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.idNotUnique">Property ID "{id}" (found on "{elementName}") previously used; ID values must be unique within a document!{severity,equals,EventSeverity:FATAL,,
-Any reference to it will be considered a reference to the first occurrence in the document.}[ See position {loc}.]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.markerNotInitialChild">fo:marker must be an initial child: {mcname}[ (See position {loc}.)]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.markerNotUniqueForSameParent">fo:marker "marker-class-name" must be unique for same parent: {mcname}[ (See position {loc}.)]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.invalidProperty">Invalid property encountered on "{elementName}": {attr}[ (See position {loc}.)]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.invalidPropertyValue">Invalid property value encountered in {propName}="{propValue}"[: {e}][ (See position {loc}.)]</message>
- <message key="org.apache.fop.fo.FOValidationEventProducer.unimplementedFeature">The following feature isn't implemented by Apache FOP, yet: {feature}[ (See position {loc}.)]</message>
- <message key="org.apache.fop.fo.flow.table.TableEventProducer.nonAutoBPDOnTable">Only a value of "auto" for block-progression-dimension has a well-specified behavior on fo:table. Falling back to "auto".</message>
- <message key="org.apache.fop.fo.flow.table.TableEventProducer.noTablePaddingWithCollapsingBorderModel">In collapsing border model a table does not have padding (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders), but a non-zero value for padding was found. The padding will be ignored.</message>
- <message key="org.apache.fop.fo.flow.table.TableEventProducer.noMixRowsAndCells">Either fo:table-rows or fo:table-cells may be children of an {elementName} but not both.[ (See position {loc}.)]</message>
+ <message key="locator">[ (See position {loc})| (See {#gatherContextInfo})| (No context info available)]</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child element of "{elementName}"![ {ruleViolated}]{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.missingChildElement">"{elementName}" is missing child elements.
+Required content model: {contentModel}{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.missingProperty">Element "{elementName}" is missing required property "{propertyName}"!{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.idNotUnique">Property ID "{id}" (found on "{elementName}") previously used; ID values must be unique within a document!{severity,equals,EventSeverity:FATAL,,
+Any reference to it will be considered a reference to the first occurrence in the document.}{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.markerNotInitialChild">fo:marker must be an initial child: {mcname}{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.markerNotUniqueForSameParent">fo:marker "marker-class-name" must be unique for same parent: {mcname}{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.invalidProperty">Invalid property encountered on "{elementName}": {attr}{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.invalidPropertyValue">Invalid property value encountered in {propName}="{propValue}"[: {e}]{{locator}}</message>
+ <message key="org.apache.fop.fo.FOValidationEventProducer.unimplementedFeature">The following feature isn't implemented by Apache FOP, yet: {feature}{{locator}}</message>
+ <message key="org.apache.fop.fo.flow.table.TableEventProducer.nonAutoBPDOnTable">Only a value of "auto" for block-progression-dimension has a well-specified behavior on fo:table. Falling back to "auto".{{locator}}</message>
+ <message key="org.apache.fop.fo.flow.table.TableEventProducer.noTablePaddingWithCollapsingBorderModel">In collapsing border model a table does not have padding (see http://www.w3.org/TR/REC-CSS2/tables.html#collapsing-borders), but a non-zero value for padding was found. The padding will be ignored.{{locator}}</message>
+ <message key="org.apache.fop.fo.flow.table.TableEventProducer.noMixRowsAndCells">Either fo:table-rows or fo:table-cells may be children of an {elementName} but not both.{{locator}}</message>
+ <message key="org.apache.fop.fo.flow.table.TableEventProducer.footerOrderCannotRecover">This table uses the collapsing border model. In order to resolve borders in an efficient way the table-footer must be known before any table-body is parsed. Either put the footer at the correct place or switch to the separate border model.{{locator}}</message>
+ <message key="org.apache.fop.fo.flow.table.TableEventProducer.startEndRowUnderTableRowWarning">starts-row/ends-row for fo:table-cells non-applicable for children of an fo:table-row.{{locator}}</message>
</catalogue>
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=634027&r1=634026&r2=634027&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 Wed Mar 5 12:58:35 2008
@@ -430,8 +430,22 @@
*/
protected void nodesOutOfOrderError(Locator loc, String tooLateNode,
String tooEarlyNode) throws ValidationException {
+ nodesOutOfOrderError(loc, tooLateNode, tooEarlyNode, false);
+ }
+
+ /**
+ * Helper function to standardize "out of order" exceptions
+ * (e.g., fo:layout-master-set appearing after fo:page-sequence)
+ * @param loc org.xml.sax.Locator object of the error (*not* parent node)
+ * @param tooLateNode string name of node that should be earlier in document
+ * @param tooEarlyNode string name of node that should be later in document
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @throws ValidationException the validation error provoked by the method call
+ */
+ protected void nodesOutOfOrderError(Locator loc, String tooLateNode,
+ String tooEarlyNode, boolean canRecover) throws ValidationException {
getFOValidationEventProducer().nodeOutOfOrder(this, getName(),
- tooLateNode, tooEarlyNode, loc);
+ tooLateNode, tooEarlyNode, canRecover, loc);
}
/**
@@ -552,9 +566,10 @@
/**
* Returns a String containing as much context information as possible about a node. Call
- * this methods only in exceptional conditions because this method may perform quite extensive
+ * this method only in exceptional conditions because this method may perform quite extensive
* information gathering inside the FO tree.
- * @return a String containing
+ * @return a String containing context information
+ * @deprecated Not localized! Should rename getContextInfoAlt() to getContextInfo() when done!
*/
public String getContextInfo() {
StringBuffer sb = new StringBuffer();
@@ -579,6 +594,30 @@
sb.setLength(80);
}
return sb.toString();
+ }
+
+ /**
+ * 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
+ */
+ public String getContextInfoAlt() {
+ String s = gatherContextInfo();
+ if (s != null) {
+ StringBuffer sb = new StringBuffer();
+ if (getLocalName() != null) {
+ sb.append(getName());
+ sb.append(", ");
+ }
+ sb.append("\"");
+ sb.append(s);
+ sb.append("\"");
+ return sb.toString();
+ } else {
+ return null;
+ }
}
/**
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java?rev=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java Wed Mar 5 12:58:35 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo;
+
+import java.util.Map;
+
+import org.apache.fop.util.text.AdvancedMessageFormat;
+import org.apache.fop.util.text.AdvancedMessageFormat.Function;
+
+public class FONodeGatherContextInfoFunction 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";
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FONodeGatherContextInfoFunction.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventProducer.java Wed Mar 5 12:58:35 2008
@@ -66,10 +66,12 @@
* @param elementName the name of the context node
* @param tooLateNode string name of node that should be earlier in document
* @param tooEarlyNode string name of node that should be later in document
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
* @param loc the location of the error or null
* @throws ValidationException the validation error provoked by the method call
*/
- void nodeOutOfOrder(Object source, String elementName, String tooLateNode, String tooEarlyNode,
+ void nodeOutOfOrder(Object source, String elementName,
+ String tooLateNode, String tooEarlyNode, boolean canRecover,
Locator loc) throws ValidationException;
/**
@@ -124,17 +126,6 @@
Locator loc) throws ValidationException;
/**
- * An id was used twice in a document.
- * @param source the event source
- * @param elementName the name of the context node
- * @param id the id that was reused
- * @param loc the location of the error or null
- * @event.severity WARN
- *//*
- void idNotUniqueWarning(Object source, String elementName, String id, Locator loc);
- */
-
- /**
* A marker is not an initial child on a node.
* @param source the event source
* @param elementName the name of the context node
@@ -167,17 +158,6 @@
*/
void invalidProperty(Object source, String elementName, QName attr, boolean canRecover,
Locator loc) throws ValidationException;
-
- /**
- * An invalid property was encountered.
- * @param source the event source
- * @param elementName the name of the context node
- * @param attr the invalid attribute
- * @param loc the location of the error or null
- * @event.severity WARN
- *//*
- void invalidPropertyWarning(Object source, String elementName, QName attr,
- Locator loc);*/
/**
* An invalid property value was encountered.
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/Table.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/Table.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/Table.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/Table.java Wed Mar 5 12:58:35 2008
@@ -196,15 +196,11 @@
} else {
tableFooterFound = true;
if (tableBodyFound) {
- if (getUserAgent().validateStrictly()) {
- nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)");
- } else if (!isSeparateBorderModel()) {
- nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)."
- + " This table uses the collapsing border"
- + " model. In order to resolve borders in an efficient way"
- + " the table-footer must be known before any table-body"
- + " is parsed. Either put the footer at the correct place"
- + " or switch to the separate border model");
+ nodesOutOfOrderError(loc, "fo:table-footer", "(table-body+)", true);
+ if (!isSeparateBorderModel()) {
+ TableEventProducer eventProducer = TableEventProducer.Factory.create(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.footerOrderCannotRecover(this, getName(), getLocator());
}
}
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCaption.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCaption.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCaption.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCaption.java Wed Mar 5 12:58:35 2008
@@ -57,7 +57,8 @@
super(parent);
if (!notImplementedWarningGiven) {
- log.warn("fo:table-caption is not yet implemented.");
+ getFOValidationEventProducer().unimplementedFeature(this, getName(),
+ "fo:table-caption", getLocator());
notImplementedWarningGiven = true;
}
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCell.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCell.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCell.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableCell.java Wed Mar 5 12:58:35 2008
@@ -102,17 +102,13 @@
*/
public void endOfNode() throws FOPException {
if (!blockItemFound) {
- if (getUserAgent().validateStrictly()) {
- missingChildElementError("marker* (%block;)+");
- } else if (firstChild != null) {
- log.warn("fo:table-cell content that is not "
- + "enclosed by a fo:block will be dropped/ignored.");
- }
+ missingChildElementError("marker* (%block;)+", true);
}
if ((startsRow() || endsRow())
&& getParent().getNameId() == FO_TABLE_ROW ) {
- log.warn("starts-row/ends-row for fo:table-cells "
- + "non-applicable for children of an fo:table-row.");
+ TableEventProducer eventProducer = TableEventProducer.Factory.create(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.startEndRowUnderTableRowWarning(this, getLocator());
}
getFOEventHandler().endCell(this);
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/table/TableEventProducer.java Wed Mar 5 12:58:35 2008
@@ -72,5 +72,26 @@
*/
void noMixRowsAndCells(Object source, String elementName, Locator loc)
throws ValidationException;
+
+ /**
+ * The table-footer was found after the table-body. FOP cannot recover with collapsed border
+ * model.
+ * @param source the event source
+ * @param elementName the name of the context node
+ * @param loc the location of the error or null
+ * @throws ValidationException the validation error provoked by the method call
+ * @event.severity FATAL
+ */
+ void footerOrderCannotRecover(Object source, String elementName, Locator loc)
+ throws ValidationException;
+
+ /**
+ * starts-row/ends-row for fo:table-cells non-applicable for children of an fo:table-row
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void startEndRowUnderTableRowWarning(Object source, Locator loc);
+
}
Copied: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java (from r633855, xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/AdvancedMessageFormat.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java?p2=xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java&p1=xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/AdvancedMessageFormat.java&r1=633855&r2=634027&rev=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/AdvancedMessageFormat.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java Wed Mar 5 12:58:35 2008
@@ -17,13 +17,14 @@
/* $Id$ */
-package org.apache.fop.util;
+package org.apache.fop.util.text;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.xml.sax.Locator;
+import org.apache.xmlgraphics.util.Service;
+
/**
* Formats messages based on a template and with a set of named parameters. This is similar to
@@ -41,9 +42,33 @@
*/
public class AdvancedMessageFormat {
- private static final String COMMA_SEPARATOR_REGEX = "(?<!\\\\),";
+ /** Regex that matches "," but not "\," (escaped comma) */
+ static final String COMMA_SEPARATOR_REGEX = "(?<!\\\\),";
+
+ private static final Map PART_FACTORIES = new java.util.HashMap();
+ private static final List OBJECT_FORMATTERS = new java.util.ArrayList();
+ private static final Map FUNCTIONS = new java.util.HashMap();
+
private CompositePart rootPart;
+ static {
+ Iterator iter;
+ iter = Service.providers(PartFactory.class, true);
+ while (iter.hasNext()) {
+ PartFactory factory = (PartFactory)iter.next();
+ PART_FACTORIES.put(factory.getFormat(), factory);
+ }
+ iter = Service.providers(ObjectFormatter.class, true);
+ while (iter.hasNext()) {
+ OBJECT_FORMATTERS.add((ObjectFormatter)iter.next());
+ }
+ iter = Service.providers(Function.class, true);
+ while (iter.hasNext()) {
+ Function function = (Function)iter.next();
+ FUNCTIONS.put(function.getName(), function);
+ }
+ }
+
/**
* Construct a new message format.
* @param pattern the message format pattern.
@@ -98,6 +123,14 @@
parent.addChild(composite);
i += parseInnerPattern(pattern, composite, sb, i);
break;
+ case '|':
+ if (sb.length() > 0) {
+ parent.addChild(new TextPart(sb.toString()));
+ sb.setLength(0);
+ }
+ parent.newSection();
+ i++;
+ break;
case '\\':
if (i < len - 1) {
i++;
@@ -118,22 +151,31 @@
private Part parseField(String field) {
String[] parts = field.split(COMMA_SEPARATOR_REGEX, 3);
+ String fieldName = parts[0];
if (parts.length == 1) {
- return new SimpleFieldPart(parts[0]);
+ if (fieldName.startsWith("#")) {
+ return new FunctionPart(fieldName.substring(1));
+ } else {
+ return new SimpleFieldPart(fieldName);
+ }
} else {
String format = parts[1];
if (parts.length == 2) {
throw new IllegalArgumentException("Pattern must have three parts!");
}
- if ("if".equals(format)) {
- return new IfFieldPart(parts[0], parts[2]);
- } else if ("equals".equals(format)) {
- return new EqualsFieldPart(parts[0], parts[2]);
+ PartFactory factory = (PartFactory)PART_FACTORIES.get(format);
+ if (factory == null) {
+ throw new IllegalArgumentException(
+ "No PartFactory available under the name: " + format);
}
- return new SimpleFieldPart(parts[0]);
+ return factory.newPart(fieldName, parts[2]);
}
}
+ private static Function getFunction(String functionName) {
+ return (Function)FUNCTIONS.get(functionName);
+ }
+
/**
* Formats a message with the given parameters.
* @param params a Map of named parameters (Contents: <String, Object>)
@@ -145,16 +187,26 @@
return sb.toString();
}
- private interface Part {
+ public interface Part {
void write(StringBuffer sb, Map params);
boolean isGenerated(Map params);
}
- private interface ObjectFormatter {
+ public interface PartFactory {
+ Part newPart(String fieldName, String values);
+ String getFormat();
+ }
+
+ public interface ObjectFormatter {
void format(StringBuffer sb, Object obj);
boolean supportsObject(Object obj);
}
+ public interface Function {
+ Object evaluate(Map params);
+ Object getName();
+ }
+
private static class TextPart implements Part {
private String text;
@@ -179,12 +231,6 @@
private static class SimpleFieldPart implements Part {
- private static final List OBJECT_FORMATTERS = new java.util.ArrayList();
-
- static {
- OBJECT_FORMATTERS.add(new LocatorFormatter());
- }
-
private String fieldName;
public SimpleFieldPart(String fieldName) {
@@ -197,23 +243,7 @@
"Message pattern contains unsupported field name: " + fieldName);
}
Object obj = params.get(fieldName);
- if (obj instanceof String) {
- sb.append(obj);
- } else {
- boolean handled = false;
- Iterator iter = OBJECT_FORMATTERS.iterator();
- while (iter.hasNext()) {
- ObjectFormatter formatter = (ObjectFormatter)iter.next();
- if (formatter.supportsObject(obj)) {
- formatter.format(sb, obj);
- handled = true;
- break;
- }
- }
- if (!handled) {
- sb.append(obj.toString());
- }
- }
+ formatObject(obj, sb);
}
public boolean isGenerated(Map params) {
@@ -227,131 +257,134 @@
}
}
- private static class IfFieldPart implements Part {
-
- protected String fieldName;
- protected String ifValue;
- protected String elseValue;
-
- public IfFieldPart(String fieldName, String values) {
- this.fieldName = fieldName;
- parseValues(values);
- }
-
- protected void parseValues(String values) {
- String[] parts = values.split(COMMA_SEPARATOR_REGEX, 2);
- if (parts.length == 2) {
- ifValue = unescapeComma(parts[0]);
- elseValue = unescapeComma(parts[1]);
- } else {
- ifValue = unescapeComma(values);
- }
- }
-
- public void write(StringBuffer sb, Map params) {
- boolean isTrue = isTrue(params);
- if (isTrue) {
- sb.append(ifValue);
- } else if (elseValue != null) {
- sb.append(elseValue);
+ public static void formatObject(Object obj, StringBuffer target) {
+ if (obj instanceof String) {
+ target.append(obj);
+ } else {
+ boolean handled = false;
+ Iterator iter = OBJECT_FORMATTERS.iterator();
+ while (iter.hasNext()) {
+ ObjectFormatter formatter = (ObjectFormatter)iter.next();
+ if (formatter.supportsObject(obj)) {
+ formatter.format(target, obj);
+ handled = true;
+ break;
+ }
}
- }
-
- protected boolean isTrue(Map params) {
- Object obj = params.get(fieldName);
- boolean isTrue;
- if (obj instanceof Boolean) {
- return ((Boolean)obj).booleanValue();
- } else {
- return (obj != null);
+ if (!handled) {
+ target.append(obj.toString());
}
}
-
- public boolean isGenerated(Map params) {
- return isTrue(params) || (elseValue != null);
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return "{" + this.fieldName + ", if...}";
- }
}
- private static class EqualsFieldPart extends IfFieldPart {
+ private static class FunctionPart implements Part {
- private String equalsValue;
+ private Function function;
- public EqualsFieldPart(String fieldName, String values) {
- super(fieldName, values);
- }
-
- /** {@inheritDoc} */
- protected void parseValues(String values) {
- String[] parts = values.split(COMMA_SEPARATOR_REGEX, 3);
- this.equalsValue = parts[0];
- if (parts.length == 1) {
- throw new IllegalArgumentException(
- "'equals' format must have at least 2 parameters");
- }
- if (parts.length == 3) {
- ifValue = unescapeComma(parts[1]);
- elseValue = unescapeComma(parts[2]);
- } else {
- ifValue = unescapeComma(parts[1]);
+ public FunctionPart(String functionName) {
+ this.function = getFunction(functionName);
+ if (this.function == null) {
+ throw new IllegalArgumentException("Unknown function: " + functionName);
}
}
- protected boolean isTrue(Map params) {
- Object obj = params.get(fieldName);
- if (obj != null) {
- return String.valueOf(obj).equals(this.equalsValue);
- } else {
- return false;
- }
+ public void write(StringBuffer sb, Map params) {
+ Object obj = this.function.evaluate(params);
+ formatObject(obj, sb);
}
+ public boolean isGenerated(Map params) {
+ Object obj = this.function.evaluate(params);
+ return obj != null;
+ }
+
/** {@inheritDoc} */
public String toString() {
- return "{" + this.fieldName + ", equals " + this.equalsValue + "}";
+ return "{#" + this.function.getName() + "}";
}
-
}
-
private static class CompositePart implements Part {
- private List parts = new java.util.ArrayList();
+ protected List parts = new java.util.ArrayList();
private boolean conditional;
+ private boolean hasSections = false;
public CompositePart(boolean conditional) {
this.conditional = conditional;
}
+ private CompositePart(List parts) {
+ this.parts.addAll(parts);
+ this.conditional = true;
+ }
+
public void addChild(Part part) {
- this.parts.add(part);
+ if (part == null) {
+ throw new NullPointerException("part must not be null");
+ }
+ if (hasSections) {
+ CompositePart composite = (CompositePart)this.parts.get(this.parts.size() - 1);
+ composite.addChild(part);
+ } else {
+ this.parts.add(part);
+ }
}
-
+
+ public void newSection() {
+ if (!hasSections) {
+ List p = this.parts;
+ //Dropping into a different mode...
+ this.parts = new java.util.ArrayList();
+ this.parts.add(new CompositePart(p));
+ hasSections = true;
+ }
+ this.parts.add(new CompositePart(true));
+ }
+
public void write(StringBuffer sb, Map params) {
- if (isGenerated(params)) {
+ if (hasSections) {
Iterator iter = this.parts.iterator();
while (iter.hasNext()) {
- Part part = (Part)iter.next();
- part.write(sb, params);
+ CompositePart part = (CompositePart)iter.next();
+ if (part.isGenerated(params)) {
+ part.write(sb, params);
+ break;
+ }
+ }
+ } else {
+ if (isGenerated(params)) {
+ Iterator iter = this.parts.iterator();
+ while (iter.hasNext()) {
+ Part part = (Part)iter.next();
+ part.write(sb, params);
+ }
}
}
}
public boolean isGenerated(Map params) {
- if (conditional) {
+ if (hasSections) {
Iterator iter = this.parts.iterator();
while (iter.hasNext()) {
Part part = (Part)iter.next();
- if (!part.isGenerated(params)) {
- return false;
+ if (part.isGenerated(params)) {
+ return true;
}
}
+ return false;
+ } else {
+ if (conditional) {
+ Iterator iter = this.parts.iterator();
+ while (iter.hasNext()) {
+ Part part = (Part)iter.next();
+ if (!part.isGenerated(params)) {
+ return false;
+ }
+ }
+ }
+ return true;
}
- return true;
}
/** {@inheritDoc} */
@@ -360,20 +393,8 @@
}
}
- private static class LocatorFormatter implements ObjectFormatter {
-
- public void format(StringBuffer sb, Object obj) {
- Locator loc = (Locator)obj;
- sb.append(loc.getLineNumber()).append(":").append(loc.getColumnNumber());
- }
-
- public boolean supportsObject(Object obj) {
- return obj instanceof Locator;
- }
-
- }
-
- private static String unescapeComma(String string) {
+
+ static String unescapeComma(String string) {
return string.replaceAll("\\\\,", ",");
}
}
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java?rev=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java Wed Mar 5 12:58:35 2008
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.util.text;
+
+import java.util.Map;
+
+import org.apache.fop.util.text.AdvancedMessageFormat.Part;
+import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory;
+
+public class EqualsFieldPart extends IfFieldPart {
+
+ private String equalsValue;
+
+ public EqualsFieldPart(String fieldName, String values) {
+ super(fieldName, values);
+ }
+
+ /** {@inheritDoc} */
+ protected void parseValues(String values) {
+ String[] parts = values.split(AdvancedMessageFormat.COMMA_SEPARATOR_REGEX, 3);
+ this.equalsValue = parts[0];
+ if (parts.length == 1) {
+ throw new IllegalArgumentException(
+ "'equals' format must have at least 2 parameters");
+ }
+ if (parts.length == 3) {
+ ifValue = AdvancedMessageFormat.unescapeComma(parts[1]);
+ elseValue = AdvancedMessageFormat.unescapeComma(parts[2]);
+ } else {
+ ifValue = AdvancedMessageFormat.unescapeComma(parts[1]);
+ }
+ }
+
+ protected boolean isTrue(Map params) {
+ Object obj = params.get(fieldName);
+ if (obj != null) {
+ return String.valueOf(obj).equals(this.equalsValue);
+ } else {
+ return false;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "{" + this.fieldName + ", equals " + this.equalsValue + "}";
+ }
+
+ public static class Factory implements PartFactory {
+
+ /** {@inheritDoc} */
+ public Part newPart(String fieldName, String values) {
+ return new EqualsFieldPart(fieldName, values);
+ }
+
+ /** {@inheritDoc} */
+ public String getFormat() {
+ return "equals";
+ }
+
+ }
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java?rev=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java Wed Mar 5 12:58:35 2008
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.util.text;
+
+import java.util.Map;
+
+import org.apache.fop.util.text.AdvancedMessageFormat.Part;
+import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory;
+
+public class IfFieldPart implements Part {
+
+ protected String fieldName;
+ protected String ifValue;
+ protected String elseValue;
+
+ public IfFieldPart(String fieldName, String values) {
+ this.fieldName = fieldName;
+ parseValues(values);
+ }
+
+ protected void parseValues(String values) {
+ String[] parts = values.split(AdvancedMessageFormat.COMMA_SEPARATOR_REGEX, 2);
+ if (parts.length == 2) {
+ ifValue = AdvancedMessageFormat.unescapeComma(parts[0]);
+ elseValue = AdvancedMessageFormat.unescapeComma(parts[1]);
+ } else {
+ ifValue = AdvancedMessageFormat.unescapeComma(values);
+ }
+ }
+
+ public void write(StringBuffer sb, Map params) {
+ boolean isTrue = isTrue(params);
+ if (isTrue) {
+ sb.append(ifValue);
+ } else if (elseValue != null) {
+ sb.append(elseValue);
+ }
+ }
+
+ protected boolean isTrue(Map params) {
+ Object obj = params.get(fieldName);
+ if (obj instanceof Boolean) {
+ return ((Boolean)obj).booleanValue();
+ } else {
+ return (obj != null);
+ }
+ }
+
+ public boolean isGenerated(Map params) {
+ return isTrue(params) || (elseValue != null);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "{" + this.fieldName + ", if...}";
+ }
+
+ public static class Factory implements PartFactory {
+
+ /** {@inheritDoc} */
+ public Part newPart(String fieldName, String values) {
+ return new IfFieldPart(fieldName, values);
+ }
+
+ /** {@inheritDoc} */
+ public String getFormat() {
+ return "if";
+ }
+
+ }
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java?rev=634027&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java Wed Mar 5 12:58:35 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.util.text;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.util.text.AdvancedMessageFormat.ObjectFormatter;
+
+public class LocatorFormatter implements ObjectFormatter {
+
+ public void format(StringBuffer sb, Object obj) {
+ Locator loc = (Locator)obj;
+ sb.append(loc.getLineNumber()).append(":").append(loc.getColumnNumber());
+ }
+
+ public boolean supportsObject(Object obj) {
+ return obj instanceof Locator;
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java?rev=634027&r1=634026&r2=634027&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/test/java/org/apache/fop/util/AdvancedMessageFormatTestCase.java Wed Mar 5 12:58:35 2008
@@ -26,6 +26,7 @@
import org.xml.sax.helpers.LocatorImpl;
import org.apache.fop.events.model.EventSeverity;
+import org.apache.fop.util.text.AdvancedMessageFormat;
/**
* Tests for EventFormatter.
@@ -57,6 +58,20 @@
format = new AdvancedMessageFormat(pattern);
msg = format.format(params);
assertEquals("Testing {escaped [characters], now a normal field fo:external-graphic!", msg);
+
+ pattern = "Multi-conditional: [case1: {var1}|case2: {var2}|case3: {var3}]";
+ format = new AdvancedMessageFormat(pattern);
+
+ params = new java.util.HashMap();
+ msg = format.format(params);
+ assertEquals("Multi-conditional: ", msg);
+
+ params.put("var3", "value3");
+ msg = format.format(params);
+ assertEquals("Multi-conditional: case3: value3", msg);
+ params.put("var1", "value1");
+ msg = format.format(params);
+ assertEquals("Multi-conditional: case1: value1", msg);
}
public void testObjectFormatting() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org