Beispiel #1
0
 private void saveItem() {
   mItem.setTitle(mTitle.getText().toString());
   mItem.setDetails(mDetails.getText().toString());
   // date is already set
   mItem.setAutodelete(mAutoDelete.isChecked());
   ItemManager.get(getActivity()).saveItem(mItem);
 }
  // 點擊確定與取消按鈕都會呼叫這個方法
  public void onSubmit(View view) {
    // 確定按鈕
    if (view.getId() == R.id.ok_teim) {
      // 讀取使用者輸入的標題與內容
      String titleText = title_text.getText().toString();
      String contentText = content_text.getText().toString();

      // 設定記事物件的標題與內容
      item.setTitle(titleText);
      item.setContent(contentText);

      // 如果是修改記事
      if (getIntent().getAction().equals("net.macdidi.myandroidtutorial.EDIT_ITEM")) {
        item.setLastModify(new Date().getTime());
      }
      // 新增記事
      else {
        item.setDatetime(new Date().getTime());
      }

      Intent result = getIntent();
      // 設定回傳的記事物件
      result.putExtra("net.macdidi.myandroidtutorial.Item", item);
      setResult(Activity.RESULT_OK, result);
    }

    // 結束
    finish();
  }
 private void text(String text) {
   switch (state) {
     case ITEM_TITLE:
       currentItem.setTitle(text);
       break;
     case ITEM_DESCRIPTION:
       currentItem.setDescription(text);
       break;
     case ITEM_CONTENT:
       currentItem.setContent(text);
       break;
     case ITEM_PUB_DATE:
       Date date;
       try {
         date = dateFormat.parse(text);
       } catch (ParseException e) {
         e.printStackTrace();
         return;
       }
       currentItem.setPubDate(date.getTime());
       break;
     default:
       break;
   }
 }
    // 點擊確定與取消按鈕都會呼叫這個方法
    public void onSubmit(View view) {
        // 確定按鈕
        if (view.getId() == R.id.ok_teim) {
            String titleText = title_text.getText().toString();
            String contentText = content_text.getText().toString();

            item.setTitle(titleText);
            item.setContent(contentText);

            if (getIntent().getAction().equals(
                    "net.macdidi.myandroidtutorial.EDIT_ITEM")) {
                item.setLastModify(new Date().getTime());
            }
            // 新增記事
            else {
                item.setDatetime(new Date().getTime());
                // 建立SharedPreferences物件
                SharedPreferences sharedPreferences =
                        PreferenceManager.getDefaultSharedPreferences(this);
                // 讀取設定的預設顏色
                int color = sharedPreferences.getInt("DEFAULT_COLOR", -1);
                item.setColor(getColors(color));
            }

            Intent result = getIntent();
            result.putExtra("net.macdidi.myandroidtutorial.Item", item);
            setResult(Activity.RESULT_OK, result);
        }

        // 結束
        finish();
    }
  /** 4.テキストデータ読み込み時 */
  public void characters(char[] ch, int offset, int length) {

    String textData = new String(ch, offset, length);
    //		System.out.println("テキストデータ:" + textData);
    if ("TotalResults".equals(currentQName)) totalResults = Integer.parseInt(textData);

    if ("Item".equals(currentQName)) {
      tmpItem = new Item();
      tmpItem.setCategory(category);
    }
    if ("ASIN".equals(currentQName)) tmpItem.setAsin(textData);
    else if ("DetailPageURL".equals(currentQName)) tmpItem.setDetailPageURL(textData);
    else if ("SalesRank".equals(currentQName)) tmpItem.setSalesRank(Integer.parseInt(textData));
    else if ("URL".equals(currentQName) && "SmallImage".equals(currentQName2))
      tmpItem.setSmallImageURL(textData);
    else if ("URL".equals(currentQName) && "MediumImage".equals(currentQName2))
      tmpItem.setMediumImageURL(textData);
    else if ("URL".equals(currentQName) && "LargeImage".equals(currentQName2))
      tmpItem.setLargeImageURL(textData);
    else if ("EAN".equals(currentQName)) tmpItem.setEan(textData);
    else if ("Condition".equals(currentQName)
        && "OfferAttributes".equals(currentQName2)
        && "Offer".equals(currentQName3)) tmpItem.setCondition(textData);
    else if ("Amount".equals(currentQName) && "ListPrice".equals(currentQName2))
      tmpItem.setListPrice(Integer.parseInt(textData));
    else if ("ReleaseDate".equals(currentQName)) tmpItem.setReleaseDate(textData);
    else if ("Title".equals(currentQName)) tmpItem.setTitle(textData);
    else if ("Amount".equals(currentQName)
        && "Price".equals(currentQName2)
        && "OfferListingId".equals(currentQName3))
      tmpItem.setOfferPrice(Integer.parseInt(textData));
    else if ("PercentageSaved".equals(currentQName))
      tmpItem.setPercentageSaved(Integer.parseInt(textData));
    else if ("AvailabilityType".equals(currentQName)) tmpItem.setAvailability(textData);
  }
