gt:             rFTransmitter = new RFTransmitter(binary.subList(position,
context: /*
   *
   * This file was generated by LLRP Code Generator
   * see http://llrp-toolkit.cvs.sourceforge.net/llrp-toolkit
   * for more information
   * Generated on: Mon Mar 10 14:26:47 KST 2014;
   *
   */
  
  /*
   * Copyright (C) 2014 KAIST
   * @author Janggwan Im <limg00n@kaist.ac.kr>
   * 
   * Copyright 2007 ETH Zurich
   *
   * 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 kr.ac.kaist.resl.ltk.generated.parameters;
  
  import org.apache.log4j.Logger;
  
  import org.jdom.Content;
  import org.jdom.Document;
  import org.jdom.Element;
  import org.jdom.Namespace;
  
  import org.llrp.ltk.exceptions.InvalidLLRPMessageException;
  import org.llrp.ltk.exceptions.MissingParameterException;
  import kr.ac.kaist.resl.ltk.generated.LLRPConstants;
  import kr.ac.kaist.resl.ltk.generated.interfaces.AirProtocolInventoryCommandSettings;
  import kr.ac.kaist.resl.ltk.generated.parameters.C1G2InventoryCommand;
  import kr.ac.kaist.resl.ltk.generated.parameters.RFReceiver;
  import kr.ac.kaist.resl.ltk.generated.parameters.RFTransmitter;
  import org.llrp.ltk.types.LLRPBitList;
  import org.llrp.ltk.types.LLRPMessage;
  import org.llrp.ltk.types.SignedShort;
  import org.llrp.ltk.types.TLVParameter;
  import org.llrp.ltk.types.TVParameter;
  import org.llrp.ltk.types.UnsignedShort;
  
  import java.util.LinkedList;
  import java.util.List;
  
  
  /**
   * This parameter carries a single antenna's configuration and it specifies the default values for the parameter set that are passed in this parameter block. The scope of the default values is the antenna. The default values are used for parameters during an operation on this antenna if the parameter was unspecified in the spec that describes the operation.
  
  See also {@link <a href="http://www.epcglobalinc.org/standards/llrp/llrp_1_0_1-standard-20070813.pdf#page=74&view=fit">LLRP Specification Section 12.2.6</a>}
   and {@link <a href="http://www.epcglobalinc.org/standards/llrp/llrp_1_0_1-standard-20070813.pdf#page=141&view=fit">LLRP Specification Section 16.2.6.6</a>}
  
  
   */
  
  /**
   * This parameter carries a single antenna's configuration and it specifies the default values for the parameter set that are passed in this parameter block. The scope of the default values is the antenna. The default values are used for parameters during an operation on this antenna if the parameter was unspecified in the spec that describes the operation.
  
  See also {@link <a href="http://www.epcglobalinc.org/standards/llrp/llrp_1_0_1-standard-20070813.pdf#page=74&view=fit">LLRP Specification Section 12.2.6</a>}
   and {@link <a href="http://www.epcglobalinc.org/standards/llrp/llrp_1_0_1-standard-20070813.pdf#page=141&view=fit">LLRP Specification Section 16.2.6.6</a>}
  
        .
   */
  public class AntennaConfiguration extends TLVParameter {
      public static final SignedShort TYPENUM = new SignedShort(222);
      private static final Logger LOGGER = Logger.getLogger(AntennaConfiguration.class);
      protected UnsignedShort antennaID;
      protected RFReceiver rFReceiver;
      protected RFTransmitter rFTransmitter;
      protected List<AirProtocolInventoryCommandSettings> airProtocolInventoryCommandSettingsList =
          new LinkedList<AirProtocolInventoryCommandSettings>();
  
      /**
       * empty constructor to create new parameter.
       */
      public AntennaConfiguration() {
      }
  
      /**
       * Constructor to create parameter from binary encoded parameter
       * calls decodeBinary to decode parameter.
       * @param list to be decoded
       */
      public AntennaConfiguration(LLRPBitList list) {
          decodeBinary(list);
      }
  
      /**
      * Constructor to create parameter from xml encoded parameter
      * calls decodeXML to decode parameter.
      * @param element to be decoded
      */
      public AntennaConfiguration(Element element)
          throws InvalidLLRPMessageException {
          decodeXML(element);
      }
  
      /**
      * {@inheritDoc}
      */
      public LLRPBitList encodeBinarySpecific() {
          LLRPBitList resultBits = new LLRPBitList();
  
          if (antennaID == null) {
              LOGGER.warn(" antennaID not set");
              throw new MissingParameterException(
                  " antennaID not set  for Parameter of Type AntennaConfiguration");
          }
  
          resultBits.append(antennaID.encodeBinary());
  
          if (rFReceiver == null) {
              // optional parameter, may be null
              LOGGER.info(" rFReceiver not set");
          } else {
              resultBits.append(rFReceiver.encodeBinary());
          }
  
          if (rFTransmitter == null) {
              // optional parameter, may be null
              LOGGER.info(" rFTransmitter not set");
          } else {
              resultBits.append(rFTransmitter.encodeBinary());
          }
  
          if (airProtocolInventoryCommandSettingsList == null) {
              //just warn - it is optional 
              LOGGER.info(" airProtocolInventoryCommandSettingsList not set");
          } else {
              for (AirProtocolInventoryCommandSettings field : airProtocolInventoryCommandSettingsList) {
                  resultBits.append(field.encodeBinary());
              }
          }
  
          return resultBits;
      }
  
      /**
      * {@inheritDoc}
      */
      public Content encodeXML(String name, Namespace ns) {
          // element in namespace defined by parent element
          Element element = new Element(name, ns);
          // child element are always in default LLRP namespace
          ns = Namespace.getNamespace("llrp", LLRPConstants.LLRPNAMESPACE);
  
          if (antennaID == null) {
              LOGGER.warn(" antennaID not set");
              throw new MissingParameterException(" antennaID not set");
          } else {
              element.addContent(antennaID.encodeXML("AntennaID", ns));
          }
  
          //parameters
          if (rFReceiver == null) {
              LOGGER.info("rFReceiver not set");
          } else {
              element.addContent(rFReceiver.encodeXML(rFReceiver.getClass()
                                                                .getSimpleName(),
                      ns));
          }
  
          if (rFTransmitter == null) {
              LOGGER.info("rFTransmitter not set");
          } else {
              element.addContent(rFTransmitter.encodeXML(
                      rFTransmitter.getClass().getSimpleName(), ns));
          }
  
          if (airProtocolInventoryCommandSettingsList == null) {
              LOGGER.info("airProtocolInventoryCommandSettingsList not set");
          } else {
              for (AirProtocolInventoryCommandSettings field : airProtocolInventoryCommandSettingsList) {
                  element.addContent(field.encodeXML(field.getClass().getName()
                                                          .replaceAll(field.getClass()
                                                                           .getPackage()
                                                                           .getName() +
                              ".", ""), ns));
              }
          }
  
          return element;
      }
  
      /**
      * {@inheritDoc}
      */
      protected void decodeBinarySpecific(LLRPBitList binary) {
          int position = 0;
          int tempByteLength;
          int tempLength = 0;
          int count;
          SignedShort type;
          int fieldCount;
          Custom custom;
          antennaID = new UnsignedShort(binary.subList(position,
                      UnsignedShort.length()));
          position += UnsignedShort.length();
  
          // look ahead to see type
          // may be optional or exactly once
          type = null;
          tempByteLength = 0;
          tempLength = 0;
  
          try {
              // if first bit is one it is a TV Parameter
              if (binary.get(position)) {
                  // do not take the first bit as it is always 1
                  type = new SignedShort(binary.subList(position + 1, 7));
              } else {
                  type = new SignedShort(binary.subList(position +
                              RESERVEDLENGTH, TYPENUMBERLENGTH));
                  tempByteLength = new UnsignedShort(binary.subList(position +
                              RESERVEDLENGTH + TYPENUMBERLENGTH,
                              UnsignedShort.length())).toShort();
                  tempLength = 8 * tempByteLength;
              }
          } catch (IllegalArgumentException le) {
              // if an IllegalArgumentException is thrown, list was not long enough so the parameter is missing
              LOGGER.info(
                  "AntennaConfiguration misses optional parameter of type RFReceiver");
          }
  
          if (binary.get(position)) {
              // length can statically be determined for TV Parameters
              tempLength = rFReceiver.length();
          }
  
          if ((type != null) && type.equals(RFReceiver.TYPENUM)) {
              rFReceiver = new RFReceiver(binary.subList(position, tempLength));
              position += tempLength;
              LOGGER.debug(
                  " rFReceiver is instantiated with RFReceiver with length" +
                  tempLength);
          } else {
              LOGGER.info(
                  "AntennaConfiguration misses optional parameter of type RFReceiver");
          }
  
          // look ahead to see type
          // may be optional or exactly once
          type = null;
          tempByteLength = 0;
          tempLength = 0;
  
          try {
              // if first bit is one it is a TV Parameter
              if (binary.get(position)) {
                  // do not take the first bit as it is always 1
                  type = new SignedShort(binary.subList(position + 1, 7));
              } else {
                  type = new SignedShort(binary.subList(position +
                              RESERVEDLENGTH, TYPENUMBERLENGTH));
                  tempByteLength = new UnsignedShort(binary.subList(position +
                              RESERVEDLENGTH + TYPENUMBERLENGTH,
                              UnsignedShort.length())).toShort();
                  tempLength = 8 * tempByteLength;
              }
          } catch (IllegalArgumentException le) {
              // if an IllegalArgumentException is thrown, list was not long enough so the parameter is missing
              LOGGER.info(
                  "AntennaConfiguration misses optional parameter of type RFTransmitter");
          }
  
          if (binary.get(position)) {
              // length can statically be determined for TV Parameters
              tempLength = rFTransmitter.length();
          }
  
          if ((type != null) && type.equals(RFTransmitter.TYPENUM)) {
  