Пример #1
0
  @Override
  public void processElement(String namespaceURI, String localName, RaplaSAXAttributes atts)
      throws RaplaSAXParseException {
    if (!RAPLA_NS.equals(namespaceURI)) return;
    if (localName.equals(RaplaMap.TYPE.getLocalName())) {
      entityMap = new RaplaMapImpl();
      return;
    }
    if (localName.equals("mapentry")) {
      key = getString(atts, "key");
      String value = getString(atts, "value", null);
      if (value != null) {
        try {
          entityMap.putPrivate(key, value);
        } catch (ClassCastException ex) {
          getLogger().error("Mixed maps are currently not supported.", ex);
        }
      }
      return;
    }

    String refid = getString(atts, "idref", null);
    String keyref = getString(atts, "keyref", null);
    RaplaType raplaType = getTypeForLocalName(localName);
    if (refid != null) {
      childReader = null;
      // We ignore the old references from 1.7 that are not compatible
      if (!entityMap.isTypeSupportedAsLink(raplaType)) {
        return;
      }
      String id = getId(raplaType, refid);
      entityMap.putIdPrivate(key, id, raplaType);
    } else if (keyref != null) {
      childReader = null;
      DynamicType type = getDynamicType(keyref);
      if (type != null) {
        String id = ((Entity) type).getId();
        entityMap.putIdPrivate(key, id, DynamicType.TYPE);
      }
    } else {
      childReader = getChildHandlerForType(raplaType);
      delegateElement(childReader, namespaceURI, localName, atts);
    }
  }
Пример #2
0
  @Override
  public void processEnd(String namespaceURI, String localName) throws RaplaSAXParseException {
    if (!RAPLA_NS.equals(namespaceURI)) return;

    if (childReader != null) {
      RaplaObject type = childReader.getType();
      try {
        entityMap.putPrivate(key, type);
      } catch (ClassCastException ex) {
        getLogger().error("Mixed maps are currently not supported.", ex);
      }
    }
    childReader = null;
  }