示例#1
0
  @Override
  void startElement(String qName, Attributes attributes) throws SAXException {

    elementStack.push(qName);

    switch (QNAME.valueOf(qName)) {
      case candles:
        CandleGraph candleGraph = new CandleGraph();
        candleGraph.setPeriod(Integer.valueOf(attributes.getValue("period")));
        candleGraph.setStatus(CandleStatus.getFromValue(attributes.getValue("status")));
        candleGraph.setBoard(attributes.getValue("board"));
        candleGraph.setSeccode(attributes.getValue("seccode"));
        objectStack.push(candleGraph);
        break;

      case candle:
        Candle candle = new Candle();
        candle.setDate(Utils.parseDate(attributes.getValue("date")));
        candle.setOpen(Double.valueOf(attributes.getValue("open")));
        candle.setHigh(Double.valueOf(attributes.getValue("high")));
        candle.setLow(Double.valueOf(attributes.getValue("low")));
        candle.setClose(Double.valueOf(attributes.getValue("close")));
        candle.setVolume(Integer.valueOf(attributes.getValue("volume")));
        String oi = attributes.getValue("oi");
        if (oi != null) {
          candle.setOi(Integer.valueOf(oi));
        }
        objectStack.peek().getCandles().add(candle);
        break;
      default:
        break;
    }
  }
示例#2
0
  @Override
  void endElement(String qName) throws SAXException {

    elementStack.pop();

    switch (QNAME.valueOf(qName)) {
      case candles:
        notifyCompleteElement(objectStack.pop());
        break;

      default:
        break;
    }
  }