Beispiel #6
0
  // parsing the XML
  public void parseXMLAndStoreIt(XmlPullParser myParser) {
    int event;
    String text = null;
    // Create item
    try {
      event = myParser.getEventType();
      Item item = null;
      boolean checkItem = true;
      boolean newItem = false;

      while (event != XmlPullParser.END_DOCUMENT) {
        String name = myParser.getName();
        if (checkItem) {
          item = new Item();
          checkItem = false;
        }

        switch (event) {
          case XmlPullParser.START_TAG:
            if (name.equals("item")) {
              newItem = true;
            }
            break;
          case XmlPullParser.TEXT:
            text = myParser.getText();
            break;
          case XmlPullParser.END_TAG:
            switch (name) {
              case "title":
                if (newItem) {
                  item.setTitle(text);
                }
                break;
              case "description":
                if (newItem) {
                  item.setDescription(text);
                }
                break;
              case "link":
                if (newItem) {
                  item.setLink(text);
                }
                break;
            }
            break;
        }
        // add to an array list
        if (item.itemReady()) {
          feed.addItem(item);
          newItem = false;
          checkItem = true;
        }
        event = myParser.next();
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 /** Test method add */
 @Test
 public void testAdd() {
   final Item newEpisode = new Item();
   newEpisode.setGuid(CodeHelper.getGlobalForeverUniqueID());
   newEpisode.setTitle("This is my new Item");
   // Count episodes before
   final int initialCount = feed.getItems().size();
   feedManager.addItem(newEpisode, null, feed, PublishEventTO.getNoPublishInstance());
   // re-read feed and count episodes
   feed = feedManager.getFeed(feed);
   final int newCount = feed.getItems().size();
   // Compare
   assertEquals(initialCount + 1, newCount);
 }
 public void inflateMenu(int menu) {
   MenuInflater menuInflater = new SupportMenuInflater(getContext());
   MenuBuilder menuBuilder = new MenuBuilder(getContext());
   menuInflater.inflate(menu, menuBuilder);
   List<Item> items = new ArrayList<>();
   for (int i = 0; i < menuBuilder.size(); i++) {
     MenuItem menuItem = menuBuilder.getItem(i);
     Item item = new Item();
     item.setId(menuItem.getItemId());
     item.setIcon(menuItem.getIcon());
     item.setTitle(menuItem.getTitle().toString());
     items.add(item);
   }
   addItems(items);
 }
  /** @see junit.framework.TestCase#setUp() */
  @Before
  public void setup() {
    setupMocking();

    // Create a feed that can be read, updated or deleted.
    final OLATResourceable podcastResource = feedManager.createPodcastResource();
    feed = feedManager.getFeed(podcastResource);
    feed.setTitle(PODCAST_TITLE);
    feedManager.updateFeedMetadata(feed);

    // Add an episode
    // A feed can only be edited when it is an internal feed (meaning that
    // it is made within OLAT). Obviously, external feeds cannot be changed.
    final Item item = new Item();
    item.setTitle("My Test Item");
    feed = feedManager.updateFeedMode(Boolean.FALSE, feed);
    feedManager.addItem(item, null, feed, PublishEventTO.getNoPublishInstance());
  }
  private void createMessage(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_createMessage

    String itemTitle = itemTitleTextField.getText().trim();
    String itemDescription = itemDescriptionTextArea.getText().trim();

    if (itemTitle.length() > 0 && itemDescription.length() > 0) {
      Item tmp = null;
      int currentSelectedItemIndex = itemList.getSelectedIndex();

      if (currentSelectedItemIndex >= 0) {
        tmp = listModel.getElementAt(currentSelectedItemIndex);
      } else {
        tmp = new Item();
      }

      tmp.setTitle(itemTitle);
      tmp.setDescription(itemDescription);

      if (currentSelectedItemIndex < 0) {
        listModel.addElement(tmp);
      }

      createItemButton.setText("Create");
      itemList.clearSelection();
      clearItemFields();

      if (!deleteItemButton.isEnabled()) {
        deleteItemButton.setEnabled(true);
      }
    } else {
      JOptionPane.showMessageDialog(
          null,
          "Item Title and Description can not be empty",
          "Input Error",
          JOptionPane.ERROR_MESSAGE);
    }
  } // GEN-LAST:event_createMessage
Beispiel #11
0
  /**
   * 封装在线商品列表
   *
   * @param xml
   * @return
   * @throws DocumentException
   */
  public static List<Item> getItemElememt(String xml) throws Exception {
    List li = new ArrayList();
    Document document = formatStr2Doc(xml);
    Element rootElt = document.getRootElement();
    Element recommend = rootElt.element("ItemArray");
    Iterator<Element> iter = recommend.elementIterator("Item");
    while (iter.hasNext()) {
      Item item = new Item();
      Element element = iter.next();
      Element elflag = element.element("SellingStatus").element("ListingStatus");
      if (elflag != null) { // 如查商品不在线,就不取在线商品
        if (elflag.getText().equals("Active")) {

        } else {
          continue;
        }
      }
      item.setTitle(element.elementText("Title"));
      item.setCurrency(element.elementText("Currency"));
      item.setCountry(element.elementText("Country"));
      item.setSite(element.elementText("Site"));
      item.setPostalCode(element.elementText("PostalCode"));
      item.setLocation(element.elementText("Location"));
      item.setItemID(element.elementText("ItemID"));
      item.setHitCounter(element.elementText("HitCounter"));
      item.setAutoPay(element.elementText("AutoPay").equals("true") ? true : false);
      item.setGiftIcon(element.elementText("GiftIcon"));
      item.setListingDuration(element.elementText("ListingDuration"));
      item.setQuantity(Integer.parseInt(element.elementText("Quantity")));
      item.setSKU(element.elementText("SKU"));
      StartPrice sp = new StartPrice();
      sp.setValue(Double.parseDouble(element.element("SellingStatus").elementText("CurrentPrice")));
      sp.setCurrencyID(
          element.element("SellingStatus").element("CurrentPrice").attributeValue("currencyID"));
      item.setStartPrice(sp);
      item.setConditionID(
          Integer.parseInt(
              element.elementText("ConditionID") == null
                  ? "1000"
                  : element.elementText("ConditionID")));
      List lishipto = new ArrayList();
      Iterator<Element> shipe = element.elementIterator("ShipToLocations");
      while (shipe.hasNext()) {
        Element elstr = shipe.next();
        lishipto.add(elstr.getText());
      }
      item.setShipToLocations(lishipto);
      // 取得退货政策并封装
      Element returne = element.element("ReturnPolicy");
      ReturnPolicy rp = new ReturnPolicy();
      rp.setRefundOption(returne.elementText("RefundOption"));
      rp.setReturnsWithinOption(returne.elementText("ReturnsWithinOption"));
      rp.setReturnsAcceptedOption(returne.elementText("ReturnsAcceptedOption"));
      rp.setDescription(returne.elementText("Description"));
      rp.setShippingCostPaidByOption(returne.elementText("ShippingCostPaidByOption"));
      item.setReturnPolicy(rp);
      // 买家要求
      BuyerRequirementDetails brd = new BuyerRequirementDetails();
      MaximumItemRequirements mirs = new MaximumItemRequirements();
      Element buyere = element.element("BuyerRequirementDetails");
      if (buyere != null) {
        Element maxiteme = buyere.element("MaximumItemRequirements");
        if (maxiteme != null) {
          if (StringUtils.isNotEmpty(maxiteme.elementText("MaximumItemCount"))) {
            mirs.setMaximumItemCount(Integer.parseInt(maxiteme.elementText("MaximumItemCount")));
          }
          if (StringUtils.isNotEmpty(maxiteme.elementText("MinimumFeedbackScore"))) {
            mirs.setMinimumFeedbackScore(
                Integer.parseInt(maxiteme.elementText("MinimumFeedbackScore")));
          }
          brd.setMaximumItemRequirements(mirs);
        }

        Element maxUnpaid = buyere.element("MaximumUnpaidItemStrikesInfo");
        if (maxUnpaid != null) {
          MaximumUnpaidItemStrikesInfo muis = new MaximumUnpaidItemStrikesInfo();
          if (StringUtils.isNotEmpty(maxUnpaid.elementText("Count"))) {
            muis.setCount(Integer.getInteger(maxUnpaid.elementText("Count")));
          }
          muis.setPeriod(maxUnpaid.elementText("Period"));
          brd.setMaximumUnpaidItemStrikesInfo(muis);
        }

        Element maxPolicy = buyere.element("MaximumBuyerPolicyViolations");
        if (maxPolicy != null) {
          MaximumBuyerPolicyViolations mbpv = new MaximumBuyerPolicyViolations();
          if (StringUtils.isNotEmpty(maxPolicy.elementText("Count"))) {
            mbpv.setCount(Integer.parseInt(maxPolicy.elementText("Count")));
          }
          mbpv.setPeriod(maxPolicy.elementText("Period"));
          brd.setMaximumBuyerPolicyViolations(mbpv);
        }
        item.setBuyerRequirementDetails(brd);
      }

      li.add(item);
    }
    return li;
  }
Beispiel #12
0
  /**
   * 查询商品明细
   *
   * @param xml
   * @return
   * @throws DocumentException
   */
  public static Item getItem(String xml) throws Exception {
    Item item = new Item();
    Document document = formatStr2Doc(xml);
    Element rootElt = document.getRootElement();
    Element element = rootElt.element("Item");
    item.setTitle(element.elementText("Title"));
    item.setCurrency(element.elementText("Currency"));
    item.setCountry(element.elementText("Country"));
    item.setSite(element.elementText("Site"));
    item.setPostalCode(element.elementText("PostalCode"));
    item.setLocation(element.elementText("Location"));
    item.setItemID(element.elementText("ItemID"));
    item.setHitCounter(element.elementText("HitCounter"));
    item.setAutoPay(element.elementText("AutoPay").equals("true") ? true : false);
    item.setGiftIcon(element.elementText("GiftIcon"));
    item.setListingDuration(element.elementText("ListingDuration"));
    item.setQuantity(Integer.parseInt(element.elementText("Quantity")));
    item.setPayPalEmailAddress(element.elementText("PayPalEmailAddress"));
    item.setGetItFast("false".equals(element.elementText("GetItFast")) ? false : true);
    item.setPrivateListing("true".equals(element.elementText("PrivateListing")) ? true : false);
    item.setDispatchTimeMax(Integer.parseInt(element.elementText("DispatchTimeMax")));
    item.setListingDuration(element.elementText("ListingDuration"));
    item.setDescription(element.elementText("Description"));
    item.setSKU(element.elementText("SKU"));
    item.setConditionID(
        Integer.parseInt(
            element.elementText("CategoryID") == null
                ? "1000"
                : element.elementText("CategoryID")));
    PrimaryCategory pc = new PrimaryCategory();
    pc.setCategoryID(element.element("PrimaryCategory").elementText("CategoryID"));

    item.setPrimaryCategory(pc);
    String listType = "";
    if ("FixedPriceItem".equals(element.elementText("ListingType"))) {
      if (element.element("Variations") != null) {
        listType = "2";
      } else {
        listType = element.elementText("ListingType");
      }
    } else {
      listType = element.elementText("ListingType");
    }
    item.setListingType(listType);
    // 自定义属性
    Element elspe = element.element("ItemSpecifics");
    if (elspe != null) {
      ItemSpecifics itemSpecifics = new ItemSpecifics();
      Iterator<Element> itnvl = elspe.elementIterator("NameValueList");
      List<NameValueList> linvl = new ArrayList<NameValueList>();
      while (itnvl.hasNext()) {
        Element nvl = itnvl.next();
        NameValueList nvli = new NameValueList();
        nvli.setName(nvl.elementText("Name"));
        List<String> listr = new ArrayList();
        Iterator<Element> itval = nvl.elementIterator("Value");
        while (itval.hasNext()) {
          listr.add(itval.next().getText());
        }
        nvli.setValue(listr);
        linvl.add(nvli);
      }
      itemSpecifics.setNameValueList(linvl);
    }
    // 图片信息
    Element pice = element.element("PictureDetails");
    if (pice != null) {
      PictureDetails pd = new PictureDetails();
      if (pice.elementText("GalleryType") != null) {
        pd.setGalleryType(pice.elementText("GalleryType"));
      }
      if (pice.elementText("PhotoDisplay") != null) {
        pd.setPhotoDisplay(pice.elementText("PhotoDisplay"));
      }
      if (pice.elementText("GalleryURL") != null) {
        String url = pice.elementText("GalleryURL");
        if (url.indexOf("?") > 0) {
          url.substring(0, url.indexOf("?"));
        }
        pd.setGalleryURL(url);
      }
      Iterator<Element> itpicurl = pice.elementIterator("PictureURL");
      List<String> urlli = new ArrayList();
      while (itpicurl.hasNext()) {
        Element url = itpicurl.next();
        String urlstr = url.getStringValue();
        if (urlstr.indexOf("?") > 0) {
          urlstr = urlstr.substring(0, urlstr.indexOf("?"));
        }
        urlli.add(urlstr);
      }
      pd.setPictureURL(urlli);
      item.setPictureDetails(pd);
    }
    // 取得退货政策并封装
    Element returne = element.element("ReturnPolicy");
    ReturnPolicy rp = new ReturnPolicy();
    rp.setRefundOption(returne.elementText("RefundOption"));
    rp.setReturnsWithinOption(returne.elementText("ReturnsWithinOption"));
    rp.setReturnsAcceptedOption(returne.elementText("ReturnsAcceptedOption"));
    rp.setDescription(returne.elementText("Description"));
    rp.setShippingCostPaidByOption(returne.elementText("ShippingCostPaidByOption"));
    item.setReturnPolicy(rp);
    // 买家要求
    BuyerRequirementDetails brd = new BuyerRequirementDetails();
    MaximumItemRequirements mirs = new MaximumItemRequirements();
    Element buyere = element.element("BuyerRequirementDetails");
    if (buyere != null) {
      Element maxiteme = buyere.element("MaximumItemRequirements");
      if (maxiteme != null) {
        if (maxiteme.elementText("MaximumItemCount") != null) {
          mirs.setMaximumItemCount(Integer.parseInt(maxiteme.elementText("MaximumItemCount")));
        }
        if (maxiteme.elementText("MinimumFeedbackScore") != null) {
          mirs.setMinimumFeedbackScore(
              Integer.parseInt(maxiteme.elementText("MinimumFeedbackScore")));
        }
        brd.setMaximumItemRequirements(mirs);
      }

      Element maxUnpaid = buyere.element("MaximumUnpaidItemStrikesInfo");
      if (maxUnpaid != null) {
        MaximumUnpaidItemStrikesInfo muis = new MaximumUnpaidItemStrikesInfo();
        String count = maxUnpaid.elementText("Count");
        muis.setCount(Integer.parseInt(count));
        muis.setPeriod(maxUnpaid.elementText("Period"));
        brd.setMaximumUnpaidItemStrikesInfo(muis);
      }

      Element maxPolicy = buyere.element("MaximumBuyerPolicyViolations");
      if (maxPolicy != null) {
        MaximumBuyerPolicyViolations mbpv = new MaximumBuyerPolicyViolations();
        mbpv.setCount(Integer.parseInt(maxPolicy.elementText("Count")));
        mbpv.setPeriod(maxPolicy.elementText("Period"));
        brd.setMaximumBuyerPolicyViolations(mbpv);
      }
      if (buyere.elementText("LinkedPayPalAccount") != null) {
        brd.setLinkedPayPalAccount(
            buyere.elementText("LinkedPayPalAccount").equals("true") ? true : false);
      }
      if (buyere.elementText("ShipToRegistrationCountry") != null) {
        brd.setShipToRegistrationCountry(
            buyere.elementText("ShipToRegistrationCountry").equals("true") ? true : false);
      }
      item.setBuyerRequirementDetails(brd);
    }
    // 运输选项
    ShippingDetails sd = new ShippingDetails();
    Element elsd = element.element("ShippingDetails");
    Iterator<Element> itershipping = elsd.elementIterator("ShippingServiceOptions");
    List<ShippingServiceOptions> lisso = new ArrayList();
    // 国内运输
    while (itershipping.hasNext()) {
      Element shipping = itershipping.next();
      ShippingServiceOptions sso = new ShippingServiceOptions();
      sso.setShippingService(shipping.elementText("ShippingService"));
      if (shipping.elementText("ShippingServiceCost") != null) {
        sso.setShippingServiceCost(
            new ShippingServiceCost(
                shipping.attributeValue("currencyID"),
                Double.parseDouble(shipping.elementText("ShippingServiceCost"))));
      }
      sso.setShippingServicePriority(
          Integer.parseInt(shipping.elementText("ShippingServicePriority")));
      if (shipping.elementText("FreeShipping") != null) {
        sso.setFreeShipping(shipping.elementText("FreeShipping").equals("true") ? true : false);
      }
      ShippingServiceAdditionalCost ssac = new ShippingServiceAdditionalCost();
      ssac.setValue(
          Double.parseDouble(
              shipping.elementText("ShippingServiceAdditionalCost") != null
                  ? shipping.elementText("ShippingServiceAdditionalCost")
                  : "0"));
      sso.setShippingServiceAdditionalCost(ssac);
      ShippingSurcharge ss = new ShippingSurcharge();
      ss.setValue(
          Double.parseDouble(
              shipping.elementText("ShippingSurcharge") != null
                  ? shipping.elementText("ShippingSurcharge")
                  : "0"));
      sso.setShippingSurcharge(ss);
      lisso.add(sso);
    }
    if (lisso.size() > 0) {
      sd.setShippingServiceOptions(lisso);
    }
    // 不运送到的国家
    Iterator<Element> excEl = elsd.elementIterator("ExcludeShipToLocation");
    List<String> liex = new ArrayList<String>();
    while (excEl.hasNext()) {
      Element els = excEl.next();
      liex.add(els.getText());
    }
    if (liex.size() > 0) {
      sd.setExcludeShipToLocation(liex);
    }
    // 国际运输
    Iterator<Element> iteInt = elsd.elementIterator("InternationalShippingServiceOption");
    List<InternationalShippingServiceOption> liint =
        new ArrayList<InternationalShippingServiceOption>();
    while (iteInt.hasNext()) {
      Element intel = iteInt.next();
      InternationalShippingServiceOption isso = new InternationalShippingServiceOption();
      isso.setShippingService(intel.elementText("ShippingService"));
      isso.setShippingServiceCost(
          new ShippingServiceCost(
              intel.attributeValue("currencyID"),
              Double.parseDouble(intel.elementText("ShippingServiceCost"))));
      Iterator<Element> iteto = intel.elementIterator("ShipToLocation");
      List<String> listr = new ArrayList();
      while (iteto.hasNext()) {
        listr.add(iteto.next().getText());
      }
      isso.setShipToLocation(listr);
      isso.setShippingServicePriority(
          Integer.parseInt(intel.elementText("ShippingServicePriority")));

      ShippingServiceAdditionalCost ssac = new ShippingServiceAdditionalCost();
      ssac.setValue(
          Double.parseDouble(
              intel.elementText("ShippingServiceAdditionalCost") != null
                  ? intel.elementText("ShippingServiceAdditionalCost")
                  : "0"));
      isso.setShippingServiceAdditionalCost(ssac);
      liint.add(isso);
    }
    if (liint.size() > 0) {
      sd.setInternationalShippingServiceOption(liint);
    }
    // 计算所需的长宽高
    Element re = elsd.element("CalculatedShippingRate");
    if (re != null) {
      CalculatedShippingRate csr = new CalculatedShippingRate();
      if (re.elementText("InternationalPackagingHandlingCosts") != null) {
        csr.setPackagingHandlingCosts(
            new PackagingHandlingCosts(
                re.attributeValue("currencyID"),
                Double.parseDouble(re.elementText("InternationalPackagingHandlingCosts"))));
      }
      if (re.elementText("OriginatingPostalCode") != null) {
        csr.setOriginatingPostalCode(re.elementText("OriginatingPostalCode"));
      }
      if (re.elementText("PackageDepth") != null) {
        csr.setPackageDepth(Double.parseDouble(re.elementText("PackageDepth")));
      }
      if (re.elementText("PackageLength") != null) {
        csr.setPackageLength(Double.parseDouble(re.elementText("PackageLength")));
      }
      if (re.elementText("PackageWidth") != null) {
        csr.setPackageWidth(Double.parseDouble(re.elementText("PackageWidth")));
      }
      if (re.elementText("ShippingIrregular") != null) {
        csr.setShippingIrregular(Boolean.parseBoolean(re.elementText("ShippingIrregular")));
      }
      if (re.elementText("ShippingPackage") != null) {
        csr.setShippingPackage(re.elementText("ShippingPackage"));
      }
      if (re.elementText("WeightMajor") != null) {
        csr.setWeightMajor(Double.parseDouble(re.elementText("WeightMajor")));
      }
      if (re.elementText("WeightMinor") != null) {
        csr.setWeightMinor(Double.parseDouble(re.elementText("WeightMinor")));
      }
      sd.setCalculatedShippingRate(csr);
    }
    sd.setShippingType(elsd.elementText("ShippingType"));
    item.setShippingDetails(sd);
    // 卖家信息
    Seller seller = new Seller();
    Element elsel = element.element("Seller");
    seller.setUserID(elsel.elementText("UserID"));
    seller.setEmail(elsel.elementText("Email"));
    item.setSeller(seller);
    // 多属性
    Element vartions = element.element("Variations");
    if (vartions != null) {
      Iterator<Element> elvar = vartions.elementIterator("Variation");
      List<Variation> livar = new ArrayList();
      while (elvar.hasNext()) {
        Element ele = elvar.next();
        Variation var = new Variation();
        var.setSKU(ele.elementText("SKU"));
        var.setQuantity(
            Integer.parseInt(ele.elementText("Quantity"))
                - Integer.parseInt(ele.element("SellingStatus").elementText("QuantitySold")));
        var.setStartPrice(
            new StartPrice(
                ele.attributeValue("currencyID"),
                Double.parseDouble(ele.elementText("StartPrice"))));
        Element elvs = ele.element("VariationSpecifics");
        Iterator<Element> elnvl = elvs.elementIterator("NameValueList");
        List<NameValueList> linvl = new ArrayList();
        while (elnvl.hasNext()) {
          Element elment = elnvl.next();
          NameValueList nvl = new NameValueList();
          nvl.setName(elment.elementText("Name"));
          List<String> li = new ArrayList<String>();
          li.add(elment.elementText("Value"));
          nvl.setValue(li);
          linvl.add(nvl);
        }
        List<VariationSpecifics> livs = new ArrayList();
        VariationSpecifics vs = new VariationSpecifics();
        vs.setNameValueList(linvl);
        livs.add(vs);
        var.setVariationSpecifics(livs);
        livar.add(var);
      }
      Variations vtions = new Variations();
      vtions.setVariation(livar);
      // 多属性值
      Element elvss = vartions.element("VariationSpecificsSet");
      Iterator<Element> itele = elvss.elementIterator("NameValueList");
      List<NameValueList> linvl = new ArrayList();
      while (itele.hasNext()) {
        Element nvlel = itele.next();
        NameValueList nvl = new NameValueList();
        nvl.setName(nvlel.elementText("Name"));
        Iterator<Element> itvalue = nvlel.elementIterator("Value");
        List<String> livalue = new ArrayList();
        while (itvalue.hasNext()) {
          Element value = itvalue.next();
          livalue.add(value.getText());
        }
        nvl.setValue(livalue);
        linvl.add(nvl);
      }
      VariationSpecificsSet vss = new VariationSpecificsSet();
      vss.setNameValueList(linvl);
      vtions.setVariationSpecificsSet(vss);
      // 多属性图片信息
      Pictures pic = new Pictures();
      Element elpic = vartions.element("Pictures");
      pic.setVariationSpecificName(elpic.elementText("VariationSpecificName"));
      Iterator<Element> iturl = elpic.elementIterator("VariationSpecificPictureSet");
      List<VariationSpecificPictureSet> livsps = new ArrayList();
      while (iturl.hasNext()) {
        Element urle = iturl.next();
        VariationSpecificPictureSet vsps = new VariationSpecificPictureSet();
        vsps.setVariationSpecificValue(urle.elementText("VariationSpecificValue"));
        Iterator<Element> url = urle.elementIterator("PictureURL");
        List li = new ArrayList();
        while (url.hasNext()) {
          Element e = url.next();
          String urlstr = e.getText();
          if (urlstr.indexOf("?") > 0) {
            urlstr = urlstr.substring(0, urlstr.indexOf("?"));
          }
          li.add(urlstr);
        }
        vsps.setPictureURL(li);
        livsps.add(vsps);
      }
      pic.setVariationSpecificPictureSet(livsps);
      vtions.setPictures(pic);

      item.setVariations(vtions);
    } else {
      Element el = element.element("StartPrice");
      item.setStartPrice(
          new StartPrice(el.attributeValue("currencyID"), Double.parseDouble(el.getText())));
      if (element.element("BuyItNowPrice") != null) {
        item.setBuyItNowPrice(Double.parseDouble(element.elementText("BuyItNowPrice")));
      }
      if (element.element("ReservePrice") != null) {
        item.setReservePrice(Double.parseDouble(element.elementText("ReservePrice")));
      }
    }
    return item;
  }