summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeter Bernard West <pbwest@apache.org>2004-05-30 06:30:36 +0000
committerPeter Bernard West <pbwest@apache.org>2004-05-30 06:30:36 +0000
commit92744826d617ae847b473609c12ab3858c57b470 (patch)
tree0446bc09a281e4343dec13fa3ef29a671e933772 /src
parent84d03a2b1ca8250d4df4f82e503437daf682ea04 (diff)
downloadxmlgraphics-fop-92744826d617ae847b473609c12ab3858c57b470.tar.gz
xmlgraphics-fop-92744826d617ae847b473609c12ab3858c57b470.zip
Added getLocale()
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197667 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/fo/FONode.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java
index 6297e20d3..bb794b837 100644
--- a/src/java/org/apache/fop/fo/FONode.java
+++ b/src/java/org/apache/fop/fo/FONode.java
@@ -22,6 +22,7 @@ import java.awt.geom.Rectangle2D;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -31,7 +32,9 @@ import org.apache.fop.area.AreaListener;
import org.apache.fop.datastructs.ROBitSet;
import org.apache.fop.datastructs.SyncedNode;
import org.apache.fop.datastructs.TreeException;
+import org.apache.fop.datatypes.CountryType;
import org.apache.fop.datatypes.EnumType;
+import org.apache.fop.datatypes.LanguageType;
import org.apache.fop.datatypes.Numeric;
import org.apache.fop.datatypes.PropertyValue;
import org.apache.fop.datatypes.PropertyValueList;
@@ -607,6 +610,31 @@ public class FONode extends SyncedNode implements AreaListener {
}
/**
+ * Gets the current locale. This is derived from the <code>language</code>
+ * and <code>country</code> properties in effect. Note that no account is
+ * taken of <code>script</code> at this stage.
+ * <p><b>N.B.</b> The initial values of both <code>language</code> and
+ * <code>country</code> are taken from the default <code>Locale</code>
+ * returned bu the JVM. This may be problemattical in the case where a
+ * user sets a <code>language</code> but not a <code>country</code>,
+ * because the <code>Locale</code> returned by this method will use the
+ * default <code>country</code>.
+ *
+ * @return the locale
+ * @throws PropertyException
+ */
+ public Locale getLocale() throws PropertyException {
+ Locale locale = null;
+ // Get the value of the language and country properties
+ PropertyValue pv = getPropertyValue(PropNames.LANGUAGE);
+ String language =
+ LanguageType.getISO639_1Language(
+ getPropertyValue(PropNames.LANGUAGE));
+ String country =
+ CountryType.getCountry(getPropertyValue(PropNames.COUNTRY));
+ return new Locale(language, country);
+ }
+ /**
* Clone the current font size.
* @return a <tt>Numeric</tt> containing the current font size
* @exception PropertyException if current font size is not defined,