Package org.apache.ws.jaxme.test.misc.address

Examples of org.apache.ws.jaxme.test.misc.address.Address


  public static void main(String[] args) throws Exception {
    File f = new File("Address.xml");
    InputSource isource = new InputSource(new FileInputStream(f));
    isource.setSystemId(f.toURL().toString());
    Address addr = getAddress(isource);

    // A simpler variant might be:
    // Address addr = unmarshaller.unmarshal(f);

    if (addr.getName() == null) {
      System.out.println("Loaded address without name.");
    } else {
      System.out.println("Loaded address " + addr.getName().getLast() +
                         ", " + addr.getName().getFirst() + ".");
    }
    System.out.println("Details:" + getAddressAsString(addr));
  }
View Full Code Here


  public static void main(String[] args) throws Exception {
    File f = new File("Address.xml");
    InputSource isource = new InputSource(new FileInputStream(f));
    isource.setSystemId(f.toURL().toString());
    Address addr = getAddress(isource);

    // A simpler variant might be:
    // Address addr = unmarshaller.unmarshal(f);

    if (addr.getName() == null) {
      System.out.println("Loaded address without name.");
    } else {
      System.out.println("Loaded address " + addr.getName().getLast() +
                         ", " + addr.getName().getFirst() + ".");
    }
    System.out.println("Details:" + getAddressAsString(addr));
  }
View Full Code Here


