示例#1
0
    private PertSource buildFromXML(String elemName, Attributes attrs) throws IOException {
      String id = AttributeExtractor.extractAttribute(elemName, attrs, "pertSrc", "id", true);

      String src = AttributeExtractor.extractAttribute(elemName, attrs, "pertSrc", "src", true);

      String type = AttributeExtractor.extractAttribute(elemName, attrs, "pertSrc", "type", true);
      type = CharacterEntityMapper.unmapEntities(type, false);

      String proxyKey =
          AttributeExtractor.extractAttribute(elemName, attrs, "pertSrc", "proxy", false);

      String proxySign =
          AttributeExtractor.extractAttribute(elemName, attrs, "pertSrc", "proxySign", false);
      if ((proxySign == null) && (proxyKey != null)) {
        throw new IOException();
      }

      String notes =
          AttributeExtractor.extractAttribute(elemName, attrs, "pertSrc", "notes", false);

      PertSource nps = new PertSource(id, src, type, proxyKey, proxySign);
      if (notes != null) {
        nps.setNotes(Splitter.stringBreak(notes, ",", 0, false));
      }

      return (nps);
    }
  /**
   * ************************************************************************* * * Handle the
   * attributes for the keyword *
   */
  public static ExpressionEntry buildFromXML(BTState appState, String elemName, Attributes attrs)
      throws IOException {
    if (!elemName.equals("data")) {
      return (null);
    }

    String region = null;
    String time = null;
    String expr = null;
    String confidence = null;
    String startStrategy = null;
    String endStrategy = null;
    String variable = null;
    String srcStr = null;
    String stratSrcStr = null;

    if (attrs != null) {
      int count = attrs.getLength();
      for (int i = 0; i < count; i++) {
        String key = attrs.getQName(i);
        if (key == null) {
          continue;
        }
        String val = attrs.getValue(i);
        if (key.equals("region")) {
          region = CharacterEntityMapper.unmapEntities(val, false);
        } else if (key.equals("time")) {
          time = val;
        } else if (key.equals("expr")) {
          expr = val;
        } else if (key.equals("confidence")) {
          confidence = val;
        } else if (key.equals("starttype")) {
          startStrategy = val;
        } else if (key.equals("endtype")) {
          endStrategy = val;
        } else if (key.equals("value")) {
          variable = val;
        } else if (key.equals("source")) {
          srcStr = val;
        } else if (key.equals("stratSource")) {
          stratSrcStr = val;
        }
      }
    }

    if ((region == null) || (time == null) || (expr == null)) {
      throw new IOException();
    }

    return (new ExpressionEntry(
        appState,
        region,
        time,
        expr,
        srcStr,
        confidence,
        stratSrcStr,
        startStrategy,
        endStrategy,
        variable));
  }