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/04/02 10:24:46 UTC

svn commit: r643787 - in /xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text: AdvancedMessageFormat.java EqualsFieldPart.java IfFieldPart.java LocatorFormatter.java

Author: jeremias
Date: Wed Apr  2 01:24:41 2008
New Revision: 643787

URL: http://svn.apache.org/viewvc?rev=643787&view=rev
Log:
Completed javadocs

Modified:
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java
    xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java

Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java?rev=643787&r1=643786&r2=643787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java Wed Apr  2 01:24:41 2008
@@ -204,23 +204,85 @@
         rootPart.write(target, params);
     }
     
+    /**
+     * Represents a message template part. This interface is implemented by various variants of
+     * the single curly braces pattern ({field}, {field,if,yes,no} etc.).
+     */
     public interface Part {
+        
+        /**
+         * Writes the formatted part to a string buffer.
+         * @param sb the target string buffer
+         * @param params the parameters to work with
+         */
         void write(StringBuffer sb, Map params);
+        
+        /**
+         * Indicates whether there is any content that is generated by this message part.
+         * @param params the parameters to work with
+         * @return true if the part has content
+         */
         boolean isGenerated(Map params);
     }
     
+    /**
+     * Implementations of this interface parse a field part and return message parts.
+     */
     public interface PartFactory {
+        
+        /**
+         * Creates a new part by parsing the values parameter to configure the part.
+         * @param fieldName the field name
+         * @param values the unparsed parameter values
+         * @return the new message part
+         */
         Part newPart(String fieldName, String values);
+        
+        /**
+         * Returns the name of the message part format.
+         * @return the name of the message part format
+         */
         String getFormat();
     }
     
+    /**
+     * Implementations of this interface format certain objects to strings.
+     */
     public interface ObjectFormatter {
+        
+        /**
+         * Formats an object to a string and writes the result to a string buffer.
+         * @param sb the target string buffer
+         * @param obj the object to be formatted
+         */
         void format(StringBuffer sb, Object obj);
+        
+        /**
+         * Indicates whether a given object is supported.
+         * @param obj the object
+         * @return true if the object is supported by the formatter
+         */
         boolean supportsObject(Object obj);
     }
     
+    /**
+     * Implementations of this interface do some computation based on the message parameters
+     * given to it. Note: at the moment, this has to be done in a local-independent way since
+     * there is no locale information.
+     */
     public interface Function {
+        
+        /**
+         * Executes the function.
+         * @param params the message parameters
+         * @return the function result
+         */
         Object evaluate(Map params);
+        
+        /**
+         * Returns the name of the function.
+         * @return the name of the function
+         */
         Object getName();
     }
     
@@ -274,6 +336,14 @@
         }
     }
     
+    /**
+     * Formats an object to a string and writes the result to a string buffer. This method
+     * usually uses the object's <code>toString()</code> method unless there is an
+     * {@link ObjectFormatter} that supports the object. {@link ObjectFormatter}s are registered
+     * through the service provider mechanism defined by the JAR specification.
+     * @param obj the object to be formatted
+     * @param target the target string buffer
+     */
     public static void formatObject(Object obj, StringBuffer target) {
         if (obj instanceof String) {
             target.append(obj);

Modified: 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=643787&r1=643786&r2=643787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/EqualsFieldPart.java Wed Apr  2 01:24:41 2008
@@ -24,10 +24,20 @@
 import org.apache.fop.util.text.AdvancedMessageFormat.Part;
 import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory;
 
+/**
+ * Defines an "equals" field part that can compare a field's string value against another string.
+ * It returns either of two possible values attached as additional part parameters. Example:
+ * <code>{field,equals,new,This is new!,This is old!}</code>
+ */
 public class EqualsFieldPart extends IfFieldPart {
     
     private String equalsValue;
     
+    /**
+     * Creates a new "equals" field part.
+     * @param fieldName the field name
+     * @param values the unparsed parameter values
+     */
     public EqualsFieldPart(String fieldName, String values) {
         super(fieldName, values);
     }
@@ -48,6 +58,7 @@
         }
     }
     
+    /** {@inheritDoc} */
     protected boolean isTrue(Map params) {
         Object obj = params.get(fieldName);
         if (obj != null) {
@@ -62,6 +73,9 @@
         return "{" + this.fieldName + ", equals " + this.equalsValue + "}";
     }
     
+    /**
+     * Part factory for "equals".
+     */
     public static class Factory implements PartFactory {
 
         /** {@inheritDoc} */

Modified: 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=643787&r1=643786&r2=643787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/IfFieldPart.java Wed Apr  2 01:24:41 2008
@@ -24,17 +24,34 @@
 import org.apache.fop.util.text.AdvancedMessageFormat.Part;
 import org.apache.fop.util.text.AdvancedMessageFormat.PartFactory;
 
+/**
+ * Defines an "if" field part that checks if field's value is true or false.
+ * It returns either of two possible values attached as additional part parameters. Example:
+ * <code>{field,if,Yes,No}</code>
+ */
 public class IfFieldPart implements Part {
     
+    /** the field name for the part */
     protected String fieldName;
+    /** the value being returned if the field is true */
     protected String ifValue;
+    /** the value being returned if the field is false */
     protected String elseValue;
     
+    /**
+     * Creates a new "if" field part.
+     * @param fieldName the field name
+     * @param values the unparsed parameter values
+     */
     public IfFieldPart(String fieldName, String values) {
         this.fieldName = fieldName;
         parseValues(values);
     }
 
+    /**
+     * Parses the parameter values
+     * @param values the unparsed parameter values
+     */
     protected void parseValues(String values) {
         String[] parts = AdvancedMessageFormat.COMMA_SEPARATOR_REGEX.split(values, 2);
         if (parts.length == 2) {
@@ -45,6 +62,7 @@
         }
     }
     
+    /** {@inheritDoc} */
     public void write(StringBuffer sb, Map params) {
         boolean isTrue = isTrue(params);
         if (isTrue) {
@@ -54,6 +72,12 @@
         }
     }
 
+    /**
+     * Indicates whether the field's value is true. If the field is not a boolen, it is true
+     * if the field is not null.
+     * @param params the message parameters
+     * @return true the field's value as boolean
+     */
     protected boolean isTrue(Map params) {
         Object obj = params.get(fieldName);
         if (obj instanceof Boolean) {
@@ -63,6 +87,7 @@
         }
     }
 
+    /** {@inheritDoc} */
     public boolean isGenerated(Map params) {
         return isTrue(params) || (elseValue != null);
     }
@@ -72,6 +97,9 @@
         return "{" + this.fieldName + ", if...}";
     }
     
+    /**
+     * Part factory for "if".
+     */
     public static class Factory implements PartFactory {
 
         /** {@inheritDoc} */

Modified: 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=643787&r1=643786&r2=643787&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/util/text/LocatorFormatter.java Wed Apr  2 01:24:41 2008
@@ -23,13 +23,18 @@
 
 import org.apache.fop.util.text.AdvancedMessageFormat.ObjectFormatter;
 
+/**
+ * Object formatter for the SAX Locator object.
+ */
 public class LocatorFormatter implements ObjectFormatter {
 
+    /** {@inheritDoc} */
     public void format(StringBuffer sb, Object obj) {
         Locator loc = (Locator)obj;
         sb.append(loc.getLineNumber()).append(":").append(loc.getColumnNumber());
     }
 
+    /** {@inheritDoc} */
     public boolean supportsObject(Object obj) {
         return obj instanceof Locator;
     }



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