static XNode[][] toSeqs(XEnumeration i_Enum) throws Exception {
   java.util.Collection<XNode[]> c = new java.util.ArrayList<XNode[]>();
   while (i_Enum.hasMoreElements()) {
     XNode[] s = (XNode[]) i_Enum.nextElement();
     c.add(s);
   }
   Object[] arr = c.toArray();
   XNode[][] ret = new XNode[arr.length][];
   for (int i = 0; i < arr.length; ++i) {
     ret[i] = (XNode[]) arr[i];
   }
   return ret;
 }
 static Statement[] toSeq(XEnumeration i_Enum) throws Exception {
   java.util.Collection<Statement> c = new java.util.ArrayList<Statement>();
   while (i_Enum.hasMoreElements()) {
     Statement s = (Statement) i_Enum.nextElement();
     c.add(s);
   }
   // java sucks
   Object[] arr = c.toArray();
   Statement[] ret = new Statement[arr.length];
   for (int i = 0; i < arr.length; ++i) {
     ret[i] = (Statement) arr[i];
   }
   return ret;
 }
  private XComponent loadRDFa(String file) throws Exception {
    XComponent xComp = null;

    System.out.println("Loading test document...");

    PropertyValue[] loadProps = new PropertyValue[1];
    loadProps[0] = new PropertyValue();
    loadProps[0].Name = "Hidden";
    loadProps[0].Value = true;

    xComp = util.DesktopTools.loadDoc(xMSF, file, loadProps);

    XRepositorySupplier xRepoSupplier = UnoRuntime.queryInterface(XRepositorySupplier.class, xComp);
    assertTrue("xRS null", null != xRepoSupplier);

    XDocumentRepository xDocRepository =
        UnoRuntime.queryInterface(XDocumentRepository.class, xRepoSupplier.getRDFRepository());
    assertTrue("xRep null", null != xDocRepository);

    XTextDocument xTextDoc = UnoRuntime.queryInterface(XTextDocument.class, xComp);

    XText xText = xTextDoc.getText();

    XEnumerationAccess xEA = UnoRuntime.queryInterface(XEnumerationAccess.class, xText);
    XEnumeration xEnum = xEA.createEnumeration();

    System.out.println("...done");

    System.out.println("Checking RDFa in loaded test document...");

    XMetadatable xPara;
    Pair<Statement[], Boolean> result;

    Statement x_FooBarLit1 = new Statement(foo, bar, mkLit("1"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 1", !result.Second && eq(result.First, new Statement[] {x_FooBarLit1}));

    Statement x_FooBarLit2 = new Statement(foo, bar, mkLit("2"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 2", !result.Second && eq(result.First, new Statement[] {x_FooBarLit2}));

    Statement x_BlankBarLit3 = new Statement(blank1, bar, mkLit("3"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 3", !result.Second && eq(result.First, new Statement[] {x_BlankBarLit3}));
    XBlankNode b3 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);

    Statement x_BlankBarLit4 = new Statement(blank2, bar, mkLit("4"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 4", !result.Second && eq(result.First, new Statement[] {x_BlankBarLit4}));
    XBlankNode b4 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);

    Statement x_BlankBarLit5 = new Statement(blank1, bar, mkLit("5"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 5", !result.Second && eq(result.First, new Statement[] {x_BlankBarLit5}));
    XBlankNode b5 = UnoRuntime.queryInterface(XBlankNode.class, result.First[0].Subject);

    assertTrue("RDFa: 3 != 4", !b3.getStringValue().equals(b4.getStringValue()));
    assertTrue("RDFa: 3 == 5", b3.getStringValue().equals(b5.getStringValue()));

    Statement x_FooBarLit6 = new Statement(foo, bar, mkLit("6"), null);
    Statement x_FooBazLit6 = new Statement(foo, baz, mkLit("6"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue(
        "RDFa: 6",
        !result.Second && eq(result.First, new Statement[] {x_FooBarLit6, x_FooBazLit6}));

    Statement x_FooBarLit7 = new Statement(foo, bar, mkLit("7"), null);
    Statement x_FooBazLit7 = new Statement(foo, baz, mkLit("7"), null);
    Statement x_FooFooLit7 = new Statement(foo, foo, mkLit("7"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue(
        "RDFa: 7",
        !result.Second
            && eq(result.First, new Statement[] {x_FooBarLit7, x_FooBazLit7, x_FooFooLit7}));

    XNode lit = mkLit("a fooish bar");
    XNode lit_type = mkLit("a fooish bar", bar);
    Statement x_FooBarLit = new Statement(foo, bar, lit, null);
    Statement x_FooBarLittype = new Statement(foo, bar, lit_type, null);

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 8", result.Second && eq(result.First, new Statement[] {x_FooBarLit}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 9", result.Second && eq(result.First, new Statement[] {x_FooBarLit}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 10", result.Second && eq(result.First, new Statement[] {x_FooBarLittype}));

    Statement x_FooBarLit11 = new Statement(foo, bar, mkLit("11", bar), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 11", !result.Second && eq(result.First, new Statement[] {x_FooBarLit11}));

    XURI xFile = URI.createNS(xContext, file, "/" + contentPath);
    Statement x_FileBarLit12 = new Statement(xFile, bar, mkLit("12"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 12", !result.Second && eq(result.First, new Statement[] {x_FileBarLit12}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 13", result.Second && eq(result.First, new Statement[] {x_FooBarLit}));

    new Statement(foo, rdfs_label, mkLit("14"), null);
    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue(
        "RDFa: 14",
        result.Second && eq(result.First, new Statement[] {/* x_FooLabelLit14 */ x_FooBarLit}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 15", eq(result.First, new Statement[] {}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 16", eq(result.First, new Statement[] {}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 17", eq(result.First, new Statement[] {}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 18", eq(result.First, new Statement[] {}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 19", eq(result.First, new Statement[] {}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 20", eq(result.First, new Statement[] {}));

    xPara = UnoRuntime.queryInterface(XMetadatable.class, xEnum.nextElement());
    result = xDocRepository.getStatementRDFa(xPara);
    assertTrue("RDFa: 21", eq(result.First, new Statement[] {}));

    System.out.println("...done");

    return xComp;
  }