/** * Returns whether any information on the physical address is available. * * @returns <code>true</code>, if any physical information is available, <code>false</code> otherwise */ public boolean isPhysicalInfoAvailable() { return !getDeliveryPoint().isEmpty() || getCity() != null || getAdministrativeArea() != null || getPostalCode() != null || getCountry() != null; } }
public static Address convertFromJAXB( AddressType ad ) { if ( ad == null ) { return null; } Address address = new Address(); address.setAdministrativeArea( ad.getAdministrativeArea() ); address.setCity( ad.getCity() ); address.setCountry( ad.getCountry() ); address.setPostalCode( ad.getPostalCode() ); address.setDeliveryPoint( ad.getDeliveryPoint() ); return address; }
/** * @param addressEl * context {@link OMElement} * @return an {@link Address} instance, never <code>null</code> */ protected Address parseAddress( OMElement addressEl ) { Address address = new Address(); XPath xpath = new XPath( "ows:DeliveryPoint", nsContext ); String[] deliveryPoints = getNodesAsStrings( addressEl, xpath ); for ( String deliveryPoint : deliveryPoints ) { address.getDeliveryPoint().add( deliveryPoint ); } xpath = new XPath( "ows:City", nsContext ); address.setCity( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:AdministrativeArea", nsContext ); address.setAdministrativeArea( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:PostalCode", nsContext ); address.setPostalCode( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:Country", nsContext ); address.setCountry( getNodeAsString( addressEl, xpath, null ) ); xpath = new XPath( "ows:ElectronicMailAddress", nsContext ); String[] eMails = getNodesAsStrings( addressEl, xpath ); for ( int i = 0; i < eMails.length; i++ ) { address.getElectronicMailAddress().add( eMails[i] ); } return address; }
if ( addr != null && addr.isPhysicalInfoAvailable() ) { writer.writeStartElement( WMSNS, "ContactAddress" ); writeElement( writer, WMSNS, "AddressType", "postal" ); for ( String s : addr.getDeliveryPoint() ) { maybeWriteElementNS( writer, WMSNS, "Address", s ); writeElement( writer, WMSNS, "City", addr.getCity() ); writeElement( writer, WMSNS, "StateOrProvince", addr.getAdministrativeArea() ); writeElement( writer, WMSNS, "PostCode", addr.getPostalCode() ); writeElement( writer, WMSNS, "Country", addr.getCountry() ); writer.writeEndElement(); maybeWriteElementNS( writer, WMSNS, "ContactFacsimileTelephone", contact.getContactInfo().getPhone().getFacsimile().get( 0 ) ); if ( addr != null && !addr.getElectronicMailAddress().isEmpty() ) { maybeWriteElementNS( writer, WMSNS, "ContactElectronicMailAddress", addr.getElectronicMailAddress().get( 0 ) );
if ( addr != null && addr.isPhysicalInfoAvailable() ) { writer.writeStartElement( "ContactAddress" ); writeElement( writer, "AddressType", "postal" ); for ( String s : addr.getDeliveryPoint() ) { maybeWriteElement( writer, "Address", s ); writeElement( writer, "City", addr.getCity() ); writeElement( writer, "StateOrProvince", addr.getAdministrativeArea() ); writeElement( writer, "PostCode", addr.getPostalCode() ); writeElement( writer, "Country", addr.getCountry() ); writer.writeEndElement(); maybeWriteElement( writer, "ContactFacsimileTelephone", contact.getContactInfo().getPhone().getFacsimile().get( 0 ) ); if ( addr != null && !addr.getElectronicMailAddress().isEmpty() ) { maybeWriteElement( writer, "ContactElectronicMailAddress", addr.getElectronicMailAddress().get( 0 ) );
if ( address != null ) { writer.writeStartElement( owsNS, "Address" ); exportSimpleStrings( writer, address.getDeliveryPoint(), owsNS, "DeliveryPoint" ); writeOptionalElement( writer, owsNS, "City", address.getCity() ); writeOptionalElement( writer, owsNS, "AdministrativeArea", address.getAdministrativeArea() ); writeOptionalElement( writer, owsNS, "PostalCode", address.getPostalCode() ); writeOptionalElement( writer, owsNS, "Country", address.getCountry() ); exportSimpleStrings( writer, address.getElectronicMailAddress(), owsNS, "ElectronicMailAddress" ); writer.writeEndElement();