Beispiel #1
0
  /**
   * 生成sel的document
   *
   * @param normalName normal普通状态的图片名
   * @param specialName 特殊状态(pressed按下/checked选中)的图片名
   * @param end 特殊状态(pressed按下/checked选中)后缀名
   * @return
   */
  public static Document createSelector(String normalName, String specialName, String end) {
    Document doc = XmlUtil.read("res\\drawable\\sel.xml");
    Element rootElement = doc.getRootElement();

    List<Element> elements = XmlUtil.getAllElements(doc);

    for (Element element : elements) {
      Attribute attr = element.attribute("drawable");
      if (attr == null) {
        continue;
      }
      String value = attr.getStringValue();
      if (value.contains(end)) {
        // 替换特殊状态(pressed/checked)的item加后缀
        value = value.replace(end, specialName);
        attr.setValue(value);
      } else if (element.attributeCount() > 1) {
        // 移除不需要的element
        rootElement.remove(element);
      } else {
        // normal状态的item不加后缀
        value = value.replace("normal", normalName);
        attr.setValue(value);
      }
    }

    return doc;
  }
  public void processDiscoItemsResponse(JID from, List<Element> items) throws ComponentException {

    for (Element item : items) {
      Attribute name = item.attribute("name");
      if (name != null && name.getStringValue().equals(BUDDYCLOUD_SERVER)) {
        remoteChannelDiscoveryStatus.put(from.toString(), DISCOVERED);
        setDiscoveredServer(from.toString(), item.attributeValue("jid"));
        sendFederatedRequests(from.toString());
        return;
      }
    }
    IQ infoRequest = new IQ(IQ.Type.get);
    infoRequest.setFrom(localServer);
    infoRequest.getElement().addElement("query", JabberPubsub.NS_DISCO_INFO);

    remoteServerItemsToProcess.put(from.toString(), items.size());
    String infoRequestId;
    for (Element item : items) {
      infoRequestId = getId() + ":info";
      infoRequest.setTo(item.attributeValue("jid"));
      infoRequest.setID(infoRequestId);
      remoteServerInfoRequestIds.put(infoRequestId, from.toString());
      component.sendPacket(infoRequest.createCopy());
    }
    remoteChannelDiscoveryStatus.put(from.toString(), DISCO_INFO);
  }
Beispiel #3
0
 public void visit(Attribute node) {
   String text = node.getStringValue();
   extractUsedProperties(text);
 }
  @SuppressWarnings("unchecked")
  public static FaultSectionPrefData fromXMLMetadata(Element el) {

    int sectionId = Integer.parseInt(el.attributeValue("sectionId"));
    String sectionName = el.attributeValue("sectionName");
    String shortName = el.attributeValue("shortName");
    double aveLongTermSlipRate = Double.parseDouble(el.attributeValue("aveLongTermSlipRate"));
    double aveDip = Double.parseDouble(el.attributeValue("aveDip"));
    double aveRake = Double.parseDouble(el.attributeValue("aveRake"));
    double aveUpperDepth = Double.parseDouble(el.attributeValue("aveUpperDepth"));
    double aveLowerDepth = Double.parseDouble(el.attributeValue("aveLowerDepth"));
    double aseismicSlipFactor = Double.parseDouble(el.attributeValue("aseismicSlipFactor"));
    float dipDirection = Float.parseFloat(el.attributeValue("dipDirection"));

    Attribute parentSectNameAtt = el.attribute("parentSectionName");
    String parentSectionName;
    if (parentSectNameAtt != null) parentSectionName = parentSectNameAtt.getStringValue();
    else parentSectionName = null;

    Attribute parentSectIDAtt = el.attribute("parentSectionId");
    int parentSectionId;
    if (parentSectIDAtt != null)
      parentSectionId = Integer.parseInt(parentSectIDAtt.getStringValue());
    else parentSectionId = -1;

    Element traceEl = el.element("FaultTrace");

    String traceName = traceEl.attributeValue("name");

    FaultTrace trace = new FaultTrace(traceName);

    Iterator<Element> traceIt = (Iterator<Element>) traceEl.elementIterator();
    while (traceIt.hasNext()) {
      Element locEl = traceIt.next();

      trace.add(Location.fromXMLMetadata(locEl));
    }

    boolean connector = false;
    Attribute connectorAtt = el.attribute("connector");
    if (connectorAtt != null) connector = Boolean.parseBoolean(connectorAtt.getStringValue());

    Region zonePolygon = null;
    Element zonePolygonEl = el.element("ZonePolygon");
    if (zonePolygonEl != null) {
      zonePolygon = Region.fromXMLMetadata(zonePolygonEl);
    }

    FaultSectionPrefData data = new FaultSectionPrefData();
    data.setSectionId(sectionId);
    data.setSectionName(sectionName);
    data.setShortName(shortName);
    data.setAveSlipRate(aveLongTermSlipRate);
    data.setAveDip(aveDip);
    data.setAveRake(aveRake);
    data.setAveUpperDepth(aveUpperDepth);
    data.setAveLowerDepth(aveLowerDepth);
    data.setAseismicSlipFactor(aseismicSlipFactor);
    Attribute couplingAtt = el.attribute("couplingCoeff");
    if (couplingAtt != null)
      data.setCouplingCoeff(Double.parseDouble(couplingAtt.getStringValue()));
    data.setDipDirection(dipDirection);
    data.setFaultTrace(trace);
    data.setParentSectionName(parentSectionName);
    data.setParentSectionId(parentSectionId);
    data.setConnector(connector);
    data.setZonePolygon(zonePolygon);

    Attribute lastEventAtt = el.attribute("dateOfLastEventMillis");
    if (lastEventAtt != null)
      data.setDateOfLastEvent(Long.parseLong(lastEventAtt.getStringValue()));
    Attribute lastSlipAtt = el.attribute("slipInLastEvent");
    if (lastSlipAtt != null)
      data.setSlipInLastEvent(Double.parseDouble(lastSlipAtt.getStringValue()));

    return data;
  }