Exemple #1
0
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {
    ModelReader8Handler.ElementHandler current =
        (myHandlersStack.empty()
            ? (ModelReader8Handler.ElementHandler) null
            : myHandlersStack.peek());
    if (current == null) {
      // root
      current = modelhandler;
    } else {
      current = current.createChild(myValues.peek(), qName, attributes);
    }

    // check required
    for (String attr : current.requiredAttributes()) {
      if (attributes.getValue(attr) == null) {
        throw new SAXParseException("attribute " + attr + " is absent", null);
      }
    }

    Object result = current.createObject(attributes);
    if (myHandlersStack.empty()) {
      myResult = (ModelLoadResult) result;
    }

    // handle attributes
    for (int i = 0; i < attributes.getLength(); i++) {
      String name = attributes.getQName(i);
      String value = attributes.getValue(i);
      current.handleAttribute(result, name, value);
    }
    myHandlersStack.push(current);
    myValues.push(result);
  }
Exemple #2
0
 @Override
 public void characters(char[] array, int start, int len) throws SAXException {
   ModelReader8Handler.ElementHandler current =
       (myHandlersStack.empty()
           ? (ModelReader8Handler.ElementHandler) null
           : myHandlersStack.peek());
   if (current != null) {
     current.handleText(myValues.peek(), new String(array, start, len));
   }
 }
Exemple #3
0
 @Override
 public void endElement(String uri, String localName, String qName) throws SAXException {
   ModelReader8Handler.ElementHandler current = myHandlersStack.pop();
   Object childValue = myValues.pop();
   current.validate(childValue);
   if (myChildHandlersStack.empty()) {
     myResult = (ModelLoadResult) childValue;
   } else {
     ModelReader8Handler.ChildHandler ch = myChildHandlersStack.pop();
     if (ch != null) {
       ch.apply(myValues.peek(), childValue);
     }
   }
 }
Exemple #4
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   SNode result = (SNode) resultObject;
   if ("type".equals(name)) {
     return;
   }
   if ("typeId".equals(name)) {
     fieldlinkMap.addTypeLocation(fieldhelper.readLinkId(value), result);
     return;
   }
   if ("nodeInfo".equals(name)) {
     return;
   }
   if ("role".equals(name)) {
     result.putUserObject("role", fieldhelper.readRole(value));
     return;
   }
   if ("roleId".equals(name)) {
     fieldlinkMap.addRoleLocation(fieldhelper.readLinkId(value), result);
     return;
   }
   if ("id".equals(name)) {
     SNodeId id = jetbrains.mps.smodel.SNodeId.fromString(value);
     if (id == null) {
       throw new SAXParseException("bad node ID", null);
     }
     ((jetbrains.mps.smodel.SNode) result).setId(id);
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #5
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   SModuleReference result = (SModuleReference) resultObject;
   if ("namespace".equals(name)) {
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #6
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   Integer result = (Integer) resultObject;
   if ("version".equals(name)) {
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #7
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   if ("name".equals(name)) {
     return;
   }
   if ("nameId".equals(name)) {
     return;
   }
   if ("value".equals(name)) {
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #8
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   if ("role".equals(name)) {
     return;
   }
   if ("roleId".equals(name)) {
     return;
   }
   if ("targetNodeId".equals(name)) {
     return;
   }
   if ("resolveInfo".equals(name)) {
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #9
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   String[] result = (String[]) resultObject;
   if ("index".equals(name)) {
     return;
   }
   if ("version".equals(name)) {
     return;
   }
   if ("modelUID".equals(name)) {
     return;
   }
   if ("implicit".equals(name)) {
     result[3] = value;
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #10
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   ModelLoadResult result = (ModelLoadResult) resultObject;
   if ("modelUID".equals(name)) {
     return;
   }
   if ("version".equals(name)) {
     int version;
     try {
       version = (value == null ? -1 : Integer.parseInt(value));
     } catch (NumberFormatException e) {
       version = -1;
     }
     fieldmodel.getSModelHeader().setVersion(version);
     return;
   }
   if ("doNotGenerate".equals(name)) {
     fieldmodel.getSModelHeader().setDoNotGenerate(Boolean.parseBoolean(value));
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }
Exemple #11
0
 @Override
 protected void handleAttribute(Object resultObject, String name, String value)
     throws SAXException {
   String result = (String) resultObject;
   if ("type".equals(name)) {
     return;
   }
   if ("typeId".equals(name)) {
     return;
   }
   if ("nodeInfo".equals(name)) {
     return;
   }
   if ("role".equals(name)) {
     return;
   }
   if ("roleId".equals(name)) {
     return;
   }
   if ("id".equals(name)) {
     return;
   }
   super.handleAttribute(resultObject, name, value);
 }