public class AddressCreator {
  public static void writeAddress(Writer pWriter) throws JAXBException {
    // Create the element:
    Address addr = new AddressImpl();
    addr.setName(new NameTypeImpl());
    addr.getName().setFirst("Jane");
    addr.getName().setLast("Doe");
    addr.setPostal(new PostalTypeImpl());
    addr.getPostal().setStreet("34 Main Street");
    addr.getPostal().setCity("Boston");
    addr.getPostal().setState("MA");
    addr.getPostal().setZIP("02215");
    addr.setEmailDetails(new EmailDetailsTypeImpl());

    EmailType email = new EmailTypeImpl();
    email.setType("Private");
    email.setEmailAddress("jdoe@yourcompany.com");
    addr.getEmailDetails().getEmail().add(email);
    email = new EmailTypeImpl();
    email.setType("Office");
    email.setEmailAddress("josephdoe@mycompany.com");
    addr.getEmailDetails().getEmail().add(email);
    email = new EmailTypeImpl();
    email.setType("Office");
    email.setEmailAddress("joseph.doe@mycompany.com");
    addr.getEmailDetails().getEmail().add(email);

    addr.setPhoneDetails(new PhoneDetailsTypeImpl());
    PhoneType phone = new PhoneTypeImpl();
    phone.setType("Work");
    phone.setPhoneNumber("555.6789");
    addr.getPhoneDetails().getPhone().add(phone);
    phone = new PhoneTypeImpl();
    phone.setType("Fax");
    phone.setPhoneNumber("555.1212");
    addr.getPhoneDetails().getPhone().add(phone);

    // And save it into the file "Address.xml"
    JAXBContext context = JAXBContext.newInstance("org.apache.ws.jaxme.test.misc.address");
    Marshaller marshaller = context.createMarshaller();
    marshaller.marshal(addr, pWriter);
View Full Code Here

  public void testPrint() throws Exception {
    String address = getAddress();
    InputSource isource = new InputSource(new StringReader(address));
    isource.setSystemId("testPrint.xml");
    Address addr = AddressPrinter.getAddress(isource);
    JAXBContext context = JAXBContext.newInstance("org.apache.ws.jaxme.test.misc.address");
    StringWriter sw = new StringWriter();
    context.createMarshaller().marshal(addr, sw);
    sw.close();
    String got = sw.toString();
View Full Code Here

  public void testPrint() throws Exception {
    String address = getAddress();
    InputSource isource = new InputSource(new StringReader(address));
    isource.setSystemId("testPrint.xml");
    Address addr = AddressPrinter.getAddress(isource);
    JAXBContext context = JAXBContext.newInstance("org.apache.ws.jaxme.test.misc.address");
    StringWriter sw = new StringWriter();
    context.createMarshaller().marshal(addr, sw);
    sw.close();
    String got = sw.toString();
View Full Code Here


public class AddressCreator {
  public static void writeAddress(Writer pWriter) throws JAXBException {
    // Create the element:
    Address addr = new AddressImpl();
    addr.setName(new NameTypeImpl());
    addr.getName().setFirst("Jane");
    addr.getName().setLast("Doe");
    addr.setPostal(new PostalTypeImpl());
    addr.getPostal().setStreet("34 Main Street");
    addr.getPostal().setCity("Boston");
    addr.getPostal().setState("MA");
    addr.getPostal().setZIP("02215");
    addr.setEmailDetails(new EmailDetailsTypeImpl());

    EmailType email = new EmailTypeImpl();
    email.setType("Private");
    email.setEmailAddress("jdoe@yourcompany.com");
    addr.getEmailDetails().getEmail().add(email);
    email = new EmailTypeImpl();
    email.setType("Office");
    email.setEmailAddress("josephdoe@mycompany.com");
    addr.getEmailDetails().getEmail().add(email);
    email = new EmailTypeImpl();
    email.setType("Office");
    email.setEmailAddress("joseph.doe@mycompany.com");
    addr.getEmailDetails().getEmail().add(email);

    addr.setPhoneDetails(new PhoneDetailsTypeImpl());
    PhoneType phone = new PhoneTypeImpl();
    phone.setType("Work");
    phone.setPhoneNumber("555.6789");
    addr.getPhoneDetails().getPhone().add(phone);
    phone = new PhoneTypeImpl();
    phone.setType("Fax");
    phone.setPhoneNumber("555.1212");
    addr.getPhoneDetails().getPhone().add(phone);

    // And save it into the file "Address.xml"
    JAXBContext context = JAXBContext.newInstance("org.apache.ws.jaxme.test.misc.address");
    Marshaller marshaller = context.createMarshaller();
    marshaller.marshal(addr, pWriter);
View Full Code Here

    } catch (Throwable t) {
      fail("Unexpected throwable " + t);
    }

    org.apache.ws.jaxme.test.misc.address.ObjectFactory of = new org.apache.ws.jaxme.test.misc.address.ObjectFactory();
    Address address = of.createAddress();
    address.setName(of.createAddressTypeNameType());
    AddressType.NameType name = address.getName();
    name.setFirst("Jane");
    try {
      assertFalse(context.createValidator().validate(address));
    } catch (Throwable t) {
      t.printStackTrace();
View Full Code Here

  public static void main(String[] args) throws Exception {
    File f = new File("Address.xml");
    InputSource isource = new InputSource(new FileInputStream(f));
    isource.setSystemId(f.toURL().toString());
    Address addr = getAddress(isource);

    // A simpler variant might be:
    // Address addr = unmarshaller.unmarshal(f);

    if (addr.getName() == null) {
      System.out.println("Loaded address without name.");
    } else {
      System.out.println("Loaded address " + addr.getName().getLast() +
                         ", " + addr.getName().getFirst() + ".");
    }
    System.out.println("Details:" + getAddressAsString(addr));
  }
View Full Code Here

public class AddressCreator {
  public static void writeAddress(Writer pWriter) throws JAXBException {
    ObjectFactory f = new ObjectFactory();
   
    // Create the element:
    Address addr = f.createAddress();
    addr.setName(f.createAddressTypeNameType());
    addr.getName().setFirst("Jane");
    addr.getName().setLast("Doe");
    addr.setPostal(f.createAddressTypePostalType());
    addr.getPostal().setStreet("34 Main Street");
    addr.getPostal().setCity("Boston");
    addr.getPostal().setState("MA");
    addr.getPostal().setZIP("02215");
    addr.setEmailDetails(f.createAddressTypeEmailDetailsType());
   
    EmailType email = f.createAddressTypeEmailDetailsTypeEmailType();
    email.setType("Private");
    email.setEmailAddress("jdoe@yourcompany.com");
    addr.getEmailDetails().getEmail().add(email);
    email = f.createAddressTypeEmailDetailsTypeEmailType();
    email.setType("Office");
    email.setEmailAddress("josephdoe@mycompany.com");
    addr.getEmailDetails().getEmail().add(email);
    email = f.createAddressTypeEmailDetailsTypeEmailType();
    email.setType("Office");
    email.setEmailAddress("joseph.doe@mycompany.com");
    addr.getEmailDetails().getEmail().add(email);
   
    addr.setPhoneDetails(f.createAddressTypePhoneDetailsType());
    PhoneType phone = f.createAddressTypePhoneDetailsTypePhoneType();
    phone.setType("Work");
    phone.setPhoneNumber("555.6789");
    addr.getPhoneDetails().getPhone().add(phone);
    phone = f.createAddressTypePhoneDetailsTypePhoneType();
    phone.setType("Fax");
    phone.setPhoneNumber("555.1212");
    addr.getPhoneDetails().getPhone().add(phone);
   
    // And save it into the file "Address.xml"
    JAXBContext context = JAXBContext.newInstance("org.apache.ws.jaxme.test.misc.address");
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(JMMarshallerImpl.JAXME_XML_DECLARATION, Boolean.FALSE);
View Full Code Here

    } catch (Throwable t) {
      fail("Unexpected throwable " + t);
    }

    org.apache.ws.jaxme.test.misc.address.ObjectFactory of = new org.apache.ws.jaxme.test.misc.address.ObjectFactory();
    Address address = of.createAddress();
    address.setName(of.createAddressTypeNameType());
    AddressType.NameType name = address.getName();
    name.setFirst("Jane");
    try {
      assertFalse(context.createValidator().validate(address));
    } catch (Throwable t) {
      t.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.test.misc.address.Address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.