Package com.ebay.sdk.attributes.model

Examples of com.ebay.sdk.attributes.model.Attribute


    AttributeType[] attrs = attrSet.getAttribute();
    if( attrs != null ) {
      for (int i = 0; i < attrs.length; i++) {
        int n;
        Attribute attr = (Attribute) attrSet.getAttribute(i);

        Element attrNode = XmlUtil.appendChildNode(doc, attrSetNode, ATTRIBUTE);
        XmlUtil.appendAttributeNode(attrNode, ID, attr.getAttributeID());

        Element valueElement;
        Value val;
        if (attr.getType() == AttributeTypes.ATTR_ID) {
          checkSingleValueListItem(attr);
          val = (Value) attr.getValue(0);

          valueElement = XmlUtil.appendChildNode(doc, attrNode, VALUE);
          XmlUtil.appendAttributeNode(valueElement, ID, val.getValueID().intValue());

          if (val.getValueID().intValue() == (int) ValueIds.OTHER && val.getValueLiteral() != null) {
            // Add one more Attribute node with the same id.
            Element attrOther = XmlUtil.appendChildNode(doc, attrSetNode,
                ATTRIBUTE);
            XmlUtil.appendAttributeNode(attrOther, ID, attr.getAttributeID());

            Node v_e = XmlUtil.appendChildNode(doc, attrOther, VALUE);
            XmlUtil.appendChildNode(doc, v_e, NAME, val.getValueLiteral());
          }
        } else if (attr.getType() == AttributeTypes.ATTR_IDS) {
          for (n = 0; n < attr.getValue().length; n++) {
            Value v_s = (Value) attr.getValue(n);
            valueElement = XmlUtil.appendChildNode(doc, attrNode, VALUE);
            XmlUtil.appendAttributeNode(valueElement, ID, v_s.getValueID().intValue());
          }
        } else if (attr.getType() == AttributeTypes.ATTR_TEXT) {
          checkSingleValueListItem(attr);
          val = (Value) attr.getValue(0);

          valueElement = XmlUtil.appendChildNode(doc, attrNode, VALUE);
          XmlUtil.appendChildNode(doc, valueElement, NAME, val.getValueLiteral());

          /*
                   if( val.ValueId == (int)ValueIds.OTHER )
                   {
                  // Add another attribute node with the same attribute Id
           Node attrOther = XmlUtil.AddChild(doc, attrSetNode, ATTRIBUTE);
           XmlUtil.AddAttributeNode(doc, attrOther, ID, attr.AttributeId.ToString());

                  valueElement = XmlUtil.AddChild(doc, attrOther, VALUE);
           XmlUtil.AddAttributeNode(doc, valueElement, ID, val.ValueId.ToString());
                   }
           */
        } else if (attr.getType() == AttributeTypes.ATTR_TEXT_DATE) {
          checkSingleValueListItem(attr);
          val = (Value) attr.getValue(0);

          valueElement = XmlUtil.appendChildNode(doc, attrNode, VALUE);
          XmlUtil.appendAttributeNode(valueElement, ID, val.getValueID().intValue());

          addDateToValueNode(valueElement, val.getValueLiteral());
        } else {
          // Unsupported attribute type.
          for (n = 0; n < attr.getValue().length; n++) {
          //foreach(IValue v_o in attr.ValueList )
            Value v_o = (Value) attr.getValue(n);
            valueElement = XmlUtil.appendChildNode(doc, attrNode, VALUE);
            XmlUtil.appendChildNode(doc, valueElement, NAME, v_o.getValueLiteral());
            if (v_o.getValueID() != null && v_o.getValueID().intValue() != 0) {
              XmlUtil.appendAttributeNode(valueElement, ID, v_o.getValueID().toString());
            }
View Full Code Here


      return errSet;
    }
    Document xml = attrXmlProvider.getMultipleCSXml(new AttributeSet[]{attrSet});

    for(int i = 0; i < attrs.length; i++ ) {
      Attribute attr = (Attribute)attrSet.getAttribute(i);
      String select = getRuleSelectString(attrSet.getAttributeSetID(), attr.getAttributeID());
      NodeList rules = XPathUtil.selectNodes(select, xml);

      int rCnt = rules.getLength();
      for (int r = 0; r < rCnt; r++) {
        Error err = validateAttr(attr, rules.item(r));
View Full Code Here

    String key;
    Object val;
    AttrInfo info;
    ArrayList al;
    Attribute attr = null;

    while(iter.hasMoreElements())
    {
      key = iter.nextElement().toString();
      val = ht.get(key);
      if (val instanceof ArrayList)
      {
        al = (ArrayList)val;
        cnt = al.size();
        // Option Other
        if (cnt == 2)
        {
          AttrInfo info0 = (AttrInfo)al.get(0);
          AttrInfo info1 = (AttrInfo)al.get(1);
          if (info0.typeId == AttributeTypes.ATTR_ID)
          {
            attr = ExtractAttr2(info0, info1);
            attrSet.add(attr);
          }
          else if (info1.typeId == AttributeTypes.ATTR_ID)
          {
            attr = ExtractAttr2(info1, info0);
            attrSet.add(attr);
          }
          else
          {
            //Unknow type.
          }
        }
        // DateTime
        else if (cnt == 3)
        {
          YMD ymd = new YMD(null, null, null);
          for (int i = 0; i < cnt; i ++)
          {
            info = (AttrInfo)al.get(i);
            switch(info.typeId)
            {
              case AttributeTypes.ATTR_DATE_D:
                ymd.day = info.val[0];
                break;
              case AttributeTypes.ATTR_DATE_M:
                ymd.month = info.val[0];
                break;
              case AttributeTypes.ATTR_DATE_Y:
                ymd.year = info.val[0];
                break;
            }
          }

          YMD.FixYMD(ymd);

          if (ymd.day != null && ymd.month!= null && ymd.year != null)
          {
            info = (AttrInfo)al.get(0);
            ArrayList_removeRange(al, 0, cnt);

            info.typeId = AttributeTypes.ATTR_TEXT_DATE;
            info.val = new String[] { ymd.year + ymd.month + ymd.day };
            al.add(info);

            attr = ExtractAttr(info);
            ((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.COMPLETE_TEXT_DATE));
            //attr.ValueList[0].ValueId = (int)ValueIds.COMPLETE_TEXT_DATE;

            attrSet.add(attr);
          }
        }
      }
      else
      {
        info = (AttrInfo) val;

        // Only year field.
        if( info.typeId == AttributeTypes.ATTR_DATE_Y )
        {
          info.typeId = AttributeTypes.ATTR_DATE_Y;
          info.val = info.val;

          attr = ExtractAttr(info);
          //((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.COMPLETE_TEXT_DATE));
          ((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.TEXT));

          attrSet.add(attr);
        }
        else
        {
          attr = ExtractAttr(info);
          if( attr.getType() == AttributeTypes.ATTR_TEXT )
          {
            ((Value)attr.getValue()[0]).setValueID(new Integer(ValueIds.TEXT));
            //attr.ValueList[0].ValueId = (int) ValueIds.TEXT;
          }

          attrSet.add(attr);
        }
View Full Code Here

TOP

Related Classes of com.ebay.sdk.attributes.model.Attribute

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.