pbwest 2004/05/29 23:30:36 Modified: src/java/org/apache/fop/fo Tag: FOP_0-20-0_Alt-Design FONode.java Log: Added getLocale() Revision Changes Path No revision No revision 1.2.2.31 +28 -0 xml-fop/src/java/org/apache/fop/fo/FONode.java Index: FONode.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FONode.java,v retrieving revision 1.2.2.30 retrieving revision 1.2.2.31 diff -u -r1.2.2.30 -r1.2.2.31 --- FONode.java 27 May 2004 15:42:26 -0000 1.2.2.30 +++ FONode.java 30 May 2004 06:30:36 -0000 1.2.2.31 @@ -22,6 +22,7 @@ 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.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; @@ -606,6 +609,31 @@ return EnumType.getEnumValue(wm); } + /** + * 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
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]