Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2014 Philip Helger (www.helger.com) philip[at]helger[dot]com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package com.helger.appbasics.object.accarea;
 
 
 
 
 {
   private static final String ATTR_CLIENTID = "clientid";
   private static final String ATTR_DISPLAYNAME = "displayname";
   private static final String ATTR_COMPANYTYPE = "companytype";
   private static final String ATTR_COMPANYVATIN = "companyvatin";
   private static final String ATTR_COMPANYNUMBER = "companynumber";
   private static final String ELEMENT_ADDRESS = "address";
   private static final String ATTR_TELEPHONE = "telephone";
   private static final String ATTR_FAX = "fax";
   private static final String ATTR_EMAILADDRESS = "emailaddress";
   private static final String ATTR_WEBSITE = "website";
   private static final String ATTR_DEFAULTCURRENCY = "defaultcurrency";
   private static final String ATTR_OFFICE_LOCATION = "officelocation";
   private static final String ATTR_COMMERCIAL_REGISTRATION_NUMBER = "commregno";
   private static final String ATTR_COMMERCIAL_COURT = "commcourt";
 
   private final IClientResolver m_aClientResolver;
 
   public AccountingAreaMicroTypeConverter (@Nonnull final IClientResolver aClientResolver)
   {
      = aClientResolver;
   }
 
   @Nonnull
   public IMicroElement convertToMicroElement (@Nonnull final Object aObject,
                                               @Nullable final String sNamespaceURI,
                                               @Nonnull @Nonempty final String sTagName)
   {
     final IAccountingArea aValue = (IAccountingAreaaObject;
     final IMicroElement aElement = new MicroElement (sNamespaceURIsTagName);
     aElement.setAttribute (aValue.getClientID ());
     setObjectFields (aValueaElement);
     aElement.setAttribute (aValue.getDisplayName ());
     aElement.setAttribute (aValue.getCompanyType ());
     aElement.setAttribute (aValue.getCompanyVATIN ());
     aElement.setAttribute (aValue.getCompanyNumber ());
     aElement.appendChild (MicroTypeConverter.convertToMicroElement (aValue.getAddress (),
                                                                     sNamespaceURI,
                                                                     ));
     aElement.setAttribute (aValue.getTelephone ());
     aElement.setAttribute (aValue.getFax ());
     aElement.setAttribute (aValue.getEmailAddress ());
     aElement.setAttribute (aValue.getWebSite ());
     aElement.setAttribute (aValue.getDefaultCurrencyID ());
     aElement.setAttribute (aValue.getOfficeLocation ());
     aElement.setAttribute (aValue.getCommercialCourt ());
     return aElement;
   }
 
   @Nonnull
   public AccountingArea convertToNative (@Nonnull final IMicroElement aElement)
   {
     final Locale aLocale = SystemHelper.getSystemLocale ();
     final String sClientID = aElement.getAttribute ();
     final IClient aClient = .getClientOfID (sClientID);
     if (aClient == null)
       throw new IllegalStateException ("Failed to resolve client ID '" + sClientID + "'");
 
     final String sDisplayName = aElement.getAttribute ();
     final String sCompanyType = aElement.getAttribute ();
     final String sCompanyVATIN = aElement.getAttribute ();
     final String sCompanyNumber = aElement.getAttribute ();
     final Address aAddress = MicroTypeConverter.convertToNative (aElement.getFirstChildElement (),
                                                                 Address.class);
    final String sTelephone = aElement.getAttribute ();
    final String sFax = aElement.getAttribute ();
    final String sEmailAddress = aElement.getAttribute ();
    final String sWebSite = aElement.getAttribute ();
    final String sDefaultCurrency = aElement.getAttribute ();
    final ECurrency eDefaultCurrency = ECurrency.getFromIDOrNull (sDefaultCurrency);
    final String sOfficeLocation = aElement.getAttribute ();
    final String sCommercialRegistrationNumber = aElement.getAttribute ();
    final String sCommercialCourt = aElement.getAttribute ();
    return new AccountingArea (aClient,
                               getStubObject (aElement),
                               sDisplayName,
                               sCompanyType,
                               sCompanyVATIN,
                               sCompanyNumber,
                               aAddress,
                               sTelephone,
                               sFax,
                               sEmailAddress,
                               sWebSite,
                               eDefaultCurrency,
                               sOfficeLocation,
                               sCommercialRegistrationNumber,
                               sCommercialCourt,
                               aLocale);
  }
New to GrepCode? Check out our FAQ X