Office: changed the artefact uri delimiter from / to \::
Signed-off-by: Dusan Kalanj <kalanj@chalmers.se>
diff --git a/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraExcelRow.java b/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraExcelRow.java
index fd0fcb5..6891c1f 100644
--- a/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraExcelRow.java
+++ b/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraExcelRow.java
@@ -62,11 +62,6 @@
private static final String CELL_DELIMITER = " | ";
/**
- * Delimiter between sheetId and rowId as used in the uri.
- */
- private static final String ID_DELIMITER = "-";
-
- /**
* A constant that is used if the row index isn't found when opening object
* details.
*/
@@ -122,7 +117,7 @@
Matcher m = p.matcher(rowBuilder);
String rowContent = (m.replaceAll(" ")).trim();
- String rowUriEnd = row.getSheet().getSheetName() + ID_DELIMITER + rowId;
+ String rowUriEnd = row.getSheet().getSheetName() + CapraOfficeObject.URI_DELIMITER + rowId;
String rowUri = CapraOfficeObject.createUri(officeFile, rowUriEnd);
this.setData(rowContent);
@@ -215,14 +210,14 @@
*/
public String getSheetName() {
String itemId = getId();
- int lastIndexOfDelimiter = itemId.lastIndexOf(ID_DELIMITER);
+ int lastIndexOfDelimiter = itemId.indexOf(CapraOfficeObject.URI_DELIMITER);
return itemId.substring(0, lastIndexOfDelimiter);
}
private String getRowIdFromObjectUri() {
String itemId = getId();
- int lastIndexOfDelimiter = itemId.lastIndexOf(ID_DELIMITER);
- return itemId.substring(lastIndexOfDelimiter + 1);
+ int lastIndexOfDelimiter = itemId.indexOf(CapraOfficeObject.URI_DELIMITER);
+ return itemId.substring(lastIndexOfDelimiter + CapraOfficeObject.URI_DELIMITER.length());
}
private String getRowIdFromExcelRow(Row row) {
diff --git a/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraOfficeObject.java b/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraOfficeObject.java
index a48da83..bf16450 100644
--- a/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraOfficeObject.java
+++ b/org.eclipse.capra.ui.office/src/org/eclipse/capra/ui/office/objects/CapraOfficeObject.java
@@ -34,6 +34,12 @@
public static final String XLSX = "xlsx";
/**
+ * The String that separates the file-path from the object-id in the
+ * OfficeObject uri.
+ */
+ public static final String URI_DELIMITER = "\\\\::";
+
+ /**
* The description of the object (row in Excel, requirement in Word)
*/
private String data = "";
@@ -90,16 +96,16 @@
* Returns the ID of the OfficeObject.
*/
public String getId() {
- int lastDelimiterIndex = uri.lastIndexOf(File.separator);
- return uri.substring(lastDelimiterIndex + 1);
+ int firstDelimiterIndex = uri.indexOf(URI_DELIMITER);
+ return uri.substring(firstDelimiterIndex + URI_DELIMITER.length());
}
/**
* Returns the File reference of the file that contains the OfficeObject
*/
public File getFile() {
- int lastDelimiterIndex = uri.lastIndexOf(File.separator);
- return new File(uri.substring(0, lastDelimiterIndex));
+ int firstDelimiterIndex = uri.indexOf(URI_DELIMITER);
+ return new File(uri.substring(0, firstDelimiterIndex));
}
/**
@@ -109,9 +115,9 @@
* @return a readable name of the OfficeObject
*/
public String getName() {
- return getFile().getName() + File.separator + getId();
+ return getFile().getName() + URI_DELIMITER + getId();
}
-
+
/**
* Extracts the ID of the object from uri of the OfficeObject.
*
@@ -120,8 +126,8 @@
* @return ID of the object
*/
public static String getIdFromUri(String uri) {
- int lastDelimiterIndex = uri.lastIndexOf(File.separator);
- return uri.substring(lastDelimiterIndex + 1);
+ int firstDelimiterIndex = uri.indexOf(URI_DELIMITER);
+ return uri.substring(firstDelimiterIndex + URI_DELIMITER.length());
}
/**
@@ -132,8 +138,8 @@
* @return file-path of the file that contains the object
*/
public static String getFilePathFromUri(String uri) {
- int lastDelimiterIndex = uri.lastIndexOf(File.separator);
- return uri.substring(0, lastDelimiterIndex);
+ int delimiterIndex = uri.indexOf(URI_DELIMITER);
+ return uri.substring(0, delimiterIndex);
}
/**
@@ -166,7 +172,7 @@
* @return a uri of the object in the form of filePath/objectID
*/
public static String createUri(File officeFile, Object objectId) {
- return officeFile.getAbsolutePath() + File.separator + objectId;
+ return officeFile.getAbsolutePath() + URI_DELIMITER + objectId;
}
/**