diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/Database/RowSet.java')
-rw-r--r-- | odk/examples/DevelopersGuide/Database/RowSet.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/odk/examples/DevelopersGuide/Database/RowSet.java b/odk/examples/DevelopersGuide/Database/RowSet.java index 780aaedf9370..c19dcdc681b7 100644 --- a/odk/examples/DevelopersGuide/Database/RowSet.java +++ b/odk/examples/DevelopersGuide/Database/RowSet.java @@ -77,7 +77,7 @@ public class RowSet public static void printDataSources() throws com.sun.star.uno.Exception { // create a DatabaseContext and print all DataSource names - XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface( + XNameAccess xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext", xContext)); @@ -89,13 +89,13 @@ public class RowSet public static void useRowSet() throws com.sun.star.uno.Exception { // first we create our RowSet object - XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface( + XRowSet xRowRes = UnoRuntime.queryInterface( XRowSet.class, xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext)); System.out.println("RowSet created!"); // set the properties needed to connect to a database - XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes); xProp.setPropertyValue("DataSourceName","Bibliography"); xProp.setPropertyValue("Command","biblio"); xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); @@ -104,7 +104,7 @@ public class RowSet System.out.println("RowSet executed!"); - XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes); + XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes); xComp.dispose(); System.out.println("RowSet destroyed!"); } @@ -112,13 +112,13 @@ public class RowSet public static void showRowSetPrivileges() throws com.sun.star.uno.Exception { // first we create our RowSet object - XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface( + XRowSet xRowRes = UnoRuntime.queryInterface( XRowSet.class, xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext)); System.out.println("RowSet created!"); // set the properties needed to connect to a database - XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes); xProp.setPropertyValue("DataSourceName","Bibliography"); xProp.setPropertyValue("Command","biblio"); xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); @@ -138,7 +138,7 @@ public class RowSet System.out.println("DELETE"); // now destroy the RowSet - XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes); + XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes); xComp.dispose(); System.out.println("RowSet destroyed!"); } @@ -146,13 +146,13 @@ public class RowSet public static void showRowSetRowCount() throws com.sun.star.uno.Exception { // first we create our RowSet object - XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface( + XRowSet xRowRes = UnoRuntime.queryInterface( XRowSet.class, xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext)); System.out.println("RowSet created!"); // set the properties needed to connect to a database - XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes); xProp.setPropertyValue("DataSourceName","Bibliography"); xProp.setPropertyValue("Command","biblio"); xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); @@ -163,14 +163,14 @@ public class RowSet // now look if the RowCount is already final System.out.println("The RowCount is final: " + xProp.getPropertyValue("IsRowCountFinal")); - XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class,xRowRes); + XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class,xRowRes); xRes.last(); System.out.println("The RowCount is final: " + xProp.getPropertyValue("IsRowCountFinal")); System.out.println("There are " + xProp.getPropertyValue("RowCount") + " rows!"); // now destroy the RowSet - XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes); + XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes); xComp.dispose(); System.out.println("RowSet destroyed!"); } @@ -178,7 +178,7 @@ public class RowSet public static void showRowSetEvents() throws com.sun.star.uno.Exception { // first we create our RowSet object - XRowSet xRowRes = (XRowSet)UnoRuntime.queryInterface( + XRowSet xRowRes = UnoRuntime.queryInterface( XRowSet.class, xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext)); @@ -186,12 +186,12 @@ public class RowSet // add our Listener System.out.println("Append our Listener!"); RowSetEventListener pRow = new RowSetEventListener(); - XRowSetApproveBroadcaster xApBroad = (XRowSetApproveBroadcaster)UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class,xRowRes); + XRowSetApproveBroadcaster xApBroad = UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class,xRowRes); xApBroad.addRowSetApproveListener(pRow); xRowRes.addRowSetListener(pRow); // set the properties needed to connect to a database - XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes); + XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes); xProp.setPropertyValue("DataSourceName","Bibliography"); xProp.setPropertyValue("Command","biblio"); xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE)); @@ -200,7 +200,7 @@ public class RowSet System.out.println("RowSet executed!"); // do some movements to check if we got all notifications - XResultSet xRes = (XResultSet)UnoRuntime.queryInterface(XResultSet.class,xRowRes); + XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class,xRowRes); System.out.println("beforeFirst"); xRes.beforeFirst(); // this should lead to no notifications because @@ -226,7 +226,7 @@ public class RowSet System.out.println("We stand after the last row: " + xRes.isAfterLast()); // now destroy the RowSet - XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes); + XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes); xComp.dispose(); System.out.println("RowSet destroyed!"); } |