Package net.sf.graphiti.model

Examples of net.sf.graphiti.model.FileFormat


   *            The {@link OutputStream} to write to.
   */
  public void write(String path, OutputStream byteStream) {
    Element element = null;
    Configuration configuration = graph.getConfiguration();
    FileFormat format = configuration.getFileFormat();

    List<Transformation> transformations = format
        .getExportTransformations();
    try {
      for (Transformation transformation : transformations) {
        if (transformation.isXslt()) {
          if (element == null) {
            // writes graph
            element = writeGraph();
          }
         
          XsltTransformer transformer = new XsltTransformer(
              configuration.getContributorId(),
              transformation.getFileName());
          transformer.setParameter("path", path);
          element = transformer.transformDomToDom(element);
        } else {
          transformation.getInstance().transform(graph, byteStream);
          return;
        }
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    if (format.getContentType().equals("text")) {
      String content = element.getTextContent();
      try {
        byteStream.write(content.getBytes());
      } catch (IOException e) {
        // byte stream is a byte array output stream
View Full Code Here


   * @return A {@link Graph} if successful.
   * @throws Exception
   */
  private Graph parse(Configuration configuration, IFile file)
      throws Exception {
    FileFormat format = configuration.getFileFormat();
    List<Transformation> transformations = format
        .getImportTransformations();
    Element element = null;
    if (transformations.isEmpty()) {
      InputStream in = file.getContents();
      element = DomHelper.parse(in).getDocumentElement();
View Full Code Here

  public Graph parse(IFile file) throws IncompatibleConfigurationFile {
    // finds all suitable configurations
    String fileExt = file.getFileExtension();
    List<Configuration> configurations = new ArrayList<Configuration>();
    for (Configuration configuration : this.configurations) {
      FileFormat format = configuration.getFileFormat();
      if (format.getFileExtension().equals(fileExt)) {
        configurations.add(configuration);
      }
    }

    Configuration configuration;
View Full Code Here

      throws CoreException {
    String name = element.getAttribute("name");

    String extension = element.getAttribute("extension");
    String type = element.getAttribute("type");
    FileFormat format = new FileFormat(extension, type);

    IConfigurationElement[] children = element.getChildren("import");
    children = children[0].getChildren();
    parseTransformations(format.getImportTransformations(), children);

    children = element.getChildren("export");
    if (children.length > 0) {
      children = children[0].getChildren();
      parseTransformations(format.getExportTransformations(), children);
    }

    Map<String, ObjectType> graphTypes = parseTypes(element
        .getChildren("graphType"));
    Map<String, ObjectType> vertexTypes = parseTypes(element
View Full Code Here

TOP

Related Classes of net.sf.graphiti.model.FileFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.