Esempio n. 1
0
  public static void dumpJAXB(SnomDocument document) {
    // create JAXB context and instantiate marshaller
    JAXBContext context;
    try {
      context = JAXBContext.newInstance(document.getClass());
      Marshaller m = context.createMarshaller();
      m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      StringWriter w = new StringWriter();
      m.marshal(document, w);

      System.out.println(w.toString());
    } catch (JAXBException ex) {
      System.out.println(ex);
    }
  }
Esempio n. 2
0
  private static void testElems() {

    SnomDocument elem = new SnomIPPhoneText();

    ((SnomIPPhoneText) elem).setTitle("Hello World!");
    ((SnomIPPhoneText) elem).setText("Dies ist ein Text-Element.");
    elem.setFetch(server.getAddressString().concat("/asdf/"), 3000);

    dumpJAXB(elem);

    elem = new SnomIPPhoneInput();
    ((SnomIPPhoneInput) elem).setTitle("SnomIPPhoneInput");
    ((SnomIPPhoneInput) elem).setURL("http://127.0.0.1/asdf/");
    SnomIPPhoneInput.InputItem input = new SnomIPPhoneInput.InputItem();
    input.setDisplayName("Gib was ein;");
    input.setQueryStringParam("&action=foo&antwort=");
    input.setInputFlags("a");
    ((SnomIPPhoneInput) elem).setInputItem(input);

    dumpJAXB(elem);

    elem = new SnomIPPhoneDirectory();
    ((SnomIPPhoneDirectory) elem).setTitle("SnomIPPhoneDirectory");
    SnomIPPhoneDirectory.DirectoryEntry dir_entries[] = new SnomIPPhoneDirectory.DirectoryEntry[3];
    dir_entries[0] = new SnomIPPhoneDirectory.DirectoryEntry();
    dir_entries[0].setName("Name 1");
    dir_entries[0].setTelephone("0 11 1234");
    ((SnomIPPhoneDirectory) elem).getDirectoryEntry().add(dir_entries[0]);

    dir_entries[1] = new SnomIPPhoneDirectory.DirectoryEntry();
    dir_entries[1].setName("Name 2");
    dir_entries[1].setTelephone("0 22 1234");
    ((SnomIPPhoneDirectory) elem).getDirectoryEntry().add(dir_entries[1]);

    dir_entries[2] = new SnomIPPhoneDirectory.DirectoryEntry();
    dir_entries[2].setName("Name 3");
    dir_entries[2].setTelephone("0 33 1234");
    ((SnomIPPhoneDirectory) elem).getDirectoryEntry().add(dir_entries[2]);

    dumpJAXB(elem);

    elem = new SnomIPPhoneMenu();
    ((SnomIPPhoneMenu) elem).setTitle("SnomIPPhoneMenu");
    SnomIPPhoneMenu.MenuItem entries[] = new SnomIPPhoneMenu.MenuItem[3];
    entries[0] = new SnomIPPhoneMenu.MenuItem();
    entries[0].setName("Eintrag 1");
    entries[0].setURL("http://127.0.0.1/asdf/1");
    ((SnomIPPhoneMenu) elem).getMenuItem().add(entries[0]);

    entries[1] = new SnomIPPhoneMenu.MenuItem();
    entries[1].setName("Eintrag 2");
    entries[1].setURL("http://127.0.0.1/asdf/2");
    ((SnomIPPhoneMenu) elem).getMenuItem().add(entries[1]);

    entries[2] = new SnomIPPhoneMenu.MenuItem();
    entries[2].setName("Eintrag 3");
    entries[2].setURL("http://127.0.0.1/asdf/3");
    ((SnomIPPhoneMenu) elem).getMenuItem().add(entries[2]);

    dumpJAXB(elem);

    elem = new SnomIPPhoneImage();
    SnomIPPhoneImage.Data data = new SnomIPPhoneImage.Data();
    data.setValue(("blablab.base64.zeug.blubber").getBytes());
    ((SnomIPPhoneImage) elem).setData(data);

    dumpJAXB(elem);
  }