object. */
XMultiComponentFactory xmulticomponentfactory =
xcomponentcontext.getServiceManager();
// Querying for the interface XSet on XMultiComponentFactory
XSet xsetMultiComponentFactory = ( XSet ) UnoRuntime.queryInterface(
XSet.class, xmulticomponentfactory );
// Getting the XSingleServiceFactory for the Car component
XSingleServiceFactory xsingleservicefactoryCar =
Car.__getServiceFactory( "Car$_Car", ( XMultiServiceFactory )
UnoRuntime.queryInterface( XMultiServiceFactory.class,
xmulticomponentfactory ), null );
// Inserting the XSingleServiceFactory into the container
xsetMultiComponentFactory.insert( xsingleservicefactoryCar );
// Creating an instance of the Car component
Object objectCar = xmulticomponentfactory.createInstanceWithContext(
"org.OpenOffice.Car", xcomponentcontext );
// Querying for the interface XAccelerationControl
XAccelerationControl xaccelerationcontrol = ( XAccelerationControl )
UnoRuntime.queryInterface( XAccelerationControl.class, objectCar );
// Print the current speed
System.out.println( "Current speed: " + Car._Car.getCurrentSpeed() );
// Speed up
xaccelerationcontrol.speedUp( 123.55 );
// Print the current speed
System.out.println( "Current speed: " + Car._Car.getCurrentSpeed() );
// Slow down
xaccelerationcontrol.slowDown( 112.43 );
// Print the current speed
System.out.println( "Current speed: " + Car._Car.getCurrentSpeed() );
// Querying for the interface XDrivingDirection
XDrivingDirection xdrivingdirection = ( XDrivingDirection )
UnoRuntime.queryInterface( XDrivingDirection.class, objectCar );
// Print the current angle
System.out.println( "Current angle: " + Car._Car.getCurrentAngle() );
// Changing the direction
xdrivingdirection.turnLeft( 100 );
// Print the current angle
System.out.println( "Current angle: " + Car._Car.getCurrentAngle() );
xdrivingdirection.turnRight( 150 );
// Print the current angle
System.out.println( "Current angle: " + Car._Car.getCurrentAngle() );
// Querying for the interface XPropertySet
XPropertySet xpropertysetCar = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class, objectCar );
// Setting the number of seats
xpropertysetCar.setPropertyValue( "Seats", new Short( ( short ) 5 ) );
// Print the number of seats
System.out.println( "Number of seats: " +
xpropertysetCar.getPropertyValue( "Seats" ) );
// Setting the color of the car
xpropertysetCar.setPropertyValue( "Color", new Long( ( long ) 232 ) );
// Print the color of the car
System.out.println( "Color of the car: " +
xpropertysetCar.getPropertyValue( "Color" ) );
// Get properties from the car.
XPropertySetInfo xpropertysetinfo = xpropertysetCar.getPropertySetInfo();
// Print the number of the color of the car.
System.out.println( "Color of the car: " +
xpropertysetinfo.getPropertyByName( "Color" ).Attributes );
// Removing the XSingleServiceFactory of Car from the container
xsetMultiComponentFactory.remove( xsingleservicefactoryCar );
System.exit(0);
}
catch( Exception exception ) {
System.err.println( exception );