Java Code Examples for com.ibm.icu.util.ULocale#setDefault()

The following examples show how to use com.ibm.icu.util.ULocale#setDefault() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateTimePropertyTypeTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testToString( )
{
	assertEquals( null, type.toString( design, propDefn, null ) );

	calendar.set( 2004, Calendar.OCTOBER, 18 );

	ULocale preULocale = ULocale.getDefault( );

	ULocale.setDefault( ULocale.ENGLISH );
	String value = type.toString( design, propDefn, calendar.getTime( ) );
	assertTrue( value.startsWith( "2004-10-18" ) ); //$NON-NLS-1$

	ULocale.setDefault( ULocale.GERMAN );
	value = type.toString( design, propDefn, calendar.getTime( ) );
	assertTrue( value.startsWith( "2004-10-18" ) ); //$NON-NLS-1$

	ULocale.setDefault( preULocale );
}
 
Example 2
Source File: FloatPropertyTypeTest.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void testToXml( )
{
	ULocale preULocale = ULocale.getDefault( );

	ULocale.setDefault( ULocale.GERMAN );
	assertEquals( null, type.toXml( design, propDefn, null ) );
	assertEquals(
			"123.456", type.toXml( design, propDefn, new Double( 123.456d ) ) ); //$NON-NLS-1$
	assertEquals(
			"123456.789", type.toXml( design, propDefn, new Double( "123456.789" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
	ULocale.setDefault( ULocale.ENGLISH );
	assertEquals( null, type.toXml( design, propDefn, null ) );
	assertEquals(
			"123.456", type.toXml( design, propDefn, new Double( 123.456d ) ) ); //$NON-NLS-1$
	assertEquals(
			"123456.789", type.toXml( design, propDefn, new Double( "123456.789" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$

	ULocale.setDefault( preULocale );
}
 
Example 3
Source File: MarkerScript.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void beforeDrawMarkerLine( Axis axis, MarkerLine mLine,
		IChartScriptContext icsc )
{
	ULocale.setDefault( ULocale.US );
	if ( icsc.getULocale( ).equals( ULocale.US ) )
	{
		mLine.getLabel( ).getCaption( ).getColor( ).set( 165, 184, 55 );
		mLine.getLineAttributes( ).getColor( ).set( 165, 184, 55 );
	}
}
 
Example 4
Source File: DesignSessionTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests open design method. Test cases:
 * 
 * <ul>
 * <li>Case1:Open design with null ULocale.
 * <li>Case2:Open design with a given ULocale.
 * <li>Case3:Open design with a given design file.
 * <li>Case4:Retrieve the session from the opened designs.
 * <li>Case5:Check the number of designs which are kept in the session's
 * design list.
 * <li>Case6:Drop a design then check the size of the design list.
 * </ul>
 * 
 * @throws DesignFileException
 */

public void testOpenDesign( ) throws DesignFileException
{
	ULocale defaultULocale = ULocale.getDefault( );
	ULocale.setDefault( ULocale.CHINESE );

	DesignSession session = new DesignSession( null );
	assertEquals( ULocale.CHINESE, CoreTestUtil.getSessionLocale( session ) );

	session = new DesignSession( ULocale.ENGLISH );
	assertEquals( ULocale.ENGLISH, CoreTestUtil.getSessionLocale( session ) );

	ReportDesign design = session.createDesign( null, null );
	assertNotNull( design );
	assertEquals( session, CoreTestUtil.getDesignSession( design ) );

	design = session
			.openDesign( getResource( "input/DesignSessionTest.xml" ).toString( ) ); //$NON-NLS-1$
	assertEquals( session, CoreTestUtil.getDesignSession( design ) );

	design = session
			.openDesign( getResource( "input/DesignSessionTest.xml" ).toString( ) ); //$NON-NLS-1$

	assertEquals( 3, CoreTestUtil.getDesigns( session ).size( ) );
	session.drop( design );
	assertEquals( 2, CoreTestUtil.getDesigns( session ).size( ) );

	design = session.createDesign( "template", null ); //$NON-NLS-1$
	assertEquals( 3, CoreTestUtil.getDesigns( session ).size( ) );

	ULocale.setDefault( defaultULocale );
}
 
Example 5
Source File: Regression_134309.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor
 */
public Regression_134309( )
{
	final PluginSettings ps = PluginSettings.instance( );
	try
	{

		
		//ULocale.setDefault( new ULocale( "ar_YE" ) );

		dRenderer = ps.getDevice( "dv.JPG" );//$NON-NLS-1$

	}
	catch ( ChartException ex )
	{
		ex.printStackTrace( );
	}
	cm = createBarChart( );
	BufferedImage img = new BufferedImage(
			500,
			500,
			BufferedImage.TYPE_INT_ARGB );
	Graphics g = img.getGraphics( );

	Graphics2D g2d = (Graphics2D) g;
	dRenderer.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, g2d );
	dRenderer.setProperty( IDeviceRenderer.FILE_IDENTIFIER, this
			.genOutputFile( OUTPUT )
			  ); //$NON-NLS-1$
	Bounds bo = BoundsImpl.create( 0, 0, 500, 500 );
	bo.scale( 72d / dRenderer.getDisplayServer( ).getDpiResolution( ) );

	Generator gr = Generator.instance( );

	try
	{
		RunTimeContext rtc = new RunTimeContext( );
		rtc.setRightToLeft(true);
		gcs = gr.build(
				dRenderer.getDisplayServer( ),
				cm,
				bo,
				null,
				rtc,
				null );
		gr.render( dRenderer, gcs );
	}
	catch ( ChartException e )
	{
		// TODO Auto-generated catch block
		e.printStackTrace( );
	}
	ULocale.setDefault( new ULocale( "en_US" ) );
}
 
Example 6
Source File: Regression_132783.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructor
 */
public Regression_132783( )
{
	final PluginSettings ps = PluginSettings.instance( );
	try
	{

		 
	//	ULocale.setDefault( new ULocale( "ar_YE" ) );

		dRenderer = ps.getDevice( "dv.JPG" );//$NON-NLS-1$

	}
	catch ( ChartException ex )
	{
		ex.printStackTrace( );
	}
	cm = createMeterChart( );
	BufferedImage img = new BufferedImage(
			500,
			500,
			BufferedImage.TYPE_INT_ARGB );
	Graphics g = img.getGraphics( );

	Graphics2D g2d = (Graphics2D) g;
	dRenderer.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, g2d );
	dRenderer.setProperty( IDeviceRenderer.FILE_IDENTIFIER, this
			.genOutputFile( OUTPUT )
			  ); //$NON-NLS-1$
	Bounds bo = BoundsImpl.create( 0, 0, 500, 500 );
	bo.scale( 72d / dRenderer.getDisplayServer( ).getDpiResolution( ) );

	Generator gr = Generator.instance( );

	try
	{
		 RunTimeContext rtc = new RunTimeContext( );
		 rtc.setRightToLeft(true);
		gcs = gr.build(
				dRenderer.getDisplayServer( ),
				cm,
				bo,
				null,
				rtc,
				null );
		gr.render( dRenderer, gcs );
	}
	catch ( ChartException e )
	{
		// TODO Auto-generated catch block
		e.printStackTrace( );
	}
	ULocale.setDefault( new ULocale( "en_US" ) );
}
 
Example 7
Source File: BirtDateTimeTest.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Test
   public void testWeek( ) throws BirtException
{
	String[] scripts = new String[]{
			"BirtDateTime.week(new Date(2006, 0, 1) )",
			"BirtDateTime.week(new Date(2006, 0, 3) )",
			"BirtDateTime.week(new Date(2006, 0, 7) )",
			"BirtDateTime.week(new Date(2006, 0, 8) )",
			"BirtDateTime.week(new Date(2006, 0, 14))",
			"BirtDateTime.week(\"1855-1-1\")",
			"BirtDateTime.week( new Date(1780, 0, 2))",
			"BirtDateTime.week(new Date(1780, 0, 8))",
			"BirtDateTime.week(new Date(1780, 0, 9))",
			"BirtDateTime.week(new Date(1780, 1, 9))",
			"BirtDateTime.week( new Date(1780, 2, 9))",
			"BirtDateTime.week(new Date(1780, 3, 9, 11, 0, 0) )",
			"BirtDateTime.week(new Date(1780, 4, 9, 23, 0, 0) )"
	};

	int[] values = new int[]{
			1, 1, 1, 2, 2, 1, 2, 2, 3, 7, 11, 16, 20
	};

	for ( int i = 0; i < values.length; i++ )
	{
		assertEquals( ( (Number) cx.evaluateString( scope,
				scripts[i],
				"inline",
				1,
				null ) ).intValue( ), values[i] );
	}
	
	// Test France locale
	ULocale.setDefault( ULocale.FRANCE );
	scripts = new String[]{
			"BirtDateTime.week(new Date(2016, 0, 1) )",
			"BirtDateTime.week(new Date(2016, 0, 3) )",
			"BirtDateTime.week(new Date(2016, 0, 7) )"
	};
	values = new int[]{
			53, 53, 1
	};
	for ( int i = 0; i < values.length; i++ )
	{
		assertEquals( ( (Number) cx.evaluateString( scope,
				scripts[i],
				"inline",
				1,
				null ) ).intValue( ), values[i] );
	}
	
	// Test US Locale
	ULocale.setDefault( ULocale.US );
	values = new int[]{
			1, 2, 2
	};
	for ( int i = 0; i < values.length; i++ )
	{
		assertEquals( ( (Number) cx.evaluateString( scope,
				scripts[i],
				"inline",
				1,
				null ) ).intValue( ), values[i] );
	}
}