Пример #1
0
 /**
  * You must call {@link StreamProvider#isApplicable(String,
  * com.intellij.openapi.components.RoamingType)} before
  */
 public static void doSendContent(
     @NotNull StreamProvider provider,
     @NotNull String fileSpec,
     @NotNull Parent element,
     @NotNull RoamingType type,
     boolean async)
     throws IOException {
   // we should use standard line-separator (\n) - stream provider can share file content on any OS
   BufferExposingByteArrayOutputStream content = elementToBytes(element, false);
   provider.saveContent(fileSpec, content.getInternalBuffer(), content.size(), type, async);
 }
Пример #2
0
  public static void sendContent(
      @NotNull StreamProvider provider,
      @NotNull String fileSpec,
      @NotNull Parent element,
      @NotNull RoamingType type,
      boolean async) {
    if (!provider.isApplicable(fileSpec, type)) {
      return;
    }

    try {
      doSendContent(provider, fileSpec, element, type, async);
    } catch (IOException e) {
      LOG.warn(e);
    }
  }
Пример #3
0
  public static void Parse(String filename)
      throws SAXException, ParserConfigurationException, IOException {
    if (debug) {
      System.out.println("PARSE: " + filename);
    }

    if (filesparsed.get(filename) == null) {
      try {
        Parse(streamProvider.getStream(dirDefault + filename), filename);
        filesparsed.put(filename, Boolean.TRUE);
      } catch (Exception e) {
        System.out.println("EXCEPTION: " + e.getMessage());
        e.printStackTrace();
        System.exit(-1);
      }
    }
    if (debug) {
      System.out.println("ENDPARSE: " + filename);
    }
  }
Пример #4
0
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {

    tags.add(qName);
    if (debug) {
      System.out.println("Start Element: " + qName + " parent: " + getParent());
    }
    dumpAttrs(attributes);
    lastText = "";

    if (qName.equalsIgnoreCase("object")
        && (getParent().equals("model") || getParent().equals("component"))) {
      pushHandler(new ObjectHandler(isService));
    } else if (qName.equalsIgnoreCase(ParamHandler.TOP_TAG)
        && getParent().equals("object")
        && !isAnyChildOf("profile")) {
      ObjectHandler oh = (ObjectHandler) getHandler();
      pushHandler(new ParamHandler((oh != null ? oh.getParam().getName() : "")));
    } else if (qName.equalsIgnoreCase(DatatypeHandler.TOP_TAG)
        && getParent().equals("dm:document")) {
      pushHandler(new DatatypeHandler());
    } else if (qName.equalsIgnoreCase(BibiliographyHandler.TOP_TAG)
        && getParent().equals("dm:document")) {
      pushHandler(new BibiliographyHandler());
    } else if (qName.equalsIgnoreCase("component")) {
      if (getParent().equals("import")) {
        String n = attributes.getValue("name");
        dumpTags();
        if (n != null) {
          // TODO really import or maybe do nothing
        }
      } else if (getParent().equals("model")) {
        dumpTags();
        String path = attributes.getValue("path");
        String ref = attributes.getValue("ref");
        if (ref != null && path != null) {
          List<Parameter> cs = components.get(ref);
          if (cs != null) {
            for (Parameter p : cs) {
              // copy parameters
              Parameter pc = p.clone();
              pc.setName(path + pc.getName());
              Parameter.Add(pc);
            }
          }
        }
      } else {
        dumpTags();
        currentComponent = attributes.getValue("name");
        pushHandler(new ComponentHandler());
      }
    } else if (qName.equalsIgnoreCase("model")) {
      try {
        isService = attributes.getValue("isService").equals("true");
      } catch (NullPointerException e) {
      }
      Model.setName(attributes.getValue("name"));
    } else if (qName.equalsIgnoreCase("import")) {
      String fname = attributes.getValue("file");
      InputStream is = streamProvider.getStream(dirDefault + fname);
      if (is == null) {
        String fnameBase = fname.substring(0, fname.length() - 4);
        fname = fnameBase + "-0.xml";
        is = streamProvider.getStream(dirDefault + fname);
      }

      try {
        Parse(is, fname);
      } catch (Exception e) {
        e.printStackTrace();
        System.out.println("EXCEPTION: (import " + fname + ") " + e.getMessage());
      }
    } else if (qName.equalsIgnoreCase("profile")) {
      pushHandler(new NullHandler(qName));
    } else if (getParent().equals("")) {
      handlers.clear();
    } else {
    }

    DefaultHandler h = getHandler();
    if (h != null) {
      h.startElement(uri, localName, qName, attributes);
    }
  }
Пример #5
0
 public static void delete(
     @NotNull StreamProvider provider, @NotNull String fileSpec, @NotNull RoamingType type) {
   if (provider.isApplicable(fileSpec, type)) {
     provider.delete(fileSpec, type);
   }
 }