1 /*******************************************************************************
2 * Copyright (c) 2013 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.common.ids.definitions.imports;
14 import org.apache.commons.io.FilenameUtils;
15 import org.eclipse.winery.model.tosca.TImport;
16 import org.eclipse.winery.common.Util;
17 import org.eclipse.winery.common.ids.Namespace;
18 import org.eclipse.winery.common.ids.XMLId;
19 import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
22 * class for import ids (not used for definitions)
24 * // Convention: id of import is filename without extension
26 public class GenericImportId extends TOSCAComponentId {
28 private final String type;
32 * @param type the importType (e.g., MimeTypes.MIMETYPE_XSD)
34 public GenericImportId(Namespace namespace, XMLId xmlId, String type) {
35 super(namespace, xmlId);
39 public GenericImportId(String ns, String id, boolean encoded, String type) {
40 super(ns, id, encoded);
45 * Generates an ImportId based on an TImport object The import has to be an
46 * import created by winery. This method uses the convention that the id is
47 * derived from the location
49 * @param i the TImport element to derive an id from
51 public GenericImportId(TImport i) {
52 this(i.getNamespace(), GenericImportId.getId(i), false, i.getImportType());
55 private static String getId(TImport i) {
56 String fileName = Util.getLastURIPart(i.getLocation());
57 String id = FilenameUtils.removeExtension(fileName);
61 public String getType() {